diff options
author | Ruiling, Song <ruiling.song@amd.com> | 2023-10-25 09:24:36 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-25 09:24:36 +0800 |
commit | ac24238002076e36b2d33d18d1bf47a9de59fab4 (patch) | |
tree | ede47d0bd6fedca46d1c6bd60c99d14755b7c1a2 /llvm/lib/Transforms/Utils/BasicBlockUtils.cpp | |
parent | b745ce952560716545e82770bf835e48a567eaf1 (diff) | |
download | llvm-ac24238002076e36b2d33d18d1bf47a9de59fab4.zip llvm-ac24238002076e36b2d33d18d1bf47a9de59fab4.tar.gz llvm-ac24238002076e36b2d33d18d1bf47a9de59fab4.tar.bz2 |
[LowerSwitch] Don't let pass manager handle the dependency (#68662)
Some passes has limitation that only support simple terminators:
branch/unreachable/return. Right now, they ask the pass manager to add
LowerSwitch pass to eliminate `switch`. Let's manage such kind of pass
dependency by ourselves. Also add the assertion in the related passes.
Diffstat (limited to 'llvm/lib/Transforms/Utils/BasicBlockUtils.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/BasicBlockUtils.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp index 389aab3..05ff4ef 100644 --- a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp +++ b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp @@ -2076,3 +2076,13 @@ void llvm::InvertBranch(BranchInst *PBI, IRBuilderBase &Builder) { PBI->setCondition(NewCond); PBI->swapSuccessors(); } + +bool llvm::hasOnlySimpleTerminator(const Function &F) { + for (auto &BB : F) { + auto *Term = BB.getTerminator(); + if (!(isa<ReturnInst>(Term) || isa<UnreachableInst>(Term) || + isa<BranchInst>(Term))) + return false; + } + return true; +} |