[llvm] r368796 - Remove unreachable blocks before splitting a coroutine.
John McCall via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 13 20:54:13 PDT 2019
Author: rjmccall
Date: Tue Aug 13 20:54:13 2019
New Revision: 368796
URL: http://llvm.org/viewvc/llvm-project?rev=368796&view=rev
Log:
Remove unreachable blocks before splitting a coroutine.
The suspend-crossing algorithm is not correct in the presence of uses
that cannot be reached on some successor path from their defs.
Modified:
llvm/trunk/lib/Transforms/Coroutines/CoroSplit.cpp
Modified: llvm/trunk/lib/Transforms/Coroutines/CoroSplit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Coroutines/CoroSplit.cpp?rev=368796&r1=368795&r2=368796&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Coroutines/CoroSplit.cpp (original)
+++ llvm/trunk/lib/Transforms/Coroutines/CoroSplit.cpp Tue Aug 13 20:54:13 2019
@@ -55,6 +55,7 @@
#include "llvm/Pass.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/PrettyStackTrace.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
@@ -1397,6 +1398,19 @@ static void splitRetconCoroutine(Functio
}
}
+namespace {
+ class PrettyStackTraceFunction : public PrettyStackTraceEntry {
+ Function &F;
+ public:
+ PrettyStackTraceFunction(Function &F) : F(F) {}
+ void print(raw_ostream &OS) const override {
+ OS << "While splitting coroutine ";
+ F.printAsOperand(OS, /*print type*/ false, F.getParent());
+ OS << "\n";
+ }
+ };
+}
+
static void splitCoroutine(Function &F, coro::Shape &Shape,
SmallVectorImpl<Function *> &Clones) {
switch (Shape.ABI) {
@@ -1410,7 +1424,11 @@ static void splitCoroutine(Function &F,
}
static void splitCoroutine(Function &F, CallGraph &CG, CallGraphSCC &SCC) {
- EliminateUnreachableBlocks(F);
+ PrettyStackTraceFunction prettyStackTrace(F);
+
+ // The suspend-crossing algorithm in buildCoroutineFrame get tripped
+ // up by uses in unreachable blocks, so remove them as a first pass.
+ removeUnreachableBlocks(F);
coro::Shape Shape(F);
if (!Shape.CoroBegin)
More information about the llvm-commits
mailing list