<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
span.hoenzb
        {mso-style-name:hoenzb;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="SV" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">Thanks Philip!<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">Based on your input we will stop using/testing -die for our out-of-tree target.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">I guess that the DeadInstructionElimination pass will be removed when the new PM is default. But maybe we can get rid of it already before that?
<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">It does not seem to be used (in-tree) except for some lit-tests. If we replace those uses by -dce, then maybe the pass can be removed right away.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">And I assume that -print-bb also should be removed (since it is a BasicBlockPass).<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">/Björn<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US">From:</span></b><span lang="EN-US"> Philip Pfaffe [mailto:philip.pfaffe@gmail.com]
<br>
<b>Sent:</b> den 8 maj 2018 16:46<br>
<b>To:</b> Björn Pettersson A <bjorn.a.pettersson@ericsson.com><br>
<b>Cc:</b> Sanjoy Das <sanjoy@playingwithpointers.com>; Chandler Carruth <chandlerc@google.com>; llvm-dev@lists.llvm.org<br>
<b>Subject:</b> Re: [llvm-dev] Preservation of CallGraph (by BasicBlockPass, FunctionPass)<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">Hi Björn,<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">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><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">-die is not implemented, since the new pass manager does not support BasicBlock passes. But you can use dce instead: "-passes=dce"<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">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.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Cheers,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Philip<o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">2018-05-08 15:56 GMT+02:00 Björn Pettersson A via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>>:<o:p></o:p></p>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<p class="MsoNormal">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 style="color:#888888"><br>
<span class="hoenzb">/Björn</span></span><o:p></o:p></p>
<div>
<div>
<p class="MsoNormal"><br>
> -----Original Message-----<br>
> From: Sanjoy Das [mailto:<a href="mailto:sanjoy@playingwithpointers.com">sanjoy@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.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::updateCGAndAnalysisManagerForFunctionPass 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>
> > ;----------------------------------------------------------------<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>
> > ;----------------------------------------------------------------<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::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>
> > _______________________________________________<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" target="_blank">
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
> ><br>
_______________________________________________<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" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><o:p></o:p></p>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</div>
</body>
</html>