Use malloc to allocate storage for task parameters on Windows.
Fixes bug #55. A number of tests were crashing on Windows due to the task launch code using alloca to allocate space for the tasks' parameters. On Windows, the stack isn't generally big enough for this to be a good idea. Also added an alignment parmaeter to ISPCMalloc() to pass the alignment requirement along.
This commit is contained in:
@@ -640,6 +640,14 @@ lEmitFunctionCode(FunctionEmitContext *ctx, llvm::Function *function,
|
||||
assert(threadCountSym);
|
||||
threadCountSym->storagePtr = ctx->AllocaInst(LLVMTypes::Int32Type, "threadCount");
|
||||
ctx->StoreInst(threadCount, threadCountSym->storagePtr);
|
||||
|
||||
#ifdef ISPC_IS_WINDOWS
|
||||
// On Windows, we dynamically-allocate space for the task arguments
|
||||
// (see FunctionEmitContext::LaunchInst().) Here is where we emit
|
||||
// the code to free that memory, now that we've copied the
|
||||
// parameter values out of the structure.
|
||||
ctx->EmitFree(structParamPtr);
|
||||
#endif // ISPC_IS_WINDOWS
|
||||
}
|
||||
else {
|
||||
// Regular, non-task function
|
||||
|
||||
Reference in New Issue
Block a user