<div dir="ltr">Hi Björn,<div><br></div><div>1) The pass pipeline syntax is documented here: <a href="https://github.com/llvm-project/llvm/blob/master/include/llvm/Passes/PassBuilder.h#L378">https://github.com/llvm-project/llvm/blob/master/include/llvm/Passes/PassBuilder.h#L378</a></div><div>-die is not implemented, since the new pass manager does not support BasicBlock passes. But you can use dce instead: "-passes=dce"</div><div><br></div><div>2) I don't have a qualified answer here, but if I recall correctly, the trouble to correctly update the callgraph was the main motivation for the new PM in the first place.</div><div><br></div><div>Cheers,</div><div>Philip</div></div><div class="gmail_extra"><br><div class="gmail_quote">2018-05-08 15:56 GMT+02:00 Björn Pettersson A via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Well, do you have a patch that enables the new pass manager that we can land then?<br>
<br>
To be more serious:<br>
<br>
1) I don't even know how to run those passes using the new pass manager even if it where enabled by default. I guess that I'm supposed to use -passes. Is there a syntax description for that option somewhere? How do I for example run -die?<br>
<br>
2) "Use the new pass manager" does not answer the question if a basic block may destroy the call graph. Or if it is incorrect for the FPPassManager to say that it preserves all analyses.<br>
<span class="HOEnZb"><font color="#888888"><br>
/Björn<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
> -----Original Message-----<br>
> From: Sanjoy Das [mailto:<a href="mailto:sanjoy@playingwithpointers.com">sanjoy@<wbr>playingwithpointers.com</a>]<br>
> Sent: den 7 maj 2018 20:22<br>
> To: Björn Pettersson A <<a href="mailto:bjorn.a.pettersson@ericsson.com">bjorn.a.pettersson@ericsson.<wbr>com</a>>; Chandler<br>
> Carruth <<a href="mailto:chandlerc@google.com">chandlerc@google.com</a>><br>
> Cc: <a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
> Subject: Re: [llvm-dev] Preservation of CallGraph (by BasicBlockPass,<br>
> FunctionPass)<br>
> <br>
> I'm not sure about the old pass manager, but I think the new pass<br>
> manager solves this issue.  See<br>
> llvm::<wbr>updateCGAndAnalysisManagerForF<wbr>unctionPass where it updates the<br>
> call graph to be in sync with edges deleted by function passes.  So I<br>
> suspect the right fix is to use the new pass manager.<br>
> <br>
> -- Sanjoy<br>
> <br>
> On Mon, May 7, 2018 at 7:32 AM, Björn Pettersson A via llvm-dev<br>
> <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br>
> > If I run:<br>
> ><br>
> >   opt -globals-aa -die -inline -debug-pass=Details foo.ll -S<br>
> ><br>
> ><br>
> ><br>
> > then I will get this pass structure:<br>
> ><br>
> ><br>
> ><br>
> > Target Library Information<br>
> ><br>
> > Target Transform Information<br>
> ><br>
> > Target Pass Configuration<br>
> ><br>
> > Assumption Cache Tracker<br>
> ><br>
> > Profile summary info<br>
> ><br>
> >   ModulePass Manager<br>
> ><br>
> >     CallGraph Construction<br>
> ><br>
> >     Globals Alias Analysis<br>
> ><br>
> >     FunctionPass Manager<br>
> ><br>
> >       BasicBlockPass Manager<br>
> ><br>
> >         Dead Instruction Elimination<br>
> ><br>
> >     Call Graph SCC Pass Manager<br>
> ><br>
> >       Function Integration/Inlining<br>
> ><br>
> >       FunctionPass Manager<br>
> ><br>
> >         Module Verifier<br>
> ><br>
> >     Print Module IR<br>
> ><br>
> ><br>
> ><br>
> ><br>
> ><br>
> > FPPassManager:: getAnalysisUsage is doing setPreservesAll(),<br>
> ><br>
> > but is it correct that the FunctionPass Manager always preserves the<br>
> > CallGraph?<br>
> ><br>
> ><br>
> ><br>
> ><br>
> ><br>
> > My real problem is that when I use a foo.ll input that looks like this:<br>
> ><br>
> ><br>
> ><br>
> > ;-----------------------------<wbr>------------------------------<wbr>-----<br>
> ><br>
> > target triple = "x86_64-unknown-linux-gnu"<br>
> ><br>
> ><br>
> ><br>
> > @b = external global i16, align 1<br>
> ><br>
> ><br>
> ><br>
> > ; Function Attrs: nounwind readnone<br>
> ><br>
> > define i16 @f1() #0 {<br>
> ><br>
> > entry:<br>
> ><br>
> >   ret i16 undef<br>
> ><br>
> > }<br>
> ><br>
> ><br>
> ><br>
> > define void @f2() {<br>
> ><br>
> > entry:<br>
> ><br>
> >   %call = call i16 @f1()<br>
> ><br>
> >   store i16 %call, i16* @b, align 1<br>
> ><br>
> >   %call1 = call i16 @f1()<br>
> ><br>
> >   ret void<br>
> ><br>
> > }<br>
> ><br>
> ><br>
> ><br>
> > attributes #0 = { nounwind readnone }<br>
> ><br>
> > ;-----------------------------<wbr>------------------------------<wbr>-----<br>
> ><br>
> ><br>
> ><br>
> > then %call1 will be removed by the Dead Instruction Elimination pass. I.e.<br>
> > that pass is not preserving the CallGraph!<br>
> ><br>
> ><br>
> ><br>
> > Dead Instruction Elimination is a BasicBlockPass, and<br>
> > DeadInstElimination::<wbr>getAnalysisUsage is doing setPreservesCFG() (even<br>
> > though that should be implicit for a BasicBlockPass afaik).<br>
> ><br>
> > When reading the description of BasicBlockPass it seems to be legal to<br>
> > remove calls, and that should not impact the CFG, right? But it will impact<br>
> > the CallGraph.<br>
> ><br>
> ><br>
> ><br>
> > I believe that when the FunctionPass Manager is used from within the Call<br>
> > Graph SCC Pass Manager, then the CGPassManager will check the<br>
> modification<br>
> > status from the FPManager and call RefreshCallGraph() (or set<br>
> > CallGraphUpToDate=false;) in case modification had been done. Thus, it<br>
> seems<br>
> > to be legit for a FunctionPass (and thereby also the FunctionPassManager)<br>
> to<br>
> > not always preserve the CallGraph. And I think this is handled within the<br>
> > CGPassManager, but not when FPManager is executed directly from the<br>
> > MPManager<br>
> ><br>
> ><br>
> ><br>
> > Currently the test case above will end up in an assert, since there is a<br>
> > missing use of @f1 in the CallGraph when doing the inlining.<br>
> ><br>
> > That will go away if I remove the setPreservesAll from the FPPassManager::<br>
> > getAnalysisUsage (which I assume is too aggressive).<br>
> ><br>
> ><br>
> ><br>
> > Would it be correct to change the FPPassManager:: getAnalysisUsage to<br>
> > exclude “CallGraph Construction” from the set of preserved analyses, or<br>
> am I<br>
> > missing something here?<br>
> ><br>
> ><br>
> ><br>
> > I assume that DeadInstElimination isn’t preserving the CallGraph. Shouldn’t<br>
> > that (automatically/dynamically) impact which analyses that are preserved<br>
> > from the BBPassManager and the FPPassManager for this pass structure?<br>
> ><br>
> ><br>
> ><br>
> > Regards,<br>
> ><br>
> > Björn<br>
> ><br>
> ><br>
> > ______________________________<wbr>_________________<br>
> > LLVM Developers mailing list<br>
> > <a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
> > <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
> ><br>
______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
</div></div></blockquote></div><br></div>