diff options
| author | bors <bors@rust-lang.org> | 2020-01-13 04:01:00 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-01-13 04:01:00 +0000 |
| commit | e82febc78e5a14356de5f713b904eebef1e86956 (patch) | |
| tree | e1c8bffd16e5b0f003d8d9d61415cfb72a2549c7 /src/rustllvm/PassWrapper.cpp | |
| parent | 3ebcfa1451cfedc13a07e6353d8ade9742dfdc2a (diff) | |
| parent | c9e996f05cff70e69240b9a9d2d56e57af21eb3a (diff) | |
| download | rust-e82febc78e5a14356de5f713b904eebef1e86956.tar.gz rust-e82febc78e5a14356de5f713b904eebef1e86956.zip | |
Auto merge of #67900 - nikic:prepare-llvm-10, r=nagisa
Prepare for LLVM 10 upgrade Split off from #67759, this just adds the necessary compatibility bits and updates codegen tests, without performing the actual LLVM upgrade. r? @alexcrichton
Diffstat (limited to 'src/rustllvm/PassWrapper.cpp')
| -rw-r--r-- | src/rustllvm/PassWrapper.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/rustllvm/PassWrapper.cpp b/src/rustllvm/PassWrapper.cpp index 6698e5d58be..eaa845a279f 100644 --- a/src/rustllvm/PassWrapper.cpp +++ b/src/rustllvm/PassWrapper.cpp @@ -8,6 +8,7 @@ #include "llvm/Analysis/TargetLibraryInfo.h" #include "llvm/Analysis/TargetTransformInfo.h" #include "llvm/CodeGen/TargetSubtargetInfo.h" +#include "llvm/InitializePasses.h" #include "llvm/IR/AutoUpgrade.h" #include "llvm/IR/AssemblyAnnotationWriter.h" #include "llvm/IR/IntrinsicInst.h" @@ -532,6 +533,18 @@ enum class LLVMRustFileType { ObjectFile, }; +#if LLVM_VERSION_GE(10, 0) +static CodeGenFileType fromRust(LLVMRustFileType Type) { + switch (Type) { + case LLVMRustFileType::AssemblyFile: + return CGFT_AssemblyFile; + case LLVMRustFileType::ObjectFile: + return CGFT_ObjectFile; + default: + report_fatal_error("Bad FileType."); + } +} +#else static TargetMachine::CodeGenFileType fromRust(LLVMRustFileType Type) { switch (Type) { case LLVMRustFileType::AssemblyFile: @@ -542,6 +555,7 @@ static TargetMachine::CodeGenFileType fromRust(LLVMRustFileType Type) { report_fatal_error("Bad FileType."); } } +#endif extern "C" LLVMRustResult LLVMRustWriteOutputFile(LLVMTargetMachineRef Target, LLVMPassManagerRef PMR, @@ -849,7 +863,11 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules, int num_modules, const char **preserved_symbols, int num_symbols) { +#if LLVM_VERSION_GE(10, 0) + auto Ret = std::make_unique<LLVMRustThinLTOData>(); +#else auto Ret = llvm::make_unique<LLVMRustThinLTOData>(); +#endif // Load each module's summary and merge it into one combined index for (int i = 0; i < num_modules; i++) { @@ -944,6 +962,15 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules, ExportedGUIDs.insert(GUID); } } +#if LLVM_VERSION_GE(10, 0) + auto isExported = [&](StringRef ModuleIdentifier, ValueInfo VI) { + const auto &ExportList = Ret->ExportLists.find(ModuleIdentifier); + return (ExportList != Ret->ExportLists.end() && + ExportList->second.count(VI)) || + ExportedGUIDs.count(VI.getGUID()); + }; + thinLTOInternalizeAndPromoteInIndex(Ret->Index, isExported, isPrevailing); +#else auto isExported = [&](StringRef ModuleIdentifier, GlobalValue::GUID GUID) { const auto &ExportList = Ret->ExportLists.find(ModuleIdentifier); return (ExportList != Ret->ExportLists.end() && @@ -951,6 +978,7 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules, ExportedGUIDs.count(GUID); }; thinLTOInternalizeAndPromoteInIndex(Ret->Index, isExported); +#endif return Ret.release(); } @@ -1081,7 +1109,11 @@ struct LLVMRustThinLTOBuffer { extern "C" LLVMRustThinLTOBuffer* LLVMRustThinLTOBufferCreate(LLVMModuleRef M) { +#if LLVM_VERSION_GE(10, 0) + auto Ret = std::make_unique<LLVMRustThinLTOBuffer>(); +#else auto Ret = llvm::make_unique<LLVMRustThinLTOBuffer>(); +#endif { raw_string_ostream OS(Ret->data); { |
