[LLVMdev] why functionattrs doesn't add dependency of AliasAnalysis

Nick Lewycky nicholas at mxc.ca
Thu Sep 5 01:24:24 PDT 2013


Liu Xin wrote:
> Hi, List,
>
> As you may know, BCC of android makes use of LLVM's major components.
> Its LTO actually selects some optimizations of LLVM.
>
> I found it can not only use "-functionattrs". I must first use
> -argpromotion first, or I end up this error:
>
> Pass 'Deduce function attributes' is not initialized.
> Verify if there is a pass dependency cycle.
> Required Passes:
> bcc: external/llvm/lib/VMCore/PassManager.cpp:616: void
> llvm::PMTopLevelManager::schedulePass(llvm::Pass*): Assertion `PI &&
> "Expected required passes to be initialized"' failed.
>
> The strangest thing is the opt doesn't suffer from this issue. please
> note that directly use -functionattrs, it can run without AliasAnalysis.
>   Could you explain why?
>
> liuxin at rd58:~/testbed$ opt  -functionattrs -debug-pass=Structure < pf.bc
>  > /dev/null
> Pass Arguments:  -targetlibinfo -no-aa -basiccg -functionattrs
> -preverify -domtree -verify
> Target Library Information
> No Alias Analysis (always returns 'may' alias)
>    ModulePass Manager
>      Basic CallGraph Construction
>      Call Graph SCC Pass Manager
>        Deduce function attributes
>        FunctionPass Manager
>          Preliminary module verification
>          Dominator Tree Construction
>          Module Verifier
>      Bitcode Writer
>
>
> I checked out the latest svn code of LLVM. Clearly, FunctionAttrs
> requires AliasAnalysis of AU.
>
>      virtual void getAnalysisUsage(AnalysisUsage &AU) const {
>        AU.setPreservesCFG();
>        AU.addRequired<AliasAnalysis>();
>        AU.addRequired<TargetLibraryInfo>();
>        CallGraphSCCPass::getAnalysisUsage(AU);
>      }
>
> My changeset is almost like this. the issue has gone away.
>
> --- a/lib/Transforms/IPO/FunctionAttrs.cpp
> +++ b/lib/Transforms/IPO/FunctionAttrs.cpp
> @@ -76,6 +76,7 @@ namespace {
>   char FunctionAttrs::ID = 0;
>   INITIALIZE_PASS_BEGIN(FunctionAttrs, "functionattrs",
> "Deduce function attributes", false, false)
> +INITIALIZE_AG_DEPENDENCY(AliasAnalysis)
>   INITIALIZE_AG_DEPENDENCY(CallGraph)
>   INITIALIZE_PASS_END(FunctionAttrs, "functionattrs",
> "Deduce function attributes", false, false)
>
>
> Do you guys just miss the dependency for it?

I think we missed the dependency for it. Fixed in r190035. Thanks!

Nick



More information about the llvm-dev mailing list