AliasAnalysis calling failed in Pass interaction

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

AliasAnalysis calling failed in Pass interaction

Shen Liu
Dear LLVM developers,

I am Shen, a PhD student at Lehigh Univ. PA.  Now I am implementing a Program Dependence Graph(PDG) on LLVM. I have 4 passes here:

1. ProgramDependenceGraph (a ModulePass on the highest level)
2. DataDependenceGraph (a Intermediate FunctionPass).
3. FlowDependenceAnalysis Pass (a intermediate FunctionPass) which uses llvm built-in AliasAnalysis (-basicaa)
4. AliasAnalysis Pass  (LLVM built-in Pass)

When my call chain is 

DatadependenceGraph <-- FlowDependenceAnalysis <-- AliasAnalysis 

everything is fine and basicaa is executed successfully.

My problem is, when I use a Module Pass to call a Function Pass, the low level AliasAnalysis does not work anymore, all return values for location comparisons are "May Alias". In other words, the call chain

ProgramDependenceGraph(Module Pass) <-- DatadependenceGraph(Function Pass) <-- FlowDependenceAnalysis <-- AliasAnalysis if failed.

However, if I change ProgramDependenceGraph into a Function Pass, this call chain works and AliasAnalysis can be executed successfully.

So, i guess there may be an error in my interaction between Module Pass and Function Pass. Could you give me some hints to help me solve it? Thank you very much!


Here are some key code for Pass interaction in my implementation: 

bool ProgramDependencyGraph::runOnModule(Module &M)
{
 ...
  for(Module::iterator F = M.begin(), E = M.end(); F != E; ++F)
    {
       DataDependencyGraph &ddgGraph = getAnalysis<DataDependencyGraph>(*F);
       ....
    }
}

...
void ProgramDependencyGraph::getAnalysisUsage(AnalysisUsage &AU) const
{
   ...
  AU.addRequired<DataDependencyGraph>();
  AU.setPreservesAll();
}


Best Regards,

Shen



_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: AliasAnalysis calling failed in Pass interaction

Daniel Berlin
On Wed, Apr 29, 2015 at 1:27 PM, Shen Liu <[hidden email]> wrote:
> Dear LLVM developers,
>
> I am Shen, a PhD student at Lehigh Univ. PA.  Now I am implementing a
> Program Dependence Graph(PDG) on LLVM. I have 4 passes here:
>
> 1. ProgramDependenceGraph (a ModulePass on the highest level)
> 2. DataDependenceGraph (a Intermediate FunctionPass).
> 3. FlowDependenceAnalysis Pass (a intermediate FunctionPass) which uses llvm
> built-in AliasAnalysis (-basicaa)

Does this implement AliasAnalysis?

> 4. AliasAnalysis Pass  (LLVM built-in Pass)
>
> When my call chain is
>
> DatadependenceGraph <-- FlowDependenceAnalysis <-- AliasAnalysis
>
> everything is fine and basicaa is executed successfully.

BasicAA is not AliasAnalysis. BasicAA is *an* AliasAnalysis.

If you have not added BasicAliasAnalysis to the pass list, it will not
be called when you call AliasAnalysis API.

>
> My problem is, when I use a Module Pass to call a Function Pass, the low
> level AliasAnalysis does not work anymore, all return values for location
> comparisons are "May Alias". In other words, the call chain
>
> ProgramDependenceGraph(Module Pass) <-- DatadependenceGraph(Function Pass)
> <-- FlowDependenceAnalysis <-- AliasAnalysis if failed.
>
> However, if I change ProgramDependenceGraph into a Function Pass, this call
> chain works and AliasAnalysis can be executed successfully.
>
> So, i guess there may be an error in my interaction between Module Pass and
> Function Pass. Could you give me some hints to help me solve it? Thank you
> very much!
>
>
> Here are some key code for Pass interaction in my implementation:
>
> bool ProgramDependencyGraph::runOnModule(Module &M)
> {
>  ...
>   for(Module::iterator F = M.begin(), E = M.end(); F != E; ++F)
>     {
>        DataDependencyGraph &ddgGraph = getAnalysis<DataDependencyGraph>(*F);
>        ....
>     }
> }
>
> ...
> void ProgramDependencyGraph::getAnalysisUsage(AnalysisUsage &AU) const
> {
>    ...
>   AU.addRequired<DataDependencyGraph>();
>   AU.setPreservesAll();
> }
>

