On Oct 1, 2009, at 6:58 PM, dan mihai wrote:
> Hi,
>
> I am trying to use alias analysis (Anderson) and noticed that for
> pointers to functions
> I don't get the expected result: a pointer that clearly may point to
> a function is
> reported as NoAlias.
Hi Dan,
Andersaa is extremely experimental at this point and has many known
bugs.
-Chris
>
> I use -anders-aa -aa-eval -print-no-aliases -print-may-aliases -
> print-must-aliases
>
> Here is a test case:
>
> ///////////////try_calls_aliases.c
> #include <stdio.h>
>
> typedef int (*PF)();
>
> PF pf01=0;
> PF pf2=0;
>
> int pointed_to_function0() {
> printf("pointed_to_function0\n");
> return 1;
> }
>
> int pointed_to_function1() {
> pf01 = pointed_to_function1;
> printf("pointed_to_function1\n");
> return 1;
> }
>
> void ptr_function_caller(PF pf) {
> printf("ptr_function_caller\n");
> pf();
> PF lpf0 = pointed_to_function0;
> PF lpf1 = pointed_to_function1;
> }
>
> int main(int argc, char* argv[]) {
> ptr_function_caller(pointed_to_function0);
> return 0;
> }
> -------------
>
> After
> llvmgcc -emit-llvm try_calls_aliases.c -c -o try_calls_aliases.bc
> opt 2>&1 -anders-aa -aa-eval -print-no-aliases -print-may-
> aliases -print-must-aliases try_calls_aliases.bc | egrep -e 'Alias|
> Function' > c
> I get:
> ...........
> Function: ptr_function_caller: 8 pointers, 2 call sites
> NoAlias: i32 (...)* bitcast (i32 ()* @pointed_to_function0 to
> i32 (...)*), i32 (...)* bitcast (i32 ()* @pointed_to_function1 to
> i32 (...)*)
> NoAlias: i32 (...)* %pf, i32 (...)* bitcast (i32 ()*
> @pointed_to_function0 to i32 (...)
> *)
???????????????????????????????????????????????????????????????????????????????
> NoAlias: i32 (...)* %pf, i32 (...)* bitcast (i32 ()*
> @pointed_to_function1 to i32 (...)*)
> NoAlias: i32 (...)* bitcast (i32 ()* @pointed_to_function0 to
> i32 (...)*), i8* getelementptr ([20 x i8]* @.str2, i32 0, i64 0)
> NoAlias: i32 (...)* bitcast (i32 ()* @pointed_to_function1 to
> i32 (...)*), i8* getelementptr ([20 x i8]* @.str2, i32 0, i64 0)
> NoAlias: i32 (...)* %pf, i8* getelementptr ([20 x i8]* @.str2,
> i32 0, i64 0)
> NoAlias: i32 (...)* bitcast (i32 ()* @pointed_to_function0 to
> i32 (...)*), i32 (...)** %pf_addr
> NoAlias: i32 (...)* bitcast (i32 ()* @pointed_to_function1 to
> i32 (...)*), i32 (...)** %pf_addr
> NoAlias: i32 (...)* %pf, i32 (...)** %pf_addr
> NoAlias: i32 (...)** %pf_addr, i8* getelementptr ([20 x i8]*
> @.str2, i32 0, i64 0)
> NoAlias: i32 (...)* bitcast (i32 ()* @pointed_to_function0 to
> i32 (...)*), i32 (...)** %lpf1
> NoAlias: i32 (...)* bitcast (i32 ()* @pointed_to_function1 to
> i32 (...)*), i32 (...)** %lpf1
> NoAlias: i32 (...)* %pf, i32 (...)** %lpf1
> NoAlias: i32 (...)** %lpf1, i8* getelementptr ([20 x i8]*
> @.str2, i32 0, i64 0)
> NoAlias: i32 (...)** %lpf1, i32 (...)** %pf_addr
> NoAlias: i32 (...)* bitcast (i32 ()* @pointed_to_function0 to
> i32 (...)*), i32 (...)** %lpf0
> NoAlias: i32 (...)* bitcast (i32 ()* @pointed_to_function1 to
> i32 (...)*), i32 (...)** %lpf0
> NoAlias: i32 (...)* %pf, i32 (...)** %lpf0
> NoAlias: i32 (...)** %lpf0, i8* getelementptr ([20 x i8]*
> @.str2, i32 0, i64 0)
> NoAlias: i32 (...)** %lpf0, i32 (...)** %pf_addr
> NoAlias: i32 (...)** %lpf0, i32 (...)** %lpf1
> NoAlias: i32 (...)* %1, i32 (...)* bitcast (i32 ()*
> @pointed_to_function0 to i32 (...)*)
> NoAlias: i32 (...)* %1, i32 (...)* bitcast (i32 ()*
> @pointed_to_function1 to i32 (...)*)
> MayAlias: i32 (...)* %1, i32 (...)* %pf
> NoAlias: i32 (...)* %1, i8* getelementptr ([20 x i8]* @.str2,
> i32 0, i64 0)
> NoAlias: i32 (...)* %1, i32 (...)** %pf_addr
> NoAlias: i32 (...)* %1, i32 (...)** %lpf1
> NoAlias: i32 (...)* %1, i32 (...)** %lpf0
> ...............
>
> Any advice on how to get this work as expected? (that is pf MayAlias
> pointed_to_function0 inside ptr_function_caller, etc)?
>
> Thank you,
> Dan
>
>
>
> Insert movie times and more without leaving HotmailĀ®. See
> how._______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20091001/fc329237/attachment.html>