llvm.org GIT mirror llvm / 27c28ce
misched: Added handleMove support for updating all kill flags, not just for allocatable regs. This is a medium term workaround until we have a more robust solution in the form of a register liveness utility for postRA passes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166001 91177308-0d34-0410-b5e6-96231b3b80d8 Andrew Trick 7 years ago
4 changed file(s) with 55 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
259259 /// instruction 'mi' has been moved within a basic block. This will update
260260 /// the live intervals for all operands of mi. Moves between basic blocks
261261 /// are not supported.
262 void handleMove(MachineInstr* MI);
262 ///
263 /// \param updateFlags Update live intervals for nonallocatable physregs.
264 void handleMove(MachineInstr* MI, bool UpdateFlags = false);
263265
264266 /// moveIntoBundle - Update intervals for operands of MI so that they
265267 /// begin/end on the SlotIndex for BundleStart.
268 ///
269 /// \param updateFlags Update live intervals for nonallocatable physregs.
266270 ///
267271 /// Requires MI and BundleStart to have SlotIndexes, and assumes
268272 /// existing liveness is accurate. BundleStart should be the first
269273 /// instruction in the Bundle.
270 void handleMoveIntoBundle(MachineInstr* MI, MachineInstr* BundleStart);
274 void handleMoveIntoBundle(MachineInstr* MI, MachineInstr* BundleStart,
275 bool UpdateFlags = false);
271276
272277 // Register mask functions.
273278 //
10101010 SlotIndex OldIdx;
10111011 SlotIndex NewIdx;
10121012 SmallPtrSet Updated;
1013 bool UpdateFlags;
10131014
10141015 public:
10151016 HMEditor(LiveIntervals& LIS, const MachineRegisterInfo& MRI,
10161017 const TargetRegisterInfo& TRI,
1017 SlotIndex OldIdx, SlotIndex NewIdx)
1018 : LIS(LIS), MRI(MRI), TRI(TRI), OldIdx(OldIdx), NewIdx(NewIdx) {}
1018 SlotIndex OldIdx, SlotIndex NewIdx, bool UpdateFlags)
1019 : LIS(LIS), MRI(MRI), TRI(TRI), OldIdx(OldIdx), NewIdx(NewIdx),
1020 UpdateFlags(UpdateFlags) {}
1021
1022 // FIXME: UpdateFlags is a workaround that creates live intervals for all
1023 // physregs, even those that aren't needed for regalloc, in order to update
1024 // kill flags. This is wasteful. Eventually, LiveVariables will strip all kill
1025 // flags, and postRA passes will use a live register utility instead.
1026 LiveInterval *getRegUnitLI(unsigned Unit) {
1027 if (UpdateFlags)
1028 return &LIS.getRegUnit(Unit);
1029 return LIS.getCachedRegUnit(Unit);
1030 }
10191031
10201032 /// Update all live ranges touched by MI, assuming a move from OldIdx to
10211033 /// NewIdx.
10431055 // For physregs, only update the regunits that actually have a
10441056 // precomputed live range.
10451057 for (MCRegUnitIterator Units(Reg, &TRI); Units.isValid(); ++Units)
1046 if (LiveInterval *LI = LIS.getCachedRegUnit(*Units))
1058 if (LiveInterval *LI = getRegUnitLI(*Units))
10471059 updateRange(*LI);
10481060 }
10491061 if (hasRegMask)
12871299 }
12881300 };
12891301
1290 void LiveIntervals::handleMove(MachineInstr* MI) {
1302 void LiveIntervals::handleMove(MachineInstr* MI, bool UpdateFlags) {
12911303 assert(!MI->isBundled() && "Can't handle bundled instructions yet.");
12921304 SlotIndex OldIndex = Indexes->getInstructionIndex(MI);
12931305 Indexes->removeMachineInstrFromMaps(MI);
12961308 OldIndex < getMBBEndIdx(MI->getParent()) &&
12971309 "Cannot handle moves across basic block boundaries.");
12981310
1299 HMEditor HME(*this, *MRI, *TRI, OldIndex, NewIndex);
1311 HMEditor HME(*this, *MRI, *TRI, OldIndex, NewIndex, UpdateFlags);
13001312 HME.updateAllRanges(MI);
13011313 }
13021314
13031315 void LiveIntervals::handleMoveIntoBundle(MachineInstr* MI,
1304 MachineInstr* BundleStart) {
1316 MachineInstr* BundleStart,
1317 bool UpdateFlags) {
13051318 SlotIndex OldIndex = Indexes->getInstructionIndex(MI);
13061319 SlotIndex NewIndex = Indexes->getInstructionIndex(BundleStart);
1307 HMEditor HME(*this, *MRI, *TRI, OldIndex, NewIndex);
1320 HMEditor HME(*this, *MRI, *TRI, OldIndex, NewIndex, UpdateFlags);
13081321 HME.updateAllRanges(MI);
13091322 }
359359 BB->splice(InsertPos, BB, MI);
360360
361361 // Update LiveIntervals
362 LIS->handleMove(MI);
362 LIS->handleMove(MI, /*UpdateFlags=*/true);
363363
364364 // Recede RegionBegin if an instruction moves above the first.
365365 if (RegionBegin == InsertPos)
None ; RUN: llc < %s -march=x86-64 -mcpu=core2 -enable-misched \
1 ; RUN: -misched=shuffle -misched-bottomup | FileCheck %s
0 ; RUN: llc < %s -march=x86-64 -mcpu=core2 -x86-early-ifcvt -enable-misched \
1 ; RUN: -misched=shuffle -misched-bottomup -verify-machineinstrs \
2 ; RUN: | FileCheck %s
23 ; REQUIRES: asserts
34 ;
45 ; Interesting MachineScheduler cases.
2526 if.end: ; preds = %entry
2627 ret void
2728 }
29
30 ; The machine verifier checks that EFLAGS kill flags are updated when
31 ; the scheduler reorders cmovel instructions.
32 ;
33 ; CHECK: test
34 ; CHECK: cmovel
35 ; CHECK: cmovel
36 ; CHECK: call
37 define void @foo(i32 %b) nounwind uwtable ssp {
38 entry:
39 %tobool = icmp ne i32 %b, 0
40 br i1 %tobool, label %if.then, label %if.end
41
42 if.then: ; preds = %entry
43 br label %if.end
44
45 if.end: ; preds = %if.then, %entry
46 %v1 = phi i32 [1, %entry], [2, %if.then]
47 %v2 = phi i32 [3, %entry], [4, %if.then]
48 call void @bar(i32 %v1, i32 %v2)
49 ret void
50 }
51
52 declare void @bar(i32,i32)