Commit ea38f958 by Ben Clayton

LLVMReactor: Mark all functions as 'DoesNotThrow'

This should disable code generation of exception handling, which we do not require. Bug: b/135298866 Change-Id: I081d4317d7cdad6a9101db026bb72e4a09fb874c Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/32949 Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Tested-by: 's avatarBen Clayton <bclayton@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 9d96071c
...@@ -885,6 +885,27 @@ namespace rr ...@@ -885,6 +885,27 @@ namespace rr
} }
} }
static ::llvm::Function* createFunction(const char *name, ::llvm::Type *retTy, const std::vector<::llvm::Type*> &params)
{
llvm::FunctionType *functionType = llvm::FunctionType::get(retTy, params, false);
auto func = llvm::Function::Create(functionType, llvm::GlobalValue::InternalLinkage, name, ::module);
func->setDoesNotThrow();
func->setCallingConv(llvm::CallingConv::C);
#if defined(_WIN32)
// FIXME(capn):
// On Windows, stack memory is committed in increments of 4 kB pages, with the last page
// having a trap which allows the OS to grow the stack. For functions with a stack frame
// larger than 4 kB this can cause an issue when a variable is accessed beyond the guard
// page. Therefore the compiler emits a call to __chkstk in the function prolog to probe
// the stack and ensure all pages have been committed. This is currently broken in LLVM
// JIT, but we can prevent emitting the stack probe call:
func->addFnAttr("stack-probe-size", "1048576");
#endif
return func;
}
Nucleus::Nucleus() Nucleus::Nucleus()
{ {
::codegenMutex.lock(); // Reactor and LLVM are currently not thread safe ::codegenMutex.lock(); // Reactor and LLVM are currently not thread safe
...@@ -1087,20 +1108,7 @@ namespace rr ...@@ -1087,20 +1108,7 @@ namespace rr
void Nucleus::createFunction(Type *ReturnType, std::vector<Type*> &Params) void Nucleus::createFunction(Type *ReturnType, std::vector<Type*> &Params)
{ {
llvm::FunctionType *functionType = llvm::FunctionType::get(T(ReturnType), T(Params), false); ::function = rr::createFunction("", T(ReturnType), T(Params));
::function = llvm::Function::Create(functionType, llvm::GlobalValue::InternalLinkage, "", ::module);
::function->setCallingConv(llvm::CallingConv::C);
#if defined(_WIN32)
// FIXME(capn):
// On Windows, stack memory is committed in increments of 4 kB pages, with the last page
// having a trap which allows the OS to grow the stack. For functions with a stack frame
// larger than 4 kB this can cause an issue when a variable is accessed beyond the guard
// page. Therefore the compiler emits a call to __chkstk in the function prolog to probe
// the stack and ensure all pages have been committed. This is currently broken in LLVM
// JIT, but we can prevent emitting the stack probe call:
::function->addFnAttr("stack-probe-size", "1048576");
#endif
#ifdef ENABLE_RR_DEBUG_INFO #ifdef ENABLE_RR_DEBUG_INFO
::debugInfo = std::unique_ptr<DebugInfo>(new DebugInfo(::builder, ::context, ::module, ::function)); ::debugInfo = std::unique_ptr<DebugInfo>(new DebugInfo(::builder, ::context, ::module, ::function));
...@@ -4338,9 +4346,7 @@ void Nucleus::createCoroutine(Type *YieldType, std::vector<Type*> &Params) ...@@ -4338,9 +4346,7 @@ void Nucleus::createCoroutine(Type *YieldType, std::vector<Type*> &Params)
// } // }
// } // }
// //
llvm::FunctionType *coroutineAwaitTy = llvm::FunctionType::get(boolTy, {handleTy, promisePtrTy}, false); ::coroutine.await = rr::createFunction("coroutine_await", boolTy, {handleTy, promisePtrTy});
::coroutine.await = llvm::Function::Create(coroutineAwaitTy, llvm::GlobalValue::InternalLinkage, "coroutine_await", ::module);
::coroutine.await->setCallingConv(llvm::CallingConv::C);
{ {
auto args = ::coroutine.await->arg_begin(); auto args = ::coroutine.await->arg_begin();
auto handle = args++; auto handle = args++;
...@@ -4371,9 +4377,7 @@ void Nucleus::createCoroutine(Type *YieldType, std::vector<Type*> &Params) ...@@ -4371,9 +4377,7 @@ void Nucleus::createCoroutine(Type *YieldType, std::vector<Type*> &Params)
// llvm.coro.destroy(handle); // llvm.coro.destroy(handle);
// } // }
// //
llvm::FunctionType *coroutineDestroyTy = llvm::FunctionType::get(voidTy, handleTy, false); ::coroutine.destroy = rr::createFunction("coroutine_destroy", voidTy, {handleTy});
::coroutine.destroy = llvm::Function::Create(coroutineDestroyTy, llvm::GlobalValue::InternalLinkage, "coroutine_destroy", ::module);
::coroutine.destroy->setCallingConv(llvm::CallingConv::C);
{ {
auto handle = ::coroutine.destroy->arg_begin(); auto handle = ::coroutine.destroy->arg_begin();
::builder->SetInsertPoint(llvm::BasicBlock::Create(*::context, "", ::coroutine.destroy)); ::builder->SetInsertPoint(llvm::BasicBlock::Create(*::context, "", ::coroutine.destroy));
...@@ -4413,9 +4417,7 @@ void Nucleus::createCoroutine(Type *YieldType, std::vector<Type*> &Params) ...@@ -4413,9 +4417,7 @@ void Nucleus::createCoroutine(Type *YieldType, std::vector<Type*> &Params)
// return handle; // return handle;
// } // }
// //
llvm::FunctionType *functionType = llvm::FunctionType::get(handleTy, T(Params), false); ::function = rr::createFunction("coroutine_begin", handleTy, T(Params));
::function = llvm::Function::Create(functionType, llvm::GlobalValue::InternalLinkage, "coroutine_begin", ::module);
::function->setCallingConv(llvm::CallingConv::C);
#ifdef ENABLE_RR_DEBUG_INFO #ifdef ENABLE_RR_DEBUG_INFO
::debugInfo = std::unique_ptr<DebugInfo>(new DebugInfo(::builder, ::context, ::module, ::function)); ::debugInfo = std::unique_ptr<DebugInfo>(new DebugInfo(::builder, ::context, ::module, ::function));
...@@ -4462,17 +4464,6 @@ void Nucleus::createCoroutine(Type *YieldType, std::vector<Type*> &Params) ...@@ -4462,17 +4464,6 @@ void Nucleus::createCoroutine(Type *YieldType, std::vector<Type*> &Params)
// Switch back to the entry block for reactor codegen. // Switch back to the entry block for reactor codegen.
::builder->SetInsertPoint(entryBlock); ::builder->SetInsertPoint(entryBlock);
#if defined(_WIN32)
// FIXME(capn):
// On Windows, stack memory is committed in increments of 4 kB pages, with the last page
// having a trap which allows the OS to grow the stack. For functions with a stack frame
// larger than 4 kB this can cause an issue when a variable is accessed beyond the guard
// page. Therefore the compiler emits a call to __chkstk in the function prolog to probe
// the stack and ensure all pages have been committed. This is currently broken in LLVM
// JIT, but we can prevent emitting the stack probe call:
::function->addFnAttr("stack-probe-size", "1048576");
#endif
} }
void Nucleus::yield(Value* val) void Nucleus::yield(Value* val)
......
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