[PATCH] D31100: [LTO] Allow client to skip code gen
Teresa Johnson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 30 13:38:42 PDT 2017
tejohnson updated this revision to Diff 93534.
tejohnson added a comment.
Add support for allowing LTO client to emit LLVM IR assembly or bitcode.
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
@@ -21,6 +21,8 @@
#include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/Bitcode/BitcodeReader.h"
#include "llvm/Bitcode/BitcodeWriter.h"
+#include "llvm/Bitcode/BitcodeWriterPass.h"
+#include "llvm/IR/IRPrintingPasses.h"
#include "llvm/IR/LegacyPassManager.h"
#include "llvm/IR/PassManager.h"
#include "llvm/IR/Verifier.h"
@@ -269,11 +271,32 @@
if (Conf.PreCodeGenModuleHook && !Conf.PreCodeGenModuleHook(Task, Mod))
return;
- auto Stream = AddStream(Task);
- legacy::PassManager CodeGenPasses;
- if (TM->addPassesToEmitFile(CodeGenPasses, *Stream->OS, Conf.CGFileType))
- report_fatal_error("Failed to setup codegen");
- CodeGenPasses.run(Mod);
+ switch (Conf.IROutputType) {
+ case Config::EIRT_Nothing:
+ break;
+
+ case Config::EIRT_BC: {
+ auto Stream = AddStream(Task);
+ legacy::PassManager PerModulePasses;
+ PerModulePasses.add(createBitcodeWriterPass(*Stream->OS));
+ PerModulePasses.run(Mod);
+ } break;
+
+ case Config::EIRT_LL: {
+ auto Stream = AddStream(Task);
+ legacy::PassManager PerModulePasses;
+ PerModulePasses.add(createPrintModulePass(*Stream->OS));
+ PerModulePasses.run(Mod);
+ } break;
+
+ case Config::EIRT_CodeGen: {
+ auto Stream = AddStream(Task);
+ legacy::PassManager CodeGenPasses;
+ if (TM->addPassesToEmitFile(CodeGenPasses, *Stream->OS, Conf.CGFileType))
+ report_fatal_error("Failed to setup codegen");
+ CodeGenPasses.run(Mod);
+ } break;
+ }
}
void splitCodeGen(Config &C, TargetMachine *TM, AddStreamFn AddStream,
Index: include/llvm/LTO/Config.h
===================================================================
--- include/llvm/LTO/Config.h
+++ include/llvm/LTO/Config.h
@@ -46,6 +46,16 @@
unsigned OptLevel = 2;
bool DisableVerify = false;
+ enum EmitIRType {
+ EIRT_CodeGen, /// Do CodeGen and emit CGFileType
+ EIRT_LL, /// Emit human-readable LLVM assembly
+ EIRT_BC, /// Emit LLVM bitcode files
+ EIRT_Nothing, /// Don't emit anything (benchmarking mode)
+ };
+
+ /// Type of IR file to output, defaults to none (do codegen).
+ EmitIRType IROutputType = EIRT_CodeGen;
+
/// Disable entirely the optimizer, including importing for ThinLTO
bool CodeGenOnly = false;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31100.93534.patch
Type: text/x-patch
Size: 2396 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170330/acf042d9/attachment-0001.bin>
More information about the llvm-commits
mailing list