[llvm-dev] Understand alias-analysis results

Shuai Wang via llvm-dev llvm-dev at lists.llvm.org
Thu Jul 9 01:15:04 PDT 2020


Hello,

I am performing alias analysis toward the following simple code:

struct MyStruct {
int * f1;
int * f2;
};

void NOALIAS(void* p, void* q){
}

int main() {
struct MyStruct s[2];
int a,b;
s[0].f1 = &a;
s[1].f1 = &b;

NOALIAS(s[a].f1, s[b].f2);

return 0;
}

When I use the following command to generate .bc code and conduct alias
analysis:

clang -c -emit-llvm t.c -O2
opt -basicaa -aa-eval -print-alias-sets -disable-output t.bc

I got the following outputs:

Alias sets for function 'NOALIAS':
Alias Set Tracker: 0 alias sets for 0 pointer values.

Alias sets for function 'main':
Alias Set Tracker: 0 alias sets for 0 pointer values.

===== Alias Analysis Evaluator Report =====
  1 Total Alias Queries Performed
  0 no alias responses (0.0%)
  1 may alias responses (100.0%)
  0 partial alias responses (0.0%)
  0 must alias responses (0.0%)

I checked the generated .ll code, and it shows that within the main
function and NOALIAS functions, there is only a "ret" statement, with no
global or local variables used. Could anyone shed some lights on where the
"1 may alias" come from?  And is there a way that I can force the alias
analysis algorithm to focus only the "main" function? Thank you very much.

Best,
Shuai
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200709/231863e2/attachment.html>


More information about the llvm-dev mailing list