summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorWei Mi <wmi@google.com>2016-05-11 22:37:43 +0000
committerWei Mi <wmi@google.com>2016-05-11 22:37:43 +0000
commit8c4136b0d86a2bff476153ffdf994ed39a8288df (patch)
treeb605eb3ba9fc9367f6442ebe11c6f89747055598 /llvm/lib/CodeGen
parent35ee9339a8a75ebb9b26f7ea3d3e8f6a8d763b86 (diff)
downloadbcm5719-llvm-8c4136b0d86a2bff476153ffdf994ed39a8288df.tar.gz
bcm5719-llvm-8c4136b0d86a2bff476153ffdf994ed39a8288df.zip
Fix a bug when hoist spill to a BB with landingpad successor.
This is to fix the bug in https://llvm.org/bugs/show_bug.cgi?id=27612. When spill is hoisted to a BB with landingpad successor, and if the VNI of the spill reg lives into the landingpad successor, the spill should be inserted before the call which may throw exception. InsertPointAnalysis is used to compute the safe insert point. http://reviews.llvm.org/D20027 is a preparing patch for this patch. Differential Revision: http://reviews.llvm.org/D19884. llvm-svn: 269249
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/InlineSpiller.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/llvm/lib/CodeGen/InlineSpiller.cpp b/llvm/lib/CodeGen/InlineSpiller.cpp
index 6d2fcb9c358..1a62cad9cbb 100644
--- a/llvm/lib/CodeGen/InlineSpiller.cpp
+++ b/llvm/lib/CodeGen/InlineSpiller.cpp
@@ -13,6 +13,7 @@
//===----------------------------------------------------------------------===//
#include "Spiller.h"
+#include "SplitKit.h"
#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/Statistic.h"
@@ -69,6 +70,8 @@ class HoistSpillHelper : private LiveRangeEdit::Delegate {
const TargetRegisterInfo &TRI;
const MachineBlockFrequencyInfo &MBFI;
+ InsertPointAnalysis IPA;
+
// Map from StackSlot to its original register.
DenseMap<int, unsigned> StackSlotToReg;
// Map from pair of (StackSlot and Original VNI) to a set of spills which
@@ -114,7 +117,8 @@ public:
MFI(*mf.getFrameInfo()), MRI(mf.getRegInfo()),
TII(*mf.getSubtarget().getInstrInfo()),
TRI(*mf.getSubtarget().getRegisterInfo()),
- MBFI(pass.getAnalysis<MachineBlockFrequencyInfo>()) {}
+ MBFI(pass.getAnalysis<MachineBlockFrequencyInfo>()),
+ IPA(LIS, mf.getNumBlockIDs()) {}
void addToMergeableSpills(MachineInstr *Spill, int StackSlot,
unsigned Original);
@@ -1075,7 +1079,7 @@ bool HoistSpillHelper::rmFromMergeableSpills(MachineInstr *Spill,
bool HoistSpillHelper::isSpillCandBB(unsigned OrigReg, VNInfo &OrigVNI,
MachineBasicBlock &BB, unsigned &LiveReg) {
SlotIndex Idx;
- MachineBasicBlock::iterator MI = BB.getFirstTerminator();
+ MachineBasicBlock::iterator MI = IPA.getLastInsertPointIter(BB);
if (MI != BB.end())
Idx = LIS.getInstructionIndex(*MI);
else
@@ -1376,6 +1380,8 @@ void HoistSpillHelper::hoistAllSpills() {
for (auto &Ent : MergeableSpills) {
int Slot = Ent.first.first;
unsigned OrigReg = SlotToOrigReg[Slot];
+ LiveInterval &OrigLI = LIS.getInterval(OrigReg);
+ IPA.setInterval(&OrigLI);
VNInfo *OrigVNI = Ent.first.second;
SmallPtrSet<MachineInstr *, 16> &EqValSpills = Ent.second;
if (Ent.second.empty())
@@ -1408,17 +1414,15 @@ void HoistSpillHelper::hoistAllSpills() {
// Stack live range update.
LiveInterval &StackIntvl = LSS.getInterval(Slot);
- if (!SpillsToIns.empty() || !SpillsToRm.empty()) {
- LiveInterval &OrigLI = LIS.getInterval(OrigReg);
+ if (!SpillsToIns.empty() || !SpillsToRm.empty())
StackIntvl.MergeValueInAsValue(OrigLI, OrigVNI,
StackIntvl.getValNumInfo(0));
- }
// Insert hoisted spills.
for (auto const Insert : SpillsToIns) {
MachineBasicBlock *BB = Insert.first;
unsigned LiveReg = Insert.second;
- MachineBasicBlock::iterator MI = BB->getFirstTerminator();
+ MachineBasicBlock::iterator MI = IPA.getLastInsertPointIter(*BB);
TII.storeRegToStackSlot(*BB, MI, LiveReg, false, Slot,
MRI.getRegClass(LiveReg), &TRI);
LIS.InsertMachineInstrRangeInMaps(std::prev(MI), MI);
OpenPOWER on IntegriCloud