aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/SelectOptimize.cpp
diff options
context:
space:
mode:
authorOrlando Cazalet-Hyams <orlando.hyams@sony.com>2024-02-14 14:48:16 +0000
committerGitHub <noreply@github.com>2024-02-14 14:48:16 +0000
commita50bd0d799e3f3fbb759ab842691a0bb570f8614 (patch)
tree3cb9dd4b02c6d2f06cfc3210e2778cc8f4e7a428 /llvm/lib/CodeGen/SelectOptimize.cpp
parent2d7fdfa61f8b037ce65e9c5482f422b37d6c0b99 (diff)
downloadllvm-a50bd0d799e3f3fbb759ab842691a0bb570f8614.zip
llvm-a50bd0d799e3f3fbb759ab842691a0bb570f8614.tar.gz
llvm-a50bd0d799e3f3fbb759ab842691a0bb570f8614.tar.bz2
[RemoveDIs] Replicate dbg intrinsic movement pattern in SelectOptimize (#81737)
Fix crash mentioned in comments on d759618df76361a8e490eeae5c5399e0738cbfd0. The assertion being hit was complaining that we had dangling DPValues; the DPValues attached to the terminator of StartBlock become dangling after the terminator is erased, and they're never "flushed" back onto the new terminator once it's added. Doing that makes the crash go away, but doesn't replicate existing dbg.* behaviour. See the comment in the patch. This change both fixes the crash (because there are now no DPValues left on the terminator to dangle) and replicates existing behaviour (moves those DPValues down to the new block).
Diffstat (limited to 'llvm/lib/CodeGen/SelectOptimize.cpp')
-rw-r--r--llvm/lib/CodeGen/SelectOptimize.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SelectOptimize.cpp b/llvm/lib/CodeGen/SelectOptimize.cpp
index 31c4b63..5609f48 100644
--- a/llvm/lib/CodeGen/SelectOptimize.cpp
+++ b/llvm/lib/CodeGen/SelectOptimize.cpp
@@ -621,6 +621,12 @@ void SelectOptimizeImpl::convertProfitableSIGroups(SelectGroups &ProfSIGroups) {
SelectLike LastSI = ASI.back();
BasicBlock *StartBlock = SI.getI()->getParent();
BasicBlock::iterator SplitPt = ++(BasicBlock::iterator(LastSI.getI()));
+ // With RemoveDIs turned off, SplitPt can be a dbg.* intrinsic. With
+ // RemoveDIs turned on, SplitPt would instead point to the next
+ // instruction. To match existing dbg.* intrinsic behaviour with RemoveDIs,
+ // tell splitBasicBlock that we want to include any DPValues attached to
+ // SplitPt in the splice.
+ SplitPt.setHeadBit(true);
BasicBlock *EndBlock = StartBlock->splitBasicBlock(SplitPt, "select.end");
BFI->setBlockFreq(EndBlock, BFI->getBlockFreq(StartBlock));
// Delete the unconditional branch that was just created by the split.