<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="">+Teresa, Mehdi<div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On May 2, 2017, at 08:31, James Henderson <<a href="mailto:jh7370.2008@my.bristol.ac.uk" class="">jh7370.2008@my.bristol.ac.uk</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><p class="gmail-MsoPlainText">Hi,</p><p class="gmail-MsoPlainText">We have been investigating an issue when running LTO with
our proprietary linker, which links against libLTO dynamically. The issue is
that when we pass -time-passes via the lto_codegen_debug_options function in the
LTO C API, no time information is produced during compilation. The reason for
this is that time information is stored in state owned by a ManagedStatic
instance, and is only printed when the state is destroyed. This in turn only
happens when ManagedStatics are cleaned up, via the llvm_shutdown function. As
we do not link against LLVM (except libLTO dynamically), we have no access to
llvm_shutdown, which in turn means we are not able to clean up ManagedStatic
instances and thus no timing information is produced.</p><p class="gmail-MsoPlainText">We have considered a few options and have come up with
the following suggestions, and would appreciate some feedback:</p><p class="gmail-MsoPlainText" style="margin-left:36pt"><span class=""><span class="">1)<span style="font:7pt "times new roman"" class="">      </span></span></span>Add
llvm_shutdown (or rather likely some wrapper function that does the same job)
to the C interface of libLTO. This should be called when we are done with the
library.</p></div></div></blockquote><div>This seems pretty reasonable to me.  I'm not sure what others think.</div><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><p class="gmail-MsoPlainText" style="margin-left:36pt"><span class=""><span class="">2)<span style="font:7pt "times new roman"" class="">      </span></span></span>Add
a “full-shutdown” command-line option to LLVM - that can be passed via
lto_codegen_debug_options - which causes ManagedStatic-owned state to be
destroyed on shutdown. This could even be more widely useful outside the LTO
case.</p><p class="gmail-MsoPlainText" style="margin-left:36pt"><span class=""><span class="">3)<span style="font:7pt "times new roman"" class="">      </span></span></span>Call
llvm_shutdown() immediately after compilation as part of the compile function.</p><p class="gmail-MsoPlainText" style="margin-left:36pt"><span class=""><span class="">4)<span style="font:7pt "times new roman"" class="">      </span></span></span>None
of the above, because there’s a better way that I am unaware of to clean up
this state.</p></div></div></blockquote><div>Perhaps this timing stuff should live in the LLVMContext instead?  And then you get timing-per-LLVMContext?</div><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><p class="gmail-MsoPlainText">I have a marginal preference for 1), but does anybody have any other preferences or suggestions?<br class=""></p><p class="gmail-MsoPlainText">Regards,</p>



<span style="font-size:11pt;font-family:"calibri",sans-serif" class="">James</span></div>
</div></blockquote></div><br class=""></div></body></html>