Commit 52551d1c by Nicolas Capens Committed by Nicolas Capens

Work around stack probe issue.

LLVM fails to resolve the __chkstck function for probing the stack when it's larger than 4 kB. We don't need it for SwiftShader because newly created threads have 1 MB of committed stack memory. Bug b/115344057 Bug swiftshader:25 Change-Id: Ic6097376052b07ed6af950dfdac8499b5fc83053 Reviewed-on: https://swiftshader-review.googlesource.com/20688Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Tested-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent fcedef47
......@@ -919,6 +919,17 @@ namespace sw
::function = llvm::Function::Create(functionType, llvm::GlobalValue::InternalLinkage, "", ::module);
::function->setCallingConv(llvm::CallingConv::C);
#if defined(_WIN32) && SWIFTSHADER_LLVM_VERSION >= 7
// 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
::builder->SetInsertPoint(llvm::BasicBlock::Create(*::context, "", ::function));
}
......
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