Andrew Kelley via llvm-dev
2018-Mar-29 05:19 UTC
[llvm-dev] workaround for CoroSplit not spilling alloca?
My frontend is emitting an array (here called %error_return_trace_addresses). You can see we take the address of the first element and store it ; Function Attrs: nobuiltin noinline nounwind optnone define internal fastcc i8* @failing(%StackTrace* nonnull, %Allocator*, i16*) unnamed_addr #3 !dbg !273 { Entry: %error_return_trace_addresses = alloca [1 x i64], align 8 %error_return_trace = alloca %StackTrace, align 8 %3 = alloca i8*, align 8 %4 = alloca %"[]u8", align 8 %5 = getelementptr inbounds %StackTrace, %StackTrace* %error_return_trace, i32 0, i32 0 store i64 0, i64* %5, align 8 %6 = getelementptr inbounds %StackTrace, %StackTrace* %error_return_trace, i32 0, i32 1 %7 = getelementptr inbounds %"[]usize", %"[]usize"* %6, i32 0, i32 0 %8 = getelementptr inbounds [1 x i64], [1 x i64]* %error_return_trace_addresses, i64 0, i64 0 store i64* %8, i64** %7, align 8 however CoroSplit does not spill it. we write through the pointer, which writes to the fn stack data. then there is a suspend point, and the data becomes corrupt. then we read through the pointer and get corrupt data. this is because %error_return_trace_addresses should be spilled. is there a way for a frontend to explicitly require an alloca to be spilled? perhaps putting it as a field in the promise alloca? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180329/06cd28be/attachment.html>