Skip to content

Commit c7381b6

Browse files
davemgreentstellar
authored andcommitted
[ARM] Skip debug during vpt block creation
Debug info is currently preventing VPT block creation, leading to different codegen. This patch attempts to skip any debug instructions during vpt block creation, making sure they do not interfere. Differential Revision: https://reviews.llvm.org/D103610
1 parent fd27379 commit c7381b6

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

llvm/lib/Target/ARM/MVEVPTBlockPass.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ static bool StepOverPredicatedInstrs(MachineBasicBlock::instr_iterator &Iter,
107107
NumInstrsSteppedOver = 0;
108108

109109
while (Iter != EndIter) {
110+
if (Iter->isDebugInstr()) {
111+
// Skip debug instructions
112+
++Iter;
113+
continue;
114+
}
115+
110116
NextPred = getVPTInstrPredicate(*Iter, PredReg);
111117
assert(NextPred != ARMVCC::Else &&
112118
"VPT block pass does not expect Else preds");
@@ -170,6 +176,8 @@ CreateVPTBlock(MachineBasicBlock::instr_iterator &Iter,
170176
LLVM_DEBUG(for (MachineBasicBlock::instr_iterator AddedInstIter =
171177
std::next(BlockBeg);
172178
AddedInstIter != Iter; ++AddedInstIter) {
179+
if (AddedInstIter->isDebugInstr())
180+
continue;
173181
dbgs() << " adding: ";
174182
AddedInstIter->dump();
175183
});
@@ -197,7 +205,7 @@ CreateVPTBlock(MachineBasicBlock::instr_iterator &Iter,
197205
if (!IsVPRDefinedOrKilledByBlock(Iter, VPNOTBlockEndIter))
198206
break;
199207

200-
LLVM_DEBUG(dbgs() << " removing VPNOT: "; Iter->dump(););
208+
LLVM_DEBUG(dbgs() << " removing VPNOT: "; Iter->dump());
201209

202210
// Record the new size of the block
203211
BlockSize += ElseInstCnt;
@@ -211,6 +219,9 @@ CreateVPTBlock(MachineBasicBlock::instr_iterator &Iter,
211219
// Note that we are using "Iter" to iterate over the block so we can update
212220
// it at the same time.
213221
for (; Iter != VPNOTBlockEndIter; ++Iter) {
222+
if (Iter->isDebugInstr())
223+
continue;
224+
214225
// Find the register in which the predicate is
215226
int OpIdx = findFirstVPTPredOperandIdx(*Iter);
216227
assert(OpIdx != -1);

llvm/test/CodeGen/Thumb2/mve-vpt-block-debug.mir

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,18 +80,14 @@ body: |
8080
; CHECK: DBG_VALUE $q2, $noreg, !19, !DIExpression(), debug-location !21
8181
; CHECK: DBG_VALUE $q2, $noreg, !19, !DIExpression(), debug-location !21
8282
; CHECK: DBG_VALUE $noreg, $noreg, !20, !DIExpression(), debug-location !21
83-
; CHECK: BUNDLE implicit-def $vpr, implicit-def $q2, implicit-def $d4, implicit-def $s8, implicit-def $s9, implicit-def $d5, implicit-def $s10, implicit-def $s11, implicit $q1, implicit $q0, implicit killed $q2, debug-location !23 {
84-
; CHECK: MVE_VPTv4s32 8, renamable $q1, renamable $q0, 10, implicit-def $vpr, debug-location !23
83+
; CHECK: BUNDLE implicit-def dead $vpr, implicit-def $q2, implicit-def $d4, implicit-def $s8, implicit-def $s9, implicit-def $d5, implicit-def $s10, implicit-def $s11, implicit killed $q1, implicit killed $q0, implicit killed $q2, debug-location !23 {
84+
; CHECK: MVE_VPTv4s32 12, renamable $q1, renamable $q0, 10, implicit-def $vpr, debug-location !23
8585
; CHECK: renamable $q2 = MVE_VADDi32 renamable $q0, renamable $q1, 1, internal renamable $vpr, killed renamable $q2, debug-location !23
86+
; CHECK: DBG_VALUE $noreg, $noreg, !20, !DIExpression(), debug-location !21
87+
; CHECK: DBG_VALUE internal $q2, $noreg, !19, !DIExpression(), debug-location !21
88+
; CHECK: renamable $q2 = MVE_VADDi32 killed renamable $q0, killed renamable $q1, 2, internal killed renamable $vpr, internal killed renamable $q2, debug-location !25
89+
; CHECK: DBG_VALUE internal $q2, $noreg, !19, !DIExpression(), debug-location !21
8690
; CHECK: }
87-
; CHECK: DBG_VALUE $noreg, $noreg, !20, !DIExpression(), debug-location !21
88-
; CHECK: DBG_VALUE $q2, $noreg, !19, !DIExpression(), debug-location !21
89-
; CHECK: renamable $vpr = MVE_VPNOT killed renamable $vpr, 0, $noreg, debug-location !24
90-
; CHECK: BUNDLE implicit-def $q2, implicit-def $d4, implicit-def $s8, implicit-def $s9, implicit-def $d5, implicit-def $s10, implicit-def $s11, implicit killed $vpr, implicit killed $q0, implicit killed $q1, implicit killed $q2, debug-location !25 {
91-
; CHECK: MVE_VPST 8, implicit $vpr, debug-location !25
92-
; CHECK: renamable $q2 = MVE_VADDi32 killed renamable $q0, killed renamable $q1, 1, killed renamable $vpr, killed renamable $q2, debug-location !25
93-
; CHECK: }
94-
; CHECK: DBG_VALUE $q2, $noreg, !19, !DIExpression(), debug-location !21
9591
; CHECK: $q0 = MVE_VORR killed $q2, killed $q2, 0, $noreg, undef $q0, debug-location !26
9692
; CHECK: tBX_RET 14 /* CC::al */, $noreg, implicit $q0, debug-location !26
9793
DBG_VALUE $q0, $noreg, !17, !DIExpression(), debug-location !21

0 commit comments

Comments
 (0)