<div dir="ltr"><div>Hi Mindong,</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Nov 27, 2019 at 3:29 AM chenmindong via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
I'm working on enabling thinLTO for our custom backend on LLVM-8 with lld to get code size benefits from dead symbol elimination. The code in LTO::run() of LTO.cpp confuses me that, even though thinLTO is specified, runRegularLTO() will be run first and its return value determines whether runThinLTO() will be executed. <br>
<br>
My question is if it's clearly known that thinLTO is used, is it still necessary to execute runRegularLTO()?If it is, what's the reason behind?</blockquote><div><br></div><div>This is to handle the case where the LTO link is given a mix of regular and thin LTO bitcode - it should do regular LTO on that subset and ThinLTO on the other. The other case this handles is when a bitcode object is split into regular and thin LTO halves - this is enabled for things like CFI but shouldn't be the default currently (you'd have to build with -fsplit-lto-unit to get it unless you are building with CFI).</div><div><br></div><div>Whether the bitcode is added to the regular or Thin LTO partition is determined in LTO::addModule, and is based on a flag set when the bitcode is read which is based in turn on whether the bitcode has a summary block, and whether that is a thinlto or regular (full) LTO summary block. How are you creating your bitcode files? If you run llvm-dis on it does it have summary entries? You can also see if you run llvm-bcanalyzer whether it has a GLOBALVAL_SUMMARY_BLOCK or a FULL_LTO_GLOBALVAL_SUMMARY_BLOCK or neither. If you are compiling with -flto=thin you should realistically have the former, which would make it a ThinLTO bitcode. But it sounds like you have some objects that either don't or have the full LTO summary.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> For now our custom backend, where distributed thinLTO is adopted, it works fine as I removed the line executing runRegularLTO(). But if I preserve it, the code fails the `if (Conf.PostInternalizeModuleHook &&!Conf.PostInternalizeModuleHook(0, *RegularLTO.CombinedModule))`, which I also don't understand, and fall through to backend() and abort there. I believe something is missed during adding the target support but cannot figure it out. Could anyone help?<br></blockquote><div><br></div><div>By default there should not be a PostInternalizeModuleHook set (it is set to support cases like -save-temps), so it isn't surprising that it would fail that test and fall through to the backend() call, which is what you would want if there was a regular LTO partition. Where is it aborting in the backend?</div><div><br></div><div>Teresa</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Regards,<br>
Mindong Chen<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><span style="font-family:Times;font-size:medium"><table cellspacing="0" cellpadding="0"><tbody><tr style="color:rgb(85,85,85);font-family:sans-serif;font-size:small"><td nowrap style="border-top:2px solid rgb(213,15,37)">Teresa Johnson |</td><td nowrap style="border-top:2px solid rgb(51,105,232)"> Software Engineer |</td><td nowrap style="border-top:2px solid rgb(0,153,57)"> <a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a> |</td><td nowrap style="border-top:2px solid rgb(238,178,17)"><br></td></tr></tbody></table></span></div></div></div></div>