[LLVMdev] inttoptr and basicaa

Pranav Bhandarkar pranavb at codeaurora.org
Thu Nov 8 18:53:16 PST 2012


Hi,

I am observing some incorrect behavior in basicaa, wherein two pointers that
basicaa should determine to be MustAlias are ending up NoAlias - the other
extreme :(
I am blaming this on basicaa not handling inttoptr.  Here is the relevant IR
snippet.
--------------------
 %sunkaddr36 = ptrtoint %struct.BitParams* %bs to i32
  %sunkaddr37 = add i32 %sunkaddr36, 16
  %sunkaddr38 = inttoptr i32 %sunkaddr37 to i32*



 %sunkaddr39 = ptrtoint %struct.BitParams* %bs to i32
  %sunkaddr40 = add i32 %sunkaddr39, 16
  %sunkaddr41 = inttoptr i32 %sunkaddr40 to i64*
---------------------

A query to basicaa: alias(%sunkaddr41, 8, %sunkaddr38, 4) results in a
NoAlias return value. 
The reason is that nothing inside basicaa processes inttoptr; the fall
through case of using TBAA (int and long long in this case) is executed and
NoAlias is returned as the pointer types are different.

I have two questions.
1) Is it safe for basicaa to reason about inttoptr in a manner similar to
aliasGEP (using decomposeGEPExpression to symbolically evaluate the
pointer).
2) If the answer to the above is no, then shouldn't basicaa treat the above
conservatively before it looks at TBAA ?


Thanks,
Pranav

Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,  hosted
by The Linux Foundation




More information about the llvm-dev mailing list