[LLVMdev] Question regarding the alias analysis chaining behaviour

Nick Lewycky nicholas at mxc.ca
Thu Nov 25 11:16:36 PST 2010


[+llvmdev]

Rajeshwar Vanka wrote:
> -----Original Message-----
> From: Nick Lewycky [mailto:nicholas at mxc.ca]
> Sent: Wednesday, November 24, 2010 3:51 PM
> To: dirac
> Cc: llvmdev at cs.uiuc.edu
> Subject: Re: [LLVMdev] Question regarding the alias analysis chaining
> behaviour
>
> dirac wrote:
>> Hi,
>>      I am using LLVM 2.4 on a Linux RHEL5 machine. I was trying to figure
>> out how the chaining of the alias analysis passes works in LLVM. Here
>> are the command I used to test the chaining part.
>>    1.  ./opt hello_world_1_nest_func.bc -o hello_world_1_nest_func_AA.bc
>> -no-aa -anders-aa -licm
>>     Result: Anderson's AA and No Alias Analysis both are called.
>>     2. ./opt hello_world_1_nest_func.bc -o hello_world_1_nest_func_AA.bc
>> -basicaa -anders-aa -licm
>>     Result: Anderson's AA and Basic AA both are called.
>>     3. ./opt hello_world_1_nest_func.bc -o hello_world_1_nest_func_AA.bc
>> -basicaa -licm
>>     Result: Only Basic AA is called. (When I use -no-aa instead of
>> -basicaa, only the NoAA is called).
>>     4. ./opt hello_world_1_nest_func.bc -o hello_world_1_nest_func_AA.bc
>> -basicaa -anders-aa -licm -licm
>>     Result: First licm gets a mix of both AA passes (basic and anders),
>> second licm only gets basic.
>>     5. ./opt hello_world_1_nest_func.bc -o hello_world_1_nest_func_AA.bc
>> -basicaa -anders-aa -licm -basicaa -anders-aa -licm
>>     Result: Both licm instances get a mix of Anders and Basic AA.
>>
>>     Am I to conclude that the Anderson's Alias Analysis is only applied
>> to LICM? and other passes which require alias analysis use BasicAA or
>> NoAA depending which on which one is specified on the command line? Is
>> this the reason I am seeing calls to different AAs when although I
>> specify an AA which neither Basic nor No AA?
>>
>>     I read on llvm docs that it is not possible to actually specify one
>> user-created alias analysis on the command line which is applied to all
>> subsequent passes on the command line. Does this mean that there is a
>> constraint on the command line user-created AA... which is that it only
>> applies to the top-level pass (licm above) specified immediately after
>> the user-created AA?
>
>>> The AA that you specify will be created when you specify it and live
>>> until that pass is invalidated (not explicitly preserved by a pass that
>>> runs). The next time a pass requires AA, the pass manager will create
>>> the default AA (BasicAA) and not the one you put on the command line.
>
>>> You can view what the pass manager is actually doing with "opt
>>> -debug-pass=Structure ...".
>
>>> Nick
>
> So, what you are saying is that if I create an AA, and that is used by a
> pass X, then
> the AA I create will only be alive until that pass remains valid? I am a
> little confused here.
>> From my understanding, an AA will be created only once, and its information
> is updated using
> Copy/delete/replace Value functions. Does this not apply to an AA pass that
> I create?

The BasicAA pass is created only once because it is an ImmutablePass. I 
should've asked what type of Pass your custom AA is, but this is a 
common problem where someone writes an AA as a FunctionPass (or uses 
Andersen's AA before we removed it from the tree) and it doesn't live 
through the whole execution.

See http://llvm.org/docs/WritingAnLLVMPass.html#passtype and below for a 
list of the passes and their requirements. (Yes, BasicAA really does 
meet the requirements for an immutable pass. It stores no state and the 
copy/delete/replace functions are all no-ops.)

Nick

>
> Thanks.
> Rajesh
>
>>     I read in the same llvm doc that the "superclass" (The main Alias
>> Analysis pass I assume) decides which response to use when the
>> user-defined AA overrides the default methods. However, in my current
>> version, I don't see code for deciding between the two AAs. Is this an
>> artifact of the older version I am using?
>>
>>     Thanks for your response.
>>
>> Rajesh
>>
>>
>>
>> _______________________________________________
>> 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