[PATCH] D23245: [Coroutines] Part 6: Elide dynamic allocation of a coroutine frame when possible

David Majnemer via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 10 08:40:34 PDT 2016


majnemer accepted this revision.
majnemer added a comment.
This revision is now accepted and ready to land.

LGTM with nits addressed.


================
Comment at: lib/Transforms/Coroutines/CoroInstr.h:106-112
@@ -69,1 +105,9 @@
 public:
+  CoroAllocInst *getAlloc() const {
+    auto *V = getArgOperand(ElideArg);
+    if (isa<ConstantPointerNull>(V))
+      return nullptr;
+
+    return cast<CoroAllocInst>(V);
+  }
+  Value *getMem() const { return getArgOperand(MemArg); }
----------------
I'd phrase this another way to make it more conservative:
  CoroAllocInst *getAlloc() const {
    if (auto *CAI = dyn_cast<CoroAllocInst>getArgOperand(ElideArg->stripPointerCasts()))
      return CAI;

    return nullptr;
  }

This way, we won't crash if `undef` or a `bitcast` or `null` or some other weird operation is sitting in the elide arg.


https://reviews.llvm.org/D23245





More information about the llvm-commits mailing list