summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorWei Mi <wmi@google.com>2016-02-05 18:14:24 +0000
committerWei Mi <wmi@google.com>2016-02-05 18:14:24 +0000
commita62f05898959a7e58e512614e50082e2e6eb588c (patch)
tree6e9bcbe4858bf61b88144349b9c9a04a6e39d1de /llvm/lib
parent6e1967ef668c284e8cfd4437c47861ea8ec8485c (diff)
downloadbcm5719-llvm-a62f05898959a7e58e512614e50082e2e6eb588c.tar.gz
bcm5719-llvm-a62f05898959a7e58e512614e50082e2e6eb588c.zip
Some stackslots are allocated to vregs which have no real reference.
LiveRangeEdit::eliminateDeadDef is used to remove dead define instructions after rematerialization. To remove a VNI for a vreg from its LiveInterval, LiveIntervals::removeVRegDefAt is used. However, after non-PHI VNIs are all removed, PHI VNI are still left in the LiveInterval. Such unused vregs will be kept in RegsToSpill[] at the end of InlineSpiller::reMaterializeAll and spiller will allocate stackslot for them. The fix is to get rid of unused reg by checking whether it has non-dbg reference instead of whether it has non-empty interval. llvm-svn: 259895
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/InlineSpiller.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/llvm/lib/CodeGen/InlineSpiller.cpp b/llvm/lib/CodeGen/InlineSpiller.cpp
index e31013266bc..1ab528a70c2 100644
--- a/llvm/lib/CodeGen/InlineSpiller.cpp
+++ b/llvm/lib/CodeGen/InlineSpiller.cpp
@@ -981,18 +981,20 @@ void InlineSpiller::reMaterializeAll() {
DEBUG(dbgs() << "Remat created " << DeadDefs.size() << " dead defs.\n");
Edit->eliminateDeadDefs(DeadDefs, RegsToSpill);
- // Get rid of deleted and empty intervals.
+ // LiveRangeEdit::eliminateDeadDef is used to remove dead define instructions
+ // after rematerialization. To remove a VNI for a vreg from its LiveInterval,
+ // LiveIntervals::removeVRegDefAt is used. However, after non-PHI VNIs are all
+ // removed, PHI VNI are still left in the LiveInterval.
+ // So to get rid of unused reg, we need to check whether it has non-dbg
+ // reference instead of whether it has non-empty interval.
unsigned ResultPos = 0;
for (unsigned Reg : RegsToSpill) {
- if (!LIS.hasInterval(Reg))
- continue;
-
- LiveInterval &LI = LIS.getInterval(Reg);
- if (LI.empty()) {
+ if (MRI.reg_nodbg_empty(Reg)) {
Edit->eraseVirtReg(Reg);
continue;
}
-
+ assert((LIS.hasInterval(Reg) && !LIS.getInterval(Reg).empty()) &&
+ "Reg with empty interval has reference");
RegsToSpill[ResultPos++] = Reg;
}
RegsToSpill.erase(RegsToSpill.begin() + ResultPos, RegsToSpill.end());
OpenPOWER on IntegriCloud