[LLVMdev] tbaa

ggan at codeaurora.org ggan at codeaurora.org
Mon Dec 5 15:08:02 PST 2011


Hi Yi,

I didn't get a chance to run your code. But from the debug information you
posted about tbaa alias analysis:

Alias Set Tracker: 1 alias sets for 7 pointer values.
 AliasSet[0x207f860, 7] may alias, Mod/Ref   Pointers: (i32* %1, 4),
(i32* %x, 4), (i32** %p, 8), (i32** %q, 8), (float* %z, 4), (float** %t,
8), (i32* %2, 4)

I guess it is because of the way how TBAA alias analysis treats pointers.
See file: tools/clang/lib/CodeGen/CodeGenTBAA.cpp, line 147&148

    147   if (Ty->isPointerType())
    148     return MetadataCache[Ty] = getTBAAInfoForNamedType("any pointer",
    149                                                        getChar());

For any pointer, no matter which object it points to, TBAA will generate
the same type of tbaa metadata, which is called "any pointer". Since the
elements in the alias set you posted are all pointers, TBAA will think
that they all "may alias" each other.

The BasicAA pass analyzes in a different way. So it is not surprise if
they return you different results.

Can you post the IR of the code? It would be much easier to explain this
if we can see the IR.

Gan






> Duncan Sands <baldrick <at> free.fr> writes:
>
>>
>> Hi Yi,
>>
>> > Could anyone tell me how exactly do I use "Type Based Alias Analysis"?
>> >
>> > I compiled the C program with Clang, and verified that there is tbaa
>> > metadata in the IR code.
>> >
>> > But then when I use "opt -tbaa input.c.bc -aa-eval" to check the
>> results,
>> > it always gives 100% may aliasing no matter what input.
>>
>> you need to run some optimizations on your bitcode, at least mem2reg, to
>> get
>> it in a form where alias analysis will do something useful.
>>
>> Ciao, Duncan.
>>
>
> Thanks for the advice. But I tried -mem2reg. It gives me the same results:
> everything may alias while -basicaa give more meaningful results.
>
> Have you made -tbaa working before? Could you show me the optimizations
> you used?
>
> Thank you.
> Yi
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>





More information about the llvm-dev mailing list