[PATCH] D21395: Fix for Bug 28144 and print register preserved in comments in asm files
Matthias Braun via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 17 11:46:21 PDT 2016
MatzeB added inline comments.
================
Comment at: lib/CodeGen/AsmPrinter/AsmPrinter.cpp:659-673
@@ -656,1 +658,17 @@
+
+ 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";
+ }
}
----------------
This part seems independent to me and could go into a separate commit.
================
Comment at: lib/CodeGen/RegUsageInfoCollector.cpp:113-126
@@ -112,1 +112,16 @@
+ for (MachineBasicBlock &MBB : MF) {
+ for (MachineInstr &MI : MBB) {
+ if (!MI.isCall())
+ continue;
+ for (MachineOperand &MO : MI.operands()) {
+ if (!MO.isRegMask())
+ continue;
+ const uint32_t *CalleeRegMask = MO.getRegMask();
+ for (unsigned i = 0; i < RegMaskSize; ++i)
+ RegMask[i] = RegMask[i] & CalleeRegMask[i];
+ break;
+ }
+ }
+ }
+
----------------
Note that the register allocator already computes this information. You can simply use something like `MachineRegisterInfo::getUsedPhysRegsMask()` to get it.
http://reviews.llvm.org/D21395
More information about the llvm-commits
mailing list