[LLVMdev] Using an alias analysis pass

Félix Cloutier felixcca at yahoo.ca
Tue Apr 21 15:55:52 PDT 2015


> Le 2015-04-21 à 18:36:38, Daniel Berlin <dberlin at dberlin.org> a écrit :
> 
>> I made it a FunctionPass instead of an ImmutablePass because
>> InitializeAliasAnalysis now needs a DataLayout argument, and I wasn’t sure
>> how to get that one from an ImmutablePass.
> 
> See CFLAliasAnalysis.cpp. You can get the datalayout from
> doInitialization from the module.

This is also what NoAA does, but given that it’s a bit special, I wasn’t sure if it was desirable.

I returned to that, and with the RegisterPass change, this appears to work as expected, so problem solved?

>> 
>> The first was to add the AA pass before calling `populateModulePassManager`,
>> since the AA passes are the first ones to be added, and this would put mine
>> first. This didn’t help: `runOnFunction` was called, but `alias` never was.
> 
> Okay, so without seeing what passes you are adding, i can't say why
> alias was never called.
> 
> You need to ensure you are adding the pass in the right order.
> The first pass added to AA is the last pass queried (IE it's reverse order)


I figured that the last pass added has precedence a the comment that says that TBAA is added before Basic AA so that Basic AA wins in case of a disagreement, but since that it didn’t work, I tried the other way too.

For future reference, PassManagerBuilder creates the following AA passes <http://llvm.org/docs/doxygen/html/PassManagerBuilder_8cpp_source.html#l00136>:

if (UseCFLAA <http://llvm.org/docs/doxygen/html/PassManagerBuilder_8cpp.html#a4e59132007f4c97b2a808df5fedf9584>)
  PM.add <http://llvm.org/docs/doxygen/html/classllvm_1_1legacy_1_1PassManagerBase.html#a2ce2eacfa52640d3a2feb2d46d561b85>(createCFLAliasAnalysisPass <http://llvm.org/docs/doxygen/html/namespacellvm.html#aa497e235b2414fe9e942c308aa6edcb6>());
PM.add <http://llvm.org/docs/doxygen/html/classllvm_1_1legacy_1_1PassManagerBase.html#a2ce2eacfa52640d3a2feb2d46d561b85>(createTypeBasedAliasAnalysisPass <http://llvm.org/docs/doxygen/html/namespacellvm.html#a022323238327ae5edae5d42398e0325f>());
PM.add <http://llvm.org/docs/doxygen/html/classllvm_1_1legacy_1_1PassManagerBase.html#a2ce2eacfa52640d3a2feb2d46d561b85>(createScopedNoAliasAAPass <http://llvm.org/docs/doxygen/html/namespacellvm.html#ad81266aaa6ff7606ad771dc5e451592b>());
PM.add <http://llvm.org/docs/doxygen/html/classllvm_1_1legacy_1_1PassManagerBase.html#a2ce2eacfa52640d3a2feb2d46d561b85>(createBasicAliasAnalysisPass <http://llvm.org/docs/doxygen/html/namespacellvm.html#ab81115c38e816dea4cb563ca24faed96>());

Thanks for your help.

Félix
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150421/bcc19d98/attachment.html>


More information about the llvm-dev mailing list