diff options
| author | John McCall <rjmccall@apple.com> | 2019-08-14 03:54:13 +0000 |
|---|---|---|
| committer | John McCall <rjmccall@apple.com> | 2019-08-14 03:54:13 +0000 |
| commit | 5f60b68c68c00137304be0e0016e43d02066b2fd (patch) | |
| tree | 5cfe77c1c5753aecbb8884e01260c0cb9ec808e4 /llvm/lib | |
| parent | 2133feec933ea7311ee74ee39a5e6a0bcfaef822 (diff) | |
| download | bcm5719-llvm-5f60b68c68c00137304be0e0016e43d02066b2fd.tar.gz bcm5719-llvm-5f60b68c68c00137304be0e0016e43d02066b2fd.zip | |
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.
llvm-svn: 368796
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Transforms/Coroutines/CoroSplit.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Coroutines/CoroSplit.cpp b/llvm/lib/Transforms/Coroutines/CoroSplit.cpp index db318d858da..01357f0c8bd 100644 --- a/llvm/lib/Transforms/Coroutines/CoroSplit.cpp +++ b/llvm/lib/Transforms/Coroutines/CoroSplit.cpp @@ -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(Function &F, coro::Shape &Shape, } } +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, coro::Shape &Shape, } 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) |

