[llvm] r327371 - bpf: Enhance debug information for peephole optimization passes
Yonghong Song via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 12 23:47:07 PDT 2018
Author: yhs
Date: Mon Mar 12 23:47:07 2018
New Revision: 327371
URL: http://llvm.org/viewvc/llvm-project?rev=327371&view=rev
Log:
bpf: Enhance debug information for peephole optimization passes
Add more debug information for peephole optimization passes.
These would only be enabled for debug version binary and could help
analyzing why some optimization opportunities were missed.
Signed-off-by: Jiong Wang <jiong.wang at netronome.com>
Signed-off-by: Yonghong Song <yhs at fb.com>
Modified:
llvm/trunk/lib/Target/BPF/BPFMIPeephole.cpp
Modified: llvm/trunk/lib/Target/BPF/BPFMIPeephole.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/BPF/BPFMIPeephole.cpp?rev=327371&r1=327370&r2=327371&view=diff
==============================================================================
--- llvm/trunk/lib/Target/BPF/BPFMIPeephole.cpp (original)
+++ llvm/trunk/lib/Target/BPF/BPFMIPeephole.cpp Mon Mar 12 23:47:07 2018
@@ -79,6 +79,9 @@ bool BPFMIPeephole::isMovFrom32Def(Machi
{
MachineInstr *DefInsn = MRI->getVRegDef(MovMI->getOperand(1).getReg());
+ DEBUG(dbgs() << " Def of Mov Src:");
+ DEBUG(DefInsn->dump());
+
if (!DefInsn)
return false;
@@ -108,6 +111,8 @@ bool BPFMIPeephole::isMovFrom32Def(Machi
return false;
}
+ DEBUG(dbgs() << " One ZExt elim sequence identified.\n");
+
return true;
}
@@ -134,21 +139,32 @@ bool BPFMIPeephole::eliminateZExtSeq(voi
unsigned ShfReg = MI.getOperand(1).getReg();
MachineInstr *SllMI = MRI->getVRegDef(ShfReg);
+ DEBUG(dbgs() << "Starting SRL found:");
+ DEBUG(MI.dump());
+
if (!SllMI ||
SllMI->isPHI() ||
SllMI->getOpcode() != BPF::SLL_ri ||
SllMI->getOperand(2).getImm() != 32)
continue;
+ DEBUG(dbgs() << " SLL found:");
+ DEBUG(SllMI->dump());
+
MachineInstr *MovMI = MRI->getVRegDef(SllMI->getOperand(1).getReg());
if (!MovMI ||
MovMI->isPHI() ||
MovMI->getOpcode() != BPF::MOV_32_64)
continue;
+ DEBUG(dbgs() << " Type cast Mov found:");
+ DEBUG(MovMI->dump());
+
unsigned SubReg = MovMI->getOperand(1).getReg();
- if (!isMovFrom32Def(MovMI))
+ if (!isMovFrom32Def(MovMI)) {
+ DEBUG(dbgs() << " One ZExt elim sequence failed qualifying elim.\n");
continue;
+ }
BuildMI(MBB, MI, MI.getDebugLoc(), TII->get(BPF::SUBREG_TO_REG), DstReg)
.addImm(0).addReg(SubReg).addImm(BPF::sub_32);
@@ -223,6 +239,8 @@ bool BPFMIPreEmitPeephole::eliminateRedu
for (MachineInstr &MI : MBB) {
// If the previous instruction was marked for elimination, remove it now.
if (ToErase) {
+ DEBUG(dbgs() << " Redundant Mov Eliminated:");
+ DEBUG(ToErase->dump());
ToErase->eraseFromParent();
ToErase = nullptr;
}
More information about the llvm-commits
mailing list