full changelog at https://blog.rust-lang.org/2017/11/22/Rust-1.22.html port changes: - switch to clang and libc++ (instead of egcc and estdc++) - use devel/llvm instead of the embedded llvm version - make i386 produce code for 'pentiumpro' instead of 'pentium4' so that ppl can use ripgrep on pentium II's (yay!) - use a hack (codegen-units=16) to fix memory pressure issues on i386. Might not work forever..... tested on i386 & amd64, went into an i386 bulk. all the hard work from semarie@
94 lines
3.2 KiB
Plaintext
94 lines
3.2 KiB
Plaintext
$OpenBSD: patch-src_rustllvm_PassWrapper_cpp,v 1.1 2017/12/04 17:31:49 landry Exp $
|
|
Backport of https://github.com/rust-lang/rust/commit/56f5a19e456 for using LLVM 5.0
|
|
Index: src/rustllvm/PassWrapper.cpp
|
|
--- src/rustllvm/PassWrapper.cpp.orig
|
|
+++ src/rustllvm/PassWrapper.cpp
|
|
@@ -26,12 +26,14 @@
|
|
#include "llvm/Transforms/IPO/PassManagerBuilder.h"
|
|
|
|
#if LLVM_VERSION_GE(4, 0)
|
|
-#include "llvm/Object/ModuleSummaryIndexObjectFile.h"
|
|
#include "llvm/Transforms/IPO/AlwaysInliner.h"
|
|
#include "llvm/Transforms/IPO/FunctionImport.h"
|
|
#include "llvm/Transforms/Utils/FunctionImportUtils.h"
|
|
#include "llvm/LTO/LTO.h"
|
|
+#if LLVM_VERSION_LE(4, 0)
|
|
+#include "llvm/Object/ModuleSummaryIndexObjectFile.h"
|
|
#endif
|
|
+#endif
|
|
|
|
#include "llvm-c/Transforms/PassManagerBuilder.h"
|
|
|
|
@@ -888,6 +890,28 @@ addPreservedGUID(const ModuleSummaryIndex &Index,
|
|
return;
|
|
Preserved.insert(GUID);
|
|
|
|
+#if LLVM_VERSION_GE(5, 0)
|
|
+ auto Info = Index.getValueInfo(GUID);
|
|
+ if (!Info) {
|
|
+ return;
|
|
+ }
|
|
+ for (auto &Summary : Info.getSummaryList()) {
|
|
+ for (auto &Ref : Summary->refs()) {
|
|
+ addPreservedGUID(Index, Preserved, Ref.getGUID());
|
|
+ }
|
|
+
|
|
+ GlobalValueSummary *GVSummary = Summary.get();
|
|
+ if (isa<FunctionSummary>(GVSummary)) {
|
|
+ FunctionSummary *FS = cast<FunctionSummary>(GVSummary);
|
|
+ for (auto &Call: FS->calls()) {
|
|
+ addPreservedGUID(Index, Preserved, Call.first.getGUID());
|
|
+ }
|
|
+ for (auto &GUID: FS->type_tests()) {
|
|
+ addPreservedGUID(Index, Preserved, GUID);
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+#else
|
|
auto SummaryList = Index.findGlobalValueSummaryList(GUID);
|
|
if (SummaryList == Index.end())
|
|
return;
|
|
@@ -917,6 +941,7 @@ addPreservedGUID(const ModuleSummaryIndex &Index,
|
|
}
|
|
}
|
|
}
|
|
+#endif
|
|
}
|
|
|
|
// The main entry point for creating the global ThinLTO analysis. The structure
|
|
@@ -937,6 +962,12 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modul
|
|
|
|
Ret->ModuleMap[module->identifier] = mem_buffer;
|
|
|
|
+#if LLVM_VERSION_GE(5, 0)
|
|
+ if (Error Err = readModuleSummaryIndex(mem_buffer, Ret->Index, i)) {
|
|
+ LLVMRustSetLastError(toString(std::move(Err)).c_str());
|
|
+ return nullptr;
|
|
+ }
|
|
+#else
|
|
Expected<std::unique_ptr<object::ModuleSummaryIndexObjectFile>> ObjOrErr =
|
|
object::ModuleSummaryIndexObjectFile::create(mem_buffer);
|
|
if (!ObjOrErr) {
|
|
@@ -945,6 +976,7 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modul
|
|
}
|
|
auto Index = (*ObjOrErr)->takeIndex();
|
|
Ret->Index.mergeFrom(std::move(Index), i);
|
|
+#endif
|
|
}
|
|
|
|
// Collect for each module the list of function it defines (GUID -> Summary)
|
|
@@ -978,8 +1010,13 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modul
|
|
StringMap<std::map<GlobalValue::GUID, GlobalValue::LinkageTypes>> ResolvedODR;
|
|
DenseMap<GlobalValue::GUID, const GlobalValueSummary *> PrevailingCopy;
|
|
for (auto &I : Ret->Index) {
|
|
+#if LLVM_VERSION_GE(5, 0)
|
|
+ if (I.second.SummaryList.size() > 1)
|
|
+ PrevailingCopy[I.first] = getFirstDefinitionForLinker(I.second.SummaryList);
|
|
+#else
|
|
if (I.second.size() > 1)
|
|
PrevailingCopy[I.first] = getFirstDefinitionForLinker(I.second);
|
|
+#endif
|
|
}
|
|
auto isPrevailing = [&](GlobalValue::GUID GUID, const GlobalValueSummary *S) {
|
|
const auto &Prevailing = PrevailingCopy.find(GUID);
|