aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
diff options
context:
space:
mode:
authorStephen Tozer <stephen.tozer@sony.com>2024-03-19 20:07:07 +0000
committerGitHub <noreply@github.com>2024-03-19 20:07:07 +0000
commitffd08c7759000f55332f1657a1fab64a7adc03fd (patch)
treeffc35f7afc77e9aa3ff89031c72a9ec8e7321b2b /llvm/lib/Transforms/Utils/SimplifyCFG.cpp
parent3cd9dccbb4235e057d0e53ab0b9673f3766800d4 (diff)
downloadllvm-ffd08c7759000f55332f1657a1fab64a7adc03fd.zip
llvm-ffd08c7759000f55332f1657a1fab64a7adc03fd.tar.gz
llvm-ffd08c7759000f55332f1657a1fab64a7adc03fd.tar.bz2
[RemoveDIs][NFC] Rename DPValue -> DbgVariableRecord (#85216)
This is the major rename patch that prior patches have built towards. The DPValue class is being renamed to DbgVariableRecord, which reflects the updated terminology for the "final" implementation of the RemoveDI feature. This is a pure string substitution + clang-format patch. The only manual component of this patch was determining where to perform these string substitutions: `DPValue` and `DPV` are almost exclusively used for DbgRecords, *except* for: - llvm/lib/target, where 'DP' is used to mean double-precision, and so appears as part of .td files and in variable names. NB: There is a single existing use of `DPValue` here that refers to debug info, which I've manually updated. - llvm/tools/gold, where 'LDPV' is used as a prefix for symbol visibility enums. Outside of these places, I've applied several basic string substitutions, with the intent that they only affect DbgRecord-related identifiers; I've checked them as I went through to verify this, with reasonable confidence that there are no unintended changes that slipped through the cracks. The substitutions applied are all case-sensitive, and are applied in the order shown: ``` DPValue -> DbgVariableRecord DPVal -> DbgVarRec DPV -> DVR ``` Following the previous rename patches, it should be the case that there are no instances of any of these strings that are meant to refer to the general case of DbgRecords, or anything other than the DPValue class. The idea behind this patch is therefore that pure string substitution is correct in all cases as long as these assumptions hold.
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/SimplifyCFG.cpp69
1 files changed, 36 insertions, 33 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 292ad78..55bbffb 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -1126,8 +1126,9 @@ static void CloneInstructionsIntoPredecessorBlockAndUpdateSSAUses(
NewBonusInst->insertInto(PredBlock, PTI->getIterator());
auto Range = NewBonusInst->cloneDebugInfoFrom(&BonusInst);
- RemapDPValueRange(NewBonusInst->getModule(), Range, VMap,
- RF_NoModuleLevelChanges | RF_IgnoreMissingLocals);
+ RemapDbgVariableRecordRange(NewBonusInst->getModule(), Range, VMap,
+ RF_NoModuleLevelChanges |
+ RF_IgnoreMissingLocals);
if (isa<DbgInfoIntrinsic>(BonusInst))
continue;
@@ -1526,15 +1527,15 @@ static bool shouldHoistCommonInstructions(Instruction *I1, Instruction *I2,
return true;
}
-/// Hoists DPValues from \p I1 and \p OtherInstrs that are identical in
-/// lock-step to \p TI. This matches how dbg.* intrinsics are hoisting in
+/// Hoists DbgVariableRecords from \p I1 and \p OtherInstrs that are identical
+/// in lock-step to \p TI. This matches how dbg.* intrinsics are hoisting in
/// hoistCommonCodeFromSuccessors. e.g. The input:
-/// I1 DPVs: { x, z },
-/// OtherInsts: { I2 DPVs: { x, y, z } }
-/// would result in hoisting only DPValue x.
-static void
-hoistLockstepIdenticalDPValues(Instruction *TI, Instruction *I1,
- SmallVectorImpl<Instruction *> &OtherInsts) {
+/// I1 DVRs: { x, z },
+/// OtherInsts: { I2 DVRs: { x, y, z } }
+/// would result in hoisting only DbgVariableRecord x.
+static void hoistLockstepIdenticalDbgVariableRecords(
+ Instruction *TI, Instruction *I1,
+ SmallVectorImpl<Instruction *> &OtherInsts) {
if (!I1->hasDbgRecords())
return;
using CurrentAndEndIt =
@@ -1570,12 +1571,12 @@ hoistLockstepIdenticalDPValues(Instruction *TI, Instruction *I1,
// This replicates the dbg.* intrinsic behaviour in
// hoistCommonCodeFromSuccessors.
while (none_of(Itrs, atEnd)) {
- bool HoistDPVs = allIdentical(Itrs);
+ bool HoistDVRs = allIdentical(Itrs);
for (CurrentAndEndIt &Pair : Itrs) {
// Increment Current iterator now as we may be about to move the
// DbgRecord.
DbgRecord &DR = *Pair.first++;
- if (HoistDPVs) {
+ if (HoistDVRs) {
DR.removeFromParent();
TI->getParent()->insertDbgRecordBefore(&DR, TI->getIterator());
}
@@ -1691,7 +1692,7 @@ bool SimplifyCFGOpt::hoistCommonCodeFromSuccessors(BasicBlock *BB,
// at the beginning of the loop, we can hoist the terminator instruction.
// If any instructions remain in the block, we cannot hoist terminators.
if (NumSkipped || !AllInstsAreIdentical) {
- hoistLockstepIdenticalDPValues(TI, I1, OtherInsts);
+ hoistLockstepIdenticalDbgVariableRecords(TI, I1, OtherInsts);
return Changed;
}
@@ -1721,9 +1722,9 @@ bool SimplifyCFGOpt::hoistCommonCodeFromSuccessors(BasicBlock *BB,
// The debug location is an integral part of a debug info intrinsic
// and can't be separated from it or replaced. Instead of attempting
// to merge locations, simply hoist both copies of the intrinsic.
- hoistLockstepIdenticalDPValues(TI, I1, OtherInsts);
- // We've just hoisted DPValues; move I1 after them (before TI) and
- // leave any that were not hoisted behind (by calling moveBefore
+ hoistLockstepIdenticalDbgVariableRecords(TI, I1, OtherInsts);
+ // We've just hoisted DbgVariableRecords; move I1 after them (before TI)
+ // and leave any that were not hoisted behind (by calling moveBefore
// rather than moveBeforePreserving).
I1->moveBefore(TI);
for (auto &SuccIter : OtherSuccIterRange) {
@@ -1735,9 +1736,9 @@ bool SimplifyCFGOpt::hoistCommonCodeFromSuccessors(BasicBlock *BB,
// For a normal instruction, we just move one to right before the
// branch, then replace all uses of the other with the first. Finally,
// we remove the now redundant second instruction.
- hoistLockstepIdenticalDPValues(TI, I1, OtherInsts);
- // We've just hoisted DPValues; move I1 after them (before TI) and
- // leave any that were not hoisted behind (by calling moveBefore
+ hoistLockstepIdenticalDbgVariableRecords(TI, I1, OtherInsts);
+ // We've just hoisted DbgVariableRecords; move I1 after them (before TI)
+ // and leave any that were not hoisted behind (by calling moveBefore
// rather than moveBeforePreserving).
I1->moveBefore(TI);
for (auto &SuccIter : OtherSuccIterRange) {
@@ -1759,7 +1760,7 @@ bool SimplifyCFGOpt::hoistCommonCodeFromSuccessors(BasicBlock *BB,
NumHoistCommonInstrs += SuccIterPairs.size();
} else {
if (NumSkipped >= HoistCommonSkipLimit) {
- hoistLockstepIdenticalDPValues(TI, I1, OtherInsts);
+ hoistLockstepIdenticalDbgVariableRecords(TI, I1, OtherInsts);
return Changed;
}
// We are about to skip over a pair of non-identical instructions. Record
@@ -1822,9 +1823,9 @@ bool SimplifyCFGOpt::hoistSuccIdenticalTerminatorToSwitchOrIf(
}
}
- // Hoist DPValues attached to the terminator to match dbg.* intrinsic hoisting
- // behaviour in hoistCommonCodeFromSuccessors.
- hoistLockstepIdenticalDPValues(TI, I1, OtherSuccTIs);
+ // Hoist DbgVariableRecords attached to the terminator to match dbg.*
+ // intrinsic hoisting behaviour in hoistCommonCodeFromSuccessors.
+ hoistLockstepIdenticalDbgVariableRecords(TI, I1, OtherSuccTIs);
// Clone the terminator and hoist it into the pred, without any debug info.
Instruction *NT = I1->clone();
NT->insertInto(TIParent, TI->getIterator());
@@ -3179,7 +3180,7 @@ bool SimplifyCFGOpt::SpeculativelyExecuteBB(BranchInst *BI,
DbgAssign->replaceVariableLocationOp(OrigV, S);
};
for_each(at::getAssignmentMarkers(SpeculatedStore), replaceVariable);
- for_each(at::getDPVAssignmentMarkers(SpeculatedStore), replaceVariable);
+ for_each(at::getDVRAssignmentMarkers(SpeculatedStore), replaceVariable);
}
// Metadata can be dependent on the condition we are hoisting above.
@@ -3204,13 +3205,15 @@ bool SimplifyCFGOpt::SpeculativelyExecuteBB(BranchInst *BI,
}
// Hoist the instructions.
- // In "RemoveDIs" non-instr debug-info mode, drop DPValues attached to these
- // instructions, in the same way that dbg.value intrinsics are dropped at the
- // end of this block.
+ // In "RemoveDIs" non-instr debug-info mode, drop DbgVariableRecords attached
+ // to these instructions, in the same way that dbg.value intrinsics are
+ // dropped at the end of this block.
for (auto &It : make_range(ThenBB->begin(), ThenBB->end()))
for (DbgRecord &DR : make_early_inc_range(It.getDbgRecordRange()))
- // Drop all records except assign-kind DPValues (dbg.assign equivalent).
- if (DPValue *DPV = dyn_cast<DPValue>(&DR); !DPV || !DPV->isDbgAssign())
+ // Drop all records except assign-kind DbgVariableRecords (dbg.assign
+ // equivalent).
+ if (DbgVariableRecord *DVR = dyn_cast<DbgVariableRecord>(&DR);
+ !DVR || !DVR->isDbgAssign())
It.dropOneDbgRecord(&DR);
BB->splice(BI->getIterator(), ThenBB, ThenBB->begin(),
std::prev(ThenBB->end()));
@@ -3385,7 +3388,7 @@ FoldCondBranchOnValueKnownInPredecessorImpl(BranchInst *BI, DomTreeUpdater *DTU,
TranslateMap[Cond] = CB;
// RemoveDIs: track instructions that we optimise away while folding, so
- // that we can copy DPValues from them later.
+ // that we can copy DbgVariableRecords from them later.
BasicBlock::iterator SrcDbgCursor = BB->begin();
for (BasicBlock::iterator BBI = BB->begin(); &*BBI != BI; ++BBI) {
if (PHINode *PN = dyn_cast<PHINode>(BBI)) {
@@ -3849,10 +3852,10 @@ static bool performBranchToCommonDestFolding(BranchInst *BI, BranchInst *PBI,
if (PredBlock->IsNewDbgInfoFormat) {
PredBlock->getTerminator()->cloneDebugInfoFrom(BB->getTerminator());
- for (DPValue &DPV :
+ for (DbgVariableRecord &DVR :
filterDbgVars(PredBlock->getTerminator()->getDbgRecordRange())) {
- RemapDPValue(M, &DPV, VMap,
- RF_NoModuleLevelChanges | RF_IgnoreMissingLocals);
+ RemapDbgVariableRecord(M, &DVR, VMap,
+ RF_NoModuleLevelChanges | RF_IgnoreMissingLocals);
}
}