[LLVMdev] running llvmgcc without optimization?

Vikram S. Adve vadve at cs.uiuc.edu
Tue Nov 19 21:44:01 PST 2002


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.


> -----Original Message-----
> From: llvmdev-admin at cs.uiuc.edu 
> [mailto:llvmdev-admin at cs.uiuc.edu] On Behalf Of Juan Nicolas Ruiz
> Sent: Tuesday, November 19, 2002 8:49 PM
> To: llvmdev at cs.uiuc.edu
> Subject: [LLVMdev] running llvmgcc without optimization?
> 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
> like:
>   int *op;
>   int *ip=(int*)malloc(sizeof(int));
>   op=ip;
>   /* store/read into *ip */
>   free(op);
> but llvm-gcc transforms the above code to
>   int *ip=(int*)malloc(sizeof(int));
>   /* store/read into *ip */
>   free(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 another.
> nicolas
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev

More information about the llvm-dev mailing list