[llvm-commits] [llvm] r40776 - /llvm/trunk/lib/Transforms/Scalar/GVN.cpp
Author: resistor Date: Fri Aug 3 06:03:26 2007 New Revision: 40776 URL: http://llvm.org/viewvc/llvm-project?rev=40776&view=rev Log: Fix a subtle iterator invalidation bug in a recursive algorithm. Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=40776&r1=40775&r2=40776&view=diff == --- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Fri Aug 3 06:03:26 2007 @@ -726,19 +726,21 @@ bool top_level) { // If we have already computed this value, return the previously computed val. - Value *&V = Phis[BB]; + Value *V = Phis[BB]; if (V && ! top_level) return V; BasicBlock* singlePred = BB->getSinglePredecessor(); - if (singlePred) -return V = GetValueForBlock(singlePred, orig, Phis); - + if (singlePred) { +V = GetValueForBlock(singlePred, orig, Phis); +Phis[BB] = V; +return V; + } // Otherwise, the idom is the loop, so we need to insert a PHI node. Do so // now, then get values to fill in the incoming values for the PHI. PHINode *PN = new PHINode(orig->getType(), orig->getName()+".rle", BB->begin()); PN->reserveOperandSpace(std::distance(pred_begin(BB), pred_end(BB))); - V = PN; + Phis[BB] = PN; bool all_same = true; Value* first = 0; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [PATCH] partial codgen support for ByVal arguments
The attached patch implements code generation of byval arguments on the callee. For now only the case were the struct is in the stack is handle correctly. With the patch, the function --- %struct.s = type { i64, i64, i64 } define i64 @f(%struct.s* byval %a) { entry: %tmp2 = getelementptr %struct.s* %a, i32 0, i32 0] %tmp3 = load i64* %tmp2 ret i64 %tmp3 } Correctly compiles to f: movq8(%rsp), %rax ret There is still a lot to implement and debug, but I would like to know any comments one might have. Cheers, -- Rafael Avila de Espindola Google Ireland Ltd. Gordon House Barrow Street Dublin 4 Ireland Registered in Dublin, Ireland Registration Number: 368047 Index: include/llvm/CodeGen/SelectionDAGNodes.h === --- include/llvm/CodeGen/SelectionDAGNodes.h (revision 40777) +++ include/llvm/CodeGen/SelectionDAGNodes.h (working copy) @@ -68,6 +68,10 @@ ByValOffs = 4, Nest = 1<<5, ///< Parameter is nested function static chain NestOffs = 5, +ByValAlign= 0xF << 6, //< The alignment of the struct +ByValAlignOffs= 6, +ByValSize = 0x1 << 10, //< The size of the struct +ByValSizeOffs = 10, OrigAlignment = 0x1F<<27, OrigAlignmentOffs = 27 }; @@ -200,6 +204,10 @@ /// Bit 0 - signness /// Bit 1 - 'inreg' attribute /// Bit 2 - 'sret' attribute +/// Bit 4 - 'byval' attribute +/// Bit 5 - 'nest' attribute +/// Bit 6-9 - alignment of byval structures +/// Bit 10-26 - size of byval structures /// Bits 31:27 - argument ABI alignment in the first argument piece and /// alignment '1' in other argument pieces. CALL, Index: include/llvm/CodeGen/CallingConvLower.h === --- include/llvm/CodeGen/CallingConvLower.h (revision 40777) +++ include/llvm/CodeGen/CallingConvLower.h (working copy) @@ -190,6 +190,10 @@ StackOffset += Size; return Result; } + + void HandleStruct(unsigned ValNo, MVT::ValueType ValVT, +MVT::ValueType LocVT, CCValAssign::LocInfo LocInfo, +unsigned ArgFlags); private: /// MarkAllocated - Mark a register and all of its aliases as allocated. void MarkAllocated(unsigned Reg); Index: utils/TableGen/CallingConvEmitter.cpp === --- utils/TableGen/CallingConvEmitter.cpp (revision 40777) +++ utils/TableGen/CallingConvEmitter.cpp (working copy) @@ -130,7 +130,9 @@ << IndentStr << "else\n" << IndentStr << IndentStr << "LocInfo = CCValAssign::AExt;\n"; } else if (Action->isSubClassOf("CCStructAssign")) { - O << "assert(0 && \"Not Implemented\");\n"; + O << IndentStr << + "State.HandleStruct(ValNo, ValVT, LocVT, LocInfo, ArgFlags);\n"; + O << IndentStr << "return false;\n"; } else { Action->dump(); throw "Unknown CCAction!"; Index: lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp === --- lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (revision 40777) +++ lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (working copy) @@ -3848,8 +3848,15 @@ Flags |= ISD::ParamFlags::InReg; if (Attrs && Attrs->paramHasAttr(j, ParamAttr::StructRet)) Flags |= ISD::ParamFlags::StructReturn; -if (Attrs && Attrs->paramHasAttr(j, ParamAttr::ByVal)) +if (Attrs && Attrs->paramHasAttr(j, ParamAttr::ByVal)) { Flags |= ISD::ParamFlags::ByVal; + const PointerType *Ty = cast(I->getType()); + const StructType *STy = cast(Ty->getElementType()); + unsigned StructAlign = Log2_32(getTargetData()->getABITypeAlignment(STy)); + unsigned StructSize = getTargetData()->getTypeSize(STy); + Flags |= (StructAlign << ISD::ParamFlags::ByValAlignOffs); + Flags |= (StructSize << ISD::ParamFlags::ByValSizeOffs); +} if (Attrs && Attrs->paramHasAttr(j, ParamAttr::Nest)) Flags |= ISD::ParamFlags::Nest; Flags |= (OriginalAlignment << ISD::ParamFlags::OrigAlignmentOffs); Index: lib/CodeGen/SelectionDAG/CallingConvLower.cpp === --- lib/CodeGen/SelectionDAG/CallingConvLower.cpp (revision 40777) +++ lib/CodeGen/SelectionDAG/CallingConvLower.cpp (working copy) @@ -28,7 +28,18 @@ UsedRegs.resize(MRI.getNumRegs()); } +void CCState::HandleStruct(unsigned ValNo, MVT::ValueType ValVT, + MVT::ValueType LocVT, CCValAssign::LocInfo LocInfo, + unsigned ArgFlags) { + unsigned Align = 1 << ((ArgFlags & ISD::ParamFlags::ByValAlign) >> + ISD::ParamFlags::ByValAlignOffs); + unsigned Size = (ArgFlags & ISD::ParamFlags::ByValSize)
[llvm-commits] Current List Of Linux Failures (Time For Bug Bash?)
All, Below is a current list of failures on i686-pc-linux-gnu for trunk as of r40774 (current). While a few known failures are (EH, etc.) tolerated, the list has grown to the unacceptable level. I would encourage the Linux developers to begin early to address these test cases as the volume of them warrants an early start for the release. Your help would be very much appreciated. Thanks, Reid. External/nightly.out:TEST-FAIL: jit /External/SPEC/CFP2006/444.namd/444.namd External/nightly.out:TEST-FAIL: cbe /External/SPEC/CINT2006/400.perlbench/400.perlbench External/nightly.out:TEST-FAIL: cbe /External/SPEC/CINT2006/403.gcc/403.gcc External/nightly.out:TEST-FAIL: llc /External/SPEC/CINT2006/471.omnetpp/471.omnetpp External/nightly.out:TEST-FAIL: jit /External/SPEC/CINT2006/471.omnetpp/471.omnetpp External/nightly.out:TEST-FAIL: cbe /External/SPEC/CINT2006/471.omnetpp/471.omnetpp External/nightly.out:TEST-FAIL: cbe /External/SPEC/CINT2000/176.gcc/176.gcc External/nightly.out:TEST-FAIL: jit /External/SPEC/CINT2000/186.crafty/186.crafty External/nightly.out:TEST-FAIL: cbe /External/SPEC/CINT2000/254.gap/254.gap MultiSource/nightly.out:TEST-FAIL: cbe /MultiSource/Applications/SPASS/SPASS MultiSource/nightly.out:TEST-FAIL: llc /MultiSource/Applications/oggenc/oggenc MultiSource/nightly.out:TEST-FAIL: jit /MultiSource/Applications/oggenc/oggenc MultiSource/nightly.out:TEST-FAIL: cbe /MultiSource/Applications/oggenc/oggenc MultiSource/nightly.out:TEST-FAIL: cbe /MultiSource/Applications/JM/ldecod/ldecod MultiSource/nightly.out:TEST-FAIL: cbe /MultiSource/Applications/JM/lencod/lencod MultiSource/nightly.out:TEST-FAIL: jit /MultiSource/Applications/minisat/minisat MultiSource/nightly.out:TEST-FAIL: cbe /MultiSource/Benchmarks/McCat/18-imp/imp MultiSource/nightly.out:TEST-FAIL: cbe /MultiSource/Benchmarks/Ptrdist/bc/bc MultiSource/nightly.out:TEST-FAIL: cbe /MultiSource/Benchmarks/FreeBench/pcompress2/pcompress2 MultiSource/nightly.out:TEST-FAIL: cbe /MultiSource/Benchmarks/MallocBench/gs/gs MultiSource/nightly.out:TEST-FAIL: cbe /MultiSource/Benchmarks/mediabench/gsm/toast/toast MultiSource/nightly.out:TEST-FAIL: cbe /MultiSource/Benchmarks/mediabench/jpeg/jpeg-6a/cjpeg MultiSource/nightly.out:TEST-FAIL: cbe /MultiSource/Benchmarks/MiBench/automotive-susan/automotive-susan MultiSource/nightly.out:TEST-FAIL: cbe /MultiSource/Benchmarks/MiBench/consumer-jpeg/consumer-jpeg MultiSource/nightly.out:TEST-FAIL: cbe /MultiSource/Benchmarks/MiBench/consumer-lame/consumer-lame MultiSource/nightly.out:TEST-FAIL: cbe /MultiSource/Benchmarks/MiBench/telecomm-gsm/telecomm-gsm MultiSource/nightly.out:TEST-FAIL: cbe /MultiSource/Benchmarks/tramp3d-v4/tramp3d-v4 SingleSource/nightly.out:TEST-FAIL: llc /SingleSource/UnitTests/Vector/SSE/sse.expandfft SingleSource/nightly.out:TEST-FAIL: jit /SingleSource/UnitTests/Vector/SSE/sse.expandfft SingleSource/nightly.out:TEST-FAIL: jit /SingleSource/UnitTests/Vector/multiplies SingleSource/nightly.out:TEST-FAIL: jit /SingleSource/UnitTests/Threads/tls SingleSource/nightly.out:TEST-FAIL: jit /SingleSource/UnitTests/2007-04-25-weak SingleSource/nightly.out:TEST-FAIL: llc /SingleSource/Regression/C++/EH/ctor_dtor_count-2 SingleSource/nightly.out:TEST-FAIL: jit /SingleSource/Regression/C++/EH/ctor_dtor_count-2 SingleSource/nightly.out:TEST-FAIL: cbe /SingleSource/Regression/C++/EH/ctor_dtor_count-2 SingleSource/nightly.out:TEST-FAIL: llc /SingleSource/Regression/C++/EH/ctor_dtor_count SingleSource/nightly.out:TEST-FAIL: jit /SingleSource/Regression/C++/EH/ctor_dtor_count SingleSource/nightly.out:TEST-FAIL: cbe /SingleSource/Regression/C++/EH/ctor_dtor_count SingleSource/nightly.out:TEST-FAIL: llc /SingleSource/Regression/C++/EH/exception_spec_test SingleSource/nightly.out:TEST-FAIL: jit /SingleSource/Regression/C++/EH/exception_spec_test SingleSource/nightly.out:TEST-FAIL: cbe /SingleSource/Regression/C++/EH/exception_spec_test SingleSource/nightly.out:TEST-FAIL: llc /SingleSource/Regression/C++/EH/function_try_block SingleSource/nightly.out:TEST-FAIL: jit /SingleSource/Regression/C++/EH/function_try_block SingleSource/nightly.out:TEST-FAIL: cbe /SingleSource/Regression/C++/EH/function_try_block SingleSource/nightly.out:TEST-FAIL: llc /SingleSource/Regression/C++/EH/simple_rethrow SingleSource/nightly.out:TEST-FAIL: jit /SingleSource/Regression/C++/EH/simple_rethrow SingleSource/nightly.out:TEST-FAIL: cbe /SingleSource/Regression/C++/EH/simple_rethrow SingleSource/nightly.out:TEST-FAIL: llc /SingleSource/Regression/C++/EH/simple_throw SingleSource/nightly.out:TEST-FAIL: jit /SingleSource/Regression/C++/EH/simple_throw SingleSource/nightly.out:TEST-FAIL: cbe /SingleSource/Regression/C++/EH/simple_throw SingleSource/nightly.out:TEST-FAIL: llc /SingleSource/Regression/C++/EH/throw_rethrow_test SingleSource/nightly.out:TEST-FAIL: jit /SingleSource/Regression/C++/EH/throw_rethrow_test SingleSource/nightly.out:TEST-FAIL: cbe /SingleSource/Regression/C++/EH/thr
[llvm-commits] [poolalloc] r40786 - in /poolalloc/branches/SVA/lib/DSA: DataStructure.cpp Info.cpp LeafRepl.cpp Local.cpp
Author: alenhar2 Date: Fri Aug 3 12:46:27 2007 New Revision: 40786 URL: http://llvm.org/viewvc/llvm-project?rev=40786&view=rev Log: kernel stat pass and cleanup Modified: poolalloc/branches/SVA/lib/DSA/DataStructure.cpp poolalloc/branches/SVA/lib/DSA/Info.cpp poolalloc/branches/SVA/lib/DSA/LeafRepl.cpp poolalloc/branches/SVA/lib/DSA/Local.cpp Modified: poolalloc/branches/SVA/lib/DSA/DataStructure.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/branches/SVA/lib/DSA/DataStructure.cpp?rev=40786&r1=40785&r2=40786&view=diff == --- poolalloc/branches/SVA/lib/DSA/DataStructure.cpp (original) +++ poolalloc/branches/SVA/lib/DSA/DataStructure.cpp Fri Aug 3 12:46:27 2007 @@ -1890,7 +1890,7 @@ if (Callee->getNumReferrers() == 1 && Callee->isComplete() && Callee->getGlobalsList().empty()) { // No useful info? #ifndef NDEBUG -std::cerr << "WARNING: Useless call site found.\n"; +std::cerr << "WARNING: Useless call site found in " << CS.getCallSite().getInstruction()->getParent()->getParent()->getName() << "\n"; #endif Calls.erase(OldIt); ++NumDeleted; Modified: poolalloc/branches/SVA/lib/DSA/Info.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/branches/SVA/lib/DSA/Info.cpp?rev=40786&r1=40785&r2=40786&view=diff == --- poolalloc/branches/SVA/lib/DSA/Info.cpp (original) +++ poolalloc/branches/SVA/lib/DSA/Info.cpp Fri Aug 3 12:46:27 2007 @@ -2,7 +2,12 @@ #include "llvm/Function.h" #include "llvm/BasicBlock.h" #include "llvm/Instructions.h" +#include "llvm/Constants.h" #include "llvm/ADT/Statistic.h" +#include "llvm/Support/InstVisitor.h" + +#include "dsa/DataStructure.h" +#include "dsa/DSGraph.h" using namespace llvm; @@ -26,3 +31,156 @@ RegisterPass X("call-info", "Call Info Pass"); } + +struct dsstat { + int U; + int I; + int UI; + int F; + int T; + void add(DSNode* N) { +if (!N) return; +if (N->isIncomplete()) ++I; +if (N->isUnknownNode()) ++U; +if (N->isIncomplete() && N->isUnknownNode()) ++UI; +if (N->isNodeCompletelyFolded()) ++F; +++T; + } + void print(const char* name) const { +std::cerr << name << ", U: " << U << "\n"; +std::cerr << name << ", I: " << I << "\n"; +std::cerr << name << ", UI: " << UI << "\n"; +std::cerr << name << ", F: " << F << "\n"; +std::cerr << name << ", T: " << T << "\n"; + } + void clear() { +U = I = UI = F = T = 0; + } + void addNorm(struct dsstat& o) { +if (o.U) ++U; +if (o.I) ++I; +if (o.UI) ++UI; +if (o.F) ++F; +if (o.T) ++T; + } +}; + +namespace { + class LDSTCount : public FunctionPass, public InstVisitor { +TDDataStructures* T; +DSGraph* G; + +struct dsstat LD; +struct dsstat ST; +struct dsstat GEP; +struct dsstat GEPA; +struct dsstat ALL; +struct dsstat LD_F; +struct dsstat ST_F; +struct dsstat GEP_F; +struct dsstat GEPA_F; +struct dsstat ALL_F; +struct dsstat LD_T; +struct dsstat ST_T; +struct dsstat GEP_T; +struct dsstat GEPA_T; +struct dsstat ALL_T; + + + public: +void getAnalysisUsage(AnalysisUsage &AU) const { + AU.setPreservesAll(); + AU.addRequired(); +} + +bool doInitialization(Module &M) { + LD.clear(); + ST.clear(); + GEP.clear(); + GEPA.clear(); + ALL.clear(); + LD_F.clear(); + ST_F.clear(); + GEP_F.clear(); + GEPA_F.clear(); + ALL_F.clear(); + LD_T.clear(); + ST_T.clear(); + GEP_T.clear(); + GEPA_T.clear(); + ALL_T.clear(); + return false; +} + +bool doFinalization (Module &M) { + LD.print("Loads"); + ST.print("Stores"); + GEP.print("GEPs"); + GEPA.print("Array GEPs"); + ALL.print("All"); + LD_F.print("Loads, Fn"); + ST_F.print("Stores, Fn"); + GEP_F.print("GEPs, Fn"); + GEPA_F.print("GEPs, Fn"); + ALL_F.print("All, Fn"); + return false; +} + +bool runOnFunction(Function& F) { + T = &getAnalysis(); + G = &T->getDSGraph(F); + visit(F); + LD_F.addNorm(LD_T); + ST_F.addNorm(ST_T); + GEP_F.addNorm(GEP_T); + GEPA_F.addNorm(GEPA_T); + ALL_F.addNorm(ALL_T); + LD_T.clear(); + ST_T.clear(); + GEP_T.clear(); + GEPA_T.clear(); + ALL_T.clear(); + return false; +} + +bool hasAllConstantIndices(GetElementPtrInst* G) const { + for (unsigned i = 1, e = G->getNumOperands(); i != e; ++i) { +if (!isa(G->getOperand(i))) + return false; + } + return true; +} + +void visitGetElementPtrInst(User& VGEP) { + DSNode* N = G->getNodeForValue(VGEP.getOperand(0)).getNode(); + if (hasAllConstantIndices(cast(&VGEP))) { +GEP.add(N); +GEP_T.add(N); + } else { +GEPA.a
[llvm-commits] [llvm] r40792 - in /llvm/trunk/lib/Target: Alpha/AlphaTargetMachine.cpp IA64/IA64TargetMachine.cpp PowerPC/PPCSubtarget.h Sparc/SparcTargetMachine.cpp TargetData.cpp X86/X86TargetMachin
Author: johannes Date: Fri Aug 3 15:20:50 2007 New Revision: 40792 URL: http://llvm.org/viewvc/llvm-project?rev=40792&view=rev Log: long double patch 2 of N. Handle it in TargetData. (I've tried to get the info right for all targets, but I'm not expert on all of them - check yours.) Modified: llvm/trunk/lib/Target/Alpha/AlphaTargetMachine.cpp llvm/trunk/lib/Target/IA64/IA64TargetMachine.cpp llvm/trunk/lib/Target/PowerPC/PPCSubtarget.h llvm/trunk/lib/Target/Sparc/SparcTargetMachine.cpp llvm/trunk/lib/Target/TargetData.cpp llvm/trunk/lib/Target/X86/X86TargetMachine.cpp Modified: llvm/trunk/lib/Target/Alpha/AlphaTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Alpha/AlphaTargetMachine.cpp?rev=40792&r1=40791&r2=40792&view=diff == --- llvm/trunk/lib/Target/Alpha/AlphaTargetMachine.cpp (original) +++ llvm/trunk/lib/Target/Alpha/AlphaTargetMachine.cpp Fri Aug 3 15:20:50 2007 @@ -57,7 +57,7 @@ } AlphaTargetMachine::AlphaTargetMachine(const Module &M, const std::string &FS) - : DataLayout("e"), + : DataLayout("e-f128:128:128"), FrameInfo(TargetFrameInfo::StackGrowsDown, 16, 0), JITInfo(*this), Subtarget(M, FS), Modified: llvm/trunk/lib/Target/IA64/IA64TargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/IA64/IA64TargetMachine.cpp?rev=40792&r1=40791&r2=40792&view=diff == --- llvm/trunk/lib/Target/IA64/IA64TargetMachine.cpp (original) +++ llvm/trunk/lib/Target/IA64/IA64TargetMachine.cpp Fri Aug 3 15:20:50 2007 @@ -63,7 +63,7 @@ /// IA64TargetMachine ctor - Create an LP64 architecture model /// IA64TargetMachine::IA64TargetMachine(const Module &M, const std::string &FS) - : DataLayout("e"), + : DataLayout("e-f80:128:128"), FrameInfo(TargetFrameInfo::StackGrowsDown, 16, 0), TLInfo(*this) { // FIXME? check this stuff } Modified: llvm/trunk/lib/Target/PowerPC/PPCSubtarget.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCSubtarget.h?rev=40792&r1=40791&r2=40792&view=diff == --- llvm/trunk/lib/Target/PowerPC/PPCSubtarget.h (original) +++ llvm/trunk/lib/Target/PowerPC/PPCSubtarget.h Fri Aug 3 15:20:50 2007 @@ -104,8 +104,8 @@ /// getTargetDataString - Return the pointer size and type alignment /// properties of this subtarget. const char *getTargetDataString() const { -return isPPC64() ? "E-p:64:64-f64:32:64-i64:32:64" - : "E-p:32:32-f64:32:64-i64:32:64"; +return isPPC64() ? "E-p:64:64-f64:32:64-i64:32:64-f128:64:128" + : "E-p:32:32-f64:32:64-i64:32:64-f128:64:128"; } /// 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=40792&r1=40791&r2=40792&view=diff == --- llvm/trunk/lib/Target/Sparc/SparcTargetMachine.cpp (original) +++ llvm/trunk/lib/Target/Sparc/SparcTargetMachine.cpp Fri Aug 3 15:20:50 2007 @@ -30,7 +30,7 @@ /// SparcTargetMachine ctor - Create an ILP32 architecture model /// SparcTargetMachine::SparcTargetMachine(const Module &M, const std::string &FS) - : DataLayout("E-p:32:32"), + : DataLayout("E-p:32:32-f128:128:128"), Subtarget(M, FS), InstrInfo(Subtarget), FrameInfo(TargetFrameInfo::StackGrowsDown, 8, 0) { } Modified: llvm/trunk/lib/Target/TargetData.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetData.cpp?rev=40792&r1=40791&r2=40792&view=diff == --- llvm/trunk/lib/Target/TargetData.cpp (original) +++ llvm/trunk/lib/Target/TargetData.cpp Fri Aug 3 15:20:50 2007 @@ -436,6 +436,13 @@ return 4; case Type::DoubleTyID: return 8; + case Type::PPC_FP128TyID: + case Type::FP128TyID: +return 16; + // In memory objects this is always aligned to a higher boundary, but + // only 10 bytes contain information. + case Type::X86_FP80TyID: +return 10; case Type::VectorTyID: { const VectorType *PTy = cast(Ty); return PTy->getBitWidth() / 8; @@ -493,6 +500,11 @@ break; case Type::FloatTyID: case Type::DoubleTyID: + // PPC_FP128TyID and FP128TyID have different data contents, but the + // same size and alignment, so they look the same here. + case Type::PPC_FP128TyID: + case Type::FP128TyID: + case Type::X86_FP80TyID: AlignType = FLOAT_ALIGN; break; case Type::VectorTyID: { Modified: llvm/trunk/lib/Target/X86/X86TargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetMachine.cpp?rev=40792&r1=40791&r2=4
[llvm-commits] [llvm] r40791 - /llvm/trunk/lib/Transforms/Scalar/GVN.cpp
Author: resistor Date: Fri Aug 3 14:59:35 2007 New Revision: 40791 URL: http://llvm.org/viewvc/llvm-project?rev=40791&view=rev Log: Fix a subtle miscompilation. This allows 197.parser to be compiled correctly. Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=40791&r1=40790&r2=40791&view=diff == --- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Fri Aug 3 14:59:35 2007 @@ -726,21 +726,23 @@ bool top_level) { // If we have already computed this value, return the previously computed val. - Value *V = Phis[BB]; - if (V && ! top_level) return V; + DenseMap::iterator V = Phis.find(BB); + if (V != Phis.end() && !top_level) return V->second; BasicBlock* singlePred = BB->getSinglePredecessor(); if (singlePred) { -V = GetValueForBlock(singlePred, orig, Phis); -Phis[BB] = V; -return V; +Value *ret = GetValueForBlock(singlePred, orig, Phis); +Phis[BB] = ret; +return ret; } // Otherwise, the idom is the loop, so we need to insert a PHI node. Do so // now, then get values to fill in the incoming values for the PHI. PHINode *PN = new PHINode(orig->getType(), orig->getName()+".rle", BB->begin()); PN->reserveOperandSpace(std::distance(pred_begin(BB), pred_end(BB))); - Phis[BB] = PN; + + if (Phis.count(BB) == 0) +Phis.insert(std::make_pair(BB, PN)); bool all_same = true; Value* first = 0; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r40793 - in /llvm/trunk: include/llvm/CodeGen/ValueTypes.h include/llvm/CodeGen/ValueTypes.td lib/VMCore/ValueTypes.cpp
Author: johannes Date: Fri Aug 3 15:51:37 2007 New Revision: 40793 URL: http://llvm.org/viewvc/llvm-project?rev=40793&view=rev Log: long double patch 3 of N. Add to MVT. Modified: llvm/trunk/include/llvm/CodeGen/ValueTypes.h llvm/trunk/include/llvm/CodeGen/ValueTypes.td llvm/trunk/lib/VMCore/ValueTypes.cpp Modified: llvm/trunk/include/llvm/CodeGen/ValueTypes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/ValueTypes.h?rev=40793&r1=40792&r2=40793&view=diff == --- llvm/trunk/include/llvm/CodeGen/ValueTypes.h (original) +++ llvm/trunk/include/llvm/CodeGen/ValueTypes.h Fri Aug 3 15:51:37 2007 @@ -42,29 +42,30 @@ f64= 8, // This is a 64 bit floating point value f80= 9, // This is a 80 bit floating point value f128 = 10, // This is a 128 bit floating point value -Flag = 11, // This is a condition code or machine flag. +ppcf128= 11, // This is a PPC 128-bit floating point value +Flag = 12, // This is a condition code or machine flag. -isVoid = 12, // This has no value +isVoid = 13, // This has no value -v8i8 = 13, // 8 x i8 -v4i16 = 14, // 4 x i16 -v2i32 = 15, // 2 x i32 -v1i64 = 16, // 1 x i64 -v16i8 = 17, // 16 x i8 -v8i16 = 18, // 8 x i16 -v3i32 = 19, // 3 x i32 -v4i32 = 20, // 4 x i32 -v2i64 = 21, // 2 x i64 - -v2f32 = 22, // 2 x f32 -v3f32 = 23, // 3 x f32 -v4f32 = 24, // 4 x f32 -v2f64 = 25, // 2 x f64 +v8i8 = 14, // 8 x i8 +v4i16 = 15, // 4 x i16 +v2i32 = 16, // 2 x i32 +v1i64 = 17, // 1 x i64 +v16i8 = 18, // 16 x i8 +v8i16 = 19, // 8 x i16 +v3i32 = 20, // 3 x i32 +v4i32 = 21, // 4 x i32 +v2i64 = 22, // 2 x i64 + +v2f32 = 23, // 2 x f32 +v3f32 = 24, // 3 x f32 +v4f32 = 25, // 4 x f32 +v2f64 = 26, // 2 x f64 FIRST_VECTOR_VALUETYPE = v8i8, LAST_VECTOR_VALUETYPE = v2f64, -LAST_VALUETYPE = 26, // This always remains at the end of the list. +LAST_VALUETYPE = 27, // This always remains at the end of the list. // iAny - An integer value of any bit width. This is used for intrinsics // that have overloadings based on integer bit widths. This is only for @@ -114,7 +115,7 @@ /// MVT::isFloatingPoint - Return true if this is an FP, or a vector FP type. static inline bool isFloatingPoint(ValueType VT) { ValueType SVT = VT & SimpleTypeMask; -return (SVT >= f32 && SVT <= f128) || (SVT >= v2f32 && SVT <= v2f64); +return (SVT >= f32 && SVT <= ppcf128) || (SVT >= v2f32 && SVT <= v2f64); } /// MVT::isVector - Return true if this is a vector value type. @@ -197,6 +198,7 @@ case MVT::v3i32: case MVT::v3f32: return 96; case MVT::f128: +case MVT::ppcf128: case MVT::i128: case MVT::v16i8: case MVT::v8i16: Modified: llvm/trunk/include/llvm/CodeGen/ValueTypes.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/ValueTypes.td?rev=40793&r1=40792&r2=40793&view=diff == --- llvm/trunk/include/llvm/CodeGen/ValueTypes.td (original) +++ llvm/trunk/include/llvm/CodeGen/ValueTypes.td Fri Aug 3 15:51:37 2007 @@ -30,23 +30,24 @@ def f64: ValueType<64 , 8>; // 64-bit floating point value def f80: ValueType<80 , 9>; // 80-bit floating point value def f128 : ValueType<128, 10>; // 128-bit floating point value -def FlagVT : ValueType<0 , 11>; // Condition code or machine flag -def isVoid : ValueType<0 , 12>; // Produces no value -def v8i8 : ValueType<64 , 13>; // 8 x i8 vector value -def v4i16 : ValueType<64 , 14>; // 4 x i16 vector value -def v2i32 : ValueType<64 , 15>; // 2 x i32 vector value -def v1i64 : ValueType<64 , 16>; // 1 x i64 vector value +def ppcf128: ValueType<128, 11>; // PPC 128-bit floating point value +def FlagVT : ValueType<0 , 12>; // Condition code or machine flag +def isVoid : ValueType<0 , 13>; // Produces no value +def v8i8 : ValueType<64 , 14>; // 8 x i8 vector value +def v4i16 : ValueType<64 , 15>; // 4 x i16 vector value +def v2i32 : ValueType<64 , 16>; // 2 x i32 vector value +def v1i64 : ValueType<64 , 17>; // 1 x i64 vector value -def v16i8 : ValueType<128, 17>; // 16 x i8 vector value -def v8i16 : ValueType<128, 18>; // 8 x i16 vector value -def v3i32 : ValueType<96 , 19>; // 3 x i32 vector value -def v4i32 : ValueType<128,
Re: [llvm-commits] [PATCH] partial codgen support for ByVal arguments
On Aug 3, 2007, at 9:22 AM, Rafael Espindola wrote: > The attached patch implements code generation of byval arguments on > the callee. For now only the case were the struct is in the stack is > handle correctly. I think this patch is looking very good. As it can only affect things marked 'byval', please feel free to commit what you have. As a next step, it would be good to implement passing of a struct into a call by-val. -Chris > With the patch, the function > --- > %struct.s = type { i64, i64, i64 } > > define i64 @f(%struct.s* byval %a) { > entry: > %tmp2 = getelementptr %struct.s* %a, i32 0, i32 0] > %tmp3 = load i64* %tmp2 > ret i64 %tmp3 > } > > Correctly compiles to > > f: > movq8(%rsp), %rax > ret > > There is still a lot to implement and debug, but I would like to know > any comments one might have. > > Cheers, > -- > Rafael Avila de Espindola > > Google Ireland Ltd. > Gordon House > Barrow Street > Dublin 4 > Ireland > > Registered in Dublin, Ireland > Registration Number: 368047 > > ___ > llvm-commits mailing list > llvm-commits@cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm] r40792 - in /llvm/trunk/lib/Target: Alpha/AlphaTargetMachine.cpp IA64/IA64TargetMachine.cpp PowerPC/PPCSubtarget.h Sparc/SparcTargetMachine.cpp TargetData.cpp X86/X86TargetMa
> --- llvm/trunk/lib/Target/X86/X86TargetMachine.cpp (original) > +++ llvm/trunk/lib/Target/X86/X86TargetMachine.cpp Fri Aug 3 15:20:50 2007 > @@ -115,8 +115,8 @@ > bool is64Bit) >: Subtarget(M, FS, is64Bit), > DataLayout(Subtarget.is64Bit() ? > - std::string("e-p:64:64-f64:32:64-i64:32:64") : > - std::string("e-p:32:32-f64:32:64-i64:32:64")), > + std::string("e-p:64:64-f64:32:64-i64:32:64-f80:128:128") : > + std::string("e-p:32:32-f64:32:64-i64:32:64-f80:128:128")), sizeof(long double) on i686-pc-linux-gnu (32-bit) is 12, and __alignof is 4. > +PPC_FP128TyID, ///< 5: 128 bit floating point type (two 64-bits) Is there a different name for this? PowerPC isn't the only platform that uses (or could use) a double-double approach. Also, what LLVM instruction would be used for conversions between this type and the regular FP128 type? The current fpext/fptrunc instructions don't seem to cover this case. Maybe fptrunc could be generalized to cover all floating-point conversions for which there are values for the operand type which cannot be exactly represented in the result type. Dan -- Dan Gohman, Cray Inc. ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm] r40792 - in /llvm/trunk/lib/Target: Alpha/AlphaTargetMachine.cpp IA64/IA64TargetMachine.cpp PowerPC/PPCSubtarget.h Sparc/SparcTargetMachine.cpp TargetData.cpp X86/X86TargetMa
On Aug 3, 2007, at 2:06 PM, Dan Gohman wrote: >> --- llvm/trunk/lib/Target/X86/X86TargetMachine.cpp (original) >> +++ llvm/trunk/lib/Target/X86/X86TargetMachine.cpp Fri Aug 3 >> 15:20:50 2007 >> @@ -115,8 +115,8 @@ >> bool is64Bit) >>: Subtarget(M, FS, is64Bit), >> DataLayout(Subtarget.is64Bit() ? >> - std::string("e-p:64:64-f64:32:64-i64:32:64") : >> - std::string("e-p:32:32-f64:32:64-i64:32:64")), >> + std::string("e-p:64:64-f64:32:64-i64:32:64- >> f80:128:128") : >> + std::string("e-p:32:32-f64:32:64-i64:32:64- >> f80:128:128")), > > sizeof(long double) on i686-pc-linux-gnu (32-bit) is 12, and > __alignof is 4. Thanks, I'll make this OS-dependent as well. >> +PPC_FP128TyID, ///< 5: 128 bit floating point type (two 64- >> bits) > > Is there a different name for this? PowerPC isn't the only platform > that > uses (or could use) a double-double approach. What other target does? I've no objection to renaming if you have a more descriptive suggestion (with a relatively short name - 80 columns you know. Wonder how many LLVM hackers have ever seen a punched card) > Also, what LLVM instruction would be used for conversions between this > type and the regular FP128 type? I don't see a short-term need to support this; they don't exist simultaneously on any target AFAIK. (Having this target dependency in the IR is unfortunate, IMO; if there were a single "long double" type you couldn't even ask that question. But as long as the FEs are responsible for decimal->binary constant conversion we're stuck with it.) ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r40796 - /llvm/trunk/lib/Target/X86/X86TargetMachine.cpp
Author: johannes Date: Fri Aug 3 17:46:15 2007 New Revision: 40796 URL: http://llvm.org/viewvc/llvm-project?rev=40796&view=rev Log: Make x86 long double alignment 32 for everything but Darwin (which makes size within a struct==96) Modified: llvm/trunk/lib/Target/X86/X86TargetMachine.cpp Modified: llvm/trunk/lib/Target/X86/X86TargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetMachine.cpp?rev=40796&r1=40795&r2=40796&view=diff == --- llvm/trunk/lib/Target/X86/X86TargetMachine.cpp (original) +++ llvm/trunk/lib/Target/X86/X86TargetMachine.cpp Fri Aug 3 17:46:15 2007 @@ -116,7 +116,9 @@ : Subtarget(M, FS, is64Bit), DataLayout(Subtarget.is64Bit() ? std::string("e-p:64:64-f64:32:64-i64:32:64-f80:128:128") : - std::string("e-p:32:32-f64:32:64-i64:32:64-f80:128:128")), + Subtarget.isTargetDarwin() ? + std::string("e-p:32:32-f64:32:64-i64:32:64-f80:128:128") : + std::string("e-p:32:32-f64:32:64-i64:32:64-f80:32:32")), FrameInfo(TargetFrameInfo::StackGrowsDown, Subtarget.getStackAlignment(), Subtarget.is64Bit() ? -8 : -4), InstrInfo(*this), JITInfo(*this), TLInfo(*this) { ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [test-suite] r40797 - /test-suite/trunk/Makefile.programs
Author: reid Date: Fri Aug 3 18:49:37 2007 New Revision: 40797 URL: http://llvm.org/viewvc/llvm-project?rev=40797&view=rev Log: For PR1583: Restore some sanity to building test programs. The output of CBE *must* be compiled and linked with gcc not g++, even if the source program contained exception handling. The CBE uses separation of definition and declaration for static variables which is not permitted by C++ but is by C. Additionally, it is very important to get the libstdc++ from llvm-gcc not the one provided by the C compiler. When compiling .cbe.c or even .s, the -L options must be given to GCC such that it links the llvm-gcc version of libstdc++ or else there will be an ABI mismatch. For example, llvm-gg++ 4.0.1 exception handling is not compatible with g++ 4.2.1 exception handling. 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=40797&r1=40796&r2=40797&view=diff == --- test-suite/trunk/Makefile.programs (original) +++ test-suite/trunk/Makefile.programs Fri Aug 3 18:49:37 2007 @@ -102,21 +102,6 @@ endif endif -# LLVMGCCLD - This sets up the command to use for linking test programs -# that were generated with llvm-gcc. Usually $(CC) is sufficient but, -# depending on libstdc++ and libgcc.a usage, it may be necessary to ensure -# that the link is done against llvm-gcc's version of those libraries. If -# the LINK_WITH_LLVMGCC_LIBS variable is set, then the link is done that -# way. Unfortunately, this can't help JIT because it is always linked with -# the libraries of lli. -ifndef LLVMGCCLD -LLVMGCCLD := $(CC) -endif -ifdef LINK_WITH_LLVMGCC_LIBS -#LLVMGCCLD := $(CC) -L$(LLVMGCCDIR)/lib/gcc/$(LLVMGCCARCH) -L$(LLVMGCCDIR)/lib/debug -L$(LLVMGCCDIR)/lib -LLVMGCCLD := $(CC) -L$(LLVMGCCDIR)/lib/gcc/$(LLVMGCCARCH) -L$(LLVMGCCDIR)/lib -endif - ifndef STDIN_FILENAME STDIN_FILENAME := /dev/null endif @@ -272,7 +257,7 @@ $(PROGRAMS_TO_TEST:%=Output/%.llvm.bc): \ Output/%.llvm.bc: Output/%.linked.bc $(LLVM_LDDPROG) - -$(LLVMLD) $(STATS) $< $(EXTRA_LINKTIME_OPT_FLAGS) -lc $(LIBS) -o Output/$*.llvm + -$(LLVMLD) $(STATS) $< $(EXTRA_LINKTIME_OPT_FLAGS) $(LLVMLD_FLAGS) -lc $(LIBS) -o Output/$*.llvm ifneq ($(OPTPASSES),) -$(LOPT) -q $(OPTPASSES) $@ -o [EMAIL PROTECTED] -f $(MV) -f [EMAIL PROTECTED] $@ @@ -280,7 +265,7 @@ $(PROGRAMS_TO_TEST:%=Output/%.llvm): \ Output/%.llvm: Output/%.linked.bc $(LLVMLDPROG) - -$(LLVMLD) $(STATS) $< -lc $(LIBS) -o Output/$*.llvm + -$(LLVMLD) $(STATS) $< $(LLVMLD_FLAGS) -lc $(LIBS) -o Output/$*.llvm ifneq ($(OPTPASSES),) -$(LOPT) -q $(OPTPASSES) $@ -o [EMAIL PROTECTED] -f $(MV) -f [EMAIL PROTECTED] $@ @@ -288,20 +273,20 @@ $(PROGRAMS_TO_TEST:%=Output/%.noopt-llvm.bc): \ Output/%.noopt-llvm.bc: Output/%.linked.rbc $(LLVMLDPROG) - -$(LLVMLD) -disable-opt $(STATS) $< -lc $(LIBS) -o Output/$*.noopt-llvm + -$(LLVMLD) -disable-opt $(STATS) $(LLVMLD_FLAGS) $< -lc $(LIBS) -o Output/$*.noopt-llvm $(PROGRAMS_TO_TEST:%=Output/%.noopt-llvm): \ Output/%.noopt-llvm: Output/%.linked.rbc $(LLVMLDPROG) - -$(LLVMLD) -disable-opt $(STATS) $< -lc $(LIBS) -o Output/$*.noopt-llvm + -$(LLVMLD) -disable-opt $(STATS) $(LLVMLD_FLAGS) $< -lc $(LIBS) -o Output/$*.noopt-llvm $(PROGRAMS_TO_TEST:%=Output/%.nollvm-ldopt-llvm.bc): \ Output/%.nollvm-ldopt-llvm.bc: Output/%.linked.bc $(LLVMLDPROG) - -$(LLVMLD) -disable-opt $(STATS) $< -lc $(LIBS) -o Output/$*.nollvm-ldopt-llvm + -$(LLVMLD) -disable-opt $(STATS) $(LLVMLD_FLAGS) $< -lc $(LIBS) -o Output/$*.nollvm-ldopt-llvm $(PROGRAMS_TO_TEST:%=Output/%.nollvm-ldopt-llvm): \ Output/%.nollvm-ldopt-llvm: Output/%.linked.rbc $(LLVMLDPROG) - -$(LLVMLD) -disable-opt $(STATS) $< -lc $(LIBS) -o Output/$*.nollvm-ldopt-llvm + -$(LLVMLD) -disable-opt $(STATS) $(LLVMLD_FLAGS) $< -lc $(LIBS) -o Output/$*.nollvm-ldopt-llvm endif # ifndef DISABLE_FOR_LLVM_PROGRAMS @@ -319,8 +304,8 @@ # If the program requires exception handling support, enable (potentially # expensive) support for it. ifdef REQUIRES_EH_SUPPORT -LLCFLAGS += -enable-correct-eh-support -LLVMGCCLD := $(CXX) +LLCFLAGS += -enable-eh +LLVMLD_FLAGS += -disable-inlining endif # Pass target specific llc flags @@ -335,9 +320,14 @@ Output/%.cbe.c: Output/%.llvm.bc $(LLC) -$(LLC) $(LLCFLAGS) -march=c $< -o $@ -f +ifdef REQUIRES_EH_SUPPORT +MORE_LDFLAGS=-L$(LLVMGCCDIR)/lib/gcc/$(LLVMGCCARCH) -L$(LLVMGCCDIR)/lib -lstdc++ +endif + $(PROGRAMS_TO_TEST:%=Output/%.cbe): \ Output/%.cbe: Output/%.cbe.c - -$(LLVMGCCLD) $< $(LDFLAGS) $(CFLAGS) -fno-strict-aliasing -O2 -fno-inline $(TARGET_FLAGS) -o $@ + -$(CC) $< -o $@ $(LDFLAGS) $(MORE_LDFLAGS) $(CFLAGS) \ + -fno-strict-aliasing -O2 -fno-inline $(TARGET_FLAGS) # # Compile a linked program
Re: [llvm-commits] [test-suite] r40797 - /test-suite/trunk/Makefile.programs
On Aug 3, 2007, at 4:49 PM, Reid Spencer wrote: > Author: reid > Date: Fri Aug 3 18:49:37 2007 > New Revision: 40797 > > @@ -387,7 +377,7 @@ > # If the program requires exception handling support, enable > (potentially > # expensive) support for it. > ifdef REQUIRES_EH_SUPPORT > -JIT_OPTS += -enable-correct-eh-support > +JIT_OPTS += -enable-eh > endif This seems unrelated and incorrect, -Chris ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm] r40796 - /llvm/trunk/lib/Target/X86/X86TargetMachine.cpp
On Aug 3, 2007, at 3:46 PM, Dale Johannesen wrote: > Author: johannes > Date: Fri Aug 3 17:46:15 2007 > New Revision: 40796 Thanks Dale, > == > > --- llvm/trunk/lib/Target/X86/X86TargetMachine.cpp (original) > +++ llvm/trunk/lib/Target/X86/X86TargetMachine.cpp Fri Aug 3 > 17:46:15 2007 > @@ -116,7 +116,9 @@ >: Subtarget(M, FS, is64Bit), > DataLayout(Subtarget.is64Bit() ? > std::string("e-p:64:64-f64:32:64-i64:32:64- > f80:128:128") : > - std::string("e-p:32:32-f64:32:64-i64:32:64- > f80:128:128")), > + Subtarget.isTargetDarwin() ? > + std::string("e-p:32:32-f64:32:64-i64:32:64- > f80:128:128") : > + std::string("e-p:32:32-f64:32:64-i64:32:64- > f80:32:32")), > FrameInfo(TargetFrameInfo::StackGrowsDown, >Subtarget.getStackAlignment(), Subtarget.is64Bit() ? > -8 : -4), > InstrInfo(*this), JITInfo(*this), TLInfo(*this) { Dale, this is getting complicated :) Can you please add a new X86Subtarget::getDataLayout() method? That would make this just be: DataLayout(Subtarget.getDataLayout()) -Chris ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm] r40792 - in /llvm/trunk/lib/Target: Alpha/AlphaTargetMachine.cpp IA64/IA64TargetMachine.cpp PowerPC/PPCSubtarget.h Sparc/SparcTargetMachine.cpp TargetData.cpp X86/X86TargetMa
>>> +PPC_FP128TyID, ///< 5: 128 bit floating point type (two 64- >>> bits) >> >> Is there a different name for this? PowerPC isn't the only platform >> that >> uses (or could use) a double-double approach. > > What other target does? I've no objection to renaming if you have a > more descriptive suggestion I agree this seems common too, and if we know of a target that has it, we can pick a name. However, I also think it is reasonable to just start out with this name and rename/generalize it down the road if we find a need for it. > (with a relatively short name - 80 > columns you know. Wonder how many LLVM hackers have ever seen a > punched card) Poor Dale :) >> Also, what LLVM instruction would be used for conversions between >> this >> type and the regular FP128 type? > > I don't see a short-term need to support this; they don't exist > simultaneously on any target AFAIK. Right, I think we can just define some convention and stick to it. I don't expect to see code that does this in practice. We could just define "ppc" 128-bit as smaller than IEEE 128-bit, since it is less general, for example. > (Having this target dependency > in the IR is unfortunate, IMO; if there were a single "long double" > type you couldn't even ask that question. But as long as the FEs are > responsible for decimal->binary constant conversion we're stuck with > it.) Yep, not only that, but the middle-end needs to know how to constant fold correctly etc. -Chris ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [test-suite] r40797 - /test-suite/trunk/Makefile.programs
On Fri, 2007-08-03 at 16:58 -0700, Chris Lattner wrote: > On Aug 3, 2007, at 4:49 PM, Reid Spencer wrote: > > > Author: reid > > Date: Fri Aug 3 18:49:37 2007 > > New Revision: 40797 > > > > @@ -387,7 +377,7 @@ > > # If the program requires exception handling support, enable > > (potentially > > # expensive) support for it. > > ifdef REQUIRES_EH_SUPPORT > > -JIT_OPTS += -enable-correct-eh-support > > +JIT_OPTS += -enable-eh > > endif > > This seems unrelated and incorrect, Its related in the sense of getting the number of false negatives reduced in test-suite. The change was recommended by Anton. If its incorrect, please take it up with him. It does, however, reduce exception related errors. > > -Chris > ___ > llvm-commits mailing list > llvm-commits@cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r40802 - /llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
Author: lattner Date: Fri Aug 3 20:04:40 2007 New Revision: 40802 URL: http://llvm.org/viewvc/llvm-project?rev=40802&view=rev Log: make RenamePassWorkList a local var instead of an ivar. Modified: llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp Modified: llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp?rev=40802&r1=40801&r2=40802&view=diff == --- llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp Fri Aug 3 20:04:40 2007 @@ -121,9 +121,6 @@ /// non-determinstic behavior. DenseMap BBNumbers; -/// RenamePassWorkList - Worklist used by RenamePass() -std::vector RenamePassWorkList; - public: PromoteMem2Reg(const std::vector &A, SmallVector &Retry, DominatorTree &dt, @@ -154,7 +151,8 @@ const std::vector &AIs); void RenamePass(BasicBlock *BB, BasicBlock *Pred, -std::vector &IncVals); +std::vector &IncVals, +std::vector &Worklist); bool QueuePhiNode(BasicBlock *BB, unsigned AllocaIdx, unsigned &Version, SmallPtrSet &InsertedPHINodes); }; @@ -404,13 +402,14 @@ // Walks all basic blocks in the function performing the SSA rename algorithm // and inserting the phi nodes we marked as necessary // - RenamePassWorkList.clear(); + + std::vector RenamePassWorkList; RenamePassWorkList.push_back(RenamePassData(F.begin(), 0, Values)); while(!RenamePassWorkList.empty()) { RenamePassData RPD = RenamePassWorkList.back(); RenamePassWorkList.pop_back(); // RenamePass may add new worklist entries. -RenamePass(RPD.BB, RPD.Pred, RPD.Values); +RenamePass(RPD.BB, RPD.Pred, RPD.Values, RenamePassWorkList); } // The renamer uses the Visited set to avoid infinite loops. Clear it now. @@ -699,7 +698,8 @@ // value each Alloca contains on exit from the predecessor block Pred. // void PromoteMem2Reg::RenamePass(BasicBlock *BB, BasicBlock *Pred, -std::vector &IncomingVals) { +std::vector &IncomingVals, +std::vector &Worklist) { // If we are inserting any phi nodes into this BB, they will already be in the // block. if (PHINode *APN = dyn_cast(BB->begin())) { @@ -793,7 +793,7 @@ // Recurse to our successors. TerminatorInst *TI = BB->getTerminator(); for (unsigned i = 0; i != TI->getNumSuccessors(); i++) -RenamePassWorkList.push_back(RenamePassData(TI->getSuccessor(i), BB, IncomingVals)); +Worklist.push_back(RenamePassData(TI->getSuccessor(i), BB, IncomingVals)); } /// PromoteMemToReg - Promote the specified list of alloca instructions into ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r40803 - /llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
Author: lattner Date: Fri Aug 3 20:07:49 2007 New Revision: 40803 URL: http://llvm.org/viewvc/llvm-project?rev=40803&view=rev Log: avoid an unneeded vector copy. This speeds up mem2reg on the testcase in PR1432 by 6% Modified: llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp Modified: llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp?rev=40803&r1=40802&r2=40803&view=diff == --- llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp Fri Aug 3 20:07:49 2007 @@ -76,11 +76,18 @@ // Data package used by RenamePass() class VISIBILITY_HIDDEN RenamePassData { public: +RenamePassData() {} RenamePassData(BasicBlock *B, BasicBlock *P, const std::vector &V) : BB(B), Pred(P), Values(V) {} BasicBlock *BB; BasicBlock *Pred; std::vector Values; + +void swap(RenamePassData &RHS) { + std::swap(BB, RHS.BB); + std::swap(Pred, RHS.Pred); + Values.swap(RHS.Values); +} }; struct VISIBILITY_HIDDEN PromoteMem2Reg { @@ -406,7 +413,8 @@ std::vector RenamePassWorkList; RenamePassWorkList.push_back(RenamePassData(F.begin(), 0, Values)); while(!RenamePassWorkList.empty()) { -RenamePassData RPD = RenamePassWorkList.back(); +RenamePassData RPD; +RPD.swap(RenamePassWorkList.back()); RenamePassWorkList.pop_back(); // RenamePass may add new worklist entries. RenamePass(RPD.BB, RPD.Pred, RPD.Values, RenamePassWorkList); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r40804 - /llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
Author: lattner Date: Fri Aug 3 20:19:38 2007 New Revision: 40804 URL: http://llvm.org/viewvc/llvm-project?rev=40804&view=rev Log: add a typedef, no other change. Modified: llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp Modified: llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp?rev=40804&r1=40803&r2=40804&view=diff == --- llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp Fri Aug 3 20:19:38 2007 @@ -76,12 +76,14 @@ // Data package used by RenamePass() class VISIBILITY_HIDDEN RenamePassData { public: +typedef std::vector ValVector; + RenamePassData() {} RenamePassData(BasicBlock *B, BasicBlock *P, - const std::vector &V) : BB(B), Pred(P), Values(V) {} + const ValVector &V) : BB(B), Pred(P), Values(V) {} BasicBlock *BB; BasicBlock *Pred; -std::vector Values; +ValVector Values; void swap(RenamePassData &RHS) { std::swap(BB, RHS.BB); @@ -158,7 +160,7 @@ const std::vector &AIs); void RenamePass(BasicBlock *BB, BasicBlock *Pred, -std::vector &IncVals, +RenamePassData::ValVector &IncVals, std::vector &Worklist); bool QueuePhiNode(BasicBlock *BB, unsigned AllocaIdx, unsigned &Version, SmallPtrSet &InsertedPHINodes); @@ -402,17 +404,16 @@ // the alloca's. We do this in case there is a load of a value that has not // been stored yet. In this case, it will get this null value. // - std::vector Values(Allocas.size()); + RenamePassData::ValVector Values(Allocas.size()); for (unsigned i = 0, e = Allocas.size(); i != e; ++i) Values[i] = UndefValue::get(Allocas[i]->getAllocatedType()); // Walks all basic blocks in the function performing the SSA rename algorithm // and inserting the phi nodes we marked as necessary // - std::vector RenamePassWorkList; RenamePassWorkList.push_back(RenamePassData(F.begin(), 0, Values)); - while(!RenamePassWorkList.empty()) { + while (!RenamePassWorkList.empty()) { RenamePassData RPD; RPD.swap(RenamePassWorkList.back()); RenamePassWorkList.pop_back(); @@ -706,7 +707,7 @@ // value each Alloca contains on exit from the predecessor block Pred. // void PromoteMem2Reg::RenamePass(BasicBlock *BB, BasicBlock *Pred, -std::vector &IncomingVals, +RenamePassData::ValVector &IncomingVals, std::vector &Worklist) { // If we are inserting any phi nodes into this BB, they will already be in the // block. ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r40805 - /llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
Author: lattner Date: Fri Aug 3 20:41:18 2007 New Revision: 40805 URL: http://llvm.org/viewvc/llvm-project?rev=40805&view=rev Log: refactor some code to shrink PromoteMem2Reg::run a bit Modified: llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp Modified: llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp?rev=40805&r1=40804&r2=40805&view=diff == --- llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp Fri Aug 3 20:41:18 2007 @@ -16,6 +16,7 @@ // //===--===// +#define DEBUG_TYPE "mem2reg" #include "llvm/Transforms/Utils/PromoteMemToReg.h" #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" @@ -26,12 +27,17 @@ #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/Statistic.h" #include "llvm/ADT/StringExtras.h" #include "llvm/Support/CFG.h" #include "llvm/Support/Compiler.h" #include using namespace llvm; +STATISTIC(NumLocalPromoted, "Number of alloca's promoted within one block"); +STATISTIC(NumSingleStore, "Number of alloca's promoted with a single store"); +STATISTIC(NumDeadAlloca,"Number of dead alloca's removed"); + // Provide DenseMapKeyInfo for all pointers. namespace llvm { template<> @@ -153,6 +159,12 @@ } private: +void RemoveFromAllocasList(unsigned &AllocaIdx) { + Allocas[AllocaIdx] = Allocas.back(); + Allocas.pop_back(); + --AllocaIdx; +} + void MarkDominatingPHILive(BasicBlock *BB, unsigned AllocaNum, SmallPtrSet &DeadPHINodes); bool PromoteLocallyUsedAlloca(BasicBlock *BB, AllocaInst *AI); @@ -165,6 +177,58 @@ bool QueuePhiNode(BasicBlock *BB, unsigned AllocaIdx, unsigned &Version, SmallPtrSet &InsertedPHINodes); }; + + struct AllocaInfo { +std::vector DefiningBlocks; +std::vector UsingBlocks; + +StoreInst *OnlyStore; +BasicBlock *OnlyBlock; +bool OnlyUsedInOneBlock; + +Value *AllocaPointerVal; + +void clear() { + DefiningBlocks.clear(); + UsingBlocks.clear(); + OnlyStore = 0; + OnlyBlock = 0; + OnlyUsedInOneBlock = true; + AllocaPointerVal = 0; +} + +/// AnalyzeAlloca - Scan the uses of the specified alloca, filling in our +/// ivars. +void AnalyzeAlloca(AllocaInst *AI) { + clear(); + + // As we scan the uses of the alloca instruction, keep track of stores, + // and decide whether all of the loads and stores to the alloca are within + // the same basic block. + for (Value::use_iterator U = AI->use_begin(), E = AI->use_end(); + U != E; ++U){ +Instruction *User = cast(*U); +if (StoreInst *SI = dyn_cast(User)) { + // Remember the basic blocks which define new values for the alloca + DefiningBlocks.push_back(SI->getParent()); + AllocaPointerVal = SI->getOperand(0); + OnlyStore = SI; +} else { + LoadInst *LI = cast(User); + // Otherwise it must be a load instruction, keep track of variable reads + UsingBlocks.push_back(LI->getParent()); + AllocaPointerVal = LI; +} + +if (OnlyUsedInOneBlock) { + if (OnlyBlock == 0) +OnlyBlock = User->getParent(); + else if (OnlyBlock != User->getParent()) +OnlyUsedInOneBlock = false; +} + } +} + }; } // end of anonymous namespace @@ -180,6 +244,8 @@ if (AST) PointerAllocaValues.resize(Allocas.size()); + AllocaInfo Info; + for (unsigned AllocaNum = 0; AllocaNum != Allocas.size(); ++AllocaNum) { AllocaInst *AI = Allocas[AllocaNum]; @@ -194,80 +260,46 @@ AI->eraseFromParent(); // Remove the alloca from the Allocas list, since it has been processed - Allocas[AllocaNum] = Allocas.back(); - Allocas.pop_back(); - --AllocaNum; + RemoveFromAllocasList(AllocaNum); + ++NumDeadAlloca; continue; } - + // Calculate the set of read and write-locations for each alloca. This is // analogous to finding the 'uses' and 'definitions' of each variable. -std::vector DefiningBlocks; -std::vector UsingBlocks; - -StoreInst *OnlyStore = 0; -BasicBlock *OnlyBlock = 0; -bool OnlyUsedInOneBlock = true; - -// As we scan the uses of the alloca instruction, keep track of stores, and -// decide whether all of the loads and stores to the alloca are within the -// same basic block. -Value *AllocaPointerVal = 0; -for (Value::use_iterator U =AI->use_begin(), E = AI->use_end(); U != E;++U){ - Instruc
[llvm-commits] [llvm] r40806 - /llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
Author: lattner Date: Fri Aug 3 20:47:41 2007 New Revision: 40806 URL: http://llvm.org/viewvc/llvm-project?rev=40806&view=rev Log: split rewriting of single-store allocas into its own method. Modified: llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp Modified: llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp?rev=40806&r1=40805&r2=40806&view=diff == --- llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp Fri Aug 3 20:47:41 2007 @@ -78,6 +78,7 @@ } namespace { + struct AllocaInfo; // Data package used by RenamePass() class VISIBILITY_HIDDEN RenamePassData { @@ -165,6 +166,8 @@ --AllocaIdx; } +void RewriteSingleStoreAlloca(AllocaInst *AI, AllocaInfo &Info); + void MarkDominatingPHILive(BasicBlock *BB, unsigned AllocaNum, SmallPtrSet &DeadPHINodes); bool PromoteLocallyUsedAlloca(BasicBlock *BB, AllocaInst *AI); @@ -232,6 +235,7 @@ } // end of anonymous namespace + void PromoteMem2Reg::run() { Function &F = *DF.getRoot()->getParent(); @@ -282,45 +286,7 @@ // If there is only a single store to this value, replace any loads of // it that are directly dominated by the definition with the value stored. if (Info.DefiningBlocks.size() == 1) { - // Be aware of loads before the store. - std::set ProcessedBlocks; - for (unsigned i = 0, e = Info.UsingBlocks.size(); i != e; ++i) -// If the store dominates the block and if we haven't processed it yet, -// do so now. -if (dominates(Info.OnlyStore->getParent(), Info.UsingBlocks[i])) - if (ProcessedBlocks.insert(Info.UsingBlocks[i]).second) { -BasicBlock *UseBlock = Info.UsingBlocks[i]; - -// If the use and store are in the same block, do a quick scan to -// verify that there are no uses before the store. -if (UseBlock == Info.OnlyStore->getParent()) { - BasicBlock::iterator I = UseBlock->begin(); - for (; &*I != Info.OnlyStore; ++I) { // scan block for store. -if (isa(I) && I->getOperand(0) == AI) - break; - } - if (&*I != Info.OnlyStore) break; // Do not handle this case. -} - -// Otherwise, if this is a different block or if all uses happen -// after the store, do a simple linear scan to replace loads with -// the stored value. -for (BasicBlock::iterator I = UseBlock->begin(),E = UseBlock->end(); - I != E; ) { - if (LoadInst *LI = dyn_cast(I++)) { -if (LI->getOperand(0) == AI) { - LI->replaceAllUsesWith(Info.OnlyStore->getOperand(0)); - if (AST && isa(LI->getType())) -AST->deleteValue(LI); - LI->eraseFromParent(); -} - } -} - -// Finally, remove this block from the UsingBlock set. -Info.UsingBlocks[i] = Info.UsingBlocks.back(); ---i; --e; - } + RewriteSingleStoreAlloca(AI, Info); // Finally, after the scan, check to see if the store is all that is left. if (Info.UsingBlocks.empty()) { @@ -559,6 +525,58 @@ NewPhiNodes.clear(); } + +/// RewriteSingleStoreAlloca - If there is only a single store to this value, +/// replace any loads of it that are directly dominated by the definition with +/// the value stored. +void PromoteMem2Reg::RewriteSingleStoreAlloca(AllocaInst *AI, + AllocaInfo &Info) { + // Be aware of loads before the store. + std::set ProcessedBlocks; + for (unsigned i = 0, e = Info.UsingBlocks.size(); i != e; ++i) { +// If the store dominates the block and if we haven't processed it yet, +// do so now. +if (!dominates(Info.OnlyStore->getParent(), Info.UsingBlocks[i])) + continue; + +if (!ProcessedBlocks.insert(Info.UsingBlocks[i]).second) + continue; + +BasicBlock *UseBlock = Info.UsingBlocks[i]; + +// If the use and store are in the same block, do a quick scan to +// verify that there are no uses before the store. +if (UseBlock == Info.OnlyStore->getParent()) { + BasicBlock::iterator I = UseBlock->begin(); + for (; &*I != Info.OnlyStore; ++I) { // scan block for store. +if (isa(I) && I->getOperand(0) == AI) + break; + } + if (&*I != Info.OnlyStore) break; // Do not handle this case. +} + +// Otherwise, if this is a different block or if all uses happen +// after the store, do a simple linear scan to replace loads with +/
[llvm-commits] [llvm] r40809 - /llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
Author: lattner Date: Fri Aug 3 21:15:24 2007 New Revision: 40809 URL: http://llvm.org/viewvc/llvm-project?rev=40809&view=rev Log: In mem2reg, when handling the single-store case, make sure to remove a using block from the list if we handle it. Not doing this caused us to not be able to promote (with the fast path) allocas which have uses (whoops). This increases the # allocas hitting this fastpath from 4042 to 8935 on the testcase in PR1432, speeding up mem2reg by 2.6x Modified: llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp Modified: llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp?rev=40809&r1=40808&r2=40809&view=diff == --- llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp Fri Aug 3 21:15:24 2007 @@ -531,28 +531,29 @@ /// the value stored. void PromoteMem2Reg::RewriteSingleStoreAlloca(AllocaInst *AI, AllocaInfo &Info) { + StoreInst *OnlyStore = Info.OnlyStore; + // Be aware of loads before the store. std::set ProcessedBlocks; for (unsigned i = 0, e = Info.UsingBlocks.size(); i != e; ++i) { // If the store dominates the block and if we haven't processed it yet, // do so now. -if (!dominates(Info.OnlyStore->getParent(), Info.UsingBlocks[i])) - continue; - -if (!ProcessedBlocks.insert(Info.UsingBlocks[i]).second) +if (!dominates(OnlyStore->getParent(), Info.UsingBlocks[i])) continue; BasicBlock *UseBlock = Info.UsingBlocks[i]; +if (!ProcessedBlocks.insert(UseBlock).second) + continue; // If the use and store are in the same block, do a quick scan to // verify that there are no uses before the store. -if (UseBlock == Info.OnlyStore->getParent()) { +if (UseBlock == OnlyStore->getParent()) { BasicBlock::iterator I = UseBlock->begin(); - for (; &*I != Info.OnlyStore; ++I) { // scan block for store. + for (; &*I != OnlyStore; ++I) { // scan block for store. if (isa(I) && I->getOperand(0) == AI) break; } - if (&*I != Info.OnlyStore) break; // Do not handle this case. + if (&*I != OnlyStore) break; // Do not handle this case. } // Otherwise, if this is a different block or if all uses happen @@ -562,7 +563,7 @@ I != E; ) { if (LoadInst *LI = dyn_cast(I++)) { if (LI->getOperand(0) == AI) { - LI->replaceAllUsesWith(Info.OnlyStore->getOperand(0)); + LI->replaceAllUsesWith(OnlyStore->getOperand(0)); if (AST && isa(LI->getType())) AST->deleteValue(LI); LI->eraseFromParent(); @@ -572,6 +573,7 @@ // Finally, remove this block from the UsingBlock set. Info.UsingBlocks[i] = Info.UsingBlocks.back(); +Info.UsingBlocks.pop_back(); --i; --e; } } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r40810 - /llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
Author: lattner Date: Fri Aug 3 21:21:22 2007 New Revision: 40810 URL: http://llvm.org/viewvc/llvm-project?rev=40810&view=rev Log: switch from using a std::set to using a SmallPtrSet. This speeds up the testcase in PR1432 from 6.33s to 2.90s (2.22x) Modified: llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp Modified: llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp?rev=40810&r1=40809&r2=40810&view=diff == --- llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp Fri Aug 3 21:21:22 2007 @@ -534,7 +534,7 @@ StoreInst *OnlyStore = Info.OnlyStore; // Be aware of loads before the store. - std::set ProcessedBlocks; + SmallPtrSet ProcessedBlocks; for (unsigned i = 0, e = Info.UsingBlocks.size(); i != e; ++i) { // If the store dominates the block and if we haven't processed it yet, // do so now. @@ -542,7 +542,7 @@ continue; BasicBlock *UseBlock = Info.UsingBlocks[i]; -if (!ProcessedBlocks.insert(UseBlock).second) +if (!ProcessedBlocks.insert(UseBlock)) continue; // If the use and store are in the same block, do a quick scan to @@ -559,7 +559,7 @@ // Otherwise, if this is a different block or if all uses happen // after the store, do a simple linear scan to replace loads with // the stored value. -for (BasicBlock::iterator I = UseBlock->begin(),E = UseBlock->end(); +for (BasicBlock::iterator I = UseBlock->begin(), E = UseBlock->end(); I != E; ) { if (LoadInst *LI = dyn_cast(I++)) { if (LI->getOperand(0) == AI) { ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r40811 - /llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
Author: lattner Date: Fri Aug 3 21:32:22 2007 New Revision: 40811 URL: http://llvm.org/viewvc/llvm-project?rev=40811&view=rev Log: Three improvements: 1. Check for revisiting a block before checking domination, which is faster. 2. If the stored value isn't an instruction, we don't have to check for domination. 3. If we have a value used in the same block more than once, make sure to remove the block from the UsingBlocks vector. Not doing so forces us to go through the slow path for the alloca. The combination of these improvements increases the number of allocas on the fastpath from 8935 to 8982 on PR1432. This speeds it up from 2.90s to 2.20s (31%) Modified: llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp Modified: llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp?rev=40811&r1=40810&r2=40811&view=diff == --- llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp Fri Aug 3 21:32:22 2007 @@ -532,17 +532,26 @@ void PromoteMem2Reg::RewriteSingleStoreAlloca(AllocaInst *AI, AllocaInfo &Info) { StoreInst *OnlyStore = Info.OnlyStore; + bool StoringGlobalVal = !isa(OnlyStore->getOperand(0)); // Be aware of loads before the store. SmallPtrSet ProcessedBlocks; for (unsigned i = 0, e = Info.UsingBlocks.size(); i != e; ++i) { -// If the store dominates the block and if we haven't processed it yet, -// do so now. -if (!dominates(OnlyStore->getParent(), Info.UsingBlocks[i])) +BasicBlock *UseBlock = Info.UsingBlocks[i]; + +// If we already processed this block, don't reprocess it. +if (!ProcessedBlocks.insert(UseBlock)) { + Info.UsingBlocks[i] = Info.UsingBlocks.back(); + Info.UsingBlocks.pop_back(); + --i; --e; continue; +} -BasicBlock *UseBlock = Info.UsingBlocks[i]; -if (!ProcessedBlocks.insert(UseBlock)) +// If the store dominates the block and if we haven't processed it yet, +// do so now. We can't handle the case where the store doesn't dominate a +// block because there may be a path between the store and the use, but we +// may need to insert phi nodes to handle dominance properly. +if (StoringGlobalVal || !dominates(OnlyStore->getParent(), UseBlock)) continue; // If the use and store are in the same block, do a quick scan to @@ -553,7 +562,8 @@ if (isa(I) && I->getOperand(0) == AI) break; } - if (&*I != OnlyStore) break; // Do not handle this case. + if (&*I != OnlyStore) +break; // Do not handle this alloca. } // Otherwise, if this is a different block or if all uses happen ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r40812 - /llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
Author: lattner Date: Fri Aug 3 21:38:38 2007 New Revision: 40812 URL: http://llvm.org/viewvc/llvm-project?rev=40812&view=rev Log: When we do the single-store optimization, delete both the store and the alloca so they don't get reprocessed. This speeds up PR1432 from 2.20s to 2.17s. Modified: llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp Modified: llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp?rev=40812&r1=40811&r2=40812&view=diff == --- llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp Fri Aug 3 21:38:38 2007 @@ -290,9 +290,15 @@ // Finally, after the scan, check to see if the store is all that is left. if (Info.UsingBlocks.empty()) { -++NumSingleStore; +// Remove the (now dead) store and alloca. +Info.OnlyStore->eraseFromParent(); +if (AST) AST->deleteValue(AI); +AI->eraseFromParent(); + // The alloca has been processed, move on. RemoveFromAllocasList(AllocaNum); + +++NumSingleStore; continue; } } @@ -728,7 +734,7 @@ if (AIt != CurValues.end()) { // Store updates the "current value"... AIt->second = SI->getOperand(0); - BB->getInstList().erase(SI); + SI->eraseFromParent(); } } } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r40813 - /llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
Author: lattner Date: Fri Aug 3 21:45:02 2007 New Revision: 40813 URL: http://llvm.org/viewvc/llvm-project?rev=40813&view=rev Log: fix a logic bug where we wouldn't promote single store allocas if the stored value was a non-instruction value. Doh. This increase the # single store allocas from 8982 to 9026, and speeds up mem2reg on the testcase in PR1432 from 2.17 to 2.13s. Modified: llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp Modified: llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp?rev=40813&r1=40812&r2=40813&view=diff == --- llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp Fri Aug 3 21:45:02 2007 @@ -557,7 +557,7 @@ // do so now. We can't handle the case where the store doesn't dominate a // block because there may be a path between the store and the use, but we // may need to insert phi nodes to handle dominance properly. -if (StoringGlobalVal || !dominates(OnlyStore->getParent(), UseBlock)) +if (!StoringGlobalVal && !dominates(OnlyStore->getParent(), UseBlock)) continue; // If the use and store are in the same block, do a quick scan to @@ -569,7 +569,7 @@ break; } if (&*I != OnlyStore) -break; // Do not handle this alloca. +continue; // Do not promote the uses of this in this block. } // Otherwise, if this is a different block or if all uses happen ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm] r40809 - /llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
On Sat, 2007-08-04 at 02:15 +, Chris Lattner wrote: > Author: lattner > Date: Fri Aug 3 21:15:24 2007 > New Revision: 40809 > > URL: http://llvm.org/viewvc/llvm-project?rev=40809&view=rev > Log: > In mem2reg, when handling the single-store case, make sure to remove > a using block from the list if we handle it. Not doing this caused us > to not be able to promote (with the fast path) allocas which have uses > (whoops). > > This increases the # allocas hitting this fastpath from 4042 to 8935 on the > testcase in PR1432, speeding up mem2reg by 2.6x Whoa! Nice! Reid. > > > Modified: > llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp > > Modified: llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp > URL: > http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp?rev=40809&r1=40808&r2=40809&view=diff > > == > --- llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp (original) > +++ llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp Fri Aug 3 > 21:15:24 2007 > @@ -531,28 +531,29 @@ > /// the value stored. > void PromoteMem2Reg::RewriteSingleStoreAlloca(AllocaInst *AI, >AllocaInfo &Info) { > + StoreInst *OnlyStore = Info.OnlyStore; > + >// Be aware of loads before the store. >std::set ProcessedBlocks; >for (unsigned i = 0, e = Info.UsingBlocks.size(); i != e; ++i) { > // If the store dominates the block and if we haven't processed it yet, > // do so now. > -if (!dominates(Info.OnlyStore->getParent(), Info.UsingBlocks[i])) > - continue; > - > -if (!ProcessedBlocks.insert(Info.UsingBlocks[i]).second) > +if (!dominates(OnlyStore->getParent(), Info.UsingBlocks[i])) >continue; > > BasicBlock *UseBlock = Info.UsingBlocks[i]; > +if (!ProcessedBlocks.insert(UseBlock).second) > + continue; > > // If the use and store are in the same block, do a quick scan to > // verify that there are no uses before the store. > -if (UseBlock == Info.OnlyStore->getParent()) { > +if (UseBlock == OnlyStore->getParent()) { >BasicBlock::iterator I = UseBlock->begin(); > - for (; &*I != Info.OnlyStore; ++I) { // scan block for store. > + for (; &*I != OnlyStore; ++I) { // scan block for store. > if (isa(I) && I->getOperand(0) == AI) >break; >} > - if (&*I != Info.OnlyStore) break; // Do not handle this case. > + if (&*I != OnlyStore) break; // Do not handle this case. > } > > // Otherwise, if this is a different block or if all uses happen > @@ -562,7 +563,7 @@ > I != E; ) { >if (LoadInst *LI = dyn_cast(I++)) { > if (LI->getOperand(0) == AI) { > - LI->replaceAllUsesWith(Info.OnlyStore->getOperand(0)); > + LI->replaceAllUsesWith(OnlyStore->getOperand(0)); >if (AST && isa(LI->getType())) > AST->deleteValue(LI); >LI->eraseFromParent(); > @@ -572,6 +573,7 @@ > > // Finally, remove this block from the UsingBlock set. > Info.UsingBlocks[i] = Info.UsingBlocks.back(); > +Info.UsingBlocks.pop_back(); > --i; --e; >} > } > > > ___ > llvm-commits mailing list > llvm-commits@cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits