[LLVMdev] More detailed example...
Sarah Thompson
sarah at findatlantis.com
Fri Jan 5 17:44:12 PST 2007
> How are you compiling this? I get the following sort of output:
>
>
llvm-gcc incdec.cpp -o incdec
I am currently using LLVM 1.8 -- I was basically holding off porting
until LLVM 2.0 stabilises because I want to be able to move to 64 bit
Intel and don't want to have to hit a moving target.
> void %inc(int* %p) {
> entry:
> %tmp = volatile load int* %p ; <int> [#uses=1]
> %tmp1 = add int %tmp, 1 ; <int> [#uses=1]
> volatile store int %tmp1, int* %p
> tail call void (...)* %mcp_yield( )
> %tmp.1 = volatile load int* %p ; <int> [#uses=1]
> %tmp1.1 = add int %tmp.1, 1 ; <int> [#uses=1]
> volatile store int %tmp1.1, int* %p
> tail call void (...)* %mcp_yield( )
> %tmp.2 = volatile load int* %p ; <int> [#uses=1]
> %tmp1.2 = add int %tmp.2, 1 ; <int> [#uses=1]
> volatile store int %tmp1.2, int* %p
> tail call void (...)* %mcp_yield( )
> ret void
> }
>
> I ran this with "llvm-gcc -c mcp.c -o mcp.bc". In the example you gave,
> it is valid for LLVM to optimize away the volatile memory accesses if
> it were doing link-time optimizations; it could prove that "int n"'s
> value never changed the observable behaviour of the program and elided it.
>
This looks right, and would definitely generate correct code if it was
used. I will try again with the gcc command line you used.
Thanks,
Sarah
More information about the llvm-dev
mailing list