gdb for llvm

I don't know how to use gdb for llvm. I follow the manual. But
$gdb opt
can't load opt. I got:
"/usr/dcs/projects/cs426/jliu7/llvm/tools/Debug/opt": not in executable
format: File format not recognized

Try one of "gdb64" or "gdb-64".


How can I run llvm-gcc in such a way that does not perform
optimizations like constant propagation and dead code elimination?

In particular, I'm trying to analyze cases where the code will look

  int *op;
  int *ip=(int*)malloc(sizeof(int));
  /* store/read into *ip */

but llvm-gcc transforms the above code to

  int *ip=(int*)malloc(sizeof(int));
  /* store/read into *ip */

which is a very reasonable thing to do, except that I _need_ to test
cases where I allocate objects with one pointer and deallocate with


As far as I know, there isn't. The gcc front-end has only been modified
to emit code in LLVM syntax, it will do whatever it regularly does,
which includes some optimizations.

The only solution I know of is to write LLVM assembly directly and then
use the LLVM assembler to make .bc files for input into opt and friends.
That will not eliminate dead code or constant-propagate.



A copy operation like op=ip get's eliminated because it is redundant in
SSA form. Both become a single virtual register.

Instead, do the following:
  int **tmp = alloca int*;
  ip = malloc...
  store ip, tmp;
  load tmp, op;

Now, if gccas may run mem2reg, in which case tmp will be eliminated by
promoting from stack to register (and then folded away as before). If
so, pass tmp to some procedure and it will be left on the stack.