[PATCH] D43000: Do not move stores for coroutine allocator args
Brian Gesiak via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 6 18:26:53 PST 2018
modocache created this revision.
modocache added reviewers: rsmith, GorNishanov, eric_niebler.
The behavior described in Coroutines TS `[dcl.fct.def.coroutine]/7`
allows coroutine parameters to be passed into allocator functions.
The instructions to store values into the alloca'd parameters must not
be moved past the frame allocation, otherwise uninitialized values are
passed to the allocator.
Test Plan: `check-llvm`
Repository:
rL LLVM
https://reviews.llvm.org/D43000
Files:
lib/Transforms/Coroutines/CoroSplit.cpp
Index: lib/Transforms/Coroutines/CoroSplit.cpp
===================================================================
--- lib/Transforms/Coroutines/CoroSplit.cpp
+++ lib/Transforms/Coroutines/CoroSplit.cpp
@@ -654,13 +654,28 @@
// set.
do {
Instruction *Current = Work.pop_back_val();
+ DEBUG(dbgs() << "CoroSplit: Will not relocate:\t" << *Current << "\n");
DoNotRelocate.insert(Current);
for (Value *U : Current->operands()) {
auto *I = dyn_cast<Instruction>(U);
if (!I)
continue;
- if (isa<AllocaInst>(U))
+
+ if (auto *Alloca = dyn_cast<AllocaInst>(I)) {
+ // Stores to alloca instructions that occur before coroutine frame
+ // is allocated should not be moved; the stored values may be used
+ // by the coroutine frame allocator.
+ if (RelocBlocks.count(Alloca->getParent()) != 0) {
+ for (auto AI = Alloca->user_begin(), AE = Alloca->user_end(); AI != AE;
+ ++AI) {
+ if (auto *Store = dyn_cast<llvm::StoreInst>(*AI)) {
+ DoNotRelocate.insert(Store);
+ }
+ }
+ }
continue;
+ }
+
if (DoNotRelocate.count(I) == 0) {
Work.push_back(I);
DoNotRelocate.insert(I);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43000.133128.patch
Type: text/x-patch
Size: 1260 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180207/9f46784a/attachment.bin>
More information about the llvm-commits
mailing list