[LLVMdev] Question about Alias Analysis

Chris Lattner sabre at nondot.org
Tue Jun 26 11:00:01 PDT 2007


On Mon, 25 Jun 2007, Ben Chambers wrote:
> I guess what confuses me is that it doesn't seem like it was able to
> figure out that *b = a.  Am I looking at this wrong?  Is there a more
> accurate way of getting the alias information out of the pass?

The answer is to not look at the alias sets.  I'd suggest looking at the 
raw results of alias queries.  To do this, use the -aa-eval pass with the 
-print-all-alias-modref-info option.  The alias set builder uses 
unification to build the sets, so it will give you less precise 
information than the raw queries do.

-Chris

> Thanks,
> Ben Chambers
>
> Output:
> AliasSet[0x601e70,2] may  alias, Mod/Ref   Pointers: (i32* %a, 4),
> (i32* %tmp1, 4)
> AliasSet[0x601ea0,1] must alias, Mod/Ref   Pointers: (i32** %b, 4)
> AliasSet[0x601f10,1] must alias, Mod/Ref   Pointers: (i32* %tmp, 4)
> AliasSet[0x601f60,1] must alias, Mod/Ref   Pointers: (i32* %retval, 4)
>
> Input:
>
> int main() {
> int a = 5;
> int* b = &a;
> return *b;
> }
>
> Assembly:
>
> define i32 @main() {
> entry:
> %retval = alloca i32, align 4   ; <i32*> [#uses=2]
> %tmp = alloca i32, align 4    ; <i32*> [#uses=2]
> %a = alloca i32, align 4    ; <i32*> [#uses=2]
> %b = alloca i32*, align 4   ; <i32**> [#uses=2]
> "alloca point" = bitcast i32 0 to i32   ; <i32> [#uses=0]
> store i32 5, i32* %a
> store i32* %a, i32** %b
> %tmp1 = load i32** %b   ; <i32*> [#uses=1]
> %tmp2 = load i32* %tmp1   ; <i32> [#uses=1]
> store i32 %tmp2, i32* %tmp
> %tmp3 = load i32* %tmp    ; <i32> [#uses=1]
> store i32 %tmp3, i32* %retval
> br label %return
>
> return:   ; preds = %entry
> %retval4 = load i32* %retval    ; <i32> [#uses=1]
> ret i32 %retval4
> }
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>

-Chris

-- 
http://nondot.org/sabre/
http://llvm.org/



More information about the llvm-dev mailing list