aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/SelectOptimize.cpp
diff options
context:
space:
mode:
authorJeremy Morse <jeremy.morse@sony.com>2024-01-22 18:12:24 +0000
committerGitHub <noreply@github.com>2024-01-22 18:12:24 +0000
commitd7fb9eb818d22085c7dae0ce9a8be7ade963d7e5 (patch)
treee97e53547f76170b11a17df44425195bc072f00f /llvm/lib/CodeGen/SelectOptimize.cpp
parent7378fb30645ad5398491acea3960a8115d1b171c (diff)
downloadllvm-d7fb9eb818d22085c7dae0ce9a8be7ade963d7e5.zip
llvm-d7fb9eb818d22085c7dae0ce9a8be7ade963d7e5.tar.gz
llvm-d7fb9eb818d22085c7dae0ce9a8be7ade963d7e5.tar.bz2
[DebugInfo][RemoveDIs] Handle DPValues in SelectOptimize (#79005)
When there are debug intrinsics in-between groups of select instructions, select-optimise sinks them into the "end" block. This needs to be replicated for DPValues, the non-instruction variable assignment object. Implement that and add a RUN line to a test that was sensitive to this to ensure it gets tested. (The exact range of instructions being transformed here is a little fiddly, hence I've gone with a helper lambda).
Diffstat (limited to 'llvm/lib/CodeGen/SelectOptimize.cpp')
-rw-r--r--llvm/lib/CodeGen/SelectOptimize.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SelectOptimize.cpp b/llvm/lib/CodeGen/SelectOptimize.cpp
index 1316919..d14283c 100644
--- a/llvm/lib/CodeGen/SelectOptimize.cpp
+++ b/llvm/lib/CodeGen/SelectOptimize.cpp
@@ -491,6 +491,23 @@ void SelectOptimizeImpl::convertProfitableSIGroups(SelectGroups &ProfSIGroups) {
DI->moveBeforePreserving(&*EndBlock->getFirstInsertionPt());
}
+ // Duplicate implementation for DPValues, the non-instruction debug-info
+ // record. Helper lambda for moving DPValues to the end block.
+ auto TransferDPValues = [&](Instruction &I) {
+ for (auto &DPValue : llvm::make_early_inc_range(I.getDbgValueRange())) {
+ DPValue.removeFromParent();
+ EndBlock->insertDPValueBefore(&DPValue,
+ EndBlock->getFirstInsertionPt());
+ }
+ };
+
+ // Iterate over all instructions in between SI and LastSI, not including
+ // SI itself. These are all the variable assignments that happen "in the
+ // middle" of the select group.
+ auto R = make_range(std::next(SI->getIterator()),
+ std::next(LastSI->getIterator()));
+ llvm::for_each(R, TransferDPValues);
+
// These are the new basic blocks for the conditional branch.
// At least one will become an actual new basic block.
BasicBlock *TrueBlock = nullptr, *FalseBlock = nullptr;