<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
Hi,<br><br>I am trying to use alias analysis (Anderson) and noticed that for pointers to functions <br>I don't get the expected result: a pointer that clearly may point to a function is <br>reported as NoAlias.<br><br>I use -anders-aa  -aa-eval -print-no-aliases -print-may-aliases  -print-must-aliases<br><br>Here is a test case:<br><br>///////////////try_calls_aliases.c <br>#include <stdio.h><br><br>typedef int (*PF)();<br><br>PF pf01=0;<br>PF pf2=0;<br><br>int pointed_to_function0() {<br>  printf("pointed_to_function0\n");<br>  return 1;<br>}<br><br>int pointed_to_function1() {<br>  pf01 = pointed_to_function1;<br>  printf("pointed_to_function1\n");<br>  return 1;<br>}<br><br>void ptr_function_caller(PF pf) {<br>  printf("ptr_function_caller\n");<br>  pf();<br>  PF lpf0 = pointed_to_function0;<br>  PF lpf1 = pointed_to_function1;<br>}<br><br>int main(int argc, char* argv[]) {<br>  ptr_function_caller(pointed_to_function0);<br>  return 0;<br>}<br>-------------<br><br>After<br> llvmgcc  -emit-llvm try_calls_aliases.c  -c -o try_calls_aliases.bc<br> 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<br>I get:<br>...........<br>Function: ptr_function_caller: 8 pointers, 2 call sites<br>  NoAlias:    i32 (...)* bitcast (i32 ()* @pointed_to_function0 to i32 (...)*), i32 (...)* bitcast (i32 ()* @pointed_to_function1 to i32 (...)*)<br>  NoAlias:    i32 (...)* %pf, i32 (...)* bitcast (i32 ()* @pointed_to_function0 to i32 (...)*) ???????????????????????????????????????????????????????????????????????????????<br>  NoAlias:    i32 (...)* %pf, i32 (...)* bitcast (i32 ()* @pointed_to_function1 to i32 (...)*)<br>  NoAlias:    i32 (...)* bitcast (i32 ()* @pointed_to_function0 to i32 (...)*), i8* getelementptr ([20 x i8]* @.str2, i32 0, i64 0)<br>  NoAlias:    i32 (...)* bitcast (i32 ()* @pointed_to_function1 to i32 (...)*), i8* getelementptr ([20 x i8]* @.str2, i32 0, i64 0)<br>  NoAlias:    i32 (...)* %pf, i8* getelementptr ([20 x i8]* @.str2, i32 0, i64 0)<br>  NoAlias:    i32 (...)* bitcast (i32 ()* @pointed_to_function0 to i32 (...)*), i32 (...)** %pf_addr<br>  NoAlias:    i32 (...)* bitcast (i32 ()* @pointed_to_function1 to i32 (...)*), i32 (...)** %pf_addr<br>  NoAlias:    i32 (...)* %pf, i32 (...)** %pf_addr<br>  NoAlias:    i32 (...)** %pf_addr, i8* getelementptr ([20 x i8]* @.str2, i32 0, i64 0)<br>  NoAlias:    i32 (...)* bitcast (i32 ()* @pointed_to_function0 to i32 (...)*), i32 (...)** %lpf1<br>  NoAlias:    i32 (...)* bitcast (i32 ()* @pointed_to_function1 to i32 (...)*), i32 (...)** %lpf1<br>  NoAlias:    i32 (...)* %pf, i32 (...)** %lpf1<br>  NoAlias:    i32 (...)** %lpf1, i8* getelementptr ([20 x i8]* @.str2, i32 0, i64 0)<br>  NoAlias:    i32 (...)** %lpf1, i32 (...)** %pf_addr<br>  NoAlias:    i32 (...)* bitcast (i32 ()* @pointed_to_function0 to i32 (...)*), i32 (...)** %lpf0<br>  NoAlias:    i32 (...)* bitcast (i32 ()* @pointed_to_function1 to i32 (...)*), i32 (...)** %lpf0<br>  NoAlias:    i32 (...)* %pf, i32 (...)** %lpf0<br>  NoAlias:    i32 (...)** %lpf0, i8* getelementptr ([20 x i8]* @.str2, i32 0, i64 0)<br>  NoAlias:    i32 (...)** %lpf0, i32 (...)** %pf_addr<br>  NoAlias:    i32 (...)** %lpf0, i32 (...)** %lpf1<br>  NoAlias:    i32 (...)* %1, i32 (...)* bitcast (i32 ()* @pointed_to_function0 to i32 (...)*)<br>  NoAlias:    i32 (...)* %1, i32 (...)* bitcast (i32 ()* @pointed_to_function1 to i32 (...)*)<br>  MayAlias:    i32 (...)* %1, i32 (...)* %pf<br>  NoAlias:    i32 (...)* %1, i8* getelementptr ([20 x i8]* @.str2, i32 0, i64 0)<br>  NoAlias:    i32 (...)* %1, i32 (...)** %pf_addr<br>  NoAlias:    i32 (...)* %1, i32 (...)** %lpf1<br>  NoAlias:    i32 (...)* %1, i32 (...)** %lpf0<br>...............<br><br>Any advice on how to get this work as expected? (that is pf MayAlias pointed_to_function0 inside ptr_function_caller, etc)?<br><br>Thank you,<br>Dan<br><br><br>                                         <br /><hr />Insert movie times and more without leaving HotmailŪ. <a href='http://windowslive.com/Tutorial/Hotmail/QuickAdd?ocid=TXT_TAGLM_WL_HM_Tutorial_QuickAdd_062009' target='_new'>See how.</a></body>
</html>