Hi, Using this option I do get all the vars as may alias ie MayAlias: i32* %j.0, i32* %k MayAlias: i32* %i.0, i32* %k MayAlias: i32* %i.0, i32* %j.0 Is there any other analysis which will give them as must aliases. Actually what I want to do is implement a flow sensitive points-to(not alias) analysis and then use that information for some optimizations like PRE. Will that be possible? Duncan Sands wrote:> Hi Ambika, > >> to compile it to bitcode I give the following command : >> >> llvm-gcc -emit-llvm -c -o s.bc s.c >> >> and then I run different alias analysis passes like -anders-aa, >> -basicaa using following: >> >> opt -anders-aa -aa-eval -print-all-alias-modref-info s.bc > > alias analysis will work poorly if you don't run any optimizers. > The alias analysis passes assume that at least some basic optimizations > have been done. Try compiling like this: > > llvm-gcc -emit-llvm -c -o s.bc s.c -O1 > > Ciao, > > Duncan.
Hi Ambika,> Using this option I do get all the vars as may alias ie > > MayAlias: i32* %j.0, i32* %k > MayAlias: i32* %i.0, i32* %k > MayAlias: i32* %i.0, i32* %j.0 > > Is there any other analysis which will give them as must aliases.at -O1 these variables are entirely eliminated here. I'm surprised they aren't eliminated for you. Ciao, Duncan. PS: $ cat ambika.c int main() { int *i,*j,k; i=&k; j=&k; k=4; printf("%d,%d,%d",*i,*j,k); return 0; } $ llvm-gcc -S -O1 -emit-llvm -o - ambika.c ambika.c: In function ‘main’: ambika.c:7: warning: incompatible implicit declaration of built-in function ‘printf’ ; ModuleID = 'ambika.c' target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" target triple = "x86_64-unknown-linux-gnu" @.str = private constant [9 x i8] c"%d,%d,%d\00", align 1 ; <[9 x i8]*> [#uses=1] define i32 @main() nounwind { entry: %0 = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([9 x i8]* @.str, i64 0, i64 0), i32 4, i32 4, i32 4) nounwind ; <i32> [#uses=0] ret i32 0 } declare i32 @printf(i8* nocapture, ...) nounwind
Hi, Using this option I do get all the vars as may alias ie MayAlias: i32* %j.0, i32* %k MayAlias: i32* %i.0, i32* %k MayAlias: i32* %i.0, i32* %j.0 Is there any other analysis which will give them as must aliases. Actually what I want to do is implement a flow sensitive points-to(not alias) analysis and then use that information for some optimizations like PRE. Will that be possible?> > Duncan Sands wrote: >> Hi Ambika, >> >>> to compile it to bitcode I give the following command : >>> >>> llvm-gcc -emit-llvm -c -o s.bc s.c >>> >>> and then I run different alias analysis passes like -anders-aa, >>> -basicaa using following: >>> >>> opt -anders-aa -aa-eval -print-all-alias-modref-info s.bc >> >> alias analysis will work poorly if you don't run any optimizers. >> The alias analysis passes assume that at least some basic optimizations >> have been done. Try compiling like this: >> >> llvm-gcc -emit-llvm -c -o s.bc s.c -O1 >> >> Ciao, >> >> Duncan. > >
Hi, I actually used the example mentioned by Török int main(int argc, char **argv) { int *i=0,*j=0,k; if (argc > 1) { i=&k; } else { j=&k; } k=4; printf("%d,%d,%d,%p,%p",*i,*j,k,i,j); return 0; } Duncan Sands wrote:> Hi Ambika, > >> Using this option I do get all the vars as may alias ie >> >> MayAlias: i32* %j.0, i32* %k >> MayAlias: i32* %i.0, i32* %k >> MayAlias: i32* %i.0, i32* %j.0 >> >> Is there any other analysis which will give them as must aliases. > > at -O1 these variables are entirely eliminated here. I'm surprised > they aren't eliminated for you. > > Ciao, > > Duncan. > > PS: > > $ cat ambika.c > int main() > { > int *i,*j,k; > i=&k; > j=&k; > k=4; > printf("%d,%d,%d",*i,*j,k); > return 0; > } > $ llvm-gcc -S -O1 -emit-llvm -o - ambika.c > ambika.c: In function ‘main’: > ambika.c:7: warning: incompatible implicit declaration of built-in > function ‘printf’ > ; ModuleID = 'ambika.c' > target datalayout = > "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" > > target triple = "x86_64-unknown-linux-gnu" > > @.str = private constant [9 x i8] c"%d,%d,%d\00", align 1 ; <[9 x > i8]*> [#uses=1] > > define i32 @main() nounwind { > entry: > %0 = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds > ([9 x i8]* @.str, i64 0, i64 0), i32 4, i32 4, i32 4) nounwind ; <i32> > [#uses=0] > ret i32 0 > } > > declare i32 @printf(i8* nocapture, ...) nounwind
Seemingly Similar Threads
- [LLVMdev] A very basic doubt about LLVM Alias Analysis
- [LLVMdev] A very basic doubt about LLVM Alias Analysis
- [LLVMdev] A very basic doubt about LLVM Alias Analysis
- [LLVMdev] A very basic doubt about LLVM Alias Analysis
- [LLVMdev] A very basic doubt about LLVM Alias Analysis