<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html;
      charset=windows-1252">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">On 4/15/2018 11:44 AM, Mustakimur
      Khandaker via llvm-dev wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:BY2PR05MB710BBF391709E06B7DBEF1AEFB10@BY2PR05MB710.namprd05.prod.outlook.com">
      <meta http-equiv="Content-Type" content="text/html;
        charset=windows-1252">
      <style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
      <div id="divtagdefaultwrapper"
style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;"
        dir="ltr">
        <div>Hi </div>
        <div>I have this simple c code for which I would like to use for
          alias analysis. </div>
        <div><br>
        </div>
        <blockquote style="margin: 0 0 0 40px; border: none; padding:
          0px;">
          <div>#include <stdio.h></div>
          <div>#include <stdlib.h></div>
          <div><br>
          </div>
          <div>static int (*fp) (void); </div>
          <div>void ind_call (int (*compr)(void)){ </div>
          <div>    fp = compr; </div>
          <div>    fp(); </div>
          <div>} </div>
          <div>int hello(void){ </div>
          <div>    return printf("hello world\n"); </div>
          <div>} </div>
          <div>int main(){ </div>
          <div>    ind_call(hello); </div>
          <div>    return 0; </div>
          <div>} </div>
        </blockquote>
        <div><br>
        </div>
        <div>So, I do the following: </div>
        <blockquote style="margin: 0 0 0 40px; border: none; padding:
          0px;">
          <div>bin/opt -basicaa -cfl-anders-aa -print-alias-sets
            bin/test/test.bc </div>
        </blockquote>
        <div><br>
        </div>
        <div>I get the following result: </div>
        <blockquote style="margin: 0 0 0 40px; border: none; padding:
          0px;">
          <div>Alias sets for function 'ind_call': </div>
          <div>Alias Set Tracker: 2 alias sets for 2 pointer values. </div>
          <div>  AliasSet[0x91a5820, 1] must alias, Mod/Ref   Pointers:
            (i32 ()** %compr.addr, 8) </div>
          <div>  AliasSet[0x91a58c0, 2] may alias, Mod/Ref   Pointers:
            (i32 ()** @fp, 8) </div>
          <div>    1 Unknown instructions: i32 %call <br>
          </div>
        </blockquote>
      </div>
    </blockquote>
    <br>
    LLVM's alias analysis is not very smart; it depends on other
    optimization passes to produce reasonable results.  You should at
    least run mem2reg before trying to do any alias analysis queries.<br>
    <br>
    -Eli<br>
    <p><br>
    </p>
    <pre class="moz-signature" cols="72">-- 
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project</pre>
  </body>
</html>