[PATCH] D37093: [coroutines] Promote cleanup.dest.slot-like allocas to registers to avoid storing them in the coroutine frame

Hal Finkel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 4 13:46:06 PDT 2017


hfinkel added a comment.

In https://reviews.llvm.org/D37093#860565, @eric_niebler wrote:

> >> I do not want to promote all promotable allocas, I only would like to target cleanup allocas (flags and dest.slot),
> > 
> > Why? It sounds like you're trying to optimize some aspect of the -O0 lowering.
>
> Because as Gor writes at the top:
>
> > We don't want them to be saved into the coroutine frame (as some of the cleanup code may
> >  access them after coroutine frame destroyed).
>
> This bug manifests as a codegen use-after-free in -O0.


That's fine, but does not in itself explain why the variable cannot be extracted from the frame, or otherwise made available to the cleanup code. I'm not worried about the size of the stack frame at -O0 being larger than necessary (it will, compared to optimized code, be larger regardless). Moreover, the lowering algorithm must be sound at the IR level (not just in a state where it happens to work for some patterns that Clang happens to create).


https://reviews.llvm.org/D37093





More information about the llvm-commits mailing list