From lattner at cs.uiuc.edu Mon Jul 19 00:02:19 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 19 Jul 2004 00:02:19 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/RegAllocLinearScan.cpp Message-ID: <200407190502.AAA03233@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: RegAllocLinearScan.cpp updated: 1.78 -> 1.79 --- Log message: Fix assertion to not dereference end! --- Diffs of the changes: (+2 -2) Index: llvm/lib/CodeGen/RegAllocLinearScan.cpp diff -u llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.78 llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.79 --- llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.78 Sun Jul 18 23:47:36 2004 +++ llvm/lib/CodeGen/RegAllocLinearScan.cpp Mon Jul 19 00:02:09 2004 @@ -399,8 +399,8 @@ std::vector::iterator addedItEnd = added.end(); for (IntervalPtrs::iterator i = unhandled_.begin(), e =unhandled_.end(); i != e && addedIt != addedItEnd; ++i) { - while ((*i)->start() > (*addedIt)->start() && - addedIt != addedItEnd) { + while (addedIt != addedItEnd && + (*i)->start() > (*addedIt)->start()) { #ifndef NDEBUG // This code only works if addIntervalsForSpills retursn a // sorted interval list. Assert this is the case now. From lattner at cs.uiuc.edu Mon Jul 19 00:15:20 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 19 Jul 2004 00:15:20 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervals.cpp Message-ID: <200407190515.AAA04391@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveIntervals.cpp updated: 1.90 -> 1.91 --- Log message: See comments. The live intervals were not coming out of the spiller in sorted order, causing the inactive list in the linearscan list to get unsorted, which basically fuxored everything up severely. These seems to fix the joiner, so with more testing I will enable it by default. --- Diffs of the changes: (+20 -1) Index: llvm/lib/CodeGen/LiveIntervals.cpp diff -u llvm/lib/CodeGen/LiveIntervals.cpp:1.90 llvm/lib/CodeGen/LiveIntervals.cpp:1.91 --- llvm/lib/CodeGen/LiveIntervals.cpp:1.90 Sun Jul 18 21:15:56 2004 +++ llvm/lib/CodeGen/LiveIntervals.cpp Mon Jul 19 00:15:10 2004 @@ -185,6 +185,16 @@ return true; } +namespace { + /// CompareIntervalStar - This is a simple comparison function for interval + /// pointers. It compares based on their starting point. + struct CompareIntervalStar { + bool operator()(LiveInterval *LHS, LiveInterval* RHS) const { + return LHS->start() < RHS->start(); + } + }; +} + std::vector LiveIntervals::addIntervalsForSpills( const LiveInterval& li, VirtRegMap& vrm, @@ -210,7 +220,7 @@ MachineBasicBlock::iterator mi = getInstructionFromIndex(index); for_operand: - for (unsigned i = 0; i < mi->getNumOperands(); ++i) { + for (unsigned i = 0; i != mi->getNumOperands(); ++i) { MachineOperand& mop = mi->getOperand(i); if (mop.isRegister() && mop.getReg() == li.reg) { if (MachineInstr* fmi = @@ -267,6 +277,15 @@ } } + // FIXME: This method MUST return intervals in sorted order. If a + // particular machine instruction both uses and defines the vreg being + // spilled (e.g., vr = vr + 1) and if the def is processed before the + // use, the list ends up not sorted. + // + // The proper way to fix this is to process all uses of the vreg before we + // process any defs. However, this would require refactoring the above + // blob of code, which I'm not feeling up to right now. + std::sort(added.begin(), added.end(), CompareIntervalStar()); return added; } From lattner at cs.uiuc.edu Mon Jul 19 00:56:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 19 Jul 2004 00:56:01 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervals.cpp Message-ID: <200407190556.AAA07894@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveIntervals.cpp updated: 1.91 -> 1.92 --- Log message: Two changes, both very significant: * vreg <-> vreg joining now works, enable it unconditionally when joining is enabled (which is the default). * Fix a serious pessimization of spill code where we were saying that a spilled DEF operand was live into the subsequent instruction. This allows for substantially better code when spilling starts to happen. --- Diffs of the changes: (+2 -11) Index: llvm/lib/CodeGen/LiveIntervals.cpp diff -u llvm/lib/CodeGen/LiveIntervals.cpp:1.91 llvm/lib/CodeGen/LiveIntervals.cpp:1.92 --- llvm/lib/CodeGen/LiveIntervals.cpp:1.91 Mon Jul 19 00:15:10 2004 +++ llvm/lib/CodeGen/LiveIntervals.cpp Mon Jul 19 00:55:50 2004 @@ -60,11 +60,6 @@ EnableJoining("join-liveintervals", cl::desc("Join compatible live intervals"), cl::init(true)); - - cl::opt - EnableVirtVirtJoining("join-liveintervals-virtvirtjoining", - cl::desc("Join live intervals for virtreg pairs (buggy)"), - cl::init(false)); }; void LiveIntervals::getAnalysisUsage(AnalysisUsage &AU) const @@ -251,7 +246,7 @@ // use of the next instruction. Otherwise we end // after the use of this instruction. unsigned end = 1 + (mop.isDef() ? - getUseIndex(index+InstrSlots::NUM) : + getStoreIndex(index) : getUseIndex(index)); // create a new register for this spill @@ -545,11 +540,7 @@ Intervals::iterator intB = r2iB->second; // both A and B are virtual registers - - // FIXME: coallescing two virtual registers together is - // apparently broken. - if (EnableVirtVirtJoining && - MRegisterInfo::isVirtualRegister(intA->reg) && + if (MRegisterInfo::isVirtualRegister(intA->reg) && MRegisterInfo::isVirtualRegister(intB->reg)) { const TargetRegisterClass *rcA, *rcB; From lattner at cs.uiuc.edu Mon Jul 19 01:00:28 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 19 Jul 2004 01:00:28 -0500 Subject: [llvm-commits] CVS: llvm/lib/Support/ToolRunner.cpp Message-ID: <200407190600.BAA08171@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Support: ToolRunner.cpp updated: 1.25 -> 1.26 --- Log message: Fix bugpoint miscompilation support on OS/X Patch contributed by the fabulous Nate Begeman. --- Diffs of the changes: (+3 -1) Index: llvm/lib/Support/ToolRunner.cpp diff -u llvm/lib/Support/ToolRunner.cpp:1.25 llvm/lib/Support/ToolRunner.cpp:1.26 --- llvm/lib/Support/ToolRunner.cpp:1.25 Fri Jul 16 14:45:45 2004 +++ llvm/lib/Support/ToolRunner.cpp Mon Jul 19 01:00:17 2004 @@ -406,7 +406,9 @@ #elif (defined(__POWERPC__) || defined(__ppc__)) && defined(__APPLE__) "-dynamiclib", // `-dynamiclib' for MacOS X/PowerPC "-fno-common", // allow global vars w/o initializers to live - // in data segment, rather than generating blocks + // in data segment, rather than generating + "dynamic_lookup", // blocks. dynamic_lookup requires that you set + // MACOSX_DEPLOYMENT_TARGET=10.3 in your env. #else "-shared", // `-shared' for Linux/X86, maybe others #endif From lattner at cs.uiuc.edu Mon Jul 19 01:04:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 19 Jul 2004 01:04:01 -0500 Subject: [llvm-commits] CVS: llvm/lib/Support/ToolRunner.cpp Message-ID: <200407190604.BAA08191@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Support: ToolRunner.cpp updated: 1.26 -> 1.27 --- Log message: Err, fix last checkin --- Diffs of the changes: (+1 -1) Index: llvm/lib/Support/ToolRunner.cpp diff -u llvm/lib/Support/ToolRunner.cpp:1.26 llvm/lib/Support/ToolRunner.cpp:1.27 --- llvm/lib/Support/ToolRunner.cpp:1.26 Mon Jul 19 01:00:17 2004 +++ llvm/lib/Support/ToolRunner.cpp Mon Jul 19 01:03:51 2004 @@ -406,7 +406,7 @@ #elif (defined(__POWERPC__) || defined(__ppc__)) && defined(__APPLE__) "-dynamiclib", // `-dynamiclib' for MacOS X/PowerPC "-fno-common", // allow global vars w/o initializers to live - // in data segment, rather than generating + "-undefined", // in data segment, rather than generating "dynamic_lookup", // blocks. dynamic_lookup requires that you set // MACOSX_DEPLOYMENT_TARGET=10.3 in your env. #else From lattner at cs.uiuc.edu Mon Jul 19 01:26:56 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 19 Jul 2004 01:26:56 -0500 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/LiveVariables.h Message-ID: <200407190626.BAA19859@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: LiveVariables.h updated: 1.15 -> 1.16 --- Log message: Remove the DefBlock element of VarInfo. DefBlock is always DefInst->getParent() --- Diffs of the changes: (+2 -3) Index: llvm/include/llvm/CodeGen/LiveVariables.h diff -u llvm/include/llvm/CodeGen/LiveVariables.h:1.15 llvm/include/llvm/CodeGen/LiveVariables.h:1.16 --- llvm/include/llvm/CodeGen/LiveVariables.h:1.15 Thu Jul 1 01:14:57 2004 +++ llvm/include/llvm/CodeGen/LiveVariables.h Mon Jul 19 01:26:45 2004 @@ -39,8 +39,7 @@ class LiveVariables : public MachineFunctionPass { public: struct VarInfo { - /// DefBlock - The basic block which defines this value... - MachineBasicBlock *DefBlock; + /// DefInst - The machine instruction that defines this register. MachineInstr *DefInst; /// AliveBlocks - Set of blocks of which this value is alive completely @@ -55,7 +54,7 @@ /// std::vector > Kills; - VarInfo() : DefBlock(0), DefInst(0) {} + VarInfo() : DefInst(0) {} /// removeKill - Delete a kill corresponding to the specified /// machine instruction. Returns true if there was a kill From lattner at cs.uiuc.edu Mon Jul 19 01:27:00 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 19 Jul 2004 01:27:00 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveVariables.cpp Message-ID: <200407190627.BAA19866@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveVariables.cpp updated: 1.37 -> 1.38 --- Log message: Remove the DefBlock element of VarInfo. DefBlock is always DefInst->getParent() --- Diffs of the changes: (+4 -4) Index: llvm/lib/CodeGen/LiveVariables.cpp diff -u llvm/lib/CodeGen/LiveVariables.cpp:1.37 llvm/lib/CodeGen/LiveVariables.cpp:1.38 --- llvm/lib/CodeGen/LiveVariables.cpp:1.37 Fri Jul 9 11:44:37 2004 +++ llvm/lib/CodeGen/LiveVariables.cpp Mon Jul 19 01:26:50 2004 @@ -64,7 +64,7 @@ break; } - if (MBB == VRInfo.DefBlock) return; // Terminate recursion + if (MBB == VRInfo.DefInst->getParent()) return; // Terminate recursion if (VRInfo.AliveBlocks.size() <= BBNum) VRInfo.AliveBlocks.resize(BBNum+1); // Make space... @@ -95,7 +95,8 @@ assert(VRInfo.Kills[i].first != MBB && "entry should be at end!"); #endif - assert(MBB != VRInfo.DefBlock && "Should have kill for defblock!"); + assert(MBB != VRInfo.DefInst->getParent() && + "Should have kill for defblock!"); // Add a new kill entry for this basic block. VRInfo.Kills.push_back(std::make_pair(MBB, MI)); @@ -230,8 +231,7 @@ if (MRegisterInfo::isVirtualRegister(MO.getReg())) { VarInfo &VRInfo = getVarInfo(MO.getReg()); - assert(VRInfo.DefBlock == 0 && "Variable multiply defined!"); - VRInfo.DefBlock = MBB; // Created here... + assert(VRInfo.DefInst == 0 && "Variable multiply defined!"); VRInfo.DefInst = MI; VRInfo.Kills.push_back(std::make_pair(MBB, MI)); // Defaults to dead } else if (MRegisterInfo::isPhysicalRegister(MO.getReg()) && From lattner at cs.uiuc.edu Mon Jul 19 01:55:27 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 19 Jul 2004 01:55:27 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervals.cpp LiveVariables.cpp PHIElimination.cpp TwoAddressInstructionPass.cpp Message-ID: <200407190655.BAA30469@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveIntervals.cpp updated: 1.92 -> 1.93 LiveVariables.cpp updated: 1.38 -> 1.39 PHIElimination.cpp updated: 1.28 -> 1.29 TwoAddressInstructionPass.cpp updated: 1.20 -> 1.21 --- Log message: Simplify the interface to LiveVariables::addVirtualRegister(Killed|Dead) --- Diffs of the changes: (+10 -9) Index: llvm/lib/CodeGen/LiveIntervals.cpp diff -u llvm/lib/CodeGen/LiveIntervals.cpp:1.92 llvm/lib/CodeGen/LiveIntervals.cpp:1.93 --- llvm/lib/CodeGen/LiveIntervals.cpp:1.92 Mon Jul 19 00:55:50 2004 +++ llvm/lib/CodeGen/LiveIntervals.cpp Mon Jul 19 01:55:17 2004 @@ -263,7 +263,7 @@ nI.addRange(start, end); added.push_back(&nI); // update live variables - lv_->addVirtualRegisterKilled(nReg, mi->getParent(),mi); + lv_->addVirtualRegisterKilled(nReg, mi); DEBUG(std::cerr << "\t\t\t\tadded new interval: " << nI << '\n'); } Index: llvm/lib/CodeGen/LiveVariables.cpp diff -u llvm/lib/CodeGen/LiveVariables.cpp:1.38 llvm/lib/CodeGen/LiveVariables.cpp:1.39 --- llvm/lib/CodeGen/LiveVariables.cpp:1.38 Mon Jul 19 01:26:50 2004 +++ llvm/lib/CodeGen/LiveVariables.cpp Mon Jul 19 01:55:17 2004 @@ -99,7 +99,7 @@ "Should have kill for defblock!"); // Add a new kill entry for this basic block. - VRInfo.Kills.push_back(std::make_pair(MBB, MI)); + VRInfo.Kills.push_back(std::make_pair(MI->getParent(), MI)); // Update all dominating blocks to mark them known live. const BasicBlock *BB = MBB->getBasicBlock(); @@ -233,7 +233,8 @@ assert(VRInfo.DefInst == 0 && "Variable multiply defined!"); VRInfo.DefInst = MI; - VRInfo.Kills.push_back(std::make_pair(MBB, MI)); // Defaults to dead + // Defaults to dead + VRInfo.Kills.push_back(std::make_pair(MI->getParent(), MI)); } else if (MRegisterInfo::isPhysicalRegister(MO.getReg()) && AllocatablePhysicalRegisters[MO.getReg()]) { HandlePhysRegDef(MO.getReg(), MI); Index: llvm/lib/CodeGen/PHIElimination.cpp diff -u llvm/lib/CodeGen/PHIElimination.cpp:1.28 llvm/lib/CodeGen/PHIElimination.cpp:1.29 --- llvm/lib/CodeGen/PHIElimination.cpp:1.28 Wed Jun 30 23:29:47 2004 +++ llvm/lib/CodeGen/PHIElimination.cpp Mon Jul 19 01:55:17 2004 @@ -122,7 +122,7 @@ // each for each incoming block), the "def" block and instruction fields // for the VarInfo is not filled in. // - LV->addVirtualRegisterKilled(IncomingReg, &MBB, PHICopy); + LV->addVirtualRegisterKilled(IncomingReg, PHICopy); // Since we are going to be deleting the PHI node, if it is the last use // of any registers, or if the value itself is dead, we need to move this @@ -140,7 +140,7 @@ // Add all of the kills back, which will update the appropriate info... for (unsigned i = 0, e = Range.size(); i != e; ++i) - LV->addVirtualRegisterKilled(Range[i].second, &MBB, PHICopy); + LV->addVirtualRegisterKilled(Range[i].second, PHICopy); } RKs = LV->dead_range(MI); @@ -149,7 +149,7 @@ Range.assign(RKs.first, RKs.second); LV->removeVirtualRegistersDead(RKs.first, RKs.second); for (unsigned i = 0, e = Range.size(); i != e; ++i) - LV->addVirtualRegisterDead(Range[i].second, &MBB, PHICopy); + LV->addVirtualRegisterDead(Range[i].second, PHICopy); } } @@ -251,7 +251,7 @@ // if (!ValueIsLive) { MachineBasicBlock::iterator Prev = prior(I); - LV->addVirtualRegisterKilled(SrcReg, &opBlock, Prev); + LV->addVirtualRegisterKilled(SrcReg, Prev); } } } Index: llvm/lib/CodeGen/TwoAddressInstructionPass.cpp diff -u llvm/lib/CodeGen/TwoAddressInstructionPass.cpp:1.20 llvm/lib/CodeGen/TwoAddressInstructionPass.cpp:1.21 --- llvm/lib/CodeGen/TwoAddressInstructionPass.cpp:1.20 Thu Jun 24 19:13:11 2004 +++ llvm/lib/CodeGen/TwoAddressInstructionPass.cpp Mon Jul 19 01:55:17 2004 @@ -151,10 +151,10 @@ // update live variables for regB if (LV->removeVirtualRegisterKilled(regB, &*mbbi, mi)) - LV->addVirtualRegisterKilled(regB, &*mbbi, prevMi); + LV->addVirtualRegisterKilled(regB, prevMi); if (LV->removeVirtualRegisterDead(regB, &*mbbi, mi)) - LV->addVirtualRegisterDead(regB, &*mbbi, prevMi); + LV->addVirtualRegisterDead(regB, prevMi); } // replace all occurences of regB with regA From lattner at cs.uiuc.edu Mon Jul 19 01:55:32 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 19 Jul 2004 01:55:32 -0500 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/LiveVariables.h Message-ID: <200407190655.BAA30476@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: LiveVariables.h updated: 1.16 -> 1.17 --- Log message: Simplify the interface to LiveVariables::addVirtualRegister(Killed|Dead) --- Diffs of the changes: (+4 -8) Index: llvm/include/llvm/CodeGen/LiveVariables.h diff -u llvm/include/llvm/CodeGen/LiveVariables.h:1.16 llvm/include/llvm/CodeGen/LiveVariables.h:1.17 --- llvm/include/llvm/CodeGen/LiveVariables.h:1.16 Mon Jul 19 01:26:45 2004 +++ llvm/include/llvm/CodeGen/LiveVariables.h Mon Jul 19 01:55:21 2004 @@ -151,11 +151,9 @@ /// specified register is killed after being used by the specified /// instruction. /// - void addVirtualRegisterKilled(unsigned IncomingReg, - MachineBasicBlock *MBB, - MachineInstr *MI) { + void addVirtualRegisterKilled(unsigned IncomingReg, MachineInstr *MI) { RegistersKilled.insert(std::make_pair(MI, IncomingReg)); - getVarInfo(IncomingReg).Kills.push_back(std::make_pair(MBB, MI)); + getVarInfo(IncomingReg).Kills.push_back(std::make_pair(MI->getParent(),MI)); } /// removeVirtualRegisterKilled - Remove the specified virtual @@ -189,11 +187,9 @@ /// addVirtualRegisterDead - Add information about the fact that the specified /// register is dead after being used by the specified instruction. /// - void addVirtualRegisterDead(unsigned IncomingReg, - MachineBasicBlock *MBB, - MachineInstr *MI) { + void addVirtualRegisterDead(unsigned IncomingReg, MachineInstr *MI) { RegistersDead.insert(std::make_pair(MI, IncomingReg)); - getVarInfo(IncomingReg).Kills.push_back(std::make_pair(MBB, MI)); + getVarInfo(IncomingReg).Kills.push_back(std::make_pair(MI->getParent(),MI)); } /// removeVirtualRegisterDead - Remove the specified virtual From lattner at cs.uiuc.edu Mon Jul 19 02:04:58 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 19 Jul 2004 02:04:58 -0500 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/LiveVariables.h Message-ID: <200407190704.CAA01015@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: LiveVariables.h updated: 1.17 -> 1.18 --- Log message: There is no need to store the MBB along with the MI any more, we can now ask instructions for their parent. --- Diffs of the changes: (+8 -10) Index: llvm/include/llvm/CodeGen/LiveVariables.h diff -u llvm/include/llvm/CodeGen/LiveVariables.h:1.17 llvm/include/llvm/CodeGen/LiveVariables.h:1.18 --- llvm/include/llvm/CodeGen/LiveVariables.h:1.17 Mon Jul 19 01:55:21 2004 +++ llvm/include/llvm/CodeGen/LiveVariables.h Mon Jul 19 02:04:48 2004 @@ -48,11 +48,10 @@ /// std::vector AliveBlocks; - /// Kills - List of MachineBasicblock's which contain the last use of this - /// virtual register (kill it). This also includes the specific instruction - /// which kills the value. + /// Kills - List of MachineInstruction's which are the last use of this + /// virtual register (kill it) in their basic block. /// - std::vector > Kills; + std::vector Kills; VarInfo() : DefInst(0) {} @@ -60,13 +59,12 @@ /// machine instruction. Returns true if there was a kill /// corresponding to this instruction, false otherwise. bool removeKill(MachineInstr *MI) { - for (std::vector >::iterator - i = Kills.begin(); i != Kills.end(); ++i) { - if (i->second == MI) { + for (std::vector::iterator i = Kills.begin(), + e = Kills.end(); i != e; ++i) + if (*i == MI) { Kills.erase(i); return true; } - } return false; } }; @@ -153,7 +151,7 @@ /// void addVirtualRegisterKilled(unsigned IncomingReg, MachineInstr *MI) { RegistersKilled.insert(std::make_pair(MI, IncomingReg)); - getVarInfo(IncomingReg).Kills.push_back(std::make_pair(MI->getParent(),MI)); + getVarInfo(IncomingReg).Kills.push_back(MI); } /// removeVirtualRegisterKilled - Remove the specified virtual @@ -189,7 +187,7 @@ /// void addVirtualRegisterDead(unsigned IncomingReg, MachineInstr *MI) { RegistersDead.insert(std::make_pair(MI, IncomingReg)); - getVarInfo(IncomingReg).Kills.push_back(std::make_pair(MI->getParent(),MI)); + getVarInfo(IncomingReg).Kills.push_back(MI); } /// removeVirtualRegisterDead - Remove the specified virtual From lattner at cs.uiuc.edu Mon Jul 19 02:05:06 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 19 Jul 2004 02:05:06 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervals.cpp LiveVariables.cpp PHIElimination.cpp Message-ID: <200407190705.CAA01033@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveIntervals.cpp updated: 1.93 -> 1.94 LiveVariables.cpp updated: 1.39 -> 1.40 PHIElimination.cpp updated: 1.29 -> 1.30 --- Log message: There is no need to store the MBB along with the MI any more, we can now ask instructions for their parent. --- Diffs of the changes: (+16 -16) Index: llvm/lib/CodeGen/LiveIntervals.cpp diff -u llvm/lib/CodeGen/LiveIntervals.cpp:1.93 llvm/lib/CodeGen/LiveIntervals.cpp:1.94 --- llvm/lib/CodeGen/LiveIntervals.cpp:1.93 Mon Jul 19 01:55:17 2004 +++ llvm/lib/CodeGen/LiveIntervals.cpp Mon Jul 19 02:04:55 2004 @@ -311,11 +311,11 @@ // two cases we have to handle here. The most common case is a vreg // whose lifetime is contained within a basic block. In this case there // will be a single kill, in MBB, which comes after the definition. - if (vi.Kills.size() == 1 && vi.Kills[0].first == mbb) { + if (vi.Kills.size() == 1 && vi.Kills[0]->getParent() == mbb) { // FIXME: what about dead vars? unsigned killIdx; - if (vi.Kills[0].second != mi) - killIdx = getUseIndex(getInstructionIndex(vi.Kills[0].second))+1; + if (vi.Kills[0] != mi) + killIdx = getUseIndex(getInstructionIndex(vi.Kills[0]))+1; else killIdx = defIndex+1; @@ -353,9 +353,9 @@ // Finally, this virtual register is live from the start of any killing // block to the 'use' slot of the killing instruction. for (unsigned i = 0, e = vi.Kills.size(); i != e; ++i) { - std::pair &Kill = vi.Kills[i]; - interval.addRange(getInstructionIndex(Kill.first->begin()), - getUseIndex(getInstructionIndex(Kill.second))+1); + MachineInstr *Kill = vi.Kills[i]; + interval.addRange(getInstructionIndex(Kill->getParent()->begin()), + getUseIndex(getInstructionIndex(Kill))+1); } } else { Index: llvm/lib/CodeGen/LiveVariables.cpp diff -u llvm/lib/CodeGen/LiveVariables.cpp:1.39 llvm/lib/CodeGen/LiveVariables.cpp:1.40 --- llvm/lib/CodeGen/LiveVariables.cpp:1.39 Mon Jul 19 01:55:17 2004 +++ llvm/lib/CodeGen/LiveVariables.cpp Mon Jul 19 02:04:55 2004 @@ -59,7 +59,7 @@ // Check to see if this basic block is one of the killing blocks. If so, // remove it... for (unsigned i = 0, e = VRInfo.Kills.size(); i != e; ++i) - if (VRInfo.Kills[i].first == MBB) { + if (VRInfo.Kills[i]->getParent() == MBB) { VRInfo.Kills.erase(VRInfo.Kills.begin()+i); // Erase entry break; } @@ -83,23 +83,23 @@ void LiveVariables::HandleVirtRegUse(VarInfo &VRInfo, MachineBasicBlock *MBB, MachineInstr *MI) { // Check to see if this basic block is already a kill block... - if (!VRInfo.Kills.empty() && VRInfo.Kills.back().first == MBB) { + if (!VRInfo.Kills.empty() && VRInfo.Kills.back()->getParent() == MBB) { // Yes, this register is killed in this basic block already. Increase the // live range by updating the kill instruction. - VRInfo.Kills.back().second = MI; + VRInfo.Kills.back() = MI; return; } #ifndef NDEBUG for (unsigned i = 0, e = VRInfo.Kills.size(); i != e; ++i) - assert(VRInfo.Kills[i].first != MBB && "entry should be at end!"); + assert(VRInfo.Kills[i]->getParent() != MBB && "entry should be at end!"); #endif assert(MBB != VRInfo.DefInst->getParent() && "Should have kill for defblock!"); // Add a new kill entry for this basic block. - VRInfo.Kills.push_back(std::make_pair(MI->getParent(), MI)); + VRInfo.Kills.push_back(MI); // Update all dominating blocks to mark them known live. const BasicBlock *BB = MBB->getBasicBlock(); @@ -234,7 +234,7 @@ assert(VRInfo.DefInst == 0 && "Variable multiply defined!"); VRInfo.DefInst = MI; // Defaults to dead - VRInfo.Kills.push_back(std::make_pair(MI->getParent(), MI)); + VRInfo.Kills.push_back(MI); } else if (MRegisterInfo::isPhysicalRegister(MO.getReg()) && AllocatablePhysicalRegisters[MO.getReg()]) { HandlePhysRegDef(MO.getReg(), MI); @@ -283,12 +283,12 @@ // for (unsigned i = 0, e = VirtRegInfo.size(); i != e; ++i) for (unsigned j = 0, e = VirtRegInfo[i].Kills.size(); j != e; ++j) { - if (VirtRegInfo[i].Kills[j].second == VirtRegInfo[i].DefInst) - RegistersDead.insert(std::make_pair(VirtRegInfo[i].Kills[j].second, + if (VirtRegInfo[i].Kills[j] == VirtRegInfo[i].DefInst) + RegistersDead.insert(std::make_pair(VirtRegInfo[i].Kills[j], i + MRegisterInfo::FirstVirtualRegister)); else - RegistersKilled.insert(std::make_pair(VirtRegInfo[i].Kills[j].second, + RegistersKilled.insert(std::make_pair(VirtRegInfo[i].Kills[j], i + MRegisterInfo::FirstVirtualRegister)); } Index: llvm/lib/CodeGen/PHIElimination.cpp diff -u llvm/lib/CodeGen/PHIElimination.cpp:1.29 llvm/lib/CodeGen/PHIElimination.cpp:1.30 --- llvm/lib/CodeGen/PHIElimination.cpp:1.29 Mon Jul 19 01:55:17 2004 +++ llvm/lib/CodeGen/PHIElimination.cpp Mon Jul 19 02:04:55 2004 @@ -235,7 +235,7 @@ // Is it killed in this successor? for (unsigned i = 0, e = InRegVI.Kills.size(); i != e; ++i) - if (InRegVI.Kills[i].first == SuccMBB) { + if (InRegVI.Kills[i]->getParent() == SuccMBB) { ValueIsLive = true; break; } From lattner at cs.uiuc.edu Mon Jul 19 02:52:35 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 19 Jul 2004 02:52:35 -0500 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/MachineInstr.h Message-ID: <200407190752.CAA27353@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: MachineInstr.h updated: 1.150 -> 1.151 --- Log message: Delete 4 methods, make clients use hte mark* methods directly --- Diffs of the changes: (+1 -7) Index: llvm/include/llvm/CodeGen/MachineInstr.h diff -u llvm/include/llvm/CodeGen/MachineInstr.h:1.150 llvm/include/llvm/CodeGen/MachineInstr.h:1.151 --- llvm/include/llvm/CodeGen/MachineInstr.h:1.150 Thu Jun 24 19:13:06 2004 +++ llvm/include/llvm/CodeGen/MachineInstr.h Mon Jul 19 02:52:25 2004 @@ -322,7 +322,6 @@ friend std::ostream& operator<<(std::ostream& os, const MachineOperand& mop); -private: /// markHi32, markLo32, etc. - These methods must be accessed via /// corresponding methods in MachineInstr. These methods are deprecated /// and only used by the SPARC v9 back-end. @@ -332,6 +331,7 @@ void markHi64() { flags |= HIFLAG64; } void markLo64() { flags |= LOFLAG64; } +private: /// setRegForValue - Replaces the Value with its corresponding physical /// register after register allocation is complete. This is deprecated /// and only used by the SPARC v9 back-end. @@ -664,12 +664,6 @@ unsigned substituteValue(const Value* oldVal, Value* newVal, bool defsOnly, bool notDefsAndUses, bool& someArgsWereIgnored); - - void setOperandHi32(unsigned i) { operands[i].markHi32(); } - void setOperandLo32(unsigned i) { operands[i].markLo32(); } - void setOperandHi64(unsigned i) { operands[i].markHi64(); } - void setOperandLo64(unsigned i) { operands[i].markLo64(); } - // SetRegForOperand - // SetRegForImplicitRef - From lattner at cs.uiuc.edu Mon Jul 19 02:52:45 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 19 Jul 2004 02:52:45 -0500 Subject: [llvm-commits] CVS: llvm/lib/Target/SparcV9/SparcV9CodeEmitter.cpp SparcV9InstrInfo.cpp SparcV9PrologEpilogInserter.cpp Message-ID: <200407190752.CAA27366@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/SparcV9: SparcV9CodeEmitter.cpp updated: 1.66 -> 1.67 SparcV9InstrInfo.cpp updated: 1.67 -> 1.68 SparcV9PrologEpilogInserter.cpp updated: 1.39 -> 1.40 --- Log message: Inline 4 methods --- Diffs of the changes: (+18 -18) Index: llvm/lib/Target/SparcV9/SparcV9CodeEmitter.cpp diff -u llvm/lib/Target/SparcV9/SparcV9CodeEmitter.cpp:1.66 llvm/lib/Target/SparcV9/SparcV9CodeEmitter.cpp:1.67 --- llvm/lib/Target/SparcV9/SparcV9CodeEmitter.cpp:1.66 Wed Jun 9 16:54:59 2004 +++ llvm/lib/Target/SparcV9/SparcV9CodeEmitter.cpp Mon Jul 19 02:52:35 2004 @@ -757,10 +757,10 @@ if (op.isHiBits64()) { hiBits64=true; } MI->SetMachineOperandConst(ii, MachineOperand::MO_SignExtendedImmed, branchTarget); - if (loBits32) { MI->setOperandLo32(ii); } - else if (hiBits32) { MI->setOperandHi32(ii); } - else if (loBits64) { MI->setOperandLo64(ii); } - else if (hiBits64) { MI->setOperandHi64(ii); } + if (loBits32) { MI->getOperand(ii).markLo32(); } + else if (hiBits32) { MI->getOperand(ii).markHi32(); } + else if (loBits64) { MI->getOperand(ii).markLo64(); } + else if (hiBits64) { MI->getOperand(ii).markHi64(); } DEBUG(std::cerr << "Rewrote BB ref: "); unsigned fixedInstr = SparcV9CodeEmitter::getBinaryCodeForInstr(*MI); MCE.emitWordAt (fixedInstr, Ref); Index: llvm/lib/Target/SparcV9/SparcV9InstrInfo.cpp diff -u llvm/lib/Target/SparcV9/SparcV9InstrInfo.cpp:1.67 llvm/lib/Target/SparcV9/SparcV9InstrInfo.cpp:1.68 --- llvm/lib/Target/SparcV9/SparcV9InstrInfo.cpp:1.67 Sat Jul 17 19:38:32 2004 +++ llvm/lib/Target/SparcV9/SparcV9InstrInfo.cpp Mon Jul 19 02:52:35 2004 @@ -164,7 +164,7 @@ // Set the high 22 bits in dest if non-zero and simm13 field of OR not enough if (!smallNegValue && (C & ~MAXLO) && C > MAXSIMM) { miSETHI = BuildMI(V9::SETHI, 2).addZImm(C).addRegDef(dest); - miSETHI->setOperandHi32(0); + miSETHI->getOperand(0).markHi32(); mvec.push_back(miSETHI); } @@ -174,7 +174,7 @@ if (miSETHI) { // unsigned value with high-order bits set using SETHI miOR = BuildMI(V9::ORi,3).addReg(dest).addZImm(C).addRegDef(dest); - miOR->setOperandLo32(1); + miOR->getOperand(1).markLo32(); } else { // unsigned or small signed value that fits in simm13 field of OR assert(smallNegValue || (C & ~MAXSIMM) == 0); @@ -261,12 +261,12 @@ // Set the high 22 bits in dest MI = BuildMI(V9::SETHI, 2).addReg(val).addRegDef(dest); - MI->setOperandHi32(0); + MI->getOperand(0).markHi32(); mvec.push_back(MI); // Set the low 10 bits in dest MI = BuildMI(V9::ORr, 3).addReg(dest).addReg(val).addRegDef(dest); - MI->setOperandLo32(1); + MI->getOperand(1).markLo32(); mvec.push_back(MI); } @@ -288,24 +288,24 @@ MachineInstr* MI; MI = BuildMI(V9::SETHI, 2).addPCDisp(val).addRegDef(tmpReg); - MI->setOperandHi64(0); + MI->getOperand(0).markHi64(); mvec.push_back(MI); MI = BuildMI(V9::ORi, 3).addReg(tmpReg).addPCDisp(val).addRegDef(tmpReg); - MI->setOperandLo64(1); + MI->getOperand(1).markLo64(); mvec.push_back(MI); mvec.push_back(BuildMI(V9::SLLXi6, 3).addReg(tmpReg).addZImm(32) .addRegDef(tmpReg)); MI = BuildMI(V9::SETHI, 2).addPCDisp(val).addRegDef(dest); - MI->setOperandHi32(0); + MI->getOperand(0).markHi32(); mvec.push_back(MI); MI = BuildMI(V9::ORr, 3).addReg(dest).addReg(tmpReg).addRegDef(dest); mvec.push_back(MI); MI = BuildMI(V9::ORi, 3).addReg(dest).addPCDisp(val).addRegDef(dest); - MI->setOperandLo32(1); + MI->getOperand(1).markLo32(); mvec.push_back(MI); } @@ -512,18 +512,18 @@ MachineInstr* MI; MI = BuildMI(V9::SETHI, 2).addConstantPoolIndex(CPI).addRegDef(tmpReg); - MI->setOperandHi64(0); + MI->getOperand(0).markHi64(); mvec.push_back(MI); MI = BuildMI(V9::ORi, 3).addReg(tmpReg).addConstantPoolIndex(CPI) .addRegDef(tmpReg); - MI->setOperandLo64(1); + MI->getOperand(1).markLo64(); mvec.push_back(MI); mvec.push_back(BuildMI(V9::SLLXi6, 3).addReg(tmpReg).addZImm(32) .addRegDef(tmpReg)); MI = BuildMI(V9::SETHI, 2).addConstantPoolIndex(CPI).addRegDef(addrReg); - MI->setOperandHi32(0); + MI->getOperand(0).markHi32(); mvec.push_back(MI); MI = BuildMI(V9::ORr, 3).addReg(addrReg).addReg(tmpReg).addRegDef(addrReg); @@ -531,7 +531,7 @@ MI = BuildMI(V9::ORi, 3).addReg(addrReg).addConstantPoolIndex(CPI) .addRegDef(addrReg); - MI->setOperandLo32(1); + MI->getOperand(1).markLo32(); mvec.push_back(MI); // Now load the constant from out ConstantPool label Index: llvm/lib/Target/SparcV9/SparcV9PrologEpilogInserter.cpp diff -u llvm/lib/Target/SparcV9/SparcV9PrologEpilogInserter.cpp:1.39 llvm/lib/Target/SparcV9/SparcV9PrologEpilogInserter.cpp:1.40 --- llvm/lib/Target/SparcV9/SparcV9PrologEpilogInserter.cpp:1.39 Wed Jun 2 00:54:43 2004 +++ llvm/lib/Target/SparcV9/SparcV9PrologEpilogInserter.cpp Mon Jul 19 02:52:35 2004 @@ -93,12 +93,12 @@ MachineInstr* M = BuildMI(V9::SETHI, 2).addSImm(C) .addMReg(uregNum, MachineOperand::Def); - M->setOperandHi32(0); + M->getOperand(0).markHi32(); mvec.push_back(M); M = BuildMI(V9::ORi, 3).addMReg(uregNum).addSImm(C) .addMReg(uregNum, MachineOperand::Def); - M->setOperandLo32(1); + M->getOperand(1).markLo32(); mvec.push_back(M); M = BuildMI(V9::SRAi5, 3).addMReg(uregNum).addZImm(0) From llvm at cs.uiuc.edu Mon Jul 19 08:25:12 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Mon, 19 Jul 2004 08:25:12 -0500 Subject: [llvm-commits] CVS: llvm/lib/Target/SparcV9/SparcV9InstrInfo.cpp Message-ID: <200407191325.IAA04522@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/SparcV9: SparcV9InstrInfo.cpp updated: 1.68 -> 1.69 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : Simplify a conditional operator for a constant result from GV->isNullValue() --- Diffs of the changes: (+1 -2) Index: llvm/lib/Target/SparcV9/SparcV9InstrInfo.cpp diff -u llvm/lib/Target/SparcV9/SparcV9InstrInfo.cpp:1.68 llvm/lib/Target/SparcV9/SparcV9InstrInfo.cpp:1.69 --- llvm/lib/Target/SparcV9/SparcV9InstrInfo.cpp:1.68 Mon Jul 19 02:52:35 2004 +++ llvm/lib/Target/SparcV9/SparcV9InstrInfo.cpp Mon Jul 19 08:25:02 2004 @@ -62,8 +62,7 @@ // GlobalValue: no conversions needed: get value and return it if (const GlobalValue* GV = dyn_cast(V)) { isValidConstant = true; // may be overwritten by recursive call - return GV->isNullValue() ? 0 : - ConvertConstantToIntType(target, GV, destType, isValidConstant); + return ConvertConstantToIntType(target, GV, destType, isValidConstant); } // ConstantBool: no conversions needed: get value and return it From lattner at cs.uiuc.edu Mon Jul 19 08:28:50 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 19 Jul 2004 08:28:50 -0500 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/MachineInstr.h Message-ID: <200407191328.IAA10425@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: MachineInstr.h updated: 1.151 -> 1.152 --- Log message: Fix comment --- Diffs of the changes: (+2 -3) Index: llvm/include/llvm/CodeGen/MachineInstr.h diff -u llvm/include/llvm/CodeGen/MachineInstr.h:1.151 llvm/include/llvm/CodeGen/MachineInstr.h:1.152 --- llvm/include/llvm/CodeGen/MachineInstr.h:1.151 Mon Jul 19 02:52:25 2004 +++ llvm/include/llvm/CodeGen/MachineInstr.h Mon Jul 19 08:28:39 2004 @@ -322,9 +322,8 @@ friend std::ostream& operator<<(std::ostream& os, const MachineOperand& mop); - /// markHi32, markLo32, etc. - These methods must be accessed via - /// corresponding methods in MachineInstr. These methods are deprecated - /// and only used by the SPARC v9 back-end. + /// markHi32, markLo32, etc. - These methods are deprecated and only used by + /// the SPARC v9 back-end. /// void markHi32() { flags |= HIFLAG32; } void markLo32() { flags |= LOFLAG32; } From lattner at cs.uiuc.edu Mon Jul 19 09:08:20 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 19 Jul 2004 09:08:20 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervals.cpp LiveIntervals.h Message-ID: <200407191408.JAA12178@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveIntervals.cpp updated: 1.94 -> 1.95 LiveIntervals.h updated: 1.28 -> 1.29 --- Log message: Split joinIntervals into two methods --- Diffs of the changes: (+89 -84) Index: llvm/lib/CodeGen/LiveIntervals.cpp diff -u llvm/lib/CodeGen/LiveIntervals.cpp:1.94 llvm/lib/CodeGen/LiveIntervals.cpp:1.95 --- llvm/lib/CodeGen/LiveIntervals.cpp:1.94 Mon Jul 19 02:04:55 2004 +++ llvm/lib/CodeGen/LiveIntervals.cpp Mon Jul 19 09:08:09 2004 @@ -494,101 +494,102 @@ return reg; } -void LiveIntervals::joinIntervals() -{ - DEBUG(std::cerr << "********** JOINING INTERVALS ***********\n"); - +void LiveIntervals::joinIntervalsInMachineBB(MachineBasicBlock *MBB) { + DEBUG(std::cerr << ((Value*)MBB->getBasicBlock())->getName() << ":\n"); const TargetInstrInfo& tii = *tm_->getInstrInfo(); - for (MachineFunction::iterator mbbi = mf_->begin(), mbbe = mf_->end(); - mbbi != mbbe; ++mbbi) { - MachineBasicBlock* mbb = mbbi; - DEBUG(std::cerr << ((Value*)mbb->getBasicBlock())->getName() << ":\n"); - - for (MachineBasicBlock::iterator mi = mbb->begin(), mie = mbb->end(); - mi != mie; ++mi) { - const TargetInstrDescriptor& tid = tii.get(mi->getOpcode()); - DEBUG(std::cerr << getInstructionIndex(mi) << '\t'; - mi->print(std::cerr, tm_);); - - // we only join virtual registers with allocatable - // physical registers since we do not have liveness information - // on not allocatable physical registers - unsigned regA, regB; - if (tii.isMoveInstr(*mi, regA, regB) && - (MRegisterInfo::isVirtualRegister(regA) || - lv_->getAllocatablePhysicalRegisters()[regA]) && - (MRegisterInfo::isVirtualRegister(regB) || - lv_->getAllocatablePhysicalRegisters()[regB])) { - - // get representative registers - regA = rep(regA); - regB = rep(regB); + for (MachineBasicBlock::iterator mi = MBB->begin(), mie = MBB->end(); + mi != mie; ++mi) { + const TargetInstrDescriptor& tid = tii.get(mi->getOpcode()); + DEBUG(std::cerr << getInstructionIndex(mi) << '\t'; + mi->print(std::cerr, tm_);); + + // we only join virtual registers with allocatable + // physical registers since we do not have liveness information + // on not allocatable physical registers + unsigned regA, regB; + if (tii.isMoveInstr(*mi, regA, regB) && + (MRegisterInfo::isVirtualRegister(regA) || + lv_->getAllocatablePhysicalRegisters()[regA]) && + (MRegisterInfo::isVirtualRegister(regB) || + lv_->getAllocatablePhysicalRegisters()[regB])) { + + // get representative registers + regA = rep(regA); + regB = rep(regB); + + // if they are already joined we continue + if (regA == regB) + continue; + + Reg2IntervalMap::iterator r2iA = r2iMap_.find(regA); + assert(r2iA != r2iMap_.end() && + "Found unknown vreg in 'isMoveInstr' instruction"); + Reg2IntervalMap::iterator r2iB = r2iMap_.find(regB); + assert(r2iB != r2iMap_.end() && + "Found unknown vreg in 'isMoveInstr' instruction"); + + Intervals::iterator intA = r2iA->second; + Intervals::iterator intB = r2iB->second; + + // both A and B are virtual registers + if (MRegisterInfo::isVirtualRegister(intA->reg) && + MRegisterInfo::isVirtualRegister(intB->reg)) { + + const TargetRegisterClass *rcA, *rcB; + rcA = mf_->getSSARegMap()->getRegClass(intA->reg); + rcB = mf_->getSSARegMap()->getRegClass(intB->reg); + // if they are not of the same register class we continue + if (rcA != rcB) + continue; + + // if their intervals do not overlap we join them + if (!intB->overlaps(*intA)) { + intA->join(*intB); + r2iB->second = r2iA->second; + r2rMap_.insert(std::make_pair(intB->reg, intA->reg)); + intervals_.erase(intB); + } + } else if (MRegisterInfo::isPhysicalRegister(intA->reg) ^ + MRegisterInfo::isPhysicalRegister(intB->reg)) { + if (MRegisterInfo::isPhysicalRegister(intB->reg)) { + std::swap(regA, regB); + std::swap(intA, intB); + std::swap(r2iA, r2iB); + } - // if they are already joined we continue - if (regA == regB) + assert(MRegisterInfo::isPhysicalRegister(intA->reg) && + MRegisterInfo::isVirtualRegister(intB->reg) && + "A must be physical and B must be virtual"); + + const TargetRegisterClass *rcA, *rcB; + rcA = mri_->getRegClass(intA->reg); + rcB = mf_->getSSARegMap()->getRegClass(intB->reg); + // if they are not of the same register class we continue + if (rcA != rcB) continue; - Reg2IntervalMap::iterator r2iA = r2iMap_.find(regA); - assert(r2iA != r2iMap_.end() && - "Found unknown vreg in 'isMoveInstr' instruction"); - Reg2IntervalMap::iterator r2iB = r2iMap_.find(regB); - assert(r2iB != r2iMap_.end() && - "Found unknown vreg in 'isMoveInstr' instruction"); - - Intervals::iterator intA = r2iA->second; - Intervals::iterator intB = r2iB->second; - - // both A and B are virtual registers - if (MRegisterInfo::isVirtualRegister(intA->reg) && - MRegisterInfo::isVirtualRegister(intB->reg)) { - - const TargetRegisterClass *rcA, *rcB; - rcA = mf_->getSSARegMap()->getRegClass(intA->reg); - rcB = mf_->getSSARegMap()->getRegClass(intB->reg); - // if they are not of the same register class we continue - if (rcA != rcB) - continue; - - // if their intervals do not overlap we join them - if (!intB->overlaps(*intA)) { - intA->join(*intB); - r2iB->second = r2iA->second; - r2rMap_.insert(std::make_pair(intB->reg, intA->reg)); - intervals_.erase(intB); - } - } else if (MRegisterInfo::isPhysicalRegister(intA->reg) ^ - MRegisterInfo::isPhysicalRegister(intB->reg)) { - if (MRegisterInfo::isPhysicalRegister(intB->reg)) { - std::swap(regA, regB); - std::swap(intA, intB); - std::swap(r2iA, r2iB); - } - - assert(MRegisterInfo::isPhysicalRegister(intA->reg) && - MRegisterInfo::isVirtualRegister(intB->reg) && - "A must be physical and B must be virtual"); - - const TargetRegisterClass *rcA, *rcB; - rcA = mri_->getRegClass(intA->reg); - rcB = mf_->getSSARegMap()->getRegClass(intB->reg); - // if they are not of the same register class we continue - if (rcA != rcB) - continue; - - if (!intA->overlaps(*intB) && - !overlapsAliases(*intA, *intB)) { - intA->join(*intB); - r2iB->second = r2iA->second; - r2rMap_.insert(std::make_pair(intB->reg, intA->reg)); - intervals_.erase(intB); - } + if (!intA->overlaps(*intB) && + !overlapsAliases(*intA, *intB)) { + intA->join(*intB); + r2iB->second = r2iA->second; + r2rMap_.insert(std::make_pair(intB->reg, intA->reg)); + intervals_.erase(intB); } } } } } +void LiveIntervals::joinIntervals() +{ + DEBUG(std::cerr << "********** JOINING INTERVALS ***********\n"); + + for (MachineFunction::iterator I = mf_->begin(), E = mf_->end(); + I != E; ++I) + joinIntervalsInMachineBB(I); +} + bool LiveIntervals::overlapsAliases(const LiveInterval& lhs, const LiveInterval& rhs) const { Index: llvm/lib/CodeGen/LiveIntervals.h diff -u llvm/lib/CodeGen/LiveIntervals.h:1.28 llvm/lib/CodeGen/LiveIntervals.h:1.29 --- llvm/lib/CodeGen/LiveIntervals.h:1.28 Sun Jul 18 21:13:59 2004 +++ llvm/lib/CodeGen/LiveIntervals.h Mon Jul 19 09:08:10 2004 @@ -169,6 +169,10 @@ /// joinIntervals - join compatible live intervals void joinIntervals(); + /// joinIntervalsInMachineBB - Join intervals based on move + /// instructions in the specified basic block. + void joinIntervalsInMachineBB(MachineBasicBlock *MBB); + /// handleRegisterDef - update intervals for a register def /// (calls handlePhysicalRegisterDef and /// handleVirtualRegisterDef) From lattner at cs.uiuc.edu Mon Jul 19 09:40:40 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 19 Jul 2004 09:40:40 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervals.cpp Message-ID: <200407191440.JAA13715@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveIntervals.cpp updated: 1.95 -> 1.96 --- Log message: When joining intervals, join intervals in deeply nested loops first. This is a simple change, but seems to improve code a little. For example, on 256.bzip2, we went from 75.0s -> 73.33s (2% speedup). --- Diffs of the changes: (+35 -5) Index: llvm/lib/CodeGen/LiveIntervals.cpp diff -u llvm/lib/CodeGen/LiveIntervals.cpp:1.95 llvm/lib/CodeGen/LiveIntervals.cpp:1.96 --- llvm/lib/CodeGen/LiveIntervals.cpp:1.95 Mon Jul 19 09:08:09 2004 +++ llvm/lib/CodeGen/LiveIntervals.cpp Mon Jul 19 09:40:29 2004 @@ -109,7 +109,6 @@ // join intervals if requested if (EnableJoining) joinIntervals(); - //DEBUG(mf_->viewCFG()); numIntervalsAfter += intervals_.size(); @@ -581,13 +580,44 @@ } } -void LiveIntervals::joinIntervals() -{ - DEBUG(std::cerr << "********** JOINING INTERVALS ***********\n"); - +namespace { + // DepthMBBCompare - Comparison predicate that sort first based on the loop + // depth of the basic block (the unsigned), and then on the MBB number. + struct DepthMBBCompare { + typedef std::pair DepthMBBPair; + bool operator()(const DepthMBBPair &LHS, const DepthMBBPair &RHS) const { + if (LHS.first > RHS.first) return true; // Deeper loops first + return LHS.first == RHS.first && + LHS.second->getNumber() < RHS.second->getNumber(); + } + }; +} + +void LiveIntervals::joinIntervals() { + DEBUG(std::cerr << "********** JOINING INTERVALS ***********\n"); + + const LoopInfo &LI = getAnalysis(); + if (LI.begin() == LI.end()) { + // If there are no loops in the function, join intervals in function order. for (MachineFunction::iterator I = mf_->begin(), E = mf_->end(); I != E; ++I) joinIntervalsInMachineBB(I); + } else { + // Otherwise, join intervals in inner loops before other intervals. + // Unfortunately we can't just iterate over loop hierarchy here because + // there may be more MBB's than BB's. Collect MBB's for sorting. + std::vector > MBBs; + for (MachineFunction::iterator I = mf_->begin(), E = mf_->end(); + I != E; ++I) + MBBs.push_back(std::make_pair(LI.getLoopDepth(I->getBasicBlock()), I)); + + // Sort by loop depth. + std::sort(MBBs.begin(), MBBs.end(), DepthMBBCompare()); + + // Finally, join intervals in loop nest order. + for (unsigned i = 0, e = MBBs.size(); i != e; ++i) + joinIntervalsInMachineBB(MBBs[i].second); + } } bool LiveIntervals::overlapsAliases(const LiveInterval& lhs, From lattner at cs.uiuc.edu Mon Jul 19 10:17:03 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 19 Jul 2004 10:17:03 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervals.cpp Message-ID: <200407191517.KAA15396@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveIntervals.cpp updated: 1.96 -> 1.97 --- Log message: Fix a bug that occurs when the last instruction in a range is dead --- Diffs of the changes: (+6 -3) Index: llvm/lib/CodeGen/LiveIntervals.cpp diff -u llvm/lib/CodeGen/LiveIntervals.cpp:1.96 llvm/lib/CodeGen/LiveIntervals.cpp:1.97 --- llvm/lib/CodeGen/LiveIntervals.cpp:1.96 Mon Jul 19 09:40:29 2004 +++ llvm/lib/CodeGen/LiveIntervals.cpp Mon Jul 19 10:16:53 2004 @@ -205,12 +205,15 @@ const TargetRegisterClass* rc = mf_->getSSARegMap()->getRegClass(li.reg); for (LiveInterval::Ranges::const_iterator - i = li.ranges.begin(), e = li.ranges.end(); i != e; ++i) { + i = li.ranges.begin(), e = li.ranges.end(); i != e; ++i) { unsigned index = getBaseIndex(i->first); unsigned end = getBaseIndex(i->second-1) + InstrSlots::NUM; - for (; index < end; index += InstrSlots::NUM) { + for (; index != end; index += InstrSlots::NUM) { // skip deleted instructions - while (!getInstructionFromIndex(index)) index += InstrSlots::NUM; + while (index != end && !getInstructionFromIndex(index)) + index += InstrSlots::NUM; + if (index == end) break; + MachineBasicBlock::iterator mi = getInstructionFromIndex(index); for_operand: From vadve at cs.uiuc.edu Mon Jul 19 11:03:31 2004 From: vadve at cs.uiuc.edu (Vikram Adve) Date: Mon, 19 Jul 2004 11:03:31 -0500 Subject: [llvm-commits] CVS: llvm-www/Features.html Message-ID: <200407191603.LAA18660@psmith.cs.uiuc.edu> Changes in directory llvm-www: Features.html updated: 1.7 -> 1.8 --- Log message: Added important features we never listed before : the IR and the pass manager! --- Diffs of the changes: (+8 -0) Index: llvm-www/Features.html diff -u llvm-www/Features.html:1.7 llvm-www/Features.html:1.8 --- llvm-www/Features.html:1.7 Tue Jun 1 13:34:58 2004 +++ llvm-www/Features.html Mon Jul 19 11:03:21 2004 @@ -11,6 +11,14 @@ includes a front-end for "Stacker", a Forth-like language. +
  • A stable implementation of the LLVM instruction set, which serves + as both the online and offline code representation, together with assembly + (ASCII) and bytecode (binary) readers and writers, and a verifier. + +
  • A powerful pass-management system that automatically sequences passes + (including analysis, transformation, and code-generation passes) based on + their dependences, and pipelines them for efficiency. +
  • A wide range of global scalar optimizations.
  • A link-time interprocedural optimization framework with a rich set of From criswell at cs.uiuc.edu Mon Jul 19 11:12:36 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Mon, 19 Jul 2004 11:12:36 -0500 Subject: [llvm-commits] CVS: llvm/configure Message-ID: <200407191612.LAA11012@choi.cs.uiuc.edu> Changes in directory llvm: configure updated: 1.95 -> 1.96 --- Log message: Added support for stdint.h. It is now automatically included by DataTypes.h. So far, it doesn't seem to break Linux, Solaris, or MacOS X. This should automatically include it for those people who need it. --- Diffs of the changes: (+141 -3) Index: llvm/configure diff -u llvm/configure:1.95 llvm/configure:1.96 --- llvm/configure:1.95 Tue Jun 22 18:47:13 2004 +++ llvm/configure Mon Jul 19 11:12:25 2004 @@ -465,7 +465,7 @@ #endif" ac_unique_file=""Makefile.config.in"" -ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS subdirs INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os OS LLVMGCCDIR ARCH CXX CXXFLAGS LDFLAGS CPPFLAGS ac_ct_CXX EXEEXT OBJEXT CC CFLAGS ac_ct_CC CPP ifGNUmake LEX LEXLIB LEX_OUTPUT_ROOT YACC BISON EGREP LN_S ECHO AR ac_ct_AR RANLIB ac_ct_RANLIB STRIP ac_ct_STRIP CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL DOT ETAGS ETAGSFLAGS PYTHON QMTEST HAVE_PTHREAD_MUTEX_LOCK INCLUDE_SYS_TYPES_H INCLUDE_INTTYPES_H ENDIAN HAVE_STD_EXT_HASH_MAP HAVE_GNU_EXT_HASH_MAP HAVE_GLOBAL_HASH_MAP HAVE_STD_EXT_HASH_SET HAVE_GNU_EXT_HASH_SET HAVE_GLOBAL_HASH_S! ET HAVE_STD_ITERATOR HAVE_BI_ITERATOR HAVE_FWD_ITERATOR ALLOCA MMAP_FILE ENABLE_OPTIMIZED SPEC95_ROOT USE_SPEC95 SPEC2000_ROOT USE_SPEC2000 POVRAY_ROOT USE_POVRAY UPB DISABLE_LLC_DIFFS JIT LLVMCC1 LLVMCC1PLUS BCR PAPIDIR SHLIBEXT LIBOBJS LTLIBOBJS' +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS subdirs INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os OS LLVMGCCDIR ARCH CXX CXXFLAGS LDFLAGS CPPFLAGS ac_ct_CXX EXEEXT OBJEXT CC CFLAGS ac_ct_CC CPP ifGNUmake LEX LEXLIB LEX_OUTPUT_ROOT YACC BISON EGREP LN_S ECHO AR ac_ct_AR RANLIB ac_ct_RANLIB STRIP ac_ct_STRIP CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL DOT ETAGS ETAGSFLAGS PYTHON QMTEST HAVE_PTHREAD_MUTEX_LOCK INCLUDE_SYS_TYPES_H INCLUDE_INTTYPES_H INCLUDE_STDINT_H ENDIAN HAVE_STD_EXT_HASH_MAP HAVE_GNU_EXT_HASH_MAP HAVE_GLOBAL_HASH_MAP HAVE_STD_EXT_HASH_SET HAVE_GNU_EXT_HASH_SET H! AVE_GLOBAL_HASH_SET HAVE_STD_ITERATOR HAVE_BI_ITERATOR HAVE_FWD_ITERATOR ALLOCA MMAP_FILE ENABLE_OPTIMIZED SPEC95_ROOT USE_SPEC95 SPEC2000_ROOT USE_SPEC2000 POVRAY_ROOT USE_POVRAY UPB DISABLE_LLC_DIFFS JIT LLVMCC1 LLVMCC1PLUS BCR PAPIDIR SHLIBEXT LIBOBJS LTLIBOBJS' ac_subst_files='' # Initialize some variables set by options. @@ -19342,6 +19342,144 @@ +if test "${ac_cv_header_stdint_h+set}" = set; then + echo "$as_me:$LINENO: checking for stdint.h" >&5 +echo $ECHO_N "checking for stdint.h... $ECHO_C" >&6 +if test "${ac_cv_header_stdint_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: $ac_cv_header_stdint_h" >&5 +echo "${ECHO_T}$ac_cv_header_stdint_h" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking stdint.h usability" >&5 +echo $ECHO_N "checking stdint.h usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_header_compiler=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking stdint.h presence" >&5 +echo $ECHO_N "checking stdint.h presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc in + yes:no ) + { echo "$as_me:$LINENO: WARNING: stdint.h: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: stdint.h: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: stdint.h: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: stdint.h: proceeding with the preprocessor's result" >&2;} + ( + cat <<\_ASBOX +## ------------------------------------ ## +## Report this to bug-autoconf at gnu.org. ## +## ------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; + no:yes ) + { echo "$as_me:$LINENO: WARNING: stdint.h: present but cannot be compiled" >&5 +echo "$as_me: WARNING: stdint.h: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: stdint.h: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: stdint.h: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: stdint.h: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: stdint.h: proceeding with the preprocessor's result" >&2;} + ( + cat <<\_ASBOX +## ------------------------------------ ## +## Report this to bug-autoconf at gnu.org. ## +## ------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +echo "$as_me:$LINENO: checking for stdint.h" >&5 +echo $ECHO_N "checking for stdint.h... $ECHO_C" >&6 +if test "${ac_cv_header_stdint_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_header_stdint_h=$ac_header_preproc +fi +echo "$as_me:$LINENO: result: $ac_cv_header_stdint_h" >&5 +echo "${ECHO_T}$ac_cv_header_stdint_h" >&6 + +fi +if test $ac_cv_header_stdint_h = yes; then + INCLUDE_STDINT_H='#include ' +else + INCLUDE_STDINT_H='' +fi + + + + echo "$as_me:$LINENO: checking for pid_t" >&5 echo $ECHO_N "checking for pid_t... $ECHO_C" >&6 @@ -21786,8 +21924,7 @@ - -for ac_func in getcwd gettimeofday strdup strtoq strtoll backtrace isatty mkstemp getrusage isnan +for ac_func in getcwd gettimeofday strdup strtoq strtoll backtrace isatty mkstemp getrusage do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` echo "$as_me:$LINENO: checking for $ac_func" >&5 @@ -23091,6 +23228,7 @@ s, at HAVE_PTHREAD_MUTEX_LOCK@,$HAVE_PTHREAD_MUTEX_LOCK,;t t s, at INCLUDE_SYS_TYPES_H@,$INCLUDE_SYS_TYPES_H,;t t s, at INCLUDE_INTTYPES_H@,$INCLUDE_INTTYPES_H,;t t +s, at INCLUDE_STDINT_H@,$INCLUDE_STDINT_H,;t t s, at ENDIAN@,$ENDIAN,;t t s, at HAVE_STD_EXT_HASH_MAP@,$HAVE_STD_EXT_HASH_MAP,;t t s, at HAVE_GNU_EXT_HASH_MAP@,$HAVE_GNU_EXT_HASH_MAP,;t t From criswell at cs.uiuc.edu Mon Jul 19 11:12:39 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Mon, 19 Jul 2004 11:12:39 -0500 Subject: [llvm-commits] CVS: llvm/include/Support/DataTypes.h.in Message-ID: <200407191612.LAA11019@choi.cs.uiuc.edu> Changes in directory llvm/include/Support: DataTypes.h.in updated: 1.5 -> 1.6 --- Log message: Added support for stdint.h. It is now automatically included by DataTypes.h. So far, it doesn't seem to break Linux, Solaris, or MacOS X. This should automatically include it for those people who need it. --- Diffs of the changes: (+1 -0) Index: llvm/include/Support/DataTypes.h.in diff -u llvm/include/Support/DataTypes.h.in:1.5 llvm/include/Support/DataTypes.h.in:1.6 --- llvm/include/Support/DataTypes.h.in:1.5 Fri Jun 4 15:58:34 2004 +++ llvm/include/Support/DataTypes.h.in Mon Jul 19 11:12:29 2004 @@ -33,6 +33,7 @@ // Note that includes , if this is a C99 system. @INCLUDE_INTTYPES_H@ @INCLUDE_SYS_TYPES_H@ + at INCLUDE_STDINT_H@ #else // Visual C++ doesn't provide standard integer headers, but it does provide // built-in data types. From criswell at cs.uiuc.edu Mon Jul 19 11:12:40 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Mon, 19 Jul 2004 11:12:40 -0500 Subject: [llvm-commits] CVS: llvm/autoconf/configure.ac Message-ID: <200407191612.LAA11026@choi.cs.uiuc.edu> Changes in directory llvm/autoconf: configure.ac updated: 1.93 -> 1.94 --- Log message: Added support for stdint.h. It is now automatically included by DataTypes.h. So far, it doesn't seem to break Linux, Solaris, or MacOS X. This should automatically include it for those people who need it. --- Diffs of the changes: (+5 -0) Index: llvm/autoconf/configure.ac diff -u llvm/autoconf/configure.ac:1.93 llvm/autoconf/configure.ac:1.94 --- llvm/autoconf/configure.ac:1.93 Tue Jun 22 18:43:04 2004 +++ llvm/autoconf/configure.ac Mon Jul 19 11:12:29 2004 @@ -250,6 +250,11 @@ [INCLUDE_INTTYPES_H='#include '], [INCLUDE_INTTYPES_H='']) AC_SUBST(INCLUDE_INTTYPES_H) +AC_CHECK_HEADER([stdint.h], + [INCLUDE_STDINT_H='#include '], + [INCLUDE_STDINT_H='']) +AC_SUBST(INCLUDE_STDINT_H) + dnl Check for types AC_TYPE_PID_T From lattner at cs.uiuc.edu Mon Jul 19 13:48:09 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 19 Jul 2004 13:48:09 -0500 Subject: [llvm-commits] CVS: llvm/docs/CFEBuildInstrs.html Message-ID: <200407191848.NAA15722@apoc.cs.uiuc.edu> Changes in directory llvm/docs: CFEBuildInstrs.html updated: 1.20 -> 1.21 --- Log message: Just run 'make', not all-gcc --- Diffs of the changes: (+4 -4) Index: llvm/docs/CFEBuildInstrs.html diff -u llvm/docs/CFEBuildInstrs.html:1.20 llvm/docs/CFEBuildInstrs.html:1.21 --- llvm/docs/CFEBuildInstrs.html:1.20 Mon Jun 21 09:00:44 2004 +++ llvm/docs/CFEBuildInstrs.html Mon Jul 19 13:47:59 2004 @@ -116,7 +116,7 @@ % cd build % ../src/configure --prefix=$CFEINSTALL --disable-threads --disable-nls --disable-shared \ --enable-languages=c,c++ - % gmake all-gcc + % gmake % setenv LLVM_LIB_SEARCH_PATH `pwd`/gcc % gmake all; gmake install @@ -127,7 +127,7 @@ % cd build % ../src/configure --prefix=$CFEINSTALL --disable-threads --disable-nls --disable-shared \ --enable-languages=c,c++ --disable-c-mbchar - % gmake all-gcc + % gmake % setenv LLVM_LIB_SEARCH_PATH `pwd`/gcc % gmake all; gmake install @@ -147,7 +147,7 @@ % ../src/configure --prefix=$CFEINSTALL --disable-threads --disable-nls \ --disable-shared --enable-languages=c,c++ --host=sparcv9-sun-solaris2.8 \ --disable-c-mbchar - % gmake all-gcc + % gmake % setenv LLVM_LIB_SEARCH_PATH `pwd`/gcc % gmake all; gmake install @@ -302,7 +302,7 @@ Brian Gaeke
    LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/06/21 14:00:44 $ + Last modified: $Date: 2004/07/19 18:47:59 $ From lattner at cs.uiuc.edu Mon Jul 19 14:30:50 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 19 Jul 2004 14:30:50 -0500 Subject: [llvm-commits] CVS: llvm/docs/SourceLevelDebugging.html Message-ID: <200407191930.OAA15816@apoc.cs.uiuc.edu> Changes in directory llvm/docs: SourceLevelDebugging.html updated: 1.7 -> 1.8 --- Log message: Fix broken link --- Diffs of the changes: (+3 -3) Index: llvm/docs/SourceLevelDebugging.html diff -u llvm/docs/SourceLevelDebugging.html:1.7 llvm/docs/SourceLevelDebugging.html:1.8 --- llvm/docs/SourceLevelDebugging.html:1.7 Thu Jun 3 18:42:24 2004 +++ llvm/docs/SourceLevelDebugging.html Mon Jul 19 14:30:40 2004 @@ -81,8 +81,8 @@

    This document is the central repository for all information pertaining to debug information in LLVM. It describes the user -interface for the llvm-db -tool, which provides a powerful source-level debugger +interface for the llvm-db tool, which provides a +powerful source-level debugger to users of LLVM-based compilers. It then describes the various components that make up the debugger and the libraries which future clients may use. Finally, it describes the Chris Lattner
    LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/06/03 23:42:24 $ + Last modified: $Date: 2004/07/19 19:30:40 $ From brukman at cs.uiuc.edu Mon Jul 19 16:11:55 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Mon, 19 Jul 2004 16:11:55 -0500 Subject: [llvm-commits] CVS: llvm/include/llvm/Constants.h Message-ID: <200407192111.QAA04926@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: Constants.h updated: 1.51 -> 1.52 --- Log message: Convert tabs to spaces; fix name of function in assert() description. --- Diffs of the changes: (+1 -1) Index: llvm/include/llvm/Constants.h diff -u llvm/include/llvm/Constants.h:1.51 llvm/include/llvm/Constants.h:1.52 --- llvm/include/llvm/Constants.h:1.51 Sun Jul 18 19:58:47 2004 +++ llvm/include/llvm/Constants.h Mon Jul 19 16:11:45 2004 @@ -136,7 +136,7 @@ /// bool equalsInt(unsigned char V) const { assert(V <= 127 && - "equals: Can only be used with very small positive constants!"); + "equalsInt: Can only be used with very small positive constants!"); return Val.Unsigned == V; } From brukman at cs.uiuc.edu Mon Jul 19 16:22:12 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Mon, 19 Jul 2004 16:22:12 -0500 Subject: [llvm-commits] CVS: llvm/include/llvm/Constant.h Message-ID: <200407192122.QAA05077@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: Constant.h updated: 1.15 -> 1.16 --- Log message: Tabs to spaces. --- Diffs of the changes: (+3 -4) Index: llvm/include/llvm/Constant.h diff -u llvm/include/llvm/Constant.h:1.15 llvm/include/llvm/Constant.h:1.16 --- llvm/include/llvm/Constant.h:1.15 Sun Jul 18 19:58:02 2004 +++ llvm/include/llvm/Constant.h Mon Jul 19 16:22:02 2004 @@ -21,7 +21,7 @@ class Constant : public User { protected: inline Constant(const Type *Ty, ValueTy vty = Value::SimpleConstantVal, - const std::string& Name = "" ) + const std::string& Name = "") : User(Ty, vty, Name) {} ~Constant() {} @@ -48,7 +48,6 @@ /// destroyConstantImpl as the last thing they do, to destroy all users and /// delete this. virtual void destroyConstant() { assert(0 && "Not reached!"); } - //// Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const Constant *) { return true; } @@ -57,8 +56,8 @@ return V->getValueType() == Value::SimpleConstantVal || V->getValueType() == Value::ConstantExprVal || V->getValueType() == Value::ConstantAggregateZeroVal || - V->getValueType() == Value::FunctionVal || - V->getValueType() == Value::GlobalVariableVal; + V->getValueType() == Value::FunctionVal || + V->getValueType() == Value::GlobalVariableVal; } /// replaceUsesOfWithOnConstant - This method is a special form of From alkis at cs.uiuc.edu Mon Jul 19 18:36:05 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Mon, 19 Jul 2004 18:36:05 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/RegAllocLinearScan.cpp Message-ID: <200407192336.SAA08210@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: RegAllocLinearScan.cpp updated: 1.79 -> 1.80 --- Log message: Remove dead code. --- Diffs of the changes: (+0 -17) Index: llvm/lib/CodeGen/RegAllocLinearScan.cpp diff -u llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.79 llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.80 --- llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.79 Mon Jul 19 00:02:09 2004 +++ llvm/lib/CodeGen/RegAllocLinearScan.cpp Mon Jul 19 18:35:55 2004 @@ -123,23 +123,6 @@ std::cerr << mri_->getName(reg) << '\n'; } } - -// void verifyAssignment() const { -// for (Virt2PhysMap::const_iterator i = v2pMap_.begin(), -// e = v2pMap_.end(); i != e; ++i) -// for (Virt2PhysMap::const_iterator i2 = next(i); i2 != e; ++i2) -// if (MRegisterInfo::isVirtualRegister(i->second) && -// (i->second == i2->second || -// mri_->areAliases(i->second, i2->second))) { -// const Interval -// &in = li_->getInterval(i->second), -// &in2 = li_->getInterval(i2->second); -// if (in.overlaps(in2)) { -// std::cerr << in << " overlaps " << in2 << '\n'; -// assert(0); -// } -// } -// } }; } From lattner at cs.uiuc.edu Mon Jul 19 18:47:32 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 19 Jul 2004 18:47:32 -0500 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/InstSelectSimple.cpp Message-ID: <200407192347.SAA17472@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: InstSelectSimple.cpp updated: 1.272 -> 1.273 --- Log message: Generate better code for multiplies by negative constants like -4, -1, -9, etc. --- Diffs of the changes: (+42 -4) Index: llvm/lib/Target/X86/InstSelectSimple.cpp diff -u llvm/lib/Target/X86/InstSelectSimple.cpp:1.272 llvm/lib/Target/X86/InstSelectSimple.cpp:1.273 --- llvm/lib/Target/X86/InstSelectSimple.cpp:1.272 Sat Jul 17 19:33:38 2004 +++ llvm/lib/Target/X86/InstSelectSimple.cpp Mon Jul 19 18:47:21 2004 @@ -2324,11 +2324,21 @@ static const unsigned MOVrrTab[] = {X86::MOV8rr, X86::MOV16rr, X86::MOV32rr}; static const unsigned MOVriTab[] = {X86::MOV8ri, X86::MOV16ri, X86::MOV32ri}; static const unsigned ADDrrTab[] = {X86::ADD8rr, X86::ADD16rr, X86::ADD32rr}; + static const unsigned NEGrTab[] = {X86::NEG8r , X86::NEG16r , X86::NEG32r }; unsigned Class = getClass(DestTy); + unsigned TmpReg; // Handle special cases here. switch (ConstRHS) { + case -2: + TmpReg = makeAnotherReg(DestTy); + BuildMI(*MBB, IP, NEGrTab[Class], 1, TmpReg).addReg(op0Reg); + BuildMI(*MBB, IP, ADDrrTab[Class], 1,DestReg).addReg(TmpReg).addReg(TmpReg); + return; + case -1: + BuildMI(*MBB, IP, NEGrTab[Class], 1, DestReg).addReg(op0Reg); + return; case 0: BuildMI(*MBB, IP, MOVriTab[Class], 1, DestReg).addImm(0); return; @@ -2342,10 +2352,20 @@ case 5: case 9: if (Class == cInt) { - addFullAddress(BuildMI(*MBB, IP, X86::LEA32r, 5, DestReg), + addFullAddress(BuildMI(*MBB, IP, X86::LEA32r, 5, TmpReg), op0Reg, ConstRHS-1, op0Reg, 0); return; } + case -3: + case -5: + case -9: + if (Class == cInt) { + TmpReg = makeAnotherReg(DestTy); + addFullAddress(BuildMI(*MBB, IP, X86::LEA32r, 5, TmpReg), + op0Reg, -ConstRHS-1, op0Reg, 0); + BuildMI(*MBB, IP, NEGrTab[Class], 1, DestReg).addReg(TmpReg); + return; + } } // If the element size is exactly a power of 2, use a shift to get it. @@ -2353,16 +2373,34 @@ switch (Class) { default: assert(0 && "Unknown class for this function!"); case cByte: - BuildMI(*MBB, IP, X86::SHL32ri,2, DestReg).addReg(op0Reg).addImm(Shift-1); + BuildMI(*MBB, IP, X86::SHL8ri,2, DestReg).addReg(op0Reg).addImm(Shift-1); return; case cShort: - BuildMI(*MBB, IP, X86::SHL32ri,2, DestReg).addReg(op0Reg).addImm(Shift-1); + BuildMI(*MBB, IP, X86::SHL16ri,2, DestReg).addReg(op0Reg).addImm(Shift-1); return; case cInt: BuildMI(*MBB, IP, X86::SHL32ri,2, DestReg).addReg(op0Reg).addImm(Shift-1); return; } } + + // If the element size is a negative power of 2, use a shift/neg to get it. + if (unsigned Shift = ExactLog2(-ConstRHS)) { + TmpReg = makeAnotherReg(DestTy); + BuildMI(*MBB, IP, NEGrTab[Class], 1, TmpReg).addReg(op0Reg); + switch (Class) { + default: assert(0 && "Unknown class for this function!"); + case cByte: + BuildMI(*MBB, IP, X86::SHL8ri,2, DestReg).addReg(TmpReg).addImm(Shift-1); + return; + case cShort: + BuildMI(*MBB, IP, X86::SHL16ri,2, DestReg).addReg(TmpReg).addImm(Shift-1); + return; + case cInt: + BuildMI(*MBB, IP, X86::SHL32ri,2, DestReg).addReg(TmpReg).addImm(Shift-1); + return; + } + } if (Class == cShort) { BuildMI(*MBB, IP, X86::IMUL16rri,2,DestReg).addReg(op0Reg).addImm(ConstRHS); @@ -2373,7 +2411,7 @@ } // Most general case, emit a normal multiply... - unsigned TmpReg = makeAnotherReg(DestTy); + TmpReg = makeAnotherReg(DestTy); BuildMI(*MBB, IP, MOVriTab[Class], 1, TmpReg).addImm(ConstRHS); // Emit a MUL to multiply the register holding the index by From lattner at cs.uiuc.edu Mon Jul 19 18:51:07 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 19 Jul 2004 18:51:07 -0500 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/InstSelectSimple.cpp Message-ID: <200407192351.SAA17921@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: InstSelectSimple.cpp updated: 1.273 -> 1.274 --- Log message: While I'm at it, don't break codegen of mul by 3,5,9. --- Diffs of the changes: (+1 -1) Index: llvm/lib/Target/X86/InstSelectSimple.cpp diff -u llvm/lib/Target/X86/InstSelectSimple.cpp:1.273 llvm/lib/Target/X86/InstSelectSimple.cpp:1.274 --- llvm/lib/Target/X86/InstSelectSimple.cpp:1.273 Mon Jul 19 18:47:21 2004 +++ llvm/lib/Target/X86/InstSelectSimple.cpp Mon Jul 19 18:50:57 2004 @@ -2352,7 +2352,7 @@ case 5: case 9: if (Class == cInt) { - addFullAddress(BuildMI(*MBB, IP, X86::LEA32r, 5, TmpReg), + addFullAddress(BuildMI(*MBB, IP, X86::LEA32r, 5, DestReg), op0Reg, ConstRHS-1, op0Reg, 0); return; } From brukman at cs.uiuc.edu Mon Jul 19 19:52:26 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Mon, 19 Jul 2004 19:52:26 -0500 Subject: [llvm-commits] CVS: llvm/include/Support/StringExtras.h Message-ID: <200407200052.TAA08897@zion.cs.uiuc.edu> Changes in directory llvm/include/Support: StringExtras.h updated: 1.17 -> 1.18 --- Log message: isupper() and tolower() are declared in --- Diffs of the changes: (+3 -3) Index: llvm/include/Support/StringExtras.h diff -u llvm/include/Support/StringExtras.h:1.17 llvm/include/Support/StringExtras.h:1.18 --- llvm/include/Support/StringExtras.h:1.17 Mon Jul 12 15:25:04 2004 +++ llvm/include/Support/StringExtras.h Mon Jul 19 19:52:16 2004 @@ -16,6 +16,7 @@ #include "Support/DataTypes.h" #include +#include #include namespace llvm { @@ -51,7 +52,6 @@ } if (isNeg) *--BufPtr = '-'; // Add negative sign... - return std::string(BufPtr); } @@ -98,9 +98,9 @@ } static inline std::string LowercaseString(const std::string &S) { - std::string result (S); + std::string result(S); for (unsigned i = 0; i < S.length(); ++i) - if (isupper (result[i])) + if (isupper(result[i])) result[i] = (char)tolower(result[i]); return result; } From lattner at cs.uiuc.edu Mon Jul 19 19:57:31 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 19 Jul 2004 19:57:31 -0500 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/InstCombine/cast.ll Message-ID: <200407200057.TAA20679@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/InstCombine: cast.ll updated: 1.20 -> 1.21 --- Log message: Testcases missed by the instruction combiner --- Diffs of the changes: (+14 -0) Index: llvm/test/Regression/Transforms/InstCombine/cast.ll diff -u llvm/test/Regression/Transforms/InstCombine/cast.ll:1.20 llvm/test/Regression/Transforms/InstCombine/cast.ll:1.21 --- llvm/test/Regression/Transforms/InstCombine/cast.ll:1.20 Mon May 24 23:28:43 2004 +++ llvm/test/Regression/Transforms/InstCombine/cast.ll Mon Jul 19 19:57:21 2004 @@ -103,3 +103,17 @@ %c = cast int* %P to bool ;; setne P, null ret bool %c } + + +short %test17(bool %tmp3) { + %c = cast bool %tmp3 to int + %t86 = cast int %c to short + ret short %t86 +} + +short %test18(sbyte %tmp3) { + %c = cast sbyte %tmp3 to int + %t86 = cast int %c to short + ret short %t86 +} + From lattner at cs.uiuc.edu Mon Jul 19 19:59:43 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 19 Jul 2004 19:59:43 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp Message-ID: <200407200059.TAA20690@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: InstructionCombining.cpp updated: 1.225 -> 1.226 --- Log message: Rewrite cast->cast elimination code completely based on the information we actually care about. Someday when the cast instruction is gone, we can do better here, but this will do for now. This implements instcombine/cast.ll:test17/18 as well. --- Diffs of the changes: (+52 -42) Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.225 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.226 --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.225 Sun Jul 18 13:59:44 2004 +++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Mon Jul 19 19:59:32 2004 @@ -1938,6 +1938,29 @@ return 0; } +enum CastType { + Noop = 0, + Truncate = 1, + Signext = 2, + Zeroext = 3 +}; + +/// getCastType - In the future, we will split the cast instruction into these +/// various types. Until then, we have to do the analysis here. +static CastType getCastType(const Type *Src, const Type *Dest) { + assert(Src->isIntegral() && Dest->isIntegral() && + "Only works on integral types!"); + unsigned SrcSize = Src->getPrimitiveSize()*8; + if (Src == Type::BoolTy) SrcSize = 1; + unsigned DestSize = Dest->getPrimitiveSize()*8; + if (Dest == Type::BoolTy) DestSize = 1; + + if (SrcSize == DestSize) return Noop; + if (SrcSize > DestSize) return Truncate; + if (Src->isSigned()) return Signext; + return Zeroext; +} + // isEliminableCastOfCast - Return true if it is valid to eliminate the CI // instruction. @@ -1954,50 +1977,37 @@ // Allow free casting and conversion of sizes as long as the sign doesn't // change... if (SrcTy->isIntegral() && MidTy->isIntegral() && DstTy->isIntegral()) { - unsigned SrcSize = SrcTy->getPrimitiveSize(); - unsigned MidSize = MidTy->getPrimitiveSize(); - unsigned DstSize = DstTy->getPrimitiveSize(); + CastType FirstCast = getCastType(SrcTy, MidTy); + CastType SecondCast = getCastType(MidTy, DstTy); - // Cases where we are monotonically decreasing the size of the type are - // always ok, regardless of what sign changes are going on. - // - if (SrcSize >= MidSize && MidSize >= DstSize) + // Capture the effect of these two casts. If the result is a legal cast, + // the CastType is stored here, otherwise a special code is used. + static const unsigned CastResult[] = { + // First cast is noop + 0, 1, 2, 3, + // First cast is a truncate + 1, 1, 4, 4, // trunc->extend is not safe to eliminate + // First cast is a sign ext + 2, 5, 2, 4, // signext->trunc always ok, signext->zeroext never ok + // First cast is a zero ext + 3, 5, 3, 3, // zeroext->trunc always ok + }; + + unsigned Result = CastResult[FirstCast*4+SecondCast]; + switch (Result) { + default: assert(0 && "Illegal table value!"); + case 0: + case 1: + case 2: + case 3: + // FIXME: in the future, when LLVM has explicit sign/zeroextends and + // truncates, we could eliminate more casts. + return (unsigned)getCastType(SrcTy, DstTy) == Result; + case 4: + return false; // Not possible to eliminate this here. + case 5: + // Sign or zero extend followed by truncate is always ok return true; - - // Cases where the source and destination type are the same, but the middle - // type is bigger are noops. - // - if (SrcSize == DstSize && MidSize > SrcSize) - return true; - - // If we are monotonically growing, things are more complex. - // - if (SrcSize <= MidSize && MidSize <= DstSize) { - // We have eight combinations of signedness to worry about. Here's the - // table: - static const int SignTable[8] = { - // CODE, SrcSigned, MidSigned, DstSigned, Comment - 1, // U U U Always ok - 1, // U U S Always ok - 3, // U S U Ok iff SrcSize != MidSize - 3, // U S S Ok iff SrcSize != MidSize - 0, // S U U Never ok - 2, // S U S Ok iff MidSize == DstSize - 1, // S S U Always ok - 1, // S S S Always ok - }; - - // Choose an action based on the current entry of the signtable that this - // cast of cast refers to... - unsigned Row = SrcTy->isSigned()*4+MidTy->isSigned()*2+DstTy->isSigned(); - switch (SignTable[Row]) { - case 0: return false; // Never ok - case 1: return true; // Always ok - case 2: return MidSize == DstSize; // Ok iff MidSize == DstSize - case 3: // Ok iff SrcSize != MidSize - return SrcSize != MidSize || SrcTy == Type::BoolTy; - default: assert(0 && "Bad entry in sign table!"); - } } } From brukman at cs.uiuc.edu Mon Jul 19 20:08:00 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Mon, 19 Jul 2004 20:08:00 -0500 Subject: [llvm-commits] CVS: llvm/test/Programs/SingleSource/Benchmarks/Stanford/Makefile Message-ID: <200407200108.UAA09100@zion.cs.uiuc.edu> Changes in directory llvm/test/Programs/SingleSource/Benchmarks/Stanford: Makefile updated: 1.3 -> 1.4 --- Log message: Set FP_TOLERANCE to allow for minor FP differences. --- Diffs of the changes: (+1 -0) Index: llvm/test/Programs/SingleSource/Benchmarks/Stanford/Makefile diff -u llvm/test/Programs/SingleSource/Benchmarks/Stanford/Makefile:1.3 llvm/test/Programs/SingleSource/Benchmarks/Stanford/Makefile:1.4 --- llvm/test/Programs/SingleSource/Benchmarks/Stanford/Makefile:1.3 Thu Sep 11 12:58:27 2003 +++ llvm/test/Programs/SingleSource/Benchmarks/Stanford/Makefile Mon Jul 19 20:07:50 2004 @@ -1,4 +1,5 @@ LEVEL = ../../../../.. LDFLAGS += -lm +FP_TOLERANCE = 0.001 include $(LEVEL)/test/Programs/SingleSource/Makefile.singlesrc From lattner at cs.uiuc.edu Mon Jul 19 20:17:29 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 19 Jul 2004 20:17:29 -0500 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/SimplifyCFG/BrUnwind.ll Message-ID: <200407200117.UAA21162@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/SimplifyCFG: BrUnwind.ll added (r1.1) --- Log message: test that unconditional branches to unwinds are always eliminated --- Diffs of the changes: (+12 -0) Index: llvm/test/Regression/Transforms/SimplifyCFG/BrUnwind.ll diff -c /dev/null llvm/test/Regression/Transforms/SimplifyCFG/BrUnwind.ll:1.1 *** /dev/null Mon Jul 19 20:17:29 2004 --- llvm/test/Regression/Transforms/SimplifyCFG/BrUnwind.ll Mon Jul 19 20:17:19 2004 *************** *** 0 **** --- 1,12 ---- + ;RUN: llvm-as < %s | opt -simplifycfg | llvm-dis | not grep 'br label' + void %test(bool %C) { + br bool %C, label %A, label %B + A: + call void %test(bool %C) + br label %X + B: + call void %test(bool %C) + br label %X + X: + unwind + } From lattner at cs.uiuc.edu Mon Jul 19 20:17:48 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 19 Jul 2004 20:17:48 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Utils/SimplifyCFG.cpp Message-ID: <200407200117.UAA21171@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Utils: SimplifyCFG.cpp updated: 1.47 -> 1.48 --- Log message: Implement SimplifyCFG/BrUnwind.ll --- Diffs of the changes: (+9 -2) Index: llvm/lib/Transforms/Utils/SimplifyCFG.cpp diff -u llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.47 llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.48 --- llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.47 Sat Jul 17 19:32:14 2004 +++ llvm/lib/Transforms/Utils/SimplifyCFG.cpp Mon Jul 19 20:17:38 2004 @@ -764,12 +764,19 @@ } else if (UnwindInst *UI = dyn_cast(BB->begin())) { // Check to see if the first instruction in this block is just an unwind. // If so, replace any invoke instructions which use this as an exception - // destination with call instructions. + // destination with call instructions, and any unconditional branch + // predecessor with an unwind. // std::vector Preds(pred_begin(BB), pred_end(BB)); while (!Preds.empty()) { BasicBlock *Pred = Preds.back(); - if (InvokeInst *II = dyn_cast(Pred->getTerminator())) + if (BranchInst *BI = dyn_cast(Pred->getTerminator())) { + if (BI->isUnconditional()) { + Pred->getInstList().pop_back(); // nuke uncond branch + new UnwindInst(Pred); // Use unwind. + Changed = true; + } + } else if (InvokeInst *II = dyn_cast(Pred->getTerminator())) if (II->getUnwindDest() == BB) { // Insert a new branch instruction before the invoke, because this // is now a fall through... From lattner at cs.uiuc.edu Mon Jul 19 20:47:59 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 19 Jul 2004 20:47:59 -0500 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/InstCombine/GEPIdxCanon.ll Message-ID: <200407200147.UAA21757@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/InstCombine: GEPIdxCanon.ll added (r1.1) --- Log message: New testcase that instcombine should help out with. --- Diffs of the changes: (+8 -0) Index: llvm/test/Regression/Transforms/InstCombine/GEPIdxCanon.ll diff -c /dev/null llvm/test/Regression/Transforms/InstCombine/GEPIdxCanon.ll:1.1 *** /dev/null Mon Jul 19 20:47:59 2004 --- llvm/test/Regression/Transforms/InstCombine/GEPIdxCanon.ll Mon Jul 19 20:47:49 2004 *************** *** 0 **** --- 1,8 ---- + ; RUN: llvm-as < %s | opt -instcombine -gcse -instcombine | llvm-dis | not grep getelementptr + + bool %test(int* %A) { + %B = getelementptr int* %A, int 1 + %C = getelementptr int* %A, uint 1 + %V = seteq int* %B, %C + ret bool %V + } From lattner at cs.uiuc.edu Mon Jul 19 20:48:25 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 19 Jul 2004 20:48:25 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp Message-ID: <200407200148.UAA21769@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: InstructionCombining.cpp updated: 1.226 -> 1.227 --- Log message: Implement InstCombine/GEPIdxCanon.ll --- Diffs of the changes: (+10 -1) Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.226 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.227 --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.226 Mon Jul 19 19:59:32 2004 +++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Mon Jul 19 20:48:15 2004 @@ -2700,7 +2700,8 @@ Value *Op = GEP.getOperand(i); if (Op->getType()->getPrimitiveSize() > TD->getPointerSize()) if (Constant *C = dyn_cast(Op)) { - GEP.setOperand(i, ConstantExpr::getCast(C, TD->getIntPtrType())); + GEP.setOperand(i, ConstantExpr::getCast(C, + TD->getIntPtrType()->getSignedVersion())); MadeChange = true; } else { Op = InsertNewInstBefore(new CastInst(Op, TD->getIntPtrType(), @@ -2708,6 +2709,14 @@ GEP.setOperand(i, Op); MadeChange = true; } + + // If this is a constant idx, make sure to canonicalize it to be a signed + // operand, otherwise CSE and other optimizations are pessimized. + if (ConstantUInt *CUI = dyn_cast(Op)) { + GEP.setOperand(i, ConstantExpr::getCast(CUI, + CUI->getType()->getSignedVersion())); + MadeChange = true; + } } if (MadeChange) return &GEP; From brukman at cs.uiuc.edu Mon Jul 19 21:18:35 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Mon, 19 Jul 2004 21:18:35 -0500 Subject: [llvm-commits] CVS: llvm/include/Support/StringExtras.h Message-ID: <200407200218.VAA09603@zion.cs.uiuc.edu> Changes in directory llvm/include/Support: StringExtras.h updated: 1.18 -> 1.19 --- Log message: Dump the old-fashioned C-style in favor of new `C++'-style --- Diffs of the changes: (+1 -1) Index: llvm/include/Support/StringExtras.h diff -u llvm/include/Support/StringExtras.h:1.18 llvm/include/Support/StringExtras.h:1.19 --- llvm/include/Support/StringExtras.h:1.18 Mon Jul 19 19:52:16 2004 +++ llvm/include/Support/StringExtras.h Mon Jul 19 21:18:25 2004 @@ -15,8 +15,8 @@ #define SUPPORT_STRINGEXTRAS_H #include "Support/DataTypes.h" +#include #include -#include #include namespace llvm { From gaeke at cs.uiuc.edu Mon Jul 19 22:27:49 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Mon, 19 Jul 2004 22:27:49 -0500 (CDT) Subject: [llvm-commits] CVS: reopt/lib/LightWtProfiling/RegSaveRestore.h Message-ID: <200407200327.WAA20073@seraph.cs.uiuc.edu> Changes in directory reopt/lib/LightWtProfiling: RegSaveRestore.h updated: 1.4 -> 1.5 --- Log message: Added save/load macros for L registers, in case they ever end up being handy... --- Diffs of the changes: (+24 -0) Index: reopt/lib/LightWtProfiling/RegSaveRestore.h diff -u reopt/lib/LightWtProfiling/RegSaveRestore.h:1.4 reopt/lib/LightWtProfiling/RegSaveRestore.h:1.5 --- reopt/lib/LightWtProfiling/RegSaveRestore.h:1.4 Sun May 16 00:24:19 2004 +++ reopt/lib/LightWtProfiling/RegSaveRestore.h Mon Jul 19 22:27:39 2004 @@ -39,6 +39,30 @@ asm volatile ("ldx %0, %%i5":: "m"(i_reg_save[5])); \ } while (0) +#define SAVE_L_REGS(l_reg_save) \ +do { \ + asm volatile ("stx %%l0, %0": "=m"(l_reg_save[0])); \ + asm volatile ("stx %%l1, %0": "=m"(l_reg_save[1])); \ + asm volatile ("stx %%l2, %0": "=m"(l_reg_save[2])); \ + asm volatile ("stx %%l3, %0": "=m"(l_reg_save[3])); \ + asm volatile ("stx %%l4, %0": "=m"(l_reg_save[4])); \ + asm volatile ("stx %%l5, %0": "=m"(l_reg_save[5])); \ + asm volatile ("stx %%l6, %0": "=m"(l_reg_save[6])); \ + asm volatile ("stx %%l7, %0": "=m"(l_reg_save[7])); \ +} while (0) + +#define LOAD_L_REGS(l_reg_save) \ +do { \ + asm volatile ("ldx %0, %%l0":: "m"(l_reg_save[0])); \ + asm volatile ("ldx %0, %%l1":: "m"(l_reg_save[1])); \ + asm volatile ("ldx %0, %%l2":: "m"(l_reg_save[2])); \ + asm volatile ("ldx %0, %%l3":: "m"(l_reg_save[3])); \ + asm volatile ("ldx %0, %%l4":: "m"(l_reg_save[4])); \ + asm volatile ("ldx %0, %%l5":: "m"(l_reg_save[5])); \ + asm volatile ("ldx %0, %%l6":: "m"(l_reg_save[6])); \ + asm volatile ("ldx %0, %%l7":: "m"(l_reg_save[7])); \ +} while (0) + #define SAVE_G1_REG(g1_reg) \ asm volatile ("stx %%g1, %0": "=m"(g1_reg)) From lattner at cs.uiuc.edu Mon Jul 19 22:58:17 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 19 Jul 2004 22:58:17 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/IPO/GlobalConstifier.cpp Message-ID: <200407200358.WAA22784@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/IPO: GlobalConstifier.cpp updated: 1.4 -> 1.5 --- Log message: Ignore instructions that are in trivially dead functions. This allows us to constify 14 globals instead of 4 in a trivial C++ testcase. --- Diffs of the changes: (+17 -4) Index: llvm/lib/Transforms/IPO/GlobalConstifier.cpp diff -u llvm/lib/Transforms/IPO/GlobalConstifier.cpp:1.4 llvm/lib/Transforms/IPO/GlobalConstifier.cpp:1.5 --- llvm/lib/Transforms/IPO/GlobalConstifier.cpp:1.4 Sun Jul 18 14:56:20 2004 +++ llvm/lib/Transforms/IPO/GlobalConstifier.cpp Mon Jul 19 22:58:07 2004 @@ -39,6 +39,16 @@ Pass *llvm::createGlobalConstifierPass() { return new Constifier(); } +/// A lot of global constants are stored only in trivially dead setter +/// functions. Because we don't want to cycle between globaldce and this pass, +/// just do a simple check to catch the common case. +static bool ContainingFunctionIsTriviallyDead(Instruction *I) { + Function *F = I->getParent()->getParent(); + if (!F->hasInternalLinkage()) return false; + F->removeDeadConstantUsers(); + return F->use_empty(); +} + /// isStoredThrough - Return false if the specified pointer is provably never /// stored through. If we can't tell, we must conservatively assume it might. /// @@ -48,10 +58,13 @@ if (isStoredThrough(CE)) return true; } else if (Instruction *I = dyn_cast(*UI)) { - if (I->getOpcode() == Instruction::GetElementPtr) { - if (isStoredThrough(I)) return true; - } else if (!isa(*UI) && !isa(*UI)) - return true; // Any other non-load instruction might store! + if (!ContainingFunctionIsTriviallyDead(I)) { + if (I->getOpcode() == Instruction::GetElementPtr) { + if (isStoredThrough(I)) return true; + } else if (!isa(*UI) && !isa(*UI)) { + return true; // Any other non-load instruction might store! + } + } } else { // Otherwise must be a global or some other user. return true; From lattner at cs.uiuc.edu Tue Jul 20 00:20:49 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 20 Jul 2004 00:20:49 -0500 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/InstCombine/IntPtrCast.ll Message-ID: <200407200520.AAA23919@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/InstCombine: IntPtrCast.ll added (r1.1) --- Log message: new testcase --- Diffs of the changes: (+8 -0) Index: llvm/test/Regression/Transforms/InstCombine/IntPtrCast.ll diff -c /dev/null llvm/test/Regression/Transforms/InstCombine/IntPtrCast.ll:1.1 *** /dev/null Tue Jul 20 00:20:49 2004 --- llvm/test/Regression/Transforms/InstCombine/IntPtrCast.ll Tue Jul 20 00:20:39 2004 *************** *** 0 **** --- 1,8 ---- + ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep cast + target pointersize = 32 + + int *%test(int *%P) { + %V = cast int* %P to int + %P2 = cast int %V to int* + ret int* %P2 + } From lattner at cs.uiuc.edu Tue Jul 20 00:21:10 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 20 Jul 2004 00:21:10 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp Message-ID: <200407200521.AAA23928@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: InstructionCombining.cpp updated: 1.227 -> 1.228 --- Log message: Implement Transforms/InstCombine/IntPtrCast.ll --- Diffs of the changes: (+16 -11) Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.227 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.228 --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.227 Mon Jul 19 20:48:15 2004 +++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Tue Jul 20 00:21:00 2004 @@ -1966,7 +1966,7 @@ // instruction. // static inline bool isEliminableCastOfCast(const Type *SrcTy, const Type *MidTy, - const Type *DstTy) { + const Type *DstTy, TargetData *TD) { // It is legal to eliminate the instruction if casting A->B->A if the sizes // are identical and the bits don't get reinterpreted (for example @@ -1974,6 +1974,15 @@ if (SrcTy == DstTy && SrcTy->isLosslesslyConvertibleTo(MidTy)) return true; + // If the source and destination types are pointer types, and the intermediate + // is an integer type bigger than a pointer, eliminate the casts. + if (isa(SrcTy) && isa(DstTy)) { + if (isa(MidTy)) return true; + + if (MidTy->isInteger() && MidTy->getPrimitiveSize() >= TD->getPointerSize()) + return true; + } + // Allow free casting and conversion of sizes as long as the sign doesn't // change... if (SrcTy->isIntegral() && MidTy->isIntegral() && DstTy->isIntegral()) { @@ -2010,18 +2019,14 @@ return true; } } - - // Otherwise, we cannot succeed. Specifically we do not want to allow things - // like: short -> ushort -> uint, because this can create wrong results if - // the input short is negative! - // return false; } -static bool ValueRequiresCast(const Value *V, const Type *Ty) { +static bool ValueRequiresCast(const Value *V, const Type *Ty, TargetData *TD) { if (V->getType() == Ty || isa(V)) return false; if (const CastInst *CI = dyn_cast(V)) - if (isEliminableCastOfCast(CI->getOperand(0)->getType(), CI->getType(), Ty)) + if (isEliminableCastOfCast(CI->getOperand(0)->getType(), CI->getType(), Ty, + TD)) return false; return true; } @@ -2056,7 +2061,7 @@ // if (CastInst *CSrc = dyn_cast(Src)) { if (isEliminableCastOfCast(CSrc->getOperand(0)->getType(), - CSrc->getType(), CI.getType())) { + CSrc->getType(), CI.getType(), TD)) { // This instruction now refers directly to the cast's src operand. This // has a good chance of making CSrc dead. CI.setOperand(0, CSrc->getOperand(0)); @@ -2153,8 +2158,8 @@ // Don't insert two casts if they cannot be eliminated. We allow two // casts to be inserted if the sizes are the same. This could only be // converting signedness, which is a noop. - if (DestBitSize == SrcBitSize || !ValueRequiresCast(Op1, DestTy) || - !ValueRequiresCast(Op0, DestTy)) { + if (DestBitSize == SrcBitSize || !ValueRequiresCast(Op1, DestTy,TD) || + !ValueRequiresCast(Op0, DestTy, TD)) { Value *Op0c = InsertOperandCastBefore(Op0, DestTy, SrcI); Value *Op1c = InsertOperandCastBefore(Op1, DestTy, SrcI); return BinaryOperator::create(cast(SrcI) From lattner at cs.uiuc.edu Tue Jul 20 00:45:34 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 20 Jul 2004 00:45:34 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Utils/InlineFunction.cpp Message-ID: <200407200545.AAA25154@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Utils: InlineFunction.cpp updated: 1.25 -> 1.26 --- Log message: Fix a serious code pessimization problem. If an inlined function has a single return, clone the 'ret' BB code into the block AFTER the inlined call, not the other way around. --- Diffs of the changes: (+6 -5) Index: llvm/lib/Transforms/Utils/InlineFunction.cpp diff -u llvm/lib/Transforms/Utils/InlineFunction.cpp:1.25 llvm/lib/Transforms/Utils/InlineFunction.cpp:1.26 --- llvm/lib/Transforms/Utils/InlineFunction.cpp:1.25 Fri Apr 16 00:17:59 2004 +++ llvm/lib/Transforms/Utils/InlineFunction.cpp Tue Jul 20 00:45:24 2004 @@ -304,14 +304,15 @@ // Splice the code from the return block into the block that it will return // to, which contains the code that was after the call. BasicBlock *ReturnBB = Returns[0]->getParent(); - ReturnBB->getInstList().splice(Returns[0], AfterCallBB->getInstList()); + AfterCallBB->getInstList().splice(AfterCallBB->begin(), + ReturnBB->getInstList()); - // Update PHI nodes that use the AfterCallBB to use the ReturnBB. - AfterCallBB->replaceAllUsesWith(ReturnBB); + // Update PHI nodes that use the ReturnBB to use the AfterCallBB. + ReturnBB->replaceAllUsesWith(AfterCallBB); - // Delete the return instruction now and empty AfterCallBB now. + // Delete the return instruction now and empty ReturnBB now. Returns[0]->getParent()->getInstList().erase(Returns[0]); - Caller->getBasicBlockList().erase(AfterCallBB); + Caller->getBasicBlockList().erase(ReturnBB); } // Since we are now done with the Call/Invoke, we can delete it. From alkis at cs.uiuc.edu Tue Jul 20 05:20:14 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Tue, 20 Jul 2004 05:20:14 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervals.cpp Message-ID: <200407201020.FAA31422@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveIntervals.cpp updated: 1.97 -> 1.98 --- Log message: Remove unneeded functor. LiveInterval has a < operator. --- Diffs of the changes: (+1 -11) Index: llvm/lib/CodeGen/LiveIntervals.cpp diff -u llvm/lib/CodeGen/LiveIntervals.cpp:1.97 llvm/lib/CodeGen/LiveIntervals.cpp:1.98 --- llvm/lib/CodeGen/LiveIntervals.cpp:1.97 Mon Jul 19 10:16:53 2004 +++ llvm/lib/CodeGen/LiveIntervals.cpp Tue Jul 20 05:20:03 2004 @@ -179,16 +179,6 @@ return true; } -namespace { - /// CompareIntervalStar - This is a simple comparison function for interval - /// pointers. It compares based on their starting point. - struct CompareIntervalStar { - bool operator()(LiveInterval *LHS, LiveInterval* RHS) const { - return LHS->start() < RHS->start(); - } - }; -} - std::vector LiveIntervals::addIntervalsForSpills( const LiveInterval& li, VirtRegMap& vrm, @@ -282,7 +272,7 @@ // The proper way to fix this is to process all uses of the vreg before we // process any defs. However, this would require refactoring the above // blob of code, which I'm not feeling up to right now. - std::sort(added.begin(), added.end(), CompareIntervalStar()); + std::sort(added.begin(), added.end(), less_ptr()); return added; } From alkis at cs.uiuc.edu Tue Jul 20 08:28:27 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Tue, 20 Jul 2004 08:28:27 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/VirtRegMap.h Message-ID: <200407201328.IAA18831@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: VirtRegMap.h updated: 1.11 -> 1.12 --- Log message: Add function to clear all virtual->physical mappings but not assigned stack slots. This is in preparation for the iterative linear scan. --- Diffs of the changes: (+5 -0) Index: llvm/lib/CodeGen/VirtRegMap.h diff -u llvm/lib/CodeGen/VirtRegMap.h:1.11 llvm/lib/CodeGen/VirtRegMap.h:1.12 --- llvm/lib/CodeGen/VirtRegMap.h:1.11 Sat May 29 15:38:05 2004 +++ llvm/lib/CodeGen/VirtRegMap.h Tue Jul 20 08:28:17 2004 @@ -87,6 +87,11 @@ v2pMap_[virtReg] = NO_PHYS_REG; } + void clearAllVirt() { + v2pMap_.clear(); + grow(); + } + bool hasStackSlot(unsigned virtReg) const { return getStackSlot(virtReg) != NO_STACK_SLOT; } From alkis at cs.uiuc.edu Tue Jul 20 08:55:43 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Tue, 20 Jul 2004 08:55:43 -0500 Subject: [llvm-commits] CVS: llvm-java/Makefile.rules Message-ID: <200407201355.IAA18974@zion.cs.uiuc.edu> Changes in directory llvm-java: Makefile.rules updated: 1.4 -> 1.5 --- Log message: Use PROJTOOLCURRENT instead of an explicit path. --- Diffs of the changes: (+1 -1) Index: llvm-java/Makefile.rules diff -u llvm-java/Makefile.rules:1.4 llvm-java/Makefile.rules:1.5 --- llvm-java/Makefile.rules:1.4 Thu Jul 15 06:28:44 2004 +++ llvm-java/Makefile.rules Tue Jul 20 08:55:33 2004 @@ -14,7 +14,7 @@ touch .class-stamp endif -CLASS2LLVM := $(LEVEL)/tools/Debug/class2llvm$(EXEEXT) +CLASS2LLVM := $(PROJTOOLCURRENT)/class2llvm$(EXEEXT) LDIS := $(LLVMTOOLCURRENT)/llvm-dis$(EXEEXT) LAS := $(LLVMTOOLCURRENT)/llvm-as$(EXEEXT) LLINK := $(LLVMTOOLCURRENT)/llvm-link$(EXEEXT) From brukman at cs.uiuc.edu Tue Jul 20 10:58:48 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Tue, 20 Jul 2004 10:58:48 -0500 Subject: [llvm-commits] CVS: llvm/test/Programs/MultiSource/Benchmarks/McCat/17-bintr/bintree.h Message-ID: <200407201558.KAA20305@zion.cs.uiuc.edu> Changes in directory llvm/test/Programs/MultiSource/Benchmarks/McCat/17-bintr: bintree.h updated: 1.2 -> 1.3 --- Log message: * malloc() is declared in on MacOS X * Make file readable: fix whitespace --- Diffs of the changes: (+26 -27) Index: llvm/test/Programs/MultiSource/Benchmarks/McCat/17-bintr/bintree.h diff -u llvm/test/Programs/MultiSource/Benchmarks/McCat/17-bintr/bintree.h:1.2 llvm/test/Programs/MultiSource/Benchmarks/McCat/17-bintr/bintree.h:1.3 --- llvm/test/Programs/MultiSource/Benchmarks/McCat/17-bintr/bintree.h:1.2 Wed Jun 23 09:23:34 2004 +++ llvm/test/Programs/MultiSource/Benchmarks/McCat/17-bintr/bintree.h Tue Jul 20 10:58:38 2004 @@ -1,11 +1,11 @@ /***************************************************************************/ -/* */ -/* Filename : bintree.h */ -/* */ -/* Author : Frederic Bergeron (91 485 12) */ -/* */ -/* Date : 1996/09/26 */ -/* */ +/* */ +/* Filename : bintree.h */ +/* */ +/* Author : Frederic Bergeron (91 485 12) */ +/* */ +/* Date : 1996/09/26 */ +/* */ /***************************************************************************/ #ifndef _bintree @@ -13,44 +13,43 @@ #include "general.h" -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) || defined(__APPLE__) # include #else # include #endif - struct binaryTree { - int value; - struct binaryTree* left; - struct binaryTree* right; + int value; + struct binaryTree* left; + struct binaryTree* right; }; +struct binaryTree* createBinaryTree(int newValue); -struct binaryTree* createBinaryTree( int newValue ); +void printBinaryTree(struct binaryTree* tree); -void printBinaryTree( struct binaryTree* tree ); +void printSortedBinaryTree(struct binaryTree* tree); -void printSortedBinaryTree( struct binaryTree* tree ); +struct binaryTree* insertSortedBinaryTree(int newValue, + struct binaryTree** tree); -struct binaryTree* insertSortedBinaryTree( int newValue, - struct binaryTree** tree ); +double getArithmeticMeanBinaryTree(struct binaryTree* tree); -double getArithmeticMeanBinaryTree( struct binaryTree* tree ); +double getArithmeticMeanOptimized(struct binaryTree* tree); -double getArithmeticMeanOptimized( struct binaryTree* tree ); +void getArithmeticMeanOptimizedRecurs(struct binaryTree* tree, double* sum, + double* count); -void getArithmeticMeanOptimizedRecurs( struct binaryTree* tree, double* sum, double* count ); +int memberOfBinaryTree(struct binaryTree* tree, int searchedValue); -int memberOfBinaryTree( struct binaryTree* tree, int searchedValue ); +void memberOfBinaryTreeRecurs(struct binaryTree* tree, int searchedValue, + int* found); -void memberOfBinaryTreeRecurs( struct binaryTree* tree, int searchedValue, int* found ); +int memberOfSortedBinaryTree(struct binaryTree* tree, int searchedValue); -int memberOfSortedBinaryTree( struct binaryTree* tree, int searchedValue ); +int getSizeBinaryTree(struct binaryTree* tree); -int getSizeBinaryTree( struct binaryTree* tree ); +double getSumBinaryTree(struct binaryTree* tree); -double getSumBinaryTree( struct binaryTree* tree ); - - #endif From brukman at cs.uiuc.edu Tue Jul 20 11:04:11 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Tue, 20 Jul 2004 11:04:11 -0500 Subject: [llvm-commits] CVS: llvm/test/Programs/SingleSource/Benchmarks/Misc/mandel.c Message-ID: <200407201604.LAA20436@zion.cs.uiuc.edu> Changes in directory llvm/test/Programs/SingleSource/Benchmarks/Misc: mandel.c updated: 1.8 -> 1.9 --- Log message: Some platforms (e.g., MacOS X) define cabs() as: struct {double x, y;} z; double cabs(z); cabs(z) == hypot(x,y) == sqrt(x*x+y*y), so rewrite to be more portable. --- Diffs of the changes: (+3 -3) Index: llvm/test/Programs/SingleSource/Benchmarks/Misc/mandel.c diff -u llvm/test/Programs/SingleSource/Benchmarks/Misc/mandel.c:1.8 llvm/test/Programs/SingleSource/Benchmarks/Misc/mandel.c:1.9 --- llvm/test/Programs/SingleSource/Benchmarks/Misc/mandel.c:1.8 Tue Jun 22 14:00:55 2004 +++ llvm/test/Programs/SingleSource/Benchmarks/Misc/mandel.c Tue Jul 20 11:04:01 2004 @@ -14,9 +14,9 @@ #define I 1.0iF -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) || defined(__APPLE__) #include -#include +#include #else #include #endif @@ -35,7 +35,7 @@ for (n = 0; n < MAX_ITER; ++n) { z = z * z + c; - if (cabs(z) >= ESCAPE) + if (hypot(__real__ z, __imag__ z) >= ESCAPE) break; } emit(z); From brukman at cs.uiuc.edu Tue Jul 20 11:11:30 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Tue, 20 Jul 2004 11:11:30 -0500 Subject: [llvm-commits] CVS: llvm/test/Programs/SingleSource/Benchmarks/Misc/mandel.c Message-ID: <200407201611.LAA20514@zion.cs.uiuc.edu> Changes in directory llvm/test/Programs/SingleSource/Benchmarks/Misc: mandel.c updated: 1.9 -> 1.10 --- Log message: Unbreak FreeBSD support -- it needs --- Diffs of the changes: (+5 -2) Index: llvm/test/Programs/SingleSource/Benchmarks/Misc/mandel.c diff -u llvm/test/Programs/SingleSource/Benchmarks/Misc/mandel.c:1.9 llvm/test/Programs/SingleSource/Benchmarks/Misc/mandel.c:1.10 --- llvm/test/Programs/SingleSource/Benchmarks/Misc/mandel.c:1.9 Tue Jul 20 11:04:01 2004 +++ llvm/test/Programs/SingleSource/Benchmarks/Misc/mandel.c Tue Jul 20 11:11:20 2004 @@ -14,12 +14,15 @@ #define I 1.0iF -#if defined(__FreeBSD__) || defined(__APPLE__) -#include +#if defined(__FreeBSD__) +#include +#elif defined(__APPLE__) #include #else #include #endif + +#include volatile double __complex__ accum; void emit(double __complex__ X) { From brukman at cs.uiuc.edu Tue Jul 20 11:12:42 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Tue, 20 Jul 2004 11:12:42 -0500 Subject: [llvm-commits] CVS: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/malloc_.h Message-ID: <200407201612.LAA20551@zion.cs.uiuc.edu> Changes in directory llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs: malloc_.h updated: 1.2 -> 1.3 --- Log message: MacOS X declares malloc() in --- Diffs of the changes: (+1 -1) Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/malloc_.h diff -u llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/malloc_.h:1.2 llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/malloc_.h:1.3 --- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/malloc_.h:1.2 Wed Jun 23 09:23:34 2004 +++ llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/malloc_.h Tue Jul 20 11:12:32 2004 @@ -30,7 +30,7 @@ # ifdef BSD4_2 extern char *malloc(); # else -# if defined(__FreeBSD__) +# if defined(__FreeBSD__) || defined(__APPLE__) # include # else # include From brukman at cs.uiuc.edu Tue Jul 20 11:14:16 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Tue, 20 Jul 2004 11:14:16 -0500 Subject: [llvm-commits] CVS: llvm/include/Support/StringExtras.h Message-ID: <200407201614.LAA20616@zion.cs.uiuc.edu> Changes in directory llvm/include/Support: StringExtras.h updated: 1.19 -> 1.20 --- Log message: Use C++-style instead of C-style --- Diffs of the changes: (+1 -1) Index: llvm/include/Support/StringExtras.h diff -u llvm/include/Support/StringExtras.h:1.19 llvm/include/Support/StringExtras.h:1.20 --- llvm/include/Support/StringExtras.h:1.19 Mon Jul 19 21:18:25 2004 +++ llvm/include/Support/StringExtras.h Tue Jul 20 11:14:06 2004 @@ -16,8 +16,8 @@ #include "Support/DataTypes.h" #include +#include #include -#include namespace llvm { From lattner at cs.uiuc.edu Tue Jul 20 11:56:32 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 20 Jul 2004 11:56:32 -0500 Subject: [llvm-commits] CVS: llvm/test/Programs/MultiSource/Benchmarks/McCat/17-bintr/bintree.h Message-ID: <200407201656.LAA32503@apoc.cs.uiuc.edu> Changes in directory llvm/test/Programs/MultiSource/Benchmarks/McCat/17-bintr: bintree.h updated: 1.3 -> 1.4 --- Log message: malloc is always located in stdlib.h --- Diffs of the changes: (+1 -5) Index: llvm/test/Programs/MultiSource/Benchmarks/McCat/17-bintr/bintree.h diff -u llvm/test/Programs/MultiSource/Benchmarks/McCat/17-bintr/bintree.h:1.3 llvm/test/Programs/MultiSource/Benchmarks/McCat/17-bintr/bintree.h:1.4 --- llvm/test/Programs/MultiSource/Benchmarks/McCat/17-bintr/bintree.h:1.3 Tue Jul 20 10:58:38 2004 +++ llvm/test/Programs/MultiSource/Benchmarks/McCat/17-bintr/bintree.h Tue Jul 20 11:56:22 2004 @@ -13,11 +13,7 @@ #include "general.h" -#if defined(__FreeBSD__) || defined(__APPLE__) -# include -#else -# include -#endif +#include struct binaryTree { int value; From lattner at cs.uiuc.edu Tue Jul 20 11:58:23 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 20 Jul 2004 11:58:23 -0500 Subject: [llvm-commits] CVS: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/malloc_.h Message-ID: <200407201658.LAA00386@apoc.cs.uiuc.edu> Changes in directory llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs: malloc_.h updated: 1.3 -> 1.4 --- Log message: stdlib is, well, a standard --- Diffs of the changes: (+2 -10) Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/malloc_.h diff -u llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/malloc_.h:1.3 llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/malloc_.h:1.4 --- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/malloc_.h:1.3 Tue Jul 20 11:12:32 2004 +++ llvm/test/Programs/MultiSource/Benchmarks/MallocBench/gs/malloc_.h Tue Jul 20 11:58:13 2004 @@ -20,21 +20,13 @@ /* malloc_.h */ /* Generic substitute for Unix malloc.h */ +#include + #ifdef __MSDOS__ # include #else # ifdef VMS extern char *malloc(); extern void free(); -# else -# ifdef BSD4_2 - extern char *malloc(); -# else -# if defined(__FreeBSD__) || defined(__APPLE__) -# include -# else -# include -# endif -# endif # endif #endif From brukman at cs.uiuc.edu Tue Jul 20 13:24:43 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Tue, 20 Jul 2004 13:24:43 -0500 Subject: [llvm-commits] CVS: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/make/arscan.c job.c make.h misc.c read.c Message-ID: <200407201824.NAA21483@zion.cs.uiuc.edu> Changes in directory llvm/test/Programs/MultiSource/Benchmarks/MallocBench/make: arscan.c updated: 1.3 -> 1.4 job.c updated: 1.3 -> 1.4 make.h updated: 1.3 -> 1.4 misc.c updated: 1.3 -> 1.4 read.c updated: 1.3 -> 1.4 --- Log message: Fix compilation on MacOS X, similar fixes as for FreeBSD. --- Diffs of the changes: (+14 -10) Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/make/arscan.c diff -u llvm/test/Programs/MultiSource/Benchmarks/MallocBench/make/arscan.c:1.3 llvm/test/Programs/MultiSource/Benchmarks/MallocBench/make/arscan.c:1.4 --- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/make/arscan.c:1.3 Fri Jun 25 03:03:11 2004 +++ llvm/test/Programs/MultiSource/Benchmarks/MallocBench/make/arscan.c Tue Jul 20 13:24:33 2004 @@ -37,8 +37,8 @@ #include #endif -#if (defined (STDC_HEADERS) || defined (__GNU_LIBRARY__) \ - || defined (POSIX)) || defined (__FreeBSD__) +#if (defined(STDC_HEADERS) || defined(__GNU_LIBRARY__) || \ + defined(POSIX)) || defined(__FreeBSD__) || defined(__APPLE__) #include #include #define ANSI_STRING @@ -94,7 +94,7 @@ #endif #if defined(__GNU_LIBRARY__) || defined(POSIX) || defined(_IBMR2) || \ - defined(__FreeBSD__) + defined(__FreeBSD__) || defined(__APPLE__) #include #else extern int read (), open (), close (), write (), fstat (); Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/make/job.c diff -u llvm/test/Programs/MultiSource/Benchmarks/MallocBench/make/job.c:1.3 llvm/test/Programs/MultiSource/Benchmarks/MallocBench/make/job.c:1.4 --- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/make/job.c:1.3 Fri Jun 25 03:03:11 2004 +++ llvm/test/Programs/MultiSource/Benchmarks/MallocBench/make/job.c Tue Jul 20 13:24:33 2004 @@ -30,7 +30,8 @@ /* Default shell to use. */ char default_shell[] = "/bin/sh"; -#if defined(POSIX) || defined(__GNU_LIBRARY__) || defined(__FreeBSD__) +#if defined(POSIX) || defined(__GNU_LIBRARY__) || defined(__FreeBSD__) || \ + defined(__APPLE__) #include #include #define GET_NGROUPS_MAX sysconf (_SC_NGROUPS_MAX) @@ -100,7 +101,8 @@ #endif /* WTERMSIG defined or USG and don't have . */ -#if defined(__GNU_LIBRARY__) || defined(POSIX) || defined(__CYGWIN__) || defined(__FreeBSD__) +#if defined(__GNU_LIBRARY__) || defined(POSIX) || defined(__CYGWIN__) || \ + defined(__FreeBSD__) || defined(__APPLE__) #include #define GID_T gid_t Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/make/make.h diff -u llvm/test/Programs/MultiSource/Benchmarks/MallocBench/make/make.h:1.3 llvm/test/Programs/MultiSource/Benchmarks/MallocBench/make/make.h:1.4 --- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/make/make.h:1.3 Fri Jun 25 03:03:11 2004 +++ llvm/test/Programs/MultiSource/Benchmarks/MallocBench/make/make.h Tue Jul 20 13:24:33 2004 @@ -82,8 +82,8 @@ #endif -#if (defined (STDC_HEADERS) || defined (__GNU_LIBRARY__) \ - || defined (POSIX) || defined(__FreeBSD__)) +#if (defined(STDC_HEADERS) || defined(__GNU_LIBRARY__) || \ + defined(POSIX) || defined(__FreeBSD__) || defined(__APPLE__)) #include #include #define ANSI_STRING @@ -216,7 +216,7 @@ #endif /* USG and don't have vfork. */ #if defined(__GNU_LIBRARY__) || defined(POSIX) || defined(__CYGWIN__) || \ - defined(__FreeBSD__) + defined(__FreeBSD__) || defined(__APPLE__) #include #include Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/make/misc.c diff -u llvm/test/Programs/MultiSource/Benchmarks/MallocBench/make/misc.c:1.3 llvm/test/Programs/MultiSource/Benchmarks/MallocBench/make/misc.c:1.4 --- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/make/misc.c:1.3 Fri Jun 25 03:03:11 2004 +++ llvm/test/Programs/MultiSource/Benchmarks/MallocBench/make/misc.c Tue Jul 20 13:24:33 2004 @@ -476,7 +476,8 @@ } #endif -#if !defined(POSIX) && !defined(__GNU_LIBRARY__) && !defined(__CYGWIN__) && !defined(__FreeBSD__) +#if !defined(POSIX) && !defined(__GNU_LIBRARY__) && !defined(__CYGWIN__) && \ + !defined(__FreeBSD__) && !defined(__APPLE__) extern int getuid (), getgid (), geteuid (), getegid (); #ifdef USG extern int setuid (), setgid (); Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/make/read.c diff -u llvm/test/Programs/MultiSource/Benchmarks/MallocBench/make/read.c:1.3 llvm/test/Programs/MultiSource/Benchmarks/MallocBench/make/read.c:1.4 --- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/make/read.c:1.3 Fri Jun 25 03:03:11 2004 +++ llvm/test/Programs/MultiSource/Benchmarks/MallocBench/make/read.c Tue Jul 20 13:24:33 2004 @@ -22,7 +22,8 @@ #include "variable.h" /* This is POSIX.2, but most systems using -DPOSIX probably don't have it. */ -#if defined(__GNU_LIBRARY__) || defined(__CYGWIN__) || defined(__FreeBSD__) +#if defined(__GNU_LIBRARY__) || defined(__CYGWIN__) || defined(__FreeBSD__) || \ + defined(__APPLE__) #include #else #include "glob/glob.h" From brukman at cs.uiuc.edu Tue Jul 20 15:25:28 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Tue, 20 Jul 2004 15:25:28 -0500 Subject: [llvm-commits] CVS: llvm/docs/GettingStarted.html Message-ID: <200407202025.PAA22690@zion.cs.uiuc.edu> Changes in directory llvm/docs: GettingStarted.html updated: 1.63 -> 1.64 --- Log message: Refer would-be llvm-gcc source users/hackers to the compilation guide. --- Diffs of the changes: (+2 -3) Index: llvm/docs/GettingStarted.html diff -u llvm/docs/GettingStarted.html:1.63 llvm/docs/GettingStarted.html:1.64 --- llvm/docs/GettingStarted.html:1.63 Sun Jul 18 17:32:22 2004 +++ llvm/docs/GettingStarted.html Tue Jul 20 15:25:18 2004 @@ -240,8 +240,7 @@ on your platform.

    The GCC front end is not very portable at the moment. If you want to get it -to work on another platform, you can download a copy of the source and try to -compile it on your platform.

    +to work on another platform, you can download a copy of the source and try to compile it on your platform.

    @@ -1267,7 +1266,7 @@ Chris Lattner
    The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/07/18 22:32:22 $ + Last modified: $Date: 2004/07/20 20:25:18 $ From gaeke at cs.uiuc.edu Tue Jul 20 17:23:09 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Tue, 20 Jul 2004 17:23:09 -0500 Subject: [llvm-commits] CVS: reopt/lib/Inst/lib/Phase1/Phase1.cpp PrimInfo.cpp Message-ID: <200407202223.RAA23669@zion.cs.uiuc.edu> Changes in directory reopt/lib/Inst/lib/Phase1: Phase1.cpp updated: 1.31 -> 1.32 PrimInfo.cpp updated: 1.19 -> 1.20 --- Log message: Add hacks to get this stuff compiling again - I actually have no idea if it still works :-( --- Diffs of the changes: (+5 -11) Index: reopt/lib/Inst/lib/Phase1/Phase1.cpp diff -u reopt/lib/Inst/lib/Phase1/Phase1.cpp:1.31 reopt/lib/Inst/lib/Phase1/Phase1.cpp:1.32 --- reopt/lib/Inst/lib/Phase1/Phase1.cpp:1.31 Tue Feb 24 14:42:03 2004 +++ reopt/lib/Inst/lib/Phase1/Phase1.cpp Tue Jul 20 17:22:59 2004 @@ -137,14 +137,9 @@ if(ConstantExpr* ce = dyn_cast(rpairParam)) { assert(ce->getNumOperands() == 1 && "ConstantExpr encountered with unexpected #opds"); - if(ConstantPointerRef* cpr = - dyn_cast(ce->getOperand(0))) { - if(Function* func = dyn_cast(cpr->getValue())) { - return func; - } - } + if (Function* func = dyn_cast (ce->getOperand (0))) + return func; } - return 0; } @@ -304,9 +299,8 @@ for(Value::use_iterator u = startFunc->use_begin(), ue = startFunc->use_end(); u != ue; ++u) { - if(isa(*u)) { - continue; // skips forward declarations of sigfun - } + if (isa (*u)) + continue; // skips forward declarations of sigfun CallInst* startCall = dyn_cast(*u); assert(startCall && "Use of a registered pp sigfun not in a call"); Index: reopt/lib/Inst/lib/Phase1/PrimInfo.cpp diff -u reopt/lib/Inst/lib/Phase1/PrimInfo.cpp:1.19 reopt/lib/Inst/lib/Phase1/PrimInfo.cpp:1.20 --- reopt/lib/Inst/lib/Phase1/PrimInfo.cpp:1.19 Tue Feb 24 14:42:03 2004 +++ reopt/lib/Inst/lib/Phase1/PrimInfo.cpp Tue Jul 20 17:22:59 2004 @@ -86,7 +86,7 @@ std::vector init; init.push_back(ConstantUInt::get(Type::UIntTy, siteID)); // siteID init.push_back(ConstantUInt::get(Type::UIntTy, gbtType)); // gbtType - init.push_back(ConstantPointerRef::get(loadVar)); // loadVar + init.push_back(loadVar); // loadVar return ConstantStruct::get(st, init); } From reid at x10sys.com Tue Jul 20 17:31:28 2004 From: reid at x10sys.com (Reid Spencer) Date: Wed, 21 Jul 2004 00:31:28 +0200 Subject: [llvm-commits] CVS: reopt/lib/Inst/lib/Phase1/Phase1.cpp PrimInfo.cpp In-Reply-To: <200407202223.RAA23669@zion.cs.uiuc.edu> References: <200407202223.RAA23669@zion.cs.uiuc.edu> Message-ID: <40FD9D40.9030303@x10sys.com> Brian, For your peace of mind, the CPR changes look right to me .. at least this change set shouldn't have borked it in new ways. Reid. Brian Gaeke wrote: > Changes in directory reopt/lib/Inst/lib/Phase1: > > Phase1.cpp updated: 1.31 -> 1.32 > PrimInfo.cpp updated: 1.19 -> 1.20 > > --- > Log message: > > Add hacks to get this stuff compiling again - I actually have no > idea if it still works :-( > > > --- > Diffs of the changes: (+5 -11) > > Index: reopt/lib/Inst/lib/Phase1/Phase1.cpp > diff -u reopt/lib/Inst/lib/Phase1/Phase1.cpp:1.31 reopt/lib/Inst/lib/Phase1/Phase1.cpp:1.32 > --- reopt/lib/Inst/lib/Phase1/Phase1.cpp:1.31 Tue Feb 24 14:42:03 2004 > +++ reopt/lib/Inst/lib/Phase1/Phase1.cpp Tue Jul 20 17:22:59 2004 > @@ -137,14 +137,9 @@ > if(ConstantExpr* ce = dyn_cast(rpairParam)) { > assert(ce->getNumOperands() == 1 && > "ConstantExpr encountered with unexpected #opds"); > - if(ConstantPointerRef* cpr = > - dyn_cast(ce->getOperand(0))) { > - if(Function* func = dyn_cast(cpr->getValue())) { > - return func; > - } > - } > + if (Function* func = dyn_cast (ce->getOperand (0))) > + return func; > } > - > return 0; > } > > @@ -304,9 +299,8 @@ > for(Value::use_iterator u = startFunc->use_begin(), > ue = startFunc->use_end(); u != ue; ++u) { > > - if(isa(*u)) { > - continue; // skips forward declarations of sigfun > - } > + if (isa (*u)) > + continue; // skips forward declarations of sigfun > > CallInst* startCall = dyn_cast(*u); > assert(startCall && "Use of a registered pp sigfun not in a call"); > > > Index: reopt/lib/Inst/lib/Phase1/PrimInfo.cpp > diff -u reopt/lib/Inst/lib/Phase1/PrimInfo.cpp:1.19 reopt/lib/Inst/lib/Phase1/PrimInfo.cpp:1.20 > --- reopt/lib/Inst/lib/Phase1/PrimInfo.cpp:1.19 Tue Feb 24 14:42:03 2004 > +++ reopt/lib/Inst/lib/Phase1/PrimInfo.cpp Tue Jul 20 17:22:59 2004 > @@ -86,7 +86,7 @@ > std::vector init; > init.push_back(ConstantUInt::get(Type::UIntTy, siteID)); // siteID > init.push_back(ConstantUInt::get(Type::UIntTy, gbtType)); // gbtType > - init.push_back(ConstantPointerRef::get(loadVar)); // loadVar > + init.push_back(loadVar); // loadVar > return ConstantStruct::get(st, init); > } > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://mail.cs.uiuc.edu/mailman/listinfo/llvm-commits > From gaeke at cs.uiuc.edu Tue Jul 20 17:41:51 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Tue, 20 Jul 2004 17:41:51 -0500 (CDT) Subject: [llvm-commits] CVS: reopt/include/reopt/TraceJIT.h Message-ID: <200407202241.RAA06873@seraph.cs.uiuc.edu> Changes in directory reopt/include/reopt: TraceJIT.h updated: 1.1 -> 1.2 --- Log message: Add prototype for addOptimizationPasses(). --- Diffs of the changes: (+1 -0) Index: reopt/include/reopt/TraceJIT.h diff -u reopt/include/reopt/TraceJIT.h:1.1 reopt/include/reopt/TraceJIT.h:1.2 --- reopt/include/reopt/TraceJIT.h:1.1 Wed Jun 30 01:33:17 2004 +++ reopt/include/reopt/TraceJIT.h Tue Jul 20 17:41:41 2004 @@ -99,6 +99,7 @@ MachineCodeEmitter *getEmitter() { return MCE; } private: void addPassesToReoptimizeTrace (FunctionPassManager &PM); + void addOptimizationPasses (FunctionPassManager &PM); void maybeAddInternalGlobal (GlobalValue *GV, unsigned int &Counter); void addInternalGlobalMappings (Module &M); void runJITOnFunction (Function *F); From gaeke at cs.uiuc.edu Tue Jul 20 17:41:52 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Tue, 20 Jul 2004 17:41:52 -0500 (CDT) Subject: [llvm-commits] CVS: reopt/lib/TraceJIT/TraceJIT.cpp Message-ID: <200407202241.RAA06880@seraph.cs.uiuc.edu> Changes in directory reopt/lib/TraceJIT: TraceJIT.cpp updated: 1.5 -> 1.6 --- Log message: Add call to addOptimizationPasses(). --- Diffs of the changes: (+1 -0) Index: reopt/lib/TraceJIT/TraceJIT.cpp diff -u reopt/lib/TraceJIT/TraceJIT.cpp:1.5 reopt/lib/TraceJIT/TraceJIT.cpp:1.6 --- reopt/lib/TraceJIT/TraceJIT.cpp:1.5 Sun Jul 11 22:03:39 2004 +++ reopt/lib/TraceJIT/TraceJIT.cpp Tue Jul 20 17:41:42 2004 @@ -50,6 +50,7 @@ DEBUG (PM.add (new PrintFunctionPass ("Function created from trace:\n", &std::cerr))); DEBUG (PM.add (createVerifierPass ())); + addOptimizationPasses (PM); TJI.addPassesToJITCompile (PM); DEBUG (PM.add (createMachineFunctionPrinterPass (&std::cerr, "Before unpacking:\n"))); From gaeke at cs.uiuc.edu Tue Jul 20 17:41:53 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Tue, 20 Jul 2004 17:41:53 -0500 (CDT) Subject: [llvm-commits] CVS: reopt/lib/TraceJIT/TraceJITOpts.cpp Message-ID: <200407202241.RAA06887@seraph.cs.uiuc.edu> Changes in directory reopt/lib/TraceJIT: TraceJITOpts.cpp added (r1.1) --- Log message: File containing stub function which will eventually add optimization passes to the TraceJIT. --- Diffs of the changes: (+20 -0) Index: reopt/lib/TraceJIT/TraceJITOpts.cpp diff -c /dev/null reopt/lib/TraceJIT/TraceJITOpts.cpp:1.1 *** /dev/null Tue Jul 20 17:41:53 2004 --- reopt/lib/TraceJIT/TraceJITOpts.cpp Tue Jul 20 17:41:43 2004 *************** *** 0 **** --- 1,20 ---- + //===-- TraceJITOpts.cpp - Optimizations for LLVM Trace JIT Compiler ------===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by the LLVM research group and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // Trace optimization passes are added here. + // + //===----------------------------------------------------------------------===// + + #include "reopt/TraceJIT.h" + #include "llvm/Transforms/Scalar.h" + using namespace llvm; + + void TraceJIT::addOptimizationPasses (FunctionPassManager &PM) { + } + From gaeke at cs.uiuc.edu Tue Jul 20 17:52:09 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Tue, 20 Jul 2004 17:52:09 -0500 (CDT) Subject: [llvm-commits] CVS: reopt/lib/TraceToFunction/TraceToFunction.cpp Message-ID: <200407202252.RAA06904@seraph.cs.uiuc.edu> Changes in directory reopt/lib/TraceToFunction: TraceToFunction.cpp updated: 1.77 -> 1.78 --- Log message: Fix bugs in hasUseDominatedByEdge having to do with the dominance properties of Phi nodes. --- Diffs of the changes: (+28 -3) Index: reopt/lib/TraceToFunction/TraceToFunction.cpp diff -u reopt/lib/TraceToFunction/TraceToFunction.cpp:1.77 reopt/lib/TraceToFunction/TraceToFunction.cpp:1.78 --- reopt/lib/TraceToFunction/TraceToFunction.cpp:1.77 Thu Jul 15 17:05:15 2004 +++ reopt/lib/TraceToFunction/TraceToFunction.cpp Tue Jul 20 17:51:59 2004 @@ -658,17 +658,42 @@ BasicBlock *target) { for (Value::use_iterator UI = defInst->use_begin (), UE = defInst->use_end (); UI != UE; ++UI) { + DEBUG (std::cerr << "hasUseDominatedByEdge: considering whether the " + << "edge from %" << source->getName () << " to %" + << target->getName () << " dominates user:\n" << **UI); if (Instruction *useInst = dyn_cast (*UI)) { - if (DS->dominates (&target->front(), useInst)) + DEBUG (std::cerr << "hasUseDominatedByEdge: user is in BB %" + << useInst->getParent()->getName () << "\n"); + bool dom; + if (PHINode *PN = dyn_cast(useInst)) { + BasicBlock *predBlock = 0; + for (unsigned i = 0; i < PN->getNumIncomingValues (); ++i) + if (PN->getIncomingValue (i) == defInst) { + predBlock = PN->getIncomingBlock (i); + break; + } + assert (predBlock + && "Couldn't find phi node pred block given incoming value"); + DEBUG (std::cerr << "hasUseDominatedByEdge: it's a phi node; pred. block is %" + << predBlock->getName () << "\n"); + dom = DS->dominates (&target->front(), predBlock->getTerminator()); + } else { + dom = DS->dominates (&target->front(), useInst); + } + if (dom) { + DEBUG (std::cerr << "hasUseDominatedByEdge: DOMINATED\n"); return true; + } else { + DEBUG (std::cerr << "hasUseDominatedByEdge: NOT DOMINATED\n"); + } } else { // Gack, it's not an Instruction. assert (0 && "Found non-Instruction User, don't know dominator info"); } } DEBUG (std::cerr << "hasUseDominatedByEdge: found no dominated use" - << " starting from " << target->getName () << " for:\n" - << *defInst); + << " starting from " << target->getName () << " for:\n" + << *defInst); return false; } From gaeke at cs.uiuc.edu Tue Jul 20 17:54:20 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Tue, 20 Jul 2004 17:54:20 -0500 (CDT) Subject: [llvm-commits] CVS: reopt/test/run-tests Message-ID: <200407202254.RAA06930@seraph.cs.uiuc.edu> Changes in directory reopt/test: run-tests updated: 1.12 -> 1.13 --- Log message: Add realmm, fix path for intmm in my private tree --- Diffs of the changes: (+2 -1) Index: reopt/test/run-tests diff -u reopt/test/run-tests:1.12 reopt/test/run-tests:1.13 --- reopt/test/run-tests:1.12 Thu Jul 8 14:23:29 2004 +++ reopt/test/run-tests Tue Jul 20 17:54:10 2004 @@ -63,7 +63,8 @@ hash) SUBDIR=SingleSource/Reoptimizer/Hash ;; towers) SUBDIR=SingleSource/Reoptimizer/Towers ;; treesort) SUBDIR=SingleSource/Reoptimizer/Treesort ;; - intmm) SUBDIR=SingleSource/Reoptimizer/IntMM ;; + intmm) SUBDIR=SingleSource/Reoptimizer/Intmm ;; + realmm) SUBDIR=SingleSource/Reoptimizer/Realmm ;; mcf) SUBDIR=External/SPEC/CINT2000/181.mcf; spectest=1 ;; art) SUBDIR=External/SPEC/CFP2000/179.art; spectest=1;; From gaeke at cs.uiuc.edu Tue Jul 20 18:08:05 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Tue, 20 Jul 2004 18:08:05 -0500 (CDT) Subject: [llvm-commits] CVS: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp Message-ID: <200407202308.SAA06977@seraph.cs.uiuc.edu> Changes in directory reopt/lib/LightWtProfiling: UnpackTraceFunction.cpp updated: 1.99 -> 1.100 --- Log message: I think the static stack words go at the bottom (%fp end) of the stack, not the top (%sp end). So the registers should come above the static stack words. --- Diffs of the changes: (+1 -1) Index: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp diff -u reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.99 reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.100 --- reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.99 Thu Jul 15 16:53:55 2004 +++ reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp Tue Jul 20 18:07:55 2004 @@ -141,7 +141,7 @@ } unsigned UnpackTraceFunction::stackOffsetForReg (const unsigned R) const { - return 2047 + StaticStackSize + 176 + R * 8; + return 2047 + 176 + R * 8; } std::string UnpackTraceFunction::RegStr (const unsigned R) const { From gaeke at cs.uiuc.edu Tue Jul 20 20:31:56 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Tue, 20 Jul 2004 20:31:56 -0500 (CDT) Subject: [llvm-commits] CVS: llvm/Makefile.rules Message-ID: <200407210131.UAA11275@seraph.cs.uiuc.edu> Changes in directory llvm: Makefile.rules updated: 1.187 -> 1.188 --- Log message: Move LLVM tool definitions to Makefile.rules --- Diffs of the changes: (+15 -2) Index: llvm/Makefile.rules diff -u llvm/Makefile.rules:1.187 llvm/Makefile.rules:1.188 --- llvm/Makefile.rules:1.187 Wed Jul 7 22:42:20 2004 +++ llvm/Makefile.rules Tue Jul 20 20:31:46 2004 @@ -256,10 +256,23 @@ LLVMGXX := PATH=$(LLVMTOOLCURRENT):$(PATH) $(LLVMGCCDIR)/bin/g++ #-------------------------------------------------------------------------- -# Some of the compiled LLVM tools which are used for compilation of runtime -# libraries. +# The compiled LLVM tools # + LLVMAS := $(LLVMTOOLCURRENT)/llvm-as$(EXEEXT) +# Find the location of the platform specific LLVM GCC libraries +LLVMGCCLIBDIR=$(dir $(shell $(LLVMGCC) -print-file-name=libgcc.a)) +# LLVM Tool Definitions (LLVMGCC, LLVMGXX, LLVMAS are provided by +# Makefile.rules) LLI = $(LLVMTOOLCURRENT)/lli$(EXEEXT) +LLC = $(LLVMTOOLCURRENT)/llc$(EXEEXT) +LGCCAS = $(LLVMTOOLCURRENT)/gccas$(EXEEXT) +LGCCLD = $(LGCCLDPROG) -L$(LLVMGCCLIBDIR) -L$(LLVMGCCDIR)/lib +LDIS = $(LLVMTOOLCURRENT)/llvm-dis$(EXEEXT) +LOPT = $(LLVMTOOLCURRENT)/opt$(EXEEXT) +LLINK = $(LLVMTOOLCURRENT)/llvm-link$(EXEEXT) +LPROF = $(LLVMTOOLCURRENT)/llvm-prof$(EXEEXT) +LANALYZE = $(LLVMTOOLCURRENT)/analyze$(EXEEXT) +LBUGPOINT= $(LLVMTOOLCURRENT)/bugpoint$(EXEEXT) ########################################################################### From gaeke at cs.uiuc.edu Tue Jul 20 20:31:57 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Tue, 20 Jul 2004 20:31:57 -0500 (CDT) Subject: [llvm-commits] CVS: llvm/test/Makefile.tests Message-ID: <200407210131.UAA11282@seraph.cs.uiuc.edu> Changes in directory llvm/test: Makefile.tests updated: 1.89 -> 1.90 --- Log message: Move LLVM tool definitions to Makefile.rules --- Diffs of the changes: (+0 -15) Index: llvm/test/Makefile.tests diff -u llvm/test/Makefile.tests:1.89 llvm/test/Makefile.tests:1.90 --- llvm/test/Makefile.tests:1.89 Mon Jun 21 21:26:33 2004 +++ llvm/test/Makefile.tests Tue Jul 20 20:31:47 2004 @@ -34,21 +34,6 @@ .PRECIOUS: Output/%.llvm.bc .PRECIOUS: Output/%.llvm -# Find the location of the platform specific LLVM GCC libraries -LLVMGCCLIBDIR=$(dir $(shell $(LLVMGCC) -print-file-name=libgcc.a)) - -# LLVM Tool Definitions (LLVMGCC, LLVMGXX, LLVMAS are provided by Makefile.rules) -LLI = $(LLVMTOOLCURRENT)/lli$(EXEEXT) -LLC = $(LLVMTOOLCURRENT)/llc$(EXEEXT) -LGCCAS = $(LLVMTOOLCURRENT)/gccas$(EXEEXT) -LGCCLD = $(LGCCLDPROG) -L$(LLVMGCCLIBDIR) -L$(LLVMGCCDIR)/lib -LDIS = $(LLVMTOOLCURRENT)/llvm-dis$(EXEEXT) -LOPT = $(LLVMTOOLCURRENT)/opt$(EXEEXT) -LLINK = $(LLVMTOOLCURRENT)/llvm-link$(EXEEXT) -LPROF = $(LLVMTOOLCURRENT)/llvm-prof$(EXEEXT) -LANALYZE = $(LLVMTOOLCURRENT)/analyze$(EXEEXT) -LBUGPOINT= $(LLVMTOOLCURRENT)/bugpoint$(EXEEXT) - LCCFLAGS += -O2 -Wall LCXXFLAGS += -O2 -Wall LLCFLAGS = From gaeke at cs.uiuc.edu Tue Jul 20 21:51:59 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Tue, 20 Jul 2004 21:51:59 -0500 (CDT) Subject: [llvm-commits] CVS: reopt/lib/TraceToFunction/TraceToFunction.cpp Message-ID: <200407210251.VAA11435@seraph.cs.uiuc.edu> Changes in directory reopt/lib/TraceToFunction: TraceToFunction.cpp updated: 1.78 -> 1.79 --- Log message: Turn on use of hasUseDominatedByEdge(). --- Diffs of the changes: (+1 -1) Index: reopt/lib/TraceToFunction/TraceToFunction.cpp diff -u reopt/lib/TraceToFunction/TraceToFunction.cpp:1.78 reopt/lib/TraceToFunction/TraceToFunction.cpp:1.79 --- reopt/lib/TraceToFunction/TraceToFunction.cpp:1.78 Tue Jul 20 17:51:59 2004 +++ reopt/lib/TraceToFunction/TraceToFunction.cpp Tue Jul 20 21:51:49 2004 @@ -790,7 +790,7 @@ for (LiveVariableVector::iterator SI = So.begin (), SE = So.end (); SI != SE; ++SI) if (dominates (T, cast ((*SI))->getParent (), -#if 0 // WARNING: hasUseDominatedByEdge isn't working right yet! +#if 1 // WARNING: hasUseDominatedByEdge isn't working right yet! BI->getParent ()) && hasUseDominatedByEdge (cast (*SI), srcB, successor)) From gaeke at cs.uiuc.edu Tue Jul 20 21:52:00 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Tue, 20 Jul 2004 21:52:00 -0500 (CDT) Subject: [llvm-commits] CVS: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp Message-ID: <200407210252.VAA11442@seraph.cs.uiuc.edu> Changes in directory reopt/lib/LightWtProfiling: UnpackTraceFunction.cpp updated: 1.100 -> 1.101 --- Log message: Don't touch the MatrixFn's %fp - apparently, this is some kind of ABI violation. Instead, we'll use %g1 as our TraceFn %fp. --- Diffs of the changes: (+33 -71) Index: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp diff -u reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.100 reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.101 --- reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.100 Tue Jul 20 18:07:55 2004 +++ reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp Tue Jul 20 21:51:50 2004 @@ -108,10 +108,6 @@ if (intCCRegSeen) RegsToSave.insert (SparcV9::ccr); - // Always put fp in the set because it is restored unconditionally. - static const unsigned fp = SparcV9::i6; - RegsToSave.insert (fp); - // Get the saved register allocator state for all live-in variables. // We are going to need to save live-in values which reside in registers // on the stack, so we need to dig their register numbers out now. @@ -179,8 +175,8 @@ void UnpackTraceFunction::rewriteProlog (MachineFunction &MF, MachineBasicBlock &EntryBB) { const SparcV9RegInfo &TRI = *TM->getRegInfo (); - static const unsigned sp = SparcV9::o6, fp = SparcV9::i6, g1 = SparcV9::g1, - g2 = SparcV9::g2; + static const unsigned sp = SparcV9::o6, MatrixFP = SparcV9::i6, + TraceFP = SparcV9::g1, g2 = SparcV9::g2; // UTF prolog: start out by clearing SAVE and stack-load instructions out // of the entry BB. @@ -190,9 +186,10 @@ std::vector E; - // 0. Save caller's stack pointer in %g1. + // 0. Save caller's stack pointer in TraceFP (%g1); it will be used + // as TraceFn's frame pointer. E.push_back (BuildMI (V9::ORr, 3).addMReg (sp).addZImm (0) - .addMReg (g1, MachineOperand::Def)); + .addMReg (TraceFP, MachineOperand::Def)); // 1. Emit ADD instruction to allocate the right amount of stack space. E.push_back (BuildMI (V9::ADDi, 3).addMReg (sp).addSImm (-TotalStackSize) @@ -242,24 +239,15 @@ RegType, g2); else if (Source.AllocState == AllocInfo::Spilled) // Copy live-in value from MatrixFn's stack - TRI.cpMem2RegMI (mvec, fp, Source.Placement, R, RegType, g2); + TRI.cpMem2RegMI (mvec, MatrixFP, Source.Placement, R, RegType, g2); if (Target.AllocState == AllocInfo::Spilled) // Finally copy it onto TraceFn's stack - TRI.cpReg2MemMI (mvec, R, g1, Target.Placement, RegType, g2); + TRI.cpReg2MemMI (mvec, R, TraceFP, Target.Placement, RegType, g2); for (std::vector::iterator vi = mvec.begin (), ve = mvec.end (); vi != ve; ++vi) E.push_back (*vi); } - // 4. Caller's stack pointer becomes our frame pointer. - // We do it now because copies (performed above) of live-ins spilled on - // MatrixFn's stack need to reference the old frame pointer (fp), and copies - // (also performed above) of live-ins spilled on TraceFn's stack need to - // reference the new frame pointer (g1). - E.push_back (BuildMI (V9::ORr, 3).addMReg (g1).addZImm (0) - .addMReg (fp, MachineOperand::Def)); - fpIsTraceFP = true; - MachineBasicBlock::iterator MBBIt = EntryBB.begin (); for (std::vector::iterator ei = E.begin (), ee = E.end (); ei != ee; ++ei) { @@ -353,11 +341,9 @@ const AllocInfo &Target, Value *liveOutValue, Value *liveOutTraceValue) { const SparcV9RegInfo &TRI = *TM->getRegInfo (); std::vector mvec; - static const unsigned sp = SparcV9::o6, fp = SparcV9::i6, g1 = SparcV9::g1, - g2 = SparcV9::g2, g3 = SparcV9::g3; + static const unsigned sp = SparcV9::o6, TraceFP = SparcV9::g1, + g2 = SparcV9::g2, g3 = SparcV9::g3, MatrixFP = SparcV9::i6; - assert (fpIsTraceFP - && "Can't call addLiveOutCopy without TraceFn stack frame pointer"); assert ((Target.AllocState == AllocInfo::Allocated || Target.AllocState == AllocInfo::Spilled) && "Live-out values must be in regs or spilled in the matrixFn"); @@ -369,7 +355,7 @@ << RegStr (Target.Placement) << " to RegsToSave set\n"); RegsToSave.insert (Target.Placement); } - unsigned R = g1, RegType; + unsigned R = SparcV9::g4, RegType; // We don't need to use a temp reg. if the live-out value is already // in a register in the TraceFn. if (Source.AllocState == AllocInfo::Allocated) @@ -385,7 +371,7 @@ g2, mvec); } else if (Source.AllocState == AllocInfo::Spilled) { // Copy live-out value from TraceFn's stack to the register. - TRI.cpMem2RegMI (mvec, fp, Source.Placement, R, RegType, g2); + TRI.cpMem2RegMI (mvec, TraceFP, Source.Placement, R, RegType, g2); } // Most live-outs are in registers in MatrixFn. They get saved on TraceFn's @@ -399,12 +385,7 @@ // MatrixFn's stack, so MatrixFn's frame pointer will be the base // register. But first we need to load it from the stack (FIXME: we // should only do this once!) - static const unsigned matrixFP = SparcV9::g3; - TRI.cpMem2RegMI (mvec, sp, stackOffsetForReg (fp), matrixFP, - TRI.getRegType(matrixFP), g2); - DEBUG (std::cerr << "addLiveOutCopy: loading matrixFn's frame pointer; " - << "value is spilled at offset = " << Target.Placement << "\n"); - BaseReg = matrixFP; + BaseReg = MatrixFP; Offset = Target.Placement; } TRI.cpReg2MemMI (mvec, R, BaseReg, Offset, RegType, g2); @@ -465,8 +446,8 @@ bool UnpackTraceFunction::rewriteEpilogInstr (MachineBasicBlock &MBB, MachineBasicBlock::iterator iter){ - static const unsigned sp = SparcV9::o6, fp = SparcV9::i6, g1 = SparcV9::g1, - g2 = SparcV9::g2, g3 = SparcV9::g3, matrixFP = SparcV9::g3; + static const unsigned sp = SparcV9::o6, g1 = SparcV9::g1, + g2 = SparcV9::g2, g3 = SparcV9::g3; const TargetInstrInfo &TII = *TM->getInstrInfo (); const SparcV9RegInfo &TRI = *TM->getRegInfo (); MachineInstr &inst = *iter; @@ -501,8 +482,6 @@ std::pair ai = GetValueAllocState (TF, V, false); AllocInfo &MatrixAI = ai.first; if (MatrixAI.AllocState == AllocInfo::Allocated) { - assert (fpIsTraceFP - && "Need TraceFn frame pointer to store live-out registers"); // MatrixAI.Placement is the register allocated to V in MatrixFn. unsigned MatrixReg = MatrixAI.Placement; // Store V onto TraceFn's stack, from which it will be reloaded into a @@ -514,22 +493,10 @@ RegsToSave.insert (MatrixReg); } else if (MatrixAI.AllocState == AllocInfo::Spilled) { // MatrixAI.Placement is the stack slot allocated to V in MatrixFn. - // Make sure we have MatrixFn's frame pointer in a register: - if (!g3IsMatrixFP) { - // Insert a load instruction before this one to load matrixFP off - // the TraceFn stack. - std::vector mvec; - TRI.cpMem2RegMI (mvec, sp, stackOffsetForReg (fp), matrixFP, - TRI.getRegType(matrixFP), g2); - for (std::vector::iterator i = mvec.begin (), - e = mvec.end (); i != e; ++i) { - DEBUG (std::cerr << "rewriteEpilogInstr: inserting " << *i << "\n"); - MBB.insert (iter, *i); - } - g3IsMatrixFP = true; - } + static const unsigned MatrixFP = SparcV9::i6; // Store it into its stack slot on MatrixFn's stack. - newBaseReg = matrixFP; + // using MatrixFn's frame pointer as the base register. + newBaseReg = MatrixFP; newImmedOffset = MatrixAI.Placement; } else { assert (0 && "Live-outs must be allocated or spilled in MatrixFn"); @@ -563,10 +530,6 @@ void UnpackTraceFunction::rewriteEpilog (MachineFunction &MF, MachineBasicBlock &MBB) { - // We start out each trace-exit MBB with %fp holding the TraceFn frame - // pointer. - fpIsTraceFP = true; - // Rewrite any stores into live-out pseudo-arguments to store into stack // slots instead. Delete old epilog leftovers in the process. for (MachineBasicBlock::iterator i = MBB.begin (), e = MBB.end (); i != e; ) { @@ -596,19 +559,9 @@ const PHINode *PN = dyn_cast (Inst); ++Inst) eliminatePhiAtTraceExit (MF, MBB, PN); - // Restore MatrixFn's FP. Warning! After this point, addLiveOutCopy won't work - // anymore, because it depends on being able to access TraceFn's frame - // pointer in %fp. - const SparcV9RegInfo &TRI = *TM->getRegInfo (); - static const unsigned fp = SparcV9::i6, sp = SparcV9::o6, g2 = SparcV9::g2; + static const unsigned sp = SparcV9::o6, g2 = SparcV9::g2; std::vector mvec; - TRI.cpMem2RegMI (mvec, sp, stackOffsetForReg (fp), fp, TRI.getRegType(fp), - g2); - for (std::vector::iterator vi = mvec.begin (), - ve = mvec.end (); vi != ve; ++vi) - MBB.push_back (*vi); - fpIsTraceFP = false; - RegsToSave.erase (fp); + const SparcV9RegInfo &TRI = *TM->getRegInfo (); // Get the set of registers used in this function which we saved in // findRegsToSave, earlier, and restore all used registers from stack @@ -660,7 +613,6 @@ DEBUG(std::cerr << "UnpackTraceFunction: unpacking " << MF.getFunction()->getName() << "()\n"); - fpIsTraceFP = false; // Initialize RegsToSave with the set of registers we'll need to save in the // prolog and restore in the epilog. @@ -676,12 +628,22 @@ DEBUG(std::cerr << "UnpackTraceFunction: Stack sizes: static = " << StaticStackSize << ", total = " << TotalStackSize << "\n"); - // Rewrite function prolog, found in the entry MachineBasicBlock of MF - rewriteProlog (MF, MF.front ()); - - // Rewrite function epilogs, found in every exit MachineBasicBlock of MF for (MachineFunction::iterator I = MF.begin (), E = MF.end (); I != E; ++I) { MachineBasicBlock &MBB = *I; + static const unsigned fp = SparcV9::i6, TraceFP = SparcV9::g1; + if (I == MF.begin()) { + // Rewrite function prolog, found in the entry MachineBasicBlock of MF. + rewriteProlog (MF, MBB); + continue; + } + // Rewrite references to %fp to use TraceFP (%g1) instead. + for (MachineBasicBlock::iterator BI = MBB.begin (), BE = MBB.end (); + BI != BE; ++BI) + for (unsigned i = 0; i < BI->getNumOperands(); ++i) + if (BI->getOperand (i).hasAllocatedReg () + && BI->getOperand (i).getReg () == fp) + BI->SetMachineOperandReg (i, TraceFP); + // Rewrite function epilogs, found in every exit MachineBasicBlock of MF. if (containsReturnInstr (MBB)) rewriteEpilog (MF, MBB); } From gaeke at cs.uiuc.edu Tue Jul 20 22:14:00 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Tue, 20 Jul 2004 22:14:00 -0500 Subject: [llvm-commits] CVS: llvm/lib/Support/IsInf.cpp Message-ID: <200407210314.WAA05838@zion.cs.uiuc.edu> Changes in directory llvm/lib/Support: IsInf.cpp added (r1.1) --- Log message: Add platform-independent wrapper function for isinf(). Patch contributed by Bill Wendling. --- Diffs of the changes: (+31 -0) Index: llvm/lib/Support/IsInf.cpp diff -c /dev/null llvm/lib/Support/IsInf.cpp:1.1 *** /dev/null Tue Jul 20 22:14:00 2004 --- llvm/lib/Support/IsInf.cpp Tue Jul 20 22:13:50 2004 *************** *** 0 **** --- 1,31 ---- + //===-- IsInf.cpp ---------------------------------------------------------===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by the LLVM research group and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // Platform-independent wrapper around C99 isinf(). + // + //===----------------------------------------------------------------------===// + + #include "Config/config.h" + #if HAVE_ISINF_IN_MATH_H + # include + #elif HAVE_ISINF_IN_CMATH + # include + #elif HAVE_STD_ISINF_IN_CMATH + # include + using std::isinf; + #else + # error "Don't know how to get isinf()" + #endif + + namespace llvm { + + int IsInf (float f) { return isinf (f); } + int IsInf (double d) { return isinf (d); } + + }; // end namespace llvm; From gaeke at cs.uiuc.edu Tue Jul 20 22:14:23 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Tue, 20 Jul 2004 22:14:23 -0500 Subject: [llvm-commits] CVS: llvm/configure Message-ID: <200407210314.WAA05878@zion.cs.uiuc.edu> Changes in directory llvm: configure updated: 1.96 -> 1.97 --- Log message: Regenerated with autoconf-2.57. Patch contributed by Bill Wendling. --- Diffs of the changes: (+176 -0) Index: llvm/configure diff -u llvm/configure:1.96 llvm/configure:1.97 --- llvm/configure:1.96 Mon Jul 19 11:12:25 2004 +++ llvm/configure Tue Jul 20 22:14:12 2004 @@ -20964,6 +20964,182 @@ fi +echo "$as_me:$LINENO: checking for isinf in " >&5 +echo $ECHO_N "checking for isinf in ... $ECHO_C" >&6 +if test "${ac_cv_func_isinf_in_math_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + int foo(float f) {return isinf(f);} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_isinf_in_math_h=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_func_isinf_in_math_h=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +fi +echo "$as_me:$LINENO: result: $ac_cv_func_isinf_in_math_h" >&5 +echo "${ECHO_T}$ac_cv_func_isinf_in_math_h" >&6 + if test "$ac_cv_func_isinf_in_math_h" = "yes" + then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_ISINF_IN_MATH_H 1 +_ACEOF + + fi +echo "$as_me:$LINENO: checking for isinf in " >&5 +echo $ECHO_N "checking for isinf in ... $ECHO_C" >&6 +if test "${ac_cv_func_isinf_in_cmath+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + int foo(float f) {return isinf(f);} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_isinf_in_cmath=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_func_isinf_in_cmath=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +fi +echo "$as_me:$LINENO: result: $ac_cv_func_isinf_in_cmath" >&5 +echo "${ECHO_T}$ac_cv_func_isinf_in_cmath" >&6 + if test "$ac_cv_func_isinf_in_cmath" = "yes" + then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_ISINF_IN_CMATH 1 +_ACEOF + + fi +echo "$as_me:$LINENO: checking for std::isinf in " >&5 +echo $ECHO_N "checking for std::isinf in ... $ECHO_C" >&6 +if test "${ac_cv_func_std_isinf_in_cmath+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + using std::isinf; int foo(float f) {return isinf(f);} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_std_isinf_in_cmath=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_func_std_isinf_in_cmath=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +fi +echo "$as_me:$LINENO: result: $ac_cv_func_std_isinf_in_cmath" >&5 +echo "${ECHO_T}$ac_cv_func_std_isinf_in_cmath" >&6 + if test "$ac_cv_func_std_isinf_in_cmath" = "yes" + then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_STD_ISINF_IN_CMATH 1 +_ACEOF + + fi + + # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works # for constant arguments. Useless! echo "$as_me:$LINENO: checking for working alloca.h" >&5 From gaeke at cs.uiuc.edu Tue Jul 20 22:14:49 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Tue, 20 Jul 2004 22:14:49 -0500 Subject: [llvm-commits] CVS: llvm/autoconf/acinclude.m4 Message-ID: <200407210314.WAA05920@zion.cs.uiuc.edu> Changes in directory llvm/autoconf: acinclude.m4 updated: 1.6 -> 1.7 --- Log message: Add support for checking for isinf(). Patch contributed by Bill Wendling. --- Diffs of the changes: (+14 -0) Index: llvm/autoconf/acinclude.m4 diff -u llvm/autoconf/acinclude.m4:1.6 llvm/autoconf/acinclude.m4:1.7 --- llvm/autoconf/acinclude.m4:1.6 Tue Jun 22 18:42:49 2004 +++ llvm/autoconf/acinclude.m4 Tue Jul 20 22:14:39 2004 @@ -6282,3 +6282,17 @@ using std::isnan; int foo(float f) {return isnan(f);}]) ]) +AC_DEFUN([AC_FUNC_ISINF],[ +AC_SINGLE_CXX_CHECK([HAVE_ISINF_IN_MATH_H], [ac_cv_func_isinf_in_math_h], + [isinf], [], + [#include + int foo(float f) {return isinf(f);}]) +AC_SINGLE_CXX_CHECK([HAVE_ISINF_IN_CMATH], [ac_cv_func_isinf_in_cmath], + [isinf], [], + [#include + int foo(float f) {return isinf(f);}]) +AC_SINGLE_CXX_CHECK([HAVE_STD_ISINF_IN_CMATH], [ac_cv_func_std_isinf_in_cmath], + [std::isinf], [], + [#include + using std::isinf; int foo(float f) {return isinf(f);}]) +]) From gaeke at cs.uiuc.edu Tue Jul 20 22:15:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Tue, 20 Jul 2004 22:15:01 -0500 Subject: [llvm-commits] CVS: llvm/autoconf/configure.ac Message-ID: <200407210315.WAA05967@zion.cs.uiuc.edu> Changes in directory llvm/autoconf: configure.ac updated: 1.94 -> 1.95 --- Log message: Add call to check for isinf(). Patch contributed by Bill Wendling. --- Diffs of the changes: (+1 -0) Index: llvm/autoconf/configure.ac diff -u llvm/autoconf/configure.ac:1.94 llvm/autoconf/configure.ac:1.95 --- llvm/autoconf/configure.ac:1.94 Mon Jul 19 11:12:29 2004 +++ llvm/autoconf/configure.ac Tue Jul 20 22:14:51 2004 @@ -278,6 +278,7 @@ AC_CXX_HAVE_FWD_ITERATOR AC_FUNC_ISNAN +AC_FUNC_ISINF dnl Checks for library functions. AC_FUNC_ALLOCA From gaeke at cs.uiuc.edu Tue Jul 20 22:15:12 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Tue, 20 Jul 2004 22:15:12 -0500 Subject: [llvm-commits] CVS: llvm/include/Config/config.h.in Message-ID: <200407210315.WAA06007@zion.cs.uiuc.edu> Changes in directory llvm/include/Config: config.h.in updated: 1.20 -> 1.21 --- Log message: Regenerated with autoheader-2.57. Patch contributed by Bill Wendling. --- Diffs of the changes: (+10 -3) Index: llvm/include/Config/config.h.in diff -u llvm/include/Config/config.h.in:1.20 llvm/include/Config/config.h.in:1.21 --- llvm/include/Config/config.h.in:1.20 Tue Jun 22 18:47:23 2004 +++ llvm/include/Config/config.h.in Tue Jul 20 22:15:02 2004 @@ -51,6 +51,12 @@ /* Define to 1 if you have the `isatty' function. */ #undef HAVE_ISATTY +/* Define to 1 if your compiler defines isinf in the header file. */ +#undef HAVE_ISINF_IN_CMATH + +/* Define to 1 if your compiler defines isinf in the header file. */ +#undef HAVE_ISINF_IN_MATH_H + /* Define to 1 if your compiler defines isnan in the header file. */ #undef HAVE_ISNAN_IN_CMATH @@ -104,6 +110,10 @@ /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H +/* Define to 1 if your compiler defines std::isinf in the header file. + */ +#undef HAVE_STD_ISINF_IN_CMATH + /* Define to 1 if your compiler defines std::isnan in the header file. */ #undef HAVE_STD_ISNAN_IN_CMATH @@ -150,9 +160,6 @@ /* Define to 1 if you have the header file. */ #undef HAVE_WINDOWS_H -/* Define to 1 if you have the isnan() function */ -#undef HAVE_ISNAN - /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT From gaeke at cs.uiuc.edu Tue Jul 20 22:15:24 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Tue, 20 Jul 2004 22:15:24 -0500 Subject: [llvm-commits] CVS: llvm/include/Support/MathExtras.h Message-ID: <200407210315.WAA06048@zion.cs.uiuc.edu> Changes in directory llvm/include/Support: MathExtras.h updated: 1.12 -> 1.13 --- Log message: Add prototypes for platform-independent wrappers for isinf(). Patch contributed by Bill Wendling. --- Diffs of the changes: (+4 -0) Index: llvm/include/Support/MathExtras.h diff -u llvm/include/Support/MathExtras.h:1.12 llvm/include/Support/MathExtras.h:1.13 --- llvm/include/Support/MathExtras.h:1.12 Tue Jun 22 19:25:24 2004 +++ llvm/include/Support/MathExtras.h Tue Jul 20 22:15:14 2004 @@ -43,6 +43,10 @@ int IsNAN (float f); int IsNAN (double d); +// Platform-independent wrappers for the C99 isinf() function. +int IsInf (float f); +int IsInf (double d); + } // End llvm namespace #endif From gaeke at cs.uiuc.edu Tue Jul 20 22:15:36 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Tue, 20 Jul 2004 22:15:36 -0500 Subject: [llvm-commits] CVS: llvm/lib/Target/CBackend/Writer.cpp Message-ID: <200407210315.WAA06088@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/CBackend: Writer.cpp updated: 1.190 -> 1.191 --- Log message: Emit NaNs and INFs bit-identically to the bytecode file, if the system has printf("%a") support. Patch contributed by Bill Wendling. --- Diffs of the changes: (+64 -2) Index: llvm/lib/Target/CBackend/Writer.cpp diff -u llvm/lib/Target/CBackend/Writer.cpp:1.190 llvm/lib/Target/CBackend/Writer.cpp:1.191 --- llvm/lib/Target/CBackend/Writer.cpp:1.190 Sat Jul 17 19:39:48 2004 +++ llvm/lib/Target/CBackend/Writer.cpp Tue Jul 20 22:15:26 2004 @@ -33,6 +33,7 @@ #include "llvm/Support/InstVisitor.h" #include "llvm/Support/Mangler.h" #include "Support/StringExtras.h" +#include "Support/MathExtras.h" #include "Config/config.h" #include #include @@ -556,14 +557,32 @@ Out << "(*(" << (FPC->getType() == Type::FloatTy ? "float" : "double") << "*)&FPConstant" << I->second << ")"; } else { + std::string Num; #if HAVE_PRINTF_A // Print out the constant as a floating point number. char Buffer[100]; sprintf(Buffer, "%a", FPC->getValue()); - Out << Buffer << " /*" << FPC->getValue() << "*/ "; + Num = Buffer; #else - Out << ftostr(FPC->getValue()); + Num = ftostr(FPC->getValue()); #endif + + if (IsNAN(FPC->getValue())) { + // The value is NaN + if (FPC->getType() == Type::FloatTy) + Out << "LLVM_NANF(\"" << Num << "\") /*nan*/ "; + else + Out << "LLVM_NAN(\"" << Num << "\") /*nan*/ "; + } else if (IsInf(FPC->getValue())) { + // The value is Inf + if (FPC->getValue() < 0) Out << "-"; + if (FPC->getType() == Type::FloatTy) + Out << "LLVM_INFF /*inf*/ "; + else + Out << "LLVM_INF /*inf*/ "; + } else { + Out << Num; + } } break; } @@ -700,6 +719,49 @@ << "#else\n" << "#define __ATTRIBUTE_WEAK__\n" << "#endif\n\n"; + + // Define NaN and Inf as GCC builtins if using GCC, as 0 otherwise + // From the GCC documentation: + // + // double __builtin_nan (const char *str) + // + // This is an implementation of the ISO C99 function nan. + // + // Since ISO C99 defines this function in terms of strtod, which we do + // not implement, a description of the parsing is in order. The string is + // parsed as by strtol; that is, the base is recognized by leading 0 or + // 0x prefixes. The number parsed is placed in the significand such that + // the least significant bit of the number is at the least significant + // bit of the significand. The number is truncated to fit the significand + // field provided. The significand is forced to be a quiet NaN. + // + // This function, if given a string literal, is evaluated early enough + // that it is considered a compile-time constant. + // + // float __builtin_nanf (const char *str) + // + // Similar to __builtin_nan, except the return type is float. + // + // double __builtin_inf (void) + // + // Similar to __builtin_huge_val, except a warning is generated if the + // target floating-point format does not support infinities. This + // function is suitable for implementing the ISO C99 macro INFINITY. + // + // float __builtin_inff (void) + // + // Similar to __builtin_inf, except the return type is float. + Out << "#ifdef __GNUC__\n" + << "#define LLVM_NAN(NanStr) __builtin_nan(NanStr) /* Double */\n" + << "#define LLVM_NANF(NanStr) __builtin_nan(NanStr) /* Float */\n" + << "#define LLVM_INF __builtin_inf() /* Double */\n" + << "#define LLVM_INFF __builtin_inff() /* Float */\n" + << "#else\n" + << "#define LLVM_NAN(NanStr) ((double)0.0) /* Double */\n" + << "#define LLVM_NANF(NanStr) 0.0F /* Float */\n" + << "#define LLVM_INF ((double)0.0) /* Double */\n" + << "#define LLVM_INFF 0.0F /* Float */\n" + << "#endif\n"; } bool CWriter::doInitialization(Module &M) { From gaeke at cs.uiuc.edu Tue Jul 20 22:30:38 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Tue, 20 Jul 2004 22:30:38 -0500 (CDT) Subject: [llvm-commits] CVS: llvm/autoconf/acinclude.m4 Message-ID: <200407210330.WAA19294@seraph.cs.uiuc.edu> Changes in directory llvm/autoconf: acinclude.m4 updated: 1.7 -> 1.8 --- Log message: Add check for finite(). Solaris doesn't have isinf, but it has finite...go figure! --- Diffs of the changes: (+4 -0) Index: llvm/autoconf/acinclude.m4 diff -u llvm/autoconf/acinclude.m4:1.7 llvm/autoconf/acinclude.m4:1.8 --- llvm/autoconf/acinclude.m4:1.7 Tue Jul 20 22:14:39 2004 +++ llvm/autoconf/acinclude.m4 Tue Jul 20 22:30:27 2004 @@ -6295,4 +6295,8 @@ [std::isinf], [], [#include using std::isinf; int foo(float f) {return isinf(f);}]) +AC_SINGLE_CXX_CHECK([HAVE_FINITE_IN_IEEEFP_H], [ac_cv_func_finite_in_ieeefp_h], + [finite], [], + [#include + int foo(float f) {return finite(f);}]) ]) From gaeke at cs.uiuc.edu Tue Jul 20 22:33:02 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Tue, 20 Jul 2004 22:33:02 -0500 (CDT) Subject: [llvm-commits] CVS: llvm/lib/Support/IsInf.cpp Message-ID: <200407210333.WAA19310@seraph.cs.uiuc.edu> Changes in directory llvm/lib/Support: IsInf.cpp updated: 1.1 -> 1.2 --- Log message: Solaris hack for isinf() --- Diffs of the changes: (+5 -0) Index: llvm/lib/Support/IsInf.cpp diff -u llvm/lib/Support/IsInf.cpp:1.1 llvm/lib/Support/IsInf.cpp:1.2 --- llvm/lib/Support/IsInf.cpp:1.1 Tue Jul 20 22:13:50 2004 +++ llvm/lib/Support/IsInf.cpp Tue Jul 20 22:32:51 2004 @@ -19,6 +19,11 @@ #elif HAVE_STD_ISINF_IN_CMATH # include using std::isinf; +#elif HAVE_FINITE_IN_IEEEFP_H +// A handy workaround I found at http://www.unixguide.net/sun/faq ... +// apparently this has been a problem with Solaris for years. +# include +static int isinf(double x) { return !finite(x) && x==x; } #else # error "Don't know how to get isinf()" #endif From gaeke at cs.uiuc.edu Tue Jul 20 22:34:08 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Tue, 20 Jul 2004 22:34:08 -0500 Subject: [llvm-commits] CVS: llvm/include/Config/config.h.in Message-ID: <200407210334.WAA06259@zion.cs.uiuc.edu> Changes in directory llvm/include/Config: config.h.in updated: 1.21 -> 1.22 --- Log message: Regenerated with autoconf/autoheader 2.57 --- Diffs of the changes: (+4 -0) Index: llvm/include/Config/config.h.in diff -u llvm/include/Config/config.h.in:1.21 llvm/include/Config/config.h.in:1.22 --- llvm/include/Config/config.h.in:1.21 Tue Jul 20 22:15:02 2004 +++ llvm/include/Config/config.h.in Tue Jul 20 22:33:58 2004 @@ -30,6 +30,10 @@ /* Define to 1 if you have the header file. */ #undef HAVE_FCNTL_H +/* Define to 1 if your compiler defines finite in the header file. + */ +#undef HAVE_FINITE_IN_IEEEFP_H + /* Define to 1 if you have the `getcwd' function. */ #undef HAVE_GETCWD From gaeke at cs.uiuc.edu Tue Jul 20 22:34:08 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Tue, 20 Jul 2004 22:34:08 -0500 Subject: [llvm-commits] CVS: llvm/configure Message-ID: <200407210334.WAA06264@zion.cs.uiuc.edu> Changes in directory llvm: configure updated: 1.97 -> 1.98 --- Log message: Regenerated with autoconf/autoheader 2.57 --- Diffs of the changes: (+58 -0) Index: llvm/configure diff -u llvm/configure:1.97 llvm/configure:1.98 --- llvm/configure:1.97 Tue Jul 20 22:14:12 2004 +++ llvm/configure Tue Jul 20 22:33:58 2004 @@ -21138,6 +21138,64 @@ _ACEOF fi +echo "$as_me:$LINENO: checking for finite in " >&5 +echo $ECHO_N "checking for finite in ... $ECHO_C" >&6 +if test "${ac_cv_func_finite_in_ieeefp_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + int foo(float f) {return finite(f);} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_finite_in_ieeefp_h=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_func_finite_in_ieeefp_h=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +fi +echo "$as_me:$LINENO: result: $ac_cv_func_finite_in_ieeefp_h" >&5 +echo "${ECHO_T}$ac_cv_func_finite_in_ieeefp_h" >&6 + if test "$ac_cv_func_finite_in_ieeefp_h" = "yes" + then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_FINITE_IN_IEEEFP_H 1 +_ACEOF + + fi # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works From gaeke at cs.uiuc.edu Tue Jul 20 22:50:11 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Tue, 20 Jul 2004 22:50:11 -0500 Subject: [llvm-commits] CVS: llvm/autoconf/acinclude.m4 Message-ID: <200407210350.WAA06505@zion.cs.uiuc.edu> Changes in directory llvm/autoconf: acinclude.m4 updated: 1.8 -> 1.9 --- Log message: Add AC_MSG_CHECKING and AC_MSG_RESULT statements which were missing from two of our custom checks. --- Diffs of the changes: (+4 -0) Index: llvm/autoconf/acinclude.m4 diff -u llvm/autoconf/acinclude.m4:1.8 llvm/autoconf/acinclude.m4:1.9 --- llvm/autoconf/acinclude.m4:1.8 Tue Jul 20 22:30:27 2004 +++ llvm/autoconf/acinclude.m4 Tue Jul 20 22:50:01 2004 @@ -6210,6 +6210,7 @@ # http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_have_ext_slist.html AC_DEFUN([AC_C_PRINTF_A], [ + AC_MSG_CHECKING([for printf %a format specifier]) AC_LANG_SAVE AC_LANG_C AC_RUN_IFELSE( @@ -6229,6 +6230,7 @@ return (0);]]]), ac_c_printf_a=yes,ac_c_printf_a=no) AC_LANG_RESTORE + AC_MSG_RESULT($ac_c_printf_a) if test "$ac_c_printf_a" = "yes"; then AC_DEFINE([HAVE_PRINTF_A],[1],[Define to have the %a format string]) fi @@ -6239,6 +6241,7 @@ # AC_DEFUN([AC_LINK_USE_R], [ + AC_MSG_CHECKING([for compiler -Wl,-R option]) AC_LANG_SAVE AC_LANG_C oldcflags="$CFLAGS" @@ -6246,6 +6249,7 @@ AC_LINK_IFELSE([int main() { return 0; }],[ac_cv_link_use_r=yes],[ac_cv_link_use_r=no]) CFLAGS="$oldcflags" AC_LANG_RESTORE + AC_MSG_RESULT($ac_cv_link_use_r) if test "$ac_cv_link_use_r" = yes then AC_DEFINE([HAVE_LINK_R],[1],[Define if you can use -Wl,-R. to pass -R. to the linker, in order to add the current directory to the dynamic linker search path.]) From gaeke at cs.uiuc.edu Tue Jul 20 22:50:35 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Tue, 20 Jul 2004 22:50:35 -0500 Subject: [llvm-commits] CVS: llvm/configure Message-ID: <200407210350.WAA06550@zion.cs.uiuc.edu> Changes in directory llvm: configure updated: 1.98 -> 1.99 --- Log message: Regenerated using autoconf-2.57. --- Diffs of the changes: (+8 -0) Index: llvm/configure diff -u llvm/configure:1.98 llvm/configure:1.99 --- llvm/configure:1.98 Tue Jul 20 22:33:58 2004 +++ llvm/configure Tue Jul 20 22:50:25 2004 @@ -19827,6 +19827,8 @@ + echo "$as_me:$LINENO: checking for printf %a format specifier" >&5 +echo $ECHO_N "checking for printf %a format specifier... $ECHO_C" >&6 ac_ext=c @@ -19898,6 +19900,8 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu + echo "$as_me:$LINENO: result: $ac_c_printf_a" >&5 +echo "${ECHO_T}$ac_c_printf_a" >&6 if test "$ac_c_printf_a" = "yes"; then cat >>confdefs.h <<\_ACEOF @@ -22323,6 +22327,8 @@ + echo "$as_me:$LINENO: checking for compiler -Wl,-R option" >&5 +echo $ECHO_N "checking for compiler -Wl,-R option... $ECHO_C" >&6 ac_ext=c @@ -22363,6 +22369,8 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu + echo "$as_me:$LINENO: result: $ac_cv_link_use_r" >&5 +echo "${ECHO_T}$ac_cv_link_use_r" >&6 if test "$ac_cv_link_use_r" = yes then From lattner at cs.uiuc.edu Tue Jul 20 22:57:05 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 20 Jul 2004 22:57:05 -0500 Subject: [llvm-commits] CVS: llvm/lib/Analysis/BasicAliasAnalysis.cpp Message-ID: <200407210357.WAA05003@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: BasicAliasAnalysis.cpp updated: 1.46 -> 1.47 --- Log message: Do not ignore casts unless they are pointer-pointer casts. This caused us to miscompile the SingleSource/Regression/C++/pointer_member.cpp program. --- Diffs of the changes: (+8 -4) Index: llvm/lib/Analysis/BasicAliasAnalysis.cpp diff -u llvm/lib/Analysis/BasicAliasAnalysis.cpp:1.46 llvm/lib/Analysis/BasicAliasAnalysis.cpp:1.47 --- llvm/lib/Analysis/BasicAliasAnalysis.cpp:1.46 Sat Jul 17 19:18:30 2004 +++ llvm/lib/Analysis/BasicAliasAnalysis.cpp Tue Jul 20 22:56:54 2004 @@ -240,10 +240,12 @@ const Value *V2, unsigned V2Size) { // Strip off any constant expression casts if they exist if (const ConstantExpr *CE = dyn_cast(V1)) - if (CE->getOpcode() == Instruction::Cast) + if (CE->getOpcode() == Instruction::Cast && + isa(CE->getOperand(0)->getType())) V1 = CE->getOperand(0); if (const ConstantExpr *CE = dyn_cast(V2)) - if (CE->getOpcode() == Instruction::Cast) + if (CE->getOpcode() == Instruction::Cast && + isa(CE->getOperand(0)->getType())) V2 = CE->getOperand(0); // Are we checking for alias of the same value? @@ -255,9 +257,11 @@ // Strip off cast instructions... if (const Instruction *I = dyn_cast(V1)) - return alias(I->getOperand(0), V1Size, V2, V2Size); + if (isa(I->getOperand(0)->getType())) + return alias(I->getOperand(0), V1Size, V2, V2Size); if (const Instruction *I = dyn_cast(V2)) - return alias(V1, V1Size, I->getOperand(0), V2Size); + if (isa(I->getOperand(0)->getType())) + return alias(V1, V1Size, I->getOperand(0), V2Size); // Figure out what objects these things are pointing to if we can... const Value *O1 = getUnderlyingObject(V1); From lattner at cs.uiuc.edu Tue Jul 20 23:27:34 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 20 Jul 2004 23:27:34 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp Message-ID: <200407210427.XAA06191@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: InstructionCombining.cpp updated: 1.228 -> 1.229 --- Log message: Remove special casing of pointers and treat them generically as integers of the appopriate size. This gives us the ability to eliminate int -> ptr -> int --- Diffs of the changes: (+5 -8) Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.228 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.229 --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.228 Tue Jul 20 00:21:00 2004 +++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Tue Jul 20 23:27:24 2004 @@ -1974,14 +1974,11 @@ if (SrcTy == DstTy && SrcTy->isLosslesslyConvertibleTo(MidTy)) return true; - // If the source and destination types are pointer types, and the intermediate - // is an integer type bigger than a pointer, eliminate the casts. - if (isa(SrcTy) && isa(DstTy)) { - if (isa(MidTy)) return true; - - if (MidTy->isInteger() && MidTy->getPrimitiveSize() >= TD->getPointerSize()) - return true; - } + // If we are casting between pointer and integer types, treat pointers as + // integers of the appropriate size for the code below. + if (isa(SrcTy)) SrcTy = TD->getIntPtrType(); + if (isa(MidTy)) MidTy = TD->getIntPtrType(); + if (isa(DstTy)) DstTy = TD->getIntPtrType(); // Allow free casting and conversion of sizes as long as the sign doesn't // change... From lattner at cs.uiuc.edu Wed Jul 21 00:17:59 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 21 Jul 2004 00:17:59 -0500 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/AliasSetTracker.h Message-ID: <200407210517.AAA13773@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis: AliasSetTracker.h updated: 1.13 -> 1.14 --- Log message: Make the AST interface a bit richer by returning whether an insertion caused an insertion or not (because the pointer set already existed). --- Diffs of the changes: (+17 -10) Index: llvm/include/llvm/Analysis/AliasSetTracker.h diff -u llvm/include/llvm/Analysis/AliasSetTracker.h:1.13 llvm/include/llvm/Analysis/AliasSetTracker.h:1.14 --- llvm/include/llvm/Analysis/AliasSetTracker.h:1.13 Sun May 23 16:10:42 2004 +++ llvm/include/llvm/Analysis/AliasSetTracker.h Wed Jul 21 00:17:49 2004 @@ -255,12 +255,15 @@ /// 3. If the instruction aliases multiple sets, merge the sets, and add /// the instruction to the result. /// - void add(LoadInst *LI); - void add(StoreInst *SI); - void add(CallSite CS); // Call/Invoke instructions - void add(CallInst *CI) { add(CallSite(CI)); } - void add(InvokeInst *II) { add(CallSite(II)); } - void add(Instruction *I); // Dispatch to one of the other add methods... + /// These methods return true if inserting the instruction resulted in the + /// addition of a new alias set (i.e., the pointer did not alias anything). + /// + bool add(LoadInst *LI); + bool add(StoreInst *SI); + bool add(CallSite CS); // Call/Invoke instructions + bool add(CallInst *CI) { return add(CallSite(CI)); } + bool add(InvokeInst *II) { return add(CallSite(II)); } + bool add(Instruction *I); // Dispatch to one of the other add methods... void add(BasicBlock &BB); // Add all instructions in basic block void add(const AliasSetTracker &AST); // Add alias relations from another AST @@ -275,8 +278,10 @@ const ilist &getAliasSets() const { return AliasSets; } /// getAliasSetForPointer - Return the alias set that the specified pointer - /// lives in... - AliasSet &getAliasSetForPointer(Value *P, unsigned Size); + /// lives in. If the New argument is non-null, this method sets the value to + /// true if a new alias set is created to contain the pointer (because the + /// pointer didn't alias anything). + AliasSet &getAliasSetForPointer(Value *P, unsigned Size, bool *New = 0); /// getAliasAnalysis - Return the underlying alias analysis object used by /// this tracker. @@ -305,8 +310,10 @@ AliasSet::PointerRec())).first; } - AliasSet &addPointer(Value *P, unsigned Size, AliasSet::AccessType E) { - AliasSet &AS = getAliasSetForPointer(P, Size); + AliasSet &addPointer(Value *P, unsigned Size, AliasSet::AccessType E, + bool &NewSet) { + NewSet = false; + AliasSet &AS = getAliasSetForPointer(P, Size, &NewSet); AS.AccessTy |= E; return AS; } From lattner at cs.uiuc.edu Wed Jul 21 00:18:14 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 21 Jul 2004 00:18:14 -0500 Subject: [llvm-commits] CVS: llvm/lib/Analysis/AliasSetTracker.cpp Message-ID: <200407210518.AAA13784@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: AliasSetTracker.cpp updated: 1.17 -> 1.18 --- Log message: Make the AST interface a bit richer by returning whether an insertion caused an insertion or not (because the pointer set already existed). --- Diffs of the changes: (+32 -19) Index: llvm/lib/Analysis/AliasSetTracker.cpp diff -u llvm/lib/Analysis/AliasSetTracker.cpp:1.17 llvm/lib/Analysis/AliasSetTracker.cpp:1.18 --- llvm/lib/Analysis/AliasSetTracker.cpp:1.17 Sun Jul 4 07:19:55 2004 +++ llvm/lib/Analysis/AliasSetTracker.cpp Wed Jul 21 00:18:04 2004 @@ -189,7 +189,8 @@ /// getAliasSetForPointer - Return the alias set that the specified pointer /// lives in... -AliasSet &AliasSetTracker::getAliasSetForPointer(Value *Pointer, unsigned Size){ +AliasSet &AliasSetTracker::getAliasSetForPointer(Value *Pointer, unsigned Size, + bool *New) { AliasSet::HashNodePair &Entry = getEntryFor(Pointer); // Check to see if the pointer is already known... @@ -201,6 +202,7 @@ AS->addPointer(*this, Entry, Size); return *AS; } else { + if (New) *New = true; // Otherwise create a new alias set to hold the loaded pointer... AliasSets.push_back(AliasSet()); AliasSets.back().addPointer(*this, Entry, Size); @@ -208,45 +210,55 @@ } } -void AliasSetTracker::add(LoadInst *LI) { - AliasSet &AS = - addPointer(LI->getOperand(0), - AA.getTargetData().getTypeSize(LI->getType()), AliasSet::Refs); +bool AliasSetTracker::add(LoadInst *LI) { + bool NewPtr; + AliasSet &AS = addPointer(LI->getOperand(0), + AA.getTargetData().getTypeSize(LI->getType()), + AliasSet::Refs, NewPtr); if (LI->isVolatile()) AS.setVolatile(); + return NewPtr; } -void AliasSetTracker::add(StoreInst *SI) { - AliasSet &AS = - addPointer(SI->getOperand(1), - AA.getTargetData().getTypeSize(SI->getOperand(0)->getType()), - AliasSet::Mods); +bool AliasSetTracker::add(StoreInst *SI) { + bool NewPtr; + Value *Val = SI->getOperand(0); + AliasSet &AS = addPointer(SI->getOperand(1), + AA.getTargetData().getTypeSize(Val->getType()), + AliasSet::Mods, NewPtr); if (SI->isVolatile()) AS.setVolatile(); + return NewPtr; } -void AliasSetTracker::add(CallSite CS) { +bool AliasSetTracker::add(CallSite CS) { + bool NewPtr; if (Function *F = CS.getCalledFunction()) if (AA.doesNotAccessMemory(F)) - return; + return true; // doesn't alias anything AliasSet *AS = findAliasSetForCallSite(CS); if (!AS) { AliasSets.push_back(AliasSet()); AS = &AliasSets.back(); + AS->addCallSite(CS, AA); + return true; + } else { + AS->addCallSite(CS, AA); + return false; } - AS->addCallSite(CS, AA); } -void AliasSetTracker::add(Instruction *I) { +bool AliasSetTracker::add(Instruction *I) { // Dispatch to one of the other add methods... if (LoadInst *LI = dyn_cast(I)) - add(LI); + return add(LI); else if (StoreInst *SI = dyn_cast(I)) - add(SI); + return add(SI); else if (CallInst *CI = dyn_cast(I)) - add(CI); + return add(CI); else if (InvokeInst *II = dyn_cast(I)) - add(II); + return add(II); + return true; } void AliasSetTracker::add(BasicBlock &BB) { @@ -271,9 +283,10 @@ // Loop over all of the pointers in this alias set... AliasSet::iterator I = AS.begin(), E = AS.end(); + bool X; for (; I != E; ++I) addPointer(I->first, I->second.getSize(), - (AliasSet::AccessType)AS.AccessTy); + (AliasSet::AccessType)AS.AccessTy, X); } } From lattner at cs.uiuc.edu Wed Jul 21 02:04:07 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 21 Jul 2004 02:04:07 -0500 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/AliasSetTracker.h Message-ID: <200407210704.CAA18979@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis: AliasSetTracker.h updated: 1.14 -> 1.15 --- Log message: Add a bunch of new functionality, primarily to do with removing aliasing pointers from an AST. --- Diffs of the changes: (+22 -1) Index: llvm/include/llvm/Analysis/AliasSetTracker.h diff -u llvm/include/llvm/Analysis/AliasSetTracker.h:1.14 llvm/include/llvm/Analysis/AliasSetTracker.h:1.15 --- llvm/include/llvm/Analysis/AliasSetTracker.h:1.14 Wed Jul 21 00:17:49 2004 +++ llvm/include/llvm/Analysis/AliasSetTracker.h Wed Jul 21 02:03:57 2004 @@ -129,7 +129,6 @@ // stores. bool isVolatile() const { return Volatile; } - /// isForwardingAliasSet - Return true if this alias set should be ignored as /// part of the AliasSetTracker object. bool isForwardingAliasSet() const { return Forward; } @@ -143,6 +142,7 @@ class iterator; iterator begin() const { return iterator(PtrList); } iterator end() const { return iterator(); } + bool empty() const { return PtrList == 0; } void print(std::ostream &OS) const; void dump() const; @@ -168,6 +168,9 @@ return *CurNode; } value_type *operator->() const { return &operator*(); } + + Value *getPointer() const { return CurNode->first; } + unsigned getSize() const { return CurNode->second.getSize(); } iterator& operator++() { // Preincrement assert(CurNode && "Advancing past AliasSet.end()!"); @@ -267,6 +270,18 @@ void add(BasicBlock &BB); // Add all instructions in basic block void add(const AliasSetTracker &AST); // Add alias relations from another AST + /// remove methods - These methods are used to remove all entries that might + /// be aliased by the specified instruction. These methods return true if any + /// alias sets were eliminated. + bool remove(LoadInst *LI); + bool remove(StoreInst *SI); + bool remove(CallSite CS); + bool remove(CallInst *CI) { return remove(CallSite(CI)); } + bool remove(InvokeInst *II) { return remove(CallSite(II)); } + bool remove(Instruction *I); + void remove(AliasSet &AS); + + /// deleteValue method - This method is used to remove a pointer value from /// the AliasSetTracker entirely. It should be used when an instruction is /// deleted from the program to update the AST. If you don't use this, you @@ -283,6 +298,12 @@ /// pointer didn't alias anything). AliasSet &getAliasSetForPointer(Value *P, unsigned Size, bool *New = 0); + /// getAliasSetForPointerIfExists - Return the alias set containing the + /// location specified if one exists, otherwise return null. + AliasSet *getAliasSetForPointerIfExists(Value *P, unsigned Size) { + return findAliasSetForPointer(P, Size); + } + /// getAliasAnalysis - Return the underlying alias analysis object used by /// this tracker. AliasAnalysis &getAliasAnalysis() const { return AA; } From lattner at cs.uiuc.edu Wed Jul 21 02:04:37 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 21 Jul 2004 02:04:37 -0500 Subject: [llvm-commits] CVS: llvm/lib/Analysis/AliasSetTracker.cpp Message-ID: <200407210704.CAA18990@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: AliasSetTracker.cpp updated: 1.18 -> 1.19 --- Log message: Add capability to remove aliasing aliassets from an AST --- Diffs of the changes: (+56 -0) Index: llvm/lib/Analysis/AliasSetTracker.cpp diff -u llvm/lib/Analysis/AliasSetTracker.cpp:1.18 llvm/lib/Analysis/AliasSetTracker.cpp:1.19 --- llvm/lib/Analysis/AliasSetTracker.cpp:1.18 Wed Jul 21 00:18:04 2004 +++ llvm/lib/Analysis/AliasSetTracker.cpp Wed Jul 21 02:04:26 2004 @@ -290,6 +290,62 @@ } } +/// remove - Remove the specified (potentially non-empty) alias set from the +/// tracker. +void AliasSetTracker::remove(AliasSet &AS) { + bool SetDead; + do { + AliasSet::iterator I = AS.begin(); + Value *Ptr = I.getPointer(); ++I; + + // deleteValue will delete the set automatically when the last pointer + // reference is destroyed. "Predict" when this will happen. + SetDead = I == AS.end(); + deleteValue(Ptr); // Delete all of the pointers from the set + } while (!SetDead); +} + + +bool AliasSetTracker::remove(LoadInst *LI) { + unsigned Size = AA.getTargetData().getTypeSize(LI->getType()); + AliasSet *AS = findAliasSetForPointer(LI->getOperand(0), Size); + if (!AS) return false; + remove(*AS); + return true; +} + +bool AliasSetTracker::remove(StoreInst *SI) { + unsigned Size = AA.getTargetData().getTypeSize(SI->getOperand(0)->getType()); + AliasSet *AS = findAliasSetForPointer(SI->getOperand(1), Size); + if (!AS) return false; + remove(*AS); + return true; +} + +bool AliasSetTracker::remove(CallSite CS) { + if (Function *F = CS.getCalledFunction()) + if (AA.doesNotAccessMemory(F)) + return false; // doesn't alias anything + + AliasSet *AS = findAliasSetForCallSite(CS); + if (!AS) return false; + remove(*AS); + return true; +} + +bool AliasSetTracker::remove(Instruction *I) { + // Dispatch to one of the other remove methods... + if (LoadInst *LI = dyn_cast(I)) + return remove(LI); + else if (StoreInst *SI = dyn_cast(I)) + return remove(SI); + else if (CallInst *CI = dyn_cast(I)) + return remove(CI); + else if (InvokeInst *II = dyn_cast(I)) + return remove(II); + return true; +} + // deleteValue method - This method is used to remove a pointer value from the // AliasSetTracker entirely. It should be used when an instruction is deleted From alkis at cs.uiuc.edu Wed Jul 21 03:19:00 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Wed, 21 Jul 2004 03:19:00 -0500 Subject: [llvm-commits] CVS: llvm/docs/CommandGuide/llc.pod Message-ID: <200407210819.DAA18147@zion.cs.uiuc.edu> Changes in directory llvm/docs/CommandGuide: llc.pod updated: 1.2 -> 1.3 --- Log message: Linearscan is no longer experimental. --- Diffs of the changes: (+1 -1) Index: llvm/docs/CommandGuide/llc.pod diff -u llvm/docs/CommandGuide/llc.pod:1.2 llvm/docs/CommandGuide/llc.pod:1.3 --- llvm/docs/CommandGuide/llc.pod:1.2 Fri Jul 2 11:06:19 2004 +++ llvm/docs/CommandGuide/llc.pod Wed Jul 21 03:18:50 2004 @@ -139,7 +139,7 @@ =item I -Linear scan global register allocator (experimental) +Linear scan global register allocator =back From alkis at cs.uiuc.edu Wed Jul 21 03:19:00 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Wed, 21 Jul 2004 03:19:00 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/Passes.cpp Message-ID: <200407210819.DAA18146@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: Passes.cpp updated: 1.7 -> 1.8 --- Log message: Linearscan is no longer experimental. --- Diffs of the changes: (+1 -1) Index: llvm/lib/CodeGen/Passes.cpp diff -u llvm/lib/CodeGen/Passes.cpp:1.7 llvm/lib/CodeGen/Passes.cpp:1.8 --- llvm/lib/CodeGen/Passes.cpp:1.7 Thu Jul 15 19:06:01 2004 +++ llvm/lib/CodeGen/Passes.cpp Wed Jul 21 03:18:50 2004 @@ -26,7 +26,7 @@ cl::Prefix, cl::values(clEnumVal(simple, " simple register allocator"), clEnumVal(local, " local register allocator"), - clEnumVal(linearscan, " linear scan register allocator (experimental)"), + clEnumVal(linearscan, " linear scan register allocator"), clEnumValEnd), cl::init(local)); } From alkis at cs.uiuc.edu Wed Jul 21 03:24:47 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Wed, 21 Jul 2004 03:24:47 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/RegAllocIterativeScan.cpp Passes.cpp Message-ID: <200407210824.DAA31585@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: RegAllocIterativeScan.cpp added (r1.1) Passes.cpp updated: 1.8 -> 1.9 --- Log message: Add Iterative scan register allocator. --- Diffs of the changes: (+479 -4) Index: llvm/lib/CodeGen/RegAllocIterativeScan.cpp diff -c /dev/null llvm/lib/CodeGen/RegAllocIterativeScan.cpp:1.1 *** /dev/null Wed Jul 21 03:24:45 2004 --- llvm/lib/CodeGen/RegAllocIterativeScan.cpp Wed Jul 21 03:24:34 2004 *************** *** 0 **** --- 1,472 ---- + //===-- RegAllocIterativeScan.cpp - Iterative Scan register allocator -----===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by the LLVM research group and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // This file implements a linear scan register allocator. + // + //===----------------------------------------------------------------------===// + + #define DEBUG_TYPE "regalloc" + #include "llvm/Function.h" + #include "llvm/CodeGen/LiveVariables.h" + #include "llvm/CodeGen/MachineFunctionPass.h" + #include "llvm/CodeGen/MachineInstr.h" + #include "llvm/CodeGen/Passes.h" + #include "llvm/CodeGen/SSARegMap.h" + #include "llvm/Target/MRegisterInfo.h" + #include "llvm/Target/TargetMachine.h" + #include "Support/Debug.h" + #include "Support/Statistic.h" + #include "Support/STLExtras.h" + #include "LiveIntervals.h" + #include "PhysRegTracker.h" + #include "VirtRegMap.h" + #include + #include + #include + #include + + using namespace llvm; + + namespace { + + Statistic efficiency + ("regalloc", "Ratio of intervals processed over total intervals"); + + static unsigned numIterations = 0; + static unsigned numIntervals = 0; + + class RA : public MachineFunctionPass { + private: + MachineFunction* mf_; + const TargetMachine* tm_; + const MRegisterInfo* mri_; + LiveIntervals* li_; + typedef std::list IntervalPtrs; + IntervalPtrs unhandled_, fixed_, active_, inactive_, handled_, spilled_; + + std::auto_ptr prt_; + std::auto_ptr vrm_; + std::auto_ptr spiller_; + + typedef std::vector SpillWeights; + SpillWeights spillWeights_; + + public: + virtual const char* getPassName() const { + return "Linear Scan Register Allocator"; + } + + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.addRequired(); + AU.addRequired(); + MachineFunctionPass::getAnalysisUsage(AU); + } + + /// runOnMachineFunction - register allocate the whole function + bool runOnMachineFunction(MachineFunction&); + + void releaseMemory(); + + private: + /// linearScan - the linear scan algorithm. Returns a boolean + /// indicating if there were any spills + bool linearScan(); + + /// initIntervalSets - initializes the four interval sets: + /// unhandled, fixed, active and inactive + void initIntervalSets(LiveIntervals::Intervals& li); + + /// processActiveIntervals - expire old intervals and move + /// non-overlapping ones to the incative list + void processActiveIntervals(IntervalPtrs::value_type cur); + + /// processInactiveIntervals - expire old intervals and move + /// overlapping ones to the active list + void processInactiveIntervals(IntervalPtrs::value_type cur); + + /// updateSpillWeights - updates the spill weights of the + /// specifed physical register and its weight + void updateSpillWeights(unsigned reg, SpillWeights::value_type weight); + + /// assignRegOrStackSlotAtInterval - assign a register if one + /// is available, or spill. + void assignRegOrSpillAtInterval(IntervalPtrs::value_type cur); + + /// + /// register handling helpers + /// + + /// getFreePhysReg - return a free physical register for this + /// virtual register interval if we have one, otherwise return + /// 0 + unsigned getFreePhysReg(IntervalPtrs::value_type cur); + + /// assignVirt2StackSlot - assigns this virtual register to a + /// stack slot. returns the stack slot + int assignVirt2StackSlot(unsigned virtReg); + + void printIntervals(const char* const str, + RA::IntervalPtrs::const_iterator i, + RA::IntervalPtrs::const_iterator e) const { + if (str) std::cerr << str << " intervals:\n"; + for (; i != e; ++i) { + std::cerr << "\t" << **i << " -> "; + unsigned reg = (*i)->reg; + if (MRegisterInfo::isVirtualRegister(reg)) { + reg = vrm_->getPhys(reg); + } + std::cerr << mri_->getName(reg) << '\n'; + } + } + }; + } + + void RA::releaseMemory() + { + unhandled_.clear(); + fixed_.clear(); + active_.clear(); + inactive_.clear(); + handled_.clear(); + spilled_.clear(); + } + + bool RA::runOnMachineFunction(MachineFunction &fn) { + mf_ = &fn; + tm_ = &fn.getTarget(); + mri_ = tm_->getRegisterInfo(); + li_ = &getAnalysis(); + if (!prt_.get()) prt_.reset(new PhysRegTracker(*mri_)); + vrm_.reset(new VirtRegMap(*mf_)); + if (!spiller_.get()) spiller_.reset(createSpiller()); + + initIntervalSets(li_->getIntervals()); + + numIntervals += li_->getIntervals().size(); + + while (linearScan()) { + // we spilled some registers, so we need to add intervals for + // the spill code and restart the algorithm + std::set spilledRegs; + for (IntervalPtrs::iterator + i = spilled_.begin(); i != spilled_.end(); ) { + int slot = vrm_->assignVirt2StackSlot((*i)->reg); + std::vector added = + li_->addIntervalsForSpills(**i, *vrm_, slot); + std::copy(added.begin(), added.end(), std::back_inserter(handled_)); + spilledRegs.insert((*i)->reg); + i = spilled_.erase(i); + } + for (IntervalPtrs::iterator + i = handled_.begin(); i != handled_.end(); ) + if (spilledRegs.count((*i)->reg)) + i = handled_.erase(i); + else + ++i; + handled_.swap(unhandled_); + vrm_->clearAllVirt(); + } + + efficiency = double(numIterations) / double(numIntervals); + + DEBUG(std::cerr << *vrm_); + + spiller_->runOnMachineFunction(*mf_, *vrm_); + + return true; + } + + bool RA::linearScan() + { + // linear scan algorithm + DEBUG(std::cerr << "********** LINEAR SCAN **********\n"); + DEBUG(std::cerr << "********** Function: " + << mf_->getFunction()->getName() << '\n'); + + + unhandled_.sort(less_ptr()); + DEBUG(printIntervals("unhandled", unhandled_.begin(), unhandled_.end())); + DEBUG(printIntervals("fixed", fixed_.begin(), fixed_.end())); + DEBUG(printIntervals("active", active_.begin(), active_.end())); + DEBUG(printIntervals("inactive", inactive_.begin(), inactive_.end())); + + while (!unhandled_.empty()) { + // pick the interval with the earliest start point + IntervalPtrs::value_type cur = unhandled_.front(); + unhandled_.pop_front(); + ++numIterations; + DEBUG(std::cerr << "\n*** CURRENT ***: " << *cur << '\n'); + + processActiveIntervals(cur); + processInactiveIntervals(cur); + + // if this register is fixed we are done + if (MRegisterInfo::isPhysicalRegister(cur->reg)) { + prt_->addRegUse(cur->reg); + active_.push_back(cur); + handled_.push_back(cur); + } + // otherwise we are allocating a virtual register. try to find + // a free physical register or spill an interval in order to + // assign it one (we could spill the current though). + else { + assignRegOrSpillAtInterval(cur); + } + + DEBUG(printIntervals("active", active_.begin(), active_.end())); + DEBUG(printIntervals("inactive", inactive_.begin(), inactive_.end())); + } + + // expire any remaining active intervals + for (IntervalPtrs::iterator i = active_.begin(); i != active_.end(); ) { + unsigned reg = (*i)->reg; + DEBUG(std::cerr << "\tinterval " << **i << " expired\n"); + if (MRegisterInfo::isVirtualRegister(reg)) + reg = vrm_->getPhys(reg); + prt_->delRegUse(reg); + i = active_.erase(i); + } + + // expire any remaining inactive intervals + for (IntervalPtrs::iterator + i = inactive_.begin(); i != inactive_.end(); ) { + DEBUG(std::cerr << "\tinterval " << **i << " expired\n"); + i = inactive_.erase(i); + } + + // return true if we spilled anything + return !spilled_.empty(); + } + + void RA::initIntervalSets(LiveIntervals::Intervals& li) + { + assert(unhandled_.empty() && fixed_.empty() && + active_.empty() && inactive_.empty() && + "interval sets should be empty on initialization"); + + for (LiveIntervals::Intervals::iterator i = li.begin(), e = li.end(); + i != e; ++i) { + unhandled_.push_back(&*i); + if (MRegisterInfo::isPhysicalRegister(i->reg)) + fixed_.push_back(&*i); + } + } + + void RA::processActiveIntervals(IntervalPtrs::value_type cur) + { + DEBUG(std::cerr << "\tprocessing active intervals:\n"); + for (IntervalPtrs::iterator i = active_.begin(); i != active_.end();) { + unsigned reg = (*i)->reg; + // remove expired intervals + if ((*i)->expiredAt(cur->start())) { + DEBUG(std::cerr << "\t\tinterval " << **i << " expired\n"); + if (MRegisterInfo::isVirtualRegister(reg)) + reg = vrm_->getPhys(reg); + prt_->delRegUse(reg); + // remove from active + i = active_.erase(i); + } + // move inactive intervals to inactive list + else if (!(*i)->liveAt(cur->start())) { + DEBUG(std::cerr << "\t\tinterval " << **i << " inactive\n"); + if (MRegisterInfo::isVirtualRegister(reg)) + reg = vrm_->getPhys(reg); + prt_->delRegUse(reg); + // add to inactive + inactive_.push_back(*i); + // remove from active + i = active_.erase(i); + } + else { + ++i; + } + } + } + + void RA::processInactiveIntervals(IntervalPtrs::value_type cur) + { + DEBUG(std::cerr << "\tprocessing inactive intervals:\n"); + for (IntervalPtrs::iterator i = inactive_.begin(); i != inactive_.end();) { + unsigned reg = (*i)->reg; + + // remove expired intervals + if ((*i)->expiredAt(cur->start())) { + DEBUG(std::cerr << "\t\tinterval " << **i << " expired\n"); + // remove from inactive + i = inactive_.erase(i); + } + // move re-activated intervals in active list + else if ((*i)->liveAt(cur->start())) { + DEBUG(std::cerr << "\t\tinterval " << **i << " active\n"); + if (MRegisterInfo::isVirtualRegister(reg)) + reg = vrm_->getPhys(reg); + prt_->addRegUse(reg); + // add to active + active_.push_back(*i); + // remove from inactive + i = inactive_.erase(i); + } + else { + ++i; + } + } + } + + void RA::updateSpillWeights(unsigned reg, SpillWeights::value_type weight) + { + spillWeights_[reg] += weight; + for (const unsigned* as = mri_->getAliasSet(reg); *as; ++as) + spillWeights_[*as] += weight; + } + + void RA::assignRegOrSpillAtInterval(IntervalPtrs::value_type cur) + { + DEBUG(std::cerr << "\tallocating current interval: "); + + PhysRegTracker backupPrt = *prt_; + + spillWeights_.assign(mri_->getNumRegs(), 0.0); + + // for each interval in active update spill weights + for (IntervalPtrs::const_iterator i = active_.begin(), e = active_.end(); + i != e; ++i) { + unsigned reg = (*i)->reg; + if (MRegisterInfo::isVirtualRegister(reg)) + reg = vrm_->getPhys(reg); + updateSpillWeights(reg, (*i)->weight); + } + + // for every interval in inactive we overlap with, mark the + // register as not free and update spill weights + for (IntervalPtrs::const_iterator i = inactive_.begin(), + e = inactive_.end(); i != e; ++i) { + if (cur->overlaps(**i)) { + unsigned reg = (*i)->reg; + if (MRegisterInfo::isVirtualRegister(reg)) + reg = vrm_->getPhys(reg); + prt_->addRegUse(reg); + updateSpillWeights(reg, (*i)->weight); + } + } + + // for every interval in fixed we overlap with, + // mark the register as not free and update spill weights + for (IntervalPtrs::const_iterator i = fixed_.begin(), + e = fixed_.end(); i != e; ++i) { + if (cur->overlaps(**i)) { + unsigned reg = (*i)->reg; + prt_->addRegUse(reg); + updateSpillWeights(reg, (*i)->weight); + } + } + + unsigned physReg = getFreePhysReg(cur); + // restore the physical register tracker + *prt_ = backupPrt; + // if we find a free register, we are done: assign this virtual to + // the free physical register and add this interval to the active + // list. + if (physReg) { + DEBUG(std::cerr << mri_->getName(physReg) << '\n'); + vrm_->assignVirt2Phys(cur->reg, physReg); + prt_->addRegUse(physReg); + active_.push_back(cur); + handled_.push_back(cur); + return; + } + DEBUG(std::cerr << "no free registers\n"); + + DEBUG(std::cerr << "\tassigning stack slot at interval "<< *cur << ":\n"); + + float minWeight = HUGE_VAL; + unsigned minReg = 0; + const TargetRegisterClass* rc = mf_->getSSARegMap()->getRegClass(cur->reg); + for (TargetRegisterClass::iterator i = rc->allocation_order_begin(*mf_); + i != rc->allocation_order_end(*mf_); ++i) { + unsigned reg = *i; + if (minWeight > spillWeights_[reg]) { + minWeight = spillWeights_[reg]; + minReg = reg; + } + } + DEBUG(std::cerr << "\t\tregister with min weight: " + << mri_->getName(minReg) << " (" << minWeight << ")\n"); + + // if the current has the minimum weight, we spill it and move on + if (cur->weight <= minWeight) { + DEBUG(std::cerr << "\t\t\tspilling(c): " << *cur << '\n'); + spilled_.push_back(cur); + return; + } + + // otherwise we spill all intervals aliasing the register with + // minimum weight, assigned the newly cleared register to the + // current interval and continue + std::vector added; + assert(MRegisterInfo::isPhysicalRegister(minReg) && + "did not choose a register to spill?"); + std::vector toSpill(mri_->getNumRegs(), false); + toSpill[minReg] = true; + for (const unsigned* as = mri_->getAliasSet(minReg); *as; ++as) + toSpill[*as] = true; + unsigned earliestStart = cur->start(); + + std::set spilled; + + for (IntervalPtrs::iterator i = active_.begin(); i != active_.end(); ) { + unsigned reg = (*i)->reg; + if (MRegisterInfo::isVirtualRegister(reg) && + toSpill[vrm_->getPhys(reg)] && + cur->overlaps(**i)) { + DEBUG(std::cerr << "\t\t\tspilling(a): " << **i << '\n'); + spilled_.push_back(*i); + prt_->delRegUse(vrm_->getPhys(reg)); + vrm_->clearVirt(reg); + i = active_.erase(i); + } + else + ++i; + } + for (IntervalPtrs::iterator i = inactive_.begin(); i != inactive_.end(); ) { + unsigned reg = (*i)->reg; + if (MRegisterInfo::isVirtualRegister(reg) && + toSpill[vrm_->getPhys(reg)] && + cur->overlaps(**i)) { + DEBUG(std::cerr << "\t\t\tspilling(i): " << **i << '\n'); + spilled_.push_back(*i); + vrm_->clearVirt(reg); + i = inactive_.erase(i); + } + else + ++i; + } + + vrm_->assignVirt2Phys(cur->reg, minReg); + prt_->addRegUse(minReg); + active_.push_back(cur); + handled_.push_back(cur); + + } + + unsigned RA::getFreePhysReg(IntervalPtrs::value_type cur) + { + const TargetRegisterClass* rc = mf_->getSSARegMap()->getRegClass(cur->reg); + + for (TargetRegisterClass::iterator i = rc->allocation_order_begin(*mf_); + i != rc->allocation_order_end(*mf_); ++i) { + unsigned reg = *i; + if (prt_->isRegAvail(reg)) + return reg; + } + return 0; + } + + FunctionPass* llvm::createIterativeScanRegisterAllocator() { + return new RA(); + } Index: llvm/lib/CodeGen/Passes.cpp diff -u llvm/lib/CodeGen/Passes.cpp:1.8 llvm/lib/CodeGen/Passes.cpp:1.9 --- llvm/lib/CodeGen/Passes.cpp:1.8 Wed Jul 21 03:18:50 2004 +++ llvm/lib/CodeGen/Passes.cpp Wed Jul 21 03:24:34 2004 @@ -18,15 +18,16 @@ using namespace llvm; namespace { - enum RegAllocName { simple, local, linearscan }; + enum RegAllocName { simple, local, linearscan, iterativescan }; cl::opt RegAlloc("regalloc", cl::desc("Register allocator to use: (default = simple)"), cl::Prefix, - cl::values(clEnumVal(simple, " simple register allocator"), - clEnumVal(local, " local register allocator"), - clEnumVal(linearscan, " linear scan register allocator"), + cl::values(clEnumVal(simple, " simple register allocator"), + clEnumVal(local, " local register allocator"), + clEnumVal(linearscan, " linear scan register allocator"), + clEnumVal(iterativescan," iterative scan register allocator"), clEnumValEnd), cl::init(local)); } @@ -42,6 +43,8 @@ return createLocalRegisterAllocator(); case linearscan: return createLinearScanRegisterAllocator(); + case iterativescan: + return createIterativeScanRegisterAllocator(); } } From alkis at cs.uiuc.edu Wed Jul 21 03:24:47 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Wed, 21 Jul 2004 03:24:47 -0500 Subject: [llvm-commits] CVS: llvm/docs/CommandGuide/llc.pod Message-ID: <200407210824.DAA31584@zion.cs.uiuc.edu> Changes in directory llvm/docs/CommandGuide: llc.pod updated: 1.3 -> 1.4 --- Log message: Add Iterative scan register allocator. --- Diffs of the changes: (+4 -0) Index: llvm/docs/CommandGuide/llc.pod diff -u llvm/docs/CommandGuide/llc.pod:1.3 llvm/docs/CommandGuide/llc.pod:1.4 --- llvm/docs/CommandGuide/llc.pod:1.3 Wed Jul 21 03:18:50 2004 +++ llvm/docs/CommandGuide/llc.pod Wed Jul 21 03:24:35 2004 @@ -141,6 +141,10 @@ Linear scan global register allocator +=item I + +Iterative scan global register allocator + =back =item B<--spiller>=I From alkis at cs.uiuc.edu Wed Jul 21 03:24:47 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Wed, 21 Jul 2004 03:24:47 -0500 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/Passes.h Message-ID: <200407210824.DAA31583@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: Passes.h updated: 1.16 -> 1.17 --- Log message: Add Iterative scan register allocator. --- Diffs of the changes: (+5 -0) Index: llvm/include/llvm/CodeGen/Passes.h diff -u llvm/include/llvm/CodeGen/Passes.h:1.16 llvm/include/llvm/CodeGen/Passes.h:1.17 --- llvm/include/llvm/CodeGen/Passes.h:1.16 Fri Jul 2 00:44:13 2004 +++ llvm/include/llvm/CodeGen/Passes.h Wed Jul 21 03:24:35 2004 @@ -70,6 +70,11 @@ /// FunctionPass *createLinearScanRegisterAllocator(); + /// IterativeScanRegisterAllocation Pass - This pass implements the iterative + /// scan register allocation algorithm, a global register allocator. + /// + FunctionPass *createIterativeScanRegisterAllocator(); + /// PrologEpilogCodeInserter Pass - This pass inserts prolog and epilog code, /// and eliminates abstract frame references. /// From alkis at cs.uiuc.edu Wed Jul 21 03:28:49 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Wed, 21 Jul 2004 03:28:49 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/RegAllocIterativeScan.cpp Message-ID: <200407210828.DAA06707@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: RegAllocIterativeScan.cpp updated: 1.1 -> 1.2 --- Log message: Improve file comment. --- Diffs of the changes: (+7 -1) Index: llvm/lib/CodeGen/RegAllocIterativeScan.cpp diff -u llvm/lib/CodeGen/RegAllocIterativeScan.cpp:1.1 llvm/lib/CodeGen/RegAllocIterativeScan.cpp:1.2 --- llvm/lib/CodeGen/RegAllocIterativeScan.cpp:1.1 Wed Jul 21 03:24:34 2004 +++ llvm/lib/CodeGen/RegAllocIterativeScan.cpp Wed Jul 21 03:28:39 2004 @@ -7,7 +7,13 @@ // //===----------------------------------------------------------------------===// // -// This file implements a linear scan register allocator. +// This file implements an iterative scan register +// allocator. Iterative scan is a linear scan variant with the +// following difference: +// +// It performs linear scan and keeps a list of the registers it cannot +// allocate. It then spills all those registers and repeats the +// process until allocation succeeds. // //===----------------------------------------------------------------------===// From alkis at cs.uiuc.edu Wed Jul 21 03:38:16 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Wed, 21 Jul 2004 03:38:16 -0500 Subject: [llvm-commits] CVS: llvm/include/Support/STLExtras.h Message-ID: <200407210838.DAA13902@zion.cs.uiuc.edu> Changes in directory llvm/include/Support: STLExtras.h updated: 1.16 -> 1.17 --- Log message: Add greater_ptr functor. --- Diffs of the changes: (+7 -0) Index: llvm/include/Support/STLExtras.h diff -u llvm/include/Support/STLExtras.h:1.16 llvm/include/Support/STLExtras.h:1.17 --- llvm/include/Support/STLExtras.h:1.16 Sun May 30 02:45:09 2004 +++ llvm/include/Support/STLExtras.h Wed Jul 21 03:38:06 2004 @@ -60,6 +60,13 @@ } }; +template +struct greater_ptr : public std::binary_function { + bool operator()(const Ty* left, const Ty* right) const { + return *right < *left; + } +}; + // deleter - Very very very simple method that is used to invoke operator // delete on something. It is used like this: // From alkis at cs.uiuc.edu Wed Jul 21 04:08:47 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Wed, 21 Jul 2004 04:08:47 -0500 Subject: [llvm-commits] CVS: llvm-java/Makefile.rules Message-ID: <200407210908.EAA17148@zion.cs.uiuc.edu> Changes in directory llvm-java: Makefile.rules updated: 1.5 -> 1.6 --- Log message: Remove llvm tool defs since these are now defined in the topmost Makefile.rules. --- Diffs of the changes: (+0 -4) Index: llvm-java/Makefile.rules diff -u llvm-java/Makefile.rules:1.5 llvm-java/Makefile.rules:1.6 --- llvm-java/Makefile.rules:1.5 Tue Jul 20 08:55:33 2004 +++ llvm-java/Makefile.rules Wed Jul 21 04:08:37 2004 @@ -15,10 +15,6 @@ endif CLASS2LLVM := $(PROJTOOLCURRENT)/class2llvm$(EXEEXT) -LDIS := $(LLVMTOOLCURRENT)/llvm-dis$(EXEEXT) -LAS := $(LLVMTOOLCURRENT)/llvm-as$(EXEEXT) -LLINK := $(LLVMTOOLCURRENT)/llvm-link$(EXEEXT) -LOPT := $(LLVMTOOLCURRENT)/opt$(EXEEXT) # rule to make assembly from bytecode %.dis-ll: %.bc From alkis at cs.uiuc.edu Wed Jul 21 04:47:05 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Wed, 21 Jul 2004 04:47:05 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/RegAllocIterativeScan.cpp Message-ID: <200407210947.EAA22140@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: RegAllocIterativeScan.cpp updated: 1.2 -> 1.3 --- Log message: Change std::list into a std::vector for IntervalSets. This reduces compile time for 176.gcc from 5.6 secs to 4.7 secs. --- Diffs of the changes: (+5 -4) Index: llvm/lib/CodeGen/RegAllocIterativeScan.cpp diff -u llvm/lib/CodeGen/RegAllocIterativeScan.cpp:1.2 llvm/lib/CodeGen/RegAllocIterativeScan.cpp:1.3 --- llvm/lib/CodeGen/RegAllocIterativeScan.cpp:1.2 Wed Jul 21 03:28:39 2004 +++ llvm/lib/CodeGen/RegAllocIterativeScan.cpp Wed Jul 21 04:46:55 2004 @@ -53,7 +53,7 @@ const TargetMachine* tm_; const MRegisterInfo* mri_; LiveIntervals* li_; - typedef std::list IntervalPtrs; + typedef std::vector IntervalPtrs; IntervalPtrs unhandled_, fixed_, active_, inactive_, handled_, spilled_; std::auto_ptr prt_; @@ -196,7 +196,8 @@ << mf_->getFunction()->getName() << '\n'); - unhandled_.sort(less_ptr()); + std::sort(unhandled_.begin(), unhandled_.end(), + greater_ptr()); DEBUG(printIntervals("unhandled", unhandled_.begin(), unhandled_.end())); DEBUG(printIntervals("fixed", fixed_.begin(), fixed_.end())); DEBUG(printIntervals("active", active_.begin(), active_.end())); @@ -204,8 +205,8 @@ while (!unhandled_.empty()) { // pick the interval with the earliest start point - IntervalPtrs::value_type cur = unhandled_.front(); - unhandled_.pop_front(); + IntervalPtrs::value_type cur = unhandled_.back(); + unhandled_.pop_back(); ++numIterations; DEBUG(std::cerr << "\n*** CURRENT ***: " << *cur << '\n'); From alkis at cs.uiuc.edu Wed Jul 21 07:00:20 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Wed, 21 Jul 2004 07:00:20 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/RegAllocIterativeScan.cpp Message-ID: <200407211200.HAA08030@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: RegAllocIterativeScan.cpp updated: 1.3 -> 1.4 --- Log message: Clear spilled list at once. Remove unused vector. --- Diffs of the changes: (+2 -3) Index: llvm/lib/CodeGen/RegAllocIterativeScan.cpp diff -u llvm/lib/CodeGen/RegAllocIterativeScan.cpp:1.3 llvm/lib/CodeGen/RegAllocIterativeScan.cpp:1.4 --- llvm/lib/CodeGen/RegAllocIterativeScan.cpp:1.3 Wed Jul 21 04:46:55 2004 +++ llvm/lib/CodeGen/RegAllocIterativeScan.cpp Wed Jul 21 07:00:10 2004 @@ -161,14 +161,14 @@ // the spill code and restart the algorithm std::set spilledRegs; for (IntervalPtrs::iterator - i = spilled_.begin(); i != spilled_.end(); ) { + i = spilled_.begin(); i != spilled_.end(); ++i) { int slot = vrm_->assignVirt2StackSlot((*i)->reg); std::vector added = li_->addIntervalsForSpills(**i, *vrm_, slot); std::copy(added.begin(), added.end(), std::back_inserter(handled_)); spilledRegs.insert((*i)->reg); - i = spilled_.erase(i); } + spilled_.clear(); for (IntervalPtrs::iterator i = handled_.begin(); i != handled_.end(); ) if (spilledRegs.count((*i)->reg)) @@ -415,7 +415,6 @@ // otherwise we spill all intervals aliasing the register with // minimum weight, assigned the newly cleared register to the // current interval and continue - std::vector added; assert(MRegisterInfo::isPhysicalRegister(minReg) && "did not choose a register to spill?"); std::vector toSpill(mri_->getNumRegs(), false); From brukman at cs.uiuc.edu Wed Jul 21 07:47:50 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Wed, 21 Jul 2004 07:47:50 -0500 Subject: [llvm-commits] CVS: llvm/Makefile.rules Message-ID: <200407211247.HAA14764@zion.cs.uiuc.edu> Changes in directory llvm: Makefile.rules updated: 1.188 -> 1.189 --- Log message: * Uncomment rule for location of LLI (formerly commented out: typo?) * Add space between VAR and `=' --- Diffs of the changes: (+11 -10) Index: llvm/Makefile.rules diff -u llvm/Makefile.rules:1.188 llvm/Makefile.rules:1.189 --- llvm/Makefile.rules:1.188 Tue Jul 20 20:31:46 2004 +++ llvm/Makefile.rules Wed Jul 21 07:47:40 2004 @@ -263,16 +263,17 @@ # Find the location of the platform specific LLVM GCC libraries LLVMGCCLIBDIR=$(dir $(shell $(LLVMGCC) -print-file-name=libgcc.a)) # LLVM Tool Definitions (LLVMGCC, LLVMGXX, LLVMAS are provided by -# Makefile.rules) LLI = $(LLVMTOOLCURRENT)/lli$(EXEEXT) -LLC = $(LLVMTOOLCURRENT)/llc$(EXEEXT) -LGCCAS = $(LLVMTOOLCURRENT)/gccas$(EXEEXT) -LGCCLD = $(LGCCLDPROG) -L$(LLVMGCCLIBDIR) -L$(LLVMGCCDIR)/lib -LDIS = $(LLVMTOOLCURRENT)/llvm-dis$(EXEEXT) -LOPT = $(LLVMTOOLCURRENT)/opt$(EXEEXT) -LLINK = $(LLVMTOOLCURRENT)/llvm-link$(EXEEXT) -LPROF = $(LLVMTOOLCURRENT)/llvm-prof$(EXEEXT) -LANALYZE = $(LLVMTOOLCURRENT)/analyze$(EXEEXT) -LBUGPOINT= $(LLVMTOOLCURRENT)/bugpoint$(EXEEXT) +# Makefile.rules) +LLI = $(LLVMTOOLCURRENT)/lli$(EXEEXT) +LLC = $(LLVMTOOLCURRENT)/llc$(EXEEXT) +LGCCAS = $(LLVMTOOLCURRENT)/gccas$(EXEEXT) +LGCCLD = $(LGCCLDPROG) -L$(LLVMGCCLIBDIR) -L$(LLVMGCCDIR)/lib +LDIS = $(LLVMTOOLCURRENT)/llvm-dis$(EXEEXT) +LOPT = $(LLVMTOOLCURRENT)/opt$(EXEEXT) +LLINK = $(LLVMTOOLCURRENT)/llvm-link$(EXEEXT) +LPROF = $(LLVMTOOLCURRENT)/llvm-prof$(EXEEXT) +LANALYZE = $(LLVMTOOLCURRENT)/analyze$(EXEEXT) +LBUGPOINT = $(LLVMTOOLCURRENT)/bugpoint$(EXEEXT) ########################################################################### From brukman at cs.uiuc.edu Wed Jul 21 07:53:24 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Wed, 21 Jul 2004 07:53:24 -0500 Subject: [llvm-commits] CVS: llvm/docs/CommandGuide/llc.pod Message-ID: <200407211253.HAA14931@zion.cs.uiuc.edu> Changes in directory llvm/docs/CommandGuide: llc.pod updated: 1.4 -> 1.5 --- Log message: Fix spelling of `iterative scan' --- Diffs of the changes: (+1 -1) Index: llvm/docs/CommandGuide/llc.pod diff -u llvm/docs/CommandGuide/llc.pod:1.4 llvm/docs/CommandGuide/llc.pod:1.5 --- llvm/docs/CommandGuide/llc.pod:1.4 Wed Jul 21 03:24:35 2004 +++ llvm/docs/CommandGuide/llc.pod Wed Jul 21 07:53:14 2004 @@ -141,7 +141,7 @@ Linear scan global register allocator -=item I +=item I Iterative scan global register allocator From brukman at cs.uiuc.edu Wed Jul 21 09:10:01 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Wed, 21 Jul 2004 09:10:01 -0500 Subject: [llvm-commits] CVS: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/perl/str.h util.h Message-ID: <200407211410.JAA15629@zion.cs.uiuc.edu> Changes in directory llvm/test/Programs/MultiSource/Benchmarks/MallocBench/perl: str.h updated: 1.1 -> 1.2 util.h updated: 1.1 -> 1.2 --- Log message: Add missing function declarations. --- Diffs of the changes: (+11 -2) Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/perl/str.h diff -u llvm/test/Programs/MultiSource/Benchmarks/MallocBench/perl/str.h:1.1 llvm/test/Programs/MultiSource/Benchmarks/MallocBench/perl/str.h:1.2 --- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/perl/str.h:1.1 Tue Feb 17 16:21:16 2004 +++ llvm/test/Programs/MultiSource/Benchmarks/MallocBench/perl/str.h Wed Jul 21 09:09:51 2004 @@ -1,4 +1,4 @@ -/* $RCSfile: str.h,v $$Revision: 1.1 $$Date: 2004/02/17 22:21:16 $ +/* $RCSfile: str.h,v $$Revision: 1.2 $$Date: 2004/07/21 14:09:51 $ * * Copyright (c) 1989, Larry Wall * @@ -6,6 +6,9 @@ * as specified in the README file that comes with the perl 3.0 kit. * * $Log: str.h,v $ + * Revision 1.2 2004/07/21 14:09:51 brukman + * Add missing function declarations. + * * Revision 1.1 2004/02/17 22:21:16 criswell * Initial commit of the perl Malloc Benchmark. I've cheated a little by * generating the yacc output files and committing them directly, but it was @@ -120,6 +123,7 @@ stabset((x)->str_magic,(x)) #endif +str_sset(STR *dstr, register STR *sstr); #define STR_SSET(dst,src) if (dst != src) str_sset(dst,src) EXT STR **tmps_list; Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/perl/util.h diff -u llvm/test/Programs/MultiSource/Benchmarks/MallocBench/perl/util.h:1.1 llvm/test/Programs/MultiSource/Benchmarks/MallocBench/perl/util.h:1.2 --- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/perl/util.h:1.1 Tue Feb 17 16:21:17 2004 +++ llvm/test/Programs/MultiSource/Benchmarks/MallocBench/perl/util.h Wed Jul 21 09:09:51 2004 @@ -1,4 +1,4 @@ -/* $Header: /home/vadve/shared/PublicCVS/llvm/test/Programs/MultiSource/Benchmarks/MallocBench/perl/util.h,v 1.1 2004/02/17 22:21:17 criswell Exp $ +/* $Header: /home/vadve/shared/PublicCVS/llvm/test/Programs/MultiSource/Benchmarks/MallocBench/perl/util.h,v 1.2 2004/07/21 14:09:51 brukman Exp $ * * Copyright (c) 1989, Larry Wall * @@ -6,6 +6,9 @@ * as specified in the README file that comes with the perl 3.0 kit. * * $Log: util.h,v $ + * Revision 1.2 2004/07/21 14:09:51 brukman + * Add missing function declarations. + * * Revision 1.1 2004/02/17 22:21:17 criswell * Initial commit of the perl Malloc Benchmark. I've cheated a little by * generating the yacc output files and committing them directly, but it was @@ -45,3 +48,5 @@ #endif unsigned long scanoct(); unsigned long scanhex(); +void fatal(char*,long,long,long,long); +void fatal(va_list); From alkis at cs.uiuc.edu Wed Jul 21 12:23:54 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Wed, 21 Jul 2004 12:23:54 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/RegAllocIterativeScan.cpp Message-ID: <200407211723.MAA16934@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: RegAllocIterativeScan.cpp updated: 1.4 -> 1.5 --- Log message: Fix analysis name. --- Diffs of the changes: (+1 -1) Index: llvm/lib/CodeGen/RegAllocIterativeScan.cpp diff -u llvm/lib/CodeGen/RegAllocIterativeScan.cpp:1.4 llvm/lib/CodeGen/RegAllocIterativeScan.cpp:1.5 --- llvm/lib/CodeGen/RegAllocIterativeScan.cpp:1.4 Wed Jul 21 07:00:10 2004 +++ llvm/lib/CodeGen/RegAllocIterativeScan.cpp Wed Jul 21 12:23:44 2004 @@ -65,7 +65,7 @@ public: virtual const char* getPassName() const { - return "Linear Scan Register Allocator"; + return "Iterative Scan Register Allocator"; } virtual void getAnalysisUsage(AnalysisUsage &AU) const { From brukman at cs.uiuc.edu Wed Jul 21 13:02:53 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Wed, 21 Jul 2004 13:02:53 -0500 Subject: [llvm-commits] CVS: llvm/docs/SystemLibrary.html Message-ID: <200407211802.NAA17378@zion.cs.uiuc.edu> Changes in directory llvm/docs: SystemLibrary.html updated: 1.2 -> 1.3 --- Log message: Delete extra space; add

    tags around text within a

    --- Diffs of the changes: (+5 -3) Index: llvm/docs/SystemLibrary.html diff -u llvm/docs/SystemLibrary.html:1.2 llvm/docs/SystemLibrary.html:1.3 --- llvm/docs/SystemLibrary.html:1.2 Sat Jul 17 13:50:19 2004 +++ llvm/docs/SystemLibrary.html Wed Jul 21 13:02:43 2004 @@ -7,9 +7,11 @@ -
    System Library
    +
    System Library
    -
    Warning: This document is a work in progress.
    +
    +

    Warning: This document is a work in progress.

    +
    • Abstract
    • @@ -195,7 +197,7 @@ Reid Spencer
      LLVM Compiler Infrastructure
      - Last modified: $Date: 2004/07/17 18:50:19 $ + Last modified: $Date: 2004/07/21 18:02:43 $ From brukman at cs.uiuc.edu Wed Jul 21 13:04:37 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Wed, 21 Jul 2004 13:04:37 -0500 Subject: [llvm-commits] CVS: llvm/docs/SystemLibrary.html Message-ID: <200407211804.NAA17529@zion.cs.uiuc.edu> Changes in directory llvm/docs: SystemLibrary.html updated: 1.3 -> 1.4 --- Log message: Reid doesn't need a definite article in front of his name. --- Diffs of the changes: (+2 -2) Index: llvm/docs/SystemLibrary.html diff -u llvm/docs/SystemLibrary.html:1.3 llvm/docs/SystemLibrary.html:1.4 --- llvm/docs/SystemLibrary.html:1.3 Wed Jul 21 13:02:43 2004 +++ llvm/docs/SystemLibrary.html Wed Jul 21 13:04:27 2004 @@ -41,7 +41,7 @@
    -

    Written by the Reid Spencer

    +

    Written by Reid Spencer

    @@ -197,7 +197,7 @@ Reid Spencer
    LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/07/21 18:02:43 $ + Last modified: $Date: 2004/07/21 18:04:27 $ From lattner at cs.uiuc.edu Wed Jul 21 14:50:55 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 21 Jul 2004 14:50:55 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp Message-ID: <200407211950.OAA28915@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: InstructionCombining.cpp updated: 1.229 -> 1.230 --- Log message: Make cast-cast code a bit more defensive "simplify" a bit of code for comparison/and folding --- Diffs of the changes: (+42 -32) Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.229 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.230 --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.229 Tue Jul 20 23:27:24 2004 +++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Wed Jul 21 14:50:44 2004 @@ -1453,38 +1453,42 @@ if (LHSI->hasOneUse()) switch (LHSI->getOpcode()) { case Instruction::And: - if (isa(LHSI->getOperand(1))) { - - + if (isa(LHSI->getOperand(1)) && + LHSI->getOperand(0)->hasOneUse()) { // If this is: (X >> C1) & C2 != C3 (where any shift and any compare // could exist), turn it into (X & (C2 << C1)) != (C3 << C1). This // happens a LOT in code produced by the C front-end, for bitfield // access. - if (LHSI->getOperand(0)->hasOneUse()) - if (ShiftInst *Shift = dyn_cast(LHSI->getOperand(0))) - if (ConstantUInt *ShAmt = - dyn_cast(Shift->getOperand(1))) { - ConstantInt *AndCST = cast(LHSI->getOperand(1)); + ShiftInst *Shift = dyn_cast(LHSI->getOperand(0)); + ConstantUInt *ShAmt; + ShAmt = Shift ? dyn_cast(Shift->getOperand(1)) : 0; + ConstantInt *AndCST = cast(LHSI->getOperand(1)); + const Type *Ty = LHSI->getType(); - // We can fold this as long as we can't shift unknown bits - // into the mask. This can only happen with signed shift - // rights, as they sign-extend. - const Type *Ty = Shift->getType(); - if (Shift->getOpcode() != Instruction::Shr || - Shift->getType()->isUnsigned() || - // To test for the bad case of the signed shr, see if any - // of the bits shifted in could be tested after the mask. - ConstantExpr::getAnd(ConstantExpr::getShl(ConstantInt::getAllOnesValue(Ty), ConstantUInt::get(Type::UByteTy, Ty->getPrimitiveSize()*8-ShAmt->getValue())), AndCST)->isNullValue()) { - unsigned ShiftOp = Shift->getOpcode() == Instruction::Shl - ? Instruction::Shr : Instruction::Shl; - I.setOperand(1, ConstantExpr::get(ShiftOp, CI, ShAmt)); - LHSI->setOperand(1,ConstantExpr::get(ShiftOp,AndCST,ShAmt)); - LHSI->setOperand(0, Shift->getOperand(0)); - WorkList.push_back(Shift); // Shift is probably dead. - AddUsesToWorkList(I); - return &I; - } - } + // We can fold this as long as we can't shift unknown bits + // into the mask. This can only happen with signed shift + // rights, as they sign-extend. + if (ShAmt) { + bool CanFold = Shift->getOpcode() != Instruction::Shr || + Shift->getType()->isUnsigned(); + if (!CanFold && + // To test for the bad case of the signed shr, see if any + // of the bits shifted in could be tested after the mask. + ConstantExpr::getAnd(ConstantExpr::getShl(ConstantInt::getAllOnesValue(Ty), ConstantUInt::get(Type::UByteTy, Ty->getPrimitiveSize()*8-ShAmt->getValue())), AndCST)->isNullValue()) { + CanFold = true; + } + + if (CanFold) { + unsigned ShiftOp = Shift->getOpcode() == Instruction::Shl + ? Instruction::Shr : Instruction::Shl; + I.setOperand(1, ConstantExpr::get(ShiftOp, CI, ShAmt)); + LHSI->setOperand(1,ConstantExpr::get(ShiftOp,AndCST,ShAmt)); + LHSI->setOperand(0, Shift->getOperand(0)); + WorkList.push_back(Shift); // Shift is dead. + AddUsesToWorkList(I); + return &I; + } + } } break; case Instruction::Div: @@ -1970,7 +1974,7 @@ // It is legal to eliminate the instruction if casting A->B->A if the sizes // are identical and the bits don't get reinterpreted (for example - // int->float->int would not be allowed) + // int->float->int would not be allowed). if (SrcTy == DstTy && SrcTy->isLosslesslyConvertibleTo(MidTy)) return true; @@ -1994,9 +1998,9 @@ // First cast is a truncate 1, 1, 4, 4, // trunc->extend is not safe to eliminate // First cast is a sign ext - 2, 5, 2, 4, // signext->trunc always ok, signext->zeroext never ok + 2, 5, 2, 4, // signext->zeroext never ok // First cast is a zero ext - 3, 5, 3, 3, // zeroext->trunc always ok + 3, 5, 3, 3, }; unsigned Result = CastResult[FirstCast*4+SecondCast]; @@ -2012,8 +2016,14 @@ case 4: return false; // Not possible to eliminate this here. case 5: - // Sign or zero extend followed by truncate is always ok - return true; + // Sign or zero extend followed by truncate is always ok if the result + // is a truncate or noop. + CastType ResultCast = getCastType(SrcTy, DstTy); + if (ResultCast == Noop || ResultCast == Truncate) + return true; + // Otherwise we are still growing the value, we are only safe if the + // result will match the sign/zeroextendness of the result. + return ResultCast == FirstCast; } } return false; From lattner at cs.uiuc.edu Wed Jul 21 15:14:21 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 21 Jul 2004 15:14:21 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp Message-ID: <200407212014.PAA30050@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: InstructionCombining.cpp updated: 1.230 -> 1.231 --- Log message: * Further cleanup. * Test for whether bits are shifted out during the optzn. If so, the fold is illegal, though it can be handled explicitly for setne/seteq This fixes the miscompilation of 254.gap last night, which was a latent bug exposed by other optimizer improvements. --- Diffs of the changes: (+27 -9) Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.230 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.231 --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.230 Wed Jul 21 14:50:44 2004 +++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Wed Jul 21 15:14:10 2004 @@ -1471,22 +1471,40 @@ if (ShAmt) { bool CanFold = Shift->getOpcode() != Instruction::Shr || Shift->getType()->isUnsigned(); - if (!CanFold && + if (!CanFold) { // To test for the bad case of the signed shr, see if any // of the bits shifted in could be tested after the mask. - ConstantExpr::getAnd(ConstantExpr::getShl(ConstantInt::getAllOnesValue(Ty), ConstantUInt::get(Type::UByteTy, Ty->getPrimitiveSize()*8-ShAmt->getValue())), AndCST)->isNullValue()) { - CanFold = true; + Constant *OShAmt = ConstantUInt::get(Type::UByteTy, + Ty->getPrimitiveSize()*8-ShAmt->getValue()); + Constant *ShVal = + ConstantExpr::getShl(ConstantInt::getAllOnesValue(Ty), OShAmt); + if (ConstantExpr::getAnd(ShVal, AndCST)->isNullValue()) + CanFold = true; } if (CanFold) { unsigned ShiftOp = Shift->getOpcode() == Instruction::Shl ? Instruction::Shr : Instruction::Shl; - I.setOperand(1, ConstantExpr::get(ShiftOp, CI, ShAmt)); - LHSI->setOperand(1,ConstantExpr::get(ShiftOp,AndCST,ShAmt)); - LHSI->setOperand(0, Shift->getOperand(0)); - WorkList.push_back(Shift); // Shift is dead. - AddUsesToWorkList(I); - return &I; + Constant *NewCst = ConstantExpr::get(ShiftOp, CI, ShAmt); + + // Check to see if we are shifting out any of the bits being + // compared. + if (ConstantExpr::get(Shift->getOpcode(), NewCst, ShAmt) != CI){ + // If we shifted bits out, the fold is not going to work out. + // As a special case, check to see if this means that the + // result is always true or false now. + if (I.getOpcode() == Instruction::SetEQ) + return ReplaceInstUsesWith(I, ConstantBool::False); + if (I.getOpcode() == Instruction::SetNE) + return ReplaceInstUsesWith(I, ConstantBool::True); + } else { + I.setOperand(1, NewCst); + LHSI->setOperand(1, ConstantExpr::get(ShiftOp, AndCST,ShAmt)); + LHSI->setOperand(0, Shift->getOperand(0)); + WorkList.push_back(Shift); // Shift is dead. + AddUsesToWorkList(I); + return &I; + } } } } From gaeke at cs.uiuc.edu Wed Jul 21 15:17:30 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed, 21 Jul 2004 15:17:30 -0500 (CDT) Subject: [llvm-commits] CVS: reopt/lib/TraceToFunction/TraceToFunction.cpp Message-ID: <200407212017.PAA16575@seraph.cs.uiuc.edu> Changes in directory reopt/lib/TraceToFunction: TraceToFunction.cpp updated: 1.79 -> 1.80 --- Log message: Hmm... it doesn't work after all. Never mind. We'll come back to this later. --- Diffs of the changes: (+1 -1) Index: reopt/lib/TraceToFunction/TraceToFunction.cpp diff -u reopt/lib/TraceToFunction/TraceToFunction.cpp:1.79 reopt/lib/TraceToFunction/TraceToFunction.cpp:1.80 --- reopt/lib/TraceToFunction/TraceToFunction.cpp:1.79 Tue Jul 20 21:51:49 2004 +++ reopt/lib/TraceToFunction/TraceToFunction.cpp Wed Jul 21 15:17:19 2004 @@ -790,7 +790,7 @@ for (LiveVariableVector::iterator SI = So.begin (), SE = So.end (); SI != SE; ++SI) if (dominates (T, cast ((*SI))->getParent (), -#if 1 // WARNING: hasUseDominatedByEdge isn't working right yet! +#if 0 // WARNING: hasUseDominatedByEdge isn't working right yet! BI->getParent ()) && hasUseDominatedByEdge (cast (*SI), srcB, successor)) From gaeke at cs.uiuc.edu Wed Jul 21 15:18:56 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed, 21 Jul 2004 15:18:56 -0500 (CDT) Subject: [llvm-commits] CVS: reopt/lib/TraceJIT/TraceJITOpts.cpp Message-ID: <200407212018.PAA16597@seraph.cs.uiuc.edu> Changes in directory reopt/lib/TraceJIT: TraceJITOpts.cpp updated: 1.1 -> 1.2 --- Log message: Add some sample optimizations, and an option to turn them on. --- Diffs of the changes: (+10 -0) Index: reopt/lib/TraceJIT/TraceJITOpts.cpp diff -u reopt/lib/TraceJIT/TraceJITOpts.cpp:1.1 reopt/lib/TraceJIT/TraceJITOpts.cpp:1.2 --- reopt/lib/TraceJIT/TraceJITOpts.cpp:1.1 Tue Jul 20 17:41:43 2004 +++ reopt/lib/TraceJIT/TraceJITOpts.cpp Wed Jul 21 15:18:45 2004 @@ -13,8 +13,18 @@ #include "reopt/TraceJIT.h" #include "llvm/Transforms/Scalar.h" +#include "llvm/Analysis/LoadValueNumbering.h" +#include "Support/CommandLine.h" using namespace llvm; +namespace { + cl::opt RunOptimizationPasses ("run-opt-passes", cl::init(false)); +}; + void TraceJIT::addOptimizationPasses (FunctionPassManager &PM) { + if (RunOptimizationPasses) { + PM.add(createInstructionCombiningPass()); + PM.add(createDeadCodeEliminationPass()); + } } From gaeke at cs.uiuc.edu Wed Jul 21 15:18:56 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed, 21 Jul 2004 15:18:56 -0500 (CDT) Subject: [llvm-commits] CVS: reopt/test/run-tests Message-ID: <200407212018.PAA16604@seraph.cs.uiuc.edu> Changes in directory reopt/test: run-tests updated: 1.13 -> 1.14 --- Log message: Add a skip-trace command line option. Make it so I don't have to add all of my private SingleSource/Reoptimizer tests individually. --- Diffs of the changes: (+29 -17) Index: reopt/test/run-tests diff -u reopt/test/run-tests:1.13 reopt/test/run-tests:1.14 --- reopt/test/run-tests:1.13 Tue Jul 20 17:54:10 2004 +++ reopt/test/run-tests Wed Jul 21 15:18:46 2004 @@ -16,6 +16,7 @@ fi # parse arguments +skiptrace=0 outputonly=0 action=test for arg in $@; do @@ -25,16 +26,29 @@ -debug) action=debug ;; -test) action=test ;; -list) action=list ;; + -skiptrace=*) skiptrace=`echo $arg|sed 's/^-skiptrace=//'` ;; *) benchmk=$arg ;; esac done +# get full path to test/Programs subdirectory +objroot=`gmake prdirs | egrep 'LLVM.*Object Root' |cut -d: -f2-` + +EXTRATESTSUBDIR=SingleSource/Reoptimizer +EXTRATESTDIR=${objroot}/test/Programs/$EXTRATESTSUBDIR # sanity check arguments if [ "$action" = "list" ]; then echo "" echo "SUPPORTED TESTS:" echo "----------------" - grep SUBDIR= $0 | egrep -v '(exec|grep)' | sed 's/) / /' | sed 's/;.*$//' + grep SUBDIR= $0 | egrep -v '(exec|grep|ucname)' | sed 's/) / /' | sed 's/;.*$//' + if [ -d $EXTRATESTDIR ]; then + for d in ${EXTRATESTDIR}/*; do + arg=`basename $d | tr A-Z a-z` + ucname=`echo $arg | perl -pe '$_ = ucfirst lc $_;'` + echo " $arg SUBDIR=$EXTRATESTSUBDIR/$ucname" + done + fi exit 0 fi if [ -z "$benchmk" ]; then @@ -43,6 +57,9 @@ if [ \( $outputonly -ne 0 \) -a \( "$action" != "clean" \) ]; then die "Error: -output only meaningful w/ -clean" fi +if [ \( $skiptrace -ne 0 \) -a \( "$action" != "test" \) ]; then + die "Error: -skiptrace=N only meaningful when running a test" +fi # choose from among the programs we know of (sets SUBDIR and spectest) spectest=0 @@ -54,30 +71,21 @@ stanford) SUBDIR=SingleSource/Benchmarks/Stanford ;; olden) SUBDIR=MultiSource/Benchmarks/Olden ;; - ary3) SUBDIR=SingleSource/Reoptimizer/Ary3 ;; - sieve) SUBDIR=SingleSource/Reoptimizer/Sieve ;; - lists) SUBDIR=SingleSource/Reoptimizer/Lists ;; - strcat) SUBDIR=SingleSource/Reoptimizer/Strcat ;; - mynestedloop) SUBDIR=SingleSource/Reoptimizer/MyNestedLoop ;; - fib2) SUBDIR=SingleSource/Reoptimizer/Fib2 ;; - hash) SUBDIR=SingleSource/Reoptimizer/Hash ;; - towers) SUBDIR=SingleSource/Reoptimizer/Towers ;; - treesort) SUBDIR=SingleSource/Reoptimizer/Treesort ;; - intmm) SUBDIR=SingleSource/Reoptimizer/Intmm ;; - realmm) SUBDIR=SingleSource/Reoptimizer/Realmm ;; - mcf) SUBDIR=External/SPEC/CINT2000/181.mcf; spectest=1 ;; art) SUBDIR=External/SPEC/CFP2000/179.art; spectest=1;; equake) SUBDIR=External/SPEC/CFP2000/183.equake; spectest=1 ;; gzip) SUBDIR=External/SPEC/CINT2000/164.gzip; spectest=1 ;; bzip2) SUBDIR=External/SPEC/CINT2000/256.bzip2; spectest=1 ;; - *) die "Error: Unknown benchmark $arg" ;; + *) ucname=`echo $benchmk | perl -pe '$_ = ucfirst lc $_;'` + SUBDIR=$EXTRATESTSUBDIR/$ucname + if [ ! -d $objroot/test/Programs/$SUBDIR ] + then + die "Error: Unknown benchmark $benchmk" + fi + ;; esac echo "Starting ${action} on $benchmk" - -# get full path to test/Programs subdirectory -objroot=`gmake prdirs | egrep 'LLVM.*Object Root' |cut -d: -f2-` fullsubdirpath="${objroot}/test/Programs/${SUBDIR}" do_debug () { @@ -106,6 +114,10 @@ } do_test () { + if [ $skiptrace -ne 0 ]; then + LLVM_REOPT="--skip-trace=$skiptrace $LLVM_REOPT" + export LLVM_REOPT + fi if [ "$benchmk" = "olden" ]; then exec gmake SUBDIR=$SUBDIR LARGE_PROBLEM_SIZE=1 elif [ $spectest -eq 1 ]; then From gaeke at cs.uiuc.edu Wed Jul 21 15:50:33 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed, 21 Jul 2004 15:50:33 -0500 Subject: [llvm-commits] CVS: llvm/include/Support/Debug.h Message-ID: <200407212050.PAA08625@zion.cs.uiuc.edu> Changes in directory llvm/include/Support: Debug.h updated: 1.3 -> 1.4 --- Log message: Include here, because most people using DEBUG() want to use std::cerr too. This means that users of this file do not also need to include . --- Diffs of the changes: (+3 -0) Index: llvm/include/Support/Debug.h diff -u llvm/include/Support/Debug.h:1.3 llvm/include/Support/Debug.h:1.4 --- llvm/include/Support/Debug.h:1.3 Tue Nov 11 16:41:29 2003 +++ llvm/include/Support/Debug.h Wed Jul 21 15:50:22 2004 @@ -26,6 +26,9 @@ #ifndef SUPPORT_DEBUG_H #define SUPPORT_DEBUG_H +// Unsurprisingly, most users of this macro use std::cerr too. +#include + namespace llvm { // DebugFlag - This boolean is set to true if the '-debug' command line option From gaeke at cs.uiuc.edu Wed Jul 21 15:50:43 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed, 21 Jul 2004 15:50:43 -0500 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/Local.cpp Steensgaard.cpp Message-ID: <200407212050.PAA08689@zion.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: Local.cpp updated: 1.108 -> 1.109 Steensgaard.cpp updated: 1.40 -> 1.41 --- Log message: These files don't need to include since they include "Support/Debug.h". --- Diffs of the changes: (+0 -2) Index: llvm/lib/Analysis/DataStructure/Local.cpp diff -u llvm/lib/Analysis/DataStructure/Local.cpp:1.108 llvm/lib/Analysis/DataStructure/Local.cpp:1.109 --- llvm/lib/Analysis/DataStructure/Local.cpp:1.108 Sat Jul 17 19:18:30 2004 +++ llvm/lib/Analysis/DataStructure/Local.cpp Wed Jul 21 15:50:33 2004 @@ -24,7 +24,6 @@ #include "Support/CommandLine.h" #include "Support/Debug.h" #include "Support/Timer.h" -#include // FIXME: This should eventually be a FunctionPass that is automatically // aggregated into a Pass. Index: llvm/lib/Analysis/DataStructure/Steensgaard.cpp diff -u llvm/lib/Analysis/DataStructure/Steensgaard.cpp:1.40 llvm/lib/Analysis/DataStructure/Steensgaard.cpp:1.41 --- llvm/lib/Analysis/DataStructure/Steensgaard.cpp:1.40 Wed Jul 7 01:32:21 2004 +++ llvm/lib/Analysis/DataStructure/Steensgaard.cpp Wed Jul 21 15:50:33 2004 @@ -19,7 +19,6 @@ #include "llvm/Analysis/AliasAnalysis.h" #include "llvm/Module.h" #include "Support/Debug.h" -#include using namespace llvm; namespace { From gaeke at cs.uiuc.edu Wed Jul 21 15:50:43 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed, 21 Jul 2004 15:50:43 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervals.cpp RegAllocIterativeScan.cpp RegAllocLinearScan.cpp RegAllocLocal.cpp RegAllocSimple.cpp TwoAddressInstructionPass.cpp VirtRegMap.cpp Message-ID: <200407212050.PAA08724@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveIntervals.cpp updated: 1.98 -> 1.99 RegAllocIterativeScan.cpp updated: 1.5 -> 1.6 RegAllocLinearScan.cpp updated: 1.80 -> 1.81 RegAllocLocal.cpp updated: 1.63 -> 1.64 RegAllocSimple.cpp updated: 1.57 -> 1.58 TwoAddressInstructionPass.cpp updated: 1.21 -> 1.22 VirtRegMap.cpp updated: 1.15 -> 1.16 --- Log message: These files don't need to include since they include "Support/Debug.h". --- Diffs of the changes: (+0 -7) Index: llvm/lib/CodeGen/LiveIntervals.cpp diff -u llvm/lib/CodeGen/LiveIntervals.cpp:1.98 llvm/lib/CodeGen/LiveIntervals.cpp:1.99 --- llvm/lib/CodeGen/LiveIntervals.cpp:1.98 Tue Jul 20 05:20:03 2004 +++ llvm/lib/CodeGen/LiveIntervals.cpp Wed Jul 21 15:50:33 2004 @@ -33,7 +33,6 @@ #include "Support/STLExtras.h" #include "VirtRegMap.h" #include -#include using namespace llvm; Index: llvm/lib/CodeGen/RegAllocIterativeScan.cpp diff -u llvm/lib/CodeGen/RegAllocIterativeScan.cpp:1.5 llvm/lib/CodeGen/RegAllocIterativeScan.cpp:1.6 --- llvm/lib/CodeGen/RegAllocIterativeScan.cpp:1.5 Wed Jul 21 12:23:44 2004 +++ llvm/lib/CodeGen/RegAllocIterativeScan.cpp Wed Jul 21 15:50:33 2004 @@ -34,7 +34,6 @@ #include "VirtRegMap.h" #include #include -#include #include using namespace llvm; Index: llvm/lib/CodeGen/RegAllocLinearScan.cpp diff -u llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.80 llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.81 --- llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.80 Mon Jul 19 18:35:55 2004 +++ llvm/lib/CodeGen/RegAllocLinearScan.cpp Wed Jul 21 15:50:33 2004 @@ -28,7 +28,6 @@ #include "VirtRegMap.h" #include #include -#include #include using namespace llvm; Index: llvm/lib/CodeGen/RegAllocLocal.cpp diff -u llvm/lib/CodeGen/RegAllocLocal.cpp:1.63 llvm/lib/CodeGen/RegAllocLocal.cpp:1.64 --- llvm/lib/CodeGen/RegAllocLocal.cpp:1.63 Wed Jun 16 01:57:29 2004 +++ llvm/lib/CodeGen/RegAllocLocal.cpp Wed Jul 21 15:50:33 2004 @@ -25,7 +25,6 @@ #include "Support/Debug.h" #include "Support/DenseMap.h" #include "Support/Statistic.h" -#include using namespace llvm; namespace { Index: llvm/lib/CodeGen/RegAllocSimple.cpp diff -u llvm/lib/CodeGen/RegAllocSimple.cpp:1.57 llvm/lib/CodeGen/RegAllocSimple.cpp:1.58 --- llvm/lib/CodeGen/RegAllocSimple.cpp:1.57 Thu Jun 24 19:13:11 2004 +++ llvm/lib/CodeGen/RegAllocSimple.cpp Wed Jul 21 15:50:33 2004 @@ -25,7 +25,6 @@ #include "Support/Debug.h" #include "Support/Statistic.h" #include "Support/STLExtras.h" -#include using namespace llvm; namespace { Index: llvm/lib/CodeGen/TwoAddressInstructionPass.cpp diff -u llvm/lib/CodeGen/TwoAddressInstructionPass.cpp:1.21 llvm/lib/CodeGen/TwoAddressInstructionPass.cpp:1.22 --- llvm/lib/CodeGen/TwoAddressInstructionPass.cpp:1.21 Mon Jul 19 01:55:17 2004 +++ llvm/lib/CodeGen/TwoAddressInstructionPass.cpp Wed Jul 21 15:50:33 2004 @@ -40,7 +40,6 @@ #include "Support/Debug.h" #include "Support/Statistic.h" #include "Support/STLExtras.h" -#include using namespace llvm; namespace { Index: llvm/lib/CodeGen/VirtRegMap.cpp diff -u llvm/lib/CodeGen/VirtRegMap.cpp:1.15 llvm/lib/CodeGen/VirtRegMap.cpp:1.16 --- llvm/lib/CodeGen/VirtRegMap.cpp:1.15 Thu Jul 15 19:06:01 2004 +++ llvm/lib/CodeGen/VirtRegMap.cpp Wed Jul 21 15:50:33 2004 @@ -27,7 +27,6 @@ #include "Support/DenseMap.h" #include "Support/Statistic.h" #include "Support/STLExtras.h" -#include using namespace llvm; From gaeke at cs.uiuc.edu Wed Jul 21 15:50:43 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed, 21 Jul 2004 15:50:43 -0500 Subject: [llvm-commits] CVS: llvm/lib/Support/ToolRunner.cpp Message-ID: <200407212050.PAA08718@zion.cs.uiuc.edu> Changes in directory llvm/lib/Support: ToolRunner.cpp updated: 1.27 -> 1.28 --- Log message: These files don't need to include since they include "Support/Debug.h". --- Diffs of the changes: (+0 -1) Index: llvm/lib/Support/ToolRunner.cpp diff -u llvm/lib/Support/ToolRunner.cpp:1.27 llvm/lib/Support/ToolRunner.cpp:1.28 --- llvm/lib/Support/ToolRunner.cpp:1.27 Mon Jul 19 01:03:51 2004 +++ llvm/lib/Support/ToolRunner.cpp Wed Jul 21 15:50:33 2004 @@ -16,7 +16,6 @@ #include "Config/config.h" // for HAVE_LINK_R #include "Support/Debug.h" #include "Support/FileUtilities.h" -#include #include #include using namespace llvm; From gaeke at cs.uiuc.edu Wed Jul 21 15:50:43 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed, 21 Jul 2004 15:50:43 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/ModuloScheduling/MSSchedule.cpp MSchedGraph.cpp ModuloScheduling.cpp Message-ID: <200407212050.PAA08717@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/ModuloScheduling: MSSchedule.cpp updated: 1.1 -> 1.2 MSchedGraph.cpp updated: 1.3 -> 1.4 ModuloScheduling.cpp updated: 1.19 -> 1.20 --- Log message: These files don't need to include since they include "Support/Debug.h". --- Diffs of the changes: (+0 -3) Index: llvm/lib/CodeGen/ModuloScheduling/MSSchedule.cpp diff -u llvm/lib/CodeGen/ModuloScheduling/MSSchedule.cpp:1.1 llvm/lib/CodeGen/ModuloScheduling/MSSchedule.cpp:1.2 --- llvm/lib/CodeGen/ModuloScheduling/MSSchedule.cpp:1.1 Wed May 26 01:27:36 2004 +++ llvm/lib/CodeGen/ModuloScheduling/MSSchedule.cpp Wed Jul 21 15:50:33 2004 @@ -15,7 +15,6 @@ #include "MSSchedule.h" #include "Support/Debug.h" #include "llvm/Target/TargetSchedInfo.h" -#include using namespace llvm; Index: llvm/lib/CodeGen/ModuloScheduling/MSchedGraph.cpp diff -u llvm/lib/CodeGen/ModuloScheduling/MSchedGraph.cpp:1.3 llvm/lib/CodeGen/ModuloScheduling/MSchedGraph.cpp:1.4 --- llvm/lib/CodeGen/ModuloScheduling/MSchedGraph.cpp:1.3 Wed May 26 01:27:18 2004 +++ llvm/lib/CodeGen/ModuloScheduling/MSchedGraph.cpp Wed Jul 21 15:50:33 2004 @@ -17,7 +17,6 @@ #include "llvm/CodeGen/MachineBasicBlock.h" #include "llvm/Target/TargetInstrInfo.h" #include "Support/Debug.h" -#include using namespace llvm; MSchedGraphNode::MSchedGraphNode(const MachineInstr* inst, Index: llvm/lib/CodeGen/ModuloScheduling/ModuloScheduling.cpp diff -u llvm/lib/CodeGen/ModuloScheduling/ModuloScheduling.cpp:1.19 llvm/lib/CodeGen/ModuloScheduling/ModuloScheduling.cpp:1.20 --- llvm/lib/CodeGen/ModuloScheduling/ModuloScheduling.cpp:1.19 Fri May 28 15:14:12 2004 +++ llvm/lib/CodeGen/ModuloScheduling/ModuloScheduling.cpp Wed Jul 21 15:50:33 2004 @@ -23,7 +23,6 @@ #include "Support/StringExtras.h" #include #include -#include #include #include From gaeke at cs.uiuc.edu Wed Jul 21 15:50:43 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed, 21 Jul 2004 15:50:43 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/ExprTypeConvert.cpp Message-ID: <200407212050.PAA08734@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms: ExprTypeConvert.cpp updated: 1.94 -> 1.95 --- Log message: These files don't need to include since they include "Support/Debug.h". --- Diffs of the changes: (+0 -2) Index: llvm/lib/Transforms/ExprTypeConvert.cpp diff -u llvm/lib/Transforms/ExprTypeConvert.cpp:1.94 llvm/lib/Transforms/ExprTypeConvert.cpp:1.95 --- llvm/lib/Transforms/ExprTypeConvert.cpp:1.94 Wed Jul 14 21:06:06 2004 +++ llvm/lib/Transforms/ExprTypeConvert.cpp Wed Jul 21 15:50:33 2004 @@ -18,12 +18,10 @@ #include "llvm/iOther.h" #include "llvm/iPHINode.h" #include "llvm/iMemory.h" - #include "llvm/Analysis/Expressions.h" #include "Support/STLExtras.h" #include "Support/Debug.h" #include -#include using namespace llvm; static bool OperandConvertibleToType(User *U, Value *V, const Type *Ty, From gaeke at cs.uiuc.edu Wed Jul 21 15:50:43 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed, 21 Jul 2004 15:50:43 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Instrumentation/TraceBasicBlocks.cpp Message-ID: <200407212050.PAA08740@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Instrumentation: TraceBasicBlocks.cpp updated: 1.5 -> 1.6 --- Log message: These files don't need to include since they include "Support/Debug.h". --- Diffs of the changes: (+0 -1) Index: llvm/lib/Transforms/Instrumentation/TraceBasicBlocks.cpp diff -u llvm/lib/Transforms/Instrumentation/TraceBasicBlocks.cpp:1.5 llvm/lib/Transforms/Instrumentation/TraceBasicBlocks.cpp:1.6 --- llvm/lib/Transforms/Instrumentation/TraceBasicBlocks.cpp:1.5 Sun Jul 4 07:19:56 2004 +++ llvm/lib/Transforms/Instrumentation/TraceBasicBlocks.cpp Wed Jul 21 15:50:33 2004 @@ -23,7 +23,6 @@ #include "llvm/iPHINode.h" #include "ProfilingUtils.h" #include "Support/Debug.h" -#include #include using namespace llvm; From gaeke at cs.uiuc.edu Wed Jul 21 15:50:43 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed, 21 Jul 2004 15:50:43 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Utils/CodeExtractor.cpp SimplifyCFG.cpp Message-ID: <200407212050.PAA08760@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Utils: CodeExtractor.cpp updated: 1.26 -> 1.27 SimplifyCFG.cpp updated: 1.48 -> 1.49 --- Log message: These files don't need to include since they include "Support/Debug.h". --- Diffs of the changes: (+0 -2) Index: llvm/lib/Transforms/Utils/CodeExtractor.cpp diff -u llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.26 llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.27 --- llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.26 Wed Jul 14 21:06:11 2004 +++ llvm/lib/Transforms/Utils/CodeExtractor.cpp Wed Jul 21 15:50:33 2004 @@ -28,7 +28,6 @@ #include "Support/Debug.h" #include "Support/StringExtras.h" #include -#include #include using namespace llvm; Index: llvm/lib/Transforms/Utils/SimplifyCFG.cpp diff -u llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.48 llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.49 --- llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.48 Mon Jul 19 20:17:38 2004 +++ llvm/lib/Transforms/Utils/SimplifyCFG.cpp Wed Jul 21 15:50:33 2004 @@ -21,7 +21,6 @@ #include #include #include -#include using namespace llvm; From gaeke at cs.uiuc.edu Wed Jul 21 15:50:43 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed, 21 Jul 2004 15:50:43 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Instrumentation/ProfilePaths/Graph.cpp GraphAuxiliary.cpp InstLoops.cpp Message-ID: <200407212050.PAA08753@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Instrumentation/ProfilePaths: Graph.cpp updated: 1.15 -> 1.16 GraphAuxiliary.cpp updated: 1.22 -> 1.23 InstLoops.cpp updated: 1.14 -> 1.15 --- Log message: These files don't need to include since they include "Support/Debug.h". --- Diffs of the changes: (+0 -3) Index: llvm/lib/Transforms/Instrumentation/ProfilePaths/Graph.cpp diff -u llvm/lib/Transforms/Instrumentation/ProfilePaths/Graph.cpp:1.15 llvm/lib/Transforms/Instrumentation/ProfilePaths/Graph.cpp:1.16 --- llvm/lib/Transforms/Instrumentation/ProfilePaths/Graph.cpp:1.15 Sun Jul 4 07:19:56 2004 +++ llvm/lib/Transforms/Instrumentation/ProfilePaths/Graph.cpp Wed Jul 21 15:50:33 2004 @@ -16,7 +16,6 @@ #include "llvm/iTerminators.h" #include "Support/Debug.h" #include -#include using std::vector; Index: llvm/lib/Transforms/Instrumentation/ProfilePaths/GraphAuxiliary.cpp diff -u llvm/lib/Transforms/Instrumentation/ProfilePaths/GraphAuxiliary.cpp:1.22 llvm/lib/Transforms/Instrumentation/ProfilePaths/GraphAuxiliary.cpp:1.23 --- llvm/lib/Transforms/Instrumentation/ProfilePaths/GraphAuxiliary.cpp:1.22 Sun Jul 4 07:19:56 2004 +++ llvm/lib/Transforms/Instrumentation/ProfilePaths/GraphAuxiliary.cpp Wed Jul 21 15:50:33 2004 @@ -17,7 +17,6 @@ #include "llvm/iTerminators.h" #include "Support/Debug.h" #include -#include #include "Graph.h" //using std::list; Index: llvm/lib/Transforms/Instrumentation/ProfilePaths/InstLoops.cpp diff -u llvm/lib/Transforms/Instrumentation/ProfilePaths/InstLoops.cpp:1.14 llvm/lib/Transforms/Instrumentation/ProfilePaths/InstLoops.cpp:1.15 --- llvm/lib/Transforms/Instrumentation/ProfilePaths/InstLoops.cpp:1.14 Sun Jul 4 07:19:56 2004 +++ llvm/lib/Transforms/Instrumentation/ProfilePaths/InstLoops.cpp Wed Jul 21 15:50:33 2004 @@ -24,7 +24,6 @@ #include "llvm/Pass.h" #include "Support/Debug.h" #include "../ProfilingUtils.h" -#include namespace llvm { From gaeke at cs.uiuc.edu Wed Jul 21 15:50:43 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed, 21 Jul 2004 15:50:43 -0500 Subject: [llvm-commits] CVS: llvm/tools/bugpoint/ExecutionDriver.cpp ExtractFunction.cpp Message-ID: <200407212050.PAA08769@zion.cs.uiuc.edu> Changes in directory llvm/tools/bugpoint: ExecutionDriver.cpp updated: 1.44 -> 1.45 ExtractFunction.cpp updated: 1.35 -> 1.36 --- Log message: These files don't need to include since they include "Support/Debug.h". --- Diffs of the changes: (+0 -2) Index: llvm/tools/bugpoint/ExecutionDriver.cpp diff -u llvm/tools/bugpoint/ExecutionDriver.cpp:1.44 llvm/tools/bugpoint/ExecutionDriver.cpp:1.45 --- llvm/tools/bugpoint/ExecutionDriver.cpp:1.44 Thu Jul 15 19:08:04 2004 +++ llvm/tools/bugpoint/ExecutionDriver.cpp Wed Jul 21 15:50:33 2004 @@ -19,7 +19,6 @@ #include "Support/FileUtilities.h" #include "Support/SystemUtils.h" #include -#include using namespace llvm; namespace { Index: llvm/tools/bugpoint/ExtractFunction.cpp diff -u llvm/tools/bugpoint/ExtractFunction.cpp:1.35 llvm/tools/bugpoint/ExtractFunction.cpp:1.36 --- llvm/tools/bugpoint/ExtractFunction.cpp:1.35 Sun Jul 4 07:20:55 2004 +++ llvm/tools/bugpoint/ExtractFunction.cpp Wed Jul 21 15:50:33 2004 @@ -27,7 +27,6 @@ #include "Support/CommandLine.h" #include "Support/Debug.h" #include "Support/FileUtilities.h" -#include #include using namespace llvm; From gaeke at cs.uiuc.edu Wed Jul 21 15:53:38 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed, 21 Jul 2004 15:53:38 -0500 Subject: [llvm-commits] CVS: reopt/lib/Mapping/ValueAllocState.cpp Message-ID: <200407212053.PAA08987@zion.cs.uiuc.edu> Changes in directory reopt/lib/Mapping: ValueAllocState.cpp updated: 1.1 -> 1.2 --- Log message: We don't need to include after already including Support/Debug.h. --- Diffs of the changes: (+0 -1) Index: reopt/lib/Mapping/ValueAllocState.cpp diff -u reopt/lib/Mapping/ValueAllocState.cpp:1.1 reopt/lib/Mapping/ValueAllocState.cpp:1.2 --- reopt/lib/Mapping/ValueAllocState.cpp:1.1 Wed Jul 14 01:11:55 2004 +++ reopt/lib/Mapping/ValueAllocState.cpp Wed Jul 21 15:53:28 2004 @@ -22,7 +22,6 @@ #include "Support/Debug.h" #include "../../../../lib/Target/SparcV9/RegAlloc/AllocInfo.h" #include "../../../../lib/Target/SparcV9/RegAlloc/PhyRegAlloc.h" -#include namespace llvm { From gaeke at cs.uiuc.edu Wed Jul 21 15:53:38 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed, 21 Jul 2004 15:53:38 -0500 Subject: [llvm-commits] CVS: reopt/lib/BinInterface/LLVMTrace.cpp Message-ID: <200407212053.PAA08973@zion.cs.uiuc.edu> Changes in directory reopt/lib/BinInterface: LLVMTrace.cpp updated: 1.6 -> 1.7 --- Log message: We don't need to include after already including Support/Debug.h. --- Diffs of the changes: (+0 -1) Index: reopt/lib/BinInterface/LLVMTrace.cpp diff -u reopt/lib/BinInterface/LLVMTrace.cpp:1.6 reopt/lib/BinInterface/LLVMTrace.cpp:1.7 --- reopt/lib/BinInterface/LLVMTrace.cpp:1.6 Sat May 15 23:58:06 2004 +++ reopt/lib/BinInterface/LLVMTrace.cpp Wed Jul 21 15:53:28 2004 @@ -14,7 +14,6 @@ #include "llvm/BasicBlock.h" #include "llvm/iPHINode.h" #include "Support/Debug.h" -#include using namespace llvm; From gaeke at cs.uiuc.edu Wed Jul 21 15:53:38 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed, 21 Jul 2004 15:53:38 -0500 Subject: [llvm-commits] CVS: reopt/lib/TraceJIT/TraceJITGlobals.cpp Message-ID: <200407212053.PAA09015@zion.cs.uiuc.edu> Changes in directory reopt/lib/TraceJIT: TraceJITGlobals.cpp updated: 1.4 -> 1.5 --- Log message: We don't need to include after already including Support/Debug.h. --- Diffs of the changes: (+0 -1) Index: reopt/lib/TraceJIT/TraceJITGlobals.cpp diff -u reopt/lib/TraceJIT/TraceJITGlobals.cpp:1.4 reopt/lib/TraceJIT/TraceJITGlobals.cpp:1.5 --- reopt/lib/TraceJIT/TraceJITGlobals.cpp:1.4 Thu Jul 8 14:25:06 2004 +++ reopt/lib/TraceJIT/TraceJITGlobals.cpp Wed Jul 21 15:53:28 2004 @@ -16,7 +16,6 @@ #include "reopt/TraceJIT.h" #include "llvm/Module.h" #include "Support/Debug.h" -#include using namespace llvm; struct InternalGlobalMap { From gaeke at cs.uiuc.edu Wed Jul 21 15:53:38 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed, 21 Jul 2004 15:53:38 -0500 Subject: [llvm-commits] CVS: reopt/lib/TraceCache/InstrUtils.cpp Message-ID: <200407212053.PAA09001@zion.cs.uiuc.edu> Changes in directory reopt/lib/TraceCache: InstrUtils.cpp updated: 1.19 -> 1.20 --- Log message: We don't need to include after already including Support/Debug.h. --- Diffs of the changes: (+0 -1) Index: reopt/lib/TraceCache/InstrUtils.cpp diff -u reopt/lib/TraceCache/InstrUtils.cpp:1.19 reopt/lib/TraceCache/InstrUtils.cpp:1.20 --- reopt/lib/TraceCache/InstrUtils.cpp:1.19 Mon May 17 15:56:09 2004 +++ reopt/lib/TraceCache/InstrUtils.cpp Wed Jul 21 15:53:28 2004 @@ -8,7 +8,6 @@ #include "reopt/InstrUtils.h" #include "Support/Debug.h" #include -#include namespace llvm { From gaeke at cs.uiuc.edu Wed Jul 21 15:53:38 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed, 21 Jul 2004 15:53:38 -0500 Subject: [llvm-commits] CVS: reopt/lib/Optimizations/RuntimeLICM.cpp Message-ID: <200407212053.PAA08994@zion.cs.uiuc.edu> Changes in directory reopt/lib/Optimizations: RuntimeLICM.cpp updated: 1.3 -> 1.4 --- Log message: We don't need to include after already including Support/Debug.h. --- Diffs of the changes: (+0 -1) Index: reopt/lib/Optimizations/RuntimeLICM.cpp diff -u reopt/lib/Optimizations/RuntimeLICM.cpp:1.3 reopt/lib/Optimizations/RuntimeLICM.cpp:1.4 --- reopt/lib/Optimizations/RuntimeLICM.cpp:1.3 Sat May 22 15:41:41 2004 +++ reopt/lib/Optimizations/RuntimeLICM.cpp Wed Jul 21 15:53:28 2004 @@ -12,7 +12,6 @@ #include "llvm/iPHINode.h" #include "reopt/BinInterface/LLVMTrace.h" #include "Support/Debug.h" -#include #include using namespace llvm; From gaeke at cs.uiuc.edu Wed Jul 21 15:53:38 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed, 21 Jul 2004 15:53:38 -0500 Subject: [llvm-commits] CVS: reopt/lib/TraceIO/TraceReader.cpp Message-ID: <200407212053.PAA09008@zion.cs.uiuc.edu> Changes in directory reopt/lib/TraceIO: TraceReader.cpp updated: 1.2 -> 1.3 --- Log message: We don't need to include after already including Support/Debug.h. --- Diffs of the changes: (+0 -1) Index: reopt/lib/TraceIO/TraceReader.cpp diff -u reopt/lib/TraceIO/TraceReader.cpp:1.2 reopt/lib/TraceIO/TraceReader.cpp:1.3 --- reopt/lib/TraceIO/TraceReader.cpp:1.2 Thu Jul 8 14:34:31 2004 +++ reopt/lib/TraceIO/TraceReader.cpp Wed Jul 21 15:53:28 2004 @@ -5,7 +5,6 @@ #include "llvm/Module.h" #include #include -#include using namespace llvm; namespace llvm { From gaeke at cs.uiuc.edu Wed Jul 21 15:53:38 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed, 21 Jul 2004 15:53:38 -0500 Subject: [llvm-commits] CVS: reopt/lib/TraceToFunction/TraceToFunction.cpp Message-ID: <200407212053.PAA09022@zion.cs.uiuc.edu> Changes in directory reopt/lib/TraceToFunction: TraceToFunction.cpp updated: 1.80 -> 1.81 --- Log message: We don't need to include after already including Support/Debug.h. --- Diffs of the changes: (+0 -1) Index: reopt/lib/TraceToFunction/TraceToFunction.cpp diff -u reopt/lib/TraceToFunction/TraceToFunction.cpp:1.80 reopt/lib/TraceToFunction/TraceToFunction.cpp:1.81 --- reopt/lib/TraceToFunction/TraceToFunction.cpp:1.80 Wed Jul 21 15:17:19 2004 +++ reopt/lib/TraceToFunction/TraceToFunction.cpp Wed Jul 21 15:53:28 2004 @@ -39,7 +39,6 @@ #define DEBUG_TYPE "tracetofunction" #include "Support/Debug.h" // for DEBUG() #include -#include namespace llvm { From gaeke at cs.uiuc.edu Wed Jul 21 15:53:38 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed, 21 Jul 2004 15:53:38 -0500 Subject: [llvm-commits] CVS: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp Message-ID: <200407212053.PAA08980@zion.cs.uiuc.edu> Changes in directory reopt/lib/LightWtProfiling: UnpackTraceFunction.cpp updated: 1.101 -> 1.102 --- Log message: We don't need to include after already including Support/Debug.h. --- Diffs of the changes: (+0 -1) Index: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp diff -u reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.101 reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.102 --- reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.101 Tue Jul 20 21:51:50 2004 +++ reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp Wed Jul 21 15:53:28 2004 @@ -29,7 +29,6 @@ #include "../../../../lib/Target/SparcV9/RegAlloc/AllocInfo.h" #include "../../../../lib/Target/SparcV9/SparcV9RegInfo.h" #include "../../../../lib/Target/SparcV9/SparcV9TargetMachine.h" -#include namespace llvm { From gaeke at cs.uiuc.edu Wed Jul 21 16:03:07 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed, 21 Jul 2004 16:03:07 -0500 (CDT) Subject: [llvm-commits] CVS: reopt/test/HexFilter.pl Summarize.pl Message-ID: <200407212103.QAA16695@seraph.cs.uiuc.edu> Changes in directory reopt/test: HexFilter.pl added (r1.1) Summarize.pl added (r1.1) --- Log message: More scripts that I commonly use --- Diffs of the changes: (+46 -0) Index: reopt/test/HexFilter.pl diff -c /dev/null reopt/test/HexFilter.pl:1.1 *** /dev/null Wed Jul 21 16:03:07 2004 --- reopt/test/HexFilter.pl Wed Jul 21 16:02:57 2004 *************** *** 0 **** --- 1,5 ---- + #!/usr/dcs/software/supported/bin/perl -p + # Make things that look like sparc addrs into underscores, so that diff won't + # be able to tell they're different. + + s/1[0-9a-f]{8}/1________/g; Index: reopt/test/Summarize.pl diff -c /dev/null reopt/test/Summarize.pl:1.1 *** /dev/null Wed Jul 21 16:03:07 2004 --- reopt/test/Summarize.pl Wed Jul 21 16:02:57 2004 *************** *** 0 **** --- 1,41 ---- + exec perl -Sx $0 ${1+"$@"} + #! magically/invoked/perl + # Test summarizer for reoptimizer's run-tests script + # + + format STDOUT_TOP = + CodeGen + Benchmark Traces? Pass Test? Extra info? + ------------- ---------- ---------- ------------------------ + . + + format STDOUT = + @<<<<<<<<<<<< @<<<<<<<<< @<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<< + $test $traces $fail $extra + . + + while (<>) { + if (/Running Reoptimizer version of (\S+)/) { + $test = $1; + $traces = 0; + $fail = 'PASS'; + $extra = ''; + } + elsif (/^Finished CodeGen/) { + ++$traces; + } + elsif (/TEST \(reopt-llc\) '(\S+)' FAILED/) { + $fail = 'FAIL'; + } + elsif (/Finished running Reoptimizer tests for (\S+)/) { + die "Wrong test?" unless $test eq $1; + if ($traces) { $traces = "$traces traces"; } + else { $traces = "no traces"; } + write; + } + elsif (/(Segmentation Fault|Bus Error|Assertion failed|Terminated|Killed)/i) { + $extra = "$1"; + } + } + + exit(0); From lattner at cs.uiuc.edu Wed Jul 21 16:28:36 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 21 Jul 2004 16:28:36 -0500 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/InstSelectSimple.cpp Message-ID: <200407212128.QAA30668@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: InstSelectSimple.cpp updated: 1.274 -> 1.275 --- Log message: Fix cases where we generated horrible code like this: mov %EDI, 12 add %EDI, %ECX mov %ECX, 12 add %ECX, %EDX mov %EDX, 12 add %EDX, %ESI instead (really!) generate this: add %ECX, 12 add %EDX, 12 add %ESI, 12 --- Diffs of the changes: (+7 -1) Index: llvm/lib/Target/X86/InstSelectSimple.cpp diff -u llvm/lib/Target/X86/InstSelectSimple.cpp:1.274 llvm/lib/Target/X86/InstSelectSimple.cpp:1.275 --- llvm/lib/Target/X86/InstSelectSimple.cpp:1.274 Mon Jul 19 18:50:57 2004 +++ llvm/lib/Target/X86/InstSelectSimple.cpp Wed Jul 21 16:28:26 2004 @@ -2967,8 +2967,9 @@ // Okay, we found a user. If the load is the first operand and there is // no second operand load, reverse the operand ordering. Note that this // can fail for a subtract (ie, no change will be made). + bool Swapped = false; if (!isa(User->getOperand(1))) - cast(User)->swapOperands(); + Swapped = !cast(User)->swapOperands(); // Okay, now that everything is set up, if this load is used by the second // operand, and if there are no instructions that invalidate the load @@ -2985,6 +2986,11 @@ User->getOpcode() == Instruction::Div) && isSafeToFoldLoadIntoInstruction(I, *User)) return; // Eliminate the load! + + // If we swapped the operands to the instruction, but couldn't fold the + // load anyway, swap them back. We don't want to break add X, int + // folding. + if (Swapped) cast(User)->swapOperands(); } } From lattner at cs.uiuc.edu Wed Jul 21 18:18:08 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 21 Jul 2004 18:18:08 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/TwoAddressInstructionPass.cpp Message-ID: <200407212318.SAA31385@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: TwoAddressInstructionPass.cpp updated: 1.22 -> 1.23 --- Log message: Minor cleanups --- Diffs of the changes: (+6 -8) Index: llvm/lib/CodeGen/TwoAddressInstructionPass.cpp diff -u llvm/lib/CodeGen/TwoAddressInstructionPass.cpp:1.22 llvm/lib/CodeGen/TwoAddressInstructionPass.cpp:1.23 --- llvm/lib/CodeGen/TwoAddressInstructionPass.cpp:1.22 Wed Jul 21 15:50:33 2004 +++ llvm/lib/CodeGen/TwoAddressInstructionPass.cpp Wed Jul 21 18:17:57 2004 @@ -28,8 +28,8 @@ //===----------------------------------------------------------------------===// #define DEBUG_TYPE "twoaddrinstr" -#include "llvm/Function.h" #include "llvm/CodeGen/Passes.h" +#include "llvm/Function.h" #include "llvm/CodeGen/LiveVariables.h" #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/MachineInstr.h" @@ -105,13 +105,8 @@ "two address instruction invalid"); // if the two operands are the same we just remove the use - // and mark the def as def&use - if (mi->getOperand(0).getReg() == - mi->getOperand(1).getReg()) { - } - else { - MadeChange = true; - + // and mark the def as def&use, otherwise we have to insert a copy. + if (mi->getOperand(0).getReg() != mi->getOperand(1).getReg()) { // rewrite: // a = b op c // to: @@ -128,9 +123,11 @@ // instruction (a = b + a for example) because our // transformation will not work. This should never occur // because we are in SSA form. +#ifndef NDEBUG for (unsigned i = 1; i != mi->getNumOperands(); ++i) assert(!mi->getOperand(i).isRegister() || mi->getOperand(i).getReg() != regA); +#endif const TargetRegisterClass* rc = MF.getSSARegMap()->getRegClass(regA); @@ -167,6 +164,7 @@ assert(mi->getOperand(0).isDef()); mi->getOperand(0).setUse(); mi->RemoveOperand(1); + MadeChange = true; DEBUG(std::cerr << "\t\trewrite to:\t"; mi->print(std::cerr, &TM)); From lattner at cs.uiuc.edu Wed Jul 21 19:04:24 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 21 Jul 2004 19:04:24 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervals.cpp Message-ID: <200407220004.TAA00734@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveIntervals.cpp updated: 1.99 -> 1.100 --- Log message: That funny 2-address lowering pass can also cause multiple definitions, fortunately, they are easy to handle if we know about them. This patch fixes some serious pessimization of code produced by the linscan register allocator. --- Diffs of the changes: (+18 -8) Index: llvm/lib/CodeGen/LiveIntervals.cpp diff -u llvm/lib/CodeGen/LiveIntervals.cpp:1.99 llvm/lib/CodeGen/LiveIntervals.cpp:1.100 --- llvm/lib/CodeGen/LiveIntervals.cpp:1.99 Wed Jul 21 15:50:33 2004 +++ llvm/lib/CodeGen/LiveIntervals.cpp Wed Jul 21 19:04:14 2004 @@ -291,10 +291,10 @@ LiveVariables::VarInfo& vi = lv_->getVarInfo(interval.reg); // Virtual registers may be defined multiple times (due to phi - // elimination). Much of what we do only has to be done once for the vreg. - // We use an empty interval to detect the first time we see a vreg. + // elimination and 2-addr elimination). Much of what we do only has to be + // done once for the vreg. We use an empty interval to detect the first + // time we see a vreg. if (interval.empty()) { - // Get the Idx of the defining instructions. unsigned defIndex = getDefIndex(getInstructionIndex(mi)); @@ -351,11 +351,21 @@ } else { // If this is the second time we see a virtual register definition, it - // must be due to phi elimination. In this case, the defined value will - // be live until the end of the basic block it is defined in. - unsigned defIndex = getDefIndex(getInstructionIndex(mi)); - interval.addRange(defIndex, - getInstructionIndex(&mbb->back()) + InstrSlots::NUM); + // must be due to phi elimination or two addr elimination. If this is + // the result of two address elimination, then the vreg is the first + // operand, and is a def-and-use. + if (mi->getOperand(0).isRegister() && + mi->getOperand(0).getReg() == interval.reg && + mi->getOperand(0).isDef() && mi->getOperand(0).isUse()) { + // If this is a two-address definition, just ignore it. + } else { + // Otherwise, this must be because of phi elimination. In this case, + // the defined value will be live until the end of the basic block it + // is defined in. + unsigned defIndex = getDefIndex(getInstructionIndex(mi)); + interval.addRange(defIndex, + getInstructionIndex(&mbb->back()) + InstrSlots::NUM); + } } DEBUG(std::cerr << '\n'); From alkis at cs.uiuc.edu Wed Jul 21 21:17:04 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Wed, 21 Jul 2004 21:17:04 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/RegAllocIterativeScan.cpp Message-ID: <200407220217.VAA10878@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: RegAllocIterativeScan.cpp updated: 1.6 -> 1.7 --- Log message: Use reverse iterators when updating the vector, since scanning from the end will reduce erase() runtimes. --- Diffs of the changes: (+14 -11) Index: llvm/lib/CodeGen/RegAllocIterativeScan.cpp diff -u llvm/lib/CodeGen/RegAllocIterativeScan.cpp:1.6 llvm/lib/CodeGen/RegAllocIterativeScan.cpp:1.7 --- llvm/lib/CodeGen/RegAllocIterativeScan.cpp:1.6 Wed Jul 21 15:50:33 2004 +++ llvm/lib/CodeGen/RegAllocIterativeScan.cpp Wed Jul 21 21:16:53 2004 @@ -230,20 +230,21 @@ } // expire any remaining active intervals - for (IntervalPtrs::iterator i = active_.begin(); i != active_.end(); ) { + for (IntervalPtrs::reverse_iterator + i = active_.rbegin(); i != active_.rend(); ) { unsigned reg = (*i)->reg; DEBUG(std::cerr << "\tinterval " << **i << " expired\n"); if (MRegisterInfo::isVirtualRegister(reg)) reg = vrm_->getPhys(reg); prt_->delRegUse(reg); - i = active_.erase(i); + i = IntervalPtrs::reverse_iterator(active_.erase(i.base()-1)); } // expire any remaining inactive intervals - for (IntervalPtrs::iterator - i = inactive_.begin(); i != inactive_.end(); ) { + for (IntervalPtrs::reverse_iterator + i = inactive_.rbegin(); i != inactive_.rend(); ) { DEBUG(std::cerr << "\tinterval " << **i << " expired\n"); - i = inactive_.erase(i); + i = IntervalPtrs::reverse_iterator(inactive_.erase(i.base()-1)); } // return true if we spilled anything @@ -267,7 +268,8 @@ void RA::processActiveIntervals(IntervalPtrs::value_type cur) { DEBUG(std::cerr << "\tprocessing active intervals:\n"); - for (IntervalPtrs::iterator i = active_.begin(); i != active_.end();) { + for (IntervalPtrs::reverse_iterator + i = active_.rbegin(); i != active_.rend();) { unsigned reg = (*i)->reg; // remove expired intervals if ((*i)->expiredAt(cur->start())) { @@ -276,7 +278,7 @@ reg = vrm_->getPhys(reg); prt_->delRegUse(reg); // remove from active - i = active_.erase(i); + i = IntervalPtrs::reverse_iterator(active_.erase(i.base()-1)); } // move inactive intervals to inactive list else if (!(*i)->liveAt(cur->start())) { @@ -287,7 +289,7 @@ // add to inactive inactive_.push_back(*i); // remove from active - i = active_.erase(i); + i = IntervalPtrs::reverse_iterator(active_.erase(i.base()-1)); } else { ++i; @@ -298,14 +300,15 @@ void RA::processInactiveIntervals(IntervalPtrs::value_type cur) { DEBUG(std::cerr << "\tprocessing inactive intervals:\n"); - for (IntervalPtrs::iterator i = inactive_.begin(); i != inactive_.end();) { + for (IntervalPtrs::reverse_iterator + i = inactive_.rbegin(); i != inactive_.rend();) { unsigned reg = (*i)->reg; // remove expired intervals if ((*i)->expiredAt(cur->start())) { DEBUG(std::cerr << "\t\tinterval " << **i << " expired\n"); // remove from inactive - i = inactive_.erase(i); + i = IntervalPtrs::reverse_iterator(inactive_.erase(i.base()-1)); } // move re-activated intervals in active list else if ((*i)->liveAt(cur->start())) { @@ -316,7 +319,7 @@ // add to active active_.push_back(*i); // remove from inactive - i = inactive_.erase(i); + i = IntervalPtrs::reverse_iterator(inactive_.erase(i.base()-1)); } else { ++i; From lattner at cs.uiuc.edu Thu Jul 22 00:48:48 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu, 22 Jul 2004 00:48:48 -0500 Subject: [llvm-commits] CVS: llvm/test/Regression/CodeGen/Generic/GC/alloc_loop.ll Message-ID: <200407220548.AAA05737@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/CodeGen/Generic/GC: alloc_loop.ll updated: 1.2 -> 1.3 --- Log message: Update gc intrinsics to take pointer to object as well as pointer to field. Patch contributed by Tobias Nurmiranta --- Diffs of the changes: (+2 -2) Index: llvm/test/Regression/CodeGen/Generic/GC/alloc_loop.ll diff -u llvm/test/Regression/CodeGen/Generic/GC/alloc_loop.ll:1.2 llvm/test/Regression/CodeGen/Generic/GC/alloc_loop.ll:1.3 --- llvm/test/Regression/CodeGen/Generic/GC/alloc_loop.ll:1.2 Thu May 27 00:51:00 2004 +++ llvm/test/Regression/CodeGen/Generic/GC/alloc_loop.ll Thu Jul 22 00:48:38 2004 @@ -4,7 +4,7 @@ declare void %llvm_gc_initialize(uint) declare void %llvm.gcroot(sbyte**, sbyte*) -declare void %llvm.gcwrite(sbyte*, sbyte**) +declare void %llvm.gcwrite(sbyte*, sbyte*, sbyte**) int %main() { entry: @@ -32,7 +32,7 @@ ;; *B = A; %B.1 = load sbyte*** %B %A.1 = load sbyte** %A - call void %llvm.gcwrite(sbyte* %A.1, sbyte** %B.1) + call void %llvm.gcwrite(sbyte* %A.1, sbyte* %B, sbyte** %B.1) br label %AllocLoop From lattner at cs.uiuc.edu Thu Jul 22 00:49:48 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu, 22 Jul 2004 00:49:48 -0500 Subject: [llvm-commits] CVS: llvm/docs/GarbageCollection.html Message-ID: <200407220549.AAA05757@apoc.cs.uiuc.edu> Changes in directory llvm/docs: GarbageCollection.html updated: 1.6 -> 1.7 --- Log message: Update documentation for gc intrinsics change. Contributed by Tobias Nurmiranta --- Diffs of the changes: (+9 -8) Index: llvm/docs/GarbageCollection.html diff -u llvm/docs/GarbageCollection.html:1.6 llvm/docs/GarbageCollection.html:1.7 --- llvm/docs/GarbageCollection.html:1.6 Fri Jul 9 00:03:54 2004 +++ llvm/docs/GarbageCollection.html Thu Jul 22 00:49:38 2004 @@ -234,8 +234,8 @@
    - sbyte *%llvm.gcread(sbyte **)
    - void %llvm.gcwrite(sbyte*, sbyte**) + sbyte *%llvm.gcread(sbyte *, sbyte **)
    + void %llvm.gcwrite(sbyte*, sbyte*, sbyte**)

    Several of the more interesting garbage collectors (e.g., generational @@ -250,7 +250,9 @@

    To support garbage collectors that use read or write barriers, LLVM provides the llvm.gcread and llvm.gcwrite intrinsics. The first intrinsic has exactly the same semantics as a non-volatile LLVM load and the -second has the same semantics as a non-volatile LLVM store. At code generation +second has the same semantics as a non-volatile LLVM store, with the +additions that they also take a pointer to the start of the memory +object as an argument. At code generation time, these intrinsics are replaced with calls into the garbage collector (llvm_gc_read and llvm_gc_write respectively), which are then @@ -341,8 +343,8 @@

    - void *llvm_gc_read(void **)
    - void llvm_gc_write(void*, void**) + void *llvm_gc_read(void*, void **)
    + void llvm_gc_write(void*, void *, void**)

    @@ -353,8 +355,7 @@

    If an actual read or write barrier is needed, it should be straight-forward to -implement it. Note that we may add a pointer to the start of the memory object -as a parameter in the future, if needed. +implement it.

    @@ -525,7 +526,7 @@ Chris Lattner
    LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/07/09 05:03:54 $ + Last modified: $Date: 2004/07/22 05:49:38 $ From lattner at cs.uiuc.edu Thu Jul 22 00:50:11 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu, 22 Jul 2004 00:50:11 -0500 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Verifier.cpp Message-ID: <200407220550.AAA05772@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Verifier.cpp updated: 1.115 -> 1.116 --- Log message: Updates to gc intrinsics, contributed by Tobias Nurmiranta --- Diffs of the changes: (+2 -2) Index: llvm/lib/VMCore/Verifier.cpp diff -u llvm/lib/VMCore/Verifier.cpp:1.115 llvm/lib/VMCore/Verifier.cpp:1.116 --- llvm/lib/VMCore/Verifier.cpp:1.115 Sat Jul 17 19:02:41 2004 +++ llvm/lib/VMCore/Verifier.cpp Thu Jul 22 00:50:01 2004 @@ -711,8 +711,8 @@ "Second argument to llvm.gcroot must be a constant!", &CI); NumArgs = 2; break; - case Intrinsic::gcread: NumArgs = 1; break; - case Intrinsic::gcwrite: NumArgs = 2; break; + case Intrinsic::gcread: NumArgs = 2; break; + case Intrinsic::gcwrite: NumArgs = 3; break; case Intrinsic::dbg_stoppoint: NumArgs = 4; break; case Intrinsic::dbg_region_start:NumArgs = 1; break; From lattner at cs.uiuc.edu Thu Jul 22 00:50:51 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu, 22 Jul 2004 00:50:51 -0500 Subject: [llvm-commits] CVS: llvm/runtime/GC/GCInterface.h Message-ID: <200407220550.AAA05786@apoc.cs.uiuc.edu> Changes in directory llvm/runtime/GC: GCInterface.h updated: 1.2 -> 1.3 --- Log message: Update GC intrinsics to take a pointer to the object as well as a pointer to the field being updated. Patch contributed by Tobias Nurmiranta --- Diffs of the changes: (+2 -2) Index: llvm/runtime/GC/GCInterface.h diff -u llvm/runtime/GC/GCInterface.h:1.2 llvm/runtime/GC/GCInterface.h:1.3 --- llvm/runtime/GC/GCInterface.h:1.2 Thu May 27 00:51:13 2004 +++ llvm/runtime/GC/GCInterface.h Thu Jul 22 00:50:41 2004 @@ -38,11 +38,11 @@ /* llvm_gc_read - This function should be implemented to include any read * barrier code that is needed by the garbage collector. */ -void *llvm_gc_read(void **P); +void *llvm_gc_read(void *ObjPtr, void **FieldPtr); /* llvm_gc_write - This function should be implemented to include any write * barrier code that is needed by the garbage collector. */ -void llvm_gc_write(void *V, void **P); +void llvm_gc_write(void *V, void *ObjPtr, void **FieldPtr); #endif From lattner at cs.uiuc.edu Thu Jul 22 00:50:58 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu, 22 Jul 2004 00:50:58 -0500 Subject: [llvm-commits] CVS: llvm/runtime/GC/SemiSpace/semispace.c Message-ID: <200407220550.AAA05794@apoc.cs.uiuc.edu> Changes in directory llvm/runtime/GC/SemiSpace: semispace.c updated: 1.4 -> 1.5 --- Log message: Update GC intrinsics to take a pointer to the object as well as a pointer to the field being updated. Patch contributed by Tobias Nurmiranta --- Diffs of the changes: (+2 -2) Index: llvm/runtime/GC/SemiSpace/semispace.c diff -u llvm/runtime/GC/SemiSpace/semispace.c:1.4 llvm/runtime/GC/SemiSpace/semispace.c:1.5 --- llvm/runtime/GC/SemiSpace/semispace.c:1.4 Fri Jul 16 16:40:32 2004 +++ llvm/runtime/GC/SemiSpace/semispace.c Thu Jul 22 00:50:48 2004 @@ -89,8 +89,8 @@ } /* We use no read/write barriers */ -void *llvm_gc_read(void **P) { return *P; } -void llvm_gc_write(void *V, void **P) { *P = V; } +void *llvm_gc_read(void *ObjPtr, void **FieldPtr) { return *FieldPtr; } +void llvm_gc_write(void *V, void *ObjPtr, void **FieldPtr) { *FieldPtr = V; } /*===----------------------------------------------------------------------===** From lattner at cs.uiuc.edu Thu Jul 22 00:51:23 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu, 22 Jul 2004 00:51:23 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/LowerGC.cpp Message-ID: <200407220551.AAA05809@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: LowerGC.cpp updated: 1.4 -> 1.5 --- Log message: Update GC intrinsics to take a pointer to the object as well as a pointer to the field being updated. Patch contributed by Tobias Nurmiranta --- Diffs of the changes: (+8 -5) Index: llvm/lib/Transforms/Scalar/LowerGC.cpp diff -u llvm/lib/Transforms/Scalar/LowerGC.cpp:1.4 llvm/lib/Transforms/Scalar/LowerGC.cpp:1.5 --- llvm/lib/Transforms/Scalar/LowerGC.cpp:1.4 Sun Jul 18 03:34:19 2004 +++ llvm/lib/Transforms/Scalar/LowerGC.cpp Thu Jul 22 00:51:13 2004 @@ -109,10 +109,10 @@ // If the program is using read/write barriers, find the implementations of // them from the GC runtime library. if (GCReadInt) // Make: sbyte* %llvm_gc_read(sbyte**) - GCRead = M.getOrInsertFunction("llvm_gc_read", VoidPtr, VoidPtrPtr, 0); + GCRead = M.getOrInsertFunction("llvm_gc_read", VoidPtr, VoidPtr, VoidPtrPtr, 0); if (GCWriteInt) // Make: void %llvm_gc_write(sbyte*, sbyte**) GCWrite = M.getOrInsertFunction("llvm_gc_write", Type::VoidTy, - VoidPtr, VoidPtrPtr, 0); + VoidPtr, VoidPtr, VoidPtrPtr, 0); // If the program has GC roots, get or create the global root list. if (GCRootInt) { @@ -182,14 +182,17 @@ CI->setOperand(0, GCWrite); // Insert casts of the operands as needed. Coerce(CI, 1, VoidPtr); - Coerce(CI, 2, VoidPtrPtr); + Coerce(CI, 2, VoidPtr); + Coerce(CI, 3, VoidPtrPtr); } else { - Coerce(CI, 1, VoidPtrPtr); + Coerce(CI, 1, VoidPtr); + Coerce(CI, 2, VoidPtrPtr); if (CI->getType() == VoidPtr) { CI->setOperand(0, GCRead); } else { // Create a whole new call to replace the old one. - CallInst *NC = new CallInst(GCRead, CI->getOperand(1), + CallInst *NC = new CallInst(GCRead, CI->getOperand(1), + CI->getOperand(2), CI->getName(), CI); Value *NV = new CastInst(NC, CI->getType(), "", CI); CI->replaceAllUsesWith(NV); From lattner at cs.uiuc.edu Thu Jul 22 00:52:06 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu, 22 Jul 2004 00:52:06 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/TwoAddressInstructionPass.cpp Message-ID: <200407220552.AAA05824@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: TwoAddressInstructionPass.cpp updated: 1.23 -> 1.24 --- Log message: Remove extraneous punctuation --- Diffs of the changes: (+2 -2) Index: llvm/lib/CodeGen/TwoAddressInstructionPass.cpp diff -u llvm/lib/CodeGen/TwoAddressInstructionPass.cpp:1.23 llvm/lib/CodeGen/TwoAddressInstructionPass.cpp:1.24 --- llvm/lib/CodeGen/TwoAddressInstructionPass.cpp:1.23 Wed Jul 21 18:17:57 2004 +++ llvm/lib/CodeGen/TwoAddressInstructionPass.cpp Thu Jul 22 00:51:56 2004 @@ -146,10 +146,10 @@ varInfo.DefInst = prevMi; // update live variables for regB - if (LV->removeVirtualRegisterKilled(regB, &*mbbi, mi)) + if (LV->removeVirtualRegisterKilled(regB, mbbi, mi)) LV->addVirtualRegisterKilled(regB, prevMi); - if (LV->removeVirtualRegisterDead(regB, &*mbbi, mi)) + if (LV->removeVirtualRegisterDead(regB, mbbi, mi)) LV->addVirtualRegisterDead(regB, prevMi); } From lattner at cs.uiuc.edu Thu Jul 22 02:58:24 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu, 22 Jul 2004 02:58:24 -0500 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/AliasSetTracker.h Message-ID: <200407220758.CAA12996@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis: AliasSetTracker.h updated: 1.15 -> 1.16 --- Log message: Clean up reference counting to stop "leaking" alias sets --- Diffs of the changes: (+14 -14) Index: llvm/include/llvm/Analysis/AliasSetTracker.h diff -u llvm/include/llvm/Analysis/AliasSetTracker.h:1.15 llvm/include/llvm/Analysis/AliasSetTracker.h:1.16 --- llvm/include/llvm/Analysis/AliasSetTracker.h:1.15 Wed Jul 21 02:03:57 2004 +++ llvm/include/llvm/Analysis/AliasSetTracker.h Thu Jul 22 02:58:14 2004 @@ -62,9 +62,8 @@ if (AS->Forward) { AliasSet *OldAS = AS; AS = OldAS->getForwardedTarget(AST); - if (--OldAS->RefCount == 0) - OldAS->removeFromTracker(AST); - AS->RefCount++; + AS->addRef(); + OldAS->dropRef(AST); } return AS; } @@ -118,6 +117,13 @@ void setPrev(AliasSet *P) { Prev = P; } void setNext(AliasSet *N) { Next = N; } + void addRef() { ++RefCount; } + void dropRef(AliasSetTracker &AST) { + assert(RefCount >= 1 && "Invalid reference count detected!"); + if (--RefCount == 0) + removeFromTracker(AST); + } + public: /// Accessors... bool isRef() const { return AccessTy & Refs; } @@ -187,15 +193,10 @@ AliasSet() : PtrList(0), PtrListEnd(&PtrList), Forward(0), RefCount(0), AccessTy(NoModRef), AliasTy(MustAlias), Volatile(false) { } + AliasSet(const AliasSet &AS) { - // AliasSet's only get copy constructed in simple circumstances. In - // particular, they cannot have any pointers in their list. Despite this, - // we have to be sure to update the PtrListEnd to not point to the source - // AliasSet's list. - assert(AS.PtrList == 0 && "AliasSet has pointers in it!"); - PtrList = 0; PtrListEnd = &PtrList; - Forward = AS.Forward; RefCount = AS.RefCount; - AccessTy = AS.AccessTy; AliasTy = AS.AliasTy; Volatile = AS.Volatile; + assert(0 && "Copy ctor called!?!?!"); + abort(); } HashNodePair *getSomePointer() const { @@ -210,9 +211,8 @@ AliasSet *Dest = Forward->getForwardedTarget(AST); if (Dest != Forward) { - Dest->RefCount++; - if (--Forward->RefCount == 0) - Forward->removeFromTracker(AST); + Dest->addRef(); + Forward->dropRef(AST); Forward = Dest; } return Dest; From lattner at cs.uiuc.edu Thu Jul 22 02:58:28 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu, 22 Jul 2004 02:58:28 -0500 Subject: [llvm-commits] CVS: llvm/lib/Analysis/AliasSetTracker.cpp Message-ID: <200407220758.CAA13003@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: AliasSetTracker.cpp updated: 1.19 -> 1.20 --- Log message: Clean up reference counting to stop "leaking" alias sets --- Diffs of the changes: (+13 -11) Index: llvm/lib/Analysis/AliasSetTracker.cpp diff -u llvm/lib/Analysis/AliasSetTracker.cpp:1.19 llvm/lib/Analysis/AliasSetTracker.cpp:1.20 --- llvm/lib/Analysis/AliasSetTracker.cpp:1.19 Wed Jul 21 02:04:26 2004 +++ llvm/lib/Analysis/AliasSetTracker.cpp Thu Jul 22 02:58:18 2004 @@ -45,7 +45,7 @@ assert(RefCount != 0); AS.Forward = this; // Forward across AS now... - RefCount++; // AS is now pointing to us... + addRef(); // AS is now pointing to us... // Merge the list of constituent pointers... if (AS.PtrList) { @@ -59,6 +59,10 @@ } void AliasSetTracker::removeAliasSet(AliasSet *AS) { + if (AliasSet *Fwd = AS->Forward) { + Fwd->dropRef(*this); + AS->Forward = 0; + } AliasSets.erase(AS); } @@ -91,7 +95,7 @@ assert(*PtrListEnd == 0 && "End of list is not null?"); *PtrListEnd = &Entry; PtrListEnd = Entry.second.setPrevInList(PtrListEnd); - RefCount++; // Entry points to alias set... + addRef(); // Entry points to alias set... } void AliasSet::addCallSite(CallSite CS, AliasAnalysis &AA) { @@ -130,7 +134,7 @@ // If this is a may-alias set, we have to check all of the pointers in the set // to be sure it doesn't alias the set... for (iterator I = begin(), E = end(); I != E; ++I) - if (AA.alias(Ptr, Size, I->first, I->second.getSize())) + if (AA.alias(Ptr, Size, I.getPointer(), I.getSize())) return true; // Check the call sites list and invoke list... @@ -204,7 +208,7 @@ } else { if (New) *New = true; // Otherwise create a new alias set to hold the loaded pointer... - AliasSets.push_back(AliasSet()); + AliasSets.push_back(new AliasSet()); AliasSets.back().addPointer(*this, Entry, Size); return AliasSets.back(); } @@ -238,7 +242,7 @@ AliasSet *AS = findAliasSetForCallSite(CS); if (!AS) { - AliasSets.push_back(AliasSet()); + AliasSets.push_back(new AliasSet()); AS = &AliasSets.back(); AS->addCallSite(CS, AA); return true; @@ -285,7 +289,7 @@ AliasSet::iterator I = AS.begin(), E = AS.end(); bool X; for (; I != E; ++I) - addPointer(I->first, I->second.getSize(), + addPointer(I.getPointer(), I.getSize(), (AliasSet::AccessType)AS.AccessTy, X); } } @@ -364,9 +368,7 @@ // Unlink from the list of values... PtrValEnt.second.removeFromList(); // Stop using the alias set - if (--AS->RefCount == 0) - AS->removeFromTracker(*this); - + AS->dropRef(*this); PointerMap.erase(I); } @@ -394,8 +396,8 @@ OS << "Pointers: "; for (iterator I = begin(), E = end(); I != E; ++I) { if (I != begin()) OS << ", "; - WriteAsOperand(OS << "(", I->first); - OS << ", " << I->second.getSize() << ")"; + WriteAsOperand(OS << "(", I.getPointer()); + OS << ", " << I.getSize() << ")"; } } if (!CallSites.empty()) { From lattner at cs.uiuc.edu Thu Jul 22 02:59:10 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu, 22 Jul 2004 02:59:10 -0500 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/DeadStoreElimination/ Message-ID: <200407220759.CAA13057@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/DeadStoreElimination: --- Log message: Directory /home/vadve/shared/PublicCVS/llvm/test/Regression/Transforms/DeadStoreElimination added to the repository --- Diffs of the changes: (+0 -0) From lattner at cs.uiuc.edu Thu Jul 22 02:59:30 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu, 22 Jul 2004 02:59:30 -0500 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/DeadStoreElimination/simple.llx Message-ID: <200407220759.CAA13071@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/DeadStoreElimination: simple.llx added (r1.1) --- Log message: Trivial testcase for dse --- Diffs of the changes: (+8 -0) Index: llvm/test/Regression/Transforms/DeadStoreElimination/simple.llx diff -c /dev/null llvm/test/Regression/Transforms/DeadStoreElimination/simple.llx:1.1 *** /dev/null Thu Jul 22 02:59:30 2004 --- llvm/test/Regression/Transforms/DeadStoreElimination/simple.llx Thu Jul 22 02:59:20 2004 *************** *** 0 **** --- 1,8 ---- + ; RUN: llvm-as < %s | opt -dse | llvm-dis | not grep DEAD + + void %test(int* %Q, int* %P) { + %DEAD = load int* %Q + store int %DEAD, int* %P + store int 0, int* %P + ret void + } From lattner at cs.uiuc.edu Thu Jul 22 03:00:38 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu, 22 Jul 2004 03:00:38 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp Message-ID: <200407220800.DAA13099@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: DeadStoreElimination.cpp added (r1.1) --- Log message: This is a trivial dead store elimination pass. It very very simple and can be improved in many ways. But: stop laughing, even with -basicaa it deletes 15% of the stores in 252.eon :) --- Diffs of the changes: (+139 -0) Index: llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp diff -c /dev/null llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp:1.1 *** /dev/null Thu Jul 22 03:00:38 2004 --- llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp Thu Jul 22 03:00:28 2004 *************** *** 0 **** --- 1,139 ---- + //===- DeadStoreElimination.cpp - Dead Store Elimination ------------------===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by the LLVM research group and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // This file implements a trivial dead store elimination that only considers + // basic-block local redundant stores. + // + // FIXME: This should eventually be extended to be a post-dominator tree + // traversal. Doing so would be pretty trivial. + // + //===----------------------------------------------------------------------===// + + #include "llvm/Transforms/Scalar.h" + #include "llvm/Function.h" + #include "llvm/Instructions.h" + #include "llvm/Analysis/AliasAnalysis.h" + #include "llvm/Analysis/AliasSetTracker.h" + #include "llvm/Target/TargetData.h" + #include "llvm/Transforms/Utils/Local.h" + #include "Support/Statistic.h" + using namespace llvm; + + namespace { + Statistic<> NumStores("dse", "Number of stores deleted"); + Statistic<> NumOther ("dse", "Number of other instrs removed"); + + struct DSE : public FunctionPass { + + virtual bool runOnFunction(Function &F) { + bool Changed = false; + for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I) + Changed |= runOnBasicBlock(*I); + return Changed; + } + + bool runOnBasicBlock(BasicBlock &BB); + + void DeleteDeadValueChains(Value *V, AliasSetTracker &AST); + + // getAnalysisUsage - We require post dominance frontiers (aka Control + // Dependence Graph) + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.addRequired(); + AU.addRequired(); + AU.addPreserved(); + } + }; + RegisterOpt X("dse", "Dead Store Elimination"); + } + + Pass *llvm::createDeadStoreEliminationPass() { return new DSE(); } + + bool DSE::runOnBasicBlock(BasicBlock &BB) { + TargetData &TD = getAnalysis(); + AliasAnalysis &AA = getAnalysis(); + AliasSetTracker KillLocs(AA); + + // If this block ends in a return, unwind, and eventually tailcall/barrier, + // then all allocas are dead at its end. + if (BB.getTerminator()->getNumSuccessors() == 0) { + + } + + bool MadeChange = false; + for (BasicBlock::iterator BBI = BB.end(); BBI != BB.begin(); ) { + Instruction *I = --BBI; // Keep moving iterator backwards + + #if 0 + // AST doesn't support malloc/free/alloca??? + if (isa(I)) { + // Free instructions make any stores to the free'd location dead. + KillLocs.insert(I); + } + #endif + + if (!isa(I) || cast(I)->isVolatile()) { + // If this is a non-store instruction, it makes everything referenced no + // longer killed. Remove anything aliased from the alias set tracker. + KillLocs.remove(I); + continue; + } + + // If this is a non-volatile store instruction, and if it is already in + // the stored location is already in the tracker, then this is a dead + // store. We can just delete it here, but while we're at it, we also + // delete any trivially dead expression chains. + unsigned ValSize = TD.getTypeSize(I->getOperand(0)->getType()); + Value *Ptr = I->getOperand(1); + if (AliasSet *AS = KillLocs.getAliasSetForPointerIfExists(Ptr, ValSize)) + for (AliasSet::iterator ASI = AS->begin(), E = AS->end(); ASI != E; ++ASI) + if (AA.alias(ASI.getPointer(), ASI.getSize(), Ptr, ValSize) + == AliasAnalysis::MustAlias) { + // If we found a must alias in the killed set, then this store really + // is dead. Delete it now. + ++BBI; // Don't invalidate iterator. + Value *Val = I->getOperand(0); + BB.getInstList().erase(I); // Nuke the store! + ++NumStores; + DeleteDeadValueChains(Val, KillLocs); // Delete any now-dead instrs + DeleteDeadValueChains(Ptr, KillLocs); // Delete any now-dead instrs + MadeChange = true; + goto BigContinue; + } + + // Otherwise, this is a non-dead store just add it to the set of dead + // locations. + KillLocs.add(cast(I)); + BigContinue:; + } + return MadeChange; + } + + void DSE::DeleteDeadValueChains(Value *V, AliasSetTracker &AST) { + // Value must be dead. + if (!V->use_empty()) return; + + if (Instruction *I = dyn_cast(V)) + if (isInstructionTriviallyDead(I)) { + AST.deleteValue(I); + getAnalysis().deleteValue(I); + + // See if this made any operands dead. We do it this way in case the + // instruction uses the same operand twice. We don't want to delete a + // value then reference it. + while (unsigned NumOps = I->getNumOperands()) { + Value *Op = I->getOperand(NumOps-1); + I->op_erase(I->op_end()-1); // Drop from the operand list. + DeleteDeadValueChains(Op, AST); // Attempt to nuke it. + } + + I->getParent()->getInstList().erase(I); + ++NumOther; + } + } From lattner at cs.uiuc.edu Thu Jul 22 03:07:40 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu, 22 Jul 2004 03:07:40 -0500 Subject: [llvm-commits] CVS: llvm/include/llvm/Transforms/Scalar.h Message-ID: <200407220807.DAA13218@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Transforms: Scalar.h updated: 1.41 -> 1.42 --- Log message: New prototype --- Diffs of the changes: (+6 -0) Index: llvm/include/llvm/Transforms/Scalar.h diff -u llvm/include/llvm/Transforms/Scalar.h:1.41 llvm/include/llvm/Transforms/Scalar.h:1.42 --- llvm/include/llvm/Transforms/Scalar.h:1.41 Fri Jun 25 02:41:06 2004 +++ llvm/include/llvm/Transforms/Scalar.h Thu Jul 22 03:07:30 2004 @@ -63,6 +63,12 @@ // Pass *createDeadCodeEliminationPass(); +//===----------------------------------------------------------------------===// +// +// DeadStoreElimination - This pass deletes stores that are post-dominated by +// must-aliased stores and are not loaded used between the stores. +// +Pass *createDeadStoreEliminationPass(); //===----------------------------------------------------------------------===// // From alkis at cs.uiuc.edu Thu Jul 22 03:14:54 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Thu, 22 Jul 2004 03:14:54 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/RegAllocLinearScan.cpp Message-ID: <200407220814.DAA13001@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: RegAllocLinearScan.cpp updated: 1.81 -> 1.82 --- Log message: Some compile time improvements resulting in a 1sec speedup in the 5sec compilation of gcc: * Use vectors instead of lists for the intervals sets * Use a heap for the unhandled set to keep intervals always sorted and makes insertions back to the heap very fast (compared to scanning a list) --- Diffs of the changes: (+53 -75) Index: llvm/lib/CodeGen/RegAllocLinearScan.cpp diff -u llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.81 llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.82 --- llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.81 Wed Jul 21 15:50:33 2004 +++ llvm/lib/CodeGen/RegAllocLinearScan.cpp Thu Jul 22 03:14:44 2004 @@ -29,6 +29,7 @@ #include #include #include +#include using namespace llvm; @@ -46,9 +47,12 @@ const TargetMachine* tm_; const MRegisterInfo* mri_; LiveIntervals* li_; - typedef std::list IntervalPtrs; - IntervalPtrs unhandled_, fixed_, active_, inactive_, handled_; - + typedef std::vector IntervalPtrs; + IntervalPtrs handled_, fixed_, active_, inactive_; + typedef std::priority_queue > IntervalHeap; + IntervalHeap unhandled_; std::auto_ptr prt_; std::auto_ptr vrm_; std::auto_ptr spiller_; @@ -82,11 +86,11 @@ /// processActiveIntervals - expire old intervals and move /// non-overlapping ones to the incative list - void processActiveIntervals(IntervalPtrs::value_type cur); + void processActiveIntervals(LiveInterval* cur); /// processInactiveIntervals - expire old intervals and move /// overlapping ones to the active list - void processInactiveIntervals(IntervalPtrs::value_type cur); + void processInactiveIntervals(LiveInterval* cur); /// updateSpillWeights - updates the spill weights of the /// specifed physical register and its weight @@ -94,7 +98,7 @@ /// assignRegOrStackSlotAtInterval - assign a register if one /// is available, or spill. - void assignRegOrStackSlotAtInterval(IntervalPtrs::value_type cur); + void assignRegOrStackSlotAtInterval(LiveInterval* cur); /// /// register handling helpers @@ -103,15 +107,14 @@ /// getFreePhysReg - return a free physical register for this /// virtual register interval if we have one, otherwise return /// 0 - unsigned getFreePhysReg(IntervalPtrs::value_type cur); + unsigned getFreePhysReg(LiveInterval* cur); /// assignVirt2StackSlot - assigns this virtual register to a /// stack slot. returns the stack slot int assignVirt2StackSlot(unsigned virtReg); - void printIntervals(const char* const str, - RA::IntervalPtrs::const_iterator i, - RA::IntervalPtrs::const_iterator e) const { + template + void printIntervals(const char* const str, ItTy i, ItTy e) const { if (str) std::cerr << str << " intervals:\n"; for (; i != e; ++i) { std::cerr << "\t" << **i << " -> "; @@ -127,7 +130,7 @@ void RA::releaseMemory() { - unhandled_.clear(); + while (!unhandled_.empty()) unhandled_.pop(); fixed_.clear(); active_.clear(); inactive_.clear(); @@ -159,15 +162,15 @@ DEBUG(std::cerr << "********** Function: " << mf_->getFunction()->getName() << '\n'); - DEBUG(printIntervals("unhandled", unhandled_.begin(), unhandled_.end())); + // DEBUG(printIntervals("unhandled", unhandled_.begin(), unhandled_.end())); DEBUG(printIntervals("fixed", fixed_.begin(), fixed_.end())); DEBUG(printIntervals("active", active_.begin(), active_.end())); DEBUG(printIntervals("inactive", inactive_.begin(), inactive_.end())); while (!unhandled_.empty()) { // pick the interval with the earliest start point - IntervalPtrs::value_type cur = unhandled_.front(); - unhandled_.pop_front(); + LiveInterval* cur = unhandled_.top(); + unhandled_.pop(); ++numIterations; DEBUG(std::cerr << "\n*** CURRENT ***: " << *cur << '\n'); @@ -189,18 +192,26 @@ DEBUG(printIntervals("active", active_.begin(), active_.end())); DEBUG(printIntervals("inactive", inactive_.begin(), inactive_.end())); - // DEBUG(verifyAssignment()); } numIntervals += li_->getIntervals().size(); efficiency = double(numIterations) / double(numIntervals); // expire any remaining active intervals - for (IntervalPtrs::iterator i = active_.begin(); i != active_.end(); ++i) { + for (IntervalPtrs::reverse_iterator + i = active_.rbegin(); i != active_.rend(); ) { unsigned reg = (*i)->reg; DEBUG(std::cerr << "\tinterval " << **i << " expired\n"); if (MRegisterInfo::isVirtualRegister(reg)) reg = vrm_->getPhys(reg); prt_->delRegUse(reg); + i = IntervalPtrs::reverse_iterator(active_.erase(i.base()-1)); + } + + // expire any remaining inactive intervals + for (IntervalPtrs::reverse_iterator + i = inactive_.rbegin(); i != inactive_.rend(); ) { + DEBUG(std::cerr << "\tinterval " << **i << " expired\n"); + i = IntervalPtrs::reverse_iterator(inactive_.erase(i.base()-1)); } DEBUG(std::cerr << *vrm_); @@ -214,7 +225,7 @@ for (LiveIntervals::Intervals::iterator i = li.begin(), e = li.end(); i != e; ++i) { - unhandled_.push_back(&*i); + unhandled_.push(&*i); if (MRegisterInfo::isPhysicalRegister(i->reg)) fixed_.push_back(&*i); } @@ -223,7 +234,8 @@ void RA::processActiveIntervals(IntervalPtrs::value_type cur) { DEBUG(std::cerr << "\tprocessing active intervals:\n"); - for (IntervalPtrs::iterator i = active_.begin(); i != active_.end();) { + for (IntervalPtrs::reverse_iterator + i = active_.rbegin(); i != active_.rend();) { unsigned reg = (*i)->reg; // remove expired intervals if ((*i)->expiredAt(cur->start())) { @@ -232,7 +244,7 @@ reg = vrm_->getPhys(reg); prt_->delRegUse(reg); // remove from active - i = active_.erase(i); + i = IntervalPtrs::reverse_iterator(active_.erase(i.base()-1)); } // move inactive intervals to inactive list else if (!(*i)->liveAt(cur->start())) { @@ -243,7 +255,7 @@ // add to inactive inactive_.push_back(*i); // remove from active - i = active_.erase(i); + i = IntervalPtrs::reverse_iterator(active_.erase(i.base()-1)); } else { ++i; @@ -254,14 +266,15 @@ void RA::processInactiveIntervals(IntervalPtrs::value_type cur) { DEBUG(std::cerr << "\tprocessing inactive intervals:\n"); - for (IntervalPtrs::iterator i = inactive_.begin(); i != inactive_.end();) { + for (IntervalPtrs::reverse_iterator + i = inactive_.rbegin(); i != inactive_.rend();) { unsigned reg = (*i)->reg; // remove expired intervals if ((*i)->expiredAt(cur->start())) { DEBUG(std::cerr << "\t\tinterval " << **i << " expired\n"); // remove from inactive - i = inactive_.erase(i); + i = IntervalPtrs::reverse_iterator(inactive_.erase(i.base()-1)); } // move re-activated intervals in active list else if ((*i)->liveAt(cur->start())) { @@ -272,7 +285,7 @@ // add to active active_.push_back(*i); // remove from inactive - i = inactive_.erase(i); + i = IntervalPtrs::reverse_iterator(inactive_.erase(i.base()-1)); } else { ++i; @@ -287,7 +300,7 @@ spillWeights_[*as] += weight; } -void RA::assignRegOrStackSlotAtInterval(IntervalPtrs::value_type cur) +void RA::assignRegOrStackSlotAtInterval(LiveInterval* cur) { DEBUG(std::cerr << "\tallocating current interval: "); @@ -370,47 +383,19 @@ li_->addIntervalsForSpills(*cur, *vrm_, slot); if (added.empty()) return; // Early exit if all spills were folded. -#ifndef NDEBUG - int OldStart = -1; -#endif // Merge added with unhandled. Note that we know that // addIntervalsForSpills returns intervals sorted by their starting // point. - std::vector::iterator addedIt = added.begin(); - std::vector::iterator addedItEnd = added.end(); - for (IntervalPtrs::iterator i = unhandled_.begin(), e =unhandled_.end(); - i != e && addedIt != addedItEnd; ++i) { - while (addedIt != addedItEnd && - (*i)->start() > (*addedIt)->start()) { -#ifndef NDEBUG - // This code only works if addIntervalsForSpills retursn a - // sorted interval list. Assert this is the case now. - assert(OldStart <= (int)(*addedIt)->start() && - "addIntervalsForSpills didn't return sorted interval list!"); - OldStart = (*addedIt)->start(); -#endif - i = unhandled_.insert(i, *(addedIt++)); - } - } - - while (addedIt != addedItEnd) { -#ifndef NDEBUG - // This code only works if addIntervalsForSpills retursn a - // sorted interval list. Assert this is the case now. - assert(OldStart <= (int)(*addedIt)->start() && - "addIntervalsForSpills didn't return sorted interval list!"); - OldStart = (*addedIt)->start(); -#endif - unhandled_.push_back(*(addedIt++)); - } + for (unsigned i = 0, e = added.size(); i != e; ++i) + unhandled_.push(added[i]); return; } // push the current interval back to unhandled since we are going // to re-run at least this iteration. Since we didn't modify it it // should go back right in the front of the list - unhandled_.push_front(cur); + unhandled_.push(cur); // otherwise we spill all intervals aliasing the register with // minimum weight, rollback to the interval with the earliest @@ -426,7 +411,8 @@ std::set spilled; - for (IntervalPtrs::iterator i = active_.begin(); i != active_.end(); ++i) { + for (IntervalPtrs::iterator + i = active_.begin(); i != active_.end(); ++i) { unsigned reg = (*i)->reg; if (MRegisterInfo::isVirtualRegister(reg) && toSpill[vrm_->getPhys(reg)] && @@ -440,8 +426,8 @@ spilled.insert(reg); } } - for (IntervalPtrs::iterator i = inactive_.begin(); - i != inactive_.end(); ++i) { + for (IntervalPtrs::iterator + i = inactive_.begin(); i != inactive_.end(); ++i) { unsigned reg = (*i)->reg; if (MRegisterInfo::isVirtualRegister(reg) && toSpill[vrm_->getPhys(reg)] && @@ -460,7 +446,7 @@ // scan handled in reverse order and undo each one, restoring the // state of unhandled while (!handled_.empty()) { - IntervalPtrs::value_type i = handled_.back(); + LiveInterval* i = handled_.back(); // if this interval starts before t we are done if (i->start() < earliestStart) break; @@ -471,11 +457,11 @@ active_.erase(it); if (MRegisterInfo::isPhysicalRegister(i->reg)) { prt_->delRegUse(i->reg); - unhandled_.push_front(i); + unhandled_.push(i); } else { if (!spilled.count(i->reg)) - unhandled_.push_front(i); + unhandled_.push(i); prt_->delRegUse(vrm_->getPhys(i->reg)); vrm_->clearVirt(i->reg); } @@ -483,17 +469,17 @@ else if ((it = find(inactive_.begin(), inactive_.end(), i)) != inactive_.end()) { inactive_.erase(it); if (MRegisterInfo::isPhysicalRegister(i->reg)) - unhandled_.push_front(i); + unhandled_.push(i); else { if (!spilled.count(i->reg)) - unhandled_.push_front(i); + unhandled_.push(i); vrm_->clearVirt(i->reg); } } else { if (MRegisterInfo::isVirtualRegister(i->reg)) vrm_->clearVirt(i->reg); - unhandled_.push_front(i); + unhandled_.push(i); } } @@ -514,19 +500,11 @@ std::sort(added.begin(), added.end(), less_ptr()); // merge added with unhandled - std::vector::iterator addedIt = added.begin(); - std::vector::iterator addedItEnd = added.end(); - for (IntervalPtrs::iterator i = unhandled_.begin(), e = unhandled_.end(); - i != e && addedIt != addedItEnd; ++i) { - if ((*i)->start() > (*addedIt)->start()) - i = unhandled_.insert(i, *(addedIt++)); - } - while (addedIt != addedItEnd) - unhandled_.push_back(*(addedIt++)); - + for (unsigned i = 0, e = added.size(); i != e; ++i) + unhandled_.push(added[i]); } -unsigned RA::getFreePhysReg(IntervalPtrs::value_type cur) +unsigned RA::getFreePhysReg(LiveInterval* cur) { const TargetRegisterClass* rc = mf_->getSSARegMap()->getRegClass(cur->reg); From lattner at cs.uiuc.edu Thu Jul 22 03:34:43 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu, 22 Jul 2004 03:34:43 -0500 Subject: [llvm-commits] CVS: llvm/tools/gccas/gccas.cpp Message-ID: <200407220834.DAA13876@apoc.cs.uiuc.edu> Changes in directory llvm/tools/gccas: gccas.cpp updated: 1.97 -> 1.98 --- Log message: Remove redundant SCCP pass Add new DSE pass. Add a temporary option to disable it in case we need it This is going in after the July 22 nightly tester run, so we'll wait until the 23rd to see it :) --- Diffs of the changes: (+5 -1) Index: llvm/tools/gccas/gccas.cpp diff -u llvm/tools/gccas/gccas.cpp:1.97 llvm/tools/gccas/gccas.cpp:1.98 --- llvm/tools/gccas/gccas.cpp:1.97 Thu May 27 00:40:58 2004 +++ llvm/tools/gccas/gccas.cpp Thu Jul 22 03:34:33 2004 @@ -46,6 +46,9 @@ cl::opt DisableOptimizations("disable-opt", cl::desc("Do not run any optimization passes")); + + cl::opt + DisableDSE("disable-dse", cl::desc("Do not run dead store elimination")); } @@ -99,11 +102,12 @@ addPass(PM, createLoadValueNumberingPass()); // GVN for load instructions addPass(PM, createGCSEPass()); // Remove common subexprs addPass(PM, createSCCPPass()); // Constant prop with SCCP - addPass(PM, createSCCPPass()); // Constant prop with SCCP // Run instcombine after redundancy elimination to exploit opportunities // opened up by them. addPass(PM, createInstructionCombiningPass()); + if (!DisableDSE) + addPass(PM, createDeadStoreEliminationPass()); // Delete dead stores addPass(PM, createAggressiveDCEPass()); // SSA based 'Aggressive DCE' addPass(PM, createCFGSimplificationPass()); // Merge & remove BBs addPass(PM, createDeadTypeEliminationPass()); // Eliminate dead types From alkis at cs.uiuc.edu Thu Jul 22 09:29:41 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Thu, 22 Jul 2004 09:29:41 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/Passes.cpp Message-ID: <200407221429.JAA20313@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: Passes.cpp updated: 1.9 -> 1.10 --- Log message: Fit to 80 columns. --- Diffs of the changes: (+11 -10) Index: llvm/lib/CodeGen/Passes.cpp diff -u llvm/lib/CodeGen/Passes.cpp:1.9 llvm/lib/CodeGen/Passes.cpp:1.10 --- llvm/lib/CodeGen/Passes.cpp:1.9 Wed Jul 21 03:24:34 2004 +++ llvm/lib/CodeGen/Passes.cpp Thu Jul 22 09:29:31 2004 @@ -20,16 +20,17 @@ namespace { enum RegAllocName { simple, local, linearscan, iterativescan }; - cl::opt - RegAlloc("regalloc", - cl::desc("Register allocator to use: (default = simple)"), - cl::Prefix, - cl::values(clEnumVal(simple, " simple register allocator"), - clEnumVal(local, " local register allocator"), - clEnumVal(linearscan, " linear scan register allocator"), - clEnumVal(iterativescan," iterative scan register allocator"), - clEnumValEnd), - cl::init(local)); + cl::opt Changes in directory llvm/lib/CodeGen: LiveIntervals.cpp updated: 1.100 -> 1.101 --- Log message: Sorting is now handled by both linearscan and iterative scan so live intervals need not be sorted anymore. Removing this redundant step improves LiveIntervals running time by 5% on 176.gcc. --- Diffs of the changes: (+0 -10) Index: llvm/lib/CodeGen/LiveIntervals.cpp diff -u llvm/lib/CodeGen/LiveIntervals.cpp:1.100 llvm/lib/CodeGen/LiveIntervals.cpp:1.101 --- llvm/lib/CodeGen/LiveIntervals.cpp:1.100 Wed Jul 21 19:04:14 2004 +++ llvm/lib/CodeGen/LiveIntervals.cpp Thu Jul 22 10:18:10 2004 @@ -159,7 +159,6 @@ } } - intervals_.sort(); DEBUG(std::cerr << "********** INTERVALS **********\n"); DEBUG(std::copy(intervals_.begin(), intervals_.end(), std::ostream_iterator(std::cerr, "\n"))); @@ -263,15 +262,6 @@ } } - // FIXME: This method MUST return intervals in sorted order. If a - // particular machine instruction both uses and defines the vreg being - // spilled (e.g., vr = vr + 1) and if the def is processed before the - // use, the list ends up not sorted. - // - // The proper way to fix this is to process all uses of the vreg before we - // process any defs. However, this would require refactoring the above - // blob of code, which I'm not feeling up to right now. - std::sort(added.begin(), added.end(), less_ptr()); return added; } From brukman at cs.uiuc.edu Thu Jul 22 10:26:33 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Thu, 22 Jul 2004 10:26:33 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/TwoAddressInstructionPass.cpp Message-ID: <200407221526.KAA18918@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: TwoAddressInstructionPass.cpp updated: 1.24 -> 1.25 --- Log message: Fix indentation and wrap code at 80 cols --- Diffs of the changes: (+101 -111) Index: llvm/lib/CodeGen/TwoAddressInstructionPass.cpp diff -u llvm/lib/CodeGen/TwoAddressInstructionPass.cpp:1.24 llvm/lib/CodeGen/TwoAddressInstructionPass.cpp:1.25 --- llvm/lib/CodeGen/TwoAddressInstructionPass.cpp:1.24 Thu Jul 22 00:51:56 2004 +++ llvm/lib/CodeGen/TwoAddressInstructionPass.cpp Thu Jul 22 10:26:23 2004 @@ -43,133 +43,123 @@ using namespace llvm; namespace { - Statistic<> numTwoAddressInstrs("twoaddressinstruction", - "Number of two-address instructions"); - Statistic<> numInstrsAdded("twoaddressinstruction", - "Number of instructions added"); - - struct TwoAddressInstructionPass : public MachineFunctionPass - { - virtual void getAnalysisUsage(AnalysisUsage &AU) const; - - /// runOnMachineFunction - pass entry point - bool runOnMachineFunction(MachineFunction&); - }; + Statistic<> numTwoAddressInstrs("twoaddressinstruction", + "Number of two-address instructions"); + Statistic<> numInstrsAdded("twoaddressinstruction", + "Number of instructions added"); + + struct TwoAddressInstructionPass : public MachineFunctionPass { + virtual void getAnalysisUsage(AnalysisUsage &AU) const; + + /// runOnMachineFunction - pass entry point + bool runOnMachineFunction(MachineFunction&); + }; - RegisterPass X( - "twoaddressinstruction", "Two-Address instruction pass"); + RegisterPass + X("twoaddressinstruction", "Two-Address instruction pass"); }; const PassInfo *llvm::TwoAddressInstructionPassID = X.getPassInfo(); -void TwoAddressInstructionPass::getAnalysisUsage(AnalysisUsage &AU) const -{ - AU.addPreserved(); - AU.addPreservedID(PHIEliminationID); - MachineFunctionPass::getAnalysisUsage(AU); +void TwoAddressInstructionPass::getAnalysisUsage(AnalysisUsage &AU) const { + AU.addPreserved(); + AU.addPreservedID(PHIEliminationID); + MachineFunctionPass::getAnalysisUsage(AU); } /// runOnMachineFunction - Reduce two-address instructions to two /// operands. /// bool TwoAddressInstructionPass::runOnMachineFunction(MachineFunction &MF) { - DEBUG(std::cerr << "Machine Function\n"); - const TargetMachine &TM = MF.getTarget(); - const MRegisterInfo &MRI = *TM.getRegisterInfo(); - const TargetInstrInfo &TII = *TM.getInstrInfo(); - LiveVariables* LV = getAnalysisToUpdate(); - - bool MadeChange = false; - - DEBUG(std::cerr << "********** REWRITING TWO-ADDR INSTRS **********\n"); - DEBUG(std::cerr << "********** Function: " - << MF.getFunction()->getName() << '\n'); - - for (MachineFunction::iterator mbbi = MF.begin(), mbbe = MF.end(); - mbbi != mbbe; ++mbbi) { - for (MachineBasicBlock::iterator mi = mbbi->begin(), me = mbbi->end(); - mi != me; ++mi) { - unsigned opcode = mi->getOpcode(); - - // ignore if it is not a two-address instruction - if (!TII.isTwoAddrInstr(opcode)) - continue; - - ++numTwoAddressInstrs; - - DEBUG(std::cerr << '\t'; mi->print(std::cerr, &TM)); - - assert(mi->getOperand(1).isRegister() && - mi->getOperand(1).getReg() && - mi->getOperand(1).isUse() && - "two address instruction invalid"); - - // if the two operands are the same we just remove the use - // and mark the def as def&use, otherwise we have to insert a copy. - if (mi->getOperand(0).getReg() != mi->getOperand(1).getReg()) { - // rewrite: - // a = b op c - // to: - // a = b - // a = a op c - unsigned regA = mi->getOperand(0).getReg(); - unsigned regB = mi->getOperand(1).getReg(); - - assert(MRegisterInfo::isVirtualRegister(regA) && - MRegisterInfo::isVirtualRegister(regB) && - "cannot update physical register live information"); - - // first make sure we do not have a use of a in the - // instruction (a = b + a for example) because our - // transformation will not work. This should never occur - // because we are in SSA form. + DEBUG(std::cerr << "Machine Function\n"); + const TargetMachine &TM = MF.getTarget(); + const MRegisterInfo &MRI = *TM.getRegisterInfo(); + const TargetInstrInfo &TII = *TM.getInstrInfo(); + LiveVariables* LV = getAnalysisToUpdate(); + + bool MadeChange = false; + + DEBUG(std::cerr << "********** REWRITING TWO-ADDR INSTRS **********\n"); + DEBUG(std::cerr << "********** Function: " + << MF.getFunction()->getName() << '\n'); + + for (MachineFunction::iterator mbbi = MF.begin(), mbbe = MF.end(); + mbbi != mbbe; ++mbbi) { + for (MachineBasicBlock::iterator mi = mbbi->begin(), me = mbbi->end(); + mi != me; ++mi) { + unsigned opcode = mi->getOpcode(); + + // ignore if it is not a two-address instruction + if (!TII.isTwoAddrInstr(opcode)) + continue; + + ++numTwoAddressInstrs; + DEBUG(std::cerr << '\t'; mi->print(std::cerr, &TM)); + assert(mi->getOperand(1).isRegister() && mi->getOperand(1).getReg() && + mi->getOperand(1).isUse() && "two address instruction invalid"); + + // if the two operands are the same we just remove the use + // and mark the def as def&use, otherwise we have to insert a copy. + if (mi->getOperand(0).getReg() != mi->getOperand(1).getReg()) { + // rewrite: + // a = b op c + // to: + // a = b + // a = a op c + unsigned regA = mi->getOperand(0).getReg(); + unsigned regB = mi->getOperand(1).getReg(); + + assert(MRegisterInfo::isVirtualRegister(regA) && + MRegisterInfo::isVirtualRegister(regB) && + "cannot update physical register live information"); + + // first make sure we do not have a use of a in the + // instruction (a = b + a for example) because our + // transformation will not work. This should never occur + // because we are in SSA form. #ifndef NDEBUG - for (unsigned i = 1; i != mi->getNumOperands(); ++i) - assert(!mi->getOperand(i).isRegister() || - mi->getOperand(i).getReg() != regA); + for (unsigned i = 1; i != mi->getNumOperands(); ++i) + assert(!mi->getOperand(i).isRegister() || + mi->getOperand(i).getReg() != regA); #endif - const TargetRegisterClass* rc = - MF.getSSARegMap()->getRegClass(regA); - unsigned Added = MRI.copyRegToReg(*mbbi, mi, regA, regB, rc); - numInstrsAdded += Added; - - MachineBasicBlock::iterator prevMi = prior(mi); - DEBUG(std::cerr << "\t\tprepend:\t"; - prevMi->print(std::cerr, &TM)); - - if (LV) { - // update live variables for regA - assert(Added == 1 && - "Cannot handle multi-instruction copies yet!"); - LiveVariables::VarInfo& varInfo = LV->getVarInfo(regA); - varInfo.DefInst = prevMi; - - // update live variables for regB - if (LV->removeVirtualRegisterKilled(regB, mbbi, mi)) - LV->addVirtualRegisterKilled(regB, prevMi); - - if (LV->removeVirtualRegisterDead(regB, mbbi, mi)) - LV->addVirtualRegisterDead(regB, prevMi); - } - - // replace all occurences of regB with regA - for (unsigned i = 1, e = mi->getNumOperands(); i != e; ++i) { - if (mi->getOperand(i).isRegister() && - mi->getOperand(i).getReg() == regB) - mi->SetMachineOperandReg(i, regA); - } - } - - assert(mi->getOperand(0).isDef()); - mi->getOperand(0).setUse(); - mi->RemoveOperand(1); - MadeChange = true; + const TargetRegisterClass* rc = MF.getSSARegMap()->getRegClass(regA); + unsigned Added = MRI.copyRegToReg(*mbbi, mi, regA, regB, rc); + numInstrsAdded += Added; + + MachineBasicBlock::iterator prevMi = prior(mi); + DEBUG(std::cerr << "\t\tprepend:\t"; prevMi->print(std::cerr, &TM)); + + if (LV) { + // update live variables for regA + assert(Added == 1 && "Cannot handle multi-instruction copies yet!"); + LiveVariables::VarInfo& varInfo = LV->getVarInfo(regA); + varInfo.DefInst = prevMi; + + // update live variables for regB + if (LV->removeVirtualRegisterKilled(regB, mbbi, mi)) + LV->addVirtualRegisterKilled(regB, prevMi); - DEBUG(std::cerr << "\t\trewrite to:\t"; - mi->print(std::cerr, &TM)); + if (LV->removeVirtualRegisterDead(regB, mbbi, mi)) + LV->addVirtualRegisterDead(regB, prevMi); } + + // replace all occurences of regB with regA + for (unsigned i = 1, e = mi->getNumOperands(); i != e; ++i) { + if (mi->getOperand(i).isRegister() && + mi->getOperand(i).getReg() == regB) + mi->SetMachineOperandReg(i, regA); + } + } + + assert(mi->getOperand(0).isDef()); + mi->getOperand(0).setUse(); + mi->RemoveOperand(1); + MadeChange = true; + + DEBUG(std::cerr << "\t\trewrite to:\t"; mi->print(std::cerr, &TM)); } + } - return MadeChange; + return MadeChange; } From alkis at cs.uiuc.edu Thu Jul 22 10:30:43 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Thu, 22 Jul 2004 10:30:43 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/Passes.cpp Message-ID: <200407221530.KAA19055@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: Passes.cpp updated: 1.10 -> 1.11 --- Log message: Put variable name to a separate line. --- Diffs of the changes: (+2 -1) Index: llvm/lib/CodeGen/Passes.cpp diff -u llvm/lib/CodeGen/Passes.cpp:1.10 llvm/lib/CodeGen/Passes.cpp:1.11 --- llvm/lib/CodeGen/Passes.cpp:1.10 Thu Jul 22 09:29:31 2004 +++ llvm/lib/CodeGen/Passes.cpp Thu Jul 22 10:30:33 2004 @@ -20,7 +20,8 @@ namespace { enum RegAllocName { simple, local, linearscan, iterativescan }; - cl::opt + RegAlloc( "regalloc", cl::desc("Register allocator to use: (default = simple)"), cl::Prefix, From lattner at cs.uiuc.edu Thu Jul 22 11:31:28 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu, 22 Jul 2004 11:31:28 -0500 Subject: [llvm-commits] CVS: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/perl/util.c util.h Message-ID: <200407221631.LAA11801@apoc.cs.uiuc.edu> Changes in directory llvm/test/Programs/MultiSource/Benchmarks/MallocBench/perl: util.c updated: 1.1 -> 1.2 util.h updated: 1.2 -> 1.3 --- Log message: For some reason this test magically started failing last night due to the definition of fatal. Looking at it, I don't see how it could have worked in the first place, so just comment the silly thing out. Also, remove stupid CVS logs --- Diffs of the changes: (+8 -28) Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/perl/util.c diff -u llvm/test/Programs/MultiSource/Benchmarks/MallocBench/perl/util.c:1.1 llvm/test/Programs/MultiSource/Benchmarks/MallocBench/perl/util.c:1.2 --- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/perl/util.c:1.1 Tue Feb 17 16:21:17 2004 +++ llvm/test/Programs/MultiSource/Benchmarks/MallocBench/perl/util.c Thu Jul 22 11:31:17 2004 @@ -1,22 +1,10 @@ -/* $RCSfile: util.c,v $$Revision: 1.1 $$Date: 2004/02/17 22:21:17 $ +/* $RCSfile: util.c,v $$Revision: 1.2 $$Date: 2004/07/22 16:31:17 $ * * Copyright (c) 1989, Larry Wall * * You may distribute under the terms of the GNU General Public License * as specified in the README file that comes with the perl 3.0 kit. * - * $Log: util.c,v $ - * Revision 1.1 2004/02/17 22:21:17 criswell - * Initial commit of the perl Malloc Benchmark. I've cheated a little by - * generating the yacc output files and committing them directly, but it was - * easier than disabling the Bison Voodoo that gets executed by default. - * - * Revision 4.0.1.1 91/04/12 09:19:25 lwall - * patch1: random cleanup in cpp namespace - * - * Revision 4.0 91/03/20 01:56:39 lwall - * 4.0 baseline. - * */ #include "EXTERN.h" @@ -810,6 +798,7 @@ } /*VARARGS1*/ +#if 0 fatal(pat,a1,a2,a3,a4) char *pat; long a1, a2, a3, a4; @@ -851,6 +840,7 @@ statusvalue >>= 8; exit((int)((errno&255)?errno:((statusvalue&255)?statusvalue:255))); } +#endif /*VARARGS1*/ warn(pat,a1,a2,a3,a4) Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/perl/util.h diff -u llvm/test/Programs/MultiSource/Benchmarks/MallocBench/perl/util.h:1.2 llvm/test/Programs/MultiSource/Benchmarks/MallocBench/perl/util.h:1.3 --- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/perl/util.h:1.2 Wed Jul 21 09:09:51 2004 +++ llvm/test/Programs/MultiSource/Benchmarks/MallocBench/perl/util.h Thu Jul 22 11:31:17 2004 @@ -1,22 +1,10 @@ -/* $Header: /home/vadve/shared/PublicCVS/llvm/test/Programs/MultiSource/Benchmarks/MallocBench/perl/util.h,v 1.2 2004/07/21 14:09:51 brukman Exp $ +/* $Header: /home/vadve/shared/PublicCVS/llvm/test/Programs/MultiSource/Benchmarks/MallocBench/perl/util.h,v 1.3 2004/07/22 16:31:17 lattner Exp $ * * Copyright (c) 1989, Larry Wall * * You may distribute under the terms of the GNU General Public License * as specified in the README file that comes with the perl 3.0 kit. * - * $Log: util.h,v $ - * Revision 1.2 2004/07/21 14:09:51 brukman - * Add missing function declarations. - * - * Revision 1.1 2004/02/17 22:21:17 criswell - * Initial commit of the perl Malloc Benchmark. I've cheated a little by - * generating the yacc output files and committing them directly, but it was - * easier than disabling the Bison Voodoo that gets executed by default. - * - * Revision 4.0 91/03/20 01:56:48 lwall - * 4.0 baseline. - * */ EXT int *screamfirst INIT(Null(int*)); @@ -48,5 +36,7 @@ #endif unsigned long scanoct(); unsigned long scanhex(); -void fatal(char*,long,long,long,long); -void fatal(va_list); +//void fatal(char*,long,long,long,long); +//void fatal(va_list); + +#define fatal(X, ...) do { printf(X); abort(); } while (0) From lattner at cs.uiuc.edu Thu Jul 22 13:42:10 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu, 22 Jul 2004 13:42:10 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/Passes.cpp Message-ID: <200407221842.NAA12390@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: Passes.cpp updated: 1.11 -> 1.12 --- Log message: Make linear scan the default --- Diffs of the changes: (+1 -1) Index: llvm/lib/CodeGen/Passes.cpp diff -u llvm/lib/CodeGen/Passes.cpp:1.11 llvm/lib/CodeGen/Passes.cpp:1.12 --- llvm/lib/CodeGen/Passes.cpp:1.11 Thu Jul 22 10:30:33 2004 +++ llvm/lib/CodeGen/Passes.cpp Thu Jul 22 13:42:00 2004 @@ -31,7 +31,7 @@ clEnumVal(linearscan, " linear scan register allocator"), clEnumVal(iterativescan, " iterative scan register allocator"), clEnumValEnd), - cl::init(local)); + cl::init(linearscan)); } FunctionPass *llvm::createRegisterAllocator() { From lattner at cs.uiuc.edu Thu Jul 22 16:25:57 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu, 22 Jul 2004 16:25:57 -0500 Subject: [llvm-commits] CVS: llvm-www/testresults/index.html Message-ID: <200407222125.QAA13559@apoc.cs.uiuc.edu> Changes in directory llvm-www/testresults: index.html updated: 1.8 -> 1.9 --- Log message: machine upgrade --- Diffs of the changes: (+3 -3) Index: llvm-www/testresults/index.html diff -u llvm-www/testresults/index.html:1.8 llvm-www/testresults/index.html:1.9 --- llvm-www/testresults/index.html:1.8 Fri Jun 25 03:15:33 2004 +++ llvm-www/testresults/index.html Thu Jul 22 16:25:47 2004 @@ -25,8 +25,8 @@
  • X86: Linux (Dual P4 Xeon @ 3.06GHz) -- debug build
  • -
  • X86: Linux (Celeron @ -1.7GHz) -- release build
  • +
  • X86: Linux (P4 @ +2.3GHz) -- release build
  • X86: FreeBSD 5.1 (may not be run every day)
  • PPC: Mac OS X 10.3 "Panther" on PowerPC G5 (dual 1.8Ghz CPU) (C Back-end Only)
  • @@ -41,7 +41,7 @@
    Chris Lattner
    The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/06/25 08:15:33 $ + Last modified: $Date: 2004/07/22 21:25:47 $ From lattner at cs.uiuc.edu Thu Jul 22 16:30:45 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu, 22 Jul 2004 16:30:45 -0500 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/Makefile X86.h X86TargetMachine.cpp X86SimpInstrSelector.cpp Message-ID: <200407222130.QAA16081@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: Makefile updated: 1.16 -> 1.17 X86.h updated: 1.26 -> 1.27 X86TargetMachine.cpp updated: 1.62 -> 1.63 X86SimpInstrSelector.cpp (r1.7) removed --- Log message: Remove some (LARGE) abandoned code for the release. If this is ever needed again in the future, it can be resurrected out of CVS --- Diffs of the changes: (+2 -17) Index: llvm/lib/Target/X86/Makefile diff -u llvm/lib/Target/X86/Makefile:1.16 llvm/lib/Target/X86/Makefile:1.17 --- llvm/lib/Target/X86/Makefile:1.16 Tue Apr 6 14:33:59 2004 +++ llvm/lib/Target/X86/Makefile Thu Jul 22 16:30:35 2004 @@ -13,8 +13,7 @@ # Make sure that tblgen is run, first thing. $(SourceDepend): X86GenRegisterInfo.h.inc X86GenRegisterNames.inc \ X86GenRegisterInfo.inc X86GenInstrNames.inc \ - X86GenInstrInfo.inc X86GenSimpInstrSelector.inc \ - X86GenInstrSelector.inc + X86GenInstrInfo.inc X86GenInstrSelector.inc X86GenRegisterNames.inc:: $(SourceDir)/X86.td $(SourceDir)/X86RegisterInfo.td \ $(SourceDir)/../Target.td $(TBLGEN) @@ -41,10 +40,6 @@ @echo "Building X86.td instruction information with tblgen" $(VERB) $(TBLGEN) -I $(BUILD_SRC_DIR) $< -gen-instr-desc -o $@ -X86GenSimpInstrSelector.inc:: $(SourceDir)/X86InstrSel.td $(TBLGEN) - @echo "Building X86.td simple instruction selector with tblgen" - $(VERB) $(TBLGEN) -I $(BUILD_SRC_DIR) $< -gen-simp-instr-sel -o $@ - X86GenInstrSelector.inc:: $(SourceDir)/X86.td $(SourceDir)/X86InstrInfo.td \ $(SourceDir)/../Target.td $(TBLGEN) @echo "Building X86.td instruction selector with tblgen" Index: llvm/lib/Target/X86/X86.h diff -u llvm/lib/Target/X86/X86.h:1.26 llvm/lib/Target/X86/X86.h:1.27 --- llvm/lib/Target/X86/X86.h:1.26 Tue Apr 6 14:33:59 2004 +++ llvm/lib/Target/X86/X86.h Thu Jul 22 16:30:35 2004 @@ -29,12 +29,6 @@ /// FunctionPass *createX86SimpleInstructionSelector(TargetMachine &TM); -/// createX86ReallySimpleInstructionSelector - This pass converts an LLVM -/// function into a machine code representation in an even simpler fashion -/// than above. -/// -FunctionPass *createX86ReallySimpleInstructionSelector(TargetMachine &TM); - /// createX86PatternInstructionSelector - This pass converts an LLVM function /// into a machine code representation using pattern matching and a machine /// description file. Index: llvm/lib/Target/X86/X86TargetMachine.cpp diff -u llvm/lib/Target/X86/X86TargetMachine.cpp:1.62 llvm/lib/Target/X86/X86TargetMachine.cpp:1.63 --- llvm/lib/Target/X86/X86TargetMachine.cpp:1.62 Sat Jul 10 23:17:04 2004 +++ llvm/lib/Target/X86/X86TargetMachine.cpp Thu Jul 22 16:30:35 2004 @@ -34,8 +34,6 @@ cl::opt DisableOutput("disable-x86-llc-output", cl::Hidden, cl::desc("Disable the X86 asm printer, for use " "when profiling the code generator.")); - cl::opt NoSimpleISel("disable-simple-isel", cl::init(true), - cl::desc("Use the hand coded 'simple' X86 instruction selector")); // Register the target. RegisterTarget X("x86", " IA-32 (Pentium and above)"); @@ -85,10 +83,8 @@ // Make sure that no unreachable blocks are instruction selected. PM.add(createUnreachableBlockEliminationPass()); - if (NoPatternISel && NoSimpleISel) + if (NoPatternISel) PM.add(createX86SimpleInstructionSelector(*this)); - else if (NoPatternISel) - PM.add(createX86ReallySimpleInstructionSelector(*this)); else PM.add(createX86PatternInstructionSelector(*this)); From lattner at cs.uiuc.edu Thu Jul 22 16:32:48 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu, 22 Jul 2004 16:32:48 -0500 Subject: [llvm-commits] CVS: llvm/utils/TableGen/TableGen.cpp SimpleInstrSelEmitter.cpp SimpleInstrSelEmitter.h Message-ID: <200407222132.QAA16505@apoc.cs.uiuc.edu> Changes in directory llvm/utils/TableGen: TableGen.cpp updated: 1.29 -> 1.30 SimpleInstrSelEmitter.cpp (r1.3) removed SimpleInstrSelEmitter.h (r1.1) removed --- Log message: Remove some abandoned code that was never finished. If needed in the future it can be ressurected from CVS. --- Diffs of the changes: (+1 -7) Index: llvm/utils/TableGen/TableGen.cpp diff -u llvm/utils/TableGen/TableGen.cpp:1.29 llvm/utils/TableGen/TableGen.cpp:1.30 --- llvm/utils/TableGen/TableGen.cpp:1.29 Thu Jul 15 19:02:21 2004 +++ llvm/utils/TableGen/TableGen.cpp Thu Jul 22 16:32:38 2004 @@ -23,7 +23,6 @@ #include "RegisterInfoEmitter.h" #include "InstrInfoEmitter.h" #include "InstrSelectorEmitter.h" -#include "SimpleInstrSelEmitter.h" #include #include #include @@ -36,7 +35,7 @@ GenRegisterEnums, GenRegister, GenRegisterHeader, GenInstrEnums, GenInstrs, GenInstrSelector, PrintEnums, - Parse, GenSimpInstrSel, + Parse }; namespace { @@ -58,8 +57,6 @@ "Generate instruction descriptions"), clEnumValN(GenInstrSelector, "gen-instr-selector", "Generate an instruction selector"), - clEnumValN(GenSimpInstrSel, "gen-simp-instr-sel", - "Generate a simple instruction selector"), clEnumValN(PrintEnums, "print-enums", "Print enum values for a class"), clEnumValN(Parse, "parse", @@ -471,9 +468,6 @@ *Out << "\n"; break; } - case GenSimpInstrSel: - SimpleInstrSelEmitter(Records).run(*Out); - break; default: assert(1 && "Invalid Action"); return 1; From lattner at cs.uiuc.edu Thu Jul 22 16:46:12 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu, 22 Jul 2004 16:46:12 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/Passes.cpp Message-ID: <200407222146.QAA16859@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: Passes.cpp updated: 1.12 -> 1.13 --- Log message: The default has not been 'simple' for AGES! --- Diffs of the changes: (+1 -1) Index: llvm/lib/CodeGen/Passes.cpp diff -u llvm/lib/CodeGen/Passes.cpp:1.12 llvm/lib/CodeGen/Passes.cpp:1.13 --- llvm/lib/CodeGen/Passes.cpp:1.12 Thu Jul 22 13:42:00 2004 +++ llvm/lib/CodeGen/Passes.cpp Thu Jul 22 16:46:02 2004 @@ -23,7 +23,7 @@ cl::opt RegAlloc( "regalloc", - cl::desc("Register allocator to use: (default = simple)"), + cl::desc("Register allocator to use: (default = linearscan)"), cl::Prefix, cl::values( clEnumVal(simple, " simple register allocator"), From lattner at cs.uiuc.edu Thu Jul 22 16:54:32 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu, 22 Jul 2004 16:54:32 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervals.cpp Message-ID: <200407222154.QAA17201@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveIntervals.cpp updated: 1.101 -> 1.102 --- Log message: Fix broken -debug printing --- Diffs of the changes: (+1 -0) Index: llvm/lib/CodeGen/LiveIntervals.cpp diff -u llvm/lib/CodeGen/LiveIntervals.cpp:1.101 llvm/lib/CodeGen/LiveIntervals.cpp:1.102 --- llvm/lib/CodeGen/LiveIntervals.cpp:1.101 Thu Jul 22 10:18:10 2004 +++ llvm/lib/CodeGen/LiveIntervals.cpp Thu Jul 22 16:54:22 2004 @@ -306,6 +306,7 @@ assert(vi.AliveBlocks.empty() && "Shouldn't be alive across any blocks!"); interval.addRange(defIndex, killIdx); + DEBUG(std::cerr << "\n"); return; } } From criswell at cs.uiuc.edu Thu Jul 22 17:11:27 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Thu, 22 Jul 2004 17:11:27 -0500 Subject: [llvm-commits] CVS: llvm/CREDITS.TXT Message-ID: <200407222211.RAA27229@choi.cs.uiuc.edu> Changes in directory llvm: CREDITS.TXT updated: 1.12 -> 1.13 --- Log message: Give some credit to Oscar. Should help to address Bug#13. --- Diffs of the changes: (+3 -0) Index: llvm/CREDITS.TXT diff -u llvm/CREDITS.TXT:1.12 llvm/CREDITS.TXT:1.13 --- llvm/CREDITS.TXT:1.12 Fri Jun 25 16:00:10 2004 +++ llvm/CREDITS.TXT Thu Jul 22 17:11:16 2004 @@ -49,6 +49,9 @@ E: wanderer at rsu.ru D: Test suite fixes for FreeBSD. +N: Oscar the Plant +D: LLVM Inspiration + N: Vladimir Prus E: ghost at cs.msu.su D: Made inst_iterator behave like a proper iterator, LowerConstantExprs pass From brukman at cs.uiuc.edu Thu Jul 22 17:43:31 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Thu, 22 Jul 2004 17:43:31 -0500 Subject: [llvm-commits] CVS: llvm/CREDITS.TXT Message-ID: <200407222243.RAA30745@zion.cs.uiuc.edu> Changes in directory llvm: CREDITS.TXT updated: 1.13 -> 1.14 --- Log message: Let's not get carried away here, please. --- Diffs of the changes: (+0 -3) Index: llvm/CREDITS.TXT diff -u llvm/CREDITS.TXT:1.13 llvm/CREDITS.TXT:1.14 --- llvm/CREDITS.TXT:1.13 Thu Jul 22 17:11:16 2004 +++ llvm/CREDITS.TXT Thu Jul 22 17:43:21 2004 @@ -49,9 +49,6 @@ E: wanderer at rsu.ru D: Test suite fixes for FreeBSD. -N: Oscar the Plant -D: LLVM Inspiration - N: Vladimir Prus E: ghost at cs.msu.su D: Made inst_iterator behave like a proper iterator, LowerConstantExprs pass From lattner at cs.uiuc.edu Thu Jul 22 18:05:22 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu, 22 Jul 2004 18:05:22 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/PHIElimination.cpp Message-ID: <200407222305.SAA18944@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: PHIElimination.cpp updated: 1.30 -> 1.31 --- Log message: costmetic changes --- Diffs of the changes: (+14 -14) Index: llvm/lib/CodeGen/PHIElimination.cpp diff -u llvm/lib/CodeGen/PHIElimination.cpp:1.30 llvm/lib/CodeGen/PHIElimination.cpp:1.31 --- llvm/lib/CodeGen/PHIElimination.cpp:1.30 Mon Jul 19 02:04:55 2004 +++ llvm/lib/CodeGen/PHIElimination.cpp Thu Jul 22 18:05:12 2004 @@ -95,13 +95,13 @@ ++AfterPHIsIt; // Skip over all of the PHI nodes... while (MBB.front().getOpcode() == TargetInstrInfo::PHI) { - // Unlink the PHI node from the basic block... but don't delete the PHI yet - MachineInstr *MI = MBB.remove(MBB.begin()); + // Unlink the PHI node from the basic block, but don't delete the PHI yet. + MachineInstr *MPhi = MBB.remove(MBB.begin()); - assert(MRegisterInfo::isVirtualRegister(MI->getOperand(0).getReg()) && + assert(MRegisterInfo::isVirtualRegister(MPhi->getOperand(0).getReg()) && "PHI node doesn't write virt reg?"); - unsigned DestReg = MI->getOperand(0).getReg(); + unsigned DestReg = MPhi->getOperand(0).getReg(); // Create a new register for the incoming PHI arguments const TargetRegisterClass *RC = MF.getSSARegMap()->getRegClass(DestReg); @@ -126,10 +126,10 @@ // Since we are going to be deleting the PHI node, if it is the last use // of any registers, or if the value itself is dead, we need to move this - // information over to the new copy we just inserted... + // information over to the new copy we just inserted. // std::pair - RKs = LV->killed_range(MI); + RKs = LV->killed_range(MPhi); std::vector > Range; if (RKs.first != RKs.second) { // Copy the range into a vector... @@ -143,7 +143,7 @@ LV->addVirtualRegisterKilled(Range[i].second, PHICopy); } - RKs = LV->dead_range(MI); + RKs = LV->dead_range(MPhi); if (RKs.first != RKs.second) { // Works as above... Range.assign(RKs.first, RKs.second); @@ -155,18 +155,18 @@ // Adjust the VRegPHIUseCount map to account for the removal of this PHI // node. - for (unsigned i = 1; i != MI->getNumOperands(); i += 2) - VRegPHIUseCount[MI->getOperand(i).getReg()] -= BBIsSuccOfPreds; + for (unsigned i = 1; i != MPhi->getNumOperands(); i += 2) + VRegPHIUseCount[MPhi->getOperand(i).getReg()] -= BBIsSuccOfPreds; // Now loop over all of the incoming arguments, changing them to copy into // the IncomingReg register in the corresponding predecessor basic block. // - for (int i = MI->getNumOperands() - 1; i >= 2; i-=2) { - MachineOperand &opVal = MI->getOperand(i-1); + for (int i = MPhi->getNumOperands() - 1; i >= 2; i-=2) { + MachineOperand &opVal = MPhi->getOperand(i-1); // Get the MachineBasicBlock equivalent of the BasicBlock that is the // source path the PHI. - MachineBasicBlock &opBlock = *MI->getOperand(i).getMachineBasicBlock(); + MachineBasicBlock &opBlock = *MPhi->getOperand(i).getMachineBasicBlock(); MachineBasicBlock::iterator I = opBlock.getFirstTerminator(); @@ -257,8 +257,8 @@ } } - // really delete the PHI instruction now! - delete MI; + // Really delete the PHI instruction now! + delete MPhi; } return true; } From brukman at cs.uiuc.edu Thu Jul 22 20:08:23 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Thu, 22 Jul 2004 20:08:23 -0500 Subject: [llvm-commits] CVS: llvm/include/llvm/Target/TargetData.h TargetMachine.h Message-ID: <200407230108.UAA31764@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Target: TargetData.h updated: 1.24 -> 1.25 TargetMachine.h updated: 1.48 -> 1.49 --- Log message: * Add a BoolAlignment field to TargetData, default is 1 byte * Fix spacing --- Diffs of the changes: (+20 -16) Index: llvm/include/llvm/Target/TargetData.h diff -u llvm/include/llvm/Target/TargetData.h:1.24 llvm/include/llvm/Target/TargetData.h:1.25 --- llvm/include/llvm/Target/TargetData.h:1.24 Wed Apr 14 12:45:48 2004 +++ llvm/include/llvm/Target/TargetData.h Thu Jul 22 20:08:13 2004 @@ -34,7 +34,8 @@ class TargetData : public ImmutablePass { bool LittleEndian; // Defaults to false - unsigned char ByteAlignment; // Defaults to 1 bytes + unsigned char BoolAlignment; // Defaults to 1 byte + unsigned char ByteAlignment; // Defaults to 1 byte unsigned char ShortAlignment; // Defaults to 2 bytes unsigned char IntAlignment; // Defaults to 4 bytes unsigned char LongAlignment; // Defaults to 8 bytes @@ -47,23 +48,24 @@ TargetData(const std::string &TargetName = "", bool LittleEndian = false, unsigned char PtrSize = 8, - unsigned char PtrAl = 8, unsigned char DoubleAl = 8, - unsigned char FloatAl = 4, unsigned char LongAl = 8, - unsigned char IntAl = 4, unsigned char ShortAl = 2, - unsigned char ByteAl = 1); + unsigned char PtrAl = 8, unsigned char DoubleAl = 8, + unsigned char FloatAl = 4, unsigned char LongAl = 8, + unsigned char IntAl = 4, unsigned char ShortAl = 2, + unsigned char ByteAl = 1, unsigned char BoolAl = 1); // Copy constructor TargetData (const TargetData &TD) : - ImmutablePass (), - LittleEndian (TD.isLittleEndian ()), - ByteAlignment (TD.getByteAlignment ()), - ShortAlignment (TD.getShortAlignment ()), - IntAlignment (TD.getIntAlignment ()), - LongAlignment (TD.getLongAlignment ()), - FloatAlignment (TD.getFloatAlignment ()), - DoubleAlignment (TD.getDoubleAlignment ()), - PointerSize (TD.getPointerSize ()), - PointerAlignment (TD.getPointerAlignment ()) { + ImmutablePass(), + LittleEndian(TD.isLittleEndian()), + BoolAlignment(TD.getBoolAlignment()), + ByteAlignment(TD.getByteAlignment()), + ShortAlignment(TD.getShortAlignment()), + IntAlignment(TD.getIntAlignment()), + LongAlignment(TD.getLongAlignment()), + FloatAlignment(TD.getFloatAlignment()), + DoubleAlignment(TD.getDoubleAlignment()), + PointerSize(TD.getPointerSize()), + PointerAlignment(TD.getPointerAlignment()) { } TargetData(const std::string &ToolName, const Module *M); @@ -74,6 +76,7 @@ bool isBigEndian() const { return !LittleEndian; } /// Target alignment constraints + unsigned char getBoolAlignment() const { return BoolAlignment; } unsigned char getByteAlignment() const { return ByteAlignment; } unsigned char getShortAlignment() const { return ShortAlignment; } unsigned char getIntAlignment() const { return IntAlignment; } Index: llvm/include/llvm/Target/TargetMachine.h diff -u llvm/include/llvm/Target/TargetMachine.h:1.48 llvm/include/llvm/Target/TargetMachine.h:1.49 --- llvm/include/llvm/Target/TargetMachine.h:1.48 Sat Jul 10 21:43:07 2004 +++ llvm/include/llvm/Target/TargetMachine.h Thu Jul 22 20:08:13 2004 @@ -51,7 +51,8 @@ unsigned char PtrSize = 8, unsigned char PtrAl = 8, unsigned char DoubleAl = 8, unsigned char FloatAl = 4, unsigned char LongAl = 8, unsigned char IntAl = 4, - unsigned char ShortAl = 2, unsigned char ByteAl = 1); + unsigned char ShortAl = 2, unsigned char ByteAl = 1, + unsigned char BoolAl = 1); /// This constructor is used for targets that support arbitrary TargetData /// layouts, like the C backend. It initializes the TargetData to match that From brukman at cs.uiuc.edu Thu Jul 22 20:10:02 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Thu, 22 Jul 2004 20:10:02 -0500 Subject: [llvm-commits] CVS: llvm/lib/Target/TargetData.cpp TargetMachine.cpp Message-ID: <200407230110.UAA31851@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target: TargetData.cpp updated: 1.49 -> 1.50 TargetMachine.cpp updated: 1.31 -> 1.32 --- Log message: * Add BoolAlignment to TargetData, default is 1 byte, size 1 byte * Convert tabs to spaces --- Diffs of the changes: (+11 -8) Index: llvm/lib/Target/TargetData.cpp diff -u llvm/lib/Target/TargetData.cpp:1.49 llvm/lib/Target/TargetData.cpp:1.50 --- llvm/lib/Target/TargetData.cpp:1.49 Thu Jul 15 02:44:34 2004 +++ llvm/lib/Target/TargetData.cpp Thu Jul 22 20:09:52 2004 @@ -30,7 +30,7 @@ } static inline void getTypeInfo(const Type *Ty, const TargetData *TD, - uint64_t &Size, unsigned char &Alignment); + uint64_t &Size, unsigned char &Alignment); //===----------------------------------------------------------------------===// // Support for StructLayout @@ -42,7 +42,7 @@ // Loop over each of the elements, placing them in memory... for (StructType::element_iterator TI = ST->element_begin(), - TE = ST->element_end(); TI != TE; ++TI) { + TE = ST->element_end(); TI != TE; ++TI) { const Type *Ty = *TI; unsigned char A; unsigned TyAlign; @@ -79,7 +79,7 @@ unsigned char PtrAl, unsigned char DoubleAl, unsigned char FloatAl, unsigned char LongAl, unsigned char IntAl, unsigned char ShortAl, - unsigned char ByteAl) { + unsigned char ByteAl, unsigned char BoolAl) { // If this assert triggers, a pass "required" TargetData information, but the // top level tool did not provide one for it. We do not want to default @@ -97,6 +97,7 @@ IntAlignment = IntAl; ShortAlignment = ShortAl; ByteAlignment = ByteAl; + BoolAlignment = BoolAl; } TargetData::TargetData(const std::string &ToolName, const Module *M) { @@ -109,6 +110,7 @@ IntAlignment = 4; ShortAlignment = 2; ByteAlignment = 1; + BoolAlignment = 1; } static std::map, @@ -146,11 +148,11 @@ } static inline void getTypeInfo(const Type *Ty, const TargetData *TD, - uint64_t &Size, unsigned char &Alignment) { + uint64_t &Size, unsigned char &Alignment) { assert(Ty->isSized() && "Cannot getTypeInfo() on a type that is unsized!"); switch (Ty->getTypeID()) { + case Type::BoolTyID: Size = 1; Alignment = TD->getBoolAlignment(); return; case Type::VoidTyID: - case Type::BoolTyID: case Type::UByteTyID: case Type::SByteTyID: Size = 1; Alignment = TD->getByteAlignment(); return; case Type::UShortTyID: @@ -212,7 +214,7 @@ uint64_t TargetData::getIndexedOffset(const Type *ptrTy, - const std::vector &Idx) const { + const std::vector &Idx) const { const Type *Ty = ptrTy; assert(isa(Ty) && "Illegal argument for getIndexedOffset()"); uint64_t Result = 0; Index: llvm/lib/Target/TargetMachine.cpp diff -u llvm/lib/Target/TargetMachine.cpp:1.31 llvm/lib/Target/TargetMachine.cpp:1.32 --- llvm/lib/Target/TargetMachine.cpp:1.31 Mon Jun 21 16:44:12 2004 +++ llvm/lib/Target/TargetMachine.cpp Thu Jul 22 20:09:52 2004 @@ -45,10 +45,11 @@ unsigned char PtrSize, unsigned char PtrAl, unsigned char DoubleAl, unsigned char FloatAl, unsigned char LongAl, unsigned char IntAl, - unsigned char ShortAl, unsigned char ByteAl) + unsigned char ShortAl, unsigned char ByteAl, + unsigned char BoolAl) : Name(name), DataLayout(name, LittleEndian, PtrSize, PtrAl, DoubleAl, FloatAl, LongAl, - IntAl, ShortAl, ByteAl) { + IntAl, ShortAl, ByteAl, BoolAl) { IL = il ? il : new DefaultIntrinsicLowering(); } TargetMachine::TargetMachine(const std::string &name, IntrinsicLowering *il, From brukman at cs.uiuc.edu Thu Jul 22 20:30:59 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Thu, 22 Jul 2004 20:30:59 -0500 Subject: [llvm-commits] CVS: llvm/tools/bugpoint/BugDriver.cpp CrashDebugger.cpp ExecutionDriver.cpp Miscompilation.cpp bugpoint.cpp Message-ID: <200407230130.UAA15872@zion.cs.uiuc.edu> Changes in directory llvm/tools/bugpoint: BugDriver.cpp updated: 1.34 -> 1.35 CrashDebugger.cpp updated: 1.35 -> 1.36 ExecutionDriver.cpp updated: 1.45 -> 1.46 Miscompilation.cpp updated: 1.50 -> 1.51 bugpoint.cpp updated: 1.17 -> 1.18 --- Log message: * Convert "\n" -> '\n' * Print out another '\n' after printing out program execution status * Make sure code wraps at 80 cols --- Diffs of the changes: (+21 -20) Index: llvm/tools/bugpoint/BugDriver.cpp diff -u llvm/tools/bugpoint/BugDriver.cpp:1.34 llvm/tools/bugpoint/BugDriver.cpp:1.35 --- llvm/tools/bugpoint/BugDriver.cpp:1.34 Sun Jul 4 07:20:55 2004 +++ llvm/tools/bugpoint/BugDriver.cpp Thu Jul 22 20:30:49 2004 @@ -79,7 +79,7 @@ << InputFilename << "'!\n"; } } catch (const ParseException &E) { - std::cerr << "bugpoint: " << E.getMessage() << "\n"; + std::cerr << "bugpoint: " << E.getMessage() << '\n'; Result = 0; } return Result; @@ -107,7 +107,7 @@ std::string ErrorMessage; if (LinkModules(Program, M.get(), &ErrorMessage)) { std::cerr << ToolName << ": error linking in '" << Filenames[i] << "': " - << ErrorMessage << "\n"; + << ErrorMessage << '\n'; return true; } } @@ -143,7 +143,7 @@ std::cout << "Running the code generator to test for a crash: "; try { compileProgram(Program); - std::cout << "\n"; + std::cout << '\n'; } catch (ToolExecutionError &TEE) { std::cout << TEE.what(); return debugCodeGeneratorCrash(); @@ -160,7 +160,7 @@ try { ReferenceOutputFile = executeProgramWithCBE("bugpoint.reference.out"); CreatedOutput = true; - std::cout << "Reference output is: " << ReferenceOutputFile << "\n"; + std::cout << "Reference output is: " << ReferenceOutputFile << '\n'; } catch (ToolExecutionError &TEE) { std::cerr << TEE.what(); if (Interpreter != cbe) { Index: llvm/tools/bugpoint/CrashDebugger.cpp diff -u llvm/tools/bugpoint/CrashDebugger.cpp:1.35 llvm/tools/bugpoint/CrashDebugger.cpp:1.36 --- llvm/tools/bugpoint/CrashDebugger.cpp:1.35 Tue May 25 03:53:40 2004 +++ llvm/tools/bugpoint/CrashDebugger.cpp Thu Jul 22 20:30:49 2004 @@ -329,7 +329,7 @@ do { --Simplification; std::cout << "\n*** Attempting to reduce testcase by deleting instruc" - << "tions: Simplification Level #" << Simplification << "\n"; + << "tions: Simplification Level #" << Simplification << '\n'; // Now that we have deleted the functions that are unnecessary for the // program, try to remove instructions that are not necessary to cause the @@ -416,7 +416,7 @@ std::cout << "\n*** Found crashing pass" << (PassesToRun.size() == 1 ? ": " : "es: ") - << getPassesString(PassesToRun) << "\n"; + << getPassesString(PassesToRun) << '\n'; EmitProgressBytecode("passinput"); @@ -425,8 +425,9 @@ static bool TestForCodeGenCrash(BugDriver &BD, Module *M) { try { - std::cerr << "\n"; + std::cerr << '\n'; BD.compileProgram(M); + std::cerr << '\n'; return false; } catch (ToolExecutionError &TEE) { std::cerr << "\n"; Index: llvm/tools/bugpoint/ExecutionDriver.cpp diff -u llvm/tools/bugpoint/ExecutionDriver.cpp:1.45 llvm/tools/bugpoint/ExecutionDriver.cpp:1.46 --- llvm/tools/bugpoint/ExecutionDriver.cpp:1.45 Wed Jul 21 15:50:33 2004 +++ llvm/tools/bugpoint/ExecutionDriver.cpp Thu Jul 22 20:30:49 2004 @@ -42,7 +42,7 @@ cl::opt CheckProgramExitCode("check-exit-code", - cl::desc("Assume nonzero exit code is failure (default on)"), + cl::desc("Assume nonzero exit code is failure (default on)"), cl::init(true)); cl::opt @@ -279,7 +279,7 @@ bool FilesDifferent = false; if (DiffFiles(ReferenceOutputFile, Output, &Error)) { if (!Error.empty()) { - std::cerr << "While diffing output: " << Error << "\n"; + std::cerr << "While diffing output: " << Error << '\n'; exit(1); } FilesDifferent = true; Index: llvm/tools/bugpoint/Miscompilation.cpp diff -u llvm/tools/bugpoint/Miscompilation.cpp:1.50 llvm/tools/bugpoint/Miscompilation.cpp:1.51 --- llvm/tools/bugpoint/Miscompilation.cpp:1.50 Sat Jul 17 19:44:37 2004 +++ llvm/tools/bugpoint/Miscompilation.cpp Thu Jul 22 20:30:49 2004 @@ -174,7 +174,7 @@ if (!DeleteInputs) M1 = CloneModule(M1); if (LinkModules(M1, M2, &ErrorMsg)) { std::cerr << BD.getToolName() << ": Error linking modules together:" - << ErrorMsg << "\n"; + << ErrorMsg << '\n'; exit(1); } if (DeleteInputs) delete M2; // We are done with this module... @@ -203,7 +203,7 @@ << " run through the pass" << (BD.getPassesToRun().size() == 1 ? "" : "es") << ":"; PrintFunctionList(Funcs); - std::cout << "\n"; + std::cout << '\n'; // Split the module into the two halves of the program we want. Module *ToNotOptimize = CloneModule(BD.getProgram()); @@ -296,7 +296,7 @@ std::string ErrorMsg; if (LinkModules(ToNotOptimize, ToOptimizeLoopExtracted, &ErrorMsg)) { std::cerr << BD.getToolName() << ": Error linking modules together:" - << ErrorMsg << "\n"; + << ErrorMsg << '\n'; exit(1); } @@ -359,7 +359,7 @@ } else { std::cout << "blocks are extracted."; } - std::cout << "\n"; + std::cout << '\n'; // Split the module into the two halves of the program we want. Module *ToNotOptimize = CloneModule(BD.getProgram()); @@ -426,7 +426,7 @@ std::string ErrorMsg; if (LinkModules(ProgClone, Extracted, &ErrorMsg)) { std::cerr << BD.getToolName() << ": Error linking modules together:" - << ErrorMsg << "\n"; + << ErrorMsg << '\n'; exit(1); } @@ -473,7 +473,7 @@ << (MiscompiledFunctions.size() == 1 ? " is" : "s are") << " being miscompiled: "; PrintFunctionList(MiscompiledFunctions); - std::cout << "\n"; + std::cout << '\n'; // See if we can rip any loops out of the miscompiled functions and still // trigger the problem. @@ -493,7 +493,7 @@ << (MiscompiledFunctions.size() == 1 ? " is" : "s are") << " being miscompiled: "; PrintFunctionList(MiscompiledFunctions); - std::cout << "\n"; + std::cout << '\n'; } if (ExtractBlocks(BD, TestFn, MiscompiledFunctions)) { @@ -512,7 +512,7 @@ << (MiscompiledFunctions.size() == 1 ? " is" : "s are") << " being miscompiled: "; PrintFunctionList(MiscompiledFunctions); - std::cout << "\n"; + std::cout << '\n'; } return MiscompiledFunctions; @@ -552,7 +552,7 @@ std::cout << "\n*** Found miscompiling pass" << (getPassesToRun().size() == 1 ? "" : "es") << ": " - << getPassesString(getPassesToRun()) << "\n"; + << getPassesString(getPassesToRun()) << '\n'; EmitProgressBytecode("passinput"); std::vector MiscompiledFunctions = @@ -807,7 +807,7 @@ } for (unsigned i=0, e = InputArgv.size(); i != e; ++i) std::cout << " " << InputArgv[i]; - std::cout << "\n"; + std::cout << '\n'; std::cout << "The shared object was created with:\n llc -march=c " << SafeModuleBC << " -o temporary.c\n" << " gcc -xc temporary.c -O2 -o " << SharedObject Index: llvm/tools/bugpoint/bugpoint.cpp diff -u llvm/tools/bugpoint/bugpoint.cpp:1.17 llvm/tools/bugpoint/bugpoint.cpp:1.18 --- llvm/tools/bugpoint/bugpoint.cpp:1.17 Sat Jul 10 20:06:20 2004 +++ llvm/tools/bugpoint/bugpoint.cpp Thu Jul 22 20:30:49 2004 @@ -57,7 +57,7 @@ try { return D.run(); } catch (ToolExecutionError &TEE) { - std::cerr << "Tool execution error: " << TEE.what() << "\n"; + std::cerr << "Tool execution error: " << TEE.what() << '\n'; return 1; } catch (...) { std::cerr << "Whoops, an exception leaked out of bugpoint. " From gaeke at cs.uiuc.edu Fri Jul 23 00:00:12 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Fri, 23 Jul 2004 00:00:12 -0500 (CDT) Subject: [llvm-commits] CVS: reopt/include/reopt/UnpackTraceFunction.h Message-ID: <200407230500.AAA08856@seraph.cs.uiuc.edu> Changes in directory reopt/include/reopt: UnpackTraceFunction.h updated: 1.13 -> 1.14 --- Log message: rewriteProlog and rewriteEpilog don't need to take MachineFunction arguments. Add prototype for new runOnMachineBasicBlock method. --- Diffs of the changes: (+3 -3) Index: reopt/include/reopt/UnpackTraceFunction.h diff -u reopt/include/reopt/UnpackTraceFunction.h:1.13 reopt/include/reopt/UnpackTraceFunction.h:1.14 --- reopt/include/reopt/UnpackTraceFunction.h:1.13 Thu Jul 15 16:53:32 2004 +++ reopt/include/reopt/UnpackTraceFunction.h Fri Jul 23 00:00:01 2004 @@ -62,7 +62,7 @@ void PrintValueAIs (const std::string &ValueName, const AllocInfo &MatrixAI, const AllocInfo &TraceAI) const; - void rewriteProlog (MachineFunction &MF, MachineBasicBlock &MBB); + void rewriteProlog (MachineBasicBlock &MBB); void copyConstantToRegister (MachineFunction &MF, Constant *C, unsigned Reg, unsigned SpareReg, std::vector &mvec); @@ -73,8 +73,8 @@ const PHINode *PN); bool rewriteEpilogInstr (MachineBasicBlock &MBB, MachineBasicBlock::iterator iter); - void rewriteEpilog (MachineFunction &MF, MachineBasicBlock &MBB); - + void rewriteEpilog (MachineBasicBlock &MBB); + bool runOnMachineBasicBlock (MachineBasicBlock &MBB); public: UnpackTraceFunction (TargetMachine *TM_) : TM (TM_), TF (0) { } void setTraceFunction (TraceFunction *TF_) { TF = TF_; } From gaeke at cs.uiuc.edu Fri Jul 23 00:00:13 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Fri, 23 Jul 2004 00:00:13 -0500 (CDT) Subject: [llvm-commits] CVS: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp Message-ID: <200407230500.AAA08863@seraph.cs.uiuc.edu> Changes in directory reopt/lib/LightWtProfiling: UnpackTraceFunction.cpp updated: 1.102 -> 1.103 --- Log message: Add new runOnMachineBasicBlock method to encapsulate all the rewrites that are common to all MBBs. Use one common definition of sp, g3, MatrixFP, etc. for the whole file. Eliminate FMOVDs at the beginning of the function which are inserted by the register allocator (why does it do this???) Swap MatrixFP and TraceFP when we make a function call from on-trace. This fixes Olden/em3d. --- Diffs of the changes: (+67 -36) Index: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp diff -u reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.102 reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.103 --- reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.102 Wed Jul 21 15:53:28 2004 +++ reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp Fri Jul 23 00:00:03 2004 @@ -65,6 +65,10 @@ extern std::pair GetValueAllocState (TraceFunction *TF, Value *V, bool preferLiveIn = true); +// Commonly used registers: +static const unsigned sp = SparcV9::o6, MatrixFP = SparcV9::i6, + TraceFP = SparcV9::g1, g2 = SparcV9::g2, g3 = SparcV9::g3; + /// Fill in the set of registers used in this function, which is kept in /// 'RegsToSave' in the UnpackTraceFunction Pass object, and is used by /// rewriteProlog() and rewriteEpilog(). Registers are @@ -97,6 +101,7 @@ } } } + RegsToSave.insert (MatrixFP); // Deal with some sparc lunacy: If any of the floatcc regs are used, then we // only put %fsr in the set, not the floatcc regs which were actually used. @@ -171,16 +176,12 @@ std::cerr << " in TraceFn\n"; } -void UnpackTraceFunction::rewriteProlog (MachineFunction &MF, - MachineBasicBlock &EntryBB) { - const SparcV9RegInfo &TRI = *TM->getRegInfo (); - static const unsigned sp = SparcV9::o6, MatrixFP = SparcV9::i6, - TraceFP = SparcV9::g1, g2 = SparcV9::g2; - +void UnpackTraceFunction::rewriteProlog (MachineBasicBlock &EntryBB) { // UTF prolog: start out by clearing SAVE and stack-load instructions out // of the entry BB. while (EntryBB.front().getOpcode() == V9::SAVEi - || EntryBB.front().getOpcode() == V9::LDXi) + || EntryBB.front().getOpcode() == V9::LDXi + || EntryBB.front().getOpcode() == V9::FMOVD) EntryBB.pop_front(); std::vector E; @@ -197,6 +198,7 @@ // 2. Save used registers onto the stack. std::vector mvec; int RegType; + const SparcV9RegInfo &TRI = *TM->getRegInfo (); for (std::set::iterator i = RegsToSave.begin (), e = RegsToSave.end (); i != e; ++i) { mvec.clear (); @@ -340,8 +342,6 @@ const AllocInfo &Target, Value *liveOutValue, Value *liveOutTraceValue) { const SparcV9RegInfo &TRI = *TM->getRegInfo (); std::vector mvec; - static const unsigned sp = SparcV9::o6, TraceFP = SparcV9::g1, - g2 = SparcV9::g2, g3 = SparcV9::g3, MatrixFP = SparcV9::i6; assert ((Target.AllocState == AllocInfo::Allocated || Target.AllocState == AllocInfo::Spilled) @@ -445,8 +445,6 @@ bool UnpackTraceFunction::rewriteEpilogInstr (MachineBasicBlock &MBB, MachineBasicBlock::iterator iter){ - static const unsigned sp = SparcV9::o6, g1 = SparcV9::g1, - g2 = SparcV9::g2, g3 = SparcV9::g3; const TargetInstrInfo &TII = *TM->getInstrInfo (); const SparcV9RegInfo &TRI = *TM->getRegInfo (); MachineInstr &inst = *iter; @@ -492,7 +490,6 @@ RegsToSave.insert (MatrixReg); } else if (MatrixAI.AllocState == AllocInfo::Spilled) { // MatrixAI.Placement is the stack slot allocated to V in MatrixFn. - static const unsigned MatrixFP = SparcV9::i6; // Store it into its stack slot on MatrixFn's stack. // using MatrixFn's frame pointer as the base register. newBaseReg = MatrixFP; @@ -527,8 +524,7 @@ return false; // Don't delete the instr. } -void UnpackTraceFunction::rewriteEpilog (MachineFunction &MF, - MachineBasicBlock &MBB) { +void UnpackTraceFunction::rewriteEpilog (MachineBasicBlock &MBB) { // Rewrite any stores into live-out pseudo-arguments to store into stack // slots instead. Delete old epilog leftovers in the process. for (MachineBasicBlock::iterator i = MBB.begin (), e = MBB.end (); i != e; ) { @@ -556,12 +552,12 @@ // eliminate them by inserting copies now. for (BasicBlock::const_iterator Inst = RBB->begin (); const PHINode *PN = dyn_cast (Inst); ++Inst) - eliminatePhiAtTraceExit (MF, MBB, PN); + eliminatePhiAtTraceExit (*MBB.getParent (), MBB, PN); - static const unsigned sp = SparcV9::o6, g2 = SparcV9::g2; std::vector mvec; const SparcV9RegInfo &TRI = *TM->getRegInfo (); + RegsToSave.erase (MatrixFP); // Get the set of registers used in this function which we saved in // findRegsToSave, earlier, and restore all used registers from stack // except SP. @@ -597,6 +593,57 @@ BuildMI (&MBB, V9::NOP, 0); } +bool UnpackTraceFunction::runOnMachineBasicBlock (MachineBasicBlock &MBB) { + const SparcV9RegInfo &TRI = *TM->getRegInfo (); + if (&MBB == &MBB.getParent()->front()) { + // Rewrite function prolog, found in the entry MachineBasicBlock. + rewriteProlog (MBB); + return true; + } + for (MachineBasicBlock::iterator BI = MBB.begin (); BI != MBB.end (); ++BI) { + // Rewrite references to %fp to use TraceFP (%g1) instead. + for (unsigned i = 0; i < BI->getNumOperands(); ++i) + if (BI->getOperand (i).hasAllocatedReg () + && BI->getOperand (i).getReg () == MatrixFP) + BI->SetMachineOperandReg (i, TraceFP); + // If this is a CALL, add compensation code around it. + if (BI->getOpcode() == V9::CALL || BI->getOpcode() == V9::JMPLCALLi) { + std::vector mvec; + // Save TraceFP on the stack. + TRI.cpReg2MemMI (mvec, TraceFP, sp, stackOffsetForReg (TraceFP), + TRI.getRegType (TraceFP), g2); + // Let fp = g1. + mvec.push_back (BuildMI (V9::ORr, 3).addMReg (TraceFP).addZImm (0) + .addMReg (MatrixFP, MachineOperand::Def)); + // Insert all the instrs into the MBB after the call instruction. + for (std::vector::iterator ei = mvec.begin (), + ee = mvec.end (); ei != ee; ++ei) { + BI = MBB.insert (BI, *ei); + ++BI; + } + ++BI; // Skip over the call instruction. + ++BI; // Skip over the delay slot. + // Load saved TraceFP and MatrixFP off the TraceFn stack. + mvec.clear(); + TRI.cpMem2RegMI (mvec, sp, stackOffsetForReg (MatrixFP), MatrixFP, + TRI.getRegType (MatrixFP), g2); + TRI.cpMem2RegMI (mvec, sp, stackOffsetForReg (TraceFP), TraceFP, + TRI.getRegType (TraceFP), g2); + // Insert all the instrs into the MBB after the call instruction. + for (std::vector::iterator ei = mvec.begin (), + ee = mvec.end (); ei != ee; ++ei) { + BI = MBB.insert (BI, *ei); + ++BI; + } + --BI; + } + } + // Rewrite function epilogs, found in every exit MachineBasicBlock of MF. + if (containsReturnInstr (MBB)) + rewriteEpilog (MBB); + return true; // MachineBasicBlock was modified +} + /// runOnMachineFunction - Prepare MF, which is the machine code for /// TF->TraceFn, to be executed using a low-overhead calling convention for /// traces. We use the live-variable and return-block information in TF and the @@ -627,29 +674,13 @@ DEBUG(std::cerr << "UnpackTraceFunction: Stack sizes: static = " << StaticStackSize << ", total = " << TotalStackSize << "\n"); - for (MachineFunction::iterator I = MF.begin (), E = MF.end (); I != E; ++I) { - MachineBasicBlock &MBB = *I; - static const unsigned fp = SparcV9::i6, TraceFP = SparcV9::g1; - if (I == MF.begin()) { - // Rewrite function prolog, found in the entry MachineBasicBlock of MF. - rewriteProlog (MF, MBB); - continue; - } - // Rewrite references to %fp to use TraceFP (%g1) instead. - for (MachineBasicBlock::iterator BI = MBB.begin (), BE = MBB.end (); - BI != BE; ++BI) - for (unsigned i = 0; i < BI->getNumOperands(); ++i) - if (BI->getOperand (i).hasAllocatedReg () - && BI->getOperand (i).getReg () == fp) - BI->SetMachineOperandReg (i, TraceFP); - // Rewrite function epilogs, found in every exit MachineBasicBlock of MF. - if (containsReturnInstr (MBB)) - rewriteEpilog (MF, MBB); - } + bool Changed = false; + for (MachineFunction::iterator I = MF.begin (), E = MF.end (); I != E; ++I) + Changed |= runOnMachineBasicBlock (*I); DEBUG(std::cerr << "UnpackTraceFunction: done unpacking " << MF.getFunction()->getName() << "()\n"); - return true; // MachineFunction was modified + return Changed; } } // end namespace llvm From gaeke at cs.uiuc.edu Fri Jul 23 00:00:14 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Fri, 23 Jul 2004 00:00:14 -0500 (CDT) Subject: [llvm-commits] CVS: reopt/test/Makefile Message-ID: <200407230500.AAA08870@seraph.cs.uiuc.edu> Changes in directory reopt/test: Makefile updated: 1.6 -> 1.7 --- Log message: Don't set LARGE_PROBLEM_SIZE here. We're all grown up, we can set environment variables ourselves. --- Diffs of the changes: (+0 -2) Index: reopt/test/Makefile diff -u reopt/test/Makefile:1.6 reopt/test/Makefile:1.7 --- reopt/test/Makefile:1.6 Fri Jun 25 03:04:02 2004 +++ reopt/test/Makefile Fri Jul 23 00:00:04 2004 @@ -11,8 +11,6 @@ LEVEL = .. include $(LEVEL)/Makefile.common -export LARGE_PROBLEM_SIZE - # test target - Descend into test/Programs and run the TEST.reopt.Makefile # tests... test:: From gaeke at cs.uiuc.edu Fri Jul 23 00:00:15 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Fri, 23 Jul 2004 00:00:15 -0500 (CDT) Subject: [llvm-commits] CVS: reopt/test/run-tests Message-ID: <200407230500.AAA08877@seraph.cs.uiuc.edu> Changes in directory reopt/test: run-tests updated: 1.14 -> 1.15 --- Log message: Don't set LARGE_PROBLEM_SIZE here. We're all grown up, we can set environment variables ourselves. Add em3d, bh run lines. --- Diffs of the changes: (+3 -3) Index: reopt/test/run-tests diff -u reopt/test/run-tests:1.14 reopt/test/run-tests:1.15 --- reopt/test/run-tests:1.14 Wed Jul 21 15:18:46 2004 +++ reopt/test/run-tests Fri Jul 23 00:00:05 2004 @@ -70,6 +70,8 @@ shootout) SUBDIR=SingleSource/Benchmarks/Shootout ;; stanford) SUBDIR=SingleSource/Benchmarks/Stanford ;; olden) SUBDIR=MultiSource/Benchmarks/Olden ;; + em3d) SUBDIR=MultiSource/Benchmarks/Olden/em3d ;; + bh) SUBDIR=MultiSource/Benchmarks/Olden/bh ;; mcf) SUBDIR=External/SPEC/CINT2000/181.mcf; spectest=1 ;; art) SUBDIR=External/SPEC/CFP2000/179.art; spectest=1;; @@ -118,9 +120,7 @@ LLVM_REOPT="--skip-trace=$skiptrace $LLVM_REOPT" export LLVM_REOPT fi - if [ "$benchmk" = "olden" ]; then - exec gmake SUBDIR=$SUBDIR LARGE_PROBLEM_SIZE=1 - elif [ $spectest -eq 1 ]; then + if [ $spectest -eq 1 ]; then exec gmake SUBDIR=$SUBDIR SPECTEST=1 else exec gmake SUBDIR=$SUBDIR From lattner at cs.uiuc.edu Fri Jul 23 00:26:15 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 23 Jul 2004 00:26:15 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervals.h LiveIntervals.cpp Message-ID: <200407230526.AAA28773@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveIntervals.h updated: 1.29 -> 1.30 LiveIntervals.cpp updated: 1.102 -> 1.103 --- Log message: Force coallescing of live ranges that have a single definition, even if they interfere. Because these intervals have a single definition, and one of them is a copy instruction, they are always safe to merge even if their lifetimes interfere. This slightly reduces the amount of spill code, for example on 252.eon, from: 12837 spiller - Number of loads added 7604 spiller - Number of stores added 5842 spiller - Number of register spills 18155 liveintervals - Number of identity moves eliminated after coalescing to: 12754 spiller - Number of loads added 7585 spiller - Number of stores added 5803 spiller - Number of register spills 18262 liveintervals - Number of identity moves eliminated after coalescing The much much bigger win would be to merge intervals with multiple definitions (aka phi nodes) but this is not that day. --- Diffs of the changes: (+30 -9) Index: llvm/lib/CodeGen/LiveIntervals.h diff -u llvm/lib/CodeGen/LiveIntervals.h:1.29 llvm/lib/CodeGen/LiveIntervals.h:1.30 --- llvm/lib/CodeGen/LiveIntervals.h:1.29 Mon Jul 19 09:08:10 2004 +++ llvm/lib/CodeGen/LiveIntervals.h Fri Jul 23 00:26:05 2004 @@ -36,6 +36,7 @@ float weight; // weight of this interval: // (number of uses *10^loopDepth) Ranges ranges; // the ranges in which this register is live + bool isDefinedOnce; // True if there is one def of this register explicit LiveInterval(unsigned r); Index: llvm/lib/CodeGen/LiveIntervals.cpp diff -u llvm/lib/CodeGen/LiveIntervals.cpp:1.102 llvm/lib/CodeGen/LiveIntervals.cpp:1.103 --- llvm/lib/CodeGen/LiveIntervals.cpp:1.102 Thu Jul 22 16:54:22 2004 +++ llvm/lib/CodeGen/LiveIntervals.cpp Fri Jul 23 00:26:05 2004 @@ -285,6 +285,9 @@ // done once for the vreg. We use an empty interval to detect the first // time we see a vreg. if (interval.empty()) { + // Assume this interval is singly defined until we find otherwise. + interval.isDefinedOnce = true; + // Get the Idx of the defining instructions. unsigned defIndex = getDefIndex(getInstructionIndex(mi)); @@ -357,6 +360,7 @@ interval.addRange(defIndex, getInstructionIndex(&mbb->back()) + InstrSlots::NUM); } + interval.isDefinedOnce = false; } DEBUG(std::cerr << '\n'); @@ -524,6 +528,9 @@ Intervals::iterator intA = r2iA->second; Intervals::iterator intB = r2iB->second; + DEBUG(std::cerr << "\t\tInspecting " << *intA << " and " << *intB + << ": "); + // both A and B are virtual registers if (MRegisterInfo::isVirtualRegister(intA->reg) && MRegisterInfo::isVirtualRegister(intB->reg)) { @@ -531,19 +538,26 @@ const TargetRegisterClass *rcA, *rcB; rcA = mf_->getSSARegMap()->getRegClass(intA->reg); rcB = mf_->getSSARegMap()->getRegClass(intB->reg); + // if they are not of the same register class we continue - if (rcA != rcB) + if (rcA != rcB) { + DEBUG(std::cerr << "Differing reg classes.\n"); continue; + } // if their intervals do not overlap we join them - if (!intB->overlaps(*intA)) { + if ((intA->isDefinedOnce && intB->isDefinedOnce) || + !intB->overlaps(*intA)) { intA->join(*intB); + DEBUG(std::cerr << "Joined. Result = " << *intA << "\n"); r2iB->second = r2iA->second; r2rMap_.insert(std::make_pair(intB->reg, intA->reg)); intervals_.erase(intB); + } else { + DEBUG(std::cerr << "Interference!\n"); } - } else if (MRegisterInfo::isPhysicalRegister(intA->reg) ^ - MRegisterInfo::isPhysicalRegister(intB->reg)) { + } else if (!MRegisterInfo::isPhysicalRegister(intA->reg) || + !MRegisterInfo::isPhysicalRegister(intB->reg)) { if (MRegisterInfo::isPhysicalRegister(intB->reg)) { std::swap(regA, regB); std::swap(intA, intB); @@ -558,16 +572,23 @@ rcA = mri_->getRegClass(intA->reg); rcB = mf_->getSSARegMap()->getRegClass(intB->reg); // if they are not of the same register class we continue - if (rcA != rcB) + if (rcA != rcB) { + DEBUG(std::cerr << "Differing reg classes.\n"); continue; + } if (!intA->overlaps(*intB) && !overlapsAliases(*intA, *intB)) { intA->join(*intB); + DEBUG(std::cerr << "Joined. Result = " << *intA << "\n"); r2iB->second = r2iA->second; r2rMap_.insert(std::make_pair(intB->reg, intA->reg)); intervals_.erase(intB); + } else { + DEBUG(std::cerr << "Interference!\n"); } + } else { + DEBUG(std::cerr << "Cannot join physregs.\n"); } } } @@ -642,8 +663,8 @@ LiveInterval::LiveInterval(unsigned r) : reg(r), - weight((MRegisterInfo::isPhysicalRegister(r) ? HUGE_VAL : 0.0F)) -{ + weight((MRegisterInfo::isPhysicalRegister(r) ? HUGE_VAL : 0.0F)), + isDefinedOnce(false) { } bool LiveInterval::spilled() const @@ -740,8 +761,8 @@ void LiveInterval::join(const LiveInterval& other) { - DEBUG(std::cerr << "\t\tjoining " << *this << " with " << other); Ranges::iterator cur = ranges.begin(); + isDefinedOnce &= other.isDefinedOnce; for (Ranges::const_iterator i = other.ranges.begin(), e = other.ranges.end(); i != e; ++i) { @@ -751,7 +772,6 @@ } weight += other.weight; ++numJoins; - DEBUG(std::cerr << ". Result = " << *this << "\n"); } LiveInterval::Ranges::iterator LiveInterval:: From lattner at cs.uiuc.edu Fri Jul 23 00:27:54 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 23 Jul 2004 00:27:54 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/PHIElimination.cpp Message-ID: <200407230527.AAA28864@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: PHIElimination.cpp updated: 1.31 -> 1.32 --- Log message: Update live intervals more accurately for PHI elim. This slightly reduces the live intervals for some registers. --- Diffs of the changes: (+6 -10) Index: llvm/lib/CodeGen/PHIElimination.cpp diff -u llvm/lib/CodeGen/PHIElimination.cpp:1.31 llvm/lib/CodeGen/PHIElimination.cpp:1.32 --- llvm/lib/CodeGen/PHIElimination.cpp:1.31 Thu Jul 22 18:05:12 2004 +++ llvm/lib/CodeGen/PHIElimination.cpp Fri Jul 23 00:27:43 2004 @@ -131,18 +131,9 @@ std::pair RKs = LV->killed_range(MPhi); std::vector > Range; - if (RKs.first != RKs.second) { - // Copy the range into a vector... - Range.assign(RKs.first, RKs.second); - - // Delete the range... + if (RKs.first != RKs.second) // Delete the range. LV->removeVirtualRegistersKilled(RKs.first, RKs.second); - // Add all of the kills back, which will update the appropriate info... - for (unsigned i = 0, e = Range.size(); i != e; ++i) - LV->addVirtualRegisterKilled(Range[i].second, PHICopy); - } - RKs = LV->dead_range(MPhi); if (RKs.first != RKs.second) { // Works as above... @@ -252,6 +243,11 @@ if (!ValueIsLive) { MachineBasicBlock::iterator Prev = prior(I); LV->addVirtualRegisterKilled(SrcReg, Prev); + + // This vreg no longer lives all of the way through opBlock. + unsigned opBlockNum = opBlock.getNumber(); + if (opBlockNum < InRegVI.AliveBlocks.size()) + InRegVI.AliveBlocks[opBlockNum] = false; } } } From lattner at cs.uiuc.edu Fri Jul 23 01:47:05 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 23 Jul 2004 01:47:05 -0500 Subject: [llvm-commits] CVS: llvm/test/Programs/Makefile.programs Message-ID: <200407230647.BAA29508@apoc.cs.uiuc.edu> Changes in directory llvm/test/Programs: Makefile.programs updated: 1.131 -> 1.132 --- Log message: Switch linscan column to iterativescan --- Diffs of the changes: (+3 -3) Index: llvm/test/Programs/Makefile.programs diff -u llvm/test/Programs/Makefile.programs:1.131 llvm/test/Programs/Makefile.programs:1.132 --- llvm/test/Programs/Makefile.programs:1.131 Mon Jun 21 21:28:05 2004 +++ llvm/test/Programs/Makefile.programs Fri Jul 23 01:46:55 2004 @@ -292,7 +292,7 @@ $(PROGRAMS_TO_TEST:%=Output/%.llc-ls.s): \ Output/%.llc-ls.s: Output/%.llvm.bc $(LLC) - -$(LLC) $(LLCFLAGS) -f -regalloc=linearscan $< -o $@ + -$(LLC) $(LLCFLAGS) -f -regalloc=iterativescan $< -o $@ ## Alternative command to run llc remotely on another machine: @@ -353,7 +353,7 @@ $(PROGRAMS_TO_TEST:%=Output/%.out-jit-ls): \ Output/%.out-jit-ls: Output/%.llvm.bc $(LLI) - -$(RUNSAFELY) $(STDIN_FILENAME) $@ $(LLI) -regalloc=linearscan $(JIT_OPTS) $< $(RUN_OPTIONS) + -$(RUNSAFELY) $(STDIN_FILENAME) $@ $(LLI) -regalloc=iterativescan $(JIT_OPTS) $< $(RUN_OPTIONS) ifdef PROGRAM_REQUIRED_TO_EXIT_OK @if test \! -f $@.exitok; then echo "TEST (jit-ls): $* FAILED!"; rm -f $@; fi endif @@ -393,7 +393,7 @@ $(PROGRAMS_TO_TEST:%=Output/%.bugpoint-llc-ls): \ Output/%.bugpoint-llc-ls: Output/%.llvm.bc $(LBUGPOINT) Output/%.out-nat - $(LBUGPOINT) $< -run-llc $(BUGPOINT_OPTIONS) -regalloc=linearscan $(BUGPOINT_ARGS) + $(LBUGPOINT) $< -run-llc $(BUGPOINT_OPTIONS) -regalloc=iterativescan $(BUGPOINT_ARGS) $(PROGRAMS_TO_TEST:%=Output/%.bugpoint-jit): \ Output/%.bugpoint-jit: Output/%.llvm.bc $(LBUGPOINT) Output/%.out-nat From lattner at cs.uiuc.edu Fri Jul 23 01:47:49 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 23 Jul 2004 01:47:49 -0500 Subject: [llvm-commits] CVS: llvm/test/Programs/External/SPEC/Makefile.spec Message-ID: <200407230647.BAA29521@apoc.cs.uiuc.edu> Changes in directory llvm/test/Programs/External/SPEC: Makefile.spec updated: 1.32 -> 1.33 --- Log message: Switch linscan column to iterative scan now that linscan is the default --- Diffs of the changes: (+3 -3) Index: llvm/test/Programs/External/SPEC/Makefile.spec diff -u llvm/test/Programs/External/SPEC/Makefile.spec:1.32 llvm/test/Programs/External/SPEC/Makefile.spec:1.33 --- llvm/test/Programs/External/SPEC/Makefile.spec:1.32 Thu Jul 8 11:19:42 2004 +++ llvm/test/Programs/External/SPEC/Makefile.spec Fri Jul 23 01:47:38 2004 @@ -84,7 +84,7 @@ Output/%.out-jit-ls: Output/%.llvm.bc $(LLI) $(SPEC_SANDBOX) jit-ls-$(RUN_TYPE) $@ $(REF_IN_DIR) \ $(RUNSAFELY) $(STDIN_FILENAME) $(STDOUT_FILENAME) \ - $(LLI) -regalloc=linearscan $(JIT_OPTS) ../../$< $(RUN_OPTIONS) + $(LLI) -regalloc=iterativescan $(JIT_OPTS) ../../$< $(RUN_OPTIONS) -(cd Output/jit-ls-$(RUN_TYPE); cat $(LOCAL_OUTPUTS)) > $@ -cp Output/jit-ls-$(RUN_TYPE)/$(STDOUT_FILENAME).time $@.time @@ -161,7 +161,7 @@ Output/%.bugpoint-llc-ls: Output/%.llvm.bc $(LBUGPOINT) Output/%.out-nat $(SPEC_SANDBOX) bugpoint-$(RUN_TYPE) $@ $(REF_IN_DIR) \ $(LBUGPOINT) ../../$< -run-llc $(BUGPOINT_OPTIONS) \ - -regalloc=linearscan $(BUGPOINT_ARGS) + -regalloc=iterativescan $(BUGPOINT_ARGS) @echo "===> Leaving Output/bugpoint-$(RUN_TYPE)" $(PROGRAMS_TO_TEST:%=Output/%.bugpoint-jit): \ @@ -174,7 +174,7 @@ Output/%.bugpoint-jit-ls: Output/%.llvm.bc $(LBUGPOINT) Output/%.out-nat $(SPEC_SANDBOX) bugpoint-$(RUN_TYPE) $@ $(REF_IN_DIR) \ $(LBUGPOINT) ../../$< -run-jit $(BUGPOINT_OPTIONS) \ - -regalloc=linearscan $(BUGPOINT_ARGS) + -regalloc=iterativescan $(BUGPOINT_ARGS) @echo "===> Leaving Output/bugpoint-$(RUN_TYPE)" From lattner at cs.uiuc.edu Fri Jul 23 01:49:41 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 23 Jul 2004 01:49:41 -0500 Subject: [llvm-commits] CVS: llvm/test/Programs/TEST.nightly.Makefile TEST.nightly.report Message-ID: <200407230649.BAA29540@apoc.cs.uiuc.edu> Changes in directory llvm/test/Programs: TEST.nightly.Makefile updated: 1.31 -> 1.32 TEST.nightly.report updated: 1.24 -> 1.25 --- Log message: Switch columns to "beta" instead of "ls" --- Diffs of the changes: (+5 -5) Index: llvm/test/Programs/TEST.nightly.Makefile diff -u llvm/test/Programs/TEST.nightly.Makefile:1.31 llvm/test/Programs/TEST.nightly.Makefile:1.32 --- llvm/test/Programs/TEST.nightly.Makefile:1.31 Sat Jun 19 18:30:16 2004 +++ llvm/test/Programs/TEST.nightly.Makefile Fri Jul 23 01:49:31 2004 @@ -71,7 +71,7 @@ echo "TEST-FAIL: llc $(RELDIR)/$*" >> $@;\ fi -# LLC-linearscan tests +# LLC experimental tests $(PROGRAMS_TO_TEST:%=Output/%.nightly.llc-ls.report.txt): \ Output/%.nightly.llc-ls.report.txt: Output/%.llvm.bc Output/%.exe-llc-ls $(LLC) @echo > $@ @@ -124,7 +124,7 @@ echo "TEST-FAIL: jit $(RELDIR)/$*" >> $@;\ fi -# JIT-linearscan tests +# JIT experimental tests $(PROGRAMS_TO_TEST:%=Output/%.nightly.jit-ls.report.txt): \ Output/%.nightly.jit-ls.report.txt: Output/%.llvm.bc Output/%.exe-jit-ls $(JIT) @echo > $@ Index: llvm/test/Programs/TEST.nightly.report diff -u llvm/test/Programs/TEST.nightly.report:1.24 llvm/test/Programs/TEST.nightly.report:1.25 --- llvm/test/Programs/TEST.nightly.report:1.24 Sat Jun 19 18:30:16 2004 +++ llvm/test/Programs/TEST.nightly.report Fri Jul 23 01:49:31 2004 @@ -70,10 +70,10 @@ ["GCC" , 'TEST-RESULT-nat-time: real\s*([.0-9m:]+)', \&FormatTime], ["CBE" , 'TEST-RESULT-cbe-time: real\s*([.0-9m:]+)', \&FormatTime], ["LLC" , 'TEST-RESULT-llc-time: real\s*([.0-9m:]+)', \&FormatTime], - ["LLC-LS" , 'TEST-RESULT-llc-ls-time: real\s*([.0-9m:]+)', \&FormatTime], + ["LLC-BETA" , 'TEST-RESULT-llc-ls-time: real\s*([.0-9m:]+)', \&FormatTime], ["JIT" , 'TEST-RESULT-jit-time: real\s*([.0-9m:]+)', \&FormatTime], - ["JIT-LS" , 'TEST-RESULT-jit-ls-time: real\s*([.0-9m:]+)', \&FormatTime], + ["JIT-BETA" , 'TEST-RESULT-jit-ls-time: real\s*([.0-9m:]+)', \&FormatTime], ["GCC/CBE" , \&GCCCBERatio], ["GCC/LLC" , \&GCCLLCRatio], - ["GCC/LLC-LS" , \&GCCLLC_LSRatio] + ["GCC/LLC-Beta" , \&GCCLLC_LSRatio] ); From lattner at cs.uiuc.edu Fri Jul 23 01:50:28 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 23 Jul 2004 01:50:28 -0500 Subject: [llvm-commits] CVS: llvm/utils/NightlyTestTemplate.html Message-ID: <200407230650.BAA29554@apoc.cs.uiuc.edu> Changes in directory llvm/utils: NightlyTestTemplate.html updated: 1.31 -> 1.32 --- Log message: Change column name --- Diffs of the changes: (+3 -3) Index: llvm/utils/NightlyTestTemplate.html diff -u llvm/utils/NightlyTestTemplate.html:1.31 llvm/utils/NightlyTestTemplate.html:1.32 --- llvm/utils/NightlyTestTemplate.html:1.31 Fri Jun 25 15:57:19 2004 +++ llvm/utils/NightlyTestTemplate.html Fri Jul 23 01:50:18 2004 @@ -206,9 +206,9 @@ GCC output: greater than 1 is a speedup, less than 1 is a slowdown.
  • GCC/CBE - The speed-up of the CBE output vs the native GCC output: greater than 1 is a speedup, less than 1 is a slowdown.
  • -
  • LLC-LS - How long does the program generated by the static - backend LLC take to execute the program, when compiled with the linear scan - register allocator. This is temporary, for tuning.
  • +
  • LLC-BETA - How long does the program generated by the static + backend LLC take to execute the program, when compiled with new experimental + features. This is temporary, for tuning.
  • A complete log of testing From lattner at cs.uiuc.edu Fri Jul 23 03:24:34 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 23 Jul 2004 03:24:34 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervals.h Message-ID: <200407230824.DAA02132@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveIntervals.h updated: 1.30 -> 1.31 --- Log message: Improve comments a bit Use an explicit LiveRange class to represent ranges instead of an std::pair. This is a minor cleanup, but is really intended to make a future patch simpler and less invasive. Alkis, could you please take a look at LiveInterval::liveAt? I suspect that you can add an operator<(unsigned) to LiveRange, allowing us to speed up the upper_bound call by quite a bit (this would also apply to other callers of upper/lower_bound). I would do it myself, but I still don't understand that crazy liveAt function, despite the comment. :) Basically I would like to see this: LiveRange dummy(index, index+1); Ranges::const_iterator r = std::upper_bound(ranges.begin(), ranges.end(), dummy); Turn into: Ranges::const_iterator r = std::upper_bound(ranges.begin(), ranges.end(), index); --- Diffs of the changes: (+28 -5) Index: llvm/lib/CodeGen/LiveIntervals.h diff -u llvm/lib/CodeGen/LiveIntervals.h:1.30 llvm/lib/CodeGen/LiveIntervals.h:1.31 --- llvm/lib/CodeGen/LiveIntervals.h:1.30 Fri Jul 23 00:26:05 2004 +++ llvm/lib/CodeGen/LiveIntervals.h Fri Jul 23 03:24:23 2004 @@ -29,9 +29,29 @@ class MRegisterInfo; class VirtRegMap; + /// LiveRange structure - This represents a simple register range in the + /// program, with an inclusive start point and an exclusive end point. + /// These ranges are rendered as [start,end). + struct LiveRange { + unsigned start; // Start point of the interval (inclusive) + unsigned end; // End point of the interval (exclusive) + LiveRange(unsigned S, unsigned E) : start(S), end(E) { + assert(S < E && "Cannot create empty or backwards range"); + } + + bool operator<(const LiveRange &LR) const { + return start < LR.start || (start == LR.start && end < LR.end); + } + bool operator==(const LiveRange &LR) const { + return start == LR.start && end == LR.end; + } + private: + LiveRange(); // DO NOT IMPLEMENT + }; + std::ostream& operator<<(std::ostream& os, const LiveRange &LR); + struct LiveInterval { - typedef std::pair Range; - typedef std::vector Ranges; + typedef std::vector Ranges; unsigned reg; // the register of this interval float weight; // weight of this interval: // (number of uses *10^loopDepth) @@ -44,14 +64,17 @@ bool spilled() const; + /// start - Return the lowest numbered slot covered by interval. unsigned start() const { assert(!empty() && "empty interval for register"); - return ranges.front().first; + return ranges.front().start; } + /// end - return the maximum point of the interval of the whole, + /// exclusive. unsigned end() const { assert(!empty() && "empty interval for register"); - return ranges.back().second; + return ranges.back().end; } bool expiredAt(unsigned index) const { @@ -62,7 +85,7 @@ bool overlaps(const LiveInterval& other) const; - void addRange(unsigned start, unsigned end); + void addRange(LiveRange R); void join(const LiveInterval& other); From alkis at cs.uiuc.edu Fri Jul 23 08:34:27 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri, 23 Jul 2004 08:34:27 -0500 Subject: [llvm-commits] CVS: llvm/test/Programs/TEST.nightly.report Message-ID: <200407231334.IAA24655@zion.cs.uiuc.edu> Changes in directory llvm/test/Programs: TEST.nightly.report updated: 1.25 -> 1.26 --- Log message: CHange llc-ls to llc-beta. --- Diffs of the changes: (+6 -6) Index: llvm/test/Programs/TEST.nightly.report diff -u llvm/test/Programs/TEST.nightly.report:1.25 llvm/test/Programs/TEST.nightly.report:1.26 --- llvm/test/Programs/TEST.nightly.report:1.25 Fri Jul 23 01:49:31 2004 +++ llvm/test/Programs/TEST.nightly.report Fri Jul 23 08:34:17 2004 @@ -41,12 +41,12 @@ } } -sub GCCLLC_LSRatio { +sub GCCLLC_BETARatio { my ($Cols, $Col) = @_; my $GCC = $Cols->[$Col-8]; - my $LLC_LS = $Cols->[$Col-5]; - if ($GCC ne "*" and $LLC_LS ne "*" and $LLC_LS != "0") { - return sprintf("%3.2f", $GCC/$LLC_LS); + my $LLC_BETA = $Cols->[$Col-5]; + if ($GCC ne "*" and $LLC_BETA ne "*" and $LLC_BETA != "0") { + return sprintf("%3.2f", $GCC/$LLC_BETA); } else { return "n/a"; } @@ -63,7 +63,7 @@ ["GCCAS" , "TEST-RESULT-compile: $WallTimeRE"], ["Bytecode" , 'TEST-RESULT-compile: *([0-9]+)'], ["LLC
    compile" , "TEST-RESULT-llc: $WallTimeRE"], - ["LLC-LS
    compile" , "TEST-RESULT-llc-ls: $WallTimeRE"], + ["LLC-BETA
    compile" , "TEST-RESULT-llc-ls: $WallTimeRE"], ["JIT
    codegen" , "TEST-RESULT-jit-comptime: $WallTimeRE"], ["Machine
    code", 'TEST-RESULT-jit-machcode: *([0-9]+).*bytes of machine code'], [], @@ -75,5 +75,5 @@ ["JIT-BETA" , 'TEST-RESULT-jit-ls-time: real\s*([.0-9m:]+)', \&FormatTime], ["GCC/CBE" , \&GCCCBERatio], ["GCC/LLC" , \&GCCLLCRatio], - ["GCC/LLC-Beta" , \&GCCLLC_LSRatio] + ["GCC/LLC-Beta" , \&GCCLLC_BETARatio] ); From criswell at cs.uiuc.edu Fri Jul 23 10:41:04 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Fri, 23 Jul 2004 10:41:04 -0500 Subject: [llvm-commits] CVS: llvm/configure Message-ID: <200407231541.KAA11732@choi.cs.uiuc.edu> Changes in directory llvm: configure updated: 1.99 -> 1.100 --- Log message: Revised the generation of files so that they follow the newer autoconf standards. This is in hopes of fixing configuration problems on Windows Services for Unix. --- Diffs of the changes: (+32 -29) Index: llvm/configure diff -u llvm/configure:1.99 llvm/configure:1.100 --- llvm/configure:1.99 Tue Jul 20 22:50:25 2004 +++ llvm/configure Fri Jul 23 10:40:53 2004 @@ -1535,6 +1535,10 @@ ac_config_headers="$ac_config_headers include/Config/config.h" + + ac_config_files="$ac_config_files Makefile.config include/Support/DataTypes.h include/Support/ThreadSupport.h include/Support/hash_map include/Support/hash_set include/Support/iterator" + + ac_config_commands="$ac_config_commands Makefile" @@ -4052,7 +4056,7 @@ ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 4055 "configure"' > conftest.$ac_ext + echo '#line 4059 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -4893,7 +4897,7 @@ # Provide some information about the compiler. -echo "$as_me:4896:" \ +echo "$as_me:4900:" \ "checking for Fortran 77 compiler version" >&5 ac_compiler=`set X $ac_compile; echo $2` { (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 @@ -5898,11 +5902,11 @@ -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:5901: $lt_compile\"" >&5) + (eval echo "\"\$as_me:5905: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:5905: \$? = $ac_status" >&5 + echo "$as_me:5909: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -6130,11 +6134,11 @@ -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:6133: $lt_compile\"" >&5) + (eval echo "\"\$as_me:6137: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:6137: \$? = $ac_status" >&5 + echo "$as_me:6141: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -6197,11 +6201,11 @@ -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:6200: $lt_compile\"" >&5) + (eval echo "\"\$as_me:6204: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:6204: \$? = $ac_status" >&5 + echo "$as_me:6208: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -8209,7 +8213,7 @@ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext <&5) + (eval echo "\"\$as_me:10446: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:10446: \$? = $ac_status" >&5 + echo "$as_me:10450: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -10506,11 +10510,11 @@ -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:10509: $lt_compile\"" >&5) + (eval echo "\"\$as_me:10513: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:10513: \$? = $ac_status" >&5 + echo "$as_me:10517: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -11749,7 +11753,7 @@ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext <&5) + (eval echo "\"\$as_me:12676: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:12676: \$? = $ac_status" >&5 + echo "$as_me:12680: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -12736,11 +12740,11 @@ -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:12739: $lt_compile\"" >&5) + (eval echo "\"\$as_me:12743: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:12743: \$? = $ac_status" >&5 + echo "$as_me:12747: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -14676,11 +14680,11 @@ -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:14679: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14683: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:14683: \$? = $ac_status" >&5 + echo "$as_me:14687: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -14908,11 +14912,11 @@ -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:14911: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14915: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:14915: \$? = $ac_status" >&5 + echo "$as_me:14919: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -14975,11 +14979,11 @@ -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:14978: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14982: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:14982: \$? = $ac_status" >&5 + echo "$as_me:14986: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -16987,7 +16991,7 @@ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext <confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure From criswell at cs.uiuc.edu Fri Jul 23 10:41:07 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Fri, 23 Jul 2004 10:41:07 -0500 Subject: [llvm-commits] CVS: llvm/autoconf/configure.ac Message-ID: <200407231541.KAA11739@choi.cs.uiuc.edu> Changes in directory llvm/autoconf: configure.ac updated: 1.95 -> 1.96 --- Log message: Revised the generation of files so that they follow the newer autoconf standards. This is in hopes of fixing configuration problems on Windows Services for Unix. --- Diffs of the changes: (+12 -7) Index: llvm/autoconf/configure.ac diff -u llvm/autoconf/configure.ac:1.95 llvm/autoconf/configure.ac:1.96 --- llvm/autoconf/configure.ac:1.95 Tue Jul 20 22:14:51 2004 +++ llvm/autoconf/configure.ac Fri Jul 23 10:40:57 2004 @@ -26,8 +26,18 @@ fi done -dnl Configure a header file +dnl Configure header files AC_CONFIG_HEADERS(include/Config/config.h) + +dnl Configure other output file +AC_CONFIG_FILES(Makefile.config + include/Support/DataTypes.h + include/Support/ThreadSupport.h + include/Support/hash_map + include/Support/hash_set + include/Support/iterator) + +dnl Do special configuration of Makefiles AC_CONFIG_MAKEFILE(Makefile) AC_CONFIG_MAKEFILE(Makefile.common) AC_CONFIG_MAKEFILE(lib/Makefile) @@ -448,12 +458,7 @@ [Extension that shared libraries have, e.g., ".so".]) dnl Create the output files -AC_OUTPUT(Makefile.config - include/Support/DataTypes.h - include/Support/ThreadSupport.h - include/Support/hash_map - include/Support/hash_set - include/Support/iterator) +AC_OUTPUT() dnl Warn loudly if llvm-gcc was not obviously working if test $llvmgccwarn = yes From lattner at cs.uiuc.edu Fri Jul 23 12:49:27 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 23 Jul 2004 12:49:27 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveInterval.cpp LiveInterval.h LiveIntervals.cpp LiveIntervals.h Message-ID: <200407231749.MAA10905@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveInterval.cpp added (r1.1) LiveInterval.h added (r1.1) LiveIntervals.cpp updated: 1.104 -> 1.105 LiveIntervals.h updated: 1.31 -> 1.32 --- Log message: Pull the LiveRange and LiveInterval classes out of LiveIntervals.h (which will soon be renamed) into their own file. The new file should not emit DEBUG output or have other side effects. The LiveInterval class also now doesn't know whether its working on registers or some other thing. In the future we will want to use the LiveInterval class and friends to do stack packing. In addition to a code simplification, this will allow us to do it more easily. --- Diffs of the changes: (+286 -239) Index: llvm/lib/CodeGen/LiveInterval.cpp diff -c /dev/null llvm/lib/CodeGen/LiveInterval.cpp:1.1 *** /dev/null Fri Jul 23 12:49:26 2004 --- llvm/lib/CodeGen/LiveInterval.cpp Fri Jul 23 12:49:16 2004 *************** *** 0 **** --- 1,151 ---- + //===-- LiveInterval.cpp - Live Interval Representation -------------------===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by the LLVM research group and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // This file implements the LiveRange and LiveInterval classes. Given some + // numbering of each the machine instructions an interval [i, j) is said to be a + // live interval for register v if there is no instruction with number j' > j + // such that v is live at j' abd there is no instruction with number i' < i such + // that v is live at i'. In this implementation intervals can have holes, + // i.e. an interval might look like [1,20), [50,65), [1000,1001). Each + // individual range is represented as an instance of LiveRange, and the whole + // interval is represented as an instance of LiveInterval. + // + //===----------------------------------------------------------------------===// + + #include "LiveInterval.h" + #include "Support/STLExtras.h" + #include + using namespace llvm; + + // An example for liveAt(): + // + // this = [1,4), liveAt(0) will return false. The instruction defining + // this spans slots [0,3]. The interval belongs to an spilled + // definition of the variable it represents. This is because slot 1 is + // used (def slot) and spans up to slot 3 (store slot). + // + bool LiveInterval::liveAt(unsigned index) const { + LiveRange dummy(index, index+1); + Ranges::const_iterator r = std::upper_bound(ranges.begin(), + ranges.end(), + dummy); + if (r == ranges.begin()) + return false; + + --r; + return index >= r->start && index < r->end; + } + + // An example for overlaps(): + // + // 0: A = ... + // 4: B = ... + // 8: C = A + B ;; last use of A + // + // The live intervals should look like: + // + // A = [3, 11) + // B = [7, x) + // C = [11, y) + // + // A->overlaps(C) should return false since we want to be able to join + // A and C. + bool LiveInterval::overlaps(const LiveInterval& other) const { + Ranges::const_iterator i = ranges.begin(); + Ranges::const_iterator ie = ranges.end(); + Ranges::const_iterator j = other.ranges.begin(); + Ranges::const_iterator je = other.ranges.end(); + if (i->start < j->start) { + i = std::upper_bound(i, ie, *j); + if (i != ranges.begin()) --i; + } + else if (j->start < i->start) { + j = std::upper_bound(j, je, *i); + if (j != other.ranges.begin()) --j; + } + + while (i != ie && j != je) { + if (i->start == j->start) + return true; + + if (i->start > j->start) { + swap(i, j); + swap(ie, je); + } + assert(i->start < j->start); + + if (i->end > j->start) + return true; + ++i; + } + + return false; + } + + void LiveInterval::addRange(LiveRange LR) { + Ranges::iterator it = + ranges.insert(std::upper_bound(ranges.begin(), ranges.end(), LR), LR); + + mergeRangesBackward(mergeRangesForward(it)); + } + + void LiveInterval::join(const LiveInterval& other) { + Ranges::iterator cur = ranges.begin(); + isDefinedOnce &= other.isDefinedOnce; + + for (Ranges::const_iterator i = other.ranges.begin(), + e = other.ranges.end(); i != e; ++i) { + cur = ranges.insert(std::upper_bound(cur, ranges.end(), *i), *i); + cur = mergeRangesBackward(mergeRangesForward(cur)); + } + weight += other.weight; + } + + LiveInterval::Ranges::iterator + LiveInterval::mergeRangesForward(Ranges::iterator it) { + Ranges::iterator n; + while ((n = next(it)) != ranges.end()) { + if (n->start > it->end) + break; + it->end = std::max(it->end, n->end); + n = ranges.erase(n); + } + return it; + } + + LiveInterval::Ranges::iterator + LiveInterval::mergeRangesBackward(Ranges::iterator it) { + while (it != ranges.begin()) { + Ranges::iterator p = prior(it); + if (it->start > p->end) + break; + + it->start = std::min(it->start, p->start); + it->end = std::max(it->end, p->end); + it = ranges.erase(p); + } + + return it; + } + + std::ostream& llvm::operator<<(std::ostream& os, const LiveRange &LR) { + return os << "[" << LR.start << "," << LR.end << ")"; + } + + std::ostream& llvm::operator<<(std::ostream& os, const LiveInterval& li) { + os << "%reg" << li.reg << ',' << li.weight; + if (li.empty()) + return os << "EMPTY"; + + os << " = "; + for (LiveInterval::Ranges::const_iterator i = li.ranges.begin(), + e = li.ranges.end(); i != e; ++i) + os << *i; + return os; + } Index: llvm/lib/CodeGen/LiveInterval.h diff -c /dev/null llvm/lib/CodeGen/LiveInterval.h:1.1 *** /dev/null Fri Jul 23 12:49:27 2004 --- llvm/lib/CodeGen/LiveInterval.h Fri Jul 23 12:49:16 2004 *************** *** 0 **** --- 1,109 ---- + //===-- llvm/CodeGen/LiveInterval.h - Interval representation ---*- C++ -*-===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by the LLVM research group and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // This file implements the LiveRange and LiveInterval classes. Given some + // numbering of each the machine instructions an interval [i, j) is said to be a + // live interval for register v if there is no instruction with number j' > j + // such that v is live at j' abd there is no instruction with number i' < i such + // that v is live at i'. In this implementation intervals can have holes, + // i.e. an interval might look like [1,20), [50,65), [1000,1001). Each + // individual range is represented as an instance of LiveRange, and the whole + // interval is represented as an instance of LiveInterval. + // + //===----------------------------------------------------------------------===// + + #ifndef LLVM_CODEGEN_LIVEINTERVAL_H + #define LLVM_CODEGEN_LIVEINTERVAL_H + + #include + #include + #include + + namespace llvm { + /// LiveRange structure - This represents a simple register range in the + /// program, with an inclusive start point and an exclusive end point. + /// These ranges are rendered as [start,end). + struct LiveRange { + unsigned start; // Start point of the interval (inclusive) + unsigned end; // End point of the interval (exclusive) + LiveRange(unsigned S, unsigned E) : start(S), end(E) { + assert(S < E && "Cannot create empty or backwards range"); + } + + bool operator<(const LiveRange &LR) const { + return start < LR.start || (start == LR.start && end < LR.end); + } + bool operator==(const LiveRange &LR) const { + return start == LR.start && end == LR.end; + } + private: + LiveRange(); // DO NOT IMPLEMENT + }; + std::ostream& operator<<(std::ostream& os, const LiveRange &LR); + + /// LiveInterval - This class represents some number of live ranges for a + /// register or value. This class also contains a bit of register allocator + /// state. + struct LiveInterval { + typedef std::vector Ranges; + unsigned reg; // the register of this interval + float weight; // weight of this interval + Ranges ranges; // the ranges in which this register is live + bool isDefinedOnce; // True if this interval contains one value. + + LiveInterval(unsigned Reg, float Weight) + : reg(Reg), weight(Weight), isDefinedOnce(false) { + } + + bool containsOneValue() const { return isDefinedOnce; } + + bool empty() const { return ranges.empty(); } + + /// start - Return the lowest numbered slot covered by interval. + unsigned start() const { + assert(!empty() && "empty interval for register"); + return ranges.front().start; + } + + /// end - return the maximum point of the interval of the whole, + /// exclusive. + unsigned end() const { + assert(!empty() && "empty interval for register"); + return ranges.back().end; + } + + bool expiredAt(unsigned index) const { + return end() <= (index + 1); + } + + bool liveAt(unsigned index) const; + + bool overlaps(const LiveInterval& other) const; + + void addRange(LiveRange R); + + void join(const LiveInterval& other); + + bool operator<(const LiveInterval& other) const { + return start() < other.start(); + } + + bool operator==(const LiveInterval& other) const { + return reg == other.reg; + } + + private: + Ranges::iterator mergeRangesForward(Ranges::iterator it); + Ranges::iterator mergeRangesBackward(Ranges::iterator it); + }; + + std::ostream& operator<<(std::ostream& os, const LiveInterval& li); + } + + #endif Index: llvm/lib/CodeGen/LiveIntervals.cpp diff -u llvm/lib/CodeGen/LiveIntervals.cpp:1.104 llvm/lib/CodeGen/LiveIntervals.cpp:1.105 --- llvm/lib/CodeGen/LiveIntervals.cpp:1.104 Fri Jul 23 03:22:09 2004 +++ llvm/lib/CodeGen/LiveIntervals.cpp Fri Jul 23 12:49:16 2004 @@ -250,6 +250,7 @@ // the spill weight is now infinity as it // cannot be spilled again nI.weight = HUGE_VAL; + DEBUG(std::cerr << " +" << LiveRange(start, end)); nI.addRange(LiveRange(start, end)); added.push_back(&nI); // update live variables @@ -309,7 +310,7 @@ assert(vi.AliveBlocks.empty() && "Shouldn't be alive across any blocks!"); interval.addRange(LiveRange(defIndex, killIdx)); - DEBUG(std::cerr << "\n"); + DEBUG(std::cerr << " +" << LiveRange(defIndex, killIdx) << "\n"); return; } } @@ -318,9 +319,10 @@ // of the defining block, potentially live across some blocks, then is // live into some number of blocks, but gets killed. Start by adding a // range that goes from this definition to the end of the defining block. - interval.addRange(LiveRange(defIndex, - getInstructionIndex(&mbb->back()) + - InstrSlots::NUM)); + LiveRange NewLR(defIndex, getInstructionIndex(&mbb->back()) + + InstrSlots::NUM); + DEBUG(std::cerr << " +" << NewLR); + interval.addRange(NewLR); // Iterate over all of the blocks that the variable is completely // live in, adding [insrtIndex(begin), instrIndex(end)+4) to the @@ -329,9 +331,10 @@ if (vi.AliveBlocks[i]) { MachineBasicBlock* mbb = mf_->getBlockNumbered(i); if (!mbb->empty()) { - interval.addRange(LiveRange( - getInstructionIndex(&mbb->front()), - getInstructionIndex(&mbb->back()) + InstrSlots::NUM)); + LiveRange LR(getInstructionIndex(&mbb->front()), + getInstructionIndex(&mbb->back())+InstrSlots::NUM); + interval.addRange(LR); + DEBUG(std::cerr << " +" << LR); } } } @@ -340,9 +343,10 @@ // block to the 'use' slot of the killing instruction. for (unsigned i = 0, e = vi.Kills.size(); i != e; ++i) { MachineInstr *Kill = vi.Kills[i]; - interval.addRange(LiveRange( - getInstructionIndex(Kill->getParent()->begin()), - getUseIndex(getInstructionIndex(Kill))+1)); + LiveRange LR(getInstructionIndex(Kill->getParent()->begin()), + getUseIndex(getInstructionIndex(Kill))+1); + interval.addRange(LR); + DEBUG(std::cerr << " +" << LR); } } else { @@ -359,8 +363,10 @@ // the defined value will be live until the end of the basic block it // is defined in. unsigned defIndex = getDefIndex(getInstructionIndex(mi)); - interval.addRange(LiveRange(defIndex, - getInstructionIndex(&mbb->back()) +InstrSlots::NUM)); + LiveRange LR(defIndex, + getInstructionIndex(&mbb->back()) +InstrSlots::NUM); + interval.addRange(LR); + DEBUG(std::cerr << " +" << LR); } interval.isDefinedOnce = false; } @@ -413,7 +419,7 @@ exit: assert(start < end && "did not find end of interval?"); interval.addRange(LiveRange(start, end)); - DEBUG(std::cerr << '\n'); + DEBUG(std::cerr << " +" << LiveRange(start, end) << '\n'); } void LiveIntervals::handleRegisterDef(MachineBasicBlock* mbb, @@ -547,10 +553,11 @@ continue; } - // if their intervals do not overlap we join them - if ((intA->isDefinedOnce && intB->isDefinedOnce) || + // if their intervals do not overlap we join them. + if ((intA->containsOneValue() && intB->containsOneValue()) || !intB->overlaps(*intA)) { intA->join(*intB); + ++numJoins; DEBUG(std::cerr << "Joined. Result = " << *intA << "\n"); r2iB->second = r2iA->second; r2rMap_.insert(std::make_pair(intB->reg, intA->reg)); @@ -582,6 +589,7 @@ if (!intA->overlaps(*intB) && !overlapsAliases(*intA, *intB)) { intA->join(*intB); + ++numJoins; DEBUG(std::cerr << "Joined. Result = " << *intA << "\n"); r2iB->second = r2iA->second; r2rMap_.insert(std::make_pair(intB->reg, intA->reg)); @@ -656,158 +664,11 @@ { Reg2IntervalMap::iterator r2iit = r2iMap_.lower_bound(reg); if (r2iit == r2iMap_.end() || r2iit->first != reg) { - intervals_.push_back(LiveInterval(reg)); + float Weight = MRegisterInfo::isPhysicalRegister(reg) ? HUGE_VAL :0.0F; + intervals_.push_back(LiveInterval(reg, Weight)); r2iit = r2iMap_.insert(r2iit, std::make_pair(reg, --intervals_.end())); } return *r2iit->second; } -LiveInterval::LiveInterval(unsigned r) - : reg(r), - weight((MRegisterInfo::isPhysicalRegister(r) ? HUGE_VAL : 0.0F)), - isDefinedOnce(false) { -} - -bool LiveInterval::spilled() const -{ - return (weight == HUGE_VAL && - MRegisterInfo::isVirtualRegister(reg)); -} - -// An example for liveAt(): -// -// this = [1,4), liveAt(0) will return false. The instruction defining -// this spans slots [0,3]. The interval belongs to an spilled -// definition of the variable it represents. This is because slot 1 is -// used (def slot) and spans up to slot 3 (store slot). -// -bool LiveInterval::liveAt(unsigned index) const -{ - LiveRange dummy(index, index+1); - Ranges::const_iterator r = std::upper_bound(ranges.begin(), - ranges.end(), - dummy); - if (r == ranges.begin()) - return false; - - --r; - return index >= r->start && index < r->end; -} - -// An example for overlaps(): -// -// 0: A = ... -// 4: B = ... -// 8: C = A + B ;; last use of A -// -// The live intervals should look like: -// -// A = [3, 11) -// B = [7, x) -// C = [11, y) -// -// A->overlaps(C) should return false since we want to be able to join -// A and C. -bool LiveInterval::overlaps(const LiveInterval& other) const -{ - Ranges::const_iterator i = ranges.begin(); - Ranges::const_iterator ie = ranges.end(); - Ranges::const_iterator j = other.ranges.begin(); - Ranges::const_iterator je = other.ranges.end(); - if (i->start < j->start) { - i = std::upper_bound(i, ie, *j); - if (i != ranges.begin()) --i; - } - else if (j->start < i->start) { - j = std::upper_bound(j, je, *i); - if (j != other.ranges.begin()) --j; - } - - while (i != ie && j != je) { - if (i->start == j->start) - return true; - - if (i->start > j->start) { - swap(i, j); - swap(ie, je); - } - assert(i->start < j->start); - - if (i->end > j->start) - return true; - ++i; - } - - return false; -} - -void LiveInterval::addRange(LiveRange LR) { - DEBUG(std::cerr << " +" << LR); - Ranges::iterator it = - ranges.insert(std::upper_bound(ranges.begin(), ranges.end(), LR), LR); - - mergeRangesBackward(mergeRangesForward(it)); -} - -void LiveInterval::join(const LiveInterval& other) -{ - Ranges::iterator cur = ranges.begin(); - isDefinedOnce &= other.isDefinedOnce; - - for (Ranges::const_iterator i = other.ranges.begin(), - e = other.ranges.end(); i != e; ++i) { - cur = ranges.insert(std::upper_bound(cur, ranges.end(), *i), *i); - cur = mergeRangesForward(cur); - cur = mergeRangesBackward(cur); - } - weight += other.weight; - ++numJoins; -} - -LiveInterval::Ranges::iterator LiveInterval:: -mergeRangesForward(Ranges::iterator it) -{ - Ranges::iterator n; - while ((n = next(it)) != ranges.end()) { - if (n->start > it->end) - break; - it->end = std::max(it->end, n->end); - n = ranges.erase(n); - } - return it; -} - -LiveInterval::Ranges::iterator LiveInterval:: -mergeRangesBackward(Ranges::iterator it) -{ - while (it != ranges.begin()) { - Ranges::iterator p = prior(it); - if (it->start > p->end) - break; - - it->start = std::min(it->start, p->start); - it->end = std::max(it->end, p->end); - it = ranges.erase(p); - } - - return it; -} - -std::ostream& llvm::operator<<(std::ostream& os, const LiveRange &LR) { - return os << "[" << LR.start << "," << LR.end << ")"; -} - - -std::ostream& llvm::operator<<(std::ostream& os, const LiveInterval& li) -{ - os << "%reg" << li.reg << ',' << li.weight; - if (li.empty()) - return os << "EMPTY"; - - os << " = "; - for (LiveInterval::Ranges::const_iterator i = li.ranges.begin(), - e = li.ranges.end(); i != e; ++i) - os << *i; - return os; -} Index: llvm/lib/CodeGen/LiveIntervals.h diff -u llvm/lib/CodeGen/LiveIntervals.h:1.31 llvm/lib/CodeGen/LiveIntervals.h:1.32 --- llvm/lib/CodeGen/LiveIntervals.h:1.31 Fri Jul 23 03:24:23 2004 +++ llvm/lib/CodeGen/LiveIntervals.h Fri Jul 23 12:49:16 2004 @@ -21,6 +21,7 @@ #define LLVM_CODEGEN_LIVEINTERVALS_H #include "llvm/CodeGen/MachineFunctionPass.h" +#include "LiveInterval.h" #include namespace llvm { @@ -29,81 +30,6 @@ class MRegisterInfo; class VirtRegMap; - /// LiveRange structure - This represents a simple register range in the - /// program, with an inclusive start point and an exclusive end point. - /// These ranges are rendered as [start,end). - struct LiveRange { - unsigned start; // Start point of the interval (inclusive) - unsigned end; // End point of the interval (exclusive) - LiveRange(unsigned S, unsigned E) : start(S), end(E) { - assert(S < E && "Cannot create empty or backwards range"); - } - - bool operator<(const LiveRange &LR) const { - return start < LR.start || (start == LR.start && end < LR.end); - } - bool operator==(const LiveRange &LR) const { - return start == LR.start && end == LR.end; - } - private: - LiveRange(); // DO NOT IMPLEMENT - }; - std::ostream& operator<<(std::ostream& os, const LiveRange &LR); - - struct LiveInterval { - typedef std::vector Ranges; - unsigned reg; // the register of this interval - float weight; // weight of this interval: - // (number of uses *10^loopDepth) - Ranges ranges; // the ranges in which this register is live - bool isDefinedOnce; // True if there is one def of this register - - explicit LiveInterval(unsigned r); - - bool empty() const { return ranges.empty(); } - - bool spilled() const; - - /// start - Return the lowest numbered slot covered by interval. - unsigned start() const { - assert(!empty() && "empty interval for register"); - return ranges.front().start; - } - - /// end - return the maximum point of the interval of the whole, - /// exclusive. - unsigned end() const { - assert(!empty() && "empty interval for register"); - return ranges.back().end; - } - - bool expiredAt(unsigned index) const { - return end() <= (index + 1); - } - - bool liveAt(unsigned index) const; - - bool overlaps(const LiveInterval& other) const; - - void addRange(LiveRange R); - - void join(const LiveInterval& other); - - bool operator<(const LiveInterval& other) const { - return start() < other.start(); - } - - bool operator==(const LiveInterval& other) const { - return reg == other.reg; - } - - private: - Ranges::iterator mergeRangesForward(Ranges::iterator it); - Ranges::iterator mergeRangesBackward(Ranges::iterator it); - }; - - std::ostream& operator<<(std::ostream& os, const LiveInterval& li); - class LiveIntervals : public MachineFunctionPass { public: From lattner at cs.uiuc.edu Fri Jul 23 12:56:41 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 23 Jul 2004 12:56:41 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp LiveIntervalAnalysis.h RegAllocIterativeScan.cpp RegAllocLinearScan.cpp Message-ID: <200407231756.MAA19628@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveIntervalAnalysis.cpp updated: 1.105 -> 1.106 LiveIntervalAnalysis.h updated: 1.32 -> 1.33 RegAllocIterativeScan.cpp updated: 1.7 -> 1.8 RegAllocLinearScan.cpp updated: 1.82 -> 1.83 --- Log message: Rename LiveIntervals.(cpp|h) -> LiveIntervalAnalysis.(cpp|h) --- Diffs of the changes: (+7 -7) Index: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp diff -u llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.105 llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.106 --- llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.105 Fri Jul 23 12:49:16 2004 +++ llvm/lib/CodeGen/LiveIntervalAnalysis.cpp Fri Jul 23 12:56:30 2004 @@ -1,4 +1,4 @@ -//===-- LiveIntervals.cpp - Live Interval Analysis ------------------------===// +//===-- LiveIntervalAnalysis.cpp - Live Interval Analysis -----------------===// // // The LLVM Compiler Infrastructure // @@ -16,7 +16,7 @@ //===----------------------------------------------------------------------===// #define DEBUG_TYPE "liveintervals" -#include "LiveIntervals.h" +#include "LiveIntervalAnalysis.h" #include "llvm/Value.h" #include "llvm/Analysis/LoopInfo.h" #include "llvm/CodeGen/LiveVariables.h" Index: llvm/lib/CodeGen/LiveIntervalAnalysis.h diff -u llvm/lib/CodeGen/LiveIntervalAnalysis.h:1.32 llvm/lib/CodeGen/LiveIntervalAnalysis.h:1.33 --- llvm/lib/CodeGen/LiveIntervalAnalysis.h:1.32 Fri Jul 23 12:49:16 2004 +++ llvm/lib/CodeGen/LiveIntervalAnalysis.h Fri Jul 23 12:56:30 2004 @@ -1,4 +1,4 @@ -//===-- llvm/CodeGen/LiveInterval.h - Live Interval Analysis ----*- C++ -*-===// +//===-- LiveIntervalAnalysis.h - Live Interval Analysis ---------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -17,8 +17,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_CODEGEN_LIVEINTERVALS_H -#define LLVM_CODEGEN_LIVEINTERVALS_H +#ifndef LLVM_CODEGEN_LIVEINTERVAL_ANALYSIS_H +#define LLVM_CODEGEN_LIVEINTERVAL_ANALYSIS_H #include "llvm/CodeGen/MachineFunctionPass.h" #include "LiveInterval.h" Index: llvm/lib/CodeGen/RegAllocIterativeScan.cpp diff -u llvm/lib/CodeGen/RegAllocIterativeScan.cpp:1.7 llvm/lib/CodeGen/RegAllocIterativeScan.cpp:1.8 --- llvm/lib/CodeGen/RegAllocIterativeScan.cpp:1.7 Wed Jul 21 21:16:53 2004 +++ llvm/lib/CodeGen/RegAllocIterativeScan.cpp Fri Jul 23 12:56:30 2004 @@ -29,7 +29,7 @@ #include "Support/Debug.h" #include "Support/Statistic.h" #include "Support/STLExtras.h" -#include "LiveIntervals.h" +#include "LiveIntervalAnalysis.h" #include "PhysRegTracker.h" #include "VirtRegMap.h" #include Index: llvm/lib/CodeGen/RegAllocLinearScan.cpp diff -u llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.82 llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.83 --- llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.82 Thu Jul 22 03:14:44 2004 +++ llvm/lib/CodeGen/RegAllocLinearScan.cpp Fri Jul 23 12:56:30 2004 @@ -23,7 +23,7 @@ #include "Support/Debug.h" #include "Support/Statistic.h" #include "Support/STLExtras.h" -#include "LiveIntervals.h" +#include "LiveIntervalAnalysis.h" #include "PhysRegTracker.h" #include "VirtRegMap.h" #include From lattner at cs.uiuc.edu Fri Jul 23 13:13:34 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 23 Jul 2004 13:13:34 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveInterval.h LiveInterval.cpp Message-ID: <200407231813.NAA22305@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveInterval.h updated: 1.1 -> 1.2 LiveInterval.cpp updated: 1.1 -> 1.2 --- Log message: Instead of searching for a live interval pair, search for a location. This gives a very modest speedup of .3 seconds compiling 176.gcc (out of 20s). --- Diffs of the changes: (+9 -6) Index: llvm/lib/CodeGen/LiveInterval.h diff -u llvm/lib/CodeGen/LiveInterval.h:1.1 llvm/lib/CodeGen/LiveInterval.h:1.2 --- llvm/lib/CodeGen/LiveInterval.h:1.1 Fri Jul 23 12:49:16 2004 +++ llvm/lib/CodeGen/LiveInterval.h Fri Jul 23 13:13:24 2004 @@ -47,6 +47,11 @@ }; std::ostream& operator<<(std::ostream& os, const LiveRange &LR); + inline bool operator<(unsigned V, const LiveRange &LR) { + return V < LR.start; + } + + /// LiveInterval - This class represents some number of live ranges for a /// register or value. This class also contains a bit of register allocator /// state. Index: llvm/lib/CodeGen/LiveInterval.cpp diff -u llvm/lib/CodeGen/LiveInterval.cpp:1.1 llvm/lib/CodeGen/LiveInterval.cpp:1.2 --- llvm/lib/CodeGen/LiveInterval.cpp:1.1 Fri Jul 23 12:49:16 2004 +++ llvm/lib/CodeGen/LiveInterval.cpp Fri Jul 23 13:13:24 2004 @@ -30,16 +30,14 @@ // definition of the variable it represents. This is because slot 1 is // used (def slot) and spans up to slot 3 (store slot). // -bool LiveInterval::liveAt(unsigned index) const { - LiveRange dummy(index, index+1); - Ranges::const_iterator r = std::upper_bound(ranges.begin(), - ranges.end(), - dummy); +bool LiveInterval::liveAt(unsigned I) const { + Ranges::const_iterator r = std::upper_bound(ranges.begin(), ranges.end(), I); + if (r == ranges.begin()) return false; --r; - return index >= r->start && index < r->end; + return I >= r->start && I < r->end; } // An example for overlaps(): From lattner at cs.uiuc.edu Fri Jul 23 13:39:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 23 Jul 2004 13:39:02 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervalAnalysis.h Message-ID: <200407231839.NAA23370@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveIntervalAnalysis.h updated: 1.33 -> 1.34 --- Log message: Speedup debug builds a bit --- Diffs of the changes: (+3 -2) Index: llvm/lib/CodeGen/LiveIntervalAnalysis.h diff -u llvm/lib/CodeGen/LiveIntervalAnalysis.h:1.33 llvm/lib/CodeGen/LiveIntervalAnalysis.h:1.34 --- llvm/lib/CodeGen/LiveIntervalAnalysis.h:1.33 Fri Jul 23 12:56:30 2004 +++ llvm/lib/CodeGen/LiveIntervalAnalysis.h Fri Jul 23 13:38:52 2004 @@ -95,8 +95,9 @@ virtual bool runOnMachineFunction(MachineFunction&); LiveInterval& getInterval(unsigned reg) { - assert(r2iMap_.count(reg)&& "Interval does not exist for register"); - return *r2iMap_.find(reg)->second; + Reg2IntervalMap::iterator I = r2iMap_.find(reg); + assert(I != r2iMap_.end()&& "Interval does not exist for register"); + return *I->second; } /// getInstructionIndex - returns the base index of instr From lattner at cs.uiuc.edu Fri Jul 23 13:40:10 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 23 Jul 2004 13:40:10 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveInterval.cpp Message-ID: <200407231840.NAA23391@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveInterval.cpp updated: 1.2 -> 1.3 --- Log message: Search by the start point, not by the whole interval. This saves some comparisons, reducing linscan by another .1 seconds :) --- Diffs of the changes: (+12 -11) Index: llvm/lib/CodeGen/LiveInterval.cpp diff -u llvm/lib/CodeGen/LiveInterval.cpp:1.2 llvm/lib/CodeGen/LiveInterval.cpp:1.3 --- llvm/lib/CodeGen/LiveInterval.cpp:1.2 Fri Jul 23 13:13:24 2004 +++ llvm/lib/CodeGen/LiveInterval.cpp Fri Jul 23 13:40:00 2004 @@ -25,10 +25,10 @@ // An example for liveAt(): // -// this = [1,4), liveAt(0) will return false. The instruction defining -// this spans slots [0,3]. The interval belongs to an spilled -// definition of the variable it represents. This is because slot 1 is -// used (def slot) and spans up to slot 3 (store slot). +// this = [1,4), liveAt(0) will return false. The instruction defining this +// spans slots [0,3]. The interval belongs to an spilled definition of the +// variable it represents. This is because slot 1 is used (def slot) and spans +// up to slot 3 (store slot). // bool LiveInterval::liveAt(unsigned I) const { Ranges::const_iterator r = std::upper_bound(ranges.begin(), ranges.end(), I); @@ -37,7 +37,7 @@ return false; --r; - return I >= r->start && I < r->end; + return r->contains(I); } // An example for overlaps(): @@ -60,12 +60,13 @@ Ranges::const_iterator j = other.ranges.begin(); Ranges::const_iterator je = other.ranges.end(); if (i->start < j->start) { - i = std::upper_bound(i, ie, *j); + i = std::upper_bound(i, ie, j->start); if (i != ranges.begin()) --i; - } - else if (j->start < i->start) { - j = std::upper_bound(j, je, *i); + } else if (j->start < i->start) { + j = std::upper_bound(j, je, i->start); if (j != other.ranges.begin()) --j; + } else { + return true; } while (i != ie && j != je) { @@ -88,7 +89,7 @@ void LiveInterval::addRange(LiveRange LR) { Ranges::iterator it = - ranges.insert(std::upper_bound(ranges.begin(), ranges.end(), LR), LR); + ranges.insert(std::upper_bound(ranges.begin(), ranges.end(), LR.start), LR); mergeRangesBackward(mergeRangesForward(it)); } @@ -99,7 +100,7 @@ for (Ranges::const_iterator i = other.ranges.begin(), e = other.ranges.end(); i != e; ++i) { - cur = ranges.insert(std::upper_bound(cur, ranges.end(), *i), *i); + cur = ranges.insert(std::upper_bound(cur, ranges.end(), i->start), *i); cur = mergeRangesBackward(mergeRangesForward(cur)); } weight += other.weight; From lattner at cs.uiuc.edu Fri Jul 23 13:40:23 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 23 Jul 2004 13:40:23 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveInterval.h Message-ID: <200407231840.NAA23396@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveInterval.h updated: 1.2 -> 1.3 --- Log message: New helper method --- Diffs of the changes: (+7 -1) Index: llvm/lib/CodeGen/LiveInterval.h diff -u llvm/lib/CodeGen/LiveInterval.h:1.2 llvm/lib/CodeGen/LiveInterval.h:1.3 --- llvm/lib/CodeGen/LiveInterval.h:1.2 Fri Jul 23 13:13:24 2004 +++ llvm/lib/CodeGen/LiveInterval.h Fri Jul 23 13:39:12 2004 @@ -36,13 +36,19 @@ assert(S < E && "Cannot create empty or backwards range"); } + /// contains - Return true if the index is covered by this range. + /// + bool contains(unsigned I) const { + return start <= I && I < end; + } + bool operator<(const LiveRange &LR) const { return start < LR.start || (start == LR.start && end < LR.end); } bool operator==(const LiveRange &LR) const { return start == LR.start && end == LR.end; } - private: + private: LiveRange(); // DO NOT IMPLEMENT }; std::ostream& operator<<(std::ostream& os, const LiveRange &LR); From gaeke at cs.uiuc.edu Fri Jul 23 14:36:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Fri, 23 Jul 2004 14:36:01 -0500 (CDT) Subject: [llvm-commits] CVS: llvm/lib/VMCore/PassManagerT.h Message-ID: <200407231936.OAA11631@seraph.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: PassManagerT.h updated: 1.50 -> 1.51 --- Log message: Fix problem with inserting FunctionPasses that depend on ImmutablePasses (e.g., LICM) into FunctionPassManagers. The problem is that we were using a C-style cast to cast required analysis passes to PassClass*, but if it's a FunctionPassManager, and the required analysis pass is an ImmutablePass, the types aren't really compatible, so the C-style cast causes a crash. --- Diffs of the changes: (+12 -4) Index: llvm/lib/VMCore/PassManagerT.h diff -u llvm/lib/VMCore/PassManagerT.h:1.50 llvm/lib/VMCore/PassManagerT.h:1.51 --- llvm/lib/VMCore/PassManagerT.h:1.50 Thu Jul 15 19:07:44 2004 +++ llvm/lib/VMCore/PassManagerT.h Fri Jul 23 14:35:50 2004 @@ -454,8 +454,12 @@ // Loop over all of the analyses used by this pass, for (std::vector::const_iterator I = Required.begin(), E = Required.end(); I != E; ++I) { - if (getAnalysisOrNullDown(*I) == 0) - add((PassClass*)(*I)->createPass()); + if (getAnalysisOrNullDown(*I) == 0) { + Pass *AP = (*I)->createPass(); + if (ImmutablePass *IP = dynamic_cast (AP)) { add(IP); } + else if (PassClass *RP = dynamic_cast (AP)) { add(RP); } + else { assert (0 && "Wrong kind of pass for this PassManager"); } + } } // Tell the pass to add itself to this PassManager... the way it does so @@ -477,8 +481,12 @@ // Loop over all of the analyses used by this pass, for (std::vector::const_iterator I = Required.begin(), E = Required.end(); I != E; ++I) { - if (getAnalysisOrNullDown(*I) == 0) - add((PassClass*)(*I)->createPass()); + if (getAnalysisOrNullDown(*I) == 0) { + Pass *AP = (*I)->createPass(); + if (ImmutablePass *IP = dynamic_cast (AP)) add(IP); + else if (PassClass *RP = dynamic_cast (AP)) add(RP); + else assert (0 && "Wrong kind of pass for this PassManager"); + } } // Add the ImmutablePass to this PassManager. From lattner at cs.uiuc.edu Fri Jul 23 14:38:54 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 23 Jul 2004 14:38:54 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveInterval.cpp LiveInterval.h Message-ID: <200407231938.OAA29421@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveInterval.cpp updated: 1.3 -> 1.4 LiveInterval.h updated: 1.3 -> 1.4 --- Log message: Change addRange and join to be a little bit smarter. In particular, we don't want to insert a new range into the middle of the vector, then delete ranges one at a time next to the inserted one as they are merged. Instead, if the inserted interval overlaps, just start merging. The only time we insert into the middle of the vector is when we don't overlap at all. Also delete blocks of live ranges if we overlap with many of them. This patch speeds up joining by .7 seconds on a large testcase, but more importantly gets all of the range adding code into addRangeFrom. --- Diffs of the changes: (+85 -36) Index: llvm/lib/CodeGen/LiveInterval.cpp diff -u llvm/lib/CodeGen/LiveInterval.cpp:1.3 llvm/lib/CodeGen/LiveInterval.cpp:1.4 --- llvm/lib/CodeGen/LiveInterval.cpp:1.3 Fri Jul 23 13:40:00 2004 +++ llvm/lib/CodeGen/LiveInterval.cpp Fri Jul 23 14:38:44 2004 @@ -87,50 +87,93 @@ return false; } -void LiveInterval::addRange(LiveRange LR) { - Ranges::iterator it = - ranges.insert(std::upper_bound(ranges.begin(), ranges.end(), LR.start), LR); - - mergeRangesBackward(mergeRangesForward(it)); +/// extendIntervalEndTo - This method is used when we want to extend the range +/// specified by I to end at the specified endpoint. To do this, we should +/// merge and eliminate all ranges that this will overlap with. The iterator is +/// not invalidated. +void LiveInterval::extendIntervalEndTo(Ranges::iterator I, unsigned NewEnd) { + assert(I != ranges.end() && "Not a valid interval!"); + + // Search for the first interval that we can't merge with. + Ranges::iterator MergeTo = next(I); + for (; MergeTo != ranges.end() && NewEnd >= MergeTo->end; ++MergeTo) + /*empty*/; + + // If NewEnd was in the middle of an interval, make sure to get its endpoint. + I->end = std::max(NewEnd, prior(MergeTo)->end); + + // Erase any dead ranges + ranges.erase(next(I), MergeTo); } -void LiveInterval::join(const LiveInterval& other) { - Ranges::iterator cur = ranges.begin(); - isDefinedOnce &= other.isDefinedOnce; - for (Ranges::const_iterator i = other.ranges.begin(), - e = other.ranges.end(); i != e; ++i) { - cur = ranges.insert(std::upper_bound(cur, ranges.end(), i->start), *i); - cur = mergeRangesBackward(mergeRangesForward(cur)); +/// extendIntervalStartTo - This method is used when we want to extend the range +/// specified by I to start at the specified endpoint. To do this, we should +/// merge and eliminate all ranges that this will overlap with. +LiveInterval::Ranges::iterator +LiveInterval::extendIntervalStartTo(Ranges::iterator I, unsigned NewStart) { + assert(I != ranges.end() && "Not a valid interval!"); + + // Search for the first interval that we can't merge with. + Ranges::iterator MergeTo = I; + do { + if (MergeTo == ranges.begin()) { + I->start = NewStart; + return I; + } + --MergeTo; + } while (NewStart <= MergeTo->start); + + // If we start in the middle of another interval, just delete a range and + // extend that interval. + if (MergeTo->end >= NewStart) { + MergeTo->end = I->end; + } else { + // Otherwise, extend the interval right after. + ++MergeTo; + MergeTo->start = NewStart; + MergeTo->end = I->end; } - weight += other.weight; + + ranges.erase(next(MergeTo), next(I)); + return MergeTo; } LiveInterval::Ranges::iterator -LiveInterval::mergeRangesForward(Ranges::iterator it) { - Ranges::iterator n; - while ((n = next(it)) != ranges.end()) { - if (n->start > it->end) - break; - it->end = std::max(it->end, n->end); - n = ranges.erase(n); +LiveInterval::addRangeFrom(LiveRange LR, Ranges::iterator From) { + unsigned Start = LR.start, End = LR.end; + Ranges::iterator it = std::upper_bound(From, ranges.end(), Start); + + // If the inserted interval starts in the middle or right at the end of + // another interval, just extend that interval to contain the range of LR. + if (it != ranges.begin()) { + Ranges::iterator B = prior(it); + if (B->start <= Start && B->end >= Start) { + extendIntervalEndTo(B, End); + return B; + } } - return it; + + // Otherwise, if this range ends in the middle of, or right next to, another + // interval, merge it into that interval. + if (it != ranges.end() && it->start <= End) + return extendIntervalStartTo(it, Start); + + // Otherwise, this is just a new range that doesn't interact with anything. + // Insert it. + return ranges.insert(it, LR); } -LiveInterval::Ranges::iterator -LiveInterval::mergeRangesBackward(Ranges::iterator it) { - while (it != ranges.begin()) { - Ranges::iterator p = prior(it); - if (it->start > p->end) - break; - - it->start = std::min(it->start, p->start); - it->end = std::max(it->end, p->end); - it = ranges.erase(p); - } +void LiveInterval::join(const LiveInterval& other) { + isDefinedOnce &= other.isDefinedOnce; - return it; + // Join the ranges of other into the ranges of this interval. + Ranges::iterator cur = ranges.begin(); + for (Ranges::const_iterator i = other.ranges.begin(), + e = other.ranges.end(); i != e; ++i) + cur = addRangeFrom(*i, cur); + + weight += other.weight; } std::ostream& llvm::operator<<(std::ostream& os, const LiveRange &LR) { Index: llvm/lib/CodeGen/LiveInterval.h diff -u llvm/lib/CodeGen/LiveInterval.h:1.3 llvm/lib/CodeGen/LiveInterval.h:1.4 --- llvm/lib/CodeGen/LiveInterval.h:1.3 Fri Jul 23 13:39:12 2004 +++ llvm/lib/CodeGen/LiveInterval.h Fri Jul 23 14:38:44 2004 @@ -97,7 +97,12 @@ bool overlaps(const LiveInterval& other) const; - void addRange(LiveRange R); + /// addRange - Add the specified LiveRange to this interval, merging + /// intervals as appropriate. This returns an iterator to the inserted live + /// range (which may have grown since it was inserted. + void addRange(LiveRange LR) { + addRangeFrom(LR, ranges.begin()); + } void join(const LiveInterval& other); @@ -110,8 +115,9 @@ } private: - Ranges::iterator mergeRangesForward(Ranges::iterator it); - Ranges::iterator mergeRangesBackward(Ranges::iterator it); + Ranges::iterator addRangeFrom(LiveRange LR, Ranges::iterator From); + void extendIntervalEndTo(Ranges::iterator I, unsigned NewEnd); + Ranges::iterator extendIntervalStartTo(Ranges::iterator I, unsigned NewStr); }; std::ostream& operator<<(std::ostream& os, const LiveInterval& li); From gaeke at cs.uiuc.edu Fri Jul 23 14:39:49 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Fri, 23 Jul 2004 14:39:49 -0500 (CDT) Subject: [llvm-commits] CVS: llvm-www/releases/1.2/docs/ReleaseNotes.html Message-ID: <200407231939.OAA11726@seraph.cs.uiuc.edu> Changes in directory llvm-www/releases/1.2/docs: ReleaseNotes.html updated: 1.24 -> 1.25 --- Log message: bug found --- Diffs of the changes: (+3 -1) Index: llvm-www/releases/1.2/docs/ReleaseNotes.html diff -u llvm-www/releases/1.2/docs/ReleaseNotes.html:1.24 llvm-www/releases/1.2/docs/ReleaseNotes.html:1.25 --- llvm-www/releases/1.2/docs/ReleaseNotes.html:1.24 Tue Jul 6 21:27:05 2004 +++ llvm-www/releases/1.2/docs/ReleaseNotes.html Fri Jul 23 14:39:39 2004 @@ -359,6 +359,8 @@

  • Verifier misses malformed switch instruction
  • +
  • Can't add LICM to FunctionPassManager
  • + @@ -690,7 +692,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/07/07 02:27:05 $ + Last modified: $Date: 2004/07/23 19:39:39 $ From gaeke at cs.uiuc.edu Fri Jul 23 14:41:23 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Fri, 23 Jul 2004 14:41:23 -0500 (CDT) Subject: [llvm-commits] CVS: llvm/docs/ReleaseNotes.html Message-ID: <200407231941.OAA11764@seraph.cs.uiuc.edu> Changes in directory llvm/docs: ReleaseNotes.html updated: 1.219 -> 1.220 --- Log message: bug fixed --- Diffs of the changes: (+2 -1) Index: llvm/docs/ReleaseNotes.html diff -u llvm/docs/ReleaseNotes.html:1.219 llvm/docs/ReleaseNotes.html:1.220 --- llvm/docs/ReleaseNotes.html:1.219 Sun Jul 18 02:25:14 2004 +++ llvm/docs/ReleaseNotes.html Fri Jul 23 14:41:13 2004 @@ -295,6 +295,7 @@ an instruction is not embedded into a function
  • [X86] stackifier crash on floating point setcc X, X
  • +
  • Can't add LICM to FunctionPassManager
  • Bugs in the C/C++ front-end:

    @@ -765,7 +766,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/07/18 07:25:14 $ + Last modified: $Date: 2004/07/23 19:41:13 $ From lattner at cs.uiuc.edu Fri Jul 23 16:24:29 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 23 Jul 2004 16:24:29 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp LiveIntervalAnalysis.h Message-ID: <200407232124.QAA31424@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveIntervalAnalysis.cpp updated: 1.106 -> 1.107 LiveIntervalAnalysis.h updated: 1.34 -> 1.35 --- Log message: More minor changes: * Inline some functions * Eliminate some comparisons from the release build This is good for another .3 on gcc. --- Diffs of the changes: (+31 -44) Index: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp diff -u llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.106 llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.107 --- llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.106 Fri Jul 23 12:56:30 2004 +++ llvm/lib/CodeGen/LiveIntervalAnalysis.cpp Fri Jul 23 16:24:19 2004 @@ -374,7 +374,7 @@ DEBUG(std::cerr << '\n'); } -void LiveIntervals::handlePhysicalRegisterDef(MachineBasicBlock* mbb, +void LiveIntervals::handlePhysicalRegisterDef(MachineBasicBlock *MBB, MachineBasicBlock::iterator mi, LiveInterval& interval) { @@ -383,7 +383,6 @@ DEBUG(std::cerr << "\t\tregister: "; printRegName(interval.reg)); typedef LiveVariables::killed_iterator KillIter; - MachineBasicBlock::iterator e = mbb->end(); unsigned baseIndex = getInstructionIndex(mi); unsigned start = getDefIndex(baseIndex); unsigned end = start; @@ -403,8 +402,9 @@ // If it is not dead on definition, it must be killed by a // subsequent instruction. Hence its interval is: // [defSlot(def), useSlot(kill)+1) - do { + while (1) { ++mi; + assert(mi != MBB->end() && "physreg was not killed in defining block!"); baseIndex += InstrSlots::NUM; for (KillIter ki = lv_->killed_begin(mi), ke = lv_->killed_end(mi); ki != ke; ++ki) { @@ -414,7 +414,7 @@ goto exit; } } - } while (mi != e); + } exit: assert(start < end && "did not find end of interval?"); @@ -422,35 +422,16 @@ DEBUG(std::cerr << " +" << LiveRange(start, end) << '\n'); } -void LiveIntervals::handleRegisterDef(MachineBasicBlock* mbb, - MachineBasicBlock::iterator mi, - unsigned reg) -{ - if (MRegisterInfo::isPhysicalRegister(reg)) { - if (lv_->getAllocatablePhysicalRegisters()[reg]) { - handlePhysicalRegisterDef(mbb, mi, getOrCreateInterval(reg)); - for (const unsigned* as = mri_->getAliasSet(reg); *as; ++as) - handlePhysicalRegisterDef(mbb, mi, getOrCreateInterval(*as)); - } - } - else - handleVirtualRegisterDef(mbb, mi, getOrCreateInterval(reg)); -} - -unsigned LiveIntervals::getInstructionIndex(MachineInstr* instr) const -{ - Mi2IndexMap::const_iterator it = mi2iMap_.find(instr); - return (it == mi2iMap_.end() ? - std::numeric_limits::max() : - it->second); -} - -MachineInstr* LiveIntervals::getInstructionFromIndex(unsigned index) const -{ - index /= InstrSlots::NUM; // convert index to vector index - assert(index < i2miMap_.size() && - "index does not correspond to an instruction"); - return i2miMap_[index]; +void LiveIntervals::handleRegisterDef(MachineBasicBlock *MBB, + MachineBasicBlock::iterator MI, + unsigned reg) { + if (MRegisterInfo::isVirtualRegister(reg)) + handleVirtualRegisterDef(MBB, MI, getOrCreateInterval(reg)); + else if (lv_->getAllocatablePhysicalRegisters()[reg]) { + handlePhysicalRegisterDef(MBB, MI, getOrCreateInterval(reg)); + for (const unsigned* AS = mri_->getAliasSet(reg); *AS; ++AS) + handlePhysicalRegisterDef(MBB, MI, getOrCreateInterval(*AS)); + } } /// computeIntervals - computes the live intervals for virtual @@ -490,14 +471,6 @@ } } -unsigned LiveIntervals::rep(unsigned reg) -{ - Reg2RegMap::iterator it = r2rMap_.find(reg); - if (it != r2rMap_.end()) - return it->second = rep(it->second); - return reg; -} - void LiveIntervals::joinIntervalsInMachineBB(MachineBasicBlock *MBB) { DEBUG(std::cerr << ((Value*)MBB->getBasicBlock())->getName() << ":\n"); const TargetInstrInfo& tii = *tm_->getInstrInfo(); Index: llvm/lib/CodeGen/LiveIntervalAnalysis.h diff -u llvm/lib/CodeGen/LiveIntervalAnalysis.h:1.34 llvm/lib/CodeGen/LiveIntervalAnalysis.h:1.35 --- llvm/lib/CodeGen/LiveIntervalAnalysis.h:1.34 Fri Jul 23 13:38:52 2004 +++ llvm/lib/CodeGen/LiveIntervalAnalysis.h Fri Jul 23 16:24:19 2004 @@ -101,11 +101,20 @@ } /// getInstructionIndex - returns the base index of instr - unsigned getInstructionIndex(MachineInstr* instr) const; + unsigned getInstructionIndex(MachineInstr* instr) const { + Mi2IndexMap::const_iterator it = mi2iMap_.find(instr); + assert(it != mi2iMap_.end() && "Invalid instruction!"); + return it->second; + } /// getInstructionFromIndex - given an index in any slot of an /// instruction return a pointer the instruction - MachineInstr* getInstructionFromIndex(unsigned index) const; + MachineInstr* getInstructionFromIndex(unsigned index) const { + index /= InstrSlots::NUM; // convert index to vector index + assert(index < i2miMap_.size() && + "index does not correspond to an instruction"); + return i2miMap_[index]; + } Intervals& getIntervals() { return intervals_; } @@ -150,7 +159,12 @@ LiveInterval& getOrCreateInterval(unsigned reg); /// rep - returns the representative of this register - unsigned rep(unsigned reg); + unsigned rep(unsigned reg) { + Reg2RegMap::iterator it = r2rMap_.find(reg); + if (it != r2rMap_.end()) + return it->second = rep(it->second); + return reg; + } void printRegName(unsigned reg) const; }; From alkis at cs.uiuc.edu Fri Jul 23 19:26:10 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri, 23 Jul 2004 19:26:10 -0500 Subject: [llvm-commits] CVS: llvm-java/test/SingleSource/ Message-ID: <200407240026.TAA29052@zion.cs.uiuc.edu> Changes in directory llvm-java/test/SingleSource: --- Log message: Directory /home/vadve/shared/PublicCVS/llvm-java/test/SingleSource added to the repository --- Diffs of the changes: (+0 -0) From alkis at cs.uiuc.edu Fri Jul 23 19:27:19 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri, 23 Jul 2004 19:27:19 -0500 Subject: [llvm-commits] CVS: llvm-java/test/Makefile.test Message-ID: <200407240027.TAA29103@zion.cs.uiuc.edu> Changes in directory llvm-java/test: Makefile.test updated: 1.3 -> 1.4 --- Log message: Make raw.bc files depend on class2llvm --- Diffs of the changes: (+1 -1) Index: llvm-java/test/Makefile.test diff -u llvm-java/test/Makefile.test:1.3 llvm-java/test/Makefile.test:1.4 --- llvm-java/test/Makefile.test:1.3 Fri Jul 16 05:18:10 2004 +++ llvm-java/test/Makefile.test Fri Jul 23 19:27:09 2004 @@ -20,7 +20,7 @@ .PRECIOUS: Output/.dir Output/%.bc Output/%.ll Output/%.llvm.bc Output/%.llvm # rule to build raw bytecode from a classfile -Output/%.raw.bc: %.class Output/.dir +Output/%.raw.bc: %.class Output/.dir $(CLASS2LLVM) $(CLASS2LLVM) $* | $(LOPT) -mem2reg > $@ #rule to link in runtime to raw bytecode From alkis at cs.uiuc.edu Fri Jul 23 19:43:00 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri, 23 Jul 2004 19:43:00 -0500 Subject: [llvm-commits] CVS: llvm-java/test/Programs/ Message-ID: <200407240043.TAA29261@zion.cs.uiuc.edu> Changes in directory llvm-java/test/Programs: --- Log message: Directory /home/vadve/shared/PublicCVS/llvm-java/test/Programs added to the repository --- Diffs of the changes: (+0 -0) From alkis at cs.uiuc.edu Fri Jul 23 19:43:14 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri, 23 Jul 2004 19:43:14 -0500 Subject: [llvm-commits] CVS: llvm-java/test/Programs/SingleSource/ Message-ID: <200407240043.TAA29278@zion.cs.uiuc.edu> Changes in directory llvm-java/test/Programs/SingleSource: --- Log message: Directory /home/vadve/shared/PublicCVS/llvm-java/test/Programs/SingleSource added to the repository --- Diffs of the changes: (+0 -0) From alkis at cs.uiuc.edu Fri Jul 23 19:46:34 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri, 23 Jul 2004 19:46:34 -0500 Subject: [llvm-commits] CVS: llvm-java/Makefile.rules Message-ID: <200407240046.TAA29328@zion.cs.uiuc.edu> Changes in directory llvm-java: Makefile.rules updated: 1.6 -> 1.7 --- Log message: Move .java -> .class rule in Makefile.test. --- Diffs of the changes: (+0 -7) Index: llvm-java/Makefile.rules diff -u llvm-java/Makefile.rules:1.6 llvm-java/Makefile.rules:1.7 --- llvm-java/Makefile.rules:1.6 Wed Jul 21 04:08:37 2004 +++ llvm-java/Makefile.rules Fri Jul 23 19:46:24 2004 @@ -7,13 +7,6 @@ # ##===----------------------------------------------------------------------===## -ifdef BUILD_JAVA_SOURCE -all:: .class-stamp -.class-stamp: $(shell find . -name '*.java') - $(JAVAC) $? - touch .class-stamp -endif - CLASS2LLVM := $(PROJTOOLCURRENT)/class2llvm$(EXEEXT) # rule to make assembly from bytecode From alkis at cs.uiuc.edu Fri Jul 23 19:46:34 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri, 23 Jul 2004 19:46:34 -0500 Subject: [llvm-commits] CVS: llvm-java/test/Makefile.test Message-ID: <200407240046.TAA29321@zion.cs.uiuc.edu> Changes in directory llvm-java/test: Makefile.test updated: 1.4 -> 1.5 --- Log message: Move .java -> .class rule in Makefile.test. --- Diffs of the changes: (+7 -0) Index: llvm-java/test/Makefile.test diff -u llvm-java/test/Makefile.test:1.4 llvm-java/test/Makefile.test:1.5 --- llvm-java/test/Makefile.test:1.4 Fri Jul 23 19:27:09 2004 +++ llvm-java/test/Makefile.test Fri Jul 23 19:46:24 2004 @@ -9,6 +9,13 @@ include $(LEVEL)/Makefile.common +ifdef BUILD_JAVA_SOURCE +all:: .class-stamp +.class-stamp: $(shell find . -name '*.java') + $(JAVAC) $? + touch .class-stamp +endif + .PHONY: clean clean:: From alkis at cs.uiuc.edu Fri Jul 23 19:49:24 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri, 23 Jul 2004 19:49:24 -0500 Subject: [llvm-commits] CVS: llvm-java/test/Programs/SingleSource/UnitTests/ Message-ID: <200407240049.TAA29396@zion.cs.uiuc.edu> Changes in directory llvm-java/test/Programs/SingleSource/UnitTests: --- Log message: Directory /home/vadve/shared/PublicCVS/llvm-java/test/Programs/SingleSource/UnitTests added to the repository --- Diffs of the changes: (+0 -0) From alkis at cs.uiuc.edu Fri Jul 23 19:53:36 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri, 23 Jul 2004 19:53:36 -0500 Subject: [llvm-commits] CVS: llvm-java/test/Regression/ Message-ID: <200407240053.TAA29452@zion.cs.uiuc.edu> Changes in directory llvm-java/test/Regression: --- Log message: Directory /home/vadve/shared/PublicCVS/llvm-java/test/Regression added to the repository --- Diffs of the changes: (+0 -0) From alkis at cs.uiuc.edu Fri Jul 23 20:29:44 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri, 23 Jul 2004 20:29:44 -0500 Subject: [llvm-commits] CVS: llvm-java/test/Regression/Makefile Message-ID: <200407240129.UAA29724@zion.cs.uiuc.edu> Changes in directory llvm-java/test/Regression: Makefile added (r1.1) --- Log message: Improve testing framework. Now the hierarchy is similar to /test. --- Diffs of the changes: (+13 -0) Index: llvm-java/test/Regression/Makefile diff -c /dev/null llvm-java/test/Regression/Makefile:1.1 *** /dev/null Fri Jul 23 20:29:44 2004 --- llvm-java/test/Regression/Makefile Fri Jul 23 20:29:34 2004 *************** *** 0 **** --- 1,13 ---- + ##===- test/Regression/Makefile ----------------------------*- Makefile -*-===## + # + # The LLVM Compiler Infrastructure + # + # This file was developed by the LLVM research group and is distributed under + # the University of Illinois Open Source License. See LICENSE.TXT for details. + # + ##===----------------------------------------------------------------------===## + LEVEL := ../.. + + PARALLEL_DIRS := ClassFile + + include $(LEVEL)/test/Makefile.test From alkis at cs.uiuc.edu Fri Jul 23 20:29:44 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri, 23 Jul 2004 20:29:44 -0500 Subject: [llvm-commits] CVS: llvm-java/test/Programs/Makefile Message-ID: <200407240129.UAA29745@zion.cs.uiuc.edu> Changes in directory llvm-java/test/Programs: Makefile added (r1.1) --- Log message: Improve testing framework. Now the hierarchy is similar to /test. --- Diffs of the changes: (+13 -0) Index: llvm-java/test/Programs/Makefile diff -c /dev/null llvm-java/test/Programs/Makefile:1.1 *** /dev/null Fri Jul 23 20:29:44 2004 --- llvm-java/test/Programs/Makefile Fri Jul 23 20:29:34 2004 *************** *** 0 **** --- 1,13 ---- + ##===- test/Programs/Makefile ------------------------------*- Makefile -*-===## + # + # The LLVM Compiler Infrastructure + # + # This file was developed by the LLVM research group and is distributed under + # the University of Illinois Open Source License. See LICENSE.TXT for details. + # + ##===----------------------------------------------------------------------===## + LEVEL := ../.. + + PARALLEL_DIRS := SingleSource + + include $(LEVEL)/Makefile.common From alkis at cs.uiuc.edu Fri Jul 23 20:29:44 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri, 23 Jul 2004 20:29:44 -0500 Subject: [llvm-commits] CVS: llvm-java/test/Programs/SingleSource/UnitTests/Makefile Message-ID: <200407240129.UAA29731@zion.cs.uiuc.edu> Changes in directory llvm-java/test/Programs/SingleSource/UnitTests: Makefile updated: 1.2 -> 1.3 --- Log message: Improve testing framework. Now the hierarchy is similar to /test. --- Diffs of the changes: (+5 -3) Index: llvm-java/test/Programs/SingleSource/UnitTests/Makefile diff -u llvm-java/test/Programs/SingleSource/UnitTests/Makefile:1.2 llvm-java/test/Programs/SingleSource/UnitTests/Makefile:1.3 --- llvm-java/test/Programs/SingleSource/UnitTests/Makefile:1.2 Thu Jul 15 06:28:44 2004 +++ llvm-java/test/Programs/SingleSource/UnitTests/Makefile Fri Jul 23 20:29:34 2004 @@ -1,4 +1,4 @@ -##===- tests/Compiler/Makefile -----------------------------*- Makefile -*-===## +##===- test/Programs/SingleSource/UnitTests/Makefile -------*- Makefile -*-===## # # The LLVM Compiler Infrastructure # @@ -6,10 +6,12 @@ # the University of Illinois Open Source License. See LICENSE.TXT for details. # ##===----------------------------------------------------------------------===## -LEVEL := ../.. +LEVEL := ../../../.. CLASSFILES := $(wildcard *.class) +BUILD_JAVA_SOURCE=1 + all:: $(foreach ext,linked.dis-ll,$(CLASSFILES:%.class=Output/%.$(ext))) -include $(LEVEL)/test/Makefile.test +include ../Makefile.singlesrc From alkis at cs.uiuc.edu Fri Jul 23 20:29:44 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri, 23 Jul 2004 20:29:44 -0500 Subject: [llvm-commits] CVS: llvm-java/test/Programs/SingleSource/Makefile.singlesrc Makefile Message-ID: <200407240129.UAA29742@zion.cs.uiuc.edu> Changes in directory llvm-java/test/Programs/SingleSource: Makefile.singlesrc added (r1.1) Makefile added (r1.1) --- Log message: Improve testing framework. Now the hierarchy is similar to /test. --- Diffs of the changes: (+27 -0) Index: llvm-java/test/Programs/SingleSource/Makefile.singlesrc diff -c /dev/null llvm-java/test/Programs/SingleSource/Makefile.singlesrc:1.1 *** /dev/null Fri Jul 23 20:29:44 2004 --- llvm-java/test/Programs/SingleSource/Makefile.singlesrc Fri Jul 23 20:29:34 2004 *************** *** 0 **** --- 1,14 ---- + ##==-- test/Programs/SingleSource/Makefile.singlesrc -----*- makefile -*--====## + # + # The LLVM Compiler Infrastructure + # + # This file was developed by the LLVM research group and is distributed under + # the University of Illinois Open Source License. See LICENSE.TXT for details. + # + ##===----------------------------------------------------------------------===## + + # rule to build raw bytecode from a classfile + Output/%.raw.bc: %.class Output/.dir $(CLASS2LLVM) + $(CLASS2LLVM) $* | $(LOPT) -mem2reg > $@ + + include $(LEVEL)/test/Makefile.test Index: llvm-java/test/Programs/SingleSource/Makefile diff -c /dev/null llvm-java/test/Programs/SingleSource/Makefile:1.1 *** /dev/null Fri Jul 23 20:29:44 2004 --- llvm-java/test/Programs/SingleSource/Makefile Fri Jul 23 20:29:34 2004 *************** *** 0 **** --- 1,13 ---- + ##===- test/Programs/SingleSource/Makefile -----------------*- Makefile -*-===## + # + # The LLVM Compiler Infrastructure + # + # This file was developed by the LLVM research group and is distributed under + # the University of Illinois Open Source License. See LICENSE.TXT for details. + # + ##===----------------------------------------------------------------------===## + LEVEL := ../../.. + + PARALLEL_DIRS := UnitTests + + include Makefile.singlesrc From alkis at cs.uiuc.edu Fri Jul 23 20:29:44 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri, 23 Jul 2004 20:29:44 -0500 Subject: [llvm-commits] CVS: llvm-java/Makefile.rules Message-ID: <200407240129.UAA29761@zion.cs.uiuc.edu> Changes in directory llvm-java: Makefile.rules updated: 1.7 -> 1.8 --- Log message: Improve testing framework. Now the hierarchy is similar to /test. --- Diffs of the changes: (+1 -8) Index: llvm-java/Makefile.rules diff -u llvm-java/Makefile.rules:1.7 llvm-java/Makefile.rules:1.8 --- llvm-java/Makefile.rules:1.7 Fri Jul 23 19:46:24 2004 +++ llvm-java/Makefile.rules Fri Jul 23 20:29:34 2004 @@ -8,11 +8,4 @@ ##===----------------------------------------------------------------------===## CLASS2LLVM := $(PROJTOOLCURRENT)/class2llvm$(EXEEXT) - -# rule to make assembly from bytecode -%.dis-ll: %.bc - $(LDIS) < $< > $@ - -# rule to make bytecode from assembly -%.bc: %.ll - $(LAS) < $< > $@ +CLASSDUMP := $(PROJTOOLCURRENT)/classdump$(EXEEXT) From alkis at cs.uiuc.edu Fri Jul 23 20:29:44 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri, 23 Jul 2004 20:29:44 -0500 Subject: [llvm-commits] CVS: llvm-java/test/Makefile.test Makefile Message-ID: <200407240129.UAA29757@zion.cs.uiuc.edu> Changes in directory llvm-java/test: Makefile.test updated: 1.5 -> 1.6 Makefile updated: 1.2 -> 1.3 --- Log message: Improve testing framework. Now the hierarchy is similar to /test. --- Diffs of the changes: (+10 -6) Index: llvm-java/test/Makefile.test diff -u llvm-java/test/Makefile.test:1.5 llvm-java/test/Makefile.test:1.6 --- llvm-java/test/Makefile.test:1.5 Fri Jul 23 19:46:24 2004 +++ llvm-java/test/Makefile.test Fri Jul 23 20:29:34 2004 @@ -19,17 +19,21 @@ .PHONY: clean clean:: - $(RM) -f a.out core + $(RM) -f a.out core *.class .class-stamp $(RM) -rf Output/ # we don't want these files to be deleted by make, even if they are # intermediate results .PRECIOUS: Output/.dir Output/%.bc Output/%.ll Output/%.llvm.bc Output/%.llvm -# rule to build raw bytecode from a classfile -Output/%.raw.bc: %.class Output/.dir $(CLASS2LLVM) - $(CLASS2LLVM) $* | $(LOPT) -mem2reg > $@ - #rule to link in runtime to raw bytecode Output/%.linked.bc: Output/%.raw.bc $(BUILD_SRC_ROOT)/runtime/runtime.bc $(LLVMTOOLCURRENT)/llvm-link$(EXEEXT) $^ -o $@ + +# rule to make assembly from bytecode +%.dis-ll: %.bc + $(LDIS) < $< > $@ + +# rule to make bytecode from assembly +%.bc: %.ll + $(LAS) < $< > $@ Index: llvm-java/test/Makefile diff -u llvm-java/test/Makefile:1.2 llvm-java/test/Makefile:1.3 --- llvm-java/test/Makefile:1.2 Tue Jul 13 19:31:40 2004 +++ llvm-java/test/Makefile Fri Jul 23 20:29:34 2004 @@ -8,6 +8,6 @@ ##===----------------------------------------------------------------------===## LEVEL := .. -BUILD_JAVA_SOURCE=1 +PARALLEL_DIRS := Programs Regression include $(LEVEL)/Makefile.common From alkis at cs.uiuc.edu Fri Jul 23 20:44:14 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri, 23 Jul 2004 20:44:14 -0500 Subject: [llvm-commits] CVS: llvm-java/test/Programs/SingleSource/Makefile Message-ID: <200407240144.UAA29875@zion.cs.uiuc.edu> Changes in directory llvm-java/test/Programs/SingleSource: Makefile updated: 1.1 -> 1.2 --- Log message: We don't need to include Makefile.singlesrc here. --- Diffs of the changes: (+1 -1) Index: llvm-java/test/Programs/SingleSource/Makefile diff -u llvm-java/test/Programs/SingleSource/Makefile:1.1 llvm-java/test/Programs/SingleSource/Makefile:1.2 --- llvm-java/test/Programs/SingleSource/Makefile:1.1 Fri Jul 23 20:29:34 2004 +++ llvm-java/test/Programs/SingleSource/Makefile Fri Jul 23 20:44:04 2004 @@ -10,4 +10,4 @@ PARALLEL_DIRS := UnitTests -include Makefile.singlesrc +include $(LEVEL)/Makefile.common From lattner at cs.uiuc.edu Fri Jul 23 21:52:33 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 23 Jul 2004 21:52:33 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveInterval.h LiveInterval.cpp Message-ID: <200407240252.VAA24713@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveInterval.h updated: 1.4 -> 1.5 LiveInterval.cpp updated: 1.4 -> 1.5 --- Log message: Little stuff: * Fix comment typeo * add dump() methods * add a few new methods like getLiveRangeContaining, removeRange & joinable (which is currently the same as overlaps) * Remove the unused operator== Bigger change: * In LiveInterval, instead of using a boolean isDefinedOnce to keep track of if there are > 1 definitions in a particular interval, keep a counter, NumValues to keep track of exactly how many there are. * In LiveRange, add a new ValId element to indicate which of the numbered values each LiveRange belongs to. We now no longer merge LiveRanges if they are of differing value ID's even if they are neighbors. --- Diffs of the changes: (+167 -27) Index: llvm/lib/CodeGen/LiveInterval.h diff -u llvm/lib/CodeGen/LiveInterval.h:1.4 llvm/lib/CodeGen/LiveInterval.h:1.5 --- llvm/lib/CodeGen/LiveInterval.h:1.4 Fri Jul 23 14:38:44 2004 +++ llvm/lib/CodeGen/LiveInterval.h Fri Jul 23 21:52:23 2004 @@ -10,7 +10,7 @@ // This file implements the LiveRange and LiveInterval classes. Given some // numbering of each the machine instructions an interval [i, j) is said to be a // live interval for register v if there is no instruction with number j' > j -// such that v is live at j' abd there is no instruction with number i' < i such +// such that v is live at j' and there is no instruction with number i' < i such // that v is live at i'. In this implementation intervals can have holes, // i.e. an interval might look like [1,20), [50,65), [1000,1001). Each // individual range is represented as an instance of LiveRange, and the whole @@ -31,8 +31,10 @@ /// These ranges are rendered as [start,end). struct LiveRange { unsigned start; // Start point of the interval (inclusive) - unsigned end; // End point of the interval (exclusive) - LiveRange(unsigned S, unsigned E) : start(S), end(E) { + unsigned end; // End point of the interval (exclusive) + unsigned ValId; // identifier for the value contained in this interval. + + LiveRange(unsigned S, unsigned E, unsigned V) : start(S), end(E), ValId(V) { assert(S < E && "Cannot create empty or backwards range"); } @@ -48,6 +50,9 @@ bool operator==(const LiveRange &LR) const { return start == LR.start && end == LR.end; } + + void dump() const; + private: LiveRange(); // DO NOT IMPLEMENT }; @@ -66,13 +71,16 @@ unsigned reg; // the register of this interval float weight; // weight of this interval Ranges ranges; // the ranges in which this register is live - bool isDefinedOnce; // True if this interval contains one value. LiveInterval(unsigned Reg, float Weight) - : reg(Reg), weight(Weight), isDefinedOnce(false) { + : reg(Reg), weight(Weight), NumValues(0) { } - bool containsOneValue() const { return isDefinedOnce; } + bool containsOneValue() const { return NumValues == 1; } + + unsigned getNextValue() { + return NumValues++; + } bool empty() const { return ranges.empty(); } @@ -95,6 +103,17 @@ bool liveAt(unsigned index) const; + /// getLiveRangeContaining - Return the live range that contains the + /// specified index, or null if there is none. + LiveRange *getLiveRangeContaining(unsigned Idx); + + + /// joinable - Two intervals are joinable if the either don't overlap at all + /// or if the destination of the copy is a single assignment value, and it + /// only overlaps with one value in the source interval. + bool joinable(const LiveInterval& other, unsigned CopyIdx) const; + + bool overlaps(const LiveInterval& other) const; /// addRange - Add the specified LiveRange to this interval, merging @@ -104,17 +123,25 @@ addRangeFrom(LR, ranges.begin()); } - void join(const LiveInterval& other); + /// join - Join two live intervals (this, and other) together. This + /// operation is the result of a copy instruction in the source program, + /// that occurs at index 'CopyIdx' that copies from 'other' to 'this'. This + /// destroys 'other'. + void join(LiveInterval& other, unsigned CopyIdx); + + + /// removeRange - Remove the specified range from this interval. Note that + /// the range must already be in this interval in its entirety. + void removeRange(unsigned Start, unsigned End); bool operator<(const LiveInterval& other) const { return start() < other.start(); } - bool operator==(const LiveInterval& other) const { - return reg == other.reg; - } + void dump() const; private: + unsigned NumValues; // the number of distinct values in this interval. Ranges::iterator addRangeFrom(LiveRange LR, Ranges::iterator From); void extendIntervalEndTo(Ranges::iterator I, unsigned NewEnd); Ranges::iterator extendIntervalStartTo(Ranges::iterator I, unsigned NewStr); Index: llvm/lib/CodeGen/LiveInterval.cpp diff -u llvm/lib/CodeGen/LiveInterval.cpp:1.4 llvm/lib/CodeGen/LiveInterval.cpp:1.5 --- llvm/lib/CodeGen/LiveInterval.cpp:1.4 Fri Jul 23 14:38:44 2004 +++ llvm/lib/CodeGen/LiveInterval.cpp Fri Jul 23 21:52:23 2004 @@ -20,7 +20,8 @@ #include "LiveInterval.h" #include "Support/STLExtras.h" -#include +#include +#include using namespace llvm; // An example for liveAt(): @@ -87,17 +88,27 @@ return false; } +/// joinable - Two intervals are joinable if the either don't overlap at all +/// or if the destination of the copy is a single assignment value, and it +/// only overlaps with one value in the source interval. +bool LiveInterval::joinable(const LiveInterval &other, unsigned CopyIdx) const { + return overlaps(other); +} + + /// extendIntervalEndTo - This method is used when we want to extend the range /// specified by I to end at the specified endpoint. To do this, we should /// merge and eliminate all ranges that this will overlap with. The iterator is /// not invalidated. void LiveInterval::extendIntervalEndTo(Ranges::iterator I, unsigned NewEnd) { assert(I != ranges.end() && "Not a valid interval!"); + unsigned ValId = I->ValId; // Search for the first interval that we can't merge with. Ranges::iterator MergeTo = next(I); - for (; MergeTo != ranges.end() && NewEnd >= MergeTo->end; ++MergeTo) - /*empty*/; + for (; MergeTo != ranges.end() && NewEnd >= MergeTo->end; ++MergeTo) { + assert(MergeTo->ValId == ValId && "Cannot merge with differing values!"); + } // If NewEnd was in the middle of an interval, make sure to get its endpoint. I->end = std::max(NewEnd, prior(MergeTo)->end); @@ -113,20 +124,23 @@ LiveInterval::Ranges::iterator LiveInterval::extendIntervalStartTo(Ranges::iterator I, unsigned NewStart) { assert(I != ranges.end() && "Not a valid interval!"); + unsigned ValId = I->ValId; // Search for the first interval that we can't merge with. Ranges::iterator MergeTo = I; do { if (MergeTo == ranges.begin()) { I->start = NewStart; + ranges.erase(MergeTo, I); return I; } + assert(MergeTo->ValId == ValId && "Cannot merge with differing values!"); --MergeTo; } while (NewStart <= MergeTo->start); // If we start in the middle of another interval, just delete a range and // extend that interval. - if (MergeTo->end >= NewStart) { + if (MergeTo->end >= NewStart && MergeTo->ValId == ValId) { MergeTo->end = I->end; } else { // Otherwise, extend the interval right after. @@ -148,38 +162,133 @@ // another interval, just extend that interval to contain the range of LR. if (it != ranges.begin()) { Ranges::iterator B = prior(it); - if (B->start <= Start && B->end >= Start) { - extendIntervalEndTo(B, End); - return B; + if (LR.ValId == B->ValId) { + if (B->start <= Start && B->end >= Start) { + extendIntervalEndTo(B, End); + return B; + } + } else { + // Check to make sure that we are not overlapping two live ranges with + // different ValId's. + assert(B->end <= Start && + "Cannot overlap two LiveRanges with differing ValID's"); } } // Otherwise, if this range ends in the middle of, or right next to, another // interval, merge it into that interval. - if (it != ranges.end() && it->start <= End) - return extendIntervalStartTo(it, Start); + if (it != ranges.end()) + if (LR.ValId == it->ValId) { + if (it->start <= End) { + it = extendIntervalStartTo(it, Start); + + // If LR is a complete superset of an interval, we may need to grow its + // endpoint as well. + if (End > it->end) + extendIntervalEndTo(it, End); + return it; + } + } else { + // Check to make sure that we are not overlapping two live ranges with + // different ValId's. + assert(it->start >= End && + "Cannot overlap two LiveRanges with differing ValID's"); + } // Otherwise, this is just a new range that doesn't interact with anything. // Insert it. return ranges.insert(it, LR); } -void LiveInterval::join(const LiveInterval& other) { - isDefinedOnce &= other.isDefinedOnce; + +/// removeRange - Remove the specified range from this interval. Note that +/// the range must already be in this interval in its entirety. +void LiveInterval::removeRange(unsigned Start, unsigned End) { + // Find the LiveRange containing this span. + Ranges::iterator I = std::upper_bound(ranges.begin(), ranges.end(), Start); + assert(I != ranges.begin() && "Range is not in interval!"); + --I; + assert(I->contains(Start) && I->contains(End-1) && + "Range is not entirely in interval!"); + + // If the span we are removing is at the start of the LiveRange, adjust it. + if (I->start == Start) { + if (I->end == End) + ranges.erase(I); // Removed the whole LiveRange. + else + I->start = End; + return; + } + + // Otherwise if the span we are removing is at the end of the LiveRange, + // adjust the other way. + if (I->end == End) { + I->start = Start; + return; + } + + // Otherwise, we are splitting the LiveRange into two pieces. + unsigned OldEnd = I->end; + I->end = Start; // Trim the old interval. + + // Insert the new one. + ranges.insert(next(I), LiveRange(End, OldEnd, I->ValId)); +} + +/// getLiveRangeContaining - Return the live range that contains the +/// specified index, or null if there is none. +LiveRange *LiveInterval::getLiveRangeContaining(unsigned Idx) { + Ranges::iterator It = std::upper_bound(ranges.begin(), ranges.end(), Idx); + if (It != ranges.begin()) { + LiveRange &LR = *prior(It); + if (LR.contains(Idx)) + return &LR; + } + + return 0; +} + + + +/// join - Join two live intervals (this, and other) together. This operation +/// is the result of a copy instruction in the source program, that occurs at +/// index 'CopyIdx' that copies from 'Other' to 'this'. +void LiveInterval::join(LiveInterval &Other, unsigned CopyIdx) { + LiveRange *SourceLR = Other.getLiveRangeContaining(CopyIdx-1); + LiveRange *DestLR = getLiveRangeContaining(CopyIdx); + assert(SourceLR && DestLR && "Not joining due to a copy?"); + unsigned MergedSrcValIdx = SourceLR->ValId; + unsigned MergedDstValIdx = DestLR->ValId; // Join the ranges of other into the ranges of this interval. - Ranges::iterator cur = ranges.begin(); - for (Ranges::const_iterator i = other.ranges.begin(), - e = other.ranges.end(); i != e; ++i) - cur = addRangeFrom(*i, cur); + Ranges::iterator InsertPos = ranges.begin(); + std::map Dst2SrcIdxMap; + for (Ranges::iterator I = Other.ranges.begin(), + E = Other.ranges.end(); I != E; ++I) { + // Map the ValId in the other live range to the current live range. + if (I->ValId == MergedSrcValIdx) + I->ValId = MergedDstValIdx; + else { + unsigned &NV = Dst2SrcIdxMap[I->ValId]; + if (NV == 0) NV = getNextValue(); + I->ValId = NV; + } - weight += other.weight; + InsertPos = addRangeFrom(*I, InsertPos); + } + + weight += Other.weight; } std::ostream& llvm::operator<<(std::ostream& os, const LiveRange &LR) { - return os << "[" << LR.start << "," << LR.end << ")"; + return os << '[' << LR.start << ',' << LR.end << ':' << LR.ValId << ")"; +} + +void LiveRange::dump() const { + std::cerr << *this << "\n"; } + std::ostream& llvm::operator<<(std::ostream& os, const LiveInterval& li) { os << "%reg" << li.reg << ',' << li.weight; if (li.empty()) @@ -191,3 +300,7 @@ os << *i; return os; } + +void LiveInterval::dump() const { + std::cerr << *this << "\n"; +} From lattner at cs.uiuc.edu Fri Jul 23 21:53:54 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 23 Jul 2004 21:53:54 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervalAnalysis.h Message-ID: <200407240253.VAA24728@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveIntervalAnalysis.h updated: 1.35 -> 1.36 --- Log message: Add a new differingRegisterClasses method make overlapsAliases take pointers instead of references fix indentation --- Diffs of the changes: (+8 -4) Index: llvm/lib/CodeGen/LiveIntervalAnalysis.h diff -u llvm/lib/CodeGen/LiveIntervalAnalysis.h:1.35 llvm/lib/CodeGen/LiveIntervalAnalysis.h:1.36 --- llvm/lib/CodeGen/LiveIntervalAnalysis.h:1.35 Fri Jul 23 16:24:19 2004 +++ llvm/lib/CodeGen/LiveIntervalAnalysis.h Fri Jul 23 21:53:43 2004 @@ -96,8 +96,8 @@ LiveInterval& getInterval(unsigned reg) { Reg2IntervalMap::iterator I = r2iMap_.find(reg); - assert(I != r2iMap_.end()&& "Interval does not exist for register"); - return *I->second; + assert(I != r2iMap_.end()&& "Interval does not exist for register"); + return *I->second; } /// getInstructionIndex - returns the base index of instr @@ -152,8 +152,12 @@ MachineBasicBlock::iterator mi, LiveInterval& interval); - bool overlapsAliases(const LiveInterval& lhs, - const LiveInterval& rhs) const; + /// Return true if the two specified registers belong to different + /// register classes. The registers may be either phys or virt regs. + bool differingRegisterClasses(unsigned RegA, unsigned RegB) const; + + bool overlapsAliases(const LiveInterval *lhs, + const LiveInterval *rhs) const; LiveInterval& getOrCreateInterval(unsigned reg); From lattner at cs.uiuc.edu Fri Jul 23 21:59:17 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 23 Jul 2004 21:59:17 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp Message-ID: <200407240259.VAA24747@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveIntervalAnalysis.cpp updated: 1.107 -> 1.108 --- Log message: Big change to compute logical value numbers for each LiveRange added to an Interval. This generalizes the isDefinedOnce mechanism that we used before to help us coallesce ranges that overlap. As part of this, every logical range with a different value is assigned a different number in the interval. For example, for code that looks like this: 0 X = ... 4 X += ... ... N = X We now generate a live interval that contains two ranges: [2,6:0),[6,?:1) reflecting the fact that there are two different values in the range at different positions in the code. Currently we are not using this information at all, so this just slows down liveintervals. In the future, this will change. Note that this change also substantially refactors the joinIntervalsInMachineBB method to merge the cases for virt-virt and phys-virt joining into a single case, adds comments, and makes the code a bit easier to follow. --- Diffs of the changes: (+150 -124) Index: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp diff -u llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.107 llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.108 --- llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.107 Fri Jul 23 16:24:19 2004 +++ llvm/lib/CodeGen/LiveIntervalAnalysis.cpp Fri Jul 23 21:59:07 2004 @@ -106,6 +106,12 @@ numIntervals += intervals_.size(); +#if 1 + DEBUG(std::cerr << "********** INTERVALS **********\n"); + DEBUG(std::copy(intervals_.begin(), intervals_.end(), + std::ostream_iterator(std::cerr, "\n"))); +#endif + // join intervals if requested if (EnableJoining) joinIntervals(); @@ -250,8 +256,9 @@ // the spill weight is now infinity as it // cannot be spilled again nI.weight = HUGE_VAL; - DEBUG(std::cerr << " +" << LiveRange(start, end)); - nI.addRange(LiveRange(start, end)); + LiveRange LR(start, end, nI.getNextValue()); + DEBUG(std::cerr << " +" << LR); + nI.addRange(LR); added.push_back(&nI); // update live variables lv_->addVirtualRegisterKilled(nReg, mi); @@ -286,12 +293,13 @@ // done once for the vreg. We use an empty interval to detect the first // time we see a vreg. if (interval.empty()) { - // Assume this interval is singly defined until we find otherwise. - interval.isDefinedOnce = true; - // Get the Idx of the defining instructions. unsigned defIndex = getDefIndex(getInstructionIndex(mi)); + unsigned ValNum = interval.getNextValue(); + assert(ValNum == 0 && "First value in interval is not 0?"); + ValNum = 0; // Clue in the optimizer. + // Loop over all of the blocks that the vreg is defined in. There are // two cases we have to handle here. The most common case is a vreg // whose lifetime is contained within a basic block. In this case there @@ -309,8 +317,9 @@ if (killIdx > defIndex) { assert(vi.AliveBlocks.empty() && "Shouldn't be alive across any blocks!"); - interval.addRange(LiveRange(defIndex, killIdx)); - DEBUG(std::cerr << " +" << LiveRange(defIndex, killIdx) << "\n"); + LiveRange LR(defIndex, killIdx, ValNum); + interval.addRange(LR); + DEBUG(std::cerr << " +" << LR << "\n"); return; } } @@ -320,7 +329,7 @@ // live into some number of blocks, but gets killed. Start by adding a // range that goes from this definition to the end of the defining block. LiveRange NewLR(defIndex, getInstructionIndex(&mbb->back()) + - InstrSlots::NUM); + InstrSlots::NUM, ValNum); DEBUG(std::cerr << " +" << NewLR); interval.addRange(NewLR); @@ -332,7 +341,8 @@ MachineBasicBlock* mbb = mf_->getBlockNumbered(i); if (!mbb->empty()) { LiveRange LR(getInstructionIndex(&mbb->front()), - getInstructionIndex(&mbb->back())+InstrSlots::NUM); + getInstructionIndex(&mbb->back())+InstrSlots::NUM, + ValNum); interval.addRange(LR); DEBUG(std::cerr << " +" << LR); } @@ -344,7 +354,7 @@ for (unsigned i = 0, e = vi.Kills.size(); i != e; ++i) { MachineInstr *Kill = vi.Kills[i]; LiveRange LR(getInstructionIndex(Kill->getParent()->begin()), - getUseIndex(getInstructionIndex(Kill))+1); + getUseIndex(getInstructionIndex(Kill))+1, ValNum); interval.addRange(LR); DEBUG(std::cerr << " +" << LR); } @@ -357,18 +367,44 @@ if (mi->getOperand(0).isRegister() && mi->getOperand(0).getReg() == interval.reg && mi->getOperand(0).isDef() && mi->getOperand(0).isUse()) { - // If this is a two-address definition, just ignore it. + // If this is a two-address definition, then we have already processed + // the live range. The only problem is that we didn't realize there + // are actually two values in the live interval. Because of this we + // need to take the LiveRegion that defines this register and split it + // into two values. + unsigned DefIndex = getDefIndex(getInstructionIndex(vi.DefInst)); + unsigned RedefIndex = getDefIndex(getInstructionIndex(mi)); + + // Delete the initial value, which should be short and continuous, + // becuase the 2-addr copy must be in the same MBB as the redef. + interval.removeRange(DefIndex, RedefIndex); + + LiveRange LR(DefIndex, RedefIndex, interval.getNextValue()); + DEBUG(std::cerr << " replace range with " << LR); + interval.addRange(LR); + + // If this redefinition is dead, we need to add a dummy unit live + // range covering the def slot. + for (LiveVariables::killed_iterator KI = lv_->dead_begin(mi), + E = lv_->dead_end(mi); KI != E; ++KI) + if (KI->second == interval.reg) { + interval.addRange(LiveRange(RedefIndex, RedefIndex+1, 0)); + break; + } + + DEBUG(std::cerr << "RESULT: " << interval); + } else { // Otherwise, this must be because of phi elimination. In this case, // the defined value will be live until the end of the basic block it // is defined in. unsigned defIndex = getDefIndex(getInstructionIndex(mi)); LiveRange LR(defIndex, - getInstructionIndex(&mbb->back()) +InstrSlots::NUM); + getInstructionIndex(&mbb->back()) + InstrSlots::NUM, + interval.getNextValue()); interval.addRange(LR); DEBUG(std::cerr << " +" << LR); } - interval.isDefinedOnce = false; } DEBUG(std::cerr << '\n'); @@ -402,7 +438,7 @@ // If it is not dead on definition, it must be killed by a // subsequent instruction. Hence its interval is: // [defSlot(def), useSlot(kill)+1) - while (1) { + while (true) { ++mi; assert(mi != MBB->end() && "physreg was not killed in defining block!"); baseIndex += InstrSlots::NUM; @@ -418,8 +454,9 @@ exit: assert(start < end && "did not find end of interval?"); - interval.addRange(LiveRange(start, end)); - DEBUG(std::cerr << " +" << LiveRange(start, end) << '\n'); + LiveRange LR(start, end, interval.getNextValue()); + interval.addRange(LR); + DEBUG(std::cerr << " +" << LR << '\n'); } void LiveIntervals::handleRegisterDef(MachineBasicBlock *MBB, @@ -472,109 +509,73 @@ } void LiveIntervals::joinIntervalsInMachineBB(MachineBasicBlock *MBB) { - DEBUG(std::cerr << ((Value*)MBB->getBasicBlock())->getName() << ":\n"); - const TargetInstrInfo& tii = *tm_->getInstrInfo(); + DEBUG(std::cerr << ((Value*)MBB->getBasicBlock())->getName() << ":\n"); + const TargetInstrInfo &TII = *tm_->getInstrInfo(); - for (MachineBasicBlock::iterator mi = MBB->begin(), mie = MBB->end(); - mi != mie; ++mi) { - const TargetInstrDescriptor& tid = tii.get(mi->getOpcode()); - DEBUG(std::cerr << getInstructionIndex(mi) << '\t'; - mi->print(std::cerr, tm_);); - - // we only join virtual registers with allocatable - // physical registers since we do not have liveness information - // on not allocatable physical registers - unsigned regA, regB; - if (tii.isMoveInstr(*mi, regA, regB) && - (MRegisterInfo::isVirtualRegister(regA) || - lv_->getAllocatablePhysicalRegisters()[regA]) && - (MRegisterInfo::isVirtualRegister(regB) || - lv_->getAllocatablePhysicalRegisters()[regB])) { - - // get representative registers - regA = rep(regA); - regB = rep(regB); - - // if they are already joined we continue - if (regA == regB) - continue; - - Reg2IntervalMap::iterator r2iA = r2iMap_.find(regA); - assert(r2iA != r2iMap_.end() && - "Found unknown vreg in 'isMoveInstr' instruction"); - Reg2IntervalMap::iterator r2iB = r2iMap_.find(regB); - assert(r2iB != r2iMap_.end() && - "Found unknown vreg in 'isMoveInstr' instruction"); - - Intervals::iterator intA = r2iA->second; - Intervals::iterator intB = r2iB->second; - - DEBUG(std::cerr << "\t\tInspecting " << *intA << " and " << *intB - << ": "); - - // both A and B are virtual registers - if (MRegisterInfo::isVirtualRegister(intA->reg) && - MRegisterInfo::isVirtualRegister(intB->reg)) { - - const TargetRegisterClass *rcA, *rcB; - rcA = mf_->getSSARegMap()->getRegClass(intA->reg); - rcB = mf_->getSSARegMap()->getRegClass(intB->reg); - - // if they are not of the same register class we continue - if (rcA != rcB) { - DEBUG(std::cerr << "Differing reg classes.\n"); - continue; - } - - // if their intervals do not overlap we join them. - if ((intA->containsOneValue() && intB->containsOneValue()) || - !intB->overlaps(*intA)) { - intA->join(*intB); - ++numJoins; - DEBUG(std::cerr << "Joined. Result = " << *intA << "\n"); - r2iB->second = r2iA->second; - r2rMap_.insert(std::make_pair(intB->reg, intA->reg)); - intervals_.erase(intB); - } else { - DEBUG(std::cerr << "Interference!\n"); - } - } else if (!MRegisterInfo::isPhysicalRegister(intA->reg) || - !MRegisterInfo::isPhysicalRegister(intB->reg)) { - if (MRegisterInfo::isPhysicalRegister(intB->reg)) { - std::swap(regA, regB); - std::swap(intA, intB); - std::swap(r2iA, r2iB); - } - - assert(MRegisterInfo::isPhysicalRegister(intA->reg) && - MRegisterInfo::isVirtualRegister(intB->reg) && - "A must be physical and B must be virtual"); - - const TargetRegisterClass *rcA, *rcB; - rcA = mri_->getRegClass(intA->reg); - rcB = mf_->getSSARegMap()->getRegClass(intB->reg); - // if they are not of the same register class we continue - if (rcA != rcB) { - DEBUG(std::cerr << "Differing reg classes.\n"); - continue; - } - - if (!intA->overlaps(*intB) && - !overlapsAliases(*intA, *intB)) { - intA->join(*intB); - ++numJoins; - DEBUG(std::cerr << "Joined. Result = " << *intA << "\n"); - r2iB->second = r2iA->second; - r2rMap_.insert(std::make_pair(intB->reg, intA->reg)); - intervals_.erase(intB); - } else { - DEBUG(std::cerr << "Interference!\n"); - } - } else { - DEBUG(std::cerr << "Cannot join physregs.\n"); - } + for (MachineBasicBlock::iterator mi = MBB->begin(), mie = MBB->end(); + mi != mie; ++mi) { + DEBUG(std::cerr << getInstructionIndex(mi) << '\t' << *mi); + + // we only join virtual registers with allocatable + // physical registers since we do not have liveness information + // on not allocatable physical registers + unsigned regA, regB; + if (TII.isMoveInstr(*mi, regA, regB) && + (MRegisterInfo::isVirtualRegister(regA) || + lv_->getAllocatablePhysicalRegisters()[regA]) && + (MRegisterInfo::isVirtualRegister(regB) || + lv_->getAllocatablePhysicalRegisters()[regB])) { + + // Get representative registers. + regA = rep(regA); + regB = rep(regB); + + // If they are already joined we continue. + if (regA == regB) + continue; + + // If they are both physical registers, we cannot join them. + if (MRegisterInfo::isPhysicalRegister(regA) && + MRegisterInfo::isPhysicalRegister(regB)) + continue; + + // If they are not of the same register class, we cannot join them. + if (differingRegisterClasses(regA, regB)) + continue; + + LiveInterval &IntA = getInterval(regA); + LiveInterval &IntB = getInterval(regB); + assert(IntA.reg == regA && IntB.reg == regB && + "Register mapping is horribly broken!"); + + bool TriviallyJoinable = + IntA.containsOneValue() && IntB.containsOneValue(); + + unsigned MIDefIdx = getDefIndex(getInstructionIndex(mi)); + if ((TriviallyJoinable || !IntB.joinable(IntA, MIDefIdx)) && + !overlapsAliases(&IntA, &IntB)) { + IntB.join(IntA, MIDefIdx); + + // FIXME: Turn 'intervals_' into an ilist so we don't need to do these + // map lookups! + intervals_.erase(r2iMap_[regA]); + r2iMap_[regA] = r2iMap_[regB]; + + if (!MRegisterInfo::isPhysicalRegister(regA)) { + r2rMap_[regA] = regB; + } else { + // Otherwise merge the data structures the other way so we don't lose + // the physreg information. + r2rMap_[regB] = regA; + IntB.reg = regA; } + DEBUG(std::cerr << "Joined. Result = " << IntB << "\n"); + ++numJoins; + } else { + DEBUG(std::cerr << "Interference!\n"); + } } + } } namespace { @@ -617,16 +618,41 @@ } } -bool LiveIntervals::overlapsAliases(const LiveInterval& lhs, - const LiveInterval& rhs) const -{ - assert(MRegisterInfo::isPhysicalRegister(lhs.reg) && - "first interval must describe a physical register"); +/// Return true if the two specified registers belong to different register +/// classes. The registers may be either phys or virt regs. +bool LiveIntervals::differingRegisterClasses(unsigned RegA, + unsigned RegB) const { + const TargetRegisterClass *RegClass; + + // Get the register classes for the first reg. + if (MRegisterInfo::isVirtualRegister(RegA)) + RegClass = mf_->getSSARegMap()->getRegClass(RegA); + else + RegClass = mri_->getRegClass(RegA); + + // Compare against the regclass for the second reg. + if (MRegisterInfo::isVirtualRegister(RegB)) + return RegClass != mf_->getSSARegMap()->getRegClass(RegB); + else + return RegClass != mri_->getRegClass(RegB); +} + +bool LiveIntervals::overlapsAliases(const LiveInterval *LHS, + const LiveInterval *RHS) const { + if (!MRegisterInfo::isPhysicalRegister(LHS->reg)) { + if (!MRegisterInfo::isPhysicalRegister(RHS->reg)) + return false; // vreg-vreg merge has no aliases! + std::swap(LHS, RHS); + } + + assert(MRegisterInfo::isPhysicalRegister(LHS->reg) && + MRegisterInfo::isVirtualRegister(RHS->reg) && + "first interval must describe a physical register"); - for (const unsigned* as = mri_->getAliasSet(lhs.reg); *as; ++as) { - Reg2IntervalMap::const_iterator r2i = r2iMap_.find(*as); + for (const unsigned *AS = mri_->getAliasSet(LHS->reg); *AS; ++AS) { + Reg2IntervalMap::const_iterator r2i = r2iMap_.find(*AS); assert(r2i != r2iMap_.end() && "alias does not have interval?"); - if (rhs.overlaps(*r2i->second)) + if (RHS->overlaps(*r2i->second)) return true; } From lattner at cs.uiuc.edu Fri Jul 23 22:32:16 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 23 Jul 2004 22:32:16 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp LiveIntervalAnalysis.h RegAllocIterativeScan.cpp RegAllocLinearScan.cpp Message-ID: <200407240332.WAA28620@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveIntervalAnalysis.cpp updated: 1.108 -> 1.109 LiveIntervalAnalysis.h updated: 1.36 -> 1.37 RegAllocIterativeScan.cpp updated: 1.8 -> 1.9 RegAllocLinearScan.cpp updated: 1.83 -> 1.84 --- Log message: Completely eliminate the intervals_ list. instead, the r2iMap_ maintains ownership of the intervals. --- Diffs of the changes: (+71 -79) Index: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp diff -u llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.108 llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.109 --- llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.108 Fri Jul 23 21:59:07 2004 +++ llvm/lib/CodeGen/LiveIntervalAnalysis.cpp Fri Jul 23 22:32:06 2004 @@ -76,9 +76,12 @@ { mi2iMap_.clear(); i2miMap_.clear(); + for (std::map::iterator I = r2iMap_.begin(), + E = r2iMap_.end(); I != E; ++I) + delete I->second; // free all intervals. r2iMap_.clear(); + r2rMap_.clear(); - intervals_.clear(); } @@ -104,18 +107,18 @@ computeIntervals(); - numIntervals += intervals_.size(); + numIntervals += getNumIntervals(); #if 1 DEBUG(std::cerr << "********** INTERVALS **********\n"); - DEBUG(std::copy(intervals_.begin(), intervals_.end(), - std::ostream_iterator(std::cerr, "\n"))); + DEBUG(for (iterator I = begin(), E = end(); I != E; ++I) + std::cerr << *I->second << "\n"); #endif // join intervals if requested if (EnableJoining) joinIntervals(); - numIntervalsAfter += intervals_.size(); + numIntervalsAfter += getNumIntervals(); // perform a final pass over the instructions and compute spill // weights, coalesce virtual registers and remove identity moves @@ -130,11 +133,11 @@ for (MachineBasicBlock::iterator mii = mbb->begin(), mie = mbb->end(); mii != mie; ) { // if the move will be an identity move delete it - unsigned srcReg, dstReg; + unsigned srcReg, dstReg, RegRep; if (tii.isMoveInstr(*mii, srcReg, dstReg) && - rep(srcReg) == rep(dstReg)) { + (RegRep = rep(srcReg)) == rep(dstReg)) { // remove from def list - LiveInterval& interval = getOrCreateInterval(rep(dstReg)); + LiveInterval &interval = getOrCreateInterval(RegRep); // remove index -> MachineInstr and // MachineInstr -> index mappings Mi2IndexMap::iterator mi2i = mi2iMap_.find(mii); @@ -154,9 +157,8 @@ unsigned reg = rep(mop.getReg()); mii->SetMachineOperandReg(i, reg); - Reg2IntervalMap::iterator r2iit = r2iMap_.find(reg); - assert(r2iit != r2iMap_.end()); - r2iit->second->weight += + LiveInterval &RegInt = getInterval(reg); + RegInt.weight += (mop.isUse() + mop.isDef()) * pow(10.0F, loopDepth); } } @@ -166,8 +168,8 @@ } DEBUG(std::cerr << "********** INTERVALS **********\n"); - DEBUG(std::copy(intervals_.begin(), intervals_.end(), - std::ostream_iterator(std::cerr, "\n"))); + DEBUG (for (iterator I = begin(), E = end(); I != E; ++I) + std::cerr << *I->second << "\n"); DEBUG(std::cerr << "********** MACHINEINSTRS **********\n"); DEBUG( for (MachineFunction::iterator mbbi = mf_->begin(), mbbe = mf_->end(); @@ -548,6 +550,8 @@ assert(IntA.reg == regA && IntB.reg == regB && "Register mapping is horribly broken!"); + // If two intervals contain a single value and are joined by a copy, it + // does not matter if the intervals overlap, they can always be joined. bool TriviallyJoinable = IntA.containsOneValue() && IntB.containsOneValue(); @@ -555,19 +559,18 @@ if ((TriviallyJoinable || !IntB.joinable(IntA, MIDefIdx)) && !overlapsAliases(&IntA, &IntB)) { IntB.join(IntA, MIDefIdx); - - // FIXME: Turn 'intervals_' into an ilist so we don't need to do these - // map lookups! - intervals_.erase(r2iMap_[regA]); - r2iMap_[regA] = r2iMap_[regB]; + delete r2iMap_[regA]; // Delete the dead interval if (!MRegisterInfo::isPhysicalRegister(regA)) { + r2iMap_.erase(regA); r2rMap_[regA] = regB; } else { // Otherwise merge the data structures the other way so we don't lose // the physreg information. r2rMap_[regB] = regA; IntB.reg = regA; + r2iMap_[regA] = r2iMap_[regB]; + r2iMap_.erase(regB); } DEBUG(std::cerr << "Joined. Result = " << IntB << "\n"); ++numJoins; @@ -649,25 +652,15 @@ MRegisterInfo::isVirtualRegister(RHS->reg) && "first interval must describe a physical register"); - for (const unsigned *AS = mri_->getAliasSet(LHS->reg); *AS; ++AS) { - Reg2IntervalMap::const_iterator r2i = r2iMap_.find(*AS); - assert(r2i != r2iMap_.end() && "alias does not have interval?"); - if (RHS->overlaps(*r2i->second)) - return true; - } + for (const unsigned *AS = mri_->getAliasSet(LHS->reg); *AS; ++AS) + if (RHS->overlaps(getInterval(*AS))) + return true; - return false; + return false; } -LiveInterval& LiveIntervals::getOrCreateInterval(unsigned reg) -{ - Reg2IntervalMap::iterator r2iit = r2iMap_.lower_bound(reg); - if (r2iit == r2iMap_.end() || r2iit->first != reg) { - float Weight = MRegisterInfo::isPhysicalRegister(reg) ? HUGE_VAL :0.0F; - intervals_.push_back(LiveInterval(reg, Weight)); - r2iit = r2iMap_.insert(r2iit, std::make_pair(reg, --intervals_.end())); - } - - return *r2iit->second; +LiveInterval *LiveIntervals::createInterval(unsigned reg) const { + float Weight = MRegisterInfo::isPhysicalRegister(reg) ? HUGE_VAL :0.0F; + return new LiveInterval(reg, Weight); } Index: llvm/lib/CodeGen/LiveIntervalAnalysis.h diff -u llvm/lib/CodeGen/LiveIntervalAnalysis.h:1.36 llvm/lib/CodeGen/LiveIntervalAnalysis.h:1.37 --- llvm/lib/CodeGen/LiveIntervalAnalysis.h:1.36 Fri Jul 23 21:53:43 2004 +++ llvm/lib/CodeGen/LiveIntervalAnalysis.h Fri Jul 23 22:32:06 2004 @@ -22,7 +22,6 @@ #include "llvm/CodeGen/MachineFunctionPass.h" #include "LiveInterval.h" -#include namespace llvm { @@ -30,17 +29,10 @@ class MRegisterInfo; class VirtRegMap; - class LiveIntervals : public MachineFunctionPass - { - public: - typedef std::list Intervals; - - private: + class LiveIntervals : public MachineFunctionPass { MachineFunction* mf_; const TargetMachine* tm_; const MRegisterInfo* mri_; - MachineBasicBlock* currentMbb_; - MachineBasicBlock::iterator currentInstr_; LiveVariables* lv_; typedef std::map Mi2IndexMap; @@ -49,14 +41,14 @@ typedef std::vector Index2MiMap; Index2MiMap i2miMap_; - typedef std::map Reg2IntervalMap; - Reg2IntervalMap r2iMap_; + /// r2iMap_ - This map OWNS the interval pointed to by the map. When + /// this map is destroyed or when entries are modified, this intervals + /// should be destroyed or modified as well. + std::map r2iMap_; typedef std::map Reg2RegMap; Reg2RegMap r2rMap_; - Intervals intervals_; - public: struct InstrSlots { @@ -88,15 +80,15 @@ return getBaseIndex(index) + InstrSlots::STORE; } - virtual void getAnalysisUsage(AnalysisUsage &AU) const; - virtual void releaseMemory(); - - /// runOnMachineFunction - pass entry point - virtual bool runOnMachineFunction(MachineFunction&); - - LiveInterval& getInterval(unsigned reg) { - Reg2IntervalMap::iterator I = r2iMap_.find(reg); - assert(I != r2iMap_.end()&& "Interval does not exist for register"); + typedef std::map::const_iterator iterator; + iterator begin() const { return r2iMap_.begin(); } + iterator end() const { return r2iMap_.end(); } + unsigned getNumIntervals() const { return r2iMap_.size(); } + + LiveInterval &getInterval(unsigned reg) const { + std::map::const_iterator I = + r2iMap_.find(reg); + assert(I != r2iMap_.end() && "Interval does not exist for register"); return *I->second; } @@ -116,12 +108,16 @@ return i2miMap_[index]; } - Intervals& getIntervals() { return intervals_; } - std::vector addIntervalsForSpills(const LiveInterval& i, VirtRegMap& vrm, int slot); + virtual void getAnalysisUsage(AnalysisUsage &AU) const; + virtual void releaseMemory(); + + /// runOnMachineFunction - pass entry point + virtual bool runOnMachineFunction(MachineFunction&); + private: /// computeIntervals - compute live intervals void computeIntervals(); @@ -159,8 +155,14 @@ bool overlapsAliases(const LiveInterval *lhs, const LiveInterval *rhs) const; + LiveInterval *createInterval(unsigned Reg) const; - LiveInterval& getOrCreateInterval(unsigned reg); + LiveInterval &getOrCreateInterval(unsigned reg) { + LiveInterval *&LI = r2iMap_[reg]; + if (LI == 0) + LI = createInterval(reg); + return *LI; + } /// rep - returns the representative of this register unsigned rep(unsigned reg) { Index: llvm/lib/CodeGen/RegAllocIterativeScan.cpp diff -u llvm/lib/CodeGen/RegAllocIterativeScan.cpp:1.8 llvm/lib/CodeGen/RegAllocIterativeScan.cpp:1.9 --- llvm/lib/CodeGen/RegAllocIterativeScan.cpp:1.8 Fri Jul 23 12:56:30 2004 +++ llvm/lib/CodeGen/RegAllocIterativeScan.cpp Fri Jul 23 22:32:06 2004 @@ -85,7 +85,7 @@ /// initIntervalSets - initializes the four interval sets: /// unhandled, fixed, active and inactive - void initIntervalSets(LiveIntervals::Intervals& li); + void initIntervalSets(); /// processActiveIntervals - expire old intervals and move /// non-overlapping ones to the incative list @@ -151,9 +151,9 @@ vrm_.reset(new VirtRegMap(*mf_)); if (!spiller_.get()) spiller_.reset(createSpiller()); - initIntervalSets(li_->getIntervals()); + initIntervalSets(); - numIntervals += li_->getIntervals().size(); + numIntervals += li_->getNumIntervals(); while (linearScan()) { // we spilled some registers, so we need to add intervals for @@ -251,17 +251,15 @@ return !spilled_.empty(); } -void RA::initIntervalSets(LiveIntervals::Intervals& li) -{ +void RA::initIntervalSets() { assert(unhandled_.empty() && fixed_.empty() && active_.empty() && inactive_.empty() && "interval sets should be empty on initialization"); - for (LiveIntervals::Intervals::iterator i = li.begin(), e = li.end(); - i != e; ++i) { - unhandled_.push_back(&*i); - if (MRegisterInfo::isPhysicalRegister(i->reg)) - fixed_.push_back(&*i); + for (LiveIntervals::iterator i = li_->begin(), e = li_->end(); i != e; ++i){ + unhandled_.push_back(i->second); + if (MRegisterInfo::isPhysicalRegister(i->second->reg)) + fixed_.push_back(i->second); } } Index: llvm/lib/CodeGen/RegAllocLinearScan.cpp diff -u llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.83 llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.84 --- llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.83 Fri Jul 23 12:56:30 2004 +++ llvm/lib/CodeGen/RegAllocLinearScan.cpp Fri Jul 23 22:32:06 2004 @@ -82,7 +82,7 @@ /// initIntervalSets - initializa the four interval sets: /// unhandled, fixed, active and inactive - void initIntervalSets(LiveIntervals::Intervals& li); + void initIntervalSets(); /// processActiveIntervals - expire old intervals and move /// non-overlapping ones to the incative list @@ -146,7 +146,7 @@ vrm_.reset(new VirtRegMap(*mf_)); if (!spiller_.get()) spiller_.reset(createSpiller()); - initIntervalSets(li_->getIntervals()); + initIntervalSets(); linearScan(); @@ -193,7 +193,7 @@ DEBUG(printIntervals("active", active_.begin(), active_.end())); DEBUG(printIntervals("inactive", inactive_.begin(), inactive_.end())); } - numIntervals += li_->getIntervals().size(); + numIntervals += li_->getNumIntervals(); efficiency = double(numIterations) / double(numIntervals); // expire any remaining active intervals @@ -217,17 +217,16 @@ DEBUG(std::cerr << *vrm_); } -void RA::initIntervalSets(LiveIntervals::Intervals& li) +void RA::initIntervalSets() { assert(unhandled_.empty() && fixed_.empty() && active_.empty() && inactive_.empty() && "interval sets should be empty on initialization"); - for (LiveIntervals::Intervals::iterator i = li.begin(), e = li.end(); - i != e; ++i) { - unhandled_.push(&*i); - if (MRegisterInfo::isPhysicalRegister(i->reg)) - fixed_.push_back(&*i); + for (LiveIntervals::iterator i = li_->begin(), e = li_->end(); i != e; ++i){ + unhandled_.push(i->second); + if (MRegisterInfo::isPhysicalRegister(i->second->reg)) + fixed_.push_back(i->second); } } From lattner at cs.uiuc.edu Fri Jul 23 22:42:00 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 23 Jul 2004 22:42:00 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveInterval.cpp Message-ID: <200407240342.WAA28959@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveInterval.cpp updated: 1.5 -> 1.6 --- Log message: In the joiner, merge the small interval into the large interval. This restores us back to taking about 10.5s on gcc, instead of taking 15.6s! The net result is that my big patches have hand no significant effect on compile time or code quality. heh. --- Diffs of the changes: (+9 -0) Index: llvm/lib/CodeGen/LiveInterval.cpp diff -u llvm/lib/CodeGen/LiveInterval.cpp:1.5 llvm/lib/CodeGen/LiveInterval.cpp:1.6 --- llvm/lib/CodeGen/LiveInterval.cpp:1.5 Fri Jul 23 21:52:23 2004 +++ llvm/lib/CodeGen/LiveInterval.cpp Fri Jul 23 22:41:50 2004 @@ -260,6 +260,15 @@ unsigned MergedSrcValIdx = SourceLR->ValId; unsigned MergedDstValIdx = DestLR->ValId; + // Try to do the least amount of work possible. In particular, if there are + // more liverange chunks in the other set than there are in the 'this' set, + // swap sets to merge the fewest chunks in possible. + if (Other.ranges.size() > ranges.size()) { + std::swap(MergedSrcValIdx, MergedDstValIdx); + std::swap(ranges, Other.ranges); + std::swap(NumValues, Other.NumValues); + } + // Join the ranges of other into the ranges of this interval. Ranges::iterator InsertPos = ranges.begin(); std::map Dst2SrcIdxMap; From lattner at cs.uiuc.edu Fri Jul 23 23:32:32 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 23 Jul 2004 23:32:32 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp Message-ID: <200407240432.XAA01160@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveIntervalAnalysis.cpp updated: 1.109 -> 1.110 --- Log message: whoops, didn't mean to remove this --- Diffs of the changes: (+3 -1) Index: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp diff -u llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.109 llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.110 --- llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.109 Fri Jul 23 22:32:06 2004 +++ llvm/lib/CodeGen/LiveIntervalAnalysis.cpp Fri Jul 23 23:32:22 2004 @@ -549,7 +549,9 @@ LiveInterval &IntB = getInterval(regB); assert(IntA.reg == regA && IntB.reg == regB && "Register mapping is horribly broken!"); - + + DEBUG(std::cerr << "\t\tInspecting " << IntA << " and " << IntB << ": "); + // If two intervals contain a single value and are joined by a copy, it // does not matter if the intervals overlap, they can always be joined. bool TriviallyJoinable = From lattner at cs.uiuc.edu Sat Jul 24 02:41:34 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 24 Jul 2004 02:41:34 -0500 Subject: [llvm-commits] CVS: llvm/lib/Support/SystemUtils.cpp Message-ID: <200407240741.CAA13809@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Support: SystemUtils.cpp updated: 1.30 -> 1.31 --- Log message: Add support for killing the program if it executes for too long. --- Diffs of the changes: (+42 -12) Index: llvm/lib/Support/SystemUtils.cpp diff -u llvm/lib/Support/SystemUtils.cpp:1.30 llvm/lib/Support/SystemUtils.cpp:1.31 --- llvm/lib/Support/SystemUtils.cpp:1.30 Fri Jun 18 10:38:49 2004 +++ llvm/lib/Support/SystemUtils.cpp Sat Jul 24 02:41:23 2004 @@ -125,9 +125,14 @@ close(InFD); // Close the original FD } +static bool Timeout = false; +static void TimeOutHandler(int Sig) { + Timeout = true; +} + /// RunProgramWithTimeout - This function executes the specified program, with /// the specified null-terminated argument array, with the stdin/out/err fd's -/// redirected, with a timeout specified on the command line. This terminates +/// redirected, with a timeout specified by the last argument. This terminates /// the calling program if there is an error executing the specified program. /// It returns the return value of the program, or -1 if a timeout is detected. /// @@ -135,9 +140,8 @@ const char **Args, const std::string &StdInFile, const std::string &StdOutFile, - const std::string &StdErrFile) { - // FIXME: install sigalarm handler here for timeout... - + const std::string &StdErrFile, + unsigned NumSeconds) { #ifdef HAVE_SYS_WAIT_H int Child = fork(); switch (Child) { @@ -165,24 +169,50 @@ // Make sure all output has been written while waiting std::cout << std::flush; + // Install a timeout handler. + Timeout = false; + struct sigaction Act, Old; + Act.sa_sigaction = 0; + Act.sa_handler = TimeOutHandler; + Act.sa_flags = SA_NOMASK; + sigaction(SIGALRM, &Act, &Old); + + // Set the timeout if one is set. + if (NumSeconds) + alarm(NumSeconds); + int Status; - if (wait(&Status) != Child) { + while (wait(&Status) != Child) { if (errno == EINTR) { - static bool FirstTimeout = true; - if (FirstTimeout) { - std::cout << + if (Timeout) { + static bool FirstTimeout = true; + if (FirstTimeout) { + std::cout << "*** Program execution timed out! This mechanism is designed to handle\n" " programs stuck in infinite loops gracefully. The -timeout option\n" " can be used to change the timeout threshold or disable it completely\n" " (with -timeout=0). This message is only displayed once.\n"; - FirstTimeout = false; + FirstTimeout = false; + } } + + // Kill the child. + kill(Child, SIGKILL); + + if (wait(&Status) != Child) + std::cerr << "Something funny happened waiting for the child!\n"; + + alarm(0); + sigaction(SIGALRM, &Old, 0); return -1; // Timeout detected + } else { + std::cerr << "Error waiting for child process!\n"; + exit(1); } - - std::cerr << "Error waiting for child process!\n"; - exit(1); } + + alarm(0); + sigaction(SIGALRM, &Old, 0); return Status; #else From lattner at cs.uiuc.edu Sat Jul 24 02:41:41 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 24 Jul 2004 02:41:41 -0500 Subject: [llvm-commits] CVS: llvm/include/Support/SystemUtils.h Message-ID: <200407240741.CAA13822@apoc.cs.uiuc.edu> Changes in directory llvm/include/Support: SystemUtils.h updated: 1.11 -> 1.12 --- Log message: Add support for killing the program if it executes for too long. --- Diffs of the changes: (+3 -2) Index: llvm/include/Support/SystemUtils.h diff -u llvm/include/Support/SystemUtils.h:1.11 llvm/include/Support/SystemUtils.h:1.12 --- llvm/include/Support/SystemUtils.h:1.11 Thu May 27 19:58:48 2004 +++ llvm/include/Support/SystemUtils.h Sat Jul 24 02:41:31 2004 @@ -38,14 +38,15 @@ /// RunProgramWithTimeout - This function executes the specified program, with /// the specified null-terminated argument array, with the stdin/out/err fd's -/// redirected, with a timeout specified on the commandline. This terminates +/// redirected, with a timeout specified by the last argument. This terminates /// the calling program if there is an error executing the specified program. /// It returns the return value of the program, or -1 if a timeout is detected. /// int RunProgramWithTimeout(const std::string &ProgramPath, const char **Args, const std::string &StdInFile = "", const std::string &StdOutFile = "", - const std::string &StdErrFile = ""); + const std::string &StdErrFile = "", + unsigned NumSeconds = 0); /// ExecWait - Execute a program with the given arguments and environment and /// wait for it to terminate. From lattner at cs.uiuc.edu Sat Jul 24 02:49:00 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 24 Jul 2004 02:49:00 -0500 Subject: [llvm-commits] CVS: llvm/include/llvm/Support/ToolRunner.h Message-ID: <200407240749.CAA17658@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Support: ToolRunner.h updated: 1.13 -> 1.14 --- Log message: Provide timeout values to all abstract interpreters --- Diffs of the changes: (+7 -4) Index: llvm/include/llvm/Support/ToolRunner.h diff -u llvm/include/llvm/Support/ToolRunner.h:1.13 llvm/include/llvm/Support/ToolRunner.h:1.14 --- llvm/include/llvm/Support/ToolRunner.h:1.13 Tue May 4 17:02:41 2004 +++ llvm/include/llvm/Support/ToolRunner.h Sat Jul 24 02:48:50 2004 @@ -64,7 +64,7 @@ const std::string &InputFile, const std::string &OutputFile, const std::vector &SharedLibs = - std::vector()); + std::vector(), unsigned Timeout = 0); /// MakeSharedObject - This compiles the specified file (which is either a .c /// file or a .s file) into a shared object. @@ -110,7 +110,8 @@ const std::string &InputFile, const std::string &OutputFile, const std::vector &SharedLibs = - std::vector()) = 0; + std::vector(), + unsigned Timeout = 0) = 0; }; //===---------------------------------------------------------------------===// @@ -139,7 +140,8 @@ const std::string &InputFile, const std::string &OutputFile, const std::vector &SharedLibs = - std::vector()); + std::vector(), + unsigned Timeout = 0); // Sometimes we just want to go half-way and only generate the .c file, not // necessarily compile it with GCC and run the program. This throws an @@ -175,7 +177,8 @@ const std::string &InputFile, const std::string &OutputFile, const std::vector &SharedLibs = - std::vector()); + std::vector(), + unsigned Timeout = 0); // Sometimes we just want to go half-way and only generate the .s file, // not necessarily compile it all the way and run the program. This throws From lattner at cs.uiuc.edu Sat Jul 24 02:49:21 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 24 Jul 2004 02:49:21 -0500 Subject: [llvm-commits] CVS: llvm/lib/Support/ToolRunner.cpp Message-ID: <200407240749.CAA17682@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Support: ToolRunner.cpp updated: 1.28 -> 1.29 --- Log message: Pass timeouts into the low level "execute program with timeout" function --- Diffs of the changes: (+18 -12) Index: llvm/lib/Support/ToolRunner.cpp diff -u llvm/lib/Support/ToolRunner.cpp:1.28 llvm/lib/Support/ToolRunner.cpp:1.29 --- llvm/lib/Support/ToolRunner.cpp:1.28 Wed Jul 21 15:50:33 2004 +++ llvm/lib/Support/ToolRunner.cpp Sat Jul 24 02:49:11 2004 @@ -66,7 +66,8 @@ const std::string &InputFile, const std::string &OutputFile, const std::vector &SharedLibs = - std::vector()); + std::vector(), + unsigned Timeout = 0); }; } @@ -74,7 +75,8 @@ const std::vector &Args, const std::string &InputFile, const std::string &OutputFile, - const std::vector &SharedLibs) { + const std::vector &SharedLibs, + unsigned Timeout) { if (!SharedLibs.empty()) throw ToolExecutionError("LLI currently does not support " "loading shared libraries."); @@ -100,7 +102,7 @@ std::cerr << "\n"; ); return RunProgramWithTimeout(LLIPath, &LLIArgs[0], - InputFile, OutputFile, OutputFile); + InputFile, OutputFile, OutputFile, Timeout); } // LLI create method - Try to find the LLI executable @@ -156,7 +158,8 @@ const std::vector &Args, const std::string &InputFile, const std::string &OutputFile, - const std::vector &SharedLibs) { + const std::vector &SharedLibs, + unsigned Timeout) { std::string OutputAsmFile; OutputAsm(Bytecode, OutputAsmFile); @@ -164,7 +167,7 @@ // Assuming LLC worked, compile the result with GCC and run it. return gcc->ExecuteProgram(OutputAsmFile, Args, GCC::AsmFile, - InputFile, OutputFile, SharedLibs); + InputFile, OutputFile, SharedLibs, Timeout); } /// createLLC - Try to find the LLC executable @@ -206,7 +209,7 @@ const std::string &InputFile, const std::string &OutputFile, const std::vector &SharedLibs = - std::vector()); + std::vector(), unsigned Timeout =0); }; } @@ -214,7 +217,8 @@ const std::vector &Args, const std::string &InputFile, const std::string &OutputFile, - const std::vector &SharedLibs) { + const std::vector &SharedLibs, + unsigned Timeout) { // Construct a vector of parameters, incorporating those from the command-line std::vector JITArgs; JITArgs.push_back(LLIPath.c_str()); @@ -242,7 +246,7 @@ ); DEBUG(std::cerr << "\nSending output to " << OutputFile << "\n"); return RunProgramWithTimeout(LLIPath, &JITArgs[0], - InputFile, OutputFile, OutputFile); + InputFile, OutputFile, OutputFile, Timeout); } /// createJIT - Try to find the LLI executable @@ -297,14 +301,15 @@ const std::vector &Args, const std::string &InputFile, const std::string &OutputFile, - const std::vector &SharedLibs) { + const std::vector &SharedLibs, + unsigned Timeout) { std::string OutputCFile; OutputC(Bytecode, OutputCFile); FileRemover CFileRemove(OutputCFile); return gcc->ExecuteProgram(OutputCFile, Args, GCC::CFile, - InputFile, OutputFile, SharedLibs); + InputFile, OutputFile, SharedLibs, Timeout); } /// createCBE - Try to find the 'llc' executable @@ -336,7 +341,8 @@ FileType fileType, const std::string &InputFile, const std::string &OutputFile, - const std::vector &SharedLibs) { + const std::vector &SharedLibs, + unsigned Timeout) { std::vector GCCArgs; GCCArgs.push_back(GCCPath.c_str()); @@ -388,7 +394,7 @@ FileRemover OutputBinaryRemover(OutputBinary); return RunProgramWithTimeout(OutputBinary, &ProgramArgs[0], - InputFile, OutputFile, OutputFile); + InputFile, OutputFile, OutputFile, Timeout); } int GCC::MakeSharedObject(const std::string &InputFile, FileType fileType, From lattner at cs.uiuc.edu Sat Jul 24 02:50:58 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 24 Jul 2004 02:50:58 -0500 Subject: [llvm-commits] CVS: llvm/lib/Support/SystemUtils.cpp Message-ID: <200407240750.CAA18441@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Support: SystemUtils.cpp updated: 1.31 -> 1.32 --- Log message: Get rid of the printout from the low-level system interface --- Diffs of the changes: (+13 -24) Index: llvm/lib/Support/SystemUtils.cpp diff -u llvm/lib/Support/SystemUtils.cpp:1.31 llvm/lib/Support/SystemUtils.cpp:1.32 --- llvm/lib/Support/SystemUtils.cpp:1.31 Sat Jul 24 02:41:23 2004 +++ llvm/lib/Support/SystemUtils.cpp Sat Jul 24 02:50:48 2004 @@ -182,34 +182,23 @@ alarm(NumSeconds); int Status; - while (wait(&Status) != Child) { + while (wait(&Status) != Child) if (errno == EINTR) { if (Timeout) { - static bool FirstTimeout = true; - if (FirstTimeout) { - std::cout << - "*** Program execution timed out! This mechanism is designed to handle\n" - " programs stuck in infinite loops gracefully. The -timeout option\n" - " can be used to change the timeout threshold or disable it completely\n" - " (with -timeout=0). This message is only displayed once.\n"; - FirstTimeout = false; - } + // Kill the child. + kill(Child, SIGKILL); + + if (wait(&Status) != Child) + std::cerr << "Something funny happened waiting for the child!\n"; + + alarm(0); + sigaction(SIGALRM, &Old, 0); + return -1; // Timeout detected + } else { + std::cerr << "Error waiting for child process!\n"; + exit(1); } - - // Kill the child. - kill(Child, SIGKILL); - - if (wait(&Status) != Child) - std::cerr << "Something funny happened waiting for the child!\n"; - - alarm(0); - sigaction(SIGALRM, &Old, 0); - return -1; // Timeout detected - } else { - std::cerr << "Error waiting for child process!\n"; - exit(1); } - } alarm(0); sigaction(SIGALRM, &Old, 0); From lattner at cs.uiuc.edu Sat Jul 24 02:51:37 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 24 Jul 2004 02:51:37 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp Message-ID: <200407240751.CAA18457@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: DeadStoreElimination.cpp updated: 1.1 -> 1.2 --- Log message: obvious fix --- Diffs of the changes: (+1 -0) Index: llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp diff -u llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp:1.1 llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp:1.2 --- llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp:1.1 Thu Jul 22 03:00:28 2004 +++ llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp Sat Jul 24 02:51:27 2004 @@ -45,6 +45,7 @@ // getAnalysisUsage - We require post dominance frontiers (aka Control // Dependence Graph) virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.setPreservesCFG(); AU.addRequired(); AU.addRequired(); AU.addPreserved(); From lattner at cs.uiuc.edu Sat Jul 24 02:53:37 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 24 Jul 2004 02:53:37 -0500 Subject: [llvm-commits] CVS: llvm/tools/bugpoint/BugDriver.cpp ExecutionDriver.cpp Message-ID: <200407240753.CAA19263@apoc.cs.uiuc.edu> Changes in directory llvm/tools/bugpoint: BugDriver.cpp updated: 1.35 -> 1.36 ExecutionDriver.cpp updated: 1.46 -> 1.47 --- Log message: Finally give bugpoint -timeout support! --- Diffs of the changes: (+20 -2) Index: llvm/tools/bugpoint/BugDriver.cpp diff -u llvm/tools/bugpoint/BugDriver.cpp:1.35 llvm/tools/bugpoint/BugDriver.cpp:1.36 --- llvm/tools/bugpoint/BugDriver.cpp:1.35 Thu Jul 22 20:30:49 2004 +++ llvm/tools/bugpoint/BugDriver.cpp Sat Jul 24 02:53:26 2004 @@ -156,7 +156,7 @@ // bool CreatedOutput = false; if (ReferenceOutputFile.empty()) { - std::cout << "Generating reference output from raw program..."; + std::cout << "Generating reference output from raw program: "; try { ReferenceOutputFile = executeProgramWithCBE("bugpoint.reference.out"); CreatedOutput = true; Index: llvm/tools/bugpoint/ExecutionDriver.cpp diff -u llvm/tools/bugpoint/ExecutionDriver.cpp:1.46 llvm/tools/bugpoint/ExecutionDriver.cpp:1.47 --- llvm/tools/bugpoint/ExecutionDriver.cpp:1.46 Thu Jul 22 20:30:49 2004 +++ llvm/tools/bugpoint/ExecutionDriver.cpp Sat Jul 24 02:53:26 2004 @@ -53,6 +53,11 @@ AdditionalSOs("additional-so", cl::desc("Additional shared objects to load " "into executing programs")); + + cl::opt + TimeoutValue("timeout", cl::init(300), cl::value_desc("seconds"), + cl::desc("Number of seconds program is allowed to run before it " + "is killed (default is 300s), 0 disables timeout")); } namespace llvm { @@ -201,7 +206,20 @@ // Actually execute the program! int RetVal = AI->ExecuteProgram(BytecodeFile, InputArgv, InputFile, - OutputFile, SharedObjs); + OutputFile, SharedObjs, TimeoutValue); + + if (RetVal == -1) { + std::cerr << ""; + static bool FirstTimeout = true; + if (FirstTimeout) { + std::cout << "\n" + "*** Program execution timed out! This mechanism is designed to handle\n" + " programs stuck in infinite loops gracefully. The -timeout option\n" + " can be used to change the timeout threshold or disable it completely\n" + " (with -timeout=0). This message is only displayed once.\n"; + FirstTimeout = false; + } + } if (ProgramExitedNonzero != 0) *ProgramExitedNonzero = (RetVal != 0); From lattner at cs.uiuc.edu Sat Jul 24 02:54:26 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 24 Jul 2004 02:54:26 -0500 Subject: [llvm-commits] CVS: llvm/test/Programs/Makefile.programs Message-ID: <200407240754.CAA19289@apoc.cs.uiuc.edu> Changes in directory llvm/test/Programs: Makefile.programs updated: 1.132 -> 1.133 --- Log message: Make bugpoint automatically get the timeout value from the RUNTIMELIMIT variable, which defaults to 500s but can be customized in a program makefile or be passed on the command line to make. --- Diffs of the changes: (+1 -0) Index: llvm/test/Programs/Makefile.programs diff -u llvm/test/Programs/Makefile.programs:1.132 llvm/test/Programs/Makefile.programs:1.133 --- llvm/test/Programs/Makefile.programs:1.132 Fri Jul 23 01:46:55 2004 +++ llvm/test/Programs/Makefile.programs Sat Jul 24 02:54:16 2004 @@ -373,6 +373,7 @@ # Specify stdin, reference output, and command line options for the program... BUGPOINT_OPTIONS += -input=$(STDIN_FILENAME) -output=Output/$*.out-nat +BUGPOINT_OPTIONS += -timeout=$(RUNTIMELIMIT) BUGPOINT_OPTIONS += --tool-args $(LLCFLAGS) BUGPOINT_ARGS += --args -- $(RUN_OPTIONS) From lattner at cs.uiuc.edu Sat Jul 24 02:54:47 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 24 Jul 2004 02:54:47 -0500 Subject: [llvm-commits] CVS: llvm/test/Programs/External/SPEC/Makefile.spec Message-ID: <200407240754.CAA19316@apoc.cs.uiuc.edu> Changes in directory llvm/test/Programs/External/SPEC: Makefile.spec updated: 1.33 -> 1.34 --- Log message: Make bugpoint automatically get the timeout value from the RUNTIMELIMIT variable, which defaults to 500s but can be customized in a program makefile or be passed on the command line to make. --- Diffs of the changes: (+1 -0) Index: llvm/test/Programs/External/SPEC/Makefile.spec diff -u llvm/test/Programs/External/SPEC/Makefile.spec:1.33 llvm/test/Programs/External/SPEC/Makefile.spec:1.34 --- llvm/test/Programs/External/SPEC/Makefile.spec:1.33 Fri Jul 23 01:47:38 2004 +++ llvm/test/Programs/External/SPEC/Makefile.spec Sat Jul 24 02:54:37 2004 @@ -131,6 +131,7 @@ # Specify stdin, reference output, and command line options for the program... BUGPOINT_OPTIONS += -input=$(STDIN_FILENAME) -output=../$*.out-nat +BUGPOINT_OPTIONS += -timeout=$(RUNTIMELIMIT) BUGPOINT_OPTIONS += --tool-args $(LLCFLAGS) BUGPOINT_ARGS += --args -- $(RUN_OPTIONS) From alkis at cs.uiuc.edu Sat Jul 24 05:44:21 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 24 Jul 2004 05:44:21 -0500 Subject: [llvm-commits] CVS: llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/strcat.cpp moments.cpp lists1.cpp hash.cpp ary2.cpp ary.cpp Message-ID: <200407241044.FAA25187@zion.cs.uiuc.edu> Changes in directory llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++: strcat.cpp updated: 1.2 -> 1.3 moments.cpp updated: 1.3 -> 1.4 lists1.cpp updated: 1.4 -> 1.5 hash.cpp updated: 1.2 -> 1.3 ary2.cpp updated: 1.4 -> 1.5 ary.cpp updated: 1.3 -> 1.4 --- Log message: Reduce problem sizes for these tests as they consume about half a gig of RAM when ran. This is not funny on a machine with "only" 768MB. --- Diffs of the changes: (+11 -11) Index: llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/strcat.cpp diff -u llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/strcat.cpp:1.2 llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/strcat.cpp:1.3 --- llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/strcat.cpp:1.2 Tue Jun 15 15:48:16 2004 +++ llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/strcat.cpp Sat Jul 24 05:44:11 2004 @@ -1,5 +1,5 @@ // -*- mode: c++ -*- -// $Id: strcat.cpp,v 1.2 2004/06/15 20:48:16 lattner Exp $ +// $Id: strcat.cpp,v 1.3 2004/07/24 10:44:11 alkis Exp $ // http://www.bagley.org/~doug/shootout/ // with help from PeterB @@ -9,7 +9,7 @@ int main(int argc, char *argv[]) { - int i, n = ((argc == 2) ? atoi(argv[1]) : 50000000); + int i, n = ((argc == 2) ? atoi(argv[1]) : 5000000); string str; size_t capacity = 31; str.reserve(capacity); // as per C-string Index: llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/moments.cpp diff -u llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/moments.cpp:1.3 llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/moments.cpp:1.4 --- llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/moments.cpp:1.3 Tue Jun 15 15:48:16 2004 +++ llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/moments.cpp Sat Jul 24 05:44:11 2004 @@ -66,7 +66,7 @@ }; int main(int argc, char**argv) { - int n = ((argc == 2) ? atoi(argv[1]) : 50000000); + int n = ((argc == 2) ? atoi(argv[1]) : 5000000); vector v; double d; Index: llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/lists1.cpp diff -u llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/lists1.cpp:1.4 llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/lists1.cpp:1.5 --- llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/lists1.cpp:1.4 Tue Jun 15 15:48:16 2004 +++ llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/lists1.cpp Sat Jul 24 05:44:11 2004 @@ -1,5 +1,5 @@ // -*- mode: c++ -*- -// $Id: lists1.cpp,v 1.4 2004/06/15 20:48:16 lattner Exp $ +// $Id: lists1.cpp,v 1.5 2004/07/24 10:44:11 alkis Exp $ // http://www.bagley.org/~doug/shootout/ #include @@ -27,7 +27,7 @@ } int main(int argc, char* argv[]) { - int N = (argc == 2 ? (atoi(argv[1]) < 1 ? 1 : atoi(argv[1])): 10000000); + int N = (argc == 2 ? (atoi(argv[1]) < 1 ? 1 : atoi(argv[1])): 1000000); list::iterator i; // create empty list B Index: llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/hash.cpp diff -u llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/hash.cpp:1.2 llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/hash.cpp:1.3 --- llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/hash.cpp:1.2 Tue Jun 15 15:48:16 2004 +++ llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/hash.cpp Sat Jul 24 05:44:11 2004 @@ -1,5 +1,5 @@ // -*- mode: c++ -*- -// $Id: hash.cpp,v 1.2 2004/06/15 20:48:16 lattner Exp $ +// $Id: hash.cpp,v 1.3 2004/07/24 10:44:11 alkis Exp $ // http://www.bagley.org/~doug/shootout/ #include @@ -16,7 +16,7 @@ int main(int argc, char *argv[]) { - int n = ((argc == 2) ? atoi(argv[1]) : 3500000); + int n = ((argc == 2) ? atoi(argv[1]) : 500000); char buf[16]; typedef hash_map, eqstr> HM; HM X; Index: llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/ary2.cpp diff -u llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/ary2.cpp:1.4 llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/ary2.cpp:1.5 --- llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/ary2.cpp:1.4 Tue Jun 15 15:48:16 2004 +++ llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/ary2.cpp Sat Jul 24 05:44:11 2004 @@ -1,5 +1,5 @@ // -*- mode: c++ -*- -// $Id: ary2.cpp,v 1.4 2004/06/15 20:48:16 lattner Exp $ +// $Id: ary2.cpp,v 1.5 2004/07/24 10:44:11 alkis Exp $ // http://www.bagley.org/~doug/shootout/ #include @@ -7,7 +7,7 @@ int main(int argc, char *argv[]) { - int i, n = 10*((argc == 2) ? atoi(argv[1]) : 9000000); + int i, n = 10*((argc == 2) ? atoi(argv[1]) : 900000); typedef std::vector ARY; ARY x(n); ARY y(n); Index: llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/ary.cpp diff -u llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/ary.cpp:1.3 llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/ary.cpp:1.4 --- llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/ary.cpp:1.3 Tue Jun 15 15:48:16 2004 +++ llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/ary.cpp Sat Jul 24 05:44:11 2004 @@ -1,5 +1,5 @@ // -*- mode: c++ -*- -// $Id: ary.cpp,v 1.3 2004/06/15 20:48:16 lattner Exp $ +// $Id: ary.cpp,v 1.4 2004/07/24 10:44:11 alkis Exp $ // http://www.bagley.org/~doug/shootout/ #include @@ -7,7 +7,7 @@ int main(int argc, char *argv[]) { - int i, n = ((argc == 2) ? atoi(argv[1]) : 90000000); + int i, n = ((argc == 2) ? atoi(argv[1]) : 9000000); typedef std::vector ARY; ARY x(n); ARY y(n); From alkis at cs.uiuc.edu Sat Jul 24 06:43:38 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 24 Jul 2004 06:43:38 -0500 Subject: [llvm-commits] CVS: llvm-java/test/Regression/ClassFile/Makefile Message-ID: <200407241143.GAA29774@zion.cs.uiuc.edu> Changes in directory llvm-java/test/Regression/ClassFile: Makefile added (r1.1) --- Log message: Build .class files one by one by invoking javac on each one of them (instead of all togeter) --- Diffs of the changes: (+13 -0) Index: llvm-java/test/Regression/ClassFile/Makefile diff -c /dev/null llvm-java/test/Regression/ClassFile/Makefile:1.1 *** /dev/null Sat Jul 24 06:43:38 2004 --- llvm-java/test/Regression/ClassFile/Makefile Sat Jul 24 06:43:28 2004 *************** *** 0 **** --- 1,13 ---- + ##===- test/Regression/ClassFile/Makefile ------------------*- Makefile -*-===## + # + # The LLVM Compiler Infrastructure + # + # This file was developed by the LLVM research group and is distributed under + # the University of Illinois Open Source License. See LICENSE.TXT for details. + # + ##===----------------------------------------------------------------------===## + LEVEL := ../../.. + + JAVAFILES := $(wildcard *.java) + + include $(LEVEL)/test/Makefile.test From alkis at cs.uiuc.edu Sat Jul 24 06:43:38 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 24 Jul 2004 06:43:38 -0500 Subject: [llvm-commits] CVS: llvm-java/test/Programs/SingleSource/UnitTests/Makefile Message-ID: <200407241143.GAA29769@zion.cs.uiuc.edu> Changes in directory llvm-java/test/Programs/SingleSource/UnitTests: Makefile updated: 1.3 -> 1.4 --- Log message: Build .class files one by one by invoking javac on each one of them (instead of all togeter) --- Diffs of the changes: (+2 -4) Index: llvm-java/test/Programs/SingleSource/UnitTests/Makefile diff -u llvm-java/test/Programs/SingleSource/UnitTests/Makefile:1.3 llvm-java/test/Programs/SingleSource/UnitTests/Makefile:1.4 --- llvm-java/test/Programs/SingleSource/UnitTests/Makefile:1.3 Fri Jul 23 20:29:34 2004 +++ llvm-java/test/Programs/SingleSource/UnitTests/Makefile Sat Jul 24 06:43:28 2004 @@ -8,10 +8,8 @@ ##===----------------------------------------------------------------------===## LEVEL := ../../../.. -CLASSFILES := $(wildcard *.class) +JAVAFILES := $(wildcard *.java) -BUILD_JAVA_SOURCE=1 - -all:: $(foreach ext,linked.dis-ll,$(CLASSFILES:%.class=Output/%.$(ext))) +all:: $(foreach ext,linked.dis-ll,$(JAVAFILES:%.java=Output/%.$(ext))) include ../Makefile.singlesrc From alkis at cs.uiuc.edu Sat Jul 24 06:43:38 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 24 Jul 2004 06:43:38 -0500 Subject: [llvm-commits] CVS: llvm-java/test/Makefile.test Message-ID: <200407241143.GAA29764@zion.cs.uiuc.edu> Changes in directory llvm-java/test: Makefile.test updated: 1.6 -> 1.7 --- Log message: Build .class files one by one by invoking javac on each one of them (instead of all togeter) --- Diffs of the changes: (+6 -9) Index: llvm-java/test/Makefile.test diff -u llvm-java/test/Makefile.test:1.6 llvm-java/test/Makefile.test:1.7 --- llvm-java/test/Makefile.test:1.6 Fri Jul 23 20:29:34 2004 +++ llvm-java/test/Makefile.test Sat Jul 24 06:43:28 2004 @@ -9,13 +9,6 @@ include $(LEVEL)/Makefile.common -ifdef BUILD_JAVA_SOURCE -all:: .class-stamp -.class-stamp: $(shell find . -name '*.java') - $(JAVAC) $? - touch .class-stamp -endif - .PHONY: clean clean:: @@ -24,10 +17,10 @@ # we don't want these files to be deleted by make, even if they are # intermediate results -.PRECIOUS: Output/.dir Output/%.bc Output/%.ll Output/%.llvm.bc Output/%.llvm +.PRECIOUS: Output/.dir Output/%.bc Output/%.ll Output/%.llvm.bc Output/%.llvm Output/%.class #rule to link in runtime to raw bytecode -Output/%.linked.bc: Output/%.raw.bc $(BUILD_SRC_ROOT)/runtime/runtime.bc +%.linked.bc: %.raw.bc $(BUILD_SRC_ROOT)/runtime/runtime.bc $(LLVMTOOLCURRENT)/llvm-link$(EXEEXT) $^ -o $@ # rule to make assembly from bytecode @@ -37,3 +30,7 @@ # rule to make bytecode from assembly %.bc: %.ll $(LAS) < $< > $@ + +# rule to compile java source +%.class: %.java + $(JAVAC) $< From alkis at cs.uiuc.edu Sat Jul 24 06:44:25 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 24 Jul 2004 06:44:25 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/RegAllocLinearScan.cpp RegAllocIterativeScan.cpp LiveIntervalAnalysis.h LiveIntervalAnalysis.cpp LiveInterval.h LiveInterval.cpp Message-ID: <200407241144.GAA29830@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: RegAllocLinearScan.cpp updated: 1.84 -> 1.85 RegAllocIterativeScan.cpp updated: 1.9 -> 1.10 LiveIntervalAnalysis.h updated: 1.37 -> 1.38 LiveIntervalAnalysis.cpp updated: 1.110 -> 1.111 LiveInterval.h updated: 1.5 -> 1.6 LiveInterval.cpp updated: 1.6 -> 1.7 --- Log message: Change std::map into a std::map. This saves some space and removes the pointer indirection caused by following the pointer. --- Diffs of the changes: (+50 -36) Index: llvm/lib/CodeGen/RegAllocLinearScan.cpp diff -u llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.84 llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.85 --- llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.84 Fri Jul 23 22:32:06 2004 +++ llvm/lib/CodeGen/RegAllocLinearScan.cpp Sat Jul 24 06:44:15 2004 @@ -224,9 +224,9 @@ "interval sets should be empty on initialization"); for (LiveIntervals::iterator i = li_->begin(), e = li_->end(); i != e; ++i){ - unhandled_.push(i->second); - if (MRegisterInfo::isPhysicalRegister(i->second->reg)) - fixed_.push_back(i->second); + unhandled_.push(&i->second); + if (MRegisterInfo::isPhysicalRegister(i->second.reg)) + fixed_.push_back(&i->second); } } Index: llvm/lib/CodeGen/RegAllocIterativeScan.cpp diff -u llvm/lib/CodeGen/RegAllocIterativeScan.cpp:1.9 llvm/lib/CodeGen/RegAllocIterativeScan.cpp:1.10 --- llvm/lib/CodeGen/RegAllocIterativeScan.cpp:1.9 Fri Jul 23 22:32:06 2004 +++ llvm/lib/CodeGen/RegAllocIterativeScan.cpp Sat Jul 24 06:44:15 2004 @@ -257,9 +257,9 @@ "interval sets should be empty on initialization"); for (LiveIntervals::iterator i = li_->begin(), e = li_->end(); i != e; ++i){ - unhandled_.push_back(i->second); - if (MRegisterInfo::isPhysicalRegister(i->second->reg)) - fixed_.push_back(i->second); + unhandled_.push_back(&i->second); + if (MRegisterInfo::isPhysicalRegister(i->second.reg)) + fixed_.push_back(&i->second); } } Index: llvm/lib/CodeGen/LiveIntervalAnalysis.h diff -u llvm/lib/CodeGen/LiveIntervalAnalysis.h:1.37 llvm/lib/CodeGen/LiveIntervalAnalysis.h:1.38 --- llvm/lib/CodeGen/LiveIntervalAnalysis.h:1.37 Fri Jul 23 22:32:06 2004 +++ llvm/lib/CodeGen/LiveIntervalAnalysis.h Sat Jul 24 06:44:15 2004 @@ -41,10 +41,8 @@ typedef std::vector Index2MiMap; Index2MiMap i2miMap_; - /// r2iMap_ - This map OWNS the interval pointed to by the map. When - /// this map is destroyed or when entries are modified, this intervals - /// should be destroyed or modified as well. - std::map r2iMap_; + typedef std::map Reg2IntervalMap; + Reg2IntervalMap r2iMap_; typedef std::map Reg2RegMap; Reg2RegMap r2rMap_; @@ -80,16 +78,22 @@ return getBaseIndex(index) + InstrSlots::STORE; } - typedef std::map::const_iterator iterator; - iterator begin() const { return r2iMap_.begin(); } - iterator end() const { return r2iMap_.end(); } - unsigned getNumIntervals() const { return r2iMap_.size(); } - - LiveInterval &getInterval(unsigned reg) const { - std::map::const_iterator I = - r2iMap_.find(reg); + // FIXME: this should really be a const_iterator + typedef Reg2IntervalMap::iterator iterator; + iterator begin() { return r2iMap_.begin(); } + iterator end() { return r2iMap_.end(); } + unsigned getNumIntervals() const { return r2iMap_.size(); } + + LiveInterval &getInterval(unsigned reg) { + Reg2IntervalMap::iterator I = r2iMap_.find(reg); + assert(I != r2iMap_.end() && "Interval does not exist for register"); + return I->second; + } + + const LiveInterval &getInterval(unsigned reg) const { + Reg2IntervalMap::const_iterator I = r2iMap_.find(reg); assert(I != r2iMap_.end() && "Interval does not exist for register"); - return *I->second; + return I->second; } /// getInstructionIndex - returns the base index of instr @@ -155,13 +159,13 @@ bool overlapsAliases(const LiveInterval *lhs, const LiveInterval *rhs) const; - LiveInterval *createInterval(unsigned Reg) const; + static LiveInterval createInterval(unsigned Reg); LiveInterval &getOrCreateInterval(unsigned reg) { - LiveInterval *&LI = r2iMap_[reg]; - if (LI == 0) - LI = createInterval(reg); - return *LI; + Reg2IntervalMap::iterator I = r2iMap_.find(reg); + if (I == r2iMap_.end()) + I = r2iMap_.insert(I, std::make_pair(reg, createInterval(reg))); + return I->second; } /// rep - returns the representative of this register Index: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp diff -u llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.110 llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.111 --- llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.110 Fri Jul 23 23:32:22 2004 +++ llvm/lib/CodeGen/LiveIntervalAnalysis.cpp Sat Jul 24 06:44:15 2004 @@ -76,11 +76,7 @@ { mi2iMap_.clear(); i2miMap_.clear(); - for (std::map::iterator I = r2iMap_.begin(), - E = r2iMap_.end(); I != E; ++I) - delete I->second; // free all intervals. r2iMap_.clear(); - r2rMap_.clear(); } @@ -112,7 +108,7 @@ #if 1 DEBUG(std::cerr << "********** INTERVALS **********\n"); DEBUG(for (iterator I = begin(), E = end(); I != E; ++I) - std::cerr << *I->second << "\n"); + std::cerr << I->second << "\n"); #endif // join intervals if requested @@ -169,7 +165,7 @@ DEBUG(std::cerr << "********** INTERVALS **********\n"); DEBUG (for (iterator I = begin(), E = end(); I != E; ++I) - std::cerr << *I->second << "\n"); + std::cerr << I->second << "\n"); DEBUG(std::cerr << "********** MACHINEINSTRS **********\n"); DEBUG( for (MachineFunction::iterator mbbi = mf_->begin(), mbbe = mf_->end(); @@ -561,7 +557,6 @@ if ((TriviallyJoinable || !IntB.joinable(IntA, MIDefIdx)) && !overlapsAliases(&IntA, &IntB)) { IntB.join(IntA, MIDefIdx); - delete r2iMap_[regA]; // Delete the dead interval if (!MRegisterInfo::isPhysicalRegister(regA)) { r2iMap_.erase(regA); @@ -571,7 +566,7 @@ // the physreg information. r2rMap_[regB] = regA; IntB.reg = regA; - r2iMap_[regA] = r2iMap_[regB]; + IntA.swap(IntB); r2iMap_.erase(regB); } DEBUG(std::cerr << "Joined. Result = " << IntB << "\n"); @@ -661,8 +656,8 @@ return false; } -LiveInterval *LiveIntervals::createInterval(unsigned reg) const { +LiveInterval LiveIntervals::createInterval(unsigned reg) { float Weight = MRegisterInfo::isPhysicalRegister(reg) ? HUGE_VAL :0.0F; - return new LiveInterval(reg, Weight); + return LiveInterval(reg, Weight); } Index: llvm/lib/CodeGen/LiveInterval.h diff -u llvm/lib/CodeGen/LiveInterval.h:1.5 llvm/lib/CodeGen/LiveInterval.h:1.6 --- llvm/lib/CodeGen/LiveInterval.h:1.5 Fri Jul 23 21:52:23 2004 +++ llvm/lib/CodeGen/LiveInterval.h Sat Jul 24 06:44:15 2004 @@ -76,6 +76,21 @@ : reg(Reg), weight(Weight), NumValues(0) { } + LiveInterval& operator=(const LiveInterval& rhs) { + reg = rhs.reg; + weight = rhs.weight; + ranges = rhs.ranges; + NumValues = rhs.NumValues; + return *this; + } + + void swap(LiveInterval& other) { + std::swap(reg, other.reg); + std::swap(weight, other.weight); + ranges.swap(other.ranges); + std::swap(NumValues, other.NumValues); + } + bool containsOneValue() const { return NumValues == 1; } unsigned getNextValue() { Index: llvm/lib/CodeGen/LiveInterval.cpp diff -u llvm/lib/CodeGen/LiveInterval.cpp:1.6 llvm/lib/CodeGen/LiveInterval.cpp:1.7 --- llvm/lib/CodeGen/LiveInterval.cpp:1.6 Fri Jul 23 22:41:50 2004 +++ llvm/lib/CodeGen/LiveInterval.cpp Sat Jul 24 06:44:15 2004 @@ -75,8 +75,8 @@ return true; if (i->start > j->start) { - swap(i, j); - swap(ie, je); + std::swap(i, j); + std::swap(ie, je); } assert(i->start < j->start); From alkis at cs.uiuc.edu Sat Jul 24 06:51:37 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 24 Jul 2004 06:51:37 -0500 Subject: [llvm-commits] CVS: llvm-java/test/Makefile.test Message-ID: <200407241151.GAA30761@zion.cs.uiuc.edu> Changes in directory llvm-java/test: Makefile.test updated: 1.7 -> 1.8 --- Log message: Move .ll -> .bc rule to Makefile.rules since this is needed for the runtime. --- Diffs of the changes: (+0 -4) Index: llvm-java/test/Makefile.test diff -u llvm-java/test/Makefile.test:1.7 llvm-java/test/Makefile.test:1.8 --- llvm-java/test/Makefile.test:1.7 Sat Jul 24 06:43:28 2004 +++ llvm-java/test/Makefile.test Sat Jul 24 06:51:27 2004 @@ -27,10 +27,6 @@ %.dis-ll: %.bc $(LDIS) < $< > $@ -# rule to make bytecode from assembly -%.bc: %.ll - $(LAS) < $< > $@ - # rule to compile java source %.class: %.java $(JAVAC) $< From alkis at cs.uiuc.edu Sat Jul 24 06:51:37 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 24 Jul 2004 06:51:37 -0500 Subject: [llvm-commits] CVS: llvm-java/Makefile.rules Message-ID: <200407241151.GAA30768@zion.cs.uiuc.edu> Changes in directory llvm-java: Makefile.rules updated: 1.8 -> 1.9 --- Log message: Move .ll -> .bc rule to Makefile.rules since this is needed for the runtime. --- Diffs of the changes: (+4 -0) Index: llvm-java/Makefile.rules diff -u llvm-java/Makefile.rules:1.8 llvm-java/Makefile.rules:1.9 --- llvm-java/Makefile.rules:1.8 Fri Jul 23 20:29:34 2004 +++ llvm-java/Makefile.rules Sat Jul 24 06:51:27 2004 @@ -9,3 +9,7 @@ CLASS2LLVM := $(PROJTOOLCURRENT)/class2llvm$(EXEEXT) CLASSDUMP := $(PROJTOOLCURRENT)/classdump$(EXEEXT) + +# rule to make bytecode from assembly +%.bc: %.ll + $(LAS) < $< > $@ From alkis at cs.uiuc.edu Sat Jul 24 06:53:32 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 24 Jul 2004 06:53:32 -0500 Subject: [llvm-commits] CVS: llvm-java/Makefile Message-ID: <200407241153.GAA30985@zion.cs.uiuc.edu> Changes in directory llvm-java: Makefile updated: 1.2 -> 1.3 --- Log message: Add runtime to list of dirs --- Diffs of the changes: (+1 -1) Index: llvm-java/Makefile diff -u llvm-java/Makefile:1.2 llvm-java/Makefile:1.3 --- llvm-java/Makefile:1.2 Thu Apr 15 23:03:45 2004 +++ llvm-java/Makefile Sat Jul 24 06:53:22 2004 @@ -8,6 +8,6 @@ ##===----------------------------------------------------------------------===## LEVEL := . -DIRS := lib tools +DIRS := lib tools runtime include $(LEVEL)/Makefile.common From alkis at cs.uiuc.edu Sat Jul 24 10:41:07 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 24 Jul 2004 10:41:07 -0500 Subject: [llvm-commits] CVS: llvm-java/test/Makefile.test Message-ID: <200407241541.KAA06670@zion.cs.uiuc.edu> Changes in directory llvm-java/test: Makefile.test updated: 1.8 -> 1.9 --- Log message: Fix linking rule. --- Diffs of the changes: (+1 -1) Index: llvm-java/test/Makefile.test diff -u llvm-java/test/Makefile.test:1.8 llvm-java/test/Makefile.test:1.9 --- llvm-java/test/Makefile.test:1.8 Sat Jul 24 06:51:27 2004 +++ llvm-java/test/Makefile.test Sat Jul 24 10:40:57 2004 @@ -20,7 +20,7 @@ .PRECIOUS: Output/.dir Output/%.bc Output/%.ll Output/%.llvm.bc Output/%.llvm Output/%.class #rule to link in runtime to raw bytecode -%.linked.bc: %.raw.bc $(BUILD_SRC_ROOT)/runtime/runtime.bc +%.linked.bc: %.raw.bc $(LEVEL)/runtime/runtime.bc $(LLVMTOOLCURRENT)/llvm-link$(EXEEXT) $^ -o $@ # rule to make assembly from bytecode From alkis at cs.uiuc.edu Sat Jul 24 11:37:07 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 24 Jul 2004 11:37:07 -0500 Subject: [llvm-commits] CVS: llvm-java/Makefile.rules Message-ID: <200407241637.LAA06935@zion.cs.uiuc.edu> Changes in directory llvm-java: Makefile.rules updated: 1.9 -> 1.10 --- Log message: Use the correct variable for llvm-as. --- Diffs of the changes: (+1 -1) Index: llvm-java/Makefile.rules diff -u llvm-java/Makefile.rules:1.9 llvm-java/Makefile.rules:1.10 --- llvm-java/Makefile.rules:1.9 Sat Jul 24 06:51:27 2004 +++ llvm-java/Makefile.rules Sat Jul 24 11:36:57 2004 @@ -12,4 +12,4 @@ # rule to make bytecode from assembly %.bc: %.ll - $(LAS) < $< > $@ + $(LLVMAS) < $< > $@ From alkis at cs.uiuc.edu Sat Jul 24 13:55:26 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 24 Jul 2004 13:55:26 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveInterval.h Message-ID: <200407241855.NAA07531@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveInterval.h updated: 1.6 -> 1.7 --- Log message: Remove implementation of operator= and make it private so that it is not used accidentally. --- Diffs of the changes: (+1 -8) Index: llvm/lib/CodeGen/LiveInterval.h diff -u llvm/lib/CodeGen/LiveInterval.h:1.6 llvm/lib/CodeGen/LiveInterval.h:1.7 --- llvm/lib/CodeGen/LiveInterval.h:1.6 Sat Jul 24 06:44:15 2004 +++ llvm/lib/CodeGen/LiveInterval.h Sat Jul 24 13:55:15 2004 @@ -76,14 +76,6 @@ : reg(Reg), weight(Weight), NumValues(0) { } - LiveInterval& operator=(const LiveInterval& rhs) { - reg = rhs.reg; - weight = rhs.weight; - ranges = rhs.ranges; - NumValues = rhs.NumValues; - return *this; - } - void swap(LiveInterval& other) { std::swap(reg, other.reg); std::swap(weight, other.weight); @@ -160,6 +152,7 @@ Ranges::iterator addRangeFrom(LiveRange LR, Ranges::iterator From); void extendIntervalEndTo(Ranges::iterator I, unsigned NewEnd); Ranges::iterator extendIntervalStartTo(Ranges::iterator I, unsigned NewStr); + LiveInterval& operator=(const LiveInterval& rhs); // DO NOT IMPLEMENT }; std::ostream& operator<<(std::ostream& os, const LiveInterval& li); From alkis at cs.uiuc.edu Sat Jul 24 14:12:20 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 24 Jul 2004 14:12:20 -0500 Subject: [llvm-commits] CVS: llvm-java/test/Makefile.test Message-ID: <200407241912.OAA07672@zion.cs.uiuc.edu> Changes in directory llvm-java/test: Makefile.test updated: 1.9 -> 1.10 --- Log message: Use correct patterns for .PRECIOUS dependancies. --- Diffs of the changes: (+1 -1) Index: llvm-java/test/Makefile.test diff -u llvm-java/test/Makefile.test:1.9 llvm-java/test/Makefile.test:1.10 --- llvm-java/test/Makefile.test:1.9 Sat Jul 24 10:40:57 2004 +++ llvm-java/test/Makefile.test Sat Jul 24 14:12:10 2004 @@ -17,7 +17,7 @@ # we don't want these files to be deleted by make, even if they are # intermediate results -.PRECIOUS: Output/.dir Output/%.bc Output/%.ll Output/%.llvm.bc Output/%.llvm Output/%.class +.PRECIOUS: Output/.dir %.bc %.ll %.llvm.bc %.llvm %.class #rule to link in runtime to raw bytecode %.linked.bc: %.raw.bc $(LEVEL)/runtime/runtime.bc From alkis at cs.uiuc.edu Sat Jul 24 15:01:08 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 24 Jul 2004 15:01:08 -0500 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp Message-ID: <200407242001.PAA07921@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Compiler.cpp updated: 1.61 -> 1.62 --- Log message: Apparently the prototype for main is "void main(String[])". --- Diffs of the changes: (+1 -1) Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.61 llvm-java/lib/Compiler/Compiler.cpp:1.62 --- llvm-java/lib/Compiler/Compiler.cpp:1.61 Fri Jul 16 07:17:32 2004 +++ llvm-java/lib/Compiler/Compiler.cpp Sat Jul 24 15:00:57 2004 @@ -812,7 +812,7 @@ Function* main = compilerImpl_->compileMethod(m, - className + "/main([Ljava/lang/String;)I"); + className + "/main([Ljava/lang/String;)V"); Function* javaMain = m.getOrInsertFunction ("llvm_java_main", Type::IntTy, Type::IntTy, PointerType::get(PointerType::get(Type::SByteTy)), NULL); From alkis at cs.uiuc.edu Sat Jul 24 15:02:50 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 24 Jul 2004 15:02:50 -0500 Subject: [llvm-commits] CVS: llvm-java/test/Programs/SingleSource/UnitTests/TableSwitch.java LookupSwitch.java LongCompare.java If.java ForLoop.java FloatCompare.java BigConstants.java Arithm.java Message-ID: <200407242002.PAA07980@zion.cs.uiuc.edu> Changes in directory llvm-java/test/Programs/SingleSource/UnitTests: TableSwitch.java updated: 1.2 -> 1.3 LookupSwitch.java updated: 1.2 -> 1.3 LongCompare.java updated: 1.1 -> 1.2 If.java updated: 1.2 -> 1.3 ForLoop.java updated: 1.1 -> 1.2 FloatCompare.java updated: 1.1 -> 1.2 BigConstants.java updated: 1.1 -> 1.2 Arithm.java updated: 1.3 -> 1.4 --- Log message: Apparently the prototype for main is "void main(String[])". --- Diffs of the changes: (+31 -26) Index: llvm-java/test/Programs/SingleSource/UnitTests/TableSwitch.java diff -u llvm-java/test/Programs/SingleSource/UnitTests/TableSwitch.java:1.2 llvm-java/test/Programs/SingleSource/UnitTests/TableSwitch.java:1.3 --- llvm-java/test/Programs/SingleSource/UnitTests/TableSwitch.java:1.2 Thu May 27 07:50:41 2004 +++ llvm-java/test/Programs/SingleSource/UnitTests/TableSwitch.java Sat Jul 24 15:02:39 2004 @@ -1,13 +1,13 @@ public class TableSwitch { - public static int main(String[] args) { + public static void main(String[] args) { switch (4) { - case 0: return 4; - case 1: return 3; - case 2: return 2; - case 3: return 1; - case 4: return 0; - default: return -1; + case 0: System.out.println(4); + case 1: System.out.println(3); + case 2: System.out.println(2); + case 3: System.out.println(1); + case 4: System.out.println(0); + default: System.out.println(-1); } } } Index: llvm-java/test/Programs/SingleSource/UnitTests/LookupSwitch.java diff -u llvm-java/test/Programs/SingleSource/UnitTests/LookupSwitch.java:1.2 llvm-java/test/Programs/SingleSource/UnitTests/LookupSwitch.java:1.3 --- llvm-java/test/Programs/SingleSource/UnitTests/LookupSwitch.java:1.2 Thu May 27 07:50:41 2004 +++ llvm-java/test/Programs/SingleSource/UnitTests/LookupSwitch.java Sat Jul 24 15:02:39 2004 @@ -1,11 +1,11 @@ public class LookupSwitch { - public static int main(String[] args) { + public static void main(String[] args) { switch (128) { - case 0: return 255; - case 128: return 128; - case 255: return 0; - default: return -1; + case 0: System.out.println(255); + case 128: System.out.println(128); + case 255: System.out.println(0); + default: System.out.println(-1); } } } Index: llvm-java/test/Programs/SingleSource/UnitTests/LongCompare.java diff -u llvm-java/test/Programs/SingleSource/UnitTests/LongCompare.java:1.1 llvm-java/test/Programs/SingleSource/UnitTests/LongCompare.java:1.2 --- llvm-java/test/Programs/SingleSource/UnitTests/LongCompare.java:1.1 Thu May 27 16:08:56 2004 +++ llvm-java/test/Programs/SingleSource/UnitTests/LongCompare.java Sat Jul 24 15:02:39 2004 @@ -1,9 +1,11 @@ public class LongCompare { - public static int main(String[] args) { + public static void main(String[] args) { long l1 = 123456789123456789L; long l2 = 987654321987654321L; - return l1 == l2 ? 1 : 0; + System.out.println("l1 = " + l1); + System.out.println("l2 = " + l2); + System.out.println("l1 == l2 = " + (l1 == l2)); } } Index: llvm-java/test/Programs/SingleSource/UnitTests/If.java diff -u llvm-java/test/Programs/SingleSource/UnitTests/If.java:1.2 llvm-java/test/Programs/SingleSource/UnitTests/If.java:1.3 --- llvm-java/test/Programs/SingleSource/UnitTests/If.java:1.2 Thu May 27 07:50:41 2004 +++ llvm-java/test/Programs/SingleSource/UnitTests/If.java Sat Jul 24 15:02:39 2004 @@ -1,9 +1,10 @@ public class If { - public static int main(String[] args) { + public static void main(String[] args) { int i = 0; if (i == 0) - return 0; - return 1; + System.out.println("i == 0"); + else + System.out.println("i != 0"); } } Index: llvm-java/test/Programs/SingleSource/UnitTests/ForLoop.java diff -u llvm-java/test/Programs/SingleSource/UnitTests/ForLoop.java:1.1 llvm-java/test/Programs/SingleSource/UnitTests/ForLoop.java:1.2 --- llvm-java/test/Programs/SingleSource/UnitTests/ForLoop.java:1.1 Sat Jun 12 18:38:51 2004 +++ llvm-java/test/Programs/SingleSource/UnitTests/ForLoop.java Sat Jul 24 15:02:39 2004 @@ -1,10 +1,10 @@ public class ForLoop { - public static int main(String[] args) { + public static void main(String[] args) { int sum = 0; for (int i = 0; i < 100; ++i) sum += i; - return sum; + System.out.println(sum); } } Index: llvm-java/test/Programs/SingleSource/UnitTests/FloatCompare.java diff -u llvm-java/test/Programs/SingleSource/UnitTests/FloatCompare.java:1.1 llvm-java/test/Programs/SingleSource/UnitTests/FloatCompare.java:1.2 --- llvm-java/test/Programs/SingleSource/UnitTests/FloatCompare.java:1.1 Sat Jun 12 18:41:49 2004 +++ llvm-java/test/Programs/SingleSource/UnitTests/FloatCompare.java Sat Jul 24 15:02:39 2004 @@ -1,6 +1,6 @@ public class FloatCompare { - public static int main(String[] args) { + public static void main(String[] args) { int count = 0; for (float f = 0.0F; f < 10F; f += 1.1F) @@ -9,6 +9,6 @@ for (double d = 100; d > 0; d -= 11) ++count; - return count; + System.out.println(count); } } Index: llvm-java/test/Programs/SingleSource/UnitTests/BigConstants.java diff -u llvm-java/test/Programs/SingleSource/UnitTests/BigConstants.java:1.1 llvm-java/test/Programs/SingleSource/UnitTests/BigConstants.java:1.2 --- llvm-java/test/Programs/SingleSource/UnitTests/BigConstants.java:1.1 Thu May 27 15:24:49 2004 +++ llvm-java/test/Programs/SingleSource/UnitTests/BigConstants.java Sat Jul 24 15:02:39 2004 @@ -1,11 +1,13 @@ public class BigConstants { - public static int main(String[] args) { + public static void main(String[] args) { int i = 1234567890; long l = 1234567890123456789L; float f = -1.23456789e10F; double d = 1.23456789e100; - - return 0; + System.out.println("i = " + i); + System.out.println("l = " + l); + System.out.println("f = " + f); + System.out.println("d = " + d); } } Index: llvm-java/test/Programs/SingleSource/UnitTests/Arithm.java diff -u llvm-java/test/Programs/SingleSource/UnitTests/Arithm.java:1.3 llvm-java/test/Programs/SingleSource/UnitTests/Arithm.java:1.4 --- llvm-java/test/Programs/SingleSource/UnitTests/Arithm.java:1.3 Thu May 27 07:50:41 2004 +++ llvm-java/test/Programs/SingleSource/UnitTests/Arithm.java Sat Jul 24 15:02:39 2004 @@ -1,9 +1,9 @@ public class Arithm { - public static int main(String[] args) { + public static void main(String[] args) { int one = 1; int two = 2; - return (one + two) - (two * two) + (two / one) + (two % one) + (two << one) - (two >> 1) + (-two); // = 2 + System.out.println((one + two) - (two * two) + (two / one) + (two % one) + (two << one) - (two >> 1) + (-two)); // = 2 } } From alkis at cs.uiuc.edu Sat Jul 24 15:05:52 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 24 Jul 2004 15:05:52 -0500 Subject: [llvm-commits] CVS: llvm-java/test/Programs/SingleSource/Makefile.singlesrc Message-ID: <200407242005.PAA08073@zion.cs.uiuc.edu> Changes in directory llvm-java/test/Programs/SingleSource: Makefile.singlesrc updated: 1.1 -> 1.2 --- Log message: Generate class files in Output/. Add rules to run .class files with the native jvm. --- Diffs of the changes: (+2 -2) Index: llvm-java/test/Programs/SingleSource/Makefile.singlesrc diff -u llvm-java/test/Programs/SingleSource/Makefile.singlesrc:1.1 llvm-java/test/Programs/SingleSource/Makefile.singlesrc:1.2 --- llvm-java/test/Programs/SingleSource/Makefile.singlesrc:1.1 Fri Jul 23 20:29:34 2004 +++ llvm-java/test/Programs/SingleSource/Makefile.singlesrc Sat Jul 24 15:05:42 2004 @@ -8,7 +8,7 @@ ##===----------------------------------------------------------------------===## # rule to build raw bytecode from a classfile -Output/%.raw.bc: %.class Output/.dir $(CLASS2LLVM) - $(CLASS2LLVM) $* | $(LOPT) -mem2reg > $@ +%.raw.bc: %.class $(CLASS2LLVM) + $(CLASS2LLVM) $(subst /,.,$*) | $(LOPT) -mem2reg > $@ include $(LEVEL)/test/Makefile.test From alkis at cs.uiuc.edu Sat Jul 24 15:05:52 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 24 Jul 2004 15:05:52 -0500 Subject: [llvm-commits] CVS: llvm-java/test/Makefile.test Message-ID: <200407242005.PAA08080@zion.cs.uiuc.edu> Changes in directory llvm-java/test: Makefile.test updated: 1.10 -> 1.11 --- Log message: Generate class files in Output/. Add rules to run .class files with the native jvm. --- Diffs of the changes: (+12 -4) Index: llvm-java/test/Makefile.test diff -u llvm-java/test/Makefile.test:1.10 llvm-java/test/Makefile.test:1.11 --- llvm-java/test/Makefile.test:1.10 Sat Jul 24 14:12:10 2004 +++ llvm-java/test/Makefile.test Sat Jul 24 15:05:42 2004 @@ -12,12 +12,12 @@ .PHONY: clean clean:: - $(RM) -f a.out core *.class .class-stamp + $(RM) -f a.out core $(RM) -rf Output/ # we don't want these files to be deleted by make, even if they are # intermediate results -.PRECIOUS: Output/.dir %.bc %.ll %.llvm.bc %.llvm %.class +.PRECIOUS: Output/.dir Output/%.class %.bc %.ll %.llvm.bc %.llvm #rule to link in runtime to raw bytecode %.linked.bc: %.raw.bc $(LEVEL)/runtime/runtime.bc @@ -28,5 +28,13 @@ $(LDIS) < $< > $@ # rule to compile java source -%.class: %.java - $(JAVAC) $< +Output/%.class: %.java Output/.dir + $(JAVAC) -d Output $< + +# rule to run a .class file with the jvm +%.out-nat: %.class + $(JAVA) -cp Output $(subst /,.,$(subst Output/,,$*)) > $*.out-nat || rm -f $*.out-nat + +# rule to run a .class file with the llvm jit +%.out-jit: %.llvm.bc + $(LLI) $< > $*.out-nat || rm -f $*.out-nat From alkis at cs.uiuc.edu Sat Jul 24 15:33:33 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 24 Jul 2004 15:33:33 -0500 Subject: [llvm-commits] CVS: llvm-java/lib/ClassFile/ClassFile.cpp Message-ID: <200407242033.PAA08224@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/ClassFile: ClassFile.cpp updated: 1.17 -> 1.18 --- Log message: Remove much of the constness in this file as most classes cannot be modified anyway. We are just careful when we are returning containers of pointers to these datastructures as we do not want users to modify them. --- Diffs of the changes: (+9 -9) Index: llvm-java/lib/ClassFile/ClassFile.cpp diff -u llvm-java/lib/ClassFile/ClassFile.cpp:1.17 llvm-java/lib/ClassFile/ClassFile.cpp:1.18 --- llvm-java/lib/ClassFile/ClassFile.cpp:1.17 Wed Jul 14 04:21:53 2004 +++ llvm-java/lib/ClassFile/ClassFile.cpp Sat Jul 24 15:33:23 2004 @@ -141,7 +141,7 @@ //===----------------------------------------------------------------------===// // ClassFile implementation -const ClassFile* ClassFile::readClassFile(std::istream& is) +ClassFile* ClassFile::readClassFile(std::istream& is) { if (readU1(is) != 0xCA) throw ClassFileParseError("bad magic"); if (readU1(is) != 0xFE) throw ClassFileParseError("bad magic"); @@ -189,9 +189,9 @@ throw ClassNotFoundException("Class " + classname + " not found"); } -const ClassFile* ClassFile::getClassFile(const std::string& classname) +ClassFile* ClassFile::getClassFile(const std::string& classname) { - typedef std::map Name2ClassMap; + typedef std::map Name2ClassMap; static Name2ClassMap n2cMap_; Name2ClassMap::iterator it = n2cMap_.upper_bound(classname); @@ -228,7 +228,7 @@ (*i)->getName()->str() + (*i)->getDescriptor()->str(), *i)); } -const Method* ClassFile::getMethod(const std::string& nameAndDescr) const +Method* ClassFile::getMethod(const std::string& nameAndDescr) const { Name2MethodMap::const_iterator it = n2mMap_.find(nameAndDescr); return it == n2mMap_.end() ? NULL : it->second; @@ -267,8 +267,8 @@ //===----------------------------------------------------------------------===// // Utility functions -const Attribute* llvm::Java::getAttribute(const Attributes& attrs, - const std::string& name) +Attribute* llvm::Java::getAttribute(const Attributes& attrs, + const std::string& name) { for (unsigned i = 0, e = attrs.size(); i != e; ++i) if (attrs[i]->getName()->str() == name) @@ -500,7 +500,7 @@ return os; } -const ConstantValueAttribute* Field::getConstantValueAttribute() const +ConstantValueAttribute* Field::getConstantValueAttribute() const { if (!isStatic()) return NULL; @@ -548,12 +548,12 @@ return os; } -const CodeAttribute* Method::getCodeAttribute() const +CodeAttribute* Method::getCodeAttribute() const { return (CodeAttribute*) getAttribute(attributes_, Attribute::CODE); } -const ExceptionsAttribute* Method::getExceptionsAttribute() const +ExceptionsAttribute* Method::getExceptionsAttribute() const { return (ExceptionsAttribute*) getAttribute(attributes_, Attribute::EXCEPTIONS); From alkis at cs.uiuc.edu Sat Jul 24 15:33:33 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 24 Jul 2004 15:33:33 -0500 Subject: [llvm-commits] CVS: llvm-java/include/llvm/Java/ClassFile.h Message-ID: <200407242033.PAA08231@zion.cs.uiuc.edu> Changes in directory llvm-java/include/llvm/Java: ClassFile.h updated: 1.16 -> 1.17 --- Log message: Remove much of the constness in this file as most classes cannot be modified anyway. We are just careful when we are returning containers of pointers to these datastructures as we do not want users to modify them. --- Diffs of the changes: (+22 -22) Index: llvm-java/include/llvm/Java/ClassFile.h diff -u llvm-java/include/llvm/Java/ClassFile.h:1.16 llvm-java/include/llvm/Java/ClassFile.h:1.17 --- llvm-java/include/llvm/Java/ClassFile.h:1.16 Wed Jul 14 04:21:53 2004 +++ llvm-java/include/llvm/Java/ClassFile.h Sat Jul 24 15:33:23 2004 @@ -59,18 +59,18 @@ typedef std::vector Methods; typedef std::vector Attributes; - const Attribute* getAttribute(const Attributes& attrs, - const std::string& name); + Attribute* getAttribute(const Attributes& attrs, + const std::string& name); class ClassFile { - static const ClassFile* readClassFile(std::istream& is); + static ClassFile* readClassFile(std::istream& is); static std::vector getClassPath(); static std::string getFileForClass(const std::string& classname); typedef std::map Name2MethodMap; public: - static const ClassFile* getClassFile(const std::string& classname); + static ClassFile* getClassFile(const std::string& classname); ~ClassFile(); @@ -85,8 +85,8 @@ bool isInterface() const { return accessFlags_ & ACC_INTERFACE; } bool isAbstract() const { return accessFlags_ & ACC_ABSTRACT; } - const ConstantClass* getThisClass() const { return thisClass_; } - const ConstantClass* getSuperClass() const { return superClass_; } + ConstantClass* getThisClass() const { return thisClass_; } + ConstantClass* getSuperClass() const { return superClass_; } const Classes& getInterfaces() const { return interfaces_; } @@ -96,7 +96,7 @@ const Attributes& getAttributes() const { return attributes_; } - const Method* getMethod(const std::string& nameAndDescr) const; + Method* getMethod(const std::string& nameAndDescr) const; std::ostream& dump(std::ostream& os) const; @@ -160,8 +160,8 @@ uint16_t nameIdx_; public: ConstantClass(const ConstantPool& cp, std::istream& is); - const ConstantUtf8* getName() const { - return (const ConstantUtf8*) cPool_[nameIdx_]; + ConstantUtf8* getName() const { + return (ConstantUtf8*) cPool_[nameIdx_]; } std::ostream& dump(std::ostream& os) const; }; @@ -173,11 +173,11 @@ ConstantMemberRef(const ConstantPool& cp, std::istream& is); public: - const ConstantClass* getClass() const { - return (const ConstantClass*) cPool_[classIdx_]; + ConstantClass* getClass() const { + return (ConstantClass*) cPool_[classIdx_]; } - const ConstantNameAndType* getNameAndType() const { - return (const ConstantNameAndType*) cPool_[nameAndTypeIdx_]; + ConstantNameAndType* getNameAndType() const { + return (ConstantNameAndType*) cPool_[nameAndTypeIdx_]; } std::ostream& dump(std::ostream& os) const; }; @@ -201,8 +201,8 @@ uint16_t stringIdx_; public: ConstantString(const ConstantPool& cp, std::istream& is); - const ConstantUtf8* getValue() const { - return (const ConstantUtf8*) cPool_[stringIdx_]; + ConstantUtf8* getValue() const { + return (ConstantUtf8*) cPool_[stringIdx_]; } std::ostream& dump(std::ostream& os) const; }; @@ -246,11 +246,11 @@ uint16_t descriptorIdx_; public: ConstantNameAndType(const ConstantPool& cp, std::istream& is); - const ConstantUtf8* getName() const { - return (const ConstantUtf8*) cPool_[nameIdx_]; + ConstantUtf8* getName() const { + return (ConstantUtf8*) cPool_[nameIdx_]; } - const ConstantUtf8* getDescriptor() const { - return (const ConstantUtf8*) cPool_[descriptorIdx_]; + ConstantUtf8* getDescriptor() const { + return (ConstantUtf8*) cPool_[descriptorIdx_]; } std::ostream& dump(std::ostream& os) const; }; @@ -291,7 +291,7 @@ ConstantUtf8* getName() const { return name_; } ConstantUtf8* getDescriptor() const { return descriptor_; } const Attributes& getAttributes() const { return attributes_; } - const ConstantValueAttribute* getConstantValueAttribute() const; + ConstantValueAttribute* getConstantValueAttribute() const; std::ostream& dump(std::ostream& os) const; }; @@ -328,8 +328,8 @@ ConstantUtf8* getName() const { return name_; } ConstantUtf8* getDescriptor() const { return descriptor_; } const Attributes& getAttributes() const { return attributes_; } - const CodeAttribute* getCodeAttribute() const; - const ExceptionsAttribute* getExceptionsAttribute() const; + CodeAttribute* getCodeAttribute() const; + ExceptionsAttribute* getExceptionsAttribute() const; std::ostream& dump(std::ostream& os) const; }; From alkis at cs.uiuc.edu Sat Jul 24 15:42:23 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 24 Jul 2004 15:42:23 -0500 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp Message-ID: <200407242042.PAA08289@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Compiler.cpp updated: 1.62 -> 1.63 --- Log message: Remove some more constness :-) --- Diffs of the changes: (+28 -30) Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.62 llvm-java/lib/Compiler/Compiler.cpp:1.63 --- llvm-java/lib/Compiler/Compiler.cpp:1.62 Sat Jul 24 15:00:57 2004 +++ llvm-java/lib/Compiler/Compiler.cpp Sat Jul 24 15:42:13 2004 @@ -49,18 +49,17 @@ return !isTwoSlotValue(v); } - llvm::Constant* getConstant(const Constant* c) { - if (dynamic_cast(c)) + llvm::Constant* getConstant(Constant* c) { + if (dynamic_cast(c)) assert(0 && "not implemented"); - else if (const ConstantInteger* i = - dynamic_cast(c)) + else if (ConstantInteger* i = + dynamic_cast(c)) return ConstantSInt::get(Type::IntTy, i->getValue()); - else if (const ConstantFloat* f = dynamic_cast(c)) + else if (ConstantFloat* f = dynamic_cast(c)) return ConstantFP::get(Type::FloatTy, f->getValue()); - else if (const ConstantLong* l = dynamic_cast(c)) + else if (ConstantLong* l = dynamic_cast(c)) return ConstantSInt::get(Type::LongTy, l->getValue()); - else if (const ConstantDouble* d = - dynamic_cast(c)) + else if (ConstantDouble* d = dynamic_cast(c)) return ConstantFP::get(Type::DoubleTy, d->getValue()); else return NULL; // FIXME: throw something @@ -71,7 +70,7 @@ public: Bytecode2BasicBlockMapper(Function& f, BC2BBMap& m, - const CodeAttribute& c) + CodeAttribute& c) : function_(f), bc2bbMap_(m), codeAttr_(c) { } void compute() { @@ -136,21 +135,21 @@ public BytecodeParser { private: Module* module_; - const ClassFile* cf_; + ClassFile* cf_; OperandStack opStack_; Locals locals_; BC2BBMap bc2bbMap_; BasicBlock* prologue_; typedef SetVector FunctionSet; FunctionSet toCompileFunctions_; - typedef std::map Class2TypeMap; + typedef std::map Class2TypeMap; Class2TypeMap c2tMap_; private: BasicBlock* getBBAt(unsigned bcI) { return bc2bbMap_[bcI]; } private: - const Type* getType(JType type) { + Type* getType(JType type) { switch (type) { case REFERENCE: return PointerType::get(getTypeForClass("java/lang/Object")); @@ -181,12 +180,12 @@ return static_cast(-1); } - const Type* getType(const ConstantUtf8* descr) { + Type* getType(ConstantUtf8* descr) { unsigned i = 0; return getTypeHelper(descr->str(), i); } - const Type* getTypeHelper(const std::string& descr, unsigned& i) { + Type* getTypeHelper(const std::string& descr, unsigned& i) { assert(i < descr.size()); switch (descr[i++]) { case 'B': return Type::SByteTy; @@ -221,22 +220,22 @@ } } - const Type* getTypeForClass(const std::string& className) { + Type* getTypeForClass(const std::string& className) { Class2TypeMap::iterator it = c2tMap_.lower_bound(className); if (it == c2tMap_.end() || it->first != className) { - const ClassFile* cf = ClassFile::getClassFile(className); + ClassFile* cf = ClassFile::getClassFile(className); OpaqueType* newType = OpaqueType::get(); it = c2tMap_.insert(it, std::make_pair(className, newType)); std::vector elements; - if (const ConstantClass* super = cf->getSuperClass()) + if (ConstantClass* super = cf->getSuperClass()) elements.push_back (getTypeForClass(super->getName()->str())); const Fields& fields = cf->getFields(); for (unsigned i = 0, e = fields.size(); i != e; ++i) { - const Field* field = fields[i]; + Field* field = fields[i]; if (field->isStatic()) { llvm::Constant* init = NULL; - if (const ConstantValueAttribute* cv = + if (ConstantValueAttribute* cv = field->getConstantValueAttribute()) init = getConstant(cv->getValue()); @@ -262,7 +261,7 @@ return it->second; } - Value* getOrCreateLocal(unsigned index, const Type* type) { + Value* getOrCreateLocal(unsigned index, Type* type) { if (!locals_[index] || cast(locals_[index]->getType())->getElementType() != type) { locals_[index] = new AllocaInst @@ -277,7 +276,7 @@ DEBUG(std::cerr << "Compiling method: " << classMethodDesc << '\n'); module_ = &module; - const Method* method; + Method* method; tie(cf_, method) = findClassAndMethod(classMethodDesc); std::string name = cf_->getThisClass()->getName()->str(); @@ -291,7 +290,7 @@ Function::InternalLinkage : Function::ExternalLinkage); - const Java::CodeAttribute* codeAttr = method->getCodeAttribute(); + Java::CodeAttribute* codeAttr = method->getCodeAttribute(); while (!opStack_.empty()) opStack_.pop(); @@ -318,14 +317,14 @@ return function; } - std::pair + std::pair findClassAndMethod(const std::string& classMethodDesc) { unsigned slash = classMethodDesc.find('/'); std::string className = classMethodDesc.substr(0, slash); std::string methodNameAndDescr = classMethodDesc.substr(slash+1); - const ClassFile* classfile = ClassFile::getClassFile(className); - const Method* method = classfile->getMethod(methodNameAndDescr); + ClassFile* classfile = ClassFile::getClassFile(className); + Method* method = classfile->getMethod(methodNameAndDescr); if (!method) throw InvocationTargetException( "Method " + methodNameAndDescr + @@ -371,7 +370,7 @@ } void do_ldc(unsigned bcI, unsigned index) { - const Constant* c = cf_->getConstantPool()[index]; + Constant* c = cf_->getConstantPool()[index]; assert(getConstant(c) && "Java constant not handled!"); opStack_.push(getConstant(c)); } @@ -721,17 +720,16 @@ } void do_invokestatic(unsigned bcI, unsigned index) { - const ConstantMethodRef* methodRef = + ConstantMethodRef* methodRef = (ConstantMethodRef*)(cf_->getConstantPool()[index]); - const ConstantNameAndType* nameAndType = - methodRef->getNameAndType(); + ConstantNameAndType* nameAndType = methodRef->getNameAndType(); std::string funcName = methodRef->getClass()->getName()->str() + '/' + nameAndType->getName()->str() + nameAndType->getDescriptor()->str(); - const FunctionType* funcType = + FunctionType* funcType = cast(getType(nameAndType->getDescriptor())); std::vector params(funcType->getNumParams(), NULL); for (unsigned i = funcType->getNumParams(); i > 0; ) { From alkis at cs.uiuc.edu Sat Jul 24 15:49:04 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 24 Jul 2004 15:49:04 -0500 Subject: [llvm-commits] CVS: llvm-java/runtime/runtime.ll Message-ID: <200407242049.PAA08376@zion.cs.uiuc.edu> Changes in directory llvm-java/runtime: runtime.ll updated: 1.2 -> 1.3 --- Log message: Change main prototype to match Java's. --- Diffs of the changes: (+3 -3) Index: llvm-java/runtime/runtime.ll diff -u llvm-java/runtime/runtime.ll:1.2 llvm-java/runtime/runtime.ll:1.3 --- llvm-java/runtime/runtime.ll:1.2 Fri Jul 16 05:18:51 2004 +++ llvm-java/runtime/runtime.ll Sat Jul 24 15:48:53 2004 @@ -3,11 +3,11 @@ implementation declare void %llvm_java_static_init() -declare int %llvm_java_main(int, sbyte**) +declare void %llvm_java_main(int, sbyte**) int %main(int %argc, sbyte** %argv) { entry: call void %llvm_java_static_init() - %result = call int %llvm_java_main(int %argc, sbyte** %argv) - ret int %result + call void %llvm_java_main(int %argc, sbyte** %argv) + ret int 0 } From alkis at cs.uiuc.edu Sat Jul 24 15:49:04 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 24 Jul 2004 15:49:04 -0500 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp Message-ID: <200407242049.PAA08383@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Compiler.cpp updated: 1.63 -> 1.64 --- Log message: Change main prototype to match Java's. --- Diffs of the changes: (+1 -1) Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.63 llvm-java/lib/Compiler/Compiler.cpp:1.64 --- llvm-java/lib/Compiler/Compiler.cpp:1.63 Sat Jul 24 15:42:13 2004 +++ llvm-java/lib/Compiler/Compiler.cpp Sat Jul 24 15:48:54 2004 @@ -813,7 +813,7 @@ className + "/main([Ljava/lang/String;)V"); Function* javaMain = m.getOrInsertFunction ("llvm_java_main", Type::IntTy, - Type::IntTy, PointerType::get(PointerType::get(Type::SByteTy)), NULL); + Type::VoidTy, PointerType::get(PointerType::get(Type::SByteTy)), NULL); BasicBlock* bb = new BasicBlock("entry", javaMain); const FunctionType* mainTy = main->getFunctionType(); From alkis at cs.uiuc.edu Sat Jul 24 15:55:53 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 24 Jul 2004 15:55:53 -0500 Subject: [llvm-commits] CVS: llvm-java/test/Programs/SingleSource/UnitTests/StaticInitializers.java Message-ID: <200407242055.PAA08497@zion.cs.uiuc.edu> Changes in directory llvm-java/test/Programs/SingleSource/UnitTests: StaticInitializers.java added (r1.1) --- Log message: New test case --- Diffs of the changes: (+16 -0) Index: llvm-java/test/Programs/SingleSource/UnitTests/StaticInitializers.java diff -c /dev/null llvm-java/test/Programs/SingleSource/UnitTests/StaticInitializers.java:1.1 *** /dev/null Sat Jul 24 15:55:53 2004 --- llvm-java/test/Programs/SingleSource/UnitTests/StaticInitializers.java Sat Jul 24 15:55:43 2004 *************** *** 0 **** --- 1,16 ---- + public class StaticInitializers + { + static int foo = 0; + static int bar = init(); + static int baz = init(); + + static int init() { + return ++foo; + } + + public static void main(String[] args) { + System.out.println("foo = " + foo); + System.out.println("bar = " + bar); + System.out.println("baz = " + baz); + } + } From alkis at cs.uiuc.edu Sat Jul 24 16:05:09 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 24 Jul 2004 16:05:09 -0500 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp Message-ID: <200407242105.QAA08621@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Compiler.cpp updated: 1.64 -> 1.65 --- Log message: Initialize the module_ in the compileMethod() function which is the only entry point to the compiler. --- Diffs of the changes: (+5 -6) Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.64 llvm-java/lib/Compiler/Compiler.cpp:1.65 --- llvm-java/lib/Compiler/Compiler.cpp:1.64 Sat Jul 24 15:48:54 2004 +++ llvm-java/lib/Compiler/Compiler.cpp Sat Jul 24 16:04:59 2004 @@ -271,11 +271,9 @@ return locals_[index]; } - Function* compileMethodOnly(Module& module, - const std::string& classMethodDesc) { + Function* compileMethodOnly(const std::string& classMethodDesc) { DEBUG(std::cerr << "Compiling method: " << classMethodDesc << '\n'); - module_ = &module; Method* method; tie(cf_, method) = findClassAndMethod(classMethodDesc); @@ -284,7 +282,7 @@ name += method->getName()->str(); name += method->getDescriptor()->str(); - Function* function = module.getOrInsertFunction + Function* function = module_->getOrInsertFunction (name, cast(getType(method->getDescriptor()))); function->setLinkage(method->isPrivate() ? Function::InternalLinkage : @@ -337,13 +335,14 @@ public: Function* compileMethod(Module& module, const std::string& classMethodDesc) { + module_ = &module; c2tMap_.insert(std::make_pair("java/lang/Object", OpaqueType::get())); module.addTypeName("java/lang/Object", c2tMap_["java/lang/Object"]); - Function* function = compileMethodOnly(module, classMethodDesc); + Function* function = compileMethodOnly(classMethodDesc); for (unsigned i = 0; i != toCompileFunctions_.size(); ++i) { Function* f = toCompileFunctions_[i]; - compileMethodOnly(module, f->getName()); + compileMethodOnly(f->getName()); } return function; From alkis at cs.uiuc.edu Sat Jul 24 16:49:47 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 24 Jul 2004 16:49:47 -0500 Subject: [llvm-commits] CVS: llvm-java/lib/ClassFile/ClassFile.cpp Message-ID: <200407242149.QAA08829@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/ClassFile: ClassFile.cpp updated: 1.18 -> 1.19 --- Log message: Add classpath (-cp or -classpath) command line option. --- Diffs of the changes: (+20 -4) Index: llvm-java/lib/ClassFile/ClassFile.cpp diff -u llvm-java/lib/ClassFile/ClassFile.cpp:1.18 llvm-java/lib/ClassFile/ClassFile.cpp:1.19 --- llvm-java/lib/ClassFile/ClassFile.cpp:1.18 Sat Jul 24 15:33:23 2004 +++ llvm-java/lib/ClassFile/ClassFile.cpp Sat Jul 24 16:49:37 2004 @@ -15,6 +15,7 @@ #define DEBUG_TYPE "classfile" #include +#include #include #include #include @@ -28,6 +29,22 @@ using namespace llvm::Java; +namespace { + + using namespace llvm; + + static cl::opt + ClassPath("cp", + cl::desc("A : separated list of directories"), + cl::value_desc("class search path"), + cl::init(getenv("CLASSPATH"))); + static cl::alias + ClassPathA("classpath", + cl::desc("Alias for -cp"), + cl::aliasopt(ClassPath)); + +} + //===----------------------------------------------------------------------===// // Internal utility functions namespace { @@ -153,14 +170,13 @@ std::vector ClassFile::getClassPath() { - std::string classpath = getenv("CLASSPATH"); - DEBUG(std::cerr << "CLASSPATH=" << classpath << '\n'); + DEBUG(std::cerr << "CLASSPATH=" << ClassPath << '\n'); std::vector result; unsigned b = 0, e = 0; do { - e = classpath.find(':', b); - result.push_back(classpath.substr(b, e)); + e = ClassPath.find(':', b); + result.push_back(ClassPath.substr(b, e)); b = e + 1; } while (e != std::string::npos); From alkis at cs.uiuc.edu Sat Jul 24 17:06:28 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 24 Jul 2004 17:06:28 -0500 Subject: [llvm-commits] CVS: llvm-java/lib/ClassFile/ClassFile.cpp Message-ID: <200407242206.RAA08986@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/ClassFile: ClassFile.cpp updated: 1.19 -> 1.20 --- Log message: Fix classpath parsing. --- Diffs of the changes: (+1 -1) Index: llvm-java/lib/ClassFile/ClassFile.cpp diff -u llvm-java/lib/ClassFile/ClassFile.cpp:1.19 llvm-java/lib/ClassFile/ClassFile.cpp:1.20 --- llvm-java/lib/ClassFile/ClassFile.cpp:1.19 Sat Jul 24 16:49:37 2004 +++ llvm-java/lib/ClassFile/ClassFile.cpp Sat Jul 24 17:06:18 2004 @@ -176,7 +176,7 @@ unsigned b = 0, e = 0; do { e = ClassPath.find(':', b); - result.push_back(ClassPath.substr(b, e)); + result.push_back(ClassPath.substr(b, e - b)); b = e + 1; } while (e != std::string::npos); From alkis at cs.uiuc.edu Sat Jul 24 17:37:54 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 24 Jul 2004 17:37:54 -0500 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp Message-ID: <200407242237.RAA09242@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Compiler.cpp updated: 1.65 -> 1.66 --- Log message: Correct arguments for llvm_java_main(). --- Diffs of the changes: (+2 -2) Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.65 llvm-java/lib/Compiler/Compiler.cpp:1.66 --- llvm-java/lib/Compiler/Compiler.cpp:1.65 Sat Jul 24 16:04:59 2004 +++ llvm-java/lib/Compiler/Compiler.cpp Sat Jul 24 17:37:44 2004 @@ -811,8 +811,8 @@ compilerImpl_->compileMethod(m, className + "/main([Ljava/lang/String;)V"); Function* javaMain = m.getOrInsertFunction - ("llvm_java_main", Type::IntTy, - Type::VoidTy, PointerType::get(PointerType::get(Type::SByteTy)), NULL); + ("llvm_java_main", Type::VoidTy, + Type::IntTy, PointerType::get(PointerType::get(Type::SByteTy)), NULL); BasicBlock* bb = new BasicBlock("entry", javaMain); const FunctionType* mainTy = main->getFunctionType(); From alkis at cs.uiuc.edu Sat Jul 24 18:32:11 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 24 Jul 2004 18:32:11 -0500 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp Message-ID: <200407242332.SAA09549@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Compiler.cpp updated: 1.66 -> 1.67 --- Log message: Fix return instruction from function returning void. --- Diffs of the changes: (+6 -7) Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.66 llvm-java/lib/Compiler/Compiler.cpp:1.67 --- llvm-java/lib/Compiler/Compiler.cpp:1.66 Sat Jul 24 17:37:44 2004 +++ llvm-java/lib/Compiler/Compiler.cpp Sat Jul 24 18:32:01 2004 @@ -816,11 +816,10 @@ BasicBlock* bb = new BasicBlock("entry", javaMain); const FunctionType* mainTy = main->getFunctionType(); - new ReturnInst( - new CallInst(main, - // FIXME: Forward correct params from llvm_java_main - llvm::Constant::getNullValue(mainTy->getParamType(0)), - TMP, - bb), - bb); + new CallInst(main, + // FIXME: Forward correct params from llvm_java_main + llvm::Constant::getNullValue(mainTy->getParamType(0)), + TMP, + bb); + new ReturnInst(NULL, bb); } From alkis at cs.uiuc.edu Sat Jul 24 18:40:24 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 24 Jul 2004 18:40:24 -0500 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp Message-ID: <200407242340.SAA09638@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Compiler.cpp updated: 1.67 -> 1.68 --- Log message: Values with type void should not have a name. --- Diffs of the changes: (+1 -1) Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.67 llvm-java/lib/Compiler/Compiler.cpp:1.68 --- llvm-java/lib/Compiler/Compiler.cpp:1.67 Sat Jul 24 18:32:01 2004 +++ llvm-java/lib/Compiler/Compiler.cpp Sat Jul 24 18:40:14 2004 @@ -819,7 +819,7 @@ new CallInst(main, // FIXME: Forward correct params from llvm_java_main llvm::Constant::getNullValue(mainTy->getParamType(0)), - TMP, + "", bb); new ReturnInst(NULL, bb); } From alkis at cs.uiuc.edu Sat Jul 24 18:56:05 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 24 Jul 2004 18:56:05 -0500 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp Message-ID: <200407242356.SAA09783@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Compiler.cpp updated: 1.68 -> 1.69 --- Log message: Implement static initializers and the getstatic and putstatic java opcodes. --- Diffs of the changes: (+81 -18) Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.68 llvm-java/lib/Compiler/Compiler.cpp:1.69 --- llvm-java/lib/Compiler/Compiler.cpp:1.68 Sat Jul 24 18:40:14 2004 +++ llvm-java/lib/Compiler/Compiler.cpp Sat Jul 24 18:55:54 2004 @@ -233,22 +233,7 @@ const Fields& fields = cf->getFields(); for (unsigned i = 0, e = fields.size(); i != e; ++i) { Field* field = fields[i]; - if (field->isStatic()) { - llvm::Constant* init = NULL; - if (ConstantValueAttribute* cv = - field->getConstantValueAttribute()) - init = getConstant(cv->getValue()); - - new GlobalVariable(getType(field->getDescriptor()), - field->isFinal(), - (field->isPrivate() & bool(init) ? - GlobalVariable::InternalLinkage : - GlobalVariable::ExternalLinkage), - init, - className + '/' + field->getName()->str(), - module_); - } - else + if (!field->isStatic()) elements.push_back(getType(field->getDescriptor())); } PATypeHolder holder = newType; @@ -271,6 +256,21 @@ return locals_[index]; } + GlobalVariable* getStaticField(unsigned index) { + ConstantFieldRef* fieldRef = + (ConstantFieldRef*)(cf_->getConstantPool()[index]); + ConstantNameAndType* nameAndType = fieldRef->getNameAndType(); + + std::string globalName = + fieldRef->getClass()->getName()->str() + '/' + + nameAndType->getName()->str(); + + GlobalVariable* global = module_->getGlobalVariable + (globalName, getType(nameAndType->getDescriptor())); + + return global; + } + Function* compileMethodOnly(const std::string& classMethodDesc) { DEBUG(std::cerr << "Compiling method: " << classMethodDesc << '\n'); @@ -315,6 +315,53 @@ return function; } + void emitStaticInitializers(const ClassFile* classfile) { + const Method* method = classfile->getMethod("()V"); + if (!method) + return; + + std::string name = classfile->getThisClass()->getName()->str(); + name += '/'; + name += method->getName()->str(); + name += method->getDescriptor()->str(); + + Function* hook = + module_->getOrInsertFunction("llvm_java_static_init", + Type::VoidTy, 0); + Function* init = + module_->getOrInsertFunction(name, Type::VoidTy, 0); + + // if this is the first time we scheduled this function + // for compilation insert a call to it right before the + // terminator of the only basic block in + // llvm_java_static_init + if (toCompileFunctions_.insert(init)) { + assert(hook->front().getTerminator() && + "llvm_java_static_init should have a terminator!"); + new CallInst(init, "", hook->front().getTerminator()); + // we also create the global variables of this class + const Fields& fields = classfile->getFields(); + for (unsigned i = 0, e = fields.size(); i != e; ++i) { + Field* field = fields[i]; + if (field->isStatic()) { + llvm::Constant* init = NULL; + if (ConstantValueAttribute* cv = + field->getConstantValueAttribute()) + init = getConstant(cv->getValue()); + + new GlobalVariable(getType(field->getDescriptor()), + field->isFinal(), + (field->isPrivate() & bool(init) ? + GlobalVariable::InternalLinkage : + GlobalVariable::ExternalLinkage), + init, + classfile->getThisClass()->getName()->str() + '/' + field->getName()->str(), + module_); + } + } + } + } + std::pair findClassAndMethod(const std::string& classMethodDesc) { unsigned slash = classMethodDesc.find('/'); @@ -322,7 +369,9 @@ std::string methodNameAndDescr = classMethodDesc.substr(slash+1); ClassFile* classfile = ClassFile::getClassFile(className); + emitStaticInitializers(classfile); Method* method = classfile->getMethod(methodNameAndDescr); + if (!method) throw InvocationTargetException( "Method " + methodNameAndDescr + @@ -336,10 +385,22 @@ Function* compileMethod(Module& module, const std::string& classMethodDesc) { module_ = &module; + // initialize the static initializer function + Function* staticInit = + module_->getOrInsertFunction("llvm_java_static_init", + Type::VoidTy, 0); + BasicBlock* staticInitBB = new BasicBlock("entry", staticInit); + new ReturnInst(NULL, staticInitBB); + + // insert an opaque type for java.lang.Object. This is + // defined in runtime.ll c2tMap_.insert(std::make_pair("java/lang/Object", OpaqueType::get())); module.addTypeName("java/lang/Object", c2tMap_["java/lang/Object"]); + + // compile the method requested Function* function = compileMethodOnly(classMethodDesc); + // compile all other methods called by this method recursively for (unsigned i = 0; i != toCompileFunctions_.size(); ++i) { Function* f = toCompileFunctions_[i]; compileMethodOnly(f->getName()); @@ -695,11 +756,13 @@ } void do_getstatic(unsigned bcI, unsigned index) { - assert(0 && "not implemented"); + Value* v = new LoadInst(getStaticField(index), TMP, getBBAt(bcI)); + opStack_.push(v); } void do_putstatic(unsigned bcI, unsigned index) { - assert(0 && "not implemented"); + Value* v = opStack_.top(); opStack_.pop(); + new StoreInst(v, getStaticField(index), getBBAt(bcI)); } void do_getfield(unsigned bcI, unsigned index) { From lattner at cs.uiuc.edu Sat Jul 24 22:24:21 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 24 Jul 2004 22:24:21 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp Message-ID: <200407250324.WAA26727@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveIntervalAnalysis.cpp updated: 1.111 -> 1.112 --- Log message: Add debugging output for joining assignments --- Diffs of the changes: (+5 -0) Index: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp diff -u llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.111 llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.112 --- llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.111 Sat Jul 24 06:44:15 2004 +++ llvm/lib/CodeGen/LiveIntervalAnalysis.cpp Sat Jul 24 22:24:11 2004 @@ -616,6 +616,11 @@ for (unsigned i = 0, e = MBBs.size(); i != e; ++i) joinIntervalsInMachineBB(MBBs[i].second); } + + DEBUG(std::cerr << "*** Register mapping ***\n"); + DEBUG(for (std::map::iterator I = r2rMap_.begin(), + E = r2rMap_.end(); I != E; ++I) + std::cerr << " reg " << I->first << " -> reg " << I->second << "\n";); } /// Return true if the two specified registers belong to different register From lattner at cs.uiuc.edu Sun Jul 25 00:44:03 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 25 Jul 2004 00:44:03 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveInterval.cpp Message-ID: <200407250544.AAA29786@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveInterval.cpp updated: 1.7 -> 1.8 --- Log message: Fix a bug in the range remover --- Diffs of the changes: (+1 -1) Index: llvm/lib/CodeGen/LiveInterval.cpp diff -u llvm/lib/CodeGen/LiveInterval.cpp:1.7 llvm/lib/CodeGen/LiveInterval.cpp:1.8 --- llvm/lib/CodeGen/LiveInterval.cpp:1.7 Sat Jul 24 06:44:15 2004 +++ llvm/lib/CodeGen/LiveInterval.cpp Sun Jul 25 00:43:53 2004 @@ -223,7 +223,7 @@ // Otherwise if the span we are removing is at the end of the LiveRange, // adjust the other way. if (I->end == End) { - I->start = Start; + I->end = Start; return; } From lattner at cs.uiuc.edu Sun Jul 25 00:45:28 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 25 Jul 2004 00:45:28 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp Message-ID: <200407250545.AAA29810@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveIntervalAnalysis.cpp updated: 1.112 -> 1.113 --- Log message: Fix a bug where we incorrectly value numbered the first PHI definition the same as the PHI use. This is not correct as the PHI use value is different depending on which branch is taken. This fixes espresso with aggressive coallescing, and perhaps others. --- Diffs of the changes: (+26 -3) Index: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp diff -u llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.112 llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.113 --- llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.112 Sat Jul 24 22:24:11 2004 +++ llvm/lib/CodeGen/LiveIntervalAnalysis.cpp Sun Jul 25 00:45:18 2004 @@ -393,9 +393,32 @@ DEBUG(std::cerr << "RESULT: " << interval); } else { - // Otherwise, this must be because of phi elimination. In this case, - // the defined value will be live until the end of the basic block it - // is defined in. + // Otherwise, this must be because of phi elimination. If this is the + // first redefinition of the vreg that we have seen, go back and change + // the live range in the PHI block to be a different value number. + if (interval.containsOneValue()) { + assert(vi.Kills.size() == 1 && + "PHI elimination vreg should have one kill, the PHI itself!"); + + // Remove the old range that we now know has an incorrect number. + MachineInstr *Killer = vi.Kills[0]; + unsigned Start = getInstructionIndex(Killer->getParent()->begin()); + unsigned End = getUseIndex(getInstructionIndex(Killer))+1; + DEBUG(std::cerr << "Removing [" << Start << "," << End << "] from: " + << interval << "\n"); + interval.removeRange(Start, End); + DEBUG(std::cerr << "RESULT: " << interval); + + // Replace the interval with one of a NEW value number. + LiveRange LR(Start, End, interval.getNextValue()); + DEBUG(std::cerr << " replace range with " << LR); + interval.addRange(LR); + DEBUG(std::cerr << "RESULT: " << interval); + } + + // In the case of PHI elimination, each variable definition is only + // live until the end of the block. We've already taken care of the + // rest of the live range. unsigned defIndex = getDefIndex(getInstructionIndex(mi)); LiveRange LR(defIndex, getInstructionIndex(&mbb->back()) + InstrSlots::NUM, From alkis at cs.uiuc.edu Sun Jul 25 01:07:25 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sun, 25 Jul 2004 01:07:25 -0500 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Value.cpp Message-ID: <200407250607.BAA11692@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Value.cpp updated: 1.47 -> 1.48 --- Log message: Disallow creation of named values of type void. --- Diffs of the changes: (+2 -0) Index: llvm/lib/VMCore/Value.cpp diff -u llvm/lib/VMCore/Value.cpp:1.47 llvm/lib/VMCore/Value.cpp:1.48 --- llvm/lib/VMCore/Value.cpp:1.47 Sat Jul 17 19:01:50 2004 +++ llvm/lib/VMCore/Value.cpp Sun Jul 25 01:07:15 2004 @@ -36,6 +36,8 @@ assert((Ty->isFirstClassType() || Ty == Type::VoidTy || isa(ty)) && "Cannot create non-first-class values except for constants!"); + if (ty == Type::VoidTy) + assert(name == "" && "Cannot have named void values!"); } Value::~Value() { From alkis at cs.uiuc.edu Sun Jul 25 01:17:02 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sun, 25 Jul 2004 01:17:02 -0500 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Value.cpp Message-ID: <200407250617.BAA11851@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Value.cpp updated: 1.48 -> 1.49 --- Log message: Use name.empty() instead of testing against equality with the empty string. --- Diffs of the changes: (+1 -1) Index: llvm/lib/VMCore/Value.cpp diff -u llvm/lib/VMCore/Value.cpp:1.48 llvm/lib/VMCore/Value.cpp:1.49 --- llvm/lib/VMCore/Value.cpp:1.48 Sun Jul 25 01:07:15 2004 +++ llvm/lib/VMCore/Value.cpp Sun Jul 25 01:16:52 2004 @@ -37,7 +37,7 @@ isa(ty)) && "Cannot create non-first-class values except for constants!"); if (ty == Type::VoidTy) - assert(name == "" && "Cannot have named void values!"); + assert(name.empty() && "Cannot have named void values!"); } Value::~Value() { From lattner at cs.uiuc.edu Sun Jul 25 01:23:11 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 25 Jul 2004 01:23:11 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveInterval.cpp LiveInterval.h Message-ID: <200407250623.BAA13327@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveInterval.cpp updated: 1.8 -> 1.9 LiveInterval.h updated: 1.7 -> 1.8 --- Log message: Make a method const, no functionality changes --- Diffs of the changes: (+6 -6) Index: llvm/lib/CodeGen/LiveInterval.cpp diff -u llvm/lib/CodeGen/LiveInterval.cpp:1.8 llvm/lib/CodeGen/LiveInterval.cpp:1.9 --- llvm/lib/CodeGen/LiveInterval.cpp:1.8 Sun Jul 25 00:43:53 2004 +++ llvm/lib/CodeGen/LiveInterval.cpp Sun Jul 25 01:23:01 2004 @@ -237,10 +237,10 @@ /// getLiveRangeContaining - Return the live range that contains the /// specified index, or null if there is none. -LiveRange *LiveInterval::getLiveRangeContaining(unsigned Idx) { - Ranges::iterator It = std::upper_bound(ranges.begin(), ranges.end(), Idx); +const LiveRange *LiveInterval::getLiveRangeContaining(unsigned Idx) const { + Ranges::const_iterator It = std::upper_bound(ranges.begin(),ranges.end(),Idx); if (It != ranges.begin()) { - LiveRange &LR = *prior(It); + const LiveRange &LR = *prior(It); if (LR.contains(Idx)) return &LR; } @@ -254,8 +254,8 @@ /// is the result of a copy instruction in the source program, that occurs at /// index 'CopyIdx' that copies from 'Other' to 'this'. void LiveInterval::join(LiveInterval &Other, unsigned CopyIdx) { - LiveRange *SourceLR = Other.getLiveRangeContaining(CopyIdx-1); - LiveRange *DestLR = getLiveRangeContaining(CopyIdx); + const LiveRange *SourceLR = Other.getLiveRangeContaining(CopyIdx-1); + const LiveRange *DestLR = getLiveRangeContaining(CopyIdx); assert(SourceLR && DestLR && "Not joining due to a copy?"); unsigned MergedSrcValIdx = SourceLR->ValId; unsigned MergedDstValIdx = DestLR->ValId; Index: llvm/lib/CodeGen/LiveInterval.h diff -u llvm/lib/CodeGen/LiveInterval.h:1.7 llvm/lib/CodeGen/LiveInterval.h:1.8 --- llvm/lib/CodeGen/LiveInterval.h:1.7 Sat Jul 24 13:55:15 2004 +++ llvm/lib/CodeGen/LiveInterval.h Sun Jul 25 01:23:01 2004 @@ -112,7 +112,7 @@ /// getLiveRangeContaining - Return the live range that contains the /// specified index, or null if there is none. - LiveRange *getLiveRangeContaining(unsigned Idx); + const LiveRange *getLiveRangeContaining(unsigned Idx) const; /// joinable - Two intervals are joinable if the either don't overlap at all From lattner at cs.uiuc.edu Sun Jul 25 02:11:29 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 25 Jul 2004 02:11:29 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveInterval.cpp Message-ID: <200407250711.CAA14850@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveInterval.cpp updated: 1.9 -> 1.10 --- Log message: This patch makes use of the infrastructure implemented before to safely and aggressively coallesce live ranges even if they overlap. Consider this LLVM code for example: int %test(int %X) { %Y = mul int %X, 1 ;; Codegens to Y = X %Z = add int %X, %Y ret int %Z } The mul is just there to get a copy into the code stream. This produces this machine code: (0x869e5a8, LLVM BB @0x869b9a0): %reg1024 = mov , 1, %NOREG, 0 ;; "X" %reg1025 = mov %reg1024 ;; "Y" (subsumed by X) %reg1026 = add %reg1024, %reg1025 %EAX = mov %reg1026 ret Note that the life times of reg1024 and reg1025 overlap, even though they contain the same value. This results in this machine code: test: mov %EAX, DWORD PTR [%ESP + 4] mov %ECX, %EAX add %EAX, %ECX ret Another, worse case involves loops and PHI nodes. Consider this trivial loop: testcase: int %test2(int %X) { entry: br label %Loop Loop: %Y = phi int [%X, %entry], [%Z, %Loop] %Z = add int %Y, 1 %cond = seteq int %Z, 100 br bool %cond, label %Out, label %Loop Out: ret int %Z } Because of interactions between the PHI elimination pass and the register allocator, this got compiled to this code: test2: mov %ECX, DWORD PTR [%ESP + 4] .LBBtest2_1: *** mov %EAX, %ECX inc %EAX cmp %EAX, 100 *** mov %ECX, %EAX jne .LBBtest2_1 ret Or on powerpc, this code: _test2: mflr r0 stw r0, 8(r1) stwu r1, -60(r1) .LBB_test2_1: addi r2, r3, 1 cmpwi cr0, r2, 100 *** or r3, r2, r2 bne cr0, .LBB_test2_1 *** or r3, r2, r2 lwz r0, 68(r1) mtlr r0 addi r1, r1, 60 blr 0 With this improvement in place, we now generate this code for these two testcases, which is what we want: test: mov %EAX, DWORD PTR [%ESP + 4] add %EAX, %EAX ret test2: mov %EAX, DWORD PTR [%ESP + 4] .LBBtest2_1: inc %EAX cmp %EAX, 100 jne .LBBtest2_1 # Loop ret Or on PPC: _test2: mflr r0 stw r0, 8(r1) stwu r1, -60(r1) .LBB_test2_1: addi r3, r3, 1 cmpwi cr0, r3, 100 bne cr0, .LBB_test2_1 lwz r0, 68(r1) mtlr r0 addi r1, r1, 60 blr 0 Static numbers for spill code loads/stores/reg-reg copies (smaller is better): em3d: before: 47/25/26 after: 44/22/24 164.gzip: before: 433/245/310 after: 403/231/278 175.vpr: before: 3721/2189/1581 after: 4144/2081/1423 176.gcc: before: 26195/8866/9235 after: 25942/8082/8275 186.crafty: before: 4295/2587/3079 after: 4119/2519/2916 252.eon: before: 12754/7585/5803 after: 12508/7425/5643 256.bzip2: before: 463/226/315 after: 482:241/309 Runtime perf number samples on X86: gzip: before: 41.09 after: 39.86 bzip2: runtime: before: 56.71s after: 57.07s gcc: before: 6.16 after: 6.12 eon: before: 2.03s after: 2.00s --- Diffs of the changes: (+43 -1) Index: llvm/lib/CodeGen/LiveInterval.cpp diff -u llvm/lib/CodeGen/LiveInterval.cpp:1.9 llvm/lib/CodeGen/LiveInterval.cpp:1.10 --- llvm/lib/CodeGen/LiveInterval.cpp:1.9 Sun Jul 25 01:23:01 2004 +++ llvm/lib/CodeGen/LiveInterval.cpp Sun Jul 25 02:11:19 2004 @@ -60,6 +60,7 @@ Ranges::const_iterator ie = ranges.end(); Ranges::const_iterator j = other.ranges.begin(); Ranges::const_iterator je = other.ranges.end(); + if (i->start < j->start) { i = std::upper_bound(i, ie, j->start); if (i != ranges.begin()) --i; @@ -92,7 +93,48 @@ /// or if the destination of the copy is a single assignment value, and it /// only overlaps with one value in the source interval. bool LiveInterval::joinable(const LiveInterval &other, unsigned CopyIdx) const { - return overlaps(other); + const LiveRange *SourceLR = other.getLiveRangeContaining(CopyIdx-1); + const LiveRange *DestLR = getLiveRangeContaining(CopyIdx); + assert(SourceLR && DestLR && "Not joining due to a copy?"); + unsigned OtherValIdx = SourceLR->ValId; + unsigned ThisValIdx = DestLR->ValId; + + Ranges::const_iterator i = ranges.begin(); + Ranges::const_iterator ie = ranges.end(); + Ranges::const_iterator j = other.ranges.begin(); + Ranges::const_iterator je = other.ranges.end(); + + if (i->start < j->start) { + i = std::upper_bound(i, ie, j->start); + if (i != ranges.begin()) --i; + } else if (j->start < i->start) { + j = std::upper_bound(j, je, i->start); + if (j != other.ranges.begin()) --j; + } + + while (i != ie && j != je) { + if (i->start == j->start) { + // If this is not the allowed value merge, we cannot join. + if (i->ValId != ThisValIdx || j->ValId != OtherValIdx) + return true; + } else if (i->start < j->start) { + if (i->end > j->start) { + if (i->ValId != ThisValIdx || j->ValId != OtherValIdx) + return true; + } + } else { + if (j->end > i->start) { + if (i->ValId != ThisValIdx || j->ValId != OtherValIdx) + return true; + } + } + if (i->end < j->end) + ++i; + else + ++j; + } + + return false; } From lattner at cs.uiuc.edu Sun Jul 25 02:34:11 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 25 Jul 2004 02:34:11 -0500 Subject: [llvm-commits] CVS: llvm/lib/Support/SystemUtils.cpp Message-ID: <200407250734.CAA15237@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Support: SystemUtils.cpp updated: 1.32 -> 1.33 --- Log message: Remove linux/solaris specific stuff. --- Diffs of the changes: (+3 -1) Index: llvm/lib/Support/SystemUtils.cpp diff -u llvm/lib/Support/SystemUtils.cpp:1.32 llvm/lib/Support/SystemUtils.cpp:1.33 --- llvm/lib/Support/SystemUtils.cpp:1.32 Sat Jul 24 02:50:48 2004 +++ llvm/lib/Support/SystemUtils.cpp Sun Jul 25 02:34:00 2004 @@ -27,6 +27,7 @@ #include #include #include +#include using namespace llvm; /// isExecutableFile - This function returns true if the filename specified @@ -174,7 +175,8 @@ struct sigaction Act, Old; Act.sa_sigaction = 0; Act.sa_handler = TimeOutHandler; - Act.sa_flags = SA_NOMASK; + sigemptyset(&Act.sa_mask); + Act.sa_flags = 0; sigaction(SIGALRM, &Act, &Old); // Set the timeout if one is set. From lattner at cs.uiuc.edu Sun Jul 25 02:47:35 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 25 Jul 2004 02:47:35 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveInterval.cpp LiveIntervalAnalysis.cpp Message-ID: <200407250747.CAA23648@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveInterval.cpp updated: 1.10 -> 1.11 LiveIntervalAnalysis.cpp updated: 1.113 -> 1.114 --- Log message: Fix the sense of joinable --- Diffs of the changes: (+5 -5) Index: llvm/lib/CodeGen/LiveInterval.cpp diff -u llvm/lib/CodeGen/LiveInterval.cpp:1.10 llvm/lib/CodeGen/LiveInterval.cpp:1.11 --- llvm/lib/CodeGen/LiveInterval.cpp:1.10 Sun Jul 25 02:11:19 2004 +++ llvm/lib/CodeGen/LiveInterval.cpp Sun Jul 25 02:47:25 2004 @@ -116,16 +116,16 @@ if (i->start == j->start) { // If this is not the allowed value merge, we cannot join. if (i->ValId != ThisValIdx || j->ValId != OtherValIdx) - return true; + return false; } else if (i->start < j->start) { if (i->end > j->start) { if (i->ValId != ThisValIdx || j->ValId != OtherValIdx) - return true; + return false; } } else { if (j->end > i->start) { if (i->ValId != ThisValIdx || j->ValId != OtherValIdx) - return true; + return false; } } if (i->end < j->end) @@ -134,7 +134,7 @@ ++j; } - return false; + return true; } Index: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp diff -u llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.113 llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.114 --- llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.113 Sun Jul 25 00:45:18 2004 +++ llvm/lib/CodeGen/LiveIntervalAnalysis.cpp Sun Jul 25 02:47:25 2004 @@ -577,7 +577,7 @@ IntA.containsOneValue() && IntB.containsOneValue(); unsigned MIDefIdx = getDefIndex(getInstructionIndex(mi)); - if ((TriviallyJoinable || !IntB.joinable(IntA, MIDefIdx)) && + if ((TriviallyJoinable || IntB.joinable(IntA, MIDefIdx)) && !overlapsAliases(&IntA, &IntB)) { IntB.join(IntA, MIDefIdx); From lattner at cs.uiuc.edu Sun Jul 25 02:57:32 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 25 Jul 2004 02:57:32 -0500 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/AliasSetTracker.h Message-ID: <200407250757.CAA25059@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis: AliasSetTracker.h updated: 1.16 -> 1.17 --- Log message: Add support for free instructions --- Diffs of the changes: (+3 -0) Index: llvm/include/llvm/Analysis/AliasSetTracker.h diff -u llvm/include/llvm/Analysis/AliasSetTracker.h:1.16 llvm/include/llvm/Analysis/AliasSetTracker.h:1.17 --- llvm/include/llvm/Analysis/AliasSetTracker.h:1.16 Thu Jul 22 02:58:14 2004 +++ llvm/include/llvm/Analysis/AliasSetTracker.h Sun Jul 25 02:57:21 2004 @@ -27,6 +27,7 @@ class AliasAnalysis; class LoadInst; class StoreInst; +class FreeInst; class AliasSetTracker; class AliasSet; @@ -263,6 +264,7 @@ /// bool add(LoadInst *LI); bool add(StoreInst *SI); + bool add(FreeInst *FI); bool add(CallSite CS); // Call/Invoke instructions bool add(CallInst *CI) { return add(CallSite(CI)); } bool add(InvokeInst *II) { return add(CallSite(II)); } @@ -275,6 +277,7 @@ /// alias sets were eliminated. bool remove(LoadInst *LI); bool remove(StoreInst *SI); + bool remove(FreeInst *FI); bool remove(CallSite CS); bool remove(CallInst *CI) { return remove(CallSite(CI)); } bool remove(InvokeInst *II) { return remove(CallSite(II)); } From lattner at cs.uiuc.edu Sun Jul 25 02:57:47 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 25 Jul 2004 02:57:47 -0500 Subject: [llvm-commits] CVS: llvm/lib/Analysis/AliasSetTracker.cpp Message-ID: <200407250757.CAA25071@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: AliasSetTracker.cpp updated: 1.20 -> 1.21 --- Log message: Add support for free instructions --- Diffs of the changes: (+18 -2) Index: llvm/lib/Analysis/AliasSetTracker.cpp diff -u llvm/lib/Analysis/AliasSetTracker.cpp:1.20 llvm/lib/Analysis/AliasSetTracker.cpp:1.21 --- llvm/lib/Analysis/AliasSetTracker.cpp:1.20 Thu Jul 22 02:58:18 2004 +++ llvm/lib/Analysis/AliasSetTracker.cpp Sun Jul 25 02:57:37 2004 @@ -233,6 +233,13 @@ return NewPtr; } +bool AliasSetTracker::add(FreeInst *FI) { + bool NewPtr; + AliasSet &AS = addPointer(FI->getOperand(0), ~0, + AliasSet::Mods, NewPtr); + return NewPtr; +} + bool AliasSetTracker::add(CallSite CS) { bool NewPtr; @@ -262,6 +269,8 @@ return add(CI); else if (InvokeInst *II = dyn_cast(I)) return add(II); + else if (FreeInst *FI = dyn_cast(I)) + return add(FI); return true; } @@ -326,6 +335,13 @@ return true; } +bool AliasSetTracker::remove(FreeInst *FI) { + AliasSet *AS = findAliasSetForPointer(FI->getOperand(0), ~0); + if (!AS) return false; + remove(*AS); + return true; +} + bool AliasSetTracker::remove(CallSite CS) { if (Function *F = CS.getCalledFunction()) if (AA.doesNotAccessMemory(F)) @@ -345,8 +361,8 @@ return remove(SI); else if (CallInst *CI = dyn_cast(I)) return remove(CI); - else if (InvokeInst *II = dyn_cast(I)) - return remove(II); + else if (FreeInst *FI = dyn_cast(I)) + return remove(FI); return true; } From lattner at cs.uiuc.edu Sun Jul 25 02:58:00 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 25 Jul 2004 02:58:00 -0500 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/DeadStoreElimination/free.llx Message-ID: <200407250758.CAA25081@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/DeadStoreElimination: free.llx added (r1.1) --- Log message: New testcase for DSE --- Diffs of the changes: (+8 -0) Index: llvm/test/Regression/Transforms/DeadStoreElimination/free.llx diff -c /dev/null llvm/test/Regression/Transforms/DeadStoreElimination/free.llx:1.1 *** /dev/null Sun Jul 25 02:58:00 2004 --- llvm/test/Regression/Transforms/DeadStoreElimination/free.llx Sun Jul 25 02:57:50 2004 *************** *** 0 **** --- 1,8 ---- + ; RUN: llvm-as < %s | opt -dse | llvm-dis | not grep DEAD + + void %test(int* %Q, int* %P) { + %DEAD = load int* %Q + store int %DEAD, int* %P + free int* %P + ret void + } From lattner at cs.uiuc.edu Sun Jul 25 02:58:49 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 25 Jul 2004 02:58:49 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp Message-ID: <200407250758.CAA25092@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: DeadStoreElimination.cpp updated: 1.2 -> 1.3 --- Log message: Free instructions kill values too. This implements DeadStoreElim/free.llx --- Diffs of the changes: (+13 -4) Index: llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp diff -u llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp:1.2 llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp:1.3 --- llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp:1.2 Sat Jul 24 02:51:27 2004 +++ llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp Sun Jul 25 02:58:38 2004 @@ -79,7 +79,8 @@ } #endif - if (!isa(I) || cast(I)->isVolatile()) { + if (!isa(I) && + (!isa(I) || cast(I)->isVolatile())) { // If this is a non-store instruction, it makes everything referenced no // longer killed. Remove anything aliased from the alias set tracker. KillLocs.remove(I); @@ -90,8 +91,16 @@ // the stored location is already in the tracker, then this is a dead // store. We can just delete it here, but while we're at it, we also // delete any trivially dead expression chains. - unsigned ValSize = TD.getTypeSize(I->getOperand(0)->getType()); - Value *Ptr = I->getOperand(1); + unsigned ValSize; + Value *Ptr; + if (isa(I)) { + Ptr = I->getOperand(1); + ValSize = TD.getTypeSize(I->getOperand(0)->getType()); + } else { + Ptr = I->getOperand(0); + ValSize = ~0; + } + if (AliasSet *AS = KillLocs.getAliasSetForPointerIfExists(Ptr, ValSize)) for (AliasSet::iterator ASI = AS->begin(), E = AS->end(); ASI != E; ++ASI) if (AA.alias(ASI.getPointer(), ASI.getSize(), Ptr, ValSize) @@ -110,7 +119,7 @@ // Otherwise, this is a non-dead store just add it to the set of dead // locations. - KillLocs.add(cast(I)); + KillLocs.add(I); BigContinue:; } return MadeChange; From alkis at cs.uiuc.edu Sun Jul 25 03:10:43 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sun, 25 Jul 2004 03:10:43 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/RegAllocLinearScan.cpp Message-ID: <200407250810.DAA03364@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: RegAllocLinearScan.cpp updated: 1.85 -> 1.86 --- Log message: Add some comments to the backtracking code. --- Diffs of the changes: (+17 -2) Index: llvm/lib/CodeGen/RegAllocLinearScan.cpp diff -u llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.85 llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.86 --- llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.85 Sat Jul 24 06:44:15 2004 +++ llvm/lib/CodeGen/RegAllocLinearScan.cpp Sun Jul 25 03:10:33 2004 @@ -403,13 +403,24 @@ assert(MRegisterInfo::isPhysicalRegister(minReg) && "did not choose a register to spill?"); std::vector toSpill(mri_->getNumRegs(), false); + // we are going to spill minReg and all its aliases toSpill[minReg] = true; for (const unsigned* as = mri_->getAliasSet(minReg); *as; ++as) toSpill[*as] = true; + + // the earliest start of a spilled interval indicates up to where + // in handled we need to roll back unsigned earliestStart = cur->start(); + // set of spilled vregs (used later to rollback properly) std::set spilled; + // spill live intervals of virtual regs mapped to the physical + // register we want to clear (and its aliases). we only spill + // those that overlap with the current interval as the rest do not + // affect its allocation. we also keep track of the earliest start + // of all spilled live intervals since this will mark our rollback + // point for (IntervalPtrs::iterator i = active_.begin(); i != active_.end(); ++i) { unsigned reg = (*i)->reg; @@ -442,8 +453,9 @@ } DEBUG(std::cerr << "\t\trolling back to: " << earliestStart << '\n'); - // scan handled in reverse order and undo each one, restoring the - // state of unhandled + // scan handled in reverse order up to the earliaset start of a + // spilled live interval and undo each one, restoring the state of + // unhandled while (!handled_.empty()) { LiveInterval* i = handled_.back(); // if this interval starts before t we are done @@ -451,6 +463,9 @@ break; DEBUG(std::cerr << "\t\t\tundo changes for: " << *i << '\n'); handled_.pop_back(); + // when undoing a live interval allocation we must know if it + // is active or inactive to properly update the PhysRegTracker + // and the VirtRegMap IntervalPtrs::iterator it; if ((it = find(active_.begin(), active_.end(), i)) != active_.end()) { active_.erase(it); From alkis at cs.uiuc.edu Sun Jul 25 05:32:23 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sun, 25 Jul 2004 05:32:23 -0500 Subject: [llvm-commits] CVS: llvm-java/test/Programs/SingleSource/UnitTests/FieldAccess.java Message-ID: <200407251032.FAA19228@zion.cs.uiuc.edu> Changes in directory llvm-java/test/Programs/SingleSource/UnitTests: FieldAccess.java added (r1.1) --- Log message: New test case --- Diffs of the changes: (+21 -0) Index: llvm-java/test/Programs/SingleSource/UnitTests/FieldAccess.java diff -c /dev/null llvm-java/test/Programs/SingleSource/UnitTests/FieldAccess.java:1.1 *** /dev/null Sun Jul 25 05:32:23 2004 --- llvm-java/test/Programs/SingleSource/UnitTests/FieldAccess.java Sun Jul 25 05:32:13 2004 *************** *** 0 **** --- 1,21 ---- + class A { + int i; + float f; + } + + class B extends A { + int i; + double d; + } + + public class FieldAccess + { + public static void main(String[] args) { + B b = null; + b.d = 4.0; + b.i = 3; + b.f = 2.0F; + ((A) b).i = 4; + ((A) b).f = 1.0F; + } + } From alkis at cs.uiuc.edu Sun Jul 25 05:37:39 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sun, 25 Jul 2004 05:37:39 -0500 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp Message-ID: <200407251037.FAA19367@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Compiler.cpp updated: 1.69 -> 1.70 --- Log message: Implement getfield and putfield java opcodes. --- Diffs of the changes: (+68 -18) Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.69 llvm-java/lib/Compiler/Compiler.cpp:1.70 --- llvm-java/lib/Compiler/Compiler.cpp:1.69 Sat Jul 24 18:55:54 2004 +++ llvm-java/lib/Compiler/Compiler.cpp Sun Jul 25 05:37:29 2004 @@ -142,8 +142,14 @@ BasicBlock* prologue_; typedef SetVector FunctionSet; FunctionSet toCompileFunctions_; - typedef std::map Class2TypeMap; - Class2TypeMap c2tMap_; + struct ClassInfo { + explicit ClassInfo(Type* t) : type(t) { } + Type* type; + typedef std::map Field2IndexMap; + Field2IndexMap f2iMap; + }; + typedef std::map Class2InfoMap; + Class2InfoMap c2ciMap_; private: BasicBlock* getBBAt(unsigned bcI) { return bc2bbMap_[bcI]; } @@ -152,7 +158,7 @@ Type* getType(JType type) { switch (type) { case REFERENCE: - return PointerType::get(getTypeForClass("java/lang/Object")); + return PointerType::get(getClassInfo("java/lang/Object").type); case BOOLEAN: return Type::BoolTy; case CHAR: return Type::UShortTy; case FLOAT: return Type::FloatTy; @@ -201,7 +207,7 @@ unsigned e = descr.find(';', i); std::string className = descr.substr(i, e - i); i = e + 1; - return PointerType::get(getTypeForClass(className)); + return PointerType::get(getClassInfo(className).type); } case '[': // FIXME: this should really be a new class @@ -220,28 +226,33 @@ } } - Type* getTypeForClass(const std::string& className) { - Class2TypeMap::iterator it = c2tMap_.lower_bound(className); - if (it == c2tMap_.end() || it->first != className) { + ClassInfo& getClassInfo(const std::string& className) { + Class2InfoMap::iterator it = c2ciMap_.lower_bound(className); + if (it == c2ciMap_.end() || it->first != className) { ClassFile* cf = ClassFile::getClassFile(className); OpaqueType* newType = OpaqueType::get(); - it = c2tMap_.insert(it, std::make_pair(className, newType)); + it = c2ciMap_.insert(it, std::make_pair(className, + ClassInfo(newType))); std::vector elements; if (ConstantClass* super = cf->getSuperClass()) elements.push_back - (getTypeForClass(super->getName()->str())); + (getClassInfo(super->getName()->str()).type); const Fields& fields = cf->getFields(); for (unsigned i = 0, e = fields.size(); i != e; ++i) { Field* field = fields[i]; - if (!field->isStatic()) + if (!field->isStatic()) { + it->second.f2iMap.insert( + std::make_pair(field->getName()->str(), + elements.size())); elements.push_back(getType(field->getDescriptor())); + } } PATypeHolder holder = newType; newType->refineAbstractTypeTo(StructType::get(elements)); - it->second = holder.get(); + it->second.type = holder.get(); DEBUG(std::cerr << "Adding " << className << " = " - << *it->second << " to type map\n"); - module_->addTypeName(className, it->second); + << *it->second.type << " to type map\n"); + module_->addTypeName(className, it->second.type); } return it->second; } @@ -271,6 +282,40 @@ return global; } + Value* getField(unsigned bcI, unsigned index, Value* ptr) { + ConstantFieldRef* fieldRef = + (ConstantFieldRef*)(cf_->getConstantPool()[index]); + ConstantNameAndType* nameAndType = fieldRef->getNameAndType(); + + // Cast ptr to correct type + std::string className = fieldRef->getClass()->getName()->str(); + ptr = new CastInst(ptr, + PointerType::get(getClassInfo(className).type), + TMP, getBBAt(bcI)); + ClassFile* classfile = ClassFile::getClassFile(className); + std::string fieldName = nameAndType->getName()->str(); + + // deref pointer + std::vector indices(1, ConstantUInt::get(Type::UIntTy, 0)); + while (true) { + ClassInfo& info = getClassInfo(className); + ClassInfo::Field2IndexMap::iterator it = + info.f2iMap.find(fieldName); + if (it == info.f2iMap.end()) { + className = classfile->getSuperClass()->getName()->str(); + classfile = ClassFile::getClassFile(className); + indices.push_back(ConstantUInt::get(Type::UIntTy, 0)); + } + else { + indices.push_back(ConstantUInt::get(Type::UIntTy, + it->second)); + break; + } + } + + return new GetElementPtrInst(ptr, indices, TMP, getBBAt(bcI)); + } + Function* compileMethodOnly(const std::string& classMethodDesc) { DEBUG(std::cerr << "Compiling method: " << classMethodDesc << '\n'); @@ -394,9 +439,10 @@ // insert an opaque type for java.lang.Object. This is // defined in runtime.ll - c2tMap_.insert(std::make_pair("java/lang/Object", - OpaqueType::get())); - module.addTypeName("java/lang/Object", c2tMap_["java/lang/Object"]); + c2ciMap_.insert(std::make_pair("java/lang/Object", + ClassInfo(OpaqueType::get()))); + module.addTypeName("java/lang/Object", + getClassInfo("java/lang/Object").type); // compile the method requested Function* function = compileMethodOnly(classMethodDesc); @@ -766,11 +812,15 @@ } void do_getfield(unsigned bcI, unsigned index) { - assert(0 && "not implemented"); + Value* p = opStack_.top(); opStack_.pop(); + Value* v = new LoadInst(getField(bcI, index, p), TMP, getBBAt(bcI)); + opStack_.push(v); } void do_putfield(unsigned bcI, unsigned index) { - assert(0 && "not implemented"); + Value* v = opStack_.top(); opStack_.pop(); + Value* p = opStack_.top(); opStack_.pop(); + new StoreInst(v, getField(bcI, index, p), getBBAt(bcI)); } void do_invokevirtual(unsigned bcI, unsigned index) { From lattner at cs.uiuc.edu Sun Jul 25 06:07:17 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 25 Jul 2004 06:07:17 -0500 Subject: [llvm-commits] CVS: llvm/include/Support/SetVector.h Message-ID: <200407251107.GAA03441@apoc.cs.uiuc.edu> Changes in directory llvm/include/Support: SetVector.h updated: 1.3 -> 1.4 --- Log message: Add back() and pop_back() methods to SetVector Move clear to the end of the class Add assertions --- Diffs of the changes: (+28 -14) Index: llvm/include/Support/SetVector.h diff -u llvm/include/Support/SetVector.h:1.3 llvm/include/Support/SetVector.h:1.4 --- llvm/include/Support/SetVector.h:1.3 Thu Jul 15 03:18:31 2004 +++ llvm/include/Support/SetVector.h Sun Jul 25 06:07:02 2004 @@ -19,6 +19,7 @@ #include #include +#include namespace llvm { @@ -44,16 +45,10 @@ /// @brief Initialize a SetVector with a range of elements template - SetVector( It Start, It End ) { + SetVector(It Start, It End) { insert(Start, End); } - /// @brief Completely clear the SetVector - void clear() { - set_.clear(); - vector_.clear(); - } - /// @brief Determine if the SetVector is empty or not. bool empty() const { return vector_.empty(); @@ -84,35 +79,54 @@ return vector_.end(); } + /// @brief Return the last element of the SetVector. + const T &back() const { + assert(!empty() && "Cannot call back() on empty SetVector!"); + return vector_.back(); + } + /// @brief Index into the SetVector. const_reference operator[](size_type n) const { - return vector_[n]; + assert(n < vector_.size() && "SetVector access out of range!"); + return vector_[n]; } /// @returns true iff the element was inserted into the SetVector. /// @brief Insert a new element into the SetVector. - bool insert( const value_type& X ) { + bool insert(const value_type &X) { bool result = set_.insert(X).second; - if ( result ) { + if (result) vector_.push_back(X); - } return result; } /// @brief Insert a range of elements into the SetVector. template - void insert( It Start, It End ) { + void insert(It Start, It End) { for (; Start != End; ++Start) - if ( set_.insert(*Start).second ) + if (set_.insert(*Start).second) vector_.push_back(*Start); } /// @returns 0 if the element is not in the SetVector, 1 if it is. /// @brief Count the number of elements of a given key in the SetVector. - size_type count( const key_type& key ) const { + size_type count(const key_type &key) const { return set_.count(key); } + /// @brief Completely clear the SetVector + void clear() { + set_.clear(); + vector_.clear(); + } + + /// @brief Remove the last element of the SetVector. + void pop_back() { + assert(!empty() && "Cannot remove an element from an empty SetVector!"); + set_.erase(back()); + vector_.pop_back(); + } + private: set_type set_; ///< The set. vector_type vector_; ///< The vector. From lattner at cs.uiuc.edu Sun Jul 25 06:10:06 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 25 Jul 2004 06:10:06 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp Message-ID: <200407251110.GAA03578@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: DeadStoreElimination.cpp updated: 1.3 -> 1.4 --- Log message: * Substantially simplify how free instructions are handled (potentially fixing a bug in DSE). * Delete dead operand uses iteratively instead of recursively, using a SetVector. * Defer deletion of dead operand uses until the end of processing, which means we don't have to bother with updating the AliasSetTracker. This speeds up DSE substantially. --- Diffs of the changes: (+52 -43) Index: llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp diff -u llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp:1.3 llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp:1.4 --- llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp:1.3 Sun Jul 25 02:58:38 2004 +++ llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp Sun Jul 25 06:09:56 2004 @@ -22,6 +22,7 @@ #include "llvm/Analysis/AliasSetTracker.h" #include "llvm/Target/TargetData.h" #include "llvm/Transforms/Utils/Local.h" +#include "Support/SetVector.h" #include "Support/Statistic.h" using namespace llvm; @@ -40,7 +41,8 @@ bool runOnBasicBlock(BasicBlock &BB); - void DeleteDeadValueChains(Value *V, AliasSetTracker &AST); + void DeleteDeadInstructionChains(Instruction *I, + SetVector &DeadInsts); // getAnalysisUsage - We require post dominance frontiers (aka Control // Dependence Graph) @@ -67,20 +69,24 @@ } + // PotentiallyDeadInsts - Deleting dead stores from the program can make other + // instructions die if they were only used as operands to stores. Keep track + // of the operands to stores so that we can try deleting them at the end of + // the traversal. + SetVector PotentiallyDeadInsts; + bool MadeChange = false; for (BasicBlock::iterator BBI = BB.end(); BBI != BB.begin(); ) { Instruction *I = --BBI; // Keep moving iterator backwards -#if 0 - // AST doesn't support malloc/free/alloca??? - if (isa(I)) { + // If this is a free instruction, it makes the free'd location dead! + if (FreeInst *FI = dyn_cast(I)) { // Free instructions make any stores to the free'd location dead. - KillLocs.insert(I); + KillLocs.add(FI); + continue; } -#endif - if (!isa(I) && - (!isa(I) || cast(I)->isVolatile())) { + if (!isa(I) || cast(I)->isVolatile()) { // If this is a non-store instruction, it makes everything referenced no // longer killed. Remove anything aliased from the alias set tracker. KillLocs.remove(I); @@ -91,59 +97,62 @@ // the stored location is already in the tracker, then this is a dead // store. We can just delete it here, but while we're at it, we also // delete any trivially dead expression chains. - unsigned ValSize; - Value *Ptr; - if (isa(I)) { - Ptr = I->getOperand(1); - ValSize = TD.getTypeSize(I->getOperand(0)->getType()); - } else { - Ptr = I->getOperand(0); - ValSize = ~0; - } + unsigned ValSize = TD.getTypeSize(I->getOperand(0)->getType()); + Value *Ptr = I->getOperand(1); if (AliasSet *AS = KillLocs.getAliasSetForPointerIfExists(Ptr, ValSize)) for (AliasSet::iterator ASI = AS->begin(), E = AS->end(); ASI != E; ++ASI) if (AA.alias(ASI.getPointer(), ASI.getSize(), Ptr, ValSize) == AliasAnalysis::MustAlias) { // If we found a must alias in the killed set, then this store really - // is dead. Delete it now. + // is dead. Remember that the various operands of the store now have + // fewer users. At the end we will see if we can delete any values + // that are dead as part of the store becoming dead. + if (Instruction *Op = dyn_cast(I->getOperand(0))) + PotentiallyDeadInsts.insert(Op); + if (Instruction *Op = dyn_cast(Ptr)) + PotentiallyDeadInsts.insert(Op); + + // Delete it now. ++BBI; // Don't invalidate iterator. - Value *Val = I->getOperand(0); BB.getInstList().erase(I); // Nuke the store! ++NumStores; - DeleteDeadValueChains(Val, KillLocs); // Delete any now-dead instrs - DeleteDeadValueChains(Ptr, KillLocs); // Delete any now-dead instrs MadeChange = true; goto BigContinue; } // Otherwise, this is a non-dead store just add it to the set of dead // locations. - KillLocs.add(I); + KillLocs.add(cast(I)); BigContinue:; } + + while (!PotentiallyDeadInsts.empty()) { + Instruction *I = PotentiallyDeadInsts.back(); + PotentiallyDeadInsts.pop_back(); + DeleteDeadInstructionChains(I, PotentiallyDeadInsts); + } return MadeChange; } -void DSE::DeleteDeadValueChains(Value *V, AliasSetTracker &AST) { - // Value must be dead. - if (!V->use_empty()) return; - - if (Instruction *I = dyn_cast(V)) - if (isInstructionTriviallyDead(I)) { - AST.deleteValue(I); - getAnalysis().deleteValue(I); - - // See if this made any operands dead. We do it this way in case the - // instruction uses the same operand twice. We don't want to delete a - // value then reference it. - while (unsigned NumOps = I->getNumOperands()) { - Value *Op = I->getOperand(NumOps-1); - I->op_erase(I->op_end()-1); // Drop from the operand list. - DeleteDeadValueChains(Op, AST); // Attempt to nuke it. - } - - I->getParent()->getInstList().erase(I); - ++NumOther; - } +void DSE::DeleteDeadInstructionChains(Instruction *I, + SetVector &DeadInsts) { + // Instruction must be dead. + if (!I->use_empty() || !isInstructionTriviallyDead(I)) return; + + // Let the alias analysis know that we have nuked a value. + getAnalysis().deleteValue(I); + + // See if this made any operands dead. We do it this way in case the + // instruction uses the same operand twice. We don't want to delete a + // value then reference it. + while (unsigned NumOps = I->getNumOperands()) { + Instruction *Op = dyn_cast(I->getOperand(NumOps-1)); + I->op_erase(I->op_end()-1); // Drop from the operand list. + + if (Op) DeadInsts.insert(Op); // Attempt to nuke it later. + } + + I->getParent()->getInstList().erase(I); + ++NumOther; } From lattner at cs.uiuc.edu Sun Jul 25 07:13:45 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 25 Jul 2004 07:13:45 -0500 Subject: [llvm-commits] CVS: llvm/test/Regression/TableGen/TargetInstrInfo.td Message-ID: <200407251213.HAA03727@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/TableGen: TargetInstrInfo.td added (r1.1) --- Log message: Codify my thoughts on where we want to end up with the target-independent code generator. Comments welcome. --- Diffs of the changes: (+148 -0) Index: llvm/test/Regression/TableGen/TargetInstrInfo.td diff -c /dev/null llvm/test/Regression/TableGen/TargetInstrInfo.td:1.1 *** /dev/null Sun Jul 25 07:13:45 2004 --- llvm/test/Regression/TableGen/TargetInstrInfo.td Sun Jul 25 07:13:35 2004 *************** *** 0 **** --- 1,148 ---- + // This test describes how we eventually want to describe instructions in + // the target independent code generators. + // RUN: tblgen %s + + // Target indep stuff. + class Instruction { // Would have other stuff eventually + bit isTwoAddress = 0; + string AssemblyString; + } + class RegisterClass; + + class RTLNode; + + def ops; // Marker for operand list. + + // Various expressions used in RTL descriptions. + def imm8 : RTLNode; + def imm32 : RTLNode; + def addr : RTLNode; + + def set : RTLNode; + def signext : RTLNode; + def zeroext : RTLNode; + def plus : RTLNode; + def and : RTLNode; + def xor : RTLNode; + def shl : RTLNode; + def load : RTLNode; + def store : RTLNode; + def unspec : RTLNode; + + // Start of X86 specific stuff. + + def R8 : RegisterClass; + def R16 : RegisterClass; + def R32 : RegisterClass; + + def CL; // As are currently defined + def AL; + def AX; + def EDX; + + class Format val> { + bits<5> Value = val; + } + + def Pseudo : Format<0>; def RawFrm : Format<1>; + def AddRegFrm : Format<2>; def MRMDestReg : Format<3>; + def MRMDestMem : Format<4>; def MRMSrcReg : Format<5>; + def MRMSrcMem : Format<6>; + def MRM0r : Format<16>; def MRM1r : Format<17>; def MRM2r : Format<18>; + def MRM3r : Format<19>; def MRM4r : Format<20>; def MRM5r : Format<21>; + def MRM6r : Format<22>; def MRM7r : Format<23>; + def MRM0m : Format<24>; def MRM1m : Format<25>; def MRM2m : Format<26>; + def MRM3m : Format<27>; def MRM4m : Format<28>; def MRM5m : Format<29>; + def MRM6m : Format<30>; def MRM7m : Format<31>; + + + class Inst opcode, + Format f, list rtl> : Instruction { + dag Operands = opnds; + string AssemblyString = asmstr; + bits<8> Opcode = opcode; + Format Format = f; + list RTL = rtl; + } + + + // Start of instruction definitions, the real point of this file. + // + // Note that these patterns show a couple of important things: + // 1. The order and contents of the operands of the MachineInstr are + // described here. Eventually we can do away with this when everything + // is generated from the description. + // 2. The asm string is captured here, which makes it possible to get rid of + // a ton of hacks in the various printers and a bunch of flags. + // 3. Target specific properties (e.g. Format) can still be captured as + // needed. + // 4. We capture the behavior of the instruction with a simplified RTL-like + // expression. + // 5. The use/def properties for each operand are automatically inferred from + // the pattern. + // 6. Address expressions should become first-class entities. + + // Simple copy instruction. isMoveInstr could easily be inferred from this, + // as could MRegisterInfo::copyRegToReg. + def MOV8rr : Inst<(ops R8:$dst, R8:$src), + "mov $dst, $src", 0x88, MRMDestReg, + [(set R8:$dst, R8:$src)]>; + + // Simple immediate initialization. + def MOV8ri : Inst<(ops R8:$dst, imm8:$src), + "mov $dst, $src", 0xB0, AddRegFrm, + [(set R8:$dst, imm8:$src)]>; + + // Two address instructions are described as three-addr instructions, with + // the special target-independent isTwoAddress flag set. The asm pattern + // should not refer to the $src1, this would be enforced by the + // TargetInstrInfo tablegen backend. + let isTwoAddress = 1 in + def AND8rr : Inst<(ops R8:$dst, R8:$src1, R8:$src2), + "and $dst, $src2", 0x20, MRMDestReg, + [(set R8:$dst, (and R8:$src1, R8:$src2))]>; + + // Instructions that have explicit uses/defs make them explicit in the RTL. + // Instructions that need extra stuff emitted in the assembly can, trivially. + let isTwoAddress = 1 in + def SHL32rCL : Inst<(ops R32:$dst, R32:$src), + "shl $dst, CL", 0xD2, MRM4r, + [(set R32:$dst, (shl R32:$src, CL))]>; + + // The RTL list is a list, allowing complex instructions to be defined easily. + // Temporary 'internal' registers can be used to break instructions appart. + let isTwoAddress = 1 in + def XOR32mi : Inst<(ops addr:$addr, imm32:$imm), + "xor $dst, $src2", 0x81, MRM6m, + [(set R32:$tmp1, (load addr:$addr)), + (set R32:$tmp2, (xor R32:$tmp1, imm32:$imm)), + (store addr:$addr, R32:$tmp2)]>; + + // Alternatively, if each tmporary register is only used once, the instruction + // can just be described in nested form. This would be the canonical + // representation the target generator would convert the above into. Pick your + // favorite indentation scheme. + let isTwoAddress = 1 in + def AND32mr : Inst<(ops addr:$addr, R32:$src), + "xor $dst, $src2", 0x81, MRM6m, + [(store addr:$addr, + (and + (load addr:$addr), + R32:$src) + ) + ]>; + + // Describing complex instructions is not too hard! Note how implicit uses/defs + // become explicit here. + def CBW : Inst<(ops), + "cbw", 0x98, RawFrm, + [(set AX, (signext AL))]>; + + // Noop, does nothing. + def NOOP : Inst<(ops), "nop", 0x90, RawFrm, []>; + + + // Instructions that don't expect optimization can use unspec. + def IN8rr : Inst<(ops), "in AL, EDX", 0xEC, RawFrm, + [(set AL, (unspec EDX))]>; + From llvm at cs.uiuc.edu Sun Jul 25 12:50:10 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun, 25 Jul 2004 12:50:10 -0500 Subject: [llvm-commits] CVS: llvm/include/llvm/Bytecode/Format.h Message-ID: <200407251750.MAA00917@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Bytecode: Format.h updated: 1.9 -> 1.10 --- Log message: bug 402: http://llvm.cs.uiuc.edu/PR402 : A new set of block identifiers has been added for version 1.3 so that the range of values can fit within 5 bits. This aids in halving the size of block headers. --- Diffs of the changes: (+45 -0) Index: llvm/include/llvm/Bytecode/Format.h diff -u llvm/include/llvm/Bytecode/Format.h:1.9 llvm/include/llvm/Bytecode/Format.h:1.10 --- llvm/include/llvm/Bytecode/Format.h:1.9 Sun Jan 18 15:09:23 2004 +++ llvm/include/llvm/Bytecode/Format.h Sun Jul 25 12:50:00 2004 @@ -32,6 +32,7 @@ SymbolTable, ModuleGlobalInfo, GlobalTypePlane, + DependentLibs, // Function subtypes: // Can also have ConstantPool block @@ -48,6 +49,50 @@ // encoded more efficiently. CompactionTable = 0x33, }; + + /// In LLVM 1.3 format, the identifier and the size of the block are + /// encoded into a single vbr_uint32 with 5 bits for the block identifier + /// and 27-bits for block length. This limits blocks to a maximum of + /// 128MBytes of data, and block types to 31 which should be sufficient + /// for the foreseeable usage. Because the values of block identifiers MUST + /// fit within 5 bits (values 1-31), this enumeration is used to ensure + /// smaller values are used for 1.3 and subsequent bytecode versions. + /// @brief The block number identifiers used in LLVM 1.3 bytecode + /// format. + enum CompressedBytecodeBlockIdentifiers { + + // Zero value ist verbotten! + Reserved_DoNotUse = 0x00, ///< Don't use this! + + // This is the uber block that contains the rest of the blocks. + ModuleBlockID = 0x01, ///< 1.3 identifier for modules + + // Module subtypes: + + // This is the identifier for a function + FunctionBlockID = 0x02, ///< 1.3 identifier for Functions + ConstantPoolBlockID = 0x03, ///< 1.3 identifier for constant pool + SymbolTableBlockID = 0x04, ///< 1.3 identifier for symbol table + ModuleGlobalInfoBlockID = 0x05,///< 1.3 identifier for module globals + GlobalTypePlaneBlockID = 0x06, ///< 1.3 identifier for global types + + // Function subtypes: + + // InstructionList - The instructions in the body of a function. This + // superceeds the old BasicBlock node used in LLVM 1.0. + InstructionListBlockID = 0x07, ///< 1.3 identifier for insruction list + + // CompactionTable - blocks with this id are used to define local remapping + // tables for a function, allowing the indices used within the function to + // be as small as possible. This often allows the instructions to be + // encoded more efficiently. + CompactionTableBlockID = 0x08, ///< 1.3 identifier for compaction tables + + // Dependent Libraries - blocks with this id contain strings of library + // names, as they might appear on a -l option to the linker. + DependentLibsBlockID = 0x09, ///< 1.3 identifier for list of dependent libs + }; + }; } // End llvm namespace From llvm at cs.uiuc.edu Sun Jul 25 12:52:37 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun, 25 Jul 2004 12:52:37 -0500 Subject: [llvm-commits] CVS: llvm/include/llvm/Module.h Message-ID: <200407251752.MAA00944@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: Module.h updated: 1.46 -> 1.47 --- Log message: bug 263: http://llvm.cs.uiuc.edu/PR263 : The necessary changes to module in order to support both target triples and a list of dependent libraries. --- Diffs of the changes: (+30 -5) Index: llvm/include/llvm/Module.h diff -u llvm/include/llvm/Module.h:1.46 llvm/include/llvm/Module.h:1.47 --- llvm/include/llvm/Module.h:1.46 Sat Jul 17 18:30:11 2004 +++ llvm/include/llvm/Module.h Sun Jul 25 12:52:27 2004 @@ -47,6 +47,7 @@ public: typedef iplist GlobalListType; typedef iplist FunctionListType; + typedef std::vector LibraryListType; // Global Variable iterators... typedef GlobalListType::iterator giterator; @@ -60,18 +61,24 @@ typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator const_reverse_iterator; + // Library list iterators + typedef LibraryListType::iterator literator; + typedef LibraryListType::const_iterator const_literator; + enum Endianness { AnyEndianness, LittleEndian, BigEndian }; enum PointerSize { AnyPointerSize, Pointer32, Pointer64 }; private: GlobalListType GlobalList; // The Global Variables in the module FunctionListType FunctionList; // The Functions in the module + LibraryListType LibraryList; // The Libraries needed by the module SymbolTable *SymTab; // Symbol Table for the module - std::string ModuleID; // Human readable identifier for the module + std::string ModuleID; // Human readable identifier for the module + std::string TargetTriple; // Platform target triple Module compiled on // These flags are probably not the right long-term way to handle this kind of // target information, but it is sufficient for now. - Endianness Endian; // True if target is little endian + Endianness Endian; // True if target is little endian PointerSize PtrSize; // True if target has 32-bit pointers (false = 64-bit) // Accessor for the underlying GVRefMap... only through the Constant class... @@ -84,7 +91,9 @@ Module(const std::string &ModuleID); ~Module(); - const std::string &getModuleIdentifier() const { return ModuleID; } + const std::string& getModuleIdentifier() const { return ModuleID; } + const std::string& getTargetTriple() const { return TargetTriple; } + void setTargetTriple(std::string& T) { TargetTriple = T; } /// Target endian information... Endianness getEndianness() const { return Endian; } @@ -181,6 +190,7 @@ //===--------------------------------------------------------------------===// // Module iterator forwarding functions // + // Globals list interface inline giterator gbegin() { return GlobalList.begin(); } inline const_giterator gbegin() const { return GlobalList.begin(); } inline giterator gend () { return GlobalList.end(); } @@ -198,8 +208,7 @@ inline const GlobalVariable &gback() const { return GlobalList.back(); } inline GlobalVariable &gback() { return GlobalList.back(); } - - + // FunctionList interface inline iterator begin() { return FunctionList.begin(); } inline const_iterator begin() const { return FunctionList.begin(); } inline iterator end () { return FunctionList.end(); } @@ -217,6 +226,22 @@ inline const Function &back() const { return FunctionList.back(); } inline Function &back() { return FunctionList.back(); } + // LibraryList interface + inline literator lbegin() { return LibraryList.begin(); } + inline const_literator lbegin() const { return LibraryList.begin(); } + inline literator lend () { return LibraryList.end(); } + inline const_literator lend () const { return LibraryList.end(); } + + inline unsigned lsize() const { return LibraryList.size(); } + inline bool lempty() const { return LibraryList.empty(); } + inline const std::string& lfront() const { return LibraryList.front(); } + inline std::string& lfront() { return LibraryList.front(); } + inline const std::string& lback() const { return LibraryList.back(); } + inline std::string& lback() { return LibraryList.back(); } + + inline void linsert(std::string& Lib){ LibraryList.push_back(Lib); } + inline void lremove(std::string& Lib); + void print(std::ostream &OS) const { print(OS, 0); } void print(std::ostream &OS, AssemblyAnnotationWriter *AAW) const; From llvm at cs.uiuc.edu Sun Jul 25 12:56:10 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun, 25 Jul 2004 12:56:10 -0500 Subject: [llvm-commits] CVS: llvm/lib/AsmParser/Lexer.l Message-ID: <200407251756.MAA00979@zion.cs.uiuc.edu> Changes in directory llvm/lib/AsmParser: Lexer.l updated: 1.51 -> 1.52 --- Log message: bug 263: http://llvm.cs.uiuc.edu/PR263 : Provide new tokens for target triples and dependent libraries. --- Diffs of the changes: (+2 -0) Index: llvm/lib/AsmParser/Lexer.l diff -u llvm/lib/AsmParser/Lexer.l:1.51 llvm/lib/AsmParser/Lexer.l:1.52 --- llvm/lib/AsmParser/Lexer.l:1.51 Wed Jul 14 01:44:56 2004 +++ llvm/lib/AsmParser/Lexer.l Sun Jul 25 12:56:00 2004 @@ -193,6 +193,8 @@ except { RET_TOK(TermOpVal, Unwind, UNWIND); } not { return NOT; } /* Deprecated, turned into XOR */ target { return TARGET; } +triple { return TRIPLE; } +deplibs { return DEPLIBS; } endian { return ENDIAN; } pointersize { return POINTERSIZE; } little { return LITTLE; } From llvm at cs.uiuc.edu Sun Jul 25 12:58:38 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun, 25 Jul 2004 12:58:38 -0500 Subject: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y Message-ID: <200407251758.MAA00997@zion.cs.uiuc.edu> Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.191 -> 1.192 --- Log message: bug 263: http://llvm.cs.uiuc.edu/PR263 : Provide parsing for the target triple and dependent libraries. --- Diffs of the changes: (+22 -1) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.191 llvm/lib/AsmParser/llvmAsmParser.y:1.192 --- llvm/lib/AsmParser/llvmAsmParser.y:1.191 Sat Jul 17 19:08:11 2004 +++ llvm/lib/AsmParser/llvmAsmParser.y Sun Jul 25 12:58:28 2004 @@ -912,7 +912,8 @@ %token IMPLEMENTATION ZEROINITIALIZER TRUETOK FALSETOK BEGINTOK ENDTOK %token DECLARE GLOBAL CONSTANT VOLATILE %token TO DOTDOTDOT NULL_TOK CONST INTERNAL LINKONCE WEAK APPENDING -%token OPAQUE NOT EXTERNAL TARGET ENDIAN POINTERSIZE LITTLE BIG +%token OPAQUE NOT EXTERNAL TARGET TRIPLE ENDIAN POINTERSIZE LITTLE BIG +%token DEPLIBS // Basic Block Terminating Operators %token RET BR SWITCH INVOKE UNWIND @@ -1422,6 +1423,8 @@ } | ConstPool TARGET TargetDefinition { } + | ConstPool DEPLIBS '=' LibrariesDefinition { + } | /* empty: end of list */ { }; @@ -1440,8 +1443,26 @@ CurModule.CurrentModule->setPointerSize(Module::Pointer64); else ThrowException("Invalid pointer size: '" + utostr($3) + "'!"); + } + | TRIPLE '=' STRINGCONSTANT { + std::string triple($3); + CurModule.CurrentModule->setTargetTriple(triple); }; +LibrariesDefinition : '[' LibList ']' + ; + +LibList : LibList ',' STRINGCONSTANT { + std::string lib($3); + CurModule.CurrentModule->linsert(lib); + } + | STRINGCONSTANT { + std::string lib($1); + CurModule.CurrentModule->linsert(lib); + } + | /* empty: end of list */ { + } + ; //===----------------------------------------------------------------------===// // Rules to match Function Headers From llvm at cs.uiuc.edu Sun Jul 25 13:07:46 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun, 25 Jul 2004 13:07:46 -0500 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Reader/Reader.cpp Reader.h Message-ID: <200407251807.NAA01106@zion.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Reader: Reader.cpp updated: 1.116 -> 1.117 Reader.h updated: 1.7 -> 1.8 --- Log message: bug 263: http://llvm.cs.uiuc.edu/PR263 : - encode/decode target triple and dependent libraries bug 401: http://llvm.cs.uiuc.edu/PR401 : - fix encoding/decoding of FP values to be little-endian only bug 402: http://llvm.cs.uiuc.edu/PR402 : - initial (compatible) cut at 24-bit types instead of 32-bit - reduce size of block headers by 50% Other: - cleanup Writer by consolidating to one compilation unit, rem. other files - use a std::vector instead of std::deque so the buffer can be allocated in multiples of 64KByte chunks rather than in multiples of some smaller (default) number. --- Diffs of the changes: (+171 -28) Index: llvm/lib/Bytecode/Reader/Reader.cpp diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.116 llvm/lib/Bytecode/Reader/Reader.cpp:1.117 --- llvm/lib/Bytecode/Reader/Reader.cpp:1.116 Sat Jul 17 19:12:03 2004 +++ llvm/lib/Bytecode/Reader/Reader.cpp Sun Jul 25 13:07:36 2004 @@ -156,24 +156,79 @@ /// Read a float value in little-endian order inline void BytecodeReader::read_float(float& FloatVal) { - /// FIXME: This is a broken implementation! It reads - /// it in a platform-specific endianess. Need to make - /// it little endian always. - read_data(&FloatVal, &FloatVal+1); + if (hasPlatformSpecificFloatingPoint) { + read_data(&FloatVal, &FloatVal+1); + } else { + /// FIXME: This isn't optimal, it has size problems on some platforms + /// where FP is not IEEE. + union { + float f; + uint32_t i; + } FloatUnion; + FloatUnion.i = At[0] | (At[1] << 8) | (At[2] << 16) | (At[3] << 24); + At+=sizeof(uint32_t); + FloatVal = FloatUnion.f; + } } /// Read a double value in little-endian order inline void BytecodeReader::read_double(double& DoubleVal) { - /// FIXME: This is a broken implementation! It reads - /// it in a platform-specific endianess. Need to make - /// it little endian always. - read_data(&DoubleVal, &DoubleVal+1); + if (hasPlatformSpecificFloatingPoint) { + read_data(&DoubleVal, &DoubleVal+1); + } else { + /// FIXME: This isn't optimal, it has size problems on some platforms + /// where FP is not IEEE. + union { + double d; + uint64_t i; + } DoubleUnion; + DoubleUnion.i = At[0] | (At[1] << 8) | (At[2] << 16) | (At[3] << 24) | + (uint64_t(At[4]) << 32) | (uint64_t(At[5]) << 40) | + (uint64_t(At[6]) << 48) | (uint64_t(At[7]) << 56); + At+=sizeof(uint64_t); + DoubleVal = DoubleUnion.d; + } } /// Read a block header and obtain its type and size inline void BytecodeReader::read_block(unsigned &Type, unsigned &Size) { - Type = read_uint(); - Size = read_uint(); + if ( hasLongBlockHeaders ) { + Type = read_uint(); + Size = read_uint(); + switch (Type) { + case BytecodeFormat::Reserved_DoNotUse : + error("Reserved_DoNotUse used as Module Type?"); + Type = BytecodeFormat::Module; break; + case BytecodeFormat::Module: + Type = BytecodeFormat::ModuleBlockID; break; + case BytecodeFormat::Function: + Type = BytecodeFormat::FunctionBlockID; break; + case BytecodeFormat::ConstantPool: + Type = BytecodeFormat::ConstantPoolBlockID; break; + case BytecodeFormat::SymbolTable: + Type = BytecodeFormat::SymbolTableBlockID; break; + case BytecodeFormat::ModuleGlobalInfo: + Type = BytecodeFormat::ModuleGlobalInfoBlockID; break; + case BytecodeFormat::GlobalTypePlane: + Type = BytecodeFormat::GlobalTypePlaneBlockID; break; + case BytecodeFormat::InstructionList: + Type = BytecodeFormat::InstructionListBlockID; break; + case BytecodeFormat::CompactionTable: + Type = BytecodeFormat::CompactionTableBlockID; break; + case BytecodeFormat::BasicBlock: + /// This block type isn't used after version 1.1. However, we have to + /// still allow the value in case this is an old bc format file. + /// We just let its value creep thru. + break; + default: + error("Invalid module type found: " + utostr(Type)); + break; + } + } else { + Size = read_uint(); + Type = Size & 0x1F; // mask low order five bits + Size >>= 5; // get rid of five low order bits, leaving high 27 + } BlockStart = At; if (At + Size > BlockEnd) error("Attempt to size a block past end of memory"); @@ -216,6 +271,9 @@ /// @see sanitizeTypeId inline bool BytecodeReader::read_typeid(unsigned &TypeId) { TypeId = read_vbr_uint(); + if ( !has32BitTypes ) + if ( TypeId == 0x00FFFFFF ) + TypeId = read_vbr_uint(); return sanitizeTypeId(TypeId); } @@ -1504,7 +1562,7 @@ read_block(Type, Size); switch (Type) { - case BytecodeFormat::ConstantPool: + case BytecodeFormat::ConstantPoolBlockID: if (!InsertedArguments) { // Insert arguments into the value table before we parse the first basic // block in the function, but after we potentially read in the @@ -1516,7 +1574,7 @@ ParseConstantPool(FunctionValues, FunctionTypes, true); break; - case BytecodeFormat::CompactionTable: + case BytecodeFormat::CompactionTableBlockID: ParseCompactionTable(); break; @@ -1534,7 +1592,7 @@ break; } - case BytecodeFormat::InstructionList: { + case BytecodeFormat::InstructionListBlockID: { // Insert arguments into the value table before we parse the instruction // list for the function, but after we potentially read in the compaction // table. @@ -1549,7 +1607,7 @@ break; } - case BytecodeFormat::SymbolTable: + case BytecodeFormat::SymbolTableBlockID: ParseSymbolTable(F, &F->getSymbolTable()); break; @@ -1784,13 +1842,28 @@ error("Invalid function type (type type) found"); } - if (hasInconsistentModuleGlobalInfo) - align32(); - // Now that the function signature list is set up, reverse it so that we can // remove elements efficiently from the back of the vector. std::reverse(FunctionSignatureList.begin(), FunctionSignatureList.end()); + // If this bytecode format has dependent library information in it .. + if (!hasNoDependentLibraries) { + // Read in the number of dependent library items that follow + unsigned num_dep_libs = read_vbr_uint(); + std::string dep_lib; + while( num_dep_libs-- ) { + dep_lib = read_str(); + TheModule->linsert(dep_lib); + } + + // Read target triple and place into the module + std::string triple = read_str(); + TheModule->setTargetTriple(triple); + } + + if (hasInconsistentModuleGlobalInfo) + align32(); + // This is for future proofing... in the future extra fields may be added that // we don't understand, so we transparently ignore them. // @@ -1820,6 +1893,10 @@ hasExplicitPrimitiveZeros = false; hasRestrictedGEPTypes = false; hasTypeDerivedFromValue = false; + hasLongBlockHeaders = false; + hasPlatformSpecificFloatingPoint = false; + has32BitTypes = false; + hasNoDependentLibraries = false; switch (RevisionNum) { case 0: // LLVM 1.0, 1.1 release version @@ -1827,6 +1904,7 @@ hasInconsistentModuleGlobalInfo = true; hasExplicitPrimitiveZeros = true; + // FALL THROUGH case 1: // LLVM 1.2 release version // LLVM 1.2 added explicit support for emitting strings efficiently. @@ -1846,7 +1924,35 @@ hasTypeDerivedFromValue = true; // FALL THROUGH - case 2: // LLVM 1.3 release version + + case 2: /// 1.2.5 (mid-release) version + + /// LLVM 1.2 and earlier had two-word block headers. This is a bit wasteful, + /// especially for small files where the 8 bytes per block is a large fraction + /// of the total block size. In LLVM 1.3, the block type and length are + /// compressed into a single 32-bit unsigned integer. 27 bits for length, 5 + /// bits for block type. + hasLongBlockHeaders = true; + + /// LLVM 1.2 and earlier wrote floating point values in a platform specific + /// bit ordering. This was fixed in LLVM 1.3, but we still need to be backwards + /// compatible. + hasPlatformSpecificFloatingPoint = true; + + /// LLVM 1.2 and earlier wrote type slot numbers as vbr_uint32. In LLVM 1.3 + /// this has been reduced to vbr_uint24. It shouldn't make much difference + /// since we haven't run into a module with > 24 million types, but for safety + /// the 24-bit restriction has been enforced in 1.3 to free some bits in + /// various places and to ensure consistency. + has32BitTypes = true; + + /// LLVM 1.2 and earlier did not provide a target triple nor a list of + /// libraries on which the bytecode is dependent. LLVM 1.3 provides these + /// features, for use in future versions of LLVM. + hasNoDependentLibraries = true; + + // FALL THROUGH + case 3: // LLVM 1.3 release version break; default: @@ -1870,7 +1976,7 @@ // Read into instance variables... ParseVersionInfo(); - align32(); /// FIXME: Is this redundant? VI is first and 4 bytes! + align32(); bool SeenModuleGlobalInfo = false; bool SeenGlobalTypePlane = false; @@ -1881,7 +1987,7 @@ switch (Type) { - case BytecodeFormat::GlobalTypePlane: + case BytecodeFormat::GlobalTypePlaneBlockID: if (SeenGlobalTypePlane) error("Two GlobalTypePlane Blocks Encountered!"); @@ -1889,22 +1995,22 @@ SeenGlobalTypePlane = true; break; - case BytecodeFormat::ModuleGlobalInfo: + case BytecodeFormat::ModuleGlobalInfoBlockID: if (SeenModuleGlobalInfo) error("Two ModuleGlobalInfo Blocks Encountered!"); ParseModuleGlobalInfo(); SeenModuleGlobalInfo = true; break; - case BytecodeFormat::ConstantPool: + case BytecodeFormat::ConstantPoolBlockID: ParseConstantPool(ModuleValues, ModuleTypes,false); break; - case BytecodeFormat::Function: + case BytecodeFormat::FunctionBlockID: ParseFunctionLazily(); break; - case BytecodeFormat::SymbolTable: + case BytecodeFormat::SymbolTableBlockID: ParseSymbolTable(0, &TheModule->getSymbolTable()); break; @@ -1967,14 +2073,16 @@ error("Invalid bytecode signature: " + utostr(Sig)); } - // Tell the handler we're starting a module if (Handler) Handler->handleModuleBegin(ModuleID); - // Get the module block and size and verify + // Get the module block and size and verify. This is handled specially + // because the module block/size is always written in long format. Other + // blocks are written in short format so the read_block method is used. unsigned Type, Size; - read_block(Type, Size); - if (Type != BytecodeFormat::Module) { + Type = read_uint(); + Size = read_uint(); + if (Type != BytecodeFormat::ModuleBlockID) { error("Expected Module Block! Type:" + utostr(Type) + ", Size:" + utostr(Size)); } Index: llvm/lib/Bytecode/Reader/Reader.h diff -u llvm/lib/Bytecode/Reader/Reader.h:1.7 llvm/lib/Bytecode/Reader/Reader.h:1.8 --- llvm/lib/Bytecode/Reader/Reader.h:1.7 Sat Jul 17 19:13:12 2004 +++ llvm/lib/Bytecode/Reader/Reader.h Sun Jul 25 13:07:36 2004 @@ -56,6 +56,7 @@ /// @name Types /// @{ public: + /// @brief A convenience type for the buffer pointer typedef const unsigned char* BufPtr; @@ -268,6 +269,36 @@ /// from Value style of bytecode file is being read. bool hasTypeDerivedFromValue; + /// LLVM 1.2 and earlier encoded block headers as two uint (8 bytes), one for + /// the size and one for the type. This is a bit wasteful, especially for small + /// files where the 8 bytes per block is a large fraction of the total block + /// size. In LLVM 1.3, the block type and length are encoded into a single + /// uint32 by restricting the number of block types (limit 31) and the maximum + /// size of a block (limit 2^27-1=134,217,727). Note that the module block + /// still uses the 8-byte format so the maximum size of a file can be + /// 2^32-1 bytes long. + bool hasLongBlockHeaders; + + /// LLVM 1.2 and earlier wrote floating point values in a platform specific + /// bit ordering. This was fixed in LLVM 1.3 + bool hasPlatformSpecificFloatingPoint; + + /// LLVM 1.2 and earlier wrote type slot numbers as vbr_uint32. In LLVM 1.3 + /// this has been reduced to vbr_uint24. It shouldn't make much difference + /// since we haven't run into a module with > 24 million types, but for safety + /// the 24-bit restriction has been enforced in 1.3 to free some bits in + /// various places and to ensure consistency. In particular, global vars are + /// restricted to 24-bits. + bool has32BitTypes; + + /// LLVM 1.2 and earlier did not provide a target triple nor a list of + /// libraries on which the bytecode is dependent. LLVM 1.3 provides these + /// features, for use in future versions of LLVM. + bool hasNoDependentLibraries; + + /// LLVM 1.2 and earlier encoded the file version as part of the module block + /// but this information may be needed to + /// CompactionTable - If a compaction table is active in the current function, /// this is the mapping that it contains. std::vector CompactionTypes; @@ -430,6 +461,10 @@ /// @brief Read an unsigned integer with variable bit rate encoding inline unsigned read_vbr_uint(); + /// @brief Read an unsigned integer of no more than 24-bits with variable + /// bit rate encoding. + inline unsigned read_vbr_uint24(); + /// @brief Read an unsigned 64-bit integer with variable bit rate encoding. inline uint64_t read_vbr_uint64(); From llvm at cs.uiuc.edu Sun Jul 25 13:07:46 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun, 25 Jul 2004 13:07:46 -0500 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Writer/Writer.cpp WriterInternals.h ConstantWriter.cpp InstructionWriter.cpp WriterPrimitives.h Message-ID: <200407251807.NAA01116@zion.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Writer: Writer.cpp updated: 1.70 -> 1.71 WriterInternals.h updated: 1.21 -> 1.22 ConstantWriter.cpp (r1.40) removed InstructionWriter.cpp (r1.42) removed WriterPrimitives.h (r1.7) removed --- Log message: bug 263: http://llvm.cs.uiuc.edu/PR263 : - encode/decode target triple and dependent libraries bug 401: http://llvm.cs.uiuc.edu/PR401 : - fix encoding/decoding of FP values to be little-endian only bug 402: http://llvm.cs.uiuc.edu/PR402 : - initial (compatible) cut at 24-bit types instead of 32-bit - reduce size of block headers by 50% Other: - cleanup Writer by consolidating to one compilation unit, rem. other files - use a std::vector instead of std::deque so the buffer can be allocated in multiples of 64KByte chunks rather than in multiples of some smaller (default) number. --- Diffs of the changes: (+832 -74) Index: llvm/lib/Bytecode/Writer/Writer.cpp diff -u llvm/lib/Bytecode/Writer/Writer.cpp:1.70 llvm/lib/Bytecode/Writer/Writer.cpp:1.71 --- llvm/lib/Bytecode/Writer/Writer.cpp:1.70 Sat Jul 17 19:16:21 2004 +++ llvm/lib/Bytecode/Writer/Writer.cpp Sun Jul 25 13:07:36 2004 @@ -10,24 +10,21 @@ // This library implements the functionality defined in llvm/Bytecode/Writer.h // // Note that this file uses an unusual technique of outputting all the bytecode -// to a deque of unsigned char, then copies the deque to an ostream. The +// to a vector of unsigned char, then copies the vector to an ostream. The // reason for this is that we must do "seeking" in the stream to do back- // patching, and some very important ostreams that we want to support (like // pipes) do not support seeking. :( :( :( // -// The choice of the deque data structure is influenced by the extremely fast -// "append" speed, plus the free "seek"/replace in the middle of the stream. I -// didn't use a vector because the stream could end up very large and copying -// the whole thing to reallocate would be kinda silly. -// //===----------------------------------------------------------------------===// #include "WriterInternals.h" #include "llvm/Bytecode/WriteBytecodePass.h" #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" +#include "llvm/Instructions.h" #include "llvm/Module.h" #include "llvm/SymbolTable.h" +#include "llvm/Support/GetElementPtrTypeIterator.h" #include "Support/STLExtras.h" #include "Support/Statistic.h" #include @@ -39,15 +36,720 @@ static Statistic<> BytesWritten("bytecodewriter", "Number of bytecode bytes written"); -BytecodeWriter::BytecodeWriter(std::deque &o, const Module *M) +//===----------------------------------------------------------------------===// +//=== Output Primitives ===// +//===----------------------------------------------------------------------===// + +// output - If a position is specified, it must be in the valid portion of the +// string... note that this should be inlined always so only the relevant IF +// body should be included. +inline void BytecodeWriter::output(unsigned i, int pos) { + if (pos == -1) { // Be endian clean, little endian is our friend + Out.push_back((unsigned char)i); + Out.push_back((unsigned char)(i >> 8)); + Out.push_back((unsigned char)(i >> 16)); + Out.push_back((unsigned char)(i >> 24)); + } else { + Out[pos ] = (unsigned char)i; + Out[pos+1] = (unsigned char)(i >> 8); + Out[pos+2] = (unsigned char)(i >> 16); + Out[pos+3] = (unsigned char)(i >> 24); + } +} + +inline void BytecodeWriter::output(int i) { + output((unsigned)i); +} + +/// output_vbr - Output an unsigned value, by using the least number of bytes +/// possible. This is useful because many of our "infinite" values are really +/// very small most of the time; but can be large a few times. +/// Data format used: If you read a byte with the high bit set, use the low +/// seven bits as data and then read another byte. Note that using this may +/// cause the output buffer to become unaligned. +inline void BytecodeWriter::output_vbr(uint64_t i) { + while (1) { + if (i < 0x80) { // done? + Out.push_back((unsigned char)i); // We know the high bit is clear... + return; + } + + // Nope, we are bigger than a character, output the next 7 bits and set the + // high bit to say that there is more coming... + Out.push_back(0x80 | ((unsigned char)i & 0x7F)); + i >>= 7; // Shift out 7 bits now... + } +} + +inline void BytecodeWriter::output_vbr(unsigned i) { + while (1) { + if (i < 0x80) { // done? + Out.push_back((unsigned char)i); // We know the high bit is clear... + return; + } + + // Nope, we are bigger than a character, output the next 7 bits and set the + // high bit to say that there is more coming... + Out.push_back(0x80 | ((unsigned char)i & 0x7F)); + i >>= 7; // Shift out 7 bits now... + } +} + +inline void BytecodeWriter::output_typeid(unsigned i) { + if (i <= 0x00FFFFFF) + this->output_vbr(i); + else { + this->output_vbr(0x00FFFFFF); + this->output_vbr(i); + } +} + +inline void BytecodeWriter::output_vbr(int64_t i) { + if (i < 0) + output_vbr(((uint64_t)(-i) << 1) | 1); // Set low order sign bit... + else + output_vbr((uint64_t)i << 1); // Low order bit is clear. +} + + +inline void BytecodeWriter::output_vbr(int i) { + if (i < 0) + output_vbr(((unsigned)(-i) << 1) | 1); // Set low order sign bit... + else + output_vbr((unsigned)i << 1); // Low order bit is clear. +} + +// align32 - emit the minimal number of bytes that will bring us to 32 bit +// alignment... +// +inline void BytecodeWriter::align32() { + int NumPads = (4-(Out.size() & 3)) & 3; // Bytes to get padding to 32 bits + while (NumPads--) Out.push_back((unsigned char)0xAB); +} + +inline void BytecodeWriter::output(const std::string &s, bool Aligned ) { + unsigned Len = s.length(); + output_vbr(Len ); // Strings may have an arbitrary length... + Out.insert(Out.end(), s.begin(), s.end()); + + if (Aligned) + align32(); // Make sure we are now aligned... +} + +inline void BytecodeWriter::output_data(const void *Ptr, const void *End) { + Out.insert(Out.end(), (const unsigned char*)Ptr, (const unsigned char*)End); +} + +inline void BytecodeWriter::output_float(float& FloatVal) { + /// FIXME: This isn't optimal, it has size problems on some platforms + /// where FP is not IEEE. + union { + float f; + uint32_t i; + } FloatUnion; + FloatUnion.f = FloatVal; + Out.push_back( static_cast( (FloatUnion.i & 0xFF ))); + Out.push_back( static_cast( (FloatUnion.i >> 8) & 0xFF)); + Out.push_back( static_cast( (FloatUnion.i >> 16) & 0xFF)); + Out.push_back( static_cast( (FloatUnion.i >> 24) & 0xFF)); +} + +inline void BytecodeWriter::output_double(double& DoubleVal) { + /// FIXME: This isn't optimal, it has size problems on some platforms + /// where FP is not IEEE. + union { + double d; + uint64_t i; + } DoubleUnion; + DoubleUnion.d = DoubleVal; + Out.push_back( static_cast( (DoubleUnion.i & 0xFF ))); + Out.push_back( static_cast( (DoubleUnion.i >> 8) & 0xFF)); + Out.push_back( static_cast( (DoubleUnion.i >> 16) & 0xFF)); + Out.push_back( static_cast( (DoubleUnion.i >> 24) & 0xFF)); + Out.push_back( static_cast( (DoubleUnion.i >> 32) & 0xFF)); + Out.push_back( static_cast( (DoubleUnion.i >> 40) & 0xFF)); + Out.push_back( static_cast( (DoubleUnion.i >> 48) & 0xFF)); + Out.push_back( static_cast( (DoubleUnion.i >> 56) & 0xFF)); +} + +inline BytecodeBlock::BytecodeBlock(unsigned ID, BytecodeWriter& w, + bool elideIfEmpty, bool hasLongFormat ) + : Id(ID), Writer(w), ElideIfEmpty(elideIfEmpty), HasLongFormat(hasLongFormat){ + + if (HasLongFormat) { + w.output(ID); + w.output(0U); // For length in long format + } else { + w.output(0U); /// Place holder for ID and length for this block + } + Loc = w.size(); +} + +inline BytecodeBlock::~BytecodeBlock() { // Do backpatch when block goes out + // of scope... + if (Loc == Writer.size() && ElideIfEmpty) { + // If the block is empty, and we are allowed to, do not emit the block at + // all! + Writer.resize(Writer.size()-(HasLongFormat?8:4)); + return; + } + + //cerr << "OldLoc = " << Loc << " NewLoc = " << NewLoc << " diff = " + // << (NewLoc-Loc) << endl; + if (HasLongFormat) + Writer.output(unsigned(Writer.size()-Loc), int(Loc-4)); + else + Writer.output(unsigned(Writer.size()-Loc) << 5 | (Id & 0x1F), int(Loc-4)); + Writer.align32(); // Blocks must ALWAYS be aligned +} + +//===----------------------------------------------------------------------===// +//=== Constant Output ===// +//===----------------------------------------------------------------------===// + +void BytecodeWriter::outputType(const Type *T) { + output_vbr((unsigned)T->getTypeID()); + + // That's all there is to handling primitive types... + if (T->isPrimitiveType()) { + return; // We might do this if we alias a prim type: %x = type int + } + + switch (T->getTypeID()) { // Handle derived types now. + case Type::FunctionTyID: { + const FunctionType *MT = cast(T); + int Slot = Table.getSlot(MT->getReturnType()); + assert(Slot != -1 && "Type used but not available!!"); + output_typeid((unsigned)Slot); + + // Output the number of arguments to function (+1 if varargs): + output_vbr((unsigned)MT->getNumParams()+MT->isVarArg()); + + // Output all of the arguments... + FunctionType::param_iterator I = MT->param_begin(); + for (; I != MT->param_end(); ++I) { + Slot = Table.getSlot(*I); + assert(Slot != -1 && "Type used but not available!!"); + output_typeid((unsigned)Slot); + } + + // Terminate list with VoidTy if we are a varargs function... + if (MT->isVarArg()) + output_typeid((unsigned)Type::VoidTyID); + break; + } + + case Type::ArrayTyID: { + const ArrayType *AT = cast(T); + int Slot = Table.getSlot(AT->getElementType()); + assert(Slot != -1 && "Type used but not available!!"); + output_typeid((unsigned)Slot); + //std::cerr << "Type slot = " << Slot << " Type = " << T->getName() << endl; + + output_vbr(AT->getNumElements()); + break; + } + + case Type::StructTyID: { + const StructType *ST = cast(T); + + // Output all of the element types... + for (StructType::element_iterator I = ST->element_begin(), + E = ST->element_end(); I != E; ++I) { + int Slot = Table.getSlot(*I); + assert(Slot != -1 && "Type used but not available!!"); + output_typeid((unsigned)Slot); + } + + // Terminate list with VoidTy + output_typeid((unsigned)Type::VoidTyID); + break; + } + + case Type::PointerTyID: { + const PointerType *PT = cast(T); + int Slot = Table.getSlot(PT->getElementType()); + assert(Slot != -1 && "Type used but not available!!"); + output_typeid((unsigned)Slot); + break; + } + + case Type::OpaqueTyID: { + // No need to emit anything, just the count of opaque types is enough. + break; + } + + //case Type::PackedTyID: + default: + std::cerr << __FILE__ << ":" << __LINE__ << ": Don't know how to serialize" + << " Type '" << T->getDescription() << "'\n"; + break; + } +} + +void BytecodeWriter::outputConstant(const Constant *CPV) { + assert((CPV->getType()->isPrimitiveType() || !CPV->isNullValue()) && + "Shouldn't output null constants!"); + + // We must check for a ConstantExpr before switching by type because + // a ConstantExpr can be of any type, and has no explicit value. + // + if (const ConstantExpr *CE = dyn_cast(CPV)) { + // FIXME: Encoding of constant exprs could be much more compact! + assert(CE->getNumOperands() > 0 && "ConstantExpr with 0 operands"); + output_vbr(CE->getNumOperands()); // flags as an expr + output_vbr(CE->getOpcode()); // flags as an expr + + for (User::const_op_iterator OI = CE->op_begin(); OI != CE->op_end(); ++OI){ + int Slot = Table.getSlot(*OI); + assert(Slot != -1 && "Unknown constant used in ConstantExpr!!"); + output_vbr((unsigned)Slot); + Slot = Table.getSlot((*OI)->getType()); + output_typeid((unsigned)Slot); + } + return; + } else { + output_vbr(0U); // flag as not a ConstantExpr + } + + switch (CPV->getType()->getTypeID()) { + case Type::BoolTyID: // Boolean Types + if (cast(CPV)->getValue()) + output_vbr(1U); + else + output_vbr(0U); + break; + + case Type::UByteTyID: // Unsigned integer types... + case Type::UShortTyID: + case Type::UIntTyID: + case Type::ULongTyID: + output_vbr(cast(CPV)->getValue()); + break; + + case Type::SByteTyID: // Signed integer types... + case Type::ShortTyID: + case Type::IntTyID: + case Type::LongTyID: + output_vbr(cast(CPV)->getValue()); + break; + + case Type::ArrayTyID: { + const ConstantArray *CPA = cast(CPV); + assert(!CPA->isString() && "Constant strings should be handled specially!"); + + for (unsigned i = 0; i != CPA->getNumOperands(); ++i) { + int Slot = Table.getSlot(CPA->getOperand(i)); + assert(Slot != -1 && "Constant used but not available!!"); + output_vbr((unsigned)Slot); + } + break; + } + + case Type::StructTyID: { + const ConstantStruct *CPS = cast(CPV); + const std::vector &Vals = CPS->getValues(); + + for (unsigned i = 0; i < Vals.size(); ++i) { + int Slot = Table.getSlot(Vals[i]); + assert(Slot != -1 && "Constant used but not available!!"); + output_vbr((unsigned)Slot); + } + break; + } + + case Type::PointerTyID: + assert(0 && "No non-null, non-constant-expr constants allowed!"); + abort(); + + case Type::FloatTyID: { // Floating point types... + float Tmp = (float)cast(CPV)->getValue(); + output_float(Tmp); + break; + } + case Type::DoubleTyID: { + double Tmp = cast(CPV)->getValue(); + output_double(Tmp); + break; + } + + case Type::VoidTyID: + case Type::LabelTyID: + default: + std::cerr << __FILE__ << ":" << __LINE__ << ": Don't know how to serialize" + << " type '" << *CPV->getType() << "'\n"; + break; + } + return; +} + +void BytecodeWriter::outputConstantStrings() { + SlotCalculator::string_iterator I = Table.string_begin(); + SlotCalculator::string_iterator E = Table.string_end(); + if (I == E) return; // No strings to emit + + // If we have != 0 strings to emit, output them now. Strings are emitted into + // the 'void' type plane. + output_vbr(unsigned(E-I)); + output_typeid(Type::VoidTyID); + + // Emit all of the strings. + for (I = Table.string_begin(); I != E; ++I) { + const ConstantArray *Str = *I; + int Slot = Table.getSlot(Str->getType()); + assert(Slot != -1 && "Constant string of unknown type?"); + output_typeid((unsigned)Slot); + + // Now that we emitted the type (which indicates the size of the string), + // emit all of the characters. + std::string Val = Str->getAsString(); + output_data(Val.c_str(), Val.c_str()+Val.size()); + } +} + +//===----------------------------------------------------------------------===// +//=== Instruction Output ===// +//===----------------------------------------------------------------------===// +typedef unsigned char uchar; + +// outputInstructionFormat0 - Output those wierd instructions that have a large +// number of operands or have large operands themselves... +// +// Format: [opcode] [type] [numargs] [arg0] [arg1] ... [arg] +// +void BytecodeWriter::outputInstructionFormat0(const Instruction *I, unsigned Opcode, + const SlotCalculator &Table, + unsigned Type) { + // Opcode must have top two bits clear... + output_vbr(Opcode << 2); // Instruction Opcode ID + output_typeid(Type); // Result type + + unsigned NumArgs = I->getNumOperands(); + output_vbr(NumArgs + (isa(I) || isa(I) || + isa(I))); + + if (!isa(&I)) { + for (unsigned i = 0; i < NumArgs; ++i) { + int Slot = Table.getSlot(I->getOperand(i)); + assert(Slot >= 0 && "No slot number for value!?!?"); + output_vbr((unsigned)Slot); + } + + if (isa(I) || isa(I)) { + int Slot = Table.getSlot(I->getType()); + assert(Slot != -1 && "Cast return type unknown?"); + output_typeid((unsigned)Slot); + } else if (const VANextInst *VAI = dyn_cast(I)) { + int Slot = Table.getSlot(VAI->getArgType()); + assert(Slot != -1 && "VarArg argument type unknown?"); + output_typeid((unsigned)Slot); + } + + } else { + int Slot = Table.getSlot(I->getOperand(0)); + assert(Slot >= 0 && "No slot number for value!?!?"); + output_vbr(unsigned(Slot)); + + // We need to encode the type of sequential type indices into their slot # + unsigned Idx = 1; + for (gep_type_iterator TI = gep_type_begin(I), E = gep_type_end(I); + Idx != NumArgs; ++TI, ++Idx) { + Slot = Table.getSlot(I->getOperand(Idx)); + assert(Slot >= 0 && "No slot number for value!?!?"); + + if (isa(*TI)) { + unsigned IdxId; + switch (I->getOperand(Idx)->getType()->getTypeID()) { + default: assert(0 && "Unknown index type!"); + case Type::UIntTyID: IdxId = 0; break; + case Type::IntTyID: IdxId = 1; break; + case Type::ULongTyID: IdxId = 2; break; + case Type::LongTyID: IdxId = 3; break; + } + Slot = (Slot << 2) | IdxId; + } + output_vbr(unsigned(Slot)); + } + } + + align32(); // We must maintain correct alignment! +} + + +// outputInstrVarArgsCall - Output the absurdly annoying varargs function calls. +// This are more annoying than most because the signature of the call does not +// tell us anything about the types of the arguments in the varargs portion. +// Because of this, we encode (as type 0) all of the argument types explicitly +// before the argument value. This really sucks, but you shouldn't be using +// varargs functions in your code! *death to printf*! +// +// Format: [opcode] [type] [numargs] [arg0] [arg1] ... [arg] +// +void BytecodeWriter::outputInstrVarArgsCall(const Instruction *I, + unsigned Opcode, + const SlotCalculator &Table, + unsigned Type) { + assert(isa(I) || isa(I)); + // Opcode must have top two bits clear... + output_vbr(Opcode << 2); // Instruction Opcode ID + output_typeid(Type); // Result type (varargs type) + + const PointerType *PTy = cast(I->getOperand(0)->getType()); + const FunctionType *FTy = cast(PTy->getElementType()); + unsigned NumParams = FTy->getNumParams(); + + unsigned NumFixedOperands; + if (isa(I)) { + // Output an operand for the callee and each fixed argument, then two for + // each variable argument. + NumFixedOperands = 1+NumParams; + } else { + assert(isa(I) && "Not call or invoke??"); + // Output an operand for the callee and destinations, then two for each + // variable argument. + NumFixedOperands = 3+NumParams; + } + output_vbr(2 * I->getNumOperands()-NumFixedOperands); + + // The type for the function has already been emitted in the type field of the + // instruction. Just emit the slot # now. + for (unsigned i = 0; i != NumFixedOperands; ++i) { + int Slot = Table.getSlot(I->getOperand(i)); + assert(Slot >= 0 && "No slot number for value!?!?"); + output_vbr((unsigned)Slot); + } + + for (unsigned i = NumFixedOperands, e = I->getNumOperands(); i != e; ++i) { + // Output Arg Type ID + int Slot = Table.getSlot(I->getOperand(i)->getType()); + assert(Slot >= 0 && "No slot number for value!?!?"); + output_typeid((unsigned)Slot); + + // Output arg ID itself + Slot = Table.getSlot(I->getOperand(i)); + assert(Slot >= 0 && "No slot number for value!?!?"); + output_vbr((unsigned)Slot); + } + align32(); // We must maintain correct alignment! +} + + +// outputInstructionFormat1 - Output one operand instructions, knowing that no +// operand index is >= 2^12. +// +inline void BytecodeWriter::outputInstructionFormat1(const Instruction *I, + unsigned Opcode, + unsigned *Slots, + unsigned Type) { + // bits Instruction format: + // -------------------------- + // 01-00: Opcode type, fixed to 1. + // 07-02: Opcode + // 19-08: Resulting type plane + // 31-20: Operand #1 (if set to (2^12-1), then zero operands) + // + unsigned Bits = 1 | (Opcode << 2) | (Type << 8) | (Slots[0] << 20); + // cerr << "1 " << IType << " " << Type << " " << Slots[0] << endl; + output(Bits); +} + + +// outputInstructionFormat2 - Output two operand instructions, knowing that no +// operand index is >= 2^8. +// +inline void BytecodeWriter::outputInstructionFormat2(const Instruction *I, + unsigned Opcode, + unsigned *Slots, + unsigned Type) { + // bits Instruction format: + // -------------------------- + // 01-00: Opcode type, fixed to 2. + // 07-02: Opcode + // 15-08: Resulting type plane + // 23-16: Operand #1 + // 31-24: Operand #2 + // + unsigned Bits = 2 | (Opcode << 2) | (Type << 8) | + (Slots[0] << 16) | (Slots[1] << 24); + // cerr << "2 " << IType << " " << Type << " " << Slots[0] << " " + // << Slots[1] << endl; + output(Bits); +} + + +// outputInstructionFormat3 - Output three operand instructions, knowing that no +// operand index is >= 2^6. +// +inline void BytecodeWriter::outputInstructionFormat3(const Instruction *I, + unsigned Opcode, + unsigned *Slots, + unsigned Type) { + // bits Instruction format: + // -------------------------- + // 01-00: Opcode type, fixed to 3. + // 07-02: Opcode + // 13-08: Resulting type plane + // 19-14: Operand #1 + // 25-20: Operand #2 + // 31-26: Operand #3 + // + unsigned Bits = 3 | (Opcode << 2) | (Type << 8) | + (Slots[0] << 14) | (Slots[1] << 20) | (Slots[2] << 26); + //cerr << "3 " << IType << " " << Type << " " << Slots[0] << " " + // << Slots[1] << " " << Slots[2] << endl; + output(Bits); +} + +void BytecodeWriter::outputInstruction(const Instruction &I) { + assert(I.getOpcode() < 62 && "Opcode too big???"); + unsigned Opcode = I.getOpcode(); + unsigned NumOperands = I.getNumOperands(); + + // Encode 'volatile load' as 62 and 'volatile store' as 63. + if (isa(I) && cast(I).isVolatile()) + Opcode = 62; + if (isa(I) && cast(I).isVolatile()) + Opcode = 63; + + // Figure out which type to encode with the instruction. Typically we want + // the type of the first parameter, as opposed to the type of the instruction + // (for example, with setcc, we always know it returns bool, but the type of + // the first param is actually interesting). But if we have no arguments + // we take the type of the instruction itself. + // + const Type *Ty; + switch (I.getOpcode()) { + case Instruction::Select: + case Instruction::Malloc: + case Instruction::Alloca: + Ty = I.getType(); // These ALWAYS want to encode the return type + break; + case Instruction::Store: + Ty = I.getOperand(1)->getType(); // Encode the pointer type... + assert(isa(Ty) && "Store to nonpointer type!?!?"); + break; + default: // Otherwise use the default behavior... + Ty = NumOperands ? I.getOperand(0)->getType() : I.getType(); + break; + } + + unsigned Type; + int Slot = Table.getSlot(Ty); + assert(Slot != -1 && "Type not available!!?!"); + Type = (unsigned)Slot; + + // Varargs calls and invokes are encoded entirely different from any other + // instructions. + if (const CallInst *CI = dyn_cast(&I)){ + const PointerType *Ty =cast(CI->getCalledValue()->getType()); + if (cast(Ty->getElementType())->isVarArg()) { + outputInstrVarArgsCall(CI, Opcode, Table, Type); + return; + } + } else if (const InvokeInst *II = dyn_cast(&I)) { + const PointerType *Ty =cast(II->getCalledValue()->getType()); + if (cast(Ty->getElementType())->isVarArg()) { + outputInstrVarArgsCall(II, Opcode, Table, Type); + return; + } + } + + if (NumOperands <= 3) { + // Make sure that we take the type number into consideration. We don't want + // to overflow the field size for the instruction format we select. + // + unsigned MaxOpSlot = Type; + unsigned Slots[3]; Slots[0] = (1 << 12)-1; // Marker to signify 0 operands + + for (unsigned i = 0; i != NumOperands; ++i) { + int slot = Table.getSlot(I.getOperand(i)); + assert(slot != -1 && "Broken bytecode!"); + if (unsigned(slot) > MaxOpSlot) MaxOpSlot = unsigned(slot); + Slots[i] = unsigned(slot); + } + + // Handle the special cases for various instructions... + if (isa(I) || isa(I)) { + // Cast has to encode the destination type as the second argument in the + // packet, or else we won't know what type to cast to! + Slots[1] = Table.getSlot(I.getType()); + assert(Slots[1] != ~0U && "Cast return type unknown?"); + if (Slots[1] > MaxOpSlot) MaxOpSlot = Slots[1]; + NumOperands++; + } else if (const VANextInst *VANI = dyn_cast(&I)) { + Slots[1] = Table.getSlot(VANI->getArgType()); + assert(Slots[1] != ~0U && "va_next return type unknown?"); + if (Slots[1] > MaxOpSlot) MaxOpSlot = Slots[1]; + NumOperands++; + } else if (const GetElementPtrInst *GEP = dyn_cast(&I)) { + // We need to encode the type of sequential type indices into their slot # + unsigned Idx = 1; + for (gep_type_iterator I = gep_type_begin(GEP), E = gep_type_end(GEP); + I != E; ++I, ++Idx) + if (isa(*I)) { + unsigned IdxId; + switch (GEP->getOperand(Idx)->getType()->getTypeID()) { + default: assert(0 && "Unknown index type!"); + case Type::UIntTyID: IdxId = 0; break; + case Type::IntTyID: IdxId = 1; break; + case Type::ULongTyID: IdxId = 2; break; + case Type::LongTyID: IdxId = 3; break; + } + Slots[Idx] = (Slots[Idx] << 2) | IdxId; + if (Slots[Idx] > MaxOpSlot) MaxOpSlot = Slots[Idx]; + } + } + + // Decide which instruction encoding to use. This is determined primarily + // by the number of operands, and secondarily by whether or not the max + // operand will fit into the instruction encoding. More operands == fewer + // bits per operand. + // + switch (NumOperands) { + case 0: + case 1: + if (MaxOpSlot < (1 << 12)-1) { // -1 because we use 4095 to indicate 0 ops + outputInstructionFormat1(&I, Opcode, Slots, Type); + return; + } + break; + + case 2: + if (MaxOpSlot < (1 << 8)) { + outputInstructionFormat2(&I, Opcode, Slots, Type); + return; + } + break; + + case 3: + if (MaxOpSlot < (1 << 6)) { + outputInstructionFormat3(&I, Opcode, Slots, Type); + return; + } + break; + default: + break; + } + } + + // If we weren't handled before here, we either have a large number of + // operands or a large operand index that we are referring to. + outputInstructionFormat0(&I, Opcode, Table, Type); +} + +//===----------------------------------------------------------------------===// +//=== Block Output ===// +//===----------------------------------------------------------------------===// + +BytecodeWriter::BytecodeWriter(std::vector &o, const Module *M) : Out(o), Table(M) { // Emit the signature... static const unsigned char *Sig = (const unsigned char*)"llvm"; - output_data(Sig, Sig+4, Out); + output_data(Sig, Sig+4); // Emit the top level CLASS block. - BytecodeBlock ModuleBlock(BytecodeFormat::Module, Out); + BytecodeBlock ModuleBlock(BytecodeFormat::ModuleBlockID, *this, false, true); bool isBigEndian = M->getEndianness() == Module::BigEndian; bool hasLongPointers = M->getPointerSize() == Module::Pointer64; @@ -56,14 +758,14 @@ // Output the version identifier... we are currently on bytecode version #2, // which corresponds to LLVM v1.3. - unsigned Version = (2 << 4) | (unsigned)isBigEndian | (hasLongPointers << 1) | + unsigned Version = (3 << 4) | (unsigned)isBigEndian | (hasLongPointers << 1) | (hasNoEndianness << 2) | (hasNoPointerSize << 3); - output_vbr(Version, Out); - align32(Out); + output_vbr(Version); + align32(); // The Global type plane comes first { - BytecodeBlock CPool(BytecodeFormat::GlobalTypePlane, Out ); + BytecodeBlock CPool(BytecodeFormat::GlobalTypePlaneBlockID, *this ); outputTypes(Type::FirstDerivedTyID); } @@ -94,7 +796,7 @@ unsigned NumEntries = Types.size() - TypeNum; // Output type header: [num entries] - output_vbr(NumEntries, Out); + output_vbr(NumEntries); for (unsigned i = TypeNum; i < TypeNum+NumEntries; ++i) outputType(Types[i]); @@ -126,12 +828,12 @@ // Output type header: [num entries][type id number] // - output_vbr(NC, Out); + output_vbr(NC); // Output the Type ID Number... int Slot = Table.getSlot(Plane.front()->getType()); assert (Slot != -1 && "Type in constant pool but not in function!!"); - output_vbr((unsigned)Slot, Out); + output_typeid((unsigned)Slot); for (unsigned i = ValNo; i < ValNo+NC; ++i) { const Value *V = Plane[i]; @@ -146,7 +848,7 @@ } void BytecodeWriter::outputConstants(bool isFunction) { - BytecodeBlock CPool(BytecodeFormat::ConstantPool, Out, + BytecodeBlock CPool(BytecodeFormat::ConstantPoolBlockID, *this, true /* Elide block if empty */); unsigned NumPlanes = Table.getNumPlanes(); @@ -189,7 +891,7 @@ } void BytecodeWriter::outputModuleInfoBlock(const Module *M) { - BytecodeBlock ModuleInfoBlock(BytecodeFormat::ModuleGlobalInfo, Out); + BytecodeBlock ModuleInfoBlock(BytecodeFormat::ModuleGlobalInfoBlockID, *this); // Output the types for the global variables in the module... for (Module::const_giterator I = M->gbegin(), End = M->gend(); I != End;++I) { @@ -200,37 +902,48 @@ // bit5+ = Slot # for type unsigned oSlot = ((unsigned)Slot << 5) | (getEncodedLinkage(I) << 2) | (I->hasInitializer() << 1) | (unsigned)I->isConstant(); - output_vbr(oSlot, Out); + output_vbr(oSlot ); // If we have an initializer, output it now. if (I->hasInitializer()) { Slot = Table.getSlot((Value*)I->getInitializer()); assert(Slot != -1 && "No slot for global var initializer!"); - output_vbr((unsigned)Slot, Out); + output_vbr((unsigned)Slot); } } - output_vbr((unsigned)Table.getSlot(Type::VoidTy), Out); + output_typeid((unsigned)Table.getSlot(Type::VoidTy)); // Output the types of the functions in this module... for (Module::const_iterator I = M->begin(), End = M->end(); I != End; ++I) { int Slot = Table.getSlot(I->getType()); assert(Slot != -1 && "Module const pool is broken!"); assert(Slot >= Type::FirstDerivedTyID && "Derived type not in range!"); - output_vbr((unsigned)Slot, Out); + output_typeid((unsigned)Slot); } - output_vbr((unsigned)Table.getSlot(Type::VoidTy), Out); + output_typeid((unsigned)Table.getSlot(Type::VoidTy)); + + // Put out the list of dependent libraries for the Module + Module::const_literator LI = M->lbegin(); + Module::const_literator LE = M->lend(); + output_vbr( unsigned(LE - LI) ); // Put out the number of dependent libraries + for ( ; LI != LE; ++LI ) { + output(*LI, /*aligned=*/false); + } + + // Output the target triple from the module + output(M->getTargetTriple(), /*aligned=*/ true); } void BytecodeWriter::outputInstructions(const Function *F) { - BytecodeBlock ILBlock(BytecodeFormat::InstructionList, Out); + BytecodeBlock ILBlock(BytecodeFormat::InstructionListBlockID, *this); for (Function::const_iterator BB = F->begin(), E = F->end(); BB != E; ++BB) for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I!=E; ++I) outputInstruction(*I); } void BytecodeWriter::outputFunction(const Function *F) { - BytecodeBlock FunctionBlock(BytecodeFormat::Function, Out); - output_vbr(getEncodedLinkage(F), Out); + BytecodeBlock FunctionBlock(BytecodeFormat::FunctionBlockID, *this); + output_vbr(getEncodedLinkage(F)); // If this is an external function, there is nothing else to emit! if (F->isExternal()) return; @@ -273,17 +986,17 @@ case 0: // Avoid emitting two vbr's if possible. case 1: case 2: - output_vbr((PlaneNo << 2) | End-StartNo, Out); + output_vbr((PlaneNo << 2) | End-StartNo); break; default: // Output the number of things. - output_vbr((unsigned(End-StartNo) << 2) | 3, Out); - output_vbr(PlaneNo, Out); // Emit the type plane this is + output_vbr((unsigned(End-StartNo) << 2) | 3); + output_typeid(PlaneNo); // Emit the type plane this is break; } for (unsigned i = StartNo; i != End; ++i) - output_vbr(Table.getGlobalSlot(Plane[i]), Out); + output_vbr(Table.getGlobalSlot(Plane[i])); } void BytecodeWriter::outputCompactionTypes(unsigned StartNo) { @@ -293,7 +1006,7 @@ // The compaction types may have been uncompactified back to the // global types. If so, we just write an empty table if (CTypes.size() == 0 ) { - output_vbr(0U, Out); + output_vbr(0U); return; } @@ -303,14 +1016,15 @@ unsigned NumTypes = CTypes.size() - StartNo; // Output the number of types. - output_vbr(NumTypes, Out); + output_vbr(NumTypes); for (unsigned i = StartNo; i < StartNo+NumTypes; ++i) - output_vbr(Table.getGlobalSlot(CTypes[i]), Out); + output_typeid(Table.getGlobalSlot(CTypes[i])); } void BytecodeWriter::outputCompactionTable() { - BytecodeBlock CTB(BytecodeFormat::CompactionTable, Out, true/*ElideIfEmpty*/); + BytecodeBlock CTB(BytecodeFormat::CompactionTableBlockID, *this, + true/*ElideIfEmpty*/); const std::vector > &CT =Table.getCompactionTable(); // First thing is first, emit the type compaction table if there is one. @@ -325,16 +1039,16 @@ // space! if ( MST.isEmpty() ) return; - BytecodeBlock SymTabBlock(BytecodeFormat::SymbolTable, Out, + BytecodeBlock SymTabBlock(BytecodeFormat::SymbolTableBlockID, *this, true/* ElideIfEmpty*/); //Symtab block header for types: [num entries] - output_vbr(MST.num_types(), Out); + output_vbr(MST.num_types()); for (SymbolTable::type_const_iterator TI = MST.type_begin(), TE = MST.type_end(); TI != TE; ++TI ) { //Symtab entry:[def slot #][name] - output_vbr((unsigned)Table.getSlot(TI->second), Out); - output(TI->first, Out, /*align=*/false); + output_typeid((unsigned)Table.getSlot(TI->second)); + output(TI->first, /*align=*/false); } // Now do each of the type planes in order. @@ -347,29 +1061,30 @@ if (I == End) continue; // Don't mess with an absent type... // Symtab block header: [num entries][type id number] - output_vbr(MST.type_size(PI->first), Out); + output_vbr(MST.type_size(PI->first)); Slot = Table.getSlot(PI->first); assert(Slot != -1 && "Type in symtab, but not in table!"); - output_vbr((unsigned)Slot, Out); + output_typeid((unsigned)Slot); for (; I != End; ++I) { // Symtab entry: [def slot #][name] Slot = Table.getSlot(I->second); assert(Slot != -1 && "Value in symtab but has no slot number!!"); - output_vbr((unsigned)Slot, Out); - output(I->first, Out, false); // Don't force alignment... + output_vbr((unsigned)Slot); + output(I->first, false); // Don't force alignment... } } } -void llvm::WriteBytecodeToFile(const Module *C, std::ostream &Out) { - assert(C && "You can't write a null module!!"); +void llvm::WriteBytecodeToFile(const Module *M, std::ostream &Out) { + assert(M && "You can't write a null module!!"); - std::deque Buffer; + std::vector Buffer; + Buffer.reserve(64 * 1024); // avoid lots of little reallocs // This object populates buffer for us... - BytecodeWriter BCW(Buffer, C); + BytecodeWriter BCW(Buffer, M); // Keep track of how much we've written... BytesWritten += Buffer.size(); @@ -379,7 +1094,7 @@ // chunks, until we're done. // - std::deque::const_iterator I = Buffer.begin(),E = Buffer.end(); + std::vector::const_iterator I = Buffer.begin(),E = Buffer.end(); while (I != E) { // Loop until it's all written // Scan to see how big this chunk is... const unsigned char *ChunkPtr = &*I; Index: llvm/lib/Bytecode/Writer/WriterInternals.h diff -u llvm/lib/Bytecode/Writer/WriterInternals.h:1.21 llvm/lib/Bytecode/Writer/WriterInternals.h:1.22 --- llvm/lib/Bytecode/Writer/WriterInternals.h:1.21 Sun Jul 4 06:44:27 2004 +++ llvm/lib/Bytecode/Writer/WriterInternals.h Sun Jul 25 13:07:36 2004 @@ -19,19 +19,21 @@ #ifndef LLVM_LIB_BYTECODE_WRITER_WRITERINTERNALS_H #define LLVM_LIB_BYTECODE_WRITER_WRITERINTERNALS_H -#include "WriterPrimitives.h" #include "SlotCalculator.h" #include "llvm/Bytecode/Writer.h" #include "llvm/Bytecode/Format.h" #include "llvm/Instruction.h" +#include "Support/DataTypes.h" +#include +#include namespace llvm { class BytecodeWriter { - std::deque &Out; + std::vector &Out; SlotCalculator Table; public: - BytecodeWriter(std::deque &o, const Module *M); + BytecodeWriter(std::vector &o, const Module *M); private: void outputConstants(bool isFunction); @@ -44,6 +46,25 @@ unsigned StartNo); void outputInstructions(const Function *F); void outputInstruction(const Instruction &I); + void outputInstructionFormat0(const Instruction *I, unsigned Opcode, + const SlotCalculator &Table, + unsigned Type); + void outputInstrVarArgsCall(const Instruction *I, + unsigned Opcode, + const SlotCalculator &Table, + unsigned Type) ; + inline void outputInstructionFormat1(const Instruction *I, + unsigned Opcode, + unsigned *Slots, + unsigned Type) ; + inline void outputInstructionFormat2(const Instruction *I, + unsigned Opcode, + unsigned *Slots, + unsigned Type) ; + inline void outputInstructionFormat3(const Instruction *I, + unsigned Opcode, + unsigned *Slots, + unsigned Type) ; void outputModuleInfoBlock(const Module *C); void outputSymbolTable(const SymbolTable &ST); @@ -52,48 +73,70 @@ unsigned StartNo); void outputConstant(const Constant *CPV); void outputType(const Type *T); -}; + /// @brief Unsigned integer output primitive + inline void output(unsigned i, int pos = -1); + + /// @brief Signed integer output primitive + inline void output(int i); + + /// @brief 64-bit variable bit rate output primitive. + inline void output_vbr(uint64_t i); + + /// @brief 32-bit variable bit rate output primitive. + inline void output_vbr(unsigned i); + + /// @brief Signed 64-bit variable bit rate output primitive. + inline void output_vbr(int64_t i); + + /// @brief Signed 32-bit variable bit rate output primitive. + inline void output_vbr(int i); + + /// Emit the minimal number of bytes that will bring us to 32 bit alignment. + /// @brief 32-bit alignment output primitive + inline void align32(); + inline void output(const std::string &s, bool Aligned = true); + inline void output_data(const void *Ptr, const void *End); + + inline void output_float(float& FloatVal); + inline void output_double(double& DoubleVal); + + inline void output_typeid(unsigned i); + + inline size_t size() const { return Out.size(); } + inline void resize(size_t S) { Out.resize(S); } + friend class BytecodeBlock; +}; /// BytecodeBlock - Little helper class is used by the bytecode writer to help /// do backpatching of bytecode block sizes really easily. It backpatches when /// it goes out of scope. /// class BytecodeBlock { + unsigned Id; unsigned Loc; - std::deque &Out; + BytecodeWriter& Writer; /// ElideIfEmpty - If this is true and the bytecode block ends up being empty, /// the block can remove itself from the output stream entirely. bool ElideIfEmpty; + /// If this is true then the block is written with a long format header using + /// a uint (32-bits) for both the block id and size. Otherwise, it uses the + /// short format which is a single uint with 27 bits for size and 5 bits for + /// the block id. Both formats are used in a bc file with version 1.3. + /// Previously only the long format was used. + bool HasLongFormat; + BytecodeBlock(const BytecodeBlock &); // do not implement void operator=(const BytecodeBlock &); // do not implement public: - inline BytecodeBlock(unsigned ID, std::deque &o, - bool elideIfEmpty = false) - : Out(o), ElideIfEmpty(elideIfEmpty) { - output(ID, Out); - output(0U, Out); // Reserve the space for the block size... - Loc = Out.size(); - } - - inline ~BytecodeBlock() { // Do backpatch when block goes out - // of scope... - if (Loc == Out.size() && ElideIfEmpty) { - // If the block is empty, and we are allowed to, do not emit the block at - // all! - Out.resize(Out.size()-8); - return; - } - - //cerr << "OldLoc = " << Loc << " NewLoc = " << NewLoc << " diff = " - // << (NewLoc-Loc) << endl; - output(unsigned(Out.size()-Loc), Out, int(Loc-4)); - align32(Out); // Blocks must ALWAYS be aligned - } + inline BytecodeBlock(unsigned ID, BytecodeWriter& w, + bool elideIfEmpty = false, bool hasLongFormat = false); + + inline ~BytecodeBlock(); }; } // End llvm namespace From llvm at cs.uiuc.edu Sun Jul 25 13:08:28 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun, 25 Jul 2004 13:08:28 -0500 Subject: [llvm-commits] CVS: llvm/lib/VMCore/AsmWriter.cpp Message-ID: <200407251808.NAA01129@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: AsmWriter.cpp updated: 1.149 -> 1.150 --- Log message: bug 263: http://llvm.cs.uiuc.edu/PR263 : Add ability to write target triple and dependent libraries information. --- Diffs of the changes: (+11 -0) Index: llvm/lib/VMCore/AsmWriter.cpp diff -u llvm/lib/VMCore/AsmWriter.cpp:1.149 llvm/lib/VMCore/AsmWriter.cpp:1.150 --- llvm/lib/VMCore/AsmWriter.cpp:1.149 Sat Jul 17 20:04:19 2004 +++ llvm/lib/VMCore/AsmWriter.cpp Sun Jul 25 13:08:18 2004 @@ -732,6 +732,17 @@ case Module::Pointer64: Out << "target pointersize = 64\n"; break; case Module::AnyPointerSize: break; } + Out << "target triple = \"" << M->getTargetTriple() << "\"\n"; + + // Loop over the dependent libraries and emit them + Out << "deplibs = [\n"; + for (Module::const_literator LI = M->lbegin(), LE = M->lend(); LI != LE; ) { + Out << "\"" << *LI << "\""; + ++LI; + if ( LI != LE ) + Out << ",\n"; + } + Out << " ]\n"; // Loop over the symbol table, emitting all named constants... printSymbolTable(M->getSymbolTable()); From llvm at cs.uiuc.edu Sun Jul 25 13:09:07 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun, 25 Jul 2004 13:09:07 -0500 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Module.cpp Message-ID: <200407251809.NAA01142@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Module.cpp updated: 1.53 -> 1.54 --- Log message: bug 263: http://llvm.cs.uiuc.edu/PR263 : Ensure the list of libraries is cleared. --- Diffs of the changes: (+1 -0) Index: llvm/lib/VMCore/Module.cpp diff -u llvm/lib/VMCore/Module.cpp:1.53 llvm/lib/VMCore/Module.cpp:1.54 --- llvm/lib/VMCore/Module.cpp:1.53 Sat Jul 17 18:53:23 2004 +++ llvm/lib/VMCore/Module.cpp Sun Jul 25 13:08:57 2004 @@ -75,6 +75,7 @@ GlobalList.setParent(0); FunctionList.clear(); FunctionList.setParent(0); + LibraryList.clear(); delete SymTab; } From llvm at cs.uiuc.edu Sun Jul 25 13:09:57 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun, 25 Jul 2004 13:09:57 -0500 Subject: [llvm-commits] CVS: llvm/test/Feature/properties.ll Message-ID: <200407251809.NAA01162@zion.cs.uiuc.edu> Changes in directory llvm/test/Feature: properties.ll updated: 1.1 -> 1.2 --- Log message: bug 263: http://llvm.cs.uiuc.edu/PR263 : Add target triple and dependent libraries support to this test. --- Diffs of the changes: (+2 -0) Index: llvm/test/Feature/properties.ll diff -u llvm/test/Feature/properties.ll:1.1 llvm/test/Feature/properties.ll:1.2 --- llvm/test/Feature/properties.ll:1.1 Tue Apr 22 14:06:48 2003 +++ llvm/test/Feature/properties.ll Sun Jul 25 13:09:47 2004 @@ -1,4 +1,6 @@ target endian = little target pointersize = 32 +target triple = "proc-vend-sys" +deplibs = [ "m", "c" ] From reid at x10sys.com Sun Jul 25 13:30:53 2004 From: reid at x10sys.com (Reid Spencer) Date: Sun, 25 Jul 2004 11:30:53 -0700 Subject: [llvm-commits] Bytecode Changes Message-ID: <1090780253.23180.14.camel@bashful.x10sys.com> Folks, I have committed my last round of byte code changes for the LLVM 1.3 release. These changes provide fixes for bugs 263, 401, and 402. The basic changes are: - support for dependent libraries list in modules - support for target triple in modules - smaller block header sizes (50% reduction) - pre-allocated buffer space for writing byte code files - various code cleanups These changes *should* be 100% transparent to you since the version number increased (to 3) with these changes. Reading of version 2 byte code has been tested and works well. You will only incur these changes if you cvs update the changes, rebuild the llvm tools set and (c) rebuild the runtime libraries. This change set passes 100% Feature, 100% Regression and the Olden test suite. Reid. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20040725/94acd3bc/attachment.bin From lattner at cs.uiuc.edu Sun Jul 25 13:32:12 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 25 Jul 2004 13:32:12 -0500 Subject: [llvm-commits] CVS: llvm/lib/Analysis/AliasSetTracker.cpp Message-ID: <200407251832.NAA06988@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: AliasSetTracker.cpp updated: 1.21 -> 1.22 --- Log message: Fix a latent bug in the AliasSetTracker that was exposed by the FreeInst additions and broke a bunch of programs last night. --- Diffs of the changes: (+2 -1) Index: llvm/lib/Analysis/AliasSetTracker.cpp diff -u llvm/lib/Analysis/AliasSetTracker.cpp:1.21 llvm/lib/Analysis/AliasSetTracker.cpp:1.22 --- llvm/lib/Analysis/AliasSetTracker.cpp:1.21 Sun Jul 25 02:57:37 2004 +++ llvm/lib/Analysis/AliasSetTracker.cpp Sun Jul 25 13:32:01 2004 @@ -198,7 +198,8 @@ AliasSet::HashNodePair &Entry = getEntryFor(Pointer); // Check to see if the pointer is already known... - if (Entry.second.hasAliasSet() && Size <= Entry.second.getSize()) { + if (Entry.second.hasAliasSet()) { + Entry.second.updateSize(Size); // Return the set! return *Entry.second.getAliasSet(*this)->getForwardedTarget(*this); } else if (AliasSet *AS = findAliasSetForPointer(Pointer, Size)) { From llvm at cs.uiuc.edu Sun Jul 25 16:28:29 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun, 25 Jul 2004 16:28:29 -0500 Subject: [llvm-commits] CVS: llvm/include/llvm/Module.h Message-ID: <200407252128.QAA02273@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: Module.h updated: 1.47 -> 1.48 --- Log message: Reduce the footprint of the dependent library interface Document the dependent library interface Constify the std::string& parameters in the dep lib interface. --- Diffs of the changes: (+18 -17) Index: llvm/include/llvm/Module.h diff -u llvm/include/llvm/Module.h:1.47 llvm/include/llvm/Module.h:1.48 --- llvm/include/llvm/Module.h:1.47 Sun Jul 25 12:52:27 2004 +++ llvm/include/llvm/Module.h Sun Jul 25 16:28:19 2004 @@ -62,8 +62,7 @@ typedef std::reverse_iterator const_reverse_iterator; // Library list iterators - typedef LibraryListType::iterator literator; - typedef LibraryListType::const_iterator const_literator; + typedef LibraryListType::const_iterator lib_iterator; enum Endianness { AnyEndianness, LittleEndian, BigEndian }; enum PointerSize { AnyPointerSize, Pointer32, Pointer64 }; @@ -93,7 +92,7 @@ const std::string& getModuleIdentifier() const { return ModuleID; } const std::string& getTargetTriple() const { return TargetTriple; } - void setTargetTriple(std::string& T) { TargetTriple = T; } + void setTargetTriple(const std::string& T) { TargetTriple = T; } /// Target endian information... Endianness getEndianness() const { return Endian; } @@ -226,21 +225,23 @@ inline const Function &back() const { return FunctionList.back(); } inline Function &back() { return FunctionList.back(); } - // LibraryList interface - inline literator lbegin() { return LibraryList.begin(); } - inline const_literator lbegin() const { return LibraryList.begin(); } - inline literator lend () { return LibraryList.end(); } - inline const_literator lend () const { return LibraryList.end(); } - - inline unsigned lsize() const { return LibraryList.size(); } - inline bool lempty() const { return LibraryList.empty(); } - inline const std::string& lfront() const { return LibraryList.front(); } - inline std::string& lfront() { return LibraryList.front(); } - inline const std::string& lback() const { return LibraryList.back(); } - inline std::string& lback() { return LibraryList.back(); } + //===--------------------------------------------------------------------===// + // List of dependent library access functionsns + + /// @brief Get a constant iterator to beginning of dependent library list. + inline lib_iterator lib_begin() const { return LibraryList.begin(); } + + /// @brief Get a constant iterator to end of dependent library list. + inline lib_iterator lib_end() const { return LibraryList.end(); } + + /// @brief Returns the number of items in the list of libraries. + inline unsigned lib_size() const { return LibraryList.size(); } + + /// @brief Add a library to the list of dependent libraries + inline void addLibrary(const std::string& Lib){ LibraryList.push_back(Lib); } - inline void linsert(std::string& Lib){ LibraryList.push_back(Lib); } - inline void lremove(std::string& Lib); + /// @brief Remove a library from the list of dependent libraries + inline void removeLibrary(const std::string& Lib); void print(std::ostream &OS) const { print(OS, 0); } void print(std::ostream &OS, AssemblyAnnotationWriter *AAW) const; From llvm at cs.uiuc.edu Sun Jul 25 16:29:53 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun, 25 Jul 2004 16:29:53 -0500 Subject: [llvm-commits] CVS: llvm/lib/VMCore/AsmWriter.cpp Message-ID: <200407252129.QAA02327@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: AsmWriter.cpp updated: 1.150 -> 1.151 --- Log message: Adjust to new Module.h interface for dependent libraries Only write the target triple and deplibs if they are non-empty. --- Diffs of the changes: (+12 -8) Index: llvm/lib/VMCore/AsmWriter.cpp diff -u llvm/lib/VMCore/AsmWriter.cpp:1.150 llvm/lib/VMCore/AsmWriter.cpp:1.151 --- llvm/lib/VMCore/AsmWriter.cpp:1.150 Sun Jul 25 13:08:18 2004 +++ llvm/lib/VMCore/AsmWriter.cpp Sun Jul 25 16:29:43 2004 @@ -732,17 +732,21 @@ case Module::Pointer64: Out << "target pointersize = 64\n"; break; case Module::AnyPointerSize: break; } - Out << "target triple = \"" << M->getTargetTriple() << "\"\n"; + if (M->getTargetTriple().size() > 0) + Out << "target triple = \"" << M->getTargetTriple() << "\"\n"; // Loop over the dependent libraries and emit them - Out << "deplibs = [\n"; - for (Module::const_literator LI = M->lbegin(), LE = M->lend(); LI != LE; ) { - Out << "\"" << *LI << "\""; - ++LI; - if ( LI != LE ) - Out << ",\n"; + if (M->lib_size() > 0) { + Out << "deplibs = [\n"; + for (Module::lib_iterator LI = M->lib_begin(), LE = M->lib_end(); + LI != LE; ) { + Out << "\"" << *LI << "\""; + ++LI; + if ( LI != LE ) + Out << ",\n"; + } + Out << " ]\n"; } - Out << " ]\n"; // Loop over the symbol table, emitting all named constants... printSymbolTable(M->getSymbolTable()); From llvm at cs.uiuc.edu Sun Jul 25 16:31:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun, 25 Jul 2004 16:31:01 -0500 Subject: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y Message-ID: <200407252131.QAA02367@zion.cs.uiuc.edu> Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.192 -> 1.193 --- Log message: Adjust to new Module.h interface for dependent libraries Remove mem leaks resulting from not freeing parse strings. --- Diffs of the changes: (+7 -8) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.192 llvm/lib/AsmParser/llvmAsmParser.y:1.193 --- llvm/lib/AsmParser/llvmAsmParser.y:1.192 Sun Jul 25 12:58:28 2004 +++ llvm/lib/AsmParser/llvmAsmParser.y Sun Jul 25 16:30:51 2004 @@ -1445,20 +1445,19 @@ ThrowException("Invalid pointer size: '" + utostr($3) + "'!"); } | TRIPLE '=' STRINGCONSTANT { - std::string triple($3); - CurModule.CurrentModule->setTargetTriple(triple); + CurModule.CurrentModule->setTargetTriple($3); + free($3); }; -LibrariesDefinition : '[' LibList ']' - ; +LibrariesDefinition : '[' LibList ']'; LibList : LibList ',' STRINGCONSTANT { - std::string lib($3); - CurModule.CurrentModule->linsert(lib); + CurModule.CurrentModule->addLibrary($3); + free($3); } | STRINGCONSTANT { - std::string lib($1); - CurModule.CurrentModule->linsert(lib); + CurModule.CurrentModule->addLibrary($1); + free($1); } | /* empty: end of list */ { } From llvm at cs.uiuc.edu Sun Jul 25 16:32:12 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun, 25 Jul 2004 16:32:12 -0500 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Writer/Writer.cpp Message-ID: <200407252132.QAA02391@zion.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Writer: Writer.cpp updated: 1.71 -> 1.72 --- Log message: Adjust to new Module.h interface for dependent libraries. --- Diffs of the changes: (+2 -2) Index: llvm/lib/Bytecode/Writer/Writer.cpp diff -u llvm/lib/Bytecode/Writer/Writer.cpp:1.71 llvm/lib/Bytecode/Writer/Writer.cpp:1.72 --- llvm/lib/Bytecode/Writer/Writer.cpp:1.71 Sun Jul 25 13:07:36 2004 +++ llvm/lib/Bytecode/Writer/Writer.cpp Sun Jul 25 16:32:02 2004 @@ -923,8 +923,8 @@ output_typeid((unsigned)Table.getSlot(Type::VoidTy)); // Put out the list of dependent libraries for the Module - Module::const_literator LI = M->lbegin(); - Module::const_literator LE = M->lend(); + Module::lib_iterator LI = M->lib_begin(); + Module::lib_iterator LE = M->lib_end(); output_vbr( unsigned(LE - LI) ); // Put out the number of dependent libraries for ( ; LI != LE; ++LI ) { output(*LI, /*aligned=*/false); From llvm at cs.uiuc.edu Sun Jul 25 16:33:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun, 25 Jul 2004 16:33:01 -0500 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Reader/Reader.h Message-ID: <200407252133.QAA02416@zion.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Reader: Reader.h updated: 1.8 -> 1.9 --- Log message: Don't create a backwards compatibility flag for something that was a regression bug introduced in release 1.2 --- Diffs of the changes: (+0 -4) Index: llvm/lib/Bytecode/Reader/Reader.h diff -u llvm/lib/Bytecode/Reader/Reader.h:1.8 llvm/lib/Bytecode/Reader/Reader.h:1.9 --- llvm/lib/Bytecode/Reader/Reader.h:1.8 Sun Jul 25 13:07:36 2004 +++ llvm/lib/Bytecode/Reader/Reader.h Sun Jul 25 16:32:51 2004 @@ -279,10 +279,6 @@ /// 2^32-1 bytes long. bool hasLongBlockHeaders; - /// LLVM 1.2 and earlier wrote floating point values in a platform specific - /// bit ordering. This was fixed in LLVM 1.3 - bool hasPlatformSpecificFloatingPoint; - /// LLVM 1.2 and earlier wrote type slot numbers as vbr_uint32. In LLVM 1.3 /// this has been reduced to vbr_uint24. It shouldn't make much difference /// since we haven't run into a module with > 24 million types, but for safety From llvm at cs.uiuc.edu Sun Jul 25 16:36:36 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun, 25 Jul 2004 16:36:36 -0500 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Reader/Reader.cpp Message-ID: <200407252136.QAA02439@zion.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Reader: Reader.cpp updated: 1.117 -> 1.118 --- Log message: Always write FP values correctly. Adjust for new Module.h interface for dependent libraries. Excise unused backwards compatibility flag. --- Diffs of the changes: (+21 -35) Index: llvm/lib/Bytecode/Reader/Reader.cpp diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.117 llvm/lib/Bytecode/Reader/Reader.cpp:1.118 --- llvm/lib/Bytecode/Reader/Reader.cpp:1.117 Sun Jul 25 13:07:36 2004 +++ llvm/lib/Bytecode/Reader/Reader.cpp Sun Jul 25 16:36:26 2004 @@ -156,38 +156,30 @@ /// Read a float value in little-endian order inline void BytecodeReader::read_float(float& FloatVal) { - if (hasPlatformSpecificFloatingPoint) { - read_data(&FloatVal, &FloatVal+1); - } else { - /// FIXME: This isn't optimal, it has size problems on some platforms - /// where FP is not IEEE. - union { - float f; - uint32_t i; - } FloatUnion; - FloatUnion.i = At[0] | (At[1] << 8) | (At[2] << 16) | (At[3] << 24); - At+=sizeof(uint32_t); - FloatVal = FloatUnion.f; - } + /// FIXME: This isn't optimal, it has size problems on some platforms + /// where FP is not IEEE. + union { + float f; + uint32_t i; + } FloatUnion; + FloatUnion.i = At[0] | (At[1] << 8) | (At[2] << 16) | (At[3] << 24); + At+=sizeof(uint32_t); + FloatVal = FloatUnion.f; } /// Read a double value in little-endian order inline void BytecodeReader::read_double(double& DoubleVal) { - if (hasPlatformSpecificFloatingPoint) { - read_data(&DoubleVal, &DoubleVal+1); - } else { - /// FIXME: This isn't optimal, it has size problems on some platforms - /// where FP is not IEEE. - union { - double d; - uint64_t i; - } DoubleUnion; - DoubleUnion.i = At[0] | (At[1] << 8) | (At[2] << 16) | (At[3] << 24) | - (uint64_t(At[4]) << 32) | (uint64_t(At[5]) << 40) | - (uint64_t(At[6]) << 48) | (uint64_t(At[7]) << 56); - At+=sizeof(uint64_t); - DoubleVal = DoubleUnion.d; - } + /// FIXME: This isn't optimal, it has size problems on some platforms + /// where FP is not IEEE. + union { + double d; + uint64_t i; + } DoubleUnion; + DoubleUnion.i = At[0] | (At[1] << 8) | (At[2] << 16) | (At[3] << 24) | + (uint64_t(At[4]) << 32) | (uint64_t(At[5]) << 40) | + (uint64_t(At[6]) << 48) | (uint64_t(At[7]) << 56); + At+=sizeof(uint64_t); + DoubleVal = DoubleUnion.d; } /// Read a block header and obtain its type and size @@ -1853,7 +1845,7 @@ std::string dep_lib; while( num_dep_libs-- ) { dep_lib = read_str(); - TheModule->linsert(dep_lib); + TheModule->addLibrary(dep_lib); } // Read target triple and place into the module @@ -1894,7 +1886,6 @@ hasRestrictedGEPTypes = false; hasTypeDerivedFromValue = false; hasLongBlockHeaders = false; - hasPlatformSpecificFloatingPoint = false; has32BitTypes = false; hasNoDependentLibraries = false; @@ -1934,11 +1925,6 @@ /// bits for block type. hasLongBlockHeaders = true; - /// LLVM 1.2 and earlier wrote floating point values in a platform specific - /// bit ordering. This was fixed in LLVM 1.3, but we still need to be backwards - /// compatible. - hasPlatformSpecificFloatingPoint = true; - /// LLVM 1.2 and earlier wrote type slot numbers as vbr_uint32. In LLVM 1.3 /// this has been reduced to vbr_uint24. It shouldn't make much difference /// since we haven't run into a module with > 24 million types, but for safety From llvm at cs.uiuc.edu Sun Jul 25 16:45:04 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun, 25 Jul 2004 16:45:04 -0500 Subject: [llvm-commits] CVS: llvm/lib/VMCore/AsmWriter.cpp Message-ID: <200407252145.QAA02486@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: AsmWriter.cpp updated: 1.151 -> 1.152 --- Log message: Avoid use of size(), which counts, in favor of other mechanisms. --- Diffs of the changes: (+5 -4) Index: llvm/lib/VMCore/AsmWriter.cpp diff -u llvm/lib/VMCore/AsmWriter.cpp:1.151 llvm/lib/VMCore/AsmWriter.cpp:1.152 --- llvm/lib/VMCore/AsmWriter.cpp:1.151 Sun Jul 25 16:29:43 2004 +++ llvm/lib/VMCore/AsmWriter.cpp Sun Jul 25 16:44:54 2004 @@ -732,14 +732,15 @@ case Module::Pointer64: Out << "target pointersize = 64\n"; break; case Module::AnyPointerSize: break; } - if (M->getTargetTriple().size() > 0) + if (!M->getTargetTriple().empty()) Out << "target triple = \"" << M->getTargetTriple() << "\"\n"; // Loop over the dependent libraries and emit them - if (M->lib_size() > 0) { + Module::lib_iterator LI= M->lib_begin(); + Module::lib_iterator LE= M->lib_end(); + if (LI != LE) { Out << "deplibs = [\n"; - for (Module::lib_iterator LI = M->lib_begin(), LE = M->lib_end(); - LI != LE; ) { + while ( LI != LE ) { Out << "\"" << *LI << "\""; ++LI; if ( LI != LE ) From llvm at cs.uiuc.edu Sun Jul 25 17:15:43 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun, 25 Jul 2004 17:15:43 -0500 Subject: [llvm-commits] CVS: llvm/docs/ReleaseNotes.html Message-ID: <200407252215.RAA02784@zion.cs.uiuc.edu> Changes in directory llvm/docs: ReleaseNotes.html updated: 1.220 -> 1.221 --- Log message: Bugs fixed. --- Diffs of the changes: (+5 -1) Index: llvm/docs/ReleaseNotes.html diff -u llvm/docs/ReleaseNotes.html:1.220 llvm/docs/ReleaseNotes.html:1.221 --- llvm/docs/ReleaseNotes.html:1.220 Fri Jul 23 14:41:13 2004 +++ llvm/docs/ReleaseNotes.html Sun Jul 25 17:15:33 2004 @@ -183,7 +183,11 @@ produced when linking C++ programs has been fixed.
  • lli Doesn't Handle Exceptions From Bytecode Reader
  • +
  • Global Vars Have (Somewhat) Limited + Type Range
  • operator<< on a Value* now prints the address of the object instead of its contents.
  • +
  • Bytecode Enhancements + Needed
  • [loopsimplify] Loop simplify is really slow on 252.eon
  • @@ -766,7 +770,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/07/23 19:41:13 $ + Last modified: $Date: 2004/07/25 22:15:33 $ From lattner at cs.uiuc.edu Sun Jul 25 17:36:46 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 25 Jul 2004 17:36:46 -0500 Subject: [llvm-commits] CVS: llvm/lib/Target/CBackend/Writer.cpp Message-ID: <200407252236.RAA32344@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/CBackend: Writer.cpp updated: 1.191 -> 1.192 --- Log message: Temporarily disable this code, as it is emitting LLVM_NAN("nan") which results in a call to the glibc 'nan' function because the initializer is not a string. This breaks when used in a global initializer. Try compiling this testcase for example: %X = global float --- Diffs of the changes: (+2 -2) Index: llvm/lib/Target/CBackend/Writer.cpp diff -u llvm/lib/Target/CBackend/Writer.cpp:1.191 llvm/lib/Target/CBackend/Writer.cpp:1.192 --- llvm/lib/Target/CBackend/Writer.cpp:1.191 Tue Jul 20 22:15:26 2004 +++ llvm/lib/Target/CBackend/Writer.cpp Sun Jul 25 17:36:35 2004 @@ -570,9 +570,9 @@ if (IsNAN(FPC->getValue())) { // The value is NaN if (FPC->getType() == Type::FloatTy) - Out << "LLVM_NANF(\"" << Num << "\") /*nan*/ "; + Out << "LLVM_NANF(\"0\") /*nan*/ "; else - Out << "LLVM_NAN(\"" << Num << "\") /*nan*/ "; + Out << "LLVM_NAN(\"0\") /*nan*/ "; } else if (IsInf(FPC->getValue())) { // The value is Inf if (FPC->getValue() < 0) Out << "-"; From lattner at cs.uiuc.edu Sun Jul 25 18:15:54 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 25 Jul 2004 18:15:54 -0500 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Reader/Reader.cpp Message-ID: <200407252315.SAA23387@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Reader: Reader.cpp updated: 1.118 -> 1.119 --- Log message: Fix a serious bug in the double constant reader. In particular, because (At[3] << 24) is an int type and it is being coerced to uint64_t, it was getting sign extended, causing us to get FFFFFFFFxxxxxxxx constants all of the time. --- Diffs of the changes: (+2 -1) Index: llvm/lib/Bytecode/Reader/Reader.cpp diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.118 llvm/lib/Bytecode/Reader/Reader.cpp:1.119 --- llvm/lib/Bytecode/Reader/Reader.cpp:1.118 Sun Jul 25 16:36:26 2004 +++ llvm/lib/Bytecode/Reader/Reader.cpp Sun Jul 25 18:15:44 2004 @@ -175,7 +175,8 @@ double d; uint64_t i; } DoubleUnion; - DoubleUnion.i = At[0] | (At[1] << 8) | (At[2] << 16) | (At[3] << 24) | + DoubleUnion.i = (uint64_t(At[0]) << 0) | (uint64_t(At[1]) << 8) | + (uint64_t(At[2]) << 16) | (uint64_t(At[3]) << 24) | (uint64_t(At[4]) << 32) | (uint64_t(At[5]) << 40) | (uint64_t(At[6]) << 48) | (uint64_t(At[7]) << 56); At+=sizeof(uint64_t); From lattner at cs.uiuc.edu Sun Jul 25 20:23:09 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 25 Jul 2004 20:23:09 -0500 Subject: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y Message-ID: <200407260123.UAA28689@apoc.cs.uiuc.edu> Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.193 -> 1.194 --- Log message: Fix an extremely serious regression that was causing LLVM basic blocks to be scrambled around almost at random, having really bad effects on icache locality. --- Diffs of the changes: (+6 -0) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.193 llvm/lib/AsmParser/llvmAsmParser.y:1.194 --- llvm/lib/AsmParser/llvmAsmParser.y:1.193 Sun Jul 25 16:30:51 2004 +++ llvm/lib/AsmParser/llvmAsmParser.y Sun Jul 25 20:22:59 2004 @@ -383,6 +383,12 @@ ThrowException("Redefinition of label " + ID.getName()); ID.destroy(); // Free strdup'd memory. + + // Make sure to move the basic block to the correct location in the + // function, instead of leaving it inserted wherever it was first + // referenced. + CurFun.CurrentFunction->getBasicBlockList().remove(BB); + CurFun.CurrentFunction->getBasicBlockList().push_back(BB); return BB; } From lattner at cs.uiuc.edu Sun Jul 25 20:40:30 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 25 Jul 2004 20:40:30 -0500 Subject: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y Message-ID: <200407260140.UAA29615@apoc.cs.uiuc.edu> Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.194 -> 1.195 --- Log message: Fix bug in previous patch :( --- Diffs of the changes: (+12 -6) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.194 llvm/lib/AsmParser/llvmAsmParser.y:1.195 --- llvm/lib/AsmParser/llvmAsmParser.y:1.194 Sun Jul 25 20:22:59 2004 +++ llvm/lib/AsmParser/llvmAsmParser.y Sun Jul 25 20:40:20 2004 @@ -383,12 +383,6 @@ ThrowException("Redefinition of label " + ID.getName()); ID.destroy(); // Free strdup'd memory. - - // Make sure to move the basic block to the correct location in the - // function, instead of leaving it inserted wherever it was first - // referenced. - CurFun.CurrentFunction->getBasicBlockList().remove(BB); - CurFun.CurrentFunction->getBasicBlockList().push_back(BB); return BB; } @@ -1685,9 +1679,21 @@ } | /* empty */ { $$ = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true); + + // Make sure to move the basic block to the correct location in the + // function, instead of leaving it inserted wherever it was first + // referenced. + CurFun.CurrentFunction->getBasicBlockList().remove(CurBB); + CurFun.CurrentFunction->getBasicBlockList().push_back(CurBB); } | LABELSTR { $$ = CurBB = getBBVal(ValID::create($1), true); + + // Make sure to move the basic block to the correct location in the + // function, instead of leaving it inserted wherever it was first + // referenced. + CurFun.CurrentFunction->getBasicBlockList().remove(CurBB); + CurFun.CurrentFunction->getBasicBlockList().push_back(CurBB); }; BBTerminatorInst : RET ResolvedVal { // Return with a result... From lattner at cs.uiuc.edu Sun Jul 25 21:47:22 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 25 Jul 2004 21:47:22 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/IndVarSimplify.cpp Message-ID: <200407260247.VAA31303@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: IndVarSimplify.cpp updated: 1.67 -> 1.68 --- Log message: Throttle back indvar substitution from creating multiplies in loops. This is bad bad bad. --- Diffs of the changes: (+3 -3) Index: llvm/lib/Transforms/Scalar/IndVarSimplify.cpp diff -u llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1.67 llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1.68 --- llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1.67 Thu Jun 24 01:49:18 2004 +++ llvm/lib/Transforms/Scalar/IndVarSimplify.cpp Sun Jul 25 21:47:12 2004 @@ -607,9 +607,9 @@ // variable. Doing so will put expensive multiply instructions inside // of the loop. For now just disable indvar subst on anything more // complex than a linear addrec. - if (!isa(SCEV) || - cast(SCEV)->getNumOperands() < 3) - IndVars.push_back(std::make_pair(PN, SCEV)); + if (SCEVAddRecExpr *AR = dyn_cast(SCEV)) + if (AR->getNumOperands() == 2 && isa(AR->getOperand(1))) + IndVars.push_back(std::make_pair(PN, SCEV)); } // If there are no induction variables in the loop, there is nothing more to