[PATCH] D31100: [LTO] Allow client to skip code gen

Teresa Johnson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 17 14:01:33 PDT 2017


tejohnson created this revision.
Herald added a subscriber: mehdi_amini.

This is useful when invoking the ThinLTO backend via clang, which
already has handling (immediately after the existing early return
when invoking the ThinLTO backend) for setting up the requested code
generation.

We noticed that when invoking the thinBackend via clang (for the
distributed build case) that flags like -ffunction-sections and
-emit-llvm were not having the intended effect. This could have been
fixed by setting up the TargetOptions and the CodeGenFileType in the LTO
Config, but since clang already has handling for all of this, it is
straightforward to just let it do the handling.


https://reviews.llvm.org/D31100

Files:
  include/llvm/LTO/Config.h
  lib/LTO/LTOBackend.cpp


Index: lib/LTO/LTOBackend.cpp
===================================================================
--- lib/LTO/LTOBackend.cpp
+++ lib/LTO/LTOBackend.cpp
@@ -269,6 +269,9 @@
   if (Conf.PreCodeGenModuleHook && !Conf.PreCodeGenModuleHook(Task, Mod))
     return;
 
+  if (Conf.SkipCodeGen)
+    return;
+
   auto Stream = AddStream(Task);
   legacy::PassManager CodeGenPasses;
   if (TM->addPassesToEmitFile(CodeGenPasses, *Stream->OS, Conf.CGFileType))
Index: include/llvm/LTO/Config.h
===================================================================
--- include/llvm/LTO/Config.h
+++ include/llvm/LTO/Config.h
@@ -49,6 +49,9 @@
   /// Disable entirely the optimizer, including importing for ThinLTO
   bool CodeGenOnly = false;
 
+  /// Skip code generation, the client is responsible for it.
+  bool SkipCodeGen = false;
+
   /// If this field is set, the set of passes run in the middle-end optimizer
   /// will be the one specified by the string. Only works with the new pass
   /// manager as the old one doesn't have this ability.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31100.92197.patch
Type: text/x-patch
Size: 1039 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170317/7bfbb0fd/attachment.bin>


More information about the llvm-commits mailing list