<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 8, 2016, at 5:09 PM, Maxime Chevalier-Boisvert <<a href="mailto:maximecb@apple.com" class="">maximecb@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">You’re saying that we shouldn’t release resources until doFinalization? </div></div></div></blockquote><div><br class=""></div><div>Yes: this seems to be the semantic of your pass, you *need* to keep the results alive for the duration of the pipeline on the module you are processing for it to be correct. The doInitialization() and doFinalization() methods are the boundaries that indicates when the pass manager starts a module and end a module.</div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">That doesn’t seem like it solves the fundamental issue. The pass in question has its results cleared and recomputed multiple times. We don’t really understand why our pass is marked as dead when it’s needed later in the pipeline.</div></div></div></blockquote><div><br class=""></div><div>The fact that it is needed later is not enough, to avoid getting a call to “releaseMemory()” it also has to be marked as preserved by every single pass in the pipeline.</div><div><br class=""></div><div>Basically your ImmutableAnalysis is a kind of “manually managed” analysis with state that you manage outside of the knowledge of the passmanager. </div><div><br class=""></div><div>In any case it should always be “correct” to ignore the calls to releaseMemory(), I believe this is just an optimization: it semantic AFAIK is that the pass manager signals it does not know of a pass that will use the result of this analysis, so it can be free’d now to reduce the peak memory.</div><div>(In fact it is correct only if the runOnXXX() method can deal with the pass not being cleaned, but it does not matter for an immutable pass, it is never run).</div><div><br class=""></div><div>On the other hand, doFinalization() should always clear the internal state for correctness though (it depends on the kind of state you have, but as a general rule…).</div><div><br class=""></div><div>Hope this help.</div><div><br class=""></div><div>— </div><div>Mehdi</div><div><br class=""></div><div><br class=""></div><div><br class=""></div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div><div class="">- Maxime</div><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Dec 8, 2016, at 4:13 PM, Mehdi Amini <<a href="mailto:mehdi.amini@apple.com" class="">mehdi.amini@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi,<div class=""><br class=""></div><div class="">There are two relevant hooks for you immutable pass: </div><div class=""><br class=""></div><div class="">1) releaseMemory()</div><div class="">2) doFinalization()</div><div class=""><br class=""></div><div class="">Are you looking at the first one? I think you should act on the second instead and it should solve your issue.</div><div class=""><br class=""></div><div class="">— </div><div class="">Mehdi</div><div class=""><br class=""></div><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Dec 8, 2016, at 10:58 AM, Maxime Chevalier-Boisvert via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">We have our own subtarget, with its own pipeline and set of passes.</div><div class=""><br class=""></div><div class="">The problem I’m facing, as explained, is that adding the DummyCGSCCPass to our pipeline causes an early pass to be finalized when it shouldn’t be. The information then becomes unavailable when needed, in the machine code generation part of our pipeline.</div><div class=""><br class=""></div><div class="">It’s unclear to us why this is happening. I was hoping someone familiar with the pass manager may have advice, or that someone may have run into a similar problem before.</div><div class=""><br class=""></div><div class="">- Maxime</div><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div class="">On Dec 7, 2016, at 9:46 PM, vivek pandya via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>> wrote:</div><div class=""><div dir="ltr" class=""><br class=""><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br class=""><br class="">
Hello,<br class="">
<br class="">
I'm trying to enable interprocedural register allocation (IPRA).</blockquote><div class="">Hi Maxime,</div><div class=""><br class=""></div><div class="">I don't understand here why you need to enable IPRA as that is already scheduled based on option -mllvm -enable-ipra. So I think easy way to make IPRA execute every time is to set default value of EnableIPRA option to true.</div><div class="">you can find this option defined in lib/CodeGen/TargetMachine.cpp and you may also need to change its initialization to true in TargetOptions constructor in include/llvm/Target/TargetOptions.h</div><div class=""><br class=""></div><div class="">- Vivek</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> In order to do this, I’ve added the DummyCGSCCPass to our pipeline, as is done in TargetPassConfig::<wbr class="">addISelPrepare. My understanding is that this pass wraps the following passes into an SCC pass manager, so that they are run in bottom-up order, which is necessary to enable register allocation info from callees to be available at call sites.<br class="">
<br class="">
The problem I’m running into is that we have an ImmutablePass which is run early in our pipeline (and needed in later machine code generation stages), and for some reason, this pass gets finalized and re-run multiple times, destroying the information we need in the process. I’m really not sure what is happening. The pass is clearly marked as required by later passes, but somehow it is found to be “dead”, finalized, and then re-run. To make matters more confusing, we have another ImmutablePass which is run early and used late, but this one doesn’t get finalized. My coworkers and I are really not sure what the difference might be.<br class="">
<br class="">
Could someone more familiar with IPRA or the PassManager provide some hints as to what might be happening?<br class="">
<br class="">
Regards,<br class="">
<br class="">
- Maxime<br class=""></blockquote></div></div></div>
_______________________________________________<br class="">LLVM Developers mailing list<br class=""><a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a><br class=""><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br class=""></div></blockquote></div><br class=""></div>_______________________________________________<br class="">LLVM Developers mailing list<br class=""><a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a><br class=""><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br class=""></div></blockquote></div><br class=""></div></div></div></blockquote></div><br class=""></div></div></blockquote></div><br class=""></body></html>