annotate lib/CodeGen/CalcSpillWeights.cpp @ 134:3a76565eade5 LLVM5.0.1

update 5.0.1
author mir3636
date Sat, 17 Feb 2018 09:57:20 +0900
parents 803732b1fca8
children c2174574ed3a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
1 //===- CalcSpillWeights.cpp -----------------------------------------------===//
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 //
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 // The LLVM Compiler Infrastructure
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 //
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 // This file is distributed under the University of Illinois Open Source
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 // License. See LICENSE.TXT for details.
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 //
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 //===----------------------------------------------------------------------===//
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 #include "llvm/CodeGen/CalcSpillWeights.h"
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
11 #include "llvm/ADT/SmallPtrSet.h"
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
12 #include "llvm/CodeGen/LiveInterval.h"
134
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
13 #include "llvm/CodeGen/LiveIntervals.h"
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 #include "llvm/CodeGen/MachineFunction.h"
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
15 #include "llvm/CodeGen/MachineInstr.h"
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 #include "llvm/CodeGen/MachineLoopInfo.h"
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
17 #include "llvm/CodeGen/MachineOperand.h"
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 #include "llvm/CodeGen/MachineRegisterInfo.h"
134
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
19 #include "llvm/CodeGen/TargetInstrInfo.h"
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
20 #include "llvm/CodeGen/TargetRegisterInfo.h"
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
21 #include "llvm/CodeGen/TargetSubtargetInfo.h"
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
22 #include "llvm/CodeGen/VirtRegMap.h"
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 #include "llvm/Support/Debug.h"
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 #include "llvm/Support/raw_ostream.h"
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
25 #include <cassert>
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
26 #include <tuple>
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
27
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 using namespace llvm;
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
29
77
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
30 #define DEBUG_TYPE "calcspillweights"
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
31
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 void llvm::calculateSpillWeightsAndHints(LiveIntervals &LIS,
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 MachineFunction &MF,
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
34 VirtRegMap *VRM,
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 const MachineLoopInfo &MLI,
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 const MachineBlockFrequencyInfo &MBFI,
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 VirtRegAuxInfo::NormalizingFn norm) {
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 DEBUG(dbgs() << "********** Compute Spill Weights **********\n"
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 << "********** Function: " << MF.getName() << '\n');
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
40
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 MachineRegisterInfo &MRI = MF.getRegInfo();
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
42 VirtRegAuxInfo VRAI(MF, LIS, VRM, MLI, MBFI, norm);
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 for (unsigned i = 0, e = MRI.getNumVirtRegs(); i != e; ++i) {
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 unsigned Reg = TargetRegisterInfo::index2VirtReg(i);
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 if (MRI.reg_nodbg_empty(Reg))
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 continue;
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 VRAI.calculateSpillWeightAndHint(LIS.getInterval(Reg));
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 }
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 }
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
50
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 // Return the preferred allocation register for reg, given a COPY instruction.
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 static unsigned copyHint(const MachineInstr *mi, unsigned reg,
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 const TargetRegisterInfo &tri,
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 const MachineRegisterInfo &mri) {
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 unsigned sub, hreg, hsub;
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 if (mi->getOperand(0).getReg() == reg) {
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 sub = mi->getOperand(0).getSubReg();
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 hreg = mi->getOperand(1).getReg();
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 hsub = mi->getOperand(1).getSubReg();
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 } else {
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 sub = mi->getOperand(1).getSubReg();
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
62 hreg = mi->getOperand(0).getReg();
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
63 hsub = mi->getOperand(0).getSubReg();
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 }
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
65
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
66 if (!hreg)
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 return 0;
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
68
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
69 if (TargetRegisterInfo::isVirtualRegister(hreg))
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
70 return sub == hsub ? hreg : 0;
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
71
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
72 const TargetRegisterClass *rc = mri.getRegClass(reg);
134
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
73 if (!tri.enableMultipleCopyHints()) {
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
74 // Only allow physreg hints in rc.
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
75 if (sub == 0)
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
76 return rc->contains(hreg) ? hreg : 0;
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
77
134
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
78 // reg:sub should match the physreg hreg.
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
79 return tri.getMatchingSuperReg(hreg, sub, rc);
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
80 }
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
81
134
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
82 unsigned CopiedPReg = (hsub ? tri.getSubReg(hreg, hsub) : hreg);
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
83 if (rc->contains(CopiedPReg))
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
84 return CopiedPReg;
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
85
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
86 // Check if reg:sub matches so that a super register could be hinted.
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
87 if (sub)
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
88 return tri.getMatchingSuperReg(CopiedPReg, sub, rc);
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
89
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
90 return 0;
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
91 }
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
92
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
93 // Check if all values in LI are rematerializable
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
94 static bool isRematerializable(const LiveInterval &LI,
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
95 const LiveIntervals &LIS,
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
96 VirtRegMap *VRM,
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
97 const TargetInstrInfo &TII) {
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
98 unsigned Reg = LI.reg;
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
99 unsigned Original = VRM ? VRM->getOriginal(Reg) : 0;
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
100 for (LiveInterval::const_vni_iterator I = LI.vni_begin(), E = LI.vni_end();
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
101 I != E; ++I) {
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
102 const VNInfo *VNI = *I;
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
103 if (VNI->isUnused())
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
104 continue;
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
105 if (VNI->isPHIDef())
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
106 return false;
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
107
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
108 MachineInstr *MI = LIS.getInstructionFromIndex(VNI->def);
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
109 assert(MI && "Dead valno in interval");
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
110
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
111 // Trace copies introduced by live range splitting. The inline
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
112 // spiller can rematerialize through these copies, so the spill
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
113 // weight must reflect this.
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
114 if (VRM) {
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
115 while (MI->isFullCopy()) {
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
116 // The copy destination must match the interval register.
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
117 if (MI->getOperand(0).getReg() != Reg)
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
118 return false;
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
119
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
120 // Get the source register.
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
121 Reg = MI->getOperand(1).getReg();
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
122
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
123 // If the original (pre-splitting) registers match this
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
124 // copy came from a split.
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
125 if (!TargetRegisterInfo::isVirtualRegister(Reg) ||
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
126 VRM->getOriginal(Reg) != Original)
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
127 return false;
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
128
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
129 // Follow the copy live-in value.
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
130 const LiveInterval &SrcLI = LIS.getInterval(Reg);
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
131 LiveQueryResult SrcQ = SrcLI.Query(VNI->def);
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
132 VNI = SrcQ.valueIn();
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
133 assert(VNI && "Copy from non-existing value");
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
134 if (VNI->isPHIDef())
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
135 return false;
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
136 MI = LIS.getInstructionFromIndex(VNI->def);
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
137 assert(MI && "Dead valno in interval");
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
138 }
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
139 }
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
140
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 95
diff changeset
141 if (!TII.isTriviallyReMaterializable(*MI, LIS.getAliasAnalysis()))
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
142 return false;
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
143 }
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
144 return true;
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
145 }
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
146
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
147 void VirtRegAuxInfo::calculateSpillWeightAndHint(LiveInterval &li) {
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
148 float weight = weightCalcHelper(li);
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
149 // Check if unspillable.
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
150 if (weight < 0)
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
151 return;
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
152 li.weight = weight;
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
153 }
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
154
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
155 float VirtRegAuxInfo::futureWeight(LiveInterval &li, SlotIndex start,
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
156 SlotIndex end) {
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
157 return weightCalcHelper(li, &start, &end);
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
158 }
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
159
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
160 float VirtRegAuxInfo::weightCalcHelper(LiveInterval &li, SlotIndex *start,
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
161 SlotIndex *end) {
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
162 MachineRegisterInfo &mri = MF.getRegInfo();
77
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
163 const TargetRegisterInfo &tri = *MF.getSubtarget().getRegisterInfo();
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
164 MachineBasicBlock *mbb = nullptr;
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
165 MachineLoop *loop = nullptr;
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
166 bool isExiting = false;
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
167 float totalWeight = 0;
83
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 77
diff changeset
168 unsigned numInstr = 0; // Number of instructions using li
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
169 SmallPtrSet<MachineInstr*, 8> visited;
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
170
134
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
171 std::pair<unsigned, unsigned> TargetHint = mri.getRegAllocationHint(li.reg);
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
172
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
173 // Don't recompute spill weight for an unspillable register.
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
174 bool Spillable = li.isSpillable();
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
175
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
176 bool localSplitArtifact = start && end;
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
177
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
178 // Do not update future local split artifacts.
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
179 bool updateLI = !localSplitArtifact;
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
180
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
181 if (localSplitArtifact) {
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
182 MachineBasicBlock *localMBB = LIS.getMBBFromIndex(*end);
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
183 assert(localMBB == LIS.getMBBFromIndex(*start) &&
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
184 "start and end are expected to be in the same basic block");
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
185
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
186 // Local split artifact will have 2 additional copy instructions and they
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
187 // will be in the same BB.
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
188 // localLI = COPY other
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
189 // ...
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
190 // other = COPY localLI
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
191 totalWeight += LiveIntervals::getSpillWeight(true, false, &MBFI, localMBB);
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
192 totalWeight += LiveIntervals::getSpillWeight(false, true, &MBFI, localMBB);
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
193
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
194 numInstr += 2;
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
195 }
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
196
134
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
197 // CopyHint is a sortable hint derived from a COPY instruction.
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
198 struct CopyHint {
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
199 unsigned Reg;
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
200 float Weight;
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
201 bool IsPhys;
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
202 unsigned HintOrder;
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
203 CopyHint(unsigned R, float W, bool P, unsigned HR) :
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
204 Reg(R), Weight(W), IsPhys(P), HintOrder(HR) {}
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
205 bool operator<(const CopyHint &rhs) const {
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
206 // Always prefer any physreg hint.
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
207 if (IsPhys != rhs.IsPhys)
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
208 return (IsPhys && !rhs.IsPhys);
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
209 if (Weight != rhs.Weight)
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
210 return (Weight > rhs.Weight);
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
211
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
212 // This is just a temporary way to achive NFC for targets that don't
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
213 // enable multiple copy hints. HintOrder should be removed when all
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
214 // targets return true in enableMultipleCopyHints().
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
215 return (HintOrder < rhs.HintOrder);
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
216
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
217 #if 0 // Should replace the HintOrder check, see above.
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
218 // (just for the purpose of maintaining the set)
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
219 return Reg < rhs.Reg;
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
220 #endif
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
221 }
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
222 };
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
223 std::set<CopyHint> CopyHints;
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
224
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
225 // Temporary: see comment for HintOrder above.
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
226 unsigned CopyHintOrder = 0;
77
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
227 for (MachineRegisterInfo::reg_instr_iterator
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
228 I = mri.reg_instr_begin(li.reg), E = mri.reg_instr_end();
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
229 I != E; ) {
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
230 MachineInstr *mi = &*(I++);
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
231
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
232 // For local split artifacts, we are interested only in instructions between
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
233 // the expected start and end of the range.
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
234 SlotIndex si = LIS.getInstructionIndex(*mi);
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
235 if (localSplitArtifact && ((si < *start) || (si > *end)))
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
236 continue;
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
237
83
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 77
diff changeset
238 numInstr++;
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
239 if (mi->isIdentityCopy() || mi->isImplicitDef() || mi->isDebugValue())
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
240 continue;
83
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 77
diff changeset
241 if (!visited.insert(mi).second)
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
242 continue;
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
243
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
244 float weight = 1.0f;
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
245 if (Spillable) {
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
246 // Get loop info for mi.
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
247 if (mi->getParent() != mbb) {
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
248 mbb = mi->getParent();
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
249 loop = Loops.getLoopFor(mbb);
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
250 isExiting = loop ? loop->isLoopExiting(mbb) : false;
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
251 }
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
252
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
253 // Calculate instr weight.
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
254 bool reads, writes;
77
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
255 std::tie(reads, writes) = mi->readsWritesVirtualRegister(li.reg);
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 95
diff changeset
256 weight = LiveIntervals::getSpillWeight(writes, reads, &MBFI, *mi);
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
257
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
258 // Give extra weight to what looks like a loop induction variable update.
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
259 if (writes && isExiting && LIS.isLiveOutOfMBB(li, mbb))
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
260 weight *= 3;
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
261
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
262 totalWeight += weight;
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
263 }
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
264
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
265 // Get allocation hints from copies.
134
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
266 if (!mi->isCopy() ||
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
267 (TargetHint.first != 0 && !tri.enableMultipleCopyHints()))
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
268 continue;
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
269 unsigned hint = copyHint(mi, li.reg, tri, mri);
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
270 if (!hint)
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
271 continue;
77
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
272 // Force hweight onto the stack so that x86 doesn't add hidden precision,
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
273 // making the comparison incorrectly pass (i.e., 1 > 1 == true??).
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
274 //
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
275 // FIXME: we probably shouldn't use floats at all.
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
276 volatile float hweight = Hint[hint] += weight;
134
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
277 if (TargetRegisterInfo::isVirtualRegister(hint) || mri.isAllocatable(hint))
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
278 CopyHints.insert(CopyHint(hint, hweight, tri.isPhysicalRegister(hint),
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
279 (tri.enableMultipleCopyHints() ? hint : CopyHintOrder++)));
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
280 }
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
281
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
282 Hint.clear();
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
283
134
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
284 // Pass all the sorted copy hints to mri.
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
285 if (updateLI && CopyHints.size()) {
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
286 // Remove a generic hint if previously added by target.
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
287 if (TargetHint.first == 0 && TargetHint.second)
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
288 mri.clearSimpleHint(li.reg);
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
289
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
290 for (auto &Hint : CopyHints) {
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
291 if (TargetHint.first != 0 && Hint.Reg == TargetHint.second)
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
292 // Don't add again the target-type hint.
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
293 continue;
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
294 mri.addRegAllocationHint(li.reg, Hint.Reg);
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
295 if (!tri.enableMultipleCopyHints())
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
296 break;
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
297 }
134
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
298
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
299 // Weakly boost the spill weight of hinted registers.
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
300 totalWeight *= 1.01F;
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
301 }
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
302
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
303 // If the live interval was already unspillable, leave it that way.
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
304 if (!Spillable)
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
305 return -1.0;
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
306
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 95
diff changeset
307 // Mark li as unspillable if all live ranges are tiny and the interval
1172e4bd9c6f update 4.0.0
mir3636
parents: 95
diff changeset
308 // is not live at any reg mask. If the interval is live at a reg mask
1172e4bd9c6f update 4.0.0
mir3636
parents: 95
diff changeset
309 // spilling may be required.
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
310 if (updateLI && li.isZeroLength(LIS.getSlotIndexes()) &&
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 95
diff changeset
311 !li.isLiveAtIndexes(LIS.getRegMaskSlots())) {
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
312 li.markNotSpillable();
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
313 return -1.0;
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
314 }
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
315
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
316 // If all of the definitions of the interval are re-materializable,
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
317 // it is a preferred candidate for spilling.
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
318 // FIXME: this gets much more complicated once we support non-trivial
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
319 // re-materialization.
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
320 if (isRematerializable(li, LIS, VRM, *MF.getSubtarget().getInstrInfo()))
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
321 totalWeight *= 0.5F;
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
322
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
323 if (localSplitArtifact)
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
324 return normalize(totalWeight, start->distance(*end), numInstr);
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
325 return normalize(totalWeight, li.getSize(), numInstr);
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
326 }