[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
Tue Jun 21 07:48:54 PDT 2016
vivekvpandya added a reviewer: MatzeB.
vivekvpandya updated this revision to Diff 61373.
vivekvpandya added a comment.
Updated patch to fetch latest changes in AsmPrinter.cpp. I also feel that it would be good to add an option similar to -asm-show-inst in llc to control this printing. So what are reviewer's thoughts ?
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.61373.patch
Type: text/x-patch
Size: 1550 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160621/ed032d2a/attachment.bin>
More information about the llvm-commits
mailing list