<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Mar 17, 2017 at 2:09 PM, Teresa Johnson <span dir="ltr"><<a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span class="gmail-">On Fri, Mar 17, 2017 at 2:05 PM, Peter Collingbourne <span dir="ltr"><<a href="mailto:peter@pcc.me.uk" target="_blank">peter@pcc.me.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto"><div>Can you achieve this by setting PreCodeGenModuleHook to a function that returns false?</div></div></blockquote><div><br></div></span><div>I thought about that, but it seemed clearer to be explicit about the intent. I thought the intended purpose of returning when a hook returned false was that it was to flag error conditions?</div></div></div></div></blockquote><div><br></div><div>Sorry for dropping the ball on this thread.</div><div><br></div><div>The purpose is to allow the client to interrupt the flow for any reason. See for example <a href="http://llvm-cs.pcc.me.uk/tools/gold/gold-plugin.cpp#757">http://llvm-cs.pcc.me.uk/tools/gold/gold-plugin.cpp#757</a> for how this feature is used in the gold plugin. -emit-llvm is very similar to that use case.</div><div><br></div><div>Peter</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br></div><div>Teresa</div><div><div class="gmail-h5"><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"><div dir="auto"><div><span class="gmail-m_4017330461680162135HOEnZb"><font color="#888888"><div dir="auto"><br></div><div dir="auto">Peter</div></font></span><div><div class="gmail-m_4017330461680162135h5"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mar 17, 2017 14:01, "Teresa Johnson via Phabricator" <<a href="mailto:reviews@reviews.llvm.org" target="_blank">reviews@reviews.llvm.org</a>> wrote:<br type="attribution"><blockquote class="gmail-m_4017330461680162135m_-9216950914819362284quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">tejohnson created this revision.<br>
Herald added a subscriber: mehdi_amini.<br>
<br>
This is useful when invoking the ThinLTO backend via clang, which<br>
already has handling (immediately after the existing early return<br>
when invoking the ThinLTO backend) for setting up the requested code<br>
generation.<br>
<br>
We noticed that when invoking the thinBackend via clang (for the<br>
distributed build case) that flags like -ffunction-sections and<br>
-emit-llvm were not having the intended effect. This could have been<br>
fixed by setting up the TargetOptions and the CodeGenFileType in the LTO<br>
Config, but since clang already has handling for all of this, it is<br>
straightforward to just let it do the handling.<br>
<br>
<br>
<a href="https://reviews.llvm.org/D31100" rel="noreferrer" target="_blank">https://reviews.llvm.org/D3110<wbr>0</a><br>
<br>
Files:<br>
  include/llvm/LTO/Config.h<br>
  lib/LTO/LTOBackend.cpp<br>
<br>
<br>
Index: lib/LTO/LTOBackend.cpp<br>
==============================<wbr>==============================<wbr>=======<br>
--- lib/LTO/LTOBackend.cpp<br>
+++ lib/LTO/LTOBackend.cpp<br>
@@ -269,6 +269,9 @@<br>
   if (Conf.PreCodeGenModuleHook && !Conf.PreCodeGenModuleHook(Tas<wbr>k, Mod))<br>
     return;<br>
<br>
+  if (Conf.SkipCodeGen)<br>
+    return;<br>
+<br>
   auto Stream = AddStream(Task);<br>
   legacy::PassManager CodeGenPasses;<br>
   if (TM->addPassesToEmitFile(CodeG<wbr>enPasses, *Stream->OS, Conf.CGFileType))<br>
Index: include/llvm/LTO/Config.h<br>
==============================<wbr>==============================<wbr>=======<br>
--- include/llvm/LTO/Config.h<br>
+++ include/llvm/LTO/Config.h<br>
@@ -49,6 +49,9 @@<br>
   /// Disable entirely the optimizer, including importing for ThinLTO<br>
   bool CodeGenOnly = false;<br>
<br>
+  /// Skip code generation, the client is responsible for it.<br>
+  bool SkipCodeGen = false;<br>
+<br>
   /// If this field is set, the set of passes run in the middle-end optimizer<br>
   /// will be the one specified by the string. Only works with the new pass<br>
   /// manager as the old one doesn't have this ability.<br>
<br>
<br>
</blockquote></div><br></div></div></div></div></div>
</blockquote></div></div></div><span class="gmail-HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div class="gmail-m_4017330461680162135gmail_signature"><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)"> <a href="tel:(408)%20460-2413" value="+14084602413" target="_blank">408-460-2413</a></td></tr></tbody></table></span></div>
</font></span></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr">-- <div>Peter</div></div></div>
</div></div>