<div dir="auto"><div>Can you achieve this by setting PreCodeGenModuleHook to a function that returns false?<div dir="auto"><br></div><div dir="auto">Peter</div><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">reviews@reviews.llvm.org</a>> wrote:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;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/<wbr>D31100</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(<wbr>Task, Mod))<br>
     return;<br>
<br>
+  if (Conf.SkipCodeGen)<br>
+    return;<br>
+<br>
   auto Stream = AddStream(Task);<br>
   legacy::PassManager CodeGenPasses;<br>
   if (TM->addPassesToEmitFile(<wbr>CodeGenPasses, *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>