提交 5b44e10f 编写于 作者: J Jan-Erik Rediger

[LLVM-3.9] Preserve certain functions when internalizing

This makes sure to still use the old way for older LLVM versions.
上级 6ed5db8d
......@@ -358,9 +358,24 @@ LLVMRustAddAlwaysInlinePass(LLVMPassManagerBuilderRef PMB, bool AddLifetimes) {
extern "C" void
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);
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));
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册