This does not require alias analysis or it's analysis group, which is
wrong if you want those to work?

>
> Best Regards,
>
> Shen
>
>
>
> _______________________________________________
> LLVM Developers mailing list
> [hidden email]         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: AliasAnalysis calling failed in Pass interaction

Shen Liu
Hi Daniel, thanks for your reply! Yes I didn't implement AA by myself but called builtin -basicaa interface for temporary use. Just add the -basicaa option in my opt command.

I hope -basicaa can be called to process to check some simple aliases. And when I do 

DataDependencyGraph &ddgGraph = getAnalysis<DataDependencyGraph>(*F);

inside a Function Pass, it works.What make me confused is when my Pass is a Module Pass, --basicaa cannot be called anymore. It seems the -basicaa option cannot be seen by getAnalysis() if I call it in a Module Pass. 

Do you have any suggestions?

Best Regards,

Shen 



On Wed, Apr 29, 2015 at 4:45 PM, Daniel Berlin <[hidden email]> wrote:
On Wed, Apr 29, 2015 at 1:27 PM, Shen Liu <[hidden email]> wrote:
> Dear LLVM developers,
>
> I am Shen, a PhD student at Lehigh Univ. PA.  Now I am implementing a
> Program Dependence Graph(PDG) on LLVM. I have 4 passes here:
>
> 1. ProgramDependenceGraph (a ModulePass on the highest level)
> 2. DataDependenceGraph (a Intermediate FunctionPass).
> 3. FlowDependenceAnalysis Pass (a intermediate FunctionPass) which uses llvm
> built-in AliasAnalysis (-basicaa)

Does this implement AliasAnalysis?


 

> 4. AliasAnalysis Pass  (LLVM built-in Pass)
>
> When my call chain is
>
> DatadependenceGraph <-- FlowDependenceAnalysis <-- AliasAnalysis
>
> everything is fine and basicaa is executed successfully.

BasicAA is not AliasAnalysis. BasicAA is *an* AliasAnalysis.

If you have not added BasicAliasAnalysis to the pass list, it will not
be called when you call AliasAnalysis API.

>
> My problem is, when I use a Module Pass to call a Function Pass, the low
> level AliasAnalysis does not work anymore, all return values for location
> comparisons are "May Alias". In other words, the call chain
>
> ProgramDependenceGraph(Module Pass) <-- DatadependenceGraph(Function Pass)
> <-- FlowDependenceAnalysis <-- AliasAnalysis if failed.
>
> However, if I change ProgramDependenceGraph into a Function Pass, this call
> chain works and AliasAnalysis can be executed successfully.
>
> So, i guess there may be an error in my interaction between Module Pass and
> Function Pass. Could you give me some hints to help me solve it? Thank you
> very much!
>
>
> Here are some key code for Pass interaction in my implementation:
>
> bool ProgramDependencyGraph::runOnModule(Module &M)
> {
>  ...
>   for(Module::iterator F = M.begin(), E = M.end(); F != E; ++F)
>     {
>        DataDependencyGraph &ddgGraph = getAnalysis<DataDependencyGraph>(*F);
>        ....
>     }
> }
>
> ...
> void ProgramDependencyGraph::getAnalysisUsage(AnalysisUsage &AU) const
> {
>    ...
>   AU.addRequired<DataDependencyGraph>();
>   AU.setPreservesAll();
> }
>

This does not require alias analysis or it's analysis group, which is
wrong if you want those to work?

>
> Best Regards,
>
> Shen
>
>
>
> _______________________________________________
> LLVM Developers mailing list
> [hidden email]         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: AliasAnalysis calling failed in Pass interaction

Daniel Berlin
On Wed, Apr 29, 2015 at 2:05 PM, Shen Liu <[hidden email]> wrote:

> Hi Daniel, thanks for your reply! Yes I didn't implement AA by myself but
> called builtin -basicaa interface for temporary use. Just add the -basicaa
> option in my opt command.
>
> I hope -basicaa can be called to process to check some simple aliases. And
> when I do
>
> DataDependencyGraph &ddgGraph = getAnalysis<DataDependencyGraph>(*F);
>
> inside a Function Pass, it works.What make me confused is when my Pass is a
> Module Pass, --basicaa cannot be called anymore. It seems the -basicaa
> option cannot be seen by getAnalysis() if I call it in a Module Pass.

Using it as a command line option makes it run a pass. It does not
make it available to your pass.
Essentially, you are getting lucky.
The point at which basicaa gets runs when added as a command line
option happens to make it hang around at the point you are using a
function pass.

If you want this to work properly, always, the right thing to do is to
tell it you want alias analysis in your AnalysisUsage.

IE
  AU.addRequiredTransitive<AliasAnalysis>();


>
> Do you have any suggestions?
>
> Best Regards,
>
> Shen
>
>
>
> On Wed, Apr 29, 2015 at 4:45 PM, Daniel Berlin <[hidden email]> wrote:
>>
>> On Wed, Apr 29, 2015 at 1:27 PM, Shen Liu <[hidden email]> wrote:
>> > Dear LLVM developers,
>> >
>> > I am Shen, a PhD student at Lehigh Univ. PA.  Now I am implementing a
>> > Program Dependence Graph(PDG) on LLVM. I have 4 passes here:
>> >
>> > 1. ProgramDependenceGraph (a ModulePass on the highest level)
>> > 2. DataDependenceGraph (a Intermediate FunctionPass).
>> > 3. FlowDependenceAnalysis Pass (a intermediate FunctionPass) which uses
>> > llvm
>> > built-in AliasAnalysis (-basicaa)
>>
>> Does this implement AliasAnalysis?
>
>
>
>
>>
>>
>> > 4. AliasAnalysis Pass  (LLVM built-in Pass)
>> >
>> > When my call chain is
>> >
>> > DatadependenceGraph <-- FlowDependenceAnalysis <-- AliasAnalysis
>> >
>> > everything is fine and basicaa is executed successfully.
>>
>> BasicAA is not AliasAnalysis. BasicAA is *an* AliasAnalysis.
>>
>> If you have not added BasicAliasAnalysis to the pass list, it will not
>> be called when you call AliasAnalysis API.
>>
>> >
>> > My problem is, when I use a Module Pass to call a Function Pass, the low
>> > level AliasAnalysis does not work anymore, all return values for
>> > location
>> > comparisons are "May Alias". In other words, the call chain
>> >
>> > ProgramDependenceGraph(Module Pass) <-- DatadependenceGraph(Function
>> > Pass)
>> > <-- FlowDependenceAnalysis <-- AliasAnalysis if failed.
>> >
>> > However, if I change ProgramDependenceGraph into a Function Pass, this
>> > call
>> > chain works and AliasAnalysis can be executed successfully.
>> >
>> > So, i guess there may be an error in my interaction between Module Pass
>> > and
>> > Function Pass. Could you give me some hints to help me solve it? Thank
>> > you
>> > very much!
>> >
>> >
>> > Here are some key code for Pass interaction in my implementation:
>> >
>> > bool ProgramDependencyGraph::runOnModule(Module &M)
>> > {
>> >  ...
>> >   for(Module::iterator F = M.begin(), E = M.end(); F != E; ++F)
>> >     {
>> >        DataDependencyGraph &ddgGraph =
>> > getAnalysis<DataDependencyGraph>(*F);
>> >        ....
>> >     }
>> > }
>> >
>> > ...
>> > void ProgramDependencyGraph::getAnalysisUsage(AnalysisUsage &AU) const
>> > {
>> >    ...
>> >   AU.addRequired<DataDependencyGraph>();
>> >   AU.setPreservesAll();
>> > }
>> >
>>
>> This does not require alias analysis or it's analysis group, which is
>> wrong if you want those to work?
>>
>> >
>> > Best Regards,
>> >
>> > Shen
>> >
>> >
>> >
>> > _______________________________________________
>> > LLVM Developers mailing list
>> > [hidden email]         http://llvm.cs.uiuc.edu
>> > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>> >
>
>
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev