Skip to content

Commit 497521c

Browse files
Addressed some more review comments
1 parent 92a561a commit 497521c

File tree

1 file changed

+21
-18
lines changed

1 file changed

+21
-18
lines changed

llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -976,14 +976,18 @@ static void addDebugSubstitutionsToTable(MachineFunction *MF,
976976
// OriginalInstr in the new MergedInstr.
977977
auto Reg = OriginalInstr.getOperand(0).getReg();
978978
unsigned OperandNo = 0;
979-
for (auto Op : MergedInstr.operands()) {
980-
if (Op.getReg() == Reg)
979+
bool RegFound = false;
980+
for (const auto Op : MergedInstr.operands()) {
981+
if (Op.getReg() == Reg) {
982+
RegFound = true;
981983
break;
984+
}
982985
OperandNo++;
983986
}
984987

985-
MF->makeDebugValueSubstitution({OriginalInstr.peekDebugInstrNum(), 0},
986-
{InstrNumToSet, OperandNo});
988+
if (RegFound)
989+
MF->makeDebugValueSubstitution({OriginalInstr.peekDebugInstrNum(), 0},
990+
{InstrNumToSet, OperandNo});
987991
}
988992

989993
MachineBasicBlock::iterator
@@ -1264,15 +1268,6 @@ AArch64LoadStoreOpt::mergePairedInsns(MachineBasicBlock::iterator I,
12641268
// DBG_INSTR_REF !7, dbg-instr-ref(1, 0), debug-location !9
12651269
// DBG_INSTR_REF !8, dbg-instr-ref(2, 0), debug-location !9
12661270

1267-
// $x0 is where the final value is stored, so the sign extend (SBFMXri)
1268-
// instruction contains the final value we care about we give it a new
1269-
// debug-instr-number 3. Whereas, $w1 contains the final value that we care
1270-
// about, therefore the LDP instruction is also given a new
1271-
// debug-instr-number 4. We have to add these subsitutions to the
1272-
// debugValueSubstitutions table. However, we also have to ensure that the
1273-
// OpIndex that pointed to debug-instr-number 1 gets updated to 1, because
1274-
// $w1 is the second operand of the LDP instruction.
1275-
12761271
// We want the final result to look like:
12771272
// debugValueSubstitutions:
12781273
// - { srcinst: 1, srcop: 0, dstinst: 4, dstop: 1, subreg: 0 }
@@ -1283,6 +1278,15 @@ AArch64LoadStoreOpt::mergePairedInsns(MachineBasicBlock::iterator I,
12831278
// DBG_INSTR_REF !7, dbg-instr-ref(1, 0), debug-location !9
12841279
// DBG_INSTR_REF !8, dbg-instr-ref(2, 0), debug-location !9
12851280

1281+
// $x0 is where the final value is stored, so the sign extend (SBFMXri)
1282+
// instruction contains the final value we care about we give it a new
1283+
// debug-instr-number 3. Whereas, $w1 contains the final value that we care
1284+
// about, therefore the LDP instruction is also given a new
1285+
// debug-instr-number 4. We have to add these subsitutions to the
1286+
// debugValueSubstitutions table. However, we also have to ensure that the
1287+
// OpIndex that pointed to debug-instr-number 1 gets updated to 1, because
1288+
// $w1 is the second operand of the LDP instruction.
1289+
12861290
if (I->peekDebugInstrNum()) {
12871291
// If I is the instruction which got sign extended and has a
12881292
// debug-instr-number, give the SBFMXri instruction a new
@@ -1349,10 +1353,6 @@ AArch64LoadStoreOpt::mergePairedInsns(MachineBasicBlock::iterator I,
13491353
// DBG_INSTR_REF !12, dbg-instr-ref(1, 0), debug-location !14
13501354
// DBG_INSTR_REF !13, dbg-instr-ref(2, 0), debug-location !14
13511355

1352-
// Here all that needs to be done is, that the LDP instruction needs to be
1353-
// updated with a new debug-instr-number, we then need to add entries into
1354-
// the debugSubstitutions table to map the old instr-refs to the new ones.
1355-
13561356
// We want the final result to look like:
13571357
// debugValueSubstitutions:
13581358
// - { srcinst: 1, srcop: 0, dstinst: 3, dstop: 1, subreg: 0 }
@@ -1361,8 +1361,11 @@ AArch64LoadStoreOpt::mergePairedInsns(MachineBasicBlock::iterator I,
13611361
// DBG_INSTR_REF !12, dbg-instr-ref(1, 0), debug-location !14
13621362
// DBG_INSTR_REF !12, dbg-instr-ref(2, 0), debug-location !14
13631363

1364-
// Assign new DebugInstrNum to the Paired instruction.
1364+
// Here all that needs to be done is, that the LDP instruction needs to be
1365+
// updated with a new debug-instr-number, we then need to add entries into
1366+
// the debugSubstitutions table to map the old instr-refs to the new ones.
13651367

1368+
// Assign new DebugInstrNum to the Paired instruction.
13661369
if (I->peekDebugInstrNum()) {
13671370
unsigned NewDebugInstrNum = MIB->getDebugInstrNum();
13681371
addDebugSubstitutionsToTable(MBB->getParent(), NewDebugInstrNum, *I,

0 commit comments

Comments
 (0)