Jakob Stoklund Olesen | bd5109f | 2011-09-28 00:01:56 +0000 | [diff] [blame] | 1 | //===- ExecutionDepsFix.cpp - Fix execution dependecy issues ----*- C++ -*-===// |
Jakob Stoklund Olesen | 49e121d | 2010-03-25 17:25:00 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
Jakob Stoklund Olesen | 49e121d | 2010-03-25 17:25:00 +0000 | [diff] [blame] | 9 | |
Matthias Braun | e6ff30b | 2017-03-18 05:08:58 +0000 | [diff] [blame] | 10 | #include "llvm/CodeGen/ExecutionDepsFix.h" |
| 11 | |
Chandler Carruth | ed0881b | 2012-12-03 16:50:05 +0000 | [diff] [blame] | 12 | #include "llvm/ADT/PostOrderIterator.h" |
Matthias Braun | 8142efa | 2014-12-17 19:13:47 +0000 | [diff] [blame] | 13 | #include "llvm/ADT/iterator_range.h" |
Juergen Ributzka | 310034e | 2013-12-14 06:52:56 +0000 | [diff] [blame] | 14 | #include "llvm/CodeGen/LivePhysRegs.h" |
Jakob Stoklund Olesen | 49e121d | 2010-03-25 17:25:00 +0000 | [diff] [blame] | 15 | #include "llvm/CodeGen/MachineFunctionPass.h" |
| 16 | #include "llvm/CodeGen/MachineRegisterInfo.h" |
Marina Yatsina | 53ce3f9 | 2016-08-17 19:07:40 +0000 | [diff] [blame] | 17 | #include "llvm/CodeGen/RegisterClassInfo.h" |
Jakob Stoklund Olesen | 42caaa4 | 2010-04-04 18:00:21 +0000 | [diff] [blame] | 18 | #include "llvm/Support/Allocator.h" |
Jakob Stoklund Olesen | 49e121d | 2010-03-25 17:25:00 +0000 | [diff] [blame] | 19 | #include "llvm/Support/Debug.h" |
| 20 | #include "llvm/Support/raw_ostream.h" |
Chandler Carruth | ed0881b | 2012-12-03 16:50:05 +0000 | [diff] [blame] | 21 | #include "llvm/Target/TargetInstrInfo.h" |
Eric Christopher | d913448 | 2014-08-04 21:25:23 +0000 | [diff] [blame] | 22 | #include "llvm/Target/TargetSubtargetInfo.h" |
| 23 | |
Jakob Stoklund Olesen | 49e121d | 2010-03-25 17:25:00 +0000 | [diff] [blame] | 24 | using namespace llvm; |
| 25 | |
Matthias Braun | e9f8209 | 2017-03-18 05:05:40 +0000 | [diff] [blame] | 26 | #define DEBUG_TYPE "execution-deps-fix" |
Chandler Carruth | 1b9dde0 | 2014-04-22 02:02:50 +0000 | [diff] [blame] | 27 | |
Matthias Braun | 046318b | 2015-03-06 18:56:20 +0000 | [diff] [blame] | 28 | /// Translate TRI register number to a list of indices into our smaller tables |
Matthias Braun | 8142efa | 2014-12-17 19:13:47 +0000 | [diff] [blame] | 29 | /// of interesting registers. |
| 30 | iterator_range<SmallVectorImpl<int>::const_iterator> |
Matthias Braun | e9f8209 | 2017-03-18 05:05:40 +0000 | [diff] [blame] | 31 | ExecutionDepsFix::regIndices(unsigned Reg) const { |
Jakob Stoklund Olesen | 30c8112 | 2011-09-27 23:50:46 +0000 | [diff] [blame] | 32 | assert(Reg < AliasMap.size() && "Invalid register"); |
Matthias Braun | 8142efa | 2014-12-17 19:13:47 +0000 | [diff] [blame] | 33 | const auto &Entry = AliasMap[Reg]; |
| 34 | return make_range(Entry.begin(), Entry.end()); |
Jakob Stoklund Olesen | b551aa4 | 2010-03-29 23:24:21 +0000 | [diff] [blame] | 35 | } |
| 36 | |
Matthias Braun | e9f8209 | 2017-03-18 05:05:40 +0000 | [diff] [blame] | 37 | DomainValue *ExecutionDepsFix::alloc(int domain) { |
Jakob Stoklund Olesen | 42caaa4 | 2010-04-04 18:00:21 +0000 | [diff] [blame] | 38 | DomainValue *dv = Avail.empty() ? |
| 39 | new(Allocator.Allocate()) DomainValue : |
| 40 | Avail.pop_back_val(); |
Jakob Stoklund Olesen | 42caaa4 | 2010-04-04 18:00:21 +0000 | [diff] [blame] | 41 | if (domain >= 0) |
Jakob Stoklund Olesen | d03ac95 | 2010-04-04 21:27:26 +0000 | [diff] [blame] | 42 | dv->addDomain(domain); |
Jakob Stoklund Olesen | b7e44a3 | 2011-11-08 23:26:00 +0000 | [diff] [blame] | 43 | assert(dv->Refs == 0 && "Reference count wasn't cleared"); |
Jakob Stoklund Olesen | 53ec977 | 2011-11-09 00:06:18 +0000 | [diff] [blame] | 44 | assert(!dv->Next && "Chained DomainValue shouldn't have been recycled"); |
Jakob Stoklund Olesen | 42caaa4 | 2010-04-04 18:00:21 +0000 | [diff] [blame] | 45 | return dv; |
| 46 | } |
| 47 | |
Sanjay Patel | 4297c3f | 2015-03-15 18:16:04 +0000 | [diff] [blame] | 48 | /// Release a reference to DV. When the last reference is released, |
Jakob Stoklund Olesen | 1438e19 | 2011-11-08 21:57:44 +0000 | [diff] [blame] | 49 | /// collapse if needed. |
Matthias Braun | e9f8209 | 2017-03-18 05:05:40 +0000 | [diff] [blame] | 50 | void ExecutionDepsFix::release(DomainValue *DV) { |
Jakob Stoklund Olesen | 53ec977 | 2011-11-09 00:06:18 +0000 | [diff] [blame] | 51 | while (DV) { |
| 52 | assert(DV->Refs && "Bad DomainValue"); |
| 53 | if (--DV->Refs) |
| 54 | return; |
Jakob Stoklund Olesen | 1438e19 | 2011-11-08 21:57:44 +0000 | [diff] [blame] | 55 | |
Jakob Stoklund Olesen | 53ec977 | 2011-11-09 00:06:18 +0000 | [diff] [blame] | 56 | // There are no more DV references. Collapse any contained instructions. |
| 57 | if (DV->AvailableDomains && !DV->isCollapsed()) |
| 58 | collapse(DV, DV->getFirstDomain()); |
Jakob Stoklund Olesen | 1438e19 | 2011-11-08 21:57:44 +0000 | [diff] [blame] | 59 | |
Jakob Stoklund Olesen | 53ec977 | 2011-11-09 00:06:18 +0000 | [diff] [blame] | 60 | DomainValue *Next = DV->Next; |
| 61 | DV->clear(); |
| 62 | Avail.push_back(DV); |
| 63 | // Also release the next DomainValue in the chain. |
| 64 | DV = Next; |
| 65 | } |
| 66 | } |
| 67 | |
Sanjay Patel | 4297c3f | 2015-03-15 18:16:04 +0000 | [diff] [blame] | 68 | /// Follow the chain of dead DomainValues until a live DomainValue is reached. |
| 69 | /// Update the referenced pointer when necessary. |
Matthias Braun | e9f8209 | 2017-03-18 05:05:40 +0000 | [diff] [blame] | 70 | DomainValue *ExecutionDepsFix::resolve(DomainValue *&DVRef) { |
Jakob Stoklund Olesen | 53ec977 | 2011-11-09 00:06:18 +0000 | [diff] [blame] | 71 | DomainValue *DV = DVRef; |
| 72 | if (!DV || !DV->Next) |
| 73 | return DV; |
| 74 | |
| 75 | // DV has a chain. Find the end. |
| 76 | do DV = DV->Next; |
| 77 | while (DV->Next); |
| 78 | |
| 79 | // Update DVRef to point to DV. |
| 80 | retain(DV); |
| 81 | release(DVRef); |
| 82 | DVRef = DV; |
| 83 | return DV; |
Jakob Stoklund Olesen | 42caaa4 | 2010-04-04 18:00:21 +0000 | [diff] [blame] | 84 | } |
| 85 | |
Jakob Stoklund Olesen | b551aa4 | 2010-03-29 23:24:21 +0000 | [diff] [blame] | 86 | /// Set LiveRegs[rx] = dv, updating reference counts. |
Matthias Braun | e9f8209 | 2017-03-18 05:05:40 +0000 | [diff] [blame] | 87 | void ExecutionDepsFix::setLiveReg(int rx, DomainValue *dv) { |
Jakob Stoklund Olesen | 3b9af40 | 2010-03-30 20:04:01 +0000 | [diff] [blame] | 88 | assert(unsigned(rx) < NumRegs && "Invalid index"); |
Jakob Stoklund Olesen | 543bef6 | 2011-11-15 01:15:25 +0000 | [diff] [blame] | 89 | assert(LiveRegs && "Must enter basic block first."); |
Jakob Stoklund Olesen | 3b9af40 | 2010-03-30 20:04:01 +0000 | [diff] [blame] | 90 | |
Jakob Stoklund Olesen | 543bef6 | 2011-11-15 01:15:25 +0000 | [diff] [blame] | 91 | if (LiveRegs[rx].Value == dv) |
Jakob Stoklund Olesen | b551aa4 | 2010-03-29 23:24:21 +0000 | [diff] [blame] | 92 | return; |
Jakob Stoklund Olesen | 543bef6 | 2011-11-15 01:15:25 +0000 | [diff] [blame] | 93 | if (LiveRegs[rx].Value) |
| 94 | release(LiveRegs[rx].Value); |
| 95 | LiveRegs[rx].Value = retain(dv); |
Jakob Stoklund Olesen | b551aa4 | 2010-03-29 23:24:21 +0000 | [diff] [blame] | 96 | } |
| 97 | |
| 98 | // Kill register rx, recycle or collapse any DomainValue. |
Matthias Braun | e9f8209 | 2017-03-18 05:05:40 +0000 | [diff] [blame] | 99 | void ExecutionDepsFix::kill(int rx) { |
Jakob Stoklund Olesen | 3b9af40 | 2010-03-30 20:04:01 +0000 | [diff] [blame] | 100 | assert(unsigned(rx) < NumRegs && "Invalid index"); |
Jakob Stoklund Olesen | 543bef6 | 2011-11-15 01:15:25 +0000 | [diff] [blame] | 101 | assert(LiveRegs && "Must enter basic block first."); |
| 102 | if (!LiveRegs[rx].Value) |
| 103 | return; |
Jakob Stoklund Olesen | b551aa4 | 2010-03-29 23:24:21 +0000 | [diff] [blame] | 104 | |
Jakob Stoklund Olesen | 543bef6 | 2011-11-15 01:15:25 +0000 | [diff] [blame] | 105 | release(LiveRegs[rx].Value); |
Craig Topper | c0196b1 | 2014-04-14 00:51:57 +0000 | [diff] [blame] | 106 | LiveRegs[rx].Value = nullptr; |
Jakob Stoklund Olesen | b551aa4 | 2010-03-29 23:24:21 +0000 | [diff] [blame] | 107 | } |
| 108 | |
| 109 | /// Force register rx into domain. |
Matthias Braun | e9f8209 | 2017-03-18 05:05:40 +0000 | [diff] [blame] | 110 | void ExecutionDepsFix::force(int rx, unsigned domain) { |
Jakob Stoklund Olesen | 3b9af40 | 2010-03-30 20:04:01 +0000 | [diff] [blame] | 111 | assert(unsigned(rx) < NumRegs && "Invalid index"); |
Jakob Stoklund Olesen | 543bef6 | 2011-11-15 01:15:25 +0000 | [diff] [blame] | 112 | assert(LiveRegs && "Must enter basic block first."); |
| 113 | if (DomainValue *dv = LiveRegs[rx].Value) { |
Jakob Stoklund Olesen | d03ac95 | 2010-04-04 21:27:26 +0000 | [diff] [blame] | 114 | if (dv->isCollapsed()) |
| 115 | dv->addDomain(domain); |
Jakob Stoklund Olesen | 41051a0 | 2010-04-06 19:48:56 +0000 | [diff] [blame] | 116 | else if (dv->hasDomain(domain)) |
Jakob Stoklund Olesen | 9e338bb | 2011-11-08 21:57:47 +0000 | [diff] [blame] | 117 | collapse(dv, domain); |
Jakob Stoklund Olesen | 41051a0 | 2010-04-06 19:48:56 +0000 | [diff] [blame] | 118 | else { |
Jakob Stoklund Olesen | bd5109f | 2011-09-28 00:01:56 +0000 | [diff] [blame] | 119 | // This is an incompatible open DomainValue. Collapse it to whatever and |
| 120 | // force the new value into domain. This costs a domain crossing. |
Jakob Stoklund Olesen | 9e338bb | 2011-11-08 21:57:47 +0000 | [diff] [blame] | 121 | collapse(dv, dv->getFirstDomain()); |
Jakob Stoklund Olesen | 543bef6 | 2011-11-15 01:15:25 +0000 | [diff] [blame] | 122 | assert(LiveRegs[rx].Value && "Not live after collapse?"); |
| 123 | LiveRegs[rx].Value->addDomain(domain); |
Jakob Stoklund Olesen | 41051a0 | 2010-04-06 19:48:56 +0000 | [diff] [blame] | 124 | } |
Jakob Stoklund Olesen | b551aa4 | 2010-03-29 23:24:21 +0000 | [diff] [blame] | 125 | } else { |
Jakob Stoklund Olesen | 3b9af40 | 2010-03-30 20:04:01 +0000 | [diff] [blame] | 126 | // Set up basic collapsed DomainValue. |
Jakob Stoklund Olesen | 9e338bb | 2011-11-08 21:57:47 +0000 | [diff] [blame] | 127 | setLiveReg(rx, alloc(domain)); |
Jakob Stoklund Olesen | b551aa4 | 2010-03-29 23:24:21 +0000 | [diff] [blame] | 128 | } |
| 129 | } |
| 130 | |
| 131 | /// Collapse open DomainValue into given domain. If there are multiple |
| 132 | /// registers using dv, they each get a unique collapsed DomainValue. |
Matthias Braun | e9f8209 | 2017-03-18 05:05:40 +0000 | [diff] [blame] | 133 | void ExecutionDepsFix::collapse(DomainValue *dv, unsigned domain) { |
Jakob Stoklund Olesen | d03ac95 | 2010-04-04 21:27:26 +0000 | [diff] [blame] | 134 | assert(dv->hasDomain(domain) && "Cannot collapse"); |
Jakob Stoklund Olesen | b551aa4 | 2010-03-29 23:24:21 +0000 | [diff] [blame] | 135 | |
| 136 | // Collapse all the instructions. |
Jakob Stoklund Olesen | d03ac95 | 2010-04-04 21:27:26 +0000 | [diff] [blame] | 137 | while (!dv->Instrs.empty()) |
Duncan P. N. Exon Smith | 9cfc75c | 2016-06-30 00:01:54 +0000 | [diff] [blame] | 138 | TII->setExecutionDomain(*dv->Instrs.pop_back_val(), domain); |
Jakob Stoklund Olesen | d03ac95 | 2010-04-04 21:27:26 +0000 | [diff] [blame] | 139 | dv->setSingleDomain(domain); |
Jakob Stoklund Olesen | b551aa4 | 2010-03-29 23:24:21 +0000 | [diff] [blame] | 140 | |
| 141 | // If there are multiple users, give them new, unique DomainValues. |
Jakob Stoklund Olesen | 42caaa4 | 2010-04-04 18:00:21 +0000 | [diff] [blame] | 142 | if (LiveRegs && dv->Refs > 1) |
Jakob Stoklund Olesen | 3b9af40 | 2010-03-30 20:04:01 +0000 | [diff] [blame] | 143 | for (unsigned rx = 0; rx != NumRegs; ++rx) |
Jakob Stoklund Olesen | 543bef6 | 2011-11-15 01:15:25 +0000 | [diff] [blame] | 144 | if (LiveRegs[rx].Value == dv) |
Jakob Stoklund Olesen | 9e338bb | 2011-11-08 21:57:47 +0000 | [diff] [blame] | 145 | setLiveReg(rx, alloc(domain)); |
Jakob Stoklund Olesen | b551aa4 | 2010-03-29 23:24:21 +0000 | [diff] [blame] | 146 | } |
| 147 | |
Sanjay Patel | 4297c3f | 2015-03-15 18:16:04 +0000 | [diff] [blame] | 148 | /// All instructions and registers in B are moved to A, and B is released. |
Matthias Braun | e9f8209 | 2017-03-18 05:05:40 +0000 | [diff] [blame] | 149 | bool ExecutionDepsFix::merge(DomainValue *A, DomainValue *B) { |
Jakob Stoklund Olesen | d03ac95 | 2010-04-04 21:27:26 +0000 | [diff] [blame] | 150 | assert(!A->isCollapsed() && "Cannot merge into collapsed"); |
| 151 | assert(!B->isCollapsed() && "Cannot merge from collapsed"); |
Jakob Stoklund Olesen | 58ca0a6 | 2010-03-31 20:05:12 +0000 | [diff] [blame] | 152 | if (A == B) |
Jakob Stoklund Olesen | 4cd5866 | 2010-03-31 17:13:16 +0000 | [diff] [blame] | 153 | return true; |
Jakob Stoklund Olesen | d03ac95 | 2010-04-04 21:27:26 +0000 | [diff] [blame] | 154 | // Restrict to the domains that A and B have in common. |
| 155 | unsigned common = A->getCommonDomains(B->AvailableDomains); |
| 156 | if (!common) |
Jakob Stoklund Olesen | b551aa4 | 2010-03-29 23:24:21 +0000 | [diff] [blame] | 157 | return false; |
Jakob Stoklund Olesen | d03ac95 | 2010-04-04 21:27:26 +0000 | [diff] [blame] | 158 | A->AvailableDomains = common; |
Jakob Stoklund Olesen | b551aa4 | 2010-03-29 23:24:21 +0000 | [diff] [blame] | 159 | A->Instrs.append(B->Instrs.begin(), B->Instrs.end()); |
Jakob Stoklund Olesen | 1205881 | 2011-11-08 20:57:04 +0000 | [diff] [blame] | 160 | |
| 161 | // Clear the old DomainValue so we won't try to swizzle instructions twice. |
Jakob Stoklund Olesen | b7e44a3 | 2011-11-08 23:26:00 +0000 | [diff] [blame] | 162 | B->clear(); |
Jakob Stoklund Olesen | 53ec977 | 2011-11-09 00:06:18 +0000 | [diff] [blame] | 163 | // All uses of B are referred to A. |
| 164 | B->Next = retain(A); |
Jakob Stoklund Olesen | 1205881 | 2011-11-08 20:57:04 +0000 | [diff] [blame] | 165 | |
Michael Ilseman | addddc4 | 2014-12-15 18:48:43 +0000 | [diff] [blame] | 166 | for (unsigned rx = 0; rx != NumRegs; ++rx) { |
| 167 | assert(LiveRegs && "no space allocated for live registers"); |
Jakob Stoklund Olesen | 543bef6 | 2011-11-15 01:15:25 +0000 | [diff] [blame] | 168 | if (LiveRegs[rx].Value == B) |
Jakob Stoklund Olesen | 9e338bb | 2011-11-08 21:57:47 +0000 | [diff] [blame] | 169 | setLiveReg(rx, A); |
Michael Ilseman | addddc4 | 2014-12-15 18:48:43 +0000 | [diff] [blame] | 170 | } |
Jakob Stoklund Olesen | b551aa4 | 2010-03-29 23:24:21 +0000 | [diff] [blame] | 171 | return true; |
| 172 | } |
| 173 | |
Sanjay Patel | 4297c3f | 2015-03-15 18:16:04 +0000 | [diff] [blame] | 174 | /// Set up LiveRegs by merging predecessor live-out values. |
Matthias Braun | e9f8209 | 2017-03-18 05:05:40 +0000 | [diff] [blame] | 175 | void ExecutionDepsFix::enterBasicBlock(MachineBasicBlock *MBB) { |
Jakob Stoklund Olesen | 543bef6 | 2011-11-15 01:15:25 +0000 | [diff] [blame] | 176 | // Reset instruction counter in each basic block. |
| 177 | CurInstr = 0; |
| 178 | |
Andrew Trick | b6d56be | 2013-10-14 22:19:03 +0000 | [diff] [blame] | 179 | // Set up UndefReads to track undefined register reads. |
| 180 | UndefReads.clear(); |
Juergen Ributzka | 310034e | 2013-12-14 06:52:56 +0000 | [diff] [blame] | 181 | LiveRegSet.clear(); |
Andrew Trick | b6d56be | 2013-10-14 22:19:03 +0000 | [diff] [blame] | 182 | |
Jakob Stoklund Olesen | 543bef6 | 2011-11-15 01:15:25 +0000 | [diff] [blame] | 183 | // Set up LiveRegs to represent registers entering MBB. |
| 184 | if (!LiveRegs) |
| 185 | LiveRegs = new LiveReg[NumRegs]; |
| 186 | |
| 187 | // Default values are 'nothing happened a long time ago'. |
| 188 | for (unsigned rx = 0; rx != NumRegs; ++rx) { |
Craig Topper | c0196b1 | 2014-04-14 00:51:57 +0000 | [diff] [blame] | 189 | LiveRegs[rx].Value = nullptr; |
Jakob Stoklund Olesen | 543bef6 | 2011-11-15 01:15:25 +0000 | [diff] [blame] | 190 | LiveRegs[rx].Def = -(1 << 20); |
| 191 | } |
| 192 | |
| 193 | // This is the entry block. |
| 194 | if (MBB->pred_empty()) { |
Matthias Braun | d9da162 | 2015-09-09 18:08:03 +0000 | [diff] [blame] | 195 | for (const auto &LI : MBB->liveins()) { |
| 196 | for (int rx : regIndices(LI.PhysReg)) { |
Matthias Braun | 8142efa | 2014-12-17 19:13:47 +0000 | [diff] [blame] | 197 | // Treat function live-ins as if they were defined just before the first |
| 198 | // instruction. Usually, function arguments are set up immediately |
| 199 | // before the call. |
| 200 | LiveRegs[rx].Def = -1; |
| 201 | } |
Jakob Stoklund Olesen | 543bef6 | 2011-11-15 01:15:25 +0000 | [diff] [blame] | 202 | } |
| 203 | DEBUG(dbgs() << "BB#" << MBB->getNumber() << ": entry\n"); |
| 204 | return; |
| 205 | } |
Jakob Stoklund Olesen | 3dc89c9 | 2011-11-09 01:06:56 +0000 | [diff] [blame] | 206 | |
Jakob Stoklund Olesen | 3b9af40 | 2010-03-30 20:04:01 +0000 | [diff] [blame] | 207 | // Try to coalesce live-out registers from predecessors. |
Jakob Stoklund Olesen | 543bef6 | 2011-11-15 01:15:25 +0000 | [diff] [blame] | 208 | for (MachineBasicBlock::const_pred_iterator pi = MBB->pred_begin(), |
| 209 | pe = MBB->pred_end(); pi != pe; ++pi) { |
Keno Fischer | 578cf7a | 2017-01-30 23:37:03 +0000 | [diff] [blame] | 210 | auto fi = MBBInfos.find(*pi); |
| 211 | assert(fi != MBBInfos.end() && |
| 212 | "Should have pre-allocated MBBInfos for all MBBs"); |
| 213 | LiveReg *Incoming = fi->second.OutRegs; |
| 214 | // Incoming is null if this is a backedge from a BB |
| 215 | // we haven't processed yet |
| 216 | if (Incoming == nullptr) { |
Jakob Stoklund Olesen | 543bef6 | 2011-11-15 01:15:25 +0000 | [diff] [blame] | 217 | continue; |
| 218 | } |
Jakob Stoklund Olesen | 543bef6 | 2011-11-15 01:15:25 +0000 | [diff] [blame] | 219 | |
| 220 | for (unsigned rx = 0; rx != NumRegs; ++rx) { |
| 221 | // Use the most recent predecessor def for each register. |
Keno Fischer | 578cf7a | 2017-01-30 23:37:03 +0000 | [diff] [blame] | 222 | LiveRegs[rx].Def = std::max(LiveRegs[rx].Def, Incoming[rx].Def); |
Jakob Stoklund Olesen | 543bef6 | 2011-11-15 01:15:25 +0000 | [diff] [blame] | 223 | |
Keno Fischer | 578cf7a | 2017-01-30 23:37:03 +0000 | [diff] [blame] | 224 | DomainValue *pdv = resolve(Incoming[rx].Value); |
Jakob Stoklund Olesen | 543bef6 | 2011-11-15 01:15:25 +0000 | [diff] [blame] | 225 | if (!pdv) |
Jakob Stoklund Olesen | 3dc89c9 | 2011-11-09 01:06:56 +0000 | [diff] [blame] | 226 | continue; |
Jakob Stoklund Olesen | 543bef6 | 2011-11-15 01:15:25 +0000 | [diff] [blame] | 227 | if (!LiveRegs[rx].Value) { |
Jakob Stoklund Olesen | 9e338bb | 2011-11-08 21:57:47 +0000 | [diff] [blame] | 228 | setLiveReg(rx, pdv); |
Chris Lattner | 503a0ef | 2010-03-31 20:32:51 +0000 | [diff] [blame] | 229 | continue; |
Jakob Stoklund Olesen | 3b9af40 | 2010-03-30 20:04:01 +0000 | [diff] [blame] | 230 | } |
Chris Lattner | 503a0ef | 2010-03-31 20:32:51 +0000 | [diff] [blame] | 231 | |
| 232 | // We have a live DomainValue from more than one predecessor. |
Jakob Stoklund Olesen | 543bef6 | 2011-11-15 01:15:25 +0000 | [diff] [blame] | 233 | if (LiveRegs[rx].Value->isCollapsed()) { |
Eric Christopher | 650c8f2 | 2014-05-20 17:11:11 +0000 | [diff] [blame] | 234 | // We are already collapsed, but predecessor is not. Force it. |
Jakob Stoklund Olesen | 543bef6 | 2011-11-15 01:15:25 +0000 | [diff] [blame] | 235 | unsigned Domain = LiveRegs[rx].Value->getFirstDomain(); |
| 236 | if (!pdv->isCollapsed() && pdv->hasDomain(Domain)) |
| 237 | collapse(pdv, Domain); |
Chris Lattner | 503a0ef | 2010-03-31 20:32:51 +0000 | [diff] [blame] | 238 | continue; |
| 239 | } |
Jakob Stoklund Olesen | 42caaa4 | 2010-04-04 18:00:21 +0000 | [diff] [blame] | 240 | |
Chris Lattner | 503a0ef | 2010-03-31 20:32:51 +0000 | [diff] [blame] | 241 | // Currently open, merge in predecessor. |
Jakob Stoklund Olesen | d03ac95 | 2010-04-04 21:27:26 +0000 | [diff] [blame] | 242 | if (!pdv->isCollapsed()) |
Jakob Stoklund Olesen | 543bef6 | 2011-11-15 01:15:25 +0000 | [diff] [blame] | 243 | merge(LiveRegs[rx].Value, pdv); |
Chris Lattner | 503a0ef | 2010-03-31 20:32:51 +0000 | [diff] [blame] | 244 | else |
Jakob Stoklund Olesen | 9e338bb | 2011-11-08 21:57:47 +0000 | [diff] [blame] | 245 | force(rx, pdv->getFirstDomain()); |
Jakob Stoklund Olesen | 3b9af40 | 2010-03-30 20:04:01 +0000 | [diff] [blame] | 246 | } |
| 247 | } |
Keno Fischer | 578cf7a | 2017-01-30 23:37:03 +0000 | [diff] [blame] | 248 | DEBUG( |
| 249 | dbgs() << "BB#" << MBB->getNumber() |
| 250 | << (!isBlockDone(MBB) ? ": incomplete\n" : ": all preds known\n")); |
Jakob Stoklund Olesen | b551aa4 | 2010-03-29 23:24:21 +0000 | [diff] [blame] | 251 | } |
| 252 | |
Matthias Braun | e9f8209 | 2017-03-18 05:05:40 +0000 | [diff] [blame] | 253 | void ExecutionDepsFix::leaveBasicBlock(MachineBasicBlock *MBB) { |
Jakob Stoklund Olesen | 543bef6 | 2011-11-15 01:15:25 +0000 | [diff] [blame] | 254 | assert(LiveRegs && "Must enter basic block first."); |
Keno Fischer | 578cf7a | 2017-01-30 23:37:03 +0000 | [diff] [blame] | 255 | LiveReg *OldOutRegs = MBBInfos[MBB].OutRegs; |
| 256 | // Save register clearances at end of MBB - used by enterBasicBlock(). |
| 257 | MBBInfos[MBB].OutRegs = LiveRegs; |
Jakob Stoklund Olesen | 543bef6 | 2011-11-15 01:15:25 +0000 | [diff] [blame] | 258 | |
Keno Fischer | 578cf7a | 2017-01-30 23:37:03 +0000 | [diff] [blame] | 259 | // While processing the basic block, we kept `Def` relative to the start |
| 260 | // of the basic block for convenience. However, future use of this information |
| 261 | // only cares about the clearance from the end of the block, so adjust |
| 262 | // everything to be relative to the end of the basic block. |
| 263 | for (unsigned i = 0, e = NumRegs; i != e; ++i) |
| 264 | LiveRegs[i].Def -= CurInstr; |
| 265 | if (OldOutRegs) { |
| 266 | // This must be the second pass. |
Jakob Stoklund Olesen | 3dc89c9 | 2011-11-09 01:06:56 +0000 | [diff] [blame] | 267 | // Release all the DomainValues instead of keeping them. |
| 268 | for (unsigned i = 0, e = NumRegs; i != e; ++i) |
Keno Fischer | 578cf7a | 2017-01-30 23:37:03 +0000 | [diff] [blame] | 269 | release(OldOutRegs[i].Value); |
| 270 | delete[] OldOutRegs; |
Jakob Stoklund Olesen | 3dc89c9 | 2011-11-09 01:06:56 +0000 | [diff] [blame] | 271 | } |
Craig Topper | c0196b1 | 2014-04-14 00:51:57 +0000 | [diff] [blame] | 272 | LiveRegs = nullptr; |
Jakob Stoklund Olesen | 736cf46 | 2011-11-07 21:40:27 +0000 | [diff] [blame] | 273 | } |
| 274 | |
Matthias Braun | e9f8209 | 2017-03-18 05:05:40 +0000 | [diff] [blame] | 275 | bool ExecutionDepsFix::visitInstr(MachineInstr *MI) { |
Jakob Stoklund Olesen | 543bef6 | 2011-11-15 01:15:25 +0000 | [diff] [blame] | 276 | // Update instructions with explicit execution domains. |
Duncan P. N. Exon Smith | 9cfc75c | 2016-06-30 00:01:54 +0000 | [diff] [blame] | 277 | std::pair<uint16_t, uint16_t> DomP = TII->getExecutionDomain(*MI); |
Jakob Stoklund Olesen | 543bef6 | 2011-11-15 01:15:25 +0000 | [diff] [blame] | 278 | if (DomP.first) { |
| 279 | if (DomP.second) |
| 280 | visitSoftInstr(MI, DomP.second); |
Jakob Stoklund Olesen | 736cf46 | 2011-11-07 21:40:27 +0000 | [diff] [blame] | 281 | else |
Jakob Stoklund Olesen | 543bef6 | 2011-11-15 01:15:25 +0000 | [diff] [blame] | 282 | visitHardInstr(MI, DomP.first); |
| 283 | } |
| 284 | |
Keno Fischer | 578cf7a | 2017-01-30 23:37:03 +0000 | [diff] [blame] | 285 | return !DomP.first; |
Jakob Stoklund Olesen | 543bef6 | 2011-11-15 01:15:25 +0000 | [diff] [blame] | 286 | } |
| 287 | |
Marina Yatsina | 88f0c31 | 2016-08-11 07:32:08 +0000 | [diff] [blame] | 288 | /// \brief Helps avoid false dependencies on undef registers by updating the |
| 289 | /// machine instructions' undef operand to use a register that the instruction |
| 290 | /// is truly dependent on, or use a register with clearance higher than Pref. |
Keno Fischer | 282c624 | 2017-04-04 20:30:47 +0000 | [diff] [blame] | 291 | /// Returns true if it was able to find a true dependency, thus not requiring |
| 292 | /// a dependency breaking instruction regardless of clearance. |
| 293 | bool ExecutionDepsFix::pickBestRegisterForUndef(MachineInstr *MI, |
| 294 | unsigned OpIdx, unsigned Pref) { |
Marina Yatsina | 88f0c31 | 2016-08-11 07:32:08 +0000 | [diff] [blame] | 295 | MachineOperand &MO = MI->getOperand(OpIdx); |
| 296 | assert(MO.isUndef() && "Expected undef machine operand"); |
| 297 | |
| 298 | unsigned OriginalReg = MO.getReg(); |
| 299 | |
| 300 | // Update only undef operands that are mapped to one register. |
| 301 | if (AliasMap[OriginalReg].size() != 1) |
Keno Fischer | 282c624 | 2017-04-04 20:30:47 +0000 | [diff] [blame] | 302 | return false; |
Marina Yatsina | 88f0c31 | 2016-08-11 07:32:08 +0000 | [diff] [blame] | 303 | |
| 304 | // Get the undef operand's register class |
| 305 | const TargetRegisterClass *OpRC = |
| 306 | TII->getRegClass(MI->getDesc(), OpIdx, TRI, *MF); |
| 307 | |
| 308 | // If the instruction has a true dependency, we can hide the false depdency |
| 309 | // behind it. |
| 310 | for (MachineOperand &CurrMO : MI->operands()) { |
| 311 | if (!CurrMO.isReg() || CurrMO.isDef() || CurrMO.isUndef() || |
| 312 | !OpRC->contains(CurrMO.getReg())) |
| 313 | continue; |
| 314 | // We found a true dependency - replace the undef register with the true |
| 315 | // dependency. |
| 316 | MO.setReg(CurrMO.getReg()); |
Keno Fischer | 282c624 | 2017-04-04 20:30:47 +0000 | [diff] [blame] | 317 | return true; |
Marina Yatsina | 88f0c31 | 2016-08-11 07:32:08 +0000 | [diff] [blame] | 318 | } |
| 319 | |
| 320 | // Go over all registers in the register class and find the register with |
| 321 | // max clearance or clearance higher than Pref. |
| 322 | unsigned MaxClearance = 0; |
| 323 | unsigned MaxClearanceReg = OriginalReg; |
Marina Yatsina | 53ce3f9 | 2016-08-17 19:07:40 +0000 | [diff] [blame] | 324 | ArrayRef<MCPhysReg> Order = RegClassInfo.getOrder(OpRC); |
| 325 | for (auto Reg : Order) { |
Marina Yatsina | 4b22642 | 2016-08-17 11:40:21 +0000 | [diff] [blame] | 326 | assert(AliasMap[Reg].size() == 1 && |
| 327 | "Reg is expected to be mapped to a single index"); |
| 328 | int RCrx = *regIndices(Reg).begin(); |
| 329 | unsigned Clearance = CurInstr - LiveRegs[RCrx].Def; |
Marina Yatsina | 88f0c31 | 2016-08-11 07:32:08 +0000 | [diff] [blame] | 330 | if (Clearance <= MaxClearance) |
| 331 | continue; |
| 332 | MaxClearance = Clearance; |
Marina Yatsina | 4b22642 | 2016-08-17 11:40:21 +0000 | [diff] [blame] | 333 | MaxClearanceReg = Reg; |
Marina Yatsina | 88f0c31 | 2016-08-11 07:32:08 +0000 | [diff] [blame] | 334 | |
| 335 | if (MaxClearance > Pref) |
| 336 | break; |
| 337 | } |
| 338 | |
| 339 | // Update the operand if we found a register with better clearance. |
| 340 | if (MaxClearanceReg != OriginalReg) |
| 341 | MO.setReg(MaxClearanceReg); |
Keno Fischer | 282c624 | 2017-04-04 20:30:47 +0000 | [diff] [blame] | 342 | |
| 343 | return false; |
Marina Yatsina | 88f0c31 | 2016-08-11 07:32:08 +0000 | [diff] [blame] | 344 | } |
| 345 | |
Andrew Trick | b6d56be | 2013-10-14 22:19:03 +0000 | [diff] [blame] | 346 | /// \brief Return true to if it makes sense to break dependence on a partial def |
| 347 | /// or undef use. |
Matthias Braun | e9f8209 | 2017-03-18 05:05:40 +0000 | [diff] [blame] | 348 | bool ExecutionDepsFix::shouldBreakDependence(MachineInstr *MI, unsigned OpIdx, |
| 349 | unsigned Pref) { |
Matthias Braun | 8142efa | 2014-12-17 19:13:47 +0000 | [diff] [blame] | 350 | unsigned reg = MI->getOperand(OpIdx).getReg(); |
Matthias Braun | 046318b | 2015-03-06 18:56:20 +0000 | [diff] [blame] | 351 | for (int rx : regIndices(reg)) { |
Matthias Braun | 8142efa | 2014-12-17 19:13:47 +0000 | [diff] [blame] | 352 | unsigned Clearance = CurInstr - LiveRegs[rx].Def; |
| 353 | DEBUG(dbgs() << "Clearance: " << Clearance << ", want " << Pref); |
Andrew Trick | b6d56be | 2013-10-14 22:19:03 +0000 | [diff] [blame] | 354 | |
Matthias Braun | 8142efa | 2014-12-17 19:13:47 +0000 | [diff] [blame] | 355 | if (Pref > Clearance) { |
| 356 | DEBUG(dbgs() << ": Break dependency.\n"); |
| 357 | continue; |
| 358 | } |
Keno Fischer | 578cf7a | 2017-01-30 23:37:03 +0000 | [diff] [blame] | 359 | DEBUG(dbgs() << ": OK .\n"); |
Andrew Trick | b6d56be | 2013-10-14 22:19:03 +0000 | [diff] [blame] | 360 | return false; |
| 361 | } |
Matthias Braun | 8142efa | 2014-12-17 19:13:47 +0000 | [diff] [blame] | 362 | return true; |
Andrew Trick | b6d56be | 2013-10-14 22:19:03 +0000 | [diff] [blame] | 363 | } |
| 364 | |
Jakob Stoklund Olesen | 543bef6 | 2011-11-15 01:15:25 +0000 | [diff] [blame] | 365 | // Update def-ages for registers defined by MI. |
| 366 | // If Kill is set, also kill off DomainValues clobbered by the defs. |
Andrew Trick | b6d56be | 2013-10-14 22:19:03 +0000 | [diff] [blame] | 367 | // |
| 368 | // Also break dependencies on partial defs and undef uses. |
Matthias Braun | e9f8209 | 2017-03-18 05:05:40 +0000 | [diff] [blame] | 369 | void ExecutionDepsFix::processDefs(MachineInstr *MI, bool breakDependency, |
| 370 | bool Kill) { |
Jakob Stoklund Olesen | 543bef6 | 2011-11-15 01:15:25 +0000 | [diff] [blame] | 371 | assert(!MI->isDebugValue() && "Won't process debug values"); |
Andrew Trick | b6d56be | 2013-10-14 22:19:03 +0000 | [diff] [blame] | 372 | |
| 373 | // Break dependence on undef uses. Do this before updating LiveRegs below. |
| 374 | unsigned OpNum; |
Keno Fischer | 578cf7a | 2017-01-30 23:37:03 +0000 | [diff] [blame] | 375 | if (breakDependency) { |
| 376 | unsigned Pref = TII->getUndefRegClearance(*MI, OpNum, TRI); |
| 377 | if (Pref) { |
Keno Fischer | 282c624 | 2017-04-04 20:30:47 +0000 | [diff] [blame] | 378 | bool HadTrueDependency = pickBestRegisterForUndef(MI, OpNum, Pref); |
| 379 | // We don't need to bother trying to break a dependency if this |
| 380 | // instruction has a true dependency on that register through another |
| 381 | // operand - we'll have to wait for it to be available regardless. |
| 382 | if (!HadTrueDependency && shouldBreakDependence(MI, OpNum, Pref)) |
Keno Fischer | 578cf7a | 2017-01-30 23:37:03 +0000 | [diff] [blame] | 383 | UndefReads.push_back(std::make_pair(MI, OpNum)); |
| 384 | } |
Andrew Trick | b6d56be | 2013-10-14 22:19:03 +0000 | [diff] [blame] | 385 | } |
Jakob Stoklund Olesen | 543bef6 | 2011-11-15 01:15:25 +0000 | [diff] [blame] | 386 | const MCInstrDesc &MCID = MI->getDesc(); |
| 387 | for (unsigned i = 0, |
Evan Cheng | 7f8e563 | 2011-12-07 07:15:52 +0000 | [diff] [blame] | 388 | e = MI->isVariadic() ? MI->getNumOperands() : MCID.getNumDefs(); |
Jakob Stoklund Olesen | 543bef6 | 2011-11-15 01:15:25 +0000 | [diff] [blame] | 389 | i != e; ++i) { |
| 390 | MachineOperand &MO = MI->getOperand(i); |
| 391 | if (!MO.isReg()) |
| 392 | continue; |
Jakob Stoklund Olesen | 543bef6 | 2011-11-15 01:15:25 +0000 | [diff] [blame] | 393 | if (MO.isUse()) |
| 394 | continue; |
Matthias Braun | 046318b | 2015-03-06 18:56:20 +0000 | [diff] [blame] | 395 | for (int rx : regIndices(MO.getReg())) { |
Matthias Braun | 8142efa | 2014-12-17 19:13:47 +0000 | [diff] [blame] | 396 | // This instruction explicitly defines rx. |
| 397 | DEBUG(dbgs() << TRI->getName(RC->getRegister(rx)) << ":\t" << CurInstr |
| 398 | << '\t' << *MI); |
Jakob Stoklund Olesen | 543bef6 | 2011-11-15 01:15:25 +0000 | [diff] [blame] | 399 | |
Keno Fischer | 578cf7a | 2017-01-30 23:37:03 +0000 | [diff] [blame] | 400 | if (breakDependency) { |
| 401 | // Check clearance before partial register updates. |
| 402 | // Call breakDependence before setting LiveRegs[rx].Def. |
| 403 | unsigned Pref = TII->getPartialRegUpdateClearance(*MI, i, TRI); |
| 404 | if (Pref && shouldBreakDependence(MI, i, Pref)) |
| 405 | TII->breakPartialRegDependency(*MI, i, TRI); |
| 406 | } |
Jakob Stoklund Olesen | 543bef6 | 2011-11-15 01:15:25 +0000 | [diff] [blame] | 407 | |
Matthias Braun | 8142efa | 2014-12-17 19:13:47 +0000 | [diff] [blame] | 408 | // How many instructions since rx was last written? |
| 409 | LiveRegs[rx].Def = CurInstr; |
Andrew Trick | b6d56be | 2013-10-14 22:19:03 +0000 | [diff] [blame] | 410 | |
Matthias Braun | 8142efa | 2014-12-17 19:13:47 +0000 | [diff] [blame] | 411 | // Kill off domains redefined by generic instructions. |
| 412 | if (Kill) |
| 413 | kill(rx); |
| 414 | } |
Jakob Stoklund Olesen | 543bef6 | 2011-11-15 01:15:25 +0000 | [diff] [blame] | 415 | } |
Jakob Stoklund Olesen | 543bef6 | 2011-11-15 01:15:25 +0000 | [diff] [blame] | 416 | ++CurInstr; |
Jakob Stoklund Olesen | 736cf46 | 2011-11-07 21:40:27 +0000 | [diff] [blame] | 417 | } |
| 418 | |
Andrew Trick | b6d56be | 2013-10-14 22:19:03 +0000 | [diff] [blame] | 419 | /// \break Break false dependencies on undefined register reads. |
| 420 | /// |
| 421 | /// Walk the block backward computing precise liveness. This is expensive, so we |
| 422 | /// only do it on demand. Note that the occurrence of undefined register reads |
| 423 | /// that should be broken is very rare, but when they occur we may have many in |
| 424 | /// a single block. |
Matthias Braun | e9f8209 | 2017-03-18 05:05:40 +0000 | [diff] [blame] | 425 | void ExecutionDepsFix::processUndefReads(MachineBasicBlock *MBB) { |
Andrew Trick | b6d56be | 2013-10-14 22:19:03 +0000 | [diff] [blame] | 426 | if (UndefReads.empty()) |
| 427 | return; |
| 428 | |
| 429 | // Collect this block's live out register units. |
Matthias Braun | 0c989a8 | 2016-12-08 00:15:51 +0000 | [diff] [blame] | 430 | LiveRegSet.init(*TRI); |
Matthias Braun | 24f26e6 | 2016-05-03 00:08:46 +0000 | [diff] [blame] | 431 | // We do not need to care about pristine registers as they are just preserved |
| 432 | // but not actually used in the function. |
Matthias Braun | d1aabb2 | 2016-05-03 00:24:32 +0000 | [diff] [blame] | 433 | LiveRegSet.addLiveOutsNoPristines(*MBB); |
Juergen Ributzka | 310034e | 2013-12-14 06:52:56 +0000 | [diff] [blame] | 434 | |
Andrew Trick | b6d56be | 2013-10-14 22:19:03 +0000 | [diff] [blame] | 435 | MachineInstr *UndefMI = UndefReads.back().first; |
| 436 | unsigned OpIdx = UndefReads.back().second; |
| 437 | |
Pete Cooper | 7679afd | 2015-07-24 21:13:43 +0000 | [diff] [blame] | 438 | for (MachineInstr &I : make_range(MBB->rbegin(), MBB->rend())) { |
Andrew Trick | 60cf0ad | 2013-12-13 22:23:54 +0000 | [diff] [blame] | 439 | // Update liveness, including the current instruction's defs. |
Pete Cooper | 7679afd | 2015-07-24 21:13:43 +0000 | [diff] [blame] | 440 | LiveRegSet.stepBackward(I); |
Andrew Trick | 3a99693 | 2013-10-15 03:39:43 +0000 | [diff] [blame] | 441 | |
Pete Cooper | 7679afd | 2015-07-24 21:13:43 +0000 | [diff] [blame] | 442 | if (UndefMI == &I) { |
Juergen Ributzka | 310034e | 2013-12-14 06:52:56 +0000 | [diff] [blame] | 443 | if (!LiveRegSet.contains(UndefMI->getOperand(OpIdx).getReg())) |
Duncan P. N. Exon Smith | 9cfc75c | 2016-06-30 00:01:54 +0000 | [diff] [blame] | 444 | TII->breakPartialRegDependency(*UndefMI, OpIdx, TRI); |
Andrew Trick | b6d56be | 2013-10-14 22:19:03 +0000 | [diff] [blame] | 445 | |
| 446 | UndefReads.pop_back(); |
| 447 | if (UndefReads.empty()) |
| 448 | return; |
| 449 | |
| 450 | UndefMI = UndefReads.back().first; |
| 451 | OpIdx = UndefReads.back().second; |
| 452 | } |
Andrew Trick | b6d56be | 2013-10-14 22:19:03 +0000 | [diff] [blame] | 453 | } |
| 454 | } |
| 455 | |
Jakob Stoklund Olesen | b551aa4 | 2010-03-29 23:24:21 +0000 | [diff] [blame] | 456 | // A hard instruction only works in one domain. All input registers will be |
| 457 | // forced into that domain. |
Matthias Braun | e9f8209 | 2017-03-18 05:05:40 +0000 | [diff] [blame] | 458 | void ExecutionDepsFix::visitHardInstr(MachineInstr *mi, unsigned domain) { |
Jakob Stoklund Olesen | b551aa4 | 2010-03-29 23:24:21 +0000 | [diff] [blame] | 459 | // Collapse all uses. |
| 460 | for (unsigned i = mi->getDesc().getNumDefs(), |
| 461 | e = mi->getDesc().getNumOperands(); i != e; ++i) { |
| 462 | MachineOperand &mo = mi->getOperand(i); |
| 463 | if (!mo.isReg()) continue; |
Matthias Braun | 046318b | 2015-03-06 18:56:20 +0000 | [diff] [blame] | 464 | for (int rx : regIndices(mo.getReg())) { |
Matthias Braun | 8142efa | 2014-12-17 19:13:47 +0000 | [diff] [blame] | 465 | force(rx, domain); |
| 466 | } |
Jakob Stoklund Olesen | b551aa4 | 2010-03-29 23:24:21 +0000 | [diff] [blame] | 467 | } |
| 468 | |
| 469 | // Kill all defs and force them. |
| 470 | for (unsigned i = 0, e = mi->getDesc().getNumDefs(); i != e; ++i) { |
| 471 | MachineOperand &mo = mi->getOperand(i); |
| 472 | if (!mo.isReg()) continue; |
Matthias Braun | 046318b | 2015-03-06 18:56:20 +0000 | [diff] [blame] | 473 | for (int rx : regIndices(mo.getReg())) { |
Matthias Braun | 8142efa | 2014-12-17 19:13:47 +0000 | [diff] [blame] | 474 | kill(rx); |
| 475 | force(rx, domain); |
| 476 | } |
Jakob Stoklund Olesen | b551aa4 | 2010-03-29 23:24:21 +0000 | [diff] [blame] | 477 | } |
| 478 | } |
| 479 | |
| 480 | // A soft instruction can be changed to work in other domains given by mask. |
Matthias Braun | e9f8209 | 2017-03-18 05:05:40 +0000 | [diff] [blame] | 481 | void ExecutionDepsFix::visitSoftInstr(MachineInstr *mi, unsigned mask) { |
Jakob Stoklund Olesen | d03ac95 | 2010-04-04 21:27:26 +0000 | [diff] [blame] | 482 | // Bitmask of available domains for this instruction after taking collapsed |
| 483 | // operands into account. |
| 484 | unsigned available = mask; |
| 485 | |
Jakob Stoklund Olesen | b551aa4 | 2010-03-29 23:24:21 +0000 | [diff] [blame] | 486 | // Scan the explicit use operands for incoming domains. |
Jakob Stoklund Olesen | b551aa4 | 2010-03-29 23:24:21 +0000 | [diff] [blame] | 487 | SmallVector<int, 4> used; |
Jakob Stoklund Olesen | 3b9af40 | 2010-03-30 20:04:01 +0000 | [diff] [blame] | 488 | if (LiveRegs) |
| 489 | for (unsigned i = mi->getDesc().getNumDefs(), |
| 490 | e = mi->getDesc().getNumOperands(); i != e; ++i) { |
Chris Lattner | 503a0ef | 2010-03-31 20:32:51 +0000 | [diff] [blame] | 491 | MachineOperand &mo = mi->getOperand(i); |
| 492 | if (!mo.isReg()) continue; |
Matthias Braun | 046318b | 2015-03-06 18:56:20 +0000 | [diff] [blame] | 493 | for (int rx : regIndices(mo.getReg())) { |
Matthias Braun | 8142efa | 2014-12-17 19:13:47 +0000 | [diff] [blame] | 494 | DomainValue *dv = LiveRegs[rx].Value; |
| 495 | if (dv == nullptr) |
| 496 | continue; |
Jakob Stoklund Olesen | d03ac95 | 2010-04-04 21:27:26 +0000 | [diff] [blame] | 497 | // Bitmask of domains that dv and available have in common. |
| 498 | unsigned common = dv->getCommonDomains(available); |
Chris Lattner | 503a0ef | 2010-03-31 20:32:51 +0000 | [diff] [blame] | 499 | // Is it possible to use this collapsed register for free? |
Jakob Stoklund Olesen | d03ac95 | 2010-04-04 21:27:26 +0000 | [diff] [blame] | 500 | if (dv->isCollapsed()) { |
| 501 | // Restrict available domains to the ones in common with the operand. |
Andrew Trick | b6d56be | 2013-10-14 22:19:03 +0000 | [diff] [blame] | 502 | // If there are no common domains, we must pay the cross-domain |
Jakob Stoklund Olesen | d03ac95 | 2010-04-04 21:27:26 +0000 | [diff] [blame] | 503 | // penalty for this operand. |
| 504 | if (common) available = common; |
| 505 | } else if (common) |
| 506 | // Open DomainValue is compatible, save it for merging. |
Chris Lattner | 503a0ef | 2010-03-31 20:32:51 +0000 | [diff] [blame] | 507 | used.push_back(rx); |
| 508 | else |
Jakob Stoklund Olesen | d03ac95 | 2010-04-04 21:27:26 +0000 | [diff] [blame] | 509 | // Open DomainValue is not compatible with instruction. It is useless |
| 510 | // now. |
Jakob Stoklund Olesen | 9e338bb | 2011-11-08 21:57:47 +0000 | [diff] [blame] | 511 | kill(rx); |
Chris Lattner | 503a0ef | 2010-03-31 20:32:51 +0000 | [diff] [blame] | 512 | } |
Jakob Stoklund Olesen | b551aa4 | 2010-03-29 23:24:21 +0000 | [diff] [blame] | 513 | } |
Jakob Stoklund Olesen | b551aa4 | 2010-03-29 23:24:21 +0000 | [diff] [blame] | 514 | |
| 515 | // If the collapsed operands force a single domain, propagate the collapse. |
Jakob Stoklund Olesen | d03ac95 | 2010-04-04 21:27:26 +0000 | [diff] [blame] | 516 | if (isPowerOf2_32(available)) { |
Michael J. Spencer | df1ecbd7 | 2013-05-24 22:23:49 +0000 | [diff] [blame] | 517 | unsigned domain = countTrailingZeros(available); |
Duncan P. N. Exon Smith | 9cfc75c | 2016-06-30 00:01:54 +0000 | [diff] [blame] | 518 | TII->setExecutionDomain(*mi, domain); |
Jakob Stoklund Olesen | b551aa4 | 2010-03-29 23:24:21 +0000 | [diff] [blame] | 519 | visitHardInstr(mi, domain); |
| 520 | return; |
| 521 | } |
| 522 | |
Jakob Stoklund Olesen | d03ac95 | 2010-04-04 21:27:26 +0000 | [diff] [blame] | 523 | // Kill off any remaining uses that don't match available, and build a list of |
| 524 | // incoming DomainValues that we want to merge. |
Craig Topper | 3b8aca2 | 2017-02-25 18:12:25 +0000 | [diff] [blame] | 525 | SmallVector<const LiveReg *, 4> Regs; |
Craig Topper | c446b1f | 2017-02-24 06:38:24 +0000 | [diff] [blame] | 526 | for (int rx : used) { |
Michael Ilseman | addddc4 | 2014-12-15 18:48:43 +0000 | [diff] [blame] | 527 | assert(LiveRegs && "no space allocated for live registers"); |
Jakob Stoklund Olesen | 543bef6 | 2011-11-15 01:15:25 +0000 | [diff] [blame] | 528 | const LiveReg &LR = LiveRegs[rx]; |
Jakob Stoklund Olesen | 3b9af40 | 2010-03-30 20:04:01 +0000 | [diff] [blame] | 529 | // This useless DomainValue could have been missed above. |
Jakob Stoklund Olesen | 543bef6 | 2011-11-15 01:15:25 +0000 | [diff] [blame] | 530 | if (!LR.Value->getCommonDomains(available)) { |
| 531 | kill(rx); |
Jakob Stoklund Olesen | b551aa4 | 2010-03-29 23:24:21 +0000 | [diff] [blame] | 532 | continue; |
| 533 | } |
Jakob Stoklund Olesen | 543bef6 | 2011-11-15 01:15:25 +0000 | [diff] [blame] | 534 | // Sorted insertion. |
Craig Topper | 3b8aca2 | 2017-02-25 18:12:25 +0000 | [diff] [blame] | 535 | auto I = std::upper_bound(Regs.begin(), Regs.end(), &LR, |
| 536 | [](const LiveReg *LHS, const LiveReg *RHS) { |
| 537 | return LHS->Def < RHS->Def; |
| 538 | }); |
| 539 | Regs.insert(I, &LR); |
Jakob Stoklund Olesen | b551aa4 | 2010-03-29 23:24:21 +0000 | [diff] [blame] | 540 | } |
| 541 | |
Jakob Stoklund Olesen | d03ac95 | 2010-04-04 21:27:26 +0000 | [diff] [blame] | 542 | // doms are now sorted in order of appearance. Try to merge them all, giving |
| 543 | // priority to the latest ones. |
Craig Topper | c0196b1 | 2014-04-14 00:51:57 +0000 | [diff] [blame] | 544 | DomainValue *dv = nullptr; |
Jakob Stoklund Olesen | 543bef6 | 2011-11-15 01:15:25 +0000 | [diff] [blame] | 545 | while (!Regs.empty()) { |
Chris Lattner | 503a0ef | 2010-03-31 20:32:51 +0000 | [diff] [blame] | 546 | if (!dv) { |
Craig Topper | 3b8aca2 | 2017-02-25 18:12:25 +0000 | [diff] [blame] | 547 | dv = Regs.pop_back_val()->Value; |
Jakob Stoklund Olesen | 0284541 | 2011-11-23 04:03:08 +0000 | [diff] [blame] | 548 | // Force the first dv to match the current instruction. |
| 549 | dv->AvailableDomains = dv->getCommonDomains(available); |
| 550 | assert(dv->AvailableDomains && "Domain should have been filtered"); |
Chris Lattner | 503a0ef | 2010-03-31 20:32:51 +0000 | [diff] [blame] | 551 | continue; |
| 552 | } |
Jakob Stoklund Olesen | 42caaa4 | 2010-04-04 18:00:21 +0000 | [diff] [blame] | 553 | |
Craig Topper | 3b8aca2 | 2017-02-25 18:12:25 +0000 | [diff] [blame] | 554 | DomainValue *Latest = Regs.pop_back_val()->Value; |
Jakob Stoklund Olesen | 543bef6 | 2011-11-15 01:15:25 +0000 | [diff] [blame] | 555 | // Skip already merged values. |
| 556 | if (Latest == dv || Latest->Next) |
| 557 | continue; |
| 558 | if (merge(dv, Latest)) |
| 559 | continue; |
Jakob Stoklund Olesen | 42caaa4 | 2010-04-04 18:00:21 +0000 | [diff] [blame] | 560 | |
Jakob Stoklund Olesen | d03ac95 | 2010-04-04 21:27:26 +0000 | [diff] [blame] | 561 | // If latest didn't merge, it is useless now. Kill all registers using it. |
Michael Ilseman | addddc4 | 2014-12-15 18:48:43 +0000 | [diff] [blame] | 562 | for (int i : used) { |
| 563 | assert(LiveRegs && "no space allocated for live registers"); |
| 564 | if (LiveRegs[i].Value == Latest) |
| 565 | kill(i); |
| 566 | } |
Jakob Stoklund Olesen | b551aa4 | 2010-03-29 23:24:21 +0000 | [diff] [blame] | 567 | } |
| 568 | |
| 569 | // dv is the DomainValue we are going to use for this instruction. |
Jakob Stoklund Olesen | 0284541 | 2011-11-23 04:03:08 +0000 | [diff] [blame] | 570 | if (!dv) { |
Jakob Stoklund Olesen | 9e338bb | 2011-11-08 21:57:47 +0000 | [diff] [blame] | 571 | dv = alloc(); |
Jakob Stoklund Olesen | 0284541 | 2011-11-23 04:03:08 +0000 | [diff] [blame] | 572 | dv->AvailableDomains = available; |
| 573 | } |
Jakob Stoklund Olesen | b551aa4 | 2010-03-29 23:24:21 +0000 | [diff] [blame] | 574 | dv->Instrs.push_back(mi); |
| 575 | |
Silviu Baranga | 3c31499 | 2012-10-03 08:29:36 +0000 | [diff] [blame] | 576 | // Finally set all defs and non-collapsed uses to dv. We must iterate through |
| 577 | // all the operators, including imp-def ones. |
| 578 | for (MachineInstr::mop_iterator ii = mi->operands_begin(), |
| 579 | ee = mi->operands_end(); |
| 580 | ii != ee; ++ii) { |
| 581 | MachineOperand &mo = *ii; |
Jakob Stoklund Olesen | b551aa4 | 2010-03-29 23:24:21 +0000 | [diff] [blame] | 582 | if (!mo.isReg()) continue; |
Matthias Braun | 046318b | 2015-03-06 18:56:20 +0000 | [diff] [blame] | 583 | for (int rx : regIndices(mo.getReg())) { |
Matthias Braun | 8142efa | 2014-12-17 19:13:47 +0000 | [diff] [blame] | 584 | if (!LiveRegs[rx].Value || (mo.isDef() && LiveRegs[rx].Value != dv)) { |
| 585 | kill(rx); |
| 586 | setLiveReg(rx, dv); |
| 587 | } |
Jakob Stoklund Olesen | b551aa4 | 2010-03-29 23:24:21 +0000 | [diff] [blame] | 588 | } |
| 589 | } |
| 590 | } |
| 591 | |
Matthias Braun | e9f8209 | 2017-03-18 05:05:40 +0000 | [diff] [blame] | 592 | void ExecutionDepsFix::processBasicBlock(MachineBasicBlock *MBB, |
| 593 | bool PrimaryPass) { |
Keno Fischer | 578cf7a | 2017-01-30 23:37:03 +0000 | [diff] [blame] | 594 | enterBasicBlock(MBB); |
| 595 | // If this block is not done, it makes little sense to make any decisions |
| 596 | // based on clearance information. We need to make a second pass anyway, |
| 597 | // and by then we'll have better information, so we can avoid doing the work |
| 598 | // to try and break dependencies now. |
| 599 | bool breakDependency = isBlockDone(MBB); |
| 600 | for (MachineInstr &MI : *MBB) { |
| 601 | if (!MI.isDebugValue()) { |
| 602 | bool Kill = false; |
| 603 | if (PrimaryPass) |
| 604 | Kill = visitInstr(&MI); |
| 605 | processDefs(&MI, breakDependency, Kill); |
| 606 | } |
| 607 | } |
| 608 | if (breakDependency) |
| 609 | processUndefReads(MBB); |
| 610 | leaveBasicBlock(MBB); |
| 611 | } |
| 612 | |
Matthias Braun | e9f8209 | 2017-03-18 05:05:40 +0000 | [diff] [blame] | 613 | bool ExecutionDepsFix::isBlockDone(MachineBasicBlock *MBB) { |
Keno Fischer | 578cf7a | 2017-01-30 23:37:03 +0000 | [diff] [blame] | 614 | return MBBInfos[MBB].PrimaryCompleted && |
| 615 | MBBInfos[MBB].IncomingCompleted == MBBInfos[MBB].PrimaryIncoming && |
| 616 | MBBInfos[MBB].IncomingProcessed == MBB->pred_size(); |
| 617 | } |
| 618 | |
Matthias Braun | e9f8209 | 2017-03-18 05:05:40 +0000 | [diff] [blame] | 619 | bool ExecutionDepsFix::runOnMachineFunction(MachineFunction &mf) { |
Andrew Kaylor | 50271f7 | 2016-05-03 22:32:30 +0000 | [diff] [blame] | 620 | if (skipFunction(*mf.getFunction())) |
| 621 | return false; |
Jakob Stoklund Olesen | 49e121d | 2010-03-25 17:25:00 +0000 | [diff] [blame] | 622 | MF = &mf; |
Eric Christopher | fc6de42 | 2014-08-05 02:39:49 +0000 | [diff] [blame] | 623 | TII = MF->getSubtarget().getInstrInfo(); |
| 624 | TRI = MF->getSubtarget().getRegisterInfo(); |
Marina Yatsina | 53ce3f9 | 2016-08-17 19:07:40 +0000 | [diff] [blame] | 625 | RegClassInfo.runOnMachineFunction(mf); |
Craig Topper | c0196b1 | 2014-04-14 00:51:57 +0000 | [diff] [blame] | 626 | LiveRegs = nullptr; |
Jakob Stoklund Olesen | 30c8112 | 2011-09-27 23:50:46 +0000 | [diff] [blame] | 627 | assert(NumRegs == RC->getNumRegs() && "Bad regclass"); |
Jakob Stoklund Olesen | 49e121d | 2010-03-25 17:25:00 +0000 | [diff] [blame] | 628 | |
Jakob Stoklund Olesen | 543bef6 | 2011-11-15 01:15:25 +0000 | [diff] [blame] | 629 | DEBUG(dbgs() << "********** FIX EXECUTION DEPENDENCIES: " |
Craig Topper | cf0444b | 2014-11-17 05:50:14 +0000 | [diff] [blame] | 630 | << TRI->getRegClassName(RC) << " **********\n"); |
Jakob Stoklund Olesen | 543bef6 | 2011-11-15 01:15:25 +0000 | [diff] [blame] | 631 | |
Jakob Stoklund Olesen | bd5109f | 2011-09-28 00:01:56 +0000 | [diff] [blame] | 632 | // If no relevant registers are used in the function, we can skip it |
| 633 | // completely. |
Jakob Stoklund Olesen | b551aa4 | 2010-03-29 23:24:21 +0000 | [diff] [blame] | 634 | bool anyregs = false; |
Matthias Braun | 9912bb8 | 2015-07-14 17:52:07 +0000 | [diff] [blame] | 635 | const MachineRegisterInfo &MRI = mf.getRegInfo(); |
Matthias Braun | d55bcf2 | 2015-08-18 18:54:27 +0000 | [diff] [blame] | 636 | for (unsigned Reg : *RC) { |
| 637 | if (MRI.isPhysRegUsed(Reg)) { |
| 638 | anyregs = true; |
| 639 | break; |
| 640 | } |
| 641 | } |
Jakob Stoklund Olesen | b551aa4 | 2010-03-29 23:24:21 +0000 | [diff] [blame] | 642 | if (!anyregs) return false; |
Jakob Stoklund Olesen | 49e121d | 2010-03-25 17:25:00 +0000 | [diff] [blame] | 643 | |
Jakob Stoklund Olesen | 30c8112 | 2011-09-27 23:50:46 +0000 | [diff] [blame] | 644 | // Initialize the AliasMap on the first use. |
| 645 | if (AliasMap.empty()) { |
Matthias Braun | 8142efa | 2014-12-17 19:13:47 +0000 | [diff] [blame] | 646 | // Given a PhysReg, AliasMap[PhysReg] returns a list of indices into RC and |
| 647 | // therefore the LiveRegs array. |
| 648 | AliasMap.resize(TRI->getNumRegs()); |
Jakob Stoklund Olesen | 30c8112 | 2011-09-27 23:50:46 +0000 | [diff] [blame] | 649 | for (unsigned i = 0, e = RC->getNumRegs(); i != e; ++i) |
Jakob Stoklund Olesen | 54038d7 | 2012-06-01 23:28:30 +0000 | [diff] [blame] | 650 | for (MCRegAliasIterator AI(RC->getRegister(i), TRI, true); |
| 651 | AI.isValid(); ++AI) |
Matthias Braun | 8142efa | 2014-12-17 19:13:47 +0000 | [diff] [blame] | 652 | AliasMap[*AI].push_back(i); |
Jakob Stoklund Olesen | 30c8112 | 2011-09-27 23:50:46 +0000 | [diff] [blame] | 653 | } |
| 654 | |
Keno Fischer | 578cf7a | 2017-01-30 23:37:03 +0000 | [diff] [blame] | 655 | // Initialize the MMBInfos |
| 656 | for (auto &MBB : mf) { |
| 657 | MBBInfo InitialInfo; |
| 658 | MBBInfos.insert(std::make_pair(&MBB, InitialInfo)); |
| 659 | } |
| 660 | |
| 661 | /* |
| 662 | * We want to visit every instruction in every basic block in order to update |
| 663 | * it's execution domain or break any false dependencies. However, for the |
| 664 | * dependency breaking, we need to know clearances from all predecessors |
| 665 | * (including any backedges). One way to do so would be to do two complete |
| 666 | * passes over all basic blocks/instructions, the first for recording |
| 667 | * clearances, the second to break the dependencies. However, for functions |
| 668 | * without backedges, or functions with a lot of straight-line code, and |
| 669 | * a small loop, that would be a lot of unnecessary work (since only the |
| 670 | * BBs that are part of the loop require two passes). As an example, |
| 671 | * consider the following loop. |
| 672 | * |
| 673 | * |
| 674 | * PH -> A -> B (xmm<Undef> -> xmm<Def>) -> C -> D -> EXIT |
| 675 | * ^ | |
| 676 | * +----------------------------------+ |
| 677 | * |
| 678 | * The iteration order is as follows: |
| 679 | * Naive: PH A B C D A' B' C' D' |
| 680 | * Optimized: PH A B C A' B' C' D |
| 681 | * |
| 682 | * Note that we avoid processing D twice, because we can entirely process |
| 683 | * the predecessors before getting to D. We call a block that is ready |
| 684 | * for its second round of processing `done` (isBlockDone). Once we finish |
| 685 | * processing some block, we update the counters in MBBInfos and re-process |
| 686 | * any successors that are now done. |
| 687 | */ |
| 688 | |
Duncan P. N. Exon Smith | 8f11e1a | 2015-10-09 16:54:49 +0000 | [diff] [blame] | 689 | MachineBasicBlock *Entry = &*MF->begin(); |
Jakob Stoklund Olesen | 68e197e | 2011-11-07 21:59:29 +0000 | [diff] [blame] | 690 | ReversePostOrderTraversal<MachineBasicBlock*> RPOT(Entry); |
Keno Fischer | 4ecee77 | 2017-04-05 17:42:56 +0000 | [diff] [blame] | 691 | SmallVector<MachineBasicBlock *, 4> Workqueue; |
Jakob Stoklund Olesen | 68e197e | 2011-11-07 21:59:29 +0000 | [diff] [blame] | 692 | for (ReversePostOrderTraversal<MachineBasicBlock*>::rpo_iterator |
| 693 | MBBI = RPOT.begin(), MBBE = RPOT.end(); MBBI != MBBE; ++MBBI) { |
| 694 | MachineBasicBlock *MBB = *MBBI; |
Keno Fischer | 578cf7a | 2017-01-30 23:37:03 +0000 | [diff] [blame] | 695 | // N.B: IncomingProcessed and IncomingCompleted were already updated while |
| 696 | // processing this block's predecessors. |
| 697 | MBBInfos[MBB].PrimaryCompleted = true; |
| 698 | MBBInfos[MBB].PrimaryIncoming = MBBInfos[MBB].IncomingProcessed; |
Keno Fischer | 4ecee77 | 2017-04-05 17:42:56 +0000 | [diff] [blame] | 699 | bool Primary = true; |
| 700 | Workqueue.push_back(MBB); |
| 701 | while (!Workqueue.empty()) { |
| 702 | MachineBasicBlock *ActiveMBB = &*Workqueue.back(); |
| 703 | Workqueue.pop_back(); |
| 704 | processBasicBlock(ActiveMBB, Primary); |
| 705 | bool Done = isBlockDone(ActiveMBB); |
| 706 | for (auto *Succ : ActiveMBB->successors()) { |
| 707 | if (!isBlockDone(Succ)) { |
| 708 | if (Primary) { |
| 709 | MBBInfos[Succ].IncomingProcessed++; |
| 710 | } |
| 711 | if (Done) { |
| 712 | MBBInfos[Succ].IncomingCompleted++; |
| 713 | } |
| 714 | if (isBlockDone(Succ)) { |
| 715 | Workqueue.push_back(Succ); |
| 716 | } |
| 717 | } |
| 718 | } |
| 719 | Primary = false; |
| 720 | } |
Jakob Stoklund Olesen | 49e121d | 2010-03-25 17:25:00 +0000 | [diff] [blame] | 721 | } |
Jakob Stoklund Olesen | b551aa4 | 2010-03-29 23:24:21 +0000 | [diff] [blame] | 722 | |
Keno Fischer | 578cf7a | 2017-01-30 23:37:03 +0000 | [diff] [blame] | 723 | // We need to go through again and finalize any blocks that are not done yet. |
| 724 | // This is possible if blocks have dead predecessors, so we didn't visit them |
| 725 | // above. |
| 726 | for (ReversePostOrderTraversal<MachineBasicBlock *>::rpo_iterator |
| 727 | MBBI = RPOT.begin(), |
| 728 | MBBE = RPOT.end(); |
| 729 | MBBI != MBBE; ++MBBI) { |
| 730 | MachineBasicBlock *MBB = *MBBI; |
| 731 | if (!isBlockDone(MBB)) { |
| 732 | processBasicBlock(MBB, false); |
| 733 | // Don't update successors here. We'll get to them anyway through this |
| 734 | // loop. |
| 735 | } |
Jakob Stoklund Olesen | 3dc89c9 | 2011-11-09 01:06:56 +0000 | [diff] [blame] | 736 | } |
| 737 | |
Jakob Stoklund Olesen | a70e941 | 2011-11-07 23:08:21 +0000 | [diff] [blame] | 738 | // Clear the LiveOuts vectors and collapse any remaining DomainValues. |
| 739 | for (ReversePostOrderTraversal<MachineBasicBlock*>::rpo_iterator |
| 740 | MBBI = RPOT.begin(), MBBE = RPOT.end(); MBBI != MBBE; ++MBBI) { |
Keno Fischer | 578cf7a | 2017-01-30 23:37:03 +0000 | [diff] [blame] | 741 | auto FI = MBBInfos.find(*MBBI); |
| 742 | if (FI == MBBInfos.end() || !FI->second.OutRegs) |
Jakob Stoklund Olesen | a70e941 | 2011-11-07 23:08:21 +0000 | [diff] [blame] | 743 | continue; |
Jakob Stoklund Olesen | a70e941 | 2011-11-07 23:08:21 +0000 | [diff] [blame] | 744 | for (unsigned i = 0, e = NumRegs; i != e; ++i) |
Keno Fischer | 578cf7a | 2017-01-30 23:37:03 +0000 | [diff] [blame] | 745 | if (FI->second.OutRegs[i].Value) |
| 746 | release(FI->second.OutRegs[i].Value); |
| 747 | delete[] FI->second.OutRegs; |
Jakob Stoklund Olesen | a70e941 | 2011-11-07 23:08:21 +0000 | [diff] [blame] | 748 | } |
Keno Fischer | 578cf7a | 2017-01-30 23:37:03 +0000 | [diff] [blame] | 749 | MBBInfos.clear(); |
Andrew Trick | b6d56be | 2013-10-14 22:19:03 +0000 | [diff] [blame] | 750 | UndefReads.clear(); |
Jakob Stoklund Olesen | 42caaa4 | 2010-04-04 18:00:21 +0000 | [diff] [blame] | 751 | Avail.clear(); |
| 752 | Allocator.DestroyAll(); |
Jakob Stoklund Olesen | b551aa4 | 2010-03-29 23:24:21 +0000 | [diff] [blame] | 753 | |
Jakob Stoklund Olesen | 49e121d | 2010-03-25 17:25:00 +0000 | [diff] [blame] | 754 | return false; |
| 755 | } |