From sabre at nondot.org Mon Nov 2 00:06:14 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 02 Nov 2009 06:06:14 -0000 Subject: [llvm-commits] [llvm] r85789 - in /llvm/trunk: lib/Transforms/Scalar/SCCP.cpp test/Transforms/SCCP/loadtest.ll Message-ID: <200911020606.nA266EZ5001541@zion.cs.uiuc.edu> Author: lattner Date: Mon Nov 2 00:06:14 2009 New Revision: 85789 URL: http://llvm.org/viewvc/llvm-project?rev=85789&view=rev Log: Use the libanalysis 'ConstantFoldLoadFromConstPtr' function instead of reinventing SCCP-specific logic. This gives us new powers. Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp llvm/trunk/test/Transforms/SCCP/loadtest.ll Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCP.cpp?rev=85789&r1=85788&r2=85789&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SCCP.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Mon Nov 2 00:06:14 2009 @@ -28,6 +28,7 @@ #include "llvm/Analysis/MemoryBuiltins.h" #include "llvm/Analysis/ValueTracking.h" #include "llvm/Transforms/Utils/Local.h" +#include "llvm/Target/TargetData.h" #include "llvm/Support/CallSite.h" #include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" @@ -154,6 +155,7 @@ /// Constant Propagation. /// class SCCPSolver : public InstVisitor { + const TargetData *TD; DenseSet BBExecutable;// The basic blocks that are executable DenseMap ValueState; // The state each value is in. @@ -194,6 +196,7 @@ typedef std::pair Edge; DenseSet KnownFeasibleEdges; public: + SCCPSolver(const TargetData *td) : TD(td) {} /// MarkBlockExecutable - This method can be used by clients to mark all of /// the blocks that are known to be intrinsically live in the processed unit. @@ -1109,16 +1112,15 @@ // global, we can replace the load with the loaded constant value! void SCCPSolver::visitLoadInst(LoadInst &I) { LatticeVal PtrVal = getValueState(I.getOperand(0)); + if (PtrVal.isUndefined()) return; // The pointer is not resolved yet! LatticeVal &IV = ValueState[&I]; if (IV.isOverdefined()) return; - if (PtrVal.isUndefined()) return; // The pointer is not resolved yet! - if (!PtrVal.isConstant() || I.isVolatile()) return markOverdefined(IV, &I); - Value *Ptr = PtrVal.getConstant(); + Constant *Ptr = PtrVal.getConstant(); // load null -> null if (isa(Ptr) && I.getPointerAddressSpace() == 0) @@ -1126,11 +1128,7 @@ // Transform load (constant global) into the value loaded. if (GlobalVariable *GV = dyn_cast(Ptr)) { - if (GV->isConstant()) { - if (GV->hasDefinitiveInitializer()) - return markConstant(IV, &I, GV->getInitializer()); - - } else if (!TrackedGlobals.empty()) { + if (!TrackedGlobals.empty()) { // If we are tracking this global, merge in the known value for it. DenseMap::iterator It = TrackedGlobals.find(GV); @@ -1141,14 +1139,9 @@ } } - // Transform load (constantexpr_GEP global, 0, ...) into the value loaded. - if (ConstantExpr *CE = dyn_cast(Ptr)) - if (CE->getOpcode() == Instruction::GetElementPtr) - if (GlobalVariable *GV = dyn_cast(CE->getOperand(0))) - if (GV->isConstant() && GV->hasDefinitiveInitializer()) - if (Constant *V = - ConstantFoldLoadThroughGEPConstantExpr(GV->getInitializer(), CE)) - return markConstant(IV, &I, V); + // Transform load from a constant into a constant if possible. + if (Constant *C = ConstantFoldLoadFromConstPtr(Ptr, TD)) + return markConstant(IV, &I, C); // Otherwise we cannot say for certain what value this load will produce. // Bail out. @@ -1530,7 +1523,7 @@ // bool SCCP::runOnFunction(Function &F) { DEBUG(errs() << "SCCP on function '" << F.getName() << "'\n"); - SCCPSolver Solver; + SCCPSolver Solver(getAnalysisIfAvailable()); // Mark the first block of the function as being executable. Solver.MarkBlockExecutable(F.begin()); @@ -1640,7 +1633,7 @@ } bool IPSCCP::runOnModule(Module &M) { - SCCPSolver Solver; + SCCPSolver Solver(getAnalysisIfAvailable()); // Loop over all functions, marking arguments to those with their addresses // taken or that are external as overdefined. Modified: llvm/trunk/test/Transforms/SCCP/loadtest.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SCCP/loadtest.ll?rev=85789&r1=85788&r2=85789&view=diff ============================================================================== --- llvm/trunk/test/Transforms/SCCP/loadtest.ll (original) +++ llvm/trunk/test/Transforms/SCCP/loadtest.ll Mon Nov 2 00:06:14 2009 @@ -1,5 +1,6 @@ ; This test makes sure that these instructions are properly constant propagated. -; + +target datalayout = "e-p:32:32" ; RUN: opt < %s -sccp -S | not grep load @@ -20,7 +21,13 @@ define i32 @test3() { %A = getelementptr [2 x { i32, float }]* @Y, i64 0, i64 0, i32 0 ; [#uses=1] - %B = load i32* %A ; [#uses=1] + %B = load i32* %A ret i32 %B } +define i8 @test4() { + %A = bitcast i32* @X to i8* + %B = load i8* %A + ret i8 %B +} + From sabre at nondot.org Mon Nov 2 00:11:24 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 02 Nov 2009 06:11:24 -0000 Subject: [llvm-commits] [llvm] r85790 - /llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Message-ID: <200911020611.nA26BOrk001896@zion.cs.uiuc.edu> Author: lattner Date: Mon Nov 2 00:11:23 2009 New Revision: 85790 URL: http://llvm.org/viewvc/llvm-project?rev=85790&view=rev Log: avoid redundant lookups in BBExecutable, and make it a SmallPtrSet. Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCP.cpp?rev=85790&r1=85789&r2=85790&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SCCP.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Mon Nov 2 00:11:23 2009 @@ -37,6 +37,7 @@ #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/PointerIntPair.h" +#include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/Statistic.h" #include "llvm/ADT/STLExtras.h" @@ -156,7 +157,7 @@ /// class SCCPSolver : public InstVisitor { const TargetData *TD; - DenseSet BBExecutable;// The basic blocks that are executable + SmallPtrSet BBExecutable;// The BBs that are executable. DenseMap ValueState; // The state each value is in. /// GlobalValue - If we are tracking any values for the contents of a global @@ -200,10 +201,13 @@ /// MarkBlockExecutable - This method can be used by clients to mark all of /// the blocks that are known to be intrinsically live in the processed unit. - void MarkBlockExecutable(BasicBlock *BB) { + /// + /// This returns true if the block was not considered live before. + bool MarkBlockExecutable(BasicBlock *BB) { + if (!BBExecutable.insert(BB)) return false; DEBUG(errs() << "Marking Block Executable: " << BB->getName() << "\n"); - BBExecutable.insert(BB); // Basic block is executable! BBWorkList.push_back(BB); // Add the block to the work list! + return true; } /// TrackValueOfGlobalVariable - Clients can use this method to @@ -348,18 +352,17 @@ if (!KnownFeasibleEdges.insert(Edge(Source, Dest)).second) return; // This edge is already known to be executable! - if (BBExecutable.count(Dest)) { - DEBUG(errs() << "Marking Edge Executable: " << Source->getName() - << " -> " << Dest->getName() << "\n"); - - // The destination is already executable, but we just made an edge + if (!MarkBlockExecutable(Dest)) { + // If the destination is already executable, we just made an *edge* // feasible that wasn't before. Revisit the PHI nodes in the block // because they have potentially new operands. - for (BasicBlock::iterator I = Dest->begin(); isa(I); ++I) - visitPHINode(*cast(I)); + DEBUG(errs() << "Marking Edge Executable: " << Source->getName() + << " -> " << Dest->getName() << "\n"); - } else { - MarkBlockExecutable(Dest); + PHINode *PN; + for (BasicBlock::iterator I = Dest->begin(); + (PN = dyn_cast(I)); ++I) + visitPHINode(*PN); } } @@ -1229,8 +1232,7 @@ // Finally, if this is the first call to the function hit, mark its entry // block executable. - if (!BBExecutable.count(F->begin())) - MarkBlockExecutable(F->begin()); + MarkBlockExecutable(F->begin()); // Propagate information from this call site into the callee. CallSite::arg_iterator CAI = CS.arg_begin(); From sabre at nondot.org Mon Nov 2 00:17:08 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 02 Nov 2009 06:17:08 -0000 Subject: [llvm-commits] [llvm] r85791 - /llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Message-ID: <200911020617.nA26H8MD002290@zion.cs.uiuc.edu> Author: lattner Date: Mon Nov 2 00:17:06 2009 New Revision: 85791 URL: http://llvm.org/viewvc/llvm-project?rev=85791&view=rev Log: remove some confused code that dates from when we had "multiple return values" but not "first class aggregates" Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCP.cpp?rev=85791&r1=85790&r2=85791&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SCCP.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Mon Nov 2 00:17:06 2009 @@ -661,16 +661,8 @@ } // Handle functions that return multiple values. - if (0 && !TrackedMultipleRetVals.empty() && I.getNumOperands() > 1) { - for (unsigned i = 0, e = I.getNumOperands(); i != e; ++i) { - DenseMap, LatticeVal>::iterator - It = TrackedMultipleRetVals.find(std::make_pair(F, i)); - if (It == TrackedMultipleRetVals.end()) break; - mergeInValue(It->second, F, getValueState(I.getOperand(i))); - } - } else if (!TrackedMultipleRetVals.empty() && - /*I.getNumOperands() == 1 &&*/ - isa(I.getOperand(0)->getType())) { + if (!TrackedMultipleRetVals.empty() && + isa(I.getOperand(0)->getType())) { for (unsigned i = 0, e = I.getOperand(0)->getType()->getNumContainedTypes(); i != e; ++i) { DenseMap, LatticeVal>::iterator From sabre at nondot.org Mon Nov 2 00:28:16 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 02 Nov 2009 06:28:16 -0000 Subject: [llvm-commits] [llvm] r85792 - /llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Message-ID: <200911020628.nA26SGpw002768@zion.cs.uiuc.edu> Author: lattner Date: Mon Nov 2 00:28:16 2009 New Revision: 85792 URL: http://llvm.org/viewvc/llvm-project?rev=85792&view=rev Log: restore some code I removed in r85788, refactor it into a shared place instead of duplicating it 4 times. Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCP.cpp?rev=85792&r1=85791&r2=85792&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SCCP.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Mon Nov 2 00:28:16 2009 @@ -386,6 +386,20 @@ if (BBExecutable.count(I.getParent())) // Inst is executable? visit(I); } + + /// RemoveFromOverdefinedPHIs - If I has any entries in the + /// UsersOfOverdefinedPHIs map for PN, remove them now. + void RemoveFromOverdefinedPHIs(Instruction *I, PHINode *PN) { + if (UsersOfOverdefinedPHIs.empty()) return; + std::multimap::iterator It, E; + tie(It, E) = UsersOfOverdefinedPHIs.equal_range(PN); + while (It != E) { + if (It->second == I) + UsersOfOverdefinedPHIs.erase(It++); + else + ++It; + } + } private: friend class InstVisitor; @@ -904,8 +918,8 @@ // added ourselves to the UsersOfOverdefinedPHIs list for the PHIs, // make sure to clean out any entries that we put there, for // efficiency. - UsersOfOverdefinedPHIs.erase(PN1); - UsersOfOverdefinedPHIs.erase(PN2); + RemoveFromOverdefinedPHIs(&I, PN1); + RemoveFromOverdefinedPHIs(&I, PN2); } markOverdefined(&I); @@ -986,8 +1000,8 @@ // added ourselves to the UsersOfOverdefinedPHIs list for the PHIs, // make sure to clean out any entries that we put there, for // efficiency. - UsersOfOverdefinedPHIs.erase(PN1); - UsersOfOverdefinedPHIs.erase(PN2); + RemoveFromOverdefinedPHIs(&I, PN1); + RemoveFromOverdefinedPHIs(&I, PN2); } markOverdefined(&I); From sabre at nondot.org Mon Nov 2 00:34:04 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 02 Nov 2009 06:34:04 -0000 Subject: [llvm-commits] [llvm] r85793 - /llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Message-ID: <200911020634.nA26Y5G1003017@zion.cs.uiuc.edu> Author: lattner Date: Mon Nov 2 00:34:04 2009 New Revision: 85793 URL: http://llvm.org/viewvc/llvm-project?rev=85793&view=rev Log: don't mark the arguments of prototype overdefined, they will never be queried. Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCP.cpp?rev=85793&r1=85792&r2=85793&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SCCP.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Mon Nov 2 00:34:04 2009 @@ -1646,16 +1646,19 @@ // Loop over all functions, marking arguments to those with their addresses // taken or that are external as overdefined. // - for (Module::iterator F = M.begin(), E = M.end(); F != E; ++F) + for (Module::iterator F = M.begin(), E = M.end(); F != E; ++F) { + if (F->isDeclaration()) + continue; + if (!F->hasLocalLinkage() || AddressIsTaken(F)) { - if (!F->isDeclaration()) - Solver.MarkBlockExecutable(F->begin()); + Solver.MarkBlockExecutable(F->begin()); for (Function::arg_iterator AI = F->arg_begin(), E = F->arg_end(); AI != E; ++AI) Solver.markOverdefined(AI); } else { Solver.AddTrackedFunction(F); } + } // Loop over global variables. We inform the solver about any internal global // variables that do not have their 'addresses taken'. If they don't have From asl at math.spbu.ru Mon Nov 2 01:01:14 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Mon, 2 Nov 2009 10:01:14 +0300 Subject: [llvm-commits] [llvm] r85764 - in /llvm/trunk/lib/Target/ARM: ARM.td ARMBaseInstrInfo.cpp ARMBaseInstrInfo.h ARMInstrFormats.td ARMInstrInfo.cpp ARMInstrInfo.h Thumb1InstrInfo.cpp Thumb2InstrInfo.cpp In-Reply-To: <2DB4E637-9985-4FC7-8D08-2DB1B17BD341@apple.com> References: <200911020010.nA20Ade4021334@zion.cs.uiuc.edu> <2DB4E637-9985-4FC7-8D08-2DB1B17BD341@apple.com> Message-ID: Hello, Evan > What is "canXformTo16Bit" for? It seems that this flag is currently unused, I added it for the sake of completeness. I don't know - maybe the flag should be removed at all. -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From asl at math.spbu.ru Mon Nov 2 01:04:41 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Mon, 2 Nov 2009 10:04:41 +0300 Subject: [llvm-commits] [llvm] r85764 - in /llvm/trunk/lib/Target/ARM: ARM.td ARMBaseInstrInfo.cpp ARMBaseInstrInfo.h ARMInstrFormats.td ARMInstrInfo.cpp ARMInstrInfo.h Thumb1InstrInfo.cpp Thumb2InstrInfo.cpp In-Reply-To: References: <200911020010.nA20Ade4021334@zion.cs.uiuc.edu> <7703A6BF-6F9F-4636-961C-23B5080B78A2@apple.com> Message-ID: Hello, Evan > 1. When the register is virtual, it could have used > machineregisterinfo to find the def. It would have been much faster. Yes, however, I never saw such case in (rather huge) real codes. I will add it. > 2. When the register is physical it can scan all the way to the top of > the MBB, that's extremely expensive. Do we have any better way? It seems - no. We need to find the def of the register which is closest to the insertion point. Even if some instruction numbering would be saved after RA, then iterating of instructions seems to be cheaper than iterating over defs of the phys reg. -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From evan.cheng at apple.com Mon Nov 2 01:08:49 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Sun, 1 Nov 2009 23:08:49 -0800 Subject: [llvm-commits] [llvm] r85764 - in /llvm/trunk/lib/Target/ARM: ARM.td ARMBaseInstrInfo.cpp ARMBaseInstrInfo.h ARMInstrFormats.td ARMInstrInfo.cpp ARMInstrInfo.h Thumb1InstrInfo.cpp Thumb2InstrInfo.cpp In-Reply-To: References: <200911020010.nA20Ade4021334@zion.cs.uiuc.edu> <7703A6BF-6F9F-4636-961C-23B5080B78A2@apple.com> Message-ID: On Nov 1, 2009, at 11:04 PM, Anton Korobeynikov wrote: > Hello, Evan > >> 1. When the register is virtual, it could have used >> machineregisterinfo to find the def. It would have been much faster. > Yes, however, I never saw such case in (rather huge) real codes. I > will add it. > >> 2. When the register is physical it can scan all the way to the top >> of >> the MBB, that's extremely expensive. > Do we have any better way? It seems - no. We need to find the def of > the > register which is closest to the insertion point. Even if some > instruction > numbering would be saved after RA, then iterating of instructions > seems to > be cheaper than iterating over defs of the phys reg. This has to be done in a late pass which can walk basic blocks from top down and tracking the domain of every register. When it sees a fcpyd, it knows the domain of source register and can change it. The current implementation really is a non-starter, especially for JIT. Can you disable it for now? Evan > > -- > With best regards, Anton Korobeynikov > Faculty of Mathematics and Mechanics, Saint Petersburg State > University From evan.cheng at apple.com Mon Nov 2 01:11:55 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 02 Nov 2009 07:11:55 -0000 Subject: [llvm-commits] [llvm] r85794 - /llvm/trunk/test/CodeGen/ARM/2008-11-19-ScavengerAssert.ll Message-ID: <200911020711.nA27Bt3h004523@zion.cs.uiuc.edu> Author: evancheng Date: Mon Nov 2 01:11:54 2009 New Revision: 85794 URL: http://llvm.org/viewvc/llvm-project?rev=85794&view=rev Log: Remove an irrelevant and poorly reduced test case. Removed: llvm/trunk/test/CodeGen/ARM/2008-11-19-ScavengerAssert.ll Removed: llvm/trunk/test/CodeGen/ARM/2008-11-19-ScavengerAssert.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/2008-11-19-ScavengerAssert.ll?rev=85793&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/2008-11-19-ScavengerAssert.ll (original) +++ llvm/trunk/test/CodeGen/ARM/2008-11-19-ScavengerAssert.ll (removed) @@ -1,414 +0,0 @@ -; RUN: llc < %s -mtriple=arm-apple-darwin9 -stats |& grep asm-printer | grep 154 - - %"struct.Adv5::Ekin<3>" = type <{ i8 }> - %"struct.Adv5::X::Energyflux<3>" = type { double } - %"struct.BinaryNode >, double, MultiPatchView, 3> >,Field >, double, MultiPatchView, 3> > >" = type { %"struct.Field >,double,MultiPatchView, 3> >", %"struct.Field >,double,MultiPatchView, 3> >" } - %"struct.BinaryNode >, double, Remote >,Field >, double, Remote > >" = type { %"struct.Field >,double,Remote >", %"struct.Field >,double,Remote >" } - %"struct.BinaryNode,BinaryNode >, double, MultiPatchView, 3> >, Field >, double, MultiPatchView, 3> > > >" = type { %"struct.Adv5::X::Energyflux<3>", %"struct.BinaryNode >, double, MultiPatchView, 3> >,Field >, double, MultiPatchView, 3> > >" } - %"struct.BinaryNode,BinaryNode >, double, Remote >, Field >, double, Remote > > >" = type { %"struct.Adv5::X::Energyflux<3>", %"struct.BinaryNode >, double, Remote >,Field >, double, Remote > >" } - %"struct.Centering<3>" = type { i32, i32, %"struct.std::vector,std::allocator > >", %"struct.std::vector,std::allocator > >" } - %"struct.ContextMapper<1>" = type { i32 (...)** } - %"struct.DataBlockController" = type { %"struct.RefBlockController", %"struct.Adv5::Ekin<3>"*, i8, %"struct.SingleObservable", i32 } - %"struct.DataBlockPtr" = type { %"struct.RefCountedBlockPtr >" } - %"struct.Domain<1,DomainTraits > >" = type { %"struct.DomainBase > >" } - %"struct.Domain<1,DomainTraits > >" = type { %"struct.DomainBase > >" } - %"struct.Domain<1,DomainTraits > >" = type { %"struct.DomainBase > >" } - %"struct.Domain<3,DomainTraits > >" = type { %"struct.DomainBase > >" } - %"struct.Domain<3,DomainTraits > >" = type { %"struct.DomainBase > >" } - %"struct.Domain<3,DomainTraits > >" = type { %"struct.DomainBase > >" } - %"struct.DomainBase > >" = type { [2 x i32] } - %"struct.DomainBase > >" = type { [3 x %"struct.WrapNoInit >"] } - %"struct.DomainBase > >" = type { i32 } - %"struct.DomainBase > >" = type { [3 x %"struct.WrapNoInit >"] } - %"struct.DomainBase > >" = type { [3 x i32] } - %"struct.DomainBase > >" = type { [3 x %"struct.WrapNoInit >"] } - %"struct.DomainLayout<3>" = type { %"struct.Node,Interval<3> >" } - %"struct.DomainMap,int>" = type { i32, %"struct.DomainMapNode,int>"*, %"struct.DomainMapIterator,int>" } - %"struct.DomainMapIterator,int>" = type { %"struct.DomainMapNode,int>"*, %"struct.std::_List_const_iterator >" } - %"struct.DomainMapNode,int>" = type { %"struct.Interval<1>", %"struct.DomainMapNode,int>"*, %"struct.DomainMapNode,int>"*, %"struct.DomainMapNode,int>"*, %"struct.std::list,std::allocator > >" } - %"struct.Engine<3,Zero,ConstantFunction>" = type { %"struct.Adv5::Ekin<3>", %"struct.Interval<3>", [3 x i32] } - %"struct.Engine<3,double,Brick>" = type { %"struct.Pooma::BrickBase<3>", %"struct.DataBlockPtr", double* } - %"struct.Engine<3,double,BrickView>" = type { %"struct.Pooma::BrickViewBase<3>", %"struct.DataBlockPtr", double* } - %"struct.Engine<3,double,ConstantFunction>" = type { double, %"struct.Interval<3>", [3 x i32] } - %"struct.Engine<3,double,ExpressionTag, BinaryNode >, double, MultiPatchView, 3> >, Field >, double, MultiPatchView, 3> > > > > >" = type { %"struct.BinaryNode,BinaryNode >, double, MultiPatchView, 3> >, Field >, double, MultiPatchView, 3> > > >", %"struct.Interval<3>" } - %"struct.Engine<3,double,ExpressionTag, BinaryNode >, double, Remote >, Field >, double, Remote > > > > >" = type { %"struct.BinaryNode,BinaryNode >, double, Remote >, Field >, double, Remote > > >", %"struct.Interval<3>" } - %"struct.Engine<3,double,MultiPatch > >" = type { %"struct.ContextMapper<1>", %"struct.GridLayout<3>", %"struct.RefCountedBlockPtr >,false,RefBlockController > > >", i32* } - %"struct.Engine<3,double,MultiPatchView, 3> >" = type { %"struct.GridLayoutView<3,3>", %"struct.Engine<3,double,MultiPatch > >" } - %"struct.Engine<3,double,Remote >" = type { %"struct.Interval<3>", i32, %"struct.RefCountedPtr > >" } - %"struct.Engine<3,double,Remote >" = type { %"struct.Interval<3>", i32, %"struct.RefCountedPtr > >" } - %"struct.Field >,Zero,ConstantFunction>" = type { %"struct.FieldEngine >,Zero,ConstantFunction>" } - %"struct.Field >,double,ConstantFunction>" = type { %"struct.FieldEngine >,double,ConstantFunction>" } - %"struct.Field >,double,ExpressionTag, BinaryNode >, double, MultiPatchView, 3> >, Field >, double, MultiPatchView, 3> > > > > >" = type { %"struct.FieldEngine >,double,ExpressionTag, BinaryNode >, double, MultiPatchView, 3> >, Field >, double, MultiPatchView, 3> > > > > >" } - %"struct.Field >,double,ExpressionTag, BinaryNode >, double, Remote >, Field >, double, Remote > > > > >" = type { %"struct.FieldEngine >,double,ExpressionTag, BinaryNode >, double, Remote >, Field >, double, Remote > > > > >" } - %"struct.Field >,double,MultiPatch > >" = type { %"struct.FieldEngine >,double,MultiPatch > >" } - %"struct.Field >,double,MultiPatchView, 3> >" = type { %"struct.FieldEngine >,double,MultiPatchView, 3> >" } - %"struct.Field >,double,Remote >" = type { %"struct.FieldEngine >,double,Remote >" } - %"struct.FieldEngine >,Zero,ConstantFunction>" = type { i32, %"struct.Centering<3>", i32, %"struct.RefCountedBlockPtr, ConstantFunction>,false,RefBlockController, ConstantFunction> > >", %"struct.Interval<3>", %"struct.GuardLayers<3>", %"struct.UniformRectilinearMesh >" } - %"struct.FieldEngine >,double,ConstantFunction>" = type { i32, %"struct.Centering<3>", i32, %"struct.RefCountedBlockPtr,false,RefBlockController > >", %"struct.Interval<3>", %"struct.GuardLayers<3>", %"struct.UniformRectilinearMesh >" } - %"struct.FieldEngine >,double,ExpressionTag, BinaryNode >, double, MultiPatchView, 3> >, Field >, double, MultiPatchView, 3> > > > > >" = type { %"struct.Engine<3,double,ExpressionTag, BinaryNode >, double, MultiPatchView, 3> >, Field >, double, MultiPatchView, 3> > > > > >", %"struct.Field >,double,MultiPatchView, 3> >"* } - %"struct.FieldEngine >,double,ExpressionTag, BinaryNode >, double, Remote >, Field >, double, Remote > > > > >" = type { %"struct.Engine<3,double,ExpressionTag, BinaryNode >, double, Remote >, Field >, double, Remote > > > > >", %"struct.Field >,double,Remote >"* } - %"struct.FieldEngine >,double,MultiPatch > >" = type { i32, %"struct.Centering<3>", i32, %"struct.RefCountedBlockPtr > >,false,RefBlockController > > > >", %"struct.Interval<3>", %"struct.GuardLayers<3>", %"struct.UniformRectilinearMesh >" } - %"struct.FieldEngine >,double,MultiPatchView, 3> >" = type { i32, %"struct.Centering<3>", i32, %"struct.RefCountedBlockPtr, 3> >,false,RefBlockController, 3> > > >", %"struct.Interval<3>", %"struct.GuardLayers<3>", %"struct.UniformRectilinearMesh >" } - %"struct.FieldEngine >,double,Remote >" = type { i32, %"struct.Centering<3>", i32, %"struct.RefCountedBlockPtr >,false,RefBlockController > > >", %"struct.Interval<3>", %"struct.GuardLayers<3>", %"struct.UniformRectilinearMesh >" } - %"struct.FieldEngineBaseData<3,Zero,ConstantFunction>" = type { %"struct.Engine<3,Zero,ConstantFunction>", %struct.RelationList } - %"struct.FieldEngineBaseData<3,double,ConstantFunction>" = type { %"struct.Engine<3,double,ConstantFunction>", %struct.RelationList } - %"struct.FieldEngineBaseData<3,double,MultiPatch > >" = type { %"struct.Engine<3,double,MultiPatch > >", %struct.RelationList } - %"struct.FieldEngineBaseData<3,double,MultiPatchView, 3> >" = type { %"struct.Engine<3,double,MultiPatchView, 3> >", %struct.RelationList } - %"struct.FieldEngineBaseData<3,double,Remote >" = type { %"struct.Engine<3,double,Remote >", %struct.RelationList } - %struct.GlobalIDDataBase = type { %"struct.std::vector >", %"struct.std::map,std::allocator > >" } - %"struct.GlobalIDDataBase::Pack" = type { i32, i32, i32, i32 } - %"struct.GridLayout<3>" = type { %"struct.ContextMapper<1>", %"struct.LayoutBase<3,GridLayoutData<3> >", %"struct.Observable >" } - %"struct.GridLayoutData<3>" = type { %"struct.LayoutBaseData<3>", %struct.RefCounted, [21 x i8], i8, [3 x i32], [3 x %"struct.DomainMap,int>"], [3 x %"struct.DomainMap,int>"] } - %"struct.GridLayoutView<3,3>" = type { %"struct.LayoutBaseView<3,3,GridLayoutViewData<3, 3> >" } - %"struct.GridLayoutViewData<3,3>" = type { %"struct.LayoutBaseViewData<3,3,GridLayout<3> >", %struct.RefCounted } - %"struct.GuardLayers<3>" = type { [3 x i32], [3 x i32] } - %"struct.INode<3>" = type { %"struct.Interval<3>", %struct.GlobalIDDataBase*, i32 } - %"struct.Interval<1>" = type { %"struct.Domain<1,DomainTraits > >" } - %"struct.Interval<3>" = type { %"struct.Domain<3,DomainTraits > >" } - %"struct.LayoutBase<3,GridLayoutData<3> >" = type { %"struct.RefCountedPtr >" } - %"struct.LayoutBaseData<3>" = type { i32, %"struct.Interval<3>", %"struct.Interval<3>", %"struct.std::vector, Interval<3> >*,std::allocator, Interval<3> >*> >", %"struct.std::vector, Interval<3> >*,std::allocator, Interval<3> >*> >", %"struct.std::vector, Interval<3> >*,std::allocator, Interval<3> >*> >", i8, i8, %"struct.GuardLayers<3>", %"struct.GuardLayers<3>", %"struct.std::vector::GCFillInfo,std::allocator::GCFillInfo> >", [3 x i32], [3 x i32], %"struct.Loc<3>" } - %"struct.LayoutBaseData<3>::GCFillInfo" = type { %"struct.Interval<3>", i32, i32, i32 } - %"struct.LayoutBaseView<3,3,GridLayoutViewData<3, 3> >" = type { %"struct.RefCountedPtr >" } - %"struct.LayoutBaseViewData<3,3,GridLayout<3> >" = type { i32, %"struct.GridLayout<3>", %"struct.GuardLayers<3>", %"struct.GuardLayers<3>", %"struct.ViewIndexer<3,3>", %"struct.std::vector, Interval<3> >*,std::allocator, Interval<3> >*> >", %"struct.std::vector, Interval<3> >*,std::allocator, Interval<3> >*> >", %"struct.std::vector, Interval<3> >*,std::allocator, Interval<3> >*> >", i8 } - %"struct.Loc<1>" = type { %"struct.Domain<1,DomainTraits > >" } - %"struct.Loc<3>" = type { %"struct.Domain<3,DomainTraits > >" } - %"struct.MultiArg6 >, double, MultiPatch > >,Field >, double, MultiPatch > >,Field >, double, MultiPatch > >,Field >, double, MultiPatch > >,Field >, double, ConstantFunction>,Field >, Zero, ConstantFunction> >" = type { %"struct.Field >,double,MultiPatch > >", %! "struct.Field >,double,MultiPatch > >", %"struct.Field >,double,MultiPatch > >", %"struct.Field >,double,MultiPatch > >", %"struct.Field >,double,ConstantFunction>", %"struct.Field >,Zero,ConstantFunction>" } - %"struct.NoMeshData<3>" = type { %struct.RefCounted, %"struct.Interval<3>", %"struct.Interval<3>", %"struct.Interval<3>", %"struct.Interval<3>" } - %"struct.Node,Interval<3> >" = type { %"struct.Interval<3>", %"struct.Interval<3>", i32, i32, i32, i32 } - %"struct.Observable >" = type { %"struct.GridLayout<3>"*, %"struct.std::vector >*,std::allocator >*> >", i32, %"struct.Adv5::Ekin<3>" } - %"struct.Pooma::BrickBase<3>" = type { %"struct.DomainLayout<3>", [3 x i32], [3 x i32], i32, i8 } - %"struct.Pooma::BrickViewBase<3>" = type { %"struct.Interval<3>", [3 x i32], [3 x i32], i32, i8 } - %"struct.Range<1>" = type { %"struct.Domain<1,DomainTraits > >" } - %"struct.Range<3>" = type { %"struct.Domain<3,DomainTraits > >" } - %"struct.RefBlockController > >" = type { %struct.RefCounted, %"struct.Engine<3,double,Remote >"*, %"struct.Engine<3,double,Remote >"*, %"struct.Engine<3,double,Remote >"*, i8 } - %"struct.RefBlockController, ConstantFunction> >" = type { %struct.RefCounted, %"struct.FieldEngineBaseData<3,Zero,ConstantFunction>"*, %"struct.FieldEngineBaseData<3,Zero,ConstantFunction>"*, %"struct.FieldEngineBaseData<3,Zero,ConstantFunction>"*, i8 } - %"struct.RefBlockController >" = type { %struct.RefCounted, %"struct.FieldEngineBaseData<3,double,ConstantFunction>"*, %"struct.FieldEngineBaseData<3,double,ConstantFunction>"*, %"struct.FieldEngineBaseData<3,double,ConstantFunction>"*, i8 } - %"struct.RefBlockController > > >" = type { %struct.RefCounted, %"struct.FieldEngineBaseData<3,double,MultiPatch > >"*, %"struct.FieldEngineBaseData<3,double,MultiPatch > >"*, %"struct.FieldEngineBaseData<3,double,MultiPatch > >"*, i8 } - %"struct.RefBlockController, 3> > >" = type { %struct.RefCounted, %"struct.FieldEngineBaseData<3,double,MultiPatchView, 3> >"*, %"struct.FieldEngineBaseData<3,double,MultiPatchView, 3> >"*, %"struct.FieldEngineBaseData<3,double,MultiPatchView, 3> >"*, i8 } - %"struct.RefBlockController > >" = type { %struct.RefCounted, %"struct.FieldEngineBaseData<3,double,Remote >"*, %"struct.FieldEngineBaseData<3,double,Remote >"*, %"struct.FieldEngineBaseData<3,double,Remote >"*, i8 } - %"struct.RefBlockController" = type { %struct.RefCounted, double*, double*, double*, i8 } - %struct.RefCounted = type { i32, %"struct.Adv5::Ekin<3>" } - %"struct.RefCountedBlockPtr >,false,RefBlockController > > >" = type { i32, %"struct.RefCountedPtr > > >" } - %"struct.RefCountedBlockPtr, ConstantFunction>,false,RefBlockController, ConstantFunction> > >" = type { i32, %"struct.RefCountedPtr, ConstantFunction> > >" } - %"struct.RefCountedBlockPtr,false,RefBlockController > >" = type { i32, %"struct.RefCountedPtr > >" } - %"struct.RefCountedBlockPtr > >,false,RefBlockController > > > >" = type { i32, %"struct.RefCountedPtr > > > >" } - %"struct.RefCountedBlockPtr, 3> >,false,RefBlockController, 3> > > >" = type { i32, %"struct.RefCountedPtr, 3> > > >" } - %"struct.RefCountedBlockPtr >,false,RefBlockController > > >" = type { i32, %"struct.RefCountedPtr > > >" } - %"struct.RefCountedBlockPtr >" = type { i32, %"struct.RefCountedPtr >" } - %"struct.RefCountedPtr >" = type { %"struct.DataBlockController"* } - %"struct.RefCountedPtr >" = type { %"struct.GridLayoutData<3>"* } - %"struct.RefCountedPtr >" = type { %"struct.GridLayoutViewData<3,3>"* } - %"struct.RefCountedPtr > > >" = type { %"struct.RefBlockController > >"* } - %"struct.RefCountedPtr, ConstantFunction> > >" = type { %"struct.RefBlockController, ConstantFunction> >"* } - %"struct.RefCountedPtr > >" = type { %"struct.RefBlockController >"* } - %"struct.RefCountedPtr > > > >" = type { %"struct.RefBlockController > > >"* } - %"struct.RefCountedPtr, 3> > > >" = type { %"struct.RefBlockController, 3> > >"* } - %"struct.RefCountedPtr > > >" = type { %"struct.RefBlockController > >"* } - %"struct.RefCountedPtr" = type { %struct.RelationListData* } - %"struct.RefCountedPtr > >" = type { %"struct.Shared >"* } - %"struct.RefCountedPtr > >" = type { %"struct.Shared >"* } - %"struct.RefCountedPtr > >" = type { %"struct.UniformRectilinearMeshData >"* } - %struct.RelationList = type { %"struct.RefCountedPtr" } - %struct.RelationListData = type { %struct.RefCounted, %"struct.std::vector >" } - %struct.RelationListItem = type { i32 (...)**, i32, i32, i8 } - %"struct.Shared >" = type { %struct.RefCounted, %"struct.Engine<3,double,Brick>" } - %"struct.Shared >" = type { %struct.RefCounted, %"struct.Engine<3,double,BrickView>" } - %"struct.SingleObservable" = type { %"struct.ContextMapper<1>"* } - %"struct.UniformRectilinearMesh >" = type { %"struct.RefCountedPtr > >" } - %"struct.UniformRectilinearMeshData >" = type { %"struct.NoMeshData<3>", %"struct.Vector<3,double,Full>", %"struct.Vector<3,double,Full>" } - %"struct.Vector<3,double,Full>" = type { %"struct.VectorEngine<3,double,Full>" } - %"struct.VectorEngine<3,double,Full>" = type { [3 x double] } - %"struct.ViewIndexer<3,3>" = type { %"struct.Interval<3>", %"struct.Range<3>", [3 x i32], [3 x i32], %"struct.Loc<3>" } - %"struct.WrapNoInit >" = type { %"struct.Interval<1>" } - %"struct.WrapNoInit >" = type { %"struct.Loc<1>" } - %"struct.WrapNoInit >" = type { %"struct.Range<1>" } - %"struct.std::_List_base,std::allocator > >" = type { %"struct.std::_List_base,std::allocator > >::_List_impl" } - %"struct.std::_List_base,std::allocator > >::_List_impl" = type { %"struct.std::_List_node_base" } - %"struct.std::_List_const_iterator >" = type { %"struct.std::_List_node_base"* } - %"struct.std::_List_node_base" = type { %"struct.std::_List_node_base"*, %"struct.std::_List_node_base"* } - %"struct.std::_Rb_tree,std::_Select1st >,std::less,std::allocator > >" = type { %"struct.std::_Rb_tree,std::_Select1st >,std::less,std::allocator > >::_Rb_tree_impl,false>" } - %"struct.std::_Rb_tree,std::_Select1st >,std::less,std::allocator > >::_Rb_tree_impl,false>" = type { %"struct.Adv5::Ekin<3>", %"struct.std::_Rb_tree_node_base", i32 } - %"struct.std::_Rb_tree_node_base" = type { i32, %"struct.std::_Rb_tree_node_base"*, %"struct.std::_Rb_tree_node_base"*, %"struct.std::_Rb_tree_node_base"* } - %"struct.std::_Vector_base >" = type { %"struct.std::_Vector_base >::_Vector_impl" } - %"struct.std::_Vector_base >::_Vector_impl" = type { %"struct.GlobalIDDataBase::Pack"*, %"struct.GlobalIDDataBase::Pack"*, %"struct.GlobalIDDataBase::Pack"* } - %"struct.std::_Vector_base::GCFillInfo,std::allocator::GCFillInfo> >" = type { %"struct.std::_Vector_base::GCFillInfo,std::allocator::GCFillInfo> >::_Vector_impl" } - %"struct.std::_Vector_base::GCFillInfo,std::allocator::GCFillInfo> >::_Vector_impl" = type { %"struct.LayoutBaseData<3>::GCFillInfo"*, %"struct.LayoutBaseData<3>::GCFillInfo"*, %"struct.LayoutBaseData<3>::GCFillInfo"* } - %"struct.std::_Vector_base,std::allocator > >" = type { %"struct.std::_Vector_base,std::allocator > >::_Vector_impl" } - %"struct.std::_Vector_base,std::allocator > >::_Vector_impl" = type { %"struct.Loc<3>"*, %"struct.Loc<3>"*, %"struct.Loc<3>"* } - %"struct.std::_Vector_base, Interval<3> >*,std::allocator, Interval<3> >*> >" = type { %"struct.std::_Vector_base, Interval<3> >*,std::allocator, Interval<3> >*> >::_Vector_impl" } - %"struct.std::_Vector_base, Interval<3> >*,std::allocator, Interval<3> >*> >::_Vector_impl" = type { %"struct.Node,Interval<3> >"**, %"struct.Node,Interval<3> >"**, %"struct.Node,Interval<3> >"** } - %"struct.std::_Vector_base >*,std::allocator >*> >" = type { %"struct.std::_Vector_base >*,std::allocator >*> >::_Vector_impl" } - %"struct.std::_Vector_base >*,std::allocator >*> >::_Vector_impl" = type { %"struct.ContextMapper<1>"**, %"struct.ContextMapper<1>"**, %"struct.ContextMapper<1>"** } - %"struct.std::_Vector_base >" = type { %"struct.std::_Vector_base >::_Vector_impl" } - %"struct.std::_Vector_base >::_Vector_impl" = type { %struct.RelationListItem**, %struct.RelationListItem**, %struct.RelationListItem** } - %"struct.std::_Vector_base,std::allocator > >" = type { %"struct.std::_Vector_base,std::allocator > >::_Vector_impl" } - %"struct.std::_Vector_base,std::allocator > >::_Vector_impl" = type { %"struct.Vector<3,double,Full>"*, %"struct.Vector<3,double,Full>"*, %"struct.Vector<3,double,Full>"* } - %"struct.std::list,std::allocator > >" = type { %"struct.std::_List_base,std::allocator > >" } - %"struct.std::map,std::allocator > >" = type { %"struct.std::_Rb_tree,std::_Select1st >,std::less,std::allocator > >" } - %"struct.std::vector >" = type { %"struct.std::_Vector_base >" } - %"struct.std::vector::GCFillInfo,std::allocator::GCFillInfo> >" = type { %"struct.std::_Vector_base::GCFillInfo,std::allocator::GCFillInfo> >" } - %"struct.std::vector,std::allocator > >" = type { %"struct.std::_Vector_base,std::allocator > >" } - %"struct.std::vector, Interval<3> >*,std::allocator, Interval<3> >*> >" = type { %"struct.std::_Vector_base, Interval<3> >*,std::allocator, Interval<3> >*> >" } - %"struct.std::vector >*,std::allocator >*> >" = type { %"struct.std::_Vector_base >*,std::allocator >*> >" } - %"struct.std::vector >" = type { %"struct.std::_Vector_base >" } - %"struct.std::vector,std::allocator > >" = type { %"struct.std::_Vector_base,std::allocator > >" } - -declare void @llvm.memcpy.i32(i8*, i8*, i32, i32) nounwind - -declare fastcc void @_ZN11FieldEngineI22UniformRectilinearMeshI10MeshTraitsILi3Ed21UniformRectilinearTag12CartesianTagLi3EEEd10MultiPatchI7GridTag6RemoteI5BrickEEEC1ERKSC_(%"struct.FieldEngine >,double,MultiPatch > >"*, %"struct.FieldEngine >,double,MultiPatch > >"*) nounwind - -declare fastcc void @_ZN9CenteringILi3EEC1ERKS0_i(%"struct.Centering<3>"*, %"struct.Centering<3>"*, i32) nounwind - -declare fastcc void @_ZN11FieldEngineI22UniformRectilinearMeshI10MeshTraitsILi3Ed21UniformRectilinearTag12CartesianTagLi3EEEd6RemoteI9BrickViewEED1Ev(%"struct.FieldEngine >,double,Remote >"*) nounwind - -declare fastcc void @_ZN11FieldEngineI22UniformRectilinearMeshI10MeshTraitsILi3Ed21UniformRectilinearTag12CartesianTagLi3EEEd6RemoteI9BrickViewEEC1Id14MultiPatchViewI7GridTagS6_I5BrickELi3EEEERKS_IS5_T_T0_ERK5INodeILi3EE(%"struct.FieldEngine >,double,Remote >"*, %"struct.FieldEngine >,double,MultiPatchView, 3> >"*, %"struct.INode<3>"*) nounwind - -declare fastcc void @_ZN11FieldEngineI22UniformRectilinearMeshI10MeshTraitsILi3Ed21UniformRectilinearTag12CartesianTagLi3EEEd14MultiPatchViewI7GridTag6RemoteI5BrickELi3EEED1Ev(%"struct.FieldEngine >,double,MultiPatchView, 3> >"*) nounwind - -declare fastcc void @_ZN11FieldEngineI22UniformRectilinearMeshI10MeshTraitsILi3Ed21UniformRectilinearTag12CartesianTagLi3EEEd14MultiPatchViewI7GridTag6RemoteI5BrickELi3EEEC1Id10MultiPatchIS7_SA_EEERKS_IS5_T_T0_ERK8IntervalILi3EE(%"struct.FieldEngine >,double,MultiPatchView, 3> >"*, %"struct.FieldEngine >,double,MultiPatch > >"*, %"struct.Interval<3>"*) nounwind - -define fastcc void @t(double %dt, %"struct.Field >,double,MultiPatch > >"* %rh, %"struct.Field >,double,MultiPatch > >"* %T, %"struct.Field >,double,MultiPatch > >"* %v, %"struct.Field >,double,MultiPatch > >"* %pg, %"struct.Field >,double,MultiPatch > >"* %ph, %"struct.Field >,double,MultiPatch > >"* %cs, %"struct.Field >,double,ConstantFunction>"* %cv, %"struct.Field >,Zero,ConstantFunction>"* %dlmdlt, %"struct.Field >,double,ConstantFunction>"* %xmue, %"struct.Field >,double,MultiPatch > >"* %vint, %"struct.Field >,double,MultiPatch > >"* %cent, %"struct.Field >,double,MultiPatch > >"* %fvis, double %c_nr, double %c_av, i8 zeroext %cartvis_f) nounwind { -entry: - %0 = alloca %"struct.Field >,double,ExpressionTag, BinaryNode >, double, Remote >, Field >, double, Remote > > > > >" ; <%"struct.Field >,double,ExpressionTag, BinaryNode >, double, Remote >, Field >, double, Remote > > > > >"*> [#uses=4] - %s.i.i.i.i.i = alloca %"struct.Interval<3>" ; <%"struct.Interval<3>"*> [#uses=0] - %1 = alloca %"struct.BinaryNode,BinaryNode >, double, MultiPatchView, 3> >, Field >, double, MultiPatchView, 3> > > >" ; <%"struct.BinaryNode,BinaryNode >, double, MultiPatchView, 3> >, Field >, double, MultiPatchView, 3> > > >"*> [#uses=2] - %multiArg.i = alloca %"struct.MultiArg6 >, double, MultiPatch > >,Field >, double, MultiPatch > >,Field >, double, MultiPatch > >,Field >, double, MultiPatch > >,Field >, double, ConstantFunction>,Field >, Zero, ConstantFunction> >" ; <%"struct.MultiArg6 >, double, MultiPatch > >,Field >, double, MultiPatch > >,Field >, double, MultiPatch > >,Field >, double, MultiPatch > >,Field >, double, ConstantFunction>,Field >, Zero, ConstantFunction> >"*> [#uses=0] - %2 = alloca %"struct.Field >,double,MultiPatch > >" ; <%"struct.Field >,double,MultiPatch > >"*> [#uses=6] - %3 = alloca %"struct.Field >,double,MultiPatch > >" ; <%"struct.Field >,double,MultiPatch > >"*> [#uses=2] - %4 = alloca %"struct.Field >,double,MultiPatchView, 3> >" ; <%"struct.Field >,double,MultiPatchView, 3> >"*> [#uses=0] - %5 = alloca %"struct.Field >,double,MultiPatch > >" ; <%"struct.Field >,double,MultiPatch > >"*> [#uses=2] - %6 = alloca %"struct.Field >,double,MultiPatchView, 3> >" ; <%"struct.Field >,double,MultiPatchView, 3> >"*> [#uses=0] - %7 = alloca %"struct.Field >,double,MultiPatch > >" ; <%"struct.Field >,double,MultiPatch > >"*> [#uses=0] - %8 = alloca %"struct.Field >,double,MultiPatch > >" ; <%"struct.Field >,double,MultiPatch > >"*> [#uses=0] - %9 = alloca %"struct.Field >,double,MultiPatch > >" ; <%"struct.Field >,double,MultiPatch > >"*> [#uses=0] - %10 = alloca %"struct.Field >,double,MultiPatch > >" ; <%"struct.Field >,double,MultiPatch > >"*> [#uses=0] - %11 = alloca %"struct.Field >,double,MultiPatch > >" ; <%"struct.Field >,double,MultiPatch > >"*> [#uses=0] - %12 = alloca %"struct.Field >,double,MultiPatch > >" ; <%"struct.Field >,double,MultiPatch > >"*> [#uses=0] - %13 = alloca %"struct.Field >,double,MultiPatch > >" ; <%"struct.Field >,double,MultiPatch > >"*> [#uses=0] - %14 = alloca %"struct.Field >,double,MultiPatch > >" ; <%"struct.Field >,double,MultiPatch > >"*> [#uses=0] - %15 = alloca %"struct.Field >,double,MultiPatch > >" ; <%"struct.Field >,double,MultiPatch > >"*> [#uses=0] - %16 = alloca %"struct.Field >,double,MultiPatch > >" ; <%"struct.Field >,double,MultiPatch > >"*> [#uses=0] - %17 = alloca %"struct.Interval<3>" ; <%"struct.Interval<3>"*> [#uses=0] - %18 = alloca %"struct.Field >,double,MultiPatch > >" ; <%"struct.Field >,double,MultiPatch > >"*> [#uses=0] - %19 = alloca double ; [#uses=0] - %20 = alloca %"struct.Field >,double,MultiPatchView, 3> >" ; <%"struct.Field >,double,MultiPatchView, 3> >"*> [#uses=0] - %21 = alloca %"struct.Interval<3>" ; <%"struct.Interval<3>"*> [#uses=0] - %22 = alloca %"struct.Field >,double,MultiPatchView, 3> >" ; <%"struct.Field >,double,MultiPatchView, 3> >"*> [#uses=0] - %23 = alloca %"struct.Field >,double,MultiPatchView, 3> >" ; <%"struct.Field >,double,MultiPatchView, 3> >"*> [#uses=0] - %24 = alloca %"struct.Interval<3>" ; <%"struct.Interval<3>"*> [#uses=0] - %25 = alloca %"struct.Field >,double,MultiPatch > >" ; <%"struct.Field >,double,MultiPatch > >"*> [#uses=0] - %26 = alloca %"struct.Field >,double,MultiPatch > >" ; <%"struct.Field >,double,MultiPatch > >"*> [#uses=0] - %27 = alloca %"struct.Field >,double,MultiPatch > >" ; <%"struct.Field >,double,MultiPatch > >"*> [#uses=0] - %28 = alloca %"struct.Field >,double,MultiPatch > >" ; <%"struct.Field >,double,MultiPatch > >"*> [#uses=0] - %29 = alloca %"struct.Interval<3>" ; <%"struct.Interval<3>"*> [#uses=0] - %30 = alloca %"struct.Field >,double,MultiPatch > >" ; <%"struct.Field >,double,MultiPatch > >"*> [#uses=0] - %31 = alloca %"struct.Field >,double,MultiPatch > >" ; <%"struct.Field >,double,MultiPatch > >"*> [#uses=0] - %32 = alloca %"struct.Field >,double,MultiPatch > >" ; <%"struct.Field >,double,MultiPatch > >"*> [#uses=0] - %33 = alloca %"struct.Field >,double,MultiPatch > >" ; <%"struct.Field >,double,MultiPatch > >"*> [#uses=0] - %34 = alloca %"struct.Field >,double,MultiPatch > >" ; <%"struct.Field >,double,MultiPatch > >"*> [#uses=0] - %35 = alloca %"struct.Interval<3>" ; <%"struct.Interval<3>"*> [#uses=0] - %36 = alloca %"struct.Field >,double,MultiPatch > >" ; <%"struct.Field >,double,MultiPatch > >"*> [#uses=0] - %37 = getelementptr %"struct.Field >,double,MultiPatch > >"* %v, i32 0, i32 0, i32 5 ; <%"struct.GuardLayers<3>"*> [#uses=1] - %38 = bitcast %"struct.GuardLayers<3>"* %37 to i8* ; [#uses=1] - br label %bb.i.i.i.i.i - -bb.i.i.i.i.i: ; preds = %bb.i.i.i.i.i, %entry - %39 = icmp eq i32* null, null ; [#uses=1] - br i1 %39, label %_ZN14ScalarCodeInfoILi3ELi4EEC1Ev.exit.i, label %bb.i.i.i.i.i - -_ZN14ScalarCodeInfoILi3ELi4EEC1Ev.exit.i: ; preds = %bb.i.i.i.i.i - br label %bb.i.i.i35.i.i34 - -bb.i.i.i35.i.i34: ; preds = %bb.i.i.i35.i.i34, %_ZN14ScalarCodeInfoILi3ELi4EEC1Ev.exit.i - %40 = icmp eq i32* null, null ; [#uses=1] - br i1 %40, label %_ZNSt6vectorIbSaIbEEC1EmRKbRKS0_.exit36.i.i37, label %bb.i.i.i35.i.i34 - -_ZNSt6vectorIbSaIbEEC1EmRKbRKS0_.exit36.i.i37: ; preds = %bb.i.i.i35.i.i34 - br label %bb.i.i.i19.i.i47 - -bb.i.i.i19.i.i47: ; preds = %bb.i.i.i19.i.i47, %_ZNSt6vectorIbSaIbEEC1EmRKbRKS0_.exit36.i.i37 - %41 = icmp eq i32* null, null ; [#uses=1] - br i1 %41, label %_ZNSt6vectorIbSaIbEEC1EmRKbRKS0_.exit20.i.i50, label %bb.i.i.i19.i.i47 - -_ZNSt6vectorIbSaIbEEC1EmRKbRKS0_.exit20.i.i50: ; preds = %bb.i.i.i19.i.i47 - %42 = getelementptr %"struct.Field >,double,MultiPatch > >"* %rh, i32 0, i32 0 ; <%"struct.FieldEngine >,double,MultiPatch > >"*> [#uses=1] - br label %bb.i.i.i19.i.i.i - -bb.i.i.i19.i.i.i: ; preds = %bb.i.i.i19.i.i.i, %_ZNSt6vectorIbSaIbEEC1EmRKbRKS0_.exit20.i.i50 - %43 = icmp eq i32* null, null ; [#uses=1] - br i1 %43, label %_ZNSt6vectorIbSaIbEEC1EmRKbRKS0_.exit20.i.i.i, label %bb.i.i.i19.i.i.i - -_ZNSt6vectorIbSaIbEEC1EmRKbRKS0_.exit20.i.i.i: ; preds = %bb.i.i.i19.i.i.i - br label %bb.i.i.i35.i.i433 - -bb.i.i.i35.i.i433: ; preds = %bb.i.i.i35.i.i433, %_ZNSt6vectorIbSaIbEEC1EmRKbRKS0_.exit20.i.i.i - %44 = icmp eq i32* null, null ; [#uses=1] - br i1 %44, label %_ZNSt6vectorIbSaIbEEC1EmRKbRKS0_.exit36.i.i436, label %bb.i.i.i35.i.i433 - -_ZNSt6vectorIbSaIbEEC1EmRKbRKS0_.exit36.i.i436: ; preds = %bb.i.i.i35.i.i433 - br label %bb.i.i.i19.i.i446 - -bb.i.i.i19.i.i446: ; preds = %bb.i.i.i19.i.i446, %_ZNSt6vectorIbSaIbEEC1EmRKbRKS0_.exit36.i.i436 - %45 = icmp eq i32* null, null ; [#uses=1] - br i1 %45, label %_ZNSt6vectorIbSaIbEEC1EmRKbRKS0_.exit20.i.i449, label %bb.i.i.i19.i.i446 - -_ZNSt6vectorIbSaIbEEC1EmRKbRKS0_.exit20.i.i449: ; preds = %bb.i.i.i19.i.i446 - br label %bb.i.i.i.i.i459 - -bb.i.i.i.i.i459: ; preds = %bb.i.i.i.i.i459, %_ZNSt6vectorIbSaIbEEC1EmRKbRKS0_.exit20.i.i449 - %46 = icmp eq i32* null, null ; [#uses=1] - br i1 %46, label %_ZN14ScalarCodeInfoILi3ELi6EEC1Ev.exit.i460, label %bb.i.i.i.i.i459 - -_ZN14ScalarCodeInfoILi3ELi6EEC1Ev.exit.i460: ; preds = %bb.i.i.i.i.i459 - %47 = getelementptr %"struct.Field >,double,MultiPatch > >"* %5, i32 0, i32 0, i32 1 ; <%"struct.Centering<3>"*> [#uses=1] - %48 = getelementptr %"struct.Field >,double,MultiPatch > >"* %vint, i32 0, i32 0, i32 1 ; <%"struct.Centering<3>"*> [#uses=2] - %49 = getelementptr %"struct.Field >,double,MultiPatch > >"* %5, i32 0, i32 0, i32 5 ; <%"struct.GuardLayers<3>"*> [#uses=1] - %50 = bitcast %"struct.GuardLayers<3>"* %49 to i8* ; [#uses=1] - %51 = bitcast %"struct.GuardLayers<3>"* null to i8* ; [#uses=2] - %52 = getelementptr %"struct.Field >,double,MultiPatch > >"* %3, i32 0, i32 0, i32 1 ; <%"struct.Centering<3>"*> [#uses=1] - %53 = getelementptr %"struct.Field >,double,MultiPatch > >"* %3, i32 0, i32 0, i32 5 ; <%"struct.GuardLayers<3>"*> [#uses=1] - %54 = bitcast %"struct.GuardLayers<3>"* %53 to i8* ; [#uses=1] - %55 = getelementptr %"struct.Field >,double,MultiPatch > >"* %2, i32 0, i32 0, i32 1 ; <%"struct.Centering<3>"*> [#uses=1] - %56 = getelementptr %"struct.Field >,double,MultiPatch > >"* %2, i32 0, i32 0, i32 4, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 1 ; [#uses=1] - %57 = getelementptr %"struct.Field >,double,MultiPatch > >"* %2, i32 0, i32 0, i32 4, i32 0, i32 0, i32 0, i32 1, i32 0, i32 0, i32 0, i32 0, i32 1 ; [#uses=1] - %58 = getelementptr %"struct.Field >,double,MultiPatch > >"* %2, i32 0, i32 0, i32 4, i32 0, i32 0, i32 0, i32 2, i32 0, i32 0, i32 0, i32 0, i32 0 ; [#uses=1] - %59 = getelementptr %"struct.Field >,double,MultiPatch > >"* %2, i32 0, i32 0, i32 4, i32 0, i32 0, i32 0, i32 2, i32 0, i32 0, i32 0, i32 0, i32 1 ; [#uses=1] - %60 = getelementptr %"struct.Field >,double,MultiPatch > >"* %2, i32 0, i32 0, i32 5 ; <%"struct.GuardLayers<3>"*> [#uses=1] - %61 = bitcast %"struct.GuardLayers<3>"* %60 to i8* ; [#uses=1] - %62 = getelementptr %"struct.BinaryNode,BinaryNode >, double, MultiPatchView, 3> >, Field >, double, MultiPatchView, 3> > > >"* %1, i32 0, i32 1, i32 0, i32 0 ; <%"struct.FieldEngine >,double,MultiPatchView, 3> >"*> [#uses=1] - %63 = getelementptr %"struct.BinaryNode,BinaryNode >, double, MultiPatchView, 3> >, Field >, double, MultiPatchView, 3> > > >"* %1, i32 0, i32 1, i32 1, i32 0 ; <%"struct.FieldEngine >,double,MultiPatchView, 3> >"*> [#uses=1] - %64 = getelementptr %"struct.Field >,double,ExpressionTag, BinaryNode >, double, MultiPatchView, 3> >, Field >, double, MultiPatchView, 3> > > > > >"* null, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0 ; [#uses=1] - %65 = getelementptr %"struct.Field >,double,ExpressionTag, BinaryNode >, double, Remote >, Field >, double, Remote > > > > >"* %0, i32 0, i32 0, i32 0, i32 0, i32 1, i32 1, i32 0 ; <%"struct.FieldEngine >,double,Remote >"*> [#uses=2] - %66 = getelementptr %"struct.Field >,double,ExpressionTag, BinaryNode >, double, Remote >, Field >, double, Remote > > > > >"* %0, i32 0, i32 0, i32 0, i32 0, i32 1, i32 0, i32 0, i32 4, i32 0, i32 0, i32 0, i32 1, i32 0, i32 0, i32 0, i32 0, i32 0 ; [#uses=1] - %67 = getelementptr %"struct.Field >,double,ExpressionTag, BinaryNode >, double, Remote >, Field >, double, Remote > > > > >"* %0, i32 0, i32 0, i32 0, i32 0, i32 1, i32 0, i32 0, i32 4, i32 0, i32 0, i32 0, i32 1, i32 0, i32 0, i32 0, i32 0, i32 1 ; [#uses=1] - %68 = getelementptr %"struct.Field >,double,ExpressionTag, BinaryNode >, double, Remote >, Field >, double, Remote > > > > >"* %0, i32 0, i32 0, i32 0, i32 0, i32 1, i32 0, i32 0, i32 4, i32 0, i32 0, i32 0, i32 2, i32 0, i32 0, i32 0, i32 0, i32 1 ; [#uses=1] - br label %bb15 - -bb15: ; preds = %_Z6assignI22UniformRectilinearMeshI10MeshTraitsILi3Ed21UniformRectilinearTag12CartesianTagLi3EEEd14MultiPatchViewI7GridTag6RemoteI5BrickELi3EES5_d13ExpressionTagI10BinaryNodeI10OpMultiply6ScalarIdESD_I5OpAdd9ReferenceI5FieldIS5_dSB_EESL_EEE8OpAssignERKSJ_IT_T0_T1_ESV_RKSJ_IT2_T3_T4_ERKT5_.exit, %_ZN14ScalarCodeInfoILi3ELi6EEC1Ev.exit.i460 - %i.0.reg2mem.0 = phi i32 [ 0, %_ZN14ScalarCodeInfoILi3ELi6EEC1Ev.exit.i460 ], [ %indvar.next, %_Z6assignI22UniformRectilinearMeshI10MeshTraitsILi3Ed21UniformRectilinearTag12CartesianTagLi3EEEd14MultiPatchViewI7GridTag6RemoteI5BrickELi3EES5_d13ExpressionTagI10BinaryNodeI10OpMultiply6ScalarIdESD_I5OpAdd9ReferenceI5FieldIS5_dSB_EESL_EEE8OpAssignERKSJ_IT_T0_T1_ESV_RKSJ_IT2_T3_T4_ERKT5_.exit ] ; [#uses=4] - call fastcc void @_ZN9CenteringILi3EEC1ERKS0_i(%"struct.Centering<3>"* %47, %"struct.Centering<3>"* %48, i32 %i.0.reg2mem.0) nounwind - call void @llvm.memcpy.i32(i8* %50, i8* %51, i32 24, i32 4) nounwind - call fastcc void @_ZN9CenteringILi3EEC1ERKS0_i(%"struct.Centering<3>"* %52, %"struct.Centering<3>"* %48, i32 %i.0.reg2mem.0) nounwind - call void @llvm.memcpy.i32(i8* %54, i8* %51, i32 24, i32 4) nounwind - br i1 false, label %bb.i940, label %bb4.i943 - -bb.i940: ; preds = %bb15 - br label %_ZNK11FieldEngineI22UniformRectilinearMeshI10MeshTraitsILi3Ed21UniformRectilinearTag12CartesianTagLi3EEEd10MultiPatchI7GridTag6RemoteI5BrickEEE11totalDomainEv.exit944 - -bb4.i943: ; preds = %bb15 - br label %_ZNK11FieldEngineI22UniformRectilinearMeshI10MeshTraitsILi3Ed21UniformRectilinearTag12CartesianTagLi3EEEd10MultiPatchI7GridTag6RemoteI5BrickEEE11totalDomainEv.exit944 - -_ZNK11FieldEngineI22UniformRectilinearMeshI10MeshTraitsILi3Ed21UniformRectilinearTag12CartesianTagLi3EEEd10MultiPatchI7GridTag6RemoteI5BrickEEE11totalDomainEv.exit944: ; preds = %bb4.i943, %bb.i940 - call fastcc void @_ZN11FieldEngineI22UniformRectilinearMeshI10MeshTraitsILi3Ed21UniformRectilinearTag12CartesianTagLi3EEEd14MultiPatchViewI7GridTag6RemoteI5BrickELi3EEEC1Id10MultiPatchIS7_SA_EEERKS_IS5_T_T0_ERK8IntervalILi3EE(%"struct.FieldEngine >,double,MultiPatchView, 3> >"* null, %"struct.FieldEngine >,double,MultiPatch > >"* null, %"struct.Interval<3>"* null) nounwind - call fastcc void @_ZN9CenteringILi3EEC1ERKS0_i(%"struct.Centering<3>"* %55, %"struct.Centering<3>"* null, i32 %i.0.reg2mem.0) nounwind - call void @llvm.memcpy.i32(i8* %61, i8* %38, i32 24, i32 4) nounwind - %69 = load %"struct.Loc<3>"** null, align 4 ; <%"struct.Loc<3>"*> [#uses=1] - %70 = ptrtoint %"struct.Loc<3>"* %69 to i32 ; [#uses=1] - %.off.i911 = sub i32 0, %70 ; [#uses=1] - %71 = icmp ult i32 %.off.i911, 12 ; [#uses=1] - %72 = sub i32 0, 0 ; [#uses=2] - %73 = load i32* %56, align 4 ; [#uses=1] - %74 = add i32 %73, 0 ; [#uses=1] - %75 = sub i32 %74, %72 ; [#uses=1] - %76 = add i32 %75, 0 ; [#uses=1] - %77 = load i32* null, align 8 ; [#uses=2] - %78 = load i32* null, align 4 ; [#uses=1] - %79 = sub i32 %77, %78 ; [#uses=1] - %80 = load i32* %57, align 4 ; [#uses=1] - %81 = load i32* null, align 4 ; [#uses=1] - br i1 %71, label %bb.i912, label %bb4.i915 - -bb.i912: ; preds = %_ZNK11FieldEngineI22UniformRectilinearMeshI10MeshTraitsILi3Ed21UniformRectilinearTag12CartesianTagLi3EEEd10MultiPatchI7GridTag6RemoteI5BrickEEE11totalDomainEv.exit944 - br label %_ZNK11FieldEngineI22UniformRectilinearMeshI10MeshTraitsILi3Ed21UniformRectilinearTag12CartesianTagLi3EEEd10MultiPatchI7GridTag6RemoteI5BrickEEE11totalDomainEv.exit916 - -bb4.i915: ; preds = %_ZNK11FieldEngineI22UniformRectilinearMeshI10MeshTraitsILi3Ed21UniformRectilinearTag12CartesianTagLi3EEEd10MultiPatchI7GridTag6RemoteI5BrickEEE11totalDomainEv.exit944 - %82 = sub i32 %77, %79 ; [#uses=1] - %83 = add i32 %82, %80 ; [#uses=1] - %84 = add i32 %83, %81 ; [#uses=1] - %85 = load i32* %58, align 8 ; [#uses=2] - %86 = load i32* null, align 8 ; [#uses=1] - %87 = sub i32 %85, %86 ; [#uses=2] - %88 = load i32* %59, align 4 ; [#uses=1] - %89 = load i32* null, align 4 ; [#uses=1] - %90 = sub i32 %85, %87 ; [#uses=1] - %91 = add i32 %90, %88 ; [#uses=1] - %92 = add i32 %91, %89 ; [#uses=1] - br label %_ZNK11FieldEngineI22UniformRectilinearMeshI10MeshTraitsILi3Ed21UniformRectilinearTag12CartesianTagLi3EEEd10MultiPatchI7GridTag6RemoteI5BrickEEE11totalDomainEv.exit916 - -_ZNK11FieldEngineI22UniformRectilinearMeshI10MeshTraitsILi3Ed21UniformRectilinearTag12CartesianTagLi3EEEd10MultiPatchI7GridTag6RemoteI5BrickEEE11totalDomainEv.exit916: ; preds = %bb4.i915, %bb.i912 - %.0978.0.0.1.0.0.0.0.1.0 = phi i32 [ %84, %bb4.i915 ], [ 0, %bb.i912 ] ; [#uses=0] - %.0978.0.0.2.0.0.0.0.0.0 = phi i32 [ %87, %bb4.i915 ], [ 0, %bb.i912 ] ; [#uses=1] - %.0978.0.0.2.0.0.0.0.1.0 = phi i32 [ %92, %bb4.i915 ], [ 0, %bb.i912 ] ; [#uses=0] - store i32 %72, i32* null, align 8 - store i32 %76, i32* null, align 4 - store i32 %.0978.0.0.2.0.0.0.0.0.0, i32* null, align 8 - call fastcc void @_ZN11FieldEngineI22UniformRectilinearMeshI10MeshTraitsILi3Ed21UniformRectilinearTag12CartesianTagLi3EEEd14MultiPatchViewI7GridTag6RemoteI5BrickELi3EEEC1Id10MultiPatchIS7_SA_EEERKS_IS5_T_T0_ERK8IntervalILi3EE(%"struct.FieldEngine >,double,MultiPatchView, 3> >"* null, %"struct.FieldEngine >,double,MultiPatch > >"* null, %"struct.Interval<3>"* null) nounwind - %93 = load i32* null, align 8 ; [#uses=1] - %94 = icmp sgt i32 %93, 0 ; [#uses=1] - br i1 %94, label %bb1.i, label %_Z6assignI22UniformRectilinearMeshI10MeshTraitsILi3Ed21UniformRectilinearTag12CartesianTagLi3EEEd14MultiPatchViewI7GridTag6RemoteI5BrickELi3EES5_d13ExpressionTagI10BinaryNodeI10OpMultiply6ScalarIdESD_I5OpAdd9ReferenceI5FieldIS5_dSB_EESL_EEE8OpAssignERKSJ_IT_T0_T1_ESV_RKSJ_IT2_T3_T4_ERKT5_.exit - -bb1.i: ; preds = %bb3.i23.i.i, %_ZNK11FieldEngineI22UniformRectilinearMeshI10MeshTraitsILi3Ed21UniformRectilinearTag12CartesianTagLi3EEEd10MultiPatchI7GridTag6RemoteI5BrickEEE11totalDomainEv.exit916 - call fastcc void @_ZN11FieldEngineI22UniformRectilinearMeshI10MeshTraitsILi3Ed21UniformRectilinearTag12CartesianTagLi3EEEd14MultiPatchViewI7GridTag6RemoteI5BrickELi3EEED1Ev(%"struct.FieldEngine >,double,MultiPatchView, 3> >"* %63) nounwind - call fastcc void @_ZN11FieldEngineI22UniformRectilinearMeshI10MeshTraitsILi3Ed21UniformRectilinearTag12CartesianTagLi3EEEd14MultiPatchViewI7GridTag6RemoteI5BrickELi3EEED1Ev(%"struct.FieldEngine >,double,MultiPatchView, 3> >"* %62) nounwind - br label %bb.i17.i14.i - -bb.i17.i14.i: ; preds = %_ZNK11FieldEngineI22UniformRectilinearMeshI10MeshTraitsILi3Ed21UniformRectilinearTag12CartesianTagLi3EEEd6RemoteI9BrickViewEE14physicalDomainEv.exit26.i.i.i.i, %bb1.i - %i.0.02.rec.i.i.i = phi i32 [ %.rec.i.i.i641, %_ZNK11FieldEngineI22UniformRectilinearMeshI10MeshTraitsILi3Ed21UniformRectilinearTag12CartesianTagLi3EEEd6RemoteI9BrickViewEE14physicalDomainEv.exit26.i.i.i.i ], [ 0, %bb1.i ] ; [#uses=1] - %95 = load double* %64, align 8 ; [#uses=1] - store double %95, double* null, align 8 - call fastcc void @_ZN11FieldEngineI22UniformRectilinearMeshI10MeshTraitsILi3Ed21UniformRectilinearTag12CartesianTagLi3EEEd6RemoteI9BrickViewEEC1Id14MultiPatchViewI7GridTagS6_I5BrickELi3EEEERKS_IS5_T_T0_ERK5INodeILi3EE(%"struct.FieldEngine >,double,Remote >"* %65, %"struct.FieldEngine >,double,MultiPatchView, 3> >"* null, %"struct.INode<3>"* null) nounwind - %96 = load %"struct.Loc<3>"** null, align 4 ; <%"struct.Loc<3>"*> [#uses=1] - %97 = ptrtoint %"struct.Loc<3>"* %96 to i32 ; [#uses=1] - %.off.i21.i.i.i.i = sub i32 0, %97 ; [#uses=1] - %98 = icmp ult i32 %.off.i21.i.i.i.i, 12 ; [#uses=1] - br i1 %98, label %bb.i22.i.i.i.i, label %bb3.i25.i.i.i.i - -bb.i22.i.i.i.i: ; preds = %bb.i17.i14.i - %99 = load i32* null, align 4 ; [#uses=1] - %100 = icmp eq i32 %99, 1 ; [#uses=1] - %101 = load i32* null, align 4 ; [#uses=1] - br i1 %100, label %_ZNK11FieldEngineI22UniformRectilinearMeshI10MeshTraitsILi3Ed21UniformRectilinearTag12CartesianTagLi3EEEd6RemoteI9BrickViewEE14physicalDomainEv.exit26.i.i.i.i, label %bb6.i.i24.i.i.i.i - -bb6.i.i24.i.i.i.i: ; preds = %bb.i22.i.i.i.i - br label %_ZNK11FieldEngineI22UniformRectilinearMeshI10MeshTraitsILi3Ed21UniformRectilinearTag12CartesianTagLi3EEEd6RemoteI9BrickViewEE14physicalDomainEv.exit26.i.i.i.i - -bb3.i25.i.i.i.i: ; preds = %bb.i17.i14.i - %102 = load i32* %66, align 8 ; [#uses=2] - %103 = load i32* %67, align 4 ; [#uses=1] - %104 = load i32* %68, align 4 ; [#uses=1] - br label %_ZNK11FieldEngineI22UniformRectilinearMeshI10MeshTraitsILi3Ed21UniformRectilinearTag12CartesianTagLi3EEEd6RemoteI9BrickViewEE14physicalDomainEv.exit26.i.i.i.i - -_ZNK11FieldEngineI22UniformRectilinearMeshI10MeshTraitsILi3Ed21UniformRectilinearTag12CartesianTagLi3EEEd6RemoteI9BrickViewEE14physicalDomainEv.exit26.i.i.i.i: ; preds = %bb3.i25.i.i.i.i, %bb6.i.i24.i.i.i.i, %bb.i22.i.i.i.i - %.rle1279 = phi i32 [ 0, %bb3.i25.i.i.i.i ], [ 0, %bb6.i.i24.i.i.i.i ], [ 0, %bb.i22.i.i.i.i ] ; [#uses=1] - %.rle1277 = phi i32 [ %102, %bb3.i25.i.i.i.i ], [ 0, %bb6.i.i24.i.i.i.i ], [ 0, %bb.i22.i.i.i.i ] ; [#uses=1] - %.rle1275 = phi i32 [ 0, %bb3.i25.i.i.i.i ], [ 0, %bb6.i.i24.i.i.i.i ], [ 0, %bb.i22.i.i.i.i ] ; [#uses=1] - %.01034.0.0.2.0.0.0.0.1.0 = phi i32 [ %104, %bb3.i25.i.i.i.i ], [ 0, %bb6.i.i24.i.i.i.i ], [ 0, %bb.i22.i.i.i.i ] ; [#uses=1] - %.01034.0.0.2.0.0.0.0.0.0 = phi i32 [ 0, %bb3.i25.i.i.i.i ], [ 0, %bb6.i.i24.i.i.i.i ], [ 0, %bb.i22.i.i.i.i ] ; [#uses=1] - %.01034.0.0.1.0.0.0.0.1.0 = phi i32 [ %103, %bb3.i25.i.i.i.i ], [ 0, %bb6.i.i24.i.i.i.i ], [ 0, %bb.i22.i.i.i.i ] ; [#uses=1] - %.01034.0.0.1.0.0.0.0.0.0 = phi i32 [ %102, %bb3.i25.i.i.i.i ], [ 0, %bb6.i.i24.i.i.i.i ], [ 0, %bb.i22.i.i.i.i ] ; [#uses=1] - %.01034.0.0.0.0.0.0.0.1.0 = phi i32 [ 0, %bb3.i25.i.i.i.i ], [ 0, %bb6.i.i24.i.i.i.i ], [ %101, %bb.i22.i.i.i.i ] ; [#uses=1] - %.01034.0.0.0.0.0.0.0.0.0 = phi i32 [ 0, %bb3.i25.i.i.i.i ], [ 0, %bb6.i.i24.i.i.i.i ], [ 0, %bb.i22.i.i.i.i ] ; [#uses=1] - %105 = sub i32 %.01034.0.0.0.0.0.0.0.0.0, %.rle1275 ; [#uses=0] - %106 = sub i32 %.01034.0.0.1.0.0.0.0.0.0, %.rle1277 ; [#uses=0] - %107 = sub i32 %.01034.0.0.2.0.0.0.0.0.0, %.rle1279 ; [#uses=0] - store i32 %.01034.0.0.0.0.0.0.0.1.0, i32* null, align 4 - store i32 %.01034.0.0.1.0.0.0.0.1.0, i32* null, align 4 - store i32 %.01034.0.0.2.0.0.0.0.1.0, i32* null, align 4 - call fastcc void @_ZN11FieldEngineI22UniformRectilinearMeshI10MeshTraitsILi3Ed21UniformRectilinearTag12CartesianTagLi3EEEd6RemoteI9BrickViewEED1Ev(%"struct.FieldEngine >,double,Remote >"* %65) nounwind - %.rec.i.i.i641 = add i32 %i.0.02.rec.i.i.i, 1 ; [#uses=1] - %108 = load %"struct.INode<3>"** null, align 4 ; <%"struct.INode<3>"*> [#uses=1] - %109 = icmp eq %"struct.INode<3>"* null, %108 ; [#uses=1] - br i1 %109, label %bb3.i23.i.i, label %bb.i17.i14.i - -bb3.i23.i.i: ; preds = %_ZNK11FieldEngineI22UniformRectilinearMeshI10MeshTraitsILi3Ed21UniformRectilinearTag12CartesianTagLi3EEEd6RemoteI9BrickViewEE14physicalDomainEv.exit26.i.i.i.i - br label %bb1.i - -_Z6assignI22UniformRectilinearMeshI10MeshTraitsILi3Ed21UniformRectilinearTag12CartesianTagLi3EEEd14MultiPatchViewI7GridTag6RemoteI5BrickELi3EES5_d13ExpressionTagI10BinaryNodeI10OpMultiply6ScalarIdESD_I5OpAdd9ReferenceI5FieldIS5_dSB_EESL_EEE8OpAssignERKSJ_IT_T0_T1_ESV_RKSJ_IT2_T3_T4_ERKT5_.exit: ; preds = %_ZNK11FieldEngineI22UniformRectilinearMeshI10MeshTraitsILi3Ed21UniformRectilinearTag12CartesianTagLi3EEEd10MultiPatchI7GridTag6RemoteI5BrickEEE11totalDomainEv.exit916 - %indvar.next = add i32 %i.0.reg2mem.0, 1 ; [#uses=2] - %exitcond = icmp eq i32 %indvar.next, 3 ; [#uses=1] - br i1 %exitcond, label %bb18, label %bb15 - -bb18: ; preds = %_Z6assignI22UniformRectilinearMeshI10MeshTraitsILi3Ed21UniformRectilinearTag12CartesianTagLi3EEEd14MultiPatchViewI7GridTag6RemoteI5BrickELi3EES5_d13ExpressionTagI10BinaryNodeI10OpMultiply6ScalarIdESD_I5OpAdd9ReferenceI5FieldIS5_dSB_EESL_EEE8OpAssignERKSJ_IT_T0_T1_ESV_RKSJ_IT2_T3_T4_ERKT5_.exit - call fastcc void @_ZN11FieldEngineI22UniformRectilinearMeshI10MeshTraitsILi3Ed21UniformRectilinearTag12CartesianTagLi3EEEd10MultiPatchI7GridTag6RemoteI5BrickEEEC1ERKSC_(%"struct.FieldEngine >,double,MultiPatch > >"* null, %"struct.FieldEngine >,double,MultiPatch > >"* %42) nounwind - unreachable -} From clattner at apple.com Mon Nov 2 01:30:52 2009 From: clattner at apple.com (Chris Lattner) Date: Sun, 1 Nov 2009 23:30:52 -0800 Subject: [llvm-commits] [llvm] r85764 - in /llvm/trunk/lib/Target/ARM: ARM.td ARMBaseInstrInfo.cpp ARMBaseInstrInfo.h ARMInstrFormats.td ARMInstrInfo.cpp ARMInstrInfo.h Thumb1InstrInfo.cpp Thumb2InstrInfo.cpp In-Reply-To: References: <200911020010.nA20Ade4021334@zion.cs.uiuc.edu> <7703A6BF-6F9F-4636-961C-23B5080B78A2@apple.com> Message-ID: <9C2785E9-143B-4F5C-8E8C-E5727F372468@apple.com> On Nov 1, 2009, at 11:08 PM, Evan Cheng wrote: >> Do we have any better way? It seems - no. We need to find the def of >> the >> register which is closest to the insertion point. Even if some >> instruction >> numbering would be saved after RA, then iterating of instructions >> seems to >> be cheaper than iterating over defs of the phys reg. > > This has to be done in a late pass which can walk basic blocks from > top down and tracking the domain of every register. When it sees a > fcpyd, it knows the domain of source register and can change it. The > current implementation really is a non-starter, especially for JIT. FWIW, I agree with Evan's approach. This would also allow you to disable the pass in -fast mode etc. -Chris From sabre at nondot.org Mon Nov 2 01:33:59 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 02 Nov 2009 07:33:59 -0000 Subject: [llvm-commits] [llvm] r85795 - in /llvm/trunk: lib/Transforms/Scalar/SCCP.cpp test/Transforms/SCCP/ipsccp-basic.ll Message-ID: <200911020733.nA27XxI6005372@zion.cs.uiuc.edu> Author: lattner Date: Mon Nov 2 01:33:59 2009 New Revision: 85795 URL: http://llvm.org/viewvc/llvm-project?rev=85795&view=rev Log: improve IPSCCP to be able to propagate the result of "!mayBeOverridden" function to calls of that function, regardless of whether it has local linkage or has its address taken. Not escaping should only affect whether we make an aggressive assumption about the arguments to a function, not whether we can track the result of it. Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp llvm/trunk/test/Transforms/SCCP/ipsccp-basic.ll Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCP.cpp?rev=85795&r1=85794&r2=85795&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SCCP.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Mon Nov 2 01:33:59 2009 @@ -25,7 +25,6 @@ #include "llvm/Instructions.h" #include "llvm/Pass.h" #include "llvm/Analysis/ConstantFolding.h" -#include "llvm/Analysis/MemoryBuiltins.h" #include "llvm/Analysis/ValueTracking.h" #include "llvm/Transforms/Utils/Local.h" #include "llvm/Target/TargetData.h" @@ -227,7 +226,6 @@ /// and out of the specified function (which cannot have its address taken), /// this method must be called. void AddTrackedFunction(Function *F) { - assert(F->hasLocalLinkage() && "Can only track internal functions!"); // Add an entry, F -> undef. if (const StructType *STy = dyn_cast(F->getReturnType())) { for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) @@ -380,11 +378,9 @@ // instruction that was just changed state somehow. Based on this // information, we need to update the specified user of this instruction. // - void OperandChangedState(User *U) { - // Only instructions use other variable values! - Instruction &I = cast(*U); - if (BBExecutable.count(I.getParent())) // Inst is executable? - visit(I); + void OperandChangedState(Instruction *I) { + if (BBExecutable.count(I->getParent())) // Inst is executable? + visit(*I); } /// RemoveFromOverdefinedPHIs - If I has any entries in the @@ -428,8 +424,6 @@ void visitLoadInst (LoadInst &I); void visitGetElementPtrInst(GetElementPtrInst &I); void visitCallInst (CallInst &I) { - if (isFreeCall(&I)) - return; visitCallSite(CallSite::get(&I)); } void visitInvokeInst (InvokeInst &II) { @@ -656,19 +650,19 @@ markConstant(&PN, OperandVal); // Acquire operand value } + + + void SCCPSolver::visitReturnInst(ReturnInst &I) { if (I.getNumOperands() == 0) return; // ret void Function *F = I.getParent()->getParent(); + // If we are tracking the return value of this function, merge it in. - if (!F->hasLocalLinkage()) - return; - if (!TrackedRetVals.empty()) { DenseMap::iterator TFRVI = TrackedRetVals.find(F); - if (TFRVI != TrackedRetVals.end() && - !TFRVI->second.isOverdefined()) { + if (TFRVI != TrackedRetVals.end()) { mergeInValue(TFRVI->second, F, getValueState(I.getOperand(0))); return; } @@ -1164,14 +1158,14 @@ // The common case is that we aren't tracking the callee, either because we // are not doing interprocedural analysis or the callee is indirect, or is // external. Handle these cases first. - if (F == 0 || !F->hasLocalLinkage()) { + if (F == 0 || F->isDeclaration()) { CallOverdefined: // Void return and not tracking callee, just bail. if (I->getType()->isVoidTy()) return; // Otherwise, if we have a single return value case, and if the function is // a declaration, maybe we can constant fold it. - if (!isa(I->getType()) && F && F->isDeclaration() && + if (F && F->isDeclaration() && !isa(I->getType()) && canConstantFoldCallTo(F)) { SmallVector Operands; @@ -1235,7 +1229,7 @@ // common path above. goto CallOverdefined; } - + // Finally, if this is the first call to the function hit, mark its entry // block executable. MarkBlockExecutable(F->begin()); @@ -1244,6 +1238,8 @@ CallSite::arg_iterator CAI = CS.arg_begin(); for (Function::arg_iterator AI = F->arg_begin(), E = F->arg_end(); AI != E; ++AI, ++CAI) { + // If this argument is byval, and if the function is not readonly, there + // will be an implicit copy formed of the input aggregate. if (AI->hasByValAttr() && !F->onlyReadsMemory()) { markOverdefined(AI); continue; @@ -1273,7 +1269,8 @@ // for (Value::use_iterator UI = I->use_begin(), E = I->use_end(); UI != E; ++UI) - OperandChangedState(*UI); + if (Instruction *I = dyn_cast(*UI)) + OperandChangedState(I); } // Process the instruction work list. @@ -1292,7 +1289,8 @@ if (!getValueState(I).isOverdefined()) for (Value::use_iterator UI = I->use_begin(), E = I->use_end(); UI != E; ++UI) - OperandChangedState(*UI); + if (Instruction *I = dyn_cast(*UI)) + OperandChangedState(I); } // Process the basic block work list. @@ -1650,14 +1648,24 @@ if (F->isDeclaration()) continue; - if (!F->hasLocalLinkage() || AddressIsTaken(F)) { - Solver.MarkBlockExecutable(F->begin()); - for (Function::arg_iterator AI = F->arg_begin(), E = F->arg_end(); - AI != E; ++AI) - Solver.markOverdefined(AI); - } else { + // If this is a strong or ODR definition of this function, then we can + // propagate information about its result into callsites of it. + if (!F->mayBeOverridden()) Solver.AddTrackedFunction(F); - } + + // If this function only has direct calls that we can see, we can track its + // arguments and return value aggressively, and can assume it is not called + // unless we see evidence to the contrary. + if (F->hasLocalLinkage() && !AddressIsTaken(F)) + continue; + + // Assume the function is called. + Solver.MarkBlockExecutable(F->begin()); + + // Assume nothing about the incoming arguments. + for (Function::arg_iterator AI = F->arg_begin(), E = F->arg_end(); + AI != E; ++AI) + Solver.markOverdefined(AI); } // Loop over global variables. We inform the solver about any internal global @@ -1805,16 +1813,21 @@ // TODO: Process multiple value ret instructions also. const DenseMap &RV = Solver.getTrackedRetVals(); for (DenseMap::const_iterator I = RV.begin(), - E = RV.end(); I != E; ++I) - if (!I->second.isOverdefined() && - !I->first->getReturnType()->isVoidTy()) { - Function *F = I->first; - for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) - if (ReturnInst *RI = dyn_cast(BB->getTerminator())) - if (!isa(RI->getOperand(0))) - RI->setOperand(0, UndefValue::get(F->getReturnType())); - } - + E = RV.end(); I != E; ++I) { + Function *F = I->first; + if (I->second.isOverdefined() || F->getReturnType()->isVoidTy()) + continue; + + // We can only do this if we know that nothing else can call the function. + if (!F->hasLocalLinkage() || AddressIsTaken(F)) + continue; + + for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) + if (ReturnInst *RI = dyn_cast(BB->getTerminator())) + if (!isa(RI->getOperand(0))) + RI->setOperand(0, UndefValue::get(F->getReturnType())); + } + // If we infered constant or undef values for globals variables, we can delete // the global and any stores that remain to it. const DenseMap &TG = Solver.getTrackedGlobals(); Modified: llvm/trunk/test/Transforms/SCCP/ipsccp-basic.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SCCP/ipsccp-basic.ll?rev=85795&r1=85794&r2=85795&view=diff ============================================================================== --- llvm/trunk/test/Transforms/SCCP/ipsccp-basic.ll (original) +++ llvm/trunk/test/Transforms/SCCP/ipsccp-basic.ll Mon Nov 2 01:33:59 2009 @@ -134,3 +134,17 @@ ret i64 %b } + +;;======================== test6 + +define i64 @test6a() { + ret i64 0 +} + +define i64 @test6b() { + %a = call i64 @test6a() + ret i64 %a +} +; CHECK: define i64 @test6b +; CHECK: ret i64 0 + From sabre at nondot.org Mon Nov 2 01:34:29 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 02 Nov 2009 07:34:29 -0000 Subject: [llvm-commits] [llvm] r85796 - /llvm/trunk/include/llvm/Support/StandardPasses.h Message-ID: <200911020734.nA27YTg2005396@zion.cs.uiuc.edu> Author: lattner Date: Mon Nov 2 01:34:29 2009 New Revision: 85796 URL: http://llvm.org/viewvc/llvm-project?rev=85796&view=rev Log: now that ip sccp *really* subsumes ipcp, remove ipcp again. Modified: llvm/trunk/include/llvm/Support/StandardPasses.h Modified: llvm/trunk/include/llvm/Support/StandardPasses.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/StandardPasses.h?rev=85796&r1=85795&r2=85796&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/StandardPasses.h (original) +++ llvm/trunk/include/llvm/Support/StandardPasses.h Mon Nov 2 01:34:29 2009 @@ -99,7 +99,6 @@ if (UnitAtATime) { PM->add(createGlobalOptimizerPass()); // Optimize out global vars - PM->add(createIPConstantPropagationPass()); // IP CP PM->add(createIPSCCPPass()); // IP SCCP PM->add(createDeadArgEliminationPass()); // Dead argument elimination } From evan.cheng at apple.com Mon Nov 2 01:51:19 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 02 Nov 2009 07:51:19 -0000 Subject: [llvm-commits] [llvm] r85797 - /llvm/trunk/lib/Target/ARM/README.txt Message-ID: <200911020751.nA27pJdG005964@zion.cs.uiuc.edu> Author: evancheng Date: Mon Nov 2 01:51:19 2009 New Revision: 85797 URL: http://llvm.org/viewvc/llvm-project?rev=85797&view=rev Log: Add an entry. Modified: llvm/trunk/lib/Target/ARM/README.txt Modified: llvm/trunk/lib/Target/ARM/README.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/README.txt?rev=85797&r1=85796&r2=85797&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/README.txt (original) +++ llvm/trunk/lib/Target/ARM/README.txt Mon Nov 2 01:51:19 2009 @@ -609,3 +609,6 @@ revisions of patches are on the mailing list, beginning at: http://lists.cs.uiuc.edu/pipermail/llvmdev/2009-June/022763.html +//===---------------------------------------------------------------------===// + +Make use of the "rbit" instruction. From evan.cheng at apple.com Mon Nov 2 01:58:25 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 02 Nov 2009 07:58:25 -0000 Subject: [llvm-commits] [llvm] r85798 - /llvm/trunk/lib/Target/ARM/README.txt Message-ID: <200911020758.nA27wPWW006220@zion.cs.uiuc.edu> Author: evancheng Date: Mon Nov 2 01:58:25 2009 New Revision: 85798 URL: http://llvm.org/viewvc/llvm-project?rev=85798&view=rev Log: These are done / no longer care. Modified: llvm/trunk/lib/Target/ARM/README.txt Modified: llvm/trunk/lib/Target/ARM/README.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/README.txt?rev=85798&r1=85797&r2=85798&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/README.txt (original) +++ llvm/trunk/lib/Target/ARM/README.txt Mon Nov 2 01:58:25 2009 @@ -8,12 +8,8 @@ add doesn't need to overflow between the two 16-bit chunks. * Implement pre/post increment support. (e.g. PR935) -* Coalesce stack slots! * Implement smarter constant generation for binops with large immediates. -* Consider materializing FP constants like 0.0f and 1.0f using integer - immediate instructions then copy to FPU. Slower than load into FPU? - //===---------------------------------------------------------------------===// Crazy idea: Consider code that uses lots of 8-bit or 16-bit values. By the @@ -422,14 +418,6 @@ //===---------------------------------------------------------------------===// -More register scavenging work: - -1. Use the register scavenger to track frame index materialized into registers - (those that do not fit in addressing modes) to allow reuse in the same BB. -2. Finish scavenging for Thumb. - -//===---------------------------------------------------------------------===// - More LSR enhancements possible: 1. Teach LSR about pre- and post- indexed ops to allow iv increment be merged @@ -540,10 +528,6 @@ //===---------------------------------------------------------------------===// -We need to fix constant isel for ARMv6t2 to use MOVT. - -//===---------------------------------------------------------------------===// - Constant island pass should make use of full range SoImm values for LEApcrel. Be careful though as the last attempt caused infinite looping on lencod. @@ -593,11 +577,6 @@ //===---------------------------------------------------------------------===// -add/sub/and/or + i32 imm can be simplified by folding part of the immediate -into the operation. - -//===---------------------------------------------------------------------===// - It might be profitable to cse MOVi16 if there are lots of 32-bit immediates with the same bottom half. From evan.cheng at apple.com Mon Nov 2 02:09:50 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 02 Nov 2009 08:09:50 -0000 Subject: [llvm-commits] [llvm] r85799 - in /llvm/trunk: lib/CodeGen/MachineLICM.cpp test/CodeGen/ARM/remat.ll test/CodeGen/X86/2007-11-30-LoadFolding-Bug.ll Message-ID: <200911020809.nA289opg006565@zion.cs.uiuc.edu> Author: evancheng Date: Mon Nov 2 02:09:49 2009 New Revision: 85799 URL: http://llvm.org/viewvc/llvm-project?rev=85799&view=rev Log: Initilize the machine LICM CSE map upon the first time an instruction is hoisted to the loop preheader. Add instructions which are already in the preheader block that may be common expressions of those that are hoisted out. These does get a few more instructions CSE'ed. Modified: llvm/trunk/lib/CodeGen/MachineLICM.cpp llvm/trunk/test/CodeGen/ARM/remat.ll llvm/trunk/test/CodeGen/X86/2007-11-30-LoadFolding-Bug.ll Modified: llvm/trunk/lib/CodeGen/MachineLICM.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineLICM.cpp?rev=85799&r1=85798&r2=85799&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineLICM.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineLICM.cpp Mon Nov 2 02:09:49 2009 @@ -56,12 +56,12 @@ // State that is updated as we process loops bool Changed; // True if a loop is changed. + bool FirstInLoop; // True if it's the first LICM in the loop. MachineLoop *CurLoop; // The current loop we are working on. MachineBasicBlock *CurPreheader; // The preheader for CurLoop. - // For each BB and opcode pair, keep a list of hoisted instructions. - DenseMap, - std::vector > CSEMap; + // For each opcode, keep a list of potentail CSE instructions. + DenseMap > CSEMap; public: static char ID; // Pass identification, replacement for typeid MachineLICM() : MachineFunctionPass(&ID) {} @@ -115,6 +115,11 @@ /// that is safe to hoist, this instruction is called to do the dirty work. /// void Hoist(MachineInstr *MI); + + /// InitCSEMap - Initialize the CSE map with instructions that are in the + /// current loop preheader that may become duplicates of instructions that + /// are hoisted out of the loop. + void InitCSEMap(MachineBasicBlock *BB); }; } // end anonymous namespace @@ -140,7 +145,7 @@ bool MachineLICM::runOnMachineFunction(MachineFunction &MF) { DEBUG(errs() << "******** Machine LICM ********\n"); - Changed = false; + Changed = FirstInLoop = false; TM = &MF.getTarget(); TII = TM->getInstrInfo(); TRI = TM->getRegisterInfo(); @@ -152,8 +157,7 @@ DT = &getAnalysis(); AA = &getAnalysis(); - for (MachineLoopInfo::iterator - I = LI->begin(), E = LI->end(); I != E; ++I) { + for (MachineLoopInfo::iterator I = LI->begin(), E = LI->end(); I != E; ++I) { CurLoop = *I; // Only visit outer-most preheader-sporting loops. @@ -170,7 +174,11 @@ if (!CurPreheader) continue; + // CSEMap is initialized for loop header when the first instruction is + // being hoisted. + FirstInLoop = true; HoistRegion(DT->getNode(CurLoop->getHeader())); + CSEMap.clear(); } return Changed; @@ -191,10 +199,7 @@ for (MachineBasicBlock::iterator MII = BB->begin(), E = BB->end(); MII != E; ) { MachineBasicBlock::iterator NextMII = MII; ++NextMII; - MachineInstr &MI = *MII; - - Hoist(&MI); - + Hoist(&*MII); MII = NextMII; } @@ -430,6 +435,27 @@ return NewMIs[0]; } +void MachineLICM::InitCSEMap(MachineBasicBlock *BB) { + for (MachineBasicBlock::iterator I = BB->begin(),E = BB->end(); I != E; ++I) { + const MachineInstr *MI = &*I; + // FIXME: For now, only hoist re-materilizable instructions. LICM will + // increase register pressure. We want to make sure it doesn't increase + // spilling. + if (TII->isTriviallyReMaterializable(MI, AA)) { + unsigned Opcode = MI->getOpcode(); + DenseMap >::iterator + CI = CSEMap.find(Opcode); + if (CI != CSEMap.end()) + CI->second.push_back(MI); + else { + std::vector CSEMIs; + CSEMIs.push_back(MI); + CSEMap.insert(std::make_pair(Opcode, CSEMIs)); + } + } + } +} + /// Hoist - When an instruction is found to use only loop invariant operands /// that are safe to hoist, this instruction is called to do the dirty work. /// @@ -454,11 +480,14 @@ errs() << "\n"; }); + // If this is the first instruction being hoisted to the preheader, + // initialize the CSE map with potential common expressions. + InitCSEMap(CurPreheader); + // Look for opportunity to CSE the hoisted instruction. - std::pair BBOpcPair = - std::make_pair(CurPreheader->getNumber(), MI->getOpcode()); - DenseMap, - std::vector >::iterator CI = CSEMap.find(BBOpcPair); + unsigned Opcode = MI->getOpcode(); + DenseMap >::iterator + CI = CSEMap.find(Opcode); bool DoneCSE = false; if (CI != CSEMap.end()) { const MachineInstr *Dup = LookForDuplicate(MI, CI->second, RegInfo); @@ -477,15 +506,15 @@ // Otherwise, splice the instruction to the preheader. if (!DoneCSE) { - CurPreheader->splice(CurPreheader->getFirstTerminator(), - MI->getParent(), MI); + CurPreheader->splice(CurPreheader->getFirstTerminator(),MI->getParent(),MI); + // Add to the CSE map. if (CI != CSEMap.end()) CI->second.push_back(MI); else { std::vector CSEMIs; CSEMIs.push_back(MI); - CSEMap.insert(std::make_pair(BBOpcPair, CSEMIs)); + CSEMap.insert(std::make_pair(Opcode, CSEMIs)); } } Modified: llvm/trunk/test/CodeGen/ARM/remat.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/remat.ll?rev=85799&r1=85798&r2=85799&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/remat.ll (original) +++ llvm/trunk/test/CodeGen/ARM/remat.ll Mon Nov 2 02:09:49 2009 @@ -1,5 +1,5 @@ ; RUN: llc < %s -mtriple=arm-apple-darwin -; RUN: llc < %s -mtriple=arm-apple-darwin -stats -info-output-file - | grep "Number of re-materialization" | grep 4 +; RUN: llc < %s -mtriple=arm-apple-darwin -stats -info-output-file - | grep "Number of re-materialization" | grep 5 %struct.CONTENTBOX = type { i32, i32, i32, i32, i32 } %struct.LOCBOX = type { i32, i32, i32, i32 } Modified: llvm/trunk/test/CodeGen/X86/2007-11-30-LoadFolding-Bug.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2007-11-30-LoadFolding-Bug.ll?rev=85799&r1=85798&r2=85799&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2007-11-30-LoadFolding-Bug.ll (original) +++ llvm/trunk/test/CodeGen/X86/2007-11-30-LoadFolding-Bug.ll Mon Nov 2 02:09:49 2009 @@ -1,6 +1,5 @@ -; RUN: llc < %s -march=x86 -mattr=+sse2 -stats |& \ -; RUN: grep {1 .*folded into instructions} -; Increment in loop bb.128.i adjusted to 2, to prevent loop reversal from +; RUN: llc < %s -march=x86 -mattr=+sse2 | FileCheck %s +; Increment in loop bb.i28.i adjusted to 2, to prevent loop reversal from ; kicking in. declare fastcc void @rdft(i32, i32, double*, i32*, double*) @@ -34,6 +33,9 @@ br label %bb.i28.i bb.i28.i: ; preds = %bb.i28.i, %cond_next36.i +; CHECK: %bb.i28.i +; CHECK: addl $2 +; CHECK: addl $2 %j.0.reg2mem.0.i16.i = phi i32 [ 0, %cond_next36.i ], [ %indvar.next39.i, %bb.i28.i ] ; [#uses=2] %din_addr.1.reg2mem.0.i17.i = phi double [ 0.000000e+00, %cond_next36.i ], [ %tmp16.i25.i, %bb.i28.i ] ; [#uses=1] %tmp1.i18.i = fptosi double %din_addr.1.reg2mem.0.i17.i to i32 ; [#uses=2] From baldrick at free.fr Mon Nov 2 08:23:47 2009 From: baldrick at free.fr (Duncan Sands) Date: Mon, 02 Nov 2009 15:23:47 +0100 Subject: [llvm-commits] [llvm] r85738 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/phi.ll In-Reply-To: <200911012007.nA1K78eB012267@zion.cs.uiuc.edu> References: <200911012007.nA1K78eB012267@zion.cs.uiuc.edu> Message-ID: <4AEEEB73.9070101@free.fr> Hi Chris, > - LoadAlignment = std::max(LoadAlignment, LI->getAlignment()); > + LoadAlignment = std::min(LoadAlignment, LI->getAlignment()); if one alignment is zero and the other is not, then zero (the minimum) may be the wrong result. On the other hand, if one is zero and the other is over aligned (bigger than the ABI alignment), then zero is the right thing, not the bigger alignment. You need target data to get this right. Ciao, Duncan. From baldrick at free.fr Mon Nov 2 09:48:33 2009 From: baldrick at free.fr (Duncan Sands) Date: Mon, 02 Nov 2009 15:48:33 -0000 Subject: [llvm-commits] [dragonegg] r85802 - /dragonegg/trunk/www/index.html Message-ID: <200911021548.nA2FmX5a007104@zion.cs.uiuc.edu> Author: baldrick Date: Mon Nov 2 09:48:31 2009 New Revision: 85802 URL: http://llvm.org/viewvc/llvm-project?rev=85802&view=rev Log: I hereby decree that indirect gotos work properly with dragonegg. Since they use the new indirect branch and block address stuff, this is not entirely true, but will be soon. Modified: dragonegg/trunk/www/index.html Modified: dragonegg/trunk/www/index.html URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/www/index.html?rev=85802&r1=85801&r2=85802&view=diff ============================================================================== --- dragonegg/trunk/www/index.html (original) +++ dragonegg/trunk/www/index.html Mon Nov 2 09:48:31 2009 @@ -40,7 +40,6 @@
  • Ada and C++ work somewhat
  • Java, Obj-C and Obj-C++ are untested
  • Exception handling does not work
  • -
  • Indirect gotos do not always work
  • Limited debug info
  • Requires one gcc patch
  • Only supports x86-32 and x86-64
  • From baldrick at free.fr Mon Nov 2 09:56:37 2009 From: baldrick at free.fr (Duncan Sands) Date: Mon, 02 Nov 2009 15:56:37 -0000 Subject: [llvm-commits] [dragonegg] r85803 - in /dragonegg/trunk: TODO x86/llvm-target.cpp Message-ID: <200911021556.nA2Fuco5007559@zion.cs.uiuc.edu> Author: baldrick Date: Mon Nov 2 09:56:37 2009 New Revision: 85803 URL: http://llvm.org/viewvc/llvm-project?rev=85803&view=rev Log: Add the list of all x86 builtins supported by gcc-4.5, with ones we don't support commented out. This way it is easy to see what needs doing. Add a note about how we could easily add support for several gcc builtins. Comment out the IX86_BUILTIN_LOADQ expansion code from llvm-gcc, because I couldn't work out which gcc intrinsic (if any) it corresponds to. Modified: dragonegg/trunk/TODO dragonegg/trunk/x86/llvm-target.cpp Modified: dragonegg/trunk/TODO URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/TODO?rev=85803&r1=85802&r2=85803&view=diff ============================================================================== --- dragonegg/trunk/TODO (original) +++ dragonegg/trunk/TODO Mon Nov 2 09:56:37 2009 @@ -62,3 +62,7 @@ Output proper debug info rather than throwing most of it away. Add support for exception handling. + +Many x86 specific builtins are not supported, even though it would be easy to +add support for some of them, for example the 256 bit versions of builtins we +do support. Improve this. Modified: dragonegg/trunk/x86/llvm-target.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/x86/llvm-target.cpp?rev=85803&r1=85802&r2=85803&view=diff ============================================================================== --- dragonegg/trunk/x86/llvm-target.cpp (original) +++ dragonegg/trunk/x86/llvm-target.cpp Mon Nov 2 09:56:37 2009 @@ -82,18 +82,42 @@ const Type *ResultType, std::vector &Ops) { const HandlerEntry Handlers[] = { + // Unsupported builtins are commented out. {"__builtin_ia32_addpd", &&IX86_BUILTIN_ADDPD}, - {"__builtin_ia32_addpd256", &&IX86_BUILTIN_ADDPD}, + //{"__builtin_ia32_addpd256", &&IX86_BUILTIN_ADDPD256}, {"__builtin_ia32_addps", &&IX86_BUILTIN_ADDPS}, - {"__builtin_ia32_addps256", &&IX86_BUILTIN_ADDPS}, + //{"__builtin_ia32_addps256", &&IX86_BUILTIN_ADDPS256}, + //{"__builtin_ia32_addsd", &&IX86_BUILTIN_ADDSD}, + //{"__builtin_ia32_addss", &&IX86_BUILTIN_ADDSS}, + //{"__builtin_ia32_addsubpd", &&IX86_BUILTIN_ADDSUBPD}, + //{"__builtin_ia32_addsubpd256", &&IX86_BUILTIN_ADDSUBPD256}, + //{"__builtin_ia32_addsubps", &&IX86_BUILTIN_ADDSUBPS}, + //{"__builtin_ia32_addsubps256", &&IX86_BUILTIN_ADDSUBPS256}, + //{"__builtin_ia32_aesdec128", &&IX86_BUILTIN_AESDEC128}, + //{"__builtin_ia32_aesdeclast128", &&IX86_BUILTIN_AESDECLAST128}, + //{"__builtin_ia32_aesenc128", &&IX86_BUILTIN_AESENC128}, + //{"__builtin_ia32_aesenclast128", &&IX86_BUILTIN_AESENCLAST128}, + //{"__builtin_ia32_aesimc128", &&IX86_BUILTIN_AESIMC128}, + //{"__builtin_ia32_aeskeygenassist128", &&IX86_BUILTIN_AESKEYGENASSIST128}, {"__builtin_ia32_andnpd", &&IX86_BUILTIN_ANDNPD}, - {"__builtin_ia32_andnpd256", &&IX86_BUILTIN_ANDNPD}, + //{"__builtin_ia32_andnpd256", &&IX86_BUILTIN_ANDNPD256}, {"__builtin_ia32_andnps", &&IX86_BUILTIN_ANDNPS}, - {"__builtin_ia32_andnps256", &&IX86_BUILTIN_ANDNPS}, + //{"__builtin_ia32_andnps256", &&IX86_BUILTIN_ANDNPS256}, {"__builtin_ia32_andpd", &&IX86_BUILTIN_ANDPD}, - {"__builtin_ia32_andpd256", &&IX86_BUILTIN_ANDPD}, + //{"__builtin_ia32_andpd256", &&IX86_BUILTIN_ANDPD256}, {"__builtin_ia32_andps", &&IX86_BUILTIN_ANDPS}, - {"__builtin_ia32_andps256", &&IX86_BUILTIN_ANDPS}, + //{"__builtin_ia32_andps256", &&IX86_BUILTIN_ANDPS256}, + //{"__builtin_ia32_blendpd", &&IX86_BUILTIN_BLENDPD}, + //{"__builtin_ia32_blendpd256", &&IX86_BUILTIN_BLENDPD256}, + //{"__builtin_ia32_blendps", &&IX86_BUILTIN_BLENDPS}, + //{"__builtin_ia32_blendps256", &&IX86_BUILTIN_BLENDPS256}, + //{"__builtin_ia32_blendvpd", &&IX86_BUILTIN_BLENDVPD}, + //{"__builtin_ia32_blendvpd256", &&IX86_BUILTIN_BLENDVPD256}, + //{"__builtin_ia32_blendvps", &&IX86_BUILTIN_BLENDVPS}, + //{"__builtin_ia32_blendvps256", &&IX86_BUILTIN_BLENDVPS256}, + //{"__builtin_ia32_bsrdi", &&IX86_BUILTIN_BSRDI}, + //{"__builtin_ia32_bsrsi", &&IX86_BUILTIN_BSRSI}, + //{"__builtin_ia32_clflush", &&IX86_BUILTIN_CLFLUSH}, {"__builtin_ia32_cmpeqpd", &&IX86_BUILTIN_CMPEQPD}, {"__builtin_ia32_cmpeqps", &&IX86_BUILTIN_CMPEQPS}, {"__builtin_ia32_cmpeqsd", &&IX86_BUILTIN_CMPEQSD}, @@ -116,8 +140,10 @@ {"__builtin_ia32_cmpneqss", &&IX86_BUILTIN_CMPNEQSS}, {"__builtin_ia32_cmpngepd", &&IX86_BUILTIN_CMPNGEPD}, {"__builtin_ia32_cmpngeps", &&IX86_BUILTIN_CMPNGEPS}, + //{"__builtin_ia32_cmpngess", &&IX86_BUILTIN_CMPNGESS}, {"__builtin_ia32_cmpngtpd", &&IX86_BUILTIN_CMPNGTPD}, {"__builtin_ia32_cmpngtps", &&IX86_BUILTIN_CMPNGTPS}, + //{"__builtin_ia32_cmpngtss", &&IX86_BUILTIN_CMPNGTSS}, {"__builtin_ia32_cmpnlepd", &&IX86_BUILTIN_CMPNLEPD}, {"__builtin_ia32_cmpnleps", &&IX86_BUILTIN_CMPNLEPS}, {"__builtin_ia32_cmpnlesd", &&IX86_BUILTIN_CMPNLESD}, @@ -130,71 +156,400 @@ {"__builtin_ia32_cmpordps", &&IX86_BUILTIN_CMPORDPS}, {"__builtin_ia32_cmpordsd", &&IX86_BUILTIN_CMPORDSD}, {"__builtin_ia32_cmpordss", &&IX86_BUILTIN_CMPORDSS}, + //{"__builtin_ia32_cmppd", &&IX86_BUILTIN_CMPPD}, + //{"__builtin_ia32_cmppd256", &&IX86_BUILTIN_CMPPD256}, + //{"__builtin_ia32_cmpps", &&IX86_BUILTIN_CMPPS}, + //{"__builtin_ia32_cmpps256", &&IX86_BUILTIN_CMPPS256}, + //{"__builtin_ia32_cmpsd", &&IX86_BUILTIN_CMPSD}, + //{"__builtin_ia32_cmpss", &&IX86_BUILTIN_CMPSS}, {"__builtin_ia32_cmpunordpd", &&IX86_BUILTIN_CMPUNORDPD}, {"__builtin_ia32_cmpunordps", &&IX86_BUILTIN_CMPUNORDPS}, {"__builtin_ia32_cmpunordsd", &&IX86_BUILTIN_CMPUNORDSD}, {"__builtin_ia32_cmpunordss", &&IX86_BUILTIN_CMPUNORDSS}, + //{"__builtin_ia32_comieq", &&IX86_BUILTIN_COMIEQSS}, + //{"__builtin_ia32_comige", &&IX86_BUILTIN_COMIGESS}, + //{"__builtin_ia32_comigt", &&IX86_BUILTIN_COMIGTSS}, + //{"__builtin_ia32_comile", &&IX86_BUILTIN_COMILESS}, + //{"__builtin_ia32_comilt", &&IX86_BUILTIN_COMILTSS}, + //{"__builtin_ia32_comineq", &&IX86_BUILTIN_COMINEQSS}, + //{"__builtin_ia32_comisdeq", &&IX86_BUILTIN_COMIEQSD}, + //{"__builtin_ia32_comisdge", &&IX86_BUILTIN_COMIGESD}, + //{"__builtin_ia32_comisdgt", &&IX86_BUILTIN_COMIGTSD}, + //{"__builtin_ia32_comisdle", &&IX86_BUILTIN_COMILESD}, + //{"__builtin_ia32_comisdlt", &&IX86_BUILTIN_COMILTSD}, + //{"__builtin_ia32_comisdneq", &&IX86_BUILTIN_COMINEQSD}, + //{"__builtin_ia32_copysignpd", &&IX86_BUILTIN_CPYSGNPD}, + //{"__builtin_ia32_copysignps", &&IX86_BUILTIN_CPYSGNPS}, + //{"__builtin_ia32_crc32di", &&IX86_BUILTIN_CRC32DI}, + //{"__builtin_ia32_crc32hi", &&IX86_BUILTIN_CRC32HI}, + //{"__builtin_ia32_crc32qi", &&IX86_BUILTIN_CRC32QI}, + //{"__builtin_ia32_crc32si", &&IX86_BUILTIN_CRC32SI}, + //{"__builtin_ia32_cvtdq2pd", &&IX86_BUILTIN_CVTDQ2PD}, + //{"__builtin_ia32_cvtdq2pd256", &&IX86_BUILTIN_CVTDQ2PD256}, + //{"__builtin_ia32_cvtdq2ps", &&IX86_BUILTIN_CVTDQ2PS}, + //{"__builtin_ia32_cvtdq2ps256", &&IX86_BUILTIN_CVTDQ2PS256}, + //{"__builtin_ia32_cvtpd2dq", &&IX86_BUILTIN_CVTPD2DQ}, + //{"__builtin_ia32_cvtpd2dq256", &&IX86_BUILTIN_CVTPD2DQ256}, + //{"__builtin_ia32_cvtpd2pi", &&IX86_BUILTIN_CVTPD2PI}, + //{"__builtin_ia32_cvtpd2ps", &&IX86_BUILTIN_CVTPD2PS}, + //{"__builtin_ia32_cvtpd2ps256", &&IX86_BUILTIN_CVTPD2PS256}, + //{"__builtin_ia32_cvtpi2pd", &&IX86_BUILTIN_CVTPI2PD}, + //{"__builtin_ia32_cvtpi2ps", &&IX86_BUILTIN_CVTPI2PS}, + //{"__builtin_ia32_cvtps2dq", &&IX86_BUILTIN_CVTPS2DQ}, + //{"__builtin_ia32_cvtps2dq256", &&IX86_BUILTIN_CVTPS2DQ256}, + //{"__builtin_ia32_cvtps2pd", &&IX86_BUILTIN_CVTPS2PD}, + //{"__builtin_ia32_cvtps2pd256", &&IX86_BUILTIN_CVTPS2PD256}, + //{"__builtin_ia32_cvtps2pi", &&IX86_BUILTIN_CVTPS2PI}, + //{"__builtin_ia32_cvtsd2si", &&IX86_BUILTIN_CVTSD2SI}, + //{"__builtin_ia32_cvtsd2si64", &&IX86_BUILTIN_CVTSD2SI64}, + //{"__builtin_ia32_cvtsd2ss", &&IX86_BUILTIN_CVTSD2SS}, + //{"__builtin_ia32_cvtsi2sd", &&IX86_BUILTIN_CVTSI2SD}, + //{"__builtin_ia32_cvtsi2ss", &&IX86_BUILTIN_CVTSI2SS}, + //{"__builtin_ia32_cvtsi642sd", &&IX86_BUILTIN_CVTSI642SD}, + //{"__builtin_ia32_cvtsi642ss", &&IX86_BUILTIN_CVTSI642SS}, + //{"__builtin_ia32_cvtss2sd", &&IX86_BUILTIN_CVTSS2SD}, + //{"__builtin_ia32_cvtss2si", &&IX86_BUILTIN_CVTSS2SI}, + //{"__builtin_ia32_cvtss2si64", &&IX86_BUILTIN_CVTSS2SI64}, + //{"__builtin_ia32_cvttpd2dq", &&IX86_BUILTIN_CVTTPD2DQ}, + //{"__builtin_ia32_cvttpd2dq256", &&IX86_BUILTIN_CVTTPD2DQ256}, + //{"__builtin_ia32_cvttpd2pi", &&IX86_BUILTIN_CVTTPD2PI}, + //{"__builtin_ia32_cvttps2dq", &&IX86_BUILTIN_CVTTPS2DQ}, + //{"__builtin_ia32_cvttps2dq256", &&IX86_BUILTIN_CVTTPS2DQ256}, + //{"__builtin_ia32_cvttps2pi", &&IX86_BUILTIN_CVTTPS2PI}, + //{"__builtin_ia32_cvttsd2si", &&IX86_BUILTIN_CVTTSD2SI}, + //{"__builtin_ia32_cvttsd2si64", &&IX86_BUILTIN_CVTTSD2SI64}, + //{"__builtin_ia32_cvttss2si", &&IX86_BUILTIN_CVTTSS2SI}, + //{"__builtin_ia32_cvttss2si64", &&IX86_BUILTIN_CVTTSS2SI64}, + //{"__builtin_ia32_cvtudq2ps", &&IX86_BUILTIN_CVTUDQ2PS}, {"__builtin_ia32_divpd", &&IX86_BUILTIN_DIVPD}, - {"__builtin_ia32_divpd256", &&IX86_BUILTIN_DIVPD}, + //{"__builtin_ia32_divpd256", &&IX86_BUILTIN_DIVPD256}, {"__builtin_ia32_divps", &&IX86_BUILTIN_DIVPS}, - {"__builtin_ia32_divps256", &&IX86_BUILTIN_DIVPS}, + //{"__builtin_ia32_divps256", &&IX86_BUILTIN_DIVPS256}, + //{"__builtin_ia32_divsd", &&IX86_BUILTIN_DIVSD}, + //{"__builtin_ia32_divss", &&IX86_BUILTIN_DIVSS}, + //{"__builtin_ia32_dppd", &&IX86_BUILTIN_DPPD}, + //{"__builtin_ia32_dpps", &&IX86_BUILTIN_DPPS}, + //{"__builtin_ia32_dpps256", &&IX86_BUILTIN_DPPS256}, + //{"__builtin_ia32_emms", &&IX86_BUILTIN_EMMS}, + //{"__builtin_ia32_extrq", &&IX86_BUILTIN_EXTRQ}, + //{"__builtin_ia32_extrqi", &&IX86_BUILTIN_EXTRQI}, + //{"__builtin_ia32_femms", &&IX86_BUILTIN_FEMMS}, + //{"__builtin_ia32_haddpd", &&IX86_BUILTIN_HADDPD}, + //{"__builtin_ia32_haddpd256", &&IX86_BUILTIN_HADDPD256}, + //{"__builtin_ia32_haddps", &&IX86_BUILTIN_HADDPS}, + //{"__builtin_ia32_haddps256", &&IX86_BUILTIN_HADDPS256}, + //{"__builtin_ia32_hsubpd", &&IX86_BUILTIN_HSUBPD}, + //{"__builtin_ia32_hsubpd256", &&IX86_BUILTIN_HSUBPD256}, + //{"__builtin_ia32_hsubps", &&IX86_BUILTIN_HSUBPS}, + //{"__builtin_ia32_hsubps256", &&IX86_BUILTIN_HSUBPS256}, + //{"__builtin_ia32_insertps128", &&IX86_BUILTIN_INSERTPS128}, + //{"__builtin_ia32_insertq", &&IX86_BUILTIN_INSERTQ}, + //{"__builtin_ia32_insertqi", &&IX86_BUILTIN_INSERTQI}, + //{"__builtin_ia32_lddqu", &&IX86_BUILTIN_LDDQU}, + //{"__builtin_ia32_lddqu256", &&IX86_BUILTIN_LDDQU256}, {"__builtin_ia32_ldmxcsr", &&IX86_BUILTIN_LDMXCSR}, + //{"__builtin_ia32_lfence", &&IX86_BUILTIN_LFENCE}, {"__builtin_ia32_loaddqu", &&IX86_BUILTIN_LOADDQU}, - {"__builtin_ia32_loaddqu256", &&IX86_BUILTIN_LOADDQU}, + //{"__builtin_ia32_loaddqu256", &&IX86_BUILTIN_LOADDQU256}, {"__builtin_ia32_loadhpd", &&IX86_BUILTIN_LOADHPD}, {"__builtin_ia32_loadhps", &&IX86_BUILTIN_LOADHPS}, {"__builtin_ia32_loadlpd", &&IX86_BUILTIN_LOADLPD}, {"__builtin_ia32_loadlps", &&IX86_BUILTIN_LOADLPS}, - {"__builtin_ia32_loadlv4si", &&IX86_BUILTIN_LOADQ}, {"__builtin_ia32_loadupd", &&IX86_BUILTIN_LOADUPD}, - {"__builtin_ia32_loadupd256", &&IX86_BUILTIN_LOADUPD}, + //{"__builtin_ia32_loadupd256", &&IX86_BUILTIN_LOADUPD256}, {"__builtin_ia32_loadups", &&IX86_BUILTIN_LOADUPS}, - {"__builtin_ia32_loadups256", &&IX86_BUILTIN_LOADUPS}, + //{"__builtin_ia32_loadups256", &&IX86_BUILTIN_LOADUPS256}, + //{"__builtin_ia32_maskloadpd", &&IX86_BUILTIN_MASKLOADPD}, + //{"__builtin_ia32_maskloadpd256", &&IX86_BUILTIN_MASKLOADPD256}, + //{"__builtin_ia32_maskloadps", &&IX86_BUILTIN_MASKLOADPS}, + //{"__builtin_ia32_maskloadps256", &&IX86_BUILTIN_MASKLOADPS256}, + //{"__builtin_ia32_maskmovdqu", &&IX86_BUILTIN_MASKMOVDQU}, + //{"__builtin_ia32_maskmovq", &&IX86_BUILTIN_MASKMOVQ}, + //{"__builtin_ia32_maskstorepd", &&IX86_BUILTIN_MASKSTOREPD}, + //{"__builtin_ia32_maskstorepd256", &&IX86_BUILTIN_MASKSTOREPD256}, + //{"__builtin_ia32_maskstoreps", &&IX86_BUILTIN_MASKSTOREPS}, + //{"__builtin_ia32_maskstoreps256", &&IX86_BUILTIN_MASKSTOREPS256}, + //{"__builtin_ia32_maxpd", &&IX86_BUILTIN_MAXPD}, + //{"__builtin_ia32_maxpd256", &&IX86_BUILTIN_MAXPD256}, + //{"__builtin_ia32_maxps", &&IX86_BUILTIN_MAXPS}, + //{"__builtin_ia32_maxps256", &&IX86_BUILTIN_MAXPS256}, + //{"__builtin_ia32_maxsd", &&IX86_BUILTIN_MAXSD}, + //{"__builtin_ia32_maxss", &&IX86_BUILTIN_MAXSS}, + //{"__builtin_ia32_mfence", &&IX86_BUILTIN_MFENCE}, + //{"__builtin_ia32_minpd", &&IX86_BUILTIN_MINPD}, + //{"__builtin_ia32_minpd256", &&IX86_BUILTIN_MINPD256}, + //{"__builtin_ia32_minps", &&IX86_BUILTIN_MINPS}, + //{"__builtin_ia32_minps256", &&IX86_BUILTIN_MINPS256}, + //{"__builtin_ia32_minsd", &&IX86_BUILTIN_MINSD}, + //{"__builtin_ia32_minss", &&IX86_BUILTIN_MINSS}, + //{"__builtin_ia32_monitor", &&IX86_BUILTIN_MONITOR}, + //{"__builtin_ia32_movddup256", &&IX86_BUILTIN_MOVDDUP256}, {"__builtin_ia32_movhlps", &&IX86_BUILTIN_MOVHLPS}, {"__builtin_ia32_movlhps", &&IX86_BUILTIN_MOVLHPS}, + //{"__builtin_ia32_movmskpd", &&IX86_BUILTIN_MOVMSKPD}, + //{"__builtin_ia32_movmskpd256", &&IX86_BUILTIN_MOVMSKPD256}, + //{"__builtin_ia32_movmskps", &&IX86_BUILTIN_MOVMSKPS}, + //{"__builtin_ia32_movmskps256", &&IX86_BUILTIN_MOVMSKPS256}, + //{"__builtin_ia32_movntdq", &&IX86_BUILTIN_MOVNTDQ}, + //{"__builtin_ia32_movntdq256", &&IX86_BUILTIN_MOVNTDQ256}, + //{"__builtin_ia32_movntdqa", &&IX86_BUILTIN_MOVNTDQA}, + //{"__builtin_ia32_movnti", &&IX86_BUILTIN_MOVNTI}, + //{"__builtin_ia32_movntpd", &&IX86_BUILTIN_MOVNTPD}, + //{"__builtin_ia32_movntpd256", &&IX86_BUILTIN_MOVNTPD256}, + //{"__builtin_ia32_movntps", &&IX86_BUILTIN_MOVNTPS}, + //{"__builtin_ia32_movntps256", &&IX86_BUILTIN_MOVNTPS256}, + //{"__builtin_ia32_movntq", &&IX86_BUILTIN_MOVNTQ}, + //{"__builtin_ia32_movntsd", &&IX86_BUILTIN_MOVNTSD}, + //{"__builtin_ia32_movntss", &&IX86_BUILTIN_MOVNTSS}, {"__builtin_ia32_movq128", &&IX86_BUILTIN_MOVQ128}, {"__builtin_ia32_movsd", &&IX86_BUILTIN_MOVSD}, {"__builtin_ia32_movshdup", &&IX86_BUILTIN_MOVSHDUP}, - {"__builtin_ia32_movshdup256", &&IX86_BUILTIN_MOVSHDUP}, + //{"__builtin_ia32_movshdup256", &&IX86_BUILTIN_MOVSHDUP256}, {"__builtin_ia32_movsldup", &&IX86_BUILTIN_MOVSLDUP}, - {"__builtin_ia32_movsldup256", &&IX86_BUILTIN_MOVSLDUP}, + //{"__builtin_ia32_movsldup256", &&IX86_BUILTIN_MOVSLDUP256}, {"__builtin_ia32_movss", &&IX86_BUILTIN_MOVSS}, + //{"__builtin_ia32_mpsadbw128", &&IX86_BUILTIN_MPSADBW128}, {"__builtin_ia32_mulpd", &&IX86_BUILTIN_MULPD}, - {"__builtin_ia32_mulpd256", &&IX86_BUILTIN_MULPD}, + //{"__builtin_ia32_mulpd256", &&IX86_BUILTIN_MULPD256}, {"__builtin_ia32_mulps", &&IX86_BUILTIN_MULPS}, - {"__builtin_ia32_mulps256", &&IX86_BUILTIN_MULPS}, + //{"__builtin_ia32_mulps256", &&IX86_BUILTIN_MULPS256}, + //{"__builtin_ia32_mulsd", &&IX86_BUILTIN_MULSD}, + //{"__builtin_ia32_mulss", &&IX86_BUILTIN_MULSS}, + //{"__builtin_ia32_mwait", &&IX86_BUILTIN_MWAIT}, {"__builtin_ia32_orpd", &&IX86_BUILTIN_ORPD}, - {"__builtin_ia32_orpd256", &&IX86_BUILTIN_ORPD}, + //{"__builtin_ia32_orpd256", &&IX86_BUILTIN_ORPD256}, {"__builtin_ia32_orps", &&IX86_BUILTIN_ORPS}, - {"__builtin_ia32_orps256", &&IX86_BUILTIN_ORPS}, + //{"__builtin_ia32_orps256", &&IX86_BUILTIN_ORPS256}, + //{"__builtin_ia32_pabsb", &&IX86_BUILTIN_PABSB}, + //{"__builtin_ia32_pabsb128", &&IX86_BUILTIN_PABSB128}, + //{"__builtin_ia32_pabsd", &&IX86_BUILTIN_PABSD}, + //{"__builtin_ia32_pabsd128", &&IX86_BUILTIN_PABSD128}, + //{"__builtin_ia32_pabsw", &&IX86_BUILTIN_PABSW}, + //{"__builtin_ia32_pabsw128", &&IX86_BUILTIN_PABSW128}, + //{"__builtin_ia32_packssdw", &&IX86_BUILTIN_PACKSSDW}, + //{"__builtin_ia32_packssdw128", &&IX86_BUILTIN_PACKSSDW128}, + //{"__builtin_ia32_packsswb", &&IX86_BUILTIN_PACKSSWB}, + //{"__builtin_ia32_packsswb128", &&IX86_BUILTIN_PACKSSWB128}, + //{"__builtin_ia32_packusdw128", &&IX86_BUILTIN_PACKUSDW128}, + //{"__builtin_ia32_packuswb", &&IX86_BUILTIN_PACKUSWB}, + //{"__builtin_ia32_packuswb128", &&IX86_BUILTIN_PACKUSWB128}, {"__builtin_ia32_paddb", &&IX86_BUILTIN_PADDB}, {"__builtin_ia32_paddb128", &&IX86_BUILTIN_PADDB128}, {"__builtin_ia32_paddd", &&IX86_BUILTIN_PADDD}, {"__builtin_ia32_paddd128", &&IX86_BUILTIN_PADDD128}, {"__builtin_ia32_paddq", &&IX86_BUILTIN_PADDQ}, {"__builtin_ia32_paddq128", &&IX86_BUILTIN_PADDQ128}, + //{"__builtin_ia32_paddsb", &&IX86_BUILTIN_PADDSB}, + //{"__builtin_ia32_paddsb128", &&IX86_BUILTIN_PADDSB128}, + //{"__builtin_ia32_paddsw", &&IX86_BUILTIN_PADDSW}, + //{"__builtin_ia32_paddsw128", &&IX86_BUILTIN_PADDSW128}, + //{"__builtin_ia32_paddusb", &&IX86_BUILTIN_PADDUSB}, + //{"__builtin_ia32_paddusb128", &&IX86_BUILTIN_PADDUSB128}, + //{"__builtin_ia32_paddusw", &&IX86_BUILTIN_PADDUSW}, + //{"__builtin_ia32_paddusw128", &&IX86_BUILTIN_PADDUSW128}, {"__builtin_ia32_paddw", &&IX86_BUILTIN_PADDW}, {"__builtin_ia32_paddw128", &&IX86_BUILTIN_PADDW128}, + //{"__builtin_ia32_palignr", &&IX86_BUILTIN_PALIGNR}, + //{"__builtin_ia32_palignr128", &&IX86_BUILTIN_PALIGNR128}, {"__builtin_ia32_pand", &&IX86_BUILTIN_PAND}, {"__builtin_ia32_pand128", &&IX86_BUILTIN_PAND128}, {"__builtin_ia32_pandn", &&IX86_BUILTIN_PANDN}, {"__builtin_ia32_pandn128", &&IX86_BUILTIN_PANDN128}, + //{"__builtin_ia32_pavgb", &&IX86_BUILTIN_PAVGB}, + //{"__builtin_ia32_pavgb128", &&IX86_BUILTIN_PAVGB128}, + //{"__builtin_ia32_pavgusb", &&IX86_BUILTIN_PAVGUSB}, + //{"__builtin_ia32_pavgw", &&IX86_BUILTIN_PAVGW}, + //{"__builtin_ia32_pavgw128", &&IX86_BUILTIN_PAVGW128}, + //{"__builtin_ia32_pblendvb128", &&IX86_BUILTIN_PBLENDVB128}, + //{"__builtin_ia32_pblendw128", &&IX86_BUILTIN_PBLENDW128}, + //{"__builtin_ia32_pclmulqdq128", &&IX86_BUILTIN_PCLMULQDQ128}, + //{"__builtin_ia32_pcmpeqb", &&IX86_BUILTIN_PCMPEQB}, + //{"__builtin_ia32_pcmpeqb128", &&IX86_BUILTIN_PCMPEQB128}, + //{"__builtin_ia32_pcmpeqd", &&IX86_BUILTIN_PCMPEQD}, + //{"__builtin_ia32_pcmpeqd128", &&IX86_BUILTIN_PCMPEQD128}, + //{"__builtin_ia32_pcmpeqq", &&IX86_BUILTIN_PCMPEQQ}, + //{"__builtin_ia32_pcmpeqw", &&IX86_BUILTIN_PCMPEQW}, + //{"__builtin_ia32_pcmpeqw128", &&IX86_BUILTIN_PCMPEQW128}, + //{"__builtin_ia32_pcmpestri128", &&IX86_BUILTIN_PCMPESTRI128}, + //{"__builtin_ia32_pcmpestria128", &&IX86_BUILTIN_PCMPESTRA128}, + //{"__builtin_ia32_pcmpestric128", &&IX86_BUILTIN_PCMPESTRC128}, + //{"__builtin_ia32_pcmpestrio128", &&IX86_BUILTIN_PCMPESTRO128}, + //{"__builtin_ia32_pcmpestris128", &&IX86_BUILTIN_PCMPESTRS128}, + //{"__builtin_ia32_pcmpestriz128", &&IX86_BUILTIN_PCMPESTRZ128}, + //{"__builtin_ia32_pcmpestrm128", &&IX86_BUILTIN_PCMPESTRM128}, + //{"__builtin_ia32_pcmpgtb", &&IX86_BUILTIN_PCMPGTB}, + //{"__builtin_ia32_pcmpgtb128", &&IX86_BUILTIN_PCMPGTB128}, + //{"__builtin_ia32_pcmpgtd", &&IX86_BUILTIN_PCMPGTD}, + //{"__builtin_ia32_pcmpgtd128", &&IX86_BUILTIN_PCMPGTD128}, + //{"__builtin_ia32_pcmpgtq", &&IX86_BUILTIN_PCMPGTQ}, + //{"__builtin_ia32_pcmpgtw", &&IX86_BUILTIN_PCMPGTW}, + //{"__builtin_ia32_pcmpgtw128", &&IX86_BUILTIN_PCMPGTW128}, + //{"__builtin_ia32_pcmpistri128", &&IX86_BUILTIN_PCMPISTRI128}, + //{"__builtin_ia32_pcmpistria128", &&IX86_BUILTIN_PCMPISTRA128}, + //{"__builtin_ia32_pcmpistric128", &&IX86_BUILTIN_PCMPISTRC128}, + //{"__builtin_ia32_pcmpistrio128", &&IX86_BUILTIN_PCMPISTRO128}, + //{"__builtin_ia32_pcmpistris128", &&IX86_BUILTIN_PCMPISTRS128}, + //{"__builtin_ia32_pcmpistriz128", &&IX86_BUILTIN_PCMPISTRZ128}, + //{"__builtin_ia32_pcmpistrm128", &&IX86_BUILTIN_PCMPISTRM128}, + //{"__builtin_ia32_pd256_pd", &&IX86_BUILTIN_PD256_PD}, + //{"__builtin_ia32_pd_pd256", &&IX86_BUILTIN_PD_PD256}, + //{"__builtin_ia32_pf2id", &&IX86_BUILTIN_PF2ID}, + //{"__builtin_ia32_pf2iw", &&IX86_BUILTIN_PF2IW}, + //{"__builtin_ia32_pfacc", &&IX86_BUILTIN_PFACC}, + //{"__builtin_ia32_pfadd", &&IX86_BUILTIN_PFADD}, + //{"__builtin_ia32_pfcmpeq", &&IX86_BUILTIN_PFCMPEQ}, + //{"__builtin_ia32_pfcmpge", &&IX86_BUILTIN_PFCMPGE}, + //{"__builtin_ia32_pfcmpgt", &&IX86_BUILTIN_PFCMPGT}, + //{"__builtin_ia32_pfmax", &&IX86_BUILTIN_PFMAX}, + //{"__builtin_ia32_pfmin", &&IX86_BUILTIN_PFMIN}, + //{"__builtin_ia32_pfmul", &&IX86_BUILTIN_PFMUL}, + //{"__builtin_ia32_pfnacc", &&IX86_BUILTIN_PFNACC}, + //{"__builtin_ia32_pfpnacc", &&IX86_BUILTIN_PFPNACC}, + //{"__builtin_ia32_pfrcp", &&IX86_BUILTIN_PFRCP}, + //{"__builtin_ia32_pfrcpit1", &&IX86_BUILTIN_PFRCPIT1}, + //{"__builtin_ia32_pfrcpit2", &&IX86_BUILTIN_PFRCPIT2}, + //{"__builtin_ia32_pfrsqit1", &&IX86_BUILTIN_PFRSQIT1}, + //{"__builtin_ia32_pfrsqrt", &&IX86_BUILTIN_PFRSQRT}, + //{"__builtin_ia32_pfsub", &&IX86_BUILTIN_PFSUB}, + //{"__builtin_ia32_pfsubr", &&IX86_BUILTIN_PFSUBR}, + //{"__builtin_ia32_phaddd", &&IX86_BUILTIN_PHADDD}, + //{"__builtin_ia32_phaddd128", &&IX86_BUILTIN_PHADDD128}, + //{"__builtin_ia32_phaddsw", &&IX86_BUILTIN_PHADDSW}, + //{"__builtin_ia32_phaddsw128", &&IX86_BUILTIN_PHADDSW128}, + //{"__builtin_ia32_phaddw", &&IX86_BUILTIN_PHADDW}, + //{"__builtin_ia32_phaddw128", &&IX86_BUILTIN_PHADDW128}, + //{"__builtin_ia32_phminposuw128", &&IX86_BUILTIN_PHMINPOSUW128}, + //{"__builtin_ia32_phsubd", &&IX86_BUILTIN_PHSUBD}, + //{"__builtin_ia32_phsubd128", &&IX86_BUILTIN_PHSUBD128}, + //{"__builtin_ia32_phsubsw", &&IX86_BUILTIN_PHSUBSW}, + //{"__builtin_ia32_phsubsw128", &&IX86_BUILTIN_PHSUBSW128}, + //{"__builtin_ia32_phsubw", &&IX86_BUILTIN_PHSUBW}, + //{"__builtin_ia32_phsubw128", &&IX86_BUILTIN_PHSUBW128}, + //{"__builtin_ia32_pi2fd", &&IX86_BUILTIN_PI2FD}, + //{"__builtin_ia32_pi2fw", &&IX86_BUILTIN_PI2FW}, + //{"__builtin_ia32_pmaddubsw", &&IX86_BUILTIN_PMADDUBSW}, + //{"__builtin_ia32_pmaddubsw128", &&IX86_BUILTIN_PMADDUBSW128}, + //{"__builtin_ia32_pmaddwd", &&IX86_BUILTIN_PMADDWD}, + //{"__builtin_ia32_pmaddwd128", &&IX86_BUILTIN_PMADDWD128}, + //{"__builtin_ia32_pmaxsb128", &&IX86_BUILTIN_PMAXSB128}, + //{"__builtin_ia32_pmaxsd128", &&IX86_BUILTIN_PMAXSD128}, + //{"__builtin_ia32_pmaxsw", &&IX86_BUILTIN_PMAXSW}, + //{"__builtin_ia32_pmaxsw128", &&IX86_BUILTIN_PMAXSW128}, + //{"__builtin_ia32_pmaxub", &&IX86_BUILTIN_PMAXUB}, + //{"__builtin_ia32_pmaxub128", &&IX86_BUILTIN_PMAXUB128}, + //{"__builtin_ia32_pmaxud128", &&IX86_BUILTIN_PMAXUD128}, + //{"__builtin_ia32_pmaxuw128", &&IX86_BUILTIN_PMAXUW128}, + //{"__builtin_ia32_pminsb128", &&IX86_BUILTIN_PMINSB128}, + //{"__builtin_ia32_pminsd128", &&IX86_BUILTIN_PMINSD128}, + //{"__builtin_ia32_pminsw", &&IX86_BUILTIN_PMINSW}, + //{"__builtin_ia32_pminsw128", &&IX86_BUILTIN_PMINSW128}, + //{"__builtin_ia32_pminub", &&IX86_BUILTIN_PMINUB}, + //{"__builtin_ia32_pminub128", &&IX86_BUILTIN_PMINUB128}, + //{"__builtin_ia32_pminud128", &&IX86_BUILTIN_PMINUD128}, + //{"__builtin_ia32_pminuw128", &&IX86_BUILTIN_PMINUW128}, + //{"__builtin_ia32_pmovmskb", &&IX86_BUILTIN_PMOVMSKB}, + //{"__builtin_ia32_pmovmskb128", &&IX86_BUILTIN_PMOVMSKB128}, + //{"__builtin_ia32_pmovsxbd128", &&IX86_BUILTIN_PMOVSXBD128}, + //{"__builtin_ia32_pmovsxbq128", &&IX86_BUILTIN_PMOVSXBQ128}, + //{"__builtin_ia32_pmovsxbw128", &&IX86_BUILTIN_PMOVSXBW128}, + //{"__builtin_ia32_pmovsxdq128", &&IX86_BUILTIN_PMOVSXDQ128}, + //{"__builtin_ia32_pmovsxwd128", &&IX86_BUILTIN_PMOVSXWD128}, + //{"__builtin_ia32_pmovsxwq128", &&IX86_BUILTIN_PMOVSXWQ128}, + //{"__builtin_ia32_pmovzxbd128", &&IX86_BUILTIN_PMOVZXBD128}, + //{"__builtin_ia32_pmovzxbq128", &&IX86_BUILTIN_PMOVZXBQ128}, + //{"__builtin_ia32_pmovzxbw128", &&IX86_BUILTIN_PMOVZXBW128}, + //{"__builtin_ia32_pmovzxdq128", &&IX86_BUILTIN_PMOVZXDQ128}, + //{"__builtin_ia32_pmovzxwd128", &&IX86_BUILTIN_PMOVZXWD128}, + //{"__builtin_ia32_pmovzxwq128", &&IX86_BUILTIN_PMOVZXWQ128}, + //{"__builtin_ia32_pmuldq128", &&IX86_BUILTIN_PMULDQ128}, + //{"__builtin_ia32_pmulhrsw", &&IX86_BUILTIN_PMULHRSW}, + //{"__builtin_ia32_pmulhrsw128", &&IX86_BUILTIN_PMULHRSW128}, + //{"__builtin_ia32_pmulhrw", &&IX86_BUILTIN_PMULHRW}, + //{"__builtin_ia32_pmulhuw", &&IX86_BUILTIN_PMULHUW}, + //{"__builtin_ia32_pmulhuw128", &&IX86_BUILTIN_PMULHUW128}, + //{"__builtin_ia32_pmulhw", &&IX86_BUILTIN_PMULHW}, + //{"__builtin_ia32_pmulhw128", &&IX86_BUILTIN_PMULHW128}, + //{"__builtin_ia32_pmulld128", &&IX86_BUILTIN_PMULLD128}, {"__builtin_ia32_pmullw", &&IX86_BUILTIN_PMULLW}, {"__builtin_ia32_pmullw128", &&IX86_BUILTIN_PMULLW128}, + //{"__builtin_ia32_pmuludq", &&IX86_BUILTIN_PMULUDQ}, + //{"__builtin_ia32_pmuludq128", &&IX86_BUILTIN_PMULUDQ128}, {"__builtin_ia32_por", &&IX86_BUILTIN_POR}, {"__builtin_ia32_por128", &&IX86_BUILTIN_POR128}, + //{"__builtin_ia32_ps256_ps", &&IX86_BUILTIN_PS256_PS}, + //{"__builtin_ia32_psadbw", &&IX86_BUILTIN_PSADBW}, + //{"__builtin_ia32_psadbw128", &&IX86_BUILTIN_PSADBW128}, + //{"__builtin_ia32_pshufb", &&IX86_BUILTIN_PSHUFB}, + //{"__builtin_ia32_pshufb128", &&IX86_BUILTIN_PSHUFB128}, {"__builtin_ia32_pshufd", &&IX86_BUILTIN_PSHUFD}, {"__builtin_ia32_pshufhw", &&IX86_BUILTIN_PSHUFHW}, {"__builtin_ia32_pshuflw", &&IX86_BUILTIN_PSHUFLW}, {"__builtin_ia32_pshufw", &&IX86_BUILTIN_PSHUFW}, + //{"__builtin_ia32_psignb", &&IX86_BUILTIN_PSIGNB}, + //{"__builtin_ia32_psignb128", &&IX86_BUILTIN_PSIGNB128}, + //{"__builtin_ia32_psignd", &&IX86_BUILTIN_PSIGND}, + //{"__builtin_ia32_psignd128", &&IX86_BUILTIN_PSIGND128}, + //{"__builtin_ia32_psignw", &&IX86_BUILTIN_PSIGNW}, + //{"__builtin_ia32_psignw128", &&IX86_BUILTIN_PSIGNW128}, + //{"__builtin_ia32_pslld", &&IX86_BUILTIN_PSLLD}, + //{"__builtin_ia32_pslld128", &&IX86_BUILTIN_PSLLD128}, + //{"__builtin_ia32_pslldi", &&IX86_BUILTIN_PSLLDI}, + //{"__builtin_ia32_pslldi128", &&IX86_BUILTIN_PSLLDI128}, + //{"__builtin_ia32_pslldqi128", &&IX86_BUILTIN_PSLLDQI128}, + //{"__builtin_ia32_psllq", &&IX86_BUILTIN_PSLLQ}, + //{"__builtin_ia32_psllq128", &&IX86_BUILTIN_PSLLQ128}, + //{"__builtin_ia32_psllqi", &&IX86_BUILTIN_PSLLQI}, + //{"__builtin_ia32_psllqi128", &&IX86_BUILTIN_PSLLQI128}, + //{"__builtin_ia32_psllw", &&IX86_BUILTIN_PSLLW}, + //{"__builtin_ia32_psllw128", &&IX86_BUILTIN_PSLLW128}, + //{"__builtin_ia32_psllwi", &&IX86_BUILTIN_PSLLWI}, + //{"__builtin_ia32_psllwi128", &&IX86_BUILTIN_PSLLWI128}, + //{"__builtin_ia32_ps_ps256", &&IX86_BUILTIN_PS_PS256}, + //{"__builtin_ia32_psrad", &&IX86_BUILTIN_PSRAD}, + //{"__builtin_ia32_psrad128", &&IX86_BUILTIN_PSRAD128}, + //{"__builtin_ia32_psradi", &&IX86_BUILTIN_PSRADI}, + //{"__builtin_ia32_psradi128", &&IX86_BUILTIN_PSRADI128}, + //{"__builtin_ia32_psraw", &&IX86_BUILTIN_PSRAW}, + //{"__builtin_ia32_psraw128", &&IX86_BUILTIN_PSRAW128}, + //{"__builtin_ia32_psrawi", &&IX86_BUILTIN_PSRAWI}, + //{"__builtin_ia32_psrawi128", &&IX86_BUILTIN_PSRAWI128}, + //{"__builtin_ia32_psrld", &&IX86_BUILTIN_PSRLD}, + //{"__builtin_ia32_psrld128", &&IX86_BUILTIN_PSRLD128}, + //{"__builtin_ia32_psrldi", &&IX86_BUILTIN_PSRLDI}, + //{"__builtin_ia32_psrldi128", &&IX86_BUILTIN_PSRLDI128}, + //{"__builtin_ia32_psrldqi128", &&IX86_BUILTIN_PSRLDQI128}, + //{"__builtin_ia32_psrlq", &&IX86_BUILTIN_PSRLQ}, + //{"__builtin_ia32_psrlq128", &&IX86_BUILTIN_PSRLQ128}, + //{"__builtin_ia32_psrlqi", &&IX86_BUILTIN_PSRLQI}, + //{"__builtin_ia32_psrlqi128", &&IX86_BUILTIN_PSRLQI128}, + //{"__builtin_ia32_psrlw", &&IX86_BUILTIN_PSRLW}, + //{"__builtin_ia32_psrlw128", &&IX86_BUILTIN_PSRLW128}, + //{"__builtin_ia32_psrlwi", &&IX86_BUILTIN_PSRLWI}, + //{"__builtin_ia32_psrlwi128", &&IX86_BUILTIN_PSRLWI128}, {"__builtin_ia32_psubb", &&IX86_BUILTIN_PSUBB}, {"__builtin_ia32_psubb128", &&IX86_BUILTIN_PSUBB128}, {"__builtin_ia32_psubd", &&IX86_BUILTIN_PSUBD}, {"__builtin_ia32_psubd128", &&IX86_BUILTIN_PSUBD128}, {"__builtin_ia32_psubq", &&IX86_BUILTIN_PSUBQ}, {"__builtin_ia32_psubq128", &&IX86_BUILTIN_PSUBQ128}, + //{"__builtin_ia32_psubsb", &&IX86_BUILTIN_PSUBSB}, + //{"__builtin_ia32_psubsb128", &&IX86_BUILTIN_PSUBSB128}, + //{"__builtin_ia32_psubsw", &&IX86_BUILTIN_PSUBSW}, + //{"__builtin_ia32_psubsw128", &&IX86_BUILTIN_PSUBSW128}, + //{"__builtin_ia32_psubusb", &&IX86_BUILTIN_PSUBUSB}, + //{"__builtin_ia32_psubusb128", &&IX86_BUILTIN_PSUBUSB128}, + //{"__builtin_ia32_psubusw", &&IX86_BUILTIN_PSUBUSW}, + //{"__builtin_ia32_psubusw128", &&IX86_BUILTIN_PSUBUSW128}, {"__builtin_ia32_psubw", &&IX86_BUILTIN_PSUBW}, {"__builtin_ia32_psubw128", &&IX86_BUILTIN_PSUBW128}, + //{"__builtin_ia32_pswapdsf", &&IX86_BUILTIN_PSWAPDSF}, + //{"__builtin_ia32_pswapdsi", &&IX86_BUILTIN_PSWAPDSI}, + //{"__builtin_ia32_ptestc128", &&IX86_BUILTIN_PTESTC}, + //{"__builtin_ia32_ptestc256", &&IX86_BUILTIN_PTESTC256}, + //{"__builtin_ia32_ptestnzc128", &&IX86_BUILTIN_PTESTNZC}, + //{"__builtin_ia32_ptestnzc256", &&IX86_BUILTIN_PTESTNZC256}, + //{"__builtin_ia32_ptestz128", &&IX86_BUILTIN_PTESTZ}, + //{"__builtin_ia32_ptestz256", &&IX86_BUILTIN_PTESTZ256}, {"__builtin_ia32_punpckhbw", &&IX86_BUILTIN_PUNPCKHBW}, {"__builtin_ia32_punpckhbw128", &&IX86_BUILTIN_PUNPCKHBW128}, {"__builtin_ia32_punpckhdq", &&IX86_BUILTIN_PUNPCKHDQ}, @@ -211,31 +566,83 @@ {"__builtin_ia32_punpcklwd128", &&IX86_BUILTIN_PUNPCKLWD128}, {"__builtin_ia32_pxor", &&IX86_BUILTIN_PXOR}, {"__builtin_ia32_pxor128", &&IX86_BUILTIN_PXOR128}, + //{"__builtin_ia32_rcpps", &&IX86_BUILTIN_RCPPS}, + //{"__builtin_ia32_rcpps256", &&IX86_BUILTIN_RCPPS256}, + //{"__builtin_ia32_rcpss", &&IX86_BUILTIN_RCPSS}, + //{"__builtin_ia32_rdpmc", &&IX86_BUILTIN_RDPMC}, + //{"__builtin_ia32_rdtsc", &&IX86_BUILTIN_RDTSC}, + //{"__builtin_ia32_rdtscp", &&IX86_BUILTIN_RDTSCP}, + //{"__builtin_ia32_rolhi", &&IX86_BUILTIN_ROLHI}, + //{"__builtin_ia32_rolqi", &&IX86_BUILTIN_ROLQI}, + //{"__builtin_ia32_rorhi", &&IX86_BUILTIN_RORHI}, + //{"__builtin_ia32_rorqi", &&IX86_BUILTIN_RORQI}, + //{"__builtin_ia32_roundpd", &&IX86_BUILTIN_ROUNDPD}, + //{"__builtin_ia32_roundpd256", &&IX86_BUILTIN_ROUNDPD256}, + //{"__builtin_ia32_roundps", &&IX86_BUILTIN_ROUNDPS}, + //{"__builtin_ia32_roundps256", &&IX86_BUILTIN_ROUNDPS256}, + //{"__builtin_ia32_roundsd", &&IX86_BUILTIN_ROUNDSD}, + //{"__builtin_ia32_roundss", &&IX86_BUILTIN_ROUNDSS}, + //{"__builtin_ia32_rsqrtf", &&IX86_BUILTIN_RSQRTF}, + //{"__builtin_ia32_rsqrtps", &&IX86_BUILTIN_RSQRTPS}, + //{"__builtin_ia32_rsqrtps256", &&IX86_BUILTIN_RSQRTPS256}, + //{"__builtin_ia32_rsqrtps_nr", &&IX86_BUILTIN_RSQRTPS_NR}, + //{"__builtin_ia32_rsqrtps_nr256", &&IX86_BUILTIN_RSQRTPS_NR256}, + //{"__builtin_ia32_rsqrtss", &&IX86_BUILTIN_RSQRTSS}, + //{"__builtin_ia32_sfence", &&IX86_BUILTIN_SFENCE}, {"__builtin_ia32_shufpd", &&IX86_BUILTIN_SHUFPD}, - {"__builtin_ia32_shufpd256", &&IX86_BUILTIN_SHUFPD}, + //{"__builtin_ia32_shufpd256", &&IX86_BUILTIN_SHUFPD256}, {"__builtin_ia32_shufps", &&IX86_BUILTIN_SHUFPS}, - {"__builtin_ia32_shufps256", &&IX86_BUILTIN_SHUFPS}, + //{"__builtin_ia32_shufps256", &&IX86_BUILTIN_SHUFPS256}, + //{"__builtin_ia32_si256_si", &&IX86_BUILTIN_SI256_SI}, + //{"__builtin_ia32_si_si256", &&IX86_BUILTIN_SI_SI256}, + //{"__builtin_ia32_sqrtpd", &&IX86_BUILTIN_SQRTPD}, + //{"__builtin_ia32_sqrtpd256", &&IX86_BUILTIN_SQRTPD256}, + //{"__builtin_ia32_sqrtps", &&IX86_BUILTIN_SQRTPS}, + //{"__builtin_ia32_sqrtps256", &&IX86_BUILTIN_SQRTPS256}, + //{"__builtin_ia32_sqrtps_nr", &&IX86_BUILTIN_SQRTPS_NR}, + //{"__builtin_ia32_sqrtps_nr256", &&IX86_BUILTIN_SQRTPS_NR256}, + //{"__builtin_ia32_sqrtsd", &&IX86_BUILTIN_SQRTSD}, + //{"__builtin_ia32_sqrtss", &&IX86_BUILTIN_SQRTSS}, {"__builtin_ia32_stmxcsr", &&IX86_BUILTIN_STMXCSR}, {"__builtin_ia32_storedqu", &&IX86_BUILTIN_STOREDQU}, - {"__builtin_ia32_storedqu256", &&IX86_BUILTIN_STOREDQU}, + //{"__builtin_ia32_storedqu256", &&IX86_BUILTIN_STOREDQU256}, {"__builtin_ia32_storehps", &&IX86_BUILTIN_STOREHPS}, {"__builtin_ia32_storelps", &&IX86_BUILTIN_STORELPS}, {"__builtin_ia32_storeupd", &&IX86_BUILTIN_STOREUPD}, - {"__builtin_ia32_storeupd256", &&IX86_BUILTIN_STOREUPD}, + //{"__builtin_ia32_storeupd256", &&IX86_BUILTIN_STOREUPD256}, {"__builtin_ia32_storeups", &&IX86_BUILTIN_STOREUPS}, - {"__builtin_ia32_storeups256", &&IX86_BUILTIN_STOREUPS}, + //{"__builtin_ia32_storeups256", &&IX86_BUILTIN_STOREUPS256}, {"__builtin_ia32_subpd", &&IX86_BUILTIN_SUBPD}, - {"__builtin_ia32_subpd256", &&IX86_BUILTIN_SUBPD}, + //{"__builtin_ia32_subpd256", &&IX86_BUILTIN_SUBPD256}, {"__builtin_ia32_subps", &&IX86_BUILTIN_SUBPS}, - {"__builtin_ia32_subps256", &&IX86_BUILTIN_SUBPS}, + //{"__builtin_ia32_subps256", &&IX86_BUILTIN_SUBPS256}, + //{"__builtin_ia32_subsd", &&IX86_BUILTIN_SUBSD}, + //{"__builtin_ia32_subss", &&IX86_BUILTIN_SUBSS}, + //{"__builtin_ia32_ucomieq", &&IX86_BUILTIN_UCOMIEQSS}, + //{"__builtin_ia32_ucomige", &&IX86_BUILTIN_UCOMIGESS}, + //{"__builtin_ia32_ucomigt", &&IX86_BUILTIN_UCOMIGTSS}, + //{"__builtin_ia32_ucomile", &&IX86_BUILTIN_UCOMILESS}, + //{"__builtin_ia32_ucomilt", &&IX86_BUILTIN_UCOMILTSS}, + //{"__builtin_ia32_ucomineq", &&IX86_BUILTIN_UCOMINEQSS}, + //{"__builtin_ia32_ucomisdeq", &&IX86_BUILTIN_UCOMIEQSD}, + //{"__builtin_ia32_ucomisdge", &&IX86_BUILTIN_UCOMIGESD}, + //{"__builtin_ia32_ucomisdgt", &&IX86_BUILTIN_UCOMIGTSD}, + //{"__builtin_ia32_ucomisdle", &&IX86_BUILTIN_UCOMILESD}, + //{"__builtin_ia32_ucomisdlt", &&IX86_BUILTIN_UCOMILTSD}, + //{"__builtin_ia32_ucomisdneq", &&IX86_BUILTIN_UCOMINEQSD}, {"__builtin_ia32_unpckhpd", &&IX86_BUILTIN_UNPCKHPD}, - {"__builtin_ia32_unpckhpd256", &&IX86_BUILTIN_UNPCKHPD}, + //{"__builtin_ia32_unpckhpd256", &&IX86_BUILTIN_UNPCKHPD256}, {"__builtin_ia32_unpckhps", &&IX86_BUILTIN_UNPCKHPS}, - {"__builtin_ia32_unpckhps256", &&IX86_BUILTIN_UNPCKHPS}, + //{"__builtin_ia32_unpckhps256", &&IX86_BUILTIN_UNPCKHPS256}, {"__builtin_ia32_unpcklpd", &&IX86_BUILTIN_UNPCKLPD}, - {"__builtin_ia32_unpcklpd256", &&IX86_BUILTIN_UNPCKLPD}, + //{"__builtin_ia32_unpcklpd256", &&IX86_BUILTIN_UNPCKLPD256}, {"__builtin_ia32_unpcklps", &&IX86_BUILTIN_UNPCKLPS}, - {"__builtin_ia32_unpcklps256", &&IX86_BUILTIN_UNPCKLPS}, + //{"__builtin_ia32_unpcklps256", &&IX86_BUILTIN_UNPCKLPS256}, + //{"__builtin_ia32_vbroadcastf128_pd256", &&IX86_BUILTIN_VBROADCASTPD256}, + //{"__builtin_ia32_vbroadcastf128_ps256", &&IX86_BUILTIN_VBROADCASTPS256}, + //{"__builtin_ia32_vbroadcastsd256", &&IX86_BUILTIN_VBROADCASTSD256}, + //{"__builtin_ia32_vbroadcastss", &&IX86_BUILTIN_VBROADCASTSS}, + //{"__builtin_ia32_vbroadcastss256", &&IX86_BUILTIN_VBROADCASTSS256}, {"__builtin_ia32_vec_ext_v16qi", &&IX86_BUILTIN_VEC_EXT_V16QI}, {"__builtin_ia32_vec_ext_v2df", &&IX86_BUILTIN_VEC_EXT_V2DF}, {"__builtin_ia32_vec_ext_v2di", &&IX86_BUILTIN_VEC_EXT_V2DI}, @@ -247,15 +654,79 @@ {"__builtin_ia32_vec_init_v2si", &&IX86_BUILTIN_VEC_INIT_V2SI}, {"__builtin_ia32_vec_init_v4hi", &&IX86_BUILTIN_VEC_INIT_V4HI}, {"__builtin_ia32_vec_init_v8qi", &&IX86_BUILTIN_VEC_INIT_V8QI}, + //{"__builtin_ia32_vec_pack_sfix", &&IX86_BUILTIN_VEC_PACK_SFIX}, {"__builtin_ia32_vec_set_v16qi", &&IX86_BUILTIN_VEC_SET_V16QI}, {"__builtin_ia32_vec_set_v2di", &&IX86_BUILTIN_VEC_SET_V2DI}, {"__builtin_ia32_vec_set_v4hi", &&IX86_BUILTIN_VEC_SET_V4HI}, + //{"__builtin_ia32_vec_set_v4sf", &&IX86_BUILTIN_VEC_SET_V4SF}, {"__builtin_ia32_vec_set_v4si", &&IX86_BUILTIN_VEC_SET_V4SI}, {"__builtin_ia32_vec_set_v8hi", &&IX86_BUILTIN_VEC_SET_V8HI}, + //{"__builtin_ia32_vextractf128_pd256", &&IX86_BUILTIN_EXTRACTF128PD256}, + //{"__builtin_ia32_vextractf128_ps256", &&IX86_BUILTIN_EXTRACTF128PS256}, + //{"__builtin_ia32_vextractf128_si256", &&IX86_BUILTIN_EXTRACTF128SI256}, + //{"__builtin_ia32_vfmaddpd", &&IX86_BUILTIN_VFMADDPD}, + //{"__builtin_ia32_vfmaddpd256", &&IX86_BUILTIN_VFMADDPD256}, + //{"__builtin_ia32_vfmaddps", &&IX86_BUILTIN_VFMADDPS}, + //{"__builtin_ia32_vfmaddps256", &&IX86_BUILTIN_VFMADDPS256}, + //{"__builtin_ia32_vfmaddsd", &&IX86_BUILTIN_VFMADDSD}, + //{"__builtin_ia32_vfmaddss", &&IX86_BUILTIN_VFMADDSS}, + //{"__builtin_ia32_vfmaddsubpd", &&IX86_BUILTIN_VFMADDSUBPD}, + //{"__builtin_ia32_vfmaddsubpd256", &&IX86_BUILTIN_VFMADDSUBPD256}, + //{"__builtin_ia32_vfmaddsubps", &&IX86_BUILTIN_VFMADDSUBPS}, + //{"__builtin_ia32_vfmaddsubps256", &&IX86_BUILTIN_VFMADDSUBPS256}, + //{"__builtin_ia32_vfmsubaddpd", &&IX86_BUILTIN_VFMSUBADDPD}, + //{"__builtin_ia32_vfmsubaddpd256", &&IX86_BUILTIN_VFMSUBADDPD256}, + //{"__builtin_ia32_vfmsubaddps", &&IX86_BUILTIN_VFMSUBADDPS}, + //{"__builtin_ia32_vfmsubaddps256", &&IX86_BUILTIN_VFMSUBADDPS256}, + //{"__builtin_ia32_vfmsubpd", &&IX86_BUILTIN_VFMSUBPD}, + //{"__builtin_ia32_vfmsubpd256", &&IX86_BUILTIN_VFMSUBPD256}, + //{"__builtin_ia32_vfmsubps", &&IX86_BUILTIN_VFMSUBPS}, + //{"__builtin_ia32_vfmsubps256", &&IX86_BUILTIN_VFMSUBPS256}, + //{"__builtin_ia32_vfmsubsd", &&IX86_BUILTIN_VFMSUBSD}, + //{"__builtin_ia32_vfmsubss", &&IX86_BUILTIN_VFMSUBSS}, + //{"__builtin_ia32_vfnmaddpd", &&IX86_BUILTIN_VFNMADDPD}, + //{"__builtin_ia32_vfnmaddpd256", &&IX86_BUILTIN_VFNMADDPD256}, + //{"__builtin_ia32_vfnmaddps", &&IX86_BUILTIN_VFNMADDPS}, + //{"__builtin_ia32_vfnmaddps256", &&IX86_BUILTIN_VFNMADDPS256}, + //{"__builtin_ia32_vfnmaddsd", &&IX86_BUILTIN_VFNMADDSD}, + //{"__builtin_ia32_vfnmaddss", &&IX86_BUILTIN_VFNMADDSS}, + //{"__builtin_ia32_vfnmsubpd", &&IX86_BUILTIN_VFNMSUBPD}, + //{"__builtin_ia32_vfnmsubpd256", &&IX86_BUILTIN_VFNMSUBPD256}, + //{"__builtin_ia32_vfnmsubps", &&IX86_BUILTIN_VFNMSUBPS}, + //{"__builtin_ia32_vfnmsubps256", &&IX86_BUILTIN_VFNMSUBPS256}, + //{"__builtin_ia32_vfnmsubsd", &&IX86_BUILTIN_VFNMSUBSD}, + //{"__builtin_ia32_vfnmsubss", &&IX86_BUILTIN_VFNMSUBSS}, + //{"__builtin_ia32_vinsertf128_pd256", &&IX86_BUILTIN_VINSERTF128PD256}, + //{"__builtin_ia32_vinsertf128_ps256", &&IX86_BUILTIN_VINSERTF128PS256}, + //{"__builtin_ia32_vinsertf128_si256", &&IX86_BUILTIN_VINSERTF128SI256}, + //{"__builtin_ia32_vperm2f128_pd256", &&IX86_BUILTIN_VPERM2F128PD256}, + //{"__builtin_ia32_vperm2f128_ps256", &&IX86_BUILTIN_VPERM2F128PS256}, + //{"__builtin_ia32_vperm2f128_si256", &&IX86_BUILTIN_VPERM2F128SI256}, + //{"__builtin_ia32_vpermilpd", &&IX86_BUILTIN_VPERMILPD}, + //{"__builtin_ia32_vpermilpd256", &&IX86_BUILTIN_VPERMILPD256}, + //{"__builtin_ia32_vpermilps", &&IX86_BUILTIN_VPERMILPS}, + //{"__builtin_ia32_vpermilps256", &&IX86_BUILTIN_VPERMILPS256}, + //{"__builtin_ia32_vpermilvarpd", &&IX86_BUILTIN_VPERMILVARPD}, + //{"__builtin_ia32_vpermilvarpd256", &&IX86_BUILTIN_VPERMILVARPD256}, + //{"__builtin_ia32_vpermilvarps", &&IX86_BUILTIN_VPERMILVARPS}, + //{"__builtin_ia32_vpermilvarps256", &&IX86_BUILTIN_VPERMILVARPS256}, + //{"__builtin_ia32_vtestcpd", &&IX86_BUILTIN_VTESTCPD}, + //{"__builtin_ia32_vtestcpd256", &&IX86_BUILTIN_VTESTCPD256}, + //{"__builtin_ia32_vtestcps", &&IX86_BUILTIN_VTESTCPS}, + //{"__builtin_ia32_vtestcps256", &&IX86_BUILTIN_VTESTCPS256}, + //{"__builtin_ia32_vtestnzcpd", &&IX86_BUILTIN_VTESTNZCPD}, + //{"__builtin_ia32_vtestnzcpd256", &&IX86_BUILTIN_VTESTNZCPD256}, + //{"__builtin_ia32_vtestnzcps", &&IX86_BUILTIN_VTESTNZCPS}, + //{"__builtin_ia32_vtestnzcps256", &&IX86_BUILTIN_VTESTNZCPS256}, + //{"__builtin_ia32_vtestzpd", &&IX86_BUILTIN_VTESTZPD}, + //{"__builtin_ia32_vtestzpd256", &&IX86_BUILTIN_VTESTZPD256}, + //{"__builtin_ia32_vtestzps", &&IX86_BUILTIN_VTESTZPS}, + //{"__builtin_ia32_vtestzps256", &&IX86_BUILTIN_VTESTZPS256}, + //{"__builtin_ia32_vzeroall", &&IX86_BUILTIN_VZEROALL}, {"__builtin_ia32_xorpd", &&IX86_BUILTIN_XORPD}, - {"__builtin_ia32_xorpd256", &&IX86_BUILTIN_XORPD}, + //{"__builtin_ia32_xorpd256", &&IX86_BUILTIN_XORPD256}, {"__builtin_ia32_xorps", &&IX86_BUILTIN_XORPS}, - {"__builtin_ia32_xorps256", &&IX86_BUILTIN_XORPS} + //{"__builtin_ia32_xorps256", &&IX86_BUILTIN_XORPS256}, }; static std::vector FunctionCodeCache; @@ -500,17 +971,17 @@ Result = BuildVectorShuffle(Result, Ops[0], 4, 5, 2, 3); return true; } - IX86_BUILTIN_LOADQ: { - const PointerType *i64Ptr = Type::getInt64PtrTy(Context); - Ops[0] = Builder.CreateBitCast(Ops[0], i64Ptr); - Ops[0] = Builder.CreateLoad(Ops[0]); - Value *Zero = ConstantInt::get(Type::getInt64Ty(Context), 0); - Result = BuildVector(Zero, Zero, NULL); - Value *Idx = ConstantInt::get(Type::getInt32Ty(Context), 0); - Result = Builder.CreateInsertElement(Result, Ops[0], Idx); - Result = Builder.CreateBitCast(Result, ResultType); - return true; - } +//TODO IX86_BUILTIN_LOADQ: { +//TODO const PointerType *i64Ptr = Type::getInt64PtrTy(Context); +//TODO Ops[0] = Builder.CreateBitCast(Ops[0], i64Ptr); +//TODO Ops[0] = Builder.CreateLoad(Ops[0]); +//TODO Value *Zero = ConstantInt::get(Type::getInt64Ty(Context), 0); +//TODO Result = BuildVector(Zero, Zero, NULL); +//TODO Value *Idx = ConstantInt::get(Type::getInt32Ty(Context), 0); +//TODO Result = Builder.CreateInsertElement(Result, Ops[0], Idx); +//TODO Result = Builder.CreateBitCast(Result, ResultType); +//TODO return true; +//TODO } IX86_BUILTIN_LOADUPS: { VectorType *v4f32 = VectorType::get(Type::getFloatTy(Context), 4); const PointerType *v4f32Ptr = v4f32->getPointerTo(); From grosbach at apple.com Mon Nov 2 10:47:33 2009 From: grosbach at apple.com (Jim Grosbach) Date: Mon, 02 Nov 2009 16:47:33 -0000 Subject: [llvm-commits] [test-suite] r85804 - /test-suite/trunk/Makefile.programs Message-ID: <200911021647.nA2GlX7H009663@zion.cs.uiuc.edu> Author: grosbach Date: Mon Nov 2 10:47:33 2009 New Revision: 85804 URL: http://llvm.org/viewvc/llvm-project?rev=85804&view=rev Log: ARM LLCBETA does not use NEON for scalar floating point. Modified: test-suite/trunk/Makefile.programs Modified: test-suite/trunk/Makefile.programs URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/Makefile.programs?rev=85804&r1=85803&r2=85804&view=diff ============================================================================== --- test-suite/trunk/Makefile.programs (original) +++ test-suite/trunk/Makefile.programs Mon Nov 2 10:47:33 2009 @@ -244,12 +244,12 @@ LLCBETAOPTION := -enable-sparc-v9-insts endif ifeq ($(ARCH),ARM) -LLCBETAOPTION := -arm-dynamic-stack-alignment +LLCBETAOPTION := -arm-use-neon-fp=0 #-combiner-alias-analysis #-schedule-livein-copies endif ifeq ($(ARCH),THUMB) -LLCBETAOPTION := -arm-dynamic-stack-alignment +LLCBETAOPTION := -arm-use-neon-fp=0 #-combiner-alias-analysis #-enable-thumb-reg-scavenging endif From bob.wilson at apple.com Mon Nov 2 10:58:32 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Mon, 02 Nov 2009 16:58:32 -0000 Subject: [llvm-commits] [llvm] r85805 - /llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Message-ID: <200911021658.nA2GwWdK010062@zion.cs.uiuc.edu> Author: bwilson Date: Mon Nov 2 10:58:31 2009 New Revision: 85805 URL: http://llvm.org/viewvc/llvm-project?rev=85805&view=rev Log: Prune unnecessary include. Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp?rev=85805&r1=85804&r2=85805&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Mon Nov 2 10:58:31 2009 @@ -13,7 +13,6 @@ #include "ARM.h" #include "ARMAddressingModes.h" -#include "ARMConstantPoolValue.h" #include "ARMISelLowering.h" #include "ARMTargetMachine.h" #include "llvm/CallingConv.h" From bob.wilson at apple.com Mon Nov 2 10:59:06 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Mon, 02 Nov 2009 16:59:06 -0000 Subject: [llvm-commits] [llvm] r85806 - in /llvm/trunk/lib/Target/ARM: ARMCodeEmitter.cpp ARMConstantPoolValue.cpp ARMConstantPoolValue.h AsmPrinter/ARMAsmPrinter.cpp Message-ID: <200911021659.nA2Gx7nO010095@zion.cs.uiuc.edu> Author: bwilson Date: Mon Nov 2 10:59:06 2009 New Revision: 85806 URL: http://llvm.org/viewvc/llvm-project?rev=85806&view=rev Log: Add support for BlockAddress values in ARM constant pools. Modified: llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp llvm/trunk/lib/Target/ARM/ARMConstantPoolValue.cpp llvm/trunk/lib/Target/ARM/ARMConstantPoolValue.h llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Modified: llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp?rev=85806&r1=85805&r2=85806&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp Mon Nov 2 10:59:06 2009 @@ -428,6 +428,7 @@ DEBUG(errs() << " ** ARM constant pool #" << CPI << " @ " << (void*)MCE.getCurrentPCValue() << " " << *ACPV << '\n'); + assert(ACPV->isGlobalValue() && "unsupported constant pool value"); GlobalValue *GV = ACPV->getGV(); if (GV) { Reloc::Model RelocM = TM.getRelocationModel(); Modified: llvm/trunk/lib/Target/ARM/ARMConstantPoolValue.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMConstantPoolValue.cpp?rev=85806&r1=85805&r2=85806&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMConstantPoolValue.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMConstantPoolValue.cpp Mon Nov 2 10:59:06 2009 @@ -13,19 +13,21 @@ #include "ARMConstantPoolValue.h" #include "llvm/ADT/FoldingSet.h" +#include "llvm/Constant.h" +#include "llvm/Constants.h" #include "llvm/GlobalValue.h" #include "llvm/Type.h" #include "llvm/Support/raw_ostream.h" #include using namespace llvm; -ARMConstantPoolValue::ARMConstantPoolValue(GlobalValue *gv, unsigned id, +ARMConstantPoolValue::ARMConstantPoolValue(Constant *cval, unsigned id, ARMCP::ARMCPKind K, unsigned char PCAdj, const char *Modif, bool AddCA) - : MachineConstantPoolValue((const Type*)gv->getType()), - GV(gv), S(NULL), LabelId(id), Kind(K), PCAdjust(PCAdj), + : MachineConstantPoolValue((const Type*)cval->getType()), + CVal(cval), S(NULL), LabelId(id), Kind(K), PCAdjust(PCAdj), Modifier(Modif), AddCurrentAddress(AddCA) {} ARMConstantPoolValue::ARMConstantPoolValue(LLVMContext &C, @@ -34,14 +36,22 @@ const char *Modif, bool AddCA) : MachineConstantPoolValue((const Type*)Type::getInt32Ty(C)), - GV(NULL), S(strdup(s)), LabelId(id), Kind(ARMCP::CPValue), PCAdjust(PCAdj), - Modifier(Modif), AddCurrentAddress(AddCA) {} + CVal(NULL), S(strdup(s)), LabelId(id), Kind(ARMCP::CPExtSymbol), + PCAdjust(PCAdj), Modifier(Modif), AddCurrentAddress(AddCA) {} ARMConstantPoolValue::ARMConstantPoolValue(GlobalValue *gv, const char *Modif) : MachineConstantPoolValue((const Type*)Type::getInt32Ty(gv->getContext())), - GV(gv), S(NULL), LabelId(0), Kind(ARMCP::CPValue), PCAdjust(0), + CVal(gv), S(NULL), LabelId(0), Kind(ARMCP::CPValue), PCAdjust(0), Modifier(Modif) {} +GlobalValue *ARMConstantPoolValue::getGV() const { + return dyn_cast_or_null(CVal); +} + +BlockAddress *ARMConstantPoolValue::getBlockAddress() const { + return dyn_cast_or_null(CVal); +} + int ARMConstantPoolValue::getExistingMachineCPValue(MachineConstantPool *CP, unsigned Alignment) { unsigned AlignMask = Alignment - 1; @@ -51,7 +61,7 @@ (Constants[i].getAlignment() & AlignMask) == 0) { ARMConstantPoolValue *CPV = (ARMConstantPoolValue *)Constants[i].Val.MachineCPVal; - if (CPV->GV == GV && + if (CPV->CVal == CVal && CPV->S == S && CPV->LabelId == LabelId && CPV->PCAdjust == PCAdjust) @@ -68,7 +78,7 @@ void ARMConstantPoolValue::AddSelectionDAGCSEId(FoldingSetNodeID &ID) { - ID.AddPointer(GV); + ID.AddPointer(CVal); ID.AddPointer(S); ID.AddInteger(LabelId); ID.AddInteger(PCAdjust); @@ -80,8 +90,8 @@ void ARMConstantPoolValue::print(raw_ostream &O) const { - if (GV) - O << GV->getName(); + if (CVal) + O << CVal->getName(); else O << S; if (Modifier) O << "(" << Modifier << ")"; Modified: llvm/trunk/lib/Target/ARM/ARMConstantPoolValue.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMConstantPoolValue.h?rev=85806&r1=85805&r2=85806&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMConstantPoolValue.h (original) +++ llvm/trunk/lib/Target/ARM/ARMConstantPoolValue.h Mon Nov 2 10:59:06 2009 @@ -18,31 +18,35 @@ namespace llvm { +class Constant; +class BlockAddress; class GlobalValue; class LLVMContext; namespace ARMCP { enum ARMCPKind { CPValue, + CPExtSymbol, + CPBlockAddress, CPLSDA }; } /// ARMConstantPoolValue - ARM specific constantpool value. This is used to /// represent PC relative displacement between the address of the load -/// instruction and the global value being loaded, i.e. (&GV-(LPIC+8)). +/// instruction and the constant being loaded, i.e. (&GV-(LPIC+8)). class ARMConstantPoolValue : public MachineConstantPoolValue { - GlobalValue *GV; // GlobalValue being loaded. + Constant *CVal; // Constant being loaded. const char *S; // ExtSymbol being loaded. unsigned LabelId; // Label id of the load. - ARMCP::ARMCPKind Kind; // Value or LSDA? + ARMCP::ARMCPKind Kind; // Kind of constant. unsigned char PCAdjust; // Extra adjustment if constantpool is pc relative. // 8 for ARM, 4 for Thumb. const char *Modifier; // GV modifier i.e. (&GV(modifier)-(LPIC+8)) bool AddCurrentAddress; public: - ARMConstantPoolValue(GlobalValue *gv, unsigned id, + ARMConstantPoolValue(Constant *cval, unsigned id, ARMCP::ARMCPKind Kind = ARMCP::CPValue, unsigned char PCAdj = 0, const char *Modifier = NULL, bool AddCurrentAddress = false); @@ -53,14 +57,17 @@ ARMConstantPoolValue(); ~ARMConstantPoolValue(); - - GlobalValue *getGV() const { return GV; } + GlobalValue *getGV() const; const char *getSymbol() const { return S; } + BlockAddress *getBlockAddress() const; const char *getModifier() const { return Modifier; } bool hasModifier() const { return Modifier != NULL; } bool mustAddCurrentAddress() const { return AddCurrentAddress; } unsigned getLabelId() const { return LabelId; } unsigned char getPCAdjustment() const { return PCAdjust; } + bool isGlobalValue() const { return Kind == ARMCP::CPValue; } + bool isExtSymbol() const { return Kind == ARMCP::CPExtSymbol; } + bool isBlockAddress() { return Kind == ARMCP::CPBlockAddress; } bool isLSDA() { return Kind == ARMCP::CPLSDA; } virtual unsigned getRelocationInfo() const { @@ -69,7 +76,6 @@ return 2; } - virtual int getExistingMachineCPValue(MachineConstantPool *CP, unsigned Alignment); 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=85806&r1=85805&r2=85806&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Mon Nov 2 10:59:06 2009 @@ -159,7 +159,6 @@ printDataDirective(MCPV->getType()); ARMConstantPoolValue *ACPV = static_cast(MCPV); - GlobalValue *GV = ACPV->getGV(); std::string Name; if (ACPV->isLSDA()) { @@ -167,7 +166,10 @@ raw_svector_ostream(LSDAName) << MAI->getPrivateGlobalPrefix() << "_LSDA_" << getFunctionNumber(); Name = LSDAName.str(); - } else if (GV) { + } else if (ACPV->isBlockAddress()) { + Name = GetBlockAddressSymbol(ACPV->getBlockAddress())->getName(); + } else if (ACPV->isGlobalValue()) { + GlobalValue *GV = ACPV->getGV(); bool isIndirect = Subtarget->isTargetDarwin() && Subtarget->GVIsIndirectSymbol(GV, TM.getRelocationModel()); if (!isIndirect) @@ -188,8 +190,10 @@ StubSym = OutContext.GetOrCreateSymbol(NameStr.str()); } } - } else + } else { + assert(ACPV->isExtSymbol() && "unrecognized constant pool value"); Name = Mang->makeNameProper(ACPV->getSymbol()); + } O << Name; if (ACPV->hasModifier()) O << "(" << ACPV->getModifier() << ")"; From grosbach at apple.com Mon Nov 2 10:59:18 2009 From: grosbach at apple.com (Jim Grosbach) Date: Mon, 2 Nov 2009 08:59:18 -0800 Subject: [llvm-commits] [llvm] r85787 - in /llvm/trunk: lib/Target/ARM/ARMBaseInstrInfo.cpp test/CodeGen/Thumb2/2009-11-01-CopyReg2RegBug.ll In-Reply-To: <200911020444.nA24iuOZ030845@zion.cs.uiuc.edu> References: <200911020444.nA24iuOZ030845@zion.cs.uiuc.edu> Message-ID: <63860812-1A15-4269-A0DE-2C6603627455@apple.com> Hi Evan, Looks good. Trivial comment tweak below. -Jim On Nov 1, 2009, at 8:44 PM, Evan Cheng wrote: > Author: evancheng > Date: Sun Nov 1 22:44:55 2009 > New Revision: 85787 > > URL: http://llvm.org/viewvc/llvm-project?rev=85787&view=rev > Log: > Unbreak ARMBaseRegisterInfo::copyRegToReg. > > Added: > llvm/trunk/test/CodeGen/Thumb2/2009-11-01-CopyReg2RegBug.ll > Modified: > llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp > > Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp?rev=85787&r1=85786&r2=85787&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp (original) > +++ llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp Sun Nov 1 > 22:44:55 2009 > @@ -660,26 +660,27 @@ > } else if (DestRC == ARM::DPRRegisterClass) { > const ARMBaseRegisterInfo* TRI = &getRegisterInfo(); > > + // If we do not found an instruction defining the reg, this > means the s/found/find > + // register should be live-in for this BB. It's always to > better to use > + // NEON reg-reg moves. > + unsigned Domain = ARMII::DomainNEON; > + > // Find the Machine Instruction which defines SrcReg. > - MachineBasicBlock::iterator J = (I == MBB.begin() ? I : prior > (I)); > - while (J != MBB.begin()) { > - if (J->modifiesRegister(SrcReg, TRI)) > - break; > - --J; > - } > + if (!MBB.empty()) { > + MachineBasicBlock::iterator J = (I == MBB.begin() ? I : prior > (I)); > + while (J != MBB.begin()) { > + if (J->modifiesRegister(SrcReg, TRI)) > + break; > + --J; > + } > > - unsigned Domain; > - if (J->modifiesRegister(SrcReg, TRI)) { > - Domain = J->getDesc().TSFlags & ARMII::DomainMask; > - // Instructions in general domain are subreg accesses. > - // Map them to NEON reg-reg moves. > - if (Domain == ARMII::DomainGeneral) > - Domain = ARMII::DomainNEON; > - } else { > - // We reached the beginning of the BB and found no > instruction defining > - // the reg. This means that register should be live-in for > this BB. > - // It's always to better to use NEON reg-reg moves. > - Domain = ARMII::DomainNEON; > + if (J->modifiesRegister(SrcReg, TRI)) { > + Domain = J->getDesc().TSFlags & ARMII::DomainMask; > + // Instructions in general domain are subreg accesses. > + // Map them to NEON reg-reg moves. > + if (Domain == ARMII::DomainGeneral) > + Domain = ARMII::DomainNEON; > + } > } > > if ((Domain & ARMII::DomainNEON) && getSubtarget().hasNEON()) { > > Added: llvm/trunk/test/CodeGen/Thumb2/2009-11-01-CopyReg2RegBug.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/2009-11-01-CopyReg2RegBug.ll?rev=85787&view=auto > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/test/CodeGen/Thumb2/2009-11-01-CopyReg2RegBug.ll > (added) > +++ llvm/trunk/test/CodeGen/Thumb2/2009-11-01-CopyReg2RegBug.ll Sun > Nov 1 22:44:55 2009 > @@ -0,0 +1,29 @@ > +; RUN: llc < %s -mtriple=thumbv7-apple-darwin -relocation-model=pic > -disable-fp-elim -mcpu=cortex-a8 > + > +define arm_apcscc void @get_initial_mb16x16_cost() nounwind { > +entry: > + br i1 undef, label %bb4, label %bb1 > + > +bb1: ; preds = %entry > + br label %bb7 > + > +bb4: ; preds = %entry > + br i1 undef, label %bb7.thread, label %bb5 > + > +bb5: ; preds = %bb4 > + br label %bb7 > + > +bb7.thread: ; preds = %bb4 > + br label %bb8 > + > +bb7: ; preds = %bb5, > %bb1 > + br i1 undef, label %bb8, label %bb10 > + > +bb8: ; preds = %bb7, > %bb7.thread > + %0 = phi double [ 5.120000e+02, %bb7.thread ], [ undef, %bb7 ] ; > [#uses=1] > + %1 = fdiv double %0, undef ; > [#uses=0] > + unreachable > + > +bb10: ; preds = %bb7 > + ret void > +} > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From david_goodwin at apple.com Mon Nov 2 11:06:28 2009 From: david_goodwin at apple.com (David Goodwin) Date: Mon, 02 Nov 2009 17:06:28 -0000 Subject: [llvm-commits] [llvm] r85807 - /llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp Message-ID: <200911021706.nA2H6SZm010309@zion.cs.uiuc.edu> Author: david_goodwin Date: Mon Nov 2 11:06:28 2009 New Revision: 85807 URL: http://llvm.org/viewvc/llvm-project?rev=85807&view=rev Log: Chain dependencies used to enforce memory order should have latency of 0 (except for true dependency of Store followed by aliased Load... we estimate that case with a single cycle of latency assuming the hardware will bypass) Modified: llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp Modified: llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp?rev=85807&r1=85806&r2=85807&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp (original) +++ llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp Mon Nov 2 11:06:28 2009 @@ -317,29 +317,35 @@ } // Add chain dependencies. + // Chain dependencies used to enforce memory order should have + // latency of 0 (except for true dependency of Store followed by + // aliased Load... we estimate that with a single cycle of latency + // assuming the hardware will bypass) // Note that isStoreToStackSlot and isLoadFromStackSLot are not usable // after stack slots are lowered to actual addresses. // TODO: Use an AliasAnalysis and do real alias-analysis queries, and // produce more precise dependence information. +#define STORE_LOAD_LATENCY 1 + unsigned TrueMemOrderLatency = 0; if (TID.isCall() || TID.hasUnmodeledSideEffects()) { new_chain: // This is the conservative case. Add dependencies on all memory // references. if (Chain) - Chain->addPred(SDep(SU, SDep::Order, SU->Latency)); + Chain->addPred(SDep(SU, SDep::Order, /*Latency=*/0)); Chain = SU; for (unsigned k = 0, m = PendingLoads.size(); k != m; ++k) - PendingLoads[k]->addPred(SDep(SU, SDep::Order, SU->Latency)); + PendingLoads[k]->addPred(SDep(SU, SDep::Order, TrueMemOrderLatency)); PendingLoads.clear(); for (std::map::iterator I = MemDefs.begin(), E = MemDefs.end(); I != E; ++I) { - I->second->addPred(SDep(SU, SDep::Order, SU->Latency)); + I->second->addPred(SDep(SU, SDep::Order, /*Latency=*/0)); I->second = SU; } for (std::map >::iterator I = MemUses.begin(), E = MemUses.end(); I != E; ++I) { for (unsigned i = 0, e = I->second.size(); i != e; ++i) - I->second[i]->addPred(SDep(SU, SDep::Order, SU->Latency)); + I->second[i]->addPred(SDep(SU, SDep::Order, TrueMemOrderLatency)); I->second.clear(); } // See if it is known to just have a single memory reference. @@ -356,12 +362,13 @@ // Unknown memory accesses. Assume the worst. ChainMMO = 0; } else if (TID.mayStore()) { + TrueMemOrderLatency = STORE_LOAD_LATENCY; if (const Value *V = getUnderlyingObjectForInstr(MI, MFI)) { // A store to a specific PseudoSourceValue. Add precise dependencies. // Handle the def in MemDefs, if there is one. std::map::iterator I = MemDefs.find(V); if (I != MemDefs.end()) { - I->second->addPred(SDep(SU, SDep::Order, SU->Latency, /*Reg=*/0, + I->second->addPred(SDep(SU, SDep::Order, /*Latency=*/0, /*Reg=*/0, /*isNormalMemory=*/true)); I->second = SU; } else { @@ -372,35 +379,37 @@ MemUses.find(V); if (J != MemUses.end()) { for (unsigned i = 0, e = J->second.size(); i != e; ++i) - J->second[i]->addPred(SDep(SU, SDep::Order, SU->Latency, /*Reg=*/0, - /*isNormalMemory=*/true)); + J->second[i]->addPred(SDep(SU, SDep::Order, TrueMemOrderLatency, + /*Reg=*/0, /*isNormalMemory=*/true)); J->second.clear(); } // Add dependencies from all the PendingLoads, since without // memoperands we must assume they alias anything. for (unsigned k = 0, m = PendingLoads.size(); k != m; ++k) - PendingLoads[k]->addPred(SDep(SU, SDep::Order, SU->Latency)); + PendingLoads[k]->addPred(SDep(SU, SDep::Order, TrueMemOrderLatency)); // Add a general dependence too, if needed. if (Chain) - Chain->addPred(SDep(SU, SDep::Order, SU->Latency)); - } else + Chain->addPred(SDep(SU, SDep::Order, /*Latency=*/0)); + } else { // Treat all other stores conservatively. goto new_chain; + } } else if (TID.mayLoad()) { + TrueMemOrderLatency = 0; if (MI->isInvariantLoad(AA)) { // Invariant load, no chain dependencies needed! } else if (const Value *V = getUnderlyingObjectForInstr(MI, MFI)) { // A load from a specific PseudoSourceValue. Add precise dependencies. std::map::iterator I = MemDefs.find(V); if (I != MemDefs.end()) - I->second->addPred(SDep(SU, SDep::Order, SU->Latency, /*Reg=*/0, + I->second->addPred(SDep(SU, SDep::Order, /*Latency=*/0, /*Reg=*/0, /*isNormalMemory=*/true)); MemUses[V].push_back(SU); // Add a general dependence too, if needed. if (Chain && (!ChainMMO || (ChainMMO->isStore() || ChainMMO->isVolatile()))) - Chain->addPred(SDep(SU, SDep::Order, SU->Latency)); + Chain->addPred(SDep(SU, SDep::Order, /*Latency=*/0)); } else if (MI->hasVolatileMemoryRef()) { // Treat volatile loads conservatively. Note that this includes // cases where memoperand information is unavailable. @@ -411,10 +420,10 @@ // we can't even assume that the load doesn't alias well-behaved // memory locations. if (Chain) - Chain->addPred(SDep(SU, SDep::Order, SU->Latency)); + Chain->addPred(SDep(SU, SDep::Order, /*Latency=*/0)); for (std::map::iterator I = MemDefs.begin(), E = MemDefs.end(); I != E; ++I) - I->second->addPred(SDep(SU, SDep::Order, SU->Latency)); + I->second->addPred(SDep(SU, SDep::Order, /*Latency=*/0)); PendingLoads.push_back(SU); } } From bob.wilson at apple.com Mon Nov 2 11:10:38 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Mon, 02 Nov 2009 17:10:38 -0000 Subject: [llvm-commits] [llvm] r85808 - /llvm/trunk/lib/Target/ARM/ARMConstantPoolValue.h Message-ID: <200911021710.nA2HAc12010447@zion.cs.uiuc.edu> Author: bwilson Date: Mon Nov 2 11:10:37 2009 New Revision: 85808 URL: http://llvm.org/viewvc/llvm-project?rev=85808&view=rev Log: Hyphenate some comments. Modified: llvm/trunk/lib/Target/ARM/ARMConstantPoolValue.h Modified: llvm/trunk/lib/Target/ARM/ARMConstantPoolValue.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMConstantPoolValue.h?rev=85808&r1=85807&r2=85808&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMConstantPoolValue.h (original) +++ llvm/trunk/lib/Target/ARM/ARMConstantPoolValue.h Mon Nov 2 11:10:37 2009 @@ -33,14 +33,14 @@ } /// ARMConstantPoolValue - ARM specific constantpool value. This is used to -/// represent PC relative displacement between the address of the load +/// represent PC-relative displacement between the address of the load /// instruction and the constant being loaded, i.e. (&GV-(LPIC+8)). class ARMConstantPoolValue : public MachineConstantPoolValue { Constant *CVal; // Constant being loaded. const char *S; // ExtSymbol being loaded. unsigned LabelId; // Label id of the load. ARMCP::ARMCPKind Kind; // Kind of constant. - unsigned char PCAdjust; // Extra adjustment if constantpool is pc relative. + unsigned char PCAdjust; // Extra adjustment if constantpool is pc-relative. // 8 for ARM, 4 for Thumb. const char *Modifier; // GV modifier i.e. (&GV(modifier)-(LPIC+8)) bool AddCurrentAddress; @@ -86,7 +86,6 @@ void dump() const; }; - inline raw_ostream &operator<<(raw_ostream &O, const ARMConstantPoolValue &V) { V.print(O); return O; From david_goodwin at apple.com Mon Nov 2 11:26:25 2009 From: david_goodwin at apple.com (David Goodwin) Date: Mon, 2 Nov 2009 09:26:25 -0800 Subject: [llvm-commits] [llvm] r85697 - in /llvm/trunk: lib/Target/ARM/ARMInstrNEON.td test/CodeGen/ARM/fmacs.ll test/CodeGen/ARM/fnmacs.ll test/CodeGen/Thumb2/cross-rc-coalescing-2.ll In-Reply-To: References: <200910312257.n9VMvbZm030355@zion.cs.uiuc.edu> Message-ID: The itineraries are much more expressive now. They can model arbitrary resource usage as well as operand use and def stages (see ARMScheduleV7.td... don't get me started on the cortex-a8 microarchitecture ;-). I've been comparing our cortex-a8 scheduling against shark and so far it is quite accurate. There is also a generic callback into the subtarget to let it adjust latency for cases that don't fit the model... though I haven't used that yet. I assume this is an important case that is not being handled correctly. Is there an example? David On Nov 1, 2009, at 10:31 AM, Evan Cheng wrote: > > On Nov 1, 2009, at 10:22 AM, Anton Korobeynikov wrote: > >> Hello, Evan >> >>> On the other hand, a vmla.32 followed by another vmla.32 is just >>> fine. And >>> it is faster than vmul + vadd. I agree we should try to solve it >>> better. >>> Perhaps expanding it before or during schedule2. >> Right, NEON scheduling is tricky, it seems that our instruction >> itineraries are not expressible enough for such complex pipelines. > > I think we should be able to handle at least the true dependency > cases. Instruction latency is a function of both defining > instruction and the use. cc'ing David for his comments. > > Evan > >> >> -- >> With best regards, Anton Korobeynikov >> Faculty of Mathematics and Mechanics, Saint Petersburg State >> University > From david_goodwin at apple.com Mon Nov 2 11:28:36 2009 From: david_goodwin at apple.com (David Goodwin) Date: Mon, 02 Nov 2009 17:28:36 -0000 Subject: [llvm-commits] [llvm] r85809 - in /llvm/trunk/lib/Target/ARM: ARMInstrInfo.td ARMInstrThumb2.td Message-ID: <200911021728.nA2HSa6Q011387@zion.cs.uiuc.edu> Author: david_goodwin Date: Mon Nov 2 11:28:36 2009 New Revision: 85809 URL: http://llvm.org/viewvc/llvm-project?rev=85809&view=rev Log: Fix schedule model for BFC. Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=85809&r1=85808&r2=85809&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Mon Nov 2 11:28:36 2009 @@ -1205,7 +1205,7 @@ BinOpFrag<(and node:$LHS, (not node:$RHS))>>; def BFC : I<(outs GPR:$dst), (ins GPR:$src, bf_inv_mask_imm:$imm), - AddrMode1, Size4Bytes, IndexModeNone, DPFrm, IIC_iALUi, + AddrMode1, Size4Bytes, IndexModeNone, DPFrm, IIC_iUNAsi, "bfc", "\t$dst, $imm", "$src = $dst", [(set GPR:$dst, (and GPR:$src, bf_inv_mask_imm:$imm))]>, Requires<[IsARM, HasV6T2]> { Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td?rev=85809&r1=85808&r2=85809&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Mon Nov 2 11:28:36 2009 @@ -787,7 +787,7 @@ let Constraints = "$src = $dst" in def t2BFC : T2I<(outs GPR:$dst), (ins GPR:$src, bf_inv_mask_imm:$imm), - IIC_iALUi, "bfc", "\t$dst, $imm", + IIC_iUNAsi, "bfc", "\t$dst, $imm", [(set GPR:$dst, (and GPR:$src, bf_inv_mask_imm:$imm))]>; def t2SBFX : T2I<(outs GPR:$dst), (ins GPR:$src, imm0_31:$lsb, imm0_31:$width), From sabre at nondot.org Mon Nov 2 12:22:51 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 02 Nov 2009 18:22:51 -0000 Subject: [llvm-commits] [llvm] r85810 - in /llvm/trunk: lib/Transforms/Scalar/SCCP.cpp test/Transforms/SCCP/2008-03-10-sret.ll test/Transforms/SCCP/ipsccp-basic.ll Message-ID: <200911021822.nA2IMp41013382@zion.cs.uiuc.edu> Author: lattner Date: Mon Nov 2 12:22:51 2009 New Revision: 85810 URL: http://llvm.org/viewvc/llvm-project?rev=85810&view=rev Log: disable IPSCCP support for multiple return values, it is buggy, so just disable it until I can fix it. Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp llvm/trunk/test/Transforms/SCCP/2008-03-10-sret.ll llvm/trunk/test/Transforms/SCCP/ipsccp-basic.ll Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCP.cpp?rev=85810&r1=85809&r2=85810&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SCCP.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Mon Nov 2 12:22:51 2009 @@ -1650,7 +1650,8 @@ // If this is a strong or ODR definition of this function, then we can // propagate information about its result into callsites of it. - if (!F->mayBeOverridden()) + if (!F->mayBeOverridden() && + !isa(F->getReturnType())) Solver.AddTrackedFunction(F); // If this function only has direct calls that we can see, we can track its Modified: llvm/trunk/test/Transforms/SCCP/2008-03-10-sret.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SCCP/2008-03-10-sret.ll?rev=85810&r1=85809&r2=85810&view=diff ============================================================================== --- llvm/trunk/test/Transforms/SCCP/2008-03-10-sret.ll (original) +++ llvm/trunk/test/Transforms/SCCP/2008-03-10-sret.ll Mon Nov 2 12:22:51 2009 @@ -4,6 +4,8 @@ ; RUN: grep {%mrv1 = insertvalue %T %mrv, i32 17, 1} %t ; RUN: grep {ret %T %mrv1} %t +; XFAIL: * + %T = type {i32,i32} define internal {i32, i32} @bar(i32 %A) { Modified: llvm/trunk/test/Transforms/SCCP/ipsccp-basic.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SCCP/ipsccp-basic.ll?rev=85810&r1=85809&r2=85810&view=diff ============================================================================== --- llvm/trunk/test/Transforms/SCCP/ipsccp-basic.ll (original) +++ llvm/trunk/test/Transforms/SCCP/ipsccp-basic.ll Mon Nov 2 12:22:51 2009 @@ -1,4 +1,5 @@ ; RUN: opt < %s -ipsccp -S | FileCheck %s +; XFAIL: * ;;======================== test1 From baldrick at free.fr Mon Nov 2 12:22:47 2009 From: baldrick at free.fr (Duncan Sands) Date: Mon, 02 Nov 2009 19:22:47 +0100 Subject: [llvm-commits] [llvm] r85368 - in /llvm/trunk/lib/AsmParser: LLLexer.cpp LLParser.cpp LLParser.h LLToken.h In-Reply-To: <200910280339.n9S3dOUJ029862@zion.cs.uiuc.edu> References: <200910280339.n9S3dOUJ029862@zion.cs.uiuc.edu> Message-ID: <4AEF2377.3090103@free.fr> Hi Chris, > + "cannot take address of numeric label after it the function is defined"); after it the -> after the Ciao, Duncan. From sabre at nondot.org Mon Nov 2 12:27:22 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 02 Nov 2009 18:27:22 -0000 Subject: [llvm-commits] [llvm] r85811 - in /llvm/trunk/test/Transforms/SCCP: 2008-03-10-sret.ll ipsccp-basic.ll Message-ID: <200911021827.nA2IRMUT013610@zion.cs.uiuc.edu> Author: lattner Date: Mon Nov 2 12:27:22 2009 New Revision: 85811 URL: http://llvm.org/viewvc/llvm-project?rev=85811&view=rev Log: merge 2008-03-10-sret.ll into ipsccp-basic.ll, and upgrade its syntax. Removed: llvm/trunk/test/Transforms/SCCP/2008-03-10-sret.ll Modified: llvm/trunk/test/Transforms/SCCP/ipsccp-basic.ll Removed: llvm/trunk/test/Transforms/SCCP/2008-03-10-sret.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SCCP/2008-03-10-sret.ll?rev=85810&view=auto ============================================================================== --- llvm/trunk/test/Transforms/SCCP/2008-03-10-sret.ll (original) +++ llvm/trunk/test/Transforms/SCCP/2008-03-10-sret.ll (removed) @@ -1,21 +0,0 @@ -; RUN: opt < %s -ipsccp -S > %t -; RUN: grep {ret i32 36} %t -; RUN: grep {%mrv = insertvalue %T undef, i32 18, 0} %t -; RUN: grep {%mrv1 = insertvalue %T %mrv, i32 17, 1} %t -; RUN: grep {ret %T %mrv1} %t - -; XFAIL: * - -%T = type {i32,i32} - -define internal {i32, i32} @bar(i32 %A) { - %X = add i32 1, %A - ret i32 %X, i32 %A -} - -define i32 @foo() { - %X = call {i32, i32} @bar(i32 17) - %Y = getresult {i32, i32} %X, 0 - %Z = add i32 %Y, %Y - ret i32 %Z -} Modified: llvm/trunk/test/Transforms/SCCP/ipsccp-basic.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SCCP/ipsccp-basic.ll?rev=85811&r1=85810&r2=85811&view=diff ============================================================================== --- llvm/trunk/test/Transforms/SCCP/ipsccp-basic.ll (original) +++ llvm/trunk/test/Transforms/SCCP/ipsccp-basic.ll Mon Nov 2 12:27:22 2009 @@ -149,3 +149,29 @@ ; CHECK: define i64 @test6b ; CHECK: ret i64 0 +;;======================== test7 + + +%T = type {i32,i32} + +define internal {i32, i32} @test7a(i32 %A) { + %X = add i32 1, %A + %mrv0 = insertvalue %T undef, i32 %X, 0 + %mrv1 = insertvalue %T %mrv0, i32 %A, 1 + ret %T %mrv1 +; CHECK: @test7a +; CHECK-NEXT: %mrv0 = insertvalue %T undef, i32 18, 0 +; CHECK-NEXT: %mrv1 = insertvalue %T %mrv0, i32 17, 1 +} + +define i32 @test7b() { + %X = call {i32, i32} @test7a(i32 17) + %Y = extractvalue {i32, i32} %X, 0 + %Z = add i32 %Y, %Y + ret i32 %Z +; CHECK: define i32 @test7b +; CHECK-NEXT: call %T @test7a(i32 17) +; CHECK-NEXT: ret i32 36 +} + + From sabre at nondot.org Mon Nov 2 12:28:46 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 02 Nov 2009 18:28:46 -0000 Subject: [llvm-commits] [llvm] r85812 - /llvm/trunk/lib/AsmParser/LLParser.cpp Message-ID: <200911021828.nA2ISkIV013702@zion.cs.uiuc.edu> Author: lattner Date: Mon Nov 2 12:28:45 2009 New Revision: 85812 URL: http://llvm.org/viewvc/llvm-project?rev=85812&view=rev Log: typo Modified: llvm/trunk/lib/AsmParser/LLParser.cpp Modified: llvm/trunk/lib/AsmParser/LLParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=85812&r1=85811&r2=85812&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLParser.cpp (original) +++ llvm/trunk/lib/AsmParser/LLParser.cpp Mon Nov 2 12:28:45 2009 @@ -130,7 +130,7 @@ Res = PFS->GetBB(Refs[i].first.UIntVal, Refs[i].first.Loc); } else if (Refs[i].first.Kind == ValID::t_LocalID) { return Error(Refs[i].first.Loc, - "cannot take address of numeric label after it the function is defined"); + "cannot take address of numeric label after the function is defined"); } else { Res = dyn_cast_or_null( TheFn->getValueSymbolTable().lookup(Refs[i].first.StrVal)); From mrs at apple.com Mon Nov 2 12:39:12 2009 From: mrs at apple.com (Mike Stump) Date: Mon, 2 Nov 2009 10:39:12 -0800 Subject: [llvm-commits] [llvm-gcc-4.2] r85649 - /llvm-gcc-4.2/trunk/gcc/cp/decl.c In-Reply-To: <4AEDF65C.9000308@mxc.ca> References: <200910310927.n9V9R6bi001921@zion.cs.uiuc.edu> <4AED5991.4050202@free.fr> <4AEDF65C.9000308@mxc.ca> Message-ID: On Nov 1, 2009, at 12:58 PM, Nick Lewycky wrote: > The other thing is that not all GCC thunks can be lowered to LLVM > aliases. See PR2861 for the case that hit me. I'm waiting to see what > happens when clang needs to codegen the same thing :) I think I'll be starting in on thunk codegen for clang next... I don't see how aliases could be used; thunks require extra code, and I didn't see any provision for extra code for aliases. From vhernandez at apple.com Mon Nov 2 12:51:29 2009 From: vhernandez at apple.com (Victor Hernandez) Date: Mon, 02 Nov 2009 18:51:29 -0000 Subject: [llvm-commits] [llvm] r85814 - /llvm/trunk/lib/Analysis/MemoryBuiltins.cpp Message-ID: <200911021851.nA2IpTYX014735@zion.cs.uiuc.edu> Author: hernande Date: Mon Nov 2 12:51:28 2009 New Revision: 85814 URL: http://llvm.org/viewvc/llvm-project?rev=85814&view=rev Log: Set bit instead of calling pow() to compute 2 << n Modified: llvm/trunk/lib/Analysis/MemoryBuiltins.cpp Modified: llvm/trunk/lib/Analysis/MemoryBuiltins.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryBuiltins.cpp?rev=85814&r1=85813&r2=85814&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/MemoryBuiltins.cpp (original) +++ llvm/trunk/lib/Analysis/MemoryBuiltins.cpp Mon Nov 2 12:51:28 2009 @@ -16,6 +16,7 @@ #include "llvm/Constants.h" #include "llvm/Instructions.h" #include "llvm/Module.h" +#include "llvm/ADT/APInt.h" #include "llvm/Analysis/ConstantFolding.h" using namespace llvm; @@ -156,15 +157,22 @@ return Op1; } if (Opcode == Instruction::Shl) { - ConstantInt* Op1Int = dyn_cast(Op1); - if (!Op1Int) return NULL; - Value* Op1Pow = ConstantInt::get(Op1->getType(), (uint64_t) - pow(2.0, (double) Op1Int->getZExtValue())); + ConstantInt* Op1CI = dyn_cast(Op1); + if (!Op1CI) return NULL; + + APInt Op1Int = Op1CI->getValue(); + unsigned Op1Width = Op1Int.getBitWidth(); + // check for overflow + if (Op1Int.getActiveBits() > 64 || Op1Int.getZExtValue() > Op1Width) + return NULL; + Value* Op1Pow = ConstantInt::get(Context, + APInt(Op1Width, 0).set(Op1Int.getZExtValue())); + if (Op0 == ElementSize || (FoldedElementSize && Op0 == FoldedElementSize)) // ArraySize << log2(ElementSize) return Op1Pow; if (Op1Pow == ElementSize || - (FoldedElementSize && Op1Pow == FoldedElementSize)) + (FoldedElementSize && Op1Pow == FoldedElementSize)) // ElementSize << log2(ArraySize) return Op0; } From vhernandez at apple.com Mon Nov 2 12:52:12 2009 From: vhernandez at apple.com (Victor Hernandez) Date: Mon, 2 Nov 2009 10:52:12 -0800 Subject: [llvm-commits] [llvm] r85478 - /llvm/trunk/lib/Analysis/MemoryBuiltins.cpp In-Reply-To: <4AEA9CC9.3080305@free.fr> References: <200910290343.n9T3hBGO002753@zion.cs.uiuc.edu> <4AE951BB.2000105@free.fr> <4AEA9CC9.3080305@free.fr> Message-ID: <4ECCC52D-2654-4F03-81B5-075C727ABA9F@apple.com> Duncan, Thanks for the feedback. I just committed the pow removal. Victor On Oct 30, 2009, at 12:59 AM, Duncan Sands wrote: > Hi Victor, > >> + unsigned Op1BitWidth = Op1->getType()->getPrimitiveSizeInBits >> (); > > you could also get the constant int as an APInt and use the > getBitWidth > method. > >> + // check for overflow >> + if (Op1Int->getZExtValue() > Op1BitWidth) >> + return NULL; > > This will cause an assertion failure if Op1Int's value does not fit > in 64 bits. > >> + >> + Value* Op1Pow = ConstantInt::get(Context, >> + APInt(Op1BitWidth, 1, false) << Op1Int- >> >getValue()); > > The APInt class has a "set" method that allows you to set a > particular bit. I think that would be better. > > Ciao, > > Duncan. From ofv at wanadoo.es Mon Nov 2 13:11:03 2009 From: ofv at wanadoo.es (Oscar Fuentes) Date: Mon, 02 Nov 2009 19:11:03 -0000 Subject: [llvm-commits] [llvm] r85817 - /llvm/trunk/cmake/modules/LLVMProcessSources.cmake Message-ID: <200911021911.nA2JB38U015629@zion.cs.uiuc.edu> Author: ofv Date: Mon Nov 2 13:11:03 2009 New Revision: 85817 URL: http://llvm.org/viewvc/llvm-project?rev=85817&view=rev Log: CMake: Report an error if there is an unknown .cpp file in a source directory. This is useful in case someone who works with the config&make build system forgot to add a file to its CMakeLists.txt. Instead of obtaining undefined references at link time, cmake will complain at configure time on the first build after a svn update. Modified: llvm/trunk/cmake/modules/LLVMProcessSources.cmake Modified: llvm/trunk/cmake/modules/LLVMProcessSources.cmake URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/LLVMProcessSources.cmake?rev=85817&r1=85816&r2=85817&view=diff ============================================================================== --- llvm/trunk/cmake/modules/LLVMProcessSources.cmake (original) +++ llvm/trunk/cmake/modules/LLVMProcessSources.cmake Mon Nov 2 13:11:03 2009 @@ -22,6 +22,7 @@ function(llvm_process_sources OUT_VAR) set( sources ${ARGN} ) + llvm_check_source_file_list( ${sources} ) # Create file dependencies on the tablegenned files, if any. Seems # that this is not strictly needed, as dependencies of the .cpp # sources on the tablegenned .inc files are detected and handled, @@ -37,3 +38,17 @@ endif() set( ${OUT_VAR} ${sources} PARENT_SCOPE ) endfunction(llvm_process_sources) + + +function(llvm_check_source_file_list) + set(listed ${ARGN}) + file(GLOB globbed *.cpp) + foreach(g ${globbed}) + get_filename_component(fn ${g} NAME) + list(FIND listed ${fn} idx) + if( idx LESS 0 ) + message(SEND_ERROR "Found unknown source file ${g} +Please update ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt\n") + endif() + endforeach() +endfunction(llvm_check_source_file_list) From kennethuil at gmail.com Mon Nov 2 13:13:34 2009 From: kennethuil at gmail.com (Kenneth Uildriks) Date: Mon, 2 Nov 2009 13:13:34 -0600 Subject: [llvm-commits] [PATCH] Make opt default to not adding a target data string, and update tests Message-ID: <400d33ea0911021113h7385041fo34c1fafd3ca38b19@mail.gmail.com> All tests in the test directory that depend on target data now explicitly include the target data in the input assembly. This makes it safe for opt to not add target data whenever it's not supplied by either the module or the command line, which in turn stops opt from breaking valid code with bogus target data assumptions. -------------- next part -------------- A non-text attachment was scrubbed... Name: tests-opt.patch Type: application/octet-stream Size: 36041 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091102/82f5ceec/attachment.obj From sabre at nondot.org Mon Nov 2 13:31:11 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 02 Nov 2009 19:31:11 -0000 Subject: [llvm-commits] [llvm] r85818 - in /llvm/trunk: include/llvm/Support/StandardPasses.h lib/Transforms/Scalar/SCCP.cpp Message-ID: <200911021931.nA2JVB3a016469@zion.cs.uiuc.edu> Author: lattner Date: Mon Nov 2 13:31:10 2009 New Revision: 85818 URL: http://llvm.org/viewvc/llvm-project?rev=85818&view=rev Log: revert r8579[56], which are causing unhappiness in buildbot land. Modified: llvm/trunk/include/llvm/Support/StandardPasses.h llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Modified: llvm/trunk/include/llvm/Support/StandardPasses.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/StandardPasses.h?rev=85818&r1=85817&r2=85818&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/StandardPasses.h (original) +++ llvm/trunk/include/llvm/Support/StandardPasses.h Mon Nov 2 13:31:10 2009 @@ -99,6 +99,7 @@ if (UnitAtATime) { PM->add(createGlobalOptimizerPass()); // Optimize out global vars + PM->add(createIPConstantPropagationPass()); // IP CP PM->add(createIPSCCPPass()); // IP SCCP PM->add(createDeadArgEliminationPass()); // Dead argument elimination } Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCP.cpp?rev=85818&r1=85817&r2=85818&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SCCP.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Mon Nov 2 13:31:10 2009 @@ -25,6 +25,7 @@ #include "llvm/Instructions.h" #include "llvm/Pass.h" #include "llvm/Analysis/ConstantFolding.h" +#include "llvm/Analysis/MemoryBuiltins.h" #include "llvm/Analysis/ValueTracking.h" #include "llvm/Transforms/Utils/Local.h" #include "llvm/Target/TargetData.h" @@ -226,6 +227,7 @@ /// and out of the specified function (which cannot have its address taken), /// this method must be called. void AddTrackedFunction(Function *F) { + assert(F->hasLocalLinkage() && "Can only track internal functions!"); // Add an entry, F -> undef. if (const StructType *STy = dyn_cast(F->getReturnType())) { for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) @@ -378,9 +380,11 @@ // instruction that was just changed state somehow. Based on this // information, we need to update the specified user of this instruction. // - void OperandChangedState(Instruction *I) { - if (BBExecutable.count(I->getParent())) // Inst is executable? - visit(*I); + void OperandChangedState(User *U) { + // Only instructions use other variable values! + Instruction &I = cast(*U); + if (BBExecutable.count(I.getParent())) // Inst is executable? + visit(I); } /// RemoveFromOverdefinedPHIs - If I has any entries in the @@ -424,6 +428,8 @@ void visitLoadInst (LoadInst &I); void visitGetElementPtrInst(GetElementPtrInst &I); void visitCallInst (CallInst &I) { + if (isFreeCall(&I)) + return; visitCallSite(CallSite::get(&I)); } void visitInvokeInst (InvokeInst &II) { @@ -650,19 +656,19 @@ markConstant(&PN, OperandVal); // Acquire operand value } - - - void SCCPSolver::visitReturnInst(ReturnInst &I) { if (I.getNumOperands() == 0) return; // ret void Function *F = I.getParent()->getParent(); - // If we are tracking the return value of this function, merge it in. + if (!F->hasLocalLinkage()) + return; + if (!TrackedRetVals.empty()) { DenseMap::iterator TFRVI = TrackedRetVals.find(F); - if (TFRVI != TrackedRetVals.end()) { + if (TFRVI != TrackedRetVals.end() && + !TFRVI->second.isOverdefined()) { mergeInValue(TFRVI->second, F, getValueState(I.getOperand(0))); return; } @@ -1158,14 +1164,14 @@ // The common case is that we aren't tracking the callee, either because we // are not doing interprocedural analysis or the callee is indirect, or is // external. Handle these cases first. - if (F == 0 || F->isDeclaration()) { + if (F == 0 || !F->hasLocalLinkage()) { CallOverdefined: // Void return and not tracking callee, just bail. if (I->getType()->isVoidTy()) return; // Otherwise, if we have a single return value case, and if the function is // a declaration, maybe we can constant fold it. - if (F && F->isDeclaration() && !isa(I->getType()) && + if (!isa(I->getType()) && F && F->isDeclaration() && canConstantFoldCallTo(F)) { SmallVector Operands; @@ -1229,7 +1235,7 @@ // common path above. goto CallOverdefined; } - + // Finally, if this is the first call to the function hit, mark its entry // block executable. MarkBlockExecutable(F->begin()); @@ -1238,8 +1244,6 @@ CallSite::arg_iterator CAI = CS.arg_begin(); for (Function::arg_iterator AI = F->arg_begin(), E = F->arg_end(); AI != E; ++AI, ++CAI) { - // If this argument is byval, and if the function is not readonly, there - // will be an implicit copy formed of the input aggregate. if (AI->hasByValAttr() && !F->onlyReadsMemory()) { markOverdefined(AI); continue; @@ -1269,8 +1273,7 @@ // for (Value::use_iterator UI = I->use_begin(), E = I->use_end(); UI != E; ++UI) - if (Instruction *I = dyn_cast(*UI)) - OperandChangedState(I); + OperandChangedState(*UI); } // Process the instruction work list. @@ -1289,8 +1292,7 @@ if (!getValueState(I).isOverdefined()) for (Value::use_iterator UI = I->use_begin(), E = I->use_end(); UI != E; ++UI) - if (Instruction *I = dyn_cast(*UI)) - OperandChangedState(I); + OperandChangedState(*UI); } // Process the basic block work list. @@ -1648,25 +1650,14 @@ if (F->isDeclaration()) continue; - // If this is a strong or ODR definition of this function, then we can - // propagate information about its result into callsites of it. - if (!F->mayBeOverridden() && - !isa(F->getReturnType())) + if (!F->hasLocalLinkage() || AddressIsTaken(F)) { + Solver.MarkBlockExecutable(F->begin()); + for (Function::arg_iterator AI = F->arg_begin(), E = F->arg_end(); + AI != E; ++AI) + Solver.markOverdefined(AI); + } else { Solver.AddTrackedFunction(F); - - // If this function only has direct calls that we can see, we can track its - // arguments and return value aggressively, and can assume it is not called - // unless we see evidence to the contrary. - if (F->hasLocalLinkage() && !AddressIsTaken(F)) - continue; - - // Assume the function is called. - Solver.MarkBlockExecutable(F->begin()); - - // Assume nothing about the incoming arguments. - for (Function::arg_iterator AI = F->arg_begin(), E = F->arg_end(); - AI != E; ++AI) - Solver.markOverdefined(AI); + } } // Loop over global variables. We inform the solver about any internal global @@ -1814,21 +1805,16 @@ // TODO: Process multiple value ret instructions also. const DenseMap &RV = Solver.getTrackedRetVals(); for (DenseMap::const_iterator I = RV.begin(), - E = RV.end(); I != E; ++I) { - Function *F = I->first; - if (I->second.isOverdefined() || F->getReturnType()->isVoidTy()) - continue; - - // We can only do this if we know that nothing else can call the function. - if (!F->hasLocalLinkage() || AddressIsTaken(F)) - continue; - - for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) - if (ReturnInst *RI = dyn_cast(BB->getTerminator())) - if (!isa(RI->getOperand(0))) - RI->setOperand(0, UndefValue::get(F->getReturnType())); - } - + E = RV.end(); I != E; ++I) + if (!I->second.isOverdefined() && + !I->first->getReturnType()->isVoidTy()) { + Function *F = I->first; + for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) + if (ReturnInst *RI = dyn_cast(BB->getTerminator())) + if (!isa(RI->getOperand(0))) + RI->setOperand(0, UndefValue::get(F->getReturnType())); + } + // If we infered constant or undef values for globals variables, we can delete // the global and any stores that remain to it. const DenseMap &TG = Solver.getTrackedGlobals(); From enderby at apple.com Mon Nov 2 14:14:47 2009 From: enderby at apple.com (Kevin Enderby) Date: Mon, 02 Nov 2009 20:14:47 -0000 Subject: [llvm-commits] [llvm] r85823 - /llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Message-ID: <200911022014.nA2KEoqg018908@zion.cs.uiuc.edu> Author: enderby Date: Mon Nov 2 14:14:39 2009 New Revision: 85823 URL: http://llvm.org/viewvc/llvm-project?rev=85823&view=rev Log: Fix ARMAsmParser::ParseMemoryOffsetReg() where the parameter OffsetRegNum should have been passed as a reference. Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp?rev=85823&r1=85822&r2=85823&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Mon Nov 2 14:14:39 2009 @@ -56,7 +56,7 @@ const MCExpr *&ShiftAmount, const MCExpr *&Offset, bool &OffsetIsReg, - int OffsetRegNum); + int &OffsetRegNum); bool ParseShift(enum ShiftType &St, const MCExpr *&ShiftAmount); @@ -393,7 +393,7 @@ const MCExpr *&ShiftAmount, const MCExpr *&Offset, bool &OffsetIsReg, - int OffsetRegNum) { + int &OffsetRegNum) { ARMOperand Op; Negative = false; OffsetRegShifted = false; From bob.wilson at apple.com Mon Nov 2 14:59:24 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Mon, 02 Nov 2009 20:59:24 -0000 Subject: [llvm-commits] [llvm] r85824 - in /llvm/trunk/lib/Target/ARM: ARMISelLowering.cpp ARMInstrInfo.td ARMInstrThumb.td ARMInstrThumb2.td Message-ID: <200911022059.nA2KxOTV021097@zion.cs.uiuc.edu> Author: bwilson Date: Mon Nov 2 14:59:23 2009 New Revision: 85824 URL: http://llvm.org/viewvc/llvm-project?rev=85824&view=rev Log: Put BlockAddresses into ARM constant pools. Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp llvm/trunk/lib/Target/ARM/ARMInstrInfo.td llvm/trunk/lib/Target/ARM/ARMInstrThumb.td llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=85824&r1=85823&r2=85824&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Mon Nov 2 14:59:23 2009 @@ -1209,9 +1209,26 @@ SDValue ARMTargetLowering::LowerBlockAddress(SDValue Op, SelectionDAG &DAG) { DebugLoc DL = Op.getDebugLoc(); + EVT PtrVT = getPointerTy(); BlockAddress *BA = cast(Op)->getBlockAddress(); - SDValue Result = DAG.getBlockAddress(BA, DL, /*isTarget=*/true); - return DAG.getNode(ARMISD::Wrapper, DL, getPointerTy(), Result); + Reloc::Model RelocM = getTargetMachine().getRelocationModel(); + SDValue CPAddr; + if (RelocM == Reloc::Static) { + CPAddr = DAG.getTargetConstantPool(BA, PtrVT, 4); + } else { + unsigned PCAdj = Subtarget->isThumb() ? 4 : 8; + ARMConstantPoolValue *CPV = new ARMConstantPoolValue(BA, ARMPCLabelIndex, + ARMCP::CPBlockAddress, + PCAdj); + CPAddr = DAG.getTargetConstantPool(CPV, PtrVT, 4); + } + CPAddr = DAG.getNode(ARMISD::Wrapper, DL, PtrVT, CPAddr); + SDValue Result = DAG.getLoad(PtrVT, DL, DAG.getEntryNode(), CPAddr, + PseudoSourceValue::getConstantPool(), 0); + if (RelocM == Reloc::Static) + return Result; + SDValue PICLabel = DAG.getConstant(ARMPCLabelIndex++, MVT::i32); + return DAG.getNode(ARMISD::PIC_ADD, DL, PtrVT, Result, PICLabel); } // Lower ISD::GlobalTLSAddress using the "general dynamic" model Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=85824&r1=85823&r2=85824&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Mon Nov 2 14:59:23 2009 @@ -1607,7 +1607,6 @@ // ConstantPool, GlobalAddress, and JumpTable def : ARMPat<(ARMWrapper tglobaladdr :$dst), (LEApcrel tglobaladdr :$dst)>; def : ARMPat<(ARMWrapper tconstpool :$dst), (LEApcrel tconstpool :$dst)>; -def : ARMPat<(ARMWrapper tblockaddress:$dst), (LEApcrel tblockaddress:$dst)>; def : ARMPat<(ARMWrapperJT tjumptable:$dst, imm:$id), (LEApcrelJT tjumptable:$dst, imm:$id)>; Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb.td?rev=85824&r1=85823&r2=85824&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb.td Mon Nov 2 14:59:23 2009 @@ -685,7 +685,6 @@ // ConstantPool, GlobalAddress def : T1Pat<(ARMWrapper tglobaladdr :$dst), (tLEApcrel tglobaladdr :$dst)>; def : T1Pat<(ARMWrapper tconstpool :$dst), (tLEApcrel tconstpool :$dst)>; -def : T1Pat<(ARMWrapper tblockaddress:$dst), (tLEApcrel tblockaddress:$dst)>; // JumpTable def : T1Pat<(ARMWrapperJT tjumptable:$dst, imm:$id), Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td?rev=85824&r1=85823&r2=85824&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Mon Nov 2 14:59:23 2009 @@ -1169,7 +1169,6 @@ // ConstantPool, GlobalAddress, and JumpTable def : T2Pat<(ARMWrapper tglobaladdr :$dst), (t2LEApcrel tglobaladdr :$dst)>; def : T2Pat<(ARMWrapper tconstpool :$dst), (t2LEApcrel tconstpool :$dst)>; -def : T2Pat<(ARMWrapper tblockaddress:$dst), (t2LEApcrel tblockaddress:$dst)>; def : T2Pat<(ARMWrapperJT tjumptable:$dst, imm:$id), (t2LEApcrelJT tjumptable:$dst, imm:$id)>; From evan.cheng at apple.com Mon Nov 2 15:49:14 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 02 Nov 2009 21:49:14 -0000 Subject: [llvm-commits] [llvm] r85827 - in /llvm/trunk: lib/CodeGen/MachineLICM.cpp test/CodeGen/ARM/remat.ll test/CodeGen/X86/2007-11-30-LoadFolding-Bug.ll Message-ID: <200911022149.nA2LnES6023664@zion.cs.uiuc.edu> Author: evancheng Date: Mon Nov 2 15:49:14 2009 New Revision: 85827 URL: http://llvm.org/viewvc/llvm-project?rev=85827&view=rev Log: Revert 85799 for now. It might be breaking llvm-gcc driver. Modified: llvm/trunk/lib/CodeGen/MachineLICM.cpp llvm/trunk/test/CodeGen/ARM/remat.ll llvm/trunk/test/CodeGen/X86/2007-11-30-LoadFolding-Bug.ll Modified: llvm/trunk/lib/CodeGen/MachineLICM.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineLICM.cpp?rev=85827&r1=85826&r2=85827&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineLICM.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineLICM.cpp Mon Nov 2 15:49:14 2009 @@ -56,12 +56,12 @@ // State that is updated as we process loops bool Changed; // True if a loop is changed. - bool FirstInLoop; // True if it's the first LICM in the loop. MachineLoop *CurLoop; // The current loop we are working on. MachineBasicBlock *CurPreheader; // The preheader for CurLoop. - // For each opcode, keep a list of potentail CSE instructions. - DenseMap > CSEMap; + // For each BB and opcode pair, keep a list of hoisted instructions. + DenseMap, + std::vector > CSEMap; public: static char ID; // Pass identification, replacement for typeid MachineLICM() : MachineFunctionPass(&ID) {} @@ -115,11 +115,6 @@ /// that is safe to hoist, this instruction is called to do the dirty work. /// void Hoist(MachineInstr *MI); - - /// InitCSEMap - Initialize the CSE map with instructions that are in the - /// current loop preheader that may become duplicates of instructions that - /// are hoisted out of the loop. - void InitCSEMap(MachineBasicBlock *BB); }; } // end anonymous namespace @@ -145,7 +140,7 @@ bool MachineLICM::runOnMachineFunction(MachineFunction &MF) { DEBUG(errs() << "******** Machine LICM ********\n"); - Changed = FirstInLoop = false; + Changed = false; TM = &MF.getTarget(); TII = TM->getInstrInfo(); TRI = TM->getRegisterInfo(); @@ -157,7 +152,8 @@ DT = &getAnalysis(); AA = &getAnalysis(); - for (MachineLoopInfo::iterator I = LI->begin(), E = LI->end(); I != E; ++I) { + for (MachineLoopInfo::iterator + I = LI->begin(), E = LI->end(); I != E; ++I) { CurLoop = *I; // Only visit outer-most preheader-sporting loops. @@ -174,11 +170,7 @@ if (!CurPreheader) continue; - // CSEMap is initialized for loop header when the first instruction is - // being hoisted. - FirstInLoop = true; HoistRegion(DT->getNode(CurLoop->getHeader())); - CSEMap.clear(); } return Changed; @@ -199,7 +191,10 @@ for (MachineBasicBlock::iterator MII = BB->begin(), E = BB->end(); MII != E; ) { MachineBasicBlock::iterator NextMII = MII; ++NextMII; - Hoist(&*MII); + MachineInstr &MI = *MII; + + Hoist(&MI); + MII = NextMII; } @@ -435,27 +430,6 @@ return NewMIs[0]; } -void MachineLICM::InitCSEMap(MachineBasicBlock *BB) { - for (MachineBasicBlock::iterator I = BB->begin(),E = BB->end(); I != E; ++I) { - const MachineInstr *MI = &*I; - // FIXME: For now, only hoist re-materilizable instructions. LICM will - // increase register pressure. We want to make sure it doesn't increase - // spilling. - if (TII->isTriviallyReMaterializable(MI, AA)) { - unsigned Opcode = MI->getOpcode(); - DenseMap >::iterator - CI = CSEMap.find(Opcode); - if (CI != CSEMap.end()) - CI->second.push_back(MI); - else { - std::vector CSEMIs; - CSEMIs.push_back(MI); - CSEMap.insert(std::make_pair(Opcode, CSEMIs)); - } - } - } -} - /// Hoist - When an instruction is found to use only loop invariant operands /// that are safe to hoist, this instruction is called to do the dirty work. /// @@ -480,14 +454,11 @@ errs() << "\n"; }); - // If this is the first instruction being hoisted to the preheader, - // initialize the CSE map with potential common expressions. - InitCSEMap(CurPreheader); - // Look for opportunity to CSE the hoisted instruction. - unsigned Opcode = MI->getOpcode(); - DenseMap >::iterator - CI = CSEMap.find(Opcode); + std::pair BBOpcPair = + std::make_pair(CurPreheader->getNumber(), MI->getOpcode()); + DenseMap, + std::vector >::iterator CI = CSEMap.find(BBOpcPair); bool DoneCSE = false; if (CI != CSEMap.end()) { const MachineInstr *Dup = LookForDuplicate(MI, CI->second, RegInfo); @@ -506,15 +477,15 @@ // Otherwise, splice the instruction to the preheader. if (!DoneCSE) { - CurPreheader->splice(CurPreheader->getFirstTerminator(),MI->getParent(),MI); - + CurPreheader->splice(CurPreheader->getFirstTerminator(), + MI->getParent(), MI); // Add to the CSE map. if (CI != CSEMap.end()) CI->second.push_back(MI); else { std::vector CSEMIs; CSEMIs.push_back(MI); - CSEMap.insert(std::make_pair(Opcode, CSEMIs)); + CSEMap.insert(std::make_pair(BBOpcPair, CSEMIs)); } } Modified: llvm/trunk/test/CodeGen/ARM/remat.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/remat.ll?rev=85827&r1=85826&r2=85827&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/remat.ll (original) +++ llvm/trunk/test/CodeGen/ARM/remat.ll Mon Nov 2 15:49:14 2009 @@ -1,5 +1,5 @@ ; RUN: llc < %s -mtriple=arm-apple-darwin -; RUN: llc < %s -mtriple=arm-apple-darwin -stats -info-output-file - | grep "Number of re-materialization" | grep 5 +; RUN: llc < %s -mtriple=arm-apple-darwin -stats -info-output-file - | grep "Number of re-materialization" | grep 4 %struct.CONTENTBOX = type { i32, i32, i32, i32, i32 } %struct.LOCBOX = type { i32, i32, i32, i32 } Modified: llvm/trunk/test/CodeGen/X86/2007-11-30-LoadFolding-Bug.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2007-11-30-LoadFolding-Bug.ll?rev=85827&r1=85826&r2=85827&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2007-11-30-LoadFolding-Bug.ll (original) +++ llvm/trunk/test/CodeGen/X86/2007-11-30-LoadFolding-Bug.ll Mon Nov 2 15:49:14 2009 @@ -1,5 +1,6 @@ -; RUN: llc < %s -march=x86 -mattr=+sse2 | FileCheck %s -; Increment in loop bb.i28.i adjusted to 2, to prevent loop reversal from +; RUN: llc < %s -march=x86 -mattr=+sse2 -stats |& \ +; RUN: grep {1 .*folded into instructions} +; Increment in loop bb.128.i adjusted to 2, to prevent loop reversal from ; kicking in. declare fastcc void @rdft(i32, i32, double*, i32*, double*) @@ -33,9 +34,6 @@ br label %bb.i28.i bb.i28.i: ; preds = %bb.i28.i, %cond_next36.i -; CHECK: %bb.i28.i -; CHECK: addl $2 -; CHECK: addl $2 %j.0.reg2mem.0.i16.i = phi i32 [ 0, %cond_next36.i ], [ %indvar.next39.i, %bb.i28.i ] ; [#uses=2] %din_addr.1.reg2mem.0.i17.i = phi double [ 0.000000e+00, %cond_next36.i ], [ %tmp16.i25.i, %bb.i28.i ] ; [#uses=1] %tmp1.i18.i = fptosi double %din_addr.1.reg2mem.0.i17.i to i32 ; [#uses=2] From bob.wilson at apple.com Mon Nov 2 16:44:23 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Mon, 02 Nov 2009 22:44:23 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r85835 - in /llvm-gcc-4.2/trunk/gcc: llvm-convert.cpp llvm-internal.h Message-ID: <200911022244.nA2MiNFd026188@zion.cs.uiuc.edu> Author: bwilson Date: Mon Nov 2 16:44:23 2009 New Revision: 85835 URL: http://llvm.org/viewvc/llvm-project?rev=85835&view=rev Log: Reimplement indirect goto support using Duncan's code from dragonegg. GCC is already transforming the code to have a single indirect goto per function, so repeating that transformation when we convert to llvm is only adding overhead. Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp llvm-gcc-4.2/trunk/gcc/llvm-internal.h 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=85835&r1=85834&r2=85835&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Mon Nov 2 16:44:23 2009 @@ -181,9 +181,7 @@ FuncEHSelector = 0; FuncEHGetTypeID = 0; -#ifdef USEINDIRECTBRANCH - IndirectBranch = 0; -#else +#ifndef USEINDIRECTBRANCH NumAddressTakenBlocks = 0; IndirectGotoBlock = 0; #endif @@ -730,22 +728,7 @@ EmitPostPads(); EmitUnwindBlock(); -#ifdef USEINDIRECTBRANCH - // If someone did an indirect goto, emit the indirect goto block at the end of - // the function. - if (IndirectBranch) { - EmitBlock(IndirectBranch->getParent()); - Builder.ClearInsertionPoint(); - - // If someone took the address of a label but never did an indirect goto, - // we made a zero entry PHI node, which is illegal. Zap it now. - PHINode *PN = cast(IndirectBranch->getAddress()); - if (PN->getNumIncomingValues() == 0) { - PN->replaceAllUsesWith(UndefValue::get(PN->getType())); - PN->eraseFromParent(); - } - } -#else +#ifndef USEINDIRECTBRANCH // If this function takes the address of a label, emit the indirect goto // block. if (IndirectGotoBlock) { @@ -1076,8 +1059,12 @@ // Constants. case LABEL_DECL: { +#ifdef USEINDIRECTBRANCH + LV = LValue(EmitLV_LABEL_DECL(exp), 1); +#else Value *Ptr = TreeConstantToLLVM::EmitLV_LABEL_DECL(exp); LV = LValue(Ptr, 1); +#endif break; } case COMPLEX_CST: { @@ -1702,23 +1689,11 @@ } } +#ifndef USEINDIRECTBRANCH //===----------------------------------------------------------------------===// // ... Address Of Labels Extension Support ... //===----------------------------------------------------------------------===// -#ifdef USEINDIRECTBRANCH -/// getBlockAddress - Create a BlockAddress and add it as a possible -/// destination of the IndirectBranch. -BlockAddress *TreeToLLVM::getBlockAddress(BasicBlock *BB) { - // Make sure that there is a block for the indirect goto. - if (IndirectBranch == 0) - getIndirectGotoBlock(); - - // Make sure the indirect branch includes all of the address-taken blocks. - IndirectBranch->addDestination(BB); - return BlockAddress::get(Fn, BB); -} -#else /// getIndirectGotoBlockNumber - Return the unique ID of the specified basic /// block for uses that take the address of it. Constant *TreeToLLVM::getIndirectGotoBlockNumber(BasicBlock *BB) { @@ -1734,26 +1709,10 @@ cast(getIndirectGotoBlock()->getTerminator())->addCase(Val, BB); return Val; } -#endif /// getIndirectGotoBlock - Get (and potentially lazily create) the indirect /// goto block. BasicBlock *TreeToLLVM::getIndirectGotoBlock() { -#ifdef USEINDIRECTBRANCH - // If we already made the indirect branch for indirect goto, return its block. - if (IndirectBranch) return IndirectBranch->getParent(); - - BasicBlock *IndirectGotoBlock = BasicBlock::Create(Context, "indirectgoto"); - LLVMBuilder TmpBuilder(IndirectGotoBlock, *TheFolder); - const Type *Int8PtrTy = Type::getInt8PtrTy(Context); - - // Create the PHI node that indirect gotos will add entries to. - Value *DestVal = TmpBuilder.CreatePHI(Int8PtrTy, "indirect.goto.dest"); - - // Create the indirect branch instruction. - IndirectBranch = TmpBuilder.CreateIndirectBr(DestVal); - return IndirectBranch->getParent(); -#else if (IndirectGotoBlock) return IndirectGotoBlock; // Create a temporary for the value to be switched on. @@ -1766,8 +1725,8 @@ // Finally, return it. return IndirectGotoBlock; -#endif } +#endif //===----------------------------------------------------------------------===// @@ -1782,32 +1741,38 @@ } Value *TreeToLLVM::EmitGOTO_EXPR(tree exp) { - if (TREE_CODE(TREE_OPERAND(exp, 0)) == LABEL_DECL) { + tree dest = GOTO_DESTINATION(exp); + if (TREE_CODE(dest) == LABEL_DECL) { // Direct branch. - Builder.CreateBr(getLabelDeclBlock(TREE_OPERAND(exp, 0))); + Builder.CreateBr(getLabelDeclBlock(dest)); } else { +#ifdef USEINDIRECTBRANCH + // Indirect branch. + basic_block bb = bb_for_stmt(exp); + Value *V = Emit(dest, 0); + IndirectBrInst *Br = Builder.CreateIndirectBr(V, EDGE_COUNT(bb->succs)); + + // Add the list of possible destinations. + edge e; + edge_iterator ei; + FOR_EACH_EDGE (e, ei, bb->succs) + Br->addDestination(getLabelDeclBlock(tree_block_label(e->dest))); +#else // Otherwise we have an indirect goto. BasicBlock *DestBB = getIndirectGotoBlock(); -#ifdef USEINDIRECTBRANCH - Value *V = Emit(TREE_OPERAND(exp, 0), 0); - V = Builder.CreateBitCast(V, Type::getInt8PtrTy(Context)); - // The first instruction in the indirect goto block has to be the PHI for - // the indirect branch address; add an entry for this branch. - cast(DestBB->begin())->addIncoming(V, Builder.GetInsertBlock()); -#else // Store the destination block to the GotoValue alloca. - Value *V = Emit(TREE_OPERAND(exp, 0), 0); + Value *V = Emit(dest); V = CastToType(Instruction::PtrToInt, V, TD.getIntPtrType(Context)); Builder.CreateStore(V, IndirectGotoValue); -#endif // NOTE: This is HORRIBLY INCORRECT in the presence of exception handlers. // There should be one collector block per cleanup level! Note that // standard GCC gets this wrong as well. // Builder.CreateBr(DestBB); +#endif } EmitBlock(BasicBlock::Create(Context, "")); return 0; @@ -6974,6 +6939,14 @@ return LValue(Builder.CreateStructGEP(Ptr.Ptr, Idx), Alignment); } +#ifdef USEINDIRECTBRANCH +Constant *TreeToLLVM::EmitLV_LABEL_DECL(tree exp) { + // GCC kindly diverts labels for unreachable basic blocks to reachable blocks, + // so we are not obliged to output unreachable blocks even if the original + // code took the address of one. + return BlockAddress::get(Fn, getLabelDeclBlock(exp)); +} +#endif //===----------------------------------------------------------------------===// // ... Constant Expressions ... @@ -8052,11 +8025,10 @@ "Taking the address of a label that isn't in the current fn!?"); } - BasicBlock *BB = getLabelDeclBlock(exp); #ifdef USEINDIRECTBRANCH - Constant *Ptr = TheTreeToLLVM->getBlockAddress(BB); - return TheFolder->CreateBitCast(Ptr, Type::getInt8PtrTy(Context)); + return TheTreeToLLVM->EmitLV_LABEL_DECL(exp); #else + BasicBlock *BB = getLabelDeclBlock(exp); Constant *C = TheTreeToLLVM->getIndirectGotoBlockNumber(BB); return TheFolder->CreateIntToPtr(C, Type::getInt8PtrTy(Context)); #endif Modified: llvm-gcc-4.2/trunk/gcc/llvm-internal.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-internal.h?rev=85835&r1=85834&r2=85835&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-internal.h (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-internal.h Mon Nov 2 16:44:23 2009 @@ -331,13 +331,7 @@ /// FuncEHGetTypeID - Function used to return type id for give typeinfo. Function *FuncEHGetTypeID; -#ifdef USEINDIRECTBRANCH - /// IndirectBranch - The first time an indirect goto is seen we create a - /// block with an indirect branch. Every time we see the address of a label - /// taken, we add the label to the indirect goto. Every subsequent indirect - /// goto is codegen'd as a jump to the IndirectBranch's basic block. - IndirectBrInst *IndirectBranch; -#else +#ifndef USEINDIRECTBRANCH /// NumAddressTakenBlocks - Count the number of labels whose addresses are /// taken. uint64_t NumAddressTakenBlocks; @@ -370,11 +364,7 @@ /// the address of the result. LValue EmitLV(tree_node *exp); -#ifdef USEINDIRECTBRANCH - /// getBlockAddress - Create a BlockAddress and add it as a possible - /// destination of the IndirectBranch. - BlockAddress *getBlockAddress(BasicBlock *BB); -#else +#ifndef USEINDIRECTBRANCH /// getIndirectGotoBlockNumber - Return the unique ID of the specified basic /// block for uses that take the address of it. Constant *getIndirectGotoBlockNumber(BasicBlock *BB); @@ -622,6 +612,12 @@ Value *&Result, const Type *ResultType, std::vector &Ops); + +#ifdef USEINDIRECTBRANCH +public: + // Helper for taking the address of a label. + Constant *EmitLV_LABEL_DECL(tree_node *exp); +#endif }; /// TreeConstantToLLVM - An instance of this class is created and used to From bob.wilson at apple.com Mon Nov 2 16:42:34 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Mon, 2 Nov 2009 14:42:34 -0800 Subject: [llvm-commits] [llvm-gcc-4.2] r85513 - in /llvm-gcc-4.2/trunk/gcc: llvm-convert.cpp llvm-internal.h In-Reply-To: References: <200910291733.n9THXTXM017953@zion.cs.uiuc.edu> <4AE9FD88.1080507@free.fr> <59C841C1-4D28-47E4-87C3-EE49578066A1@apple.com> <4AEA02BD.7060509@free.fr> Message-ID: On Oct 29, 2009, at 3:09 PM, Bob Wilson wrote: > > On Oct 29, 2009, at 2:01 PM, Duncan Sands wrote: > >> Hi Bob, >> >>> Besides consistency with clang, the idea behind doing it this way >>> is to reduce the number of edges in the CFG. Indirect branches are >>> typically used in things like interpreter loops, where you have a >>> large number of labels and a large number of gotos. If you add an >>> edge from every goto to every label, the CFG can blow up. Instead >>> we have a single indirect branch and all the gotos branch to it, >>> basically factoring out the CFG. >> >> but gcc already does this factorization for you IIRC. So you should >> find >> that there is already only one computed goto in the gimple no matter >> how >> many there were to start off with. > > Oh, I didn't know that. I was just trying to be consistent with the > existing code in llvm-gcc and clang. I'll have another look at it. > If what you say is correct, I agree that the dragonegg approach would > be better. I've changed it to use the dragonegg code. Thanks, Duncan! From bob.wilson at apple.com Mon Nov 2 17:14:22 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Mon, 02 Nov 2009 23:14:22 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r85837 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Message-ID: <200911022314.nA2NENbt027470@zion.cs.uiuc.edu> Author: bwilson Date: Mon Nov 2 17:14:19 2009 New Revision: 85837 URL: http://llvm.org/viewvc/llvm-project?rev=85837&view=rev Log: Fix broken build. 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=85837&r1=85836&r2=85837&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Mon Nov 2 17:14:19 2009 @@ -1763,7 +1763,7 @@ BasicBlock *DestBB = getIndirectGotoBlock(); // Store the destination block to the GotoValue alloca. - Value *V = Emit(dest); + Value *V = Emit(dest, 0); V = CastToType(Instruction::PtrToInt, V, TD.getIntPtrType(Context)); Builder.CreateStore(V, IndirectGotoValue); From sabre at nondot.org Mon Nov 2 17:25:40 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 02 Nov 2009 23:25:40 -0000 Subject: [llvm-commits] [llvm] r85840 - /llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Message-ID: <200911022325.nA2NPetB027923@zion.cs.uiuc.edu> Author: lattner Date: Mon Nov 2 17:25:39 2009 New Revision: 85840 URL: http://llvm.org/viewvc/llvm-project?rev=85840&view=rev Log: fix a nasty iterator invalidation bug from my conversion from std::map to DenseMap, exposed on release llvm-gcc bootstrap. Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCP.cpp?rev=85840&r1=85839&r2=85840&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SCCP.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Mon Nov 2 17:25:39 2009 @@ -1079,8 +1079,7 @@ // can turn this into a getelementptr ConstantExpr. // void SCCPSolver::visitGetElementPtrInst(GetElementPtrInst &I) { - LatticeVal &IV = ValueState[&I]; - if (IV.isOverdefined()) return; + if (ValueState[&I].isOverdefined()) return; SmallVector Operands; Operands.reserve(I.getNumOperands()); @@ -1091,7 +1090,7 @@ return; // Operands are not resolved yet. if (State.isOverdefined()) - return markOverdefined(IV, &I); + return markOverdefined(&I); assert(State.isConstant() && "Unknown state!"); Operands.push_back(State.getConstant()); From bob.wilson at apple.com Mon Nov 2 18:02:06 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 03 Nov 2009 00:02:06 -0000 Subject: [llvm-commits] [llvm] r85844 - /llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Message-ID: <200911030002.nA3026E3029272@zion.cs.uiuc.edu> Author: bwilson Date: Mon Nov 2 18:02:05 2009 New Revision: 85844 URL: http://llvm.org/viewvc/llvm-project?rev=85844&view=rev Log: Revert previous change to a comment. The BlockAddresses go in the constant pool so they don't get wrapped separately. Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=85844&r1=85843&r2=85844&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Mon Nov 2 18:02:05 2009 @@ -1186,12 +1186,12 @@ return result; } -// ConstantPool, BlockAddress, JumpTable, GlobalAddress, and ExternalSymbol are -// lowered as their target counterpart wrapped in the ARMISD::Wrapper -// node. Suppose N is one of the above mentioned nodes. It has to be wrapped -// because otherwise Select(N) returns N. So the raw TargetGlobalAddress -// nodes, etc. can only be used to form addressing mode. These wrapped nodes -// will be selected into MOVi. +// ConstantPool, JumpTable, GlobalAddress, and ExternalSymbol are lowered as +// their target counterpart wrapped in the ARMISD::Wrapper node. Suppose N is +// one of the above mentioned nodes. It has to be wrapped because otherwise +// Select(N) returns N. So the raw TargetGlobalAddress nodes, etc. can only +// be used to form addressing mode. These wrapped nodes will be selected +// into MOVi. static SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG) { EVT PtrVT = Op.getValueType(); // FIXME there is no actual debug info here From anton at korobeynikov.info Mon Nov 2 18:24:06 2009 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Tue, 3 Nov 2009 03:24:06 +0300 Subject: [llvm-commits] [llvm] r85049 - in /llvm/trunk/lib/Target/ARM: ARMBaseRegisterInfo.cpp ARMBaseRegisterInfo.h In-Reply-To: <200910250753.n9P7rSQb019706@zion.cs.uiuc.edu> References: <200910250753.n9P7rSQb019706@zion.cs.uiuc.edu> Message-ID: Hello, Evan > Add ARM getMatchingSuperRegClass to handle S / D / Q cross regclass coalescing. This causes PR5367, I've reverted it for now. -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From asl at math.spbu.ru Mon Nov 2 18:24:48 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Tue, 03 Nov 2009 00:24:48 -0000 Subject: [llvm-commits] [llvm] r85847 - in /llvm/trunk: lib/Target/ARM/ARMBaseRegisterInfo.cpp test/CodeGen/ARM/2009-11-01-NeonMoves.ll Message-ID: <200911030024.nA30Ombr030165@zion.cs.uiuc.edu> Author: asl Date: Mon Nov 2 18:24:48 2009 New Revision: 85847 URL: http://llvm.org/viewvc/llvm-project?rev=85847&view=rev Log: Revert r85049, it is causing PR5367 Modified: llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp llvm/trunk/test/CodeGen/ARM/2009-11-01-NeonMoves.ll Modified: llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp?rev=85847&r1=85846&r2=85847&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp Mon Nov 2 18:24:48 2009 @@ -257,6 +257,7 @@ ARMBaseRegisterInfo::getMatchingSuperRegClass(const TargetRegisterClass *A, const TargetRegisterClass *B, unsigned SubIdx) const { +#if 0 switch (SubIdx) { default: return 0; case 1: @@ -277,6 +278,7 @@ // D sub-registers. return A; } +#endif return 0; } Modified: llvm/trunk/test/CodeGen/ARM/2009-11-01-NeonMoves.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/2009-11-01-NeonMoves.ll?rev=85847&r1=85846&r2=85847&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/2009-11-01-NeonMoves.ll (original) +++ llvm/trunk/test/CodeGen/ARM/2009-11-01-NeonMoves.ll Mon Nov 2 18:24:48 2009 @@ -1,4 +1,4 @@ -; RUN: llc -mcpu=cortex-a8 < %s | grep vmov | count 1 +; RUN: llc -mcpu=cortex-a8 < %s | grep vmov | count 2 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64" target triple = "armv7-eabi" From asl at math.spbu.ru Mon Nov 2 18:37:36 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Tue, 03 Nov 2009 00:37:36 -0000 Subject: [llvm-commits] [llvm] r85848 - in /llvm/trunk/test/CodeGen/Thumb2: 2009-08-04-SubregLoweringBug.ll cross-rc-coalescing-2.ll Message-ID: <200911030037.nA30bbr7030592@zion.cs.uiuc.edu> Author: asl Date: Mon Nov 2 18:37:36 2009 New Revision: 85848 URL: http://llvm.org/viewvc/llvm-project?rev=85848&view=rev Log: Temporary xfail until PR5367 will be resolved Modified: llvm/trunk/test/CodeGen/Thumb2/2009-08-04-SubregLoweringBug.ll llvm/trunk/test/CodeGen/Thumb2/cross-rc-coalescing-2.ll Modified: llvm/trunk/test/CodeGen/Thumb2/2009-08-04-SubregLoweringBug.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/2009-08-04-SubregLoweringBug.ll?rev=85848&r1=85847&r2=85848&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/2009-08-04-SubregLoweringBug.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/2009-08-04-SubregLoweringBug.ll Mon Nov 2 18:37:36 2009 @@ -1,6 +1,7 @@ ; RUN: llc < %s -mtriple=thumbv7-apple-darwin9 -mattr=+neon -arm-use-neon-fp ; RUN: llc < %s -mtriple=thumbv7-apple-darwin9 -mattr=+neon -arm-use-neon-fp | not grep fcpys ; rdar://7117307 +; XFAIL: * %struct.Hosp = type { i32, i32, i32, %struct.List, %struct.List, %struct.List, %struct.List } %struct.List = type { %struct.List*, %struct.Patient*, %struct.List* } Modified: llvm/trunk/test/CodeGen/Thumb2/cross-rc-coalescing-2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/cross-rc-coalescing-2.ll?rev=85848&r1=85847&r2=85848&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/cross-rc-coalescing-2.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/cross-rc-coalescing-2.ll Mon Nov 2 18:37:36 2009 @@ -1,4 +1,5 @@ ; RUN: llc < %s -mtriple=thumbv7-apple-darwin9 -mcpu=cortex-a8 | grep fcpys | count 4 +; XFAIL: * define arm_apcscc void @fht(float* nocapture %fz, i16 signext %n) nounwind { entry: From anton at korobeynikov.info Mon Nov 2 18:56:06 2009 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Tue, 3 Nov 2009 03:56:06 +0300 Subject: [llvm-commits] [llvm] r85362 - in /llvm/trunk: lib/Target/ARM/ARMISelLowering.cpp lib/Target/ARM/ARMISelLowering.h lib/Target/ARM/ARMInstrVFP.td lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp lib/Target/ARM/AsmPrinter/ARMInstPrinter.h test/CodeGen/A Message-ID: Hello, Evan > +define arm_apcscc float @t4(float %x) nounwind readnone optsize { > +entry: > +; CHECK: t4: > +; CHECK: fconsts s1, 184 > + ?%0 = fmul float %x, -2.400000e+01 > + ?ret float %0 > +} This is invalid assembler. According to ARM docs immediate should have '#' in the beginning. -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From asl at math.spbu.ru Mon Nov 2 19:04:26 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Tue, 03 Nov 2009 01:04:26 -0000 Subject: [llvm-commits] [llvm] r85850 - in /llvm/trunk/lib/Target/ARM: ARM.h ARMBaseInstrInfo.cpp ARMTargetMachine.cpp NEONMoveFix.cpp Message-ID: <200911030104.nA314RYX031608@zion.cs.uiuc.edu> Author: asl Date: Mon Nov 2 19:04:26 2009 New Revision: 85850 URL: http://llvm.org/viewvc/llvm-project?rev=85850&view=rev Log: Turn neon reg-reg moves fixup code into separate pass. This should reduce the compile time. Added: llvm/trunk/lib/Target/ARM/NEONMoveFix.cpp Modified: llvm/trunk/lib/Target/ARM/ARM.h llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp Modified: llvm/trunk/lib/Target/ARM/ARM.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARM.h?rev=85850&r1=85849&r2=85850&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARM.h (original) +++ llvm/trunk/lib/Target/ARM/ARM.h Mon Nov 2 19:04:26 2009 @@ -105,6 +105,7 @@ FunctionPass *createARMLoadStoreOptimizationPass(bool PreAlloc = false); FunctionPass *createARMConstantIslandPass(); FunctionPass *createNEONPreAllocPass(); +FunctionPass *createNEONMoveFixPass(); FunctionPass *createThumb2ITBlockPass(); FunctionPass *createThumb2SizeReductionPass(); Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp?rev=85850&r1=85849&r2=85850&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp Mon Nov 2 19:04:26 2009 @@ -658,39 +658,8 @@ // Always use neon reg-reg move if source or dest is NEON-only regclass. BuildMI(MBB, I, DL, get(ARM::VMOVD), DestReg).addReg(SrcReg); } else if (DestRC == ARM::DPRRegisterClass) { - const ARMBaseRegisterInfo* TRI = &getRegisterInfo(); - - // If we do not found an instruction defining the reg, this means the - // register should be live-in for this BB. It's always to better to use - // NEON reg-reg moves. - unsigned Domain = ARMII::DomainNEON; - - // Find the Machine Instruction which defines SrcReg. - if (!MBB.empty()) { - MachineBasicBlock::iterator J = (I == MBB.begin() ? I : prior(I)); - while (J != MBB.begin()) { - if (J->modifiesRegister(SrcReg, TRI)) - break; - --J; - } - - if (J->modifiesRegister(SrcReg, TRI)) { - Domain = J->getDesc().TSFlags & ARMII::DomainMask; - // Instructions in general domain are subreg accesses. - // Map them to NEON reg-reg moves. - if (Domain == ARMII::DomainGeneral) - Domain = ARMII::DomainNEON; - } - } - - if ((Domain & ARMII::DomainNEON) && getSubtarget().hasNEON()) { - BuildMI(MBB, I, DL, get(ARM::VMOVQ), DestReg).addReg(SrcReg); - } else { - assert((Domain & ARMII::DomainVFP || - !getSubtarget().hasNEON()) && "Invalid domain!"); - AddDefaultPred(BuildMI(MBB, I, DL, get(ARM::FCPYD), DestReg) - .addReg(SrcReg)); - } + AddDefaultPred(BuildMI(MBB, I, DL, get(ARM::FCPYD), DestReg) + .addReg(SrcReg)); } else if (DestRC == ARM::QPRRegisterClass || DestRC == ARM::QPR_VFP2RegisterClass) { BuildMI(MBB, I, DL, get(ARM::VMOVQ), DestReg).addReg(SrcReg); Modified: llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp?rev=85850&r1=85849&r2=85850&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp Mon Nov 2 19:04:26 2009 @@ -112,8 +112,11 @@ bool ARMBaseTargetMachine::addPreEmitPass(PassManagerBase &PM, CodeGenOpt::Level OptLevel) { // FIXME: temporarily disabling load / store optimization pass for Thumb1. - if (OptLevel != CodeGenOpt::None && !Subtarget.isThumb1Only()) - PM.add(createIfConverterPass()); + if (OptLevel != CodeGenOpt::None) { + if (!Subtarget.isThumb1Only()) + PM.add(createIfConverterPass()); + PM.add(createNEONMoveFixPass()); + } if (Subtarget.isThumb2()) { PM.add(createThumb2ITBlockPass()); Added: llvm/trunk/lib/Target/ARM/NEONMoveFix.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/NEONMoveFix.cpp?rev=85850&view=auto ============================================================================== --- llvm/trunk/lib/Target/ARM/NEONMoveFix.cpp (added) +++ llvm/trunk/lib/Target/ARM/NEONMoveFix.cpp Mon Nov 2 19:04:26 2009 @@ -0,0 +1,144 @@ +//===-- NEONMoveFix.cpp - Convert vfp reg-reg moves into neon ---*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#define DEBUG_TYPE "neon-mov-fix" +#include "ARM.h" +#include "ARMMachineFunctionInfo.h" +#include "ARMInstrInfo.h" +#include "llvm/CodeGen/MachineInstr.h" +#include "llvm/CodeGen/MachineInstrBuilder.h" +#include "llvm/CodeGen/MachineFunctionPass.h" +#include "llvm/ADT/Statistic.h" +#include "llvm/Support/Debug.h" +#include "llvm/Support/raw_ostream.h" +using namespace llvm; + +STATISTIC(NumVMovs, "Number of reg-reg moves converted"); + +namespace { + struct NEONMoveFixPass : public MachineFunctionPass { + static char ID; + NEONMoveFixPass() : MachineFunctionPass(&ID) {} + + virtual bool runOnMachineFunction(MachineFunction &Fn); + + virtual const char *getPassName() const { + return "NEON reg-reg move conversion"; + } + + private: + const TargetRegisterInfo *TRI; + const ARMBaseInstrInfo *TII; + const ARMSubtarget *Subtarget; + + typedef DenseMap RegMap; + + bool InsertMoves(MachineBasicBlock &MBB); + }; + char NEONMoveFixPass::ID = 0; +} + +bool NEONMoveFixPass::InsertMoves(MachineBasicBlock &MBB) { + RegMap Defs; + bool Modified = false; + + // Walk over MBB tracking the def points of the registers. + MachineBasicBlock::iterator MII = MBB.begin(), E = MBB.end(); + MachineBasicBlock::iterator NextMII; + for (; MII != E; MII = NextMII) { + NextMII = next(MII); + MachineInstr *MI = &*MII; + + if (MI->getOpcode() == ARM::FCPYD && + !TII->isPredicated(MI)) { + unsigned SrcReg = MI->getOperand(1).getReg(); + // If we do not found an instruction defining the reg, this means the + // register should be live-in for this BB. It's always to better to use + // NEON reg-reg moves. + unsigned Domain = ARMII::DomainNEON; + RegMap::iterator DefMI = Defs.find(SrcReg); + if (DefMI != Defs.end()) { + Domain = DefMI->second->getDesc().TSFlags & ARMII::DomainMask; + // Instructions in general domain are subreg accesses. + // Map them to NEON reg-reg moves. + if (Domain == ARMII::DomainGeneral) + Domain = ARMII::DomainNEON; + } + + if ((Domain & ARMII::DomainNEON) && Subtarget->hasNEON()) { + // Convert FCPYD to VMOVD. + unsigned DestReg = MI->getOperand(0).getReg(); + + DEBUG({errs() << "vmov convert: "; MI->dump();}); + + // It's safe to ignore imp-defs / imp-uses here, since: + // - We're running late, no intelligent condegen passes should be run + // afterwards + // - The imp-defs / imp-uses are superregs only, we don't care about + // them. + BuildMI(MBB, *MI, MI->getDebugLoc(), + TII->get(ARM::VMOVD), DestReg).addReg(SrcReg); + MBB.erase(MI); + MachineBasicBlock::iterator I = prior(NextMII); + MI = &*I; + + DEBUG({errs() << " into: "; MI->dump();}); + + Modified = true; + ++NumVMovs; + } else { + assert((Domain & ARMII::DomainVFP || + !Subtarget->hasNEON()) && "Invalid domain!"); + // Do nothing. + } + } + + // Update def information. + for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { + const MachineOperand& MO = MI->getOperand(i); + if (!MO.isReg() || !MO.isDef()) + continue; + unsigned MOReg = MO.getReg(); + + Defs[MOReg] = MI; + // Catch subregs as well. + for (const unsigned *R = TRI->getSubRegisters(MOReg); *R; ++R) + Defs[*R] = MI; + } + } + + return Modified; +} + +bool NEONMoveFixPass::runOnMachineFunction(MachineFunction &Fn) { + ARMFunctionInfo *AFI = Fn.getInfo(); + const TargetMachine &TM = Fn.getTarget(); + + if (AFI->isThumbFunction()) + return false; + + TRI = TM.getRegisterInfo(); + Subtarget = &TM.getSubtarget(); + TII = static_cast(TM.getInstrInfo()); + + bool Modified = false; + for (MachineFunction::iterator MFI = Fn.begin(), E = Fn.end(); MFI != E; + ++MFI) { + MachineBasicBlock &MBB = *MFI; + Modified |= InsertMoves(MBB); + } + + return Modified; +} + +/// createNEONMoveFixPass - Returns an instance of the NEON reg-reg moves fix +/// pass. +FunctionPass *llvm::createNEONMoveFixPass() { + return new NEONMoveFixPass(); +} From evan.cheng at apple.com Mon Nov 2 20:13:57 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 2 Nov 2009 18:13:57 -0800 Subject: [llvm-commits] [llvm] r85850 - in /llvm/trunk/lib/Target/ARM: ARM.h ARMBaseInstrInfo.cpp ARMTargetMachine.cpp NEONMoveFix.cpp In-Reply-To: <200911030104.nA314RYX031608@zion.cs.uiuc.edu> References: <200911030104.nA314RYX031608@zion.cs.uiuc.edu> Message-ID: <1C12EC22-892A-4F26-8005-B2AD1EBEDBC8@apple.com> On Nov 2, 2009, at 5:04 PM, Anton Korobeynikov wrote: > > ============================================================================== > --- llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp (original) > +++ llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp Mon Nov 2 19:04:26 2009 > @@ -112,8 +112,11 @@ > bool ARMBaseTargetMachine::addPreEmitPass(PassManagerBase &PM, > CodeGenOpt::Level OptLevel) { > // FIXME: temporarily disabling load / store optimization pass for Thumb1. > - if (OptLevel != CodeGenOpt::None && !Subtarget.isThumb1Only()) > - PM.add(createIfConverterPass()); > + if (OptLevel != CodeGenOpt::None) { > + if (!Subtarget.isThumb1Only()) > + PM.add(createIfConverterPass()); > + PM.add(createNEONMoveFixPass()); Please make sure this is run only when NEON is available. Evan > + } > > if (Subtarget.isThumb2()) { > PM.add(createThumb2ITBlockPass()); > > Added: llvm/trunk/lib/Target/ARM/NEONMoveFix.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/NEONMoveFix.cpp?rev=85850&view=auto > > ============================================================================== > --- llvm/trunk/lib/Target/ARM/NEONMoveFix.cpp (added) > +++ llvm/trunk/lib/Target/ARM/NEONMoveFix.cpp Mon Nov 2 19:04:26 2009 > @@ -0,0 +1,144 @@ > +//===-- NEONMoveFix.cpp - Convert vfp reg-reg moves into neon ---*- C++ -*-===// > +// > +// The LLVM Compiler Infrastructure > +// > +// This file is distributed under the University of Illinois Open Source > +// License. See LICENSE.TXT for details. > +// > +//===----------------------------------------------------------------------===// > + > +#define DEBUG_TYPE "neon-mov-fix" > +#include "ARM.h" > +#include "ARMMachineFunctionInfo.h" > +#include "ARMInstrInfo.h" > +#include "llvm/CodeGen/MachineInstr.h" > +#include "llvm/CodeGen/MachineInstrBuilder.h" > +#include "llvm/CodeGen/MachineFunctionPass.h" > +#include "llvm/ADT/Statistic.h" > +#include "llvm/Support/Debug.h" > +#include "llvm/Support/raw_ostream.h" > +using namespace llvm; > + > +STATISTIC(NumVMovs, "Number of reg-reg moves converted"); > + > +namespace { > + struct NEONMoveFixPass : public MachineFunctionPass { > + static char ID; > + NEONMoveFixPass() : MachineFunctionPass(&ID) {} > + > + virtual bool runOnMachineFunction(MachineFunction &Fn); > + > + virtual const char *getPassName() const { > + return "NEON reg-reg move conversion"; > + } > + > + private: > + const TargetRegisterInfo *TRI; > + const ARMBaseInstrInfo *TII; > + const ARMSubtarget *Subtarget; > + > + typedef DenseMap RegMap; > + > + bool InsertMoves(MachineBasicBlock &MBB); > + }; > + char NEONMoveFixPass::ID = 0; > +} > + > +bool NEONMoveFixPass::InsertMoves(MachineBasicBlock &MBB) { > + RegMap Defs; > + bool Modified = false; > + > + // Walk over MBB tracking the def points of the registers. > + MachineBasicBlock::iterator MII = MBB.begin(), E = MBB.end(); > + MachineBasicBlock::iterator NextMII; > + for (; MII != E; MII = NextMII) { > + NextMII = next(MII); > + MachineInstr *MI = &*MII; > + > + if (MI->getOpcode() == ARM::FCPYD && > + !TII->isPredicated(MI)) { > + unsigned SrcReg = MI->getOperand(1).getReg(); > + // If we do not found an instruction defining the reg, this means the > + // register should be live-in for this BB. It's always to better to use > + // NEON reg-reg moves. > + unsigned Domain = ARMII::DomainNEON; > + RegMap::iterator DefMI = Defs.find(SrcReg); > + if (DefMI != Defs.end()) { > + Domain = DefMI->second->getDesc().TSFlags & ARMII::DomainMask; > + // Instructions in general domain are subreg accesses. > + // Map them to NEON reg-reg moves. > + if (Domain == ARMII::DomainGeneral) > + Domain = ARMII::DomainNEON; > + } > + > + if ((Domain & ARMII::DomainNEON) && Subtarget->hasNEON()) { > + // Convert FCPYD to VMOVD. > + unsigned DestReg = MI->getOperand(0).getReg(); > + > + DEBUG({errs() << "vmov convert: "; MI->dump();}); > + > + // It's safe to ignore imp-defs / imp-uses here, since: > + // - We're running late, no intelligent condegen passes should be run > + // afterwards > + // - The imp-defs / imp-uses are superregs only, we don't care about > + // them. > + BuildMI(MBB, *MI, MI->getDebugLoc(), > + TII->get(ARM::VMOVD), DestReg).addReg(SrcReg); > + MBB.erase(MI); > + MachineBasicBlock::iterator I = prior(NextMII); > + MI = &*I; > + > + DEBUG({errs() << " into: "; MI->dump();}); > + > + Modified = true; > + ++NumVMovs; > + } else { > + assert((Domain & ARMII::DomainVFP || > + !Subtarget->hasNEON()) && "Invalid domain!"); > + // Do nothing. > + } > + } > + > + // Update def information. > + for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { > + const MachineOperand& MO = MI->getOperand(i); > + if (!MO.isReg() || !MO.isDef()) > + continue; > + unsigned MOReg = MO.getReg(); > + > + Defs[MOReg] = MI; > + // Catch subregs as well. > + for (const unsigned *R = TRI->getSubRegisters(MOReg); *R; ++R) > + Defs[*R] = MI; > + } > + } > + > + return Modified; > +} > + > +bool NEONMoveFixPass::runOnMachineFunction(MachineFunction &Fn) { > + ARMFunctionInfo *AFI = Fn.getInfo(); > + const TargetMachine &TM = Fn.getTarget(); > + > + if (AFI->isThumbFunction()) > + return false; > + > + TRI = TM.getRegisterInfo(); > + Subtarget = &TM.getSubtarget(); > + TII = static_cast(TM.getInstrInfo()); > + > + bool Modified = false; > + for (MachineFunction::iterator MFI = Fn.begin(), E = Fn.end(); MFI != E; > + ++MFI) { > + MachineBasicBlock &MBB = *MFI; > + Modified |= InsertMoves(MBB); > + } > + > + return Modified; > +} > + > +/// createNEONMoveFixPass - Returns an instance of the NEON reg-reg moves fix > +/// pass. > +FunctionPass *llvm::createNEONMoveFixPass() { > + return new NEONMoveFixPass(); > +} > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From natebegeman at mac.com Mon Nov 2 20:19:31 2009 From: natebegeman at mac.com (Nate Begeman) Date: Tue, 03 Nov 2009 02:19:31 -0000 Subject: [llvm-commits] [llvm] r85853 - /llvm/trunk/test/CodeGen/Generic/intrinsics.ll Message-ID: <200911030219.nA32JV5U002185@zion.cs.uiuc.edu> Author: sampo Date: Mon Nov 2 20:19:31 2009 New Revision: 85853 URL: http://llvm.org/viewvc/llvm-project?rev=85853&view=rev Log: Declare sin & cos as readonly so they match the code in SelectionDAGBuild Modified: llvm/trunk/test/CodeGen/Generic/intrinsics.ll Modified: llvm/trunk/test/CodeGen/Generic/intrinsics.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Generic/intrinsics.ll?rev=85853&r1=85852&r2=85853&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Generic/intrinsics.ll (original) +++ llvm/trunk/test/CodeGen/Generic/intrinsics.ll Mon Nov 2 20:19:31 2009 @@ -14,9 +14,9 @@ ; SIN -declare float @sinf(float) +declare float @sinf(float) readonly -declare double @sin(double) +declare double @sin(double) readonly define double @test_sin(float %F) { %G = call float @sinf( float %F ) ; [#uses=1] @@ -27,9 +27,9 @@ ; COS -declare float @cosf(float) +declare float @cosf(float) readonly -declare double @cos(double) +declare double @cos(double) readonly define double @test_cos(float %F) { %G = call float @cosf( float %F ) ; [#uses=1] From gohman at apple.com Mon Nov 2 21:16:40 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 2 Nov 2009 19:16:40 -0800 Subject: [llvm-commits] [PATCH] Make opt default to not adding a target data string, and update tests In-Reply-To: <400d33ea0911021113h7385041fo34c1fafd3ca38b19@mail.gmail.com> References: <400d33ea0911021113h7385041fo34c1fafd3ca38b19@mail.gmail.com> Message-ID: <06A3392E-15EA-4760-A3D9-B3B9CEDE6F67@apple.com> Hello, If I read this correctly, this makes the NoDefaultDataLayout option unused. Is that right? If so, please remove the option completely. Otherwise, this patch looks fine. Thanks for updating all those tests! Dan On Nov 2, 2009, at 11:13 AM, Kenneth Uildriks wrote: > All tests in the test directory that depend on target data now > explicitly include the target data in the input assembly. This makes > it safe for opt to not add target data whenever it's not supplied by > either the module or the command line, which in turn stops opt from > breaking valid code with bogus target data assumptions. > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From lessen42 at gmail.com Mon Nov 2 03:53:12 2009 From: lessen42 at gmail.com (David Conrad) Date: Mon, 2 Nov 2009 04:53:12 -0500 Subject: [llvm-commits] [llvm] r85697 - in /llvm/trunk: lib/Target/ARM/ARMInstrNEON.td test/CodeGen/ARM/fmacs.ll test/CodeGen/ARM/fnmacs.ll test/CodeGen/Thumb2/cross-rc-coalescing-2.ll In-Reply-To: References: <200910312257.n9VMvbZm030355@zion.cs.uiuc.edu> Message-ID: <72AADD0D-6CAF-433E-8533-A8157E28F8D9@gmail.com> On Nov 1, 2009, at 1:31 PM, Evan Cheng wrote: > > On Nov 1, 2009, at 10:22 AM, Anton Korobeynikov wrote: > >> Hello, Evan >> >>> On the other hand, a vmla.32 followed by another vmla.32 is just >>> fine. And >>> it is faster than vmul + vadd. I agree we should try to solve it >>> better. >>> Perhaps expanding it before or during schedule2. >> Right, NEON scheduling is tricky, it seems that our instruction >> itineraries are not expressible enough for such complex pipelines. > > I think we should be able to handle at least the true dependency > cases. Instruction latency is a function of both defining instruction > and the use. cc'ing David for his comments. Whoops, I'm too used to MLs with reply-to set to the list address. Anyway, I misread the commit, but separating vmla.f32 into vmul.f32 + vadd.f32 doesn't help either. The vmul+vadd chain will have the result available the same cycle as worst-case vmla: 9 cycles after issue. Ignoring pipelined instructions, the vmul+vadd will stall for 4 cycles between the instructions and 4 cycles after, equal to the 8 cycles for vmla in the same situation. The note in the ref manual about vmla/vmls is just calling attention to the special forwarding path available to only those instructions; the 8 cycle stall is what would always happen otherwise based on the cycle timings. Thus even without modeling the special behaviour of vmla it's always better to use it: it'll always be at least as fast as a separate vmul +vadd. This applies to the integer versions as well. From natebegeman at mac.com Mon Nov 2 21:30:51 2009 From: natebegeman at mac.com (Nate Begeman) Date: Tue, 03 Nov 2009 03:30:51 -0000 Subject: [llvm-commits] [llvm] r85857 - /llvm/trunk/include/llvm/Target/TargetSelectionDAG.td Message-ID: <200911030330.nA33UpH5004693@zion.cs.uiuc.edu> Author: sampo Date: Mon Nov 2 21:30:51 2009 New Revision: 85857 URL: http://llvm.org/viewvc/llvm-project?rev=85857&view=rev Log: Add a couple more target nodes Modified: llvm/trunk/include/llvm/Target/TargetSelectionDAG.td Modified: llvm/trunk/include/llvm/Target/TargetSelectionDAG.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetSelectionDAG.td?rev=85857&r1=85856&r2=85857&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetSelectionDAG.td (original) +++ llvm/trunk/include/llvm/Target/TargetSelectionDAG.td Mon Nov 2 21:30:51 2009 @@ -329,6 +329,8 @@ def fsqrt : SDNode<"ISD::FSQRT" , SDTFPUnaryOp>; def fsin : SDNode<"ISD::FSIN" , SDTFPUnaryOp>; def fcos : SDNode<"ISD::FCOS" , SDTFPUnaryOp>; +def fexp2 : SDNode<"ISD::FEXP2" , SDTFPUnaryOp>; +def flog2 : SDNode<"ISD::FLOG2" , SDTFPUnaryOp>; def frint : SDNode<"ISD::FRINT" , SDTFPUnaryOp>; def ftrunc : SDNode<"ISD::FTRUNC" , SDTFPUnaryOp>; def fceil : SDNode<"ISD::FCEIL" , SDTFPUnaryOp>; From clattner at apple.com Mon Nov 2 21:40:06 2009 From: clattner at apple.com (Chris Lattner) Date: Mon, 2 Nov 2009 19:40:06 -0800 Subject: [llvm-commits] [llvm] r85738 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/phi.ll In-Reply-To: <4AEEEB73.9070101@free.fr> References: <200911012007.nA1K78eB012267@zion.cs.uiuc.edu> <4AEEEB73.9070101@free.fr> Message-ID: On Nov 2, 2009, at 6:23 AM, Duncan Sands wrote: > Hi Chris, > >> - LoadAlignment = std::max(LoadAlignment, LI->getAlignment()); >> + LoadAlignment = std::min(LoadAlignment, LI->getAlignment()); > > if one alignment is zero and the other is not, then zero (the > minimum) may > be the wrong result. On the other hand, if one is zero and the > other is > over aligned (bigger than the ABI alignment), then zero is the right > thing, > not the bigger alignment. You need target data to get this right. The transformation explicitly does not transform the case when some loads have an alignment specified and others do. It only xforms when all are specified or none are. -Chris From sabre at nondot.org Mon Nov 2 21:42:52 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 03 Nov 2009 03:42:52 -0000 Subject: [llvm-commits] [llvm] r85858 - in /llvm/trunk: include/llvm/Support/StandardPasses.h lib/Transforms/Scalar/SCCP.cpp Message-ID: <200911030342.nA33gq5U005301@zion.cs.uiuc.edu> Author: lattner Date: Mon Nov 2 21:42:51 2009 New Revision: 85858 URL: http://llvm.org/viewvc/llvm-project?rev=85858&view=rev Log: turn IPSCCP back on now that the iterator invalidation bug is fixed. Modified: llvm/trunk/include/llvm/Support/StandardPasses.h llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Modified: llvm/trunk/include/llvm/Support/StandardPasses.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/StandardPasses.h?rev=85858&r1=85857&r2=85858&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/StandardPasses.h (original) +++ llvm/trunk/include/llvm/Support/StandardPasses.h Mon Nov 2 21:42:51 2009 @@ -99,7 +99,6 @@ if (UnitAtATime) { PM->add(createGlobalOptimizerPass()); // Optimize out global vars - PM->add(createIPConstantPropagationPass()); // IP CP PM->add(createIPSCCPPass()); // IP SCCP PM->add(createDeadArgEliminationPass()); // Dead argument elimination } Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCP.cpp?rev=85858&r1=85857&r2=85858&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SCCP.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Mon Nov 2 21:42:51 2009 @@ -25,7 +25,6 @@ #include "llvm/Instructions.h" #include "llvm/Pass.h" #include "llvm/Analysis/ConstantFolding.h" -#include "llvm/Analysis/MemoryBuiltins.h" #include "llvm/Analysis/ValueTracking.h" #include "llvm/Transforms/Utils/Local.h" #include "llvm/Target/TargetData.h" @@ -227,7 +226,6 @@ /// and out of the specified function (which cannot have its address taken), /// this method must be called. void AddTrackedFunction(Function *F) { - assert(F->hasLocalLinkage() && "Can only track internal functions!"); // Add an entry, F -> undef. if (const StructType *STy = dyn_cast(F->getReturnType())) { for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) @@ -380,11 +378,9 @@ // instruction that was just changed state somehow. Based on this // information, we need to update the specified user of this instruction. // - void OperandChangedState(User *U) { - // Only instructions use other variable values! - Instruction &I = cast(*U); - if (BBExecutable.count(I.getParent())) // Inst is executable? - visit(I); + void OperandChangedState(Instruction *I) { + if (BBExecutable.count(I->getParent())) // Inst is executable? + visit(*I); } /// RemoveFromOverdefinedPHIs - If I has any entries in the @@ -428,8 +424,6 @@ void visitLoadInst (LoadInst &I); void visitGetElementPtrInst(GetElementPtrInst &I); void visitCallInst (CallInst &I) { - if (isFreeCall(&I)) - return; visitCallSite(CallSite::get(&I)); } void visitInvokeInst (InvokeInst &II) { @@ -656,19 +650,19 @@ markConstant(&PN, OperandVal); // Acquire operand value } + + + void SCCPSolver::visitReturnInst(ReturnInst &I) { if (I.getNumOperands() == 0) return; // ret void Function *F = I.getParent()->getParent(); + // If we are tracking the return value of this function, merge it in. - if (!F->hasLocalLinkage()) - return; - if (!TrackedRetVals.empty()) { DenseMap::iterator TFRVI = TrackedRetVals.find(F); - if (TFRVI != TrackedRetVals.end() && - !TFRVI->second.isOverdefined()) { + if (TFRVI != TrackedRetVals.end()) { mergeInValue(TFRVI->second, F, getValueState(I.getOperand(0))); return; } @@ -1163,14 +1157,14 @@ // The common case is that we aren't tracking the callee, either because we // are not doing interprocedural analysis or the callee is indirect, or is // external. Handle these cases first. - if (F == 0 || !F->hasLocalLinkage()) { + if (F == 0 || F->isDeclaration()) { CallOverdefined: // Void return and not tracking callee, just bail. if (I->getType()->isVoidTy()) return; // Otherwise, if we have a single return value case, and if the function is // a declaration, maybe we can constant fold it. - if (!isa(I->getType()) && F && F->isDeclaration() && + if (F && F->isDeclaration() && !isa(I->getType()) && canConstantFoldCallTo(F)) { SmallVector Operands; @@ -1234,7 +1228,7 @@ // common path above. goto CallOverdefined; } - + // Finally, if this is the first call to the function hit, mark its entry // block executable. MarkBlockExecutable(F->begin()); @@ -1243,6 +1237,8 @@ CallSite::arg_iterator CAI = CS.arg_begin(); for (Function::arg_iterator AI = F->arg_begin(), E = F->arg_end(); AI != E; ++AI, ++CAI) { + // If this argument is byval, and if the function is not readonly, there + // will be an implicit copy formed of the input aggregate. if (AI->hasByValAttr() && !F->onlyReadsMemory()) { markOverdefined(AI); continue; @@ -1272,7 +1268,8 @@ // for (Value::use_iterator UI = I->use_begin(), E = I->use_end(); UI != E; ++UI) - OperandChangedState(*UI); + if (Instruction *I = dyn_cast(*UI)) + OperandChangedState(I); } // Process the instruction work list. @@ -1291,7 +1288,8 @@ if (!getValueState(I).isOverdefined()) for (Value::use_iterator UI = I->use_begin(), E = I->use_end(); UI != E; ++UI) - OperandChangedState(*UI); + if (Instruction *I = dyn_cast(*UI)) + OperandChangedState(I); } // Process the basic block work list. @@ -1649,14 +1647,25 @@ if (F->isDeclaration()) continue; - if (!F->hasLocalLinkage() || AddressIsTaken(F)) { - Solver.MarkBlockExecutable(F->begin()); - for (Function::arg_iterator AI = F->arg_begin(), E = F->arg_end(); - AI != E; ++AI) - Solver.markOverdefined(AI); - } else { + // If this is a strong or ODR definition of this function, then we can + // propagate information about its result into callsites of it. + if (!F->mayBeOverridden() && + !isa(F->getReturnType())) Solver.AddTrackedFunction(F); - } + + // If this function only has direct calls that we can see, we can track its + // arguments and return value aggressively, and can assume it is not called + // unless we see evidence to the contrary. + if (F->hasLocalLinkage() && !AddressIsTaken(F)) + continue; + + // Assume the function is called. + Solver.MarkBlockExecutable(F->begin()); + + // Assume nothing about the incoming arguments. + for (Function::arg_iterator AI = F->arg_begin(), E = F->arg_end(); + AI != E; ++AI) + Solver.markOverdefined(AI); } // Loop over global variables. We inform the solver about any internal global @@ -1804,16 +1813,21 @@ // TODO: Process multiple value ret instructions also. const DenseMap &RV = Solver.getTrackedRetVals(); for (DenseMap::const_iterator I = RV.begin(), - E = RV.end(); I != E; ++I) - if (!I->second.isOverdefined() && - !I->first->getReturnType()->isVoidTy()) { - Function *F = I->first; - for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) - if (ReturnInst *RI = dyn_cast(BB->getTerminator())) - if (!isa(RI->getOperand(0))) - RI->setOperand(0, UndefValue::get(F->getReturnType())); - } - + E = RV.end(); I != E; ++I) { + Function *F = I->first; + if (I->second.isOverdefined() || F->getReturnType()->isVoidTy()) + continue; + + // We can only do this if we know that nothing else can call the function. + if (!F->hasLocalLinkage() || AddressIsTaken(F)) + continue; + + for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) + if (ReturnInst *RI = dyn_cast(BB->getTerminator())) + if (!isa(RI->getOperand(0))) + RI->setOperand(0, UndefValue::get(F->getReturnType())); + } + // If we infered constant or undef values for globals variables, we can delete // the global and any stores that remain to it. const DenseMap &TG = Solver.getTrackedGlobals(); From kremenek at apple.com Mon Nov 2 22:01:54 2009 From: kremenek at apple.com (Ted Kremenek) Date: Tue, 03 Nov 2009 04:01:54 -0000 Subject: [llvm-commits] [llvm] r85859 - /llvm/trunk/lib/Transforms/Utils/CMakeLists.txt Message-ID: <200911030401.nA341svN006074@zion.cs.uiuc.edu> Author: kremenek Date: Mon Nov 2 22:01:53 2009 New Revision: 85859 URL: http://llvm.org/viewvc/llvm-project?rev=85859&view=rev Log: Alphabetize. Modified: llvm/trunk/lib/Transforms/Utils/CMakeLists.txt Modified: llvm/trunk/lib/Transforms/Utils/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/CMakeLists.txt?rev=85859&r1=85858&r2=85859&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/CMakeLists.txt (original) +++ llvm/trunk/lib/Transforms/Utils/CMakeLists.txt Mon Nov 2 22:01:53 2009 @@ -13,6 +13,7 @@ LCSSA.cpp Local.cpp LoopSimplify.cpp + LoopUnroll.cpp LowerInvoke.cpp LowerSwitch.cpp Mem2Reg.cpp @@ -21,7 +22,6 @@ SSI.cpp SimplifyCFG.cpp UnifyFunctionExitNodes.cpp - LoopUnroll.cpp ValueMapper.cpp ) From kremenek at apple.com Mon Nov 2 22:06:58 2009 From: kremenek at apple.com (Ted Kremenek) Date: Tue, 03 Nov 2009 04:06:58 -0000 Subject: [llvm-commits] [llvm] r85860 - /llvm/trunk/utils/UpdateCMakeLists.pl Message-ID: <200911030406.nA346wTK006274@zion.cs.uiuc.edu> Author: kremenek Date: Mon Nov 2 22:06:58 2009 New Revision: 85860 URL: http://llvm.org/viewvc/llvm-project?rev=85860&view=rev Log: Support updating 'llvm_add_target' lists as well. Modified: llvm/trunk/utils/UpdateCMakeLists.pl Modified: llvm/trunk/utils/UpdateCMakeLists.pl URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/UpdateCMakeLists.pl?rev=85860&r1=85859&r2=85860&view=diff ============================================================================== --- llvm/trunk/utils/UpdateCMakeLists.pl (original) +++ llvm/trunk/utils/UpdateCMakeLists.pl Mon Nov 2 22:06:58 2009 @@ -68,7 +68,7 @@ while() { if (!$foundLibrary) { print OUT $_; - if (/^add_clang_library\(/ || /^add_llvm_library\(/) { + if (/^add_clang_library\(/ || /^add_llvm_library\(/ || /^add_llvm_target\(/) { $foundLibrary = 1; EmitCMakeList($dir); } From kremenek at apple.com Mon Nov 2 22:14:14 2009 From: kremenek at apple.com (Ted Kremenek) Date: Tue, 03 Nov 2009 04:14:14 -0000 Subject: [llvm-commits] [llvm] r85861 - /llvm/trunk/lib/Target/ARM/CMakeLists.txt Message-ID: <200911030414.nA34EEf2006597@zion.cs.uiuc.edu> Author: kremenek Date: Mon Nov 2 22:14:12 2009 New Revision: 85861 URL: http://llvm.org/viewvc/llvm-project?rev=85861&view=rev Log: Update CMake file. Modified: llvm/trunk/lib/Target/ARM/CMakeLists.txt Modified: llvm/trunk/lib/Target/ARM/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/CMakeLists.txt?rev=85861&r1=85860&r2=85861&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/CMakeLists.txt (original) +++ llvm/trunk/lib/Target/ARM/CMakeLists.txt Mon Nov 2 22:14:12 2009 @@ -17,15 +17,16 @@ ARMCodeEmitter.cpp ARMConstantIslandPass.cpp ARMConstantPoolValue.cpp - ARMInstrInfo.cpp ARMISelDAGToDAG.cpp ARMISelLowering.cpp + ARMInstrInfo.cpp ARMJITInfo.cpp ARMLoadStoreOptimizer.cpp ARMMCAsmInfo.cpp ARMRegisterInfo.cpp ARMSubtarget.cpp ARMTargetMachine.cpp + NEONMoveFix.cpp NEONPreAllocPass.cpp Thumb1InstrInfo.cpp Thumb1RegisterInfo.cpp From kennethuil at gmail.com Mon Nov 2 22:26:45 2009 From: kennethuil at gmail.com (Kenneth Uildriks) Date: Mon, 2 Nov 2009 22:26:45 -0600 Subject: [llvm-commits] [PATCH] Make opt default to not adding a target data string, and update tests In-Reply-To: <06A3392E-15EA-4760-A3D9-B3B9CEDE6F67@apple.com> References: <400d33ea0911021113h7385041fo34c1fafd3ca38b19@mail.gmail.com> <06A3392E-15EA-4760-A3D9-B3B9CEDE6F67@apple.com> Message-ID: <400d33ea0911022026y163086b5h64b7ff0d75a969e3@mail.gmail.com> On Mon, Nov 2, 2009 at 9:16 PM, Dan Gohman wrote: > Hello, > > If I read this correctly, this makes the NoDefaultDataLayout > option unused. Is that right? If so, please remove the option > completely. > > Otherwise, this patch looks fine. Thanks for updating all those tests! > > Dan > Here's the revised patch. -------------- next part -------------- A non-text attachment was scrubbed... Name: tests-opt2.patch Type: text/x-patch Size: 36572 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091102/1b8ed399/attachment.bin From clattner at apple.com Mon Nov 2 22:29:17 2009 From: clattner at apple.com (Chris Lattner) Date: Mon, 2 Nov 2009 20:29:17 -0800 Subject: [llvm-commits] [llvm] r85814 - /llvm/trunk/lib/Analysis/MemoryBuiltins.cpp In-Reply-To: <200911021851.nA2IpTYX014735@zion.cs.uiuc.edu> References: <200911021851.nA2IpTYX014735@zion.cs.uiuc.edu> Message-ID: On Nov 2, 2009, at 10:51 AM, Victor Hernandez wrote: > URL: http://llvm.org/viewvc/llvm-project?rev=85814&view=rev > Log: > Set bit instead of calling pow() to compute 2 << n Thanks Victor, > +++ llvm/trunk/lib/Analysis/MemoryBuiltins.cpp Mon Nov 2 12:51:28 > 2009 > @@ -16,6 +16,7 @@ > #include "llvm/Constants.h" > #include "llvm/Instructions.h" > #include "llvm/Module.h" > +#include "llvm/ADT/APInt.h" You don't need this #include, please remove it. > @@ -156,15 +157,22 @@ > return Op1; > } > if (Opcode == Instruction::Shl) { > - ConstantInt* Op1Int = dyn_cast(Op1); > - if (!Op1Int) return NULL; > - Value* Op1Pow = ConstantInt::get(Op1->getType(), (uint64_t) > - pow(2.0, (double) Op1Int- > >getZExtValue())); > + ConstantInt* Op1CI = dyn_cast(Op1); > + if (!Op1CI) return NULL; > + > + APInt Op1Int = Op1CI->getValue(); > + unsigned Op1Width = Op1Int.getBitWidth(); > + // check for overflow > + if (Op1Int.getActiveBits() > 64 || Op1Int.getZExtValue() > > Op1Width) > + return NULL; If the shift overflows, the original code is undefined. Please just use the APInt::getLimitedValue method (with the bitwidth as the argument) to handle this. You'll end up with much more elegant code. Finally, please use: ConstantInt *Op1CI instead of: ConstantInt* Op1CI With Op1CI and many other variables in this file. Thanks, -Chris > + Value* Op1Pow = ConstantInt::get(Context, > + APInt(Op1Width, 0).set > (Op1Int.getZExtValue())); > + > if (Op0 == ElementSize || (FoldedElementSize && Op0 == > FoldedElementSize)) > // ArraySize << log2(ElementSize) > return Op1Pow; > if (Op1Pow == ElementSize || > - (FoldedElementSize && Op1Pow == FoldedElementSize)) > + (FoldedElementSize && Op1Pow == FoldedElementSize)) > // ElementSize << log2(ArraySize) > return Op0; > } > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From gohman at apple.com Mon Nov 2 22:59:23 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 02 Nov 2009 20:59:23 -0800 Subject: [llvm-commits] [PATCH] Make opt default to not adding a target data string, and update tests In-Reply-To: <400d33ea0911022026y163086b5h64b7ff0d75a969e3@mail.gmail.com> References: <400d33ea0911021113h7385041fo34c1fafd3ca38b19@mail.gmail.com> <06A3392E-15EA-4760-A3D9-B3B9CEDE6F67@apple.com> <400d33ea0911022026y163086b5h64b7ff0d75a969e3@mail.gmail.com> Message-ID: Looks good; please apply. Thanks! Dan On Nov 2, 2009, at 8:26 PM, Kenneth Uildriks wrote: > On Mon, Nov 2, 2009 at 9:16 PM, Dan Gohman wrote: >> Hello, >> >> If I read this correctly, this makes the NoDefaultDataLayout >> option unused. Is that right? If so, please remove the option >> completely. >> >> Otherwise, this patch looks fine. Thanks for updating all those >> tests! >> >> Dan >> > > Here's the revised patch. > From sabre at nondot.org Mon Nov 2 23:33:46 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 03 Nov 2009 05:33:46 -0000 Subject: [llvm-commits] [llvm] r85863 - /llvm/trunk/lib/Transforms/Utils/Local.cpp Message-ID: <200911030533.nA35XklX009860@zion.cs.uiuc.edu> Author: lattner Date: Mon Nov 2 23:33:46 2009 New Revision: 85863 URL: http://llvm.org/viewvc/llvm-project?rev=85863&view=rev Log: remove a isFreeCall check: it is a callinst that can write to memory already. Modified: llvm/trunk/lib/Transforms/Utils/Local.cpp Modified: llvm/trunk/lib/Transforms/Utils/Local.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/Local.cpp?rev=85863&r1=85862&r2=85863&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/Local.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/Local.cpp Mon Nov 2 23:33:46 2009 @@ -24,7 +24,6 @@ #include "llvm/ADT/SmallPtrSet.h" #include "llvm/Analysis/ConstantFolding.h" #include "llvm/Analysis/DebugInfo.h" -#include "llvm/Analysis/MemoryBuiltins.h" #include "llvm/Analysis/ProfileInfo.h" #include "llvm/Target/TargetData.h" #include "llvm/Support/GetElementPtrTypeIterator.h" @@ -60,8 +59,8 @@ // If we see a free or a call which may write to memory (i.e. which might do // a free) the pointer could be marked invalid. - if (isFreeCall(BBI) || (isa(BBI) && BBI->mayWriteToMemory() && - !isa(BBI))) + if (isa(BBI) && BBI->mayWriteToMemory() && + !isa(BBI)) return false; if (LoadInst *LI = dyn_cast(BBI)) { From sabre at nondot.org Mon Nov 2 23:34:52 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 03 Nov 2009 05:34:52 -0000 Subject: [llvm-commits] [llvm] r85865 - /llvm/trunk/lib/Analysis/CaptureTracking.cpp Message-ID: <200911030534.nA35Yqj5009914@zion.cs.uiuc.edu> Author: lattner Date: Mon Nov 2 23:34:51 2009 New Revision: 85865 URL: http://llvm.org/viewvc/llvm-project?rev=85865&view=rev Log: remove a check of isFreeCall: the argument to free is already nocapture so the generic call code works fine. Modified: llvm/trunk/lib/Analysis/CaptureTracking.cpp Modified: llvm/trunk/lib/Analysis/CaptureTracking.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/CaptureTracking.cpp?rev=85865&r1=85864&r2=85865&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/CaptureTracking.cpp (original) +++ llvm/trunk/lib/Analysis/CaptureTracking.cpp Mon Nov 2 23:34:51 2009 @@ -17,7 +17,6 @@ //===----------------------------------------------------------------------===// #include "llvm/Analysis/CaptureTracking.h" -#include "llvm/Analysis/MemoryBuiltins.h" #include "llvm/Instructions.h" #include "llvm/Value.h" #include "llvm/ADT/SmallSet.h" @@ -49,9 +48,6 @@ switch (I->getOpcode()) { case Instruction::Call: - if (isFreeCall(I)) - // Freeing a pointer does not cause it to be captured. - break; case Instruction::Invoke: { CallSite CS = CallSite::get(I); // Not captured if the callee is readonly, doesn't return a copy through From sabre at nondot.org Mon Nov 2 23:35:19 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 03 Nov 2009 05:35:19 -0000 Subject: [llvm-commits] [llvm] r85866 - /llvm/trunk/lib/Analysis/AliasSetTracker.cpp Message-ID: <200911030535.nA35ZJHk009942@zion.cs.uiuc.edu> Author: lattner Date: Mon Nov 2 23:35:19 2009 New Revision: 85866 URL: http://llvm.org/viewvc/llvm-project?rev=85866&view=rev Log: remove unneeded checks of isFreeCall Modified: llvm/trunk/lib/Analysis/AliasSetTracker.cpp Modified: llvm/trunk/lib/Analysis/AliasSetTracker.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/AliasSetTracker.cpp?rev=85866&r1=85865&r2=85866&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/AliasSetTracker.cpp (original) +++ llvm/trunk/lib/Analysis/AliasSetTracker.cpp Mon Nov 2 23:35:19 2009 @@ -13,7 +13,6 @@ #include "llvm/Analysis/AliasSetTracker.h" #include "llvm/Analysis/AliasAnalysis.h" -#include "llvm/Analysis/MemoryBuiltins.h" #include "llvm/Instructions.h" #include "llvm/IntrinsicInst.h" #include "llvm/Pass.h" @@ -305,13 +304,6 @@ bool AliasSetTracker::add(CallSite CS) { - Instruction* Inst = CS.getInstruction(); - if (isFreeCall(Inst)) { - bool NewPtr; - addPointer(Inst->getOperand(1), ~0, AliasSet::Mods, NewPtr); - return NewPtr; - } - if (isa(CS.getInstruction())) return true; // Ignore DbgInfo Intrinsics. if (AA.doesNotAccessMemory(CS)) @@ -435,14 +427,6 @@ } bool AliasSetTracker::remove(CallSite CS) { - Instruction* Inst = CS.getInstruction(); - if (isFreeCall(Inst)) { - AliasSet *AS = findAliasSetForPointer(Inst->getOperand(1), ~0); - if (!AS) return false; - remove(*AS); - return true; - } - if (AA.doesNotAccessMemory(CS)) return false; // doesn't alias anything From clattner at apple.com Mon Nov 2 23:36:14 2009 From: clattner at apple.com (Chris Lattner) Date: Mon, 2 Nov 2009 21:36:14 -0800 Subject: [llvm-commits] [llvm] r85176 - in /llvm/trunk: examples/BrainF/ include/llvm-c/ include/llvm/ include/llvm/Analysis/ include/llvm/Support/ include/llvm/Transforms/ lib/Analysis/ lib/Analysis/IPA/ lib/AsmParser/ lib/Bitcode/Writer/ lib/CodeGen/SelectionDAG/ lib/ExecutionEngine/Interpreter/ lib/Target/CBackend/ lib/Target/CppBackend/ lib/Target/MSIL/ lib/Transforms/Scalar/ lib/Transforms/Utils/ lib/VMCore/ In-Reply-To: <200910262343.n9QNhpYj012068@zion.cs.uiuc.edu> References: <200910262343.n9QNhpYj012068@zion.cs.uiuc.edu> Message-ID: On Oct 26, 2009, at 4:43 PM, Victor Hernandez wrote: > Author: hernande > Date: Mon Oct 26 18:43:48 2009 > New Revision: 85176 > > URL: http://llvm.org/viewvc/llvm-project?rev=85176&view=rev > Log: > Remove FreeInst. > Remove LowerAllocations pass. > Update some more passes to treate free calls just like they were > treating FreeInst. Thanks Victor, > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/VMCore/Instruction.cpp (original) > +// Code here matches isFreeCall from MallocHelper, which is not in > VMCore. > +static bool isFreeCall(const Value* I) { > + const CallInst *CI = dyn_cast(I); > + if (!CI) > + return false; > + > + const Module* M = CI->getParent()->getParent()->getParent(); > + Function *FreeFunc = M->getFunction("free"); > + > + if (CI->getOperand(0) != FreeFunc) > + return false; Please use something like this, which would be much more efficient: const CallInst *CI = dyn_cast(I); if (!CI) return false; Function *Callee = CI->getCalledFunction(); if (Callee == 0 || !Callee->isDeclaration() || Callee->getName() != "free") return false; > + > + // Check free prototype. > + // FIXME: workaround for PR5130, this will be obsolete when a > nobuiltin > + // attribute will exist. > + const FunctionType *FTy = FreeFunc->getFunctionType(); > + if (FTy->getReturnType() != Type::getVoidTy(M->getContext())) Use ->isVoidTy() instead of comparing against a newly constructed type. > /// mayReadFromMemory - Return true if this instruction may read > memory. > /// > bool Instruction::mayReadFromMemory() const { > switch (getOpcode()) { > default: return false; > - case Instruction::Free: > case Instruction::VAArg: > case Instruction::Load: > return true; > case Instruction::Call: > + if (isFreeCall(this)) > + return true; > return !cast(this)->doesNotAccessMemory(); This call to isFreeCall isn't needed because the existing code works for it. > case Instruction::Invoke: > return !cast(this)->doesNotAccessMemory(); > @@ -326,11 +352,12 @@ > bool Instruction::mayWriteToMemory() const { > switch (getOpcode()) { > default: return false; > - case Instruction::Free: > case Instruction::Store: > case Instruction::VAArg: > return true; > case Instruction::Call: > + if (isFreeCall(this)) > + return true; > return !cast(this)->onlyReadsMemory(); Likewise. I removed some other ones that are not needed. -Chris From evan.cheng at apple.com Mon Nov 2 23:50:58 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 03 Nov 2009 05:50:58 -0000 Subject: [llvm-commits] [llvm] r85869 - /llvm/trunk/lib/Target/ARM/ARMRegisterInfo.td Message-ID: <200911030550.nA35owXu010430@zion.cs.uiuc.edu> Author: evancheng Date: Mon Nov 2 23:50:57 2009 New Revision: 85869 URL: http://llvm.org/viewvc/llvm-project?rev=85869&view=rev Log: Add QPR_8 as a superreg class of SPR_8 and DPR_8. Modified: llvm/trunk/lib/Target/ARM/ARMRegisterInfo.td Modified: llvm/trunk/lib/Target/ARM/ARMRegisterInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMRegisterInfo.td?rev=85869&r1=85868&r2=85869&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMRegisterInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMRegisterInfo.td Mon Nov 2 23:50:57 2009 @@ -357,6 +357,13 @@ let SubRegClassList = [SPR, SPR, SPR, SPR, DPR_VFP2, DPR_VFP2]; } +// Subset of QPR that have DPR_8 and SPR_8 subregs. +def QPR_8 : RegisterClass<"ARM", [v16i8, v8i16, v4i32, v2i64, v4f32, v2f64], + 128, + [Q0, Q1, Q2, Q3]> { + let SubRegClassList = [SPR_8, SPR_8, SPR_8, SPR_8, DPR_8, DPR_8]; +} + // Condition code registers. def CCR : RegisterClass<"ARM", [i32], 32, [CPSR]>; From evan.cheng at apple.com Mon Nov 2 23:51:39 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 03 Nov 2009 05:51:39 -0000 Subject: [llvm-commits] [llvm] r85870 - /llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp Message-ID: <200911030551.nA35pdm3010458@zion.cs.uiuc.edu> Author: evancheng Date: Mon Nov 2 23:51:39 2009 New Revision: 85870 URL: http://llvm.org/viewvc/llvm-project?rev=85870&view=rev Log: Clean up copyRegToReg. Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp?rev=85870&r1=85869&r2=85870&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp Mon Nov 2 23:51:39 2009 @@ -620,28 +620,12 @@ if (I != MBB.end()) DL = I->getDebugLoc(); if (DestRC != SrcRC) { - // Allow DPR / DPR_VFP2 / DPR_8 cross-class copies - // Allow QPR / QPR_VFP2 cross-class copies - if (DestRC == ARM::DPRRegisterClass) { - if (SrcRC == ARM::DPR_VFP2RegisterClass || - SrcRC == ARM::DPR_8RegisterClass) { - } else - return false; - } else if (DestRC == ARM::DPR_VFP2RegisterClass) { - if (SrcRC == ARM::DPRRegisterClass || - SrcRC == ARM::DPR_8RegisterClass) { - } else - return false; - } else if (DestRC == ARM::DPR_8RegisterClass) { - if (SrcRC == ARM::DPRRegisterClass || - SrcRC == ARM::DPR_VFP2RegisterClass) { - } else - return false; - } else if ((DestRC == ARM::QPRRegisterClass && - SrcRC == ARM::QPR_VFP2RegisterClass) || - (DestRC == ARM::QPR_VFP2RegisterClass && - SrcRC == ARM::QPRRegisterClass)) { - } else + if (DestRC->getSize() != SrcRC->getSize()) + return false; + + // Allow DPR / DPR_VFP2 / DPR_8 cross-class copies. + // Allow QPR / QPR_VFP2 / QPR_8 cross-class copies. + if (DestRC->getSize() != 8 && DestRC->getSize() != 16) return false; } @@ -651,17 +635,18 @@ } else if (DestRC == ARM::SPRRegisterClass) { AddDefaultPred(BuildMI(MBB, I, DL, get(ARM::FCPYS), DestReg) .addReg(SrcReg)); + } else if (DestRC == ARM::DPRRegisterClass) { + AddDefaultPred(BuildMI(MBB, I, DL, get(ARM::FCPYD), DestReg) + .addReg(SrcReg)); } else if (DestRC == ARM::DPR_VFP2RegisterClass || DestRC == ARM::DPR_8RegisterClass || SrcRC == ARM::DPR_VFP2RegisterClass || SrcRC == ARM::DPR_8RegisterClass) { // Always use neon reg-reg move if source or dest is NEON-only regclass. BuildMI(MBB, I, DL, get(ARM::VMOVD), DestReg).addReg(SrcReg); - } else if (DestRC == ARM::DPRRegisterClass) { - AddDefaultPred(BuildMI(MBB, I, DL, get(ARM::FCPYD), DestReg) - .addReg(SrcReg)); } else if (DestRC == ARM::QPRRegisterClass || - DestRC == ARM::QPR_VFP2RegisterClass) { + DestRC == ARM::QPR_VFP2RegisterClass || + DestRC == ARM::QPR_8RegisterClass) { BuildMI(MBB, I, DL, get(ARM::VMOVQ), DestReg).addReg(SrcReg); } else { return false; @@ -736,7 +721,8 @@ .addFrameIndex(FI).addImm(0).addMemOperand(MMO)); } else { assert((RC == ARM::QPRRegisterClass || - RC == ARM::QPR_VFP2RegisterClass) && "Unknown regclass!"); + RC == ARM::QPR_VFP2RegisterClass || + RC == ARM::QPR_8RegisterClass) && "Unknown regclass!"); // FIXME: Neon instructions should support predicates BuildMI(MBB, I, DL, get(ARM::VLDRQ), DestReg).addFrameIndex(FI).addImm(0). addMemOperand(MMO); From evan.cheng at apple.com Mon Nov 2 23:52:54 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 03 Nov 2009 05:52:54 -0000 Subject: [llvm-commits] [llvm] r85871 - in /llvm/trunk: lib/Target/ARM/ARMBaseRegisterInfo.cpp test/CodeGen/ARM/2009-10-02-NEONSubregsBug.ll test/CodeGen/ARM/2009-11-01-NeonMoves.ll test/CodeGen/Thumb2/2009-08-04-SubregLoweringBug.ll test/CodeGen/Thumb2/cross-rc-coalescing-2.ll Message-ID: <200911030552.nA35qsRU010526@zion.cs.uiuc.edu> Author: evancheng Date: Mon Nov 2 23:52:54 2009 New Revision: 85871 URL: http://llvm.org/viewvc/llvm-project?rev=85871&view=rev Log: Fix PR5367. QPR_8 is the super regclass of DPR_8 and SPR_8. Added: llvm/trunk/test/CodeGen/ARM/2009-10-02-NEONSubregsBug.ll Modified: llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp llvm/trunk/test/CodeGen/ARM/2009-11-01-NeonMoves.ll llvm/trunk/test/CodeGen/Thumb2/2009-08-04-SubregLoweringBug.ll llvm/trunk/test/CodeGen/Thumb2/cross-rc-coalescing-2.ll Modified: llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp?rev=85871&r1=85870&r2=85871&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp Mon Nov 2 23:52:54 2009 @@ -257,7 +257,6 @@ ARMBaseRegisterInfo::getMatchingSuperRegClass(const TargetRegisterClass *A, const TargetRegisterClass *B, unsigned SubIdx) const { -#if 0 switch (SubIdx) { default: return 0; case 1: @@ -266,19 +265,27 @@ case 4: // S sub-registers. if (A->getSize() == 8) { + if (B == &ARM::SPR_8RegClass) + return &ARM::DPR_8RegClass; + assert(B == &ARM::SPRRegClass && "Expecting SPR register class!"); if (A == &ARM::DPR_8RegClass) return A; return &ARM::DPR_VFP2RegClass; } assert(A->getSize() == 16 && "Expecting a Q register class!"); + if (B == &ARM::SPR_8RegClass) + return &ARM::QPR_8RegClass; return &ARM::QPR_VFP2RegClass; case 5: case 6: // D sub-registers. + if (B == &ARM::DPR_VFP2RegClass) + return &ARM::QPR_VFP2RegClass; + if (B == &ARM::DPR_8RegClass) + return &ARM::QPR_8RegClass; return A; } -#endif return 0; } Added: llvm/trunk/test/CodeGen/ARM/2009-10-02-NEONSubregsBug.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/2009-10-02-NEONSubregsBug.ll?rev=85871&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/2009-10-02-NEONSubregsBug.ll (added) +++ llvm/trunk/test/CodeGen/ARM/2009-10-02-NEONSubregsBug.ll Mon Nov 2 23:52:54 2009 @@ -0,0 +1,63 @@ +; RUN: llc -mtriple=armv7-eabi -mcpu=cortex-a8 -enable-unsafe-fp-math < %s +; PR5367 + +define arm_aapcs_vfpcc void @_Z27Benchmark_SceDualQuaternionPvm(i8* nocapture %pBuffer, i32 %numItems) nounwind { +entry: + br i1 undef, label %return, label %bb + +bb: ; preds = %bb, %entry + %0 = load float* undef, align 4 ; [#uses=1] + %1 = load float* null, align 4 ; [#uses=1] + %2 = insertelement <4 x float> undef, float undef, i32 1 ; <<4 x float>> [#uses=1] + %3 = insertelement <4 x float> %2, float %1, i32 2 ; <<4 x float>> [#uses=2] + %4 = insertelement <4 x float> undef, float %0, i32 2 ; <<4 x float>> [#uses=1] + %5 = insertelement <4 x float> %4, float 0.000000e+00, i32 3 ; <<4 x float>> [#uses=4] + %6 = fsub <4 x float> zeroinitializer, %3 ; <<4 x float>> [#uses=1] + %7 = shufflevector <4 x float> %6, <4 x float> undef, <4 x i32> zeroinitializer ; <<4 x float>> [#uses=2] + %8 = shufflevector <4 x float> %5, <4 x float> undef, <2 x i32> ; <<2 x float>> [#uses=1] + %9 = shufflevector <2 x float> %8, <2 x float> undef, <4 x i32> ; <<4 x float>> [#uses=2] + %10 = fmul <4 x float> %7, %9 ; <<4 x float>> [#uses=1] + %11 = shufflevector <4 x float> zeroinitializer, <4 x float> undef, <4 x i32> zeroinitializer ; <<4 x float>> [#uses=1] + %12 = shufflevector <4 x float> %5, <4 x float> undef, <2 x i32> ; <<2 x float>> [#uses=2] + %13 = shufflevector <2 x float> %12, <2 x float> undef, <4 x i32> zeroinitializer ; <<4 x float>> [#uses=1] + %14 = fmul <4 x float> %11, %13 ; <<4 x float>> [#uses=1] + %15 = fadd <4 x float> %10, %14 ; <<4 x float>> [#uses=1] + %16 = shufflevector <2 x float> %12, <2 x float> undef, <4 x i32> ; <<4 x float>> [#uses=1] + %17 = fadd <4 x float> %15, zeroinitializer ; <<4 x float>> [#uses=1] + %18 = shufflevector <4 x float> %17, <4 x float> zeroinitializer, <4 x i32> ; <<4 x float>> [#uses=1] + %19 = fmul <4 x float> %7, %16 ; <<4 x float>> [#uses=1] + %20 = fadd <4 x float> %19, zeroinitializer ; <<4 x float>> [#uses=1] + %21 = shufflevector <4 x float> %3, <4 x float> undef, <4 x i32> ; <<4 x float>> [#uses=1] + %22 = shufflevector <4 x float> %21, <4 x float> undef, <4 x i32> zeroinitializer ; <<4 x float>> [#uses=1] + %23 = fmul <4 x float> %22, %9 ; <<4 x float>> [#uses=1] + %24 = fadd <4 x float> %20, %23 ; <<4 x float>> [#uses=1] + %25 = shufflevector <4 x float> %18, <4 x float> %24, <4 x i32> ; <<4 x float>> [#uses=1] + %26 = shufflevector <4 x float> %25, <4 x float> undef, <4 x i32> ; <<4 x float>> [#uses=1] + %27 = fmul <4 x float> %26, ; <<4 x float>> [#uses=1] + %28 = fsub <4 x float> , %5 ; <<4 x float>> [#uses=1] + %29 = tail call <4 x float> @llvm.arm.neon.vrecpe.v4f32(<4 x float> zeroinitializer) nounwind ; <<4 x float>> [#uses=1] + %30 = fmul <4 x float> zeroinitializer, %29 ; <<4 x float>> [#uses=1] + %31 = fmul <4 x float> %30, ; <<4 x float>> [#uses=1] + %32 = shufflevector <4 x float> %27, <4 x float> undef, <4 x i32> zeroinitializer ; <<4 x float>> [#uses=1] + %33 = shufflevector <4 x float> %28, <4 x float> undef, <2 x i32> ; <<2 x float>> [#uses=1] + %34 = shufflevector <2 x float> %33, <2 x float> undef, <4 x i32> ; <<4 x float>> [#uses=1] + %35 = fmul <4 x float> %32, %34 ; <<4 x float>> [#uses=1] + %36 = fadd <4 x float> %35, zeroinitializer ; <<4 x float>> [#uses=1] + %37 = shufflevector <4 x float> %5, <4 x float> undef, <4 x i32> ; <<4 x float>> [#uses=1] + %38 = shufflevector <4 x float> %37, <4 x float> undef, <4 x i32> zeroinitializer ; <<4 x float>> [#uses=1] + %39 = fmul <4 x float> zeroinitializer, %38 ; <<4 x float>> [#uses=1] + %40 = fadd <4 x float> %36, %39 ; <<4 x float>> [#uses=1] + %41 = fadd <4 x float> %40, zeroinitializer ; <<4 x float>> [#uses=1] + %42 = shufflevector <4 x float> undef, <4 x float> %41, <4 x i32> ; <<4 x float>> [#uses=1] + %43 = fmul <4 x float> %42, %31 ; <<4 x float>> [#uses=1] + store float undef, float* undef, align 4 + store float 0.000000e+00, float* null, align 4 + %44 = extractelement <4 x float> %43, i32 1 ; [#uses=1] + store float %44, float* undef, align 4 + br i1 undef, label %return, label %bb + +return: ; preds = %bb, %entry + ret void +} + +declare <4 x float> @llvm.arm.neon.vrecpe.v4f32(<4 x float>) nounwind readnone Modified: llvm/trunk/test/CodeGen/ARM/2009-11-01-NeonMoves.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/2009-11-01-NeonMoves.ll?rev=85871&r1=85870&r2=85871&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/2009-11-01-NeonMoves.ll (original) +++ llvm/trunk/test/CodeGen/ARM/2009-11-01-NeonMoves.ll Mon Nov 2 23:52:54 2009 @@ -1,4 +1,4 @@ -; RUN: llc -mcpu=cortex-a8 < %s | grep vmov | count 2 +; RUN: llc -mcpu=cortex-a8 < %s | grep vmov | count 1 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64" target triple = "armv7-eabi" Modified: llvm/trunk/test/CodeGen/Thumb2/2009-08-04-SubregLoweringBug.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/2009-08-04-SubregLoweringBug.ll?rev=85871&r1=85870&r2=85871&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/2009-08-04-SubregLoweringBug.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/2009-08-04-SubregLoweringBug.ll Mon Nov 2 23:52:54 2009 @@ -1,7 +1,6 @@ ; RUN: llc < %s -mtriple=thumbv7-apple-darwin9 -mattr=+neon -arm-use-neon-fp ; RUN: llc < %s -mtriple=thumbv7-apple-darwin9 -mattr=+neon -arm-use-neon-fp | not grep fcpys ; rdar://7117307 -; XFAIL: * %struct.Hosp = type { i32, i32, i32, %struct.List, %struct.List, %struct.List, %struct.List } %struct.List = type { %struct.List*, %struct.Patient*, %struct.List* } Modified: llvm/trunk/test/CodeGen/Thumb2/cross-rc-coalescing-2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/cross-rc-coalescing-2.ll?rev=85871&r1=85870&r2=85871&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/cross-rc-coalescing-2.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/cross-rc-coalescing-2.ll Mon Nov 2 23:52:54 2009 @@ -1,5 +1,4 @@ ; RUN: llc < %s -mtriple=thumbv7-apple-darwin9 -mcpu=cortex-a8 | grep fcpys | count 4 -; XFAIL: * define arm_apcscc void @fht(float* nocapture %fz, i16 signext %n) nounwind { entry: From jyasskin at google.com Tue Nov 3 00:29:37 2009 From: jyasskin at google.com (Jeffrey Yasskin) Date: Tue, 03 Nov 2009 06:29:37 -0000 Subject: [llvm-commits] [llvm] r85873 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Message-ID: <200911030629.nA36Tb2S011758@zion.cs.uiuc.edu> Author: jyasskin Date: Tue Nov 3 00:29:36 2009 New Revision: 85873 URL: http://llvm.org/viewvc/llvm-project?rev=85873&view=rev Log: Fix a funky "declared with greater visibility than the type of its field" warning from gcc by removing VISIBILITY_HIDDEN attributes. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=85873&r1=85872&r2=85873&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Tue Nov 3 00:29:36 2009 @@ -124,7 +124,7 @@ //===----------------------------------------------------------------------===// /// DbgVariable - This class is used to track local variable information. /// -class VISIBILITY_HIDDEN DbgVariable { +class DbgVariable { DIVariable Var; // Variable Descriptor. unsigned FrameIndex; // Variable frame index. bool InlinedFnVar; // Variable for an inlined function. @@ -142,7 +142,7 @@ /// DbgScope - This class is used to track scope information. /// class DbgConcreteScope; -class VISIBILITY_HIDDEN DbgScope { +class DbgScope { DbgScope *Parent; // Parent to this scope. DIDescriptor Desc; // Debug info descriptor for scope. // FIXME use WeakVH for Desc. From bob.wilson at apple.com Tue Nov 3 00:29:56 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 03 Nov 2009 06:29:56 -0000 Subject: [llvm-commits] [llvm] r85874 - /llvm/trunk/lib/Target/ARM/ARMInstrThumb.td Message-ID: <200911030629.nA36TuQg011780@zion.cs.uiuc.edu> Author: bwilson Date: Tue Nov 3 00:29:56 2009 New Revision: 85874 URL: http://llvm.org/viewvc/llvm-project?rev=85874&view=rev Log: For Thumb indirect branches, use "mov pc, reg" which does not switch between ARM/Thumb modes and does not require the low bit of the target address to be set for Thumb. Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb.td?rev=85874&r1=85873&r2=85874&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb.td Tue Nov 3 00:29:56 2009 @@ -182,7 +182,7 @@ // Indirect branches let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in { - def tBRIND : TI<(outs), (ins GPR:$dst), IIC_Br, "bx\t$dst", + def tBRIND : TI<(outs), (ins GPR:$dst), IIC_Br, "mov\tpc, $dst", [(brind GPR:$dst)]>; } From evan.cheng at apple.com Tue Nov 3 01:08:08 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 03 Nov 2009 07:08:08 -0000 Subject: [llvm-commits] [llvm] r85878 - /llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp Message-ID: <200911030708.nA3788L7013010@zion.cs.uiuc.edu> Author: evancheng Date: Tue Nov 3 01:08:08 2009 New Revision: 85878 URL: http://llvm.org/viewvc/llvm-project?rev=85878&view=rev Log: Trim unnecessary include. Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp?rev=85878&r1=85877&r2=85878&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp Tue Nov 3 01:08:08 2009 @@ -23,7 +23,6 @@ #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/MachineJumpTableInfo.h" #include "llvm/CodeGen/MachineMemOperand.h" -#include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/CodeGen/PseudoSourceValue.h" #include "llvm/MC/MCAsmInfo.h" #include "llvm/Support/CommandLine.h" From daniel at zuster.org Tue Nov 3 01:26:38 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 03 Nov 2009 07:26:38 -0000 Subject: [llvm-commits] [llvm] r85882 - /llvm/trunk/utils/lit/TestRunner.py Message-ID: <200911030726.nA37Qc82013917@zion.cs.uiuc.edu> Author: ddunbar Date: Tue Nov 3 01:26:38 2009 New Revision: 85882 URL: http://llvm.org/viewvc/llvm-project?rev=85882&view=rev Log: lit: Update Clang's test style to use XFAIL: and XTARGET: lines that match LLVM's tests. Modified: llvm/trunk/utils/lit/TestRunner.py Modified: llvm/trunk/utils/lit/TestRunner.py URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/TestRunner.py?rev=85882&r1=85881&r2=85882&view=diff ============================================================================== --- llvm/trunk/utils/lit/TestRunner.py (original) +++ llvm/trunk/utils/lit/TestRunner.py Tue Nov 3 01:26:38 2009 @@ -333,7 +333,24 @@ return executeCommand(command, cwd=cwd, env=test.config.environment) -def parseIntegratedTestScript(test, xfailHasColon, requireAndAnd): +def isExpectedFail(xfails, xtargets, target_triple): + # Check if any xfail matches this target. + for item in xfails: + if item == '*' or item in target_triple: + break + else: + return False + + # If so, see if it is expected to pass on this target. + # + # FIXME: Rename XTARGET to something that makes sense, like XPASS. + for item in xtargets: + if item == '*' or item in target_triple: + return False + + return True + +def parseIntegratedTestScript(test, requireAndAnd): """parseIntegratedTestScript - Scan an LLVM/Clang style integrated test script and extract the lines to 'RUN' as well as 'XFAIL' and 'XTARGET' information. The RUN lines also will have variable substitution performed. @@ -377,12 +394,9 @@ script[-1] = script[-1][:-1] + ln else: script.append(ln) - elif xfailHasColon and 'XFAIL:' in ln: + elif 'XFAIL:' in ln: items = ln[ln.index('XFAIL:') + 6:].split(',') xfails.extend([s.strip() for s in items]) - elif not xfailHasColon and 'XFAIL' in ln: - items = ln[ln.index('XFAIL') + 5:].split(',') - xfails.extend([s.strip() for s in items]) elif 'XTARGET:' in ln: items = ln[ln.index('XTARGET:') + 8:].split(',') xtargets.extend([s.strip() for s in items]) @@ -421,7 +435,8 @@ # Strip off '&&' script[i] = ln[:-2] - return script,xfails,xtargets,tmpBase,execdir + isXFail = isExpectedFail(xfails, xtargets, test.suite.config.target_triple) + return script,isXFail,tmpBase,execdir def formatTestOutput(status, out, err, exitCode, script): output = StringIO.StringIO() @@ -444,11 +459,11 @@ if test.config.unsupported: return (Test.UNSUPPORTED, 'Test is unsupported') - res = parseIntegratedTestScript(test, True, False) + res = parseIntegratedTestScript(test, False) if len(res) == 2: return res - script, xfails, xtargets, tmpBase, execdir = res + script, isXFail, tmpBase, execdir = res if litConfig.noExecute: return (Test.PASS, '') @@ -460,19 +475,6 @@ if len(res) == 2: return res - isXFail = False - for item in xfails: - if item == '*' or item in test.suite.config.target_triple: - isXFail = True - break - - # If this is XFAIL, see if it is expected to pass on this target. - if isXFail: - for item in xtargets: - if item == '*' or item in test.suite.config.target_triple: - isXFail = False - break - out,err,exitCode = res if isXFail: ok = exitCode != 0 @@ -490,11 +492,11 @@ if test.config.unsupported: return (Test.UNSUPPORTED, 'Test is unsupported') - res = parseIntegratedTestScript(test, False, requireAndAnd) + res = parseIntegratedTestScript(test, requireAndAnd) if len(res) == 2: return res - script, xfails, xtargets, tmpBase, execdir = res + script, isXFail, tmpBase, execdir = res if litConfig.noExecute: return (Test.PASS, '') @@ -510,7 +512,7 @@ return res out,err,exitCode = res - if xfails: + if isXFail: ok = exitCode != 0 status = (Test.XPASS, Test.XFAIL)[ok] else: From daniel at zuster.org Tue Nov 3 01:49:22 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 03 Nov 2009 07:49:22 -0000 Subject: [llvm-commits] [llvm] r85884 - /llvm/trunk/include/llvm/Support/StandardPasses.h Message-ID: <200911030749.nA37nM1l014684@zion.cs.uiuc.edu> Author: ddunbar Date: Tue Nov 3 01:49:22 2009 New Revision: 85884 URL: http://llvm.org/viewvc/llvm-project?rev=85884&view=rev Log: Speculatively redisable IPSCCP, I think its still breaking things. Modified: llvm/trunk/include/llvm/Support/StandardPasses.h Modified: llvm/trunk/include/llvm/Support/StandardPasses.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/StandardPasses.h?rev=85884&r1=85883&r2=85884&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/StandardPasses.h (original) +++ llvm/trunk/include/llvm/Support/StandardPasses.h Tue Nov 3 01:49:22 2009 @@ -99,7 +99,8 @@ if (UnitAtATime) { PM->add(createGlobalOptimizerPass()); // Optimize out global vars - PM->add(createIPSCCPPass()); // IP SCCP + PM->add(createIPConstantPropagationPass()); // IP CP +// PM->add(createIPSCCPPass()); // IP SCCP PM->add(createDeadArgEliminationPass()); // Dead argument elimination } PM->add(createInstructionCombiningPass()); // Clean up after IPCP & DAE From baldrick at free.fr Tue Nov 3 03:40:08 2009 From: baldrick at free.fr (Duncan Sands) Date: Tue, 03 Nov 2009 09:40:08 -0000 Subject: [llvm-commits] [llvm] r85893 - /llvm/trunk/include/llvm/Support/StandardPasses.h Message-ID: <200911030940.nA39e9ZV000318@zion.cs.uiuc.edu> Author: baldrick Date: Tue Nov 3 03:40:08 2009 New Revision: 85893 URL: http://llvm.org/viewvc/llvm-project?rev=85893&view=rev Log: Run the functionattrs pass after the inliner, and not before. This makes both logical sense (see below) and increases the number of functions marked readnone/readonly by about 1-2% in practice. The number of functions marked nocapture goes up by about 5-10%. The reason it makes sense is shown by the following example: if you run -functionattrs -inline on it, then no attributes are assigned. But if you instead run -inline -functionattrs then @f is marked readnone because the simplifications produced by the inliner eliminate the store. @x = external global i32 define void @w(i1 %b) { br i1 %b, label %write, label %return write: store i32 1, i32 *@x br label %return return: ret void } define void @f() { call void @w(i1 0) ret void } Modified: llvm/trunk/include/llvm/Support/StandardPasses.h Modified: llvm/trunk/include/llvm/Support/StandardPasses.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/StandardPasses.h?rev=85893&r1=85892&r2=85893&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/StandardPasses.h (original) +++ llvm/trunk/include/llvm/Support/StandardPasses.h Tue Nov 3 03:40:08 2009 @@ -107,13 +107,12 @@ PM->add(createCFGSimplificationPass()); // Clean up after IPCP & DAE // Start of CallGraph SCC passes. - if (UnitAtATime) { - if (HaveExceptions) - PM->add(createPruneEHPass()); // Remove dead EH info - PM->add(createFunctionAttrsPass()); // Set readonly/readnone attrs - } + if (UnitAtATime && HaveExceptions) + PM->add(createPruneEHPass()); // Remove dead EH info if (InliningPass) PM->add(InliningPass); + if (UnitAtATime) + PM->add(createFunctionAttrsPass()); // Set readonly/readnone attrs if (OptimizationLevel > 2) PM->add(createArgumentPromotionPass()); // Scalarize uninlined fn args From baldrick at free.fr Tue Nov 3 05:11:09 2009 From: baldrick at free.fr (Duncan Sands) Date: Tue, 03 Nov 2009 12:11:09 +0100 Subject: [llvm-commits] [llvm-gcc-4.2] r85835 - in /llvm-gcc-4.2/trunk/gcc: llvm-convert.cpp llvm-internal.h In-Reply-To: <200911022244.nA2MiNFd026188@zion.cs.uiuc.edu> References: <200911022244.nA2MiNFd026188@zion.cs.uiuc.edu> Message-ID: <4AF00FCD.7030508@free.fr> Hi Bob, thanks for doing this. > +Constant *TreeToLLVM::EmitLV_LABEL_DECL(tree exp) { > + // GCC kindly diverts labels for unreachable basic blocks to reachable blocks, > + // so we are not obliged to output unreachable blocks even if the original > + // code took the address of one. this comment is only really relevant to dragonegg, which outputs basic basic blocks in dom order (in order to translate phi nodes), and as a side-effect only outputs reachable basic blocks. Ciao, Duncan. From chandlerc at google.com Tue Nov 3 05:27:55 2009 From: chandlerc at google.com (Chandler Carruth) Date: Tue, 3 Nov 2009 03:27:55 -0800 Subject: [llvm-commits] PATCH: Use absolute paths rather than canonical paths in lit Message-ID: <74c447500911030327n7b98266ev8894339f2f0530b3@mail.gmail.com> Hey Daniel, This patch switches to use absolute paths instead of canonical paths in lit's test suite walking. Because the walking pattern is sensitive to file layout and walks up the paths to find test suite definitions, it is useful to allow that tree to be synthesized using symlinks. Seem reasonable? -------------- next part -------------- A non-text attachment was scrubbed... Name: no-realpath.patch Type: application/octet-stream Size: 986 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091103/8e164c30/attachment.obj From benny.kra at googlemail.com Tue Nov 3 06:52:51 2009 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Tue, 03 Nov 2009 12:52:51 -0000 Subject: [llvm-commits] [llvm] r85896 - /llvm/trunk/lib/Transforms/IPO/LowerSetJmp.cpp Message-ID: <200911031252.nA3CqpG3008133@zion.cs.uiuc.edu> Author: d0k Date: Tue Nov 3 06:52:50 2009 New Revision: 85896 URL: http://llvm.org/viewvc/llvm-project?rev=85896&view=rev Log: Eliminate some temporaries. Modified: llvm/trunk/lib/Transforms/IPO/LowerSetJmp.cpp Modified: llvm/trunk/lib/Transforms/IPO/LowerSetJmp.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/LowerSetJmp.cpp?rev=85896&r1=85895&r2=85896&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/LowerSetJmp.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/LowerSetJmp.cpp Tue Nov 3 06:52:50 2009 @@ -47,9 +47,6 @@ #include "llvm/Transforms/Utils/Local.h" #include "llvm/ADT/DepthFirstIterator.h" #include "llvm/ADT/Statistic.h" -#include "llvm/ADT/StringExtras.h" -#include "llvm/ADT/VectorExtras.h" -#include "llvm/ADT/SmallVector.h" #include using namespace llvm; @@ -108,7 +105,7 @@ void TransformLongJmpCall(CallInst* Inst); void TransformSetJmpCall(CallInst* Inst); - bool IsTransformableFunction(const std::string& Name); + bool IsTransformableFunction(StringRef Name); public: static char ID; // Pass identification, replacement for typeid LowerSetJmp() : ModulePass(&ID) {} @@ -249,13 +246,8 @@ // "llvm.{setjmp,longjmp}" functions and none of the setjmp/longjmp error // handling functions (beginning with __llvm_sjljeh_...they don't throw // exceptions). -bool LowerSetJmp::IsTransformableFunction(const std::string& Name) { - std::string SJLJEh("__llvm_sjljeh"); - - if (Name.size() > SJLJEh.size()) - return std::string(Name.begin(), Name.begin() + SJLJEh.size()) != SJLJEh; - - return true; +bool LowerSetJmp::IsTransformableFunction(StringRef Name) { + return !Name.startswith("__llvm_sjljeh_"); } // TransformLongJmpCall - Transform a longjmp call into a call to the @@ -263,8 +255,7 @@ // throwing the exception for us. void LowerSetJmp::TransformLongJmpCall(CallInst* Inst) { - const Type* SBPTy = - Type::getInt8PtrTy(Inst->getContext()); + const Type* SBPTy = Type::getInt8PtrTy(Inst->getContext()); // Create the call to "__llvm_sjljeh_throw_longjmp". This takes the // same parameters as "longjmp", except that the buffer is cast to a @@ -272,10 +263,8 @@ // Inst's uses and doesn't get a name. CastInst* CI = new BitCastInst(Inst->getOperand(1), SBPTy, "LJBuf", Inst); - SmallVector Args; - Args.push_back(CI); - Args.push_back(Inst->getOperand(2)); - CallInst::Create(ThrowLongJmp, Args.begin(), Args.end(), "", Inst); + Value *Args[] = { CI, Inst->getOperand(2) }; + CallInst::Create(ThrowLongJmp, Args, Args + 2, "", Inst); SwitchValuePair& SVP = SwitchValMap[Inst->getParent()->getParent()]; @@ -390,11 +379,11 @@ Type::getInt8PtrTy(Inst->getContext()); CastInst* BufPtr = new BitCastInst(Inst->getOperand(1), SBPTy, "SBJmpBuf", Inst); - std::vector Args = - make_vector(GetSetJmpMap(Func), BufPtr, - ConstantInt::get(Type::getInt32Ty(Inst->getContext()), - SetJmpIDMap[Func]++), 0); - CallInst::Create(AddSJToMap, Args.begin(), Args.end(), "", Inst); + Value *Args[] = { + GetSetJmpMap(Func), BufPtr, + ConstantInt::get(Type::getInt32Ty(Inst->getContext()), SetJmpIDMap[Func]++) + }; + CallInst::Create(AddSJToMap, Args, Args + 3, "", Inst); // We are guaranteed that there are no values live across basic blocks // (because we are "not in SSA form" yet), but there can still be values live From baldrick at free.fr Tue Nov 3 07:26:22 2009 From: baldrick at free.fr (Duncan Sands) Date: Tue, 03 Nov 2009 13:26:22 -0000 Subject: [llvm-commits] [dragonegg] r85897 - /dragonegg/trunk/gcc-patches/i386_static.diff Message-ID: <200911031326.nA3DQM8T009486@zion.cs.uiuc.edu> Author: baldrick Date: Tue Nov 3 07:26:21 2009 New Revision: 85897 URL: http://llvm.org/viewvc/llvm-project?rev=85897&view=rev Log: Add prototypes, so that gcc successfully bootstraps with the patch applied. Modified: dragonegg/trunk/gcc-patches/i386_static.diff Modified: dragonegg/trunk/gcc-patches/i386_static.diff URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/gcc-patches/i386_static.diff?rev=85897&r1=85896&r2=85897&view=diff ============================================================================== --- dragonegg/trunk/gcc-patches/i386_static.diff (original) +++ dragonegg/trunk/gcc-patches/i386_static.diff Tue Nov 3 07:26:21 2009 @@ -1,39 +1,45 @@ Index: mainline/gcc/config/i386/i386.c =================================================================== ---- mainline.orig/gcc/config/i386/i386.c 2009-09-28 10:25:38.639572451 +0200 -+++ mainline/gcc/config/i386/i386.c 2009-09-28 10:58:43.498571902 +0200 -@@ -4898,7 +4898,7 @@ +--- mainline.orig/gcc/config/i386/i386.c 2009-11-02 17:21:03.257325701 +0100 ++++ mainline/gcc/config/i386/i386.c 2009-11-03 13:26:05.384538824 +0100 +@@ -4943,7 +4943,8 @@ case, we return the original mode and warn ABI change if CUM isn't NULL. */ -static enum machine_mode ++extern enum machine_mode type_natural_mode (const_tree, CUMULATIVE_ARGS *); +enum machine_mode type_natural_mode (const_tree type, CUMULATIVE_ARGS *cum) { enum machine_mode mode = TYPE_MODE (type); -@@ -5029,7 +5029,7 @@ +@@ -5074,7 +5075,9 @@ See the x86-64 PS ABI for details. */ -static int ++extern int classify_argument (enum machine_mode, const_tree, ++ enum x86_64_reg_class [MAX_CLASSES], int); +int classify_argument (enum machine_mode mode, const_tree type, enum x86_64_reg_class classes[MAX_CLASSES], int bit_offset) { -@@ -5409,7 +5409,7 @@ +@@ -5454,7 +5457,9 @@ /* Examine the argument and return set number of register required in each class. Return 0 iff parameter should be passed in memory. */ -static int ++extern int examine_argument (enum machine_mode, const_tree, int, ++ int *, int *); +int examine_argument (enum machine_mode mode, const_tree type, int in_return, int *int_nregs, int *sse_nregs) { -@@ -6089,7 +6089,7 @@ +@@ -6134,7 +6139,8 @@ /* Return true when TYPE should be 128bit aligned for 32bit argument passing ABI. */ -static bool ++extern bool contains_aligned_value_p (tree); +bool contains_aligned_value_p (tree type) { From criswell at cs.uiuc.edu Tue Nov 3 09:16:49 2009 From: criswell at cs.uiuc.edu (John Criswell) Date: Tue, 3 Nov 2009 09:16:49 -0600 Subject: [llvm-commits] CVS: llvm-www/safecode/Azulmedia.css people.html pubs.html links.html index.html Message-ID: <200911031516.nA3FGnga016706@maute.cs.uiuc.edu> Changes in directory llvm-www/safecode: Azulmedia.css added (r1.1) people.html added (r1.1) pubs.html added (r1.1) links.html added (r1.1) index.html updated: 1.25 -> 1.26 --- Log message: Adding new SAFECode web site. --- Diffs of the changes: (+862 -115) Azulmedia.css | 322 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ index.html | 232 +++++++++++++++++++++-------------------- links.html | 103 ++++++++++++++++++ people.html | 140 +++++++++++++++++++++++++ pubs.html | 180 ++++++++++++++++++++++++++++++++ 5 files changed, 862 insertions(+), 115 deletions(-) Index: llvm-www/safecode/Azulmedia.css diff -c /dev/null llvm-www/safecode/Azulmedia.css:1.1 *** /dev/null Tue Nov 3 09:16:08 2009 --- llvm-www/safecode/Azulmedia.css Tue Nov 3 09:15:58 2009 *************** *** 0 **** --- 1,322 ---- + /******************************************** + AUTHOR: Erwin Aligam + WEBSITE: http://www.styleshout.com/ + TEMPLATE NAME: Azulmedia + TEMPLATE CODE: S-0008 + VERSION: 2.0 + *******************************************/ + + /******************************************** + HTML ELEMENTS + ********************************************/ + + /* top elements */ + * { + padding: 0; margin: 0; + } + body { + margin: 0; padding: 0; + font: normal .80em/1.6em Verdana, Tahoma, sans-serif; + color: #BDBDBD; + background: #000; + text-align: center; + } + /* links */ + a { + color: #FFF; + background-color: inherit; + text-decoration: none; + } + a:hover { + color: #FFF; + background-color: inherit; + text-decoration: underline; + } + + /* headers */ + h1, h2, h3 { + font: normal 1.3em 'Trebuchet MS', Arial, Sans-serif; + color: #FFF; + } + h1 { font-size: 1.6em; } + h2 { font-size: 1.4em; text-transform:uppercase; font-weight: bold;} + h3 { font-size: 1.3em; font-weight: bold; } + + p, h1, h2, h3 { + margin: 0; + padding: 10px 15px; + } + + ul, ol { + margin: 10px 30px; + padding: 0 15px; + color: #FFF; + } + + /* images */ + img { + border: 3px solid #555; + } + img.no-border { + border: none; + } + img.float-right { + margin: 5px 0px 5px 15px; + } + img.float-left { + margin: 5px 15px 5px 0px; + } + a img { + border: 3px solid #555; + } + a:hover img { + border: 3px solid #CCC !important; /* IE fix*/ + border: 3px solid #555; + } + + code { + margin: 5px 0; + padding: 10px; + text-align: left; + display: block; + overflow: auto; + font: 500 1em/1.5em 'Lucida Console', 'courier new', monospace; + /* white-space: pre; */ + background: #0A1646; + } + acronym { + cursor: help; + border-bottom: 1px solid #777; + } + blockquote { + margin: 15px; + padding: 0 0 0 20px; + background: #0A1646; + font: bold 1.3em/1.5em 'Trebuchet MS', Sans-serif; + } + + /* form elements */ + form { + margin: 10px 15px; + padding: 0; + background: #0A1646; + } + label { + display:block; + font-weight:bold; + margin:5px 0; + } + input { + padding: 2px; + border:1px solid #eee; + font: normal 1em Verdana, sans-serif; + color:#777; + } + textarea { + width: 250px; + padding:2px; + font: normal 1em Verdana, sans-serif; + border:1px solid #eee; + height:100px; + display:block; + color:#777; + } + input.button { + margin: 0; + font: bold 1em Arial, Sans-serif; + border: 1px solid #CCC; + background: #FFF; + padding: 2px 3px; + color: #333; + } + + /* search form */ + .searchform form{ + background-color: transparent; + border: none; + margin: 0; padding: 0; + } + .searchform input.textbox { + margin: 0; + width: 145px; + border: 1px solid #777; + background: #FFF; + color: #333; + height: 14px; + vertical-align: top; + } + .searchform input.button { + margin: 0; + padding: 2px 3px; + font: bold 12px Arial, Sans-serif; + background: #FFF; + border: 1px solid #f2f2f2; + color: #333; + width: 65px; + vertical-align: top; + } + + /*********************** + LAYOUT + ************************/ + #wrap { + background: #212B5C url(images/bg.jpg) repeat-x 0 0; + margin: 20px auto 0 auto; + text-align: left; + border-color: #444; + border-style: solid; + border-width: 1px 1px 5px 1px; + } + #wrap, #footer-wrap { + width: 84%; + } + + /* header */ + #header { + position: relative; + height: 110px; + background: #7F8082 url(images/header-bg.jpg) repeat-x 0% 100%; + border-bottom: 5px solid #444; + } + #header h1#logo { + position: absolute; + top: 5px; left: 20px; + margin: 0; padding: 0; + font: bolder 50px 'Trebuchet MS', Arial, Sans-serif; + letter-spacing: -2px; + } + #header h2#slogan { + position: absolute; + top: 50px; left: 65px; + color: #FFF; + text-indent: 0px; + font: bold 18px Tahoma, 'Trebuchet MS', Sans-serif; + text-transform: none; + } + + /* content-wrap */ + #content-wrap { + clear: both; + margin: 0; padding: 0; + } + + /* box */ + .box { + margin: 10px 15px; + border: 1px solid #0A1646; + background-color: #1B2455; + } + + /* main */ + #main { + margin: 0 0 0 220px; + padding-top: 20px; + } + #main .box { + margin-left: 0; + } + + /* sidebar */ + #sidebar { + float: left; + width: 200px; + margin: 0; + padding-top: 20px; + } + #sidebar ul.sidemenu { + margin: 0 0 0 15px; padding: 0; + background: #242424; + border-top: 5px solid #444; + } + #sidebar ul.sidemenu li { + display: inline; + list-style: none; + } + #sidebar ul.sidemenu li a { + display: block; + padding: 5px 10px 5px 15px; + text-decoration: none; + color: #CCC; + font-weight: bold; + } + #sidebar ul.sidemenu li a:hover { + color: #333; + background: #A0A0A0; + } + + /* Footer */ + #footer-wrap { + clear: both; + color: #FFF; + background: #000; + margin: 0 auto; + padding: 0; + font-size: 88%; + } + #footer-wrap a { + text-decoration: none; + font-weight: bold; + color: #FFF; + } + #footer-wrap .footer-left{ + float: left; + width: 65%; + padding-bottom: 20px; + } + #footer-wrap .footer-right{ + float: right; + width: 30%; + padding-bottom: 20px; + } + + /* menu tabs */ + #header a { + position: absolute; + top: 20px; right: 20px; + margin:0; padding: 0; + list-style:none; + font: bold 1.3em 'Trebuchet MS', Tahoma, verdana, sans-serif; + height: 2.3em; + } + + #header ul { + position: absolute; + top: 20px; right: 20px; + margin:0; padding: 0; + list-style:none; + font: bold 1.3em 'Trebuchet MS', Tahoma, verdana, sans-serif; + height: 2.3em; + } + #header li { + display:inline; + margin:0; padding:0; + } + #header a { + float: left; + margin:0; + padding:3px 10px 2px 10px; + text-decoration:none; + color: #CCC; + } + #header #current a { + color: #FFF; + border-top: 5px solid #FFF; + } + /* end menu tabs */ + + /* alignment classes */ + .float-left { float: left; } + .float-right { float: right; } + .align-left { text-align: left; } + .align-right { text-align: right; } + + /* additional classes */ + .clear { clear: both; } + .gray { color: #A0A0A0; } + .comments { + text-align: right; + padding: 7px 15px; + margin: 20px 15px 15px 15px; + background: #0A1646; + } + Index: llvm-www/safecode/people.html diff -c /dev/null llvm-www/safecode/people.html:1.1 *** /dev/null Tue Nov 3 09:16:49 2009 --- llvm-www/safecode/people.html Tue Nov 3 09:15:58 2009 *************** *** 0 **** --- 1,140 ---- + + + + + + + + + + + + + + + + SAFECode + + + + + +
    + + + + +
    + + + +
    + +
    + +

    Project Members

    +
    + +

    Faculty

    + + + +

    Graduate Students

    +
      +
    • + John Criswell +
    • + +
    • + Andrew Lenharth +
    • + +
    • + Haohui Mai +
    • +
    + +

    Undergraduate Students

    +
      +
    • + Brice Lin +
    • +
    + +

    Graduate Student Alumni

    + + + +

    Undergraduate Student Alumni

    +
      +
    • + Billy Lau +
    • +
    +
    +
    + +
    + +
    + + +
    + + + + + + + Index: llvm-www/safecode/pubs.html diff -c /dev/null llvm-www/safecode/pubs.html:1.1 *** /dev/null Tue Nov 3 09:16:49 2009 --- llvm-www/safecode/pubs.html Tue Nov 3 09:15:58 2009 *************** *** 0 **** --- 1,180 ---- + + + + + + + + + + + + + + + + Publications + + + + + +
    + + + + +
    + + + +
    + + +
    + +

    SAFECode Publications

    +
    + +
    + + +
    + +

    Related Publications

    +
    + + + +
    +
    + +
    + +
    + + +
    + + + + + + + Index: llvm-www/safecode/links.html diff -c /dev/null llvm-www/safecode/links.html:1.1 *** /dev/null Tue Nov 3 09:16:49 2009 --- llvm-www/safecode/links.html Tue Nov 3 09:15:58 2009 *************** *** 0 **** --- 1,103 ---- + + + + + + + + + + + + + + + + Links + + + + + +
    + + + + +
    + + + +
    + + + +
    + +

    +

    + +
    + +
    + + +
    + + + + + + + Index: llvm-www/safecode/index.html diff -u llvm-www/safecode/index.html:1.25 llvm-www/safecode/index.html:1.26 --- llvm-www/safecode/index.html:1.25 Thu Oct 1 18:27:17 2009 +++ llvm-www/safecode/index.html Tue Nov 3 09:15:58 2009 @@ -1,124 +1,126 @@ - - + + + + - SAFE Code - - - -
    SAFECode
    + + + + + + -
    + -

    Static Analysis For safe Execution of Code

    +SAFECode + + -

    SAFECode project aims at providing -memory safety guarantees to programs written in unsafe languages like -C and C++. - -

    As a part of this project, we developed a relatively simple -compilation strategy that for standard C programs guarantees sound -semantics for an aggressive interprocedural pointer analysis (or -simpler ones), a call graph, and type information for a subset of -memory. These provide the foundation for sophisticated static analyses -to be applied to such programs with a guarantee of soundness. Our work -builds on a previously published transformation called Automatic Pool -Allocation to ensure that hard-to-detect memory errors (dangling pointer -references and certain array bounds errors) cannot invalidate the call -graph, points-to information or type information. A technical report -on this work is available from here -
    - -

    Second, we developed a backwards-compatible run-time array bounds -checking solution that has very low overhead. More information on this -work is available from - here -
    - -

    Finally, we also developed a novel technique that can detect dangling -pointer errors (accesses to freed memory) with low over head in some -applications. More information on this -work is available here - - -

    - - -

    Project Members

    - -

    Faculty

    - - - -

    Graduate Students

    - - - -

    Publications

    - - - -

    Funding

    - -

    This project is sponsored by the NSF Embedded Systems program under award -CCR-02-09202 and in part by an NSF CAREER award, EIA-0093426 and ONR, -N0004-02-0102.

    - -

    Links

    - - -
    -
    - Valid CSS! - Valid HTML 4.01! + + +
    + + + +
    + + + +
    + +
    + +

    Home

    +
    + +

    + The purpose of the SAFECode project is to enable program safety without + runtime checks and garbage collection, using static analysis when + possible and run-time checks when necessary. SAFECode defines a code + representation with minimal semantic restrictions designed to enable + static enforcement of safety, using aggressive compiler techniques + developed in this project. +

    + +

    + SAFECode is designed to provide the following safety guarantees: +

      +
    • + Array bounds checking (prevents pointers from overflowing from one + memory object into another) +
    • + +
    • + Loads and stores only access valid memory objects +
    • + +
    • + Type safety for a subset of memory objects proven to be type-safe +
    • + +
    • + Sound operational semantics in the face of dangling pointer + errors (i.e., all safety guarantees hold even when dangling pointers + are dereferenced). +
    • + +
    • + Optional dangling pointer detection (induces more overhead) +
    • +
    +

    +
    +
    + +
    + +
    + + + + + + + From criswell at cs.uiuc.edu Tue Nov 3 09:18:42 2009 From: criswell at cs.uiuc.edu (John Criswell) Date: Tue, 3 Nov 2009 09:18:42 -0600 Subject: [llvm-commits] CVS: llvm-www/safecode/images/ Message-ID: <200911031518.nA3FIgdK016775@maute.cs.uiuc.edu> Changes in directory llvm-www/safecode/images: --- Log message: Directory /home/vadve/shared/PublicCVS/llvm-www/safecode/images added to the repository --- Diffs of the changes: (+0 -0) 0 files changed From criswell at cs.uiuc.edu Tue Nov 3 09:19:36 2009 From: criswell at cs.uiuc.edu (John Criswell) Date: Tue, 3 Nov 2009 09:19:36 -0600 Subject: [llvm-commits] CVS: llvm-www/safecode/images/imark_bold.gif Message-ID: <200911031519.nA3FJa9v016820@maute.cs.uiuc.edu> Changes in directory llvm-www/safecode/images: imark_bold.gif added (r1.1) --- Log message: Adding University of Illinois logo and link. --- Diffs of the changes: (+0 -0) imark_bold.gif | 0 1 files changed Index: llvm-www/safecode/images/imark_bold.gif From kennethuil at gmail.com Tue Nov 3 09:25:21 2009 From: kennethuil at gmail.com (Kenneth Uildriks) Date: Tue, 03 Nov 2009 15:25:21 -0000 Subject: [llvm-commits] [llvm] r85899 - /llvm/trunk/include/llvm/Module.h Message-ID: <200911031525.nA3FPLE9014344@zion.cs.uiuc.edu> Author: kennethuil Date: Tue Nov 3 09:25:20 2009 New Revision: 85899 URL: http://llvm.org/viewvc/llvm-project?rev=85899&view=rev Log: Added a comment to a function that had none Modified: llvm/trunk/include/llvm/Module.h Modified: llvm/trunk/include/llvm/Module.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Module.h?rev=85899&r1=85898&r2=85899&view=diff ============================================================================== --- llvm/trunk/include/llvm/Module.h (original) +++ llvm/trunk/include/llvm/Module.h Tue Nov 3 09:25:20 2009 @@ -252,6 +252,7 @@ AttrListPtr AttributeList, const Type *RetTy, ...) END_WITH_NULL; + /// getOrInsertFunction - Same as above, but without the attributes. Constant *getOrInsertFunction(const StringRef &Name, const Type *RetTy, ...) END_WITH_NULL; From kennethuil at gmail.com Tue Nov 3 09:29:07 2009 From: kennethuil at gmail.com (Kenneth Uildriks) Date: Tue, 03 Nov 2009 15:29:07 -0000 Subject: [llvm-commits] [llvm] r85900 - in /llvm/trunk: test/Analysis/BasicAA/ test/Analysis/ScalarEvolution/ test/CodeGen/X86/ test/Transforms/ArgumentPromotion/ test/Transforms/DeadStoreElimination/ test/Transforms/GlobalOpt/ test/Transforms/IndVarSimplify/ test/Transforms/Inline/ test/Transforms/InstCombine/ test/Transforms/MemCpyOpt/ test/Transforms/ScalarRepl/ tools/opt/ Message-ID: <200911031529.nA3FT9HY014534@zion.cs.uiuc.edu> Author: kennethuil Date: Tue Nov 3 09:29:06 2009 New Revision: 85900 URL: http://llvm.org/viewvc/llvm-project?rev=85900&view=rev Log: Make opt default to not adding a target data string and update tests that depend on target data to supply it within the test Modified: llvm/trunk/test/Analysis/BasicAA/2006-03-03-BadArraySubscript.ll llvm/trunk/test/Analysis/BasicAA/2009-10-13-AtomicModRef.ll llvm/trunk/test/Analysis/BasicAA/featuretest.ll llvm/trunk/test/Analysis/BasicAA/global-size.ll llvm/trunk/test/Analysis/BasicAA/modref.ll llvm/trunk/test/Analysis/BasicAA/store-promote.ll llvm/trunk/test/Analysis/ScalarEvolution/2009-05-09-PointerEdgeCount.ll llvm/trunk/test/CodeGen/X86/vec_ins_extract.ll llvm/trunk/test/Transforms/ArgumentPromotion/aggregate-promote.ll llvm/trunk/test/Transforms/ArgumentPromotion/basictest.ll llvm/trunk/test/Transforms/ArgumentPromotion/byval.ll llvm/trunk/test/Transforms/ArgumentPromotion/chained.ll llvm/trunk/test/Transforms/ArgumentPromotion/control-flow2.ll llvm/trunk/test/Transforms/DeadStoreElimination/2008-07-28-load-store.ll llvm/trunk/test/Transforms/DeadStoreElimination/PartialStore.ll llvm/trunk/test/Transforms/DeadStoreElimination/context-sensitive.ll llvm/trunk/test/Transforms/DeadStoreElimination/simple.ll llvm/trunk/test/Transforms/GlobalOpt/globalsra-partial.ll llvm/trunk/test/Transforms/GlobalOpt/globalsra.ll llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-1.ll llvm/trunk/test/Transforms/IndVarSimplify/preserve-gep-loop-variant.ll llvm/trunk/test/Transforms/IndVarSimplify/preserve-gep-remainder.ll llvm/trunk/test/Transforms/Inline/basictest.ll llvm/trunk/test/Transforms/InstCombine/2003-11-13-ConstExprCastCall.ll llvm/trunk/test/Transforms/InstCombine/2007-10-10-EliminateMemCpy.ll llvm/trunk/test/Transforms/InstCombine/align-2d-gep.ll llvm/trunk/test/Transforms/InstCombine/align-addr.ll llvm/trunk/test/Transforms/InstCombine/align-inc.ll llvm/trunk/test/Transforms/InstCombine/alloca.ll llvm/trunk/test/Transforms/InstCombine/call.ll llvm/trunk/test/Transforms/InstCombine/cast-load-gep.ll llvm/trunk/test/Transforms/InstCombine/cast.ll llvm/trunk/test/Transforms/InstCombine/cast2.ll llvm/trunk/test/Transforms/InstCombine/constant-fold-gep.ll llvm/trunk/test/Transforms/InstCombine/fold-bin-operand.ll llvm/trunk/test/Transforms/InstCombine/fp-ret-bitcast.ll llvm/trunk/test/Transforms/InstCombine/loadstore-alignment.ll llvm/trunk/test/Transforms/InstCombine/ptr-int-cast.ll llvm/trunk/test/Transforms/MemCpyOpt/2008-03-13-ReturnSlotBitcast.ll llvm/trunk/test/Transforms/MemCpyOpt/align.ll llvm/trunk/test/Transforms/ScalarRepl/2003-05-29-ArrayFail.ll llvm/trunk/test/Transforms/ScalarRepl/2006-11-07-InvalidArrayPromote.ll llvm/trunk/test/Transforms/ScalarRepl/2008-06-05-loadstore-agg.ll llvm/trunk/test/Transforms/ScalarRepl/2008-09-22-vector-gep.ll llvm/trunk/test/Transforms/ScalarRepl/2009-03-04-MemCpyAlign.ll llvm/trunk/test/Transforms/ScalarRepl/DifferingTypes.ll llvm/trunk/test/Transforms/ScalarRepl/arraytest.ll llvm/trunk/test/Transforms/ScalarRepl/basictest.ll llvm/trunk/test/Transforms/ScalarRepl/bitfield-sroa.ll llvm/trunk/test/Transforms/ScalarRepl/copy-aggregate.ll llvm/trunk/test/Transforms/ScalarRepl/debuginfo.ll llvm/trunk/test/Transforms/ScalarRepl/load-store-aggregate.ll llvm/trunk/test/Transforms/ScalarRepl/memcpy-from-global.ll llvm/trunk/test/Transforms/ScalarRepl/not-a-vector.ll llvm/trunk/test/Transforms/ScalarRepl/union-fp-int.ll llvm/trunk/test/Transforms/ScalarRepl/union-packed.ll llvm/trunk/test/Transforms/ScalarRepl/vector_memcpy.ll llvm/trunk/test/Transforms/ScalarRepl/vector_promote.ll llvm/trunk/tools/opt/opt.cpp Modified: llvm/trunk/test/Analysis/BasicAA/2006-03-03-BadArraySubscript.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/BasicAA/2006-03-03-BadArraySubscript.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Analysis/BasicAA/2006-03-03-BadArraySubscript.ll (original) +++ llvm/trunk/test/Analysis/BasicAA/2006-03-03-BadArraySubscript.ll Tue Nov 3 09:29:06 2009 @@ -1,5 +1,6 @@ ; RUN: opt < %s -aa-eval -disable-output |& grep {2 no alias respon} ; TEST that A[1][0] may alias A[0][i]. +target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" define void @test(i32 %N) { entry: Modified: llvm/trunk/test/Analysis/BasicAA/2009-10-13-AtomicModRef.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/BasicAA/2009-10-13-AtomicModRef.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Analysis/BasicAA/2009-10-13-AtomicModRef.ll (original) +++ llvm/trunk/test/Analysis/BasicAA/2009-10-13-AtomicModRef.ll Tue Nov 3 09:29:06 2009 @@ -1,4 +1,5 @@ ; RUN: opt -gvn -instcombine -S < %s | FileCheck %s +target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" declare i8 @llvm.atomic.load.add.i8.p0i8(i8*, i8) Modified: llvm/trunk/test/Analysis/BasicAA/featuretest.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/BasicAA/featuretest.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Analysis/BasicAA/featuretest.ll (original) +++ llvm/trunk/test/Analysis/BasicAA/featuretest.ll Tue Nov 3 09:29:06 2009 @@ -2,6 +2,7 @@ ; determine, as noted in the comments. ; RUN: opt < %s -basicaa -gvn -instcombine -dce -S | not grep REMOVE +target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" @Global = external global { i32 } Modified: llvm/trunk/test/Analysis/BasicAA/global-size.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/BasicAA/global-size.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Analysis/BasicAA/global-size.ll (original) +++ llvm/trunk/test/Analysis/BasicAA/global-size.ll Tue Nov 3 09:29:06 2009 @@ -2,6 +2,7 @@ ; the global. ; RUN: opt < %s -basicaa -gvn -instcombine -S | not grep load +target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" @B = global i16 8 ; [#uses=2] Modified: llvm/trunk/test/Analysis/BasicAA/modref.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/BasicAA/modref.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Analysis/BasicAA/modref.ll (original) +++ llvm/trunk/test/Analysis/BasicAA/modref.ll Tue Nov 3 09:29:06 2009 @@ -1,4 +1,5 @@ ; RUN: opt < %s -basicaa -gvn -dse -S | FileCheck %s +target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" declare void @llvm.memset.i32(i8*, i8, i32, i32) declare void @llvm.memset.i8(i8*, i8, i8, i32) @@ -88,4 +89,4 @@ call void @llvm.lifetime.end(i64 10, i8* %P) ret void ; CHECK: ret void -} \ No newline at end of file +} Modified: llvm/trunk/test/Analysis/BasicAA/store-promote.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/BasicAA/store-promote.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Analysis/BasicAA/store-promote.ll (original) +++ llvm/trunk/test/Analysis/BasicAA/store-promote.ll Tue Nov 3 09:29:06 2009 @@ -3,6 +3,7 @@ ; two pointers, then the load should be hoisted, and the store sunk. ; RUN: opt < %s -basicaa -licm -S | FileCheck %s +target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" @A = global i32 7 ; [#uses=3] @B = global i32 8 ; [#uses=2] Modified: llvm/trunk/test/Analysis/ScalarEvolution/2009-05-09-PointerEdgeCount.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/2009-05-09-PointerEdgeCount.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Analysis/ScalarEvolution/2009-05-09-PointerEdgeCount.ll (original) +++ llvm/trunk/test/Analysis/ScalarEvolution/2009-05-09-PointerEdgeCount.ll Tue Nov 3 09:29:06 2009 @@ -1,5 +1,6 @@ ; RUN: opt < %s -analyze -scalar-evolution -disable-output | grep {count is 2} ; PR3171 +target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" %struct.Foo = type { i32 } %struct.NonPod = type { [2 x %struct.Foo] } Modified: llvm/trunk/test/CodeGen/X86/vec_ins_extract.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/vec_ins_extract.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/vec_ins_extract.ll (original) +++ llvm/trunk/test/CodeGen/X86/vec_ins_extract.ll Tue Nov 3 09:29:06 2009 @@ -3,6 +3,7 @@ ; This checks that various insert/extract idiom work without going to the ; stack. +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32" define void @test(<4 x float>* %F, float %f) { entry: Modified: llvm/trunk/test/Transforms/ArgumentPromotion/aggregate-promote.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ArgumentPromotion/aggregate-promote.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Transforms/ArgumentPromotion/aggregate-promote.ll (original) +++ llvm/trunk/test/Transforms/ArgumentPromotion/aggregate-promote.ll Tue Nov 3 09:29:06 2009 @@ -1,4 +1,5 @@ ; RUN: opt < %s -argpromotion -instcombine -S | not grep load +target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" %QuadTy = type { i32, i32, i32, i32 } @G = constant %QuadTy { Modified: llvm/trunk/test/Transforms/ArgumentPromotion/basictest.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ArgumentPromotion/basictest.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Transforms/ArgumentPromotion/basictest.ll (original) +++ llvm/trunk/test/Transforms/ArgumentPromotion/basictest.ll Tue Nov 3 09:29:06 2009 @@ -1,4 +1,5 @@ ; RUN: opt < %s -argpromotion -mem2reg -S | not grep alloca +target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" define internal i32 @test(i32* %X, i32* %Y) { %A = load i32* %X ; [#uses=1] %B = load i32* %Y ; [#uses=1] Modified: llvm/trunk/test/Transforms/ArgumentPromotion/byval.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ArgumentPromotion/byval.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Transforms/ArgumentPromotion/byval.ll (original) +++ llvm/trunk/test/Transforms/ArgumentPromotion/byval.ll Tue Nov 3 09:29:06 2009 @@ -1,4 +1,5 @@ ; RUN: opt < %s -argpromotion -scalarrepl -S | not grep load +target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" ; Argpromote + scalarrepl should change this to passing the two integers by value. %struct.ss = type { i32, i64 } Modified: llvm/trunk/test/Transforms/ArgumentPromotion/chained.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ArgumentPromotion/chained.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Transforms/ArgumentPromotion/chained.ll (original) +++ llvm/trunk/test/Transforms/ArgumentPromotion/chained.ll Tue Nov 3 09:29:06 2009 @@ -1,4 +1,5 @@ ; RUN: opt < %s -argpromotion -instcombine -S | not grep load +target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" @G1 = constant i32 0 ; [#uses=1] @G2 = constant i32* @G1 ; [#uses=1] Modified: llvm/trunk/test/Transforms/ArgumentPromotion/control-flow2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ArgumentPromotion/control-flow2.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Transforms/ArgumentPromotion/control-flow2.ll (original) +++ llvm/trunk/test/Transforms/ArgumentPromotion/control-flow2.ll Tue Nov 3 09:29:06 2009 @@ -1,5 +1,6 @@ ; RUN: opt < %s -argpromotion -S | \ ; RUN: grep {load i32\\* %A} +target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" define internal i32 @callee(i1 %C, i32* %P) { br i1 %C, label %T, label %F Modified: llvm/trunk/test/Transforms/DeadStoreElimination/2008-07-28-load-store.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/DeadStoreElimination/2008-07-28-load-store.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Transforms/DeadStoreElimination/2008-07-28-load-store.ll (original) +++ llvm/trunk/test/Transforms/DeadStoreElimination/2008-07-28-load-store.ll Tue Nov 3 09:29:06 2009 @@ -1,5 +1,6 @@ ; RUN: opt < %s -dse -S | not grep tmp5 ; PR2599 +target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" define void @foo({ i32, i32 }* %x) nounwind { entry: Modified: llvm/trunk/test/Transforms/DeadStoreElimination/PartialStore.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/DeadStoreElimination/PartialStore.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Transforms/DeadStoreElimination/PartialStore.ll (original) +++ llvm/trunk/test/Transforms/DeadStoreElimination/PartialStore.ll Tue Nov 3 09:29:06 2009 @@ -2,6 +2,7 @@ ; RUN: not grep {store i8} ; Ensure that the dead store is deleted in this case. It is wholely ; overwritten by the second store. +target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" define i32 @test() { %V = alloca i32 ; [#uses=3] %V2 = bitcast i32* %V to i8* ; [#uses=1] Modified: llvm/trunk/test/Transforms/DeadStoreElimination/context-sensitive.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/DeadStoreElimination/context-sensitive.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Transforms/DeadStoreElimination/context-sensitive.ll (original) +++ llvm/trunk/test/Transforms/DeadStoreElimination/context-sensitive.ll Tue Nov 3 09:29:06 2009 @@ -1,4 +1,5 @@ ; RUN: opt < %s -dse -S | not grep DEAD +target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" declare void @ext() Modified: llvm/trunk/test/Transforms/DeadStoreElimination/simple.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/DeadStoreElimination/simple.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Transforms/DeadStoreElimination/simple.ll (original) +++ llvm/trunk/test/Transforms/DeadStoreElimination/simple.ll Tue Nov 3 09:29:06 2009 @@ -1,4 +1,5 @@ ; RUN: opt < %s -dse -S | not grep DEAD +target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" define void @test(i32* %Q, i32* %P) { %DEAD = load i32* %Q ; [#uses=1] Modified: llvm/trunk/test/Transforms/GlobalOpt/globalsra-partial.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/globalsra-partial.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/globalsra-partial.ll (original) +++ llvm/trunk/test/Transforms/GlobalOpt/globalsra-partial.ll Tue Nov 3 09:29:06 2009 @@ -1,6 +1,7 @@ ; In this case, the global can only be broken up by one level. ; RUN: opt < %s -globalopt -S | not grep 12345 +target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" @G = internal global { i32, [4 x float] } zeroinitializer ; <{ i32, [4 x float] }*> [#uses=3] Modified: llvm/trunk/test/Transforms/GlobalOpt/globalsra.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/globalsra.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/globalsra.ll (original) +++ llvm/trunk/test/Transforms/GlobalOpt/globalsra.ll Tue Nov 3 09:29:06 2009 @@ -1,4 +1,5 @@ ; RUN: opt < %s -globalopt -S | not grep global +target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" @G = internal global { i32, float, { double } } { i32 1, Modified: llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-1.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-1.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-1.ll (original) +++ llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-1.ll Tue Nov 3 09:29:06 2009 @@ -1,4 +1,5 @@ ; RUN: opt < %s -globalopt -S | not grep global +target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" @G = internal global i32* null ; [#uses=3] Modified: llvm/trunk/test/Transforms/IndVarSimplify/preserve-gep-loop-variant.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/IndVarSimplify/preserve-gep-loop-variant.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Transforms/IndVarSimplify/preserve-gep-loop-variant.ll (original) +++ llvm/trunk/test/Transforms/IndVarSimplify/preserve-gep-loop-variant.ll Tue Nov 3 09:29:06 2009 @@ -2,6 +2,7 @@ ; RUN: not grep inttoptr %t ; RUN: not grep ptrtoint %t ; RUN: grep scevgep %t +target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" ; Indvars shouldn't need inttoptr/ptrtoint to expand an address here. Modified: llvm/trunk/test/Transforms/IndVarSimplify/preserve-gep-remainder.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/IndVarSimplify/preserve-gep-remainder.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Transforms/IndVarSimplify/preserve-gep-remainder.ll (original) +++ llvm/trunk/test/Transforms/IndVarSimplify/preserve-gep-remainder.ll Tue Nov 3 09:29:06 2009 @@ -1,5 +1,6 @@ ; RUN: opt < %s -indvars -S \ ; RUN: | grep {\[%\]p.2.ip.1 = getelementptr \\\[3 x \\\[3 x double\\\]\\\]\\* \[%\]p, i64 2, i64 \[%\]tmp, i64 1} +target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" ; Indvars shouldn't expand this to ; %p.2.ip.1 = getelementptr [3 x [3 x double]]* %p, i64 0, i64 %tmp, i64 19 Modified: llvm/trunk/test/Transforms/Inline/basictest.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/Inline/basictest.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Transforms/Inline/basictest.ll (original) +++ llvm/trunk/test/Transforms/Inline/basictest.ll Tue Nov 3 09:29:06 2009 @@ -1,4 +1,5 @@ ; RUN: opt < %s -inline -scalarrepl -S | FileCheck %s +target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" define i32 @test1f(i32 %i) { ret i32 %i Modified: llvm/trunk/test/Transforms/InstCombine/2003-11-13-ConstExprCastCall.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/2003-11-13-ConstExprCastCall.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/2003-11-13-ConstExprCastCall.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/2003-11-13-ConstExprCastCall.ll Tue Nov 3 09:29:06 2009 @@ -1,4 +1,5 @@ ; RUN: opt < %s -instcombine -S | FileCheck %s +target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" declare void @free(i8*) Modified: llvm/trunk/test/Transforms/InstCombine/2007-10-10-EliminateMemCpy.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/2007-10-10-EliminateMemCpy.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/2007-10-10-EliminateMemCpy.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/2007-10-10-EliminateMemCpy.ll Tue Nov 3 09:29:06 2009 @@ -1,5 +1,6 @@ ; RUN: opt < %s -instcombine -S | not grep call ; RUN: opt < %s -std-compile-opts -S | not grep xyz +target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" @.str = internal constant [4 x i8] c"xyz\00" ; <[4 x i8]*> [#uses=1] Modified: llvm/trunk/test/Transforms/InstCombine/align-2d-gep.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/align-2d-gep.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/align-2d-gep.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/align-2d-gep.ll Tue Nov 3 09:29:06 2009 @@ -1,4 +1,5 @@ ; RUN: opt < %s -instcombine -S | grep {align 16} | count 1 +target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" ; A multi-dimensional array in a nested loop doing vector stores that ; aren't yet aligned. Instcombine can understand the addressing in the Modified: llvm/trunk/test/Transforms/InstCombine/align-addr.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/align-addr.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/align-addr.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/align-addr.ll Tue Nov 3 09:29:06 2009 @@ -1,4 +1,5 @@ ; RUN: opt < %s -instcombine -S | grep {align 16} | count 1 +target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" ; Instcombine should be able to prove vector alignment in the ; presence of a few mild address computation tricks. Modified: llvm/trunk/test/Transforms/InstCombine/align-inc.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/align-inc.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/align-inc.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/align-inc.ll Tue Nov 3 09:29:06 2009 @@ -1,5 +1,6 @@ ; RUN: opt < %s -instcombine -S | grep {GLOBAL.*align 16} ; RUN: opt < %s -instcombine -S | grep {tmp = load} +target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" @GLOBAL = internal global [4 x i32] zeroinitializer Modified: llvm/trunk/test/Transforms/InstCombine/alloca.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/alloca.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/alloca.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/alloca.ll Tue Nov 3 09:29:06 2009 @@ -1,4 +1,5 @@ ; Zero byte allocas should be deleted. +target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" ; RUN: opt < %s -instcombine -S | \ ; RUN: not grep alloca Modified: llvm/trunk/test/Transforms/InstCombine/call.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/call.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/call.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/call.ll Tue Nov 3 09:29:06 2009 @@ -1,6 +1,7 @@ ; Ignore stderr, we expect warnings there ; RUN: opt < %s -instcombine 2> /dev/null -S | FileCheck %s +target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" ; Simple case, argument translatable without changing the value declare void @test1a(i8*) Modified: llvm/trunk/test/Transforms/InstCombine/cast-load-gep.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/cast-load-gep.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/cast-load-gep.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/cast-load-gep.ll Tue Nov 3 09:29:06 2009 @@ -1,5 +1,6 @@ ; RUN: opt < %s -instcombine -globaldce -S | \ ; RUN: not grep Array +target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" ; Pulling the cast out of the load allows us to eliminate the load, and then ; the whole array. Modified: llvm/trunk/test/Transforms/InstCombine/cast.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/cast.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/cast.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/cast.ll Tue Nov 3 09:29:06 2009 @@ -1,5 +1,6 @@ ; Tests to make sure elimination of casts is working correctly ; RUN: opt < %s -instcombine -S | FileCheck %s +target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" @inbuf = external global [32832 x i8] ; <[32832 x i8]*> [#uses=1] Modified: llvm/trunk/test/Transforms/InstCombine/cast2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/cast2.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/cast2.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/cast2.ll Tue Nov 3 09:29:06 2009 @@ -1,5 +1,6 @@ ; Tests to make sure elimination of casts is working correctly ; RUN: opt < %s -instcombine -S | FileCheck %s +target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" define i16 @test1(i16 %a) { %tmp = zext i16 %a to i32 ; [#uses=2] Modified: llvm/trunk/test/Transforms/InstCombine/constant-fold-gep.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/constant-fold-gep.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/constant-fold-gep.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/constant-fold-gep.ll Tue Nov 3 09:29:06 2009 @@ -1,4 +1,5 @@ ; RUN: opt < %s -instcombine -S | FileCheck %s +target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64" ; Constant folding should fix notionally out-of-bounds indices ; and add inbounds keywords. Modified: llvm/trunk/test/Transforms/InstCombine/fold-bin-operand.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/fold-bin-operand.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/fold-bin-operand.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/fold-bin-operand.ll Tue Nov 3 09:29:06 2009 @@ -1,4 +1,5 @@ ; RUN: opt < %s -instcombine -S | not grep icmp +target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" define i1 @f(i1 %x) { %b = and i1 %x, icmp eq (i8* inttoptr (i32 1 to i8*), i8* inttoptr (i32 2 to i8*)) Modified: llvm/trunk/test/Transforms/InstCombine/fp-ret-bitcast.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/fp-ret-bitcast.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/fp-ret-bitcast.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/fp-ret-bitcast.ll Tue Nov 3 09:29:06 2009 @@ -1,5 +1,6 @@ ; RUN: opt < %s -instcombine -S | \ ; RUN: grep {call float bitcast} | count 1 +target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" %struct.NSObject = type { %struct.objc_class* } %struct.NSArray = type { %struct.NSObject } %struct.objc_class = type opaque Modified: llvm/trunk/test/Transforms/InstCombine/loadstore-alignment.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/loadstore-alignment.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/loadstore-alignment.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/loadstore-alignment.ll Tue Nov 3 09:29:06 2009 @@ -1,4 +1,5 @@ ; RUN: opt < %s -instcombine -S | grep {, align 16} | count 14 +target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" @x = external global <2 x i64>, align 16 @xx = external global [13 x <2 x i64>], align 16 Modified: llvm/trunk/test/Transforms/InstCombine/ptr-int-cast.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/ptr-int-cast.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/ptr-int-cast.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/ptr-int-cast.ll Tue Nov 3 09:29:06 2009 @@ -1,4 +1,5 @@ ; RUN: opt < %s -instcombine -S > %t +target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" define i1 @test1(i32 *%x) nounwind { entry: Modified: llvm/trunk/test/Transforms/MemCpyOpt/2008-03-13-ReturnSlotBitcast.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/MemCpyOpt/2008-03-13-ReturnSlotBitcast.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Transforms/MemCpyOpt/2008-03-13-ReturnSlotBitcast.ll (original) +++ llvm/trunk/test/Transforms/MemCpyOpt/2008-03-13-ReturnSlotBitcast.ll Tue Nov 3 09:29:06 2009 @@ -1,4 +1,5 @@ ; RUN: opt < %s -memcpyopt -S | not grep {call.*memcpy.} +target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64" %a = type { i32 } %b = type { float } Modified: llvm/trunk/test/Transforms/MemCpyOpt/align.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/MemCpyOpt/align.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Transforms/MemCpyOpt/align.ll (original) +++ llvm/trunk/test/Transforms/MemCpyOpt/align.ll Tue Nov 3 09:29:06 2009 @@ -1,4 +1,5 @@ ; RUN: opt < %s -S -memcpyopt | FileCheck %s +target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64" ; The resulting memset is only 4-byte aligned, despite containing ; a 16-byte alignmed store in the middle. Modified: llvm/trunk/test/Transforms/ScalarRepl/2003-05-29-ArrayFail.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ScalarRepl/2003-05-29-ArrayFail.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Transforms/ScalarRepl/2003-05-29-ArrayFail.ll (original) +++ llvm/trunk/test/Transforms/ScalarRepl/2003-05-29-ArrayFail.ll Tue Nov 3 09:29:06 2009 @@ -1,4 +1,5 @@ ; RUN: opt < %s -scalarrepl -instcombine -S | not grep alloca +target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64" ; Test that an array is not incorrectly deconstructed. Modified: llvm/trunk/test/Transforms/ScalarRepl/2006-11-07-InvalidArrayPromote.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ScalarRepl/2006-11-07-InvalidArrayPromote.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Transforms/ScalarRepl/2006-11-07-InvalidArrayPromote.ll (original) +++ llvm/trunk/test/Transforms/ScalarRepl/2006-11-07-InvalidArrayPromote.ll Tue Nov 3 09:29:06 2009 @@ -1,4 +1,5 @@ ; RUN: opt < %s -scalarrepl -S | not grep alloca +target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64" define i32 @func(<4 x float> %v0, <4 x float> %v1) nounwind { %vsiidx = alloca [2 x <4 x i32>], align 16 ; <[2 x <4 x i32>]*> [#uses=3] Modified: llvm/trunk/test/Transforms/ScalarRepl/2008-06-05-loadstore-agg.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ScalarRepl/2008-06-05-loadstore-agg.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Transforms/ScalarRepl/2008-06-05-loadstore-agg.ll (original) +++ llvm/trunk/test/Transforms/ScalarRepl/2008-06-05-loadstore-agg.ll Tue Nov 3 09:29:06 2009 @@ -4,6 +4,7 @@ ; values. This checks of scalarrepl splits up the struct and array properly. ; RUN: opt < %s -scalarrepl -S | not grep alloca +target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64" define i32 @foo() { %target = alloca { i32, i32 } ; <{ i32, i32 }*> [#uses=1] Modified: llvm/trunk/test/Transforms/ScalarRepl/2008-09-22-vector-gep.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ScalarRepl/2008-09-22-vector-gep.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Transforms/ScalarRepl/2008-09-22-vector-gep.ll (original) +++ llvm/trunk/test/Transforms/ScalarRepl/2008-09-22-vector-gep.ll Tue Nov 3 09:29:06 2009 @@ -5,6 +5,7 @@ ; RUN: opt < %s -scalarrepl -S > %t ; RUN: cat %t | not grep alloca +target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64" %struct.two = type <{ < 2 x i8 >, i16 }> Modified: llvm/trunk/test/Transforms/ScalarRepl/2009-03-04-MemCpyAlign.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ScalarRepl/2009-03-04-MemCpyAlign.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Transforms/ScalarRepl/2009-03-04-MemCpyAlign.ll (original) +++ llvm/trunk/test/Transforms/ScalarRepl/2009-03-04-MemCpyAlign.ll Tue Nov 3 09:29:06 2009 @@ -2,6 +2,7 @@ ; is only known to access it with 1-byte alignment. ; RUN: opt < %s -scalarrepl -S | grep {store i16 1, .*, align 1} ; PR3720 +target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64" %struct.st = type { i16 } Modified: llvm/trunk/test/Transforms/ScalarRepl/DifferingTypes.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ScalarRepl/DifferingTypes.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Transforms/ScalarRepl/DifferingTypes.ll (original) +++ llvm/trunk/test/Transforms/ScalarRepl/DifferingTypes.ll Tue Nov 3 09:29:06 2009 @@ -3,6 +3,7 @@ ; depending on the endianness of the target... ; RUN: opt < %s -scalarrepl -S | \ ; RUN: not grep alloca +target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64" define i32 @testfunc(i32 %i, i8 %j) { %I = alloca i32 ; [#uses=3] Modified: llvm/trunk/test/Transforms/ScalarRepl/arraytest.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ScalarRepl/arraytest.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Transforms/ScalarRepl/arraytest.ll (original) +++ llvm/trunk/test/Transforms/ScalarRepl/arraytest.ll Tue Nov 3 09:29:06 2009 @@ -1,4 +1,5 @@ ; RUN: opt < %s -scalarrepl -mem2reg -S | not grep alloca +target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64" define i32 @test() { %X = alloca [4 x i32] ; <[4 x i32]*> [#uses=1] Modified: llvm/trunk/test/Transforms/ScalarRepl/basictest.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ScalarRepl/basictest.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Transforms/ScalarRepl/basictest.ll (original) +++ llvm/trunk/test/Transforms/ScalarRepl/basictest.ll Tue Nov 3 09:29:06 2009 @@ -1,4 +1,5 @@ ; RUN: opt < %s -scalarrepl -mem2reg -S | not grep alloca +target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64" define i32 @test() { %X = alloca { i32, float } ; <{ i32, float }*> [#uses=1] Modified: llvm/trunk/test/Transforms/ScalarRepl/bitfield-sroa.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ScalarRepl/bitfield-sroa.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Transforms/ScalarRepl/bitfield-sroa.ll (original) +++ llvm/trunk/test/Transforms/ScalarRepl/bitfield-sroa.ll Tue Nov 3 09:29:06 2009 @@ -1,5 +1,6 @@ ; RUN: opt < %s -scalarrepl -S | not grep alloca ; rdar://6532315 +target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64" %t = type { { i32, i16, i8, i8 } } define i8 @foo(i64 %A) { Modified: llvm/trunk/test/Transforms/ScalarRepl/copy-aggregate.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ScalarRepl/copy-aggregate.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Transforms/ScalarRepl/copy-aggregate.ll (original) +++ llvm/trunk/test/Transforms/ScalarRepl/copy-aggregate.ll Tue Nov 3 09:29:06 2009 @@ -1,5 +1,6 @@ ; RUN: opt < %s -scalarrepl -S | not grep alloca ; PR3290 +target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64" ;; Store of integer to whole alloca struct. define i32 @test1(i64 %V) nounwind { Modified: llvm/trunk/test/Transforms/ScalarRepl/debuginfo.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ScalarRepl/debuginfo.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Transforms/ScalarRepl/debuginfo.ll (original) +++ llvm/trunk/test/Transforms/ScalarRepl/debuginfo.ll Tue Nov 3 09:29:06 2009 @@ -1,4 +1,5 @@ ; RUN: opt < %s -scalarrepl -S | not grep alloca +target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64" %llvm.dbg.anchor.type = type { i32, i32 } %llvm.dbg.basictype.type = type { i32, { }*, i8*, { }*, i32, i64, i64, i64, i32, i32 } %llvm.dbg.compile_unit.type = type { i32, { }*, i32, i8*, i8*, i8*, i1, i1, i8* } Modified: llvm/trunk/test/Transforms/ScalarRepl/load-store-aggregate.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ScalarRepl/load-store-aggregate.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Transforms/ScalarRepl/load-store-aggregate.ll (original) +++ llvm/trunk/test/Transforms/ScalarRepl/load-store-aggregate.ll Tue Nov 3 09:29:06 2009 @@ -1,6 +1,7 @@ ; This testcase shows that scalarrepl is able to replace struct alloca's which ; are directly loaded from or stored to (using the first class aggregates ; feature). +target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64" ; RUN: opt < %s -scalarrepl -S > %t ; RUN: cat %t | not grep alloca Modified: llvm/trunk/test/Transforms/ScalarRepl/memcpy-from-global.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ScalarRepl/memcpy-from-global.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Transforms/ScalarRepl/memcpy-from-global.ll (original) +++ llvm/trunk/test/Transforms/ScalarRepl/memcpy-from-global.ll Tue Nov 3 09:29:06 2009 @@ -1,4 +1,5 @@ ; RUN: opt < %s -scalarrepl -S | not grep {call.*memcpy} +target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64" @C.0.1248 = internal constant [128 x float] [ float -1.000000e+00, float -1.000000e+00, float -1.000000e+00, float 0.000000e+00, float -1.000000e+00, float -1.000000e+00, float 0.000000e+00, float -1.000000e+00, float -1.000000e+00, float -1.000000e+00, float 0.000000e+00, float 1.000000e+00, float -1.000000e+00, float -1.000000e+00, float 1.000000e+00, float 0.000000e+00, float -1.000000e+00, float 0.000000e+00, float -1.000000e+00, float -1.000000e+00, float -1.000000e+00, float 0.000000e+00, float -1.000000e+00, float 1.000000e+00, float -1.000000e+00, float 0.000000e+00, float 1.000000e+00, float -1.000000e+00, float -1.000000e+00, float 0.000000e+00, float 1.000000e+00, float 1.000000e+00, float -1.000000e+00, float 1.000000e+00, float -1.000000e+00, float 0.000000e+00, float -1.000000e+00, float 1.000000e+00, float 0.000000e+00, float -1.000000e+00, float -1.000000e+00, float 1.000000e+00, float 0.000000e+00, float 1.000000e+00, float -1.000000e+00, float 1.000000e+00! , float 1.000000e+00, float 0.000000e+00, float 0.000000e+00, float -1.000000e+00, float -1.000000e+00, float -1.000000e+00, float 0.000000e+00, float -1.000000e+00, float -1.000000e+00, float 1.000000e+00, float 0.000000e+00, float -1.000000e+00, float 1.000000e+00, float -1.000000e+00, float 0.000000e+00, float -1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float -1.000000e+00, float -1.000000e+00, float 0.000000e+00, float 1.000000e+00, float -1.000000e+00, float 0.000000e+00, float -1.000000e+00, float 1.000000e+00, float -1.000000e+00, float 0.000000e+00, float 1.000000e+00, float 1.000000e+00, float -1.000000e+00, float 1.000000e+00, float 0.000000e+00, float 1.000000e+00, float 0.000000e+00, float -1.000000e+00, float -1.000000e+00, float 1.000000e+00, float 0.000000e+00, float -1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 0.000000e+00, float 1.000000e+00, float -1.000000e+00, float 1.000000e+00, float 0.000000e+00, float 1.! 000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.00! 0000e+00 , float -1.000000e+00, float 0.000000e+00, float 1.000000e+00, float 1.000000e+00, float 0.000000e+00, float -1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 0.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 0.000000e+00, float 0.000000e+00, float 1.000000e+00, float -1.000000e+00, float -1.000000e+00, float 0.000000e+00, float 1.000000e+00, float -1.000000e+00, float 1.000000e+00, float 0.000000e+00, float 1.000000e+00, float 1.000000e+00, float -1.000000e+00, float 0.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00 ], align 32 ; <[128 x float]*> [#uses=1] define float @grad4(i32 %hash, float %x, float %y, float %z, float %w) { Modified: llvm/trunk/test/Transforms/ScalarRepl/not-a-vector.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ScalarRepl/not-a-vector.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Transforms/ScalarRepl/not-a-vector.ll (original) +++ llvm/trunk/test/Transforms/ScalarRepl/not-a-vector.ll Tue Nov 3 09:29:06 2009 @@ -1,6 +1,7 @@ ; RUN: opt < %s -scalarrepl -S | not grep alloca ; RUN: opt < %s -scalarrepl -S | not grep {7 x double} ; RUN: opt < %s -scalarrepl -instcombine -S | grep {ret double %B} +target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64" define double @test(double %A, double %B) { %ARR = alloca [7 x i64] Modified: llvm/trunk/test/Transforms/ScalarRepl/union-fp-int.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ScalarRepl/union-fp-int.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Transforms/ScalarRepl/union-fp-int.ll (original) +++ llvm/trunk/test/Transforms/ScalarRepl/union-fp-int.ll Tue Nov 3 09:29:06 2009 @@ -2,6 +2,7 @@ ; RUN: not grep alloca ; RUN: opt < %s -scalarrepl -S | \ ; RUN: grep {bitcast.*float.*i32} +target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64" define i32 @test(float %X) { %X_addr = alloca float ; [#uses=2] Modified: llvm/trunk/test/Transforms/ScalarRepl/union-packed.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ScalarRepl/union-packed.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Transforms/ScalarRepl/union-packed.ll (original) +++ llvm/trunk/test/Transforms/ScalarRepl/union-packed.ll Tue Nov 3 09:29:06 2009 @@ -2,6 +2,7 @@ ; RUN: not grep alloca ; RUN: opt < %s -scalarrepl -S | \ ; RUN: grep bitcast +target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64" define <4 x i32> @test(<4 x float> %X) { %X_addr = alloca <4 x float> ; <<4 x float>*> [#uses=2] Modified: llvm/trunk/test/Transforms/ScalarRepl/vector_memcpy.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ScalarRepl/vector_memcpy.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Transforms/ScalarRepl/vector_memcpy.ll (original) +++ llvm/trunk/test/Transforms/ScalarRepl/vector_memcpy.ll Tue Nov 3 09:29:06 2009 @@ -1,6 +1,7 @@ ; RUN: opt < %s -scalarrepl -S > %t ; RUN: grep {ret <16 x float> %A} %t ; RUN: grep {ret <16 x float> zeroinitializer} %t +target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64" define <16 x float> @foo(<16 x float> %A) nounwind { %tmp = alloca <16 x float>, align 16 Modified: llvm/trunk/test/Transforms/ScalarRepl/vector_promote.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ScalarRepl/vector_promote.ll?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/test/Transforms/ScalarRepl/vector_promote.ll (original) +++ llvm/trunk/test/Transforms/ScalarRepl/vector_promote.ll Tue Nov 3 09:29:06 2009 @@ -1,5 +1,6 @@ ; RUN: opt < %s -scalarrepl -S | not grep alloca ; RUN: opt < %s -scalarrepl -S | grep {load <4 x float>} +target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64" define void @test(<4 x float>* %F, float %f) { entry: Modified: llvm/trunk/tools/opt/opt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/opt.cpp?rev=85900&r1=85899&r2=85900&view=diff ============================================================================== --- llvm/trunk/tools/opt/opt.cpp (original) +++ llvm/trunk/tools/opt/opt.cpp Tue Nov 3 09:29:06 2009 @@ -132,10 +132,6 @@ cl::desc("data layout string to use if not specified by module"), cl::value_desc("layout-string"), cl::init("")); -static cl::opt -NoDefaultDataLayout("no-default-data-layout", - cl::desc("no data layout assumptions unless module specifies data layout")); - // ---------- Define Printers for module and function passes ------------ namespace { @@ -401,7 +397,7 @@ const std::string &ModuleDataLayout = M.get()->getDataLayout(); if (!ModuleDataLayout.empty()) TD = new TargetData(ModuleDataLayout); - else if (!NoDefaultDataLayout) + else if (!DefaultDataLayout.empty()) TD = new TargetData(DefaultDataLayout); if (TD) From criswell at cs.uiuc.edu Tue Nov 3 09:37:36 2009 From: criswell at cs.uiuc.edu (John Criswell) Date: Tue, 3 Nov 2009 09:37:36 -0600 Subject: [llvm-commits] CVS: llvm-www/safecode/sidebar.incl Message-ID: <200911031537.nA3FbaD8017249@maute.cs.uiuc.edu> Changes in directory llvm-www/safecode: sidebar.incl added (r1.1) --- Log message: Sidebar menu. --- Diffs of the changes: (+10 -0) sidebar.incl | 10 ++++++++++ 1 files changed, 10 insertions(+) Index: llvm-www/safecode/sidebar.incl diff -c /dev/null llvm-www/safecode/sidebar.incl:1.1 *** /dev/null Tue Nov 3 09:37:02 2009 --- llvm-www/safecode/sidebar.incl Tue Nov 3 09:36:52 2009 *************** *** 0 **** --- 1,10 ---- + + From criswell at cs.uiuc.edu Tue Nov 3 09:38:02 2009 From: criswell at cs.uiuc.edu (John Criswell) Date: Tue, 3 Nov 2009 09:38:02 -0600 Subject: [llvm-commits] CVS: llvm-www/safecode/links.html Message-ID: <200911031538.nA3Fc2Hv017263@maute.cs.uiuc.edu> Changes in directory llvm-www/safecode: links.html updated: 1.1 -> 1.2 --- Log message: Use the new sidebar include file. --- Diffs of the changes: (+2 -11) links.html | 13 ++----------- 1 files changed, 2 insertions(+), 11 deletions(-) Index: llvm-www/safecode/links.html diff -u llvm-www/safecode/links.html:1.1 llvm-www/safecode/links.html:1.2 --- llvm-www/safecode/links.html:1.1 Tue Nov 3 09:15:58 2009 +++ llvm-www/safecode/links.html Tue Nov 3 09:37:22 2009 @@ -38,17 +38,8 @@
    - - + +
    From criswell at cs.uiuc.edu Tue Nov 3 09:39:38 2009 From: criswell at cs.uiuc.edu (John Criswell) Date: Tue, 3 Nov 2009 09:39:38 -0600 Subject: [llvm-commits] CVS: llvm-www/safecode/index.html people.html pubs.html Message-ID: <200911031539.nA3Fdcgs017336@maute.cs.uiuc.edu> Changes in directory llvm-www/safecode: index.html updated: 1.26 -> 1.27 people.html updated: 1.1 -> 1.2 pubs.html updated: 1.1 -> 1.2 --- Log message: Switch to the new sidebar menu include file. --- Diffs of the changes: (+3 -30) index.html | 11 +---------- people.html | 11 +---------- pubs.html | 11 +---------- 3 files changed, 3 insertions(+), 30 deletions(-) Index: llvm-www/safecode/index.html diff -u llvm-www/safecode/index.html:1.26 llvm-www/safecode/index.html:1.27 --- llvm-www/safecode/index.html:1.26 Tue Nov 3 09:15:58 2009 +++ llvm-www/safecode/index.html Tue Nov 3 09:38:56 2009 @@ -38,17 +38,8 @@
    - -
    Index: llvm-www/safecode/people.html diff -u llvm-www/safecode/people.html:1.1 llvm-www/safecode/people.html:1.2 --- llvm-www/safecode/people.html:1.1 Tue Nov 3 09:15:58 2009 +++ llvm-www/safecode/people.html Tue Nov 3 09:38:56 2009 @@ -38,17 +38,8 @@
    - -
    Index: llvm-www/safecode/pubs.html diff -u llvm-www/safecode/pubs.html:1.1 llvm-www/safecode/pubs.html:1.2 --- llvm-www/safecode/pubs.html:1.1 Tue Nov 3 09:15:58 2009 +++ llvm-www/safecode/pubs.html Tue Nov 3 09:38:56 2009 @@ -41,17 +41,8 @@
    - -
    From criswell at cs.uiuc.edu Tue Nov 3 09:44:12 2009 From: criswell at cs.uiuc.edu (John Criswell) Date: Tue, 3 Nov 2009 09:44:12 -0600 Subject: [llvm-commits] CVS: llvm-www/safecode/people.html Message-ID: <200911031544.nA3FiC69017467@maute.cs.uiuc.edu> Changes in directory llvm-www/safecode: people.html updated: 1.2 -> 1.3 --- Log message: Added Nicolas Geoffray to Alumni because of his work on Secure Virtual Architecture. --- Diffs of the changes: (+4 -0) people.html | 4 ++++ 1 files changed, 4 insertions(+) Index: llvm-www/safecode/people.html diff -u llvm-www/safecode/people.html:1.2 llvm-www/safecode/people.html:1.3 --- llvm-www/safecode/people.html:1.2 Tue Nov 3 09:38:56 2009 +++ llvm-www/safecode/people.html Tue Nov 3 09:43:26 2009 @@ -83,6 +83,10 @@
  • + Nicolas Geoffray +
  • + +
  • Sumant Kowshik
  • From criswell at cs.uiuc.edu Tue Nov 3 10:02:26 2009 From: criswell at cs.uiuc.edu (John Criswell) Date: Tue, 3 Nov 2009 10:02:26 -0600 Subject: [llvm-commits] CVS: llvm-www/safecode/people.html Message-ID: <200911031602.nA3G2QrL017884@maute.cs.uiuc.edu> Changes in directory llvm-www/safecode: people.html updated: 1.3 -> 1.4 --- Log message: Corrected title. --- Diffs of the changes: (+1 -1) people.html | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm-www/safecode/people.html diff -u llvm-www/safecode/people.html:1.3 llvm-www/safecode/people.html:1.4 --- llvm-www/safecode/people.html:1.3 Tue Nov 3 09:43:26 2009 +++ llvm-www/safecode/people.html Tue Nov 3 10:01:44 2009 @@ -13,7 +13,7 @@ -SAFECode +Project Members From criswell at cs.uiuc.edu Tue Nov 3 10:20:49 2009 From: criswell at cs.uiuc.edu (John Criswell) Date: Tue, 3 Nov 2009 10:20:49 -0600 Subject: [llvm-commits] CVS: llvm-www/safecode/pubs.html Message-ID: <200911031620.nA3GKnqs018290@maute.cs.uiuc.edu> Changes in directory llvm-www/safecode: pubs.html updated: 1.2 -> 1.3 --- Log message: Added missing SAFECode publications. Added SVA publication from Usenix Security 2009. Added full conference names for some entries. --- Diffs of the changes: (+59 -4) pubs.html | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 59 insertions(+), 4 deletions(-) Index: llvm-www/safecode/pubs.html diff -u llvm-www/safecode/pubs.html:1.2 llvm-www/safecode/pubs.html:1.3 --- llvm-www/safecode/pubs.html:1.2 Tue Nov 3 09:38:56 2009 +++ llvm-www/safecode/pubs.html Tue Nov 3 10:20:02 2009 @@ -50,7 +50,47 @@

    SAFECode Publications


    - + +
      +
    • + + Efficiently Detecting All Dangling Pointer Uses in Production Servers + +
      + Dinakar Dhurjati and Vikram Adve. +
      + International Conference on Dependable Systems and Networks (DSN), 2006 +
    • + +
      + +
        +
      • + + SAFECode: Enforcing Alias Analysis for Weakly Typed Languages + +
        + Dinakar Dhurjati, Sumant Kowshik, and Vikram Adve. +
        + ACM SIGPLAN Conference on Programming Language Design and +Implementation (PLDI), June 2006 +
      • + +
        + +
          +
        • + + Backwards-Compatible Array Bounds Checking for C with Very Low Overhead + +
          + Dinakar Dhurjati and Vikram Adve. +
          + International Conference on Software Engineering (ICSE), May 2006 +
        • + +
          +
          • @@ -61,7 +101,7 @@ Technical Report #UIUCDCS-R-2005-2657, Computer Science Dept., University of Illinois, Nov 2005
          • -

            +
          • @@ -85,7 +125,7 @@
            Dinakar Dhurjati, Sumant Kowshik, Vikram Adve and Chris Lattner.
            - LCTES 2003. + Languages Compilers and Tools for Embedded Systems (LCTES), June 2003.

          • @@ -98,7 +138,8 @@
            Sumant Kowshik, Dinakar Dhurjati, Vikram Adve.
            - CASES 2002. + Internaltional Conference on Compilers, Architecture and Synthesis for + Embedded Systems (CASES), October 2002.
            @@ -111,6 +152,20 @@
              +
            • + + Memory Safety for Low-Level Software/Hardware Interactions + +
              + John Criswell, Nicolas Geoffray, and Vikram Adve +
              + Proceedings of the Eighteenth USENIX Security Symposium, + Montreal, Canada, August 2009. +
            • + +
              + +
              • Secure Virtual Architecture: A Safe Execution Environment for Commodity From criswell at cs.uiuc.edu Tue Nov 3 10:24:05 2009 From: criswell at cs.uiuc.edu (John Criswell) Date: Tue, 3 Nov 2009 10:24:05 -0600 Subject: [llvm-commits] CVS: llvm-www/safecode/pubs.html Message-ID: <200911031624.nA3GO5Xe018390@maute.cs.uiuc.edu> Changes in directory llvm-www/safecode: pubs.html updated: 1.3 -> 1.4 --- Log message: Fixed formatting mistakes. Fixed link to Usenix Security 2009 publication. --- Diffs of the changes: (+1 -5) pubs.html | 6 +----- 1 files changed, 1 insertion(+), 5 deletions(-) Index: llvm-www/safecode/pubs.html diff -u llvm-www/safecode/pubs.html:1.3 llvm-www/safecode/pubs.html:1.4 --- llvm-www/safecode/pubs.html:1.3 Tue Nov 3 10:20:02 2009 +++ llvm-www/safecode/pubs.html Tue Nov 3 10:23:20 2009 @@ -64,7 +64,6 @@
                -
                • SAFECode: Enforcing Alias Analysis for Weakly Typed Languages @@ -78,7 +77,6 @@
                  -
                  • Backwards-Compatible Array Bounds Checking for C with Very Low Overhead @@ -91,7 +89,6 @@
                    -
                    • Enforcing Alias Analysis for Weakly Typed Languages @@ -152,7 +149,7 @@
                        -
                      • +
                      • Memory Safety for Low-Level Software/Hardware Interactions @@ -165,7 +162,6 @@
                        -
                        • Secure Virtual Architecture: A Safe Execution Environment for Commodity From criswell at cs.uiuc.edu Tue Nov 3 10:25:47 2009 From: criswell at cs.uiuc.edu (John Criswell) Date: Tue, 3 Nov 2009 10:25:47 -0600 Subject: [llvm-commits] CVS: llvm-www/safecode/pubs.html Message-ID: <200911031625.nA3GPlat018454@maute.cs.uiuc.edu> Changes in directory llvm-www/safecode: pubs.html updated: 1.4 -> 1.5 --- Log message: Fixed hyperlinks. --- Diffs of the changes: (+1 -1) pubs.html | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm-www/safecode/pubs.html diff -u llvm-www/safecode/pubs.html:1.4 llvm-www/safecode/pubs.html:1.5 --- llvm-www/safecode/pubs.html:1.4 Tue Nov 3 10:23:20 2009 +++ llvm-www/safecode/pubs.html Tue Nov 3 10:25:04 2009 @@ -101,7 +101,7 @@
                        • - + Memory Safety Without Garbage Collection for Embedded Applications
                          From bob.wilson at apple.com Tue Nov 3 10:36:22 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 03 Nov 2009 16:36:22 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r85902 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Message-ID: <200911031636.nA3GaNEf017055@zion.cs.uiuc.edu> Author: bwilson Date: Tue Nov 3 10:36:22 2009 New Revision: 85902 URL: http://llvm.org/viewvc/llvm-project?rev=85902&view=rev Log: Remove comment that is not relevant here. 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=85902&r1=85901&r2=85902&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Tue Nov 3 10:36:22 2009 @@ -6941,9 +6941,6 @@ #ifdef USEINDIRECTBRANCH Constant *TreeToLLVM::EmitLV_LABEL_DECL(tree exp) { - // GCC kindly diverts labels for unreachable basic blocks to reachable blocks, - // so we are not obliged to output unreachable blocks even if the original - // code took the address of one. return BlockAddress::get(Fn, getLabelDeclBlock(exp)); } #endif From bob.wilson at apple.com Tue Nov 3 10:33:24 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 3 Nov 2009 08:33:24 -0800 Subject: [llvm-commits] [llvm-gcc-4.2] r85835 - in /llvm-gcc-4.2/trunk/gcc: llvm-convert.cpp llvm-internal.h In-Reply-To: <4AF00FCD.7030508@free.fr> References: <200911022244.nA2MiNFd026188@zion.cs.uiuc.edu> <4AF00FCD.7030508@free.fr> Message-ID: <25F07A47-09D1-4DF8-8367-7B33E34231FF@apple.com> On Nov 3, 2009, at 3:11 AM, Duncan Sands wrote: > Hi Bob, thanks for doing this. > >> +Constant *TreeToLLVM::EmitLV_LABEL_DECL(tree exp) { >> + // GCC kindly diverts labels for unreachable basic blocks to >> reachable blocks, >> + // so we are not obliged to output unreachable blocks even if >> the original >> + // code took the address of one. > > this comment is only really relevant to dragonegg, which outputs > basic basic > blocks in dom order (in order to translate phi nodes), and as a side- > effect > only outputs reachable basic blocks. OK. I removed it. Thanks for the review. From sabre at nondot.org Tue Nov 3 10:50:11 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 03 Nov 2009 16:50:11 -0000 Subject: [llvm-commits] [llvm] r85903 - /llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Message-ID: <200911031650.nA3GoBAO017521@zion.cs.uiuc.edu> Author: lattner Date: Tue Nov 3 10:50:11 2009 New Revision: 85903 URL: http://llvm.org/viewvc/llvm-project?rev=85903&view=rev Log: fix a subtle bug I introduced when refactoring SCCP. Testcase to follow. Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCP.cpp?rev=85903&r1=85902&r2=85903&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SCCP.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Tue Nov 3 10:50:11 2009 @@ -107,7 +107,7 @@ /// markConstant - Return true if this is a change in status. bool markConstant(Constant *V) { - if (isConstant()) { + if (getLatticeValue() == constant) { // Constant but not forcedconstant. assert(getConstant() == V && "Marking constant with different value"); return false; } From sabre at nondot.org Tue Nov 3 11:03:02 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 03 Nov 2009 17:03:02 -0000 Subject: [llvm-commits] [llvm] r85906 - /llvm/trunk/test/Transforms/SCCP/crash.ll Message-ID: <200911031703.nA3H323j018003@zion.cs.uiuc.edu> Author: lattner Date: Tue Nov 3 11:03:02 2009 New Revision: 85906 URL: http://llvm.org/viewvc/llvm-project?rev=85906&view=rev Log: testcase for r85903 Added: llvm/trunk/test/Transforms/SCCP/crash.ll Added: llvm/trunk/test/Transforms/SCCP/crash.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SCCP/crash.ll?rev=85906&view=auto ============================================================================== --- llvm/trunk/test/Transforms/SCCP/crash.ll (added) +++ llvm/trunk/test/Transforms/SCCP/crash.ll Tue Nov 3 11:03:02 2009 @@ -0,0 +1,24 @@ +; RUN: opt %s -sccp -S +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128" +target triple = "x86_64-apple-darwin10.0" + +define void @test1(i8 %arg) { +entry: + br i1 undef, label %return, label %bb + +bb: + br label %bb34 + +bb23: + %c = icmp eq i8 %arg, undef + br i1 %c, label %bb34, label %bb23 + +bb34: + %Kind.1 = phi i32 [ undef, %bb ], [ %ins174, %bb23 ] + %mask173 = or i32 %Kind.1, 7 + %ins174 = and i32 %mask173, -249 + br label %bb23 + +return: + ret void +} From sabre at nondot.org Tue Nov 3 11:54:13 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 03 Nov 2009 17:54:13 -0000 Subject: [llvm-commits] [llvm] r85907 - /llvm/trunk/test/FrontendC++/integration-O2.cpp Message-ID: <200911031754.nA3HsD0u019580@zion.cs.uiuc.edu> Author: lattner Date: Tue Nov 3 11:54:12 2009 New Revision: 85907 URL: http://llvm.org/viewvc/llvm-project?rev=85907&view=rev Log: xfail this test since daniel turned off ipsccp Modified: llvm/trunk/test/FrontendC++/integration-O2.cpp Modified: llvm/trunk/test/FrontendC++/integration-O2.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC%2B%2B/integration-O2.cpp?rev=85907&r1=85906&r2=85907&view=diff ============================================================================== --- llvm/trunk/test/FrontendC++/integration-O2.cpp (original) +++ llvm/trunk/test/FrontendC++/integration-O2.cpp Tue Nov 3 11:54:12 2009 @@ -1,4 +1,5 @@ // RUN: %llvmgxx %s -O2 -S -o - | FileCheck %s +// XFAIL: * // This test verifies that we get expected codegen out of the -O2 optimization // level from the full optimizer. From dpatel at apple.com Tue Nov 3 12:30:28 2009 From: dpatel at apple.com (Devang Patel) Date: Tue, 03 Nov 2009 18:30:28 -0000 Subject: [llvm-commits] [llvm] r85909 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Message-ID: <200911031830.nA3IUStM020955@zion.cs.uiuc.edu> Author: dpatel Date: Tue Nov 3 12:30:27 2009 New Revision: 85909 URL: http://llvm.org/viewvc/llvm-project?rev=85909&view=rev Log: Ignore unnamed variables. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=85909&r1=85908&r2=85909&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Tue Nov 3 12:30:27 2009 @@ -1249,6 +1249,9 @@ DIE *DwarfDebug::CreateDbgScopeVariable(DbgVariable *DV, CompileUnit *Unit) { // Get the descriptor. const DIVariable &VD = DV->getVariable(); + const char *Name = VD.getName(); + if (!Name) + return NULL; // Translate tag to proper Dwarf tag. The result variable is dropped for // now. @@ -1267,7 +1270,6 @@ // Define variable debug information entry. DIE *VariableDie = new DIE(Tag); - const char *Name = VD.getName(); AddString(VariableDie, dwarf::DW_AT_name, dwarf::DW_FORM_string, Name); // Add source line info if available. From sabre at nondot.org Tue Nov 3 12:30:31 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 03 Nov 2009 18:30:31 -0000 Subject: [llvm-commits] [llvm] r85910 - /llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp Message-ID: <200911031830.nA3IUVTj020969@zion.cs.uiuc.edu> Author: lattner Date: Tue Nov 3 12:30:31 2009 New Revision: 85910 URL: http://llvm.org/viewvc/llvm-project?rev=85910&view=rev Log: mark some constant global const. Modified: llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp Modified: llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp?rev=85910&r1=85909&r2=85910&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp Tue Nov 3 12:30:31 2009 @@ -28,7 +28,6 @@ using namespace llvm; -namespace { //===----------------------------------------------------------------------===// /// Typedefs @@ -40,16 +39,18 @@ /// Constants // Indentation. -unsigned TabWidth = 4; -unsigned Indent1 = TabWidth*1; -unsigned Indent2 = TabWidth*2; -unsigned Indent3 = TabWidth*3; +static const unsigned TabWidth = 4; +static const unsigned Indent1 = TabWidth*1; +static const unsigned Indent2 = TabWidth*2; +static const unsigned Indent3 = TabWidth*3; // Default help string. -const char * DefaultHelpString = "NO HELP MESSAGE PROVIDED"; +static const char * const DefaultHelpString = "NO HELP MESSAGE PROVIDED"; // Name for the "sink" option. -const char * SinkOptionName = "AutoGeneratedSinkOption"; +static const char * const SinkOptionName = "AutoGeneratedSinkOption"; + +namespace { //===----------------------------------------------------------------------===// /// Helper functions From asl at math.spbu.ru Tue Nov 3 12:46:11 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Tue, 03 Nov 2009 18:46:11 -0000 Subject: [llvm-commits] [llvm] r85914 - in /llvm/trunk/lib/Target/ARM: ARMTargetMachine.cpp NEONMoveFix.cpp Message-ID: <200911031846.nA3IkBep021543@zion.cs.uiuc.edu> Author: asl Date: Tue Nov 3 12:46:11 2009 New Revision: 85914 URL: http://llvm.org/viewvc/llvm-project?rev=85914&view=rev Log: Move subtarget check upper for NEON reg-reg fixup pass. Modified: llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp llvm/trunk/lib/Target/ARM/NEONMoveFix.cpp Modified: llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp?rev=85914&r1=85913&r2=85914&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp Tue Nov 3 12:46:11 2009 @@ -115,7 +115,8 @@ if (OptLevel != CodeGenOpt::None) { if (!Subtarget.isThumb1Only()) PM.add(createIfConverterPass()); - PM.add(createNEONMoveFixPass()); + if (Subtarget.hasNEON()) + PM.add(createNEONMoveFixPass()); } if (Subtarget.isThumb2()) { Modified: llvm/trunk/lib/Target/ARM/NEONMoveFix.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/NEONMoveFix.cpp?rev=85914&r1=85913&r2=85914&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/NEONMoveFix.cpp (original) +++ llvm/trunk/lib/Target/ARM/NEONMoveFix.cpp Tue Nov 3 12:46:11 2009 @@ -35,7 +35,6 @@ private: const TargetRegisterInfo *TRI; const ARMBaseInstrInfo *TII; - const ARMSubtarget *Subtarget; typedef DenseMap RegMap; @@ -71,7 +70,7 @@ Domain = ARMII::DomainNEON; } - if ((Domain & ARMII::DomainNEON) && Subtarget->hasNEON()) { + if (Domain & ARMII::DomainNEON) { // Convert FCPYD to VMOVD. unsigned DestReg = MI->getOperand(0).getReg(); @@ -93,8 +92,7 @@ Modified = true; ++NumVMovs; } else { - assert((Domain & ARMII::DomainVFP || - !Subtarget->hasNEON()) && "Invalid domain!"); + assert((Domain & ARMII::DomainVFP) && "Invalid domain!"); // Do nothing. } } @@ -124,7 +122,6 @@ return false; TRI = TM.getRegisterInfo(); - Subtarget = &TM.getSubtarget(); TII = static_cast(TM.getInstrInfo()); bool Modified = false; From baldrick at free.fr Tue Nov 3 12:57:43 2009 From: baldrick at free.fr (Duncan Sands) Date: Tue, 03 Nov 2009 18:57:43 -0000 Subject: [llvm-commits] [dragonegg] r85915 - /dragonegg/trunk/llvm-types.cpp Message-ID: <200911031857.nA3IvhHX021984@zion.cs.uiuc.edu> Author: baldrick Date: Tue Nov 3 12:57:42 2009 New Revision: 85915 URL: http://llvm.org/viewvc/llvm-project?rev=85915&view=rev Log: In a qualified union, the smallest field needs to be chosen. This ensures that the LLVM type will be smaller than the smallest possible size achievable by the GCC type (which is of variable size), an important invariant for Ada. While there, for normal unions choose the field with the largest size, rather than the field with the largest alignment. I think the previous alignment choice was an attempt to help out the old constructor code, which had many assumptions about alignment. Modified: dragonegg/trunk/llvm-types.cpp Modified: dragonegg/trunk/llvm-types.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-types.cpp?rev=85915&r1=85914&r2=85915&view=diff ============================================================================== --- dragonegg/trunk/llvm-types.cpp (original) +++ dragonegg/trunk/llvm-types.cpp Tue Nov 3 12:57:42 2009 @@ -1854,13 +1854,17 @@ /// then we will add padding later on anyway to match union size. void TypeConverter::SelectUnionMember(tree type, StructTypeConversionInfo &Info) { + bool FindBiggest = TREE_CODE(type) != QUAL_UNION_TYPE; + const Type *UnionTy = 0; tree GccUnionTy = 0; tree UnionField = 0; - unsigned MaxAlignSize = 0, MaxAlign = 0; + unsigned MinAlign = ~0U; + uint64_t BestSize = FindBiggest ? 0ULL : ~0ULL; for (tree Field = TYPE_FIELDS(type); Field; Field = TREE_CHAIN(Field)) { if (TREE_CODE(Field) != FIELD_DECL) continue; - assert(getFieldOffsetInBits(Field) == 0 && "Union with non-zero offset?"); + assert(DECL_FIELD_OFFSET(Field) && integer_zerop(DECL_FIELD_OFFSET(Field)) + && "Union with non-zero offset?"); // Skip fields that are known not to be present. if (TREE_CODE(type) == QUAL_UNION_TYPE && @@ -1869,29 +1873,29 @@ tree TheGccTy = TREE_TYPE(Field); - // Skip zero-length fields; ConvertType refuses to construct a type - // of size 0. - if (DECL_SIZE(Field) && - TREE_CODE(DECL_SIZE(Field)) == INTEGER_CST && - TREE_INT_CST_LOW(DECL_SIZE(Field)) == 0) + // Skip zero-length bitfields. These are only used for setting the + // alignment. + if (DECL_BIT_FIELD(Field) && DECL_SIZE(Field) && + integer_zerop(DECL_SIZE(Field))) continue; const Type *TheTy = ConvertType(TheGccTy); - unsigned Size = Info.getTypeSize(TheTy); unsigned Align = Info.getTypeAlignment(TheTy); + uint64_t Size = Info.getTypeSize(TheTy); adjustPaddingElement(GccUnionTy, TheGccTy); - // Select TheTy as union type if it is more aligned than any other. If - // more than one field achieves the maximum alignment then choose the - // biggest. - if (UnionTy == 0 || Align > MaxAlign || - (Align == MaxAlign && Size > MaxAlignSize)) { + // Select TheTy as union type if it is the biggest/smallest field (depending + // on the value of FindBiggest). If more than one field achieves this size + // then choose the least aligned. + if ((Size == BestSize && Align < MinAlign) || + (FindBiggest && Size > BestSize) || + (!FindBiggest && Size < BestSize)) { UnionTy = TheTy; UnionField = Field; GccUnionTy = TheGccTy; - MaxAlignSize = Size; - MaxAlign = Align; + BestSize = Size; + MinAlign = Align; } // Skip remaining fields if this one is known to be present. From dpatel at apple.com Tue Nov 3 13:06:07 2009 From: dpatel at apple.com (Devang Patel) Date: Tue, 03 Nov 2009 19:06:07 -0000 Subject: [llvm-commits] [llvm] r85921 - in /llvm/trunk: lib/AsmParser/LLParser.cpp test/DebugInfo/2009-11-03-InsertExtractValue.ll Message-ID: <200911031906.nA3J68oi022376@zion.cs.uiuc.edu> Author: dpatel Date: Tue Nov 3 13:06:07 2009 New Revision: 85921 URL: http://llvm.org/viewvc/llvm-project?rev=85921&view=rev Log: Parse debug info attached with insertvalue and extractvalue instructions. Added: llvm/trunk/test/DebugInfo/2009-11-03-InsertExtractValue.ll Modified: llvm/trunk/lib/AsmParser/LLParser.cpp Modified: llvm/trunk/lib/AsmParser/LLParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=85921&r1=85920&r2=85921&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLParser.cpp (original) +++ llvm/trunk/lib/AsmParser/LLParser.cpp Tue Nov 3 13:06:07 2009 @@ -1137,6 +1137,8 @@ return TokError("expected ',' as start of index list"); while (EatIfPresent(lltok::comma)) { + if (Lex.getKind() == lltok::NamedOrCustomMD) + break; unsigned Idx; if (ParseUInt32(Idx)) return true; Indices.push_back(Idx); @@ -2111,6 +2113,9 @@ ParseIndexList(Indices) || ParseToken(lltok::rparen, "expected ')' in extractvalue constantexpr")) return true; + if (Lex.getKind() == lltok::NamedOrCustomMD) + if (ParseOptionalCustomMetadata()) return true; + if (!isa(Val->getType()) && !isa(Val->getType())) return Error(ID.Loc, "extractvalue operand must be array or struct"); if (!ExtractValueInst::getIndexedType(Val->getType(), Indices.begin(), @@ -2132,6 +2137,8 @@ ParseIndexList(Indices) || ParseToken(lltok::rparen, "expected ')' in insertvalue constantexpr")) return true; + if (Lex.getKind() == lltok::NamedOrCustomMD) + if (ParseOptionalCustomMetadata()) return true; if (!isa(Val0->getType()) && !isa(Val0->getType())) return Error(ID.Loc, "extractvalue operand must be array or struct"); if (!ExtractValueInst::getIndexedType(Val0->getType(), Indices.begin(), @@ -3737,6 +3744,8 @@ if (ParseTypeAndValue(Val, Loc, PFS) || ParseIndexList(Indices)) return true; + if (Lex.getKind() == lltok::NamedOrCustomMD) + if (ParseOptionalCustomMetadata()) return true; if (!isa(Val->getType()) && !isa(Val->getType())) return Error(Loc, "extractvalue operand must be array or struct"); @@ -3758,6 +3767,8 @@ ParseTypeAndValue(Val1, Loc1, PFS) || ParseIndexList(Indices)) return true; + if (Lex.getKind() == lltok::NamedOrCustomMD) + if (ParseOptionalCustomMetadata()) return true; if (!isa(Val0->getType()) && !isa(Val0->getType())) return Error(Loc0, "extractvalue operand must be array or struct"); Added: llvm/trunk/test/DebugInfo/2009-11-03-InsertExtractValue.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/2009-11-03-InsertExtractValue.ll?rev=85921&view=auto ============================================================================== --- llvm/trunk/test/DebugInfo/2009-11-03-InsertExtractValue.ll (added) +++ llvm/trunk/test/DebugInfo/2009-11-03-InsertExtractValue.ll Tue Nov 3 13:06:07 2009 @@ -0,0 +1,11 @@ +; RUN: llvm-as < %s | llvm-dis | FileCheck %s + +!0 = metadata !{i32 42} + +define <{i32, i32}> @f1() { +; CHECK: !dbg !0 + %r = insertvalue <{ i32, i32 }> zeroinitializer, i32 4, 1, !dbg !0 +; CHECK: !dbg !0 + %e = extractvalue <{ i32, i32 }> %r, 0, !dbg !0 + ret <{ i32, i32 }> %r +} From baldrick at free.fr Tue Nov 3 13:10:22 2009 From: baldrick at free.fr (Duncan Sands) Date: Tue, 03 Nov 2009 19:10:22 -0000 Subject: [llvm-commits] [llvm] r85922 - /llvm/trunk/lib/Support/MemoryBuffer.cpp Message-ID: <200911031910.nA3JAM5b022573@zion.cs.uiuc.edu> Author: baldrick Date: Tue Nov 3 13:10:22 2009 New Revision: 85922 URL: http://llvm.org/viewvc/llvm-project?rev=85922&view=rev Log: Make this code more robust by not thinking we are making progress if zero bytes were read. Modified: llvm/trunk/lib/Support/MemoryBuffer.cpp Modified: llvm/trunk/lib/Support/MemoryBuffer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/MemoryBuffer.cpp?rev=85922&r1=85921&r2=85922&view=diff ============================================================================== --- llvm/trunk/lib/Support/MemoryBuffer.cpp (original) +++ llvm/trunk/lib/Support/MemoryBuffer.cpp Tue Nov 3 13:10:22 2009 @@ -226,7 +226,7 @@ size_t BytesLeft = FileSize; while (BytesLeft) { ssize_t NumRead = ::read(FD, BufPtr, BytesLeft); - if (NumRead != -1) { + if (NumRead > 0) { BytesLeft -= NumRead; BufPtr += NumRead; } else if (errno == EINTR) { From sabre at nondot.org Tue Nov 3 13:24:52 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 03 Nov 2009 19:24:52 -0000 Subject: [llvm-commits] [llvm] r85923 - in /llvm/trunk: lib/Transforms/Scalar/SCCP.cpp test/Transforms/SCCP/ipsccp-basic.ll Message-ID: <200911031924.nA3JOqcx023129@zion.cs.uiuc.edu> Author: lattner Date: Tue Nov 3 13:24:51 2009 New Revision: 85923 URL: http://llvm.org/viewvc/llvm-project?rev=85923&view=rev Log: fix an IPSCCP bug I introduced when I changed IPSCCP to start working on functions that don't have local linkage. Basically, we need to be more careful about propagating argument information to functions whose results we aren't tracking. This fixes a miscompilation of LLVMCConfigurationEmitter.cpp when built with an llvm-gcc that has ipsccp enabled. Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp llvm/trunk/test/Transforms/SCCP/ipsccp-basic.ll Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCP.cpp?rev=85923&r1=85922&r2=85923&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SCCP.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Tue Nov 3 13:24:51 2009 @@ -174,6 +174,9 @@ /// that return multiple values. DenseMap, LatticeVal> TrackedMultipleRetVals; + /// TrackingIncomingArguments - This is the set of functions that are + SmallPtrSet TrackingIncomingArguments; + /// The reason for two worklists is that overdefined is the lowest state /// on the lattice, and moving things to overdefined as fast as possible /// makes SCCP converge much faster. @@ -235,6 +238,10 @@ TrackedRetVals.insert(std::make_pair(F, LatticeVal())); } + void AddArgumentTrackedFunction(Function *F) { + TrackingIncomingArguments.insert(F); + } + /// Solve - Solve for constants and executable blocks. /// void Solve(); @@ -1190,6 +1197,27 @@ return markOverdefined(I); } + // If this is a local function that doesn't have its address taken, mark its + // entry block executable and merge in the actual arguments to the call into + // the formal arguments of the function. + if (!TrackingIncomingArguments.empty() && TrackingIncomingArguments.count(F)){ + MarkBlockExecutable(F->begin()); + + // Propagate information from this call site into the callee. + CallSite::arg_iterator CAI = CS.arg_begin(); + for (Function::arg_iterator AI = F->arg_begin(), E = F->arg_end(); + AI != E; ++AI, ++CAI) { + // If this argument is byval, and if the function is not readonly, there + // will be an implicit copy formed of the input aggregate. + if (AI->hasByValAttr() && !F->onlyReadsMemory()) { + markOverdefined(AI); + continue; + } + + mergeInValue(AI, getValueState(*CAI)); + } + } + // If this is a single/zero retval case, see if we're tracking the function. DenseMap::iterator TFRVI = TrackedRetVals.find(F); if (TFRVI != TrackedRetVals.end()) { @@ -1228,24 +1256,6 @@ // common path above. goto CallOverdefined; } - - // Finally, if this is the first call to the function hit, mark its entry - // block executable. - MarkBlockExecutable(F->begin()); - - // Propagate information from this call site into the callee. - CallSite::arg_iterator CAI = CS.arg_begin(); - for (Function::arg_iterator AI = F->arg_begin(), E = F->arg_end(); - AI != E; ++AI, ++CAI) { - // If this argument is byval, and if the function is not readonly, there - // will be an implicit copy formed of the input aggregate. - if (AI->hasByValAttr() && !F->onlyReadsMemory()) { - markOverdefined(AI); - continue; - } - - mergeInValue(AI, getValueState(*CAI)); - } } void SCCPSolver::Solve() { @@ -1656,8 +1666,10 @@ // If this function only has direct calls that we can see, we can track its // arguments and return value aggressively, and can assume it is not called // unless we see evidence to the contrary. - if (F->hasLocalLinkage() && !AddressIsTaken(F)) + if (F->hasLocalLinkage() && !AddressIsTaken(F)) { + Solver.AddArgumentTrackedFunction(F); continue; + } // Assume the function is called. Solver.MarkBlockExecutable(F->begin()); Modified: llvm/trunk/test/Transforms/SCCP/ipsccp-basic.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SCCP/ipsccp-basic.ll?rev=85923&r1=85922&r2=85923&view=diff ============================================================================== --- llvm/trunk/test/Transforms/SCCP/ipsccp-basic.ll (original) +++ llvm/trunk/test/Transforms/SCCP/ipsccp-basic.ll Tue Nov 3 13:24:51 2009 @@ -174,4 +174,24 @@ ; CHECK-NEXT: ret i32 36 } +;;======================== test8 + + +define internal {} @test8a(i32 %A, i32* %P) { + store i32 %A, i32* %P + ret {} {} +; CHECK: @test8a +; CHECK-NEXT: store i32 5, +; CHECK-NEXT: ret +} + +define void @test8b(i32* %P) { + %X = call {} @test8a(i32 5, i32* %P) + ret void +; CHECK: define void @test8b +; CHECK-NEXT: call {} @test8a +; CHECK-NEXT: ret void +} + + From gohman at apple.com Tue Nov 3 13:28:48 2009 From: gohman at apple.com (Dan Gohman) Date: Tue, 3 Nov 2009 11:28:48 -0800 Subject: [llvm-commits] [llvm] r85922 - /llvm/trunk/lib/Support/MemoryBuffer.cpp In-Reply-To: <200911031910.nA3JAM5b022573@zion.cs.uiuc.edu> References: <200911031910.nA3JAM5b022573@zion.cs.uiuc.edu> Message-ID: Hi Duncan, On Nov 3, 2009, at 11:10 AM, Duncan Sands wrote: > --- llvm/trunk/lib/Support/MemoryBuffer.cpp (original) > +++ llvm/trunk/lib/Support/MemoryBuffer.cpp Tue Nov 3 13:10:22 2009 > @@ -226,7 +226,7 @@ > size_t BytesLeft = FileSize; > while (BytesLeft) { > ssize_t NumRead = ::read(FD, BufPtr, BytesLeft); > - if (NumRead != -1) { > + if (NumRead > 0) { > BytesLeft -= NumRead; > BufPtr += NumRead; > } else if (errno == EINTR) { Given this, the code should explicitly set errno to 0 so that it doesn't infinite loop if it reaches the end of the file and errno happens to have the value EINTR. Dan From sabre at nondot.org Tue Nov 3 13:35:13 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 03 Nov 2009 19:35:13 -0000 Subject: [llvm-commits] [llvm] r85929 - in /llvm/trunk: include/llvm/Support/StandardPasses.h test/FrontendC++/integration-O2.cpp Message-ID: <200911031935.nA3JZEQC023567@zion.cs.uiuc.edu> Author: lattner Date: Tue Nov 3 13:35:13 2009 New Revision: 85929 URL: http://llvm.org/viewvc/llvm-project?rev=85929&view=rev Log: turn IPSCCP back on by default, try #3 or 4? Woo. Modified: llvm/trunk/include/llvm/Support/StandardPasses.h llvm/trunk/test/FrontendC++/integration-O2.cpp Modified: llvm/trunk/include/llvm/Support/StandardPasses.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/StandardPasses.h?rev=85929&r1=85928&r2=85929&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/StandardPasses.h (original) +++ llvm/trunk/include/llvm/Support/StandardPasses.h Tue Nov 3 13:35:13 2009 @@ -99,8 +99,7 @@ if (UnitAtATime) { PM->add(createGlobalOptimizerPass()); // Optimize out global vars - PM->add(createIPConstantPropagationPass()); // IP CP -// PM->add(createIPSCCPPass()); // IP SCCP + PM->add(createIPSCCPPass()); // IP SCCP PM->add(createDeadArgEliminationPass()); // Dead argument elimination } PM->add(createInstructionCombiningPass()); // Clean up after IPCP & DAE Modified: llvm/trunk/test/FrontendC++/integration-O2.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC%2B%2B/integration-O2.cpp?rev=85929&r1=85928&r2=85929&view=diff ============================================================================== --- llvm/trunk/test/FrontendC++/integration-O2.cpp (original) +++ llvm/trunk/test/FrontendC++/integration-O2.cpp Tue Nov 3 13:35:13 2009 @@ -1,5 +1,4 @@ // RUN: %llvmgxx %s -O2 -S -o - | FileCheck %s -// XFAIL: * // This test verifies that we get expected codegen out of the -O2 optimization // level from the full optimizer. From vhernandez at apple.com Tue Nov 3 14:02:36 2009 From: vhernandez at apple.com (Victor Hernandez) Date: Tue, 03 Nov 2009 20:02:36 -0000 Subject: [llvm-commits] [llvm] r85933 - /llvm/trunk/lib/Analysis/MemoryBuiltins.cpp Message-ID: <200911032002.nA3K2aSe024624@zion.cs.uiuc.edu> Author: hernande Date: Tue Nov 3 14:02:35 2009 New Revision: 85933 URL: http://llvm.org/viewvc/llvm-project?rev=85933&view=rev Log: Changes (* location in pointer variables, avoiding include, and using APInt::getLimitedValue) based on feedback to r85814 Modified: llvm/trunk/lib/Analysis/MemoryBuiltins.cpp Modified: llvm/trunk/lib/Analysis/MemoryBuiltins.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryBuiltins.cpp?rev=85933&r1=85932&r2=85933&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/MemoryBuiltins.cpp (original) +++ llvm/trunk/lib/Analysis/MemoryBuiltins.cpp Tue Nov 3 14:02:35 2009 @@ -16,7 +16,6 @@ #include "llvm/Constants.h" #include "llvm/Instructions.h" #include "llvm/Module.h" -#include "llvm/ADT/APInt.h" #include "llvm/Analysis/ConstantFolding.h" using namespace llvm; @@ -26,7 +25,7 @@ /// isMalloc - Returns true if the the value is either a malloc call or a /// bitcast of the result of a malloc call. -bool llvm::isMalloc(const Value* I) { +bool llvm::isMalloc(const Value *I) { return extractMallocCall(I) || extractMallocCallFromBitCast(I); } @@ -34,7 +33,7 @@ if (!CI) return false; - const Module* M = CI->getParent()->getParent()->getParent(); + const Module *M = CI->getParent()->getParent()->getParent(); Function *MallocFunc = M->getFunction("malloc"); if (CI->getOperand(0) != MallocFunc) @@ -58,17 +57,17 @@ /// extractMallocCall - Returns the corresponding CallInst if the instruction /// is a malloc call. Since CallInst::CreateMalloc() only creates calls, we /// ignore InvokeInst here. -const CallInst* llvm::extractMallocCall(const Value* I) { +const CallInst *llvm::extractMallocCall(const Value *I) { const CallInst *CI = dyn_cast(I); return (isMallocCall(CI)) ? CI : NULL; } -CallInst* llvm::extractMallocCall(Value* I) { +CallInst *llvm::extractMallocCall(Value *I) { CallInst *CI = dyn_cast(I); return (isMallocCall(CI)) ? CI : NULL; } -static bool isBitCastOfMallocCall(const BitCastInst* BCI) { +static bool isBitCastOfMallocCall(const BitCastInst *BCI) { if (!BCI) return false; @@ -77,13 +76,13 @@ /// extractMallocCallFromBitCast - Returns the corresponding CallInst if the /// instruction is a bitcast of the result of a malloc call. -CallInst* llvm::extractMallocCallFromBitCast(Value* I) { +CallInst *llvm::extractMallocCallFromBitCast(Value *I) { BitCastInst *BCI = dyn_cast(I); return (isBitCastOfMallocCall(BCI)) ? cast(BCI->getOperand(0)) : NULL; } -const CallInst* llvm::extractMallocCallFromBitCast(const Value* I) { +const CallInst *llvm::extractMallocCallFromBitCast(const Value *I) { const BitCastInst *BCI = dyn_cast(I); return (isBitCastOfMallocCall(BCI)) ? cast(BCI->getOperand(0)) : NULL; @@ -94,21 +93,21 @@ return isa(val) && cast(val)->isOne(); } -static Value* isArrayMallocHelper(const CallInst *CI, LLVMContext &Context, - const TargetData* TD) { +static Value *isArrayMallocHelper(const CallInst *CI, LLVMContext &Context, + const TargetData *TD) { if (!CI) return NULL; // Type must be known to determine array size. - const Type* T = getMallocAllocatedType(CI); + const Type *T = getMallocAllocatedType(CI); if (!T) return NULL; - Value* MallocArg = CI->getOperand(1); - ConstantExpr* CO = dyn_cast(MallocArg); - BinaryOperator* BO = dyn_cast(MallocArg); + Value *MallocArg = CI->getOperand(1); + ConstantExpr *CO = dyn_cast(MallocArg); + BinaryOperator *BO = dyn_cast(MallocArg); - Constant* ElementSize = ConstantExpr::getSizeOf(T); + Constant *ElementSize = ConstantExpr::getSizeOf(T); ElementSize = ConstantExpr::getTruncOrBitCast(ElementSize, MallocArg->getType()); Constant *FoldedElementSize = @@ -128,8 +127,8 @@ if (!CO && !BO) return NULL; - Value* Op0 = NULL; - Value* Op1 = NULL; + Value *Op0 = NULL; + Value *Op1 = NULL; unsigned Opcode = 0; if (CO && ((CO->getOpcode() == Instruction::Mul) || (CO->getOpcode() == Instruction::Shl))) { @@ -157,17 +156,13 @@ return Op1; } if (Opcode == Instruction::Shl) { - ConstantInt* Op1CI = dyn_cast(Op1); + ConstantInt *Op1CI = dyn_cast(Op1); if (!Op1CI) return NULL; APInt Op1Int = Op1CI->getValue(); - unsigned Op1Width = Op1Int.getBitWidth(); - // check for overflow - if (Op1Int.getActiveBits() > 64 || Op1Int.getZExtValue() > Op1Width) - return NULL; - Value* Op1Pow = ConstantInt::get(Context, - APInt(Op1Width, 0).set(Op1Int.getZExtValue())); - + uint64_t BitToSet = Op1Int.getLimitedValue(Op1Int.getBitWidth() - 1); + Value *Op1Pow = ConstantInt::get(Context, + APInt(Op1Int.getBitWidth(), 0).set(BitToSet)); if (Op0 == ElementSize || (FoldedElementSize && Op0 == FoldedElementSize)) // ArraySize << log2(ElementSize) return Op1Pow; @@ -185,10 +180,10 @@ /// isArrayMalloc - Returns the corresponding CallInst if the instruction /// is a call to malloc whose array size can be determined and the array size /// is not constant 1. Otherwise, return NULL. -CallInst* llvm::isArrayMalloc(Value* I, LLVMContext &Context, - const TargetData* TD) { +CallInst *llvm::isArrayMalloc(Value *I, LLVMContext &Context, + const TargetData *TD) { CallInst *CI = extractMallocCall(I); - Value* ArraySize = isArrayMallocHelper(CI, Context, TD); + Value *ArraySize = isArrayMallocHelper(CI, Context, TD); if (ArraySize && ArraySize != ConstantInt::get(CI->getOperand(1)->getType(), 1)) @@ -198,10 +193,10 @@ return NULL; } -const CallInst* llvm::isArrayMalloc(const Value* I, LLVMContext &Context, - const TargetData* TD) { +const CallInst *llvm::isArrayMalloc(const Value *I, LLVMContext &Context, + const TargetData *TD) { const CallInst *CI = extractMallocCall(I); - Value* ArraySize = isArrayMallocHelper(CI, Context, TD); + Value *ArraySize = isArrayMallocHelper(CI, Context, TD); if (ArraySize && ArraySize != ConstantInt::get(CI->getOperand(1)->getType(), 1)) @@ -214,10 +209,10 @@ /// getMallocType - Returns the PointerType resulting from the malloc call. /// This PointerType is the result type of the call's only bitcast use. /// If there is no unique bitcast use, then return NULL. -const PointerType* llvm::getMallocType(const CallInst* CI) { +const PointerType *llvm::getMallocType(const CallInst *CI) { assert(isMalloc(CI) && "GetMallocType and not malloc call"); - const BitCastInst* BCI = NULL; + const BitCastInst *BCI = NULL; // Determine if CallInst has a bitcast use. for (Value::use_const_iterator UI = CI->use_begin(), E = CI->use_end(); @@ -241,8 +236,8 @@ /// getMallocAllocatedType - Returns the Type allocated by malloc call. This /// Type is the result type of the call's only bitcast use. If there is no /// unique bitcast use, then return NULL. -const Type* llvm::getMallocAllocatedType(const CallInst* CI) { - const PointerType* PT = getMallocType(CI); +const Type *llvm::getMallocAllocatedType(const CallInst *CI) { + const PointerType *PT = getMallocType(CI); return PT ? PT->getElementType() : NULL; } @@ -251,8 +246,8 @@ /// then return that multiple. For non-array mallocs, the multiple is /// constant 1. Otherwise, return NULL for mallocs whose array size cannot be /// determined. -Value* llvm::getMallocArraySize(CallInst* CI, LLVMContext &Context, - const TargetData* TD) { +Value *llvm::getMallocArraySize(CallInst *CI, LLVMContext &Context, + const TargetData *TD) { return isArrayMallocHelper(CI, Context, TD); } @@ -261,12 +256,12 @@ // /// isFreeCall - Returns true if the the value is a call to the builtin free() -bool llvm::isFreeCall(const Value* I) { +bool llvm::isFreeCall(const Value *I) { const CallInst *CI = dyn_cast(I); if (!CI) return false; - const Module* M = CI->getParent()->getParent()->getParent(); + const Module *M = CI->getParent()->getParent()->getParent(); Function *FreeFunc = M->getFunction("free"); if (CI->getOperand(0) != FreeFunc) From baldrick at free.fr Tue Nov 3 14:08:31 2009 From: baldrick at free.fr (Duncan Sands) Date: Tue, 03 Nov 2009 21:08:31 +0100 Subject: [llvm-commits] [llvm] r85922 - /llvm/trunk/lib/Support/MemoryBuffer.cpp In-Reply-To: References: <200911031910.nA3JAM5b022573@zion.cs.uiuc.edu> Message-ID: <4AF08DBF.7090005@free.fr> Hi Dan, >> --- llvm/trunk/lib/Support/MemoryBuffer.cpp (original) >> +++ llvm/trunk/lib/Support/MemoryBuffer.cpp Tue Nov 3 13:10:22 2009 >> @@ -226,7 +226,7 @@ >> size_t BytesLeft = FileSize; >> while (BytesLeft) { >> ssize_t NumRead = ::read(FD, BufPtr, BytesLeft); >> - if (NumRead != -1) { >> + if (NumRead > 0) { >> BytesLeft -= NumRead; >> BufPtr += NumRead; >> } else if (errno == EINTR) { > > Given this, the code should explicitly set errno to 0 so that it doesn't > infinite loop if it reaches the end of the file and errno happens to > have the value EINTR. if errno is EINTR, isn't it correct to go around again, even if zero bytes were read? Ciao, Duncan. From asl at math.spbu.ru Tue Nov 3 14:09:19 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Tue, 3 Nov 2009 23:09:19 +0300 Subject: [llvm-commits] [llvm] r85850 - in /llvm/trunk/lib/Target/ARM: ARM.h ARMBaseInstrInfo.cpp ARMTargetMachine.cpp NEONMoveFix.cpp In-Reply-To: <1C12EC22-892A-4F26-8005-B2AD1EBEDBC8@apple.com> References: <200911030104.nA314RYX031608@zion.cs.uiuc.edu> <1C12EC22-892A-4F26-8005-B2AD1EBEDBC8@apple.com> Message-ID: > Please make sure this is run only when NEON is available. Done. Actually, there was already a check inside - I moved it upper. -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From david_goodwin at apple.com Tue Nov 3 14:15:00 2009 From: david_goodwin at apple.com (David Goodwin) Date: Tue, 03 Nov 2009 20:15:00 -0000 Subject: [llvm-commits] [llvm] r85934 - /llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp Message-ID: <200911032015.nA3KF0LW025030@zion.cs.uiuc.edu> Author: david_goodwin Date: Tue Nov 3 14:15:00 2009 New Revision: 85934 URL: http://llvm.org/viewvc/llvm-project?rev=85934&view=rev Log: . When building schedule graph use mayAlias information to avoid chaining loads/stores of spill slots with non-aliased memory ops. Modified: llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp Modified: llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp?rev=85934&r1=85933&r2=85934&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp (original) +++ llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp Tue Nov 3 14:15:00 2009 @@ -98,7 +98,9 @@ /// information and it can be tracked to a normal reference to a known /// object, return the Value for that object. Otherwise return null. static const Value *getUnderlyingObjectForInstr(const MachineInstr *MI, - const MachineFrameInfo *MFI) { + const MachineFrameInfo *MFI, + bool &MayAlias) { + MayAlias = true; if (!MI->hasOneMemOperand() || !(*MI->memoperands_begin())->getValue() || (*MI->memoperands_begin())->isVolatile()) @@ -110,6 +112,7 @@ V = getUnderlyingObject(V); if (const PseudoSourceValue *PSV = dyn_cast(V)) { + MayAlias = PSV->mayAlias(MFI); // For now, ignore PseudoSourceValues which may alias LLVM IR values // because the code that uses this function has no way to cope with // such aliases. @@ -124,6 +127,23 @@ return 0; } +static bool mayUnderlyingObjectForInstrAlias(const MachineInstr *MI, + const MachineFrameInfo *MFI) { + if (!MI->hasOneMemOperand() || + !(*MI->memoperands_begin())->getValue() || + (*MI->memoperands_begin())->isVolatile()) + return true; + + const Value *V = (*MI->memoperands_begin())->getValue(); + if (!V) + return true; + + V = getUnderlyingObject(V); + if (const PseudoSourceValue *PSV = dyn_cast(V)) + return PSV->mayAlias(MFI); + return true; +} + void ScheduleDAGInstrs::StartBlock(MachineBasicBlock *BB) { if (MachineLoop *ML = MLI.getLoopFor(BB)) if (BB == ML->getLoopLatch()) { @@ -362,8 +382,9 @@ // Unknown memory accesses. Assume the worst. ChainMMO = 0; } else if (TID.mayStore()) { + bool MayAlias = true; TrueMemOrderLatency = STORE_LOAD_LATENCY; - if (const Value *V = getUnderlyingObjectForInstr(MI, MFI)) { + if (const Value *V = getUnderlyingObjectForInstr(MI, MFI, MayAlias)) { // A store to a specific PseudoSourceValue. Add precise dependencies. // Handle the def in MemDefs, if there is one. std::map::iterator I = MemDefs.find(V); @@ -383,22 +404,26 @@ /*Reg=*/0, /*isNormalMemory=*/true)); J->second.clear(); } - // Add dependencies from all the PendingLoads, since without - // memoperands we must assume they alias anything. - for (unsigned k = 0, m = PendingLoads.size(); k != m; ++k) - PendingLoads[k]->addPred(SDep(SU, SDep::Order, TrueMemOrderLatency)); - // Add a general dependence too, if needed. - if (Chain) - Chain->addPred(SDep(SU, SDep::Order, /*Latency=*/0)); - } else { + if (MayAlias) { + // Add dependencies from all the PendingLoads, since without + // memoperands we must assume they alias anything. + for (unsigned k = 0, m = PendingLoads.size(); k != m; ++k) + PendingLoads[k]->addPred(SDep(SU, SDep::Order, TrueMemOrderLatency)); + // Add a general dependence too, if needed. + if (Chain) + Chain->addPred(SDep(SU, SDep::Order, /*Latency=*/0)); + } + } else if (MayAlias) { // Treat all other stores conservatively. goto new_chain; } } else if (TID.mayLoad()) { + bool MayAlias = true; TrueMemOrderLatency = 0; if (MI->isInvariantLoad(AA)) { // Invariant load, no chain dependencies needed! - } else if (const Value *V = getUnderlyingObjectForInstr(MI, MFI)) { + } else if (const Value *V = + getUnderlyingObjectForInstr(MI, MFI, MayAlias)) { // A load from a specific PseudoSourceValue. Add precise dependencies. std::map::iterator I = MemDefs.find(V); if (I != MemDefs.end()) @@ -414,16 +439,19 @@ // Treat volatile loads conservatively. Note that this includes // cases where memoperand information is unavailable. goto new_chain; - } else { - // A normal load. Depend on the general chain, as well as on + } else if (MayAlias) { + // A "MayAlias" load. Depend on the general chain, as well as on // all stores. In the absense of MachineMemOperand information, // we can't even assume that the load doesn't alias well-behaved // memory locations. if (Chain) Chain->addPred(SDep(SU, SDep::Order, /*Latency=*/0)); for (std::map::iterator I = MemDefs.begin(), - E = MemDefs.end(); I != E; ++I) - I->second->addPred(SDep(SU, SDep::Order, /*Latency=*/0)); + E = MemDefs.end(); I != E; ++I) { + SUnit *DefSU = I->second; + if (mayUnderlyingObjectForInstrAlias(DefSU->getInstr(), MFI)) + DefSU->addPred(SDep(SU, SDep::Order, /*Latency=*/0)); + } PendingLoads.push_back(SU); } } From vhernandez at apple.com Tue Nov 3 14:16:37 2009 From: vhernandez at apple.com (Victor Hernandez) Date: Tue, 3 Nov 2009 12:16:37 -0800 Subject: [llvm-commits] [llvm] r85814 - /llvm/trunk/lib/Analysis/MemoryBuiltins.cpp In-Reply-To: References: <200911021851.nA2IpTYX014735@zion.cs.uiuc.edu> Message-ID: <5AF1EA0B-5B79-43C8-8A85-8088DD84333D@apple.com> Fixed these in r85933. Victor On Nov 2, 2009, at 8:29 PM, Chris Lattner wrote: > On Nov 2, 2009, at 10:51 AM, Victor Hernandez wrote: >> URL: http://llvm.org/viewvc/llvm-project?rev=85814&view=rev >> Log: >> Set bit instead of calling pow() to compute 2 << n > > Thanks Victor, > >> +++ llvm/trunk/lib/Analysis/MemoryBuiltins.cpp Mon Nov 2 12:51:28 >> 2009 >> @@ -16,6 +16,7 @@ >> #include "llvm/Constants.h" >> #include "llvm/Instructions.h" >> #include "llvm/Module.h" >> +#include "llvm/ADT/APInt.h" > > You don't need this #include, please remove it. > >> @@ -156,15 +157,22 @@ >> return Op1; >> } >> if (Opcode == Instruction::Shl) { >> - ConstantInt* Op1Int = dyn_cast(Op1); >> - if (!Op1Int) return NULL; >> - Value* Op1Pow = ConstantInt::get(Op1->getType(), (uint64_t) >> - pow(2.0, (double) Op1Int- >> >getZExtValue())); >> + ConstantInt* Op1CI = dyn_cast(Op1); >> + if (!Op1CI) return NULL; >> + >> + APInt Op1Int = Op1CI->getValue(); >> + unsigned Op1Width = Op1Int.getBitWidth(); >> + // check for overflow >> + if (Op1Int.getActiveBits() > 64 || Op1Int.getZExtValue() > >> Op1Width) >> + return NULL; > > If the shift overflows, the original code is undefined. Please just > use the APInt::getLimitedValue method (with the bitwidth as the > argument) to handle this. You'll end up with much more elegant code. > > Finally, please use: > > ConstantInt *Op1CI > instead of: > ConstantInt* Op1CI > > With Op1CI and many other variables in this file. > > Thanks, > > -Chris > > > >> + Value* Op1Pow = ConstantInt::get(Context, >> + APInt(Op1Width, 0).set >> (Op1Int.getZExtValue())); >> + >> if (Op0 == ElementSize || (FoldedElementSize && Op0 == >> FoldedElementSize)) >> // ArraySize << log2(ElementSize) >> return Op1Pow; >> if (Op1Pow == ElementSize || >> - (FoldedElementSize && Op1Pow == FoldedElementSize)) >> + (FoldedElementSize && Op1Pow == FoldedElementSize)) >> // ElementSize << log2(ArraySize) >> return Op0; >> } >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091103/20d4b82b/attachment.html From baldrick at free.fr Tue Nov 3 14:16:35 2009 From: baldrick at free.fr (Duncan Sands) Date: Tue, 03 Nov 2009 21:16:35 +0100 Subject: [llvm-commits] [llvm] r85923 - in /llvm/trunk: lib/Transforms/Scalar/SCCP.cpp test/Transforms/SCCP/ipsccp-basic.ll In-Reply-To: <200911031924.nA3JOqcx023129@zion.cs.uiuc.edu> References: <200911031924.nA3JOqcx023129@zion.cs.uiuc.edu> Message-ID: <4AF08FA3.2050909@free.fr> Hi Chris, > + /// TrackingIncomingArguments - This is the set of functions that are incomplete comment. Ciao, Duncan. From vhernandez at apple.com Tue Nov 3 14:39:35 2009 From: vhernandez at apple.com (Victor Hernandez) Date: Tue, 03 Nov 2009 20:39:35 -0000 Subject: [llvm-commits] [llvm] r85936 - in /llvm/trunk/lib: Analysis/MemoryBuiltins.cpp VMCore/Instruction.cpp Message-ID: <200911032039.nA3KdZuW026026@zion.cs.uiuc.edu> Author: hernande Date: Tue Nov 3 14:39:35 2009 New Revision: 85936 URL: http://llvm.org/viewvc/llvm-project?rev=85936&view=rev Log: Changes requested (avoid getFunction(), avoid Type creation via isVoidTy(), and avoid redundant isFreeCall cases) in feedback to r85176 Modified: llvm/trunk/lib/Analysis/MemoryBuiltins.cpp llvm/trunk/lib/VMCore/Instruction.cpp Modified: llvm/trunk/lib/Analysis/MemoryBuiltins.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryBuiltins.cpp?rev=85936&r1=85935&r2=85936&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/MemoryBuiltins.cpp (original) +++ llvm/trunk/lib/Analysis/MemoryBuiltins.cpp Tue Nov 3 14:39:35 2009 @@ -33,16 +33,14 @@ if (!CI) return false; - const Module *M = CI->getParent()->getParent()->getParent(); - Function *MallocFunc = M->getFunction("malloc"); - - if (CI->getOperand(0) != MallocFunc) + Function *Callee = CI->getCalledFunction(); + if (Callee == 0 || !Callee->isDeclaration() || Callee->getName() != "malloc") return false; // Check malloc prototype. // FIXME: workaround for PR5130, this will be obsolete when a nobuiltin // attribute will exist. - const FunctionType *FTy = MallocFunc->getFunctionType(); + const FunctionType *FTy = Callee->getFunctionType(); if (FTy->getNumParams() != 1) return false; if (IntegerType *ITy = dyn_cast(FTy->param_begin()->get())) { @@ -260,22 +258,19 @@ const CallInst *CI = dyn_cast(I); if (!CI) return false; - - const Module *M = CI->getParent()->getParent()->getParent(); - Function *FreeFunc = M->getFunction("free"); - - if (CI->getOperand(0) != FreeFunc) + Function *Callee = CI->getCalledFunction(); + if (Callee == 0 || !Callee->isDeclaration() || Callee->getName() != "free") return false; // Check free prototype. // FIXME: workaround for PR5130, this will be obsolete when a nobuiltin // attribute will exist. - const FunctionType *FTy = FreeFunc->getFunctionType(); - if (FTy->getReturnType() != Type::getVoidTy(M->getContext())) + const FunctionType *FTy = Callee->getFunctionType(); + if (!FTy->getReturnType()->isVoidTy()) return false; if (FTy->getNumParams() != 1) return false; - if (FTy->param_begin()->get() != Type::getInt8PtrTy(M->getContext())) + if (FTy->param_begin()->get() != Type::getInt8PtrTy(Callee->getContext())) return false; return true; Modified: llvm/trunk/lib/VMCore/Instruction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instruction.cpp?rev=85936&r1=85935&r2=85936&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Instruction.cpp (original) +++ llvm/trunk/lib/VMCore/Instruction.cpp Tue Nov 3 14:39:35 2009 @@ -303,32 +303,6 @@ return false; } -// Code here matches isFreeCall from MemoryBuiltins, which is not in VMCore. -static bool isFreeCall(const Value* I) { - const CallInst *CI = dyn_cast(I); - if (!CI) - return false; - - const Module* M = CI->getParent()->getParent()->getParent(); - Function *FreeFunc = M->getFunction("free"); - - if (CI->getOperand(0) != FreeFunc) - return false; - - // Check free prototype. - // FIXME: workaround for PR5130, this will be obsolete when a nobuiltin - // attribute will exist. - const FunctionType *FTy = FreeFunc->getFunctionType(); - if (FTy->getReturnType() != Type::getVoidTy(M->getContext())) - return false; - if (FTy->getNumParams() != 1) - return false; - if (FTy->param_begin()->get() != Type::getInt8PtrTy(M->getContext())) - return false; - - return true; -} - /// mayReadFromMemory - Return true if this instruction may read memory. /// bool Instruction::mayReadFromMemory() const { @@ -338,8 +312,6 @@ case Instruction::Load: return true; case Instruction::Call: - if (isFreeCall(this)) - return true; return !cast(this)->doesNotAccessMemory(); case Instruction::Invoke: return !cast(this)->doesNotAccessMemory(); @@ -357,8 +329,6 @@ case Instruction::VAArg: return true; case Instruction::Call: - if (isFreeCall(this)) - return true; return !cast(this)->onlyReadsMemory(); case Instruction::Invoke: return !cast(this)->onlyReadsMemory(); @@ -418,18 +388,16 @@ CI = dyn_cast(BCI->getOperand(0)); } - if (!CI) return false; - - const Module* M = CI->getParent()->getParent()->getParent(); - Constant *MallocFunc = M->getFunction("malloc"); - - if (CI->getOperand(0) != MallocFunc) + if (!CI) + return false; + Function *Callee = CI->getCalledFunction(); + if (Callee == 0 || !Callee->isDeclaration() || Callee->getName() != "malloc") return false; // Check malloc prototype. // FIXME: workaround for PR5130, this will be obsolete when a nobuiltin // attribute will exist. - const FunctionType *FTy = cast(MallocFunc)->getFunctionType(); + const FunctionType *FTy = Callee->getFunctionType(); if (FTy->getNumParams() != 1) return false; if (IntegerType *ITy = dyn_cast(FTy->param_begin()->get())) { From vhernandez at apple.com Tue Nov 3 14:40:11 2009 From: vhernandez at apple.com (Victor Hernandez) Date: Tue, 3 Nov 2009 12:40:11 -0800 Subject: [llvm-commits] [llvm] r85176 - in /llvm/trunk: examples/BrainF/ include/llvm-c/ include/llvm/ include/llvm/Analysis/ include/llvm/Support/ include/llvm/Transforms/ lib/Analysis/ lib/Analysis/IPA/ lib/AsmParser/ lib/Bitcode/Writer/ lib/CodeGen/SelectionDAG/ lib/ExecutionEngine/Interpreter/ lib/Target/CBackend/ lib/Target/CppBackend/ lib/Target/MSIL/ lib/Transforms/Scalar/ lib/Transforms/Utils/ lib/VMCore/ In-Reply-To: References: <200910262343.n9QNhpYj012068@zion.cs.uiuc.edu> Message-ID: <11A96F11-9B45-470E-AA92-F277A2EA216C@apple.com> Fixed in r85936. Victor On Nov 2, 2009, at 9:36 PM, Chris Lattner wrote: > > On Oct 26, 2009, at 4:43 PM, Victor Hernandez wrote: > >> Author: hernande >> Date: Mon Oct 26 18:43:48 2009 >> New Revision: 85176 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=85176&view=rev >> Log: >> Remove FreeInst. >> Remove LowerAllocations pass. >> Update some more passes to treate free calls just like they were >> treating FreeInst. > > Thanks Victor, > >> >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- llvm/trunk/lib/VMCore/Instruction.cpp (original) > >> +// Code here matches isFreeCall from MallocHelper, which is not in >> VMCore. >> +static bool isFreeCall(const Value* I) { >> + const CallInst *CI = dyn_cast(I); >> + if (!CI) >> + return false; >> + >> + const Module* M = CI->getParent()->getParent()->getParent(); >> + Function *FreeFunc = M->getFunction("free"); >> + >> + if (CI->getOperand(0) != FreeFunc) >> + return false; > > Please use something like this, which would be much more efficient: > > const CallInst *CI = dyn_cast(I); > if (!CI) > return false; > Function *Callee = CI->getCalledFunction(); > if (Callee == 0 || !Callee->isDeclaration() || Callee->getName() != > "free") > return false; > > >> + >> + // Check free prototype. >> + // FIXME: workaround for PR5130, this will be obsolete when a >> nobuiltin >> + // attribute will exist. >> + const FunctionType *FTy = FreeFunc->getFunctionType(); >> + if (FTy->getReturnType() != Type::getVoidTy(M->getContext())) > > Use ->isVoidTy() instead of comparing against a newly constructed > type. > >> /// mayReadFromMemory - Return true if this instruction may read >> memory. >> /// >> bool Instruction::mayReadFromMemory() const { >> switch (getOpcode()) { >> default: return false; >> - case Instruction::Free: >> case Instruction::VAArg: >> case Instruction::Load: >> return true; >> case Instruction::Call: >> + if (isFreeCall(this)) >> + return true; >> return !cast(this)->doesNotAccessMemory(); > > This call to isFreeCall isn't needed because the existing code works > for it. > >> case Instruction::Invoke: >> return !cast(this)->doesNotAccessMemory(); >> @@ -326,11 +352,12 @@ >> bool Instruction::mayWriteToMemory() const { >> switch (getOpcode()) { >> default: return false; >> - case Instruction::Free: >> case Instruction::Store: >> case Instruction::VAArg: >> return true; >> case Instruction::Call: >> + if (isFreeCall(this)) >> + return true; >> return !cast(this)->onlyReadsMemory(); > > Likewise. I removed some other ones that are not needed. > > -Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091103/b988040c/attachment.html From clattner at apple.com Tue Nov 3 14:51:20 2009 From: clattner at apple.com (Chris Lattner) Date: Tue, 3 Nov 2009 12:51:20 -0800 Subject: [llvm-commits] [llvm] r85933 - /llvm/trunk/lib/Analysis/MemoryBuiltins.cpp In-Reply-To: <200911032002.nA3K2aSe024624@zion.cs.uiuc.edu> References: <200911032002.nA3K2aSe024624@zion.cs.uiuc.edu> Message-ID: thanks Victor! On Nov 3, 2009, at 12:02 PM, Victor Hernandez wrote: > Author: hernande > Date: Tue Nov 3 14:02:35 2009 > New Revision: 85933 > > URL: http://llvm.org/viewvc/llvm-project?rev=85933&view=rev > Log: > Changes (* location in pointer variables, avoiding include, and > using APInt::getLimitedValue) based on feedback to r85814 From sabre at nondot.org Tue Nov 3 14:52:57 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 03 Nov 2009 20:52:57 -0000 Subject: [llvm-commits] [llvm] r85937 - /llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Message-ID: <200911032052.nA3KqvXn026474@zion.cs.uiuc.edu> Author: lattner Date: Tue Nov 3 14:52:57 2009 New Revision: 85937 URL: http://llvm.org/viewvc/llvm-project?rev=85937&view=rev Log: finish half thunk thought Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCP.cpp?rev=85937&r1=85936&r2=85937&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SCCP.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Tue Nov 3 14:52:57 2009 @@ -174,7 +174,9 @@ /// that return multiple values. DenseMap, LatticeVal> TrackedMultipleRetVals; - /// TrackingIncomingArguments - This is the set of functions that are + /// TrackingIncomingArguments - This is the set of functions for whose + /// arguments we make optimistic assumptions about and try to prove as + /// constants. SmallPtrSet TrackingIncomingArguments; /// The reason for two worklists is that overdefined is the lowest state From david_goodwin at apple.com Tue Nov 3 14:57:51 2009 From: david_goodwin at apple.com (David Goodwin) Date: Tue, 03 Nov 2009 20:57:51 -0000 Subject: [llvm-commits] [llvm] r85939 - in /llvm/trunk: include/llvm/CodeGen/LatencyPriorityQueue.h include/llvm/CodeGen/ScheduleDAG.h lib/CodeGen/AggressiveAntiDepBreaker.cpp lib/CodeGen/AggressiveAntiDepBreaker.h lib/CodeGen/AntiDepBreaker.h lib/CodeGen/CriticalAntiDepBreaker.cpp lib/CodeGen/CriticalAntiDepBreaker.h lib/CodeGen/ExactHazardRecognizer.cpp lib/CodeGen/LatencyPriorityQueue.cpp lib/CodeGen/PostRASchedulerList.cpp lib/CodeGen/ScheduleDAG.cpp Message-ID: <200911032057.nA3KvpgC026665@zion.cs.uiuc.edu> Author: david_goodwin Date: Tue Nov 3 14:57:50 2009 New Revision: 85939 URL: http://llvm.org/viewvc/llvm-project?rev=85939&view=rev Log: Do a scheduling pass ignoring anti-dependencies to identify candidate registers that should be renamed. Modified: llvm/trunk/include/llvm/CodeGen/LatencyPriorityQueue.h llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.h llvm/trunk/lib/CodeGen/AntiDepBreaker.h llvm/trunk/lib/CodeGen/CriticalAntiDepBreaker.cpp llvm/trunk/lib/CodeGen/CriticalAntiDepBreaker.h llvm/trunk/lib/CodeGen/ExactHazardRecognizer.cpp llvm/trunk/lib/CodeGen/LatencyPriorityQueue.cpp llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp llvm/trunk/lib/CodeGen/ScheduleDAG.cpp Modified: llvm/trunk/include/llvm/CodeGen/LatencyPriorityQueue.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LatencyPriorityQueue.h?rev=85939&r1=85938&r2=85939&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/LatencyPriorityQueue.h (original) +++ llvm/trunk/include/llvm/CodeGen/LatencyPriorityQueue.h Tue Nov 3 14:57:50 2009 @@ -39,12 +39,21 @@ /// predecessor for. This is used as a tie-breaker heuristic for better /// mobility. std::vector NumNodesSolelyBlocking; - + + /// IgnoreAntiDep - Ignore anti-dependencies + bool IgnoreAntiDep; + + /// Queue - The queue. PriorityQueue, latency_sort> Queue; + public: - LatencyPriorityQueue() : Queue(latency_sort(this)) { + LatencyPriorityQueue() : IgnoreAntiDep(false), Queue(latency_sort(this)) { } - + + void setIgnoreAntiDep(bool ignore) { + IgnoreAntiDep = ignore; + } + void initNodes(std::vector &sunits) { SUnits = &sunits; NumNodesSolelyBlocking.resize(SUnits->size(), 0); @@ -63,7 +72,7 @@ unsigned getLatency(unsigned NodeNum) const { assert(NodeNum < (*SUnits).size()); - return (*SUnits)[NodeNum].getHeight(); + return (*SUnits)[NodeNum].getHeight(IgnoreAntiDep); } unsigned getNumSolelyBlockNodes(unsigned NodeNum) const { Modified: llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h?rev=85939&r1=85938&r2=85939&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h (original) +++ llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h Tue Nov 3 14:57:50 2009 @@ -340,28 +340,34 @@ void removePred(const SDep &D); /// getDepth - Return the depth of this node, which is the length of the - /// maximum path up to any node with has no predecessors. - unsigned getDepth() const { - if (!isDepthCurrent) const_cast(this)->ComputeDepth(); + /// maximum path up to any node with has no predecessors. If IgnoreAntiDep + /// is true, ignore anti-dependence edges. + unsigned getDepth(bool IgnoreAntiDep=false) const { + if (!isDepthCurrent) + const_cast(this)->ComputeDepth(IgnoreAntiDep); return Depth; } /// getHeight - Return the height of this node, which is the length of the - /// maximum path down to any node with has no successors. - unsigned getHeight() const { - if (!isHeightCurrent) const_cast(this)->ComputeHeight(); + /// maximum path down to any node with has no successors. If IgnoreAntiDep + /// is true, ignore anti-dependence edges. + unsigned getHeight(bool IgnoreAntiDep=false) const { + if (!isHeightCurrent) + const_cast(this)->ComputeHeight(IgnoreAntiDep); return Height; } - /// setDepthToAtLeast - If NewDepth is greater than this node's depth - /// value, set it to be the new depth value. This also recursively - /// marks successor nodes dirty. - void setDepthToAtLeast(unsigned NewDepth); - - /// setDepthToAtLeast - If NewDepth is greater than this node's depth - /// value, set it to be the new height value. This also recursively - /// marks predecessor nodes dirty. - void setHeightToAtLeast(unsigned NewHeight); + /// setDepthToAtLeast - If NewDepth is greater than this node's + /// depth value, set it to be the new depth value. This also + /// recursively marks successor nodes dirty. If IgnoreAntiDep is + /// true, ignore anti-dependence edges. + void setDepthToAtLeast(unsigned NewDepth, bool IgnoreAntiDep=false); + + /// setDepthToAtLeast - If NewDepth is greater than this node's + /// depth value, set it to be the new height value. This also + /// recursively marks predecessor nodes dirty. If IgnoreAntiDep is + /// true, ignore anti-dependence edges. + void setHeightToAtLeast(unsigned NewHeight, bool IgnoreAntiDep=false); /// setDepthDirty - Set a flag in this node to indicate that its /// stored Depth value will require recomputation the next time @@ -394,8 +400,8 @@ void print(raw_ostream &O, const ScheduleDAG *G) const; private: - void ComputeDepth(); - void ComputeHeight(); + void ComputeDepth(bool IgnoreAntiDep); + void ComputeHeight(bool IgnoreAntiDep); }; //===--------------------------------------------------------------------===// Modified: llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp?rev=85939&r1=85938&r2=85939&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp (original) +++ llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp Tue Nov 3 14:57:50 2009 @@ -14,7 +14,7 @@ // //===----------------------------------------------------------------------===// -#define DEBUG_TYPE "aggressive-antidep" +#define DEBUG_TYPE "post-RA-sched" #include "AggressiveAntiDepBreaker.h" #include "llvm/CodeGen/MachineBasicBlock.h" #include "llvm/CodeGen/MachineFrameInfo.h" @@ -31,7 +31,7 @@ static cl::opt AntiDepTrials("agg-antidep-trials", cl::desc("Maximum number of anti-dependency breaking passes"), - cl::init(2), cl::Hidden); + cl::init(1), cl::Hidden); AggressiveAntiDepState::AggressiveAntiDepState(MachineBasicBlock *BB) : GroupNodes(TargetRegisterInfo::FirstVirtualRegister, 0) { @@ -265,18 +265,24 @@ } /// AntiDepPathStep - Return SUnit that SU has an anti-dependence on. -static void AntiDepPathStep(SUnit *SU, std::vector& Edges) { - SmallSet Dups; +static void AntiDepPathStep(SUnit *SU, AntiDepBreaker::AntiDepRegVector& Regs, + std::vector& Edges) { + AntiDepBreaker::AntiDepRegSet RegSet; + for (unsigned i = 0, e = Regs.size(); i < e; ++i) + RegSet.insert(Regs[i]); + for (SUnit::pred_iterator P = SU->Preds.begin(), PE = SU->Preds.end(); P != PE; ++P) { if (P->getKind() == SDep::Anti) { unsigned Reg = P->getReg(); - if (Dups.count(Reg) == 0) { + if (RegSet.count(Reg) != 0) { Edges.push_back(&*P); - Dups.insert(Reg); + RegSet.erase(Reg); } } } + + assert(RegSet.empty() && "Expected all antidep registers to be found"); } void AggressiveAntiDepBreaker::HandleLastUse(unsigned Reg, unsigned KillIdx, @@ -593,6 +599,7 @@ /// unsigned AggressiveAntiDepBreaker::BreakAntiDependencies( std::vector& SUnits, + CandidateMap& Candidates, MachineBasicBlock::iterator& Begin, MachineBasicBlock::iterator& End, unsigned InsertPosIndex) { @@ -601,9 +608,15 @@ std::multimap& RegRefs = State->GetRegRefs(); + // Nothing to do if no candidates. + if (Candidates.empty()) { + DEBUG(errs() << "\n===== No anti-dependency candidates\n"); + return 0; + } + // The code below assumes that there is at least one instruction, // so just duck out immediately if the block is empty. - if (SUnits.empty()) return false; + if (SUnits.empty()) return 0; // Manage saved state to enable multiple passes... if (AntiDepTrials > 1) { @@ -618,7 +631,8 @@ // ...need a map from MI to SUnit. std::map MISUnitMap; - DEBUG(errs() << "Breaking all anti-dependencies\n"); + DEBUG(errs() << "\n===== Attempting to break " << Candidates.size() << + " anti-dependencies\n"); for (unsigned i = 0, e = SUnits.size(); i != e; ++i) { SUnit *SU = &SUnits[i]; MISUnitMap.insert(std::pair(SU->getInstr(), SU)); @@ -655,8 +669,10 @@ std::vector Edges; SUnit *PathSU = MISUnitMap[MI]; - if (PathSU) - AntiDepPathStep(PathSU, Edges); + AntiDepBreaker::CandidateMap::iterator + citer = Candidates.find(PathSU); + if (citer != Candidates.end()) + AntiDepPathStep(PathSU, citer->second, Edges); // Ignore KILL instructions (they form a group in ScanInstruction // but don't cause any anti-dependence breaking themselves) Modified: llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.h?rev=85939&r1=85938&r2=85939&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.h (original) +++ llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.h Tue Nov 3 14:57:50 2009 @@ -131,6 +131,9 @@ /// dependencies may be exposed, so multiple passes are required. unsigned GetMaxTrials(); + /// NeedCandidates - Candidates required. + bool NeedCandidates() { return true; } + /// Start - Initialize anti-dep breaking for a new basic block. void StartBlock(MachineBasicBlock *BB); @@ -138,6 +141,7 @@ /// of the ScheduleDAG and break them by renaming registers. /// unsigned BreakAntiDependencies(std::vector& SUnits, + CandidateMap& Candidates, MachineBasicBlock::iterator& Begin, MachineBasicBlock::iterator& End, unsigned InsertPosIndex); Modified: llvm/trunk/lib/CodeGen/AntiDepBreaker.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AntiDepBreaker.h?rev=85939&r1=85938&r2=85939&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AntiDepBreaker.h (original) +++ llvm/trunk/lib/CodeGen/AntiDepBreaker.h Tue Nov 3 14:57:50 2009 @@ -21,6 +21,8 @@ #include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/CodeGen/ScheduleDAG.h" #include "llvm/Target/TargetRegisterInfo.h" +#include "llvm/ADT/SmallSet.h" +#include "llvm/ADT/SmallVector.h" namespace llvm { @@ -29,12 +31,20 @@ /// anti-dependencies. class AntiDepBreaker { public: + typedef SmallSet AntiDepRegSet; + typedef SmallVector AntiDepRegVector; + typedef std::map CandidateMap; + virtual ~AntiDepBreaker(); /// GetMaxTrials - Return the maximum number of anti-dependence /// breaking attempts that will be made for a block. virtual unsigned GetMaxTrials() =0; + /// NeedCandidates - Return true if the schedule must provide + /// candidates with BreakAntiDependencies(). + virtual bool NeedCandidates() =0; + /// Start - Initialize anti-dep breaking for a new basic block. virtual void StartBlock(MachineBasicBlock *BB) =0; @@ -43,9 +53,10 @@ /// the number of anti-dependencies broken. /// virtual unsigned BreakAntiDependencies(std::vector& SUnits, - MachineBasicBlock::iterator& Begin, - MachineBasicBlock::iterator& End, - unsigned InsertPosIndex) =0; + CandidateMap& Candidates, + MachineBasicBlock::iterator& Begin, + MachineBasicBlock::iterator& End, + unsigned InsertPosIndex) =0; /// Observe - Update liveness information to account for the current /// instruction, which will not be scheduled. Modified: llvm/trunk/lib/CodeGen/CriticalAntiDepBreaker.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CriticalAntiDepBreaker.cpp?rev=85939&r1=85938&r2=85939&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/CriticalAntiDepBreaker.cpp (original) +++ llvm/trunk/lib/CodeGen/CriticalAntiDepBreaker.cpp Tue Nov 3 14:57:50 2009 @@ -13,7 +13,7 @@ // //===----------------------------------------------------------------------===// -#define DEBUG_TYPE "critical-antidep" +#define DEBUG_TYPE "post-RA-sched" #include "CriticalAntiDepBreaker.h" #include "llvm/CodeGen/MachineBasicBlock.h" #include "llvm/CodeGen/MachineFrameInfo.h" @@ -316,6 +316,7 @@ unsigned CriticalAntiDepBreaker:: BreakAntiDependencies(std::vector& SUnits, + CandidateMap& Candidates, MachineBasicBlock::iterator& Begin, MachineBasicBlock::iterator& End, unsigned InsertPosIndex) { Modified: llvm/trunk/lib/CodeGen/CriticalAntiDepBreaker.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CriticalAntiDepBreaker.h?rev=85939&r1=85938&r2=85939&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/CriticalAntiDepBreaker.h (original) +++ llvm/trunk/lib/CodeGen/CriticalAntiDepBreaker.h Tue Nov 3 14:57:50 2009 @@ -68,6 +68,9 @@ /// only a single pass unsigned GetMaxTrials() { return 1; } + /// NeedCandidates - Candidates not needed. + bool NeedCandidates() { return false; } + /// Start - Initialize anti-dep breaking for a new basic block. void StartBlock(MachineBasicBlock *BB); @@ -75,6 +78,7 @@ /// of the ScheduleDAG and break them by renaming registers. /// unsigned BreakAntiDependencies(std::vector& SUnits, + CandidateMap& Candidates, MachineBasicBlock::iterator& Begin, MachineBasicBlock::iterator& End, unsigned InsertPosIndex); Modified: llvm/trunk/lib/CodeGen/ExactHazardRecognizer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ExactHazardRecognizer.cpp?rev=85939&r1=85938&r2=85939&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/ExactHazardRecognizer.cpp (original) +++ llvm/trunk/lib/CodeGen/ExactHazardRecognizer.cpp Tue Nov 3 14:57:50 2009 @@ -12,7 +12,7 @@ // //===----------------------------------------------------------------------===// -#define DEBUG_TYPE "exact-hazards" +#define DEBUG_TYPE "post-RA-sched" #include "ExactHazardRecognizer.h" #include "llvm/CodeGen/ScheduleHazardRecognizer.h" #include "llvm/Support/Debug.h" Modified: llvm/trunk/lib/CodeGen/LatencyPriorityQueue.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LatencyPriorityQueue.cpp?rev=85939&r1=85938&r2=85939&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LatencyPriorityQueue.cpp (original) +++ llvm/trunk/lib/CodeGen/LatencyPriorityQueue.cpp Tue Nov 3 14:57:50 2009 @@ -55,6 +55,7 @@ SUnit *OnlyAvailablePred = 0; for (SUnit::const_pred_iterator I = SU->Preds.begin(), E = SU->Preds.end(); I != E; ++I) { + if (IgnoreAntiDep && (I->getKind() == SDep::Anti)) continue; SUnit &Pred = *I->getSUnit(); if (!Pred.isScheduled) { // We found an available, but not scheduled, predecessor. If it's the @@ -73,9 +74,11 @@ // this node is the sole unscheduled node for. unsigned NumNodesBlocking = 0; for (SUnit::const_succ_iterator I = SU->Succs.begin(), E = SU->Succs.end(); - I != E; ++I) + I != E; ++I) { + if (IgnoreAntiDep && (I->getKind() == SDep::Anti)) continue; if (getSingleUnscheduledPred(I->getSUnit()) == SU) ++NumNodesBlocking; + } NumNodesSolelyBlocking[SU->NodeNum] = NumNodesBlocking; Queue.push(SU); @@ -88,8 +91,10 @@ // the node available. void LatencyPriorityQueue::ScheduledNode(SUnit *SU) { for (SUnit::const_succ_iterator I = SU->Succs.begin(), E = SU->Succs.end(); - I != E; ++I) + I != E; ++I) { + if (IgnoreAntiDep && (I->getKind() == SDep::Anti)) continue; AdjustPriorityOfUnscheduledPreds(I->getSUnit()); + } } /// AdjustPriorityOfUnscheduledPreds - One of the predecessors of SU was just Modified: llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp?rev=85939&r1=85938&r2=85939&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp (original) +++ llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp Tue Nov 3 14:57:50 2009 @@ -175,10 +175,11 @@ void FixupKills(MachineBasicBlock *MBB); private: - void ReleaseSucc(SUnit *SU, SDep *SuccEdge); - void ReleaseSuccessors(SUnit *SU); - void ScheduleNodeTopDown(SUnit *SU, unsigned CurCycle); - void ListScheduleTopDown(); + void ReleaseSucc(SUnit *SU, SDep *SuccEdge, bool IgnoreAntiDep); + void ReleaseSuccessors(SUnit *SU, bool IgnoreAntiDep); + void ScheduleNodeTopDown(SUnit *SU, unsigned CurCycle, bool IgnoreAntiDep); + void ListScheduleTopDown( + AntiDepBreaker::CandidateMap *AntiDepCandidates); void StartBlockForKills(MachineBasicBlock *BB); // ToggleKillFlag - Toggle a register operand kill flag. Other @@ -320,15 +321,32 @@ BuildSchedGraph(AA); if (AntiDepBreak != NULL) { + AntiDepBreaker::CandidateMap AntiDepCandidates; + const bool NeedCandidates = AntiDepBreak->NeedCandidates(); + for (unsigned i = 0, Trials = AntiDepBreak->GetMaxTrials(); i < Trials; ++i) { - DEBUG(errs() << "********** Break Anti-Deps, Trial " << + DEBUG(errs() << "\n********** Break Anti-Deps, Trial " << i << " **********\n"); + + // If candidates are required, then schedule forward ignoring + // anti-dependencies to collect the candidate operands for + // anti-dependence breaking. The candidates will be the def + // operands for the anti-dependencies that if broken would allow + // an improved schedule + if (NeedCandidates) { + DEBUG(for (unsigned su = 0, e = SUnits.size(); su != e; ++su) + SUnits[su].dumpAll(this)); + + AntiDepCandidates.clear(); + AvailableQueue.initNodes(SUnits); + ListScheduleTopDown(&AntiDepCandidates); + AvailableQueue.releaseState(); + } + unsigned Broken = - AntiDepBreak->BreakAntiDependencies(SUnits, Begin, InsertPos, - InsertPosIndex); - if (Broken == 0) - break; + AntiDepBreak->BreakAntiDependencies(SUnits, AntiDepCandidates, + Begin, InsertPos, InsertPosIndex); // We made changes. Update the dependency graph. // Theoretically we could update the graph in place: @@ -336,24 +354,26 @@ // the def's anti-dependence *and* output-dependence edges due to // that register, and add new anti-dependence and output-dependence // edges based on the next live range of the register. - SUnits.clear(); - EntrySU = SUnit(); - ExitSU = SUnit(); - BuildSchedGraph(AA); + if ((Broken != 0) || NeedCandidates) { + SUnits.clear(); + Sequence.clear(); + EntrySU = SUnit(); + ExitSU = SUnit(); + BuildSchedGraph(AA); + } NumFixedAnti += Broken; + if (Broken == 0) + break; } } DEBUG(errs() << "********** List Scheduling **********\n"); - DEBUG(for (unsigned su = 0, e = SUnits.size(); su != e; ++su) SUnits[su].dumpAll(this)); AvailableQueue.initNodes(SUnits); - - ListScheduleTopDown(); - + ListScheduleTopDown(NULL); AvailableQueue.releaseState(); } @@ -552,7 +572,8 @@ /// ReleaseSucc - Decrement the NumPredsLeft count of a successor. Add it to /// the PendingQueue if the count reaches zero. Also update its cycle bound. -void SchedulePostRATDList::ReleaseSucc(SUnit *SU, SDep *SuccEdge) { +void SchedulePostRATDList::ReleaseSucc(SUnit *SU, SDep *SuccEdge, + bool IgnoreAntiDep) { SUnit *SuccSU = SuccEdge->getSUnit(); #ifndef NDEBUG @@ -568,7 +589,8 @@ // Compute how many cycles it will be before this actually becomes // available. This is the max of the start time of all predecessors plus // their latencies. - SuccSU->setDepthToAtLeast(SU->getDepth() + SuccEdge->getLatency()); + SuccSU->setDepthToAtLeast(SU->getDepth(IgnoreAntiDep) + + SuccEdge->getLatency(), IgnoreAntiDep); // If all the node's predecessors are scheduled, this node is ready // to be scheduled. Ignore the special ExitSU node. @@ -577,40 +599,73 @@ } /// ReleaseSuccessors - Call ReleaseSucc on each of SU's successors. -void SchedulePostRATDList::ReleaseSuccessors(SUnit *SU) { +void SchedulePostRATDList::ReleaseSuccessors(SUnit *SU, bool IgnoreAntiDep) { for (SUnit::succ_iterator I = SU->Succs.begin(), E = SU->Succs.end(); - I != E; ++I) - ReleaseSucc(SU, &*I); + I != E; ++I) { + if (IgnoreAntiDep && (I->getKind() == SDep::Anti)) continue; + ReleaseSucc(SU, &*I, IgnoreAntiDep); + } } /// ScheduleNodeTopDown - Add the node to the schedule. Decrement the pending /// count of its successors. If a successor pending count is zero, add it to /// the Available queue. -void SchedulePostRATDList::ScheduleNodeTopDown(SUnit *SU, unsigned CurCycle) { +void SchedulePostRATDList::ScheduleNodeTopDown(SUnit *SU, unsigned CurCycle, + bool IgnoreAntiDep) { DEBUG(errs() << "*** Scheduling [" << CurCycle << "]: "); DEBUG(SU->dump(this)); Sequence.push_back(SU); - assert(CurCycle >= SU->getDepth() && "Node scheduled above its depth!"); - SU->setDepthToAtLeast(CurCycle); + assert(CurCycle >= SU->getDepth(IgnoreAntiDep) && + "Node scheduled above its depth!"); + SU->setDepthToAtLeast(CurCycle, IgnoreAntiDep); - ReleaseSuccessors(SU); + ReleaseSuccessors(SU, IgnoreAntiDep); SU->isScheduled = true; AvailableQueue.ScheduledNode(SU); } /// ListScheduleTopDown - The main loop of list scheduling for top-down /// schedulers. -void SchedulePostRATDList::ListScheduleTopDown() { +void SchedulePostRATDList::ListScheduleTopDown( + AntiDepBreaker::CandidateMap *AntiDepCandidates) { unsigned CurCycle = 0; + const bool IgnoreAntiDep = (AntiDepCandidates != NULL); + + // We're scheduling top-down but we're visiting the regions in + // bottom-up order, so we don't know the hazards at the start of a + // region. So assume no hazards (this should usually be ok as most + // blocks are a single region). + HazardRec->Reset(); + + // If ignoring anti-dependencies, the Schedule DAG still has Anti + // dep edges, but we ignore them for scheduling purposes + AvailableQueue.setIgnoreAntiDep(IgnoreAntiDep); // Release any successors of the special Entry node. - ReleaseSuccessors(&EntrySU); + ReleaseSuccessors(&EntrySU, IgnoreAntiDep); - // All leaves to Available queue. + // Add all leaves to Available queue. If ignoring antideps we also + // adjust the predecessor count for each node to not include antidep + // edges. for (unsigned i = 0, e = SUnits.size(); i != e; ++i) { // It is available if it has no predecessors. - if (SUnits[i].Preds.empty()) { + bool available = SUnits[i].Preds.empty(); + // If we are ignoring anti-dependencies then a node that has only + // anti-dep predecessors is available. + if (!available && IgnoreAntiDep) { + available = true; + for (SUnit::const_pred_iterator I = SUnits[i].Preds.begin(), + E = SUnits[i].Preds.end(); I != E; ++I) { + if (I->getKind() != SDep::Anti) { + available = false; + } else { + SUnits[i].NumPredsLeft -= 1; + } + } + } + + if (available) { AvailableQueue.push(&SUnits[i]); SUnits[i].isAvailable = true; } @@ -629,26 +684,25 @@ // so, add them to the available queue. unsigned MinDepth = ~0u; for (unsigned i = 0, e = PendingQueue.size(); i != e; ++i) { - if (PendingQueue[i]->getDepth() <= CurCycle) { + if (PendingQueue[i]->getDepth(IgnoreAntiDep) <= CurCycle) { AvailableQueue.push(PendingQueue[i]); PendingQueue[i]->isAvailable = true; PendingQueue[i] = PendingQueue.back(); PendingQueue.pop_back(); --i; --e; - } else if (PendingQueue[i]->getDepth() < MinDepth) - MinDepth = PendingQueue[i]->getDepth(); + } else if (PendingQueue[i]->getDepth(IgnoreAntiDep) < MinDepth) + MinDepth = PendingQueue[i]->getDepth(IgnoreAntiDep); } DEBUG(errs() << "\n*** Examining Available\n"; LatencyPriorityQueue q = AvailableQueue; while (!q.empty()) { SUnit *su = q.pop(); - errs() << "Height " << su->getHeight() << ": "; + errs() << "Height " << su->getHeight(IgnoreAntiDep) << ": "; su->dump(this); }); SUnit *FoundSUnit = 0; - bool HasNoopHazards = false; while (!AvailableQueue.empty()) { SUnit *CurSUnit = AvailableQueue.pop(); @@ -672,9 +726,30 @@ NotReady.clear(); } - // If we found a node to schedule, do it now. + // If we found a node to schedule... if (FoundSUnit) { - ScheduleNodeTopDown(FoundSUnit, CurCycle); + // If we are ignoring anti-dependencies and the SUnit we are + // scheduling has an antidep predecessor that has not been + // scheduled, then we will need to break that antidep if we want + // to get this schedule when not ignoring anti-dependencies. + if (IgnoreAntiDep) { + AntiDepBreaker::AntiDepRegVector AntiDepRegs; + for (SUnit::const_pred_iterator I = FoundSUnit->Preds.begin(), + E = FoundSUnit->Preds.end(); I != E; ++I) { + if ((I->getKind() == SDep::Anti) && !I->getSUnit()->isScheduled) + AntiDepRegs.push_back(I->getReg()); + } + + if (AntiDepRegs.size() > 0) { + DEBUG(errs() << "*** AntiDep Candidate: "); + DEBUG(FoundSUnit->dump(this)); + AntiDepCandidates->insert( + AntiDepBreaker::CandidateMap::value_type(FoundSUnit, AntiDepRegs)); + } + } + + // ... schedule the node... + ScheduleNodeTopDown(FoundSUnit, CurCycle, IgnoreAntiDep); HazardRec->EmitInstruction(FoundSUnit); CycleHasInsts = true; Modified: llvm/trunk/lib/CodeGen/ScheduleDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ScheduleDAG.cpp?rev=85939&r1=85938&r2=85939&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/ScheduleDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/ScheduleDAG.cpp Tue Nov 3 14:57:50 2009 @@ -183,8 +183,8 @@ /// setDepthToAtLeast - Update this node's successors to reflect the /// fact that this node's depth just increased. /// -void SUnit::setDepthToAtLeast(unsigned NewDepth) { - if (NewDepth <= getDepth()) +void SUnit::setDepthToAtLeast(unsigned NewDepth, bool IgnoreAntiDep) { + if (NewDepth <= getDepth(IgnoreAntiDep)) return; setDepthDirty(); Depth = NewDepth; @@ -194,8 +194,8 @@ /// setHeightToAtLeast - Update this node's predecessors to reflect the /// fact that this node's height just increased. /// -void SUnit::setHeightToAtLeast(unsigned NewHeight) { - if (NewHeight <= getHeight()) +void SUnit::setHeightToAtLeast(unsigned NewHeight, bool IgnoreAntiDep) { + if (NewHeight <= getHeight(IgnoreAntiDep)) return; setHeightDirty(); Height = NewHeight; @@ -204,7 +204,7 @@ /// ComputeDepth - Calculate the maximal path from the node to the exit. /// -void SUnit::ComputeDepth() { +void SUnit::ComputeDepth(bool IgnoreAntiDep) { SmallVector WorkList; WorkList.push_back(this); do { @@ -214,6 +214,7 @@ unsigned MaxPredDepth = 0; for (SUnit::const_pred_iterator I = Cur->Preds.begin(), E = Cur->Preds.end(); I != E; ++I) { + if (IgnoreAntiDep && (I->getKind() == SDep::Anti)) continue; SUnit *PredSU = I->getSUnit(); if (PredSU->isDepthCurrent) MaxPredDepth = std::max(MaxPredDepth, @@ -237,7 +238,7 @@ /// ComputeHeight - Calculate the maximal path from the node to the entry. /// -void SUnit::ComputeHeight() { +void SUnit::ComputeHeight(bool IgnoreAntiDep) { SmallVector WorkList; WorkList.push_back(this); do { @@ -247,6 +248,7 @@ unsigned MaxSuccHeight = 0; for (SUnit::const_succ_iterator I = Cur->Succs.begin(), E = Cur->Succs.end(); I != E; ++I) { + if (IgnoreAntiDep && (I->getKind() == SDep::Anti)) continue; SUnit *SuccSU = I->getSUnit(); if (SuccSU->isHeightCurrent) MaxSuccHeight = std::max(MaxSuccHeight, @@ -346,7 +348,7 @@ AnyNotSched = true; } if (SUnits[i].isScheduled && - (isBottomUp ? SUnits[i].getHeight() : SUnits[i].getHeight()) > + (isBottomUp ? SUnits[i].getHeight() : SUnits[i].getDepth()) > unsigned(INT_MAX)) { if (!AnyNotSched) errs() << "*** Scheduling failed! ***\n"; From sabre at nondot.org Tue Nov 3 15:25:50 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 03 Nov 2009 21:25:50 -0000 Subject: [llvm-commits] [llvm] r85945 - in /llvm/trunk/test/Transforms/SCCP: empty-struct.ll ipsccp-basic.ll Message-ID: <200911032125.nA3LPoRe027940@zion.cs.uiuc.edu> Author: lattner Date: Tue Nov 3 15:25:50 2009 New Revision: 85945 URL: http://llvm.org/viewvc/llvm-project?rev=85945&view=rev Log: merge a test into ipsccp-basic. running llvm-ld to get one pass is... bad. Removed: llvm/trunk/test/Transforms/SCCP/empty-struct.ll Modified: llvm/trunk/test/Transforms/SCCP/ipsccp-basic.ll Removed: llvm/trunk/test/Transforms/SCCP/empty-struct.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SCCP/empty-struct.ll?rev=85944&view=auto ============================================================================== --- llvm/trunk/test/Transforms/SCCP/empty-struct.ll (original) +++ llvm/trunk/test/Transforms/SCCP/empty-struct.ll (removed) @@ -1,20 +0,0 @@ -; RUN: llvm-as < %s > %t.bc -; RUN: llvm-ld %t.bc -o %t.sh -; PR2612 - - at current_foo = internal global { } zeroinitializer - -define i32 @main(...) { -entry: - %retval = alloca i32 ; [#uses=2] - store i32 0, i32* %retval - %local_foo = alloca { } ; <{ }*> [#uses=1] - load { }* @current_foo ; <{ }>:0 [#uses=1] - store { } %0, { }* %local_foo - br label %return - -return: ; preds = %entry - load i32* %retval ; :1 [#uses=1] - ret i32 %1 -} - Modified: llvm/trunk/test/Transforms/SCCP/ipsccp-basic.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SCCP/ipsccp-basic.ll?rev=85945&r1=85944&r2=85945&view=diff ============================================================================== --- llvm/trunk/test/Transforms/SCCP/ipsccp-basic.ll (original) +++ llvm/trunk/test/Transforms/SCCP/ipsccp-basic.ll Tue Nov 3 15:25:50 2009 @@ -189,9 +189,19 @@ %X = call {} @test8a(i32 5, i32* %P) ret void ; CHECK: define void @test8b -; CHECK-NEXT: call {} @test8a +; CHECK-NEXT: call { } @test8a ; CHECK-NEXT: ret void } +;;======================== test9 + at test9g = internal global { } zeroinitializer + +define void @test9() { +entry: + %local_foo = alloca { } + load { }* @current_foo + store { } %0, { }* %local_foo + ret void +} From sabre at nondot.org Tue Nov 3 15:26:26 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 03 Nov 2009 21:26:26 -0000 Subject: [llvm-commits] [llvm] r85946 - /llvm/trunk/test/Transforms/SCCP/ipsccp-basic.ll Message-ID: <200911032126.nA3LQRtk027980@zion.cs.uiuc.edu> Author: lattner Date: Tue Nov 3 15:26:26 2009 New Revision: 85946 URL: http://llvm.org/viewvc/llvm-project?rev=85946&view=rev Log: fix test Modified: llvm/trunk/test/Transforms/SCCP/ipsccp-basic.ll Modified: llvm/trunk/test/Transforms/SCCP/ipsccp-basic.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SCCP/ipsccp-basic.ll?rev=85946&r1=85945&r2=85946&view=diff ============================================================================== --- llvm/trunk/test/Transforms/SCCP/ipsccp-basic.ll (original) +++ llvm/trunk/test/Transforms/SCCP/ipsccp-basic.ll Tue Nov 3 15:26:26 2009 @@ -200,7 +200,7 @@ define void @test9() { entry: %local_foo = alloca { } - load { }* @current_foo + load { }* @test9g store { } %0, { }* %local_foo ret void } From evan.cheng at apple.com Tue Nov 3 15:40:02 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 03 Nov 2009 21:40:02 -0000 Subject: [llvm-commits] [llvm] r85947 - in /llvm/trunk: lib/CodeGen/MachineLICM.cpp test/CodeGen/ARM/remat.ll test/CodeGen/X86/2007-11-30-LoadFolding-Bug.ll Message-ID: <200911032140.nA3Le2fj028599@zion.cs.uiuc.edu> Author: evancheng Date: Tue Nov 3 15:40:02 2009 New Revision: 85947 URL: http://llvm.org/viewvc/llvm-project?rev=85947&view=rev Log: Re-apply 85799. It turns out my code isn't buggy. Modified: llvm/trunk/lib/CodeGen/MachineLICM.cpp llvm/trunk/test/CodeGen/ARM/remat.ll llvm/trunk/test/CodeGen/X86/2007-11-30-LoadFolding-Bug.ll Modified: llvm/trunk/lib/CodeGen/MachineLICM.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineLICM.cpp?rev=85947&r1=85946&r2=85947&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineLICM.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineLICM.cpp Tue Nov 3 15:40:02 2009 @@ -56,12 +56,12 @@ // State that is updated as we process loops bool Changed; // True if a loop is changed. + bool FirstInLoop; // True if it's the first LICM in the loop. MachineLoop *CurLoop; // The current loop we are working on. MachineBasicBlock *CurPreheader; // The preheader for CurLoop. - // For each BB and opcode pair, keep a list of hoisted instructions. - DenseMap, - std::vector > CSEMap; + // For each opcode, keep a list of potentail CSE instructions. + DenseMap > CSEMap; public: static char ID; // Pass identification, replacement for typeid MachineLICM() : MachineFunctionPass(&ID) {} @@ -115,6 +115,11 @@ /// that is safe to hoist, this instruction is called to do the dirty work. /// void Hoist(MachineInstr *MI); + + /// InitCSEMap - Initialize the CSE map with instructions that are in the + /// current loop preheader that may become duplicates of instructions that + /// are hoisted out of the loop. + void InitCSEMap(MachineBasicBlock *BB); }; } // end anonymous namespace @@ -140,7 +145,7 @@ bool MachineLICM::runOnMachineFunction(MachineFunction &MF) { DEBUG(errs() << "******** Machine LICM ********\n"); - Changed = false; + Changed = FirstInLoop = false; TM = &MF.getTarget(); TII = TM->getInstrInfo(); TRI = TM->getRegisterInfo(); @@ -152,8 +157,7 @@ DT = &getAnalysis(); AA = &getAnalysis(); - for (MachineLoopInfo::iterator - I = LI->begin(), E = LI->end(); I != E; ++I) { + for (MachineLoopInfo::iterator I = LI->begin(), E = LI->end(); I != E; ++I) { CurLoop = *I; // Only visit outer-most preheader-sporting loops. @@ -170,7 +174,11 @@ if (!CurPreheader) continue; + // CSEMap is initialized for loop header when the first instruction is + // being hoisted. + FirstInLoop = true; HoistRegion(DT->getNode(CurLoop->getHeader())); + CSEMap.clear(); } return Changed; @@ -191,10 +199,7 @@ for (MachineBasicBlock::iterator MII = BB->begin(), E = BB->end(); MII != E; ) { MachineBasicBlock::iterator NextMII = MII; ++NextMII; - MachineInstr &MI = *MII; - - Hoist(&MI); - + Hoist(&*MII); MII = NextMII; } @@ -430,6 +435,27 @@ return NewMIs[0]; } +void MachineLICM::InitCSEMap(MachineBasicBlock *BB) { + for (MachineBasicBlock::iterator I = BB->begin(),E = BB->end(); I != E; ++I) { + const MachineInstr *MI = &*I; + // FIXME: For now, only hoist re-materilizable instructions. LICM will + // increase register pressure. We want to make sure it doesn't increase + // spilling. + if (TII->isTriviallyReMaterializable(MI, AA)) { + unsigned Opcode = MI->getOpcode(); + DenseMap >::iterator + CI = CSEMap.find(Opcode); + if (CI != CSEMap.end()) + CI->second.push_back(MI); + else { + std::vector CSEMIs; + CSEMIs.push_back(MI); + CSEMap.insert(std::make_pair(Opcode, CSEMIs)); + } + } + } +} + /// Hoist - When an instruction is found to use only loop invariant operands /// that are safe to hoist, this instruction is called to do the dirty work. /// @@ -454,11 +480,14 @@ errs() << "\n"; }); + // If this is the first instruction being hoisted to the preheader, + // initialize the CSE map with potential common expressions. + InitCSEMap(CurPreheader); + // Look for opportunity to CSE the hoisted instruction. - std::pair BBOpcPair = - std::make_pair(CurPreheader->getNumber(), MI->getOpcode()); - DenseMap, - std::vector >::iterator CI = CSEMap.find(BBOpcPair); + unsigned Opcode = MI->getOpcode(); + DenseMap >::iterator + CI = CSEMap.find(Opcode); bool DoneCSE = false; if (CI != CSEMap.end()) { const MachineInstr *Dup = LookForDuplicate(MI, CI->second, RegInfo); @@ -477,15 +506,15 @@ // Otherwise, splice the instruction to the preheader. if (!DoneCSE) { - CurPreheader->splice(CurPreheader->getFirstTerminator(), - MI->getParent(), MI); + CurPreheader->splice(CurPreheader->getFirstTerminator(),MI->getParent(),MI); + // Add to the CSE map. if (CI != CSEMap.end()) CI->second.push_back(MI); else { std::vector CSEMIs; CSEMIs.push_back(MI); - CSEMap.insert(std::make_pair(BBOpcPair, CSEMIs)); + CSEMap.insert(std::make_pair(Opcode, CSEMIs)); } } Modified: llvm/trunk/test/CodeGen/ARM/remat.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/remat.ll?rev=85947&r1=85946&r2=85947&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/remat.ll (original) +++ llvm/trunk/test/CodeGen/ARM/remat.ll Tue Nov 3 15:40:02 2009 @@ -1,5 +1,5 @@ ; RUN: llc < %s -mtriple=arm-apple-darwin -; RUN: llc < %s -mtriple=arm-apple-darwin -stats -info-output-file - | grep "Number of re-materialization" | grep 4 +; RUN: llc < %s -mtriple=arm-apple-darwin -stats -info-output-file - | grep "Number of re-materialization" | grep 5 %struct.CONTENTBOX = type { i32, i32, i32, i32, i32 } %struct.LOCBOX = type { i32, i32, i32, i32 } Modified: llvm/trunk/test/CodeGen/X86/2007-11-30-LoadFolding-Bug.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2007-11-30-LoadFolding-Bug.ll?rev=85947&r1=85946&r2=85947&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2007-11-30-LoadFolding-Bug.ll (original) +++ llvm/trunk/test/CodeGen/X86/2007-11-30-LoadFolding-Bug.ll Tue Nov 3 15:40:02 2009 @@ -1,6 +1,5 @@ -; RUN: llc < %s -march=x86 -mattr=+sse2 -stats |& \ -; RUN: grep {1 .*folded into instructions} -; Increment in loop bb.128.i adjusted to 2, to prevent loop reversal from +; RUN: llc < %s -march=x86 -mattr=+sse2 | FileCheck %s +; Increment in loop bb.i28.i adjusted to 2, to prevent loop reversal from ; kicking in. declare fastcc void @rdft(i32, i32, double*, i32*, double*) @@ -34,6 +33,9 @@ br label %bb.i28.i bb.i28.i: ; preds = %bb.i28.i, %cond_next36.i +; CHECK: %bb.i28.i +; CHECK: addl $2 +; CHECK: addl $2 %j.0.reg2mem.0.i16.i = phi i32 [ 0, %cond_next36.i ], [ %indvar.next39.i, %bb.i28.i ] ; [#uses=2] %din_addr.1.reg2mem.0.i17.i = phi double [ 0.000000e+00, %cond_next36.i ], [ %tmp16.i25.i, %bb.i28.i ] ; [#uses=1] %tmp1.i18.i = fptosi double %din_addr.1.reg2mem.0.i17.i to i32 ; [#uses=2] From evan.cheng at apple.com Tue Nov 3 15:50:02 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 03 Nov 2009 21:50:02 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r85950 - /llvm-gcc-4.2/trunk/build_gcc Message-ID: <200911032150.nA3Lo2Qr029092@zion.cs.uiuc.edu> Author: evancheng Date: Tue Nov 3 15:50:02 2009 New Revision: 85950 URL: http://llvm.org/viewvc/llvm-project?rev=85950&view=rev Log: Allow user to override DARWIN_VERS from command line. 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=85950&r1=85949&r2=85950&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/build_gcc (original) +++ llvm-gcc-4.2/trunk/build_gcc Tue Nov 3 15:50:02 2009 @@ -116,7 +116,9 @@ NON_ARM_CONFIGFLAGS="--with-gxx-include-dir=/usr/include/c++/$LIBSTDCXX_VERSION" # LLVM LOCAL end -DARWIN_VERS=`uname -r | sed 's/\..*//'` +if [ "x$DARWIN_VERS" == "x" ]; then + DARWIN_VERS=`uname -r | sed 's/\..*//'` +fi echo DARWIN_VERS = $DARWIN_VERS # APPLE LOCAL begin ARM From sabre at nondot.org Tue Nov 3 15:50:10 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 03 Nov 2009 21:50:10 -0000 Subject: [llvm-commits] [llvm] r85951 - /llvm/trunk/docs/ReleaseNotes.html Message-ID: <200911032150.nA3LoAro029118@zion.cs.uiuc.edu> Author: lattner Date: Tue Nov 3 15:50:09 2009 New Revision: 85951 URL: http://llvm.org/viewvc/llvm-project?rev=85951&view=rev Log: fix broken link Modified: llvm/trunk/docs/ReleaseNotes.html Modified: llvm/trunk/docs/ReleaseNotes.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/ReleaseNotes.html?rev=85951&r1=85950&r2=85951&view=diff ============================================================================== --- llvm/trunk/docs/ReleaseNotes.html (original) +++ llvm/trunk/docs/ReleaseNotes.html Tue Nov 3 15:50:09 2009 @@ -1058,7 +1058,7 @@
                        • LLVM will not correctly compile on Solaris and/or OpenSolaris using the stock GCC 3.x.x series 'out the box', -See: Broken versions of GCC and other tools. +See: Broken versions of GCC and other tools. However, A Modern GCC Build for x86/x86-64 has been made available from the third party AuroraUX Project that has been meticulously tested for bootstrapping LLVM & Clang.
                        • From evan.cheng at apple.com Tue Nov 3 15:59:33 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 03 Nov 2009 21:59:33 -0000 Subject: [llvm-commits] [llvm] r85952 - in /llvm/trunk: lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp test/CodeGen/ARM/fpconsts.ll Message-ID: <200911032159.nA3LxX2l029501@zion.cs.uiuc.edu> Author: evancheng Date: Tue Nov 3 15:59:33 2009 New Revision: 85952 URL: http://llvm.org/viewvc/llvm-project?rev=85952&view=rev Log: fconsts / fconstd immediate should be proceeded with #. Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp llvm/trunk/test/CodeGen/ARM/fpconsts.ll 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=85952&r1=85951&r2=85952&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Tue Nov 3 15:59:33 2009 @@ -980,7 +980,7 @@ void ARMAsmPrinter::printVFPf32ImmOperand(const MachineInstr *MI, int OpNum) { const ConstantFP *FP = MI->getOperand(OpNum).getFPImm(); - O << ARM::getVFPf32Imm(FP->getValueAPF()); + O << '#' << ARM::getVFPf32Imm(FP->getValueAPF()); if (VerboseAsm) { O.PadToColumn(MAI->getCommentColumn()); O << MAI->getCommentString() << ' '; @@ -990,7 +990,7 @@ void ARMAsmPrinter::printVFPf64ImmOperand(const MachineInstr *MI, int OpNum) { const ConstantFP *FP = MI->getOperand(OpNum).getFPImm(); - O << ARM::getVFPf64Imm(FP->getValueAPF()); + O << '#' << ARM::getVFPf64Imm(FP->getValueAPF()); if (VerboseAsm) { O.PadToColumn(MAI->getCommentColumn()); O << MAI->getCommentString() << ' '; Modified: llvm/trunk/test/CodeGen/ARM/fpconsts.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/fpconsts.ll?rev=85952&r1=85951&r2=85952&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/fpconsts.ll (original) +++ llvm/trunk/test/CodeGen/ARM/fpconsts.ll Tue Nov 3 15:59:33 2009 @@ -3,7 +3,7 @@ define arm_apcscc float @t1(float %x) nounwind readnone optsize { entry: ; CHECK: t1: -; CHECK: fconsts s1, 16 +; CHECK: fconsts s1, #16 %0 = fadd float %x, 4.000000e+00 ret float %0 } @@ -11,7 +11,7 @@ define arm_apcscc double @t2(double %x) nounwind readnone optsize { entry: ; CHECK: t2: -; CHECK: fconstd d1, 8 +; CHECK: fconstd d1, #8 %0 = fadd double %x, 3.000000e+00 ret double %0 } @@ -19,7 +19,7 @@ define arm_apcscc double @t3(double %x) nounwind readnone optsize { entry: ; CHECK: t3: -; CHECK: fconstd d1, 170 +; CHECK: fconstd d1, #170 %0 = fmul double %x, -1.300000e+01 ret double %0 } @@ -27,7 +27,7 @@ define arm_apcscc float @t4(float %x) nounwind readnone optsize { entry: ; CHECK: t4: -; CHECK: fconsts s1, 184 +; CHECK: fconsts s1, #184 %0 = fmul float %x, -2.400000e+01 ret float %0 } From nunoplopes at sapo.pt Tue Nov 3 16:07:08 2009 From: nunoplopes at sapo.pt (Nuno Lopes) Date: Tue, 03 Nov 2009 22:07:08 -0000 Subject: [llvm-commits] [llvm] r85953 - in /llvm/trunk/examples/Kaleidoscope: Chapter2/ Chapter3/ Chapter4/ Chapter5/ Chapter6/ Chapter7/ Message-ID: <200911032207.nA3M78Lg029822@zion.cs.uiuc.edu> Author: nlopes Date: Tue Nov 3 16:07:07 2009 New Revision: 85953 URL: http://llvm.org/viewvc/llvm-project?rev=85953&view=rev Log: set svn:ignore Modified: llvm/trunk/examples/Kaleidoscope/Chapter2/ (props changed) llvm/trunk/examples/Kaleidoscope/Chapter3/ (props changed) llvm/trunk/examples/Kaleidoscope/Chapter4/ (props changed) llvm/trunk/examples/Kaleidoscope/Chapter5/ (props changed) llvm/trunk/examples/Kaleidoscope/Chapter6/ (props changed) llvm/trunk/examples/Kaleidoscope/Chapter7/ (props changed) Propchange: llvm/trunk/examples/Kaleidoscope/Chapter2/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Tue Nov 3 16:07:07 2009 @@ -0,0 +1,8 @@ +Debug +Release +Release-Asserts +Debug+Coverage-Asserts +Debug+Coverage +Release+Coverage +Debug+Checks + Propchange: llvm/trunk/examples/Kaleidoscope/Chapter3/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Tue Nov 3 16:07:07 2009 @@ -0,0 +1,8 @@ +Debug +Release +Release-Asserts +Debug+Coverage-Asserts +Debug+Coverage +Release+Coverage +Debug+Checks + Propchange: llvm/trunk/examples/Kaleidoscope/Chapter4/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Tue Nov 3 16:07:07 2009 @@ -0,0 +1,8 @@ +Debug +Release +Release-Asserts +Debug+Coverage-Asserts +Debug+Coverage +Release+Coverage +Debug+Checks + Propchange: llvm/trunk/examples/Kaleidoscope/Chapter5/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Tue Nov 3 16:07:07 2009 @@ -0,0 +1,8 @@ +Debug +Release +Release-Asserts +Debug+Coverage-Asserts +Debug+Coverage +Release+Coverage +Debug+Checks + Propchange: llvm/trunk/examples/Kaleidoscope/Chapter6/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Tue Nov 3 16:07:07 2009 @@ -0,0 +1,8 @@ +Debug +Release +Release-Asserts +Debug+Coverage-Asserts +Debug+Coverage +Release+Coverage +Debug+Checks + Propchange: llvm/trunk/examples/Kaleidoscope/Chapter7/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Tue Nov 3 16:07:07 2009 @@ -0,0 +1,8 @@ +Debug +Release +Release-Asserts +Debug+Coverage-Asserts +Debug+Coverage +Release+Coverage +Debug+Checks + From grosbach at apple.com Tue Nov 3 16:07:35 2009 From: grosbach at apple.com (Jim Grosbach) Date: Tue, 3 Nov 2009 14:07:35 -0800 Subject: [llvm-commits] [llvm] r85697 - in /llvm/trunk: lib/Target/ARM/ARMInstrNEON.td test/CodeGen/ARM/fmacs.ll test/CodeGen/ARM/fnmacs.ll test/CodeGen/Thumb2/cross-rc-coalescing-2.ll In-Reply-To: <72AADD0D-6CAF-433E-8533-A8157E28F8D9@gmail.com> References: <200910312257.n9VMvbZm030355@zion.cs.uiuc.edu> <72AADD0D-6CAF-433E-8533-A8157E28F8D9@gmail.com> Message-ID: <7098F362-DE42-4D5D-B84A-78C3ED93F2AA@apple.com> On Nov 2, 2009, at 1:53 AM, David Conrad wrote: > Thus even without modeling the special behaviour of vmla it's always > better to use it: it'll always be at least as fast as a separate vmul > +vadd. This applies to the integer versions as well. Hi David, Unfortunately, this turns out not to be the case. The NEON unit will stall adjacent instructions in the presence of vmla to preserve in- order retirement. If a RAW hazard is present, the stall is 8 (possibly 7) cycles, otherwise it is 4 cycles. It may be possible to model this with the recent post-allocation scheduler improvements, but for now it's better to just avoid the instructions when doing scalar math. Since we're using NEON vector instructions for scalar floating point math on the A8, having vmla intermingled with other NEON instructions is not uncommon in generated code. -Jim From bob.wilson at apple.com Tue Nov 3 16:11:13 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 3 Nov 2009 14:11:13 -0800 Subject: [llvm-commits] [llvm-gcc-4.2] r85950 - /llvm-gcc-4.2/trunk/build_gcc In-Reply-To: <200911032150.nA3Lo2Qr029092@zion.cs.uiuc.edu> References: <200911032150.nA3Lo2Qr029092@zion.cs.uiuc.edu> Message-ID: <53257430-5A04-4A96-88E0-5EB323584158@apple.com> This should not be necessary. Just set UNAME_RELEASE to the version number you want. On Nov 3, 2009, at 1:50 PM, Evan Cheng wrote: > Author: evancheng > Date: Tue Nov 3 15:50:02 2009 > New Revision: 85950 > > URL: http://llvm.org/viewvc/llvm-project?rev=85950&view=rev > Log: > Allow user to override DARWIN_VERS from command line. > > 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=85950&r1=85949&r2=85950&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm-gcc-4.2/trunk/build_gcc (original) > +++ llvm-gcc-4.2/trunk/build_gcc Tue Nov 3 15:50:02 2009 > @@ -116,7 +116,9 @@ > NON_ARM_CONFIGFLAGS="--with-gxx-include-dir=/usr/include/c++/ > $LIBSTDCXX_VERSION" > # LLVM LOCAL end > > -DARWIN_VERS=`uname -r | sed 's/\..*//'` > +if [ "x$DARWIN_VERS" == "x" ]; then > + DARWIN_VERS=`uname -r | sed 's/\..*//'` > +fi > echo DARWIN_VERS = $DARWIN_VERS > > # APPLE LOCAL begin ARM > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From criswell at cs.uiuc.edu Tue Nov 3 16:16:33 2009 From: criswell at cs.uiuc.edu (John Criswell) Date: Tue, 3 Nov 2009 16:16:33 -0600 Subject: [llvm-commits] CVS: llvm-www/safecode/index.html Message-ID: <200911032216.nA3MGXMA023516@maute.cs.uiuc.edu> Changes in directory llvm-www/safecode: index.html updated: 1.27 -> 1.28 --- Log message: Replaced old text with newer text provided by Vikram. --- Diffs of the changes: (+2 -1) index.html | 3 ++- 1 files changed, 2 insertions(+), 1 deletion(-) Index: llvm-www/safecode/index.html diff -u llvm-www/safecode/index.html:1.27 llvm-www/safecode/index.html:1.28 --- llvm-www/safecode/index.html:1.27 Tue Nov 3 09:38:56 2009 +++ llvm-www/safecode/index.html Tue Nov 3 16:15:36 2009 @@ -49,7 +49,8 @@

                          The purpose of the SAFECode project is to enable program safety without - runtime checks and garbage collection, using static analysis when + garbage collection and with minimal run-time checks using static + analysis when possible and run-time checks when necessary. SAFECode defines a code representation with minimal semantic restrictions designed to enable static enforcement of safety, using aggressive compiler techniques From isanbard at gmail.com Tue Nov 3 16:50:10 2009 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 03 Nov 2009 22:50:10 -0000 Subject: [llvm-commits] [llvm] r85963 - /llvm/trunk/utils/buildit/build_llvm Message-ID: <200911032250.nA3MoA2p031728@zion.cs.uiuc.edu> Author: void Date: Tue Nov 3 16:50:10 2009 New Revision: 85963 URL: http://llvm.org/viewvc/llvm-project?rev=85963&view=rev Log: Use llvm-gcc on newer Darwins. 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=85963&r1=85962&r2=85963&view=diff ============================================================================== --- llvm/trunk/utils/buildit/build_llvm (original) +++ llvm/trunk/utils/buildit/build_llvm Tue Nov 3 16:50:10 2009 @@ -123,7 +123,7 @@ PATH=$DIR/bin:$PATH # otherwise, try to use llvm-gcc if it's available -else +elif [ $DARWIN_VERS -gt 9 ]; then # If the user has set CC or CXX, respect their wishes. If not, # compile with LLVM-GCC/LLVM-G++ if available; if LLVM is not # available, fall back to usual GCC/G++ default. From evan.cheng at apple.com Tue Nov 3 17:13:34 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 03 Nov 2009 23:13:34 -0000 Subject: [llvm-commits] [llvm] r85965 - in /llvm/trunk/lib/Target/ARM: ARMBaseInstrInfo.cpp ARMInstrThumb2.td Message-ID: <200911032313.nA3NDZtw032645@zion.cs.uiuc.edu> Author: evancheng Date: Tue Nov 3 17:13:34 2009 New Revision: 85965 URL: http://llvm.org/viewvc/llvm-project?rev=85965&view=rev Log: Fix t2Int_eh_sjlj_setjmp. Immediate form of orr is a 32-bit instruction. So it should be 22 bytes instead of 20 bytes long. Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp?rev=85965&r1=85964&r2=85965&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp Tue Nov 3 17:13:34 2009 @@ -448,7 +448,7 @@ case ARM::Int_eh_sjlj_setjmp: return 24; case ARM::t2Int_eh_sjlj_setjmp: - return 20; + return 22; case ARM::BR_JTr: case ARM::BR_JTm: case ARM::BR_JTadd: Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td?rev=85965&r1=85964&r2=85965&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Tue Nov 3 17:13:34 2009 @@ -1082,7 +1082,7 @@ AddrModeNone, SizeSpecial, NoItinerary, "str.w\tsp, [$src, #+8] @ eh_setjmp begin\n" "\tadr\tr12, 0f\n" - "\torr\tr12, #1\n" + "\torr.w\tr12, r12, #1\n" "\tstr.w\tr12, [$src, #+4]\n" "\tmovs\tr0, #0\n" "\tb\t1f\n" From sabre at nondot.org Tue Nov 3 17:40:48 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 03 Nov 2009 23:40:48 -0000 Subject: [llvm-commits] [llvm] r85973 - in /llvm/trunk: lib/Transforms/Scalar/SCCP.cpp test/Transforms/SCCP/ipsccp-basic.ll Message-ID: <200911032340.nA3NemmX001210@zion.cs.uiuc.edu> Author: lattner Date: Tue Nov 3 17:40:48 2009 New Revision: 85973 URL: http://llvm.org/viewvc/llvm-project?rev=85973&view=rev Log: reimplement multiple return value handling in IPSCCP, making it more aggressive an correct. This survives building llvm in 64-bit mode with optimizations and the built llvm passes make check. Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp llvm/trunk/test/Transforms/SCCP/ipsccp-basic.ll Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCP.cpp?rev=85973&r1=85972&r2=85973&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SCCP.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Tue Nov 3 17:40:48 2009 @@ -159,6 +159,11 @@ SmallPtrSet BBExecutable;// The BBs that are executable. DenseMap ValueState; // The state each value is in. + /// StructValueState - This maintains ValueState for values that have + /// StructType, for example for formal arguments, calls, insertelement, etc. + /// + DenseMap, LatticeVal> StructValueState; + /// GlobalValue - If we are tracking any values for the contents of a global /// variable, we keep a mapping from the constant accessor to the element of /// the global, to the currently known value. If the value becomes @@ -173,6 +178,10 @@ /// TrackedMultipleRetVals - Same as TrackedRetVals, but used for functions /// that return multiple values. DenseMap, LatticeVal> TrackedMultipleRetVals; + + /// MRVFunctionsTracked - Each function in TrackedMultipleRetVals is + /// represented here for efficient lookup. + SmallPtrSet MRVFunctionsTracked; /// TrackingIncomingArguments - This is the set of functions for whose /// arguments we make optimistic assumptions about and try to prove as @@ -219,8 +228,8 @@ /// specified global variable if it can. This is only legal to call if /// performing Interprocedural SCCP. void TrackValueOfGlobalVariable(GlobalVariable *GV) { - const Type *ElTy = GV->getType()->getElementType(); - if (ElTy->isFirstClassType()) { + // We only track the contents of scalar globals. + if (GV->getType()->getElementType()->isSingleValueType()) { LatticeVal &IV = TrackedGlobals[GV]; if (!isa(GV->getInitializer())) IV.markConstant(GV->getInitializer()); @@ -233,6 +242,7 @@ void AddTrackedFunction(Function *F) { // Add an entry, F -> undef. if (const StructType *STy = dyn_cast(F->getReturnType())) { + MRVFunctionsTracked.insert(F); for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) TrackedMultipleRetVals.insert(std::make_pair(std::make_pair(F, i), LatticeVal())); @@ -264,6 +274,13 @@ assert(I != ValueState.end() && "V is not in valuemap!"); return I->second; } + + LatticeVal getStructLatticeValueFor(Value *V, unsigned i) const { + DenseMap, LatticeVal>::const_iterator I = + StructValueState.find(std::make_pair(V, i)); + assert(I != StructValueState.end() && "V is not in valuemap!"); + return I->second; + } /// getTrackedRetVals - Get the inferred return value map. /// @@ -278,9 +295,20 @@ } void markOverdefined(Value *V) { + assert(!isa(V->getType()) && "Should use other method"); markOverdefined(ValueState[V], V); } + /// markAnythingOverdefined - Mark the specified value overdefined. This + /// works with both scalars and structs. + void markAnythingOverdefined(Value *V) { + if (const StructType *STy = dyn_cast(V->getType())) + for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) + markOverdefined(getStructValueState(V, i), V); + else + markOverdefined(V); + } + private: // markConstant - Make a value be marked as "constant". If the value // is not already a constant, add it to the instruction work list so that @@ -293,10 +321,12 @@ } void markConstant(Value *V, Constant *C) { + assert(!isa(V->getType()) && "Should use other method"); markConstant(ValueState[V], V, C); } void markForcedConstant(Value *V, Constant *C) { + assert(!isa(V->getType()) && "Should use other method"); ValueState[V].markForcedConstant(C); DEBUG(errs() << "markForcedConstant: " << *C << ": " << *V << '\n'); InstWorkList.push_back(V); @@ -330,6 +360,7 @@ } void mergeInValue(Value *V, LatticeVal MergeWithV) { + assert(!isa(V->getType()) && "Should use other method"); mergeInValue(ValueState[V], V, MergeWithV); } @@ -338,8 +369,12 @@ /// value. This function handles the case when the value hasn't been seen yet /// by properly seeding constants etc. LatticeVal &getValueState(Value *V) { + assert(!isa(V->getType()) && "Should use getStructValueState"); + + // TODO: Change to do insert+find in one operation. DenseMap::iterator I = ValueState.find(V); - if (I != ValueState.end()) return I->second; // Common case, in the map + if (I != ValueState.end()) + return I->second; // Common case, already in the map. LatticeVal &LV = ValueState[V]; @@ -353,6 +388,39 @@ return LV; } + /// getStructValueState - Return the LatticeVal object that corresponds to the + /// value/field pair. This function handles the case when the value hasn't + /// been seen yet by properly seeding constants etc. + LatticeVal &getStructValueState(Value *V, unsigned i) { + assert(isa(V->getType()) && "Should use getValueState"); + assert(i < cast(V->getType())->getNumElements() && + "Invalid element #"); + + // TODO: Change to do insert+find in one operation. + DenseMap, LatticeVal>::iterator + I = StructValueState.find(std::make_pair(V, i)); + if (I != StructValueState.end()) + return I->second; // Common case, already in the map. + + LatticeVal &LV = StructValueState[std::make_pair(V, i)]; + + if (Constant *C = dyn_cast(V)) { + if (isa(C)) + ; // Undef values remain undefined. + else if (ConstantStruct *CS = dyn_cast(C)) + LV.markConstant(CS->getOperand(i)); // Constants are constant. + else if (isa(C)) { + const Type *FieldTy = cast(V->getType())->getElementType(i); + LV.markConstant(Constant::getNullValue(FieldTy)); + } else + LV.markOverdefined(); // Unknown sort of constant. + } + + // All others are underdefined by default. + return LV; + } + + /// markEdgeExecutable - Mark a basic block as executable, adding it to the BB /// work list if it is not already executable. void markEdgeExecutable(BasicBlock *Source, BasicBlock *Dest) { @@ -444,12 +512,12 @@ void visitUnreachableInst(TerminatorInst &I) { /*returns void*/ } void visitAllocaInst (Instruction &I) { markOverdefined(&I); } void visitVANextInst (Instruction &I) { markOverdefined(&I); } - void visitVAArgInst (Instruction &I) { markOverdefined(&I); } + void visitVAArgInst (Instruction &I) { markAnythingOverdefined(&I); } void visitInstruction(Instruction &I) { // If a new instruction is added to LLVM that we don't handle. errs() << "SCCP: Don't know how to handle: " << I; - markOverdefined(&I); // Just in case + markAnythingOverdefined(&I); // Just in case } }; @@ -596,6 +664,11 @@ // successors executable. // void SCCPSolver::visitPHINode(PHINode &PN) { + // If this PN returns a struct, just mark the result overdefined. + // TODO: We could do a lot better than this if code actually uses this. + if (isa(PN.getType())) + return markAnythingOverdefined(&PN); + if (getValueState(&PN).isOverdefined()) { // There may be instructions using this PHI node that are not overdefined // themselves. If so, make sure that they know that the PHI node operand @@ -617,7 +690,7 @@ // and slow us down a lot. Just mark them overdefined. if (PN.getNumIncomingValues() > 64) return markOverdefined(&PN); - + // Look at all of the executable operands of the PHI node. If any of them // are overdefined, the PHI becomes overdefined as well. If they are all // constant, and they agree with each other, the PHI becomes the identical @@ -666,28 +739,26 @@ if (I.getNumOperands() == 0) return; // ret void Function *F = I.getParent()->getParent(); + Value *ResultOp = I.getOperand(0); // If we are tracking the return value of this function, merge it in. - if (!TrackedRetVals.empty()) { + if (!TrackedRetVals.empty() && !isa(ResultOp->getType())) { DenseMap::iterator TFRVI = TrackedRetVals.find(F); if (TFRVI != TrackedRetVals.end()) { - mergeInValue(TFRVI->second, F, getValueState(I.getOperand(0))); + mergeInValue(TFRVI->second, F, getValueState(ResultOp)); return; } } // Handle functions that return multiple values. - if (!TrackedMultipleRetVals.empty() && - isa(I.getOperand(0)->getType())) { - for (unsigned i = 0, e = I.getOperand(0)->getType()->getNumContainedTypes(); - i != e; ++i) { - DenseMap, LatticeVal>::iterator - It = TrackedMultipleRetVals.find(std::make_pair(F, i)); - if (It == TrackedMultipleRetVals.end()) break; - if (Value *Val = FindInsertedValue(I.getOperand(0), i, I.getContext())) - mergeInValue(It->second, F, getValueState(Val)); - } + if (!TrackedMultipleRetVals.empty()) { + if (const StructType *STy = dyn_cast(ResultOp->getType())) + if (MRVFunctionsTracked.count(F)) + for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) + mergeInValue(TrackedMultipleRetVals[std::make_pair(F, i)], F, + getStructValueState(ResultOp, i)); + } } @@ -712,78 +783,62 @@ OpSt.getConstant(), I.getType())); } -void SCCPSolver::visitExtractValueInst(ExtractValueInst &EVI) { - Value *Aggr = EVI.getAggregateOperand(); - - // If the operand to the extractvalue is an undef, the result is undef. - if (isa(Aggr)) - return; - // Currently only handle single-index extractvalues. +void SCCPSolver::visitExtractValueInst(ExtractValueInst &EVI) { + // If this returns a struct, mark all elements over defined, we don't track + // structs in structs. + if (isa(EVI.getType())) + return markAnythingOverdefined(&EVI); + + // If this is extracting from more than one level of struct, we don't know. if (EVI.getNumIndices() != 1) return markOverdefined(&EVI); - - Function *F = 0; - if (CallInst *CI = dyn_cast(Aggr)) - F = CI->getCalledFunction(); - else if (InvokeInst *II = dyn_cast(Aggr)) - F = II->getCalledFunction(); - - // TODO: If IPSCCP resolves the callee of this function, we could propagate a - // result back! - if (F == 0 || TrackedMultipleRetVals.empty()) - return markOverdefined(&EVI); - - // See if we are tracking the result of the callee. If not tracking this - // function (for example, it is a declaration) just move to overdefined. - if (!TrackedMultipleRetVals.count(std::make_pair(F, *EVI.idx_begin()))) - return markOverdefined(&EVI); - - // Otherwise, the value will be merged in here as a result of CallSite - // handling. + + Value *AggVal = EVI.getAggregateOperand(); + unsigned i = *EVI.idx_begin(); + LatticeVal EltVal = getStructValueState(AggVal, i); + mergeInValue(getValueState(&EVI), &EVI, EltVal); } void SCCPSolver::visitInsertValueInst(InsertValueInst &IVI) { - Value *Aggr = IVI.getAggregateOperand(); - Value *Val = IVI.getInsertedValueOperand(); - - // If the operands to the insertvalue are undef, the result is undef. - if (isa(Aggr) && isa(Val)) - return; - - // Currently only handle single-index insertvalues. - if (IVI.getNumIndices() != 1) + const StructType *STy = dyn_cast(IVI.getType()); + if (STy == 0) return markOverdefined(&IVI); - - // Currently only handle insertvalue instructions that are in a single-use - // chain that builds up a return value. - for (const InsertValueInst *TmpIVI = &IVI; ; ) { - if (!TmpIVI->hasOneUse()) - return markOverdefined(&IVI); - - const Value *V = *TmpIVI->use_begin(); - if (isa(V)) - break; - TmpIVI = dyn_cast(V); - if (!TmpIVI) - return markOverdefined(&IVI); - } - - // See if we are tracking the result of the callee. - Function *F = IVI.getParent()->getParent(); - DenseMap, LatticeVal>::iterator - It = TrackedMultipleRetVals.find(std::make_pair(F, *IVI.idx_begin())); - - // Merge in the inserted member value. - if (It != TrackedMultipleRetVals.end()) - mergeInValue(It->second, F, getValueState(Val)); - - // Mark the aggregate result of the IVI overdefined; any tracking that we do - // will be done on the individual member values. - markOverdefined(&IVI); + + // If this has more than one index, we can't handle it, drive all results to + // undef. + if (IVI.getNumIndices() != 1) + return markAnythingOverdefined(&IVI); + + Value *Aggr = IVI.getAggregateOperand(); + unsigned Idx = *IVI.idx_begin(); + + // Compute the result based on what we're inserting. + for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) { + // This passes through all values that aren't the inserted element. + if (i != Idx) { + LatticeVal EltVal = getStructValueState(Aggr, i); + mergeInValue(getStructValueState(&IVI, i), &IVI, EltVal); + continue; + } + + Value *Val = IVI.getInsertedValueOperand(); + if (isa(Val->getType())) + // We don't track structs in structs. + markOverdefined(getStructValueState(&IVI, i), &IVI); + else { + LatticeVal InVal = getValueState(Val); + mergeInValue(getStructValueState(&IVI, i), &IVI, InVal); + } + } } void SCCPSolver::visitSelectInst(SelectInst &I) { + // If this select returns a struct, just mark the result overdefined. + // TODO: We could do a lot better than this if code actually uses this. + if (isa(I.getType())) + return markAnythingOverdefined(&I); + LatticeVal CondValue = getValueState(I.getCondition()); if (CondValue.isUndefined()) return; @@ -1011,7 +1066,7 @@ } void SCCPSolver::visitExtractElementInst(ExtractElementInst &I) { - // FIXME : SCCP does not handle vectors properly. + // TODO : SCCP does not handle vectors properly. return markOverdefined(&I); #if 0 @@ -1027,7 +1082,7 @@ } void SCCPSolver::visitInsertElementInst(InsertElementInst &I) { - // FIXME : SCCP does not handle vectors properly. + // TODO : SCCP does not handle vectors properly. return markOverdefined(&I); #if 0 LatticeVal &ValState = getValueState(I.getOperand(0)); @@ -1051,7 +1106,7 @@ } void SCCPSolver::visitShuffleVectorInst(ShuffleVectorInst &I) { - // FIXME : SCCP does not handle vectors properly. + // TODO : SCCP does not handle vectors properly. return markOverdefined(&I); #if 0 LatticeVal &V1State = getValueState(I.getOperand(0)); @@ -1105,6 +1160,10 @@ } void SCCPSolver::visitStoreInst(StoreInst &SI) { + // If this store is of a struct, ignore it. + if (isa(SI.getOperand(0)->getType())) + return; + if (TrackedGlobals.empty() || !isa(SI.getOperand(1))) return; @@ -1122,6 +1181,10 @@ // Handle load instructions. If the operand is a constant pointer to a constant // global, we can replace the load with the loaded constant value! void SCCPSolver::visitLoadInst(LoadInst &I) { + // If this load is of a struct, just mark the result overdefined. + if (isa(I.getType())) + return markAnythingOverdefined(&I); + LatticeVal PtrVal = getValueState(I.getOperand(0)); if (PtrVal.isUndefined()) return; // The pointer is not resolved yet! @@ -1196,7 +1259,7 @@ } // Otherwise, we don't know anything about this call, mark it overdefined. - return markOverdefined(I); + return markAnythingOverdefined(I); } // If this is a local function that doesn't have its address taken, mark its @@ -1216,47 +1279,33 @@ continue; } - mergeInValue(AI, getValueState(*CAI)); + if (const StructType *STy = dyn_cast(AI->getType())) { + for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) + mergeInValue(getStructValueState(AI, i), AI, + getStructValueState(*CAI, i)); + } else { + mergeInValue(AI, getValueState(*CAI)); + } } } // If this is a single/zero retval case, see if we're tracking the function. - DenseMap::iterator TFRVI = TrackedRetVals.find(F); - if (TFRVI != TrackedRetVals.end()) { + if (const StructType *STy = dyn_cast(F->getReturnType())) { + if (!MRVFunctionsTracked.count(F)) + goto CallOverdefined; // Not tracking this callee. + + // If we are tracking this callee, propagate the result of the function + // into this call site. + for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) + mergeInValue(getStructValueState(I, i), I, + TrackedMultipleRetVals[std::make_pair(F, i)]); + } else { + DenseMap::iterator TFRVI = TrackedRetVals.find(F); + if (TFRVI == TrackedRetVals.end()) + goto CallOverdefined; // Not tracking this callee. + // If so, propagate the return value of the callee into this call result. mergeInValue(I, TFRVI->second); - } else if (isa(I->getType())) { - // Check to see if we're tracking this callee, if not, handle it in the - // common path above. - DenseMap, LatticeVal>::iterator - TMRVI = TrackedMultipleRetVals.find(std::make_pair(F, 0)); - if (TMRVI == TrackedMultipleRetVals.end()) - goto CallOverdefined; - - // Need to mark as overdefined, otherwise it stays undefined which - // creates extractvalue undef, - markOverdefined(I); - - // If we are tracking this callee, propagate the return values of the call - // into this call site. We do this by walking all the uses. Single-index - // ExtractValueInst uses can be tracked; anything more complicated is - // currently handled conservatively. - for (Value::use_iterator UI = I->use_begin(), E = I->use_end(); - UI != E; ++UI) { - if (ExtractValueInst *EVI = dyn_cast(*UI)) { - if (EVI->getNumIndices() == 1) { - mergeInValue(EVI, - TrackedMultipleRetVals[std::make_pair(F, *EVI->idx_begin())]); - continue; - } - } - // The aggregate value is used in a way not handled here. Assume nothing. - markOverdefined(*UI); - } - } else { - // Otherwise we're not tracking this callee, so handle it in the - // common path above. - goto CallOverdefined; } } @@ -1297,7 +1346,7 @@ // since all of its users will have already been marked as overdefined. // Update all of the users of this instruction's value. // - if (!getValueState(I).isOverdefined()) + if (isa(I->getType()) || !getValueState(I).isOverdefined()) for (Value::use_iterator UI = I->use_begin(), E = I->use_end(); UI != E; ++UI) if (Instruction *I = dyn_cast(*UI)) @@ -1345,13 +1394,35 @@ // Look for instructions which produce undef values. if (I->getType()->isVoidTy()) continue; + if (const StructType *STy = dyn_cast(I->getType())) { + // Only a few things that can be structs matter for undef. Just send + // all their results to overdefined. We could be more precise than this + // but it isn't worth bothering. + if (isa(I) || isa(I)) { + for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) { + LatticeVal &LV = getStructValueState(I, i); + if (LV.isUndefined()) + markOverdefined(LV, I); + } + } + continue; + } + LatticeVal &LV = getValueState(I); if (!LV.isUndefined()) continue; + // No instructions using structs need disambiguation. + if (isa(I->getOperand(0)->getType())) + continue; + // Get the lattice values of the first two operands for use below. LatticeVal Op0LV = getValueState(I->getOperand(0)); LatticeVal Op1LV; if (I->getNumOperands() == 2) { + // No instructions using structs need disambiguation. + if (isa(I->getOperand(1)->getType())) + continue; + // If this is a two-operand instruction, and if both operands are // undefs, the result stays undef. Op1LV = getValueState(I->getOperand(1)); @@ -1547,7 +1618,7 @@ // Mark all arguments to the function as being overdefined. for (Function::arg_iterator AI = F.arg_begin(), E = F.arg_end(); AI != E;++AI) - Solver.markOverdefined(AI); + Solver.markAnythingOverdefined(AI); // Solve for constants. bool ResolvedUndefs = true; @@ -1578,6 +1649,10 @@ if (Inst->getType()->isVoidTy() || isa(Inst)) continue; + // TODO: Reconstruct structs from their elements. + if (isa(Inst->getType())) + continue; + LatticeVal IV = Solver.getLatticeValueFor(Inst); if (IV.isOverdefined()) continue; @@ -1661,8 +1736,7 @@ // If this is a strong or ODR definition of this function, then we can // propagate information about its result into callsites of it. - if (!F->mayBeOverridden() && - !isa(F->getReturnType())) + if (!F->mayBeOverridden()) Solver.AddTrackedFunction(F); // If this function only has direct calls that we can see, we can track its @@ -1679,7 +1753,7 @@ // Assume nothing about the incoming arguments. for (Function::arg_iterator AI = F->arg_begin(), E = F->arg_end(); AI != E; ++AI) - Solver.markOverdefined(AI); + Solver.markAnythingOverdefined(AI); } // Loop over global variables. We inform the solver about any internal global @@ -1712,8 +1786,11 @@ if (Solver.isBlockExecutable(F->begin())) { for (Function::arg_iterator AI = F->arg_begin(), E = F->arg_end(); AI != E; ++AI) { - if (AI->use_empty()) continue; + if (AI->use_empty() || isa(AI->getType())) continue; + // TODO: Could use getStructLatticeValueFor to find out if the entire + // result is a constant and replace it entirely if so. + LatticeVal IV = Solver.getLatticeValueFor(AI); if (IV.isOverdefined()) continue; @@ -1752,9 +1829,12 @@ for (BasicBlock::iterator BI = BB->begin(), E = BB->end(); BI != E; ) { Instruction *Inst = BI++; - if (Inst->getType()->isVoidTy()) + if (Inst->getType()->isVoidTy() || isa(Inst->getType())) continue; + // TODO: Could use getStructLatticeValueFor to find out if the entire + // result is a constant and replace it entirely if so. + LatticeVal IV = Solver.getLatticeValueFor(Inst); if (IV.isOverdefined()) continue; Modified: llvm/trunk/test/Transforms/SCCP/ipsccp-basic.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SCCP/ipsccp-basic.ll?rev=85973&r1=85972&r2=85973&view=diff ============================================================================== --- llvm/trunk/test/Transforms/SCCP/ipsccp-basic.ll (original) +++ llvm/trunk/test/Transforms/SCCP/ipsccp-basic.ll Tue Nov 3 17:40:48 2009 @@ -1,5 +1,4 @@ ; RUN: opt < %s -ipsccp -S | FileCheck %s -; XFAIL: * ;;======================== test1 @@ -128,7 +127,7 @@ ; CHECK: define i64 @test5b() ; CHECK: A: ; CHECK-NEXT: %c = call i64 @test5c(%0 %a) -; CHECK-NEXT: ret i64 %c +; CHECK-NEXT: ret i64 5 define internal i64 @test5c({i64,i64} %a) { %b = extractvalue {i64,i64} %a, 0 From evan.cheng at apple.com Tue Nov 3 17:42:41 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 03 Nov 2009 23:42:41 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r85974 - /llvm-gcc-4.2/trunk/build_gcc Message-ID: <200911032342.nA3NgfOO001271@zion.cs.uiuc.edu> Author: evancheng Date: Tue Nov 3 17:42:40 2009 New Revision: 85974 URL: http://llvm.org/viewvc/llvm-project?rev=85974&view=rev Log: Revert 85950. It's not necessary. 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=85974&r1=85973&r2=85974&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/build_gcc (original) +++ llvm-gcc-4.2/trunk/build_gcc Tue Nov 3 17:42:40 2009 @@ -116,9 +116,7 @@ NON_ARM_CONFIGFLAGS="--with-gxx-include-dir=/usr/include/c++/$LIBSTDCXX_VERSION" # LLVM LOCAL end -if [ "x$DARWIN_VERS" == "x" ]; then - DARWIN_VERS=`uname -r | sed 's/\..*//'` -fi +DARWIN_VERS=`uname -r | sed 's/\..*//'` echo DARWIN_VERS = $DARWIN_VERS # APPLE LOCAL begin ARM From bob.wilson at apple.com Tue Nov 3 17:44:32 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 03 Nov 2009 23:44:32 -0000 Subject: [llvm-commits] [llvm] r85975 - /llvm/trunk/lib/CodeGen/BranchFolding.cpp Message-ID: <200911032344.nA3NiWK7001336@zion.cs.uiuc.edu> Author: bwilson Date: Tue Nov 3 17:44:31 2009 New Revision: 85975 URL: http://llvm.org/viewvc/llvm-project?rev=85975&view=rev Log: Fix branch folding bug for indirect branches: for a block containing only an unconditional branch (possibly from tail merging), this code is trying to redirect all of its predecessors to go directly to the branch target, but that isn't feasible for indirect branches. The other predecessors (that don't end with indirect branches) could theoretically still be handled, but that is not easily done right now. The AnalyzeBranch interface doesn't currently let us distinguish jump table branches from indirect branches, and this code is currently handling jump tables. To avoid punting on address-taken blocks, we would have to give up handling jump tables. That seems like a bad tradeoff. Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.cpp?rev=85975&r1=85974&r2=85975&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/BranchFolding.cpp (original) +++ llvm/trunk/lib/CodeGen/BranchFolding.cpp Tue Nov 3 17:44:31 2009 @@ -1050,7 +1050,8 @@ // If this branch is the only thing in its block, see if we can forward // other blocks across it. if (CurTBB && CurCond.empty() && CurFBB == 0 && - MBB->begin()->getDesc().isBranch() && CurTBB != MBB) { + MBB->begin()->getDesc().isBranch() && CurTBB != MBB && + !MBB->hasAddressTaken()) { // This block may contain just an unconditional branch. Because there can // be 'non-branch terminators' in the block, try removing the branch and // then seeing if the block is empty. From lhames at gmail.com Tue Nov 3 17:52:08 2009 From: lhames at gmail.com (Lang Hames) Date: Tue, 03 Nov 2009 23:52:08 -0000 Subject: [llvm-commits] [llvm] r85979 - in /llvm/trunk: include/llvm/CodeGen/ lib/CodeGen/ Message-ID: <200911032352.nA3Nq9hl001625@zion.cs.uiuc.edu> Author: lhames Date: Tue Nov 3 17:52:08 2009 New Revision: 85979 URL: http://llvm.org/viewvc/llvm-project?rev=85979&view=rev Log: The Indexes Patch. This introduces a new pass, SlotIndexes, which is responsible for numbering instructions for register allocation (and other clients). SlotIndexes numbering is designed to match the existing scheme, so this patch should not cause any changes in the generated code. For consistency, and to avoid naming confusion, LiveIndex has been renamed SlotIndex. The processImplicitDefs method of the LiveIntervals analysis has been moved into its own pass so that it can be run prior to SlotIndexes. This was necessary to match the existing numbering scheme. Added: llvm/trunk/include/llvm/CodeGen/ProcessImplicitDefs.h llvm/trunk/include/llvm/CodeGen/SlotIndexes.h llvm/trunk/lib/CodeGen/ProcessImplicitDefs.cpp llvm/trunk/lib/CodeGen/SlotIndexes.cpp Modified: llvm/trunk/include/llvm/CodeGen/LiveInterval.h llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h llvm/trunk/include/llvm/CodeGen/LiveStackAnalysis.h llvm/trunk/lib/CodeGen/LiveInterval.cpp llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp llvm/trunk/lib/CodeGen/LiveStackAnalysis.cpp llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp llvm/trunk/lib/CodeGen/RegAllocPBQP.cpp llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.h llvm/trunk/lib/CodeGen/Spiller.cpp llvm/trunk/lib/CodeGen/StackSlotColoring.cpp llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp llvm/trunk/lib/CodeGen/VirtRegMap.cpp llvm/trunk/lib/CodeGen/VirtRegMap.h Modified: llvm/trunk/include/llvm/CodeGen/LiveInterval.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveInterval.h?rev=85979&r1=85978&r2=85979&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/LiveInterval.h (original) +++ llvm/trunk/include/llvm/CodeGen/LiveInterval.h Tue Nov 3 17:52:08 2009 @@ -21,221 +21,19 @@ #ifndef LLVM_CODEGEN_LIVEINTERVAL_H #define LLVM_CODEGEN_LIVEINTERVAL_H -#include "llvm/ADT/DenseMapInfo.h" #include "llvm/ADT/SmallVector.h" #include "llvm/Support/Allocator.h" #include "llvm/Support/AlignOf.h" +#include "llvm/CodeGen/SlotIndexes.h" #include #include namespace llvm { + class LiveIntervals; class MachineInstr; class MachineRegisterInfo; class TargetRegisterInfo; class raw_ostream; - - /// LiveIndex - An opaque wrapper around machine indexes. - class LiveIndex { - friend class VNInfo; - friend class LiveInterval; - friend class LiveIntervals; - friend struct DenseMapInfo; - - public: - - enum Slot { LOAD, USE, DEF, STORE, NUM }; - - private: - - unsigned index; - - static const unsigned PHI_BIT = 1 << 31; - - public: - - /// Construct a default LiveIndex pointing to a reserved index. - LiveIndex() : index(0) {} - - /// Construct an index from the given index, pointing to the given slot. - LiveIndex(LiveIndex m, Slot s) - : index((m.index / NUM) * NUM + s) {} - - /// Print this index to the given raw_ostream. - void print(raw_ostream &os) const; - - /// Compare two LiveIndex objects for equality. - bool operator==(LiveIndex other) const { - return ((index & ~PHI_BIT) == (other.index & ~PHI_BIT)); - } - /// Compare two LiveIndex objects for inequality. - bool operator!=(LiveIndex other) const { - return ((index & ~PHI_BIT) != (other.index & ~PHI_BIT)); - } - - /// Compare two LiveIndex objects. Return true if the first index - /// is strictly lower than the second. - bool operator<(LiveIndex other) const { - return ((index & ~PHI_BIT) < (other.index & ~PHI_BIT)); - } - /// Compare two LiveIndex objects. Return true if the first index - /// is lower than, or equal to, the second. - bool operator<=(LiveIndex other) const { - return ((index & ~PHI_BIT) <= (other.index & ~PHI_BIT)); - } - - /// Compare two LiveIndex objects. Return true if the first index - /// is greater than the second. - bool operator>(LiveIndex other) const { - return ((index & ~PHI_BIT) > (other.index & ~PHI_BIT)); - } - - /// Compare two LiveIndex objects. Return true if the first index - /// is greater than, or equal to, the second. - bool operator>=(LiveIndex other) const { - return ((index & ~PHI_BIT) >= (other.index & ~PHI_BIT)); - } - - /// Returns true if this index represents a load. - bool isLoad() const { - return ((index % NUM) == LOAD); - } - - /// Returns true if this index represents a use. - bool isUse() const { - return ((index % NUM) == USE); - } - - /// Returns true if this index represents a def. - bool isDef() const { - return ((index % NUM) == DEF); - } - - /// Returns true if this index represents a store. - bool isStore() const { - return ((index % NUM) == STORE); - } - - /// Returns the slot for this LiveIndex. - Slot getSlot() const { - return static_cast(index % NUM); - } - - /// Returns true if this index represents a non-PHI use/def. - bool isNonPHIIndex() const { - return ((index & PHI_BIT) == 0); - } - - /// Returns true if this index represents a PHI use/def. - bool isPHIIndex() const { - return ((index & PHI_BIT) == PHI_BIT); - } - - private: - - /// Construct an index from the given index, with its PHI kill marker set. - LiveIndex(bool phi, LiveIndex o) : index(o.index) { - if (phi) - index |= PHI_BIT; - else - index &= ~PHI_BIT; - } - - explicit LiveIndex(unsigned idx) - : index(idx & ~PHI_BIT) {} - - LiveIndex(bool phi, unsigned idx) - : index(idx & ~PHI_BIT) { - if (phi) - index |= PHI_BIT; - } - - LiveIndex(bool phi, unsigned idx, Slot slot) - : index(((idx / NUM) * NUM + slot) & ~PHI_BIT) { - if (phi) - index |= PHI_BIT; - } - - LiveIndex nextSlot_() const { - assert((index & PHI_BIT) == ((index + 1) & PHI_BIT) && - "Index out of bounds."); - return LiveIndex(index + 1); - } - - LiveIndex nextIndex_() const { - assert((index & PHI_BIT) == ((index + NUM) & PHI_BIT) && - "Index out of bounds."); - return LiveIndex(index + NUM); - } - - LiveIndex prevSlot_() const { - assert((index & PHI_BIT) == ((index - 1) & PHI_BIT) && - "Index out of bounds."); - return LiveIndex(index - 1); - } - - LiveIndex prevIndex_() const { - assert((index & PHI_BIT) == ((index - NUM) & PHI_BIT) && - "Index out of bounds."); - return LiveIndex(index - NUM); - } - - int distance(LiveIndex other) const { - return (other.index & ~PHI_BIT) - (index & ~PHI_BIT); - } - - /// Returns an unsigned number suitable as an index into a - /// vector over all instructions. - unsigned getVecIndex() const { - return (index & ~PHI_BIT) / NUM; - } - - /// Scale this index by the given factor. - LiveIndex scale(unsigned factor) const { - unsigned i = (index & ~PHI_BIT) / NUM, - o = (index % ~PHI_BIT) % NUM; - assert(index <= (~0U & ~PHI_BIT) / (factor * NUM) && - "Rescaled interval would overflow"); - return LiveIndex(i * NUM * factor, o); - } - - static LiveIndex emptyKey() { - return LiveIndex(true, 0x7fffffff); - } - - static LiveIndex tombstoneKey() { - return LiveIndex(true, 0x7ffffffe); - } - - static unsigned getHashValue(const LiveIndex &v) { - return v.index * 37; - } - - }; - - inline raw_ostream& operator<<(raw_ostream &os, LiveIndex mi) { - mi.print(os); - return os; - } - - /// Densemap specialization for LiveIndex. - template <> - struct DenseMapInfo { - static inline LiveIndex getEmptyKey() { - return LiveIndex::emptyKey(); - } - static inline LiveIndex getTombstoneKey() { - return LiveIndex::tombstoneKey(); - } - static inline unsigned getHashValue(const LiveIndex &v) { - return LiveIndex::getHashValue(v); - } - static inline bool isEqual(const LiveIndex &LHS, - const LiveIndex &RHS) { - return (LHS == RHS); - } - static inline bool isPod() { return true; } - }; - /// VNInfo - Value Number Information. /// This class holds information about a machine level values, including @@ -270,23 +68,25 @@ public: - typedef SmallVector KillSet; + typedef SmallVector KillSet; /// The ID number of this value. unsigned id; /// The index of the defining instruction (if isDefAccurate() returns true). - LiveIndex def; + SlotIndex def; KillSet kills; - VNInfo() - : flags(IS_UNUSED), id(~1U) { cr.copy = 0; } + /* + VNInfo(LiveIntervals &li_) + : defflags(IS_UNUSED), id(~1U) { cr.copy = 0; } + */ /// VNInfo constructor. /// d is presumed to point to the actual defining instr. If it doesn't /// setIsDefAccurate(false) should be called after construction. - VNInfo(unsigned i, LiveIndex d, MachineInstr *c) + VNInfo(unsigned i, SlotIndex d, MachineInstr *c) : flags(IS_DEF_ACCURATE), id(i), def(d) { cr.copy = c; } /// VNInfo construtor, copies values from orig, except for the value number. @@ -377,7 +177,7 @@ } /// Returns true if the given index is a kill of this value. - bool isKill(LiveIndex k) const { + bool isKill(SlotIndex k) const { KillSet::const_iterator i = std::lower_bound(kills.begin(), kills.end(), k); return (i != kills.end() && *i == k); @@ -385,7 +185,7 @@ /// addKill - Add a kill instruction index to the specified value /// number. - void addKill(LiveIndex k) { + void addKill(SlotIndex k) { if (kills.empty()) { kills.push_back(k); } else { @@ -397,7 +197,7 @@ /// Remove the specified kill index from this value's kills list. /// Returns true if the value was present, otherwise returns false. - bool removeKill(LiveIndex k) { + bool removeKill(SlotIndex k) { KillSet::iterator i = std::lower_bound(kills.begin(), kills.end(), k); if (i != kills.end() && *i == k) { kills.erase(i); @@ -407,7 +207,7 @@ } /// Remove all kills in the range [s, e). - void removeKills(LiveIndex s, LiveIndex e) { + void removeKills(SlotIndex s, SlotIndex e) { KillSet::iterator si = std::lower_bound(kills.begin(), kills.end(), s), se = std::upper_bound(kills.begin(), kills.end(), e); @@ -421,11 +221,11 @@ /// program, with an inclusive start point and an exclusive end point. /// These ranges are rendered as [start,end). struct LiveRange { - LiveIndex start; // Start point of the interval (inclusive) - LiveIndex end; // End point of the interval (exclusive) + SlotIndex start; // Start point of the interval (inclusive) + SlotIndex end; // End point of the interval (exclusive) VNInfo *valno; // identifier for the value contained in this interval. - LiveRange(LiveIndex S, LiveIndex E, VNInfo *V) + LiveRange(SlotIndex S, SlotIndex E, VNInfo *V) : start(S), end(E), valno(V) { assert(S < E && "Cannot create empty or backwards range"); @@ -433,13 +233,13 @@ /// contains - Return true if the index is covered by this range. /// - bool contains(LiveIndex I) const { + bool contains(SlotIndex I) const { return start <= I && I < end; } /// containsRange - Return true if the given range, [S, E), is covered by /// this range. - bool containsRange(LiveIndex S, LiveIndex E) const { + bool containsRange(SlotIndex S, SlotIndex E) const { assert((S < E) && "Backwards interval?"); return (start <= S && S < end) && (start < E && E <= end); } @@ -461,11 +261,11 @@ raw_ostream& operator<<(raw_ostream& os, const LiveRange &LR); - inline bool operator<(LiveIndex V, const LiveRange &LR) { + inline bool operator<(SlotIndex V, const LiveRange &LR) { return V < LR.start; } - inline bool operator<(const LiveRange &LR, LiveIndex V) { + inline bool operator<(const LiveRange &LR, SlotIndex V) { return LR.start < V; } @@ -522,7 +322,7 @@ /// end of the interval. If no LiveRange contains this position, but the /// position is in a hole, this method returns an iterator pointing the the /// LiveRange immediately after the hole. - iterator advanceTo(iterator I, LiveIndex Pos) { + iterator advanceTo(iterator I, SlotIndex Pos) { if (Pos >= endIndex()) return end(); while (I->end <= Pos) ++I; @@ -569,7 +369,7 @@ /// getNextValue - Create a new value number and return it. MIIdx specifies /// the instruction that defines the value number. - VNInfo *getNextValue(LiveIndex def, MachineInstr *CopyMI, + VNInfo *getNextValue(SlotIndex def, MachineInstr *CopyMI, bool isDefAccurate, BumpPtrAllocator &VNInfoAllocator){ VNInfo *VNI = static_cast(VNInfoAllocator.Allocate((unsigned)sizeof(VNInfo), @@ -625,13 +425,15 @@ /// current interval, but are defined in the Clobbers interval, mark them /// used with an unknown definition value. Caller must pass in reference to /// VNInfoAllocator since it will create a new val#. - void MergeInClobberRanges(const LiveInterval &Clobbers, + void MergeInClobberRanges(LiveIntervals &li_, + const LiveInterval &Clobbers, BumpPtrAllocator &VNInfoAllocator); /// MergeInClobberRange - Same as MergeInClobberRanges except it merge in a /// single LiveRange only. - void MergeInClobberRange(LiveIndex Start, - LiveIndex End, + void MergeInClobberRange(LiveIntervals &li_, + SlotIndex Start, + SlotIndex End, BumpPtrAllocator &VNInfoAllocator); /// MergeValueInAsValue - Merge all of the live ranges of a specific val# @@ -657,56 +459,54 @@ bool empty() const { return ranges.empty(); } /// beginIndex - Return the lowest numbered slot covered by interval. - LiveIndex beginIndex() const { - if (empty()) - return LiveIndex(); + SlotIndex beginIndex() const { + assert(!empty() && "Call to beginIndex() on empty interval."); return ranges.front().start; } /// endNumber - return the maximum point of the interval of the whole, /// exclusive. - LiveIndex endIndex() const { - if (empty()) - return LiveIndex(); + SlotIndex endIndex() const { + assert(!empty() && "Call to endIndex() on empty interval."); return ranges.back().end; } - bool expiredAt(LiveIndex index) const { + bool expiredAt(SlotIndex index) const { return index >= endIndex(); } - bool liveAt(LiveIndex index) const; + bool liveAt(SlotIndex index) const; // liveBeforeAndAt - Check if the interval is live at the index and the // index just before it. If index is liveAt, check if it starts a new live // range.If it does, then check if the previous live range ends at index-1. - bool liveBeforeAndAt(LiveIndex index) const; + bool liveBeforeAndAt(SlotIndex index) const; /// getLiveRangeContaining - Return the live range that contains the /// specified index, or null if there is none. - const LiveRange *getLiveRangeContaining(LiveIndex Idx) const { + const LiveRange *getLiveRangeContaining(SlotIndex Idx) const { const_iterator I = FindLiveRangeContaining(Idx); return I == end() ? 0 : &*I; } /// getLiveRangeContaining - Return the live range that contains the /// specified index, or null if there is none. - LiveRange *getLiveRangeContaining(LiveIndex Idx) { + LiveRange *getLiveRangeContaining(SlotIndex Idx) { iterator I = FindLiveRangeContaining(Idx); return I == end() ? 0 : &*I; } /// FindLiveRangeContaining - Return an iterator to the live range that /// contains the specified index, or end() if there is none. - const_iterator FindLiveRangeContaining(LiveIndex Idx) const; + const_iterator FindLiveRangeContaining(SlotIndex Idx) const; /// FindLiveRangeContaining - Return an iterator to the live range that /// contains the specified index, or end() if there is none. - iterator FindLiveRangeContaining(LiveIndex Idx); + iterator FindLiveRangeContaining(SlotIndex Idx); /// findDefinedVNInfo - Find the by the specified /// index (register interval) or defined - VNInfo *findDefinedVNInfoForRegInt(LiveIndex Idx) const; + VNInfo *findDefinedVNInfoForRegInt(SlotIndex Idx) const; /// findDefinedVNInfo - Find the VNInfo that's defined by the specified /// register (stack inteval only). @@ -721,7 +521,7 @@ /// overlaps - Return true if the live interval overlaps a range specified /// by [Start, End). - bool overlaps(LiveIndex Start, LiveIndex End) const; + bool overlaps(SlotIndex Start, SlotIndex End) const; /// overlapsFrom - Return true if the intersection of the two live intervals /// is not empty. The specified iterator is a hint that we can begin @@ -738,18 +538,19 @@ /// join - Join two live intervals (this, and other) together. This applies /// mappings to the value numbers in the LHS/RHS intervals as specified. If /// the intervals are not joinable, this aborts. - void join(LiveInterval &Other, const int *ValNoAssignments, + void join(LiveInterval &Other, + const int *ValNoAssignments, const int *RHSValNoAssignments, SmallVector &NewVNInfo, MachineRegisterInfo *MRI); /// isInOneLiveRange - Return true if the range specified is entirely in the /// a single LiveRange of the live interval. - bool isInOneLiveRange(LiveIndex Start, LiveIndex End); + bool isInOneLiveRange(SlotIndex Start, SlotIndex End); /// removeRange - Remove the specified range from this interval. Note that /// the range must be a single LiveRange in its entirety. - void removeRange(LiveIndex Start, LiveIndex End, + void removeRange(SlotIndex Start, SlotIndex End, bool RemoveDeadValNo = false); void removeRange(LiveRange LR, bool RemoveDeadValNo = false) { @@ -773,8 +574,8 @@ void ComputeJoinedWeight(const LiveInterval &Other); bool operator<(const LiveInterval& other) const { - const LiveIndex &thisIndex = beginIndex(); - const LiveIndex &otherIndex = other.beginIndex(); + const SlotIndex &thisIndex = beginIndex(); + const SlotIndex &otherIndex = other.beginIndex(); return (thisIndex < otherIndex || (thisIndex == otherIndex && reg < other.reg)); } @@ -785,8 +586,9 @@ private: Ranges::iterator addRangeFrom(LiveRange LR, Ranges::iterator From); - void extendIntervalEndTo(Ranges::iterator I, LiveIndex NewEnd); - Ranges::iterator extendIntervalStartTo(Ranges::iterator I, LiveIndex NewStr); + void extendIntervalEndTo(Ranges::iterator I, SlotIndex NewEnd); + Ranges::iterator extendIntervalStartTo(Ranges::iterator I, SlotIndex NewStr); + LiveInterval& operator=(const LiveInterval& rhs); // DO NOT IMPLEMENT }; Modified: llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h?rev=85979&r1=85978&r2=85979&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h (original) +++ llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h Tue Nov 3 17:52:08 2009 @@ -23,12 +23,14 @@ #include "llvm/CodeGen/MachineBasicBlock.h" #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/LiveInterval.h" +#include "llvm/CodeGen/SlotIndexes.h" #include "llvm/ADT/BitVector.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallVector.h" #include "llvm/Support/Allocator.h" #include +#include namespace llvm { @@ -40,21 +42,6 @@ class TargetInstrInfo; class TargetRegisterClass; class VirtRegMap; - typedef std::pair IdxMBBPair; - - inline bool operator<(LiveIndex V, const IdxMBBPair &IM) { - return V < IM.first; - } - - inline bool operator<(const IdxMBBPair &IM, LiveIndex V) { - return IM.first < V; - } - - struct Idx2MBBCompare { - bool operator()(const IdxMBBPair &LHS, const IdxMBBPair &RHS) const { - return LHS.first < RHS.first; - } - }; class LiveIntervals : public MachineFunctionPass { MachineFunction* mf_; @@ -64,33 +51,15 @@ const TargetInstrInfo* tii_; AliasAnalysis *aa_; LiveVariables* lv_; + SlotIndexes* indexes_; /// Special pool allocator for VNInfo's (LiveInterval val#). /// BumpPtrAllocator VNInfoAllocator; - /// MBB2IdxMap - The indexes of the first and last instructions in the - /// specified basic block. - std::vector > MBB2IdxMap; - - /// Idx2MBBMap - Sorted list of pairs of index of first instruction - /// and MBB id. - std::vector Idx2MBBMap; - - /// FunctionSize - The number of instructions present in the function - uint64_t FunctionSize; - - typedef DenseMap Mi2IndexMap; - Mi2IndexMap mi2iMap_; - - typedef std::vector Index2MiMap; - Index2MiMap i2miMap_; - typedef DenseMap Reg2IntervalMap; Reg2IntervalMap r2iMap_; - DenseMap terminatorGaps; - /// phiJoinCopies - Copy instructions which are PHI joins. SmallVector phiJoinCopies; @@ -100,48 +69,10 @@ /// CloneMIs - A list of clones as result of re-materialization. std::vector CloneMIs; - typedef LiveInterval::InstrSlots InstrSlots; - public: static char ID; // Pass identification, replacement for typeid LiveIntervals() : MachineFunctionPass(&ID) {} - LiveIndex getBaseIndex(LiveIndex index) { - return LiveIndex(index, LiveIndex::LOAD); - } - LiveIndex getBoundaryIndex(LiveIndex index) { - return LiveIndex(index, - (LiveIndex::Slot)(LiveIndex::NUM - 1)); - } - LiveIndex getLoadIndex(LiveIndex index) { - return LiveIndex(index, LiveIndex::LOAD); - } - LiveIndex getUseIndex(LiveIndex index) { - return LiveIndex(index, LiveIndex::USE); - } - LiveIndex getDefIndex(LiveIndex index) { - return LiveIndex(index, LiveIndex::DEF); - } - LiveIndex getStoreIndex(LiveIndex index) { - return LiveIndex(index, LiveIndex::STORE); - } - - LiveIndex getNextSlot(LiveIndex m) const { - return m.nextSlot_(); - } - - LiveIndex getNextIndex(LiveIndex m) const { - return m.nextIndex_(); - } - - LiveIndex getPrevSlot(LiveIndex m) const { - return m.prevSlot_(); - } - - LiveIndex getPrevIndex(LiveIndex m) const { - return m.prevIndex_(); - } - static float getSpillWeight(bool isDef, bool isUse, unsigned loopDepth) { return (isDef + isUse) * powf(10.0F, (float)loopDepth); } @@ -170,111 +101,18 @@ return r2iMap_.count(reg); } - /// getMBBStartIdx - Return the base index of the first instruction in the - /// specified MachineBasicBlock. - LiveIndex getMBBStartIdx(MachineBasicBlock *MBB) const { - return getMBBStartIdx(MBB->getNumber()); - } - LiveIndex getMBBStartIdx(unsigned MBBNo) const { - assert(MBBNo < MBB2IdxMap.size() && "Invalid MBB number!"); - return MBB2IdxMap[MBBNo].first; - } - - /// getMBBEndIdx - Return the store index of the last instruction in the - /// specified MachineBasicBlock. - LiveIndex getMBBEndIdx(MachineBasicBlock *MBB) const { - return getMBBEndIdx(MBB->getNumber()); - } - LiveIndex getMBBEndIdx(unsigned MBBNo) const { - assert(MBBNo < MBB2IdxMap.size() && "Invalid MBB number!"); - return MBB2IdxMap[MBBNo].second; - } - /// getScaledIntervalSize - get the size of an interval in "units," /// where every function is composed of one thousand units. This /// measure scales properly with empty index slots in the function. double getScaledIntervalSize(LiveInterval& I) { - return (1000.0 / InstrSlots::NUM * I.getSize()) / i2miMap_.size(); + return (1000.0 * I.getSize()) / indexes_->getIndexesLength(); } /// getApproximateInstructionCount - computes an estimate of the number /// of instructions in a given LiveInterval. unsigned getApproximateInstructionCount(LiveInterval& I) { double IntervalPercentage = getScaledIntervalSize(I) / 1000.0; - return (unsigned)(IntervalPercentage * FunctionSize); - } - - /// getMBBFromIndex - given an index in any instruction of an - /// MBB return a pointer the MBB - MachineBasicBlock* getMBBFromIndex(LiveIndex index) const { - std::vector::const_iterator I = - std::lower_bound(Idx2MBBMap.begin(), Idx2MBBMap.end(), index); - // Take the pair containing the index - std::vector::const_iterator J = - ((I != Idx2MBBMap.end() && I->first > index) || - (I == Idx2MBBMap.end() && Idx2MBBMap.size()>0)) ? (I-1): I; - - assert(J != Idx2MBBMap.end() && J->first <= index && - index <= getMBBEndIdx(J->second) && - "index does not correspond to an MBB"); - return J->second; - } - - /// getInstructionIndex - returns the base index of instr - LiveIndex getInstructionIndex(const MachineInstr* instr) const { - Mi2IndexMap::const_iterator it = mi2iMap_.find(instr); - assert(it != mi2iMap_.end() && "Invalid instruction!"); - return it->second; - } - - /// getInstructionFromIndex - given an index in any slot of an - /// instruction return a pointer the instruction - MachineInstr* getInstructionFromIndex(LiveIndex index) const { - // convert index to vector index - unsigned i = index.getVecIndex(); - assert(i < i2miMap_.size() && - "index does not correspond to an instruction"); - return i2miMap_[i]; - } - - /// hasGapBeforeInstr - Return true if the previous instruction slot, - /// i.e. Index - InstrSlots::NUM, is not occupied. - bool hasGapBeforeInstr(LiveIndex Index) { - Index = getBaseIndex(getPrevIndex(Index)); - return getInstructionFromIndex(Index) == 0; - } - - /// hasGapAfterInstr - Return true if the successive instruction slot, - /// i.e. Index + InstrSlots::Num, is not occupied. - bool hasGapAfterInstr(LiveIndex Index) { - Index = getBaseIndex(getNextIndex(Index)); - return getInstructionFromIndex(Index) == 0; - } - - /// findGapBeforeInstr - Find an empty instruction slot before the - /// specified index. If "Furthest" is true, find one that's furthest - /// away from the index (but before any index that's occupied). - LiveIndex findGapBeforeInstr(LiveIndex Index, bool Furthest = false) { - Index = getBaseIndex(getPrevIndex(Index)); - if (getInstructionFromIndex(Index)) - return LiveIndex(); // No gap! - if (!Furthest) - return Index; - LiveIndex PrevIndex = getBaseIndex(getPrevIndex(Index)); - while (getInstructionFromIndex(Index)) { - Index = PrevIndex; - PrevIndex = getBaseIndex(getPrevIndex(Index)); - } - return Index; - } - - /// InsertMachineInstrInMaps - Insert the specified machine instruction - /// into the instruction index map at the given index. - void InsertMachineInstrInMaps(MachineInstr *MI, LiveIndex Index) { - i2miMap_[Index.getVecIndex()] = MI; - Mi2IndexMap::iterator it = mi2iMap_.find(MI); - assert(it == mi2iMap_.end() && "Already in map!"); - mi2iMap_[MI] = Index; + return (unsigned)(IntervalPercentage * indexes_->getFunctionSize()); } /// conflictsWithPhysRegDef - Returns true if the specified register @@ -288,19 +126,7 @@ bool CheckUse, SmallPtrSet &JoinedCopies); - /// findLiveInMBBs - Given a live range, if the value of the range - /// is live in any MBB returns true as well as the list of basic blocks - /// in which the value is live. - bool findLiveInMBBs(LiveIndex Start, LiveIndex End, - SmallVectorImpl &MBBs) const; - - /// findReachableMBBs - Return a list MBB that can be reached via any - /// branch or fallthroughs. Return true if the list is not empty. - bool findReachableMBBs(LiveIndex Start, LiveIndex End, - SmallVectorImpl &MBBs) const; - // Interval creation - LiveInterval &getOrCreateInterval(unsigned reg) { Reg2IntervalMap::iterator I = r2iMap_.find(reg); if (I == r2iMap_.end()) @@ -325,36 +151,75 @@ r2iMap_.erase(I); } + SlotIndex getZeroIndex() const { + return indexes_->getZeroIndex(); + } + + SlotIndex getInvalidIndex() const { + return indexes_->getInvalidIndex(); + } + /// isNotInMIMap - returns true if the specified machine instr has been /// removed or was never entered in the map. - bool isNotInMIMap(MachineInstr* instr) const { - return !mi2iMap_.count(instr); + bool isNotInMIMap(const MachineInstr* Instr) const { + return !indexes_->hasIndex(Instr); + } + + /// Returns the base index of the given instruction. + SlotIndex getInstructionIndex(const MachineInstr *instr) const { + return indexes_->getInstructionIndex(instr); + } + + /// Returns the instruction associated with the given index. + MachineInstr* getInstructionFromIndex(SlotIndex index) const { + return indexes_->getInstructionFromIndex(index); + } + + /// Return the first index in the given basic block. + SlotIndex getMBBStartIdx(const MachineBasicBlock *mbb) const { + return indexes_->getMBBStartIdx(mbb); + } + + /// Return the last index in the given basic block. + SlotIndex getMBBEndIdx(const MachineBasicBlock *mbb) const { + return indexes_->getMBBEndIdx(mbb); + } + + MachineBasicBlock* getMBBFromIndex(SlotIndex index) const { + return indexes_->getMBBFromIndex(index); + } + + bool hasGapBeforeInstr(SlotIndex index) { + return indexes_->hasGapBeforeInstr(index); + } + + bool hasGapAfterInstr(SlotIndex index) { + return indexes_->hasGapAfterInstr(index); + } + + SlotIndex findGapBeforeInstr(SlotIndex index, bool furthest = false) { + return indexes_->findGapBeforeInstr(index, furthest); + } + + void InsertMachineInstrInMaps(MachineInstr *MI, SlotIndex Index) { + indexes_->insertMachineInstrInMaps(MI, Index); } - /// RemoveMachineInstrFromMaps - This marks the specified machine instr as - /// deleted. void RemoveMachineInstrFromMaps(MachineInstr *MI) { - // remove index -> MachineInstr and - // MachineInstr -> index mappings - Mi2IndexMap::iterator mi2i = mi2iMap_.find(MI); - if (mi2i != mi2iMap_.end()) { - i2miMap_[mi2i->second.index/InstrSlots::NUM] = 0; - mi2iMap_.erase(mi2i); - } + indexes_->removeMachineInstrFromMaps(MI); } - /// ReplaceMachineInstrInMaps - Replacing a machine instr with a new one in - /// maps used by register allocator. void ReplaceMachineInstrInMaps(MachineInstr *MI, MachineInstr *NewMI) { - Mi2IndexMap::iterator mi2i = mi2iMap_.find(MI); - if (mi2i == mi2iMap_.end()) - return; - i2miMap_[mi2i->second.index/InstrSlots::NUM] = NewMI; - Mi2IndexMap::iterator it = mi2iMap_.find(MI); - assert(it != mi2iMap_.end() && "Invalid instruction!"); - LiveIndex Index = it->second; - mi2iMap_.erase(it); - mi2iMap_[NewMI] = Index; + indexes_->replaceMachineInstrInMaps(MI, NewMI); + } + + bool findLiveInMBBs(SlotIndex Start, SlotIndex End, + SmallVectorImpl &MBBs) const { + return indexes_->findLiveInMBBs(Start, End, MBBs); + } + + void renumber() { + indexes_->renumber(); } BumpPtrAllocator& getVNInfoAllocator() { return VNInfoAllocator; } @@ -417,13 +282,6 @@ /// marker to implicit_def defs and their uses. void processImplicitDefs(); - /// computeNumbering - Compute the index numbering. - void computeNumbering(); - - /// scaleNumbering - Rescale interval numbers to introduce gaps for new - /// instructions - void scaleNumbering(int factor); - /// intervalIsInOneMBB - Returns true if the specified interval is entirely /// within a single basic block. bool intervalIsInOneMBB(const LiveInterval &li) const; @@ -443,14 +301,14 @@ /// handleVirtualRegisterDef) void handleRegisterDef(MachineBasicBlock *MBB, MachineBasicBlock::iterator MI, - LiveIndex MIIdx, + SlotIndex MIIdx, MachineOperand& MO, unsigned MOIdx); /// handleVirtualRegisterDef - update intervals for a virtual /// register def void handleVirtualRegisterDef(MachineBasicBlock *MBB, MachineBasicBlock::iterator MI, - LiveIndex MIIdx, MachineOperand& MO, + SlotIndex MIIdx, MachineOperand& MO, unsigned MOIdx, LiveInterval& interval); @@ -458,13 +316,13 @@ /// def. void handlePhysicalRegisterDef(MachineBasicBlock* mbb, MachineBasicBlock::iterator mi, - LiveIndex MIIdx, MachineOperand& MO, + SlotIndex MIIdx, MachineOperand& MO, LiveInterval &interval, MachineInstr *CopyMI); /// handleLiveInRegister - Create interval for a livein register. void handleLiveInRegister(MachineBasicBlock* mbb, - LiveIndex MIIdx, + SlotIndex MIIdx, LiveInterval &interval, bool isAlias = false); /// getReMatImplicitUse - If the remat definition MI has one (for now, we @@ -477,7 +335,7 @@ /// which reaches the given instruction also reaches the specified use /// index. bool isValNoAvailableAt(const LiveInterval &li, MachineInstr *MI, - LiveIndex UseIdx) const; + SlotIndex UseIdx) const; /// isReMaterializable - Returns true if the definition MI of the specified /// val# of the specified interval is re-materializable. Also returns true @@ -492,7 +350,7 @@ /// MI. If it is successul, MI is updated with the newly created MI and /// returns true. bool tryFoldMemoryOperand(MachineInstr* &MI, VirtRegMap &vrm, - MachineInstr *DefMI, LiveIndex InstrIdx, + MachineInstr *DefMI, SlotIndex InstrIdx, SmallVector &Ops, bool isSS, int FrameIndex, unsigned Reg); @@ -506,7 +364,7 @@ /// VNInfo that's after the specified index but is within the basic block. bool anyKillInMBBAfterIdx(const LiveInterval &li, const VNInfo *VNI, MachineBasicBlock *MBB, - LiveIndex Idx) const; + SlotIndex Idx) const; /// hasAllocatableSuperReg - Return true if the specified physical register /// has any super register that's allocatable. @@ -514,17 +372,17 @@ /// SRInfo - Spill / restore info. struct SRInfo { - LiveIndex index; + SlotIndex index; unsigned vreg; bool canFold; - SRInfo(LiveIndex i, unsigned vr, bool f) + SRInfo(SlotIndex i, unsigned vr, bool f) : index(i), vreg(vr), canFold(f) {} }; - bool alsoFoldARestore(int Id, LiveIndex index, unsigned vr, + bool alsoFoldARestore(int Id, SlotIndex index, unsigned vr, BitVector &RestoreMBBs, DenseMap >&RestoreIdxes); - void eraseRestoreInfo(int Id, LiveIndex index, unsigned vr, + void eraseRestoreInfo(int Id, SlotIndex index, unsigned vr, BitVector &RestoreMBBs, DenseMap >&RestoreIdxes); @@ -543,7 +401,7 @@ /// functions for addIntervalsForSpills to rewrite uses / defs for the given /// live range. bool rewriteInstructionForSpills(const LiveInterval &li, const VNInfo *VNI, - bool TrySplit, LiveIndex index, LiveIndex end, + bool TrySplit, SlotIndex index, SlotIndex end, MachineInstr *MI, MachineInstr *OrigDefMI, MachineInstr *DefMI, unsigned Slot, int LdSlot, bool isLoad, bool isLoadSS, bool DefIsReMat, bool CanDelete, Modified: llvm/trunk/include/llvm/CodeGen/LiveStackAnalysis.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveStackAnalysis.h?rev=85979&r1=85978&r2=85979&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/LiveStackAnalysis.h (original) +++ llvm/trunk/include/llvm/CodeGen/LiveStackAnalysis.h Tue Nov 3 17:52:08 2009 @@ -48,8 +48,6 @@ iterator begin() { return S2IMap.begin(); } iterator end() { return S2IMap.end(); } - void scaleNumbering(int factor); - unsigned getNumIntervals() const { return (unsigned)S2IMap.size(); } LiveInterval &getOrCreateInterval(int Slot, const TargetRegisterClass *RC) { Added: llvm/trunk/include/llvm/CodeGen/ProcessImplicitDefs.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/ProcessImplicitDefs.h?rev=85979&view=auto ============================================================================== --- llvm/trunk/include/llvm/CodeGen/ProcessImplicitDefs.h (added) +++ llvm/trunk/include/llvm/CodeGen/ProcessImplicitDefs.h Tue Nov 3 17:52:08 2009 @@ -0,0 +1,41 @@ +//===-------------- llvm/CodeGen/ProcessImplicitDefs.h ----------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + + +#ifndef LLVM_CODEGEN_PROCESSIMPLICITDEFS_H +#define LLVM_CODEGEN_PROCESSIMPLICITDEFS_H + +#include "llvm/CodeGen/MachineFunctionPass.h" + +namespace llvm { + + class MachineInstr; + class TargetInstrInfo; + + /// Process IMPLICIT_DEF instructions and make sure there is one implicit_def + /// for each use. Add isUndef marker to implicit_def defs and their uses. + class ProcessImplicitDefs : public MachineFunctionPass { + private: + + bool CanTurnIntoImplicitDef(MachineInstr *MI, unsigned Reg, + unsigned OpIdx, const TargetInstrInfo *tii_); + + public: + static char ID; + + ProcessImplicitDefs() : MachineFunctionPass(&ID) {} + + virtual void getAnalysisUsage(AnalysisUsage &au) const; + + virtual bool runOnMachineFunction(MachineFunction &fn); + }; + +} + +#endif // LLVM_CODEGEN_PROCESSIMPLICITDEFS_H Added: llvm/trunk/include/llvm/CodeGen/SlotIndexes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SlotIndexes.h?rev=85979&view=auto ============================================================================== --- llvm/trunk/include/llvm/CodeGen/SlotIndexes.h (added) +++ llvm/trunk/include/llvm/CodeGen/SlotIndexes.h Tue Nov 3 17:52:08 2009 @@ -0,0 +1,775 @@ +//===- llvm/CodeGen/SlotIndexes.h - Slot indexes representation -*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file implements SlotIndex and related classes. The purpuse of SlotIndex +// is to describe a position at which a register can become live, or cease to +// be live. +// +// SlotIndex is mostly a proxy for entries of the SlotIndexList, a class which +// is held is LiveIntervals and provides the real numbering. This allows +// LiveIntervals to perform largely transparent renumbering. The SlotIndex +// class does hold a PHI bit, which determines whether the index relates to a +// PHI use or def point, or an actual instruction. See the SlotIndex class +// description for futher information. +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CODEGEN_SLOTINDEXES_H +#define LLVM_CODEGEN_SLOTINDEXES_H + +#include "llvm/ADT/PointerIntPair.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/CodeGen/MachineBasicBlock.h" +#include "llvm/CodeGen/MachineFunctionPass.h" +#include "llvm/CodeGen/MachineInstr.h" +#include "llvm/Support/Allocator.h" + +namespace llvm { + + /// This class represents an entry in the slot index list held in the + /// SlotIndexes pass. It should not be used directly. See the + /// SlotIndex & SlotIndexes classes for the public interface to this + /// information. + class IndexListEntry { + friend class SlotIndex; + friend class SlotIndexes; + + private: + + IndexListEntry *next, *prev; + MachineInstr *mi; + unsigned index; + + public: + + IndexListEntry(MachineInstr *mi, unsigned index) + : mi(mi), index(index) {} + + MachineInstr* getInstr() const { return mi; } + void setInstr(MachineInstr *mi) { this->mi = mi; } + + unsigned getIndex() const { return index; } + void setIndex(unsigned index) { this->index = index; } + + IndexListEntry* getNext() { return next; } + const IndexListEntry* getNext() const { return next; } + void setNext(IndexListEntry *next) { this->next = next; } + + IndexListEntry* getPrev() { return prev; } + const IndexListEntry* getPrev() const { return prev; } + void setPrev(IndexListEntry *prev) { this->prev = prev; } + + /* + bool operator==(const IndexListEntry &other) const { + assert(getIndex() != other.getIndex() || this == &other && + "Non-equal index list entries compare equal."); + return getIndex() == other.getIndex(); + } + + bool operator!=(const IndexListEntry &other) const { + return getIndex() != other.getIndex(); + } + + bool operator<(const IndexListEntry &other) const { + return getIndex() < other.getIndex(); + } + + bool operator<=(const IndexListEntry &other) const { + return getIndex() <= other.getIndex(); + } + + bool operator>(const IndexListEntry &other) const { + return getIndex() > other.getIndex(); + } + + bool operator>=(const IndexListEntry &other) const { + return getIndex() >= other.getIndex(); + } + + int distance(const IndexListEntry &other) const { + return other.getIndex() - getIndex(); + } + */ + }; + + // Specialize PointerLikeTypeTraits for IndexListEntry. + template <> + class PointerLikeTypeTraits { + public: + static inline void* getAsVoidPointer(IndexListEntry *p) { + return p; + } + static inline IndexListEntry* getFromVoidPointer(void *p) { + return static_cast(p); + } + enum { NumLowBitsAvailable = 3 }; + }; + + /// SlotIndex - An opaque wrapper around machine indexes. + class SlotIndex { + friend class SlotIndexes; + friend class DenseMapInfo; + + private: + + // FIXME: Is there any way to statically allocate these things and have + // them 8-byte aligned? + static std::auto_ptr emptyKeyPtr, tombstoneKeyPtr; + static const unsigned PHI_BIT = 1 << 2; + + PointerIntPair lie; + + SlotIndex(IndexListEntry *entry, unsigned phiAndSlot) + : lie(entry, phiAndSlot) { + assert(entry != 0 && "Attempt to construct index with 0 pointer."); + } + + IndexListEntry& entry() const { + assert(lie.getPointer() != 0 && "Use of invalid index."); + return *lie.getPointer(); + } + + int getIndex() const { + return entry().getIndex() | getSlot(); + } + + static inline unsigned getHashValue(const SlotIndex &v) { + IndexListEntry *ptrVal = &v.entry(); + return (unsigned((intptr_t)ptrVal) >> 4) ^ + (unsigned((intptr_t)ptrVal) >> 9); + } + + public: + + // FIXME: Ugh. This is public because LiveIntervalAnalysis is still using it + // for some spill weight stuff. Fix that, then make this private. + enum Slot { LOAD, USE, DEF, STORE, NUM }; + + static inline SlotIndex getEmptyKey() { + // FIXME: How do we guarantee these numbers don't get allocated to + // legit indexes? + if (emptyKeyPtr.get() == 0) + emptyKeyPtr.reset(new IndexListEntry(0, ~0U & ~3U)); + + return SlotIndex(emptyKeyPtr.get(), 0); + } + + static inline SlotIndex getTombstoneKey() { + // FIXME: How do we guarantee these numbers don't get allocated to + // legit indexes? + if (tombstoneKeyPtr.get() == 0) + tombstoneKeyPtr.reset(new IndexListEntry(0, ~0U & ~7U)); + + return SlotIndex(tombstoneKeyPtr.get(), 0); + } + + /// Construct an invalid index. + SlotIndex() : lie(&getEmptyKey().entry(), 0) {} + + // Construct a new slot index from the given one, set the phi flag on the + // new index to the value of the phi parameter. + SlotIndex(const SlotIndex &li, bool phi) + : lie(&li.entry(), phi ? PHI_BIT & li.getSlot() : (unsigned)li.getSlot()){ + assert(lie.getPointer() != 0 && + "Attempt to construct index with 0 pointer."); + } + + // Construct a new slot index from the given one, set the phi flag on the + // new index to the value of the phi parameter, and the slot to the new slot. + SlotIndex(const SlotIndex &li, bool phi, Slot s) + : lie(&li.entry(), phi ? PHI_BIT & s : (unsigned)s) { + assert(lie.getPointer() != 0 && + "Attempt to construct index with 0 pointer."); + } + + /// Returns true if this is a valid index. Invalid indicies do + /// not point into an index table, and cannot be compared. + bool isValid() const { + return (lie.getPointer() != 0) && (lie.getPointer()->getIndex() != 0); + } + + /// Print this index to the given raw_ostream. + void print(raw_ostream &os) const; + + /// Dump this index to stderr. + void dump() const; + + /// Compare two SlotIndex objects for equality. + bool operator==(SlotIndex other) const { + return getIndex() == other.getIndex(); + } + /// Compare two SlotIndex objects for inequality. + bool operator!=(SlotIndex other) const { + return getIndex() != other.getIndex(); + } + + /// Compare two SlotIndex objects. Return true if the first index + /// is strictly lower than the second. + bool operator<(SlotIndex other) const { + return getIndex() < other.getIndex(); + } + /// Compare two SlotIndex objects. Return true if the first index + /// is lower than, or equal to, the second. + bool operator<=(SlotIndex other) const { + return getIndex() <= other.getIndex(); + } + + /// Compare two SlotIndex objects. Return true if the first index + /// is greater than the second. + bool operator>(SlotIndex other) const { + return getIndex() > other.getIndex(); + } + + /// Compare two SlotIndex objects. Return true if the first index + /// is greater than, or equal to, the second. + bool operator>=(SlotIndex other) const { + return getIndex() >= other.getIndex(); + } + + /// Return the distance from this index to the given one. + int distance(SlotIndex other) const { + return other.getIndex() - getIndex(); + } + + /// Returns the slot for this SlotIndex. + Slot getSlot() const { + return static_cast(lie.getInt() & ~PHI_BIT); + } + + /// Returns the state of the PHI bit. + bool isPHI() const { + return lie.getInt() & PHI_BIT; + } + + /// Returns the base index for associated with this index. The base index + /// is the one associated with the LOAD slot for the instruction pointed to + /// by this index. + SlotIndex getBaseIndex() const { + return getLoadIndex(); + } + + /// Returns the boundary index for associated with this index. The boundary + /// index is the one associated with the LOAD slot for the instruction + /// pointed to by this index. + SlotIndex getBoundaryIndex() const { + return getStoreIndex(); + } + + /// Returns the index of the LOAD slot for the instruction pointed to by + /// this index. + SlotIndex getLoadIndex() const { + return SlotIndex(&entry(), SlotIndex::LOAD); + } + + /// Returns the index of the USE slot for the instruction pointed to by + /// this index. + SlotIndex getUseIndex() const { + return SlotIndex(&entry(), SlotIndex::USE); + } + + /// Returns the index of the DEF slot for the instruction pointed to by + /// this index. + SlotIndex getDefIndex() const { + return SlotIndex(&entry(), SlotIndex::DEF); + } + + /// Returns the index of the STORE slot for the instruction pointed to by + /// this index. + SlotIndex getStoreIndex() const { + return SlotIndex(&entry(), SlotIndex::STORE); + } + + /// Returns the next slot in the index list. This could be either the + /// next slot for the instruction pointed to by this index or, if this + /// index is a STORE, the first slot for the next instruction. + /// WARNING: This method is considerably more expensive than the methods + /// that return specific slots (getUseIndex(), etc). If you can - please + /// use one of those methods. + SlotIndex getNextSlot() const { + Slot s = getSlot(); + if (s == SlotIndex::STORE) { + return SlotIndex(entry().getNext(), SlotIndex::LOAD); + } + return SlotIndex(&entry(), s + 1); + } + + /// Returns the next index. This is the index corresponding to the this + /// index's slot, but for the next instruction. + SlotIndex getNextIndex() const { + return SlotIndex(entry().getNext(), getSlot()); + } + + /// Returns the previous slot in the index list. This could be either the + /// previous slot for the instruction pointed to by this index or, if this + /// index is a LOAD, the last slot for the previous instruction. + /// WARNING: This method is considerably more expensive than the methods + /// that return specific slots (getUseIndex(), etc). If you can - please + /// use one of those methods. + SlotIndex getPrevSlot() const { + Slot s = getSlot(); + if (s == SlotIndex::LOAD) { + return SlotIndex(entry().getPrev(), SlotIndex::STORE); + } + return SlotIndex(&entry(), s - 1); + } + + /// Returns the previous index. This is the index corresponding to this + /// index's slot, but for the previous instruction. + SlotIndex getPrevIndex() const { + return SlotIndex(entry().getPrev(), getSlot()); + } + + }; + + /// DenseMapInfo specialization for SlotIndex. + template <> + struct DenseMapInfo { + static inline SlotIndex getEmptyKey() { + return SlotIndex::getEmptyKey(); + } + static inline SlotIndex getTombstoneKey() { + return SlotIndex::getTombstoneKey(); + } + static inline unsigned getHashValue(const SlotIndex &v) { + return SlotIndex::getHashValue(v); + } + static inline bool isEqual(const SlotIndex &LHS, const SlotIndex &RHS) { + return (LHS == RHS); + } + static inline bool isPod() { return false; } + }; + + inline raw_ostream& operator<<(raw_ostream &os, SlotIndex li) { + li.print(os); + return os; + } + + typedef std::pair IdxMBBPair; + + inline bool operator<(SlotIndex V, const IdxMBBPair &IM) { + return V < IM.first; + } + + inline bool operator<(const IdxMBBPair &IM, SlotIndex V) { + return IM.first < V; + } + + struct Idx2MBBCompare { + bool operator()(const IdxMBBPair &LHS, const IdxMBBPair &RHS) const { + return LHS.first < RHS.first; + } + }; + + /// SlotIndexes pass. + /// + /// This pass assigns indexes to each instruction. + class SlotIndexes : public MachineFunctionPass { + private: + + MachineFunction *mf; + IndexListEntry *indexListHead; + unsigned functionSize; + + typedef DenseMap Mi2IndexMap; + Mi2IndexMap mi2iMap; + + /// MBB2IdxMap - The indexes of the first and last instructions in the + /// specified basic block. + typedef DenseMap > MBB2IdxMap; + MBB2IdxMap mbb2IdxMap; + + /// Idx2MBBMap - Sorted list of pairs of index of first instruction + /// and MBB id. + std::vector idx2MBBMap; + + typedef DenseMap TerminatorGapsMap; + TerminatorGapsMap terminatorGaps; + + // IndexListEntry allocator. + BumpPtrAllocator ileAllocator; + + IndexListEntry* createEntry(MachineInstr *mi, unsigned index) { + IndexListEntry *entry = + static_cast( + ileAllocator.Allocate(sizeof(IndexListEntry), + alignof())); + + new (entry) IndexListEntry(mi, index); + + return entry; + } + + void initList() { + assert(indexListHead == 0 && "Zero entry non-null at initialisation."); + indexListHead = createEntry(0, ~0U); + indexListHead->setNext(0); + indexListHead->setPrev(indexListHead); + } + + void clearList() { + indexListHead = 0; + ileAllocator.Reset(); + } + + IndexListEntry* getTail() { + assert(indexListHead != 0 && "Call to getTail on uninitialized list."); + return indexListHead->getPrev(); + } + + const IndexListEntry* getTail() const { + assert(indexListHead != 0 && "Call to getTail on uninitialized list."); + return indexListHead->getPrev(); + } + + // Returns true if the index list is empty. + bool empty() const { return (indexListHead == getTail()); } + + IndexListEntry* front() { + assert(!empty() && "front() called on empty index list."); + return indexListHead; + } + + const IndexListEntry* front() const { + assert(!empty() && "front() called on empty index list."); + return indexListHead; + } + + IndexListEntry* back() { + assert(!empty() && "back() called on empty index list."); + return getTail()->getPrev(); + } + + const IndexListEntry* back() const { + assert(!empty() && "back() called on empty index list."); + return getTail()->getPrev(); + } + + /// Insert a new entry before itr. + void insert(IndexListEntry *itr, IndexListEntry *val) { + assert(itr != 0 && "itr should not be null."); + IndexListEntry *prev = itr->getPrev(); + val->setNext(itr); + val->setPrev(prev); + + if (itr != indexListHead) { + prev->setNext(val); + } + else { + indexListHead = val; + } + itr->setPrev(val); + } + + /// Push a new entry on to the end of the list. + void push_back(IndexListEntry *val) { + insert(getTail(), val); + } + + public: + static char ID; + + SlotIndexes() : MachineFunctionPass(&ID), indexListHead(0) {} + + virtual void getAnalysisUsage(AnalysisUsage &au) const; + virtual void releaseMemory(); + + virtual bool runOnMachineFunction(MachineFunction &fn); + + /// Dump the indexes. + void dump() const; + + /// Renumber the index list, providing space for new instructions. + void renumber(); + + /// Returns the zero index for this analysis. + SlotIndex getZeroIndex() { + assert(front()->getIndex() == 0 && "First index is not 0?"); + return SlotIndex(front(), 0); + } + + /// Returns the invalid index marker for this analysis. + SlotIndex getInvalidIndex() { + return getZeroIndex(); + } + + /// Returns the distance between the highest and lowest indexes allocated + /// so far. + unsigned getIndexesLength() const { + assert(front()->getIndex() == 0 && + "Initial index isn't zero?"); + + return back()->getIndex(); + } + + /// Returns the number of instructions in the function. + unsigned getFunctionSize() const { + return functionSize; + } + + /// Returns true if the given machine instr is mapped to an index, + /// otherwise returns false. + bool hasIndex(const MachineInstr *instr) const { + return (mi2iMap.find(instr) != mi2iMap.end()); + } + + /// Returns the base index for the given instruction. + SlotIndex getInstructionIndex(const MachineInstr *instr) const { + Mi2IndexMap::const_iterator itr = mi2iMap.find(instr); + assert(itr != mi2iMap.end() && "Instruction not found in maps."); + return itr->second; + } + + /// Returns the instruction for the given index, or null if the given + /// index has no instruction associated with it. + MachineInstr* getInstructionFromIndex(SlotIndex index) const { + return index.entry().getInstr(); + } + + /// Returns the next non-null index. + SlotIndex getNextNonNullIndex(SlotIndex index) { + SlotIndex nextNonNull = index.getNextIndex(); + + while (&nextNonNull.entry() != getTail() && + getInstructionFromIndex(nextNonNull) == 0) { + nextNonNull = nextNonNull.getNextIndex(); + } + + return nextNonNull; + } + + /// Returns the first index in the given basic block. + SlotIndex getMBBStartIdx(const MachineBasicBlock *mbb) const { + MBB2IdxMap::const_iterator itr = mbb2IdxMap.find(mbb); + assert(itr != mbb2IdxMap.end() && "MBB not found in maps."); + return itr->second.first; + } + + /// Returns the last index in the given basic block. + SlotIndex getMBBEndIdx(const MachineBasicBlock *mbb) const { + MBB2IdxMap::const_iterator itr = mbb2IdxMap.find(mbb); + assert(itr != mbb2IdxMap.end() && "MBB not found in maps."); + return itr->second.second; + } + + /// Returns the terminator gap for the given index. + SlotIndex getTerminatorGap(const MachineBasicBlock *mbb) { + TerminatorGapsMap::iterator itr = terminatorGaps.find(mbb); + assert(itr != terminatorGaps.end() && + "All MBBs should have terminator gaps in their indexes."); + return itr->second; + } + + /// Returns the basic block which the given index falls in. + MachineBasicBlock* getMBBFromIndex(SlotIndex index) const { + std::vector::const_iterator I = + std::lower_bound(idx2MBBMap.begin(), idx2MBBMap.end(), index); + // Take the pair containing the index + std::vector::const_iterator J = + ((I != idx2MBBMap.end() && I->first > index) || + (I == idx2MBBMap.end() && idx2MBBMap.size()>0)) ? (I-1): I; + + assert(J != idx2MBBMap.end() && J->first <= index && + index <= getMBBEndIdx(J->second) && + "index does not correspond to an MBB"); + return J->second; + } + + bool findLiveInMBBs(SlotIndex start, SlotIndex end, + SmallVectorImpl &mbbs) const { + std::vector::const_iterator itr = + std::lower_bound(idx2MBBMap.begin(), idx2MBBMap.end(), start); + bool resVal = false; + + while (itr != idx2MBBMap.end()) { + if (itr->first >= end) + break; + mbbs.push_back(itr->second); + resVal = true; + ++itr; + } + return resVal; + } + + /// Return a list of MBBs that can be reach via any branches or + /// fall-throughs. + bool findReachableMBBs(SlotIndex start, SlotIndex end, + SmallVectorImpl &mbbs) const { + std::vector::const_iterator itr = + std::lower_bound(idx2MBBMap.begin(), idx2MBBMap.end(), start); + + bool resVal = false; + while (itr != idx2MBBMap.end()) { + if (itr->first > end) + break; + MachineBasicBlock *mbb = itr->second; + if (getMBBEndIdx(mbb) > end) + break; + for (MachineBasicBlock::succ_iterator si = mbb->succ_begin(), + se = mbb->succ_end(); si != se; ++si) + mbbs.push_back(*si); + resVal = true; + ++itr; + } + return resVal; + } + + /// Returns the MBB covering the given range, or null if the range covers + /// more than one basic block. + MachineBasicBlock* getMBBCoveringRange(SlotIndex start, SlotIndex end) const { + + assert(start < end && "Backwards ranges not allowed."); + + std::vector::const_iterator itr = + std::lower_bound(idx2MBBMap.begin(), idx2MBBMap.end(), start); + + if (itr == idx2MBBMap.end()) { + itr = prior(itr); + return itr->second; + } + + // Check that we don't cross the boundary into this block. + if (itr->first < end) + return 0; + + itr = prior(itr); + + if (itr->first <= start) + return itr->second; + + return 0; + } + + /// Returns true if there is a gap in the numbering before the given index. + bool hasGapBeforeInstr(SlotIndex index) { + index = index.getBaseIndex(); + SlotIndex prevIndex = index.getPrevIndex(); + + if (prevIndex == getZeroIndex()) + return false; + + if (getInstructionFromIndex(prevIndex) == 0) + return true; + + if (prevIndex.distance(index) >= 2 * SlotIndex::NUM) + return true; + + return false; + } + + /// Returns true if there is a gap in the numbering after the given index. + bool hasGapAfterInstr(SlotIndex index) const { + // Not implemented yet. + assert(false && + "SlotIndexes::hasGapAfterInstr(SlotIndex) not implemented yet."); + return false; + } + + /// findGapBeforeInstr - Find an empty instruction slot before the + /// specified index. If "Furthest" is true, find one that's furthest + /// away from the index (but before any index that's occupied). + // FIXME: This whole method should go away in future. It should + // always be possible to insert code between existing indices. + SlotIndex findGapBeforeInstr(SlotIndex index, bool furthest = false) { + if (index == getZeroIndex()) + return getInvalidIndex(); + + index = index.getBaseIndex(); + SlotIndex prevIndex = index.getPrevIndex(); + + if (prevIndex == getZeroIndex()) + return getInvalidIndex(); + + // Try to reuse existing index objects with null-instrs. + if (getInstructionFromIndex(prevIndex) == 0) { + if (furthest) { + while (getInstructionFromIndex(prevIndex) == 0 && + prevIndex != getZeroIndex()) { + prevIndex = prevIndex.getPrevIndex(); + } + + prevIndex = prevIndex.getNextIndex(); + } + + assert(getInstructionFromIndex(prevIndex) == 0 && "Index list is broken."); + + return prevIndex; + } + + int dist = prevIndex.distance(index); + + // Double check that the spacing between this instruction and + // the last is sane. + assert(dist >= SlotIndex::NUM && + "Distance between indexes too small."); + + // If there's no gap return an invalid index. + if (dist < 2*SlotIndex::NUM) { + return getInvalidIndex(); + } + + // Otherwise insert new index entries into the list using the + // gap in the numbering. + IndexListEntry *newEntry = + createEntry(0, prevIndex.entry().getIndex() + SlotIndex::NUM); + + insert(&index.entry(), newEntry); + + // And return a pointer to the entry at the start of the gap. + return index.getPrevIndex(); + } + + /// Insert the given machine instruction into the mapping at the given + /// index. + void insertMachineInstrInMaps(MachineInstr *mi, SlotIndex index) { + index = index.getBaseIndex(); + IndexListEntry *miEntry = &index.entry(); + assert(miEntry->getInstr() == 0 && "Index already in use."); + miEntry->setInstr(mi); + + assert(mi2iMap.find(mi) == mi2iMap.end() && + "MachineInstr already has an index."); + + mi2iMap.insert(std::make_pair(mi, index)); + } + + /// Remove the given machine instruction from the mapping. + void removeMachineInstrFromMaps(MachineInstr *mi) { + // remove index -> MachineInstr and + // MachineInstr -> index mappings + Mi2IndexMap::iterator mi2iItr = mi2iMap.find(mi); + if (mi2iItr != mi2iMap.end()) { + IndexListEntry *miEntry(&mi2iItr->second.entry()); + assert(miEntry->getInstr() == mi && "Instruction indexes broken."); + // FIXME: Eventually we want to actually delete these indexes. + miEntry->setInstr(0); + mi2iMap.erase(mi2iItr); + } + } + + /// ReplaceMachineInstrInMaps - Replacing a machine instr with a new one in + /// maps used by register allocator. + void replaceMachineInstrInMaps(MachineInstr *mi, MachineInstr *newMI) { + Mi2IndexMap::iterator mi2iItr = mi2iMap.find(mi); + if (mi2iItr == mi2iMap.end()) + return; + SlotIndex replaceBaseIndex = mi2iItr->second; + IndexListEntry *miEntry(&replaceBaseIndex.entry()); + assert(miEntry->getInstr() == mi && + "Mismatched instruction in index tables."); + miEntry->setInstr(newMI); + mi2iMap.erase(mi2iItr); + mi2iMap.insert(std::make_pair(newMI, replaceBaseIndex)); + } + + }; + + +} + +#endif // LLVM_CODEGEN_LIVEINDEX_H Modified: llvm/trunk/lib/CodeGen/LiveInterval.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveInterval.cpp?rev=85979&r1=85978&r2=85979&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveInterval.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveInterval.cpp Tue Nov 3 17:52:08 2009 @@ -19,6 +19,7 @@ //===----------------------------------------------------------------------===// #include "llvm/CodeGen/LiveInterval.h" +#include "llvm/CodeGen/LiveIntervalAnalysis.h" #include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallSet.h" @@ -28,11 +29,6 @@ #include using namespace llvm; -// Print a LiveIndex to a raw_ostream. -void LiveIndex::print(raw_ostream &os) const { - os << (index & ~PHI_BIT); -} - // An example for liveAt(): // // this = [1,4), liveAt(0) will return false. The instruction defining this @@ -40,7 +36,7 @@ // variable it represents. This is because slot 1 is used (def slot) and spans // up to slot 3 (store slot). // -bool LiveInterval::liveAt(LiveIndex I) const { +bool LiveInterval::liveAt(SlotIndex I) const { Ranges::const_iterator r = std::upper_bound(ranges.begin(), ranges.end(), I); if (r == ranges.begin()) @@ -53,7 +49,7 @@ // liveBeforeAndAt - Check if the interval is live at the index and the index // just before it. If index is liveAt, check if it starts a new live range. // If it does, then check if the previous live range ends at index-1. -bool LiveInterval::liveBeforeAndAt(LiveIndex I) const { +bool LiveInterval::liveBeforeAndAt(SlotIndex I) const { Ranges::const_iterator r = std::upper_bound(ranges.begin(), ranges.end(), I); if (r == ranges.begin()) @@ -131,7 +127,7 @@ /// overlaps - Return true if the live interval overlaps a range specified /// by [Start, End). -bool LiveInterval::overlaps(LiveIndex Start, LiveIndex End) const { +bool LiveInterval::overlaps(SlotIndex Start, SlotIndex End) const { assert(Start < End && "Invalid range"); const_iterator I = begin(); const_iterator E = end(); @@ -149,10 +145,10 @@ /// specified by I to end at the specified endpoint. To do this, we should /// merge and eliminate all ranges that this will overlap with. The iterator is /// not invalidated. -void LiveInterval::extendIntervalEndTo(Ranges::iterator I, LiveIndex NewEnd) { +void LiveInterval::extendIntervalEndTo(Ranges::iterator I, SlotIndex NewEnd) { assert(I != ranges.end() && "Not a valid interval!"); VNInfo *ValNo = I->valno; - LiveIndex OldEnd = I->end; + SlotIndex OldEnd = I->end; // Search for the first interval that we can't merge with. Ranges::iterator MergeTo = next(I); @@ -167,7 +163,7 @@ ranges.erase(next(I), MergeTo); // Update kill info. - ValNo->removeKills(OldEnd, I->end.prevSlot_()); + ValNo->removeKills(OldEnd, I->end.getPrevSlot()); // If the newly formed range now touches the range after it and if they have // the same value number, merge the two ranges into one range. @@ -183,7 +179,7 @@ /// specified by I to start at the specified endpoint. To do this, we should /// merge and eliminate all ranges that this will overlap with. LiveInterval::Ranges::iterator -LiveInterval::extendIntervalStartTo(Ranges::iterator I, LiveIndex NewStart) { +LiveInterval::extendIntervalStartTo(Ranges::iterator I, SlotIndex NewStart) { assert(I != ranges.end() && "Not a valid interval!"); VNInfo *ValNo = I->valno; @@ -216,7 +212,7 @@ LiveInterval::iterator LiveInterval::addRangeFrom(LiveRange LR, iterator From) { - LiveIndex Start = LR.start, End = LR.end; + SlotIndex Start = LR.start, End = LR.end; iterator it = std::upper_bound(From, ranges.end(), Start); // If the inserted interval starts in the middle or right at the end of @@ -268,7 +264,7 @@ /// isInOneLiveRange - Return true if the range specified is entirely in /// a single LiveRange of the live interval. -bool LiveInterval::isInOneLiveRange(LiveIndex Start, LiveIndex End) { +bool LiveInterval::isInOneLiveRange(SlotIndex Start, SlotIndex End) { Ranges::iterator I = std::upper_bound(ranges.begin(), ranges.end(), Start); if (I == ranges.begin()) return false; @@ -279,7 +275,7 @@ /// removeRange - Remove the specified range from this interval. Note that /// the range must be in a single LiveRange in its entirety. -void LiveInterval::removeRange(LiveIndex Start, LiveIndex End, +void LiveInterval::removeRange(SlotIndex Start, SlotIndex End, bool RemoveDeadValNo) { // Find the LiveRange containing this span. Ranges::iterator I = std::upper_bound(ranges.begin(), ranges.end(), Start); @@ -331,7 +327,7 @@ } // Otherwise, we are splitting the LiveRange into two pieces. - LiveIndex OldEnd = I->end; + SlotIndex OldEnd = I->end; I->end = Start; // Trim the old interval. // Insert the new one. @@ -362,36 +358,11 @@ ValNo->setIsUnused(true); } } - -/// scaleNumbering - Renumber VNI and ranges to provide gaps for new -/// instructions. - -void LiveInterval::scaleNumbering(unsigned factor) { - // Scale ranges. - for (iterator RI = begin(), RE = end(); RI != RE; ++RI) { - RI->start = RI->start.scale(factor); - RI->end = RI->end.scale(factor); - } - - // Scale VNI info. - for (vni_iterator VNI = vni_begin(), VNIE = vni_end(); VNI != VNIE; ++VNI) { - VNInfo *vni = *VNI; - - if (vni->isDefAccurate()) - vni->def = vni->def.scale(factor); - - for (unsigned i = 0; i < vni->kills.size(); ++i) { - if (!vni->kills[i].isPHIIndex()) - vni->kills[i] = vni->kills[i].scale(factor); - } - } -} - /// getLiveRangeContaining - Return the live range that contains the /// specified index, or null if there is none. LiveInterval::const_iterator -LiveInterval::FindLiveRangeContaining(LiveIndex Idx) const { +LiveInterval::FindLiveRangeContaining(SlotIndex Idx) const { const_iterator It = std::upper_bound(begin(), end(), Idx); if (It != ranges.begin()) { --It; @@ -403,7 +374,7 @@ } LiveInterval::iterator -LiveInterval::FindLiveRangeContaining(LiveIndex Idx) { +LiveInterval::FindLiveRangeContaining(SlotIndex Idx) { iterator It = std::upper_bound(begin(), end(), Idx); if (It != begin()) { --It; @@ -416,7 +387,7 @@ /// findDefinedVNInfo - Find the VNInfo defined by the specified /// index (register interval). -VNInfo *LiveInterval::findDefinedVNInfoForRegInt(LiveIndex Idx) const { +VNInfo *LiveInterval::findDefinedVNInfoForRegInt(SlotIndex Idx) const { for (LiveInterval::const_vni_iterator i = vni_begin(), e = vni_end(); i != e; ++i) { if ((*i)->def == Idx) @@ -440,7 +411,8 @@ /// join - Join two live intervals (this, and other) together. This applies /// mappings to the value numbers in the LHS/RHS intervals as specified. If /// the intervals are not joinable, this aborts. -void LiveInterval::join(LiveInterval &Other, const int *LHSValNoAssignments, +void LiveInterval::join(LiveInterval &Other, + const int *LHSValNoAssignments, const int *RHSValNoAssignments, SmallVector &NewVNInfo, MachineRegisterInfo *MRI) { @@ -554,14 +526,15 @@ /// The LiveRanges in RHS are allowed to overlap with LiveRanges in the /// current interval, it will replace the value numbers of the overlaped /// live ranges with the specified value number. -void LiveInterval::MergeValueInAsValue(const LiveInterval &RHS, - const VNInfo *RHSValNo, VNInfo *LHSValNo) { +void LiveInterval::MergeValueInAsValue( + const LiveInterval &RHS, + const VNInfo *RHSValNo, VNInfo *LHSValNo) { SmallVector ReplacedValNos; iterator IP = begin(); for (const_iterator I = RHS.begin(), E = RHS.end(); I != E; ++I) { if (I->valno != RHSValNo) continue; - LiveIndex Start = I->start, End = I->end; + SlotIndex Start = I->start, End = I->end; IP = std::upper_bound(IP, end(), Start); // If the start of this range overlaps with an existing liverange, trim it. if (IP != begin() && IP[-1].end > Start) { @@ -621,7 +594,8 @@ /// MergeInClobberRanges - For any live ranges that are not defined in the /// current interval, but are defined in the Clobbers interval, mark them /// used with an unknown definition value. -void LiveInterval::MergeInClobberRanges(const LiveInterval &Clobbers, +void LiveInterval::MergeInClobberRanges(LiveIntervals &li_, + const LiveInterval &Clobbers, BumpPtrAllocator &VNInfoAllocator) { if (Clobbers.empty()) return; @@ -638,20 +612,20 @@ ClobberValNo = UnusedValNo; else { UnusedValNo = ClobberValNo = - getNextValue(LiveIndex(), 0, false, VNInfoAllocator); + getNextValue(li_.getInvalidIndex(), 0, false, VNInfoAllocator); ValNoMaps.insert(std::make_pair(I->valno, ClobberValNo)); } bool Done = false; - LiveIndex Start = I->start, End = I->end; + SlotIndex Start = I->start, End = I->end; // If a clobber range starts before an existing range and ends after // it, the clobber range will need to be split into multiple ranges. // Loop until the entire clobber range is handled. while (!Done) { Done = true; IP = std::upper_bound(IP, end(), Start); - LiveIndex SubRangeStart = Start; - LiveIndex SubRangeEnd = End; + SlotIndex SubRangeStart = Start; + SlotIndex SubRangeEnd = End; // If the start of this range overlaps with an existing liverange, trim it. if (IP != begin() && IP[-1].end > SubRangeStart) { @@ -687,13 +661,14 @@ } } -void LiveInterval::MergeInClobberRange(LiveIndex Start, - LiveIndex End, +void LiveInterval::MergeInClobberRange(LiveIntervals &li_, + SlotIndex Start, + SlotIndex End, BumpPtrAllocator &VNInfoAllocator) { // Find a value # to use for the clobber ranges. If there is already a value# // for unknown values, use it. VNInfo *ClobberValNo = - getNextValue(LiveIndex(), 0, false, VNInfoAllocator); + getNextValue(li_.getInvalidIndex(), 0, false, VNInfoAllocator); iterator IP = begin(); IP = std::upper_bound(IP, end(), Start); @@ -881,8 +856,6 @@ OS << "-("; for (unsigned j = 0; j != ee; ++j) { OS << vni->kills[j]; - if (vni->kills[j].isPHIIndex()) - OS << "*"; if (j != ee-1) OS << " "; } Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=85979&r1=85978&r2=85979&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Tue Nov 3 17:52:08 2009 @@ -28,6 +28,7 @@ #include "llvm/CodeGen/MachineMemOperand.h" #include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/CodeGen/Passes.h" +#include "llvm/CodeGen/ProcessImplicitDefs.h" #include "llvm/Target/TargetRegisterInfo.h" #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetMachine.h" @@ -80,6 +81,10 @@ } AU.addRequiredID(TwoAddressInstructionPassID); + AU.addPreserved(); + AU.addRequired(); + AU.addPreserved(); + AU.addRequiredTransitive(); MachineFunctionPass::getAnalysisUsage(AU); } @@ -89,12 +94,7 @@ E = r2iMap_.end(); I != E; ++I) delete I->second; - MBB2IdxMap.clear(); - Idx2MBBMap.clear(); - mi2iMap_.clear(); - i2miMap_.clear(); r2iMap_.clear(); - terminatorGaps.clear(); phiJoinCopies.clear(); // Release VNInfo memroy regions after all VNInfo objects are dtor'd. @@ -106,422 +106,6 @@ } } -static bool CanTurnIntoImplicitDef(MachineInstr *MI, unsigned Reg, - unsigned OpIdx, const TargetInstrInfo *tii_){ - unsigned SrcReg, DstReg, SrcSubReg, DstSubReg; - if (tii_->isMoveInstr(*MI, SrcReg, DstReg, SrcSubReg, DstSubReg) && - Reg == SrcReg) - return true; - - if (OpIdx == 2 && MI->getOpcode() == TargetInstrInfo::SUBREG_TO_REG) - return true; - if (OpIdx == 1 && MI->getOpcode() == TargetInstrInfo::EXTRACT_SUBREG) - return true; - return false; -} - -/// processImplicitDefs - Process IMPLICIT_DEF instructions and make sure -/// there is one implicit_def for each use. Add isUndef marker to -/// implicit_def defs and their uses. -void LiveIntervals::processImplicitDefs() { - SmallSet ImpDefRegs; - SmallVector ImpDefMIs; - MachineBasicBlock *Entry = mf_->begin(); - SmallPtrSet Visited; - for (df_ext_iterator > - DFI = df_ext_begin(Entry, Visited), E = df_ext_end(Entry, Visited); - DFI != E; ++DFI) { - MachineBasicBlock *MBB = *DFI; - for (MachineBasicBlock::iterator I = MBB->begin(), E = MBB->end(); - I != E; ) { - MachineInstr *MI = &*I; - ++I; - if (MI->getOpcode() == TargetInstrInfo::IMPLICIT_DEF) { - unsigned Reg = MI->getOperand(0).getReg(); - ImpDefRegs.insert(Reg); - if (TargetRegisterInfo::isPhysicalRegister(Reg)) { - for (const unsigned *SS = tri_->getSubRegisters(Reg); *SS; ++SS) - ImpDefRegs.insert(*SS); - } - ImpDefMIs.push_back(MI); - continue; - } - - if (MI->getOpcode() == TargetInstrInfo::INSERT_SUBREG) { - MachineOperand &MO = MI->getOperand(2); - if (ImpDefRegs.count(MO.getReg())) { - // %reg1032 = INSERT_SUBREG %reg1032, undef, 2 - // This is an identity copy, eliminate it now. - if (MO.isKill()) { - LiveVariables::VarInfo& vi = lv_->getVarInfo(MO.getReg()); - vi.removeKill(MI); - } - MI->eraseFromParent(); - continue; - } - } - - bool ChangedToImpDef = false; - for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { - MachineOperand& MO = MI->getOperand(i); - if (!MO.isReg() || !MO.isUse() || MO.isUndef()) - continue; - unsigned Reg = MO.getReg(); - if (!Reg) - continue; - if (!ImpDefRegs.count(Reg)) - continue; - // Use is a copy, just turn it into an implicit_def. - if (CanTurnIntoImplicitDef(MI, Reg, i, tii_)) { - bool isKill = MO.isKill(); - MI->setDesc(tii_->get(TargetInstrInfo::IMPLICIT_DEF)); - for (int j = MI->getNumOperands() - 1, ee = 0; j > ee; --j) - MI->RemoveOperand(j); - if (isKill) { - ImpDefRegs.erase(Reg); - LiveVariables::VarInfo& vi = lv_->getVarInfo(Reg); - vi.removeKill(MI); - } - ChangedToImpDef = true; - break; - } - - MO.setIsUndef(); - if (MO.isKill() || MI->isRegTiedToDefOperand(i)) { - // Make sure other uses of - for (unsigned j = i+1; j != e; ++j) { - MachineOperand &MOJ = MI->getOperand(j); - if (MOJ.isReg() && MOJ.isUse() && MOJ.getReg() == Reg) - MOJ.setIsUndef(); - } - ImpDefRegs.erase(Reg); - } - } - - if (ChangedToImpDef) { - // Backtrack to process this new implicit_def. - --I; - } else { - for (unsigned i = 0; i != MI->getNumOperands(); ++i) { - MachineOperand& MO = MI->getOperand(i); - if (!MO.isReg() || !MO.isDef()) - continue; - ImpDefRegs.erase(MO.getReg()); - } - } - } - - // Any outstanding liveout implicit_def's? - for (unsigned i = 0, e = ImpDefMIs.size(); i != e; ++i) { - MachineInstr *MI = ImpDefMIs[i]; - unsigned Reg = MI->getOperand(0).getReg(); - if (TargetRegisterInfo::isPhysicalRegister(Reg) || - !ImpDefRegs.count(Reg)) { - // Delete all "local" implicit_def's. That include those which define - // physical registers since they cannot be liveout. - MI->eraseFromParent(); - continue; - } - - // If there are multiple defs of the same register and at least one - // is not an implicit_def, do not insert implicit_def's before the - // uses. - bool Skip = false; - for (MachineRegisterInfo::def_iterator DI = mri_->def_begin(Reg), - DE = mri_->def_end(); DI != DE; ++DI) { - if (DI->getOpcode() != TargetInstrInfo::IMPLICIT_DEF) { - Skip = true; - break; - } - } - if (Skip) - continue; - - // The only implicit_def which we want to keep are those that are live - // out of its block. - MI->eraseFromParent(); - - for (MachineRegisterInfo::use_iterator UI = mri_->use_begin(Reg), - UE = mri_->use_end(); UI != UE; ) { - MachineOperand &RMO = UI.getOperand(); - MachineInstr *RMI = &*UI; - ++UI; - MachineBasicBlock *RMBB = RMI->getParent(); - if (RMBB == MBB) - continue; - - // Turn a copy use into an implicit_def. - unsigned SrcReg, DstReg, SrcSubReg, DstSubReg; - if (tii_->isMoveInstr(*RMI, SrcReg, DstReg, SrcSubReg, DstSubReg) && - Reg == SrcReg) { - RMI->setDesc(tii_->get(TargetInstrInfo::IMPLICIT_DEF)); - for (int j = RMI->getNumOperands() - 1, ee = 0; j > ee; --j) - RMI->RemoveOperand(j); - continue; - } - - const TargetRegisterClass* RC = mri_->getRegClass(Reg); - unsigned NewVReg = mri_->createVirtualRegister(RC); - RMO.setReg(NewVReg); - RMO.setIsUndef(); - RMO.setIsKill(); - } - } - ImpDefRegs.clear(); - ImpDefMIs.clear(); - } -} - - -void LiveIntervals::computeNumbering() { - Index2MiMap OldI2MI = i2miMap_; - std::vector OldI2MBB = Idx2MBBMap; - - Idx2MBBMap.clear(); - MBB2IdxMap.clear(); - mi2iMap_.clear(); - i2miMap_.clear(); - terminatorGaps.clear(); - phiJoinCopies.clear(); - - FunctionSize = 0; - - // Number MachineInstrs and MachineBasicBlocks. - // Initialize MBB indexes to a sentinal. - MBB2IdxMap.resize(mf_->getNumBlockIDs(), - std::make_pair(LiveIndex(),LiveIndex())); - - LiveIndex MIIndex; - for (MachineFunction::iterator MBB = mf_->begin(), E = mf_->end(); - MBB != E; ++MBB) { - LiveIndex StartIdx = MIIndex; - - // Insert an empty slot at the beginning of each block. - MIIndex = getNextIndex(MIIndex); - i2miMap_.push_back(0); - - for (MachineBasicBlock::iterator I = MBB->begin(), E = MBB->end(); - I != E; ++I) { - - if (I == MBB->getFirstTerminator()) { - // Leave a gap for before terminators, this is where we will point - // PHI kills. - LiveIndex tGap(true, MIIndex); - bool inserted = - terminatorGaps.insert(std::make_pair(&*MBB, tGap)).second; - assert(inserted && - "Multiple 'first' terminators encountered during numbering."); - inserted = inserted; // Avoid compiler warning if assertions turned off. - i2miMap_.push_back(0); - - MIIndex = getNextIndex(MIIndex); - } - - bool inserted = mi2iMap_.insert(std::make_pair(I, MIIndex)).second; - assert(inserted && "multiple MachineInstr -> index mappings"); - inserted = true; - i2miMap_.push_back(I); - MIIndex = getNextIndex(MIIndex); - FunctionSize++; - - // Insert max(1, numdefs) empty slots after every instruction. - unsigned Slots = I->getDesc().getNumDefs(); - if (Slots == 0) - Slots = 1; - while (Slots--) { - MIIndex = getNextIndex(MIIndex); - i2miMap_.push_back(0); - } - - } - - if (MBB->getFirstTerminator() == MBB->end()) { - // Leave a gap for before terminators, this is where we will point - // PHI kills. - LiveIndex tGap(true, MIIndex); - bool inserted = - terminatorGaps.insert(std::make_pair(&*MBB, tGap)).second; - assert(inserted && - "Multiple 'first' terminators encountered during numbering."); - inserted = inserted; // Avoid compiler warning if assertions turned off. - i2miMap_.push_back(0); - - MIIndex = getNextIndex(MIIndex); - } - - // Set the MBB2IdxMap entry for this MBB. - MBB2IdxMap[MBB->getNumber()] = std::make_pair(StartIdx, getPrevSlot(MIIndex)); - Idx2MBBMap.push_back(std::make_pair(StartIdx, MBB)); - } - - std::sort(Idx2MBBMap.begin(), Idx2MBBMap.end(), Idx2MBBCompare()); - - if (!OldI2MI.empty()) - for (iterator OI = begin(), OE = end(); OI != OE; ++OI) { - for (LiveInterval::iterator LI = OI->second->begin(), - LE = OI->second->end(); LI != LE; ++LI) { - - // Remap the start index of the live range to the corresponding new - // number, or our best guess at what it _should_ correspond to if the - // original instruction has been erased. This is either the following - // instruction or its predecessor. - unsigned index = LI->start.getVecIndex(); - LiveIndex::Slot offset = LI->start.getSlot(); - if (LI->start.isLoad()) { - std::vector::const_iterator I = - std::lower_bound(OldI2MBB.begin(), OldI2MBB.end(), LI->start); - // Take the pair containing the index - std::vector::const_iterator J = - (I == OldI2MBB.end() && OldI2MBB.size()>0) ? (I-1): I; - - LI->start = getMBBStartIdx(J->second); - } else { - LI->start = LiveIndex( - LiveIndex(mi2iMap_[OldI2MI[index]]), - (LiveIndex::Slot)offset); - } - - // Remap the ending index in the same way that we remapped the start, - // except for the final step where we always map to the immediately - // following instruction. - index = (getPrevSlot(LI->end)).getVecIndex(); - offset = LI->end.getSlot(); - if (LI->end.isLoad()) { - // VReg dies at end of block. - std::vector::const_iterator I = - std::lower_bound(OldI2MBB.begin(), OldI2MBB.end(), LI->end); - --I; - - LI->end = getNextSlot(getMBBEndIdx(I->second)); - } else { - unsigned idx = index; - while (index < OldI2MI.size() && !OldI2MI[index]) ++index; - - if (index != OldI2MI.size()) - LI->end = - LiveIndex(mi2iMap_[OldI2MI[index]], - (idx == index ? offset : LiveIndex::LOAD)); - else - LI->end = - LiveIndex(LiveIndex::NUM * i2miMap_.size()); - } - } - - for (LiveInterval::vni_iterator VNI = OI->second->vni_begin(), - VNE = OI->second->vni_end(); VNI != VNE; ++VNI) { - VNInfo* vni = *VNI; - - // Remap the VNInfo def index, which works the same as the - // start indices above. VN's with special sentinel defs - // don't need to be remapped. - if (vni->isDefAccurate() && !vni->isUnused()) { - unsigned index = vni->def.getVecIndex(); - LiveIndex::Slot offset = vni->def.getSlot(); - if (vni->def.isLoad()) { - std::vector::const_iterator I = - std::lower_bound(OldI2MBB.begin(), OldI2MBB.end(), vni->def); - // Take the pair containing the index - std::vector::const_iterator J = - (I == OldI2MBB.end() && OldI2MBB.size()>0) ? (I-1): I; - - vni->def = getMBBStartIdx(J->second); - } else { - vni->def = LiveIndex(mi2iMap_[OldI2MI[index]], offset); - } - } - - // Remap the VNInfo kill indices, which works the same as - // the end indices above. - for (size_t i = 0; i < vni->kills.size(); ++i) { - unsigned index = getPrevSlot(vni->kills[i]).getVecIndex(); - LiveIndex::Slot offset = vni->kills[i].getSlot(); - - if (vni->kills[i].isLoad()) { - assert("Value killed at a load slot."); - /*std::vector::const_iterator I = - std::lower_bound(OldI2MBB.begin(), OldI2MBB.end(), vni->kills[i]); - --I; - - vni->kills[i] = getMBBEndIdx(I->second);*/ - } else { - if (vni->kills[i].isPHIIndex()) { - std::vector::const_iterator I = - std::lower_bound(OldI2MBB.begin(), OldI2MBB.end(), vni->kills[i]); - --I; - vni->kills[i] = terminatorGaps[I->second]; - } else { - assert(OldI2MI[index] != 0 && - "Kill refers to instruction not present in index maps."); - vni->kills[i] = LiveIndex(mi2iMap_[OldI2MI[index]], offset); - } - - /* - unsigned idx = index; - while (index < OldI2MI.size() && !OldI2MI[index]) ++index; - - if (index != OldI2MI.size()) - vni->kills[i] = mi2iMap_[OldI2MI[index]] + - (idx == index ? offset : 0); - else - vni->kills[i] = InstrSlots::NUM * i2miMap_.size(); - */ - } - } - } - } -} - -void LiveIntervals::scaleNumbering(int factor) { - // Need to - // * scale MBB begin and end points - // * scale all ranges. - // * Update VNI structures. - // * Scale instruction numberings - - // Scale the MBB indices. - Idx2MBBMap.clear(); - for (MachineFunction::iterator MBB = mf_->begin(), MBBE = mf_->end(); - MBB != MBBE; ++MBB) { - std::pair &mbbIndices = MBB2IdxMap[MBB->getNumber()]; - mbbIndices.first = mbbIndices.first.scale(factor); - mbbIndices.second = mbbIndices.second.scale(factor); - Idx2MBBMap.push_back(std::make_pair(mbbIndices.first, MBB)); - } - std::sort(Idx2MBBMap.begin(), Idx2MBBMap.end(), Idx2MBBCompare()); - - // Scale terminator gaps. - for (DenseMap::iterator - TGI = terminatorGaps.begin(), TGE = terminatorGaps.end(); - TGI != TGE; ++TGI) { - terminatorGaps[TGI->first] = TGI->second.scale(factor); - } - - // Scale the intervals. - for (iterator LI = begin(), LE = end(); LI != LE; ++LI) { - LI->second->scaleNumbering(factor); - } - - // Scale MachineInstrs. - Mi2IndexMap oldmi2iMap = mi2iMap_; - LiveIndex highestSlot; - for (Mi2IndexMap::iterator MI = oldmi2iMap.begin(), ME = oldmi2iMap.end(); - MI != ME; ++MI) { - LiveIndex newSlot = MI->second.scale(factor); - mi2iMap_[MI->first] = newSlot; - highestSlot = std::max(highestSlot, newSlot); - } - - unsigned highestVIndex = highestSlot.getVecIndex(); - i2miMap_.clear(); - i2miMap_.resize(highestVIndex + 1); - for (Mi2IndexMap::iterator MI = mi2iMap_.begin(), ME = mi2iMap_.end(); - MI != ME; ++MI) { - i2miMap_[MI->second.getVecIndex()] = const_cast(MI->first); - } - -} - - /// runOnMachineFunction - Register allocate the whole function /// bool LiveIntervals::runOnMachineFunction(MachineFunction &fn) { @@ -532,10 +116,9 @@ tii_ = tm_->getInstrInfo(); aa_ = &getAnalysis(); lv_ = &getAnalysis(); + indexes_ = &getAnalysis(); allocatableRegs_ = tri_->getAllocatableSet(fn); - processImplicitDefs(); - computeNumbering(); computeIntervals(); performEarlyCoalescing(); @@ -579,12 +162,13 @@ VirtRegMap &vrm, unsigned reg) { for (LiveInterval::Ranges::const_iterator I = li.ranges.begin(), E = li.ranges.end(); I != E; ++I) { - for (LiveIndex index = getBaseIndex(I->start), - end = getNextIndex(getBaseIndex(getPrevSlot(I->end))); index != end; - index = getNextIndex(index)) { + for (SlotIndex index = I->start.getBaseIndex(), + end = I->end.getPrevSlot().getBaseIndex().getNextIndex(); + index != end; + index = index.getNextIndex()) { // skip deleted instructions while (index != end && !getInstructionFromIndex(index)) - index = getNextIndex(index); + index = index.getNextIndex(); if (index == end) break; MachineInstr *MI = getInstructionFromIndex(index); @@ -620,16 +204,17 @@ SmallPtrSet &JoinedCopies) { for (LiveInterval::Ranges::const_iterator I = li.ranges.begin(), E = li.ranges.end(); I != E; ++I) { - for (LiveIndex index = getBaseIndex(I->start), - end = getNextIndex(getBaseIndex(getPrevSlot(I->end))); index != end; - index = getNextIndex(index)) { + for (SlotIndex index = I->start.getBaseIndex(), + end = I->end.getPrevSlot().getBaseIndex().getNextIndex(); + index != end; + index = index.getNextIndex()) { // Skip deleted instructions. MachineInstr *MI = 0; while (index != end) { MI = getInstructionFromIndex(index); if (MI) break; - index = getNextIndex(index); + index = index.getNextIndex(); } if (index == end) break; @@ -664,7 +249,7 @@ void LiveIntervals::handleVirtualRegisterDef(MachineBasicBlock *mbb, MachineBasicBlock::iterator mi, - LiveIndex MIIdx, + SlotIndex MIIdx, MachineOperand& MO, unsigned MOIdx, LiveInterval &interval) { @@ -680,11 +265,11 @@ LiveVariables::VarInfo& vi = lv_->getVarInfo(interval.reg); if (interval.empty()) { // Get the Idx of the defining instructions. - LiveIndex defIndex = getDefIndex(MIIdx); + SlotIndex defIndex = MIIdx.getDefIndex(); // Earlyclobbers move back one, so that they overlap the live range // of inputs. if (MO.isEarlyClobber()) - defIndex = getUseIndex(MIIdx); + defIndex = MIIdx.getUseIndex(); VNInfo *ValNo; MachineInstr *CopyMI = NULL; unsigned SrcReg, DstReg, SrcSubReg, DstSubReg; @@ -704,16 +289,11 @@ // will be a single kill, in MBB, which comes after the definition. if (vi.Kills.size() == 1 && vi.Kills[0]->getParent() == mbb) { // FIXME: what about dead vars? - LiveIndex killIdx; + SlotIndex killIdx; if (vi.Kills[0] != mi) - killIdx = getNextSlot(getUseIndex(getInstructionIndex(vi.Kills[0]))); - else if (MO.isEarlyClobber()) - // Earlyclobbers that die in this instruction move up one extra, to - // compensate for having the starting point moved back one. This - // gets them to overlap the live range of other outputs. - killIdx = getNextSlot(getNextSlot(defIndex)); + killIdx = getInstructionIndex(vi.Kills[0]).getDefIndex(); else - killIdx = getNextSlot(defIndex); + killIdx = defIndex.getStoreIndex(); // If the kill happens after the definition, we have an intra-block // live range. @@ -732,7 +312,8 @@ // of the defining block, potentially live across some blocks, then is // live into some number of blocks, but gets killed. Start by adding a // range that goes from this definition to the end of the defining block. - LiveRange NewLR(defIndex, getNextSlot(getMBBEndIdx(mbb)), ValNo); + LiveRange NewLR(defIndex, getMBBEndIdx(mbb).getNextIndex().getLoadIndex(), + ValNo); DEBUG(errs() << " +" << NewLR); interval.addRange(NewLR); @@ -741,9 +322,10 @@ // live interval. for (SparseBitVector<>::iterator I = vi.AliveBlocks.begin(), E = vi.AliveBlocks.end(); I != E; ++I) { - LiveRange LR(getMBBStartIdx(*I), - getNextSlot(getMBBEndIdx(*I)), // MBB ends at -1. - ValNo); + LiveRange LR( + getMBBStartIdx(mf_->getBlockNumbered(*I)), + getMBBEndIdx(mf_->getBlockNumbered(*I)).getNextIndex().getLoadIndex(), + ValNo); interval.addRange(LR); DEBUG(errs() << " +" << LR); } @@ -752,8 +334,8 @@ // block to the 'use' slot of the killing instruction. for (unsigned i = 0, e = vi.Kills.size(); i != e; ++i) { MachineInstr *Kill = vi.Kills[i]; - LiveIndex killIdx = - getNextSlot(getUseIndex(getInstructionIndex(Kill))); + SlotIndex killIdx = + getInstructionIndex(Kill).getDefIndex(); LiveRange LR(getMBBStartIdx(Kill->getParent()), killIdx, ValNo); interval.addRange(LR); ValNo->addKill(killIdx); @@ -772,13 +354,13 @@ // need to take the LiveRegion that defines this register and split it // into two values. assert(interval.containsOneValue()); - LiveIndex DefIndex = getDefIndex(interval.getValNumInfo(0)->def); - LiveIndex RedefIndex = getDefIndex(MIIdx); + SlotIndex DefIndex = interval.getValNumInfo(0)->def.getDefIndex(); + SlotIndex RedefIndex = MIIdx.getDefIndex(); if (MO.isEarlyClobber()) - RedefIndex = getUseIndex(MIIdx); + RedefIndex = MIIdx.getUseIndex(); const LiveRange *OldLR = - interval.getLiveRangeContaining(getPrevSlot(RedefIndex)); + interval.getLiveRangeContaining(RedefIndex.getUseIndex()); VNInfo *OldValNo = OldLR->valno; // Delete the initial value, which should be short and continuous, @@ -811,10 +393,8 @@ // If this redefinition is dead, we need to add a dummy unit live // range covering the def slot. if (MO.isDead()) - interval.addRange( - LiveRange(RedefIndex, MO.isEarlyClobber() ? - getNextSlot(getNextSlot(RedefIndex)) : - getNextSlot(RedefIndex), OldValNo)); + interval.addRange(LiveRange(RedefIndex, RedefIndex.getStoreIndex(), + OldValNo)); DEBUG({ errs() << " RESULT: "; @@ -829,9 +409,8 @@ VNInfo *VNI = interval.getValNumInfo(0); MachineInstr *Killer = vi.Kills[0]; phiJoinCopies.push_back(Killer); - LiveIndex Start = getMBBStartIdx(Killer->getParent()); - LiveIndex End = - getNextSlot(getUseIndex(getInstructionIndex(Killer))); + SlotIndex Start = getMBBStartIdx(Killer->getParent()); + SlotIndex End = getInstructionIndex(Killer).getDefIndex(); DEBUG({ errs() << " Removing [" << Start << "," << End << "] from: "; interval.print(errs(), tri_); @@ -841,7 +420,7 @@ assert(interval.ranges.size() == 1 && "Newly discovered PHI interval has >1 ranges."); MachineBasicBlock *killMBB = getMBBFromIndex(interval.endIndex()); - VNI->addKill(terminatorGaps[killMBB]); + VNI->addKill(indexes_->getTerminatorGap(killMBB)); VNI->setHasPHIKill(true); DEBUG({ errs() << " RESULT: "; @@ -851,8 +430,8 @@ // Replace the interval with one of a NEW value number. Note that this // value number isn't actually defined by an instruction, weird huh? :) LiveRange LR(Start, End, - interval.getNextValue(LiveIndex(mbb->getNumber()), - 0, false, VNInfoAllocator)); + interval.getNextValue(SlotIndex(getMBBStartIdx(mbb), true), + 0, false, VNInfoAllocator)); LR.valno->setIsPHIDef(true); DEBUG(errs() << " replace range with " << LR); interval.addRange(LR); @@ -866,9 +445,9 @@ // In the case of PHI elimination, each variable definition is only // live until the end of the block. We've already taken care of the // rest of the live range. - LiveIndex defIndex = getDefIndex(MIIdx); + SlotIndex defIndex = MIIdx.getDefIndex(); if (MO.isEarlyClobber()) - defIndex = getUseIndex(MIIdx); + defIndex = MIIdx.getUseIndex(); VNInfo *ValNo; MachineInstr *CopyMI = NULL; @@ -880,10 +459,10 @@ CopyMI = mi; ValNo = interval.getNextValue(defIndex, CopyMI, true, VNInfoAllocator); - LiveIndex killIndex = getNextSlot(getMBBEndIdx(mbb)); + SlotIndex killIndex = getMBBEndIdx(mbb).getNextIndex().getLoadIndex(); LiveRange LR(defIndex, killIndex, ValNo); interval.addRange(LR); - ValNo->addKill(terminatorGaps[mbb]); + ValNo->addKill(indexes_->getTerminatorGap(mbb)); ValNo->setHasPHIKill(true); DEBUG(errs() << " +" << LR); } @@ -894,7 +473,7 @@ void LiveIntervals::handlePhysicalRegisterDef(MachineBasicBlock *MBB, MachineBasicBlock::iterator mi, - LiveIndex MIIdx, + SlotIndex MIIdx, MachineOperand& MO, LiveInterval &interval, MachineInstr *CopyMI) { @@ -905,12 +484,12 @@ printRegName(interval.reg, tri_); }); - LiveIndex baseIndex = MIIdx; - LiveIndex start = getDefIndex(baseIndex); + SlotIndex baseIndex = MIIdx; + SlotIndex start = baseIndex.getDefIndex(); // Earlyclobbers move back one. if (MO.isEarlyClobber()) - start = getUseIndex(MIIdx); - LiveIndex end = start; + start = MIIdx.getUseIndex(); + SlotIndex end = start; // If it is not used after definition, it is considered dead at // the instruction defining it. Hence its interval is: @@ -919,53 +498,51 @@ // advance below compensates. if (MO.isDead()) { DEBUG(errs() << " dead"); - if (MO.isEarlyClobber()) - end = getNextSlot(getNextSlot(start)); - else - end = getNextSlot(start); + end = start.getStoreIndex(); goto exit; } // If it is not dead on definition, it must be killed by a // subsequent instruction. Hence its interval is: // [defSlot(def), useSlot(kill)+1) - baseIndex = getNextIndex(baseIndex); + baseIndex = baseIndex.getNextIndex(); while (++mi != MBB->end()) { - while (baseIndex.getVecIndex() < i2miMap_.size() && - getInstructionFromIndex(baseIndex) == 0) - baseIndex = getNextIndex(baseIndex); + + if (getInstructionFromIndex(baseIndex) == 0) + baseIndex = indexes_->getNextNonNullIndex(baseIndex); + if (mi->killsRegister(interval.reg, tri_)) { DEBUG(errs() << " killed"); - end = getNextSlot(getUseIndex(baseIndex)); + end = baseIndex.getDefIndex(); goto exit; } else { int DefIdx = mi->findRegisterDefOperandIdx(interval.reg, false, tri_); if (DefIdx != -1) { if (mi->isRegTiedToUseOperand(DefIdx)) { // Two-address instruction. - end = getDefIndex(baseIndex); - if (mi->getOperand(DefIdx).isEarlyClobber()) - end = getUseIndex(baseIndex); + end = baseIndex.getDefIndex(); + assert(!mi->getOperand(DefIdx).isEarlyClobber() && + "Two address instruction is an early clobber?"); } else { // Another instruction redefines the register before it is ever read. // Then the register is essentially dead at the instruction that defines // it. Hence its interval is: // [defSlot(def), defSlot(def)+1) DEBUG(errs() << " dead"); - end = getNextSlot(start); + end = start.getStoreIndex(); } goto exit; } } - baseIndex = getNextIndex(baseIndex); + baseIndex = baseIndex.getNextIndex(); } // The only case we should have a dead physreg here without a killing or // instruction where we know it's dead is if it is live-in to the function // and never used. Another possible case is the implicit use of the // physical register has been deleted by two-address pass. - end = getNextSlot(start); + end = start.getStoreIndex(); exit: assert(start < end && "did not find end of interval?"); @@ -985,7 +562,7 @@ void LiveIntervals::handleRegisterDef(MachineBasicBlock *MBB, MachineBasicBlock::iterator MI, - LiveIndex MIIdx, + SlotIndex MIIdx, MachineOperand& MO, unsigned MOIdx) { if (TargetRegisterInfo::isVirtualRegister(MO.getReg())) @@ -1012,7 +589,7 @@ } void LiveIntervals::handleLiveInRegister(MachineBasicBlock *MBB, - LiveIndex MIIdx, + SlotIndex MIIdx, LiveInterval &interval, bool isAlias) { DEBUG({ errs() << "\t\tlivein register: "; @@ -1022,18 +599,18 @@ // Look for kills, if it reaches a def before it's killed, then it shouldn't // be considered a livein. MachineBasicBlock::iterator mi = MBB->begin(); - LiveIndex baseIndex = MIIdx; - LiveIndex start = baseIndex; - while (baseIndex.getVecIndex() < i2miMap_.size() && - getInstructionFromIndex(baseIndex) == 0) - baseIndex = getNextIndex(baseIndex); - LiveIndex end = baseIndex; + SlotIndex baseIndex = MIIdx; + SlotIndex start = baseIndex; + if (getInstructionFromIndex(baseIndex) == 0) + baseIndex = indexes_->getNextNonNullIndex(baseIndex); + + SlotIndex end = baseIndex; bool SeenDefUse = false; while (mi != MBB->end()) { if (mi->killsRegister(interval.reg, tri_)) { DEBUG(errs() << " killed"); - end = getNextSlot(getUseIndex(baseIndex)); + end = baseIndex.getDefIndex(); SeenDefUse = true; break; } else if (mi->modifiesRegister(interval.reg, tri_)) { @@ -1042,17 +619,14 @@ // it. Hence its interval is: // [defSlot(def), defSlot(def)+1) DEBUG(errs() << " dead"); - end = getNextSlot(getDefIndex(start)); + end = start.getStoreIndex(); SeenDefUse = true; break; } - baseIndex = getNextIndex(baseIndex); ++mi; if (mi != MBB->end()) { - while (baseIndex.getVecIndex() < i2miMap_.size() && - getInstructionFromIndex(baseIndex) == 0) - baseIndex = getNextIndex(baseIndex); + baseIndex = indexes_->getNextNonNullIndex(baseIndex); } } @@ -1060,7 +634,7 @@ if (!SeenDefUse) { if (isAlias) { DEBUG(errs() << " dead"); - end = getNextSlot(getDefIndex(MIIdx)); + end = MIIdx.getStoreIndex(); } else { DEBUG(errs() << " live through"); end = baseIndex; @@ -1068,7 +642,7 @@ } VNInfo *vni = - interval.getNextValue(LiveIndex(MBB->getNumber()), + interval.getNextValue(SlotIndex(getMBBStartIdx(MBB), true), 0, false, VNInfoAllocator); vni->setIsPHIDef(true); LiveRange LR(start, end, vni); @@ -1139,11 +713,11 @@ MachineInstr *PHICopy = OtherCopies[i]; DEBUG(errs() << "Moving: " << *PHICopy); - LiveIndex MIIndex = getInstructionIndex(PHICopy); - LiveIndex DefIndex = getDefIndex(MIIndex); + SlotIndex MIIndex = getInstructionIndex(PHICopy); + SlotIndex DefIndex = MIIndex.getDefIndex(); LiveRange *SLR = SrcInt.getLiveRangeContaining(DefIndex); - LiveIndex StartIndex = SLR->start; - LiveIndex EndIndex = SLR->end; + SlotIndex StartIndex = SLR->start; + SlotIndex EndIndex = SLR->end; // Delete val# defined by the now identity copy and add the range from // beginning of the mbb to the end of the range. @@ -1169,11 +743,11 @@ MachineInstr *PHICopy = IdentCopies[i]; DEBUG(errs() << "Coalescing: " << *PHICopy); - LiveIndex MIIndex = getInstructionIndex(PHICopy); - LiveIndex DefIndex = getDefIndex(MIIndex); + SlotIndex MIIndex = getInstructionIndex(PHICopy); + SlotIndex DefIndex = MIIndex.getDefIndex(); LiveRange *SLR = SrcInt.getLiveRangeContaining(DefIndex); - LiveIndex StartIndex = SLR->start; - LiveIndex EndIndex = SLR->end; + SlotIndex StartIndex = SLR->start; + SlotIndex EndIndex = SLR->end; // Delete val# defined by the now identity copy and add the range from // beginning of the mbb to the end of the range. @@ -1186,9 +760,9 @@ } // Remove the phi join and update the phi block liveness. - LiveIndex MIIndex = getInstructionIndex(Join); - LiveIndex UseIndex = getUseIndex(MIIndex); - LiveIndex DefIndex = getDefIndex(MIIndex); + SlotIndex MIIndex = getInstructionIndex(Join); + SlotIndex UseIndex = MIIndex.getUseIndex(); + SlotIndex DefIndex = MIIndex.getDefIndex(); LiveRange *SLR = SrcInt.getLiveRangeContaining(UseIndex); LiveRange *DLR = DstInt.getLiveRangeContaining(DefIndex); DLR->valno->setCopy(0); @@ -1218,7 +792,7 @@ MBBI != E; ++MBBI) { MachineBasicBlock *MBB = MBBI; // Track the index of the current machine instr. - LiveIndex MIIndex = getMBBStartIdx(MBB); + SlotIndex MIIndex = getMBBStartIdx(MBB); DEBUG(errs() << ((Value*)MBB->getBasicBlock())->getName() << ":\n"); MachineBasicBlock::iterator MI = MBB->begin(), miEnd = MBB->end(); @@ -1235,9 +809,8 @@ } // Skip over empty initial indices. - while (MIIndex.getVecIndex() < i2miMap_.size() && - getInstructionFromIndex(MIIndex) == 0) - MIIndex = getNextIndex(MIIndex); + if (getInstructionFromIndex(MIIndex) == 0) + MIIndex = indexes_->getNextNonNullIndex(MIIndex); for (; MI != miEnd; ++MI) { DEBUG(errs() << MIIndex << "\t" << *MI); @@ -1254,19 +827,9 @@ else if (MO.isUndef()) UndefUses.push_back(MO.getReg()); } - - // Skip over the empty slots after each instruction. - unsigned Slots = MI->getDesc().getNumDefs(); - if (Slots == 0) - Slots = 1; - - while (Slots--) - MIIndex = getNextIndex(MIIndex); - // Skip over empty indices. - while (MIIndex.getVecIndex() < i2miMap_.size() && - getInstructionFromIndex(MIIndex) == 0) - MIIndex = getNextIndex(MIIndex); + // Move to the next instr slot. + MIIndex = indexes_->getNextNonNullIndex(MIIndex); } } @@ -1279,45 +842,6 @@ } } -bool LiveIntervals::findLiveInMBBs( - LiveIndex Start, LiveIndex End, - SmallVectorImpl &MBBs) const { - std::vector::const_iterator I = - std::lower_bound(Idx2MBBMap.begin(), Idx2MBBMap.end(), Start); - - bool ResVal = false; - while (I != Idx2MBBMap.end()) { - if (I->first >= End) - break; - MBBs.push_back(I->second); - ResVal = true; - ++I; - } - return ResVal; -} - -bool LiveIntervals::findReachableMBBs( - LiveIndex Start, LiveIndex End, - SmallVectorImpl &MBBs) const { - std::vector::const_iterator I = - std::lower_bound(Idx2MBBMap.begin(), Idx2MBBMap.end(), Start); - - bool ResVal = false; - while (I != Idx2MBBMap.end()) { - if (I->first > End) - break; - MachineBasicBlock *MBB = I->second; - if (getMBBEndIdx(MBB) > End) - break; - for (MachineBasicBlock::succ_iterator SI = MBB->succ_begin(), - SE = MBB->succ_end(); SI != SE; ++SI) - MBBs.push_back(*SI); - ResVal = true; - ++I; - } - return ResVal; -} - LiveInterval* LiveIntervals::createInterval(unsigned reg) { float Weight = TargetRegisterInfo::isPhysicalRegister(reg) ? HUGE_VALF : 0.0F; return new LiveInterval(reg, Weight); @@ -1389,8 +913,8 @@ /// isValNoAvailableAt - Return true if the val# of the specified interval /// which reaches the given instruction also reaches the specified use index. bool LiveIntervals::isValNoAvailableAt(const LiveInterval &li, MachineInstr *MI, - LiveIndex UseIdx) const { - LiveIndex Index = getInstructionIndex(MI); + SlotIndex UseIdx) const { + SlotIndex Index = getInstructionIndex(MI); VNInfo *ValNo = li.FindLiveRangeContaining(Index)->valno; LiveInterval::const_iterator UI = li.FindLiveRangeContaining(UseIdx); return UI != li.end() && UI->valno == ValNo; @@ -1417,7 +941,7 @@ for (MachineRegisterInfo::use_iterator ri = mri_->use_begin(li.reg), re = mri_->use_end(); ri != re; ++ri) { MachineInstr *UseMI = &*ri; - LiveIndex UseIdx = getInstructionIndex(UseMI); + SlotIndex UseIdx = getInstructionIndex(UseMI); if (li.FindLiveRangeContaining(UseIdx)->valno != ValNo) continue; if (!isValNoAvailableAt(ImpLi, MI, UseIdx)) @@ -1502,7 +1026,7 @@ /// returns true. bool LiveIntervals::tryFoldMemoryOperand(MachineInstr* &MI, VirtRegMap &vrm, MachineInstr *DefMI, - LiveIndex InstrIdx, + SlotIndex InstrIdx, SmallVector &Ops, bool isSS, int Slot, unsigned Reg) { // If it is an implicit def instruction, just delete it. @@ -1540,9 +1064,7 @@ vrm.transferSpillPts(MI, fmi); vrm.transferRestorePts(MI, fmi); vrm.transferEmergencySpills(MI, fmi); - mi2iMap_.erase(MI); - i2miMap_[InstrIdx.getVecIndex()] = fmi; - mi2iMap_[fmi] = InstrIdx; + ReplaceMachineInstrInMaps(MI, fmi); MI = MBB.insert(MBB.erase(MI), fmi); ++numFolds; return true; @@ -1570,19 +1092,21 @@ } bool LiveIntervals::intervalIsInOneMBB(const LiveInterval &li) const { - SmallPtrSet MBBs; - for (LiveInterval::Ranges::const_iterator - I = li.ranges.begin(), E = li.ranges.end(); I != E; ++I) { - std::vector::const_iterator II = - std::lower_bound(Idx2MBBMap.begin(), Idx2MBBMap.end(), I->start); - if (II == Idx2MBBMap.end()) - continue; - if (I->end > II->first) // crossing a MBB. - return false; - MBBs.insert(II->second); - if (MBBs.size() > 1) + LiveInterval::Ranges::const_iterator itr = li.ranges.begin(); + + MachineBasicBlock *mbb = indexes_->getMBBCoveringRange(itr->start, itr->end); + + if (mbb == 0) + return false; + + for (++itr; itr != li.ranges.end(); ++itr) { + MachineBasicBlock *mbb2 = + indexes_->getMBBCoveringRange(itr->start, itr->end); + + if (mbb2 != mbb) return false; } + return true; } @@ -1614,7 +1138,7 @@ /// for addIntervalsForSpills to rewrite uses / defs for the given live range. bool LiveIntervals:: rewriteInstructionForSpills(const LiveInterval &li, const VNInfo *VNI, - bool TrySplit, LiveIndex index, LiveIndex end, + bool TrySplit, SlotIndex index, SlotIndex end, MachineInstr *MI, MachineInstr *ReMatOrigDefMI, MachineInstr *ReMatDefMI, unsigned Slot, int LdSlot, @@ -1791,14 +1315,13 @@ if (HasUse) { if (CreatedNewVReg) { - LiveRange LR(getLoadIndex(index), getNextSlot(getUseIndex(index)), - nI.getNextValue(LiveIndex(), 0, false, - VNInfoAllocator)); + LiveRange LR(index.getLoadIndex(), index.getDefIndex(), + nI.getNextValue(SlotIndex(), 0, false, VNInfoAllocator)); DEBUG(errs() << " +" << LR); nI.addRange(LR); } else { // Extend the split live interval to this def / use. - LiveIndex End = getNextSlot(getUseIndex(index)); + SlotIndex End = index.getDefIndex(); LiveRange LR(nI.ranges[nI.ranges.size()-1].end, End, nI.getValNumInfo(nI.getNumValNums()-1)); DEBUG(errs() << " +" << LR); @@ -1806,9 +1329,8 @@ } } if (HasDef) { - LiveRange LR(getDefIndex(index), getStoreIndex(index), - nI.getNextValue(LiveIndex(), 0, false, - VNInfoAllocator)); + LiveRange LR(index.getDefIndex(), index.getStoreIndex(), + nI.getNextValue(SlotIndex(), 0, false, VNInfoAllocator)); DEBUG(errs() << " +" << LR); nI.addRange(LR); } @@ -1824,13 +1346,13 @@ bool LiveIntervals::anyKillInMBBAfterIdx(const LiveInterval &li, const VNInfo *VNI, MachineBasicBlock *MBB, - LiveIndex Idx) const { - LiveIndex End = getMBBEndIdx(MBB); + SlotIndex Idx) const { + SlotIndex End = getMBBEndIdx(MBB); for (unsigned j = 0, ee = VNI->kills.size(); j != ee; ++j) { - if (VNI->kills[j].isPHIIndex()) + if (VNI->kills[j].isPHI()) continue; - LiveIndex KillIdx = VNI->kills[j]; + SlotIndex KillIdx = VNI->kills[j]; if (KillIdx > Idx && KillIdx < End) return true; } @@ -1841,11 +1363,11 @@ /// during spilling. namespace { struct RewriteInfo { - LiveIndex Index; + SlotIndex Index; MachineInstr *MI; bool HasUse; bool HasDef; - RewriteInfo(LiveIndex i, MachineInstr *mi, bool u, bool d) + RewriteInfo(SlotIndex i, MachineInstr *mi, bool u, bool d) : Index(i), MI(mi), HasUse(u), HasDef(d) {} }; @@ -1874,8 +1396,8 @@ std::vector &NewLIs) { bool AllCanFold = true; unsigned NewVReg = 0; - LiveIndex start = getBaseIndex(I->start); - LiveIndex end = getNextIndex(getBaseIndex(getPrevSlot(I->end))); + SlotIndex start = I->start.getBaseIndex(); + SlotIndex end = I->end.getPrevSlot().getBaseIndex().getNextIndex(); // First collect all the def / use in this live range that will be rewritten. // Make sure they are sorted according to instruction index. @@ -1886,7 +1408,7 @@ MachineOperand &O = ri.getOperand(); ++ri; assert(!O.isImplicit() && "Spilling register that's used as implicit use?"); - LiveIndex index = getInstructionIndex(MI); + SlotIndex index = getInstructionIndex(MI); if (index < start || index >= end) continue; @@ -1910,7 +1432,7 @@ for (unsigned i = 0, e = RewriteMIs.size(); i != e; ) { RewriteInfo &rwi = RewriteMIs[i]; ++i; - LiveIndex index = rwi.Index; + SlotIndex index = rwi.Index; bool MIHasUse = rwi.HasUse; bool MIHasDef = rwi.HasDef; MachineInstr *MI = rwi.MI; @@ -1993,12 +1515,12 @@ if (MI != ReMatOrigDefMI || !CanDelete) { bool HasKill = false; if (!HasUse) - HasKill = anyKillInMBBAfterIdx(li, I->valno, MBB, getDefIndex(index)); + HasKill = anyKillInMBBAfterIdx(li, I->valno, MBB, index.getDefIndex()); else { // If this is a two-address code, then this index starts a new VNInfo. - const VNInfo *VNI = li.findDefinedVNInfoForRegInt(getDefIndex(index)); + const VNInfo *VNI = li.findDefinedVNInfoForRegInt(index.getDefIndex()); if (VNI) - HasKill = anyKillInMBBAfterIdx(li, VNI, MBB, getDefIndex(index)); + HasKill = anyKillInMBBAfterIdx(li, VNI, MBB, index.getDefIndex()); } DenseMap >::iterator SII = SpillIdxes.find(MBBId); @@ -2071,7 +1593,7 @@ } } -bool LiveIntervals::alsoFoldARestore(int Id, LiveIndex index, +bool LiveIntervals::alsoFoldARestore(int Id, SlotIndex index, unsigned vr, BitVector &RestoreMBBs, DenseMap > &RestoreIdxes) { if (!RestoreMBBs[Id]) @@ -2085,7 +1607,7 @@ return false; } -void LiveIntervals::eraseRestoreInfo(int Id, LiveIndex index, +void LiveIntervals::eraseRestoreInfo(int Id, SlotIndex index, unsigned vr, BitVector &RestoreMBBs, DenseMap > &RestoreIdxes) { if (!RestoreMBBs[Id]) @@ -2093,7 +1615,7 @@ std::vector &Restores = RestoreIdxes[Id]; for (unsigned i = 0, e = Restores.size(); i != e; ++i) if (Restores[i].index == index && Restores[i].vreg) - Restores[i].index = LiveIndex(); + Restores[i].index = SlotIndex(); } /// handleSpilledImpDefs - Remove IMPLICIT_DEF instructions which are being @@ -2192,18 +1714,18 @@ } // Fill in the new live interval. - LiveIndex index = getInstructionIndex(MI); + SlotIndex index = getInstructionIndex(MI); if (HasUse) { - LiveRange LR(getLoadIndex(index), getUseIndex(index), - nI.getNextValue(LiveIndex(), 0, false, + LiveRange LR(index.getLoadIndex(), index.getUseIndex(), + nI.getNextValue(SlotIndex(), 0, false, getVNInfoAllocator())); DEBUG(errs() << " +" << LR); nI.addRange(LR); vrm.addRestorePoint(NewVReg, MI); } if (HasDef) { - LiveRange LR(getDefIndex(index), getStoreIndex(index), - nI.getNextValue(LiveIndex(), 0, false, + LiveRange LR(index.getDefIndex(), index.getStoreIndex(), + nI.getNextValue(SlotIndex(), 0, false, getVNInfoAllocator())); DEBUG(errs() << " +" << LR); nI.addRange(LR); @@ -2267,8 +1789,8 @@ if (vrm.getPreSplitReg(li.reg)) { vrm.setIsSplitFromReg(li.reg, 0); // Unset the split kill marker on the last use. - LiveIndex KillIdx = vrm.getKillPoint(li.reg); - if (KillIdx != LiveIndex()) { + SlotIndex KillIdx = vrm.getKillPoint(li.reg); + if (KillIdx != SlotIndex()) { MachineInstr *KillMI = getInstructionFromIndex(KillIdx); assert(KillMI && "Last use disappeared?"); int KillOp = KillMI->findRegisterUseOperandIdx(li.reg, true); @@ -2394,7 +1916,7 @@ while (Id != -1) { std::vector &spills = SpillIdxes[Id]; for (unsigned i = 0, e = spills.size(); i != e; ++i) { - LiveIndex index = spills[i].index; + SlotIndex index = spills[i].index; unsigned VReg = spills[i].vreg; LiveInterval &nI = getOrCreateInterval(VReg); bool isReMat = vrm.isReMaterialized(VReg); @@ -2432,16 +1954,16 @@ if (FoundUse) { // Also folded uses, do not issue a load. eraseRestoreInfo(Id, index, VReg, RestoreMBBs, RestoreIdxes); - nI.removeRange(getLoadIndex(index), getNextSlot(getUseIndex(index))); + nI.removeRange(index.getLoadIndex(), index.getDefIndex()); } - nI.removeRange(getDefIndex(index), getStoreIndex(index)); + nI.removeRange(index.getDefIndex(), index.getStoreIndex()); } } // Otherwise tell the spiller to issue a spill. if (!Folded) { LiveRange *LR = &nI.ranges[nI.ranges.size()-1]; - bool isKill = LR->end == getStoreIndex(index); + bool isKill = LR->end == index.getStoreIndex(); if (!MI->registerDefIsDead(nI.reg)) // No need to spill a dead def. vrm.addSpillPoint(VReg, isKill, MI); @@ -2457,8 +1979,8 @@ while (Id != -1) { std::vector &restores = RestoreIdxes[Id]; for (unsigned i = 0, e = restores.size(); i != e; ++i) { - LiveIndex index = restores[i].index; - if (index == LiveIndex()) + SlotIndex index = restores[i].index; + if (index == SlotIndex()) continue; unsigned VReg = restores[i].vreg; LiveInterval &nI = getOrCreateInterval(VReg); @@ -2513,7 +2035,7 @@ // If folding is not possible / failed, then tell the spiller to issue a // load / rematerialization for us. if (Folded) - nI.removeRange(getLoadIndex(index), getNextSlot(getUseIndex(index))); + nI.removeRange(index.getLoadIndex(), index.getDefIndex()); else vrm.addRestorePoint(VReg, MI); } @@ -2526,10 +2048,10 @@ for (unsigned i = 0, e = NewLIs.size(); i != e; ++i) { LiveInterval *LI = NewLIs[i]; if (!LI->empty()) { - LI->weight /= InstrSlots::NUM * getApproximateInstructionCount(*LI); + LI->weight /= SlotIndex::NUM * getApproximateInstructionCount(*LI); if (!AddedKill.count(LI)) { LiveRange *LR = &LI->ranges[LI->ranges.size()-1]; - LiveIndex LastUseIdx = getBaseIndex(LR->end); + SlotIndex LastUseIdx = LR->end.getBaseIndex(); MachineInstr *LastUse = getInstructionFromIndex(LastUseIdx); int UseIdx = LastUse->findRegisterUseOperandIdx(LI->reg, false); assert(UseIdx != -1); @@ -2580,7 +2102,7 @@ E = mri_->reg_end(); I != E; ++I) { MachineOperand &O = I.getOperand(); MachineInstr *MI = O.getParent(); - LiveIndex Index = getInstructionIndex(MI); + SlotIndex Index = getInstructionIndex(MI); if (pli.liveAt(Index)) ++NumConflicts; } @@ -2623,15 +2145,15 @@ if (SeenMIs.count(MI)) continue; SeenMIs.insert(MI); - LiveIndex Index = getInstructionIndex(MI); + SlotIndex Index = getInstructionIndex(MI); for (unsigned i = 0, e = PRegs.size(); i != e; ++i) { unsigned PReg = PRegs[i]; LiveInterval &pli = getInterval(PReg); if (!pli.liveAt(Index)) continue; vrm.addEmergencySpill(PReg, MI); - LiveIndex StartIdx = getLoadIndex(Index); - LiveIndex EndIdx = getNextSlot(getStoreIndex(Index)); + SlotIndex StartIdx = Index.getLoadIndex(); + SlotIndex EndIdx = Index.getNextIndex().getBaseIndex(); if (pli.isInOneLiveRange(StartIdx, EndIdx)) { pli.removeRange(StartIdx, EndIdx); Cut = true; @@ -2651,7 +2173,8 @@ continue; LiveInterval &spli = getInterval(*AS); if (spli.liveAt(Index)) - spli.removeRange(getLoadIndex(Index), getNextSlot(getStoreIndex(Index))); + spli.removeRange(Index.getLoadIndex(), + Index.getNextIndex().getBaseIndex()); } } } @@ -2662,13 +2185,13 @@ MachineInstr* startInst) { LiveInterval& Interval = getOrCreateInterval(reg); VNInfo* VN = Interval.getNextValue( - LiveIndex(getInstructionIndex(startInst), LiveIndex::DEF), + SlotIndex(getInstructionIndex(startInst).getDefIndex()), startInst, true, getVNInfoAllocator()); VN->setHasPHIKill(true); - VN->kills.push_back(terminatorGaps[startInst->getParent()]); + VN->kills.push_back(indexes_->getTerminatorGap(startInst->getParent())); LiveRange LR( - LiveIndex(getInstructionIndex(startInst), LiveIndex::DEF), - getNextSlot(getMBBEndIdx(startInst->getParent())), VN); + SlotIndex(getInstructionIndex(startInst).getDefIndex()), + getMBBEndIdx(startInst->getParent()).getNextIndex().getBaseIndex(), VN); Interval.addRange(LR); return LR; Modified: llvm/trunk/lib/CodeGen/LiveStackAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveStackAnalysis.cpp?rev=85979&r1=85978&r2=85979&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveStackAnalysis.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveStackAnalysis.cpp Tue Nov 3 17:52:08 2009 @@ -27,15 +27,10 @@ char LiveStacks::ID = 0; static RegisterPass X("livestacks", "Live Stack Slot Analysis"); -void LiveStacks::scaleNumbering(int factor) { - // Scale the intervals. - for (iterator LI = begin(), LE = end(); LI != LE; ++LI) { - LI->second.scaleNumbering(factor); - } -} - void LiveStacks::getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesAll(); + AU.addPreserved(); + AU.addRequiredTransitive(); MachineFunctionPass::getAnalysisUsage(AU); } Modified: llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp?rev=85979&r1=85978&r2=85979&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp (original) +++ llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp Tue Nov 3 17:52:08 2009 @@ -57,6 +57,7 @@ const TargetRegisterInfo* TRI; MachineFrameInfo *MFI; MachineRegisterInfo *MRI; + SlotIndexes *SIs; LiveIntervals *LIs; LiveStacks *LSs; VirtRegMap *VRM; @@ -68,7 +69,7 @@ MachineBasicBlock *BarrierMBB; // Barrier - Current barrier index. - LiveIndex BarrierIdx; + SlotIndex BarrierIdx; // CurrLI - Current live interval being split. LiveInterval *CurrLI; @@ -83,16 +84,19 @@ DenseMap IntervalSSMap; // Def2SpillMap - A map from a def instruction index to spill index. - DenseMap Def2SpillMap; + DenseMap Def2SpillMap; public: static char ID; - PreAllocSplitting() : MachineFunctionPass(&ID) {} + PreAllocSplitting() + : MachineFunctionPass(&ID) {} virtual bool runOnMachineFunction(MachineFunction &MF); virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesCFG(); + AU.addRequired(); + AU.addPreserved(); AU.addRequired(); AU.addPreserved(); AU.addRequired(); @@ -129,23 +133,23 @@ private: MachineBasicBlock::iterator findNextEmptySlot(MachineBasicBlock*, MachineInstr*, - LiveIndex&); + SlotIndex&); MachineBasicBlock::iterator findSpillPoint(MachineBasicBlock*, MachineInstr*, MachineInstr*, - SmallPtrSet&, LiveIndex&); + SmallPtrSet&, SlotIndex&); MachineBasicBlock::iterator - findRestorePoint(MachineBasicBlock*, MachineInstr*, LiveIndex, - SmallPtrSet&, LiveIndex&); + findRestorePoint(MachineBasicBlock*, MachineInstr*, SlotIndex, + SmallPtrSet&, SlotIndex&); int CreateSpillStackSlot(unsigned, const TargetRegisterClass *); bool IsAvailableInStack(MachineBasicBlock*, unsigned, - LiveIndex, LiveIndex, - LiveIndex&, int&) const; + SlotIndex, SlotIndex, + SlotIndex&, int&) const; - void UpdateSpillSlotInterval(VNInfo*, LiveIndex, LiveIndex); + void UpdateSpillSlotInterval(VNInfo*, SlotIndex, SlotIndex); bool SplitRegLiveInterval(LiveInterval*); @@ -157,7 +161,7 @@ bool Rematerialize(unsigned vreg, VNInfo* ValNo, MachineInstr* DefMI, MachineBasicBlock::iterator RestorePt, - LiveIndex RestoreIdx, + SlotIndex RestoreIdx, SmallPtrSet& RefsInMBB); MachineInstr* FoldSpill(unsigned vreg, const TargetRegisterClass* RC, MachineInstr* DefMI, @@ -209,12 +213,12 @@ /// instruction index map. If there isn't one, return end(). MachineBasicBlock::iterator PreAllocSplitting::findNextEmptySlot(MachineBasicBlock *MBB, MachineInstr *MI, - LiveIndex &SpotIndex) { + SlotIndex &SpotIndex) { MachineBasicBlock::iterator MII = MI; if (++MII != MBB->end()) { - LiveIndex Index = + SlotIndex Index = LIs->findGapBeforeInstr(LIs->getInstructionIndex(MII)); - if (Index != LiveIndex()) { + if (Index != SlotIndex()) { SpotIndex = Index; return MII; } @@ -230,7 +234,7 @@ PreAllocSplitting::findSpillPoint(MachineBasicBlock *MBB, MachineInstr *MI, MachineInstr *DefMI, SmallPtrSet &RefsInMBB, - LiveIndex &SpillIndex) { + SlotIndex &SpillIndex) { MachineBasicBlock::iterator Pt = MBB->begin(); MachineBasicBlock::iterator MII = MI; @@ -243,7 +247,7 @@ if (MII == EndPt || RefsInMBB.count(MII)) return Pt; while (MII != EndPt && !RefsInMBB.count(MII)) { - LiveIndex Index = LIs->getInstructionIndex(MII); + SlotIndex Index = LIs->getInstructionIndex(MII); // We can't insert the spill between the barrier (a call), and its // corresponding call frame setup. @@ -276,9 +280,9 @@ /// found. MachineBasicBlock::iterator PreAllocSplitting::findRestorePoint(MachineBasicBlock *MBB, MachineInstr *MI, - LiveIndex LastIdx, + SlotIndex LastIdx, SmallPtrSet &RefsInMBB, - LiveIndex &RestoreIndex) { + SlotIndex &RestoreIndex) { // FIXME: Allow spill to be inserted to the beginning of the mbb. Update mbb // begin index accordingly. MachineBasicBlock::iterator Pt = MBB->end(); @@ -299,10 +303,10 @@ // FIXME: Limit the number of instructions to examine to reduce // compile time? while (MII != EndPt) { - LiveIndex Index = LIs->getInstructionIndex(MII); + SlotIndex Index = LIs->getInstructionIndex(MII); if (Index > LastIdx) break; - LiveIndex Gap = LIs->findGapBeforeInstr(Index); + SlotIndex Gap = LIs->findGapBeforeInstr(Index); // We can't insert a restore between the barrier (a call) and its // corresponding call frame teardown. @@ -311,7 +315,7 @@ if (MII == EndPt || RefsInMBB.count(MII)) return Pt; ++MII; } while (MII->getOpcode() != TRI->getCallFrameDestroyOpcode()); - } else if (Gap != LiveIndex()) { + } else if (Gap != SlotIndex()) { Pt = MII; RestoreIndex = Gap; } @@ -344,7 +348,7 @@ if (CurrSLI->hasAtLeastOneValue()) CurrSValNo = CurrSLI->getValNumInfo(0); else - CurrSValNo = CurrSLI->getNextValue(LiveIndex(), 0, false, + CurrSValNo = CurrSLI->getNextValue(SlotIndex(), 0, false, LSs->getVNInfoAllocator()); return SS; } @@ -353,9 +357,9 @@ /// slot at the specified index. bool PreAllocSplitting::IsAvailableInStack(MachineBasicBlock *DefMBB, - unsigned Reg, LiveIndex DefIndex, - LiveIndex RestoreIndex, - LiveIndex &SpillIndex, + unsigned Reg, SlotIndex DefIndex, + SlotIndex RestoreIndex, + SlotIndex &SpillIndex, int& SS) const { if (!DefMBB) return false; @@ -363,7 +367,7 @@ DenseMap::iterator I = IntervalSSMap.find(Reg); if (I == IntervalSSMap.end()) return false; - DenseMap::iterator + DenseMap::iterator II = Def2SpillMap.find(DefIndex); if (II == Def2SpillMap.end()) return false; @@ -384,8 +388,8 @@ /// interval being split, and the spill and restore indicies, update the live /// interval of the spill stack slot. void -PreAllocSplitting::UpdateSpillSlotInterval(VNInfo *ValNo, LiveIndex SpillIndex, - LiveIndex RestoreIndex) { +PreAllocSplitting::UpdateSpillSlotInterval(VNInfo *ValNo, SlotIndex SpillIndex, + SlotIndex RestoreIndex) { assert(LIs->getMBBFromIndex(RestoreIndex) == BarrierMBB && "Expect restore in the barrier mbb"); @@ -398,8 +402,8 @@ } SmallPtrSet Processed; - LiveIndex EndIdx = LIs->getMBBEndIdx(MBB); - LiveRange SLR(SpillIndex, LIs->getNextSlot(EndIdx), CurrSValNo); + SlotIndex EndIdx = LIs->getMBBEndIdx(MBB); + LiveRange SLR(SpillIndex, EndIdx.getNextSlot(), CurrSValNo); CurrSLI->addRange(SLR); Processed.insert(MBB); @@ -418,7 +422,7 @@ WorkList.pop_back(); if (Processed.count(MBB)) continue; - LiveIndex Idx = LIs->getMBBStartIdx(MBB); + SlotIndex Idx = LIs->getMBBStartIdx(MBB); LR = CurrLI->getLiveRangeContaining(Idx); if (LR && LR->valno == ValNo) { EndIdx = LIs->getMBBEndIdx(MBB); @@ -428,7 +432,7 @@ CurrSLI->addRange(SLR); } else if (LR->end > EndIdx) { // Live range extends beyond end of mbb, process successors. - LiveRange SLR(Idx, LIs->getNextIndex(EndIdx), CurrSValNo); + LiveRange SLR(Idx, EndIdx.getNextIndex(), CurrSValNo); CurrSLI->addRange(SLR); for (MachineBasicBlock::succ_iterator SI = MBB->succ_begin(), SE = MBB->succ_end(); SI != SE; ++SI) @@ -491,12 +495,12 @@ } // Once we've found it, extend its VNInfo to our instruction. - LiveIndex DefIndex = LIs->getInstructionIndex(Walker); - DefIndex = LIs->getDefIndex(DefIndex); - LiveIndex EndIndex = LIs->getMBBEndIdx(MBB); + SlotIndex DefIndex = LIs->getInstructionIndex(Walker); + DefIndex = DefIndex.getDefIndex(); + SlotIndex EndIndex = LIs->getMBBEndIdx(MBB); RetVNI = NewVNs[Walker]; - LI->addRange(LiveRange(DefIndex, LIs->getNextSlot(EndIndex), RetVNI)); + LI->addRange(LiveRange(DefIndex, EndIndex.getNextSlot(), RetVNI)); } else if (!ContainsDefs && ContainsUses) { SmallPtrSet& BlockUses = Uses[MBB]; @@ -528,12 +532,12 @@ IsTopLevel, IsIntraBlock); } - LiveIndex UseIndex = LIs->getInstructionIndex(Walker); - UseIndex = LIs->getUseIndex(UseIndex); - LiveIndex EndIndex; + SlotIndex UseIndex = LIs->getInstructionIndex(Walker); + UseIndex = UseIndex.getUseIndex(); + SlotIndex EndIndex; if (IsIntraBlock) { EndIndex = LIs->getInstructionIndex(UseI); - EndIndex = LIs->getUseIndex(EndIndex); + EndIndex = EndIndex.getUseIndex(); } else EndIndex = LIs->getMBBEndIdx(MBB); @@ -542,7 +546,7 @@ RetVNI = PerformPHIConstruction(Walker, MBB, LI, Visited, Defs, Uses, NewVNs, LiveOut, Phis, false, true); - LI->addRange(LiveRange(UseIndex, LIs->getNextSlot(EndIndex), RetVNI)); + LI->addRange(LiveRange(UseIndex, EndIndex.getNextSlot(), RetVNI)); // FIXME: Need to set kills properly for inter-block stuff. if (RetVNI->isKill(UseIndex)) RetVNI->removeKill(UseIndex); @@ -588,13 +592,12 @@ IsTopLevel, IsIntraBlock); } - LiveIndex StartIndex = LIs->getInstructionIndex(Walker); - StartIndex = foundDef ? LIs->getDefIndex(StartIndex) : - LIs->getUseIndex(StartIndex); - LiveIndex EndIndex; + SlotIndex StartIndex = LIs->getInstructionIndex(Walker); + StartIndex = foundDef ? StartIndex.getDefIndex() : StartIndex.getUseIndex(); + SlotIndex EndIndex; if (IsIntraBlock) { EndIndex = LIs->getInstructionIndex(UseI); - EndIndex = LIs->getUseIndex(EndIndex); + EndIndex = EndIndex.getUseIndex(); } else EndIndex = LIs->getMBBEndIdx(MBB); @@ -604,7 +607,7 @@ RetVNI = PerformPHIConstruction(Walker, MBB, LI, Visited, Defs, Uses, NewVNs, LiveOut, Phis, false, true); - LI->addRange(LiveRange(StartIndex, LIs->getNextSlot(EndIndex), RetVNI)); + LI->addRange(LiveRange(StartIndex, EndIndex.getNextSlot(), RetVNI)); if (foundUse && RetVNI->isKill(StartIndex)) RetVNI->removeKill(StartIndex); @@ -640,9 +643,9 @@ // assume that we are not intrablock here. if (Phis.count(MBB)) return Phis[MBB]; - LiveIndex StartIndex = LIs->getMBBStartIdx(MBB); + SlotIndex StartIndex = LIs->getMBBStartIdx(MBB); VNInfo *RetVNI = Phis[MBB] = - LI->getNextValue(LiveIndex(), /*FIXME*/ 0, false, + LI->getNextValue(SlotIndex(), /*FIXME*/ 0, false, LIs->getVNInfoAllocator()); if (!IsIntraBlock) LiveOut[MBB] = RetVNI; @@ -685,19 +688,19 @@ for (DenseMap::iterator I = IncomingVNs.begin(), E = IncomingVNs.end(); I != E; ++I) { I->second->setHasPHIKill(true); - LiveIndex KillIndex = LIs->getMBBEndIdx(I->first); + SlotIndex KillIndex = LIs->getMBBEndIdx(I->first); if (!I->second->isKill(KillIndex)) I->second->addKill(KillIndex); } } - LiveIndex EndIndex; + SlotIndex EndIndex; if (IsIntraBlock) { EndIndex = LIs->getInstructionIndex(UseI); - EndIndex = LIs->getUseIndex(EndIndex); + EndIndex = EndIndex.getUseIndex(); } else EndIndex = LIs->getMBBEndIdx(MBB); - LI->addRange(LiveRange(StartIndex, LIs->getNextSlot(EndIndex), RetVNI)); + LI->addRange(LiveRange(StartIndex, EndIndex.getNextSlot(), RetVNI)); if (IsIntraBlock) RetVNI->addKill(EndIndex); @@ -733,8 +736,8 @@ DE = MRI->def_end(); DI != DE; ++DI) { Defs[(*DI).getParent()].insert(&*DI); - LiveIndex DefIdx = LIs->getInstructionIndex(&*DI); - DefIdx = LIs->getDefIndex(DefIdx); + SlotIndex DefIdx = LIs->getInstructionIndex(&*DI); + DefIdx = DefIdx.getDefIndex(); assert(DI->getOpcode() != TargetInstrInfo::PHI && "Following NewVN isPHIDef flag incorrect. Fix me!"); @@ -769,13 +772,13 @@ // Add ranges for dead defs for (MachineRegisterInfo::def_iterator DI = MRI->def_begin(LI->reg), DE = MRI->def_end(); DI != DE; ++DI) { - LiveIndex DefIdx = LIs->getInstructionIndex(&*DI); - DefIdx = LIs->getDefIndex(DefIdx); + SlotIndex DefIdx = LIs->getInstructionIndex(&*DI); + DefIdx = DefIdx.getDefIndex(); if (LI->liveAt(DefIdx)) continue; VNInfo* DeadVN = NewVNs[&*DI]; - LI->addRange(LiveRange(DefIdx, LIs->getNextSlot(DefIdx), DeadVN)); + LI->addRange(LiveRange(DefIdx, DefIdx.getNextSlot(), DeadVN)); DeadVN->addKill(DefIdx); } @@ -784,8 +787,8 @@ VI != VE; ++VI) { VNInfo* VNI = *VI; for (unsigned i = 0, e = VNI->kills.size(); i != e; ++i) { - LiveIndex KillIdx = VNI->kills[i]; - if (KillIdx.isPHIIndex()) + SlotIndex KillIdx = VNI->kills[i]; + if (KillIdx.isPHI()) continue; MachineInstr *KillMI = LIs->getInstructionFromIndex(KillIdx); if (KillMI) { @@ -826,14 +829,14 @@ // Locate two-address redefinitions for (VNInfo::KillSet::iterator KI = OldVN->kills.begin(), KE = OldVN->kills.end(); KI != KE; ++KI) { - assert(!KI->isPHIIndex() && + assert(!KI->isPHI() && "VN previously reported having no PHI kills."); MachineInstr* MI = LIs->getInstructionFromIndex(*KI); unsigned DefIdx = MI->findRegisterDefOperandIdx(CurrLI->reg); if (DefIdx == ~0U) continue; if (MI->isRegTiedToUseOperand(DefIdx)) { VNInfo* NextVN = - CurrLI->findDefinedVNInfoForRegInt(LIs->getDefIndex(*KI)); + CurrLI->findDefinedVNInfoForRegInt(KI->getDefIndex()); if (NextVN == OldVN) continue; Stack.push_back(NextVN); } @@ -865,10 +868,10 @@ for (MachineRegisterInfo::reg_iterator I = MRI->reg_begin(CurrLI->reg), E = MRI->reg_end(); I != E; ++I) { MachineOperand& MO = I.getOperand(); - LiveIndex InstrIdx = LIs->getInstructionIndex(&*I); + SlotIndex InstrIdx = LIs->getInstructionIndex(&*I); - if ((MO.isUse() && NewLI.liveAt(LIs->getUseIndex(InstrIdx))) || - (MO.isDef() && NewLI.liveAt(LIs->getDefIndex(InstrIdx)))) + if ((MO.isUse() && NewLI.liveAt(InstrIdx.getUseIndex())) || + (MO.isDef() && NewLI.liveAt(InstrIdx.getDefIndex()))) OpsToChange.push_back(std::make_pair(&*I, I.getOperandNo())); } @@ -893,12 +896,12 @@ bool PreAllocSplitting::Rematerialize(unsigned VReg, VNInfo* ValNo, MachineInstr* DefMI, MachineBasicBlock::iterator RestorePt, - LiveIndex RestoreIdx, + SlotIndex RestoreIdx, SmallPtrSet& RefsInMBB) { MachineBasicBlock& MBB = *RestorePt->getParent(); MachineBasicBlock::iterator KillPt = BarrierMBB->end(); - LiveIndex KillIdx; + SlotIndex KillIdx; if (!ValNo->isDefAccurate() || DefMI->getParent() == BarrierMBB) KillPt = findSpillPoint(BarrierMBB, Barrier, NULL, RefsInMBB, KillIdx); else @@ -911,8 +914,8 @@ LIs->InsertMachineInstrInMaps(prior(RestorePt), RestoreIdx); ReconstructLiveInterval(CurrLI); - LiveIndex RematIdx = LIs->getInstructionIndex(prior(RestorePt)); - RematIdx = LIs->getDefIndex(RematIdx); + SlotIndex RematIdx = LIs->getInstructionIndex(prior(RestorePt)); + RematIdx = RematIdx.getDefIndex(); RenumberValno(CurrLI->findDefinedVNInfoForRegInt(RematIdx)); ++NumSplits; @@ -968,7 +971,7 @@ if (CurrSLI->hasAtLeastOneValue()) CurrSValNo = CurrSLI->getValNumInfo(0); else - CurrSValNo = CurrSLI->getNextValue(LiveIndex(), 0, false, + CurrSValNo = CurrSLI->getNextValue(SlotIndex(), 0, false, LSs->getVNInfoAllocator()); } @@ -1052,11 +1055,14 @@ /// so it would not cross the barrier that's being processed. Shrink wrap /// (minimize) the live interval to the last uses. bool PreAllocSplitting::SplitRegLiveInterval(LiveInterval *LI) { + DEBUG(errs() << "Pre-alloc splitting " << LI->reg << " for " << *Barrier + << " result: "); + CurrLI = LI; // Find live range where current interval cross the barrier. LiveInterval::iterator LR = - CurrLI->FindLiveRangeContaining(LIs->getUseIndex(BarrierIdx)); + CurrLI->FindLiveRangeContaining(BarrierIdx.getUseIndex()); VNInfo *ValNo = LR->valno; assert(!ValNo->isUnused() && "Val# is defined by a dead def?"); @@ -1065,8 +1071,10 @@ ? LIs->getInstructionFromIndex(ValNo->def) : NULL; // If this would create a new join point, do not split. - if (DefMI && createsNewJoin(LR, DefMI->getParent(), Barrier->getParent())) + if (DefMI && createsNewJoin(LR, DefMI->getParent(), Barrier->getParent())) { + DEBUG(errs() << "FAILED (would create a new join point).\n"); return false; + } // Find all references in the barrier mbb. SmallPtrSet RefsInMBB; @@ -1078,21 +1086,25 @@ } // Find a point to restore the value after the barrier. - LiveIndex RestoreIndex; + SlotIndex RestoreIndex; MachineBasicBlock::iterator RestorePt = findRestorePoint(BarrierMBB, Barrier, LR->end, RefsInMBB, RestoreIndex); - if (RestorePt == BarrierMBB->end()) + if (RestorePt == BarrierMBB->end()) { + DEBUG(errs() << "FAILED (could not find a suitable restore point).\n"); return false; + } if (DefMI && LIs->isReMaterializable(*LI, ValNo, DefMI)) if (Rematerialize(LI->reg, ValNo, DefMI, RestorePt, - RestoreIndex, RefsInMBB)) - return true; + RestoreIndex, RefsInMBB)) { + DEBUG(errs() << "success (remat).\n"); + return true; + } // Add a spill either before the barrier or after the definition. MachineBasicBlock *DefMBB = DefMI ? DefMI->getParent() : NULL; const TargetRegisterClass *RC = MRI->getRegClass(CurrLI->reg); - LiveIndex SpillIndex; + SlotIndex SpillIndex; MachineInstr *SpillMI = NULL; int SS = -1; if (!ValNo->isDefAccurate()) { @@ -1103,8 +1115,10 @@ } else { MachineBasicBlock::iterator SpillPt = findSpillPoint(BarrierMBB, Barrier, NULL, RefsInMBB, SpillIndex); - if (SpillPt == BarrierMBB->begin()) + if (SpillPt == BarrierMBB->begin()) { + DEBUG(errs() << "FAILED (could not find a suitable spill point).\n"); return false; // No gap to insert spill. + } // Add spill. SS = CreateSpillStackSlot(CurrLI->reg, RC); @@ -1116,8 +1130,10 @@ RestoreIndex, SpillIndex, SS)) { // If it's already split, just restore the value. There is no need to spill // the def again. - if (!DefMI) + if (!DefMI) { + DEBUG(errs() << "FAILED (def is dead).\n"); return false; // Def is dead. Do nothing. + } if ((SpillMI = FoldSpill(LI->reg, RC, DefMI, Barrier, BarrierMBB, SS, RefsInMBB))) { @@ -1129,12 +1145,16 @@ // Add spill after the def and the last use before the barrier. SpillPt = findSpillPoint(BarrierMBB, Barrier, DefMI, RefsInMBB, SpillIndex); - if (SpillPt == DefMBB->begin()) + if (SpillPt == DefMBB->begin()) { + DEBUG(errs() << "FAILED (could not find a suitable spill point).\n"); return false; // No gap to insert spill. + } } else { SpillPt = findNextEmptySlot(DefMBB, DefMI, SpillIndex); - if (SpillPt == DefMBB->end()) + if (SpillPt == DefMBB->end()) { + DEBUG(errs() << "FAILED (could not find a suitable spill point).\n"); return false; // No gap to insert spill. + } } // Add spill. SS = CreateSpillStackSlot(CurrLI->reg, RC); @@ -1162,18 +1182,19 @@ } // Update spill stack slot live interval. - UpdateSpillSlotInterval(ValNo, LIs->getNextSlot(LIs->getUseIndex(SpillIndex)), - LIs->getDefIndex(RestoreIndex)); + UpdateSpillSlotInterval(ValNo, SpillIndex.getUseIndex().getNextSlot(), + RestoreIndex.getDefIndex()); ReconstructLiveInterval(CurrLI); if (!FoldedRestore) { - LiveIndex RestoreIdx = LIs->getInstructionIndex(prior(RestorePt)); - RestoreIdx = LIs->getDefIndex(RestoreIdx); + SlotIndex RestoreIdx = LIs->getInstructionIndex(prior(RestorePt)); + RestoreIdx = RestoreIdx.getDefIndex(); RenumberValno(CurrLI->findDefinedVNInfoForRegInt(RestoreIdx)); } ++NumSplits; + DEBUG(errs() << "success.\n"); return true; } @@ -1254,8 +1275,8 @@ // reaching definition (VNInfo). for (MachineRegisterInfo::use_iterator UI = MRI->use_begin((*LI)->reg), UE = MRI->use_end(); UI != UE; ++UI) { - LiveIndex index = LIs->getInstructionIndex(&*UI); - index = LIs->getUseIndex(index); + SlotIndex index = LIs->getInstructionIndex(&*UI); + index = index.getUseIndex(); const LiveRange* LR = (*LI)->getLiveRangeContaining(index); VNUseCount[LR->valno].insert(&*UI); @@ -1404,7 +1425,7 @@ if (LR->valno->hasPHIKill()) return false; - LiveIndex MBBEnd = LIs->getMBBEndIdx(BarrierMBB); + SlotIndex MBBEnd = LIs->getMBBEndIdx(BarrierMBB); if (LR->end < MBBEnd) return false; @@ -1467,6 +1488,7 @@ TII = TM->getInstrInfo(); MFI = MF.getFrameInfo(); MRI = &MF.getRegInfo(); + SIs = &getAnalysis(); LIs = &getAnalysis(); LSs = &getAnalysis(); VRM = &getAnalysis(); Added: llvm/trunk/lib/CodeGen/ProcessImplicitDefs.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ProcessImplicitDefs.cpp?rev=85979&view=auto ============================================================================== --- llvm/trunk/lib/CodeGen/ProcessImplicitDefs.cpp (added) +++ llvm/trunk/lib/CodeGen/ProcessImplicitDefs.cpp Tue Nov 3 17:52:08 2009 @@ -0,0 +1,231 @@ +//===---------------------- ProcessImplicitDefs.cpp -----------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#define DEBUG_TYPE "processimplicitdefs" + +#include "llvm/CodeGen/ProcessImplicitDefs.h" + +#include "llvm/ADT/DepthFirstIterator.h" +#include "llvm/ADT/SmallSet.h" +#include "llvm/Analysis/AliasAnalysis.h" +#include "llvm/CodeGen/LiveVariables.h" +#include "llvm/CodeGen/MachineInstr.h" +#include "llvm/CodeGen/MachineRegisterInfo.h" +#include "llvm/CodeGen/Passes.h" +#include "llvm/Support/Debug.h" +#include "llvm/Target/TargetInstrInfo.h" +#include "llvm/Target/TargetRegisterInfo.h" + + +using namespace llvm; + +char ProcessImplicitDefs::ID = 0; +static RegisterPass X("processimpdefs", + "Process Implicit Definitions."); + +void ProcessImplicitDefs::getAnalysisUsage(AnalysisUsage &AU) const { + AU.setPreservesCFG(); + AU.addPreserved(); + AU.addPreserved(); + AU.addRequired(); + AU.addPreservedID(MachineLoopInfoID); + AU.addPreservedID(MachineDominatorsID); + AU.addPreservedID(TwoAddressInstructionPassID); + AU.addPreservedID(PHIEliminationID); + MachineFunctionPass::getAnalysisUsage(AU); +} + +bool ProcessImplicitDefs::CanTurnIntoImplicitDef(MachineInstr *MI, + unsigned Reg, unsigned OpIdx, + const TargetInstrInfo *tii_) { + unsigned SrcReg, DstReg, SrcSubReg, DstSubReg; + if (tii_->isMoveInstr(*MI, SrcReg, DstReg, SrcSubReg, DstSubReg) && + Reg == SrcReg) + return true; + + if (OpIdx == 2 && MI->getOpcode() == TargetInstrInfo::SUBREG_TO_REG) + return true; + if (OpIdx == 1 && MI->getOpcode() == TargetInstrInfo::EXTRACT_SUBREG) + return true; + return false; +} + +/// processImplicitDefs - Process IMPLICIT_DEF instructions and make sure +/// there is one implicit_def for each use. Add isUndef marker to +/// implicit_def defs and their uses. +bool ProcessImplicitDefs::runOnMachineFunction(MachineFunction &fn) { + + DEBUG(errs() << "********** PROCESS IMPLICIT DEFS **********\n" + << "********** Function: " + << ((Value*)fn.getFunction())->getName() << '\n'); + + bool Changed = false; + + const TargetInstrInfo *tii_ = fn.getTarget().getInstrInfo(); + const TargetRegisterInfo *tri_ = fn.getTarget().getRegisterInfo(); + MachineRegisterInfo *mri_ = &fn.getRegInfo(); + + LiveVariables *lv_ = &getAnalysis(); + + SmallSet ImpDefRegs; + SmallVector ImpDefMIs; + MachineBasicBlock *Entry = fn.begin(); + SmallPtrSet Visited; + + for (df_ext_iterator > + DFI = df_ext_begin(Entry, Visited), E = df_ext_end(Entry, Visited); + DFI != E; ++DFI) { + MachineBasicBlock *MBB = *DFI; + for (MachineBasicBlock::iterator I = MBB->begin(), E = MBB->end(); + I != E; ) { + MachineInstr *MI = &*I; + ++I; + if (MI->getOpcode() == TargetInstrInfo::IMPLICIT_DEF) { + unsigned Reg = MI->getOperand(0).getReg(); + ImpDefRegs.insert(Reg); + if (TargetRegisterInfo::isPhysicalRegister(Reg)) { + for (const unsigned *SS = tri_->getSubRegisters(Reg); *SS; ++SS) + ImpDefRegs.insert(*SS); + } + ImpDefMIs.push_back(MI); + continue; + } + + if (MI->getOpcode() == TargetInstrInfo::INSERT_SUBREG) { + MachineOperand &MO = MI->getOperand(2); + if (ImpDefRegs.count(MO.getReg())) { + // %reg1032 = INSERT_SUBREG %reg1032, undef, 2 + // This is an identity copy, eliminate it now. + if (MO.isKill()) { + LiveVariables::VarInfo& vi = lv_->getVarInfo(MO.getReg()); + vi.removeKill(MI); + } + MI->eraseFromParent(); + Changed = true; + continue; + } + } + + bool ChangedToImpDef = false; + for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { + MachineOperand& MO = MI->getOperand(i); + if (!MO.isReg() || !MO.isUse() || MO.isUndef()) + continue; + unsigned Reg = MO.getReg(); + if (!Reg) + continue; + if (!ImpDefRegs.count(Reg)) + continue; + // Use is a copy, just turn it into an implicit_def. + if (CanTurnIntoImplicitDef(MI, Reg, i, tii_)) { + bool isKill = MO.isKill(); + MI->setDesc(tii_->get(TargetInstrInfo::IMPLICIT_DEF)); + for (int j = MI->getNumOperands() - 1, ee = 0; j > ee; --j) + MI->RemoveOperand(j); + if (isKill) { + ImpDefRegs.erase(Reg); + LiveVariables::VarInfo& vi = lv_->getVarInfo(Reg); + vi.removeKill(MI); + } + ChangedToImpDef = true; + Changed = true; + break; + } + + Changed = true; + MO.setIsUndef(); + if (MO.isKill() || MI->isRegTiedToDefOperand(i)) { + // Make sure other uses of + for (unsigned j = i+1; j != e; ++j) { + MachineOperand &MOJ = MI->getOperand(j); + if (MOJ.isReg() && MOJ.isUse() && MOJ.getReg() == Reg) + MOJ.setIsUndef(); + } + ImpDefRegs.erase(Reg); + } + } + + if (ChangedToImpDef) { + // Backtrack to process this new implicit_def. + --I; + } else { + for (unsigned i = 0; i != MI->getNumOperands(); ++i) { + MachineOperand& MO = MI->getOperand(i); + if (!MO.isReg() || !MO.isDef()) + continue; + ImpDefRegs.erase(MO.getReg()); + } + } + } + + // Any outstanding liveout implicit_def's? + for (unsigned i = 0, e = ImpDefMIs.size(); i != e; ++i) { + MachineInstr *MI = ImpDefMIs[i]; + unsigned Reg = MI->getOperand(0).getReg(); + if (TargetRegisterInfo::isPhysicalRegister(Reg) || + !ImpDefRegs.count(Reg)) { + // Delete all "local" implicit_def's. That include those which define + // physical registers since they cannot be liveout. + MI->eraseFromParent(); + Changed = true; + continue; + } + + // If there are multiple defs of the same register and at least one + // is not an implicit_def, do not insert implicit_def's before the + // uses. + bool Skip = false; + for (MachineRegisterInfo::def_iterator DI = mri_->def_begin(Reg), + DE = mri_->def_end(); DI != DE; ++DI) { + if (DI->getOpcode() != TargetInstrInfo::IMPLICIT_DEF) { + Skip = true; + break; + } + } + if (Skip) + continue; + + // The only implicit_def which we want to keep are those that are live + // out of its block. + MI->eraseFromParent(); + Changed = true; + + for (MachineRegisterInfo::use_iterator UI = mri_->use_begin(Reg), + UE = mri_->use_end(); UI != UE; ) { + MachineOperand &RMO = UI.getOperand(); + MachineInstr *RMI = &*UI; + ++UI; + MachineBasicBlock *RMBB = RMI->getParent(); + if (RMBB == MBB) + continue; + + // Turn a copy use into an implicit_def. + unsigned SrcReg, DstReg, SrcSubReg, DstSubReg; + if (tii_->isMoveInstr(*RMI, SrcReg, DstReg, SrcSubReg, DstSubReg) && + Reg == SrcReg) { + RMI->setDesc(tii_->get(TargetInstrInfo::IMPLICIT_DEF)); + for (int j = RMI->getNumOperands() - 1, ee = 0; j > ee; --j) + RMI->RemoveOperand(j); + continue; + } + + const TargetRegisterClass* RC = mri_->getRegClass(Reg); + unsigned NewVReg = mri_->createVirtualRegister(RC); + RMO.setReg(NewVReg); + RMO.setIsUndef(); + RMO.setIsKill(); + } + } + ImpDefRegs.clear(); + ImpDefMIs.clear(); + } + + return Changed; +} + Modified: llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp?rev=85979&r1=85978&r2=85979&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp (original) +++ llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp Tue Nov 3 17:52:08 2009 @@ -145,6 +145,7 @@ virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesCFG(); AU.addRequired(); + AU.addPreserved(); if (StrongPHIElim) AU.addRequiredID(StrongPHIEliminationID); // Make sure PassManager knows which analyses to make available @@ -175,11 +176,11 @@ /// processActiveIntervals - expire old intervals and move non-overlapping /// ones to the inactive list. - void processActiveIntervals(LiveIndex CurPoint); + void processActiveIntervals(SlotIndex CurPoint); /// processInactiveIntervals - expire old intervals and move overlapping /// ones to the active list. - void processInactiveIntervals(LiveIndex CurPoint); + void processInactiveIntervals(SlotIndex CurPoint); /// hasNextReloadInterval - Return the next liveinterval that's being /// defined by a reload from the same SS as the specified one. @@ -365,7 +366,7 @@ return Reg; VNInfo *vni = cur.begin()->valno; - if ((vni->def == LiveIndex()) || + if ((vni->def == SlotIndex()) || vni->isUnused() || !vni->isDefAccurate()) return Reg; MachineInstr *CopyMI = li_->getInstructionFromIndex(vni->def); @@ -402,7 +403,7 @@ if (!O.isKill()) continue; MachineInstr *MI = &*I; - if (SrcLI.liveAt(li_->getDefIndex(li_->getInstructionIndex(MI)))) + if (SrcLI.liveAt(li_->getInstructionIndex(MI).getDefIndex())) O.setIsKill(false); } } @@ -479,10 +480,17 @@ for (LiveIntervals::iterator i = li_->begin(), e = li_->end(); i != e; ++i) { if (TargetRegisterInfo::isPhysicalRegister(i->second->reg)) { - mri_->setPhysRegUsed(i->second->reg); - fixed_.push_back(std::make_pair(i->second, i->second->begin())); - } else - unhandled_.push(i->second); + if (!i->second->empty()) { + mri_->setPhysRegUsed(i->second->reg); + fixed_.push_back(std::make_pair(i->second, i->second->begin())); + } + } else { + if (i->second->empty()) { + assignRegOrStackSlotAtInterval(i->second); + } + else + unhandled_.push(i->second); + } } } @@ -502,13 +510,13 @@ ++NumIters; DEBUG(errs() << "\n*** CURRENT ***: " << *cur << '\n'); - if (!cur->empty()) { - processActiveIntervals(cur->beginIndex()); - processInactiveIntervals(cur->beginIndex()); + assert(!cur->empty() && "Empty interval in unhandled set."); - assert(TargetRegisterInfo::isVirtualRegister(cur->reg) && - "Can only allocate virtual registers!"); - } + processActiveIntervals(cur->beginIndex()); + processInactiveIntervals(cur->beginIndex()); + + assert(TargetRegisterInfo::isVirtualRegister(cur->reg) && + "Can only allocate virtual registers!"); // Allocating a virtual register. try to find a free // physical register or spill an interval (possibly this one) in order to @@ -585,7 +593,7 @@ /// processActiveIntervals - expire old intervals and move non-overlapping ones /// to the inactive list. -void RALinScan::processActiveIntervals(LiveIndex CurPoint) +void RALinScan::processActiveIntervals(SlotIndex CurPoint) { DEBUG(errs() << "\tprocessing active intervals:\n"); @@ -631,7 +639,7 @@ /// processInactiveIntervals - expire old intervals and move overlapping /// ones to the active list. -void RALinScan::processInactiveIntervals(LiveIndex CurPoint) +void RALinScan::processInactiveIntervals(SlotIndex CurPoint) { DEBUG(errs() << "\tprocessing inactive intervals:\n"); @@ -712,7 +720,7 @@ return IP.end(); } -static void RevertVectorIteratorsTo(RALinScan::IntervalPtrs &V, LiveIndex Point){ +static void RevertVectorIteratorsTo(RALinScan::IntervalPtrs &V, SlotIndex Point){ for (unsigned i = 0, e = V.size(); i != e; ++i) { RALinScan::IntervalPtr &IP = V[i]; LiveInterval::iterator I = std::upper_bound(IP.first->begin(), @@ -738,7 +746,7 @@ if (SI.hasAtLeastOneValue()) VNI = SI.getValNumInfo(0); else - VNI = SI.getNextValue(LiveIndex(), 0, false, + VNI = SI.getNextValue(SlotIndex(), 0, false, ls_->getVNInfoAllocator()); LiveInterval &RI = li_->getInterval(cur->reg); @@ -906,7 +914,7 @@ backUpRegUses(); std::vector > SpillWeightsToAdd; - LiveIndex StartPosition = cur->beginIndex(); + SlotIndex StartPosition = cur->beginIndex(); const TargetRegisterClass *RCLeader = RelatedRegClasses.getLeaderValue(RC); // If start of this live interval is defined by a move instruction and its @@ -916,7 +924,7 @@ // one, e.g. X86::mov32to32_. These move instructions are not coalescable. if (!vrm_->getRegAllocPref(cur->reg) && cur->hasAtLeastOneValue()) { VNInfo *vni = cur->begin()->valno; - if ((vni->def != LiveIndex()) && !vni->isUnused() && + if ((vni->def != SlotIndex()) && !vni->isUnused() && vni->isDefAccurate()) { MachineInstr *CopyMI = li_->getInstructionFromIndex(vni->def); unsigned SrcReg, DstReg, SrcSubReg, DstSubReg; @@ -1118,6 +1126,7 @@ DowngradedRegs.clear(); assignRegOrStackSlotAtInterval(cur); } else { + assert(false && "Ran out of registers during register allocation!"); llvm_report_error("Ran out of registers during register allocation!"); } return; @@ -1172,7 +1181,7 @@ LiveInterval *ReloadLi = added[i]; if (ReloadLi->weight == HUGE_VALF && li_->getApproximateInstructionCount(*ReloadLi) == 0) { - LiveIndex ReloadIdx = ReloadLi->beginIndex(); + SlotIndex ReloadIdx = ReloadLi->beginIndex(); MachineBasicBlock *ReloadMBB = li_->getMBBFromIndex(ReloadIdx); int ReloadSS = vrm_->getStackSlot(ReloadLi->reg); if (LastReloadMBB == ReloadMBB && LastReloadSS == ReloadSS) { @@ -1242,7 +1251,7 @@ spilled.insert(sli->reg); } - LiveIndex earliestStart = earliestStartInterval->beginIndex(); + SlotIndex earliestStart = earliestStartInterval->beginIndex(); DEBUG(errs() << "\t\trolling back to: " << earliestStart << '\n'); @@ -1323,7 +1332,7 @@ LiveInterval *ReloadLi = added[i]; if (ReloadLi->weight == HUGE_VALF && li_->getApproximateInstructionCount(*ReloadLi) == 0) { - LiveIndex ReloadIdx = ReloadLi->beginIndex(); + SlotIndex ReloadIdx = ReloadLi->beginIndex(); MachineBasicBlock *ReloadMBB = li_->getMBBFromIndex(ReloadIdx); int ReloadSS = vrm_->getStackSlot(ReloadLi->reg); if (LastReloadMBB == ReloadMBB && LastReloadSS == ReloadSS) { Modified: llvm/trunk/lib/CodeGen/RegAllocPBQP.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocPBQP.cpp?rev=85979&r1=85978&r2=85979&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RegAllocPBQP.cpp (original) +++ llvm/trunk/lib/CodeGen/RegAllocPBQP.cpp Tue Nov 3 17:52:08 2009 @@ -85,6 +85,8 @@ /// PBQP analysis usage. virtual void getAnalysisUsage(AnalysisUsage &au) const { + au.addRequired(); + au.addPreserved(); au.addRequired(); //au.addRequiredID(SplitCriticalEdgesID); au.addRequired(); @@ -684,7 +686,7 @@ vni = stackInterval.getValNumInfo(0); else vni = stackInterval.getNextValue( - LiveIndex(), 0, false, lss->getVNInfoAllocator()); + SlotIndex(), 0, false, lss->getVNInfoAllocator()); LiveInterval &rhsInterval = lis->getInterval(spilled->reg); stackInterval.MergeRangesInAsValue(rhsInterval, vni); @@ -832,7 +834,7 @@ tm = &mf->getTarget(); tri = tm->getRegisterInfo(); tii = tm->getInstrInfo(); - mri = &mf->getRegInfo(); + mri = &mf->getRegInfo(); lis = &getAnalysis(); lss = &getAnalysis(); Modified: llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp?rev=85979&r1=85978&r2=85979&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp (original) +++ llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp Tue Nov 3 17:52:08 2009 @@ -76,6 +76,7 @@ AU.addRequired(); AU.addRequired(); AU.addPreserved(); + AU.addPreserved(); AU.addRequired(); AU.addPreserved(); AU.addPreservedID(MachineDominatorsID); @@ -105,7 +106,7 @@ bool SimpleRegisterCoalescing::AdjustCopiesBackFrom(LiveInterval &IntA, LiveInterval &IntB, MachineInstr *CopyMI) { - LiveIndex CopyIdx = li_->getDefIndex(li_->getInstructionIndex(CopyMI)); + SlotIndex CopyIdx = li_->getInstructionIndex(CopyMI).getDefIndex(); // BValNo is a value number in B that is defined by a copy from A. 'B3' in // the example above. @@ -120,7 +121,7 @@ assert(BValNo->def == CopyIdx && "Copy doesn't define the value?"); // AValNo is the value number in A that defines the copy, A3 in the example. - LiveIndex CopyUseIdx = li_->getUseIndex(CopyIdx); + SlotIndex CopyUseIdx = CopyIdx.getUseIndex(); LiveInterval::iterator ALR = IntA.FindLiveRangeContaining(CopyUseIdx); assert(ALR != IntA.end() && "Live range not found!"); VNInfo *AValNo = ALR->valno; @@ -158,13 +159,13 @@ // Get the LiveRange in IntB that this value number starts with. LiveInterval::iterator ValLR = - IntB.FindLiveRangeContaining(li_->getPrevSlot(AValNo->def)); + IntB.FindLiveRangeContaining(AValNo->def.getPrevSlot()); assert(ValLR != IntB.end() && "Live range not found!"); // Make sure that the end of the live range is inside the same block as // CopyMI. MachineInstr *ValLREndInst = - li_->getInstructionFromIndex(li_->getPrevSlot(ValLR->end)); + li_->getInstructionFromIndex(ValLR->end.getPrevSlot()); if (!ValLREndInst || ValLREndInst->getParent() != CopyMI->getParent()) return false; @@ -193,7 +194,7 @@ IntB.print(errs(), tri_); }); - LiveIndex FillerStart = ValLR->end, FillerEnd = BLR->start; + SlotIndex FillerStart = ValLR->end, FillerEnd = BLR->start; // We are about to delete CopyMI, so need to remove it as the 'instruction // that defines this value #'. Update the the valnum with the new defining // instruction #. @@ -306,8 +307,8 @@ bool SimpleRegisterCoalescing::RemoveCopyByCommutingDef(LiveInterval &IntA, LiveInterval &IntB, MachineInstr *CopyMI) { - LiveIndex CopyIdx = - li_->getDefIndex(li_->getInstructionIndex(CopyMI)); + SlotIndex CopyIdx = + li_->getInstructionIndex(CopyMI).getDefIndex(); // FIXME: For now, only eliminate the copy by commuting its def when the // source register is a virtual register. We want to guard against cases @@ -330,7 +331,7 @@ // AValNo is the value number in A that defines the copy, A3 in the example. LiveInterval::iterator ALR = - IntA.FindLiveRangeContaining(li_->getPrevSlot(CopyIdx)); + IntA.FindLiveRangeContaining(CopyIdx.getUseIndex()); // assert(ALR != IntA.end() && "Live range not found!"); VNInfo *AValNo = ALR->valno; @@ -376,7 +377,7 @@ for (MachineRegisterInfo::use_iterator UI = mri_->use_begin(IntA.reg), UE = mri_->use_end(); UI != UE; ++UI) { MachineInstr *UseMI = &*UI; - LiveIndex UseIdx = li_->getInstructionIndex(UseMI); + SlotIndex UseIdx = li_->getInstructionIndex(UseMI); LiveInterval::iterator ULR = IntA.FindLiveRangeContaining(UseIdx); if (ULR == IntA.end()) continue; @@ -401,7 +402,7 @@ bool BHasPHIKill = BValNo->hasPHIKill(); SmallVector BDeadValNos; VNInfo::KillSet BKills; - std::map BExtend; + std::map BExtend; // If ALR and BLR overlaps and end of BLR extends beyond end of ALR, e.g. // A = or A, B @@ -428,7 +429,7 @@ ++UI; if (JoinedCopies.count(UseMI)) continue; - LiveIndex UseIdx= li_->getUseIndex(li_->getInstructionIndex(UseMI)); + SlotIndex UseIdx = li_->getInstructionIndex(UseMI).getUseIndex(); LiveInterval::iterator ULR = IntA.FindLiveRangeContaining(UseIdx); if (ULR == IntA.end() || ULR->valno != AValNo) continue; @@ -439,7 +440,7 @@ if (Extended) UseMO.setIsKill(false); else - BKills.push_back(li_->getNextSlot(UseIdx)); + BKills.push_back(UseIdx.getDefIndex()); } unsigned SrcReg, DstReg, SrcSubIdx, DstSubIdx; if (!tii_->isMoveInstr(*UseMI, SrcReg, DstReg, SrcSubIdx, DstSubIdx)) @@ -448,7 +449,7 @@ // This copy will become a noop. If it's defining a new val#, // remove that val# as well. However this live range is being // extended to the end of the existing live range defined by the copy. - LiveIndex DefIdx = li_->getDefIndex(UseIdx); + SlotIndex DefIdx = UseIdx.getDefIndex(); const LiveRange *DLR = IntB.getLiveRangeContaining(DefIdx); BHasPHIKill |= DLR->valno->hasPHIKill(); assert(DLR->valno->def == DefIdx); @@ -495,8 +496,8 @@ for (LiveInterval::iterator AI = IntA.begin(), AE = IntA.end(); AI != AE; ++AI) { if (AI->valno != AValNo) continue; - LiveIndex End = AI->end; - std::map::iterator + SlotIndex End = AI->end; + std::map::iterator EI = BExtend.find(End); if (EI != BExtend.end()) End = EI->second; @@ -507,7 +508,7 @@ if (BHasSubRegs) { for (const unsigned *SR = tri_->getSubRegisters(IntB.reg); *SR; ++SR) { LiveInterval &SRLI = li_->getInterval(*SR); - SRLI.MergeInClobberRange(AI->start, End, li_->getVNInfoAllocator()); + SRLI.MergeInClobberRange(*li_, AI->start, End, li_->getVNInfoAllocator()); } } } @@ -551,7 +552,7 @@ /// from a physical register live interval as well as from the live intervals /// of its sub-registers. static void removeRange(LiveInterval &li, - LiveIndex Start, LiveIndex End, + SlotIndex Start, SlotIndex End, LiveIntervals *li_, const TargetRegisterInfo *tri_) { li.removeRange(Start, End, true); if (TargetRegisterInfo::isPhysicalRegister(li.reg)) { @@ -559,8 +560,9 @@ if (!li_->hasInterval(*SR)) continue; LiveInterval &sli = li_->getInterval(*SR); - LiveIndex RemoveStart = Start; - LiveIndex RemoveEnd = Start; + SlotIndex RemoveStart = Start; + SlotIndex RemoveEnd = Start; + while (RemoveEnd != End) { LiveInterval::iterator LR = sli.FindLiveRangeContaining(RemoveStart); if (LR == sli.end()) @@ -577,14 +579,14 @@ /// as the copy instruction, trim the live interval to the last use and return /// true. bool -SimpleRegisterCoalescing::TrimLiveIntervalToLastUse(LiveIndex CopyIdx, +SimpleRegisterCoalescing::TrimLiveIntervalToLastUse(SlotIndex CopyIdx, MachineBasicBlock *CopyMBB, LiveInterval &li, const LiveRange *LR) { - LiveIndex MBBStart = li_->getMBBStartIdx(CopyMBB); - LiveIndex LastUseIdx; + SlotIndex MBBStart = li_->getMBBStartIdx(CopyMBB); + SlotIndex LastUseIdx; MachineOperand *LastUse = - lastRegisterUse(LR->start, li_->getPrevSlot(CopyIdx), li.reg, LastUseIdx); + lastRegisterUse(LR->start, CopyIdx.getPrevSlot(), li.reg, LastUseIdx); if (LastUse) { MachineInstr *LastUseMI = LastUse->getParent(); if (!isSameOrFallThroughBB(LastUseMI->getParent(), CopyMBB, tii_)) { @@ -603,8 +605,8 @@ // There are uses before the copy, just shorten the live range to the end // of last use. LastUse->setIsKill(); - removeRange(li, li_->getDefIndex(LastUseIdx), LR->end, li_, tri_); - LR->valno->addKill(li_->getNextSlot(LastUseIdx)); + removeRange(li, LastUseIdx.getDefIndex(), LR->end, li_, tri_); + LR->valno->addKill(LastUseIdx.getDefIndex()); unsigned SrcReg, DstReg, SrcSubIdx, DstSubIdx; if (tii_->isMoveInstr(*LastUseMI, SrcReg, DstReg, SrcSubIdx, DstSubIdx) && DstReg == li.reg) { @@ -617,7 +619,7 @@ // Is it livein? if (LR->start <= MBBStart && LR->end > MBBStart) { - if (LR->start == LiveIndex()) { + if (LR->start == li_->getZeroIndex()) { assert(TargetRegisterInfo::isPhysicalRegister(li.reg)); // Live-in to the function but dead. Remove it from entry live-in set. mf_->begin()->removeLiveIn(li.reg); @@ -634,7 +636,7 @@ unsigned DstReg, unsigned DstSubIdx, MachineInstr *CopyMI) { - LiveIndex CopyIdx = li_->getUseIndex(li_->getInstructionIndex(CopyMI)); + SlotIndex CopyIdx = li_->getInstructionIndex(CopyMI).getUseIndex(); LiveInterval::iterator SrcLR = SrcInt.FindLiveRangeContaining(CopyIdx); assert(SrcLR != SrcInt.end() && "Live range not found!"); VNInfo *ValNo = SrcLR->valno; @@ -683,7 +685,7 @@ return false; } - LiveIndex DefIdx = li_->getDefIndex(CopyIdx); + SlotIndex DefIdx = CopyIdx.getDefIndex(); const LiveRange *DLR= li_->getInterval(DstReg).getLiveRangeContaining(DefIdx); DLR->valno->setCopy(0); // Don't forget to update sub-register intervals. @@ -716,7 +718,7 @@ // should mark it dead: if (DefMI->getParent() == MBB) { DefMI->addRegisterDead(SrcInt.reg, tri_); - SrcLR->end = li_->getNextSlot(SrcLR->start); + SrcLR->end = SrcLR->start.getNextSlot(); } } @@ -815,8 +817,8 @@ (TargetRegisterInfo::isVirtualRegister(CopyDstReg) || allocatableRegs_[CopyDstReg])) { LiveInterval &LI = li_->getInterval(CopyDstReg); - LiveIndex DefIdx = - li_->getDefIndex(li_->getInstructionIndex(UseMI)); + SlotIndex DefIdx = + li_->getInstructionIndex(UseMI).getDefIndex(); if (const LiveRange *DLR = LI.getLiveRangeContaining(DefIdx)) { if (DLR->valno->def == DefIdx) DLR->valno->setCopy(UseMI); @@ -835,12 +837,12 @@ if (!UseMO.isKill()) continue; MachineInstr *UseMI = UseMO.getParent(); - LiveIndex UseIdx = - li_->getUseIndex(li_->getInstructionIndex(UseMI)); + SlotIndex UseIdx = + li_->getInstructionIndex(UseMI).getUseIndex(); const LiveRange *LR = LI.getLiveRangeContaining(UseIdx); if (!LR || - (!LR->valno->isKill(li_->getNextSlot(UseIdx)) && - LR->valno->def != li_->getNextSlot(UseIdx))) { + (!LR->valno->isKill(UseIdx.getDefIndex()) && + LR->valno->def != UseIdx.getDefIndex())) { // Interesting problem. After coalescing reg1027's def and kill are both // at the same point: %reg1027,0.000000e+00 = [56,814:0) 0 at 70-(814) // @@ -881,16 +883,16 @@ /// Return true if live interval is removed. bool SimpleRegisterCoalescing::ShortenDeadCopyLiveRange(LiveInterval &li, MachineInstr *CopyMI) { - LiveIndex CopyIdx = li_->getInstructionIndex(CopyMI); + SlotIndex CopyIdx = li_->getInstructionIndex(CopyMI); LiveInterval::iterator MLR = - li.FindLiveRangeContaining(li_->getDefIndex(CopyIdx)); + li.FindLiveRangeContaining(CopyIdx.getDefIndex()); if (MLR == li.end()) return false; // Already removed by ShortenDeadCopySrcLiveRange. - LiveIndex RemoveStart = MLR->start; - LiveIndex RemoveEnd = MLR->end; - LiveIndex DefIdx = li_->getDefIndex(CopyIdx); + SlotIndex RemoveStart = MLR->start; + SlotIndex RemoveEnd = MLR->end; + SlotIndex DefIdx = CopyIdx.getDefIndex(); // Remove the liverange that's defined by this. - if (RemoveStart == DefIdx && RemoveEnd == li_->getNextSlot(DefIdx)) { + if (RemoveStart == DefIdx && RemoveEnd == DefIdx.getStoreIndex()) { removeRange(li, RemoveStart, RemoveEnd, li_, tri_); return removeIntervalIfEmpty(li, li_, tri_); } @@ -901,7 +903,7 @@ /// the val# it defines. If the live interval becomes empty, remove it as well. bool SimpleRegisterCoalescing::RemoveDeadDef(LiveInterval &li, MachineInstr *DefMI) { - LiveIndex DefIdx = li_->getDefIndex(li_->getInstructionIndex(DefMI)); + SlotIndex DefIdx = li_->getInstructionIndex(DefMI).getDefIndex(); LiveInterval::iterator MLR = li.FindLiveRangeContaining(DefIdx); if (DefIdx != MLR->valno->def) return false; @@ -912,10 +914,10 @@ /// PropagateDeadness - Propagate the dead marker to the instruction which /// defines the val#. static void PropagateDeadness(LiveInterval &li, MachineInstr *CopyMI, - LiveIndex &LRStart, LiveIntervals *li_, + SlotIndex &LRStart, LiveIntervals *li_, const TargetRegisterInfo* tri_) { MachineInstr *DefMI = - li_->getInstructionFromIndex(li_->getDefIndex(LRStart)); + li_->getInstructionFromIndex(LRStart.getDefIndex()); if (DefMI && DefMI != CopyMI) { int DeadIdx = DefMI->findRegisterDefOperandIdx(li.reg, false); if (DeadIdx != -1) @@ -923,7 +925,7 @@ else DefMI->addOperand(MachineOperand::CreateReg(li.reg, /*def*/true, /*implicit*/true, /*kill*/false, /*dead*/true)); - LRStart = li_->getNextSlot(LRStart); + LRStart = LRStart.getNextSlot(); } } @@ -934,8 +936,8 @@ bool SimpleRegisterCoalescing::ShortenDeadCopySrcLiveRange(LiveInterval &li, MachineInstr *CopyMI) { - LiveIndex CopyIdx = li_->getInstructionIndex(CopyMI); - if (CopyIdx == LiveIndex()) { + SlotIndex CopyIdx = li_->getInstructionIndex(CopyMI); + if (CopyIdx == SlotIndex()) { // FIXME: special case: function live in. It can be a general case if the // first instruction index starts at > 0 value. assert(TargetRegisterInfo::isPhysicalRegister(li.reg)); @@ -948,13 +950,13 @@ } LiveInterval::iterator LR = - li.FindLiveRangeContaining(li_->getPrevSlot(CopyIdx)); + li.FindLiveRangeContaining(CopyIdx.getPrevIndex().getStoreIndex()); if (LR == li.end()) // Livein but defined by a phi. return false; - LiveIndex RemoveStart = LR->start; - LiveIndex RemoveEnd = li_->getNextSlot(li_->getDefIndex(CopyIdx)); + SlotIndex RemoveStart = LR->start; + SlotIndex RemoveEnd = CopyIdx.getStoreIndex(); if (LR->end > RemoveEnd) // More uses past this copy? Nothing to do. return false; @@ -974,7 +976,7 @@ // If the live range starts in another mbb and the copy mbb is not a fall // through mbb, then we can only cut the range from the beginning of the // copy mbb. - RemoveStart = li_->getNextSlot(li_->getMBBStartIdx(CopyMBB)); + RemoveStart = li_->getMBBStartIdx(CopyMBB).getNextIndex().getBaseIndex(); if (LR->valno->def == RemoveStart) { // If the def MI defines the val# and this copy is the only kill of the @@ -1030,14 +1032,14 @@ // If the virtual register live interval extends into a loop, turn down // aggressiveness. - LiveIndex CopyIdx = - li_->getDefIndex(li_->getInstructionIndex(CopyMI)); + SlotIndex CopyIdx = + li_->getInstructionIndex(CopyMI).getDefIndex(); const MachineLoop *L = loopInfo->getLoopFor(CopyMBB); if (!L) { // Let's see if the virtual register live interval extends into the loop. LiveInterval::iterator DLR = DstInt.FindLiveRangeContaining(CopyIdx); assert(DLR != DstInt.end() && "Live range not found!"); - DLR = DstInt.FindLiveRangeContaining(li_->getNextSlot(DLR->end)); + DLR = DstInt.FindLiveRangeContaining(DLR->end.getNextSlot()); if (DLR != DstInt.end()) { CopyMBB = li_->getMBBFromIndex(DLR->start); L = loopInfo->getLoopFor(CopyMBB); @@ -1047,7 +1049,7 @@ if (!L || Length <= Threshold) return true; - LiveIndex UseIdx = li_->getUseIndex(CopyIdx); + SlotIndex UseIdx = CopyIdx.getUseIndex(); LiveInterval::iterator SLR = SrcInt.FindLiveRangeContaining(UseIdx); MachineBasicBlock *SMBB = li_->getMBBFromIndex(SLR->start); if (loopInfo->getLoopFor(SMBB) != L) { @@ -1060,7 +1062,7 @@ if (SuccMBB == CopyMBB) continue; if (DstInt.overlaps(li_->getMBBStartIdx(SuccMBB), - li_->getNextSlot(li_->getMBBEndIdx(SuccMBB)))) + li_->getMBBEndIdx(SuccMBB).getNextIndex().getBaseIndex())) return false; } } @@ -1091,12 +1093,12 @@ // If the virtual register live interval is defined or cross a loop, turn // down aggressiveness. - LiveIndex CopyIdx = - li_->getDefIndex(li_->getInstructionIndex(CopyMI)); - LiveIndex UseIdx = li_->getUseIndex(CopyIdx); + SlotIndex CopyIdx = + li_->getInstructionIndex(CopyMI).getDefIndex(); + SlotIndex UseIdx = CopyIdx.getUseIndex(); LiveInterval::iterator SLR = SrcInt.FindLiveRangeContaining(UseIdx); assert(SLR != SrcInt.end() && "Live range not found!"); - SLR = SrcInt.FindLiveRangeContaining(li_->getPrevSlot(SLR->start)); + SLR = SrcInt.FindLiveRangeContaining(SLR->start.getPrevSlot()); if (SLR == SrcInt.end()) return true; MachineBasicBlock *SMBB = li_->getMBBFromIndex(SLR->start); @@ -1116,7 +1118,7 @@ if (PredMBB == SMBB) continue; if (SrcInt.overlaps(li_->getMBBStartIdx(PredMBB), - li_->getNextSlot(li_->getMBBEndIdx(PredMBB)))) + li_->getMBBEndIdx(PredMBB).getNextIndex().getBaseIndex())) return false; } } @@ -1705,7 +1707,7 @@ // Update the liveintervals of sub-registers. for (const unsigned *AS = tri_->getSubRegisters(DstReg); *AS; ++AS) - li_->getOrCreateInterval(*AS).MergeInClobberRanges(*ResSrcInt, + li_->getOrCreateInterval(*AS).MergeInClobberRanges(*li_, *ResSrcInt, li_->getVNInfoAllocator()); } @@ -1867,7 +1869,7 @@ /// is live at the given point. bool SimpleRegisterCoalescing::ValueLiveAt(LiveInterval::iterator LRItr, LiveInterval::iterator LREnd, - LiveIndex defPoint) const { + SlotIndex defPoint) const { for (const VNInfo *valno = LRItr->valno; (LRItr != LREnd) && (LRItr->valno == valno); ++LRItr) { if (LRItr->contains(defPoint)) @@ -2047,7 +2049,7 @@ // Update the liveintervals of sub-registers. if (TargetRegisterInfo::isPhysicalRegister(LHS.reg)) for (const unsigned *AS = tri_->getSubRegisters(LHS.reg); *AS; ++AS) - li_->getOrCreateInterval(*AS).MergeInClobberRanges(LHS, + li_->getOrCreateInterval(*AS).MergeInClobberRanges(*li_, LHS, li_->getVNInfoAllocator()); return true; @@ -2148,7 +2150,7 @@ } else { // It was defined as a copy from the LHS, find out what value # it is. RHSValNoInfo = - LHS.getLiveRangeContaining(li_->getPrevSlot(RHSValNoInfo0->def))->valno; + LHS.getLiveRangeContaining(RHSValNoInfo0->def.getPrevSlot())->valno; RHSValID = RHSValNoInfo->id; RHSVal0DefinedFromLHS = RHSValID; } @@ -2212,7 +2214,7 @@ // Figure out the value # from the RHS. LHSValsDefinedFromRHS[VNI]= - RHS.getLiveRangeContaining(li_->getPrevSlot(VNI->def))->valno; + RHS.getLiveRangeContaining(VNI->def.getPrevSlot())->valno; } // Loop over the value numbers of the RHS, seeing if any are defined from @@ -2230,7 +2232,7 @@ // Figure out the value # from the LHS. RHSValsDefinedFromLHS[VNI]= - LHS.getLiveRangeContaining(li_->getPrevSlot(VNI->def))->valno; + LHS.getLiveRangeContaining(VNI->def.getPrevSlot())->valno; } LHSValNoAssignments.resize(LHS.getNumValNums(), -1); @@ -2494,11 +2496,11 @@ /// lastRegisterUse - Returns the last use of the specific register between /// cycles Start and End or NULL if there are no uses. MachineOperand * -SimpleRegisterCoalescing::lastRegisterUse(LiveIndex Start, - LiveIndex End, +SimpleRegisterCoalescing::lastRegisterUse(SlotIndex Start, + SlotIndex End, unsigned Reg, - LiveIndex &UseIdx) const{ - UseIdx = LiveIndex(); + SlotIndex &UseIdx) const{ + UseIdx = SlotIndex(); if (TargetRegisterInfo::isVirtualRegister(Reg)) { MachineOperand *LastUse = NULL; for (MachineRegisterInfo::use_iterator I = mri_->use_begin(Reg), @@ -2510,22 +2512,24 @@ SrcReg == DstReg) // Ignore identity copies. continue; - LiveIndex Idx = li_->getInstructionIndex(UseMI); + SlotIndex Idx = li_->getInstructionIndex(UseMI); + // FIXME: Should this be Idx != UseIdx? SlotIndex() will return something + // that compares higher than any other interval. if (Idx >= Start && Idx < End && Idx >= UseIdx) { LastUse = &Use; - UseIdx = li_->getUseIndex(Idx); + UseIdx = Idx.getUseIndex(); } } return LastUse; } - LiveIndex s = Start; - LiveIndex e = li_->getBaseIndex(li_->getPrevSlot(End)); + SlotIndex s = Start; + SlotIndex e = End.getPrevSlot().getBaseIndex(); while (e >= s) { // Skip deleted instructions MachineInstr *MI = li_->getInstructionFromIndex(e); - while (e != LiveIndex() && li_->getPrevIndex(e) >= s && !MI) { - e = li_->getPrevIndex(e); + while (e != SlotIndex() && e.getPrevIndex() >= s && !MI) { + e = e.getPrevIndex(); MI = li_->getInstructionFromIndex(e); } if (e < s || MI == NULL) @@ -2539,12 +2543,12 @@ MachineOperand &Use = MI->getOperand(i); if (Use.isReg() && Use.isUse() && Use.getReg() && tri_->regsOverlap(Use.getReg(), Reg)) { - UseIdx = li_->getUseIndex(e); + UseIdx = e.getUseIndex(); return &Use; } } - e = li_->getPrevIndex(e); + e = e.getPrevIndex(); } return NULL; @@ -2568,7 +2572,7 @@ static bool isZeroLengthInterval(LiveInterval *li, LiveIntervals *li_) { for (LiveInterval::Ranges::const_iterator i = li->ranges.begin(), e = li->ranges.end(); i != e; ++i) - if (li_->getPrevIndex(i->end) > i->start) + if (i->end.getPrevIndex() > i->start) return false; return true; } @@ -2579,7 +2583,7 @@ for (MachineFunction::iterator mbbi = mf_->begin(), mbbe = mf_->end(); mbbi != mbbe; ++mbbi) { MachineBasicBlock* MBB = mbbi; - LiveIndex MBBEnd = li_->getMBBEndIdx(MBB); + SlotIndex MBBEnd = li_->getMBBEndIdx(MBB); MachineLoop* loop = loopInfo->getLoopFor(MBB); unsigned loopDepth = loop ? loop->getLoopDepth() : 0; bool isExiting = loop ? loop->isLoopExiting(MBB) : false; @@ -2621,7 +2625,7 @@ float Weight = li_->getSpillWeight(HasDef, HasUse, loopDepth); if (HasDef && isExiting) { // Looks like this is a loop count variable update. - LiveIndex DefIdx = li_->getDefIndex(li_->getInstructionIndex(MI)); + SlotIndex DefIdx = li_->getInstructionIndex(MI).getDefIndex(); const LiveRange *DLR = li_->getInterval(Reg).getLiveRangeContaining(DefIdx); if (DLR->end > MBBEnd) Modified: llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.h?rev=85979&r1=85978&r2=85979&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.h (original) +++ llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.h Tue Nov 3 17:52:08 2009 @@ -146,7 +146,7 @@ /// TrimLiveIntervalToLastUse - If there is a last use in the same basic /// block as the copy instruction, trim the ive interval to the last use /// and return true. - bool TrimLiveIntervalToLastUse(LiveIndex CopyIdx, + bool TrimLiveIntervalToLastUse(SlotIndex CopyIdx, MachineBasicBlock *CopyMBB, LiveInterval &li, const LiveRange *LR); @@ -205,7 +205,7 @@ /// iterator, or any subsequent range with the same value number, /// is live at the given point. bool ValueLiveAt(LiveInterval::iterator LRItr, LiveInterval::iterator LREnd, - LiveIndex defPoint) const; + SlotIndex defPoint) const; /// RangeIsDefinedByCopyFromReg - Return true if the specified live range of /// the specified live interval is defined by a copy from the specified @@ -241,9 +241,8 @@ /// lastRegisterUse - Returns the last use of the specific register between /// cycles Start and End or NULL if there are no uses. - MachineOperand *lastRegisterUse(LiveIndex Start, - LiveIndex End, unsigned Reg, - LiveIndex &LastUseIdx) const; + MachineOperand *lastRegisterUse(SlotIndex Start, SlotIndex End, + unsigned Reg, SlotIndex &LastUseIdx) const; /// CalculateSpillWeights - Compute spill weights for all virtual register /// live intervals. Added: llvm/trunk/lib/CodeGen/SlotIndexes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SlotIndexes.cpp?rev=85979&view=auto ============================================================================== --- llvm/trunk/lib/CodeGen/SlotIndexes.cpp (added) +++ llvm/trunk/lib/CodeGen/SlotIndexes.cpp Tue Nov 3 17:52:08 2009 @@ -0,0 +1,189 @@ +//===-- SlotIndexes.cpp - Slot Indexes Pass ------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#define DEBUG_TYPE "slotindexes" + +#include "llvm/CodeGen/SlotIndexes.h" +#include "llvm/CodeGen/MachineFunction.h" +#include "llvm/Support/Debug.h" +#include "llvm/Support/raw_ostream.h" + +using namespace llvm; + +std::auto_ptr SlotIndex::emptyKeyPtr(0), + SlotIndex::tombstoneKeyPtr(0); + +char SlotIndexes::ID = 0; +static RegisterPass X("slotindexes", "Slot index numbering"); + +void SlotIndexes::getAnalysisUsage(AnalysisUsage &au) const { + au.setPreservesAll(); + MachineFunctionPass::getAnalysisUsage(au); +} + +void SlotIndexes::releaseMemory() { + mi2iMap.clear(); + mbb2IdxMap.clear(); + idx2MBBMap.clear(); + terminatorGaps.clear(); + clearList(); +} + +bool SlotIndexes::runOnMachineFunction(MachineFunction &fn) { + + // Compute numbering as follows: + // Grab an iterator to the start of the index list. + // Iterate over all MBBs, and within each MBB all MIs, keeping the MI + // iterator in lock-step (though skipping it over indexes which have + // null pointers in the instruction field). + // At each iteration assert that the instruction pointed to in the index + // is the same one pointed to by the MI iterator. This + + // FIXME: This can be simplified. The mi2iMap_, Idx2MBBMap, etc. should + // only need to be set up once after the first numbering is computed. + + mf = &fn; + initList(); + + const unsigned gap = 1; + + // Check that the list contains only the sentinal. + assert(indexListHead->getNext() == 0 && + "Index list non-empty at initial numbering?"); + assert(idx2MBBMap.empty() && + "Index -> MBB mapping non-empty at initial numbering?"); + assert(mbb2IdxMap.empty() && + "MBB -> Index mapping non-empty at initial numbering?"); + assert(mi2iMap.empty() && + "MachineInstr -> Index mapping non-empty at initial numbering?"); + + functionSize = 0; + /* + for (unsigned s = 0; s < SlotIndex::NUM; ++s) { + indexList.push_back(createEntry(0, s)); + } + + unsigned index = gap * SlotIndex::NUM; + */ + + unsigned index = 0; + + // Iterate over the the function. + for (MachineFunction::iterator mbbItr = mf->begin(), mbbEnd = mf->end(); + mbbItr != mbbEnd; ++mbbItr) { + MachineBasicBlock *mbb = &*mbbItr; + + // Insert an index for the MBB start. + push_back(createEntry(0, index)); + SlotIndex blockStartIndex(back(), SlotIndex::LOAD); + + index += gap * SlotIndex::NUM; + + for (MachineBasicBlock::iterator miItr = mbb->begin(), miEnd = mbb->end(); + miItr != miEnd; ++miItr) { + MachineInstr *mi = &*miItr; + + if (miItr == mbb->getFirstTerminator()) { + push_back(createEntry(0, index)); + terminatorGaps.insert( + std::make_pair(mbb, SlotIndex(back(), SlotIndex::PHI_BIT))); + index += gap * SlotIndex::NUM; + } + + // Insert a store index for the instr. + push_back(createEntry(mi, index)); + + // Save this base index in the maps. + mi2iMap.insert( + std::make_pair(mi, SlotIndex(back(), SlotIndex::LOAD))); + + ++functionSize; + + unsigned Slots = mi->getDesc().getNumDefs(); + if (Slots == 0) + Slots = 1; + + index += (Slots + 1) * gap * SlotIndex::NUM; + } + + if (mbb->getFirstTerminator() == mbb->end()) { + push_back(createEntry(0, index)); + terminatorGaps.insert( + std::make_pair(mbb, SlotIndex(back(), SlotIndex::PHI_BIT))); + index += gap * SlotIndex::NUM; + } + + SlotIndex blockEndIndex(back(), SlotIndex::STORE); + mbb2IdxMap.insert( + std::make_pair(mbb, std::make_pair(blockStartIndex, blockEndIndex))); + + idx2MBBMap.push_back(IdxMBBPair(blockStartIndex, mbb)); + } + + // One blank instruction at the end. + push_back(createEntry(0, index)); + + // Sort the Idx2MBBMap + std::sort(idx2MBBMap.begin(), idx2MBBMap.end(), Idx2MBBCompare()); + + DEBUG(dump()); + + // And we're done! + return false; +} + +void SlotIndexes::renumber() { + assert(false && "SlotIndexes::runmuber is not fully implemented yet."); + + // Compute numbering as follows: + // Grab an iterator to the start of the index list. + // Iterate over all MBBs, and within each MBB all MIs, keeping the MI + // iterator in lock-step (though skipping it over indexes which have + // null pointers in the instruction field). + // At each iteration assert that the instruction pointed to in the index + // is the same one pointed to by the MI iterator. This + + // FIXME: This can be simplified. The mi2iMap_, Idx2MBBMap, etc. should + // only need to be set up once - when the first numbering is computed. + + assert(false && "Renumbering not supported yet."); +} + +void SlotIndexes::dump() const { + for (const IndexListEntry *itr = front(); itr != getTail(); + itr = itr->getNext()) { + errs() << itr->getIndex() << " "; + + if (itr->getInstr() != 0) { + errs() << *itr->getInstr(); + } else { + errs() << "\n"; + } + } + + for (MBB2IdxMap::iterator itr = mbb2IdxMap.begin(); + itr != mbb2IdxMap.end(); ++itr) { + errs() << "MBB " << itr->first->getNumber() << " (" << itr->first << ") - [" + << itr->second.first << ", " << itr->second.second << "]\n"; + } +} + +// Print a SlotIndex to a raw_ostream. +void SlotIndex::print(raw_ostream &os) const { + os << getIndex(); + if (isPHI()) + os << "*"; +} + +// Dump a SlotIndex to stderr. +void SlotIndex::dump() const { + print(errs()); + errs() << "\n"; +} + Modified: llvm/trunk/lib/CodeGen/Spiller.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/Spiller.cpp?rev=85979&r1=85978&r2=85979&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/Spiller.cpp (original) +++ llvm/trunk/lib/CodeGen/Spiller.cpp Tue Nov 3 17:52:08 2009 @@ -51,13 +51,15 @@ /// Ensures there is space before the given machine instruction, returns the /// instruction's new number. - LiveIndex makeSpaceBefore(MachineInstr *mi) { + SlotIndex makeSpaceBefore(MachineInstr *mi) { if (!lis->hasGapBeforeInstr(lis->getInstructionIndex(mi))) { - lis->scaleNumbering(2); - ls->scaleNumbering(2); + // FIXME: Should be updated to use rewrite-in-place methods when they're + // introduced. Currently broken. + //lis->scaleNumbering(2); + //ls->scaleNumbering(2); } - LiveIndex miIdx = lis->getInstructionIndex(mi); + SlotIndex miIdx = lis->getInstructionIndex(mi); assert(lis->hasGapBeforeInstr(miIdx)); @@ -66,13 +68,15 @@ /// Ensure there is space after the given machine instruction, returns the /// instruction's new number. - LiveIndex makeSpaceAfter(MachineInstr *mi) { + SlotIndex makeSpaceAfter(MachineInstr *mi) { if (!lis->hasGapAfterInstr(lis->getInstructionIndex(mi))) { - lis->scaleNumbering(2); - ls->scaleNumbering(2); + // FIXME: Should be updated to use rewrite-in-place methods when they're + // introduced. Currently broken. + // lis->scaleNumbering(2); + // ls->scaleNumbering(2); } - LiveIndex miIdx = lis->getInstructionIndex(mi); + SlotIndex miIdx = lis->getInstructionIndex(mi); assert(lis->hasGapAfterInstr(miIdx)); @@ -83,19 +87,19 @@ /// after the given instruction. Returns the base index of the inserted /// instruction. The caller is responsible for adding an appropriate /// LiveInterval to the LiveIntervals analysis. - LiveIndex insertStoreAfter(MachineInstr *mi, unsigned ss, + SlotIndex insertStoreAfter(MachineInstr *mi, unsigned ss, unsigned vreg, const TargetRegisterClass *trc) { MachineBasicBlock::iterator nextInstItr(next(mi)); - LiveIndex miIdx = makeSpaceAfter(mi); + SlotIndex miIdx = makeSpaceAfter(mi); tii->storeRegToStackSlot(*mi->getParent(), nextInstItr, vreg, true, ss, trc); MachineBasicBlock::iterator storeInstItr(next(mi)); MachineInstr *storeInst = &*storeInstItr; - LiveIndex storeInstIdx = lis->getNextIndex(miIdx); + SlotIndex storeInstIdx = miIdx.getNextIndex(); assert(lis->getInstructionFromIndex(storeInstIdx) == 0 && "Store inst index already in use."); @@ -108,15 +112,15 @@ /// Insert a store of the given vreg to the given stack slot immediately /// before the given instructnion. Returns the base index of the inserted /// Instruction. - LiveIndex insertStoreBefore(MachineInstr *mi, unsigned ss, + SlotIndex insertStoreBefore(MachineInstr *mi, unsigned ss, unsigned vreg, const TargetRegisterClass *trc) { - LiveIndex miIdx = makeSpaceBefore(mi); + SlotIndex miIdx = makeSpaceBefore(mi); tii->storeRegToStackSlot(*mi->getParent(), mi, vreg, true, ss, trc); MachineBasicBlock::iterator storeInstItr(prior(mi)); MachineInstr *storeInst = &*storeInstItr; - LiveIndex storeInstIdx = lis->getPrevIndex(miIdx); + SlotIndex storeInstIdx = miIdx.getPrevIndex(); assert(lis->getInstructionFromIndex(storeInstIdx) == 0 && "Store inst index already in use."); @@ -131,9 +135,9 @@ unsigned vreg, const TargetRegisterClass *trc) { - LiveIndex storeInstIdx = insertStoreAfter(mi, ss, vreg, trc); - LiveIndex start = lis->getDefIndex(lis->getInstructionIndex(mi)), - end = lis->getUseIndex(storeInstIdx); + SlotIndex storeInstIdx = insertStoreAfter(mi, ss, vreg, trc); + SlotIndex start = lis->getInstructionIndex(mi).getDefIndex(), + end = storeInstIdx.getUseIndex(); VNInfo *vni = li->getNextValue(storeInstIdx, 0, true, lis->getVNInfoAllocator()); @@ -149,18 +153,18 @@ /// after the given instruction. Returns the base index of the inserted /// instruction. The caller is responsibel for adding/removing an appropriate /// range vreg's LiveInterval. - LiveIndex insertLoadAfter(MachineInstr *mi, unsigned ss, + SlotIndex insertLoadAfter(MachineInstr *mi, unsigned ss, unsigned vreg, const TargetRegisterClass *trc) { MachineBasicBlock::iterator nextInstItr(next(mi)); - LiveIndex miIdx = makeSpaceAfter(mi); + SlotIndex miIdx = makeSpaceAfter(mi); tii->loadRegFromStackSlot(*mi->getParent(), nextInstItr, vreg, ss, trc); MachineBasicBlock::iterator loadInstItr(next(mi)); MachineInstr *loadInst = &*loadInstItr; - LiveIndex loadInstIdx = lis->getNextIndex(miIdx); + SlotIndex loadInstIdx = miIdx.getNextIndex(); assert(lis->getInstructionFromIndex(loadInstIdx) == 0 && "Store inst index already in use."); @@ -174,15 +178,15 @@ /// before the given instruction. Returns the base index of the inserted /// instruction. The caller is responsible for adding an appropriate /// LiveInterval to the LiveIntervals analysis. - LiveIndex insertLoadBefore(MachineInstr *mi, unsigned ss, + SlotIndex insertLoadBefore(MachineInstr *mi, unsigned ss, unsigned vreg, const TargetRegisterClass *trc) { - LiveIndex miIdx = makeSpaceBefore(mi); + SlotIndex miIdx = makeSpaceBefore(mi); tii->loadRegFromStackSlot(*mi->getParent(), mi, vreg, ss, trc); MachineBasicBlock::iterator loadInstItr(prior(mi)); MachineInstr *loadInst = &*loadInstItr; - LiveIndex loadInstIdx = lis->getPrevIndex(miIdx); + SlotIndex loadInstIdx = miIdx.getPrevIndex(); assert(lis->getInstructionFromIndex(loadInstIdx) == 0 && "Load inst index already in use."); @@ -197,9 +201,9 @@ unsigned vreg, const TargetRegisterClass *trc) { - LiveIndex loadInstIdx = insertLoadBefore(mi, ss, vreg, trc); - LiveIndex start = lis->getDefIndex(loadInstIdx), - end = lis->getUseIndex(lis->getInstructionIndex(mi)); + SlotIndex loadInstIdx = insertLoadBefore(mi, ss, vreg, trc); + SlotIndex start = loadInstIdx.getDefIndex(), + end = lis->getInstructionIndex(mi).getUseIndex(); VNInfo *vni = li->getNextValue(loadInstIdx, 0, true, lis->getVNInfoAllocator()); @@ -321,21 +325,21 @@ vrm->assignVirt2StackSlot(li->reg, ss); MachineInstr *mi = 0; - LiveIndex storeIdx = LiveIndex(); + SlotIndex storeIdx = SlotIndex(); if (valno->isDefAccurate()) { // If we have an accurate def we can just grab an iterator to the instr // after the def. mi = lis->getInstructionFromIndex(valno->def); - storeIdx = lis->getDefIndex(insertStoreAfter(mi, ss, li->reg, trc)); + storeIdx = insertStoreAfter(mi, ss, li->reg, trc).getDefIndex(); } else { // if we get here we have a PHI def. mi = &lis->getMBBFromIndex(valno->def)->front(); - storeIdx = lis->getDefIndex(insertStoreBefore(mi, ss, li->reg, trc)); + storeIdx = insertStoreBefore(mi, ss, li->reg, trc).getDefIndex(); } MachineBasicBlock *defBlock = mi->getParent(); - LiveIndex loadIdx = LiveIndex(); + SlotIndex loadIdx = SlotIndex(); // Now we need to find the load... MachineBasicBlock::iterator useItr(mi); @@ -343,11 +347,11 @@ if (useItr != defBlock->end()) { MachineInstr *loadInst = useItr; - loadIdx = lis->getUseIndex(insertLoadBefore(loadInst, ss, li->reg, trc)); + loadIdx = insertLoadBefore(loadInst, ss, li->reg, trc).getUseIndex(); } else { MachineInstr *loadInst = &defBlock->back(); - loadIdx = lis->getUseIndex(insertLoadAfter(loadInst, ss, li->reg, trc)); + loadIdx = insertLoadAfter(loadInst, ss, li->reg, trc).getUseIndex(); } li->removeRange(storeIdx, loadIdx, true); Modified: llvm/trunk/lib/CodeGen/StackSlotColoring.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/StackSlotColoring.cpp?rev=85979&r1=85978&r2=85979&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/StackSlotColoring.cpp (original) +++ llvm/trunk/lib/CodeGen/StackSlotColoring.cpp Tue Nov 3 17:52:08 2009 @@ -98,6 +98,8 @@ virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesCFG(); + AU.addRequired(); + AU.addPreserved(); AU.addRequired(); AU.addRequired(); AU.addPreserved(); Modified: llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp?rev=85979&r1=85978&r2=85979&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp (original) +++ llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp Tue Nov 3 17:52:08 2009 @@ -72,6 +72,8 @@ virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesCFG(); AU.addRequired(); + AU.addRequired(); + AU.addPreserved(); AU.addRequired(); // TODO: Actually make this true. @@ -294,7 +296,7 @@ static bool isLiveIn(unsigned r, MachineBasicBlock* MBB, LiveIntervals& LI) { LiveInterval& I = LI.getOrCreateInterval(r); - LiveIndex idx = LI.getMBBStartIdx(MBB); + SlotIndex idx = LI.getMBBStartIdx(MBB); return I.liveAt(idx); } @@ -427,7 +429,7 @@ } LiveInterval& PI = LI.getOrCreateInterval(DestReg); - LiveIndex pIdx = LI.getDefIndex(LI.getInstructionIndex(P)); + SlotIndex pIdx = LI.getInstructionIndex(P).getDefIndex(); VNInfo* PVN = PI.getLiveRangeContaining(pIdx)->valno; PhiValueNumber.insert(std::make_pair(DestReg, PVN->id)); @@ -747,7 +749,7 @@ LiveInterval& I = LI.getInterval(curr.second); MachineBasicBlock::iterator term = MBB->getFirstTerminator(); - LiveIndex endIdx = LiveIndex(); + SlotIndex endIdx = SlotIndex(); if (term != MBB->end()) endIdx = LI.getInstructionIndex(term); else @@ -771,7 +773,7 @@ // Renumber the instructions so that we can perform the index computations // needed to create new live intervals. - LI.computeNumbering(); + LI.renumber(); // For copies that we inserted at the ends of predecessors, we construct // live intervals. This is pretty easy, since we know that the destination @@ -783,15 +785,15 @@ InsertedPHIDests.begin(), E = InsertedPHIDests.end(); I != E; ++I) { if (RegHandled.insert(I->first).second) { LiveInterval& Int = LI.getOrCreateInterval(I->first); - LiveIndex instrIdx = LI.getInstructionIndex(I->second); - if (Int.liveAt(LI.getDefIndex(instrIdx))) - Int.removeRange(LI.getDefIndex(instrIdx), - LI.getNextSlot(LI.getMBBEndIdx(I->second->getParent())), + SlotIndex instrIdx = LI.getInstructionIndex(I->second); + if (Int.liveAt(instrIdx.getDefIndex())) + Int.removeRange(instrIdx.getDefIndex(), + LI.getMBBEndIdx(I->second->getParent()).getNextSlot(), true); LiveRange R = LI.addLiveRangeToEndOfBlock(I->first, I->second); R.valno->setCopy(I->second); - R.valno->def = LI.getDefIndex(LI.getInstructionIndex(I->second)); + R.valno->def = LI.getInstructionIndex(I->second).getDefIndex(); } } } @@ -816,8 +818,8 @@ Stacks[I->getOperand(i).getReg()].size()) { // Remove the live range for the old vreg. LiveInterval& OldInt = LI.getInterval(I->getOperand(i).getReg()); - LiveInterval::iterator OldLR = OldInt.FindLiveRangeContaining( - LI.getUseIndex(LI.getInstructionIndex(I))); + LiveInterval::iterator OldLR = + OldInt.FindLiveRangeContaining(LI.getInstructionIndex(I).getUseIndex()); if (OldLR != OldInt.end()) OldInt.removeRange(*OldLR, true); @@ -829,11 +831,10 @@ VNInfo* FirstVN = *Int.vni_begin(); FirstVN->setHasPHIKill(false); if (I->getOperand(i).isKill()) - FirstVN->addKill( - LI.getUseIndex(LI.getInstructionIndex(I))); + FirstVN->addKill(LI.getInstructionIndex(I).getUseIndex()); LiveRange LR (LI.getMBBStartIdx(I->getParent()), - LI.getNextSlot(LI.getUseIndex(LI.getInstructionIndex(I))), + LI.getInstructionIndex(I).getUseIndex().getNextSlot(), FirstVN); Int.addRange(LR); @@ -862,14 +863,14 @@ LiveInterval& LHS = LI.getOrCreateInterval(primary); LiveInterval& RHS = LI.getOrCreateInterval(secondary); - LI.computeNumbering(); + LI.renumber(); DenseMap VNMap; for (LiveInterval::iterator I = RHS.begin(), E = RHS.end(); I != E; ++I) { LiveRange R = *I; - LiveIndex Start = R.start; - LiveIndex End = R.end; + SlotIndex Start = R.start; + SlotIndex End = R.end; if (LHS.getLiveRangeContaining(Start)) return false; @@ -963,19 +964,19 @@ TII->copyRegToReg(*SI->second, SI->second->getFirstTerminator(), I->first, SI->first, RC, RC); - LI.computeNumbering(); + LI.renumber(); LiveInterval& Int = LI.getOrCreateInterval(I->first); - LiveIndex instrIdx = + SlotIndex instrIdx = LI.getInstructionIndex(--SI->second->getFirstTerminator()); - if (Int.liveAt(LI.getDefIndex(instrIdx))) - Int.removeRange(LI.getDefIndex(instrIdx), - LI.getNextSlot(LI.getMBBEndIdx(SI->second)), true); + if (Int.liveAt(instrIdx.getDefIndex())) + Int.removeRange(instrIdx.getDefIndex(), + LI.getMBBEndIdx(SI->second).getNextSlot(), true); LiveRange R = LI.addLiveRangeToEndOfBlock(I->first, --SI->second->getFirstTerminator()); R.valno->setCopy(--SI->second->getFirstTerminator()); - R.valno->def = LI.getDefIndex(instrIdx); + R.valno->def = instrIdx.getDefIndex(); DEBUG(errs() << "Renaming failed: " << SI->first << " -> " << I->first << "\n"); @@ -1010,7 +1011,7 @@ if (PI.containsOneValue()) { LI.removeInterval(DestReg); } else { - LiveIndex idx = LI.getDefIndex(LI.getInstructionIndex(PInstr)); + SlotIndex idx = LI.getInstructionIndex(PInstr).getDefIndex(); PI.removeRange(*PI.getLiveRangeContaining(idx), true); } } else { @@ -1024,7 +1025,7 @@ LiveInterval& InputI = LI.getInterval(reg); if (MBB != PInstr->getParent() && InputI.liveAt(LI.getMBBStartIdx(PInstr->getParent())) && - InputI.expiredAt(LI.getNextIndex(LI.getInstructionIndex(PInstr)))) + InputI.expiredAt(LI.getInstructionIndex(PInstr).getNextIndex())) InputI.removeRange(LI.getMBBStartIdx(PInstr->getParent()), LI.getInstructionIndex(PInstr), true); @@ -1032,7 +1033,7 @@ // If the PHI is not dead, then the valno defined by the PHI // now has an unknown def. - LiveIndex idx = LI.getDefIndex(LI.getInstructionIndex(PInstr)); + SlotIndex idx = LI.getInstructionIndex(PInstr).getDefIndex(); const LiveRange* PLR = PI.getLiveRangeContaining(idx); PLR->valno->setIsPHIDef(true); LiveRange R (LI.getMBBStartIdx(PInstr->getParent()), @@ -1044,7 +1045,7 @@ PInstr->eraseFromParent(); } - LI.computeNumbering(); + LI.renumber(); return true; } Modified: llvm/trunk/lib/CodeGen/VirtRegMap.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/VirtRegMap.cpp?rev=85979&r1=85978&r2=85979&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/VirtRegMap.cpp (original) +++ llvm/trunk/lib/CodeGen/VirtRegMap.cpp Tue Nov 3 17:52:08 2009 @@ -56,7 +56,7 @@ TII = mf.getTarget().getInstrInfo(); TRI = mf.getTarget().getRegisterInfo(); MF = &mf; - + ReMatId = MAX_STACK_SLOT+1; LowSpillSlot = HighSpillSlot = NO_STACK_SLOT; Modified: llvm/trunk/lib/CodeGen/VirtRegMap.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/VirtRegMap.h?rev=85979&r1=85978&r2=85979&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/VirtRegMap.h (original) +++ llvm/trunk/lib/CodeGen/VirtRegMap.h Tue Nov 3 17:52:08 2009 @@ -80,7 +80,7 @@ /// Virt2SplitKillMap - This is splitted virtual register to its last use /// (kill) index mapping. - IndexedMap Virt2SplitKillMap; + IndexedMap Virt2SplitKillMap; /// ReMatMap - This is virtual register to re-materialized instruction /// mapping. Each virtual register whose definition is going to be @@ -142,7 +142,7 @@ VirtRegMap() : MachineFunctionPass(&ID), Virt2PhysMap(NO_PHYS_REG), Virt2StackSlotMap(NO_STACK_SLOT), Virt2ReMatIdMap(NO_STACK_SLOT), Virt2SplitMap(0), - Virt2SplitKillMap(LiveIndex()), ReMatMap(NULL), + Virt2SplitKillMap(SlotIndex()), ReMatMap(NULL), ReMatId(MAX_STACK_SLOT+1), LowSpillSlot(NO_STACK_SLOT), HighSpillSlot(NO_STACK_SLOT) { } virtual bool runOnMachineFunction(MachineFunction &MF); @@ -266,17 +266,17 @@ } /// @brief record the last use (kill) of a split virtual register. - void addKillPoint(unsigned virtReg, LiveIndex index) { + void addKillPoint(unsigned virtReg, SlotIndex index) { Virt2SplitKillMap[virtReg] = index; } - LiveIndex getKillPoint(unsigned virtReg) const { + SlotIndex getKillPoint(unsigned virtReg) const { return Virt2SplitKillMap[virtReg]; } /// @brief remove the last use (kill) of a split virtual register. void removeKillPoint(unsigned virtReg) { - Virt2SplitKillMap[virtReg] = LiveIndex(); + Virt2SplitKillMap[virtReg] = SlotIndex(); } /// @brief returns true if the specified MachineInstr is a spill point. From evan.cheng at apple.com Tue Nov 3 18:00:40 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 04 Nov 2009 00:00:40 -0000 Subject: [llvm-commits] [llvm] r85980 - /llvm/trunk/lib/Target/ARM/ARMInstrThumb.td Message-ID: <200911040000.nA400e3u001866@zion.cs.uiuc.edu> Author: evancheng Date: Tue Nov 3 18:00:39 2009 New Revision: 85980 URL: http://llvm.org/viewvc/llvm-project?rev=85980&view=rev Log: Use ldr.n to workaround a darwin assembler bug. Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb.td?rev=85980&r1=85979&r2=85980&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb.td Tue Nov 3 18:00:39 2009 @@ -326,9 +326,10 @@ "ldr", "\t$dst, $addr", []>; // Load tconstpool +// FIXME: Use ldr.n to work around a Darwin assembler bug. let canFoldAsLoad = 1 in def tLDRpci : T1pIs<(outs tGPR:$dst), (ins i32imm:$addr), IIC_iLoadi, - "ldr", "\t$dst, $addr", + "ldr.n", "\t$dst, $addr", [(set tGPR:$dst, (load (ARMWrapper tconstpool:$addr)))]>; // Special LDR for loads from non-pc-relative constpools. From evan.cheng at apple.com Tue Nov 3 18:08:13 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 04 Nov 2009 00:08:13 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r85982 - /llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Message-ID: <200911040008.nA408DFD002125@zion.cs.uiuc.edu> Author: evancheng Date: Tue Nov 3 18:08:13 2009 New Revision: 85982 URL: http://llvm.org/viewvc/llvm-project?rev=85982&view=rev Log: llvm-gcc is inlining too little at -O2 for C++ code. On WebKit, llvm-gcc compiled code is generally > 20% smaller, but it's > 5% slower. GCC mark all C++ member functions as "inline" and that makes it inline aggressively. After careful consideration, we have decided to increase -O2 inlining limit to 200 for C++ code. Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp?rev=85982&r1=85981&r2=85982&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Tue Nov 3 18:08:13 2009 @@ -352,11 +352,20 @@ // inliner. gcc has many options that control inlining, but we have decided // not to support anything like that for llvm-gcc. static unsigned GuessAtInliningThreshold() { - unsigned threshold = 200; - if (optimize_size || optimize < 3) + if (optimize_size) // Reduce inline limit. - threshold = 50; - return threshold; + return 50; + + if (optimize >= 3) + return 200; + + // gcc mark C++ member functions "inline" and inline them more aggressively. + // We are not going to do that. Up the inline threshold when compiling for + // C++. + StringRef LanguageName = lang_hooks.name; + if (LanguageName == "GNU C++" || LanguageName == "GNU Objective-C++") + return 200; + return 50; } void llvm_initialize_backend(void) { From bob.wilson at apple.com Tue Nov 3 18:26:50 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 3 Nov 2009 16:26:50 -0800 Subject: [llvm-commits] [llvm] r85980 - /llvm/trunk/lib/Target/ARM/ARMInstrThumb.td In-Reply-To: <200911040000.nA400e3u001866@zion.cs.uiuc.edu> References: <200911040000.nA400e3u001866@zion.cs.uiuc.edu> Message-ID: <81ACCBF7-61BB-4E08-B324-3572DC58A017@apple.com> I think CodeGen/Thumb2/machine-licm.ll needs to be updated, too. On Nov 3, 2009, at 4:00 PM, Evan Cheng wrote: > Author: evancheng > Date: Tue Nov 3 18:00:39 2009 > New Revision: 85980 > > URL: http://llvm.org/viewvc/llvm-project?rev=85980&view=rev > Log: > Use ldr.n to workaround a darwin assembler bug. > > Modified: > llvm/trunk/lib/Target/ARM/ARMInstrThumb.td > > Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb.td > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb.td?rev=85980&r1=85979&r2=85980&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Target/ARM/ARMInstrThumb.td (original) > +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb.td Tue Nov 3 18:00:39 > 2009 > @@ -326,9 +326,10 @@ > "ldr", "\t$dst, $addr", []>; > > // Load tconstpool > +// FIXME: Use ldr.n to work around a Darwin assembler bug. > let canFoldAsLoad = 1 in > def tLDRpci : T1pIs<(outs tGPR:$dst), (ins i32imm:$addr), IIC_iLoadi, > - "ldr", "\t$dst, $addr", > + "ldr.n", "\t$dst, $addr", > [(set tGPR:$dst, (load (ARMWrapper tconstpool: > $addr)))]>; > > // Special LDR for loads from non-pc-relative constpools. > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From evan.cheng at apple.com Tue Nov 3 18:42:33 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 04 Nov 2009 00:42:33 -0000 Subject: [llvm-commits] [llvm] r85986 - /llvm/trunk/test/CodeGen/Thumb2/machine-licm.ll Message-ID: <200911040042.nA40gXgi003237@zion.cs.uiuc.edu> Author: evancheng Date: Tue Nov 3 18:42:33 2009 New Revision: 85986 URL: http://llvm.org/viewvc/llvm-project?rev=85986&view=rev Log: Fix test. Modified: llvm/trunk/test/CodeGen/Thumb2/machine-licm.ll Modified: llvm/trunk/test/CodeGen/Thumb2/machine-licm.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/machine-licm.ll?rev=85986&r1=85985&r2=85986&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/machine-licm.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/machine-licm.ll Tue Nov 3 18:42:33 2009 @@ -15,7 +15,7 @@ bb.nph: ; preds = %entry ; CHECK: BB#1 -; CHECK: ldr r{{[0-9]+}}, LCPI1_0 +; CHECK: ldr{{.*}} r{{[0-9]+}}, LCPI1_0 ; CHECK: ldr{{.*}} r{{[0-9]+}}, LCPI1_1 %.pre = load i32* @GV, align 4 ; [#uses=1] br label %bb From isanbard at gmail.com Tue Nov 3 19:24:05 2009 From: isanbard at gmail.com (Bill Wendling) Date: Wed, 04 Nov 2009 01:24:05 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r85992 - in /llvm-gcc-4.2/trunk/gcc: config/darwin.h llvm-backend.cpp Message-ID: <200911040124.nA41O59R004608@zion.cs.uiuc.edu> Author: void Date: Tue Nov 3 19:24:04 2009 New Revision: 85992 URL: http://llvm.org/viewvc/llvm-project?rev=85992&view=rev Log: Reverting r84717. fldry is generating aligned loads of strings. It requires the strings to be 16-byte aligned, which this breaks. Modified: llvm-gcc-4.2/trunk/gcc/config/darwin.h llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Modified: llvm-gcc-4.2/trunk/gcc/config/darwin.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/darwin.h?rev=85992&r1=85991&r2=85992&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/darwin.h (original) +++ llvm-gcc-4.2/trunk/gcc/config/darwin.h Tue Nov 3 19:24:04 2009 @@ -698,21 +698,10 @@ char *N = (char *)alloca(strlen(fmt) + 37); \ sprintf(N, fmt, i++); \ GV->setName(N); \ - GV->setAlignment(TARGET_64BIT ? 8 : 4); \ } \ } while (0) /* LLVM LOCAL - end radar 6389998 */ -/* LLVM LOCAL - begin radar 7291825 */ -/* Give a constant string a sufficient alignment for the platform. */ -#define TARGET_ADJUST_CSTRING_ALIGN(GV) \ - do { \ - if (GV->hasInternalLinkage()) { \ - GV->setAlignment(TARGET_64BIT ? 8 : 4); \ - } \ - } while (0) -/* LLVM LOCAL - end radar 7291825 */ - #endif /* LLVM LOCAL end */ Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp?rev=85992&r1=85991&r2=85992&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Tue Nov 3 19:24:04 2009 @@ -1415,16 +1415,8 @@ unsigned TargetAlign = getTargetData().getABITypeAlignment(GV->getType()->getElementType()); if (DECL_USER_ALIGN(decl) || - 8 * TargetAlign < (unsigned)DECL_ALIGN(decl)) { + 8 * TargetAlign < (unsigned)DECL_ALIGN(decl)) GV->setAlignment(DECL_ALIGN(decl) / 8); - } -#ifdef TARGET_ADJUST_CSTRING_ALIGN - else if (DECL_INITIAL(decl) != error_mark_node && // uninitialized? - DECL_INITIAL(decl) && - TREE_CODE(DECL_INITIAL(decl)) == STRING_CST) { - TARGET_ADJUST_CSTRING_ALIGN(GV); - } -#endif } // Handle used decls From dgregor at apple.com Tue Nov 3 19:32:06 2009 From: dgregor at apple.com (Douglas Gregor) Date: Wed, 04 Nov 2009 01:32:06 -0000 Subject: [llvm-commits] [llvm] r85994 - /llvm/trunk/lib/CodeGen/CMakeLists.txt Message-ID: <200911040132.nA41W6qp004925@zion.cs.uiuc.edu> Author: dgregor Date: Tue Nov 3 19:32:06 2009 New Revision: 85994 URL: http://llvm.org/viewvc/llvm-project?rev=85994&view=rev Log: Fix CMake makefiles Modified: llvm/trunk/lib/CodeGen/CMakeLists.txt Modified: llvm/trunk/lib/CodeGen/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CMakeLists.txt?rev=85994&r1=85993&r2=85994&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/CMakeLists.txt (original) +++ llvm/trunk/lib/CodeGen/CMakeLists.txt Tue Nov 3 19:32:06 2009 @@ -42,6 +42,7 @@ Passes.cpp PostRASchedulerList.cpp PreAllocSplitting.cpp + ProcessImplicitDefs.cpp PrologEpilogInserter.cpp PseudoSourceValue.cpp RegAllocLinearScan.cpp @@ -57,6 +58,7 @@ ShrinkWrapping.cpp SimpleRegisterCoalescing.cpp SjLjEHPrepare.cpp + SlotIndexes.cpp Spiller.cpp StackProtector.cpp StackSlotColoring.cpp From lhames at gmail.com Tue Nov 3 19:34:22 2009 From: lhames at gmail.com (Lang Hames) Date: Wed, 04 Nov 2009 01:34:22 -0000 Subject: [llvm-commits] [llvm] r85995 - /llvm/trunk/include/llvm/CodeGen/SlotIndexes.h Message-ID: <200911040134.nA41YM8D004997@zion.cs.uiuc.edu> Author: lhames Date: Tue Nov 3 19:34:22 2009 New Revision: 85995 URL: http://llvm.org/viewvc/llvm-project?rev=85995&view=rev Log: Removed an unnecessary friend declaration and some crufty comments from IndexListEntry. Modified: llvm/trunk/include/llvm/CodeGen/SlotIndexes.h Modified: llvm/trunk/include/llvm/CodeGen/SlotIndexes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SlotIndexes.h?rev=85995&r1=85994&r2=85995&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/SlotIndexes.h (original) +++ llvm/trunk/include/llvm/CodeGen/SlotIndexes.h Tue Nov 3 19:34:22 2009 @@ -37,7 +37,6 @@ /// information. class IndexListEntry { friend class SlotIndex; - friend class SlotIndexes; private: @@ -63,38 +62,6 @@ IndexListEntry* getPrev() { return prev; } const IndexListEntry* getPrev() const { return prev; } void setPrev(IndexListEntry *prev) { this->prev = prev; } - - /* - bool operator==(const IndexListEntry &other) const { - assert(getIndex() != other.getIndex() || this == &other && - "Non-equal index list entries compare equal."); - return getIndex() == other.getIndex(); - } - - bool operator!=(const IndexListEntry &other) const { - return getIndex() != other.getIndex(); - } - - bool operator<(const IndexListEntry &other) const { - return getIndex() < other.getIndex(); - } - - bool operator<=(const IndexListEntry &other) const { - return getIndex() <= other.getIndex(); - } - - bool operator>(const IndexListEntry &other) const { - return getIndex() > other.getIndex(); - } - - bool operator>=(const IndexListEntry &other) const { - return getIndex() >= other.getIndex(); - } - - int distance(const IndexListEntry &other) const { - return other.getIndex() - getIndex(); - } - */ }; // Specialize PointerLikeTypeTraits for IndexListEntry. From lhames at gmail.com Tue Nov 3 19:52:40 2009 From: lhames at gmail.com (Lang Hames) Date: Wed, 04 Nov 2009 01:52:40 -0000 Subject: [llvm-commits] [llvm] r85997 - /llvm/trunk/include/llvm/CodeGen/SlotIndexes.h Message-ID: <200911040152.nA41qeIt005623@zion.cs.uiuc.edu> Author: lhames Date: Tue Nov 3 19:52:40 2009 New Revision: 85997 URL: http://llvm.org/viewvc/llvm-project?rev=85997&view=rev Log: Another spurious friend declaration removed. Modified: llvm/trunk/include/llvm/CodeGen/SlotIndexes.h Modified: llvm/trunk/include/llvm/CodeGen/SlotIndexes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SlotIndexes.h?rev=85997&r1=85996&r2=85997&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/SlotIndexes.h (original) +++ llvm/trunk/include/llvm/CodeGen/SlotIndexes.h Tue Nov 3 19:52:40 2009 @@ -36,8 +36,6 @@ /// SlotIndex & SlotIndexes classes for the public interface to this /// information. class IndexListEntry { - friend class SlotIndex; - private: IndexListEntry *next, *prev; From evan.cheng at apple.com Tue Nov 3 21:08:58 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 04 Nov 2009 03:08:58 -0000 Subject: [llvm-commits] [llvm] r86000 - /llvm/trunk/include/llvm/Metadata.h Message-ID: <200911040308.nA438wxv008265@zion.cs.uiuc.edu> Author: evancheng Date: Tue Nov 3 21:08:57 2009 New Revision: 86000 URL: http://llvm.org/viewvc/llvm-project?rev=86000&view=rev Log: Silence implicit conversion warnings. Modified: llvm/trunk/include/llvm/Metadata.h Modified: llvm/trunk/include/llvm/Metadata.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Metadata.h?rev=86000&r1=85999&r2=86000&view=diff ============================================================================== --- llvm/trunk/include/llvm/Metadata.h (original) +++ llvm/trunk/include/llvm/Metadata.h Tue Nov 3 21:08:57 2009 @@ -63,7 +63,7 @@ StringRef getString() const { return Str; } - unsigned getLength() const { return Str.size(); } + unsigned getLength() const { return (unsigned)Str.size(); } typedef StringRef::iterator iterator; @@ -191,7 +191,7 @@ /// getNumElements - Return number of NamedMDNode elements. unsigned getNumElements() const { - return Node.size(); + return (unsigned)Node.size(); } /// addElement - Add metadata element. From deeppatel1987 at gmail.com Tue Nov 3 21:13:05 2009 From: deeppatel1987 at gmail.com (Sandeep Patel) Date: Wed, 4 Nov 2009 03:13:05 +0000 Subject: [llvm-commits] [llvm] r85980 - /llvm/trunk/lib/Target/ARM/ARMInstrThumb.td In-Reply-To: <200911040000.nA400e3u001866@zion.cs.uiuc.edu> References: <200911040000.nA400e3u001866@zion.cs.uiuc.edu> Message-ID: <305d6f60911031913j7f35487bwc6632536364f150d@mail.gmail.com> This broke arm-eabi. deep On Wed, Nov 4, 2009 at 12:00 AM, Evan Cheng wrote: > Author: evancheng > Date: Tue Nov ?3 18:00:39 2009 > New Revision: 85980 > > URL: http://llvm.org/viewvc/llvm-project?rev=85980&view=rev > Log: > Use ldr.n to workaround a darwin assembler bug. > > Modified: > ? ?llvm/trunk/lib/Target/ARM/ARMInstrThumb.td > > Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb.td > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb.td?rev=85980&r1=85979&r2=85980&view=diff > > ============================================================================== > --- llvm/trunk/lib/Target/ARM/ARMInstrThumb.td (original) > +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb.td Tue Nov ?3 18:00:39 2009 > @@ -326,9 +326,10 @@ > ? ? ? ? ? ? ? ? ? ? "ldr", "\t$dst, $addr", []>; > > ?// Load tconstpool > +// FIXME: Use ldr.n to work around a Darwin assembler bug. > ?let canFoldAsLoad = 1 in > ?def tLDRpci : T1pIs<(outs tGPR:$dst), (ins i32imm:$addr), IIC_iLoadi, > - ? ? ? ? ? ? ? ? ?"ldr", "\t$dst, $addr", > + ? ? ? ? ? ? ? ? ?"ldr.n", "\t$dst, $addr", > ? ? ? ? ? ? ? ? ? [(set tGPR:$dst, (load (ARMWrapper tconstpool:$addr)))]>; > > ?// Special LDR for loads from non-pc-relative constpools. > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From bob.wilson at apple.com Tue Nov 3 21:24:22 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 3 Nov 2009 19:24:22 -0800 Subject: [llvm-commits] [llvm] r85980 - /llvm/trunk/lib/Target/ARM/ARMInstrThumb.td In-Reply-To: <305d6f60911031913j7f35487bwc6632536364f150d@mail.gmail.com> References: <200911040000.nA400e3u001866@zion.cs.uiuc.edu> <305d6f60911031913j7f35487bwc6632536364f150d@mail.gmail.com> Message-ID: <0FB6BDEA-FF15-4C8E-98A9-9486A3D9383C@apple.com> How? testcase, etc.... On Nov 3, 2009, at 7:13 PM, Sandeep Patel wrote: > This broke arm-eabi. > > deep > > On Wed, Nov 4, 2009 at 12:00 AM, Evan Cheng wrote: >> Author: evancheng >> Date: Tue Nov 3 18:00:39 2009 >> New Revision: 85980 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=85980&view=rev >> Log: >> Use ldr.n to workaround a darwin assembler bug. >> >> Modified: >> llvm/trunk/lib/Target/ARM/ARMInstrThumb.td >> >> Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb.td >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb.td?rev=85980&r1=85979&r2=85980&view=diff >> >> ============================================================================== >> --- llvm/trunk/lib/Target/ARM/ARMInstrThumb.td (original) >> +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb.td Tue Nov 3 18:00:39 2009 >> @@ -326,9 +326,10 @@ >> "ldr", "\t$dst, $addr", []>; >> >> // Load tconstpool >> +// FIXME: Use ldr.n to work around a Darwin assembler bug. >> let canFoldAsLoad = 1 in >> def tLDRpci : T1pIs<(outs tGPR:$dst), (ins i32imm:$addr), IIC_iLoadi, >> - "ldr", "\t$dst, $addr", >> + "ldr.n", "\t$dst, $addr", >> [(set tGPR:$dst, (load (ARMWrapper tconstpool:$addr)))]>; >> >> // Special LDR for loads from non-pc-relative constpools. >> >> >> _______________________________________________ >> 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 deeppatel1987 at gmail.com Tue Nov 3 21:29:04 2009 From: deeppatel1987 at gmail.com (Sandeep Patel) Date: Wed, 4 Nov 2009 03:29:04 +0000 Subject: [llvm-commits] [llvm] r85980 - /llvm/trunk/lib/Target/ARM/ARMInstrThumb.td In-Reply-To: <0FB6BDEA-FF15-4C8E-98A9-9486A3D9383C@apple.com> References: <200911040000.nA400e3u001866@zion.cs.uiuc.edu> <305d6f60911031913j7f35487bwc6632536364f150d@mail.gmail.com> <0FB6BDEA-FF15-4C8E-98A9-9486A3D9383C@apple.com> Message-ID: <305d6f60911031929j1655f870ga414dfc30d14e75b@mail.gmail.com> ccOyyiCD.s:214: Error: bad instruction `ldr.nhi r1,.LCPI3_1' while building _gcov.c for the thumb multilib. We're working on a buildbot. deep On Wed, Nov 4, 2009 at 3:24 AM, Bob Wilson wrote: > How? ?testcase, etc.... > > On Nov 3, 2009, at 7:13 PM, Sandeep Patel wrote: > >> This broke arm-eabi. >> >> deep >> >> On Wed, Nov 4, 2009 at 12:00 AM, Evan Cheng wrote: >>> Author: evancheng >>> Date: Tue Nov ?3 18:00:39 2009 >>> New Revision: 85980 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=85980&view=rev >>> Log: >>> Use ldr.n to workaround a darwin assembler bug. >>> >>> Modified: >>> ? ?llvm/trunk/lib/Target/ARM/ARMInstrThumb.td >>> >>> Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb.td >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb.td?rev=85980&r1=85979&r2=85980&view=diff >>> >>> ============================================================================== >>> --- llvm/trunk/lib/Target/ARM/ARMInstrThumb.td (original) >>> +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb.td Tue Nov ?3 18:00:39 2009 >>> @@ -326,9 +326,10 @@ >>> ? ? ? ? ? ? ? ? ? ? "ldr", "\t$dst, $addr", []>; >>> >>> ?// Load tconstpool >>> +// FIXME: Use ldr.n to work around a Darwin assembler bug. >>> ?let canFoldAsLoad = 1 in >>> ?def tLDRpci : T1pIs<(outs tGPR:$dst), (ins i32imm:$addr), IIC_iLoadi, >>> - ? ? ? ? ? ? ? ? ?"ldr", "\t$dst, $addr", >>> + ? ? ? ? ? ? ? ? ?"ldr.n", "\t$dst, $addr", >>> ? ? ? ? ? ? ? ? ? [(set tGPR:$dst, (load (ARMWrapper tconstpool:$addr)))]>; >>> >>> ?// Special LDR for loads from non-pc-relative constpools. >>> >>> >>> _______________________________________________ >>> 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 daniel at zuster.org Tue Nov 3 22:32:50 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Wed, 04 Nov 2009 04:32:50 -0000 Subject: [llvm-commits] [llvm] r86005 - in /llvm/trunk: Makefile.config.in Makefile.rules autoconf/configure.ac configure Message-ID: <200911040432.nA44Wp3o011088@zion.cs.uiuc.edu> Author: ddunbar Date: Tue Nov 3 22:32:50 2009 New Revision: 86005 URL: http://llvm.org/viewvc/llvm-project?rev=86005&view=rev Log: configure: Add --with-optimize-option, for setting the default value of OPTIMIZE_OPTION. Modified: llvm/trunk/Makefile.config.in llvm/trunk/Makefile.rules llvm/trunk/autoconf/configure.ac llvm/trunk/configure Modified: llvm/trunk/Makefile.config.in URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/Makefile.config.in?rev=86005&r1=86004&r2=86005&view=diff ============================================================================== --- llvm/trunk/Makefile.config.in (original) +++ llvm/trunk/Makefile.config.in Tue Nov 3 22:32:50 2009 @@ -250,6 +250,9 @@ #DEBUG_SYMBOLS = 1 @DEBUG_SYMBOLS@ +# The compiler flags to use for optimized builds. +OPTIMIZE_OPTION := @OPTIMIZE_OPTION@ + # When ENABLE_PROFILING is enabled, the llvm source base is built with profile # information to allow gprof to be used to get execution frequencies. #ENABLE_PROFILING = 1 Modified: llvm/trunk/Makefile.rules URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/Makefile.rules?rev=86005&r1=86004&r2=86005&view=diff ============================================================================== --- llvm/trunk/Makefile.rules (original) +++ llvm/trunk/Makefile.rules Tue Nov 3 22:32:50 2009 @@ -312,16 +312,6 @@ #-------------------------------------------------------------------- CPP.Defines := -# OPTIMIZE_OPTION - The optimization level option we want to build LLVM with -# this can be overridden on the make command line. -ifndef OPTIMIZE_OPTION - ifneq ($(HOST_OS),MingW) - OPTIMIZE_OPTION := -O3 - else - OPTIMIZE_OPTION := -O2 - endif -endif - ifeq ($(ENABLE_OPTIMIZED),1) BuildMode := Release # Don't use -fomit-frame-pointer on Darwin or FreeBSD. Modified: llvm/trunk/autoconf/configure.ac URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/autoconf/configure.ac?rev=86005&r1=86004&r2=86005&view=diff ============================================================================== --- llvm/trunk/autoconf/configure.ac (original) +++ llvm/trunk/autoconf/configure.ac Tue Nov 3 22:32:50 2009 @@ -607,6 +607,23 @@ AC_MSG_ERROR([Invalid llvm-gcc. Use --with-llvmgcc when --with-llvmgxx is used]); fi +dnl Override the option to use for optimized builds. +AC_ARG_WITH(optimize-option, + AS_HELP_STRING([--with-optimize-option], + [Select the compiler options to use for optimized builds]),, + withval=default) +AC_MSG_CHECKING([optimization flags]) +case "$withval" in + default) + case "$llvm_cv_os_type" in + MingW) optimize_option=-O3 ;; + *) optimize_option=-O2 ;; + esac ;; + *) optimize_option="$withval" ;; +esac +AC_SUBST(OPTIMIZE_OPTION,$optimize_option) +AC_MSG_RESULT([$optimize_option]) + dnl Specify extra build options AC_ARG_WITH(extra-options, AS_HELP_STRING([--with-extra-options], Modified: llvm/trunk/configure URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/configure?rev=86005&r1=86004&r2=86005&view=diff ============================================================================== --- llvm/trunk/configure (original) +++ llvm/trunk/configure Tue Nov 3 22:32:50 2009 @@ -848,6 +848,7 @@ LLVM_ENUM_ASM_PRINTERS LLVM_ENUM_ASM_PARSERS ENABLE_CBE_PRINTF_A +OPTIMIZE_OPTION EXTRA_OPTIONS BINUTILS_INCDIR ENABLE_LLVMC_DYNAMIC @@ -1597,6 +1598,8 @@ searches PATH) --with-llvmgxx Specify location of llvm-g++ driver (default searches PATH) + --with-optimize-option Select the compiler options to use for optimized + builds --with-extra-options Specify additional options to compile LLVM with --with-ocaml-libdir Specify install location for ocaml bindings (default is stdlib) @@ -5192,6 +5195,29 @@ fi +# Check whether --with-optimize-option was given. +if test "${with_optimize_option+set}" = set; then + withval=$with_optimize_option; +else + withval=default +fi + +{ echo "$as_me:$LINENO: checking optimization flags" >&5 +echo $ECHO_N "checking optimization flags... $ECHO_C" >&6; } +case "$withval" in + default) + case "$llvm_cv_os_type" in + MingW) optimize_option=-O3 ;; + *) optimize_option=-O2 ;; + esac ;; + *) optimize_option="$withval" ;; +esac +OPTIMIZE_OPTION=$optimize_option + +{ echo "$as_me:$LINENO: result: $optimize_option" >&5 +echo "${ECHO_T}$optimize_option" >&6; } + + # Check whether --with-extra-options was given. if test "${with_extra_options+set}" = set; then withval=$with_extra_options; @@ -11010,7 +11036,7 @@ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext + echo '#line 13183 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -14872,11 +14898,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:14875: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14901: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:14879: \$? = $ac_status" >&5 + echo "$as_me:14905: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -15140,11 +15166,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:15143: $lt_compile\"" >&5) + (eval echo "\"\$as_me:15169: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:15147: \$? = $ac_status" >&5 + echo "$as_me:15173: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -15244,11 +15270,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:15247: $lt_compile\"" >&5) + (eval echo "\"\$as_me:15273: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:15251: \$? = $ac_status" >&5 + echo "$as_me:15277: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -17696,7 +17722,7 @@ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext <&5) + (eval echo "\"\$as_me:20193: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:20171: \$? = $ac_status" >&5 + echo "$as_me:20197: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -20268,11 +20294,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:20271: $lt_compile\"" >&5) + (eval echo "\"\$as_me:20297: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:20275: \$? = $ac_status" >&5 + echo "$as_me:20301: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -21838,11 +21864,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:21841: $lt_compile\"" >&5) + (eval echo "\"\$as_me:21867: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:21845: \$? = $ac_status" >&5 + echo "$as_me:21871: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -21942,11 +21968,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:21945: $lt_compile\"" >&5) + (eval echo "\"\$as_me:21971: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:21949: \$? = $ac_status" >&5 + echo "$as_me:21975: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -24177,11 +24203,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:24180: $lt_compile\"" >&5) + (eval echo "\"\$as_me:24206: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:24184: \$? = $ac_status" >&5 + echo "$as_me:24210: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -24445,11 +24471,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:24448: $lt_compile\"" >&5) + (eval echo "\"\$as_me:24474: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:24452: \$? = $ac_status" >&5 + echo "$as_me:24478: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -24549,11 +24575,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:24552: $lt_compile\"" >&5) + (eval echo "\"\$as_me:24578: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:24556: \$? = $ac_status" >&5 + echo "$as_me:24582: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -36072,11 +36098,11 @@ LLVM_ENUM_ASM_PRINTERS!$LLVM_ENUM_ASM_PRINTERS$ac_delim LLVM_ENUM_ASM_PARSERS!$LLVM_ENUM_ASM_PARSERS$ac_delim ENABLE_CBE_PRINTF_A!$ENABLE_CBE_PRINTF_A$ac_delim +OPTIMIZE_OPTION!$OPTIMIZE_OPTION$ac_delim EXTRA_OPTIONS!$EXTRA_OPTIONS$ac_delim BINUTILS_INCDIR!$BINUTILS_INCDIR$ac_delim ENABLE_LLVMC_DYNAMIC!$ENABLE_LLVMC_DYNAMIC$ac_delim ENABLE_LLVMC_DYNAMIC_PLUGINS!$ENABLE_LLVMC_DYNAMIC_PLUGINS$ac_delim -CXX!$CXX$ac_delim _ACEOF if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then @@ -36118,6 +36144,7 @@ ac_delim='%!_!# ' for ac_last_try in false false false false false :; do cat >conf$$subs.sed <<_ACEOF +CXX!$CXX$ac_delim CXXFLAGS!$CXXFLAGS$ac_delim ac_ct_CXX!$ac_ct_CXX$ac_delim NM!$NM$ac_delim @@ -36214,7 +36241,7 @@ LTLIBOBJS!$LTLIBOBJS$ac_delim _ACEOF - if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 94; then + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 95; then break elif $ac_last_try; then { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 From sabre at nondot.org Tue Nov 3 23:00:13 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 04 Nov 2009 05:00:13 -0000 Subject: [llvm-commits] [llvm] r86006 - /llvm/trunk/include/llvm/Support/IRBuilder.h Message-ID: <200911040500.nA450Eqp011960@zion.cs.uiuc.edu> Author: lattner Date: Tue Nov 3 23:00:12 2009 New Revision: 86006 URL: http://llvm.org/viewvc/llvm-project?rev=86006&view=rev Log: make IRBuilder zap "X|0" and "X&-1" when building IR, this happens during bitfield codegen and slows down -O0 compile times by making useless IR. rdar://7362516 Modified: llvm/trunk/include/llvm/Support/IRBuilder.h Modified: llvm/trunk/include/llvm/Support/IRBuilder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/IRBuilder.h?rev=86006&r1=86005&r2=86006&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/IRBuilder.h (original) +++ llvm/trunk/include/llvm/Support/IRBuilder.h Tue Nov 3 23:00:12 2009 @@ -390,15 +390,21 @@ return Insert(BinaryOperator::CreateAShr(LHS, RHS), Name); } Value *CreateAnd(Value *LHS, Value *RHS, const Twine &Name = "") { - if (Constant *LC = dyn_cast(LHS)) - if (Constant *RC = dyn_cast(RHS)) + if (Constant *RC = dyn_cast(RHS)) { + if (isa(RC) && cast(RC)->isAllOnesValue()) + return LHS; // LHS & -1 -> LHS + if (Constant *LC = dyn_cast(LHS)) return Folder.CreateAnd(LC, RC); + } return Insert(BinaryOperator::CreateAnd(LHS, RHS), Name); } Value *CreateOr(Value *LHS, Value *RHS, const Twine &Name = "") { - if (Constant *LC = dyn_cast(LHS)) - if (Constant *RC = dyn_cast(RHS)) + if (Constant *RC = dyn_cast(RHS)) { + if (RC->isNullValue()) + return LHS; // LHS | 0 -> LHS + if (Constant *LC = dyn_cast(LHS)) return Folder.CreateOr(LC, RC); + } return Insert(BinaryOperator::CreateOr(LHS, RHS), Name); } Value *CreateXor(Value *LHS, Value *RHS, const Twine &Name = "") { From nicholas at mxc.ca Wed Nov 4 00:15:28 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Wed, 04 Nov 2009 06:15:28 -0000 Subject: [llvm-commits] [llvm] r86009 - /llvm/trunk/docs/GettingStarted.html Message-ID: <200911040615.nA46FStr014546@zion.cs.uiuc.edu> Author: nicholas Date: Wed Nov 4 00:15:28 2009 New Revision: 86009 URL: http://llvm.org/viewvc/llvm-project?rev=86009&view=rev Log: The magic for our current brand of .bc files is BC. For older ones it was llvc. When was it ever "llvm"? Modified: llvm/trunk/docs/GettingStarted.html Modified: llvm/trunk/docs/GettingStarted.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/GettingStarted.html?rev=86009&r1=86008&r2=86009&view=diff ============================================================================== --- llvm/trunk/docs/GettingStarted.html (original) +++ llvm/trunk/docs/GettingStarted.html Wed Nov 4 00:15:28 2009 @@ -1154,7 +1154,7 @@

                           $ mount -t binfmt_misc none /proc/sys/fs/binfmt_misc
                          -$ echo ':llvm:M::llvm::/path/to/lli:' > /proc/sys/fs/binfmt_misc/register
                          +$ echo ':llvm:M::BC::/path/to/lli:' > /proc/sys/fs/binfmt_misc/register
                           $ chmod u+x hello.bc   (if needed)
                           $ ./hello.bc
                           
                          From sabre at nondot.org Wed Nov 4 00:24:41 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 04 Nov 2009 06:24:41 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r86012 - /llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Message-ID: <200911040624.nA46OfI1014936@zion.cs.uiuc.edu> Author: lattner Date: Wed Nov 4 00:24:41 2009 New Revision: 86012 URL: http://llvm.org/viewvc/llvm-project?rev=86012&view=rev Log: tidy up Modified: llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-types.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-types.cpp?rev=86012&r1=86011&r2=86012&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-types.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Wed Nov 4 00:24:41 2009 @@ -654,15 +654,11 @@ /// GetFieldIndex - Returns the index of the LLVM field corresponding to /// this FIELD_DECL, or ~0U if the type the field belongs to has not yet /// been converted. -unsigned int TypeConverter::GetFieldIndex(tree_node *field_decl) { +unsigned int TypeConverter::GetFieldIndex(tree field_decl) { assert(TREE_CODE(field_decl) == FIELD_DECL && "Not a FIELD_DECL!"); std::map::iterator I = FieldIndexMap.find(field_decl); - if (I != FieldIndexMap.end()) { - return I->second; - } else { - assert(false && "Type not laid out for LLVM?"); - return ~0U; - } + assert(I != FieldIndexMap.end() && "Type not laid out for LLVM?"); + return I->second; } /// SetFieldIndex - Set the index of the LLVM field corresponding to From evan.cheng at apple.com Wed Nov 4 01:38:48 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 04 Nov 2009 07:38:48 -0000 Subject: [llvm-commits] [llvm] r86019 - /llvm/trunk/lib/Target/ARM/ARMInstrThumb.td Message-ID: <200911040738.nA47cm8m017413@zion.cs.uiuc.edu> Author: evancheng Date: Wed Nov 4 01:38:48 2009 New Revision: 86019 URL: http://llvm.org/viewvc/llvm-project?rev=86019&view=rev Log: The .n suffix must go after the predicate. Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb.td?rev=86019&r1=86018&r2=86019&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb.td Wed Nov 4 01:38:48 2009 @@ -329,7 +329,7 @@ // FIXME: Use ldr.n to work around a Darwin assembler bug. let canFoldAsLoad = 1 in def tLDRpci : T1pIs<(outs tGPR:$dst), (ins i32imm:$addr), IIC_iLoadi, - "ldr.n", "\t$dst, $addr", + "ldr", ".n\t$dst, $addr", [(set tGPR:$dst, (load (ARMWrapper tconstpool:$addr)))]>; // Special LDR for loads from non-pc-relative constpools. From evan.cheng at apple.com Wed Nov 4 01:53:29 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 3 Nov 2009 23:53:29 -0800 Subject: [llvm-commits] [llvm] r85980 - /llvm/trunk/lib/Target/ARM/ARMInstrThumb.td In-Reply-To: <305d6f60911031929j1655f870ga414dfc30d14e75b@mail.gmail.com> References: <200911040000.nA400e3u001866@zion.cs.uiuc.edu> <305d6f60911031913j7f35487bwc6632536364f150d@mail.gmail.com> <0FB6BDEA-FF15-4C8E-98A9-9486A3D9383C@apple.com> <305d6f60911031929j1655f870ga414dfc30d14e75b@mail.gmail.com> Message-ID: Fixed. Evan On Nov 3, 2009, at 7:29 PM, Sandeep Patel wrote: > ccOyyiCD.s:214: Error: bad instruction `ldr.nhi r1,.LCPI3_1' > > while building _gcov.c for the thumb multilib. > > We're working on a buildbot. > > deep > > On Wed, Nov 4, 2009 at 3:24 AM, Bob Wilson > wrote: >> How? testcase, etc.... >> >> On Nov 3, 2009, at 7:13 PM, Sandeep Patel wrote: >> >>> This broke arm-eabi. >>> >>> deep >>> >>> On Wed, Nov 4, 2009 at 12:00 AM, Evan Cheng >>> wrote: >>>> Author: evancheng >>>> Date: Tue Nov 3 18:00:39 2009 >>>> New Revision: 85980 >>>> >>>> URL: http://llvm.org/viewvc/llvm-project?rev=85980&view=rev >>>> Log: >>>> Use ldr.n to workaround a darwin assembler bug. >>>> >>>> Modified: >>>> llvm/trunk/lib/Target/ARM/ARMInstrThumb.td >>>> >>>> Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb.td >>>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb.td?rev=85980&r1=85979&r2=85980&view=diff >>>> >>>> = >>>> = >>>> = >>>> = >>>> = >>>> = >>>> = >>>> = >>>> = >>>> = >>>> = >>>> =================================================================== >>>> --- llvm/trunk/lib/Target/ARM/ARMInstrThumb.td (original) >>>> +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb.td Tue Nov 3 >>>> 18:00:39 2009 >>>> @@ -326,9 +326,10 @@ >>>> "ldr", "\t$dst, $addr", []>; >>>> >>>> // Load tconstpool >>>> +// FIXME: Use ldr.n to work around a Darwin assembler bug. >>>> let canFoldAsLoad = 1 in >>>> def tLDRpci : T1pIs<(outs tGPR:$dst), (ins i32imm:$addr), >>>> IIC_iLoadi, >>>> - "ldr", "\t$dst, $addr", >>>> + "ldr.n", "\t$dst, $addr", >>>> [(set tGPR:$dst, (load (ARMWrapper tconstpool: >>>> $addr)))]>; >>>> >>>> // Special LDR for loads from non-pc-relative constpools. >>>> >>>> >>>> _______________________________________________ >>>> 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 Wed Nov 4 01:57:05 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 04 Nov 2009 07:57:05 -0000 Subject: [llvm-commits] [llvm] r86020 - /llvm/trunk/test/Transforms/InstCombine/sub.ll Message-ID: <200911040757.nA47v5mI017975@zion.cs.uiuc.edu> Author: lattner Date: Wed Nov 4 01:57:05 2009 New Revision: 86020 URL: http://llvm.org/viewvc/llvm-project?rev=86020&view=rev Log: filecheckize this test. Modified: llvm/trunk/test/Transforms/InstCombine/sub.ll Modified: llvm/trunk/test/Transforms/InstCombine/sub.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/sub.ll?rev=86020&r1=86019&r2=86020&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/sub.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/sub.ll Wed Nov 4 01:57:05 2009 @@ -1,148 +1,213 @@ ; This test makes sure that these instructions are properly eliminated. ; -; RUN: opt < %s -instcombine -S | \ -; RUN: grep -v {sub i32 %Cok, %Bok} | grep -v {sub i32 0, %Aok} | not grep sub +; RUN: opt < %s -instcombine -S | FileCheck %s define i32 @test1(i32 %A) { - %B = sub i32 %A, %A ; [#uses=1] + %B = sub i32 %A, %A ret i32 %B +; CHECK: @test1 +; CHECK: ret i32 0 } define i32 @test2(i32 %A) { - %B = sub i32 %A, 0 ; [#uses=1] + %B = sub i32 %A, 0 ret i32 %B +; CHECK: @test2 +; CHECK: ret i32 %A } define i32 @test3(i32 %A) { - %B = sub i32 0, %A ; [#uses=1] - %C = sub i32 0, %B ; [#uses=1] + %B = sub i32 0, %A + %C = sub i32 0, %B ret i32 %C +; CHECK: @test3 +; CHECK: ret i32 %A } define i32 @test4(i32 %A, i32 %x) { - %B = sub i32 0, %A ; [#uses=1] - %C = sub i32 %x, %B ; [#uses=1] + %B = sub i32 0, %A + %C = sub i32 %x, %B ret i32 %C +; CHECK: @test4 +; CHECK: %C = add i32 %x, %A +; CHECK: ret i32 %C } -define i32 @test5(i32 %A, i32 %Bok, i32 %Cok) { - %D = sub i32 %Bok, %Cok ; [#uses=1] - %E = sub i32 %A, %D ; [#uses=1] +define i32 @test5(i32 %A, i32 %B, i32 %C) { + %D = sub i32 %B, %C + %E = sub i32 %A, %D ret i32 %E +; CHECK: @test5 +; CHECK: %D = sub i32 %C, %B +; CHECK: %E = add +; CHECK: ret i32 %E } define i32 @test6(i32 %A, i32 %B) { - %C = and i32 %A, %B ; [#uses=1] - %D = sub i32 %A, %C ; [#uses=1] + %C = and i32 %A, %B + %D = sub i32 %A, %C ret i32 %D +; CHECK: @test6 +; CHECK-NEXT: xor i32 %B, -1 +; CHECK-NEXT: %D = and i32 +; CHECK-NEXT: ret i32 %D } define i32 @test7(i32 %A) { - %B = sub i32 -1, %A ; [#uses=1] + %B = sub i32 -1, %A ret i32 %B +; CHECK: @test7 +; CHECK: %B = xor i32 %A, -1 +; CHECK: ret i32 %B } define i32 @test8(i32 %A) { - %B = mul i32 9, %A ; [#uses=1] - %C = sub i32 %B, %A ; [#uses=1] + %B = mul i32 9, %A + %C = sub i32 %B, %A ret i32 %C +; CHECK: @test8 +; CHECK: %C = shl i32 %A, 3 +; CHECK: ret i32 %C } define i32 @test9(i32 %A) { - %B = mul i32 3, %A ; [#uses=1] - %C = sub i32 %A, %B ; [#uses=1] + %B = mul i32 3, %A + %C = sub i32 %A, %B ret i32 %C +; CHECK: @test9 +; CHECK: %C = mul i32 %A, -2 +; CHECK: ret i32 %C } define i32 @test10(i32 %A, i32 %B) { - %C = sub i32 0, %A ; [#uses=1] - %D = sub i32 0, %B ; [#uses=1] - %E = mul i32 %C, %D ; [#uses=1] + %C = sub i32 0, %A + %D = sub i32 0, %B + %E = mul i32 %C, %D ret i32 %E +; CHECK: @test10 +; CHECK: %E = mul i32 %A, %B +; CHECK: ret i32 %E } -define i32 @test10.upgrd.1(i32 %A) { - %C = sub i32 0, %A ; [#uses=1] - %E = mul i32 %C, 7 ; [#uses=1] +define i32 @test10a(i32 %A) { + %C = sub i32 0, %A + %E = mul i32 %C, 7 ret i32 %E +; CHECK: @test10a +; CHECK: %E = mul i32 %A, -7 +; CHECK: ret i32 %E } define i1 @test11(i8 %A, i8 %B) { - %C = sub i8 %A, %B ; [#uses=1] - %cD = icmp ne i8 %C, 0 ; [#uses=1] + %C = sub i8 %A, %B + %cD = icmp ne i8 %C, 0 ret i1 %cD +; CHECK: @test11 +; CHECK: %cD = icmp ne i8 %A, %B +; CHECK: ret i1 %cD } define i32 @test12(i32 %A) { - %B = ashr i32 %A, 31 ; [#uses=1] - %C = sub i32 0, %B ; [#uses=1] + %B = ashr i32 %A, 31 + %C = sub i32 0, %B ret i32 %C +; CHECK: @test12 +; CHECK: %C = lshr i32 %A, 31 +; CHECK: ret i32 %C } define i32 @test13(i32 %A) { - %B = lshr i32 %A, 31 ; [#uses=1] - %C = sub i32 0, %B ; [#uses=1] + %B = lshr i32 %A, 31 + %C = sub i32 0, %B ret i32 %C +; CHECK: @test13 +; CHECK: %C = ashr i32 %A, 31 +; CHECK: ret i32 %C } define i32 @test14(i32 %A) { - %B = lshr i32 %A, 31 ; [#uses=1] - %C = bitcast i32 %B to i32 ; [#uses=1] - %D = sub i32 0, %C ; [#uses=1] + %B = lshr i32 %A, 31 + %C = bitcast i32 %B to i32 + %D = sub i32 0, %C ret i32 %D +; CHECK: @test14 +; CHECK: %D = ashr i32 %A, 31 +; CHECK: ret i32 %D } define i32 @test15(i32 %A, i32 %B) { - %C = sub i32 0, %A ; [#uses=1] - %D = srem i32 %B, %C ; [#uses=1] + %C = sub i32 0, %A + %D = srem i32 %B, %C ret i32 %D +; CHECK: @test15 +; CHECK: %D = srem i32 %B, %A +; CHECK: ret i32 %D } define i32 @test16(i32 %A) { - %X = sdiv i32 %A, 1123 ; [#uses=1] - %Y = sub i32 0, %X ; [#uses=1] + %X = sdiv i32 %A, 1123 + %Y = sub i32 0, %X ret i32 %Y +; CHECK: @test16 +; CHECK: %Y = sdiv i32 %A, -1123 +; CHECK: ret i32 %Y } ; Can't fold subtract here because negation it might oveflow. ; PR3142 -define i32 @test17(i32 %Aok) { - %B = sub i32 0, %Aok ; [#uses=1] - %C = sdiv i32 %B, 1234 ; [#uses=1] - ret i32 %C +define i32 @test17(i32 %A) { + %B = sub i32 0, %A + %C = sdiv i32 %B, 1234 + ret i32 %C +; CHECK: @test17 +; CHECK: %B = sub i32 0, %A +; CHECK: %C = sdiv i32 %B, 1234 +; CHECK: ret i32 %C } define i64 @test18(i64 %Y) { - %tmp.4 = shl i64 %Y, 2 ; [#uses=1] - %tmp.12 = shl i64 %Y, 2 ; [#uses=1] - %tmp.8 = sub i64 %tmp.4, %tmp.12 ; [#uses=1] + %tmp.4 = shl i64 %Y, 2 + %tmp.12 = shl i64 %Y, 2 + %tmp.8 = sub i64 %tmp.4, %tmp.12 ret i64 %tmp.8 +; CHECK: @test18 +; CHECK: ret i64 0 } define i32 @test19(i32 %X, i32 %Y) { - %Z = sub i32 %X, %Y ; [#uses=1] - %Q = add i32 %Z, %Y ; [#uses=1] + %Z = sub i32 %X, %Y + %Q = add i32 %Z, %Y ret i32 %Q +; CHECK: @test19 +; CHECK: ret i32 %X } define i1 @test20(i32 %g, i32 %h) { - %tmp.2 = sub i32 %g, %h ; [#uses=1] - %tmp.4 = icmp ne i32 %tmp.2, %g ; [#uses=1] + %tmp.2 = sub i32 %g, %h + %tmp.4 = icmp ne i32 %tmp.2, %g ret i1 %tmp.4 +; CHECK: @test20 +; CHECK: %tmp.4 = icmp ne i32 %h, 0 +; CHECK: ret i1 %tmp.4 } define i1 @test21(i32 %g, i32 %h) { - %tmp.2 = sub i32 %g, %h ; [#uses=1] - %tmp.4 = icmp ne i32 %tmp.2, %g ; [#uses=1] - ret i1 %tmp.4 + %tmp.2 = sub i32 %g, %h + %tmp.4 = icmp ne i32 %tmp.2, %g + ret i1 %tmp.4 +; CHECK: @test21 +; CHECK: %tmp.4 = icmp ne i32 %h, 0 +; CHECK: ret i1 %tmp.4 } ; PR2298 -define i8 @test22(i32 %a, i32 %b) zeroext nounwind { - %tmp2 = sub i32 0, %a ; [#uses=1] - %tmp4 = sub i32 0, %b ; [#uses=1] - %tmp5 = icmp eq i32 %tmp2, %tmp4 ; [#uses=1] - %retval89 = zext i1 %tmp5 to i8 ; [#uses=1] - ret i8 %retval89 +define i1 @test22(i32 %a, i32 %b) zeroext nounwind { + %tmp2 = sub i32 0, %a + %tmp4 = sub i32 0, %b + %tmp5 = icmp eq i32 %tmp2, %tmp4 + ret i1 %tmp5 +; CHECK: @test22 +; CHECK: %tmp5 = icmp eq i32 %a, %b +; CHECK: ret i1 %tmp5 } From sabre at nondot.org Wed Nov 4 02:05:21 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 04 Nov 2009 08:05:21 -0000 Subject: [llvm-commits] [llvm] r86021 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/sub.ll Message-ID: <200911040805.nA485LdL018303@zion.cs.uiuc.edu> Author: lattner Date: Wed Nov 4 02:05:20 2009 New Revision: 86021 URL: http://llvm.org/viewvc/llvm-project?rev=86021&view=rev Log: move two functions up higher in the file. Delete a useless argument to EmitGEPOffset. Implement some new transforms for optimizing subtracts of two pointer to ints into the same vector. This happens for C++ iterator idioms for example, stringmap takes a const char* that points to the start and end of a string. Once inlined, we want the pointer difference to turn back into a length. This is rdar://7362831. Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp llvm/trunk/test/Transforms/InstCombine/sub.ll Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=86021&r1=86020&r2=86021&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Wed Nov 4 02:05:20 2009 @@ -217,6 +217,7 @@ // Instruction *visitAdd(BinaryOperator &I); Instruction *visitFAdd(BinaryOperator &I); + Value *OptimizePointerDifference(Value *LHS, Value *RHS, const Type *Ty); Instruction *visitSub(BinaryOperator &I); Instruction *visitFSub(BinaryOperator &I); Instruction *visitMul(BinaryOperator &I); @@ -2510,7 +2511,7 @@ RHSConv->getOperand(0))) { // Insert the new integer add. Value *NewAdd = Builder->CreateNSWAdd(LHSConv->getOperand(0), - RHSConv->getOperand(0), "addconv"); + RHSConv->getOperand(0),"addconv"); return new SIToFPInst(NewAdd, I.getType()); } } @@ -2519,13 +2520,210 @@ return Changed ? &I : 0; } + +/// EmitGEPOffset - Given a getelementptr instruction/constantexpr, emit the +/// code necessary to compute the offset from the base pointer (without adding +/// in the base pointer). Return the result as a signed integer of intptr size. +static Value *EmitGEPOffset(User *GEP, InstCombiner &IC) { + TargetData &TD = *IC.getTargetData(); + gep_type_iterator GTI = gep_type_begin(GEP); + const Type *IntPtrTy = TD.getIntPtrType(GEP->getContext()); + Value *Result = Constant::getNullValue(IntPtrTy); + + // Build a mask for high order bits. + unsigned IntPtrWidth = TD.getPointerSizeInBits(); + uint64_t PtrSizeMask = ~0ULL >> (64-IntPtrWidth); + + for (User::op_iterator i = GEP->op_begin() + 1, e = GEP->op_end(); i != e; + ++i, ++GTI) { + Value *Op = *i; + uint64_t Size = TD.getTypeAllocSize(GTI.getIndexedType()) & PtrSizeMask; + if (ConstantInt *OpC = dyn_cast(Op)) { + if (OpC->isZero()) continue; + + // Handle a struct index, which adds its field offset to the pointer. + if (const StructType *STy = dyn_cast(*GTI)) { + Size = TD.getStructLayout(STy)->getElementOffset(OpC->getZExtValue()); + + Result = IC.Builder->CreateAdd(Result, + ConstantInt::get(IntPtrTy, Size), + GEP->getName()+".offs"); + continue; + } + + Constant *Scale = ConstantInt::get(IntPtrTy, Size); + Constant *OC = + ConstantExpr::getIntegerCast(OpC, IntPtrTy, true /*SExt*/); + Scale = ConstantExpr::getMul(OC, Scale); + // Emit an add instruction. + Result = IC.Builder->CreateAdd(Result, Scale, GEP->getName()+".offs"); + continue; + } + // Convert to correct type. + if (Op->getType() != IntPtrTy) + Op = IC.Builder->CreateIntCast(Op, IntPtrTy, true, Op->getName()+".c"); + if (Size != 1) { + Constant *Scale = ConstantInt::get(IntPtrTy, Size); + // We'll let instcombine(mul) convert this to a shl if possible. + Op = IC.Builder->CreateMul(Op, Scale, GEP->getName()+".idx"); + } + + // Emit an add instruction. + Result = IC.Builder->CreateAdd(Op, Result, GEP->getName()+".offs"); + } + return Result; +} + + +/// EvaluateGEPOffsetExpression - Return a value that can be used to compare +/// the *offset* implied by a GEP to zero. For example, if we have &A[i], we +/// want to return 'i' for "icmp ne i, 0". Note that, in general, indices can +/// be complex, and scales are involved. The above expression would also be +/// legal to codegen as "icmp ne (i*4), 0" (assuming A is a pointer to i32). +/// This later form is less amenable to optimization though, and we are allowed +/// to generate the first by knowing that pointer arithmetic doesn't overflow. +/// +/// If we can't emit an optimized form for this expression, this returns null. +/// +static Value *EvaluateGEPOffsetExpression(User *GEP, Instruction &I, + InstCombiner &IC) { + TargetData &TD = *IC.getTargetData(); + gep_type_iterator GTI = gep_type_begin(GEP); + + // Check to see if this gep only has a single variable index. If so, and if + // any constant indices are a multiple of its scale, then we can compute this + // in terms of the scale of the variable index. For example, if the GEP + // implies an offset of "12 + i*4", then we can codegen this as "3 + i", + // because the expression will cross zero at the same point. + unsigned i, e = GEP->getNumOperands(); + int64_t Offset = 0; + for (i = 1; i != e; ++i, ++GTI) { + if (ConstantInt *CI = dyn_cast(GEP->getOperand(i))) { + // Compute the aggregate offset of constant indices. + if (CI->isZero()) continue; + + // Handle a struct index, which adds its field offset to the pointer. + if (const StructType *STy = dyn_cast(*GTI)) { + Offset += TD.getStructLayout(STy)->getElementOffset(CI->getZExtValue()); + } else { + uint64_t Size = TD.getTypeAllocSize(GTI.getIndexedType()); + Offset += Size*CI->getSExtValue(); + } + } else { + // Found our variable index. + break; + } + } + + // If there are no variable indices, we must have a constant offset, just + // evaluate it the general way. + if (i == e) return 0; + + Value *VariableIdx = GEP->getOperand(i); + // Determine the scale factor of the variable element. For example, this is + // 4 if the variable index is into an array of i32. + uint64_t VariableScale = TD.getTypeAllocSize(GTI.getIndexedType()); + + // Verify that there are no other variable indices. If so, emit the hard way. + for (++i, ++GTI; i != e; ++i, ++GTI) { + ConstantInt *CI = dyn_cast(GEP->getOperand(i)); + if (!CI) return 0; + + // Compute the aggregate offset of constant indices. + if (CI->isZero()) continue; + + // Handle a struct index, which adds its field offset to the pointer. + if (const StructType *STy = dyn_cast(*GTI)) { + Offset += TD.getStructLayout(STy)->getElementOffset(CI->getZExtValue()); + } else { + uint64_t Size = TD.getTypeAllocSize(GTI.getIndexedType()); + Offset += Size*CI->getSExtValue(); + } + } + + // Okay, we know we have a single variable index, which must be a + // pointer/array/vector index. If there is no offset, life is simple, return + // the index. + unsigned IntPtrWidth = TD.getPointerSizeInBits(); + if (Offset == 0) { + // Cast to intptrty in case a truncation occurs. If an extension is needed, + // we don't need to bother extending: the extension won't affect where the + // computation crosses zero. + if (VariableIdx->getType()->getPrimitiveSizeInBits() > IntPtrWidth) + VariableIdx = new TruncInst(VariableIdx, + TD.getIntPtrType(VariableIdx->getContext()), + VariableIdx->getName(), &I); + return VariableIdx; + } + + // Otherwise, there is an index. The computation we will do will be modulo + // the pointer size, so get it. + uint64_t PtrSizeMask = ~0ULL >> (64-IntPtrWidth); + + Offset &= PtrSizeMask; + VariableScale &= PtrSizeMask; + + // To do this transformation, any constant index must be a multiple of the + // variable scale factor. For example, we can evaluate "12 + 4*i" as "3 + i", + // but we can't evaluate "10 + 3*i" in terms of i. Check that the offset is a + // multiple of the variable scale. + int64_t NewOffs = Offset / (int64_t)VariableScale; + if (Offset != NewOffs*(int64_t)VariableScale) + return 0; + + // Okay, we can do this evaluation. Start by converting the index to intptr. + const Type *IntPtrTy = TD.getIntPtrType(VariableIdx->getContext()); + if (VariableIdx->getType() != IntPtrTy) + VariableIdx = CastInst::CreateIntegerCast(VariableIdx, IntPtrTy, + true /*SExt*/, + VariableIdx->getName(), &I); + Constant *OffsetVal = ConstantInt::get(IntPtrTy, NewOffs); + return BinaryOperator::CreateAdd(VariableIdx, OffsetVal, "offset", &I); +} + + +/// Optimize pointer differences into the same array into a size. Consider: +/// &A[10] - &A[0]: we should compile this to "10". LHS/RHS are the pointer +/// operands to the ptrtoint instructions for the LHS/RHS of the subtract. +/// +Value *InstCombiner::OptimizePointerDifference(Value *LHS, Value *RHS, + const Type *Ty) { + assert(TD && "Must have target data info for this"); + + // If LHS is a gep based on RHS or RHS is a gep based on LHS, we can optimize + // this. + bool Swapped; + GetElementPtrInst *GEP; + + if ((GEP = dyn_cast(LHS)) && + GEP->getOperand(0) == RHS) + Swapped = false; + else if ((GEP = dyn_cast(RHS)) && + GEP->getOperand(0) == LHS) + Swapped = true; + else + return 0; + + // TODO: Could also optimize &A[i] - &A[j] -> "i-j". + + // Emit the offset of the GEP and an intptr_t. + Value *Result = EmitGEPOffset(GEP, *this); + + // If we have p - gep(p, ...) then we have to negate the result. + if (Swapped) + Result = Builder->CreateNeg(Result, "diff.neg"); + + return Builder->CreateIntCast(Result, Ty, true); +} + + Instruction *InstCombiner::visitSub(BinaryOperator &I) { Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1); if (Op0 == Op1) // sub X, X -> 0 return ReplaceInstUsesWith(I, Constant::getNullValue(I.getType())); - // If this is a 'B = x-(-A)', change to B = x+A... + // If this is a 'B = x-(-A)', change to B = x+A. if (Value *V = dyn_castNegVal(Op1)) return BinaryOperator::CreateAdd(Op0, V); @@ -2533,9 +2731,11 @@ return ReplaceInstUsesWith(I, Op0); // undef - X -> undef if (isa(Op1)) return ReplaceInstUsesWith(I, Op1); // X - undef -> undef - + if (I.getType() == Type::getInt1Ty(*Context)) + return BinaryOperator::CreateXor(Op0, Op1); + if (ConstantInt *C = dyn_cast(Op0)) { - // Replace (-1 - A) with (~A)... + // Replace (-1 - A) with (~A). if (C->isAllOnesValue()) return BinaryOperator::CreateNot(Op1); @@ -2558,8 +2758,7 @@ SI->getOperand(0), CU, SI->getName()); } } - } - else if (SI->getOpcode() == Instruction::AShr) { + } else if (SI->getOpcode() == Instruction::AShr) { if (ConstantInt *CU = dyn_cast(SI->getOperand(1))) { // Check to see if we are shifting out everything but the sign bit. if (CU->getLimitedValue(SI->getType()->getPrimitiveSizeInBits()) == @@ -2584,9 +2783,6 @@ return SelectInst::Create(ZI->getOperand(0), SubOne(C), C); } - if (I.getType() == Type::getInt1Ty(*Context)) - return BinaryOperator::CreateXor(Op0, Op1); - if (BinaryOperator *Op1I = dyn_cast(Op1)) { if (Op1I->getOpcode() == Instruction::Add) { if (Op1I->getOperand(0) == Op0) // X-(X+Y) == -Y @@ -2668,6 +2864,28 @@ if (X == dyn_castFoldableMul(Op1, C2)) return BinaryOperator::CreateMul(X, ConstantExpr::getSub(C1, C2)); } + + // Optimize pointer differences into the same array into a size. Consider: + // &A[10] - &A[0]: we should compile this to "10". + if (TD) { + if (PtrToIntInst *LHS = dyn_cast(Op0)) + if (PtrToIntInst *RHS = dyn_cast(Op1)) + if (Value *Res = OptimizePointerDifference(LHS->getOperand(0), + RHS->getOperand(0), + I.getType())) + return ReplaceInstUsesWith(I, Res); + + // trunc(p)-trunc(q) -> trunc(p-q) + if (TruncInst *LHST = dyn_cast(Op0)) + if (TruncInst *RHST = dyn_cast(Op1)) + if (PtrToIntInst *LHS = dyn_cast(LHST->getOperand(0))) + if (PtrToIntInst *RHS = dyn_cast(RHST->getOperand(0))) + if (Value *Res = OptimizePointerDifference(LHS->getOperand(0), + RHS->getOperand(0), + I.getType())) + return ReplaceInstUsesWith(I, Res); + } + return 0; } @@ -5417,166 +5635,6 @@ IsSigned); } -/// EmitGEPOffset - Given a getelementptr instruction/constantexpr, emit the -/// code necessary to compute the offset from the base pointer (without adding -/// in the base pointer). Return the result as a signed integer of intptr size. -static Value *EmitGEPOffset(User *GEP, Instruction &I, InstCombiner &IC) { - TargetData &TD = *IC.getTargetData(); - gep_type_iterator GTI = gep_type_begin(GEP); - const Type *IntPtrTy = TD.getIntPtrType(I.getContext()); - Value *Result = Constant::getNullValue(IntPtrTy); - - // Build a mask for high order bits. - unsigned IntPtrWidth = TD.getPointerSizeInBits(); - uint64_t PtrSizeMask = ~0ULL >> (64-IntPtrWidth); - - for (User::op_iterator i = GEP->op_begin() + 1, e = GEP->op_end(); i != e; - ++i, ++GTI) { - Value *Op = *i; - uint64_t Size = TD.getTypeAllocSize(GTI.getIndexedType()) & PtrSizeMask; - if (ConstantInt *OpC = dyn_cast(Op)) { - if (OpC->isZero()) continue; - - // Handle a struct index, which adds its field offset to the pointer. - if (const StructType *STy = dyn_cast(*GTI)) { - Size = TD.getStructLayout(STy)->getElementOffset(OpC->getZExtValue()); - - Result = IC.Builder->CreateAdd(Result, - ConstantInt::get(IntPtrTy, Size), - GEP->getName()+".offs"); - continue; - } - - Constant *Scale = ConstantInt::get(IntPtrTy, Size); - Constant *OC = - ConstantExpr::getIntegerCast(OpC, IntPtrTy, true /*SExt*/); - Scale = ConstantExpr::getMul(OC, Scale); - // Emit an add instruction. - Result = IC.Builder->CreateAdd(Result, Scale, GEP->getName()+".offs"); - continue; - } - // Convert to correct type. - if (Op->getType() != IntPtrTy) - Op = IC.Builder->CreateIntCast(Op, IntPtrTy, true, Op->getName()+".c"); - if (Size != 1) { - Constant *Scale = ConstantInt::get(IntPtrTy, Size); - // We'll let instcombine(mul) convert this to a shl if possible. - Op = IC.Builder->CreateMul(Op, Scale, GEP->getName()+".idx"); - } - - // Emit an add instruction. - Result = IC.Builder->CreateAdd(Op, Result, GEP->getName()+".offs"); - } - return Result; -} - - -/// EvaluateGEPOffsetExpression - Return a value that can be used to compare -/// the *offset* implied by a GEP to zero. For example, if we have &A[i], we -/// want to return 'i' for "icmp ne i, 0". Note that, in general, indices can -/// be complex, and scales are involved. The above expression would also be -/// legal to codegen as "icmp ne (i*4), 0" (assuming A is a pointer to i32). -/// This later form is less amenable to optimization though, and we are allowed -/// to generate the first by knowing that pointer arithmetic doesn't overflow. -/// -/// If we can't emit an optimized form for this expression, this returns null. -/// -static Value *EvaluateGEPOffsetExpression(User *GEP, Instruction &I, - InstCombiner &IC) { - TargetData &TD = *IC.getTargetData(); - gep_type_iterator GTI = gep_type_begin(GEP); - - // Check to see if this gep only has a single variable index. If so, and if - // any constant indices are a multiple of its scale, then we can compute this - // in terms of the scale of the variable index. For example, if the GEP - // implies an offset of "12 + i*4", then we can codegen this as "3 + i", - // because the expression will cross zero at the same point. - unsigned i, e = GEP->getNumOperands(); - int64_t Offset = 0; - for (i = 1; i != e; ++i, ++GTI) { - if (ConstantInt *CI = dyn_cast(GEP->getOperand(i))) { - // Compute the aggregate offset of constant indices. - if (CI->isZero()) continue; - - // Handle a struct index, which adds its field offset to the pointer. - if (const StructType *STy = dyn_cast(*GTI)) { - Offset += TD.getStructLayout(STy)->getElementOffset(CI->getZExtValue()); - } else { - uint64_t Size = TD.getTypeAllocSize(GTI.getIndexedType()); - Offset += Size*CI->getSExtValue(); - } - } else { - // Found our variable index. - break; - } - } - - // If there are no variable indices, we must have a constant offset, just - // evaluate it the general way. - if (i == e) return 0; - - Value *VariableIdx = GEP->getOperand(i); - // Determine the scale factor of the variable element. For example, this is - // 4 if the variable index is into an array of i32. - uint64_t VariableScale = TD.getTypeAllocSize(GTI.getIndexedType()); - - // Verify that there are no other variable indices. If so, emit the hard way. - for (++i, ++GTI; i != e; ++i, ++GTI) { - ConstantInt *CI = dyn_cast(GEP->getOperand(i)); - if (!CI) return 0; - - // Compute the aggregate offset of constant indices. - if (CI->isZero()) continue; - - // Handle a struct index, which adds its field offset to the pointer. - if (const StructType *STy = dyn_cast(*GTI)) { - Offset += TD.getStructLayout(STy)->getElementOffset(CI->getZExtValue()); - } else { - uint64_t Size = TD.getTypeAllocSize(GTI.getIndexedType()); - Offset += Size*CI->getSExtValue(); - } - } - - // Okay, we know we have a single variable index, which must be a - // pointer/array/vector index. If there is no offset, life is simple, return - // the index. - unsigned IntPtrWidth = TD.getPointerSizeInBits(); - if (Offset == 0) { - // Cast to intptrty in case a truncation occurs. If an extension is needed, - // we don't need to bother extending: the extension won't affect where the - // computation crosses zero. - if (VariableIdx->getType()->getPrimitiveSizeInBits() > IntPtrWidth) - VariableIdx = new TruncInst(VariableIdx, - TD.getIntPtrType(VariableIdx->getContext()), - VariableIdx->getName(), &I); - return VariableIdx; - } - - // Otherwise, there is an index. The computation we will do will be modulo - // the pointer size, so get it. - uint64_t PtrSizeMask = ~0ULL >> (64-IntPtrWidth); - - Offset &= PtrSizeMask; - VariableScale &= PtrSizeMask; - - // To do this transformation, any constant index must be a multiple of the - // variable scale factor. For example, we can evaluate "12 + 4*i" as "3 + i", - // but we can't evaluate "10 + 3*i" in terms of i. Check that the offset is a - // multiple of the variable scale. - int64_t NewOffs = Offset / (int64_t)VariableScale; - if (Offset != NewOffs*(int64_t)VariableScale) - return 0; - - // Okay, we can do this evaluation. Start by converting the index to intptr. - const Type *IntPtrTy = TD.getIntPtrType(VariableIdx->getContext()); - if (VariableIdx->getType() != IntPtrTy) - VariableIdx = CastInst::CreateIntegerCast(VariableIdx, IntPtrTy, - true /*SExt*/, - VariableIdx->getName(), &I); - Constant *OffsetVal = ConstantInt::get(IntPtrTy, NewOffs); - return BinaryOperator::CreateAdd(VariableIdx, OffsetVal, "offset", &I); -} - /// FoldGEPICmp - Fold comparisons between a GEP instruction and something /// else. At this point we know that the GEP is on the LHS of the comparison. @@ -5597,7 +5655,7 @@ // If not, synthesize the offset the hard way. if (Offset == 0) - Offset = EmitGEPOffset(GEPLHS, I, *this); + Offset = EmitGEPOffset(GEPLHS, *this); return new ICmpInst(ICmpInst::getSignedPredicate(Cond), Offset, Constant::getNullValue(Offset->getType())); } else if (GEPOperator *GEPRHS = dyn_cast(RHS)) { @@ -5683,8 +5741,8 @@ (isa(GEPLHS) || GEPLHS->hasOneUse()) && (isa(GEPRHS) || GEPRHS->hasOneUse())) { // ((gep Ptr, OFFSET1) cmp (gep Ptr, OFFSET2) ---> (OFFSET1 cmp OFFSET2) - Value *L = EmitGEPOffset(GEPLHS, I, *this); - Value *R = EmitGEPOffset(GEPRHS, I, *this); + Value *L = EmitGEPOffset(GEPLHS, *this); + Value *R = EmitGEPOffset(GEPRHS, *this); return new ICmpInst(ICmpInst::getSignedPredicate(Cond), L, R); } } @@ -8201,8 +8259,7 @@ if (TD && GEP->hasOneUse() && isa(GEP->getOperand(0))) { if (GEP->hasAllConstantIndices()) { // We are guaranteed to get a constant from EmitGEPOffset. - ConstantInt *OffsetV = - cast(EmitGEPOffset(GEP, CI, *this)); + ConstantInt *OffsetV = cast(EmitGEPOffset(GEP, *this)); int64_t Offset = OffsetV->getSExtValue(); // Get the base pointer input of the bitcast, and the type it points to. @@ -11310,8 +11367,7 @@ !isa(BCI->getOperand(0)) && GEP.hasAllConstantIndices()) { // Determine how much the GEP moves the pointer. We are guaranteed to get // a constant back from EmitGEPOffset. - ConstantInt *OffsetV = - cast(EmitGEPOffset(&GEP, GEP, *this)); + ConstantInt *OffsetV = cast(EmitGEPOffset(&GEP, *this)); int64_t Offset = OffsetV->getSExtValue(); // If this GEP instruction doesn't move the pointer, just replace the GEP Modified: llvm/trunk/test/Transforms/InstCombine/sub.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/sub.ll?rev=86021&r1=86020&r2=86021&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/sub.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/sub.ll Wed Nov 4 02:05:20 2009 @@ -1,4 +1,6 @@ -; This test makes sure that these instructions are properly eliminated. +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128" + +; Optimize subtracts. ; ; RUN: opt < %s -instcombine -S | FileCheck %s @@ -211,3 +213,38 @@ ; CHECK: ret i1 %tmp5 } +; rdar://7362831 +define i32 @test23(i8* %P, i64 %A){ + %B = getelementptr inbounds i8* %P, i64 %A + %C = ptrtoint i8* %B to i64 + %D = trunc i64 %C to i32 + %E = ptrtoint i8* %P to i64 + %F = trunc i64 %E to i32 + %G = sub i32 %D, %F + ret i32 %G +; CHECK: @test23 +; CHECK: %A1 = trunc i64 %A to i32 +; CHECK: ret i32 %A1 +} + +define i64 @test24(i8* %P, i64 %A){ + %B = getelementptr inbounds i8* %P, i64 %A + %C = ptrtoint i8* %B to i64 + %E = ptrtoint i8* %P to i64 + %G = sub i64 %C, %E + ret i64 %G +; CHECK: @test24 +; CHECK-NEXT: ret i64 %A +} + +define i64 @test24a(i8* %P, i64 %A){ + %B = getelementptr inbounds i8* %P, i64 %A + %C = ptrtoint i8* %B to i64 + %E = ptrtoint i8* %P to i64 + %G = sub i64 %E, %C + ret i64 %G +; CHECK: @test24a +; CHECK-NEXT: sub i64 0, %A +; CHECK-NEXT: ret i64 +} + From evan.cheng at apple.com Wed Nov 4 02:33:20 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 04 Nov 2009 08:33:20 -0000 Subject: [llvm-commits] [llvm] r86022 - in /llvm/trunk: lib/CodeGen/SimpleRegisterCoalescing.cpp test/CodeGen/X86/2009-11-04-SubregCoalescingBug.ll Message-ID: <200911040833.nA48XKjV019452@zion.cs.uiuc.edu> Author: evancheng Date: Wed Nov 4 02:33:14 2009 New Revision: 86022 URL: http://llvm.org/viewvc/llvm-project?rev=86022&view=rev Log: RangeIsDefinedByCopyFromReg() should check for subreg_to_reg, insert_subreg, and extract_subreg as a "copy" that defines a valno. Also fixes a typo. These two issues prevent a simple subreg coalescing from happening before. Added: llvm/trunk/test/CodeGen/X86/2009-11-04-SubregCoalescingBug.ll Modified: llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp Modified: llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp?rev=86022&r1=86021&r2=86022&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp (original) +++ llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp Wed Nov 4 02:33:14 2009 @@ -1369,7 +1369,7 @@ if (SrcSubIdx) SrcSubRC = SrcRC->getSubRegisterRegClass(SrcSubIdx); assert(SrcSubRC && "Illegal subregister index"); - if (!SrcSubRC->contains(DstReg)) { + if (!SrcSubRC->contains(DstSubReg)) { DEBUG(errs() << "\tIncompatible source regclass: " << tri_->getName(DstSubReg) << " not in " << SrcSubRC->getName() << ".\n"); @@ -1834,6 +1834,25 @@ return std::find(V.begin(), V.end(), Val) != V.end(); } +static bool isValNoDefMove(const MachineInstr *MI, unsigned DR, unsigned SR, + const TargetInstrInfo *TII, + const TargetRegisterInfo *TRI) { + unsigned SrcReg, DstReg, SrcSubIdx, DstSubIdx; + if (TII->isMoveInstr(*MI, SrcReg, DstReg, SrcSubIdx, DstSubIdx)) + ; + else if (MI->getOpcode() == TargetInstrInfo::EXTRACT_SUBREG) { + DstReg = MI->getOperand(0).getReg(); + SrcReg = MI->getOperand(1).getReg(); + } else if (MI->getOpcode() == TargetInstrInfo::SUBREG_TO_REG || + MI->getOpcode() == TargetInstrInfo::INSERT_SUBREG) { + DstReg = MI->getOperand(0).getReg(); + SrcReg = MI->getOperand(2).getReg(); + } else + return false; + return (SrcReg == SR || TRI->isSuperRegister(SR, SrcReg)) && + (DstReg == DR || TRI->isSuperRegister(DR, DstReg)); +} + /// RangeIsDefinedByCopyFromReg - Return true if the specified live range of /// the specified live interval is defined by a copy from the specified /// register. @@ -1850,12 +1869,9 @@ // It's a sub-register live interval, we may not have precise information. // Re-compute it. MachineInstr *DefMI = li_->getInstructionFromIndex(LR->start); - unsigned SrcReg, DstReg, SrcSubIdx, DstSubIdx; - if (DefMI && - tii_->isMoveInstr(*DefMI, SrcReg, DstReg, SrcSubIdx, DstSubIdx) && - DstReg == li.reg && SrcReg == Reg) { + if (DefMI && isValNoDefMove(DefMI, li.reg, Reg, tii_, tri_)) { // Cache computed info. - LR->valno->def = LR->start; + LR->valno->def = LR->start; LR->valno->setCopy(DefMI); return true; } Added: llvm/trunk/test/CodeGen/X86/2009-11-04-SubregCoalescingBug.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2009-11-04-SubregCoalescingBug.ll?rev=86022&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/2009-11-04-SubregCoalescingBug.ll (added) +++ llvm/trunk/test/CodeGen/X86/2009-11-04-SubregCoalescingBug.ll Wed Nov 4 02:33:14 2009 @@ -0,0 +1,15 @@ +; RUN: llc < %s -mtriple=x86_64-apple-darwin11 | FileCheck %s +; rdar://7362871 + +define void @bar(i32 %b, i32 %a) nounwind optsize ssp { +entry: +; CHECK: leal 15(%rsi), %edi +; CHECK-NOT: movl +; CHECK: call _foo + %0 = add i32 %a, 15 ; [#uses=1] + %1 = zext i32 %0 to i64 ; [#uses=1] + tail call void @foo(i64 %1) nounwind + ret void +} + +declare void @foo(i64) From evan.cheng at apple.com Wed Nov 4 02:36:50 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 04 Nov 2009 08:36:50 -0000 Subject: [llvm-commits] [llvm] r86023 - /llvm/trunk/utils/buildit/build_llvm Message-ID: <200911040836.nA48aobJ019556@zion.cs.uiuc.edu> Author: evancheng Date: Wed Nov 4 02:36:50 2009 New Revision: 86023 URL: http://llvm.org/viewvc/llvm-project?rev=86023&view=rev Log: Look for llvm-gcc under /Developer/usr/bin first. 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=86023&r1=86022&r2=86023&view=diff ============================================================================== --- llvm/trunk/utils/buildit/build_llvm (original) +++ llvm/trunk/utils/buildit/build_llvm Wed Nov 4 02:36:50 2009 @@ -127,7 +127,7 @@ # If the user has set CC or CXX, respect their wishes. If not, # compile with LLVM-GCC/LLVM-G++ if available; if LLVM is not # available, fall back to usual GCC/G++ default. - savedPATH=$PATH ; PATH="$PATH:/Developer/usr/bin" + savedPATH=$PATH ; PATH="/Developer/usr/bin:$PATH" XTMPCC=$(which llvm-gcc) if [ x$CC = x -a x$XTMPCC != x ] ; then export CC=$XTMPCC ; fi XTMPCC=$(which llvm-g++) From lessen42 at gmail.com Wed Nov 4 03:29:27 2009 From: lessen42 at gmail.com (David Conrad) Date: Wed, 4 Nov 2009 04:29:27 -0500 Subject: [llvm-commits] [llvm] r85697 - in /llvm/trunk: lib/Target/ARM/ARMInstrNEON.td test/CodeGen/ARM/fmacs.ll test/CodeGen/ARM/fnmacs.ll test/CodeGen/Thumb2/cross-rc-coalescing-2.ll In-Reply-To: <7098F362-DE42-4D5D-B84A-78C3ED93F2AA@apple.com> References: <200910312257.n9VMvbZm030355@zion.cs.uiuc.edu> <72AADD0D-6CAF-433E-8533-A8157E28F8D9@gmail.com> <7098F362-DE42-4D5D-B84A-78C3ED93F2AA@apple.com> Message-ID: <60FF8C44-7B05-4910-92B2-E6AF8E653DE9@gmail.com> On Nov 3, 2009, at 5:07 PM, Jim Grosbach wrote: > > On Nov 2, 2009, at 1:53 AM, David Conrad wrote: > >> Thus even without modeling the special behaviour of vmla it's always >> better to use it: it'll always be at least as fast as a separate vmul >> +vadd. This applies to the integer versions as well. > > > Hi David, > > Unfortunately, this turns out not to be the case. The NEON unit will > stall adjacent instructions in the presence of vmla to preserve in- > order retirement. If a RAW hazard is present, the stall is 8 > (possibly 7) cycles, otherwise it is 4 cycles. You're correct, sorry for the noise and wrong information. From grosbach at apple.com Wed Nov 4 09:54:58 2009 From: grosbach at apple.com (Jim Grosbach) Date: Wed, 4 Nov 2009 07:54:58 -0800 Subject: [llvm-commits] [llvm] r85697 - in /llvm/trunk: lib/Target/ARM/ARMInstrNEON.td test/CodeGen/ARM/fmacs.ll test/CodeGen/ARM/fnmacs.ll test/CodeGen/Thumb2/cross-rc-coalescing-2.ll In-Reply-To: <60FF8C44-7B05-4910-92B2-E6AF8E653DE9@gmail.com> References: <200910312257.n9VMvbZm030355@zion.cs.uiuc.edu> <72AADD0D-6CAF-433E-8533-A8157E28F8D9@gmail.com> <7098F362-DE42-4D5D-B84A-78C3ED93F2AA@apple.com> <60FF8C44-7B05-4910-92B2-E6AF8E653DE9@gmail.com> Message-ID: <6EE77ABE-BB3A-4421-9B44-258631F3D41D@apple.com> On Nov 4, 2009, at 1:29 AM, David Conrad wrote: > On Nov 3, 2009, at 5:07 PM, Jim Grosbach wrote: > >> >> On Nov 2, 2009, at 1:53 AM, David Conrad wrote: >> >>> Thus even without modeling the special behaviour of vmla it's always >>> better to use it: it'll always be at least as fast as a separate >>> vmul >>> +vadd. This applies to the integer versions as well. >> >> >> Hi David, >> >> Unfortunately, this turns out not to be the case. The NEON unit >> will stall adjacent instructions in the presence of vmla to >> preserve in-order retirement. If a RAW hazard is present, the stall >> is 8 (possibly 7) cycles, otherwise it is 4 cycles. > > You're correct, sorry for the noise and wrong information. No worries. Always better to talk it through and make sure things are right. Thanks for having a look and providing feedback! Regards, Jim From baldrick at free.fr Wed Nov 4 12:08:39 2009 From: baldrick at free.fr (Duncan Sands) Date: Wed, 04 Nov 2009 18:08:39 -0000 Subject: [llvm-commits] [dragonegg] r86033 - in /dragonegg/trunk: llvm-convert.cpp llvm-internal.h Message-ID: <200911041808.nA4I8dQj026031@zion.cs.uiuc.edu> Author: baldrick Date: Wed Nov 4 12:08:38 2009 New Revision: 86033 URL: http://llvm.org/viewvc/llvm-project?rev=86033&view=rev Log: Add correct trampoline support. The issue here is that LLVM has one trampoline intrinsic, while gcc has two. The LLVM intrinsic combines the effect of the two gcc intrinsics. However since the gcc init and adjust intrinsics for the same trampoline can be called in different (nested) functions, using the LLVM intrinsic requires storing its result in the stack frame object passed to nested functions as the static chain. In llvm-gcc this is taken care of by creating a variable for this during nested function lowering. However dragonegg does not have this luxury. In fact there's only one place we can put it: the storage that was intended by gcc to be used for holding the trampoline machine code. So put it there, and place the machine code in a separate stack temporary. Modified: dragonegg/trunk/llvm-convert.cpp dragonegg/trunk/llvm-internal.h Modified: dragonegg/trunk/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-convert.cpp?rev=86033&r1=86032&r2=86033&view=diff ============================================================================== --- dragonegg/trunk/llvm-convert.cpp (original) +++ dragonegg/trunk/llvm-convert.cpp Wed Nov 4 12:08:38 2009 @@ -4406,6 +4406,8 @@ return EmitBuiltinExtractReturnAddr(stmt, Result); case BUILT_IN_FROB_RETURN_ADDR: return EmitBuiltinFrobReturnAddr(stmt, Result); + case BUILT_IN_ADJUST_TRAMPOLINE: + return EmitBuiltinAdjustTrampoline(stmt, Result); case BUILT_IN_INIT_TRAMPOLINE: return EmitBuiltinInitTrampoline(stmt, Result); @@ -5631,27 +5633,76 @@ return true; } +bool TreeToLLVM::EmitBuiltinAdjustTrampoline(gimple stmt, Value *&Result) { + if (!validate_gimple_arglist(stmt, POINTER_TYPE, VOID_TYPE)) + return false; + + const Type *ResultTy = ConvertType(gimple_call_return_type(stmt)); + + // The adjusted value is stored as a pointer at the start of the storage GCC + // allocated for the trampoline - load it out and return it. + assert(TD.getPointerSize() <= TRAMPOLINE_SIZE && + "Trampoline smaller than a pointer!"); + Value *Tramp = EmitGimpleReg(gimple_call_arg(stmt, 0)); + Tramp = Builder.CreateBitCast(Tramp, ResultTy->getPointerTo()); + Result = Builder.CreateLoad(Tramp, "adjusted"); + + // The load has the alignment of the trampoline storage. + unsigned Align = TYPE_ALIGN(TREE_TYPE(TREE_TYPE(gimple_call_arg(stmt, 0))))/8; + cast(Result)->setAlignment(Align); + + return true; +} + bool TreeToLLVM::EmitBuiltinInitTrampoline(gimple stmt, Value *&Result) { if (!validate_gimple_arglist(stmt, POINTER_TYPE, POINTER_TYPE, POINTER_TYPE, VOID_TYPE)) return false; + // LLVM's trampoline intrinsic, llvm.init.trampoline, combines the effect of + // GCC's init_trampoline and adjust_trampoline. Calls to adjust_trampoline + // should return the result of the llvm.init.trampoline call. This is tricky + // because the adjust_trampoline and init_trampoline calls need not occur in + // the same function. To overcome this, we don't store the trampoline machine + // code in the storage GCC created for it, we store the result of the call to + // llvm.init.trampoline there instead. Since this storage is the argument to + // adjust_trampoline, we turn adjust_trampoline into a load from its argument. + // The trampoline machine code itself is stored in a stack temporary that we + // create (one for each init_trampoline) in the function where init_trampoline + // is called. static const Type *VPTy = Type::getInt8PtrTy(Context); - Value *Tramp = Emit(gimple_call_arg(stmt, 0), 0); - Tramp = Builder.CreateBitCast(Tramp, VPTy); + // Create a stack temporary to hold the trampoline machine code. + const Type *TrampType = ArrayType::get(Type::getInt8Ty(Context), + TRAMPOLINE_SIZE); + AllocaInst *TrampTmp = CreateTemporary(TrampType); + TrampTmp->setAlignment(TRAMPOLINE_ALIGNMENT); + TrampTmp->setName("TRAMP"); Value *Func = Emit(gimple_call_arg(stmt, 1), 0); - Func = Builder.CreateBitCast(Func, VPTy); - Value *Chain = Emit(gimple_call_arg(stmt, 2), 0); - Chain = Builder.CreateBitCast(Chain, VPTy); - Value *Ops[3] = { Tramp, Func, Chain }; + Value *Ops[3] = { + Builder.CreateBitCast(TrampTmp, VPTy), + Builder.CreateBitCast(Func, VPTy), + Builder.CreateBitCast(Chain, VPTy) + }; Function *Intr = Intrinsic::getDeclaration(TheModule, Intrinsic::init_trampoline); - Result = Builder.CreateCall(Intr, Ops, Ops+3, "tramp"); + Value *Adjusted = Builder.CreateCall(Intr, Ops, Ops + 3, "adjusted"); + + // Store the llvm.init.trampoline result to the GCC trampoline storage. + assert(TD.getPointerSize() <= TRAMPOLINE_SIZE && + "Trampoline smaller than a pointer!"); + Value *Tramp = Emit(gimple_call_arg(stmt, 0), 0); + Tramp = Builder.CreateBitCast(Tramp, Adjusted->getType()->getPointerTo()); + StoreInst *Store = Builder.CreateStore(Adjusted, Tramp); + + // The store has the alignment of the trampoline storage. + unsigned Align = TYPE_ALIGN(TREE_TYPE(TREE_TYPE(gimple_call_arg(stmt, 0))))/8; + Store->setAlignment(Align); + return true; } Modified: dragonegg/trunk/llvm-internal.h URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-internal.h?rev=86033&r1=86032&r2=86033&view=diff ============================================================================== --- dragonegg/trunk/llvm-internal.h (original) +++ dragonegg/trunk/llvm-internal.h Wed Nov 4 12:08:38 2009 @@ -674,6 +674,7 @@ bool EmitBuiltinEHReturn(gimple stmt, Value *&Result); bool EmitBuiltinInitDwarfRegSizes(gimple stmt, Value *&Result); bool EmitBuiltinUnwindInit(gimple stmt, Value *&Result); + bool EmitBuiltinAdjustTrampoline(gimple stmt, Value *&Result); bool EmitBuiltinInitTrampoline(gimple stmt, Value *&Result); // Complex Math Expressions. From clattner at apple.com Wed Nov 4 12:10:15 2009 From: clattner at apple.com (Chris Lattner) Date: Wed, 4 Nov 2009 10:10:15 -0800 Subject: [llvm-commits] [llvm] r86009 - /llvm/trunk/docs/GettingStarted.html In-Reply-To: <200911040615.nA46FStr014546@zion.cs.uiuc.edu> References: <200911040615.nA46FStr014546@zion.cs.uiuc.edu> Message-ID: <69E5E751-3512-4E12-A25C-8297DC25E398@apple.com> On Nov 3, 2009, at 10:15 PM, Nick Lewycky wrote: > Author: nicholas > Date: Wed Nov 4 00:15:28 2009 > New Revision: 86009 > > URL: http://llvm.org/viewvc/llvm-project?rev=86009&view=rev > Log: > The magic for our current brand of .bc files is BC. For older ones > it was llvc. > When was it ever "llvm"? That was before Reid made LLVM BC files be gzip'ed internally, I vaguely remember that this was ~ LLVM 1.3. -Chris > > Modified: > llvm/trunk/docs/GettingStarted.html > > Modified: llvm/trunk/docs/GettingStarted.html > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/GettingStarted.html?rev=86009&r1=86008&r2=86009&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/docs/GettingStarted.html (original) > +++ llvm/trunk/docs/GettingStarted.html Wed Nov 4 00:15:28 2009 > @@ -1154,7 +1154,7 @@ >
                          >
                          > $ mount -t binfmt_misc none /proc/sys/fs/binfmt_misc
                          > -$ echo ':llvm:M::llvm::/path/to/lli:' > /proc/sys/fs/binfmt_misc/ 
                          > register
                          > +$ echo ':llvm:M::BC::/path/to/lli:' > /proc/sys/fs/binfmt_misc/ 
                          > register
                          > $ chmod u+x hello.bc   (if needed)
                          > $ ./hello.bc
                          > 
                          > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From grosbach at apple.com Wed Nov 4 12:40:08 2009 From: grosbach at apple.com (Jim Grosbach) Date: Wed, 04 Nov 2009 18:40:08 -0000 Subject: [llvm-commits] [test-suite] r86035 - /test-suite/trunk/Makefile.programs Message-ID: <200911041840.nA4Ie8xA027248@zion.cs.uiuc.edu> Author: grosbach Date: Wed Nov 4 12:40:08 2009 New Revision: 86035 URL: http://llvm.org/viewvc/llvm-project?rev=86035&view=rev Log: back to dynamic stack alignment for ARM LLCBETA Modified: test-suite/trunk/Makefile.programs Modified: test-suite/trunk/Makefile.programs URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/Makefile.programs?rev=86035&r1=86034&r2=86035&view=diff ============================================================================== --- test-suite/trunk/Makefile.programs (original) +++ test-suite/trunk/Makefile.programs Wed Nov 4 12:40:08 2009 @@ -244,12 +244,12 @@ LLCBETAOPTION := -enable-sparc-v9-insts endif ifeq ($(ARCH),ARM) -LLCBETAOPTION := -arm-use-neon-fp=0 +LLCBETAOPTION := -arm-dynamic-stack-alignment #-combiner-alias-analysis #-schedule-livein-copies endif ifeq ($(ARCH),THUMB) -LLCBETAOPTION := -arm-use-neon-fp=0 +LLCBETAOPTION := -arm-dynamic-stack-alignment #-combiner-alias-analysis #-enable-thumb-reg-scavenging endif From sabre at nondot.org Wed Nov 4 12:57:42 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 04 Nov 2009 18:57:42 -0000 Subject: [llvm-commits] [llvm] r86036 - /llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Message-ID: <200911041857.nA4Ivgc2027935@zion.cs.uiuc.edu> Author: lattner Date: Wed Nov 4 12:57:42 2009 New Revision: 86036 URL: http://llvm.org/viewvc/llvm-project?rev=86036&view=rev Log: Fix an iterator invalidation bug that happens when a hashtable resizes in IPSCCP. This fixes PR5394. Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCP.cpp?rev=86036&r1=86035&r2=86036&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SCCP.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Wed Nov 4 12:57:42 2009 @@ -1280,9 +1280,10 @@ } if (const StructType *STy = dyn_cast(AI->getType())) { - for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) - mergeInValue(getStructValueState(AI, i), AI, - getStructValueState(*CAI, i)); + for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) { + LatticeVal CallArg = getStructValueState(*CAI, i); + mergeInValue(getStructValueState(AI, i), AI, CallArg); + } } else { mergeInValue(AI, getValueState(*CAI)); } From stoklund at 2pi.dk Wed Nov 4 13:24:37 2009 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 04 Nov 2009 19:24:37 -0000 Subject: [llvm-commits] [llvm] r86041 - in /llvm/trunk: include/llvm/CodeGen/AsmPrinter.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp lib/Target/X86/AsmPrinter/X86MCInstLower.cpp Message-ID: <200911041924.nA4JOc2D029091@zion.cs.uiuc.edu> Author: stoklund Date: Wed Nov 4 13:24:37 2009 New Revision: 86041 URL: http://llvm.org/viewvc/llvm-project?rev=86041&view=rev Log: Print out an informative comment for KILL instructions. The KILL pseudo-instruction may survive to the asm printer pass, just like the IMPLICIT_DEF. Print the KILL as a comment instead of just leaving a blank line in the output. With -asm-verbose=0, a blank line is printed, like IMPLICIT?DEF. Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/AsmPrinter.h?rev=86041&r1=86040&r2=86041&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/AsmPrinter.h (original) +++ llvm/trunk/include/llvm/CodeGen/AsmPrinter.h Wed Nov 4 13:24:37 2009 @@ -374,8 +374,10 @@ /// printImplicitDef - This method prints the specified machine instruction /// that is an implicit def. virtual void printImplicitDef(const MachineInstr *MI) const; - - + + /// printKill - This method prints the specified kill machine instruction. + virtual void printKill(const MachineInstr *MI) const; + /// printPICJumpTableSetLabel - This method prints a set label for the /// specified MachineBasicBlock for a jumptable entry. virtual void printPICJumpTableSetLabel(unsigned uid, Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=86041&r1=86040&r2=86041&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Wed Nov 4 13:24:37 2009 @@ -1590,6 +1590,17 @@ << TRI->getName(MI->getOperand(0).getReg()); } +void AsmPrinter::printKill(const MachineInstr *MI) const { + if (!VerboseAsm) return; + O.PadToColumn(MAI->getCommentColumn()); + O << MAI->getCommentString() << " kill:"; + for (unsigned n = 0, e = MI->getNumOperands(); n != e; ++n) { + const MachineOperand &op = MI->getOperand(n); + assert(op.isReg() && "KILL instruction must have only register operands"); + O << ' ' << TRI->getName(op.getReg()) << (op.isDef() ? "" : ""); + } +} + /// printLabel - This method prints a local label used by debug and /// exception handling tables. void AsmPrinter::printLabel(const MachineInstr *MI) const { 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=86041&r1=86040&r2=86041&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Wed Nov 4 13:24:37 2009 @@ -1346,6 +1346,7 @@ printLabel(MI); return; case TargetInstrInfo::KILL: + printKill(MI); return; case TargetInstrInfo::INLINEASM: O << '\t'; Modified: llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp?rev=86041&r1=86040&r2=86041&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp Wed Nov 4 13:24:37 2009 @@ -306,6 +306,7 @@ printLabel(MI); return; case TargetInstrInfo::KILL: + printKill(MI); return; case TargetInstrInfo::INLINEASM: O << '\t'; Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp?rev=86041&r1=86040&r2=86041&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp Wed Nov 4 13:24:37 2009 @@ -412,6 +412,7 @@ printImplicitDef(MI); return; case TargetInstrInfo::KILL: + printKill(MI); return; case X86::MOVPC32r: { MCInst TmpInst; From bob.wilson at apple.com Wed Nov 4 13:25:34 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Wed, 04 Nov 2009 19:25:34 -0000 Subject: [llvm-commits] [llvm] r86042 - /llvm/trunk/test/CodeGen/ARM/indirectbr.ll Message-ID: <200911041925.nA4JPZ83029141@zion.cs.uiuc.edu> Author: bwilson Date: Wed Nov 4 13:25:34 2009 New Revision: 86042 URL: http://llvm.org/viewvc/llvm-project?rev=86042&view=rev Log: Add test for ARM indirectbr codegen. Added: llvm/trunk/test/CodeGen/ARM/indirectbr.ll Added: llvm/trunk/test/CodeGen/ARM/indirectbr.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/indirectbr.ll?rev=86042&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/indirectbr.ll (added) +++ llvm/trunk/test/CodeGen/ARM/indirectbr.ll Wed Nov 4 13:25:34 2009 @@ -0,0 +1,63 @@ +; RUN: llc < %s -relocation-model=pic -march=arm | FileCheck %s -check-prefix=ARM +; RUN: llc < %s -relocation-model=pic -march=thumb | FileCheck %s -check-prefix=THUMB +; RUN: llc < %s -relocation-model=static -march=thumb -mattr=+thumb2 | FileCheck %s -check-prefix=THUMB2 + + at nextaddr = global i8* null ; [#uses=2] + at C.0.2070 = private constant [5 x i8*] [i8* blockaddress(@foo, %L1), i8* blockaddress(@foo, %L2), i8* blockaddress(@foo, %L3), i8* blockaddress(@foo, %L4), i8* blockaddress(@foo, %L5)] ; <[5 x i8*]*> [#uses=1] + +define internal arm_apcscc i32 @foo(i32 %i) nounwind { +; ARM: foo: +; THUMB: foo: +; THUMB2: foo: +entry: + %0 = load i8** @nextaddr, align 4 ; [#uses=2] + %1 = icmp eq i8* %0, null ; [#uses=1] + br i1 %1, label %bb3, label %bb2 + +bb2: ; preds = %entry, %bb3 + %gotovar.4.0 = phi i8* [ %gotovar.4.0.pre, %bb3 ], [ %0, %entry ] ; [#uses=1] +; ARM: bx +; THUMB: mov pc, r1 +; THUMB2: mov pc, r1 + indirectbr i8* %gotovar.4.0, [label %L5, label %L4, label %L3, label %L2, label %L1] + +bb3: ; preds = %entry + %2 = getelementptr inbounds [5 x i8*]* @C.0.2070, i32 0, i32 %i ; [#uses=1] + %gotovar.4.0.pre = load i8** %2, align 4 ; [#uses=1] + br label %bb2 + +L5: ; preds = %bb2 + br label %L4 + +L4: ; preds = %L5, %bb2 + %res.0 = phi i32 [ 385, %L5 ], [ 35, %bb2 ] ; [#uses=1] + br label %L3 + +L3: ; preds = %L4, %bb2 + %res.1 = phi i32 [ %res.0, %L4 ], [ 5, %bb2 ] ; [#uses=1] + br label %L2 + +L2: ; preds = %L3, %bb2 + %res.2 = phi i32 [ %res.1, %L3 ], [ 1, %bb2 ] ; [#uses=1] + %phitmp = mul i32 %res.2, 6 ; [#uses=1] + br label %L1 + +L1: ; preds = %L2, %bb2 + %res.3 = phi i32 [ %phitmp, %L2 ], [ 2, %bb2 ] ; [#uses=1] +; ARM: ldr r1, LCPI1_2 +; ARM: add r1, pc, r1 +; ARM: str r1 +; THUMB: ldr r2, LCPI1_4 +; THUMB: add r2, pc +; THUMB: str r2 +; THUMB2: ldr r2, LCPI1_2 +; THUMB2-NEXT: str r2 + store i8* blockaddress(@foo, %L5), i8** @nextaddr, align 4 + ret i32 %res.3 +} +; ARM: LCPI1_2: +; ARM-NEXT: .long L_foo_L5-(LPC2+8) +; THUMB: LCPI1_4: +; THUMB-NEXT: .long L_foo_L5-(LPC2+4) +; THUMB2: LCPI1_2: +; THUMB2-NEXT: .long L_foo_L5 From gohman at apple.com Wed Nov 4 13:28:19 2009 From: gohman at apple.com (Dan Gohman) Date: Wed, 4 Nov 2009 11:28:19 -0800 Subject: [llvm-commits] [llvm] r85922 - /llvm/trunk/lib/Support/MemoryBuffer.cpp In-Reply-To: <4AF08DBF.7090005@free.fr> References: <200911031910.nA3JAM5b022573@zion.cs.uiuc.edu> <4AF08DBF.7090005@free.fr> Message-ID: On Nov 3, 2009, at 12:08 PM, Duncan Sands wrote: > Hi Dan, > >>> --- llvm/trunk/lib/Support/MemoryBuffer.cpp (original) >>> +++ llvm/trunk/lib/Support/MemoryBuffer.cpp Tue Nov 3 13:10:22 2009 >>> @@ -226,7 +226,7 @@ >>> size_t BytesLeft = FileSize; >>> while (BytesLeft) { >>> ssize_t NumRead = ::read(FD, BufPtr, BytesLeft); >>> - if (NumRead != -1) { >>> + if (NumRead > 0) { >>> BytesLeft -= NumRead; >>> BufPtr += NumRead; >>> } else if (errno == EINTR) { >> Given this, the code should explicitly set errno to 0 so that it doesn't >> infinite loop if it reaches the end of the file and errno happens to >> have the value EINTR. > > if errno is EINTR, isn't it correct to go around again, even if zero bytes > were read? read could return 0 and leave errno unmodified. errno could be set to EINTR by unrelated code before the first read call. If read keeps returning 0 for some reason, the code wouldn't recover. Dan From dpatel at apple.com Wed Nov 4 13:37:40 2009 From: dpatel at apple.com (Devang Patel) Date: Wed, 04 Nov 2009 19:37:40 -0000 Subject: [llvm-commits] [llvm] r86043 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Message-ID: <200911041937.nA4JbekB029552@zion.cs.uiuc.edu> Author: dpatel Date: Wed Nov 4 13:37:40 2009 New Revision: 86043 URL: http://llvm.org/viewvc/llvm-project?rev=86043&view=rev Log: Array element size does not match array size but array is not a bitfield. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=86043&r1=86042&r2=86043&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Wed Nov 4 13:37:40 2009 @@ -1138,7 +1138,9 @@ AddSourceLine(MemberDie, &DT); uint64_t Size = DT.getSizeInBits(); - uint64_t FieldSize = DT.getOriginalTypeSize(); + uint64_t FieldSize = Size; + if (DT.getTypeDerivedFrom().getTag() != dwarf::DW_TAG_array_type) + FieldSize = DT.getOriginalTypeSize(); if (Size != FieldSize) { // Handle bitfield. From echristo at apple.com Wed Nov 4 13:57:50 2009 From: echristo at apple.com (Eric Christopher) Date: Wed, 04 Nov 2009 19:57:50 -0000 Subject: [llvm-commits] [llvm] r86044 - /llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp Message-ID: <200911041957.nA4Jvo3g030547@zion.cs.uiuc.edu> Author: echristo Date: Wed Nov 4 13:57:50 2009 New Revision: 86044 URL: http://llvm.org/viewvc/llvm-project?rev=86044&view=rev Log: Add some options to disable various code gen optimizations. Modified: llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp Modified: llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp?rev=86044&r1=86043&r2=86044&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp (original) +++ llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp Wed Nov 4 13:57:50 2009 @@ -31,6 +31,22 @@ bool EnableFastISel; } +static cl::opt DisablePostRA("disable-post-ra", cl::Hidden, + cl::desc("Disable Post Regalloc")); +static cl::opt DisableBranchFold("disable-branch-fold", cl::Hidden, + cl::desc("Disable branch folding")); +static cl::opt DisableCodePlace("disable-code-place", cl::Hidden, + cl::desc("Disable code placement")); +static cl::opt DisableSSC("disable-ssc", cl::Hidden, + cl::desc("Disable Stack Slot Coloring")); +static cl::opt DisableMachineLICM("disable-machine-licm", cl::Hidden, + cl::desc("Disable Machine LICM")); +static cl::opt DisableMachineSink("disable-machine-sink", cl::Hidden, + cl::desc("Disable Machine Sinking")); +static cl::opt DisableLSR("disable-lsr", cl::Hidden, + cl::desc("Disable Loop Strength Reduction Pass")); +static cl::opt DisableCGP("disable-cgp", cl::Hidden, + cl::desc("Disable Codegen Prepare")); static cl::opt PrintLSR("print-lsr-output", cl::Hidden, cl::desc("Print LLVM IR produced by the loop-reduce pass")); static cl::opt PrintISelInput("print-isel-input", cl::Hidden, @@ -208,7 +224,7 @@ // Standard LLVM-Level Passes. // Run loop strength reduction before anything else. - if (OptLevel != CodeGenOpt::None) { + if (OptLevel != CodeGenOpt::None && !DisableLSR) { PM.add(createLoopStrengthReducePass(getTargetLowering())); if (PrintLSR) PM.add(createPrintFunctionPass("\n\n*** Code after LSR ***\n", &errs())); @@ -236,7 +252,7 @@ // Make sure that no unreachable blocks are instruction selected. PM.add(createUnreachableBlockEliminationPass()); - if (OptLevel != CodeGenOpt::None) + if (OptLevel != CodeGenOpt::None && !DisableCGP) PM.add(createCodeGenPreparePass(getTargetLowering())); PM.add(createStackProtectorPass(getTargetLowering())); @@ -265,8 +281,10 @@ /* allowDoubleDefs= */ true); if (OptLevel != CodeGenOpt::None) { - PM.add(createMachineLICMPass()); - PM.add(createMachineSinkingPass()); + if (!DisableMachineLICM) + PM.add(createMachineLICMPass()); + if (!DisableMachineSink) + PM.add(createMachineSinkingPass()); printAndVerify(PM, "After MachineLICM and MachineSinking", /* allowDoubleDefs= */ true); } @@ -281,7 +299,7 @@ printAndVerify(PM, "After Register Allocation"); // Perform stack slot coloring. - if (OptLevel != CodeGenOpt::None) { + if (OptLevel != CodeGenOpt::None && !DisableSSC) { // FIXME: Re-enable coloring with register when it's capable of adding // kill markers. PM.add(createStackSlotColoringPass(false)); @@ -304,13 +322,13 @@ printAndVerify(PM, "After PreSched2 passes"); // Second pass scheduler. - if (OptLevel != CodeGenOpt::None) { + if (OptLevel != CodeGenOpt::None && !DisablePostRA) { PM.add(createPostRAScheduler(OptLevel)); printAndVerify(PM, "After PostRAScheduler"); } // Branch folding must be run after regalloc and prolog/epilog insertion. - if (OptLevel != CodeGenOpt::None) { + if (OptLevel != CodeGenOpt::None && !DisableBranchFold) { PM.add(createBranchFoldingPass(getEnableTailMergeDefault())); printAndVerify(PM, "After BranchFolding"); } @@ -327,7 +345,7 @@ if (addPreEmitPass(PM, OptLevel)) printAndVerify(PM, "After PreEmit passes"); - if (OptLevel != CodeGenOpt::None) { + if (OptLevel != CodeGenOpt::None && !DisableCodePlace) { PM.add(createCodePlacementOptPass()); printAndVerify(PM, "After CodePlacementOpt"); } From bob.wilson at apple.com Wed Nov 4 14:04:11 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Wed, 04 Nov 2009 20:04:11 -0000 Subject: [llvm-commits] [llvm] r86045 - /llvm/trunk/test/CodeGen/ARM/indirectbr.ll Message-ID: <200911042004.nA4K4BGq030757@zion.cs.uiuc.edu> Author: bwilson Date: Wed Nov 4 14:04:11 2009 New Revision: 86045 URL: http://llvm.org/viewvc/llvm-project?rev=86045&view=rev Log: Fix broken test. Modified: llvm/trunk/test/CodeGen/ARM/indirectbr.ll Modified: llvm/trunk/test/CodeGen/ARM/indirectbr.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/indirectbr.ll?rev=86045&r1=86044&r2=86045&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/indirectbr.ll (original) +++ llvm/trunk/test/CodeGen/ARM/indirectbr.ll Wed Nov 4 14:04:11 2009 @@ -47,10 +47,10 @@ ; ARM: ldr r1, LCPI1_2 ; ARM: add r1, pc, r1 ; ARM: str r1 -; THUMB: ldr r2, LCPI1_4 +; THUMB: ldr.n r2, LCPI1_4 ; THUMB: add r2, pc ; THUMB: str r2 -; THUMB2: ldr r2, LCPI1_2 +; THUMB2: ldr.n r2, LCPI1_2 ; THUMB2-NEXT: str r2 store i8* blockaddress(@foo, %L5), i8** @nextaddr, align 4 ret i32 %res.3 From baldrick at free.fr Wed Nov 4 14:50:24 2009 From: baldrick at free.fr (Duncan Sands) Date: Wed, 04 Nov 2009 20:50:24 -0000 Subject: [llvm-commits] [llvm] r86046 - /llvm/trunk/lib/Support/MemoryBuffer.cpp Message-ID: <200911042050.nA4KoOlV032343@zion.cs.uiuc.edu> Author: baldrick Date: Wed Nov 4 14:50:23 2009 New Revision: 86046 URL: http://llvm.org/viewvc/llvm-project?rev=86046&view=rev Log: A value is only assigned to errno if NumRead equals -1, so do not reason based on errno if NumRead has a different value. Modified: llvm/trunk/lib/Support/MemoryBuffer.cpp Modified: llvm/trunk/lib/Support/MemoryBuffer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/MemoryBuffer.cpp?rev=86046&r1=86045&r2=86046&view=diff ============================================================================== --- llvm/trunk/lib/Support/MemoryBuffer.cpp (original) +++ llvm/trunk/lib/Support/MemoryBuffer.cpp Wed Nov 4 14:50:23 2009 @@ -229,7 +229,7 @@ if (NumRead > 0) { BytesLeft -= NumRead; BufPtr += NumRead; - } else if (errno == EINTR) { + } else if (NumRead == -1 && errno == EINTR) { // try again } else { // error reading. From baldrick at free.fr Wed Nov 4 14:50:58 2009 From: baldrick at free.fr (Duncan Sands) Date: Wed, 04 Nov 2009 21:50:58 +0100 Subject: [llvm-commits] [llvm] r85922 - /llvm/trunk/lib/Support/MemoryBuffer.cpp In-Reply-To: References: <200911031910.nA3JAM5b022573@zion.cs.uiuc.edu> <4AF08DBF.7090005@free.fr> Message-ID: <4AF1E932.2010301@free.fr> Hi Dan, >> if errno is EINTR, isn't it correct to go around again, even if zero bytes >> were read? > > read could return 0 and leave errno unmodified. errno could be set to > EINTR by unrelated code before the first read call. If read keeps > returning 0 for some reason, the code wouldn't recover. fair enough. Fixed in commit 86046. Ciao, Duncan. From lhames at gmail.com Wed Nov 4 15:24:16 2009 From: lhames at gmail.com (Lang Hames) Date: Wed, 04 Nov 2009 21:24:16 -0000 Subject: [llvm-commits] [llvm] r86049 - in /llvm/trunk: include/llvm/CodeGen/SlotIndexes.h lib/CodeGen/SlotIndexes.cpp Message-ID: <200911042124.nA4LOGUs001039@zion.cs.uiuc.edu> Author: lhames Date: Wed Nov 4 15:24:15 2009 New Revision: 86049 URL: http://llvm.org/viewvc/llvm-project?rev=86049&view=rev Log: Handle empty/tombstone keys for LiveIndex more cleanly. Check for index sanity when constructing index list entries. Modified: llvm/trunk/include/llvm/CodeGen/SlotIndexes.h llvm/trunk/lib/CodeGen/SlotIndexes.cpp Modified: llvm/trunk/include/llvm/CodeGen/SlotIndexes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SlotIndexes.h?rev=86049&r1=86048&r2=86049&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/SlotIndexes.h (original) +++ llvm/trunk/include/llvm/CodeGen/SlotIndexes.h Wed Nov 4 15:24:15 2009 @@ -28,6 +28,7 @@ #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/MachineInstr.h" #include "llvm/Support/Allocator.h" +#include "llvm/Support/ErrorHandling.h" namespace llvm { @@ -38,14 +39,35 @@ class IndexListEntry { private: + static std::auto_ptr emptyKeyEntry, + tombstoneKeyEntry; + typedef enum { EMPTY_KEY, TOMBSTONE_KEY } ReservedEntryType; + static const unsigned EMPTY_KEY_INDEX = ~0U & ~3U, + TOMBSTONE_KEY_INDEX = ~0U & ~7U; + IndexListEntry *next, *prev; MachineInstr *mi; unsigned index; + // This constructor is only to be used by getEmptyKeyEntry + // & getTombstoneKeyEntry. It sets index to the given + // value and mi to zero. + IndexListEntry(ReservedEntryType r) : mi(0) { + switch(r) { + case EMPTY_KEY: index = EMPTY_KEY_INDEX; break; + case TOMBSTONE_KEY: index = TOMBSTONE_KEY_INDEX; break; + default: assert(false && "Invalid value for constructor."); + } + } + public: - IndexListEntry(MachineInstr *mi, unsigned index) - : mi(mi), index(index) {} + IndexListEntry(MachineInstr *mi, unsigned index) : mi(mi), index(index) { + if (index == EMPTY_KEY_INDEX || index == TOMBSTONE_KEY_INDEX) { + llvm_report_error("Attempt to create invalid index. " + "Available indexes may have been exhausted?."); + } + } MachineInstr* getInstr() const { return mi; } void setInstr(MachineInstr *mi) { this->mi = mi; } @@ -60,6 +82,24 @@ IndexListEntry* getPrev() { return prev; } const IndexListEntry* getPrev() const { return prev; } void setPrev(IndexListEntry *prev) { this->prev = prev; } + + // This function returns the index list entry that is to be used for empty + // SlotIndex keys. + static IndexListEntry* getEmptyKeyEntry() { + if (emptyKeyEntry.get() == 0) { + emptyKeyEntry.reset(new IndexListEntry(EMPTY_KEY)); + } + return emptyKeyEntry.get(); + } + + // This function returns the index list entry that is to be used for + // tombstone SlotIndex keys. + static IndexListEntry* getTombstoneKeyEntry() { + if (tombstoneKeyEntry.get() == 0) { + tombstoneKeyEntry.reset(new IndexListEntry(TOMBSTONE_KEY)); + } + return tombstoneKeyEntry.get(); + } }; // Specialize PointerLikeTypeTraits for IndexListEntry. @@ -81,10 +121,6 @@ friend class DenseMapInfo; private: - - // FIXME: Is there any way to statically allocate these things and have - // them 8-byte aligned? - static std::auto_ptr emptyKeyPtr, tombstoneKeyPtr; static const unsigned PHI_BIT = 1 << 2; PointerIntPair lie; @@ -116,21 +152,11 @@ enum Slot { LOAD, USE, DEF, STORE, NUM }; static inline SlotIndex getEmptyKey() { - // FIXME: How do we guarantee these numbers don't get allocated to - // legit indexes? - if (emptyKeyPtr.get() == 0) - emptyKeyPtr.reset(new IndexListEntry(0, ~0U & ~3U)); - - return SlotIndex(emptyKeyPtr.get(), 0); + return SlotIndex(IndexListEntry::getEmptyKeyEntry(), 0); } static inline SlotIndex getTombstoneKey() { - // FIXME: How do we guarantee these numbers don't get allocated to - // legit indexes? - if (tombstoneKeyPtr.get() == 0) - tombstoneKeyPtr.reset(new IndexListEntry(0, ~0U & ~7U)); - - return SlotIndex(tombstoneKeyPtr.get(), 0); + return SlotIndex(IndexListEntry::getTombstoneKeyEntry(), 0); } /// Construct an invalid index. Modified: llvm/trunk/lib/CodeGen/SlotIndexes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SlotIndexes.cpp?rev=86049&r1=86048&r2=86049&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SlotIndexes.cpp (original) +++ llvm/trunk/lib/CodeGen/SlotIndexes.cpp Wed Nov 4 15:24:15 2009 @@ -16,8 +16,8 @@ using namespace llvm; -std::auto_ptr SlotIndex::emptyKeyPtr(0), - SlotIndex::tombstoneKeyPtr(0); +std::auto_ptr IndexListEntry::emptyKeyEntry, + IndexListEntry::tombstoneKeyEntry; char SlotIndexes::ID = 0; static RegisterPass X("slotindexes", "Slot index numbering"); From bob.wilson at apple.com Wed Nov 4 15:31:18 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Wed, 04 Nov 2009 21:31:18 -0000 Subject: [llvm-commits] [llvm] r86050 - in /llvm/trunk: lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp lib/Target/PowerPC/PPCISelLowering.cpp lib/Target/PowerPC/PPCISelLowering.h lib/Target/PowerPC/PPCInstr64Bit.td lib/Target/PowerPC/PPCInstrInfo.td test/CodeGen/PowerPC/indirectbr.ll Message-ID: <200911042131.nA4LVJqT001280@zion.cs.uiuc.edu> Author: bwilson Date: Wed Nov 4 15:31:18 2009 New Revision: 86050 URL: http://llvm.org/viewvc/llvm-project?rev=86050&view=rev Log: Add PowerPC codegen for indirect branches. Added: llvm/trunk/test/CodeGen/PowerPC/indirectbr.ll Modified: llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp llvm/trunk/lib/Target/PowerPC/PPCISelLowering.h llvm/trunk/lib/Target/PowerPC/PPCInstr64Bit.td llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.td Modified: llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp?rev=86050&r1=86049&r2=86050&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Wed Nov 4 15:31:18 2009 @@ -414,6 +414,9 @@ O << MAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << '_' << MO.getIndex(); return; + case MachineOperand::MO_BlockAddress: + GetBlockAddressSymbol(MO.getBlockAddress())->print(O, MAI); + return; case MachineOperand::MO_ExternalSymbol: { // Computing the address of an external symbol, not calling it. std::string Name(MAI->getGlobalPrefix()); Modified: llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp?rev=86050&r1=86049&r2=86050&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp Wed Nov 4 15:31:18 2009 @@ -196,10 +196,12 @@ // appropriate instructions to materialize the address. setOperationAction(ISD::GlobalAddress, MVT::i32, Custom); setOperationAction(ISD::GlobalTLSAddress, MVT::i32, Custom); + setOperationAction(ISD::BlockAddress, MVT::i32, Custom); setOperationAction(ISD::ConstantPool, MVT::i32, Custom); setOperationAction(ISD::JumpTable, MVT::i32, Custom); setOperationAction(ISD::GlobalAddress, MVT::i64, Custom); setOperationAction(ISD::GlobalTLSAddress, MVT::i64, Custom); + setOperationAction(ISD::BlockAddress, MVT::i64, Custom); setOperationAction(ISD::ConstantPool, MVT::i64, Custom); setOperationAction(ISD::JumpTable, MVT::i64, Custom); @@ -1167,6 +1169,36 @@ return SDValue(); // Not reached } +SDValue PPCTargetLowering::LowerBlockAddress(SDValue Op, SelectionDAG &DAG) { + EVT PtrVT = Op.getValueType(); + DebugLoc DL = Op.getDebugLoc(); + + BlockAddress *BA = cast(Op)->getBlockAddress(); + SDValue TgtBA = DAG.getBlockAddress(BA, DL, /*isTarget=*/true); + SDValue Zero = DAG.getConstant(0, PtrVT); + SDValue Hi = DAG.getNode(PPCISD::Hi, DL, PtrVT, TgtBA, Zero); + SDValue Lo = DAG.getNode(PPCISD::Lo, DL, PtrVT, TgtBA, Zero); + + // If this is a non-darwin platform, we don't support non-static relo models + // yet. + const TargetMachine &TM = DAG.getTarget(); + if (TM.getRelocationModel() == Reloc::Static || + !TM.getSubtarget().isDarwin()) { + // Generate non-pic code that has direct accesses to globals. + // The address of the global is just (hi(&g)+lo(&g)). + return DAG.getNode(ISD::ADD, DL, PtrVT, Hi, Lo); + } + + if (TM.getRelocationModel() == Reloc::PIC_) { + // With PIC, the first instruction is actually "GR+hi(&G)". + Hi = DAG.getNode(ISD::ADD, DL, PtrVT, + DAG.getNode(PPCISD::GlobalBaseReg, + DebugLoc::getUnknownLoc(), PtrVT), Hi); + } + + return DAG.getNode(ISD::ADD, DL, PtrVT, Hi, Lo); +} + SDValue PPCTargetLowering::LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) { EVT PtrVT = Op.getValueType(); @@ -4181,6 +4213,7 @@ switch (Op.getOpcode()) { default: llvm_unreachable("Wasn't expecting to be able to lower this!"); case ISD::ConstantPool: return LowerConstantPool(Op, DAG); + case ISD::BlockAddress: return LowerBlockAddress(Op, DAG); case ISD::GlobalAddress: return LowerGlobalAddress(Op, DAG); case ISD::GlobalTLSAddress: return LowerGlobalTLSAddress(Op, DAG); case ISD::JumpTable: return LowerJumpTable(Op, DAG); Modified: llvm/trunk/lib/Target/PowerPC/PPCISelLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelLowering.h?rev=86050&r1=86049&r2=86050&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCISelLowering.h (original) +++ llvm/trunk/lib/Target/PowerPC/PPCISelLowering.h Wed Nov 4 15:31:18 2009 @@ -361,6 +361,7 @@ SDValue LowerRETURNADDR(SDValue Op, SelectionDAG &DAG); SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG); SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG); + SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG); SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG); SDValue LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG); SDValue LowerJumpTable(SDValue Op, SelectionDAG &DAG); Modified: llvm/trunk/lib/Target/PowerPC/PPCInstr64Bit.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCInstr64Bit.td?rev=86050&r1=86049&r2=86050&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCInstr64Bit.td (original) +++ llvm/trunk/lib/Target/PowerPC/PPCInstr64Bit.td Wed Nov 4 15:31:18 2009 @@ -731,9 +731,13 @@ def : Pat<(PPClo tconstpool:$in , 0), (LI8 tconstpool:$in)>; def : Pat<(PPChi tjumptable:$in , 0), (LIS8 tjumptable:$in)>; def : Pat<(PPClo tjumptable:$in , 0), (LI8 tjumptable:$in)>; +def : Pat<(PPChi tblockaddress:$in, 0), (LIS8 tblockaddress:$in)>; +def : Pat<(PPClo tblockaddress:$in, 0), (LI8 tblockaddress:$in)>; def : Pat<(add G8RC:$in, (PPChi tglobaladdr:$g, 0)), (ADDIS8 G8RC:$in, tglobaladdr:$g)>; def : Pat<(add G8RC:$in, (PPChi tconstpool:$g, 0)), (ADDIS8 G8RC:$in, tconstpool:$g)>; def : Pat<(add G8RC:$in, (PPChi tjumptable:$g, 0)), (ADDIS8 G8RC:$in, tjumptable:$g)>; +def : Pat<(add G8RC:$in, (PPChi tblockaddress:$g, 0)), + (ADDIS8 G8RC:$in, tblockaddress:$g)>; Modified: llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.td?rev=86050&r1=86049&r2=86050&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.td (original) +++ llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.td Wed Nov 4 15:31:18 2009 @@ -1436,12 +1436,16 @@ def : Pat<(PPClo tconstpool:$in, 0), (LI tconstpool:$in)>; def : Pat<(PPChi tjumptable:$in, 0), (LIS tjumptable:$in)>; def : Pat<(PPClo tjumptable:$in, 0), (LI tjumptable:$in)>; +def : Pat<(PPChi tblockaddress:$in, 0), (LIS tblockaddress:$in)>; +def : Pat<(PPClo tblockaddress:$in, 0), (LI tblockaddress:$in)>; def : Pat<(add GPRC:$in, (PPChi tglobaladdr:$g, 0)), (ADDIS GPRC:$in, tglobaladdr:$g)>; def : Pat<(add GPRC:$in, (PPChi tconstpool:$g, 0)), (ADDIS GPRC:$in, tconstpool:$g)>; def : Pat<(add GPRC:$in, (PPChi tjumptable:$g, 0)), (ADDIS GPRC:$in, tjumptable:$g)>; +def : Pat<(add GPRC:$in, (PPChi tblockaddress:$g, 0)), + (ADDIS GPRC:$in, tblockaddress:$g)>; // Fused negative multiply subtract, alternate pattern def : Pat<(fsub F8RC:$B, (fmul F8RC:$A, F8RC:$C)), Added: llvm/trunk/test/CodeGen/PowerPC/indirectbr.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/indirectbr.ll?rev=86050&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/PowerPC/indirectbr.ll (added) +++ llvm/trunk/test/CodeGen/PowerPC/indirectbr.ll Wed Nov 4 15:31:18 2009 @@ -0,0 +1,55 @@ +; RUN: llc < %s -relocation-model=pic -march=ppc32 | FileCheck %s -check-prefix=PIC +; RUN: llc < %s -relocation-model=static -march=ppc32 | FileCheck %s -check-prefix=STATIC + + at nextaddr = global i8* null ; [#uses=2] + at C.0.2070 = private constant [5 x i8*] [i8* blockaddress(@foo, %L1), i8* blockaddress(@foo, %L2), i8* blockaddress(@foo, %L3), i8* blockaddress(@foo, %L4), i8* blockaddress(@foo, %L5)] ; <[5 x i8*]*> [#uses=1] + +define internal i32 @foo(i32 %i) nounwind { +; PIC: foo: +; STATIC: foo: +entry: + %0 = load i8** @nextaddr, align 4 ; [#uses=2] + %1 = icmp eq i8* %0, null ; [#uses=1] + br i1 %1, label %bb3, label %bb2 + +bb2: ; preds = %entry, %bb3 + %gotovar.4.0 = phi i8* [ %gotovar.4.0.pre, %bb3 ], [ %0, %entry ] ; [#uses=1] +; PIC: mtctr +; PIC-NEXT: bctr +; STATIC: mtctr +; STATIC-NEXT: bctr + indirectbr i8* %gotovar.4.0, [label %L5, label %L4, label %L3, label %L2, label %L1] + +bb3: ; preds = %entry + %2 = getelementptr inbounds [5 x i8*]* @C.0.2070, i32 0, i32 %i ; [#uses=1] + %gotovar.4.0.pre = load i8** %2, align 4 ; [#uses=1] + br label %bb2 + +L5: ; preds = %bb2 + br label %L4 + +L4: ; preds = %L5, %bb2 + %res.0 = phi i32 [ 385, %L5 ], [ 35, %bb2 ] ; [#uses=1] + br label %L3 + +L3: ; preds = %L4, %bb2 + %res.1 = phi i32 [ %res.0, %L4 ], [ 5, %bb2 ] ; [#uses=1] + br label %L2 + +L2: ; preds = %L3, %bb2 + %res.2 = phi i32 [ %res.1, %L3 ], [ 1, %bb2 ] ; [#uses=1] + %phitmp = mul i32 %res.2, 6 ; [#uses=1] + br label %L1 + +L1: ; preds = %L2, %bb2 + %res.3 = phi i32 [ %phitmp, %L2 ], [ 2, %bb2 ] ; [#uses=1] +; PIC: addis r4, r2, ha16(L_foo_L5-"L1$pb") +; PIC: li r5, lo16(L_foo_L5-"L1$pb") +; PIC: add r4, r4, r5 +; PIC: stw r4 +; STATIC: li r2, lo16(L_foo_L5) +; STATIC: addis r2, r2, ha16(L_foo_L5) +; STATIC: stw r2 + store i8* blockaddress(@foo, %L5), i8** @nextaddr, align 4 + ret i32 %res.3 +} From dpatel at apple.com Wed Nov 4 16:06:12 2009 From: dpatel at apple.com (Devang Patel) Date: Wed, 04 Nov 2009 22:06:12 -0000 Subject: [llvm-commits] [llvm] r86054 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Message-ID: <200911042206.nA4M6DMe002888@zion.cs.uiuc.edu> Author: dpatel Date: Wed Nov 4 16:06:12 2009 New Revision: 86054 URL: http://llvm.org/viewvc/llvm-project?rev=86054&view=rev Log: Fix DW_AT_data_member_location for bit-fields. It points to the location of annonymous field that covers respective field. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=86054&r1=86053&r2=86054&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Wed Nov 4 16:06:12 2009 @@ -1137,6 +1137,9 @@ AddSourceLine(MemberDie, &DT); + DIEBlock *MemLocationDie = new DIEBlock(); + AddUInt(MemLocationDie, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_plus_uconst); + uint64_t Size = DT.getSizeInBits(); uint64_t FieldSize = Size; if (DT.getTypeDerivedFrom().getTag() != dwarf::DW_TAG_array_type) @@ -1157,12 +1160,16 @@ // Maybe we need to work from the other end. if (TD->isLittleEndian()) Offset = FieldSize - (Offset + Size); AddUInt(MemberDie, dwarf::DW_AT_bit_offset, 0, Offset); - } - DIEBlock *Block = new DIEBlock(); - AddUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_plus_uconst); - AddUInt(Block, 0, dwarf::DW_FORM_udata, DT.getOffsetInBits() >> 3); - AddBlock(MemberDie, dwarf::DW_AT_data_member_location, 0, Block); + // Here WD_AT_data_member_location points to the anonymous + // field that includes this bit field. + AddUInt(MemLocationDie, 0, dwarf::DW_FORM_udata, FieldOffset >> 3); + + } else + // This is not a bitfield. + AddUInt(MemLocationDie, 0, dwarf::DW_FORM_udata, DT.getOffsetInBits() >> 3); + + AddBlock(MemberDie, dwarf::DW_AT_data_member_location, 0, MemLocationDie); if (DT.isProtected()) AddUInt(MemberDie, dwarf::DW_AT_accessibility, 0, From grosbach at apple.com Wed Nov 4 16:41:00 2009 From: grosbach at apple.com (Jim Grosbach) Date: Wed, 04 Nov 2009 22:41:00 -0000 Subject: [llvm-commits] [llvm] r86056 - /llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp Message-ID: <200911042241.nA4Mf05G004255@zion.cs.uiuc.edu> Author: grosbach Date: Wed Nov 4 16:41:00 2009 New Revision: 86056 URL: http://llvm.org/viewvc/llvm-project?rev=86056&view=rev Log: dynamic stack realignment necessitates scanning the floating point callee- saved instructions even if no stack adjustment for those saves is needed. Modified: llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp Modified: llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp?rev=86056&r1=86055&r2=86056&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp Wed Nov 4 16:41:00 2009 @@ -1339,10 +1339,10 @@ AFI->setGPRCalleeSavedArea2Offset(GPRCS2Offset); AFI->setDPRCalleeSavedAreaOffset(DPRCSOffset); + movePastCSLoadStoreOps(MBB, MBBI, ARM::FSTD, 0, 3, STI); NumBytes = DPRCSOffset; if (NumBytes) { - // Insert it after all the callee-save spills. - movePastCSLoadStoreOps(MBB, MBBI, ARM::FSTD, 0, 3, STI); + // Adjust SP after all the callee-save spills. emitSPUpdate(isARM, MBB, MBBI, dl, TII, -NumBytes); } From grosbach at apple.com Wed Nov 4 16:41:52 2009 From: grosbach at apple.com (Jim Grosbach) Date: Wed, 04 Nov 2009 22:41:52 -0000 Subject: [llvm-commits] [llvm] r86057 - /llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp Message-ID: <200911042241.nA4Mfq40004297@zion.cs.uiuc.edu> Author: grosbach Date: Wed Nov 4 16:41:51 2009 New Revision: 86057 URL: http://llvm.org/viewvc/llvm-project?rev=86057&view=rev Log: If a function has no stack frame at all, dynamic realignment isn't necessary. Modified: llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp Modified: llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp?rev=86057&r1=86056&r2=86057&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp Wed Nov 4 16:41:51 2009 @@ -514,6 +514,7 @@ unsigned StackAlign = MF.getTarget().getFrameInfo()->getStackAlignment(); return (RealignStack && !AFI->isThumb1OnlyFunction() && + AFI->hasStackFrame() && (MFI->getMaxAlignment() > StackAlign) && !MFI->hasVarSizedObjects()); } From clattner at apple.com Wed Nov 4 16:44:49 2009 From: clattner at apple.com (Chris Lattner) Date: Wed, 4 Nov 2009 14:44:49 -0800 Subject: [llvm-commits] [llvm] r86049 - in /llvm/trunk: include/llvm/CodeGen/SlotIndexes.h lib/CodeGen/SlotIndexes.cpp In-Reply-To: <200911042124.nA4LOGUs001039@zion.cs.uiuc.edu> References: <200911042124.nA4LOGUs001039@zion.cs.uiuc.edu> Message-ID: <2FD10997-0651-440E-82AB-1DEA6ACB0C52@apple.com> On Nov 4, 2009, at 1:24 PM, Lang Hames wrote: > Author: lhames > Date: Wed Nov 4 15:24:15 2009 > New Revision: 86049 > > URL: http://llvm.org/viewvc/llvm-project?rev=86049&view=rev > Log: > Handle empty/tombstone keys for LiveIndex more cleanly. Check for > index sanity when constructing index list entries. Hi Lang, > +++ llvm/trunk/lib/CodeGen/SlotIndexes.cpp Wed Nov 4 15:24:15 2009 > @@ -16,8 +16,8 @@ > > using namespace llvm; > > -std::auto_ptr SlotIndex::emptyKeyPtr(0), > - SlotIndex::tombstoneKeyPtr(0); > +std::auto_ptr IndexListEntry::emptyKeyEntry, > + IndexListEntry::tombstoneKeyEntry; Why are you using global variables (with static ctors/dtors in particular) for this? This does not appear to be thread safe. Can these be made instance variables of the class? -Chris From espindola at google.com Wed Nov 4 16:45:37 2009 From: espindola at google.com (Rafael Espindola) Date: Wed, 4 Nov 2009 17:45:37 -0500 Subject: [llvm-commits] [patch] Make compiler-rt build on linux Message-ID: <38a0d8450911041445q25c909ctbb92caa9b3dc402f@mail.gmail.com> I tried to build compiler-rt with cmake and got lost. I must say I like make better :-) This patch adds support for Building shared libraries and changes some files so that it builds on linux. Tested with make TargetArch=i386 make TargetArch=x86_64 I skipped the fat binary bits, since they are OS X specific and it looks like OS X doesn't care about .so. Cheers, -- Rafael ?vila de Esp?ndola -------------- next part -------------- A non-text attachment was scrubbed... Name: shared.patch Type: text/x-diff Size: 5262 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091104/e77f36da/attachment.bin From grosbach at apple.com Wed Nov 4 17:11:07 2009 From: grosbach at apple.com (Jim Grosbach) Date: Wed, 04 Nov 2009 23:11:07 -0000 Subject: [llvm-commits] [llvm] r86064 - /llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp Message-ID: <200911042311.nA4NB777005594@zion.cs.uiuc.edu> Author: grosbach Date: Wed Nov 4 17:11:07 2009 New Revision: 86064 URL: http://llvm.org/viewvc/llvm-project?rev=86064&view=rev Log: Now that the memory leak from McCat/08-main has been fixed (86056), re-enable aggressive testing of dynamic stack alignment. Note that this is off by default, and enabled for LLCBETA nightly results. Modified: llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp Modified: llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp?rev=86064&r1=86063&r2=86064&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp Wed Nov 4 17:11:07 2009 @@ -476,7 +476,11 @@ } static unsigned calculateMaxStackAlignment(const MachineFrameInfo *FFI) { - unsigned MaxAlign = 0; + // FIXME: For now, force at least 128-bit alignment. This will push the + // nightly tester harder for making sure things work correctly. When + // we're ready to enable this for real, this goes back to starting at zero. + unsigned MaxAlign = 16; +// unsigned MaxAlign = 0; for (int i = FFI->getObjectIndexBegin(), e = FFI->getObjectIndexEnd(); i != e; ++i) { @@ -509,13 +513,15 @@ if (!ARMDynamicStackAlign) return false; + // FIXME: To force more brutal testing, realign whether we need to or not. + // Change this to be more selective when we turn it on for real, of course. const MachineFrameInfo *MFI = MF.getFrameInfo(); const ARMFunctionInfo *AFI = MF.getInfo(); - unsigned StackAlign = MF.getTarget().getFrameInfo()->getStackAlignment(); +// unsigned StackAlign = MF.getTarget().getFrameInfo()->getStackAlignment(); return (RealignStack && !AFI->isThumb1OnlyFunction() && AFI->hasStackFrame() && - (MFI->getMaxAlignment() > StackAlign) && +// (MFI->getMaxAlignment() > StackAlign) && !MFI->hasVarSizedObjects()); } From sabre at nondot.org Wed Nov 4 17:20:12 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 04 Nov 2009 23:20:12 -0000 Subject: [llvm-commits] [llvm] r86067 - in /llvm/trunk: lib/Transforms/Scalar/DeadStoreElimination.cpp lib/Transforms/Scalar/JumpThreading.cpp test/Transforms/DeadStoreElimination/no-targetdata.ll Message-ID: <200911042320.nA4NKCcG005965@zion.cs.uiuc.edu> Author: lattner Date: Wed Nov 4 17:20:12 2009 New Revision: 86067 URL: http://llvm.org/viewvc/llvm-project?rev=86067&view=rev Log: improve DSE when TargetData is not around, based on work by Hans Wennborg! Added: llvm/trunk/test/Transforms/DeadStoreElimination/no-targetdata.ll Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp?rev=86067&r1=86066&r2=86067&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Wed Nov 4 17:20:12 2009 @@ -78,6 +78,21 @@ FunctionPass *llvm::createDeadStoreEliminationPass() { return new DSE(); } +/// isValueAtLeastAsBigAs - Return true if V1 is greater than or equal to the +/// stored size of V2. This returns false if we don't know. +/// +static bool isValueAtLeastAsBigAs(Value *V1, Value *V2, const TargetData *TD) { + const Type *V1Ty = V1->getType(), *V2Ty = V2->getType(); + + // Exactly the same type, must have exactly the same size. + if (V1Ty == V2Ty) return true; + + // If we don't have target data, we don't know. + if (TD == 0) return false; + + return TD->getTypeStoreSize(V1Ty) >= TD->getTypeStoreSize(V2Ty); +} + bool DSE::runOnBasicBlock(BasicBlock &BB) { MemoryDependenceAnalysis& MD = getAnalysis(); TD = getAnalysisIfAvailable(); @@ -118,9 +133,7 @@ // If this is a store-store dependence, then the previous store is dead so // long as this store is at least as big as it. if (StoreInst *DepStore = dyn_cast(InstDep.getInst())) - if (TD && - TD->getTypeStoreSize(DepStore->getOperand(0)->getType()) <= - TD->getTypeStoreSize(SI->getOperand(0)->getType())) { + if (isValueAtLeastAsBigAs(SI->getOperand(0), DepStore->getOperand(0),TD)){ // Delete the store and now-dead instructions that feed it. DeleteDeadInstruction(DepStore); NumFastStores++; Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=86067&r1=86066&r2=86067&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Wed Nov 4 17:20:12 2009 @@ -68,9 +68,6 @@ static char ID; // Pass identification JumpThreading() : FunctionPass(&ID) {} - virtual void getAnalysisUsage(AnalysisUsage &AU) const { - } - bool runOnFunction(Function &F); void FindLoopHeaders(Function &F); Added: llvm/trunk/test/Transforms/DeadStoreElimination/no-targetdata.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/DeadStoreElimination/no-targetdata.ll?rev=86067&view=auto ============================================================================== --- llvm/trunk/test/Transforms/DeadStoreElimination/no-targetdata.ll (added) +++ llvm/trunk/test/Transforms/DeadStoreElimination/no-targetdata.ll Wed Nov 4 17:20:12 2009 @@ -0,0 +1,15 @@ +; RUN: opt %s -dse -S | FileCheck %s + +declare void @test1f() + +define void @test1(i32* noalias %p) { + store i32 1, i32* %p; + call void @test1f() + store i32 2, i32 *%p + ret void +; CHECK: define void @test1 +; CHECK-NOT: store +; CHECK-NEXT: call void +; CHECK-NEXT: store i32 2 +; CHECK-NEXT: ret void +} \ No newline at end of file From grosbach at apple.com Wed Nov 4 17:20:42 2009 From: grosbach at apple.com (Jim Grosbach) Date: Wed, 04 Nov 2009 23:20:42 -0000 Subject: [llvm-commits] [llvm] r86068 - /llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp Message-ID: <200911042320.nA4NKgjg005995@zion.cs.uiuc.edu> Author: grosbach Date: Wed Nov 4 17:20:40 2009 New Revision: 86068 URL: http://llvm.org/viewvc/llvm-project?rev=86068&view=rev Log: Grammar. Modified: llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp Modified: llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp?rev=86068&r1=86067&r2=86068&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp Wed Nov 4 17:20:40 2009 @@ -1212,7 +1212,7 @@ return ScratchReg; } -/// Move iterator pass the next bunch of callee save load / store ops for +/// Move iterator past the next bunch of callee save load / store ops for /// the particular spill area (1: integer area 1, 2: integer area 2, /// 3: fp area, 0: don't care). static void movePastCSLoadStoreOps(MachineBasicBlock &MBB, From espindola at google.com Wed Nov 4 17:34:59 2009 From: espindola at google.com (Rafael Espindola) Date: Wed, 4 Nov 2009 18:34:59 -0500 Subject: [llvm-commits] [patch] Make compiler-rt build on linux In-Reply-To: <38a0d8450911041445q25c909ctbb92caa9b3dc402f@mail.gmail.com> References: <38a0d8450911041445q25c909ctbb92caa9b3dc402f@mail.gmail.com> Message-ID: <38a0d8450911041534r75a6cbb5w2f82d3a83a4a7979@mail.gmail.com> > make TargetArch=i386 Which is incorrect since -m32 is missing. The attached patch makes it build in 32 bit too. Cheers, -- Rafael ?vila de Esp?ndola -------------- next part -------------- A non-text attachment was scrubbed... Name: shared.patch Type: text/x-diff Size: 6459 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091104/cfb8da49/attachment.bin From dpatel at apple.com Wed Nov 4 17:48:01 2009 From: dpatel at apple.com (Devang Patel) Date: Wed, 04 Nov 2009 23:48:01 -0000 Subject: [llvm-commits] [llvm] r86073 - in /llvm/trunk/lib: Analysis/DebugInfo.cpp CodeGen/AsmPrinter/DwarfDebug.cpp Message-ID: <200911042348.nA4Nm1cc007091@zion.cs.uiuc.edu> Author: dpatel Date: Wed Nov 4 17:48:00 2009 New Revision: 86073 URL: http://llvm.org/viewvc/llvm-project?rev=86073&view=rev Log: While calculating original type size for a derived type, handle type variants encoded as DIDerivedType appropriately. This improves bitfield support. Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DebugInfo.cpp?rev=86073&r1=86072&r2=86073&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/DebugInfo.cpp (original) +++ llvm/trunk/lib/Analysis/DebugInfo.cpp Wed Nov 4 17:48:00 2009 @@ -401,12 +401,18 @@ /// getOriginalTypeSize - If this type is derived from a base type then /// return base type size. uint64_t DIDerivedType::getOriginalTypeSize() const { - DIType BT = getTypeDerivedFrom(); - if (!BT.isNull() && BT.isDerivedType()) - return DIDerivedType(BT.getNode()).getOriginalTypeSize(); - if (BT.isNull()) - return getSizeInBits(); - return BT.getSizeInBits(); + unsigned Tag = getTag(); + if (Tag == dwarf::DW_TAG_member || Tag == dwarf::DW_TAG_typedef || + Tag == dwarf::DW_TAG_const_type || Tag == dwarf::DW_TAG_volatile_type || + Tag == dwarf::DW_TAG_restrict_type) { + DIType BaseType = getTypeDerivedFrom(); + if (BaseType.isDerivedType()) + return DIDerivedType(BaseType.getNode()).getOriginalTypeSize(); + else + return BaseType.getSizeInBits(); + } + + return getSizeInBits(); } /// describes - Return true if this subprogram provides debugging Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=86073&r1=86072&r2=86073&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Wed Nov 4 17:48:00 2009 @@ -1141,9 +1141,7 @@ AddUInt(MemLocationDie, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_plus_uconst); uint64_t Size = DT.getSizeInBits(); - uint64_t FieldSize = Size; - if (DT.getTypeDerivedFrom().getTag() != dwarf::DW_TAG_array_type) - FieldSize = DT.getOriginalTypeSize(); + uint64_t FieldSize = DT.getOriginalTypeSize(); if (Size != FieldSize) { // Handle bitfield. From eocallaghan at auroraux.org Wed Nov 4 17:52:52 2009 From: eocallaghan at auroraux.org (Edward O'Callaghan) Date: Wed, 04 Nov 2009 23:52:52 -0000 Subject: [llvm-commits] [compiler-rt] r86075 - in /compiler-rt/trunk/lib: i386/floatdidf.S i386/floatdixf.S i386/floatundidf.S i386/floatundisf.S i386/floatundixf.S x86_64/floatundidf.S x86_64/floatundisf.S x86_64/floatundixf.S Message-ID: <200911042352.nA4Nqqqe007264@zion.cs.uiuc.edu> Author: evocallaghan Date: Wed Nov 4 17:52:51 2009 New Revision: 86075 URL: http://llvm.org/viewvc/llvm-project?rev=86075&view=rev Log: Fix x86/x64 on Linux, Credit to Rafael Espindola. Modified: compiler-rt/trunk/lib/i386/floatdidf.S compiler-rt/trunk/lib/i386/floatdixf.S compiler-rt/trunk/lib/i386/floatundidf.S compiler-rt/trunk/lib/i386/floatundisf.S compiler-rt/trunk/lib/i386/floatundixf.S compiler-rt/trunk/lib/x86_64/floatundidf.S compiler-rt/trunk/lib/x86_64/floatundisf.S compiler-rt/trunk/lib/x86_64/floatundixf.S Modified: compiler-rt/trunk/lib/i386/floatdidf.S URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/i386/floatdidf.S?rev=86075&r1=86074&r2=86075&view=diff ============================================================================== --- compiler-rt/trunk/lib/i386/floatdidf.S (original) +++ compiler-rt/trunk/lib/i386/floatdidf.S Wed Nov 4 17:52:51 2009 @@ -7,7 +7,9 @@ #ifdef __i386__ +#ifndef __ELF__ .const +#endif .align 4 twop52: .quad 0x4330000000000000 twop32: .quad 0x41f0000000000000 Modified: compiler-rt/trunk/lib/i386/floatdixf.S URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/i386/floatdixf.S?rev=86075&r1=86074&r2=86075&view=diff ============================================================================== --- compiler-rt/trunk/lib/i386/floatdixf.S (original) +++ compiler-rt/trunk/lib/i386/floatdixf.S Wed Nov 4 17:52:51 2009 @@ -26,4 +26,4 @@ fildll 4(%esp) ret -#endif // __i386__ \ No newline at end of file +#endif // __i386__ Modified: compiler-rt/trunk/lib/i386/floatundidf.S URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/i386/floatundidf.S?rev=86075&r1=86074&r2=86075&view=diff ============================================================================== --- compiler-rt/trunk/lib/i386/floatundidf.S (original) +++ compiler-rt/trunk/lib/i386/floatundidf.S Wed Nov 4 17:52:51 2009 @@ -17,7 +17,9 @@ #ifdef __i386__ +#ifndef __ELF__ .const +#endif .align 4 twop52: .quad 0x4330000000000000 twop84_plus_twop52: Modified: compiler-rt/trunk/lib/i386/floatundisf.S URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/i386/floatundisf.S?rev=86075&r1=86074&r2=86075&view=diff ============================================================================== --- compiler-rt/trunk/lib/i386/floatundisf.S (original) +++ compiler-rt/trunk/lib/i386/floatundisf.S Wed Nov 4 17:52:51 2009 @@ -51,8 +51,12 @@ #ifdef __i386__ +#ifndef __ELF__ .const .align 3 +#else +.align 8 +#endif twop52: .quad 0x4330000000000000 .quad 0x0000000000000fff sticky: .quad 0x0000000000000000 Modified: compiler-rt/trunk/lib/i386/floatundixf.S URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/i386/floatundixf.S?rev=86075&r1=86074&r2=86075&view=diff ============================================================================== --- compiler-rt/trunk/lib/i386/floatundixf.S (original) +++ compiler-rt/trunk/lib/i386/floatundixf.S Wed Nov 4 17:52:51 2009 @@ -7,7 +7,9 @@ #ifdef __i386__ +#ifndef __ELF__ .const +#endif .align 4 twop52: .quad 0x4330000000000000 twop84_plus_twop52_neg: @@ -32,4 +34,4 @@ faddl 4(%esp) ret -#endif // __i386__ \ No newline at end of file +#endif // __i386__ Modified: compiler-rt/trunk/lib/x86_64/floatundidf.S URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/x86_64/floatundidf.S?rev=86075&r1=86074&r2=86075&view=diff ============================================================================== --- compiler-rt/trunk/lib/x86_64/floatundidf.S (original) +++ compiler-rt/trunk/lib/x86_64/floatundidf.S Wed Nov 4 17:52:51 2009 @@ -17,7 +17,9 @@ #ifdef __x86_64__ +#ifndef __ELF__ .const +#endif .align 4 twop52: .quad 0x4330000000000000 twop84_plus_twop52: @@ -38,4 +40,4 @@ addsd %xmm1, %xmm0 // a_hi + a_lo (round happens here) ret -#endif // __x86_64__ \ No newline at end of file +#endif // __x86_64__ Modified: compiler-rt/trunk/lib/x86_64/floatundisf.S URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/x86_64/floatundisf.S?rev=86075&r1=86074&r2=86075&view=diff ============================================================================== --- compiler-rt/trunk/lib/x86_64/floatundisf.S (original) +++ compiler-rt/trunk/lib/x86_64/floatundisf.S Wed Nov 4 17:52:51 2009 @@ -7,7 +7,9 @@ #ifdef __x86_64__ +#ifndef __ELF__ .literal4 +#endif two: .single 2.0 #define REL_ADDR(_a) (_a)(%rip) @@ -28,4 +30,4 @@ mulss REL_ADDR(two), %xmm0 ret -#endif // __x86_64__ \ No newline at end of file +#endif // __x86_64__ Modified: compiler-rt/trunk/lib/x86_64/floatundixf.S URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/x86_64/floatundixf.S?rev=86075&r1=86074&r2=86075&view=diff ============================================================================== --- compiler-rt/trunk/lib/x86_64/floatundixf.S (original) +++ compiler-rt/trunk/lib/x86_64/floatundixf.S Wed Nov 4 17:52:51 2009 @@ -7,7 +7,9 @@ #ifdef __x86_64__ +#ifndef __ELF__ .const +#endif .align 4 twop64: .quad 0x43f0000000000000 @@ -57,4 +59,4 @@ #endif // __x86_64__ -*/ \ No newline at end of file +*/ From ssen at apple.com Wed Nov 4 17:57:44 2009 From: ssen at apple.com (Shantonu Sen) Date: Wed, 4 Nov 2009 15:57:44 -0800 Subject: [llvm-commits] [compiler-rt] r86075 - in /compiler-rt/trunk/lib: i386/floatdidf.S i386/floatdixf.S i386/floatundidf.S i386/floatundisf.S i386/floatundixf.S x86_64/floatundidf.S x86_64/floatundisf.S x86_64/floatundixf.S In-Reply-To: <200911042352.nA4Nqqqe007264@zion.cs.uiuc.edu> References: <200911042352.nA4Nqqqe007264@zion.cs.uiuc.edu> Message-ID: If newer binutils supports ".p2align 3", you can use that too. That should work on Darwin as well without requiring a conditional. Shantonu Sen ssen at apple.com Sent from my Mac Pro On Nov 4, 2009, at 3:52 PM, Edward O'Callaghan wrote: > Author: evocallaghan > Date: Wed Nov 4 17:52:51 2009 > New Revision: 86075 > > URL: http://llvm.org/viewvc/llvm-project?rev=86075&view=rev > Log: > Fix x86/x64 on Linux, Credit to Rafael Espindola. > > Modified: > compiler-rt/trunk/lib/i386/floatdidf.S > compiler-rt/trunk/lib/i386/floatdixf.S > compiler-rt/trunk/lib/i386/floatundidf.S > compiler-rt/trunk/lib/i386/floatundisf.S > compiler-rt/trunk/lib/i386/floatundixf.S > compiler-rt/trunk/lib/x86_64/floatundidf.S > compiler-rt/trunk/lib/x86_64/floatundisf.S > compiler-rt/trunk/lib/x86_64/floatundixf.S > > Modified: compiler-rt/trunk/lib/i386/floatdidf.S > URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/i386/floatdidf.S?rev=86075&r1=86074&r2=86075&view=diff > > ============================================================================== > --- compiler-rt/trunk/lib/i386/floatdidf.S (original) > +++ compiler-rt/trunk/lib/i386/floatdidf.S Wed Nov 4 17:52:51 2009 > @@ -7,7 +7,9 @@ > > #ifdef __i386__ > > +#ifndef __ELF__ > .const > +#endif > .align 4 > twop52: .quad 0x4330000000000000 > twop32: .quad 0x41f0000000000000 > > Modified: compiler-rt/trunk/lib/i386/floatdixf.S > URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/i386/floatdixf.S?rev=86075&r1=86074&r2=86075&view=diff > > ============================================================================== > --- compiler-rt/trunk/lib/i386/floatdixf.S (original) > +++ compiler-rt/trunk/lib/i386/floatdixf.S Wed Nov 4 17:52:51 2009 > @@ -26,4 +26,4 @@ > fildll 4(%esp) > ret > > -#endif // __i386__ > \ No newline at end of file > +#endif // __i386__ > > Modified: compiler-rt/trunk/lib/i386/floatundidf.S > URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/i386/floatundidf.S?rev=86075&r1=86074&r2=86075&view=diff > > ============================================================================== > --- compiler-rt/trunk/lib/i386/floatundidf.S (original) > +++ compiler-rt/trunk/lib/i386/floatundidf.S Wed Nov 4 17:52:51 2009 > @@ -17,7 +17,9 @@ > > #ifdef __i386__ > > +#ifndef __ELF__ > .const > +#endif > .align 4 > twop52: .quad 0x4330000000000000 > twop84_plus_twop52: > > Modified: compiler-rt/trunk/lib/i386/floatundisf.S > URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/i386/floatundisf.S?rev=86075&r1=86074&r2=86075&view=diff > > ============================================================================== > --- compiler-rt/trunk/lib/i386/floatundisf.S (original) > +++ compiler-rt/trunk/lib/i386/floatundisf.S Wed Nov 4 17:52:51 2009 > @@ -51,8 +51,12 @@ > > #ifdef __i386__ > > +#ifndef __ELF__ > .const > .align 3 > +#else > +.align 8 > +#endif > twop52: .quad 0x4330000000000000 > .quad 0x0000000000000fff > sticky: .quad 0x0000000000000000 > > Modified: compiler-rt/trunk/lib/i386/floatundixf.S > URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/i386/floatundixf.S?rev=86075&r1=86074&r2=86075&view=diff > > ============================================================================== > --- compiler-rt/trunk/lib/i386/floatundixf.S (original) > +++ compiler-rt/trunk/lib/i386/floatundixf.S Wed Nov 4 17:52:51 2009 > @@ -7,7 +7,9 @@ > > #ifdef __i386__ > > +#ifndef __ELF__ > .const > +#endif > .align 4 > twop52: .quad 0x4330000000000000 > twop84_plus_twop52_neg: > @@ -32,4 +34,4 @@ > faddl 4(%esp) > ret > > -#endif // __i386__ > \ No newline at end of file > +#endif // __i386__ > > Modified: compiler-rt/trunk/lib/x86_64/floatundidf.S > URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/x86_64/floatundidf.S?rev=86075&r1=86074&r2=86075&view=diff > > ============================================================================== > --- compiler-rt/trunk/lib/x86_64/floatundidf.S (original) > +++ compiler-rt/trunk/lib/x86_64/floatundidf.S Wed Nov 4 17:52:51 2009 > @@ -17,7 +17,9 @@ > > #ifdef __x86_64__ > > +#ifndef __ELF__ > .const > +#endif > .align 4 > twop52: .quad 0x4330000000000000 > twop84_plus_twop52: > @@ -38,4 +40,4 @@ > addsd %xmm1, %xmm0 // a_hi + a_lo (round happens here) > ret > > -#endif // __x86_64__ > \ No newline at end of file > +#endif // __x86_64__ > > Modified: compiler-rt/trunk/lib/x86_64/floatundisf.S > URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/x86_64/floatundisf.S?rev=86075&r1=86074&r2=86075&view=diff > > ============================================================================== > --- compiler-rt/trunk/lib/x86_64/floatundisf.S (original) > +++ compiler-rt/trunk/lib/x86_64/floatundisf.S Wed Nov 4 17:52:51 2009 > @@ -7,7 +7,9 @@ > > #ifdef __x86_64__ > > +#ifndef __ELF__ > .literal4 > +#endif > two: .single 2.0 > > #define REL_ADDR(_a) (_a)(%rip) > @@ -28,4 +30,4 @@ > mulss REL_ADDR(two), %xmm0 > ret > > -#endif // __x86_64__ > \ No newline at end of file > +#endif // __x86_64__ > > Modified: compiler-rt/trunk/lib/x86_64/floatundixf.S > URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/x86_64/floatundixf.S?rev=86075&r1=86074&r2=86075&view=diff > > ============================================================================== > --- compiler-rt/trunk/lib/x86_64/floatundixf.S (original) > +++ compiler-rt/trunk/lib/x86_64/floatundixf.S Wed Nov 4 17:52:51 2009 > @@ -7,7 +7,9 @@ > > #ifdef __x86_64__ > > +#ifndef __ELF__ > .const > +#endif > .align 4 > twop64: .quad 0x43f0000000000000 > > @@ -57,4 +59,4 @@ > > #endif // __x86_64__ > > -*/ > \ No newline at end of file > +*/ > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From eocallaghan at auroraux.org Wed Nov 4 17:58:33 2009 From: eocallaghan at auroraux.org (Edward O'Callaghan) Date: Wed, 4 Nov 2009 23:58:33 +0000 Subject: [llvm-commits] [patch] Make compiler-rt build on linux In-Reply-To: <38a0d8450911041534r75a6cbb5w2f82d3a83a4a7979@mail.gmail.com> References: <38a0d8450911041445q25c909ctbb92caa9b3dc402f@mail.gmail.com> <38a0d8450911041534r75a6cbb5w2f82d3a83a4a7979@mail.gmail.com> Message-ID: <521640720911041558m5d890cc5y22d050267966599e@mail.gmail.com> Second patch was committed in revision 86075. However the patching to: * 'make/config.mk' * 'Makefile' was left out, as we take patches for the new *portable* cmake build system and I am not reasonable nor do I have a way to test patches to the old apple makefiles as they don't work on all hosts. In future, please make patches to the cmake system, Many thanks, Edward. 2009/11/4 Rafael Espindola : >> make TargetArch=i386 > > Which is incorrect since -m32 is missing. The attached patch makes it > build in 32 bit too. > > Cheers, > -- > Rafael ?vila de Esp?ndola > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > -- -- Edward O'Callaghan http://www.auroraux.org/ eocallaghan at auroraux dot org From vhernandez at apple.com Wed Nov 4 18:03:03 2009 From: vhernandez at apple.com (Victor Hernandez) Date: Thu, 05 Nov 2009 00:03:03 -0000 Subject: [llvm-commits] [llvm] r86077 - in /llvm/trunk: examples/BrainF/ include/llvm/ include/llvm/Analysis/ lib/Analysis/ lib/AsmParser/ lib/Bitcode/Reader/ lib/Transforms/IPO/ lib/VMCore/ test/Analysis/PointerTracking/ test/Transforms/GlobalOpt/ Message-ID: <200911050003.nA5034uP007663@zion.cs.uiuc.edu> Author: hernande Date: Wed Nov 4 18:03:03 2009 New Revision: 86077 URL: http://llvm.org/viewvc/llvm-project?rev=86077&view=rev Log: Update CreateMalloc so that its callers specify the size to allocate: MallocInst-autoupgrade users use non-TargetData-computed allocation sizes. Optimization uses use TargetData to compute the allocation size. Now that malloc calls can have constant sizes, update isArrayMallocHelper() to use TargetData to determine the size of the malloced type and the size of malloced arrays. Extend getMallocType() to support malloc calls that have non-bitcast uses. Update OptimizeGlobalAddressOfMalloc() to optimize malloc calls that have non-bitcast uses. The bitcast use of a malloc call has to be treated specially here because the uses of the bitcast need to be replaced and the bitcast needs to be erased (just like the malloc call) for OptimizeGlobalAddressOfMalloc() to work correctly. Update PerformHeapAllocSRoA() to optimize malloc calls that have non-bitcast uses. The bitcast use of the malloc is not handled specially here because ReplaceUsesOfMallocWithGlobal replaces through the bitcast use. Update OptimizeOnceStoredGlobal() to not care about the malloc calls' bitcast use. Update all globalopt malloc tests to not rely on autoupgraded-MallocInsts, but instead use explicit malloc calls with correct allocation sizes. Modified: llvm/trunk/examples/BrainF/BrainF.cpp llvm/trunk/include/llvm/Analysis/MemoryBuiltins.h llvm/trunk/include/llvm/Instructions.h llvm/trunk/lib/Analysis/MemoryBuiltins.cpp llvm/trunk/lib/AsmParser/LLParser.cpp llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp llvm/trunk/lib/VMCore/Core.cpp llvm/trunk/lib/VMCore/Instructions.cpp llvm/trunk/test/Analysis/PointerTracking/sizes.ll llvm/trunk/test/Transforms/GlobalOpt/2009-06-01-RecursivePHI.ll llvm/trunk/test/Transforms/GlobalOpt/heap-sra-1.ll llvm/trunk/test/Transforms/GlobalOpt/heap-sra-2.ll llvm/trunk/test/Transforms/GlobalOpt/heap-sra-3.ll llvm/trunk/test/Transforms/GlobalOpt/heap-sra-4.ll llvm/trunk/test/Transforms/GlobalOpt/heap-sra-phi.ll llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-1.ll llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-2.ll llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-3.ll Modified: llvm/trunk/examples/BrainF/BrainF.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/BrainF/BrainF.cpp?rev=86077&r1=86076&r2=86077&view=diff ============================================================================== --- llvm/trunk/examples/BrainF/BrainF.cpp (original) +++ llvm/trunk/examples/BrainF/BrainF.cpp Wed Nov 4 18:03:03 2009 @@ -81,8 +81,11 @@ ConstantInt *val_mem = ConstantInt::get(C, APInt(32, memtotal)); BasicBlock* BB = builder->GetInsertBlock(); const Type* IntPtrTy = IntegerType::getInt32Ty(C); - ptr_arr = CallInst::CreateMalloc(BB, IntPtrTy, IntegerType::getInt8Ty(C), - val_mem, NULL, "arr"); + const Type* Int8Ty = IntegerType::getInt8Ty(C); + Constant* allocsize = ConstantExpr::getSizeOf(Int8Ty); + allocsize = ConstantExpr::getTruncOrBitCast(allocsize, IntPtrTy); + ptr_arr = CallInst::CreateMalloc(BB, IntPtrTy, Int8Ty, allocsize, val_mem, + NULL, "arr"); BB->getInstList().push_back(cast(ptr_arr)); //call void @llvm.memset.i32(i8 *%arr, i8 0, i32 %d, i32 1) Modified: llvm/trunk/include/llvm/Analysis/MemoryBuiltins.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/MemoryBuiltins.h?rev=86077&r1=86076&r2=86077&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/MemoryBuiltins.h (original) +++ llvm/trunk/include/llvm/Analysis/MemoryBuiltins.h Wed Nov 4 18:03:03 2009 @@ -50,13 +50,17 @@ const TargetData* TD); /// getMallocType - Returns the PointerType resulting from the malloc call. -/// This PointerType is the result type of the call's only bitcast use. -/// If there is no unique bitcast use, then return NULL. +/// The PointerType depends on the number of bitcast uses of the malloc call: +/// 0: PointerType is the malloc calls' return type. +/// 1: PointerType is the bitcast's result type. +/// >1: Unique PointerType cannot be determined, return NULL. const PointerType* getMallocType(const CallInst* CI); -/// getMallocAllocatedType - Returns the Type allocated by malloc call. This -/// Type is the result type of the call's only bitcast use. If there is no -/// unique bitcast use, then return NULL. +/// getMallocAllocatedType - Returns the Type allocated by malloc call. +/// The Type depends on the number of bitcast uses of the malloc call: +/// 0: PointerType is the malloc calls' return type. +/// 1: PointerType is the bitcast's result type. +/// >1: Unique PointerType cannot be determined, return NULL. const Type* getMallocAllocatedType(const CallInst* CI); /// getMallocArraySize - Returns the array size of a malloc call. If the Modified: llvm/trunk/include/llvm/Instructions.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Instructions.h?rev=86077&r1=86076&r2=86077&view=diff ============================================================================== --- llvm/trunk/include/llvm/Instructions.h (original) +++ llvm/trunk/include/llvm/Instructions.h Wed Nov 4 18:03:03 2009 @@ -899,11 +899,12 @@ /// 3. Bitcast the result of the malloc call to the specified type. static Instruction *CreateMalloc(Instruction *InsertBefore, const Type *IntPtrTy, const Type *AllocTy, - Value *ArraySize = 0, + Value *AllocSize, Value *ArraySize = 0, const Twine &Name = ""); static Instruction *CreateMalloc(BasicBlock *InsertAtEnd, const Type *IntPtrTy, const Type *AllocTy, - Value *ArraySize = 0, Function* MallocF = 0, + Value *AllocSize, Value *ArraySize = 0, + Function* MallocF = 0, const Twine &Name = ""); /// CreateFree - Generate the IR for a call to the builtin free function. static void CreateFree(Value* Source, Instruction *InsertBefore); Modified: llvm/trunk/lib/Analysis/MemoryBuiltins.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryBuiltins.cpp?rev=86077&r1=86076&r2=86077&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/MemoryBuiltins.cpp (original) +++ llvm/trunk/lib/Analysis/MemoryBuiltins.cpp Wed Nov 4 18:03:03 2009 @@ -17,6 +17,7 @@ #include "llvm/Instructions.h" #include "llvm/Module.h" #include "llvm/Analysis/ConstantFolding.h" +#include "llvm/Target/TargetData.h" using namespace llvm; //===----------------------------------------------------------------------===// @@ -96,45 +97,47 @@ if (!CI) return NULL; - // Type must be known to determine array size. + // The size of the malloc's result type must be known to determine array size. const Type *T = getMallocAllocatedType(CI); - if (!T) + if (!T || !T->isSized() || !TD) return NULL; Value *MallocArg = CI->getOperand(1); + const Type *ArgType = MallocArg->getType(); ConstantExpr *CO = dyn_cast(MallocArg); BinaryOperator *BO = dyn_cast(MallocArg); - Constant *ElementSize = ConstantExpr::getSizeOf(T); - ElementSize = ConstantExpr::getTruncOrBitCast(ElementSize, - MallocArg->getType()); - Constant *FoldedElementSize = - ConstantFoldConstantExpression(cast(ElementSize), Context, TD); + unsigned ElementSizeInt = TD->getTypeAllocSize(T); + if (const StructType *ST = dyn_cast(T)) + ElementSizeInt = TD->getStructLayout(ST)->getSizeInBytes(); + Constant *ElementSize = ConstantInt::get(ArgType, ElementSizeInt); // First, check if CI is a non-array malloc. - if (CO && ((CO == ElementSize) || - (FoldedElementSize && (CO == FoldedElementSize)))) + if (CO && CO == ElementSize) // Match CreateMalloc's use of constant 1 array-size for non-array mallocs. - return ConstantInt::get(MallocArg->getType(), 1); + return ConstantInt::get(ArgType, 1); // Second, check if CI is an array malloc whose array size can be determined. - if (isConstantOne(ElementSize) || - (FoldedElementSize && isConstantOne(FoldedElementSize))) + if (isConstantOne(ElementSize)) return MallocArg; + if (ConstantInt *CInt = dyn_cast(MallocArg)) + if (CInt->getZExtValue() % ElementSizeInt == 0) + return ConstantInt::get(ArgType, CInt->getZExtValue() / ElementSizeInt); + if (!CO && !BO) return NULL; Value *Op0 = NULL; Value *Op1 = NULL; unsigned Opcode = 0; - if (CO && ((CO->getOpcode() == Instruction::Mul) || + if (CO && ((CO->getOpcode() == Instruction::Mul) || (CO->getOpcode() == Instruction::Shl))) { Op0 = CO->getOperand(0); Op1 = CO->getOperand(1); Opcode = CO->getOpcode(); } - if (BO && ((BO->getOpcode() == Instruction::Mul) || + if (BO && ((BO->getOpcode() == Instruction::Mul) || (BO->getOpcode() == Instruction::Shl))) { Op0 = BO->getOperand(0); Op1 = BO->getOperand(1); @@ -144,12 +147,10 @@ // Determine array size if malloc's argument is the product of a mul or shl. if (Op0) { if (Opcode == Instruction::Mul) { - if ((Op1 == ElementSize) || - (FoldedElementSize && (Op1 == FoldedElementSize))) + if (Op1 == ElementSize) // ArraySize * ElementSize return Op0; - if ((Op0 == ElementSize) || - (FoldedElementSize && (Op0 == FoldedElementSize))) + if (Op0 == ElementSize) // ElementSize * ArraySize return Op1; } @@ -161,11 +162,10 @@ uint64_t BitToSet = Op1Int.getLimitedValue(Op1Int.getBitWidth() - 1); Value *Op1Pow = ConstantInt::get(Context, APInt(Op1Int.getBitWidth(), 0).set(BitToSet)); - if (Op0 == ElementSize || (FoldedElementSize && Op0 == FoldedElementSize)) + if (Op0 == ElementSize) // ArraySize << log2(ElementSize) return Op1Pow; - if (Op1Pow == ElementSize || - (FoldedElementSize && Op1Pow == FoldedElementSize)) + if (Op1Pow == ElementSize) // ElementSize << log2(ArraySize) return Op0; } @@ -205,35 +205,41 @@ } /// getMallocType - Returns the PointerType resulting from the malloc call. -/// This PointerType is the result type of the call's only bitcast use. -/// If there is no unique bitcast use, then return NULL. +/// The PointerType depends on the number of bitcast uses of the malloc call: +/// 0: PointerType is the calls' return type. +/// 1: PointerType is the bitcast's result type. +/// >1: Unique PointerType cannot be determined, return NULL. const PointerType *llvm::getMallocType(const CallInst *CI) { assert(isMalloc(CI) && "GetMallocType and not malloc call"); - const BitCastInst *BCI = NULL; - + const PointerType *MallocType = NULL; + unsigned NumOfBitCastUses = 0; + // Determine if CallInst has a bitcast use. for (Value::use_const_iterator UI = CI->use_begin(), E = CI->use_end(); UI != E; ) - if ((BCI = dyn_cast(cast(*UI++)))) - break; + if (const BitCastInst *BCI = dyn_cast(*UI++)) { + MallocType = cast(BCI->getDestTy()); + NumOfBitCastUses++; + } - // Malloc call has 1 bitcast use and no other uses, so type is the bitcast's - // destination type. - if (BCI && CI->hasOneUse()) - return cast(BCI->getDestTy()); + // Malloc call has 1 bitcast use, so type is the bitcast's destination type. + if (NumOfBitCastUses == 1) + return MallocType; // Malloc call was not bitcast, so type is the malloc function's return type. - if (!BCI) + if (NumOfBitCastUses == 0) return cast(CI->getType()); // Type could not be determined. return NULL; } -/// getMallocAllocatedType - Returns the Type allocated by malloc call. This -/// Type is the result type of the call's only bitcast use. If there is no -/// unique bitcast use, then return NULL. +/// getMallocAllocatedType - Returns the Type allocated by malloc call. +/// The Type depends on the number of bitcast uses of the malloc call: +/// 0: PointerType is the malloc calls' return type. +/// 1: PointerType is the bitcast's result type. +/// >1: Unique PointerType cannot be determined, return NULL. const Type *llvm::getMallocAllocatedType(const CallInst *CI) { const PointerType *PT = getMallocType(CI); return PT ? PT->getElementType() : NULL; Modified: llvm/trunk/lib/AsmParser/LLParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=86077&r1=86076&r2=86077&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLParser.cpp (original) +++ llvm/trunk/lib/AsmParser/LLParser.cpp Wed Nov 4 18:03:03 2009 @@ -3619,12 +3619,14 @@ // Autoupgrade old malloc instruction to malloc call. // FIXME: Remove in LLVM 3.0. const Type *IntPtrTy = Type::getInt32Ty(Context); + Constant *AllocSize = ConstantExpr::getSizeOf(Ty); + AllocSize = ConstantExpr::getTruncOrBitCast(AllocSize, IntPtrTy); if (!MallocF) // Prototype malloc as "void *(int32)". // This function is renamed as "malloc" in ValidateEndOfModule(). MallocF = cast( M->getOrInsertFunction("", Type::getInt8PtrTy(Context), IntPtrTy, NULL)); - Inst = CallInst::CreateMalloc(BB, IntPtrTy, Ty, Size, MallocF); + Inst = CallInst::CreateMalloc(BB, IntPtrTy, Ty, AllocSize, Size, MallocF); return false; } Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=86077&r1=86076&r2=86077&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original) +++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Wed Nov 4 18:03:03 2009 @@ -2101,8 +2101,10 @@ if (!Ty || !Size) return Error("Invalid MALLOC record"); if (!CurBB) return Error("Invalid malloc instruction with no BB"); const Type *Int32Ty = IntegerType::getInt32Ty(CurBB->getContext()); + Constant *AllocSize = ConstantExpr::getSizeOf(Ty->getElementType()); + AllocSize = ConstantExpr::getTruncOrBitCast(AllocSize, Int32Ty); I = CallInst::CreateMalloc(CurBB, Int32Ty, Ty->getElementType(), - Size, NULL); + AllocSize, Size, NULL); InstructionList.push_back(I); break; } Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=86077&r1=86076&r2=86077&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Wed Nov 4 18:03:03 2009 @@ -822,32 +822,42 @@ /// malloc into a global, and any loads of GV as uses of the new global. static GlobalVariable *OptimizeGlobalAddressOfMalloc(GlobalVariable *GV, CallInst *CI, - BitCastInst *BCI, + const Type *AllocTy, Value* NElems, LLVMContext &Context, TargetData* TD) { - DEBUG(errs() << "PROMOTING MALLOC GLOBAL: " << *GV - << " CALL = " << *CI << " BCI = " << *BCI << '\n'); + DEBUG(errs() << "PROMOTING GLOBAL: " << *GV << " CALL = " << *CI << '\n'); const Type *IntPtrTy = TD->getIntPtrType(Context); + // CI has either 0 or 1 bitcast uses (getMallocType() would otherwise have + // returned NULL and we would not be here). + BitCastInst *BCI = NULL; + for (Value::use_iterator UI = CI->use_begin(), E = CI->use_end(); UI != E; ) + if ((BCI = dyn_cast(cast(*UI++)))) + break; + ConstantInt *NElements = cast(NElems); if (NElements->getZExtValue() != 1) { // If we have an array allocation, transform it to a single element // allocation to make the code below simpler. - Type *NewTy = ArrayType::get(getMallocAllocatedType(CI), - NElements->getZExtValue()); - Value* NewM = CallInst::CreateMalloc(CI, IntPtrTy, NewTy); - Instruction* NewMI = cast(NewM); + Type *NewTy = ArrayType::get(AllocTy, NElements->getZExtValue()); + unsigned TypeSize = TD->getTypeAllocSize(NewTy); + if (const StructType *ST = dyn_cast(NewTy)) + TypeSize = TD->getStructLayout(ST)->getSizeInBytes(); + Instruction *NewCI = CallInst::CreateMalloc(CI, IntPtrTy, NewTy, + ConstantInt::get(IntPtrTy, TypeSize)); Value* Indices[2]; Indices[0] = Indices[1] = Constant::getNullValue(IntPtrTy); - Value *NewGEP = GetElementPtrInst::Create(NewMI, Indices, Indices + 2, - NewMI->getName()+".el0", CI); - BCI->replaceAllUsesWith(NewGEP); - BCI->eraseFromParent(); + Value *NewGEP = GetElementPtrInst::Create(NewCI, Indices, Indices + 2, + NewCI->getName()+".el0", CI); + Value *Cast = new BitCastInst(NewGEP, CI->getType(), "el0", CI); + if (BCI) BCI->replaceAllUsesWith(NewGEP); + CI->replaceAllUsesWith(Cast); + if (BCI) BCI->eraseFromParent(); CI->eraseFromParent(); - BCI = cast(NewMI); - CI = extractMallocCallFromBitCast(NewMI); + BCI = dyn_cast(NewCI); + CI = BCI ? extractMallocCallFromBitCast(BCI) : cast(NewCI); } // Create the new global variable. The contents of the malloc'd memory is @@ -861,8 +871,9 @@ GV, GV->isThreadLocal()); - // Anything that used the malloc now uses the global directly. - BCI->replaceAllUsesWith(NewGV); + // Anything that used the malloc or its bitcast now uses the global directly. + if (BCI) BCI->replaceAllUsesWith(NewGV); + CI->replaceAllUsesWith(new BitCastInst(NewGV, CI->getType(), "newgv", CI)); Constant *RepValue = NewGV; if (NewGV->getType() != GV->getType()->getElementType()) @@ -930,9 +941,9 @@ GV->getParent()->getGlobalList().insert(GV, InitBool); - // Now the GV is dead, nuke it and the malloc. + // Now the GV is dead, nuke it and the malloc (both CI and BCI). GV->eraseFromParent(); - BCI->eraseFromParent(); + if (BCI) BCI->eraseFromParent(); CI->eraseFromParent(); // To further other optimizations, loop over all users of NewGV and try to @@ -1273,13 +1284,10 @@ /// PerformHeapAllocSRoA - CI is an allocation of an array of structures. Break /// it up into multiple allocations of arrays of the fields. -static GlobalVariable *PerformHeapAllocSRoA(GlobalVariable *GV, - CallInst *CI, BitCastInst* BCI, - Value* NElems, - LLVMContext &Context, +static GlobalVariable *PerformHeapAllocSRoA(GlobalVariable *GV, CallInst *CI, + Value* NElems, LLVMContext &Context, TargetData *TD) { - DEBUG(errs() << "SROA HEAP ALLOC: " << *GV << " MALLOC CALL = " << *CI - << " BITCAST = " << *BCI << '\n'); + DEBUG(errs() << "SROA HEAP ALLOC: " << *GV << " MALLOC = " << *CI << '\n'); const Type* MAT = getMallocAllocatedType(CI); const StructType *STy = cast(MAT); @@ -1287,8 +1295,8 @@ // it into GV). If there are other uses, change them to be uses of // the global to simplify later code. This also deletes the store // into GV. - ReplaceUsesOfMallocWithGlobal(BCI, GV); - + ReplaceUsesOfMallocWithGlobal(CI, GV); + // Okay, at this point, there are no users of the malloc. Insert N // new mallocs at the same place as CI, and N globals. std::vector FieldGlobals; @@ -1306,11 +1314,16 @@ GV->isThreadLocal()); FieldGlobals.push_back(NGV); - Value *NMI = CallInst::CreateMalloc(CI, TD->getIntPtrType(Context), - FieldTy, NElems, - BCI->getName() + ".f" + Twine(FieldNo)); + unsigned TypeSize = TD->getTypeAllocSize(FieldTy); + if (const StructType* ST = dyn_cast(FieldTy)) + TypeSize = TD->getStructLayout(ST)->getSizeInBytes(); + const Type* IntPtrTy = TD->getIntPtrType(Context); + Value *NMI = CallInst::CreateMalloc(CI, IntPtrTy, FieldTy, + ConstantInt::get(IntPtrTy, TypeSize), + NElems, + CI->getName() + ".f" + Twine(FieldNo)); FieldMallocs.push_back(NMI); - new StoreInst(NMI, NGV, BCI); + new StoreInst(NMI, NGV, CI); } // The tricky aspect of this transformation is handling the case when malloc @@ -1327,18 +1340,18 @@ // } Value *RunningOr = 0; for (unsigned i = 0, e = FieldMallocs.size(); i != e; ++i) { - Value *Cond = new ICmpInst(BCI, ICmpInst::ICMP_EQ, FieldMallocs[i], - Constant::getNullValue(FieldMallocs[i]->getType()), - "isnull"); + Value *Cond = new ICmpInst(CI, ICmpInst::ICMP_EQ, FieldMallocs[i], + Constant::getNullValue(FieldMallocs[i]->getType()), + "isnull"); if (!RunningOr) RunningOr = Cond; // First seteq else - RunningOr = BinaryOperator::CreateOr(RunningOr, Cond, "tmp", BCI); + RunningOr = BinaryOperator::CreateOr(RunningOr, Cond, "tmp", CI); } // Split the basic block at the old malloc. - BasicBlock *OrigBB = BCI->getParent(); - BasicBlock *ContBB = OrigBB->splitBasicBlock(BCI, "malloc_cont"); + BasicBlock *OrigBB = CI->getParent(); + BasicBlock *ContBB = OrigBB->splitBasicBlock(CI, "malloc_cont"); // Create the block to check the first condition. Put all these blocks at the // end of the function as they are unlikely to be executed. @@ -1374,9 +1387,8 @@ } BranchInst::Create(ContBB, NullPtrBlock); - - // CI and BCI are no longer needed, remove them. - BCI->eraseFromParent(); + + // CI is no longer needed, remove it. CI->eraseFromParent(); /// InsertedScalarizedLoads - As we process loads, if we can't immediately @@ -1463,14 +1475,10 @@ /// cast of malloc. static bool TryToOptimizeStoreOfMallocToGlobal(GlobalVariable *GV, CallInst *CI, - BitCastInst *BCI, + const Type *AllocTy, Module::global_iterator &GVI, TargetData *TD, LLVMContext &Context) { - // If we can't figure out the type being malloced, then we can't optimize. - const Type *AllocTy = getMallocAllocatedType(CI); - assert(AllocTy); - // If this is a malloc of an abstract type, don't touch it. if (!AllocTy->isSized()) return false; @@ -1491,7 +1499,7 @@ // for. { SmallPtrSet PHIs; - if (!ValueIsOnlyUsedLocallyOrStoredToOneGlobal(BCI, GV, PHIs)) + if (!ValueIsOnlyUsedLocallyOrStoredToOneGlobal(CI, GV, PHIs)) return false; } @@ -1499,16 +1507,16 @@ // transform the program to use global memory instead of malloc'd memory. // This eliminates dynamic allocation, avoids an indirection accessing the // data, and exposes the resultant global to further GlobalOpt. - Value *NElems = getMallocArraySize(CI, Context, TD); // We cannot optimize the malloc if we cannot determine malloc array size. - if (NElems) { + if (Value *NElems = getMallocArraySize(CI, Context, TD)) { if (ConstantInt *NElements = dyn_cast(NElems)) // Restrict this transformation to only working on small allocations // (2048 bytes currently), as we don't want to introduce a 16M global or // something. if (TD && NElements->getZExtValue() * TD->getTypeAllocSize(AllocTy) < 2048) { - GVI = OptimizeGlobalAddressOfMalloc(GV, CI, BCI, NElems, Context, TD); + GVI = OptimizeGlobalAddressOfMalloc(GV, CI, AllocTy, NElems, + Context, TD); return true; } @@ -1526,26 +1534,29 @@ // This the structure has an unreasonable number of fields, leave it // alone. if (AllocSTy->getNumElements() <= 16 && AllocSTy->getNumElements() != 0 && - AllGlobalLoadUsesSimpleEnoughForHeapSRA(GV, BCI)) { + AllGlobalLoadUsesSimpleEnoughForHeapSRA(GV, CI)) { // If this is a fixed size array, transform the Malloc to be an alloc of // structs. malloc [100 x struct],1 -> malloc struct, 100 if (const ArrayType *AT = dyn_cast(getMallocAllocatedType(CI))) { - Value* NumElements = ConstantInt::get(Type::getInt32Ty(Context), - AT->getNumElements()); - Value* NewMI = CallInst::CreateMalloc(CI, TD->getIntPtrType(Context), - AllocSTy, NumElements, - BCI->getName()); - Value *Cast = new BitCastInst(NewMI, getMallocType(CI), "tmp", CI); - BCI->replaceAllUsesWith(Cast); - BCI->eraseFromParent(); + const Type *IntPtrTy = TD->getIntPtrType(Context); + unsigned TypeSize = TD->getStructLayout(AllocSTy)->getSizeInBytes(); + Value *AllocSize = ConstantInt::get(IntPtrTy, TypeSize); + Value *NumElements = ConstantInt::get(IntPtrTy, AT->getNumElements()); + Instruction *Malloc = CallInst::CreateMalloc(CI, IntPtrTy, AllocSTy, + AllocSize, NumElements, + CI->getName()); + Instruction *Cast = new BitCastInst(Malloc, CI->getType(), "tmp", CI); + CI->replaceAllUsesWith(Cast); CI->eraseFromParent(); - BCI = cast(NewMI); - CI = extractMallocCallFromBitCast(NewMI); + CI = dyn_cast(Malloc) ? + extractMallocCallFromBitCast(Malloc): + cast(Malloc); } - GVI = PerformHeapAllocSRoA(GV, CI, BCI, NElems, Context, TD); + GVI = PerformHeapAllocSRoA(GV, CI, getMallocArraySize(CI, Context, TD), + Context, TD); return true; } } @@ -1577,15 +1588,10 @@ if (OptimizeAwayTrappingUsesOfLoads(GV, SOVC, Context)) return true; } else if (CallInst *CI = extractMallocCall(StoredOnceVal)) { - if (getMallocAllocatedType(CI)) { - BitCastInst* BCI = NULL; - for (Value::use_iterator UI = CI->use_begin(), E = CI->use_end(); - UI != E; ) - BCI = dyn_cast(cast(*UI++)); - if (BCI && - TryToOptimizeStoreOfMallocToGlobal(GV, CI, BCI, GVI, TD, Context)) - return true; - } + const Type* MallocType = getMallocAllocatedType(CI); + if (MallocType && TryToOptimizeStoreOfMallocToGlobal(GV, CI, MallocType, + GVI, TD, Context)) + return true; } } Modified: llvm/trunk/lib/VMCore/Core.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Core.cpp?rev=86077&r1=86076&r2=86077&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Core.cpp (original) +++ llvm/trunk/lib/VMCore/Core.cpp Wed Nov 4 18:03:03 2009 @@ -1699,18 +1699,24 @@ LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef B, LLVMTypeRef Ty, const char *Name) { - const Type* IntPtrT = Type::getInt32Ty(unwrap(B)->GetInsertBlock()->getContext()); - return wrap(unwrap(B)->Insert(CallInst::CreateMalloc( - unwrap(B)->GetInsertBlock(), IntPtrT, unwrap(Ty), 0, 0, ""), - Twine(Name))); + const Type* ITy = Type::getInt32Ty(unwrap(B)->GetInsertBlock()->getContext()); + Constant* AllocSize = ConstantExpr::getSizeOf(unwrap(Ty)); + AllocSize = ConstantExpr::getTruncOrBitCast(AllocSize, ITy); + Instruction* Malloc = CallInst::CreateMalloc(unwrap(B)->GetInsertBlock(), + ITy, unwrap(Ty), AllocSize, + 0, 0, ""); + return wrap(unwrap(B)->Insert(Malloc, Twine(Name))); } LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Val, const char *Name) { - const Type* IntPtrT = Type::getInt32Ty(unwrap(B)->GetInsertBlock()->getContext()); - return wrap(unwrap(B)->Insert(CallInst::CreateMalloc( - unwrap(B)->GetInsertBlock(), IntPtrT, unwrap(Ty), unwrap(Val), 0, ""), - Twine(Name))); + const Type* ITy = Type::getInt32Ty(unwrap(B)->GetInsertBlock()->getContext()); + Constant* AllocSize = ConstantExpr::getSizeOf(unwrap(Ty)); + AllocSize = ConstantExpr::getTruncOrBitCast(AllocSize, ITy); + Instruction* Malloc = CallInst::CreateMalloc(unwrap(B)->GetInsertBlock(), + ITy, unwrap(Ty), AllocSize, + unwrap(Val), 0, ""); + return wrap(unwrap(B)->Insert(Malloc, Twine(Name))); } LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef B, LLVMTypeRef Ty, Modified: llvm/trunk/lib/VMCore/Instructions.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instructions.cpp?rev=86077&r1=86076&r2=86077&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Instructions.cpp (original) +++ llvm/trunk/lib/VMCore/Instructions.cpp Wed Nov 4 18:03:03 2009 @@ -24,6 +24,7 @@ #include "llvm/Support/CallSite.h" #include "llvm/Support/ConstantRange.h" #include "llvm/Support/MathExtras.h" +#include "llvm/Target/TargetData.h" using namespace llvm; @@ -448,22 +449,11 @@ return isa(val) && cast(val)->isOne(); } -static Value *checkArraySize(Value *Amt, const Type *IntPtrTy) { - if (!Amt) - Amt = ConstantInt::get(IntPtrTy, 1); - else { - assert(!isa(Amt) && - "Passed basic block into malloc size parameter! Use other ctor"); - assert(Amt->getType() == IntPtrTy && - "Malloc array size is not an intptr!"); - } - return Amt; -} - static Instruction *createMalloc(Instruction *InsertBefore, BasicBlock *InsertAtEnd, const Type *IntPtrTy, - const Type *AllocTy, Value *ArraySize, - Function *MallocF, const Twine &NameStr) { + const Type *AllocTy, Value *AllocSize, + Value *ArraySize, Function *MallocF, + const Twine &Name) { assert(((!InsertBefore && InsertAtEnd) || (InsertBefore && !InsertAtEnd)) && "createMalloc needs either InsertBefore or InsertAtEnd"); @@ -471,10 +461,14 @@ // bitcast (i8* malloc(typeSize)) to type* // malloc(type, arraySize) becomes: // bitcast (i8 *malloc(typeSize*arraySize)) to type* - Value *AllocSize = ConstantExpr::getSizeOf(AllocTy); - AllocSize = ConstantExpr::getTruncOrBitCast(cast(AllocSize), - IntPtrTy); - ArraySize = checkArraySize(ArraySize, IntPtrTy); + if (!ArraySize) + ArraySize = ConstantInt::get(IntPtrTy, 1); + else if (ArraySize->getType() != IntPtrTy) { + if (InsertBefore) + ArraySize = CastInst::CreateIntegerCast(ArraySize, IntPtrTy, false, "", InsertBefore); + else + ArraySize = CastInst::CreateIntegerCast(ArraySize, IntPtrTy, false, "", InsertAtEnd); + } if (!IsConstantOne(ArraySize)) { if (IsConstantOne(AllocSize)) { @@ -513,14 +507,14 @@ Result = MCall; if (Result->getType() != AllocPtrType) // Create a cast instruction to convert to the right type... - Result = new BitCastInst(MCall, AllocPtrType, NameStr, InsertBefore); + Result = new BitCastInst(MCall, AllocPtrType, Name, InsertBefore); } else { MCall = CallInst::Create(MallocF, AllocSize, "malloccall"); Result = MCall; if (Result->getType() != AllocPtrType) { InsertAtEnd->getInstList().push_back(MCall); // Create a cast instruction to convert to the right type... - Result = new BitCastInst(MCall, AllocPtrType, NameStr); + Result = new BitCastInst(MCall, AllocPtrType, Name); } } MCall->setTailCall(); @@ -538,8 +532,9 @@ /// 3. Bitcast the result of the malloc call to the specified type. Instruction *CallInst::CreateMalloc(Instruction *InsertBefore, const Type *IntPtrTy, const Type *AllocTy, - Value *ArraySize, const Twine &Name) { - return createMalloc(InsertBefore, NULL, IntPtrTy, AllocTy, + Value *AllocSize, Value *ArraySize, + const Twine &Name) { + return createMalloc(InsertBefore, NULL, IntPtrTy, AllocTy, AllocSize, ArraySize, NULL, Name); } @@ -553,9 +548,9 @@ /// responsibility of the caller. Instruction *CallInst::CreateMalloc(BasicBlock *InsertAtEnd, const Type *IntPtrTy, const Type *AllocTy, - Value *ArraySize, Function* MallocF, - const Twine &Name) { - return createMalloc(NULL, InsertAtEnd, IntPtrTy, AllocTy, + Value *AllocSize, Value *ArraySize, + Function *MallocF, const Twine &Name) { + return createMalloc(NULL, InsertAtEnd, IntPtrTy, AllocTy, AllocSize, ArraySize, MallocF, Name); } Modified: llvm/trunk/test/Analysis/PointerTracking/sizes.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/PointerTracking/sizes.ll?rev=86077&r1=86076&r2=86077&view=diff ============================================================================== --- llvm/trunk/test/Analysis/PointerTracking/sizes.ll (original) +++ llvm/trunk/test/Analysis/PointerTracking/sizes.ll Wed Nov 4 18:03:03 2009 @@ -31,6 +31,7 @@ } declare i32 @bar(i8*) +declare i32 @bar2(i64*) define i32 @foo1(i32 %n) nounwind { entry: @@ -60,11 +61,16 @@ ret i32 %add16 } -define i32 @foo2(i32 %n) nounwind { +define i32 @foo2(i64 %n) nounwind { entry: - %call = malloc i8, i32 %n ; [#uses=1] + %call = tail call i8* @malloc(i64 %n) ; [#uses=1] ; CHECK: %call = ; CHECK: ==> %n elements, %n bytes allocated + %mallocsize = mul i64 %n, 8 ; [#uses=1] + %malloccall = tail call i8* @malloc(i64 %mallocsize) ; [#uses=1] + %call3 = bitcast i8* %malloccall to i64* ; [#uses=1] +; CHECK: %malloccall = +; CHECK: ==> (8 * %n) elements, (8 * %n) bytes allocated %call2 = tail call i8* @calloc(i64 2, i64 4) nounwind ; [#uses=1] ; CHECK: %call2 = ; CHECK: ==> 8 elements, 8 bytes allocated @@ -72,13 +78,17 @@ ; CHECK: %call4 = ; CHECK: ==> 16 elements, 16 bytes allocated %call6 = tail call i32 @bar(i8* %call) nounwind ; [#uses=1] + %call7 = tail call i32 @bar2(i64* %call3) nounwind ; [#uses=1] %call8 = tail call i32 @bar(i8* %call2) nounwind ; [#uses=1] %call10 = tail call i32 @bar(i8* %call4) nounwind ; [#uses=1] - %add = add i32 %call8, %call6 ; [#uses=1] - %add11 = add i32 %add, %call10 ; [#uses=1] + %add = add i32 %call8, %call6 ; [#uses=1] + %add10 = add i32 %add, %call7 ; [#uses=1] + %add11 = add i32 %add10, %call10 ; [#uses=1] ret i32 %add11 } +declare noalias i8* @malloc(i64) nounwind + declare noalias i8* @calloc(i64, i64) nounwind declare noalias i8* @realloc(i8* nocapture, i64) nounwind Modified: llvm/trunk/test/Transforms/GlobalOpt/2009-06-01-RecursivePHI.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/2009-06-01-RecursivePHI.ll?rev=86077&r1=86076&r2=86077&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/2009-06-01-RecursivePHI.ll (original) +++ llvm/trunk/test/Transforms/GlobalOpt/2009-06-01-RecursivePHI.ll Wed Nov 4 18:03:03 2009 @@ -1,4 +1,5 @@ ; RUN: opt < %s -globalopt +target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" %struct.s_annealing_sched = type { i32, float, float, float, float } %struct.s_bb = type { i32, i32, i32, i32 } @@ -96,7 +97,9 @@ unreachable bb1.i38: ; preds = %bb - %0 = malloc %struct.s_net, i32 undef ; <%struct.s_net*> [#uses=1] + %mallocsize = mul i64 28, undef ; [#uses=1] + %malloccall = tail call i8* @malloc(i64 %mallocsize) ; [#uses=1] + %0 = bitcast i8* %malloccall to %struct.s_net* ; <%struct.s_net*> [#uses=1] br i1 undef, label %bb.i1.i39, label %my_malloc.exit2.i bb.i1.i39: ; preds = %bb1.i38 @@ -115,3 +118,5 @@ bb7: ; preds = %bb6.preheader unreachable } + +declare noalias i8* @malloc(i64) Modified: llvm/trunk/test/Transforms/GlobalOpt/heap-sra-1.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/heap-sra-1.ll?rev=86077&r1=86076&r2=86077&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/heap-sra-1.ll (original) +++ llvm/trunk/test/Transforms/GlobalOpt/heap-sra-1.ll Wed Nov 4 18:03:03 2009 @@ -1,18 +1,22 @@ -; RUN: opt < %s -globalopt -S | grep {@X.f0} -; RUN: opt < %s -globalopt -S | grep {@X.f1} -target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" -target triple = "i386-apple-darwin7" +; RUN: opt < %s -globalopt -S | FileCheck %s +target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" %struct.foo = type { i32, i32 } @X = internal global %struct.foo* null +; CHECK: @X.f0 +; CHECK: @X.f1 -define void @bar(i32 %Size) nounwind noinline { +define void @bar(i64 %Size) nounwind noinline { entry: - %.sub = malloc %struct.foo, i32 %Size + %mallocsize = mul i64 %Size, 8 ; [#uses=1] + %malloccall = tail call i8* @malloc(i64 %mallocsize) ; [#uses=1] + %.sub = bitcast i8* %malloccall to %struct.foo* ; <%struct.foo*> [#uses=1] store %struct.foo* %.sub, %struct.foo** @X, align 4 ret void } +declare noalias i8* @malloc(i64) + define i32 @baz() nounwind readonly noinline { bb1.thread: %0 = load %struct.foo** @X, align 4 Modified: llvm/trunk/test/Transforms/GlobalOpt/heap-sra-2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/heap-sra-2.ll?rev=86077&r1=86076&r2=86077&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/heap-sra-2.ll (original) +++ llvm/trunk/test/Transforms/GlobalOpt/heap-sra-2.ll Wed Nov 4 18:03:03 2009 @@ -1,20 +1,22 @@ -; RUN: opt < %s -globalopt -S | grep {@X.f0} -; RUN: opt < %s -globalopt -S | grep {@X.f1} +; RUN: opt < %s -globalopt -S | FileCheck %s +target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" -target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" -target triple = "i386-apple-darwin7" %struct.foo = type { i32, i32 } @X = internal global %struct.foo* null ; <%struct.foo**> [#uses=2] +; CHECK: @X.f0 +; CHECK: @X.f1 define void @bar(i32 %Size) nounwind noinline { entry: - %0 = malloc [1000000 x %struct.foo] - ;%.sub = bitcast [1000000 x %struct.foo]* %0 to %struct.foo* + %malloccall = tail call i8* @malloc(i64 8000000) ; [#uses=1] + %0 = bitcast i8* %malloccall to [1000000 x %struct.foo]* ; <[1000000 x %struct.foo]*> [#uses=1] %.sub = getelementptr [1000000 x %struct.foo]* %0, i32 0, i32 0 ; <%struct.foo*> [#uses=1] store %struct.foo* %.sub, %struct.foo** @X, align 4 ret void } +declare noalias i8* @malloc(i64) + define i32 @baz() nounwind readonly noinline { bb1.thread: %0 = load %struct.foo** @X, align 4 ; <%struct.foo*> [#uses=1] Modified: llvm/trunk/test/Transforms/GlobalOpt/heap-sra-3.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/heap-sra-3.ll?rev=86077&r1=86076&r2=86077&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/heap-sra-3.ll (original) +++ llvm/trunk/test/Transforms/GlobalOpt/heap-sra-3.ll Wed Nov 4 18:03:03 2009 @@ -1,24 +1,22 @@ ; RUN: opt < %s -globalopt -S | FileCheck %s - -target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" -target triple = "i386-apple-darwin10" +target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" %struct.foo = type { i32, i32 } @X = internal global %struct.foo* null ; CHECK: @X.f0 ; CHECK: @X.f1 -define void @bar(i32 %Size) nounwind noinline { +define void @bar(i64 %Size) nounwind noinline { entry: - %mallocsize = mul i32 ptrtoint (%struct.foo* getelementptr (%struct.foo* null, i32 1) to i32), %Size, ; [#uses=1] -; CHECK: mul i32 %Size - %malloccall = tail call i8* @malloc(i32 %mallocsize) ; [#uses=1] + %mallocsize = mul i64 8, %Size, ; [#uses=1] +; CHECK: mul i64 %Size, 4 + %malloccall = tail call i8* @malloc(i64 %mallocsize) ; [#uses=1] %.sub = bitcast i8* %malloccall to %struct.foo* ; <%struct.foo*> [#uses=1] store %struct.foo* %.sub, %struct.foo** @X, align 4 ret void } -declare noalias i8* @malloc(i32) +declare noalias i8* @malloc(i64) define i32 @baz() nounwind readonly noinline { bb1.thread: Modified: llvm/trunk/test/Transforms/GlobalOpt/heap-sra-4.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/heap-sra-4.ll?rev=86077&r1=86076&r2=86077&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/heap-sra-4.ll (original) +++ llvm/trunk/test/Transforms/GlobalOpt/heap-sra-4.ll Wed Nov 4 18:03:03 2009 @@ -1,24 +1,22 @@ ; RUN: opt < %s -globalopt -S | FileCheck %s - -target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" -target triple = "i386-apple-darwin7" +target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" %struct.foo = type { i32, i32 } @X = internal global %struct.foo* null ; CHECK: @X.f0 ; CHECK: @X.f1 -define void @bar(i32 %Size) nounwind noinline { +define void @bar(i64 %Size) nounwind noinline { entry: - %mallocsize = shl i32 ptrtoint (%struct.foo* getelementptr (%struct.foo* null, i32 1) to i32), 9, ; [#uses=1] - %malloccall = tail call i8* @malloc(i32 %mallocsize) ; [#uses=1] -; CHECK: @malloc(i32 mul (i32 512 + %mallocsize = shl i64 %Size, 3 ; [#uses=1] + %malloccall = tail call i8* @malloc(i64 %mallocsize) ; [#uses=1] +; CHECK: mul i64 %Size, 4 %.sub = bitcast i8* %malloccall to %struct.foo* ; <%struct.foo*> [#uses=1] store %struct.foo* %.sub, %struct.foo** @X, align 4 ret void } -declare noalias i8* @malloc(i32) +declare noalias i8* @malloc(i64) define i32 @baz() nounwind readonly noinline { bb1.thread: Modified: llvm/trunk/test/Transforms/GlobalOpt/heap-sra-phi.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/heap-sra-phi.ll?rev=86077&r1=86076&r2=86077&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/heap-sra-phi.ll (original) +++ llvm/trunk/test/Transforms/GlobalOpt/heap-sra-phi.ll Wed Nov 4 18:03:03 2009 @@ -1,19 +1,21 @@ ; RUN: opt < %s -globalopt -S | grep {tmp.f1 = phi i32. } ; RUN: opt < %s -globalopt -S | grep {tmp.f0 = phi i32. } +target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" -target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" -target triple = "i386-apple-darwin7" %struct.foo = type { i32, i32 } @X = internal global %struct.foo* null ; <%struct.foo**> [#uses=2] define void @bar(i32 %Size) nounwind noinline { entry: - %tmp = malloc [1000000 x %struct.foo] ; <[1000000 x %struct.foo]*> [#uses=1] + %malloccall = tail call i8* @malloc(i64 8000000) ; [#uses=1] + %tmp = bitcast i8* %malloccall to [1000000 x %struct.foo]* ; <[1000000 x %struct.foo]*> [#uses=1] %.sub = getelementptr [1000000 x %struct.foo]* %tmp, i32 0, i32 0 ; <%struct.foo*> [#uses=1] store %struct.foo* %.sub, %struct.foo** @X, align 4 ret void } +declare noalias i8* @malloc(i64) + define i32 @baz() nounwind readonly noinline { bb1.thread: %tmpLD1 = load %struct.foo** @X, align 4 ; <%struct.foo*> [#uses=1] Modified: llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-1.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-1.ll?rev=86077&r1=86076&r2=86077&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-1.ll (original) +++ llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-1.ll Wed Nov 4 18:03:03 2009 @@ -1,19 +1,24 @@ -; RUN: opt < %s -globalopt -S | not grep global +; RUN: opt < %s -globalopt -S | FileCheck %s target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" @G = internal global i32* null ; [#uses=3] +; CHECK-NOT: global define void @init() { - %P = malloc i32 ; [#uses=1] + %malloccall = tail call i8* @malloc(i64 4) ; [#uses=1] + %P = bitcast i8* %malloccall to i32* ; [#uses=1] store i32* %P, i32** @G %GV = load i32** @G ; [#uses=1] store i32 0, i32* %GV ret void } +declare noalias i8* @malloc(i64) + define i32 @get() { %GV = load i32** @G ; [#uses=1] %V = load i32* %GV ; [#uses=1] ret i32 %V +; CHECK: ret i32 0 } Modified: llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-2.ll?rev=86077&r1=86076&r2=86077&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-2.ll (original) +++ llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-2.ll Wed Nov 4 18:03:03 2009 @@ -1,11 +1,11 @@ ; RUN: opt < %s -globalopt -globaldce -S | not grep malloc -target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" -target triple = "i686-apple-darwin8" +target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" @G = internal global i32* null ; [#uses=3] define void @init() { - %P = malloc i32, i32 100 ; [#uses=1] + %malloccall = tail call i8* @malloc(i64 mul (i64 100, i64 4)) ; [#uses=1] + %P = bitcast i8* %malloccall to i32* ; [#uses=1] store i32* %P, i32** @G %GV = load i32** @G ; [#uses=1] %GVe = getelementptr i32* %GV, i32 40 ; [#uses=1] @@ -13,6 +13,8 @@ ret void } +declare noalias i8* @malloc(i64) + define i32 @get() { %GV = load i32** @G ; [#uses=1] %GVe = getelementptr i32* %GV, i32 40 ; [#uses=1] Modified: llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-3.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-3.ll?rev=86077&r1=86076&r2=86077&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-3.ll (original) +++ llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-3.ll Wed Nov 4 18:03:03 2009 @@ -1,11 +1,11 @@ ; RUN: opt < %s -globalopt -globaldce -S | not grep malloc -target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" -target triple = "i686-apple-darwin8" +target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" @G = internal global i32* null ; [#uses=4] define void @init() { - %P = malloc i32, i32 100 ; [#uses=1] + %malloccall = tail call i8* @malloc(i64 mul (i64 100, i64 4)) ; [#uses=1] + %P = bitcast i8* %malloccall to i32* ; [#uses=1] store i32* %P, i32** @G %GV = load i32** @G ; [#uses=1] %GVe = getelementptr i32* %GV, i32 40 ; [#uses=1] @@ -13,6 +13,8 @@ ret void } +declare noalias i8* @malloc(i64) + define i32 @get() { %GV = load i32** @G ; [#uses=1] %GVe = getelementptr i32* %GV, i32 40 ; [#uses=1] From david_goodwin at apple.com Wed Nov 4 18:16:45 2009 From: david_goodwin at apple.com (David Goodwin) Date: Thu, 05 Nov 2009 00:16:45 -0000 Subject: [llvm-commits] [llvm] r86080 - /llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp Message-ID: <200911050016.nA50Gju1008135@zion.cs.uiuc.edu> Author: david_goodwin Date: Wed Nov 4 18:16:44 2009 New Revision: 86080 URL: http://llvm.org/viewvc/llvm-project?rev=86080&view=rev Log: Correctly add chain dependencies around calls and unknown-side-effect instructions. Modified: llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp Modified: llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp?rev=86080&r1=86079&r2=86080&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp (original) +++ llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp Wed Nov 4 18:16:44 2009 @@ -367,6 +367,7 @@ for (unsigned i = 0, e = I->second.size(); i != e; ++i) I->second[i]->addPred(SDep(SU, SDep::Order, TrueMemOrderLatency)); I->second.clear(); + I->second.push_back(SU); } // See if it is known to just have a single memory reference. MachineInstr *ChainMI = Chain->getInstr(); @@ -413,7 +414,7 @@ if (Chain) Chain->addPred(SDep(SU, SDep::Order, /*Latency=*/0)); } - } else if (MayAlias) { + } else { // Treat all other stores conservatively. goto new_chain; } @@ -439,7 +440,7 @@ // Treat volatile loads conservatively. Note that this includes // cases where memoperand information is unavailable. goto new_chain; - } else if (MayAlias) { + } else { // A "MayAlias" load. Depend on the general chain, as well as on // all stores. In the absense of MachineMemOperand information, // we can't even assume that the load doesn't alias well-behaved From bob.wilson at apple.com Wed Nov 4 18:30:36 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Thu, 05 Nov 2009 00:30:36 -0000 Subject: [llvm-commits] [llvm] r86081 - /llvm/trunk/test/CodeGen/ARM/indirectbr.ll Message-ID: <200911050030.nA50UaeI008603@zion.cs.uiuc.edu> Author: bwilson Date: Wed Nov 4 18:30:35 2009 New Revision: 86081 URL: http://llvm.org/viewvc/llvm-project?rev=86081&view=rev Log: Attempt again to fix buildbot failures: make expected output less specific and compile with -mtriple to specify *-apple-darwin targets. Modified: llvm/trunk/test/CodeGen/ARM/indirectbr.ll Modified: llvm/trunk/test/CodeGen/ARM/indirectbr.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/indirectbr.ll?rev=86081&r1=86080&r2=86081&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/indirectbr.ll (original) +++ llvm/trunk/test/CodeGen/ARM/indirectbr.ll Wed Nov 4 18:30:35 2009 @@ -1,6 +1,6 @@ -; RUN: llc < %s -relocation-model=pic -march=arm | FileCheck %s -check-prefix=ARM -; RUN: llc < %s -relocation-model=pic -march=thumb | FileCheck %s -check-prefix=THUMB -; RUN: llc < %s -relocation-model=static -march=thumb -mattr=+thumb2 | FileCheck %s -check-prefix=THUMB2 +; RUN: llc < %s -relocation-model=pic -mtriple=arm-apple-darwin | FileCheck %s -check-prefix=ARM +; RUN: llc < %s -relocation-model=pic -mtriple=thumb-apple-darwin | FileCheck %s -check-prefix=THUMB +; RUN: llc < %s -relocation-model=static -mtriple=thumbv7-apple-darwin | FileCheck %s -check-prefix=THUMB2 @nextaddr = global i8* null ; [#uses=2] @C.0.2070 = private constant [5 x i8*] [i8* blockaddress(@foo, %L1), i8* blockaddress(@foo, %L2), i8* blockaddress(@foo, %L3), i8* blockaddress(@foo, %L4), i8* blockaddress(@foo, %L5)] ; <[5 x i8*]*> [#uses=1] @@ -44,20 +44,17 @@ L1: ; preds = %L2, %bb2 %res.3 = phi i32 [ %phitmp, %L2 ], [ 2, %bb2 ] ; [#uses=1] -; ARM: ldr r1, LCPI1_2 +; ARM: ldr r1, LCPI ; ARM: add r1, pc, r1 ; ARM: str r1 -; THUMB: ldr.n r2, LCPI1_4 +; THUMB: ldr.n r2, LCPI ; THUMB: add r2, pc ; THUMB: str r2 -; THUMB2: ldr.n r2, LCPI1_2 +; THUMB2: ldr.n r2, LCPI ; THUMB2-NEXT: str r2 store i8* blockaddress(@foo, %L5), i8** @nextaddr, align 4 ret i32 %res.3 } -; ARM: LCPI1_2: -; ARM-NEXT: .long L_foo_L5-(LPC2+8) -; THUMB: LCPI1_4: -; THUMB-NEXT: .long L_foo_L5-(LPC2+4) -; THUMB2: LCPI1_2: -; THUMB2-NEXT: .long L_foo_L5 +; ARM: .long L_foo_L5-(LPC{{.*}}+8) +; THUMB: .long L_foo_L5-(LPC{{.*}}+4) +; THUMB2: .long L_foo_L5 From evan.cheng at apple.com Wed Nov 4 18:51:14 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 05 Nov 2009 00:51:14 -0000 Subject: [llvm-commits] [llvm] r86085 - /llvm/trunk/lib/CodeGen/MachineLICM.cpp Message-ID: <200911050051.nA50pEAs009370@zion.cs.uiuc.edu> Author: evancheng Date: Wed Nov 4 18:51:13 2009 New Revision: 86085 URL: http://llvm.org/viewvc/llvm-project?rev=86085&view=rev Log: Code refactoring. Modified: llvm/trunk/lib/CodeGen/MachineLICM.cpp Modified: llvm/trunk/lib/CodeGen/MachineLICM.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineLICM.cpp?rev=86085&r1=86084&r2=86085&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineLICM.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineLICM.cpp Wed Nov 4 18:51:13 2009 @@ -111,6 +111,13 @@ /// be hoistable. MachineInstr *ExtractHoistableLoad(MachineInstr *MI); + /// EliminateCSE - Given a LICM'ed instruction, look for an instruction on + /// the preheader that compute the same value. If it's found, do a RAU on + /// with the definition of the existing instruction rather than hoisting + /// the instruction to the preheader. + bool EliminateCSE(MachineInstr *MI, + DenseMap >::iterator &CI); + /// Hoist - When an instruction is found to only use loop invariant operands /// that is safe to hoist, this instruction is called to do the dirty work. /// @@ -349,37 +356,6 @@ return true; } -static const MachineInstr *LookForDuplicate(const MachineInstr *MI, - std::vector &PrevMIs, - MachineRegisterInfo *RegInfo) { - unsigned NumOps = MI->getNumOperands(); - for (unsigned i = 0, e = PrevMIs.size(); i != e; ++i) { - const MachineInstr *PrevMI = PrevMIs[i]; - unsigned NumOps2 = PrevMI->getNumOperands(); - if (NumOps != NumOps2) - continue; - bool IsSame = true; - for (unsigned j = 0; j != NumOps; ++j) { - const MachineOperand &MO = MI->getOperand(j); - if (MO.isReg() && MO.isDef()) { - if (RegInfo->getRegClass(MO.getReg()) != - RegInfo->getRegClass(PrevMI->getOperand(j).getReg())) { - IsSame = false; - break; - } - continue; - } - if (!MO.isIdenticalTo(PrevMI->getOperand(j))) { - IsSame = false; - break; - } - } - if (IsSame) - return PrevMI; - } - return 0; -} - MachineInstr *MachineLICM::ExtractHoistableLoad(MachineInstr *MI) { // If not, we may be able to unfold a load and hoist that. // First test whether the instruction is loading from an amenable @@ -456,6 +432,55 @@ } } +static const MachineInstr *LookForDuplicate(const MachineInstr *MI, + std::vector &PrevMIs, + MachineRegisterInfo *RegInfo) { + unsigned NumOps = MI->getNumOperands(); + for (unsigned i = 0, e = PrevMIs.size(); i != e; ++i) { + const MachineInstr *PrevMI = PrevMIs[i]; + unsigned NumOps2 = PrevMI->getNumOperands(); + if (NumOps != NumOps2) + continue; + bool IsSame = true; + for (unsigned j = 0; j != NumOps; ++j) { + const MachineOperand &MO = MI->getOperand(j); + if (MO.isReg() && MO.isDef()) { + if (RegInfo->getRegClass(MO.getReg()) != + RegInfo->getRegClass(PrevMI->getOperand(j).getReg())) { + IsSame = false; + break; + } + continue; + } + if (!MO.isIdenticalTo(PrevMI->getOperand(j))) { + IsSame = false; + break; + } + } + if (IsSame) + return PrevMI; + } + return 0; +} + +bool MachineLICM::EliminateCSE(MachineInstr *MI, + DenseMap >::iterator &CI) { + if (CI != CSEMap.end()) { + if (const MachineInstr *Dup = LookForDuplicate(MI, CI->second, RegInfo)) { + DEBUG(errs() << "CSEing " << *MI << " with " << *Dup); + for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { + const MachineOperand &MO = MI->getOperand(i); + if (MO.isReg() && MO.isDef()) + RegInfo->replaceRegWith(MO.getReg(), Dup->getOperand(i).getReg()); + } + MI->eraseFromParent(); + ++NumCSEed; + return true; + } + } + return false; +} + /// Hoist - When an instruction is found to use only loop invariant operands /// that are safe to hoist, this instruction is called to do the dirty work. /// @@ -488,24 +513,8 @@ unsigned Opcode = MI->getOpcode(); DenseMap >::iterator CI = CSEMap.find(Opcode); - bool DoneCSE = false; - if (CI != CSEMap.end()) { - const MachineInstr *Dup = LookForDuplicate(MI, CI->second, RegInfo); - if (Dup) { - DEBUG(errs() << "CSEing " << *MI << " with " << *Dup); - for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { - const MachineOperand &MO = MI->getOperand(i); - if (MO.isReg() && MO.isDef()) - RegInfo->replaceRegWith(MO.getReg(), Dup->getOperand(i).getReg()); - } - MI->eraseFromParent(); - DoneCSE = true; - ++NumCSEed; - } - } - - // Otherwise, splice the instruction to the preheader. - if (!DoneCSE) { + if (!EliminateCSE(MI, CI)) { + // Otherwise, splice the instruction to the preheader. CurPreheader->splice(CurPreheader->getFirstTerminator(),MI->getParent(),MI); // Add to the CSE map. From bob.wilson at apple.com Wed Nov 4 18:51:31 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Thu, 05 Nov 2009 00:51:31 -0000 Subject: [llvm-commits] [llvm] r86086 - /llvm/trunk/test/CodeGen/PowerPC/indirectbr.ll Message-ID: <200911050051.nA50pV25009393@zion.cs.uiuc.edu> Author: bwilson Date: Wed Nov 4 18:51:31 2009 New Revision: 86086 URL: http://llvm.org/viewvc/llvm-project?rev=86086&view=rev Log: Add -mtriple to llc commands, attempting to fix buildbot failures. Modified: llvm/trunk/test/CodeGen/PowerPC/indirectbr.ll Modified: llvm/trunk/test/CodeGen/PowerPC/indirectbr.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/indirectbr.ll?rev=86086&r1=86085&r2=86086&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/PowerPC/indirectbr.ll (original) +++ llvm/trunk/test/CodeGen/PowerPC/indirectbr.ll Wed Nov 4 18:51:31 2009 @@ -1,5 +1,5 @@ -; RUN: llc < %s -relocation-model=pic -march=ppc32 | FileCheck %s -check-prefix=PIC -; RUN: llc < %s -relocation-model=static -march=ppc32 | FileCheck %s -check-prefix=STATIC +; RUN: llc < %s -relocation-model=pic -march=ppc32 -mtriple=powerpc-apple-darwin | FileCheck %s -check-prefix=PIC +; RUN: llc < %s -relocation-model=static -march=ppc32 -mtriple=powerpc-apple-darwin | FileCheck %s -check-prefix=STATIC @nextaddr = global i8* null ; [#uses=2] @C.0.2070 = private constant [5 x i8*] [i8* blockaddress(@foo, %L1), i8* blockaddress(@foo, %L2), i8* blockaddress(@foo, %L3), i8* blockaddress(@foo, %L4), i8* blockaddress(@foo, %L5)] ; <[5 x i8*]*> [#uses=1] From lhames at gmail.com Wed Nov 4 18:52:28 2009 From: lhames at gmail.com (Lang Hames) Date: Thu, 05 Nov 2009 00:52:28 -0000 Subject: [llvm-commits] [llvm] r86088 - /llvm/trunk/include/llvm/CodeGen/SlotIndexes.h Message-ID: <200911050052.nA50qSF2009447@zion.cs.uiuc.edu> Author: lhames Date: Wed Nov 4 18:52:28 2009 New Revision: 86088 URL: http://llvm.org/viewvc/llvm-project?rev=86088&view=rev Log: Removed an assert which was causing significant slowdowns in debug builds. This assert was very conservative to begin with (the error condition is well covered by tests elsewhere in the code) so we won't miss much by removing it. Modified: llvm/trunk/include/llvm/CodeGen/SlotIndexes.h Modified: llvm/trunk/include/llvm/CodeGen/SlotIndexes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SlotIndexes.h?rev=86088&r1=86087&r2=86088&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/SlotIndexes.h (original) +++ llvm/trunk/include/llvm/CodeGen/SlotIndexes.h Wed Nov 4 18:52:28 2009 @@ -131,7 +131,6 @@ } IndexListEntry& entry() const { - assert(lie.getPointer() != 0 && "Use of invalid index."); return *lie.getPointer(); } From dpatel at apple.com Wed Nov 4 19:13:02 2009 From: dpatel at apple.com (Devang Patel) Date: Thu, 05 Nov 2009 01:13:02 -0000 Subject: [llvm-commits] [llvm] r86091 - in /llvm/trunk/lib/AsmParser: LLParser.cpp LLParser.h Message-ID: <200911050113.nA51D2He010220@zion.cs.uiuc.edu> Author: dpatel Date: Wed Nov 4 19:13:02 2009 New Revision: 86091 URL: http://llvm.org/viewvc/llvm-project?rev=86091&view=rev Log: Use WeakVH while storing metadata in containers. This fixes PR5393. Modified: llvm/trunk/lib/AsmParser/LLParser.cpp llvm/trunk/lib/AsmParser/LLParser.h Modified: llvm/trunk/lib/AsmParser/LLParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=86091&r1=86090&r2=86091&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLParser.cpp (original) +++ llvm/trunk/lib/AsmParser/LLParser.cpp Wed Nov 4 19:13:02 2009 @@ -480,17 +480,17 @@ if (ParseUInt32(MID)) return true; // Check existing MDNode. - std::map::iterator I = MetadataCache.find(MID); + std::map::iterator I = MetadataCache.find(MID); if (I != MetadataCache.end()) { - Node = I->second; + Node = cast(I->second); return false; } // Check known forward references. - std::map >::iterator + std::map >::iterator FI = ForwardRefMDNodes.find(MID); if (FI != ForwardRefMDNodes.end()) { - Node = FI->second.first; + Node = cast(FI->second.first); return false; } @@ -570,7 +570,7 @@ MDNode *Init = MDNode::get(Context, Elts.data(), Elts.size()); MetadataCache[MetadataID] = Init; - std::map >::iterator + std::map >::iterator FI = ForwardRefMDNodes.find(MetadataID); if (FI != ForwardRefMDNodes.end()) { MDNode *FwdNode = cast(FI->second.first); Modified: llvm/trunk/lib/AsmParser/LLParser.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.h?rev=86091&r1=86090&r2=86091&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLParser.h (original) +++ llvm/trunk/lib/AsmParser/LLParser.h Wed Nov 4 19:13:02 2009 @@ -79,8 +79,8 @@ std::map > ForwardRefTypeIDs; std::vector NumberedTypes; /// MetadataCache - This map keeps track of parsed metadata constants. - std::map MetadataCache; - std::map > ForwardRefMDNodes; + std::map MetadataCache; + std::map > ForwardRefMDNodes; SmallVector, 2> MDsOnInst; struct UpRefRecord { /// Loc - This is the location of the upref. From evan.cheng at apple.com Wed Nov 4 19:16:59 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 05 Nov 2009 01:16:59 -0000 Subject: [llvm-commits] [llvm] r86092 - /llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp Message-ID: <200911050116.nA51GxHR010359@zion.cs.uiuc.edu> Author: evancheng Date: Wed Nov 4 19:16:59 2009 New Revision: 86092 URL: http://llvm.org/viewvc/llvm-project?rev=86092&view=rev Log: Now that code placement optimization pass is run for JIT, make sure it's before pre-emit passes. Modified: llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp Modified: llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp?rev=86092&r1=86091&r2=86092&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp (original) +++ llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp Wed Nov 4 19:16:59 2009 @@ -342,13 +342,13 @@ PM.add(createDebugLabelFoldingPass()); printAndVerify(PM, "After DebugLabelFolding"); - if (addPreEmitPass(PM, OptLevel)) - printAndVerify(PM, "After PreEmit passes"); - if (OptLevel != CodeGenOpt::None && !DisableCodePlace) { PM.add(createCodePlacementOptPass()); printAndVerify(PM, "After CodePlacementOpt"); } + if (addPreEmitPass(PM, OptLevel)) + printAndVerify(PM, "After PreEmit passes"); + return false; } From lhames at gmail.com Wed Nov 4 19:18:32 2009 From: lhames at gmail.com (Lang Hames) Date: Thu, 05 Nov 2009 01:18:32 -0000 Subject: [llvm-commits] [llvm] r86097 - /llvm/trunk/include/llvm/CodeGen/SlotIndexes.h Message-ID: <200911050118.nA51IWUx010467@zion.cs.uiuc.edu> Author: lhames Date: Wed Nov 4 19:18:31 2009 New Revision: 86097 URL: http://llvm.org/viewvc/llvm-project?rev=86097&view=rev Log: Tidied some ugliness in the SlotIndex default constructor. Modified: llvm/trunk/include/llvm/CodeGen/SlotIndexes.h Modified: llvm/trunk/include/llvm/CodeGen/SlotIndexes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SlotIndexes.h?rev=86097&r1=86096&r2=86097&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/SlotIndexes.h (original) +++ llvm/trunk/include/llvm/CodeGen/SlotIndexes.h Wed Nov 4 19:18:31 2009 @@ -159,7 +159,7 @@ } /// Construct an invalid index. - SlotIndex() : lie(&getEmptyKey().entry(), 0) {} + SlotIndex() : lie(IndexListEntry::getEmptyKeyEntry(), 0) {} // Construct a new slot index from the given one, set the phi flag on the // new index to the value of the phi parameter. From david_goodwin at apple.com Wed Nov 4 19:19:36 2009 From: david_goodwin at apple.com (David Goodwin) Date: Thu, 05 Nov 2009 01:19:36 -0000 Subject: [llvm-commits] [llvm] r86098 - in /llvm/trunk/lib/CodeGen: AggressiveAntiDepBreaker.cpp AggressiveAntiDepBreaker.h PostRASchedulerList.cpp Message-ID: <200911050119.nA51JaZ6010522@zion.cs.uiuc.edu> Author: david_goodwin Date: Wed Nov 4 19:19:35 2009 New Revision: 86098 URL: http://llvm.org/viewvc/llvm-project?rev=86098&view=rev Log: Break anti-dependencies using free registers in a round-robin manner to avoid introducing new anti-dependencies. Modified: llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.h llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp Modified: llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp?rev=86098&r1=86097&r2=86098&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp (original) +++ llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp Wed Nov 4 19:19:35 2009 @@ -491,8 +491,9 @@ } bool AggressiveAntiDepBreaker::FindSuitableFreeRegisters( - unsigned AntiDepGroupIndex, - std::map &RenameMap) { + unsigned AntiDepGroupIndex, + RenameOrderType& RenameOrder, + std::map &RenameMap) { unsigned *KillIndices = State->GetKillIndices(); unsigned *DefIndices = State->GetDefIndices(); std::multimap& @@ -547,22 +548,41 @@ if (Regs.size() > 1) return false; - // Check each possible rename register for SuperReg. If that register - // is available, and the corresponding registers are available for - // the other group subregisters, then we can use those registers to - // rename. - DEBUG(errs() << "\tFind Register:"); + // Check each possible rename register for SuperReg in round-robin + // order. If that register is available, and the corresponding + // registers are available for the other group subregisters, then we + // can use those registers to rename. BitVector SuperBV = RenameRegisterMap[SuperReg]; - for (int r = SuperBV.find_first(); r != -1; r = SuperBV.find_next(r)) { - const unsigned Reg = (unsigned)r; + const TargetRegisterClass *SuperRC = + TRI->getPhysicalRegisterRegClass(SuperReg, MVT::Other); + + const TargetRegisterClass::iterator RB = SuperRC->allocation_order_begin(MF); + const TargetRegisterClass::iterator RE = SuperRC->allocation_order_end(MF); + if (RB == RE) { + DEBUG(errs() << "\tEmpty Regclass!!\n"); + return false; + } + + if (RenameOrder.count(SuperRC) == 0) + RenameOrder.insert(RenameOrderType::value_type(SuperRC, RE)); + + DEBUG(errs() << "\tFind Register:"); + + const TargetRegisterClass::iterator OrigR = RenameOrder.at(SuperRC); + const TargetRegisterClass::iterator EndR = ((OrigR == RE) ? RB : OrigR); + TargetRegisterClass::iterator R = OrigR; + do { + if (R == RB) R = RE; + --R; + const unsigned Reg = *R; // Don't replace a register with itself. if (Reg == SuperReg) continue; - + DEBUG(errs() << " " << TRI->getName(Reg)); - + // If Reg is dead and Reg's most recent def is not before - // SuperRegs's kill, it's safe to replace SuperReg with - // Reg. We must also check all subregisters of Reg. + // SuperRegs's kill, it's safe to replace SuperReg with Reg. We + // must also check all subregisters of Reg. if (State->IsLive(Reg) || (KillIndices[SuperReg] > DefIndices[Reg])) { DEBUG(errs() << "(live)"); continue; @@ -580,13 +600,15 @@ if (found) continue; } - + if (Reg != 0) { DEBUG(errs() << '\n'); + RenameOrder.erase(SuperRC); + RenameOrder.insert(RenameOrderType::value_type(SuperRC, R)); RenameMap.insert(std::pair(SuperReg, Reg)); return true; } - } + } while (R != EndR); DEBUG(errs() << '\n'); @@ -627,6 +649,9 @@ State = new AggressiveAntiDepState(*SavedState); } } + + // For each regclass the next register to use for renaming. + RenameOrderType RenameOrder; // ...need a map from MI to SUnit. std::map MISUnitMap; @@ -738,7 +763,7 @@ // Look for a suitable register to use to break the anti-dependence. std::map RenameMap; - if (FindSuitableFreeRegisters(GroupIndex, RenameMap)) { + if (FindSuitableFreeRegisters(GroupIndex, RenameOrder, RenameMap)) { DEBUG(errs() << "\tBreaking anti-dependence edge on " << TRI->getName(AntiDepReg) << ":"); Modified: llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.h?rev=86098&r1=86097&r2=86098&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.h (original) +++ llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.h Wed Nov 4 19:19:35 2009 @@ -155,6 +155,9 @@ void FinishBlock(); private: + typedef std::map RenameOrderType; + /// IsImplicitDefUse - Return true if MO represents a register /// that is both implicitly used and defined in MI bool IsImplicitDefUse(MachineInstr *MI, MachineOperand& MO); @@ -169,6 +172,7 @@ void ScanInstruction(MachineInstr *MI, unsigned Count); BitVector GetRenameRegisters(unsigned Reg); bool FindSuitableFreeRegisters(unsigned AntiDepGroupIndex, + RenameOrderType& RenameOrder, std::map &RenameMap); }; } Modified: llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp?rev=86098&r1=86097&r2=86098&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp (original) +++ llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp Wed Nov 4 19:19:35 2009 @@ -770,7 +770,8 @@ // just advance the current cycle and try again. DEBUG(errs() << "*** Stall in cycle " << CurCycle << '\n'); HazardRec->AdvanceCycle(); - ++NumStalls; + if (!IgnoreAntiDep) + ++NumStalls; } else { // Otherwise, we have no instructions to issue and we have instructions // that will fault if we don't do this right. This is the case for @@ -778,7 +779,8 @@ DEBUG(errs() << "*** Emitting noop in cycle " << CurCycle << '\n'); HazardRec->EmitNoop(); Sequence.push_back(0); // NULL here means noop - ++NumNoops; + if (!IgnoreAntiDep) + ++NumNoops; } ++CurCycle; From deeppatel1987 at gmail.com Wed Nov 4 19:21:59 2009 From: deeppatel1987 at gmail.com (Sandeep Patel) Date: Thu, 05 Nov 2009 01:21:59 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r86099 - /llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp Message-ID: <200911050121.nA51LxrS010625@zion.cs.uiuc.edu> Author: sandeep Date: Wed Nov 4 19:21:58 2009 New Revision: 86099 URL: http://llvm.org/viewvc/llvm-project?rev=86099&view=rev Log: An aggregate with no register candidate FDTs in it was being marked homogeneous. Committed as obvious. Modified: llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp Modified: llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp?rev=86099&r1=86098&r2=86099&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp Wed Nov 4 19:21:58 2009 @@ -2396,6 +2396,9 @@ return false; } + if (cnt == 0) + return false; + return true; } From david_goodwin at apple.com Wed Nov 4 19:45:51 2009 From: david_goodwin at apple.com (David Goodwin) Date: Thu, 05 Nov 2009 01:45:51 -0000 Subject: [llvm-commits] [llvm] r86102 - /llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp Message-ID: <200911050145.nA51jpr9011614@zion.cs.uiuc.edu> Author: david_goodwin Date: Wed Nov 4 19:45:50 2009 New Revision: 86102 URL: http://llvm.org/viewvc/llvm-project?rev=86102&view=rev Log: Replace std::map.at() with std::map[]. Modified: llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp Modified: llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp?rev=86102&r1=86101&r2=86102&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp (original) +++ llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp Wed Nov 4 19:45:50 2009 @@ -568,7 +568,7 @@ DEBUG(errs() << "\tFind Register:"); - const TargetRegisterClass::iterator OrigR = RenameOrder.at(SuperRC); + const TargetRegisterClass::iterator OrigR = RenameOrder[SuperRC]; const TargetRegisterClass::iterator EndR = ((OrigR == RE) ? RB : OrigR); TargetRegisterClass::iterator R = OrigR; do { From wangmp at apple.com Wed Nov 4 21:19:08 2009 From: wangmp at apple.com (Mon P Wang) Date: Thu, 05 Nov 2009 03:19:08 -0000 Subject: [llvm-commits] [llvm] r86114 - in /llvm/trunk: include/llvm/Target/TargetIntrinsicInfo.h lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp lib/Target/Blackfin/BlackfinIntrinsicInfo.h Message-ID: <200911050319.nA53J8ft014864@zion.cs.uiuc.edu> Author: wangmp Date: Wed Nov 4 21:19:08 2009 New Revision: 86114 URL: http://llvm.org/viewvc/llvm-project?rev=86114&view=rev Log: Reintroduce support for overloading target intrinsics Modified: llvm/trunk/include/llvm/Target/TargetIntrinsicInfo.h llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.h Modified: llvm/trunk/include/llvm/Target/TargetIntrinsicInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetIntrinsicInfo.h?rev=86114&r1=86113&r2=86114&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetIntrinsicInfo.h (original) +++ llvm/trunk/include/llvm/Target/TargetIntrinsicInfo.h Wed Nov 4 21:19:08 2009 @@ -14,6 +14,8 @@ #ifndef LLVM_TARGET_TARGETINTRINSICINFO_H #define LLVM_TARGET_TARGETINTRINSICINFO_H +#include + namespace llvm { class Function; @@ -32,7 +34,13 @@ virtual ~TargetIntrinsicInfo(); /// Return the name of a target intrinsic, e.g. "llvm.bfin.ssync". - virtual const char *getName(unsigned IntrID) const =0; + /// The Tys and numTys parameters are for intrinsics with overloaded types + /// (e.g., those using iAny or fAny). For a declaration for an overloaded + /// intrinsic, Tys should point to an array of numTys pointers to Type, + /// and must provide exactly one type for each overloaded type in the + /// intrinsic. + virtual std::string getName(unsigned IID, const Type **Tys = 0, + unsigned numTys = 0) const = 0; /// Look up target intrinsic by name. Return intrinsic ID or 0 for unknown /// names. @@ -40,6 +48,15 @@ /// Return the target intrinsic ID of a function, or 0. virtual unsigned getIntrinsicID(Function *F) const; + + /// Returns true if the intrinsic can be overloaded. + virtual bool isOverloaded(unsigned IID) const = 0; + + /// Create or insert an LLVM Function declaration for an intrinsic, + /// and return it. The Tys and numTys are for intrinsics with overloaded + /// types. See above for more information. + virtual Function *getDeclaration(Module *M, unsigned ID, const Type **Tys = 0, + unsigned numTys = 0) const = 0; }; } // End llvm namespace Modified: llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp?rev=86114&r1=86113&r2=86114&view=diff ============================================================================== --- llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp (original) +++ llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp Wed Nov 4 21:19:08 2009 @@ -12,7 +12,11 @@ //===----------------------------------------------------------------------===// #include "BlackfinIntrinsicInfo.h" +#include "llvm/DerivedTypes.h" +#include "llvm/Function.h" #include "llvm/Intrinsics.h" +#include "llvm/Module.h" +#include "llvm/Type.h" #include "llvm/Support/raw_ostream.h" #include @@ -30,18 +34,21 @@ } -const char *BlackfinIntrinsicInfo::getName(unsigned IntrID) const { +std::string BlackfinIntrinsicInfo::getName(unsigned IntrID, const Type **Tys, + unsigned numTys) const { static const char *const names[] = { #define GET_INTRINSIC_NAME_TABLE #include "BlackfinGenIntrinsics.inc" #undef GET_INTRINSIC_NAME_TABLE }; + assert(!isOverloaded(IntrID) && "Blackfin intrinsics are not overloaded"); if (IntrID < Intrinsic::num_intrinsics) return 0; assert(IntrID < bfinIntrinsic::num_bfin_intrinsics && "Invalid intrinsic ID"); - return names[IntrID - Intrinsic::num_intrinsics]; + std::string Result(names[IntrID - Intrinsic::num_intrinsics]); + return Result; } unsigned @@ -51,3 +58,44 @@ #undef GET_FUNCTION_RECOGNIZER return 0; } + +bool BlackfinIntrinsicInfo::isOverloaded(unsigned IntrID) const { + // Overload Table + const bool OTable[] = { + false, // illegal intrinsic +#define GET_INTRINSIC_OVERLOAD_TABLE +#include "BlackfinGenIntrinsics.inc" +#undef GET_INTRINSIC_OVERLOAD_TABLE + }; + if (IntrID == 0) + return false; + else + return OTable[IntrID - Intrinsic::num_intrinsics]; +} + +/// This defines the "getAttributes(ID id)" method. +#define GET_INTRINSIC_ATTRIBUTES +#include "BlackfinGenIntrinsics.inc" +#undef GET_INTRINSIC_ATTRIBUTES + +static const FunctionType *getType(LLVMContext &Context, unsigned id) { + const Type *ResultTy = NULL; + std::vector ArgTys; + bool IsVarArg = false; + +#define GET_INTRINSIC_GENERATOR +#include "BlackfinGenIntrinsics.inc" +#undef GET_INTRINSIC_GENERATOR + + return FunctionType::get(ResultTy, ArgTys, IsVarArg); +} + +Function *BlackfinIntrinsicInfo::getDeclaration(Module *M, unsigned IntrID, + const Type **Tys, + unsigned numTy) const { + assert(!isOverloaded(IntrID) && "Blackfin intrinsics are not overloaded"); + AttrListPtr AList = getAttributes((bfinIntrinsic::ID) IntrID); + return cast(M->getOrInsertFunction(getName(IntrID), + getType(M->getContext(), IntrID), + AList)); +} Modified: llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.h?rev=86114&r1=86113&r2=86114&view=diff ============================================================================== --- llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.h (original) +++ llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.h Wed Nov 4 21:19:08 2009 @@ -19,8 +19,12 @@ class BlackfinIntrinsicInfo : public TargetIntrinsicInfo { public: - const char *getName(unsigned IntrID) const; + std::string getName(unsigned IntrID, const Type **Tys = 0, + unsigned numTys = 0) const; unsigned lookupName(const char *Name, unsigned Len) const; + bool isOverloaded(unsigned IID) const; + Function *getDeclaration(Module *M, unsigned ID, const Type **Tys = 0, + unsigned numTys = 0) const; }; } From espindola at google.com Wed Nov 4 22:52:00 2009 From: espindola at google.com (Rafael Espindola) Date: Wed, 4 Nov 2009 23:52:00 -0500 Subject: [llvm-commits] [compiler-rt] _Unwind_* Message-ID: <38a0d8450911042052q3fd64a65wdc87011028b7ddf1@mail.gmail.com> Is it intentional that compiler-rt doesn't define the _Unwind_* functions? Where are they normally taken from? By linking with libgcc? Cheers, -- Rafael ?vila de Esp?ndola From clattner at apple.com Wed Nov 4 23:47:50 2009 From: clattner at apple.com (Chris Lattner) Date: Wed, 4 Nov 2009 21:47:50 -0800 Subject: [llvm-commits] [compiler-rt] _Unwind_* In-Reply-To: <38a0d8450911042052q3fd64a65wdc87011028b7ddf1@mail.gmail.com> References: <38a0d8450911042052q3fd64a65wdc87011028b7ddf1@mail.gmail.com> Message-ID: On Nov 4, 2009, at 8:52 PM, Rafael Espindola wrote: > Is it intentional that compiler-rt doesn't define the _Unwind_* > functions? Where are they normally taken from? By linking with libgcc? We use libunwind. -Chris From sabre at nondot.org Wed Nov 4 23:57:34 2009 From: sabre at nondot.org (Chris Lattner) Date: Thu, 05 Nov 2009 05:57:34 -0000 Subject: [llvm-commits] [llvm] r86119 - in /llvm/trunk/test/Transforms/JumpThreading: 2008-11-28-InfLoop.ll 2009-01-08-DeadLoopRepl.ll 2009-01-19-InfSwitchLoop.ll crash.ll Message-ID: <200911050557.nA55vZLR019878@zion.cs.uiuc.edu> Author: lattner Date: Wed Nov 4 23:57:34 2009 New Revision: 86119 URL: http://llvm.org/viewvc/llvm-project?rev=86119&view=rev Log: merge a few crash tests into crash.ll Removed: llvm/trunk/test/Transforms/JumpThreading/2008-11-28-InfLoop.ll llvm/trunk/test/Transforms/JumpThreading/2009-01-08-DeadLoopRepl.ll llvm/trunk/test/Transforms/JumpThreading/2009-01-19-InfSwitchLoop.ll Modified: llvm/trunk/test/Transforms/JumpThreading/crash.ll Removed: llvm/trunk/test/Transforms/JumpThreading/2008-11-28-InfLoop.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/JumpThreading/2008-11-28-InfLoop.ll?rev=86118&view=auto ============================================================================== --- llvm/trunk/test/Transforms/JumpThreading/2008-11-28-InfLoop.ll (original) +++ llvm/trunk/test/Transforms/JumpThreading/2008-11-28-InfLoop.ll (removed) @@ -1,17 +0,0 @@ -; RUN: opt < %s -jump-threading -S - -target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" -target triple = "i386-apple-darwin9.5" - %struct.decContext = type { i32 } - %struct.decNumber = type { i32, i32 } - -define i32 @decNumberPower(%struct.decNumber* %res, %struct.decNumber* %lhs, %struct.decNumber* %rhs, %struct.decContext* %set) nounwind { -entry: - br i1 true, label %decDivideOp.exit, label %bb7.i - -bb7.i: ; preds = %bb7.i, %entry - br label %bb7.i - -decDivideOp.exit: ; preds = %entry - ret i32 undef -} Removed: llvm/trunk/test/Transforms/JumpThreading/2009-01-08-DeadLoopRepl.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/JumpThreading/2009-01-08-DeadLoopRepl.ll?rev=86118&view=auto ============================================================================== --- llvm/trunk/test/Transforms/JumpThreading/2009-01-08-DeadLoopRepl.ll (original) +++ llvm/trunk/test/Transforms/JumpThreading/2009-01-08-DeadLoopRepl.ll (removed) @@ -1,49 +0,0 @@ -; RUN: opt < %s -jump-threading | llvm-dis -; PR3298 - -target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" -target triple = "i386-apple-darwin9.6" - -define i32 @func(i32 %p_79, i32 %p_80) nounwind { -entry: - br label %bb7 - -bb1: ; preds = %bb2 - br label %bb2 - -bb2: ; preds = %bb7, %bb1 - %l_82.0 = phi i8 [ 0, %bb1 ], [ %l_82.1, %bb7 ] ; [#uses=3] - br i1 true, label %bb3, label %bb1 - -bb3: ; preds = %bb2 - %0 = icmp eq i32 %p_80_addr.1, 0 ; [#uses=1] - br i1 %0, label %bb7, label %bb6 - -bb5: ; preds = %bb6 - %1 = icmp eq i8 %l_82.0, 0 ; [#uses=1] - br i1 %1, label %bb1.i, label %bb.i - -bb.i: ; preds = %bb5 - br label %safe_div_func_char_s_s.exit - -bb1.i: ; preds = %bb5 - br label %safe_div_func_char_s_s.exit - -safe_div_func_char_s_s.exit: ; preds = %bb1.i, %bb.i - br label %bb6 - -bb6: ; preds = %safe_div_func_char_s_s.exit, %bb3 - %p_80_addr.0 = phi i32 [ %p_80_addr.1, %bb3 ], [ 1, %safe_div_func_char_s_s.exit ] ; [#uses=2] - %2 = icmp eq i32 %p_80_addr.0, 0 ; [#uses=1] - br i1 %2, label %bb7, label %bb5 - -bb7: ; preds = %bb6, %bb3, %entry - %l_82.1 = phi i8 [ 1, %entry ], [ %l_82.0, %bb3 ], [ %l_82.0, %bb6 ] ; [#uses=2] - %p_80_addr.1 = phi i32 [ 0, %entry ], [ %p_80_addr.1, %bb3 ], [ %p_80_addr.0, %bb6 ] ; [#uses=4] - %3 = icmp eq i32 %p_80_addr.1, 0 ; [#uses=1] - br i1 %3, label %bb8, label %bb2 - -bb8: ; preds = %bb7 - %4 = sext i8 %l_82.1 to i32 ; [#uses=0] - ret i32 0 -} Removed: llvm/trunk/test/Transforms/JumpThreading/2009-01-19-InfSwitchLoop.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/JumpThreading/2009-01-19-InfSwitchLoop.ll?rev=86118&view=auto ============================================================================== --- llvm/trunk/test/Transforms/JumpThreading/2009-01-19-InfSwitchLoop.ll (original) +++ llvm/trunk/test/Transforms/JumpThreading/2009-01-19-InfSwitchLoop.ll (removed) @@ -1,21 +0,0 @@ -; RUN: opt < %s -jump-threading -S -; PR3353 - -define i32 @test(i8 %X) { -entry: - %Y = add i8 %X, 1 - %Z = add i8 %Y, 1 - br label %bb33.i - -bb33.i: ; preds = %bb33.i, %bb32.i - switch i8 %Y, label %bb32.i [ - i8 39, label %bb35.split.i - i8 13, label %bb33.i - ] - -bb35.split.i: - ret i32 5 -bb32.i: - ret i32 1 -} - Modified: llvm/trunk/test/Transforms/JumpThreading/crash.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/JumpThreading/crash.ll?rev=86119&r1=86118&r2=86119&view=diff ============================================================================== --- llvm/trunk/test/Transforms/JumpThreading/crash.ll (original) +++ llvm/trunk/test/Transforms/JumpThreading/crash.ll Wed Nov 4 23:57:34 2009 @@ -88,4 +88,85 @@ ret i32 %c E: ret i32 412 -} \ No newline at end of file +} + + +define i32 @test2() nounwind { +entry: + br i1 true, label %decDivideOp.exit, label %bb7.i + +bb7.i: ; preds = %bb7.i, %entry + br label %bb7.i + +decDivideOp.exit: ; preds = %entry + ret i32 undef +} + + +; PR3298 + +define i32 @test3(i32 %p_79, i32 %p_80) nounwind { +entry: + br label %bb7 + +bb1: ; preds = %bb2 + br label %bb2 + +bb2: ; preds = %bb7, %bb1 + %l_82.0 = phi i8 [ 0, %bb1 ], [ %l_82.1, %bb7 ] ; [#uses=3] + br i1 true, label %bb3, label %bb1 + +bb3: ; preds = %bb2 + %0 = icmp eq i32 %p_80_addr.1, 0 ; [#uses=1] + br i1 %0, label %bb7, label %bb6 + +bb5: ; preds = %bb6 + %1 = icmp eq i8 %l_82.0, 0 ; [#uses=1] + br i1 %1, label %bb1.i, label %bb.i + +bb.i: ; preds = %bb5 + br label %safe_div_func_char_s_s.exit + +bb1.i: ; preds = %bb5 + br label %safe_div_func_char_s_s.exit + +safe_div_func_char_s_s.exit: ; preds = %bb1.i, %bb.i + br label %bb6 + +bb6: ; preds = %safe_div_func_char_s_s.exit, %bb3 + %p_80_addr.0 = phi i32 [ %p_80_addr.1, %bb3 ], [ 1, %safe_div_func_char_s_s.exit ] ; [#uses=2] + %2 = icmp eq i32 %p_80_addr.0, 0 ; [#uses=1] + br i1 %2, label %bb7, label %bb5 + +bb7: ; preds = %bb6, %bb3, %entry + %l_82.1 = phi i8 [ 1, %entry ], [ %l_82.0, %bb3 ], [ %l_82.0, %bb6 ] ; [#uses=2] + %p_80_addr.1 = phi i32 [ 0, %entry ], [ %p_80_addr.1, %bb3 ], [ %p_80_addr.0, %bb6 ] ; [#uses=4] + %3 = icmp eq i32 %p_80_addr.1, 0 ; [#uses=1] + br i1 %3, label %bb8, label %bb2 + +bb8: ; preds = %bb7 + %4 = sext i8 %l_82.1 to i32 ; [#uses=0] + ret i32 0 +} + + +; PR3353 + +define i32 @test4(i8 %X) { +entry: + %Y = add i8 %X, 1 + %Z = add i8 %Y, 1 + br label %bb33.i + +bb33.i: ; preds = %bb33.i, %bb32.i + switch i8 %Y, label %bb32.i [ + i8 39, label %bb35.split.i + i8 13, label %bb33.i + ] + +bb35.split.i: + ret i32 5 +bb32.i: + ret i32 1 +} + From dgregor at apple.com Thu Nov 5 07:30:28 2009 From: dgregor at apple.com (Douglas Gregor) Date: Thu, 05 Nov 2009 13:30:28 -0000 Subject: [llvm-commits] [llvm] r86130 - in /llvm/trunk/include/llvm/Support: Format.h LeakDetector.h OutputBuffer.h PassNameParser.h RecyclingAllocator.h Message-ID: <200911051330.nA5DUS9e017707@zion.cs.uiuc.edu> Author: dgregor Date: Thu Nov 5 07:30:28 2009 New Revision: 86130 URL: http://llvm.org/viewvc/llvm-project?rev=86130&view=rev Log: Make a few headers standalone. Plus, add a missing "template" keyword that Clang diagnoses but GCC does not. Modified: llvm/trunk/include/llvm/Support/Format.h llvm/trunk/include/llvm/Support/LeakDetector.h llvm/trunk/include/llvm/Support/OutputBuffer.h llvm/trunk/include/llvm/Support/PassNameParser.h llvm/trunk/include/llvm/Support/RecyclingAllocator.h Modified: llvm/trunk/include/llvm/Support/Format.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Format.h?rev=86130&r1=86129&r2=86130&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/Format.h (original) +++ llvm/trunk/include/llvm/Support/Format.h Thu Nov 5 07:30:28 2009 @@ -23,6 +23,7 @@ #ifndef LLVM_SUPPORT_FORMAT_H #define LLVM_SUPPORT_FORMAT_H +#include #include #ifdef WIN32 #define snprintf _snprintf Modified: llvm/trunk/include/llvm/Support/LeakDetector.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/LeakDetector.h?rev=86130&r1=86129&r2=86130&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/LeakDetector.h (original) +++ llvm/trunk/include/llvm/Support/LeakDetector.h Thu Nov 5 07:30:28 2009 @@ -26,6 +26,7 @@ namespace llvm { +class LLVMContext; class Value; struct LeakDetector { Modified: llvm/trunk/include/llvm/Support/OutputBuffer.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/OutputBuffer.h?rev=86130&r1=86129&r2=86130&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/OutputBuffer.h (original) +++ llvm/trunk/include/llvm/Support/OutputBuffer.h Thu Nov 5 07:30:28 2009 @@ -14,6 +14,7 @@ #ifndef LLVM_SUPPORT_OUTPUTBUFFER_H #define LLVM_SUPPORT_OUTPUTBUFFER_H +#include #include #include Modified: llvm/trunk/include/llvm/Support/PassNameParser.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/PassNameParser.h?rev=86130&r1=86129&r2=86130&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/PassNameParser.h (original) +++ llvm/trunk/include/llvm/Support/PassNameParser.h Thu Nov 5 07:30:28 2009 @@ -25,6 +25,7 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/raw_ostream.h" #include "llvm/Pass.h" #include #include Modified: llvm/trunk/include/llvm/Support/RecyclingAllocator.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/RecyclingAllocator.h?rev=86130&r1=86129&r2=86130&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/RecyclingAllocator.h (original) +++ llvm/trunk/include/llvm/Support/RecyclingAllocator.h Thu Nov 5 07:30:28 2009 @@ -41,7 +41,7 @@ /// SubClass. The storage may be either newly allocated or recycled. /// template - SubClass *Allocate() { return Base.Allocate(Allocator); } + SubClass *Allocate() { return Base.template Allocate(Allocator); } T *Allocate() { return Base.Allocate(Allocator); } From dgregor at apple.com Thu Nov 5 07:39:23 2009 From: dgregor at apple.com (Douglas Gregor) Date: Thu, 05 Nov 2009 13:39:23 -0000 Subject: [llvm-commits] [llvm] r86131 - in /llvm/trunk/include/llvm/Support: ConstantFolder.h TargetFolder.h Message-ID: <200911051339.nA5DdOrx017992@zion.cs.uiuc.edu> Author: dgregor Date: Thu Nov 5 07:39:23 2009 New Revision: 86131 URL: http://llvm.org/viewvc/llvm-project?rev=86131&view=rev Log: Make two more LLVM headers standalone Modified: llvm/trunk/include/llvm/Support/ConstantFolder.h llvm/trunk/include/llvm/Support/TargetFolder.h Modified: llvm/trunk/include/llvm/Support/ConstantFolder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ConstantFolder.h?rev=86131&r1=86130&r2=86131&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/ConstantFolder.h (original) +++ llvm/trunk/include/llvm/Support/ConstantFolder.h Thu Nov 5 07:39:23 2009 @@ -18,6 +18,8 @@ #define LLVM_SUPPORT_CONSTANTFOLDER_H #include "llvm/Constants.h" +#include "llvm/Instruction.h" +#include "llvm/InstrTypes.h" namespace llvm { Modified: llvm/trunk/include/llvm/Support/TargetFolder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/TargetFolder.h?rev=86131&r1=86130&r2=86131&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/TargetFolder.h (original) +++ llvm/trunk/include/llvm/Support/TargetFolder.h Thu Nov 5 07:39:23 2009 @@ -20,6 +20,8 @@ #define LLVM_SUPPORT_TARGETFOLDER_H #include "llvm/Constants.h" +#include "llvm/Instruction.h" +#include "llvm/InstrTypes.h" #include "llvm/Analysis/ConstantFolding.h" namespace llvm { From benny.kra at googlemail.com Thu Nov 5 08:32:40 2009 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Thu, 05 Nov 2009 14:32:40 -0000 Subject: [llvm-commits] [llvm] r86132 - /llvm/trunk/lib/System/Win32/Path.inc Message-ID: <200911051432.nA5EWeIe019967@zion.cs.uiuc.edu> Author: d0k Date: Thu Nov 5 08:32:40 2009 New Revision: 86132 URL: http://llvm.org/viewvc/llvm-project?rev=86132&view=rev Log: Path::createDirectoryOnDisk should ignore existing directories on win32 too. Modified: llvm/trunk/lib/System/Win32/Path.inc Modified: llvm/trunk/lib/System/Win32/Path.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Win32/Path.inc?rev=86132&r1=86131&r2=86132&view=diff ============================================================================== --- llvm/trunk/lib/System/Win32/Path.inc (original) +++ llvm/trunk/lib/System/Win32/Path.inc Thu Nov 5 08:32:40 2009 @@ -608,7 +608,8 @@ while (*next) { next = strchr(next, '/'); *next = 0; - if (!CreateDirectory(pathname, NULL)) + if (!CreateDirectory(pathname, NULL) && + GetLastError() != ERROR_ALREADY_EXISTS) return MakeErrMsg(ErrMsg, std::string(pathname) + ": Can't create directory: "); *next++ = '/'; @@ -616,7 +617,8 @@ } else { // Drop trailing slash. pathname[len-1] = 0; - if (!CreateDirectory(pathname, NULL)) { + if (!CreateDirectory(pathname, NULL) && + GetLastError() != ERROR_ALREADY_EXISTS) { return MakeErrMsg(ErrMsg, std::string(pathname) + ": Can't create directory: "); } } From benny.kra at googlemail.com Thu Nov 5 08:33:28 2009 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Thu, 05 Nov 2009 14:33:28 -0000 Subject: [llvm-commits] [llvm] r86133 - /llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Message-ID: <200911051433.nA5EXShO019997@zion.cs.uiuc.edu> Author: d0k Date: Thu Nov 5 08:33:27 2009 New Revision: 86133 URL: http://llvm.org/viewvc/llvm-project?rev=86133&view=rev Log: Do map insert+find in one step. TODO -= 2. Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCP.cpp?rev=86133&r1=86132&r2=86133&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SCCP.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Thu Nov 5 08:33:27 2009 @@ -370,13 +370,13 @@ /// by properly seeding constants etc. LatticeVal &getValueState(Value *V) { assert(!isa(V->getType()) && "Should use getStructValueState"); - - // TODO: Change to do insert+find in one operation. - DenseMap::iterator I = ValueState.find(V); - if (I != ValueState.end()) - return I->second; // Common case, already in the map. - LatticeVal &LV = ValueState[V]; + std::pair::iterator, bool> I = + ValueState.insert(std::make_pair(V, LatticeVal())); + LatticeVal &LV = I.first->second; + + if (!I.second) + return LV; // Common case, already in the map. if (Constant *C = dyn_cast(V)) { // Undef values remain undefined. @@ -395,15 +395,15 @@ assert(isa(V->getType()) && "Should use getValueState"); assert(i < cast(V->getType())->getNumElements() && "Invalid element #"); - - // TODO: Change to do insert+find in one operation. - DenseMap, LatticeVal>::iterator - I = StructValueState.find(std::make_pair(V, i)); - if (I != StructValueState.end()) - return I->second; // Common case, already in the map. - - LatticeVal &LV = StructValueState[std::make_pair(V, i)]; - + + std::pair, LatticeVal>::iterator, + bool> I = StructValueState.insert( + std::make_pair(std::make_pair(V, i), LatticeVal())); + LatticeVal &LV = I.first->second; + + if (!I.second) + return LV; // Common case, already in the map. + if (Constant *C = dyn_cast(V)) { if (isa(C)) ; // Undef values remain undefined. From daniel at zuster.org Thu Nov 5 10:27:33 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Thu, 05 Nov 2009 16:27:33 -0000 Subject: [llvm-commits] [llvm] r86137 - in /llvm/trunk: docs/CommandGuide/lit.pod utils/lit/LitConfig.py utils/lit/lit.py Message-ID: <200911051627.nA5GRXbI024145@zion.cs.uiuc.edu> Author: ddunbar Date: Thu Nov 5 10:27:33 2009 New Revision: 86137 URL: http://llvm.org/viewvc/llvm-project?rev=86137&view=rev Log: lit: Add --param NAME=VALUE option, for test suite specific use (to communicate arbitrary command line arguments to the test suite). Modified: llvm/trunk/docs/CommandGuide/lit.pod llvm/trunk/utils/lit/LitConfig.py llvm/trunk/utils/lit/lit.py Modified: llvm/trunk/docs/CommandGuide/lit.pod URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CommandGuide/lit.pod?rev=86137&r1=86136&r2=86137&view=diff ============================================================================== --- llvm/trunk/docs/CommandGuide/lit.pod (original) +++ llvm/trunk/docs/CommandGuide/lit.pod Thu Nov 5 10:27:33 2009 @@ -54,6 +54,12 @@ Search for I and I when searching for test suites, instead I and I. +=item B<--param> I, B<--param> I=I + +Add a user defined parameter I with the given I (or the empty +string if not given). The meaning and use of these parameters is test suite +dependent. + =back =head1 OUTPUT OPTIONS Modified: llvm/trunk/utils/lit/LitConfig.py URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/LitConfig.py?rev=86137&r1=86136&r2=86137&view=diff ============================================================================== --- llvm/trunk/utils/lit/LitConfig.py (original) +++ llvm/trunk/utils/lit/LitConfig.py Thu Nov 5 10:27:33 2009 @@ -17,7 +17,8 @@ def __init__(self, progname, path, quiet, useValgrind, valgrindArgs, useTclAsSh, - noExecute, debug, isWindows): + noExecute, debug, isWindows, + params): # The name of the test runner. self.progname = progname # The items to add to the PATH environment variable. @@ -29,6 +30,7 @@ self.noExecute = noExecute self.debug = debug self.isWindows = bool(isWindows) + self.params = dict(params) self.bashPath = None self.numErrors = 0 Modified: llvm/trunk/utils/lit/lit.py URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit.py?rev=86137&r1=86136&r2=86137&view=diff ============================================================================== --- llvm/trunk/utils/lit/lit.py (original) +++ llvm/trunk/utils/lit/lit.py Thu Nov 5 10:27:33 2009 @@ -321,6 +321,10 @@ parser.add_option("", "--config-prefix", dest="configPrefix", metavar="NAME", help="Prefix for 'lit' config files", action="store", default=None) + parser.add_option("", "--param", dest="userParameters", + metavar="NAME=VAL", + help="Add 'NAME' = 'VAL' to the user defined parameters", + type=str, action="append", default=[]) group = OptionGroup(parser, "Output Format") # FIXME: I find these names very confusing, although I like the @@ -396,6 +400,15 @@ inputs = args + # Create the user defined parameters. + userParams = {} + for entry in opts.userParameters: + if '=' not in entry: + name,val = entry,'' + else: + name,val = entry.split('=', 1) + userParams[name] = val + # Create the global config object. litConfig = LitConfig.LitConfig(progname = os.path.basename(sys.argv[0]), path = opts.path, @@ -405,7 +418,8 @@ useTclAsSh = opts.useTclAsSh, noExecute = opts.noExecute, debug = opts.debug, - isWindows = (platform.system()=='Windows')) + isWindows = (platform.system()=='Windows'), + params = userParams) # Load the tests from the inputs. tests = [] From dpatel at apple.com Thu Nov 5 10:32:32 2009 From: dpatel at apple.com (Devang Patel) Date: Thu, 05 Nov 2009 16:32:32 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r86138 - /llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Message-ID: <200911051632.nA5GWWxU024309@zion.cs.uiuc.edu> Author: dpatel Date: Thu Nov 5 10:32:31 2009 New Revision: 86138 URL: http://llvm.org/viewvc/llvm-project?rev=86138&view=rev Log: Enable debug info for global variables. Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp?rev=86138&r1=86137&r2=86138&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Thu Nov 5 10:32:31 2009 @@ -1446,10 +1446,7 @@ #endif } - // No debug info for globals when optimization is on. While this is - // something that would be accurate and useful to a user, it currently - // affects some optimizations that, e.g., count uses. - if (TheDebugInfo && !optimize) { + if (TheDebugInfo) { std::string Name = GV->getNameStr(); const char LPrefix[] = "\01L_OBJC_"; const char lPrefix[] = "\01l_OBJC_"; From benny.kra at googlemail.com Thu Nov 5 11:44:23 2009 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Thu, 05 Nov 2009 17:44:23 -0000 Subject: [llvm-commits] [llvm] r86141 - in /llvm/trunk: lib/Transforms/Scalar/SimplifyLibCalls.cpp test/Transforms/SimplifyLibCalls/memcmp.ll Message-ID: <200911051744.nA5HiNZ7027120@zion.cs.uiuc.edu> Author: d0k Date: Thu Nov 5 11:44:22 2009 New Revision: 86141 URL: http://llvm.org/viewvc/llvm-project?rev=86141&view=rev Log: Teach SimplifyLibCalls to fold memcmp calls with constant arguments. Modified: llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp llvm/trunk/test/Transforms/SimplifyLibCalls/memcmp.ll Modified: llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp?rev=86141&r1=86140&r2=86141&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp Thu Nov 5 11:44:22 2009 @@ -955,6 +955,17 @@ return B.CreateZExt(B.CreateXor(LHSV, RHSV, "shortdiff"), CI->getType()); } + // Constant folding: memcmp(x, y, l) -> cnst (all arguments are constant) + std::string LHSStr, RHSStr; + if (GetConstantStringInfo(LHS, LHSStr) && + GetConstantStringInfo(RHS, RHSStr)) { + // Make sure we're not reading out-of-bounds memory. + if (Len > LHSStr.length() || Len > RHSStr.length()) + return 0; + uint64_t Ret = memcmp(LHSStr.data(), RHSStr.data(), Len); + return ConstantInt::get(CI->getType(), Ret); + } + return 0; } }; @@ -2479,10 +2490,6 @@ // lround, lroundf, lroundl: // * lround(cnst) -> cnst' // -// memcmp: -// * memcmp(x,y,l) -> cnst -// (if all arguments are constant and strlen(x) <= l and strlen(y) <= l) -// // pow, powf, powl: // * pow(exp(x),y) -> exp(x*y) // * pow(sqrt(x),y) -> pow(x,y*0.5) Modified: llvm/trunk/test/Transforms/SimplifyLibCalls/memcmp.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyLibCalls/memcmp.ll?rev=86141&r1=86140&r2=86141&view=diff ============================================================================== --- llvm/trunk/test/Transforms/SimplifyLibCalls/memcmp.ll (original) +++ llvm/trunk/test/Transforms/SimplifyLibCalls/memcmp.ll Thu Nov 5 11:44:22 2009 @@ -17,6 +17,10 @@ %D = call i32 @memcmp( i8* %P, i8* %Q, i32 2 ) ; [#uses=1] %E = icmp eq i32 %D, 0 ; [#uses=1] volatile store i1 %E, i1* %BP + %F = call i32 @memcmp(i8* getelementptr ([4 x i8]* @hel, i32 0, i32 0), + i8* getelementptr ([8 x i8]* @hello_u, i32 0, i32 0), + i32 3) + volatile store i32 %F, i32* %IP ret void } From kennethuil at gmail.com Thu Nov 5 11:51:17 2009 From: kennethuil at gmail.com (Kenneth Uildriks) Date: Thu, 5 Nov 2009 11:51:17 -0600 Subject: [llvm-commits] [PATCH] At beginning of SelectionDAGISel::LowerArguments, see if return values can be lowered to registers Message-ID: <400d33ea0911050951x4ed610d6q7badfb193315be94@mail.gmail.com> Right now, it simply asserts if the return values cannot be lowered. I'm working on code that will perform an sret-demotion on function definitions and function calls if the return values cannot be lowered to registers; this will allow arbitrary-sized struct returns to get through codegen without crashing. -------------- next part -------------- A non-text attachment was scrubbed... Name: needs-sret-demote.patch Type: application/octet-stream Size: 7778 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091105/c60e102c/attachment.obj From sabre at nondot.org Thu Nov 5 11:51:44 2009 From: sabre at nondot.org (Chris Lattner) Date: Thu, 05 Nov 2009 17:51:44 -0000 Subject: [llvm-commits] [llvm] r86144 - /llvm/trunk/include/llvm/Support/CommandLine.h Message-ID: <200911051751.nA5HpiRe027382@zion.cs.uiuc.edu> Author: lattner Date: Thu Nov 5 11:51:44 2009 New Revision: 86144 URL: http://llvm.org/viewvc/llvm-project?rev=86144&view=rev Log: Declare classes with matched tags, pointed out by a clang++ warning. Modified: llvm/trunk/include/llvm/Support/CommandLine.h Modified: llvm/trunk/include/llvm/Support/CommandLine.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/CommandLine.h?rev=86144&r1=86143&r2=86144&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/CommandLine.h (original) +++ llvm/trunk/include/llvm/Support/CommandLine.h Thu Nov 5 11:51:44 2009 @@ -495,7 +495,8 @@ //-------------------------------------------------- // basic_parser - Super class of parsers to provide boilerplate code // -struct basic_parser_impl { // non-template implementation of basic_parser +class basic_parser_impl { // non-template implementation of basic_parser +public: virtual ~basic_parser_impl() {} enum ValueExpected getValueExpectedFlagDefault() const { @@ -525,7 +526,8 @@ // a typedef for the provided data type. // template -struct basic_parser : public basic_parser_impl { +class basic_parser : public basic_parser_impl { +public: typedef DataType parser_data_type; }; From clattner at apple.com Thu Nov 5 12:02:26 2009 From: clattner at apple.com (Chris Lattner) Date: Thu, 5 Nov 2009 10:02:26 -0800 Subject: [llvm-commits] [llvm] r86133 - /llvm/trunk/lib/Transforms/Scalar/SCCP.cpp In-Reply-To: <200911051433.nA5EXShO019997@zion.cs.uiuc.edu> References: <200911051433.nA5EXShO019997@zion.cs.uiuc.edu> Message-ID: On Nov 5, 2009, at 6:33 AM, Benjamin Kramer wrote: > Author: d0k > Date: Thu Nov 5 08:33:27 2009 > New Revision: 86133 > > URL: http://llvm.org/viewvc/llvm-project?rev=86133&view=rev > Log: > Do map insert+find in one step. TODO -= 2. Thanks Benjamin! -Chris From sabre at nondot.org Thu Nov 5 12:19:19 2009 From: sabre at nondot.org (Chris Lattner) Date: Thu, 05 Nov 2009 18:19:19 -0000 Subject: [llvm-commits] [llvm] r86146 - /llvm/trunk/lib/Target/README.txt Message-ID: <200911051819.nA5IJJsa028293@zion.cs.uiuc.edu> Author: lattner Date: Thu Nov 5 12:19:19 2009 New Revision: 86146 URL: http://llvm.org/viewvc/llvm-project?rev=86146&view=rev Log: add a note from PR5313 Modified: llvm/trunk/lib/Target/README.txt Modified: llvm/trunk/lib/Target/README.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/README.txt?rev=86146&r1=86145&r2=86146&view=diff ============================================================================== --- llvm/trunk/lib/Target/README.txt (original) +++ llvm/trunk/lib/Target/README.txt Thu Nov 5 12:19:19 2009 @@ -1229,6 +1229,40 @@ //===---------------------------------------------------------------------===// +[PHI TRANSLATE INDEXED GEPs] PR5313 + +Load redundancy elimination for simple loop. This loop: + +void append_text(const char* text,unsigned char * const io) { + while(*text) + *io=*text++; +} + +Compiles to have a fully redundant load in the loop (%2): + +define void @append_text(i8* nocapture %text, i8* nocapture %io) nounwind { +entry: + %0 = load i8* %text, align 1 ; [#uses=1] + %1 = icmp eq i8 %0, 0 ; [#uses=1] + br i1 %1, label %return, label %bb + +bb: ; preds = %bb, %entry + %indvar = phi i32 [ 0, %entry ], [ %tmp, %bb ] ; [#uses=2] + %text_addr.04 = getelementptr i8* %text, i32 %indvar ; [#uses=1] + %2 = load i8* %text_addr.04, align 1 ; [#uses=1] + store i8 %2, i8* %io, align 1 + %tmp = add i32 %indvar, 1 ; [#uses=2] + %scevgep = getelementptr i8* %text, i32 %tmp ; [#uses=1] + %3 = load i8* %scevgep, align 1 ; [#uses=1] + %4 = icmp eq i8 %3, 0 ; [#uses=1] + br i1 %4, label %return, label %bb + +return: ; preds = %bb, %entry + ret void +} + +//===---------------------------------------------------------------------===// + There are many load PRE testcases in testsuite/gcc.dg/tree-ssa/loadpre* in the GCC testsuite. There are many pre testcases as ssa-pre-*.c From gohman at apple.com Thu Nov 5 12:25:44 2009 From: gohman at apple.com (Dan Gohman) Date: Thu, 05 Nov 2009 18:25:44 -0000 Subject: [llvm-commits] [llvm] r86147 - /llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp Message-ID: <200911051825.nA5IPi0v028553@zion.cs.uiuc.edu> Author: djg Date: Thu Nov 5 12:25:44 2009 New Revision: 86147 URL: http://llvm.org/viewvc/llvm-project?rev=86147&view=rev Log: Add an assertion to catch indirectbr in SplitBlockPredecessors. This makes several optimization passes abort in cases where they're currently silently miscompiling code. Remove the indirectbr assertion from SplitEdge. Indirectbr is only a problem for critical edges, and SplitEdge defers to SplitCriticalEdge to handle those, and SplitCriticalEdge has its own assertion for indirectbr. Modified: llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp Modified: llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp?rev=86147&r1=86146&r2=86147&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp Thu Nov 5 12:25:44 2009 @@ -275,8 +275,6 @@ /// SplitEdge - Split the edge connecting specified block. Pass P must /// not be NULL. BasicBlock *llvm::SplitEdge(BasicBlock *BB, BasicBlock *Succ, Pass *P) { - assert(!isa(BB->getTerminator()) && - "Cannot split an edge from an IndirectBrInst"); TerminatorInst *LatchTerm = BB->getTerminator(); unsigned SuccNum = 0; #ifndef NDEBUG @@ -386,6 +384,12 @@ bool IsLoopEntry = !!L; bool SplitMakesNewLoopHeader = false; for (unsigned i = 0; i != NumPreds; ++i) { + // This is slightly more strict than necessary; the minimum requirement + // is that there be no more than one indirectbr branching to BB. And + // all BlockAddress uses would need to be updated. + assert(!isa(Preds[i]->getTerminator()) && + "Cannot split an edge from an IndirectBrInst"); + Preds[i]->getTerminator()->replaceUsesOfWith(BB, NewBB); if (LI) { From dgregor at apple.com Thu Nov 5 12:30:51 2009 From: dgregor at apple.com (Douglas Gregor) Date: Thu, 05 Nov 2009 18:30:51 -0000 Subject: [llvm-commits] [llvm] r86148 - /llvm/trunk/include/llvm/Support/CommandLine.h Message-ID: <200911051830.nA5IUp4n028721@zion.cs.uiuc.edu> Author: dgregor Date: Thu Nov 5 12:30:50 2009 New Revision: 86148 URL: http://llvm.org/viewvc/llvm-project?rev=86148&view=rev Log: Move llvm::cl::opt's conversion function into the base classes that actually need that conversion function. Silences a Clang++ warning. Modified: llvm/trunk/include/llvm/Support/CommandLine.h Modified: llvm/trunk/include/llvm/Support/CommandLine.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/CommandLine.h?rev=86148&r1=86147&r2=86148&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/CommandLine.h (original) +++ llvm/trunk/include/llvm/Support/CommandLine.h Thu Nov 5 12:30:50 2009 @@ -781,6 +781,8 @@ DataType &getValue() { check(); return *Location; } const DataType &getValue() const { check(); return *Location; } + + operator DataType() const { return this->getValue(); } }; @@ -816,6 +818,8 @@ DataType &getValue() { return Value; } DataType getValue() const { return Value; } + operator DataType() const { return getValue(); } + // If the datatype is a pointer, support -> on it. DataType operator->() const { return Value; } }; @@ -865,8 +869,6 @@ ParserClass &getParser() { return Parser; } - operator DataType() const { return this->getValue(); } - template DataType &operator=(const T &Val) { this->setValue(Val); From gohman at apple.com Thu Nov 5 12:47:09 2009 From: gohman at apple.com (Dan Gohman) Date: Thu, 05 Nov 2009 18:47:09 -0000 Subject: [llvm-commits] [llvm] r86149 - in /llvm/trunk/lib/Target: ARM/ARMISelDAGToDAG.cpp Alpha/AlphaISelDAGToDAG.cpp CellSPU/SPUISelDAGToDAG.cpp MSP430/MSP430ISelDAGToDAG.cpp Mips/MipsISelDAGToDAG.cpp PIC16/PIC16ISelDAGToDAG.cpp PowerPC/PPCISelDAGToDAG.cpp Sparc/SparcISelDAGToDAG.cpp SystemZ/SystemZISelDAGToDAG.cpp X86/X86ISelDAGToDAG.cpp XCore/XCoreISelDAGToDAG.cpp Message-ID: <200911051847.nA5IlAxk029288@zion.cs.uiuc.edu> Author: djg Date: Thu Nov 5 12:47:09 2009 New Revision: 86149 URL: http://llvm.org/viewvc/llvm-project?rev=86149&view=rev Log: Remove uninteresting and confusing debug output. Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp llvm/trunk/lib/Target/Alpha/AlphaISelDAGToDAG.cpp llvm/trunk/lib/Target/CellSPU/SPUISelDAGToDAG.cpp llvm/trunk/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp llvm/trunk/lib/Target/Mips/MipsISelDAGToDAG.cpp llvm/trunk/lib/Target/PIC16/PIC16ISelDAGToDAG.cpp llvm/trunk/lib/Target/PowerPC/PPCISelDAGToDAG.cpp llvm/trunk/lib/Target/Sparc/SparcISelDAGToDAG.cpp llvm/trunk/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp llvm/trunk/lib/Target/XCore/XCoreISelDAGToDAG.cpp Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp?rev=86149&r1=86148&r2=86149&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Thu Nov 5 12:47:09 2009 @@ -187,8 +187,6 @@ void ARMDAGToDAGISel::InstructionSelect() { - DEBUG(BB->dump()); - SelectRoot(*CurDAG); CurDAG->RemoveDeadNodes(); } Modified: llvm/trunk/lib/Target/Alpha/AlphaISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Alpha/AlphaISelDAGToDAG.cpp?rev=86149&r1=86148&r2=86149&view=diff ============================================================================== --- llvm/trunk/lib/Target/Alpha/AlphaISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/Alpha/AlphaISelDAGToDAG.cpp Thu Nov 5 12:47:09 2009 @@ -225,8 +225,6 @@ /// InstructionSelect - This callback is invoked by /// SelectionDAGISel when it has created a SelectionDAG for us to codegen. void AlphaDAGToDAGISel::InstructionSelect() { - DEBUG(BB->dump()); - // Select target instructions for the DAG. SelectRoot(*CurDAG); CurDAG->RemoveDeadNodes(); Modified: llvm/trunk/lib/Target/CellSPU/SPUISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPUISelDAGToDAG.cpp?rev=86149&r1=86148&r2=86149&view=diff ============================================================================== --- llvm/trunk/lib/Target/CellSPU/SPUISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/CellSPU/SPUISelDAGToDAG.cpp Thu Nov 5 12:47:09 2009 @@ -417,8 +417,6 @@ void SPUDAGToDAGISel::InstructionSelect() { - DEBUG(BB->dump()); - // Select target instructions for the DAG. SelectRoot(*CurDAG); CurDAG->RemoveDeadNodes(); Modified: llvm/trunk/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp?rev=86149&r1=86148&r2=86149&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp Thu Nov 5 12:47:09 2009 @@ -438,8 +438,6 @@ DEBUG(errs() << "Selection DAG after RMW preprocessing:\n"); DEBUG(CurDAG->dump()); - DEBUG(BB->dump()); - // Codegen the basic block. DEBUG(errs() << "===== Instruction selection begins:\n"); DEBUG(Indent = 0); Modified: llvm/trunk/lib/Target/Mips/MipsISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsISelDAGToDAG.cpp?rev=86149&r1=86148&r2=86149&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/Mips/MipsISelDAGToDAG.cpp Thu Nov 5 12:47:09 2009 @@ -108,7 +108,6 @@ /// InstructionSelect - This callback is invoked by /// SelectionDAGISel when it has created a SelectionDAG for us to codegen. void MipsDAGToDAGISel::InstructionSelect() { - DEBUG(BB->dump()); // Codegen the basic block. DEBUG(errs() << "===== Instruction selection begins:\n"); DEBUG(Indent = 0); Modified: llvm/trunk/lib/Target/PIC16/PIC16ISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16ISelDAGToDAG.cpp?rev=86149&r1=86148&r2=86149&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16ISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16ISelDAGToDAG.cpp Thu Nov 5 12:47:09 2009 @@ -30,7 +30,6 @@ /// InstructionSelect - This callback is invoked by /// SelectionDAGISel when it has created a SelectionDAG for us to codegen. void PIC16DAGToDAGISel::InstructionSelect() { - DEBUG(BB->dump()); SelectRoot(*CurDAG); CurDAG->RemoveDeadNodes(); } Modified: llvm/trunk/lib/Target/PowerPC/PPCISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelDAGToDAG.cpp?rev=86149&r1=86148&r2=86149&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/PPCISelDAGToDAG.cpp Thu Nov 5 12:47:09 2009 @@ -187,8 +187,6 @@ /// InstructionSelect - This callback is invoked by /// SelectionDAGISel when it has created a SelectionDAG for us to codegen. void PPCDAGToDAGISel::InstructionSelect() { - DEBUG(BB->dump()); - // Select target instructions for the DAG. SelectRoot(*CurDAG); CurDAG->RemoveDeadNodes(); Modified: llvm/trunk/lib/Target/Sparc/SparcISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/SparcISelDAGToDAG.cpp?rev=86149&r1=86148&r2=86149&view=diff ============================================================================== --- llvm/trunk/lib/Target/Sparc/SparcISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/Sparc/SparcISelDAGToDAG.cpp Thu Nov 5 12:47:09 2009 @@ -75,7 +75,6 @@ /// InstructionSelect - This callback is invoked by /// SelectionDAGISel when it has created a SelectionDAG for us to codegen. void SparcDAGToDAGISel::InstructionSelect() { - DEBUG(BB->dump()); CurBB = BB; // Select target instructions for the DAG. SelectRoot(*CurDAG); Modified: llvm/trunk/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp?rev=86149&r1=86148&r2=86149&view=diff ============================================================================== --- llvm/trunk/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp Thu Nov 5 12:47:09 2009 @@ -603,8 +603,6 @@ /// InstructionSelect - This callback is invoked by /// SelectionDAGISel when it has created a SelectionDAG for us to codegen. void SystemZDAGToDAGISel::InstructionSelect() { - DEBUG(BB->dump()); - // Codegen the basic block. DEBUG(errs() << "===== Instruction selection begins:\n"); DEBUG(Indent = 0); Modified: llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp?rev=86149&r1=86148&r2=86149&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp Thu Nov 5 12:47:09 2009 @@ -661,7 +661,6 @@ const Function *F = MF->getFunction(); OptForSize = F->hasFnAttr(Attribute::OptimizeForSize); - DEBUG(BB->dump()); if (OptLevel != CodeGenOpt::None) PreprocessForRMW(); Modified: llvm/trunk/lib/Target/XCore/XCoreISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreISelDAGToDAG.cpp?rev=86149&r1=86148&r2=86149&view=diff ============================================================================== --- llvm/trunk/lib/Target/XCore/XCoreISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/XCore/XCoreISelDAGToDAG.cpp Thu Nov 5 12:47:09 2009 @@ -149,10 +149,7 @@ /// InstructionSelect - This callback is invoked by /// SelectionDAGISel when it has created a SelectionDAG for us to codegen. -void XCoreDAGToDAGISel:: -InstructionSelect() { - DEBUG(BB->dump()); - +void XCoreDAGToDAGISel::InstructionSelect() { // Select target instructions for the DAG. SelectRoot(*CurDAG); From gohman at apple.com Thu Nov 5 12:49:11 2009 From: gohman at apple.com (Dan Gohman) Date: Thu, 05 Nov 2009 18:49:11 -0000 Subject: [llvm-commits] [llvm] r86151 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Message-ID: <200911051849.nA5InBgQ029469@zion.cs.uiuc.edu> Author: djg Date: Thu Nov 5 12:49:11 2009 New Revision: 86151 URL: http://llvm.org/viewvc/llvm-project?rev=86151&view=rev Log: Avoid printing a redundant space in SDNode->dump(). Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=86151&r1=86150&r2=86151&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Thu Nov 5 12:49:11 2009 @@ -5814,9 +5814,8 @@ void SDNode::print(raw_ostream &OS, const SelectionDAG *G) const { print_types(OS, G); - OS << " "; for (unsigned i = 0, e = getNumOperands(); i != e; ++i) { - if (i) OS << ", "; + if (i) OS << ", "; else OS << " "; OS << (void*)getOperand(i).getNode(); if (unsigned RN = getOperand(i).getResNo()) OS << ":" << RN; From ofv at wanadoo.es Thu Nov 5 12:57:57 2009 From: ofv at wanadoo.es (Oscar Fuentes) Date: Thu, 05 Nov 2009 18:57:57 -0000 Subject: [llvm-commits] [llvm] r86152 - /llvm/trunk/cmake/config-ix.cmake Message-ID: <200911051857.nA5IvvkA029805@zion.cs.uiuc.edu> Author: ofv Date: Thu Nov 5 12:57:56 2009 New Revision: 86152 URL: http://llvm.org/viewvc/llvm-project?rev=86152&view=rev Log: CMake: do not test for pthread and dl libraries on Windows (except Cygwin). Fixes PR 5368. Modified: llvm/trunk/cmake/config-ix.cmake Modified: llvm/trunk/cmake/config-ix.cmake URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/config-ix.cmake?rev=86152&r1=86151&r2=86152&view=diff ============================================================================== --- llvm/trunk/cmake/config-ix.cmake (original) +++ llvm/trunk/cmake/config-ix.cmake Thu Nov 5 12:57:56 2009 @@ -39,7 +39,9 @@ check_include_file(malloc/malloc.h HAVE_MALLOC_MALLOC_H) check_include_file(memory.h HAVE_MEMORY_H) check_include_file(ndir.h HAVE_NDIR_H) -check_include_file(pthread.h HAVE_PTHREAD_H) +if( NOT LLVM_ON_WIN32 ) + check_include_file(pthread.h HAVE_PTHREAD_H) +endif() check_include_file(setjmp.h HAVE_SETJMP_H) check_include_file(signal.h HAVE_SIGNAL_H) check_include_file(stdint.h HAVE_STDINT_H) @@ -63,10 +65,12 @@ check_include_file(windows.h HAVE_WINDOWS_H) # library checks -check_library_exists(pthread pthread_create "" HAVE_LIBPTHREAD) -check_library_exists(pthread pthread_getspecific "" HAVE_PTHREAD_GETSPECIFIC) -check_library_exists(pthread pthread_rwlock_init "" HAVE_PTHREAD_RWLOCK_INIT) -check_library_exists(dl dlopen "" HAVE_LIBDL) +if( NOT LLVM_ON_WIN32 ) + check_library_exists(pthread pthread_create "" HAVE_LIBPTHREAD) + check_library_exists(pthread pthread_getspecific "" HAVE_PTHREAD_GETSPECIFIC) + check_library_exists(pthread pthread_rwlock_init "" HAVE_PTHREAD_RWLOCK_INIT) + check_library_exists(dl dlopen "" HAVE_LIBDL) +endif() # function checks check_symbol_exists(getpagesize unistd.h HAVE_GETPAGESIZE) @@ -86,7 +90,9 @@ check_symbol_exists(mkdtemp "stdlib.h;unistd.h" HAVE_MKDTEMP) check_symbol_exists(mkstemp "stdlib.h;unistd.h" HAVE_MKSTEMP) check_symbol_exists(mktemp "stdlib.h;unistd.h" HAVE_MKTEMP) -check_symbol_exists(pthread_mutex_lock pthread.h HAVE_PTHREAD_MUTEX_LOCK) +if( NOT LLVM_ON_WIN32 ) + check_symbol_exists(pthread_mutex_lock pthread.h HAVE_PTHREAD_MUTEX_LOCK) +endif() check_symbol_exists(sbrk unistd.h HAVE_SBRK) check_symbol_exists(strtoll stdlib.h HAVE_STRTOLL) check_symbol_exists(strerror string.h HAVE_STRERROR) From ofv at wanadoo.es Thu Nov 5 13:03:26 2009 From: ofv at wanadoo.es (Oscar Fuentes) Date: Thu, 05 Nov 2009 19:03:26 -0000 Subject: [llvm-commits] [llvm] r86153 - in /llvm/trunk: cmake/config-ix.cmake include/llvm/Config/config.h.cmake Message-ID: <200911051903.nA5J3QjA029974@zion.cs.uiuc.edu> Author: ofv Date: Thu Nov 5 13:03:26 2009 New Revision: 86153 URL: http://llvm.org/viewvc/llvm-project?rev=86153&view=rev Log: CMake: Detect dotty. Patch by Arnaud Allard de Grandmaison! Modified: llvm/trunk/cmake/config-ix.cmake llvm/trunk/include/llvm/Config/config.h.cmake Modified: llvm/trunk/cmake/config-ix.cmake URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/config-ix.cmake?rev=86153&r1=86152&r2=86153&view=diff ============================================================================== --- llvm/trunk/cmake/config-ix.cmake (original) +++ llvm/trunk/cmake/config-ix.cmake Thu Nov 5 13:03:26 2009 @@ -126,6 +126,15 @@ check_type_exists(uint64_t "${headers}" HAVE_UINT64_T) check_type_exists(u_int64_t "${headers}" HAVE_U_INT64_T) +# available programs checks +find_program(DOTTY_EXECUTABLE dotty) +if(DOTTY_EXECUTABLE) + set(HAVE_DOTTY 1) + set(LLVM_PATH_DOTTY ${DOTTY_EXECUTABLE}) + mark_as_advanced(HAVE_DOTTY) + mark_as_advanced(LLVM_PATH_DOTTY) +endif() + # Define LLVM_MULTITHREADED if gcc atomic builtins exists. include(CheckAtomic) Modified: llvm/trunk/include/llvm/Config/config.h.cmake URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Config/config.h.cmake?rev=86153&r1=86152&r2=86153&view=diff ============================================================================== --- llvm/trunk/include/llvm/Config/config.h.cmake (original) +++ llvm/trunk/include/llvm/Config/config.h.cmake Thu Nov 5 13:03:26 2009 @@ -80,7 +80,7 @@ #undef HAVE_DOT /* Define if the dotty program is available */ -#undef HAVE_DOTTY +#cmakedefine HAVE_DOTTY ${HAVE_DOTTY} /* Define if you have the _dyld_func_lookup function. */ #undef HAVE_DYLD @@ -471,7 +471,7 @@ #undef LLVM_PATH_DOT /* Define to path to dotty program if found or 'echo dotty' otherwise */ -#undef LLVM_PATH_DOTTY +#cmakedefine LLVM_PATH_DOTTY "${LLVM_PATH_DOTTY}" /* Define to path to Graphviz program if found or 'echo Graphviz' otherwise */ #undef LLVM_PATH_GRAPHVIZ From gohman at apple.com Thu Nov 5 13:21:42 2009 From: gohman at apple.com (Dan Gohman) Date: Thu, 05 Nov 2009 19:21:42 -0000 Subject: [llvm-commits] [llvm] r86159 - in /llvm/trunk: include/llvm/Analysis/LoopInfo.h lib/Analysis/LoopInfo.cpp Message-ID: <200911051921.nA5JLg23030686@zion.cs.uiuc.edu> Author: djg Date: Thu Nov 5 13:21:41 2009 New Revision: 86159 URL: http://llvm.org/viewvc/llvm-project?rev=86159&view=rev Log: Factor out the predicate code for loopsimplify form exit blocks into a separate helper function. Modified: llvm/trunk/include/llvm/Analysis/LoopInfo.h llvm/trunk/lib/Analysis/LoopInfo.cpp Modified: llvm/trunk/include/llvm/Analysis/LoopInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/LoopInfo.h?rev=86159&r1=86158&r2=86159&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/LoopInfo.h (original) +++ llvm/trunk/include/llvm/Analysis/LoopInfo.h Thu Nov 5 13:21:41 2009 @@ -572,6 +572,10 @@ /// normal form. bool isLoopSimplifyForm() const; + /// hasDedicatedExits - Return true if no exit block for the loop + /// has a predecessor that is outside the loop. + bool hasDedicatedExits() const; + /// getUniqueExitBlocks - Return all unique successor blocks of this loop. /// These are the blocks _outside of the current loop_ which are branched to. /// This assumes that loop is in canonical form. Modified: llvm/trunk/lib/Analysis/LoopInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LoopInfo.cpp?rev=86159&r1=86158&r2=86159&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/LoopInfo.cpp (original) +++ llvm/trunk/lib/Analysis/LoopInfo.cpp Thu Nov 5 13:21:41 2009 @@ -286,12 +286,14 @@ /// the LoopSimplify form transforms loops to, which is sometimes called /// normal form. bool Loop::isLoopSimplifyForm() const { - // Normal-form loops have a preheader. - if (!getLoopPreheader()) - return false; - // Normal-form loops have a single backedge. - if (!getLoopLatch()) - return false; + // Normal-form loops have a preheader, a single backedge, and all of their + // exits have all their predecessors inside the loop. + return getLoopPreheader() && getLoopLatch() && hasDedicatedExits(); +} + +/// hasDedicatedExits - Return true if no exit block for the loop +/// has a predecessor that is outside the loop. +bool Loop::hasDedicatedExits() const { // Sort the blocks vector so that we can use binary search to do quick // lookups. SmallPtrSet LoopBBs(block_begin(), block_end()); From gohman at apple.com Thu Nov 5 13:33:15 2009 From: gohman at apple.com (Dan Gohman) Date: Thu, 05 Nov 2009 19:33:15 -0000 Subject: [llvm-commits] [llvm] r86160 - /llvm/trunk/lib/Transforms/Utils/LCSSA.cpp Message-ID: <200911051933.nA5JXFL6031114@zion.cs.uiuc.edu> Author: djg Date: Thu Nov 5 13:33:15 2009 New Revision: 86160 URL: http://llvm.org/viewvc/llvm-project?rev=86160&view=rev Log: Delete an unused member variable. Modified: llvm/trunk/lib/Transforms/Utils/LCSSA.cpp Modified: llvm/trunk/lib/Transforms/Utils/LCSSA.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LCSSA.cpp?rev=86160&r1=86159&r2=86160&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/LCSSA.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/LCSSA.cpp Thu Nov 5 13:33:15 2009 @@ -50,7 +50,6 @@ LCSSA() : LoopPass(&ID) {} // Cached analysis information for the current function. - LoopInfo *LI; DominatorTree *DT; std::vector LoopBlocks; PredIteratorCache PredCache; @@ -121,7 +120,6 @@ bool LCSSA::runOnLoop(Loop *TheLoop, LPPassManager &LPM) { L = TheLoop; - LI = &LPM.getAnalysis(); DT = &getAnalysis(); // Get the set of exiting blocks. From gohman at apple.com Thu Nov 5 13:41:38 2009 From: gohman at apple.com (Dan Gohman) Date: Thu, 05 Nov 2009 19:41:38 -0000 Subject: [llvm-commits] [llvm] r86161 - /llvm/trunk/lib/Analysis/IVUsers.cpp Message-ID: <200911051941.nA5Jfc3t031444@zion.cs.uiuc.edu> Author: djg Date: Thu Nov 5 13:41:37 2009 New Revision: 86161 URL: http://llvm.org/viewvc/llvm-project?rev=86161&view=rev Log: Fix IVUsers to avoid assuming that the loop has a unique backedge. Modified: llvm/trunk/lib/Analysis/IVUsers.cpp Modified: llvm/trunk/lib/Analysis/IVUsers.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/IVUsers.cpp?rev=86161&r1=86160&r2=86161&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/IVUsers.cpp (original) +++ llvm/trunk/lib/Analysis/IVUsers.cpp Thu Nov 5 13:41:37 2009 @@ -151,6 +151,8 @@ if (L->contains(User->getParent())) return false; BasicBlock *LatchBlock = L->getLoopLatch(); + if (!LatchBlock) + return false; // Ok, the user is outside of the loop. If it is dominated by the latch // block, use the post-inc value. From gohman at apple.com Thu Nov 5 13:42:20 2009 From: gohman at apple.com (Dan Gohman) Date: Thu, 05 Nov 2009 19:42:20 -0000 Subject: [llvm-commits] [llvm] r86162 - in /llvm/trunk/include/llvm/Support: ConstantFolder.h TargetFolder.h Message-ID: <200911051942.nA5JgKsu031479@zion.cs.uiuc.edu> Author: djg Date: Thu Nov 5 13:42:20 2009 New Revision: 86162 URL: http://llvm.org/viewvc/llvm-project?rev=86162&view=rev Log: InstrTypes.h includes Instruction.h, so it's not necessary to include both. Modified: llvm/trunk/include/llvm/Support/ConstantFolder.h llvm/trunk/include/llvm/Support/TargetFolder.h Modified: llvm/trunk/include/llvm/Support/ConstantFolder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ConstantFolder.h?rev=86162&r1=86161&r2=86162&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/ConstantFolder.h (original) +++ llvm/trunk/include/llvm/Support/ConstantFolder.h Thu Nov 5 13:42:20 2009 @@ -18,7 +18,6 @@ #define LLVM_SUPPORT_CONSTANTFOLDER_H #include "llvm/Constants.h" -#include "llvm/Instruction.h" #include "llvm/InstrTypes.h" namespace llvm { Modified: llvm/trunk/include/llvm/Support/TargetFolder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/TargetFolder.h?rev=86162&r1=86161&r2=86162&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/TargetFolder.h (original) +++ llvm/trunk/include/llvm/Support/TargetFolder.h Thu Nov 5 13:42:20 2009 @@ -20,7 +20,6 @@ #define LLVM_SUPPORT_TARGETFOLDER_H #include "llvm/Constants.h" -#include "llvm/Instruction.h" #include "llvm/InstrTypes.h" #include "llvm/Analysis/ConstantFolding.h" From gohman at apple.com Thu Nov 5 13:43:25 2009 From: gohman at apple.com (Dan Gohman) Date: Thu, 05 Nov 2009 19:43:25 -0000 Subject: [llvm-commits] [llvm] r86163 - /llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp Message-ID: <200911051943.nA5JhPJB031528@zion.cs.uiuc.edu> Author: djg Date: Thu Nov 5 13:43:25 2009 New Revision: 86163 URL: http://llvm.org/viewvc/llvm-project?rev=86163&view=rev Log: Call getAnalysis the normal way, instead of asking passed-in LoopPassManager for it. Modified: llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp Modified: llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp?rev=86163&r1=86162&r2=86163&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp Thu Nov 5 13:43:25 2009 @@ -15,7 +15,6 @@ #include "llvm/Transforms/Scalar.h" #include "llvm/Function.h" #include "llvm/IntrinsicInst.h" -#include "llvm/Analysis/LoopInfo.h" #include "llvm/Analysis/LoopPass.h" #include "llvm/Analysis/Dominators.h" #include "llvm/Analysis/ScalarEvolution.h" @@ -49,6 +48,7 @@ AU.addRequiredID(LCSSAID); AU.addPreservedID(LCSSAID); AU.addPreserved(); + AU.addRequired(); AU.addPreserved(); AU.addPreserved(); AU.addPreserved(); @@ -287,7 +287,7 @@ "bb.nph", OrigHeader->getParent(), NewHeader); - LoopInfo &LI = LPM.getAnalysis(); + LoopInfo &LI = getAnalysis(); if (Loop *PL = LI.getLoopFor(OrigPreHeader)) PL->addBasicBlockToLoop(NewPreHeader, LI.getBase()); BranchInst::Create(NewHeader, NewPreHeader); From gohman at apple.com Thu Nov 5 13:44:07 2009 From: gohman at apple.com (Dan Gohman) Date: Thu, 05 Nov 2009 19:44:07 -0000 Subject: [llvm-commits] [llvm] r86164 - /llvm/trunk/lib/Transforms/Utils/LoopUnroll.cpp Message-ID: <200911051944.nA5Ji7Fe031555@zion.cs.uiuc.edu> Author: djg Date: Thu Nov 5 13:44:06 2009 New Revision: 86164 URL: http://llvm.org/viewvc/llvm-project?rev=86164&view=rev Log: Teach LoopUnroll how to bail if LoopSimplify can't give it what it needs. Modified: llvm/trunk/lib/Transforms/Utils/LoopUnroll.cpp Modified: llvm/trunk/lib/Transforms/Utils/LoopUnroll.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LoopUnroll.cpp?rev=86164&r1=86163&r2=86164&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/LoopUnroll.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/LoopUnroll.cpp Thu Nov 5 13:44:06 2009 @@ -108,8 +108,19 @@ bool llvm::UnrollLoop(Loop *L, unsigned Count, LoopInfo* LI, LPPassManager* LPM) { assert(L->isLCSSAForm()); - BasicBlock *Header = L->getHeader(); + BasicBlock *Preheader = L->getLoopPreheader(); + if (!Preheader) { + DEBUG(errs() << " Can't unroll; loop preheader-insertion failed.\n"); + return false; + } + BasicBlock *LatchBlock = L->getLoopLatch(); + if (!LatchBlock) { + DEBUG(errs() << " Can't unroll; loop exit-block-insertion failed.\n"); + return false; + } + + BasicBlock *Header = L->getHeader(); BranchInst *BI = dyn_cast(LatchBlock->getTerminator()); if (!BI || BI->isUnconditional()) { From evan.cheng at apple.com Thu Nov 5 14:16:28 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 05 Nov 2009 20:16:28 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r86168 - /llvm-gcc-4.2/trunk/build_gcc Message-ID: <200911052016.nA5KGST7000608@zion.cs.uiuc.edu> Author: evancheng Date: Thu Nov 5 14:16:28 2009 New Revision: 86168 URL: http://llvm.org/viewvc/llvm-project?rev=86168&view=rev Log: Look for llvm-gcc under /Developer/usr/bin first. 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=86168&r1=86167&r2=86168&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/build_gcc (original) +++ llvm-gcc-4.2/trunk/build_gcc Thu Nov 5 14:16:28 2009 @@ -266,7 +266,7 @@ # If the user has set CC or CXX, respect their wishes. If not, # compile with LLVM-GCC/LLVM-G++ if available; if LLVM is not # available, fall back to usual GCC/G++ default. -savedPATH=$PATH ; PATH="$PATH:/Developer/usr/bin" +savedPATH=$PATH ; PATH="/Developer/usr/bin:$PATH" XTMPCC=$(which llvm-gcc) if [ x$CC = x -a x$XTMPCC != x ] ; then export CC=$XTMPCC forcedCC=1 ; fi XTMPCC=$(which llvm-g++) From david_goodwin at apple.com Thu Nov 5 15:06:09 2009 From: david_goodwin at apple.com (David Goodwin) Date: Thu, 05 Nov 2009 21:06:09 -0000 Subject: [llvm-commits] [llvm] r86172 - /llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp Message-ID: <200911052106.nA5L69L6002767@zion.cs.uiuc.edu> Author: david_goodwin Date: Thu Nov 5 15:06:09 2009 New Revision: 86172 URL: http://llvm.org/viewvc/llvm-project?rev=86172&view=rev Log: Fix bug in aggressive antidep breaking; liveness was not updated correctly for regions that do not have antidep candidates. Modified: llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp Modified: llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp?rev=86172&r1=86171&r2=86172&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp (original) +++ llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp Thu Nov 5 15:06:09 2009 @@ -630,12 +630,6 @@ std::multimap& RegRefs = State->GetRegRefs(); - // Nothing to do if no candidates. - if (Candidates.empty()) { - DEBUG(errs() << "\n===== No anti-dependency candidates\n"); - return 0; - } - // The code below assumes that there is at least one instruction, // so just duck out immediately if the block is empty. if (SUnits.empty()) return 0; @@ -655,16 +649,19 @@ // ...need a map from MI to SUnit. std::map MISUnitMap; - - DEBUG(errs() << "\n===== Attempting to break " << Candidates.size() << - " anti-dependencies\n"); for (unsigned i = 0, e = SUnits.size(); i != e; ++i) { SUnit *SU = &SUnits[i]; MISUnitMap.insert(std::pair(SU->getInstr(), SU)); } + // Even if there are no anti-dependencies we still need to go + // through the instructions to update Def, Kills, etc. #ifndef NDEBUG - { + if (Candidates.empty()) { + DEBUG(errs() << "\n===== No anti-dependency candidates\n"); + } else { + DEBUG(errs() << "\n===== Attempting to break " << Candidates.size() << + " anti-dependencies\n"); DEBUG(errs() << "Available regs:"); for (unsigned Reg = 0; Reg < TRI->getNumRegs(); ++Reg) { if (!State->IsLive(Reg)) From gohman at apple.com Thu Nov 5 15:11:53 2009 From: gohman at apple.com (Dan Gohman) Date: Thu, 05 Nov 2009 21:11:53 -0000 Subject: [llvm-commits] [llvm] r86175 - in /llvm/trunk/lib/Transforms: IPO/LoopExtractor.cpp Scalar/IndVarSimplify.cpp Scalar/LICM.cpp Scalar/LoopIndexSplit.cpp Scalar/LoopRotation.cpp Scalar/LoopStrengthReduce.cpp Scalar/LoopUnswitch.cpp Message-ID: <200911052111.nA5LBsuN003018@zion.cs.uiuc.edu> Author: djg Date: Thu Nov 5 15:11:53 2009 New Revision: 86175 URL: http://llvm.org/viewvc/llvm-project?rev=86175&view=rev Log: Update various Loop optimization passes to cope with the possibility that LoopSimplify form may not be available. Modified: llvm/trunk/lib/Transforms/IPO/LoopExtractor.cpp llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp llvm/trunk/lib/Transforms/Scalar/LICM.cpp llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp Modified: llvm/trunk/lib/Transforms/IPO/LoopExtractor.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/LoopExtractor.cpp?rev=86175&r1=86174&r2=86175&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/LoopExtractor.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/LoopExtractor.cpp Thu Nov 5 15:11:53 2009 @@ -75,6 +75,10 @@ if (L->getParentLoop()) return false; + // If LoopSimplify form is not available, stay out of trouble. + if (!L->isLoopSimplifyForm()) + return false; + DominatorTree &DT = getAnalysis(); bool Changed = false; Modified: llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp?rev=86175&r1=86174&r2=86175&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Thu Nov 5 15:11:53 2009 @@ -536,8 +536,10 @@ BasicBlock *ExitBlock = L->getExitBlock(); if (!ExitBlock) return; - Instruction *InsertPt = ExitBlock->getFirstNonPHI(); BasicBlock *Preheader = L->getLoopPreheader(); + if (!Preheader) return; + + Instruction *InsertPt = ExitBlock->getFirstNonPHI(); BasicBlock::iterator I = Preheader->getTerminator(); while (I != Preheader->begin()) { --I; Modified: llvm/trunk/lib/Transforms/Scalar/LICM.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LICM.cpp?rev=86175&r1=86174&r2=86175&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LICM.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LICM.cpp Thu Nov 5 15:11:53 2009 @@ -263,7 +263,6 @@ // Get the preheader block to move instructions into... Preheader = L->getLoopPreheader(); - assert(Preheader&&"Preheader insertion pass guarantees we have a preheader!"); // Loop over the body of this loop, looking for calls, invokes, and stores. // Because subloops have already been incorporated into AST, we skip blocks in @@ -286,12 +285,14 @@ // us to sink instructions in one pass, without iteration. After sinking // instructions, we perform another pass to hoist them out of the loop. // - SinkRegion(DT->getNode(L->getHeader())); - HoistRegion(DT->getNode(L->getHeader())); + if (L->hasDedicatedExits()) + SinkRegion(DT->getNode(L->getHeader())); + if (Preheader) + HoistRegion(DT->getNode(L->getHeader())); // Now that all loop invariants have been removed from the loop, promote any // memory references to scalars that we can... - if (!DisablePromotion) + if (!DisablePromotion && Preheader && L->hasDedicatedExits()) PromoteValuesInLoop(); // Clear out loops state information for the next iteration Modified: llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp?rev=86175&r1=86174&r2=86175&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp Thu Nov 5 15:11:53 2009 @@ -209,6 +209,10 @@ L = IncomingLoop; LPM = &LPM_Ref; + // If LoopSimplify form is not available, stay out of trouble. + if (!L->isLoopSimplifyForm()) + return false; + // FIXME - Nested loops make dominator info updates tricky. if (!L->getSubLoops().empty()) return false; Modified: llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp?rev=86175&r1=86174&r2=86175&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp Thu Nov 5 15:11:53 2009 @@ -104,17 +104,18 @@ bool LoopRotate::rotateLoop(Loop *Lp, LPPassManager &LPM) { L = Lp; - OrigHeader = L->getHeader(); OrigPreHeader = L->getLoopPreheader(); + if (!OrigPreHeader) return false; + OrigLatch = L->getLoopLatch(); + if (!OrigLatch) return false; + + OrigHeader = L->getHeader(); // If the loop has only one block then there is not much to rotate. if (L->getBlocks().size() == 1) return false; - assert(OrigHeader && OrigLatch && OrigPreHeader && - "Loop is not in canonical form"); - // If the loop header is not one of the loop exiting blocks then // either this loop is already rotated or it is not // suitable for loop rotation transformations. Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=86175&r1=86174&r2=86175&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Thu Nov 5 15:11:53 2009 @@ -2528,6 +2528,10 @@ SE = &getAnalysis(); Changed = false; + // If LoopSimplify form is not available, stay out of trouble. + if (!L->getLoopPreheader() || !L->getLoopLatch()) + return false; + if (!IU->IVUsesByStride.empty()) { DEBUG(errs() << "\nLSR on \"" << L->getHeader()->getParent()->getName() << "\" "; Modified: llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp?rev=86175&r1=86174&r2=86175&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp Thu Nov 5 15:11:53 2009 @@ -407,6 +407,10 @@ initLoopData(); Function *F = loopHeader->getParent(); + // If LoopSimplify was unable to form a preheader, don't do any unswitching. + if (!loopPreheader) + return false; + // If the condition is trivial, always unswitch. There is no code growth for // this case. if (!IsTrivialUnswitchCondition(LoopCond)) { From gohman at apple.com Thu Nov 5 15:14:46 2009 From: gohman at apple.com (Dan Gohman) Date: Thu, 05 Nov 2009 21:14:46 -0000 Subject: [llvm-commits] [llvm] r86176 - in /llvm/trunk: lib/Transforms/Utils/LoopSimplify.cpp test/Transforms/LoopSimplify/indirectbr.ll Message-ID: <200911052114.nA5LEkrq003133@zion.cs.uiuc.edu> Author: djg Date: Thu Nov 5 15:14:46 2009 New Revision: 86176 URL: http://llvm.org/viewvc/llvm-project?rev=86176&view=rev Log: The introduction of indirectbr meant the introduction of unsplittable critical edges, which means the introduction of loops which cannot be transformed to LoopSimplify form. Fix LoopSimplify to avoid transforming such loops into invalid code. Added: llvm/trunk/test/Transforms/LoopSimplify/indirectbr.ll Modified: llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp Modified: llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp?rev=86176&r1=86175&r2=86176&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp Thu Nov 5 15:14:46 2009 @@ -23,6 +23,11 @@ // // This pass also guarantees that loops will have exactly one backedge. // +// Indirectbr instructions introduce several complications. If the loop +// contains or is entered by an indirectbr instruction, it may not be possible +// to transform the loop and make these guarantees. Client code should check +// that these conditions are true before relying on them. +// // Note that the simplifycfg pass will clean up blocks which are split out but // end up being unnecessary, so usage of this pass should not pessimize // generated code. @@ -81,17 +86,15 @@ AU.addPreservedID(BreakCriticalEdgesID); // No critical edges added. } - /// verifyAnalysis() - Verify loop nest. - void verifyAnalysis() const { - assert(L->isLoopSimplifyForm() && "LoopSimplify form not preserved!"); - } + /// verifyAnalysis() - Verify LoopSimplifyForm's guarantees. + void verifyAnalysis() const; private: bool ProcessLoop(Loop *L, LPPassManager &LPM); BasicBlock *RewriteLoopExitBlock(Loop *L, BasicBlock *Exit); BasicBlock *InsertPreheaderForLoop(Loop *L); Loop *SeparateNestedLoop(Loop *L, LPPassManager &LPM); - void InsertUniqueBackedgeBlock(Loop *L, BasicBlock *Preheader); + BasicBlock *InsertUniqueBackedgeBlock(Loop *L, BasicBlock *Preheader); void PlaceSplitBlockCarefully(BasicBlock *NewBB, SmallVectorImpl &SplitPreds, Loop *L); @@ -160,8 +163,10 @@ BasicBlock *Preheader = L->getLoopPreheader(); if (!Preheader) { Preheader = InsertPreheaderForLoop(L); - NumInserted++; - Changed = true; + if (Preheader) { + NumInserted++; + Changed = true; + } } // Next, check to make sure that all exit nodes of the loop only have @@ -180,21 +185,22 @@ // Must be exactly this loop: no subloops, parent loops, or non-loop preds // allowed. if (!L->contains(*PI)) { - RewriteLoopExitBlock(L, ExitBlock); - NumInserted++; - Changed = true; + if (RewriteLoopExitBlock(L, ExitBlock)) { + NumInserted++; + Changed = true; + } break; } } // If the header has more than two predecessors at this point (from the // preheader and from multiple backedges), we must adjust the loop. - unsigned NumBackedges = L->getNumBackEdges(); - if (NumBackedges != 1) { + BasicBlock *LoopLatch = L->getLoopLatch(); + if (!LoopLatch) { // If this is really a nested loop, rip it out into a child loop. Don't do // this for loops with a giant number of backedges, just factor them into a // common backedge instead. - if (NumBackedges < 8) { + if (L->getNumBackEdges() < 8) { if (SeparateNestedLoop(L, LPM)) { ++NumNested; // This is a big restructuring change, reprocess the whole loop. @@ -207,9 +213,11 @@ // If we either couldn't, or didn't want to, identify nesting of the loops, // insert a new block that all backedges target, then make it jump to the // loop header. - InsertUniqueBackedgeBlock(L, Preheader); - NumInserted++; - Changed = true; + LoopLatch = InsertUniqueBackedgeBlock(L, Preheader); + if (LoopLatch) { + NumInserted++; + Changed = true; + } } // Scan over the PHI nodes in the loop header. Since they now have only two @@ -251,7 +259,8 @@ Instruction *Inst = I++; if (Inst == CI) continue; - if (!L->makeLoopInvariant(Inst, Changed, Preheader->getTerminator())) { + if (!L->makeLoopInvariant(Inst, Changed, + Preheader ? Preheader->getTerminator() : 0)) { AllInvariant = false; break; } @@ -303,8 +312,15 @@ SmallVector OutsideBlocks; for (pred_iterator PI = pred_begin(Header), PE = pred_end(Header); PI != PE; ++PI) - if (!L->contains(*PI)) // Coming in from outside the loop? - OutsideBlocks.push_back(*PI); // Keep track of it... + if (!L->contains(*PI)) { // Coming in from outside the loop? + // If the loop is branched to from an indirect branch, we won't + // be able to fully transform the loop, because it prohibits + // edge splitting. + if (isa((*PI)->getTerminator())) return 0; + + // Keep track of it. + OutsideBlocks.push_back(*PI); + } // Split out the loop pre-header. BasicBlock *NewBB = @@ -324,8 +340,12 @@ BasicBlock *LoopSimplify::RewriteLoopExitBlock(Loop *L, BasicBlock *Exit) { SmallVector LoopBlocks; for (pred_iterator I = pred_begin(Exit), E = pred_end(Exit); I != E; ++I) - if (L->contains(*I)) + if (L->contains(*I)) { + // Don't do this if the loop is exited via an indirect branch. + if (isa((*I)->getTerminator())) return 0; + LoopBlocks.push_back(*I); + } assert(!LoopBlocks.empty() && "No edges coming in from outside the loop?"); BasicBlock *NewBB = SplitBlockPredecessors(Exit, &LoopBlocks[0], @@ -519,13 +539,18 @@ /// backedges to target a new basic block and have that block branch to the loop /// header. This ensures that loops have exactly one backedge. /// -void LoopSimplify::InsertUniqueBackedgeBlock(Loop *L, BasicBlock *Preheader) { +BasicBlock * +LoopSimplify::InsertUniqueBackedgeBlock(Loop *L, BasicBlock *Preheader) { assert(L->getNumBackEdges() > 1 && "Must have > 1 backedge!"); // Get information about the loop BasicBlock *Header = L->getHeader(); Function *F = Header->getParent(); + // Unique backedge insertion currently depends on having a preheader. + if (!Preheader) + return 0; + // Figure out which basic blocks contain back-edges to the loop header. std::vector BackedgeBlocks; for (pred_iterator I = pred_begin(Header), E = pred_end(Header); I != E; ++I) @@ -612,4 +637,40 @@ DT->splitBlock(BEBlock); if (DominanceFrontier *DF = getAnalysisIfAvailable()) DF->splitBlock(BEBlock); + + return BEBlock; +} + +void LoopSimplify::verifyAnalysis() const { + // It used to be possible to just assert L->isLoopSimplifyForm(), however + // with the introduction of indirectbr, there are now cases where it's + // not possible to transform a loop as necessary. We can at least check + // that there is an indirectbr near any time there's trouble. + + // Indirectbr can interfere with preheader and unique backedge insertion. + if (!L->getLoopPreheader() || !L->getLoopLatch()) { + bool HasIndBrPred = false; + for (pred_iterator PI = pred_begin(L->getHeader()), + PE = pred_end(L->getHeader()); PI != PE; ++PI) + if (isa((*PI)->getTerminator())) { + HasIndBrPred = true; + break; + } + assert(HasIndBrPred && + "LoopSimplify has no excuse for missing loop header info!"); + } + + // Indirectbr can interfere with exit block canonicalization. + if (!L->hasDedicatedExits()) { + bool HasIndBrExiting = false; + SmallVector ExitingBlocks; + L->getExitingBlocks(ExitingBlocks); + for (unsigned i = 0, e = ExitingBlocks.size(); i != e; ++i) + if (isa((ExitingBlocks[i])->getTerminator())) { + HasIndBrExiting = true; + break; + } + assert(HasIndBrExiting && + "LoopSimplify has no excuse for missing exit block info!"); + } } Added: llvm/trunk/test/Transforms/LoopSimplify/indirectbr.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopSimplify/indirectbr.ll?rev=86176&view=auto ============================================================================== --- llvm/trunk/test/Transforms/LoopSimplify/indirectbr.ll (added) +++ llvm/trunk/test/Transforms/LoopSimplify/indirectbr.ll Thu Nov 5 15:14:46 2009 @@ -0,0 +1,83 @@ +; RUN: opt < %s -loopsimplify -lcssa -verify-loop-info -verify-dom-info -S \ +; RUN: | grep -F {indirectbr i8* %x, \[label %L0, label %L1\]} \ +; RUN: | count 6 + +; LoopSimplify should not try to transform loops when indirectbr is involved. + +define void @entry(i8* %x) { +entry: + indirectbr i8* %x, [ label %L0, label %L1 ] + +L0: + br label %L0 + +L1: + ret void +} + +define void @backedge(i8* %x) { +entry: + br label %L0 + +L0: + br label %L1 + +L1: + indirectbr i8* %x, [ label %L0, label %L1 ] +} + +define i64 @exit(i8* %x) { +entry: + br label %L2 + +L2: + %z = bitcast i64 0 to i64 + indirectbr i8* %x, [ label %L0, label %L1 ] + +L0: + br label %L2 + +L1: + ret i64 %z +} + +define i64 @criticalexit(i8* %x, i1 %a) { +entry: + br i1 %a, label %L1, label %L2 + +L2: + %z = bitcast i64 0 to i64 + indirectbr i8* %x, [ label %L0, label %L1 ] + +L0: + br label %L2 + +L1: + %y = phi i64 [ %z, %L2 ], [ 1, %entry ] + ret i64 %y +} + +define i64 @exit_backedge(i8* %x) { +entry: + br label %L0 + +L0: + %z = bitcast i64 0 to i64 + indirectbr i8* %x, [ label %L0, label %L1 ] + +L1: + ret i64 %z +} + +define i64 @criticalexit_backedge(i8* %x, i1 %a) { +entry: + br i1 %a, label %L0, label %L1 + +L0: + %z = bitcast i64 0 to i64 + indirectbr i8* %x, [ label %L0, label %L1 ] + +L1: + %y = phi i64 [ %z, %L0 ], [ 1, %entry ] + ret i64 %y +} From gohman at apple.com Thu Nov 5 15:47:05 2009 From: gohman at apple.com (Dan Gohman) Date: Thu, 05 Nov 2009 21:47:05 -0000 Subject: [llvm-commits] [llvm] r86180 - /llvm/trunk/lib/Transforms/Scalar/LoopDeletion.cpp Message-ID: <200911052147.nA5Ll5PQ004199@zion.cs.uiuc.edu> Author: djg Date: Thu Nov 5 15:47:04 2009 New Revision: 86180 URL: http://llvm.org/viewvc/llvm-project?rev=86180&view=rev Log: LoopDeletion depends on loops having dedicated exits. Modified: llvm/trunk/lib/Transforms/Scalar/LoopDeletion.cpp Modified: llvm/trunk/lib/Transforms/Scalar/LoopDeletion.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopDeletion.cpp?rev=86180&r1=86179&r2=86180&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopDeletion.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopDeletion.cpp Thu Nov 5 15:47:04 2009 @@ -115,6 +115,10 @@ if (!preheader) return false; + // If LoopSimplify form is not available, stay out of trouble. + if (!L->hasDedicatedExits()) + return false; + // We can't remove loops that contain subloops. If the subloops were dead, // they would already have been removed in earlier executions of this pass. if (L->begin() != L->end()) From gohman at apple.com Thu Nov 5 15:48:32 2009 From: gohman at apple.com (Dan Gohman) Date: Thu, 05 Nov 2009 21:48:32 -0000 Subject: [llvm-commits] [llvm] r86181 - /llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp Message-ID: <200911052148.nA5LmWkj004274@zion.cs.uiuc.edu> Author: djg Date: Thu Nov 5 15:48:32 2009 New Revision: 86181 URL: http://llvm.org/viewvc/llvm-project?rev=86181&view=rev Log: Avoid calling getUniqueExitBlocks from within LoopSimplify, as it depends on loops having dedicated exits, which LoopSimplify can no longer always guarantee. Modified: llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp Modified: llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp?rev=86181&r1=86180&r2=86181&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp Thu Nov 5 15:48:32 2009 @@ -241,7 +241,14 @@ // loop-invariant instructions out of the way to open up more // opportunities, and the disadvantage of having the responsibility // to preserve dominator information. - if (ExitBlocks.size() > 1 && L->getUniqueExitBlock()) { + bool UniqueExit = true; + if (!ExitBlocks.empty()) + for (unsigned i = 1, e = ExitBlocks.size(); i != e; ++i) + if (ExitBlocks[i] != ExitBlocks[0]) { + UniqueExit = false; + break; + } + if (UniqueExit) { SmallVector ExitingBlocks; L->getExitingBlocks(ExitingBlocks); for (unsigned i = 0, e = ExitingBlocks.size(); i != e; ++i) { From lhames at gmail.com Thu Nov 5 16:20:57 2009 From: lhames at gmail.com (Lang Hames) Date: Thu, 05 Nov 2009 22:20:57 -0000 Subject: [llvm-commits] [llvm] r86184 - /llvm/trunk/lib/CodeGen/SlotIndexes.cpp Message-ID: <200911052220.nA5MKvBI005349@zion.cs.uiuc.edu> Author: lhames Date: Thu Nov 5 16:20:57 2009 New Revision: 86184 URL: http://llvm.org/viewvc/llvm-project?rev=86184&view=rev Log: Added support for renumbering existing index list elements. Removed some junk from the initial numbering code in runOnMachineFunction. Modified: llvm/trunk/lib/CodeGen/SlotIndexes.cpp Modified: llvm/trunk/lib/CodeGen/SlotIndexes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SlotIndexes.cpp?rev=86184&r1=86183&r2=86184&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SlotIndexes.cpp (original) +++ llvm/trunk/lib/CodeGen/SlotIndexes.cpp Thu Nov 5 16:20:57 2009 @@ -51,8 +51,6 @@ mf = &fn; initList(); - const unsigned gap = 1; - // Check that the list contains only the sentinal. assert(indexListHead->getNext() == 0 && "Index list non-empty at initial numbering?"); @@ -64,14 +62,6 @@ "MachineInstr -> Index mapping non-empty at initial numbering?"); functionSize = 0; - /* - for (unsigned s = 0; s < SlotIndex::NUM; ++s) { - indexList.push_back(createEntry(0, s)); - } - - unsigned index = gap * SlotIndex::NUM; - */ - unsigned index = 0; // Iterate over the the function. @@ -83,7 +73,7 @@ push_back(createEntry(0, index)); SlotIndex blockStartIndex(back(), SlotIndex::LOAD); - index += gap * SlotIndex::NUM; + index += SlotIndex::NUM; for (MachineBasicBlock::iterator miItr = mbb->begin(), miEnd = mbb->end(); miItr != miEnd; ++miItr) { @@ -93,7 +83,7 @@ push_back(createEntry(0, index)); terminatorGaps.insert( std::make_pair(mbb, SlotIndex(back(), SlotIndex::PHI_BIT))); - index += gap * SlotIndex::NUM; + index += SlotIndex::NUM; } // Insert a store index for the instr. @@ -109,14 +99,14 @@ if (Slots == 0) Slots = 1; - index += (Slots + 1) * gap * SlotIndex::NUM; + index += (Slots + 1) * SlotIndex::NUM; } if (mbb->getFirstTerminator() == mbb->end()) { push_back(createEntry(0, index)); terminatorGaps.insert( std::make_pair(mbb, SlotIndex(back(), SlotIndex::PHI_BIT))); - index += gap * SlotIndex::NUM; + index += SlotIndex::NUM; } SlotIndex blockEndIndex(back(), SlotIndex::STORE); @@ -139,20 +129,36 @@ } void SlotIndexes::renumber() { - assert(false && "SlotIndexes::runmuber is not fully implemented yet."); - // Compute numbering as follows: - // Grab an iterator to the start of the index list. - // Iterate over all MBBs, and within each MBB all MIs, keeping the MI - // iterator in lock-step (though skipping it over indexes which have - // null pointers in the instruction field). - // At each iteration assert that the instruction pointed to in the index - // is the same one pointed to by the MI iterator. This + // Renumber updates the index of every element of the index list. + // If all instrs in the function have been allocated an index (which has been + // placed in the index list in the order of instruction iteration) then the + // resulting numbering will match what would have been generated by the + // pass during the initial numbering of the function if the new instructions + // had been present. + + functionSize = 0; + unsigned index = 0; + + for (IndexListEntry *curEntry = front(); curEntry != getTail(); + curEntry = curEntry->getNext()) { - // FIXME: This can be simplified. The mi2iMap_, Idx2MBBMap, etc. should - // only need to be set up once - when the first numbering is computed. + curEntry->setIndex(index); - assert(false && "Renumbering not supported yet."); + if (curEntry->getInstr() == 0) { + // MBB start entry or terminator gap. Just step index by 1. + index += SlotIndex::NUM; + } + else { + ++functionSize; + unsigned Slots = curEntry->getInstr()->getDesc().getNumDefs(); + if (Slots == 0) + Slots = 1; + + index += (Slots + 1) * SlotIndex::NUM; + + } + } } void SlotIndexes::dump() const { From dgregor at apple.com Thu Nov 5 16:58:04 2009 From: dgregor at apple.com (Douglas Gregor) Date: Thu, 05 Nov 2009 22:58:04 -0000 Subject: [llvm-commits] [llvm] r86185 - /llvm/trunk/utils/lit/TestFormats.py Message-ID: <200911052258.nA5Mw4FT006699@zion.cs.uiuc.edu> Author: dgregor Date: Thu Nov 5 16:58:04 2009 New Revision: 86185 URL: http://llvm.org/viewvc/llvm-project?rev=86185&view=rev Log: Teach lit's SyntaxCheckTest two new tricks: - skip .svn directories - add a set of excluded filenames so we can easily skip tests Modified: llvm/trunk/utils/lit/TestFormats.py Modified: llvm/trunk/utils/lit/TestFormats.py URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/TestFormats.py?rev=86185&r1=86184&r2=86185&view=diff ============================================================================== --- llvm/trunk/utils/lit/TestFormats.py (original) +++ llvm/trunk/utils/lit/TestFormats.py Thu Nov 5 16:58:04 2009 @@ -103,11 +103,13 @@ # FIXME: Refactor into generic test for running some command on a directory # of inputs. - def __init__(self, compiler, dir, recursive, pattern, extra_cxx_args=[]): + def __init__(self, compiler, dir, recursive, pattern, excludes=[], + extra_cxx_args=[]): self.compiler = str(compiler) self.dir = str(dir) self.recursive = bool(recursive) self.pattern = re.compile(pattern) + self.excludes = list(excludes) self.extra_cxx_args = list(extra_cxx_args) def getTestsInDirectory(self, testSuite, path_in_suite, @@ -116,10 +118,23 @@ if not self.recursive: subdirs[:] = [] + if dirname.__contains__('.svn'): + continue + for filename in filenames: if (not self.pattern.match(filename) or filename in localConfig.excludes): continue + + # Skip any files that were specifically excluded. + excluded = False + for exclude in self.excludes: + if filename.__contains__(exclude): + excluded = True + break + + if excluded: + continue path = os.path.join(dirname,filename) suffix = path[len(self.dir):] From dgregor at apple.com Thu Nov 5 17:01:30 2009 From: dgregor at apple.com (Douglas Gregor) Date: Thu, 05 Nov 2009 23:01:30 -0000 Subject: [llvm-commits] [llvm] r86186 - in /llvm/trunk/include/llvm: ADT/ImmutableMap.h ADT/ImmutableSet.h ADT/PriorityQueue.h ADT/Trie.h CodeGen/BinaryObject.h CodeGen/LinkAllAsmWriterComponents.h CodeGen/MachORelocation.h CodeGen/MachineCodeInfo.h CodeGen/MachineMemOperand.h Transforms/RSProfiling.h Transforms/Utils/SSI.h Message-ID: <200911052301.nA5N1UWm006818@zion.cs.uiuc.edu> Author: dgregor Date: Thu Nov 5 17:01:30 2009 New Revision: 86186 URL: http://llvm.org/viewvc/llvm-project?rev=86186&view=rev Log: Make a few more LLVM headers parsable as standalone headers. Fix some problems with the hidden copy constructors for ImmutableMap/ImmutableSet found by Clang++. Modified: llvm/trunk/include/llvm/ADT/ImmutableMap.h llvm/trunk/include/llvm/ADT/ImmutableSet.h llvm/trunk/include/llvm/ADT/PriorityQueue.h llvm/trunk/include/llvm/ADT/Trie.h llvm/trunk/include/llvm/CodeGen/BinaryObject.h llvm/trunk/include/llvm/CodeGen/LinkAllAsmWriterComponents.h llvm/trunk/include/llvm/CodeGen/MachORelocation.h llvm/trunk/include/llvm/CodeGen/MachineCodeInfo.h llvm/trunk/include/llvm/CodeGen/MachineMemOperand.h llvm/trunk/include/llvm/Transforms/RSProfiling.h llvm/trunk/include/llvm/Transforms/Utils/SSI.h Modified: llvm/trunk/include/llvm/ADT/ImmutableMap.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/ImmutableMap.h?rev=86186&r1=86185&r2=86186&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/ImmutableMap.h (original) +++ llvm/trunk/include/llvm/ADT/ImmutableMap.h Thu Nov 5 17:01:30 2009 @@ -102,8 +102,8 @@ } private: - Factory(const Factory& RHS) {}; - void operator=(const Factory& RHS) {}; + Factory(const Factory& RHS); // DO NOT IMPLEMENT + void operator=(const Factory& RHS); // DO NOT IMPLEMENT }; friend class Factory; Modified: llvm/trunk/include/llvm/ADT/ImmutableSet.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/ImmutableSet.h?rev=86186&r1=86185&r2=86186&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/ImmutableSet.h (original) +++ llvm/trunk/include/llvm/ADT/ImmutableSet.h Thu Nov 5 17:01:30 2009 @@ -988,8 +988,8 @@ BumpPtrAllocator& getAllocator() { return F.getAllocator(); } private: - Factory(const Factory& RHS) {} - void operator=(const Factory& RHS) {} + Factory(const Factory& RHS); // DO NOT IMPLEMENT + void operator=(const Factory& RHS); // DO NOT IMPLEMENT }; friend class Factory; Modified: llvm/trunk/include/llvm/ADT/PriorityQueue.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/PriorityQueue.h?rev=86186&r1=86185&r2=86186&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/PriorityQueue.h (original) +++ llvm/trunk/include/llvm/ADT/PriorityQueue.h Thu Nov 5 17:01:30 2009 @@ -14,6 +14,7 @@ #ifndef LLVM_ADT_PRIORITY_QUEUE_H #define LLVM_ADT_PRIORITY_QUEUE_H +#include #include namespace llvm { Modified: llvm/trunk/include/llvm/ADT/Trie.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/Trie.h?rev=86186&r1=86185&r2=86186&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/Trie.h (original) +++ llvm/trunk/include/llvm/ADT/Trie.h Thu Nov 5 17:01:30 2009 @@ -18,6 +18,7 @@ #include "llvm/ADT/GraphTraits.h" #include "llvm/Support/DOTGraphTraits.h" +#include #include namespace llvm { Modified: llvm/trunk/include/llvm/CodeGen/BinaryObject.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/BinaryObject.h?rev=86186&r1=86185&r2=86186&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/BinaryObject.h (original) +++ llvm/trunk/include/llvm/CodeGen/BinaryObject.h Thu Nov 5 17:01:30 2009 @@ -15,6 +15,7 @@ #ifndef LLVM_CODEGEN_BINARYOBJECT_H #define LLVM_CODEGEN_BINARYOBJECT_H +#include "llvm/CodeGen/MachineRelocation.h" #include "llvm/System/DataTypes.h" #include @@ -22,7 +23,6 @@ namespace llvm { -class MachineRelocation; typedef std::vector BinaryData; class BinaryObject { Modified: llvm/trunk/include/llvm/CodeGen/LinkAllAsmWriterComponents.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LinkAllAsmWriterComponents.h?rev=86186&r1=86185&r2=86186&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/LinkAllAsmWriterComponents.h (original) +++ llvm/trunk/include/llvm/CodeGen/LinkAllAsmWriterComponents.h Thu Nov 5 17:01:30 2009 @@ -16,6 +16,7 @@ #define LLVM_CODEGEN_LINKALLASMWRITERCOMPONENTS_H #include "llvm/CodeGen/GCs.h" +#include namespace { struct ForceAsmWriterLinking { Modified: llvm/trunk/include/llvm/CodeGen/MachORelocation.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachORelocation.h?rev=86186&r1=86185&r2=86186&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachORelocation.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachORelocation.h Thu Nov 5 17:01:30 2009 @@ -15,6 +15,8 @@ #ifndef LLVM_CODEGEN_MACHO_RELOCATION_H #define LLVM_CODEGEN_MACHO_RELOCATION_H +#include "llvm/System/DataTypes.h" + namespace llvm { /// MachORelocation - This struct contains information about each relocation Modified: llvm/trunk/include/llvm/CodeGen/MachineCodeInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineCodeInfo.h?rev=86186&r1=86185&r2=86186&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineCodeInfo.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineCodeInfo.h Thu Nov 5 17:01:30 2009 @@ -17,6 +17,8 @@ #ifndef EE_MACHINE_CODE_INFO_H #define EE_MACHINE_CODE_INFO_H +#include "llvm/System/DataTypes.h" + namespace llvm { class MachineCodeInfo { Modified: llvm/trunk/include/llvm/CodeGen/MachineMemOperand.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineMemOperand.h?rev=86186&r1=86185&r2=86186&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineMemOperand.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineMemOperand.h Thu Nov 5 17:01:30 2009 @@ -16,6 +16,8 @@ #ifndef LLVM_CODEGEN_MACHINEMEMOPERAND_H #define LLVM_CODEGEN_MACHINEMEMOPERAND_H +#include "llvm/System/DataTypes.h" + namespace llvm { class Value; Modified: llvm/trunk/include/llvm/Transforms/RSProfiling.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/RSProfiling.h?rev=86186&r1=86185&r2=86186&view=diff ============================================================================== --- llvm/trunk/include/llvm/Transforms/RSProfiling.h (original) +++ llvm/trunk/include/llvm/Transforms/RSProfiling.h Thu Nov 5 17:01:30 2009 @@ -15,7 +15,11 @@ #ifndef LLVM_TRANSFORMS_RSPROFILING_H #define LLVM_TRANSFORMS_RSPROFILING_H +#include "llvm/Pass.h" + namespace llvm { + class Value; + //===--------------------------------------------------------------------===// /// RSProfilers - The basic Random Sampling Profiler Interface Any profiler /// that implements this interface can be transformed by the random sampling Modified: llvm/trunk/include/llvm/Transforms/Utils/SSI.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/SSI.h?rev=86186&r1=86185&r2=86186&view=diff ============================================================================== --- llvm/trunk/include/llvm/Transforms/Utils/SSI.h (original) +++ llvm/trunk/include/llvm/Transforms/Utils/SSI.h Thu Nov 5 17:01:30 2009 @@ -22,6 +22,7 @@ #ifndef LLVM_TRANSFORMS_UTILS_SSI_H #define LLVM_TRANSFORMS_UTILS_SSI_H +#include "llvm/InstrTypes.h" #include "llvm/Pass.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallPtrSet.h" From gohman at apple.com Thu Nov 5 17:14:35 2009 From: gohman at apple.com (Dan Gohman) Date: Thu, 05 Nov 2009 23:14:35 -0000 Subject: [llvm-commits] [llvm] r86189 - /llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Message-ID: <200911052314.nA5NEZ1N007223@zion.cs.uiuc.edu> Author: djg Date: Thu Nov 5 17:14:35 2009 New Revision: 86189 URL: http://llvm.org/viewvc/llvm-project?rev=86189&view=rev Log: Fix the label name generation for address-taken labels to avoid potential problems with name collisions. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=86189&r1=86188&r2=86189&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Thu Nov 5 17:14:35 2009 @@ -1636,13 +1636,17 @@ assert(BB->hasName() && "Address of anonymous basic block not supported yet!"); - // FIXME: This isn't guaranteed to produce a unique name even if the - // block and function have a name. - std::string Mangled = - Mang->getMangledName(F, Mang->makeNameProper(BB->getName()).c_str(), - /*ForcePrivate=*/true); + // This code must use the function name itself, and not the function number, + // since it must be possible to generate the label name from within other + // functions. + std::string FuncName = Mang->getMangledName(F); - return OutContext.GetOrCreateSymbol(StringRef(Mangled)); + SmallString<60> Name; + raw_svector_ostream(Name) << MAI->getPrivateGlobalPrefix() << "BA" + << FuncName.size() << '_' << FuncName << '_' + << Mang->makeNameProper(BB->getName()); + + return OutContext.GetOrCreateSymbol(Name.str()); } MCSymbol *AsmPrinter::GetMBBSymbol(unsigned MBBID) const { From gohman at apple.com Thu Nov 5 17:31:40 2009 From: gohman at apple.com (Dan Gohman) Date: Thu, 05 Nov 2009 23:31:40 -0000 Subject: [llvm-commits] [llvm] r86192 - in /llvm/trunk/test/CodeGen: ARM/indirectbr.ll PowerPC/indirectbr.ll Message-ID: <200911052331.nA5NVen3007773@zion.cs.uiuc.edu> Author: djg Date: Thu Nov 5 17:31:40 2009 New Revision: 86192 URL: http://llvm.org/viewvc/llvm-project?rev=86192&view=rev Log: Update these tests for the new label names. Modified: llvm/trunk/test/CodeGen/ARM/indirectbr.ll llvm/trunk/test/CodeGen/PowerPC/indirectbr.ll Modified: llvm/trunk/test/CodeGen/ARM/indirectbr.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/indirectbr.ll?rev=86192&r1=86191&r2=86192&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/indirectbr.ll (original) +++ llvm/trunk/test/CodeGen/ARM/indirectbr.ll Thu Nov 5 17:31:40 2009 @@ -55,6 +55,6 @@ store i8* blockaddress(@foo, %L5), i8** @nextaddr, align 4 ret i32 %res.3 } -; ARM: .long L_foo_L5-(LPC{{.*}}+8) -; THUMB: .long L_foo_L5-(LPC{{.*}}+4) -; THUMB2: .long L_foo_L5 +; ARM: .long LBA4__foo__L5-(LPC{{.*}}+8) +; THUMB: .long LBA4__foo__L5-(LPC{{.*}}+4) +; THUMB2: .long LBA4__foo__L5 Modified: llvm/trunk/test/CodeGen/PowerPC/indirectbr.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/indirectbr.ll?rev=86192&r1=86191&r2=86192&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/PowerPC/indirectbr.ll (original) +++ llvm/trunk/test/CodeGen/PowerPC/indirectbr.ll Thu Nov 5 17:31:40 2009 @@ -43,12 +43,12 @@ L1: ; preds = %L2, %bb2 %res.3 = phi i32 [ %phitmp, %L2 ], [ 2, %bb2 ] ; [#uses=1] -; PIC: addis r4, r2, ha16(L_foo_L5-"L1$pb") -; PIC: li r5, lo16(L_foo_L5-"L1$pb") +; PIC: addis r4, r2, ha16(LBA4__foo__L5-"L1$pb") +; PIC: li r5, lo16(LBA4__foo__L5-"L1$pb") ; PIC: add r4, r4, r5 ; PIC: stw r4 -; STATIC: li r2, lo16(L_foo_L5) -; STATIC: addis r2, r2, ha16(L_foo_L5) +; STATIC: li r2, lo16(LBA4__foo__L5) +; STATIC: addis r2, r2, ha16(LBA4__foo__L5) ; STATIC: stw r2 store i8* blockaddress(@foo, %L5), i8** @nextaddr, align 4 ret i32 %res.3 From gohman at apple.com Thu Nov 5 17:34:59 2009 From: gohman at apple.com (Dan Gohman) Date: Thu, 05 Nov 2009 23:34:59 -0000 Subject: [llvm-commits] [llvm] r86193 - /llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Message-ID: <200911052334.nA5NYxxN007885@zion.cs.uiuc.edu> Author: djg Date: Thu Nov 5 17:34:59 2009 New Revision: 86193 URL: http://llvm.org/viewvc/llvm-project?rev=86193&view=rev Log: Teach LSR to avoid calling SplitCriticalEdge on edges with indirectbr. Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=86193&r1=86192&r2=86193&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Thu Nov 5 17:34:59 2009 @@ -490,6 +490,7 @@ // is the canonical backedge for this loop, as this can make some // inserted code be in an illegal position. if (e != 1 && PHIPred->getTerminator()->getNumSuccessors() > 1 && + !isa(PHIPred->getTerminator()) && (PN->getParent() != L->getHeader() || !L->contains(PHIPred))) { // First step, split the critical edge. From gohman at apple.com Thu Nov 5 17:53:09 2009 From: gohman at apple.com (Dan Gohman) Date: Thu, 05 Nov 2009 23:53:09 -0000 Subject: [llvm-commits] [llvm] r86196 - /llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp Message-ID: <200911052353.nA5Nr9MR008482@zion.cs.uiuc.edu> Author: djg Date: Thu Nov 5 17:53:08 2009 New Revision: 86196 URL: http://llvm.org/viewvc/llvm-project?rev=86196&view=rev Log: Use SUBREG_TO_REG instead of INSERT_SUBREG to model x86-64's implicit zero-extend. Modified: llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp Modified: llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp?rev=86196&r1=86195&r2=86196&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp Thu Nov 5 17:53:08 2009 @@ -1949,14 +1949,12 @@ 0); // We just did a 32-bit clear, insert it into a 64-bit register to // clear the whole 64-bit reg. - SDValue Undef = - SDValue(CurDAG->getMachineNode(TargetInstrInfo::IMPLICIT_DEF, - dl, MVT::i64), 0); + SDValue Zero = CurDAG->getTargetConstant(0, MVT::i64); SDValue SubRegNo = CurDAG->getTargetConstant(X86::SUBREG_32BIT, MVT::i32); ClrNode = - SDValue(CurDAG->getMachineNode(TargetInstrInfo::INSERT_SUBREG, dl, - MVT::i64, Undef, ClrNode, SubRegNo), + SDValue(CurDAG->getMachineNode(TargetInstrInfo::SUBREG_TO_REG, dl, + MVT::i64, Zero, ClrNode, SubRegNo), 0); } else { ClrNode = SDValue(CurDAG->getMachineNode(ClrOpcode, dl, NVT), 0); From deeppatel1987 at gmail.com Thu Nov 5 17:55:46 2009 From: deeppatel1987 at gmail.com (Sandeep Patel) Date: Thu, 5 Nov 2009 23:55:46 +0000 Subject: [llvm-commits] [PATCH] fix comm directive alignment Message-ID: <305d6f60911051555gf844415g87a68d583fee3063@mail.gmail.com> On ELF, the .align directive may be in log2(n) when the .comm directive takes bytes for alignment. deep -------------- next part -------------- A non-text attachment was scrubbed... Name: deep-llvm-comm-align.diff Type: application/octet-stream Size: 4141 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091105/2957196b/attachment.obj From deeppatel1987 at gmail.com Thu Nov 5 17:59:48 2009 From: deeppatel1987 at gmail.com (Sandeep Patel) Date: Thu, 5 Nov 2009 23:59:48 +0000 Subject: [llvm-commits] [PATCH] Debug args and features Message-ID: <305d6f60911051559k690f5cas7653aefbdfa81f21@mail.gmail.com> The attached debug code prints out the command line args the backend has processed and the features string. deep -------------- next part -------------- A non-text attachment was scrubbed... Name: deep-llvm-debug-args-features.diff Type: application/octet-stream Size: 1804 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091105/5ba20936/attachment.obj From gohman at apple.com Thu Nov 5 18:04:06 2009 From: gohman at apple.com (Dan Gohman) Date: Fri, 06 Nov 2009 00:04:06 -0000 Subject: [llvm-commits] [llvm] r86198 - /llvm/trunk/include/llvm/CodeGen/AsmPrinter.h Message-ID: <200911060004.nA6046NF008910@zion.cs.uiuc.edu> Author: djg Date: Thu Nov 5 18:04:05 2009 New Revision: 86198 URL: http://llvm.org/viewvc/llvm-project?rev=86198&view=rev Log: Make printImplicitDef and printKill non-virtual, since they don't need to be overridden. Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/AsmPrinter.h?rev=86198&r1=86197&r2=86198&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/AsmPrinter.h (original) +++ llvm/trunk/include/llvm/CodeGen/AsmPrinter.h Thu Nov 5 18:04:05 2009 @@ -373,10 +373,10 @@ /// printImplicitDef - This method prints the specified machine instruction /// that is an implicit def. - virtual void printImplicitDef(const MachineInstr *MI) const; + void printImplicitDef(const MachineInstr *MI) const; /// printKill - This method prints the specified kill machine instruction. - virtual void printKill(const MachineInstr *MI) const; + void printKill(const MachineInstr *MI) const; /// printPICJumpTableSetLabel - This method prints a set label for the /// specified MachineBasicBlock for a jumptable entry. From gohman at apple.com Thu Nov 5 18:04:54 2009 From: gohman at apple.com (Dan Gohman) Date: Fri, 06 Nov 2009 00:04:54 -0000 Subject: [llvm-commits] [llvm] r86199 - in /llvm/trunk/lib: CodeGen/AsmPrinter/AsmPrinter.cpp Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp Target/X86/AsmPrinter/X86MCInstLower.cpp Message-ID: <200911060004.nA604sml008956@zion.cs.uiuc.edu> Author: djg Date: Thu Nov 5 18:04:54 2009 New Revision: 86199 URL: http://llvm.org/viewvc/llvm-project?rev=86199&view=rev Log: Factor out the printing of the leading tab into printInlineAsm. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=86199&r1=86198&r2=86199&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Thu Nov 5 18:04:54 2009 @@ -1399,6 +1399,8 @@ // Disassemble the AsmStr, printing out the literal pieces, the operands, etc. const char *AsmStr = MI->getOperand(NumDefs).getSymbolName(); + O << '\t'; + // If this asmstr is empty, just print the #APP/#NOAPP markers. // These are useful to see where empty asm's wound up. if (AsmStr[0] == 0) { 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=86199&r1=86198&r2=86199&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Thu Nov 5 18:04:54 2009 @@ -1349,7 +1349,6 @@ printKill(MI); return; case TargetInstrInfo::INLINEASM: - O << '\t'; printInlineAsm(MI); return; case TargetInstrInfo::IMPLICIT_DEF: Modified: llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp?rev=86199&r1=86198&r2=86199&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp Thu Nov 5 18:04:54 2009 @@ -309,7 +309,6 @@ printKill(MI); return; case TargetInstrInfo::INLINEASM: - O << '\t'; printInlineAsm(MI); return; case TargetInstrInfo::IMPLICIT_DEF: Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp?rev=86199&r1=86198&r2=86199&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp Thu Nov 5 18:04:54 2009 @@ -405,7 +405,6 @@ printLabel(MI); return; case TargetInstrInfo::INLINEASM: - O << '\t'; printInlineAsm(MI); return; case TargetInstrInfo::IMPLICIT_DEF: From echristo at apple.com Thu Nov 5 18:11:57 2009 From: echristo at apple.com (Eric Christopher) Date: Fri, 06 Nov 2009 00:11:57 -0000 Subject: [llvm-commits] [llvm] r86203 - in /llvm/trunk: include/llvm/IntrinsicsX86.td test/CodeGen/X86/2006-04-04-CrossBlockCrash.ll test/CodeGen/X86/2006-05-01-SchedCausingSpills.ll test/CodeGen/X86/2007-05-17-ShuffleISelBug.ll test/CodeGen/X86/vec_zero-2.ll Message-ID: <200911060011.nA60BwL9009214@zion.cs.uiuc.edu> Author: echristo Date: Thu Nov 5 18:11:57 2009 New Revision: 86203 URL: http://llvm.org/viewvc/llvm-project?rev=86203&view=rev Log: Fix PR5315, original patch by Nicolas Capens! Modified: llvm/trunk/include/llvm/IntrinsicsX86.td llvm/trunk/test/CodeGen/X86/2006-04-04-CrossBlockCrash.ll llvm/trunk/test/CodeGen/X86/2006-05-01-SchedCausingSpills.ll llvm/trunk/test/CodeGen/X86/2007-05-17-ShuffleISelBug.ll llvm/trunk/test/CodeGen/X86/vec_zero-2.ll Modified: llvm/trunk/include/llvm/IntrinsicsX86.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IntrinsicsX86.td?rev=86203&r1=86202&r2=86203&view=diff ============================================================================== --- llvm/trunk/include/llvm/IntrinsicsX86.td (original) +++ llvm/trunk/include/llvm/IntrinsicsX86.td Thu Nov 5 18:11:57 2009 @@ -484,13 +484,13 @@ // Misc. let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". def int_x86_sse2_packsswb_128 : GCCBuiltin<"__builtin_ia32_packsswb128">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, + Intrinsic<[llvm_v16i8_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; def int_x86_sse2_packssdw_128 : GCCBuiltin<"__builtin_ia32_packssdw128">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, + Intrinsic<[llvm_v8i16_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; def int_x86_sse2_packuswb_128 : GCCBuiltin<"__builtin_ia32_packuswb128">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, + Intrinsic<[llvm_v16i8_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; def int_x86_sse2_movmsk_pd : GCCBuiltin<"__builtin_ia32_movmskpd">, Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty], [IntrNoMem]>; Modified: llvm/trunk/test/CodeGen/X86/2006-04-04-CrossBlockCrash.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2006-04-04-CrossBlockCrash.ll?rev=86203&r1=86202&r2=86203&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2006-04-04-CrossBlockCrash.ll (original) +++ llvm/trunk/test/CodeGen/X86/2006-04-04-CrossBlockCrash.ll Thu Nov 5 18:11:57 2009 @@ -11,7 +11,7 @@ declare <4 x float> @llvm.x86.sse.cmp.ps(<4 x float>, <4 x float>, i8) -declare <4 x i32> @llvm.x86.sse2.packssdw.128(<4 x i32>, <4 x i32>) +declare <8 x i16> @llvm.x86.sse2.packssdw.128(<4 x i32>, <4 x i32>) declare i32 @llvm.x86.sse2.pmovmskb.128(<16 x i8>) @@ -33,8 +33,8 @@ %tmp337 = bitcast <4 x i32> %tmp336 to <4 x float> ; <<4 x float>> [#uses=1] %tmp378 = tail call <4 x float> @llvm.x86.sse.cmp.ps( <4 x float> %tmp337, <4 x float> zeroinitializer, i8 1 ) ; <<4 x float>> [#uses=1] %tmp379 = bitcast <4 x float> %tmp378 to <4 x i32> ; <<4 x i32>> [#uses=1] - %tmp388 = tail call <4 x i32> @llvm.x86.sse2.packssdw.128( <4 x i32> zeroinitializer, <4 x i32> %tmp379 ) ; <<4 x i32>> [#uses=1] - %tmp392 = bitcast <4 x i32> %tmp388 to <8 x i16> ; <<8 x i16>> [#uses=1] + %tmp388 = tail call <8 x i16> @llvm.x86.sse2.packssdw.128( <4 x i32> zeroinitializer, <4 x i32> %tmp379 ) ; <<4 x i32>> [#uses=1] + %tmp392 = bitcast <8 x i16> %tmp388 to <8 x i16> ; <<8 x i16>> [#uses=1] %tmp399 = extractelement <8 x i16> %tmp392, i32 7 ; [#uses=1] %tmp423 = insertelement <8 x i16> zeroinitializer, i16 %tmp399, i32 7 ; <<8 x i16>> [#uses=1] %tmp427 = bitcast <8 x i16> %tmp423 to <16 x i8> ; <<16 x i8>> [#uses=1] Modified: llvm/trunk/test/CodeGen/X86/2006-05-01-SchedCausingSpills.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2006-05-01-SchedCausingSpills.ll?rev=86203&r1=86202&r2=86203&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2006-05-01-SchedCausingSpills.ll (original) +++ llvm/trunk/test/CodeGen/X86/2006-05-01-SchedCausingSpills.ll Thu Nov 5 18:11:57 2009 @@ -17,8 +17,8 @@ %tmp75 = bitcast <4 x float> %tmp74 to <4 x i32> ; <<4 x i32>> [#uses=1] %tmp88 = tail call <4 x float> @llvm.x86.sse.cmp.ps( <4 x float> %tmp44, <4 x float> %tmp61, i8 1 ) ; <<4 x float>> [#uses=1] %tmp89 = bitcast <4 x float> %tmp88 to <4 x i32> ; <<4 x i32>> [#uses=1] - %tmp98 = tail call <4 x i32> @llvm.x86.sse2.packssdw.128( <4 x i32> %tmp75, <4 x i32> %tmp89 ) ; <<4 x i32>> [#uses=1] - %tmp102 = bitcast <4 x i32> %tmp98 to <8 x i16> ; <<8 x i16>> [#uses=1] + %tmp98 = tail call <8 x i16> @llvm.x86.sse2.packssdw.128( <4 x i32> %tmp75, <4 x i32> %tmp89 ) ; <<4 x i32>> [#uses=1] + %tmp102 = bitcast <8 x i16> %tmp98 to <8 x i16> ; <<8 x i16>> [#uses=1] %tmp.upgrd.1 = shufflevector <8 x i16> %tmp102, <8 x i16> undef, <8 x i32> < i32 0, i32 1, i32 2, i32 3, i32 6, i32 5, i32 4, i32 7 > ; <<8 x i16>> [#uses=1] %tmp105 = shufflevector <8 x i16> %tmp.upgrd.1, <8 x i16> undef, <8 x i32> < i32 2, i32 1, i32 0, i32 3, i32 4, i32 5, i32 6, i32 7 > ; <<8 x i16>> [#uses=1] %tmp105.upgrd.2 = bitcast <8 x i16> %tmp105 to <4 x float> ; <<4 x float>> [#uses=1] @@ -32,8 +32,8 @@ %tmp134 = bitcast <4 x float> %tmp133 to <4 x i32> ; <<4 x i32>> [#uses=1] %tmp147 = tail call <4 x float> @llvm.x86.sse.cmp.ps( <4 x float> %tmp44, <4 x float> %tmp120, i8 1 ) ; <<4 x float>> [#uses=1] %tmp148 = bitcast <4 x float> %tmp147 to <4 x i32> ; <<4 x i32>> [#uses=1] - %tmp159 = tail call <4 x i32> @llvm.x86.sse2.packssdw.128( <4 x i32> %tmp134, <4 x i32> %tmp148 ) ; <<4 x i32>> [#uses=1] - %tmp163 = bitcast <4 x i32> %tmp159 to <8 x i16> ; <<8 x i16>> [#uses=1] + %tmp159 = tail call <8 x i16> @llvm.x86.sse2.packssdw.128( <4 x i32> %tmp134, <4 x i32> %tmp148 ) ; <<4 x i32>> [#uses=1] + %tmp163 = bitcast <8 x i16> %tmp159 to <8 x i16> ; <<8 x i16>> [#uses=1] %tmp164 = shufflevector <8 x i16> %tmp163, <8 x i16> undef, <8 x i32> < i32 0, i32 1, i32 2, i32 3, i32 6, i32 5, i32 4, i32 7 > ; <<8 x i16>> [#uses=1] %tmp166 = shufflevector <8 x i16> %tmp164, <8 x i16> undef, <8 x i32> < i32 2, i32 1, i32 0, i32 3, i32 4, i32 5, i32 6, i32 7 > ; <<8 x i16>> [#uses=1] %tmp166.upgrd.4 = bitcast <8 x i16> %tmp166 to <4 x float> ; <<4 x float>> [#uses=1] @@ -47,8 +47,8 @@ %tmp195 = bitcast <4 x float> %tmp194 to <4 x i32> ; <<4 x i32>> [#uses=1] %tmp208 = tail call <4 x float> @llvm.x86.sse.cmp.ps( <4 x float> %tmp44, <4 x float> %tmp181, i8 1 ) ; <<4 x float>> [#uses=1] %tmp209 = bitcast <4 x float> %tmp208 to <4 x i32> ; <<4 x i32>> [#uses=1] - %tmp220 = tail call <4 x i32> @llvm.x86.sse2.packssdw.128( <4 x i32> %tmp195, <4 x i32> %tmp209 ) ; <<4 x i32>> [#uses=1] - %tmp224 = bitcast <4 x i32> %tmp220 to <8 x i16> ; <<8 x i16>> [#uses=1] + %tmp220 = tail call <8 x i16> @llvm.x86.sse2.packssdw.128( <4 x i32> %tmp195, <4 x i32> %tmp209 ) ; <<4 x i32>> [#uses=1] + %tmp224 = bitcast <8 x i16> %tmp220 to <8 x i16> ; <<8 x i16>> [#uses=1] %tmp225 = shufflevector <8 x i16> %tmp224, <8 x i16> undef, <8 x i32> < i32 0, i32 1, i32 2, i32 3, i32 6, i32 5, i32 4, i32 7 > ; <<8 x i16>> [#uses=1] %tmp227 = shufflevector <8 x i16> %tmp225, <8 x i16> undef, <8 x i32> < i32 2, i32 1, i32 0, i32 3, i32 4, i32 5, i32 6, i32 7 > ; <<8 x i16>> [#uses=1] %tmp227.upgrd.6 = bitcast <8 x i16> %tmp227 to <4 x float> ; <<4 x float>> [#uses=1] @@ -62,8 +62,8 @@ %tmp256 = bitcast <4 x float> %tmp255 to <4 x i32> ; <<4 x i32>> [#uses=1] %tmp269 = tail call <4 x float> @llvm.x86.sse.cmp.ps( <4 x float> %tmp44, <4 x float> %tmp242, i8 1 ) ; <<4 x float>> [#uses=1] %tmp270 = bitcast <4 x float> %tmp269 to <4 x i32> ; <<4 x i32>> [#uses=1] - %tmp281 = tail call <4 x i32> @llvm.x86.sse2.packssdw.128( <4 x i32> %tmp256, <4 x i32> %tmp270 ) ; <<4 x i32>> [#uses=1] - %tmp285 = bitcast <4 x i32> %tmp281 to <8 x i16> ; <<8 x i16>> [#uses=1] + %tmp281 = tail call <8 x i16> @llvm.x86.sse2.packssdw.128( <4 x i32> %tmp256, <4 x i32> %tmp270 ) ; <<4 x i32>> [#uses=1] + %tmp285 = bitcast <8 x i16> %tmp281 to <8 x i16> ; <<8 x i16>> [#uses=1] %tmp286 = shufflevector <8 x i16> %tmp285, <8 x i16> undef, <8 x i32> < i32 0, i32 1, i32 2, i32 3, i32 6, i32 5, i32 4, i32 7 > ; <<8 x i16>> [#uses=1] %tmp288 = shufflevector <8 x i16> %tmp286, <8 x i16> undef, <8 x i32> < i32 2, i32 1, i32 0, i32 3, i32 4, i32 5, i32 6, i32 7 > ; <<8 x i16>> [#uses=1] %tmp288.upgrd.8 = bitcast <8 x i16> %tmp288 to <4 x float> ; <<4 x float>> [#uses=1] @@ -73,4 +73,4 @@ declare <4 x float> @llvm.x86.sse.cmp.ps(<4 x float>, <4 x float>, i8) -declare <4 x i32> @llvm.x86.sse2.packssdw.128(<4 x i32>, <4 x i32>) +declare <8 x i16> @llvm.x86.sse2.packssdw.128(<4 x i32>, <4 x i32>) Modified: llvm/trunk/test/CodeGen/X86/2007-05-17-ShuffleISelBug.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2007-05-17-ShuffleISelBug.ll?rev=86203&r1=86202&r2=86203&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2007-05-17-ShuffleISelBug.ll (original) +++ llvm/trunk/test/CodeGen/X86/2007-05-17-ShuffleISelBug.ll Thu Nov 5 18:11:57 2009 @@ -1,7 +1,7 @@ ; RUN: llc < %s -march=x86 -mattr=+sse2 ; RUN: llc < %s -march=x86 -mattr=+sse2 | not grep punpckhwd -declare <8 x i16> @llvm.x86.sse2.packuswb.128(<8 x i16>, <8 x i16>) +declare <16 x i8> @llvm.x86.sse2.packuswb.128(<8 x i16>, <8 x i16>) declare <8 x i16> @llvm.x86.sse2.psrl.w(<8 x i16>, <8 x i16>) @@ -13,8 +13,8 @@ %tmp805 = add <4 x i32> %tmp777, zeroinitializer %tmp832 = bitcast <4 x i32> %tmp805 to <8 x i16> %tmp838 = tail call <8 x i16> @llvm.x86.sse2.psrl.w( <8 x i16> %tmp832, <8 x i16> < i16 8, i16 undef, i16 undef, i16 undef, i16 undef, i16 undef, i16 undef, i16 undef > ) - %tmp1020 = tail call <8 x i16> @llvm.x86.sse2.packuswb.128( <8 x i16> zeroinitializer, <8 x i16> %tmp838 ) - %tmp1030 = bitcast <8 x i16> %tmp1020 to <4 x i32> + %tmp1020 = tail call <16 x i8> @llvm.x86.sse2.packuswb.128( <8 x i16> zeroinitializer, <8 x i16> %tmp838 ) + %tmp1030 = bitcast <16 x i8> %tmp1020 to <4 x i32> %tmp1033 = add <4 x i32> zeroinitializer, %tmp1030 %tmp1048 = bitcast <4 x i32> %tmp1033 to <2 x i64> %tmp1049 = or <2 x i64> %tmp1048, zeroinitializer Modified: llvm/trunk/test/CodeGen/X86/vec_zero-2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/vec_zero-2.ll?rev=86203&r1=86202&r2=86203&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/vec_zero-2.ll (original) +++ llvm/trunk/test/CodeGen/X86/vec_zero-2.ll Thu Nov 5 18:11:57 2009 @@ -12,8 +12,8 @@ %tmp5257 = sub <8 x i16> %tmp5256, zeroinitializer ; <<8 x i16>> [#uses=1] %tmp5258 = bitcast <8 x i16> %tmp5257 to <2 x i64> ; <<2 x i64>> [#uses=1] %tmp5265 = bitcast <2 x i64> %tmp5258 to <8 x i16> ; <<8 x i16>> [#uses=1] - %tmp5266 = call <8 x i16> @llvm.x86.sse2.packuswb.128( <8 x i16> %tmp5265, <8 x i16> zeroinitializer ) nounwind readnone ; <<8 x i16>> [#uses=1] - %tmp5267 = bitcast <8 x i16> %tmp5266 to <2 x i64> ; <<2 x i64>> [#uses=1] + %tmp5266 = call <16 x i8> @llvm.x86.sse2.packuswb.128( <8 x i16> %tmp5265, <8 x i16> zeroinitializer ) nounwind readnone ; <<8 x i16>> [#uses=1] + %tmp5267 = bitcast <16 x i8> %tmp5266 to <2 x i64> ; <<2 x i64>> [#uses=1] %tmp5294 = and <2 x i64> zeroinitializer, %tmp5267 ; <<2 x i64>> [#uses=1] br label %bb5310 bb5310: ; preds = %bb4743, %bb1664 @@ -21,4 +21,4 @@ ret i32 0 } -declare <8 x i16> @llvm.x86.sse2.packuswb.128(<8 x i16>, <8 x i16>) nounwind readnone +declare <16 x i8> @llvm.x86.sse2.packuswb.128(<8 x i16>, <8 x i16>) nounwind readnone From dgregor at apple.com Thu Nov 5 18:12:53 2009 From: dgregor at apple.com (Douglas Gregor) Date: Fri, 06 Nov 2009 00:12:53 -0000 Subject: [llvm-commits] [llvm] r86204 - /llvm/trunk/include/llvm/ADT/PointerUnion.h Message-ID: <200911060012.nA60CrAV009278@zion.cs.uiuc.edu> Author: dgregor Date: Thu Nov 5 18:12:53 2009 New Revision: 86204 URL: http://llvm.org/viewvc/llvm-project?rev=86204&view=rev Log: Add a bunch of missing "template" keywords to disambiguate dependent template names. GCC eats this ill-formed code, Clang does not. I already filed PR5404 to improve recovery in this case Modified: llvm/trunk/include/llvm/ADT/PointerUnion.h Modified: llvm/trunk/include/llvm/ADT/PointerUnion.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/PointerUnion.h?rev=86204&r1=86203&r2=86204&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/PointerUnion.h (original) +++ llvm/trunk/include/llvm/ADT/PointerUnion.h Thu Nov 5 18:12:53 2009 @@ -186,8 +186,9 @@ int is() const { // Is it PT1/PT2? if (::llvm::getPointerUnionTypeNum((T*)0) != -1) - return Val.is() && Val.get().is(); - return Val.is(); + return Val.template is() && + Val.template get().template is(); + return Val.template is(); } /// get() - Return the value of the specified pointer type. If the @@ -197,9 +198,9 @@ assert(is() && "Invalid accessor called"); // Is it PT1/PT2? if (::llvm::getPointerUnionTypeNum((T*)0) != -1) - return Val.get().get(); + return Val.template get().template get(); - return Val.get(); + return Val.template get(); } /// dyn_cast() - If the current value is of the specified pointer type, @@ -291,8 +292,10 @@ int is() const { // Is it PT1/PT2? if (::llvm::getPointerUnionTypeNum((T*)0) != -1) - return Val.is() && Val.get().is(); - return Val.is() && Val.get().is(); + return Val.template is() && + Val.template get().template is(); + return Val.template is() && + Val.template get().template is(); } /// get() - Return the value of the specified pointer type. If the @@ -302,9 +305,9 @@ assert(is() && "Invalid accessor called"); // Is it PT1/PT2? if (::llvm::getPointerUnionTypeNum((T*)0) != -1) - return Val.get().get(); + return Val.template get().template get(); - return Val.get().get(); + return Val.template get().template get(); } /// dyn_cast() - If the current value is of the specified pointer type, From vkutuzov at accesssoftek.com Thu Nov 5 18:14:34 2009 From: vkutuzov at accesssoftek.com (Viktor Kutuzov) Date: Thu, 5 Nov 2009 16:14:34 -0800 Subject: [llvm-commits] [PATCH] LTO code generator options Message-ID: <04F6B1512E264B27AEE607542FCDD113@andreic6e7fe55> Hello everyone, Please find the patch attached. This patch continues the #85419 - Fix to pass options from Gold plugin to LTO codegen. It lets user to specify the target triple, cpu and specific platform attribute (features) for LTO code generator. The following options has been added (names match the llc option names): -mtriple - to set the target triple; -mcpu - to set the target cpu; -mattr - to set additional platform-specific features; If speciffied, these options override all implicit settting. I have also added the -preserve option to keep all intermediate files in place for debug and troubleshooting purposes and did a little code cleaning around my changes to comply with the LLVM coding style policy. Best regards, Viktor -------------- next part -------------- A non-text attachment was scrubbed... Name: llvm-lto-codegen-target_override.diff Type: application/octet-stream Size: 27064 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091105/3389af63/attachment.obj From gohman at apple.com Thu Nov 5 18:19:43 2009 From: gohman at apple.com (Dan Gohman) Date: Fri, 06 Nov 2009 00:19:43 -0000 Subject: [llvm-commits] [llvm] r86206 - /llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp Message-ID: <200911060019.nA60JheC009563@zion.cs.uiuc.edu> Author: djg Date: Thu Nov 5 18:19:43 2009 New Revision: 86206 URL: http://llvm.org/viewvc/llvm-project?rev=86206&view=rev Log: Don't print a redundant tab for inline asm, and do use the new printKill. Modified: llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp Modified: llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp?rev=86206&r1=86205&r2=86206&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp Thu Nov 5 18:19:43 2009 @@ -695,7 +695,6 @@ O << "\n#ifndef NO_ASM_WRITER_BOILERPLATE\n"; O << " if (MI->getOpcode() == TargetInstrInfo::INLINEASM) {\n" - << " O << \"\\t\";\n" << " printInlineAsm(MI);\n" << " return;\n" << " } else if (MI->isLabel()) {\n" @@ -705,6 +704,7 @@ << " printImplicitDef(MI);\n" << " return;\n" << " } else if (MI->getOpcode() == TargetInstrInfo::KILL) {\n" + << " printKill(MI);\n" << " return;\n" << " }\n\n"; @@ -786,7 +786,6 @@ O << " return;\n"; } - O << " return;\n"; O << "}\n"; } From dpatel at apple.com Thu Nov 5 19:30:05 2009 From: dpatel at apple.com (Devang Patel) Date: Fri, 06 Nov 2009 01:30:05 -0000 Subject: [llvm-commits] [llvm] r86212 - in /llvm/trunk: lib/CodeGen/AsmPrinter/DwarfDebug.cpp test/DebugInfo/2009-11-05-DeadGlobalVariable.ll Message-ID: <200911060130.nA61U5A1011841@zion.cs.uiuc.edu> Author: dpatel Date: Thu Nov 5 19:30:04 2009 New Revision: 86212 URL: http://llvm.org/viewvc/llvm-project?rev=86212&view=rev Log: Do not try to emit debug info entry for dead global variable. Added: llvm/trunk/test/DebugInfo/2009-11-05-DeadGlobalVariable.ll Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=86212&r1=86211&r2=86212&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Thu Nov 5 19:30:04 2009 @@ -1097,6 +1097,10 @@ /// CreateGlobalVariableDIE - Create new DIE using GV. DIE *DwarfDebug::CreateGlobalVariableDIE(CompileUnit *DW_Unit, const DIGlobalVariable &GV) { + // If the global variable was optmized out then no need to create debug info entry. + if (!GV.getGlobal()) + return NULL; + DIE *GVDie = new DIE(dwarf::DW_TAG_variable); AddString(GVDie, dwarf::DW_AT_name, dwarf::DW_FORM_string, GV.getDisplayName()); @@ -1518,7 +1522,8 @@ DIGlobalVariable GV(N); if (GV.getContext().getNode() == RootScope->getDesc().getNode()) { DIE *ScopedGVDie = CreateGlobalVariableDIE(ModuleCU, GV); - SPDie->AddChild(ScopedGVDie); + if (ScopedGVDie) + SPDie->AddChild(ScopedGVDie); } } } Added: llvm/trunk/test/DebugInfo/2009-11-05-DeadGlobalVariable.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/2009-11-05-DeadGlobalVariable.ll?rev=86212&view=auto ============================================================================== --- llvm/trunk/test/DebugInfo/2009-11-05-DeadGlobalVariable.ll (added) +++ llvm/trunk/test/DebugInfo/2009-11-05-DeadGlobalVariable.ll Thu Nov 5 19:30:04 2009 @@ -0,0 +1,17 @@ +; RUN: llc %s -o /dev/null +; Here variable bar is optimzied away. Do not trip over while trying to generate debug info. + +define i32 @foo() nounwind readnone optsize ssp { +entry: + ret i32 42, !dbg !6 +} + +!llvm.dbg.gv = !{!0} + +!0 = metadata !{i32 458804, i32 0, metadata !1, metadata !"foo.bar", metadata !"foo.bar", metadata !"foo.bar", metadata !2, i32 3, metadata !5, i1 true, i1 true, null}; [DW_TAG_variable ] +!1 = metadata !{i32 458798, i32 0, metadata !2, metadata !"foo", metadata !"foo", metadata !"foo", metadata !2, i32 2, metadata !3, i1 false, i1 true}; [DW_TAG_subprogram ] +!2 = metadata !{i32 458769, i32 0, i32 12, metadata !"st.c", metadata !"/private/tmp", metadata !"clang 1.1", i1 true, i1 true, metadata !"", i32 0}; [DW_TAG_compile_unit ] +!3 = metadata !{i32 458773, metadata !2, metadata !"", null, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !4, i32 0}; [DW_TAG_subroutine_type ] +!4 = metadata !{metadata !5} +!5 = metadata !{i32 458788, metadata !2, metadata !"int", metadata !2, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5}; [DW_TAG_base_type ] +!6 = metadata !{i32 5, i32 1, metadata !1, null} From vhernandez at apple.com Thu Nov 5 19:33:24 2009 From: vhernandez at apple.com (Victor Hernandez) Date: Fri, 06 Nov 2009 01:33:24 -0000 Subject: [llvm-commits] [llvm] r86213 - in /llvm/trunk: examples/BrainF/ include/llvm/ include/llvm/Analysis/ lib/Analysis/ lib/AsmParser/ lib/Bitcode/Reader/ lib/Transforms/IPO/ lib/VMCore/ test/Analysis/PointerTracking/ test/Transforms/GlobalOpt/ Message-ID: <200911060133.nA61XPMn011991@zion.cs.uiuc.edu> Author: hernande Date: Thu Nov 5 19:33:24 2009 New Revision: 86213 URL: http://llvm.org/viewvc/llvm-project?rev=86213&view=rev Log: Revert r86077 because it caused crashes in 179.art and 175.vpr on ARM Modified: llvm/trunk/examples/BrainF/BrainF.cpp llvm/trunk/include/llvm/Analysis/MemoryBuiltins.h llvm/trunk/include/llvm/Instructions.h llvm/trunk/lib/Analysis/MemoryBuiltins.cpp llvm/trunk/lib/AsmParser/LLParser.cpp llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp llvm/trunk/lib/VMCore/Core.cpp llvm/trunk/lib/VMCore/Instructions.cpp llvm/trunk/test/Analysis/PointerTracking/sizes.ll llvm/trunk/test/Transforms/GlobalOpt/2009-06-01-RecursivePHI.ll llvm/trunk/test/Transforms/GlobalOpt/heap-sra-1.ll llvm/trunk/test/Transforms/GlobalOpt/heap-sra-2.ll llvm/trunk/test/Transforms/GlobalOpt/heap-sra-3.ll llvm/trunk/test/Transforms/GlobalOpt/heap-sra-4.ll llvm/trunk/test/Transforms/GlobalOpt/heap-sra-phi.ll llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-1.ll llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-2.ll llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-3.ll Modified: llvm/trunk/examples/BrainF/BrainF.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/BrainF/BrainF.cpp?rev=86213&r1=86212&r2=86213&view=diff ============================================================================== --- llvm/trunk/examples/BrainF/BrainF.cpp (original) +++ llvm/trunk/examples/BrainF/BrainF.cpp Thu Nov 5 19:33:24 2009 @@ -81,11 +81,8 @@ ConstantInt *val_mem = ConstantInt::get(C, APInt(32, memtotal)); BasicBlock* BB = builder->GetInsertBlock(); const Type* IntPtrTy = IntegerType::getInt32Ty(C); - const Type* Int8Ty = IntegerType::getInt8Ty(C); - Constant* allocsize = ConstantExpr::getSizeOf(Int8Ty); - allocsize = ConstantExpr::getTruncOrBitCast(allocsize, IntPtrTy); - ptr_arr = CallInst::CreateMalloc(BB, IntPtrTy, Int8Ty, allocsize, val_mem, - NULL, "arr"); + ptr_arr = CallInst::CreateMalloc(BB, IntPtrTy, IntegerType::getInt8Ty(C), + val_mem, NULL, "arr"); BB->getInstList().push_back(cast(ptr_arr)); //call void @llvm.memset.i32(i8 *%arr, i8 0, i32 %d, i32 1) Modified: llvm/trunk/include/llvm/Analysis/MemoryBuiltins.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/MemoryBuiltins.h?rev=86213&r1=86212&r2=86213&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/MemoryBuiltins.h (original) +++ llvm/trunk/include/llvm/Analysis/MemoryBuiltins.h Thu Nov 5 19:33:24 2009 @@ -50,17 +50,13 @@ const TargetData* TD); /// getMallocType - Returns the PointerType resulting from the malloc call. -/// The PointerType depends on the number of bitcast uses of the malloc call: -/// 0: PointerType is the malloc calls' return type. -/// 1: PointerType is the bitcast's result type. -/// >1: Unique PointerType cannot be determined, return NULL. +/// This PointerType is the result type of the call's only bitcast use. +/// If there is no unique bitcast use, then return NULL. const PointerType* getMallocType(const CallInst* CI); -/// getMallocAllocatedType - Returns the Type allocated by malloc call. -/// The Type depends on the number of bitcast uses of the malloc call: -/// 0: PointerType is the malloc calls' return type. -/// 1: PointerType is the bitcast's result type. -/// >1: Unique PointerType cannot be determined, return NULL. +/// getMallocAllocatedType - Returns the Type allocated by malloc call. This +/// Type is the result type of the call's only bitcast use. If there is no +/// unique bitcast use, then return NULL. const Type* getMallocAllocatedType(const CallInst* CI); /// getMallocArraySize - Returns the array size of a malloc call. If the Modified: llvm/trunk/include/llvm/Instructions.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Instructions.h?rev=86213&r1=86212&r2=86213&view=diff ============================================================================== --- llvm/trunk/include/llvm/Instructions.h (original) +++ llvm/trunk/include/llvm/Instructions.h Thu Nov 5 19:33:24 2009 @@ -899,12 +899,11 @@ /// 3. Bitcast the result of the malloc call to the specified type. static Instruction *CreateMalloc(Instruction *InsertBefore, const Type *IntPtrTy, const Type *AllocTy, - Value *AllocSize, Value *ArraySize = 0, + Value *ArraySize = 0, const Twine &Name = ""); static Instruction *CreateMalloc(BasicBlock *InsertAtEnd, const Type *IntPtrTy, const Type *AllocTy, - Value *AllocSize, Value *ArraySize = 0, - Function* MallocF = 0, + Value *ArraySize = 0, Function* MallocF = 0, const Twine &Name = ""); /// CreateFree - Generate the IR for a call to the builtin free function. static void CreateFree(Value* Source, Instruction *InsertBefore); Modified: llvm/trunk/lib/Analysis/MemoryBuiltins.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryBuiltins.cpp?rev=86213&r1=86212&r2=86213&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/MemoryBuiltins.cpp (original) +++ llvm/trunk/lib/Analysis/MemoryBuiltins.cpp Thu Nov 5 19:33:24 2009 @@ -17,7 +17,6 @@ #include "llvm/Instructions.h" #include "llvm/Module.h" #include "llvm/Analysis/ConstantFolding.h" -#include "llvm/Target/TargetData.h" using namespace llvm; //===----------------------------------------------------------------------===// @@ -97,47 +96,45 @@ if (!CI) return NULL; - // The size of the malloc's result type must be known to determine array size. + // Type must be known to determine array size. const Type *T = getMallocAllocatedType(CI); - if (!T || !T->isSized() || !TD) + if (!T) return NULL; Value *MallocArg = CI->getOperand(1); - const Type *ArgType = MallocArg->getType(); ConstantExpr *CO = dyn_cast(MallocArg); BinaryOperator *BO = dyn_cast(MallocArg); - unsigned ElementSizeInt = TD->getTypeAllocSize(T); - if (const StructType *ST = dyn_cast(T)) - ElementSizeInt = TD->getStructLayout(ST)->getSizeInBytes(); - Constant *ElementSize = ConstantInt::get(ArgType, ElementSizeInt); + Constant *ElementSize = ConstantExpr::getSizeOf(T); + ElementSize = ConstantExpr::getTruncOrBitCast(ElementSize, + MallocArg->getType()); + Constant *FoldedElementSize = + ConstantFoldConstantExpression(cast(ElementSize), Context, TD); // First, check if CI is a non-array malloc. - if (CO && CO == ElementSize) + if (CO && ((CO == ElementSize) || + (FoldedElementSize && (CO == FoldedElementSize)))) // Match CreateMalloc's use of constant 1 array-size for non-array mallocs. - return ConstantInt::get(ArgType, 1); + return ConstantInt::get(MallocArg->getType(), 1); // Second, check if CI is an array malloc whose array size can be determined. - if (isConstantOne(ElementSize)) + if (isConstantOne(ElementSize) || + (FoldedElementSize && isConstantOne(FoldedElementSize))) return MallocArg; - if (ConstantInt *CInt = dyn_cast(MallocArg)) - if (CInt->getZExtValue() % ElementSizeInt == 0) - return ConstantInt::get(ArgType, CInt->getZExtValue() / ElementSizeInt); - if (!CO && !BO) return NULL; Value *Op0 = NULL; Value *Op1 = NULL; unsigned Opcode = 0; - if (CO && ((CO->getOpcode() == Instruction::Mul) || + if (CO && ((CO->getOpcode() == Instruction::Mul) || (CO->getOpcode() == Instruction::Shl))) { Op0 = CO->getOperand(0); Op1 = CO->getOperand(1); Opcode = CO->getOpcode(); } - if (BO && ((BO->getOpcode() == Instruction::Mul) || + if (BO && ((BO->getOpcode() == Instruction::Mul) || (BO->getOpcode() == Instruction::Shl))) { Op0 = BO->getOperand(0); Op1 = BO->getOperand(1); @@ -147,10 +144,12 @@ // Determine array size if malloc's argument is the product of a mul or shl. if (Op0) { if (Opcode == Instruction::Mul) { - if (Op1 == ElementSize) + if ((Op1 == ElementSize) || + (FoldedElementSize && (Op1 == FoldedElementSize))) // ArraySize * ElementSize return Op0; - if (Op0 == ElementSize) + if ((Op0 == ElementSize) || + (FoldedElementSize && (Op0 == FoldedElementSize))) // ElementSize * ArraySize return Op1; } @@ -162,10 +161,11 @@ uint64_t BitToSet = Op1Int.getLimitedValue(Op1Int.getBitWidth() - 1); Value *Op1Pow = ConstantInt::get(Context, APInt(Op1Int.getBitWidth(), 0).set(BitToSet)); - if (Op0 == ElementSize) + if (Op0 == ElementSize || (FoldedElementSize && Op0 == FoldedElementSize)) // ArraySize << log2(ElementSize) return Op1Pow; - if (Op1Pow == ElementSize) + if (Op1Pow == ElementSize || + (FoldedElementSize && Op1Pow == FoldedElementSize)) // ElementSize << log2(ArraySize) return Op0; } @@ -205,41 +205,35 @@ } /// getMallocType - Returns the PointerType resulting from the malloc call. -/// The PointerType depends on the number of bitcast uses of the malloc call: -/// 0: PointerType is the calls' return type. -/// 1: PointerType is the bitcast's result type. -/// >1: Unique PointerType cannot be determined, return NULL. +/// This PointerType is the result type of the call's only bitcast use. +/// If there is no unique bitcast use, then return NULL. const PointerType *llvm::getMallocType(const CallInst *CI) { assert(isMalloc(CI) && "GetMallocType and not malloc call"); - const PointerType *MallocType = NULL; - unsigned NumOfBitCastUses = 0; - + const BitCastInst *BCI = NULL; + // Determine if CallInst has a bitcast use. for (Value::use_const_iterator UI = CI->use_begin(), E = CI->use_end(); UI != E; ) - if (const BitCastInst *BCI = dyn_cast(*UI++)) { - MallocType = cast(BCI->getDestTy()); - NumOfBitCastUses++; - } + if ((BCI = dyn_cast(cast(*UI++)))) + break; - // Malloc call has 1 bitcast use, so type is the bitcast's destination type. - if (NumOfBitCastUses == 1) - return MallocType; + // Malloc call has 1 bitcast use and no other uses, so type is the bitcast's + // destination type. + if (BCI && CI->hasOneUse()) + return cast(BCI->getDestTy()); // Malloc call was not bitcast, so type is the malloc function's return type. - if (NumOfBitCastUses == 0) + if (!BCI) return cast(CI->getType()); // Type could not be determined. return NULL; } -/// getMallocAllocatedType - Returns the Type allocated by malloc call. -/// The Type depends on the number of bitcast uses of the malloc call: -/// 0: PointerType is the malloc calls' return type. -/// 1: PointerType is the bitcast's result type. -/// >1: Unique PointerType cannot be determined, return NULL. +/// getMallocAllocatedType - Returns the Type allocated by malloc call. This +/// Type is the result type of the call's only bitcast use. If there is no +/// unique bitcast use, then return NULL. const Type *llvm::getMallocAllocatedType(const CallInst *CI) { const PointerType *PT = getMallocType(CI); return PT ? PT->getElementType() : NULL; Modified: llvm/trunk/lib/AsmParser/LLParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=86213&r1=86212&r2=86213&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLParser.cpp (original) +++ llvm/trunk/lib/AsmParser/LLParser.cpp Thu Nov 5 19:33:24 2009 @@ -3619,14 +3619,12 @@ // Autoupgrade old malloc instruction to malloc call. // FIXME: Remove in LLVM 3.0. const Type *IntPtrTy = Type::getInt32Ty(Context); - Constant *AllocSize = ConstantExpr::getSizeOf(Ty); - AllocSize = ConstantExpr::getTruncOrBitCast(AllocSize, IntPtrTy); if (!MallocF) // Prototype malloc as "void *(int32)". // This function is renamed as "malloc" in ValidateEndOfModule(). MallocF = cast( M->getOrInsertFunction("", Type::getInt8PtrTy(Context), IntPtrTy, NULL)); - Inst = CallInst::CreateMalloc(BB, IntPtrTy, Ty, AllocSize, Size, MallocF); + Inst = CallInst::CreateMalloc(BB, IntPtrTy, Ty, Size, MallocF); return false; } Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=86213&r1=86212&r2=86213&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original) +++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Thu Nov 5 19:33:24 2009 @@ -2101,10 +2101,8 @@ if (!Ty || !Size) return Error("Invalid MALLOC record"); if (!CurBB) return Error("Invalid malloc instruction with no BB"); const Type *Int32Ty = IntegerType::getInt32Ty(CurBB->getContext()); - Constant *AllocSize = ConstantExpr::getSizeOf(Ty->getElementType()); - AllocSize = ConstantExpr::getTruncOrBitCast(AllocSize, Int32Ty); I = CallInst::CreateMalloc(CurBB, Int32Ty, Ty->getElementType(), - AllocSize, Size, NULL); + Size, NULL); InstructionList.push_back(I); break; } Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=86213&r1=86212&r2=86213&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Thu Nov 5 19:33:24 2009 @@ -822,42 +822,32 @@ /// malloc into a global, and any loads of GV as uses of the new global. static GlobalVariable *OptimizeGlobalAddressOfMalloc(GlobalVariable *GV, CallInst *CI, - const Type *AllocTy, + BitCastInst *BCI, Value* NElems, LLVMContext &Context, TargetData* TD) { - DEBUG(errs() << "PROMOTING GLOBAL: " << *GV << " CALL = " << *CI << '\n'); + DEBUG(errs() << "PROMOTING MALLOC GLOBAL: " << *GV + << " CALL = " << *CI << " BCI = " << *BCI << '\n'); const Type *IntPtrTy = TD->getIntPtrType(Context); - // CI has either 0 or 1 bitcast uses (getMallocType() would otherwise have - // returned NULL and we would not be here). - BitCastInst *BCI = NULL; - for (Value::use_iterator UI = CI->use_begin(), E = CI->use_end(); UI != E; ) - if ((BCI = dyn_cast(cast(*UI++)))) - break; - ConstantInt *NElements = cast(NElems); if (NElements->getZExtValue() != 1) { // If we have an array allocation, transform it to a single element // allocation to make the code below simpler. - Type *NewTy = ArrayType::get(AllocTy, NElements->getZExtValue()); - unsigned TypeSize = TD->getTypeAllocSize(NewTy); - if (const StructType *ST = dyn_cast(NewTy)) - TypeSize = TD->getStructLayout(ST)->getSizeInBytes(); - Instruction *NewCI = CallInst::CreateMalloc(CI, IntPtrTy, NewTy, - ConstantInt::get(IntPtrTy, TypeSize)); + Type *NewTy = ArrayType::get(getMallocAllocatedType(CI), + NElements->getZExtValue()); + Value* NewM = CallInst::CreateMalloc(CI, IntPtrTy, NewTy); + Instruction* NewMI = cast(NewM); Value* Indices[2]; Indices[0] = Indices[1] = Constant::getNullValue(IntPtrTy); - Value *NewGEP = GetElementPtrInst::Create(NewCI, Indices, Indices + 2, - NewCI->getName()+".el0", CI); - Value *Cast = new BitCastInst(NewGEP, CI->getType(), "el0", CI); - if (BCI) BCI->replaceAllUsesWith(NewGEP); - CI->replaceAllUsesWith(Cast); - if (BCI) BCI->eraseFromParent(); + Value *NewGEP = GetElementPtrInst::Create(NewMI, Indices, Indices + 2, + NewMI->getName()+".el0", CI); + BCI->replaceAllUsesWith(NewGEP); + BCI->eraseFromParent(); CI->eraseFromParent(); - BCI = dyn_cast(NewCI); - CI = BCI ? extractMallocCallFromBitCast(BCI) : cast(NewCI); + BCI = cast(NewMI); + CI = extractMallocCallFromBitCast(NewMI); } // Create the new global variable. The contents of the malloc'd memory is @@ -871,9 +861,8 @@ GV, GV->isThreadLocal()); - // Anything that used the malloc or its bitcast now uses the global directly. - if (BCI) BCI->replaceAllUsesWith(NewGV); - CI->replaceAllUsesWith(new BitCastInst(NewGV, CI->getType(), "newgv", CI)); + // Anything that used the malloc now uses the global directly. + BCI->replaceAllUsesWith(NewGV); Constant *RepValue = NewGV; if (NewGV->getType() != GV->getType()->getElementType()) @@ -941,9 +930,9 @@ GV->getParent()->getGlobalList().insert(GV, InitBool); - // Now the GV is dead, nuke it and the malloc (both CI and BCI). + // Now the GV is dead, nuke it and the malloc. GV->eraseFromParent(); - if (BCI) BCI->eraseFromParent(); + BCI->eraseFromParent(); CI->eraseFromParent(); // To further other optimizations, loop over all users of NewGV and try to @@ -1284,10 +1273,13 @@ /// PerformHeapAllocSRoA - CI is an allocation of an array of structures. Break /// it up into multiple allocations of arrays of the fields. -static GlobalVariable *PerformHeapAllocSRoA(GlobalVariable *GV, CallInst *CI, - Value* NElems, LLVMContext &Context, +static GlobalVariable *PerformHeapAllocSRoA(GlobalVariable *GV, + CallInst *CI, BitCastInst* BCI, + Value* NElems, + LLVMContext &Context, TargetData *TD) { - DEBUG(errs() << "SROA HEAP ALLOC: " << *GV << " MALLOC = " << *CI << '\n'); + DEBUG(errs() << "SROA HEAP ALLOC: " << *GV << " MALLOC CALL = " << *CI + << " BITCAST = " << *BCI << '\n'); const Type* MAT = getMallocAllocatedType(CI); const StructType *STy = cast(MAT); @@ -1295,8 +1287,8 @@ // it into GV). If there are other uses, change them to be uses of // the global to simplify later code. This also deletes the store // into GV. - ReplaceUsesOfMallocWithGlobal(CI, GV); - + ReplaceUsesOfMallocWithGlobal(BCI, GV); + // Okay, at this point, there are no users of the malloc. Insert N // new mallocs at the same place as CI, and N globals. std::vector FieldGlobals; @@ -1314,16 +1306,11 @@ GV->isThreadLocal()); FieldGlobals.push_back(NGV); - unsigned TypeSize = TD->getTypeAllocSize(FieldTy); - if (const StructType* ST = dyn_cast(FieldTy)) - TypeSize = TD->getStructLayout(ST)->getSizeInBytes(); - const Type* IntPtrTy = TD->getIntPtrType(Context); - Value *NMI = CallInst::CreateMalloc(CI, IntPtrTy, FieldTy, - ConstantInt::get(IntPtrTy, TypeSize), - NElems, - CI->getName() + ".f" + Twine(FieldNo)); + Value *NMI = CallInst::CreateMalloc(CI, TD->getIntPtrType(Context), + FieldTy, NElems, + BCI->getName() + ".f" + Twine(FieldNo)); FieldMallocs.push_back(NMI); - new StoreInst(NMI, NGV, CI); + new StoreInst(NMI, NGV, BCI); } // The tricky aspect of this transformation is handling the case when malloc @@ -1340,18 +1327,18 @@ // } Value *RunningOr = 0; for (unsigned i = 0, e = FieldMallocs.size(); i != e; ++i) { - Value *Cond = new ICmpInst(CI, ICmpInst::ICMP_EQ, FieldMallocs[i], - Constant::getNullValue(FieldMallocs[i]->getType()), - "isnull"); + Value *Cond = new ICmpInst(BCI, ICmpInst::ICMP_EQ, FieldMallocs[i], + Constant::getNullValue(FieldMallocs[i]->getType()), + "isnull"); if (!RunningOr) RunningOr = Cond; // First seteq else - RunningOr = BinaryOperator::CreateOr(RunningOr, Cond, "tmp", CI); + RunningOr = BinaryOperator::CreateOr(RunningOr, Cond, "tmp", BCI); } // Split the basic block at the old malloc. - BasicBlock *OrigBB = CI->getParent(); - BasicBlock *ContBB = OrigBB->splitBasicBlock(CI, "malloc_cont"); + BasicBlock *OrigBB = BCI->getParent(); + BasicBlock *ContBB = OrigBB->splitBasicBlock(BCI, "malloc_cont"); // Create the block to check the first condition. Put all these blocks at the // end of the function as they are unlikely to be executed. @@ -1387,8 +1374,9 @@ } BranchInst::Create(ContBB, NullPtrBlock); - - // CI is no longer needed, remove it. + + // CI and BCI are no longer needed, remove them. + BCI->eraseFromParent(); CI->eraseFromParent(); /// InsertedScalarizedLoads - As we process loads, if we can't immediately @@ -1475,10 +1463,14 @@ /// cast of malloc. static bool TryToOptimizeStoreOfMallocToGlobal(GlobalVariable *GV, CallInst *CI, - const Type *AllocTy, + BitCastInst *BCI, Module::global_iterator &GVI, TargetData *TD, LLVMContext &Context) { + // If we can't figure out the type being malloced, then we can't optimize. + const Type *AllocTy = getMallocAllocatedType(CI); + assert(AllocTy); + // If this is a malloc of an abstract type, don't touch it. if (!AllocTy->isSized()) return false; @@ -1499,7 +1491,7 @@ // for. { SmallPtrSet PHIs; - if (!ValueIsOnlyUsedLocallyOrStoredToOneGlobal(CI, GV, PHIs)) + if (!ValueIsOnlyUsedLocallyOrStoredToOneGlobal(BCI, GV, PHIs)) return false; } @@ -1507,16 +1499,16 @@ // transform the program to use global memory instead of malloc'd memory. // This eliminates dynamic allocation, avoids an indirection accessing the // data, and exposes the resultant global to further GlobalOpt. + Value *NElems = getMallocArraySize(CI, Context, TD); // We cannot optimize the malloc if we cannot determine malloc array size. - if (Value *NElems = getMallocArraySize(CI, Context, TD)) { + if (NElems) { if (ConstantInt *NElements = dyn_cast(NElems)) // Restrict this transformation to only working on small allocations // (2048 bytes currently), as we don't want to introduce a 16M global or // something. if (TD && NElements->getZExtValue() * TD->getTypeAllocSize(AllocTy) < 2048) { - GVI = OptimizeGlobalAddressOfMalloc(GV, CI, AllocTy, NElems, - Context, TD); + GVI = OptimizeGlobalAddressOfMalloc(GV, CI, BCI, NElems, Context, TD); return true; } @@ -1534,29 +1526,26 @@ // This the structure has an unreasonable number of fields, leave it // alone. if (AllocSTy->getNumElements() <= 16 && AllocSTy->getNumElements() != 0 && - AllGlobalLoadUsesSimpleEnoughForHeapSRA(GV, CI)) { + AllGlobalLoadUsesSimpleEnoughForHeapSRA(GV, BCI)) { // If this is a fixed size array, transform the Malloc to be an alloc of // structs. malloc [100 x struct],1 -> malloc struct, 100 if (const ArrayType *AT = dyn_cast(getMallocAllocatedType(CI))) { - const Type *IntPtrTy = TD->getIntPtrType(Context); - unsigned TypeSize = TD->getStructLayout(AllocSTy)->getSizeInBytes(); - Value *AllocSize = ConstantInt::get(IntPtrTy, TypeSize); - Value *NumElements = ConstantInt::get(IntPtrTy, AT->getNumElements()); - Instruction *Malloc = CallInst::CreateMalloc(CI, IntPtrTy, AllocSTy, - AllocSize, NumElements, - CI->getName()); - Instruction *Cast = new BitCastInst(Malloc, CI->getType(), "tmp", CI); - CI->replaceAllUsesWith(Cast); + Value* NumElements = ConstantInt::get(Type::getInt32Ty(Context), + AT->getNumElements()); + Value* NewMI = CallInst::CreateMalloc(CI, TD->getIntPtrType(Context), + AllocSTy, NumElements, + BCI->getName()); + Value *Cast = new BitCastInst(NewMI, getMallocType(CI), "tmp", CI); + BCI->replaceAllUsesWith(Cast); + BCI->eraseFromParent(); CI->eraseFromParent(); - CI = dyn_cast(Malloc) ? - extractMallocCallFromBitCast(Malloc): - cast(Malloc); + BCI = cast(NewMI); + CI = extractMallocCallFromBitCast(NewMI); } - GVI = PerformHeapAllocSRoA(GV, CI, getMallocArraySize(CI, Context, TD), - Context, TD); + GVI = PerformHeapAllocSRoA(GV, CI, BCI, NElems, Context, TD); return true; } } @@ -1588,10 +1577,15 @@ if (OptimizeAwayTrappingUsesOfLoads(GV, SOVC, Context)) return true; } else if (CallInst *CI = extractMallocCall(StoredOnceVal)) { - const Type* MallocType = getMallocAllocatedType(CI); - if (MallocType && TryToOptimizeStoreOfMallocToGlobal(GV, CI, MallocType, - GVI, TD, Context)) - return true; + if (getMallocAllocatedType(CI)) { + BitCastInst* BCI = NULL; + for (Value::use_iterator UI = CI->use_begin(), E = CI->use_end(); + UI != E; ) + BCI = dyn_cast(cast(*UI++)); + if (BCI && + TryToOptimizeStoreOfMallocToGlobal(GV, CI, BCI, GVI, TD, Context)) + return true; + } } } Modified: llvm/trunk/lib/VMCore/Core.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Core.cpp?rev=86213&r1=86212&r2=86213&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Core.cpp (original) +++ llvm/trunk/lib/VMCore/Core.cpp Thu Nov 5 19:33:24 2009 @@ -1699,24 +1699,18 @@ LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef B, LLVMTypeRef Ty, const char *Name) { - const Type* ITy = Type::getInt32Ty(unwrap(B)->GetInsertBlock()->getContext()); - Constant* AllocSize = ConstantExpr::getSizeOf(unwrap(Ty)); - AllocSize = ConstantExpr::getTruncOrBitCast(AllocSize, ITy); - Instruction* Malloc = CallInst::CreateMalloc(unwrap(B)->GetInsertBlock(), - ITy, unwrap(Ty), AllocSize, - 0, 0, ""); - return wrap(unwrap(B)->Insert(Malloc, Twine(Name))); + const Type* IntPtrT = Type::getInt32Ty(unwrap(B)->GetInsertBlock()->getContext()); + return wrap(unwrap(B)->Insert(CallInst::CreateMalloc( + unwrap(B)->GetInsertBlock(), IntPtrT, unwrap(Ty), 0, 0, ""), + Twine(Name))); } LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Val, const char *Name) { - const Type* ITy = Type::getInt32Ty(unwrap(B)->GetInsertBlock()->getContext()); - Constant* AllocSize = ConstantExpr::getSizeOf(unwrap(Ty)); - AllocSize = ConstantExpr::getTruncOrBitCast(AllocSize, ITy); - Instruction* Malloc = CallInst::CreateMalloc(unwrap(B)->GetInsertBlock(), - ITy, unwrap(Ty), AllocSize, - unwrap(Val), 0, ""); - return wrap(unwrap(B)->Insert(Malloc, Twine(Name))); + const Type* IntPtrT = Type::getInt32Ty(unwrap(B)->GetInsertBlock()->getContext()); + return wrap(unwrap(B)->Insert(CallInst::CreateMalloc( + unwrap(B)->GetInsertBlock(), IntPtrT, unwrap(Ty), unwrap(Val), 0, ""), + Twine(Name))); } LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef B, LLVMTypeRef Ty, Modified: llvm/trunk/lib/VMCore/Instructions.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instructions.cpp?rev=86213&r1=86212&r2=86213&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Instructions.cpp (original) +++ llvm/trunk/lib/VMCore/Instructions.cpp Thu Nov 5 19:33:24 2009 @@ -24,7 +24,6 @@ #include "llvm/Support/CallSite.h" #include "llvm/Support/ConstantRange.h" #include "llvm/Support/MathExtras.h" -#include "llvm/Target/TargetData.h" using namespace llvm; @@ -449,11 +448,22 @@ return isa(val) && cast(val)->isOne(); } +static Value *checkArraySize(Value *Amt, const Type *IntPtrTy) { + if (!Amt) + Amt = ConstantInt::get(IntPtrTy, 1); + else { + assert(!isa(Amt) && + "Passed basic block into malloc size parameter! Use other ctor"); + assert(Amt->getType() == IntPtrTy && + "Malloc array size is not an intptr!"); + } + return Amt; +} + static Instruction *createMalloc(Instruction *InsertBefore, BasicBlock *InsertAtEnd, const Type *IntPtrTy, - const Type *AllocTy, Value *AllocSize, - Value *ArraySize, Function *MallocF, - const Twine &Name) { + const Type *AllocTy, Value *ArraySize, + Function *MallocF, const Twine &NameStr) { assert(((!InsertBefore && InsertAtEnd) || (InsertBefore && !InsertAtEnd)) && "createMalloc needs either InsertBefore or InsertAtEnd"); @@ -461,14 +471,10 @@ // bitcast (i8* malloc(typeSize)) to type* // malloc(type, arraySize) becomes: // bitcast (i8 *malloc(typeSize*arraySize)) to type* - if (!ArraySize) - ArraySize = ConstantInt::get(IntPtrTy, 1); - else if (ArraySize->getType() != IntPtrTy) { - if (InsertBefore) - ArraySize = CastInst::CreateIntegerCast(ArraySize, IntPtrTy, false, "", InsertBefore); - else - ArraySize = CastInst::CreateIntegerCast(ArraySize, IntPtrTy, false, "", InsertAtEnd); - } + Value *AllocSize = ConstantExpr::getSizeOf(AllocTy); + AllocSize = ConstantExpr::getTruncOrBitCast(cast(AllocSize), + IntPtrTy); + ArraySize = checkArraySize(ArraySize, IntPtrTy); if (!IsConstantOne(ArraySize)) { if (IsConstantOne(AllocSize)) { @@ -507,14 +513,14 @@ Result = MCall; if (Result->getType() != AllocPtrType) // Create a cast instruction to convert to the right type... - Result = new BitCastInst(MCall, AllocPtrType, Name, InsertBefore); + Result = new BitCastInst(MCall, AllocPtrType, NameStr, InsertBefore); } else { MCall = CallInst::Create(MallocF, AllocSize, "malloccall"); Result = MCall; if (Result->getType() != AllocPtrType) { InsertAtEnd->getInstList().push_back(MCall); // Create a cast instruction to convert to the right type... - Result = new BitCastInst(MCall, AllocPtrType, Name); + Result = new BitCastInst(MCall, AllocPtrType, NameStr); } } MCall->setTailCall(); @@ -532,9 +538,8 @@ /// 3. Bitcast the result of the malloc call to the specified type. Instruction *CallInst::CreateMalloc(Instruction *InsertBefore, const Type *IntPtrTy, const Type *AllocTy, - Value *AllocSize, Value *ArraySize, - const Twine &Name) { - return createMalloc(InsertBefore, NULL, IntPtrTy, AllocTy, AllocSize, + Value *ArraySize, const Twine &Name) { + return createMalloc(InsertBefore, NULL, IntPtrTy, AllocTy, ArraySize, NULL, Name); } @@ -548,9 +553,9 @@ /// responsibility of the caller. Instruction *CallInst::CreateMalloc(BasicBlock *InsertAtEnd, const Type *IntPtrTy, const Type *AllocTy, - Value *AllocSize, Value *ArraySize, - Function *MallocF, const Twine &Name) { - return createMalloc(NULL, InsertAtEnd, IntPtrTy, AllocTy, AllocSize, + Value *ArraySize, Function* MallocF, + const Twine &Name) { + return createMalloc(NULL, InsertAtEnd, IntPtrTy, AllocTy, ArraySize, MallocF, Name); } Modified: llvm/trunk/test/Analysis/PointerTracking/sizes.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/PointerTracking/sizes.ll?rev=86213&r1=86212&r2=86213&view=diff ============================================================================== --- llvm/trunk/test/Analysis/PointerTracking/sizes.ll (original) +++ llvm/trunk/test/Analysis/PointerTracking/sizes.ll Thu Nov 5 19:33:24 2009 @@ -31,7 +31,6 @@ } declare i32 @bar(i8*) -declare i32 @bar2(i64*) define i32 @foo1(i32 %n) nounwind { entry: @@ -61,16 +60,11 @@ ret i32 %add16 } -define i32 @foo2(i64 %n) nounwind { +define i32 @foo2(i32 %n) nounwind { entry: - %call = tail call i8* @malloc(i64 %n) ; [#uses=1] + %call = malloc i8, i32 %n ; [#uses=1] ; CHECK: %call = ; CHECK: ==> %n elements, %n bytes allocated - %mallocsize = mul i64 %n, 8 ; [#uses=1] - %malloccall = tail call i8* @malloc(i64 %mallocsize) ; [#uses=1] - %call3 = bitcast i8* %malloccall to i64* ; [#uses=1] -; CHECK: %malloccall = -; CHECK: ==> (8 * %n) elements, (8 * %n) bytes allocated %call2 = tail call i8* @calloc(i64 2, i64 4) nounwind ; [#uses=1] ; CHECK: %call2 = ; CHECK: ==> 8 elements, 8 bytes allocated @@ -78,17 +72,13 @@ ; CHECK: %call4 = ; CHECK: ==> 16 elements, 16 bytes allocated %call6 = tail call i32 @bar(i8* %call) nounwind ; [#uses=1] - %call7 = tail call i32 @bar2(i64* %call3) nounwind ; [#uses=1] %call8 = tail call i32 @bar(i8* %call2) nounwind ; [#uses=1] %call10 = tail call i32 @bar(i8* %call4) nounwind ; [#uses=1] - %add = add i32 %call8, %call6 ; [#uses=1] - %add10 = add i32 %add, %call7 ; [#uses=1] - %add11 = add i32 %add10, %call10 ; [#uses=1] + %add = add i32 %call8, %call6 ; [#uses=1] + %add11 = add i32 %add, %call10 ; [#uses=1] ret i32 %add11 } -declare noalias i8* @malloc(i64) nounwind - declare noalias i8* @calloc(i64, i64) nounwind declare noalias i8* @realloc(i8* nocapture, i64) nounwind Modified: llvm/trunk/test/Transforms/GlobalOpt/2009-06-01-RecursivePHI.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/2009-06-01-RecursivePHI.ll?rev=86213&r1=86212&r2=86213&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/2009-06-01-RecursivePHI.ll (original) +++ llvm/trunk/test/Transforms/GlobalOpt/2009-06-01-RecursivePHI.ll Thu Nov 5 19:33:24 2009 @@ -1,5 +1,4 @@ ; RUN: opt < %s -globalopt -target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" %struct.s_annealing_sched = type { i32, float, float, float, float } %struct.s_bb = type { i32, i32, i32, i32 } @@ -97,9 +96,7 @@ unreachable bb1.i38: ; preds = %bb - %mallocsize = mul i64 28, undef ; [#uses=1] - %malloccall = tail call i8* @malloc(i64 %mallocsize) ; [#uses=1] - %0 = bitcast i8* %malloccall to %struct.s_net* ; <%struct.s_net*> [#uses=1] + %0 = malloc %struct.s_net, i32 undef ; <%struct.s_net*> [#uses=1] br i1 undef, label %bb.i1.i39, label %my_malloc.exit2.i bb.i1.i39: ; preds = %bb1.i38 @@ -118,5 +115,3 @@ bb7: ; preds = %bb6.preheader unreachable } - -declare noalias i8* @malloc(i64) Modified: llvm/trunk/test/Transforms/GlobalOpt/heap-sra-1.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/heap-sra-1.ll?rev=86213&r1=86212&r2=86213&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/heap-sra-1.ll (original) +++ llvm/trunk/test/Transforms/GlobalOpt/heap-sra-1.ll Thu Nov 5 19:33:24 2009 @@ -1,22 +1,18 @@ -; RUN: opt < %s -globalopt -S | FileCheck %s -target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" +; RUN: opt < %s -globalopt -S | grep {@X.f0} +; RUN: opt < %s -globalopt -S | grep {@X.f1} +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" +target triple = "i386-apple-darwin7" %struct.foo = type { i32, i32 } @X = internal global %struct.foo* null -; CHECK: @X.f0 -; CHECK: @X.f1 -define void @bar(i64 %Size) nounwind noinline { +define void @bar(i32 %Size) nounwind noinline { entry: - %mallocsize = mul i64 %Size, 8 ; [#uses=1] - %malloccall = tail call i8* @malloc(i64 %mallocsize) ; [#uses=1] - %.sub = bitcast i8* %malloccall to %struct.foo* ; <%struct.foo*> [#uses=1] + %.sub = malloc %struct.foo, i32 %Size store %struct.foo* %.sub, %struct.foo** @X, align 4 ret void } -declare noalias i8* @malloc(i64) - define i32 @baz() nounwind readonly noinline { bb1.thread: %0 = load %struct.foo** @X, align 4 Modified: llvm/trunk/test/Transforms/GlobalOpt/heap-sra-2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/heap-sra-2.ll?rev=86213&r1=86212&r2=86213&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/heap-sra-2.ll (original) +++ llvm/trunk/test/Transforms/GlobalOpt/heap-sra-2.ll Thu Nov 5 19:33:24 2009 @@ -1,22 +1,20 @@ -; RUN: opt < %s -globalopt -S | FileCheck %s -target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" +; RUN: opt < %s -globalopt -S | grep {@X.f0} +; RUN: opt < %s -globalopt -S | grep {@X.f1} +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" +target triple = "i386-apple-darwin7" %struct.foo = type { i32, i32 } @X = internal global %struct.foo* null ; <%struct.foo**> [#uses=2] -; CHECK: @X.f0 -; CHECK: @X.f1 define void @bar(i32 %Size) nounwind noinline { entry: - %malloccall = tail call i8* @malloc(i64 8000000) ; [#uses=1] - %0 = bitcast i8* %malloccall to [1000000 x %struct.foo]* ; <[1000000 x %struct.foo]*> [#uses=1] + %0 = malloc [1000000 x %struct.foo] + ;%.sub = bitcast [1000000 x %struct.foo]* %0 to %struct.foo* %.sub = getelementptr [1000000 x %struct.foo]* %0, i32 0, i32 0 ; <%struct.foo*> [#uses=1] store %struct.foo* %.sub, %struct.foo** @X, align 4 ret void } -declare noalias i8* @malloc(i64) - define i32 @baz() nounwind readonly noinline { bb1.thread: %0 = load %struct.foo** @X, align 4 ; <%struct.foo*> [#uses=1] Modified: llvm/trunk/test/Transforms/GlobalOpt/heap-sra-3.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/heap-sra-3.ll?rev=86213&r1=86212&r2=86213&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/heap-sra-3.ll (original) +++ llvm/trunk/test/Transforms/GlobalOpt/heap-sra-3.ll Thu Nov 5 19:33:24 2009 @@ -1,22 +1,24 @@ ; RUN: opt < %s -globalopt -S | FileCheck %s -target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" + +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" +target triple = "i386-apple-darwin10" %struct.foo = type { i32, i32 } @X = internal global %struct.foo* null ; CHECK: @X.f0 ; CHECK: @X.f1 -define void @bar(i64 %Size) nounwind noinline { +define void @bar(i32 %Size) nounwind noinline { entry: - %mallocsize = mul i64 8, %Size, ; [#uses=1] -; CHECK: mul i64 %Size, 4 - %malloccall = tail call i8* @malloc(i64 %mallocsize) ; [#uses=1] + %mallocsize = mul i32 ptrtoint (%struct.foo* getelementptr (%struct.foo* null, i32 1) to i32), %Size, ; [#uses=1] +; CHECK: mul i32 %Size + %malloccall = tail call i8* @malloc(i32 %mallocsize) ; [#uses=1] %.sub = bitcast i8* %malloccall to %struct.foo* ; <%struct.foo*> [#uses=1] store %struct.foo* %.sub, %struct.foo** @X, align 4 ret void } -declare noalias i8* @malloc(i64) +declare noalias i8* @malloc(i32) define i32 @baz() nounwind readonly noinline { bb1.thread: Modified: llvm/trunk/test/Transforms/GlobalOpt/heap-sra-4.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/heap-sra-4.ll?rev=86213&r1=86212&r2=86213&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/heap-sra-4.ll (original) +++ llvm/trunk/test/Transforms/GlobalOpt/heap-sra-4.ll Thu Nov 5 19:33:24 2009 @@ -1,22 +1,24 @@ ; RUN: opt < %s -globalopt -S | FileCheck %s -target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" + +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" +target triple = "i386-apple-darwin7" %struct.foo = type { i32, i32 } @X = internal global %struct.foo* null ; CHECK: @X.f0 ; CHECK: @X.f1 -define void @bar(i64 %Size) nounwind noinline { +define void @bar(i32 %Size) nounwind noinline { entry: - %mallocsize = shl i64 %Size, 3 ; [#uses=1] - %malloccall = tail call i8* @malloc(i64 %mallocsize) ; [#uses=1] -; CHECK: mul i64 %Size, 4 + %mallocsize = shl i32 ptrtoint (%struct.foo* getelementptr (%struct.foo* null, i32 1) to i32), 9, ; [#uses=1] + %malloccall = tail call i8* @malloc(i32 %mallocsize) ; [#uses=1] +; CHECK: @malloc(i32 mul (i32 512 %.sub = bitcast i8* %malloccall to %struct.foo* ; <%struct.foo*> [#uses=1] store %struct.foo* %.sub, %struct.foo** @X, align 4 ret void } -declare noalias i8* @malloc(i64) +declare noalias i8* @malloc(i32) define i32 @baz() nounwind readonly noinline { bb1.thread: Modified: llvm/trunk/test/Transforms/GlobalOpt/heap-sra-phi.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/heap-sra-phi.ll?rev=86213&r1=86212&r2=86213&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/heap-sra-phi.ll (original) +++ llvm/trunk/test/Transforms/GlobalOpt/heap-sra-phi.ll Thu Nov 5 19:33:24 2009 @@ -1,21 +1,19 @@ ; RUN: opt < %s -globalopt -S | grep {tmp.f1 = phi i32. } ; RUN: opt < %s -globalopt -S | grep {tmp.f0 = phi i32. } -target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" +target triple = "i386-apple-darwin7" %struct.foo = type { i32, i32 } @X = internal global %struct.foo* null ; <%struct.foo**> [#uses=2] define void @bar(i32 %Size) nounwind noinline { entry: - %malloccall = tail call i8* @malloc(i64 8000000) ; [#uses=1] - %tmp = bitcast i8* %malloccall to [1000000 x %struct.foo]* ; <[1000000 x %struct.foo]*> [#uses=1] + %tmp = malloc [1000000 x %struct.foo] ; <[1000000 x %struct.foo]*> [#uses=1] %.sub = getelementptr [1000000 x %struct.foo]* %tmp, i32 0, i32 0 ; <%struct.foo*> [#uses=1] store %struct.foo* %.sub, %struct.foo** @X, align 4 ret void } -declare noalias i8* @malloc(i64) - define i32 @baz() nounwind readonly noinline { bb1.thread: %tmpLD1 = load %struct.foo** @X, align 4 ; <%struct.foo*> [#uses=1] Modified: llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-1.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-1.ll?rev=86213&r1=86212&r2=86213&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-1.ll (original) +++ llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-1.ll Thu Nov 5 19:33:24 2009 @@ -1,24 +1,19 @@ -; RUN: opt < %s -globalopt -S | FileCheck %s +; RUN: opt < %s -globalopt -S | not grep global target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" @G = internal global i32* null ; [#uses=3] -; CHECK-NOT: global define void @init() { - %malloccall = tail call i8* @malloc(i64 4) ; [#uses=1] - %P = bitcast i8* %malloccall to i32* ; [#uses=1] + %P = malloc i32 ; [#uses=1] store i32* %P, i32** @G %GV = load i32** @G ; [#uses=1] store i32 0, i32* %GV ret void } -declare noalias i8* @malloc(i64) - define i32 @get() { %GV = load i32** @G ; [#uses=1] %V = load i32* %GV ; [#uses=1] ret i32 %V -; CHECK: ret i32 0 } Modified: llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-2.ll?rev=86213&r1=86212&r2=86213&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-2.ll (original) +++ llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-2.ll Thu Nov 5 19:33:24 2009 @@ -1,11 +1,11 @@ ; RUN: opt < %s -globalopt -globaldce -S | not grep malloc -target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" +target triple = "i686-apple-darwin8" @G = internal global i32* null ; [#uses=3] define void @init() { - %malloccall = tail call i8* @malloc(i64 mul (i64 100, i64 4)) ; [#uses=1] - %P = bitcast i8* %malloccall to i32* ; [#uses=1] + %P = malloc i32, i32 100 ; [#uses=1] store i32* %P, i32** @G %GV = load i32** @G ; [#uses=1] %GVe = getelementptr i32* %GV, i32 40 ; [#uses=1] @@ -13,8 +13,6 @@ ret void } -declare noalias i8* @malloc(i64) - define i32 @get() { %GV = load i32** @G ; [#uses=1] %GVe = getelementptr i32* %GV, i32 40 ; [#uses=1] Modified: llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-3.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-3.ll?rev=86213&r1=86212&r2=86213&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-3.ll (original) +++ llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-3.ll Thu Nov 5 19:33:24 2009 @@ -1,11 +1,11 @@ ; RUN: opt < %s -globalopt -globaldce -S | not grep malloc -target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" +target triple = "i686-apple-darwin8" @G = internal global i32* null ; [#uses=4] define void @init() { - %malloccall = tail call i8* @malloc(i64 mul (i64 100, i64 4)) ; [#uses=1] - %P = bitcast i8* %malloccall to i32* ; [#uses=1] + %P = malloc i32, i32 100 ; [#uses=1] store i32* %P, i32** @G %GV = load i32** @G ; [#uses=1] %GVe = getelementptr i32* %GV, i32 40 ; [#uses=1] @@ -13,8 +13,6 @@ ret void } -declare noalias i8* @malloc(i64) - define i32 @get() { %GV = load i32** @G ; [#uses=1] %GVe = getelementptr i32* %GV, i32 40 ; [#uses=1] From espindola at google.com Thu Nov 5 20:36:08 2009 From: espindola at google.com (Rafael Espindola) Date: Thu, 5 Nov 2009 21:36:08 -0500 Subject: [llvm-commits] [compiler-rt][patch] Build on linux. Avoid extra _ Message-ID: <38a0d8450911051836o56e6ac7ewf0b67eeb14a3ef36@mail.gmail.com> The attached patch avoids adding an extra _ at the start of a symbol when building an ELF object. The patch also changes the makefile to build a shared library liked with libunwind so that it is a drop-in libgcc replacement. I understand that the makefile is deprecated in favor of cmake, but the patch might at least be an useful reference for someone working on cmake. Cheers, -- Rafael ?vila de Esp?ndola -------------- next part -------------- A non-text attachment was scrubbed... Name: shared.patch Type: text/x-diff Size: 3851 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091105/5900fadb/attachment.bin From deeppatel1987 at gmail.com Thu Nov 5 20:36:57 2009 From: deeppatel1987 at gmail.com (Sandeep Patel) Date: Fri, 6 Nov 2009 02:36:57 +0000 Subject: [llvm-commits] [PATCH] ARM AAPCS-VFP non-POD structure returns Message-ID: <305d6f60911051836i2f47d71kdea7ac2f5748a1dc@mail.gmail.com> The prior changes to pass homogeneous aggregates in registers didn't account for non-POD aggregates that still must be passed via a shadow return. deep -------------- next part -------------- A non-text attachment was scrubbed... Name: deep-gcc-non-pod-returns.diff Type: application/octet-stream Size: 525 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091106/f47fa0e5/attachment.obj From evan.cheng at apple.com Thu Nov 5 20:53:42 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 06 Nov 2009 02:53:42 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r86219 - /llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Message-ID: <200911060253.nA62rgKf014597@zion.cs.uiuc.edu> Author: evancheng Date: Thu Nov 5 20:53:42 2009 New Revision: 86219 URL: http://llvm.org/viewvc/llvm-project?rev=86219&view=rev Log: More code size experimentation shows this is the magical combination: -O3 - 250, -O2 - 200. Remove the C++ hack based on feedback. Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp?rev=86219&r1=86218&r2=86219&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Thu Nov 5 20:53:42 2009 @@ -357,15 +357,7 @@ return 50; if (optimize >= 3) - return 200; - - // gcc mark C++ member functions "inline" and inline them more aggressively. - // We are not going to do that. Up the inline threshold when compiling for - // C++. - StringRef LanguageName = lang_hooks.name; - if (LanguageName == "GNU C++" || LanguageName == "GNU Objective-C++") - return 200; - return 50; + return 250; } void llvm_initialize_backend(void) { From evan.cheng at apple.com Thu Nov 5 20:55:09 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 06 Nov 2009 02:55:09 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r86220 - /llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Message-ID: <200911060255.nA62t951014656@zion.cs.uiuc.edu> Author: evancheng Date: Thu Nov 5 20:55:09 2009 New Revision: 86220 URL: http://llvm.org/viewvc/llvm-project?rev=86220&view=rev Log: Oops. Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp?rev=86220&r1=86219&r2=86220&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Thu Nov 5 20:55:09 2009 @@ -358,6 +358,7 @@ if (optimize >= 3) return 250; + return 200; } void llvm_initialize_backend(void) { From daniel at zuster.org Thu Nov 5 22:11:29 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Fri, 06 Nov 2009 04:11:29 -0000 Subject: [llvm-commits] [llvm] r86226 - /llvm/trunk/utils/NewNightlyTest.pl Message-ID: <200911060411.nA64BT6Q017303@zion.cs.uiuc.edu> Author: ddunbar Date: Thu Nov 5 22:11:29 2009 New Revision: 86226 URL: http://llvm.org/viewvc/llvm-project?rev=86226&view=rev Log: NewNightlyTest: Add -llvmgccdir as alternative to environment variable. Modified: llvm/trunk/utils/NewNightlyTest.pl Modified: llvm/trunk/utils/NewNightlyTest.pl URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/NewNightlyTest.pl?rev=86226&r1=86225&r2=86226&view=diff ============================================================================== --- llvm/trunk/utils/NewNightlyTest.pl (original) +++ llvm/trunk/utils/NewNightlyTest.pl Thu Nov 5 22:11:29 2009 @@ -53,6 +53,7 @@ # building LLVM. # -use-gmake Use gmake instead of the default make command to build # llvm and run tests. +# -llvmgccdir Next argument specifies the llvm-gcc install prefix. # # TESTING OPTIONS: # -notest Do not even attempt to run the test programs. @@ -147,6 +148,14 @@ $PARALLELJOBS = "2"; my $TESTFLAGS=""; +if ($ENV{'LLVMGCCDIR'}) { + $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'}; + $LLVMGCCPATH = $ENV{'LLVMGCCDIR'} . '/bin'; +} +else { + $LLVMGCCPATH = ""; +} + while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) { shift; last if /^--$/; # Stop processing arguments on -- @@ -211,6 +220,10 @@ if (/^-test-cxxflags/) { $TESTFLAGS = "$TESTFLAGS CXXFLAGS=\'$ARGV[0]\'"; shift; next; } if (/^-compileflags/) { $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next; } + if (/^-llvmgccdir/) { $CONFIGUREARGS .= " --with-llvmgccdir=\'$ARGV[0]\'"; + $LLVMGCCPATH = $ARGV[0] . '/bin'; + shift; next;} + if (/^-noexternals$/) { $NOEXTERNALS = 1; next; } if (/^-use-gmake/) { $MAKECMD = "gmake"; shift; next; } if (/^-extraflags/) { $CONFIGUREARGS .= " --with-extra-options=\'$ARGV[0]\'"; shift; next;} @@ -220,14 +233,6 @@ print "Unknown option: $_ : ignoring!\n"; } -if ($ENV{'LLVMGCCDIR'}) { - $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'}; - $LLVMGCCPATH = $ENV{'LLVMGCCDIR'} . '/bin'; -} -else { - $LLVMGCCPATH = ""; -} - if ($CONFIGUREARGS !~ /--disable-jit/) { $CONFIGUREARGS .= " --enable-jit"; } @@ -758,6 +763,8 @@ my $gcc_version = (split '\n', $gcc_version_long)[0]; # Get llvm-gcc target triple. +# +# FIXME: This shouldn't be hardwired to llvm-gcc. my $llvmgcc_version_long = ""; if ($LLVMGCCPATH ne "") { $llvmgcc_version_long = `$LLVMGCCPATH/llvm-gcc -v 2>&1`; From daniel at zuster.org Thu Nov 5 22:12:02 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Fri, 06 Nov 2009 04:12:02 -0000 Subject: [llvm-commits] [llvm] r86227 - /llvm/trunk/utils/NewNightlyTest.pl Message-ID: <200911060412.nA64C2l9017332@zion.cs.uiuc.edu> Author: ddunbar Date: Thu Nov 5 22:12:02 2009 New Revision: 86227 URL: http://llvm.org/viewvc/llvm-project?rev=86227&view=rev Log: NewNightlyTest: Unbreak passing the build directory via a positional argument. Modified: llvm/trunk/utils/NewNightlyTest.pl Modified: llvm/trunk/utils/NewNightlyTest.pl URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/NewNightlyTest.pl?rev=86227&r1=86226&r2=86227&view=diff ============================================================================== --- llvm/trunk/utils/NewNightlyTest.pl (original) +++ llvm/trunk/utils/NewNightlyTest.pl Thu Nov 5 22:12:02 2009 @@ -116,13 +116,6 @@ my $BuildDir = $ENV{'BUILDDIR'}; my $WebDir = $ENV{'WEBDIR'}; -my $LLVMSrcDir = $ENV{'LLVMSRCDIR'}; -$LLVMSrcDir = "$BuildDir/llvm" unless $LLVMSrcDir; -my $LLVMObjDir = $ENV{'LLVMOBJDIR'}; -$LLVMObjDir = "$BuildDir/llvm" unless $LLVMObjDir; -my $LLVMTestDir = $ENV{'LLVMTESTDIR'}; -$LLVMTestDir = "$BuildDir/llvm/projects/llvm-test" unless $LLVMTestDir; - ############################################################## # # Calculate the date prefix... @@ -269,6 +262,13 @@ "\"-nickname \""); } +my $LLVMSrcDir = $ENV{'LLVMSRCDIR'}; +$LLVMSrcDir = "$BuildDir/llvm" unless $LLVMSrcDir; +my $LLVMObjDir = $ENV{'LLVMOBJDIR'}; +$LLVMObjDir = "$BuildDir/llvm" unless $LLVMObjDir; +my $LLVMTestDir = $ENV{'LLVMTESTDIR'}; +$LLVMTestDir = "$BuildDir/llvm/projects/llvm-test" unless $LLVMTestDir; + ############################################################## # # Define the file names we'll use From daniel at zuster.org Thu Nov 5 22:12:08 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Fri, 06 Nov 2009 04:12:08 -0000 Subject: [llvm-commits] [llvm] r86228 - /llvm/trunk/utils/NewNightlyTest.pl Message-ID: <200911060412.nA64C8Ww017367@zion.cs.uiuc.edu> Author: ddunbar Date: Thu Nov 5 22:12:07 2009 New Revision: 86228 URL: http://llvm.org/viewvc/llvm-project?rev=86228&view=rev Log: NewNightlyTest: Add -noclean option, which doesn't run 'make clean' before building LLVM (for testing). Also, switch to always running 'make clean' in the test-suite directories. Modified: llvm/trunk/utils/NewNightlyTest.pl Modified: llvm/trunk/utils/NewNightlyTest.pl URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/NewNightlyTest.pl?rev=86228&r1=86227&r2=86228&view=diff ============================================================================== --- llvm/trunk/utils/NewNightlyTest.pl (original) +++ llvm/trunk/utils/NewNightlyTest.pl Thu Nov 5 22:12:07 2009 @@ -43,6 +43,7 @@ # the source tree. # -noremove Do not remove the BUILDDIR after it has been built. # -noremoveresults Do not remove the WEBDIR after it has been built. +# -noclean Do not run 'make clean' before building. # -nobuild Do not build llvm. If tests are enabled perform them # on the llvm build specified in the build directory # -release Build an LLVM Release version @@ -156,6 +157,7 @@ # List command line options here... if (/^-config$/) { $CONFIG_PATH = "$ARGV[0]"; shift; next; } if (/^-nocheckout$/) { $NOCHECKOUT = 1; next; } + if (/^-noclean$/) { $NOCLEAN = 1; next; } if (/^-noremove$/) { $NOREMOVE = 1; next; } if (/^-noremoveatend$/) { $NOREMOVEATEND = 1; next; } if (/^-noremoveresults$/){ $NOREMOVERESULTS = 1; next; } @@ -528,7 +530,9 @@ RunLoggedCommand("(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) ", $ConfigureLog, "CONFIGURE"); # Build the entire tree, capturing the output into $BuildLog - RunAppendingLoggedCommand("($NICE $MAKECMD $MAKEOPTS clean)", $BuildLog, "BUILD CLEAN"); + if (!$NOCLEAN) { + RunAppendingLoggedCommand("($NICE $MAKECMD $MAKEOPTS clean)", $BuildLog, "BUILD CLEAN"); + } RunAppendingLoggedCommand("(time -p $NICE $MAKECMD $MAKEOPTS)", $BuildLog, "BUILD"); if (`grep '^$MAKECMD\[^:]*: .*Error' $BuildLog | wc -l` + 0 || @@ -562,11 +566,9 @@ my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt"; - # Make sure to clean things if in non-config mode. - if ($ConfigMode == 1) { - RunLoggedCommand("$MAKECMD -k $MAKEOPTS $PROGTESTOPTS clean $TESTFLAGS", - $ProgramTestLog, "TEST DIRECTORY $SubDir"); - } + # Make sure to clean the test results. + RunLoggedCommand("$MAKECMD -k $MAKEOPTS $PROGTESTOPTS clean $TESTFLAGS", + $ProgramTestLog, "TEST DIRECTORY $SubDir"); # Run the programs tests... creating a report.nightly.csv file. my $LLCBetaOpts = ""; From daniel at zuster.org Thu Nov 5 22:12:13 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Fri, 06 Nov 2009 04:12:13 -0000 Subject: [llvm-commits] [llvm] r86229 - /llvm/trunk/utils/NewNightlyTest.pl Message-ID: <200911060412.nA64CEMG017380@zion.cs.uiuc.edu> Author: ddunbar Date: Thu Nov 5 22:12:13 2009 New Revision: 86229 URL: http://llvm.org/viewvc/llvm-project?rev=86229&view=rev Log: NewNighlytTest: Fix timestamp format to actually make sense (it was missing the hour). Modified: llvm/trunk/utils/NewNightlyTest.pl Modified: llvm/trunk/utils/NewNightlyTest.pl URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/NewNightlyTest.pl?rev=86229&r1=86228&r2=86229&view=diff ============================================================================== --- llvm/trunk/utils/NewNightlyTest.pl (original) +++ llvm/trunk/utils/NewNightlyTest.pl Thu Nov 5 22:12:13 2009 @@ -122,8 +122,9 @@ # Calculate the date prefix... # ############################################################## +use POSIX; @TIME = localtime; -my $DATE = sprintf "%4d-%02d-%02d_%02d-%02d", $TIME[5]+1900, $TIME[4]+1, $TIME[3], $TIME[1], $TIME[0]; +my $DATE = strftime("%Y-%m-%d_%H-%M-%S", localtime()); ############################################################## # From clattner at apple.com Thu Nov 5 22:24:16 2009 From: clattner at apple.com (Chris Lattner) Date: Thu, 5 Nov 2009 20:24:16 -0800 Subject: [llvm-commits] [compiler-rt][patch] Build on linux. Avoid extra _ In-Reply-To: <38a0d8450911051836o56e6ac7ewf0b67eeb14a3ef36@mail.gmail.com> References: <38a0d8450911051836o56e6ac7ewf0b67eeb14a3ef36@mail.gmail.com> Message-ID: <30989189-821F-4611-8B04-A2B85F132293@apple.com> On Nov 5, 2009, at 6:36 PM, Rafael Espindola wrote: > The attached patch avoids adding an extra _ at the start of a symbol > when building an ELF object. The patch also changes the makefile to > build a shared library liked with libunwind so that it is a drop-in > libgcc replacement. I understand that the makefile is deprecated in > favor of cmake, but the patch might at least be an useful reference > for someone working on cmake. Hi Rafael, Can this just use the __USER_LABEL_PREFIX__ macro? On darwin it is "_" on linux it is "". You should be able to token paste that onto the start of a symbol. -Chris From sabre at nondot.org Thu Nov 5 22:27:35 2009 From: sabre at nondot.org (Chris Lattner) Date: Fri, 06 Nov 2009 04:27:35 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r86232 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Message-ID: <200911060427.nA64RZMk017833@zion.cs.uiuc.edu> Author: lattner Date: Thu Nov 5 22:27:34 2009 New Revision: 86232 URL: http://llvm.org/viewvc/llvm-project?rev=86232&view=rev Log: match mainline llvm 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=86232&r1=86231&r2=86232&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Thu Nov 5 22:27:34 2009 @@ -8149,8 +8149,7 @@ FieldPtr = TheFolder->CreateGetElementPtr(StructAddrLV, Ops+1, 2); FieldPtr = ConstantFoldInstOperands(Instruction::GetElementPtr, - FieldPtr->getType(), Ops, - 3, Context, &TD); + FieldPtr->getType(), Ops, 3, &TD); // Now that we did an offset from the start of the struct, subtract off // the offset from BitStart. From sabre at nondot.org Thu Nov 5 22:27:33 2009 From: sabre at nondot.org (Chris Lattner) Date: Fri, 06 Nov 2009 04:27:33 -0000 Subject: [llvm-commits] [llvm] r86231 - in /llvm/trunk: include/llvm/ include/llvm/Analysis/ include/llvm/Support/ lib/Analysis/ lib/Transforms/IPO/ lib/Transforms/Scalar/ lib/Transforms/Utils/ lib/VMCore/ Message-ID: <200911060427.nA64Raud017844@zion.cs.uiuc.edu> Author: lattner Date: Thu Nov 5 22:27:31 2009 New Revision: 86231 URL: http://llvm.org/viewvc/llvm-project?rev=86231&view=rev Log: remove a bunch of extraneous LLVMContext arguments from various APIs, addressing PR5325. Modified: llvm/trunk/include/llvm/Analysis/ConstantFolding.h llvm/trunk/include/llvm/Analysis/MemoryBuiltins.h llvm/trunk/include/llvm/GlobalVariable.h llvm/trunk/include/llvm/Support/TargetFolder.h llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp llvm/trunk/lib/Analysis/ConstantFolding.cpp llvm/trunk/lib/Analysis/MemoryBuiltins.cpp llvm/trunk/lib/Analysis/PointerTracking.cpp llvm/trunk/lib/Analysis/ScalarEvolution.cpp llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp llvm/trunk/lib/Transforms/Scalar/ConstantProp.cpp llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp llvm/trunk/lib/Transforms/Scalar/TailDuplication.cpp llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp llvm/trunk/lib/Transforms/Utils/LoopUnroll.cpp llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp llvm/trunk/lib/VMCore/Globals.cpp llvm/trunk/lib/VMCore/Module.cpp Modified: llvm/trunk/include/llvm/Analysis/ConstantFolding.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ConstantFolding.h?rev=86231&r1=86230&r2=86231&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/ConstantFolding.h (original) +++ llvm/trunk/include/llvm/Analysis/ConstantFolding.h Thu Nov 5 22:27:31 2009 @@ -26,20 +26,18 @@ class TargetData; class Function; class Type; - class LLVMContext; /// ConstantFoldInstruction - Attempt to constant fold the specified /// instruction. If successful, the constant result is returned, if not, null /// is returned. Note that this function can only fail when attempting to fold /// instructions like loads and stores, which have no constant expression form. /// -Constant *ConstantFoldInstruction(Instruction *I, LLVMContext &Context, - const TargetData *TD = 0); +Constant *ConstantFoldInstruction(Instruction *I, const TargetData *TD = 0); /// ConstantFoldConstantExpression - Attempt to fold the constant expression /// using the specified TargetData. If successful, the constant result is /// result is returned, if not, null is returned. -Constant *ConstantFoldConstantExpression(ConstantExpr *CE, LLVMContext &Context, +Constant *ConstantFoldConstantExpression(ConstantExpr *CE, const TargetData *TD = 0); /// ConstantFoldInstOperands - Attempt to constant fold an instruction with the @@ -49,8 +47,7 @@ /// form. /// Constant *ConstantFoldInstOperands(unsigned Opcode, const Type *DestTy, - Constant*const * Ops, unsigned NumOps, - LLVMContext &Context, + Constant *const *Ops, unsigned NumOps, const TargetData *TD = 0); /// ConstantFoldCompareInstOperands - Attempt to constant fold a compare @@ -58,8 +55,7 @@ /// returns a constant expression of the specified operands. /// Constant *ConstantFoldCompareInstOperands(unsigned Predicate, - Constant*const * Ops, unsigned NumOps, - LLVMContext &Context, + Constant *const *Ops, unsigned NumOps, const TargetData *TD = 0); /// ConstantFoldLoadFromConstPtr - Return the value that a load from C would @@ -79,7 +75,7 @@ /// ConstantFoldCall - Attempt to constant fold a call to the specified function /// with the specified arguments, returning null if unsuccessful. Constant * -ConstantFoldCall(Function *F, Constant* const* Operands, unsigned NumOperands); +ConstantFoldCall(Function *F, Constant *const *Operands, unsigned NumOperands); } #endif Modified: llvm/trunk/include/llvm/Analysis/MemoryBuiltins.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/MemoryBuiltins.h?rev=86231&r1=86230&r2=86231&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/MemoryBuiltins.h (original) +++ llvm/trunk/include/llvm/Analysis/MemoryBuiltins.h Thu Nov 5 22:27:31 2009 @@ -17,7 +17,6 @@ namespace llvm { class CallInst; -class LLVMContext; class PointerType; class TargetData; class Type; @@ -29,43 +28,42 @@ /// isMalloc - Returns true if the value is either a malloc call or a bitcast of /// the result of a malloc call -bool isMalloc(const Value* I); +bool isMalloc(const Value *I); /// extractMallocCall - Returns the corresponding CallInst if the instruction /// is a malloc call. Since CallInst::CreateMalloc() only creates calls, we /// ignore InvokeInst here. -const CallInst* extractMallocCall(const Value* I); -CallInst* extractMallocCall(Value* I); +const CallInst* extractMallocCall(const Value *I); +CallInst* extractMallocCall(Value *I); /// extractMallocCallFromBitCast - Returns the corresponding CallInst if the /// instruction is a bitcast of the result of a malloc call. -const CallInst* extractMallocCallFromBitCast(const Value* I); -CallInst* extractMallocCallFromBitCast(Value* I); +const CallInst* extractMallocCallFromBitCast(const Value *I); +CallInst* extractMallocCallFromBitCast(Value *I); /// isArrayMalloc - Returns the corresponding CallInst if the instruction /// is a call to malloc whose array size can be determined and the array size /// is not constant 1. Otherwise, return NULL. -CallInst* isArrayMalloc(Value* I, LLVMContext &Context, const TargetData* TD); -const CallInst* isArrayMalloc(const Value* I, LLVMContext &Context, - const TargetData* TD); +CallInst* isArrayMalloc(Value *I, const TargetData *TD); +const CallInst* isArrayMalloc(const Value *I, + const TargetData *TD); /// getMallocType - Returns the PointerType resulting from the malloc call. /// This PointerType is the result type of the call's only bitcast use. /// If there is no unique bitcast use, then return NULL. -const PointerType* getMallocType(const CallInst* CI); +const PointerType* getMallocType(const CallInst *CI); /// getMallocAllocatedType - Returns the Type allocated by malloc call. This /// Type is the result type of the call's only bitcast use. If there is no /// unique bitcast use, then return NULL. -const Type* getMallocAllocatedType(const CallInst* CI); +const Type* getMallocAllocatedType(const CallInst *CI); /// getMallocArraySize - Returns the array size of a malloc call. If the /// argument passed to malloc is a multiple of the size of the malloced type, /// then return that multiple. For non-array mallocs, the multiple is /// constant 1. Otherwise, return NULL for mallocs whose array size cannot be /// determined. -Value* getMallocArraySize(CallInst* CI, LLVMContext &Context, - const TargetData* TD); +Value* getMallocArraySize(CallInst *CI, const TargetData *TD); //===----------------------------------------------------------------------===// // free Call Utility Functions. Modified: llvm/trunk/include/llvm/GlobalVariable.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/GlobalVariable.h?rev=86231&r1=86230&r2=86231&view=diff ============================================================================== --- llvm/trunk/include/llvm/GlobalVariable.h (original) +++ llvm/trunk/include/llvm/GlobalVariable.h Thu Nov 5 22:27:31 2009 @@ -28,7 +28,6 @@ class Module; class Constant; -class LLVMContext; template class SymbolTableListTraits; @@ -50,8 +49,7 @@ } /// GlobalVariable ctor - If a parent module is specified, the global is /// automatically inserted into the end of the specified modules global list. - GlobalVariable(LLVMContext &Context, const Type *Ty, bool isConstant, - LinkageTypes Linkage, + GlobalVariable(const Type *Ty, bool isConstant, LinkageTypes Linkage, Constant *Initializer = 0, const Twine &Name = "", bool ThreadLocal = false, unsigned AddressSpace = 0); /// GlobalVariable ctor - This creates a global and inserts it before the Modified: llvm/trunk/include/llvm/Support/TargetFolder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/TargetFolder.h?rev=86231&r1=86230&r2=86231&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/TargetFolder.h (original) +++ llvm/trunk/include/llvm/Support/TargetFolder.h Thu Nov 5 22:27:31 2009 @@ -26,24 +26,22 @@ namespace llvm { class TargetData; -class LLVMContext; /// TargetFolder - Create constants with target dependent folding. class TargetFolder { const TargetData *TD; - LLVMContext &Context; /// Fold - Fold the constant using target specific information. Constant *Fold(Constant *C) const { if (ConstantExpr *CE = dyn_cast(C)) - if (Constant *CF = ConstantFoldConstantExpression(CE, Context, TD)) + if (Constant *CF = ConstantFoldConstantExpression(CE, TD)) return CF; return C; } public: explicit TargetFolder(const TargetData *TheTD, LLVMContext &C) : - TD(TheTD), Context(C) {} + TD(TheTD) {} //===--------------------------------------------------------------------===// // Binary Operators Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp?rev=86231&r1=86230&r2=86231&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp (original) +++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Thu Nov 5 22:27:31 2009 @@ -23,7 +23,6 @@ #include "llvm/GlobalVariable.h" #include "llvm/Instructions.h" #include "llvm/IntrinsicInst.h" -#include "llvm/LLVMContext.h" #include "llvm/Operator.h" #include "llvm/Pass.h" #include "llvm/Target/TargetData.h" @@ -99,7 +98,7 @@ /// isObjectSmallerThan - Return true if we can prove that the object specified /// by V is smaller than Size. static bool isObjectSmallerThan(const Value *V, unsigned Size, - LLVMContext &Context, const TargetData &TD) { + const TargetData &TD) { const Type *AccessTy; if (const GlobalVariable *GV = dyn_cast(V)) { AccessTy = GV->getType()->getElementType(); @@ -109,7 +108,7 @@ else return false; } else if (const CallInst* CI = extractMallocCall(V)) { - if (!isArrayMalloc(V, Context, &TD)) + if (!isArrayMalloc(V, &TD)) // The size is the argument to the malloc call. if (const ConstantInt* C = dyn_cast(CI->getOperand(1))) return (C->getZExtValue() < Size); @@ -665,10 +664,9 @@ // If the size of one access is larger than the entire object on the other // side, then we know such behavior is undefined and can assume no alias. - LLVMContext &Context = V1->getContext(); if (TD) - if ((V1Size != ~0U && isObjectSmallerThan(O2, V1Size, Context, *TD)) || - (V2Size != ~0U && isObjectSmallerThan(O1, V2Size, Context, *TD))) + if ((V1Size != ~0U && isObjectSmallerThan(O2, V1Size, *TD)) || + (V2Size != ~0U && isObjectSmallerThan(O1, V2Size, *TD))) return NoAlias; // If one pointer is the result of a call/invoke and the other is a @@ -707,16 +705,16 @@ // This function is used to determine if the indices of two GEP instructions are // equal. V1 and V2 are the indices. -static bool IndexOperandsEqual(Value *V1, Value *V2, LLVMContext &Context) { +static bool IndexOperandsEqual(Value *V1, Value *V2) { if (V1->getType() == V2->getType()) return V1 == V2; if (Constant *C1 = dyn_cast(V1)) if (Constant *C2 = dyn_cast(V2)) { // Sign extend the constants to long types, if necessary - if (C1->getType() != Type::getInt64Ty(Context)) - C1 = ConstantExpr::getSExt(C1, Type::getInt64Ty(Context)); - if (C2->getType() != Type::getInt64Ty(Context)) - C2 = ConstantExpr::getSExt(C2, Type::getInt64Ty(Context)); + if (C1->getType() != Type::getInt64Ty(C1->getContext())) + C1 = ConstantExpr::getSExt(C1, Type::getInt64Ty(C1->getContext())); + if (C2->getType() != Type::getInt64Ty(C1->getContext())) + C2 = ConstantExpr::getSExt(C2, Type::getInt64Ty(C1->getContext())); return C1 == C2; } return false; @@ -737,8 +735,6 @@ const PointerType *GEPPointerTy = cast(BasePtr1Ty); - LLVMContext &Context = GEPPointerTy->getContext(); - // Find the (possibly empty) initial sequence of equal values... which are not // necessarily constants. unsigned NumGEP1Operands = NumGEP1Ops, NumGEP2Operands = NumGEP2Ops; @@ -746,8 +742,7 @@ unsigned MaxOperands = std::max(NumGEP1Operands, NumGEP2Operands); unsigned UnequalOper = 0; while (UnequalOper != MinOperands && - IndexOperandsEqual(GEP1Ops[UnequalOper], GEP2Ops[UnequalOper], - Context)) { + IndexOperandsEqual(GEP1Ops[UnequalOper], GEP2Ops[UnequalOper])) { // Advance through the type as we go... ++UnequalOper; if (const CompositeType *CT = dyn_cast(BasePtr1Ty)) @@ -811,10 +806,11 @@ if (Constant *G2OC = dyn_cast(const_cast(G2Oper))){ if (G1OC->getType() != G2OC->getType()) { // Sign extend both operands to long. - if (G1OC->getType() != Type::getInt64Ty(Context)) - G1OC = ConstantExpr::getSExt(G1OC, Type::getInt64Ty(Context)); - if (G2OC->getType() != Type::getInt64Ty(Context)) - G2OC = ConstantExpr::getSExt(G2OC, Type::getInt64Ty(Context)); + const Type *Int64Ty = Type::getInt64Ty(G1OC->getContext()); + if (G1OC->getType() != Int64Ty) + G1OC = ConstantExpr::getSExt(G1OC, Int64Ty); + if (G2OC->getType() != Int64Ty) + G2OC = ConstantExpr::getSExt(G2OC, Int64Ty); GEP1Ops[FirstConstantOper] = G1OC; GEP2Ops[FirstConstantOper] = G2OC; } @@ -950,7 +946,7 @@ for (unsigned i = 0; i != FirstConstantOper; ++i) { if (!isa(ZeroIdxTy)) GEP1Ops[i] = GEP2Ops[i] = - Constant::getNullValue(Type::getInt32Ty(Context)); + Constant::getNullValue(Type::getInt32Ty(ZeroIdxTy->getContext())); if (const CompositeType *CT = dyn_cast(ZeroIdxTy)) ZeroIdxTy = CT->getTypeAtIndex(GEP1Ops[i]); @@ -992,11 +988,11 @@ // if (const ArrayType *AT = dyn_cast(BasePtr1Ty)) GEP1Ops[i] = - ConstantInt::get(Type::getInt64Ty(Context), + ConstantInt::get(Type::getInt64Ty(AT->getContext()), AT->getNumElements()-1); else if (const VectorType *VT = dyn_cast(BasePtr1Ty)) GEP1Ops[i] = - ConstantInt::get(Type::getInt64Ty(Context), + ConstantInt::get(Type::getInt64Ty(VT->getContext()), VT->getNumElements()-1); } } Modified: llvm/trunk/lib/Analysis/ConstantFolding.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ConstantFolding.cpp?rev=86231&r1=86230&r2=86231&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ConstantFolding.cpp (original) +++ llvm/trunk/lib/Analysis/ConstantFolding.cpp Thu Nov 5 22:27:31 2009 @@ -23,7 +23,6 @@ #include "llvm/GlobalVariable.h" #include "llvm/Instructions.h" #include "llvm/Intrinsics.h" -#include "llvm/LLVMContext.h" #include "llvm/Analysis/ValueTracking.h" #include "llvm/Target/TargetData.h" #include "llvm/ADT/SmallVector.h" @@ -493,8 +492,7 @@ /// these together. If target data info is available, it is provided as TD, /// otherwise TD is null. static Constant *SymbolicallyEvaluateBinop(unsigned Opc, Constant *Op0, - Constant *Op1, const TargetData *TD, - LLVMContext &Context){ + Constant *Op1, const TargetData *TD){ // SROA // Fold (and 0xffffffff00000000, (shl x, 32)) -> shl. @@ -521,15 +519,15 @@ /// SymbolicallyEvaluateGEP - If we can symbolically evaluate the specified GEP /// constant expression, do so. -static Constant *SymbolicallyEvaluateGEP(Constant* const* Ops, unsigned NumOps, +static Constant *SymbolicallyEvaluateGEP(Constant *const *Ops, unsigned NumOps, const Type *ResultTy, - LLVMContext &Context, const TargetData *TD) { Constant *Ptr = Ops[0]; if (!TD || !cast(Ptr->getType())->getElementType()->isSized()) return 0; - unsigned BitWidth = TD->getTypeSizeInBits(TD->getIntPtrType(Context)); + unsigned BitWidth = + TD->getTypeSizeInBits(TD->getIntPtrType(Ptr->getContext())); APInt BasePtr(BitWidth, 0); bool BaseIsInt = true; if (!Ptr->isNullValue()) { @@ -558,7 +556,7 @@ // If the base value for this address is a literal integer value, fold the // getelementptr to the resulting integer value casted to the pointer type. if (BaseIsInt) { - Constant *C = ConstantInt::get(Context, Offset+BasePtr); + Constant *C = ConstantInt::get(Ptr->getContext(), Offset+BasePtr); return ConstantExpr::getIntToPtr(C, ResultTy); } @@ -579,7 +577,8 @@ return 0; APInt NewIdx = Offset.udiv(ElemSize); Offset -= NewIdx * ElemSize; - NewIdxs.push_back(ConstantInt::get(TD->getIntPtrType(Context), NewIdx)); + NewIdxs.push_back(ConstantInt::get(TD->getIntPtrType(Ty->getContext()), + NewIdx)); Ty = ATy->getElementType(); } else if (const StructType *STy = dyn_cast(Ty)) { // Determine which field of the struct the offset points into. The @@ -587,7 +586,8 @@ // know the offset is within the struct at this point. const StructLayout &SL = *TD->getStructLayout(STy); unsigned ElIdx = SL.getElementContainingOffset(Offset.getZExtValue()); - NewIdxs.push_back(ConstantInt::get(Type::getInt32Ty(Context), ElIdx)); + NewIdxs.push_back(ConstantInt::get(Type::getInt32Ty(Ty->getContext()), + ElIdx)); Offset -= APInt(BitWidth, SL.getElementOffset(ElIdx)); Ty = STy->getTypeAtIndex(ElIdx); } else { @@ -628,8 +628,7 @@ /// is returned. Note that this function can only fail when attempting to fold /// instructions like loads and stores, which have no constant expression form. /// -Constant *llvm::ConstantFoldInstruction(Instruction *I, LLVMContext &Context, - const TargetData *TD) { +Constant *llvm::ConstantFoldInstruction(Instruction *I, const TargetData *TD) { if (PHINode *PN = dyn_cast(I)) { if (PN->getNumIncomingValues() == 0) return UndefValue::get(PN->getType()); @@ -657,21 +656,19 @@ if (const CmpInst *CI = dyn_cast(I)) return ConstantFoldCompareInstOperands(CI->getPredicate(), - Ops.data(), Ops.size(), - Context, TD); + Ops.data(), Ops.size(), TD); if (const LoadInst *LI = dyn_cast(I)) return ConstantFoldLoadInst(LI, TD); return ConstantFoldInstOperands(I->getOpcode(), I->getType(), - Ops.data(), Ops.size(), Context, TD); + Ops.data(), Ops.size(), TD); } /// ConstantFoldConstantExpression - Attempt to fold the constant expression /// using the specified TargetData. If successful, the constant result is /// result is returned, if not, null is returned. Constant *llvm::ConstantFoldConstantExpression(ConstantExpr *CE, - LLVMContext &Context, const TargetData *TD) { SmallVector Ops; for (User::op_iterator i = CE->op_begin(), e = CE->op_end(); i != e; ++i) @@ -679,10 +676,9 @@ if (CE->isCompare()) return ConstantFoldCompareInstOperands(CE->getPredicate(), - Ops.data(), Ops.size(), - Context, TD); + Ops.data(), Ops.size(), TD); return ConstantFoldInstOperands(CE->getOpcode(), CE->getType(), - Ops.data(), Ops.size(), Context, TD); + Ops.data(), Ops.size(), TD); } /// ConstantFoldInstOperands - Attempt to constant fold an instruction with the @@ -693,13 +689,11 @@ /// Constant *llvm::ConstantFoldInstOperands(unsigned Opcode, const Type *DestTy, Constant* const* Ops, unsigned NumOps, - LLVMContext &Context, const TargetData *TD) { // Handle easy binops first. if (Instruction::isBinaryOp(Opcode)) { if (isa(Ops[0]) || isa(Ops[1])) - if (Constant *C = SymbolicallyEvaluateBinop(Opcode, Ops[0], Ops[1], TD, - Context)) + if (Constant *C = SymbolicallyEvaluateBinop(Opcode, Ops[0], Ops[1], TD)) return C; return ConstantExpr::get(Opcode, Ops[0], Ops[1]); @@ -724,7 +718,7 @@ unsigned InWidth = Input->getType()->getScalarSizeInBits(); if (TD->getPointerSizeInBits() < InWidth) { Constant *Mask = - ConstantInt::get(Context, APInt::getLowBitsSet(InWidth, + ConstantInt::get(CE->getContext(), APInt::getLowBitsSet(InWidth, TD->getPointerSizeInBits())); Input = ConstantExpr::getAnd(Input, Mask); } @@ -766,7 +760,7 @@ AT->getNumElements()))) { Constant *Index[] = { Constant::getNullValue(CE->getType()), - ConstantInt::get(Context, ElemIdx) + ConstantInt::get(ElTy->getContext(), ElemIdx) }; return ConstantExpr::getGetElementPtr(GV, &Index[0], 2); @@ -800,7 +794,7 @@ case Instruction::ShuffleVector: return ConstantExpr::getShuffleVector(Ops[0], Ops[1], Ops[2]); case Instruction::GetElementPtr: - if (Constant *C = SymbolicallyEvaluateGEP(Ops, NumOps, DestTy, Context, TD)) + if (Constant *C = SymbolicallyEvaluateGEP(Ops, NumOps, DestTy, TD)) return C; return ConstantExpr::getGetElementPtr(Ops[0], Ops+1, NumOps-1); @@ -812,9 +806,8 @@ /// returns a constant expression of the specified operands. /// Constant *llvm::ConstantFoldCompareInstOperands(unsigned Predicate, - Constant*const * Ops, + Constant *const *Ops, unsigned NumOps, - LLVMContext &Context, const TargetData *TD) { // fold: icmp (inttoptr x), null -> icmp x, 0 // fold: icmp (ptrtoint x), 0 -> icmp x, null @@ -825,15 +818,14 @@ // around to know if bit truncation is happening. if (ConstantExpr *CE0 = dyn_cast(Ops[0])) { if (TD && Ops[1]->isNullValue()) { - const Type *IntPtrTy = TD->getIntPtrType(Context); + const Type *IntPtrTy = TD->getIntPtrType(CE0->getContext()); if (CE0->getOpcode() == Instruction::IntToPtr) { // Convert the integer value to the right size to ensure we get the // proper extension or truncation. Constant *C = ConstantExpr::getIntegerCast(CE0->getOperand(0), IntPtrTy, false); Constant *NewOps[] = { C, Constant::getNullValue(C->getType()) }; - return ConstantFoldCompareInstOperands(Predicate, NewOps, 2, - Context, TD); + return ConstantFoldCompareInstOperands(Predicate, NewOps, 2, TD); } // Only do this transformation if the int is intptrty in size, otherwise @@ -843,14 +835,13 @@ Constant *C = CE0->getOperand(0); Constant *NewOps[] = { C, Constant::getNullValue(C->getType()) }; // FIXME! - return ConstantFoldCompareInstOperands(Predicate, NewOps, 2, - Context, TD); + return ConstantFoldCompareInstOperands(Predicate, NewOps, 2, TD); } } if (ConstantExpr *CE1 = dyn_cast(Ops[1])) { if (TD && CE0->getOpcode() == CE1->getOpcode()) { - const Type *IntPtrTy = TD->getIntPtrType(Context); + const Type *IntPtrTy = TD->getIntPtrType(CE0->getContext()); if (CE0->getOpcode() == Instruction::IntToPtr) { // Convert the integer value to the right size to ensure we get the @@ -860,8 +851,7 @@ Constant *C1 = ConstantExpr::getIntegerCast(CE1->getOperand(0), IntPtrTy, false); Constant *NewOps[] = { C0, C1 }; - return ConstantFoldCompareInstOperands(Predicate, NewOps, 2, - Context, TD); + return ConstantFoldCompareInstOperands(Predicate, NewOps, 2, TD); } // Only do this transformation if the int is intptrty in size, otherwise @@ -872,8 +862,7 @@ Constant *NewOps[] = { CE0->getOperand(0), CE1->getOperand(0) }; - return ConstantFoldCompareInstOperands(Predicate, NewOps, 2, - Context, TD); + return ConstantFoldCompareInstOperands(Predicate, NewOps, 2, TD); } } } @@ -996,7 +985,7 @@ } static Constant *ConstantFoldFP(double (*NativeFP)(double), double V, - const Type *Ty, LLVMContext &Context) { + const Type *Ty) { errno = 0; V = NativeFP(V); if (errno != 0) { @@ -1005,17 +994,15 @@ } if (Ty->isFloatTy()) - return ConstantFP::get(Context, APFloat((float)V)); + return ConstantFP::get(Ty->getContext(), APFloat((float)V)); if (Ty->isDoubleTy()) - return ConstantFP::get(Context, APFloat(V)); + return ConstantFP::get(Ty->getContext(), APFloat(V)); llvm_unreachable("Can only constant fold float/double"); return 0; // dummy return to suppress warning } static Constant *ConstantFoldBinaryFP(double (*NativeFP)(double, double), - double V, double W, - const Type *Ty, - LLVMContext &Context) { + double V, double W, const Type *Ty) { errno = 0; V = NativeFP(V, W); if (errno != 0) { @@ -1024,9 +1011,9 @@ } if (Ty->isFloatTy()) - return ConstantFP::get(Context, APFloat((float)V)); + return ConstantFP::get(Ty->getContext(), APFloat((float)V)); if (Ty->isDoubleTy()) - return ConstantFP::get(Context, APFloat(V)); + return ConstantFP::get(Ty->getContext(), APFloat(V)); llvm_unreachable("Can only constant fold float/double"); return 0; // dummy return to suppress warning } @@ -1037,7 +1024,6 @@ llvm::ConstantFoldCall(Function *F, Constant *const *Operands, unsigned NumOperands) { if (!F->hasName()) return 0; - LLVMContext &Context = F->getContext(); StringRef Name = F->getName(); const Type *Ty = F->getReturnType(); @@ -1054,62 +1040,62 @@ switch (Name[0]) { case 'a': if (Name == "acos") - return ConstantFoldFP(acos, V, Ty, Context); + return ConstantFoldFP(acos, V, Ty); else if (Name == "asin") - return ConstantFoldFP(asin, V, Ty, Context); + return ConstantFoldFP(asin, V, Ty); else if (Name == "atan") - return ConstantFoldFP(atan, V, Ty, Context); + return ConstantFoldFP(atan, V, Ty); break; case 'c': if (Name == "ceil") - return ConstantFoldFP(ceil, V, Ty, Context); + return ConstantFoldFP(ceil, V, Ty); else if (Name == "cos") - return ConstantFoldFP(cos, V, Ty, Context); + return ConstantFoldFP(cos, V, Ty); else if (Name == "cosh") - return ConstantFoldFP(cosh, V, Ty, Context); + return ConstantFoldFP(cosh, V, Ty); else if (Name == "cosf") - return ConstantFoldFP(cos, V, Ty, Context); + return ConstantFoldFP(cos, V, Ty); break; case 'e': if (Name == "exp") - return ConstantFoldFP(exp, V, Ty, Context); + return ConstantFoldFP(exp, V, Ty); break; case 'f': if (Name == "fabs") - return ConstantFoldFP(fabs, V, Ty, Context); + return ConstantFoldFP(fabs, V, Ty); else if (Name == "floor") - return ConstantFoldFP(floor, V, Ty, Context); + return ConstantFoldFP(floor, V, Ty); break; case 'l': if (Name == "log" && V > 0) - return ConstantFoldFP(log, V, Ty, Context); + return ConstantFoldFP(log, V, Ty); else if (Name == "log10" && V > 0) - return ConstantFoldFP(log10, V, Ty, Context); + return ConstantFoldFP(log10, V, Ty); else if (Name == "llvm.sqrt.f32" || Name == "llvm.sqrt.f64") { if (V >= -0.0) - return ConstantFoldFP(sqrt, V, Ty, Context); + return ConstantFoldFP(sqrt, V, Ty); else // Undefined return Constant::getNullValue(Ty); } break; case 's': if (Name == "sin") - return ConstantFoldFP(sin, V, Ty, Context); + return ConstantFoldFP(sin, V, Ty); else if (Name == "sinh") - return ConstantFoldFP(sinh, V, Ty, Context); + return ConstantFoldFP(sinh, V, Ty); else if (Name == "sqrt" && V >= 0) - return ConstantFoldFP(sqrt, V, Ty, Context); + return ConstantFoldFP(sqrt, V, Ty); else if (Name == "sqrtf" && V >= 0) - return ConstantFoldFP(sqrt, V, Ty, Context); + return ConstantFoldFP(sqrt, V, Ty); else if (Name == "sinf") - return ConstantFoldFP(sin, V, Ty, Context); + return ConstantFoldFP(sin, V, Ty); break; case 't': if (Name == "tan") - return ConstantFoldFP(tan, V, Ty, Context); + return ConstantFoldFP(tan, V, Ty); else if (Name == "tanh") - return ConstantFoldFP(tanh, V, Ty, Context); + return ConstantFoldFP(tanh, V, Ty); break; default: break; @@ -1120,7 +1106,7 @@ if (ConstantInt *Op = dyn_cast(Operands[0])) { if (Name.startswith("llvm.bswap")) - return ConstantInt::get(Context, Op->getValue().byteSwap()); + return ConstantInt::get(F->getContext(), Op->getValue().byteSwap()); else if (Name.startswith("llvm.ctpop")) return ConstantInt::get(Ty, Op->getValue().countPopulation()); else if (Name.startswith("llvm.cttz")) @@ -1149,18 +1135,20 @@ Op2->getValueAPF().convertToDouble(); if (Name == "pow") - return ConstantFoldBinaryFP(pow, Op1V, Op2V, Ty, Context); + return ConstantFoldBinaryFP(pow, Op1V, Op2V, Ty); if (Name == "fmod") - return ConstantFoldBinaryFP(fmod, Op1V, Op2V, Ty, Context); + return ConstantFoldBinaryFP(fmod, Op1V, Op2V, Ty); if (Name == "atan2") - return ConstantFoldBinaryFP(atan2, Op1V, Op2V, Ty, Context); + return ConstantFoldBinaryFP(atan2, Op1V, Op2V, Ty); } else if (ConstantInt *Op2C = dyn_cast(Operands[1])) { if (Name == "llvm.powi.f32") - return ConstantFP::get(Context, APFloat((float)std::pow((float)Op1V, + return ConstantFP::get(F->getContext(), + APFloat((float)std::pow((float)Op1V, (int)Op2C->getZExtValue()))); if (Name == "llvm.powi.f64") - return ConstantFP::get(Context, APFloat((double)std::pow((double)Op1V, - (int)Op2C->getZExtValue()))); + return ConstantFP::get(F->getContext(), + APFloat((double)std::pow((double)Op1V, + (int)Op2C->getZExtValue()))); } return 0; } Modified: llvm/trunk/lib/Analysis/MemoryBuiltins.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryBuiltins.cpp?rev=86231&r1=86230&r2=86231&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/MemoryBuiltins.cpp (original) +++ llvm/trunk/lib/Analysis/MemoryBuiltins.cpp Thu Nov 5 22:27:31 2009 @@ -91,8 +91,7 @@ return isa(val) && cast(val)->isOne(); } -static Value *isArrayMallocHelper(const CallInst *CI, LLVMContext &Context, - const TargetData *TD) { +static Value *isArrayMallocHelper(const CallInst *CI, const TargetData *TD) { if (!CI) return NULL; @@ -109,7 +108,7 @@ ElementSize = ConstantExpr::getTruncOrBitCast(ElementSize, MallocArg->getType()); Constant *FoldedElementSize = - ConstantFoldConstantExpression(cast(ElementSize), Context, TD); + ConstantFoldConstantExpression(cast(ElementSize), TD); // First, check if CI is a non-array malloc. if (CO && ((CO == ElementSize) || @@ -159,7 +158,7 @@ APInt Op1Int = Op1CI->getValue(); uint64_t BitToSet = Op1Int.getLimitedValue(Op1Int.getBitWidth() - 1); - Value *Op1Pow = ConstantInt::get(Context, + Value *Op1Pow = ConstantInt::get(Op1CI->getContext(), APInt(Op1Int.getBitWidth(), 0).set(BitToSet)); if (Op0 == ElementSize || (FoldedElementSize && Op0 == FoldedElementSize)) // ArraySize << log2(ElementSize) @@ -178,10 +177,9 @@ /// isArrayMalloc - Returns the corresponding CallInst if the instruction /// is a call to malloc whose array size can be determined and the array size /// is not constant 1. Otherwise, return NULL. -CallInst *llvm::isArrayMalloc(Value *I, LLVMContext &Context, - const TargetData *TD) { +CallInst *llvm::isArrayMalloc(Value *I, const TargetData *TD) { CallInst *CI = extractMallocCall(I); - Value *ArraySize = isArrayMallocHelper(CI, Context, TD); + Value *ArraySize = isArrayMallocHelper(CI, TD); if (ArraySize && ArraySize != ConstantInt::get(CI->getOperand(1)->getType(), 1)) @@ -191,10 +189,9 @@ return NULL; } -const CallInst *llvm::isArrayMalloc(const Value *I, LLVMContext &Context, - const TargetData *TD) { +const CallInst *llvm::isArrayMalloc(const Value *I, const TargetData *TD) { const CallInst *CI = extractMallocCall(I); - Value *ArraySize = isArrayMallocHelper(CI, Context, TD); + Value *ArraySize = isArrayMallocHelper(CI, TD); if (ArraySize && ArraySize != ConstantInt::get(CI->getOperand(1)->getType(), 1)) @@ -244,9 +241,8 @@ /// then return that multiple. For non-array mallocs, the multiple is /// constant 1. Otherwise, return NULL for mallocs whose array size cannot be /// determined. -Value *llvm::getMallocArraySize(CallInst *CI, LLVMContext &Context, - const TargetData *TD) { - return isArrayMallocHelper(CI, Context, TD); +Value *llvm::getMallocArraySize(CallInst *CI, const TargetData *TD) { + return isArrayMallocHelper(CI, TD); } //===----------------------------------------------------------------------===// Modified: llvm/trunk/lib/Analysis/PointerTracking.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/PointerTracking.cpp?rev=86231&r1=86230&r2=86231&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/PointerTracking.cpp (original) +++ llvm/trunk/lib/Analysis/PointerTracking.cpp Thu Nov 5 22:27:31 2009 @@ -10,6 +10,7 @@ // This file implements tracking of pointer bounds. // //===----------------------------------------------------------------------===// + #include "llvm/Analysis/ConstantFolding.h" #include "llvm/Analysis/Dominators.h" #include "llvm/Analysis/LoopInfo.h" @@ -101,7 +102,7 @@ } if (CallInst *CI = extractMallocCall(V)) { - Value *arraySize = getMallocArraySize(CI, P->getContext(), TD); + Value *arraySize = getMallocArraySize(CI, TD); const Type* AllocTy = getMallocAllocatedType(CI); if (!AllocTy || !arraySize) return SE->getCouldNotCompute(); Ty = AllocTy; Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=86231&r1=86230&r2=86231&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Thu Nov 5 22:27:31 2009 @@ -3816,7 +3816,6 @@ if (Constant *C = dyn_cast(V)) return C; if (GlobalValue *GV = dyn_cast(V)) return GV; Instruction *I = cast(V); - LLVMContext &Context = I->getParent()->getContext(); std::vector Operands; Operands.resize(I->getNumOperands()); @@ -3828,12 +3827,10 @@ if (const CmpInst *CI = dyn_cast(I)) return ConstantFoldCompareInstOperands(CI->getPredicate(), - &Operands[0], Operands.size(), - Context); + &Operands[0], Operands.size()); else return ConstantFoldInstOperands(I->getOpcode(), I->getType(), - &Operands[0], Operands.size(), - Context); + &Operands[0], Operands.size()); } /// getConstantEvolutionLoopExitValue - If we know that the specified Phi is @@ -4040,12 +4037,10 @@ Constant *C; if (const CmpInst *CI = dyn_cast(I)) C = ConstantFoldCompareInstOperands(CI->getPredicate(), - &Operands[0], Operands.size(), - getContext()); + &Operands[0], Operands.size()); else C = ConstantFoldInstOperands(I->getOpcode(), I->getType(), - &Operands[0], Operands.size(), - getContext()); + &Operands[0], Operands.size()); return getSCEV(C); } } Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=86231&r1=86230&r2=86231&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Thu Nov 5 22:27:31 2009 @@ -20,7 +20,6 @@ #include "llvm/DerivedTypes.h" #include "llvm/Instructions.h" #include "llvm/IntrinsicInst.h" -#include "llvm/LLVMContext.h" #include "llvm/Module.h" #include "llvm/Pass.h" #include "llvm/Analysis/ConstantFolding.h" @@ -245,8 +244,7 @@ return false; } -static Constant *getAggregateConstantElement(Constant *Agg, Constant *Idx, - LLVMContext &Context) { +static Constant *getAggregateConstantElement(Constant *Agg, Constant *Idx) { ConstantInt *CI = dyn_cast(Idx); if (!CI) return 0; unsigned IdxV = CI->getZExtValue(); @@ -282,8 +280,7 @@ /// users of the global, cleaning up the obvious ones. This is largely just a /// quick scan over the use list to clean up the easy and obvious cruft. This /// returns true if it made a change. -static bool CleanupConstantGlobalUsers(Value *V, Constant *Init, - LLVMContext &Context) { +static bool CleanupConstantGlobalUsers(Value *V, Constant *Init) { bool Changed = false; for (Value::use_iterator UI = V->use_begin(), E = V->use_end(); UI != E;) { User *U = *UI++; @@ -304,11 +301,11 @@ Constant *SubInit = 0; if (Init) SubInit = ConstantFoldLoadThroughGEPConstantExpr(Init, CE); - Changed |= CleanupConstantGlobalUsers(CE, SubInit, Context); + Changed |= CleanupConstantGlobalUsers(CE, SubInit); } else if (CE->getOpcode() == Instruction::BitCast && isa(CE->getType())) { // Pointer cast, delete any stores and memsets to the global. - Changed |= CleanupConstantGlobalUsers(CE, 0, Context); + Changed |= CleanupConstantGlobalUsers(CE, 0); } if (CE->use_empty()) { @@ -322,11 +319,11 @@ Constant *SubInit = 0; if (!isa(GEP->getOperand(0))) { ConstantExpr *CE = - dyn_cast_or_null(ConstantFoldInstruction(GEP, Context)); + dyn_cast_or_null(ConstantFoldInstruction(GEP)); if (Init && CE && CE->getOpcode() == Instruction::GetElementPtr) SubInit = ConstantFoldLoadThroughGEPConstantExpr(Init, CE); } - Changed |= CleanupConstantGlobalUsers(GEP, SubInit, Context); + Changed |= CleanupConstantGlobalUsers(GEP, SubInit); if (GEP->use_empty()) { GEP->eraseFromParent(); @@ -344,7 +341,7 @@ if (SafeToDestroyConstant(C)) { C->destroyConstant(); // This could have invalidated UI, start over from scratch. - CleanupConstantGlobalUsers(V, Init, Context); + CleanupConstantGlobalUsers(V, Init); return true; } } @@ -469,8 +466,7 @@ /// behavior of the program in a more fine-grained way. We have determined that /// this transformation is safe already. We return the first global variable we /// insert so that the caller can reprocess it. -static GlobalVariable *SRAGlobal(GlobalVariable *GV, const TargetData &TD, - LLVMContext &Context) { +static GlobalVariable *SRAGlobal(GlobalVariable *GV, const TargetData &TD) { // Make sure this global only has simple uses that we can SRA. if (!GlobalUsersSafeToSRA(GV)) return 0; @@ -492,11 +488,9 @@ const StructLayout &Layout = *TD.getStructLayout(STy); for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) { Constant *In = getAggregateConstantElement(Init, - ConstantInt::get(Type::getInt32Ty(Context), i), - Context); + ConstantInt::get(Type::getInt32Ty(STy->getContext()), i)); assert(In && "Couldn't get element of initializer?"); - GlobalVariable *NGV = new GlobalVariable(Context, - STy->getElementType(i), false, + GlobalVariable *NGV = new GlobalVariable(STy->getElementType(i), false, GlobalVariable::InternalLinkage, In, GV->getName()+"."+Twine(i), GV->isThreadLocal(), @@ -527,12 +521,10 @@ unsigned EltAlign = TD.getABITypeAlignment(STy->getElementType()); for (unsigned i = 0, e = NumElements; i != e; ++i) { Constant *In = getAggregateConstantElement(Init, - ConstantInt::get(Type::getInt32Ty(Context), i), - Context); + ConstantInt::get(Type::getInt32Ty(Init->getContext()), i)); assert(In && "Couldn't get element of initializer?"); - GlobalVariable *NGV = new GlobalVariable(Context, - STy->getElementType(), false, + GlobalVariable *NGV = new GlobalVariable(STy->getElementType(), false, GlobalVariable::InternalLinkage, In, GV->getName()+"."+Twine(i), GV->isThreadLocal(), @@ -554,7 +546,7 @@ DEBUG(errs() << "PERFORMING GLOBAL SRA ON: " << *GV); - Constant *NullInt = Constant::getNullValue(Type::getInt32Ty(Context)); + Constant *NullInt =Constant::getNullValue(Type::getInt32Ty(GV->getContext())); // Loop over all of the uses of the global, replacing the constantexpr geps, // with smaller constantexpr geps or direct references. @@ -678,8 +670,7 @@ return true; } -static bool OptimizeAwayTrappingUsesOfValue(Value *V, Constant *NewV, - LLVMContext &Context) { +static bool OptimizeAwayTrappingUsesOfValue(Value *V, Constant *NewV) { bool Changed = false; for (Value::use_iterator UI = V->use_begin(), E = V->use_end(); UI != E; ) { Instruction *I = cast(*UI++); @@ -712,7 +703,7 @@ } else if (CastInst *CI = dyn_cast(I)) { Changed |= OptimizeAwayTrappingUsesOfValue(CI, ConstantExpr::getCast(CI->getOpcode(), - NewV, CI->getType()), Context); + NewV, CI->getType())); if (CI->use_empty()) { Changed = true; CI->eraseFromParent(); @@ -730,7 +721,7 @@ if (Idxs.size() == GEPI->getNumOperands()-1) Changed |= OptimizeAwayTrappingUsesOfValue(GEPI, ConstantExpr::getGetElementPtr(NewV, &Idxs[0], - Idxs.size()), Context); + Idxs.size())); if (GEPI->use_empty()) { Changed = true; GEPI->eraseFromParent(); @@ -746,8 +737,7 @@ /// value stored into it. If there are uses of the loaded value that would trap /// if the loaded value is dynamically null, then we know that they cannot be /// reachable with a null optimize away the load. -static bool OptimizeAwayTrappingUsesOfLoads(GlobalVariable *GV, Constant *LV, - LLVMContext &Context) { +static bool OptimizeAwayTrappingUsesOfLoads(GlobalVariable *GV, Constant *LV) { bool Changed = false; // Keep track of whether we are able to remove all the uses of the global @@ -758,7 +748,7 @@ for (Value::use_iterator GUI = GV->use_begin(), E = GV->use_end(); GUI != E;){ User *GlobalUser = *GUI++; if (LoadInst *LI = dyn_cast(GlobalUser)) { - Changed |= OptimizeAwayTrappingUsesOfValue(LI, LV, Context); + Changed |= OptimizeAwayTrappingUsesOfValue(LI, LV); // If we were able to delete all uses of the loads if (LI->use_empty()) { LI->eraseFromParent(); @@ -789,7 +779,7 @@ // nor is the global. if (AllNonStoreUsesGone) { DEBUG(errs() << " *** GLOBAL NOW DEAD!\n"); - CleanupConstantGlobalUsers(GV, 0, Context); + CleanupConstantGlobalUsers(GV, 0); if (GV->use_empty()) { GV->eraseFromParent(); ++NumDeleted; @@ -801,10 +791,10 @@ /// ConstantPropUsersOf - Walk the use list of V, constant folding all of the /// instructions that are foldable. -static void ConstantPropUsersOf(Value *V, LLVMContext &Context) { +static void ConstantPropUsersOf(Value *V) { for (Value::use_iterator UI = V->use_begin(), E = V->use_end(); UI != E; ) if (Instruction *I = dyn_cast(*UI++)) - if (Constant *NewC = ConstantFoldInstruction(I, Context)) { + if (Constant *NewC = ConstantFoldInstruction(I)) { I->replaceAllUsesWith(NewC); // Advance UI to the next non-I use to avoid invalidating it! @@ -824,12 +814,11 @@ CallInst *CI, BitCastInst *BCI, Value* NElems, - LLVMContext &Context, TargetData* TD) { DEBUG(errs() << "PROMOTING MALLOC GLOBAL: " << *GV << " CALL = " << *CI << " BCI = " << *BCI << '\n'); - const Type *IntPtrTy = TD->getIntPtrType(Context); + const Type *IntPtrTy = TD->getIntPtrType(GV->getContext()); ConstantInt *NElements = cast(NElems); if (NElements->getZExtValue() != 1) { @@ -872,10 +861,10 @@ // If there is a comparison against null, we will insert a global bool to // keep track of whether the global was initialized yet or not. GlobalVariable *InitBool = - new GlobalVariable(Context, Type::getInt1Ty(Context), false, + new GlobalVariable(Type::getInt1Ty(GV->getContext()), false, GlobalValue::InternalLinkage, - ConstantInt::getFalse(Context), GV->getName()+".init", - GV->isThreadLocal()); + ConstantInt::getFalse(GV->getContext()), + GV->getName()+".init", GV->isThreadLocal()); bool InitBoolUsed = false; // Loop over all uses of GV, processing them in turn. @@ -894,8 +883,8 @@ switch (ICI->getPredicate()) { default: llvm_unreachable("Unknown ICmp Predicate!"); case ICmpInst::ICMP_ULT: - case ICmpInst::ICMP_SLT: - LV = ConstantInt::getFalse(Context); // X < null -> always false + case ICmpInst::ICMP_SLT: // X < null -> always false + LV = ConstantInt::getFalse(GV->getContext()); break; case ICmpInst::ICMP_ULE: case ICmpInst::ICMP_SLE: @@ -917,7 +906,7 @@ } else { StoreInst *SI = cast(GV->use_back()); // The global is initialized when the store to it occurs. - new StoreInst(ConstantInt::getTrue(Context), InitBool, SI); + new StoreInst(ConstantInt::getTrue(GV->getContext()), InitBool, SI); SI->eraseFromParent(); } @@ -938,9 +927,9 @@ // To further other optimizations, loop over all users of NewGV and try to // constant prop them. This will promote GEP instructions with constant // indices into GEP constant-exprs, which will allow global-opt to hack on it. - ConstantPropUsersOf(NewGV, Context); + ConstantPropUsersOf(NewGV); if (RepValue != NewGV) - ConstantPropUsersOf(RepValue, Context); + ConstantPropUsersOf(RepValue); return NewGV; } @@ -1142,8 +1131,7 @@ static Value *GetHeapSROAValue(Value *V, unsigned FieldNo, DenseMap > &InsertedScalarizedValues, - std::vector > &PHIsToRewrite, - LLVMContext &Context) { + std::vector > &PHIsToRewrite) { std::vector &FieldVals = InsertedScalarizedValues[V]; if (FieldNo >= FieldVals.size()) @@ -1161,7 +1149,7 @@ // a new Load of the scalarized global. Result = new LoadInst(GetHeapSROAValue(LI->getOperand(0), FieldNo, InsertedScalarizedValues, - PHIsToRewrite, Context), + PHIsToRewrite), LI->getName()+".f"+Twine(FieldNo), LI); } else if (PHINode *PN = dyn_cast(V)) { // PN's type is pointer to struct. Make a new PHI of pointer to struct @@ -1185,16 +1173,14 @@ /// the load, rewrite the derived value to use the HeapSRoA'd load. static void RewriteHeapSROALoadUser(Instruction *LoadUser, DenseMap > &InsertedScalarizedValues, - std::vector > &PHIsToRewrite, - LLVMContext &Context) { + std::vector > &PHIsToRewrite) { // If this is a comparison against null, handle it. if (ICmpInst *SCI = dyn_cast(LoadUser)) { assert(isa(SCI->getOperand(1))); // If we have a setcc of the loaded pointer, we can use a setcc of any // field. Value *NPtr = GetHeapSROAValue(SCI->getOperand(0), 0, - InsertedScalarizedValues, PHIsToRewrite, - Context); + InsertedScalarizedValues, PHIsToRewrite); Value *New = new ICmpInst(SCI, SCI->getPredicate(), NPtr, Constant::getNullValue(NPtr->getType()), @@ -1212,8 +1198,7 @@ // Load the pointer for this field. unsigned FieldNo = cast(GEPI->getOperand(2))->getZExtValue(); Value *NewPtr = GetHeapSROAValue(GEPI->getOperand(0), FieldNo, - InsertedScalarizedValues, PHIsToRewrite, - Context); + InsertedScalarizedValues, PHIsToRewrite); // Create the new GEP idx vector. SmallVector GEPIdx; @@ -1245,8 +1230,7 @@ // users. for (Value::use_iterator UI = PN->use_begin(), E = PN->use_end(); UI != E; ) { Instruction *User = cast(*UI++); - RewriteHeapSROALoadUser(User, InsertedScalarizedValues, PHIsToRewrite, - Context); + RewriteHeapSROALoadUser(User, InsertedScalarizedValues, PHIsToRewrite); } } @@ -1256,13 +1240,11 @@ /// AllGlobalLoadUsesSimpleEnoughForHeapSRA. static void RewriteUsesOfLoadForHeapSRoA(LoadInst *Load, DenseMap > &InsertedScalarizedValues, - std::vector > &PHIsToRewrite, - LLVMContext &Context) { + std::vector > &PHIsToRewrite) { for (Value::use_iterator UI = Load->use_begin(), E = Load->use_end(); UI != E; ) { Instruction *User = cast(*UI++); - RewriteHeapSROALoadUser(User, InsertedScalarizedValues, PHIsToRewrite, - Context); + RewriteHeapSROALoadUser(User, InsertedScalarizedValues, PHIsToRewrite); } if (Load->use_empty()) { @@ -1276,7 +1258,6 @@ static GlobalVariable *PerformHeapAllocSRoA(GlobalVariable *GV, CallInst *CI, BitCastInst* BCI, Value* NElems, - LLVMContext &Context, TargetData *TD) { DEBUG(errs() << "SROA HEAP ALLOC: " << *GV << " MALLOC CALL = " << *CI << " BITCAST = " << *BCI << '\n'); @@ -1306,7 +1287,7 @@ GV->isThreadLocal()); FieldGlobals.push_back(NGV); - Value *NMI = CallInst::CreateMalloc(CI, TD->getIntPtrType(Context), + Value *NMI = CallInst::CreateMalloc(CI, TD->getIntPtrType(CI->getContext()), FieldTy, NElems, BCI->getName() + ".f" + Twine(FieldNo)); FieldMallocs.push_back(NMI); @@ -1342,7 +1323,8 @@ // Create the block to check the first condition. Put all these blocks at the // end of the function as they are unlikely to be executed. - BasicBlock *NullPtrBlock = BasicBlock::Create(Context, "malloc_ret_null", + BasicBlock *NullPtrBlock = BasicBlock::Create(OrigBB->getContext(), + "malloc_ret_null", OrigBB->getParent()); // Remove the uncond branch from OrigBB to ContBB, turning it into a cond @@ -1357,9 +1339,9 @@ Value *Cmp = new ICmpInst(*NullPtrBlock, ICmpInst::ICMP_NE, GVVal, Constant::getNullValue(GVVal->getType()), "tmp"); - BasicBlock *FreeBlock = BasicBlock::Create(Context, "free_it", + BasicBlock *FreeBlock = BasicBlock::Create(Cmp->getContext(), "free_it", OrigBB->getParent()); - BasicBlock *NextBlock = BasicBlock::Create(Context, "next", + BasicBlock *NextBlock = BasicBlock::Create(Cmp->getContext(), "next", OrigBB->getParent()); Instruction *BI = BranchInst::Create(FreeBlock, NextBlock, Cmp, NullPtrBlock); @@ -1394,8 +1376,7 @@ Instruction *User = cast(*UI++); if (LoadInst *LI = dyn_cast(User)) { - RewriteUsesOfLoadForHeapSRoA(LI, InsertedScalarizedValues, PHIsToRewrite, - Context); + RewriteUsesOfLoadForHeapSRoA(LI, InsertedScalarizedValues, PHIsToRewrite); continue; } @@ -1426,7 +1407,7 @@ for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) { Value *InVal = PN->getIncomingValue(i); InVal = GetHeapSROAValue(InVal, FieldNo, InsertedScalarizedValues, - PHIsToRewrite, Context); + PHIsToRewrite); FieldPN->addIncoming(InVal, PN->getIncomingBlock(i)); } } @@ -1465,8 +1446,7 @@ CallInst *CI, BitCastInst *BCI, Module::global_iterator &GVI, - TargetData *TD, - LLVMContext &Context) { + TargetData *TD) { // If we can't figure out the type being malloced, then we can't optimize. const Type *AllocTy = getMallocAllocatedType(CI); assert(AllocTy); @@ -1499,7 +1479,7 @@ // transform the program to use global memory instead of malloc'd memory. // This eliminates dynamic allocation, avoids an indirection accessing the // data, and exposes the resultant global to further GlobalOpt. - Value *NElems = getMallocArraySize(CI, Context, TD); + Value *NElems = getMallocArraySize(CI, TD); // We cannot optimize the malloc if we cannot determine malloc array size. if (NElems) { if (ConstantInt *NElements = dyn_cast(NElems)) @@ -1508,7 +1488,7 @@ // something. if (TD && NElements->getZExtValue() * TD->getTypeAllocSize(AllocTy) < 2048) { - GVI = OptimizeGlobalAddressOfMalloc(GV, CI, BCI, NElems, Context, TD); + GVI = OptimizeGlobalAddressOfMalloc(GV, CI, BCI, NElems, TD); return true; } @@ -1532,9 +1512,11 @@ // structs. malloc [100 x struct],1 -> malloc struct, 100 if (const ArrayType *AT = dyn_cast(getMallocAllocatedType(CI))) { - Value* NumElements = ConstantInt::get(Type::getInt32Ty(Context), - AT->getNumElements()); - Value* NewMI = CallInst::CreateMalloc(CI, TD->getIntPtrType(Context), + Value *NumElements = + ConstantInt::get(Type::getInt32Ty(CI->getContext()), + AT->getNumElements()); + Value *NewMI = CallInst::CreateMalloc(CI, + TD->getIntPtrType(CI->getContext()), AllocSTy, NumElements, BCI->getName()); Value *Cast = new BitCastInst(NewMI, getMallocType(CI), "tmp", CI); @@ -1545,7 +1527,7 @@ CI = extractMallocCallFromBitCast(NewMI); } - GVI = PerformHeapAllocSRoA(GV, CI, BCI, NElems, Context, TD); + GVI = PerformHeapAllocSRoA(GV, CI, BCI, NElems, TD); return true; } } @@ -1558,7 +1540,7 @@ // that only one value (besides its initializer) is ever stored to the global. static bool OptimizeOnceStoredGlobal(GlobalVariable *GV, Value *StoredOnceVal, Module::global_iterator &GVI, - TargetData *TD, LLVMContext &Context) { + TargetData *TD) { // Ignore no-op GEPs and bitcasts. StoredOnceVal = StoredOnceVal->stripPointerCasts(); @@ -1574,7 +1556,7 @@ ConstantExpr::getBitCast(SOVC, GV->getInitializer()->getType()); // Optimize away any trapping uses of the loaded value. - if (OptimizeAwayTrappingUsesOfLoads(GV, SOVC, Context)) + if (OptimizeAwayTrappingUsesOfLoads(GV, SOVC)) return true; } else if (CallInst *CI = extractMallocCall(StoredOnceVal)) { if (getMallocAllocatedType(CI)) { @@ -1582,8 +1564,7 @@ for (Value::use_iterator UI = CI->use_begin(), E = CI->use_end(); UI != E; ) BCI = dyn_cast(cast(*UI++)); - if (BCI && - TryToOptimizeStoreOfMallocToGlobal(GV, CI, BCI, GVI, TD, Context)) + if (BCI && TryToOptimizeStoreOfMallocToGlobal(GV, CI, BCI, GVI, TD)) return true; } } @@ -1596,8 +1577,7 @@ /// two values ever stored into GV are its initializer and OtherVal. See if we /// can shrink the global into a boolean and select between the two values /// whenever it is used. This exposes the values to other scalar optimizations. -static bool TryToShrinkGlobalToBoolean(GlobalVariable *GV, Constant *OtherVal, - LLVMContext &Context) { +static bool TryToShrinkGlobalToBoolean(GlobalVariable *GV, Constant *OtherVal) { const Type *GVElType = GV->getType()->getElementType(); // If GVElType is already i1, it is already shrunk. If the type of the GV is @@ -1605,7 +1585,8 @@ // between them is very expensive and unlikely to lead to later // simplification. In these cases, we typically end up with "cond ? v1 : v2" // where v1 and v2 both require constant pool loads, a big loss. - if (GVElType == Type::getInt1Ty(Context) || GVElType->isFloatingPoint() || + if (GVElType == Type::getInt1Ty(GV->getContext()) || + GVElType->isFloatingPoint() || isa(GVElType) || isa(GVElType)) return false; @@ -1618,15 +1599,16 @@ DEBUG(errs() << " *** SHRINKING TO BOOL: " << *GV); // Create the new global, initializing it to false. - GlobalVariable *NewGV = new GlobalVariable(Context, - Type::getInt1Ty(Context), false, - GlobalValue::InternalLinkage, ConstantInt::getFalse(Context), + GlobalVariable *NewGV = new GlobalVariable(Type::getInt1Ty(GV->getContext()), + false, + GlobalValue::InternalLinkage, + ConstantInt::getFalse(GV->getContext()), GV->getName()+".b", GV->isThreadLocal()); GV->getParent()->getGlobalList().insert(GV, NewGV); Constant *InitVal = GV->getInitializer(); - assert(InitVal->getType() != Type::getInt1Ty(Context) && + assert(InitVal->getType() != Type::getInt1Ty(GV->getContext()) && "No reason to shrink to bool!"); // If initialized to zero and storing one into the global, we can use a cast @@ -1643,7 +1625,8 @@ // Only do this if we weren't storing a loaded value. Value *StoreVal; if (StoringOther || SI->getOperand(0) == InitVal) - StoreVal = ConstantInt::get(Type::getInt1Ty(Context), StoringOther); + StoreVal = ConstantInt::get(Type::getInt1Ty(GV->getContext()), + StoringOther); else { // Otherwise, we are storing a previously loaded copy. To do this, // change the copy from copying the original value to just copying the @@ -1758,8 +1741,7 @@ // Delete any stores we can find to the global. We may not be able to // make it completely dead though. - bool Changed = CleanupConstantGlobalUsers(GV, GV->getInitializer(), - GV->getContext()); + bool Changed = CleanupConstantGlobalUsers(GV, GV->getInitializer()); // If the global is dead now, delete it. if (GV->use_empty()) { @@ -1774,7 +1756,7 @@ GV->setConstant(true); // Clean up any obviously simplifiable users now. - CleanupConstantGlobalUsers(GV, GV->getInitializer(), GV->getContext()); + CleanupConstantGlobalUsers(GV, GV->getInitializer()); // If the global is dead now, just nuke it. if (GV->use_empty()) { @@ -1788,8 +1770,7 @@ return true; } else if (!GV->getInitializer()->getType()->isSingleValueType()) { if (TargetData *TD = getAnalysisIfAvailable()) - if (GlobalVariable *FirstNewGV = SRAGlobal(GV, *TD, - GV->getContext())) { + if (GlobalVariable *FirstNewGV = SRAGlobal(GV, *TD)) { GVI = FirstNewGV; // Don't skip the newly produced globals! return true; } @@ -1804,8 +1785,7 @@ GV->setInitializer(SOVConstant); // Clean up any obviously simplifiable users now. - CleanupConstantGlobalUsers(GV, GV->getInitializer(), - GV->getContext()); + CleanupConstantGlobalUsers(GV, GV->getInitializer()); if (GV->use_empty()) { DEBUG(errs() << " *** Substituting initializer allowed us to " @@ -1822,14 +1802,13 @@ // Try to optimize globals based on the knowledge that only one value // (besides its initializer) is ever stored to the global. if (OptimizeOnceStoredGlobal(GV, GS.StoredOnceValue, GVI, - getAnalysisIfAvailable(), - GV->getContext())) + getAnalysisIfAvailable())) return true; // Otherwise, if the global was not a boolean, we can shrink it to be a // boolean. if (Constant *SOVConstant = dyn_cast(GS.StoredOnceValue)) - if (TryToShrinkGlobalToBoolean(GV, SOVConstant, GV->getContext())) { + if (TryToShrinkGlobalToBoolean(GV, SOVConstant)) { ++NumShrunkToBool; return true; } @@ -1981,11 +1960,10 @@ /// InstallGlobalCtors - Given a specified llvm.global_ctors list, install the /// specified array, returning the new global to use. static GlobalVariable *InstallGlobalCtors(GlobalVariable *GCL, - const std::vector &Ctors, - LLVMContext &Context) { + const std::vector &Ctors) { // If we made a change, reassemble the initializer list. std::vector CSVals; - CSVals.push_back(ConstantInt::get(Type::getInt32Ty(Context), 65535)); + CSVals.push_back(ConstantInt::get(Type::getInt32Ty(GCL->getContext()),65535)); CSVals.push_back(0); // Create the new init list. @@ -1994,12 +1972,14 @@ if (Ctors[i]) { CSVals[1] = Ctors[i]; } else { - const Type *FTy = FunctionType::get(Type::getVoidTy(Context), false); + const Type *FTy = FunctionType::get(Type::getVoidTy(GCL->getContext()), + false); const PointerType *PFTy = PointerType::getUnqual(FTy); CSVals[1] = Constant::getNullValue(PFTy); - CSVals[0] = ConstantInt::get(Type::getInt32Ty(Context), 2147483647); + CSVals[0] = ConstantInt::get(Type::getInt32Ty(GCL->getContext()), + 2147483647); } - CAList.push_back(ConstantStruct::get(Context, CSVals, false)); + CAList.push_back(ConstantStruct::get(GCL->getContext(), CSVals, false)); } // Create the array initializer. @@ -2015,8 +1995,7 @@ } // Create the new global and insert it next to the existing list. - GlobalVariable *NGV = new GlobalVariable(Context, CA->getType(), - GCL->isConstant(), + GlobalVariable *NGV = new GlobalVariable(CA->getType(), GCL->isConstant(), GCL->getLinkage(), CA, "", GCL->isThreadLocal()); GCL->getParent()->getGlobalList().insert(GCL, NGV); @@ -2050,7 +2029,7 @@ /// enough for us to understand. In particular, if it is a cast of something, /// we punt. We basically just support direct accesses to globals and GEP's of /// globals. This should be kept up to date with CommitValueTo. -static bool isSimpleEnoughPointerToCommit(Constant *C, LLVMContext &Context) { +static bool isSimpleEnoughPointerToCommit(Constant *C) { // Conservatively, avoid aggregate types. This is because we don't // want to worry about them partially overlapping other stores. if (!cast(C->getType())->getElementType()->isSingleValueType()) @@ -2090,8 +2069,7 @@ /// initializer. This returns 'Init' modified to reflect 'Val' stored into it. /// At this point, the GEP operands of Addr [0, OpNo) have been stepped into. static Constant *EvaluateStoreInto(Constant *Init, Constant *Val, - ConstantExpr *Addr, unsigned OpNo, - LLVMContext &Context) { + ConstantExpr *Addr, unsigned OpNo) { // Base case of the recursion. if (OpNo == Addr->getNumOperands()) { assert(Val->getType() == Init->getType() && "Type mismatch!"); @@ -2120,10 +2098,11 @@ ConstantInt *CU = cast(Addr->getOperand(OpNo)); unsigned Idx = CU->getZExtValue(); assert(Idx < STy->getNumElements() && "Struct index out of range!"); - Elts[Idx] = EvaluateStoreInto(Elts[Idx], Val, Addr, OpNo+1, Context); + Elts[Idx] = EvaluateStoreInto(Elts[Idx], Val, Addr, OpNo+1); // Return the modified struct. - return ConstantStruct::get(Context, &Elts[0], Elts.size(), STy->isPacked()); + return ConstantStruct::get(Init->getContext(), &Elts[0], Elts.size(), + STy->isPacked()); } else { ConstantInt *CI = cast(Addr->getOperand(OpNo)); const ArrayType *ATy = cast(Init->getType()); @@ -2146,15 +2125,14 @@ assert(CI->getZExtValue() < ATy->getNumElements()); Elts[CI->getZExtValue()] = - EvaluateStoreInto(Elts[CI->getZExtValue()], Val, Addr, OpNo+1, Context); + EvaluateStoreInto(Elts[CI->getZExtValue()], Val, Addr, OpNo+1); return ConstantArray::get(ATy, Elts); } } /// CommitValueTo - We have decided that Addr (which satisfies the predicate /// isSimpleEnoughPointerToCommit) should get Val as its value. Make it happen. -static void CommitValueTo(Constant *Val, Constant *Addr, - LLVMContext &Context) { +static void CommitValueTo(Constant *Val, Constant *Addr) { if (GlobalVariable *GV = dyn_cast(Addr)) { assert(GV->hasInitializer()); GV->setInitializer(Val); @@ -2165,7 +2143,7 @@ GlobalVariable *GV = cast(CE->getOperand(0)); Constant *Init = GV->getInitializer(); - Init = EvaluateStoreInto(Init, Val, CE, 2, Context); + Init = EvaluateStoreInto(Init, Val, CE, 2); GV->setInitializer(Init); } @@ -2173,8 +2151,7 @@ /// P after the stores reflected by 'memory' have been performed. If we can't /// decide, return null. static Constant *ComputeLoadResult(Constant *P, - const DenseMap &Memory, - LLVMContext &Context) { + const DenseMap &Memory) { // If this memory location has been recently stored, use the stored value: it // is the most up-to-date. DenseMap::const_iterator I = Memory.find(P); @@ -2212,8 +2189,6 @@ if (std::find(CallStack.begin(), CallStack.end(), F) != CallStack.end()) return false; - LLVMContext &Context = F->getContext(); - CallStack.push_back(F); /// Values - As we compute SSA register values, we store their contents here. @@ -2240,7 +2215,7 @@ if (StoreInst *SI = dyn_cast(CurInst)) { if (SI->isVolatile()) return false; // no volatile accesses. Constant *Ptr = getVal(Values, SI->getOperand(1)); - if (!isSimpleEnoughPointerToCommit(Ptr, Context)) + if (!isSimpleEnoughPointerToCommit(Ptr)) // If this is too complex for us to commit, reject it. return false; Constant *Val = getVal(Values, SI->getOperand(0)); @@ -2274,12 +2249,12 @@ } else if (LoadInst *LI = dyn_cast(CurInst)) { if (LI->isVolatile()) return false; // no volatile accesses. InstResult = ComputeLoadResult(getVal(Values, LI->getOperand(0)), - MutatedMemory, Context); + MutatedMemory); if (InstResult == 0) return false; // Could not evaluate load. } else if (AllocaInst *AI = dyn_cast(CurInst)) { if (AI->isArrayAllocation()) return false; // Cannot handle array allocs. const Type *Ty = AI->getType()->getElementType(); - AllocaTmps.push_back(new GlobalVariable(Context, Ty, false, + AllocaTmps.push_back(new GlobalVariable(Ty, false, GlobalValue::InternalLinkage, UndefValue::get(Ty), AI->getName())); @@ -2417,7 +2392,7 @@ << " stores.\n"); for (DenseMap::iterator I = MutatedMemory.begin(), E = MutatedMemory.end(); I != E; ++I) - CommitValueTo(I->second, I->first, F->getContext()); + CommitValueTo(I->second, I->first); } // At this point, we are done interpreting. If we created any 'alloca' @@ -2474,7 +2449,7 @@ if (!MadeChange) return false; - GCL = InstallGlobalCtors(GCL, Ctors, GCL->getContext()); + GCL = InstallGlobalCtors(GCL, Ctors); return true; } Modified: llvm/trunk/lib/Transforms/Scalar/ConstantProp.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/ConstantProp.cpp?rev=86231&r1=86230&r2=86231&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/ConstantProp.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/ConstantProp.cpp Thu Nov 5 22:27:31 2009 @@ -66,7 +66,7 @@ WorkList.erase(WorkList.begin()); // Get an element from the worklist... if (!I->use_empty()) // Don't muck with dead instructions... - if (Constant *C = ConstantFoldInstruction(I, F.getContext())) { + if (Constant *C = ConstantFoldInstruction(I)) { // Add all of the users of this instruction to the worklist, they might // be constant propagatable now... for (Value::use_iterator UI = I->use_begin(), UE = I->use_end(); Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=86231&r1=86230&r2=86231&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Thu Nov 5 22:27:31 2009 @@ -12824,7 +12824,7 @@ // ConstantProp instruction if trivially constant. if (!Inst->use_empty() && isa(Inst->getOperand(0))) - if (Constant *C = ConstantFoldInstruction(Inst, BB->getContext(), TD)) { + if (Constant *C = ConstantFoldInstruction(Inst, TD)) { DEBUG(errs() << "IC: ConstFold to: " << *C << " from: " << *Inst << '\n'); Inst->replaceAllUsesWith(C); @@ -12846,8 +12846,7 @@ if (!FoldedConstants.insert(CE)) continue; - Constant *NewC = - ConstantFoldConstantExpression(CE, BB->getContext(), TD); + Constant *NewC = ConstantFoldConstantExpression(CE, TD); if (NewC && NewC != CE) { *i = NewC; MadeIRChange = true; @@ -12954,7 +12953,7 @@ // Instruction isn't dead, see if we can constant propagate it. if (!I->use_empty() && isa(I->getOperand(0))) - if (Constant *C = ConstantFoldInstruction(I, F.getContext(), TD)) { + if (Constant *C = ConstantFoldInstruction(I, TD)) { DEBUG(errs() << "IC: ConstFold to: " << *C << " from: " << *I << '\n'); // Add operands to the worklist. Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=86231&r1=86230&r2=86231&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Thu Nov 5 22:27:31 2009 @@ -1044,7 +1044,7 @@ BI = NewBB->begin(); for (BasicBlock::iterator E = NewBB->end(); BI != E; ) { Instruction *Inst = BI++; - if (Constant *C = ConstantFoldInstruction(Inst, BB->getContext(), TD)) { + if (Constant *C = ConstantFoldInstruction(Inst, TD)) { Inst->replaceAllUsesWith(C); Inst->eraseFromParent(); continue; Modified: llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp?rev=86231&r1=86230&r2=86231&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp Thu Nov 5 22:27:31 2009 @@ -32,7 +32,6 @@ #include "llvm/DerivedTypes.h" #include "llvm/Function.h" #include "llvm/Instructions.h" -#include "llvm/LLVMContext.h" #include "llvm/Analysis/ConstantFolding.h" #include "llvm/Analysis/InlineCost.h" #include "llvm/Analysis/LoopInfo.h" @@ -961,7 +960,7 @@ Worklist.pop_back(); // Simple constant folding. - if (Constant *C = ConstantFoldInstruction(I, I->getContext())) { + if (Constant *C = ConstantFoldInstruction(I)) { ReplaceUsesOfWith(I, C, Worklist, L, LPM); continue; } Modified: llvm/trunk/lib/Transforms/Scalar/TailDuplication.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/TailDuplication.cpp?rev=86231&r1=86230&r2=86231&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/TailDuplication.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/TailDuplication.cpp Thu Nov 5 22:27:31 2009 @@ -359,8 +359,7 @@ Instruction *Inst = BI++; if (isInstructionTriviallyDead(Inst)) Inst->eraseFromParent(); - else if (Constant *C = ConstantFoldInstruction(Inst, - Inst->getContext())) { + else if (Constant *C = ConstantFoldInstruction(Inst)) { Inst->replaceAllUsesWith(C); Inst->eraseFromParent(); } Modified: llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp?rev=86231&r1=86230&r2=86231&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp Thu Nov 5 22:27:31 2009 @@ -322,8 +322,6 @@ /// mapping its operands through ValueMap if they are available. Constant *PruningFunctionCloner:: ConstantFoldMappedInstruction(const Instruction *I) { - LLVMContext &Context = I->getContext(); - SmallVector Ops; for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) if (Constant *Op = dyn_cast_or_null(MapValue(I->getOperand(i), @@ -334,8 +332,7 @@ if (const CmpInst *CI = dyn_cast(I)) return ConstantFoldCompareInstOperands(CI->getPredicate(), - &Ops[0], Ops.size(), - Context, TD); + &Ops[0], Ops.size(), TD); if (const LoadInst *LI = dyn_cast(I)) if (ConstantExpr *CE = dyn_cast(Ops[0])) @@ -346,7 +343,7 @@ CE); return ConstantFoldInstOperands(I->getOpcode(), I->getType(), &Ops[0], - Ops.size(), Context, TD); + Ops.size(), TD); } /// CloneAndPruneFunctionInto - This works exactly like CloneFunctionInto, Modified: llvm/trunk/lib/Transforms/Utils/LoopUnroll.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LoopUnroll.cpp?rev=86231&r1=86230&r2=86231&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/LoopUnroll.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/LoopUnroll.cpp Thu Nov 5 22:27:31 2009 @@ -362,8 +362,7 @@ if (isInstructionTriviallyDead(Inst)) (*BB)->getInstList().erase(Inst); - else if (Constant *C = ConstantFoldInstruction(Inst, - Header->getContext())) { + else if (Constant *C = ConstantFoldInstruction(Inst)) { Inst->replaceAllUsesWith(C); (*BB)->getInstList().erase(Inst); } Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=86231&r1=86230&r2=86231&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Thu Nov 5 22:27:31 2009 @@ -1217,7 +1217,7 @@ } // Check for trivial simplification. - if (Constant *C = ConstantFoldInstruction(N, BB->getContext())) { + if (Constant *C = ConstantFoldInstruction(N)) { TranslateMap[BBI] = C; delete N; // Constant folded away, don't need actual inst } else { Modified: llvm/trunk/lib/VMCore/Globals.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Globals.cpp?rev=86231&r1=86230&r2=86231&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Globals.cpp (original) +++ llvm/trunk/lib/VMCore/Globals.cpp Thu Nov 5 22:27:31 2009 @@ -16,7 +16,6 @@ #include "llvm/GlobalVariable.h" #include "llvm/GlobalAlias.h" #include "llvm/DerivedTypes.h" -#include "llvm/LLVMContext.h" #include "llvm/Module.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/Support/ErrorHandling.h" @@ -95,8 +94,7 @@ // GlobalVariable Implementation //===----------------------------------------------------------------------===// -GlobalVariable::GlobalVariable(LLVMContext &Context, const Type *Ty, - bool constant, LinkageTypes Link, +GlobalVariable::GlobalVariable(const Type *Ty, bool constant, LinkageTypes Link, Constant *InitVal, const Twine &Name, bool ThreadLocal, unsigned AddressSpace) : GlobalValue(PointerType::get(Ty, AddressSpace), Modified: llvm/trunk/lib/VMCore/Module.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Module.cpp?rev=86231&r1=86230&r2=86231&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Module.cpp (original) +++ llvm/trunk/lib/VMCore/Module.cpp Thu Nov 5 22:27:31 2009 @@ -31,8 +31,7 @@ // GlobalVariable *ilist_traits::createSentinel() { - GlobalVariable *Ret = new GlobalVariable(getGlobalContext(), - Type::getInt32Ty(getGlobalContext()), + GlobalVariable *Ret = new GlobalVariable(Type::getInt32Ty(getGlobalContext()), false, GlobalValue::ExternalLinkage); // This should not be garbage monitored. LeakDetector::removeGarbageObject(Ret); From sabre at nondot.org Thu Nov 5 23:59:53 2009 From: sabre at nondot.org (Chris Lattner) Date: Fri, 06 Nov 2009 05:59:53 -0000 Subject: [llvm-commits] [llvm] r86235 - in /llvm/trunk: include/llvm/Analysis/ScalarEvolutionExpander.h include/llvm/Support/TargetFolder.h lib/Transforms/Scalar/InstructionCombining.cpp Message-ID: <200911060559.nA65xr3x020941@zion.cs.uiuc.edu> Author: lattner Date: Thu Nov 5 23:59:53 2009 New Revision: 86235 URL: http://llvm.org/viewvc/llvm-project?rev=86235&view=rev Log: remove some more Context arguments. Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h llvm/trunk/include/llvm/Support/TargetFolder.h llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h?rev=86235&r1=86234&r2=86235&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h (original) +++ llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h Thu Nov 5 23:59:53 2009 @@ -38,8 +38,7 @@ friend struct SCEVVisitor; public: explicit SCEVExpander(ScalarEvolution &se) - : SE(se), Builder(se.getContext(), - TargetFolder(se.TD, se.getContext())) {} + : SE(se), Builder(se.getContext(), TargetFolder(se.TD)) {} /// clear - Erase the contents of the InsertedExpressions map so that users /// trying to expand the same expression into multiple BasicBlocks or Modified: llvm/trunk/include/llvm/Support/TargetFolder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/TargetFolder.h?rev=86235&r1=86234&r2=86235&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/TargetFolder.h (original) +++ llvm/trunk/include/llvm/Support/TargetFolder.h Thu Nov 5 23:59:53 2009 @@ -40,8 +40,7 @@ } public: - explicit TargetFolder(const TargetData *TheTD, LLVMContext &C) : - TD(TheTD) {} + explicit TargetFolder(const TargetData *TheTD) : TD(TheTD) {} //===--------------------------------------------------------------------===// // Binary Operators Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=86235&r1=86234&r2=86235&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Thu Nov 5 23:59:53 2009 @@ -13064,7 +13064,7 @@ /// Builder - This is an IRBuilder that automatically inserts new /// instructions into the worklist when they are created. IRBuilder - TheBuilder(F.getContext(), TargetFolder(TD, F.getContext()), + TheBuilder(F.getContext(), TargetFolder(TD), InstCombineIRInserter(Worklist)); Builder = &TheBuilder; From sabre at nondot.org Thu Nov 5 23:59:57 2009 From: sabre at nondot.org (Chris Lattner) Date: Fri, 06 Nov 2009 05:59:57 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r86236 - /llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Message-ID: <200911060559.nA65xvPS020953@zion.cs.uiuc.edu> Author: lattner Date: Thu Nov 5 23:59:57 2009 New Revision: 86236 URL: http://llvm.org/viewvc/llvm-project?rev=86236&view=rev Log: match llvm ToT Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp?rev=86236&r1=86235&r2=86236&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Thu Nov 5 23:59:57 2009 @@ -490,7 +490,7 @@ TheTarget = TME->createTargetMachine(TargetTriple, FeatureStr); assert(TheTarget->getTargetData()->isBigEndian() == BYTES_BIG_ENDIAN); - TheFolder = new TargetFolder(TheTarget->getTargetData(), getGlobalContext()); + TheFolder = new TargetFolder(TheTarget->getTargetData()); // Install information about target datalayout stuff into the module for // optimizer use. From bob.wilson at apple.com Fri Nov 6 00:07:23 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Fri, 06 Nov 2009 06:07:23 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r86237 - /llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp Message-ID: <200911060607.nA667N8e021214@zion.cs.uiuc.edu> Author: bwilson Date: Fri Nov 6 00:07:23 2009 New Revision: 86237 URL: http://llvm.org/viewvc/llvm-project?rev=86237&view=rev Log: The prior changes to pass homogeneous aggregates in registers didn't account for non-POD aggregates that still must be passed via a shadow return. Patch by Sandeep Patel. Modified: llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp Modified: llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp?rev=86237&r1=86236&r2=86237&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp Fri Nov 6 00:07:23 2009 @@ -2727,7 +2727,7 @@ bool result = false; result = vfp_arg_homogeneous_aggregate_p(TYPE_MODE(TreeType), TreeType, fdt_counts); - return result; + return result && !TREE_ADDRESSABLE(TreeType); } /* LLVM LOCAL end (ENTIRE FILE!) */ From sabre at nondot.org Fri Nov 6 00:33:02 2009 From: sabre at nondot.org (Chris Lattner) Date: Fri, 06 Nov 2009 06:33:02 -0000 Subject: [llvm-commits] [llvm] r86239 - /llvm/trunk/utils/TableGen/CodeGenTarget.h Message-ID: <200911060633.nA66X2UA022068@zion.cs.uiuc.edu> Author: lattner Date: Fri Nov 6 00:33:01 2009 New Revision: 86239 URL: http://llvm.org/viewvc/llvm-project?rev=86239&view=rev Log: clang++ points out that this is pointless. Modified: llvm/trunk/utils/TableGen/CodeGenTarget.h Modified: llvm/trunk/utils/TableGen/CodeGenTarget.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenTarget.h?rev=86239&r1=86238&r2=86239&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/CodeGenTarget.h (original) +++ llvm/trunk/utils/TableGen/CodeGenTarget.h Fri Nov 6 00:33:01 2009 @@ -229,7 +229,7 @@ unsigned Properties; // Node properties unsigned Attributes; // Pattern attributes public: - ComplexPattern() : NumOperands(0) {}; + ComplexPattern() : NumOperands(0) {} ComplexPattern(Record *R); MVT::SimpleValueType getValueType() const { return Ty; } From baldrick at free.fr Fri Nov 6 04:30:47 2009 From: baldrick at free.fr (Duncan Sands) Date: Fri, 06 Nov 2009 10:30:47 -0000 Subject: [llvm-commits] [dragonegg] r86250 - /dragonegg/trunk/llvm-backend.cpp Message-ID: <200911061030.nA6AUleC012192@zion.cs.uiuc.edu> Author: baldrick Date: Fri Nov 6 04:30:46 2009 New Revision: 86250 URL: http://llvm.org/viewvc/llvm-project?rev=86250&view=rev Log: Compile fix due to LLVM API change. Modified: dragonegg/trunk/llvm-backend.cpp Modified: dragonegg/trunk/llvm-backend.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-backend.cpp?rev=86250&r1=86249&r2=86250&view=diff ============================================================================== --- dragonegg/trunk/llvm-backend.cpp (original) +++ dragonegg/trunk/llvm-backend.cpp Fri Nov 6 04:30:46 2009 @@ -453,7 +453,7 @@ TheTarget = TME->createTargetMachine(TargetTriple, FeatureStr); assert(TheTarget->getTargetData()->isBigEndian() == BYTES_BIG_ENDIAN); - TheFolder = new TargetFolder(TheTarget->getTargetData(), getGlobalContext()); + TheFolder = new TargetFolder(TheTarget->getTargetData()); // Install information about target datalayout stuff into the module for // optimizer use. From daniel at zuster.org Fri Nov 6 04:58:07 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Fri, 06 Nov 2009 10:58:07 -0000 Subject: [llvm-commits] [llvm] r86251 - in /llvm/trunk: include/llvm/ include/llvm/ADT/ include/llvm/Bitcode/ include/llvm/MC/ include/llvm/Support/ include/llvm/Target/ lib/Linker/ lib/MC/ lib/Support/ lib/Target/ lib/Target/ARM/ lib/Target/PowerPC/ lib/Target/X86/ lib/VMCore/ Message-ID: <200911061058.nA6Aw82c013125@zion.cs.uiuc.edu> Author: ddunbar Date: Fri Nov 6 04:58:06 2009 New Revision: 86251 URL: http://llvm.org/viewvc/llvm-project?rev=86251&view=rev Log: Pass StringRef by value. Modified: llvm/trunk/include/llvm/ADT/StringMap.h llvm/trunk/include/llvm/ADT/StringRef.h llvm/trunk/include/llvm/ADT/Triple.h llvm/trunk/include/llvm/Bitcode/BitstreamWriter.h llvm/trunk/include/llvm/Constants.h llvm/trunk/include/llvm/GlobalValue.h llvm/trunk/include/llvm/InlineAsm.h llvm/trunk/include/llvm/Linker.h llvm/trunk/include/llvm/MC/MCAsmLexer.h llvm/trunk/include/llvm/MC/MCContext.h llvm/trunk/include/llvm/MC/MCExpr.h llvm/trunk/include/llvm/MC/MCSection.h llvm/trunk/include/llvm/MC/MCSectionELF.h llvm/trunk/include/llvm/MC/MCSectionMachO.h llvm/trunk/include/llvm/MC/MCStreamer.h llvm/trunk/include/llvm/MC/MCSymbol.h llvm/trunk/include/llvm/Module.h llvm/trunk/include/llvm/Pass.h llvm/trunk/include/llvm/PassAnalysisSupport.h llvm/trunk/include/llvm/PassManagers.h llvm/trunk/include/llvm/Support/raw_ostream.h llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h llvm/trunk/include/llvm/Target/TargetRegistry.h llvm/trunk/include/llvm/TypeSymbolTable.h llvm/trunk/include/llvm/ValueSymbolTable.h llvm/trunk/lib/Linker/LinkItems.cpp llvm/trunk/lib/Linker/Linker.cpp llvm/trunk/lib/MC/MCAsmStreamer.cpp llvm/trunk/lib/MC/MCAssembler.cpp llvm/trunk/lib/MC/MCContext.cpp llvm/trunk/lib/MC/MCExpr.cpp llvm/trunk/lib/MC/MCMachOStreamer.cpp llvm/trunk/lib/MC/MCNullStreamer.cpp llvm/trunk/lib/MC/MCSection.cpp llvm/trunk/lib/MC/MCSectionELF.cpp llvm/trunk/lib/MC/MCSectionMachO.cpp llvm/trunk/lib/MC/MCSymbol.cpp llvm/trunk/lib/Support/StringMap.cpp llvm/trunk/lib/Support/StringRef.cpp llvm/trunk/lib/Support/Triple.cpp llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp llvm/trunk/lib/Target/PowerPC/PPCTargetMachine.cpp llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp llvm/trunk/lib/Target/X86/X86TargetMachine.cpp llvm/trunk/lib/VMCore/Constants.cpp llvm/trunk/lib/VMCore/InlineAsm.cpp llvm/trunk/lib/VMCore/Module.cpp llvm/trunk/lib/VMCore/Pass.cpp llvm/trunk/lib/VMCore/PassManager.cpp llvm/trunk/lib/VMCore/TypeSymbolTable.cpp llvm/trunk/lib/VMCore/ValueSymbolTable.cpp Modified: llvm/trunk/include/llvm/ADT/StringMap.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringMap.h?rev=86251&r1=86250&r2=86251&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/StringMap.h (original) +++ llvm/trunk/include/llvm/ADT/StringMap.h Fri Nov 6 04:58:06 2009 @@ -96,12 +96,12 @@ /// specified bucket will be non-null. Otherwise, it will be null. In either /// case, the FullHashValue field of the bucket will be set to the hash value /// of the string. - unsigned LookupBucketFor(const StringRef &Key); + unsigned LookupBucketFor(StringRef Key); /// FindKey - Look up the bucket that contains the specified key. If it exists /// in the map, return the bucket number of the key. Otherwise return -1. /// This does not modify the map. - int FindKey(const StringRef &Key) const; + int FindKey(StringRef Key) const; /// RemoveKey - Remove the specified StringMapEntry from the table, but do not /// delete it. This aborts if the value isn't in the table. @@ -109,7 +109,7 @@ /// RemoveKey - Remove the StringMapEntry for the specified key from the /// table, returning it. If the key is not in the table, this returns null. - StringMapEntryBase *RemoveKey(const StringRef &Key); + StringMapEntryBase *RemoveKey(StringRef Key); private: void init(unsigned Size); public: @@ -282,13 +282,13 @@ return const_iterator(TheTable+NumBuckets, true); } - iterator find(const StringRef &Key) { + iterator find(StringRef Key) { int Bucket = FindKey(Key); if (Bucket == -1) return end(); return iterator(TheTable+Bucket); } - const_iterator find(const StringRef &Key) const { + const_iterator find(StringRef Key) const { int Bucket = FindKey(Key); if (Bucket == -1) return end(); return const_iterator(TheTable+Bucket); @@ -296,18 +296,18 @@ /// lookup - Return the entry for the specified key, or a default /// constructed value if no such entry exists. - ValueTy lookup(const StringRef &Key) const { + ValueTy lookup(StringRef Key) const { const_iterator it = find(Key); if (it != end()) return it->second; return ValueTy(); } - ValueTy& operator[](const StringRef &Key) { + ValueTy& operator[](StringRef Key) { return GetOrCreateValue(Key).getValue(); } - size_type count(const StringRef &Key) const { + size_type count(StringRef Key) const { return find(Key) == end() ? 0 : 1; } @@ -350,7 +350,7 @@ /// exists, return it. Otherwise, default construct a value, insert it, and /// return. template - StringMapEntry &GetOrCreateValue(const StringRef &Key, + StringMapEntry &GetOrCreateValue(StringRef Key, InitTy Val) { unsigned BucketNo = LookupBucketFor(Key); ItemBucket &Bucket = TheTable[BucketNo]; @@ -373,7 +373,7 @@ return *NewItem; } - StringMapEntry &GetOrCreateValue(const StringRef &Key) { + StringMapEntry &GetOrCreateValue(StringRef Key) { return GetOrCreateValue(Key, ValueTy()); } @@ -401,7 +401,7 @@ V.Destroy(Allocator); } - bool erase(const StringRef &Key) { + bool erase(StringRef Key) { iterator I = find(Key); if (I == end()) return false; erase(I); Modified: llvm/trunk/include/llvm/ADT/StringRef.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringRef.h?rev=86251&r1=86250&r2=86251&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/StringRef.h (original) +++ llvm/trunk/include/llvm/ADT/StringRef.h Fri Nov 6 04:58:06 2009 @@ -92,14 +92,14 @@ /// equals - Check for string equality, this is more efficient than /// compare() when the relative ordering of inequal strings isn't needed. - bool equals(const StringRef &RHS) const { + bool equals(StringRef RHS) const { return (Length == RHS.Length && memcmp(Data, RHS.Data, RHS.Length) == 0); } /// compare - Compare two strings; the result is -1, 0, or 1 if this string /// is lexicographically less than, equal to, or greater than the \arg RHS. - int compare(const StringRef &RHS) const { + int compare(StringRef RHS) const { // Check the prefix for a mismatch. if (int Res = memcmp(Data, RHS.Data, std::min(Length, RHS.Length))) return Res < 0 ? -1 : 1; @@ -135,12 +135,12 @@ /// @{ /// startswith - Check if this string starts with the given \arg Prefix. - bool startswith(const StringRef &Prefix) const { + bool startswith(StringRef Prefix) const { return substr(0, Prefix.Length).equals(Prefix); } /// endswith - Check if this string ends with the given \arg Suffix. - bool endswith(const StringRef &Suffix) const { + bool endswith(StringRef Suffix) const { return slice(size() - Suffix.Length, size()).equals(Suffix); } @@ -163,7 +163,7 @@ /// /// \return - The index of the first occurence of \arg Str, or npos if not /// found. - size_t find(const StringRef &Str) const; + size_t find(StringRef Str) const; /// rfind - Search for the last character \arg C in the string. /// @@ -184,7 +184,7 @@ /// /// \return - The index of the last occurence of \arg Str, or npos if not /// found. - size_t rfind(const StringRef &Str) const; + size_t rfind(StringRef Str) const; /// find_first_of - Find the first instance of the specified character or /// return npos if not in string. Same as find. @@ -213,7 +213,7 @@ /// count - Return the number of non-overlapped occurrences of \arg Str in /// the string. - size_t count(const StringRef &Str) const; + size_t count(StringRef Str) const; /// getAsInteger - Parse the current string as an integer of the specified /// radix. If Radix is specified as zero, this does radix autosensing using @@ -304,27 +304,27 @@ /// @name StringRef Comparison Operators /// @{ - inline bool operator==(const StringRef &LHS, const StringRef &RHS) { + inline bool operator==(StringRef LHS, StringRef RHS) { return LHS.equals(RHS); } - inline bool operator!=(const StringRef &LHS, const StringRef &RHS) { + inline bool operator!=(StringRef LHS, StringRef RHS) { return !(LHS == RHS); } - inline bool operator<(const StringRef &LHS, const StringRef &RHS) { + inline bool operator<(StringRef LHS, StringRef RHS) { return LHS.compare(RHS) == -1; } - inline bool operator<=(const StringRef &LHS, const StringRef &RHS) { + inline bool operator<=(StringRef LHS, StringRef RHS) { return LHS.compare(RHS) != 1; } - inline bool operator>(const StringRef &LHS, const StringRef &RHS) { + inline bool operator>(StringRef LHS, StringRef RHS) { return LHS.compare(RHS) == 1; } - inline bool operator>=(const StringRef &LHS, const StringRef &RHS) { + inline bool operator>=(StringRef LHS, StringRef RHS) { return LHS.compare(RHS) != -1; } Modified: llvm/trunk/include/llvm/ADT/Triple.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/Triple.h?rev=86251&r1=86250&r2=86251&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/Triple.h (original) +++ llvm/trunk/include/llvm/ADT/Triple.h Fri Nov 6 04:58:06 2009 @@ -218,23 +218,23 @@ /// setArchName - Set the architecture (first) component of the /// triple by name. - void setArchName(const StringRef &Str); + void setArchName(StringRef Str); /// setVendorName - Set the vendor (second) component of the triple /// by name. - void setVendorName(const StringRef &Str); + void setVendorName(StringRef Str); /// setOSName - Set the operating system (third) component of the /// triple by name. - void setOSName(const StringRef &Str); + void setOSName(StringRef Str); /// setEnvironmentName - Set the optional environment (fourth) /// component of the triple by name. - void setEnvironmentName(const StringRef &Str); + void setEnvironmentName(StringRef Str); /// setOSAndEnvironmentName - Set the operating system and optional /// environment components with a single string. - void setOSAndEnvironmentName(const StringRef &Str); + void setOSAndEnvironmentName(StringRef Str); /// @} /// @name Static helpers for IDs. @@ -265,12 +265,12 @@ /// getArchTypeForLLVMName - The canonical type for the given LLVM /// architecture name (e.g., "x86"). - static ArchType getArchTypeForLLVMName(const StringRef &Str); + static ArchType getArchTypeForLLVMName(StringRef Str); /// getArchTypeForDarwinArchName - Get the architecture type for a "Darwin" /// architecture name, for example as accepted by "gcc -arch" (see also /// arch(3)). - static ArchType getArchTypeForDarwinArchName(const StringRef &Str); + static ArchType getArchTypeForDarwinArchName(StringRef Str); /// @} }; Modified: llvm/trunk/include/llvm/Bitcode/BitstreamWriter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/BitstreamWriter.h?rev=86251&r1=86250&r2=86251&view=diff ============================================================================== --- llvm/trunk/include/llvm/Bitcode/BitstreamWriter.h (original) +++ llvm/trunk/include/llvm/Bitcode/BitstreamWriter.h Fri Nov 6 04:58:06 2009 @@ -294,7 +294,7 @@ /// known to exist at the end of the the record. template void EmitRecordWithAbbrevImpl(unsigned Abbrev, SmallVectorImpl &Vals, - const StringRef &Blob) { + StringRef Blob) { const char *BlobData = Blob.data(); unsigned BlobLen = (unsigned) Blob.size(); unsigned AbbrevNo = Abbrev-bitc::FIRST_APPLICATION_ABBREV; @@ -422,7 +422,7 @@ /// of the record. template void EmitRecordWithBlob(unsigned Abbrev, SmallVectorImpl &Vals, - const StringRef &Blob) { + StringRef Blob) { EmitRecordWithAbbrevImpl(Abbrev, Vals, Blob); } template @@ -435,7 +435,7 @@ /// that end with an array. template void EmitRecordWithArray(unsigned Abbrev, SmallVectorImpl &Vals, - const StringRef &Array) { + StringRef Array) { EmitRecordWithAbbrevImpl(Abbrev, Vals, Array); } template Modified: llvm/trunk/include/llvm/Constants.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Constants.h?rev=86251&r1=86250&r2=86251&view=diff ============================================================================== --- llvm/trunk/include/llvm/Constants.h (original) +++ llvm/trunk/include/llvm/Constants.h Fri Nov 6 04:58:06 2009 @@ -86,7 +86,7 @@ /// Return a ConstantInt constructed from the string strStart with the given /// radix. - static ConstantInt *get(const IntegerType *Ty, const StringRef &Str, + static ConstantInt *get(const IntegerType *Ty, StringRef Str, uint8_t radix); /// If Ty is a vector type, return a Constant with a splat of the given @@ -255,7 +255,7 @@ /// only be used for simple constant values like 2.0/1.0 etc, that are /// known-valid both as host double and as the target format. static Constant *get(const Type* Ty, double V); - static Constant *get(const Type* Ty, const StringRef &Str); + static Constant *get(const Type* Ty, StringRef Str); static ConstantFP *get(LLVMContext &Context, const APFloat &V); static ConstantFP *getNegativeZero(const Type* Ty); static ConstantFP *getInfinity(const Type *Ty, bool Negative = false); @@ -353,7 +353,7 @@ /// of the array by one (you've been warned). However, in some situations /// this is not desired so if AddNull==false then the string is copied without /// null termination. - static Constant *get(LLVMContext &Context, const StringRef &Initializer, + static Constant *get(LLVMContext &Context, StringRef Initializer, bool AddNull = true); /// Transparently provide more efficient getOperand methods. Modified: llvm/trunk/include/llvm/GlobalValue.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/GlobalValue.h?rev=86251&r1=86250&r2=86251&view=diff ============================================================================== --- llvm/trunk/include/llvm/GlobalValue.h (original) +++ llvm/trunk/include/llvm/GlobalValue.h Fri Nov 6 04:58:06 2009 @@ -90,7 +90,7 @@ bool hasSection() const { return !Section.empty(); } const std::string &getSection() const { return Section; } - void setSection(const StringRef &S) { Section = S; } + void setSection(StringRef S) { Section = S; } /// If the usage is empty (except transitively dead constants), then this /// global value can can be safely deleted since the destructor will Modified: llvm/trunk/include/llvm/InlineAsm.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/InlineAsm.h?rev=86251&r1=86250&r2=86251&view=diff ============================================================================== --- llvm/trunk/include/llvm/InlineAsm.h (original) +++ llvm/trunk/include/llvm/InlineAsm.h Fri Nov 6 04:58:06 2009 @@ -33,16 +33,16 @@ bool HasSideEffects; bool IsAlignStack; - InlineAsm(const FunctionType *Ty, const StringRef &AsmString, - const StringRef &Constraints, bool hasSideEffects, + InlineAsm(const FunctionType *Ty, StringRef AsmString, + StringRef Constraints, bool hasSideEffects, bool isAlignStack = false); virtual ~InlineAsm(); public: /// InlineAsm::get - Return the the specified uniqued inline asm string. /// - static InlineAsm *get(const FunctionType *Ty, const StringRef &AsmString, - const StringRef &Constraints, bool hasSideEffects, + static InlineAsm *get(const FunctionType *Ty, StringRef AsmString, + StringRef Constraints, bool hasSideEffects, bool isAlignStack = false); bool hasSideEffects() const { return HasSideEffects; } @@ -65,7 +65,7 @@ /// the specified constraint string is legal for the type. This returns true /// if legal, false if not. /// - static bool Verify(const FunctionType *Ty, const StringRef &Constraints); + static bool Verify(const FunctionType *Ty, StringRef Constraints); // Constraint String Parsing enum ConstraintPrefix { @@ -110,7 +110,7 @@ /// Parse - Analyze the specified string (e.g. "=*&{eax}") and fill in the /// fields in this structure. If the constraint string is not understood, /// return true, otherwise return false. - bool Parse(const StringRef &Str, + bool Parse(StringRef Str, std::vector &ConstraintsSoFar); }; @@ -118,7 +118,7 @@ /// constraints and their prefixes. If this returns an empty vector, and if /// the constraint string itself isn't empty, there was an error parsing. static std::vector - ParseConstraints(const StringRef &ConstraintString); + ParseConstraints(StringRef ConstraintString); /// ParseConstraints - Parse the constraints of this inlineasm object, /// returning them the same way that ParseConstraints(str) does. Modified: llvm/trunk/include/llvm/Linker.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Linker.h?rev=86251&r1=86250&r2=86251&view=diff ============================================================================== --- llvm/trunk/include/llvm/Linker.h (original) +++ llvm/trunk/include/llvm/Linker.h Fri Nov 6 04:58:06 2009 @@ -65,8 +65,8 @@ /// Construct the Linker with an empty module which will be given the /// name \p progname. \p progname will also be used for error messages. /// @brief Construct with empty module - Linker(const StringRef &progname, ///< name of tool running linker - const StringRef &modulename, ///< name of linker's end-result module + Linker(StringRef progname, ///< name of tool running linker + StringRef modulename, ///< name of linker's end-result module LLVMContext &C, ///< Context for global info unsigned Flags = 0 ///< ControlFlags (one or more |'d together) ); @@ -74,7 +74,7 @@ /// Construct the Linker with a previously defined module, \p aModule. Use /// \p progname for the name of the program in error messages. /// @brief Construct with existing module - Linker(const StringRef& progname, Module* aModule, unsigned Flags = 0); + Linker(StringRef progname, Module* aModule, unsigned Flags = 0); /// Destruct the Linker. /// @brief Destructor @@ -214,8 +214,8 @@ /// @returns true if an error occurs, false otherwise /// @brief Link one library into the module bool LinkInLibrary ( - const StringRef &Library, ///< The library to link in - bool& is_native ///< Indicates if lib a native library + StringRef Library, ///< The library to link in + bool& is_native ///< Indicates if lib a native library ); /// This function links one bitcode archive, \p Filename, into the module. @@ -267,7 +267,7 @@ /// will be empty (i.e. sys::Path::isEmpty() will return true). /// @returns A sys::Path to the found library /// @brief Find a library from its short name. - sys::Path FindLib(const StringRef &Filename); + sys::Path FindLib(StringRef Filename); /// @} /// @name Implementation @@ -277,9 +277,9 @@ /// Module it contains (wrapped in an auto_ptr), or 0 if an error occurs. std::auto_ptr LoadObject(const sys::Path& FN); - bool warning(const StringRef &message); - bool error(const StringRef &message); - void verbose(const StringRef &message); + bool warning(StringRef message); + bool error(StringRef message); + void verbose(StringRef message); /// @} /// @name Data Modified: llvm/trunk/include/llvm/MC/MCAsmLexer.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAsmLexer.h?rev=86251&r1=86250&r2=86251&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCAsmLexer.h (original) +++ llvm/trunk/include/llvm/MC/MCAsmLexer.h Fri Nov 6 04:58:06 2009 @@ -56,7 +56,7 @@ public: AsmToken() {} - AsmToken(TokenKind _Kind, const StringRef &_Str, int64_t _IntVal = 0) + AsmToken(TokenKind _Kind, StringRef _Str, int64_t _IntVal = 0) : Kind(_Kind), Str(_Str), IntVal(_IntVal) {} TokenKind getKind() const { return Kind; } Modified: llvm/trunk/include/llvm/MC/MCContext.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCContext.h?rev=86251&r1=86250&r2=86251&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCContext.h (original) +++ llvm/trunk/include/llvm/MC/MCContext.h Fri Nov 6 04:58:06 2009 @@ -49,7 +49,7 @@ /// CreateSymbol - Create a new symbol with the specified @param Name. /// /// @param Name - The symbol name, which must be unique across all symbols. - MCSymbol *CreateSymbol(const StringRef &Name); + MCSymbol *CreateSymbol(StringRef Name); /// GetOrCreateSymbol - Lookup the symbol inside with the specified /// @param Name. If it exists, return it. If not, create a forward @@ -58,7 +58,7 @@ /// @param Name - The symbol name, which must be unique across all symbols. /// @param IsTemporary - Whether this symbol is an assembler temporary, /// which should not survive into the symbol table for the translation unit. - MCSymbol *GetOrCreateSymbol(const StringRef &Name); + MCSymbol *GetOrCreateSymbol(StringRef Name); MCSymbol *GetOrCreateSymbol(const Twine &Name); /// CreateTemporarySymbol - Create a new temporary symbol with the specified @@ -67,10 +67,10 @@ /// @param Name - The symbol name, for debugging purposes only, temporary /// symbols do not surive assembly. If non-empty the name must be unique /// across all symbols. - MCSymbol *CreateTemporarySymbol(const StringRef &Name = ""); + MCSymbol *CreateTemporarySymbol(StringRef Name = ""); /// LookupSymbol - Get the symbol for @param Name, or null. - MCSymbol *LookupSymbol(const StringRef &Name) const; + MCSymbol *LookupSymbol(StringRef Name) const; /// @} Modified: llvm/trunk/include/llvm/MC/MCExpr.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCExpr.h?rev=86251&r1=86250&r2=86251&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCExpr.h (original) +++ llvm/trunk/include/llvm/MC/MCExpr.h Fri Nov 6 04:58:06 2009 @@ -120,7 +120,7 @@ /// @{ static const MCSymbolRefExpr *Create(const MCSymbol *Symbol, MCContext &Ctx); - static const MCSymbolRefExpr *Create(const StringRef &Name, MCContext &Ctx); + static const MCSymbolRefExpr *Create(StringRef Name, MCContext &Ctx); /// @} /// @name Accessors Modified: llvm/trunk/include/llvm/MC/MCSection.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCSection.h?rev=86251&r1=86250&r2=86251&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCSection.h (original) +++ llvm/trunk/include/llvm/MC/MCSection.h Fri Nov 6 04:58:06 2009 @@ -51,13 +51,13 @@ /// of a syntactic one. bool IsDirective; - MCSectionCOFF(const StringRef &name, bool isDirective, SectionKind K) + MCSectionCOFF(StringRef name, bool isDirective, SectionKind K) : MCSection(K), Name(name), IsDirective(isDirective) { } public: - static MCSectionCOFF *Create(const StringRef &Name, bool IsDirective, - SectionKind K, MCContext &Ctx); + static MCSectionCOFF *Create(StringRef Name, bool IsDirective, + SectionKind K, MCContext &Ctx); const std::string &getName() const { return Name; } bool isDirective() const { return IsDirective; } Modified: llvm/trunk/include/llvm/MC/MCSectionELF.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCSectionELF.h?rev=86251&r1=86250&r2=86251&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCSectionELF.h (original) +++ llvm/trunk/include/llvm/MC/MCSectionELF.h Fri Nov 6 04:58:06 2009 @@ -35,13 +35,13 @@ bool IsExplicit; protected: - MCSectionELF(const StringRef &Section, unsigned type, unsigned flags, + MCSectionELF(StringRef Section, unsigned type, unsigned flags, SectionKind K, bool isExplicit) : MCSection(K), SectionName(Section.str()), Type(type), Flags(flags), IsExplicit(isExplicit) {} public: - static MCSectionELF *Create(const StringRef &Section, unsigned Type, + static MCSectionELF *Create(StringRef Section, unsigned Type, unsigned Flags, SectionKind K, bool isExplicit, MCContext &Ctx); Modified: llvm/trunk/include/llvm/MC/MCSectionMachO.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCSectionMachO.h?rev=86251&r1=86250&r2=86251&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCSectionMachO.h (original) +++ llvm/trunk/include/llvm/MC/MCSectionMachO.h Fri Nov 6 04:58:06 2009 @@ -33,7 +33,7 @@ /// size of stubs, for example. unsigned Reserved2; - MCSectionMachO(const StringRef &Segment, const StringRef &Section, + MCSectionMachO(StringRef Segment, StringRef Section, unsigned TAA, unsigned reserved2, SectionKind K) : MCSection(K), TypeAndAttributes(TAA), Reserved2(reserved2) { assert(Segment.size() <= 16 && Section.size() <= 16 && @@ -52,8 +52,8 @@ } public: - static MCSectionMachO *Create(const StringRef &Segment, - const StringRef &Section, + static MCSectionMachO *Create(StringRef Segment, + StringRef Section, unsigned TypeAndAttributes, unsigned Reserved2, SectionKind K, MCContext &Ctx); Modified: llvm/trunk/include/llvm/MC/MCStreamer.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCStreamer.h?rev=86251&r1=86250&r2=86251&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCStreamer.h (original) +++ llvm/trunk/include/llvm/MC/MCStreamer.h Fri Nov 6 04:58:06 2009 @@ -155,7 +155,7 @@ /// /// This is used to implement assembler directives such as .byte, .ascii, /// etc. - virtual void EmitBytes(const StringRef &Data) = 0; + virtual void EmitBytes(StringRef Data) = 0; /// EmitValue - Emit the expression @param Value into the output as a native /// integer of the given @param Size bytes. Modified: llvm/trunk/include/llvm/MC/MCSymbol.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCSymbol.h?rev=86251&r1=86250&r2=86251&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCSymbol.h (original) +++ llvm/trunk/include/llvm/MC/MCSymbol.h Fri Nov 6 04:58:06 2009 @@ -56,7 +56,7 @@ private: // MCContext creates and uniques these. friend class MCContext; - MCSymbol(const StringRef &_Name, bool _IsTemporary) + MCSymbol(StringRef _Name, bool _IsTemporary) : Name(_Name), Section(0), Value(0), IsTemporary(_IsTemporary) {} MCSymbol(const MCSymbol&); // DO NOT IMPLEMENT Modified: llvm/trunk/include/llvm/Module.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Module.h?rev=86251&r1=86250&r2=86251&view=diff ============================================================================== --- llvm/trunk/include/llvm/Module.h (original) +++ llvm/trunk/include/llvm/Module.h Fri Nov 6 04:58:06 2009 @@ -154,7 +154,7 @@ public: /// The Module constructor. Note that there is no default constructor. You /// must provide a name for the module upon construction. - explicit Module(const StringRef &ModuleID, LLVMContext& C); + explicit Module(StringRef ModuleID, LLVMContext& C); /// The module destructor. This will dropAllReferences. ~Module(); @@ -196,20 +196,20 @@ public: /// Set the module identifier. - void setModuleIdentifier(const StringRef &ID) { ModuleID = ID; } + void setModuleIdentifier(StringRef ID) { ModuleID = ID; } /// Set the data layout - void setDataLayout(const StringRef &DL) { DataLayout = DL; } + void setDataLayout(StringRef DL) { DataLayout = DL; } /// Set the target triple. - void setTargetTriple(const StringRef &T) { TargetTriple = T; } + void setTargetTriple(StringRef T) { TargetTriple = T; } /// Set the module-scope inline assembly blocks. - void setModuleInlineAsm(const StringRef &Asm) { GlobalScopeAsm = Asm; } + void setModuleInlineAsm(StringRef Asm) { GlobalScopeAsm = Asm; } /// Append to the module-scope inline assembly blocks, automatically /// appending a newline to the end. - void appendModuleInlineAsm(const StringRef &Asm) { + void appendModuleInlineAsm(StringRef Asm) { GlobalScopeAsm += Asm; GlobalScopeAsm += '\n'; } @@ -221,7 +221,7 @@ /// getNamedValue - Return the first global value in the module with /// the specified name, of arbitrary type. This method returns null /// if a global with the specified name is not found. - GlobalValue *getNamedValue(const StringRef &Name) const; + GlobalValue *getNamedValue(StringRef Name) const; /// @} /// @name Function Accessors @@ -236,10 +236,10 @@ /// the existing function. /// 4. Finally, the function exists but has the wrong prototype: return the /// function with a constantexpr cast to the right prototype. - Constant *getOrInsertFunction(const StringRef &Name, const FunctionType *T, + Constant *getOrInsertFunction(StringRef Name, const FunctionType *T, AttrListPtr AttributeList); - Constant *getOrInsertFunction(const StringRef &Name, const FunctionType *T); + Constant *getOrInsertFunction(StringRef Name, const FunctionType *T); /// getOrInsertFunction - Look up the specified function in the module symbol /// table. If it does not exist, add a prototype for the function and return @@ -248,21 +248,21 @@ /// named function has a different type. This version of the method takes a /// null terminated list of function arguments, which makes it easier for /// clients to use. - Constant *getOrInsertFunction(const StringRef &Name, + Constant *getOrInsertFunction(StringRef Name, AttrListPtr AttributeList, const Type *RetTy, ...) END_WITH_NULL; /// getOrInsertFunction - Same as above, but without the attributes. - Constant *getOrInsertFunction(const StringRef &Name, const Type *RetTy, ...) + Constant *getOrInsertFunction(StringRef Name, const Type *RetTy, ...) END_WITH_NULL; - Constant *getOrInsertTargetIntrinsic(const StringRef &Name, + Constant *getOrInsertTargetIntrinsic(StringRef Name, const FunctionType *Ty, AttrListPtr AttributeList); /// getFunction - Look up the specified function in the module symbol table. /// If it does not exist, return null. - Function *getFunction(const StringRef &Name) const; + Function *getFunction(StringRef Name) const; /// @} /// @name Global Variable Accessors @@ -272,13 +272,13 @@ /// symbol table. If it does not exist, return null. If AllowInternal is set /// to true, this function will return types that have InternalLinkage. By /// default, these types are not returned. - GlobalVariable *getGlobalVariable(const StringRef &Name, + GlobalVariable *getGlobalVariable(StringRef Name, bool AllowInternal = false) const; /// getNamedGlobal - Return the first global variable in the module with the /// specified name, of arbitrary type. This method returns null if a global /// with the specified name is not found. - GlobalVariable *getNamedGlobal(const StringRef &Name) const { + GlobalVariable *getNamedGlobal(StringRef Name) const { return getGlobalVariable(Name, true); } @@ -289,7 +289,7 @@ /// with a constantexpr cast to the right type. /// 3. Finally, if the existing global is the correct delclaration, return /// the existing global. - Constant *getOrInsertGlobal(const StringRef &Name, const Type *Ty); + Constant *getOrInsertGlobal(StringRef Name, const Type *Ty); /// @} /// @name Global Alias Accessors @@ -298,7 +298,7 @@ /// getNamedAlias - Return the first global alias in the module with the /// specified name, of arbitrary type. This method returns null if a global /// with the specified name is not found. - GlobalAlias *getNamedAlias(const StringRef &Name) const; + GlobalAlias *getNamedAlias(StringRef Name) const; /// @} /// @name Named Metadata Accessors @@ -307,12 +307,12 @@ /// getNamedMetadata - Return the first NamedMDNode in the module with the /// specified name. This method returns null if a NamedMDNode with the /// specified name is not found. - NamedMDNode *getNamedMetadata(const StringRef &Name) const; + NamedMDNode *getNamedMetadata(StringRef Name) const; /// getOrInsertNamedMetadata - Return the first named MDNode in the module /// with the specified name. This method returns a new NamedMDNode if a /// NamedMDNode with the specified name is not found. - NamedMDNode *getOrInsertNamedMetadata(const StringRef &Name); + NamedMDNode *getOrInsertNamedMetadata(StringRef Name); /// @} /// @name Type Accessors @@ -321,7 +321,7 @@ /// addTypeName - Insert an entry in the symbol table mapping Str to Type. If /// there is already an entry for this name, true is returned and the symbol /// table is not modified. - bool addTypeName(const StringRef &Name, const Type *Ty); + bool addTypeName(StringRef Name, const Type *Ty); /// getTypeName - If there is at least one entry in the symbol table for the /// specified type, return it. @@ -329,7 +329,7 @@ /// getTypeByName - Return the type with the specified name in this module, or /// null if there is none by that name. - const Type *getTypeByName(const StringRef &Name) const; + const Type *getTypeByName(StringRef Name) const; /// @} /// @name Direct access to the globals list, functions list, and symbol table @@ -415,9 +415,9 @@ /// @brief Returns the number of items in the list of libraries. inline size_t lib_size() const { return LibraryList.size(); } /// @brief Add a library to the list of dependent libraries - void addLibrary(const StringRef &Lib); + void addLibrary(StringRef Lib); /// @brief Remove a library from the list of dependent libraries - void removeLibrary(const StringRef &Lib); + void removeLibrary(StringRef Lib); /// @brief Get all the libraries inline const LibraryListType& getLibraries() const { return LibraryList; } Modified: llvm/trunk/include/llvm/Pass.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Pass.h?rev=86251&r1=86250&r2=86251&view=diff ============================================================================== --- llvm/trunk/include/llvm/Pass.h (original) +++ llvm/trunk/include/llvm/Pass.h Fri Nov 6 04:58:06 2009 @@ -167,7 +167,7 @@ // lookupPassInfo - Return the pass info object for the pass with the given // argument string, or null if it is not known. - static const PassInfo *lookupPassInfo(const StringRef &Arg); + static const PassInfo *lookupPassInfo(StringRef Arg); /// getAnalysisIfAvailable() - Subclasses use this function to /// get analysis information that might be around, for example to update it. Modified: llvm/trunk/include/llvm/PassAnalysisSupport.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/PassAnalysisSupport.h?rev=86251&r1=86250&r2=86251&view=diff ============================================================================== --- llvm/trunk/include/llvm/PassAnalysisSupport.h (original) +++ llvm/trunk/include/llvm/PassAnalysisSupport.h Fri Nov 6 04:58:06 2009 @@ -22,6 +22,7 @@ #include #include "llvm/Pass.h" #include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/StringRef.h" namespace llvm { @@ -95,7 +96,7 @@ // This can be useful when a pass is trivially preserved, but may not be // linked in. Be careful about spelling! // - AnalysisUsage &addPreserved(const StringRef &Arg) { + AnalysisUsage &addPreserved(StringRef Arg) { const PassInfo *PI = Pass::lookupPassInfo(Arg); // If the pass exists, preserve it. Otherwise silently do nothing. if (PI) Preserved.push_back(PI); Modified: llvm/trunk/include/llvm/PassManagers.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/PassManagers.h?rev=86251&r1=86250&r2=86251&view=diff ============================================================================== --- llvm/trunk/include/llvm/PassManagers.h (original) +++ llvm/trunk/include/llvm/PassManagers.h Fri Nov 6 04:58:06 2009 @@ -284,11 +284,11 @@ void removeNotPreservedAnalysis(Pass *P); /// Remove dead passes used by P. - void removeDeadPasses(Pass *P, const StringRef &Msg, + void removeDeadPasses(Pass *P, StringRef Msg, enum PassDebuggingString); /// Remove P. - void freePass(Pass *P, const StringRef &Msg, + void freePass(Pass *P, StringRef Msg, enum PassDebuggingString); /// Add pass P into the PassVector. Update @@ -344,7 +344,7 @@ void dumpLastUses(Pass *P, unsigned Offset) const; void dumpPassArguments() const; void dumpPassInfo(Pass *P, enum PassDebuggingString S1, - enum PassDebuggingString S2, const StringRef &Msg); + enum PassDebuggingString S2, StringRef Msg); void dumpRequiredSet(const Pass *P) const; void dumpPreservedSet(const Pass *P) const; @@ -388,8 +388,8 @@ bool isPassDebuggingExecutionsOrMore() const; private: - void dumpAnalysisUsage(const StringRef &Msg, const Pass *P, - const AnalysisUsage::VectorType &Set) const; + void dumpAnalysisUsage(StringRef Msg, const Pass *P, + const AnalysisUsage::VectorType &Set) const; // Set of available Analysis. This information is used while scheduling // pass. If a pass requires an analysis which is not not available then 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=86251&r1=86250&r2=86251&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/raw_ostream.h (original) +++ llvm/trunk/include/llvm/Support/raw_ostream.h Fri Nov 6 04:58:06 2009 @@ -169,7 +169,7 @@ return *this; } - raw_ostream &operator<<(const StringRef &Str) { + raw_ostream &operator<<(StringRef Str) { // Inline fast path, particularly for strings with a known length. size_t Size = Str.size(); Modified: llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h?rev=86251&r1=86250&r2=86251&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h (original) +++ llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h Fri Nov 6 04:58:06 2009 @@ -15,6 +15,7 @@ #ifndef LLVM_TARGET_TARGETLOWERINGOBJECTFILE_H #define LLVM_TARGET_TARGETLOWERINGOBJECTFILE_H +#include "llvm/ADT/StringRef.h" #include "llvm/MC/SectionKind.h" namespace llvm { @@ -26,7 +27,6 @@ class MCSectionMachO; class MCContext; class GlobalValue; - class StringRef; class TargetMachine; class TargetLoweringObjectFile { @@ -288,14 +288,14 @@ /// getMachOSection - Return the MCSection for the specified mach-o section. /// This requires the operands to be valid. - const MCSectionMachO *getMachOSection(const StringRef &Segment, - const StringRef &Section, + const MCSectionMachO *getMachOSection(StringRef Segment, + StringRef Section, unsigned TypeAndAttributes, SectionKind K) const { return getMachOSection(Segment, Section, TypeAndAttributes, 0, K); } - const MCSectionMachO *getMachOSection(const StringRef &Segment, - const StringRef &Section, + const MCSectionMachO *getMachOSection(StringRef Segment, + StringRef Section, unsigned TypeAndAttributes, unsigned Reserved2, SectionKind K) const; Modified: llvm/trunk/include/llvm/Target/TargetRegistry.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetRegistry.h?rev=86251&r1=86250&r2=86251&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetRegistry.h (original) +++ llvm/trunk/include/llvm/Target/TargetRegistry.h Fri Nov 6 04:58:06 2009 @@ -51,7 +51,7 @@ typedef unsigned (*TripleMatchQualityFnTy)(const std::string &TT); typedef const MCAsmInfo *(*AsmInfoCtorFnTy)(const Target &T, - const StringRef &TT); + StringRef TT); typedef TargetMachine *(*TargetMachineCtorTy)(const Target &T, const std::string &TT, const std::string &Features); @@ -163,7 +163,7 @@ /// feature set; it should always be provided. Generally this should be /// either the target triple from the module, or the target triple of the /// host if that does not exist. - const MCAsmInfo *createAsmInfo(const StringRef &Triple) const { + const MCAsmInfo *createAsmInfo(StringRef Triple) const { if (!AsmInfoCtorFn) return 0; return AsmInfoCtorFn(*this, Triple); @@ -461,7 +461,7 @@ TargetRegistry::RegisterAsmInfo(T, &Allocator); } private: - static const MCAsmInfo *Allocator(const Target &T, const StringRef &TT) { + static const MCAsmInfo *Allocator(const Target &T, StringRef TT) { return new MCAsmInfoImpl(T, TT); } Modified: llvm/trunk/include/llvm/TypeSymbolTable.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/TypeSymbolTable.h?rev=86251&r1=86250&r2=86251&view=diff ============================================================================== --- llvm/trunk/include/llvm/TypeSymbolTable.h (original) +++ llvm/trunk/include/llvm/TypeSymbolTable.h Fri Nov 6 04:58:06 2009 @@ -58,26 +58,26 @@ /// incrementing an integer and appending it to the name, if necessary /// @returns the unique name /// @brief Get a unique name for a type - std::string getUniqueName(const StringRef &BaseName) const; + std::string getUniqueName(StringRef BaseName) const; /// This method finds the type with the given \p name in the type map /// and returns it. /// @returns null if the name is not found, otherwise the Type /// associated with the \p name. /// @brief Lookup a type by name. - Type *lookup(const StringRef &name) const; + Type *lookup(StringRef name) const; /// Lookup the type associated with name. /// @returns end() if the name is not found, or an iterator at the entry for /// Type. - iterator find(const StringRef &Name) { + iterator find(StringRef Name) { return tmap.find(Name); } /// Lookup the type associated with name. /// @returns end() if the name is not found, or an iterator at the entry for /// Type. - const_iterator find(const StringRef &Name) const { + const_iterator find(StringRef Name) const { return tmap.find(Name); } @@ -119,7 +119,7 @@ /// a many-to-one mapping between names and types. This method allows a type /// with an existing entry in the symbol table to get a new name. /// @brief Insert a type under a new name. - void insert(const StringRef &Name, const Type *Typ); + void insert(StringRef Name, const Type *Typ); /// Remove a type at the specified position in the symbol table. /// @returns the removed Type. Modified: llvm/trunk/include/llvm/ValueSymbolTable.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ValueSymbolTable.h?rev=86251&r1=86250&r2=86251&view=diff ============================================================================== --- llvm/trunk/include/llvm/ValueSymbolTable.h (original) +++ llvm/trunk/include/llvm/ValueSymbolTable.h Fri Nov 6 04:58:06 2009 @@ -69,7 +69,7 @@ /// the symbol table. /// @returns the value associated with the \p Name /// @brief Lookup a named Value. - Value *lookup(const StringRef &Name) const { return vmap.lookup(Name); } + Value *lookup(StringRef Name) const { return vmap.lookup(Name); } /// @returns true iff the symbol table is empty /// @brief Determine if the symbol table is empty @@ -112,7 +112,7 @@ /// createValueName - This method attempts to create a value name and insert /// it into the symbol table with the specified name. If it conflicts, it /// auto-renames the name and returns that instead. - ValueName *createValueName(const StringRef &Name, Value *V); + ValueName *createValueName(StringRef Name, Value *V); /// This method removes a value from the symbol table. It leaves the /// ValueName attached to the value, but it is no longer inserted in the Modified: llvm/trunk/lib/Linker/LinkItems.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/LinkItems.cpp?rev=86251&r1=86250&r2=86251&view=diff ============================================================================== --- llvm/trunk/lib/Linker/LinkItems.cpp (original) +++ llvm/trunk/lib/Linker/LinkItems.cpp Fri Nov 6 04:58:06 2009 @@ -70,7 +70,7 @@ /// LinkInLibrary - links one library into the HeadModule. /// -bool Linker::LinkInLibrary(const StringRef &Lib, bool& is_native) { +bool Linker::LinkInLibrary(StringRef Lib, bool& is_native) { is_native = false; // Determine where this library lives. sys::Path Pathname = FindLib(Lib); Modified: llvm/trunk/lib/Linker/Linker.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/Linker.cpp?rev=86251&r1=86250&r2=86251&view=diff ============================================================================== --- llvm/trunk/lib/Linker/Linker.cpp (original) +++ llvm/trunk/lib/Linker/Linker.cpp Fri Nov 6 04:58:06 2009 @@ -20,8 +20,8 @@ #include "llvm/Config/config.h" using namespace llvm; -Linker::Linker(const StringRef &progname, const StringRef &modname, - LLVMContext& C, unsigned flags): +Linker::Linker(StringRef progname, StringRef modname, + LLVMContext& C, unsigned flags): Context(C), Composite(new Module(modname, C)), LibPaths(), @@ -29,7 +29,7 @@ Error(), ProgramName(progname) { } -Linker::Linker(const StringRef &progname, Module* aModule, unsigned flags) : +Linker::Linker(StringRef progname, Module* aModule, unsigned flags) : Context(aModule->getContext()), Composite(aModule), LibPaths(), @@ -42,7 +42,7 @@ } bool -Linker::error(const StringRef &message) { +Linker::error(StringRef message) { Error = message; if (!(Flags&QuietErrors)) errs() << ProgramName << ": error: " << message << "\n"; @@ -50,7 +50,7 @@ } bool -Linker::warning(const StringRef &message) { +Linker::warning(StringRef message) { Error = message; if (!(Flags&QuietWarnings)) errs() << ProgramName << ": warning: " << message << "\n"; @@ -58,7 +58,7 @@ } void -Linker::verbose(const StringRef &message) { +Linker::verbose(StringRef message) { if (Flags&Verbose) errs() << " " << message << "\n"; } @@ -114,7 +114,7 @@ // IsLibrary - Determine if "Name" is a library in "Directory". Return // a non-empty sys::Path if its found, an empty one otherwise. -static inline sys::Path IsLibrary(const StringRef &Name, +static inline sys::Path IsLibrary(StringRef Name, const sys::Path &Directory) { sys::Path FullPath(Directory); @@ -153,7 +153,7 @@ /// Path if no matching file can be found. /// sys::Path -Linker::FindLib(const StringRef &Filename) { +Linker::FindLib(StringRef Filename) { // Determine if the pathname can be found as it stands. sys::Path FilePath(Filename); if (FilePath.canRead() && Modified: llvm/trunk/lib/MC/MCAsmStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmStreamer.cpp?rev=86251&r1=86250&r2=86251&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCAsmStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCAsmStreamer.cpp Fri Nov 6 04:58:06 2009 @@ -58,7 +58,7 @@ virtual void EmitZerofill(const MCSection *Section, MCSymbol *Symbol = 0, unsigned Size = 0, unsigned ByteAlignment = 0); - virtual void EmitBytes(const StringRef &Data); + virtual void EmitBytes(StringRef Data); virtual void EmitValue(const MCExpr *Value, unsigned Size); @@ -186,7 +186,7 @@ OS << '\n'; } -void MCAsmStreamer::EmitBytes(const StringRef &Data) { +void MCAsmStreamer::EmitBytes(StringRef Data) { assert(CurSection && "Cannot emit contents before setting section!"); for (unsigned i = 0, e = Data.size(); i != e; ++i) OS << ".byte " << (unsigned) (unsigned char) Data[i] << '\n'; Modified: llvm/trunk/lib/MC/MCAssembler.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAssembler.cpp?rev=86251&r1=86250&r2=86251&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCAssembler.cpp (original) +++ llvm/trunk/lib/MC/MCAssembler.cpp Fri Nov 6 04:58:06 2009 @@ -180,7 +180,7 @@ OS << StringRef(Zeros, N % 16); } - void WriteString(const StringRef &Str, unsigned ZeroFillSize = 0) { + void WriteString(StringRef Str, unsigned ZeroFillSize = 0) { OS << Str; if (ZeroFillSize) WriteZeros(ZeroFillSize - Str.size()); Modified: llvm/trunk/lib/MC/MCContext.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCContext.cpp?rev=86251&r1=86250&r2=86251&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCContext.cpp (original) +++ llvm/trunk/lib/MC/MCContext.cpp Fri Nov 6 04:58:06 2009 @@ -23,7 +23,7 @@ // we don't need to free them here. } -MCSymbol *MCContext::CreateSymbol(const StringRef &Name) { +MCSymbol *MCContext::CreateSymbol(StringRef Name) { assert(Name[0] != '\0' && "Normal symbols cannot be unnamed!"); // Create and bind the symbol, and ensure that names are unique. @@ -32,7 +32,7 @@ return Entry = new (*this) MCSymbol(Name, false); } -MCSymbol *MCContext::GetOrCreateSymbol(const StringRef &Name) { +MCSymbol *MCContext::GetOrCreateSymbol(StringRef Name) { MCSymbol *&Entry = Symbols[Name]; if (Entry) return Entry; @@ -46,7 +46,7 @@ } -MCSymbol *MCContext::CreateTemporarySymbol(const StringRef &Name) { +MCSymbol *MCContext::CreateTemporarySymbol(StringRef Name) { // If unnamed, just create a symbol. if (Name.empty()) new (*this) MCSymbol("", true); @@ -57,6 +57,6 @@ return Entry = new (*this) MCSymbol(Name, true); } -MCSymbol *MCContext::LookupSymbol(const StringRef &Name) const { +MCSymbol *MCContext::LookupSymbol(StringRef Name) const { return Symbols.lookup(Name); } Modified: llvm/trunk/lib/MC/MCExpr.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCExpr.cpp?rev=86251&r1=86250&r2=86251&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCExpr.cpp (original) +++ llvm/trunk/lib/MC/MCExpr.cpp Fri Nov 6 04:58:06 2009 @@ -133,8 +133,7 @@ return new (Ctx) MCSymbolRefExpr(Sym); } -const MCSymbolRefExpr *MCSymbolRefExpr::Create(const StringRef &Name, - MCContext &Ctx) { +const MCSymbolRefExpr *MCSymbolRefExpr::Create(StringRef Name, MCContext &Ctx) { return Create(Ctx.GetOrCreateSymbol(Name), Ctx); } Modified: llvm/trunk/lib/MC/MCMachOStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCMachOStreamer.cpp?rev=86251&r1=86250&r2=86251&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCMachOStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCMachOStreamer.cpp Fri Nov 6 04:58:06 2009 @@ -134,7 +134,7 @@ virtual void EmitZerofill(const MCSection *Section, MCSymbol *Symbol = 0, unsigned Size = 0, unsigned ByteAlignment = 0); - virtual void EmitBytes(const StringRef &Data); + virtual void EmitBytes(StringRef Data); virtual void EmitValue(const MCExpr *Value, unsigned Size); @@ -315,7 +315,7 @@ SectData.setAlignment(ByteAlignment); } -void MCMachOStreamer::EmitBytes(const StringRef &Data) { +void MCMachOStreamer::EmitBytes(StringRef Data) { MCDataFragment *DF = dyn_cast_or_null(getCurrentFragment()); if (!DF) DF = new MCDataFragment(CurSectionData); Modified: llvm/trunk/lib/MC/MCNullStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCNullStreamer.cpp?rev=86251&r1=86250&r2=86251&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCNullStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCNullStreamer.cpp Fri Nov 6 04:58:06 2009 @@ -45,7 +45,7 @@ virtual void EmitZerofill(const MCSection *Section, MCSymbol *Symbol = 0, unsigned Size = 0, unsigned ByteAlignment = 0) {} - virtual void EmitBytes(const StringRef &Data) {} + virtual void EmitBytes(StringRef Data) {} virtual void EmitValue(const MCExpr *Value, unsigned Size) {} Modified: llvm/trunk/lib/MC/MCSection.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCSection.cpp?rev=86251&r1=86250&r2=86251&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCSection.cpp (original) +++ llvm/trunk/lib/MC/MCSection.cpp Fri Nov 6 04:58:06 2009 @@ -25,7 +25,7 @@ //===----------------------------------------------------------------------===// MCSectionCOFF *MCSectionCOFF:: -Create(const StringRef &Name, bool IsDirective, SectionKind K, MCContext &Ctx) { +Create(StringRef Name, bool IsDirective, SectionKind K, MCContext &Ctx) { return new (Ctx) MCSectionCOFF(Name, IsDirective, K); } Modified: llvm/trunk/lib/MC/MCSectionELF.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCSectionELF.cpp?rev=86251&r1=86250&r2=86251&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCSectionELF.cpp (original) +++ llvm/trunk/lib/MC/MCSectionELF.cpp Fri Nov 6 04:58:06 2009 @@ -15,7 +15,7 @@ using namespace llvm; MCSectionELF *MCSectionELF:: -Create(const StringRef &Section, unsigned Type, unsigned Flags, +Create(StringRef Section, unsigned Type, unsigned Flags, SectionKind K, bool isExplicit, MCContext &Ctx) { return new (Ctx) MCSectionELF(Section, Type, Flags, K, isExplicit); } Modified: llvm/trunk/lib/MC/MCSectionMachO.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCSectionMachO.cpp?rev=86251&r1=86250&r2=86251&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCSectionMachO.cpp (original) +++ llvm/trunk/lib/MC/MCSectionMachO.cpp Fri Nov 6 04:58:06 2009 @@ -66,7 +66,7 @@ MCSectionMachO *MCSectionMachO:: -Create(const StringRef &Segment, const StringRef &Section, +Create(StringRef Segment, StringRef Section, unsigned TypeAndAttributes, unsigned Reserved2, SectionKind K, MCContext &Ctx) { // S_SYMBOL_STUBS must be set for Reserved2 to be non-zero. Modified: llvm/trunk/lib/MC/MCSymbol.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCSymbol.cpp?rev=86251&r1=86250&r2=86251&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCSymbol.cpp (original) +++ llvm/trunk/lib/MC/MCSymbol.cpp Fri Nov 6 04:58:06 2009 @@ -35,7 +35,7 @@ /// NameNeedsEscaping - Return true if the identifier \arg Str needs quotes /// for this assembler. -static bool NameNeedsEscaping(const StringRef &Str, const MCAsmInfo &MAI) { +static bool NameNeedsEscaping(StringRef Str, const MCAsmInfo &MAI) { assert(!Str.empty() && "Cannot create an empty MCSymbol"); // If the first character is a number and the target does not allow this, we Modified: llvm/trunk/lib/Support/StringMap.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/StringMap.cpp?rev=86251&r1=86250&r2=86251&view=diff ============================================================================== --- llvm/trunk/lib/Support/StringMap.cpp (original) +++ llvm/trunk/lib/Support/StringMap.cpp Fri Nov 6 04:58:06 2009 @@ -52,7 +52,7 @@ /// specified bucket will be non-null. Otherwise, it will be null. In either /// case, the FullHashValue field of the bucket will be set to the hash value /// of the string. -unsigned StringMapImpl::LookupBucketFor(const StringRef &Name) { +unsigned StringMapImpl::LookupBucketFor(StringRef Name) { unsigned HTSize = NumBuckets; if (HTSize == 0) { // Hash table unallocated so far? init(16); @@ -110,7 +110,7 @@ /// FindKey - Look up the bucket that contains the specified key. If it exists /// in the map, return the bucket number of the key. Otherwise return -1. /// This does not modify the map. -int StringMapImpl::FindKey(const StringRef &Key) const { +int StringMapImpl::FindKey(StringRef Key) const { unsigned HTSize = NumBuckets; if (HTSize == 0) return -1; // Really empty table? unsigned FullHashValue = HashString(Key); @@ -161,7 +161,7 @@ /// RemoveKey - Remove the StringMapEntry for the specified key from the /// table, returning it. If the key is not in the table, this returns null. -StringMapEntryBase *StringMapImpl::RemoveKey(const StringRef &Key) { +StringMapEntryBase *StringMapImpl::RemoveKey(StringRef Key) { int Bucket = FindKey(Key); if (Bucket == -1) return 0; Modified: llvm/trunk/lib/Support/StringRef.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/StringRef.cpp?rev=86251&r1=86250&r2=86251&view=diff ============================================================================== --- llvm/trunk/lib/Support/StringRef.cpp (original) +++ llvm/trunk/lib/Support/StringRef.cpp Fri Nov 6 04:58:06 2009 @@ -24,7 +24,7 @@ /// /// \return - The index of the first occurence of \arg Str, or npos if not /// found. -size_t StringRef::find(const StringRef &Str) const { +size_t StringRef::find(StringRef Str) const { size_t N = Str.size(); if (N > Length) return npos; @@ -38,7 +38,7 @@ /// /// \return - The index of the last occurence of \arg Str, or npos if not /// found. -size_t StringRef::rfind(const StringRef &Str) const { +size_t StringRef::rfind(StringRef Str) const { size_t N = Str.size(); if (N > Length) return npos; @@ -75,7 +75,7 @@ /// count - Return the number of non-overlapped occurrences of \arg Str in /// the string. -size_t StringRef::count(const StringRef &Str) const { +size_t StringRef::count(StringRef Str) const { size_t Count = 0; size_t N = Str.size(); if (N > Length) Modified: llvm/trunk/lib/Support/Triple.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Triple.cpp?rev=86251&r1=86250&r2=86251&view=diff ============================================================================== --- llvm/trunk/lib/Support/Triple.cpp (original) +++ llvm/trunk/lib/Support/Triple.cpp Fri Nov 6 04:58:06 2009 @@ -102,7 +102,7 @@ return ""; } -Triple::ArchType Triple::getArchTypeForLLVMName(const StringRef &Name) { +Triple::ArchType Triple::getArchTypeForLLVMName(StringRef Name) { if (Name == "alpha") return alpha; if (Name == "arm") @@ -141,7 +141,7 @@ return UnknownArch; } -Triple::ArchType Triple::getArchTypeForDarwinArchName(const StringRef &Str) { +Triple::ArchType Triple::getArchTypeForDarwinArchName(StringRef Str) { // See arch(3) and llvm-gcc's driver-driver.c. We don't implement support for // archs which Darwin doesn't use. @@ -393,7 +393,7 @@ setOSName(getOSTypeName(Kind)); } -void Triple::setArchName(const StringRef &Str) { +void Triple::setArchName(StringRef Str) { // Work around a miscompilation bug for Twines in gcc 4.0.3. SmallString<64> Triple; Triple += Str; @@ -404,11 +404,11 @@ setTriple(Triple.str()); } -void Triple::setVendorName(const StringRef &Str) { +void Triple::setVendorName(StringRef Str) { setTriple(getArchName() + "-" + Str + "-" + getOSAndEnvironmentName()); } -void Triple::setOSName(const StringRef &Str) { +void Triple::setOSName(StringRef Str) { if (hasEnvironment()) setTriple(getArchName() + "-" + getVendorName() + "-" + Str + "-" + getEnvironmentName()); @@ -416,11 +416,11 @@ setTriple(getArchName() + "-" + getVendorName() + "-" + Str); } -void Triple::setEnvironmentName(const StringRef &Str) { - setTriple(getArchName() + "-" + getVendorName() + "-" + getOSName() + +void Triple::setEnvironmentName(StringRef Str) { + setTriple(getArchName() + "-" + getVendorName() + "-" + getOSName() + "-" + Str); } -void Triple::setOSAndEnvironmentName(const StringRef &Str) { +void Triple::setOSAndEnvironmentName(StringRef Str) { setTriple(getArchName() + "-" + getVendorName() + "-" + Str); } Modified: llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp?rev=86251&r1=86250&r2=86251&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp Fri Nov 6 04:58:06 2009 @@ -21,8 +21,7 @@ #include "llvm/Target/TargetRegistry.h" using namespace llvm; -static const MCAsmInfo *createMCAsmInfo(const Target &T, - const StringRef &TT) { +static const MCAsmInfo *createMCAsmInfo(const Target &T, StringRef TT) { Triple TheTriple(TT); switch (TheTriple.getOS()) { case Triple::Darwin: Modified: llvm/trunk/lib/Target/PowerPC/PPCTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCTargetMachine.cpp?rev=86251&r1=86250&r2=86251&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCTargetMachine.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/PPCTargetMachine.cpp Fri Nov 6 04:58:06 2009 @@ -20,8 +20,7 @@ #include "llvm/Support/FormattedStream.h" using namespace llvm; -static const MCAsmInfo *createMCAsmInfo(const Target &T, - const StringRef &TT) { +static const MCAsmInfo *createMCAsmInfo(const Target &T, StringRef TT) { Triple TheTriple(TT); bool isPPC64 = TheTriple.getArch() == Triple::ppc64; if (TheTriple.getOS() == Triple::Darwin) Modified: llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp?rev=86251&r1=86250&r2=86251&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp (original) +++ llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Fri Nov 6 04:58:06 2009 @@ -671,7 +671,7 @@ const MCSectionMachO *TargetLoweringObjectFileMachO:: -getMachOSection(const StringRef &Segment, const StringRef &Section, +getMachOSection(StringRef Segment, StringRef Section, unsigned TypeAndAttributes, unsigned Reserved2, SectionKind Kind) const { // We unique sections by their segment/section pair. The returned section Modified: llvm/trunk/lib/Target/X86/X86TargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetMachine.cpp?rev=86251&r1=86250&r2=86251&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86TargetMachine.cpp (original) +++ llvm/trunk/lib/Target/X86/X86TargetMachine.cpp Fri Nov 6 04:58:06 2009 @@ -22,8 +22,7 @@ #include "llvm/Target/TargetRegistry.h" using namespace llvm; -static const MCAsmInfo *createMCAsmInfo(const Target &T, - const StringRef &TT) { +static const MCAsmInfo *createMCAsmInfo(const Target &T, StringRef TT) { Triple TheTriple(TT); switch (TheTriple.getOS()) { case Triple::Darwin: Modified: llvm/trunk/lib/VMCore/Constants.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Constants.cpp?rev=86251&r1=86250&r2=86251&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Constants.cpp (original) +++ llvm/trunk/lib/VMCore/Constants.cpp Fri Nov 6 04:58:06 2009 @@ -318,7 +318,7 @@ return C; } -ConstantInt* ConstantInt::get(const IntegerType* Ty, const StringRef& Str, +ConstantInt* ConstantInt::get(const IntegerType* Ty, StringRef Str, uint8_t radix) { return get(Ty->getContext(), APInt(Ty->getBitWidth(), Str, radix)); } @@ -362,7 +362,7 @@ } -Constant* ConstantFP::get(const Type* Ty, const StringRef& Str) { +Constant* ConstantFP::get(const Type* Ty, StringRef Str) { LLVMContext &Context = Ty->getContext(); APFloat FV(*TypeToFloatSemantics(Ty->getScalarType()), Str); @@ -508,7 +508,7 @@ /// Otherwise, the length parameter specifies how much of the string to use /// and it won't be null terminated. /// -Constant* ConstantArray::get(LLVMContext &Context, const StringRef &Str, +Constant* ConstantArray::get(LLVMContext &Context, StringRef Str, bool AddNull) { std::vector ElementVals; for (unsigned i = 0; i < Str.size(); ++i) Modified: llvm/trunk/lib/VMCore/InlineAsm.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/InlineAsm.cpp?rev=86251&r1=86250&r2=86251&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/InlineAsm.cpp (original) +++ llvm/trunk/lib/VMCore/InlineAsm.cpp Fri Nov 6 04:58:06 2009 @@ -26,16 +26,16 @@ // NOTE: when memoizing the function type, we have to be careful to handle the // case when the type gets refined. -InlineAsm *InlineAsm::get(const FunctionType *Ty, const StringRef &AsmString, - const StringRef &Constraints, bool hasSideEffects, +InlineAsm *InlineAsm::get(const FunctionType *Ty, StringRef AsmString, + StringRef Constraints, bool hasSideEffects, bool isAlignStack) { // FIXME: memoize! return new InlineAsm(Ty, AsmString, Constraints, hasSideEffects, isAlignStack); } -InlineAsm::InlineAsm(const FunctionType *Ty, const StringRef &asmString, - const StringRef &constraints, bool hasSideEffects, +InlineAsm::InlineAsm(const FunctionType *Ty, StringRef asmString, + StringRef constraints, bool hasSideEffects, bool isAlignStack) : Value(PointerType::getUnqual(Ty), Value::InlineAsmVal), @@ -54,7 +54,7 @@ /// Parse - Analyze the specified string (e.g. "==&{eax}") and fill in the /// fields in this structure. If the constraint string is not understood, /// return true, otherwise return false. -bool InlineAsm::ConstraintInfo::Parse(const StringRef &Str, +bool InlineAsm::ConstraintInfo::Parse(StringRef Str, std::vector &ConstraintsSoFar) { StringRef::iterator I = Str.begin(), E = Str.end(); @@ -149,7 +149,7 @@ } std::vector -InlineAsm::ParseConstraints(const StringRef &Constraints) { +InlineAsm::ParseConstraints(StringRef Constraints) { std::vector Result; // Scan the constraints string. @@ -183,7 +183,7 @@ /// Verify - Verify that the specified constraint string is reasonable for the /// specified function type, and otherwise validate the constraint string. -bool InlineAsm::Verify(const FunctionType *Ty, const StringRef &ConstStr) { +bool InlineAsm::Verify(const FunctionType *Ty, StringRef ConstStr) { if (Ty->isVarArg()) return false; std::vector Constraints = ParseConstraints(ConstStr); Modified: llvm/trunk/lib/VMCore/Module.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Module.cpp?rev=86251&r1=86250&r2=86251&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Module.cpp (original) +++ llvm/trunk/lib/VMCore/Module.cpp Fri Nov 6 04:58:06 2009 @@ -55,7 +55,7 @@ // Primitive Module methods. // -Module::Module(const StringRef &MID, LLVMContext& C) +Module::Module(StringRef MID, LLVMContext& C) : Context(C), ModuleID(MID), DataLayout("") { ValSymTab = new ValueSymbolTable(); TypeSymTab = new TypeSymbolTable(); @@ -114,7 +114,7 @@ /// getNamedValue - Return the first global value in the module with /// the specified name, of arbitrary type. This method returns null /// if a global with the specified name is not found. -GlobalValue *Module::getNamedValue(const StringRef &Name) const { +GlobalValue *Module::getNamedValue(StringRef Name) const { return cast_or_null(getValueSymbolTable().lookup(Name)); } @@ -127,7 +127,7 @@ // it. This is nice because it allows most passes to get away with not handling // the symbol table directly for this common task. // -Constant *Module::getOrInsertFunction(const StringRef &Name, +Constant *Module::getOrInsertFunction(StringRef Name, const FunctionType *Ty, AttrListPtr AttributeList) { // See if we have a definition for the specified function already. @@ -160,7 +160,7 @@ return F; } -Constant *Module::getOrInsertTargetIntrinsic(const StringRef &Name, +Constant *Module::getOrInsertTargetIntrinsic(StringRef Name, const FunctionType *Ty, AttrListPtr AttributeList) { // See if we have a definition for the specified function already. @@ -177,7 +177,7 @@ return F; } -Constant *Module::getOrInsertFunction(const StringRef &Name, +Constant *Module::getOrInsertFunction(StringRef Name, const FunctionType *Ty) { AttrListPtr AttributeList = AttrListPtr::get((AttributeWithIndex *)0, 0); return getOrInsertFunction(Name, Ty, AttributeList); @@ -188,7 +188,7 @@ // This version of the method takes a null terminated list of function // arguments, which makes it easier for clients to use. // -Constant *Module::getOrInsertFunction(const StringRef &Name, +Constant *Module::getOrInsertFunction(StringRef Name, AttrListPtr AttributeList, const Type *RetTy, ...) { va_list Args; @@ -207,7 +207,7 @@ AttributeList); } -Constant *Module::getOrInsertFunction(const StringRef &Name, +Constant *Module::getOrInsertFunction(StringRef Name, const Type *RetTy, ...) { va_list Args; va_start(Args, RetTy); @@ -228,7 +228,7 @@ // getFunction - Look up the specified function in the module symbol table. // If it does not exist, return null. // -Function *Module::getFunction(const StringRef &Name) const { +Function *Module::getFunction(StringRef Name) const { return dyn_cast_or_null(getNamedValue(Name)); } @@ -243,7 +243,7 @@ /// If AllowLocal is set to true, this function will return types that /// have an local. By default, these types are not returned. /// -GlobalVariable *Module::getGlobalVariable(const StringRef &Name, +GlobalVariable *Module::getGlobalVariable(StringRef Name, bool AllowLocal) const { if (GlobalVariable *Result = dyn_cast_or_null(getNamedValue(Name))) @@ -258,7 +258,7 @@ /// with a constantexpr cast to the right type. /// 3. Finally, if the existing global is the correct delclaration, return the /// existing global. -Constant *Module::getOrInsertGlobal(const StringRef &Name, const Type *Ty) { +Constant *Module::getOrInsertGlobal(StringRef Name, const Type *Ty) { // See if we have a definition for the specified global already. GlobalVariable *GV = dyn_cast_or_null(getNamedValue(Name)); if (GV == 0) { @@ -285,21 +285,21 @@ // getNamedAlias - Look up the specified global in the module symbol table. // If it does not exist, return null. // -GlobalAlias *Module::getNamedAlias(const StringRef &Name) const { +GlobalAlias *Module::getNamedAlias(StringRef Name) const { return dyn_cast_or_null(getNamedValue(Name)); } /// getNamedMetadata - Return the first NamedMDNode in the module with the /// specified name. This method returns null if a NamedMDNode with the //// specified name is not found. -NamedMDNode *Module::getNamedMetadata(const StringRef &Name) const { +NamedMDNode *Module::getNamedMetadata(StringRef Name) const { return dyn_cast_or_null(getValueSymbolTable().lookup(Name)); } /// getOrInsertNamedMetadata - Return the first named MDNode in the module /// with the specified name. This method returns a new NamedMDNode if a /// NamedMDNode with the specified name is not found. -NamedMDNode *Module::getOrInsertNamedMetadata(const StringRef &Name) { +NamedMDNode *Module::getOrInsertNamedMetadata(StringRef Name) { NamedMDNode *NMD = dyn_cast_or_null(getValueSymbolTable().lookup(Name)); if (!NMD) @@ -316,7 +316,7 @@ // there is already an entry for this name, true is returned and the symbol // table is not modified. // -bool Module::addTypeName(const StringRef &Name, const Type *Ty) { +bool Module::addTypeName(StringRef Name, const Type *Ty) { TypeSymbolTable &ST = getTypeSymbolTable(); if (ST.lookup(Name)) return true; // Already in symtab... @@ -330,7 +330,7 @@ /// getTypeByName - Return the type with the specified name in this module, or /// null if there is none by that name. -const Type *Module::getTypeByName(const StringRef &Name) const { +const Type *Module::getTypeByName(StringRef Name) const { const TypeSymbolTable &ST = getTypeSymbolTable(); return cast_or_null(ST.lookup(Name)); } @@ -376,14 +376,14 @@ I->dropAllReferences(); } -void Module::addLibrary(const StringRef& Lib) { +void Module::addLibrary(StringRef Lib) { for (Module::lib_iterator I = lib_begin(), E = lib_end(); I != E; ++I) if (*I == Lib) return; LibraryList.push_back(Lib); } -void Module::removeLibrary(const StringRef& Lib) { +void Module::removeLibrary(StringRef Lib) { LibraryListType::iterator I = LibraryList.begin(); LibraryListType::iterator E = LibraryList.end(); for (;I != E; ++I) Modified: llvm/trunk/lib/VMCore/Pass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Pass.cpp?rev=86251&r1=86250&r2=86251&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Pass.cpp (original) +++ llvm/trunk/lib/VMCore/Pass.cpp Fri Nov 6 04:58:06 2009 @@ -149,7 +149,7 @@ return I != PassInfoMap.end() ? I->second : 0; } - const PassInfo *GetPassInfo(const StringRef &Arg) const { + const PassInfo *GetPassInfo(StringRef Arg) const { StringMapType::const_iterator I = PassInfoStringMap.find(Arg); return I != PassInfoStringMap.end() ? I->second : 0; } @@ -238,7 +238,7 @@ return getPassRegistrar()->GetPassInfo(TI); } -const PassInfo *Pass::lookupPassInfo(const StringRef &Arg) { +const PassInfo *Pass::lookupPassInfo(StringRef Arg) { return getPassRegistrar()->GetPassInfo(Arg); } Modified: llvm/trunk/lib/VMCore/PassManager.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/PassManager.cpp?rev=86251&r1=86250&r2=86251&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/PassManager.cpp (original) +++ llvm/trunk/lib/VMCore/PassManager.cpp Fri Nov 6 04:58:06 2009 @@ -746,7 +746,7 @@ } /// Remove analysis passes that are not used any longer -void PMDataManager::removeDeadPasses(Pass *P, const StringRef &Msg, +void PMDataManager::removeDeadPasses(Pass *P, StringRef Msg, enum PassDebuggingString DBG_STR) { SmallVector DeadPasses; @@ -768,7 +768,7 @@ freePass(*I, Msg, DBG_STR); } -void PMDataManager::freePass(Pass *P, const StringRef &Msg, +void PMDataManager::freePass(Pass *P, StringRef Msg, enum PassDebuggingString DBG_STR) { dumpPassInfo(P, FREEING_MSG, DBG_STR, Msg); @@ -972,7 +972,7 @@ void PMDataManager::dumpPassInfo(Pass *P, enum PassDebuggingString S1, enum PassDebuggingString S2, - const StringRef &Msg) { + StringRef Msg) { if (PassDebugging < Executions) return; errs() << (void*)this << std::string(getDepth()*2+1, ' '); @@ -1028,7 +1028,7 @@ dumpAnalysisUsage("Preserved", P, analysisUsage.getPreservedSet()); } -void PMDataManager::dumpAnalysisUsage(const StringRef &Msg, const Pass *P, +void PMDataManager::dumpAnalysisUsage(StringRef Msg, const Pass *P, const AnalysisUsage::VectorType &Set) const { assert(PassDebugging >= Details); if (Set.empty()) Modified: llvm/trunk/lib/VMCore/TypeSymbolTable.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/TypeSymbolTable.cpp?rev=86251&r1=86250&r2=86251&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/TypeSymbolTable.cpp (original) +++ llvm/trunk/lib/VMCore/TypeSymbolTable.cpp Fri Nov 6 04:58:06 2009 @@ -31,7 +31,7 @@ } } -std::string TypeSymbolTable::getUniqueName(const StringRef &BaseName) const { +std::string TypeSymbolTable::getUniqueName(StringRef BaseName) const { std::string TryName = BaseName; const_iterator End = tmap.end(); @@ -43,7 +43,7 @@ } // lookup a type by name - returns null on failure -Type* TypeSymbolTable::lookup(const StringRef &Name) const { +Type* TypeSymbolTable::lookup(StringRef Name) const { const_iterator TI = tmap.find(Name); Type* result = 0; if (TI != tmap.end()) @@ -51,7 +51,6 @@ return result; } - // remove - Remove a type from the symbol table... Type* TypeSymbolTable::remove(iterator Entry) { assert(Entry != tmap.end() && "Invalid entry to remove!"); @@ -80,7 +79,7 @@ // insert - Insert a type into the symbol table with the specified name... -void TypeSymbolTable::insert(const StringRef &Name, const Type* T) { +void TypeSymbolTable::insert(StringRef Name, const Type* T) { assert(T && "Can't insert null type into symbol table!"); if (tmap.insert(std::make_pair(Name, T)).second) { Modified: llvm/trunk/lib/VMCore/ValueSymbolTable.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/ValueSymbolTable.cpp?rev=86251&r1=86250&r2=86251&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/ValueSymbolTable.cpp (original) +++ llvm/trunk/lib/VMCore/ValueSymbolTable.cpp Fri Nov 6 04:58:06 2009 @@ -77,7 +77,7 @@ /// createValueName - This method attempts to create a value name and insert /// it into the symbol table with the specified name. If it conflicts, it /// auto-renames the name and returns that instead. -ValueName *ValueSymbolTable::createValueName(const StringRef &Name, Value *V) { +ValueName *ValueSymbolTable::createValueName(StringRef Name, Value *V) { // In the common case, the name is not already in the symbol table. ValueName &Entry = vmap.GetOrCreateValue(Name); if (Entry.getValue() == 0) { From espindola at google.com Fri Nov 6 08:46:47 2009 From: espindola at google.com (Rafael Espindola) Date: Fri, 6 Nov 2009 09:46:47 -0500 Subject: [llvm-commits] [compiler-rt][patch] Build on linux. Avoid extra _ In-Reply-To: <30989189-821F-4611-8B04-A2B85F132293@apple.com> References: <38a0d8450911051836o56e6ac7ewf0b67eeb14a3ef36@mail.gmail.com> <30989189-821F-4611-8B04-A2B85F132293@apple.com> Message-ID: <38a0d8450911060646n2c2d74f5t4486b732455800e@mail.gmail.com> > Hi Rafael, > > Can this just use the __USER_LABEL_PREFIX__ macro? ?On darwin it is "_" on > linux it is "". ?You should be able to token paste that onto the start of a > symbol. The attached patch works for me, but there is a comment on the file about USER_LABEL_PREFIX being broken ... > -Chris > Cheers, -- Rafael ?vila de Esp?ndola -------------- next part -------------- A non-text attachment was scrubbed... Name: shared.patch Type: text/x-diff Size: 311 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091106/54524f86/attachment.bin From anton at korobeynikov.info Fri Nov 6 09:19:02 2009 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Fri, 06 Nov 2009 18:19:02 +0300 Subject: [llvm-commits] [compiler-rt][patch] Build on linux. Avoid extra _ In-Reply-To: <38a0d8450911051836o56e6ac7ewf0b67eeb14a3ef36@mail.gmail.com> References: <38a0d8450911051836o56e6ac7ewf0b67eeb14a3ef36@mail.gmail.com> Message-ID: <1257520742.32230.484.camel@aslstation> > libgcc replacement. I understand that the makefile is deprecated in > favor of cmake, but the patch might at least be an useful reference > for someone working on cmake. Just quick question about "makefile deprecation": does cmake support cross-compiling? -- With best regards, Anton Korobeynikov. Faculty of Mathematics & Mechanics, Saint Petersburg State University. From bob.wilson at apple.com Fri Nov 6 11:30:12 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Fri, 06 Nov 2009 17:30:12 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r86255 - in /llvm-gcc-4.2/trunk/gcc: llvm-convert.cpp llvm-internal.h Message-ID: <200911061730.nA6HUDqt027823@zion.cs.uiuc.edu> Author: bwilson Date: Fri Nov 6 11:30:12 2009 New Revision: 86255 URL: http://llvm.org/viewvc/llvm-project?rev=86255&view=rev Log: Enable use of indirect branches. Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp llvm-gcc-4.2/trunk/gcc/llvm-internal.h 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=86255&r1=86254&r2=86255&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Fri Nov 6 11:30:12 2009 @@ -181,11 +181,6 @@ FuncEHSelector = 0; FuncEHGetTypeID = 0; -#ifndef USEINDIRECTBRANCH - NumAddressTakenBlocks = 0; - IndirectGotoBlock = 0; -#endif - assert(TheTreeToLLVM == 0 && "Reentering function creation?"); TheTreeToLLVM = this; } @@ -728,20 +723,6 @@ EmitPostPads(); EmitUnwindBlock(); -#ifndef USEINDIRECTBRANCH - // If this function takes the address of a label, emit the indirect goto - // block. - if (IndirectGotoBlock) { - EmitBlock(IndirectGotoBlock); - - // Change the default destination to go to one of the other destinations, if - // there is any other dest. - SwitchInst *SI = cast(IndirectGotoBlock->getTerminator()); - if (SI->getNumSuccessors() > 1) - SI->setSuccessor(0, SI->getSuccessor(1)); - } -#endif - // Remove any cached LLVM values that are local to this function. Such values // may be deleted when the optimizers run, so would be dangerous to keep. eraseLocalLLVMValues(); @@ -1059,12 +1040,7 @@ // Constants. case LABEL_DECL: { -#ifdef USEINDIRECTBRANCH LV = LValue(EmitLV_LABEL_DECL(exp), 1); -#else - Value *Ptr = TreeConstantToLLVM::EmitLV_LABEL_DECL(exp); - LV = LValue(Ptr, 1); -#endif break; } case COMPLEX_CST: { @@ -1689,46 +1665,6 @@ } } -#ifndef USEINDIRECTBRANCH -//===----------------------------------------------------------------------===// -// ... Address Of Labels Extension Support ... -//===----------------------------------------------------------------------===// - -/// getIndirectGotoBlockNumber - Return the unique ID of the specified basic -/// block for uses that take the address of it. -Constant *TreeToLLVM::getIndirectGotoBlockNumber(BasicBlock *BB) { - ConstantInt *&Val = AddressTakenBBNumbers[BB]; - if (Val) return Val; - - // Assign the new ID, update AddressTakenBBNumbers to remember it. - uint64_t BlockNo = ++NumAddressTakenBlocks; - BlockNo &= ~0ULL >> (64-TD.getPointerSizeInBits()); - Val = ConstantInt::get(TD.getIntPtrType(Context), BlockNo); - - // Add it to the switch statement in the indirect goto block. - cast(getIndirectGotoBlock()->getTerminator())->addCase(Val, BB); - return Val; -} - -/// getIndirectGotoBlock - Get (and potentially lazily create) the indirect -/// goto block. -BasicBlock *TreeToLLVM::getIndirectGotoBlock() { - if (IndirectGotoBlock) return IndirectGotoBlock; - - // Create a temporary for the value to be switched on. - IndirectGotoValue = CreateTemporary(TD.getIntPtrType(Context)); - - // Create the block, emit a load, and emit the switch in the block. - IndirectGotoBlock = BasicBlock::Create(Context, "indirectgoto"); - Value *Ld = new LoadInst(IndirectGotoValue, "gotodest", IndirectGotoBlock); - SwitchInst::Create(Ld, IndirectGotoBlock, 0, IndirectGotoBlock); - - // Finally, return it. - return IndirectGotoBlock; -} -#endif - - //===----------------------------------------------------------------------===// // ... Control Flow ... //===----------------------------------------------------------------------===// @@ -1746,8 +1682,6 @@ // Direct branch. Builder.CreateBr(getLabelDeclBlock(dest)); } else { - -#ifdef USEINDIRECTBRANCH // Indirect branch. basic_block bb = bb_for_stmt(exp); Value *V = Emit(dest, 0); @@ -1758,21 +1692,6 @@ edge_iterator ei; FOR_EACH_EDGE (e, ei, bb->succs) Br->addDestination(getLabelDeclBlock(tree_block_label(e->dest))); -#else - // Otherwise we have an indirect goto. - BasicBlock *DestBB = getIndirectGotoBlock(); - - // Store the destination block to the GotoValue alloca. - Value *V = Emit(dest, 0); - V = CastToType(Instruction::PtrToInt, V, TD.getIntPtrType(Context)); - Builder.CreateStore(V, IndirectGotoValue); - - // NOTE: This is HORRIBLY INCORRECT in the presence of exception handlers. - // There should be one collector block per cleanup level! Note that - // standard GCC gets this wrong as well. - // - Builder.CreateBr(DestBB); -#endif } EmitBlock(BasicBlock::Create(Context, "")); return 0; @@ -6939,11 +6858,9 @@ return LValue(Builder.CreateStructGEP(Ptr.Ptr, Idx), Alignment); } -#ifdef USEINDIRECTBRANCH Constant *TreeToLLVM::EmitLV_LABEL_DECL(tree exp) { return BlockAddress::get(Fn, getLabelDeclBlock(exp)); } -#endif //===----------------------------------------------------------------------===// // ... Constant Expressions ... @@ -8022,13 +7939,7 @@ "Taking the address of a label that isn't in the current fn!?"); } -#ifdef USEINDIRECTBRANCH return TheTreeToLLVM->EmitLV_LABEL_DECL(exp); -#else - BasicBlock *BB = getLabelDeclBlock(exp); - Constant *C = TheTreeToLLVM->getIndirectGotoBlockNumber(BB); - return TheFolder->CreateIntToPtr(C, Type::getInt8PtrTy(Context)); -#endif } Constant *TreeConstantToLLVM::EmitLV_COMPLEX_CST(tree exp) { Modified: llvm-gcc-4.2/trunk/gcc/llvm-internal.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-internal.h?rev=86255&r1=86254&r2=86255&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-internal.h (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-internal.h Fri Nov 6 11:30:12 2009 @@ -331,24 +331,6 @@ /// FuncEHGetTypeID - Function used to return type id for give typeinfo. Function *FuncEHGetTypeID; -#ifndef USEINDIRECTBRANCH - /// NumAddressTakenBlocks - Count the number of labels whose addresses are - /// taken. - uint64_t NumAddressTakenBlocks; - - /// AddressTakenBBNumbers - For each label with its address taken, we keep - /// track of its unique ID. - std::map AddressTakenBBNumbers; - - /// IndirectGotoBlock - If non-null, the block that indirect goto's in this - /// function branch to. - BasicBlock *IndirectGotoBlock; - - /// IndirectGotoValue - This is set to be the alloca temporary that the - /// indirect goto block switches on. - Value *IndirectGotoValue; -#endif - public: TreeToLLVM(tree_node *fndecl); ~TreeToLLVM(); @@ -364,12 +346,6 @@ /// the address of the result. LValue EmitLV(tree_node *exp); -#ifndef USEINDIRECTBRANCH - /// getIndirectGotoBlockNumber - Return the unique ID of the specified basic - /// block for uses that take the address of it. - Constant *getIndirectGotoBlockNumber(BasicBlock *BB); -#endif - /// getIndirectGotoBlock - Get (and potentially lazily create) the indirect /// goto block. BasicBlock *getIndirectGotoBlock(); @@ -613,11 +589,9 @@ const Type *ResultType, std::vector &Ops); -#ifdef USEINDIRECTBRANCH public: // Helper for taking the address of a label. Constant *EmitLV_LABEL_DECL(tree_node *exp); -#endif }; /// TreeConstantToLLVM - An instance of this class is created and used to From dpatel at apple.com Fri Nov 6 11:58:12 2009 From: dpatel at apple.com (Devang Patel) Date: Fri, 06 Nov 2009 17:58:12 -0000 Subject: [llvm-commits] [llvm] r86259 - in /llvm/trunk: lib/Analysis/DebugInfo.cpp lib/CodeGen/AsmPrinter/DwarfDebug.cpp test/DebugInfo/2009-11-06-NamelessGlobalVariable.ll Message-ID: <200911061758.nA6HwCSF028921@zion.cs.uiuc.edu> Author: dpatel Date: Fri Nov 6 11:58:12 2009 New Revision: 86259 URL: http://llvm.org/viewvc/llvm-project?rev=86259&view=rev Log: Do not bother to emit debug info for nameless global variable. Added: llvm/trunk/test/DebugInfo/2009-11-06-NamelessGlobalVariable.ll Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DebugInfo.cpp?rev=86259&r1=86258&r2=86259&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/DebugInfo.cpp (original) +++ llvm/trunk/lib/Analysis/DebugInfo.cpp Fri Nov 6 11:58:12 2009 @@ -366,6 +366,9 @@ if (isNull()) return false; + if (!getDisplayName()) + return false; + if (getContext().isNull()) return false; Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=86259&r1=86258&r2=86259&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Fri Nov 6 11:58:12 2009 @@ -1098,8 +1098,8 @@ DIE *DwarfDebug::CreateGlobalVariableDIE(CompileUnit *DW_Unit, const DIGlobalVariable &GV) { // If the global variable was optmized out then no need to create debug info entry. - if (!GV.getGlobal()) - return NULL; + if (!GV.getGlobal()) return NULL; + if (!GV.getDisplayName()) return NULL; DIE *GVDie = new DIE(dwarf::DW_TAG_variable); AddString(GVDie, dwarf::DW_AT_name, dwarf::DW_FORM_string, Added: llvm/trunk/test/DebugInfo/2009-11-06-NamelessGlobalVariable.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/2009-11-06-NamelessGlobalVariable.ll?rev=86259&view=auto ============================================================================== --- llvm/trunk/test/DebugInfo/2009-11-06-NamelessGlobalVariable.ll (added) +++ llvm/trunk/test/DebugInfo/2009-11-06-NamelessGlobalVariable.ll Fri Nov 6 11:58:12 2009 @@ -0,0 +1,8 @@ +; RUN: llc %s -o /dev/null + at 0 = internal constant i32 1 ; [#uses=1] + +!llvm.dbg.gv = !{!0} + +!0 = metadata !{i32 458804, i32 0, metadata !1, metadata !"", metadata !"", metadata !"", metadata !1, i32 378, metadata !2, i1 true, i1 true, i32* @0}; [DW_TAG_variable ] +!1 = metadata !{i32 458769, i32 0, i32 1, metadata !"cbdsqr.f", metadata !"/home/duncan/LLVM/dragonegg/unsolved/", metadata !"4.5.0 20091030 (experimental)", i1 true, i1 false, metadata !"", i32 0}; [DW_TAG_compile_unit ] +!2 = metadata !{i32 458788, metadata !1, metadata !"integer(kind=4)", metadata !1, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5}; [DW_TAG_base_type ] From gohman at apple.com Fri Nov 6 12:03:10 2009 From: gohman at apple.com (Dan Gohman) Date: Fri, 06 Nov 2009 18:03:10 -0000 Subject: [llvm-commits] [llvm] r86261 - /llvm/trunk/lib/CodeGen/MachineInstr.cpp Message-ID: <200911061803.nA6I3BDq029200@zion.cs.uiuc.edu> Author: djg Date: Fri Nov 6 12:03:10 2009 New Revision: 86261 URL: http://llvm.org/viewvc/llvm-project?rev=86261&view=rev Log: Use WriteAsOperand to print GlobalAddress MachineOperands. This prints them with the leading '@'. Modified: llvm/trunk/lib/CodeGen/MachineInstr.cpp Modified: llvm/trunk/lib/CodeGen/MachineInstr.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineInstr.cpp?rev=86261&r1=86260&r2=86261&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineInstr.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineInstr.cpp Fri Nov 6 12:03:10 2009 @@ -265,7 +265,8 @@ OS << "'; break; case MachineOperand::MO_GlobalAddress: - OS << "getName(); + OS << "'; break; From sabre at nondot.org Fri Nov 6 12:15:15 2009 From: sabre at nondot.org (Chris Lattner) Date: Fri, 06 Nov 2009 18:15:15 -0000 Subject: [llvm-commits] [llvm] r86264 - in /llvm/trunk: lib/Transforms/Scalar/JumpThreading.cpp test/Transforms/JumpThreading/basic.ll Message-ID: <200911061815.nA6IFFud029687@zion.cs.uiuc.edu> Author: lattner Date: Fri Nov 6 12:15:14 2009 New Revision: 86264 URL: http://llvm.org/viewvc/llvm-project?rev=86264&view=rev Log: Extend jump threading to support much more general threading predicates. This allows us to jump thread things like: _ZN12StringSwitchI5ColorE4CaseILj7EEERS1_RAT__KcRKS0_.exit119: %tmp1.i24166 = phi i8 [ 1, %bb5.i117 ], [ %tmp1.i24165, %_Z....exit ], [ %tmp1.i24165, %bb4.i114 ] %toBoolnot.i87 = icmp eq i8 %tmp1.i24166, 0 ; [#uses=1] %tmp4.i90 = icmp eq i32 %tmp2.i, 6 ; [#uses=1] %or.cond173 = and i1 %toBoolnot.i87, %tmp4.i90 ; [#uses=1] br i1 %or.cond173, label %bb4.i96, label %_ZN12... Where it is "obvious" that when coming from %bb5.i117 that the 'and' is always false. This triggers a surprisingly high number of times in the testsuite, and gets us closer to generating good code for doug's strswitch testcase. This also make a bunch of other code in jump threading redundant, I'll rip out in the next patch. This survived an enable-checking llvm-gcc bootstrap. Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp llvm/trunk/test/Transforms/JumpThreading/basic.ll Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=86264&r1=86263&r2=86264&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Fri Nov 6 12:15:14 2009 @@ -75,8 +75,16 @@ bool ThreadEdge(BasicBlock *BB, BasicBlock *PredBB, BasicBlock *SuccBB); bool DuplicateCondBranchOnPHIIntoPred(BasicBlock *BB, BasicBlock *PredBB); - BasicBlock *FactorCommonPHIPreds(PHINode *PN, Value *Val); + + typedef SmallVectorImpl > PredValueInfo; + + bool ComputeValueKnownInPredecessors(Value *V, BasicBlock *BB, + PredValueInfo &Result); + bool ProcessThreadableEdges(Instruction *CondInst, BasicBlock *BB); + + bool ProcessBranchOnDuplicateCond(BasicBlock *PredBB, BasicBlock *DestBB); bool ProcessSwitchOnDuplicateCond(BasicBlock *PredBB, BasicBlock *DestBB); @@ -220,7 +228,133 @@ &CommonPreds[0], CommonPreds.size(), ".thr_comm", this); } + +/// GetResultOfComparison - Given an icmp/fcmp predicate and the left and right +/// hand sides of the compare instruction, try to determine the result. If the +/// result can not be determined, a null pointer is returned. +static Constant *GetResultOfComparison(CmpInst::Predicate pred, + Value *LHS, Value *RHS) { + if (Constant *CLHS = dyn_cast(LHS)) + if (Constant *CRHS = dyn_cast(RHS)) + return ConstantExpr::getCompare(pred, CLHS, CRHS); + + if (LHS == RHS) + if (isa(LHS->getType()) || isa(LHS->getType())) + if (ICmpInst::isTrueWhenEqual(pred)) + return ConstantInt::getTrue(LHS->getContext()); + else + return ConstantInt::getFalse(LHS->getContext()); + return 0; +} + + +/// ComputeValueKnownInPredecessors - Given a basic block BB and a value V, see +/// if we can infer that the value is a known ConstantInt in any of our +/// predecessors. If so, return the known the list of value and pred BB in the +/// result vector. If a value is known to be undef, it is returned as null. +/// +/// The BB basic block is known to start with a PHI node. +/// +/// This returns true if there were any known values. +/// +/// +/// TODO: Per PR2563, we could infer value range information about a predecessor +/// based on its terminator. +bool JumpThreading:: +ComputeValueKnownInPredecessors(Value *V, BasicBlock *BB,PredValueInfo &Result){ + PHINode *TheFirstPHI = cast(BB->begin()); + + // If V is a constantint, then it is known in all predecessors. + if (isa(V) || isa(V)) { + ConstantInt *CI = dyn_cast(V); + Result.resize(TheFirstPHI->getNumIncomingValues()); + for (unsigned i = 0, e = Result.size(); i != e; ++i) + Result.push_back(std::make_pair(CI, TheFirstPHI->getIncomingBlock(i))); + return true; + } + // If V is a non-instruction value, or an instruction in a different block, + // then it can't be derived from a PHI. + Instruction *I = dyn_cast(V); + if (I == 0 || I->getParent() != BB) + return false; + + /// If I is a PHI node, then we know the incoming values for any constants. + if (PHINode *PN = dyn_cast(I)) { + for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) { + Value *InVal = PN->getIncomingValue(i); + if (isa(InVal) || isa(InVal)) { + ConstantInt *CI = dyn_cast(InVal); + Result.push_back(std::make_pair(CI, PN->getIncomingBlock(i))); + } + } + return !Result.empty(); + } + + SmallVector, 8> LHSVals, RHSVals; + + // Handle some boolean conditions. + if (I->getType()->getPrimitiveSizeInBits() == 1) { + // X | true -> true + // X & false -> false + if (I->getOpcode() == Instruction::Or || + I->getOpcode() == Instruction::And) { + ComputeValueKnownInPredecessors(I->getOperand(0), BB, LHSVals); + ComputeValueKnownInPredecessors(I->getOperand(1), BB, RHSVals); + + if (LHSVals.empty() && RHSVals.empty()) + return false; + + ConstantInt *InterestingVal; + if (I->getOpcode() == Instruction::Or) + InterestingVal = ConstantInt::getTrue(I->getContext()); + else + InterestingVal = ConstantInt::getFalse(I->getContext()); + + // Scan for the sentinel. + for (unsigned i = 0, e = LHSVals.size(); i != e; ++i) + if (LHSVals[i].first == InterestingVal || LHSVals[i].first == 0) + Result.push_back(LHSVals[i]); + for (unsigned i = 0, e = RHSVals.size(); i != e; ++i) + if (RHSVals[i].first == InterestingVal || RHSVals[i].first == 0) + Result.push_back(RHSVals[i]); + return !Result.empty(); + } + + // TODO: Should handle the NOT form of XOR. + + } + + // Handle compare with phi operand, where the PHI is defined in this block. + if (CmpInst *Cmp = dyn_cast(I)) { + PHINode *PN = dyn_cast(Cmp->getOperand(0)); + if (PN && PN->getParent() == BB) { + // We can do this simplification if any comparisons fold to true or false. + // See if any do. + for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) { + BasicBlock *PredBB = PN->getIncomingBlock(i); + Value *LHS = PN->getIncomingValue(i); + Value *RHS = Cmp->getOperand(1)->DoPHITranslation(BB, PredBB); + + Constant *Res = GetResultOfComparison(Cmp->getPredicate(), LHS, RHS); + if (Res == 0) continue; + + if (isa(Res)) + Result.push_back(std::make_pair((ConstantInt*)0, PredBB)); + else if (ConstantInt *CI = dyn_cast(Res)) + Result.push_back(std::make_pair(CI, PredBB)); + } + + return !Result.empty(); + } + + // TODO: We could also recurse to see if we can determine constants another + // way. + } + return false; +} + + /// GetBestDestForBranchOnUndef - If we determine that the specified block ends /// in an undefined jump, decide which block is best to revector to. @@ -251,7 +385,7 @@ // successor, merge the blocks. This encourages recursive jump threading // because now the condition in this block can be threaded through // predecessors of our predecessor block. - if (BasicBlock *SinglePred = BB->getSinglePredecessor()) + if (BasicBlock *SinglePred = BB->getSinglePredecessor()) { if (SinglePred->getTerminator()->getNumSuccessors() == 1 && SinglePred != BB) { // If SinglePred was a loop header, BB becomes one. @@ -267,10 +401,10 @@ BB->moveBefore(&BB->getParent()->getEntryBlock()); return true; } - - // See if this block ends with a branch or switch. If so, see if the - // condition is a phi node. If so, and if an entry of the phi node is a - // constant, we can thread the block. + } + + // Look to see if the terminator is a branch of switch, if not we can't thread + // it. Value *Condition; if (BranchInst *BI = dyn_cast(BB->getTerminator())) { // Can't thread an unconditional jump. @@ -369,7 +503,7 @@ } // If we have a comparison, loop over the predecessors to see if there is - // a condition with the same value. + // a condition with a lexically identical value. pred_iterator PI = pred_begin(BB), E = pred_end(BB); for (; PI != E; ++PI) if (BranchInst *PBI = dyn_cast((*PI)->getTerminator())) @@ -402,6 +536,19 @@ if (SimplifyPartiallyRedundantLoad(LI)) return true; + + // Handle a variety of cases where we are branching on something derived from + // a PHI node in the current block. If we can prove that any predecessors + // compute a predictable value based on a PHI node, thread those predecessors. + // + // We only bother doing this if the current block has a PHI node and if the + // conditional instruction lives in the current block. If either condition + // fail, this won't be a computable value anyway. + if (CondInst->getParent() == BB && isa(BB->front())) + if (ProcessThreadableEdges(CondInst, BB)) + return true; + + // TODO: If we have: "br (X > 0)" and we have a predecessor where we know // "(X == 4)" thread through this block. @@ -690,6 +837,176 @@ return true; } +/// FindMostPopularDest - The specified list contains multiple possible +/// threadable destinations. Pick the one that occurs the most frequently in +/// the list. +static BasicBlock * +FindMostPopularDest(BasicBlock *BB, + const SmallVectorImpl > &PredToDestList) { + assert(!PredToDestList.empty()); + + // Determine popularity. If there are multiple possible destinations, we + // explicitly choose to ignore 'undef' destinations. We prefer to thread + // blocks with known and real destinations to threading undef. We'll handle + // them later if interesting. + DenseMap DestPopularity; + for (unsigned i = 0, e = PredToDestList.size(); i != e; ++i) + if (PredToDestList[i].second) + DestPopularity[PredToDestList[i].second]++; + + // Find the most popular dest. + DenseMap::iterator DPI = DestPopularity.begin(); + BasicBlock *MostPopularDest = DPI->first; + unsigned Popularity = DPI->second; + SmallVector SamePopularity; + + for (++DPI; DPI != DestPopularity.end(); ++DPI) { + // If the popularity of this entry isn't higher than the popularity we've + // seen so far, ignore it. + if (DPI->second < Popularity) + ; // ignore. + else if (DPI->second == Popularity) { + // If it is the same as what we've seen so far, keep track of it. + SamePopularity.push_back(DPI->first); + } else { + // If it is more popular, remember it. + SamePopularity.clear(); + MostPopularDest = DPI->first; + Popularity = DPI->second; + } + } + + // Okay, now we know the most popular destination. If there is more than + // destination, we need to determine one. This is arbitrary, but we need + // to make a deterministic decision. Pick the first one that appears in the + // successor list. + if (!SamePopularity.empty()) { + SamePopularity.push_back(MostPopularDest); + TerminatorInst *TI = BB->getTerminator(); + for (unsigned i = 0; ; ++i) { + assert(i != TI->getNumSuccessors() && "Didn't find any successor!"); + + if (std::find(SamePopularity.begin(), SamePopularity.end(), + TI->getSuccessor(i)) == SamePopularity.end()) + continue; + + MostPopularDest = TI->getSuccessor(i); + break; + } + } + + // Okay, we have finally picked the most popular destination. + return MostPopularDest; +} + +bool JumpThreading::ProcessThreadableEdges(Instruction *CondInst, + BasicBlock *BB) { + // If threading this would thread across a loop header, don't even try to + // thread the edge. + if (LoopHeaders.count(BB)) + return false; + + + + SmallVector, 8> PredValues; + if (!ComputeValueKnownInPredecessors(CondInst, BB, PredValues)) + return false; + assert(!PredValues.empty() && + "ComputeValueKnownInPredecessors returned true with no values"); + + DEBUG(errs() << "IN BB: " << *BB; + for (unsigned i = 0, e = PredValues.size(); i != e; ++i) { + errs() << " BB '" << BB->getName() << "': FOUND condition = "; + if (PredValues[i].first) + errs() << *PredValues[i].first; + else + errs() << "UNDEF"; + errs() << " for pred '" << PredValues[i].second->getName() + << "'.\n"; + }); + + // Decide what we want to thread through. Convert our list of known values to + // a list of known destinations for each pred. This also discards duplicate + // predecessors and keeps track of the undefined inputs (which are represented + // as a null dest in the PredToDestList. + SmallPtrSet SeenPreds; + SmallVector, 16> PredToDestList; + + BasicBlock *OnlyDest = 0; + BasicBlock *MultipleDestSentinel = (BasicBlock*)(intptr_t)~0ULL; + + for (unsigned i = 0, e = PredValues.size(); i != e; ++i) { + BasicBlock *Pred = PredValues[i].second; + if (!SeenPreds.insert(Pred)) + continue; // Duplicate predecessor entry. + + // If the predecessor ends with an indirect goto, we can't change its + // destination. + if (isa(Pred->getTerminator())) + continue; + + ConstantInt *Val = PredValues[i].first; + + BasicBlock *DestBB; + if (Val == 0) // Undef. + DestBB = 0; + else if (BranchInst *BI = dyn_cast(BB->getTerminator())) + DestBB = BI->getSuccessor(Val->isZero()); + else { + SwitchInst *SI = cast(BB->getTerminator()); + DestBB = SI->getSuccessor(SI->findCaseValue(Val)); + } + + // If we have exactly one destination, remember it for efficiency below. + if (i == 0) + OnlyDest = DestBB; + else if (OnlyDest != DestBB) + OnlyDest = MultipleDestSentinel; + + PredToDestList.push_back(std::make_pair(Pred, DestBB)); + } + + // If all edges were unthreadable, we fail. + if (PredToDestList.empty()) + return false; + + // Determine which is the most common successor. If we have many inputs and + // this block is a switch, we want to start by threading the batch that goes + // to the most popular destination first. If we only know about one + // threadable destination (the common case) we can avoid this. + BasicBlock *MostPopularDest = OnlyDest; + + if (MostPopularDest == MultipleDestSentinel) + MostPopularDest = FindMostPopularDest(BB, PredToDestList); + + // Now that we know what the most popular destination is, factor all + // predecessors that will jump to it into a single predecessor. + SmallVector PredsToFactor; + for (unsigned i = 0, e = PredToDestList.size(); i != e; ++i) + if (PredToDestList[i].second == MostPopularDest) + PredsToFactor.push_back(PredToDestList[i].first); + + BasicBlock *PredToThread; + if (PredsToFactor.size() == 1) + PredToThread = PredsToFactor[0]; + else { + DEBUG(errs() << " Factoring out " << PredsToFactor.size() + << " common predecessors.\n"); + PredToThread = SplitBlockPredecessors(BB, &PredsToFactor[0], + PredsToFactor.size(), + ".thr_comm", this); + } + + // If the threadable edges are branching on an undefined value, we get to pick + // the destination that these predecessors should get to. + if (MostPopularDest == 0) + MostPopularDest = BB->getTerminator()-> + getSuccessor(GetBestDestForJumpOnUndef(BB)); + + // Ok, try to thread it! + return ThreadEdge(BB, PredToThread, MostPopularDest); +} /// ProcessJumpOnPHI - We have a conditional branch or switch on a PHI node in /// the current block. See if there are any simplifications we can do based on @@ -814,24 +1131,6 @@ return ThreadEdge(BB, PredBB, SuccBB); } -/// GetResultOfComparison - Given an icmp/fcmp predicate and the left and right -/// hand sides of the compare instruction, try to determine the result. If the -/// result can not be determined, a null pointer is returned. -static Constant *GetResultOfComparison(CmpInst::Predicate pred, - Value *LHS, Value *RHS, - LLVMContext &Context) { - if (Constant *CLHS = dyn_cast(LHS)) - if (Constant *CRHS = dyn_cast(RHS)) - return ConstantExpr::getCompare(pred, CLHS, CRHS); - - if (LHS == RHS) - if (isa(LHS->getType()) || isa(LHS->getType())) - return ICmpInst::isTrueWhenEqual(pred) ? - ConstantInt::getTrue(Context) : ConstantInt::getFalse(Context); - - return 0; -} - /// ProcessBranchOnCompare - We found a branch on a comparison between a phi /// node and a value. If we can identify when the comparison is true between /// the phi inputs and the value, we can fold the compare for that edge and @@ -852,8 +1151,7 @@ for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) { PredVal = PN->getIncomingValue(i); - Constant *Res = GetResultOfComparison(Cmp->getPredicate(), PredVal, - RHS, Cmp->getContext()); + Constant *Res = GetResultOfComparison(Cmp->getPredicate(), PredVal, RHS); if (!Res) { PredVal = 0; continue; Modified: llvm/trunk/test/Transforms/JumpThreading/basic.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/JumpThreading/basic.ll?rev=86264&r1=86263&r2=86264&view=diff ============================================================================== --- llvm/trunk/test/Transforms/JumpThreading/basic.ll (original) +++ llvm/trunk/test/Transforms/JumpThreading/basic.ll Fri Nov 6 12:15:14 2009 @@ -170,5 +170,36 @@ } +;; This tests that the branch in 'merge' can be cloned up into T1. +;; rdar://7367025 +define i32 @test7(i1 %cond, i1 %cond2) { +Entry: +; CHECK: @test7 + %v1 = call i32 @f1() + br i1 %cond, label %Merge, label %F1 +F1: + %v2 = call i32 @f2() + br label %Merge + +Merge: + %B = phi i32 [%v1, %Entry], [%v2, %F1] + %M = icmp ne i32 %B, %v1 + %N = icmp eq i32 %B, 47 + %O = and i1 %M, %N + br i1 %O, label %T2, label %F2 + +; CHECK: Merge: +; CHECK-NOT: phi +; CHECK-NEXT: %v2 = call i32 @f2() + +T2: + call void @f3() + ret i32 %B + +F2: + ret i32 %B +; CHECK: F2: +; CHECK-NEXT: phi i32 +} From sabre at nondot.org Fri Nov 6 12:20:58 2009 From: sabre at nondot.org (Chris Lattner) Date: Fri, 06 Nov 2009 18:20:58 -0000 Subject: [llvm-commits] [llvm] r86266 - /llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Message-ID: <200911061820.nA6IKw2J029927@zion.cs.uiuc.edu> Author: lattner Date: Fri Nov 6 12:20:58 2009 New Revision: 86266 URL: http://llvm.org/viewvc/llvm-project?rev=86266&view=rev Log: remove now redundant code, r86264 handles this case. Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=86266&r1=86265&r2=86266&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Fri Nov 6 12:20:58 2009 @@ -89,7 +89,6 @@ bool ProcessSwitchOnDuplicateCond(BasicBlock *PredBB, BasicBlock *DestBB); bool ProcessJumpOnPHI(PHINode *PN); - bool ProcessBranchOnLogical(Value *V, BasicBlock *BB, bool isAnd); bool ProcessBranchOnCompare(CmpInst *Cmp, BasicBlock *BB); bool SimplifyPartiallyRedundantLoad(LoadInst *LI); @@ -480,15 +479,6 @@ if (PN->getParent() == BB) return ProcessJumpOnPHI(PN); - // If this is a conditional branch whose condition is and/or of a phi, try to - // simplify it. - if ((CondInst->getOpcode() == Instruction::And || - CondInst->getOpcode() == Instruction::Or) && - isa(BB->getTerminator()) && - ProcessBranchOnLogical(CondInst, BB, - CondInst->getOpcode() == Instruction::And)) - return true; - if (CmpInst *CondCmp = dyn_cast(CondInst)) { if (isa(CondCmp->getOperand(0))) { // If we have "br (phi != 42)" and the phi node has any constant values @@ -1075,62 +1065,6 @@ return false; } - -/// ProcessJumpOnLogicalPHI - PN's basic block contains a conditional branch -/// whose condition is an AND/OR where one side is PN. If PN has constant -/// operands that permit us to evaluate the condition for some operand, thread -/// through the block. For example with: -/// br (and X, phi(Y, Z, false)) -/// the predecessor corresponding to the 'false' will always jump to the false -/// destination of the branch. -/// -bool JumpThreading::ProcessBranchOnLogical(Value *V, BasicBlock *BB, - bool isAnd) { - // If this is a binary operator tree of the same AND/OR opcode, check the - // LHS/RHS. - if (BinaryOperator *BO = dyn_cast(V)) - if ((isAnd && BO->getOpcode() == Instruction::And) || - (!isAnd && BO->getOpcode() == Instruction::Or)) { - if (ProcessBranchOnLogical(BO->getOperand(0), BB, isAnd)) - return true; - if (ProcessBranchOnLogical(BO->getOperand(1), BB, isAnd)) - return true; - } - - // If this isn't a PHI node, we can't handle it. - PHINode *PN = dyn_cast(V); - if (!PN || PN->getParent() != BB) return false; - - // We can only do the simplification for phi nodes of 'false' with AND or - // 'true' with OR. See if we have any entries in the phi for this. - unsigned PredNo = ~0U; - ConstantInt *PredCst = ConstantInt::get(Type::getInt1Ty(BB->getContext()), - !isAnd); - for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) { - if (PN->getIncomingValue(i) == PredCst) { - PredNo = i; - break; - } - } - - // If no match, bail out. - if (PredNo == ~0U) - return false; - - // If so, we can actually do this threading. Merge any common predecessors - // that will act the same. - BasicBlock *PredBB = FactorCommonPHIPreds(PN, PredCst); - - // Next, figure out which successor we are threading to. If this was an AND, - // the constant must be FALSE, and we must be targeting the 'false' block. - // If this is an OR, the constant must be TRUE, and we must be targeting the - // 'true' block. - BasicBlock *SuccBB = BB->getTerminator()->getSuccessor(isAnd); - - // Ok, try to thread it! - return ThreadEdge(BB, PredBB, SuccBB); -} - /// ProcessBranchOnCompare - We found a branch on a comparison between a phi /// node and a value. If we can identify when the comparison is true between /// the phi inputs and the value, we can fold the compare for that edge and From sabre at nondot.org Fri Nov 6 12:22:55 2009 From: sabre at nondot.org (Chris Lattner) Date: Fri, 06 Nov 2009 18:22:55 -0000 Subject: [llvm-commits] [llvm] r86267 - /llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Message-ID: <200911061822.nA6IMtSt030022@zion.cs.uiuc.edu> Author: lattner Date: Fri Nov 6 12:22:54 2009 New Revision: 86267 URL: http://llvm.org/viewvc/llvm-project?rev=86267&view=rev Log: eliminate some more code subsumed by r86264 Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=86267&r1=86266&r2=86267&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Fri Nov 6 12:22:54 2009 @@ -1005,47 +1005,10 @@ bool JumpThreading::ProcessJumpOnPHI(PHINode *PN) { BasicBlock *BB = PN->getParent(); - // See if the phi node has any constant integer or undef values. If so, we - // can determine where the corresponding predecessor will branch. - for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) { - Value *PredVal = PN->getIncomingValue(i); - - // Check to see if this input is a constant integer. If so, the direction - // of the branch is predictable. - if (ConstantInt *CI = dyn_cast(PredVal)) { - // Merge any common predecessors that will act the same. - BasicBlock *PredBB = FactorCommonPHIPreds(PN, CI); - - BasicBlock *SuccBB; - if (BranchInst *BI = dyn_cast(BB->getTerminator())) - SuccBB = BI->getSuccessor(CI->isZero()); - else { - SwitchInst *SI = cast(BB->getTerminator()); - SuccBB = SI->getSuccessor(SI->findCaseValue(CI)); - } - - // Ok, try to thread it! - return ThreadEdge(BB, PredBB, SuccBB); - } - - // If the input is an undef, then it doesn't matter which way it will go. - // Pick an arbitrary dest and thread the edge. - if (UndefValue *UV = dyn_cast(PredVal)) { - // Merge any common predecessors that will act the same. - BasicBlock *PredBB = FactorCommonPHIPreds(PN, UV); - BasicBlock *SuccBB = - BB->getTerminator()->getSuccessor(GetBestDestForJumpOnUndef(BB)); - - // Ok, try to thread it! - return ThreadEdge(BB, PredBB, SuccBB); - } - } - - // If the incoming values are all variables, we don't know the destination of - // any predecessors. However, if any of the predecessor blocks end in an - // unconditional branch, we can *duplicate* the jump into that block in order - // to further encourage jump threading and to eliminate cases where we have - // branch on a phi of an icmp (branch on icmp is much better). + // If any of the predecessor blocks end in an unconditional branch, we can + // *duplicate* the jump into that block in order to further encourage jump + // threading and to eliminate cases where we have branch on a phi of an icmp + // (branch on icmp is much better). // We don't want to do this tranformation for switches, because we don't // really want to duplicate a switch. From dpatel at apple.com Fri Nov 6 12:24:06 2009 From: dpatel at apple.com (Devang Patel) Date: Fri, 06 Nov 2009 18:24:06 -0000 Subject: [llvm-commits] [llvm] r86269 - in /llvm/trunk: lib/Analysis/DebugInfo.cpp test/DebugInfo/2009-11-06-InvalideDerivedType.ll Message-ID: <200911061824.nA6IO6fL030086@zion.cs.uiuc.edu> Author: dpatel Date: Fri Nov 6 12:24:05 2009 New Revision: 86269 URL: http://llvm.org/viewvc/llvm-project?rev=86269&view=rev Log: Tolerate invalid derived type. Added: llvm/trunk/test/DebugInfo/2009-11-06-InvalideDerivedType.ll Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DebugInfo.cpp?rev=86269&r1=86268&r2=86269&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/DebugInfo.cpp (original) +++ llvm/trunk/lib/Analysis/DebugInfo.cpp Fri Nov 6 12:24:05 2009 @@ -409,6 +409,10 @@ Tag == dwarf::DW_TAG_const_type || Tag == dwarf::DW_TAG_volatile_type || Tag == dwarf::DW_TAG_restrict_type) { DIType BaseType = getTypeDerivedFrom(); + // If this type is not derived from any type then take conservative + // approach. + if (BaseType.isNull()) + return getSizeInBits(); if (BaseType.isDerivedType()) return DIDerivedType(BaseType.getNode()).getOriginalTypeSize(); else Added: llvm/trunk/test/DebugInfo/2009-11-06-InvalideDerivedType.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/2009-11-06-InvalideDerivedType.ll?rev=86269&view=auto ============================================================================== --- llvm/trunk/test/DebugInfo/2009-11-06-InvalideDerivedType.ll (added) +++ llvm/trunk/test/DebugInfo/2009-11-06-InvalideDerivedType.ll Fri Nov 6 12:24:05 2009 @@ -0,0 +1,13 @@ +; RUN: llc %s -o /dev/null +%struct._t = type { i32 } + + at s1 = common global %struct._t zeroinitializer, align 4 ; <%struct._t*> [#uses=0] + +!llvm.dbg.gv = !{!0} + +!0 = metadata !{i32 458804, i32 0, metadata !1, metadata !"s1", metadata !"s1", metadata !"s1", metadata !1, i32 3, metadata !2, i1 false, i1 true, %struct._t* @s1}; [DW_TAG_variable ] +!1 = metadata !{i32 458769, i32 0, i32 12, metadata !"t.c", metadata !"/tmp", metadata !"clang 1.1", i1 true, i1 false, metadata !"", i32 0}; [DW_TAG_compile_unit ] +!2 = metadata !{i32 458771, metadata !1, metadata !"_t", metadata !1, i32 1, i64 32, i64 32, i64 0, i32 0, null, metadata !3, i32 0}; [DW_TAG_structure_type ] +!3 = metadata !{metadata !4} +!4 = metadata !{i32 458765, metadata !1, metadata !"j", metadata !1, i32 2, i64 32, i64 32, i64 0, i32 0, metadata !5}; [DW_TAG_member ] +!5 = metadata !{i32 458790, metadata !1, metadata !"", null, i32 0, i64 0, i64 0, i64 0, i32 0, null}; [DW_TAG_const_type ] From sabre at nondot.org Fri Nov 6 12:24:32 2009 From: sabre at nondot.org (Chris Lattner) Date: Fri, 06 Nov 2009 18:24:32 -0000 Subject: [llvm-commits] [llvm] r86270 - /llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Message-ID: <200911061824.nA6IOWMV030113@zion.cs.uiuc.edu> Author: lattner Date: Fri Nov 6 12:24:32 2009 New Revision: 86270 URL: http://llvm.org/viewvc/llvm-project?rev=86270&view=rev Log: remove more code subsumed by r86264 Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=86270&r1=86269&r2=86270&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Fri Nov 6 12:24:32 2009 @@ -89,7 +89,6 @@ bool ProcessSwitchOnDuplicateCond(BasicBlock *PredBB, BasicBlock *DestBB); bool ProcessJumpOnPHI(PHINode *PN); - bool ProcessBranchOnCompare(CmpInst *Cmp, BasicBlock *BB); bool SimplifyPartiallyRedundantLoad(LoadInst *LI); }; @@ -480,34 +479,25 @@ return ProcessJumpOnPHI(PN); if (CmpInst *CondCmp = dyn_cast(CondInst)) { - if (isa(CondCmp->getOperand(0))) { - // If we have "br (phi != 42)" and the phi node has any constant values - // as operands, we can thread through this block. - // - // If we have "br (cmp phi, x)" and the phi node contains x such that the - // comparison uniquely identifies the branch target, we can thread - // through this block. - - if (ProcessBranchOnCompare(CondCmp, BB)) - return true; - } - - // If we have a comparison, loop over the predecessors to see if there is - // a condition with a lexically identical value. - pred_iterator PI = pred_begin(BB), E = pred_end(BB); - for (; PI != E; ++PI) - if (BranchInst *PBI = dyn_cast((*PI)->getTerminator())) - if (PBI->isConditional() && *PI != BB) { - if (CmpInst *CI = dyn_cast(PBI->getCondition())) { - if (CI->getOperand(0) == CondCmp->getOperand(0) && - CI->getOperand(1) == CondCmp->getOperand(1) && - CI->getPredicate() == CondCmp->getPredicate()) { - // TODO: Could handle things like (x != 4) --> (x == 17) - if (ProcessBranchOnDuplicateCond(*PI, BB)) - return true; + if (!isa(CondCmp->getOperand(0)) || + cast(CondCmp->getOperand(0))->getParent() != BB) { + // If we have a comparison, loop over the predecessors to see if there is + // a condition with a lexically identical value. + pred_iterator PI = pred_begin(BB), E = pred_end(BB); + for (; PI != E; ++PI) + if (BranchInst *PBI = dyn_cast((*PI)->getTerminator())) + if (PBI->isConditional() && *PI != BB) { + if (CmpInst *CI = dyn_cast(PBI->getCondition())) { + if (CI->getOperand(0) == CondCmp->getOperand(0) && + CI->getOperand(1) == CondCmp->getOperand(1) && + CI->getPredicate() == CondCmp->getPredicate()) { + // TODO: Could handle things like (x != 4) --> (x == 17) + if (ProcessBranchOnDuplicateCond(*PI, BB)) + return true; + } } } - } + } } // Check for some cases that are worth simplifying. Right now we want to look @@ -1028,62 +1018,6 @@ return false; } -/// ProcessBranchOnCompare - We found a branch on a comparison between a phi -/// node and a value. If we can identify when the comparison is true between -/// the phi inputs and the value, we can fold the compare for that edge and -/// thread through it. -bool JumpThreading::ProcessBranchOnCompare(CmpInst *Cmp, BasicBlock *BB) { - PHINode *PN = cast(Cmp->getOperand(0)); - Value *RHS = Cmp->getOperand(1); - - // If the phi isn't in the current block, an incoming edge to this block - // doesn't control the destination. - if (PN->getParent() != BB) - return false; - - // We can do this simplification if any comparisons fold to true or false. - // See if any do. - Value *PredVal = 0; - bool TrueDirection = false; - for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) { - PredVal = PN->getIncomingValue(i); - - Constant *Res = GetResultOfComparison(Cmp->getPredicate(), PredVal, RHS); - if (!Res) { - PredVal = 0; - continue; - } - - // If this folded to a constant expr, we can't do anything. - if (ConstantInt *ResC = dyn_cast(Res)) { - TrueDirection = ResC->getZExtValue(); - break; - } - // If this folded to undef, just go the false way. - if (isa(Res)) { - TrueDirection = false; - break; - } - - // Otherwise, we can't fold this input. - PredVal = 0; - } - - // If no match, bail out. - if (PredVal == 0) - return false; - - // If so, we can actually do this threading. Merge any common predecessors - // that will act the same. - BasicBlock *PredBB = FactorCommonPHIPreds(PN, PredVal); - - // Next, get our successor. - BasicBlock *SuccBB = BB->getTerminator()->getSuccessor(!TrueDirection); - - // Ok, try to thread it! - return ThreadEdge(BB, PredBB, SuccBB); -} - /// AddPHINodeEntriesForMappedBlock - We're adding 'NewPred' as a new /// predecessor to the PHIBB block. If it has PHI nodes, add entries for From sabre at nondot.org Fri Nov 6 13:21:48 2009 From: sabre at nondot.org (Chris Lattner) Date: Fri, 06 Nov 2009 19:21:48 -0000 Subject: [llvm-commits] [llvm] r86278 - in /llvm/trunk: lib/Transforms/Scalar/JumpThreading.cpp test/Transforms/JumpThreading/crash.ll Message-ID: <200911061921.nA6JLmo2032247@zion.cs.uiuc.edu> Author: lattner Date: Fri Nov 6 13:21:48 2009 New Revision: 86278 URL: http://llvm.org/viewvc/llvm-project?rev=86278&view=rev Log: Fix a problem discovered on self host. Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp llvm/trunk/test/Transforms/JumpThreading/crash.ll Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=86278&r1=86277&r2=86278&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Fri Nov 6 13:21:48 2009 @@ -267,7 +267,7 @@ ConstantInt *CI = dyn_cast(V); Result.resize(TheFirstPHI->getNumIncomingValues()); for (unsigned i = 0, e = Result.size(); i != e; ++i) - Result.push_back(std::make_pair(CI, TheFirstPHI->getIncomingBlock(i))); + Result[i] = std::make_pair(CI, TheFirstPHI->getIncomingBlock(i)); return true; } Modified: llvm/trunk/test/Transforms/JumpThreading/crash.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/JumpThreading/crash.ll?rev=86278&r1=86277&r2=86278&view=diff ============================================================================== --- llvm/trunk/test/Transforms/JumpThreading/crash.ll (original) +++ llvm/trunk/test/Transforms/JumpThreading/crash.ll Fri Nov 6 13:21:48 2009 @@ -170,3 +170,25 @@ ret i32 1 } + +define fastcc void @test5(i1 %tmp, i32 %tmp1) nounwind ssp { +entry: + br i1 %tmp, label %bb12, label %bb13 + + +bb12: + br label %bb13 + +bb13: + %.lcssa31 = phi i32 [ undef, %bb12 ], [ %tmp1, %entry ] + %A = and i1 undef, undef + br i1 %A, label %bb15, label %bb61 + +bb15: + ret void + + +bb61: + ret void +} + From ggreif at gmail.com Fri Nov 6 14:10:47 2009 From: ggreif at gmail.com (Gabor Greif) Date: Fri, 06 Nov 2009 20:10:47 -0000 Subject: [llvm-commits] [llvm] r86281 - in /llvm/trunk/test/DebugInfo: 2009-11-06-InvalidDerivedType.ll 2009-11-06-InvalideDerivedType.ll Message-ID: <200911062010.nA6KAl7H002008@zion.cs.uiuc.edu> Author: ggreif Date: Fri Nov 6 14:10:46 2009 New Revision: 86281 URL: http://llvm.org/viewvc/llvm-project?rev=86281&view=rev Log: fix typo Added: llvm/trunk/test/DebugInfo/2009-11-06-InvalidDerivedType.ll (props changed) - copied unchanged from r86280, llvm/trunk/test/DebugInfo/2009-11-06-InvalideDerivedType.ll Removed: llvm/trunk/test/DebugInfo/2009-11-06-InvalideDerivedType.ll Propchange: llvm/trunk/test/DebugInfo/2009-11-06-InvalidDerivedType.ll ------------------------------------------------------------------------------ svn:mergeinfo = Removed: llvm/trunk/test/DebugInfo/2009-11-06-InvalideDerivedType.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/2009-11-06-InvalideDerivedType.ll?rev=86280&view=auto ============================================================================== --- llvm/trunk/test/DebugInfo/2009-11-06-InvalideDerivedType.ll (original) +++ llvm/trunk/test/DebugInfo/2009-11-06-InvalideDerivedType.ll (removed) @@ -1,13 +0,0 @@ -; RUN: llc %s -o /dev/null -%struct._t = type { i32 } - - at s1 = common global %struct._t zeroinitializer, align 4 ; <%struct._t*> [#uses=0] - -!llvm.dbg.gv = !{!0} - -!0 = metadata !{i32 458804, i32 0, metadata !1, metadata !"s1", metadata !"s1", metadata !"s1", metadata !1, i32 3, metadata !2, i1 false, i1 true, %struct._t* @s1}; [DW_TAG_variable ] -!1 = metadata !{i32 458769, i32 0, i32 12, metadata !"t.c", metadata !"/tmp", metadata !"clang 1.1", i1 true, i1 false, metadata !"", i32 0}; [DW_TAG_compile_unit ] -!2 = metadata !{i32 458771, metadata !1, metadata !"_t", metadata !1, i32 1, i64 32, i64 32, i64 0, i32 0, null, metadata !3, i32 0}; [DW_TAG_structure_type ] -!3 = metadata !{metadata !4} -!4 = metadata !{i32 458765, metadata !1, metadata !"j", metadata !1, i32 2, i64 32, i64 32, i64 0, i32 0, metadata !5}; [DW_TAG_member ] -!5 = metadata !{i32 458790, metadata !1, metadata !"", null, i32 0, i64 0, i64 0, i64 0, i32 0, null}; [DW_TAG_const_type ] From eli.friedman at gmail.com Fri Nov 6 15:24:58 2009 From: eli.friedman at gmail.com (Eli Friedman) Date: Fri, 06 Nov 2009 21:24:58 -0000 Subject: [llvm-commits] [llvm] r86289 - /llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Message-ID: <200911062124.nA6LOwPp004835@zion.cs.uiuc.edu> Author: efriedma Date: Fri Nov 6 15:24:57 2009 New Revision: 86289 URL: http://llvm.org/viewvc/llvm-project?rev=86289&view=rev Log: Remove function left over from other jump threading cleanup. Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=86289&r1=86288&r2=86289&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Fri Nov 6 15:24:57 2009 @@ -75,7 +75,6 @@ bool ThreadEdge(BasicBlock *BB, BasicBlock *PredBB, BasicBlock *SuccBB); bool DuplicateCondBranchOnPHIIntoPred(BasicBlock *BB, BasicBlock *PredBB); - BasicBlock *FactorCommonPHIPreds(PHINode *PN, Value *Val); typedef SmallVectorImpl > PredValueInfo; @@ -204,29 +203,6 @@ LoopHeaders.insert(const_cast(Edges[i].second)); } - -/// FactorCommonPHIPreds - If there are multiple preds with the same incoming -/// value for the PHI, factor them together so we get one block to thread for -/// the whole group. -/// This is important for things like "phi i1 [true, true, false, true, x]" -/// where we only need to clone the block for the true blocks once. -/// -BasicBlock *JumpThreading::FactorCommonPHIPreds(PHINode *PN, Value *Val) { - SmallVector CommonPreds; - for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) - if (PN->getIncomingValue(i) == Val) - CommonPreds.push_back(PN->getIncomingBlock(i)); - - if (CommonPreds.size() == 1) - return CommonPreds[0]; - - DEBUG(errs() << " Factoring out " << CommonPreds.size() - << " common predecessors.\n"); - return SplitBlockPredecessors(PN->getParent(), - &CommonPreds[0], CommonPreds.size(), - ".thr_comm", this); -} - /// GetResultOfComparison - Given an icmp/fcmp predicate and the left and right /// hand sides of the compare instruction, try to determine the result. If the /// result can not be determined, a null pointer is returned. From vhernandez at apple.com Fri Nov 6 15:43:21 2009 From: vhernandez at apple.com (Victor Hernandez) Date: Fri, 06 Nov 2009 21:43:21 -0000 Subject: [llvm-commits] [llvm] r86290 - /llvm/trunk/lib/VMCore/Instructions.cpp Message-ID: <200911062143.nA6LhL5H005433@zion.cs.uiuc.edu> Author: hernande Date: Fri Nov 6 15:43:21 2009 New Revision: 86290 URL: http://llvm.org/viewvc/llvm-project?rev=86290&view=rev Log: CallInst::CreateMalloc() and CallInst::CreateFree() need to create calls with correct calling convention Modified: llvm/trunk/lib/VMCore/Instructions.cpp Modified: llvm/trunk/lib/VMCore/Instructions.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instructions.cpp?rev=86290&r1=86289&r2=86290&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Instructions.cpp (original) +++ llvm/trunk/lib/VMCore/Instructions.cpp Fri Nov 6 15:43:21 2009 @@ -524,6 +524,7 @@ } } MCall->setTailCall(); + MCall->setCallingConv(MallocF->getCallingConv()); assert(MCall->getType() != Type::getVoidTy(BB->getContext()) && "Malloc has void return type"); @@ -572,8 +573,8 @@ const Type *VoidTy = Type::getVoidTy(M->getContext()); const Type *IntPtrTy = Type::getInt8PtrTy(M->getContext()); // prototype free as "void free(void*)" - Constant *FreeFunc = M->getOrInsertFunction("free", VoidTy, IntPtrTy, NULL); - + Function *FreeFunc = cast(M->getOrInsertFunction("free", VoidTy, + IntPtrTy, NULL)); CallInst* Result = NULL; Value *PtrCast = Source; if (InsertBefore) { @@ -586,6 +587,7 @@ Result = CallInst::Create(FreeFunc, PtrCast, ""); } Result->setTailCall(); + Result->setCallingConv(FreeFunc->getCallingConv()); return Result; } From evan.cheng at apple.com Fri Nov 6 16:24:14 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 06 Nov 2009 22:24:14 -0000 Subject: [llvm-commits] [llvm] r86294 - in /llvm/trunk: lib/Target/ARM/ARMISelLowering.cpp lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp test/CodeGen/ARM/globals.ll Message-ID: <200911062224.nA6MOEGQ006934@zion.cs.uiuc.edu> Author: evancheng Date: Fri Nov 6 16:24:13 2009 New Revision: 86294 URL: http://llvm.org/viewvc/llvm-project?rev=86294&view=rev Log: Remove ARMPCLabelIndex from ARMISelLowering. Use ARMFunctionInfo::createConstPoolEntryUId() instead. Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp llvm/trunk/test/CodeGen/ARM/globals.ll Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=86294&r1=86293&r2=86294&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Fri Nov 6 16:24:13 2009 @@ -133,7 +133,7 @@ } ARMTargetLowering::ARMTargetLowering(TargetMachine &TM) - : TargetLowering(TM, createTLOF(TM)), ARMPCLabelIndex(0) { + : TargetLowering(TM, createTLOF(TM)) { Subtarget = &TM.getSubtarget(); if (Subtarget->isTargetDarwin()) { @@ -1004,6 +1004,8 @@ bool isDirect = false; bool isARMFunc = false; bool isLocalARMFunc = false; + MachineFunction &MF = DAG.getMachineFunction(); + ARMFunctionInfo *AFI = MF.getInfo(); if (GlobalAddressSDNode *G = dyn_cast(Callee)) { GlobalValue *GV = G->getGlobal(); isDirect = true; @@ -1015,6 +1017,7 @@ isLocalARMFunc = !Subtarget->isThumb() && !isExt; // tBX takes a register source operand. if (isARMFunc && Subtarget->isThumb1Only() && !Subtarget->hasV5TOps()) { + unsigned ARMPCLabelIndex = AFI->createConstPoolEntryUId(); ARMConstantPoolValue *CPV = new ARMConstantPoolValue(GV, ARMPCLabelIndex, ARMCP::CPValue, 4); @@ -1023,7 +1026,7 @@ Callee = DAG.getLoad(getPointerTy(), dl, DAG.getEntryNode(), CPAddr, PseudoSourceValue::getConstantPool(), 0); - SDValue PICLabel = DAG.getConstant(ARMPCLabelIndex++, MVT::i32); + SDValue PICLabel = DAG.getConstant(ARMPCLabelIndex, MVT::i32); Callee = DAG.getNode(ARMISD::PIC_ADD, dl, getPointerTy(), Callee, PICLabel); } else @@ -1036,6 +1039,7 @@ // tBX takes a register source operand. const char *Sym = S->getSymbol(); if (isARMFunc && Subtarget->isThumb1Only() && !Subtarget->hasV5TOps()) { + unsigned ARMPCLabelIndex = AFI->createConstPoolEntryUId(); ARMConstantPoolValue *CPV = new ARMConstantPoolValue(*DAG.getContext(), Sym, ARMPCLabelIndex, 4); SDValue CPAddr = DAG.getTargetConstantPool(CPV, getPointerTy(), 4); @@ -1043,7 +1047,7 @@ Callee = DAG.getLoad(getPointerTy(), dl, DAG.getEntryNode(), CPAddr, PseudoSourceValue::getConstantPool(), 0); - SDValue PICLabel = DAG.getConstant(ARMPCLabelIndex++, MVT::i32); + SDValue PICLabel = DAG.getConstant(ARMPCLabelIndex, MVT::i32); Callee = DAG.getNode(ARMISD::PIC_ADD, dl, getPointerTy(), Callee, PICLabel); } else @@ -1208,6 +1212,9 @@ } SDValue ARMTargetLowering::LowerBlockAddress(SDValue Op, SelectionDAG &DAG) { + MachineFunction &MF = DAG.getMachineFunction(); + ARMFunctionInfo *AFI = MF.getInfo(); + unsigned ARMPCLabelIndex = 0; DebugLoc DL = Op.getDebugLoc(); EVT PtrVT = getPointerTy(); BlockAddress *BA = cast(Op)->getBlockAddress(); @@ -1217,6 +1224,7 @@ CPAddr = DAG.getTargetConstantPool(BA, PtrVT, 4); } else { unsigned PCAdj = Subtarget->isThumb() ? 4 : 8; + ARMPCLabelIndex = AFI->createConstPoolEntryUId(); ARMConstantPoolValue *CPV = new ARMConstantPoolValue(BA, ARMPCLabelIndex, ARMCP::CPBlockAddress, PCAdj); @@ -1227,7 +1235,7 @@ PseudoSourceValue::getConstantPool(), 0); if (RelocM == Reloc::Static) return Result; - SDValue PICLabel = DAG.getConstant(ARMPCLabelIndex++, MVT::i32); + SDValue PICLabel = DAG.getConstant(ARMPCLabelIndex, MVT::i32); return DAG.getNode(ARMISD::PIC_ADD, DL, PtrVT, Result, PICLabel); } @@ -1238,6 +1246,9 @@ DebugLoc dl = GA->getDebugLoc(); EVT PtrVT = getPointerTy(); unsigned char PCAdj = Subtarget->isThumb() ? 4 : 8; + MachineFunction &MF = DAG.getMachineFunction(); + ARMFunctionInfo *AFI = MF.getInfo(); + unsigned ARMPCLabelIndex = AFI->createConstPoolEntryUId(); ARMConstantPoolValue *CPV = new ARMConstantPoolValue(GA->getGlobal(), ARMPCLabelIndex, ARMCP::CPValue, PCAdj, "tlsgd", true); @@ -1247,7 +1258,7 @@ PseudoSourceValue::getConstantPool(), 0); SDValue Chain = Argument.getValue(1); - SDValue PICLabel = DAG.getConstant(ARMPCLabelIndex++, MVT::i32); + SDValue PICLabel = DAG.getConstant(ARMPCLabelIndex, MVT::i32); Argument = DAG.getNode(ARMISD::PIC_ADD, dl, PtrVT, Argument, PICLabel); // call __tls_get_addr. @@ -1279,7 +1290,10 @@ SDValue ThreadPointer = DAG.getNode(ARMISD::THREAD_POINTER, dl, PtrVT); if (GV->isDeclaration()) { - // initial exec model + MachineFunction &MF = DAG.getMachineFunction(); + ARMFunctionInfo *AFI = MF.getInfo(); + unsigned ARMPCLabelIndex = AFI->createConstPoolEntryUId(); + // Initial exec model. unsigned char PCAdj = Subtarget->isThumb() ? 4 : 8; ARMConstantPoolValue *CPV = new ARMConstantPoolValue(GA->getGlobal(), ARMPCLabelIndex, @@ -1290,7 +1304,7 @@ PseudoSourceValue::getConstantPool(), 0); Chain = Offset.getValue(1); - SDValue PICLabel = DAG.getConstant(ARMPCLabelIndex++, MVT::i32); + SDValue PICLabel = DAG.getConstant(ARMPCLabelIndex, MVT::i32); Offset = DAG.getNode(ARMISD::PIC_ADD, dl, PtrVT, Offset, PICLabel); Offset = DAG.getLoad(PtrVT, dl, Chain, Offset, @@ -1355,6 +1369,9 @@ SDValue ARMTargetLowering::LowerGlobalAddressDarwin(SDValue Op, SelectionDAG &DAG) { + MachineFunction &MF = DAG.getMachineFunction(); + ARMFunctionInfo *AFI = MF.getInfo(); + unsigned ARMPCLabelIndex = 0; EVT PtrVT = getPointerTy(); DebugLoc dl = Op.getDebugLoc(); GlobalValue *GV = cast(Op)->getGlobal(); @@ -1363,6 +1380,7 @@ if (RelocM == Reloc::Static) CPAddr = DAG.getTargetConstantPool(GV, PtrVT, 4); else { + ARMPCLabelIndex = AFI->createConstPoolEntryUId(); unsigned PCAdj = (RelocM != Reloc::PIC_) ? 0 : (Subtarget->isThumb()?4:8); ARMConstantPoolValue *CPV = new ARMConstantPoolValue(GV, ARMPCLabelIndex, ARMCP::CPValue, PCAdj); @@ -1375,7 +1393,7 @@ SDValue Chain = Result.getValue(1); if (RelocM == Reloc::PIC_) { - SDValue PICLabel = DAG.getConstant(ARMPCLabelIndex++, MVT::i32); + SDValue PICLabel = DAG.getConstant(ARMPCLabelIndex, MVT::i32); Result = DAG.getNode(ARMISD::PIC_ADD, dl, PtrVT, Result, PICLabel); } @@ -1390,6 +1408,9 @@ SelectionDAG &DAG){ assert(Subtarget->isTargetELF() && "GLOBAL OFFSET TABLE not implemented for non-ELF targets"); + MachineFunction &MF = DAG.getMachineFunction(); + ARMFunctionInfo *AFI = MF.getInfo(); + unsigned ARMPCLabelIndex = AFI->createConstPoolEntryUId(); EVT PtrVT = getPointerTy(); DebugLoc dl = Op.getDebugLoc(); unsigned PCAdj = Subtarget->isThumb() ? 4 : 8; @@ -1400,7 +1421,7 @@ CPAddr = DAG.getNode(ARMISD::Wrapper, dl, MVT::i32, CPAddr); SDValue Result = DAG.getLoad(PtrVT, dl, DAG.getEntryNode(), CPAddr, PseudoSourceValue::getConstantPool(), 0); - SDValue PICLabel = DAG.getConstant(ARMPCLabelIndex++, MVT::i32); + SDValue PICLabel = DAG.getConstant(ARMPCLabelIndex, MVT::i32); return DAG.getNode(ARMISD::PIC_ADD, dl, PtrVT, Result, PICLabel); } @@ -1416,6 +1437,8 @@ } case Intrinsic::eh_sjlj_lsda: { MachineFunction &MF = DAG.getMachineFunction(); + ARMFunctionInfo *AFI = MF.getInfo(); + unsigned ARMPCLabelIndex = AFI->createConstPoolEntryUId(); EVT PtrVT = getPointerTy(); DebugLoc dl = Op.getDebugLoc(); Reloc::Model RelocM = getTargetMachine().getRelocationModel(); @@ -1433,7 +1456,7 @@ SDValue Chain = Result.getValue(1); if (RelocM == Reloc::PIC_) { - SDValue PICLabel = DAG.getConstant(ARMPCLabelIndex++, MVT::i32); + SDValue PICLabel = DAG.getConstant(ARMPCLabelIndex, MVT::i32); Result = DAG.getNode(ARMISD::PIC_ADD, dl, PtrVT, Result, PICLabel); } return Result; 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=86294&r1=86293&r2=86294&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Fri Nov 6 16:24:13 2009 @@ -199,7 +199,7 @@ if (ACPV->hasModifier()) O << "(" << ACPV->getModifier() << ")"; if (ACPV->getPCAdjustment() != 0) { O << "-(" << MAI->getPrivateGlobalPrefix() << "PC" - << ACPV->getLabelId() + << getFunctionNumber() << "_" << ACPV->getLabelId() << "+" << (unsigned)ACPV->getPCAdjustment(); if (ACPV->mustAddCurrentAddress()) O << "-."; @@ -844,7 +844,8 @@ void ARMAsmPrinter::printPCLabel(const MachineInstr *MI, int OpNum) { int Id = (int)MI->getOperand(OpNum).getImm(); - O << MAI->getPrivateGlobalPrefix() << "PC" << Id; + O << MAI->getPrivateGlobalPrefix() + << "PC" << getFunctionNumber() << "_" << Id; } void ARMAsmPrinter::printRegisterList(const MachineInstr *MI, int OpNum) { @@ -1364,7 +1365,8 @@ // FIXME: MOVE TO SHARED PLACE. unsigned Id = (unsigned)MI->getOperand(2).getImm(); const char *Prefix = MAI->getPrivateGlobalPrefix(); - MCSymbol *Label =OutContext.GetOrCreateSymbol(Twine(Prefix)+"PC"+Twine(Id)); + MCSymbol *Label =OutContext.GetOrCreateSymbol(Twine(Prefix) + + "PC" + Twine(getFunctionNumber()) + "_" + Twine(Id)); OutStreamer.EmitLabel(Label); Modified: llvm/trunk/test/CodeGen/ARM/globals.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/globals.ll?rev=86294&r1=86293&r2=86294&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/globals.ll (original) +++ llvm/trunk/test/CodeGen/ARM/globals.ll Fri Nov 6 16:24:13 2009 @@ -40,14 +40,14 @@ ; DarwinPIC: _test1: ; DarwinPIC: ldr r0, LCPI1_0 -; DarwinPIC: LPC0: +; DarwinPIC: LPC1_0: ; DarwinPIC: ldr r0, [pc, +r0] ; DarwinPIC: ldr r0, [r0] ; DarwinPIC: bx lr ; DarwinPIC: .align 2 ; DarwinPIC: LCPI1_0: -; DarwinPIC: .long L_G$non_lazy_ptr-(LPC0+8) +; DarwinPIC: .long L_G$non_lazy_ptr-(LPC1_0+8) ; DarwinPIC: .section __DATA,__nl_symbol_ptr,non_lazy_symbol_pointers ; DarwinPIC: .align 2 @@ -61,7 +61,7 @@ ; LinuxPIC: ldr r0, .LCPI1_0 ; LinuxPIC: ldr r1, .LCPI1_1 -; LinuxPIC: .LPC0: +; LinuxPIC: .LPC1_0: ; LinuxPIC: add r0, pc, r0 ; LinuxPIC: ldr r0, [r1, +r0] ; LinuxPIC: ldr r0, [r0] @@ -69,7 +69,7 @@ ; LinuxPIC: .align 2 ; LinuxPIC: .LCPI1_0: -; LinuxPIC: .long _GLOBAL_OFFSET_TABLE_-(.LPC0+8) +; LinuxPIC: .long _GLOBAL_OFFSET_TABLE_-(.LPC1_0+8) ; LinuxPIC: .align 2 ; LinuxPIC: .LCPI1_1: ; LinuxPIC: .long G(GOT) From bob.wilson at apple.com Fri Nov 6 16:38:39 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Fri, 06 Nov 2009 22:38:39 -0000 Subject: [llvm-commits] [llvm] r86295 - /llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Message-ID: <200911062238.nA6McebS007428@zion.cs.uiuc.edu> Author: bwilson Date: Fri Nov 6 16:38:38 2009 New Revision: 86295 URL: http://llvm.org/viewvc/llvm-project?rev=86295&view=rev Log: Fix comment typos. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=86295&r1=86294&r2=86295&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Fri Nov 6 16:38:38 2009 @@ -512,7 +512,7 @@ //===----------------------------------------------------------------------===// /// LEB 128 number encoding. -/// PrintULEB128 - Print a series of hexidecimal values (separated by commas) +/// PrintULEB128 - Print a series of hexadecimal values (separated by commas) /// representing an unsigned leb128 value. void AsmPrinter::PrintULEB128(unsigned Value) const { char Buffer[20]; @@ -525,7 +525,7 @@ } while (Value); } -/// PrintSLEB128 - Print a series of hexidecimal values (separated by commas) +/// PrintSLEB128 - Print a series of hexadecimal values (separated by commas) /// representing a signed leb128 value. void AsmPrinter::PrintSLEB128(int Value) const { int Sign = Value >> (8 * sizeof(Value) - 1); @@ -546,7 +546,7 @@ // Emission and print routines // -/// PrintHex - Print a value as a hexidecimal value. +/// PrintHex - Print a value as a hexadecimal value. /// void AsmPrinter::PrintHex(int Value) const { char Buffer[20]; From echristo at apple.com Fri Nov 6 16:55:02 2009 From: echristo at apple.com (Eric Christopher) Date: Fri, 06 Nov 2009 22:55:02 -0000 Subject: [llvm-commits] [test-suite] r86296 - /test-suite/trunk/SingleSource/Regression/C/packssdw-1.c Message-ID: <200911062255.nA6Mt2uU007996@zion.cs.uiuc.edu> Author: echristo Date: Fri Nov 6 16:55:01 2009 New Revision: 86296 URL: http://llvm.org/viewvc/llvm-project?rev=86296&view=rev Log: Add a very primitive test for packssdw builtins. Added: test-suite/trunk/SingleSource/Regression/C/packssdw-1.c Added: test-suite/trunk/SingleSource/Regression/C/packssdw-1.c URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/packssdw-1.c?rev=86296&view=auto ============================================================================== --- test-suite/trunk/SingleSource/Regression/C/packssdw-1.c (added) +++ test-suite/trunk/SingleSource/Regression/C/packssdw-1.c Fri Nov 6 16:55:01 2009 @@ -0,0 +1,22 @@ +#include +#include + +__v16qi foo (__v4si a, __v4si b) +{ + return __builtin_ia32_packssdw128(a, b); +} + +int main (void) +{ + __v4si a = { 0, 0, 0, 0}; + __v4si b = { 0, 0, 0, 0}; + + __v16qi c = foo(a, b); + + if (__builtin_ia32_vec_ext_v4si((__v4si)c, 0) == 0) + printf("packssdw-1 passed\n"); + else + printf("packssdw-1 failed\n"); + + return 0; +} From bob.wilson at apple.com Fri Nov 6 17:06:42 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Fri, 06 Nov 2009 23:06:42 -0000 Subject: [llvm-commits] [llvm] r86298 - /llvm/trunk/test/CodeGen/Thumb2/load-global.ll Message-ID: <200911062306.nA6N6g77008419@zion.cs.uiuc.edu> Author: bwilson Date: Fri Nov 6 17:06:42 2009 New Revision: 86298 URL: http://llvm.org/viewvc/llvm-project?rev=86298&view=rev Log: Fix a broken test. Modified: llvm/trunk/test/CodeGen/Thumb2/load-global.ll Modified: llvm/trunk/test/CodeGen/Thumb2/load-global.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/load-global.ll?rev=86298&r1=86297&r2=86298&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/load-global.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/load-global.ll Fri Nov 6 17:06:42 2009 @@ -14,7 +14,7 @@ ; PIC: _test1 ; PIC: add r0, pc -; PIC: .long L_G$non_lazy_ptr-(LPC0+4) +; PIC: .long L_G$non_lazy_ptr-(LPC1_0+4) ; LINUX: test1 ; LINUX: .long G(GOT) From sabre at nondot.org Fri Nov 6 17:19:58 2009 From: sabre at nondot.org (Chris Lattner) Date: Fri, 06 Nov 2009 23:19:58 -0000 Subject: [llvm-commits] [llvm] r86299 - /llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Message-ID: <200911062319.nA6NJwuC008894@zion.cs.uiuc.edu> Author: lattner Date: Fri Nov 6 17:19:58 2009 New Revision: 86299 URL: http://llvm.org/viewvc/llvm-project?rev=86299&view=rev Log: Fix a bug where we'd call SplitBlockPredecessors with a pred in the set only once even if it has multiple edges to BB. Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=86299&r1=86298&r2=86299&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Fri Nov 6 17:19:58 2009 @@ -940,8 +940,17 @@ // predecessors that will jump to it into a single predecessor. SmallVector PredsToFactor; for (unsigned i = 0, e = PredToDestList.size(); i != e; ++i) - if (PredToDestList[i].second == MostPopularDest) - PredsToFactor.push_back(PredToDestList[i].first); + if (PredToDestList[i].second == MostPopularDest) { + BasicBlock *Pred = PredToDestList[i].first; + + // This predecessor may be a switch or something else that has multiple + // edges to the block. Factor each of these edges by listing them + // according to # occurrences in PredsToFactor. + TerminatorInst *PredTI = Pred->getTerminator(); + for (unsigned i = 0, e = PredTI->getNumSuccessors(); i != e; ++i) + if (PredTI->getSuccessor(i) == BB) + PredsToFactor.push_back(Pred); + } BasicBlock *PredToThread; if (PredsToFactor.size() == 1) From bob.wilson at apple.com Fri Nov 6 17:33:29 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Fri, 06 Nov 2009 23:33:29 -0000 Subject: [llvm-commits] [llvm] r86301 - in /llvm/trunk: lib/Target/ARM/ARMInstrNEON.td lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp lib/Target/ARM/AsmPrinter/ARMInstPrinter.h test/CodeGen/ARM/vmov.ll Message-ID: <200911062333.nA6NXTwf009476@zion.cs.uiuc.edu> Author: bwilson Date: Fri Nov 6 17:33:28 2009 New Revision: 86301 URL: http://llvm.org/viewvc/llvm-project?rev=86301&view=rev Log: Print VMOV (immediate) operands as hexadecimal values. Apple's assembler will not accept negative values for these. LLVM's default operand printing sign extends values, so that valid unsigned values appear as negative immediates. Print all VMOV immediate operands as hex values to resolve this. Radar 7372576. Modified: llvm/trunk/lib/Target/ARM/ARMInstrNEON.td llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp llvm/trunk/lib/Target/ARM/AsmPrinter/ARMInstPrinter.h llvm/trunk/test/CodeGen/ARM/vmov.ll Modified: llvm/trunk/lib/Target/ARM/ARMInstrNEON.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrNEON.td?rev=86301&r1=86300&r2=86301&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrNEON.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrNEON.td Fri Nov 6 17:33:28 2009 @@ -102,6 +102,19 @@ } */ +def h8imm : Operand { + let PrintMethod = "printHex8ImmOperand"; +} +def h16imm : Operand { + let PrintMethod = "printHex16ImmOperand"; +} +def h32imm : Operand { + let PrintMethod = "printHex32ImmOperand"; +} +def h64imm : Operand { + let PrintMethod = "printHex64ImmOperand"; +} + //===----------------------------------------------------------------------===// // NEON load / store instructions //===----------------------------------------------------------------------===// @@ -2325,38 +2338,38 @@ // be encoded based on the immed values. def VMOVv8i8 : N1ModImm<1, 0b000, 0b1110, 0, 0, 0, 1, (outs DPR:$dst), - (ins i8imm:$SIMM), IIC_VMOVImm, + (ins h8imm:$SIMM), IIC_VMOVImm, "vmov.i8\t$dst, $SIMM", "", [(set DPR:$dst, (v8i8 vmovImm8:$SIMM))]>; def VMOVv16i8 : N1ModImm<1, 0b000, 0b1110, 0, 1, 0, 1, (outs QPR:$dst), - (ins i8imm:$SIMM), IIC_VMOVImm, + (ins h8imm:$SIMM), IIC_VMOVImm, "vmov.i8\t$dst, $SIMM", "", [(set QPR:$dst, (v16i8 vmovImm8:$SIMM))]>; def VMOVv4i16 : N1ModImm<1, 0b000, 0b1000, 0, 0, 0, 1, (outs DPR:$dst), - (ins i16imm:$SIMM), IIC_VMOVImm, + (ins h16imm:$SIMM), IIC_VMOVImm, "vmov.i16\t$dst, $SIMM", "", [(set DPR:$dst, (v4i16 vmovImm16:$SIMM))]>; def VMOVv8i16 : N1ModImm<1, 0b000, 0b1000, 0, 1, 0, 1, (outs QPR:$dst), - (ins i16imm:$SIMM), IIC_VMOVImm, + (ins h16imm:$SIMM), IIC_VMOVImm, "vmov.i16\t$dst, $SIMM", "", [(set QPR:$dst, (v8i16 vmovImm16:$SIMM))]>; def VMOVv2i32 : N1ModImm<1, 0b000, 0b0000, 0, 0, 0, 1, (outs DPR:$dst), - (ins i32imm:$SIMM), IIC_VMOVImm, + (ins h32imm:$SIMM), IIC_VMOVImm, "vmov.i32\t$dst, $SIMM", "", [(set DPR:$dst, (v2i32 vmovImm32:$SIMM))]>; def VMOVv4i32 : N1ModImm<1, 0b000, 0b0000, 0, 1, 0, 1, (outs QPR:$dst), - (ins i32imm:$SIMM), IIC_VMOVImm, + (ins h32imm:$SIMM), IIC_VMOVImm, "vmov.i32\t$dst, $SIMM", "", [(set QPR:$dst, (v4i32 vmovImm32:$SIMM))]>; def VMOVv1i64 : N1ModImm<1, 0b000, 0b1110, 0, 0, 1, 1, (outs DPR:$dst), - (ins i64imm:$SIMM), IIC_VMOVImm, + (ins h64imm:$SIMM), IIC_VMOVImm, "vmov.i64\t$dst, $SIMM", "", [(set DPR:$dst, (v1i64 vmovImm64:$SIMM))]>; def VMOVv2i64 : N1ModImm<1, 0b000, 0b1110, 0, 1, 1, 1, (outs QPR:$dst), - (ins i64imm:$SIMM), IIC_VMOVImm, + (ins h64imm:$SIMM), IIC_VMOVImm, "vmov.i64\t$dst, $SIMM", "", [(set QPR:$dst, (v2i64 vmovImm64:$SIMM))]>; 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=86301&r1=86300&r2=86301&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Fri Nov 6 17:33:28 2009 @@ -43,6 +43,7 @@ #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/Statistic.h" +#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringSet.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/ErrorHandling.h" @@ -138,6 +139,19 @@ void printVFPf32ImmOperand(const MachineInstr *MI, int OpNum); void printVFPf64ImmOperand(const MachineInstr *MI, int OpNum); + void printHex8ImmOperand(const MachineInstr *MI, int OpNum) { + O << "#0x" << utohexstr(MI->getOperand(OpNum).getImm() & 0xff); + } + void printHex16ImmOperand(const MachineInstr *MI, int OpNum) { + O << "#0x" << utohexstr(MI->getOperand(OpNum).getImm() & 0xffff); + } + void printHex32ImmOperand(const MachineInstr *MI, int OpNum) { + O << "#0x" << utohexstr(MI->getOperand(OpNum).getImm() & 0xffffffff); + } + void printHex64ImmOperand(const MachineInstr *MI, int OpNum) { + O << "#0x" << utohexstr(MI->getOperand(OpNum).getImm()); + } + virtual bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNum, unsigned AsmVariant, const char *ExtraCode); virtual bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNum, Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMInstPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmPrinter/ARMInstPrinter.h?rev=86301&r1=86300&r2=86301&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMInstPrinter.h (original) +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMInstPrinter.h Fri Nov 6 17:33:28 2009 @@ -80,6 +80,10 @@ void printNoHashImmediate(const MCInst *MI, unsigned OpNum); void printVFPf32ImmOperand(const MCInst *MI, int OpNum) {} void printVFPf64ImmOperand(const MCInst *MI, int OpNum) {} + void printHex8ImmOperand(const MCInst *MI, int OpNum) {} + void printHex16ImmOperand(const MCInst *MI, int OpNum) {} + void printHex32ImmOperand(const MCInst *MI, int OpNum) {} + void printHex64ImmOperand(const MCInst *MI, int OpNum) {} void printPCLabel(const MCInst *MI, unsigned OpNum); // FIXME: Implement. Modified: llvm/trunk/test/CodeGen/ARM/vmov.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/vmov.ll?rev=86301&r1=86300&r2=86301&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/vmov.ll (original) +++ llvm/trunk/test/CodeGen/ARM/vmov.ll Fri Nov 6 17:33:28 2009 @@ -134,6 +134,26 @@ ret <2 x i64> < i64 18374687574888349695, i64 18374687574888349695 > } +; Check for correct assembler printing for immediate values. +%struct.int8x8_t = type { <8 x i8> } +define arm_apcscc void @vdupn128(%struct.int8x8_t* noalias nocapture sret %agg.result) nounwind { +entry: +;CHECK: vdupn128: +;CHECK: vmov.i8 d0, #0x80 + %0 = getelementptr inbounds %struct.int8x8_t* %agg.result, i32 0, i32 0 ; <<8 x i8>*> [#uses=1] + store <8 x i8> , <8 x i8>* %0, align 8 + ret void +} + +define arm_apcscc void @vdupnneg75(%struct.int8x8_t* noalias nocapture sret %agg.result) nounwind { +entry: +;CHECK: vdupnneg75: +;CHECK: vmov.i8 d0, #0xB5 + %0 = getelementptr inbounds %struct.int8x8_t* %agg.result, i32 0, i32 0 ; <<8 x i8>*> [#uses=1] + store <8 x i8> , <8 x i8>* %0, align 8 + ret void +} + define <8 x i16> @vmovls8(<8 x i8>* %A) nounwind { ;CHECK: vmovls8: ;CHECK: vmovl.s8 From asl at math.spbu.ru Fri Nov 6 17:45:16 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Fri, 06 Nov 2009 23:45:16 -0000 Subject: [llvm-commits] [llvm] r86303 - in /llvm/trunk: lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp test/CodeGen/ARM/2009-11-07-SubRegAsmPrinting.ll Message-ID: <200911062345.nA6NjG1Y009900@zion.cs.uiuc.edu> Author: asl Date: Fri Nov 6 17:45:15 2009 New Revision: 86303 URL: http://llvm.org/viewvc/llvm-project?rev=86303&view=rev Log: Honour subreg machine operands during asmprinting Added: llvm/trunk/test/CodeGen/ARM/2009-11-07-SubRegAsmPrinting.ll 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=86303&r1=86302&r2=86303&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Fri Nov 6 17:45:15 2009 @@ -347,6 +347,9 @@ &ARM::DPR_VFP2RegClass); O << getRegisterName(DReg) << '[' << (RegNum & 1) << ']'; } else { + if (unsigned SubReg = MO.getSubReg()) + Reg = TRI->getSubReg(Reg, SubReg); + O << getRegisterName(Reg); } break; Added: llvm/trunk/test/CodeGen/ARM/2009-11-07-SubRegAsmPrinting.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/2009-11-07-SubRegAsmPrinting.ll?rev=86303&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/2009-11-07-SubRegAsmPrinting.ll (added) +++ llvm/trunk/test/CodeGen/ARM/2009-11-07-SubRegAsmPrinting.ll Fri Nov 6 17:45:15 2009 @@ -0,0 +1,64 @@ +; RUN: llc -mcpu=cortex-a8 < %s | FileCheck %s +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64" +target triple = "armv7-eabi" + +define arm_aapcs_vfpcc void @foo() { +entry: + %0 = load float* null, align 4 ; [#uses=2] + %1 = fmul float %0, undef ; [#uses=2] + %2 = fmul float 0.000000e+00, %1 ; [#uses=2] + %3 = fmul float %0, %1 ; [#uses=1] + %4 = fadd float 0.000000e+00, %3 ; [#uses=1] + %5 = fsub float 1.000000e+00, %4 ; [#uses=1] +; CHECK: foo: +; CHECK: fconsts s{{[0-9]+}}, #112 + %6 = fsub float 1.000000e+00, undef ; [#uses=2] + %7 = fsub float %2, undef ; [#uses=1] + %8 = fsub float 0.000000e+00, undef ; [#uses=3] + %9 = fadd float %2, undef ; [#uses=3] + %10 = load float* undef, align 8 ; [#uses=3] + %11 = fmul float %8, %10 ; [#uses=1] + %12 = fadd float undef, %11 ; [#uses=2] + %13 = fmul float undef, undef ; [#uses=1] + %14 = fmul float %6, 0.000000e+00 ; [#uses=1] + %15 = fadd float %13, %14 ; [#uses=1] + %16 = fmul float %9, %10 ; [#uses=1] + %17 = fadd float %15, %16 ; [#uses=2] + %18 = fmul float 0.000000e+00, undef ; [#uses=1] + %19 = fadd float %18, 0.000000e+00 ; [#uses=1] + %20 = fmul float undef, %10 ; [#uses=1] + %21 = fadd float %19, %20 ; [#uses=1] + %22 = load float* undef, align 8 ; [#uses=1] + %23 = fmul float %5, %22 ; [#uses=1] + %24 = fadd float %23, undef ; [#uses=1] + %25 = load float* undef, align 8 ; [#uses=2] + %26 = fmul float %8, %25 ; [#uses=1] + %27 = fadd float %24, %26 ; [#uses=1] + %28 = fmul float %9, %25 ; [#uses=1] + %29 = fadd float undef, %28 ; [#uses=1] + %30 = fmul float %8, undef ; [#uses=1] + %31 = fadd float undef, %30 ; [#uses=1] + %32 = fmul float %6, undef ; [#uses=1] + %33 = fadd float undef, %32 ; [#uses=1] + %34 = fmul float %9, undef ; [#uses=1] + %35 = fadd float %33, %34 ; [#uses=1] + %36 = fmul float 0.000000e+00, undef ; [#uses=1] + %37 = fmul float %7, undef ; [#uses=1] + %38 = fadd float %36, %37 ; [#uses=1] + %39 = fmul float undef, undef ; [#uses=1] + %40 = fadd float %38, %39 ; [#uses=1] + store float %12, float* undef, align 8 + store float %17, float* undef, align 4 + store float %21, float* undef, align 8 + store float %27, float* undef, align 8 + store float %29, float* undef, align 4 + store float %31, float* undef, align 8 + store float %40, float* undef, align 8 + store float %12, float* null, align 8 + %41 = fmul float %17, undef ; [#uses=1] + %42 = fadd float %41, undef ; [#uses=1] + %43 = fmul float %35, undef ; [#uses=1] + %44 = fadd float %42, %43 ; [#uses=1] + store float %44, float* null, align 4 + unreachable +} From evan.cheng at apple.com Fri Nov 6 17:52:49 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 06 Nov 2009 23:52:49 -0000 Subject: [llvm-commits] [llvm] r86304 - in /llvm/trunk: lib/Target/ARM/ test/CodeGen/Thumb2/ Message-ID: <200911062352.nA6Nqn65010188@zion.cs.uiuc.edu> Author: evancheng Date: Fri Nov 6 17:52:48 2009 New Revision: 86304 URL: http://llvm.org/viewvc/llvm-project?rev=86304&view=rev Log: - Add pseudo instructions tLDRpci_pic and t2LDRpci_pic which does a pc-relative load of a GV from constantpool and then add pc. It allows the code sequence to be rematerializable so it would be hoisted by machine licm. - Add a late pass to break these pseudo instructions into a number of real instructions. Also move the code in Thumb2 IT pass that breaks up t2MOVi32imm to this pass. This is done before post regalloc scheduling to allow the scheduler to proper schedule these instructions. It also allow them to be if-converted and shrunk by later passes. Added: llvm/trunk/lib/Target/ARM/ARMExpandPseudoInsts.cpp Modified: llvm/trunk/lib/Target/ARM/ARM.h llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp llvm/trunk/lib/Target/ARM/ARMInstrInfo.h llvm/trunk/lib/Target/ARM/ARMInstrThumb.td llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.cpp llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.h llvm/trunk/lib/Target/ARM/Thumb2ITBlockPass.cpp llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.h llvm/trunk/test/CodeGen/Thumb2/2009-09-28-ITBlockBug.ll llvm/trunk/test/CodeGen/Thumb2/machine-licm.ll Modified: llvm/trunk/lib/Target/ARM/ARM.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARM.h?rev=86304&r1=86303&r2=86304&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARM.h (original) +++ llvm/trunk/lib/Target/ARM/ARM.h Fri Nov 6 17:52:48 2009 @@ -103,6 +103,7 @@ ObjectCodeEmitter &OCE); FunctionPass *createARMLoadStoreOptimizationPass(bool PreAlloc = false); +FunctionPass *createARMExpandPseudoPass(); FunctionPass *createARMConstantIslandPass(); FunctionPass *createNEONPreAllocPass(); FunctionPass *createNEONMoveFixPass(); Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h?rev=86304&r1=86303&r2=86304&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h Fri Nov 6 17:52:48 2009 @@ -261,9 +261,8 @@ virtual MachineInstr* foldMemoryOperandImpl(MachineFunction &MF, MachineInstr* MI, - const SmallVectorImpl &Ops, + const SmallVectorImpl &Ops, MachineInstr* LoadMI) const; - }; static inline Added: llvm/trunk/lib/Target/ARM/ARMExpandPseudoInsts.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMExpandPseudoInsts.cpp?rev=86304&view=auto ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMExpandPseudoInsts.cpp (added) +++ llvm/trunk/lib/Target/ARM/ARMExpandPseudoInsts.cpp Fri Nov 6 17:52:48 2009 @@ -0,0 +1,115 @@ +//===-- ARMExpandPseudoInsts.cpp - Expand pseudo instructions -----*- C++ -*-=// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file contains a pass that expand pseudo instructions into target +// instructions to allow proper scheduling, if-conversion, and other late +// optimizations. This pass should be run after register allocation but before +// post- regalloc scheduling pass. +// +//===----------------------------------------------------------------------===// + +#define DEBUG_TYPE "arm-pseudo" +#include "ARM.h" +#include "ARMBaseInstrInfo.h" +#include "llvm/CodeGen/MachineFunctionPass.h" +#include "llvm/CodeGen/MachineInstrBuilder.h" + +using namespace llvm; + +namespace { + class ARMExpandPseudo : public MachineFunctionPass { + public: + static char ID; + ARMExpandPseudo() : MachineFunctionPass(&ID) {} + + const TargetInstrInfo *TII; + + virtual bool runOnMachineFunction(MachineFunction &Fn); + + virtual const char *getPassName() const { + return "ARM pseudo instruction expansion pass"; + } + + private: + bool ExpandMBB(MachineBasicBlock &MBB); + }; + char ARMExpandPseudo::ID = 0; +} + +bool ARMExpandPseudo::ExpandMBB(MachineBasicBlock &MBB) { + bool Modified = false; + + MachineBasicBlock::iterator MBBI = MBB.begin(), E = MBB.end(); + while (MBBI != E) { + MachineInstr &MI = *MBBI; + MachineBasicBlock::iterator NMBBI = next(MBBI); + + unsigned Opcode = MI.getOpcode(); + switch (Opcode) { + default: break; + case ARM::tLDRpci_pic: + case ARM::t2LDRpci_pic: { + unsigned NewLdOpc = (Opcode == ARM::tLDRpci_pic) + ? ARM::tLDRpci : ARM::t2LDRpci; + unsigned DstReg = MI.getOperand(0).getReg(); + if (!MI.getOperand(0).isDead()) { + MachineInstr *NewMI = + AddDefaultPred(BuildMI(MBB, MBBI, MI.getDebugLoc(), + TII->get(NewLdOpc), DstReg) + .addOperand(MI.getOperand(1))); + NewMI->setMemRefs(MI.memoperands_begin(), MI.memoperands_end()); + BuildMI(MBB, MBBI, MI.getDebugLoc(), TII->get(ARM::tPICADD)) + .addReg(DstReg, getDefRegState(true)) + .addReg(DstReg) + .addOperand(MI.getOperand(2)); + } + MI.eraseFromParent(); + Modified = true; + break; + } + case ARM::t2MOVi32imm: { + unsigned DstReg = MI.getOperand(0).getReg(); + unsigned Imm = MI.getOperand(1).getImm(); + unsigned Lo16 = Imm & 0xffff; + unsigned Hi16 = (Imm >> 16) & 0xffff; + if (!MI.getOperand(0).isDead()) { + AddDefaultPred(BuildMI(MBB, MBBI, MI.getDebugLoc(), + TII->get(ARM::t2MOVi16), DstReg) + .addImm(Lo16)); + AddDefaultPred(BuildMI(MBB, MBBI, MI.getDebugLoc(), + TII->get(ARM::t2MOVTi16)) + .addReg(DstReg, getDefRegState(true)) + .addReg(DstReg).addImm(Hi16)); + } + MI.eraseFromParent(); + Modified = true; + } + // FIXME: expand t2MOVi32imm + } + MBBI = NMBBI; + } + + return Modified; +} + +bool ARMExpandPseudo::runOnMachineFunction(MachineFunction &MF) { + TII = MF.getTarget().getInstrInfo(); + + bool Modified = false; + for (MachineFunction::iterator MFI = MF.begin(), E = MF.end(); MFI != E; + ++MFI) + Modified |= ExpandMBB(*MFI); + return Modified; +} + +/// createARMExpandPseudoPass - returns an instance of the pseudo instruction +/// expansion pass. +FunctionPass *llvm::createARMExpandPseudoPass() { + return new ARMExpandPseudo(); +} Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp?rev=86304&r1=86303&r2=86304&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp Fri Nov 6 17:52:48 2009 @@ -85,17 +85,24 @@ unsigned DestReg, unsigned SubIdx, const MachineInstr *Orig) const { DebugLoc dl = Orig->getDebugLoc(); - if (Orig->getOpcode() == ARM::MOVi2pieces) { + unsigned Opcode = Orig->getOpcode(); + switch (Opcode) { + default: { + MachineInstr *MI = MBB.getParent()->CloneMachineInstr(Orig); + MI->getOperand(0).setReg(DestReg); + MBB.insert(I, MI); + break; + } + case ARM::MOVi2pieces: RI.emitLoadConstPool(MBB, I, dl, DestReg, SubIdx, Orig->getOperand(1).getImm(), (ARMCC::CondCodes)Orig->getOperand(2).getImm(), Orig->getOperand(3).getReg()); - return; + break; } - MachineInstr *MI = MBB.getParent()->CloneMachineInstr(Orig); - MI->getOperand(0).setReg(DestReg); - MBB.insert(I, MI); + MachineInstr *NewMI = prior(I); + NewMI->getOperand(0).setSubReg(SubIdx); } Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.h?rev=86304&r1=86303&r2=86304&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.h (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.h Fri Nov 6 17:52:48 2009 @@ -35,15 +35,15 @@ // Return true if the block does not fall through. bool BlockHasNoFallThrough(const MachineBasicBlock &MBB) const; + void reMaterialize(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, + unsigned DestReg, unsigned SubIdx, + const MachineInstr *Orig) const; + /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As /// such, whenever a client has an instance of instruction info, it should /// always be able to get register info as well (through this method). /// const ARMRegisterInfo &getRegisterInfo() const { return RI; } - - void reMaterialize(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, - unsigned DestReg, unsigned SubIdx, - const MachineInstr *Orig) const; }; } Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb.td?rev=86304&r1=86303&r2=86304&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb.td Fri Nov 6 17:52:48 2009 @@ -740,3 +740,13 @@ def : T1Pat<(i32 imm0_255_comp:$src), (tMVN (tMOVi8 (imm_comp_XFORM imm:$src)))>; + +// Pseudo instruction that combines ldr from constpool and add pc. This should +// be expanded into two instructions late to allow if-conversion and +// scheduling. +let isReMaterializable = 1 in +def tLDRpci_pic : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr, pclabel:$cp), + NoItinerary, "@ ldr.n\t$dst, $addr\n$cp:\n\tadd\t$dst, pc", + [(set GPR:$dst, (ARMpic_add (load (ARMWrapper tconstpool:$addr)), + imm:$cp))]>, + Requires<[IsThumb1Only]>; Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td?rev=86304&r1=86303&r2=86304&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Fri Nov 6 17:52:48 2009 @@ -1179,3 +1179,13 @@ def t2MOVi32imm : T2Ix2<(outs GPR:$dst), (ins i32imm:$src), IIC_iMOVi, "movw", "\t$dst, ${src:lo16}\n\tmovt${p}\t$dst, ${src:hi16}", [(set GPR:$dst, (i32 imm:$src))]>; + +// Pseudo instruction that combines ldr from constpool and add pc. This should +// be expanded into two instructions late to allow if-conversion and +// scheduling. +let isReMaterializable = 1 in +def t2LDRpci_pic : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr, pclabel:$cp), + NoItinerary, "@ ldr.w\t$dst, $addr\n$cp:\n\tadd\t$dst, pc", + [(set GPR:$dst, (ARMpic_add (load (ARMWrapper tconstpool:$addr)), + imm:$cp))]>, + Requires<[IsThumb2]>; Modified: llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp?rev=86304&r1=86303&r2=86304&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp Fri Nov 6 17:52:48 2009 @@ -105,6 +105,10 @@ if (OptLevel != CodeGenOpt::None && !Subtarget.isThumb1Only()) PM.add(createARMLoadStoreOptimizationPass()); + // Expand some pseudo instructions into multiple instructions to allow + // proper scheduling. + PM.add(createARMExpandPseudoPass()); + return true; } Modified: llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.cpp?rev=86304&r1=86303&r2=86304&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.cpp Fri Nov 6 17:52:48 2009 @@ -11,10 +11,13 @@ // //===----------------------------------------------------------------------===// -#include "ARMInstrInfo.h" +#include "Thumb1InstrInfo.h" #include "ARM.h" +#include "ARMConstantPoolValue.h" #include "ARMGenInstrInfo.inc" #include "ARMMachineFunctionInfo.h" +#include "llvm/GlobalValue.h" +#include "llvm/CodeGen/MachineConstantPool.h" #include "llvm/CodeGen/MachineFrameInfo.h" #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/MachineMemOperand.h" @@ -263,3 +266,44 @@ return NewMI; } + +void Thumb1InstrInfo::reMaterialize(MachineBasicBlock &MBB, + MachineBasicBlock::iterator I, + unsigned DestReg, unsigned SubIdx, + const MachineInstr *Orig) const { + DebugLoc dl = Orig->getDebugLoc(); + unsigned Opcode = Orig->getOpcode(); + switch (Opcode) { + default: { + MachineInstr *MI = MBB.getParent()->CloneMachineInstr(Orig); + MI->getOperand(0).setReg(DestReg); + MBB.insert(I, MI); + break; + } + case ARM::tLDRpci_pic: { + MachineFunction &MF = *MBB.getParent(); + ARMFunctionInfo *AFI = MF.getInfo(); + MachineConstantPool *MCP = MF.getConstantPool(); + unsigned CPI = Orig->getOperand(1).getIndex(); + const MachineConstantPoolEntry &MCPE = MCP->getConstants()[CPI]; + assert(MCPE.isMachineConstantPoolEntry() && + "Expecting a machine constantpool entry!"); + ARMConstantPoolValue *ACPV = + static_cast(MCPE.Val.MachineCPVal); + assert(ACPV->isGlobalValue() && "Expecting a GV!"); + unsigned PCLabelId = AFI->createConstPoolEntryUId(); + ARMConstantPoolValue *NewCPV = + new ARMConstantPoolValue(ACPV->getGV(), PCLabelId, ARMCP::CPValue, 4); + CPI = MCP->getConstantPoolIndex(NewCPV, MCPE.getAlignment()); + MachineInstrBuilder MIB = BuildMI(MBB, I, Orig->getDebugLoc(), get(Opcode), + DestReg) + .addConstantPoolIndex(CPI).addImm(PCLabelId); + (*MIB).setMemRefs(Orig->memoperands_begin(), Orig->memoperands_end()); + break; + } + } + + MachineInstr *NewMI = prior(I); + NewMI->getOperand(0).setSubReg(SubIdx); +} + Modified: llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.h?rev=86304&r1=86303&r2=86304&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.h (original) +++ llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.h Fri Nov 6 17:52:48 2009 @@ -76,6 +76,10 @@ MachineInstr* LoadMI) const { return 0; } + + void reMaterialize(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, + unsigned DestReg, unsigned SubIdx, + const MachineInstr *Orig) const; }; } Modified: llvm/trunk/lib/Target/ARM/Thumb2ITBlockPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb2ITBlockPass.cpp?rev=86304&r1=86303&r2=86304&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb2ITBlockPass.cpp (original) +++ llvm/trunk/lib/Target/ARM/Thumb2ITBlockPass.cpp Fri Nov 6 17:52:48 2009 @@ -34,10 +34,6 @@ } private: - MachineBasicBlock::iterator - SplitT2MOV32imm(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, - MachineInstr *MI, DebugLoc dl, - unsigned PredReg, ARMCC::CondCodes CC); bool InsertITBlocks(MachineBasicBlock &MBB); }; char Thumb2ITBlockPass::ID = 0; @@ -50,34 +46,6 @@ return llvm::getInstrPredicate(MI, PredReg); } -MachineBasicBlock::iterator -Thumb2ITBlockPass::SplitT2MOV32imm(MachineBasicBlock &MBB, - MachineBasicBlock::iterator MBBI, - MachineInstr *MI, - DebugLoc dl, unsigned PredReg, - ARMCC::CondCodes CC) { - // Splitting t2MOVi32imm into a pair of t2MOVi16 + t2MOVTi16 here. - // The only reason it was a single instruction was so it could be - // re-materialized. We want to split it before this and the thumb2 - // size reduction pass to make sure the IT mask is correct and expose - // width reduction opportunities. It doesn't make sense to do this in a - // separate pass so here it is. - unsigned DstReg = MI->getOperand(0).getReg(); - bool DstDead = MI->getOperand(0).isDead(); // Is this possible? - unsigned Imm = MI->getOperand(1).getImm(); - unsigned Lo16 = Imm & 0xffff; - unsigned Hi16 = (Imm >> 16) & 0xffff; - BuildMI(MBB, MBBI, dl, TII->get(ARM::t2MOVi16), DstReg) - .addImm(Lo16).addImm(CC).addReg(PredReg); - BuildMI(MBB, MBBI, dl, TII->get(ARM::t2MOVTi16)) - .addReg(DstReg, getDefRegState(true) | getDeadRegState(DstDead)) - .addReg(DstReg).addImm(Hi16).addImm(CC).addReg(PredReg); - --MBBI; - --MBBI; - MI->eraseFromParent(); - return MBBI; -} - bool Thumb2ITBlockPass::InsertITBlocks(MachineBasicBlock &MBB) { bool Modified = false; @@ -88,11 +56,6 @@ unsigned PredReg = 0; ARMCC::CondCodes CC = getPredicate(MI, PredReg); - if (MI->getOpcode() == ARM::t2MOVi32imm) { - MBBI = SplitT2MOV32imm(MBB, MBBI, MI, dl, PredReg, CC); - continue; - } - if (CC == ARMCC::AL) { ++MBBI; continue; @@ -115,11 +78,6 @@ DebugLoc ndl = NMI->getDebugLoc(); unsigned NPredReg = 0; ARMCC::CondCodes NCC = getPredicate(NMI, NPredReg); - if (NMI->getOpcode() == ARM::t2MOVi32imm) { - MBBI = SplitT2MOV32imm(MBB, MBBI, NMI, ndl, NPredReg, NCC); - continue; - } - if (NCC == OCC) { Mask |= (1 << Pos); } else if (NCC != CC) Modified: llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp?rev=86304&r1=86303&r2=86304&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp Fri Nov 6 17:52:48 2009 @@ -11,11 +11,14 @@ // //===----------------------------------------------------------------------===// -#include "ARMInstrInfo.h" +#include "Thumb2InstrInfo.h" #include "ARM.h" +#include "ARMConstantPoolValue.h" #include "ARMAddressingModes.h" #include "ARMGenInstrInfo.inc" #include "ARMMachineFunctionInfo.h" +#include "llvm/GlobalValue.h" +#include "llvm/CodeGen/MachineConstantPool.h" #include "llvm/CodeGen/MachineFrameInfo.h" #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/MachineMemOperand.h" @@ -132,6 +135,45 @@ ARMBaseInstrInfo::loadRegFromStackSlot(MBB, I, DestReg, FI, RC); } +void Thumb2InstrInfo::reMaterialize(MachineBasicBlock &MBB, + MachineBasicBlock::iterator I, + unsigned DestReg, unsigned SubIdx, + const MachineInstr *Orig) const { + DebugLoc dl = Orig->getDebugLoc(); + unsigned Opcode = Orig->getOpcode(); + switch (Opcode) { + default: { + MachineInstr *MI = MBB.getParent()->CloneMachineInstr(Orig); + MI->getOperand(0).setReg(DestReg); + MBB.insert(I, MI); + break; + } + case ARM::t2LDRpci_pic: { + MachineFunction &MF = *MBB.getParent(); + ARMFunctionInfo *AFI = MF.getInfo(); + MachineConstantPool *MCP = MF.getConstantPool(); + unsigned CPI = Orig->getOperand(1).getIndex(); + const MachineConstantPoolEntry &MCPE = MCP->getConstants()[CPI]; + assert(MCPE.isMachineConstantPoolEntry() && + "Expecting a machine constantpool entry!"); + ARMConstantPoolValue *ACPV = + static_cast(MCPE.Val.MachineCPVal); + assert(ACPV->isGlobalValue() && "Expecting a GV!"); + unsigned PCLabelId = AFI->createConstPoolEntryUId(); + ARMConstantPoolValue *NewCPV = + new ARMConstantPoolValue(ACPV->getGV(), PCLabelId, ARMCP::CPValue, 4); + CPI = MCP->getConstantPoolIndex(NewCPV, MCPE.getAlignment()); + MachineInstrBuilder MIB = BuildMI(MBB, I, Orig->getDebugLoc(), get(Opcode), + DestReg) + .addConstantPoolIndex(CPI).addImm(PCLabelId); + (*MIB).setMemRefs(Orig->memoperands_begin(), Orig->memoperands_end()); + break; + } + } + + MachineInstr *NewMI = prior(I); + NewMI->getOperand(0).setSubReg(SubIdx); +} void llvm::emitT2RegPlusImmediate(MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI, DebugLoc dl, Modified: llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.h?rev=86304&r1=86303&r2=86304&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.h (original) +++ llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.h Fri Nov 6 17:52:48 2009 @@ -50,6 +50,10 @@ unsigned DestReg, int FrameIndex, const TargetRegisterClass *RC) const; + void reMaterialize(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, + unsigned DestReg, unsigned SubIdx, + const MachineInstr *Orig) const; + /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As /// such, whenever a client has an instance of instruction info, it should /// always be able to get register info as well (through this method). Modified: llvm/trunk/test/CodeGen/Thumb2/2009-09-28-ITBlockBug.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/2009-09-28-ITBlockBug.ll?rev=86304&r1=86303&r2=86304&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/2009-09-28-ITBlockBug.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/2009-09-28-ITBlockBug.ll Fri Nov 6 17:52:48 2009 @@ -6,10 +6,8 @@ define arm_apcscc void @t() nounwind { ; CHECK: t: -; CHECK: ittt eq -; CHECK-NEXT: addeq -; CHECK-NEXT: movweq -; CHECK-NEXT: movteq +; CHECK: it eq +; CHECK-NEXT: cmpeq entry: %pix_a.i294 = alloca [4 x %struct.pix_pos], align 4 ; <[4 x %struct.pix_pos]*> [#uses=2] br i1 undef, label %land.rhs, label %lor.end Modified: llvm/trunk/test/CodeGen/Thumb2/machine-licm.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/machine-licm.ll?rev=86304&r1=86303&r2=86304&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/machine-licm.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/machine-licm.ll Fri Nov 6 17:52:48 2009 @@ -17,6 +17,9 @@ ; CHECK: BB#1 ; CHECK: ldr{{.*}} r{{[0-9]+}}, LCPI1_0 ; CHECK: ldr{{.*}} r{{[0-9]+}}, LCPI1_1 +; CHECK: add r{{[0-9]+}}, pc +; CHECK: add r{{[0-9]+}}, pc +; CHECK: LBB1_2 %.pre = load i32* @GV, align 4 ; [#uses=1] br label %bb From jyasskin at google.com Fri Nov 6 18:00:10 2009 From: jyasskin at google.com (Jeffrey Yasskin) Date: Sat, 07 Nov 2009 00:00:10 -0000 Subject: [llvm-commits] [llvm] r86305 - /llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp Message-ID: <200911070000.nA700ADB010434@zion.cs.uiuc.edu> Author: jyasskin Date: Fri Nov 6 18:00:10 2009 New Revision: 86305 URL: http://llvm.org/viewvc/llvm-project?rev=86305&view=rev Log: Give the JITResolver a direct pointer to its JITEmitter, and use that instead of going through the global TheJIT variable. This makes it easier to use features of JITEmitter that aren't in JITCodeEmitter for fixing PR5201. Modified: llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp Modified: llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp?rev=86305&r1=86304&r2=86305&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp Fri Nov 6 18:00:10 2009 @@ -63,6 +63,7 @@ // JIT lazy compilation code. // namespace { + class JITEmitter; class JITResolverState; template @@ -213,9 +214,11 @@ std::map revGOTMap; unsigned nextGOTIndex; + JITEmitter &JE; + static JITResolver *TheJITResolver; public: - explicit JITResolver(JIT &jit) : nextGOTIndex(0) { + explicit JITResolver(JIT &jit, JITEmitter &je) : nextGOTIndex(0), JE(je) { TheJIT = &jit; LazyResolverFn = jit.getJITInfo().getLazyResolverFunction(JITCompilerFn); @@ -269,6 +272,233 @@ /// been compiled, this function compiles it first. static void *JITCompilerFn(void *Stub); }; + + /// JITEmitter - The JIT implementation of the MachineCodeEmitter, which is + /// used to output functions to memory for execution. + class JITEmitter : public JITCodeEmitter { + JITMemoryManager *MemMgr; + + // When outputting a function stub in the context of some other function, we + // save BufferBegin/BufferEnd/CurBufferPtr here. + uint8_t *SavedBufferBegin, *SavedBufferEnd, *SavedCurBufferPtr; + + // When reattempting to JIT a function after running out of space, we store + // the estimated size of the function we're trying to JIT here, so we can + // ask the memory manager for at least this much space. When we + // successfully emit the function, we reset this back to zero. + uintptr_t SizeEstimate; + + /// Relocations - These are the relocations that the function needs, as + /// emitted. + std::vector Relocations; + + /// MBBLocations - This vector is a mapping from MBB ID's to their address. + /// It is filled in by the StartMachineBasicBlock callback and queried by + /// the getMachineBasicBlockAddress callback. + std::vector MBBLocations; + + /// ConstantPool - The constant pool for the current function. + /// + MachineConstantPool *ConstantPool; + + /// ConstantPoolBase - A pointer to the first entry in the constant pool. + /// + void *ConstantPoolBase; + + /// ConstPoolAddresses - Addresses of individual constant pool entries. + /// + SmallVector ConstPoolAddresses; + + /// JumpTable - The jump tables for the current function. + /// + MachineJumpTableInfo *JumpTable; + + /// JumpTableBase - A pointer to the first entry in the jump table. + /// + void *JumpTableBase; + + /// Resolver - This contains info about the currently resolved functions. + JITResolver Resolver; + + /// DE - The dwarf emitter for the jit. + OwningPtr DE; + + /// DR - The debug registerer for the jit. + OwningPtr DR; + + /// LabelLocations - This vector is a mapping from Label ID's to their + /// address. + std::vector LabelLocations; + + /// MMI - Machine module info for exception informations + MachineModuleInfo* MMI; + + // GVSet - a set to keep track of which globals have been seen + SmallPtrSet GVSet; + + // CurFn - The llvm function being emitted. Only valid during + // finishFunction(). + const Function *CurFn; + + /// Information about emitted code, which is passed to the + /// JITEventListeners. This is reset in startFunction and used in + /// finishFunction. + JITEvent_EmittedFunctionDetails EmissionDetails; + + struct EmittedCode { + void *FunctionBody; // Beginning of the function's allocation. + void *Code; // The address the function's code actually starts at. + void *ExceptionTable; + EmittedCode() : FunctionBody(0), Code(0), ExceptionTable(0) {} + }; + struct EmittedFunctionConfig : public ValueMapConfig { + typedef JITEmitter *ExtraData; + static void onDelete(JITEmitter *, const Function*); + static void onRAUW(JITEmitter *, const Function*, const Function*); + }; + ValueMap EmittedFunctions; + + // CurFnStubUses - For a given Function, a vector of stubs that it + // references. This facilitates the JIT detecting that a stub is no + // longer used, so that it may be deallocated. + DenseMap, SmallVector > CurFnStubUses; + + // StubFnRefs - For a given pointer to a stub, a set of Functions which + // reference the stub. When the count of a stub's references drops to zero, + // the stub is unused. + DenseMap > StubFnRefs; + + // ExtFnStubs - A map of external function names to stubs which have entries + // in the JITResolver's ExternalFnToStubMap. + StringMap ExtFnStubs; + + DebugLocTuple PrevDLT; + + public: + JITEmitter(JIT &jit, JITMemoryManager *JMM, TargetMachine &TM) + : SizeEstimate(0), Resolver(jit, *this), MMI(0), CurFn(0), + EmittedFunctions(this) { + MemMgr = JMM ? JMM : JITMemoryManager::CreateDefaultMemManager(); + if (jit.getJITInfo().needsGOT()) { + MemMgr->AllocateGOT(); + DEBUG(errs() << "JIT is managing a GOT\n"); + } + + if (DwarfExceptionHandling || JITEmitDebugInfo) { + DE.reset(new JITDwarfEmitter(jit)); + } + if (JITEmitDebugInfo) { + DR.reset(new JITDebugRegisterer(TM)); + } + } + ~JITEmitter() { + delete MemMgr; + } + + /// classof - Methods for support type inquiry through isa, cast, and + /// dyn_cast: + /// + static inline bool classof(const JITEmitter*) { return true; } + static inline bool classof(const MachineCodeEmitter*) { return true; } + + JITResolver &getJITResolver() { return Resolver; } + + virtual void startFunction(MachineFunction &F); + virtual bool finishFunction(MachineFunction &F); + + void emitConstantPool(MachineConstantPool *MCP); + void initJumpTableInfo(MachineJumpTableInfo *MJTI); + void emitJumpTableInfo(MachineJumpTableInfo *MJTI); + + virtual void startGVStub(const GlobalValue* GV, unsigned StubSize, + unsigned Alignment = 1); + virtual void startGVStub(const GlobalValue* GV, void *Buffer, + unsigned StubSize); + virtual void* finishGVStub(const GlobalValue *GV); + + /// allocateSpace - Reserves space in the current block if any, or + /// allocate a new one of the given size. + virtual void *allocateSpace(uintptr_t Size, unsigned Alignment); + + /// allocateGlobal - Allocate memory for a global. Unlike allocateSpace, + /// this method does not allocate memory in the current output buffer, + /// because a global may live longer than the current function. + virtual void *allocateGlobal(uintptr_t Size, unsigned Alignment); + + virtual void addRelocation(const MachineRelocation &MR) { + Relocations.push_back(MR); + } + + virtual void StartMachineBasicBlock(MachineBasicBlock *MBB) { + if (MBBLocations.size() <= (unsigned)MBB->getNumber()) + MBBLocations.resize((MBB->getNumber()+1)*2); + MBBLocations[MBB->getNumber()] = getCurrentPCValue(); + DEBUG(errs() << "JIT: Emitting BB" << MBB->getNumber() << " at [" + << (void*) getCurrentPCValue() << "]\n"); + } + + virtual uintptr_t getConstantPoolEntryAddress(unsigned Entry) const; + virtual uintptr_t getJumpTableEntryAddress(unsigned Entry) const; + + virtual uintptr_t getMachineBasicBlockAddress(MachineBasicBlock *MBB) const { + assert(MBBLocations.size() > (unsigned)MBB->getNumber() && + MBBLocations[MBB->getNumber()] && "MBB not emitted!"); + return MBBLocations[MBB->getNumber()]; + } + + /// retryWithMoreMemory - Log a retry and deallocate all memory for the + /// given function. Increase the minimum allocation size so that we get + /// more memory next time. + void retryWithMoreMemory(MachineFunction &F); + + /// deallocateMemForFunction - Deallocate all memory for the specified + /// function body. + void deallocateMemForFunction(const Function *F); + + /// AddStubToCurrentFunction - Mark the current function being JIT'd as + /// using the stub at the specified address. Allows + /// deallocateMemForFunction to also remove stubs no longer referenced. + void AddStubToCurrentFunction(void *Stub); + + /// getExternalFnStubs - Accessor for the JIT to find stubs emitted for + /// MachineRelocations that reference external functions by name. + const StringMap &getExternalFnStubs() const { return ExtFnStubs; } + + virtual void processDebugLoc(DebugLoc DL, bool BeforePrintingInsn); + + virtual void emitLabel(uint64_t LabelID) { + if (LabelLocations.size() <= LabelID) + LabelLocations.resize((LabelID+1)*2); + LabelLocations[LabelID] = getCurrentPCValue(); + } + + virtual uintptr_t getLabelAddress(uint64_t LabelID) const { + assert(LabelLocations.size() > (unsigned)LabelID && + LabelLocations[LabelID] && "Label not emitted!"); + return LabelLocations[LabelID]; + } + + virtual void setModuleInfo(MachineModuleInfo* Info) { + MMI = Info; + if (DE.get()) DE->setModuleInfo(Info); + } + + void setMemoryExecutable() { + MemMgr->setMemoryExecutable(); + } + + JITMemoryManager *getMemMgr() const { return MemMgr; } + + private: + void *getPointerToGlobal(GlobalValue *GV, void *Reference, bool NoNeedStub); + void *getPointerToGVIndirectSym(GlobalValue *V, void *Reference, + bool NoNeedStub); + unsigned addSizeOfGlobal(const GlobalVariable *GV, unsigned Size); + unsigned addSizeOfGlobalsInConstantVal(const Constant *C, unsigned Size); + unsigned addSizeOfGlobalsInInitializer(const Constant *Init, unsigned Size); + unsigned GetSizeOfGlobalsInBytes(MachineFunction &MF); + }; } JITResolver *JITResolver::TheJITResolver = 0; @@ -314,8 +544,7 @@ // Codegen a new stub, calling the lazy resolver or the actual address of the // external function, if it was resolved. - Stub = TheJIT->getJITInfo().emitFunctionStub(F, Actual, - *TheJIT->getCodeEmitter()); + Stub = TheJIT->getJITInfo().emitFunctionStub(F, Actual, JE); if (Actual != (void*)(intptr_t)LazyResolverFn) { // If we are getting the stub for an external function, we really want the @@ -352,7 +581,7 @@ // Otherwise, codegen a new indirect symbol. IndirectSym = TheJIT->getJITInfo().emitGlobalValueIndirectSym(GV, GVAddress, - *TheJIT->getCodeEmitter()); + JE); DEBUG(errs() << "JIT: Indirect symbol emitted at [" << IndirectSym << "] for GV '" << GV->getName() << "'\n"); @@ -367,8 +596,7 @@ void *&Stub = ExternalFnToStubMap[FnAddr]; if (Stub) return Stub; - Stub = TheJIT->getJITInfo().emitFunctionStub(0, FnAddr, - *TheJIT->getCodeEmitter()); + Stub = TheJIT->getJITInfo().emitFunctionStub(0, FnAddr, JE); DEBUG(errs() << "JIT: Stub emitted at [" << Stub << "] for external function at '" << FnAddr << "'\n"); @@ -508,235 +736,6 @@ //===----------------------------------------------------------------------===// // JITEmitter code. // -namespace { - /// JITEmitter - The JIT implementation of the MachineCodeEmitter, which is - /// used to output functions to memory for execution. - class JITEmitter : public JITCodeEmitter { - JITMemoryManager *MemMgr; - - // When outputting a function stub in the context of some other function, we - // save BufferBegin/BufferEnd/CurBufferPtr here. - uint8_t *SavedBufferBegin, *SavedBufferEnd, *SavedCurBufferPtr; - - // When reattempting to JIT a function after running out of space, we store - // the estimated size of the function we're trying to JIT here, so we can - // ask the memory manager for at least this much space. When we - // successfully emit the function, we reset this back to zero. - uintptr_t SizeEstimate; - - /// Relocations - These are the relocations that the function needs, as - /// emitted. - std::vector Relocations; - - /// MBBLocations - This vector is a mapping from MBB ID's to their address. - /// It is filled in by the StartMachineBasicBlock callback and queried by - /// the getMachineBasicBlockAddress callback. - std::vector MBBLocations; - - /// ConstantPool - The constant pool for the current function. - /// - MachineConstantPool *ConstantPool; - - /// ConstantPoolBase - A pointer to the first entry in the constant pool. - /// - void *ConstantPoolBase; - - /// ConstPoolAddresses - Addresses of individual constant pool entries. - /// - SmallVector ConstPoolAddresses; - - /// JumpTable - The jump tables for the current function. - /// - MachineJumpTableInfo *JumpTable; - - /// JumpTableBase - A pointer to the first entry in the jump table. - /// - void *JumpTableBase; - - /// Resolver - This contains info about the currently resolved functions. - JITResolver Resolver; - - /// DE - The dwarf emitter for the jit. - OwningPtr DE; - - /// DR - The debug registerer for the jit. - OwningPtr DR; - - /// LabelLocations - This vector is a mapping from Label ID's to their - /// address. - std::vector LabelLocations; - - /// MMI - Machine module info for exception informations - MachineModuleInfo* MMI; - - // GVSet - a set to keep track of which globals have been seen - SmallPtrSet GVSet; - - // CurFn - The llvm function being emitted. Only valid during - // finishFunction(). - const Function *CurFn; - - /// Information about emitted code, which is passed to the - /// JITEventListeners. This is reset in startFunction and used in - /// finishFunction. - JITEvent_EmittedFunctionDetails EmissionDetails; - - struct EmittedCode { - void *FunctionBody; // Beginning of the function's allocation. - void *Code; // The address the function's code actually starts at. - void *ExceptionTable; - EmittedCode() : FunctionBody(0), Code(0), ExceptionTable(0) {} - }; - struct EmittedFunctionConfig : public ValueMapConfig { - typedef JITEmitter *ExtraData; - static void onDelete(JITEmitter *, const Function*); - static void onRAUW(JITEmitter *, const Function*, const Function*); - }; - ValueMap EmittedFunctions; - - // CurFnStubUses - For a given Function, a vector of stubs that it - // references. This facilitates the JIT detecting that a stub is no - // longer used, so that it may be deallocated. - DenseMap, SmallVector > CurFnStubUses; - - // StubFnRefs - For a given pointer to a stub, a set of Functions which - // reference the stub. When the count of a stub's references drops to zero, - // the stub is unused. - DenseMap > StubFnRefs; - - // ExtFnStubs - A map of external function names to stubs which have entries - // in the JITResolver's ExternalFnToStubMap. - StringMap ExtFnStubs; - - DebugLocTuple PrevDLT; - - public: - JITEmitter(JIT &jit, JITMemoryManager *JMM, TargetMachine &TM) - : SizeEstimate(0), Resolver(jit), MMI(0), CurFn(0), - EmittedFunctions(this) { - MemMgr = JMM ? JMM : JITMemoryManager::CreateDefaultMemManager(); - if (jit.getJITInfo().needsGOT()) { - MemMgr->AllocateGOT(); - DEBUG(errs() << "JIT is managing a GOT\n"); - } - - if (DwarfExceptionHandling || JITEmitDebugInfo) { - DE.reset(new JITDwarfEmitter(jit)); - } - if (JITEmitDebugInfo) { - DR.reset(new JITDebugRegisterer(TM)); - } - } - ~JITEmitter() { - delete MemMgr; - } - - /// classof - Methods for support type inquiry through isa, cast, and - /// dyn_cast: - /// - static inline bool classof(const JITEmitter*) { return true; } - static inline bool classof(const MachineCodeEmitter*) { return true; } - - JITResolver &getJITResolver() { return Resolver; } - - virtual void startFunction(MachineFunction &F); - virtual bool finishFunction(MachineFunction &F); - - void emitConstantPool(MachineConstantPool *MCP); - void initJumpTableInfo(MachineJumpTableInfo *MJTI); - void emitJumpTableInfo(MachineJumpTableInfo *MJTI); - - virtual void startGVStub(const GlobalValue* GV, unsigned StubSize, - unsigned Alignment = 1); - virtual void startGVStub(const GlobalValue* GV, void *Buffer, - unsigned StubSize); - virtual void* finishGVStub(const GlobalValue *GV); - - /// allocateSpace - Reserves space in the current block if any, or - /// allocate a new one of the given size. - virtual void *allocateSpace(uintptr_t Size, unsigned Alignment); - - /// allocateGlobal - Allocate memory for a global. Unlike allocateSpace, - /// this method does not allocate memory in the current output buffer, - /// because a global may live longer than the current function. - virtual void *allocateGlobal(uintptr_t Size, unsigned Alignment); - - virtual void addRelocation(const MachineRelocation &MR) { - Relocations.push_back(MR); - } - - virtual void StartMachineBasicBlock(MachineBasicBlock *MBB) { - if (MBBLocations.size() <= (unsigned)MBB->getNumber()) - MBBLocations.resize((MBB->getNumber()+1)*2); - MBBLocations[MBB->getNumber()] = getCurrentPCValue(); - DEBUG(errs() << "JIT: Emitting BB" << MBB->getNumber() << " at [" - << (void*) getCurrentPCValue() << "]\n"); - } - - virtual uintptr_t getConstantPoolEntryAddress(unsigned Entry) const; - virtual uintptr_t getJumpTableEntryAddress(unsigned Entry) const; - - virtual uintptr_t getMachineBasicBlockAddress(MachineBasicBlock *MBB) const { - assert(MBBLocations.size() > (unsigned)MBB->getNumber() && - MBBLocations[MBB->getNumber()] && "MBB not emitted!"); - return MBBLocations[MBB->getNumber()]; - } - - /// retryWithMoreMemory - Log a retry and deallocate all memory for the - /// given function. Increase the minimum allocation size so that we get - /// more memory next time. - void retryWithMoreMemory(MachineFunction &F); - - /// deallocateMemForFunction - Deallocate all memory for the specified - /// function body. - void deallocateMemForFunction(const Function *F); - - /// AddStubToCurrentFunction - Mark the current function being JIT'd as - /// using the stub at the specified address. Allows - /// deallocateMemForFunction to also remove stubs no longer referenced. - void AddStubToCurrentFunction(void *Stub); - - /// getExternalFnStubs - Accessor for the JIT to find stubs emitted for - /// MachineRelocations that reference external functions by name. - const StringMap &getExternalFnStubs() const { return ExtFnStubs; } - - virtual void processDebugLoc(DebugLoc DL, bool BeforePrintingInsn); - - virtual void emitLabel(uint64_t LabelID) { - if (LabelLocations.size() <= LabelID) - LabelLocations.resize((LabelID+1)*2); - LabelLocations[LabelID] = getCurrentPCValue(); - } - - virtual uintptr_t getLabelAddress(uint64_t LabelID) const { - assert(LabelLocations.size() > (unsigned)LabelID && - LabelLocations[LabelID] && "Label not emitted!"); - return LabelLocations[LabelID]; - } - - virtual void setModuleInfo(MachineModuleInfo* Info) { - MMI = Info; - if (DE.get()) DE->setModuleInfo(Info); - } - - void setMemoryExecutable() { - MemMgr->setMemoryExecutable(); - } - - JITMemoryManager *getMemMgr() const { return MemMgr; } - - private: - void *getPointerToGlobal(GlobalValue *GV, void *Reference, bool NoNeedStub); - void *getPointerToGVIndirectSym(GlobalValue *V, void *Reference, - bool NoNeedStub); - unsigned addSizeOfGlobal(const GlobalVariable *GV, unsigned Size); - unsigned addSizeOfGlobalsInConstantVal(const Constant *C, unsigned Size); - unsigned addSizeOfGlobalsInInitializer(const Constant *Init, unsigned Size); - unsigned GetSizeOfGlobalsInBytes(MachineFunction &MF); - }; -} - void *JITEmitter::getPointerToGlobal(GlobalValue *V, void *Reference, bool DoesntNeedStub) { if (GlobalVariable *GV = dyn_cast(V)) From grosbach at apple.com Fri Nov 6 18:13:31 2009 From: grosbach at apple.com (Jim Grosbach) Date: Sat, 07 Nov 2009 00:13:31 -0000 Subject: [llvm-commits] [llvm] r86310 - /llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.h Message-ID: <200911070013.nA70DVwF010990@zion.cs.uiuc.edu> Author: grosbach Date: Fri Nov 6 18:13:30 2009 New Revision: 86310 URL: http://llvm.org/viewvc/llvm-project?rev=86310&view=rev Log: 80-columns Modified: llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.h Modified: llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.h?rev=86310&r1=86309&r2=86310&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.h (original) +++ llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.h Fri Nov 6 18:13:30 2009 @@ -1,4 +1,4 @@ -//===- Thumb2InstrInfo.h - Thumb-2 Instruction Information ----------*- C++ -*-===// +//===- Thumb2InstrInfo.h - Thumb-2 Instruction Information -------*- C++ -*-===// // // The LLVM Compiler Infrastructure // From vhernandez at apple.com Fri Nov 6 18:16:28 2009 From: vhernandez at apple.com (Victor Hernandez) Date: Sat, 07 Nov 2009 00:16:28 -0000 Subject: [llvm-commits] [llvm] r86311 - in /llvm/trunk: examples/BrainF/ include/llvm/ include/llvm/Analysis/ lib/Analysis/ lib/AsmParser/ lib/Bitcode/Reader/ lib/Transforms/IPO/ lib/VMCore/ test/Analysis/PointerTracking/ test/Transforms/GlobalOpt/ Message-ID: <200911070016.nA70GTHF011124@zion.cs.uiuc.edu> Author: hernande Date: Fri Nov 6 18:16:28 2009 New Revision: 86311 URL: http://llvm.org/viewvc/llvm-project?rev=86311&view=rev Log: Re-commit r86077 now that r86290 fixes the 179.art and 175.vpr ARM regressions. Here is the original commit message: This commit updates malloc optimizations to operate on malloc calls that have constant int size arguments. Update CreateMalloc so that its callers specify the size to allocate: MallocInst-autoupgrade users use non-TargetData-computed allocation sizes. Optimization uses use TargetData to compute the allocation size. Now that malloc calls can have constant sizes, update isArrayMallocHelper() to use TargetData to determine the size of the malloced type and the size of malloced arrays. Extend getMallocType() to support malloc calls that have non-bitcast uses. Update OptimizeGlobalAddressOfMalloc() to optimize malloc calls that have non-bitcast uses. The bitcast use of a malloc call has to be treated specially here because the uses of the bitcast need to be replaced and the bitcast needs to be erased (just like the malloc call) for OptimizeGlobalAddressOfMalloc() to work correctly. Update PerformHeapAllocSRoA() to optimize malloc calls that have non-bitcast uses. The bitcast use of the malloc is not handled specially here because ReplaceUsesOfMallocWithGlobal replaces through the bitcast use. Update OptimizeOnceStoredGlobal() to not care about the malloc calls' bitcast use. Update all globalopt malloc tests to not rely on autoupgraded-MallocInsts, but instead use explicit malloc calls with correct allocation sizes. Modified: llvm/trunk/examples/BrainF/BrainF.cpp llvm/trunk/include/llvm/Analysis/MemoryBuiltins.h llvm/trunk/include/llvm/Instructions.h llvm/trunk/lib/Analysis/MemoryBuiltins.cpp llvm/trunk/lib/AsmParser/LLParser.cpp llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp llvm/trunk/lib/VMCore/Core.cpp llvm/trunk/lib/VMCore/Instructions.cpp llvm/trunk/test/Analysis/PointerTracking/sizes.ll llvm/trunk/test/Transforms/GlobalOpt/2009-06-01-RecursivePHI.ll llvm/trunk/test/Transforms/GlobalOpt/heap-sra-1.ll llvm/trunk/test/Transforms/GlobalOpt/heap-sra-2.ll llvm/trunk/test/Transforms/GlobalOpt/heap-sra-3.ll llvm/trunk/test/Transforms/GlobalOpt/heap-sra-4.ll llvm/trunk/test/Transforms/GlobalOpt/heap-sra-phi.ll llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-1.ll llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-2.ll llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-3.ll Modified: llvm/trunk/examples/BrainF/BrainF.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/BrainF/BrainF.cpp?rev=86311&r1=86310&r2=86311&view=diff ============================================================================== --- llvm/trunk/examples/BrainF/BrainF.cpp (original) +++ llvm/trunk/examples/BrainF/BrainF.cpp Fri Nov 6 18:16:28 2009 @@ -81,8 +81,11 @@ ConstantInt *val_mem = ConstantInt::get(C, APInt(32, memtotal)); BasicBlock* BB = builder->GetInsertBlock(); const Type* IntPtrTy = IntegerType::getInt32Ty(C); - ptr_arr = CallInst::CreateMalloc(BB, IntPtrTy, IntegerType::getInt8Ty(C), - val_mem, NULL, "arr"); + const Type* Int8Ty = IntegerType::getInt8Ty(C); + Constant* allocsize = ConstantExpr::getSizeOf(Int8Ty); + allocsize = ConstantExpr::getTruncOrBitCast(allocsize, IntPtrTy); + ptr_arr = CallInst::CreateMalloc(BB, IntPtrTy, Int8Ty, allocsize, val_mem, + NULL, "arr"); BB->getInstList().push_back(cast(ptr_arr)); //call void @llvm.memset.i32(i8 *%arr, i8 0, i32 %d, i32 1) Modified: llvm/trunk/include/llvm/Analysis/MemoryBuiltins.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/MemoryBuiltins.h?rev=86311&r1=86310&r2=86311&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/MemoryBuiltins.h (original) +++ llvm/trunk/include/llvm/Analysis/MemoryBuiltins.h Fri Nov 6 18:16:28 2009 @@ -33,44 +33,48 @@ /// extractMallocCall - Returns the corresponding CallInst if the instruction /// is a malloc call. Since CallInst::CreateMalloc() only creates calls, we /// ignore InvokeInst here. -const CallInst* extractMallocCall(const Value *I); -CallInst* extractMallocCall(Value *I); +const CallInst *extractMallocCall(const Value *I); +CallInst *extractMallocCall(Value *I); /// extractMallocCallFromBitCast - Returns the corresponding CallInst if the /// instruction is a bitcast of the result of a malloc call. -const CallInst* extractMallocCallFromBitCast(const Value *I); -CallInst* extractMallocCallFromBitCast(Value *I); +const CallInst *extractMallocCallFromBitCast(const Value *I); +CallInst *extractMallocCallFromBitCast(Value *I); /// isArrayMalloc - Returns the corresponding CallInst if the instruction /// is a call to malloc whose array size can be determined and the array size /// is not constant 1. Otherwise, return NULL. -CallInst* isArrayMalloc(Value *I, const TargetData *TD); -const CallInst* isArrayMalloc(const Value *I, +CallInst *isArrayMalloc(Value *I, const TargetData *TD); +const CallInst *isArrayMalloc(const Value *I, const TargetData *TD); /// getMallocType - Returns the PointerType resulting from the malloc call. -/// This PointerType is the result type of the call's only bitcast use. -/// If there is no unique bitcast use, then return NULL. -const PointerType* getMallocType(const CallInst *CI); - -/// getMallocAllocatedType - Returns the Type allocated by malloc call. This -/// Type is the result type of the call's only bitcast use. If there is no -/// unique bitcast use, then return NULL. -const Type* getMallocAllocatedType(const CallInst *CI); +/// The PointerType depends on the number of bitcast uses of the malloc call: +/// 0: PointerType is the malloc calls' return type. +/// 1: PointerType is the bitcast's result type. +/// >1: Unique PointerType cannot be determined, return NULL. +const PointerType *getMallocType(const CallInst *CI); + +/// getMallocAllocatedType - Returns the Type allocated by malloc call. +/// The Type depends on the number of bitcast uses of the malloc call: +/// 0: PointerType is the malloc calls' return type. +/// 1: PointerType is the bitcast's result type. +/// >1: Unique PointerType cannot be determined, return NULL. +const Type *getMallocAllocatedType(const CallInst *CI); /// getMallocArraySize - Returns the array size of a malloc call. If the /// argument passed to malloc is a multiple of the size of the malloced type, /// then return that multiple. For non-array mallocs, the multiple is /// constant 1. Otherwise, return NULL for mallocs whose array size cannot be /// determined. -Value* getMallocArraySize(CallInst *CI, const TargetData *TD); +Value *getMallocArraySize(CallInst *CI, const TargetData *TD); //===----------------------------------------------------------------------===// // free Call Utility Functions. // /// isFreeCall - Returns true if the the value is a call to the builtin free() -bool isFreeCall(const Value* I); +bool isFreeCall(const Value *I); } // End llvm namespace Modified: llvm/trunk/include/llvm/Instructions.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Instructions.h?rev=86311&r1=86310&r2=86311&view=diff ============================================================================== --- llvm/trunk/include/llvm/Instructions.h (original) +++ llvm/trunk/include/llvm/Instructions.h Fri Nov 6 18:16:28 2009 @@ -899,11 +899,12 @@ /// 3. Bitcast the result of the malloc call to the specified type. static Instruction *CreateMalloc(Instruction *InsertBefore, const Type *IntPtrTy, const Type *AllocTy, - Value *ArraySize = 0, + Value *AllocSize, Value *ArraySize = 0, const Twine &Name = ""); static Instruction *CreateMalloc(BasicBlock *InsertAtEnd, const Type *IntPtrTy, const Type *AllocTy, - Value *ArraySize = 0, Function* MallocF = 0, + Value *AllocSize, Value *ArraySize = 0, + Function* MallocF = 0, const Twine &Name = ""); /// CreateFree - Generate the IR for a call to the builtin free function. static void CreateFree(Value* Source, Instruction *InsertBefore); Modified: llvm/trunk/lib/Analysis/MemoryBuiltins.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryBuiltins.cpp?rev=86311&r1=86310&r2=86311&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/MemoryBuiltins.cpp (original) +++ llvm/trunk/lib/Analysis/MemoryBuiltins.cpp Fri Nov 6 18:16:28 2009 @@ -17,6 +17,7 @@ #include "llvm/Instructions.h" #include "llvm/Module.h" #include "llvm/Analysis/ConstantFolding.h" +#include "llvm/Target/TargetData.h" using namespace llvm; //===----------------------------------------------------------------------===// @@ -95,45 +96,47 @@ if (!CI) return NULL; - // Type must be known to determine array size. + // The size of the malloc's result type must be known to determine array size. const Type *T = getMallocAllocatedType(CI); - if (!T) + if (!T || !T->isSized() || !TD) return NULL; Value *MallocArg = CI->getOperand(1); + const Type *ArgType = MallocArg->getType(); ConstantExpr *CO = dyn_cast(MallocArg); BinaryOperator *BO = dyn_cast(MallocArg); - Constant *ElementSize = ConstantExpr::getSizeOf(T); - ElementSize = ConstantExpr::getTruncOrBitCast(ElementSize, - MallocArg->getType()); - Constant *FoldedElementSize = - ConstantFoldConstantExpression(cast(ElementSize), TD); + unsigned ElementSizeInt = TD->getTypeAllocSize(T); + if (const StructType *ST = dyn_cast(T)) + ElementSizeInt = TD->getStructLayout(ST)->getSizeInBytes(); + Constant *ElementSize = ConstantInt::get(ArgType, ElementSizeInt); // First, check if CI is a non-array malloc. - if (CO && ((CO == ElementSize) || - (FoldedElementSize && (CO == FoldedElementSize)))) + if (CO && CO == ElementSize) // Match CreateMalloc's use of constant 1 array-size for non-array mallocs. - return ConstantInt::get(MallocArg->getType(), 1); + return ConstantInt::get(ArgType, 1); // Second, check if CI is an array malloc whose array size can be determined. - if (isConstantOne(ElementSize) || - (FoldedElementSize && isConstantOne(FoldedElementSize))) + if (isConstantOne(ElementSize)) return MallocArg; + if (ConstantInt *CInt = dyn_cast(MallocArg)) + if (CInt->getZExtValue() % ElementSizeInt == 0) + return ConstantInt::get(ArgType, CInt->getZExtValue() / ElementSizeInt); + if (!CO && !BO) return NULL; Value *Op0 = NULL; Value *Op1 = NULL; unsigned Opcode = 0; - if (CO && ((CO->getOpcode() == Instruction::Mul) || + if (CO && ((CO->getOpcode() == Instruction::Mul) || (CO->getOpcode() == Instruction::Shl))) { Op0 = CO->getOperand(0); Op1 = CO->getOperand(1); Opcode = CO->getOpcode(); } - if (BO && ((BO->getOpcode() == Instruction::Mul) || + if (BO && ((BO->getOpcode() == Instruction::Mul) || (BO->getOpcode() == Instruction::Shl))) { Op0 = BO->getOperand(0); Op1 = BO->getOperand(1); @@ -143,12 +146,10 @@ // Determine array size if malloc's argument is the product of a mul or shl. if (Op0) { if (Opcode == Instruction::Mul) { - if ((Op1 == ElementSize) || - (FoldedElementSize && (Op1 == FoldedElementSize))) + if (Op1 == ElementSize) // ArraySize * ElementSize return Op0; - if ((Op0 == ElementSize) || - (FoldedElementSize && (Op0 == FoldedElementSize))) + if (Op0 == ElementSize) // ElementSize * ArraySize return Op1; } @@ -160,11 +161,10 @@ uint64_t BitToSet = Op1Int.getLimitedValue(Op1Int.getBitWidth() - 1); Value *Op1Pow = ConstantInt::get(Op1CI->getContext(), APInt(Op1Int.getBitWidth(), 0).set(BitToSet)); - if (Op0 == ElementSize || (FoldedElementSize && Op0 == FoldedElementSize)) + if (Op0 == ElementSize) // ArraySize << log2(ElementSize) return Op1Pow; - if (Op1Pow == ElementSize || - (FoldedElementSize && Op1Pow == FoldedElementSize)) + if (Op1Pow == ElementSize) // ElementSize << log2(ArraySize) return Op0; } @@ -202,35 +202,41 @@ } /// getMallocType - Returns the PointerType resulting from the malloc call. -/// This PointerType is the result type of the call's only bitcast use. -/// If there is no unique bitcast use, then return NULL. +/// The PointerType depends on the number of bitcast uses of the malloc call: +/// 0: PointerType is the calls' return type. +/// 1: PointerType is the bitcast's result type. +/// >1: Unique PointerType cannot be determined, return NULL. const PointerType *llvm::getMallocType(const CallInst *CI) { assert(isMalloc(CI) && "GetMallocType and not malloc call"); - const BitCastInst *BCI = NULL; - + const PointerType *MallocType = NULL; + unsigned NumOfBitCastUses = 0; + // Determine if CallInst has a bitcast use. for (Value::use_const_iterator UI = CI->use_begin(), E = CI->use_end(); UI != E; ) - if ((BCI = dyn_cast(cast(*UI++)))) - break; + if (const BitCastInst *BCI = dyn_cast(*UI++)) { + MallocType = cast(BCI->getDestTy()); + NumOfBitCastUses++; + } - // Malloc call has 1 bitcast use and no other uses, so type is the bitcast's - // destination type. - if (BCI && CI->hasOneUse()) - return cast(BCI->getDestTy()); + // Malloc call has 1 bitcast use, so type is the bitcast's destination type. + if (NumOfBitCastUses == 1) + return MallocType; // Malloc call was not bitcast, so type is the malloc function's return type. - if (!BCI) + if (NumOfBitCastUses == 0) return cast(CI->getType()); // Type could not be determined. return NULL; } -/// getMallocAllocatedType - Returns the Type allocated by malloc call. This -/// Type is the result type of the call's only bitcast use. If there is no -/// unique bitcast use, then return NULL. +/// getMallocAllocatedType - Returns the Type allocated by malloc call. +/// The Type depends on the number of bitcast uses of the malloc call: +/// 0: PointerType is the malloc calls' return type. +/// 1: PointerType is the bitcast's result type. +/// >1: Unique PointerType cannot be determined, return NULL. const Type *llvm::getMallocAllocatedType(const CallInst *CI) { const PointerType *PT = getMallocType(CI); return PT ? PT->getElementType() : NULL; Modified: llvm/trunk/lib/AsmParser/LLParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=86311&r1=86310&r2=86311&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLParser.cpp (original) +++ llvm/trunk/lib/AsmParser/LLParser.cpp Fri Nov 6 18:16:28 2009 @@ -3619,12 +3619,14 @@ // Autoupgrade old malloc instruction to malloc call. // FIXME: Remove in LLVM 3.0. const Type *IntPtrTy = Type::getInt32Ty(Context); + Constant *AllocSize = ConstantExpr::getSizeOf(Ty); + AllocSize = ConstantExpr::getTruncOrBitCast(AllocSize, IntPtrTy); if (!MallocF) // Prototype malloc as "void *(int32)". // This function is renamed as "malloc" in ValidateEndOfModule(). MallocF = cast( M->getOrInsertFunction("", Type::getInt8PtrTy(Context), IntPtrTy, NULL)); - Inst = CallInst::CreateMalloc(BB, IntPtrTy, Ty, Size, MallocF); + Inst = CallInst::CreateMalloc(BB, IntPtrTy, Ty, AllocSize, Size, MallocF); return false; } Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=86311&r1=86310&r2=86311&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original) +++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Fri Nov 6 18:16:28 2009 @@ -2101,8 +2101,10 @@ if (!Ty || !Size) return Error("Invalid MALLOC record"); if (!CurBB) return Error("Invalid malloc instruction with no BB"); const Type *Int32Ty = IntegerType::getInt32Ty(CurBB->getContext()); + Constant *AllocSize = ConstantExpr::getSizeOf(Ty->getElementType()); + AllocSize = ConstantExpr::getTruncOrBitCast(AllocSize, Int32Ty); I = CallInst::CreateMalloc(CurBB, Int32Ty, Ty->getElementType(), - Size, NULL); + AllocSize, Size, NULL); InstructionList.push_back(I); break; } Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=86311&r1=86310&r2=86311&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Fri Nov 6 18:16:28 2009 @@ -812,31 +812,41 @@ /// malloc into a global, and any loads of GV as uses of the new global. static GlobalVariable *OptimizeGlobalAddressOfMalloc(GlobalVariable *GV, CallInst *CI, - BitCastInst *BCI, + const Type *AllocTy, Value* NElems, TargetData* TD) { - DEBUG(errs() << "PROMOTING MALLOC GLOBAL: " << *GV - << " CALL = " << *CI << " BCI = " << *BCI << '\n'); + DEBUG(errs() << "PROMOTING GLOBAL: " << *GV << " CALL = " << *CI << '\n'); const Type *IntPtrTy = TD->getIntPtrType(GV->getContext()); + // CI has either 0 or 1 bitcast uses (getMallocType() would otherwise have + // returned NULL and we would not be here). + BitCastInst *BCI = NULL; + for (Value::use_iterator UI = CI->use_begin(), E = CI->use_end(); UI != E; ) + if ((BCI = dyn_cast(cast(*UI++)))) + break; + ConstantInt *NElements = cast(NElems); if (NElements->getZExtValue() != 1) { // If we have an array allocation, transform it to a single element // allocation to make the code below simpler. - Type *NewTy = ArrayType::get(getMallocAllocatedType(CI), - NElements->getZExtValue()); - Value* NewM = CallInst::CreateMalloc(CI, IntPtrTy, NewTy); - Instruction* NewMI = cast(NewM); + Type *NewTy = ArrayType::get(AllocTy, NElements->getZExtValue()); + unsigned TypeSize = TD->getTypeAllocSize(NewTy); + if (const StructType *ST = dyn_cast(NewTy)) + TypeSize = TD->getStructLayout(ST)->getSizeInBytes(); + Instruction *NewCI = CallInst::CreateMalloc(CI, IntPtrTy, NewTy, + ConstantInt::get(IntPtrTy, TypeSize)); Value* Indices[2]; Indices[0] = Indices[1] = Constant::getNullValue(IntPtrTy); - Value *NewGEP = GetElementPtrInst::Create(NewMI, Indices, Indices + 2, - NewMI->getName()+".el0", CI); - BCI->replaceAllUsesWith(NewGEP); - BCI->eraseFromParent(); + Value *NewGEP = GetElementPtrInst::Create(NewCI, Indices, Indices + 2, + NewCI->getName()+".el0", CI); + Value *Cast = new BitCastInst(NewGEP, CI->getType(), "el0", CI); + if (BCI) BCI->replaceAllUsesWith(NewGEP); + CI->replaceAllUsesWith(Cast); + if (BCI) BCI->eraseFromParent(); CI->eraseFromParent(); - BCI = cast(NewMI); - CI = extractMallocCallFromBitCast(NewMI); + BCI = dyn_cast(NewCI); + CI = BCI ? extractMallocCallFromBitCast(BCI) : cast(NewCI); } // Create the new global variable. The contents of the malloc'd memory is @@ -850,8 +860,9 @@ GV, GV->isThreadLocal()); - // Anything that used the malloc now uses the global directly. - BCI->replaceAllUsesWith(NewGV); + // Anything that used the malloc or its bitcast now uses the global directly. + if (BCI) BCI->replaceAllUsesWith(NewGV); + CI->replaceAllUsesWith(new BitCastInst(NewGV, CI->getType(), "newgv", CI)); Constant *RepValue = NewGV; if (NewGV->getType() != GV->getType()->getElementType()) @@ -919,9 +930,9 @@ GV->getParent()->getGlobalList().insert(GV, InitBool); - // Now the GV is dead, nuke it and the malloc. + // Now the GV is dead, nuke it and the malloc (both CI and BCI). GV->eraseFromParent(); - BCI->eraseFromParent(); + if (BCI) BCI->eraseFromParent(); CI->eraseFromParent(); // To further other optimizations, loop over all users of NewGV and try to @@ -1255,12 +1266,9 @@ /// PerformHeapAllocSRoA - CI is an allocation of an array of structures. Break /// it up into multiple allocations of arrays of the fields. -static GlobalVariable *PerformHeapAllocSRoA(GlobalVariable *GV, - CallInst *CI, BitCastInst* BCI, - Value* NElems, - TargetData *TD) { - DEBUG(errs() << "SROA HEAP ALLOC: " << *GV << " MALLOC CALL = " << *CI - << " BITCAST = " << *BCI << '\n'); +static GlobalVariable *PerformHeapAllocSRoA(GlobalVariable *GV, CallInst *CI, + Value* NElems, TargetData *TD) { + DEBUG(errs() << "SROA HEAP ALLOC: " << *GV << " MALLOC = " << *CI << '\n'); const Type* MAT = getMallocAllocatedType(CI); const StructType *STy = cast(MAT); @@ -1268,8 +1276,8 @@ // it into GV). If there are other uses, change them to be uses of // the global to simplify later code. This also deletes the store // into GV. - ReplaceUsesOfMallocWithGlobal(BCI, GV); - + ReplaceUsesOfMallocWithGlobal(CI, GV); + // Okay, at this point, there are no users of the malloc. Insert N // new mallocs at the same place as CI, and N globals. std::vector FieldGlobals; @@ -1287,11 +1295,16 @@ GV->isThreadLocal()); FieldGlobals.push_back(NGV); - Value *NMI = CallInst::CreateMalloc(CI, TD->getIntPtrType(CI->getContext()), - FieldTy, NElems, - BCI->getName() + ".f" + Twine(FieldNo)); + unsigned TypeSize = TD->getTypeAllocSize(FieldTy); + if (const StructType* ST = dyn_cast(FieldTy)) + TypeSize = TD->getStructLayout(ST)->getSizeInBytes(); + const Type* IntPtrTy = TD->getIntPtrType(CI->getContext()); + Value *NMI = CallInst::CreateMalloc(CI, IntPtrTy, FieldTy, + ConstantInt::get(IntPtrTy, TypeSize), + NElems, + CI->getName() + ".f" + Twine(FieldNo)); FieldMallocs.push_back(NMI); - new StoreInst(NMI, NGV, BCI); + new StoreInst(NMI, NGV, CI); } // The tricky aspect of this transformation is handling the case when malloc @@ -1308,18 +1321,18 @@ // } Value *RunningOr = 0; for (unsigned i = 0, e = FieldMallocs.size(); i != e; ++i) { - Value *Cond = new ICmpInst(BCI, ICmpInst::ICMP_EQ, FieldMallocs[i], - Constant::getNullValue(FieldMallocs[i]->getType()), - "isnull"); + Value *Cond = new ICmpInst(CI, ICmpInst::ICMP_EQ, FieldMallocs[i], + Constant::getNullValue(FieldMallocs[i]->getType()), + "isnull"); if (!RunningOr) RunningOr = Cond; // First seteq else - RunningOr = BinaryOperator::CreateOr(RunningOr, Cond, "tmp", BCI); + RunningOr = BinaryOperator::CreateOr(RunningOr, Cond, "tmp", CI); } // Split the basic block at the old malloc. - BasicBlock *OrigBB = BCI->getParent(); - BasicBlock *ContBB = OrigBB->splitBasicBlock(BCI, "malloc_cont"); + BasicBlock *OrigBB = CI->getParent(); + BasicBlock *ContBB = OrigBB->splitBasicBlock(CI, "malloc_cont"); // Create the block to check the first condition. Put all these blocks at the // end of the function as they are unlikely to be executed. @@ -1356,9 +1369,8 @@ } BranchInst::Create(ContBB, NullPtrBlock); - - // CI and BCI are no longer needed, remove them. - BCI->eraseFromParent(); + + // CI is no longer needed, remove it. CI->eraseFromParent(); /// InsertedScalarizedLoads - As we process loads, if we can't immediately @@ -1444,13 +1456,9 @@ /// cast of malloc. static bool TryToOptimizeStoreOfMallocToGlobal(GlobalVariable *GV, CallInst *CI, - BitCastInst *BCI, + const Type *AllocTy, Module::global_iterator &GVI, TargetData *TD) { - // If we can't figure out the type being malloced, then we can't optimize. - const Type *AllocTy = getMallocAllocatedType(CI); - assert(AllocTy); - // If this is a malloc of an abstract type, don't touch it. if (!AllocTy->isSized()) return false; @@ -1471,7 +1479,7 @@ // for. { SmallPtrSet PHIs; - if (!ValueIsOnlyUsedLocallyOrStoredToOneGlobal(BCI, GV, PHIs)) + if (!ValueIsOnlyUsedLocallyOrStoredToOneGlobal(CI, GV, PHIs)) return false; } @@ -1479,16 +1487,15 @@ // transform the program to use global memory instead of malloc'd memory. // This eliminates dynamic allocation, avoids an indirection accessing the // data, and exposes the resultant global to further GlobalOpt. - Value *NElems = getMallocArraySize(CI, TD); // We cannot optimize the malloc if we cannot determine malloc array size. - if (NElems) { + if (Value *NElems = getMallocArraySize(CI, TD)) { if (ConstantInt *NElements = dyn_cast(NElems)) // Restrict this transformation to only working on small allocations // (2048 bytes currently), as we don't want to introduce a 16M global or // something. if (TD && NElements->getZExtValue() * TD->getTypeAllocSize(AllocTy) < 2048) { - GVI = OptimizeGlobalAddressOfMalloc(GV, CI, BCI, NElems, TD); + GVI = OptimizeGlobalAddressOfMalloc(GV, CI, AllocTy, NElems, TD); return true; } @@ -1506,28 +1513,28 @@ // This the structure has an unreasonable number of fields, leave it // alone. if (AllocSTy->getNumElements() <= 16 && AllocSTy->getNumElements() != 0 && - AllGlobalLoadUsesSimpleEnoughForHeapSRA(GV, BCI)) { + AllGlobalLoadUsesSimpleEnoughForHeapSRA(GV, CI)) { // If this is a fixed size array, transform the Malloc to be an alloc of // structs. malloc [100 x struct],1 -> malloc struct, 100 if (const ArrayType *AT = dyn_cast(getMallocAllocatedType(CI))) { - Value *NumElements = - ConstantInt::get(Type::getInt32Ty(CI->getContext()), - AT->getNumElements()); - Value *NewMI = CallInst::CreateMalloc(CI, - TD->getIntPtrType(CI->getContext()), - AllocSTy, NumElements, - BCI->getName()); - Value *Cast = new BitCastInst(NewMI, getMallocType(CI), "tmp", CI); - BCI->replaceAllUsesWith(Cast); - BCI->eraseFromParent(); + const Type *IntPtrTy = TD->getIntPtrType(CI->getContext()); + unsigned TypeSize = TD->getStructLayout(AllocSTy)->getSizeInBytes(); + Value *AllocSize = ConstantInt::get(IntPtrTy, TypeSize); + Value *NumElements = ConstantInt::get(IntPtrTy, AT->getNumElements()); + Instruction *Malloc = CallInst::CreateMalloc(CI, IntPtrTy, AllocSTy, + AllocSize, NumElements, + CI->getName()); + Instruction *Cast = new BitCastInst(Malloc, CI->getType(), "tmp", CI); + CI->replaceAllUsesWith(Cast); CI->eraseFromParent(); - BCI = cast(NewMI); - CI = extractMallocCallFromBitCast(NewMI); + CI = dyn_cast(Malloc) ? + extractMallocCallFromBitCast(Malloc): + cast(Malloc); } - GVI = PerformHeapAllocSRoA(GV, CI, BCI, NElems, TD); + GVI = PerformHeapAllocSRoA(GV, CI, getMallocArraySize(CI, TD), TD); return true; } } @@ -1559,14 +1566,10 @@ if (OptimizeAwayTrappingUsesOfLoads(GV, SOVC)) return true; } else if (CallInst *CI = extractMallocCall(StoredOnceVal)) { - if (getMallocAllocatedType(CI)) { - BitCastInst* BCI = NULL; - for (Value::use_iterator UI = CI->use_begin(), E = CI->use_end(); - UI != E; ) - BCI = dyn_cast(cast(*UI++)); - if (BCI && TryToOptimizeStoreOfMallocToGlobal(GV, CI, BCI, GVI, TD)) - return true; - } + const Type* MallocType = getMallocAllocatedType(CI); + if (MallocType && TryToOptimizeStoreOfMallocToGlobal(GV, CI, MallocType, + GVI, TD)) + return true; } } Modified: llvm/trunk/lib/VMCore/Core.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Core.cpp?rev=86311&r1=86310&r2=86311&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Core.cpp (original) +++ llvm/trunk/lib/VMCore/Core.cpp Fri Nov 6 18:16:28 2009 @@ -1699,18 +1699,24 @@ LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef B, LLVMTypeRef Ty, const char *Name) { - const Type* IntPtrT = Type::getInt32Ty(unwrap(B)->GetInsertBlock()->getContext()); - return wrap(unwrap(B)->Insert(CallInst::CreateMalloc( - unwrap(B)->GetInsertBlock(), IntPtrT, unwrap(Ty), 0, 0, ""), - Twine(Name))); + const Type* ITy = Type::getInt32Ty(unwrap(B)->GetInsertBlock()->getContext()); + Constant* AllocSize = ConstantExpr::getSizeOf(unwrap(Ty)); + AllocSize = ConstantExpr::getTruncOrBitCast(AllocSize, ITy); + Instruction* Malloc = CallInst::CreateMalloc(unwrap(B)->GetInsertBlock(), + ITy, unwrap(Ty), AllocSize, + 0, 0, ""); + return wrap(unwrap(B)->Insert(Malloc, Twine(Name))); } LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Val, const char *Name) { - const Type* IntPtrT = Type::getInt32Ty(unwrap(B)->GetInsertBlock()->getContext()); - return wrap(unwrap(B)->Insert(CallInst::CreateMalloc( - unwrap(B)->GetInsertBlock(), IntPtrT, unwrap(Ty), unwrap(Val), 0, ""), - Twine(Name))); + const Type* ITy = Type::getInt32Ty(unwrap(B)->GetInsertBlock()->getContext()); + Constant* AllocSize = ConstantExpr::getSizeOf(unwrap(Ty)); + AllocSize = ConstantExpr::getTruncOrBitCast(AllocSize, ITy); + Instruction* Malloc = CallInst::CreateMalloc(unwrap(B)->GetInsertBlock(), + ITy, unwrap(Ty), AllocSize, + unwrap(Val), 0, ""); + return wrap(unwrap(B)->Insert(Malloc, Twine(Name))); } LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef B, LLVMTypeRef Ty, Modified: llvm/trunk/lib/VMCore/Instructions.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instructions.cpp?rev=86311&r1=86310&r2=86311&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Instructions.cpp (original) +++ llvm/trunk/lib/VMCore/Instructions.cpp Fri Nov 6 18:16:28 2009 @@ -24,6 +24,7 @@ #include "llvm/Support/CallSite.h" #include "llvm/Support/ConstantRange.h" #include "llvm/Support/MathExtras.h" +#include "llvm/Target/TargetData.h" using namespace llvm; @@ -448,22 +449,11 @@ return isa(val) && cast(val)->isOne(); } -static Value *checkArraySize(Value *Amt, const Type *IntPtrTy) { - if (!Amt) - Amt = ConstantInt::get(IntPtrTy, 1); - else { - assert(!isa(Amt) && - "Passed basic block into malloc size parameter! Use other ctor"); - assert(Amt->getType() == IntPtrTy && - "Malloc array size is not an intptr!"); - } - return Amt; -} - static Instruction *createMalloc(Instruction *InsertBefore, BasicBlock *InsertAtEnd, const Type *IntPtrTy, - const Type *AllocTy, Value *ArraySize, - Function *MallocF, const Twine &NameStr) { + const Type *AllocTy, Value *AllocSize, + Value *ArraySize, Function *MallocF, + const Twine &Name) { assert(((!InsertBefore && InsertAtEnd) || (InsertBefore && !InsertAtEnd)) && "createMalloc needs either InsertBefore or InsertAtEnd"); @@ -471,10 +461,14 @@ // bitcast (i8* malloc(typeSize)) to type* // malloc(type, arraySize) becomes: // bitcast (i8 *malloc(typeSize*arraySize)) to type* - Value *AllocSize = ConstantExpr::getSizeOf(AllocTy); - AllocSize = ConstantExpr::getTruncOrBitCast(cast(AllocSize), - IntPtrTy); - ArraySize = checkArraySize(ArraySize, IntPtrTy); + if (!ArraySize) + ArraySize = ConstantInt::get(IntPtrTy, 1); + else if (ArraySize->getType() != IntPtrTy) { + if (InsertBefore) + ArraySize = CastInst::CreateIntegerCast(ArraySize, IntPtrTy, false, "", InsertBefore); + else + ArraySize = CastInst::CreateIntegerCast(ArraySize, IntPtrTy, false, "", InsertAtEnd); + } if (!IsConstantOne(ArraySize)) { if (IsConstantOne(AllocSize)) { @@ -513,14 +507,14 @@ Result = MCall; if (Result->getType() != AllocPtrType) // Create a cast instruction to convert to the right type... - Result = new BitCastInst(MCall, AllocPtrType, NameStr, InsertBefore); + Result = new BitCastInst(MCall, AllocPtrType, Name, InsertBefore); } else { MCall = CallInst::Create(MallocF, AllocSize, "malloccall"); Result = MCall; if (Result->getType() != AllocPtrType) { InsertAtEnd->getInstList().push_back(MCall); // Create a cast instruction to convert to the right type... - Result = new BitCastInst(MCall, AllocPtrType, NameStr); + Result = new BitCastInst(MCall, AllocPtrType, Name); } } MCall->setTailCall(); @@ -539,8 +533,9 @@ /// 3. Bitcast the result of the malloc call to the specified type. Instruction *CallInst::CreateMalloc(Instruction *InsertBefore, const Type *IntPtrTy, const Type *AllocTy, - Value *ArraySize, const Twine &Name) { - return createMalloc(InsertBefore, NULL, IntPtrTy, AllocTy, + Value *AllocSize, Value *ArraySize, + const Twine &Name) { + return createMalloc(InsertBefore, NULL, IntPtrTy, AllocTy, AllocSize, ArraySize, NULL, Name); } @@ -554,9 +549,9 @@ /// responsibility of the caller. Instruction *CallInst::CreateMalloc(BasicBlock *InsertAtEnd, const Type *IntPtrTy, const Type *AllocTy, - Value *ArraySize, Function* MallocF, - const Twine &Name) { - return createMalloc(NULL, InsertAtEnd, IntPtrTy, AllocTy, + Value *AllocSize, Value *ArraySize, + Function *MallocF, const Twine &Name) { + return createMalloc(NULL, InsertAtEnd, IntPtrTy, AllocTy, AllocSize, ArraySize, MallocF, Name); } Modified: llvm/trunk/test/Analysis/PointerTracking/sizes.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/PointerTracking/sizes.ll?rev=86311&r1=86310&r2=86311&view=diff ============================================================================== --- llvm/trunk/test/Analysis/PointerTracking/sizes.ll (original) +++ llvm/trunk/test/Analysis/PointerTracking/sizes.ll Fri Nov 6 18:16:28 2009 @@ -31,6 +31,7 @@ } declare i32 @bar(i8*) +declare i32 @bar2(i64*) define i32 @foo1(i32 %n) nounwind { entry: @@ -60,11 +61,16 @@ ret i32 %add16 } -define i32 @foo2(i32 %n) nounwind { +define i32 @foo2(i64 %n) nounwind { entry: - %call = malloc i8, i32 %n ; [#uses=1] + %call = tail call i8* @malloc(i64 %n) ; [#uses=1] ; CHECK: %call = ; CHECK: ==> %n elements, %n bytes allocated + %mallocsize = mul i64 %n, 8 ; [#uses=1] + %malloccall = tail call i8* @malloc(i64 %mallocsize) ; [#uses=1] + %call3 = bitcast i8* %malloccall to i64* ; [#uses=1] +; CHECK: %malloccall = +; CHECK: ==> (8 * %n) elements, (8 * %n) bytes allocated %call2 = tail call i8* @calloc(i64 2, i64 4) nounwind ; [#uses=1] ; CHECK: %call2 = ; CHECK: ==> 8 elements, 8 bytes allocated @@ -72,13 +78,17 @@ ; CHECK: %call4 = ; CHECK: ==> 16 elements, 16 bytes allocated %call6 = tail call i32 @bar(i8* %call) nounwind ; [#uses=1] + %call7 = tail call i32 @bar2(i64* %call3) nounwind ; [#uses=1] %call8 = tail call i32 @bar(i8* %call2) nounwind ; [#uses=1] %call10 = tail call i32 @bar(i8* %call4) nounwind ; [#uses=1] - %add = add i32 %call8, %call6 ; [#uses=1] - %add11 = add i32 %add, %call10 ; [#uses=1] + %add = add i32 %call8, %call6 ; [#uses=1] + %add10 = add i32 %add, %call7 ; [#uses=1] + %add11 = add i32 %add10, %call10 ; [#uses=1] ret i32 %add11 } +declare noalias i8* @malloc(i64) nounwind + declare noalias i8* @calloc(i64, i64) nounwind declare noalias i8* @realloc(i8* nocapture, i64) nounwind Modified: llvm/trunk/test/Transforms/GlobalOpt/2009-06-01-RecursivePHI.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/2009-06-01-RecursivePHI.ll?rev=86311&r1=86310&r2=86311&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/2009-06-01-RecursivePHI.ll (original) +++ llvm/trunk/test/Transforms/GlobalOpt/2009-06-01-RecursivePHI.ll Fri Nov 6 18:16:28 2009 @@ -1,4 +1,5 @@ ; RUN: opt < %s -globalopt +target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" %struct.s_annealing_sched = type { i32, float, float, float, float } %struct.s_bb = type { i32, i32, i32, i32 } @@ -96,7 +97,9 @@ unreachable bb1.i38: ; preds = %bb - %0 = malloc %struct.s_net, i32 undef ; <%struct.s_net*> [#uses=1] + %mallocsize = mul i64 28, undef ; [#uses=1] + %malloccall = tail call i8* @malloc(i64 %mallocsize) ; [#uses=1] + %0 = bitcast i8* %malloccall to %struct.s_net* ; <%struct.s_net*> [#uses=1] br i1 undef, label %bb.i1.i39, label %my_malloc.exit2.i bb.i1.i39: ; preds = %bb1.i38 @@ -115,3 +118,5 @@ bb7: ; preds = %bb6.preheader unreachable } + +declare noalias i8* @malloc(i64) Modified: llvm/trunk/test/Transforms/GlobalOpt/heap-sra-1.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/heap-sra-1.ll?rev=86311&r1=86310&r2=86311&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/heap-sra-1.ll (original) +++ llvm/trunk/test/Transforms/GlobalOpt/heap-sra-1.ll Fri Nov 6 18:16:28 2009 @@ -1,18 +1,22 @@ -; RUN: opt < %s -globalopt -S | grep {@X.f0} -; RUN: opt < %s -globalopt -S | grep {@X.f1} -target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" -target triple = "i386-apple-darwin7" +; RUN: opt < %s -globalopt -S | FileCheck %s +target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" %struct.foo = type { i32, i32 } @X = internal global %struct.foo* null +; CHECK: @X.f0 +; CHECK: @X.f1 -define void @bar(i32 %Size) nounwind noinline { +define void @bar(i64 %Size) nounwind noinline { entry: - %.sub = malloc %struct.foo, i32 %Size + %mallocsize = mul i64 %Size, 8 ; [#uses=1] + %malloccall = tail call i8* @malloc(i64 %mallocsize) ; [#uses=1] + %.sub = bitcast i8* %malloccall to %struct.foo* ; <%struct.foo*> [#uses=1] store %struct.foo* %.sub, %struct.foo** @X, align 4 ret void } +declare noalias i8* @malloc(i64) + define i32 @baz() nounwind readonly noinline { bb1.thread: %0 = load %struct.foo** @X, align 4 Modified: llvm/trunk/test/Transforms/GlobalOpt/heap-sra-2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/heap-sra-2.ll?rev=86311&r1=86310&r2=86311&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/heap-sra-2.ll (original) +++ llvm/trunk/test/Transforms/GlobalOpt/heap-sra-2.ll Fri Nov 6 18:16:28 2009 @@ -1,20 +1,22 @@ -; RUN: opt < %s -globalopt -S | grep {@X.f0} -; RUN: opt < %s -globalopt -S | grep {@X.f1} +; RUN: opt < %s -globalopt -S | FileCheck %s +target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" -target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" -target triple = "i386-apple-darwin7" %struct.foo = type { i32, i32 } @X = internal global %struct.foo* null ; <%struct.foo**> [#uses=2] +; CHECK: @X.f0 +; CHECK: @X.f1 define void @bar(i32 %Size) nounwind noinline { entry: - %0 = malloc [1000000 x %struct.foo] - ;%.sub = bitcast [1000000 x %struct.foo]* %0 to %struct.foo* + %malloccall = tail call i8* @malloc(i64 8000000) ; [#uses=1] + %0 = bitcast i8* %malloccall to [1000000 x %struct.foo]* ; <[1000000 x %struct.foo]*> [#uses=1] %.sub = getelementptr [1000000 x %struct.foo]* %0, i32 0, i32 0 ; <%struct.foo*> [#uses=1] store %struct.foo* %.sub, %struct.foo** @X, align 4 ret void } +declare noalias i8* @malloc(i64) + define i32 @baz() nounwind readonly noinline { bb1.thread: %0 = load %struct.foo** @X, align 4 ; <%struct.foo*> [#uses=1] Modified: llvm/trunk/test/Transforms/GlobalOpt/heap-sra-3.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/heap-sra-3.ll?rev=86311&r1=86310&r2=86311&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/heap-sra-3.ll (original) +++ llvm/trunk/test/Transforms/GlobalOpt/heap-sra-3.ll Fri Nov 6 18:16:28 2009 @@ -1,24 +1,22 @@ ; RUN: opt < %s -globalopt -S | FileCheck %s - -target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" -target triple = "i386-apple-darwin10" +target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" %struct.foo = type { i32, i32 } @X = internal global %struct.foo* null ; CHECK: @X.f0 ; CHECK: @X.f1 -define void @bar(i32 %Size) nounwind noinline { +define void @bar(i64 %Size) nounwind noinline { entry: - %mallocsize = mul i32 ptrtoint (%struct.foo* getelementptr (%struct.foo* null, i32 1) to i32), %Size, ; [#uses=1] -; CHECK: mul i32 %Size - %malloccall = tail call i8* @malloc(i32 %mallocsize) ; [#uses=1] + %mallocsize = mul i64 8, %Size, ; [#uses=1] +; CHECK: mul i64 %Size, 4 + %malloccall = tail call i8* @malloc(i64 %mallocsize) ; [#uses=1] %.sub = bitcast i8* %malloccall to %struct.foo* ; <%struct.foo*> [#uses=1] store %struct.foo* %.sub, %struct.foo** @X, align 4 ret void } -declare noalias i8* @malloc(i32) +declare noalias i8* @malloc(i64) define i32 @baz() nounwind readonly noinline { bb1.thread: Modified: llvm/trunk/test/Transforms/GlobalOpt/heap-sra-4.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/heap-sra-4.ll?rev=86311&r1=86310&r2=86311&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/heap-sra-4.ll (original) +++ llvm/trunk/test/Transforms/GlobalOpt/heap-sra-4.ll Fri Nov 6 18:16:28 2009 @@ -1,24 +1,22 @@ ; RUN: opt < %s -globalopt -S | FileCheck %s - -target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" -target triple = "i386-apple-darwin7" +target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" %struct.foo = type { i32, i32 } @X = internal global %struct.foo* null ; CHECK: @X.f0 ; CHECK: @X.f1 -define void @bar(i32 %Size) nounwind noinline { +define void @bar(i64 %Size) nounwind noinline { entry: - %mallocsize = shl i32 ptrtoint (%struct.foo* getelementptr (%struct.foo* null, i32 1) to i32), 9, ; [#uses=1] - %malloccall = tail call i8* @malloc(i32 %mallocsize) ; [#uses=1] -; CHECK: @malloc(i32 mul (i32 512 + %mallocsize = shl i64 %Size, 3 ; [#uses=1] + %malloccall = tail call i8* @malloc(i64 %mallocsize) ; [#uses=1] +; CHECK: mul i64 %Size, 4 %.sub = bitcast i8* %malloccall to %struct.foo* ; <%struct.foo*> [#uses=1] store %struct.foo* %.sub, %struct.foo** @X, align 4 ret void } -declare noalias i8* @malloc(i32) +declare noalias i8* @malloc(i64) define i32 @baz() nounwind readonly noinline { bb1.thread: Modified: llvm/trunk/test/Transforms/GlobalOpt/heap-sra-phi.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/heap-sra-phi.ll?rev=86311&r1=86310&r2=86311&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/heap-sra-phi.ll (original) +++ llvm/trunk/test/Transforms/GlobalOpt/heap-sra-phi.ll Fri Nov 6 18:16:28 2009 @@ -1,19 +1,21 @@ ; RUN: opt < %s -globalopt -S | grep {tmp.f1 = phi i32. } ; RUN: opt < %s -globalopt -S | grep {tmp.f0 = phi i32. } +target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" -target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" -target triple = "i386-apple-darwin7" %struct.foo = type { i32, i32 } @X = internal global %struct.foo* null ; <%struct.foo**> [#uses=2] define void @bar(i32 %Size) nounwind noinline { entry: - %tmp = malloc [1000000 x %struct.foo] ; <[1000000 x %struct.foo]*> [#uses=1] + %malloccall = tail call i8* @malloc(i64 8000000) ; [#uses=1] + %tmp = bitcast i8* %malloccall to [1000000 x %struct.foo]* ; <[1000000 x %struct.foo]*> [#uses=1] %.sub = getelementptr [1000000 x %struct.foo]* %tmp, i32 0, i32 0 ; <%struct.foo*> [#uses=1] store %struct.foo* %.sub, %struct.foo** @X, align 4 ret void } +declare noalias i8* @malloc(i64) + define i32 @baz() nounwind readonly noinline { bb1.thread: %tmpLD1 = load %struct.foo** @X, align 4 ; <%struct.foo*> [#uses=1] Modified: llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-1.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-1.ll?rev=86311&r1=86310&r2=86311&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-1.ll (original) +++ llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-1.ll Fri Nov 6 18:16:28 2009 @@ -1,19 +1,24 @@ -; RUN: opt < %s -globalopt -S | not grep global +; RUN: opt < %s -globalopt -S | FileCheck %s target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" @G = internal global i32* null ; [#uses=3] +; CHECK-NOT: global define void @init() { - %P = malloc i32 ; [#uses=1] + %malloccall = tail call i8* @malloc(i64 4) ; [#uses=1] + %P = bitcast i8* %malloccall to i32* ; [#uses=1] store i32* %P, i32** @G %GV = load i32** @G ; [#uses=1] store i32 0, i32* %GV ret void } +declare noalias i8* @malloc(i64) + define i32 @get() { %GV = load i32** @G ; [#uses=1] %V = load i32* %GV ; [#uses=1] ret i32 %V +; CHECK: ret i32 0 } Modified: llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-2.ll?rev=86311&r1=86310&r2=86311&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-2.ll (original) +++ llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-2.ll Fri Nov 6 18:16:28 2009 @@ -1,11 +1,11 @@ ; RUN: opt < %s -globalopt -globaldce -S | not grep malloc -target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" -target triple = "i686-apple-darwin8" +target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" @G = internal global i32* null ; [#uses=3] define void @init() { - %P = malloc i32, i32 100 ; [#uses=1] + %malloccall = tail call i8* @malloc(i64 mul (i64 100, i64 4)) ; [#uses=1] + %P = bitcast i8* %malloccall to i32* ; [#uses=1] store i32* %P, i32** @G %GV = load i32** @G ; [#uses=1] %GVe = getelementptr i32* %GV, i32 40 ; [#uses=1] @@ -13,6 +13,8 @@ ret void } +declare noalias i8* @malloc(i64) + define i32 @get() { %GV = load i32** @G ; [#uses=1] %GVe = getelementptr i32* %GV, i32 40 ; [#uses=1] Modified: llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-3.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-3.ll?rev=86311&r1=86310&r2=86311&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-3.ll (original) +++ llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-3.ll Fri Nov 6 18:16:28 2009 @@ -1,11 +1,11 @@ ; RUN: opt < %s -globalopt -globaldce -S | not grep malloc -target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" -target triple = "i686-apple-darwin8" +target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" @G = internal global i32* null ; [#uses=4] define void @init() { - %P = malloc i32, i32 100 ; [#uses=1] + %malloccall = tail call i8* @malloc(i64 mul (i64 100, i64 4)) ; [#uses=1] + %P = bitcast i8* %malloccall to i32* ; [#uses=1] store i32* %P, i32** @G %GV = load i32** @G ; [#uses=1] %GVe = getelementptr i32* %GV, i32 40 ; [#uses=1] @@ -13,6 +13,8 @@ ret void } +declare noalias i8* @malloc(i64) + define i32 @get() { %GV = load i32** @G ; [#uses=1] %GVe = getelementptr i32* %GV, i32 40 ; [#uses=1] From jyasskin at google.com Fri Nov 6 18:26:48 2009 From: jyasskin at google.com (Jeffrey Yasskin) Date: Sat, 07 Nov 2009 00:26:48 -0000 Subject: [llvm-commits] [llvm] r86314 - /llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Message-ID: <200911070026.nA70Qmar011533@zion.cs.uiuc.edu> Author: jyasskin Date: Fri Nov 6 18:26:47 2009 New Revision: 86314 URL: http://llvm.org/viewvc/llvm-project?rev=86314&view=rev Log: Avoid "ambiguous 'else'" warning from gcc. Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=86314&r1=86313&r2=86314&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Fri Nov 6 18:26:47 2009 @@ -213,11 +213,12 @@ return ConstantExpr::getCompare(pred, CLHS, CRHS); if (LHS == RHS) - if (isa(LHS->getType()) || isa(LHS->getType())) + if (isa(LHS->getType()) || isa(LHS->getType())) { if (ICmpInst::isTrueWhenEqual(pred)) return ConstantInt::getTrue(LHS->getContext()); else return ConstantInt::getFalse(LHS->getContext()); + } return 0; } From stoklund at 2pi.dk Fri Nov 6 18:30:54 2009 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Fri, 6 Nov 2009 16:30:54 -0800 Subject: [llvm-commits] [llvm] r86303 - in /llvm/trunk: lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp test/CodeGen/ARM/2009-11-07-SubRegAsmPrinting.ll In-Reply-To: <200911062345.nA6NjG1Y009900@zion.cs.uiuc.edu> References: <200911062345.nA6NjG1Y009900@zion.cs.uiuc.edu> Message-ID: On Nov 6, 2009, at 3:45 PM, Anton Korobeynikov wrote: > Author: asl > Date: Fri Nov 6 17:45:15 2009 > New Revision: 86303 > > URL: http://llvm.org/viewvc/llvm-project?rev=86303&view=rev > Log: > Honour subreg machine operands during asmprinting > > Added: > llvm/trunk/test/CodeGen/ARM/2009-11-07-SubRegAsmPrinting.ll > 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=86303&r1=86302&r2=86303&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original) > +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Fri Nov > 6 17:45:15 2009 > @@ -347,6 +347,9 @@ > > &ARM::DPR_VFP2RegClass); > O << getRegisterName(DReg) << '[' << (RegNum & 1) << ']'; > } else { > + if (unsigned SubReg = MO.getSubReg()) > + Reg = TRI->getSubReg(Reg, SubReg); > + > O << getRegisterName(Reg); > } > break; I thought that the SubReg field was only to be used with virtual registers? Is this perhaps a bug in an earlier stage? /jakob From evan.cheng at apple.com Fri Nov 6 18:34:10 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 6 Nov 2009 16:34:10 -0800 Subject: [llvm-commits] [llvm] r86303 - in /llvm/trunk: lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp test/CodeGen/ARM/2009-11-07-SubRegAsmPrinting.ll In-Reply-To: References: <200911062345.nA6NjG1Y009900@zion.cs.uiuc.edu> Message-ID: <07E87410-00C7-444B-981B-E80A8B79B75A@apple.com> On Nov 6, 2009, at 4:30 PM, Jakob Stoklund Olesen wrote: >> >> = >> ===================================================================== >> --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original) >> +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Fri Nov >> 6 17:45:15 2009 >> @@ -347,6 +347,9 @@ >> >> &ARM::DPR_VFP2RegClass); >> O << getRegisterName(DReg) << '[' << (RegNum & 1) << ']'; >> } else { >> + if (unsigned SubReg = MO.getSubReg()) >> + Reg = TRI->getSubReg(Reg, SubReg); >> + >> O << getRegisterName(Reg); >> } >> break; > > I thought that the SubReg field was only to be used with virtual > registers? > > Is this perhaps a bug in an earlier stage? Right. It should not have survived earlier passes. Evan > > /jakob > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From vhernandez at apple.com Fri Nov 6 18:36:51 2009 From: vhernandez at apple.com (Victor Hernandez) Date: Sat, 07 Nov 2009 00:36:51 -0000 Subject: [llvm-commits] [llvm] r86316 - /llvm/trunk/lib/VMCore/Instructions.cpp Message-ID: <200911070036.nA70apJA011905@zion.cs.uiuc.edu> Author: hernande Date: Fri Nov 6 18:36:50 2009 New Revision: 86316 URL: http://llvm.org/viewvc/llvm-project?rev=86316&view=rev Log: Fit in 80 columns Modified: llvm/trunk/lib/VMCore/Instructions.cpp Modified: llvm/trunk/lib/VMCore/Instructions.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instructions.cpp?rev=86316&r1=86315&r2=86316&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Instructions.cpp (original) +++ llvm/trunk/lib/VMCore/Instructions.cpp Fri Nov 6 18:36:50 2009 @@ -465,9 +465,11 @@ ArraySize = ConstantInt::get(IntPtrTy, 1); else if (ArraySize->getType() != IntPtrTy) { if (InsertBefore) - ArraySize = CastInst::CreateIntegerCast(ArraySize, IntPtrTy, false, "", InsertBefore); + ArraySize = CastInst::CreateIntegerCast(ArraySize, IntPtrTy, false, + "", InsertBefore); else - ArraySize = CastInst::CreateIntegerCast(ArraySize, IntPtrTy, false, "", InsertAtEnd); + ArraySize = CastInst::CreateIntegerCast(ArraySize, IntPtrTy, false, + "", InsertAtEnd); } if (!IsConstantOne(ArraySize)) { From asl at math.spbu.ru Fri Nov 6 18:37:38 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Sat, 7 Nov 2009 03:37:38 +0300 Subject: [llvm-commits] [llvm] r86303 - in /llvm/trunk: lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp test/CodeGen/ARM/2009-11-07-SubRegAsmPrinting.ll In-Reply-To: References: <200911062345.nA6NjG1Y009900@zion.cs.uiuc.edu> Message-ID: Hello, Jakob > I thought that the SubReg field was only to be used with virtual > registers? I also thought so initially, but it seems, not > Is this perhaps a bug in an earlier stage? Maybe, originally we have something like this: reg1 = imp_def reg2 = fconsts fp-imm reg1 = insert_subreg reg1, reg2, idx basically, the other part will always be undef here this is later turned into something like reg1:idx = fconsts fp-imm and passed until the late end. -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From asl at math.spbu.ru Fri Nov 6 18:38:57 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Sat, 7 Nov 2009 03:38:57 +0300 Subject: [llvm-commits] [llvm] r86303 - in /llvm/trunk: lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp test/CodeGen/ARM/2009-11-07-SubRegAsmPrinting.ll In-Reply-To: <07E87410-00C7-444B-981B-E80A8B79B75A@apple.com> References: <200911062345.nA6NjG1Y009900@zion.cs.uiuc.edu> <07E87410-00C7-444B-981B-E80A8B79B75A@apple.com> Message-ID: Hello, Evan > Right. It should not have survived earlier passes. Ok. Then we need at least assert() during asmprinting. In any case - testcase is given, should I fill (another) PR? -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From vhernandez at apple.com Fri Nov 6 18:41:19 2009 From: vhernandez at apple.com (Victor Hernandez) Date: Sat, 07 Nov 2009 00:41:19 -0000 Subject: [llvm-commits] [llvm] r86317 - /llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Message-ID: <200911070041.nA70fJaQ012070@zion.cs.uiuc.edu> Author: hernande Date: Fri Nov 6 18:41:19 2009 New Revision: 86317 URL: http://llvm.org/viewvc/llvm-project?rev=86317&view=rev Log: - new SROA mallocs should have the mallocs running-or'ed, not the malloc's bitcast - fix ProcessInternalGlobal() debug output Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=86317&r1=86316&r2=86317&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Fri Nov 6 18:41:19 2009 @@ -1296,14 +1296,16 @@ FieldGlobals.push_back(NGV); unsigned TypeSize = TD->getTypeAllocSize(FieldTy); - if (const StructType* ST = dyn_cast(FieldTy)) + if (const StructType *ST = dyn_cast(FieldTy)) TypeSize = TD->getStructLayout(ST)->getSizeInBytes(); - const Type* IntPtrTy = TD->getIntPtrType(CI->getContext()); + const Type *IntPtrTy = TD->getIntPtrType(CI->getContext()); Value *NMI = CallInst::CreateMalloc(CI, IntPtrTy, FieldTy, ConstantInt::get(IntPtrTy, TypeSize), NElems, CI->getName() + ".f" + Twine(FieldNo)); - FieldMallocs.push_back(NMI); + CallInst *NCI = dyn_cast(NMI) ? + extractMallocCallFromBitCast(NMI) : cast(NMI); + FieldMallocs.push_back(NCI); new StoreInst(NMI, NGV, CI); } @@ -1530,8 +1532,7 @@ CI->replaceAllUsesWith(Cast); CI->eraseFromParent(); CI = dyn_cast(Malloc) ? - extractMallocCallFromBitCast(Malloc): - cast(Malloc); + extractMallocCallFromBitCast(Malloc) : cast(Malloc); } GVI = PerformHeapAllocSRoA(GV, CI, getMallocArraySize(CI, TD), TD); @@ -1688,24 +1689,26 @@ if (!AnalyzeGlobal(GV, GS, PHIUsers)) { #if 0 - cerr << "Global: " << *GV; - cerr << " isLoaded = " << GS.isLoaded << "\n"; - cerr << " StoredType = "; + DEBUG(errs() << "Global: " << *GV); + DEBUG(errs() << " isLoaded = " << GS.isLoaded << "\n"); + DEBUG(errs() << " StoredType = "); switch (GS.StoredType) { - case GlobalStatus::NotStored: cerr << "NEVER STORED\n"; break; - case GlobalStatus::isInitializerStored: cerr << "INIT STORED\n"; break; - case GlobalStatus::isStoredOnce: cerr << "STORED ONCE\n"; break; - case GlobalStatus::isStored: cerr << "stored\n"; break; + case GlobalStatus::NotStored: DEBUG(errs() << "NEVER STORED\n"); break; + case GlobalStatus::isInitializerStored: DEBUG(errs() << "INIT STORED\n"); + break; + case GlobalStatus::isStoredOnce: DEBUG(errs() << "STORED ONCE\n"); break; + case GlobalStatus::isStored: DEBUG(errs() << "stored\n"); break; } if (GS.StoredType == GlobalStatus::isStoredOnce && GS.StoredOnceValue) - cerr << " StoredOnceValue = " << *GS.StoredOnceValue << "\n"; + DEBUG(errs() << " StoredOnceValue = " << *GS.StoredOnceValue << "\n"); if (GS.AccessingFunction && !GS.HasMultipleAccessingFunctions) - cerr << " AccessingFunction = " << GS.AccessingFunction->getName() - << "\n"; - cerr << " HasMultipleAccessingFunctions = " - << GS.HasMultipleAccessingFunctions << "\n"; - cerr << " HasNonInstructionUser = " << GS.HasNonInstructionUser<<"\n"; - cerr << "\n"; + DEBUG(errs() << " AccessingFunction = " << GS.AccessingFunction->getName() + << "\n"); + DEBUG(errs() << " HasMultipleAccessingFunctions = " + << GS.HasMultipleAccessingFunctions << "\n"); + DEBUG(errs() << " HasNonInstructionUser = " + << GS.HasNonInstructionUser<<"\n"); + DEBUG(errs() << "\n"); #endif // If this is a first class global and has only one accessing function From stoklund at 2pi.dk Fri Nov 6 18:43:59 2009 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Fri, 6 Nov 2009 16:43:59 -0800 Subject: [llvm-commits] [llvm] r86303 - in /llvm/trunk: lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp test/CodeGen/ARM/2009-11-07-SubRegAsmPrinting.ll In-Reply-To: References: <200911062345.nA6NjG1Y009900@zion.cs.uiuc.edu> <07E87410-00C7-444B-981B-E80A8B79B75A@apple.com> Message-ID: On Nov 6, 2009, at 4:38 PM, Anton Korobeynikov wrote: > Hello, Evan > >> Right. It should not have survived earlier passes. > Ok. Then we need at least assert() during asmprinting. I agree. > In any case - > testcase is given, should I fill (another) PR? Can you reduce it further with an assert in asmprinting? /jakob From asl at math.spbu.ru Fri Nov 6 18:50:14 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Sat, 7 Nov 2009 03:50:14 +0300 Subject: [llvm-commits] [llvm] r86303 - in /llvm/trunk: lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp test/CodeGen/ARM/2009-11-07-SubRegAsmPrinting.ll In-Reply-To: References: <200911062345.nA6NjG1Y009900@zion.cs.uiuc.edu> <07E87410-00C7-444B-981B-E80A8B79B75A@apple.com> Message-ID: Hello, Jakob > Can you reduce it further with an assert in asmprinting? No, this is smallest reduction obtained exactly this way :) -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From johnny.chen at apple.com Fri Nov 6 18:54:36 2009 From: johnny.chen at apple.com (Johnny Chen) Date: Sat, 07 Nov 2009 00:54:36 -0000 Subject: [llvm-commits] [llvm] r86319 - /llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Message-ID: <200911070054.nA70saSM012531@zion.cs.uiuc.edu> Author: johnny Date: Fri Nov 6 18:54:36 2009 New Revision: 86319 URL: http://llvm.org/viewvc/llvm-project?rev=86319&view=rev Log: My previous patch (r84124) for setting the encoding bits 4 and 7 of DPSoRegFrm was wrong and too aggressive in the sense that DPSoRegFrm includes both constant shifts (with Inst{4} = 0) and register controlled shifts (with Inst{4} = 1 and Inst{7} = 0). The 'rr' fragment of the multiclass definitions actually means register/register with no shift, see A8-11. Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=86319&r1=86318&r2=86319&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Fri Nov 6 18:54:36 2009 @@ -377,15 +377,13 @@ def rr : AsI1 { - let Inst{4} = 0; + let Inst{11-4} = 0b00000000; let Inst{25} = 0; let isCommutable = Commutable; } def rs : AsI1 { - let Inst{4} = 1; - let Inst{7} = 0; let Inst{25} = 0; } } @@ -405,15 +403,13 @@ IIC_iALUr, opc, "s\t$dst, $a, $b", [(set GPR:$dst, (opnode GPR:$a, GPR:$b))]> { let isCommutable = Commutable; - let Inst{4} = 0; + let Inst{11-4} = 0b00000000; let Inst{20} = 1; let Inst{25} = 0; } def rs : AI1 { - let Inst{4} = 1; - let Inst{7} = 0; let Inst{20} = 1; let Inst{25} = 0; } @@ -435,7 +431,7 @@ def rr : AI1 { - let Inst{4} = 0; + let Inst{11-4} = 0b00000000; let Inst{20} = 1; let Inst{25} = 0; let isCommutable = Commutable; @@ -443,8 +439,6 @@ def rs : AI1 { - let Inst{4} = 1; - let Inst{7} = 0; let Inst{20} = 1; let Inst{25} = 0; } @@ -501,15 +495,13 @@ [(set GPR:$dst, (opnode GPR:$a, GPR:$b))]>, Requires<[IsARM, CarryDefIsUnused]> { let isCommutable = Commutable; - let Inst{4} = 0; + let Inst{11-4} = 0b00000000; let Inst{25} = 0; } def rs : AsI1, Requires<[IsARM, CarryDefIsUnused]> { - let Inst{4} = 1; - let Inst{7} = 0; let Inst{25} = 0; } // Carry setting variants @@ -526,7 +518,7 @@ [(set GPR:$dst, (opnode GPR:$a, GPR:$b))]>, Requires<[IsARM, CarryDefIsUsed]> { let Defs = [CPSR]; - let Inst{4} = 0; + let Inst{11-4} = 0b00000000; let Inst{20} = 1; let Inst{25} = 0; } @@ -535,8 +527,6 @@ [(set GPR:$dst, (opnode GPR:$a, so_reg:$b))]>, Requires<[IsARM, CarryDefIsUsed]> { let Defs = [CPSR]; - let Inst{4} = 1; - let Inst{7} = 0; let Inst{20} = 1; let Inst{25} = 0; } @@ -963,15 +953,13 @@ let neverHasSideEffects = 1 in def MOVr : AsI1<0b1101, (outs GPR:$dst), (ins GPR:$src), DPFrm, IIC_iMOVr, "mov", "\t$dst, $src", []>, UnaryDP { - let Inst{4} = 0; + let Inst{11-4} = 0b00000000; let Inst{25} = 0; } def MOVs : AsI1<0b1101, (outs GPR:$dst), (ins so_reg:$src), DPSoRegFrm, IIC_iMOVsr, "mov", "\t$dst, $src", [(set GPR:$dst, so_reg:$src)]>, UnaryDP { - let Inst{4} = 1; - let Inst{7} = 0; let Inst{25} = 0; } @@ -1115,8 +1103,6 @@ def RSBrs : AsI1<0b0011, (outs GPR:$dst), (ins GPR:$a, so_reg:$b), DPSoRegFrm, IIC_iALUsr, "rsb", "\t$dst, $a, $b", [(set GPR:$dst, (sub so_reg:$b, GPR:$a))]> { - let Inst{4} = 1; - let Inst{7} = 0; let Inst{25} = 0; } @@ -1131,8 +1117,6 @@ def RSBSrs : AI1<0b0011, (outs GPR:$dst), (ins GPR:$a, so_reg:$b), DPSoRegFrm, IIC_iALUsr, "rsb", "s\t$dst, $a, $b", [(set GPR:$dst, (subc so_reg:$b, GPR:$a))]> { - let Inst{4} = 1; - let Inst{7} = 0; let Inst{20} = 1; let Inst{25} = 0; } @@ -1149,8 +1133,6 @@ DPSoRegFrm, IIC_iALUsr, "rsc", "\t$dst, $a, $b", [(set GPR:$dst, (sube so_reg:$b, GPR:$a))]>, Requires<[IsARM, CarryDefIsUnused]> { - let Inst{4} = 1; - let Inst{7} = 0; let Inst{25} = 0; } } @@ -1168,8 +1150,6 @@ DPSoRegFrm, IIC_iALUsr, "rscs\t$dst, $a, $b", [(set GPR:$dst, (sube so_reg:$b, GPR:$a))]>, Requires<[IsARM, CarryDefIsUnused]> { - let Inst{4} = 1; - let Inst{7} = 0; let Inst{20} = 1; let Inst{25} = 0; } @@ -1216,14 +1196,11 @@ def MVNr : AsI1<0b1111, (outs GPR:$dst), (ins GPR:$src), DPFrm, IIC_iMOVr, "mvn", "\t$dst, $src", [(set GPR:$dst, (not GPR:$src))]>, UnaryDP { - let Inst{4} = 0; + let Inst{11-4} = 0b00000000; } def MVNs : AsI1<0b1111, (outs GPR:$dst), (ins so_reg:$src), DPSoRegFrm, IIC_iMOVsr, "mvn", "\t$dst, $src", - [(set GPR:$dst, (not so_reg:$src))]>, UnaryDP { - let Inst{4} = 1; - let Inst{7} = 0; -} + [(set GPR:$dst, (not so_reg:$src))]>, UnaryDP; let isReMaterializable = 1, isAsCheapAsAMove = 1 in def MVNi : AsI1<0b1111, (outs GPR:$dst), (ins so_imm:$imm), DPFrm, IIC_iMOVi, "mvn", "\t$dst, $imm", @@ -1536,7 +1513,7 @@ IIC_iCMOVr, "mov", "\t$dst, $true", [/*(set GPR:$dst, (ARMcmov GPR:$false, GPR:$true, imm:$cc, CCR:$ccr))*/]>, RegConstraint<"$false = $dst">, UnaryDP { - let Inst{4} = 0; + let Inst{11-4} = 0b00000000; let Inst{25} = 0; } @@ -1545,8 +1522,6 @@ "mov", "\t$dst, $true", [/*(set GPR:$dst, (ARMcmov GPR:$false, so_reg:$true, imm:$cc, CCR:$ccr))*/]>, RegConstraint<"$false = $dst">, UnaryDP { - let Inst{4} = 1; - let Inst{7} = 0; let Inst{25} = 0; } From gohman at apple.com Fri Nov 6 19:17:55 2009 From: gohman at apple.com (Dan Gohman) Date: Fri, 6 Nov 2009 17:17:55 -0800 Subject: [llvm-commits] [PATCH] At beginning of SelectionDAGISel::LowerArguments, see if return values can be lowered to registers In-Reply-To: <400d33ea0911050951x4ed610d6q7badfb193315be94@mail.gmail.com> References: <400d33ea0911050951x4ed610d6q7badfb193315be94@mail.gmail.com> Message-ID: Hello, This looks good to me, though please use spaces instead of tabs for indentation. It would be cool if we could find a way to implement CanLowerReturn without using target-specific code, since it doesn't have very much target-specific logic in it, but I'm fine leaving this as it is for now. Dan On Nov 5, 2009, at 9:51 AM, Kenneth Uildriks wrote: > Right now, it simply asserts if the return values cannot be lowered. > I'm working on code that will perform an sret-demotion on function > definitions and function calls if the return values cannot be lowered > to registers; this will allow arbitrary-sized struct returns to get > through codegen without crashing. > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From kennethuil at gmail.com Fri Nov 6 19:29:04 2009 From: kennethuil at gmail.com (Kenneth Uildriks) Date: Fri, 6 Nov 2009 19:29:04 -0600 Subject: [llvm-commits] [PATCH] At beginning of SelectionDAGISel::LowerArguments, see if return values can be lowered to registers In-Reply-To: References: <400d33ea0911050951x4ed610d6q7badfb193315be94@mail.gmail.com> Message-ID: <400d33ea0911061729o45821c10yb685a6b7561c1e61@mail.gmail.com> On Fri, Nov 6, 2009 at 7:17 PM, Dan Gohman wrote: > Hello, > > This looks good to me, though please use spaces instead of tabs for > indentation. I thought I did. Sometimes my editor is too smart for its own good. I'll fix it before I check it in. > > It would be cool if we could find a way to implement CanLowerReturn > without using target-specific code, since it doesn't have very much > target-specific logic in it, but I'm fine leaving this as it is > for now. I'd love to pull that off too, but like LowerReturn/AnalyzeReturnValues, it needs the assign callback. It could probably be tablegen'd somehow, since it doesn't have to do any actual register assignments afterwards. When I finish the automatic sret-demotion, I'll need some help to test it on various targets... all I've got is an X86. Thanks for looking at it. From dpatel at apple.com Fri Nov 6 19:32:59 2009 From: dpatel at apple.com (Devang Patel) Date: Sat, 07 Nov 2009 01:32:59 -0000 Subject: [llvm-commits] [llvm] r86321 - in /llvm/trunk: lib/Transforms/Scalar/JumpThreading.cpp test/Transforms/JumpThreading/basic.ll test/Transforms/JumpThreading/crash.ll Message-ID: <200911070132.nA71WxrW013736@zion.cs.uiuc.edu> Author: dpatel Date: Fri Nov 6 19:32:59 2009 New Revision: 86321 URL: http://llvm.org/viewvc/llvm-project?rev=86321&view=rev Log: Revert following patches to fix llvmgcc bootstrap. 86289, 86278, 86270, 86267, 86266 & 86264 Chris, please take a look. Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp llvm/trunk/test/Transforms/JumpThreading/basic.ll llvm/trunk/test/Transforms/JumpThreading/crash.ll Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=86321&r1=86320&r2=86321&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Fri Nov 6 19:32:59 2009 @@ -75,19 +75,14 @@ bool ThreadEdge(BasicBlock *BB, BasicBlock *PredBB, BasicBlock *SuccBB); bool DuplicateCondBranchOnPHIIntoPred(BasicBlock *BB, BasicBlock *PredBB); - - typedef SmallVectorImpl > PredValueInfo; - - bool ComputeValueKnownInPredecessors(Value *V, BasicBlock *BB, - PredValueInfo &Result); - bool ProcessThreadableEdges(Instruction *CondInst, BasicBlock *BB); - - + + BasicBlock *FactorCommonPHIPreds(PHINode *PN, Value *Val); bool ProcessBranchOnDuplicateCond(BasicBlock *PredBB, BasicBlock *DestBB); bool ProcessSwitchOnDuplicateCond(BasicBlock *PredBB, BasicBlock *DestBB); bool ProcessJumpOnPHI(PHINode *PN); + bool ProcessBranchOnLogical(Value *V, BasicBlock *BB, bool isAnd); + bool ProcessBranchOnCompare(CmpInst *Cmp, BasicBlock *BB); bool SimplifyPartiallyRedundantLoad(LoadInst *LI); }; @@ -203,133 +198,28 @@ LoopHeaders.insert(const_cast(Edges[i].second)); } -/// GetResultOfComparison - Given an icmp/fcmp predicate and the left and right -/// hand sides of the compare instruction, try to determine the result. If the -/// result can not be determined, a null pointer is returned. -static Constant *GetResultOfComparison(CmpInst::Predicate pred, - Value *LHS, Value *RHS) { - if (Constant *CLHS = dyn_cast(LHS)) - if (Constant *CRHS = dyn_cast(RHS)) - return ConstantExpr::getCompare(pred, CLHS, CRHS); - - if (LHS == RHS) - if (isa(LHS->getType()) || isa(LHS->getType())) { - if (ICmpInst::isTrueWhenEqual(pred)) - return ConstantInt::getTrue(LHS->getContext()); - else - return ConstantInt::getFalse(LHS->getContext()); - } - return 0; -} - - -/// ComputeValueKnownInPredecessors - Given a basic block BB and a value V, see -/// if we can infer that the value is a known ConstantInt in any of our -/// predecessors. If so, return the known the list of value and pred BB in the -/// result vector. If a value is known to be undef, it is returned as null. -/// -/// The BB basic block is known to start with a PHI node. -/// -/// This returns true if there were any known values. +/// FactorCommonPHIPreds - If there are multiple preds with the same incoming +/// value for the PHI, factor them together so we get one block to thread for +/// the whole group. +/// This is important for things like "phi i1 [true, true, false, true, x]" +/// where we only need to clone the block for the true blocks once. /// -/// -/// TODO: Per PR2563, we could infer value range information about a predecessor -/// based on its terminator. -bool JumpThreading:: -ComputeValueKnownInPredecessors(Value *V, BasicBlock *BB,PredValueInfo &Result){ - PHINode *TheFirstPHI = cast(BB->begin()); - - // If V is a constantint, then it is known in all predecessors. - if (isa(V) || isa(V)) { - ConstantInt *CI = dyn_cast(V); - Result.resize(TheFirstPHI->getNumIncomingValues()); - for (unsigned i = 0, e = Result.size(); i != e; ++i) - Result[i] = std::make_pair(CI, TheFirstPHI->getIncomingBlock(i)); - return true; - } - - // If V is a non-instruction value, or an instruction in a different block, - // then it can't be derived from a PHI. - Instruction *I = dyn_cast(V); - if (I == 0 || I->getParent() != BB) - return false; - - /// If I is a PHI node, then we know the incoming values for any constants. - if (PHINode *PN = dyn_cast(I)) { - for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) { - Value *InVal = PN->getIncomingValue(i); - if (isa(InVal) || isa(InVal)) { - ConstantInt *CI = dyn_cast(InVal); - Result.push_back(std::make_pair(CI, PN->getIncomingBlock(i))); - } - } - return !Result.empty(); - } - - SmallVector, 8> LHSVals, RHSVals; - - // Handle some boolean conditions. - if (I->getType()->getPrimitiveSizeInBits() == 1) { - // X | true -> true - // X & false -> false - if (I->getOpcode() == Instruction::Or || - I->getOpcode() == Instruction::And) { - ComputeValueKnownInPredecessors(I->getOperand(0), BB, LHSVals); - ComputeValueKnownInPredecessors(I->getOperand(1), BB, RHSVals); - - if (LHSVals.empty() && RHSVals.empty()) - return false; - - ConstantInt *InterestingVal; - if (I->getOpcode() == Instruction::Or) - InterestingVal = ConstantInt::getTrue(I->getContext()); - else - InterestingVal = ConstantInt::getFalse(I->getContext()); - - // Scan for the sentinel. - for (unsigned i = 0, e = LHSVals.size(); i != e; ++i) - if (LHSVals[i].first == InterestingVal || LHSVals[i].first == 0) - Result.push_back(LHSVals[i]); - for (unsigned i = 0, e = RHSVals.size(); i != e; ++i) - if (RHSVals[i].first == InterestingVal || RHSVals[i].first == 0) - Result.push_back(RHSVals[i]); - return !Result.empty(); - } - - // TODO: Should handle the NOT form of XOR. - - } - - // Handle compare with phi operand, where the PHI is defined in this block. - if (CmpInst *Cmp = dyn_cast(I)) { - PHINode *PN = dyn_cast(Cmp->getOperand(0)); - if (PN && PN->getParent() == BB) { - // We can do this simplification if any comparisons fold to true or false. - // See if any do. - for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) { - BasicBlock *PredBB = PN->getIncomingBlock(i); - Value *LHS = PN->getIncomingValue(i); - Value *RHS = Cmp->getOperand(1)->DoPHITranslation(BB, PredBB); - - Constant *Res = GetResultOfComparison(Cmp->getPredicate(), LHS, RHS); - if (Res == 0) continue; - - if (isa(Res)) - Result.push_back(std::make_pair((ConstantInt*)0, PredBB)); - else if (ConstantInt *CI = dyn_cast(Res)) - Result.push_back(std::make_pair(CI, PredBB)); - } - - return !Result.empty(); - } - - // TODO: We could also recurse to see if we can determine constants another - // way. - } - return false; +BasicBlock *JumpThreading::FactorCommonPHIPreds(PHINode *PN, Value *Val) { + SmallVector CommonPreds; + for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) + if (PN->getIncomingValue(i) == Val) + CommonPreds.push_back(PN->getIncomingBlock(i)); + + if (CommonPreds.size() == 1) + return CommonPreds[0]; + + DEBUG(errs() << " Factoring out " << CommonPreds.size() + << " common predecessors.\n"); + return SplitBlockPredecessors(PN->getParent(), + &CommonPreds[0], CommonPreds.size(), + ".thr_comm", this); } - - + /// GetBestDestForBranchOnUndef - If we determine that the specified block ends /// in an undefined jump, decide which block is best to revector to. @@ -360,7 +250,7 @@ // successor, merge the blocks. This encourages recursive jump threading // because now the condition in this block can be threaded through // predecessors of our predecessor block. - if (BasicBlock *SinglePred = BB->getSinglePredecessor()) { + if (BasicBlock *SinglePred = BB->getSinglePredecessor()) if (SinglePred->getTerminator()->getNumSuccessors() == 1 && SinglePred != BB) { // If SinglePred was a loop header, BB becomes one. @@ -376,10 +266,10 @@ BB->moveBefore(&BB->getParent()->getEntryBlock()); return true; } - } - - // Look to see if the terminator is a branch of switch, if not we can't thread - // it. + + // See if this block ends with a branch or switch. If so, see if the + // condition is a phi node. If so, and if an entry of the phi node is a + // constant, we can thread the block. Value *Condition; if (BranchInst *BI = dyn_cast(BB->getTerminator())) { // Can't thread an unconditional jump. @@ -455,26 +345,44 @@ if (PN->getParent() == BB) return ProcessJumpOnPHI(PN); + // If this is a conditional branch whose condition is and/or of a phi, try to + // simplify it. + if ((CondInst->getOpcode() == Instruction::And || + CondInst->getOpcode() == Instruction::Or) && + isa(BB->getTerminator()) && + ProcessBranchOnLogical(CondInst, BB, + CondInst->getOpcode() == Instruction::And)) + return true; + if (CmpInst *CondCmp = dyn_cast(CondInst)) { - if (!isa(CondCmp->getOperand(0)) || - cast(CondCmp->getOperand(0))->getParent() != BB) { - // If we have a comparison, loop over the predecessors to see if there is - // a condition with a lexically identical value. - pred_iterator PI = pred_begin(BB), E = pred_end(BB); - for (; PI != E; ++PI) - if (BranchInst *PBI = dyn_cast((*PI)->getTerminator())) - if (PBI->isConditional() && *PI != BB) { - if (CmpInst *CI = dyn_cast(PBI->getCondition())) { - if (CI->getOperand(0) == CondCmp->getOperand(0) && - CI->getOperand(1) == CondCmp->getOperand(1) && - CI->getPredicate() == CondCmp->getPredicate()) { - // TODO: Could handle things like (x != 4) --> (x == 17) - if (ProcessBranchOnDuplicateCond(*PI, BB)) - return true; - } + if (isa(CondCmp->getOperand(0))) { + // If we have "br (phi != 42)" and the phi node has any constant values + // as operands, we can thread through this block. + // + // If we have "br (cmp phi, x)" and the phi node contains x such that the + // comparison uniquely identifies the branch target, we can thread + // through this block. + + if (ProcessBranchOnCompare(CondCmp, BB)) + return true; + } + + // If we have a comparison, loop over the predecessors to see if there is + // a condition with the same value. + pred_iterator PI = pred_begin(BB), E = pred_end(BB); + for (; PI != E; ++PI) + if (BranchInst *PBI = dyn_cast((*PI)->getTerminator())) + if (PBI->isConditional() && *PI != BB) { + if (CmpInst *CI = dyn_cast(PBI->getCondition())) { + if (CI->getOperand(0) == CondCmp->getOperand(0) && + CI->getOperand(1) == CondCmp->getOperand(1) && + CI->getPredicate() == CondCmp->getPredicate()) { + // TODO: Could handle things like (x != 4) --> (x == 17) + if (ProcessBranchOnDuplicateCond(*PI, BB)) + return true; } } - } + } } // Check for some cases that are worth simplifying. Right now we want to look @@ -493,19 +401,6 @@ if (SimplifyPartiallyRedundantLoad(LI)) return true; - - // Handle a variety of cases where we are branching on something derived from - // a PHI node in the current block. If we can prove that any predecessors - // compute a predictable value based on a PHI node, thread those predecessors. - // - // We only bother doing this if the current block has a PHI node and if the - // conditional instruction lives in the current block. If either condition - // fail, this won't be a computable value anyway. - if (CondInst->getParent() == BB && isa(BB->front())) - if (ProcessThreadableEdges(CondInst, BB)) - return true; - - // TODO: If we have: "br (X > 0)" and we have a predecessor where we know // "(X == 4)" thread through this block. @@ -794,197 +689,55 @@ return true; } -/// FindMostPopularDest - The specified list contains multiple possible -/// threadable destinations. Pick the one that occurs the most frequently in -/// the list. -static BasicBlock * -FindMostPopularDest(BasicBlock *BB, - const SmallVectorImpl > &PredToDestList) { - assert(!PredToDestList.empty()); - - // Determine popularity. If there are multiple possible destinations, we - // explicitly choose to ignore 'undef' destinations. We prefer to thread - // blocks with known and real destinations to threading undef. We'll handle - // them later if interesting. - DenseMap DestPopularity; - for (unsigned i = 0, e = PredToDestList.size(); i != e; ++i) - if (PredToDestList[i].second) - DestPopularity[PredToDestList[i].second]++; - - // Find the most popular dest. - DenseMap::iterator DPI = DestPopularity.begin(); - BasicBlock *MostPopularDest = DPI->first; - unsigned Popularity = DPI->second; - SmallVector SamePopularity; - - for (++DPI; DPI != DestPopularity.end(); ++DPI) { - // If the popularity of this entry isn't higher than the popularity we've - // seen so far, ignore it. - if (DPI->second < Popularity) - ; // ignore. - else if (DPI->second == Popularity) { - // If it is the same as what we've seen so far, keep track of it. - SamePopularity.push_back(DPI->first); - } else { - // If it is more popular, remember it. - SamePopularity.clear(); - MostPopularDest = DPI->first; - Popularity = DPI->second; - } - } - - // Okay, now we know the most popular destination. If there is more than - // destination, we need to determine one. This is arbitrary, but we need - // to make a deterministic decision. Pick the first one that appears in the - // successor list. - if (!SamePopularity.empty()) { - SamePopularity.push_back(MostPopularDest); - TerminatorInst *TI = BB->getTerminator(); - for (unsigned i = 0; ; ++i) { - assert(i != TI->getNumSuccessors() && "Didn't find any successor!"); - - if (std::find(SamePopularity.begin(), SamePopularity.end(), - TI->getSuccessor(i)) == SamePopularity.end()) - continue; - - MostPopularDest = TI->getSuccessor(i); - break; - } - } - - // Okay, we have finally picked the most popular destination. - return MostPopularDest; -} -bool JumpThreading::ProcessThreadableEdges(Instruction *CondInst, - BasicBlock *BB) { - // If threading this would thread across a loop header, don't even try to - // thread the edge. - if (LoopHeaders.count(BB)) - return false; - - +/// ProcessJumpOnPHI - We have a conditional branch or switch on a PHI node in +/// the current block. See if there are any simplifications we can do based on +/// inputs to the phi node. +/// +bool JumpThreading::ProcessJumpOnPHI(PHINode *PN) { + BasicBlock *BB = PN->getParent(); - SmallVector, 8> PredValues; - if (!ComputeValueKnownInPredecessors(CondInst, BB, PredValues)) - return false; - assert(!PredValues.empty() && - "ComputeValueKnownInPredecessors returned true with no values"); - - DEBUG(errs() << "IN BB: " << *BB; - for (unsigned i = 0, e = PredValues.size(); i != e; ++i) { - errs() << " BB '" << BB->getName() << "': FOUND condition = "; - if (PredValues[i].first) - errs() << *PredValues[i].first; - else - errs() << "UNDEF"; - errs() << " for pred '" << PredValues[i].second->getName() - << "'.\n"; - }); - - // Decide what we want to thread through. Convert our list of known values to - // a list of known destinations for each pred. This also discards duplicate - // predecessors and keeps track of the undefined inputs (which are represented - // as a null dest in the PredToDestList. - SmallPtrSet SeenPreds; - SmallVector, 16> PredToDestList; - - BasicBlock *OnlyDest = 0; - BasicBlock *MultipleDestSentinel = (BasicBlock*)(intptr_t)~0ULL; - - for (unsigned i = 0, e = PredValues.size(); i != e; ++i) { - BasicBlock *Pred = PredValues[i].second; - if (!SeenPreds.insert(Pred)) - continue; // Duplicate predecessor entry. - - // If the predecessor ends with an indirect goto, we can't change its - // destination. - if (isa(Pred->getTerminator())) - continue; - - ConstantInt *Val = PredValues[i].first; + // See if the phi node has any constant integer or undef values. If so, we + // can determine where the corresponding predecessor will branch. + for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) { + Value *PredVal = PN->getIncomingValue(i); - BasicBlock *DestBB; - if (Val == 0) // Undef. - DestBB = 0; - else if (BranchInst *BI = dyn_cast(BB->getTerminator())) - DestBB = BI->getSuccessor(Val->isZero()); - else { - SwitchInst *SI = cast(BB->getTerminator()); - DestBB = SI->getSuccessor(SI->findCaseValue(Val)); + // Check to see if this input is a constant integer. If so, the direction + // of the branch is predictable. + if (ConstantInt *CI = dyn_cast(PredVal)) { + // Merge any common predecessors that will act the same. + BasicBlock *PredBB = FactorCommonPHIPreds(PN, CI); + + BasicBlock *SuccBB; + if (BranchInst *BI = dyn_cast(BB->getTerminator())) + SuccBB = BI->getSuccessor(CI->isZero()); + else { + SwitchInst *SI = cast(BB->getTerminator()); + SuccBB = SI->getSuccessor(SI->findCaseValue(CI)); + } + + // Ok, try to thread it! + return ThreadEdge(BB, PredBB, SuccBB); } - - // If we have exactly one destination, remember it for efficiency below. - if (i == 0) - OnlyDest = DestBB; - else if (OnlyDest != DestBB) - OnlyDest = MultipleDestSentinel; - PredToDestList.push_back(std::make_pair(Pred, DestBB)); - } - - // If all edges were unthreadable, we fail. - if (PredToDestList.empty()) - return false; - - // Determine which is the most common successor. If we have many inputs and - // this block is a switch, we want to start by threading the batch that goes - // to the most popular destination first. If we only know about one - // threadable destination (the common case) we can avoid this. - BasicBlock *MostPopularDest = OnlyDest; - - if (MostPopularDest == MultipleDestSentinel) - MostPopularDest = FindMostPopularDest(BB, PredToDestList); - - // Now that we know what the most popular destination is, factor all - // predecessors that will jump to it into a single predecessor. - SmallVector PredsToFactor; - for (unsigned i = 0, e = PredToDestList.size(); i != e; ++i) - if (PredToDestList[i].second == MostPopularDest) { - BasicBlock *Pred = PredToDestList[i].first; + // If the input is an undef, then it doesn't matter which way it will go. + // Pick an arbitrary dest and thread the edge. + if (UndefValue *UV = dyn_cast(PredVal)) { + // Merge any common predecessors that will act the same. + BasicBlock *PredBB = FactorCommonPHIPreds(PN, UV); + BasicBlock *SuccBB = + BB->getTerminator()->getSuccessor(GetBestDestForJumpOnUndef(BB)); - // This predecessor may be a switch or something else that has multiple - // edges to the block. Factor each of these edges by listing them - // according to # occurrences in PredsToFactor. - TerminatorInst *PredTI = Pred->getTerminator(); - for (unsigned i = 0, e = PredTI->getNumSuccessors(); i != e; ++i) - if (PredTI->getSuccessor(i) == BB) - PredsToFactor.push_back(Pred); + // Ok, try to thread it! + return ThreadEdge(BB, PredBB, SuccBB); } - - BasicBlock *PredToThread; - if (PredsToFactor.size() == 1) - PredToThread = PredsToFactor[0]; - else { - DEBUG(errs() << " Factoring out " << PredsToFactor.size() - << " common predecessors.\n"); - PredToThread = SplitBlockPredecessors(BB, &PredsToFactor[0], - PredsToFactor.size(), - ".thr_comm", this); } - // If the threadable edges are branching on an undefined value, we get to pick - // the destination that these predecessors should get to. - if (MostPopularDest == 0) - MostPopularDest = BB->getTerminator()-> - getSuccessor(GetBestDestForJumpOnUndef(BB)); - - // Ok, try to thread it! - return ThreadEdge(BB, PredToThread, MostPopularDest); -} - -/// ProcessJumpOnPHI - We have a conditional branch or switch on a PHI node in -/// the current block. See if there are any simplifications we can do based on -/// inputs to the phi node. -/// -bool JumpThreading::ProcessJumpOnPHI(PHINode *PN) { - BasicBlock *BB = PN->getParent(); - - // If any of the predecessor blocks end in an unconditional branch, we can - // *duplicate* the jump into that block in order to further encourage jump - // threading and to eliminate cases where we have branch on a phi of an icmp - // (branch on icmp is much better). + // If the incoming values are all variables, we don't know the destination of + // any predecessors. However, if any of the predecessor blocks end in an + // unconditional branch, we can *duplicate* the jump into that block in order + // to further encourage jump threading and to eliminate cases where we have + // branch on a phi of an icmp (branch on icmp is much better). // We don't want to do this tranformation for switches, because we don't // really want to duplicate a switch. @@ -1005,6 +758,137 @@ } +/// ProcessJumpOnLogicalPHI - PN's basic block contains a conditional branch +/// whose condition is an AND/OR where one side is PN. If PN has constant +/// operands that permit us to evaluate the condition for some operand, thread +/// through the block. For example with: +/// br (and X, phi(Y, Z, false)) +/// the predecessor corresponding to the 'false' will always jump to the false +/// destination of the branch. +/// +bool JumpThreading::ProcessBranchOnLogical(Value *V, BasicBlock *BB, + bool isAnd) { + // If this is a binary operator tree of the same AND/OR opcode, check the + // LHS/RHS. + if (BinaryOperator *BO = dyn_cast(V)) + if ((isAnd && BO->getOpcode() == Instruction::And) || + (!isAnd && BO->getOpcode() == Instruction::Or)) { + if (ProcessBranchOnLogical(BO->getOperand(0), BB, isAnd)) + return true; + if (ProcessBranchOnLogical(BO->getOperand(1), BB, isAnd)) + return true; + } + + // If this isn't a PHI node, we can't handle it. + PHINode *PN = dyn_cast(V); + if (!PN || PN->getParent() != BB) return false; + + // We can only do the simplification for phi nodes of 'false' with AND or + // 'true' with OR. See if we have any entries in the phi for this. + unsigned PredNo = ~0U; + ConstantInt *PredCst = ConstantInt::get(Type::getInt1Ty(BB->getContext()), + !isAnd); + for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) { + if (PN->getIncomingValue(i) == PredCst) { + PredNo = i; + break; + } + } + + // If no match, bail out. + if (PredNo == ~0U) + return false; + + // If so, we can actually do this threading. Merge any common predecessors + // that will act the same. + BasicBlock *PredBB = FactorCommonPHIPreds(PN, PredCst); + + // Next, figure out which successor we are threading to. If this was an AND, + // the constant must be FALSE, and we must be targeting the 'false' block. + // If this is an OR, the constant must be TRUE, and we must be targeting the + // 'true' block. + BasicBlock *SuccBB = BB->getTerminator()->getSuccessor(isAnd); + + // Ok, try to thread it! + return ThreadEdge(BB, PredBB, SuccBB); +} + +/// GetResultOfComparison - Given an icmp/fcmp predicate and the left and right +/// hand sides of the compare instruction, try to determine the result. If the +/// result can not be determined, a null pointer is returned. +static Constant *GetResultOfComparison(CmpInst::Predicate pred, + Value *LHS, Value *RHS, + LLVMContext &Context) { + if (Constant *CLHS = dyn_cast(LHS)) + if (Constant *CRHS = dyn_cast(RHS)) + return ConstantExpr::getCompare(pred, CLHS, CRHS); + + if (LHS == RHS) + if (isa(LHS->getType()) || isa(LHS->getType())) + return ICmpInst::isTrueWhenEqual(pred) ? + ConstantInt::getTrue(Context) : ConstantInt::getFalse(Context); + + return 0; +} + +/// ProcessBranchOnCompare - We found a branch on a comparison between a phi +/// node and a value. If we can identify when the comparison is true between +/// the phi inputs and the value, we can fold the compare for that edge and +/// thread through it. +bool JumpThreading::ProcessBranchOnCompare(CmpInst *Cmp, BasicBlock *BB) { + PHINode *PN = cast(Cmp->getOperand(0)); + Value *RHS = Cmp->getOperand(1); + + // If the phi isn't in the current block, an incoming edge to this block + // doesn't control the destination. + if (PN->getParent() != BB) + return false; + + // We can do this simplification if any comparisons fold to true or false. + // See if any do. + Value *PredVal = 0; + bool TrueDirection = false; + for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) { + PredVal = PN->getIncomingValue(i); + + Constant *Res = GetResultOfComparison(Cmp->getPredicate(), PredVal, + RHS, Cmp->getContext()); + if (!Res) { + PredVal = 0; + continue; + } + + // If this folded to a constant expr, we can't do anything. + if (ConstantInt *ResC = dyn_cast(Res)) { + TrueDirection = ResC->getZExtValue(); + break; + } + // If this folded to undef, just go the false way. + if (isa(Res)) { + TrueDirection = false; + break; + } + + // Otherwise, we can't fold this input. + PredVal = 0; + } + + // If no match, bail out. + if (PredVal == 0) + return false; + + // If so, we can actually do this threading. Merge any common predecessors + // that will act the same. + BasicBlock *PredBB = FactorCommonPHIPreds(PN, PredVal); + + // Next, get our successor. + BasicBlock *SuccBB = BB->getTerminator()->getSuccessor(!TrueDirection); + + // Ok, try to thread it! + return ThreadEdge(BB, PredBB, SuccBB); +} + + /// AddPHINodeEntriesForMappedBlock - We're adding 'NewPred' as a new /// predecessor to the PHIBB block. If it has PHI nodes, add entries for /// NewPred using the entries from OldPred (suitably mapped). Modified: llvm/trunk/test/Transforms/JumpThreading/basic.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/JumpThreading/basic.ll?rev=86321&r1=86320&r2=86321&view=diff ============================================================================== --- llvm/trunk/test/Transforms/JumpThreading/basic.ll (original) +++ llvm/trunk/test/Transforms/JumpThreading/basic.ll Fri Nov 6 19:32:59 2009 @@ -170,36 +170,5 @@ } -;; This tests that the branch in 'merge' can be cloned up into T1. -;; rdar://7367025 -define i32 @test7(i1 %cond, i1 %cond2) { -Entry: -; CHECK: @test7 - %v1 = call i32 @f1() - br i1 %cond, label %Merge, label %F1 -F1: - %v2 = call i32 @f2() - br label %Merge - -Merge: - %B = phi i32 [%v1, %Entry], [%v2, %F1] - %M = icmp ne i32 %B, %v1 - %N = icmp eq i32 %B, 47 - %O = and i1 %M, %N - br i1 %O, label %T2, label %F2 - -; CHECK: Merge: -; CHECK-NOT: phi -; CHECK-NEXT: %v2 = call i32 @f2() - -T2: - call void @f3() - ret i32 %B - -F2: - ret i32 %B -; CHECK: F2: -; CHECK-NEXT: phi i32 -} Modified: llvm/trunk/test/Transforms/JumpThreading/crash.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/JumpThreading/crash.ll?rev=86321&r1=86320&r2=86321&view=diff ============================================================================== --- llvm/trunk/test/Transforms/JumpThreading/crash.ll (original) +++ llvm/trunk/test/Transforms/JumpThreading/crash.ll Fri Nov 6 19:32:59 2009 @@ -170,25 +170,3 @@ ret i32 1 } - -define fastcc void @test5(i1 %tmp, i32 %tmp1) nounwind ssp { -entry: - br i1 %tmp, label %bb12, label %bb13 - - -bb12: - br label %bb13 - -bb13: - %.lcssa31 = phi i32 [ undef, %bb12 ], [ %tmp1, %entry ] - %A = and i1 undef, undef - br i1 %A, label %bb15, label %bb61 - -bb15: - ret void - - -bb61: - ret void -} - From stoklund at 2pi.dk Fri Nov 6 19:58:40 2009 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Sat, 07 Nov 2009 01:58:40 -0000 Subject: [llvm-commits] [llvm] r86322 - in /llvm/trunk: include/llvm/CodeGen/LiveIntervalAnalysis.h lib/CodeGen/LiveIntervalAnalysis.cpp Message-ID: <200911070158.nA71wfDw014511@zion.cs.uiuc.edu> Author: stoklund Date: Fri Nov 6 19:58:40 2009 New Revision: 86322 URL: http://llvm.org/viewvc/llvm-project?rev=86322&view=rev Log: Fix inverted conflict test in -early-coalesce. A non-identity copy cannot be coalesced when the phi join destination register is live at the copy site. Also verify the condition that the PHI join source register is only used in the PHI join. Otherwise the coalescing is invalid. 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=86322&r1=86321&r2=86322&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h (original) +++ llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h Fri Nov 6 19:58:40 2009 @@ -290,9 +290,10 @@ /// computeIntervals - Compute live intervals. void computeIntervals(); - bool isProfitableToCoalesce(LiveInterval &DstInt, LiveInterval &SrcInt, - SmallVector &IdentCopies, - SmallVector &OtherCopies); + bool isSafeAndProfitableToCoalesce(LiveInterval &DstInt, + LiveInterval &SrcInt, + SmallVector &IdentCopies, + SmallVector &OtherCopies); void performEarlyCoalescing(); Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=86322&r1=86321&r2=86322&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Fri Nov 6 19:58:40 2009 @@ -646,17 +646,17 @@ 0, false, VNInfoAllocator); vni->setIsPHIDef(true); LiveRange LR(start, end, vni); - + interval.addRange(LR); LR.valno->addKill(end); DEBUG(errs() << " +" << LR << '\n'); } -bool -LiveIntervals::isProfitableToCoalesce(LiveInterval &DstInt, LiveInterval &SrcInt, - SmallVector &IdentCopies, - SmallVector &OtherCopies) { - bool HaveConflict = false; +bool LiveIntervals:: +isSafeAndProfitableToCoalesce(LiveInterval &DstInt, + LiveInterval &SrcInt, + SmallVector &IdentCopies, + SmallVector &OtherCopies) { unsigned NumIdent = 0; for (MachineRegisterInfo::def_iterator ri = mri_->def_begin(SrcInt.reg), re = mri_->def_end(); ri != re; ++ri) { @@ -665,16 +665,16 @@ if (!tii_->isMoveInstr(*MI, SrcReg, DstReg, SrcSubReg, DstSubReg)) return false; if (SrcReg != DstInt.reg) { + // Non-identity copy - we cannot handle overlapping intervals + if (DstInt.liveAt(getInstructionIndex(MI))) + return false; OtherCopies.push_back(MI); - HaveConflict |= DstInt.liveAt(getInstructionIndex(MI)); } else { IdentCopies.push_back(MI); ++NumIdent; } } - if (!HaveConflict) - return false; // Let coalescer handle it return IdentCopies.size() > OtherCopies.size(); } @@ -701,19 +701,21 @@ LiveInterval &SrcInt = getInterval(PHISrc); SmallVector IdentCopies; SmallVector OtherCopies; - if (!isProfitableToCoalesce(DstInt, SrcInt, IdentCopies, OtherCopies)) + if (!isSafeAndProfitableToCoalesce(DstInt, SrcInt, + IdentCopies, OtherCopies)) continue; DEBUG(errs() << "PHI Join: " << *Join); assert(DstInt.containsOneValue() && "PHI join should have just one val#!"); + assert(std::distance(mri_->use_begin(PHISrc), mri_->use_end()) == 1 && + "PHI join src should not be used elsewhere"); VNInfo *VNI = DstInt.getValNumInfo(0); // Change the non-identity copies to directly target the phi destination. for (unsigned i = 0, e = OtherCopies.size(); i != e; ++i) { MachineInstr *PHICopy = OtherCopies[i]; - DEBUG(errs() << "Moving: " << *PHICopy); - SlotIndex MIIndex = getInstructionIndex(PHICopy); + DEBUG(errs() << "Moving: " << MIIndex << ' ' << *PHICopy); SlotIndex DefIndex = MIIndex.getDefIndex(); LiveRange *SLR = SrcInt.getLiveRangeContaining(DefIndex); SlotIndex StartIndex = SLR->start; @@ -724,8 +726,7 @@ SrcInt.removeValNo(SLR->valno); DEBUG(errs() << " added range [" << StartIndex << ',' << EndIndex << "] to reg" << DstInt.reg << '\n'); - if (DstInt.liveAt(StartIndex)) - DstInt.removeRange(StartIndex, EndIndex); + assert (!DstInt.liveAt(StartIndex) && "Cannot coalesce when dst live!"); VNInfo *NewVNI = DstInt.getNextValue(DefIndex, PHICopy, true, VNInfoAllocator); NewVNI->setHasPHIKill(true); From evan.cheng at apple.com Fri Nov 6 20:11:15 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 6 Nov 2009 18:11:15 -0800 Subject: [llvm-commits] [llvm] r86322 - in /llvm/trunk: include/llvm/CodeGen/LiveIntervalAnalysis.h lib/CodeGen/LiveIntervalAnalysis.cpp In-Reply-To: <200911070158.nA71wfDw014511@zion.cs.uiuc.edu> References: <200911070158.nA71wfDw014511@zion.cs.uiuc.edu> Message-ID: Sorry, Jakob. I don't think this patch is right. The check is whether the early coalescer should be handling the cases where the normal coalescer cannot. Perhaps hacking on the early coalescer is not the right approach? We're probably better off starting over by adding on-demand critical edge splitting in phi elimination. Evan On Nov 6, 2009, at 5:58 PM, Jakob Stoklund Olesen wrote: > Author: stoklund > Date: Fri Nov 6 19:58:40 2009 > New Revision: 86322 > > URL: http://llvm.org/viewvc/llvm-project?rev=86322&view=rev > Log: > Fix inverted conflict test in -early-coalesce. > > A non-identity copy cannot be coalesced when the phi join > destination register > is live at the copy site. > > Also verify the condition that the PHI join source register is only > used in > the PHI join. Otherwise the coalescing is invalid. > > 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=86322&r1=86321&r2=86322&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h (original) > +++ llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h Fri Nov > 6 19:58:40 2009 > @@ -290,9 +290,10 @@ > /// computeIntervals - Compute live intervals. > void computeIntervals(); > > - bool isProfitableToCoalesce(LiveInterval &DstInt, LiveInterval > &SrcInt, > - SmallVector > &IdentCopies, > - SmallVector > &OtherCopies); > + bool isSafeAndProfitableToCoalesce(LiveInterval &DstInt, > + LiveInterval &SrcInt, > + SmallVector &IdentCopies, > + SmallVector &OtherCopies); > > void performEarlyCoalescing(); > > > Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=86322&r1=86321&r2=86322&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original) > +++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Fri Nov 6 > 19:58:40 2009 > @@ -646,17 +646,17 @@ > 0, false, VNInfoAllocator); > vni->setIsPHIDef(true); > LiveRange LR(start, end, vni); > - > + > interval.addRange(LR); > LR.valno->addKill(end); > DEBUG(errs() << " +" << LR << '\n'); > } > > -bool > -LiveIntervals::isProfitableToCoalesce(LiveInterval &DstInt, > LiveInterval &SrcInt, > - SmallVector > &IdentCopies, > - SmallVector > &OtherCopies) { > - bool HaveConflict = false; > +bool LiveIntervals:: > +isSafeAndProfitableToCoalesce(LiveInterval &DstInt, > + LiveInterval &SrcInt, > + SmallVector > &IdentCopies, > + SmallVector > &OtherCopies) { > unsigned NumIdent = 0; > for (MachineRegisterInfo::def_iterator ri = mri_->def_begin > (SrcInt.reg), > re = mri_->def_end(); ri != re; ++ri) { > @@ -665,16 +665,16 @@ > if (!tii_->isMoveInstr(*MI, SrcReg, DstReg, SrcSubReg, DstSubReg)) > return false; > if (SrcReg != DstInt.reg) { > + // Non-identity copy - we cannot handle overlapping intervals > + if (DstInt.liveAt(getInstructionIndex(MI))) > + return false; > OtherCopies.push_back(MI); > - HaveConflict |= DstInt.liveAt(getInstructionIndex(MI)); > } else { > IdentCopies.push_back(MI); > ++NumIdent; > } > } > > - if (!HaveConflict) > - return false; // Let coalescer handle it > return IdentCopies.size() > OtherCopies.size(); > } > > @@ -701,19 +701,21 @@ > LiveInterval &SrcInt = getInterval(PHISrc); > SmallVector IdentCopies; > SmallVector OtherCopies; > - if (!isProfitableToCoalesce(DstInt, SrcInt, IdentCopies, > OtherCopies)) > + if (!isSafeAndProfitableToCoalesce(DstInt, SrcInt, > + IdentCopies, OtherCopies)) > continue; > > DEBUG(errs() << "PHI Join: " << *Join); > assert(DstInt.containsOneValue() && "PHI join should have just > one val#!"); > + assert(std::distance(mri_->use_begin(PHISrc), mri_->use_end()) > == 1 && > + "PHI join src should not be used elsewhere"); > VNInfo *VNI = DstInt.getValNumInfo(0); > > // Change the non-identity copies to directly target the phi > destination. > for (unsigned i = 0, e = OtherCopies.size(); i != e; ++i) { > MachineInstr *PHICopy = OtherCopies[i]; > - DEBUG(errs() << "Moving: " << *PHICopy); > - > SlotIndex MIIndex = getInstructionIndex(PHICopy); > + DEBUG(errs() << "Moving: " << MIIndex << ' ' << *PHICopy); > SlotIndex DefIndex = MIIndex.getDefIndex(); > LiveRange *SLR = SrcInt.getLiveRangeContaining(DefIndex); > SlotIndex StartIndex = SLR->start; > @@ -724,8 +726,7 @@ > SrcInt.removeValNo(SLR->valno); > DEBUG(errs() << " added range [" << StartIndex << ',' > << EndIndex << "] to reg" << DstInt.reg << '\n'); > - if (DstInt.liveAt(StartIndex)) > - DstInt.removeRange(StartIndex, EndIndex); > + assert (!DstInt.liveAt(StartIndex) && "Cannot coalesce when > dst live!"); > VNInfo *NewVNI = DstInt.getNextValue(DefIndex, PHICopy, true, > VNInfoAllocator); > NewVNI->setHasPHIKill(true); > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From kennethuil at gmail.com Fri Nov 6 20:11:55 2009 From: kennethuil at gmail.com (Kenneth Uildriks) Date: Sat, 07 Nov 2009 02:11:55 -0000 Subject: [llvm-commits] [llvm] r86324 - in /llvm/trunk: include/llvm/CodeGen/CallingConvLower.h include/llvm/Target/TargetLowering.h lib/CodeGen/SelectionDAG/CallingConvLower.cpp lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp lib/Target/X86/X86ISelLowering.cpp lib/Target/X86/X86ISelLowering.h Message-ID: <200911070211.nA72BttG014922@zion.cs.uiuc.edu> Author: kennethuil Date: Fri Nov 6 20:11:54 2009 New Revision: 86324 URL: http://llvm.org/viewvc/llvm-project?rev=86324&view=rev Log: Add code to check at SelectionDAGISel::LowerArguments time to see if return values can be lowered to registers. Coming soon, code to perform sret-demotion if return values cannot be lowered to registers Modified: llvm/trunk/include/llvm/CodeGen/CallingConvLower.h llvm/trunk/include/llvm/Target/TargetLowering.h llvm/trunk/lib/CodeGen/SelectionDAG/CallingConvLower.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp llvm/trunk/lib/Target/X86/X86ISelLowering.cpp llvm/trunk/lib/Target/X86/X86ISelLowering.h Modified: llvm/trunk/include/llvm/CodeGen/CallingConvLower.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/CallingConvLower.h?rev=86324&r1=86323&r2=86324&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/CallingConvLower.h (original) +++ llvm/trunk/include/llvm/CodeGen/CallingConvLower.h Fri Nov 6 20:11:54 2009 @@ -183,6 +183,13 @@ void AnalyzeReturn(const SmallVectorImpl &Outs, CCAssignFn Fn); + /// CheckReturn - Analyze the return values of a function, returning + /// true if the return can be performed without sret-demotion, and + /// false otherwise. + bool CheckReturn(const SmallVectorImpl &OutTys, + const SmallVectorImpl &ArgsFlags, + CCAssignFn Fn); + /// AnalyzeCallOperands - Analyze the outgoing arguments to a call, /// incorporating info about the passed values into this state. void AnalyzeCallOperands(const SmallVectorImpl &Outs, Modified: llvm/trunk/include/llvm/Target/TargetLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLowering.h?rev=86324&r1=86323&r2=86324&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetLowering.h (original) +++ llvm/trunk/include/llvm/Target/TargetLowering.h Fri Nov 6 20:11:54 2009 @@ -1167,6 +1167,18 @@ return SDValue(); // this is here to silence compiler errors } + /// CanLowerReturn - This hook should be implemented to check whether the + /// return values described by the Outs array can fit into the return + /// registers. If false is returned, an sret-demotion is performed. + /// + virtual bool CanLowerReturn(CallingConv::ID CallConv, bool isVarArg, + const SmallVectorImpl &OutTys, + const SmallVectorImpl &ArgsFlags, + SelectionDAG &DAG) + { + // Return true by default to get preexisting behavior. + return true; + } /// LowerReturn - This hook must be implemented to lower outgoing /// return values, described by the Outs array, into the specified /// DAG. The implementation should return the resulting token chain Modified: llvm/trunk/lib/CodeGen/SelectionDAG/CallingConvLower.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/CallingConvLower.cpp?rev=86324&r1=86323&r2=86324&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/CallingConvLower.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/CallingConvLower.cpp Fri Nov 6 20:11:54 2009 @@ -77,6 +77,21 @@ } } +/// CheckReturn - Analyze the return values of a function, returning true if +/// the return can be performed without sret-demotion, and false otherwise. +bool CCState::CheckReturn(const SmallVectorImpl &OutTys, + const SmallVectorImpl &ArgsFlags, + CCAssignFn Fn) { + // Determine which register each value should be copied into. + for (unsigned i = 0, e = OutTys.size(); i != e; ++i) { + EVT VT = OutTys[i]; + ISD::ArgFlagsTy ArgFlags = ArgsFlags[i]; + if (Fn(i, VT, VT, CCValAssign::Full, ArgFlags, *this)) + return false; + } + return true; +} + /// AnalyzeReturn - Analyze the returned values of a return, /// incorporating info about the result values into this state. void CCState::AnalyzeReturn(const SmallVectorImpl &Outs, Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp?rev=86324&r1=86323&r2=86324&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Fri Nov 6 20:11:54 2009 @@ -947,6 +947,58 @@ return RFV.getCopyFromRegs(DAG, getCurDebugLoc(), Chain, NULL); } +/// Get the EVTs and ArgFlags collections that represent the return type +/// of the given function. This does not require a DAG or a return value, and +/// is suitable for use before any DAGs for the function are constructed. +static void getReturnInfo(const Function* F, SmallVectorImpl &OutVTs, + SmallVectorImpl &OutFlags, + TargetLowering &TLI) { + const Type* ReturnType = F->getReturnType(); + + SmallVector ValueVTs; + ComputeValueVTs(TLI, ReturnType, ValueVTs); + unsigned NumValues = ValueVTs.size(); + if ( NumValues == 0 ) return; + + for (unsigned j = 0, f = NumValues; j != f; ++j) { + EVT VT = ValueVTs[j]; + ISD::NodeType ExtendKind = ISD::ANY_EXTEND; + + if (F->paramHasAttr(0, Attribute::SExt)) + ExtendKind = ISD::SIGN_EXTEND; + else if (F->paramHasAttr(0, Attribute::ZExt)) + ExtendKind = ISD::ZERO_EXTEND; + + // FIXME: C calling convention requires the return type to be promoted to + // at least 32-bit. But this is not necessary for non-C calling + // conventions. The frontend should mark functions whose return values + // require promoting with signext or zeroext attributes. + if (ExtendKind != ISD::ANY_EXTEND && VT.isInteger()) { + EVT MinVT = TLI.getRegisterType(F->getContext(), MVT::i32); + if (VT.bitsLT(MinVT)) + VT = MinVT; + } + + unsigned NumParts = TLI.getNumRegisters(F->getContext(), VT); + EVT PartVT = TLI.getRegisterType(F->getContext(), VT); + // 'inreg' on function refers to return value + ISD::ArgFlagsTy Flags = ISD::ArgFlagsTy(); + if (F->paramHasAttr(0, Attribute::InReg)) + Flags.setInReg(); + + // Propagate extension type if any + if (F->paramHasAttr(0, Attribute::SExt)) + Flags.setSExt(); + else if (F->paramHasAttr(0, Attribute::ZExt)) + Flags.setZExt(); + + for (unsigned i = 0; i < NumParts; ++i) + { + OutVTs.push_back(PartVT); + OutFlags.push_back(Flags); + } + } +} void SelectionDAGLowering::visitRet(ReturnInst &I) { SDValue Chain = getControlRoot(); @@ -5758,6 +5810,14 @@ DebugLoc dl = SDL->getCurDebugLoc(); const TargetData *TD = TLI.getTargetData(); + // Check whether the function can return without sret-demotion. + SmallVector OutVTs; + SmallVector OutsFlags; + getReturnInfo(&F, OutVTs, OutsFlags, TLI); + // For now, assert and bail out if it can't. + assert(TLI.CanLowerReturn(F.getCallingConv(), F.isVarArg(), OutVTs, OutsFlags, + DAG) && "Cannot fit return value in registers!"); + // Set up the incoming argument description vector. SmallVector Ins; unsigned Idx = 1; Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=86324&r1=86323&r2=86324&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Fri Nov 6 20:11:54 2009 @@ -1087,6 +1087,17 @@ #include "X86GenCallingConv.inc" +bool +X86TargetLowering::CanLowerReturn(CallingConv::ID CallConv, bool isVarArg, + const SmallVectorImpl &OutTys, + const SmallVectorImpl &ArgsFlags, + SelectionDAG &DAG) { + SmallVector RVLocs; + CCState CCInfo(CallConv, isVarArg, getTargetMachine(), + RVLocs, *DAG.getContext()); + return CCInfo.CheckReturn(OutTys, ArgsFlags, RetCC_X86); +} + SDValue X86TargetLowering::LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.h?rev=86324&r1=86323&r2=86324&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.h (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.h Fri Nov 6 20:11:54 2009 @@ -699,6 +699,12 @@ const SmallVectorImpl &Outs, DebugLoc dl, SelectionDAG &DAG); + virtual bool + CanLowerReturn(CallingConv::ID CallConv, bool isVarArg, + const SmallVectorImpl &OutTys, + const SmallVectorImpl &ArgsFlags, + SelectionDAG &DAG); + void ReplaceATOMIC_BINARY_64(SDNode *N, SmallVectorImpl &Results, SelectionDAG &DAG, unsigned NewOp); From stoklund at 2pi.dk Fri Nov 6 20:28:58 2009 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Fri, 6 Nov 2009 18:28:58 -0800 Subject: [llvm-commits] [llvm] r86322 - in /llvm/trunk: include/llvm/CodeGen/LiveIntervalAnalysis.h lib/CodeGen/LiveIntervalAnalysis.cpp In-Reply-To: References: <200911070158.nA71wfDw014511@zion.cs.uiuc.edu> Message-ID: <6AAE6969-BC82-4A24-806B-5200A1BF6759@2pi.dk> On Nov 6, 2009, at 6:11 PM, Evan Cheng wrote: > Sorry, Jakob. I don't think this patch is right. The check is > whether the early coalescer should be handling the cases where the > normal coalescer cannot. I am not sure I understand. The conflict test is a correctness issue. The old code looked like this: > - if (!HaveConflict) > - return false; // Let coalescer handle it That is: If there is no conflict, it is /not/ safe to coalesce. This is clearly wrong - if there is a conflict, the early coalescer must stay clear. This fix fixes the miscompilations in MallocBench. I was seeing code like this: 2508 %reg1248 = MOV32rr %reg1069 register: %reg1248 Removing [2072,2086] from: %reg1248,0.000000e+00 = [2054,2086:0) 0 at 2054-(2086) RESULT: %reg1248,0.000000e+00 = [2054,2072:0) 0 at 2054-(2220* phi) replace range with [2072,2086:1) RESULT: %reg1248,0.000000e+00 = [2054,2072:0)[2072,2086:1) 0 at 2054-(2220* phi) 1@?-(2086) +[2510,2536:2) 2516 %reg1249 = MOV32rr %reg1065 register: %reg1249 Removing [2072,2094] from: %reg1249,0.000000e+00 = [2062,2094:0) 0 at 2062-(2094) RESULT: %reg1249,0.000000e+00 = [2062,2072:0) 0 at 2062-(2220* phi) replace range with [2072,2094:1) RESULT: %reg1249,0.000000e+00 = [2062,2072:0)[2072,2094:1) 0 at 2062-(2220* phi) 1@?-(2094) +[2518,2536:2) PHI Join: %reg1065 = MOV32rr %reg1248 Moving: 2510 %reg1248 = MOV32rr %reg1069 added range [2510,2536] to reg1065 The early coalescer wanted to define %reg1065 at index 2508, even though it is being used at the next instruction. This is the miscompilation. > Perhaps hacking on the early coalescer is not the right approach? > We're probably better off starting over by adding on-demand critical > edge splitting in phi elimination. I agree. I am simply using the early coalescer to detect the cases where critical edge splitting is necessary. /jakob From evan.cheng at apple.com Fri Nov 6 20:51:28 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 6 Nov 2009 18:51:28 -0800 Subject: [llvm-commits] [llvm] r86322 - in /llvm/trunk: include/llvm/CodeGen/LiveIntervalAnalysis.h lib/CodeGen/LiveIntervalAnalysis.cpp In-Reply-To: <6AAE6969-BC82-4A24-806B-5200A1BF6759@2pi.dk> References: <200911070158.nA71wfDw014511@zion.cs.uiuc.edu> <6AAE6969-BC82-4A24-806B-5200A1BF6759@2pi.dk> Message-ID: On Nov 6, 2009, at 6:28 PM, Jakob Stoklund Olesen wrote: > > On Nov 6, 2009, at 6:11 PM, Evan Cheng wrote: > >> Sorry, Jakob. I don't think this patch is right. The check is >> whether the early coalescer should be handling the cases where the >> normal coalescer cannot. > > I am not sure I understand. The conflict test is a correctness issue. > > The old code looked like this: > >> - if (!HaveConflict) >> - return false; // Let coalescer handle it > > That is: If there is no conflict, it is /not/ safe to coalesce. This > is clearly wrong - if there is a conflict, the early coalescer must > stay clear. > > This fix fixes the miscompilations in MallocBench. > > I was seeing code like this: > > 2508 %reg1248 = MOV32rr %reg1069 > register: %reg1248 Removing [2072,2086] from: %reg1248,0.000000e > +00 = [2054,2086:0) 0 at 2054-(2086) > RESULT: %reg1248,0.000000e+00 = [2054,2072:0) 0 at 2054-(2220* phi) > replace range with [2072,2086:1) RESULT: %reg1248,0.000000e+00 = > [2054,2072:0)[2072,2086:1) 0 at 2054-(2220* phi) 1@?-(2086) > +[2510,2536:2) > > 2516 %reg1249 = MOV32rr %reg1065 > register: %reg1249 Removing [2072,2094] from: %reg1249,0.000000e > +00 = [2062,2094:0) 0 at 2062-(2094) > RESULT: %reg1249,0.000000e+00 = [2062,2072:0) 0 at 2062-(2220* phi) > replace range with [2072,2094:1) RESULT: %reg1249,0.000000e+00 = > [2062,2072:0)[2072,2094:1) 0 at 2062-(2220* phi) 1@?-(2094) > +[2518,2536:2) > > > PHI Join: %reg1065 = MOV32rr %reg1248 > Moving: 2510 %reg1248 = MOV32rr %reg1069 > added range [2510,2536] to reg1065 > > The early coalescer wanted to define %reg1065 at index 2508, even > though it is being used at the next instruction. This is the > miscompilation. But I bet the resulting code is exactly the same as that without the early coalescer . :-) > >> Perhaps hacking on the early coalescer is not the right approach? >> We're probably better off starting over by adding on-demand >> critical edge splitting in phi elimination. > > I agree. I am simply using the early coalescer to detect the cases > where critical edge splitting is necessary. Ok. Evan > > /jakob > From stoklund at 2pi.dk Fri Nov 6 21:05:00 2009 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Fri, 6 Nov 2009 19:05:00 -0800 Subject: [llvm-commits] [llvm] r86322 - in /llvm/trunk: include/llvm/CodeGen/LiveIntervalAnalysis.h lib/CodeGen/LiveIntervalAnalysis.cpp In-Reply-To: References: <200911070158.nA71wfDw014511@zion.cs.uiuc.edu> <6AAE6969-BC82-4A24-806B-5200A1BF6759@2pi.dk> Message-ID: <36A0DA16-08C3-4016-974B-5DCD1A95F8B4@2pi.dk> On Nov 6, 2009, at 6:51 PM, Evan Cheng wrote: > > On Nov 6, 2009, at 6:28 PM, Jakob Stoklund Olesen wrote: >> The early coalescer wanted to define %reg1065 at index 2508, even >> though it is being used at the next instruction. This is the >> miscompilation. > > But I bet the resulting code is exactly the same as that without the > early coalescer . :-) Yup :-) From kremenek at apple.com Fri Nov 6 21:26:59 2009 From: kremenek at apple.com (Ted Kremenek) Date: Sat, 07 Nov 2009 03:26:59 -0000 Subject: [llvm-commits] [llvm] r86325 - /llvm/trunk/lib/Target/ARM/CMakeLists.txt Message-ID: <200911070326.nA73Qx7T017293@zion.cs.uiuc.edu> Author: kremenek Date: Fri Nov 6 21:26:59 2009 New Revision: 86325 URL: http://llvm.org/viewvc/llvm-project?rev=86325&view=rev Log: Update CMake file. Modified: llvm/trunk/lib/Target/ARM/CMakeLists.txt Modified: llvm/trunk/lib/Target/ARM/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/CMakeLists.txt?rev=86325&r1=86324&r2=86325&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/CMakeLists.txt (original) +++ llvm/trunk/lib/Target/ARM/CMakeLists.txt Fri Nov 6 21:26:59 2009 @@ -17,6 +17,7 @@ ARMCodeEmitter.cpp ARMConstantIslandPass.cpp ARMConstantPoolValue.cpp + ARMExpandPseudoInsts.cpp ARMISelDAGToDAG.cpp ARMISelLowering.cpp ARMInstrInfo.cpp From evan.cheng at apple.com Fri Nov 6 21:52:03 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Sat, 07 Nov 2009 03:52:03 -0000 Subject: [llvm-commits] [llvm] r86328 - in /llvm/trunk: lib/CodeGen/MachineLICM.cpp lib/CodeGen/TargetInstrInfoImpl.cpp lib/Target/ARM/ARMConstantPoolValue.cpp lib/Target/ARM/ARMConstantPoolValue.h lib/Target/ARM/Thumb2InstrInfo.cpp lib/Target/ARM/Thumb2InstrInfo.h test/CodeGen/Thumb2/machine-licm.ll Message-ID: <200911070352.nA73q371018144@zion.cs.uiuc.edu> Author: evancheng Date: Fri Nov 6 21:52:02 2009 New Revision: 86328 URL: http://llvm.org/viewvc/llvm-project?rev=86328&view=rev Log: - Add TargetInstrInfo::isIdentical(). It's similar to MachineInstr::isIdentical except it doesn't care if the definitions' virtual registers differ. This is used by machine LICM and other MI passes to perform CSE. - Teach Thumb2InstrInfo::isIdentical() to check two t2LDRpci_pic are identical. Since pc relative constantpool entries are always different, this requires it it check if the values can actually the same. Modified: llvm/trunk/lib/CodeGen/MachineLICM.cpp llvm/trunk/lib/CodeGen/TargetInstrInfoImpl.cpp llvm/trunk/lib/Target/ARM/ARMConstantPoolValue.cpp llvm/trunk/lib/Target/ARM/ARMConstantPoolValue.h llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.h llvm/trunk/test/CodeGen/Thumb2/machine-licm.ll Modified: llvm/trunk/lib/CodeGen/MachineLICM.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineLICM.cpp?rev=86328&r1=86327&r2=86328&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineLICM.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineLICM.cpp Fri Nov 6 21:52:02 2009 @@ -22,6 +22,7 @@ #define DEBUG_TYPE "machine-licm" #include "llvm/CodeGen/Passes.h" +#include "llvm/CodeGen/MachineConstantPool.h" #include "llvm/CodeGen/MachineDominators.h" #include "llvm/CodeGen/MachineLoopInfo.h" #include "llvm/CodeGen/MachineMemOperand.h" @@ -43,6 +44,7 @@ namespace { class MachineLICM : public MachineFunctionPass { + MachineConstantPool *MCP; const TargetMachine *TM; const TargetInstrInfo *TII; const TargetRegisterInfo *TRI; @@ -111,6 +113,11 @@ /// be hoistable. MachineInstr *ExtractHoistableLoad(MachineInstr *MI); + /// LookForDuplicate - Find an instruction amount PrevMIs that is a + /// duplicate of MI. Return this instruction if it's found. + const MachineInstr *LookForDuplicate(const MachineInstr *MI, + std::vector &PrevMIs); + /// EliminateCSE - Given a LICM'ed instruction, look for an instruction on /// the preheader that compute the same value. If it's found, do a RAU on /// with the definition of the existing instruction rather than hoisting @@ -153,6 +160,7 @@ DEBUG(errs() << "******** Machine LICM ********\n"); Changed = FirstInLoop = false; + MCP = MF.getConstantPool(); TM = &MF.getTarget(); TII = TM->getInstrInfo(); TRI = TM->getRegisterInfo(); @@ -432,32 +440,12 @@ } } -static const MachineInstr *LookForDuplicate(const MachineInstr *MI, - std::vector &PrevMIs, - MachineRegisterInfo *RegInfo) { - unsigned NumOps = MI->getNumOperands(); +const MachineInstr* +MachineLICM::LookForDuplicate(const MachineInstr *MI, + std::vector &PrevMIs) { for (unsigned i = 0, e = PrevMIs.size(); i != e; ++i) { const MachineInstr *PrevMI = PrevMIs[i]; - unsigned NumOps2 = PrevMI->getNumOperands(); - if (NumOps != NumOps2) - continue; - bool IsSame = true; - for (unsigned j = 0; j != NumOps; ++j) { - const MachineOperand &MO = MI->getOperand(j); - if (MO.isReg() && MO.isDef()) { - if (RegInfo->getRegClass(MO.getReg()) != - RegInfo->getRegClass(PrevMI->getOperand(j).getReg())) { - IsSame = false; - break; - } - continue; - } - if (!MO.isIdenticalTo(PrevMI->getOperand(j))) { - IsSame = false; - break; - } - } - if (IsSame) + if (TII->isIdentical(MI, PrevMI, RegInfo)) return PrevMI; } return 0; @@ -465,18 +453,19 @@ bool MachineLICM::EliminateCSE(MachineInstr *MI, DenseMap >::iterator &CI) { - if (CI != CSEMap.end()) { - if (const MachineInstr *Dup = LookForDuplicate(MI, CI->second, RegInfo)) { - DEBUG(errs() << "CSEing " << *MI << " with " << *Dup); - for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { - const MachineOperand &MO = MI->getOperand(i); - if (MO.isReg() && MO.isDef()) - RegInfo->replaceRegWith(MO.getReg(), Dup->getOperand(i).getReg()); - } - MI->eraseFromParent(); - ++NumCSEed; - return true; + if (CI == CSEMap.end()) + return false; + + if (const MachineInstr *Dup = LookForDuplicate(MI, CI->second)) { + DEBUG(errs() << "CSEing " << *MI << " with " << *Dup); + for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { + const MachineOperand &MO = MI->getOperand(i); + if (MO.isReg() && MO.isDef()) + RegInfo->replaceRegWith(MO.getReg(), Dup->getOperand(i).getReg()); } + MI->eraseFromParent(); + ++NumCSEed; + return true; } return false; } Modified: llvm/trunk/lib/CodeGen/TargetInstrInfoImpl.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetInstrInfoImpl.cpp?rev=86328&r1=86327&r2=86328&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/TargetInstrInfoImpl.cpp (original) +++ llvm/trunk/lib/CodeGen/TargetInstrInfoImpl.cpp Fri Nov 6 21:52:02 2009 @@ -143,6 +143,37 @@ MBB.insert(I, MI); } +bool +TargetInstrInfoImpl::isIdentical(const MachineInstr *MI, + const MachineInstr *Other, + const MachineRegisterInfo *MRI) const { + if (MI->getOpcode() != Other->getOpcode() || + MI->getNumOperands() != Other->getNumOperands()) + return false; + + for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { + const MachineOperand &MO = MI->getOperand(i); + const MachineOperand &OMO = Other->getOperand(i); + if (MO.isReg() && MO.isDef()) { + assert(OMO.isReg() && OMO.isDef()); + unsigned Reg = MO.getReg(); + if (TargetRegisterInfo::isPhysicalRegister(Reg)) { + if (Reg != OMO.getReg()) + return false; + } else if (MRI->getRegClass(MO.getReg()) != + MRI->getRegClass(OMO.getReg())) + return false; + + continue; + } + + if (!MO.isIdenticalTo(OMO)) + return false; + } + + return true; +} + unsigned TargetInstrInfoImpl::GetFunctionSizeInBytes(const MachineFunction &MF) const { unsigned FnSize = 0; Modified: llvm/trunk/lib/Target/ARM/ARMConstantPoolValue.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMConstantPoolValue.cpp?rev=86328&r1=86327&r2=86328&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMConstantPoolValue.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMConstantPoolValue.cpp Fri Nov 6 21:52:02 2009 @@ -62,9 +62,10 @@ ARMConstantPoolValue *CPV = (ARMConstantPoolValue *)Constants[i].Val.MachineCPVal; if (CPV->CVal == CVal && - CPV->S == S && CPV->LabelId == LabelId && - CPV->PCAdjust == PCAdjust) + CPV->PCAdjust == PCAdjust && + (CPV->S == S || strcmp(CPV->S, S) == 0) && + (CPV->Modifier == Modifier || strcmp(CPV->Modifier, Modifier) == 0)) return i; } } @@ -84,6 +85,23 @@ ID.AddInteger(PCAdjust); } +bool +ARMConstantPoolValue::hasSameValue(ARMConstantPoolValue *ACPV) { + if (ACPV->Kind == Kind && + ACPV->CVal == CVal && + ACPV->PCAdjust == PCAdjust && + (ACPV->S == S || strcmp(ACPV->S, S) == 0) && + (ACPV->Modifier == Modifier || strcmp(ACPV->Modifier, Modifier) == 0)) { + if (ACPV->LabelId == LabelId) + return true; + // Two PC relative constpool entries containing the same GV address or + // external symbols. FIXME: What about blockaddress? + if (Kind == ARMCP::CPValue || Kind == ARMCP::CPExtSymbol) + return true; + } + return false; +} + void ARMConstantPoolValue::dump() const { errs() << " " << *this; } Modified: llvm/trunk/lib/Target/ARM/ARMConstantPoolValue.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMConstantPoolValue.h?rev=86328&r1=86327&r2=86328&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMConstantPoolValue.h (original) +++ llvm/trunk/lib/Target/ARM/ARMConstantPoolValue.h Fri Nov 6 21:52:02 2009 @@ -81,6 +81,10 @@ virtual void AddSelectionDAGCSEId(FoldingSetNodeID &ID); + /// hasSameValue - Return true if this ARM constpool value + /// can share the same constantpool entry as another ARM constpool value. + bool hasSameValue(ARMConstantPoolValue *ACPV); + void print(raw_ostream *O) const { if (O) print(*O); } void print(raw_ostream &O) const; void dump() const; Modified: llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp?rev=86328&r1=86327&r2=86328&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp Fri Nov 6 21:52:02 2009 @@ -175,6 +175,32 @@ NewMI->getOperand(0).setSubReg(SubIdx); } +bool Thumb2InstrInfo::isIdentical(const MachineInstr *MI0, + const MachineInstr *MI1, + const MachineRegisterInfo *MRI) const { + unsigned Opcode = MI0->getOpcode(); + if (Opcode == ARM::t2LDRpci_pic) { + const MachineOperand &MO0 = MI0->getOperand(1); + const MachineOperand &MO1 = MI1->getOperand(1); + if (MO0.getOffset() != MO1.getOffset()) + return false; + + const MachineFunction *MF = MI0->getParent()->getParent(); + const MachineConstantPool *MCP = MF->getConstantPool(); + int CPI0 = MO0.getIndex(); + int CPI1 = MO1.getIndex(); + const MachineConstantPoolEntry &MCPE0 = MCP->getConstants()[CPI0]; + const MachineConstantPoolEntry &MCPE1 = MCP->getConstants()[CPI1]; + ARMConstantPoolValue *ACPV0 = + static_cast(MCPE0.Val.MachineCPVal); + ARMConstantPoolValue *ACPV1 = + static_cast(MCPE1.Val.MachineCPVal); + return ACPV0->hasSameValue(ACPV1); + } + + return TargetInstrInfoImpl::isIdentical(MI0, MI1, MRI); +} + void llvm::emitT2RegPlusImmediate(MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI, DebugLoc dl, unsigned DestReg, unsigned BaseReg, int NumBytes, Modified: llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.h?rev=86328&r1=86327&r2=86328&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.h (original) +++ llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.h Fri Nov 6 21:52:02 2009 @@ -54,6 +54,10 @@ unsigned DestReg, unsigned SubIdx, const MachineInstr *Orig) const; + bool isIdentical(const MachineInstr *MI, + const MachineInstr *Other, + const MachineRegisterInfo *MRI) const; + /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As /// such, whenever a client has an instance of instruction info, it should /// always be able to get register info as well (through this method). Modified: llvm/trunk/test/CodeGen/Thumb2/machine-licm.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/machine-licm.ll?rev=86328&r1=86327&r2=86328&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/machine-licm.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/machine-licm.ll Fri Nov 6 21:52:02 2009 @@ -15,11 +15,13 @@ bb.nph: ; preds = %entry ; CHECK: BB#1 -; CHECK: ldr{{.*}} r{{[0-9]+}}, LCPI1_0 -; CHECK: ldr{{.*}} r{{[0-9]+}}, LCPI1_1 -; CHECK: add r{{[0-9]+}}, pc -; CHECK: add r{{[0-9]+}}, pc +; CHECK: ldr.n r2, LCPI1_0 +; CHECK: add r2, pc +; CHECK: ldr r{{[0-9]+}}, [r2] ; CHECK: LBB1_2 +; CHECK: LCPI1_0: +; CHECK-NOT: LCPI1_1: +; CHECK: .section %.pre = load i32* @GV, align 4 ; [#uses=1] br label %bb From evan.cheng at apple.com Fri Nov 6 22:04:37 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Sat, 07 Nov 2009 04:04:37 -0000 Subject: [llvm-commits] [llvm] r86330 - in /llvm/trunk: lib/Target/ARM/ARMBaseInstrInfo.cpp lib/Target/ARM/ARMBaseInstrInfo.h lib/Target/ARM/README.txt lib/Target/ARM/Thumb2InstrInfo.cpp lib/Target/ARM/Thumb2InstrInfo.h test/CodeGen/Thumb/machine-licm.ll test/CodeGen/Thumb2/machine-licm.ll Message-ID: <200911070404.nA744bsm018504@zion.cs.uiuc.edu> Author: evancheng Date: Fri Nov 6 22:04:34 2009 New Revision: 86330 URL: http://llvm.org/viewvc/llvm-project?rev=86330&view=rev Log: Refactor code. Fix a potential missing check. Teach isIdentical() about tLDRpci_pic. Added: llvm/trunk/test/CodeGen/Thumb/machine-licm.ll Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h llvm/trunk/lib/Target/ARM/README.txt llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.h llvm/trunk/test/CodeGen/Thumb2/machine-licm.ll Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp?rev=86330&r1=86329&r2=86330&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp Fri Nov 6 22:04:34 2009 @@ -14,11 +14,13 @@ #include "ARMBaseInstrInfo.h" #include "ARM.h" #include "ARMAddressingModes.h" +#include "ARMConstantPoolValue.h" #include "ARMGenInstrInfo.inc" #include "ARMMachineFunctionInfo.h" #include "ARMRegisterInfo.h" #include "llvm/ADT/STLExtras.h" #include "llvm/CodeGen/LiveVariables.h" +#include "llvm/CodeGen/MachineConstantPool.h" #include "llvm/CodeGen/MachineFrameInfo.h" #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/MachineJumpTableInfo.h" @@ -895,6 +897,37 @@ return false; } +bool ARMBaseInstrInfo::isIdentical(const MachineInstr *MI0, + const MachineInstr *MI1, + const MachineRegisterInfo *MRI) const { + int Opcode = MI0->getOpcode(); + if (Opcode == ARM::t2LDRpci_pic || Opcode == ARM::tLDRpci_pic) { + if (MI1->getOpcode() != Opcode) + return false; + if (MI0->getNumOperands() != MI1->getNumOperands()) + return false; + + const MachineOperand &MO0 = MI0->getOperand(1); + const MachineOperand &MO1 = MI1->getOperand(1); + if (MO0.getOffset() != MO1.getOffset()) + return false; + + const MachineFunction *MF = MI0->getParent()->getParent(); + const MachineConstantPool *MCP = MF->getConstantPool(); + int CPI0 = MO0.getIndex(); + int CPI1 = MO1.getIndex(); + const MachineConstantPoolEntry &MCPE0 = MCP->getConstants()[CPI0]; + const MachineConstantPoolEntry &MCPE1 = MCP->getConstants()[CPI1]; + ARMConstantPoolValue *ACPV0 = + static_cast(MCPE0.Val.MachineCPVal); + ARMConstantPoolValue *ACPV1 = + static_cast(MCPE1.Val.MachineCPVal); + return ACPV0->hasSameValue(ACPV1); + } + + return TargetInstrInfoImpl::isIdentical(MI0, MI1, MRI); +} + /// getInstrPredicate - If instruction is predicated, returns its predicate /// condition, otherwise returns AL. It also returns the condition code /// register by reference. Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h?rev=86330&r1=86329&r2=86330&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h Fri Nov 6 22:04:34 2009 @@ -263,6 +263,9 @@ MachineInstr* MI, const SmallVectorImpl &Ops, MachineInstr* LoadMI) const; + + virtual bool isIdentical(const MachineInstr *MI, const MachineInstr *Other, + const MachineRegisterInfo *MRI) const; }; static inline Modified: llvm/trunk/lib/Target/ARM/README.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/README.txt?rev=86330&r1=86329&r2=86330&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/README.txt (original) +++ llvm/trunk/lib/Target/ARM/README.txt Fri Nov 6 22:04:34 2009 @@ -591,3 +591,8 @@ //===---------------------------------------------------------------------===// Make use of the "rbit" instruction. + +//===---------------------------------------------------------------------===// + +Take a look at test/CodeGen/Thumb2/machine-licm.ll. ARM should be taught how +to licm and cse the unnecessary load from cp#1. Modified: llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp?rev=86330&r1=86329&r2=86330&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp Fri Nov 6 22:04:34 2009 @@ -175,32 +175,6 @@ NewMI->getOperand(0).setSubReg(SubIdx); } -bool Thumb2InstrInfo::isIdentical(const MachineInstr *MI0, - const MachineInstr *MI1, - const MachineRegisterInfo *MRI) const { - unsigned Opcode = MI0->getOpcode(); - if (Opcode == ARM::t2LDRpci_pic) { - const MachineOperand &MO0 = MI0->getOperand(1); - const MachineOperand &MO1 = MI1->getOperand(1); - if (MO0.getOffset() != MO1.getOffset()) - return false; - - const MachineFunction *MF = MI0->getParent()->getParent(); - const MachineConstantPool *MCP = MF->getConstantPool(); - int CPI0 = MO0.getIndex(); - int CPI1 = MO1.getIndex(); - const MachineConstantPoolEntry &MCPE0 = MCP->getConstants()[CPI0]; - const MachineConstantPoolEntry &MCPE1 = MCP->getConstants()[CPI1]; - ARMConstantPoolValue *ACPV0 = - static_cast(MCPE0.Val.MachineCPVal); - ARMConstantPoolValue *ACPV1 = - static_cast(MCPE1.Val.MachineCPVal); - return ACPV0->hasSameValue(ACPV1); - } - - return TargetInstrInfoImpl::isIdentical(MI0, MI1, MRI); -} - void llvm::emitT2RegPlusImmediate(MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI, DebugLoc dl, unsigned DestReg, unsigned BaseReg, int NumBytes, Modified: llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.h?rev=86330&r1=86329&r2=86330&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.h (original) +++ llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.h Fri Nov 6 22:04:34 2009 @@ -54,10 +54,6 @@ unsigned DestReg, unsigned SubIdx, const MachineInstr *Orig) const; - bool isIdentical(const MachineInstr *MI, - const MachineInstr *Other, - const MachineRegisterInfo *MRI) const; - /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As /// such, whenever a client has an instance of instruction info, it should /// always be able to get register info as well (through this method). Added: llvm/trunk/test/CodeGen/Thumb/machine-licm.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb/machine-licm.ll?rev=86330&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/Thumb/machine-licm.ll (added) +++ llvm/trunk/test/CodeGen/Thumb/machine-licm.ll Fri Nov 6 22:04:34 2009 @@ -0,0 +1,41 @@ +; RUN: llc < %s -mtriple=thumb-apple-darwin -relocation-model=pic -disable-fp-elim | FileCheck %s +; rdar://7353541 +; rdar://7354376 + +; The generated code is no where near ideal. It's not recognizing the two +; constantpool entries being loaded can be merged into one. + + at GV = external global i32 ; [#uses=2] + +define arm_apcscc void @t(i32* nocapture %vals, i32 %c) nounwind { +entry: +; CHECK: t: + %0 = icmp eq i32 %c, 0 ; [#uses=1] + br i1 %0, label %return, label %bb.nph + +bb.nph: ; preds = %entry +; CHECK: BB#1 +; CHECK: ldr.n r2, LCPI1_0 +; CHECK: add r2, pc +; CHECK: ldr r{{[0-9]+}}, [r2] +; CHECK: LBB1_2 +; CHECK: LCPI1_0: +; CHECK-NOT: LCPI1_1: +; CHECK: .section + %.pre = load i32* @GV, align 4 ; [#uses=1] + br label %bb + +bb: ; preds = %bb, %bb.nph + %1 = phi i32 [ %.pre, %bb.nph ], [ %3, %bb ] ; [#uses=1] + %i.03 = phi i32 [ 0, %bb.nph ], [ %4, %bb ] ; [#uses=2] + %scevgep = getelementptr i32* %vals, i32 %i.03 ; [#uses=1] + %2 = load i32* %scevgep, align 4 ; [#uses=1] + %3 = add nsw i32 %1, %2 ; [#uses=2] + store i32 %3, i32* @GV, align 4 + %4 = add i32 %i.03, 1 ; [#uses=2] + %exitcond = icmp eq i32 %4, %c ; [#uses=1] + br i1 %exitcond, label %return, label %bb + +return: ; preds = %bb, %entry + ret void +} Modified: llvm/trunk/test/CodeGen/Thumb2/machine-licm.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/machine-licm.ll?rev=86330&r1=86329&r2=86330&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/machine-licm.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/machine-licm.ll Fri Nov 6 22:04:34 2009 @@ -1,5 +1,6 @@ ; RUN: llc < %s -mtriple=thumbv7-apple-darwin -relocation-model=pic -disable-fp-elim | FileCheck %s ; rdar://7353541 +; rdar://7354376 ; The generated code is no where near ideal. It's not recognizing the two ; constantpool entries being loaded can be merged into one. From evan.cheng at apple.com Fri Nov 6 22:07:30 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Sat, 07 Nov 2009 04:07:30 -0000 Subject: [llvm-commits] [llvm] r86331 - /llvm/trunk/include/llvm/Target/TargetInstrInfo.h Message-ID: <200911070407.nA747U4k018583@zion.cs.uiuc.edu> Author: evancheng Date: Fri Nov 6 22:07:30 2009 New Revision: 86331 URL: http://llvm.org/viewvc/llvm-project?rev=86331&view=rev Log: Missed this. Modified: llvm/trunk/include/llvm/Target/TargetInstrInfo.h Modified: llvm/trunk/include/llvm/Target/TargetInstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetInstrInfo.h?rev=86331&r1=86330&r2=86331&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetInstrInfo.h (original) +++ llvm/trunk/include/llvm/Target/TargetInstrInfo.h Fri Nov 6 22:07:30 2009 @@ -21,7 +21,6 @@ class MCAsmInfo; class TargetRegisterClass; -class TargetRegisterInfo; class LiveVariables; class CalleeSavedInfo; class SDNode; @@ -226,6 +225,14 @@ virtual bool findCommutedOpIndices(MachineInstr *MI, unsigned &SrcOpIdx1, unsigned &SrcOpIdx2) const = 0; + /// isIdentical - Return true if two instructions are identical. This differs + /// from MachineInstr::isIdenticalTo() in that it does not require the + /// virtual destination registers to be the same. This is used by MachineLICM + /// and other MI passes to perform CSE. + virtual bool isIdentical(const MachineInstr *MI, + const MachineInstr *Other, + const MachineRegisterInfo *MRI) const = 0; + /// AnalyzeBranch - Analyze the branching code at the end of MBB, returning /// true if it cannot be understood (e.g. it's a switch dispatch or isn't /// implemented for a target). Upon success, this returns false and returns @@ -510,6 +517,10 @@ MachineBasicBlock::iterator MI, unsigned DestReg, unsigned SubReg, const MachineInstr *Orig) const; + virtual bool isIdentical(const MachineInstr *MI, + const MachineInstr *Other, + const MachineRegisterInfo *MRI) const; + virtual unsigned GetFunctionSizeInBytes(const MachineFunction &MF) const; }; From wangmp at apple.com Fri Nov 6 22:07:33 2009 From: wangmp at apple.com (Mon P Wang) Date: Sat, 07 Nov 2009 04:07:33 -0000 Subject: [llvm-commits] [llvm] r86332 - /llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp Message-ID: <200911070407.nA747XPj018595@zion.cs.uiuc.edu> Author: wangmp Date: Fri Nov 6 22:07:33 2009 New Revision: 86332 URL: http://llvm.org/viewvc/llvm-project?rev=86332&view=rev Log: Fixed Overload table bug noticed by Jakob Modified: llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp Modified: llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp?rev=86332&r1=86331&r2=86332&view=diff ============================================================================== --- llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp (original) +++ llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp Fri Nov 6 22:07:33 2009 @@ -62,7 +62,6 @@ bool BlackfinIntrinsicInfo::isOverloaded(unsigned IntrID) const { // Overload Table const bool OTable[] = { - false, // illegal intrinsic #define GET_INTRINSIC_OVERLOAD_TABLE #include "BlackfinGenIntrinsics.inc" #undef GET_INTRINSIC_OVERLOAD_TABLE From wangmp at apple.com Fri Nov 6 22:46:28 2009 From: wangmp at apple.com (Mon P Wang) Date: Sat, 07 Nov 2009 04:46:28 -0000 Subject: [llvm-commits] [llvm] r86340 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Message-ID: <200911070446.nA74kSrd019716@zion.cs.uiuc.edu> Author: wangmp Date: Fri Nov 6 22:46:25 2009 New Revision: 86340 URL: http://llvm.org/viewvc/llvm-project?rev=86340&view=rev Log: Fix memoizing of CvtRndSatSDNode Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=86340&r1=86339&r2=86340&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Fri Nov 6 22:46:25 2009 @@ -1270,11 +1270,12 @@ return Val; FoldingSetNodeID ID; + SDValue Ops[] = { Val, DTy, STy, Rnd, Sat }; + AddNodeIDNode(ID, ISD::CONVERT_RNDSAT, getVTList(VT), &Ops[0], 5); void* IP = 0; if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP)) return SDValue(E, 0); CvtRndSatSDNode *N = NodeAllocator.Allocate(); - SDValue Ops[] = { Val, DTy, STy, Rnd, Sat }; new (N) CvtRndSatSDNode(VT, dl, Ops, 5, Code); CSEMap.InsertNode(N, IP); AllNodes.push_back(N); From Jan.Sjodin at amd.com Fri Nov 6 15:39:23 2009 From: Jan.Sjodin at amd.com (Sjodin, Jan) Date: Fri, 6 Nov 2009 13:39:23 -0800 Subject: [llvm-commits] Patch for scalarized division. Message-ID: <1C8DE0332CB01445BF7ADEDE3DDD57071958CF9F@sausexmbp02.amd.com> In LegalizeVectorOps the resulting scalar divisions must not be generated if they have undefined vector elements as operands. This may be unsafe because the divides can cause division by zero exceptions, and also slows down the code. This patch attempts to fix this issue by checking if the operands are defined or not. I would be grateful if someone could review this patch. Thanks! - Jan Sjodin -------------- next part -------------- A non-text attachment was scrubbed... Name: 0015_scalarized_div.diff Type: application/octet-stream Size: 6912 bytes Desc: 0015_scalarized_div.diff Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091106/eec63aa9/attachment.obj From clattner at apple.com Fri Nov 6 23:08:17 2009 From: clattner at apple.com (Chris Lattner) Date: Fri, 6 Nov 2009 21:08:17 -0800 Subject: [llvm-commits] [llvm] r86303 - in /llvm/trunk: lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp test/CodeGen/ARM/2009-11-07-SubRegAsmPrinting.ll In-Reply-To: References: <200911062345.nA6NjG1Y009900@zion.cs.uiuc.edu> <07E87410-00C7-444B-981B-E80A8B79B75A@apple.com> Message-ID: <0FEA2F07-E2F5-4CEE-B54B-91D18D73A85C@apple.com> On Nov 6, 2009, at 4:50 PM, Anton Korobeynikov wrote: > Hello, Jakob > >> Can you reduce it further with an assert in asmprinting? > No, this is smallest reduction obtained exactly this way :) Ok, can you revert the ARM Asmprinter change or at least comment it violently so that when I get back to MC'izing ARM that I will know to delete it? -Chris From clattner at apple.com Fri Nov 6 23:09:06 2009 From: clattner at apple.com (Chris Lattner) Date: Fri, 6 Nov 2009 21:09:06 -0800 Subject: [llvm-commits] [llvm] r86314 - /llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp In-Reply-To: <200911070026.nA70Qmar011533@zion.cs.uiuc.edu> References: <200911070026.nA70Qmar011533@zion.cs.uiuc.edu> Message-ID: <31CD03E4-BDF6-4BC2-B90C-A2A315A39319@apple.com> On Nov 6, 2009, at 4:26 PM, Jeffrey Yasskin wrote: > Author: jyasskin > Date: Fri Nov 6 18:26:47 2009 > New Revision: 86314 > > URL: http://llvm.org/viewvc/llvm-project?rev=86314&view=rev > Log: > Avoid "ambiguous 'else'" warning from gcc. That's a lame warning. If GCC had better grasp of columns/indentation of the else, it could see that it was clearly doing the right thing. -Chris > > Modified: > llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp > > Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=86314&r1=86313&r2=86314&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original) > +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Fri Nov 6 > 18:26:47 2009 > @@ -213,11 +213,12 @@ > return ConstantExpr::getCompare(pred, CLHS, CRHS); > > if (LHS == RHS) > - if (isa(LHS->getType()) || isa(LHS- > >getType())) > + if (isa(LHS->getType()) || isa(LHS- > >getType())) { > if (ICmpInst::isTrueWhenEqual(pred)) > return ConstantInt::getTrue(LHS->getContext()); > else > return ConstantInt::getFalse(LHS->getContext()); > + } > return 0; > } > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From clattner at apple.com Fri Nov 6 23:09:46 2009 From: clattner at apple.com (Chris Lattner) Date: Fri, 6 Nov 2009 21:09:46 -0800 Subject: [llvm-commits] [llvm] r86314 - /llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp In-Reply-To: <31CD03E4-BDF6-4BC2-B90C-A2A315A39319@apple.com> References: <200911070026.nA70Qmar011533@zion.cs.uiuc.edu> <31CD03E4-BDF6-4BC2-B90C-A2A315A39319@apple.com> Message-ID: On Nov 6, 2009, at 9:09 PM, Chris Lattner wrote: > > On Nov 6, 2009, at 4:26 PM, Jeffrey Yasskin wrote: > >> Author: jyasskin >> Date: Fri Nov 6 18:26:47 2009 >> New Revision: 86314 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=86314&view=rev >> Log: >> Avoid "ambiguous 'else'" warning from gcc. > > That's a lame warning. If GCC had better grasp of columns/indentation > of the else, it could see that it was clearly doing the right thing. Not that I dislike your patch, of course. Thanks for doing this. :) -Chris From jyasskin at google.com Fri Nov 6 23:13:42 2009 From: jyasskin at google.com (Jeffrey Yasskin) Date: Fri, 6 Nov 2009 21:13:42 -0800 Subject: [llvm-commits] [llvm] r86314 - /llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp In-Reply-To: References: <200911070026.nA70Qmar011533@zion.cs.uiuc.edu> <31CD03E4-BDF6-4BC2-B90C-A2A315A39319@apple.com> Message-ID: On Fri, Nov 6, 2009 at 9:09 PM, Chris Lattner wrote: > > On Nov 6, 2009, at 9:09 PM, Chris Lattner wrote: > >> >> On Nov 6, 2009, at 4:26 PM, Jeffrey Yasskin wrote: >> >>> Author: jyasskin >>> Date: Fri Nov ?6 18:26:47 2009 >>> New Revision: 86314 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=86314&view=rev >>> Log: >>> Avoid "ambiguous 'else'" warning from gcc. >> >> That's a lame warning. ?If GCC had better grasp of columns/indentation >> of the else, it could see that it was clearly doing the right thing. > > Not that I dislike your patch, of course. ?Thanks for doing this. :) What? A compiler be aware of whitespace? That's only for lame languages like Haskell and Python! :) From evan.cheng at apple.com Fri Nov 6 23:21:30 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 6 Nov 2009 21:21:30 -0800 Subject: [llvm-commits] [PATCH] fix comm directive alignment In-Reply-To: <305d6f60911051555gf844415g87a68d583fee3063@mail.gmail.com> References: <305d6f60911051555gf844415g87a68d583fee3063@mail.gmail.com> Message-ID: <8A209E7D-288E-4F94-AA27-0A66CB4CBFC2@apple.com> Perhaps Daniel or Kevin can review this? Evan On Nov 5, 2009, at 3:55 PM, Sandeep Patel wrote: > On ELF, the .align directive may be in log2(n) when the .comm > directive takes bytes for alignment. > > deep > align.diff>_______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From evan.cheng at apple.com Fri Nov 6 23:25:11 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 6 Nov 2009 21:25:11 -0800 Subject: [llvm-commits] [PATCH] Debug args and features In-Reply-To: <305d6f60911051559k690f5cas7653aefbdfa81f21@mail.gmail.com> References: <305d6f60911051559k690f5cas7653aefbdfa81f21@mail.gmail.com> Message-ID: <6C1DC5A9-642F-4A96-89AD-989CF8EE1685@apple.com> Ok. Evan On Nov 5, 2009, at 3:59 PM, Sandeep Patel wrote: > The attached debug code prints out the command line args the backend > has processed and the features string. > > deep > features.diff>_______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From jyasskin at gmail.com Fri Nov 6 23:30:10 2009 From: jyasskin at gmail.com (jyasskin at gmail.com) Date: Sat, 07 Nov 2009 05:30:10 +0000 Subject: [llvm-commits] [PATCH] Make the need-stub variables accurate and consistent Message-ID: <0016e640d40e1290880477c141c0@google.com> Reviewers: , Message: Please take a look. I'd like to find an example of a global-variable far stub to put in the comment for MachineRelocation::mayNeedFarStub(). Can anyone describe the requirement for ARM or another platform so I can copy it in? Description: I'm trying to tease apart the different uses for "stubs" in the JIT. In the case of MachineRelocations, I believe "stub" always refers to a far-call stub or a load-a-faraway-global stub, so this patch adds "Far" to the term. The variable was also inconsistent between the positive and negative sense, and the positive sense ("NeedStub") was more demanding than is accurate (since a nearby-enough function can be called directly even if the platform often requires a stub). Since the negative sense causes double-negatives, I switched to "MayNeedFarStub" globally. Please review this at http://codereview.appspot.com/151051 Affected files: M include/llvm/CodeGen/MachineRelocation.h M lib/ExecutionEngine/JIT/JITEmitter.cpp M lib/Target/ARM/ARMCodeEmitter.cpp M lib/Target/X86/X86CodeEmitter.cpp From lhames at gmail.com Fri Nov 6 23:50:29 2009 From: lhames at gmail.com (Lang Hames) Date: Sat, 07 Nov 2009 05:50:29 -0000 Subject: [llvm-commits] [llvm] r86342 - in /llvm/trunk: include/llvm/CodeGen/SlotIndexes.h lib/CodeGen/SlotIndexes.cpp Message-ID: <200911070550.nA75oTJI021622@zion.cs.uiuc.edu> Author: lhames Date: Fri Nov 6 23:50:28 2009 New Revision: 86342 URL: http://llvm.org/viewvc/llvm-project?rev=86342&view=rev Log: Update some globals to use ManagedStatic. Modified: llvm/trunk/include/llvm/CodeGen/SlotIndexes.h llvm/trunk/lib/CodeGen/SlotIndexes.cpp Modified: llvm/trunk/include/llvm/CodeGen/SlotIndexes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SlotIndexes.h?rev=86342&r1=86341&r2=86342&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/SlotIndexes.h (original) +++ llvm/trunk/include/llvm/CodeGen/SlotIndexes.h Fri Nov 6 23:50:28 2009 @@ -29,9 +29,13 @@ #include "llvm/CodeGen/MachineInstr.h" #include "llvm/Support/Allocator.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/ManagedStatic.h" namespace llvm { + class EmptyIndexListEntry; + class TombstoneIndexListEntry; + /// This class represents an entry in the slot index list held in the /// SlotIndexes pass. It should not be used directly. See the /// SlotIndex & SlotIndexes classes for the public interface to this @@ -39,16 +43,22 @@ class IndexListEntry { private: - static std::auto_ptr emptyKeyEntry, - tombstoneKeyEntry; - typedef enum { EMPTY_KEY, TOMBSTONE_KEY } ReservedEntryType; static const unsigned EMPTY_KEY_INDEX = ~0U & ~3U, TOMBSTONE_KEY_INDEX = ~0U & ~7U; + // The following statics are thread safe. They're read only, and you + // can't step from them to any other list entries. + static ManagedStatic emptyKeyEntry; + static ManagedStatic tombstoneKeyEntry; + IndexListEntry *next, *prev; MachineInstr *mi; unsigned index; + protected: + + typedef enum { EMPTY_KEY, TOMBSTONE_KEY } ReservedEntryType; + // This constructor is only to be used by getEmptyKeyEntry // & getTombstoneKeyEntry. It sets index to the given // value and mi to zero. @@ -58,6 +68,8 @@ case TOMBSTONE_KEY: index = TOMBSTONE_KEY_INDEX; break; default: assert(false && "Invalid value for constructor."); } + next = this; + prev = this; } public: @@ -70,38 +82,65 @@ } MachineInstr* getInstr() const { return mi; } - void setInstr(MachineInstr *mi) { this->mi = mi; } + void setInstr(MachineInstr *mi) { + assert(index != EMPTY_KEY_INDEX && index != TOMBSTONE_KEY_INDEX && + "Attempt to modify reserved index."); + this->mi = mi; + } unsigned getIndex() const { return index; } - void setIndex(unsigned index) { this->index = index; } + void setIndex(unsigned index) { + assert(index != EMPTY_KEY_INDEX && index != TOMBSTONE_KEY_INDEX && + "Attempt to set index to invalid value."); + assert(this->index != EMPTY_KEY_INDEX && + this->index != TOMBSTONE_KEY_INDEX && + "Attempt to reset reserved index value."); + this->index = index; + } IndexListEntry* getNext() { return next; } const IndexListEntry* getNext() const { return next; } - void setNext(IndexListEntry *next) { this->next = next; } + void setNext(IndexListEntry *next) { + assert(index != EMPTY_KEY_INDEX && index != TOMBSTONE_KEY_INDEX && + "Attempt to modify reserved index."); + this->next = next; + } IndexListEntry* getPrev() { return prev; } const IndexListEntry* getPrev() const { return prev; } - void setPrev(IndexListEntry *prev) { this->prev = prev; } + void setPrev(IndexListEntry *prev) { + assert(index != EMPTY_KEY_INDEX && index != TOMBSTONE_KEY_INDEX && + "Attempt to modify reserved index."); + this->prev = prev; + } // This function returns the index list entry that is to be used for empty // SlotIndex keys. - static IndexListEntry* getEmptyKeyEntry() { - if (emptyKeyEntry.get() == 0) { - emptyKeyEntry.reset(new IndexListEntry(EMPTY_KEY)); - } - return emptyKeyEntry.get(); - } + inline static IndexListEntry* getEmptyKeyEntry(); // This function returns the index list entry that is to be used for // tombstone SlotIndex keys. - static IndexListEntry* getTombstoneKeyEntry() { - if (tombstoneKeyEntry.get() == 0) { - tombstoneKeyEntry.reset(new IndexListEntry(TOMBSTONE_KEY)); - } - return tombstoneKeyEntry.get(); - } + inline static IndexListEntry* getTombstoneKeyEntry(); + }; + + class EmptyIndexListEntry : public IndexListEntry { + public: + EmptyIndexListEntry() : IndexListEntry(EMPTY_KEY) {} }; + class TombstoneIndexListEntry : public IndexListEntry { + public: + TombstoneIndexListEntry() : IndexListEntry(TOMBSTONE_KEY) {} + }; + + inline IndexListEntry* IndexListEntry::getEmptyKeyEntry() { + return &*emptyKeyEntry; + } + + inline IndexListEntry* IndexListEntry::getTombstoneKeyEntry() { + return &*tombstoneKeyEntry; + } + // Specialize PointerLikeTypeTraits for IndexListEntry. template <> class PointerLikeTypeTraits { Modified: llvm/trunk/lib/CodeGen/SlotIndexes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SlotIndexes.cpp?rev=86342&r1=86341&r2=86342&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SlotIndexes.cpp (original) +++ llvm/trunk/lib/CodeGen/SlotIndexes.cpp Fri Nov 6 23:50:28 2009 @@ -16,8 +16,10 @@ using namespace llvm; -std::auto_ptr IndexListEntry::emptyKeyEntry, - IndexListEntry::tombstoneKeyEntry; + +// Yep - these are thread safe. See the header for details. +ManagedStatic IndexListEntry::emptyKeyEntry; +ManagedStatic IndexListEntry::tombstoneKeyEntry; char SlotIndexes::ID = 0; static RegisterPass X("slotindexes", "Slot index numbering"); From lhames at gmail.com Fri Nov 6 23:52:04 2009 From: lhames at gmail.com (Lang Hames) Date: Fri, 6 Nov 2009 21:52:04 -0800 Subject: [llvm-commits] [llvm] r86049 - in /llvm/trunk: include/llvm/CodeGen/SlotIndexes.h lib/CodeGen/SlotIndexes.cpp In-Reply-To: <2FD10997-0651-440E-82AB-1DEA6ACB0C52@apple.com> References: <200911042124.nA4LOGUs001039@zion.cs.uiuc.edu> <2FD10997-0651-440E-82AB-1DEA6ACB0C52@apple.com> Message-ID: <728927c70911062152k1d94df73v1fc9ff4358e1d136@mail.gmail.com> Yep - that's bad. Fixed in r86342. - Lang. On Wed, Nov 4, 2009 at 2:44 PM, Chris Lattner wrote: > > On Nov 4, 2009, at 1:24 PM, Lang Hames wrote: > >> Author: lhames >> Date: Wed Nov ?4 15:24:15 2009 >> New Revision: 86049 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=86049&view=rev >> Log: >> Handle empty/tombstone keys for LiveIndex more cleanly. Check for index >> sanity when constructing index list entries. > > Hi Lang, > >> +++ llvm/trunk/lib/CodeGen/SlotIndexes.cpp Wed Nov ?4 15:24:15 2009 >> @@ -16,8 +16,8 @@ >> >> using namespace llvm; >> >> -std::auto_ptr SlotIndex::emptyKeyPtr(0), >> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?SlotIndex::tombstoneKeyPtr(0); >> +std::auto_ptr IndexListEntry::emptyKeyEntry, >> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?IndexListEntry::tombstoneKeyEntry; > > Why are you using global variables (with static ctors/dtors in particular) > for this? ?This does not appear to be thread safe. ?Can these be made > instance variables of the class? > > -Chris > From wangmp at apple.com Fri Nov 6 23:59:14 2009 From: wangmp at apple.com (Mon Ping Wang) Date: Fri, 6 Nov 2009 21:59:14 -0800 Subject: [llvm-commits] Patch for scalarized division. In-Reply-To: <1C8DE0332CB01445BF7ADEDE3DDD57071958CF9F@sausexmbp02.amd.com> References: <1C8DE0332CB01445BF7ADEDE3DDD57071958CF9F@sausexmbp02.amd.com> Message-ID: Hi Jan, Some quick comments about the patch. @@ -282,6 +289,95 @@ SDValue VectorLegalizer::UnrollVSETCC(SD +bool VectorLegalizer::rangeIsDefined(SDValue Op, + uint64_t LoBitIndex, + uint64_t HiBitIndex) +{ +[Deleted Code] + case ISD::ADD: + case ISD::SUB: + case ISD::MUL: + case ISD::SDIV: + case ISD::UDIV: + case ISD::SREM: + case ISD::UREM: { We should expand the list will have to expand to almost all operators. For example, an ISD::AND or ISD::XOR could cause the same problem as well as VECTOR_SHUFFLE. @@ -326,6 +422,16 @@ SDValue VectorLegalizer::UnrollVectorOp( Scalars.push_back(DAG.getNode(Op.getOpcode(), dl, EltVT, Operands[0], DAG.getShiftAmountOperand (Operands[1]))); break; + // Ensure that both operands are defined, if not, the result will + // be undefined. + case ISD::SDIV: + case ISD::UDIV: For some machines, SREM and UREM could have the same issue. This is a generic issue that goes beyond just SDIV/UDIV. In the majority of these cases, I think we should try to avoid generating operations for UNDEF. The only cases that give me pause of doing this all the time are operations like multiplication by 0, and of 0, etc.. where the UNDEF would be defined. The only other thing is that we recursively walk up an expression tree. If the expression tree is deep, this could cost some time. The main culprit that causes these UNDEF is due to widening. A crazy idea to avoid doing this is if a hardware knows a particular operation should not be widened, maybe it could use a target hook to scalarize the operation early doing LegalizeTypes. For X86, since divides will not be vector operations, we would avoid widening them only to lower them and work hard trying to avoid generating the extra divides. -- Mon Ping On Nov 6, 2009, at 1:39 PM, Sjodin, Jan wrote: > In LegalizeVectorOps the resulting scalar divisions must not be > generated if they have undefined vector elements as operands. This may > be unsafe because the divides can cause division by zero exceptions, > and also slows down the code. This patch attempts to fix this issue by > checking if the operands are defined or not. I would be grateful if > someone could review this patch. Thanks! > > - Jan > Sjodin > < > 0015_scalarized_div.diff > >_______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091106/8ca7842d/attachment.html From sabre at nondot.org Sat Nov 7 00:19:20 2009 From: sabre at nondot.org (Chris Lattner) Date: Sat, 07 Nov 2009 06:19:20 -0000 Subject: [llvm-commits] [llvm] r86345 - in /llvm/trunk/test/CodeGen/X86: cmp0.ll cmp1.ll Message-ID: <200911070619.nA76JLr5022639@zion.cs.uiuc.edu> Author: lattner Date: Sat Nov 7 00:19:20 2009 New Revision: 86345 URL: http://llvm.org/viewvc/llvm-project?rev=86345&view=rev Log: merge cmp1 into cmp0 and filecheckize. Removed: llvm/trunk/test/CodeGen/X86/cmp1.ll Modified: llvm/trunk/test/CodeGen/X86/cmp0.ll Modified: llvm/trunk/test/CodeGen/X86/cmp0.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/cmp0.ll?rev=86345&r1=86344&r2=86345&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/cmp0.ll (original) +++ llvm/trunk/test/CodeGen/X86/cmp0.ll Sat Nov 7 00:19:20 2009 @@ -1,7 +1,24 @@ -; RUN: llc < %s -march=x86-64 | grep -v cmp +; RUN: llc < %s -march=x86-64 | FileCheck %s -define i64 @foo(i64 %x) { +define i64 @test0(i64 %x) nounwind { %t = icmp eq i64 %x, 0 %r = zext i1 %t to i64 ret i64 %r +; CHECK: test0: +; CHECK: testq %rdi, %rdi +; CHECK: sete %al +; CHECK: movzbl %al, %eax +; CHECK: ret } + +define i64 @test1(i64 %x) nounwind { + %t = icmp slt i64 %x, 1 + %r = zext i1 %t to i64 + ret i64 %r +; CHECK: test1: +; CHECK: testq %rdi, %rdi +; CHECK: setle %al +; CHECK: movzbl %al, %eax +; CHECK: ret +} + Removed: llvm/trunk/test/CodeGen/X86/cmp1.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/cmp1.ll?rev=86344&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/cmp1.ll (original) +++ llvm/trunk/test/CodeGen/X86/cmp1.ll (removed) @@ -1,7 +0,0 @@ -; RUN: llc < %s -march=x86-64 | grep -v cmp - -define i64 @foo(i64 %x) { - %t = icmp slt i64 %x, 1 - %r = zext i1 %t to i64 - ret i64 %r -} From clattner at apple.com Sat Nov 7 00:32:13 2009 From: clattner at apple.com (Chris Lattner) Date: Fri, 6 Nov 2009 22:32:13 -0800 Subject: [llvm-commits] [llvm] r86342 - in /llvm/trunk: include/llvm/CodeGen/SlotIndexes.h lib/CodeGen/SlotIndexes.cpp In-Reply-To: <200911070550.nA75oTJI021622@zion.cs.uiuc.edu> References: <200911070550.nA75oTJI021622@zion.cs.uiuc.edu> Message-ID: <2BD34464-912A-481E-9018-2F68B07E29F4@apple.com> On Nov 6, 2009, at 9:50 PM, Lang Hames wrote: > Author: lhames > Date: Fri Nov 6 23:50:28 2009 > New Revision: 86342 > > URL: http://llvm.org/viewvc/llvm-project?rev=86342&view=rev > Log: > Update some globals to use ManagedStatic. Thanks Lang, can you move the relevant methods out of line? I'd prefer SlotIndexes.h to not #include ManagedStatic.h. Ideally only .cpp files would include that header. -Chris > > Modified: > llvm/trunk/include/llvm/CodeGen/SlotIndexes.h > llvm/trunk/lib/CodeGen/SlotIndexes.cpp > > Modified: llvm/trunk/include/llvm/CodeGen/SlotIndexes.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SlotIndexes.h?rev=86342&r1=86341&r2=86342&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/include/llvm/CodeGen/SlotIndexes.h (original) > +++ llvm/trunk/include/llvm/CodeGen/SlotIndexes.h Fri Nov 6 > 23:50:28 2009 > @@ -29,9 +29,13 @@ > #include "llvm/CodeGen/MachineInstr.h" > #include "llvm/Support/Allocator.h" > #include "llvm/Support/ErrorHandling.h" > +#include "llvm/Support/ManagedStatic.h" > > namespace llvm { > > + class EmptyIndexListEntry; > + class TombstoneIndexListEntry; > + > /// This class represents an entry in the slot index list held in > the > /// SlotIndexes pass. It should not be used directly. See the > /// SlotIndex & SlotIndexes classes for the public interface to this > @@ -39,16 +43,22 @@ > class IndexListEntry { > private: > > - static std::auto_ptr emptyKeyEntry, > - tombstoneKeyEntry; > - typedef enum { EMPTY_KEY, TOMBSTONE_KEY } ReservedEntryType; > static const unsigned EMPTY_KEY_INDEX = ~0U & ~3U, > TOMBSTONE_KEY_INDEX = ~0U & ~7U; > > + // The following statics are thread safe. They're read only, > and you > + // can't step from them to any other list entries. > + static ManagedStatic emptyKeyEntry; > + static ManagedStatic tombstoneKeyEntry; > + > IndexListEntry *next, *prev; > MachineInstr *mi; > unsigned index; > > + protected: > + > + typedef enum { EMPTY_KEY, TOMBSTONE_KEY } ReservedEntryType; > + > // This constructor is only to be used by getEmptyKeyEntry > // & getTombstoneKeyEntry. It sets index to the given > // value and mi to zero. > @@ -58,6 +68,8 @@ > case TOMBSTONE_KEY: index = TOMBSTONE_KEY_INDEX; break; > default: assert(false && "Invalid value for constructor."); > } > + next = this; > + prev = this; > } > > public: > @@ -70,38 +82,65 @@ > } > > MachineInstr* getInstr() const { return mi; } > - void setInstr(MachineInstr *mi) { this->mi = mi; } > + void setInstr(MachineInstr *mi) { > + assert(index != EMPTY_KEY_INDEX && index != > TOMBSTONE_KEY_INDEX && > + "Attempt to modify reserved index."); > + this->mi = mi; > + } > > unsigned getIndex() const { return index; } > - void setIndex(unsigned index) { this->index = index; } > + void setIndex(unsigned index) { > + assert(index != EMPTY_KEY_INDEX && index != > TOMBSTONE_KEY_INDEX && > + "Attempt to set index to invalid value."); > + assert(this->index != EMPTY_KEY_INDEX && > + this->index != TOMBSTONE_KEY_INDEX && > + "Attempt to reset reserved index value."); > + this->index = index; > + } > > IndexListEntry* getNext() { return next; } > const IndexListEntry* getNext() const { return next; } > - void setNext(IndexListEntry *next) { this->next = next; } > + void setNext(IndexListEntry *next) { > + assert(index != EMPTY_KEY_INDEX && index != > TOMBSTONE_KEY_INDEX && > + "Attempt to modify reserved index."); > + this->next = next; > + } > > IndexListEntry* getPrev() { return prev; } > const IndexListEntry* getPrev() const { return prev; } > - void setPrev(IndexListEntry *prev) { this->prev = prev; } > + void setPrev(IndexListEntry *prev) { > + assert(index != EMPTY_KEY_INDEX && index != > TOMBSTONE_KEY_INDEX && > + "Attempt to modify reserved index."); > + this->prev = prev; > + } > > // This function returns the index list entry that is to be used > for empty > // SlotIndex keys. > - static IndexListEntry* getEmptyKeyEntry() { > - if (emptyKeyEntry.get() == 0) { > - emptyKeyEntry.reset(new IndexListEntry(EMPTY_KEY)); > - } > - return emptyKeyEntry.get(); > - } > + inline static IndexListEntry* getEmptyKeyEntry(); > > // This function returns the index list entry that is to be used > for > // tombstone SlotIndex keys. > - static IndexListEntry* getTombstoneKeyEntry() { > - if (tombstoneKeyEntry.get() == 0) { > - tombstoneKeyEntry.reset(new IndexListEntry(TOMBSTONE_KEY)); > - } > - return tombstoneKeyEntry.get(); > - } > + inline static IndexListEntry* getTombstoneKeyEntry(); > + }; > + > + class EmptyIndexListEntry : public IndexListEntry { > + public: > + EmptyIndexListEntry() : IndexListEntry(EMPTY_KEY) {} > }; > > + class TombstoneIndexListEntry : public IndexListEntry { > + public: > + TombstoneIndexListEntry() : IndexListEntry(TOMBSTONE_KEY) {} > + }; > + > + inline IndexListEntry* IndexListEntry::getEmptyKeyEntry() { > + return &*emptyKeyEntry; > + } > + > + inline IndexListEntry* IndexListEntry::getTombstoneKeyEntry() { > + return &*tombstoneKeyEntry; > + } > + > // Specialize PointerLikeTypeTraits for IndexListEntry. > template <> > class PointerLikeTypeTraits { > > Modified: llvm/trunk/lib/CodeGen/SlotIndexes.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SlotIndexes.cpp?rev=86342&r1=86341&r2=86342&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/CodeGen/SlotIndexes.cpp (original) > +++ llvm/trunk/lib/CodeGen/SlotIndexes.cpp Fri Nov 6 23:50:28 2009 > @@ -16,8 +16,10 @@ > > using namespace llvm; > > -std::auto_ptr IndexListEntry::emptyKeyEntry, > - IndexListEntry::tombstoneKeyEntry; > + > +// Yep - these are thread safe. See the header for details. > +ManagedStatic IndexListEntry::emptyKeyEntry; > +ManagedStatic > IndexListEntry::tombstoneKeyEntry; > > char SlotIndexes::ID = 0; > static RegisterPass X("slotindexes", "Slot index > numbering"); > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From foldr at codedgers.com Sat Nov 7 00:33:01 2009 From: foldr at codedgers.com (Mikhail Glushenkov) Date: Sat, 07 Nov 2009 06:33:01 -0000 Subject: [llvm-commits] [llvm] r86346 - /llvm/trunk/include/llvm/System/TimeValue.h Message-ID: <200911070633.nA76X1WS023103@zion.cs.uiuc.edu> Author: foldr Date: Sat Nov 7 00:33:01 2009 New Revision: 86346 URL: http://llvm.org/viewvc/llvm-project?rev=86346&view=rev Log: 80-col violation. Modified: llvm/trunk/include/llvm/System/TimeValue.h Modified: llvm/trunk/include/llvm/System/TimeValue.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/TimeValue.h?rev=86346&r1=86345&r2=86346&view=diff ============================================================================== --- llvm/trunk/include/llvm/System/TimeValue.h (original) +++ llvm/trunk/include/llvm/System/TimeValue.h Sat Nov 7 00:33:01 2009 @@ -65,8 +65,8 @@ /// @name Types /// @{ public: - typedef int64_t SecondsType; ///< Type used for representing seconds. - typedef int32_t NanoSecondsType; ///< Type used for representing nanoseconds. + typedef int64_t SecondsType; ///< Type used for representing seconds. + typedef int32_t NanoSecondsType;///< Type used for representing nanoseconds. enum TimeConversions { NANOSECONDS_PER_SECOND = 1000000000, ///< One Billion From foldr at codedgers.com Sat Nov 7 00:33:12 2009 From: foldr at codedgers.com (Mikhail Glushenkov) Date: Sat, 07 Nov 2009 06:33:12 -0000 Subject: [llvm-commits] [llvm] r86347 - /llvm/trunk/lib/Support/Timer.cpp Message-ID: <200911070633.nA76XCHt023126@zion.cs.uiuc.edu> Author: foldr Date: Sat Nov 7 00:33:12 2009 New Revision: 86347 URL: http://llvm.org/viewvc/llvm-project?rev=86347&view=rev Log: Trailing whitespace. Modified: llvm/trunk/lib/Support/Timer.cpp Modified: llvm/trunk/lib/Support/Timer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Timer.cpp?rev=86347&r1=86346&r2=86347&view=diff ============================================================================== --- llvm/trunk/lib/Support/Timer.cpp (original) +++ llvm/trunk/lib/Support/Timer.cpp Sat Nov 7 00:33:12 2009 @@ -66,7 +66,7 @@ } llvm_release_global_lock(); } - + return tmp; } @@ -182,13 +182,13 @@ Lock.acquire(); T.Lock.acquire(); } - + Elapsed += T.Elapsed; UserTime += T.UserTime; SystemTime += T.SystemTime; MemUsed += T.MemUsed; PeakMem += T.PeakMem; - + if (&T < this) { T.Lock.release(); Lock.release(); @@ -287,7 +287,7 @@ Lock.acquire(); Total.Lock.acquire(); } - + if (Total.UserTime) printVal(UserTime, Total.UserTime, OS); if (Total.SystemTime) @@ -310,7 +310,7 @@ OS << Name << "\n"; Started = false; // Once printed, don't print again - + if (&Total < this) { Total.Lock.release(); Lock.release(); @@ -329,13 +329,13 @@ if (LibSupportInfoOutputFilename == "-") return &outs(); - + std::string Error; raw_ostream *Result = new raw_fd_ostream(LibSupportInfoOutputFilename.c_str(), Error, raw_fd_ostream::F_Append); if (Error.empty()) return Result; - + errs() << "Error opening info-output-file '" << LibSupportInfoOutputFilename << " for appending!\n"; delete Result; From foldr at codedgers.com Sat Nov 7 00:33:58 2009 From: foldr at codedgers.com (Mikhail Glushenkov) Date: Sat, 07 Nov 2009 06:33:58 -0000 Subject: [llvm-commits] [llvm] r86348 - in /llvm/trunk: include/llvm/CompilerDriver/BuiltinOptions.h lib/CompilerDriver/Action.cpp lib/CompilerDriver/BuiltinOptions.cpp lib/CompilerDriver/Main.cpp Message-ID: <200911070633.nA76XxuB023168@zion.cs.uiuc.edu> Author: foldr Date: Sat Nov 7 00:33:58 2009 New Revision: 86348 URL: http://llvm.org/viewvc/llvm-project?rev=86348&view=rev Log: llvmc: Add a '-time' option. Modified: llvm/trunk/include/llvm/CompilerDriver/BuiltinOptions.h llvm/trunk/lib/CompilerDriver/Action.cpp llvm/trunk/lib/CompilerDriver/BuiltinOptions.cpp llvm/trunk/lib/CompilerDriver/Main.cpp Modified: llvm/trunk/include/llvm/CompilerDriver/BuiltinOptions.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CompilerDriver/BuiltinOptions.h?rev=86348&r1=86347&r2=86348&view=diff ============================================================================== --- llvm/trunk/include/llvm/CompilerDriver/BuiltinOptions.h (original) +++ llvm/trunk/include/llvm/CompilerDriver/BuiltinOptions.h Sat Nov 7 00:33:58 2009 @@ -25,10 +25,11 @@ extern llvm::cl::opt TempDirname; extern llvm::cl::list Languages; extern llvm::cl::opt DryRun; +extern llvm::cl::opt Time; extern llvm::cl::opt VerboseMode; extern llvm::cl::opt CheckGraph; -extern llvm::cl::opt WriteGraph; extern llvm::cl::opt ViewGraph; +extern llvm::cl::opt WriteGraph; extern llvm::cl::opt SaveTemps; #endif // LLVM_INCLUDE_COMPILER_DRIVER_BUILTIN_OPTIONS_H Modified: llvm/trunk/lib/CompilerDriver/Action.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CompilerDriver/Action.cpp?rev=86348&r1=86347&r2=86348&view=diff ============================================================================== --- llvm/trunk/lib/CompilerDriver/Action.cpp (original) +++ llvm/trunk/lib/CompilerDriver/Action.cpp Sat Nov 7 00:33:58 2009 @@ -13,9 +13,13 @@ #include "llvm/CompilerDriver/Action.h" #include "llvm/CompilerDriver/BuiltinOptions.h" + #include "llvm/Support/raw_ostream.h" #include "llvm/System/Program.h" +#include "llvm/System/TimeValue.h" + #include +#include using namespace llvm; using namespace llvmc; @@ -60,14 +64,31 @@ } } +namespace llvmc { + void AppendToGlobalTimeLog(const std::string& cmd, double time); +} + int llvmc::Action::Execute() const { if (DryRun || VerboseMode) { errs() << Command_ << " "; std::for_each(Args_.begin(), Args_.end(), print_string); errs() << '\n'; } - if (DryRun) - return 0; - else - return ExecuteProgram(Command_, Args_); + if (!DryRun) { + if (Time) { + sys::TimeValue now = sys::TimeValue::now(); + int ret = ExecuteProgram(Command_, Args_); + sys::TimeValue now2 = sys::TimeValue::now(); + now2 -= now; + double elapsed = now2.seconds() + now2.microseconds() / 1000000.0; + AppendToGlobalTimeLog(Command_, elapsed); + + return ret; + } + else { + return ExecuteProgram(Command_, Args_); + } + } + + return 0; } Modified: llvm/trunk/lib/CompilerDriver/BuiltinOptions.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CompilerDriver/BuiltinOptions.cpp?rev=86348&r1=86347&r2=86348&view=diff ============================================================================== --- llvm/trunk/lib/CompilerDriver/BuiltinOptions.cpp (original) +++ llvm/trunk/lib/CompilerDriver/BuiltinOptions.cpp Sat Nov 7 00:33:58 2009 @@ -30,8 +30,10 @@ cl::list Languages("x", cl::desc("Specify the language of the following input files"), cl::ZeroOrMore); + cl::opt DryRun("dry-run", cl::desc("Only pretend to run commands")); +cl::opt Time("time", cl::desc("Time individual commands")); cl::opt VerboseMode("v", cl::desc("Enable verbose mode")); Modified: llvm/trunk/lib/CompilerDriver/Main.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CompilerDriver/Main.cpp?rev=86348&r1=86347&r2=86348&view=diff ============================================================================== --- llvm/trunk/lib/CompilerDriver/Main.cpp (original) +++ llvm/trunk/lib/CompilerDriver/Main.cpp Sat Nov 7 00:33:58 2009 @@ -19,6 +19,7 @@ #include "llvm/Support/raw_ostream.h" #include "llvm/System/Path.h" +#include #include #include @@ -28,6 +29,8 @@ namespace { + std::stringstream* GlobalTimeLog; + sys::Path getTempDir() { sys::Path tempDir; @@ -81,6 +84,11 @@ namespace llvmc { +// Used to implement -time option. External linkage is intentional. +void AppendToGlobalTimeLog(const std::string& cmd, double time) { + *GlobalTimeLog << "# " << cmd << ' ' << time << '\n'; +} + // Sometimes plugins want to condition on the value in argv[0]. const char* ProgramName; @@ -122,7 +130,19 @@ throw std::runtime_error("no input files"); } - return BuildTargets(graph, langMap); + if (Time) { + GlobalTimeLog = new std::stringstream; + GlobalTimeLog->precision(2); + } + + int ret = BuildTargets(graph, langMap); + + if (Time) { + llvm::errs() << GlobalTimeLog->str(); + delete GlobalTimeLog; + } + + return ret; } catch(llvmc::error_code& ec) { return ec.code(); From nicholas at mxc.ca Sat Nov 7 01:10:01 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Sat, 07 Nov 2009 07:10:01 -0000 Subject: [llvm-commits] [llvm] r86349 - in /llvm/trunk: lib/Transforms/Scalar/TailRecursionElimination.cpp test/Transforms/TailCallElim/nocapture.ll Message-ID: <200911070710.nA77A1QL024356@zion.cs.uiuc.edu> Author: nicholas Date: Sat Nov 7 01:10:01 2009 New Revision: 86349 URL: http://llvm.org/viewvc/llvm-project?rev=86349&view=rev Log: Dust off tail recursion elimination. Fix a fixme by applying CaptureTracking and add a .ll to demo the new capability. Added: llvm/trunk/test/Transforms/TailCallElim/nocapture.ll Modified: llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp Modified: llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp?rev=86349&r1=86348&r2=86349&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp Sat Nov 7 01:10:01 2009 @@ -25,7 +25,7 @@ // unlikely, that the return returns something else (like constant 0), and // can still be TRE'd. It can be TRE'd if ALL OTHER return instructions in // the function return the exact same value. -// 4. If it can prove that callees do not access theier caller stack frame, +// 4. If it can prove that callees do not access their caller stack frame, // they are marked as eligible for tail call elimination (by the code // generator). // @@ -58,6 +58,7 @@ #include "llvm/Function.h" #include "llvm/Instructions.h" #include "llvm/Pass.h" +#include "llvm/Analysis/CaptureTracking.h" #include "llvm/Support/CFG.h" #include "llvm/ADT/Statistic.h" using namespace llvm; @@ -75,7 +76,7 @@ private: bool ProcessReturningBlock(ReturnInst *RI, BasicBlock *&OldEntry, bool &TailCallsAreMarkedTail, - std::vector &ArgumentPHIs, + SmallVector &ArgumentPHIs, bool CannotTailCallElimCallsMarkedTail); bool CanMoveAboveCall(Instruction *I, CallInst *CI); Value *CanTransformAccumulatorRecursion(Instruction *I, CallInst *CI); @@ -90,17 +91,7 @@ return new TailCallElim(); } - -/// AllocaMightEscapeToCalls - Return true if this alloca may be accessed by -/// callees of this function. We only do very simple analysis right now, this -/// could be expanded in the future to use mod/ref information for particular -/// call sites if desired. -static bool AllocaMightEscapeToCalls(AllocaInst *AI) { - // FIXME: do simple 'address taken' analysis. - return true; -} - -/// FunctionContainsAllocas - Scan the specified basic block for alloca +/// CheckForEscapingAllocas - Scan the specified basic block for alloca /// instructions. If it contains any that might be accessed by calls, return /// true. static bool CheckForEscapingAllocas(BasicBlock *BB, @@ -108,7 +99,7 @@ bool RetVal = false; for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) if (AllocaInst *AI = dyn_cast(I)) { - RetVal |= AllocaMightEscapeToCalls(AI); + RetVal |= PointerMayBeCaptured(AI, true); // If this alloca is in the body of the function, or if it is a variable // sized allocation, we cannot tail call eliminate calls marked 'tail' @@ -127,7 +118,7 @@ BasicBlock *OldEntry = 0; bool TailCallsAreMarkedTail = false; - std::vector ArgumentPHIs; + SmallVector ArgumentPHIs; bool MadeChange = false; bool FunctionContainsEscapingAllocas = false; @@ -204,7 +195,7 @@ if (I->mayHaveSideEffects()) // This also handles volatile loads. return false; - if (LoadInst* L = dyn_cast(I)) { + if (LoadInst *L = dyn_cast(I)) { // Loads may always be moved above calls without side effects. if (CI->mayHaveSideEffects()) { // Non-volatile loads may be moved above a call with side effects if it @@ -265,10 +256,6 @@ Function *F = TheRI->getParent()->getParent(); Value *ReturnedValue = 0; - // TODO: Handle multiple value ret instructions; - if (isa(F->getReturnType())) - return 0; - for (Function::iterator BBI = F->begin(), E = F->end(); BBI != E; ++BBI) if (ReturnInst *RI = dyn_cast(BBI->getTerminator())) if (RI != TheRI) { @@ -315,7 +302,7 @@ bool TailCallElim::ProcessReturningBlock(ReturnInst *Ret, BasicBlock *&OldEntry, bool &TailCallsAreMarkedTail, - std::vector &ArgumentPHIs, + SmallVector &ArgumentPHIs, bool CannotTailCallElimCallsMarkedTail) { BasicBlock *BB = Ret->getParent(); Function *F = BB->getParent(); Added: llvm/trunk/test/Transforms/TailCallElim/nocapture.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/TailCallElim/nocapture.ll?rev=86349&view=auto ============================================================================== --- llvm/trunk/test/Transforms/TailCallElim/nocapture.ll (added) +++ llvm/trunk/test/Transforms/TailCallElim/nocapture.ll Sat Nov 7 01:10:01 2009 @@ -0,0 +1,24 @@ +; RUN: opt %s -tailcallelim -S | FileCheck %s + +declare void @use(i8* nocapture, i8* nocapture) + +define i8* @foo(i8* nocapture %A, i1 %cond) { +; CHECK: tailrecurse: +; CHECK: %A.tr = phi i8* [ %A, %0 ], [ %B, %cond_true ] +; CHECK: %cond.tr = phi i1 [ %cond, %0 ], [ false, %cond_true ] + %B = alloca i8 +; CHECK: %B = alloca i8 + br i1 %cond, label %cond_true, label %cond_false +; CHECK: br i1 %cond.tr, label %cond_true, label %cond_false +cond_true: +; CHECK: cond_true: +; CHECK: br label %tailrecurse + call i8* @foo(i8* %B, i1 false) + ret i8* null +cond_false: +; CHECK: cond_false + call void @use(i8* %A, i8* %B) +; CHECK: tail call void @use(i8* %A.tr, i8* %B) + ret i8* null +; CHECK: ret i8* null +} From nicholas at mxc.ca Sat Nov 7 01:42:38 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Sat, 07 Nov 2009 07:42:38 -0000 Subject: [llvm-commits] [llvm] r86353 - in /llvm/trunk: lib/Transforms/Scalar/TailRecursionElimination.cpp test/Transforms/TailCallElim/nocapture.ll Message-ID: <200911070742.nA77gcN9025457@zion.cs.uiuc.edu> Author: nicholas Date: Sat Nov 7 01:42:38 2009 New Revision: 86353 URL: http://llvm.org/viewvc/llvm-project?rev=86353&view=rev Log: Oops, FunctionContainsEscapingAllocas is really used to mean two different things. Back out part of r86349 for a moment. Modified: llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp llvm/trunk/test/Transforms/TailCallElim/nocapture.ll Modified: llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp?rev=86353&r1=86352&r2=86353&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp Sat Nov 7 01:42:38 2009 @@ -91,6 +91,15 @@ return new TailCallElim(); } +/// AllocaMightEscapeToCalls - Return true if this alloca may be accessed by +/// callees of this function. We only do very simple analysis right now, this +/// could be expanded in the future to use mod/ref information for particular +/// call sites if desired. +static bool AllocaMightEscapeToCalls(AllocaInst *AI) { + // FIXME: do simple 'address taken' analysis. + return true; +} + /// CheckForEscapingAllocas - Scan the specified basic block for alloca /// instructions. If it contains any that might be accessed by calls, return /// true. @@ -99,7 +108,7 @@ bool RetVal = false; for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) if (AllocaInst *AI = dyn_cast(I)) { - RetVal |= PointerMayBeCaptured(AI, true); + RetVal |= AllocaMightEscapeToCalls(AI); // If this alloca is in the body of the function, or if it is a variable // sized allocation, we cannot tail call eliminate calls marked 'tail' @@ -145,7 +154,6 @@ /// happen. This bug is PR962. if (FunctionContainsEscapingAllocas) return false; - // Second pass, change any tail calls to loops. for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) Modified: llvm/trunk/test/Transforms/TailCallElim/nocapture.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/TailCallElim/nocapture.ll?rev=86353&r1=86352&r2=86353&view=diff ============================================================================== --- llvm/trunk/test/Transforms/TailCallElim/nocapture.ll (original) +++ llvm/trunk/test/Transforms/TailCallElim/nocapture.ll Sat Nov 7 01:42:38 2009 @@ -1,4 +1,5 @@ ; RUN: opt %s -tailcallelim -S | FileCheck %s +; XFAIL: * declare void @use(i8* nocapture, i8* nocapture) From sabre at nondot.org Sat Nov 7 01:50:34 2009 From: sabre at nondot.org (Chris Lattner) Date: Sat, 07 Nov 2009 07:50:34 -0000 Subject: [llvm-commits] [llvm] r86354 - in /llvm/trunk: lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp lib/CodeGen/SelectionDAG/SelectionDAGBuild.h test/CodeGen/Generic/switch-lower.ll Message-ID: <200911070750.nA77oY61025698@zion.cs.uiuc.edu> Author: lattner Date: Sat Nov 7 01:50:34 2009 New Revision: 86354 URL: http://llvm.org/viewvc/llvm-project?rev=86354&view=rev Log: Fix PR5421 by APInt'izing switch lowering. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.h llvm/trunk/test/CodeGen/Generic/switch-lower.ll Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp?rev=86354&r1=86353&r2=86354&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Sat Nov 7 01:50:34 2009 @@ -1743,19 +1743,19 @@ Case& FrontCase = *CR.Range.first; Case& BackCase = *(CR.Range.second-1); - const APInt& First = cast(FrontCase.Low)->getValue(); - const APInt& Last = cast(BackCase.High)->getValue(); + const APInt &First = cast(FrontCase.Low)->getValue(); + const APInt &Last = cast(BackCase.High)->getValue(); - size_t TSize = 0; + APInt TSize(First.getBitWidth(), 0); for (CaseItr I = CR.Range.first, E = CR.Range.second; I!=E; ++I) TSize += I->size(); - if (!areJTsAllowed(TLI) || TSize <= 3) + if (!areJTsAllowed(TLI) || TSize.ult(APInt(First.getBitWidth(), 4))) return false; APInt Range = ComputeRange(First, Last); - double Density = (double)TSize / Range.roundToDouble(); + double Density = TSize.roundToDouble() / Range.roundToDouble(); if (Density < 0.4) return false; @@ -1849,32 +1849,34 @@ // Size is the number of Cases represented by this range. unsigned Size = CR.Range.second - CR.Range.first; - const APInt& First = cast(FrontCase.Low)->getValue(); - const APInt& Last = cast(BackCase.High)->getValue(); + const APInt &First = cast(FrontCase.Low)->getValue(); + const APInt &Last = cast(BackCase.High)->getValue(); double FMetric = 0; CaseItr Pivot = CR.Range.first + Size/2; // Select optimal pivot, maximizing sum density of LHS and RHS. This will // (heuristically) allow us to emit JumpTable's later. - size_t TSize = 0; + APInt TSize(First.getBitWidth(), 0); for (CaseItr I = CR.Range.first, E = CR.Range.second; I!=E; ++I) TSize += I->size(); - size_t LSize = FrontCase.size(); - size_t RSize = TSize-LSize; + APInt LSize = FrontCase.size(); + APInt RSize = TSize-LSize; DEBUG(errs() << "Selecting best pivot: \n" << "First: " << First << ", Last: " << Last <<'\n' << "LSize: " << LSize << ", RSize: " << RSize << '\n'); for (CaseItr I = CR.Range.first, J=I+1, E = CR.Range.second; J!=E; ++I, ++J) { - const APInt& LEnd = cast(I->High)->getValue(); - const APInt& RBegin = cast(J->Low)->getValue(); + const APInt &LEnd = cast(I->High)->getValue(); + const APInt &RBegin = cast(J->Low)->getValue(); APInt Range = ComputeRange(LEnd, RBegin); assert((Range - 2ULL).isNonNegative() && "Invalid case distance"); - double LDensity = (double)LSize / (LEnd - First + 1ULL).roundToDouble(); - double RDensity = (double)RSize / (Last - RBegin + 1ULL).roundToDouble(); + double LDensity = (double)LSize.roundToDouble() / + (LEnd - First + 1ULL).roundToDouble(); + double RDensity = (double)RSize.roundToDouble() / + (Last - RBegin + 1ULL).roundToDouble(); double Metric = Range.logBase2()*(LDensity+RDensity); // Should always split in some non-trivial place DEBUG(errs() <<"=>Step\n" Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.h?rev=86354&r1=86353&r2=86354&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.h (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.h Sat Nov 7 01:50:34 2009 @@ -193,9 +193,9 @@ Case() : Low(0), High(0), BB(0) { } Case(Constant* low, Constant* high, MachineBasicBlock* bb) : Low(low), High(high), BB(bb) { } - uint64_t size() const { - uint64_t rHigh = cast(High)->getSExtValue(); - uint64_t rLow = cast(Low)->getSExtValue(); + APInt size() const { + const APInt &rHigh = cast(High)->getValue(); + const APInt &rLow = cast(Low)->getValue(); return (rHigh - rLow + 1ULL); } }; Modified: llvm/trunk/test/CodeGen/Generic/switch-lower.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Generic/switch-lower.ll?rev=86354&r1=86353&r2=86354&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Generic/switch-lower.ll (original) +++ llvm/trunk/test/CodeGen/Generic/switch-lower.ll Sat Nov 7 01:50:34 2009 @@ -1,8 +1,22 @@ ; RUN: llc < %s -; PR1197 -define void @exp_attr__expand_n_attribute_reference() { +; PR5421 +define void @test1() { +entry: + switch i128 undef, label %exit [ + i128 55340232221128654848, label %exit + i128 92233720368547758080, label %exit + i128 73786976294838206464, label %exit + i128 147573952589676412928, label %exit + ] +exit: + unreachable +} + + +; PR1197 +define void @test2() { entry: br i1 false, label %cond_next954, label %cond_true924 From evan.cheng at apple.com Sat Nov 7 01:57:21 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 6 Nov 2009 23:57:21 -0800 Subject: [llvm-commits] [PATCH] Make the need-stub variables accurate and consistent In-Reply-To: <0016e640d40e1290880477c141c0@google.com> References: <0016e640d40e1290880477c141c0@google.com> Message-ID: On Nov 6, 2009, at 9:30 PM, jyasskin at gmail.com wrote: > Reviewers: , > > Message: > Please take a look. > > I'd like to find an example of a global-variable far stub to put in > the > comment for MachineRelocation::mayNeedFarStub(). Can anyone describe > the > requirement for ARM or another platform so I can copy it in? > > Description: > I'm trying to tease apart the different uses for "stubs" in the JIT. > In > the case of MachineRelocations, I believe "stub" always refers to a > far-call stub or a load-a-faraway-global stub, so this patch adds > "Far" Yes, "stub" is a overloaded term. Both the ARM and X86 code emitters assume function GVs require a stub. However, they are not always due to far address though. It could be due to lazy resolution or in the dlsym mode, it's expected the addresses of globals are supplied by the client. > to the term. The variable was also inconsistent between the positive > and > negative sense, and the positive sense ("NeedStub") was more demanding > than is accurate (since a nearby-enough function can be called > directly > even if the platform often requires a stub). Since the negative sense > causes double-negatives, I switched to "MayNeedFarStub" globally. This part sounds nice. Evan > > Please review this at http://codereview.appspot.com/151051 > > Affected files: > M include/llvm/CodeGen/MachineRelocation.h > M lib/ExecutionEngine/JIT/JITEmitter.cpp > M lib/Target/ARM/ARMCodeEmitter.cpp > M lib/Target/X86/X86CodeEmitter.cpp > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From arplynn at gmail.com Sat Nov 7 01:52:19 2009 From: arplynn at gmail.com (Alastair Lynn) Date: Sat, 7 Nov 2009 07:52:19 +0000 Subject: [llvm-commits] Patch: simplification of overflow operations Message-ID: Hello- The attached patch will simplify cases where overflow intrinsics are used but the overflow bit is not to the equivalent basic instructions (llvm.uadd.with.overflow => add, for instance). This is my first patch, please don't judge me too harshly! Alastair -------------- next part -------------- A non-text attachment was scrubbed... Name: overflow-removal.patch Type: application/octet-stream Size: 2407 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091107/f5f6815e/attachment.obj -------------- next part -------------- A non-text attachment was scrubbed... Name: overflow-removal.patch.raw Type: image/raw Size: 2407 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091107/f5f6815e/attachment.bin From sabre at nondot.org Sat Nov 7 02:05:03 2009 From: sabre at nondot.org (Chris Lattner) Date: Sat, 07 Nov 2009 08:05:03 -0000 Subject: [llvm-commits] [llvm] r86355 - in /llvm/trunk: lib/Transforms/Scalar/JumpThreading.cpp test/Transforms/JumpThreading/basic.ll test/Transforms/JumpThreading/crash.ll Message-ID: <200911070805.nA7853CW026135@zion.cs.uiuc.edu> Author: lattner Date: Sat Nov 7 02:05:03 2009 New Revision: 86355 URL: http://llvm.org/viewvc/llvm-project?rev=86355&view=rev Log: reapply 86289, 86278, 86270, 86267, 86266 & 86264 plus a fix (making pred factoring only happen if threading is guaranteed to be successful). This now survives an X86-64 bootstrap of llvm-gcc. Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp llvm/trunk/test/Transforms/JumpThreading/basic.ll llvm/trunk/test/Transforms/JumpThreading/crash.ll Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=86355&r1=86354&r2=86355&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Sat Nov 7 02:05:03 2009 @@ -72,17 +72,23 @@ void FindLoopHeaders(Function &F); bool ProcessBlock(BasicBlock *BB); - bool ThreadEdge(BasicBlock *BB, BasicBlock *PredBB, BasicBlock *SuccBB); + bool ThreadEdge(BasicBlock *BB, const SmallVectorImpl &PredBBs, + BasicBlock *SuccBB); bool DuplicateCondBranchOnPHIIntoPred(BasicBlock *BB, BasicBlock *PredBB); - - BasicBlock *FactorCommonPHIPreds(PHINode *PN, Value *Val); + + typedef SmallVectorImpl > PredValueInfo; + + bool ComputeValueKnownInPredecessors(Value *V, BasicBlock *BB, + PredValueInfo &Result); + bool ProcessThreadableEdges(Instruction *CondInst, BasicBlock *BB); + + bool ProcessBranchOnDuplicateCond(BasicBlock *PredBB, BasicBlock *DestBB); bool ProcessSwitchOnDuplicateCond(BasicBlock *PredBB, BasicBlock *DestBB); bool ProcessJumpOnPHI(PHINode *PN); - bool ProcessBranchOnLogical(Value *V, BasicBlock *BB, bool isAnd); - bool ProcessBranchOnCompare(CmpInst *Cmp, BasicBlock *BB); bool SimplifyPartiallyRedundantLoad(LoadInst *LI); }; @@ -198,28 +204,133 @@ LoopHeaders.insert(const_cast(Edges[i].second)); } -/// FactorCommonPHIPreds - If there are multiple preds with the same incoming -/// value for the PHI, factor them together so we get one block to thread for -/// the whole group. -/// This is important for things like "phi i1 [true, true, false, true, x]" -/// where we only need to clone the block for the true blocks once. -/// -BasicBlock *JumpThreading::FactorCommonPHIPreds(PHINode *PN, Value *Val) { - SmallVector CommonPreds; - for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) - if (PN->getIncomingValue(i) == Val) - CommonPreds.push_back(PN->getIncomingBlock(i)); - - if (CommonPreds.size() == 1) - return CommonPreds[0]; - - DEBUG(errs() << " Factoring out " << CommonPreds.size() - << " common predecessors.\n"); - return SplitBlockPredecessors(PN->getParent(), - &CommonPreds[0], CommonPreds.size(), - ".thr_comm", this); +/// GetResultOfComparison - Given an icmp/fcmp predicate and the left and right +/// hand sides of the compare instruction, try to determine the result. If the +/// result can not be determined, a null pointer is returned. +static Constant *GetResultOfComparison(CmpInst::Predicate pred, + Value *LHS, Value *RHS) { + if (Constant *CLHS = dyn_cast(LHS)) + if (Constant *CRHS = dyn_cast(RHS)) + return ConstantExpr::getCompare(pred, CLHS, CRHS); + + if (LHS == RHS) + if (isa(LHS->getType()) || isa(LHS->getType())) { + if (ICmpInst::isTrueWhenEqual(pred)) + return ConstantInt::getTrue(LHS->getContext()); + else + return ConstantInt::getFalse(LHS->getContext()); + } + return 0; } + + +/// ComputeValueKnownInPredecessors - Given a basic block BB and a value V, see +/// if we can infer that the value is a known ConstantInt in any of our +/// predecessors. If so, return the known the list of value and pred BB in the +/// result vector. If a value is known to be undef, it is returned as null. +/// +/// The BB basic block is known to start with a PHI node. +/// +/// This returns true if there were any known values. +/// +/// +/// TODO: Per PR2563, we could infer value range information about a predecessor +/// based on its terminator. +bool JumpThreading:: +ComputeValueKnownInPredecessors(Value *V, BasicBlock *BB,PredValueInfo &Result){ + PHINode *TheFirstPHI = cast(BB->begin()); + + // If V is a constantint, then it is known in all predecessors. + if (isa(V) || isa(V)) { + ConstantInt *CI = dyn_cast(V); + Result.resize(TheFirstPHI->getNumIncomingValues()); + for (unsigned i = 0, e = Result.size(); i != e; ++i) + Result[i] = std::make_pair(CI, TheFirstPHI->getIncomingBlock(i)); + return true; + } + + // If V is a non-instruction value, or an instruction in a different block, + // then it can't be derived from a PHI. + Instruction *I = dyn_cast(V); + if (I == 0 || I->getParent() != BB) + return false; + + /// If I is a PHI node, then we know the incoming values for any constants. + if (PHINode *PN = dyn_cast(I)) { + for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) { + Value *InVal = PN->getIncomingValue(i); + if (isa(InVal) || isa(InVal)) { + ConstantInt *CI = dyn_cast(InVal); + Result.push_back(std::make_pair(CI, PN->getIncomingBlock(i))); + } + } + return !Result.empty(); + } + SmallVector, 8> LHSVals, RHSVals; + + // Handle some boolean conditions. + if (I->getType()->getPrimitiveSizeInBits() == 1) { + // X | true -> true + // X & false -> false + if (I->getOpcode() == Instruction::Or || + I->getOpcode() == Instruction::And) { + ComputeValueKnownInPredecessors(I->getOperand(0), BB, LHSVals); + ComputeValueKnownInPredecessors(I->getOperand(1), BB, RHSVals); + + if (LHSVals.empty() && RHSVals.empty()) + return false; + + ConstantInt *InterestingVal; + if (I->getOpcode() == Instruction::Or) + InterestingVal = ConstantInt::getTrue(I->getContext()); + else + InterestingVal = ConstantInt::getFalse(I->getContext()); + + // Scan for the sentinel. + for (unsigned i = 0, e = LHSVals.size(); i != e; ++i) + if (LHSVals[i].first == InterestingVal || LHSVals[i].first == 0) + Result.push_back(LHSVals[i]); + for (unsigned i = 0, e = RHSVals.size(); i != e; ++i) + if (RHSVals[i].first == InterestingVal || RHSVals[i].first == 0) + Result.push_back(RHSVals[i]); + return !Result.empty(); + } + + // TODO: Should handle the NOT form of XOR. + + } + + // Handle compare with phi operand, where the PHI is defined in this block. + if (CmpInst *Cmp = dyn_cast(I)) { + PHINode *PN = dyn_cast(Cmp->getOperand(0)); + if (PN && PN->getParent() == BB) { + // We can do this simplification if any comparisons fold to true or false. + // See if any do. + for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) { + BasicBlock *PredBB = PN->getIncomingBlock(i); + Value *LHS = PN->getIncomingValue(i); + Value *RHS = Cmp->getOperand(1)->DoPHITranslation(BB, PredBB); + + Constant *Res = GetResultOfComparison(Cmp->getPredicate(), LHS, RHS); + if (Res == 0) continue; + + if (isa(Res)) + Result.push_back(std::make_pair((ConstantInt*)0, PredBB)); + else if (ConstantInt *CI = dyn_cast(Res)) + Result.push_back(std::make_pair(CI, PredBB)); + } + + return !Result.empty(); + } + + // TODO: We could also recurse to see if we can determine constants another + // way. + } + return false; +} + + /// GetBestDestForBranchOnUndef - If we determine that the specified block ends /// in an undefined jump, decide which block is best to revector to. @@ -250,7 +361,7 @@ // successor, merge the blocks. This encourages recursive jump threading // because now the condition in this block can be threaded through // predecessors of our predecessor block. - if (BasicBlock *SinglePred = BB->getSinglePredecessor()) + if (BasicBlock *SinglePred = BB->getSinglePredecessor()) { if (SinglePred->getTerminator()->getNumSuccessors() == 1 && SinglePred != BB) { // If SinglePred was a loop header, BB becomes one. @@ -266,10 +377,10 @@ BB->moveBefore(&BB->getParent()->getEntryBlock()); return true; } - - // See if this block ends with a branch or switch. If so, see if the - // condition is a phi node. If so, and if an entry of the phi node is a - // constant, we can thread the block. + } + + // Look to see if the terminator is a branch of switch, if not we can't thread + // it. Value *Condition; if (BranchInst *BI = dyn_cast(BB->getTerminator())) { // Can't thread an unconditional jump. @@ -345,44 +456,26 @@ if (PN->getParent() == BB) return ProcessJumpOnPHI(PN); - // If this is a conditional branch whose condition is and/or of a phi, try to - // simplify it. - if ((CondInst->getOpcode() == Instruction::And || - CondInst->getOpcode() == Instruction::Or) && - isa(BB->getTerminator()) && - ProcessBranchOnLogical(CondInst, BB, - CondInst->getOpcode() == Instruction::And)) - return true; - if (CmpInst *CondCmp = dyn_cast(CondInst)) { - if (isa(CondCmp->getOperand(0))) { - // If we have "br (phi != 42)" and the phi node has any constant values - // as operands, we can thread through this block. - // - // If we have "br (cmp phi, x)" and the phi node contains x such that the - // comparison uniquely identifies the branch target, we can thread - // through this block. - - if (ProcessBranchOnCompare(CondCmp, BB)) - return true; - } - - // If we have a comparison, loop over the predecessors to see if there is - // a condition with the same value. - pred_iterator PI = pred_begin(BB), E = pred_end(BB); - for (; PI != E; ++PI) - if (BranchInst *PBI = dyn_cast((*PI)->getTerminator())) - if (PBI->isConditional() && *PI != BB) { - if (CmpInst *CI = dyn_cast(PBI->getCondition())) { - if (CI->getOperand(0) == CondCmp->getOperand(0) && - CI->getOperand(1) == CondCmp->getOperand(1) && - CI->getPredicate() == CondCmp->getPredicate()) { - // TODO: Could handle things like (x != 4) --> (x == 17) - if (ProcessBranchOnDuplicateCond(*PI, BB)) - return true; + if (!isa(CondCmp->getOperand(0)) || + cast(CondCmp->getOperand(0))->getParent() != BB) { + // If we have a comparison, loop over the predecessors to see if there is + // a condition with a lexically identical value. + pred_iterator PI = pred_begin(BB), E = pred_end(BB); + for (; PI != E; ++PI) + if (BranchInst *PBI = dyn_cast((*PI)->getTerminator())) + if (PBI->isConditional() && *PI != BB) { + if (CmpInst *CI = dyn_cast(PBI->getCondition())) { + if (CI->getOperand(0) == CondCmp->getOperand(0) && + CI->getOperand(1) == CondCmp->getOperand(1) && + CI->getPredicate() == CondCmp->getPredicate()) { + // TODO: Could handle things like (x != 4) --> (x == 17) + if (ProcessBranchOnDuplicateCond(*PI, BB)) + return true; + } } } - } + } } // Check for some cases that are worth simplifying. Right now we want to look @@ -401,6 +494,19 @@ if (SimplifyPartiallyRedundantLoad(LI)) return true; + + // Handle a variety of cases where we are branching on something derived from + // a PHI node in the current block. If we can prove that any predecessors + // compute a predictable value based on a PHI node, thread those predecessors. + // + // We only bother doing this if the current block has a PHI node and if the + // conditional instruction lives in the current block. If either condition + // fail, this won't be a computable value anyway. + if (CondInst->getParent() == BB && isa(BB->front())) + if (ProcessThreadableEdges(CondInst, BB)) + return true; + + // TODO: If we have: "br (X > 0)" and we have a predecessor where we know // "(X == 4)" thread through this block. @@ -458,8 +564,11 @@ // Next, figure out which successor we are threading to. BasicBlock *SuccBB = DestBI->getSuccessor(!BranchDir); + SmallVector Preds; + Preds.push_back(PredBB); + // Ok, try to thread it! - return ThreadEdge(BB, PredBB, SuccBB); + return ThreadEdge(BB, Preds, SuccBB); } /// ProcessSwitchOnDuplicateCond - We found a block and a predecessor of that @@ -689,55 +798,186 @@ return true; } +/// FindMostPopularDest - The specified list contains multiple possible +/// threadable destinations. Pick the one that occurs the most frequently in +/// the list. +static BasicBlock * +FindMostPopularDest(BasicBlock *BB, + const SmallVectorImpl > &PredToDestList) { + assert(!PredToDestList.empty()); + + // Determine popularity. If there are multiple possible destinations, we + // explicitly choose to ignore 'undef' destinations. We prefer to thread + // blocks with known and real destinations to threading undef. We'll handle + // them later if interesting. + DenseMap DestPopularity; + for (unsigned i = 0, e = PredToDestList.size(); i != e; ++i) + if (PredToDestList[i].second) + DestPopularity[PredToDestList[i].second]++; + + // Find the most popular dest. + DenseMap::iterator DPI = DestPopularity.begin(); + BasicBlock *MostPopularDest = DPI->first; + unsigned Popularity = DPI->second; + SmallVector SamePopularity; + + for (++DPI; DPI != DestPopularity.end(); ++DPI) { + // If the popularity of this entry isn't higher than the popularity we've + // seen so far, ignore it. + if (DPI->second < Popularity) + ; // ignore. + else if (DPI->second == Popularity) { + // If it is the same as what we've seen so far, keep track of it. + SamePopularity.push_back(DPI->first); + } else { + // If it is more popular, remember it. + SamePopularity.clear(); + MostPopularDest = DPI->first; + Popularity = DPI->second; + } + } + + // Okay, now we know the most popular destination. If there is more than + // destination, we need to determine one. This is arbitrary, but we need + // to make a deterministic decision. Pick the first one that appears in the + // successor list. + if (!SamePopularity.empty()) { + SamePopularity.push_back(MostPopularDest); + TerminatorInst *TI = BB->getTerminator(); + for (unsigned i = 0; ; ++i) { + assert(i != TI->getNumSuccessors() && "Didn't find any successor!"); + + if (std::find(SamePopularity.begin(), SamePopularity.end(), + TI->getSuccessor(i)) == SamePopularity.end()) + continue; + + MostPopularDest = TI->getSuccessor(i); + break; + } + } + + // Okay, we have finally picked the most popular destination. + return MostPopularDest; +} -/// ProcessJumpOnPHI - We have a conditional branch or switch on a PHI node in -/// the current block. See if there are any simplifications we can do based on -/// inputs to the phi node. -/// -bool JumpThreading::ProcessJumpOnPHI(PHINode *PN) { - BasicBlock *BB = PN->getParent(); +bool JumpThreading::ProcessThreadableEdges(Instruction *CondInst, + BasicBlock *BB) { + // If threading this would thread across a loop header, don't even try to + // thread the edge. + if (LoopHeaders.count(BB)) + return false; - // See if the phi node has any constant integer or undef values. If so, we - // can determine where the corresponding predecessor will branch. - for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) { - Value *PredVal = PN->getIncomingValue(i); + + + SmallVector, 8> PredValues; + if (!ComputeValueKnownInPredecessors(CondInst, BB, PredValues)) + return false; + assert(!PredValues.empty() && + "ComputeValueKnownInPredecessors returned true with no values"); + + DEBUG(errs() << "IN BB: " << *BB; + for (unsigned i = 0, e = PredValues.size(); i != e; ++i) { + errs() << " BB '" << BB->getName() << "': FOUND condition = "; + if (PredValues[i].first) + errs() << *PredValues[i].first; + else + errs() << "UNDEF"; + errs() << " for pred '" << PredValues[i].second->getName() + << "'.\n"; + }); + + // Decide what we want to thread through. Convert our list of known values to + // a list of known destinations for each pred. This also discards duplicate + // predecessors and keeps track of the undefined inputs (which are represented + // as a null dest in the PredToDestList. + SmallPtrSet SeenPreds; + SmallVector, 16> PredToDestList; + + BasicBlock *OnlyDest = 0; + BasicBlock *MultipleDestSentinel = (BasicBlock*)(intptr_t)~0ULL; + + for (unsigned i = 0, e = PredValues.size(); i != e; ++i) { + BasicBlock *Pred = PredValues[i].second; + if (!SeenPreds.insert(Pred)) + continue; // Duplicate predecessor entry. + + // If the predecessor ends with an indirect goto, we can't change its + // destination. + if (isa(Pred->getTerminator())) + continue; - // Check to see if this input is a constant integer. If so, the direction - // of the branch is predictable. - if (ConstantInt *CI = dyn_cast(PredVal)) { - // Merge any common predecessors that will act the same. - BasicBlock *PredBB = FactorCommonPHIPreds(PN, CI); - - BasicBlock *SuccBB; - if (BranchInst *BI = dyn_cast(BB->getTerminator())) - SuccBB = BI->getSuccessor(CI->isZero()); - else { - SwitchInst *SI = cast(BB->getTerminator()); - SuccBB = SI->getSuccessor(SI->findCaseValue(CI)); - } - - // Ok, try to thread it! - return ThreadEdge(BB, PredBB, SuccBB); + ConstantInt *Val = PredValues[i].first; + + BasicBlock *DestBB; + if (Val == 0) // Undef. + DestBB = 0; + else if (BranchInst *BI = dyn_cast(BB->getTerminator())) + DestBB = BI->getSuccessor(Val->isZero()); + else { + SwitchInst *SI = cast(BB->getTerminator()); + DestBB = SI->getSuccessor(SI->findCaseValue(Val)); } + + // If we have exactly one destination, remember it for efficiency below. + if (i == 0) + OnlyDest = DestBB; + else if (OnlyDest != DestBB) + OnlyDest = MultipleDestSentinel; - // If the input is an undef, then it doesn't matter which way it will go. - // Pick an arbitrary dest and thread the edge. - if (UndefValue *UV = dyn_cast(PredVal)) { - // Merge any common predecessors that will act the same. - BasicBlock *PredBB = FactorCommonPHIPreds(PN, UV); - BasicBlock *SuccBB = - BB->getTerminator()->getSuccessor(GetBestDestForJumpOnUndef(BB)); + PredToDestList.push_back(std::make_pair(Pred, DestBB)); + } + + // If all edges were unthreadable, we fail. + if (PredToDestList.empty()) + return false; + + // Determine which is the most common successor. If we have many inputs and + // this block is a switch, we want to start by threading the batch that goes + // to the most popular destination first. If we only know about one + // threadable destination (the common case) we can avoid this. + BasicBlock *MostPopularDest = OnlyDest; + + if (MostPopularDest == MultipleDestSentinel) + MostPopularDest = FindMostPopularDest(BB, PredToDestList); + + // Now that we know what the most popular destination is, factor all + // predecessors that will jump to it into a single predecessor. + SmallVector PredsToFactor; + for (unsigned i = 0, e = PredToDestList.size(); i != e; ++i) + if (PredToDestList[i].second == MostPopularDest) { + BasicBlock *Pred = PredToDestList[i].first; - // Ok, try to thread it! - return ThreadEdge(BB, PredBB, SuccBB); + // This predecessor may be a switch or something else that has multiple + // edges to the block. Factor each of these edges by listing them + // according to # occurrences in PredsToFactor. + TerminatorInst *PredTI = Pred->getTerminator(); + for (unsigned i = 0, e = PredTI->getNumSuccessors(); i != e; ++i) + if (PredTI->getSuccessor(i) == BB) + PredsToFactor.push_back(Pred); } - } + + // If the threadable edges are branching on an undefined value, we get to pick + // the destination that these predecessors should get to. + if (MostPopularDest == 0) + MostPopularDest = BB->getTerminator()-> + getSuccessor(GetBestDestForJumpOnUndef(BB)); + + // Ok, try to thread it! + return ThreadEdge(BB, PredsToFactor, MostPopularDest); +} + +/// ProcessJumpOnPHI - We have a conditional branch or switch on a PHI node in +/// the current block. See if there are any simplifications we can do based on +/// inputs to the phi node. +/// +bool JumpThreading::ProcessJumpOnPHI(PHINode *PN) { + BasicBlock *BB = PN->getParent(); - // If the incoming values are all variables, we don't know the destination of - // any predecessors. However, if any of the predecessor blocks end in an - // unconditional branch, we can *duplicate* the jump into that block in order - // to further encourage jump threading and to eliminate cases where we have - // branch on a phi of an icmp (branch on icmp is much better). + // If any of the predecessor blocks end in an unconditional branch, we can + // *duplicate* the jump into that block in order to further encourage jump + // threading and to eliminate cases where we have branch on a phi of an icmp + // (branch on icmp is much better). // We don't want to do this tranformation for switches, because we don't // really want to duplicate a switch. @@ -758,137 +998,6 @@ } -/// ProcessJumpOnLogicalPHI - PN's basic block contains a conditional branch -/// whose condition is an AND/OR where one side is PN. If PN has constant -/// operands that permit us to evaluate the condition for some operand, thread -/// through the block. For example with: -/// br (and X, phi(Y, Z, false)) -/// the predecessor corresponding to the 'false' will always jump to the false -/// destination of the branch. -/// -bool JumpThreading::ProcessBranchOnLogical(Value *V, BasicBlock *BB, - bool isAnd) { - // If this is a binary operator tree of the same AND/OR opcode, check the - // LHS/RHS. - if (BinaryOperator *BO = dyn_cast(V)) - if ((isAnd && BO->getOpcode() == Instruction::And) || - (!isAnd && BO->getOpcode() == Instruction::Or)) { - if (ProcessBranchOnLogical(BO->getOperand(0), BB, isAnd)) - return true; - if (ProcessBranchOnLogical(BO->getOperand(1), BB, isAnd)) - return true; - } - - // If this isn't a PHI node, we can't handle it. - PHINode *PN = dyn_cast(V); - if (!PN || PN->getParent() != BB) return false; - - // We can only do the simplification for phi nodes of 'false' with AND or - // 'true' with OR. See if we have any entries in the phi for this. - unsigned PredNo = ~0U; - ConstantInt *PredCst = ConstantInt::get(Type::getInt1Ty(BB->getContext()), - !isAnd); - for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) { - if (PN->getIncomingValue(i) == PredCst) { - PredNo = i; - break; - } - } - - // If no match, bail out. - if (PredNo == ~0U) - return false; - - // If so, we can actually do this threading. Merge any common predecessors - // that will act the same. - BasicBlock *PredBB = FactorCommonPHIPreds(PN, PredCst); - - // Next, figure out which successor we are threading to. If this was an AND, - // the constant must be FALSE, and we must be targeting the 'false' block. - // If this is an OR, the constant must be TRUE, and we must be targeting the - // 'true' block. - BasicBlock *SuccBB = BB->getTerminator()->getSuccessor(isAnd); - - // Ok, try to thread it! - return ThreadEdge(BB, PredBB, SuccBB); -} - -/// GetResultOfComparison - Given an icmp/fcmp predicate and the left and right -/// hand sides of the compare instruction, try to determine the result. If the -/// result can not be determined, a null pointer is returned. -static Constant *GetResultOfComparison(CmpInst::Predicate pred, - Value *LHS, Value *RHS, - LLVMContext &Context) { - if (Constant *CLHS = dyn_cast(LHS)) - if (Constant *CRHS = dyn_cast(RHS)) - return ConstantExpr::getCompare(pred, CLHS, CRHS); - - if (LHS == RHS) - if (isa(LHS->getType()) || isa(LHS->getType())) - return ICmpInst::isTrueWhenEqual(pred) ? - ConstantInt::getTrue(Context) : ConstantInt::getFalse(Context); - - return 0; -} - -/// ProcessBranchOnCompare - We found a branch on a comparison between a phi -/// node and a value. If we can identify when the comparison is true between -/// the phi inputs and the value, we can fold the compare for that edge and -/// thread through it. -bool JumpThreading::ProcessBranchOnCompare(CmpInst *Cmp, BasicBlock *BB) { - PHINode *PN = cast(Cmp->getOperand(0)); - Value *RHS = Cmp->getOperand(1); - - // If the phi isn't in the current block, an incoming edge to this block - // doesn't control the destination. - if (PN->getParent() != BB) - return false; - - // We can do this simplification if any comparisons fold to true or false. - // See if any do. - Value *PredVal = 0; - bool TrueDirection = false; - for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) { - PredVal = PN->getIncomingValue(i); - - Constant *Res = GetResultOfComparison(Cmp->getPredicate(), PredVal, - RHS, Cmp->getContext()); - if (!Res) { - PredVal = 0; - continue; - } - - // If this folded to a constant expr, we can't do anything. - if (ConstantInt *ResC = dyn_cast(Res)) { - TrueDirection = ResC->getZExtValue(); - break; - } - // If this folded to undef, just go the false way. - if (isa(Res)) { - TrueDirection = false; - break; - } - - // Otherwise, we can't fold this input. - PredVal = 0; - } - - // If no match, bail out. - if (PredVal == 0) - return false; - - // If so, we can actually do this threading. Merge any common predecessors - // that will act the same. - BasicBlock *PredBB = FactorCommonPHIPreds(PN, PredVal); - - // Next, get our successor. - BasicBlock *SuccBB = BB->getTerminator()->getSuccessor(!TrueDirection); - - // Ok, try to thread it! - return ThreadEdge(BB, PredBB, SuccBB); -} - - /// AddPHINodeEntriesForMappedBlock - We're adding 'NewPred' as a new /// predecessor to the PHIBB block. If it has PHI nodes, add entries for /// NewPred using the entries from OldPred (suitably mapped). @@ -913,10 +1022,11 @@ } } -/// ThreadEdge - We have decided that it is safe and profitable to thread an -/// edge from PredBB to SuccBB across BB. Transform the IR to reflect this -/// change. -bool JumpThreading::ThreadEdge(BasicBlock *BB, BasicBlock *PredBB, +/// ThreadEdge - We have decided that it is safe and profitable to factor the +/// blocks in PredBBs to one predecessor, then thread an edge from it to SuccBB +/// across BB. Transform the IR to reflect this change. +bool JumpThreading::ThreadEdge(BasicBlock *BB, + const SmallVectorImpl &PredBBs, BasicBlock *SuccBB) { // If threading to the same block as we come from, we would infinite loop. if (SuccBB == BB) { @@ -928,8 +1038,7 @@ // If threading this would thread across a loop header, don't thread the edge. // See the comments above FindLoopHeaders for justifications and caveats. if (LoopHeaders.count(BB)) { - DEBUG(errs() << " Not threading from '" << PredBB->getName() - << "' across loop header BB '" << BB->getName() + DEBUG(errs() << " Not threading across loop header BB '" << BB->getName() << "' to dest BB '" << SuccBB->getName() << "' - it might create an irreducible loop!\n"); return false; @@ -942,6 +1051,17 @@ return false; } + // And finally, do it! Start by factoring the predecessors is needed. + BasicBlock *PredBB; + if (PredBBs.size() == 1) + PredBB = PredBBs[0]; + else { + DEBUG(errs() << " Factoring out " << PredBBs.size() + << " common predecessors.\n"); + PredBB = SplitBlockPredecessors(BB, &PredBBs[0], PredBBs.size(), + ".thr_comm", this); + } + // And finally, do it! DEBUG(errs() << " Threading edge from '" << PredBB->getName() << "' to '" << SuccBB->getName() << "' with cost: " << JumpThreadCost Modified: llvm/trunk/test/Transforms/JumpThreading/basic.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/JumpThreading/basic.ll?rev=86355&r1=86354&r2=86355&view=diff ============================================================================== --- llvm/trunk/test/Transforms/JumpThreading/basic.ll (original) +++ llvm/trunk/test/Transforms/JumpThreading/basic.ll Sat Nov 7 02:05:03 2009 @@ -170,5 +170,36 @@ } +;; This tests that the branch in 'merge' can be cloned up into T1. +;; rdar://7367025 +define i32 @test7(i1 %cond, i1 %cond2) { +Entry: +; CHECK: @test7 + %v1 = call i32 @f1() + br i1 %cond, label %Merge, label %F1 +F1: + %v2 = call i32 @f2() + br label %Merge + +Merge: + %B = phi i32 [%v1, %Entry], [%v2, %F1] + %M = icmp ne i32 %B, %v1 + %N = icmp eq i32 %B, 47 + %O = and i1 %M, %N + br i1 %O, label %T2, label %F2 + +; CHECK: Merge: +; CHECK-NOT: phi +; CHECK-NEXT: %v2 = call i32 @f2() + +T2: + call void @f3() + ret i32 %B + +F2: + ret i32 %B +; CHECK: F2: +; CHECK-NEXT: phi i32 +} Modified: llvm/trunk/test/Transforms/JumpThreading/crash.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/JumpThreading/crash.ll?rev=86355&r1=86354&r2=86355&view=diff ============================================================================== --- llvm/trunk/test/Transforms/JumpThreading/crash.ll (original) +++ llvm/trunk/test/Transforms/JumpThreading/crash.ll Sat Nov 7 02:05:03 2009 @@ -170,3 +170,25 @@ ret i32 1 } + +define fastcc void @test5(i1 %tmp, i32 %tmp1) nounwind ssp { +entry: + br i1 %tmp, label %bb12, label %bb13 + + +bb12: + br label %bb13 + +bb13: + %.lcssa31 = phi i32 [ undef, %bb12 ], [ %tmp1, %entry ] + %A = and i1 undef, undef + br i1 %A, label %bb15, label %bb61 + +bb15: + ret void + + +bb61: + ret void +} + From sabre at nondot.org Sat Nov 7 02:31:52 2009 From: sabre at nondot.org (Chris Lattner) Date: Sat, 07 Nov 2009 08:31:52 -0000 Subject: [llvm-commits] [llvm] r86358 - /llvm/trunk/win32/ Message-ID: <200911070831.nA78VqHf027176@zion.cs.uiuc.edu> Author: lattner Date: Sat Nov 7 02:31:52 2009 New Revision: 86358 URL: http://llvm.org/viewvc/llvm-project?rev=86358&view=rev Log: remove the win32 tree, it's stale and confusing. Removed: llvm/trunk/win32/ From nicholas at mxc.ca Sat Nov 7 02:34:41 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Sat, 07 Nov 2009 08:34:41 -0000 Subject: [llvm-commits] [llvm] r86359 - in /llvm/trunk: lib/Transforms/Scalar/DeadStoreElimination.cpp test/Transforms/DeadStoreElimination/lifetime.ll test/Transforms/DeadStoreElimination/memintrinsics.ll Message-ID: <200911070834.nA78Yfbj027278@zion.cs.uiuc.edu> Author: nicholas Date: Sat Nov 7 02:34:40 2009 New Revision: 86359 URL: http://llvm.org/viewvc/llvm-project?rev=86359&view=rev Log: Teach dead store elimination that certain intrinsics write to memory just like a store. Added: llvm/trunk/test/Transforms/DeadStoreElimination/lifetime.ll llvm/trunk/test/Transforms/DeadStoreElimination/memintrinsics.ll Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp?rev=86359&r1=86358&r2=86359&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Sat Nov 7 02:34:40 2009 @@ -78,19 +78,84 @@ FunctionPass *llvm::createDeadStoreEliminationPass() { return new DSE(); } -/// isValueAtLeastAsBigAs - Return true if V1 is greater than or equal to the -/// stored size of V2. This returns false if we don't know. +/// doesClobberMemory - Does this instruction clobber (write without reading) +/// some memory? +static bool doesClobberMemory(Instruction *I) { + if (isa(I)) + return true; + if (IntrinsicInst *II = dyn_cast(I)) { + switch (II->getIntrinsicID()) { + default: return false; + case Intrinsic::memset: case Intrinsic::memmove: case Intrinsic::memcpy: + case Intrinsic::lifetime_end: return true; + } + } + return false; +} + +/// isElidable - If the memory this instruction and the memory it writes to is +/// unused, may we delete this instrtction? +static bool isElidable(Instruction *I) { + assert(doesClobberMemory(I)); + if (IntrinsicInst *II = dyn_cast(I)) + return II->getIntrinsicID() != Intrinsic::lifetime_end; + if (StoreInst *SI = dyn_cast(I)) + return !SI->isVolatile(); + return true; +} + +/// getPointerOperand - Return the pointer that is being clobbered. +static Value *getPointerOperand(Instruction *I) { + assert(doesClobberMemory(I)); + if (StoreInst *SI = dyn_cast(I)) + return SI->getPointerOperand(); + if (MemIntrinsic *MI = dyn_cast(I)) + return MI->getOperand(1); + assert(cast(I)->getIntrinsicID() == Intrinsic::lifetime_end); + return cast(I)->getOperand(2); +} + +/// getStoreSize - Return the length in bytes of the write by the clobbering +/// instruction. If variable or unknown, returns -1. +static unsigned getStoreSize(Instruction *I, const TargetData *TD = 0) { + assert(doesClobberMemory(I)); + if (StoreInst *SI = dyn_cast(I)) { + if (!TD) return -1u; + const PointerType *PTy = + cast(SI->getPointerOperand()->getType()); + return TD->getTypeStoreSize(PTy); + } + + Value *Len; + if (MemIntrinsic *MI = dyn_cast(I)) { + Len = MI->getLength(); + } else { + assert(cast(I)->getIntrinsicID() == + Intrinsic::lifetime_end); + Len = cast(I)->getOperand(0); + } + if (ConstantInt *LenCI = dyn_cast(Len)) + if (!LenCI->isAllOnesValue()) + return LenCI->getZExtValue(); + return -1u; +} + +/// isStoreAtLeastAsWideAs - Return true if the size of the store in I1 is +/// greater than or equal to the store in I2. This returns false if we don't +/// know. /// -static bool isValueAtLeastAsBigAs(Value *V1, Value *V2, const TargetData *TD) { - const Type *V1Ty = V1->getType(), *V2Ty = V2->getType(); +static bool isStoreAtLeastAsWideAs(Instruction *I1, Instruction *I2, + const TargetData *TD) { + const Type *I1Ty = getPointerOperand(I1)->getType(); + const Type *I2Ty = getPointerOperand(I2)->getType(); // Exactly the same type, must have exactly the same size. - if (V1Ty == V2Ty) return true; + if (I1Ty == I2Ty) return true; - // If we don't have target data, we don't know. - if (TD == 0) return false; + int I1Size = getStoreSize(I1, TD); + int I2Size = getStoreSize(I2, TD); - return TD->getTypeStoreSize(V1Ty) >= TD->getTypeStoreSize(V2Ty); + return I1Size != -1 && I2Size != -1 && I1Size >= I2Size; } bool DSE::runOnBasicBlock(BasicBlock &BB) { @@ -104,14 +169,9 @@ Instruction *Inst = BBI++; // If we find a store or a free, get its memory dependence. - if (!isa(Inst) && !isFreeCall(Inst)) + if (!doesClobberMemory(Inst) && !isFreeCall(Inst)) continue; - // Don't molest volatile stores or do queries that will return "clobber". - if (StoreInst *SI = dyn_cast(Inst)) - if (SI->isVolatile()) - continue; - MemDepResult InstDep = MD.getDependency(Inst); // Ignore non-local stores. @@ -124,16 +184,16 @@ continue; } - StoreInst *SI = cast(Inst); - // If not a definite must-alias dependency, ignore it. if (!InstDep.isDef()) continue; // If this is a store-store dependence, then the previous store is dead so // long as this store is at least as big as it. - if (StoreInst *DepStore = dyn_cast(InstDep.getInst())) - if (isValueAtLeastAsBigAs(SI->getOperand(0), DepStore->getOperand(0),TD)){ + if (doesClobberMemory(InstDep.getInst())) { + Instruction *DepStore = InstDep.getInst(); + if (isStoreAtLeastAsWideAs(Inst, DepStore, TD) && + isElidable(DepStore)){ // Delete the store and now-dead instructions that feed it. DeleteDeadInstruction(DepStore); NumFastStores++; @@ -146,25 +206,31 @@ --BBI; continue; } + } + + if (!isElidable(Inst)) + continue; // If we're storing the same value back to a pointer that we just // loaded from, then the store can be removed. - if (LoadInst *DepLoad = dyn_cast(InstDep.getInst())) { - if (SI->getPointerOperand() == DepLoad->getPointerOperand() && - SI->getOperand(0) == DepLoad) { - // DeleteDeadInstruction can delete the current instruction. Save BBI - // in case we need it. - WeakVH NextInst(BBI); - - DeleteDeadInstruction(SI); - - if (NextInst == 0) // Next instruction deleted. - BBI = BB.begin(); - else if (BBI != BB.begin()) // Revisit this instruction if possible. - --BBI; - NumFastStores++; - MadeChange = true; - continue; + if (StoreInst *SI = dyn_cast(Inst)) { + if (LoadInst *DepLoad = dyn_cast(InstDep.getInst())) { + if (SI->getPointerOperand() == DepLoad->getPointerOperand() && + SI->getOperand(0) == DepLoad) { + // DeleteDeadInstruction can delete the current instruction. Save BBI + // in case we need it. + WeakVH NextInst(BBI); + + DeleteDeadInstruction(SI); + + if (NextInst == 0) // Next instruction deleted. + BBI = BB.begin(); + else if (BBI != BB.begin()) // Revisit this instruction if possible. + --BBI; + NumFastStores++; + MadeChange = true; + continue; + } } } @@ -176,7 +242,7 @@ // in case we need it. WeakVH NextInst(BBI); - DeleteDeadInstruction(SI); + DeleteDeadInstruction(Inst); if (NextInst == 0) // Next instruction deleted. BBI = BB.begin(); @@ -202,11 +268,11 @@ bool DSE::handleFreeWithNonTrivialDependency(Instruction *F, MemDepResult Dep) { AliasAnalysis &AA = getAnalysis(); - StoreInst *Dependency = dyn_cast_or_null(Dep.getInst()); - if (!Dependency || Dependency->isVolatile()) + Instruction *Dependency = Dep.getInst(); + if (!Dependency || !doesClobberMemory(Dependency) || !isElidable(Dependency)) return false; - Value *DepPointer = Dependency->getPointerOperand()->getUnderlyingObject(); + Value *DepPointer = getPointerOperand(Dependency)->getUnderlyingObject(); // Check for aliasing. if (AA.alias(F->getOperand(1), 1, DepPointer, 1) != @@ -251,39 +317,28 @@ --BBI; // If we find a store whose pointer is dead. - if (StoreInst* S = dyn_cast(BBI)) { - if (!S->isVolatile()) { + if (doesClobberMemory(BBI)) { + if (isElidable(BBI)) { // See through pointer-to-pointer bitcasts - Value* pointerOperand = S->getPointerOperand()->getUnderlyingObject(); + Value *pointerOperand = getPointerOperand(BBI)->getUnderlyingObject(); // Alloca'd pointers or byval arguments (which are functionally like // alloca's) are valid candidates for removal. if (deadPointers.count(pointerOperand)) { // DCE instructions only used to calculate that store. + Instruction *Dead = BBI; BBI++; - DeleteDeadInstruction(S, &deadPointers); + DeleteDeadInstruction(Dead, &deadPointers); NumFastStores++; MadeChange = true; + continue; } } - continue; - } - - // We can also remove memcpy's to local variables at the end of a function. - if (MemCpyInst *M = dyn_cast(BBI)) { - Value *dest = M->getDest()->getUnderlyingObject(); - - if (deadPointers.count(dest)) { - BBI++; - DeleteDeadInstruction(M, &deadPointers); - NumFastOther++; - MadeChange = true; + // Because a memcpy or memmove is also a load, we can't skip it if we + // didn't remove it. + if (!isa(BBI)) continue; - } - - // Because a memcpy is also a load, we can't skip it if we didn't remove - // it. } Value* killPointer = 0; @@ -304,11 +359,11 @@ killPointer = L->getPointerOperand(); } else if (VAArgInst* V = dyn_cast(BBI)) { killPointer = V->getOperand(0); - } else if (isa(BBI) && - isa(cast(BBI)->getLength())) { - killPointer = cast(BBI)->getSource(); + } else if (isa(BBI) && + isa(cast(BBI)->getLength())) { + killPointer = cast(BBI)->getSource(); killPointerSize = cast( - cast(BBI)->getLength())->getZExtValue(); + cast(BBI)->getLength())->getZExtValue(); } else if (AllocaInst* A = dyn_cast(BBI)) { deadPointers.erase(A); Added: llvm/trunk/test/Transforms/DeadStoreElimination/lifetime.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/DeadStoreElimination/lifetime.ll?rev=86359&view=auto ============================================================================== --- llvm/trunk/test/Transforms/DeadStoreElimination/lifetime.ll (added) +++ llvm/trunk/test/Transforms/DeadStoreElimination/lifetime.ll Sat Nov 7 02:34:40 2009 @@ -0,0 +1,19 @@ +; RUN: opt -S -dse < %s | FileCheck %s + +declare void @llvm.lifetime.end(i64, i8*) +declare void @llvm.memset.i8(i8*, i8, i8, i32) + +define void @test1() { +; CHECK: @test1 + %A = alloca i8 + + store i8 0, i8* %A ;; Written to by memset + call void @llvm.lifetime.end(i64 1, i8* %A) +; CHECK: lifetime.end + + call void @llvm.memset.i8(i8* %A, i8 0, i8 -1, i32 0) +; CHECK-NOT: memset + + ret void +; CHECK: ret void +} Added: llvm/trunk/test/Transforms/DeadStoreElimination/memintrinsics.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/DeadStoreElimination/memintrinsics.ll?rev=86359&view=auto ============================================================================== --- llvm/trunk/test/Transforms/DeadStoreElimination/memintrinsics.ll (added) +++ llvm/trunk/test/Transforms/DeadStoreElimination/memintrinsics.ll Sat Nov 7 02:34:40 2009 @@ -0,0 +1,47 @@ +; RUN: opt -S -dse < %s | FileCheck %s + +declare void @llvm.memcpy.i8(i8*, i8*, i8, i32) +declare void @llvm.memmove.i8(i8*, i8*, i8, i32) +declare void @llvm.memset.i8(i8*, i8, i8, i32) + +define void @test1() { +; CHECK: @test1 + %A = alloca i8 + %B = alloca i8 + + store i8 0, i8* %A ;; Written to by memcpy +; CHECK-NOT: store + + call void @llvm.memcpy.i8(i8* %A, i8* %B, i8 -1, i32 0) + + ret void +; CHECK: ret void +} + +define void @test2() { +; CHECK: @test2 + %A = alloca i8 + %B = alloca i8 + + store i8 0, i8* %A ;; Written to by memmove +; CHECK-NOT: store + + call void @llvm.memmove.i8(i8* %A, i8* %B, i8 -1, i32 0) + + ret void +; CHECK: ret void +} + +define void @test3() { +; CHECK: @test3 + %A = alloca i8 + %B = alloca i8 + + store i8 0, i8* %A ;; Written to by memset +; CHECK-NOT: store + + call void @llvm.memset.i8(i8* %A, i8 0, i8 -1, i32 0) + + ret void +; CHECK: ret void +} From echristo at apple.com Sat Nov 7 02:45:53 2009 From: echristo at apple.com (Eric Christopher) Date: Sat, 07 Nov 2009 08:45:53 -0000 Subject: [llvm-commits] [llvm] r86360 - in /llvm/trunk: lib/Target/X86/X86InstrSSE.td test/CodeGen/X86/sse3.ll test/CodeGen/X86/vec_shuffle-3.ll Message-ID: <200911070845.nA78jsYJ000435@zion.cs.uiuc.edu> Author: echristo Date: Sat Nov 7 02:45:53 2009 New Revision: 86360 URL: http://llvm.org/viewvc/llvm-project?rev=86360&view=rev Log: Fix a couple of shuffle patterns to use movhlps instead of movhps as the constraint. Changes optimizations so update testcases as appropriate as well. Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td llvm/trunk/test/CodeGen/X86/sse3.ll llvm/trunk/test/CodeGen/X86/vec_shuffle-3.ll Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=86360&r1=86359&r2=86360&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Sat Nov 7 02:45:53 2009 @@ -2085,7 +2085,7 @@ [(set VR128:$dst, (v4i32 (pshufd:$src2 (bc_v4i32(memopv2i64 addr:$src1)), (undef))))]>; -} +} // SSE2 with ImmT == Imm8 and XS prefix. def PSHUFHWri : Ii8<0x70, MRMSrcReg, @@ -2874,7 +2874,7 @@ (PALIGNR128rr VR128:$src2, VR128:$src1, (SHUFFLE_get_palign_imm VR128:$src3))>, Requires<[HasSSSE3]>; -} +} def : Pat<(X86pshufb VR128:$src, VR128:$mask), (PSHUFBrr128 VR128:$src, VR128:$mask)>, Requires<[HasSSSE3]>; @@ -3051,15 +3051,15 @@ let AddedComplexity = 20 in { // vector_shuffle v1, (load v2) <4, 5, 2, 3> using MOVLPS -// vector_shuffle v1, (load v2) <0, 1, 4, 5> using MOVHPS +// vector_shuffle v1, (load v2) <6, 7, 2, 3> using MOVHPS def : Pat<(v4f32 (movlp VR128:$src1, (load addr:$src2))), (MOVLPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>; def : Pat<(v2f64 (movlp VR128:$src1, (load addr:$src2))), (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>; -def : Pat<(v4f32 (movhp VR128:$src1, (load addr:$src2))), - (MOVHPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>; -def : Pat<(v2f64 (movhp VR128:$src1, (load addr:$src2))), - (MOVHPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>; +def : Pat<(v4f32 (movhlps (load addr:$src1), VR128:$src2)), + (MOVHPSrm VR128:$src2, addr:$src1)>, Requires<[HasSSE1]>; +def : Pat<(v2f64 (movhlps (load addr:$src1), VR128:$src2)), + (MOVHPDrm VR128:$src2, addr:$src1)>, Requires<[HasSSE2]>; def : Pat<(v4i32 (movlp VR128:$src1, (load addr:$src2))), (MOVLPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>; @@ -3077,9 +3077,9 @@ (MOVLPSmr addr:$src1, VR128:$src2)>, Requires<[HasSSE1]>; def : Pat<(store (v2f64 (movlp (load addr:$src1), VR128:$src2)), addr:$src1), (MOVLPDmr addr:$src1, VR128:$src2)>, Requires<[HasSSE2]>; -def : Pat<(store (v4f32 (movhp (load addr:$src1), VR128:$src2)), addr:$src1), +def : Pat<(store (v4f32 (movhlps (load addr:$src1), VR128:$src2)), addr:$src1), (MOVHPSmr addr:$src1, VR128:$src2)>, Requires<[HasSSE1]>; -def : Pat<(store (v2f64 (movhp (load addr:$src1), VR128:$src2)), addr:$src1), +def : Pat<(store (v2f64 (movhlps (load addr:$src1), VR128:$src2)), addr:$src1), (MOVHPDmr addr:$src1, VR128:$src2)>, Requires<[HasSSE2]>; def : Pat<(store (v4i32 (movlp (bc_v4i32 (loadv2i64 addr:$src1)), VR128:$src2)), Modified: llvm/trunk/test/CodeGen/X86/sse3.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/sse3.ll?rev=86360&r1=86359&r2=86360&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/sse3.ll (original) +++ llvm/trunk/test/CodeGen/X86/sse3.ll Sat Nov 7 02:45:53 2009 @@ -145,7 +145,9 @@ ret void ; X64: t9: ; X64: movsd (%rsi), %xmm0 -; X64: movhps %xmm0, (%rdi) +; X64: movaps (%rdi), %xmm1 +; X64: movlhps %xmm0, %xmm1 +; X64: movaps %xmm1, (%rdi) ; X64: ret } Modified: llvm/trunk/test/CodeGen/X86/vec_shuffle-3.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/vec_shuffle-3.ll?rev=86360&r1=86359&r2=86360&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/vec_shuffle-3.ll (original) +++ llvm/trunk/test/CodeGen/X86/vec_shuffle-3.ll Sat Nov 7 02:45:53 2009 @@ -1,6 +1,6 @@ ; RUN: llc < %s -march=x86 -mattr=+sse2 -o %t ; RUN: grep movlhps %t | count 1 -; RUN: grep movhlps %t | count 1 +; RUN: grep movhps %t | count 1 define <4 x float> @test1(<4 x float>* %x, <4 x float>* %y) { %tmp = load <4 x float>* %y ; <<4 x float>> [#uses=2] @@ -18,4 +18,3 @@ %tmp4 = shufflevector <4 x float> %tmp3, <4 x float> %tmp, <4 x i32> < i32 2, i32 3, i32 6, i32 7 > ; <<4 x float>> [#uses=1] ret <4 x float> %tmp4 } - From jyasskin at google.com Sat Nov 7 02:51:52 2009 From: jyasskin at google.com (Jeffrey Yasskin) Date: Sat, 07 Nov 2009 08:51:52 -0000 Subject: [llvm-commits] [llvm] r86363 - in /llvm/trunk: include/llvm/CodeGen/MachineRelocation.h lib/ExecutionEngine/JIT/JITEmitter.cpp lib/Target/ARM/ARMCodeEmitter.cpp lib/Target/X86/X86CodeEmitter.cpp Message-ID: <200911070851.nA78priJ002694@zion.cs.uiuc.edu> Author: jyasskin Date: Sat Nov 7 02:51:52 2009 New Revision: 86363 URL: http://llvm.org/viewvc/llvm-project?rev=86363&view=rev Log: Make the need-stub variables accurate and consistent. In the case of MachineRelocations, "stub" always refers to a far-call stub or a load-a-faraway-global stub, so this patch adds "Far" to the term. (Other stubs are used for lazy compilation and dlsym address replacement.) The variable was also inconsistent between the positive and negative sense, and the positive sense ("NeedStub") was more demanding than is accurate (since a nearby-enough function can be called directly even if the platform often requires a stub). Since the negative sense causes double-negatives, I switched to "MayNeedFarStub" globally. Modified: llvm/trunk/include/llvm/CodeGen/MachineRelocation.h llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp Modified: llvm/trunk/include/llvm/CodeGen/MachineRelocation.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineRelocation.h?rev=86363&r1=86362&r2=86363&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineRelocation.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineRelocation.h Sat Nov 7 02:51:52 2009 @@ -65,7 +65,7 @@ unsigned TargetReloType : 6; // The target relocation ID AddressType AddrType : 4; // The field of Target to use - bool NeedStub : 1; // True if this relocation requires a stub + bool MayNeedFarStub : 1; // True if this relocation may require a far-stub bool GOTRelative : 1; // Should this relocation be relative to the GOT? bool TargetResolve : 1; // True if target should resolve the address @@ -81,7 +81,7 @@ /// static MachineRelocation getGV(uintptr_t offset, unsigned RelocationType, GlobalValue *GV, intptr_t cst = 0, - bool NeedStub = 0, + bool MayNeedFarStub = 0, bool GOTrelative = 0) { assert((RelocationType & ~63) == 0 && "Relocation type too large!"); MachineRelocation Result; @@ -89,7 +89,7 @@ Result.ConstantVal = cst; Result.TargetReloType = RelocationType; Result.AddrType = isGV; - Result.NeedStub = NeedStub; + Result.MayNeedFarStub = MayNeedFarStub; Result.GOTRelative = GOTrelative; Result.TargetResolve = false; Result.Target.GV = GV; @@ -101,7 +101,7 @@ static MachineRelocation getIndirectSymbol(uintptr_t offset, unsigned RelocationType, GlobalValue *GV, intptr_t cst = 0, - bool NeedStub = 0, + bool MayNeedFarStub = 0, bool GOTrelative = 0) { assert((RelocationType & ~63) == 0 && "Relocation type too large!"); MachineRelocation Result; @@ -109,7 +109,7 @@ Result.ConstantVal = cst; Result.TargetReloType = RelocationType; Result.AddrType = isIndirectSym; - Result.NeedStub = NeedStub; + Result.MayNeedFarStub = MayNeedFarStub; Result.GOTRelative = GOTrelative; Result.TargetResolve = false; Result.Target.GV = GV; @@ -126,7 +126,7 @@ Result.ConstantVal = cst; Result.TargetReloType = RelocationType; Result.AddrType = isBB; - Result.NeedStub = false; + Result.MayNeedFarStub = false; Result.GOTRelative = false; Result.TargetResolve = false; Result.Target.MBB = MBB; @@ -145,7 +145,7 @@ Result.ConstantVal = cst; Result.TargetReloType = RelocationType; Result.AddrType = isExtSym; - Result.NeedStub = true; + Result.MayNeedFarStub = true; Result.GOTRelative = GOTrelative; Result.TargetResolve = false; Result.Target.ExtSym = ES; @@ -164,7 +164,7 @@ Result.ConstantVal = cst; Result.TargetReloType = RelocationType; Result.AddrType = isConstPool; - Result.NeedStub = false; + Result.MayNeedFarStub = false; Result.GOTRelative = false; Result.TargetResolve = letTargetResolve; Result.Target.Index = CPI; @@ -183,7 +183,7 @@ Result.ConstantVal = cst; Result.TargetReloType = RelocationType; Result.AddrType = isJumpTable; - Result.NeedStub = false; + Result.MayNeedFarStub = false; Result.GOTRelative = false; Result.TargetResolve = letTargetResolve; Result.Target.Index = JTI; @@ -258,12 +258,14 @@ return GOTRelative; } - /// doesntNeedStub - This function returns true if the JIT for this target - /// target is capable of directly handling the relocated GlobalValue reference - /// without using either a stub function or issuing an extra load to get the - /// GV address. - bool doesntNeedStub() const { - return !NeedStub; + /// mayNeedFarStub - This function returns true if the JIT for this target may + /// need either a stub function or an indirect global-variable load to handle + /// the relocated GlobalValue reference. For example, the x86-64 call + /// instruction can only call functions within +/-2GB of the call site. + /// Anything farther away needs a longer mov+call sequence, which can't just + /// be written on top of the existing call. + bool mayNeedFarStub() const { + return MayNeedFarStub; } /// letTargetResolve - Return true if the target JITInfo is usually Modified: llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp?rev=86363&r1=86362&r2=86363&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp Sat Nov 7 02:51:52 2009 @@ -491,9 +491,9 @@ JITMemoryManager *getMemMgr() const { return MemMgr; } private: - void *getPointerToGlobal(GlobalValue *GV, void *Reference, bool NoNeedStub); - void *getPointerToGVIndirectSym(GlobalValue *V, void *Reference, - bool NoNeedStub); + void *getPointerToGlobal(GlobalValue *GV, void *Reference, + bool MayNeedFarStub); + void *getPointerToGVIndirectSym(GlobalValue *V, void *Reference); unsigned addSizeOfGlobal(const GlobalVariable *GV, unsigned Size); unsigned addSizeOfGlobalsInConstantVal(const Constant *C, unsigned Size); unsigned addSizeOfGlobalsInInitializer(const Constant *Init, unsigned Size); @@ -737,7 +737,7 @@ // JITEmitter code. // void *JITEmitter::getPointerToGlobal(GlobalValue *V, void *Reference, - bool DoesntNeedStub) { + bool MayNeedFarStub) { if (GlobalVariable *GV = dyn_cast(V)) return TheJIT->getOrEmitGlobalVariable(GV); @@ -747,7 +747,7 @@ // If we have already compiled the function, return a pointer to its body. Function *F = cast(V); void *ResultPtr; - if (!DoesntNeedStub) { + if (MayNeedFarStub) { // Return the function stub if it's already created. ResultPtr = Resolver.getFunctionStubIfAvailable(F); if (ResultPtr) @@ -761,14 +761,14 @@ // 'compile' it, which really just adds it to the map. In dlsym mode, // external functions are forced through a stub, regardless of reloc type. if (F->isDeclaration() && !F->hasNotBeenReadFromBitcode() && - DoesntNeedStub && !TheJIT->areDlsymStubsEnabled()) + !MayNeedFarStub && !TheJIT->areDlsymStubsEnabled()) return TheJIT->getPointerToFunction(F); // Okay, the function has not been compiled yet, if the target callback // mechanism is capable of rewriting the instruction directly, prefer to do // that instead of emitting a stub. This uses the lazy resolver, so is not // legal if lazy compilation is disabled. - if (DoesntNeedStub && TheJIT->isCompilingLazily()) + if (!MayNeedFarStub && TheJIT->isCompilingLazily()) return Resolver.AddCallbackAtLocation(F, Reference); // Otherwise, we have to emit a stub. @@ -784,11 +784,10 @@ return StubAddr; } -void *JITEmitter::getPointerToGVIndirectSym(GlobalValue *V, void *Reference, - bool NoNeedStub) { +void *JITEmitter::getPointerToGVIndirectSym(GlobalValue *V, void *Reference) { // Make sure GV is emitted first, and create a stub containing the fully // resolved address. - void *GVAddress = getPointerToGlobal(V, Reference, true); + void *GVAddress = getPointerToGlobal(V, Reference, false); void *StubAddr = Resolver.getGlobalValueIndirectSym(V, GVAddress); // Add the stub to the current function's list of referenced stubs, so we can @@ -1112,7 +1111,7 @@ << ResultPtr << "]\n"); // If the target REALLY wants a stub for this function, emit it now. - if (!MR.doesntNeedStub()) { + if (MR.mayNeedFarStub()) { if (!TheJIT->areDlsymStubsEnabled()) { ResultPtr = Resolver.getExternalFunctionStub(ResultPtr); } else { @@ -1127,11 +1126,10 @@ } else if (MR.isGlobalValue()) { ResultPtr = getPointerToGlobal(MR.getGlobalValue(), BufferBegin+MR.getMachineCodeOffset(), - MR.doesntNeedStub()); + MR.mayNeedFarStub()); } else if (MR.isIndirectSymbol()) { - ResultPtr = getPointerToGVIndirectSym(MR.getGlobalValue(), - BufferBegin+MR.getMachineCodeOffset(), - MR.doesntNeedStub()); + ResultPtr = getPointerToGVIndirectSym( + MR.getGlobalValue(), BufferBegin+MR.getMachineCodeOffset()); } else if (MR.isBasicBlock()) { ResultPtr = (void*)getMachineBasicBlockAddress(MR.getBasicBlock()); } else if (MR.isConstantPoolIndex()) { Modified: llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp?rev=86363&r1=86362&r2=86363&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp Sat Nov 7 02:51:52 2009 @@ -168,7 +168,8 @@ /// Routines that handle operands which add machine relocations which are /// fixed up by the relocation stage. void emitGlobalAddress(GlobalValue *GV, unsigned Reloc, - bool NeedStub, bool Indirect, intptr_t ACPV = 0); + bool MayNeedFarStub, bool Indirect, + intptr_t ACPV = 0); void emitExternalSymbolAddress(const char *ES, unsigned Reloc); void emitConstPoolAddress(unsigned CPI, unsigned Reloc); void emitJumpTableAddress(unsigned JTIndex, unsigned Reloc); @@ -277,13 +278,13 @@ /// template void Emitter::emitGlobalAddress(GlobalValue *GV, unsigned Reloc, - bool NeedStub, bool Indirect, + bool MayNeedFarStub, bool Indirect, intptr_t ACPV) { MachineRelocation MR = Indirect ? MachineRelocation::getIndirectSymbol(MCE.getCurrentPCOffset(), Reloc, - GV, ACPV, NeedStub) + GV, ACPV, MayNeedFarStub) : MachineRelocation::getGV(MCE.getCurrentPCOffset(), Reloc, - GV, ACPV, NeedStub); + GV, ACPV, MayNeedFarStub); MCE.addRelocation(MR); } Modified: llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp?rev=86363&r1=86362&r2=86363&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp (original) +++ llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp Sat Nov 7 02:51:52 2009 @@ -82,7 +82,7 @@ void emitPCRelativeBlockAddress(MachineBasicBlock *MBB); void emitGlobalAddress(GlobalValue *GV, unsigned Reloc, intptr_t Disp = 0, intptr_t PCAdj = 0, - bool NeedStub = false, bool Indirect = false); + bool MayNeedFarStub = false, bool Indirect = false); void emitExternalSymbolAddress(const char *ES, unsigned Reloc); void emitConstPoolAddress(unsigned CPI, unsigned Reloc, intptr_t Disp = 0, intptr_t PCAdj = 0); @@ -176,7 +176,7 @@ void Emitter::emitGlobalAddress(GlobalValue *GV, unsigned Reloc, intptr_t Disp /* = 0 */, intptr_t PCAdj /* = 0 */, - bool NeedStub /* = false */, + bool MayNeedFarStub /* = false */, bool Indirect /* = false */) { intptr_t RelocCST = Disp; if (Reloc == X86::reloc_picrel_word) @@ -185,9 +185,9 @@ RelocCST = PCAdj; MachineRelocation MR = Indirect ? MachineRelocation::getIndirectSymbol(MCE.getCurrentPCOffset(), Reloc, - GV, RelocCST, NeedStub) + GV, RelocCST, MayNeedFarStub) : MachineRelocation::getGV(MCE.getCurrentPCOffset(), Reloc, - GV, RelocCST, NeedStub); + GV, RelocCST, MayNeedFarStub); MCE.addRelocation(MR); // The relocated value will be added to the displacement if (Reloc == X86::reloc_absolute_dword) @@ -333,10 +333,10 @@ // do it, otherwise fallback to absolute (this is determined by IsPCRel). // 89 05 00 00 00 00 mov %eax,0(%rip) # PC-relative // 89 04 25 00 00 00 00 mov %eax,0x0 # Absolute - bool NeedStub = isa(RelocOp->getGlobal()); + bool MayNeedFarStub = isa(RelocOp->getGlobal()); bool Indirect = gvNeedsNonLazyPtr(*RelocOp, TM); emitGlobalAddress(RelocOp->getGlobal(), RelocType, RelocOp->getOffset(), - Adj, NeedStub, Indirect); + Adj, MayNeedFarStub, Indirect); } else if (RelocOp->isSymbol()) { emitExternalSymbolAddress(RelocOp->getSymbolName(), RelocType); } else if (RelocOp->isCPI()) { @@ -634,13 +634,13 @@ if (MO.isGlobal()) { // Assume undefined functions may be outside the Small codespace. - bool NeedStub = + bool MayNeedFarStub = (Is64BitMode && (TM.getCodeModel() == CodeModel::Large || TM.getSubtarget().isTargetDarwin())) || Opcode == X86::TAILJMPd; emitGlobalAddress(MO.getGlobal(), X86::reloc_pcrel_word, - MO.getOffset(), 0, NeedStub); + MO.getOffset(), 0, MayNeedFarStub); break; } @@ -681,10 +681,10 @@ if (Opcode == X86::MOV64ri) rt = X86::reloc_absolute_dword; // FIXME: add X86II flag? if (MO1.isGlobal()) { - bool NeedStub = isa(MO1.getGlobal()); + bool MayNeedFarStub = isa(MO1.getGlobal()); bool Indirect = gvNeedsNonLazyPtr(MO1, TM); emitGlobalAddress(MO1.getGlobal(), rt, MO1.getOffset(), 0, - NeedStub, Indirect); + MayNeedFarStub, Indirect); } else if (MO1.isSymbol()) emitExternalSymbolAddress(MO1.getSymbolName(), rt); else if (MO1.isCPI()) @@ -790,10 +790,10 @@ if (Opcode == X86::MOV64ri32) rt = X86::reloc_absolute_word_sext; // FIXME: add X86II flag? if (MO1.isGlobal()) { - bool NeedStub = isa(MO1.getGlobal()); + bool MayNeedFarStub = isa(MO1.getGlobal()); bool Indirect = gvNeedsNonLazyPtr(MO1, TM); emitGlobalAddress(MO1.getGlobal(), rt, MO1.getOffset(), 0, - NeedStub, Indirect); + MayNeedFarStub, Indirect); } else if (MO1.isSymbol()) emitExternalSymbolAddress(MO1.getSymbolName(), rt); else if (MO1.isCPI()) @@ -831,10 +831,10 @@ if (Opcode == X86::MOV64mi32) rt = X86::reloc_absolute_word_sext; // FIXME: add X86II flag? if (MO.isGlobal()) { - bool NeedStub = isa(MO.getGlobal()); + bool MayNeedFarStub = isa(MO.getGlobal()); bool Indirect = gvNeedsNonLazyPtr(MO, TM); emitGlobalAddress(MO.getGlobal(), rt, MO.getOffset(), 0, - NeedStub, Indirect); + MayNeedFarStub, Indirect); } else if (MO.isSymbol()) emitExternalSymbolAddress(MO.getSymbolName(), rt); else if (MO.isCPI()) From sabre at nondot.org Sat Nov 7 03:07:01 2009 From: sabre at nondot.org (Chris Lattner) Date: Sat, 07 Nov 2009 09:07:01 -0000 Subject: [llvm-commits] [llvm] r86365 - /llvm/trunk/lib/VMCore/Instructions.cpp Message-ID: <200911070907.nA7971bm009693@zion.cs.uiuc.edu> Author: lattner Date: Sat Nov 7 03:07:01 2009 New Revision: 86365 URL: http://llvm.org/viewvc/llvm-project?rev=86365&view=rev Log: prune #include / layering violation Modified: llvm/trunk/lib/VMCore/Instructions.cpp Modified: llvm/trunk/lib/VMCore/Instructions.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instructions.cpp?rev=86365&r1=86364&r2=86365&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Instructions.cpp (original) +++ llvm/trunk/lib/VMCore/Instructions.cpp Sat Nov 7 03:07:01 2009 @@ -24,8 +24,6 @@ #include "llvm/Support/CallSite.h" #include "llvm/Support/ConstantRange.h" #include "llvm/Support/MathExtras.h" -#include "llvm/Target/TargetData.h" - using namespace llvm; //===----------------------------------------------------------------------===// From sabre at nondot.org Sat Nov 7 03:13:23 2009 From: sabre at nondot.org (Chris Lattner) Date: Sat, 07 Nov 2009 09:13:23 -0000 Subject: [llvm-commits] [llvm] r86366 - in /llvm/trunk: include/llvm/Target/TargetData.h lib/Target/TargetData.cpp Message-ID: <200911070913.nA79DNPV009885@zion.cs.uiuc.edu> Author: lattner Date: Sat Nov 7 03:13:23 2009 New Revision: 86366 URL: http://llvm.org/viewvc/llvm-project?rev=86366&view=rev Log: rewrite TargetData to use StringRef/raw_ostream instead of thrashing std::strings. Modified: llvm/trunk/include/llvm/Target/TargetData.h llvm/trunk/lib/Target/TargetData.cpp Modified: llvm/trunk/include/llvm/Target/TargetData.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetData.h?rev=86366&r1=86365&r2=86366&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetData.h (original) +++ llvm/trunk/include/llvm/Target/TargetData.h Sat Nov 7 03:13:23 2009 @@ -121,7 +121,7 @@ } /// Constructs a TargetData from a specification string. See init(). - explicit TargetData(const std::string &TargetDescription) + explicit TargetData(StringRef TargetDescription) : ImmutablePass(&ID) { init(TargetDescription); } @@ -142,7 +142,7 @@ ~TargetData(); // Not virtual, do not subclass this class //! Parse a target data layout string and initialize TargetData alignments. - void init(const std::string &TargetDescription); + void init(StringRef TargetDescription); /// Target endianness... bool isLittleEndian() const { return LittleEndian; } Modified: llvm/trunk/lib/Target/TargetData.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetData.cpp?rev=86366&r1=86365&r2=86366&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetData.cpp (original) +++ llvm/trunk/lib/Target/TargetData.cpp Sat Nov 7 03:13:23 2009 @@ -24,9 +24,9 @@ #include "llvm/Support/MathExtras.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/raw_ostream.h" #include "llvm/System/Mutex.h" #include "llvm/ADT/DenseMap.h" -#include "llvm/ADT/StringExtras.h" #include #include using namespace llvm; @@ -132,6 +132,13 @@ // TargetData Class Implementation //===----------------------------------------------------------------------===// +/// getInt - Get an integer ignoring errors. +static unsigned getInt(StringRef R) { + unsigned Result = 0; + R.getAsInteger(10, Result); + return Result; +} + /*! A TargetDescription string consists of a sequence of hyphen-delimited specifiers for target endianness, pointer size and alignments, and various @@ -169,13 +176,12 @@ alignment. This is a special case, where the aggregate's computed worst-case alignment will be used. */ -void TargetData::init(const std::string &TargetDescription) { - std::string temp = TargetDescription; +void TargetData::init(StringRef Desc) { LayoutMap = 0; LittleEndian = false; PointerMemSize = 8; - PointerABIAlign = 8; + PointerABIAlign = 8; PointerPrefAlign = PointerABIAlign; // Default alignments @@ -190,11 +196,21 @@ setAlignment(VECTOR_ALIGN, 16, 16, 128); // v16i8, v8i16, v4i32, ... setAlignment(AGGREGATE_ALIGN, 0, 8, 0); // struct - while (!temp.empty()) { - std::string token = getToken(temp, "-"); - std::string arg0 = getToken(token, ":"); - const char *p = arg0.c_str(); - switch(*p) { + while (!Desc.empty()) { + std::pair Split = Desc.split('-'); + StringRef Token = Split.first; + Desc = Split.second; + + if (Token.empty()) + continue; + + Split = Token.split(':'); + StringRef Specifier = Split.first; + Token = Split.second; + + assert(!Specifier.empty() && "Can't be empty here"); + + switch(Specifier[0]) { case 'E': LittleEndian = false; break; @@ -202,9 +218,12 @@ LittleEndian = true; break; case 'p': - PointerMemSize = atoi(getToken(token,":").c_str()) / 8; - PointerABIAlign = atoi(getToken(token,":").c_str()) / 8; - PointerPrefAlign = atoi(getToken(token,":").c_str()) / 8; + Split = Token.split(':'); + PointerMemSize = getInt(Split.first) / 8; + Split = Split.second.split(':'); + PointerABIAlign = getInt(Split.first) / 8; + Split = Split.second.split(':'); + PointerPrefAlign = getInt(Split.first) / 8; if (PointerPrefAlign == 0) PointerPrefAlign = PointerABIAlign; break; @@ -213,20 +232,24 @@ case 'f': case 'a': case 's': { - AlignTypeEnum align_type = STACK_ALIGN; // Dummy init, silence warning - switch(*p) { - case 'i': align_type = INTEGER_ALIGN; break; - case 'v': align_type = VECTOR_ALIGN; break; - case 'f': align_type = FLOAT_ALIGN; break; - case 'a': align_type = AGGREGATE_ALIGN; break; - case 's': align_type = STACK_ALIGN; break; + AlignTypeEnum AlignType; + switch (Specifier[0]) { + default: + case 'i': AlignType = INTEGER_ALIGN; break; + case 'v': AlignType = VECTOR_ALIGN; break; + case 'f': AlignType = FLOAT_ALIGN; break; + case 'a': AlignType = AGGREGATE_ALIGN; break; + case 's': AlignType = STACK_ALIGN; break; } - uint32_t size = (uint32_t) atoi(++p); - unsigned char abi_align = atoi(getToken(token, ":").c_str()) / 8; - unsigned char pref_align = atoi(getToken(token, ":").c_str()) / 8; - if (pref_align == 0) - pref_align = abi_align; - setAlignment(align_type, abi_align, pref_align, size); + unsigned Size = getInt(Specifier.substr(1)); + Split = Token.split(':'); + unsigned char ABIAlign = getInt(Split.first) / 8; + + Split = Split.second.split(':'); + unsigned char PrefAlign = getInt(Split.first) / 8; + if (PrefAlign == 0) + PrefAlign = ABIAlign; + setAlignment(AlignType, ABIAlign, PrefAlign, Size); break; } default: @@ -376,20 +399,17 @@ std::string TargetData::getStringRepresentation() const { - std::string repr; - repr.append(LittleEndian ? "e" : "E"); - repr.append("-p:").append(itostr((int64_t) (PointerMemSize * 8))). - append(":").append(itostr((int64_t) (PointerABIAlign * 8))). - append(":").append(itostr((int64_t) (PointerPrefAlign * 8))); - for (align_const_iterator I = Alignments.begin(); - I != Alignments.end(); - ++I) { - repr.append("-").append(1, (char) I->AlignType). - append(utostr((int64_t) I->TypeBitWidth)). - append(":").append(utostr((uint64_t) (I->ABIAlign * 8))). - append(":").append(utostr((uint64_t) (I->PrefAlign * 8))); - } - return repr; + std::string Result; + raw_string_ostream OS(Result); + + OS << (LittleEndian ? "e" : "E") + << "-p:" << PointerMemSize*8 << ':' << PointerABIAlign*8 + << ':' << PointerPrefAlign*8; + for (align_const_iterator I = Alignments.begin(), E = Alignments.end(); + I != E; ++I) + OS << '-' << (char)I->AlignType << I->TypeBitWidth << ':' + << I->ABIAlign*8 << ':' << I->PrefAlign*8; + return OS.str(); } From sabre at nondot.org Sat Nov 7 03:20:54 2009 From: sabre at nondot.org (Chris Lattner) Date: Sat, 07 Nov 2009 09:20:54 -0000 Subject: [llvm-commits] [llvm] r86367 - in /llvm/trunk/lib/Target: Blackfin/AsmPrinter/BlackfinAsmPrinter.cpp Blackfin/BlackfinISelLowering.cpp SystemZ/AsmPrinter/SystemZAsmPrinter.cpp SystemZ/SystemZISelLowering.cpp SystemZ/SystemZInstrInfo.cpp TargetLoweringObjectFile.cpp X86/AsmPrinter/X86MCInstLower.cpp Message-ID: <200911070920.nA79Kseq010137@zion.cs.uiuc.edu> Author: lattner Date: Sat Nov 7 03:20:54 2009 New Revision: 86367 URL: http://llvm.org/viewvc/llvm-project?rev=86367&view=rev Log: add some missing #includes Modified: llvm/trunk/lib/Target/Blackfin/AsmPrinter/BlackfinAsmPrinter.cpp llvm/trunk/lib/Target/Blackfin/BlackfinISelLowering.cpp llvm/trunk/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp llvm/trunk/lib/Target/SystemZ/SystemZInstrInfo.cpp llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp Modified: llvm/trunk/lib/Target/Blackfin/AsmPrinter/BlackfinAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Blackfin/AsmPrinter/BlackfinAsmPrinter.cpp?rev=86367&r1=86366&r2=86367&view=diff ============================================================================== --- llvm/trunk/lib/Target/Blackfin/AsmPrinter/BlackfinAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/Blackfin/AsmPrinter/BlackfinAsmPrinter.cpp Sat Nov 7 03:20:54 2009 @@ -31,8 +31,8 @@ #include "llvm/Target/TargetRegistry.h" #include "llvm/Support/Mangler.h" #include "llvm/ADT/Statistic.h" +#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FormattedStream.h" - using namespace llvm; STATISTIC(EmittedInsts, "Number of machine instrs printed"); Modified: llvm/trunk/lib/Target/Blackfin/BlackfinISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Blackfin/BlackfinISelLowering.cpp?rev=86367&r1=86366&r2=86367&view=diff ============================================================================== --- llvm/trunk/lib/Target/Blackfin/BlackfinISelLowering.cpp (original) +++ llvm/trunk/lib/Target/Blackfin/BlackfinISelLowering.cpp Sat Nov 7 03:20:54 2009 @@ -25,7 +25,7 @@ #include "llvm/Target/TargetLoweringObjectFile.h" #include "llvm/ADT/VectorExtras.h" #include "llvm/Support/Debug.h" - +#include "llvm/Support/ErrorHandling.h" using namespace llvm; //===----------------------------------------------------------------------===// Modified: llvm/trunk/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp?rev=86367&r1=86366&r2=86367&view=diff ============================================================================== --- llvm/trunk/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp Sat Nov 7 03:20:54 2009 @@ -33,6 +33,7 @@ #include "llvm/Target/TargetLoweringObjectFile.h" #include "llvm/Target/TargetRegistry.h" #include "llvm/ADT/Statistic.h" +#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FormattedStream.h" #include "llvm/Support/Mangler.h" Modified: llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp?rev=86367&r1=86366&r2=86367&view=diff ============================================================================== --- llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp (original) +++ llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp Sat Nov 7 03:20:54 2009 @@ -34,6 +34,7 @@ #include "llvm/Target/TargetOptions.h" #include "llvm/Target/TargetLoweringObjectFile.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" #include "llvm/ADT/VectorExtras.h" using namespace llvm; Modified: llvm/trunk/lib/Target/SystemZ/SystemZInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SystemZ/SystemZInstrInfo.cpp?rev=86367&r1=86366&r2=86367&view=diff ============================================================================== --- llvm/trunk/lib/Target/SystemZ/SystemZInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/SystemZ/SystemZInstrInfo.cpp Sat Nov 7 03:20:54 2009 @@ -22,7 +22,7 @@ #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/CodeGen/PseudoSourceValue.h" - +#include "llvm/Support/ErrorHandling.h" using namespace llvm; SystemZInstrInfo::SystemZInstrInfo(SystemZTargetMachine &tm) Modified: llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp?rev=86367&r1=86366&r2=86367&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp (original) +++ llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Sat Nov 7 03:20:54 2009 @@ -24,6 +24,7 @@ #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetOptions.h" +#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/Mangler.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringExtras.h" @@ -151,7 +152,7 @@ // relocation, then we may have to drop this into a wriable data section // even though it is marked const. switch (C->getRelocationInfo()) { - default: llvm_unreachable("unknown relocation info kind"); + default: assert(0 && "unknown relocation info kind"); case Constant::NoRelocation: // If initializer is a null-terminated string, put it in a "cstring" // section of the right width. @@ -219,7 +220,7 @@ return SectionKind::getDataNoRel(); switch (C->getRelocationInfo()) { - default: llvm_unreachable("unknown relocation info kind"); + default: assert(0 && "unknown relocation info kind"); case Constant::NoRelocation: return SectionKind::getDataNoRel(); case Constant::LocalRelocation: Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp?rev=86367&r1=86366&r2=86367&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp Sat Nov 7 03:20:54 2009 @@ -21,6 +21,7 @@ #include "llvm/MC/MCExpr.h" #include "llvm/MC/MCInst.h" #include "llvm/MC/MCStreamer.h" +#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FormattedStream.h" #include "llvm/Support/Mangler.h" #include "llvm/ADT/SmallString.h" From sabre at nondot.org Sat Nov 7 03:23:04 2009 From: sabre at nondot.org (Chris Lattner) Date: Sat, 07 Nov 2009 09:23:04 -0000 Subject: [llvm-commits] [llvm] r86369 - in /llvm/trunk: include/llvm/Target/TargetData.h lib/Target/TargetData.cpp Message-ID: <200911070923.nA79N4DK010220@zion.cs.uiuc.edu> Author: lattner Date: Sat Nov 7 03:23:04 2009 New Revision: 86369 URL: http://llvm.org/viewvc/llvm-project?rev=86369&view=rev Log: more cleanup. Modified: llvm/trunk/include/llvm/Target/TargetData.h llvm/trunk/lib/Target/TargetData.cpp Modified: llvm/trunk/include/llvm/Target/TargetData.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetData.h?rev=86369&r1=86368&r2=86369&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetData.h (original) +++ llvm/trunk/include/llvm/Target/TargetData.h Sat Nov 7 03:23:04 2009 @@ -21,10 +21,7 @@ #define LLVM_TARGET_TARGETDATA_H #include "llvm/Pass.h" -#include "llvm/System/DataTypes.h" -#include "llvm/Support/ErrorHandling.h" #include "llvm/ADT/SmallVector.h" -#include namespace llvm { @@ -73,18 +70,16 @@ unsigned char PointerABIAlign; ///< Pointer ABI alignment unsigned char PointerPrefAlign; ///< Pointer preferred alignment - //! Where the primitive type alignment data is stored. - /*! - @sa init(). - @note Could support multiple size pointer alignments, e.g., 32-bit pointers - vs. 64-bit pointers by extending TargetAlignment, but for now, we don't. - */ + /// Alignments- Where the primitive type alignment data is stored. + /// + /// @sa init(). + /// @note Could support multiple size pointer alignments, e.g., 32-bit + /// pointers vs. 64-bit pointers by extending TargetAlignment, but for now, + /// we don't. SmallVector Alignments; - //! Alignment iterator shorthand - typedef SmallVector::iterator align_iterator; - //! Constant alignment iterator shorthand - typedef SmallVector::const_iterator align_const_iterator; - //! Invalid alignment. + + + /*! This member is a signal that a requested alignment type and bit width were not found in the SmallVector. @@ -92,7 +87,7 @@ static const TargetAlignElem InvalidAlignmentElem; // Opaque pointer for the StructType -> StructLayout map. - mutable void* LayoutMap; + mutable void *LayoutMap; //! Set/initialize target alignments void setAlignment(AlignTypeEnum align_type, unsigned char abi_align, @@ -106,8 +101,8 @@ /// /// Predicate that tests a TargetAlignElem reference returned by get() against /// InvalidAlignmentElem. - inline bool validAlignment(const TargetAlignElem &align) const { - return (&align != &InvalidAlignmentElem); + bool validAlignment(const TargetAlignElem &align) const { + return &align != &InvalidAlignmentElem; } public: @@ -115,11 +110,8 @@ /// /// @note This has to exist, because this is a pass, but it should never be /// used. - TargetData() : ImmutablePass(&ID) { - llvm_report_error("Bad TargetData ctor used. " - "Tool did not specify a TargetData to use?"); - } - + TargetData(); + /// Constructs a TargetData from a specification string. See init(). explicit TargetData(StringRef TargetDescription) : ImmutablePass(&ID) { Modified: llvm/trunk/lib/Target/TargetData.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetData.cpp?rev=86369&r1=86368&r2=86369&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetData.cpp (original) +++ llvm/trunk/lib/Target/TargetData.cpp Sat Nov 7 03:23:04 2009 @@ -258,6 +258,15 @@ } } +/// Default ctor. +/// +/// @note This has to exist, because this is a pass, but it should never be +/// used. +TargetData::TargetData() : ImmutablePass(&ID) { + llvm_report_error("Bad TargetData ctor used. " + "Tool did not specify a TargetData to use?"); +} + TargetData::TargetData(const Module *M) : ImmutablePass(&ID) { init(M->getDataLayout()); @@ -405,10 +414,11 @@ OS << (LittleEndian ? "e" : "E") << "-p:" << PointerMemSize*8 << ':' << PointerABIAlign*8 << ':' << PointerPrefAlign*8; - for (align_const_iterator I = Alignments.begin(), E = Alignments.end(); - I != E; ++I) - OS << '-' << (char)I->AlignType << I->TypeBitWidth << ':' - << I->ABIAlign*8 << ':' << I->PrefAlign*8; + for (unsigned i = 0, e = Alignments.size(); i != e; ++i) { + const TargetAlignElem &AI = Alignments[i]; + OS << '-' << (char)AI.AlignType << AI.TypeBitWidth << ':' + << AI.ABIAlign*8 << ':' << AI.PrefAlign*8; + } return OS.str(); } From sabre at nondot.org Sat Nov 7 03:35:35 2009 From: sabre at nondot.org (Chris Lattner) Date: Sat, 07 Nov 2009 09:35:35 -0000 Subject: [llvm-commits] [llvm] r86370 - in /llvm/trunk: docs/LangRef.html include/llvm/Target/TargetData.h lib/Target/TargetData.cpp Message-ID: <200911070935.nA79ZZhG010615@zion.cs.uiuc.edu> Author: lattner Date: Sat Nov 7 03:35:34 2009 New Revision: 86370 URL: http://llvm.org/viewvc/llvm-project?rev=86370&view=rev Log: add the ability for TargetData to return information about legal integer datatypes on a given CPU. This is intended to allow instcombine and other transformations to avoid converting big sequences of operations to an inconvenient width, and will help clean up after SRoA. See also "Adding legal integer sizes to TargetData" on Feb 1, 2009 on llvmdev, and PR3451. Comments welcome. Modified: llvm/trunk/docs/LangRef.html llvm/trunk/include/llvm/Target/TargetData.h llvm/trunk/lib/Target/TargetData.cpp Modified: llvm/trunk/docs/LangRef.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/LangRef.html?rev=86370&r1=86369&r2=86370&view=diff ============================================================================== --- llvm/trunk/docs/LangRef.html (original) +++ llvm/trunk/docs/LangRef.html Sat Nov 7 03:35:34 2009 @@ -1215,6 +1215,13 @@
                          ssize:abi:pref
                          This specifies the alignment for a stack object of a given bit size.
                          + +
                          nsize1:size2:size3...
                          +
                          This specifies a set of native integer widths for the target CPU + in bits. For example, it might contain "n32" for 32-bit PowerPC, + "n32:64" for PowerPC 64, or "n8:16:32:64" for X86-64. Elements of + this set are considered to support most general arithmetic + operations efficiently.

                          When constructing the data layout for a given target, LLVM starts with a Modified: llvm/trunk/include/llvm/Target/TargetData.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetData.h?rev=86370&r1=86369&r2=86370&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetData.h (original) +++ llvm/trunk/include/llvm/Target/TargetData.h Sat Nov 7 03:35:34 2009 @@ -70,6 +70,8 @@ unsigned char PointerABIAlign; ///< Pointer ABI alignment unsigned char PointerPrefAlign; ///< Pointer preferred alignment + SmallVector LegalIntWidths; ///< Legal Integers. + /// Alignments- Where the primitive type alignment data is stored. /// /// @sa init(). @@ -78,12 +80,8 @@ /// we don't. SmallVector Alignments; - - - /*! - This member is a signal that a requested alignment type and bit width were - not found in the SmallVector. - */ + /// InvalidAlignmentElem - This member is a signal that a requested alignment + /// type and bit width were not found in the SmallVector. static const TargetAlignElem InvalidAlignmentElem; // Opaque pointer for the StructType -> StructLayout map. @@ -127,6 +125,7 @@ PointerMemSize(TD.PointerMemSize), PointerABIAlign(TD.PointerABIAlign), PointerPrefAlign(TD.PointerPrefAlign), + LegalIntWidths(TD.LegalIntWidths), Alignments(TD.Alignments), LayoutMap(0) { } @@ -137,13 +136,33 @@ void init(StringRef TargetDescription); /// Target endianness... - bool isLittleEndian() const { return LittleEndian; } - bool isBigEndian() const { return !LittleEndian; } + bool isLittleEndian() const { return LittleEndian; } + bool isBigEndian() const { return !LittleEndian; } /// getStringRepresentation - Return the string representation of the /// TargetData. This representation is in the same format accepted by the /// string constructor above. std::string getStringRepresentation() const; + + + /// isIllegalInteger - This function returns true if the specified type is + /// known to not be a native integer type supported by the CPU. For example, + /// i64 is not native on most 32-bit CPUs and i37 is not native on any known + /// one. This returns false if the integer width is legal or we don't know. + /// + /// The width is specified in bits. + /// + bool isIllegalInteger(unsigned Width) const { + // If we don't have information about legal integer types, don't claim the + // type is illegal. + if (LegalIntWidths.empty()) return false; + + for (unsigned i = 0, e = LegalIntWidths.size(); i != e; ++i) + if (LegalIntWidths[i] == Width) + return false; + return true; + } + /// Target pointer alignment unsigned char getPointerABIAlignment() const { return PointerABIAlign; } /// Return target's alignment for stack-based pointers Modified: llvm/trunk/lib/Target/TargetData.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetData.cpp?rev=86370&r1=86369&r2=86370&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetData.cpp (original) +++ llvm/trunk/lib/Target/TargetData.cpp Sat Nov 7 03:35:34 2009 @@ -139,45 +139,7 @@ return Result; } -/*! - A TargetDescription string consists of a sequence of hyphen-delimited - specifiers for target endianness, pointer size and alignments, and various - primitive type sizes and alignments. A typical string looks something like: -

                          - "E-p:32:32:32-i1:8:8-i8:8:8-i32:32:32-i64:32:64-f32:32:32-f64:32:64" -

                          - (note: this string is not fully specified and is only an example.) - \p - Alignments come in two flavors: ABI and preferred. ABI alignment (abi_align, - below) dictates how a type will be aligned within an aggregate and when used - as an argument. Preferred alignment (pref_align, below) determines a type's - alignment when emitted as a global. - \p - Specifier string details: -

                          - [E|e]: Endianness. "E" specifies a big-endian target data model, "e" - specifies a little-endian target data model. -

                          - p:@verbatim::@endverbatim: Pointer size, - ABI and preferred alignment. -

                          - @verbatim::@endverbatim: Numeric type - alignment. Type is - one of i|f|v|a, corresponding to integer, floating point, vector, or - aggregate. Size indicates the size, e.g., 32 or 64 bits. - \p - The default string, fully specified, is: -

                          - "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64" - "-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64" - "-v64:64:64-v128:128:128" -

                          - Note that in the case of aggregates, 0 is the default ABI and preferred - alignment. This is a special case, where the aggregate's computed worst-case - alignment will be used. - */ void TargetData::init(StringRef Desc) { - LayoutMap = 0; LittleEndian = false; PointerMemSize = 8; @@ -210,7 +172,7 @@ assert(!Specifier.empty() && "Can't be empty here"); - switch(Specifier[0]) { + switch (Specifier[0]) { case 'E': LittleEndian = false; break; @@ -252,6 +214,17 @@ setAlignment(AlignType, ABIAlign, PrefAlign, Size); break; } + case 'n': // Native integer types. + Specifier = Specifier.substr(1); + do { + if (unsigned Width = getInt(Specifier)) + LegalIntWidths.push_back(Width); + Split = Token.split(':'); + Specifier = Split.first; + Token = Split.second; + } while (!Specifier.empty() || !Token.empty()); + break; + default: break; } From echristo at apple.com Sat Nov 7 03:57:16 2009 From: echristo at apple.com (Eric Christopher) Date: Sat, 07 Nov 2009 09:57:16 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r86371 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Message-ID: <200911070957.nA79vG3F011334@zion.cs.uiuc.edu> Author: echristo Date: Sat Nov 7 03:57:16 2009 New Revision: 86371 URL: http://llvm.org/viewvc/llvm-project?rev=86371&view=rev Log: Third time is the charm. Enable __builtin_object_size codegen via intrinsic. Coerce return type to size_t. Tested via bootstrap on x86-darwin10. 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=86371&r1=86370&r2=86371&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Sat Nov 7 03:57:16 2009 @@ -4909,12 +4909,12 @@ return EmitBuiltinUnwindInit(exp, Result); case BUILT_IN_OBJECT_SIZE: { - tree ArgList = TREE_OPERAND (exp, 1); - if (!validate_arglist(ArgList, POINTER_TYPE, INTEGER_TYPE, VOID_TYPE)) { + tree arglist = TREE_OPERAND (exp, 1); + if (!validate_arglist(arglist, POINTER_TYPE, INTEGER_TYPE, VOID_TYPE)) { error("Invalid builtin_object_size argument types"); return false; } - tree ObjSizeTree = TREE_VALUE (TREE_CHAIN (ArgList)); + tree ObjSizeTree = TREE_VALUE (TREE_CHAIN (arglist)); STRIP_NOPS (ObjSizeTree); if (TREE_CODE (ObjSizeTree) != INTEGER_CST || tree_int_cst_sgn (ObjSizeTree) < 0 @@ -4923,12 +4923,26 @@ return false; } - // This treats everything as unknown, and is minimally defensible as - // correct, although completely useless. - if (tree_low_cst (ObjSizeTree, 0) < 2) - Result = Constant::getAllOnesValue(TD.getIntPtrType(Context)); - else - Result = ConstantInt::get(TD.getIntPtrType(Context), 0); + tree Object = TREE_VALUE(arglist); + tree ObjTy = TREE_VALUE(TREE_CHAIN(arglist)); + + Value* Args[] = { + Emit(Object, 0), + Emit(ObjTy, 0) + }; + + // Grab the current return type. + const Type* Ty; + Ty = ConvertType(TREE_TYPE(exp)); + + // Manually coerce the arg to the correct pointer type. + Args[0] = Builder.CreateBitCast(Args[0], Type::getInt8PtrTy(Context)); + + Result = Builder.CreateCall(Intrinsic::getDeclaration(TheModule, + Intrinsic::objectsize, + &Ty, + 1), + Args, Args + 2); return true; } // Unary bit counting intrinsics. From anton at korobeynikov.info Sat Nov 7 06:18:17 2009 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Sat, 7 Nov 2009 15:18:17 +0300 Subject: [llvm-commits] [llvm] r86354 - in /llvm/trunk: lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp lib/CodeGen/SelectionDAG/SelectionDAGBuild.h test/CodeGen/Generic/switch-lower.ll In-Reply-To: <200911070750.nA77oY61025698@zion.cs.uiuc.edu> References: <200911070750.nA77oY61025698@zion.cs.uiuc.edu> Message-ID: > Fix PR5421 by APInt'izing switch lowering. Wow! Thanks, Chris! I really thought switch lowering was already APInt'ized... -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From asl at math.spbu.ru Sat Nov 7 09:20:32 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Sat, 07 Nov 2009 15:20:32 -0000 Subject: [llvm-commits] [llvm] r86375 - in /llvm/trunk: lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp lib/Target/ARM/AsmPrinter/ARMMCInstLower.cpp test/CodeGen/ARM/2009-11-07-SubRegAsmPrinting.ll Message-ID: <200911071520.nA7FKXUV022257@zion.cs.uiuc.edu> Author: asl Date: Sat Nov 7 09:20:32 2009 New Revision: 86375 URL: http://llvm.org/viewvc/llvm-project?rev=86375&view=rev Log: It turns out that the testcase in question uncovered subreg-handling bug. Add assert in asmprinter to catch such cases and xfail the tests. PR is to be filled. Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp llvm/trunk/lib/Target/ARM/AsmPrinter/ARMMCInstLower.cpp llvm/trunk/test/CodeGen/ARM/2009-11-07-SubRegAsmPrinting.ll 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=86375&r1=86374&r2=86375&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Sat Nov 7 09:20:32 2009 @@ -347,9 +347,7 @@ &ARM::DPR_VFP2RegClass); O << getRegisterName(DReg) << '[' << (RegNum & 1) << ']'; } else { - if (unsigned SubReg = MO.getSubReg()) - Reg = TRI->getSubReg(Reg, SubReg); - + assert(!MO.getSubReg() && "Subregs should be eliminated!"); O << getRegisterName(Reg); } break; Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMMCInstLower.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmPrinter/ARMMCInstLower.cpp?rev=86375&r1=86374&r2=86375&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMMCInstLower.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMMCInstLower.cpp Sat Nov 7 09:20:32 2009 @@ -137,6 +137,7 @@ case MachineOperand::MO_Register: // Ignore all implicit register operands. if (MO.isImplicit()) continue; + assert(!MO.getSubReg() && "Subregs should be eliminated!"); MCOp = MCOperand::CreateReg(MO.getReg()); break; case MachineOperand::MO_Immediate: Modified: llvm/trunk/test/CodeGen/ARM/2009-11-07-SubRegAsmPrinting.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/2009-11-07-SubRegAsmPrinting.ll?rev=86375&r1=86374&r2=86375&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/2009-11-07-SubRegAsmPrinting.ll (original) +++ llvm/trunk/test/CodeGen/ARM/2009-11-07-SubRegAsmPrinting.ll Sat Nov 7 09:20:32 2009 @@ -1,4 +1,5 @@ ; RUN: llc -mcpu=cortex-a8 < %s | FileCheck %s +; XFAIL: * target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64" target triple = "armv7-eabi" From asl at math.spbu.ru Sat Nov 7 09:18:50 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Sat, 07 Nov 2009 18:18:50 +0300 Subject: [llvm-commits] [llvm] r86303 - in /llvm/trunk: lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp test/CodeGen/ARM/2009-11-07-SubRegAsmPrinting.ll In-Reply-To: <0FEA2F07-E2F5-4CEE-B54B-91D18D73A85C@apple.com> References: <200911062345.nA6NjG1Y009900@zion.cs.uiuc.edu> <07E87410-00C7-444B-981B-E80A8B79B75A@apple.com> <0FEA2F07-E2F5-4CEE-B54B-91D18D73A85C@apple.com> Message-ID: <1257607130.32230.493.camel@aslstation> Hi, Chris > Ok, can you revert the ARM Asmprinter change or at least comment it > violently so that when I get back to MC'izing ARM that I will know to > delete it? I reverted the change, added asserts, xfailed the testcase (however, it will fail with mcinst printer anyway, since fpimm operands are not yet supported) and filled the PR :) -- With best regards, Anton Korobeynikov. Faculty of Mathematics & Mechanics, Saint Petersburg State University. From Jan.Sjodin at amd.com Sat Nov 7 09:55:09 2009 From: Jan.Sjodin at amd.com (Sjodin, Jan) Date: Sat, 7 Nov 2009 07:55:09 -0800 Subject: [llvm-commits] Patch for scalarized division. In-Reply-To: References: <1C8DE0332CB01445BF7ADEDE3DDD57071958CF9F@sausexmbp02.amd.com> Message-ID: <1C8DE0332CB01445BF7ADEDE3DDD57071958D1D1@sausexmbp02.amd.com> I agree that this is not the ideal way to do things, and the list of operations is indeed incomplete and may be different on different targets. The problem is that the type legalization is done without taking the operations into account. A more general solution would be to combine the type and ops legalization into one pass. A somewhat simpler solution could be to scalarize operations first, then do the type legalization and finally apply the non-scalarizing legalize vector ops. I do not know if there are any cases where legalization needs more information about the surrounding operations to produce correct code. - Jan ________________________________ From: Mon Ping Wang [mailto:wangmp at apple.com] Sent: Friday, November 06, 2009 11:59 PM To: Sjodin, Jan Cc: 'llvm-commits at cs.uiuc.edu' Subject: Re: [llvm-commits] Patch for scalarized division. Hi Jan, Some quick comments about the patch. @@ -282,6 +289,95 @@ SDValue VectorLegalizer::UnrollVSETCC(SD +bool VectorLegalizer::rangeIsDefined(SDValue Op, + uint64_t LoBitIndex, + uint64_t HiBitIndex) +{ +[Deleted Code] + case ISD::ADD: + case ISD::SUB: + case ISD::MUL: + case ISD::SDIV: + case ISD::UDIV: + case ISD::SREM: + case ISD::UREM: { We should expand the list will have to expand to almost all operators. For example, an ISD::AND or ISD::XOR could cause the same problem as well as VECTOR_SHUFFLE. @@ -326,6 +422,16 @@ SDValue VectorLegalizer::UnrollVectorOp( Scalars.push_back(DAG.getNode(Op.getOpcode(), dl, EltVT, Operands[0], DAG.getShiftAmountOperand(Operands[1]))); break; + // Ensure that both operands are defined, if not, the result will + // be undefined. + case ISD::SDIV: + case ISD::UDIV: For some machines, SREM and UREM could have the same issue. This is a generic issue that goes beyond just SDIV/UDIV. In the majority of these cases, I think we should try to avoid generating operations for UNDEF. The only cases that give me pause of doing this all the time are operations like multiplication by 0, and of 0, etc.. where the UNDEF would be defined. The only other thing is that we recursively walk up an expression tree. If the expression tree is deep, this could cost some time. The main culprit that causes these UNDEF is due to widening. A crazy idea to avoid doing this is if a hardware knows a particular operation should not be widened, maybe it could use a target hook to scalarize the operation early doing LegalizeTypes. For X86, since divides will not be vector operations, we would avoid widening them only to lower them and work hard trying to avoid generating the extra divides. -- Mon Ping On Nov 6, 2009, at 1:39 PM, Sjodin, Jan wrote: In LegalizeVectorOps the resulting scalar divisions must not be generated if they have undefined vector elements as operands. This may be unsafe because the divides can cause division by zero exceptions, and also slows down the code. This patch attempts to fix this issue by checking if the operands are defined or not. I would be grateful if someone could review this patch. Thanks! - Jan Sjodin<0015_scalarized_div.diff>_______________________________________________ llvm-commits mailing list llvm-commits at cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091107/05655274/attachment.html From asl at math.spbu.ru Sat Nov 7 11:12:21 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Sat, 07 Nov 2009 17:12:21 -0000 Subject: [llvm-commits] [llvm] r86379 - in /llvm/trunk/lib/Target/MSP430: AsmPrinter/MSP430AsmPrinter.cpp AsmPrinter/MSP430InstPrinter.cpp MSP430.td Message-ID: <200911071712.nA7HCM12025787@zion.cs.uiuc.edu> Author: asl Date: Sat Nov 7 11:12:21 2009 New Revision: 86379 URL: http://llvm.org/viewvc/llvm-project?rev=86379&view=rev Log: Drop old asmprinter stuff Modified: llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430InstPrinter.cpp llvm/trunk/lib/Target/MSP430/MSP430.td Modified: llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp?rev=86379&r1=86378&r2=86379&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp Sat Nov 7 11:12:21 2009 @@ -70,9 +70,6 @@ void printSrcMemOperand(const MachineInstr *MI, int OpNum, const char* Modifier = 0); void printCCOperand(const MachineInstr *MI, int OpNum); - void printInstruction(const MachineInstr *MI); // autogenerated. - static const char *getRegisterName(unsigned RegNo); - void printMachineInstruction(const MachineInstr * MI); bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, unsigned AsmVariant, @@ -96,9 +93,6 @@ }; } // end of anonymous namespace -#include "MSP430GenAsmWriter.inc" - - void MSP430AsmPrinter::emitFunctionHeader(const MachineFunction &MF) { const Function *F = MF.getFunction(); @@ -161,12 +155,7 @@ processDebugLoc(MI, true); - // Call the autogenerated instruction printer routines. - if (EnableMCInst) { - printInstructionThroughMCStreamer(MI); - } else { - printInstruction(MI); - } + printInstructionThroughMCStreamer(MI); if (VerboseAsm && !MI->getDebugLoc().isUnknown()) EmitComments(*MI); @@ -180,7 +169,7 @@ const MachineOperand &MO = MI->getOperand(OpNum); switch (MO.getType()) { case MachineOperand::MO_Register: - O << getRegisterName(MO.getReg()); + O << MSP430InstPrinter::getRegisterName(MO.getReg()); return; case MachineOperand::MO_Immediate: if (!Modifier || strcmp(Modifier, "nohash")) @@ -294,8 +283,7 @@ } //===----------------------------------------------------------------------===// -void MSP430AsmPrinter::printInstructionThroughMCStreamer(const MachineInstr *MI) -{ +void MSP430AsmPrinter::printInstructionThroughMCStreamer(const MachineInstr *MI){ MSP430MCInstLower MCInstLowering(OutContext, *Mang, *this); @@ -323,7 +311,18 @@ printMCInst(&TmpInst); } +static MCInstPrinter *createMSP430MCInstPrinter(const Target &T, + unsigned SyntaxVariant, + const MCAsmInfo &MAI, + raw_ostream &O) { + if (SyntaxVariant == 0) + return new MSP430InstPrinter(O, MAI); + return 0; +} + // Force static initialization. extern "C" void LLVMInitializeMSP430AsmPrinter() { RegisterAsmPrinter X(TheMSP430Target); + TargetRegistry::RegisterMCInstPrinter(TheMSP430Target, + createMSP430MCInstPrinter); } Modified: llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430InstPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430InstPrinter.cpp?rev=86379&r1=86378&r2=86379&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430InstPrinter.cpp (original) +++ llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430InstPrinter.cpp Sat Nov 7 11:12:21 2009 @@ -25,11 +25,9 @@ // Include the auto-generated portion of the assembly writer. #define MachineInstr MCInst -#define MSP430AsmPrinter MSP430InstPrinter // FIXME: REMOVE. #define NO_ASM_WRITER_BOILERPLATE #include "MSP430GenAsmWriter.inc" #undef MachineInstr -#undef MSP430AsmPrinter void MSP430InstPrinter::printInst(const MCInst *MI) { printInstruction(MI); Modified: llvm/trunk/lib/Target/MSP430/MSP430.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430.td?rev=86379&r1=86378&r2=86379&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430.td (original) +++ llvm/trunk/lib/Target/MSP430/MSP430.td Sat Nov 7 11:12:21 2009 @@ -50,11 +50,17 @@ def MSP430InstrInfo : InstrInfo {} + +def MSP430InstPrinter : AsmWriter { + string AsmWriterClassName = "InstPrinter"; +} + //===----------------------------------------------------------------------===// // Target Declaration //===----------------------------------------------------------------------===// def MSP430 : Target { let InstructionSet = MSP430InstrInfo; + let AssemblyWriters = [MSP430InstPrinter]; } From asl at math.spbu.ru Sat Nov 7 11:12:38 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Sat, 07 Nov 2009 17:12:38 -0000 Subject: [llvm-commits] [llvm] r86380 - /llvm/trunk/lib/Target/MSP430/MSP430MCAsmInfo.cpp Message-ID: <200911071712.nA7HCcLa025814@zion.cs.uiuc.edu> Author: asl Date: Sat Nov 7 11:12:38 2009 New Revision: 86380 URL: http://llvm.org/viewvc/llvm-project?rev=86380&view=rev Log: Use '.L' for global private prefix (as mspgcc) Modified: llvm/trunk/lib/Target/MSP430/MSP430MCAsmInfo.cpp Modified: llvm/trunk/lib/Target/MSP430/MSP430MCAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430MCAsmInfo.cpp?rev=86380&r1=86379&r2=86380&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430MCAsmInfo.cpp (original) +++ llvm/trunk/lib/Target/MSP430/MSP430MCAsmInfo.cpp Sat Nov 7 11:12:38 2009 @@ -17,4 +17,5 @@ MSP430MCAsmInfo::MSP430MCAsmInfo(const Target &T, const StringRef &TT) { AlignmentIsInBytes = false; AllowNameToStartWithDigit = true; + PrivateGlobalPrefix = ".L"; } From asl at math.spbu.ru Sat Nov 7 11:12:58 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Sat, 07 Nov 2009 17:12:58 -0000 Subject: [llvm-commits] [llvm] r86381 - in /llvm/trunk/lib/Target/MSP430: AsmPrinter/MSP430AsmPrinter.cpp MSP430MCAsmInfo.cpp README.txt Message-ID: <200911071712.nA7HCwNK025837@zion.cs.uiuc.edu> Author: asl Date: Sat Nov 7 11:12:58 2009 New Revision: 86381 URL: http://llvm.org/viewvc/llvm-project?rev=86381&view=rev Log: Some preliminary variable asmprinting Modified: llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp llvm/trunk/lib/Target/MSP430/MSP430MCAsmInfo.cpp llvm/trunk/lib/Target/MSP430/README.txt Modified: llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp?rev=86381&r1=86380&r2=86381&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp Sat Nov 7 11:12:58 2009 @@ -22,6 +22,7 @@ #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" #include "llvm/Module.h" +#include "llvm/Assembly/Writer.h" #include "llvm/CodeGen/AsmPrinter.h" #include "llvm/CodeGen/DwarfWriter.h" #include "llvm/CodeGen/MachineModuleInfo.h" @@ -79,13 +80,10 @@ const char *ExtraCode); void printInstructionThroughMCStreamer(const MachineInstr *MI); + void PrintGlobalVariable(const GlobalVariable* GVar); void emitFunctionHeader(const MachineFunction &MF); bool runOnMachineFunction(MachineFunction &F); - virtual void PrintGlobalVariable(const GlobalVariable *GV) { - // FIXME: No support for global variables? - } - void getAnalysisUsage(AnalysisUsage &AU) const { AsmPrinter::getAnalysisUsage(AU); AU.setPreservesAll(); @@ -93,6 +91,90 @@ }; } // end of anonymous namespace +void MSP430AsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) { + if (!GVar->hasInitializer()) + return; // External global require no code + + // Check to see if this is a special global used by LLVM, if so, emit it. + if (EmitSpecialLLVMGlobal(GVar)) + return; + + const TargetData *TD = TM.getTargetData(); + + std::string name = Mang->getMangledName(GVar); + Constant *C = GVar->getInitializer(); + unsigned Size = TD->getTypeAllocSize(C->getType()); + unsigned Align = TD->getPreferredAlignmentLog(GVar); + + printVisibility(name, GVar->getVisibility()); + + O << "\t.type\t" << name << ", at object\n"; + + OutStreamer.SwitchSection(getObjFileLowering().SectionForGlobal(GVar, Mang, + TM)); + + if (C->isNullValue() && !GVar->hasSection() && + !GVar->isThreadLocal() && + (GVar->hasLocalLinkage() || GVar->isWeakForLinker())) { + + if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it. + + if (GVar->hasLocalLinkage()) + O << "\t.local\t" << name << '\n'; + + O << MAI->getCOMMDirective() << name << ',' << Size; + if (MAI->getCOMMDirectiveTakesAlignment()) + O << ',' << (MAI->getAlignmentIsInBytes() ? (1 << Align) : Align); + + if (VerboseAsm) { + O.PadToColumn(MAI->getCommentColumn()); + O << MAI->getCommentString() << ' '; + WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent()); + } + O << '\n'; + return; + } + + switch (GVar->getLinkage()) { + case GlobalValue::CommonLinkage: + case GlobalValue::LinkOnceAnyLinkage: + case GlobalValue::LinkOnceODRLinkage: + case GlobalValue::WeakAnyLinkage: + case GlobalValue::WeakODRLinkage: + O << "\t.weak\t" << name << '\n'; + break; + case GlobalValue::DLLExportLinkage: + case GlobalValue::AppendingLinkage: + // FIXME: appending linkage variables should go into a section of + // their name or something. For now, just emit them as external. + case GlobalValue::ExternalLinkage: + // If external or appending, declare as a global symbol + O << "\t.globl " << name << '\n'; + // FALL THROUGH + case GlobalValue::PrivateLinkage: + case GlobalValue::LinkerPrivateLinkage: + case GlobalValue::InternalLinkage: + break; + default: + assert(0 && "Unknown linkage type!"); + } + + // Use 16-bit alignment by default to simplify bunch of stuff + EmitAlignment(Align, GVar); + O << name << ":"; + if (VerboseAsm) { + O.PadToColumn(MAI->getCommentColumn()); + O << MAI->getCommentString() << ' '; + WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent()); + } + O << '\n'; + + EmitGlobalConstant(C); + + if (MAI->hasDotTypeDotSizeDirective()) + O << "\t.size\t" << name << ", " << Size << '\n'; +} + void MSP430AsmPrinter::emitFunctionHeader(const MachineFunction &MF) { const Function *F = MF.getFunction(); Modified: llvm/trunk/lib/Target/MSP430/MSP430MCAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430MCAsmInfo.cpp?rev=86381&r1=86380&r2=86381&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430MCAsmInfo.cpp (original) +++ llvm/trunk/lib/Target/MSP430/MSP430MCAsmInfo.cpp Sat Nov 7 11:12:58 2009 @@ -15,7 +15,12 @@ using namespace llvm; MSP430MCAsmInfo::MSP430MCAsmInfo(const Target &T, const StringRef &TT) { + PrivateGlobalPrefix = ".L"; + WeakRefDirective ="\t.weak\t"; + SetDirective = "\t.set\t"; + PCSymbol="."; + AlignmentIsInBytes = false; AllowNameToStartWithDigit = true; - PrivateGlobalPrefix = ".L"; + UsesELFSectionDirectiveForBSS = true; } Modified: llvm/trunk/lib/Target/MSP430/README.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/README.txt?rev=86381&r1=86380&r2=86381&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/README.txt (original) +++ llvm/trunk/lib/Target/MSP430/README.txt Sat Nov 7 11:12:58 2009 @@ -11,8 +11,6 @@ Some things are incomplete / not implemented yet (this list surely is not complete as well): -0. Implement asmprinting for variables :) - 1. Verify, how stuff is handling implicit zext with 8 bit operands (this might be modelled currently in improper way - should we need to mark the superreg as def for every 8 bit instruction?). From asl at math.spbu.ru Sat Nov 7 11:13:35 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Sat, 07 Nov 2009 17:13:35 -0000 Subject: [llvm-commits] [llvm] r86382 - in /llvm/trunk: lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp lib/Target/MSP430/AsmPrinter/MSP430InstPrinter.cpp lib/Target/MSP430/MSP430ISelDAGToDAG.cpp test/CodeGen/MSP430/2009-09-18-AbsoluteAddr.ll test/CodeGen/MSP430/AddrMode-bis-rx.ll test/CodeGen/MSP430/AddrMode-bis-xr.ll test/CodeGen/MSP430/AddrMode-mov-rx.ll test/CodeGen/MSP430/AddrMode-mov-xr.ll test/CodeGen/MSP430/inline-asm.ll Message-ID: <200911071713.nA7HDawb025876@zion.cs.uiuc.edu> Author: asl Date: Sat Nov 7 11:13:35 2009 New Revision: 86382 URL: http://llvm.org/viewvc/llvm-project?rev=86382&view=rev Log: Initial support for addrmode handling. Tests by Brian Lucas! Added: llvm/trunk/test/CodeGen/MSP430/AddrMode-bis-rx.ll llvm/trunk/test/CodeGen/MSP430/AddrMode-bis-xr.ll llvm/trunk/test/CodeGen/MSP430/AddrMode-mov-rx.ll llvm/trunk/test/CodeGen/MSP430/AddrMode-mov-xr.ll Modified: llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430InstPrinter.cpp llvm/trunk/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp llvm/trunk/test/CodeGen/MSP430/2009-09-18-AbsoluteAddr.ll llvm/trunk/test/CodeGen/MSP430/inline-asm.ll Modified: llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp?rev=86382&r1=86381&r2=86382&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp Sat Nov 7 11:13:35 2009 @@ -295,22 +295,23 @@ const MachineOperand &Base = MI->getOperand(OpNum); const MachineOperand &Disp = MI->getOperand(OpNum+1); - if (Base.isGlobal()) - printOperand(MI, OpNum, "mem"); - else if (Disp.isImm() && !Base.getReg()) + // Print displacement first + if (!Disp.isImm()) { + printOperand(MI, OpNum+1, "mem"); + } else { + if (!Base.getReg()) + O << '&'; + + printOperand(MI, OpNum+1, "nohash"); + } + + + // Print register base field + if (Base.getReg()) { + O << '('; printOperand(MI, OpNum); - else if (Base.getReg()) { - if (Disp.getImm()) { - printOperand(MI, OpNum + 1, "nohash"); - O << '('; - printOperand(MI, OpNum); - O << ')'; - } else { - O << '@'; - printOperand(MI, OpNum); - } - } else - llvm_unreachable("Unsupported memory operand"); + O << ')'; + } } void MSP430AsmPrinter::printCCOperand(const MachineInstr *MI, int OpNum) { Modified: llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430InstPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430InstPrinter.cpp?rev=86382&r1=86381&r2=86382&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430InstPrinter.cpp (original) +++ llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430InstPrinter.cpp Sat Nov 7 11:13:35 2009 @@ -63,25 +63,22 @@ const MCOperand &Base = MI->getOperand(OpNo); const MCOperand &Disp = MI->getOperand(OpNo+1); - // FIXME: move global to displacement field! - if (Base.isExpr()) { + // Print displacement first + if (Disp.isExpr()) { O << '&'; - Base.getExpr()->print(O, &MAI); - } else if (Disp.isImm() && !Base.isReg()) - printOperand(MI, OpNo); - else if (Base.isReg()) { - if (Disp.getImm()) { - O << Disp.getImm() << '('; - printOperand(MI, OpNo); - O << ')'; - } else { - O << '@'; - printOperand(MI, OpNo); - } + Disp.getExpr()->print(O, &MAI); } else { - Base.dump(); - Disp.dump(); - llvm_unreachable("Unsupported memory operand"); + assert(Disp.isImm() && "Expected immediate in displacement field"); + if (!Base.getReg()) + O << '&'; + + O << Disp.getImm(); + } + + + // Print register base field + if (Base.getReg()) { + O << '(' << getRegisterName(Base.getReg()) << ')'; } } Modified: llvm/trunk/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp?rev=86382&r1=86381&r2=86382&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp Sat Nov 7 11:13:35 2009 @@ -45,6 +45,70 @@ STATISTIC(NumLoadMoved, "Number of loads moved below TokenFactor"); + +namespace { + struct MSP430ISelAddressMode { + enum { + RegBase, + FrameIndexBase + } BaseType; + + struct { // This is really a union, discriminated by BaseType! + SDValue Reg; + int FrameIndex; + } Base; + + int16_t Disp; + GlobalValue *GV; + Constant *CP; + BlockAddress *BlockAddr; + const char *ES; + int JT; + unsigned Align; // CP alignment. + + MSP430ISelAddressMode() + : BaseType(RegBase), Disp(0), GV(0), CP(0), BlockAddr(0), + ES(0), JT(-1), Align(0) { + } + + bool hasSymbolicDisplacement() const { + return GV != 0 || CP != 0 || ES != 0 || JT != -1; + } + + bool hasBaseReg() const { + return Base.Reg.getNode() != 0; + } + + void setBaseReg(SDValue Reg) { + BaseType = RegBase; + Base.Reg = Reg; + } + + void dump() { + errs() << "MSP430ISelAddressMode " << this << '\n'; + if (Base.Reg.getNode() != 0) { + errs() << "Base.Reg "; + Base.Reg.getNode()->dump(); + } else { + errs() << " Base.FrameIndex " << Base.FrameIndex << '\n'; + } + errs() << " Disp " << Disp << '\n'; + if (GV) { + errs() << "GV "; + GV->dump(); + } else if (CP) { + errs() << " CP "; + CP->dump(); + errs() << " Align" << Align << '\n'; + } else if (ES) { + errs() << "ES "; + errs() << ES << '\n'; + } else if (JT != -1) + errs() << " JT" << JT << " Align" << Align << '\n'; + } + }; +} + /// MSP430DAGToDAGISel - MSP430 specific code to select MSP430 machine /// instructions for SelectionDAG operations. /// @@ -65,6 +129,10 @@ return "MSP430 DAG->DAG Pattern Instruction Selection"; } + bool MatchAddress(SDValue N, MSP430ISelAddressMode &AM); + bool MatchWrapper(SDValue N, MSP430ISelAddressMode &AM); + bool MatchAddressBase(SDValue N, MSP430ISelAddressMode &AM); + bool IsLegalAndProfitableToFold(SDNode *N, SDNode *U, SDNode *Root) const; @@ -95,50 +163,155 @@ return new MSP430DAGToDAGISel(TM, OptLevel); } -// FIXME: This is pretty dummy routine and needs to be rewritten in the future. -bool MSP430DAGToDAGISel::SelectAddr(SDValue Op, SDValue Addr, - SDValue &Base, SDValue &Disp) { - // Try to match frame address first. - if (FrameIndexSDNode *FIN = dyn_cast(Addr)) { - Base = CurDAG->getTargetFrameIndex(FIN->getIndex(), MVT::i16); - Disp = CurDAG->getTargetConstant(0, MVT::i16); + +/// MatchWrapper - Try to match MSP430ISD::Wrapper node into an addressing mode. +/// These wrap things that will resolve down into a symbol reference. If no +/// match is possible, this returns true, otherwise it returns false. +bool MSP430DAGToDAGISel::MatchWrapper(SDValue N, MSP430ISelAddressMode &AM) { + // If the addressing mode already has a symbol as the displacement, we can + // never match another symbol. + if (AM.hasSymbolicDisplacement()) + return true; + + SDValue N0 = N.getOperand(0); + + if (GlobalAddressSDNode *G = dyn_cast(N0)) { + AM.GV = G->getGlobal(); + AM.Disp += G->getOffset(); + //AM.SymbolFlags = G->getTargetFlags(); + } else if (ConstantPoolSDNode *CP = dyn_cast(N0)) { + AM.CP = CP->getConstVal(); + AM.Align = CP->getAlignment(); + AM.Disp += CP->getOffset(); + //AM.SymbolFlags = CP->getTargetFlags(); + } else if (ExternalSymbolSDNode *S = dyn_cast(N0)) { + AM.ES = S->getSymbol(); + //AM.SymbolFlags = S->getTargetFlags(); + } else if (JumpTableSDNode *J = dyn_cast(N0)) { + AM.JT = J->getIndex(); + //AM.SymbolFlags = J->getTargetFlags(); + } else { + AM.BlockAddr = cast(N0)->getBlockAddress(); + //AM.SymbolFlags = cast(N0)->getTargetFlags(); + } + return false; +} + +/// MatchAddressBase - Helper for MatchAddress. Add the specified node to the +/// specified addressing mode without any further recursion. +bool MSP430DAGToDAGISel::MatchAddressBase(SDValue N, MSP430ISelAddressMode &AM) { + // Is the base register already occupied? + if (AM.BaseType != MSP430ISelAddressMode::RegBase || AM.Base.Reg.getNode()) { + // If so, we cannot select it. return true; } - switch (Addr.getOpcode()) { - case ISD::ADD: - // Operand is a result from ADD with constant operand which fits into i16. - if (ConstantSDNode *CN = dyn_cast(Addr.getOperand(1))) { - uint64_t CVal = CN->getZExtValue(); - // Offset should fit into 16 bits. - if (((CVal << 48) >> 48) == CVal) { - SDValue N0 = Addr.getOperand(0); - if (FrameIndexSDNode *FIN = dyn_cast(N0)) - Base = CurDAG->getTargetFrameIndex(FIN->getIndex(), MVT::i16); - else - Base = N0; + // Default, generate it as a register. + AM.BaseType = MSP430ISelAddressMode::RegBase; + AM.Base.Reg = N; + return false; +} - Disp = CurDAG->getTargetConstant(CVal, MVT::i16); - return true; - } +bool MSP430DAGToDAGISel::MatchAddress(SDValue N, MSP430ISelAddressMode &AM) { + DebugLoc dl = N.getDebugLoc(); + DEBUG({ + errs() << "MatchAddress: "; + AM.dump(); + }); + + switch (N.getOpcode()) { + default: break; + case ISD::Constant: { + uint64_t Val = cast(N)->getSExtValue(); + AM.Disp += Val; + return false; + } + + case MSP430ISD::Wrapper: + if (!MatchWrapper(N, AM)) + return false; + break; + + case ISD::FrameIndex: + if (AM.BaseType == MSP430ISelAddressMode::RegBase + && AM.Base.Reg.getNode() == 0) { + AM.BaseType = MSP430ISelAddressMode::FrameIndexBase; + AM.Base.FrameIndex = cast(N)->getIndex(); + return false; } break; - case MSP430ISD::Wrapper: - SDValue N0 = Addr.getOperand(0); - if (GlobalAddressSDNode *G = dyn_cast(N0)) { - Base = CurDAG->getTargetGlobalAddress(G->getGlobal(), - MVT::i16, G->getOffset()); - Disp = CurDAG->getTargetConstant(0, MVT::i16); - return true; - } else if (ExternalSymbolSDNode *E = dyn_cast(N0)) { - Base = CurDAG->getTargetExternalSymbol(E->getSymbol(), MVT::i16); - Disp = CurDAG->getTargetConstant(0, MVT::i16); + + case ISD::ADD: { + MSP430ISelAddressMode Backup = AM; + if (!MatchAddress(N.getNode()->getOperand(0), AM) && + !MatchAddress(N.getNode()->getOperand(1), AM)) + return false; + AM = Backup; + if (!MatchAddress(N.getNode()->getOperand(1), AM) && + !MatchAddress(N.getNode()->getOperand(0), AM)) + return false; + AM = Backup; + + break; + } + + case ISD::OR: + // Handle "X | C" as "X + C" iff X is known to have C bits clear. + if (ConstantSDNode *CN = dyn_cast(N.getOperand(1))) { + MSP430ISelAddressMode Backup = AM; + uint64_t Offset = CN->getSExtValue(); + // Start with the LHS as an addr mode. + if (!MatchAddress(N.getOperand(0), AM) && + // Address could not have picked a GV address for the displacement. + AM.GV == NULL && + // Check to see if the LHS & C is zero. + CurDAG->MaskedValueIsZero(N.getOperand(0), CN->getAPIntValue())) { + AM.Disp += Offset; + return false; + } + AM = Backup; } break; - }; + } - Base = Addr; - Disp = CurDAG->getTargetConstant(0, MVT::i16); + return MatchAddressBase(N, AM); +} + +/// SelectAddr - returns true if it is able pattern match an addressing mode. +/// It returns the operands which make up the maximal addressing mode it can +/// match by reference. +bool MSP430DAGToDAGISel::SelectAddr(SDValue Op, SDValue N, + SDValue &Base, SDValue &Disp) { + MSP430ISelAddressMode AM; + + if (MatchAddress(N, AM)) + return false; + + EVT VT = N.getValueType(); + if (AM.BaseType == MSP430ISelAddressMode::RegBase) { + if (!AM.Base.Reg.getNode()) + AM.Base.Reg = CurDAG->getRegister(0, VT); + } + + Base = (AM.BaseType == MSP430ISelAddressMode::FrameIndexBase) ? + CurDAG->getTargetFrameIndex(AM.Base.FrameIndex, TLI.getPointerTy()) : + AM.Base.Reg; + + if (AM.GV) + Disp = CurDAG->getTargetGlobalAddress(AM.GV, MVT::i16, AM.Disp, + 0/*AM.SymbolFlags*/); + else if (AM.CP) + Disp = CurDAG->getTargetConstantPool(AM.CP, MVT::i16, + AM.Align, AM.Disp, 0/*AM.SymbolFlags*/); + else if (AM.ES) + Disp = CurDAG->getTargetExternalSymbol(AM.ES, MVT::i16, 0/*AM.SymbolFlags*/); + else if (AM.JT != -1) + Disp = CurDAG->getTargetJumpTable(AM.JT, MVT::i16, 0/*AM.SymbolFlags*/); + else if (AM.BlockAddr) + Disp = CurDAG->getBlockAddress(AM.BlockAddr, DebugLoc()/*MVT::i32*/, + true /*AM.SymbolFlags*/); + else + Disp = CurDAG->getTargetConstant(AM.Disp, MVT::i16); return true; } Modified: llvm/trunk/test/CodeGen/MSP430/2009-09-18-AbsoluteAddr.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MSP430/2009-09-18-AbsoluteAddr.ll?rev=86382&r1=86381&r2=86382&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/MSP430/2009-09-18-AbsoluteAddr.ll (original) +++ llvm/trunk/test/CodeGen/MSP430/2009-09-18-AbsoluteAddr.ll Sat Nov 7 11:13:35 2009 @@ -3,7 +3,7 @@ target datalayout = "e-p:16:8:8-i8:8:8-i16:8:8-i32:8:8" target triple = "msp430-unknown-unknown" -@"\010x0021" = common global i8 0, align 1 ; [#uses=2] +@"\010x0021" = external global i8, align 1 ; [#uses=2] define zeroext i8 @foo(i8 zeroext %x) nounwind { entry: Added: llvm/trunk/test/CodeGen/MSP430/AddrMode-bis-rx.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MSP430/AddrMode-bis-rx.ll?rev=86382&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/MSP430/AddrMode-bis-rx.ll (added) +++ llvm/trunk/test/CodeGen/MSP430/AddrMode-bis-rx.ll Sat Nov 7 11:13:35 2009 @@ -0,0 +1,74 @@ +; RUN: llvm-as < %s | llc -march=msp430 | FileCheck %s +target datalayout = "e-p:16:16:16-i1:8:8-i8:8:8-i16:16:16-i32:16:16" +target triple = "msp430-generic-generic" + +define i16 @am1(i16 %x, i16* %a) nounwind { + %1 = load i16* %a + %2 = or i16 %1,%x + ret i16 %2 +} +; CHECK: am1: +; CHECK: bis.w 0(r14), r15 + + at foo = external global i16 + +define i16 @am2(i16 %x) nounwind { + %1 = load i16* @foo + %2 = or i16 %1,%x + ret i16 %2 +} +; CHECK: am2: +; CHECK: bis.w &foo, r15 + + at bar = internal constant [2 x i8] [ i8 32, i8 64 ] + +define i8 @am3(i8 %x, i16 %n) nounwind { + %1 = getelementptr [2 x i8]* @bar, i16 0, i16 %n + %2 = load i8* %1 + %3 = or i8 %2,%x + ret i8 %3 +} +; CHECK: am3: +; CHECK: bis.b &bar(r14), r15 + +define i16 @am4(i16 %x) nounwind { + %1 = volatile load i16* inttoptr(i16 32 to i16*) + %2 = or i16 %1,%x + ret i16 %2 +} +; CHECK: am4: +; CHECK: bis.w &32, r15 + +define i16 @am5(i16 %x, i16* %a) nounwind { + %1 = getelementptr i16* %a, i16 2 + %2 = load i16* %1 + %3 = or i16 %2,%x + ret i16 %3 +} +; CHECK: am5: +; CHECK: bis.w 4(r14), r15 + +%S = type { i16, i16 } + at baz = common global %S zeroinitializer, align 1 + +define i16 @am6(i16 %x) nounwind { + %1 = load i16* getelementptr (%S* @baz, i32 0, i32 1) + %2 = or i16 %1,%x + ret i16 %2 +} +; CHECK: am6: +; CHECK: bis.w &baz+2, r15 + +%T = type { i16, [2 x i8] } + at duh = internal constant %T { i16 16, [2 x i8][i8 32, i8 64 ] } + +define i8 @am7(i8 %x, i16 %n) nounwind { + %1 = getelementptr %T* @duh, i32 0, i32 1 + %2 = getelementptr [2 x i8]* %1, i16 0, i16 %n + %3= load i8* %2 + %4 = or i8 %3,%x + ret i8 %4 +} +; CHECK: am7: +; CHECK: bis.b &duh+2(r14), r15 + Added: llvm/trunk/test/CodeGen/MSP430/AddrMode-bis-xr.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MSP430/AddrMode-bis-xr.ll?rev=86382&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/MSP430/AddrMode-bis-xr.ll (added) +++ llvm/trunk/test/CodeGen/MSP430/AddrMode-bis-xr.ll Sat Nov 7 11:13:35 2009 @@ -0,0 +1,81 @@ +; RUN: llvm-as < %s | llc -march=msp430 | FileCheck %s +target datalayout = "e-p:16:16:16-i8:8:8-i16:16:16-i32:16:16" +target triple = "msp430-generic-generic" + +define void @am1(i16* %a, i16 %x) nounwind { + %1 = load i16* %a + %2 = or i16 %x, %1 + store i16 %2, i16* %a + ret void +} +; CHECK: am1: +; CHECK: bis.w r14, 0(r15) + + at foo = external global i16 + +define void @am2(i16 %x) nounwind { + %1 = load i16* @foo + %2 = or i16 %x, %1 + store i16 %2, i16* @foo + ret void +} +; CHECK: am2: +; CHECK: bis.w r15, &foo + + at bar = external global [2 x i8] + +define void @am3(i16 %i, i8 %x) nounwind { + %1 = getelementptr [2 x i8]* @bar, i16 0, i16 %i + %2 = load i8* %1 + %3 = or i8 %x, %2 + store i8 %3, i8* %1 + ret void +} +; CHECK: am3: +; CHECK: bis.b r14, &bar(r15) + +define void @am4(i16 %x) nounwind { + %1 = volatile load i16* inttoptr(i16 32 to i16*) + %2 = or i16 %x, %1 + volatile store i16 %2, i16* inttoptr(i16 32 to i16*) + ret void +} +; CHECK: am4: +; CHECK: bis.w r15, &32 + +define void @am5(i16* %a, i16 %x) readonly { + %1 = getelementptr inbounds i16* %a, i16 2 + %2 = load i16* %1 + %3 = or i16 %x, %2 + store i16 %3, i16* %1 + ret void +} +; CHECK: am5: +; CHECK: bis.w r14, 4(r15) + +%S = type { i16, i16 } + at baz = common global %S zeroinitializer + +define void @am6(i16 %x) nounwind { + %1 = load i16* getelementptr (%S* @baz, i32 0, i32 1) + %2 = or i16 %x, %1 + store i16 %2, i16* getelementptr (%S* @baz, i32 0, i32 1) + ret void +} +; CHECK: am6: +; CHECK: bis.w r15, &baz+2 + +%T = type { i16, [2 x i8] } + at duh = external global %T + +define void @am7(i16 %n, i8 %x) nounwind { + %1 = getelementptr %T* @duh, i32 0, i32 1 + %2 = getelementptr [2 x i8]* %1, i16 0, i16 %n + %3 = load i8* %2 + %4 = or i8 %x, %3 + store i8 %4, i8* %2 + ret void +} +; CHECK: am7: +; CHECK: bis.b r14, &duh+2(r15) + Added: llvm/trunk/test/CodeGen/MSP430/AddrMode-mov-rx.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MSP430/AddrMode-mov-rx.ll?rev=86382&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/MSP430/AddrMode-mov-rx.ll (added) +++ llvm/trunk/test/CodeGen/MSP430/AddrMode-mov-rx.ll Sat Nov 7 11:13:35 2009 @@ -0,0 +1,67 @@ +; RUN: llvm-as < %s | llc -march=msp430 | FileCheck %s +target datalayout = "e-p:16:16:16-i1:8:8-i8:8:8-i16:16:16-i32:16:16" +target triple = "msp430-generic-generic" + +define i16 @am1(i16* %a) nounwind { + %1 = load i16* %a + ret i16 %1 +} +; CHECK: am1: +; CHECK: mov.w 0(r15), r15 + + at foo = external global i16 + +define i16 @am2() nounwind { + %1 = load i16* @foo + ret i16 %1 +} +; CHECK: am2: +; CHECK: mov.w &foo, r15 + + at bar = internal constant [2 x i8] [ i8 32, i8 64 ] + +define i8 @am3(i16 %n) nounwind { + %1 = getelementptr [2 x i8]* @bar, i16 0, i16 %n + %2 = load i8* %1 + ret i8 %2 +} +; CHECK: am3: +; CHECK: mov.b &bar(r15), r15 + +define i16 @am4() nounwind { + %1 = volatile load i16* inttoptr(i16 32 to i16*) + ret i16 %1 +} +; CHECK: am4: +; CHECK: mov.w &32, r15 + +define i16 @am5(i16* %a) nounwind { + %1 = getelementptr i16* %a, i16 2 + %2 = load i16* %1 + ret i16 %2 +} +; CHECK: am5: +; CHECK: mov.w 4(r15), r15 + +%S = type { i16, i16 } + at baz = common global %S zeroinitializer, align 1 + +define i16 @am6() nounwind { + %1 = load i16* getelementptr (%S* @baz, i32 0, i32 1) + ret i16 %1 +} +; CHECK: am6: +; CHECK: mov.w &baz+2, r15 + +%T = type { i16, [2 x i8] } + at duh = internal constant %T { i16 16, [2 x i8][i8 32, i8 64 ] } + +define i8 @am7(i16 %n) nounwind { + %1 = getelementptr %T* @duh, i32 0, i32 1 + %2 = getelementptr [2 x i8]* %1, i16 0, i16 %n + %3= load i8* %2 + ret i8 %3 +} +; CHECK: am7: +; CHECK: mov.b &duh+2(r15), r15 + Added: llvm/trunk/test/CodeGen/MSP430/AddrMode-mov-xr.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MSP430/AddrMode-mov-xr.ll?rev=86382&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/MSP430/AddrMode-mov-xr.ll (added) +++ llvm/trunk/test/CodeGen/MSP430/AddrMode-mov-xr.ll Sat Nov 7 11:13:35 2009 @@ -0,0 +1,67 @@ +; RUN: llvm-as < %s | llc -march=msp430 | FileCheck %s +target datalayout = "e-p:16:16:16-i1:8:8-i8:8:8-i16:16:16-i32:16:16" +target triple = "msp430-generic-generic" + +define void @am1(i16* %a, i16 %b) nounwind { + store i16 %b, i16* %a + ret void +} +; CHECK: am1: +; CHECK: mov.w r14, 0(r15) + + at foo = external global i16 + +define void @am2(i16 %a) nounwind { + store i16 %a, i16* @foo + ret void +} +; CHECK: am2: +; CHECK: mov.w r15, &foo + + at bar = external global [2 x i8] + +define void @am3(i16 %i, i8 %a) nounwind { + %1 = getelementptr [2 x i8]* @bar, i16 0, i16 %i + store i8 %a, i8* %1 + ret void +} +; CHECK: am3: +; CHECK: mov.b r14, &bar(r15) + +define void @am4(i16 %a) nounwind { + volatile store i16 %a, i16* inttoptr(i16 32 to i16*) + ret void +} +; CHECK: am4: +; CHECK: mov.w r15, &32 + +define void @am5(i16* nocapture %p, i16 %a) nounwind readonly { + %1 = getelementptr inbounds i16* %p, i16 2 + store i16 %a, i16* %1 + ret void +} +; CHECK: am5: +; CHECK: mov.w r14, 4(r15) + +%S = type { i16, i16 } + at baz = common global %S zeroinitializer, align 1 + +define void @am6(i16 %a) nounwind { + store i16 %a, i16* getelementptr (%S* @baz, i32 0, i32 1) + ret void +} +; CHECK: am6: +; CHECK: mov.w r15, &baz+2 + +%T = type { i16, [2 x i8] } + at duh = external global %T + +define void @am7(i16 %n, i8 %a) nounwind { + %1 = getelementptr %T* @duh, i32 0, i32 1 + %2 = getelementptr [2 x i8]* %1, i16 0, i16 %n + store i8 %a, i8* %2 + ret void +} +; CHECK: am7: +; CHECK: mov.b r14, &duh+2(r15) + Modified: llvm/trunk/test/CodeGen/MSP430/inline-asm.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MSP430/inline-asm.ll?rev=86382&r1=86381&r2=86382&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/MSP430/inline-asm.ll (original) +++ llvm/trunk/test/CodeGen/MSP430/inline-asm.ll Sat Nov 7 11:13:35 2009 @@ -20,6 +20,7 @@ } define void @mem() nounwind { - call void asm sideeffect "bic\09$0,r2", "m"(i16* @foo) nounwind + %fooval = load i16* @foo + call void asm sideeffect "bic\09$0,r2", "m"(i16 %fooval) nounwind ret void } From asl at math.spbu.ru Sat Nov 7 11:13:57 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Sat, 07 Nov 2009 17:13:57 -0000 Subject: [llvm-commits] [llvm] r86383 - /llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.cpp Message-ID: <200911071713.nA7HDv78025897@zion.cs.uiuc.edu> Author: asl Date: Sat Nov 7 11:13:57 2009 New Revision: 86383 URL: http://llvm.org/viewvc/llvm-project?rev=86383&view=rev Log: Add few pseudo-source-values Modified: llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.cpp Modified: llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.cpp?rev=86383&r1=86382&r2=86383&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.cpp Sat Nov 7 11:13:57 2009 @@ -35,15 +35,23 @@ const TargetRegisterClass *RC) const { DebugLoc DL = DebugLoc::getUnknownLoc(); if (MI != MBB.end()) DL = MI->getDebugLoc(); + MachineFunction &MF = *MBB.getParent(); + MachineFrameInfo &MFI = *MF.getFrameInfo(); + + MachineMemOperand *MMO = + MF.getMachineMemOperand(PseudoSourceValue::getFixedStack(FrameIdx), + MachineMemOperand::MOStore, 0, + MFI.getObjectSize(FrameIdx), + MFI.getObjectAlignment(FrameIdx)); if (RC == &MSP430::GR16RegClass) BuildMI(MBB, MI, DL, get(MSP430::MOV16mr)) .addFrameIndex(FrameIdx).addImm(0) - .addReg(SrcReg, getKillRegState(isKill)); + .addReg(SrcReg, getKillRegState(isKill)).addMemOperand(MMO); else if (RC == &MSP430::GR8RegClass) BuildMI(MBB, MI, DL, get(MSP430::MOV8mr)) .addFrameIndex(FrameIdx).addImm(0) - .addReg(SrcReg, getKillRegState(isKill)); + .addReg(SrcReg, getKillRegState(isKill)).addMemOperand(MMO); else llvm_unreachable("Cannot store this register to stack slot!"); } @@ -54,13 +62,21 @@ const TargetRegisterClass *RC) const{ DebugLoc DL = DebugLoc::getUnknownLoc(); if (MI != MBB.end()) DL = MI->getDebugLoc(); + MachineFunction &MF = *MBB.getParent(); + MachineFrameInfo &MFI = *MF.getFrameInfo(); + + MachineMemOperand *MMO = + MF.getMachineMemOperand(PseudoSourceValue::getFixedStack(FrameIdx), + MachineMemOperand::MOLoad, 0, + MFI.getObjectSize(FrameIdx), + MFI.getObjectAlignment(FrameIdx)); if (RC == &MSP430::GR16RegClass) BuildMI(MBB, MI, DL, get(MSP430::MOV16rm)) - .addReg(DestReg).addFrameIndex(FrameIdx).addImm(0); + .addReg(DestReg).addFrameIndex(FrameIdx).addImm(0).addMemOperand(MMO); else if (RC == &MSP430::GR8RegClass) BuildMI(MBB, MI, DL, get(MSP430::MOV8rm)) - .addReg(DestReg).addFrameIndex(FrameIdx).addImm(0); + .addReg(DestReg).addFrameIndex(FrameIdx).addImm(0).addMemOperand(MMO); else llvm_unreachable("Cannot store this register to stack slot!"); } From asl at math.spbu.ru Sat Nov 7 11:14:40 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Sat, 07 Nov 2009 17:14:40 -0000 Subject: [llvm-commits] [llvm] r86384 - in /llvm/trunk: include/llvm/CodeGen/RuntimeLibcalls.h lib/CodeGen/SelectionDAG/LegalizeDAG.cpp lib/CodeGen/SelectionDAG/TargetLowering.cpp lib/Target/MSP430/MSP430ISelLowering.cpp test/CodeGen/MSP430/2009-11-05-8BitLibcalls.ll Message-ID: <200911071714.nA7HEeRM025968@zion.cs.uiuc.edu> Author: asl Date: Sat Nov 7 11:14:39 2009 New Revision: 86384 URL: http://llvm.org/viewvc/llvm-project?rev=86384&view=rev Log: Add 8 bit libcalls and make use of them for msp430 Added: llvm/trunk/test/CodeGen/MSP430/2009-11-05-8BitLibcalls.ll Modified: llvm/trunk/include/llvm/CodeGen/RuntimeLibcalls.h llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp Modified: llvm/trunk/include/llvm/CodeGen/RuntimeLibcalls.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/RuntimeLibcalls.h?rev=86384&r1=86383&r2=86384&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/RuntimeLibcalls.h (original) +++ llvm/trunk/include/llvm/CodeGen/RuntimeLibcalls.h Sat Nov 7 11:14:39 2009 @@ -41,22 +41,27 @@ SRA_I32, SRA_I64, SRA_I128, + MUL_I8, MUL_I16, MUL_I32, MUL_I64, MUL_I128, + SDIV_I8, SDIV_I16, SDIV_I32, SDIV_I64, SDIV_I128, + UDIV_I8, UDIV_I16, UDIV_I32, UDIV_I64, UDIV_I128, + SREM_I8, SREM_I16, SREM_I32, SREM_I64, SREM_I128, + UREM_I8, UREM_I16, UREM_I32, UREM_I64, Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp?rev=86384&r1=86383&r2=86384&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Sat Nov 7 11:14:39 2009 @@ -148,8 +148,11 @@ SDValue ExpandFPLibCall(SDNode *Node, RTLIB::Libcall Call_F32, RTLIB::Libcall Call_F64, RTLIB::Libcall Call_F80, RTLIB::Libcall Call_PPCF128); - SDValue ExpandIntLibCall(SDNode *Node, bool isSigned, RTLIB::Libcall Call_I16, - RTLIB::Libcall Call_I32, RTLIB::Libcall Call_I64, + SDValue ExpandIntLibCall(SDNode *Node, bool isSigned, + RTLIB::Libcall Call_I8, + RTLIB::Libcall Call_I16, + RTLIB::Libcall Call_I32, + RTLIB::Libcall Call_I64, RTLIB::Libcall Call_I128); SDValue EmitStackConvert(SDValue SrcOp, EVT SlotVT, EVT DestVT, DebugLoc dl); @@ -1909,6 +1912,7 @@ } SDValue SelectionDAGLegalize::ExpandIntLibCall(SDNode* Node, bool isSigned, + RTLIB::Libcall Call_I8, RTLIB::Libcall Call_I16, RTLIB::Libcall Call_I32, RTLIB::Libcall Call_I64, @@ -1916,9 +1920,10 @@ RTLIB::Libcall LC; switch (Node->getValueType(0).getSimpleVT().SimpleTy) { default: llvm_unreachable("Unexpected request for libcall!"); - case MVT::i16: LC = Call_I16; break; - case MVT::i32: LC = Call_I32; break; - case MVT::i64: LC = Call_I64; break; + case MVT::i8: LC = Call_I8; break; + case MVT::i16: LC = Call_I16; break; + case MVT::i32: LC = Call_I32; break; + case MVT::i64: LC = Call_I64; break; case MVT::i128: LC = Call_I128; break; } return ExpandLibCall(LC, Node, isSigned); @@ -2624,10 +2629,14 @@ Tmp1 = DAG.getNode(ISD::MUL, dl, VT, Tmp1, Tmp3); Tmp1 = DAG.getNode(ISD::SUB, dl, VT, Tmp2, Tmp1); } else if (isSigned) { - Tmp1 = ExpandIntLibCall(Node, true, RTLIB::SREM_I16, RTLIB::SREM_I32, + Tmp1 = ExpandIntLibCall(Node, true, + RTLIB::SREM_I8, + RTLIB::SREM_I16, RTLIB::SREM_I32, RTLIB::SREM_I64, RTLIB::SREM_I128); } else { - Tmp1 = ExpandIntLibCall(Node, false, RTLIB::UREM_I16, RTLIB::UREM_I32, + Tmp1 = ExpandIntLibCall(Node, false, + RTLIB::UREM_I8, + RTLIB::UREM_I16, RTLIB::UREM_I32, RTLIB::UREM_I64, RTLIB::UREM_I128); } Results.push_back(Tmp1); @@ -2643,10 +2652,14 @@ Tmp1 = DAG.getNode(DivRemOpc, dl, VTs, Node->getOperand(0), Node->getOperand(1)); else if (isSigned) - Tmp1 = ExpandIntLibCall(Node, true, RTLIB::SDIV_I16, RTLIB::SDIV_I32, + Tmp1 = ExpandIntLibCall(Node, true, + RTLIB::SDIV_I8, + RTLIB::SDIV_I16, RTLIB::SDIV_I32, RTLIB::SDIV_I64, RTLIB::SDIV_I128); else - Tmp1 = ExpandIntLibCall(Node, false, RTLIB::UDIV_I16, RTLIB::UDIV_I32, + Tmp1 = ExpandIntLibCall(Node, false, + RTLIB::UDIV_I8, + RTLIB::UDIV_I16, RTLIB::UDIV_I32, RTLIB::UDIV_I64, RTLIB::UDIV_I128); Results.push_back(Tmp1); break; @@ -2691,7 +2704,9 @@ Node->getOperand(1))); break; } - Tmp1 = ExpandIntLibCall(Node, false, RTLIB::MUL_I16, RTLIB::MUL_I32, + Tmp1 = ExpandIntLibCall(Node, false, + RTLIB::MUL_I8, + RTLIB::MUL_I16, RTLIB::MUL_I32, RTLIB::MUL_I64, RTLIB::MUL_I128); Results.push_back(Tmp1); break; Modified: llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp?rev=86384&r1=86383&r2=86384&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp Sat Nov 7 11:14:39 2009 @@ -65,22 +65,27 @@ Names[RTLIB::SRA_I32] = "__ashrsi3"; Names[RTLIB::SRA_I64] = "__ashrdi3"; Names[RTLIB::SRA_I128] = "__ashrti3"; + Names[RTLIB::MUL_I8] = "__mulqi3"; Names[RTLIB::MUL_I16] = "__mulhi3"; Names[RTLIB::MUL_I32] = "__mulsi3"; Names[RTLIB::MUL_I64] = "__muldi3"; Names[RTLIB::MUL_I128] = "__multi3"; + Names[RTLIB::SDIV_I8] = "__divqi3"; Names[RTLIB::SDIV_I16] = "__divhi3"; Names[RTLIB::SDIV_I32] = "__divsi3"; Names[RTLIB::SDIV_I64] = "__divdi3"; Names[RTLIB::SDIV_I128] = "__divti3"; + Names[RTLIB::UDIV_I8] = "__udivqi3"; Names[RTLIB::UDIV_I16] = "__udivhi3"; Names[RTLIB::UDIV_I32] = "__udivsi3"; Names[RTLIB::UDIV_I64] = "__udivdi3"; Names[RTLIB::UDIV_I128] = "__udivti3"; + Names[RTLIB::SREM_I8] = "__modqi3"; Names[RTLIB::SREM_I16] = "__modhi3"; Names[RTLIB::SREM_I32] = "__modsi3"; Names[RTLIB::SREM_I64] = "__moddi3"; Names[RTLIB::SREM_I128] = "__modti3"; + Names[RTLIB::UREM_I8] = "__umodqi3"; Names[RTLIB::UREM_I16] = "__umodhi3"; Names[RTLIB::UREM_I32] = "__umodsi3"; Names[RTLIB::UREM_I64] = "__umoddi3"; Modified: llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp?rev=86384&r1=86383&r2=86384&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp Sat Nov 7 11:14:39 2009 @@ -115,12 +115,23 @@ setOperationAction(ISD::SIGN_EXTEND_INREG, MVT::i1, Expand); // FIXME: Implement efficiently multiplication by a constant + setOperationAction(ISD::MUL, MVT::i8, Expand); + setOperationAction(ISD::MULHS, MVT::i8, Expand); + setOperationAction(ISD::MULHU, MVT::i8, Expand); + setOperationAction(ISD::SMUL_LOHI, MVT::i8, Expand); + setOperationAction(ISD::UMUL_LOHI, MVT::i8, Expand); setOperationAction(ISD::MUL, MVT::i16, Expand); setOperationAction(ISD::MULHS, MVT::i16, Expand); setOperationAction(ISD::MULHU, MVT::i16, Expand); setOperationAction(ISD::SMUL_LOHI, MVT::i16, Expand); setOperationAction(ISD::UMUL_LOHI, MVT::i16, Expand); + setOperationAction(ISD::UDIV, MVT::i8, Expand); + setOperationAction(ISD::UDIVREM, MVT::i8, Expand); + setOperationAction(ISD::UREM, MVT::i8, Expand); + setOperationAction(ISD::SDIV, MVT::i8, Expand); + setOperationAction(ISD::SDIVREM, MVT::i8, Expand); + setOperationAction(ISD::SREM, MVT::i8, Expand); setOperationAction(ISD::UDIV, MVT::i16, Expand); setOperationAction(ISD::UDIVREM, MVT::i16, Expand); setOperationAction(ISD::UREM, MVT::i16, Expand); Added: llvm/trunk/test/CodeGen/MSP430/2009-11-05-8BitLibcalls.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MSP430/2009-11-05-8BitLibcalls.ll?rev=86384&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/MSP430/2009-11-05-8BitLibcalls.ll (added) +++ llvm/trunk/test/CodeGen/MSP430/2009-11-05-8BitLibcalls.ll Sat Nov 7 11:14:39 2009 @@ -0,0 +1,22 @@ +; RUN: llc < %s | FileCheck %s + +target datalayout = "e-p:16:8:8-i8:8:8-i16:8:8-i32:8:8" +target triple = "msp430-elf" + + at g_29 = common global i8 0, align 1 ; [#uses=0] + +define signext i8 @foo(i8 signext %_si1, i8 signext %_si2) nounwind readnone { +entry: +; CHECK: foo: +; CHECK: call #__mulqi3 + %mul = mul i8 %_si2, %_si1 ; [#uses=1] + ret i8 %mul +} + +define void @uint81(i16* nocapture %p_32) nounwind { +entry: + %call = tail call i16 @bar(i8* bitcast (i8 (i8, i8)* @foo to i8*)) nounwind ; [#uses=0] + ret void +} + +declare i16 @bar(i8*) From asl at math.spbu.ru Sat Nov 7 11:15:06 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Sat, 07 Nov 2009 17:15:06 -0000 Subject: [llvm-commits] [llvm] r86385 - in /llvm/trunk: lib/Target/MSP430/MSP430ISelDAGToDAG.cpp lib/Target/MSP430/MSP430ISelLowering.cpp lib/Target/MSP430/MSP430ISelLowering.h lib/Target/MSP430/MSP430InstrInfo.td test/CodeGen/MSP430/postinc.ll Message-ID: <200911071715.nA7HF7VE025994@zion.cs.uiuc.edu> Author: asl Date: Sat Nov 7 11:15:06 2009 New Revision: 86385 URL: http://llvm.org/viewvc/llvm-project?rev=86385&view=rev Log: Add some dummy support for post-incremented loads Added: llvm/trunk/test/CodeGen/MSP430/postinc.ll Modified: llvm/trunk/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.h llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.td Modified: llvm/trunk/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp?rev=86385&r1=86384&r2=86385&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp Sat Nov 7 11:15:06 2009 @@ -147,6 +147,7 @@ DenseMap RMWStores; void PreprocessForRMW(); SDNode *Select(SDValue Op); + SDNode *SelectIndexedLoad(SDValue Op); bool SelectAddr(SDValue Op, SDValue Addr, SDValue &Base, SDValue &Disp); #ifndef NDEBUG @@ -596,6 +597,40 @@ } } + +SDNode *MSP430DAGToDAGISel::SelectIndexedLoad(SDValue Op) { + LoadSDNode *LD = cast(Op); + ISD::MemIndexedMode AM = LD->getAddressingMode(); + if (AM != ISD::POST_INC || LD->getExtensionType() != ISD::NON_EXTLOAD) + return NULL; + + EVT VT = LD->getMemoryVT(); + + unsigned Opcode = 0; + switch (VT.getSimpleVT().SimpleTy) { + case MVT::i8: + // Sanity check + if (cast(LD->getOffset())->getZExtValue() != 1) + return NULL; + + Opcode = MSP430::MOV8rm_POST; + break; + case MVT::i16: + // Sanity check + if (cast(LD->getOffset())->getZExtValue() != 2) + return NULL; + + Opcode = MSP430::MOV16rm_POST; + break; + default: + return NULL; + } + + return CurDAG->getMachineNode(Opcode, Op.getDebugLoc(), + VT.getSimpleVT().SimpleTy, MVT::i16, MVT::Other, + LD->getBasePtr(), LD->getChain()); +} + /// InstructionSelect - This callback is invoked by /// SelectionDAGISel when it has created a SelectionDAG for us to codegen. void MSP430DAGToDAGISel::InstructionSelect() { @@ -653,6 +688,11 @@ return CurDAG->getMachineNode(MSP430::ADD16ri, dl, MVT::i16, TFI, CurDAG->getTargetConstant(0, MVT::i16)); } + case ISD::LOAD: + if (SDNode *ResNode = SelectIndexedLoad(Op)) + return ResNode; + // Other cases are autogenerated. + break; } // Select the default instruction Modified: llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp?rev=86385&r1=86384&r2=86385&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp Sat Nov 7 11:15:06 2009 @@ -62,10 +62,14 @@ setBooleanContents(ZeroOrOneBooleanContent); setSchedulingPreference(SchedulingForLatency); - setLoadExtAction(ISD::EXTLOAD, MVT::i1, Promote); - setLoadExtAction(ISD::SEXTLOAD, MVT::i1, Promote); - setLoadExtAction(ISD::ZEXTLOAD, MVT::i1, Promote); - setLoadExtAction(ISD::SEXTLOAD, MVT::i8, Expand); + // We have post-incremented loads / stores + setIndexedLoadAction(ISD::POST_INC, MVT::i8, Legal); + setIndexedLoadAction(ISD::POST_INC, MVT::i16, Legal); + + setLoadExtAction(ISD::EXTLOAD, MVT::i1, Promote); + setLoadExtAction(ISD::SEXTLOAD, MVT::i1, Promote); + setLoadExtAction(ISD::ZEXTLOAD, MVT::i1, Promote); + setLoadExtAction(ISD::SEXTLOAD, MVT::i8, Expand); setLoadExtAction(ISD::SEXTLOAD, MVT::i16, Expand); // We don't have any truncstores @@ -670,6 +674,42 @@ DAG.getValueType(Val.getValueType())); } +/// getPostIndexedAddressParts - returns true by value, base pointer and +/// offset pointer and addressing mode by reference if this node can be +/// combined with a load / store to form a post-indexed load / store. +bool MSP430TargetLowering::getPostIndexedAddressParts(SDNode *N, SDNode *Op, + SDValue &Base, + SDValue &Offset, + ISD::MemIndexedMode &AM, + SelectionDAG &DAG) const { + + LoadSDNode *LD = cast(N); + if (LD->getExtensionType() != ISD::NON_EXTLOAD) + return false; + + EVT VT = LD->getMemoryVT(); + if (VT != MVT::i8 && VT != MVT::i16) + return false; + + if (Op->getOpcode() != ISD::ADD) + return false; + + if (ConstantSDNode *RHS = dyn_cast(Op->getOperand(1))) { + uint64_t RHSC = RHS->getZExtValue(); + if ((VT == MVT::i16 && RHSC != 2) || + (VT == MVT::i8 && RHSC != 1)) + return false; + + Base = Op->getOperand(0); + Offset = DAG.getConstant(RHSC, VT); + AM = ISD::POST_INC; + return true; + } + + return false; +} + + const char *MSP430TargetLowering::getTargetNodeName(unsigned Opcode) const { switch (Opcode) { default: return NULL; Modified: llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.h?rev=86385&r1=86384&r2=86385&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.h (original) +++ llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.h Sat Nov 7 11:15:06 2009 @@ -136,6 +136,12 @@ const SmallVectorImpl &Outs, DebugLoc dl, SelectionDAG &DAG); + virtual bool getPostIndexedAddressParts(SDNode *N, SDNode *Op, + SDValue &Base, + SDValue &Offset, + ISD::MemIndexedMode &AM, + SelectionDAG &DAG) const; + const MSP430Subtarget &Subtarget; const MSP430TargetMachine &TM; }; Modified: llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.td?rev=86385&r1=86384&r2=86385&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.td (original) +++ llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.td Sat Nov 7 11:15:06 2009 @@ -215,6 +215,13 @@ "mov.b\t{$src, $dst}", [(set GR16:$dst, (zextloadi16i8 addr:$src))]>; +let mayLoad = 1, hasExtraDefRegAllocReq = 1, Constraints = "$base = $base_wb" in { +def MOV8rm_POST : Pseudo<(outs GR8:$dst, GR16:$base_wb), (ins GR16:$base), + "mov.b\t{@$base+, $dst}", []>; +def MOV16rm_POST : Pseudo<(outs GR16:$dst, GR16:$base_wb), (ins GR16:$base), + "mov.w\t{@$base+, $dst}", []>; +} + // Any instruction that defines a 8-bit result leaves the high half of the // register. Truncate can be lowered to EXTRACT_SUBREG, and CopyFromReg may // be copying from a truncate, but any other 8-bit operation will zero-extend Added: llvm/trunk/test/CodeGen/MSP430/postinc.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MSP430/postinc.ll?rev=86385&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/MSP430/postinc.ll (added) +++ llvm/trunk/test/CodeGen/MSP430/postinc.ll Sat Nov 7 11:15:06 2009 @@ -0,0 +1,25 @@ +; RUN: llc < %s | FileCheck %s +target datalayout = "e-p:16:8:8-i8:8:8-i16:8:8-i32:8:8" +target triple = "msp430" + +define zeroext i16 @add(i16* nocapture %a, i16 zeroext %n) nounwind readonly { +entry: + %cmp8 = icmp eq i16 %n, 0 ; [#uses=1] + br i1 %cmp8, label %for.end, label %for.body + +for.body: ; preds = %for.body, %entry + %i.010 = phi i16 [ 0, %entry ], [ %inc, %for.body ] ; [#uses=2] + %sum.09 = phi i16 [ 0, %entry ], [ %add, %for.body ] ; [#uses=1] + %arrayidx = getelementptr i16* %a, i16 %i.010 ; [#uses=1] +; CHECK: add: +; CHECK: mov.w @r15+, r11 + %tmp4 = load i16* %arrayidx ; [#uses=1] + %add = add i16 %tmp4, %sum.09 ; [#uses=2] + %inc = add i16 %i.010, 1 ; [#uses=2] + %exitcond = icmp eq i16 %inc, %n ; [#uses=1] + br i1 %exitcond, label %for.end, label %for.body + +for.end: ; preds = %for.body, %entry + %sum.0.lcssa = phi i16 [ 0, %entry ], [ %add, %for.body ] ; [#uses=1] + ret i16 %sum.0.lcssa +} From asl at math.spbu.ru Sat Nov 7 11:15:25 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Sat, 07 Nov 2009 17:15:25 -0000 Subject: [llvm-commits] [llvm] r86386 - in /llvm/trunk/lib/Target/MSP430: MSP430ISelDAGToDAG.cpp MSP430ISelLowering.cpp MSP430InstrInfo.td Message-ID: <200911071715.nA7HFPIM026038@zion.cs.uiuc.edu> Author: asl Date: Sat Nov 7 11:15:25 2009 New Revision: 86386 URL: http://llvm.org/viewvc/llvm-project?rev=86386&view=rev Log: First try of the post-inc operands handling... Not fully worked, though :( Modified: llvm/trunk/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.td Modified: llvm/trunk/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp?rev=86386&r1=86385&r2=86386&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp Sat Nov 7 11:15:25 2009 @@ -43,6 +43,9 @@ static const bool ViewRMWDAGs = false; #endif +static cl::opt +EnablePostIncOps("enable-msp430-post-inc-ops", cl::Hidden); + STATISTIC(NumLoadMoved, "Number of loads moved below TokenFactor"); @@ -148,6 +151,9 @@ void PreprocessForRMW(); SDNode *Select(SDValue Op); SDNode *SelectIndexedLoad(SDValue Op); + SDNode *SelectIndexedBinOp(SDValue Op, SDValue N1, SDValue N2, + unsigned Opc8, unsigned Opc16); + bool SelectAddr(SDValue Op, SDValue Addr, SDValue &Base, SDValue &Disp); #ifndef NDEBUG @@ -598,39 +604,85 @@ } -SDNode *MSP430DAGToDAGISel::SelectIndexedLoad(SDValue Op) { - LoadSDNode *LD = cast(Op); +static bool isValidIndexedLoad(const LoadSDNode *LD) { ISD::MemIndexedMode AM = LD->getAddressingMode(); if (AM != ISD::POST_INC || LD->getExtensionType() != ISD::NON_EXTLOAD) - return NULL; + return false; EVT VT = LD->getMemoryVT(); - unsigned Opcode = 0; switch (VT.getSimpleVT().SimpleTy) { case MVT::i8: // Sanity check if (cast(LD->getOffset())->getZExtValue() != 1) - return NULL; + return false; - Opcode = MSP430::MOV8rm_POST; break; case MVT::i16: // Sanity check if (cast(LD->getOffset())->getZExtValue() != 2) - return NULL; + return false; + + break; + default: + return false; + } + return true; +} + +SDNode *MSP430DAGToDAGISel::SelectIndexedLoad(SDValue Op) { + LoadSDNode *LD = cast(Op); + if (!isValidIndexedLoad(LD)) + return NULL; + + MVT VT = LD->getMemoryVT().getSimpleVT(); + + unsigned Opcode = 0; + switch (VT.SimpleTy) { + case MVT::i8: + Opcode = MSP430::MOV8rm_POST; + break; + case MVT::i16: Opcode = MSP430::MOV16rm_POST; break; default: return NULL; } - return CurDAG->getMachineNode(Opcode, Op.getDebugLoc(), - VT.getSimpleVT().SimpleTy, MVT::i16, MVT::Other, - LD->getBasePtr(), LD->getChain()); + return CurDAG->getMachineNode(Opcode, Op.getDebugLoc(), + VT, MVT::i16, MVT::Other, + LD->getBasePtr(), LD->getChain()); +} + +SDNode *MSP430DAGToDAGISel::SelectIndexedBinOp(SDValue Op, + SDValue N1, SDValue N2, + unsigned Opc8, unsigned Opc16) { + if (N1.getOpcode() == ISD::LOAD && + N1.hasOneUse() && + IsLegalAndProfitableToFold(N1.getNode(), Op.getNode(), Op.getNode())) { + LoadSDNode *LD = cast(N1); + if (!isValidIndexedLoad(LD)) + return NULL; + + MVT VT = LD->getMemoryVT().getSimpleVT(); + unsigned Opc = (VT == MVT::i16 ? Opc16 : Opc8); + MachineSDNode::mmo_iterator MemRefs0 = MF->allocateMemRefsArray(1); + MemRefs0[0] = cast(N1)->getMemOperand(); + SDValue Ops0[] = { N2, LD->getBasePtr(), LD->getChain() }; + SDNode *ResNode = + CurDAG->SelectNodeTo(Op.getNode(), Opc, + VT, MVT::i16, MVT::Other, + Ops0, 3); + cast(ResNode)->setMemRefs(MemRefs0, MemRefs0 + 1); + ReplaceUses(SDValue(N1.getNode(), 2), SDValue(ResNode, 3)); + return ResNode; + } + + return NULL; } + /// InstructionSelect - This callback is invoked by /// SelectionDAGISel when it has created a SelectionDAG for us to codegen. void MSP430DAGToDAGISel::InstructionSelect() { @@ -693,6 +745,21 @@ return ResNode; // Other cases are autogenerated. break; + case ISD::ADD: + if (EnablePostIncOps) { + if (SDNode *ResNode = + SelectIndexedBinOp(Op, + Op.getOperand(0), Op.getOperand(1), + MSP430::ADD8rm_POST, MSP430::ADD16rm_POST)) + return ResNode; + else if (SDNode *ResNode = + SelectIndexedBinOp(Op, Op.getOperand(1), Op.getOperand(0), + MSP430::ADD8rm_POST, MSP430::ADD16rm_POST)) + return ResNode; + } + + // Other cases are autogenerated. + break; } // Select the default instruction Modified: llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp?rev=86386&r1=86385&r2=86386&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp Sat Nov 7 11:15:25 2009 @@ -62,7 +62,7 @@ setBooleanContents(ZeroOrOneBooleanContent); setSchedulingPreference(SchedulingForLatency); - // We have post-incremented loads / stores + // We have post-incremented loads / stores. setIndexedLoadAction(ISD::POST_INC, MVT::i8, Legal); setIndexedLoadAction(ISD::POST_INC, MVT::i16, Legal); Modified: llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.td?rev=86386&r1=86385&r2=86386&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.td (original) +++ llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.td Sat Nov 7 11:15:25 2009 @@ -287,6 +287,15 @@ [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))), (implicit SRW)]>; +let mayLoad = 1, hasExtraDefRegAllocReq = 1, +Constraints = "$base = $base_wb, $src1 = $dst" in { +def ADD8rm_POST : Pseudo<(outs GR8:$dst, GR16:$base_wb), (ins GR8:$src1, GR16:$base), + "add.b\t{@$base+, $dst}", []>; +def ADD16rm_POST : Pseudo<(outs GR16:$dst, GR16:$base_wb), (ins GR16:$src1, GR16:$base), + "add.w\t{@$base+, $dst}", []>; +} + + def ADD8ri : Pseudo<(outs GR8:$dst), (ins GR8:$src1, i8imm:$src2), "add.b\t{$src2, $dst}", [(set GR8:$dst, (add GR8:$src1, imm:$src2)), From sabre at nondot.org Sat Nov 7 11:59:32 2009 From: sabre at nondot.org (Chris Lattner) Date: Sat, 07 Nov 2009 17:59:32 -0000 Subject: [llvm-commits] [llvm] r86391 - in /llvm/trunk: lib/Transforms/Scalar/DeadStoreElimination.cpp test/Transforms/DeadStoreElimination/lifetime.ll test/Transforms/DeadStoreElimination/memintrinsics.ll Message-ID: <200911071759.nA7HxXhm027629@zion.cs.uiuc.edu> Author: lattner Date: Sat Nov 7 11:59:32 2009 New Revision: 86391 URL: http://llvm.org/viewvc/llvm-project?rev=86391&view=rev Log: Revert r86359, it is breaking the self host on the llvm-gcc-i386-darwin9 build bot. Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp llvm/trunk/test/Transforms/DeadStoreElimination/lifetime.ll llvm/trunk/test/Transforms/DeadStoreElimination/memintrinsics.ll Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp?rev=86391&r1=86390&r2=86391&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Sat Nov 7 11:59:32 2009 @@ -78,84 +78,19 @@ FunctionPass *llvm::createDeadStoreEliminationPass() { return new DSE(); } -/// doesClobberMemory - Does this instruction clobber (write without reading) -/// some memory? -static bool doesClobberMemory(Instruction *I) { - if (isa(I)) - return true; - if (IntrinsicInst *II = dyn_cast(I)) { - switch (II->getIntrinsicID()) { - default: return false; - case Intrinsic::memset: case Intrinsic::memmove: case Intrinsic::memcpy: - case Intrinsic::lifetime_end: return true; - } - } - return false; -} - -/// isElidable - If the memory this instruction and the memory it writes to is -/// unused, may we delete this instrtction? -static bool isElidable(Instruction *I) { - assert(doesClobberMemory(I)); - if (IntrinsicInst *II = dyn_cast(I)) - return II->getIntrinsicID() != Intrinsic::lifetime_end; - if (StoreInst *SI = dyn_cast(I)) - return !SI->isVolatile(); - return true; -} - -/// getPointerOperand - Return the pointer that is being clobbered. -static Value *getPointerOperand(Instruction *I) { - assert(doesClobberMemory(I)); - if (StoreInst *SI = dyn_cast(I)) - return SI->getPointerOperand(); - if (MemIntrinsic *MI = dyn_cast(I)) - return MI->getOperand(1); - assert(cast(I)->getIntrinsicID() == Intrinsic::lifetime_end); - return cast(I)->getOperand(2); -} - -/// getStoreSize - Return the length in bytes of the write by the clobbering -/// instruction. If variable or unknown, returns -1. -static unsigned getStoreSize(Instruction *I, const TargetData *TD = 0) { - assert(doesClobberMemory(I)); - if (StoreInst *SI = dyn_cast(I)) { - if (!TD) return -1u; - const PointerType *PTy = - cast(SI->getPointerOperand()->getType()); - return TD->getTypeStoreSize(PTy); - } - - Value *Len; - if (MemIntrinsic *MI = dyn_cast(I)) { - Len = MI->getLength(); - } else { - assert(cast(I)->getIntrinsicID() == - Intrinsic::lifetime_end); - Len = cast(I)->getOperand(0); - } - if (ConstantInt *LenCI = dyn_cast(Len)) - if (!LenCI->isAllOnesValue()) - return LenCI->getZExtValue(); - return -1u; -} - -/// isStoreAtLeastAsWideAs - Return true if the size of the store in I1 is -/// greater than or equal to the store in I2. This returns false if we don't -/// know. +/// isValueAtLeastAsBigAs - Return true if V1 is greater than or equal to the +/// stored size of V2. This returns false if we don't know. /// -static bool isStoreAtLeastAsWideAs(Instruction *I1, Instruction *I2, - const TargetData *TD) { - const Type *I1Ty = getPointerOperand(I1)->getType(); - const Type *I2Ty = getPointerOperand(I2)->getType(); +static bool isValueAtLeastAsBigAs(Value *V1, Value *V2, const TargetData *TD) { + const Type *V1Ty = V1->getType(), *V2Ty = V2->getType(); // Exactly the same type, must have exactly the same size. - if (I1Ty == I2Ty) return true; + if (V1Ty == V2Ty) return true; - int I1Size = getStoreSize(I1, TD); - int I2Size = getStoreSize(I2, TD); + // If we don't have target data, we don't know. + if (TD == 0) return false; - return I1Size != -1 && I2Size != -1 && I1Size >= I2Size; + return TD->getTypeStoreSize(V1Ty) >= TD->getTypeStoreSize(V2Ty); } bool DSE::runOnBasicBlock(BasicBlock &BB) { @@ -169,9 +104,14 @@ Instruction *Inst = BBI++; // If we find a store or a free, get its memory dependence. - if (!doesClobberMemory(Inst) && !isFreeCall(Inst)) + if (!isa(Inst) && !isFreeCall(Inst)) continue; + // Don't molest volatile stores or do queries that will return "clobber". + if (StoreInst *SI = dyn_cast(Inst)) + if (SI->isVolatile()) + continue; + MemDepResult InstDep = MD.getDependency(Inst); // Ignore non-local stores. @@ -184,16 +124,16 @@ continue; } + StoreInst *SI = cast(Inst); + // If not a definite must-alias dependency, ignore it. if (!InstDep.isDef()) continue; // If this is a store-store dependence, then the previous store is dead so // long as this store is at least as big as it. - if (doesClobberMemory(InstDep.getInst())) { - Instruction *DepStore = InstDep.getInst(); - if (isStoreAtLeastAsWideAs(Inst, DepStore, TD) && - isElidable(DepStore)){ + if (StoreInst *DepStore = dyn_cast(InstDep.getInst())) + if (isValueAtLeastAsBigAs(SI->getOperand(0), DepStore->getOperand(0),TD)){ // Delete the store and now-dead instructions that feed it. DeleteDeadInstruction(DepStore); NumFastStores++; @@ -206,31 +146,25 @@ --BBI; continue; } - } - - if (!isElidable(Inst)) - continue; // If we're storing the same value back to a pointer that we just // loaded from, then the store can be removed. - if (StoreInst *SI = dyn_cast(Inst)) { - if (LoadInst *DepLoad = dyn_cast(InstDep.getInst())) { - if (SI->getPointerOperand() == DepLoad->getPointerOperand() && - SI->getOperand(0) == DepLoad) { - // DeleteDeadInstruction can delete the current instruction. Save BBI - // in case we need it. - WeakVH NextInst(BBI); - - DeleteDeadInstruction(SI); - - if (NextInst == 0) // Next instruction deleted. - BBI = BB.begin(); - else if (BBI != BB.begin()) // Revisit this instruction if possible. - --BBI; - NumFastStores++; - MadeChange = true; - continue; - } + if (LoadInst *DepLoad = dyn_cast(InstDep.getInst())) { + if (SI->getPointerOperand() == DepLoad->getPointerOperand() && + SI->getOperand(0) == DepLoad) { + // DeleteDeadInstruction can delete the current instruction. Save BBI + // in case we need it. + WeakVH NextInst(BBI); + + DeleteDeadInstruction(SI); + + if (NextInst == 0) // Next instruction deleted. + BBI = BB.begin(); + else if (BBI != BB.begin()) // Revisit this instruction if possible. + --BBI; + NumFastStores++; + MadeChange = true; + continue; } } @@ -242,7 +176,7 @@ // in case we need it. WeakVH NextInst(BBI); - DeleteDeadInstruction(Inst); + DeleteDeadInstruction(SI); if (NextInst == 0) // Next instruction deleted. BBI = BB.begin(); @@ -268,11 +202,11 @@ bool DSE::handleFreeWithNonTrivialDependency(Instruction *F, MemDepResult Dep) { AliasAnalysis &AA = getAnalysis(); - Instruction *Dependency = Dep.getInst(); - if (!Dependency || !doesClobberMemory(Dependency) || !isElidable(Dependency)) + StoreInst *Dependency = dyn_cast_or_null(Dep.getInst()); + if (!Dependency || Dependency->isVolatile()) return false; - Value *DepPointer = getPointerOperand(Dependency)->getUnderlyingObject(); + Value *DepPointer = Dependency->getPointerOperand()->getUnderlyingObject(); // Check for aliasing. if (AA.alias(F->getOperand(1), 1, DepPointer, 1) != @@ -317,28 +251,39 @@ --BBI; // If we find a store whose pointer is dead. - if (doesClobberMemory(BBI)) { - if (isElidable(BBI)) { + if (StoreInst* S = dyn_cast(BBI)) { + if (!S->isVolatile()) { // See through pointer-to-pointer bitcasts - Value *pointerOperand = getPointerOperand(BBI)->getUnderlyingObject(); + Value* pointerOperand = S->getPointerOperand()->getUnderlyingObject(); // Alloca'd pointers or byval arguments (which are functionally like // alloca's) are valid candidates for removal. if (deadPointers.count(pointerOperand)) { // DCE instructions only used to calculate that store. - Instruction *Dead = BBI; BBI++; - DeleteDeadInstruction(Dead, &deadPointers); + DeleteDeadInstruction(S, &deadPointers); NumFastStores++; MadeChange = true; - continue; } } - // Because a memcpy or memmove is also a load, we can't skip it if we - // didn't remove it. - if (!isa(BBI)) + continue; + } + + // We can also remove memcpy's to local variables at the end of a function. + if (MemCpyInst *M = dyn_cast(BBI)) { + Value *dest = M->getDest()->getUnderlyingObject(); + + if (deadPointers.count(dest)) { + BBI++; + DeleteDeadInstruction(M, &deadPointers); + NumFastOther++; + MadeChange = true; continue; + } + + // Because a memcpy is also a load, we can't skip it if we didn't remove + // it. } Value* killPointer = 0; @@ -359,11 +304,11 @@ killPointer = L->getPointerOperand(); } else if (VAArgInst* V = dyn_cast(BBI)) { killPointer = V->getOperand(0); - } else if (isa(BBI) && - isa(cast(BBI)->getLength())) { - killPointer = cast(BBI)->getSource(); + } else if (isa(BBI) && + isa(cast(BBI)->getLength())) { + killPointer = cast(BBI)->getSource(); killPointerSize = cast( - cast(BBI)->getLength())->getZExtValue(); + cast(BBI)->getLength())->getZExtValue(); } else if (AllocaInst* A = dyn_cast(BBI)) { deadPointers.erase(A); Modified: llvm/trunk/test/Transforms/DeadStoreElimination/lifetime.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/DeadStoreElimination/lifetime.ll?rev=86391&r1=86390&r2=86391&view=diff ============================================================================== --- llvm/trunk/test/Transforms/DeadStoreElimination/lifetime.ll (original) +++ llvm/trunk/test/Transforms/DeadStoreElimination/lifetime.ll Sat Nov 7 11:59:32 2009 @@ -1,19 +0,0 @@ -; RUN: opt -S -dse < %s | FileCheck %s - -declare void @llvm.lifetime.end(i64, i8*) -declare void @llvm.memset.i8(i8*, i8, i8, i32) - -define void @test1() { -; CHECK: @test1 - %A = alloca i8 - - store i8 0, i8* %A ;; Written to by memset - call void @llvm.lifetime.end(i64 1, i8* %A) -; CHECK: lifetime.end - - call void @llvm.memset.i8(i8* %A, i8 0, i8 -1, i32 0) -; CHECK-NOT: memset - - ret void -; CHECK: ret void -} Modified: llvm/trunk/test/Transforms/DeadStoreElimination/memintrinsics.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/DeadStoreElimination/memintrinsics.ll?rev=86391&r1=86390&r2=86391&view=diff ============================================================================== --- llvm/trunk/test/Transforms/DeadStoreElimination/memintrinsics.ll (original) +++ llvm/trunk/test/Transforms/DeadStoreElimination/memintrinsics.ll Sat Nov 7 11:59:32 2009 @@ -1,47 +0,0 @@ -; RUN: opt -S -dse < %s | FileCheck %s - -declare void @llvm.memcpy.i8(i8*, i8*, i8, i32) -declare void @llvm.memmove.i8(i8*, i8*, i8, i32) -declare void @llvm.memset.i8(i8*, i8, i8, i32) - -define void @test1() { -; CHECK: @test1 - %A = alloca i8 - %B = alloca i8 - - store i8 0, i8* %A ;; Written to by memcpy -; CHECK-NOT: store - - call void @llvm.memcpy.i8(i8* %A, i8* %B, i8 -1, i32 0) - - ret void -; CHECK: ret void -} - -define void @test2() { -; CHECK: @test2 - %A = alloca i8 - %B = alloca i8 - - store i8 0, i8* %A ;; Written to by memmove -; CHECK-NOT: store - - call void @llvm.memmove.i8(i8* %A, i8* %B, i8 -1, i32 0) - - ret void -; CHECK: ret void -} - -define void @test3() { -; CHECK: @test3 - %A = alloca i8 - %B = alloca i8 - - store i8 0, i8* %A ;; Written to by memset -; CHECK-NOT: store - - call void @llvm.memset.i8(i8* %A, i8 0, i8 -1, i32 0) - - ret void -; CHECK: ret void -} From sabre at nondot.org Sat Nov 7 12:03:32 2009 From: sabre at nondot.org (Chris Lattner) Date: Sat, 07 Nov 2009 18:03:32 -0000 Subject: [llvm-commits] [llvm] r86392 - in /llvm/trunk/test/Transforms/DeadStoreElimination: lifetime.ll memintrinsics.ll Message-ID: <200911071803.nA7I3WPd027876@zion.cs.uiuc.edu> Author: lattner Date: Sat Nov 7 12:03:32 2009 New Revision: 86392 URL: http://llvm.org/viewvc/llvm-project?rev=86392&view=rev Log: remove empty files. Removed: llvm/trunk/test/Transforms/DeadStoreElimination/lifetime.ll llvm/trunk/test/Transforms/DeadStoreElimination/memintrinsics.ll Removed: llvm/trunk/test/Transforms/DeadStoreElimination/lifetime.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/DeadStoreElimination/lifetime.ll?rev=86391&view=auto ============================================================================== (empty) Removed: llvm/trunk/test/Transforms/DeadStoreElimination/memintrinsics.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/DeadStoreElimination/memintrinsics.ll?rev=86391&view=auto ============================================================================== (empty) From sabre at nondot.org Sat Nov 7 12:32:38 2009 From: sabre at nondot.org (Chris Lattner) Date: Sat, 7 Nov 2009 12:32:38 -0600 Subject: [llvm-commits] CVS: llvm-www/pubs/2009-10-TereiThesis.html 2009-10-TereiThesis.pdf pubs.js Message-ID: <200911071832.nA7IWccH028871@zion.cs.uiuc.edu> Changes in directory llvm-www/pubs: 2009-10-TereiThesis.html added (r1.1) 2009-10-TereiThesis.pdf added (r1.1) pubs.js updated: 1.70 -> 1.71 --- Log message: add David Terei's thesis. --- Diffs of the changes: (+43 -0) 2009-10-TereiThesis.html | 35 +++++++++++++++++++++++++++++++++++ 2009-10-TereiThesis.pdf | 0 pubs.js | 8 ++++++++ 3 files changed, 43 insertions(+) Index: llvm-www/pubs/2009-10-TereiThesis.html diff -c /dev/null llvm-www/pubs/2009-10-TereiThesis.html:1.1 *** /dev/null Sat Nov 7 12:30:57 2009 --- llvm-www/pubs/2009-10-TereiThesis.html Sat Nov 7 12:30:47 2009 *************** *** 0 **** --- 1,35 ---- + + + + + + Low Level Virtual Machine for Glasgow Haskell Compiler + + + +

                          + Low Level Virtual Machine for Glasgow Haskell Compiler +
                          +
                          + David Terei, Bachelor's Thesis +
                          + + +

                          Abstract:

                          +
                          + This thesis details the motivation, design and implementation of a new back-end for the Glasgow Haskell Compiler which uses the Low Level Virtual Machine compiler infrastructure for code generation. Haskell as implemented by GHC was found to map remarkably well onto the LLVM Assembly language, although some new approaches were required. The most notable of these being the use of a custom calling convention in order to implement GHC's optimisation feature of pinning STG virtual registers to hardware registers. In the evaluation of the LLVM back-end in regards to GHC's C and native code generator back-end, the LLVM back-end was found to offer comparable results in regards to performance in most situations with the surprising finding that LLVM's optimisations didn't offer any improvement to the run-time of the generated code. The complexity of the LLVM back-end proved to be far simpler though then either the native code generator or C back-ends and as such it offers a compell! ing primary back-end target for GHC. +
                          + +

                          Published:

                          +
                          + Low Level Virtual Machine for Glasgow Haskell Compiler, David Terei.
                          + Bachelor's Thesis, Computer Science and Engineering Dept., The University of New South Wales, Oct 2009. +
                          + +

                          Download:

                          + + + + Index: llvm-www/pubs/2009-10-TereiThesis.pdf Index: llvm-www/pubs/pubs.js diff -u llvm-www/pubs/pubs.js:1.70 llvm-www/pubs/pubs.js:1.71 --- llvm-www/pubs/pubs.js:1.70 Tue Oct 27 09:25:46 2009 +++ llvm-www/pubs/pubs.js Sat Nov 7 12:30:47 2009 @@ -1,6 +1,14 @@ // The array should be sorted reverse-chronologically, and will be displayed on // the page in the order listed. var PUBS = [ + {url: "2009-10-TereiThesis.html", + title: "Low Level Virtual Machine for Glasgow Haskell Compiler", + published: "Bachelor's Thesis, Computer Science and Engineering Dept., The University of New South Wales", + author: "David Terei", + location: "Sydney, Australia", + month: 10, + year: 2009}, + {url: "", title: "AN-Encoding Compiler: Building Safety-Critical Systems with Commodity Hardware", published: "28th International Conference, SAFECOMP 2009", From sabre at nondot.org Sat Nov 7 12:53:00 2009 From: sabre at nondot.org (Chris Lattner) Date: Sat, 07 Nov 2009 18:53:00 -0000 Subject: [llvm-commits] [llvm] r86394 - /llvm/trunk/include/llvm/Target/TargetData.h Message-ID: <200911071853.nA7Ir0Fx029629@zion.cs.uiuc.edu> Author: lattner Date: Sat Nov 7 12:53:00 2009 New Revision: 86394 URL: http://llvm.org/viewvc/llvm-project?rev=86394&view=rev Log: all targets should be required to declare legal integer types. My plan to make it optional doesn't work out. If you don't want to specify this, don't specify a TD string at all. Modified: llvm/trunk/include/llvm/Target/TargetData.h Modified: llvm/trunk/include/llvm/Target/TargetData.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetData.h?rev=86394&r1=86393&r2=86394&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetData.h (original) +++ llvm/trunk/include/llvm/Target/TargetData.h Sat Nov 7 12:53:00 2009 @@ -144,23 +144,22 @@ /// string constructor above. std::string getStringRepresentation() const; - - /// isIllegalInteger - This function returns true if the specified type is - /// known to not be a native integer type supported by the CPU. For example, + /// isLegalInteger - This function returns true if the specified type is + /// known tobe a native integer type supported by the CPU. For example, /// i64 is not native on most 32-bit CPUs and i37 is not native on any known - /// one. This returns false if the integer width is legal or we don't know. + /// one. This returns false if the integer width is not legal. /// /// The width is specified in bits. /// - bool isIllegalInteger(unsigned Width) const { - // If we don't have information about legal integer types, don't claim the - // type is illegal. - if (LegalIntWidths.empty()) return false; - + bool isLegalInteger(unsigned Width) const { for (unsigned i = 0, e = LegalIntWidths.size(); i != e; ++i) if (LegalIntWidths[i] == Width) - return false; - return true; + return true; + return false; + } + + bool isIllegalInteger(unsigned Width) const { + return !isLegalInteger(Width); } /// Target pointer alignment From sabre at nondot.org Sat Nov 7 13:07:32 2009 From: sabre at nondot.org (Chris Lattner) Date: Sat, 07 Nov 2009 19:07:32 -0000 Subject: [llvm-commits] [llvm] r86397 - in /llvm/trunk/lib/Target: ARM/ARMTargetMachine.cpp Alpha/AlphaTargetMachine.cpp Blackfin/BlackfinTargetMachine.cpp CellSPU/SPUSubtarget.h MSP430/MSP430TargetMachine.cpp Mips/MipsTargetMachine.cpp PIC16/PIC16TargetMachine.cpp PowerPC/PPCSubtarget.h Sparc/SparcTargetMachine.cpp SystemZ/SystemZTargetMachine.cpp X86/X86Subtarget.h XCore/XCoreTargetMachine.cpp Message-ID: <200911071907.nA7J7Xfd030174@zion.cs.uiuc.edu> Author: lattner Date: Sat Nov 7 13:07:32 2009 New Revision: 86397 URL: http://llvm.org/viewvc/llvm-project?rev=86397&view=rev Log: indicate what the native integer types for the target are. Please verify. Modified: llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp llvm/trunk/lib/Target/Alpha/AlphaTargetMachine.cpp llvm/trunk/lib/Target/Blackfin/BlackfinTargetMachine.cpp llvm/trunk/lib/Target/CellSPU/SPUSubtarget.h llvm/trunk/lib/Target/MSP430/MSP430TargetMachine.cpp llvm/trunk/lib/Target/Mips/MipsTargetMachine.cpp llvm/trunk/lib/Target/PIC16/PIC16TargetMachine.cpp llvm/trunk/lib/Target/PowerPC/PPCSubtarget.h llvm/trunk/lib/Target/Sparc/SparcTargetMachine.cpp llvm/trunk/lib/Target/SystemZ/SystemZTargetMachine.cpp llvm/trunk/lib/Target/X86/X86Subtarget.h llvm/trunk/lib/Target/XCore/XCoreTargetMachine.cpp Modified: llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp?rev=86397&r1=86396&r2=86397&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp Sat Nov 7 13:07:32 2009 @@ -60,8 +60,8 @@ const std::string &FS) : ARMBaseTargetMachine(T, TT, FS, false), InstrInfo(Subtarget), DataLayout(Subtarget.isAPCS_ABI() ? - std::string("e-p:32:32-f64:32:32-i64:32:32") : - std::string("e-p:32:32-f64:64:64-i64:64:64")), + std::string("e-p:32:32-f64:32:32-i64:32:32-n32") : + std::string("e-p:32:32-f64:64:64-i64:64:64-n32")), TLInfo(*this) { } @@ -73,9 +73,9 @@ : ((ARMBaseInstrInfo*)new Thumb1InstrInfo(Subtarget))), DataLayout(Subtarget.isAPCS_ABI() ? std::string("e-p:32:32-f64:32:32-i64:32:32-" - "i16:16:32-i8:8:32-i1:8:32-a:0:32") : + "i16:16:32-i8:8:32-i1:8:32-a:0:32-n32") : std::string("e-p:32:32-f64:64:64-i64:64:64-" - "i16:16:32-i8:8:32-i1:8:32-a:0:32")), + "i16:16:32-i8:8:32-i1:8:32-a:0:32-n32")), TLInfo(*this) { } Modified: llvm/trunk/lib/Target/Alpha/AlphaTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Alpha/AlphaTargetMachine.cpp?rev=86397&r1=86396&r2=86397&view=diff ============================================================================== --- llvm/trunk/lib/Target/Alpha/AlphaTargetMachine.cpp (original) +++ llvm/trunk/lib/Target/Alpha/AlphaTargetMachine.cpp Sat Nov 7 13:07:32 2009 @@ -28,7 +28,7 @@ AlphaTargetMachine::AlphaTargetMachine(const Target &T, const std::string &TT, const std::string &FS) : LLVMTargetMachine(T, TT), - DataLayout("e-f128:128:128"), + DataLayout("e-f128:128:128-n64"), FrameInfo(TargetFrameInfo::StackGrowsDown, 16, 0), JITInfo(*this), Subtarget(TT, FS), Modified: llvm/trunk/lib/Target/Blackfin/BlackfinTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Blackfin/BlackfinTargetMachine.cpp?rev=86397&r1=86396&r2=86397&view=diff ============================================================================== --- llvm/trunk/lib/Target/Blackfin/BlackfinTargetMachine.cpp (original) +++ llvm/trunk/lib/Target/Blackfin/BlackfinTargetMachine.cpp Sat Nov 7 13:07:32 2009 @@ -28,7 +28,7 @@ const std::string &TT, const std::string &FS) : LLVMTargetMachine(T, TT), - DataLayout("e-p:32:32-i64:32-f64:32"), + DataLayout("e-p:32:32-i64:32-f64:32-n32"), Subtarget(TT, FS), TLInfo(*this), InstrInfo(Subtarget), Modified: llvm/trunk/lib/Target/CellSPU/SPUSubtarget.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPUSubtarget.h?rev=86397&r1=86396&r2=86397&view=diff ============================================================================== --- llvm/trunk/lib/Target/CellSPU/SPUSubtarget.h (original) +++ llvm/trunk/lib/Target/CellSPU/SPUSubtarget.h Sat Nov 7 13:07:32 2009 @@ -82,7 +82,7 @@ const char *getTargetDataString() const { return "E-p:32:32:128-f64:64:128-f32:32:128-i64:32:128-i32:32:128" "-i16:16:128-i8:8:128-i1:8:128-a:0:128-v64:128:128-v128:128:128" - "-s:128:128"; + "-s:128:128-n32:64"; } }; } // End llvm namespace Modified: llvm/trunk/lib/Target/MSP430/MSP430TargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430TargetMachine.cpp?rev=86397&r1=86396&r2=86397&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430TargetMachine.cpp (original) +++ llvm/trunk/lib/Target/MSP430/MSP430TargetMachine.cpp Sat Nov 7 13:07:32 2009 @@ -32,7 +32,7 @@ LLVMTargetMachine(T, TT), Subtarget(TT, FS), // FIXME: Check TargetData string. - DataLayout("e-p:16:16:16-i8:8:8-i16:16:16-i32:16:32"), + DataLayout("e-p:16:16:16-i8:8:8-i16:16:16-i32:16:32-n8:16"), InstrInfo(*this), TLInfo(*this), FrameInfo(TargetFrameInfo::StackGrowsDown, 2, -2) { } Modified: llvm/trunk/lib/Target/Mips/MipsTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsTargetMachine.cpp?rev=86397&r1=86396&r2=86397&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsTargetMachine.cpp (original) +++ llvm/trunk/lib/Target/Mips/MipsTargetMachine.cpp Sat Nov 7 13:07:32 2009 @@ -38,8 +38,8 @@ bool isLittle=false): LLVMTargetMachine(T, TT), Subtarget(TT, FS, isLittle), - DataLayout(isLittle ? std::string("e-p:32:32:32-i8:8:32-i16:16:32") : - std::string("E-p:32:32:32-i8:8:32-i16:16:32")), + DataLayout(isLittle ? std::string("e-p:32:32:32-i8:8:32-i16:16:32-n32") : + std::string("E-p:32:32:32-i8:8:32-i16:16:32-n32")), InstrInfo(*this), FrameInfo(TargetFrameInfo::StackGrowsUp, 8, 0), TLInfo(*this) { Modified: llvm/trunk/lib/Target/PIC16/PIC16TargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16TargetMachine.cpp?rev=86397&r1=86396&r2=86397&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16TargetMachine.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16TargetMachine.cpp Sat Nov 7 13:07:32 2009 @@ -34,7 +34,7 @@ const std::string &FS, bool Trad) : LLVMTargetMachine(T, TT), Subtarget(TT, FS, Trad), - DataLayout("e-p:16:8:8-i8:8:8-i16:8:8-i32:8:8"), + DataLayout("e-p:16:8:8-i8:8:8-i16:8:8-i32:8:8-n8"), InstrInfo(*this), TLInfo(*this), FrameInfo(TargetFrameInfo::StackGrowsUp, 8, 0) { } Modified: llvm/trunk/lib/Target/PowerPC/PPCSubtarget.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCSubtarget.h?rev=86397&r1=86396&r2=86397&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCSubtarget.h (original) +++ llvm/trunk/lib/Target/PowerPC/PPCSubtarget.h Sat Nov 7 13:07:32 2009 @@ -101,8 +101,8 @@ const char *getTargetDataString() const { // Note, the alignment values for f64 and i64 on ppc64 in Darwin // documentation are wrong; these are correct (i.e. "what gcc does"). - return isPPC64() ? "E-p:64:64-f64:64:64-i64:64:64-f128:64:128" - : "E-p:32:32-f64:32:64-i64:32:64-f128:64:128"; + return isPPC64() ? "E-p:64:64-f64:64:64-i64:64:64-f128:64:128-n32:64" + : "E-p:32:32-f64:32:64-i64:32:64-f128:64:128-n32"; } /// isPPC64 - Return true if we are generating code for 64-bit pointer mode. Modified: llvm/trunk/lib/Target/Sparc/SparcTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/SparcTargetMachine.cpp?rev=86397&r1=86396&r2=86397&view=diff ============================================================================== --- llvm/trunk/lib/Target/Sparc/SparcTargetMachine.cpp (original) +++ llvm/trunk/lib/Target/Sparc/SparcTargetMachine.cpp Sat Nov 7 13:07:32 2009 @@ -29,7 +29,7 @@ SparcTargetMachine::SparcTargetMachine(const Target &T, const std::string &TT, const std::string &FS) : LLVMTargetMachine(T, TT), - DataLayout("E-p:32:32-f128:128:128"), + DataLayout("E-p:32:32-f128:128:128-n32"), Subtarget(TT, FS), TLInfo(*this), InstrInfo(Subtarget), FrameInfo(TargetFrameInfo::StackGrowsDown, 8, 0) { } Modified: llvm/trunk/lib/Target/SystemZ/SystemZTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SystemZ/SystemZTargetMachine.cpp?rev=86397&r1=86396&r2=86397&view=diff ============================================================================== --- llvm/trunk/lib/Target/SystemZ/SystemZTargetMachine.cpp (original) +++ llvm/trunk/lib/Target/SystemZ/SystemZTargetMachine.cpp Sat Nov 7 13:07:32 2009 @@ -28,7 +28,7 @@ : LLVMTargetMachine(T, TT), Subtarget(TT, FS), DataLayout("E-p:64:64:64-i8:8:16-i16:16:16-i32:32:32-i64:64:64-f32:32:32" - "-f64:64:64-f128:128:128-a0:16:16"), + "-f64:64:64-f128:128:128-a0:16:16-n32:64"), InstrInfo(*this), TLInfo(*this), FrameInfo(TargetFrameInfo::StackGrowsDown, 8, -160) { Modified: llvm/trunk/lib/Target/X86/X86Subtarget.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Subtarget.h?rev=86397&r1=86396&r2=86397&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86Subtarget.h (original) +++ llvm/trunk/lib/Target/X86/X86Subtarget.h Sat Nov 7 13:07:32 2009 @@ -166,11 +166,11 @@ std::string getDataLayout() const { const char *p; if (is64Bit()) - p = "e-p:64:64-s:64-f64:64:64-i64:64:64-f80:128:128"; + p = "e-p:64:64-s:64-f64:64:64-i64:64:64-f80:128:128-n8:16:32:64"; else if (isTargetDarwin()) - p = "e-p:32:32-f64:32:64-i64:32:64-f80:128:128"; + p = "e-p:32:32-f64:32:64-i64:32:64-f80:128:128-n8:16:32"; else - p = "e-p:32:32-f64:32:64-i64:32:64-f80:32:32"; + p = "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32"; return std::string(p); } Modified: llvm/trunk/lib/Target/XCore/XCoreTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreTargetMachine.cpp?rev=86397&r1=86396&r2=86397&view=diff ============================================================================== --- llvm/trunk/lib/Target/XCore/XCoreTargetMachine.cpp (original) +++ llvm/trunk/lib/Target/XCore/XCoreTargetMachine.cpp Sat Nov 7 13:07:32 2009 @@ -25,7 +25,7 @@ : LLVMTargetMachine(T, TT), Subtarget(TT, FS), DataLayout("e-p:32:32:32-a0:0:32-f32:32:32-f64:32:32-i1:8:32-i8:8:32-" - "i16:16:32-i32:32:32-i64:32:32"), + "i16:16:32-i32:32:32-i64:32:32-n32"), InstrInfo(), FrameInfo(*this), TLInfo(*this) { From sabre at nondot.org Sat Nov 7 13:11:46 2009 From: sabre at nondot.org (Chris Lattner) Date: Sat, 07 Nov 2009 19:11:46 -0000 Subject: [llvm-commits] [llvm] r86398 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/2008-01-21-MulTrunc.ll test/Transforms/InstCombine/apint-cast.ll test/Transforms/InstCombine/cast-mul-select.ll test/Transforms/InstCombine/cast-set.ll test/Transforms/InstCombine/udivrem-change-width.ll Message-ID: <200911071911.nA7JBkSV030352@zion.cs.uiuc.edu> Author: lattner Date: Sat Nov 7 13:11:46 2009 New Revision: 86398 URL: http://llvm.org/viewvc/llvm-project?rev=86398&view=rev Log: make instcombine only rewrite a chain of computation (eliminating some extends) if the new type of the computation is legal or if both the source and dest are illegal. This prevents instcombine from changing big chains of computation into i64 on 32-bit targets for example. Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp llvm/trunk/test/Transforms/InstCombine/2008-01-21-MulTrunc.ll llvm/trunk/test/Transforms/InstCombine/apint-cast.ll llvm/trunk/test/Transforms/InstCombine/cast-mul-select.ll llvm/trunk/test/Transforms/InstCombine/cast-set.ll llvm/trunk/test/Transforms/InstCombine/udivrem-change-width.ll Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=86398&r1=86397&r2=86398&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Sat Nov 7 13:11:46 2009 @@ -8289,23 +8289,6 @@ return commonCastTransforms(CI); } -/// isSafeIntegerType - Return true if this is a basic integer type, not a crazy -/// type like i42. We don't want to introduce operations on random non-legal -/// integer types where they don't already exist in the code. In the future, -/// we should consider making this based off target-data, so that 32-bit targets -/// won't get i64 operations etc. -static bool isSafeIntegerType(const Type *Ty) { - switch (Ty->getPrimitiveSizeInBits()) { - case 8: - case 16: - case 32: - case 64: - return true; - default: - return false; - } -} - /// commonIntCastTransforms - This function implements the common transforms /// for trunc, zext, and sext. Instruction *InstCombiner::commonIntCastTransforms(CastInst &CI) { @@ -8334,8 +8317,10 @@ // Only do this if the dest type is a simple type, don't convert the // expression tree to something weird like i93 unless the source is also // strange. - if ((isSafeIntegerType(DestTy->getScalarType()) || - !isSafeIntegerType(SrcI->getType()->getScalarType())) && + if (TD && + (TD->isLegalInteger(DestTy->getScalarType()->getPrimitiveSizeInBits()) || + !TD->isLegalInteger((SrcI->getType()->getScalarType() + ->getPrimitiveSizeInBits()))) && CanEvaluateInDifferentType(SrcI, DestTy, CI.getOpcode(), NumCastsRemoved)) { // If this cast is a truncate, evaluting in a different type always @@ -8356,6 +8341,7 @@ break; case Instruction::ZExt: { DoXForm = NumCastsRemoved >= 1; + if (!DoXForm && 0) { // If it's unnecessary to issue an AND to clear the high bits, it's // always profitable to do this xform. Modified: llvm/trunk/test/Transforms/InstCombine/2008-01-21-MulTrunc.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/2008-01-21-MulTrunc.ll?rev=86398&r1=86397&r2=86398&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/2008-01-21-MulTrunc.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/2008-01-21-MulTrunc.ll Sat Nov 7 13:11:46 2009 @@ -1,5 +1,7 @@ ; RUN: opt < %s -instcombine -S | FileCheck %s +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128" + define i16 @test1(i16 %a) { %tmp = zext i16 %a to i32 ; [#uses=2] %tmp21 = lshr i32 %tmp, 8 ; [#uses=1] Modified: llvm/trunk/test/Transforms/InstCombine/apint-cast.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/apint-cast.ll?rev=86398&r1=86397&r2=86398&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/apint-cast.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/apint-cast.ll Sat Nov 7 13:11:46 2009 @@ -1,6 +1,8 @@ ; Tests to make sure elimination of casts is working correctly ; RUN: opt < %s -instcombine -S | FileCheck %s +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128" + define i17 @test1(i17 %a) { %tmp = zext i17 %a to i37 ; [#uses=2] %tmp21 = lshr i37 %tmp, 8 ; [#uses=1] Modified: llvm/trunk/test/Transforms/InstCombine/cast-mul-select.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/cast-mul-select.ll?rev=86398&r1=86397&r2=86398&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/cast-mul-select.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/cast-mul-select.ll Sat Nov 7 13:11:46 2009 @@ -1,5 +1,7 @@ ; RUN: opt < %s -instcombine -S | FileCheck %s +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128" + define i32 @mul(i32 %x, i32 %y) { %A = trunc i32 %x to i8 %B = trunc i32 %y to i8 Modified: llvm/trunk/test/Transforms/InstCombine/cast-set.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/cast-set.ll?rev=86398&r1=86397&r2=86398&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/cast-set.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/cast-set.ll Sat Nov 7 13:11:46 2009 @@ -1,6 +1,8 @@ ; This tests for various complex cast elimination cases instcombine should ; handle. +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128" + ; RUN: opt < %s -instcombine -S | FileCheck %s define i1 @test1(i32 %X) { Modified: llvm/trunk/test/Transforms/InstCombine/udivrem-change-width.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/udivrem-change-width.ll?rev=86398&r1=86397&r2=86398&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/udivrem-change-width.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/udivrem-change-width.ll Sat Nov 7 13:11:46 2009 @@ -1,6 +1,8 @@ ; RUN: opt < %s -instcombine -S | not grep zext ; PR4548 +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128" + define i8 @udiv_i8(i8 %a, i8 %b) nounwind { %conv = zext i8 %a to i32 %conv2 = zext i8 %b to i32 From sabre at nondot.org Sat Nov 7 13:13:18 2009 From: sabre at nondot.org (Chris Lattner) Date: Sat, 07 Nov 2009 19:13:18 -0000 Subject: [llvm-commits] [llvm] r86399 - in /llvm/trunk/test/FrontendC: memcpy_chk.c memset_chk.c object_size.c Message-ID: <200911071913.nA7JDIGu030404@zion.cs.uiuc.edu> Author: lattner Date: Sat Nov 7 13:13:17 2009 New Revision: 86399 URL: http://llvm.org/viewvc/llvm-project?rev=86399&view=rev Log: temporarily remove these tests, as they are breaking in the buildbot, Eric, please investigate. Removed: llvm/trunk/test/FrontendC/memcpy_chk.c llvm/trunk/test/FrontendC/memset_chk.c llvm/trunk/test/FrontendC/object_size.c Removed: llvm/trunk/test/FrontendC/memcpy_chk.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/memcpy_chk.c?rev=86398&view=auto ============================================================================== --- llvm/trunk/test/FrontendC/memcpy_chk.c (original) +++ llvm/trunk/test/FrontendC/memcpy_chk.c (removed) @@ -1,28 +0,0 @@ -// RUN: %llvmgcc -S -emit-llvm -O1 %s -o - | grep call | grep memcpy_chk | count 3 -// RUN: %llvmgcc -S -emit-llvm -O1 %s -o - | grep call | grep {llvm.memcpy} | count 3 -// rdar://6716432 - -void *t1(void *d, void *s) { - return __builtin___memcpy_chk(d, s, 16, 0); -} - -void *t2(void *d, void *s) { - return __builtin___memcpy_chk(d, s, 16, 10); -} - -void *t3(void *d, void *s) { - return __builtin___memcpy_chk(d, s, 16, 17); -} - -void *t4(void *d, void *s, unsigned len) { - return __builtin___memcpy_chk(d, s, len, 17); -} - -char buf[10]; -void *t5(void *s, unsigned len) { - return __builtin___memcpy_chk(buf, s, 5, __builtin_object_size(buf, 0)); -} - -void *t6(void *d, void *s) { - return __builtin___memcpy_chk(d, s, 16, __builtin_object_size(d, 0)); -} Removed: llvm/trunk/test/FrontendC/memset_chk.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/memset_chk.c?rev=86398&view=auto ============================================================================== --- llvm/trunk/test/FrontendC/memset_chk.c (original) +++ llvm/trunk/test/FrontendC/memset_chk.c (removed) @@ -1,6 +0,0 @@ -// RUN: %llvmgcc -S -emit-llvm -O1 %s -o - | grep call | not grep memset_chk -// rdar://6728562 - -void t(void *ptr) { - __builtin___memset_chk(ptr, 0, 32, __builtin_object_size (ptr, 0)); -} Removed: llvm/trunk/test/FrontendC/object_size.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/object_size.c?rev=86398&view=auto ============================================================================== --- llvm/trunk/test/FrontendC/object_size.c (original) +++ llvm/trunk/test/FrontendC/object_size.c (removed) @@ -1,16 +0,0 @@ -// RUN: %llvmgcc -S -emit-llvm -O1 %s -o - | grep ret | grep {\\-1} | count 1 -// RUN: %llvmgcc -S -emit-llvm -O1 %s -o - | grep ret | grep {0} | count 1 -// RUN: %llvmgcc -S -emit-llvm -O1 %s -o - | grep ret | grep {8} | count 1 - -unsigned t1(void *d) { - return __builtin_object_size(d, 0); -} - -unsigned t2(void *d) { - return __builtin_object_size(d, 2); -} - -char buf[8]; -unsigned t3() { - return __builtin_object_size(buf, 0); -} From evan.cheng at apple.com Sat Nov 7 13:40:04 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Sat, 07 Nov 2009 19:40:04 -0000 Subject: [llvm-commits] [llvm] r86400 - in /llvm/trunk/lib/Target/ARM: Thumb1InstrInfo.cpp Thumb2InstrInfo.cpp Message-ID: <200911071940.nA7Je40T031298@zion.cs.uiuc.edu> Author: evancheng Date: Sat Nov 7 13:40:04 2009 New Revision: 86400 URL: http://llvm.org/viewvc/llvm-project?rev=86400&view=rev Log: t2ldrpci_pic can be used for blockaddress as well. Modified: llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.cpp llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp Modified: llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.cpp?rev=86400&r1=86399&r2=86400&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.cpp Sat Nov 7 13:40:04 2009 @@ -16,6 +16,8 @@ #include "ARMConstantPoolValue.h" #include "ARMGenInstrInfo.inc" #include "ARMMachineFunctionInfo.h" +#include "llvm/Constants.h" +#include "llvm/Function.h" #include "llvm/GlobalValue.h" #include "llvm/CodeGen/MachineConstantPool.h" #include "llvm/CodeGen/MachineFrameInfo.h" @@ -290,10 +292,19 @@ "Expecting a machine constantpool entry!"); ARMConstantPoolValue *ACPV = static_cast(MCPE.Val.MachineCPVal); - assert(ACPV->isGlobalValue() && "Expecting a GV!"); unsigned PCLabelId = AFI->createConstPoolEntryUId(); - ARMConstantPoolValue *NewCPV = - new ARMConstantPoolValue(ACPV->getGV(), PCLabelId, ARMCP::CPValue, 4); + ARMConstantPoolValue *NewCPV = 0; + if (ACPV->isGlobalValue()) + NewCPV = new ARMConstantPoolValue(ACPV->getGV(), PCLabelId, + ARMCP::CPValue, 4); + else if (ACPV->isExtSymbol()) + NewCPV = new ARMConstantPoolValue(MF.getFunction()->getContext(), + ACPV->getSymbol(), PCLabelId, 4); + else if (ACPV->isBlockAddress()) + NewCPV = new ARMConstantPoolValue(ACPV->getBlockAddress(), PCLabelId, + ARMCP::CPBlockAddress, 4); + else + llvm_unreachable("Unexpected ARM constantpool value type!!"); CPI = MCP->getConstantPoolIndex(NewCPV, MCPE.getAlignment()); MachineInstrBuilder MIB = BuildMI(MBB, I, Orig->getDebugLoc(), get(Opcode), DestReg) Modified: llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp?rev=86400&r1=86399&r2=86400&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp Sat Nov 7 13:40:04 2009 @@ -17,6 +17,8 @@ #include "ARMAddressingModes.h" #include "ARMGenInstrInfo.inc" #include "ARMMachineFunctionInfo.h" +#include "llvm/Constants.h" +#include "llvm/Function.h" #include "llvm/GlobalValue.h" #include "llvm/CodeGen/MachineConstantPool.h" #include "llvm/CodeGen/MachineFrameInfo.h" @@ -158,10 +160,19 @@ "Expecting a machine constantpool entry!"); ARMConstantPoolValue *ACPV = static_cast(MCPE.Val.MachineCPVal); - assert(ACPV->isGlobalValue() && "Expecting a GV!"); unsigned PCLabelId = AFI->createConstPoolEntryUId(); - ARMConstantPoolValue *NewCPV = - new ARMConstantPoolValue(ACPV->getGV(), PCLabelId, ARMCP::CPValue, 4); + ARMConstantPoolValue *NewCPV = 0; + if (ACPV->isGlobalValue()) + NewCPV = new ARMConstantPoolValue(ACPV->getGV(), PCLabelId, + ARMCP::CPValue, 4); + else if (ACPV->isExtSymbol()) + NewCPV = new ARMConstantPoolValue(MF.getFunction()->getContext(), + ACPV->getSymbol(), PCLabelId, 4); + else if (ACPV->isBlockAddress()) + NewCPV = new ARMConstantPoolValue(ACPV->getBlockAddress(), PCLabelId, + ARMCP::CPBlockAddress, 4); + else + llvm_unreachable("Unexpected ARM constantpool value type!!"); CPI = MCP->getConstantPoolIndex(NewCPV, MCPE.getAlignment()); MachineInstrBuilder MIB = BuildMI(MBB, I, Orig->getDebugLoc(), get(Opcode), DestReg) From echristo at apple.com Sat Nov 7 15:06:15 2009 From: echristo at apple.com (Eric Christopher) Date: Sat, 7 Nov 2009 13:06:15 -0800 Subject: [llvm-commits] [llvm] r86399 - in /llvm/trunk/test/FrontendC: memcpy_chk.c memset_chk.c object_size.c In-Reply-To: <200911071913.nA7JDIGu030404@zion.cs.uiuc.edu> References: <200911071913.nA7JDIGu030404@zion.cs.uiuc.edu> Message-ID: On Nov 7, 2009, at 11:13 AM, Chris Lattner wrote: > Author: lattner > Date: Sat Nov 7 13:13:17 2009 > New Revision: 86399 > > URL: http://llvm.org/viewvc/llvm-project?rev=86399&view=rev > Log: > temporarily remove these tests, as they are breaking in the buildbot, > Eric, please investigate. Aha, yes. All of these are depending on the frontend producing "I don't know" results (or having the gcc tree optimizers optimize them). Right now I think they're fine to remove and I'll replace them with tests in single source as I get the optimizations in. -eric From nicholas at mxc.ca Sat Nov 7 15:10:15 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Sat, 07 Nov 2009 21:10:15 -0000 Subject: [llvm-commits] [llvm] r86403 - in /llvm/trunk: lib/Target/README.txt lib/Transforms/Scalar/TailRecursionElimination.cpp test/Transforms/TailCallElim/switch.ll Message-ID: <200911072110.nA7LAFUl002078@zion.cs.uiuc.edu> Author: nicholas Date: Sat Nov 7 15:10:15 2009 New Revision: 86403 URL: http://llvm.org/viewvc/llvm-project?rev=86403&view=rev Log: Improve tail call elimination to handle the switch statement. Added: llvm/trunk/test/Transforms/TailCallElim/switch.ll Modified: llvm/trunk/lib/Target/README.txt llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp Modified: llvm/trunk/lib/Target/README.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/README.txt?rev=86403&r1=86402&r2=86403&view=diff ============================================================================== --- llvm/trunk/lib/Target/README.txt (original) +++ llvm/trunk/lib/Target/README.txt Sat Nov 7 15:10:15 2009 @@ -406,22 +406,6 @@ //===---------------------------------------------------------------------===// -Tail recursion elimination is not transforming this function, because it is -returning n, which fails the isDynamicConstant check in the accumulator -recursion checks. - -long long fib(const long long n) { - switch(n) { - case 0: - case 1: - return n; - default: - return fib(n-1) + fib(n-2); - } -} - -//===---------------------------------------------------------------------===// - Tail recursion elimination should handle: int pow2m1(int n) { Modified: llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp?rev=86403&r1=86402&r2=86403&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp Sat Nov 7 15:10:15 2009 @@ -234,7 +234,7 @@ // We currently handle static constants and arguments that are not modified as // part of the recursion. // -static bool isDynamicConstant(Value *V, CallInst *CI) { +static bool isDynamicConstant(Value *V, CallInst *CI, ReturnInst *RI) { if (isa(V)) return true; // Static constants are always dyn consts // Check to see if this is an immutable argument, if so, the value @@ -252,6 +252,15 @@ if (CI->getOperand(ArgNo+1) == Arg) return true; } + + // Switch cases are always constant integers. If the value is being switched + // on and the return is only reachable from one of its cases, it's + // effectively constant. + if (BasicBlock *UniquePred = RI->getParent()->getUniquePredecessor()) + if (SwitchInst *SI = dyn_cast(UniquePred->getTerminator())) + if (SI->getCondition() == V) + return SI->getDefaultDest() != RI->getParent(); + // Not a constant or immutable argument, we can't safely transform. return false; } @@ -273,7 +282,7 @@ // evaluatable at the start of the initial invocation of the function, // instead of at the end of the evaluation. // - if (!isDynamicConstant(RetOp, CI)) + if (!isDynamicConstant(RetOp, CI, RI)) return 0; if (ReturnedValue && RetOp != ReturnedValue) Added: llvm/trunk/test/Transforms/TailCallElim/switch.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/TailCallElim/switch.ll?rev=86403&view=auto ============================================================================== --- llvm/trunk/test/Transforms/TailCallElim/switch.ll (added) +++ llvm/trunk/test/Transforms/TailCallElim/switch.ll Sat Nov 7 15:10:15 2009 @@ -0,0 +1,34 @@ +; RUN: opt %s -tailcallelim -S | FileCheck %s + +define i64 @fib(i64 %n) nounwind readnone { +; CHECK: @fib +entry: +; CHECK: tailrecurse: +; CHECK: %accumulator.tr = phi i64 [ %n, %entry ], [ %3, %bb1 ] +; CHECK: %n.tr = phi i64 [ %n, %entry ], [ %2, %bb1 ] + switch i64 %n, label %bb1 [ +; CHECK: switch i64 %n.tr, label %bb1 [ + i64 0, label %bb2 + i64 1, label %bb2 + ] + +bb1: +; CHECK: bb1: + %0 = add i64 %n, -1 +; CHECK: %0 = add i64 %n.tr, -1 + %1 = tail call i64 @fib(i64 %0) nounwind +; CHECK: %1 = tail call i64 @fib(i64 %0) + %2 = add i64 %n, -2 +; CHECK: %2 = add i64 %n.tr, -2 + %3 = tail call i64 @fib(i64 %2) nounwind +; CHECK-NOT: tail call i64 @fib + %4 = add nsw i64 %3, %1 +; CHECK: add nsw i64 %accumulator.tr, %1 + ret i64 %4 +; CHECK: br label %tailrecurse + +bb2: +; CHECK: bb2: + ret i64 %n +; CHECK: ret i64 %accumulator.tr +} From grosbach at apple.com Sat Nov 7 15:25:39 2009 From: grosbach at apple.com (Jim Grosbach) Date: Sat, 07 Nov 2009 21:25:39 -0000 Subject: [llvm-commits] [llvm] r86404 - in /llvm/trunk/lib/Target/ARM: ARMAddressingModes.h ARMISelDAGToDAG.cpp ARMInstrInfo.td AsmPrinter/ARMAsmPrinter.cpp NEONPreAllocPass.cpp Message-ID: <200911072125.nA7LPdh9002578@zion.cs.uiuc.edu> Author: grosbach Date: Sat Nov 7 15:25:39 2009 New Revision: 86404 URL: http://llvm.org/viewvc/llvm-project?rev=86404&view=rev Log: Support alignment specifier for NEON vld/vst instructions Modified: llvm/trunk/lib/Target/ARM/ARMAddressingModes.h llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp llvm/trunk/lib/Target/ARM/ARMInstrInfo.td llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp llvm/trunk/lib/Target/ARM/NEONPreAllocPass.cpp Modified: llvm/trunk/lib/Target/ARM/ARMAddressingModes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMAddressingModes.h?rev=86404&r1=86403&r2=86404&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMAddressingModes.h (original) +++ llvm/trunk/lib/Target/ARM/ARMAddressingModes.h Sat Nov 7 15:25:39 2009 @@ -541,13 +541,15 @@ // // This is used for NEON load / store instructions. // - // addrmode6 := reg with optional writeback + // addrmode6 := reg with optional writeback and alignment // - // This is stored in three operands [regaddr, regupdate, opc]. The first is - // the address register. The second register holds the value of a post-access - // increment for writeback or reg0 if no writeback or if the writeback - // increment is the size of the memory access. The third operand encodes - // whether there is writeback to the address register. + // This is stored in four operands [regaddr, regupdate, opc, align]. The + // first is the address register. The second register holds the value of + // a post-access increment for writeback or reg0 if no writeback or if the + // writeback increment is the size of the memory access. The third + // operand encodes whether there is writeback to the address register. The + // fourth operand is the value of the alignment specifier to use or zero if + // no explicit alignment. static inline unsigned getAM6Opc(bool WB = false) { return (int)WB; Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp?rev=86404&r1=86403&r2=86404&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Sat Nov 7 15:25:39 2009 @@ -81,7 +81,7 @@ bool SelectAddrMode5(SDValue Op, SDValue N, SDValue &Base, SDValue &Offset); bool SelectAddrMode6(SDValue Op, SDValue N, SDValue &Addr, SDValue &Update, - SDValue &Opc); + SDValue &Opc, SDValue &Align); bool SelectAddrModePC(SDValue Op, SDValue N, SDValue &Offset, SDValue &Label); @@ -489,11 +489,13 @@ bool ARMDAGToDAGISel::SelectAddrMode6(SDValue Op, SDValue N, SDValue &Addr, SDValue &Update, - SDValue &Opc) { + SDValue &Opc, SDValue &Align) { Addr = N; // Default to no writeback. Update = CurDAG->getRegister(0, MVT::i32); Opc = CurDAG->getTargetConstant(ARM_AM::getAM6Opc(false), MVT::i32); + // Default to no alignment. + Align = CurDAG->getTargetConstant(0, MVT::i32); return true; } @@ -1008,8 +1010,8 @@ SDNode *N = Op.getNode(); DebugLoc dl = N->getDebugLoc(); - SDValue MemAddr, MemUpdate, MemOpc; - if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, MemUpdate, MemOpc)) + SDValue MemAddr, MemUpdate, MemOpc, Align; + if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, MemUpdate, MemOpc, Align)) return NULL; SDValue Chain = N->getOperand(0); @@ -1034,10 +1036,10 @@ if (is64BitVector) { unsigned Opc = DOpcodes[OpcodeIndex]; - const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, Chain }; + const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, Align, Chain }; std::vector ResTys(NumVecs, VT); ResTys.push_back(MVT::Other); - return CurDAG->getMachineNode(Opc, dl, ResTys, Ops, 4); + return CurDAG->getMachineNode(Opc, dl, ResTys, Ops, 5); } EVT RegVT = GetNEONSubregVT(VT); @@ -1045,10 +1047,10 @@ // Quad registers are directly supported for VLD2, // loading 2 pairs of D regs. unsigned Opc = QOpcodes0[OpcodeIndex]; - const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, Chain }; + const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, Align, Chain }; std::vector ResTys(4, VT); ResTys.push_back(MVT::Other); - SDNode *VLd = CurDAG->getMachineNode(Opc, dl, ResTys, Ops, 4); + SDNode *VLd = CurDAG->getMachineNode(Opc, dl, ResTys, Ops, 5); Chain = SDValue(VLd, 4); // Combine the even and odd subregs to produce the result. @@ -1069,14 +1071,15 @@ // Load the even subregs. unsigned Opc = QOpcodes0[OpcodeIndex]; - const SDValue OpsA[] = { MemAddr, MemUpdate, MemOpc, Chain }; - SDNode *VLdA = CurDAG->getMachineNode(Opc, dl, ResTys, OpsA, 4); + const SDValue OpsA[] = { MemAddr, MemUpdate, MemOpc, Align, Chain }; + SDNode *VLdA = CurDAG->getMachineNode(Opc, dl, ResTys, OpsA, 5); Chain = SDValue(VLdA, NumVecs+1); // Load the odd subregs. Opc = QOpcodes1[OpcodeIndex]; - const SDValue OpsB[] = { SDValue(VLdA, NumVecs), MemUpdate, MemOpc, Chain }; - SDNode *VLdB = CurDAG->getMachineNode(Opc, dl, ResTys, OpsB, 4); + const SDValue OpsB[] = { SDValue(VLdA, NumVecs), MemUpdate, MemOpc, + Align, Chain }; + SDNode *VLdB = CurDAG->getMachineNode(Opc, dl, ResTys, OpsB, 5); Chain = SDValue(VLdB, NumVecs+1); // Combine the even and odd subregs to produce the result. @@ -1096,8 +1099,8 @@ SDNode *N = Op.getNode(); DebugLoc dl = N->getDebugLoc(); - SDValue MemAddr, MemUpdate, MemOpc; - if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, MemUpdate, MemOpc)) + SDValue MemAddr, MemUpdate, MemOpc, Align; + if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, MemUpdate, MemOpc, Align)) return NULL; SDValue Chain = N->getOperand(0); @@ -1124,13 +1127,14 @@ Ops.push_back(MemAddr); Ops.push_back(MemUpdate); Ops.push_back(MemOpc); + Ops.push_back(Align); if (is64BitVector) { unsigned Opc = DOpcodes[OpcodeIndex]; for (unsigned Vec = 0; Vec < NumVecs; ++Vec) Ops.push_back(N->getOperand(Vec+3)); Ops.push_back(Chain); - return CurDAG->getMachineNode(Opc, dl, MVT::Other, Ops.data(), NumVecs+4); + return CurDAG->getMachineNode(Opc, dl, MVT::Other, Ops.data(), NumVecs+5); } EVT RegVT = GetNEONSubregVT(VT); @@ -1145,7 +1149,7 @@ N->getOperand(Vec+3))); } Ops.push_back(Chain); - return CurDAG->getMachineNode(Opc, dl, MVT::Other, Ops.data(), 8); + return CurDAG->getMachineNode(Opc, dl, MVT::Other, Ops.data(), 9); } // Otherwise, quad registers are stored with two separate instructions, @@ -1161,18 +1165,18 @@ Ops.push_back(Chain); unsigned Opc = QOpcodes0[OpcodeIndex]; SDNode *VStA = CurDAG->getMachineNode(Opc, dl, MemAddr.getValueType(), - MVT::Other, Ops.data(), NumVecs+4); + MVT::Other, Ops.data(), NumVecs+5); Chain = SDValue(VStA, 1); // Store the odd subregs. Ops[0] = SDValue(VStA, 0); // MemAddr for (unsigned Vec = 0; Vec < NumVecs; ++Vec) - Ops[Vec+3] = CurDAG->getTargetExtractSubreg(ARM::DSUBREG_1, dl, RegVT, + Ops[Vec+4] = CurDAG->getTargetExtractSubreg(ARM::DSUBREG_1, dl, RegVT, N->getOperand(Vec+3)); - Ops[NumVecs+3] = Chain; + Ops[NumVecs+4] = Chain; Opc = QOpcodes1[OpcodeIndex]; SDNode *VStB = CurDAG->getMachineNode(Opc, dl, MemAddr.getValueType(), - MVT::Other, Ops.data(), NumVecs+4); + MVT::Other, Ops.data(), NumVecs+5); Chain = SDValue(VStB, 1); ReplaceUses(SDValue(N, 0), Chain); return NULL; @@ -1186,8 +1190,8 @@ SDNode *N = Op.getNode(); DebugLoc dl = N->getDebugLoc(); - SDValue MemAddr, MemUpdate, MemOpc; - if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, MemUpdate, MemOpc)) + SDValue MemAddr, MemUpdate, MemOpc, Align; + if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, MemUpdate, MemOpc, Align)) return NULL; SDValue Chain = N->getOperand(0); @@ -1224,6 +1228,7 @@ Ops.push_back(MemAddr); Ops.push_back(MemUpdate); Ops.push_back(MemOpc); + Ops.push_back(Align); unsigned Opc = 0; if (is64BitVector) { Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=86404&r1=86403&r2=86404&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Sat Nov 7 15:25:39 2009 @@ -340,9 +340,9 @@ // addrmode6 := reg with optional writeback // def addrmode6 : Operand, - ComplexPattern { + ComplexPattern { let PrintMethod = "printAddrMode6Operand"; - let MIOperandInfo = (ops GPR:$addr, GPR:$upd, i32imm); + let MIOperandInfo = (ops GPR:$addr, GPR:$upd, i32imm, i32imm); } // addrmodepc := pc + reg 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=86404&r1=86403&r2=86404&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Sat Nov 7 15:25:39 2009 @@ -638,9 +638,17 @@ const MachineOperand &MO1 = MI->getOperand(Op); const MachineOperand &MO2 = MI->getOperand(Op+1); const MachineOperand &MO3 = MI->getOperand(Op+2); + const MachineOperand &MO4 = MI->getOperand(Op+3); - // FIXME: No support yet for specifying alignment. - O << "[" << getRegisterName(MO1.getReg()) << "]"; + O << "[" << getRegisterName(MO1.getReg()); + if (MO4.getImm()) { + if (Subtarget->isTargetDarwin()) + O << ", :"; + else + O << " @"; + O << MO4.getImm(); + } + O << "]"; if (ARM_AM::getAM6WBFlag(MO3.getImm())) { if (MO2.getReg() == 0) Modified: llvm/trunk/lib/Target/ARM/NEONPreAllocPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/NEONPreAllocPass.cpp?rev=86404&r1=86403&r2=86404&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/NEONPreAllocPass.cpp (original) +++ llvm/trunk/lib/Target/ARM/NEONPreAllocPass.cpp Sat Nov 7 15:25:39 2009 @@ -177,20 +177,20 @@ case ARM::VST2LNd8: case ARM::VST2LNd16: case ARM::VST2LNd32: - FirstOpnd = 3; + FirstOpnd = 4; NumRegs = 2; return true; case ARM::VST2q8: case ARM::VST2q16: case ARM::VST2q32: - FirstOpnd = 3; + FirstOpnd = 4; NumRegs = 4; return true; case ARM::VST2LNq16a: case ARM::VST2LNq32a: - FirstOpnd = 3; + FirstOpnd = 4; NumRegs = 2; Offset = 0; Stride = 2; @@ -198,7 +198,7 @@ case ARM::VST2LNq16b: case ARM::VST2LNq32b: - FirstOpnd = 3; + FirstOpnd = 4; NumRegs = 2; Offset = 1; Stride = 2; @@ -211,14 +211,14 @@ case ARM::VST3LNd8: case ARM::VST3LNd16: case ARM::VST3LNd32: - FirstOpnd = 3; + FirstOpnd = 4; NumRegs = 3; return true; case ARM::VST3q8a: case ARM::VST3q16a: case ARM::VST3q32a: - FirstOpnd = 4; + FirstOpnd = 5; NumRegs = 3; Offset = 0; Stride = 2; @@ -227,7 +227,7 @@ case ARM::VST3q8b: case ARM::VST3q16b: case ARM::VST3q32b: - FirstOpnd = 4; + FirstOpnd = 5; NumRegs = 3; Offset = 1; Stride = 2; @@ -235,7 +235,7 @@ case ARM::VST3LNq16a: case ARM::VST3LNq32a: - FirstOpnd = 3; + FirstOpnd = 4; NumRegs = 3; Offset = 0; Stride = 2; @@ -243,7 +243,7 @@ case ARM::VST3LNq16b: case ARM::VST3LNq32b: - FirstOpnd = 3; + FirstOpnd = 4; NumRegs = 3; Offset = 1; Stride = 2; @@ -256,14 +256,14 @@ case ARM::VST4LNd8: case ARM::VST4LNd16: case ARM::VST4LNd32: - FirstOpnd = 3; + FirstOpnd = 4; NumRegs = 4; return true; case ARM::VST4q8a: case ARM::VST4q16a: case ARM::VST4q32a: - FirstOpnd = 4; + FirstOpnd = 5; NumRegs = 4; Offset = 0; Stride = 2; @@ -272,7 +272,7 @@ case ARM::VST4q8b: case ARM::VST4q16b: case ARM::VST4q32b: - FirstOpnd = 4; + FirstOpnd = 5; NumRegs = 4; Offset = 1; Stride = 2; @@ -280,7 +280,7 @@ case ARM::VST4LNq16a: case ARM::VST4LNq32a: - FirstOpnd = 3; + FirstOpnd = 4; NumRegs = 4; Offset = 0; Stride = 2; @@ -288,7 +288,7 @@ case ARM::VST4LNq16b: case ARM::VST4LNq32b: - FirstOpnd = 3; + FirstOpnd = 4; NumRegs = 4; Offset = 1; Stride = 2; From grosbach at apple.com Sat Nov 7 16:00:39 2009 From: grosbach at apple.com (Jim Grosbach) Date: Sat, 07 Nov 2009 22:00:39 -0000 Subject: [llvm-commits] [llvm] r86408 - in /llvm/trunk/lib/Target/ARM: ARMBaseInstrInfo.cpp ARMBaseInstrInfo.h Thumb1InstrInfo.cpp Thumb1InstrInfo.h Thumb1RegisterInfo.cpp Thumb1RegisterInfo.h Thumb2ITBlockPass.cpp Thumb2InstrInfo.cpp Thumb2InstrInfo.h Thumb2RegisterInfo.h Message-ID: <200911072200.nA7M0dTb004123@zion.cs.uiuc.edu> Author: grosbach Date: Sat Nov 7 16:00:39 2009 New Revision: 86408 URL: http://llvm.org/viewvc/llvm-project?rev=86408&view=rev Log: 80-column cleanup of file header comments Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.cpp llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.h llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.h llvm/trunk/lib/Target/ARM/Thumb2ITBlockPass.cpp llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.h llvm/trunk/lib/Target/ARM/Thumb2RegisterInfo.h Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp?rev=86408&r1=86407&r2=86408&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp Sat Nov 7 16:00:39 2009 @@ -1,4 +1,4 @@ -//===- ARMBaseInstrInfo.cpp - ARM Instruction Information -----------*- C++ -*-===// +//===- ARMBaseInstrInfo.cpp - ARM Instruction Information -------*- C++ -*-===// // // The LLVM Compiler Infrastructure // Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h?rev=86408&r1=86407&r2=86408&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h Sat Nov 7 16:00:39 2009 @@ -1,4 +1,4 @@ -//===- ARMBaseInstrInfo.h - ARM Base Instruction Information -------------*- C++ -*-===// +//===- ARMBaseInstrInfo.h - ARM Base Instruction Information ----*- C++ -*-===// // // The LLVM Compiler Infrastructure // Modified: llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.cpp?rev=86408&r1=86407&r2=86408&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.cpp Sat Nov 7 16:00:39 2009 @@ -1,4 +1,4 @@ -//===- Thumb1InstrInfo.cpp - Thumb-1 Instruction Information --------*- C++ -*-===// +//===- Thumb1InstrInfo.cpp - Thumb-1 Instruction Information ----*- C++ -*-===// // // The LLVM Compiler Infrastructure // Modified: llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.h?rev=86408&r1=86407&r2=86408&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.h (original) +++ llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.h Sat Nov 7 16:00:39 2009 @@ -1,4 +1,4 @@ -//===- Thumb1InstrInfo.h - Thumb-1 Instruction Information ----------*- C++ -*-===// +//===- Thumb1InstrInfo.h - Thumb-1 Instruction Information ------*- C++ -*-===// // // The LLVM Compiler Infrastructure // Modified: llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp?rev=86408&r1=86407&r2=86408&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp Sat Nov 7 16:00:39 2009 @@ -1,4 +1,4 @@ -//===- Thumb1RegisterInfo.cpp - Thumb-1 Register Information -------*- C++ -*-===// +//===- Thumb1RegisterInfo.cpp - Thumb-1 Register Information ----*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,7 +7,8 @@ // //===----------------------------------------------------------------------===// // -// This file contains the Thumb-1 implementation of the TargetRegisterInfo class. +// This file contains the Thumb-1 implementation of the TargetRegisterInfo +// class. // //===----------------------------------------------------------------------===// Modified: llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.h?rev=86408&r1=86407&r2=86408&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.h (original) +++ llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.h Sat Nov 7 16:00:39 2009 @@ -1,4 +1,4 @@ -//===- Thumb1RegisterInfo.h - Thumb-1 Register Information Impl ----*- C++ -*-===// +//===- Thumb1RegisterInfo.h - Thumb-1 Register Information Impl -*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,7 +7,8 @@ // //===----------------------------------------------------------------------===// // -// This file contains the Thumb-1 implementation of the TargetRegisterInfo class. +// This file contains the Thumb-1 implementation of the TargetRegisterInfo +// class. // //===----------------------------------------------------------------------===// Modified: llvm/trunk/lib/Target/ARM/Thumb2ITBlockPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb2ITBlockPass.cpp?rev=86408&r1=86407&r2=86408&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb2ITBlockPass.cpp (original) +++ llvm/trunk/lib/Target/ARM/Thumb2ITBlockPass.cpp Sat Nov 7 16:00:39 2009 @@ -1,4 +1,4 @@ -//===-- Thumb2ITBlockPass.cpp - Insert Thumb IT blocks -----------*- C++ -*-===// +//===-- Thumb2ITBlockPass.cpp - Insert Thumb IT blocks ----------*- C++ -*-===// // // The LLVM Compiler Infrastructure // Modified: llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp?rev=86408&r1=86407&r2=86408&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp Sat Nov 7 16:00:39 2009 @@ -1,4 +1,4 @@ -//===- Thumb2InstrInfo.cpp - Thumb-2 Instruction Information --------*- C++ -*-===// +//===- Thumb2InstrInfo.cpp - Thumb-2 Instruction Information ----*- C++ -*-===// // // The LLVM Compiler Infrastructure // Modified: llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.h?rev=86408&r1=86407&r2=86408&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.h (original) +++ llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.h Sat Nov 7 16:00:39 2009 @@ -1,4 +1,4 @@ -//===- Thumb2InstrInfo.h - Thumb-2 Instruction Information -------*- C++ -*-===// +//===- Thumb2InstrInfo.h - Thumb-2 Instruction Information ------*- C++ -*-===// // // The LLVM Compiler Infrastructure // Modified: llvm/trunk/lib/Target/ARM/Thumb2RegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb2RegisterInfo.h?rev=86408&r1=86407&r2=86408&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb2RegisterInfo.h (original) +++ llvm/trunk/lib/Target/ARM/Thumb2RegisterInfo.h Sat Nov 7 16:00:39 2009 @@ -1,4 +1,4 @@ -//===- Thumb2RegisterInfo.h - Thumb-2 Register Information Impl ----*- C++ -*-===// +//===- Thumb2RegisterInfo.h - Thumb-2 Register Information Impl -*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,7 +7,8 @@ // //===----------------------------------------------------------------------===// // -// This file contains the Thumb-2 implementation of the TargetRegisterInfo class. +// This file contains the Thumb-2 implementation of the TargetRegisterInfo +// class. // //===----------------------------------------------------------------------===// From natebegeman at mac.com Sat Nov 7 17:17:16 2009 From: natebegeman at mac.com (Nate Begeman) Date: Sat, 07 Nov 2009 23:17:16 -0000 Subject: [llvm-commits] [llvm] r86415 - in /llvm/trunk: lib/Target/X86/X86ISelLowering.cpp lib/Target/X86/X86ISelLowering.h lib/Target/X86/X86InstrSSE.td test/CodeGen/X86/vec_shuffle-3.ll Message-ID: <200911072317.nA7NHGhb006771@zion.cs.uiuc.edu> Author: sampo Date: Sat Nov 7 17:17:15 2009 New Revision: 86415 URL: http://llvm.org/viewvc/llvm-project?rev=86415&view=rev Log: x86 vector shuffle cleanup/fixes: 1. rename the movhp patfrag to movlhps, since thats what it actually matches 2. eliminate the bogus movhps load and store patterns, they were incorrect. The load transforms are already handled (correctly) by shufps/unpack. 3. revert a recent test change to its correct form. Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp llvm/trunk/lib/Target/X86/X86ISelLowering.h llvm/trunk/lib/Target/X86/X86InstrSSE.td llvm/trunk/test/CodeGen/X86/vec_shuffle-3.ll Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=86415&r1=86414&r2=86415&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Sat Nov 7 17:17:15 2009 @@ -2528,6 +2528,21 @@ isUndefOrEqual(N->getMaskElt(3), 3); } +/// isMOVHLPS_v_undef_Mask - Special case of isMOVHLPSMask for canonical form +/// of vector_shuffle v, v, <2, 3, 2, 3>, i.e. vector_shuffle v, undef, +/// <2, 3, 2, 3> +bool X86::isMOVHLPS_v_undef_Mask(ShuffleVectorSDNode *N) { + unsigned NumElems = N->getValueType(0).getVectorNumElements(); + + if (NumElems != 4) + return false; + + return isUndefOrEqual(N->getMaskElt(0), 2) && + isUndefOrEqual(N->getMaskElt(1), 3) && + isUndefOrEqual(N->getMaskElt(2), 2) && + isUndefOrEqual(N->getMaskElt(3), 3); +} + /// isMOVLPMask - Return true if the specified VECTOR_SHUFFLE operand /// specifies a shuffle of elements that is suitable for input to MOVLP{S|D}. bool X86::isMOVLPMask(ShuffleVectorSDNode *N) { @@ -2547,10 +2562,9 @@ return true; } -/// isMOVHPMask - Return true if the specified VECTOR_SHUFFLE operand -/// specifies a shuffle of elements that is suitable for input to MOVHP{S|D} -/// and MOVLHPS. -bool X86::isMOVHPMask(ShuffleVectorSDNode *N) { +/// isMOVLHPSMask - Return true if the specified VECTOR_SHUFFLE operand +/// specifies a shuffle of elements that is suitable for input to MOVLHPS. +bool X86::isMOVLHPSMask(ShuffleVectorSDNode *N) { unsigned NumElems = N->getValueType(0).getVectorNumElements(); if (NumElems != 2 && NumElems != 4) @@ -2567,21 +2581,6 @@ return true; } -/// isMOVHLPS_v_undef_Mask - Special case of isMOVHLPSMask for canonical form -/// of vector_shuffle v, v, <2, 3, 2, 3>, i.e. vector_shuffle v, undef, -/// <2, 3, 2, 3> -bool X86::isMOVHLPS_v_undef_Mask(ShuffleVectorSDNode *N) { - unsigned NumElems = N->getValueType(0).getVectorNumElements(); - - if (NumElems != 4) - return false; - - return isUndefOrEqual(N->getMaskElt(0), 2) && - isUndefOrEqual(N->getMaskElt(1), 3) && - isUndefOrEqual(N->getMaskElt(2), 2) && - isUndefOrEqual(N->getMaskElt(3), 3); -} - /// isUNPCKLMask - Return true if the specified VECTOR_SHUFFLE operand /// specifies a shuffle of elements that is suitable for input to UNPCKL. static bool isUNPCKLMask(const SmallVectorImpl &Mask, EVT VT, @@ -4275,7 +4274,7 @@ if (!isMMX && (X86::isMOVSHDUPMask(SVOp) || X86::isMOVSLDUPMask(SVOp) || X86::isMOVHLPSMask(SVOp) || - X86::isMOVHPMask(SVOp) || + X86::isMOVLHPSMask(SVOp) || X86::isMOVLPMask(SVOp))) return Op; Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.h?rev=86415&r1=86414&r2=86415&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.h (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.h Sat Nov 7 17:17:15 2009 @@ -286,7 +286,7 @@ /// isMOVHPMask - Return true if the specified VECTOR_SHUFFLE operand /// specifies a shuffle of elements that is suitable for MOVHP{S|D}. /// as well as MOVLHPS. - bool isMOVHPMask(ShuffleVectorSDNode *N); + bool isMOVLHPSMask(ShuffleVectorSDNode *N); /// isUNPCKLMask - Return true if the specified VECTOR_SHUFFLE operand /// specifies a shuffle of elements that is suitable for input to UNPCKL. Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=86415&r1=86414&r2=86415&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Sat Nov 7 17:17:15 2009 @@ -225,9 +225,9 @@ return X86::isMOVHLPS_v_undef_Mask(cast(N)); }]>; -def movhp : PatFrag<(ops node:$lhs, node:$rhs), - (vector_shuffle node:$lhs, node:$rhs), [{ - return X86::isMOVHPMask(cast(N)); +def movlhps : PatFrag<(ops node:$lhs, node:$rhs), + (vector_shuffle node:$lhs, node:$rhs), [{ + return X86::isMOVLHPSMask(cast(N)); }]>; def movlp : PatFrag<(ops node:$lhs, node:$rhs), @@ -735,7 +735,7 @@ (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2), "movhps\t{$src2, $dst|$dst, $src2}", [(set VR128:$dst, - (movhp VR128:$src1, + (movlhps VR128:$src1, (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2))))))]>; } // AddedComplexity } // Constraints = "$src1 = $dst" @@ -760,7 +760,7 @@ (ins VR128:$src1, VR128:$src2), "movlhps\t{$src2, $dst|$dst, $src2}", [(set VR128:$dst, - (v4f32 (movhp VR128:$src1, VR128:$src2)))]>; + (v4f32 (movlhps VR128:$src1, VR128:$src2)))]>; def MOVHLPSrr : PSI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2), @@ -1494,7 +1494,7 @@ (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2), "movhpd\t{$src2, $dst|$dst, $src2}", [(set VR128:$dst, - (v2f64 (movhp VR128:$src1, + (v2f64 (movlhps VR128:$src1, (scalar_to_vector (loadf64 addr:$src2)))))]>; } // AddedComplexity } // Constraints = "$src1 = $dst" @@ -3035,7 +3035,7 @@ let AddedComplexity = 20 in { // vector_shuffle v1, v2 <0, 1, 4, 5> using MOVLHPS -def : Pat<(v4i32 (movhp VR128:$src1, VR128:$src2)), +def : Pat<(v4i32 (movlhps VR128:$src1, VR128:$src2)), (MOVLHPSrr VR128:$src1, VR128:$src2)>; // vector_shuffle v1, v2 <6, 7, 2, 3> using MOVHLPS @@ -3051,48 +3051,26 @@ let AddedComplexity = 20 in { // vector_shuffle v1, (load v2) <4, 5, 2, 3> using MOVLPS -// vector_shuffle v1, (load v2) <6, 7, 2, 3> using MOVHPS def : Pat<(v4f32 (movlp VR128:$src1, (load addr:$src2))), (MOVLPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>; def : Pat<(v2f64 (movlp VR128:$src1, (load addr:$src2))), (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>; -def : Pat<(v4f32 (movhlps (load addr:$src1), VR128:$src2)), - (MOVHPSrm VR128:$src2, addr:$src1)>, Requires<[HasSSE1]>; -def : Pat<(v2f64 (movhlps (load addr:$src1), VR128:$src2)), - (MOVHPDrm VR128:$src2, addr:$src1)>, Requires<[HasSSE2]>; - def : Pat<(v4i32 (movlp VR128:$src1, (load addr:$src2))), (MOVLPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>; def : Pat<(v2i64 (movlp VR128:$src1, (load addr:$src2))), (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>; -def : Pat<(v4i32 (movhp VR128:$src1, (load addr:$src2))), - (MOVHPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>; -def : Pat<(v2i64 (movhp VR128:$src1, (load addr:$src2))), - (MOVHPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>; } // (store (vector_shuffle (load addr), v2, <4, 5, 2, 3>), addr) using MOVLPS -// (store (vector_shuffle (load addr), v2, <0, 1, 4, 5>), addr) using MOVHPS def : Pat<(store (v4f32 (movlp (load addr:$src1), VR128:$src2)), addr:$src1), (MOVLPSmr addr:$src1, VR128:$src2)>, Requires<[HasSSE1]>; def : Pat<(store (v2f64 (movlp (load addr:$src1), VR128:$src2)), addr:$src1), (MOVLPDmr addr:$src1, VR128:$src2)>, Requires<[HasSSE2]>; -def : Pat<(store (v4f32 (movhlps (load addr:$src1), VR128:$src2)), addr:$src1), - (MOVHPSmr addr:$src1, VR128:$src2)>, Requires<[HasSSE1]>; -def : Pat<(store (v2f64 (movhlps (load addr:$src1), VR128:$src2)), addr:$src1), - (MOVHPDmr addr:$src1, VR128:$src2)>, Requires<[HasSSE2]>; - def : Pat<(store (v4i32 (movlp (bc_v4i32 (loadv2i64 addr:$src1)), VR128:$src2)), addr:$src1), (MOVLPSmr addr:$src1, VR128:$src2)>, Requires<[HasSSE1]>; def : Pat<(store (v2i64 (movlp (load addr:$src1), VR128:$src2)), addr:$src1), (MOVLPDmr addr:$src1, VR128:$src2)>, Requires<[HasSSE2]>; -def : Pat<(store (v4i32 (movhp (bc_v4i32 (loadv2i64 addr:$src1)), VR128:$src2)), - addr:$src1), - (MOVHPSmr addr:$src1, VR128:$src2)>, Requires<[HasSSE1]>; -def : Pat<(store (v2i64 (movhp (load addr:$src1), VR128:$src2)), addr:$src1), - (MOVHPDmr addr:$src1, VR128:$src2)>, Requires<[HasSSE2]>; - let AddedComplexity = 15 in { // Setting the lowest element in the vector. Modified: llvm/trunk/test/CodeGen/X86/vec_shuffle-3.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/vec_shuffle-3.ll?rev=86415&r1=86414&r2=86415&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/vec_shuffle-3.ll (original) +++ llvm/trunk/test/CodeGen/X86/vec_shuffle-3.ll Sat Nov 7 17:17:15 2009 @@ -1,6 +1,6 @@ ; RUN: llc < %s -march=x86 -mattr=+sse2 -o %t ; RUN: grep movlhps %t | count 1 -; RUN: grep movhps %t | count 1 +; RUN: grep movhlps %t | count 1 define <4 x float> @test1(<4 x float>* %x, <4 x float>* %y) { %tmp = load <4 x float>* %y ; <<4 x float>> [#uses=2] From daniel at zuster.org Sat Nov 7 17:21:31 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Sat, 07 Nov 2009 23:21:31 -0000 Subject: [llvm-commits] [llvm] r86416 - /llvm/trunk/include/llvm/CodeGen/SlotIndexes.h Message-ID: <200911072321.nA7NLVgP006972@zion.cs.uiuc.edu> Author: ddunbar Date: Sat Nov 7 17:21:30 2009 New Revision: 86416 URL: http://llvm.org/viewvc/llvm-project?rev=86416&view=rev Log: Fix class -> struct tag. Modified: llvm/trunk/include/llvm/CodeGen/SlotIndexes.h Modified: llvm/trunk/include/llvm/CodeGen/SlotIndexes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SlotIndexes.h?rev=86416&r1=86415&r2=86416&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/SlotIndexes.h (original) +++ llvm/trunk/include/llvm/CodeGen/SlotIndexes.h Sat Nov 7 17:21:30 2009 @@ -157,7 +157,7 @@ /// SlotIndex - An opaque wrapper around machine indexes. class SlotIndex { friend class SlotIndexes; - friend class DenseMapInfo; + friend struct DenseMapInfo; private: static const unsigned PHI_BIT = 1 << 2; From echristo at apple.com Sat Nov 7 17:23:44 2009 From: echristo at apple.com (Eric Christopher) Date: Sat, 7 Nov 2009 15:23:44 -0800 Subject: [llvm-commits] [llvm] r86415 - in /llvm/trunk: lib/Target/X86/X86ISelLowering.cpp lib/Target/X86/X86ISelLowering.h lib/Target/X86/X86InstrSSE.td test/CodeGen/X86/vec_shuffle-3.ll In-Reply-To: <200911072317.nA7NHGhb006771@zion.cs.uiuc.edu> References: <200911072317.nA7NHGhb006771@zion.cs.uiuc.edu> Message-ID: <9F6A23F7-BBF5-4C50-A622-A76B274FC5F1@apple.com> On Nov 7, 2009, at 3:17 PM, Nate Begeman wrote: > x86 vector shuffle cleanup/fixes: > > 1. rename the movhp patfrag to movlhps, since thats what it actually matches > 2. eliminate the bogus movhps load and store patterns, they were incorrect. The load transforms are already handled (correctly) by shufps/unpack. > 3. revert a recent test change to its correct form. Thanks for looking into it. :) -eric From daniel at zuster.org Sat Nov 7 17:51:55 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Sat, 07 Nov 2009 23:51:55 -0000 Subject: [llvm-commits] [llvm] r86417 - /llvm/trunk/lib/AsmParser/LLParser.cpp Message-ID: <200911072351.nA7NptPK007843@zion.cs.uiuc.edu> Author: ddunbar Date: Sat Nov 7 17:51:55 2009 New Revision: 86417 URL: http://llvm.org/viewvc/llvm-project?rev=86417&view=rev Log: Fix MSVC warning ( | with bool and unsigned int). Modified: llvm/trunk/lib/AsmParser/LLParser.cpp Modified: llvm/trunk/lib/AsmParser/LLParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=86417&r1=86416&r2=86417&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLParser.cpp (original) +++ llvm/trunk/lib/AsmParser/LLParser.cpp Sat Nov 7 17:51:55 2009 @@ -2039,7 +2039,7 @@ ParseToken(lltok::StringConstant, "expected constraint string")) return true; ID.StrVal2 = Lex.getStrVal(); - ID.UIntVal = HasSideEffect | ((unsigned)AlignStack<<1); + ID.UIntVal = unsigned(HasSideEffect) | (unsigned(AlignStack)<<1); ID.Kind = ValID::t_InlineAsm; return false; } From daniel at zuster.org Sat Nov 7 17:52:20 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Sat, 07 Nov 2009 23:52:20 -0000 Subject: [llvm-commits] [llvm] r86418 - in /llvm/trunk: cmake/config-ix.cmake test/CMakeLists.txt test/site.exp.in tools/llvm-config/CMakeLists.txt Message-ID: <200911072352.nA7NqKNr007876@zion.cs.uiuc.edu> Author: ddunbar Date: Sat Nov 7 17:52:20 2009 New Revision: 86418 URL: http://llvm.org/viewvc/llvm-project?rev=86418&view=rev Log: Stop running get_target_triple more than we need to. Modified: llvm/trunk/cmake/config-ix.cmake llvm/trunk/test/CMakeLists.txt llvm/trunk/test/site.exp.in llvm/trunk/tools/llvm-config/CMakeLists.txt Modified: llvm/trunk/cmake/config-ix.cmake URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/config-ix.cmake?rev=86418&r1=86417&r2=86418&view=diff ============================================================================== --- llvm/trunk/cmake/config-ix.cmake (original) +++ llvm/trunk/cmake/config-ix.cmake Sat Nov 7 17:52:20 2009 @@ -149,6 +149,9 @@ get_target_triple(LLVM_HOSTTRIPLE) message(STATUS "LLVM_HOSTTRIPLE: ${LLVM_HOSTTRIPLE}") +# FIXME: We don't distinguish the target and the host. :( +set(TARGET_TRIPLE "${LLVM_HOSTTRIPLE}") + # Determine the native architecture. string(TOLOWER "${LLVM_TARGET_ARCH}" LLVM_NATIVE_ARCH) if( LLVM_NATIVE_ARCH STREQUAL "host" ) Modified: llvm/trunk/test/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CMakeLists.txt?rev=86418&r1=86417&r2=86418&view=diff ============================================================================== --- llvm/trunk/test/CMakeLists.txt (original) +++ llvm/trunk/test/CMakeLists.txt Sat Nov 7 17:52:20 2009 @@ -1,6 +1,3 @@ -include(GetTargetTriple) -get_target_triple(target) - foreach(c ${LLVM_TARGETS_TO_BUILD}) set(TARGETS_BUILT "${TARGETS_BUILT} ${c}") endforeach(c) Modified: llvm/trunk/test/site.exp.in URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/site.exp.in?rev=86418&r1=86417&r2=86418&view=diff ============================================================================== --- llvm/trunk/test/site.exp.in (original) +++ llvm/trunk/test/site.exp.in Sat Nov 7 17:52:20 2009 @@ -1,6 +1,6 @@ ## Autogenerated by LLVM/Clang configuration. # Do not edit! -set target_triplet "@target@" +set target_triplet "@TARGET_TRIPLE@" set TARGETS_TO_BUILD "@TARGETS_TO_BUILD@" set llvmgcc_langs "@LLVMGCC_LANGS@" set llvmgcc_version "@LLVMGCC_VERSION@" Modified: llvm/trunk/tools/llvm-config/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-config/CMakeLists.txt?rev=86418&r1=86417&r2=86418&view=diff ============================================================================== --- llvm/trunk/tools/llvm-config/CMakeLists.txt (original) +++ llvm/trunk/tools/llvm-config/CMakeLists.txt Sat Nov 7 17:52:20 2009 @@ -36,9 +36,6 @@ set(LLVM_SYSTEM_LIBS ${LLVM_SYSTEM_LIBS} "-l${l}") endforeach() -include(GetTargetTriple) -get_target_triple(target) - foreach(c ${LLVM_TARGETS_TO_BUILD}) set(TARGETS_BUILT "${TARGETS_BUILT} ${c}") endforeach(c) From daniel at zuster.org Sat Nov 7 17:52:27 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Sat, 07 Nov 2009 23:52:27 -0000 Subject: [llvm-commits] [llvm] r86419 - in /llvm/trunk/cmake: config-ix.cmake modules/GetTargetTriple.cmake Message-ID: <200911072352.nA7NqRPS007892@zion.cs.uiuc.edu> Author: ddunbar Date: Sat Nov 7 17:52:27 2009 New Revision: 86419 URL: http://llvm.org/viewvc/llvm-project?rev=86419&view=rev Log: Fix CMake reporting of target triple. Modified: llvm/trunk/cmake/config-ix.cmake llvm/trunk/cmake/modules/GetTargetTriple.cmake Modified: llvm/trunk/cmake/config-ix.cmake URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/config-ix.cmake?rev=86419&r1=86418&r2=86419&view=diff ============================================================================== --- llvm/trunk/cmake/config-ix.cmake (original) +++ llvm/trunk/cmake/config-ix.cmake Sat Nov 7 17:52:27 2009 @@ -147,7 +147,6 @@ include(GetTargetTriple) get_target_triple(LLVM_HOSTTRIPLE) -message(STATUS "LLVM_HOSTTRIPLE: ${LLVM_HOSTTRIPLE}") # FIXME: We don't distinguish the target and the host. :( set(TARGET_TRIPLE "${LLVM_HOSTTRIPLE}") Modified: llvm/trunk/cmake/modules/GetTargetTriple.cmake URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/GetTargetTriple.cmake?rev=86419&r1=86418&r2=86419&view=diff ============================================================================== --- llvm/trunk/cmake/modules/GetTargetTriple.cmake (original) +++ llvm/trunk/cmake/modules/GetTargetTriple.cmake Sat Nov 7 17:52:27 2009 @@ -4,12 +4,12 @@ function( get_target_triple var ) if( MSVC ) if( CMAKE_CL_64 ) - set( ${var} "x86_64-pc-win32" PARENT_SCOPE ) + set( value "x86_64-pc-win32" ) else() - set( ${var} "i686-pc-win32" PARENT_SCOPE ) + set( value "i686-pc-win32" ) endif() elseif( MINGW AND NOT MSYS ) - set( ${var} "i686-pc-mingw32" PARENT_SCOPE ) + set( value "i686-pc-mingw32" ) else( MSVC ) set(config_guess ${LLVM_MAIN_SRC_DIR}/autoconf/config.guess) execute_process(COMMAND sh ${config_guess} @@ -19,7 +19,8 @@ if( NOT TT_RV EQUAL 0 ) message(FATAL_ERROR "Failed to execute ${config_guess}") endif( NOT TT_RV EQUAL 0 ) - set( ${var} ${TT_OUT} PARENT_SCOPE ) - message(STATUS "Target triple: ${${var}}") + set( value ${TT_OUT} ) endif( MSVC ) + set( ${var} ${value} PARENT_SCOPE ) + message(STATUS "Target triple: ${value}") endfunction( get_target_triple var ) From evan.cheng at apple.com Sat Nov 7 18:15:24 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Sun, 08 Nov 2009 00:15:24 -0000 Subject: [llvm-commits] [llvm] r86423 - in /llvm/trunk/lib/Target/ARM: ARMBaseInstrInfo.cpp ARMBaseInstrInfo.h ARMInstrInfo.cpp Thumb1InstrInfo.cpp Thumb1InstrInfo.h Thumb2InstrInfo.cpp Thumb2InstrInfo.h Message-ID: <200911080015.nA80FObx008764@zion.cs.uiuc.edu> Author: evancheng Date: Sat Nov 7 18:15:23 2009 New Revision: 86423 URL: http://llvm.org/viewvc/llvm-project?rev=86423&view=rev Log: Refactor code. Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.cpp llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.h llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.h Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp?rev=86423&r1=86422&r2=86423&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp Sat Nov 7 18:15:23 2009 @@ -18,6 +18,9 @@ #include "ARMGenInstrInfo.inc" #include "ARMMachineFunctionInfo.h" #include "ARMRegisterInfo.h" +#include "llvm/Constants.h" +#include "llvm/Function.h" +#include "llvm/GlobalValue.h" #include "llvm/ADT/STLExtras.h" #include "llvm/CodeGen/LiveVariables.h" #include "llvm/CodeGen/MachineConstantPool.h" @@ -897,6 +900,57 @@ return false; } +void ARMBaseInstrInfo:: +reMaterialize(MachineBasicBlock &MBB, + MachineBasicBlock::iterator I, + unsigned DestReg, unsigned SubIdx, + const MachineInstr *Orig) const { + DebugLoc dl = Orig->getDebugLoc(); + unsigned Opcode = Orig->getOpcode(); + switch (Opcode) { + default: { + MachineInstr *MI = MBB.getParent()->CloneMachineInstr(Orig); + MI->getOperand(0).setReg(DestReg); + MBB.insert(I, MI); + break; + } + case ARM::tLDRpci_pic: + case ARM::t2LDRpci_pic: { + MachineFunction &MF = *MBB.getParent(); + ARMFunctionInfo *AFI = MF.getInfo(); + MachineConstantPool *MCP = MF.getConstantPool(); + unsigned CPI = Orig->getOperand(1).getIndex(); + const MachineConstantPoolEntry &MCPE = MCP->getConstants()[CPI]; + assert(MCPE.isMachineConstantPoolEntry() && + "Expecting a machine constantpool entry!"); + ARMConstantPoolValue *ACPV = + static_cast(MCPE.Val.MachineCPVal); + unsigned PCLabelId = AFI->createConstPoolEntryUId(); + ARMConstantPoolValue *NewCPV = 0; + if (ACPV->isGlobalValue()) + NewCPV = new ARMConstantPoolValue(ACPV->getGV(), PCLabelId, + ARMCP::CPValue, 4); + else if (ACPV->isExtSymbol()) + NewCPV = new ARMConstantPoolValue(MF.getFunction()->getContext(), + ACPV->getSymbol(), PCLabelId, 4); + else if (ACPV->isBlockAddress()) + NewCPV = new ARMConstantPoolValue(ACPV->getBlockAddress(), PCLabelId, + ARMCP::CPBlockAddress, 4); + else + llvm_unreachable("Unexpected ARM constantpool value type!!"); + CPI = MCP->getConstantPoolIndex(NewCPV, MCPE.getAlignment()); + MachineInstrBuilder MIB = BuildMI(MBB, I, Orig->getDebugLoc(), get(Opcode), + DestReg) + .addConstantPoolIndex(CPI).addImm(PCLabelId); + (*MIB).setMemRefs(Orig->memoperands_begin(), Orig->memoperands_end()); + break; + } + } + + MachineInstr *NewMI = prior(I); + NewMI->getOperand(0).setSubReg(SubIdx); +} + bool ARMBaseInstrInfo::isIdentical(const MachineInstr *MI0, const MachineInstr *MI1, const MachineRegisterInfo *MRI) const { Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h?rev=86423&r1=86422&r2=86423&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h Sat Nov 7 18:15:23 2009 @@ -264,6 +264,11 @@ const SmallVectorImpl &Ops, MachineInstr* LoadMI) const; + virtual void reMaterialize(MachineBasicBlock &MBB, + MachineBasicBlock::iterator MI, + unsigned DestReg, unsigned SubIdx, + const MachineInstr *Orig) const; + virtual bool isIdentical(const MachineInstr *MI, const MachineInstr *Other, const MachineRegisterInfo *MRI) const; }; Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp?rev=86423&r1=86422&r2=86423&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp Sat Nov 7 18:15:23 2009 @@ -80,29 +80,26 @@ } void ARMInstrInfo:: -reMaterialize(MachineBasicBlock &MBB, - MachineBasicBlock::iterator I, +reMaterialize(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, unsigned DestReg, unsigned SubIdx, const MachineInstr *Orig) const { DebugLoc dl = Orig->getDebugLoc(); unsigned Opcode = Orig->getOpcode(); switch (Opcode) { - default: { - MachineInstr *MI = MBB.getParent()->CloneMachineInstr(Orig); - MI->getOperand(0).setReg(DestReg); - MBB.insert(I, MI); + default: break; - } - case ARM::MOVi2pieces: + case ARM::MOVi2pieces: { RI.emitLoadConstPool(MBB, I, dl, DestReg, SubIdx, Orig->getOperand(1).getImm(), (ARMCC::CondCodes)Orig->getOperand(2).getImm(), Orig->getOperand(3).getReg()); - break; + MachineInstr *NewMI = prior(I); + NewMI->getOperand(0).setSubReg(SubIdx); + return; + } } - MachineInstr *NewMI = prior(I); - NewMI->getOperand(0).setSubReg(SubIdx); + return ARMBaseInstrInfo::reMaterialize(MBB, I, DestReg, SubIdx, Orig); } Modified: llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.cpp?rev=86423&r1=86422&r2=86423&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.cpp Sat Nov 7 18:15:23 2009 @@ -13,13 +13,8 @@ #include "Thumb1InstrInfo.h" #include "ARM.h" -#include "ARMConstantPoolValue.h" #include "ARMGenInstrInfo.inc" #include "ARMMachineFunctionInfo.h" -#include "llvm/Constants.h" -#include "llvm/Function.h" -#include "llvm/GlobalValue.h" -#include "llvm/CodeGen/MachineConstantPool.h" #include "llvm/CodeGen/MachineFrameInfo.h" #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/MachineMemOperand.h" @@ -268,53 +263,3 @@ return NewMI; } - -void Thumb1InstrInfo::reMaterialize(MachineBasicBlock &MBB, - MachineBasicBlock::iterator I, - unsigned DestReg, unsigned SubIdx, - const MachineInstr *Orig) const { - DebugLoc dl = Orig->getDebugLoc(); - unsigned Opcode = Orig->getOpcode(); - switch (Opcode) { - default: { - MachineInstr *MI = MBB.getParent()->CloneMachineInstr(Orig); - MI->getOperand(0).setReg(DestReg); - MBB.insert(I, MI); - break; - } - case ARM::tLDRpci_pic: { - MachineFunction &MF = *MBB.getParent(); - ARMFunctionInfo *AFI = MF.getInfo(); - MachineConstantPool *MCP = MF.getConstantPool(); - unsigned CPI = Orig->getOperand(1).getIndex(); - const MachineConstantPoolEntry &MCPE = MCP->getConstants()[CPI]; - assert(MCPE.isMachineConstantPoolEntry() && - "Expecting a machine constantpool entry!"); - ARMConstantPoolValue *ACPV = - static_cast(MCPE.Val.MachineCPVal); - unsigned PCLabelId = AFI->createConstPoolEntryUId(); - ARMConstantPoolValue *NewCPV = 0; - if (ACPV->isGlobalValue()) - NewCPV = new ARMConstantPoolValue(ACPV->getGV(), PCLabelId, - ARMCP::CPValue, 4); - else if (ACPV->isExtSymbol()) - NewCPV = new ARMConstantPoolValue(MF.getFunction()->getContext(), - ACPV->getSymbol(), PCLabelId, 4); - else if (ACPV->isBlockAddress()) - NewCPV = new ARMConstantPoolValue(ACPV->getBlockAddress(), PCLabelId, - ARMCP::CPBlockAddress, 4); - else - llvm_unreachable("Unexpected ARM constantpool value type!!"); - CPI = MCP->getConstantPoolIndex(NewCPV, MCPE.getAlignment()); - MachineInstrBuilder MIB = BuildMI(MBB, I, Orig->getDebugLoc(), get(Opcode), - DestReg) - .addConstantPoolIndex(CPI).addImm(PCLabelId); - (*MIB).setMemRefs(Orig->memoperands_begin(), Orig->memoperands_end()); - break; - } - } - - MachineInstr *NewMI = prior(I); - NewMI->getOperand(0).setSubReg(SubIdx); -} - Modified: llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.h?rev=86423&r1=86422&r2=86423&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.h (original) +++ llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.h Sat Nov 7 18:15:23 2009 @@ -76,10 +76,6 @@ MachineInstr* LoadMI) const { return 0; } - - void reMaterialize(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, - unsigned DestReg, unsigned SubIdx, - const MachineInstr *Orig) const; }; } Modified: llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp?rev=86423&r1=86422&r2=86423&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp Sat Nov 7 18:15:23 2009 @@ -17,10 +17,6 @@ #include "ARMAddressingModes.h" #include "ARMGenInstrInfo.inc" #include "ARMMachineFunctionInfo.h" -#include "llvm/Constants.h" -#include "llvm/Function.h" -#include "llvm/GlobalValue.h" -#include "llvm/CodeGen/MachineConstantPool.h" #include "llvm/CodeGen/MachineFrameInfo.h" #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/MachineMemOperand.h" @@ -137,55 +133,6 @@ ARMBaseInstrInfo::loadRegFromStackSlot(MBB, I, DestReg, FI, RC); } -void Thumb2InstrInfo::reMaterialize(MachineBasicBlock &MBB, - MachineBasicBlock::iterator I, - unsigned DestReg, unsigned SubIdx, - const MachineInstr *Orig) const { - DebugLoc dl = Orig->getDebugLoc(); - unsigned Opcode = Orig->getOpcode(); - switch (Opcode) { - default: { - MachineInstr *MI = MBB.getParent()->CloneMachineInstr(Orig); - MI->getOperand(0).setReg(DestReg); - MBB.insert(I, MI); - break; - } - case ARM::t2LDRpci_pic: { - MachineFunction &MF = *MBB.getParent(); - ARMFunctionInfo *AFI = MF.getInfo(); - MachineConstantPool *MCP = MF.getConstantPool(); - unsigned CPI = Orig->getOperand(1).getIndex(); - const MachineConstantPoolEntry &MCPE = MCP->getConstants()[CPI]; - assert(MCPE.isMachineConstantPoolEntry() && - "Expecting a machine constantpool entry!"); - ARMConstantPoolValue *ACPV = - static_cast(MCPE.Val.MachineCPVal); - unsigned PCLabelId = AFI->createConstPoolEntryUId(); - ARMConstantPoolValue *NewCPV = 0; - if (ACPV->isGlobalValue()) - NewCPV = new ARMConstantPoolValue(ACPV->getGV(), PCLabelId, - ARMCP::CPValue, 4); - else if (ACPV->isExtSymbol()) - NewCPV = new ARMConstantPoolValue(MF.getFunction()->getContext(), - ACPV->getSymbol(), PCLabelId, 4); - else if (ACPV->isBlockAddress()) - NewCPV = new ARMConstantPoolValue(ACPV->getBlockAddress(), PCLabelId, - ARMCP::CPBlockAddress, 4); - else - llvm_unreachable("Unexpected ARM constantpool value type!!"); - CPI = MCP->getConstantPoolIndex(NewCPV, MCPE.getAlignment()); - MachineInstrBuilder MIB = BuildMI(MBB, I, Orig->getDebugLoc(), get(Opcode), - DestReg) - .addConstantPoolIndex(CPI).addImm(PCLabelId); - (*MIB).setMemRefs(Orig->memoperands_begin(), Orig->memoperands_end()); - break; - } - } - - MachineInstr *NewMI = prior(I); - NewMI->getOperand(0).setSubReg(SubIdx); -} - void llvm::emitT2RegPlusImmediate(MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI, DebugLoc dl, unsigned DestReg, unsigned BaseReg, int NumBytes, Modified: llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.h?rev=86423&r1=86422&r2=86423&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.h (original) +++ llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.h Sat Nov 7 18:15:23 2009 @@ -50,10 +50,6 @@ unsigned DestReg, int FrameIndex, const TargetRegisterClass *RC) const; - void reMaterialize(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, - unsigned DestReg, unsigned SubIdx, - const MachineInstr *Orig) const; - /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As /// such, whenever a client has an instance of instruction info, it should /// always be able to get register info as well (through this method). From grosbach at apple.com Sat Nov 7 18:27:09 2009 From: grosbach at apple.com (Jim Grosbach) Date: Sat, 7 Nov 2009 16:27:09 -0800 Subject: [llvm-commits] [llvm] r86423 - in /llvm/trunk/lib/Target/ARM: ARMBaseInstrInfo.cpp ARMBaseInstrInfo.h ARMInstrInfo.cpp Thumb1InstrInfo.cpp Thumb1InstrInfo.h Thumb2InstrInfo.cpp Thumb2InstrInfo.h In-Reply-To: <200911080015.nA80FObx008764@zion.cs.uiuc.edu> References: <200911080015.nA80FObx008764@zion.cs.uiuc.edu> Message-ID: Very nice. Good to see more commonality. On Nov 7, 2009, at 4:15 PM, Evan Cheng wrote: > Author: evancheng > Date: Sat Nov 7 18:15:23 2009 > New Revision: 86423 > > URL: http://llvm.org/viewvc/llvm-project?rev=86423&view=rev > Log: > Refactor code. > > Modified: > llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp > llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h > llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp > llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.cpp > llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.h > llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp > llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.h > > Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp?rev=86423&r1=86422&r2=86423&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp (original) > +++ llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp Sat Nov 7 > 18:15:23 2009 > @@ -18,6 +18,9 @@ > #include "ARMGenInstrInfo.inc" > #include "ARMMachineFunctionInfo.h" > #include "ARMRegisterInfo.h" > +#include "llvm/Constants.h" > +#include "llvm/Function.h" > +#include "llvm/GlobalValue.h" > #include "llvm/ADT/STLExtras.h" > #include "llvm/CodeGen/LiveVariables.h" > #include "llvm/CodeGen/MachineConstantPool.h" > @@ -897,6 +900,57 @@ > return false; > } > > +void ARMBaseInstrInfo:: > +reMaterialize(MachineBasicBlock &MBB, > + MachineBasicBlock::iterator I, > + unsigned DestReg, unsigned SubIdx, > + const MachineInstr *Orig) const { > + DebugLoc dl = Orig->getDebugLoc(); > + unsigned Opcode = Orig->getOpcode(); > + switch (Opcode) { > + default: { > + MachineInstr *MI = MBB.getParent()->CloneMachineInstr(Orig); > + MI->getOperand(0).setReg(DestReg); > + MBB.insert(I, MI); > + break; > + } > + case ARM::tLDRpci_pic: > + case ARM::t2LDRpci_pic: { > + MachineFunction &MF = *MBB.getParent(); > + ARMFunctionInfo *AFI = MF.getInfo(); > + MachineConstantPool *MCP = MF.getConstantPool(); > + unsigned CPI = Orig->getOperand(1).getIndex(); > + const MachineConstantPoolEntry &MCPE = MCP->getConstants()[CPI]; > + assert(MCPE.isMachineConstantPoolEntry() && > + "Expecting a machine constantpool entry!"); > + ARMConstantPoolValue *ACPV = > + static_cast(MCPE.Val.MachineCPVal); > + unsigned PCLabelId = AFI->createConstPoolEntryUId(); > + ARMConstantPoolValue *NewCPV = 0; >