blob: d094411116d4ca432a2c9fec5de4b164508cf486 [file] [log] [blame]
Jakob Stoklund Olesen56ab8752011-09-28 00:01:56 +00001//===- ExecutionDepsFix.cpp - Fix execution dependecy issues ----*- C++ -*-===//
Jakob Stoklund Olesen352aa502010-03-25 17:25:00 +00002//
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//===----------------------------------------------------------------------===//
9//
Jakob Stoklund Olesen56ab8752011-09-28 00:01:56 +000010// This file contains the execution dependency fix pass.
Jakob Stoklund Olesen352aa502010-03-25 17:25:00 +000011//
Jakob Stoklund Olesen56ab8752011-09-28 00:01:56 +000012// Some X86 SSE instructions like mov, and, or, xor are available in different
Jakob Stoklund Olesen352aa502010-03-25 17:25:00 +000013// variants for different operand types. These variant instructions are
14// equivalent, but on Nehalem and newer cpus there is extra latency
Jakob Stoklund Olesen56ab8752011-09-28 00:01:56 +000015// transferring data between integer and floating point domains. ARM cores
16// have similar issues when they are configured with both VFP and NEON
17// pipelines.
Jakob Stoklund Olesen352aa502010-03-25 17:25:00 +000018//
19// This pass changes the variant instructions to minimize domain crossings.
20//
21//===----------------------------------------------------------------------===//
22
Jakob Stoklund Olesendf4b35e2011-09-27 23:50:46 +000023#define DEBUG_TYPE "execution-fix"
Jakob Stoklund Olesen352aa502010-03-25 17:25:00 +000024#include "llvm/CodeGen/MachineFunctionPass.h"
25#include "llvm/CodeGen/MachineRegisterInfo.h"
Jakob Stoklund Olesendf4b35e2011-09-27 23:50:46 +000026#include "llvm/CodeGen/Passes.h"
27#include "llvm/Target/TargetInstrInfo.h"
28#include "llvm/Target/TargetMachine.h"
Jakob Stoklund Olesena59ce032011-11-07 21:59:29 +000029#include "llvm/ADT/PostOrderIterator.h"
Jakob Stoklund Olesenbbef8152010-04-04 18:00:21 +000030#include "llvm/Support/Allocator.h"
Jakob Stoklund Olesen352aa502010-03-25 17:25:00 +000031#include "llvm/Support/Debug.h"
32#include "llvm/Support/raw_ostream.h"
Jakob Stoklund Olesen352aa502010-03-25 17:25:00 +000033using namespace llvm;
34
Chris Lattner563d83f2010-03-31 20:32:51 +000035/// A DomainValue is a bit like LiveIntervals' ValNo, but it also keeps track
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +000036/// of execution domains.
37///
38/// An open DomainValue represents a set of instructions that can still switch
39/// execution domain. Multiple registers may refer to the same open
40/// DomainValue - they will eventually be collapsed to the same execution
41/// domain.
42///
43/// A collapsed DomainValue represents a single register that has been forced
44/// into one of more execution domains. There is a separate collapsed
45/// DomainValue for each register, but it may contain multiple execution
46/// domains. A register value is initially created in a single execution
47/// domain, but if we were forced to pay the penalty of a domain crossing, we
Jakob Stoklund Olesen2947f732011-11-15 01:15:25 +000048/// keep track of the fact that the register is now available in multiple
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +000049/// domains.
Jakob Stoklund Olesenbbef8152010-04-04 18:00:21 +000050namespace {
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +000051struct DomainValue {
52 // Basic reference counting.
53 unsigned Refs;
54
Jakob Stoklund Olesene0103f02010-04-04 21:27:26 +000055 // Bitmask of available domains. For an open DomainValue, it is the still
56 // possible domains for collapsing. For a collapsed DomainValue it is the
57 // domains where the register is available for free.
58 unsigned AvailableDomains;
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +000059
Jakob Stoklund Olesendbc372f2011-11-09 00:06:18 +000060 // Pointer to the next DomainValue in a chain. When two DomainValues are
61 // merged, Victim.Next is set to point to Victor, so old DomainValue
62 // references can be updated by folowing the chain.
63 DomainValue *Next;
64
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +000065 // Twiddleable instructions using or defining these registers.
66 SmallVector<MachineInstr*, 8> Instrs;
67
Jakob Stoklund Olesene0103f02010-04-04 21:27:26 +000068 // A collapsed DomainValue has no instructions to twiddle - it simply keeps
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +000069 // track of the domains where the registers are already available.
Jakob Stoklund Olesene0103f02010-04-04 21:27:26 +000070 bool isCollapsed() const { return Instrs.empty(); }
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +000071
Jakob Stoklund Olesene0103f02010-04-04 21:27:26 +000072 // Is domain available?
73 bool hasDomain(unsigned domain) const {
74 return AvailableDomains & (1u << domain);
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +000075 }
76
Jakob Stoklund Olesen1a5d2a82010-03-30 20:04:01 +000077 // Mark domain as available.
Jakob Stoklund Olesene0103f02010-04-04 21:27:26 +000078 void addDomain(unsigned domain) {
79 AvailableDomains |= 1u << domain;
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +000080 }
81
Jakob Stoklund Olesene0103f02010-04-04 21:27:26 +000082 // Restrict to a single domain available.
83 void setSingleDomain(unsigned domain) {
84 AvailableDomains = 1u << domain;
85 }
86
87 // Return bitmask of domains that are available and in mask.
88 unsigned getCommonDomains(unsigned mask) const {
89 return AvailableDomains & mask;
90 }
91
92 // First domain available.
93 unsigned getFirstDomain() const {
94 return CountTrailingZeros_32(AvailableDomains);
Jakob Stoklund Olesen1a5d2a82010-03-30 20:04:01 +000095 }
96
Jakob Stoklund Olesen737e9a22011-11-08 23:26:00 +000097 DomainValue() : Refs(0) { clear(); }
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +000098
Jakob Stoklund Olesendbc372f2011-11-09 00:06:18 +000099 // Clear this DomainValue and point to next which has all its data.
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +0000100 void clear() {
Jakob Stoklund Olesen2947f732011-11-15 01:15:25 +0000101 AvailableDomains = 0;
Jakob Stoklund Olesendbc372f2011-11-09 00:06:18 +0000102 Next = 0;
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +0000103 Instrs.clear();
104 }
105};
Jakob Stoklund Olesenbbef8152010-04-04 18:00:21 +0000106}
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +0000107
Jakob Stoklund Olesenbbef8152010-04-04 18:00:21 +0000108namespace {
Jakob Stoklund Olesen2947f732011-11-15 01:15:25 +0000109/// LiveReg - Information about a live register.
110struct LiveReg {
111 /// Value currently in this register, or NULL when no value is being tracked.
112 /// This counts as a DomainValue reference.
113 DomainValue *Value;
114
115 /// Instruction that defined this register, relative to the beginning of the
116 /// current basic block. When a LiveReg is used to represent a live-out
117 /// register, this value is relative to the end of the basic block, so it
118 /// will be a negative number.
119 int Def;
120};
121} // anonynous namespace
122
123namespace {
Jakob Stoklund Olesen56ab8752011-09-28 00:01:56 +0000124class ExeDepsFix : public MachineFunctionPass {
Jakob Stoklund Olesen352aa502010-03-25 17:25:00 +0000125 static char ID;
Jakob Stoklund Olesenbbef8152010-04-04 18:00:21 +0000126 SpecificBumpPtrAllocator<DomainValue> Allocator;
127 SmallVector<DomainValue*,16> Avail;
Jakob Stoklund Olesen352aa502010-03-25 17:25:00 +0000128
Jakob Stoklund Olesendf4b35e2011-09-27 23:50:46 +0000129 const TargetRegisterClass *const RC;
Jakob Stoklund Olesen352aa502010-03-25 17:25:00 +0000130 MachineFunction *MF;
Jakob Stoklund Olesendf4b35e2011-09-27 23:50:46 +0000131 const TargetInstrInfo *TII;
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +0000132 const TargetRegisterInfo *TRI;
Jakob Stoklund Olesendf4b35e2011-09-27 23:50:46 +0000133 std::vector<int> AliasMap;
134 const unsigned NumRegs;
Jakob Stoklund Olesen2947f732011-11-15 01:15:25 +0000135 LiveReg *LiveRegs;
136 typedef DenseMap<MachineBasicBlock*, LiveReg*> LiveOutMap;
Jakob Stoklund Olesen1a5d2a82010-03-30 20:04:01 +0000137 LiveOutMap LiveOuts;
Jakob Stoklund Olesen2947f732011-11-15 01:15:25 +0000138
139 /// Current instruction number.
140 /// The first instruction in each basic block is 0.
141 int CurInstr;
142
143 /// True when the current block has a predecessor that hasn't been visited
144 /// yet.
145 bool SeenUnknownBackEdge;
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +0000146
Jakob Stoklund Olesen352aa502010-03-25 17:25:00 +0000147public:
Jakob Stoklund Olesen56ab8752011-09-28 00:01:56 +0000148 ExeDepsFix(const TargetRegisterClass *rc)
Jakob Stoklund Olesendf4b35e2011-09-27 23:50:46 +0000149 : MachineFunctionPass(ID), RC(rc), NumRegs(RC->getNumRegs()) {}
Jakob Stoklund Olesen352aa502010-03-25 17:25:00 +0000150
151 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
152 AU.setPreservesAll();
153 MachineFunctionPass::getAnalysisUsage(AU);
154 }
155
156 virtual bool runOnMachineFunction(MachineFunction &MF);
157
158 virtual const char *getPassName() const {
Jakob Stoklund Olesencd7dcad2011-11-07 21:23:39 +0000159 return "Execution dependency fix";
Jakob Stoklund Olesen352aa502010-03-25 17:25:00 +0000160 }
161
162private:
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +0000163 // Register mapping.
Jakob Stoklund Olesen6bcb9a72011-11-08 21:57:47 +0000164 int regIndex(unsigned Reg);
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +0000165
Jakob Stoklund Olesenbbef8152010-04-04 18:00:21 +0000166 // DomainValue allocation.
Jakob Stoklund Olesen6bcb9a72011-11-08 21:57:47 +0000167 DomainValue *alloc(int domain = -1);
Jakob Stoklund Olesendbc372f2011-11-09 00:06:18 +0000168 DomainValue *retain(DomainValue *DV) {
169 if (DV) ++DV->Refs;
170 return DV;
171 }
Jakob Stoklund Olesen35e93242011-11-08 21:57:44 +0000172 void release(DomainValue*);
Jakob Stoklund Olesendbc372f2011-11-09 00:06:18 +0000173 DomainValue *resolve(DomainValue*&);
Jakob Stoklund Olesenbbef8152010-04-04 18:00:21 +0000174
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +0000175 // LiveRegs manipulations.
Jakob Stoklund Olesen6bcb9a72011-11-08 21:57:47 +0000176 void setLiveReg(int rx, DomainValue *DV);
177 void kill(int rx);
178 void force(int rx, unsigned domain);
179 void collapse(DomainValue *dv, unsigned domain);
180 bool merge(DomainValue *A, DomainValue *B);
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +0000181
Jakob Stoklund Olesen2947f732011-11-15 01:15:25 +0000182 void enterBasicBlock(MachineBasicBlock*);
Jakob Stoklund Olesen25265d02011-11-07 21:40:27 +0000183 void leaveBasicBlock(MachineBasicBlock*);
184 void visitInstr(MachineInstr*);
Jakob Stoklund Olesen2947f732011-11-15 01:15:25 +0000185 void processDefs(MachineInstr*, bool Kill);
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +0000186 void visitSoftInstr(MachineInstr*, unsigned mask);
187 void visitHardInstr(MachineInstr*, unsigned domain);
Jakob Stoklund Olesen352aa502010-03-25 17:25:00 +0000188};
189}
190
Jakob Stoklund Olesen56ab8752011-09-28 00:01:56 +0000191char ExeDepsFix::ID = 0;
Jakob Stoklund Olesen352aa502010-03-25 17:25:00 +0000192
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +0000193/// Translate TRI register number to an index into our smaller tables of
194/// interesting registers. Return -1 for boring registers.
Jakob Stoklund Olesen6bcb9a72011-11-08 21:57:47 +0000195int ExeDepsFix::regIndex(unsigned Reg) {
Jakob Stoklund Olesendf4b35e2011-09-27 23:50:46 +0000196 assert(Reg < AliasMap.size() && "Invalid register");
197 return AliasMap[Reg];
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +0000198}
199
Jakob Stoklund Olesen6bcb9a72011-11-08 21:57:47 +0000200DomainValue *ExeDepsFix::alloc(int domain) {
Jakob Stoklund Olesenbbef8152010-04-04 18:00:21 +0000201 DomainValue *dv = Avail.empty() ?
202 new(Allocator.Allocate()) DomainValue :
203 Avail.pop_back_val();
Jakob Stoklund Olesenbbef8152010-04-04 18:00:21 +0000204 if (domain >= 0)
Jakob Stoklund Olesene0103f02010-04-04 21:27:26 +0000205 dv->addDomain(domain);
Jakob Stoklund Olesen737e9a22011-11-08 23:26:00 +0000206 assert(dv->Refs == 0 && "Reference count wasn't cleared");
Jakob Stoklund Olesendbc372f2011-11-09 00:06:18 +0000207 assert(!dv->Next && "Chained DomainValue shouldn't have been recycled");
Jakob Stoklund Olesenbbef8152010-04-04 18:00:21 +0000208 return dv;
209}
210
Jakob Stoklund Olesen35e93242011-11-08 21:57:44 +0000211/// release - Release a reference to DV. When the last reference is released,
212/// collapse if needed.
213void ExeDepsFix::release(DomainValue *DV) {
Jakob Stoklund Olesendbc372f2011-11-09 00:06:18 +0000214 while (DV) {
215 assert(DV->Refs && "Bad DomainValue");
216 if (--DV->Refs)
217 return;
Jakob Stoklund Olesen35e93242011-11-08 21:57:44 +0000218
Jakob Stoklund Olesendbc372f2011-11-09 00:06:18 +0000219 // There are no more DV references. Collapse any contained instructions.
220 if (DV->AvailableDomains && !DV->isCollapsed())
221 collapse(DV, DV->getFirstDomain());
Jakob Stoklund Olesen35e93242011-11-08 21:57:44 +0000222
Jakob Stoklund Olesendbc372f2011-11-09 00:06:18 +0000223 DomainValue *Next = DV->Next;
224 DV->clear();
225 Avail.push_back(DV);
226 // Also release the next DomainValue in the chain.
227 DV = Next;
228 }
229}
230
231/// resolve - Follow the chain of dead DomainValues until a live DomainValue is
232/// reached. Update the referenced pointer when necessary.
233DomainValue *ExeDepsFix::resolve(DomainValue *&DVRef) {
234 DomainValue *DV = DVRef;
235 if (!DV || !DV->Next)
236 return DV;
237
238 // DV has a chain. Find the end.
239 do DV = DV->Next;
240 while (DV->Next);
241
242 // Update DVRef to point to DV.
243 retain(DV);
244 release(DVRef);
245 DVRef = DV;
246 return DV;
Jakob Stoklund Olesenbbef8152010-04-04 18:00:21 +0000247}
248
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +0000249/// Set LiveRegs[rx] = dv, updating reference counts.
Jakob Stoklund Olesen6bcb9a72011-11-08 21:57:47 +0000250void ExeDepsFix::setLiveReg(int rx, DomainValue *dv) {
Jakob Stoklund Olesen1a5d2a82010-03-30 20:04:01 +0000251 assert(unsigned(rx) < NumRegs && "Invalid index");
Jakob Stoklund Olesen2947f732011-11-15 01:15:25 +0000252 assert(LiveRegs && "Must enter basic block first.");
Jakob Stoklund Olesen1a5d2a82010-03-30 20:04:01 +0000253
Jakob Stoklund Olesen2947f732011-11-15 01:15:25 +0000254 if (LiveRegs[rx].Value == dv)
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +0000255 return;
Jakob Stoklund Olesen2947f732011-11-15 01:15:25 +0000256 if (LiveRegs[rx].Value)
257 release(LiveRegs[rx].Value);
258 LiveRegs[rx].Value = retain(dv);
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +0000259}
260
261// Kill register rx, recycle or collapse any DomainValue.
Jakob Stoklund Olesen6bcb9a72011-11-08 21:57:47 +0000262void ExeDepsFix::kill(int rx) {
Jakob Stoklund Olesen1a5d2a82010-03-30 20:04:01 +0000263 assert(unsigned(rx) < NumRegs && "Invalid index");
Jakob Stoklund Olesen2947f732011-11-15 01:15:25 +0000264 assert(LiveRegs && "Must enter basic block first.");
265 if (!LiveRegs[rx].Value)
266 return;
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +0000267
Jakob Stoklund Olesen2947f732011-11-15 01:15:25 +0000268 release(LiveRegs[rx].Value);
269 LiveRegs[rx].Value = 0;
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +0000270}
271
272/// Force register rx into domain.
Jakob Stoklund Olesen6bcb9a72011-11-08 21:57:47 +0000273void ExeDepsFix::force(int rx, unsigned domain) {
Jakob Stoklund Olesen1a5d2a82010-03-30 20:04:01 +0000274 assert(unsigned(rx) < NumRegs && "Invalid index");
Jakob Stoklund Olesen2947f732011-11-15 01:15:25 +0000275 assert(LiveRegs && "Must enter basic block first.");
276 if (DomainValue *dv = LiveRegs[rx].Value) {
Jakob Stoklund Olesene0103f02010-04-04 21:27:26 +0000277 if (dv->isCollapsed())
278 dv->addDomain(domain);
Jakob Stoklund Olesen8ba1c6a2010-04-06 19:48:56 +0000279 else if (dv->hasDomain(domain))
Jakob Stoklund Olesen6bcb9a72011-11-08 21:57:47 +0000280 collapse(dv, domain);
Jakob Stoklund Olesen8ba1c6a2010-04-06 19:48:56 +0000281 else {
Jakob Stoklund Olesen56ab8752011-09-28 00:01:56 +0000282 // This is an incompatible open DomainValue. Collapse it to whatever and
283 // force the new value into domain. This costs a domain crossing.
Jakob Stoklund Olesen6bcb9a72011-11-08 21:57:47 +0000284 collapse(dv, dv->getFirstDomain());
Jakob Stoklund Olesen2947f732011-11-15 01:15:25 +0000285 assert(LiveRegs[rx].Value && "Not live after collapse?");
286 LiveRegs[rx].Value->addDomain(domain);
Jakob Stoklund Olesen8ba1c6a2010-04-06 19:48:56 +0000287 }
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +0000288 } else {
Jakob Stoklund Olesen1a5d2a82010-03-30 20:04:01 +0000289 // Set up basic collapsed DomainValue.
Jakob Stoklund Olesen6bcb9a72011-11-08 21:57:47 +0000290 setLiveReg(rx, alloc(domain));
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +0000291 }
292}
293
294/// Collapse open DomainValue into given domain. If there are multiple
295/// registers using dv, they each get a unique collapsed DomainValue.
Jakob Stoklund Olesen6bcb9a72011-11-08 21:57:47 +0000296void ExeDepsFix::collapse(DomainValue *dv, unsigned domain) {
Jakob Stoklund Olesene0103f02010-04-04 21:27:26 +0000297 assert(dv->hasDomain(domain) && "Cannot collapse");
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +0000298
299 // Collapse all the instructions.
Jakob Stoklund Olesene0103f02010-04-04 21:27:26 +0000300 while (!dv->Instrs.empty())
Jakob Stoklund Olesen98e933f2011-09-27 22:57:18 +0000301 TII->setExecutionDomain(dv->Instrs.pop_back_val(), domain);
Jakob Stoklund Olesene0103f02010-04-04 21:27:26 +0000302 dv->setSingleDomain(domain);
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +0000303
304 // If there are multiple users, give them new, unique DomainValues.
Jakob Stoklund Olesenbbef8152010-04-04 18:00:21 +0000305 if (LiveRegs && dv->Refs > 1)
Jakob Stoklund Olesen1a5d2a82010-03-30 20:04:01 +0000306 for (unsigned rx = 0; rx != NumRegs; ++rx)
Jakob Stoklund Olesen2947f732011-11-15 01:15:25 +0000307 if (LiveRegs[rx].Value == dv)
Jakob Stoklund Olesen6bcb9a72011-11-08 21:57:47 +0000308 setLiveReg(rx, alloc(domain));
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +0000309}
310
311/// Merge - All instructions and registers in B are moved to A, and B is
312/// released.
Jakob Stoklund Olesen6bcb9a72011-11-08 21:57:47 +0000313bool ExeDepsFix::merge(DomainValue *A, DomainValue *B) {
Jakob Stoklund Olesene0103f02010-04-04 21:27:26 +0000314 assert(!A->isCollapsed() && "Cannot merge into collapsed");
315 assert(!B->isCollapsed() && "Cannot merge from collapsed");
Jakob Stoklund Olesen85ffee22010-03-31 20:05:12 +0000316 if (A == B)
Jakob Stoklund Olesen5f282b52010-03-31 17:13:16 +0000317 return true;
Jakob Stoklund Olesene0103f02010-04-04 21:27:26 +0000318 // Restrict to the domains that A and B have in common.
319 unsigned common = A->getCommonDomains(B->AvailableDomains);
320 if (!common)
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +0000321 return false;
Jakob Stoklund Olesene0103f02010-04-04 21:27:26 +0000322 A->AvailableDomains = common;
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +0000323 A->Instrs.append(B->Instrs.begin(), B->Instrs.end());
Jakob Stoklund Olesene1b3e112011-11-08 20:57:04 +0000324
325 // Clear the old DomainValue so we won't try to swizzle instructions twice.
Jakob Stoklund Olesen737e9a22011-11-08 23:26:00 +0000326 B->clear();
Jakob Stoklund Olesendbc372f2011-11-09 00:06:18 +0000327 // All uses of B are referred to A.
328 B->Next = retain(A);
Jakob Stoklund Olesene1b3e112011-11-08 20:57:04 +0000329
Jakob Stoklund Olesen1a5d2a82010-03-30 20:04:01 +0000330 for (unsigned rx = 0; rx != NumRegs; ++rx)
Jakob Stoklund Olesen2947f732011-11-15 01:15:25 +0000331 if (LiveRegs[rx].Value == B)
Jakob Stoklund Olesen6bcb9a72011-11-08 21:57:47 +0000332 setLiveReg(rx, A);
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +0000333 return true;
334}
335
Jakob Stoklund Olesenf4c47682011-11-09 01:06:56 +0000336// enterBasicBlock - Set up LiveRegs by merging predecessor live-out values.
Jakob Stoklund Olesen2947f732011-11-15 01:15:25 +0000337void ExeDepsFix::enterBasicBlock(MachineBasicBlock *MBB) {
Jakob Stoklund Olesenf4c47682011-11-09 01:06:56 +0000338 // Detect back-edges from predecessors we haven't processed yet.
Jakob Stoklund Olesen2947f732011-11-15 01:15:25 +0000339 SeenUnknownBackEdge = false;
340
341 // Reset instruction counter in each basic block.
342 CurInstr = 0;
343
344 // Set up LiveRegs to represent registers entering MBB.
345 if (!LiveRegs)
346 LiveRegs = new LiveReg[NumRegs];
347
348 // Default values are 'nothing happened a long time ago'.
349 for (unsigned rx = 0; rx != NumRegs; ++rx) {
350 LiveRegs[rx].Value = 0;
351 LiveRegs[rx].Def = -(1 << 20);
352 }
353
354 // This is the entry block.
355 if (MBB->pred_empty()) {
356 for (MachineBasicBlock::livein_iterator i = MBB->livein_begin(),
357 e = MBB->livein_end(); i != e; ++i) {
358 int rx = regIndex(*i);
359 if (rx < 0)
360 continue;
361 // Treat function live-ins as if they were defined just before the first
362 // instruction. Usually, function arguments are set up immediately
363 // before the call.
364 LiveRegs[rx].Def = -1;
365 }
366 DEBUG(dbgs() << "BB#" << MBB->getNumber() << ": entry\n");
367 return;
368 }
Jakob Stoklund Olesenf4c47682011-11-09 01:06:56 +0000369
Jakob Stoklund Olesen1a5d2a82010-03-30 20:04:01 +0000370 // Try to coalesce live-out registers from predecessors.
Jakob Stoklund Olesen2947f732011-11-15 01:15:25 +0000371 for (MachineBasicBlock::const_pred_iterator pi = MBB->pred_begin(),
372 pe = MBB->pred_end(); pi != pe; ++pi) {
373 LiveOutMap::const_iterator fi = LiveOuts.find(*pi);
374 if (fi == LiveOuts.end()) {
375 SeenUnknownBackEdge = true;
376 continue;
377 }
378 assert(fi->second && "Can't have NULL entries");
379
380 for (unsigned rx = 0; rx != NumRegs; ++rx) {
381 // Use the most recent predecessor def for each register.
382 LiveRegs[rx].Def = std::max(LiveRegs[rx].Def, fi->second[rx].Def);
383
384 DomainValue *pdv = resolve(fi->second[rx].Value);
385 if (!pdv)
Jakob Stoklund Olesenf4c47682011-11-09 01:06:56 +0000386 continue;
Jakob Stoklund Olesen2947f732011-11-15 01:15:25 +0000387 if (!LiveRegs[rx].Value) {
Jakob Stoklund Olesen6bcb9a72011-11-08 21:57:47 +0000388 setLiveReg(rx, pdv);
Chris Lattner563d83f2010-03-31 20:32:51 +0000389 continue;
Jakob Stoklund Olesen1a5d2a82010-03-30 20:04:01 +0000390 }
Chris Lattner563d83f2010-03-31 20:32:51 +0000391
392 // We have a live DomainValue from more than one predecessor.
Jakob Stoklund Olesen2947f732011-11-15 01:15:25 +0000393 if (LiveRegs[rx].Value->isCollapsed()) {
Chris Lattner563d83f2010-03-31 20:32:51 +0000394 // We are already collapsed, but predecessor is not. Force him.
Jakob Stoklund Olesen2947f732011-11-15 01:15:25 +0000395 unsigned Domain = LiveRegs[rx].Value->getFirstDomain();
396 if (!pdv->isCollapsed() && pdv->hasDomain(Domain))
397 collapse(pdv, Domain);
Chris Lattner563d83f2010-03-31 20:32:51 +0000398 continue;
399 }
Jakob Stoklund Olesenbbef8152010-04-04 18:00:21 +0000400
Chris Lattner563d83f2010-03-31 20:32:51 +0000401 // Currently open, merge in predecessor.
Jakob Stoklund Olesene0103f02010-04-04 21:27:26 +0000402 if (!pdv->isCollapsed())
Jakob Stoklund Olesen2947f732011-11-15 01:15:25 +0000403 merge(LiveRegs[rx].Value, pdv);
Chris Lattner563d83f2010-03-31 20:32:51 +0000404 else
Jakob Stoklund Olesen6bcb9a72011-11-08 21:57:47 +0000405 force(rx, pdv->getFirstDomain());
Jakob Stoklund Olesen1a5d2a82010-03-30 20:04:01 +0000406 }
407 }
Jakob Stoklund Olesen2947f732011-11-15 01:15:25 +0000408 DEBUG(dbgs() << "BB#" << MBB->getNumber()
409 << (SeenUnknownBackEdge ? ": incomplete\n" : ": all preds known\n"));
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +0000410}
411
Jakob Stoklund Olesen25265d02011-11-07 21:40:27 +0000412void ExeDepsFix::leaveBasicBlock(MachineBasicBlock *MBB) {
Jakob Stoklund Olesen2947f732011-11-15 01:15:25 +0000413 assert(LiveRegs && "Must enter basic block first.");
Jakob Stoklund Olesen25265d02011-11-07 21:40:27 +0000414 // Save live registers at end of MBB - used by enterBasicBlock().
Jakob Stoklund Olesenf4c47682011-11-09 01:06:56 +0000415 // Also use LiveOuts as a visited set to detect back-edges.
Jakob Stoklund Olesen2947f732011-11-15 01:15:25 +0000416 bool First = LiveOuts.insert(std::make_pair(MBB, LiveRegs)).second;
417
418 if (First) {
419 // LiveRegs was inserted in LiveOuts. Adjust all defs to be relative to
420 // the end of this block instead of the beginning.
421 for (unsigned i = 0, e = NumRegs; i != e; ++i)
422 LiveRegs[i].Def -= CurInstr;
423 } else {
Jakob Stoklund Olesenf4c47682011-11-09 01:06:56 +0000424 // Insertion failed, this must be the second pass.
425 // Release all the DomainValues instead of keeping them.
426 for (unsigned i = 0, e = NumRegs; i != e; ++i)
Jakob Stoklund Olesen2947f732011-11-15 01:15:25 +0000427 release(LiveRegs[i].Value);
Jakob Stoklund Olesenf4c47682011-11-09 01:06:56 +0000428 delete[] LiveRegs;
429 }
Jakob Stoklund Olesen25265d02011-11-07 21:40:27 +0000430 LiveRegs = 0;
431}
432
433void ExeDepsFix::visitInstr(MachineInstr *MI) {
434 if (MI->isDebugValue())
435 return;
Jakob Stoklund Olesen2947f732011-11-15 01:15:25 +0000436
437 // Update instructions with explicit execution domains.
438 std::pair<uint16_t, uint16_t> DomP = TII->getExecutionDomain(MI);
439 if (DomP.first) {
440 if (DomP.second)
441 visitSoftInstr(MI, DomP.second);
Jakob Stoklund Olesen25265d02011-11-07 21:40:27 +0000442 else
Jakob Stoklund Olesen2947f732011-11-15 01:15:25 +0000443 visitHardInstr(MI, DomP.first);
444 }
445
446 // Process defs to track register ages, and kill values clobbered by generic
447 // instructions.
448 processDefs(MI, !DomP.first);
449}
450
451// Update def-ages for registers defined by MI.
452// If Kill is set, also kill off DomainValues clobbered by the defs.
453void ExeDepsFix::processDefs(MachineInstr *MI, bool Kill) {
454 assert(!MI->isDebugValue() && "Won't process debug values");
455 const MCInstrDesc &MCID = MI->getDesc();
456 for (unsigned i = 0,
457 e = MCID.isVariadic() ? MI->getNumOperands() : MCID.getNumDefs();
458 i != e; ++i) {
459 MachineOperand &MO = MI->getOperand(i);
460 if (!MO.isReg())
461 continue;
462 if (MO.isImplicit())
463 break;
464 if (MO.isUse())
465 continue;
466 int rx = regIndex(MO.getReg());
467 if (rx < 0)
468 continue;
469
470 // This instruction explicitly defines rx.
471 DEBUG(dbgs() << TRI->getName(RC->getRegister(rx)) << ":\t" << CurInstr
472 << '\t' << *MI);
473
474 LiveRegs[rx].Def = CurInstr;
475
476 // Kill off domains redefined by generic instructions.
477 if (Kill)
478 kill(rx);
479 }
480
481 ++CurInstr;
Jakob Stoklund Olesen25265d02011-11-07 21:40:27 +0000482}
483
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +0000484// A hard instruction only works in one domain. All input registers will be
485// forced into that domain.
Jakob Stoklund Olesen56ab8752011-09-28 00:01:56 +0000486void ExeDepsFix::visitHardInstr(MachineInstr *mi, unsigned domain) {
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +0000487 // Collapse all uses.
488 for (unsigned i = mi->getDesc().getNumDefs(),
489 e = mi->getDesc().getNumOperands(); i != e; ++i) {
490 MachineOperand &mo = mi->getOperand(i);
491 if (!mo.isReg()) continue;
Jakob Stoklund Olesen6bcb9a72011-11-08 21:57:47 +0000492 int rx = regIndex(mo.getReg());
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +0000493 if (rx < 0) continue;
Jakob Stoklund Olesen6bcb9a72011-11-08 21:57:47 +0000494 force(rx, domain);
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +0000495 }
496
497 // Kill all defs and force them.
498 for (unsigned i = 0, e = mi->getDesc().getNumDefs(); i != e; ++i) {
499 MachineOperand &mo = mi->getOperand(i);
500 if (!mo.isReg()) continue;
Jakob Stoklund Olesen6bcb9a72011-11-08 21:57:47 +0000501 int rx = regIndex(mo.getReg());
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +0000502 if (rx < 0) continue;
Jakob Stoklund Olesen6bcb9a72011-11-08 21:57:47 +0000503 kill(rx);
504 force(rx, domain);
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +0000505 }
506}
507
508// A soft instruction can be changed to work in other domains given by mask.
Jakob Stoklund Olesen56ab8752011-09-28 00:01:56 +0000509void ExeDepsFix::visitSoftInstr(MachineInstr *mi, unsigned mask) {
Jakob Stoklund Olesene0103f02010-04-04 21:27:26 +0000510 // Bitmask of available domains for this instruction after taking collapsed
511 // operands into account.
512 unsigned available = mask;
513
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +0000514 // Scan the explicit use operands for incoming domains.
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +0000515 SmallVector<int, 4> used;
Jakob Stoklund Olesen1a5d2a82010-03-30 20:04:01 +0000516 if (LiveRegs)
517 for (unsigned i = mi->getDesc().getNumDefs(),
518 e = mi->getDesc().getNumOperands(); i != e; ++i) {
Chris Lattner563d83f2010-03-31 20:32:51 +0000519 MachineOperand &mo = mi->getOperand(i);
520 if (!mo.isReg()) continue;
Jakob Stoklund Olesen6bcb9a72011-11-08 21:57:47 +0000521 int rx = regIndex(mo.getReg());
Chris Lattner563d83f2010-03-31 20:32:51 +0000522 if (rx < 0) continue;
Jakob Stoklund Olesen2947f732011-11-15 01:15:25 +0000523 if (DomainValue *dv = LiveRegs[rx].Value) {
Jakob Stoklund Olesene0103f02010-04-04 21:27:26 +0000524 // Bitmask of domains that dv and available have in common.
525 unsigned common = dv->getCommonDomains(available);
Chris Lattner563d83f2010-03-31 20:32:51 +0000526 // Is it possible to use this collapsed register for free?
Jakob Stoklund Olesene0103f02010-04-04 21:27:26 +0000527 if (dv->isCollapsed()) {
528 // Restrict available domains to the ones in common with the operand.
529 // If there are no common domains, we must pay the cross-domain
530 // penalty for this operand.
531 if (common) available = common;
532 } else if (common)
533 // Open DomainValue is compatible, save it for merging.
Chris Lattner563d83f2010-03-31 20:32:51 +0000534 used.push_back(rx);
535 else
Jakob Stoklund Olesene0103f02010-04-04 21:27:26 +0000536 // Open DomainValue is not compatible with instruction. It is useless
537 // now.
Jakob Stoklund Olesen6bcb9a72011-11-08 21:57:47 +0000538 kill(rx);
Chris Lattner563d83f2010-03-31 20:32:51 +0000539 }
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +0000540 }
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +0000541
542 // If the collapsed operands force a single domain, propagate the collapse.
Jakob Stoklund Olesene0103f02010-04-04 21:27:26 +0000543 if (isPowerOf2_32(available)) {
544 unsigned domain = CountTrailingZeros_32(available);
Jakob Stoklund Olesen98e933f2011-09-27 22:57:18 +0000545 TII->setExecutionDomain(mi, domain);
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +0000546 visitHardInstr(mi, domain);
547 return;
548 }
549
Jakob Stoklund Olesene0103f02010-04-04 21:27:26 +0000550 // Kill off any remaining uses that don't match available, and build a list of
551 // incoming DomainValues that we want to merge.
Jakob Stoklund Olesen2947f732011-11-15 01:15:25 +0000552 SmallVector<LiveReg, 4> Regs;
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +0000553 for (SmallVector<int, 4>::iterator i=used.begin(), e=used.end(); i!=e; ++i) {
554 int rx = *i;
Jakob Stoklund Olesen2947f732011-11-15 01:15:25 +0000555 const LiveReg &LR = LiveRegs[rx];
Jakob Stoklund Olesen1a5d2a82010-03-30 20:04:01 +0000556 // This useless DomainValue could have been missed above.
Jakob Stoklund Olesen2947f732011-11-15 01:15:25 +0000557 if (!LR.Value->getCommonDomains(available)) {
558 kill(rx);
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +0000559 continue;
560 }
Jakob Stoklund Olesen2947f732011-11-15 01:15:25 +0000561 // Sorted insertion.
562 bool Inserted = false;
563 for (SmallVector<LiveReg, 4>::iterator i = Regs.begin(), e = Regs.end();
564 i != e && !Inserted; ++i) {
565 if (LR.Def < i->Def) {
566 Inserted = true;
567 Regs.insert(i, LR);
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +0000568 }
569 }
Jakob Stoklund Olesen2947f732011-11-15 01:15:25 +0000570 if (!Inserted)
571 Regs.push_back(LR);
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +0000572 }
573
Jakob Stoklund Olesene0103f02010-04-04 21:27:26 +0000574 // doms are now sorted in order of appearance. Try to merge them all, giving
575 // priority to the latest ones.
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +0000576 DomainValue *dv = 0;
Jakob Stoklund Olesen2947f732011-11-15 01:15:25 +0000577 while (!Regs.empty()) {
Chris Lattner563d83f2010-03-31 20:32:51 +0000578 if (!dv) {
Jakob Stoklund Olesen2947f732011-11-15 01:15:25 +0000579 dv = Regs.pop_back_val().Value;
Chris Lattner563d83f2010-03-31 20:32:51 +0000580 continue;
581 }
Jakob Stoklund Olesenbbef8152010-04-04 18:00:21 +0000582
Jakob Stoklund Olesen2947f732011-11-15 01:15:25 +0000583 DomainValue *Latest = Regs.pop_back_val().Value;
584 // Skip already merged values.
585 if (Latest == dv || Latest->Next)
586 continue;
587 if (merge(dv, Latest))
588 continue;
Jakob Stoklund Olesenbbef8152010-04-04 18:00:21 +0000589
Jakob Stoklund Olesene0103f02010-04-04 21:27:26 +0000590 // If latest didn't merge, it is useless now. Kill all registers using it.
Chris Lattner563d83f2010-03-31 20:32:51 +0000591 for (SmallVector<int,4>::iterator i=used.begin(), e=used.end(); i != e; ++i)
Jakob Stoklund Olesen2947f732011-11-15 01:15:25 +0000592 if (LiveRegs[*i].Value == Latest)
Jakob Stoklund Olesen6bcb9a72011-11-08 21:57:47 +0000593 kill(*i);
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +0000594 }
595
596 // dv is the DomainValue we are going to use for this instruction.
597 if (!dv)
Jakob Stoklund Olesen6bcb9a72011-11-08 21:57:47 +0000598 dv = alloc();
Jakob Stoklund Olesene0103f02010-04-04 21:27:26 +0000599 dv->AvailableDomains = available;
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +0000600 dv->Instrs.push_back(mi);
601
602 // Finally set all defs and non-collapsed uses to dv.
603 for (unsigned i = 0, e = mi->getDesc().getNumOperands(); i != e; ++i) {
604 MachineOperand &mo = mi->getOperand(i);
605 if (!mo.isReg()) continue;
Jakob Stoklund Olesen6bcb9a72011-11-08 21:57:47 +0000606 int rx = regIndex(mo.getReg());
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +0000607 if (rx < 0) continue;
Jakob Stoklund Olesen2947f732011-11-15 01:15:25 +0000608 if (!LiveRegs[rx].Value || (mo.isDef() && LiveRegs[rx].Value != dv)) {
Jakob Stoklund Olesen6bcb9a72011-11-08 21:57:47 +0000609 kill(rx);
610 setLiveReg(rx, dv);
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +0000611 }
612 }
613}
614
Jakob Stoklund Olesen56ab8752011-09-28 00:01:56 +0000615bool ExeDepsFix::runOnMachineFunction(MachineFunction &mf) {
Jakob Stoklund Olesen352aa502010-03-25 17:25:00 +0000616 MF = &mf;
Jakob Stoklund Olesendf4b35e2011-09-27 23:50:46 +0000617 TII = MF->getTarget().getInstrInfo();
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +0000618 TRI = MF->getTarget().getRegisterInfo();
Jakob Stoklund Olesen1a5d2a82010-03-30 20:04:01 +0000619 LiveRegs = 0;
Jakob Stoklund Olesendf4b35e2011-09-27 23:50:46 +0000620 assert(NumRegs == RC->getNumRegs() && "Bad regclass");
Jakob Stoklund Olesen352aa502010-03-25 17:25:00 +0000621
Jakob Stoklund Olesen2947f732011-11-15 01:15:25 +0000622 DEBUG(dbgs() << "********** FIX EXECUTION DEPENDENCIES: "
623 << RC->getName() << " **********\n");
624
Jakob Stoklund Olesen56ab8752011-09-28 00:01:56 +0000625 // If no relevant registers are used in the function, we can skip it
626 // completely.
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +0000627 bool anyregs = false;
Jakob Stoklund Olesendf4b35e2011-09-27 23:50:46 +0000628 for (TargetRegisterClass::const_iterator I = RC->begin(), E = RC->end();
629 I != E; ++I)
Jakob Stoklund Olesen352aa502010-03-25 17:25:00 +0000630 if (MF->getRegInfo().isPhysRegUsed(*I)) {
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +0000631 anyregs = true;
Jakob Stoklund Olesen352aa502010-03-25 17:25:00 +0000632 break;
633 }
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +0000634 if (!anyregs) return false;
Jakob Stoklund Olesen352aa502010-03-25 17:25:00 +0000635
Jakob Stoklund Olesendf4b35e2011-09-27 23:50:46 +0000636 // Initialize the AliasMap on the first use.
637 if (AliasMap.empty()) {
638 // Given a PhysReg, AliasMap[PhysReg] is either the relevant index into RC,
639 // or -1.
640 AliasMap.resize(TRI->getNumRegs(), -1);
641 for (unsigned i = 0, e = RC->getNumRegs(); i != e; ++i)
642 for (const unsigned *AI = TRI->getOverlaps(RC->getRegister(i)); *AI; ++AI)
643 AliasMap[*AI] = i;
644 }
645
Jakob Stoklund Olesen352aa502010-03-25 17:25:00 +0000646 MachineBasicBlock *Entry = MF->begin();
Jakob Stoklund Olesena59ce032011-11-07 21:59:29 +0000647 ReversePostOrderTraversal<MachineBasicBlock*> RPOT(Entry);
Jakob Stoklund Olesenf4c47682011-11-09 01:06:56 +0000648 SmallVector<MachineBasicBlock*, 16> Loops;
Jakob Stoklund Olesena59ce032011-11-07 21:59:29 +0000649 for (ReversePostOrderTraversal<MachineBasicBlock*>::rpo_iterator
650 MBBI = RPOT.begin(), MBBE = RPOT.end(); MBBI != MBBE; ++MBBI) {
651 MachineBasicBlock *MBB = *MBBI;
Jakob Stoklund Olesen2947f732011-11-15 01:15:25 +0000652 enterBasicBlock(MBB);
653 if (SeenUnknownBackEdge)
Jakob Stoklund Olesenf4c47682011-11-09 01:06:56 +0000654 Loops.push_back(MBB);
Jakob Stoklund Olesen352aa502010-03-25 17:25:00 +0000655 for (MachineBasicBlock::iterator I = MBB->begin(), E = MBB->end(); I != E;
Jakob Stoklund Olesen25265d02011-11-07 21:40:27 +0000656 ++I)
657 visitInstr(I);
658 leaveBasicBlock(MBB);
Jakob Stoklund Olesen352aa502010-03-25 17:25:00 +0000659 }
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +0000660
Jakob Stoklund Olesenf4c47682011-11-09 01:06:56 +0000661 // Visit all the loop blocks again in order to merge DomainValues from
662 // back-edges.
663 for (unsigned i = 0, e = Loops.size(); i != e; ++i) {
664 MachineBasicBlock *MBB = Loops[i];
665 enterBasicBlock(MBB);
666 leaveBasicBlock(MBB);
667 }
668
Jakob Stoklund Olesenb26c7722011-11-07 23:08:21 +0000669 // Clear the LiveOuts vectors and collapse any remaining DomainValues.
670 for (ReversePostOrderTraversal<MachineBasicBlock*>::rpo_iterator
671 MBBI = RPOT.begin(), MBBE = RPOT.end(); MBBI != MBBE; ++MBBI) {
672 LiveOutMap::const_iterator FI = LiveOuts.find(*MBBI);
Jakob Stoklund Olesenf4c47682011-11-09 01:06:56 +0000673 if (FI == LiveOuts.end() || !FI->second)
Jakob Stoklund Olesenb26c7722011-11-07 23:08:21 +0000674 continue;
Jakob Stoklund Olesenb26c7722011-11-07 23:08:21 +0000675 for (unsigned i = 0, e = NumRegs; i != e; ++i)
Jakob Stoklund Olesen2947f732011-11-15 01:15:25 +0000676 if (FI->second[i].Value)
677 release(FI->second[i].Value);
Jakob Stoklund Olesen0fdb05d2011-11-08 22:05:17 +0000678 delete[] FI->second;
Jakob Stoklund Olesenb26c7722011-11-07 23:08:21 +0000679 }
Jakob Stoklund Olesen1a5d2a82010-03-30 20:04:01 +0000680 LiveOuts.clear();
Jakob Stoklund Olesenbbef8152010-04-04 18:00:21 +0000681 Avail.clear();
682 Allocator.DestroyAll();
Jakob Stoklund Olesene4b94b42010-03-29 23:24:21 +0000683
Jakob Stoklund Olesen352aa502010-03-25 17:25:00 +0000684 return false;
685}
686
Jakob Stoklund Olesendf4b35e2011-09-27 23:50:46 +0000687FunctionPass *
688llvm::createExecutionDependencyFixPass(const TargetRegisterClass *RC) {
Jakob Stoklund Olesen56ab8752011-09-28 00:01:56 +0000689 return new ExeDepsFix(RC);
Jakob Stoklund Olesen352aa502010-03-25 17:25:00 +0000690}