blob: 94a86f24fbf6887878bed1b5dd82970778abd521 [file] [log] [blame]
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +00001//===- StrongPHIElimination.cpp - Eliminate PHI nodes by inserting copies -===//
Owen Anderson0bda0e82007-10-31 03:37:57 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Owen Anderson0bda0e82007-10-31 03:37:57 +00007//
8//===----------------------------------------------------------------------===//
9//
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +000010// This pass eliminates PHI instructions by aggressively coalescing the copies
11// that would be inserted by a naive algorithm and only inserting the copies
12// that are necessary. The coalescing technique initially assumes that all
13// registers appearing in a PHI instruction do not interfere. It then eliminates
14// proven interferences, using dominators to only perform a linear number of
15// interference tests instead of the quadratic number of interference tests
16// that this would naively require. This is a technique derived from:
17//
18// Budimlic, et al. Fast copy coalescing and live-range identification.
19// In Proceedings of the ACM SIGPLAN 2002 Conference on Programming Language
20// Design and Implementation (Berlin, Germany, June 17 - 19, 2002).
21// PLDI '02. ACM, New York, NY, 25-32.
22//
23// The original implementation constructs a data structure they call a dominance
24// forest for this purpose. The dominance forest was shown to be unnecessary,
25// as it is possible to emulate the creation and traversal of a dominance forest
26// by directly using the dominator tree, rather than actually constructing the
27// dominance forest. This technique is explained in:
28//
29// Boissinot, et al. Revisiting Out-of-SSA Translation for Correctness, Code
30// Quality and Efficiency,
31// In Proceedings of the 7th annual IEEE/ACM International Symposium on Code
32// Generation and Optimization (Seattle, Washington, March 22 - 25, 2009).
33// CGO '09. IEEE, Washington, DC, 114-125.
34//
35// Careful implementation allows for all of the dominator forest interference
36// checks to be performed at once in a single depth-first traversal of the
37// dominator tree, which is what is implemented here.
Owen Anderson0bda0e82007-10-31 03:37:57 +000038//
39//===----------------------------------------------------------------------===//
40
41#define DEBUG_TYPE "strongphielim"
Cameron Zwarich47bce432010-12-21 06:54:43 +000042#include "PHIEliminationUtils.h"
Owen Anderson0bda0e82007-10-31 03:37:57 +000043#include "llvm/CodeGen/Passes.h"
Owen Andersoneb37ecc2008-03-10 07:22:36 +000044#include "llvm/CodeGen/LiveIntervalAnalysis.h"
Owen Anderson0bda0e82007-10-31 03:37:57 +000045#include "llvm/CodeGen/MachineDominators.h"
46#include "llvm/CodeGen/MachineFunctionPass.h"
Cameron Zwarich47bce432010-12-21 06:54:43 +000047#include "llvm/CodeGen/MachineInstrBuilder.h"
48#include "llvm/CodeGen/MachineRegisterInfo.h"
49#include "llvm/Target/TargetInstrInfo.h"
50#include "llvm/Support/Debug.h"
Owen Anderson0bda0e82007-10-31 03:37:57 +000051using namespace llvm;
52
Owen Anderson0bda0e82007-10-31 03:37:57 +000053namespace {
Cameron Zwarich9eaf49b2010-12-05 22:34:08 +000054 class StrongPHIElimination : public MachineFunctionPass {
55 public:
56 static char ID; // Pass identification, replacement for typeid
57 StrongPHIElimination() : MachineFunctionPass(ID) {
58 initializeStrongPHIEliminationPass(*PassRegistry::getPassRegistry());
59 }
Owen Anderson0bda0e82007-10-31 03:37:57 +000060
Cameron Zwarich9eaf49b2010-12-05 22:34:08 +000061 virtual void getAnalysisUsage(AnalysisUsage&) const;
62 bool runOnMachineFunction(MachineFunction&);
Cameron Zwarich47bce432010-12-21 06:54:43 +000063
64 private:
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +000065 /// This struct represents a single node in the union-find data structure
66 /// representing the variable congruence classes. There is one difference
67 /// from a normal union-find data structure. We steal two bits from the parent
68 /// pointer . One of these bits is used to represent whether the register
69 /// itself has been isolated, and the other is used to represent whether the
70 /// PHI with that register as its destination has been isolated.
71 ///
72 /// Note that this leads to the strange situation where the leader of a
73 /// congruence class may no longer logically be a member, due to being
74 /// isolated.
75 struct Node {
76 enum Flags {
77 kRegisterIsolatedFlag = 1,
78 kPHIIsolatedFlag = 2
79 };
80 Node(unsigned v) : value(v), rank(0) { parent.setPointer(this); }
81
Cameron Zwarich7c881862011-01-08 22:36:53 +000082 Node *getLeader();
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +000083
84 PointerIntPair<Node*, 2> parent;
85 unsigned value;
86 unsigned rank;
87 };
88
89 /// Add a register in a new congruence class containing only itself.
90 void addReg(unsigned);
91
Cameron Zwariche272dee2011-01-09 10:32:30 +000092 /// Join the congruence classes of two registers. This function is biased
93 /// towards the left argument, i.e. after
94 ///
95 /// addReg(r2);
96 /// unionRegs(r1, r2);
97 ///
98 /// the leader of the unioned congruence class is the same as the leader of
99 /// r1's congruence class prior to the union. This is actually relied upon
100 /// in the copy insertion code.
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +0000101 void unionRegs(unsigned, unsigned);
102
103 /// Get the color of a register. The color is 0 if the register has been
104 /// isolated.
105 unsigned getRegColor(unsigned);
106
107 // Isolate a register.
108 void isolateReg(unsigned);
109
110 /// Get the color of a PHI. The color of a PHI is 0 if the PHI has been
111 /// isolated. Otherwise, it is the original color of its destination and
112 /// all of its operands (before they were isolated, if they were).
113 unsigned getPHIColor(MachineInstr*);
114
115 /// Isolate a PHI.
116 void isolatePHI(MachineInstr*);
117
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +0000118 /// Traverses a basic block, splitting any interferences found between
119 /// registers in the same congruence class. It takes two DenseMaps as
120 /// arguments that it also updates: CurrentDominatingParent, which maps
121 /// a color to the register in that congruence class whose definition was
122 /// most recently seen, and ImmediateDominatingParent, which maps a register
123 /// to the register in the same congruence class that most immediately
124 /// dominates it.
125 ///
126 /// This function assumes that it is being called in a depth-first traversal
127 /// of the dominator tree.
128 void SplitInterferencesForBasicBlock(
129 MachineBasicBlock&,
Cameron Zwarich7c881862011-01-08 22:36:53 +0000130 DenseMap<unsigned, unsigned> &CurrentDominatingParent,
131 DenseMap<unsigned, unsigned> &ImmediateDominatingParent);
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +0000132
133 // Lowers a PHI instruction, inserting copies of the source and destination
134 // registers as necessary.
Cameron Zwarich47bce432010-12-21 06:54:43 +0000135 void InsertCopiesForPHI(MachineInstr*, MachineBasicBlock*);
136
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +0000137 // Merges the live interval of Reg into NewReg and renames Reg to NewReg
138 // everywhere that Reg appears. Requires Reg and NewReg to have non-
139 // overlapping lifetimes.
140 void MergeLIsAndRename(unsigned Reg, unsigned NewReg);
141
Cameron Zwarich7c881862011-01-08 22:36:53 +0000142 MachineRegisterInfo *MRI;
143 const TargetInstrInfo *TII;
144 MachineDominatorTree *DT;
145 LiveIntervals *LI;
Cameron Zwarich47bce432010-12-21 06:54:43 +0000146
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +0000147 BumpPtrAllocator Allocator;
148
149 DenseMap<unsigned, Node*> RegNodeMap;
150
Cameron Zwarich1558f5e2010-12-29 11:00:09 +0000151 // Maps a basic block to a list of its defs of registers that appear as PHI
152 // sources.
153 DenseMap<MachineBasicBlock*, std::vector<MachineInstr*> > PHISrcDefs;
154
Cameron Zwarich645b1d22011-01-04 06:42:27 +0000155 // Maps a color to a pair of a MachineInstr* and a virtual register, which
156 // is the operand of that PHI corresponding to the current basic block.
157 DenseMap<unsigned, std::pair<MachineInstr*, unsigned> > CurrentPHIForColor;
158
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +0000159 // FIXME: Can these two data structures be combined? Would a std::multimap
160 // be any better?
161
162 // Stores pairs of predecessor basic blocks and the source registers of
163 // inserted copy instructions.
164 typedef DenseSet<std::pair<MachineBasicBlock*, unsigned> > SrcCopySet;
165 SrcCopySet InsertedSrcCopySet;
166
167 // Maps pairs of predecessor basic blocks and colors to their defining copy
168 // instructions.
169 typedef DenseMap<std::pair<MachineBasicBlock*, unsigned>, MachineInstr*>
170 SrcCopyMap;
171 SrcCopyMap InsertedSrcCopyMap;
172
173 // Maps inserted destination copy registers to their defining copy
174 // instructions.
175 typedef DenseMap<unsigned, MachineInstr*> DestCopyMap;
176 DestCopyMap InsertedDestCopies;
Cameron Zwarich9eaf49b2010-12-05 22:34:08 +0000177 };
Cameron Zwarich1558f5e2010-12-29 11:00:09 +0000178
179 struct MIIndexCompare {
Cameron Zwarich7c881862011-01-08 22:36:53 +0000180 MIIndexCompare(LiveIntervals *LiveIntervals) : LI(LiveIntervals) { }
Cameron Zwarich1558f5e2010-12-29 11:00:09 +0000181
Cameron Zwarich7c881862011-01-08 22:36:53 +0000182 bool operator()(const MachineInstr *LHS, const MachineInstr *RHS) const {
Cameron Zwarich1558f5e2010-12-29 11:00:09 +0000183 return LI->getInstructionIndex(LHS) < LI->getInstructionIndex(RHS);
184 }
185
Cameron Zwarich7c881862011-01-08 22:36:53 +0000186 LiveIntervals *LI;
Cameron Zwarich1558f5e2010-12-29 11:00:09 +0000187 };
Jakob Stoklund Olesen68be9562010-12-03 19:21:53 +0000188} // namespace
Owen Anderson0bda0e82007-10-31 03:37:57 +0000189
Dan Gohman844731a2008-05-13 00:00:25 +0000190char StrongPHIElimination::ID = 0;
Owen Anderson2ab36d32010-10-12 19:48:12 +0000191INITIALIZE_PASS_BEGIN(StrongPHIElimination, "strong-phi-node-elimination",
192 "Eliminate PHI nodes for register allocation, intelligently", false, false)
193INITIALIZE_PASS_DEPENDENCY(MachineDominatorTree)
194INITIALIZE_PASS_DEPENDENCY(SlotIndexes)
195INITIALIZE_PASS_DEPENDENCY(LiveIntervals)
196INITIALIZE_PASS_END(StrongPHIElimination, "strong-phi-node-elimination",
Owen Andersonce665bd2010-10-07 22:25:06 +0000197 "Eliminate PHI nodes for register allocation, intelligently", false, false)
Dan Gohman844731a2008-05-13 00:00:25 +0000198
Owen Anderson90c579d2010-08-06 18:33:48 +0000199char &llvm::StrongPHIEliminationID = StrongPHIElimination::ID;
Owen Anderson0bda0e82007-10-31 03:37:57 +0000200
Cameron Zwarich7c881862011-01-08 22:36:53 +0000201void StrongPHIElimination::getAnalysisUsage(AnalysisUsage &AU) const {
Cameron Zwarich9eaf49b2010-12-05 22:34:08 +0000202 AU.setPreservesCFG();
203 AU.addRequired<MachineDominatorTree>();
204 AU.addRequired<SlotIndexes>();
205 AU.addPreserved<SlotIndexes>();
206 AU.addRequired<LiveIntervals>();
207 AU.addPreserved<LiveIntervals>();
208 MachineFunctionPass::getAnalysisUsage(AU);
209}
210
Cameron Zwarich7c881862011-01-08 22:36:53 +0000211static MachineOperand *findLastUse(MachineBasicBlock *MBB, unsigned Reg) {
Cameron Zwarich47bce432010-12-21 06:54:43 +0000212 // FIXME: This only needs to check from the first terminator, as only the
213 // first terminator can use a virtual register.
214 for (MachineBasicBlock::reverse_iterator RI = MBB->rbegin(); ; ++RI) {
215 assert (RI != MBB->rend());
Cameron Zwarich7c881862011-01-08 22:36:53 +0000216 MachineInstr *MI = &*RI;
Cameron Zwarich47bce432010-12-21 06:54:43 +0000217
218 for (MachineInstr::mop_iterator OI = MI->operands_begin(),
219 OE = MI->operands_end(); OI != OE; ++OI) {
Cameron Zwarich7c881862011-01-08 22:36:53 +0000220 MachineOperand &MO = *OI;
Cameron Zwarich47bce432010-12-21 06:54:43 +0000221 if (MO.isReg() && MO.isUse() && MO.getReg() == Reg)
222 return &MO;
223 }
224 }
225 return NULL;
226}
227
Cameron Zwarich7c881862011-01-08 22:36:53 +0000228bool StrongPHIElimination::runOnMachineFunction(MachineFunction &MF) {
Cameron Zwarich47bce432010-12-21 06:54:43 +0000229 MRI = &MF.getRegInfo();
230 TII = MF.getTarget().getInstrInfo();
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +0000231 DT = &getAnalysis<MachineDominatorTree>();
Cameron Zwarich47bce432010-12-21 06:54:43 +0000232 LI = &getAnalysis<LiveIntervals>();
233
Cameron Zwarich1558f5e2010-12-29 11:00:09 +0000234 for (MachineFunction::iterator I = MF.begin(), E = MF.end();
235 I != E; ++I) {
236 for (MachineBasicBlock::iterator BBI = I->begin(), BBE = I->end();
237 BBI != BBE && BBI->isPHI(); ++BBI) {
238 unsigned DestReg = BBI->getOperand(0).getReg();
239 addReg(DestReg);
240 PHISrcDefs[I].push_back(BBI);
241
242 for (unsigned i = 1; i < BBI->getNumOperands(); i += 2) {
Cameron Zwarich7c881862011-01-08 22:36:53 +0000243 MachineOperand &SrcMO = BBI->getOperand(i);
Cameron Zwarich1558f5e2010-12-29 11:00:09 +0000244 unsigned SrcReg = SrcMO.getReg();
245 addReg(SrcReg);
246 unionRegs(DestReg, SrcReg);
247
Cameron Zwarich7c881862011-01-08 22:36:53 +0000248 MachineInstr *DefMI = MRI->getVRegDef(SrcReg);
Cameron Zwarichd16ad3e2010-12-30 00:42:23 +0000249 if (DefMI)
250 PHISrcDefs[DefMI->getParent()].push_back(DefMI);
Cameron Zwarich1558f5e2010-12-29 11:00:09 +0000251 }
252 }
253 }
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +0000254
255 // Perform a depth-first traversal of the dominator tree, splitting
256 // interferences amongst PHI-congruence classes.
257 DenseMap<unsigned, unsigned> CurrentDominatingParent;
258 DenseMap<unsigned, unsigned> ImmediateDominatingParent;
259 for (df_iterator<MachineDomTreeNode*> DI = df_begin(DT->getRootNode()),
260 DE = df_end(DT->getRootNode()); DI != DE; ++DI) {
261 SplitInterferencesForBasicBlock(*DI->getBlock(),
262 CurrentDominatingParent,
263 ImmediateDominatingParent);
264 }
265
Cameron Zwarich47bce432010-12-21 06:54:43 +0000266 // Insert copies for all PHI source and destination registers.
267 for (MachineFunction::iterator I = MF.begin(), E = MF.end();
268 I != E; ++I) {
269 for (MachineBasicBlock::iterator BBI = I->begin(), BBE = I->end();
270 BBI != BBE && BBI->isPHI(); ++BBI) {
271 InsertCopiesForPHI(BBI, I);
272 }
273 }
274
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +0000275 // FIXME: Preserve the equivalence classes during copy insertion and use
276 // the preversed equivalence classes instead of recomputing them.
277 RegNodeMap.clear();
Cameron Zwarich1558f5e2010-12-29 11:00:09 +0000278 for (MachineFunction::iterator I = MF.begin(), E = MF.end();
279 I != E; ++I) {
280 for (MachineBasicBlock::iterator BBI = I->begin(), BBE = I->end();
281 BBI != BBE && BBI->isPHI(); ++BBI) {
282 unsigned DestReg = BBI->getOperand(0).getReg();
283 addReg(DestReg);
284
285 for (unsigned i = 1; i < BBI->getNumOperands(); i += 2) {
286 unsigned SrcReg = BBI->getOperand(i).getReg();
287 addReg(SrcReg);
288 unionRegs(DestReg, SrcReg);
289 }
290 }
291 }
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +0000292
293 DenseMap<unsigned, unsigned> RegRenamingMap;
294 bool Changed = false;
295 for (MachineFunction::iterator I = MF.begin(), E = MF.end();
296 I != E; ++I) {
297 MachineBasicBlock::iterator BBI = I->begin(), BBE = I->end();
298 while (BBI != BBE && BBI->isPHI()) {
Cameron Zwarich7c881862011-01-08 22:36:53 +0000299 MachineInstr *PHI = BBI;
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +0000300
301 assert(PHI->getNumOperands() > 0);
302
303 unsigned SrcReg = PHI->getOperand(1).getReg();
304 unsigned SrcColor = getRegColor(SrcReg);
305 unsigned NewReg = RegRenamingMap[SrcColor];
306 if (!NewReg) {
307 NewReg = SrcReg;
308 RegRenamingMap[SrcColor] = SrcReg;
309 }
310 MergeLIsAndRename(SrcReg, NewReg);
311
312 unsigned DestReg = PHI->getOperand(0).getReg();
313 if (!InsertedDestCopies.count(DestReg))
314 MergeLIsAndRename(DestReg, NewReg);
315
316 for (unsigned i = 3; i < PHI->getNumOperands(); i += 2) {
317 unsigned SrcReg = PHI->getOperand(i).getReg();
318 MergeLIsAndRename(SrcReg, NewReg);
319 }
320
321 ++BBI;
322 LI->RemoveMachineInstrFromMaps(PHI);
323 PHI->eraseFromParent();
324 Changed = true;
325 }
326 }
327
328 // Due to the insertion of copies to split live ranges, the live intervals are
329 // guaranteed to not overlap, except in one case: an original PHI source and a
330 // PHI destination copy. In this case, they have the same value and thus don't
331 // truly intersect, so we merge them into the value live at that point.
332 // FIXME: Is there some better way we can handle this?
333 for (DestCopyMap::iterator I = InsertedDestCopies.begin(),
334 E = InsertedDestCopies.end(); I != E; ++I) {
335 unsigned DestReg = I->first;
336 unsigned DestColor = getRegColor(DestReg);
337 unsigned NewReg = RegRenamingMap[DestColor];
338
Cameron Zwarich7c881862011-01-08 22:36:53 +0000339 LiveInterval &DestLI = LI->getInterval(DestReg);
340 LiveInterval &NewLI = LI->getInterval(NewReg);
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +0000341
Cameron Zwarich480b80a2010-12-29 03:52:51 +0000342 assert(DestLI.ranges.size() == 1
343 && "PHI destination copy's live interval should be a single live "
344 "range from the beginning of the BB to the copy instruction.");
Cameron Zwarich7c881862011-01-08 22:36:53 +0000345 LiveRange *DestLR = DestLI.begin();
346 VNInfo *NewVNI = NewLI.getVNInfoAt(DestLR->start);
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +0000347 if (!NewVNI) {
348 NewVNI = NewLI.createValueCopy(DestLR->valno, LI->getVNInfoAllocator());
Cameron Zwarich7c881862011-01-08 22:36:53 +0000349 MachineInstr *CopyInstr = I->second;
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +0000350 CopyInstr->getOperand(1).setIsKill(true);
351 }
352
353 LiveRange NewLR(DestLR->start, DestLR->end, NewVNI);
354 NewLI.addRange(NewLR);
355
356 LI->removeInterval(DestReg);
357 MRI->replaceRegWith(DestReg, NewReg);
358 }
359
Cameron Zwarich47bce432010-12-21 06:54:43 +0000360 // Adjust the live intervals of all PHI source registers to handle the case
361 // where the PHIs in successor blocks were the only later uses of the source
362 // register.
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +0000363 for (SrcCopySet::iterator I = InsertedSrcCopySet.begin(),
364 E = InsertedSrcCopySet.end(); I != E; ++I) {
Cameron Zwarich7c881862011-01-08 22:36:53 +0000365 MachineBasicBlock *MBB = I->first;
Cameron Zwarich47bce432010-12-21 06:54:43 +0000366 unsigned SrcReg = I->second;
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +0000367 if (unsigned RenamedRegister = RegRenamingMap[getRegColor(SrcReg)])
368 SrcReg = RenamedRegister;
369
Cameron Zwarich7c881862011-01-08 22:36:53 +0000370 LiveInterval &SrcLI = LI->getInterval(SrcReg);
Cameron Zwarich47bce432010-12-21 06:54:43 +0000371
372 bool isLiveOut = false;
373 for (MachineBasicBlock::succ_iterator SI = MBB->succ_begin(),
374 SE = MBB->succ_end(); SI != SE; ++SI) {
375 if (SrcLI.liveAt(LI->getMBBStartIdx(*SI))) {
376 isLiveOut = true;
377 break;
378 }
379 }
380
381 if (isLiveOut)
382 continue;
383
Cameron Zwarich7c881862011-01-08 22:36:53 +0000384 MachineOperand *LastUse = findLastUse(MBB, SrcReg);
Cameron Zwarich47bce432010-12-21 06:54:43 +0000385 assert(LastUse);
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +0000386 SlotIndex LastUseIndex = LI->getInstructionIndex(LastUse->getParent());
387 SrcLI.removeRange(LastUseIndex.getDefIndex(), LI->getMBBEndIdx(MBB));
Cameron Zwarich47bce432010-12-21 06:54:43 +0000388 LastUse->setIsKill(true);
389 }
390
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +0000391 LI->renumber();
392
393 Allocator.Reset();
394 RegNodeMap.clear();
Cameron Zwarich1558f5e2010-12-29 11:00:09 +0000395 PHISrcDefs.clear();
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +0000396 InsertedSrcCopySet.clear();
397 InsertedSrcCopyMap.clear();
398 InsertedDestCopies.clear();
399
400 return Changed;
401}
402
403void StrongPHIElimination::addReg(unsigned Reg) {
404 if (RegNodeMap.count(Reg))
405 return;
406 RegNodeMap[Reg] = new (Allocator) Node(Reg);
407}
408
409StrongPHIElimination::Node*
410StrongPHIElimination::Node::getLeader() {
Cameron Zwarich7c881862011-01-08 22:36:53 +0000411 Node *N = this;
412 Node *Parent = parent.getPointer();
413 Node *Grandparent = Parent->parent.getPointer();
Cameron Zwarich26db4582011-01-04 16:24:51 +0000414
415 while (Parent != Grandparent) {
416 N->parent.setPointer(Grandparent);
417 N = Grandparent;
418 Parent = Parent->parent.getPointer();
419 Grandparent = Parent->parent.getPointer();
420 }
421
422 return Parent;
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +0000423}
424
425unsigned StrongPHIElimination::getRegColor(unsigned Reg) {
426 DenseMap<unsigned, Node*>::iterator RI = RegNodeMap.find(Reg);
427 if (RI == RegNodeMap.end())
428 return 0;
Cameron Zwarich7c881862011-01-08 22:36:53 +0000429 Node *Node = RI->second;
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +0000430 if (Node->parent.getInt() & Node::kRegisterIsolatedFlag)
431 return 0;
432 return Node->getLeader()->value;
433}
434
435void StrongPHIElimination::unionRegs(unsigned Reg1, unsigned Reg2) {
Cameron Zwarich7c881862011-01-08 22:36:53 +0000436 Node *Node1 = RegNodeMap[Reg1]->getLeader();
437 Node *Node2 = RegNodeMap[Reg2]->getLeader();
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +0000438
439 if (Node1->rank > Node2->rank) {
440 Node2->parent.setPointer(Node1->getLeader());
441 } else if (Node1->rank < Node2->rank) {
442 Node1->parent.setPointer(Node2->getLeader());
443 } else if (Node1 != Node2) {
444 Node2->parent.setPointer(Node1->getLeader());
445 Node1->rank++;
446 }
447}
448
449void StrongPHIElimination::isolateReg(unsigned Reg) {
Cameron Zwarich7c881862011-01-08 22:36:53 +0000450 Node *Node = RegNodeMap[Reg];
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +0000451 Node->parent.setInt(Node->parent.getInt() | Node::kRegisterIsolatedFlag);
452}
453
Cameron Zwarich7c881862011-01-08 22:36:53 +0000454unsigned StrongPHIElimination::getPHIColor(MachineInstr *PHI) {
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +0000455 assert(PHI->isPHI());
456
457 unsigned DestReg = PHI->getOperand(0).getReg();
Cameron Zwarich7c881862011-01-08 22:36:53 +0000458 Node *DestNode = RegNodeMap[DestReg];
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +0000459 if (DestNode->parent.getInt() & Node::kPHIIsolatedFlag)
460 return 0;
461
462 for (unsigned i = 1; i < PHI->getNumOperands(); i += 2) {
463 unsigned SrcColor = getRegColor(PHI->getOperand(i).getReg());
464 if (SrcColor)
465 return SrcColor;
466 }
467 return 0;
468}
469
Cameron Zwarich7c881862011-01-08 22:36:53 +0000470void StrongPHIElimination::isolatePHI(MachineInstr *PHI) {
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +0000471 assert(PHI->isPHI());
Cameron Zwarich7c881862011-01-08 22:36:53 +0000472 Node *Node = RegNodeMap[PHI->getOperand(0).getReg()];
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +0000473 Node->parent.setInt(Node->parent.getInt() | Node::kPHIIsolatedFlag);
474}
475
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +0000476/// SplitInterferencesForBasicBlock - traverses a basic block, splitting any
477/// interferences found between registers in the same congruence class. It
478/// takes two DenseMaps as arguments that it also updates:
479///
480/// 1) CurrentDominatingParent, which maps a color to the register in that
481/// congruence class whose definition was most recently seen.
482///
483/// 2) ImmediateDominatingParent, which maps a register to the register in the
484/// same congruence class that most immediately dominates it.
485///
486/// This function assumes that it is being called in a depth-first traversal
487/// of the dominator tree.
488///
489/// The algorithm used here is a generalization of the dominance-based SSA test
490/// for two variables. If there are variables a_1, ..., a_n such that
491///
492/// def(a_1) dom ... dom def(a_n),
493///
494/// then we can test for an interference between any two a_i by only using O(n)
495/// interference tests between pairs of variables. If i < j and a_i and a_j
496/// interfere, then a_i is alive at def(a_j), so it is also alive at def(a_i+1).
497/// Thus, in order to test for an interference involving a_i, we need only check
498/// for a potential interference with a_i+1.
499///
500/// This method can be generalized to arbitrary sets of variables by performing
501/// a depth-first traversal of the dominator tree. As we traverse down a branch
502/// of the dominator tree, we keep track of the current dominating variable and
503/// only perform an interference test with that variable. However, when we go to
504/// another branch of the dominator tree, the definition of the current dominating
505/// variable may no longer dominate the current block. In order to correct this,
506/// we need to use a stack of past choices of the current dominating variable
507/// and pop from this stack until we find a variable whose definition actually
508/// dominates the current block.
509///
510/// There will be one push on this stack for each variable that has become the
511/// current dominating variable, so instead of using an explicit stack we can
512/// simply associate the previous choice for a current dominating variable with
513/// the new choice. This works better in our implementation, where we test for
514/// interference in multiple distinct sets at once.
515void
516StrongPHIElimination::SplitInterferencesForBasicBlock(
Cameron Zwarich7c881862011-01-08 22:36:53 +0000517 MachineBasicBlock &MBB,
518 DenseMap<unsigned, unsigned> &CurrentDominatingParent,
519 DenseMap<unsigned, unsigned> &ImmediateDominatingParent) {
Cameron Zwarich1558f5e2010-12-29 11:00:09 +0000520 // Sort defs by their order in the original basic block, as the code below
521 // assumes that it is processing definitions in dominance order.
Cameron Zwarich7c881862011-01-08 22:36:53 +0000522 std::vector<MachineInstr*> &DefInstrs = PHISrcDefs[&MBB];
Cameron Zwarich1558f5e2010-12-29 11:00:09 +0000523 std::sort(DefInstrs.begin(), DefInstrs.end(), MIIndexCompare(LI));
524
525 for (std::vector<MachineInstr*>::const_iterator BBI = DefInstrs.begin(),
526 BBE = DefInstrs.end(); BBI != BBE; ++BBI) {
527 for (MachineInstr::const_mop_iterator I = (*BBI)->operands_begin(),
528 E = (*BBI)->operands_end(); I != E; ++I) {
Cameron Zwarich7c881862011-01-08 22:36:53 +0000529 const MachineOperand &MO = *I;
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +0000530
Cameron Zwarich438e25c2010-12-28 23:02:56 +0000531 // FIXME: This would be faster if it were possible to bail out of checking
532 // an instruction's operands after the explicit defs, but this is incorrect
533 // for variadic instructions, which may appear before register allocation
534 // in the future.
535 if (!MO.isReg() || !MO.isDef())
536 continue;
537
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +0000538 unsigned DestReg = MO.getReg();
539 if (!DestReg || !TargetRegisterInfo::isVirtualRegister(DestReg))
540 continue;
541
542 // If the virtual register being defined is not used in any PHI or has
543 // already been isolated, then there are no more interferences to check.
544 unsigned DestColor = getRegColor(DestReg);
545 if (!DestColor)
546 continue;
547
548 // The input to this pass sometimes is not in SSA form in every basic
549 // block, as some virtual registers have redefinitions. We could eliminate
550 // this by fixing the passes that generate the non-SSA code, or we could
551 // handle it here by tracking defining machine instructions rather than
552 // virtual registers. For now, we just handle the situation conservatively
553 // in a way that will possibly lead to false interferences.
554 unsigned NewParent = CurrentDominatingParent[DestColor];
555 if (NewParent == DestReg)
556 continue;
557
558 // Pop registers from the stack represented by ImmediateDominatingParent
559 // until we find a parent that dominates the current instruction.
Cameron Zwarich1558f5e2010-12-29 11:00:09 +0000560 while (NewParent && (!DT->dominates(MRI->getVRegDef(NewParent), *BBI)
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +0000561 || !getRegColor(NewParent)))
562 NewParent = ImmediateDominatingParent[NewParent];
563
564 // If NewParent is nonzero, then its definition dominates the current
565 // instruction, so it is only necessary to check for the liveness of
566 // NewParent in order to check for an interference.
567 if (NewParent
Cameron Zwarich1558f5e2010-12-29 11:00:09 +0000568 && LI->getInterval(NewParent).liveAt(LI->getInstructionIndex(*BBI))) {
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +0000569 // If there is an interference, always isolate the new register. This
570 // could be improved by using a heuristic that decides which of the two
571 // registers to isolate.
572 isolateReg(DestReg);
573 CurrentDominatingParent[DestColor] = NewParent;
574 } else {
575 // If there is no interference, update ImmediateDominatingParent and set
576 // the CurrentDominatingParent for this color to the current register.
577 ImmediateDominatingParent[DestReg] = NewParent;
578 CurrentDominatingParent[DestColor] = DestReg;
579 }
Cameron Zwarich47bce432010-12-21 06:54:43 +0000580 }
581 }
582
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +0000583 // We now walk the PHIs in successor blocks and check for interferences. This
584 // is necesary because the use of a PHI's operands are logically contained in
585 // the predecessor block. The def of a PHI's destination register is processed
586 // along with the other defs in a basic block.
Cameron Zwarich47bce432010-12-21 06:54:43 +0000587
Cameron Zwarich645b1d22011-01-04 06:42:27 +0000588 CurrentPHIForColor.clear();
Cameron Zwarich47bce432010-12-21 06:54:43 +0000589
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +0000590 for (MachineBasicBlock::succ_iterator SI = MBB.succ_begin(),
591 SE = MBB.succ_end(); SI != SE; ++SI) {
592 for (MachineBasicBlock::iterator BBI = (*SI)->begin(), BBE = (*SI)->end();
593 BBI != BBE && BBI->isPHI(); ++BBI) {
Cameron Zwarich7c881862011-01-08 22:36:53 +0000594 MachineInstr *PHI = BBI;
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +0000595
596 // If a PHI is already isolated, either by being isolated directly or
597 // having all of its operands isolated, ignore it.
598 unsigned Color = getPHIColor(PHI);
599 if (!Color)
600 continue;
601
602 // Find the index of the PHI operand that corresponds to this basic block.
603 unsigned PredIndex;
604 for (PredIndex = 1; PredIndex < PHI->getNumOperands(); PredIndex += 2) {
605 if (PHI->getOperand(PredIndex + 1).getMBB() == &MBB)
606 break;
607 }
608 assert(PredIndex < PHI->getNumOperands());
609 unsigned PredOperandReg = PHI->getOperand(PredIndex).getReg();
610
611 // Pop registers from the stack represented by ImmediateDominatingParent
612 // until we find a parent that dominates the current instruction.
613 unsigned NewParent = CurrentDominatingParent[Color];
614 while (NewParent
615 && (!DT->dominates(MRI->getVRegDef(NewParent)->getParent(), &MBB)
616 || !getRegColor(NewParent)))
617 NewParent = ImmediateDominatingParent[NewParent];
618 CurrentDominatingParent[Color] = NewParent;
619
620 // If there is an interference with a register, always isolate the
621 // register rather than the PHI. It is also possible to isolate the
622 // PHI, but that introduces copies for all of the registers involved
623 // in that PHI.
624 if (NewParent && LI->isLiveOutOfMBB(LI->getInterval(NewParent), &MBB)
625 && NewParent != PredOperandReg)
626 isolateReg(NewParent);
627
628 std::pair<MachineInstr*, unsigned> CurrentPHI = CurrentPHIForColor[Color];
629
630 // If two PHIs have the same operand from every shared predecessor, then
631 // they don't actually interfere. Otherwise, isolate the current PHI. This
632 // could possibly be improved, e.g. we could isolate the PHI with the
633 // fewest operands.
634 if (CurrentPHI.first && CurrentPHI.second != PredOperandReg)
635 isolatePHI(PHI);
636 else
637 CurrentPHIForColor[Color] = std::make_pair(PHI, PredOperandReg);
638 }
639 }
Cameron Zwarich47bce432010-12-21 06:54:43 +0000640}
641
Cameron Zwarich7c881862011-01-08 22:36:53 +0000642void StrongPHIElimination::InsertCopiesForPHI(MachineInstr *PHI,
643 MachineBasicBlock *MBB) {
Cameron Zwarich47bce432010-12-21 06:54:43 +0000644 assert(PHI->isPHI());
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +0000645 unsigned PHIColor = getPHIColor(PHI);
646
647 for (unsigned i = 1; i < PHI->getNumOperands(); i += 2) {
Cameron Zwarich7c881862011-01-08 22:36:53 +0000648 MachineOperand &SrcMO = PHI->getOperand(i);
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +0000649
650 // If a source is defined by an implicit def, there is no need to insert a
651 // copy in the predecessor.
652 if (SrcMO.isUndef())
653 continue;
654
655 unsigned SrcReg = SrcMO.getReg();
656 assert(TargetRegisterInfo::isVirtualRegister(SrcReg) &&
657 "Machine PHI Operands must all be virtual registers!");
658
Cameron Zwarich7c881862011-01-08 22:36:53 +0000659 MachineBasicBlock *PredBB = PHI->getOperand(i + 1).getMBB();
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +0000660 unsigned SrcColor = getRegColor(SrcReg);
661
662 // If neither the PHI nor the operand were isolated, then we only need to
663 // set the phi-kill flag on the VNInfo at this PHI.
664 if (PHIColor && SrcColor == PHIColor) {
Cameron Zwarich7c881862011-01-08 22:36:53 +0000665 LiveInterval &SrcInterval = LI->getInterval(SrcReg);
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +0000666 SlotIndex PredIndex = LI->getMBBEndIdx(PredBB);
Cameron Zwarich7c881862011-01-08 22:36:53 +0000667 VNInfo *SrcVNI = SrcInterval.getVNInfoAt(PredIndex.getPrevIndex());
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +0000668 assert(SrcVNI);
669 SrcVNI->setHasPHIKill(true);
670 continue;
671 }
672
673 unsigned CopyReg = 0;
674 if (PHIColor) {
675 SrcCopyMap::const_iterator I
676 = InsertedSrcCopyMap.find(std::make_pair(PredBB, PHIColor));
677 CopyReg
678 = I != InsertedSrcCopyMap.end() ? I->second->getOperand(0).getReg() : 0;
679 }
680
681 if (!CopyReg) {
Cameron Zwarich7c881862011-01-08 22:36:53 +0000682 const TargetRegisterClass *RC = MRI->getRegClass(SrcReg);
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +0000683 CopyReg = MRI->createVirtualRegister(RC);
684
685 MachineBasicBlock::iterator
686 CopyInsertPoint = findPHICopyInsertPoint(PredBB, MBB, SrcReg);
687 unsigned SrcSubReg = SrcMO.getSubReg();
Cameron Zwarich7c881862011-01-08 22:36:53 +0000688 MachineInstr *CopyInstr = BuildMI(*PredBB,
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +0000689 CopyInsertPoint,
690 PHI->getDebugLoc(),
691 TII->get(TargetOpcode::COPY),
692 CopyReg).addReg(SrcReg, 0, SrcSubReg);
693 LI->InsertMachineInstrInMaps(CopyInstr);
694
695 // addLiveRangeToEndOfBlock() also adds the phikill flag to the VNInfo for
696 // the newly added range.
697 LI->addLiveRangeToEndOfBlock(CopyReg, CopyInstr);
698 InsertedSrcCopySet.insert(std::make_pair(PredBB, SrcReg));
699
700 addReg(CopyReg);
701 if (PHIColor) {
702 unionRegs(PHIColor, CopyReg);
703 assert(getRegColor(CopyReg) != CopyReg);
704 } else {
705 PHIColor = CopyReg;
706 assert(getRegColor(CopyReg) == CopyReg);
707 }
708
709 if (!InsertedSrcCopyMap.count(std::make_pair(PredBB, PHIColor)))
710 InsertedSrcCopyMap[std::make_pair(PredBB, PHIColor)] = CopyInstr;
711 }
712
713 SrcMO.setReg(CopyReg);
714
715 // If SrcReg is not live beyond the PHI, trim its interval so that it is no
716 // longer live-in to MBB. Note that SrcReg may appear in other PHIs that are
717 // processed later, but this is still correct to do at this point because we
718 // never rely on LiveIntervals being correct while inserting copies.
719 // FIXME: Should this just count uses at PHIs like the normal PHIElimination
720 // pass does?
Cameron Zwarich7c881862011-01-08 22:36:53 +0000721 LiveInterval &SrcLI = LI->getInterval(SrcReg);
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +0000722 SlotIndex MBBStartIndex = LI->getMBBStartIdx(MBB);
723 SlotIndex PHIIndex = LI->getInstructionIndex(PHI);
724 SlotIndex NextInstrIndex = PHIIndex.getNextIndex();
725 if (SrcLI.liveAt(MBBStartIndex) && SrcLI.expiredAt(NextInstrIndex))
726 SrcLI.removeRange(MBBStartIndex, PHIIndex, true);
727 }
728
Cameron Zwarich47bce432010-12-21 06:54:43 +0000729 unsigned DestReg = PHI->getOperand(0).getReg();
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +0000730 unsigned DestColor = getRegColor(DestReg);
731
732 if (PHIColor && DestColor == PHIColor) {
Cameron Zwarich7c881862011-01-08 22:36:53 +0000733 LiveInterval &DestLI = LI->getInterval(DestReg);
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +0000734
735 // Set the phi-def flag for the VN at this PHI.
736 SlotIndex PHIIndex = LI->getInstructionIndex(PHI);
Cameron Zwarich7c881862011-01-08 22:36:53 +0000737 VNInfo *DestVNI = DestLI.getVNInfoAt(PHIIndex.getDefIndex());
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +0000738 assert(DestVNI);
739 DestVNI->setIsPHIDef(true);
740
741 // Prior to PHI elimination, the live ranges of PHIs begin at their defining
742 // instruction. After PHI elimination, PHI instructions are replaced by VNs
743 // with the phi-def flag set, and the live ranges of these VNs start at the
744 // beginning of the basic block.
745 SlotIndex MBBStartIndex = LI->getMBBStartIdx(MBB);
746 DestVNI->def = MBBStartIndex;
747 DestLI.addRange(LiveRange(MBBStartIndex,
748 PHIIndex.getDefIndex(),
749 DestVNI));
750 return;
751 }
Cameron Zwarich47bce432010-12-21 06:54:43 +0000752
Cameron Zwarich7c881862011-01-08 22:36:53 +0000753 const TargetRegisterClass *RC = MRI->getRegClass(DestReg);
Cameron Zwarich47bce432010-12-21 06:54:43 +0000754 unsigned CopyReg = MRI->createVirtualRegister(RC);
755
Cameron Zwarich7c881862011-01-08 22:36:53 +0000756 MachineInstr *CopyInstr = BuildMI(*MBB,
Cameron Zwarich47bce432010-12-21 06:54:43 +0000757 MBB->SkipPHIsAndLabels(MBB->begin()),
758 PHI->getDebugLoc(),
759 TII->get(TargetOpcode::COPY),
760 DestReg).addReg(CopyReg);
761 LI->InsertMachineInstrInMaps(CopyInstr);
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +0000762 PHI->getOperand(0).setReg(CopyReg);
Cameron Zwarich47bce432010-12-21 06:54:43 +0000763
764 // Add the region from the beginning of MBB to the copy instruction to
765 // CopyReg's live interval, and give the VNInfo the phidef flag.
Cameron Zwarich7c881862011-01-08 22:36:53 +0000766 LiveInterval &CopyLI = LI->getOrCreateInterval(CopyReg);
Cameron Zwarich47bce432010-12-21 06:54:43 +0000767 SlotIndex MBBStartIndex = LI->getMBBStartIdx(MBB);
768 SlotIndex DestCopyIndex = LI->getInstructionIndex(CopyInstr);
Cameron Zwarich7c881862011-01-08 22:36:53 +0000769 VNInfo *CopyVNI = CopyLI.getNextValue(MBBStartIndex,
Cameron Zwarich47bce432010-12-21 06:54:43 +0000770 CopyInstr,
771 LI->getVNInfoAllocator());
772 CopyVNI->setIsPHIDef(true);
773 CopyLI.addRange(LiveRange(MBBStartIndex,
774 DestCopyIndex.getDefIndex(),
775 CopyVNI));
776
777 // Adjust DestReg's live interval to adjust for its new definition at
778 // CopyInstr.
Cameron Zwarich7c881862011-01-08 22:36:53 +0000779 LiveInterval &DestLI = LI->getOrCreateInterval(DestReg);
Cameron Zwarich47bce432010-12-21 06:54:43 +0000780 SlotIndex PHIIndex = LI->getInstructionIndex(PHI);
781 DestLI.removeRange(PHIIndex.getDefIndex(), DestCopyIndex.getDefIndex());
782
Cameron Zwarich7c881862011-01-08 22:36:53 +0000783 VNInfo *DestVNI = DestLI.getVNInfoAt(DestCopyIndex.getDefIndex());
Cameron Zwarich47bce432010-12-21 06:54:43 +0000784 assert(DestVNI);
785 DestVNI->def = DestCopyIndex.getDefIndex();
786
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +0000787 InsertedDestCopies[CopyReg] = CopyInstr;
788}
Cameron Zwarichef485d82010-12-24 03:09:36 +0000789
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +0000790void StrongPHIElimination::MergeLIsAndRename(unsigned Reg, unsigned NewReg) {
791 if (Reg == NewReg)
792 return;
Cameron Zwarichef485d82010-12-24 03:09:36 +0000793
Cameron Zwarich7c881862011-01-08 22:36:53 +0000794 LiveInterval &OldLI = LI->getInterval(Reg);
795 LiveInterval &NewLI = LI->getInterval(NewReg);
Cameron Zwarich47bce432010-12-21 06:54:43 +0000796
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +0000797 // Merge the live ranges of the two registers.
798 DenseMap<VNInfo*, VNInfo*> VNMap;
799 for (LiveInterval::iterator LRI = OldLI.begin(), LRE = OldLI.end();
800 LRI != LRE; ++LRI) {
801 LiveRange OldLR = *LRI;
Cameron Zwarich7c881862011-01-08 22:36:53 +0000802 VNInfo *OldVN = OldLR.valno;
Cameron Zwarich47bce432010-12-21 06:54:43 +0000803
Cameron Zwarich7c881862011-01-08 22:36:53 +0000804 VNInfo *&NewVN = VNMap[OldVN];
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +0000805 if (!NewVN) {
806 NewVN = NewLI.createValueCopy(OldVN, LI->getVNInfoAllocator());
807 VNMap[OldVN] = NewVN;
808 }
Cameron Zwarich47bce432010-12-21 06:54:43 +0000809
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +0000810 LiveRange LR(OldLR.start, OldLR.end, NewVN);
811 NewLI.addRange(LR);
Cameron Zwarich47bce432010-12-21 06:54:43 +0000812 }
Cameron Zwarich4e7f23b2010-12-27 10:08:19 +0000813
814 // Remove the LiveInterval for the register being renamed and replace all
815 // of its defs and uses with the new register.
816 LI->removeInterval(Reg);
817 MRI->replaceRegWith(Reg, NewReg);
Cameron Zwarich9eaf49b2010-12-05 22:34:08 +0000818}