<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<br>
<br>
<div class="moz-cite-prefix">On 09/03/2018 03:51 AM, De Azevedo
Piovezan, Felipe wrote:<br>
</div>
<blockquote type="cite"
cite="mid:A18E5F8395391E4490DFB8586DAF6E6C011ADF58@ORSMSX108.amr.corp.intel.com">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<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:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
color:black;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
{mso-style-priority:34;
margin-top:0in;
margin-right:0in;
margin-bottom:0in;
margin-left:.5in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
color:black;}
span.EmailStyle18
{mso-style-type:personal;
font-family:"Calibri",sans-serif;
color:windowtext;}
span.EmailStyle19
{mso-style-type:personal;
font-family:"Calibri",sans-serif;
color:#1F497D;}
span.EmailStyle20
{mso-style-type:personal-compose;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
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]-->
<div class="WordSection1">
<p class="MsoNormal"><span style="color:windowtext">Thanks for
the reply, Fedor!<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext">>You dont
need to operate with classes defined in
PassManagerInternal.h<br>
>They are, well, internal.<br>
>Unless you want to hack into the details of PassManager
implementation</span><span style="color:windowtext"><o:p></o:p></span></p>
<p class="MsoNormal"><a name="_MailEndCompose"
moz-do-not-send="true"><span style="color:windowtext"><o:p> </o:p></span></a></p>
<p class="MsoNormal"><span style="color:windowtext">Apologies,
this was a bit of miscommunication on my part: I am indeed
trying to “open the box” of the new PM, not merely use it;
it’s a good opportunity to learn about the techniques
employed there.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext">In order to
do so, I was trying to understand some of the decisions made
in that header, and two of them stood out as odd.</span></p>
</div>
</blockquote>
Ah, okey.<br>
The main trick, as you might have got already, is using a tiny
Concept/Model wrapper <span style="color:windowtext"><o:p> to
provide virtual dispatch to an arbitrary class implementing
pass/analysis.<br>
</o:p></span>
<blockquote type="cite"
cite="mid:A18E5F8395391E4490DFB8586DAF6E6C011ADF58@ORSMSX108.amr.corp.intel.com">
<div class="WordSection1">
<p class="MsoNormal"><span style="color:windowtext">The first
one is a case where we are using override on a method but
allowing a function signature mismatch (PreservedAnalysisT
vs PreservedAnalysis).</span></p>
</div>
</blockquote>
Yes, this one does look like an inconsistency.<br>
No harm done as there is no other PreservedAnalyses.<br>
And on mismatch it will raise an *error*, not a warning due to
'override' keyword.<br>
<blockquote type="cite"
cite="mid:A18E5F8395391E4490DFB8586DAF6E6C011ADF58@ORSMSX108.amr.corp.intel.com">
<div class="WordSection1">
<p class="MsoNormal"><span style="color:windowtext"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext">The second
is the use AnalysisManagerT vs AnalysisManager in a
seemingly arbitrary way.</span></p>
</div>
</blockquote>
And this one is not an issue.<br>
PassConcept/PassModel is an interface for the PassManager template,
and part of that interface involves operating on a particular<br>
AnalysisManagerT class, passed as a parameter to 'run' method.<br>
<br>
At the same time, AnalysisConcept/Analysis is an interface for the
AnalysisManager template, and part of AnalysisModel implementation<br>
involves dealing with a very specific specialization of
AnalysisManager<IRUnitT, ExtraArgTs...>, connecting this
AnalysisModel and this AnalysisManager<br>
specialization through this set of template parameters.<br>
<blockquote type="cite"
cite="mid:A18E5F8395391E4490DFB8586DAF6E6C011ADF58@ORSMSX108.amr.corp.intel.com">
<div class="WordSection1">
<p class="MsoNormal"><span style="color:windowtext">> </span><span
style="font-size:12.0pt;font-family:"Times New
Roman",serif;color:windowtext">Again, it is not an
inconsistency, just an implementation detail<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:12.0pt;font-family:"Times New
Roman",serif;color:windowtext"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext">That’s what
I have, so far, failed to see; I will keep exploring though
– the PassManager.h file is still being digested.</span></p>
</div>
</blockquote>
Feel free to ask questions if you happen to get more.<br>
<br>
regards,<br>
Fedor.<br>
<br>
<blockquote type="cite"
cite="mid:A18E5F8395391E4490DFB8586DAF6E6C011ADF58@ORSMSX108.amr.corp.intel.com">
<div class="WordSection1">
<p class="MsoNormal"><span style="color:windowtext"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1
1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><a name="_____replyseparator"
moz-do-not-send="true"></a><b><span
style="color:windowtext">From:</span></b><span
style="color:windowtext"> Fedor Sergeev
[<a class="moz-txt-link-freetext" href="mailto:fedor.sergeev@azul.com">mailto:fedor.sergeev@azul.com</a>]
<br>
<b>Sent:</b> Sunday, September 2, 2018 7:07 PM<br>
<b>To:</b> De Azevedo Piovezan, Felipe
<a class="moz-txt-link-rfc2396E" href="mailto:felipe.de.azevedo.piovezan@intel.com"><felipe.de.azevedo.piovezan@intel.com></a>;
<a class="moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<b>Subject:</b> Re: [llvm-dev] possible inconsistency in
PassManagerInternal.h<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom:12.0pt">You dont need
to operate with classes defined in PassManagerInternal.h<br>
They are, well, internal.<br>
<br>
Unless you want to hack into the details of PassManager
implementation all you need<br>
is to write a pass/analysis - which means implementing
corresponding ::run() method - and register<br>
it with the PassBuilder one way or another.<br>
<br>
There are plenty of real examples of how you can write a pass
in llvm source tree.<br>
Also there was a recent blog post mentioned on this list with
an introduction to new pass manager.<span
style="font-size:12.0pt"><o:p></o:p></span></p>
<div>
<p class="MsoNormal">On 09/02/2018 11:22 PM, De Azevedo
Piovezan, Felipe via llvm-dev wrote:<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal">Hello,<o:p></o:p></p>
<p class="MsoNormal">(fairly new around here, apologies if the
question has an obvious answer)<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">I’ve been studying the structure of the
new PassManager in the hopes of using it soon. After
watching a couple of talks (Chandler / Sergeev), I decided
to start with the Concept/Model classes in
PassManagerInternal.h<o:p></o:p></p>
<p class="MsoNormal">While I could make sense of almost
everything there, two details caught my attention:<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">1- The PassConcept abstract class has a
function `run = 0;` which returns an object of type
`PreservedAnalysis`. Such object is forward-declared in this
header, but it is defined in PassManager.h This is the only
place in the file where we reference this class.<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">However, right after, we define the
PassModel class which derives from PassConcept, and one of
its template parameters is a typename `PreservedAnalysisT`.
The implementation of the `run` method uses the keyword
override and it returns an object of type
`PreservedAnalysisT`. <o:p></o:p></p>
<p class="MsoNormal">This should raise a warning if
PreservedAnalysisT != PreservedAnalysis. Is this
intentional? My naive intuition is that we should have
removed PreservedAnalysisT from the template and used
PreservedAnalysis. However, everywhere else in the file
PreservedAnalysisT is used as template parameter.<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">Am I missing something obvious?<o:p></o:p></p>
</blockquote>
<p class="MsoNormal"><span
style="font-size:12.0pt;font-family:"Times New
Roman",serif">PassModel is a generic template helper
used deep inside PassManager template.<br>
You should neither be modifying anything in it nor using it
directly.<br>
<br>
And yes - PreservedAnalyses is the type that your Pass'
run() method should return.<br>
<br>
<br>
<o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">2- A similar issue arises when using
AnalysisManager. <o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">Both PassConcept and PassModel have a
template typename `AnalysisManagerT`.<o:p></o:p></p>
<p class="MsoNormal">However, AnalysisPassConcept and
AnalysisPassModel have no such template parameter; instead,
they use the forward-declared AnalysisManager type, defined
in PassManager.h<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">Again, is there a particular reason for
this apparent inconsistency?<o:p></o:p></p>
</blockquote>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span
style="font-size:12.0pt;font-family:"Times New
Roman",serif">Again, it is not an inconsistency, just
an implementation detail.<br>
Ignore it and jump straight to using various
AnalysisManagers defined in PassManager.h/LoopPassManager.h
etc.<br>
<br>
regards,<br>
Fedor.<o:p></o:p></span></p>
</div>
</blockquote>
<br>
</body>
</html>