@@ -976,14 +976,18 @@ static void addDebugSubstitutionsToTable(MachineFunction *MF,
976
976
// OriginalInstr in the new MergedInstr.
977
977
auto Reg = OriginalInstr.getOperand (0 ).getReg ();
978
978
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 ;
981
983
break ;
984
+ }
982
985
OperandNo++;
983
986
}
984
987
985
- MF->makeDebugValueSubstitution ({OriginalInstr.peekDebugInstrNum (), 0 },
986
- {InstrNumToSet, OperandNo});
988
+ if (RegFound)
989
+ MF->makeDebugValueSubstitution ({OriginalInstr.peekDebugInstrNum (), 0 },
990
+ {InstrNumToSet, OperandNo});
987
991
}
988
992
989
993
MachineBasicBlock::iterator
@@ -1264,15 +1268,6 @@ AArch64LoadStoreOpt::mergePairedInsns(MachineBasicBlock::iterator I,
1264
1268
// DBG_INSTR_REF !7, dbg-instr-ref(1, 0), debug-location !9
1265
1269
// DBG_INSTR_REF !8, dbg-instr-ref(2, 0), debug-location !9
1266
1270
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
-
1276
1271
// We want the final result to look like:
1277
1272
// debugValueSubstitutions:
1278
1273
// - { srcinst: 1, srcop: 0, dstinst: 4, dstop: 1, subreg: 0 }
@@ -1283,6 +1278,15 @@ AArch64LoadStoreOpt::mergePairedInsns(MachineBasicBlock::iterator I,
1283
1278
// DBG_INSTR_REF !7, dbg-instr-ref(1, 0), debug-location !9
1284
1279
// DBG_INSTR_REF !8, dbg-instr-ref(2, 0), debug-location !9
1285
1280
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
+
1286
1290
if (I->peekDebugInstrNum ()) {
1287
1291
// If I is the instruction which got sign extended and has a
1288
1292
// debug-instr-number, give the SBFMXri instruction a new
@@ -1349,10 +1353,6 @@ AArch64LoadStoreOpt::mergePairedInsns(MachineBasicBlock::iterator I,
1349
1353
// DBG_INSTR_REF !12, dbg-instr-ref(1, 0), debug-location !14
1350
1354
// DBG_INSTR_REF !13, dbg-instr-ref(2, 0), debug-location !14
1351
1355
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
-
1356
1356
// We want the final result to look like:
1357
1357
// debugValueSubstitutions:
1358
1358
// - { srcinst: 1, srcop: 0, dstinst: 3, dstop: 1, subreg: 0 }
@@ -1361,8 +1361,11 @@ AArch64LoadStoreOpt::mergePairedInsns(MachineBasicBlock::iterator I,
1361
1361
// DBG_INSTR_REF !12, dbg-instr-ref(1, 0), debug-location !14
1362
1362
// DBG_INSTR_REF !12, dbg-instr-ref(2, 0), debug-location !14
1363
1363
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.
1365
1367
1368
+ // Assign new DebugInstrNum to the Paired instruction.
1366
1369
if (I->peekDebugInstrNum ()) {
1367
1370
unsigned NewDebugInstrNum = MIB->getDebugInstrNum ();
1368
1371
addDebugSubstitutionsToTable (MBB->getParent (), NewDebugInstrNum, *I,
0 commit comments