From evan.cheng at apple.com Mon Aug 18 03:09:03 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 18 Aug 2008 08:09:03 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r54910 - /llvm-gcc-4.2/trunk/gcc/llvm-linker-hack.cpp Message-ID: <200808180809.m7I893q3015726@zion.cs.uiuc.edu> Author: evancheng Date: Mon Aug 18 03:09:02 2008 New Revision: 54910 URL: http://llvm.org/viewvc/llvm-project?rev=54910&view=rev Log: Unbreak the build: createLoadValueNumberingPass has been removed. Modified: llvm-gcc-4.2/trunk/gcc/llvm-linker-hack.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-linker-hack.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-linker-hack.cpp?rev=54910&r1=54909&r2=54910&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-linker-hack.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-linker-hack.cpp Mon Aug 18 03:09:02 2008 @@ -76,7 +76,6 @@ llvm::createSimplifyLibCallsPass(); llvm::createArgumentPromotionPass(); llvm::createDeadArgEliminationPass(); - llvm::createLoadValueNumberingPass(); llvm::createTailCallEliminationPass(); llvm::createDeadStoreEliminationPass(); llvm::createIPConstantPropagationPass(); From resistor at mac.com Mon Aug 18 03:16:39 2008 From: resistor at mac.com (Owen Anderson) Date: Mon, 18 Aug 2008 08:16:39 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r54911 - /llvm-gcc-4.2/trunk/gcc/llvm-linker-hack.cpp Message-ID: <200808180816.m7I8GdSM015970@zion.cs.uiuc.edu> Author: resistor Date: Mon Aug 18 03:16:39 2008 New Revision: 54911 URL: http://llvm.org/viewvc/llvm-project?rev=54911&view=rev Log: This header is no more. Modified: llvm-gcc-4.2/trunk/gcc/llvm-linker-hack.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-linker-hack.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-linker-hack.cpp?rev=54911&r1=54910&r2=54911&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-linker-hack.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-linker-hack.cpp Mon Aug 18 03:16:39 2008 @@ -23,7 +23,6 @@ #include "llvm/ModuleProvider.h" #include "llvm/Analysis/Verifier.h" #include "llvm/Transforms/Scalar.h" -#include "llvm/Analysis/LoadValueNumbering.h" #include "llvm/Transforms/IPO.h" #include "llvm/Bitcode/ReaderWriter.h" #include "llvm/CodeGen/ScheduleDAG.h" From evan.cheng at apple.com Mon Aug 18 03:52:48 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 18 Aug 2008 08:52:48 -0000 Subject: [llvm-commits] [llvm] r54913 - /llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Message-ID: <200808180852.m7I8qm48017036@zion.cs.uiuc.edu> Author: evancheng Date: Mon Aug 18 03:52:48 2008 New Revision: 54913 URL: http://llvm.org/viewvc/llvm-project?rev=54913&view=rev Log: ARM asm printer can't handle dwarf info yet. Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp?rev=54913&r1=54912&r2=54913&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Mon Aug 18 03:52:48 2008 @@ -231,7 +231,8 @@ O << CurrentFnName << ":\n"; // Emit pre-function debug information. - DW.BeginFunction(&MF); + // FIXME: Dwarf support. + //DW.BeginFunction(&MF); if (Subtarget->isTargetDarwin()) { // If the function is empty, then we need to emit *something*. Otherwise, @@ -262,7 +263,8 @@ O << "\t.size " << CurrentFnName << ", .-" << CurrentFnName << "\n"; // Emit post-function debug information. - DW.EndFunction(); + // FIXME: Dwarf support. + //DW.EndFunction(); return false; } @@ -802,14 +804,16 @@ bool ARMAsmPrinter::doInitialization(Module &M) { // Emit initial debug information. - DW.BeginModule(&M); + // FIXME: Dwarf support. + //DW.BeginModule(&M); bool Result = AsmPrinter::doInitialization(M); // AsmPrinter::doInitialization should have done this analysis. MMI = getAnalysisToUpdate(); assert(MMI); - DW.SetModuleInfo(MMI); + // FIXME: Dwarf support. + //DW.SetModuleInfo(MMI); // Darwin wants symbols to be quoted if they have complex names. if (Subtarget->isTargetDarwin()) @@ -1003,7 +1007,8 @@ } // Emit initial debug information. - DW.EndModule(); + // FIXME: Dwarf support. + //DW.EndModule(); // Funny Darwin hack: This flag tells the linker that no global symbols // contain code that falls through to other global symbols (e.g. the obvious @@ -1013,7 +1018,8 @@ O << "\t.subsections_via_symbols\n"; } else { // Emit final debug information for ELF. - DW.EndModule(); + // FIXME: Dwarf support. + //DW.EndModule(); } return AsmPrinter::doFinalization(M); From nicolas.geoffray at lip6.fr Mon Aug 18 09:53:59 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 18 Aug 2008 14:53:59 -0000 Subject: [llvm-commits] [llvm] r54920 - /llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp Message-ID: <200808181454.m7IEs08j028580@zion.cs.uiuc.edu> Author: geoffray Date: Mon Aug 18 09:53:56 2008 New Revision: 54920 URL: http://llvm.org/viewvc/llvm-project?rev=54920&view=rev Log: Register the frame register function when allocating the JIT, so that lli works out of the box with -enable-eh. Modified: llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp Modified: llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp?rev=54920&r1=54919&r2=54920&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp Mon Aug 18 09:53:56 2008 @@ -78,11 +78,6 @@ ExecutionEngine *EE = JIT::createJIT(MP, ErrorStr, JMM, Fast); if (!EE) return 0; - // Register routine for informing unwinding runtime about new EH frames -#if defined(__GNUC__) - EE->InstallExceptionTableRegister(__register_frame); -#endif - // Make sure we can resolve symbols in the program as well. The zero arg // to the function tells DynamicLibrary to load the program, not a library. sys::DynamicLibrary::LoadLibraryPermanently(0, ErrorStr); @@ -111,6 +106,11 @@ abort(); } + // Register routine for informing unwinding runtime about new EH frames +#if defined(__GNUC__) + InstallExceptionTableRegister(__register_frame); +#endif + // Initialize passes. PM.doInitialization(); } From gordonhenriksen at mac.com Mon Aug 18 12:32:41 2008 From: gordonhenriksen at mac.com (Gordon Henriksen) Date: Mon, 18 Aug 2008 17:32:41 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r54921 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Message-ID: <200808181732.m7IHWgqR001170@zion.cs.uiuc.edu> Author: gordon Date: Mon Aug 18 12:32:41 2008 New Revision: 54921 URL: http://llvm.org/viewvc/llvm-project?rev=54921&view=rev Log: Method was renamed. Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=54921&r1=54920&r2=54921&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Mon Aug 18 12:32:41 2008 @@ -1504,7 +1504,7 @@ // Emits code to do something for a type attribute void TreeToLLVM::EmitTypeGcroot(Value *V, tree decl) { // GC intrinsics can only be used in functions which specify a collector. - Fn->setCollector("shadow-stack"); + Fn->setGC("shadow-stack"); Function *gcrootFun = Intrinsic::getDeclaration(TheModule, Intrinsic::gcroot); From resistor at mac.com Mon Aug 18 13:05:32 2008 From: resistor at mac.com (Owen Anderson) Date: Mon, 18 Aug 2008 18:05:32 -0000 Subject: [llvm-commits] [llvm] r54924 - in /llvm/trunk: include/llvm/CodeGen/LiveIntervalAnalysis.h lib/CodeGen/LiveIntervalAnalysis.cpp Message-ID: <200808181805.m7II5WWM002218@zion.cs.uiuc.edu> Author: resistor Date: Mon Aug 18 13:05:32 2008 New Revision: 54924 URL: http://llvm.org/viewvc/llvm-project?rev=54924&view=rev Log: Resurrect some ancient code to add spill ranges without attempting folding, remat, or splitting. This code has been updated to current APIs in so far as it compiles and, in theory, works, but does not take advantage of recent advancements. For instance, it could be improved by using MachineRegisterInfo::use_iterator. Modified: llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Modified: llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h?rev=54924&r1=54923&r2=54924&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h (original) +++ llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h Mon Aug 18 13:05:32 2008 @@ -323,6 +323,13 @@ addIntervalsForSpills(const LiveInterval& i, const MachineLoopInfo *loopInfo, VirtRegMap& vrm, float &SSWeight); + + /// addIntervalsForSpillsFast - Quickly create new intervals for spilled + /// defs / uses without remat or splitting. + std::vector + addIntervalsForSpillsFast(const LiveInterval &li, + const MachineLoopInfo *loopInfo, + VirtRegMap &vrm, float& SSWeight); /// spillPhysRegAroundRegDefsUses - Spill the specified physical register /// around all defs and uses of the specified interval. Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=54924&r1=54923&r2=54924&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Mon Aug 18 13:05:32 2008 @@ -1598,6 +1598,111 @@ std::vector LiveIntervals:: +addIntervalsForSpillsFast(const LiveInterval &li, + const MachineLoopInfo *loopInfo, + VirtRegMap &vrm, float& SSWeight) { + unsigned slot = vrm.assignVirt2StackSlot(li.reg); + + // since this is called after the analysis is done we don't know if + // LiveVariables is available + lv_ = getAnalysisToUpdate(); + + std::vector added; + + assert(li.weight != HUGE_VALF && + "attempt to spill already spilled interval!"); + + DOUT << "\t\t\t\tadding intervals for spills for interval: "; + DEBUG(li.dump()); + DOUT << '\n'; + + const TargetRegisterClass* rc = mri_->getRegClass(li.reg); + + for (LiveInterval::Ranges::const_iterator + i = li.ranges.begin(), e = li.ranges.end(); i != e; ++i) { + unsigned index = getBaseIndex(i->start); + unsigned end = getBaseIndex(i->end-1) + InstrSlots::NUM; + for (; index != end; index += InstrSlots::NUM) { + // skip deleted instructions + while (index != end && !getInstructionFromIndex(index)) + index += InstrSlots::NUM; + if (index == end) break; + + MachineInstr *MI = getInstructionFromIndex(index); + + for (unsigned i = 0; i != MI->getNumOperands(); ++i) { + MachineOperand& mop = MI->getOperand(i); + if (mop.isRegister() && mop.getReg() == li.reg) { + // Create a new virtual register for the spill interval. + unsigned NewVReg = mri_->createVirtualRegister(rc); + + // Scan all of the operands of this instruction rewriting operands + // to use NewVReg instead of li.reg as appropriate. We do this for + // two reasons: + // + // 1. If the instr reads the same spilled vreg multiple times, we + // want to reuse the NewVReg. + // 2. If the instr is a two-addr instruction, we are required to + // keep the src/dst regs pinned. + // + // Keep track of whether we replace a use and/or def so that we can + // create the spill interval with the appropriate range. + mop.setReg(NewVReg); + + bool HasUse = mop.isUse(); + bool HasDef = mop.isDef(); + for (unsigned j = i+1, e = MI->getNumOperands(); j != e; ++j) { + if (MI->getOperand(j).isReg() && + MI->getOperand(j).getReg() == li.reg) { + MI->getOperand(j).setReg(NewVReg); + HasUse |= MI->getOperand(j).isUse(); + HasDef |= MI->getOperand(j).isDef(); + } + } + + // create a new register for this spill + vrm.grow(); + vrm.assignVirt2StackSlot(NewVReg, slot); + LiveInterval &nI = getOrCreateInterval(NewVReg); + assert(nI.empty()); + + // the spill weight is now infinity as it + // cannot be spilled again + nI.weight = HUGE_VALF; + + if (HasUse) { + LiveRange LR(getLoadIndex(index), getUseIndex(index), + nI.getNextValue(~0U, 0, getVNInfoAllocator())); + DOUT << " +" << LR; + nI.addRange(LR); + } + if (HasDef) { + LiveRange LR(getDefIndex(index), getStoreIndex(index), + nI.getNextValue(~0U, 0, getVNInfoAllocator())); + DOUT << " +" << LR; + nI.addRange(LR); + } + + added.push_back(&nI); + + // update live variables if it is available + if (lv_) + lv_->addVirtualRegisterKilled(NewVReg, MI); + + DOUT << "\t\t\t\tadded new interval: "; + DEBUG(nI.dump()); + DOUT << '\n'; + } + } + } + } + + SSWeight = HUGE_VALF; + + return added; +} + +std::vector LiveIntervals:: addIntervalsForSpills(const LiveInterval &li, const MachineLoopInfo *loopInfo, VirtRegMap &vrm, float &SSWeight) { From kremenek at apple.com Mon Aug 18 13:17:27 2008 From: kremenek at apple.com (Ted Kremenek) Date: Mon, 18 Aug 2008 18:17:27 -0000 Subject: [llvm-commits] [llvm] r54926 - /llvm/tags/checker/checker-78/ Message-ID: <200808181817.m7IIHRBi002594@zion.cs.uiuc.edu> Author: kremenek Date: Mon Aug 18 13:17:27 2008 New Revision: 54926 URL: http://llvm.org/viewvc/llvm-project?rev=54926&view=rev Log: Tagging checker-78. Added: llvm/tags/checker/checker-78/ - copied from r54925, llvm/trunk/ From isanbard at gmail.com Mon Aug 18 13:17:41 2008 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 18 Aug 2008 11:17:41 -0700 Subject: [llvm-commits] [llvm-gcc-4.2] r54921 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp In-Reply-To: <200808181732.m7IHWgqR001170@zion.cs.uiuc.edu> References: <200808181732.m7IHWgqR001170@zion.cs.uiuc.edu> Message-ID: <16e5fdf90808181117w1a9c5eaeuf576290cb0f5fb36@mail.gmail.com> Thanks, Gordon. -bw On Mon, Aug 18, 2008 at 10:32 AM, Gordon Henriksen wrote: > Author: gordon > Date: Mon Aug 18 12:32:41 2008 > New Revision: 54921 > > URL: http://llvm.org/viewvc/llvm-project?rev=54921&view=rev > Log: > Method was renamed. > > Modified: > llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp > > Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=54921&r1=54920&r2=54921&view=diff > > ============================================================================== > --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) > +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Mon Aug 18 12:32:41 2008 > @@ -1504,7 +1504,7 @@ > // Emits code to do something for a type attribute > void TreeToLLVM::EmitTypeGcroot(Value *V, tree decl) { > // GC intrinsics can only be used in functions which specify a collector. > - Fn->setCollector("shadow-stack"); > + Fn->setGC("shadow-stack"); > > Function *gcrootFun = Intrinsic::getDeclaration(TheModule, > Intrinsic::gcroot); > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From isanbard at gmail.com Mon Aug 18 13:29:54 2008 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 18 Aug 2008 18:29:54 -0000 Subject: [llvm-commits] [llvm] r54929 - /llvm/trunk/test/Transforms/LoopStrengthReduce/2008-08-14-ShadowIV.ll Message-ID: <200808181829.m7IITtki003067@zion.cs.uiuc.edu> Author: void Date: Mon Aug 18 13:29:54 2008 New Revision: 54929 URL: http://llvm.org/viewvc/llvm-project?rev=54929&view=rev Log: XFAIL this test for now. Modified: llvm/trunk/test/Transforms/LoopStrengthReduce/2008-08-14-ShadowIV.ll Modified: llvm/trunk/test/Transforms/LoopStrengthReduce/2008-08-14-ShadowIV.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopStrengthReduce/2008-08-14-ShadowIV.ll?rev=54929&r1=54928&r2=54929&view=diff ============================================================================== --- llvm/trunk/test/Transforms/LoopStrengthReduce/2008-08-14-ShadowIV.ll (original) +++ llvm/trunk/test/Transforms/LoopStrengthReduce/2008-08-14-ShadowIV.ll Mon Aug 18 13:29:54 2008 @@ -1,4 +1,5 @@ ; RUN: llvm-as < %s | opt -loop-reduce | llvm-dis | grep "phi double" | count 1 +; XFAIL: * define void @foobar(i32 %n) nounwind { entry: From evan.cheng at apple.com Mon Aug 18 13:35:33 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 18 Aug 2008 11:35:33 -0700 Subject: [llvm-commits] [llvm] r54924 - in /llvm/trunk: include/llvm/CodeGen/LiveIntervalAnalysis.h lib/CodeGen/LiveIntervalAnalysis.cpp In-Reply-To: <200808181805.m7II5WWM002218@zion.cs.uiuc.edu> References: <200808181805.m7II5WWM002218@zion.cs.uiuc.edu> Message-ID: <8230251C-A119-47BE-A4AE-D3EE512CE6B1@apple.com> On Aug 18, 2008, at 11:05 AM, Owen Anderson wrote: > > + > + // since this is called after the analysis is done we don't know if > + // LiveVariables is available > + lv_ = getAnalysisToUpdate(); Thanks. Please remove dependency on LiveVariables. It's not there in the non-fast version. Evan > > + > + std::vector added; > + > + assert(li.weight != HUGE_VALF && > + "attempt to spill already spilled interval!"); > + > + DOUT << "\t\t\t\tadding intervals for spills for interval: "; > + DEBUG(li.dump()); > + DOUT << '\n'; > + > + const TargetRegisterClass* rc = mri_->getRegClass(li.reg); > + > + for (LiveInterval::Ranges::const_iterator > + i = li.ranges.begin(), e = li.ranges.end(); i != e; ++i) { > + unsigned index = getBaseIndex(i->start); > + unsigned end = getBaseIndex(i->end-1) + InstrSlots::NUM; > + for (; index != end; index += InstrSlots::NUM) { > + // skip deleted instructions > + while (index != end && !getInstructionFromIndex(index)) > + index += InstrSlots::NUM; > + if (index == end) break; > + > + MachineInstr *MI = getInstructionFromIndex(index); > + > + for (unsigned i = 0; i != MI->getNumOperands(); ++i) { > + MachineOperand& mop = MI->getOperand(i); > + if (mop.isRegister() && mop.getReg() == li.reg) { > + // Create a new virtual register for the spill interval. > + unsigned NewVReg = mri_->createVirtualRegister(rc); > + > + // Scan all of the operands of this instruction rewriting > operands > + // to use NewVReg instead of li.reg as appropriate. We > do this for > + // two reasons: > + // > + // 1. If the instr reads the same spilled vreg multiple > times, we > + // want to reuse the NewVReg. > + // 2. If the instr is a two-addr instruction, we are > required to > + // keep the src/dst regs pinned. > + // > + // Keep track of whether we replace a use and/or def so > that we can > + // create the spill interval with the appropriate range. > + mop.setReg(NewVReg); > + > + bool HasUse = mop.isUse(); > + bool HasDef = mop.isDef(); > + for (unsigned j = i+1, e = MI->getNumOperands(); j != e; + > +j) { > + if (MI->getOperand(j).isReg() && > + MI->getOperand(j).getReg() == li.reg) { > + MI->getOperand(j).setReg(NewVReg); > + HasUse |= MI->getOperand(j).isUse(); > + HasDef |= MI->getOperand(j).isDef(); > + } > + } > + > + // create a new register for this spill > + vrm.grow(); > + vrm.assignVirt2StackSlot(NewVReg, slot); > + LiveInterval &nI = getOrCreateInterval(NewVReg); > + assert(nI.empty()); > + > + // the spill weight is now infinity as it > + // cannot be spilled again > + nI.weight = HUGE_VALF; > + > + if (HasUse) { > + LiveRange LR(getLoadIndex(index), getUseIndex(index), > + nI.getNextValue(~0U, 0, > getVNInfoAllocator())); > + DOUT << " +" << LR; > + nI.addRange(LR); > + } > + if (HasDef) { > + LiveRange LR(getDefIndex(index), getStoreIndex(index), > + nI.getNextValue(~0U, 0, > getVNInfoAllocator())); > + DOUT << " +" << LR; > + nI.addRange(LR); > + } > + > + added.push_back(&nI); > + > + // update live variables if it is available > + if (lv_) > + lv_->addVirtualRegisterKilled(NewVReg, MI); > + > + DOUT << "\t\t\t\tadded new interval: "; > + DEBUG(nI.dump()); > + DOUT << '\n'; > + } > + } > + } > + } > + > + SSWeight = HUGE_VALF; > + > + return added; > +} > + > +std::vector LiveIntervals:: > addIntervalsForSpills(const LiveInterval &li, > const MachineLoopInfo *loopInfo, VirtRegMap > &vrm, > float &SSWeight) { > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From resistor at mac.com Mon Aug 18 13:38:13 2008 From: resistor at mac.com (Owen Anderson) Date: Mon, 18 Aug 2008 18:38:13 -0000 Subject: [llvm-commits] [llvm] r54930 - /llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Message-ID: <200808181838.m7IIcD81003311@zion.cs.uiuc.edu> Author: resistor Date: Mon Aug 18 13:38:12 2008 New Revision: 54930 URL: http://llvm.org/viewvc/llvm-project?rev=54930&view=rev Log: Simplify the fast-patch interval spilling by using MachineRegisterInfo::reg_iterator. Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=54930&r1=54929&r2=54930&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Mon Aug 18 13:38:12 2008 @@ -1618,83 +1618,61 @@ const TargetRegisterClass* rc = mri_->getRegClass(li.reg); - for (LiveInterval::Ranges::const_iterator - i = li.ranges.begin(), e = li.ranges.end(); i != e; ++i) { - unsigned index = getBaseIndex(i->start); - unsigned end = getBaseIndex(i->end-1) + InstrSlots::NUM; - for (; index != end; index += InstrSlots::NUM) { - // skip deleted instructions - while (index != end && !getInstructionFromIndex(index)) - index += InstrSlots::NUM; - if (index == end) break; - - MachineInstr *MI = getInstructionFromIndex(index); + DenseMap VRegMap; + DenseMap VNMap; - for (unsigned i = 0; i != MI->getNumOperands(); ++i) { - MachineOperand& mop = MI->getOperand(i); - if (mop.isRegister() && mop.getReg() == li.reg) { - // Create a new virtual register for the spill interval. - unsigned NewVReg = mri_->createVirtualRegister(rc); - - // Scan all of the operands of this instruction rewriting operands - // to use NewVReg instead of li.reg as appropriate. We do this for - // two reasons: - // - // 1. If the instr reads the same spilled vreg multiple times, we - // want to reuse the NewVReg. - // 2. If the instr is a two-addr instruction, we are required to - // keep the src/dst regs pinned. - // - // Keep track of whether we replace a use and/or def so that we can - // create the spill interval with the appropriate range. - mop.setReg(NewVReg); - - bool HasUse = mop.isUse(); - bool HasDef = mop.isDef(); - for (unsigned j = i+1, e = MI->getNumOperands(); j != e; ++j) { - if (MI->getOperand(j).isReg() && - MI->getOperand(j).getReg() == li.reg) { - MI->getOperand(j).setReg(NewVReg); - HasUse |= MI->getOperand(j).isUse(); - HasDef |= MI->getOperand(j).isDef(); - } - } - - // create a new register for this spill - vrm.grow(); - vrm.assignVirt2StackSlot(NewVReg, slot); - LiveInterval &nI = getOrCreateInterval(NewVReg); - assert(nI.empty()); - - // the spill weight is now infinity as it - // cannot be spilled again - nI.weight = HUGE_VALF; - - if (HasUse) { - LiveRange LR(getLoadIndex(index), getUseIndex(index), - nI.getNextValue(~0U, 0, getVNInfoAllocator())); - DOUT << " +" << LR; - nI.addRange(LR); - } - if (HasDef) { - LiveRange LR(getDefIndex(index), getStoreIndex(index), - nI.getNextValue(~0U, 0, getVNInfoAllocator())); - DOUT << " +" << LR; - nI.addRange(LR); - } - - added.push_back(&nI); - - // update live variables if it is available - if (lv_) - lv_->addVirtualRegisterKilled(NewVReg, MI); - - DOUT << "\t\t\t\tadded new interval: "; - DEBUG(nI.dump()); - DOUT << '\n'; - } - } + for (MachineRegisterInfo::reg_iterator RI = mri_->reg_begin(li.reg), + RE = mri_->reg_end(); RI != RE; ) { + // Create a new virtual register for the spill interval. + MachineOperand& MO = RI.getOperand(); + unsigned NewVReg = 0; + if (!VRegMap.count(MO.getParent())) + VRegMap[MO.getParent()] = NewVReg = mri_->createVirtualRegister(rc); + else + NewVReg = VRegMap[MO.getParent()]; + + // Increment iterator to avoid invalidation. + ++RI; + + MO.setReg(NewVReg); + + // create a new register for this spill + vrm.grow(); + vrm.assignVirt2StackSlot(NewVReg, slot); + LiveInterval &nI = getOrCreateInterval(NewVReg); + assert(nI.empty()); + + // the spill weight is now infinity as it + // cannot be spilled again + nI.weight = HUGE_VALF; + + unsigned index = getInstructionIndex(MO.getParent()); + bool HasUse = MO.isUse(); + bool HasDef = MO.isDef(); + if (!VNMap.count(MO.getParent())) + VNMap[MO.getParent()] = nI.getNextValue(~0U, 0, getVNInfoAllocator()); + if (HasUse) { + LiveRange LR(getLoadIndex(index), getUseIndex(index), + VNMap[MO.getParent()]); + DOUT << " +" << LR; + nI.addRange(LR); + } + if (HasDef) { + LiveRange LR(getDefIndex(index), getStoreIndex(index), + VNMap[MO.getParent()]); + DOUT << " +" << LR; + nI.addRange(LR); } + + added.push_back(&nI); + + // update live variables if it is available + if (lv_) + lv_->addVirtualRegisterKilled(NewVReg, MO.getParent()); + + DOUT << "\t\t\t\tadded new interval: "; + DEBUG(nI.dump()); + DOUT << '\n'; } SSWeight = HUGE_VALF; From kremenek at apple.com Mon Aug 18 13:38:37 2008 From: kremenek at apple.com (Ted Kremenek) Date: Mon, 18 Aug 2008 18:38:37 -0000 Subject: [llvm-commits] [llvm] r54932 - /llvm/tags/checker/checker-78/ Message-ID: <200808181838.m7IIcbM6003351@zion.cs.uiuc.edu> Author: kremenek Date: Mon Aug 18 13:38:37 2008 New Revision: 54932 URL: http://llvm.org/viewvc/llvm-project?rev=54932&view=rev Log: Removing checker-78. Removed: llvm/tags/checker/checker-78/ From kremenek at apple.com Mon Aug 18 13:38:55 2008 From: kremenek at apple.com (Ted Kremenek) Date: Mon, 18 Aug 2008 18:38:55 -0000 Subject: [llvm-commits] [llvm] r54934 - /llvm/tags/checker/checker-78/ Message-ID: <200808181838.m7IIctM1003382@zion.cs.uiuc.edu> Author: kremenek Date: Mon Aug 18 13:38:55 2008 New Revision: 54934 URL: http://llvm.org/viewvc/llvm-project?rev=54934&view=rev Log: Tagging checker-78. Added: llvm/tags/checker/checker-78/ - copied from r54933, llvm/trunk/ From evan.cheng at apple.com Mon Aug 18 13:43:43 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 18 Aug 2008 11:43:43 -0700 Subject: [llvm-commits] DebugInfoBuilder In-Reply-To: References: Message-ID: Sorry about the delay in reviewing the patch. I have been away. I think this looks good. Anton, what do you say? Evan On Aug 11, 2008, at 5:25 PM, Talin wrote: > OK I cleaned up the > 80 lines and renamed the methods as suggested. > > With regards to the LLVMDebugVersion constants - I merely copied > those from MachineModuleInfo, I have no idea what the various > version numbers correspond to. > > The problem with the debug version constants is that they are buried > inside of the CodeGen module, and I didn't want to create a > dependency from the Support module to the CodeGen module. Ideally, > those constants should be relocated to some header file where both > CodeGen and Support can access them. However, I don't know where > that would be. So in the mean time I've merely copied the > definitions until a decision is made. > > On the issue of ConstantStruct::get() and SmallVector: The way I > tend to design APIs is to take either a begin/end iterator or a > begin/end pointer. That allows you to use either a regular vector or > a SmallVector with the same API call. (Pointers are probably more > correct, although I have noticed that gcc lets you intermix pointers > from differently-sized SmallVectors without complaint.) > > -- > -- Talin > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From sabre at nondot.org Mon Aug 18 14:41:26 2008 From: sabre at nondot.org (Chris Lattner) Date: Mon, 18 Aug 2008 19:41:26 -0000 Subject: [llvm-commits] [llvm] r54936 - /llvm/trunk/lib/VMCore/AsmWriter.cpp Message-ID: <200808181941.m7IJfQAv005354@zion.cs.uiuc.edu> Author: lattner Date: Mon Aug 18 14:41:26 2008 New Revision: 54936 URL: http://llvm.org/viewvc/llvm-project?rev=54936&view=rev Log: Fix a bug daniel pointed out to me, where asmprinter started printing ascii code for hex numbers instead of the hex numbers themselves. Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AsmWriter.cpp?rev=54936&r1=54935&r2=54936&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/AsmWriter.cpp (original) +++ llvm/trunk/lib/VMCore/AsmWriter.cpp Mon Aug 18 14:41:26 2008 @@ -252,17 +252,17 @@ } else if (isprint(C)) { OS << C; } else { - OS << "\\"; + OS << '\\'; char hex1 = (C >> 4) & 0x0F; if (hex1 < 10) - OS << (hex1 + '0'); + OS << (char)(hex1 + '0'); else - OS << (hex1 - 10 + 'A'); + OS << (char)(hex1 - 10 + 'A'); char hex2 = C & 0x0F; if (hex2 < 10) - OS << (hex2 + '0'); + OS << (char)(hex2 + '0'); else - OS << (hex2 - 10 + 'A'); + OS << (char)(hex2 - 10 + 'A'); } } OS << '"'; From kremenek at apple.com Mon Aug 18 14:49:14 2008 From: kremenek at apple.com (Ted Kremenek) Date: Mon, 18 Aug 2008 19:49:14 -0000 Subject: [llvm-commits] [llvm] r54937 - /llvm/tags/checker/checker-78/ Message-ID: <200808181949.m7IJnEAn005713@zion.cs.uiuc.edu> Author: kremenek Date: Mon Aug 18 14:49:14 2008 New Revision: 54937 URL: http://llvm.org/viewvc/llvm-project?rev=54937&view=rev Log: Removing checker-78. Removed: llvm/tags/checker/checker-78/ From resistor at mac.com Mon Aug 18 14:52:22 2008 From: resistor at mac.com (Owen Anderson) Date: Mon, 18 Aug 2008 19:52:22 -0000 Subject: [llvm-commits] [llvm] r54939 - /llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Message-ID: <200808181952.m7IJqM0Q005847@zion.cs.uiuc.edu> Author: resistor Date: Mon Aug 18 14:52:22 2008 New Revision: 54939 URL: http://llvm.org/viewvc/llvm-project?rev=54939&view=rev Log: Clients of addIntervalForSpills expect the added intervals to be returned sorted by starting index. Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=54939&r1=54938&r2=54939&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Mon Aug 18 14:52:22 2008 @@ -1596,6 +1596,13 @@ } } +namespace { + struct LISorter { + bool operator()(LiveInterval* A, LiveInterval* B) { + return A->beginNumber() < B->beginNumber(); + } + }; +} std::vector LiveIntervals:: addIntervalsForSpillsFast(const LiveInterval &li, @@ -1677,6 +1684,8 @@ SSWeight = HUGE_VALF; + std::sort(added.begin(), added.end(), LISorter()); + return added; } From asl at math.spbu.ru Mon Aug 18 15:03:46 2008 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Mon, 18 Aug 2008 20:03:46 -0000 Subject: [llvm-commits] [llvm] r54942 - /llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp Message-ID: <200808182003.m7IK3krN006202@zion.cs.uiuc.edu> Author: asl Date: Mon Aug 18 15:03:45 2008 New Revision: 54942 URL: http://llvm.org/viewvc/llvm-project?rev=54942&view=rev Log: Unbreak cpp backend: upgrade output due to change in APInt API Modified: llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp Modified: llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp?rev=54942&r1=54941&r2=54942&view=diff ============================================================================== --- llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp (original) +++ llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp Mon Aug 18 15:03:45 2008 @@ -732,9 +732,10 @@ return; } if (const ConstantInt *CI = dyn_cast(CV)) { + std::string constValue = CI->getValue().toString(10, true); Out << "ConstantInt* " << constName << " = ConstantInt::get(APInt(" << cast(CI->getType())->getBitWidth() << ", \"" - << CI->getValue() << "\", 10));"; + << constValue << "\", " << constValue.length() << ", 10));"; } else if (isa(CV)) { Out << "ConstantAggregateZero* " << constName << " = ConstantAggregateZero::get(" << typeName << ");"; From isanbard at gmail.com Mon Aug 18 15:08:59 2008 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 18 Aug 2008 20:08:59 -0000 Subject: [llvm-commits] [llvm] r54944 - /llvm/tags/Apple/llvmCore-2065/ Message-ID: <200808182008.m7IK8xCS006388@zion.cs.uiuc.edu> Author: void Date: Mon Aug 18 15:08:59 2008 New Revision: 54944 URL: http://llvm.org/viewvc/llvm-project?rev=54944&view=rev Log: Creating llvmCore-2065 branch Added: llvm/tags/Apple/llvmCore-2065/ - copied from r54943, llvm/trunk/ From isanbard at gmail.com Mon Aug 18 15:09:05 2008 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 18 Aug 2008 20:09:05 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r54945 - /llvm-gcc-4.2/tags/Apple/llvmgcc42-2065/ Message-ID: <200808182009.m7IK95l9006402@zion.cs.uiuc.edu> Author: void Date: Mon Aug 18 15:09:05 2008 New Revision: 54945 URL: http://llvm.org/viewvc/llvm-project?rev=54945&view=rev Log: Creating llvmgcc42-2065 branch Added: llvm-gcc-4.2/tags/Apple/llvmgcc42-2065/ - copied from r54944, llvm-gcc-4.2/trunk/ From anton at korobeynikov.info Mon Aug 18 15:26:37 2008 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Tue, 19 Aug 2008 00:26:37 +0400 Subject: [llvm-commits] DebugInfoBuilder In-Reply-To: References: Message-ID: <1219091198.2394.53.camel@aslstation.lan> > Sorry about the delay in reviewing the patch. I have been away. I > think this looks good. Anton, what do you say? Oh, I'm sorry, I thought I answered to this e-mail. Overall patch looks ok for me. But I'd strongly suggest to change the names again to be consistent with usual LLVM naming: + // Create an anchor with the specified tag. + GlobalVariable * CreateAnchor(unsigned anchorTag, const char * anchorName); + + // Calculate alignement for primitive types. + unsigned GetBasicAlignment(unsigned sizeInBits); + + // Calculate the size of the specified LLVM type. + Constant * getSize(const Type * type); + + // Calculate the alignment of the specified LLVM type. + Constant * getAlignment(const Type * type); CreateAnchor => createAnchor, GetBasicAlignment => getBasicAlignment, etc. -- With best regards, Anton Korobeynikov. Faculty of Mathematics & Mechanics, Saint Petersburg State University. From dalej at apple.com Mon Aug 18 15:58:03 2008 From: dalej at apple.com (Dale Johannesen) Date: Mon, 18 Aug 2008 20:58:03 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r54948 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Message-ID: <200808182058.m7IKw3hM008074@zion.cs.uiuc.edu> Author: johannes Date: Mon Aug 18 15:58:02 2008 New Revision: 54948 URL: http://llvm.org/viewvc/llvm-project?rev=54948&view=rev Log: Fix derivation of names for atomic builtins. The code was using the type of the first argument, which doesn't work, see comment. The return value of the function does work. Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=54948&r1=54947&r2=54948&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Mon Aug 18 15:58:02 2008 @@ -4522,7 +4522,13 @@ return true; } #if defined(TARGET_ALPHA) || defined(TARGET_386) || defined(TARGET_POWERPC) - //gcc uses many names for the sync intrinsics + // gcc uses many names for the sync intrinsics + // The type of the first argument is not reliable for choosing the + // right llvm function; if the original type is not volatile, gcc has + // helpfully changed it to "volatile void *" at this point. The + // original type can be recovered from the function type. + // Note that Intrinsic::getDeclaration expects the type list in reversed + // order, while CreateCall expects the parameter list in normal order. case BUILT_IN_VAL_COMPARE_AND_SWAP_1: case BUILT_IN_VAL_COMPARE_AND_SWAP_2: case BUILT_IN_VAL_COMPARE_AND_SWAP_4: @@ -4540,14 +4546,10 @@ Emit(TREE_VALUE(TREE_CHAIN(arglist)), 0), Emit(TREE_VALUE(TREE_CHAIN(TREE_CHAIN(arglist))), 0) }; - const Type *OrigTy = cast(C[0]->getType())->getElementType(); const Type* Ty[2]; - Ty[0] = OrigTy; - if (isa(Ty[0])) - Ty[0] = TD.getIntPtrType(); - Ty[1] = C[0]->getType(); - - C[0] = Builder.CreateBitCast(C[0], PointerType::getUnqual(Ty[0])); + Ty[0] = ResultTy; + Ty[1] = PointerType::getUnqual(ResultTy); + C[0] = Builder.CreateBitCast(C[0], Ty[1]); C[1] = Builder.CreateIntCast(C[1], Ty[0], "cast"); C[2] = Builder.CreateIntCast(C[2], Ty[0], "cast"); @@ -4563,7 +4565,7 @@ ((DECL_FUNCTION_CODE(fndecl)) == BUILT_IN_BOOL_COMPARE_AND_SWAP_16)) Result = Builder.CreateICmpEQ(Result, C[1]); else - Result = Builder.CreateIntToPtr(Result, OrigTy); + Result = Builder.CreateIntToPtr(Result, ResultTy); return true; } case BUILT_IN_FETCH_AND_ADD_1: @@ -4577,20 +4579,17 @@ Emit(TREE_VALUE(arglist), 0), Emit(TREE_VALUE(TREE_CHAIN(arglist)), 0) }; - const Type *OrigTy = cast(C[0]->getType())->getElementType(); const Type* Ty[2]; - Ty[0] = OrigTy; - if (isa(Ty[0])) - Ty[0] = TD.getIntPtrType(); - Ty[1] = C[0]->getType(); - C[0] = Builder.CreateBitCast(C[0], PointerType::getUnqual(Ty[0])); + Ty[0] = ResultTy; + Ty[1] = PointerType::getUnqual(ResultTy); + C[0] = Builder.CreateBitCast(C[0], Ty[1]); C[1] = Builder.CreateIntCast(C[1], Ty[0], "cast"); Result = Builder.CreateCall(Intrinsic::getDeclaration(TheModule, Intrinsic::atomic_load_add, Ty, 2), C, C + 2); - Result = Builder.CreateIntToPtr(Result, OrigTy); + Result = Builder.CreateIntToPtr(Result, ResultTy); return true; } case BUILT_IN_FETCH_AND_SUB_1: @@ -4604,20 +4603,17 @@ Emit(TREE_VALUE(arglist), 0), Emit(TREE_VALUE(TREE_CHAIN(arglist)), 0) }; - const Type *OrigTy = cast(C[0]->getType())->getElementType(); const Type* Ty[2]; - Ty[0] = OrigTy; - if (isa(Ty[0])) - Ty[0] = TD.getIntPtrType(); - Ty[1] = C[0]->getType(); - C[0] = Builder.CreateBitCast(C[0], PointerType::getUnqual(Ty[0])); + Ty[0] = ResultTy; + Ty[1] = PointerType::getUnqual(ResultTy); + C[0] = Builder.CreateBitCast(C[0], Ty[1]); C[1] = Builder.CreateIntCast(C[1], Ty[0], "cast"); Result = Builder.CreateCall(Intrinsic::getDeclaration(TheModule, Intrinsic::atomic_load_sub, Ty, 2), C, C + 2); - Result = Builder.CreateIntToPtr(Result, OrigTy); + Result = Builder.CreateIntToPtr(Result, ResultTy); return true; } case BUILT_IN_FETCH_AND_OR_1: @@ -4631,20 +4627,17 @@ Emit(TREE_VALUE(arglist), 0), Emit(TREE_VALUE(TREE_CHAIN(arglist)), 0) }; - const Type *OrigTy = cast(C[0]->getType())->getElementType(); const Type* Ty[2]; - Ty[0] = OrigTy; - if (isa(Ty[0])) - Ty[0] = TD.getIntPtrType(); - Ty[1] = C[0]->getType(); - C[0] = Builder.CreateBitCast(C[0], PointerType::getUnqual(Ty[0])); + Ty[0] = ResultTy; + Ty[1] = PointerType::getUnqual(ResultTy); + C[0] = Builder.CreateBitCast(C[0], Ty[1]); C[1] = Builder.CreateIntCast(C[1], Ty[0], "cast"); Result = Builder.CreateCall(Intrinsic::getDeclaration(TheModule, Intrinsic::atomic_load_or, Ty, 2), C, C + 2); - Result = Builder.CreateIntToPtr(Result, OrigTy); + Result = Builder.CreateIntToPtr(Result, ResultTy); return true; } case BUILT_IN_FETCH_AND_AND_1: @@ -4658,20 +4651,17 @@ Emit(TREE_VALUE(arglist), 0), Emit(TREE_VALUE(TREE_CHAIN(arglist)), 0) }; - const Type *OrigTy = cast(C[0]->getType())->getElementType(); const Type* Ty[2]; - Ty[0] = OrigTy; - if (isa(Ty[0])) - Ty[0] = TD.getIntPtrType(); - Ty[1] = C[0]->getType(); - C[0] = Builder.CreateBitCast(C[0], PointerType::getUnqual(Ty[0])); + Ty[0] = ResultTy; + Ty[1] = PointerType::getUnqual(ResultTy); + C[0] = Builder.CreateBitCast(C[0], Ty[1]); C[1] = Builder.CreateIntCast(C[1], Ty[0], "cast"); Result = Builder.CreateCall(Intrinsic::getDeclaration(TheModule, Intrinsic::atomic_load_and, Ty, 2), C, C + 2); - Result = Builder.CreateIntToPtr(Result, OrigTy); + Result = Builder.CreateIntToPtr(Result, ResultTy); return true; } case BUILT_IN_FETCH_AND_XOR_1: @@ -4685,20 +4675,17 @@ Emit(TREE_VALUE(arglist), 0), Emit(TREE_VALUE(TREE_CHAIN(arglist)), 0) }; - const Type *OrigTy = cast(C[0]->getType())->getElementType(); const Type* Ty[2]; - Ty[0] = OrigTy; - if (isa(Ty[0])) - Ty[0] = TD.getIntPtrType(); - Ty[1] = C[0]->getType(); - C[0] = Builder.CreateBitCast(C[0], PointerType::getUnqual(Ty[0])); + Ty[0] = ResultTy; + Ty[1] = PointerType::getUnqual(ResultTy); + C[0] = Builder.CreateBitCast(C[0], Ty[1]); C[1] = Builder.CreateIntCast(C[1], Ty[0], "cast"); Result = Builder.CreateCall(Intrinsic::getDeclaration(TheModule, Intrinsic::atomic_load_xor, Ty, 2), C, C + 2); - Result = Builder.CreateIntToPtr(Result, OrigTy); + Result = Builder.CreateIntToPtr(Result, ResultTy); return true; } case BUILT_IN_FETCH_AND_NAND_1: @@ -4712,20 +4699,17 @@ Emit(TREE_VALUE(arglist), 0), Emit(TREE_VALUE(TREE_CHAIN(arglist)), 0) }; - const Type *OrigTy = cast(C[0]->getType())->getElementType(); const Type* Ty[2]; - Ty[0] = OrigTy; - if (isa(Ty[0])) - Ty[0] = TD.getIntPtrType(); - Ty[1] = C[0]->getType(); - C[0] = Builder.CreateBitCast(C[0], PointerType::getUnqual(Ty[0])); + Ty[0] = ResultTy; + Ty[1] = PointerType::getUnqual(ResultTy); + C[0] = Builder.CreateBitCast(C[0], Ty[1]); C[1] = Builder.CreateIntCast(C[1], Ty[0], "cast"); Result = Builder.CreateCall(Intrinsic::getDeclaration(TheModule, Intrinsic::atomic_load_nand, Ty, 2), C, C + 2); - Result = Builder.CreateIntToPtr(Result, OrigTy); + Result = Builder.CreateIntToPtr(Result, ResultTy); return true; } case BUILT_IN_LOCK_TEST_AND_SET_1: @@ -4740,13 +4724,10 @@ Emit(TREE_VALUE(TREE_CHAIN(arglist)), 0) }; - const Type *OrigTy = cast(C[0]->getType())->getElementType(); const Type* Ty[2]; - Ty[0] = OrigTy; - if (isa(Ty[0])) - Ty[0] = TD.getIntPtrType(); - Ty[1] = C[0]->getType(); - C[0] = Builder.CreateBitCast(C[0], PointerType::getUnqual(Ty[0])); + Ty[0] = ResultTy; + Ty[1] = PointerType::getUnqual(ResultTy); + C[0] = Builder.CreateBitCast(C[0], Ty[1]); C[1] = Builder.CreateIntCast(C[1], Ty[0], "cast"); Result = Builder.CreateCall(Intrinsic::getDeclaration(TheModule, @@ -4754,7 +4735,7 @@ Ty, 2), C, C + 2); - Result = Builder.CreateIntToPtr(Result, OrigTy); + Result = Builder.CreateIntToPtr(Result, ResultTy); return true; } case BUILT_IN_ADD_AND_FETCH_1: @@ -4768,13 +4749,10 @@ Emit(TREE_VALUE(arglist), 0), Emit(TREE_VALUE(TREE_CHAIN(arglist)), 0) }; - const Type *OrigTy = cast(C[0]->getType())->getElementType(); const Type* Ty[2]; - Ty[0] = OrigTy; - if (isa(Ty[0])) - Ty[0] = TD.getIntPtrType(); - Ty[1] = C[0]->getType(); - C[0] = Builder.CreateBitCast(C[0], PointerType::getUnqual(Ty[0])); + Ty[0] = ResultTy; + Ty[1] = PointerType::getUnqual(ResultTy); + C[0] = Builder.CreateBitCast(C[0], Ty[1]); C[1] = Builder.CreateIntCast(C[1], Ty[0], "cast"); Result = Builder.CreateCall(Intrinsic::getDeclaration(TheModule, @@ -4782,7 +4760,7 @@ Ty, 2), C, C + 2); Result = Builder.CreateAdd(Result, C[1]); - Result = Builder.CreateIntToPtr(Result, OrigTy); + Result = Builder.CreateIntToPtr(Result, ResultTy); return true; } case BUILT_IN_SUB_AND_FETCH_1: @@ -4796,13 +4774,10 @@ Emit(TREE_VALUE(arglist), 0), Emit(TREE_VALUE(TREE_CHAIN(arglist)), 0) }; - const Type *OrigTy = cast(C[0]->getType())->getElementType(); const Type* Ty[2]; - Ty[0] = OrigTy; - if (isa(Ty[0])) - Ty[0] = TD.getIntPtrType(); - Ty[1] = C[0]->getType(); - C[0] = Builder.CreateBitCast(C[0], PointerType::getUnqual(Ty[0])); + Ty[0] = ResultTy; + Ty[1] = PointerType::getUnqual(ResultTy); + C[0] = Builder.CreateBitCast(C[0], Ty[1]); C[1] = Builder.CreateIntCast(C[1], Ty[0], "cast"); Result = Builder.CreateCall(Intrinsic::getDeclaration(TheModule, @@ -4810,7 +4785,7 @@ Ty, 2), C, C + 2); Result = Builder.CreateSub(Result, C[1]); - Result = Builder.CreateIntToPtr(Result, OrigTy); + Result = Builder.CreateIntToPtr(Result, ResultTy); return true; } case BUILT_IN_OR_AND_FETCH_1: @@ -4824,13 +4799,10 @@ Emit(TREE_VALUE(arglist), 0), Emit(TREE_VALUE(TREE_CHAIN(arglist)), 0) }; - const Type *OrigTy = cast(C[0]->getType())->getElementType(); const Type* Ty[2]; - Ty[0] = OrigTy; - if (isa(Ty[0])) - Ty[0] = TD.getIntPtrType(); - Ty[1] = C[0]->getType(); - C[0] = Builder.CreateBitCast(C[0], PointerType::getUnqual(Ty[0])); + Ty[0] = ResultTy; + Ty[1] = PointerType::getUnqual(ResultTy); + C[0] = Builder.CreateBitCast(C[0], Ty[1]); C[1] = Builder.CreateIntCast(C[1], Ty[0], "cast"); Result = Builder.CreateCall(Intrinsic::getDeclaration(TheModule, @@ -4838,7 +4810,7 @@ Ty, 2), C, C + 2); Result = Builder.CreateOr(Result, C[1]); - Result = Builder.CreateIntToPtr(Result, OrigTy); + Result = Builder.CreateIntToPtr(Result, ResultTy); return true; } case BUILT_IN_AND_AND_FETCH_1: @@ -4852,13 +4824,10 @@ Emit(TREE_VALUE(arglist), 0), Emit(TREE_VALUE(TREE_CHAIN(arglist)), 0) }; - const Type *OrigTy = cast(C[0]->getType())->getElementType(); const Type* Ty[2]; - Ty[0] = OrigTy; - if (isa(Ty[0])) - Ty[0] = TD.getIntPtrType(); - Ty[1] = C[0]->getType(); - C[0] = Builder.CreateBitCast(C[0], PointerType::getUnqual(Ty[0])); + Ty[0] = ResultTy; + Ty[1] = PointerType::getUnqual(ResultTy); + C[0] = Builder.CreateBitCast(C[0], Ty[1]); C[1] = Builder.CreateIntCast(C[1], Ty[0], "cast"); Result = Builder.CreateCall(Intrinsic::getDeclaration(TheModule, @@ -4866,7 +4835,7 @@ Ty, 2), C, C + 2); Result = Builder.CreateAnd(Result, C[1]); - Result = Builder.CreateIntToPtr(Result, OrigTy); + Result = Builder.CreateIntToPtr(Result, ResultTy); return true; } case BUILT_IN_XOR_AND_FETCH_1: @@ -4880,13 +4849,10 @@ Emit(TREE_VALUE(arglist), 0), Emit(TREE_VALUE(TREE_CHAIN(arglist)), 0) }; - const Type *OrigTy = cast(C[0]->getType())->getElementType(); const Type* Ty[2]; - Ty[0] = OrigTy; - if (isa(Ty[0])) - Ty[0] = TD.getIntPtrType(); - Ty[1] = C[0]->getType(); - C[0] = Builder.CreateBitCast(C[0], PointerType::getUnqual(Ty[0])); + Ty[0] = ResultTy; + Ty[1] = PointerType::getUnqual(ResultTy); + C[0] = Builder.CreateBitCast(C[0], Ty[1]); C[1] = Builder.CreateIntCast(C[1], Ty[0], "cast"); Result = Builder.CreateCall(Intrinsic::getDeclaration(TheModule, @@ -4894,7 +4860,7 @@ Ty, 2), C, C + 2); Result = Builder.CreateXor(Result, C[1]); - Result = Builder.CreateIntToPtr(Result, OrigTy); + Result = Builder.CreateIntToPtr(Result, ResultTy); return true; } case BUILT_IN_NAND_AND_FETCH_1: @@ -4908,13 +4874,10 @@ Emit(TREE_VALUE(arglist), 0), Emit(TREE_VALUE(TREE_CHAIN(arglist)), 0) }; - const Type *OrigTy = cast(C[0]->getType())->getElementType(); const Type* Ty[2]; - Ty[0] = OrigTy; - if (isa(Ty[0])) - Ty[0] = TD.getIntPtrType(); - Ty[1] = C[0]->getType(); - C[0] = Builder.CreateBitCast(C[0], PointerType::getUnqual(Ty[0])); + Ty[0] = ResultTy; + Ty[1] = PointerType::getUnqual(ResultTy); + C[0] = Builder.CreateBitCast(C[0], Ty[1]); C[1] = Builder.CreateIntCast(C[1], Ty[0], "cast"); Result = Builder.CreateCall(Intrinsic::getDeclaration(TheModule, @@ -4922,7 +4885,7 @@ Ty, 2), C, C + 2); Result = Builder.CreateAnd(Builder.CreateNot(Result), C[1]); - Result = Builder.CreateIntToPtr(Result, OrigTy); + Result = Builder.CreateIntToPtr(Result, ResultTy); return true; } From resistor at mac.com Mon Aug 18 16:20:35 2008 From: resistor at mac.com (Owen Anderson) Date: Mon, 18 Aug 2008 21:20:35 -0000 Subject: [llvm-commits] [llvm] r54949 - /llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Message-ID: <200808182120.m7ILKZkN008708@zion.cs.uiuc.edu> Author: resistor Date: Mon Aug 18 16:20:32 2008 New Revision: 54949 URL: http://llvm.org/viewvc/llvm-project?rev=54949&view=rev Log: Fix several bugs in the new fast-path: 1) Remove an incorrect assertion. 2) Set the stack slot weight properly. 3) Resize the VirtRegMap when needed. Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=54949&r1=54948&r2=54949&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Mon Aug 18 16:20:32 2008 @@ -1608,11 +1608,7 @@ addIntervalsForSpillsFast(const LiveInterval &li, const MachineLoopInfo *loopInfo, VirtRegMap &vrm, float& SSWeight) { - unsigned slot = vrm.assignVirt2StackSlot(li.reg); - - // since this is called after the analysis is done we don't know if - // LiveVariables is available - lv_ = getAnalysisToUpdate(); + vrm.assignVirt2StackSlot(li.reg); std::vector added; @@ -1628,14 +1624,17 @@ DenseMap VRegMap; DenseMap VNMap; + SSWeight = 0.0f; + for (MachineRegisterInfo::reg_iterator RI = mri_->reg_begin(li.reg), RE = mri_->reg_end(); RI != RE; ) { // Create a new virtual register for the spill interval. MachineOperand& MO = RI.getOperand(); unsigned NewVReg = 0; - if (!VRegMap.count(MO.getParent())) + if (!VRegMap.count(MO.getParent())) { VRegMap[MO.getParent()] = NewVReg = mri_->createVirtualRegister(rc); - else + vrm.grow(); + } else NewVReg = VRegMap[MO.getParent()]; // Increment iterator to avoid invalidation. @@ -1644,10 +1643,7 @@ MO.setReg(NewVReg); // create a new register for this spill - vrm.grow(); - vrm.assignVirt2StackSlot(NewVReg, slot); LiveInterval &nI = getOrCreateInterval(NewVReg); - assert(nI.empty()); // the spill weight is now infinity as it // cannot be spilled again @@ -1672,17 +1668,21 @@ } added.push_back(&nI); - - // update live variables if it is available - if (lv_) - lv_->addVirtualRegisterKilled(NewVReg, MO.getParent()); DOUT << "\t\t\t\tadded new interval: "; DEBUG(nI.dump()); DOUT << '\n'; + + unsigned loopDepth = loopInfo->getLoopDepth(MO.getParent()->getParent()); + if (HasUse) { + if (HasDef) + SSWeight += getSpillWeight(true, true, loopDepth); + else + SSWeight += getSpillWeight(false, true, loopDepth); + } else + SSWeight += getSpillWeight(true, false, loopDepth); + } - - SSWeight = HUGE_VALF; std::sort(added.begin(), added.end(), LISorter()); From sabre at nondot.org Mon Aug 18 16:27:19 2008 From: sabre at nondot.org (Chris Lattner) Date: Mon, 18 Aug 2008 21:27:19 -0000 Subject: [llvm-commits] [llvm] r54950 - /llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.h Message-ID: <200808182127.m7ILRJqd008913@zion.cs.uiuc.edu> Author: lattner Date: Mon Aug 18 16:27:19 2008 New Revision: 54950 URL: http://llvm.org/viewvc/llvm-project?rev=54950&view=rev Log: remove empty file Removed: llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.h Removed: llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.h?rev=54949&view=auto ============================================================================== (empty) From tonic at nondot.org Mon Aug 18 17:05:28 2008 From: tonic at nondot.org (Tanya Lattner) Date: Mon, 18 Aug 2008 17:05:28 -0500 Subject: [llvm-commits] CVS: llvm-www/www-index.html Message-ID: <200808182205.m7IM5S1u010036@zion.cs.uiuc.edu> Changes in directory llvm-www: www-index.html updated: 1.161 -> 1.162 --- Log message: 2.4 release schedule --- Diffs of the changes: (+9 -1) www-index.html | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletion(-) Index: llvm-www/www-index.html diff -u llvm-www/www-index.html:1.161 llvm-www/www-index.html:1.162 --- llvm-www/www-index.html:1.161 Sun Aug 3 16:06:12 2008 +++ llvm-www/www-index.html Mon Aug 18 17:04:51 2008 @@ -117,7 +117,15 @@
Upcoming Releases
-

LLVM 2.4 release schedule coming soon.

+

LLVM 2.4 release schedule:

+
    +
  • Oct 6, 2008: Branch creation/Code Freeze (9PM PDT).
  • +
  • Oct 9, 2008: First round of pre-release testing begins.
  • +
  • Oct 19, 2008: Pre-release testing ends.
  • +
  • Oct 21, 2008: Second round of pre-release testing begins.
  • +
  • Oct 28, 2008: Pre-release testing ends.
  • +
  • Oct 30, 2008: 2.4 Released.
  • +

From viridia at gmail.com Mon Aug 18 18:01:49 2008 From: viridia at gmail.com (Talin) Date: Mon, 18 Aug 2008 16:01:49 -0700 Subject: [llvm-commits] DebugInfoBuilder In-Reply-To: <1219091198.2394.53.camel@aslstation.lan> References: <1219091198.2394.53.camel@aslstation.lan> Message-ID: I don't have a problem with changing the method names. The reason I used upper case is because I thought that's what the convention was (the LLVM sources aren't exactly consistent on this point, although there's been considerable improvement since I first wrote this module.) Do you want me to submit another patch, or can you just modify the names? On Mon, Aug 18, 2008 at 1:26 PM, Anton Korobeynikov wrote: > > > Sorry about the delay in reviewing the patch. I have been away. I > > think this looks good. Anton, what do you say? > Oh, I'm sorry, I thought I answered to this e-mail. > > Overall patch looks ok for me. But I'd strongly suggest to change the > names again to be consistent with usual LLVM naming: > > + // Create an anchor with the specified tag. > + GlobalVariable * CreateAnchor(unsigned anchorTag, const char * > anchorName); > + > + // Calculate alignement for primitive types. > + unsigned GetBasicAlignment(unsigned sizeInBits); > + > + // Calculate the size of the specified LLVM type. > + Constant * getSize(const Type * type); > + > + // Calculate the alignment of the specified LLVM type. > + Constant * getAlignment(const Type * type); > CreateAnchor => createAnchor, GetBasicAlignment => getBasicAlignment, > etc. > > -- > With best regards, Anton Korobeynikov. > > Faculty of Mathematics & Mechanics, Saint Petersburg State University. > > -- -- Talin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20080818/291bd7e2/attachment.html From resistor at mac.com Mon Aug 18 18:41:05 2008 From: resistor at mac.com (Owen Anderson) Date: Mon, 18 Aug 2008 23:41:05 -0000 Subject: [llvm-commits] [llvm] r54956 - /llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Message-ID: <200808182341.m7INf5bx013049@zion.cs.uiuc.edu> Author: resistor Date: Mon Aug 18 18:41:04 2008 New Revision: 54956 URL: http://llvm.org/viewvc/llvm-project?rev=54956&view=rev Log: Fix a few more bugs: 1) Assign stack slots to new temporaries. 2) Don't insert an interval into the return vector more than once. Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=54956&r1=54955&r2=54956&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Mon Aug 18 18:41:04 2008 @@ -1608,7 +1608,7 @@ addIntervalsForSpillsFast(const LiveInterval &li, const MachineLoopInfo *loopInfo, VirtRegMap &vrm, float& SSWeight) { - vrm.assignVirt2StackSlot(li.reg); + unsigned slot = vrm.assignVirt2StackSlot(li.reg); std::vector added; @@ -1631,9 +1631,13 @@ // Create a new virtual register for the spill interval. MachineOperand& MO = RI.getOperand(); unsigned NewVReg = 0; + bool newInt = false; if (!VRegMap.count(MO.getParent())) { VRegMap[MO.getParent()] = NewVReg = mri_->createVirtualRegister(rc); vrm.grow(); + vrm.assignVirt2StackSlot(NewVReg, slot); + + newInt = true; } else NewVReg = VRegMap[MO.getParent()]; @@ -1666,8 +1670,9 @@ DOUT << " +" << LR; nI.addRange(LR); } - - added.push_back(&nI); + + if (newInt) + added.push_back(&nI); DOUT << "\t\t\t\tadded new interval: "; DEBUG(nI.dump()); From gohman at apple.com Mon Aug 18 18:41:46 2008 From: gohman at apple.com (Dan Gohman) Date: Mon, 18 Aug 2008 23:41:46 -0000 Subject: [llvm-commits] [llvm] r54957 - /llvm/trunk/include/llvm/CodeGen/FastISel.h Message-ID: <200808182341.m7INfkkP013101@zion.cs.uiuc.edu> Author: djg Date: Mon Aug 18 18:41:46 2008 New Revision: 54957 URL: http://llvm.org/viewvc/llvm-project?rev=54957&view=rev Log: Fix the FastISel class' doxygen comment. Modified: llvm/trunk/include/llvm/CodeGen/FastISel.h Modified: llvm/trunk/include/llvm/CodeGen/FastISel.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/FastISel.h?rev=54957&r1=54956&r2=54957&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/FastISel.h (original) +++ llvm/trunk/include/llvm/CodeGen/FastISel.h Mon Aug 18 18:41:46 2008 @@ -25,9 +25,9 @@ class TargetInstrInfo; class TargetRegisterClass; -/// This file defines the FastISel class. This is a fast-path instruction -/// selection class that generates poor code and doesn't support illegal -/// types or non-trivial lowering, but runs quickly. +/// FastISel - This is a fast-path instruction selection class that +/// generates poor code and doesn't support illegal types or non-trivial +/// lowering, but runs quickly. class FastISel { MachineBasicBlock *MBB; MachineFunction *MF; From resistor at mac.com Mon Aug 18 19:17:30 2008 From: resistor at mac.com (Owen Anderson) Date: Tue, 19 Aug 2008 00:17:30 -0000 Subject: [llvm-commits] [llvm] r54958 - /llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Message-ID: <200808190017.m7J0HUWQ014558@zion.cs.uiuc.edu> Author: resistor Date: Mon Aug 18 19:17:30 2008 New Revision: 54958 URL: http://llvm.org/viewvc/llvm-project?rev=54958&view=rev Log: Add a flag to enable the fast spilling path. Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=54958&r1=54957&r2=54958&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Mon Aug 18 19:17:30 2008 @@ -49,6 +49,9 @@ static cl::opt EnableAggressiveRemat("aggressive-remat", cl::Hidden); +static cl::opt EnableFastSpilling("fast-spill", + cl::init(false), cl::Hidden); + STATISTIC(numIntervals, "Number of original intervals"); STATISTIC(numIntervalsAfter, "Number of intervals after coalescing"); STATISTIC(numFolds , "Number of loads/stores folded into instructions"); @@ -1698,6 +1701,10 @@ addIntervalsForSpills(const LiveInterval &li, const MachineLoopInfo *loopInfo, VirtRegMap &vrm, float &SSWeight) { + + if (EnableFastSpilling) + return addIntervalsForSpillsFast(li, loopInfo, vrm, SSWeight); + assert(li.weight != HUGE_VALF && "attempt to spill already spilled interval!"); From isanbard at gmail.com Mon Aug 18 19:30:09 2008 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 19 Aug 2008 00:30:09 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r54959 - /llvm-gcc-4.2/trunk/gcc/llvm-linker-hack.cpp Message-ID: <200808190030.m7J0U9iU014993@zion.cs.uiuc.edu> Author: void Date: Mon Aug 18 19:30:09 2008 New Revision: 54959 URL: http://llvm.org/viewvc/llvm-project?rev=54959&view=rev Log: Add this symbol to the linker hack. This way it won't be dropped on the floor. llvm::TargetMachineRegistry::getClosestStaticTargetForModule Modified: llvm-gcc-4.2/trunk/gcc/llvm-linker-hack.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-linker-hack.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-linker-hack.cpp?rev=54959&r1=54958&r2=54959&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-linker-hack.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-linker-hack.cpp Mon Aug 18 19:30:09 2008 @@ -20,8 +20,10 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "llvm/Module.h" #include "llvm/ModuleProvider.h" #include "llvm/Analysis/Verifier.h" +#include "llvm/Target/TargetMachineRegistry.h" #include "llvm/Transforms/Scalar.h" #include "llvm/Transforms/IPO.h" #include "llvm/Bitcode/ReaderWriter.h" @@ -38,7 +40,7 @@ /// This function is never dynamically called. /// void dummy_function() { - new llvm::ExistingModuleProvider(0); + llvm::ModuleProvider *MP = new llvm::ExistingModuleProvider(0); llvm::createVerifierPass(); llvm::CreateBitcodeWriterPass(*llvm::cout); llvm::WriteBitcodeToFile(0, *llvm::cout); @@ -82,8 +84,10 @@ llvm::createMemCpyOptPass(); llvm::createDeadTypeEliminationPass(); llvm::createLoopDeletionPass(); - llvm::createDeadCodeEliminationPass(); - + + std::string Err; + llvm::TargetMachineRegistry::getClosestStaticTargetForModule(*MP->getModule(), + Err); } /* LLVM LOCAL end (ENTIRE FILE!) */ From isanbard at gmail.com Mon Aug 18 19:31:12 2008 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 19 Aug 2008 00:31:12 -0000 Subject: [llvm-commits] [llvm] r54960 - /llvm/tags/Apple/llvmCore-2065/ Message-ID: <200808190031.m7J0VC5D015031@zion.cs.uiuc.edu> Author: void Date: Mon Aug 18 19:31:11 2008 New Revision: 54960 URL: http://llvm.org/viewvc/llvm-project?rev=54960&view=rev Log: Removing tag llvmCore-2065. Removed: llvm/tags/Apple/llvmCore-2065/ From isanbard at gmail.com Mon Aug 18 19:31:30 2008 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 19 Aug 2008 00:31:30 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r54961 - /llvm-gcc-4.2/tags/Apple/llvmgcc42-2065/ Message-ID: <200808190031.m7J0VUAx015049@zion.cs.uiuc.edu> Author: void Date: Mon Aug 18 19:31:30 2008 New Revision: 54961 URL: http://llvm.org/viewvc/llvm-project?rev=54961&view=rev Log: Removing tag llvmgcc-2065. Removed: llvm-gcc-4.2/tags/Apple/llvmgcc42-2065/ From isanbard at gmail.com Mon Aug 18 19:33:44 2008 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 19 Aug 2008 00:33:44 -0000 Subject: [llvm-commits] [llvm] r54962 - /llvm/tags/Apple/llvmCore-2065/ Message-ID: <200808190033.m7J0XisC015117@zion.cs.uiuc.edu> Author: void Date: Mon Aug 18 19:33:44 2008 New Revision: 54962 URL: http://llvm.org/viewvc/llvm-project?rev=54962&view=rev Log: Creating llvmCore-2065 branch Added: llvm/tags/Apple/llvmCore-2065/ - copied from r54961, llvm/trunk/ From isanbard at gmail.com Mon Aug 18 19:33:53 2008 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 19 Aug 2008 00:33:53 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r54963 - /llvm-gcc-4.2/tags/Apple/llvmgcc42-2065/ Message-ID: <200808190033.m7J0XrVS015132@zion.cs.uiuc.edu> Author: void Date: Mon Aug 18 19:33:53 2008 New Revision: 54963 URL: http://llvm.org/viewvc/llvm-project?rev=54963&view=rev Log: Creating llvmgcc42-2065 branch Added: llvm-gcc-4.2/tags/Apple/llvmgcc42-2065/ - copied from r54962, llvm-gcc-4.2/trunk/ From sabre at nondot.org Mon Aug 18 19:41:02 2008 From: sabre at nondot.org (Chris Lattner) Date: Tue, 19 Aug 2008 00:41:02 -0000 Subject: [llvm-commits] [llvm] r54964 - /llvm/trunk/lib/Target/X86/README-SSE.txt Message-ID: <200808190041.m7J0f28Y015356@zion.cs.uiuc.edu> Author: lattner Date: Mon Aug 18 19:41:02 2008 New Revision: 54964 URL: http://llvm.org/viewvc/llvm-project?rev=54964&view=rev Log: add a note Modified: llvm/trunk/lib/Target/X86/README-SSE.txt Modified: llvm/trunk/lib/Target/X86/README-SSE.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/README-SSE.txt?rev=54964&r1=54963&r2=54964&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/README-SSE.txt (original) +++ llvm/trunk/lib/Target/X86/README-SSE.txt Mon Aug 18 19:41:02 2008 @@ -839,3 +839,40 @@ shufps $2, %xmm1, %xmm2 shufps $132, %xmm2, %xmm0 movaps %xmm0, 0 + +//===---------------------------------------------------------------------===// +rdar://6037315 + +llvm-gcc-4.2 does the following for uint32_t -> float conversions on i386: + + uint32_t x; + float y = (float)x; + +becomes: + +movl %eax, -8(%ebp) // write x to the stack +movl $0x3ff00000, -4(%ebp) // 2^52 + x as a double at -4(%ebp) +movsd -8(%ebp), %xmm0 +subsd [2^52 double], %xmm0 // subtract 2^52 -- this is exact +cvtsd2ss %xmm0, %xmm0 // convert to single -- rounding happens here + +On merom/yonah, this takes a substantial stall. The following is a much +better option: + +movd %eax, %xmm0 // load x into low word of xmm0 +movsd [2^52 double], %xmm1 // load 2^52 into xmm1 +orpd %xmm1, %xmm0 // 2^52 + x in double precision +subsd %xmm1, %xmm0 // x in double precision +cvtsd2ss %xmm0, %xmm0 // x rounded to single precision + +IF we don't already need PIC, then the following is even faster still, at a +small cost to code size: + +movl $0x3ff00000, %ecx // conjure high word of 2^52 +movd %ecx, %xmm1 +movss %eax, %xmm0 // load x into low word of xmm0 +psllq $32, %xmm1 // 2^52 +orpd %xmm1, %xmm0 // 2^52 + x in double precision +subsd %xmm1, %xmm0 // x in double precision +cvtsd2ss %xmm0, %xmm0 // x in single precision + From evan.cheng at apple.com Mon Aug 18 19:51:31 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 18 Aug 2008 17:51:31 -0700 Subject: [llvm-commits] [llvm] r54876 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/2008-08-17-ICmpXorSignbit.ll In-Reply-To: <200808170734.m7H7YFS7017489@zion.cs.uiuc.edu> References: <200808170734.m7H7YFS7017489@zion.cs.uiuc.edu> Message-ID: <41A47824-D92E-44BB-BCD4-5A46AF7B2D8A@apple.com> Hi Nick, This patch caused 256.bzip2 to regress by 20% on x86 / Mac OS X. I took a quick look at it but can't really figure out what's wrong. Can you investigate? Thanks, Evan On Aug 17, 2008, at 12:34 AM, Nick Lewycky wrote: > Author: nicholas > Date: Sun Aug 17 02:34:14 2008 > New Revision: 54876 > > URL: http://llvm.org/viewvc/llvm-project?rev=54876&view=rev > Log: > Xor'ing both sides of icmp by sign-bit is equivalent to swapping > signedness of > the predicate. > > Also, make this optz'n apply in more cases where it's safe to do so. > > Added: > llvm/trunk/test/Transforms/InstCombine/2008-08-17-ICmpXorSignbit.ll > Modified: > llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp > > Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=54876&r1=54875&r2=54876&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp > (original) > +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Sun > Aug 17 02:34:14 2008 > @@ -5241,6 +5241,20 @@ > return new ICmpInst(I.getPredicate(), A, B); > } > > + ConstantInt *CI2; > + // (icmp u/s (xor A SignBit), C) -> (icmp s/u A, (xor C SignBit)) > + if (!I.isEquality() && > + match(Op0, m_Xor(m_Value(A), m_ConstantInt(CI2)))) { > + if (CI2->getValue().isSignBit()) { > + const APInt &SignBit = CI2->getValue(); > + ICmpInst::Predicate Pred = I.isSignedPredicate() > + ? I.getUnsignedPredicate() > + : I.getSignedPredicate(); > + return new ICmpInst(Pred, A, > + ConstantInt::get(CI->getValue() ^ > SignBit)); > + } > + } > + > // If we have a icmp le or icmp ge instruction, turn it into the > appropriate > // icmp lt or icmp gt instruction. This allows us to rely on > them being > // folded in the code below. > @@ -5491,35 +5505,49 @@ > // See if it's the same type of instruction on the left and right. > if (BinaryOperator *Op0I = dyn_cast(Op0)) { > if (BinaryOperator *Op1I = dyn_cast(Op1)) { > - if (Op0I->getOpcode() == Op1I->getOpcode() && Op0I- > >hasOneUse() && > - Op1I->hasOneUse() && Op0I->getOperand(1) == Op1I- > >getOperand(1) && > - I.isEquality()) { > - switch (Op0I->getOpcode()) { > + if (Op0I->getOpcode() == Op1I->getOpcode() && > + Op0I->getOperand(1) == Op1I->getOperand(1)) { > + switch (Op0I->getOpcode()) { > default: break; > case Instruction::Add: > case Instruction::Sub: > case Instruction::Xor: > - // a+x icmp eq/ne b+x --> a icmp b > - return new ICmpInst(I.getPredicate(), Op0I->getOperand(0), > - Op1I->getOperand(0)); > + if (I.isEquality()) { > + // icmp eq/ne a+x, b+x --> icmp eq/ne a, b > + return new ICmpInst(I.getPredicate(), Op0I- > >getOperand(0), > + Op1I->getOperand(0)); > + } else { > + // icmp u/s (a ^ signbit), (b ^ signbit) --> icmp s/u > a, b > + if (ConstantInt *CI = dyn_cast(Op0I- > >getOperand(1))) { > + if (CI->getValue().isSignBit()) { > + ICmpInst::Predicate Pred = I.isSignedPredicate() > + ? > I.getUnsignedPredicate() > + : > I.getSignedPredicate(); > + return new ICmpInst(Pred, Op0I->getOperand(0), > + Op1I->getOperand(0)); > + } > + } > + } > break; > case Instruction::Mul: > - if (ConstantInt *CI = dyn_cast(Op0I- > >getOperand(1))) { > - // a * Cst icmp eq/ne b * Cst --> a & Mask icmp b & Mask > - // Mask = -1 >> count-trailing-zeros(Cst). > - if (!CI->isZero() && !CI->isOne()) { > - const APInt &AP = CI->getValue(); > - ConstantInt *Mask = ConstantInt::get( > - > APInt::getLowBitsSet(AP.getBitWidth(), > - > AP.getBitWidth() - > + // a * Cst icmp eq/ne b * Cst --> a & Mask icmp b & Mask > + // Mask = -1 >> count-trailing-zeros(Cst). > + if (Op0I->hasOneUse() && Op1I->hasOneUse() && > I.isEquality()) { > + if (ConstantInt *CI = dyn_cast(Op0I- > >getOperand(1))) { > + if (!CI->isZero() && !CI->isOne()) { > + const APInt &AP = CI->getValue(); > + ConstantInt *Mask = > + > ConstantInt::get(APInt::getLowBitsSet(AP.getBitWidth(), > + > AP.getBitWidth() - > > AP.countTrailingZeros())); > - Instruction *And1 = BinaryOperator::CreateAnd(Op0I- > >getOperand(0), > - Mask); > - Instruction *And2 = BinaryOperator::CreateAnd(Op1I- > >getOperand(0), > - Mask); > - InsertNewInstBefore(And1, I); > - InsertNewInstBefore(And2, I); > - return new ICmpInst(I.getPredicate(), And1, And2); > + Instruction *And1 = > + BinaryOperator::CreateAnd(Op0I->getOperand(0), > Mask); > + Instruction *And2 = > + BinaryOperator::CreateAnd(Op1I->getOperand(0), > Mask); > + InsertNewInstBefore(And1, I); > + InsertNewInstBefore(And2, I); > + return new ICmpInst(I.getPredicate(), And1, And2); > + } > } > } > break; > > Added: llvm/trunk/test/Transforms/InstCombine/2008-08-17- > ICmpXorSignbit.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/2008-08-17-ICmpXorSignbit.ll?rev=54876&view=auto > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/test/Transforms/InstCombine/2008-08-17- > ICmpXorSignbit.ll (added) > +++ llvm/trunk/test/Transforms/InstCombine/2008-08-17- > ICmpXorSignbit.ll Sun Aug 17 02:34:14 2008 > @@ -0,0 +1,22 @@ > +; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep -v xor > + > +define i1 @test1(i8 %x, i8 %y) { > + %X = xor i8 %x, 128 > + %Y = xor i8 %y, 128 > + %tmp = icmp slt i8 %X, %Y > + ret i1 %tmp > +} > + > +define i1 @test2(i8 %x, i8 %y) { > + %X = xor i8 %x, 128 > + %Y = xor i8 %y, 128 > + %tmp = icmp ult i8 %X, %Y > + ret i1 %tmp > +} > + > +define i1 @test3(i8 %x) { > + %X = xor i8 %x, 128 > + %tmp = icmp uge i8 %X, 15 > + ret i1 %tmp > +} > + > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From kremenek at apple.com Mon Aug 18 19:55:43 2008 From: kremenek at apple.com (Ted Kremenek) Date: Tue, 19 Aug 2008 00:55:43 -0000 Subject: [llvm-commits] [llvm] r54965 - /llvm/tags/checker/checker-78/ Message-ID: <200808190055.m7J0thjl015798@zion.cs.uiuc.edu> Author: kremenek Date: Mon Aug 18 19:55:43 2008 New Revision: 54965 URL: http://llvm.org/viewvc/llvm-project?rev=54965&view=rev Log: Tagging checker-78. Added: llvm/tags/checker/checker-78/ - copied from r54964, llvm/trunk/ From resistor at mac.com Mon Aug 18 20:05:33 2008 From: resistor at mac.com (Owen Anderson) Date: Tue, 19 Aug 2008 01:05:33 -0000 Subject: [llvm-commits] [llvm] r54968 - /llvm/trunk/lib/CodeGen/VirtRegMap.cpp Message-ID: <200808190105.m7J15XAd016099@zion.cs.uiuc.edu> Author: resistor Date: Mon Aug 18 20:05:33 2008 New Revision: 54968 URL: http://llvm.org/viewvc/llvm-project?rev=54968&view=rev Log: Make SimpleSpiller respect subregister indices. Modified: llvm/trunk/lib/CodeGen/VirtRegMap.cpp Modified: llvm/trunk/lib/CodeGen/VirtRegMap.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/VirtRegMap.cpp?rev=54968&r1=54967&r2=54968&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/VirtRegMap.cpp (original) +++ llvm/trunk/lib/CodeGen/VirtRegMap.cpp Mon Aug 18 20:05:33 2008 @@ -241,6 +241,7 @@ DOUT << "********** Function: " << MF.getFunction()->getName() << '\n'; const TargetMachine &TM = MF.getTarget(); const TargetInstrInfo &TII = *TM.getInstrInfo(); + const TargetRegisterInfo &TRI = *TM.getRegisterInfo(); // LoadedRegs - Keep track of which vregs are loaded, so that we only load @@ -261,7 +262,9 @@ if (MO.isRegister() && MO.getReg()) { if (TargetRegisterInfo::isVirtualRegister(MO.getReg())) { unsigned VirtReg = MO.getReg(); + unsigned SubIdx = MO.getSubReg(); unsigned PhysReg = VRM.getPhys(VirtReg); + unsigned RReg = SubIdx ? TRI.getSubReg(PhysReg, SubIdx) : PhysReg; if (!VRM.isAssignedReg(VirtReg)) { int StackSlot = VRM.getStackSlot(VirtReg); const TargetRegisterClass* RC = @@ -286,8 +289,8 @@ ++NumStores; } } - MF.getRegInfo().setPhysRegUsed(PhysReg); - MI.getOperand(i).setReg(PhysReg); + MF.getRegInfo().setPhysRegUsed(RReg); + MI.getOperand(i).setReg(RReg); } else { MF.getRegInfo().setPhysRegUsed(MO.getReg()); } From dpatel at apple.com Mon Aug 18 20:13:58 2008 From: dpatel at apple.com (Devang Patel) Date: Tue, 19 Aug 2008 01:13:58 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r54969 - /llvm-gcc-4.2/trunk/build_gcc Message-ID: <200808190113.m7J1Dw3R016347@zion.cs.uiuc.edu> Author: dpatel Date: Mon Aug 18 20:13:58 2008 New Revision: 54969 URL: http://llvm.org/viewvc/llvm-project?rev=54969&view=rev Log: Compress manpages. Modified: llvm-gcc-4.2/trunk/build_gcc Modified: llvm-gcc-4.2/trunk/build_gcc URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/build_gcc?rev=54969&r1=54968&r2=54969&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/build_gcc (original) +++ llvm-gcc-4.2/trunk/build_gcc Mon Aug 18 20:13:58 2008 @@ -488,6 +488,8 @@ || exit 1 # LLVM LOCAL end done +# Compress manpages +gzip -f $MDIR/* # Build driver-driver using fully-named drivers for h in $HOSTS ; do From dpatel at apple.com Mon Aug 18 20:17:42 2008 From: dpatel at apple.com (Devang Patel) Date: Tue, 19 Aug 2008 01:17:42 -0000 Subject: [llvm-commits] [llvm] r54971 - /llvm/trunk/utils/buildit/build_llvm Message-ID: <200808190117.m7J1HgjG016457@zion.cs.uiuc.edu> Author: dpatel Date: Mon Aug 18 20:17:41 2008 New Revision: 54971 URL: http://llvm.org/viewvc/llvm-project?rev=54971&view=rev Log: Compress manpages. Modified: llvm/trunk/utils/buildit/build_llvm Modified: llvm/trunk/utils/buildit/build_llvm URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/buildit/build_llvm?rev=54971&r1=54970&r2=54971&view=diff ============================================================================== --- llvm/trunk/utils/buildit/build_llvm (original) +++ llvm/trunk/utils/buildit/build_llvm Mon Aug 18 20:17:41 2008 @@ -194,6 +194,10 @@ mv lib/libLTO.dylib $DT_HOME/lib/libLTO.dylib rm -f lib/libLTO.a lib/libLTO.la +# Compress manpages +MDIR=$DEST_DIR$DEST_ROOT/share/man/man1 +gzip -f $MDIR/* + ################################################################################ # Create SYM_DIR with information required for debugging. From nicholas at mxc.ca Mon Aug 18 21:16:16 2008 From: nicholas at mxc.ca (Nick Lewycky) Date: Mon, 18 Aug 2008 19:16:16 -0700 Subject: [llvm-commits] [llvm] r54876 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/2008-08-17-ICmpXorSignbit.ll In-Reply-To: <41A47824-D92E-44BB-BCD4-5A46AF7B2D8A@apple.com> References: <200808170734.m7H7YFS7017489@zion.cs.uiuc.edu> <41A47824-D92E-44BB-BCD4-5A46AF7B2D8A@apple.com> Message-ID: <48AA2CF0.7040302@mxc.ca> Evan Cheng wrote: > Hi Nick, > > This patch caused 256.bzip2 to regress by 20% on x86 / Mac OS X. I > took a quick look at it but can't really figure out what's wrong. Can > you investigate? I can try. Feel free to back out the patch if you like. Nick > Thanks, > > Evan > > > On Aug 17, 2008, at 12:34 AM, Nick Lewycky wrote: > >> Author: nicholas >> Date: Sun Aug 17 02:34:14 2008 >> New Revision: 54876 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=54876&view=rev >> Log: >> Xor'ing both sides of icmp by sign-bit is equivalent to swapping >> signedness of >> the predicate. >> >> Also, make this optz'n apply in more cases where it's safe to do so. >> >> Added: >> llvm/trunk/test/Transforms/InstCombine/2008-08-17-ICmpXorSignbit.ll >> Modified: >> llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp >> >> Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=54876&r1=54875&r2=54876&view=diff >> >> = >> = >> = >> = >> = >> = >> = >> = >> ====================================================================== >> --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp >> (original) >> +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Sun >> Aug 17 02:34:14 2008 >> @@ -5241,6 +5241,20 @@ >> return new ICmpInst(I.getPredicate(), A, B); >> } >> >> + ConstantInt *CI2; >> + // (icmp u/s (xor A SignBit), C) -> (icmp s/u A, (xor C SignBit)) >> + if (!I.isEquality() && >> + match(Op0, m_Xor(m_Value(A), m_ConstantInt(CI2)))) { >> + if (CI2->getValue().isSignBit()) { >> + const APInt &SignBit = CI2->getValue(); >> + ICmpInst::Predicate Pred = I.isSignedPredicate() >> + ? I.getUnsignedPredicate() >> + : I.getSignedPredicate(); >> + return new ICmpInst(Pred, A, >> + ConstantInt::get(CI->getValue() ^ >> SignBit)); >> + } >> + } >> + >> // If we have a icmp le or icmp ge instruction, turn it into the >> appropriate >> // icmp lt or icmp gt instruction. This allows us to rely on >> them being >> // folded in the code below. >> @@ -5491,35 +5505,49 @@ >> // See if it's the same type of instruction on the left and right. >> if (BinaryOperator *Op0I = dyn_cast(Op0)) { >> if (BinaryOperator *Op1I = dyn_cast(Op1)) { >> - if (Op0I->getOpcode() == Op1I->getOpcode() && Op0I- >>> hasOneUse() && >> - Op1I->hasOneUse() && Op0I->getOperand(1) == Op1I- >>> getOperand(1) && >> - I.isEquality()) { >> - switch (Op0I->getOpcode()) { >> + if (Op0I->getOpcode() == Op1I->getOpcode() && >> + Op0I->getOperand(1) == Op1I->getOperand(1)) { >> + switch (Op0I->getOpcode()) { >> default: break; >> case Instruction::Add: >> case Instruction::Sub: >> case Instruction::Xor: >> - // a+x icmp eq/ne b+x --> a icmp b >> - return new ICmpInst(I.getPredicate(), Op0I->getOperand(0), >> - Op1I->getOperand(0)); >> + if (I.isEquality()) { >> + // icmp eq/ne a+x, b+x --> icmp eq/ne a, b >> + return new ICmpInst(I.getPredicate(), Op0I- >>> getOperand(0), >> + Op1I->getOperand(0)); >> + } else { >> + // icmp u/s (a ^ signbit), (b ^ signbit) --> icmp s/u >> a, b >> + if (ConstantInt *CI = dyn_cast(Op0I- >>> getOperand(1))) { >> + if (CI->getValue().isSignBit()) { >> + ICmpInst::Predicate Pred = I.isSignedPredicate() >> + ? >> I.getUnsignedPredicate() >> + : >> I.getSignedPredicate(); >> + return new ICmpInst(Pred, Op0I->getOperand(0), >> + Op1I->getOperand(0)); >> + } >> + } >> + } >> break; >> case Instruction::Mul: >> - if (ConstantInt *CI = dyn_cast(Op0I- >>> getOperand(1))) { >> - // a * Cst icmp eq/ne b * Cst --> a & Mask icmp b & Mask >> - // Mask = -1 >> count-trailing-zeros(Cst). >> - if (!CI->isZero() && !CI->isOne()) { >> - const APInt &AP = CI->getValue(); >> - ConstantInt *Mask = ConstantInt::get( >> - >> APInt::getLowBitsSet(AP.getBitWidth(), >> - >> AP.getBitWidth() - >> + // a * Cst icmp eq/ne b * Cst --> a & Mask icmp b & Mask >> + // Mask = -1 >> count-trailing-zeros(Cst). >> + if (Op0I->hasOneUse() && Op1I->hasOneUse() && >> I.isEquality()) { >> + if (ConstantInt *CI = dyn_cast(Op0I- >>> getOperand(1))) { >> + if (!CI->isZero() && !CI->isOne()) { >> + const APInt &AP = CI->getValue(); >> + ConstantInt *Mask = >> + >> ConstantInt::get(APInt::getLowBitsSet(AP.getBitWidth(), >> + >> AP.getBitWidth() - >> >> AP.countTrailingZeros())); >> - Instruction *And1 = BinaryOperator::CreateAnd(Op0I- >>> getOperand(0), >> - Mask); >> - Instruction *And2 = BinaryOperator::CreateAnd(Op1I- >>> getOperand(0), >> - Mask); >> - InsertNewInstBefore(And1, I); >> - InsertNewInstBefore(And2, I); >> - return new ICmpInst(I.getPredicate(), And1, And2); >> + Instruction *And1 = >> + BinaryOperator::CreateAnd(Op0I->getOperand(0), >> Mask); >> + Instruction *And2 = >> + BinaryOperator::CreateAnd(Op1I->getOperand(0), >> Mask); >> + InsertNewInstBefore(And1, I); >> + InsertNewInstBefore(And2, I); >> + return new ICmpInst(I.getPredicate(), And1, And2); >> + } >> } >> } >> break; >> >> Added: llvm/trunk/test/Transforms/InstCombine/2008-08-17- >> ICmpXorSignbit.ll >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/2008-08-17-ICmpXorSignbit.ll?rev=54876&view=auto >> >> = >> = >> = >> = >> = >> = >> = >> = >> ====================================================================== >> --- llvm/trunk/test/Transforms/InstCombine/2008-08-17- >> ICmpXorSignbit.ll (added) >> +++ llvm/trunk/test/Transforms/InstCombine/2008-08-17- >> ICmpXorSignbit.ll Sun Aug 17 02:34:14 2008 >> @@ -0,0 +1,22 @@ >> +; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep -v xor >> + >> +define i1 @test1(i8 %x, i8 %y) { >> + %X = xor i8 %x, 128 >> + %Y = xor i8 %y, 128 >> + %tmp = icmp slt i8 %X, %Y >> + ret i1 %tmp >> +} >> + >> +define i1 @test2(i8 %x, i8 %y) { >> + %X = xor i8 %x, 128 >> + %Y = xor i8 %y, 128 >> + %tmp = icmp ult i8 %X, %Y >> + ret i1 %tmp >> +} >> + >> +define i1 @test3(i8 %x) { >> + %X = xor i8 %x, 128 >> + %tmp = icmp uge i8 %X, 15 >> + ret i1 %tmp >> +} >> + >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From sabre at nondot.org Mon Aug 18 23:23:04 2008 From: sabre at nondot.org (Chris Lattner) Date: Tue, 19 Aug 2008 04:23:04 -0000 Subject: [llvm-commits] [llvm] r54972 - /llvm/trunk/include/llvm/Support/raw_ostream.h Message-ID: <200808190423.m7J4N4if021627@zion.cs.uiuc.edu> Author: lattner Date: Mon Aug 18 23:23:02 2008 New Revision: 54972 URL: http://llvm.org/viewvc/llvm-project?rev=54972&view=rev Log: add raw_ostream method for emitting an unsigned. Modified: llvm/trunk/include/llvm/Support/raw_ostream.h Modified: llvm/trunk/include/llvm/Support/raw_ostream.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/raw_ostream.h?rev=54972&r1=54971&r2=54972&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/raw_ostream.h (original) +++ llvm/trunk/include/llvm/Support/raw_ostream.h Mon Aug 18 23:23:02 2008 @@ -72,6 +72,23 @@ return write(Str, strlen(Str)); } + raw_ostream &operator<<(unsigned N) { + // Zero is a special case. + if (N == 0) + return *this << '0'; + + char NumberBuffer[20]; + char *EndPtr = NumberBuffer+sizeof(NumberBuffer); + char *CurPtr = EndPtr; + + while (N) { + *--CurPtr = '0' + char(N % 10); + N /= 10; + } + return write(CurPtr, EndPtr-CurPtr); + } + + raw_ostream &write(const char *Ptr, unsigned Size) { if (OutBufCur+Size > OutBufEnd) flush_impl(); From sabre at nondot.org Mon Aug 18 23:26:57 2008 From: sabre at nondot.org (Chris Lattner) Date: Tue, 19 Aug 2008 04:26:57 -0000 Subject: [llvm-commits] [llvm] r54974 - /llvm/trunk/lib/VMCore/AsmWriter.cpp Message-ID: <200808190426.m7J4Qvrv021754@zion.cs.uiuc.edu> Author: lattner Date: Mon Aug 18 23:26:57 2008 New Revision: 54974 URL: http://llvm.org/viewvc/llvm-project?rev=54974&view=rev Log: Reid had to call this class "slot machine" out of some strange reference to the gambling device. Name it something more meaningful. Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AsmWriter.cpp?rev=54974&r1=54973&r2=54974&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/AsmWriter.cpp (original) +++ llvm/trunk/lib/VMCore/AsmWriter.cpp Mon Aug 18 23:26:57 2008 @@ -44,7 +44,7 @@ /// This class provides computation of slot numbers for LLVM Assembly writing. /// -class SlotMachine { +class SlotTracker { public: /// ValueMap - A mapping of Values to slot numbers typedef DenseMap ValueMap; @@ -67,24 +67,24 @@ public: /// Construct from a module - explicit SlotMachine(const Module *M); + explicit SlotTracker(const Module *M); /// Construct from a function, starting out in incorp state. - explicit SlotMachine(const Function *F); + explicit SlotTracker(const Function *F); /// Return the slot number of the specified value in it's type - /// plane. If something is not in the SlotMachine, return -1. + /// plane. If something is not in the SlotTracker, return -1. int getLocalSlot(const Value *V); int getGlobalSlot(const GlobalValue *V); /// If you'd like to deal with a function instead of just a module, use - /// this method to get its data into the SlotMachine. + /// this method to get its data into the SlotTracker. void incorporateFunction(const Function *F) { TheFunction = F; FunctionProcessed = false; } /// After calling incorporateFunction, use this method to remove the - /// most recently incorporated function from the SlotMachine. This + /// most recently incorporated function from the SlotTracker. This /// will reset the state of the machine back to just the module contents. void purgeFunction(); @@ -106,8 +106,8 @@ /// Add all of the functions arguments, basic blocks, and instructions void processFunction(); - SlotMachine(const SlotMachine &); // DO NOT IMPLEMENT - void operator=(const SlotMachine &); // DO NOT IMPLEMENT + SlotTracker(const SlotTracker &); // DO NOT IMPLEMENT + void operator=(const SlotTracker &); // DO NOT IMPLEMENT }; } // end namespace llvm @@ -121,7 +121,7 @@ static void WriteAsOperandInternal(std::ostream &Out, const Value *V, std::map &TypeTable, - SlotMachine *Machine); + SlotTracker *Machine); static const Module *getModuleFromVal(const Value *V) { if (const Argument *MA = dyn_cast(V)) @@ -136,19 +136,19 @@ return 0; } -static SlotMachine *createSlotMachine(const Value *V) { +static SlotTracker *createSlotTracker(const Value *V) { if (const Argument *FA = dyn_cast(V)) { - return new SlotMachine(FA->getParent()); + return new SlotTracker(FA->getParent()); } else if (const Instruction *I = dyn_cast(V)) { - return new SlotMachine(I->getParent()->getParent()); + return new SlotTracker(I->getParent()->getParent()); } else if (const BasicBlock *BB = dyn_cast(V)) { - return new SlotMachine(BB->getParent()); + return new SlotTracker(BB->getParent()); } else if (const GlobalVariable *GV = dyn_cast(V)){ - return new SlotMachine(GV->getParent()); + return new SlotTracker(GV->getParent()); } else if (const GlobalAlias *GA = dyn_cast(V)){ - return new SlotMachine(GA->getParent()); + return new SlotTracker(GA->getParent()); } else if (const Function *Func = dyn_cast(V)) { - return new SlotMachine(Func); + return new SlotTracker(Func); } return 0; } @@ -501,7 +501,7 @@ static void WriteConstantInt(std::ostream &Out, const Constant *CV, std::map &TypeTable, - SlotMachine *Machine) { + SlotTracker *Machine) { const int IndentSize = 4; // FIXME: WHY IS INDENT STATIC?? static std::string Indent = "\n"; @@ -691,7 +691,7 @@ /// static void WriteAsOperandInternal(std::ostream &Out, const Value *V, std::map &TypeTable, - SlotMachine *Machine) { + SlotTracker *Machine) { Out << ' '; if (V->hasName()) { PrintLLVMName(Out, V); @@ -721,7 +721,7 @@ Slot = Machine->getLocalSlot(V); } } else { - Machine = createSlotMachine(V); + Machine = createSlotTracker(V); if (Machine) { if (const GlobalValue *GV = dyn_cast(V)) { Slot = Machine->getGlobalSlot(GV); @@ -765,12 +765,12 @@ class AssemblyWriter { std::ostream &Out; - SlotMachine &Machine; + SlotTracker &Machine; const Module *TheModule; std::map TypeNames; AssemblyAnnotationWriter *AnnotationWriter; public: - inline AssemblyWriter(std::ostream &o, SlotMachine &Mac, const Module *M, + inline AssemblyWriter(std::ostream &o, SlotTracker &Mac, const Module *M, AssemblyAnnotationWriter *AAW) : Out(o), Machine(Mac), TheModule(M), AnnotationWriter(AAW) { @@ -1514,25 +1514,25 @@ //===----------------------------------------------------------------------===// void Module::print(std::ostream &o, AssemblyAnnotationWriter *AAW) const { - SlotMachine SlotTable(this); + SlotTracker SlotTable(this); AssemblyWriter W(o, SlotTable, this, AAW); W.write(this); } void GlobalVariable::print(std::ostream &o) const { - SlotMachine SlotTable(getParent()); + SlotTracker SlotTable(getParent()); AssemblyWriter W(o, SlotTable, getParent(), 0); W.write(this); } void GlobalAlias::print(std::ostream &o) const { - SlotMachine SlotTable(getParent()); + SlotTracker SlotTable(getParent()); AssemblyWriter W(o, SlotTable, getParent(), 0); W.write(this); } void Function::print(std::ostream &o, AssemblyAnnotationWriter *AAW) const { - SlotMachine SlotTable(getParent()); + SlotTracker SlotTable(getParent()); AssemblyWriter W(o, SlotTable, getParent(), AAW); W.write(this); @@ -1543,7 +1543,7 @@ } void BasicBlock::print(std::ostream &o, AssemblyAnnotationWriter *AAW) const { - SlotMachine SlotTable(getParent()); + SlotTracker SlotTable(getParent()); AssemblyWriter W(o, SlotTable, getParent() ? getParent()->getParent() : 0, AAW); W.write(this); @@ -1551,7 +1551,7 @@ void Instruction::print(std::ostream &o, AssemblyAnnotationWriter *AAW) const { const Function *F = getParent() ? getParent()->getParent() : 0; - SlotMachine SlotTable(F); + SlotTracker SlotTable(F); AssemblyWriter W(o, SlotTable, F ? F->getParent() : 0, AAW); W.write(this); @@ -1586,7 +1586,7 @@ void Type::dump() const { print(*cerr.stream()); cerr << '\n'; } //===----------------------------------------------------------------------===// -// SlotMachine Implementation +// SlotTracker Implementation //===----------------------------------------------------------------------===// #if 0 @@ -1597,7 +1597,7 @@ // Module level constructor. Causes the contents of the Module (sans functions) // to be added to the slot table. -SlotMachine::SlotMachine(const Module *M) +SlotTracker::SlotTracker(const Module *M) : TheModule(M) ///< Saved for lazy initialization. , TheFunction(0) , FunctionProcessed(false) @@ -1607,7 +1607,7 @@ // Function level constructor. Causes the contents of the Module and the one // function provided to be added to the slot table. -SlotMachine::SlotMachine(const Function *F) +SlotTracker::SlotTracker(const Function *F) : TheModule(F ? F->getParent() : 0) ///< Saved for lazy initialization , TheFunction(F) ///< Saved for lazy initialization , FunctionProcessed(false) @@ -1615,7 +1615,7 @@ { } -inline void SlotMachine::initialize() { +inline void SlotTracker::initialize() { if (TheModule) { processModule(); TheModule = 0; ///< Prevent re-processing next time we're called. @@ -1626,7 +1626,7 @@ // Iterate through all the global variables, functions, and global // variable initializers and create slots for them. -void SlotMachine::processModule() { +void SlotTracker::processModule() { SC_DEBUG("begin processModule!\n"); // Add all of the unnamed global variables to the value table. @@ -1646,7 +1646,7 @@ // Process the arguments, basic blocks, and instructions of a function. -void SlotMachine::processFunction() { +void SlotTracker::processFunction() { SC_DEBUG("begin processFunction!\n"); fNext = 0; @@ -1676,7 +1676,7 @@ /// Clean up after incorporating a function. This is the only way to get out of /// the function incorporation state that affects get*Slot/Create*Slot. Function /// incorporation state is indicated by TheFunction != 0. -void SlotMachine::purgeFunction() { +void SlotTracker::purgeFunction() { SC_DEBUG("begin purgeFunction!\n"); fMap.clear(); // Simply discard the function level map TheFunction = 0; @@ -1685,7 +1685,7 @@ } /// getGlobalSlot - Get the slot number of a global value. -int SlotMachine::getGlobalSlot(const GlobalValue *V) { +int SlotTracker::getGlobalSlot(const GlobalValue *V) { // Check for uninitialized state and do lazy initialization. initialize(); @@ -1696,7 +1696,7 @@ /// getLocalSlot - Get the slot number for a value that is local to a function. -int SlotMachine::getLocalSlot(const Value *V) { +int SlotTracker::getLocalSlot(const Value *V) { assert(!isa(V) && "Can't get a constant or global slot with this!"); // Check for uninitialized state and do lazy initialization. @@ -1708,8 +1708,8 @@ /// CreateModuleSlot - Insert the specified GlobalValue* into the slot table. -void SlotMachine::CreateModuleSlot(const GlobalValue *V) { - assert(V && "Can't insert a null Value into SlotMachine!"); +void SlotTracker::CreateModuleSlot(const GlobalValue *V) { + assert(V && "Can't insert a null Value into SlotTracker!"); assert(V->getType() != Type::VoidTy && "Doesn't need a slot!"); assert(!V->hasName() && "Doesn't need a slot!"); @@ -1726,7 +1726,7 @@ /// CreateSlot - Create a new slot for the specified value if it has no name. -void SlotMachine::CreateFunctionSlot(const Value *V) { +void SlotTracker::CreateFunctionSlot(const Value *V) { assert(V->getType() != Type::VoidTy && !V->hasName() && "Doesn't need a slot!"); From sabre at nondot.org Mon Aug 18 23:28:07 2008 From: sabre at nondot.org (Chris Lattner) Date: Tue, 19 Aug 2008 04:28:07 -0000 Subject: [llvm-commits] [llvm] r54975 - /llvm/trunk/lib/VMCore/AsmWriter.cpp Message-ID: <200808190428.m7J4S7ef021793@zion.cs.uiuc.edu> Author: lattner Date: Mon Aug 18 23:28:07 2008 New Revision: 54975 URL: http://llvm.org/viewvc/llvm-project?rev=54975&view=rev Log: put SlotTracker in an anon namespace since it is private. Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AsmWriter.cpp?rev=54975&r1=54974&r2=54975&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/AsmWriter.cpp (original) +++ llvm/trunk/lib/VMCore/AsmWriter.cpp Mon Aug 18 23:28:07 2008 @@ -37,11 +37,11 @@ #include using namespace llvm; -namespace llvm { - // Make virtual table appear in this compilation unit. AssemblyAnnotationWriter::~AssemblyAnnotationWriter() {} +namespace { + /// This class provides computation of slot numbers for LLVM Assembly writing. /// class SlotTracker { @@ -110,7 +110,7 @@ void operator=(const SlotTracker &); // DO NOT IMPLEMENT }; -} // end namespace llvm +} // end anonymous namespace char PrintModulePass::ID = 0; static RegisterPass From sabre at nondot.org Mon Aug 18 23:36:02 2008 From: sabre at nondot.org (Chris Lattner) Date: Tue, 19 Aug 2008 04:36:02 -0000 Subject: [llvm-commits] [llvm] r54976 - /llvm/trunk/lib/VMCore/AsmWriter.cpp Message-ID: <200808190436.m7J4a2WE022027@zion.cs.uiuc.edu> Author: lattner Date: Mon Aug 18 23:36:02 2008 New Revision: 54976 URL: http://llvm.org/viewvc/llvm-project?rev=54976&view=rev Log: rearrange code and make more legible. Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AsmWriter.cpp?rev=54976&r1=54975&r2=54976&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/AsmWriter.cpp (original) +++ llvm/trunk/lib/VMCore/AsmWriter.cpp Mon Aug 18 23:36:02 2008 @@ -40,78 +40,6 @@ // Make virtual table appear in this compilation unit. AssemblyAnnotationWriter::~AssemblyAnnotationWriter() {} -namespace { - -/// This class provides computation of slot numbers for LLVM Assembly writing. -/// -class SlotTracker { -public: - /// ValueMap - A mapping of Values to slot numbers - typedef DenseMap ValueMap; - -private: - /// TheModule - The module for which we are holding slot numbers - const Module* TheModule; - - /// TheFunction - The function for which we are holding slot numbers - const Function* TheFunction; - bool FunctionProcessed; - - /// mMap - The TypePlanes map for the module level data - ValueMap mMap; - unsigned mNext; - - /// fMap - The TypePlanes map for the function level data - ValueMap fMap; - unsigned fNext; - -public: - /// Construct from a module - explicit SlotTracker(const Module *M); - /// Construct from a function, starting out in incorp state. - explicit SlotTracker(const Function *F); - - /// Return the slot number of the specified value in it's type - /// plane. If something is not in the SlotTracker, return -1. - int getLocalSlot(const Value *V); - int getGlobalSlot(const GlobalValue *V); - - /// If you'd like to deal with a function instead of just a module, use - /// this method to get its data into the SlotTracker. - void incorporateFunction(const Function *F) { - TheFunction = F; - FunctionProcessed = false; - } - - /// After calling incorporateFunction, use this method to remove the - /// most recently incorporated function from the SlotTracker. This - /// will reset the state of the machine back to just the module contents. - void purgeFunction(); - - // Implementation Details -private: - /// This function does the actual initialization. - inline void initialize(); - - /// CreateModuleSlot - Insert the specified GlobalValue* into the slot table. - void CreateModuleSlot(const GlobalValue *V); - - /// CreateFunctionSlot - Insert the specified Value* into the slot table. - void CreateFunctionSlot(const Value *V); - - /// Add all of the module level global variables (and their initializers) - /// and function declarations, but not the contents of those functions. - void processModule(); - - /// Add all of the functions arguments, basic blocks, and instructions - void processFunction(); - - SlotTracker(const SlotTracker &); // DO NOT IMPLEMENT - void operator=(const SlotTracker &); // DO NOT IMPLEMENT -}; - -} // end anonymous namespace - char PrintModulePass::ID = 0; static RegisterPass X("printm", "Print module to stderr"); @@ -119,39 +47,28 @@ static RegisterPass Y("print","Print function to stderr"); -static void WriteAsOperandInternal(std::ostream &Out, const Value *V, - std::map &TypeTable, - SlotTracker *Machine); + +//===----------------------------------------------------------------------===// +// Helper Functions +//===----------------------------------------------------------------------===// static const Module *getModuleFromVal(const Value *V) { if (const Argument *MA = dyn_cast(V)) return MA->getParent() ? MA->getParent()->getParent() : 0; - else if (const BasicBlock *BB = dyn_cast(V)) + + if (const BasicBlock *BB = dyn_cast(V)) return BB->getParent() ? BB->getParent()->getParent() : 0; - else if (const Instruction *I = dyn_cast(V)) { + + if (const Instruction *I = dyn_cast(V)) { const Function *M = I->getParent() ? I->getParent()->getParent() : 0; return M ? M->getParent() : 0; - } else if (const GlobalValue *GV = dyn_cast(V)) + } + + if (const GlobalValue *GV = dyn_cast(V)) return GV->getParent(); return 0; } -static SlotTracker *createSlotTracker(const Value *V) { - if (const Argument *FA = dyn_cast(V)) { - return new SlotTracker(FA->getParent()); - } else if (const Instruction *I = dyn_cast(V)) { - return new SlotTracker(I->getParent()->getParent()); - } else if (const BasicBlock *BB = dyn_cast(V)) { - return new SlotTracker(BB->getParent()); - } else if (const GlobalVariable *GV = dyn_cast(V)){ - return new SlotTracker(GV->getParent()); - } else if (const GlobalAlias *GA = dyn_cast(V)){ - return new SlotTracker(GA->getParent()); - } else if (const Function *Func = dyn_cast(V)) { - return new SlotTracker(Func); - } - return 0; -} /// NameNeedsQuotes - Return true if the specified llvm name should be wrapped /// with ""'s. @@ -214,10 +131,10 @@ PrefixType Prefix) { assert(Name && "Cannot get empty name!"); switch (Prefix) { - default: assert(0 && "Bad prefix!"); - case GlobalPrefix: OS << '@'; break; - case LabelPrefix: break; - case LocalPrefix: OS << '%'; break; + default: assert(0 && "Bad prefix!"); + case GlobalPrefix: OS << '@'; break; + case LabelPrefix: break; + case LocalPrefix: OS << '%'; break; } // Scan the name to see if it needs quotes first. @@ -234,7 +151,7 @@ } } } - + // If we didn't need any quotes, just write out the name in one blast. if (!NeedsQuotes) { OS.write(NameStr, NameLen); @@ -268,12 +185,276 @@ OS << '"'; } +/// PrintLLVMName - Turn the specified name into an 'LLVM name', which is either +/// prefixed with % (if the string only contains simple characters) or is +/// surrounded with ""'s (if it has special chars in it). Print it out. static void PrintLLVMName(std::ostream &OS, const Value *V) { PrintLLVMName(OS, V->getValueName(), isa(V) ? GlobalPrefix : LocalPrefix); } + +//===----------------------------------------------------------------------===// +// SlotTracker Class: Enumerate slot numbers for unnamed values +//===----------------------------------------------------------------------===// + +namespace { + +/// This class provides computation of slot numbers for LLVM Assembly writing. +/// +class SlotTracker { +public: + /// ValueMap - A mapping of Values to slot numbers + typedef DenseMap ValueMap; + +private: + /// TheModule - The module for which we are holding slot numbers + const Module* TheModule; + + /// TheFunction - The function for which we are holding slot numbers + const Function* TheFunction; + bool FunctionProcessed; + + /// mMap - The TypePlanes map for the module level data + ValueMap mMap; + unsigned mNext; + + /// fMap - The TypePlanes map for the function level data + ValueMap fMap; + unsigned fNext; + +public: + /// Construct from a module + explicit SlotTracker(const Module *M); + /// Construct from a function, starting out in incorp state. + explicit SlotTracker(const Function *F); + + /// Return the slot number of the specified value in it's type + /// plane. If something is not in the SlotTracker, return -1. + int getLocalSlot(const Value *V); + int getGlobalSlot(const GlobalValue *V); + + /// If you'd like to deal with a function instead of just a module, use + /// this method to get its data into the SlotTracker. + void incorporateFunction(const Function *F) { + TheFunction = F; + FunctionProcessed = false; + } + + /// After calling incorporateFunction, use this method to remove the + /// most recently incorporated function from the SlotTracker. This + /// will reset the state of the machine back to just the module contents. + void purgeFunction(); + + // Implementation Details +private: + /// This function does the actual initialization. + inline void initialize(); + + /// CreateModuleSlot - Insert the specified GlobalValue* into the slot table. + void CreateModuleSlot(const GlobalValue *V); + + /// CreateFunctionSlot - Insert the specified Value* into the slot table. + void CreateFunctionSlot(const Value *V); + + /// Add all of the module level global variables (and their initializers) + /// and function declarations, but not the contents of those functions. + void processModule(); + + /// Add all of the functions arguments, basic blocks, and instructions + void processFunction(); + + SlotTracker(const SlotTracker &); // DO NOT IMPLEMENT + void operator=(const SlotTracker &); // DO NOT IMPLEMENT +}; + +} // end anonymous namespace + + +static SlotTracker *createSlotTracker(const Value *V) { + if (const Argument *FA = dyn_cast(V)) + return new SlotTracker(FA->getParent()); + + if (const Instruction *I = dyn_cast(V)) + return new SlotTracker(I->getParent()->getParent()); + + if (const BasicBlock *BB = dyn_cast(V)) + return new SlotTracker(BB->getParent()); + + if (const GlobalVariable *GV = dyn_cast(V)) + return new SlotTracker(GV->getParent()); + + if (const GlobalAlias *GA = dyn_cast(V)) + return new SlotTracker(GA->getParent()); + + if (const Function *Func = dyn_cast(V)) + return new SlotTracker(Func); + + return 0; +} + +#if 0 +#define SC_DEBUG(X) cerr << X +#else +#define SC_DEBUG(X) +#endif + +// Module level constructor. Causes the contents of the Module (sans functions) +// to be added to the slot table. +SlotTracker::SlotTracker(const Module *M) +: TheModule(M) ///< Saved for lazy initialization. +, TheFunction(0) +, FunctionProcessed(false) +, mNext(0), fNext(0) +{ +} + +// Function level constructor. Causes the contents of the Module and the one +// function provided to be added to the slot table. +SlotTracker::SlotTracker(const Function *F) +: TheModule(F ? F->getParent() : 0) ///< Saved for lazy initialization +, TheFunction(F) ///< Saved for lazy initialization +, FunctionProcessed(false) +, mNext(0), fNext(0) +{ +} + +inline void SlotTracker::initialize() { + if (TheModule) { + processModule(); + TheModule = 0; ///< Prevent re-processing next time we're called. + } + if (TheFunction && !FunctionProcessed) + processFunction(); +} + +// Iterate through all the global variables, functions, and global +// variable initializers and create slots for them. +void SlotTracker::processModule() { + SC_DEBUG("begin processModule!\n"); + + // Add all of the unnamed global variables to the value table. + for (Module::const_global_iterator I = TheModule->global_begin(), + E = TheModule->global_end(); I != E; ++I) + if (!I->hasName()) + CreateModuleSlot(I); + + // Add all the unnamed functions to the table. + for (Module::const_iterator I = TheModule->begin(), E = TheModule->end(); + I != E; ++I) + if (!I->hasName()) + CreateModuleSlot(I); + + SC_DEBUG("end processModule!\n"); +} + + +// Process the arguments, basic blocks, and instructions of a function. +void SlotTracker::processFunction() { + SC_DEBUG("begin processFunction!\n"); + fNext = 0; + + // Add all the function arguments with no names. + for(Function::const_arg_iterator AI = TheFunction->arg_begin(), + AE = TheFunction->arg_end(); AI != AE; ++AI) + if (!AI->hasName()) + CreateFunctionSlot(AI); + + SC_DEBUG("Inserting Instructions:\n"); + + // Add all of the basic blocks and instructions with no names. + for (Function::const_iterator BB = TheFunction->begin(), + E = TheFunction->end(); BB != E; ++BB) { + if (!BB->hasName()) + CreateFunctionSlot(BB); + for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I != E; ++I) + if (I->getType() != Type::VoidTy && !I->hasName()) + CreateFunctionSlot(I); + } + + FunctionProcessed = true; + + SC_DEBUG("end processFunction!\n"); +} + +/// Clean up after incorporating a function. This is the only way to get out of +/// the function incorporation state that affects get*Slot/Create*Slot. Function +/// incorporation state is indicated by TheFunction != 0. +void SlotTracker::purgeFunction() { + SC_DEBUG("begin purgeFunction!\n"); + fMap.clear(); // Simply discard the function level map + TheFunction = 0; + FunctionProcessed = false; + SC_DEBUG("end purgeFunction!\n"); +} + +/// getGlobalSlot - Get the slot number of a global value. +int SlotTracker::getGlobalSlot(const GlobalValue *V) { + // Check for uninitialized state and do lazy initialization. + initialize(); + + // Find the type plane in the module map + ValueMap::iterator MI = mMap.find(V); + return MI == mMap.end() ? -1 : MI->second; +} + + +/// getLocalSlot - Get the slot number for a value that is local to a function. +int SlotTracker::getLocalSlot(const Value *V) { + assert(!isa(V) && "Can't get a constant or global slot with this!"); + + // Check for uninitialized state and do lazy initialization. + initialize(); + + ValueMap::iterator FI = fMap.find(V); + return FI == fMap.end() ? -1 : FI->second; +} + + +/// CreateModuleSlot - Insert the specified GlobalValue* into the slot table. +void SlotTracker::CreateModuleSlot(const GlobalValue *V) { + assert(V && "Can't insert a null Value into SlotTracker!"); + assert(V->getType() != Type::VoidTy && "Doesn't need a slot!"); + assert(!V->hasName() && "Doesn't need a slot!"); + + unsigned DestSlot = mNext++; + mMap[V] = DestSlot; + + SC_DEBUG(" Inserting value [" << V->getType() << "] = " << V << " slot=" << + DestSlot << " ["); + // G = Global, F = Function, A = Alias, o = other + SC_DEBUG((isa(V) ? 'G' : + (isa(V) ? 'F' : + (isa(V) ? 'A' : 'o'))) << "]\n"); +} + + +/// CreateSlot - Create a new slot for the specified value if it has no name. +void SlotTracker::CreateFunctionSlot(const Value *V) { + assert(V->getType() != Type::VoidTy && !V->hasName() && + "Doesn't need a slot!"); + + unsigned DestSlot = fNext++; + fMap[V] = DestSlot; + + // G = Global, F = Function, o = other + SC_DEBUG(" Inserting value [" << V->getType() << "] = " << V << " slot=" << + DestSlot << " [o]\n"); +} + + + +//===----------------------------------------------------------------------===// +// AsmWriter Implementation +//===----------------------------------------------------------------------===// + +static void WriteAsOperandInternal(std::ostream &Out, const Value *V, + std::map &TypeTable, + SlotTracker *Machine); + + + /// fillTypeNameTable - If the module has a symbol table, take all global types /// and stuff their names into the TypeNames map. /// @@ -1585,155 +1766,3 @@ // Located here because so much of the needed functionality is here. void Type::dump() const { print(*cerr.stream()); cerr << '\n'; } -//===----------------------------------------------------------------------===// -// SlotTracker Implementation -//===----------------------------------------------------------------------===// - -#if 0 -#define SC_DEBUG(X) cerr << X -#else -#define SC_DEBUG(X) -#endif - -// Module level constructor. Causes the contents of the Module (sans functions) -// to be added to the slot table. -SlotTracker::SlotTracker(const Module *M) - : TheModule(M) ///< Saved for lazy initialization. - , TheFunction(0) - , FunctionProcessed(false) - , mNext(0), fNext(0) -{ -} - -// Function level constructor. Causes the contents of the Module and the one -// function provided to be added to the slot table. -SlotTracker::SlotTracker(const Function *F) - : TheModule(F ? F->getParent() : 0) ///< Saved for lazy initialization - , TheFunction(F) ///< Saved for lazy initialization - , FunctionProcessed(false) - , mNext(0), fNext(0) -{ -} - -inline void SlotTracker::initialize() { - if (TheModule) { - processModule(); - TheModule = 0; ///< Prevent re-processing next time we're called. - } - if (TheFunction && !FunctionProcessed) - processFunction(); -} - -// Iterate through all the global variables, functions, and global -// variable initializers and create slots for them. -void SlotTracker::processModule() { - SC_DEBUG("begin processModule!\n"); - - // Add all of the unnamed global variables to the value table. - for (Module::const_global_iterator I = TheModule->global_begin(), - E = TheModule->global_end(); I != E; ++I) - if (!I->hasName()) - CreateModuleSlot(I); - - // Add all the unnamed functions to the table. - for (Module::const_iterator I = TheModule->begin(), E = TheModule->end(); - I != E; ++I) - if (!I->hasName()) - CreateModuleSlot(I); - - SC_DEBUG("end processModule!\n"); -} - - -// Process the arguments, basic blocks, and instructions of a function. -void SlotTracker::processFunction() { - SC_DEBUG("begin processFunction!\n"); - fNext = 0; - - // Add all the function arguments with no names. - for(Function::const_arg_iterator AI = TheFunction->arg_begin(), - AE = TheFunction->arg_end(); AI != AE; ++AI) - if (!AI->hasName()) - CreateFunctionSlot(AI); - - SC_DEBUG("Inserting Instructions:\n"); - - // Add all of the basic blocks and instructions with no names. - for (Function::const_iterator BB = TheFunction->begin(), - E = TheFunction->end(); BB != E; ++BB) { - if (!BB->hasName()) - CreateFunctionSlot(BB); - for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I != E; ++I) - if (I->getType() != Type::VoidTy && !I->hasName()) - CreateFunctionSlot(I); - } - - FunctionProcessed = true; - - SC_DEBUG("end processFunction!\n"); -} - -/// Clean up after incorporating a function. This is the only way to get out of -/// the function incorporation state that affects get*Slot/Create*Slot. Function -/// incorporation state is indicated by TheFunction != 0. -void SlotTracker::purgeFunction() { - SC_DEBUG("begin purgeFunction!\n"); - fMap.clear(); // Simply discard the function level map - TheFunction = 0; - FunctionProcessed = false; - SC_DEBUG("end purgeFunction!\n"); -} - -/// getGlobalSlot - Get the slot number of a global value. -int SlotTracker::getGlobalSlot(const GlobalValue *V) { - // Check for uninitialized state and do lazy initialization. - initialize(); - - // Find the type plane in the module map - ValueMap::iterator MI = mMap.find(V); - return MI == mMap.end() ? -1 : MI->second; -} - - -/// getLocalSlot - Get the slot number for a value that is local to a function. -int SlotTracker::getLocalSlot(const Value *V) { - assert(!isa(V) && "Can't get a constant or global slot with this!"); - - // Check for uninitialized state and do lazy initialization. - initialize(); - - ValueMap::iterator FI = fMap.find(V); - return FI == fMap.end() ? -1 : FI->second; -} - - -/// CreateModuleSlot - Insert the specified GlobalValue* into the slot table. -void SlotTracker::CreateModuleSlot(const GlobalValue *V) { - assert(V && "Can't insert a null Value into SlotTracker!"); - assert(V->getType() != Type::VoidTy && "Doesn't need a slot!"); - assert(!V->hasName() && "Doesn't need a slot!"); - - unsigned DestSlot = mNext++; - mMap[V] = DestSlot; - - SC_DEBUG(" Inserting value [" << V->getType() << "] = " << V << " slot=" << - DestSlot << " ["); - // G = Global, F = Function, A = Alias, o = other - SC_DEBUG((isa(V) ? 'G' : - (isa(V) ? 'F' : - (isa(V) ? 'A' : 'o'))) << "]\n"); -} - - -/// CreateSlot - Create a new slot for the specified value if it has no name. -void SlotTracker::CreateFunctionSlot(const Value *V) { - assert(V->getType() != Type::VoidTy && !V->hasName() && - "Doesn't need a slot!"); - - unsigned DestSlot = fNext++; - fMap[V] = DestSlot; - - // G = Global, F = Function, o = other - SC_DEBUG(" Inserting value [" << V->getType() << "] = " << V << " slot=" << - DestSlot << " [o]\n"); -} From sabre at nondot.org Mon Aug 18 23:42:37 2008 From: sabre at nondot.org (Chris Lattner) Date: Tue, 19 Aug 2008 04:42:37 -0000 Subject: [llvm-commits] [llvm] r54977 - in /llvm/trunk/lib/Analysis: AliasAnalysisCounter.cpp IPA/FindUsedTypes.cpp Message-ID: <200808190442.m7J4gbXh022248@zion.cs.uiuc.edu> Author: lattner Date: Mon Aug 18 23:42:37 2008 New Revision: 54977 URL: http://llvm.org/viewvc/llvm-project?rev=54977&view=rev Log: Don't use the result of WriteAsOperand or WriteTypeSymbolic. Modified: llvm/trunk/lib/Analysis/AliasAnalysisCounter.cpp llvm/trunk/lib/Analysis/IPA/FindUsedTypes.cpp Modified: llvm/trunk/lib/Analysis/AliasAnalysisCounter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/AliasAnalysisCounter.cpp?rev=54977&r1=54976&r2=54977&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/AliasAnalysisCounter.cpp (original) +++ llvm/trunk/lib/Analysis/AliasAnalysisCounter.cpp Mon Aug 18 23:42:37 2008 @@ -140,9 +140,11 @@ if (PrintAll || (PrintAllFailures && R == MayAlias)) { cerr << AliasString << ":\t"; cerr << "[" << V1Size << "B] "; - WriteAsOperand(*cerr.stream(), V1, true, M) << ", "; + WriteAsOperand(*cerr.stream(), V1, true, M); + cerr << ", "; cerr << "[" << V2Size << "B] "; - WriteAsOperand(*cerr.stream(), V2, true, M) << "\n"; + WriteAsOperand(*cerr.stream(), V2, true, M); + cerr << "\n"; } return R; Modified: llvm/trunk/lib/Analysis/IPA/FindUsedTypes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/IPA/FindUsedTypes.cpp?rev=54977&r1=54976&r2=54977&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/IPA/FindUsedTypes.cpp (original) +++ llvm/trunk/lib/Analysis/IPA/FindUsedTypes.cpp Mon Aug 18 23:42:37 2008 @@ -59,7 +59,8 @@ UsedTypes.clear(); // reset if run multiple times... // Loop over global variables, incorporating their types - for (Module::const_global_iterator I = m.global_begin(), E = m.global_end(); I != E; ++I) { + for (Module::const_global_iterator I = m.global_begin(), E = m.global_end(); + I != E; ++I) { IncorporateType(I->getType()); if (I->hasInitializer()) IncorporateValue(I->getInitializer()); @@ -93,6 +94,8 @@ void FindUsedTypes::print(std::ostream &o, const Module *M) const { o << "Types in use by this module:\n"; for (std::set::const_iterator I = UsedTypes.begin(), - E = UsedTypes.end(); I != E; ++I) - WriteTypeSymbolic(o << " ", *I, M) << "\n"; + E = UsedTypes.end(); I != E; ++I) { + WriteTypeSymbolic(o << " ", *I, M); + o << "\n"; + } } From sabre at nondot.org Mon Aug 18 23:44:30 2008 From: sabre at nondot.org (Chris Lattner) Date: Tue, 19 Aug 2008 04:44:30 -0000 Subject: [llvm-commits] [llvm] r54978 - in /llvm/trunk/lib/CodeGen: AsmPrinter/AsmPrinter.cpp SelectionDAG/SelectionDAG.cpp Message-ID: <200808190444.m7J4iVXU022306@zion.cs.uiuc.edu> Author: lattner Date: Mon Aug 18 23:44:30 2008 New Revision: 54978 URL: http://llvm.org/viewvc/llvm-project?rev=54978&view=rev Log: don't use the result of WriteTypeSymbolic or WriteAsOperand. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=54978&r1=54977&r2=54978&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Mon Aug 18 23:44:30 2008 @@ -269,7 +269,8 @@ for (unsigned i = 0, e = CP.size(); i != e; ++i) { O << TAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << '_' << CP[i].second << ":\t\t\t\t\t" << TAI->getCommentString() << ' '; - WriteTypeSymbolic(O, CP[i].first.getType(), 0) << '\n'; + WriteTypeSymbolic(O, CP[i].first.getType(), 0); + O << '\n'; if (CP[i].first.isMachineConstantPoolEntry()) EmitMachineConstantPoolValue(CP[i].first.Val.MachineCPVal); else Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=54978&r1=54977&r2=54978&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Mon Aug 18 23:44:30 2008 @@ -4992,12 +4992,12 @@ } if (const ConstantSDNode *CSDN = dyn_cast(this)) { - cerr << "<" << CSDN->getAPIntValue() << ">"; + cerr << '<' << CSDN->getAPIntValue() << '>'; } else if (const ConstantFPSDNode *CSDN = dyn_cast(this)) { if (&CSDN->getValueAPF().getSemantics()==&APFloat::IEEEsingle) - cerr << "<" << CSDN->getValueAPF().convertToFloat() << ">"; + cerr << '<' << CSDN->getValueAPF().convertToFloat() << '>'; else if (&CSDN->getValueAPF().getSemantics()==&APFloat::IEEEdouble) - cerr << "<" << CSDN->getValueAPF().convertToDouble() << ">"; + cerr << '<' << CSDN->getValueAPF().convertToDouble() << '>'; else { cerr << "getValueAPF().convertToAPInt().dump(); @@ -5006,8 +5006,9 @@ } else if (const GlobalAddressSDNode *GADN = dyn_cast(this)) { int offset = GADN->getOffset(); - cerr << "<"; - WriteAsOperand(*cerr.stream(), GADN->getGlobal()) << ">"; + cerr << '<'; + WriteAsOperand(*cerr.stream(), GADN->getGlobal()); + cerr << '>'; if (offset > 0) cerr << " + " << offset; else From sabre at nondot.org Mon Aug 18 23:45:20 2008 From: sabre at nondot.org (Chris Lattner) Date: Tue, 19 Aug 2008 04:45:20 -0000 Subject: [llvm-commits] [llvm] r54979 - /llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp Message-ID: <200808190445.m7J4jKDL022345@zion.cs.uiuc.edu> Author: lattner Date: Mon Aug 18 23:45:19 2008 New Revision: 54979 URL: http://llvm.org/viewvc/llvm-project?rev=54979&view=rev Log: don't use the result of WriteAsOperand Modified: llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp Modified: llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp?rev=54979&r1=54978&r2=54979&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp Mon Aug 18 23:45:19 2008 @@ -58,10 +58,11 @@ static void PrintOps(Instruction *I, const std::vector &Ops) { Module *M = I->getParent()->getParent()->getParent(); cerr << Instruction::getOpcodeName(I->getOpcode()) << " " - << *Ops[0].Op->getType(); - for (unsigned i = 0, e = Ops.size(); i != e; ++i) - WriteAsOperand(*cerr.stream() << " ", Ops[i].Op, false, M) - << "," << Ops[i].Rank; + << *Ops[0].Op->getType(); + for (unsigned i = 0, e = Ops.size(); i != e; ++i) { + WriteAsOperand(*cerr.stream() << " ", Ops[i].Op, false, M); + cerr << "," << Ops[i].Rank; + } } namespace { From sabre at nondot.org Mon Aug 18 23:45:47 2008 From: sabre at nondot.org (Chris Lattner) Date: Tue, 19 Aug 2008 04:45:47 -0000 Subject: [llvm-commits] [llvm] r54980 - /llvm/trunk/lib/VMCore/Verifier.cpp Message-ID: <200808190445.m7J4jlmc022364@zion.cs.uiuc.edu> Author: lattner Date: Mon Aug 18 23:45:47 2008 New Revision: 54980 URL: http://llvm.org/viewvc/llvm-project?rev=54980&view=rev Log: whitespace cleanup Modified: llvm/trunk/lib/VMCore/Verifier.cpp Modified: llvm/trunk/lib/VMCore/Verifier.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Verifier.cpp?rev=54980&r1=54979&r2=54980&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Verifier.cpp (original) +++ llvm/trunk/lib/VMCore/Verifier.cpp Mon Aug 18 23:45:47 2008 @@ -280,7 +280,7 @@ } } - void WriteType(const Type* T ) { + void WriteType(const Type *T) { if ( !T ) return; WriteTypeSymbolic(msgs, T, Mod ); } From sabre at nondot.org Mon Aug 18 23:47:09 2008 From: sabre at nondot.org (Chris Lattner) Date: Tue, 19 Aug 2008 04:47:09 -0000 Subject: [llvm-commits] [llvm] r54981 - in /llvm/trunk: include/llvm/Assembly/Writer.h lib/VMCore/AsmWriter.cpp Message-ID: <200808190447.m7J4l9qM022411@zion.cs.uiuc.edu> Author: lattner Date: Mon Aug 18 23:47:09 2008 New Revision: 54981 URL: http://llvm.org/viewvc/llvm-project?rev=54981&view=rev Log: Change WriteTypeSymbolic/WriteAsOperand to return void instead of an ostream, which is just weird. Rename SC_DEBUG -> ST_DEBUG Remove static indentation strangeness from WriteConstantInt. This makes it so that large structs are not broken down and printed on multiple lines. If there is demand for this to return, there are better ways to implement this. Modified: llvm/trunk/include/llvm/Assembly/Writer.h llvm/trunk/lib/VMCore/AsmWriter.cpp Modified: llvm/trunk/include/llvm/Assembly/Writer.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Assembly/Writer.h?rev=54981&r1=54980&r2=54981&view=diff ============================================================================== --- llvm/trunk/include/llvm/Assembly/Writer.h (original) +++ llvm/trunk/include/llvm/Assembly/Writer.h Mon Aug 18 23:47:09 2008 @@ -29,7 +29,7 @@ // type, iff there is an entry in the Module's symbol table for the specified // type or one of its component types. This is slower than a simple x << Type; // -std::ostream &WriteTypeSymbolic(std::ostream &, const Type *, const Module *M); +void WriteTypeSymbolic(std::ostream &, const Type *, const Module *M); // WriteAsOperand - Write the name of the specified value out to the specified // ostream. This can be useful when you just want to print int %reg126, not the @@ -37,8 +37,8 @@ // then even constants get pretty-printed; for example, the type of a null // pointer is printed symbolically. // -std::ostream &WriteAsOperand(std::ostream &, const Value *, bool PrintTy = true, - const Module *Context = 0); +void WriteAsOperand(std::ostream &, const Value *, bool PrintTy = true, + const Module *Context = 0); } // End llvm namespace Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AsmWriter.cpp?rev=54981&r1=54980&r2=54981&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/AsmWriter.cpp (original) +++ llvm/trunk/lib/VMCore/AsmWriter.cpp Mon Aug 18 23:47:09 2008 @@ -295,9 +295,9 @@ } #if 0 -#define SC_DEBUG(X) cerr << X +#define ST_DEBUG(X) cerr << X #else -#define SC_DEBUG(X) +#define ST_DEBUG(X) #endif // Module level constructor. Causes the contents of the Module (sans functions) @@ -332,7 +332,7 @@ // Iterate through all the global variables, functions, and global // variable initializers and create slots for them. void SlotTracker::processModule() { - SC_DEBUG("begin processModule!\n"); + ST_DEBUG("begin processModule!\n"); // Add all of the unnamed global variables to the value table. for (Module::const_global_iterator I = TheModule->global_begin(), @@ -346,13 +346,13 @@ if (!I->hasName()) CreateModuleSlot(I); - SC_DEBUG("end processModule!\n"); + ST_DEBUG("end processModule!\n"); } // Process the arguments, basic blocks, and instructions of a function. void SlotTracker::processFunction() { - SC_DEBUG("begin processFunction!\n"); + ST_DEBUG("begin processFunction!\n"); fNext = 0; // Add all the function arguments with no names. @@ -361,7 +361,7 @@ if (!AI->hasName()) CreateFunctionSlot(AI); - SC_DEBUG("Inserting Instructions:\n"); + ST_DEBUG("Inserting Instructions:\n"); // Add all of the basic blocks and instructions with no names. for (Function::const_iterator BB = TheFunction->begin(), @@ -375,18 +375,18 @@ FunctionProcessed = true; - SC_DEBUG("end processFunction!\n"); + ST_DEBUG("end processFunction!\n"); } /// Clean up after incorporating a function. This is the only way to get out of /// the function incorporation state that affects get*Slot/Create*Slot. Function /// incorporation state is indicated by TheFunction != 0. void SlotTracker::purgeFunction() { - SC_DEBUG("begin purgeFunction!\n"); + ST_DEBUG("begin purgeFunction!\n"); fMap.clear(); // Simply discard the function level map TheFunction = 0; FunctionProcessed = false; - SC_DEBUG("end purgeFunction!\n"); + ST_DEBUG("end purgeFunction!\n"); } /// getGlobalSlot - Get the slot number of a global value. @@ -421,10 +421,10 @@ unsigned DestSlot = mNext++; mMap[V] = DestSlot; - SC_DEBUG(" Inserting value [" << V->getType() << "] = " << V << " slot=" << + ST_DEBUG(" Inserting value [" << V->getType() << "] = " << V << " slot=" << DestSlot << " ["); // G = Global, F = Function, A = Alias, o = other - SC_DEBUG((isa(V) ? 'G' : + ST_DEBUG((isa(V) ? 'G' : (isa(V) ? 'F' : (isa(V) ? 'A' : 'o'))) << "]\n"); } @@ -439,7 +439,7 @@ fMap[V] = DestSlot; // G = Global, F = Function, o = other - SC_DEBUG(" Inserting value [" << V->getType() << "] = " << V << " slot=" << + ST_DEBUG(" Inserting value [" << V->getType() << "] = " << V << " slot=" << DestSlot << " [o]\n"); } @@ -618,18 +618,19 @@ /// type, iff there is an entry in the modules symbol table for the specified /// type or one of it's component types. This is slower than a simple x << Type /// -std::ostream &llvm::WriteTypeSymbolic(std::ostream &Out, const Type *Ty, - const Module *M) { +void llvm::WriteTypeSymbolic(std::ostream &Out, const Type *Ty, + const Module *M) { Out << ' '; // If they want us to print out a type, but there is no context, we can't // print it symbolically. - if (!M) - return Out << Ty->getDescription(); - - std::map TypeNames; - fillTypeNameTable(M, TypeNames); - return printTypeInt(Out, Ty, TypeNames); + if (!M) { + Out << Ty->getDescription(); + } else { + std::map TypeNames; + fillTypeNameTable(M, TypeNames); + printTypeInt(Out, Ty, TypeNames); + } } // PrintEscapedString - Print each character of the specified string, escaping @@ -683,9 +684,6 @@ static void WriteConstantInt(std::ostream &Out, const Constant *CV, std::map &TypeTable, SlotTracker *Machine) { - const int IndentSize = 4; - // FIXME: WHY IS INDENT STATIC?? - static std::string Indent = "\n"; if (const ConstantInt *CI = dyn_cast(CV)) { if (CI->getType() == Type::Int1Ty) { Out << (CI->getZExtValue() ? "true" : "false"); @@ -791,24 +789,17 @@ Out << '{'; unsigned N = CS->getNumOperands(); if (N) { - if (N > 2) { - Indent += std::string(IndentSize, ' '); - Out << Indent; - } else { - Out << ' '; - } + Out << ' '; printTypeInt(Out, CS->getOperand(0)->getType(), TypeTable); WriteAsOperandInternal(Out, CS->getOperand(0), TypeTable, Machine); for (unsigned i = 1; i < N; i++) { Out << ", "; - if (N > 2) Out << Indent; printTypeInt(Out, CS->getOperand(i)->getType(), TypeTable); WriteAsOperandInternal(Out, CS->getOperand(i), TypeTable, Machine); } - if (N > 2) Indent.resize(Indent.size() - IndentSize); } Out << " }"; @@ -818,8 +809,7 @@ const Type *ETy = CP->getType()->getElementType(); assert(CP->getNumOperands() > 0 && "Number of operands for a PackedConst must be > 0"); - Out << '<'; - Out << ' '; + Out << "< "; printTypeInt(Out, ETy, TypeTable); WriteAsOperandInternal(Out, CP->getOperand(0), TypeTable, Machine); for (unsigned i = 1, e = CP->getNumOperands(); i != e; ++i) { @@ -926,8 +916,8 @@ /// ostream. This can be useful when you just want to print int %reg126, not /// the whole instruction that generated it. /// -std::ostream &llvm::WriteAsOperand(std::ostream &Out, const Value *V, - bool PrintType, const Module *Context) { +void llvm::WriteAsOperand(std::ostream &Out, const Value *V, bool PrintType, + const Module *Context) { std::map TypeNames; if (Context == 0) Context = getModuleFromVal(V); @@ -938,7 +928,6 @@ printTypeInt(Out, V->getType(), TypeNames); WriteAsOperandInternal(Out, V, TypeNames, 0); - return Out; } From sabre at nondot.org Tue Aug 19 00:06:27 2008 From: sabre at nondot.org (Chris Lattner) Date: Tue, 19 Aug 2008 05:06:27 -0000 Subject: [llvm-commits] [llvm] r54982 - /llvm/trunk/lib/VMCore/AsmWriter.cpp Message-ID: <200808190506.m7J56SIH022961@zion.cs.uiuc.edu> Author: lattner Date: Tue Aug 19 00:06:27 2008 New Revision: 54982 URL: http://llvm.org/viewvc/llvm-project?rev=54982&view=rev Log: random cleanups, factor some printing code for linkage and visibility Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AsmWriter.cpp?rev=54982&r1=54981&r2=54982&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/AsmWriter.cpp (original) +++ llvm/trunk/lib/VMCore/AsmWriter.cpp Tue Aug 19 00:06:27 2008 @@ -303,21 +303,14 @@ // Module level constructor. Causes the contents of the Module (sans functions) // to be added to the slot table. SlotTracker::SlotTracker(const Module *M) -: TheModule(M) ///< Saved for lazy initialization. -, TheFunction(0) -, FunctionProcessed(false) -, mNext(0), fNext(0) -{ + : TheModule(M), TheFunction(0), FunctionProcessed(false), mNext(0), fNext(0) { } // Function level constructor. Causes the contents of the Module and the one // function provided to be added to the slot table. SlotTracker::SlotTracker(const Function *F) -: TheModule(F ? F->getParent() : 0) ///< Saved for lazy initialization -, TheFunction(F) ///< Saved for lazy initialization -, FunctionProcessed(false) -, mNext(0), fNext(0) -{ + : TheModule(F ? F->getParent() : 0), TheFunction(F), FunctionProcessed(false), + mNext(0), fNext(0) { } inline void SlotTracker::initialize() { @@ -325,6 +318,7 @@ processModule(); TheModule = 0; ///< Prevent re-processing next time we're called. } + if (TheFunction && !FunctionProcessed) processFunction(); } @@ -724,41 +718,48 @@ assert(sizeof(double) == sizeof(uint64_t) && "assuming that double is 64 bits!"); Out << "0x" << utohexstr(DoubleToBits(Val)); - } else { - // Some form of long double. These appear as a magic letter identifying - // the type, then a fixed number of hex digits. - Out << "0x"; - if (&CFP->getValueAPF().getSemantics() == &APFloat::x87DoubleExtended) - Out << 'K'; - else if (&CFP->getValueAPF().getSemantics() == &APFloat::IEEEquad) - Out << 'L'; - else if (&CFP->getValueAPF().getSemantics() == &APFloat::PPCDoubleDouble) - Out << 'M'; + return; + } + + // Some form of long double. These appear as a magic letter identifying + // the type, then a fixed number of hex digits. + Out << "0x"; + if (&CFP->getValueAPF().getSemantics() == &APFloat::x87DoubleExtended) + Out << 'K'; + else if (&CFP->getValueAPF().getSemantics() == &APFloat::IEEEquad) + Out << 'L'; + else if (&CFP->getValueAPF().getSemantics() == &APFloat::PPCDoubleDouble) + Out << 'M'; + else + assert(0 && "Unsupported floating point type"); + // api needed to prevent premature destruction + APInt api = CFP->getValueAPF().convertToAPInt(); + const uint64_t* p = api.getRawData(); + uint64_t word = *p; + int shiftcount=60; + int width = api.getBitWidth(); + for (int j=0; j>shiftcount) & 15; + if (nibble < 10) + Out << (unsigned char)(nibble + '0'); else - assert(0 && "Unsupported floating point type"); - // api needed to prevent premature destruction - APInt api = CFP->getValueAPF().convertToAPInt(); - const uint64_t* p = api.getRawData(); - uint64_t word = *p; - int shiftcount=60; - int width = api.getBitWidth(); - for (int j=0; j>shiftcount) & 15; - if (nibble < 10) - Out << (unsigned char)(nibble + '0'); - else - Out << (unsigned char)(nibble - 10 + 'A'); - if (shiftcount == 0 && j+4 < width) { - word = *(++p); - shiftcount = 64; - if (width-j-4 < 64) - shiftcount = width-j-4; - } + Out << (unsigned char)(nibble - 10 + 'A'); + if (shiftcount == 0 && j+4 < width) { + word = *(++p); + shiftcount = 64; + if (width-j-4 < 64) + shiftcount = width-j-4; } } - } else if (isa(CV)) { + return; + } + + if (isa(CV)) { Out << "zeroinitializer"; - } else if (const ConstantArray *CA = dyn_cast(CV)) { + return; + } + + if (const ConstantArray *CA = dyn_cast(CV)) { // As a special case, print the array as a string if it is an array of // i8 with ConstantInt values. // @@ -766,8 +767,7 @@ if (CA->isString()) { Out << "c\""; PrintEscapedString(CA->getAsString(), Out); - Out << "\""; - + Out << '"'; } else { // Cannot output in string format... Out << '['; if (CA->getNumOperands()) { @@ -783,7 +783,10 @@ } Out << " ]"; } - } else if (const ConstantStruct *CS = dyn_cast(CV)) { + return; + } + + if (const ConstantStruct *CS = dyn_cast(CV)) { if (CS->getType()->isPacked()) Out << '<'; Out << '{'; @@ -805,29 +808,39 @@ Out << " }"; if (CS->getType()->isPacked()) Out << '>'; - } else if (const ConstantVector *CP = dyn_cast(CV)) { - const Type *ETy = CP->getType()->getElementType(); - assert(CP->getNumOperands() > 0 && - "Number of operands for a PackedConst must be > 0"); - Out << "< "; - printTypeInt(Out, ETy, TypeTable); - WriteAsOperandInternal(Out, CP->getOperand(0), TypeTable, Machine); - for (unsigned i = 1, e = CP->getNumOperands(); i != e; ++i) { - Out << ", "; - printTypeInt(Out, ETy, TypeTable); - WriteAsOperandInternal(Out, CP->getOperand(i), TypeTable, Machine); - } - Out << " >"; - } else if (isa(CV)) { + return; + } + + if (const ConstantVector *CP = dyn_cast(CV)) { + const Type *ETy = CP->getType()->getElementType(); + assert(CP->getNumOperands() > 0 && + "Number of operands for a PackedConst must be > 0"); + Out << "< "; + printTypeInt(Out, ETy, TypeTable); + WriteAsOperandInternal(Out, CP->getOperand(0), TypeTable, Machine); + for (unsigned i = 1, e = CP->getNumOperands(); i != e; ++i) { + Out << ", "; + printTypeInt(Out, ETy, TypeTable); + WriteAsOperandInternal(Out, CP->getOperand(i), TypeTable, Machine); + } + Out << " >"; + return; + } + + if (isa(CV)) { Out << "null"; - - } else if (isa(CV)) { + return; + } + + if (isa(CV)) { Out << "undef"; + return; + } - } else if (const ConstantExpr *CE = dyn_cast(CV)) { + if (const ConstantExpr *CE = dyn_cast(CV)) { Out << CE->getOpcodeName(); if (CE->isCompare()) - Out << " " << getPredicateText(CE->getPredicate()); + Out << ' ' << getPredicateText(CE->getPredicate()); Out << " ("; for (User::const_op_iterator OI=CE->op_begin(); OI != CE->op_end(); ++OI) { @@ -849,10 +862,10 @@ } Out << ')'; - - } else { - Out << ""; + return; } + + Out << ""; } @@ -872,7 +885,10 @@ const Constant *CV = dyn_cast(V); if (CV && !isa(CV)) { WriteConstantInt(Out, CV, TypeTable, Machine); - } else if (const InlineAsm *IA = dyn_cast(V)) { + return; + } + + if (const InlineAsm *IA = dyn_cast(V)) { Out << "asm "; if (IA->hasSideEffects()) Out << "sideeffect "; @@ -881,9 +897,20 @@ Out << "\", \""; PrintEscapedString(IA->getConstraintString(), Out); Out << '"'; + return; + } + + char Prefix = '%'; + int Slot; + if (Machine) { + if (const GlobalValue *GV = dyn_cast(V)) { + Slot = Machine->getGlobalSlot(GV); + Prefix = '@'; + } else { + Slot = Machine->getLocalSlot(V); + } } else { - char Prefix = '%'; - int Slot; + Machine = createSlotTracker(V); if (Machine) { if (const GlobalValue *GV = dyn_cast(V)) { Slot = Machine->getGlobalSlot(GV); @@ -892,24 +919,15 @@ Slot = Machine->getLocalSlot(V); } } else { - Machine = createSlotTracker(V); - if (Machine) { - if (const GlobalValue *GV = dyn_cast(V)) { - Slot = Machine->getGlobalSlot(GV); - Prefix = '@'; - } else { - Slot = Machine->getLocalSlot(V); - } - } else { - Slot = -1; - } - delete Machine; + Slot = -1; } - if (Slot != -1) - Out << Prefix << Slot; - else - Out << ""; + delete Machine; } + + if (Slot != -1) + Out << Prefix << Slot; + else + Out << ""; } /// WriteAsOperand - Write the name of the specified value out to the specified @@ -931,7 +949,7 @@ } -namespace llvm { +namespace { class AssemblyWriter { std::ostream &Out; @@ -950,13 +968,13 @@ fillTypeNameTable(M, TypeNames); } - inline void write(const Module *M) { printModule(M); } - inline void write(const GlobalVariable *G) { printGlobal(G); } - inline void write(const GlobalAlias *G) { printAlias(G); } - inline void write(const Function *F) { printFunction(F); } - inline void write(const BasicBlock *BB) { printBasicBlock(BB); } - inline void write(const Instruction *I) { printInstruction(*I); } - inline void write(const Type *Ty) { printType(Ty); } + void write(const Module *M) { printModule(M); } + void write(const GlobalVariable *G) { printGlobal(G); } + void write(const GlobalAlias *G) { printAlias(G); } + void write(const Function *F) { printFunction(F); } + void write(const BasicBlock *BB) { printBasicBlock(BB); } + void write(const Instruction *I) { printInstruction(*I); } + void write(const Type *Ty) { printType(Ty); } void writeOperand(const Value *Op, bool PrintType); void writeParamOperand(const Value *Operand, ParameterAttributes Attrs); @@ -983,7 +1001,7 @@ // printTypeAtLeastOneLevel - Print out one level of the possibly complex type // without considering any symbolic types that we may have equal to it. // - std::ostream &printTypeAtLeastOneLevel(const Type *Ty); + void printTypeAtLeastOneLevel(const Type *Ty); // printInfoComment - Print a little comment after the instruction indicating // which slot it occupies. @@ -994,10 +1012,13 @@ /// printTypeAtLeastOneLevel - Print out one level of the possibly complex type /// without considering any symbolic types that we may have equal to it. /// -std::ostream &AssemblyWriter::printTypeAtLeastOneLevel(const Type *Ty) { - if (const IntegerType *ITy = dyn_cast(Ty)) +void AssemblyWriter::printTypeAtLeastOneLevel(const Type *Ty) { + if (const IntegerType *ITy = dyn_cast(Ty)) { Out << "i" << utostr(ITy->getBitWidth()); - else if (const FunctionType *FTy = dyn_cast(Ty)) { + return; + } + + if (const FunctionType *FTy = dyn_cast(Ty)) { printType(FTy->getReturnType()); Out << " ("; for (FunctionType::param_iterator I = FTy->param_begin(), @@ -1011,7 +1032,10 @@ Out << "..."; } Out << ')'; - } else if (const StructType *STy = dyn_cast(Ty)) { + return; + } + + if (const StructType *STy = dyn_cast(Ty)) { if (STy->isPacked()) Out << '<'; Out << "{ "; @@ -1024,26 +1048,37 @@ Out << " }"; if (STy->isPacked()) Out << '>'; - } else if (const PointerType *PTy = dyn_cast(Ty)) { + return; + } + + if (const PointerType *PTy = dyn_cast(Ty)) { printType(PTy->getElementType()); if (unsigned AddressSpace = PTy->getAddressSpace()) Out << " addrspace(" << AddressSpace << ")"; Out << '*'; - } else if (const ArrayType *ATy = dyn_cast(Ty)) { + return; + } + + if (const ArrayType *ATy = dyn_cast(Ty)) { Out << '[' << ATy->getNumElements() << " x "; printType(ATy->getElementType()) << ']'; - } else if (const VectorType *PTy = dyn_cast(Ty)) { + return; + } + + if (const VectorType *PTy = dyn_cast(Ty)) { Out << '<' << PTy->getNumElements() << " x "; printType(PTy->getElementType()) << '>'; + return; } - else if (isa(Ty)) { + + if (isa(Ty)) { Out << "opaque"; - } else { - if (!Ty->isPrimitiveType()) - Out << ""; - printType(Ty); + return; } - return Out; + + if (!Ty->isPrimitiveType()) + Out << ""; + printType(Ty); } @@ -1051,7 +1086,10 @@ if (Operand == 0) { Out << ""; } else { - if (PrintType) { Out << ' '; printType(Operand->getType()); } + if (PrintType) { + Out << ' '; + printType(Operand->getType()); + } WriteAsOperandInternal(Out, Operand, TypeNames, &Machine); } } @@ -1136,6 +1174,34 @@ printFunction(I); } +static void PrintLinkage(GlobalValue::LinkageTypes LT, std::ostream &Out) { + switch (LT) { + case GlobalValue::InternalLinkage: Out << "internal "; break; + case GlobalValue::LinkOnceLinkage: Out << "linkonce "; break; + case GlobalValue::WeakLinkage: Out << "weak "; break; + case GlobalValue::CommonLinkage: Out << "common "; break; + case GlobalValue::AppendingLinkage: Out << "appending "; break; + case GlobalValue::DLLImportLinkage: Out << "dllimport "; break; + case GlobalValue::DLLExportLinkage: Out << "dllexport "; break; + case GlobalValue::ExternalWeakLinkage: Out << "extern_weak "; break; + case GlobalValue::ExternalLinkage: break; + case GlobalValue::GhostLinkage: + Out << "GhostLinkage not allowed in AsmWriter!\n"; + abort(); + } +} + + +static void PrintVisibility(GlobalValue::VisibilityTypes Vis, + std::ostream &Out) { + switch (Vis) { + default: assert(0 && "Invalid visibility style!"); + case GlobalValue::DefaultVisibility: break; + case GlobalValue::HiddenVisibility: Out << "hidden "; break; + case GlobalValue::ProtectedVisibility: Out << "protected "; break; + } +} + void AssemblyWriter::printGlobal(const GlobalVariable *GV) { if (GV->hasName()) { PrintLLVMName(Out, GV); @@ -1144,31 +1210,13 @@ if (!GV->hasInitializer()) { switch (GV->getLinkage()) { - case GlobalValue::DLLImportLinkage: Out << "dllimport "; break; + case GlobalValue::DLLImportLinkage: Out << "dllimport "; break; case GlobalValue::ExternalWeakLinkage: Out << "extern_weak "; break; default: Out << "external "; break; } } else { - switch (GV->getLinkage()) { - case GlobalValue::InternalLinkage: Out << "internal "; break; - case GlobalValue::CommonLinkage: Out << "common "; break; - case GlobalValue::LinkOnceLinkage: Out << "linkonce "; break; - case GlobalValue::WeakLinkage: Out << "weak "; break; - case GlobalValue::AppendingLinkage: Out << "appending "; break; - case GlobalValue::DLLImportLinkage: Out << "dllimport "; break; - case GlobalValue::DLLExportLinkage: Out << "dllexport "; break; - case GlobalValue::ExternalWeakLinkage: Out << "extern_weak "; break; - case GlobalValue::ExternalLinkage: break; - case GlobalValue::GhostLinkage: - cerr << "GhostLinkage not allowed in AsmWriter!\n"; - abort(); - } - switch (GV->getVisibility()) { - default: assert(0 && "Invalid visibility style!"); - case GlobalValue::DefaultVisibility: break; - case GlobalValue::HiddenVisibility: Out << "hidden "; break; - case GlobalValue::ProtectedVisibility: Out << "protected "; break; - } + PrintLinkage(GV->getLinkage(), Out); + PrintVisibility(GV->getVisibility(), Out); } if (GV->isThreadLocal()) Out << "thread_local "; @@ -1187,7 +1235,7 @@ Out << ", align " << GV->getAlignment(); printInfoComment(*GV); - Out << "\n"; + Out << '\n'; } void AssemblyWriter::printAlias(const GlobalAlias *GA) { @@ -1198,22 +1246,11 @@ PrintLLVMName(Out, GA); Out << " = "; } - switch (GA->getVisibility()) { - default: assert(0 && "Invalid visibility style!"); - case GlobalValue::DefaultVisibility: break; - case GlobalValue::HiddenVisibility: Out << "hidden "; break; - case GlobalValue::ProtectedVisibility: Out << "protected "; break; - } + PrintVisibility(GA->getVisibility(), Out); Out << "alias "; - switch (GA->getLinkage()) { - case GlobalValue::WeakLinkage: Out << "weak "; break; - case GlobalValue::InternalLinkage: Out << "internal "; break; - case GlobalValue::ExternalLinkage: break; - default: - assert(0 && "Invalid alias linkage"); - } + PrintLinkage(GA->getLinkage(), Out); const Constant *Aliasee = GA->getAliasee(); @@ -1250,20 +1287,21 @@ // Print the types. for (TypeSymbolTable::const_iterator TI = ST.begin(), TE = ST.end(); TI != TE; ++TI) { - Out << "\t" << getLLVMName(TI->first) << " = type "; + Out << '\t' << getLLVMName(TI->first) << " = type "; // Make sure we print out at least one level of the type structure, so // that we do not get %FILE = type %FILE // - printTypeAtLeastOneLevel(TI->second) << "\n"; + printTypeAtLeastOneLevel(TI->second); + Out << '\n'; } } /// printFunction - Print all aspects of a function. /// void AssemblyWriter::printFunction(const Function *F) { - // Print out the return type and name... - Out << "\n"; + // Print out the return type and name. + Out << '\n'; if (AnnotationWriter) AnnotationWriter->emitFunctionAnnot(F, Out); @@ -1271,27 +1309,9 @@ Out << "declare "; else Out << "define "; - - switch (F->getLinkage()) { - case GlobalValue::InternalLinkage: Out << "internal "; break; - case GlobalValue::LinkOnceLinkage: Out << "linkonce "; break; - case GlobalValue::WeakLinkage: Out << "weak "; break; - case GlobalValue::CommonLinkage: Out << "common "; break; - case GlobalValue::AppendingLinkage: Out << "appending "; break; - case GlobalValue::DLLImportLinkage: Out << "dllimport "; break; - case GlobalValue::DLLExportLinkage: Out << "dllexport "; break; - case GlobalValue::ExternalWeakLinkage: Out << "extern_weak "; break; - case GlobalValue::ExternalLinkage: break; - case GlobalValue::GhostLinkage: - cerr << "GhostLinkage not allowed in AsmWriter!\n"; - abort(); - } - switch (F->getVisibility()) { - default: assert(0 && "Invalid visibility style!"); - case GlobalValue::DefaultVisibility: break; - case GlobalValue::HiddenVisibility: Out << "hidden "; break; - case GlobalValue::ProtectedVisibility: Out << "protected "; break; - } + + PrintLinkage(F->getLinkage(), Out); + PrintVisibility(F->getVisibility(), Out); // Print the calling convention. switch (F->getCallingConv()) { From sabre at nondot.org Tue Aug 19 00:16:28 2008 From: sabre at nondot.org (Chris Lattner) Date: Tue, 19 Aug 2008 05:16:28 -0000 Subject: [llvm-commits] [llvm] r54983 - /llvm/trunk/lib/VMCore/AsmWriter.cpp Message-ID: <200808190516.m7J5GS7x023272@zion.cs.uiuc.edu> Author: lattner Date: Tue Aug 19 00:16:28 2008 New Revision: 54983 URL: http://llvm.org/viewvc/llvm-project?rev=54983&view=rev Log: more cleanup, eliminate getLLVMName when printing out type names at the top of the file. Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AsmWriter.cpp?rev=54983&r1=54982&r2=54983&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/AsmWriter.cpp (original) +++ llvm/trunk/lib/VMCore/AsmWriter.cpp Tue Aug 19 00:16:28 2008 @@ -127,20 +127,17 @@ /// PrintLLVMName - Turn the specified name into an 'LLVM name', which is either /// prefixed with % (if the string only contains simple characters) or is /// surrounded with ""'s (if it has special chars in it). Print it out. -static void PrintLLVMName(std::ostream &OS, const ValueName *Name, - PrefixType Prefix) { - assert(Name && "Cannot get empty name!"); +static void PrintLLVMName(std::ostream &OS, const char *NameStr, + unsigned NameLen, PrefixType Prefix) { + assert(NameStr && "Cannot get empty name!"); switch (Prefix) { - default: assert(0 && "Bad prefix!"); - case GlobalPrefix: OS << '@'; break; - case LabelPrefix: break; - case LocalPrefix: OS << '%'; break; + default: assert(0 && "Bad prefix!"); + case GlobalPrefix: OS << '@'; break; + case LabelPrefix: break; + case LocalPrefix: OS << '%'; break; } // Scan the name to see if it needs quotes first. - const char *NameStr = Name->getKeyData(); - unsigned NameLen = Name->getKeyLength(); - bool NeedsQuotes = NameStr[0] >= '0' && NameStr[0] <= '9'; if (!NeedsQuotes) { for (unsigned i = 0; i != NameLen; ++i) { @@ -189,7 +186,7 @@ /// prefixed with % (if the string only contains simple characters) or is /// surrounded with ""'s (if it has special chars in it). Print it out. static void PrintLLVMName(std::ostream &OS, const Value *V) { - PrintLLVMName(OS, V->getValueName(), + PrintLLVMName(OS, V->getNameStart(), V->getNameLen(), isa(V) ? GlobalPrefix : LocalPrefix); } @@ -1208,16 +1205,11 @@ Out << " = "; } - if (!GV->hasInitializer()) { - switch (GV->getLinkage()) { - case GlobalValue::DLLImportLinkage: Out << "dllimport "; break; - case GlobalValue::ExternalWeakLinkage: Out << "extern_weak "; break; - default: Out << "external "; break; - } - } else { - PrintLinkage(GV->getLinkage(), Out); - PrintVisibility(GV->getVisibility(), Out); - } + if (!GV->hasInitializer() && GV->hasExternalLinkage()) + Out << "external "; + + PrintLinkage(GV->getLinkage(), Out); + PrintVisibility(GV->getVisibility(), Out); if (GV->isThreadLocal()) Out << "thread_local "; Out << (GV->isConstant() ? "constant " : "global "); @@ -1280,14 +1272,16 @@ } printInfoComment(*GA); - Out << "\n"; + Out << '\n'; } void AssemblyWriter::printTypeSymbolTable(const TypeSymbolTable &ST) { // Print the types. for (TypeSymbolTable::const_iterator TI = ST.begin(), TE = ST.end(); TI != TE; ++TI) { - Out << '\t' << getLLVMName(TI->first) << " = type "; + Out << '\t'; + PrintLLVMName(Out, &TI->first[0], TI->first.size(), LocalPrefix); + Out << " = type "; // Make sure we print out at least one level of the type structure, so // that we do not get %FILE = type %FILE @@ -1416,7 +1410,7 @@ void AssemblyWriter::printBasicBlock(const BasicBlock *BB) { if (BB->hasName()) { // Print out the label if it exists... Out << "\n"; - PrintLLVMName(Out, BB->getValueName(), LabelPrefix); + PrintLLVMName(Out, BB->getNameStart(), BB->getNameLen(), LabelPrefix); Out << ':'; } else if (!BB->use_empty()) { // Don't print block # of no uses... Out << "\n;