[PATCH] D74651: Add IR constructs for inalloca replacement preallocated call setup

Reid Kleckner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 23 15:15:18 PDT 2020


rnk added a comment.

In D74651#1999995 <https://reviews.llvm.org/D74651#1999995>, @efriedma wrote:

> I'm not sure it's safe to rewrite an call_preallocated_setup to an alloca in the entry block, in general.  There is no rule which prevents multiple calls to the same call_preallocated_setup in a loop, without deallocating the memory in between.  Because of that, reusing the memory could lead to a miscompile.  There wouldn't be any way to deallocate the result, but that isn't necessarily a problem. You could prove this doesn't happen in common cases, and clang wouldn't generate code like that.  But LLVM optimizations could introduce it, I think, if there isn't a rule specifically preventing it.


I think if we model calls with preallocated bundles as modifying inaccessible state (i.e. the stack pointer), LLVM transforms won't do this.

I'm imagining some kind of loop result code sinking transform that wants to sink a readonly function call out of a loop, because the result is only used after the last iteration.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74651/new/

https://reviews.llvm.org/D74651





More information about the llvm-commits mailing list