Commit adfbbcbe by Nicolas Capens Committed by Nicolas Capens

Fix symbol name mangling for LLVM 7.0.

The Mach-O executable format, used on macOS/Darwin, stores function names in mangled form, so we need to mangle it ourselves during function pointer lookup. Bug b/115344057 Change-Id: I8de5756c52b5af666826134fca8274b4467fa85a Reviewed-on: https://swiftshader-review.googlesource.com/c/22188Tested-by: 's avatarNicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com>
parent 7d0b8a3e
...@@ -61,6 +61,7 @@ ...@@ -61,6 +61,7 @@
#include "llvm/IR/Intrinsics.h" #include "llvm/IR/Intrinsics.h"
#include "llvm/IR/LLVMContext.h" #include "llvm/IR/LLVMContext.h"
#include "llvm/IR/LegacyPassManager.h" #include "llvm/IR/LegacyPassManager.h"
#include "llvm/IR/Mangler.h"
#include "llvm/IR/Module.h" #include "llvm/IR/Module.h"
#include "llvm/Support/Error.h" #include "llvm/Support/Error.h"
#include "llvm/Support/TargetSelect.h" #include "llvm/Support/TargetSelect.h"
...@@ -635,10 +636,16 @@ namespace rr ...@@ -635,10 +636,16 @@ namespace rr
auto moduleKey = session.allocateVModule(); auto moduleKey = session.allocateVModule();
llvm::cantFail(compileLayer.addModule(moduleKey, std::move(mod))); llvm::cantFail(compileLayer.addModule(moduleKey, std::move(mod)));
llvm::JITSymbol symbol = compileLayer.findSymbolIn(moduleKey, name, false); std::string mangledName;
{
llvm::raw_string_ostream mangledNameStream(mangledName);
llvm::Mangler::getNameWithPrefix(mangledNameStream, name, dataLayout);
}
llvm::JITSymbol symbol = compileLayer.findSymbolIn(moduleKey, mangledName, false);
llvm::Expected<llvm::JITTargetAddress> expectAddr = symbol.getAddress(); llvm::Expected<llvm::JITTargetAddress> expectAddr = symbol.getAddress();
if (!expectAddr) if(!expectAddr)
{ {
return nullptr; return nullptr;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment