diff options
| author | 2018-04-06 14:26:03 +0000 | |
|---|---|---|
| committer | 2018-04-06 14:26:03 +0000 | |
| commit | bdabc2f19ffb9e20600dad6e8a300842a7bda50e (patch) | |
| tree | c50e7b2e5449b074651bb82a58517a8ebc4a8cf7 /gnu/llvm/lib/LTO/LTOCodeGenerator.cpp | |
| parent | Print a 'p' flag for file descriptors that were opened after pledge(2). (diff) | |
| download | wireguard-openbsd-bdabc2f19ffb9e20600dad6e8a300842a7bda50e.tar.xz wireguard-openbsd-bdabc2f19ffb9e20600dad6e8a300842a7bda50e.zip | |
Import LLVM 6.0.1 release including clang, lld and lldb.
"where is the kaboom?" deraadt@
Diffstat (limited to 'gnu/llvm/lib/LTO/LTOCodeGenerator.cpp')
| -rw-r--r-- | gnu/llvm/lib/LTO/LTOCodeGenerator.cpp | 68 |
1 files changed, 30 insertions, 38 deletions
diff --git a/gnu/llvm/lib/LTO/LTOCodeGenerator.cpp b/gnu/llvm/lib/LTO/LTOCodeGenerator.cpp index 6a275560dc9..c7306df95d3 100644 --- a/gnu/llvm/lib/LTO/LTOCodeGenerator.cpp +++ b/gnu/llvm/lib/LTO/LTOCodeGenerator.cpp @@ -21,7 +21,7 @@ #include "llvm/Analysis/TargetTransformInfo.h" #include "llvm/Bitcode/BitcodeWriter.h" #include "llvm/CodeGen/ParallelCG.h" -#include "llvm/CodeGen/RuntimeLibcalls.h" +#include "llvm/CodeGen/TargetSubtargetInfo.h" #include "llvm/Config/config.h" #include "llvm/IR/Constants.h" #include "llvm/IR/DataLayout.h" @@ -52,10 +52,7 @@ #include "llvm/Support/ToolOutputFile.h" #include "llvm/Support/YAMLTraits.h" #include "llvm/Support/raw_ostream.h" -#include "llvm/Target/TargetLowering.h" #include "llvm/Target/TargetOptions.h" -#include "llvm/Target/TargetRegisterInfo.h" -#include "llvm/Target/TargetSubtargetInfo.h" #include "llvm/Transforms/IPO.h" #include "llvm/Transforms/IPO/Internalize.h" #include "llvm/Transforms/IPO/PassManagerBuilder.h" @@ -83,16 +80,6 @@ cl::opt<bool> LTODiscardValueNames( #endif cl::Hidden); -cl::opt<bool> LTOStripInvalidDebugInfo( - "lto-strip-invalid-debug-info", - cl::desc("Strip invalid debug info metadata during LTO instead of aborting."), -#ifdef NDEBUG - cl::init(true), -#else - cl::init(false), -#endif - cl::Hidden); - cl::opt<std::string> LTORemarksFilename("lto-pass-remarks-output", cl::desc("Output filename for pass remarks"), @@ -141,7 +128,6 @@ void LTOCodeGenerator::initializeLTOPasses() { initializeMemCpyOptLegacyPassPass(R); initializeDCELegacyPassPass(R); initializeCFGSimplifyPassPass(R); - initializeLateCFGSimplifyPassPass(R); } void LTOCodeGenerator::setAsmUndefinedRefs(LTOModule *Mod) { @@ -225,10 +211,10 @@ bool LTOCodeGenerator::writeMergedModules(StringRef Path) { // create output file std::error_code EC; - tool_output_file Out(Path, EC, sys::fs::F_None); + ToolOutputFile Out(Path, EC, sys::fs::F_None); if (EC) { std::string ErrMsg = "could not open bitcode file for writing: "; - ErrMsg += Path; + ErrMsg += Path.str() + ": " + EC.message(); emitError(ErrMsg); return false; } @@ -239,7 +225,7 @@ bool LTOCodeGenerator::writeMergedModules(StringRef Path) { if (Out.os().has_error()) { std::string ErrMsg = "could not write bitcode file: "; - ErrMsg += Path; + ErrMsg += Path.str() + ": " + Out.os().error().message(); emitError(ErrMsg); Out.os().clear_error(); return false; @@ -265,12 +251,14 @@ bool LTOCodeGenerator::compileOptimizedToFile(const char **Name) { } // generate object file - tool_output_file objFile(Filename, FD); + ToolOutputFile objFile(Filename, FD); bool genResult = compileOptimized(&objFile.os()); objFile.os().close(); if (objFile.os().has_error()) { - emitError((Twine("could not write object file: ") + Filename).str()); + emitError((Twine("could not write object file: ") + Filename + ": " + + objFile.os().error().message()) + .str()); objFile.os().clear_error(); sys::fs::remove(Twine(Filename)); return false; @@ -368,9 +356,8 @@ bool LTOCodeGenerator::determineTarget() { } std::unique_ptr<TargetMachine> LTOCodeGenerator::createTargetMachine() { - return std::unique_ptr<TargetMachine>( - MArch->createTargetMachine(TripleStr, MCpu, FeatureStr, Options, - RelocModel, CodeModel::Default, CGOptLevel)); + return std::unique_ptr<TargetMachine>(MArch->createTargetMachine( + TripleStr, MCpu, FeatureStr, Options, RelocModel, None, CGOptLevel)); } // If a linkonce global is present in the MustPreserveSymbols, we need to make @@ -482,11 +469,9 @@ void LTOCodeGenerator::restoreLinkageForExternals() { GV.setLinkage(I->second); }; - std::for_each(MergedModule->begin(), MergedModule->end(), externalize); - std::for_each(MergedModule->global_begin(), MergedModule->global_end(), - externalize); - std::for_each(MergedModule->alias_begin(), MergedModule->alias_end(), - externalize); + llvm::for_each(MergedModule->functions(), externalize); + llvm::for_each(MergedModule->globals(), externalize); + llvm::for_each(MergedModule->aliases(), externalize); } void LTOCodeGenerator::verifyMergedModuleOnce() { @@ -496,8 +481,7 @@ void LTOCodeGenerator::verifyMergedModuleOnce() { HasVerifiedInput = true; bool BrokenDebugInfo = false; - if (verifyModule(*MergedModule, &dbgs(), - LTOStripInvalidDebugInfo ? &BrokenDebugInfo : nullptr)) + if (verifyModule(*MergedModule, &dbgs(), &BrokenDebugInfo)) report_fatal_error("Broken module found, compilation aborted!"); if (BrokenDebugInfo) { emitWarning("Invalid debug info found, debug info will be stripped"); @@ -623,12 +607,8 @@ void LTOCodeGenerator::parseCodeGenDebugOptions() { } } -void LTOCodeGenerator::DiagnosticHandler(const DiagnosticInfo &DI, - void *Context) { - ((LTOCodeGenerator *)Context)->DiagnosticHandler2(DI); -} -void LTOCodeGenerator::DiagnosticHandler2(const DiagnosticInfo &DI) { +void LTOCodeGenerator::DiagnosticHandler(const DiagnosticInfo &DI) { // Map the LLVM internal diagnostic severity to the LTO diagnostic severity. lto_codegen_diagnostic_severity_t Severity; switch (DI.getSeverity()) { @@ -658,17 +638,29 @@ void LTOCodeGenerator::DiagnosticHandler2(const DiagnosticInfo &DI) { (*DiagHandler)(Severity, MsgStorage.c_str(), DiagContext); } +namespace { +struct LTODiagnosticHandler : public DiagnosticHandler { + LTOCodeGenerator *CodeGenerator; + LTODiagnosticHandler(LTOCodeGenerator *CodeGenPtr) + : CodeGenerator(CodeGenPtr) {} + bool handleDiagnostics(const DiagnosticInfo &DI) override { + CodeGenerator->DiagnosticHandler(DI); + return true; + } +}; +} + void LTOCodeGenerator::setDiagnosticHandler(lto_diagnostic_handler_t DiagHandler, void *Ctxt) { this->DiagHandler = DiagHandler; this->DiagContext = Ctxt; if (!DiagHandler) - return Context.setDiagnosticHandler(nullptr, nullptr); + return Context.setDiagnosticHandler(nullptr); // Register the LTOCodeGenerator stub in the LLVMContext to forward the // diagnostic to the external DiagHandler. - Context.setDiagnosticHandler(LTOCodeGenerator::DiagnosticHandler, this, - /* RespectFilters */ true); + Context.setDiagnosticHandler(llvm::make_unique<LTODiagnosticHandler>(this), + true); } namespace { |
