[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
This commit is contained in:
David Green 2021-06-10 14:49:04 +01:00
parent db9ba830d4
commit 9872551ca0
2 changed files with 18 additions and 11 deletions

View File

@ -107,6 +107,12 @@ static bool StepOverPredicatedInstrs(MachineBasicBlock::instr_iterator &Iter,
NumInstrsSteppedOver = 0;
while (Iter != EndIter) {
if (Iter->isDebugInstr()) {
// Skip debug instructions
++Iter;
continue;
}
NextPred = getVPTInstrPredicate(*Iter, PredReg);
assert(NextPred != ARMVCC::Else &&
"VPT block pass does not expect Else preds");
@ -170,6 +176,8 @@ CreateVPTBlock(MachineBasicBlock::instr_iterator &Iter,
LLVM_DEBUG(for (MachineBasicBlock::instr_iterator AddedInstIter =
std::next(BlockBeg);
AddedInstIter != Iter; ++AddedInstIter) {
if (AddedInstIter->isDebugInstr())
continue;
dbgs() << " adding: ";
AddedInstIter->dump();
});
@ -197,7 +205,7 @@ CreateVPTBlock(MachineBasicBlock::instr_iterator &Iter,
if (!IsVPRDefinedOrKilledByBlock(Iter, VPNOTBlockEndIter))
break;
LLVM_DEBUG(dbgs() << " removing VPNOT: "; Iter->dump(););
LLVM_DEBUG(dbgs() << " removing VPNOT: "; Iter->dump());
// Record the new size of the block
BlockSize += ElseInstCnt;
@ -211,6 +219,9 @@ CreateVPTBlock(MachineBasicBlock::instr_iterator &Iter,
// Note that we are using "Iter" to iterate over the block so we can update
// it at the same time.
for (; Iter != VPNOTBlockEndIter; ++Iter) {
if (Iter->isDebugInstr())
continue;
// Find the register in which the predicate is
int OpIdx = findFirstVPTPredOperandIdx(*Iter);
assert(OpIdx != -1);

View File

@ -80,18 +80,14 @@ body: |
; CHECK: DBG_VALUE $q2, $noreg, !19, !DIExpression(), debug-location !21
; CHECK: DBG_VALUE $q2, $noreg, !19, !DIExpression(), debug-location !21
; CHECK: DBG_VALUE $noreg, $noreg, !20, !DIExpression(), debug-location !21
; 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 {
; CHECK: MVE_VPTv4s32 8, renamable $q1, renamable $q0, 10, implicit-def $vpr, debug-location !23
; 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 {
; CHECK: MVE_VPTv4s32 12, renamable $q1, renamable $q0, 10, implicit-def $vpr, debug-location !23
; CHECK: renamable $q2 = MVE_VADDi32 renamable $q0, renamable $q1, 1, internal renamable $vpr, killed renamable $q2, debug-location !23
; CHECK: DBG_VALUE $noreg, $noreg, !20, !DIExpression(), debug-location !21
; CHECK: DBG_VALUE internal $q2, $noreg, !19, !DIExpression(), debug-location !21
; CHECK: renamable $q2 = MVE_VADDi32 killed renamable $q0, killed renamable $q1, 2, internal killed renamable $vpr, internal killed renamable $q2, debug-location !25
; CHECK: DBG_VALUE internal $q2, $noreg, !19, !DIExpression(), debug-location !21
; CHECK: }
; CHECK: DBG_VALUE $noreg, $noreg, !20, !DIExpression(), debug-location !21
; CHECK: DBG_VALUE $q2, $noreg, !19, !DIExpression(), debug-location !21
; CHECK: renamable $vpr = MVE_VPNOT killed renamable $vpr, 0, $noreg, debug-location !24
; 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 {
; CHECK: MVE_VPST 8, implicit $vpr, debug-location !25
; CHECK: renamable $q2 = MVE_VADDi32 killed renamable $q0, killed renamable $q1, 1, killed renamable $vpr, killed renamable $q2, debug-location !25
; CHECK: }
; CHECK: DBG_VALUE $q2, $noreg, !19, !DIExpression(), debug-location !21
; CHECK: $q0 = MVE_VORR killed $q2, killed $q2, 0, $noreg, undef $q0, debug-location !26
; CHECK: tBX_RET 14 /* CC::al */, $noreg, implicit $q0, debug-location !26
DBG_VALUE $q0, $noreg, !17, !DIExpression(), debug-location !21