diff options
Diffstat (limited to 'llvm/tools')
-rw-r--r-- | llvm/tools/opt/NewPMDriver.cpp | 15 | ||||
-rw-r--r-- | llvm/tools/opt/NewPMDriver.h | 10 | ||||
-rw-r--r-- | llvm/tools/opt/opt.cpp | 6 |
3 files changed, 23 insertions, 8 deletions
diff --git a/llvm/tools/opt/NewPMDriver.cpp b/llvm/tools/opt/NewPMDriver.cpp index df467da690e..58e9caeff0f 100644 --- a/llvm/tools/opt/NewPMDriver.cpp +++ b/llvm/tools/opt/NewPMDriver.cpp @@ -29,6 +29,7 @@ #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ToolOutputFile.h" #include "llvm/Target/TargetMachine.h" +#include "llvm/Transforms/IPO/ThinLTOBitcodeWriter.h" #include "llvm/Transforms/Scalar/LoopPassManager.h" using namespace llvm; @@ -47,8 +48,9 @@ static cl::opt<std::string> "pipeline for handling managed aliasing queries"), cl::Hidden); -bool llvm::runPassPipeline(StringRef Arg0, Module &M, - TargetMachine *TM, tool_output_file *Out, +bool llvm::runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM, + tool_output_file *Out, + tool_output_file *ThinLTOLinkOut, StringRef PassPipeline, OutputKind OK, VerifierKind VK, bool ShouldPreserveAssemblyUseListOrder, @@ -104,6 +106,10 @@ bool llvm::runPassPipeline(StringRef Arg0, Module &M, MPM.addPass(BitcodeWriterPass(Out->os(), ShouldPreserveBitcodeUseListOrder, EmitSummaryIndex, EmitModuleHash)); break; + case OK_OutputThinLTOBitcode: + MPM.addPass(ThinLTOBitcodeWriterPass( + Out->os(), ThinLTOLinkOut ? &ThinLTOLinkOut->os() : nullptr)); + break; } // Before executing passes, print the final values of the LLVM options. @@ -113,7 +119,10 @@ bool llvm::runPassPipeline(StringRef Arg0, Module &M, MPM.run(M, MAM); // Declare success. - if (OK != OK_NoOutput) + if (OK != OK_NoOutput) { Out->keep(); + if (OK == OK_OutputThinLTOBitcode && ThinLTOLinkOut) + ThinLTOLinkOut->keep(); + } return true; } diff --git a/llvm/tools/opt/NewPMDriver.h b/llvm/tools/opt/NewPMDriver.h index 04022e7ec56..8012e0a025c 100644 --- a/llvm/tools/opt/NewPMDriver.h +++ b/llvm/tools/opt/NewPMDriver.h @@ -32,7 +32,8 @@ namespace opt_tool { enum OutputKind { OK_NoOutput, OK_OutputAssembly, - OK_OutputBitcode + OK_OutputBitcode, + OK_OutputThinLTOBitcode, }; enum VerifierKind { VK_NoVerifier, @@ -47,8 +48,11 @@ enum VerifierKind { /// inclusion of the new pass manager headers and the old headers into the same /// file. It's interface is consequentially somewhat ad-hoc, but will go away /// when the transition finishes. -bool runPassPipeline(StringRef Arg0, Module &M, - TargetMachine *TM, tool_output_file *Out, +/// +/// ThinLTOLinkOut is only used when OK is OK_OutputThinLTOBitcode, and can be +/// nullptr. +bool runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM, + tool_output_file *Out, tool_output_file *ThinLinkOut, StringRef PassPipeline, opt_tool::OutputKind OK, opt_tool::VerifierKind VK, bool ShouldPreserveAssemblyUseListOrder, diff --git a/llvm/tools/opt/opt.cpp b/llvm/tools/opt/opt.cpp index bef197d603c..9d489ab5a2d 100644 --- a/llvm/tools/opt/opt.cpp +++ b/llvm/tools/opt/opt.cpp @@ -518,7 +518,9 @@ int main(int argc, char **argv) { if (PassPipeline.getNumOccurrences() > 0) { OutputKind OK = OK_NoOutput; if (!NoOutput) - OK = OutputAssembly ? OK_OutputAssembly : OK_OutputBitcode; + OK = OutputAssembly + ? OK_OutputAssembly + : (OutputThinLTOBC ? OK_OutputThinLTOBitcode : OK_OutputBitcode); VerifierKind VK = VK_VerifyInAndOut; if (NoVerify) @@ -529,7 +531,7 @@ int main(int argc, char **argv) { // The user has asked to use the new pass manager and provided a pipeline // string. Hand off the rest of the functionality to the new code for that // layer. - return runPassPipeline(argv[0], *M, TM.get(), Out.get(), + return runPassPipeline(argv[0], *M, TM.get(), Out.get(), ThinLinkOut.get(), PassPipeline, OK, VK, PreserveAssemblyUseListOrder, PreserveBitcodeUseListOrder, EmitSummaryIndex, EmitModuleHash) |