[LLVM-3.9] Preserve certain functions when internalizing
This makes sure to still use the old way for older LLVM versions.
This commit is contained in:
parent
6ed5db8d35
commit
5b44e10fb7
1 changed files with 16 additions and 1 deletions
|
@ -358,9 +358,24 @@ LLVMRustAddAlwaysInlinePass(LLVMPassManagerBuilderRef PMB, bool AddLifetimes) {
|
||||||
|
|
||||||
extern "C" void
|
extern "C" void
|
||||||
LLVMRustRunRestrictionPass(LLVMModuleRef M, char **symbols, size_t len) {
|
LLVMRustRunRestrictionPass(LLVMModuleRef M, char **symbols, size_t len) {
|
||||||
PassManager passes;
|
llvm::legacy::PassManager passes;
|
||||||
|
|
||||||
|
#if LLVM_VERSION_MINOR <= 8
|
||||||
ArrayRef<const char*> ref(symbols, len);
|
ArrayRef<const char*> ref(symbols, len);
|
||||||
passes.add(llvm::createInternalizePass(ref));
|
passes.add(llvm::createInternalizePass(ref));
|
||||||
|
#else
|
||||||
|
auto PreserveFunctions = [=](const GlobalValue &GV) {
|
||||||
|
for (size_t i=0; i<len; i++) {
|
||||||
|
if (GV.getName() == symbols[i]) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
passes.add(llvm::createInternalizePass(PreserveFunctions));
|
||||||
|
#endif
|
||||||
|
|
||||||
passes.run(*unwrap(M));
|
passes.run(*unwrap(M));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue