Commit ec526abc by Antonio Maiorano

Fix when built against latest LLVM (11)

LLVM changes certain function return types to Expected<T> instead of T. This change adds an Unwrap that supports both cases, allowing the code to build in both contexts. Bug: b/171236524 Change-Id: I461ab440797695ca1e92d4827d6e6d8965dcf6b2 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/49468Tested-by: 's avatarAntonio Maiorano <amaiorano@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 84f5eeb6
......@@ -466,6 +466,19 @@ class ExternalSymbolGenerator : public llvm::orc::JITDylib::DefinitionGenerator
}
};
// As we must support different LLVM versions, add a generic Unwrap for functions that return Expected<T> or the actual T.
// TODO(b/165000222): Remove after LLVM 11 upgrade
template<typename T>
auto &Unwrap(llvm::Expected<T> &&v)
{
return v.get();
}
template<typename T>
auto &Unwrap(T &&v)
{
return v;
}
// JITRoutine is a rr::Routine that holds a LLVM JIT session, compiler and
// object layer as each routine may require different target machine
// settings and no Reactor routine directly links against another.
......@@ -492,7 +505,7 @@ public:
, compileLayer(session, objectLayer, std::make_unique<llvm::orc::ConcurrentIRCompiler>(JITGlobals::get()->getTargetMachineBuilder(config.getOptimization().getLevel())))
, mangle(session, JITGlobals::get()->getDataLayout())
, ctx(std::make_unique<llvm::LLVMContext>())
, dylib(session.createJITDylib("<routine>"))
, dylib(Unwrap(session.createJITDylib("<routine>")))
, addresses(count)
{
......
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