[PATCH] D21490: Print call preserved registers in comments at call site in assembly files.
Vivek Pandya via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 18 10:10:03 PDT 2016
vivekvpandya created this revision.
vivekvpandya added reviewers: qcolombet, mehdi_amini.
vivekvpandya added subscribers: MatzeB, hfinkel, mcrosier, llvm-commits.
This patch makes AsmPrinter print call preserved registers in comments at call site in assembly files.
http://reviews.llvm.org/D21490
Files:
lib/CodeGen/AsmPrinter/AsmPrinter.cpp
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21490.61167.patch
Type: text/x-patch
Size: 1550 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160618/53a0246d/attachment.bin>
More information about the llvm-commits
mailing list