[PATCH] D31670: [coroutines] Implement correct GRO lifetime

Richard Smith via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 22 11:45:39 PDT 2017


rsmith added inline comments.


================
Comment at: lib/CodeGen/CGCoroutine.cpp:273
+
+    // FIXME: There must be a cleaner way to do this!
+    if (auto *Cleanup = dyn_cast_or_null<EHCleanupScope>(&*CGF.EHStack.begin())) {
----------------
It doesn't seem safe to assume that a prior `EHCleanupScope` would be for the GRO variable, nor that it can only have one such cleanup. How about this: grab a stable EHStack iterator before you emit cleanups, grab another afterwards, and iterate over the cleanups in that range modifying them as appropriate.

Even that seems a bit fragile, though. Would it be feasible to thread the 'active' flag through `EmitAutoVarCleanups` (perhaps add it to `AutoVarEmission`)?


https://reviews.llvm.org/D31670





More information about the cfe-commits mailing list