From: Sjoerd Meijer Date: Fri, 24 May 2019 08:25:02 +0000 (+0000) Subject: [ARM] ARMExpandPseudoInsts: add debug messages X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c9505f181c36a3c6691773f5d3a284c75370e925;p=llvm [ARM] ARMExpandPseudoInsts: add debug messages This pass wasn't printing any messages at all, which I find really inconvenient while debugging/tracing things. It now dumps the before and after of expanded instructions. It doesn't do this yet for all instructions, but this is a good start I guess. Differential Revision: https://reviews.llvm.org/D62297 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@361604 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/ARM/ARMExpandPseudoInsts.cpp b/lib/Target/ARM/ARMExpandPseudoInsts.cpp index 680142c2288..a27f7f157de 100644 --- a/lib/Target/ARM/ARMExpandPseudoInsts.cpp +++ b/lib/Target/ARM/ARMExpandPseudoInsts.cpp @@ -23,6 +23,7 @@ #include "llvm/CodeGen/LivePhysRegs.h" #include "llvm/CodeGen/MachineFrameInfo.h" #include "llvm/CodeGen/MachineFunctionPass.h" +#include "llvm/Support/Debug.h" using namespace llvm; @@ -469,6 +470,7 @@ static void GetDSubRegs(unsigned Reg, NEONRegSpacing RegSpc, void ARMExpandPseudo::ExpandVLD(MachineBasicBlock::iterator &MBBI) { MachineInstr &MI = *MBBI; MachineBasicBlock &MBB = *MI.getParent(); + LLVM_DEBUG(dbgs() << "Expanding: "; MI.dump()); const NEONLdStTableEntry *TableEntry = LookupNEONLdSt(MI.getOpcode()); assert(TableEntry && TableEntry->IsLoad && "NEONLdStTable lookup failed"); @@ -570,8 +572,8 @@ void ARMExpandPseudo::ExpandVLD(MachineBasicBlock::iterator &MBBI) { // Transfer memoperands. MIB.cloneMemRefs(MI); - MI.eraseFromParent(); + LLVM_DEBUG(dbgs() << "To: "; MIB.getInstr()->dump();); } /// ExpandVST - Translate VST pseudo instructions with Q, QQ or QQQQ register @@ -579,6 +581,7 @@ void ARMExpandPseudo::ExpandVLD(MachineBasicBlock::iterator &MBBI) { void ARMExpandPseudo::ExpandVST(MachineBasicBlock::iterator &MBBI) { MachineInstr &MI = *MBBI; MachineBasicBlock &MBB = *MI.getParent(); + LLVM_DEBUG(dbgs() << "Expanding: "; MI.dump()); const NEONLdStTableEntry *TableEntry = LookupNEONLdSt(MI.getOpcode()); assert(TableEntry && !TableEntry->IsLoad && "NEONLdStTable lookup failed"); @@ -645,8 +648,8 @@ void ARMExpandPseudo::ExpandVST(MachineBasicBlock::iterator &MBBI) { // Transfer memoperands. MIB.cloneMemRefs(MI); - MI.eraseFromParent(); + LLVM_DEBUG(dbgs() << "To: "; MIB.getInstr()->dump();); } /// ExpandLaneOp - Translate VLD*LN and VST*LN instructions with Q, QQ or QQQQ @@ -654,6 +657,7 @@ void ARMExpandPseudo::ExpandVST(MachineBasicBlock::iterator &MBBI) { void ARMExpandPseudo::ExpandLaneOp(MachineBasicBlock::iterator &MBBI) { MachineInstr &MI = *MBBI; MachineBasicBlock &MBB = *MI.getParent(); + LLVM_DEBUG(dbgs() << "Expanding: "; MI.dump()); const NEONLdStTableEntry *TableEntry = LookupNEONLdSt(MI.getOpcode()); assert(TableEntry && "NEONLdStTable lookup failed"); @@ -744,6 +748,7 @@ void ARMExpandPseudo::ExpandVTBL(MachineBasicBlock::iterator &MBBI, unsigned Opc, bool IsExt) { MachineInstr &MI = *MBBI; MachineBasicBlock &MBB = *MI.getParent(); + LLVM_DEBUG(dbgs() << "Expanding: "; MI.dump()); MachineInstrBuilder MIB = BuildMI(MBB, MBBI, MI.getDebugLoc(), TII->get(Opc)); unsigned OpIdx = 0; @@ -773,6 +778,7 @@ void ARMExpandPseudo::ExpandVTBL(MachineBasicBlock::iterator &MBBI, MIB.addReg(SrcReg, RegState::Implicit | getKillRegState(SrcIsKill)); TransferImpOps(MI, MIB, MIB); MI.eraseFromParent(); + LLVM_DEBUG(dbgs() << "To: "; MIB.getInstr()->dump();); } static bool IsAnAddressOperand(const MachineOperand &MO) { @@ -829,6 +835,7 @@ void ARMExpandPseudo::ExpandMOV32BitImm(MachineBasicBlock &MBB, const MachineOperand &MO = MI.getOperand(isCC ? 2 : 1); bool RequiresBundling = STI->isTargetWindows() && IsAnAddressOperand(MO); MachineInstrBuilder LO16, HI16; + LLVM_DEBUG(dbgs() << "Expanding: "; MI.dump()); if (!STI->hasV6T2Ops() && (Opcode == ARM::MOVi32imm || Opcode == ARM::MOVCCi32imm)) { @@ -910,6 +917,8 @@ void ARMExpandPseudo::ExpandMOV32BitImm(MachineBasicBlock &MBB, LO16.add(makeImplicit(MI.getOperand(1))); TransferImpOps(MI, LO16, HI16); MI.eraseFromParent(); + LLVM_DEBUG(dbgs() << "To: "; LO16.getInstr()->dump();); + LLVM_DEBUG(dbgs() << "And: "; HI16.getInstr()->dump();); } /// Expand a CMP_SWAP pseudo-inst to an ldrex/strex loop as simply as @@ -1929,11 +1938,16 @@ bool ARMExpandPseudo::runOnMachineFunction(MachineFunction &MF) { TRI = STI->getRegisterInfo(); AFI = MF.getInfo(); + LLVM_DEBUG(dbgs() << "********** ARM EXPAND PSEUDO INSTRUCTIONS **********\n" + << "********** Function: " << MF.getName() << '\n'); + bool Modified = false; for (MachineBasicBlock &MBB : MF) Modified |= ExpandMBB(MBB); if (VerifyARMPseudo) MF.verify(this, "After expanding ARM pseudo instructions."); + + LLVM_DEBUG(dbgs() << "***************************************************\n"); return Modified; }