diff options
author | Nikita Popov <npopov@redhat.com> | 2023-08-23 15:04:45 +0200 |
---|---|---|
committer | Nikita Popov <npopov@redhat.com> | 2023-08-25 09:20:18 +0200 |
commit | 4eafc9b6ff4ae2bce82e9fdf0123b336825d931c (patch) | |
tree | 0319c1949af24b0568f4e9f891242082d691a8f6 /llvm/lib/IR/BasicBlock.cpp | |
parent | 01b2554ff4defce979b16d794c13ea99f2e2c155 (diff) | |
download | llvm-4eafc9b6ff4ae2bce82e9fdf0123b336825d931c.zip llvm-4eafc9b6ff4ae2bce82e9fdf0123b336825d931c.tar.gz llvm-4eafc9b6ff4ae2bce82e9fdf0123b336825d931c.tar.bz2 |
[IR] Treat callbr as special terminator (PR64215)
isLegalToHoistInto() currently return true for callbr instructions.
That means that a callbr with one successor will be considered a
proper loop preheader, which may result in instructions that use
the callbr return value being hoisted past it.
Fix this by adding callbr to isExceptionTerminator (with a rename
to isSpecialTerminator), which also fixes similar assumptions in
other places.
Fixes https://github.com/llvm/llvm-project/issues/64215.
Differential Revision: https://reviews.llvm.org/D158609
Diffstat (limited to 'llvm/lib/IR/BasicBlock.cpp')
-rw-r--r-- | llvm/lib/IR/BasicBlock.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/IR/BasicBlock.cpp b/llvm/lib/IR/BasicBlock.cpp index 14e1787..1081e03 100644 --- a/llvm/lib/IR/BasicBlock.cpp +++ b/llvm/lib/IR/BasicBlock.cpp @@ -396,8 +396,9 @@ bool BasicBlock::isLegalToHoistInto() const { // If the block has no successors, there can be no instructions to hoist. assert(Term->getNumSuccessors() > 0); - // Instructions should not be hoisted across exception handling boundaries. - return !Term->isExceptionalTerminator(); + // Instructions should not be hoisted across special terminators, which may + // have side effects or return values. + return !Term->isSpecialTerminator(); } bool BasicBlock::isEntryBlock() const { |