Index: lib/CodeGen/AsmPrinter/AsmPrinter.cpp =================================================================== --- lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -27,6 +27,7 @@ #include "llvm/CodeGen/MachineJumpTableInfo.h" #include "llvm/CodeGen/MachineLoopInfo.h" #include "llvm/CodeGen/MachineModuleInfoImpls.h" +#include "llvm/CodeGen/MachineOperand.h" #include "llvm/IR/DataLayout.h" #include "llvm/IR/DebugInfo.h" #include "llvm/IR/Mangler.h" @@ -623,6 +624,7 @@ static void emitComments(const MachineInstr &MI, raw_ostream &CommentOS) { const MachineFunction *MF = MI.getParent()->getParent(); const TargetInstrInfo *TII = MF->getSubtarget().getInstrInfo(); + const TargetRegisterInfo *TRI = MF->getSubtarget().getRegisterInfo(); // Check for spills and reloads int FI; @@ -653,6 +655,22 @@ // Check for spill-induced copies if (MI.getAsmPrinterFlag(MachineInstr::ReloadReuse)) CommentOS << " Reload Reuse\n"; + + if (MI.isCall()) { + const uint32_t *CalleeRegMask; + CommentOS << "Call Preserved Registers: "; + + for (const MachineOperand &MO : MI.operands()) + if (MO.isRegMask()) { + CalleeRegMask = MO.getRegMask(); + break; + } + + for (unsigned PReg = 1, PRegE = TRI->getNumRegs(); PReg < PRegE; ++PReg) + if (!MachineOperand::clobbersPhysReg(CalleeRegMask, PReg)) + CommentOS << TRI->getName(PReg) << " "; + CommentOS << "\n"; + } } /// emitImplicitDef - This method emits the specified machine instruction