From lattner at cs.uiuc.edu Mon Sep 1 10:30:02 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Sep 1 10:30:02 2003 Subject: [llvm-commits] CVS: llvm/test/Programs/SingleSource/CustomChecked/Makefile Message-ID: <200309011529.KAA10769@apoc.cs.uiuc.edu> Changes in directory llvm/test/Programs/SingleSource/CustomChecked: Makefile updated: 1.3 -> 1.4 --- Log message: Add C++ and EH libraries for the C++ tests --- Diffs of the changes: Index: llvm/test/Programs/SingleSource/CustomChecked/Makefile diff -u llvm/test/Programs/SingleSource/CustomChecked/Makefile:1.3 llvm/test/Programs/SingleSource/CustomChecked/Makefile:1.4 --- llvm/test/Programs/SingleSource/CustomChecked/Makefile:1.3 Wed May 14 14:00:46 2003 +++ llvm/test/Programs/SingleSource/CustomChecked/Makefile Mon Sep 1 10:29:18 2003 @@ -6,6 +6,8 @@ include $(LEVEL)/test/Programs/SingleSource/Makefile.singlesrc +LIBS += -lsupc++ -lexception + LLI_RUN := $(addsuffix .run-lli, $(PREFIXED_PROGRAMS_TO_TEST)) JIT_RUN := $(addsuffix .run-jit, $(PREFIXED_PROGRAMS_TO_TEST)) LLC_RUN := $(addsuffix .run-llc, $(PREFIXED_PROGRAMS_TO_TEST)) From lattner at cs.uiuc.edu Mon Sep 1 11:32:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Sep 1 11:32:01 2003 Subject: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y Message-ID: <200309011631.LAA11839@apoc.cs.uiuc.edu> Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.120 -> 1.121 --- Log message: Remove gross old hacky code that was in there for backwards compatibility 1 year is plenty of migration time! --- Diffs of the changes: Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.120 llvm/lib/AsmParser/llvmAsmParser.y:1.121 --- llvm/lib/AsmParser/llvmAsmParser.y:1.120 Sat Aug 23 18:14:51 2003 +++ llvm/lib/AsmParser/llvmAsmParser.y Mon Sep 1 11:31:28 2003 @@ -37,14 +37,6 @@ #define YYERROR_VERBOSE 1 -// HACK ALERT: This variable is used to implement the automatic conversion of -// load/store instructions with indexes into a load/store + getelementptr pair -// of instructions. When this compatiblity "Feature" is removed, this should be -// too. -// -static BasicBlock *CurBB; - - // This contains info used when building the body of a function. It is // destroyed when the function is completed. // @@ -1457,7 +1449,7 @@ $$ = $1; } | /* empty */ { - $$ = CurBB = new BasicBlock(); + $$ = new BasicBlock(); }; BBTerminatorInst : RET ResolvedVal { // Return with a result... @@ -1741,66 +1733,27 @@ $$ = new FreeInst($2); } - | LOAD Types ValueRef IndexList { + | LOAD Types ValueRef { if (!isa($2->get())) ThrowException("Can't load from nonpointer type: " + (*$2)->getDescription()); - if (GetElementPtrInst::getIndexedType(*$2, *$4) == 0) - ThrowException("Invalid indices for load instruction!"); - - Value *Src = getVal(*$2, $3); - if (!$4->empty()) { - std::cerr << "WARNING: Use of index load instruction:" - << " replacing with getelementptr/load pair.\n"; - // Create a getelementptr hack instruction to do the right thing for - // compatibility. - // - Instruction *I = new GetElementPtrInst(Src, *$4); - CurBB->getInstList().push_back(I); - Src = I; - } - - $$ = new LoadInst(Src); - delete $4; // Free the vector... + $$ = new LoadInst(getVal(*$2, $3)); delete $2; } - | STORE ResolvedVal ',' Types ValueRef IndexList { - if (!isa($4->get())) + | STORE ResolvedVal ',' Types ValueRef { + const PointerType *PT = dyn_cast($4->get()); + if (!PT) ThrowException("Can't store to a nonpointer type: " + (*$4)->getDescription()); - const Type *ElTy = GetElementPtrInst::getIndexedType(*$4, *$6); - if (ElTy == 0) - ThrowException("Can't store into that field list!"); + const Type *ElTy = PT->getElementType(); if (ElTy != $2->getType()) ThrowException("Can't store '" + $2->getType()->getDescription() + "' into space of type '" + ElTy->getDescription() + "'!"); - Value *Ptr = getVal(*$4, $5); - if (!$6->empty()) { - std::cerr << "WARNING: Use of index store instruction:" - << " replacing with getelementptr/store pair.\n"; - // Create a getelementptr hack instruction to do the right thing for - // compatibility. - // - Instruction *I = new GetElementPtrInst(Ptr, *$6); - CurBB->getInstList().push_back(I); - Ptr = I; - } - - $$ = new StoreInst($2, Ptr); - delete $4; delete $6; + $$ = new StoreInst($2, getVal(*$4, $5)); + delete $4; } | GETELEMENTPTR Types ValueRef IndexList { - for (unsigned i = 0, e = $4->size(); i != e; ++i) { - if ((*$4)[i]->getType() == Type::UIntTy) { - std::cerr << "WARNING: Use of uint type indexes to getelementptr " - << "instruction: replacing with casts to long type.\n"; - Instruction *I = new CastInst((*$4)[i], Type::LongTy); - CurBB->getInstList().push_back(I); - (*$4)[i] = I; - } - } - if (!isa($2->get())) ThrowException("getelementptr insn requires pointer operand!"); if (!GetElementPtrInst::getIndexedType(*$2, *$4, true)) From lattner at cs.uiuc.edu Mon Sep 1 11:36:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Sep 1 11:36:01 2003 Subject: [llvm-commits] CVS: llvm/include/llvm/DerivedTypes.h Message-ID: <200309011635.LAA11885@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: DerivedTypes.h updated: 1.33 -> 1.34 --- Log message: Fix spell-o --- Diffs of the changes: Index: llvm/include/llvm/DerivedTypes.h diff -u llvm/include/llvm/DerivedTypes.h:1.33 llvm/include/llvm/DerivedTypes.h:1.34 --- llvm/include/llvm/DerivedTypes.h:1.33 Thu Aug 21 17:08:59 2003 +++ llvm/include/llvm/DerivedTypes.h Mon Sep 1 11:35:30 2003 @@ -58,7 +58,8 @@ // removeAbstractTypeUser - Notify an abstract type that a user of the class // no longer has a handle to the type. This function is called primarily by // the PATypeHandle class. When there are no users of the abstract type, it - // is anihilated, because there is no way to get a reference to it ever again. + // is annihilated, because there is no way to get a reference to it ever + // again. // void removeAbstractTypeUser(AbstractTypeUser *U) const; From lattner at cs.uiuc.edu Mon Sep 1 11:39:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Sep 1 11:39:01 2003 Subject: [llvm-commits] CVS: llvm/include/llvm/DerivedTypes.h Message-ID: <200309011638.LAA14332@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: DerivedTypes.h updated: 1.34 -> 1.35 --- Log message: Other minor cleanups while I'm in the area --- Diffs of the changes: Index: llvm/include/llvm/DerivedTypes.h diff -u llvm/include/llvm/DerivedTypes.h:1.34 llvm/include/llvm/DerivedTypes.h:1.35 --- llvm/include/llvm/DerivedTypes.h:1.34 Mon Sep 1 11:35:30 2003 +++ llvm/include/llvm/DerivedTypes.h Mon Sep 1 11:38:43 2003 @@ -83,8 +83,7 @@ -class FunctionType : public DerivedType { -public: +struct FunctionType : public DerivedType { typedef std::vector ParamTypes; private: PATypeHandle ResultType; @@ -150,7 +149,6 @@ class CompositeType : public DerivedType { protected: inline CompositeType(PrimitiveID id) : DerivedType(id) { } - public: // getTypeAtIndex - Given an index value into the type, return the type of the @@ -250,7 +248,6 @@ : CompositeType(TID), ElementType(PATypeHandle(ElType, this)) { } public: - inline const Type *getElementType() const { return ElementType; } virtual const Type *getContainedType(unsigned i) const { @@ -295,7 +292,6 @@ // from GCC to make them protected: warning: `class ArrayType' only // defines private constructors and has no friends - // Private ctor - Only can be created by a static member... ArrayType(const Type *ElType, unsigned NumEl); public: @@ -329,7 +325,6 @@ // from GCC to make them protected: warning: `class PointerType' only // defines private constructors and has no friends - // Private ctor - Only can be created by a static member... PointerType(const Type *ElType); public: @@ -354,9 +349,8 @@ class OpaqueType : public DerivedType { -private: - OpaqueType(const OpaqueType &); // Do not implement - const OpaqueType &operator=(const OpaqueType &); // Do not implement + OpaqueType(const OpaqueType &); // DO NOT IMPLEMENT + const OpaqueType &operator=(const OpaqueType &); // DO NOT IMPLEMENT protected: // This should really be private, but it squelches a bogus warning // from GCC to make them protected: warning: `class OpaqueType' only @@ -364,7 +358,6 @@ // Private ctor - Only can be created by a static member... OpaqueType(); - public: // get - Static factory method for the OpaqueType class... From lattner at cs.uiuc.edu Mon Sep 1 11:43:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Sep 1 11:43:01 2003 Subject: [llvm-commits] CVS: llvm/include/llvm/Transforms/Parallelize.h Message-ID: <200309011642.LAA24129@neo.cs.uiuc.edu> Changes in directory llvm/include/llvm/Transforms: Parallelize.h (r1.1) removed --- Log message: This file is just a subset of Cilkifier.h --- Diffs of the changes: From lattner at cs.uiuc.edu Mon Sep 1 11:43:02 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Sep 1 11:43:02 2003 Subject: [llvm-commits] CVS: llvm/lib/Transforms/IPO/Parallelize.cpp Message-ID: <200309011642.LAA24118@neo.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/IPO: Parallelize.cpp updated: 1.3 -> 1.4 --- Log message: Minor cleanups Do not #include Parallelize.h, it's just a subset of Cilkifier.h --- Diffs of the changes: Index: llvm/lib/Transforms/IPO/Parallelize.cpp diff -u llvm/lib/Transforms/IPO/Parallelize.cpp:1.3 llvm/lib/Transforms/IPO/Parallelize.cpp:1.4 --- llvm/lib/Transforms/IPO/Parallelize.cpp:1.3 Wed Aug 6 12:16:24 2003 +++ llvm/lib/Transforms/IPO/Parallelize.cpp Mon Sep 1 11:42:16 2003 @@ -1,4 +1,4 @@ -//===- Parallelize.cpp - Auto parallelization using DS Graphs ---*- C++ -*-===// +//===- Parallelize.cpp - Auto parallelization using DS Graphs -------------===// // // This file implements a pass that automatically parallelizes a program, // using the Cilk multi-threaded runtime system to execute parallel code. @@ -28,19 +28,16 @@ // -- Excessive overhead at "spawned" function calls, which has no benefit // once all threads are busy (especially common when the degree of // parallelism is low). +// //===----------------------------------------------------------------------===// - -#include "llvm/Transforms/Parallelize.h" #include "llvm/Transforms/Utils/DemoteRegToStack.h" #include "llvm/Analysis/PgmDependenceGraph.h" #include "llvm/Analysis/Dominators.h" #include "llvm/Analysis/DataStructure.h" #include "llvm/Analysis/DSGraph.h" #include "llvm/Module.h" -#include "llvm/Function.h" -#include "llvm/iOther.h" -#include "llvm/iPHINode.h" +#include "llvm/Instructions.h" #include "llvm/iTerminators.h" #include "llvm/DerivedTypes.h" #include "llvm/Support/InstVisitor.h" @@ -49,8 +46,6 @@ #include "Support/STLExtras.h" #include "Support/hash_set" #include "Support/hash_map" -#include -#include #include #include @@ -221,14 +216,14 @@ // Now find all outgoing SSA dependences to the eventual non-Phi users of // the call value (i.e., direct users that are not phis, and for any // user that is a Phi, direct non-Phi users of that Phi, and recursively). - std::stack phiUsers; + std::vector phiUsers; hash_set phisSeen; // ensures we don't visit a phi twice for (Value::use_iterator UI=CI.use_begin(), UE=CI.use_end(); UI != UE; ++UI) if (const PHINode* phiUser = dyn_cast(*UI)) { if (phisSeen.find(phiUser) == phisSeen.end()) { - phiUsers.push(phiUser); + phiUsers.push_back(phiUser); phisSeen.insert(phiUser); } } @@ -237,16 +232,16 @@ // Now we've found the non-Phi users and immediate phi users. // Recursively walk the phi users and add their non-phi users. - for (const PHINode* phiUser; !phiUsers.empty(); phiUsers.pop()) + for (const PHINode* phiUser; !phiUsers.empty(); phiUsers.pop_back()) { - phiUser = phiUsers.top(); + phiUser = phiUsers.back(); for (Value::use_const_iterator UI=phiUser->use_begin(), UE=phiUser->use_end(); UI != UE; ++UI) if (const PHINode* pn = dyn_cast(*UI)) { if (phisSeen.find(pn) == phisSeen.end()) { - phiUsers.push(pn); + phiUsers.push_back(pn); phisSeen.insert(pn); } } From lattner at cs.uiuc.edu Mon Sep 1 11:46:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Sep 1 11:46:01 2003 Subject: [llvm-commits] CVS: llvm/lib/Transforms/IPO/Cilkifier.cpp Parallelize.cpp Message-ID: <200309011645.LAA23116@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/IPO: Cilkifier.cpp updated: 1.1 -> 1.2 Parallelize.cpp updated: 1.4 -> 1.5 --- Log message: Moved all of the cilkifier stuff into lib/Transforms/IPO, as it really is not support stuff. --- Diffs of the changes: Index: llvm/lib/Transforms/IPO/Cilkifier.cpp diff -u llvm/lib/Transforms/IPO/Cilkifier.cpp:1.1 llvm/lib/Transforms/IPO/Cilkifier.cpp:1.2 --- llvm/lib/Transforms/IPO/Cilkifier.cpp:1.1 Tue Dec 10 07:08:48 2002 +++ llvm/lib/Transforms/IPO/Cilkifier.cpp Mon Sep 1 11:45:30 2003 @@ -6,12 +6,10 @@ //===----------------------------------------------------------------------===// -#include "llvm/Support/Cilkifier.h" +#include "Cilkifier.h" #include "llvm/Function.h" #include "llvm/iOther.h" #include "llvm/DerivedTypes.h" -#include - //---------------------------------------------------------------------------- // Global constants used in marking Cilk functions and function calls. Index: llvm/lib/Transforms/IPO/Parallelize.cpp diff -u llvm/lib/Transforms/IPO/Parallelize.cpp:1.4 llvm/lib/Transforms/IPO/Parallelize.cpp:1.5 --- llvm/lib/Transforms/IPO/Parallelize.cpp:1.4 Mon Sep 1 11:42:16 2003 +++ llvm/lib/Transforms/IPO/Parallelize.cpp Mon Sep 1 11:45:30 2003 @@ -31,6 +31,7 @@ // //===----------------------------------------------------------------------===// +#include "Cilkifier.h" #include "llvm/Transforms/Utils/DemoteRegToStack.h" #include "llvm/Analysis/PgmDependenceGraph.h" #include "llvm/Analysis/Dominators.h" @@ -41,7 +42,6 @@ #include "llvm/iTerminators.h" #include "llvm/DerivedTypes.h" #include "llvm/Support/InstVisitor.h" -#include "llvm/Support/Cilkifier.h" #include "Support/Statistic.h" #include "Support/STLExtras.h" #include "Support/hash_set" From lattner at cs.uiuc.edu Mon Sep 1 11:50:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Sep 1 11:50:01 2003 Subject: [llvm-commits] CVS: llvm/lib/Transforms/IPO/Parallelize.cpp Message-ID: <200309011649.LAA23556@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/IPO: Parallelize.cpp updated: 1.5 -> 1.6 --- Log message: If "These should be used only by the auto-parallelization pass", we might as well put them INTO the auto-par pass. --- Diffs of the changes: Index: llvm/lib/Transforms/IPO/Parallelize.cpp diff -u llvm/lib/Transforms/IPO/Parallelize.cpp:1.5 llvm/lib/Transforms/IPO/Parallelize.cpp:1.6 --- llvm/lib/Transforms/IPO/Parallelize.cpp:1.5 Mon Sep 1 11:45:30 2003 +++ llvm/lib/Transforms/IPO/Parallelize.cpp Mon Sep 1 11:49:38 2003 @@ -31,7 +31,6 @@ // //===----------------------------------------------------------------------===// -#include "Cilkifier.h" #include "llvm/Transforms/Utils/DemoteRegToStack.h" #include "llvm/Analysis/PgmDependenceGraph.h" #include "llvm/Analysis/Dominators.h" @@ -84,6 +83,37 @@ } #endif + + +//---------------------------------------------------------------------------- +// Global constants used in marking Cilk functions and function calls. +//---------------------------------------------------------------------------- + +static const char * const CilkSuffix = ".llvm2cilk"; +static const char * const DummySyncFuncName = "__sync.llvm2cilk"; + +//---------------------------------------------------------------------------- +// Routines to identify Cilk functions, calls to Cilk functions, and syncs. +//---------------------------------------------------------------------------- + +static bool isCilk(const Function& F) { + return (F.getName().rfind(CilkSuffix) == + F.getName().size() - std::strlen(CilkSuffix)); +} + +static bool isCilkMain(const Function& F) { + return F.getName() == "main" + std::string(CilkSuffix); +} + + +static bool isCilk(const CallInst& CI) { + return CI.getCalledFunction() && isCilk(*CI.getCalledFunction()); +} + +static bool isSync(const CallInst& CI) { + return CI.getCalledFunction() && + CI.getCalledFunction()->getName() == DummySyncFuncName; +} //---------------------------------------------------------------------------- From lattner at cs.uiuc.edu Mon Sep 1 11:51:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Sep 1 11:51:01 2003 Subject: [llvm-commits] CVS: llvm/lib/Transforms/IPO/Cilkifier.cpp Cilkifier.h Message-ID: <200309011650.LAA23573@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/IPO: Cilkifier.cpp (r1.2) removed Cilkifier.h (r1.1) removed --- Log message: Dead files --- Diffs of the changes: From lattner at cs.uiuc.edu Mon Sep 1 11:54:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Sep 1 11:54:01 2003 Subject: [llvm-commits] CVS: llvm/lib/Transforms/IPO/Parallelize.cpp Message-ID: <200309011653.LAA23893@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/IPO: Parallelize.cpp updated: 1.6 -> 1.7 --- Log message: Not only is this a lot smaller, it actually works if there is already a function with the right name in the module. --- Diffs of the changes: Index: llvm/lib/Transforms/IPO/Parallelize.cpp diff -u llvm/lib/Transforms/IPO/Parallelize.cpp:1.6 llvm/lib/Transforms/IPO/Parallelize.cpp:1.7 --- llvm/lib/Transforms/IPO/Parallelize.cpp:1.6 Mon Sep 1 11:49:38 2003 +++ llvm/lib/Transforms/IPO/Parallelize.cpp Mon Sep 1 11:53:46 2003 @@ -158,11 +158,7 @@ Cilkifier::Cilkifier(Module& M) { // create the dummy Sync function and add it to the Module - DummySyncFunc = new Function(FunctionType::get( Type::VoidTy, - std::vector(), - /*isVararg*/ false), - GlobalValue::ExternalLinkage, DummySyncFuncName, - &M); + DummySyncFunc = M.getOrInsertFunction(DummySyncFuncName, Type::VoidTy, 0); } void Cilkifier::TransformFunc(Function* F, From lattner at cs.uiuc.edu Mon Sep 1 13:02:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Sep 1 13:02:01 2003 Subject: [llvm-commits] CVS: llvm/lib/Transforms/IPO/Parallelize.cpp Message-ID: <200309011801.NAA24705@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/IPO: Parallelize.cpp updated: 1.7 -> 1.8 --- Log message: Final cleanup: remove dead code --- Diffs of the changes: Index: llvm/lib/Transforms/IPO/Parallelize.cpp diff -u llvm/lib/Transforms/IPO/Parallelize.cpp:1.7 llvm/lib/Transforms/IPO/Parallelize.cpp:1.8 --- llvm/lib/Transforms/IPO/Parallelize.cpp:1.7 Mon Sep 1 11:53:46 2003 +++ llvm/lib/Transforms/IPO/Parallelize.cpp Mon Sep 1 13:01:36 2003 @@ -33,12 +33,10 @@ #include "llvm/Transforms/Utils/DemoteRegToStack.h" #include "llvm/Analysis/PgmDependenceGraph.h" -#include "llvm/Analysis/Dominators.h" #include "llvm/Analysis/DataStructure.h" #include "llvm/Analysis/DSGraph.h" #include "llvm/Module.h" #include "llvm/Instructions.h" -#include "llvm/iTerminators.h" #include "llvm/DerivedTypes.h" #include "llvm/Support/InstVisitor.h" #include "Support/Statistic.h" @@ -47,43 +45,6 @@ #include "Support/hash_map" #include #include - - - -#if 0 -void AddToDomSet(vector& domSet, BasicBlock* bb, - const DominatorTree& domTree) -{ - DominatorTreeBase::Node* bbNode = domTree.getNode(bb); - const std::vector& domKids = bbNode.getChildren(); - domSet.insert(domSet.end(), domKids.begin(), domKids.end()); - for (unsigned i = 0; i < domKids.size(); ++i) - AddToDomSet(domSet, domKids[i]->getNode(), domTree); -} - -bool CheckDominance(Function& func, - const CallInst& callInst1, - const CallInst& callInst2) -{ - if (callInst1 == callInst2) // makes sense if this is in a loop but - return false; // we're not handling loops yet - - // Check first if one call dominates the other - DominatorSet& domSet = getAnalysis(func); - if (domSet.dominates(callInst2, callInst1)) - { // swap callInst1 and callInst2 - const CallInst& tmp = callInst2; callInst2 = callInst1; callInst1 = tmp; - } - else if (! domSet.dominates(callInst1, callInst2)) - return false; // neither dominates the other: - - // - if (! AreIndependent(func, callInst1, callInst2)) - return false; -} - -#endif - //---------------------------------------------------------------------------- // Global constants used in marking Cilk functions and function calls. From lattner at cs.uiuc.edu Mon Sep 1 14:57:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Sep 1 14:57:01 2003 Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/SparcRegClassInfo.cpp SparcRegClassInfo.h SparcRegInfo.cpp Message-ID: <200309011956.OAA27333@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/Sparc: SparcRegClassInfo.cpp updated: 1.25 -> 1.26 SparcRegClassInfo.h updated: 1.19 -> 1.20 SparcRegInfo.cpp updated: 1.106 -> 1.107 --- Log message: No longer include IGNode.h in the Sparc global header --- Diffs of the changes: Index: llvm/lib/Target/Sparc/SparcRegClassInfo.cpp diff -u llvm/lib/Target/Sparc/SparcRegClassInfo.cpp:1.25 llvm/lib/Target/Sparc/SparcRegClassInfo.cpp:1.26 --- llvm/lib/Target/Sparc/SparcRegClassInfo.cpp:1.25 Fri Jul 25 16:12:15 2003 +++ llvm/lib/Target/Sparc/SparcRegClassInfo.cpp Mon Sep 1 14:56:48 2003 @@ -8,6 +8,7 @@ #include "SparcInternals.h" #include "llvm/Type.h" #include "../../CodeGen/RegAlloc/RegAllocCommon.h" // FIXME! +#include "llvm/CodeGen/IGNode.h" //----------------------------------------------------------------------------- // Int Register Class - method for coloring a node in the interference graph. @@ -160,6 +161,19 @@ Node->setColor(ccReg); // only one int cc reg is available } + + +void SparcFloatCCRegClass::colorIGNode(IGNode *Node, + const std::vector &IsColorUsedArr) const { + for(unsigned c = 0; c != 4; ++c) + if (!IsColorUsedArr[c]) { // find unused color + Node->setColor(c); + return; + } + + Node->getParentLR()->markForSpill(); +} + //----------------------------------------------------------------------------- Index: llvm/lib/Target/Sparc/SparcRegClassInfo.h diff -u llvm/lib/Target/Sparc/SparcRegClassInfo.h:1.19 llvm/lib/Target/Sparc/SparcRegClassInfo.h:1.20 --- llvm/lib/Target/Sparc/SparcRegClassInfo.h:1.19 Fri Jul 25 16:12:15 2003 +++ llvm/lib/Target/Sparc/SparcRegClassInfo.h Mon Sep 1 14:56:48 2003 @@ -8,7 +8,6 @@ #define SPARC_REG_CLASS_INFO_H #include "llvm/Target/TargetRegInfo.h" -#include "llvm/CodeGen/IGNode.h" //----------------------------------------------------------------------------- // Integer Register Class @@ -175,15 +174,7 @@ : TargetRegClassInfo(ID, 4, 5) { } void colorIGNode(IGNode *Node, - const std::vector &IsColorUsedArr) const { - for(unsigned c = 0; c != 4; ++c) - if (!IsColorUsedArr[c]) { // find unused color - Node->setColor(c); - return; - } - - Node->getParentLR()->markForSpill(); - } + const std::vector &IsColorUsedArr) const; // according to Sparc 64 ABI, all %fp CC regs are volatile // Index: llvm/lib/Target/Sparc/SparcRegInfo.cpp diff -u llvm/lib/Target/Sparc/SparcRegInfo.cpp:1.106 llvm/lib/Target/Sparc/SparcRegInfo.cpp:1.107 --- llvm/lib/Target/Sparc/SparcRegInfo.cpp:1.106 Tue Jul 29 14:53:21 2003 +++ llvm/lib/Target/Sparc/SparcRegInfo.cpp Mon Sep 1 14:56:48 2003 @@ -14,6 +14,7 @@ #include "llvm/CodeGen/MachineCodeForInstruction.h" #include "llvm/CodeGen/MachineInstrAnnot.h" #include "llvm/CodeGen/LiveRangeInfo.h" +#include "llvm/CodeGen/IGNode.h" #include "llvm/iTerminators.h" #include "llvm/iOther.h" #include "llvm/Function.h" From lattner at cs.uiuc.edu Mon Sep 1 14:59:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Sep 1 14:59:01 2003 Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/SparcRegInfo.cpp Message-ID: <200309011958.OAA27654@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/Sparc: SparcRegInfo.cpp updated: 1.107 -> 1.108 --- Log message: This file just needs LiveRange.h not IGNode.h --- Diffs of the changes: Index: llvm/lib/Target/Sparc/SparcRegInfo.cpp diff -u llvm/lib/Target/Sparc/SparcRegInfo.cpp:1.107 llvm/lib/Target/Sparc/SparcRegInfo.cpp:1.108 --- llvm/lib/Target/Sparc/SparcRegInfo.cpp:1.107 Mon Sep 1 14:56:48 2003 +++ llvm/lib/Target/Sparc/SparcRegInfo.cpp Mon Sep 1 14:58:02 2003 @@ -14,7 +14,7 @@ #include "llvm/CodeGen/MachineCodeForInstruction.h" #include "llvm/CodeGen/MachineInstrAnnot.h" #include "llvm/CodeGen/LiveRangeInfo.h" -#include "llvm/CodeGen/IGNode.h" +#include "llvm/CodeGen/LiveRange.h" #include "llvm/iTerminators.h" #include "llvm/iOther.h" #include "llvm/Function.h" @@ -941,7 +941,7 @@ void UltraSparcRegInfo::printReg(const LiveRange *LR) const { unsigned RegClassID = LR->getRegClassID(); - std::cerr << " *Node " << (LR->getUserIGNode())->getIndex(); + std::cerr << " Node "; if (!LR->hasColor()) { std::cerr << " - could not find a color\n"; From lattner at cs.uiuc.edu Mon Sep 1 15:01:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Sep 1 15:01:01 2003 Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/SparcRegClassInfo.cpp Message-ID: <200309012000.PAA27851@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/Sparc: SparcRegClassInfo.cpp updated: 1.26 -> 1.27 --- Log message: IGNode got moved to lib/CodeGen/RegAlloc --- Diffs of the changes: Index: llvm/lib/Target/Sparc/SparcRegClassInfo.cpp diff -u llvm/lib/Target/Sparc/SparcRegClassInfo.cpp:1.26 llvm/lib/Target/Sparc/SparcRegClassInfo.cpp:1.27 --- llvm/lib/Target/Sparc/SparcRegClassInfo.cpp:1.26 Mon Sep 1 14:56:48 2003 +++ llvm/lib/Target/Sparc/SparcRegClassInfo.cpp Mon Sep 1 15:00:08 2003 @@ -8,7 +8,7 @@ #include "SparcInternals.h" #include "llvm/Type.h" #include "../../CodeGen/RegAlloc/RegAllocCommon.h" // FIXME! -#include "llvm/CodeGen/IGNode.h" +#include "../../CodeGen/RegAlloc/IGNode.h" // FIXME! //----------------------------------------------------------------------------- // Int Register Class - method for coloring a node in the interference graph. From lattner at cs.uiuc.edu Mon Sep 1 15:06:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Sep 1 15:06:01 2003 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/RegAlloc/IGNode.cpp InterferenceGraph.cpp LiveRangeInfo.cpp PhyRegAlloc.cpp RegClass.cpp Message-ID: <200309012005.PAA29518@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/RegAlloc: IGNode.cpp updated: 1.8 -> 1.9 InterferenceGraph.cpp updated: 1.15 -> 1.16 LiveRangeInfo.cpp updated: 1.42 -> 1.43 PhyRegAlloc.cpp updated: 1.105 -> 1.106 RegClass.cpp updated: 1.23 -> 1.24 --- Log message: Move IGNode from public include directory to here. Minor cleanups like adding std:: namespace qualifiers --- Diffs of the changes: Index: llvm/lib/CodeGen/RegAlloc/IGNode.cpp diff -u llvm/lib/CodeGen/RegAlloc/IGNode.cpp:1.8 llvm/lib/CodeGen/RegAlloc/IGNode.cpp:1.9 --- llvm/lib/CodeGen/RegAlloc/IGNode.cpp:1.8 Thu Sep 19 19:45:46 2002 +++ llvm/lib/CodeGen/RegAlloc/IGNode.cpp Mon Sep 1 15:05:47 2003 @@ -1,13 +1,12 @@ -//===-- IGNode.cpp -------------------------------------------------------===// +//===-- IGNode.cpp --------------------------------------------------------===// // // class IGNode for coloring-based register allocation for LLVM. // //===----------------------------------------------------------------------===// -#include "llvm/CodeGen/IGNode.h" +#include "IGNode.h" #include #include -using std::cerr; //----------------------------------------------------------------------------- // Sets this IGNode on stack and reduce the degree of neighbors @@ -18,7 +17,7 @@ int neighs = AdjList.size(); if (neighs < 0) { - cerr << "\nAdj List size = " << neighs; + std::cerr << "\nAdj List size = " << neighs; assert(0 && "Invalid adj list size"); } Index: llvm/lib/CodeGen/RegAlloc/InterferenceGraph.cpp diff -u llvm/lib/CodeGen/RegAlloc/InterferenceGraph.cpp:1.15 llvm/lib/CodeGen/RegAlloc/InterferenceGraph.cpp:1.16 --- llvm/lib/CodeGen/RegAlloc/InterferenceGraph.cpp:1.15 Thu Jul 10 14:43:33 2003 +++ llvm/lib/CodeGen/RegAlloc/InterferenceGraph.cpp Mon Sep 1 15:05:47 2003 @@ -6,7 +6,7 @@ #include "RegAllocCommon.h" #include "InterferenceGraph.h" -#include "llvm/CodeGen/IGNode.h" +#include "IGNode.h" #include "Support/STLExtras.h" #include using std::cerr; @@ -22,22 +22,18 @@ // The matrix is NOT yet created by the constructor. Call createGraph() // to create it after adding all IGNodes to the IGNodeList. //----------------------------------------------------------------------------- -InterferenceGraph::InterferenceGraph(RegClass *const RC) : RegCl(RC), - IGNodeList() -{ +InterferenceGraph::InterferenceGraph(RegClass *const RC) : RegCl(RC) { IG = NULL; Size = 0; - if( DEBUG_RA >= RA_DEBUG_Interference) { - cerr << "Interference graph created!\n"; - } + if( DEBUG_RA >= RA_DEBUG_Interference) + std::cerr << "Interference graph created!\n"; } //----------------------------------------------------------------------------- // destructor. Deletes the bit matrix and all IGNodes //----------------------------------------------------------------------------- -InterferenceGraph:: ~InterferenceGraph() { - +InterferenceGraph:: ~InterferenceGraph() { // delete the matrix for(unsigned int r=0; r < IGNodeList.size(); ++r) delete[] IG[r]; @@ -98,7 +94,7 @@ char *val; if( DEBUG_RA >= RA_DEBUG_Interference) - cerr << "setting intf for: [" << row << "][" << col << "]\n"; + std::cerr << "setting intf for: [" << row << "][" << col << "]\n"; ( row > col) ? val = &IG[row][col]: val = &IG[col][row]; @@ -152,9 +148,9 @@ assertIGNode(this, SrcNode); if( DEBUG_RA >= RA_DEBUG_Interference) { - cerr << "Merging LRs: \""; printSet(*LR1); - cerr << "\" and \""; printSet(*LR2); - cerr << "\"\n"; + std::cerr << "Merging LRs: \""; printSet(*LR1); + std::cerr << "\" and \""; printSet(*LR2); + std::cerr << "\"\n"; } unsigned SrcDegree = SrcNode->getNumOfNeighbors(); @@ -215,20 +211,16 @@ //---------------------------------------------------------------------------- // Print the IGnodes //---------------------------------------------------------------------------- -void InterferenceGraph::printIG() const -{ - - for(unsigned int i=0; i < Size; i++) { - +void InterferenceGraph::printIG() const { + for(unsigned i=0; i < Size; i++) { const IGNode *const Node = IGNodeList[i]; if(Node) { - cerr << " [" << i << "] "; + std::cerr << " [" << i << "] "; - for( unsigned int j=0; j < Size; j++) { + for( unsigned int j=0; j < Size; j++) if(IG[i][j]) - cerr << "(" << i << "," << j << ") "; - } - cerr << "\n"; + std::cerr << "(" << i << "," << j << ") "; + std::cerr << "\n"; } } } @@ -236,16 +228,15 @@ //---------------------------------------------------------------------------- // Print the IGnodes in the IGNode List //---------------------------------------------------------------------------- -void InterferenceGraph::printIGNodeList() const -{ +void InterferenceGraph::printIGNodeList() const { for(unsigned i=0; i < IGNodeList.size() ; ++i) { const IGNode *const Node = IGNodeList[i]; if (Node) { - cerr << " [" << Node->getIndex() << "] "; + std::cerr << " [" << Node->getIndex() << "] "; printSet(*Node->getParentLR()); //int Deg = Node->getCurDegree(); - cerr << "\t <# of Neighs: " << Node->getNumOfNeighbors() << ">\n"; + std::cerr << "\t <# of Neighs: " << Node->getNumOfNeighbors() << ">\n"; } } } Index: llvm/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp diff -u llvm/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp:1.42 llvm/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp:1.43 --- llvm/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp:1.42 Fri Jul 25 16:06:09 2003 +++ llvm/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp Mon Sep 1 15:05:47 2003 @@ -7,7 +7,7 @@ #include "llvm/CodeGen/LiveRangeInfo.h" #include "RegAllocCommon.h" #include "RegClass.h" -#include "llvm/CodeGen/IGNode.h" +#include "IGNode.h" #include "llvm/CodeGen/MachineInstr.h" #include "llvm/CodeGen/MachineFunction.h" #include "llvm/Target/TargetMachine.h" @@ -15,7 +15,6 @@ #include "llvm/Target/TargetRegInfo.h" #include "llvm/Function.h" #include "Support/SetOperations.h" -using std::cerr; unsigned LiveRange::getRegClassID() const { return getRegClass()->getID(); } @@ -105,9 +104,9 @@ isCC)]); if (DEBUG_RA >= RA_DEBUG_LiveRanges) { - cerr << " Creating a LR for def "; - if (isCC) cerr << " (CC Register!)"; - cerr << " : " << RAV(Def) << "\n"; + std::cerr << " Creating a LR for def "; + if (isCC) std::cerr << " (CC Register!)"; + std::cerr << " : " << RAV(Def) << "\n"; } return DefRange; } @@ -125,7 +124,7 @@ DefRange->insert(Def); // add the operand to the range LiveRangeMap[Def] = DefRange; // make operand point to merged set if (DEBUG_RA >= RA_DEBUG_LiveRanges) - cerr << " Added to existing LR for def: " << RAV(Def) << "\n"; + std::cerr << " Added to existing LR for def: " << RAV(Def) << "\n"; } return DefRange; } @@ -139,7 +138,7 @@ void LiveRangeInfo::constructLiveRanges() { if (DEBUG_RA >= RA_DEBUG_LiveRanges) - cerr << "Constructing Live Ranges ...\n"; + std::cerr << "Constructing Live Ranges ...\n"; // first find the live ranges for all incoming args of the function since // those LRs start from the start of the function @@ -221,7 +220,7 @@ suggestRegs4CallRets(); if( DEBUG_RA >= RA_DEBUG_LiveRanges) - cerr << "Initial Live Ranges constructed!\n"; + std::cerr << "Initial Live Ranges constructed!\n"; } @@ -318,7 +317,7 @@ void LiveRangeInfo::coalesceLRs() { if(DEBUG_RA >= RA_DEBUG_LiveRanges) - cerr << "\nCoalescing LRs ...\n"; + std::cerr << "\nCoalescing LRs ...\n"; MachineFunction &MF = MachineFunction::get(Meth); for (MachineFunction::iterator BBI = MF.begin(); BBI != MF.end(); ++BBI) { @@ -329,9 +328,9 @@ const MachineInstr *MI = *MII; if( DEBUG_RA >= RA_DEBUG_LiveRanges) { - cerr << " *Iterating over machine instr "; + std::cerr << " *Iterating over machine instr "; MI->dump(); - cerr << "\n"; + std::cerr << "\n"; } // iterate over MI operands to find defs @@ -348,7 +347,7 @@ if (!LROfUse) { // if LR of use is not found //don't warn about labels if (!isa(*UseI) && DEBUG_RA >= RA_DEBUG_LiveRanges) - cerr << " !! Warning: No LR for use " << RAV(*UseI) << "\n"; + std::cerr << " !! Warning: No LR for use " << RAV(*UseI)<< "\n"; continue; // ignore and continue } @@ -388,7 +387,7 @@ } // for all BBs if (DEBUG_RA >= RA_DEBUG_LiveRanges) - cerr << "\nCoalescing Done!\n"; + std::cerr << "\nCoalescing Done!\n"; } /*--------------------------- Debug code for printing ---------------*/ @@ -396,15 +395,15 @@ void LiveRangeInfo::printLiveRanges() { LiveRangeMapType::iterator HMI = LiveRangeMap.begin(); // hash map iterator - cerr << "\nPrinting Live Ranges from Hash Map:\n"; + std::cerr << "\nPrinting Live Ranges from Hash Map:\n"; for( ; HMI != LiveRangeMap.end(); ++HMI) { if (HMI->first && HMI->second) { - cerr << " Value* " << RAV(HMI->first) << "\t: "; + std::cerr << " Value* " << RAV(HMI->first) << "\t: "; if (IGNode* igNode = HMI->second->getUserIGNode()) - cerr << "LR# " << igNode->getIndex(); + std::cerr << "LR# " << igNode->getIndex(); else - cerr << "LR# " << ""; - cerr << "\t:Values = "; printSet(*HMI->second); cerr << "\n"; + std::cerr << "LR# " << ""; + std::cerr << "\t:Values = "; printSet(*HMI->second); std::cerr << "\n"; } } } Index: llvm/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp diff -u llvm/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp:1.105 llvm/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp:1.106 --- llvm/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp:1.105 Thu Aug 14 01:09:30 2003 +++ llvm/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp Mon Sep 1 15:05:47 2003 @@ -7,7 +7,7 @@ #include "llvm/CodeGen/RegisterAllocation.h" #include "RegAllocCommon.h" #include "RegClass.h" -#include "llvm/CodeGen/IGNode.h" +#include "IGNode.h" #include "llvm/CodeGen/PhyRegAlloc.h" #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/MachineInstrAnnot.h" @@ -27,8 +27,6 @@ #include "Support/SetOperations.h" #include "Support/CommandLine.h" #include -using std::cerr; -using std::vector; RegAllocDebugLevel_t DEBUG_RA; @@ -57,13 +55,13 @@ bool runOnFunction(Function &F) { if (DEBUG_RA) - cerr << "\n********* Function "<< F.getName() << " ***********\n"; + std::cerr << "\n********* Function "<< F.getName() << " ***********\n"; PhyRegAlloc PRA(&F, Target, &getAnalysis(), &getAnalysis()); PRA.allocateRegisters(); - if (DEBUG_RA) cerr << "\nRegister allocation complete!\n"; + if (DEBUG_RA) std::cerr << "\nRegister allocation complete!\n"; return false; } @@ -110,7 +108,7 @@ // and IGNodeList (one in each IG). The actual nodes will be pushed later. //---------------------------------------------------------------------------- void PhyRegAlloc::createIGNodeListsAndIGs() { - if (DEBUG_RA >= RA_DEBUG_LiveRanges) cerr << "Creating LR lists ...\n"; + if (DEBUG_RA >= RA_DEBUG_LiveRanges) std::cerr << "Creating LR lists ...\n"; // hash map iterator LiveRangeMapType::const_iterator HMI = LRI.getLiveRangeMap()->begin(); @@ -123,7 +121,7 @@ LiveRange *L = HMI->second; // get the LiveRange if (!L) { if (DEBUG_RA) - cerr << "\n**** ?!?WARNING: NULL LIVE RANGE FOUND FOR: " + std::cerr << "\n**** ?!?WARNING: NULL LIVE RANGE FOUND FOR: " << RAV(HMI->first) << "****\n"; continue; } @@ -141,7 +139,7 @@ for ( unsigned rc=0; rc < NumOfRegClasses ; rc++) RegClassList[rc]->createInterferenceGraph(); - if (DEBUG_RA >= RA_DEBUG_LiveRanges) cerr << "LRLists Created!\n"; + if (DEBUG_RA >= RA_DEBUG_LiveRanges) std::cerr << "LRLists Created!\n"; } @@ -172,7 +170,7 @@ for ( ; LIt != LVSet->end(); ++LIt) { if (DEBUG_RA >= RA_DEBUG_Verbose) - cerr << "< Def=" << RAV(Def) << ", Lvar=" << RAV(*LIt) << "> "; + std::cerr << "< Def=" << RAV(Def) << ", Lvar=" << RAV(*LIt) << "> "; // get the live range corresponding to live var // @@ -201,7 +199,7 @@ const ValueSet *LVSetAft) { if (DEBUG_RA >= RA_DEBUG_Interference) - cerr << "\n For call inst: " << *MInst; + std::cerr << "\n For call inst: " << *MInst; // for each live var in live variable set after machine inst // @@ -217,12 +215,12 @@ // if (LR ) { if (DEBUG_RA >= RA_DEBUG_Interference) { - cerr << "\n\tLR after Call: "; + std::cerr << "\n\tLR after Call: "; printSet(*LR); } LR->setCallInterference(); if (DEBUG_RA >= RA_DEBUG_Interference) { - cerr << "\n ++After adding call interference for LR: " ; + std::cerr << "\n ++After adding call interference for LR: " ; printSet(*LR); } } @@ -265,7 +263,7 @@ { if (DEBUG_RA >= RA_DEBUG_Interference) - cerr << "Creating interference graphs ...\n"; + std::cerr << "Creating interference graphs ...\n"; unsigned BBLoopDepthCost; for (MachineFunction::iterator BBI = MF.begin(), BBE = MF.end(); @@ -339,7 +337,7 @@ addInterferencesForArgs(); if (DEBUG_RA >= RA_DEBUG_Interference) - cerr << "Interference graphs calculated!\n"; + std::cerr << "Interference graphs calculated!\n"; } @@ -359,7 +357,7 @@ for (MachineInstr::const_val_op_iterator It1 = MInst->begin(), ItE = MInst->end(); It1 != ItE; ++It1) { const LiveRange *LROfOp1 = LRI.getLiveRangeForValue(*It1); - assert((LROfOp1 || !It1.isUseOnly())&& "No LR for Def in PSEUDO insruction"); + assert((LROfOp1 || !It1.isUseOnly())&&"No LR for Def in PSEUDO insruction"); MachineInstr::const_val_op_iterator It2 = It1; for (++It2; It2 != ItE; ++It2) { @@ -378,8 +376,8 @@ } // for all operands in an instruction if (!setInterf && MInst->getNumOperands() > 2) { - cerr << "\nInterf not set for any operand in pseudo instr:\n"; - cerr << *MInst; + std::cerr << "\nInterf not set for any operand in pseudo instr:\n"; + std::cerr << *MInst; assert(0 && "Interf not set for pseudo instr with > 2 operands" ); } } @@ -399,7 +397,7 @@ addInterference(AI, &InSet, false); if (DEBUG_RA >= RA_DEBUG_Interference) - cerr << " - %% adding interference for argument " << RAV(AI) << "\n"; + std::cerr << " - %% adding interference for argument " << RAV(AI) << "\n"; } } @@ -450,7 +448,7 @@ } inline void -PrependInstructions(vector &IBef, +PrependInstructions(std::vector &IBef, MachineBasicBlock& MBB, MachineBasicBlock::iterator& MII, const std::string& msg) @@ -462,8 +460,8 @@ for (AdIt = IBef.begin(); AdIt != IBef.end() ; ++AdIt) { if (DEBUG_RA) { - if (OrigMI) cerr << "For MInst:\n " << *OrigMI; - cerr << msg << "PREPENDed instr:\n " << **AdIt << "\n"; + if (OrigMI) std::cerr << "For MInst:\n " << *OrigMI; + std::cerr << msg << "PREPENDed instr:\n " << **AdIt << "\n"; } InsertBefore(*AdIt, MBB, MII); } @@ -483,8 +481,8 @@ for ( AdIt = IAft.begin(); AdIt != IAft.end() ; ++AdIt ) { if (DEBUG_RA) { - if (OrigMI) cerr << "For MInst:\n " << *OrigMI; - cerr << msg << "APPENDed instr:\n " << **AdIt << "\n"; + if (OrigMI) std::cerr << "For MInst:\n " << *OrigMI; + std::cerr << msg << "APPENDed instr:\n " << **AdIt << "\n"; } InsertAfter(*AdIt, MBB, MII); } @@ -647,7 +645,7 @@ MBB, MII+1); // replace with NOP if (DEBUG_RA) { - cerr << "\nRegAlloc: Moved instr. with added code: " + std::cerr << "\nRegAlloc: Moved instr. with added code: " << *DelaySlotMI << " out of delay slots of instr: " << *MInst; } @@ -766,8 +764,8 @@ MF.getInfo()->pushTempValue(MRI.getSpilledRegSize(RegType) ); - vector MIBef, MIAft; - vector AdIMid; + std::vector MIBef, MIAft; + std::vector AdIMid; // Choose a register to hold the spilled value, if one was not preallocated. // This may insert code before and after MInst to free up the value. If so, @@ -826,9 +824,9 @@ AI.InstrnsAfter.insert(AI.InstrnsAfter.begin(), MIAft.begin(), MIAft.end()); if (DEBUG_RA) { - cerr << "\nFor Inst:\n " << *MInst; - cerr << "SPILLED LR# " << LR->getUserIGNode()->getIndex(); - cerr << "; added Instructions:"; + std::cerr << "\nFor Inst:\n " << *MInst; + std::cerr << "SPILLED LR# " << LR->getUserIGNode()->getIndex(); + std::cerr << "; added Instructions:"; for_each(MIBef.begin(), MIBef.end(), std::mem_fun(&MachineInstr::dump)); for_each(MIAft.begin(), MIAft.end(), std::mem_fun(&MachineInstr::dump)); } @@ -972,7 +970,6 @@ AdIAft.begin(), AdIAft.end()); //---- Insert code for popping the reg from the stack ---------- - AdIBef.clear(); AdIAft.clear(); @@ -1212,8 +1209,8 @@ std::vector &OrigAft = AddedInstrMap[OrigMI].InstrnsAfter; if (DEBUG_RA && OrigAft.size() > 0) { - cerr << "\nRegAlloc: Moved InstrnsAfter for: " << *OrigMI; - cerr << " to last delay slot instrn: " << *DelayedMI; + std::cerr << "\nRegAlloc: Moved InstrnsAfter for: " << *OrigMI; + std::cerr << " to last delay slot instrn: " << *DelayedMI; } // "added after" instructions of the delayed instr @@ -1235,12 +1232,12 @@ void PhyRegAlloc::printMachineCode() { - cerr << "\n;************** Function " << Fn->getName() + std::cerr << "\n;************** Function " << Fn->getName() << " *****************\n"; for (MachineFunction::iterator BBI = MF.begin(), BBE = MF.end(); BBI != BBE; ++BBI) { - cerr << "\n"; printLabel(BBI->getBasicBlock()); cerr << ": "; + std::cerr << "\n"; printLabel(BBI->getBasicBlock()); std::cerr << ": "; // get the iterator for machine instructions MachineBasicBlock& MBB = *BBI; @@ -1250,8 +1247,8 @@ for ( ; MII != MBB.end(); ++MII) { MachineInstr *MInst = *MII; - cerr << "\n\t"; - cerr << TM.getInstrInfo().getName(MInst->getOpCode()); + std::cerr << "\n\t"; + std::cerr << TM.getInstrInfo().getName(MInst->getOpCode()); for (unsigned OpNum=0; OpNum < MInst->getNumOperands(); ++OpNum) { MachineOperand& Op = MInst->getOperand(OpNum); @@ -1263,58 +1260,58 @@ const Value *const Val = Op.getVRegValue () ; // ****this code is temporary till NULL Values are fixed if (! Val ) { - cerr << "\t<*NULL*>"; + std::cerr << "\t<*NULL*>"; continue; } // if a label or a constant if (isa(Val)) { - cerr << "\t"; printLabel( Op.getVRegValue () ); + std::cerr << "\t"; printLabel( Op.getVRegValue () ); } else { // else it must be a register value const int RegNum = Op.getAllocatedRegNum(); - cerr << "\t" << "%" << MRI.getUnifiedRegName( RegNum ); + std::cerr << "\t" << "%" << MRI.getUnifiedRegName( RegNum ); if (Val->hasName() ) - cerr << "(" << Val->getName() << ")"; + std::cerr << "(" << Val->getName() << ")"; else - cerr << "(" << Val << ")"; + std::cerr << "(" << Val << ")"; if (Op.opIsDefOnly() || Op.opIsDefAndUse()) - cerr << "*"; + std::cerr << "*"; const LiveRange *LROfVal = LRI.getLiveRangeForValue(Val); if (LROfVal ) if (LROfVal->hasSpillOffset() ) - cerr << "$"; + std::cerr << "$"; } } else if (Op.getType() == MachineOperand::MO_MachineRegister) { - cerr << "\t" << "%" << MRI.getUnifiedRegName(Op.getMachineRegNum()); + std::cerr << "\t%" << MRI.getUnifiedRegName(Op.getMachineRegNum()); } else - cerr << "\t" << Op; // use dump field + std::cerr << "\t" << Op; // use dump field } unsigned NumOfImpRefs = MInst->getNumImplicitRefs(); if (NumOfImpRefs > 0) { - cerr << "\tImplicit:"; + std::cerr << "\tImplicit:"; for (unsigned z=0; z < NumOfImpRefs; z++) - cerr << RAV(MInst->getImplicitRef(z)) << "\t"; + std::cerr << RAV(MInst->getImplicitRef(z)) << "\t"; } } // for all machine instructions - cerr << "\n"; + std::cerr << "\n"; } // for all BBs - cerr << "\n"; + std::cerr << "\n"; } @@ -1333,9 +1330,9 @@ //---------------------------------------------------------------------------- void PhyRegAlloc::printLabel(const Value *Val) { if (Val->hasName()) - cerr << Val->getName(); + std::cerr << Val->getName(); else - cerr << "Label" << Val; + std::cerr << "Label" << Val; } @@ -1379,7 +1376,7 @@ //---------------------------------------------------------------------------- void PhyRegAlloc::allocateStackSpace4SpilledLRs() { - if (DEBUG_RA) cerr << "\nSetting LR stack offsets for spills...\n"; + if (DEBUG_RA) std::cerr << "\nSetting LR stack offsets for spills...\n"; LiveRangeMapType::const_iterator HMI = LRI.getLiveRangeMap()->begin(); LiveRangeMapType::const_iterator HMIEnd = LRI.getLiveRangeMap()->end(); @@ -1391,7 +1388,7 @@ int stackOffset = MF.getInfo()->allocateSpilledValue(Type::LongTy); L->setSpillOffFromFP(stackOffset); if (DEBUG_RA) - cerr << " LR# " << L->getUserIGNode()->getIndex() + std::cerr << " LR# " << L->getUserIGNode()->getIndex() << ": stack-offset = " << stackOffset << "\n"; } } @@ -1474,7 +1471,7 @@ updateMachineCode(); if (DEBUG_RA) { - cerr << "\n**** Machine Code After Register Allocation:\n\n"; + std::cerr << "\n**** Machine Code After Register Allocation:\n\n"; MF.dump(); } } Index: llvm/lib/CodeGen/RegAlloc/RegClass.cpp diff -u llvm/lib/CodeGen/RegAlloc/RegClass.cpp:1.23 llvm/lib/CodeGen/RegAlloc/RegClass.cpp:1.24 --- llvm/lib/CodeGen/RegAlloc/RegClass.cpp:1.23 Fri Jul 25 16:06:09 2003 +++ llvm/lib/CodeGen/RegAlloc/RegClass.cpp Mon Sep 1 15:05:47 2003 @@ -6,9 +6,8 @@ #include "RegClass.h" #include "RegAllocCommon.h" -#include "llvm/CodeGen/IGNode.h" +#include "IGNode.h" #include "llvm/Target/TargetRegInfo.h" -using std::cerr; //---------------------------------------------------------------------------- // This constructor inits IG. The actual matrix is created by a call to @@ -21,7 +20,7 @@ RegClassID( _MRC_->getRegClassID() ), IG(this), IGNodeStack() { if( DEBUG_RA >= RA_DEBUG_Interference) - cerr << "Created Reg Class: " << RegClassID << "\n"; + std::cerr << "Created Reg Class: " << RegClassID << "\n"; IsColorUsedArr.resize(MRC->getNumOfAllRegs()); } @@ -34,7 +33,7 @@ void RegClass::colorAllRegs() { if(DEBUG_RA >= RA_DEBUG_Coloring) - cerr << "Coloring IG of reg class " << RegClassID << " ...\n"; + std::cerr << "Coloring IG of reg class " << RegClassID << " ...\n"; // pre-color IGNodes pushAllIGNodes(); // push all IG Nodes @@ -68,9 +67,9 @@ bool PushedAll = pushUnconstrainedIGNodes(); if( DEBUG_RA >= RA_DEBUG_Coloring) { - cerr << " Puhsed all-unconstrained IGNodes. "; - if( PushedAll ) cerr << " No constrained nodes left."; - cerr << "\n"; + std::cerr << " Puhsed all-unconstrained IGNodes. "; + if( PushedAll ) std::cerr << " No constrained nodes left."; + std::cerr << "\n"; } if( PushedAll ) // if NO constrained nodes left @@ -99,7 +98,7 @@ NeedMoreSpills = !pushUnconstrainedIGNodes(); if (DEBUG_RA >= RA_DEBUG_Coloring) - cerr << "\nConstrained IG Node found !@!" << IGNodeSpill->getIndex(); + std::cerr << "\nConstrained IG Node found !@!" << IGNodeSpill->getIndex(); } while(NeedMoreSpills); // repeat until we have pushed all @@ -140,8 +139,8 @@ IGNode->pushOnStack(); // set OnStack and dec deg of neighs if (DEBUG_RA >= RA_DEBUG_Coloring) { - cerr << " pushed un-constrained IGNode " << IGNode->getIndex() ; - cerr << " on to stack\n"; + std::cerr << " pushed un-constrained IGNode " << IGNode->getIndex() + << " on to stack\n"; } } else pushedall = false; // we didn't push all live ranges @@ -239,16 +238,16 @@ } else { if( DEBUG_RA >= RA_DEBUG_Coloring) { - cerr << " Node " << Node->getIndex(); - cerr << " already colored with color " << Node->getColor() << "\n"; + std::cerr << " Node " << Node->getIndex(); + std::cerr << " already colored with color " << Node->getColor() << "\n"; } } if( !Node->hasColor() ) { if( DEBUG_RA >= RA_DEBUG_Coloring) { - cerr << " Node " << Node->getIndex(); - cerr << " - could not find a color (needs spilling)\n"; + std::cerr << " Node " << Node->getIndex(); + std::cerr << " - could not find a color (needs spilling)\n"; } } From lattner at cs.uiuc.edu Mon Sep 1 15:10:02 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Sep 1 15:10:02 2003 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp Message-ID: <200309012009.PAA30289@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/RegAlloc: PhyRegAlloc.cpp updated: 1.106 -> 1.107 --- Log message: PhyRegAlloc.h got moved to lib/CodeGen/RegAlloc --- Diffs of the changes: Index: llvm/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp diff -u llvm/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp:1.106 llvm/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp:1.107 --- llvm/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp:1.106 Mon Sep 1 15:05:47 2003 +++ llvm/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp Mon Sep 1 15:09:04 2003 @@ -5,10 +5,10 @@ //===----------------------------------------------------------------------===// #include "llvm/CodeGen/RegisterAllocation.h" +#include "PhyRegAlloc.h" #include "RegAllocCommon.h" #include "RegClass.h" #include "IGNode.h" -#include "llvm/CodeGen/PhyRegAlloc.h" #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/MachineInstrAnnot.h" #include "llvm/CodeGen/MachineFunction.h" From lattner at cs.uiuc.edu Mon Sep 1 15:12:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Sep 1 15:12:01 2003 Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/SparcRegInfo.cpp Message-ID: <200309012011.PAA30498@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/Sparc: SparcRegInfo.cpp updated: 1.108 -> 1.109 --- Log message: LiveRangeInfo got moved into the lib/CodeGen/RegAlloc directory --- Diffs of the changes: Index: llvm/lib/Target/Sparc/SparcRegInfo.cpp diff -u llvm/lib/Target/Sparc/SparcRegInfo.cpp:1.108 llvm/lib/Target/Sparc/SparcRegInfo.cpp:1.109 --- llvm/lib/Target/Sparc/SparcRegInfo.cpp:1.108 Mon Sep 1 14:58:02 2003 +++ llvm/lib/Target/Sparc/SparcRegInfo.cpp Mon Sep 1 15:11:23 2003 @@ -13,7 +13,7 @@ #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/MachineCodeForInstruction.h" #include "llvm/CodeGen/MachineInstrAnnot.h" -#include "llvm/CodeGen/LiveRangeInfo.h" +#include "../../CodeGen/RegAlloc/LiveRangeInfo.h" // FIXME!! #include "llvm/CodeGen/LiveRange.h" #include "llvm/iTerminators.h" #include "llvm/iOther.h" From lattner at cs.uiuc.edu Mon Sep 1 15:13:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Sep 1 15:13:01 2003 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp PhyRegAlloc.h Message-ID: <200309012012.PAA30966@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/RegAlloc: LiveRangeInfo.cpp updated: 1.43 -> 1.44 PhyRegAlloc.h updated: 1.46 -> 1.47 --- Log message: LiveRangeInfo got moved into the lib/CodeGen/RegAlloc directory --- Diffs of the changes: Index: llvm/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp diff -u llvm/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp:1.43 llvm/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp:1.44 --- llvm/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp:1.43 Mon Sep 1 15:05:47 2003 +++ llvm/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp Mon Sep 1 15:12:17 2003 @@ -4,7 +4,7 @@ // //===----------------------------------------------------------------------===// -#include "llvm/CodeGen/LiveRangeInfo.h" +#include "LiveRangeInfo.h" #include "RegAllocCommon.h" #include "RegClass.h" #include "IGNode.h" Index: llvm/lib/CodeGen/RegAlloc/PhyRegAlloc.h diff -u llvm/lib/CodeGen/RegAlloc/PhyRegAlloc.h:1.46 llvm/lib/CodeGen/RegAlloc/PhyRegAlloc.h:1.47 --- llvm/lib/CodeGen/RegAlloc/PhyRegAlloc.h:1.46 Tue Aug 5 17:09:31 2003 +++ llvm/lib/CodeGen/RegAlloc/PhyRegAlloc.h Mon Sep 1 15:12:17 2003 @@ -19,7 +19,7 @@ #ifndef PHY_REG_ALLOC_H #define PHY_REG_ALLOC_H -#include "llvm/CodeGen/LiveRangeInfo.h" +#include "LiveRangeInfo.h" #include "llvm/CodeGen/MachineBasicBlock.h" #include From lattner at cs.uiuc.edu Mon Sep 1 15:15:02 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Sep 1 15:15:02 2003 Subject: [llvm-commits] CVS: llvm/lib/Analysis/LiveVar/README Message-ID: <200309012014.PAA31015@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/LiveVar: README (r1.2) removed --- Log message: This file is hopelessly out of date --- Diffs of the changes: From lattner at cs.uiuc.edu Mon Sep 1 15:18:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Sep 1 15:18:01 2003 Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/SparcRegInfo.cpp Message-ID: <200309012017.PAA00746@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/Sparc: SparcRegInfo.cpp updated: 1.109 -> 1.110 --- Log message: LiveRange.h is now in lib/CodeGen/RegAlloc --- Diffs of the changes: Index: llvm/lib/Target/Sparc/SparcRegInfo.cpp diff -u llvm/lib/Target/Sparc/SparcRegInfo.cpp:1.109 llvm/lib/Target/Sparc/SparcRegInfo.cpp:1.110 --- llvm/lib/Target/Sparc/SparcRegInfo.cpp:1.109 Mon Sep 1 15:11:23 2003 +++ llvm/lib/Target/Sparc/SparcRegInfo.cpp Mon Sep 1 15:17:13 2003 @@ -14,7 +14,7 @@ #include "llvm/CodeGen/MachineCodeForInstruction.h" #include "llvm/CodeGen/MachineInstrAnnot.h" #include "../../CodeGen/RegAlloc/LiveRangeInfo.h" // FIXME!! -#include "llvm/CodeGen/LiveRange.h" +#include "../../CodeGen/RegAlloc/LiveRange.h" // FIXME!! #include "llvm/iTerminators.h" #include "llvm/iOther.h" #include "llvm/Function.h" From lattner at cs.uiuc.edu Mon Sep 1 15:18:03 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Sep 1 15:18:03 2003 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/RegAlloc/IGNode.h Message-ID: <200309012017.PAA00739@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/RegAlloc: IGNode.h updated: 1.13 -> 1.14 --- Log message: LiveRange.h is now in lib/CodeGen/RegAlloc --- Diffs of the changes: Index: llvm/lib/CodeGen/RegAlloc/IGNode.h diff -u llvm/lib/CodeGen/RegAlloc/IGNode.h:1.13 llvm/lib/CodeGen/RegAlloc/IGNode.h:1.14 --- llvm/lib/CodeGen/RegAlloc/IGNode.h:1.13 Sat Jun 21 22:06:13 2003 +++ llvm/lib/CodeGen/RegAlloc/IGNode.h Mon Sep 1 15:17:07 2003 @@ -25,7 +25,7 @@ #ifndef IG_NODE_H #define IG_NODE_H -#include "llvm/CodeGen/LiveRange.h" +#include "LiveRange.h" class RegClass; //---------------------------------------------------------------------------- From lattner at cs.uiuc.edu Mon Sep 1 15:20:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Sep 1 15:20:01 2003 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/StackSlots.h Message-ID: <200309012019.PAA00813@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: StackSlots.h (r1.2) removed --- Log message: This file is never #included --- Diffs of the changes: From lattner at cs.uiuc.edu Mon Sep 1 15:25:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Sep 1 15:25:01 2003 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/PostOpts/PeepholeOpts.cpp Message-ID: <200309012024.PAA00897@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/PostOpts: PeepholeOpts.cpp updated: 1.9 -> 1.10 --- Log message: Simplify code a bit --- Diffs of the changes: Index: llvm/lib/CodeGen/PostOpts/PeepholeOpts.cpp diff -u llvm/lib/CodeGen/PostOpts/PeepholeOpts.cpp:1.9 llvm/lib/CodeGen/PostOpts/PeepholeOpts.cpp:1.10 --- llvm/lib/CodeGen/PostOpts/PeepholeOpts.cpp:1.9 Thu Aug 14 09:43:24 2003 +++ llvm/lib/CodeGen/PostOpts/PeepholeOpts.cpp Mon Sep 1 15:24:06 2003 @@ -16,11 +16,10 @@ //************************* Internal Functions *****************************/ -inline void +static inline void DeleteInstruction(MachineBasicBlock& mvec, MachineBasicBlock::iterator& BBI, - const TargetMachine& target) -{ + const TargetMachine& target) { // Check if this instruction is in a delay slot of its predecessor. if (BBI != mvec.begin()) { const TargetInstrInfo& mii = target.getInstrInfo(); @@ -43,12 +42,10 @@ //******************* Individual Peephole Optimizations ********************/ - inline bool RemoveUselessCopies(MachineBasicBlock& mvec, MachineBasicBlock::iterator& BBI, - const TargetMachine& target) -{ + const TargetMachine& target) { if (target.getOptInfo().IsUselessCopy(*BBI)) { DeleteInstruction(mvec, BBI, target); return true; @@ -69,37 +66,27 @@ virtual const char *getPassName() const { return "Peephole Optimization"; } }; -/* Apply a list of peephole optimizations to this machine instruction - * within its local context. They are allowed to delete MI or any - * instruction before MI, but not - */ -bool -PeepholeOpts::visit(MachineBasicBlock& mvec, - MachineBasicBlock::iterator BBI) const -{ - bool changed = false; - +// Apply a list of peephole optimizations to this machine instruction +// within its local context. They are allowed to delete MI or any +// instruction before MI, but not +// +bool PeepholeOpts::visit(MachineBasicBlock& mvec, + MachineBasicBlock::iterator BBI) const { /* Remove redundant copy instructions */ - changed |= RemoveUselessCopies(mvec, BBI, target); - if (BBI == mvec.end()) // nothing more to do! - return changed; - - return changed; + return RemoveUselessCopies(mvec, BBI, target); } -bool -PeepholeOpts::runOnBasicBlock(BasicBlock &BB) -{ +bool PeepholeOpts::runOnBasicBlock(BasicBlock &BB) { // Get the machine instructions for this BB // FIXME: MachineBasicBlock::get() is deprecated, hence inlining the function const Function *F = BB.getParent(); MachineFunction &MF = MachineFunction::get(F); MachineBasicBlock *MBB = NULL; - for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I) { + for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I) if (I->getBasicBlock() == &BB) MBB = I; - } + assert(MBB && "MachineBasicBlock object not found for specified block!"); MachineBasicBlock &mvec = *MBB; @@ -108,8 +95,7 @@ // Insertions or deletions *before* MI are not safe. // for (MachineBasicBlock::reverse_iterator RI=mvec.rbegin(), - RE=mvec.rend(); RI != RE; ) - { + RE=mvec.rend(); RI != RE; ) { MachineBasicBlock::iterator BBI = RI.base()-1; // save before incr ++RI; // pre-increment to delete MI or after it visit(mvec, BBI); @@ -123,8 +109,6 @@ // createPeepholeOptsPass - Public entrypoint for peephole optimization // and this file as a whole... // -FunctionPass* -createPeepholeOptsPass(TargetMachine &T) -{ +FunctionPass* createPeepholeOptsPass(TargetMachine &T) { return new PeepholeOpts(T); } From lattner at cs.uiuc.edu Mon Sep 1 15:27:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Sep 1 15:27:01 2003 Subject: [llvm-commits] CVS: llvm/tools/lli/Makefile Message-ID: <200309012026.PAA02335@apoc.cs.uiuc.edu> Changes in directory llvm/tools/lli: Makefile updated: 1.37 -> 1.38 --- Log message: Sparc peephole optimizer moved out of post-opts library into Sparc target library --- Diffs of the changes: Index: llvm/tools/lli/Makefile diff -u llvm/tools/lli/Makefile:1.37 llvm/tools/lli/Makefile:1.38 --- llvm/tools/lli/Makefile:1.37 Thu Aug 14 23:56:09 2003 +++ llvm/tools/lli/Makefile Mon Sep 1 15:26:14 2003 @@ -36,7 +36,7 @@ JITLIBS += sparc ARCHLIBS += sched livevar instrument.a profpaths \ bcwriter transforms.a ipo.a ipa.a datastructure.a regalloc \ - select postopts.a preopts + select preopts endif USEDLIBS = lli-interpreter $(JITLIBS) $(ARCHLIBS) scalaropts analysis.a \ From lattner at cs.uiuc.edu Mon Sep 1 15:27:03 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Sep 1 15:27:03 2003 Subject: [llvm-commits] CVS: llvm/tools/llc/Makefile Message-ID: <200309012026.PAA02326@apoc.cs.uiuc.edu> Changes in directory llvm/tools/llc: Makefile updated: 1.40 -> 1.41 --- Log message: Sparc peephole optimizer moved out of post-opts library into Sparc target library --- Diffs of the changes: Index: llvm/tools/llc/Makefile diff -u llvm/tools/llc/Makefile:1.40 llvm/tools/llc/Makefile:1.41 --- llvm/tools/llc/Makefile:1.40 Thu Aug 14 23:56:01 2003 +++ llvm/tools/llc/Makefile Mon Sep 1 15:26:11 2003 @@ -8,7 +8,6 @@ select \ codegen \ preopts \ - postopts.a \ target.a \ livevar \ transforms.a \ From lattner at cs.uiuc.edu Mon Sep 1 15:28:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Sep 1 15:28:01 2003 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/PostOpts/Makefile Message-ID: <200309012027.PAA02357@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/PostOpts: Makefile (r1.1) removed --- Log message: Remove makefile for dead library --- Diffs of the changes: From lattner at cs.uiuc.edu Mon Sep 1 15:30:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Sep 1 15:30:01 2003 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/PreOpts/Makefile Message-ID: <200309012029.PAA02830@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/PreOpts: Makefile (r1.1) removed --- Log message: Remove dead library makefile --- Diffs of the changes: From lattner at cs.uiuc.edu Mon Sep 1 15:31:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Sep 1 15:31:01 2003 Subject: [llvm-commits] CVS: llvm/tools/lli/Makefile Message-ID: <200309012030.PAA02939@apoc.cs.uiuc.edu> Changes in directory llvm/tools/lli: Makefile updated: 1.38 -> 1.39 --- Log message: Preselection is now integrated into the Sparc target library --- Diffs of the changes: Index: llvm/tools/lli/Makefile diff -u llvm/tools/lli/Makefile:1.38 llvm/tools/lli/Makefile:1.39 --- llvm/tools/lli/Makefile:1.38 Mon Sep 1 15:26:14 2003 +++ llvm/tools/lli/Makefile Mon Sep 1 15:30:17 2003 @@ -36,7 +36,7 @@ JITLIBS += sparc ARCHLIBS += sched livevar instrument.a profpaths \ bcwriter transforms.a ipo.a ipa.a datastructure.a regalloc \ - select preopts + select endif USEDLIBS = lli-interpreter $(JITLIBS) $(ARCHLIBS) scalaropts analysis.a \ From lattner at cs.uiuc.edu Mon Sep 1 15:31:03 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Sep 1 15:31:03 2003 Subject: [llvm-commits] CVS: llvm/tools/llc/Makefile Message-ID: <200309012030.PAA02932@apoc.cs.uiuc.edu> Changes in directory llvm/tools/llc: Makefile updated: 1.41 -> 1.42 --- Log message: Preselection is now integrated into the Sparc target library --- Diffs of the changes: Index: llvm/tools/llc/Makefile diff -u llvm/tools/llc/Makefile:1.41 llvm/tools/llc/Makefile:1.42 --- llvm/tools/llc/Makefile:1.41 Mon Sep 1 15:26:11 2003 +++ llvm/tools/llc/Makefile Mon Sep 1 15:30:16 2003 @@ -7,7 +7,6 @@ sched \ select \ codegen \ - preopts \ target.a \ livevar \ transforms.a \ From lattner at cs.uiuc.edu Mon Sep 1 15:34:00 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Sep 1 15:34:00 2003 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/PreSelection.h PeepholeOpts.h Message-ID: <200309012033.PAA05083@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: PreSelection.h (r1.1) removed PeepholeOpts.h (r1.2) removed --- Log message: Remove header files that were privatized --- Diffs of the changes: From lattner at cs.uiuc.edu Mon Sep 1 15:34:03 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Sep 1 15:34:03 2003 Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/PeepholeOpts.cpp PreSelection.cpp Sparc.cpp SparcInternals.h Message-ID: <200309012033.PAA04481@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/Sparc: PeepholeOpts.cpp updated: 1.10 -> 1.11 PreSelection.cpp updated: 1.15 -> 1.16 Sparc.cpp updated: 1.78 -> 1.79 SparcInternals.h updated: 1.98 -> 1.99 --- Log message: Move private interfaces into private .h file --- Diffs of the changes: Index: llvm/lib/Target/Sparc/PeepholeOpts.cpp diff -u llvm/lib/Target/Sparc/PeepholeOpts.cpp:1.10 llvm/lib/Target/Sparc/PeepholeOpts.cpp:1.11 --- llvm/lib/Target/Sparc/PeepholeOpts.cpp:1.10 Mon Sep 1 15:24:06 2003 +++ llvm/lib/Target/Sparc/PeepholeOpts.cpp Mon Sep 1 15:33:07 2003 @@ -5,7 +5,7 @@ // //===----------------------------------------------------------------------===// -#include "llvm/CodeGen/PeepholeOpts.h" +#include "SparcInternals.h" #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineInstr.h" #include "llvm/Target/TargetMachine.h" Index: llvm/lib/Target/Sparc/PreSelection.cpp diff -u llvm/lib/Target/Sparc/PreSelection.cpp:1.15 llvm/lib/Target/Sparc/PreSelection.cpp:1.16 --- llvm/lib/Target/Sparc/PreSelection.cpp:1.15 Wed Aug 6 13:42:49 2003 +++ llvm/lib/Target/Sparc/PreSelection.cpp Mon Sep 1 15:33:07 2003 @@ -8,7 +8,7 @@ // //===----------------------------------------------------------------------===// -#include "llvm/CodeGen/PreSelection.h" +#include "SparcInternals.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Transforms/Scalar.h" Index: llvm/lib/Target/Sparc/Sparc.cpp diff -u llvm/lib/Target/Sparc/Sparc.cpp:1.78 llvm/lib/Target/Sparc/Sparc.cpp:1.79 --- llvm/lib/Target/Sparc/Sparc.cpp:1.78 Sun Aug 24 14:49:47 2003 +++ llvm/lib/Target/Sparc/Sparc.cpp Mon Sep 1 15:33:07 2003 @@ -13,8 +13,6 @@ #include "llvm/Transforms/Scalar.h" #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineFunctionInfo.h" -#include "llvm/CodeGen/PreSelection.h" -#include "llvm/CodeGen/PeepholeOpts.h" #include "llvm/CodeGen/InstrSelection.h" #include "llvm/CodeGen/InstrScheduling.h" #include "llvm/CodeGen/RegisterAllocation.h" Index: llvm/lib/Target/Sparc/SparcInternals.h diff -u llvm/lib/Target/Sparc/SparcInternals.h:1.98 llvm/lib/Target/Sparc/SparcInternals.h:1.99 --- llvm/lib/Target/Sparc/SparcInternals.h:1.98 Thu Aug 14 01:04:29 2003 +++ llvm/lib/Target/Sparc/SparcInternals.h Mon Sep 1 15:33:07 2003 @@ -654,6 +654,13 @@ /// empty slots at the top of each function stack Pass *createStackSlotsPass(const TargetMachine &TM); +// Interface to pre-selection pass that specializes LLVM code for a target +// machine. +Pass *createPreSelectionPass(TargetMachine &Target); + +// External interface to peephole optimization pass operating on machine code. +FunctionPass *createPeepholeOptsPass(TargetMachine &Target); + //--------------------------------------------------------------------------- // class UltraSparc From lattner at cs.uiuc.edu Mon Sep 1 15:35:00 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Sep 1 15:35:00 2003 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/Makefile Message-ID: <200309012034.PAA05332@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: Makefile updated: 1.13 -> 1.14 --- Log message: Don't build dead directories --- Diffs of the changes: Index: llvm/lib/CodeGen/Makefile diff -u llvm/lib/CodeGen/Makefile:1.13 llvm/lib/CodeGen/Makefile:1.14 --- llvm/lib/CodeGen/Makefile:1.13 Thu Aug 14 23:55:20 2003 +++ llvm/lib/CodeGen/Makefile Mon Sep 1 15:34:15 2003 @@ -1,5 +1,5 @@ LEVEL = ../.. -PARALLEL_DIRS = PreOpts InstrSelection InstrSched RegAlloc PostOpts SelectionDAG +PARALLEL_DIRS = InstrSelection InstrSched RegAlloc SelectionDAG LIBRARYNAME = codegen include $(LEVEL)/Makefile.common From lattner at cs.uiuc.edu Mon Sep 1 15:39:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Sep 1 15:39:01 2003 Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/PeepholeOpts.cpp Message-ID: <200309012038.PAA06293@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/Sparc: PeepholeOpts.cpp updated: 1.11 -> 1.12 --- Log message: Inline simple comparison which is sparc specific anyway --- Diffs of the changes: Index: llvm/lib/Target/Sparc/PeepholeOpts.cpp diff -u llvm/lib/Target/Sparc/PeepholeOpts.cpp:1.11 llvm/lib/Target/Sparc/PeepholeOpts.cpp:1.12 --- llvm/lib/Target/Sparc/PeepholeOpts.cpp:1.11 Mon Sep 1 15:33:07 2003 +++ llvm/lib/Target/Sparc/PeepholeOpts.cpp Mon Sep 1 15:38:03 2003 @@ -10,7 +10,6 @@ #include "llvm/CodeGen/MachineInstr.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetInstrInfo.h" -#include "llvm/Target/TargetOptInfo.h" #include "llvm/BasicBlock.h" #include "llvm/Pass.h" @@ -42,11 +41,55 @@ //******************* Individual Peephole Optimizations ********************/ +//---------------------------------------------------------------------------- +// Function: IsUselessCopy +// Decide whether a machine instruction is a redundant copy: +// -- ADD with g0 and result and operand are identical, or +// -- OR with g0 and result and operand are identical, or +// -- FMOVS or FMOVD and result and operand are identical. +// Other cases are possible but very rare that they would be useless copies, +// so it's not worth analyzing them. +//---------------------------------------------------------------------------- + +static bool IsUselessCopy(const TargetMachine &target, const MachineInstr* MI) { + if (MI->getOpCode() == V9::FMOVS || MI->getOpCode() == V9::FMOVD) { + return (/* both operands are allocated to the same register */ + MI->getOperand(0).getAllocatedRegNum() == + MI->getOperand(1).getAllocatedRegNum()); + } else if (MI->getOpCode() == V9::ADDr || MI->getOpCode() == V9::ORr) { + unsigned srcWithDestReg; + + for (srcWithDestReg = 0; srcWithDestReg < 2; ++srcWithDestReg) + if (MI->getOperand(srcWithDestReg).hasAllocatedReg() && + MI->getOperand(srcWithDestReg).getAllocatedRegNum() + == MI->getOperand(2).getAllocatedRegNum()) + break; + + if (srcWithDestReg == 2) + return false; + else { + /* else source and dest are allocated to the same register */ + unsigned otherOp = 1 - srcWithDestReg; + return (/* either operand otherOp is register %g0 */ + (MI->getOperand(otherOp).hasAllocatedReg() && + MI->getOperand(otherOp).getAllocatedRegNum() == + target.getRegInfo().getZeroRegNum()) || + + /* or operand otherOp == 0 */ + (MI->getOperand(otherOp).getType() + == MachineOperand::MO_SignExtendedImmed && + MI->getOperand(otherOp).getImmedValue() == 0)); + } + } + else + return false; +} + inline bool RemoveUselessCopies(MachineBasicBlock& mvec, MachineBasicBlock::iterator& BBI, const TargetMachine& target) { - if (target.getOptInfo().IsUselessCopy(*BBI)) { + if (IsUselessCopy(target, *BBI)) { DeleteInstruction(mvec, BBI, target); return true; } From lattner at cs.uiuc.edu Mon Sep 1 15:41:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Sep 1 15:41:01 2003 Subject: [llvm-commits] CVS: llvm/include/llvm/Target/TargetMachine.h Message-ID: <200309012040.PAA09399@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Target: TargetMachine.h updated: 1.33 -> 1.34 --- Log message: No longer require an OptInfo --- Diffs of the changes: Index: llvm/include/llvm/Target/TargetMachine.h diff -u llvm/include/llvm/Target/TargetMachine.h:1.33 llvm/include/llvm/Target/TargetMachine.h:1.34 --- llvm/include/llvm/Target/TargetMachine.h:1.33 Fri Aug 15 00:21:30 2003 +++ llvm/include/llvm/Target/TargetMachine.h Mon Sep 1 15:40:43 2003 @@ -15,7 +15,6 @@ class TargetRegInfo; class TargetFrameInfo; class TargetCacheInfo; -class TargetOptInfo; class MachineCodeEmitter; class MRegisterInfo; class FunctionPassManager; @@ -62,7 +61,6 @@ virtual const TargetRegInfo& getRegInfo() const = 0; virtual const TargetFrameInfo& getFrameInfo() const = 0; virtual const TargetCacheInfo& getCacheInfo() const = 0; - virtual const TargetOptInfo& getOptInfo() const = 0; const TargetData &getTargetData() const { return DataLayout; } /// getRegisterInfo - If register information is available, return it. If From lattner at cs.uiuc.edu Mon Sep 1 15:42:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Sep 1 15:42:01 2003 Subject: [llvm-commits] CVS: llvm/include/llvm/Target/TargetOptInfo.h Message-ID: <200309012041.PAA10012@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Target: TargetOptInfo.h (r1.3) removed --- Log message: Remove dead file --- Diffs of the changes: From lattner at cs.uiuc.edu Mon Sep 1 15:42:03 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Sep 1 15:42:03 2003 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86TargetMachine.h Message-ID: <200309012041.PAA09430@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86TargetMachine.h updated: 1.12 -> 1.13 --- Log message: OptInfo is no longer required --- Diffs of the changes: Index: llvm/lib/Target/X86/X86TargetMachine.h diff -u llvm/lib/Target/X86/X86TargetMachine.h:1.12 llvm/lib/Target/X86/X86TargetMachine.h:1.13 --- llvm/lib/Target/X86/X86TargetMachine.h:1.12 Sun Aug 24 14:49:48 2003 +++ llvm/lib/Target/X86/X86TargetMachine.h Mon Sep 1 15:41:07 2003 @@ -27,7 +27,6 @@ virtual const TargetSchedInfo &getSchedInfo() const { abort(); } virtual const TargetRegInfo &getRegInfo() const { abort(); } virtual const TargetCacheInfo &getCacheInfo() const { abort(); } - virtual const TargetOptInfo &getOptInfo() const { abort(); } /// addPassesToJITCompile - Add passes to the specified pass manager to /// implement a fast dynamic compiler for this target. Return true if this is From lattner at cs.uiuc.edu Mon Sep 1 15:42:04 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Sep 1 15:42:04 2003 Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/Sparc.cpp SparcInternals.h SparcOptInfo.cpp Message-ID: <200309012041.PAA09421@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/Sparc: Sparc.cpp updated: 1.79 -> 1.80 SparcInternals.h updated: 1.99 -> 1.100 SparcOptInfo.cpp updated: 1.9 -> 1.10 --- Log message: No longer provide an optinfo, noone uses it --- Diffs of the changes: Index: llvm/lib/Target/Sparc/Sparc.cpp diff -u llvm/lib/Target/Sparc/Sparc.cpp:1.79 llvm/lib/Target/Sparc/Sparc.cpp:1.80 --- llvm/lib/Target/Sparc/Sparc.cpp:1.79 Mon Sep 1 15:33:07 2003 +++ llvm/lib/Target/Sparc/Sparc.cpp Mon Sep 1 15:40:59 2003 @@ -139,8 +139,7 @@ schedInfo(*this), regInfo(*this), frameInfo(*this), - cacheInfo(*this), - optInfo(*this) { + cacheInfo(*this) { } Index: llvm/lib/Target/Sparc/SparcInternals.h diff -u llvm/lib/Target/Sparc/SparcInternals.h:1.99 llvm/lib/Target/Sparc/SparcInternals.h:1.100 --- llvm/lib/Target/Sparc/SparcInternals.h:1.99 Mon Sep 1 15:33:07 2003 +++ llvm/lib/Target/Sparc/SparcInternals.h Mon Sep 1 15:40:59 2003 @@ -14,7 +14,6 @@ #include "llvm/Target/TargetFrameInfo.h" #include "llvm/Target/TargetCacheInfo.h" #include "llvm/Target/TargetRegInfo.h" -#include "llvm/Target/TargetOptInfo.h" #include "llvm/Type.h" #include "SparcRegClassInfo.h" #include "Config/sys/types.h" @@ -631,19 +630,6 @@ }; -//--------------------------------------------------------------------------- -// class UltraSparcOptInfo -// -// Purpose: -// Interface to machine-level optimization routines for the UltraSPARC. -//--------------------------------------------------------------------------- - -struct UltraSparcOptInfo: public TargetOptInfo { - UltraSparcOptInfo(const TargetMachine &T) : TargetOptInfo(T) {} - - virtual bool IsUselessCopy (const MachineInstr* MI) const; -}; - /// createAddRegNumToValuesPass - this pass adds unsigned register numbers to /// instructions, since that's not done by the Sparc InstSelector, but that's /// how the target-independent register allocator in the JIT likes to see @@ -678,7 +664,6 @@ UltraSparcRegInfo regInfo; UltraSparcFrameInfo frameInfo; UltraSparcCacheInfo cacheInfo; - UltraSparcOptInfo optInfo; public: UltraSparc(); @@ -687,7 +672,6 @@ virtual const TargetRegInfo &getRegInfo() const { return regInfo; } virtual const TargetFrameInfo &getFrameInfo() const { return frameInfo; } virtual const TargetCacheInfo &getCacheInfo() const { return cacheInfo; } - virtual const TargetOptInfo &getOptInfo() const { return optInfo; } virtual bool addPassesToEmitAssembly(PassManager &PM, std::ostream &Out); virtual bool addPassesToJITCompile(FunctionPassManager &PM); Index: llvm/lib/Target/Sparc/SparcOptInfo.cpp diff -u llvm/lib/Target/Sparc/SparcOptInfo.cpp:1.9 llvm/lib/Target/Sparc/SparcOptInfo.cpp:1.10 --- llvm/lib/Target/Sparc/SparcOptInfo.cpp:1.9 Mon Jun 30 16:58:49 2003 +++ llvm/lib/Target/Sparc/SparcOptInfo.cpp Mon Sep 1 15:40:59 2003 @@ -1,55 +0,0 @@ -//===-- SparcOptInfo.cpp --------------------------------------------------===// -// -// FIXME: Describe -// -//===----------------------------------------------------------------------===// - -#include "SparcInternals.h" -#include "llvm/Target/TargetRegInfo.h" -#include "llvm/CodeGen/MachineInstr.h" -#include "Config/stdlib.h" - -//---------------------------------------------------------------------------- -// Function: IsUselessCopy -// Decide whether a machine instruction is a redundant copy: -// -- ADD with g0 and result and operand are identical, or -// -- OR with g0 and result and operand are identical, or -// -- FMOVS or FMOVD and result and operand are identical. -// Other cases are possible but very rare that they would be useless copies, -// so it's not worth analyzing them. -//---------------------------------------------------------------------------- - -bool -UltraSparcOptInfo::IsUselessCopy(const MachineInstr* MI) const { - if (MI->getOpCode() == V9::FMOVS || MI->getOpCode() == V9::FMOVD) { - return (/* both operands are allocated to the same register */ - MI->getOperand(0).getAllocatedRegNum() == - MI->getOperand(1).getAllocatedRegNum()); - } else if (MI->getOpCode() == V9::ADDr || MI->getOpCode() == V9::ORr) { - unsigned srcWithDestReg; - - for (srcWithDestReg = 0; srcWithDestReg < 2; ++srcWithDestReg) - if (MI->getOperand(srcWithDestReg).hasAllocatedReg() && - MI->getOperand(srcWithDestReg).getAllocatedRegNum() - == MI->getOperand(2).getAllocatedRegNum()) - break; - - if (srcWithDestReg == 2) - return false; - else { - /* else source and dest are allocated to the same register */ - unsigned otherOp = 1 - srcWithDestReg; - return (/* either operand otherOp is register %g0 */ - (MI->getOperand(otherOp).hasAllocatedReg() && - MI->getOperand(otherOp).getAllocatedRegNum() == - target.getRegInfo().getZeroRegNum()) || - - /* or operand otherOp == 0 */ - (MI->getOperand(otherOp).getType() - == MachineOperand::MO_SignExtendedImmed && - MI->getOperand(otherOp).getImmedValue() == 0)); - } - } - else - return false; -} From lattner at cs.uiuc.edu Mon Sep 1 15:43:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Sep 1 15:43:01 2003 Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/SparcOptInfo.cpp Message-ID: <200309012042.PAA12616@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/Sparc: SparcOptInfo.cpp (r1.10) removed --- Log message: Whoops, cvs rm this file, don't just empty it out :) --- Diffs of the changes: From lattner at cs.uiuc.edu Mon Sep 1 15:45:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Sep 1 15:45:01 2003 Subject: [llvm-commits] CVS: llvm/include/llvm/Transforms/Scalar.h Message-ID: <200309012044.PAA14971@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Transforms: Scalar.h updated: 1.21 -> 1.22 --- Log message: Add RPR prototype here --- Diffs of the changes: Index: llvm/include/llvm/Transforms/Scalar.h diff -u llvm/include/llvm/Transforms/Scalar.h:1.21 llvm/include/llvm/Transforms/Scalar.h:1.22 --- llvm/include/llvm/Transforms/Scalar.h:1.21 Sun Aug 31 22:14:00 2003 +++ llvm/include/llvm/Transforms/Scalar.h Mon Sep 1 15:44:42 2003 @@ -16,6 +16,14 @@ //===----------------------------------------------------------------------===// // +// RaisePointerReferences - Try to eliminate as many pointer arithmetic +// expressions as possible, by converting expressions to use getelementptr and +// friends. +// +Pass *createRaisePointerReferencesPass(); + +//===----------------------------------------------------------------------===// +// // Constant Propagation Pass - A worklist driven constant propagation pass // Pass *createConstantPropagationPass(); From lattner at cs.uiuc.edu Mon Sep 1 15:46:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Sep 1 15:46:01 2003 Subject: [llvm-commits] CVS: llvm/tools/gccas/gccas.cpp Message-ID: <200309012045.PAA17184@apoc.cs.uiuc.edu> Changes in directory llvm/tools/gccas: gccas.cpp updated: 1.70 -> 1.71 --- Log message: #include is unnecessary --- Diffs of the changes: Index: llvm/tools/gccas/gccas.cpp diff -u llvm/tools/gccas/gccas.cpp:1.70 llvm/tools/gccas/gccas.cpp:1.71 --- llvm/tools/gccas/gccas.cpp:1.70 Sun Aug 31 16:47:24 2003 +++ llvm/tools/gccas/gccas.cpp Mon Sep 1 15:45:46 2003 @@ -14,7 +14,6 @@ #include "llvm/Assembly/Parser.h" #include "llvm/Bytecode/WriteBytecodePass.h" #include "llvm/Target/TargetData.h" -#include "llvm/Transforms/RaisePointerReferences.h" #include "llvm/Transforms/IPO.h" #include "llvm/Transforms/Scalar.h" #include "Support/CommandLine.h" From lattner at cs.uiuc.edu Mon Sep 1 15:46:03 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Sep 1 15:46:03 2003 Subject: [llvm-commits] CVS: llvm/lib/Transforms/LevelRaise.cpp Message-ID: <200309012045.PAA16973@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms: LevelRaise.cpp updated: 1.84 -> 1.85 --- Log message: Prototype for creator function got moved --- Diffs of the changes: Index: llvm/lib/Transforms/LevelRaise.cpp diff -u llvm/lib/Transforms/LevelRaise.cpp:1.84 llvm/lib/Transforms/LevelRaise.cpp:1.85 --- llvm/lib/Transforms/LevelRaise.cpp:1.84 Fri Aug 1 17:15:00 2003 +++ llvm/lib/Transforms/LevelRaise.cpp Mon Sep 1 15:45:33 2003 @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -#include "llvm/Transforms/RaisePointerReferences.h" +#include "llvm/Transforms/Scalar.h" #include "llvm/Transforms/Utils/Local.h" #include "TransformInternals.h" #include "llvm/iOther.h" From lattner at cs.uiuc.edu Mon Sep 1 15:47:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Sep 1 15:47:01 2003 Subject: [llvm-commits] CVS: llvm/include/llvm/Transforms/RaisePointerReferences.h Message-ID: <200309012046.PAA17714@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Transforms: RaisePointerReferences.h (r1.5) removed --- Log message: Dead header file --- Diffs of the changes: From gaeke at cs.uiuc.edu Tue Sep 2 01:46:01 2003 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Tue Sep 2 01:46:01 2003 Subject: [llvm-commits] CVS: llvm/lib/VMCore/iMemory.cpp Message-ID: <200309020645.BAA15571@morpheus.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: iMemory.cpp updated: 1.29 -> 1.30 --- Log message: Remove assertion which is never reached. --- Diffs of the changes: Index: llvm/lib/VMCore/iMemory.cpp diff -u llvm/lib/VMCore/iMemory.cpp:1.29 llvm/lib/VMCore/iMemory.cpp:1.30 --- llvm/lib/VMCore/iMemory.cpp:1.29 Tue Jan 14 16:19:44 2003 +++ llvm/lib/VMCore/iMemory.cpp Tue Sep 2 01:45:34 2003 @@ -94,7 +94,6 @@ : Instruction(PointerType::get(checkType(getIndexedType(Ptr->getType(), Idx, true))), GetElementPtr, Name, InBe) { - assert(getIndexedType(Ptr->getType(), Idx, true) && "gep operands invalid!"); Operands.reserve(1+Idx.size()); Operands.push_back(Use(Ptr, this)); From gaeke at cs.uiuc.edu Tue Sep 2 01:48:01 2003 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Tue Sep 2 01:48:01 2003 Subject: [llvm-commits] CVS: reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp Message-ID: <200309020647.BAA15605@morpheus.cs.uiuc.edu> Changes in directory reopt/lib/LightWtProfiling: RuntimeOptimizations.cpp updated: 1.5 -> 1.6 --- Log message: I might as well check in the version of the file I'm actually using, just to be consistent. --- Diffs of the changes: Index: reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp diff -u reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp:1.5 reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp:1.6 --- reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp:1.5 Thu Aug 21 11:50:15 2003 +++ reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp Tue Sep 2 01:46:39 2003 @@ -17,7 +17,7 @@ #include // From TraceToFunction.cpp -// extern Function *runTraceToFunction (Trace &T); +extern Function *runTraceToFunction (Trace &T); // From Initialization.cpp extern void initModules (); @@ -59,6 +59,6 @@ T.print (o); // Try to turn it into a function - // Function *TF = runTraceToFunction (T); - // DEBUG(std::cerr << "Function created from trace: \n" << *TF); + Function *TF = runTraceToFunction (T); + DEBUG(std::cerr << "Function created from trace: \n" << *TF); } From gaeke at cs.uiuc.edu Tue Sep 2 01:48:04 2003 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Tue Sep 2 01:48:04 2003 Subject: [llvm-commits] CVS: reopt/lib/LightWtProfiling/TraceToFunction.cpp Message-ID: <200309020647.BAA15599@morpheus.cs.uiuc.edu> Changes in directory reopt/lib/LightWtProfiling: TraceToFunction.cpp updated: 1.2 -> 1.3 --- Log message: Try extra hard not to get sucked into dereferencing a null pointer that operator[] might have put there. Sigh. --- Diffs of the changes: Index: reopt/lib/LightWtProfiling/TraceToFunction.cpp diff -u reopt/lib/LightWtProfiling/TraceToFunction.cpp:1.2 reopt/lib/LightWtProfiling/TraceToFunction.cpp:1.3 --- reopt/lib/LightWtProfiling/TraceToFunction.cpp:1.2 Fri Aug 29 00:13:12 2003 +++ reopt/lib/LightWtProfiling/TraceToFunction.cpp Tue Sep 2 01:47:06 2003 @@ -452,7 +452,7 @@ // function, and I will still reference the version from // outside the function. Replace any reference to an operand // which has had a clone made with a reference to its clone. - else if (O2CMap.find (V) != O2CMap.end ()) { + else if (O2CMap.find (V) != O2CMap.end () && O2CMap[V]) { DEBUG(std::cerr << *V << " in instruction " << I << " is value " << O2CMap[V] << " in new function\n"); assert (V->getType () == O2CMap[V]->getType () From brukman at cs.uiuc.edu Tue Sep 2 08:42:01 2003 From: brukman at cs.uiuc.edu (Michael Brukman) Date: Tue Sep 2 08:42:01 2003 Subject: [llvm-commits] CVS: llvm/www/testresults/index.html Message-ID: <200309021341.IAA14071@tank.cs.uiuc.edu> Changes in directory llvm/www/testresults: index.html updated: 1.2 -> 1.3 --- Log message: Separated results from trinity vs. tank and debug vs. optimized builds. --- Diffs of the changes: Index: llvm/www/testresults/index.html diff -u llvm/www/testresults/index.html:1.2 llvm/www/testresults/index.html:1.3 --- llvm/www/testresults/index.html:1.2 Thu Aug 14 11:23:02 2003 +++ llvm/www/testresults/index.html Tue Sep 2 08:41:24 2003 @@ -15,9 +15,13 @@
  • Linux on X86 (Dual P4 Xeon @ 3.06GHz) -
  • Solaris on Sparc V9 (UltraSparc IIe @ 502 MHz) +
  • Solaris on Sparc V9 (UltraSparc IIe @ 502 MHz): +debug, +optimized.
  • - +
  • Solaris on Sparc V9 (UltraSPARC-IIi at 440MHz): + +optimized.

  • From lattner at cs.uiuc.edu Tue Sep 2 11:29:04 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 2 11:29:04 2003 Subject: [llvm-commits] CVS: llvm/include/llvm/Type.h Message-ID: <200309021628.LAA21729@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: Type.h updated: 1.25 -> 1.26 --- Log message: The description is no longer stored directly in the type. --- Diffs of the changes: Index: llvm/include/llvm/Type.h diff -u llvm/include/llvm/Type.h:1.25 llvm/include/llvm/Type.h:1.26 --- llvm/include/llvm/Type.h:1.25 Thu Aug 21 17:08:59 2003 +++ llvm/include/llvm/Type.h Tue Sep 2 11:28:03 2003 @@ -72,7 +72,6 @@ private: PrimitiveID ID; // The current base type of this type... unsigned UID; // The unique ID number for this class - std::string Desc; // The printed name of the string... bool Abstract; // True if type contains an OpaqueType bool Recursive; // True if the type is recursive @@ -81,10 +80,6 @@ Type(const std::string &Name, PrimitiveID id); virtual ~Type() {} - /// When types are refined, they update their description to be more concrete. - /// - inline void setDescription(const std::string &D) { Desc = D; } - /// setName - Associate the name with this type in the symbol table, but don't /// set the local name to be equal specified name. /// @@ -119,7 +114,7 @@ inline unsigned getUniqueID() const { return UID; } /// getDescription - Return the string representation of the type... - inline const std::string &getDescription() const { return Desc; } + const std::string &getDescription() const; /// isSigned - Return whether an integral numeric type is signed. This is /// true for SByteTy, ShortTy, IntTy, LongTy. Note that this is not true for From lattner at cs.uiuc.edu Tue Sep 2 11:36:02 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 2 11:36:02 2003 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Type.cpp Message-ID: <200309021635.LAA22110@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Type.cpp updated: 1.50 -> 1.51 --- Log message: Change the code to no longer compute the "type description" immediately when the type is analyzed. Instead, only compute it when requested (with getDescription), and cached for reuse later. This dramatically speeds up LLVM in general because these descriptions almost _never_ need to be constructed. The only time they are used is when a type is <<'d. Printing of modules by themselves uses other code to print symbolic types when possible, so these descriptions are really only used for debugging. Also, this fixes the particularly bad case when lots of types get resolved to each other, such as during linking of large programs. In these cases, the type descriptions would be repeatedly recomputed and discarded even though: A. noone reads the description before it gets resolved, and B. many many resolutions happen at intermediate steps, causing a HUGE waste of time. Overall, this makes the getTypeDesc function much more light-weight, and fixes bug: Assembler/2002-07-08-HugePerformanceProblem.llx, which went from taking 1048.770u/19.150s (which is 17.5 MINUTES, on apoc), to taking 0.020u/0.000s, which is a nice little speedup. :) --- Diffs of the changes: Index: llvm/lib/VMCore/Type.cpp diff -u llvm/lib/VMCore/Type.cpp:1.50 llvm/lib/VMCore/Type.cpp:1.51 --- llvm/lib/VMCore/Type.cpp:1.50 Thu Aug 21 17:12:47 2003 +++ llvm/lib/VMCore/Type.cpp Tue Sep 2 11:35:17 2003 @@ -25,6 +25,13 @@ static unsigned CurUID = 0; static std::vector UIDMappings; +// Concrete/Abstract TypeDescriptions - We lazily calculate type descriptions +// for types as they are needed. Because resolution of types must invalidate +// all of the abstract type descriptions, we keep them in a seperate map to make +// this easy. +static std::map ConcreteTypeDescriptions; +static std::map AbstractTypeDescriptions; + void PATypeHolder::dump() const { std::cerr << "PATypeHolder(" << (void*)this << ")\n"; } @@ -32,7 +39,7 @@ Type::Type(const std::string &name, PrimitiveID id) : Value(Type::TypeTy, Value::TypeVal) { - setDescription(name); + ConcreteTypeDescriptions[this] = name; ID = id; Abstract = Recursive = false; UID = CurUID++; // Assign types UID's as they are created @@ -114,6 +121,125 @@ } +// getTypeDescription - This is a recursive function that walks a type hierarchy +// calculating the description for a type. +// +static std::string getTypeDescription(const Type *Ty, + std::vector &TypeStack) { + if (isa(Ty)) { // Base case for the recursion + std::map::iterator I = + AbstractTypeDescriptions.lower_bound(Ty); + if (I != AbstractTypeDescriptions.end() && I->first == Ty) + return I->second; + std::string Desc = "opaque"+utostr(Ty->getUniqueID()); + AbstractTypeDescriptions.insert(std::make_pair(Ty, Desc)); + return Desc; + } + + if (!Ty->isAbstract() && !Ty->isRecursive()) { // Base case for the recursion + std::map::iterator I = + ConcreteTypeDescriptions.find(Ty); + if (I != ConcreteTypeDescriptions.end()) return I->second; + } + + // Check to see if the Type is already on the stack... + unsigned Slot = 0, CurSize = TypeStack.size(); + while (Slot < CurSize && TypeStack[Slot] != Ty) ++Slot; // Scan for type + + // This is another base case for the recursion. In this case, we know + // that we have looped back to a type that we have previously visited. + // Generate the appropriate upreference to handle this. + // + if (Slot < CurSize) + return "\\" + utostr(CurSize-Slot); // Here's the upreference + + // Recursive case: derived types... + std::string Result; + TypeStack.push_back(Ty); // Add us to the stack.. + + switch (Ty->getPrimitiveID()) { + case Type::FunctionTyID: { + const FunctionType *FTy = cast(Ty); + Result = getTypeDescription(FTy->getReturnType(), TypeStack) + " ("; + for (FunctionType::ParamTypes::const_iterator + I = FTy->getParamTypes().begin(), + E = FTy->getParamTypes().end(); I != E; ++I) { + if (I != FTy->getParamTypes().begin()) + Result += ", "; + Result += getTypeDescription(*I, TypeStack); + } + if (FTy->isVarArg()) { + if (!FTy->getParamTypes().empty()) Result += ", "; + Result += "..."; + } + Result += ")"; + break; + } + case Type::StructTyID: { + const StructType *STy = cast(Ty); + Result = "{ "; + for (StructType::ElementTypes::const_iterator + I = STy->getElementTypes().begin(), + E = STy->getElementTypes().end(); I != E; ++I) { + if (I != STy->getElementTypes().begin()) + Result += ", "; + Result += getTypeDescription(*I, TypeStack); + } + Result += " }"; + break; + } + case Type::PointerTyID: { + const PointerType *PTy = cast(Ty); + Result = getTypeDescription(PTy->getElementType(), TypeStack) + " *"; + break; + } + case Type::ArrayTyID: { + const ArrayType *ATy = cast(Ty); + unsigned NumElements = ATy->getNumElements(); + Result = "["; + Result += utostr(NumElements) + " x "; + Result += getTypeDescription(ATy->getElementType(), TypeStack) + "]"; + break; + } + default: + assert(0 && "Unhandled type in getTypeDescription!"); + Result = ""; + } + + TypeStack.pop_back(); // Remove self from stack... + + // In order to reduce the amount of repeated computation, we cache the computd + // value for later. + if (Ty->isAbstract()) + AbstractTypeDescriptions[Ty] = Result; + else + ConcreteTypeDescriptions[Ty] = Result; + + return Result; +} + + + +static const std::string &getOrCreateDesc(std::map&Map, + const Type *Ty) { + std::map::iterator I = Map.find(Ty); + if (I != Map.end()) return I->second; + + std::vector TypeStack; + getTypeDescription(Ty, TypeStack); + assert(Map.count(Ty) && "Type didn't get inserted!!"); + return Map[Ty]; +} + + +const std::string &Type::getDescription() const { + if (isAbstract()) + return getOrCreateDesc(AbstractTypeDescriptions, this); + else + return getOrCreateDesc(ConcreteTypeDescriptions, this); +} + + bool StructType::indexValid(const Value *V) const { if (!isa(V)) return false; if (V->getType() != Type::UByteTy) return false; @@ -247,7 +373,6 @@ OpaqueType::OpaqueType() : DerivedType(OpaqueTyID) { setAbstract(true); - setDescription("opaque"+utostr(getUniqueID())); #ifdef DEBUG_MERGE_TYPES std::cerr << "Derived new type: " << getDescription() << "\n"; #endif @@ -266,87 +391,64 @@ // some whacko opaque types, but in most cases, it will do some simple stuff // when it hits non-abstract types that aren't recursive. // -static std::string getTypeProps(const Type *Ty, - std::vector &TypeStack, - bool &isAbstract, bool &isRecursive) { - if (!Ty->isAbstract() && !Ty->isRecursive() && // Base case for the recursion - Ty->getDescription().size()) { - return Ty->getDescription(); // Primitive = leaf type - } else if (isa(Ty)) { // Base case for the recursion - isAbstract = true; // This whole type is abstract! - return Ty->getDescription(); // Opaque = leaf type - } else { - // Check to see if the Type is already on the stack... - unsigned Slot = 0, CurSize = TypeStack.size(); - while (Slot < CurSize && TypeStack[Slot] != Ty) ++Slot; // Scan for type +static void getTypeProps(const Type *Ty, std::vector &TypeStack, + bool &isAbstract, bool &isRecursive) { + if (!Ty->isAbstract() && !Ty->isRecursive()) // Base case for the recursion + return; // Primitive = leaf type + + if (isa(Ty)) { // Base case for the recursion + isAbstract = true; // This whole type is abstract! + return; // Opaque = leaf type + } + + // Check to see if the Type is already on the stack... + unsigned Slot = 0, CurSize = TypeStack.size(); + while (Slot < CurSize && TypeStack[Slot] != Ty) ++Slot; // Scan for type - // This is another base case for the recursion. In this case, we know - // that we have looped back to a type that we have previously visited. - // Generate the appropriate upreference to handle this. - // - if (Slot < CurSize) { - isRecursive = true; // We know we are recursive - return "\\" + utostr(CurSize-Slot); // Here's the upreference - } else { // Recursive case: abstract derived type... - std::string Result; - TypeStack.push_back(Ty); // Add us to the stack.. - - switch (Ty->getPrimitiveID()) { - case Type::FunctionTyID: { - const FunctionType *MTy = cast(Ty); - Result = getTypeProps(MTy->getReturnType(), TypeStack, - isAbstract, isRecursive)+" ("; - for (FunctionType::ParamTypes::const_iterator - I = MTy->getParamTypes().begin(), - E = MTy->getParamTypes().end(); I != E; ++I) { - if (I != MTy->getParamTypes().begin()) - Result += ", "; - Result += getTypeProps(*I, TypeStack, isAbstract, isRecursive); - } - if (MTy->isVarArg()) { - if (!MTy->getParamTypes().empty()) Result += ", "; - Result += "..."; - } - Result += ")"; - break; - } - case Type::StructTyID: { - const StructType *STy = cast(Ty); - Result = "{ "; - for (StructType::ElementTypes::const_iterator - I = STy->getElementTypes().begin(), - E = STy->getElementTypes().end(); I != E; ++I) { - if (I != STy->getElementTypes().begin()) - Result += ", "; - Result += getTypeProps(*I, TypeStack, isAbstract, isRecursive); - } - Result += " }"; - break; - } - case Type::PointerTyID: { - const PointerType *PTy = cast(Ty); - Result = getTypeProps(PTy->getElementType(), TypeStack, - isAbstract, isRecursive) + " *"; - break; - } - case Type::ArrayTyID: { - const ArrayType *ATy = cast(Ty); - unsigned NumElements = ATy->getNumElements(); - Result = "["; - Result += utostr(NumElements) + " x "; - Result += getTypeProps(ATy->getElementType(), TypeStack, - isAbstract, isRecursive) + "]"; - break; - } - default: - assert(0 && "Unhandled case in getTypeProps!"); - Result = ""; - } + // This is another base case for the recursion. In this case, we know + // that we have looped back to a type that we have previously visited. + // Generate the appropriate upreference to handle this. + // + if (Slot < CurSize) { + isRecursive = true; // We know we are recursive + return; + } - TypeStack.pop_back(); // Remove self from stack... - return Result; - } + // Recursive case: derived type... + TypeStack.push_back(Ty); // Add us to the stack.. + + switch (Ty->getPrimitiveID()) { + case Type::FunctionTyID: { + const FunctionType *FTy = cast(Ty); + getTypeProps(FTy->getReturnType(), TypeStack, isAbstract, isRecursive); + for (FunctionType::ParamTypes::const_iterator + I = FTy->getParamTypes().begin(), + E = FTy->getParamTypes().end(); I != E; ++I) + getTypeProps(*I, TypeStack, isAbstract, isRecursive); + break; + } + case Type::StructTyID: { + const StructType *STy = cast(Ty); + for (StructType::ElementTypes::const_iterator + I = STy->getElementTypes().begin(), + E = STy->getElementTypes().end(); I != E; ++I) + getTypeProps(*I, TypeStack, isAbstract, isRecursive); + break; + } + case Type::PointerTyID: { + const PointerType *PTy = cast(Ty); + getTypeProps(PTy->getElementType(), TypeStack, isAbstract, isRecursive); + break; + } + case Type::ArrayTyID: + getTypeProps(cast(Ty)->getElementType(), TypeStack, + isAbstract, isRecursive); + break; + default: + assert(0 && "Unhandled type in getTypeProps!"); } + + TypeStack.pop_back(); // Remove self from stack... } @@ -358,7 +460,7 @@ std::vector TypeStack; bool isAbstract = false, isRecursive = false; - setDescription(getTypeProps(this, TypeStack, isAbstract, isRecursive)); + getTypeProps(this, TypeStack, isAbstract, isRecursive); setAbstract(isAbstract); setRecursive(isRecursive); } @@ -402,8 +504,8 @@ if (const ArrayType *ATy = dyn_cast(Ty)) { if (ATy->getNumElements() != cast(Ty2)->getNumElements()) return false; - } else if (const FunctionType *MTy = dyn_cast(Ty)) { - if (MTy->isVarArg() != cast(Ty2)->isVarArg()) + } else if (const FunctionType *FTy = dyn_cast(Ty)) { + if (FTy->isVarArg() != cast(Ty2)->isVarArg()) return false; } @@ -846,6 +948,9 @@ void DerivedType::refineAbstractTypeTo(const Type *NewType) { assert(isAbstract() && "refineAbstractTypeTo: Current type is not abstract!"); assert(this != NewType && "Can't refine to myself!"); + + // The descriptions may be out of date. Conservatively clear them all! + AbstractTypeDescriptions.clear(); #ifdef DEBUG_MERGE_TYPES std::cerr << "REFINING abstract type [" << (void*)this << " " From lattner at cs.uiuc.edu Tue Sep 2 11:47:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 2 11:47:01 2003 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Type.cpp Message-ID: <200309021646.LAA22494@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Type.cpp updated: 1.51 -> 1.52 --- Log message: Further simplifications --- Diffs of the changes: Index: llvm/lib/VMCore/Type.cpp diff -u llvm/lib/VMCore/Type.cpp:1.51 llvm/lib/VMCore/Type.cpp:1.52 --- llvm/lib/VMCore/Type.cpp:1.51 Tue Sep 2 11:35:17 2003 +++ llvm/lib/VMCore/Type.cpp Tue Sep 2 11:46:41 2003 @@ -402,52 +402,19 @@ } // Check to see if the Type is already on the stack... - unsigned Slot = 0, CurSize = TypeStack.size(); - while (Slot < CurSize && TypeStack[Slot] != Ty) ++Slot; // Scan for type - - // This is another base case for the recursion. In this case, we know - // that we have looped back to a type that we have previously visited. - // Generate the appropriate upreference to handle this. - // - if (Slot < CurSize) { - isRecursive = true; // We know we are recursive - return; - } + for (unsigned Slot = 0; Slot != TypeStack.size(); ++Slot) + if (TypeStack[Slot] == Ty) { // Scan for type + isRecursive = true; // We know we are recursive + return; + } // Recursive case: derived type... TypeStack.push_back(Ty); // Add us to the stack.. - - switch (Ty->getPrimitiveID()) { - case Type::FunctionTyID: { - const FunctionType *FTy = cast(Ty); - getTypeProps(FTy->getReturnType(), TypeStack, isAbstract, isRecursive); - for (FunctionType::ParamTypes::const_iterator - I = FTy->getParamTypes().begin(), - E = FTy->getParamTypes().end(); I != E; ++I) - getTypeProps(*I, TypeStack, isAbstract, isRecursive); - break; - } - case Type::StructTyID: { - const StructType *STy = cast(Ty); - for (StructType::ElementTypes::const_iterator - I = STy->getElementTypes().begin(), - E = STy->getElementTypes().end(); I != E; ++I) - getTypeProps(*I, TypeStack, isAbstract, isRecursive); - break; - } - case Type::PointerTyID: { - const PointerType *PTy = cast(Ty); - getTypeProps(PTy->getElementType(), TypeStack, isAbstract, isRecursive); - break; - } - case Type::ArrayTyID: - getTypeProps(cast(Ty)->getElementType(), TypeStack, - isAbstract, isRecursive); - break; - default: - assert(0 && "Unhandled type in getTypeProps!"); - } + for (Type::subtype_iterator I = Ty->subtype_begin(), E = Ty->subtype_end(); + I != E; ++I) + getTypeProps(*I, TypeStack, isAbstract, isRecursive); + TypeStack.pop_back(); // Remove self from stack... } From lattner at cs.uiuc.edu Tue Sep 2 14:15:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 2 14:15:01 2003 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Type.cpp Message-ID: <200309021914.OAA28582@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Type.cpp updated: 1.52 -> 1.53 --- Log message: Ugh, fix bugs. Ok, so the last fix wasn't as great as I thought it was. Now we're back to: 131.730u, 0.330s, which is still quite an improvement, but still quite unacceptable --- Diffs of the changes: Index: llvm/lib/VMCore/Type.cpp diff -u llvm/lib/VMCore/Type.cpp:1.52 llvm/lib/VMCore/Type.cpp:1.53 --- llvm/lib/VMCore/Type.cpp:1.52 Tue Sep 2 11:46:41 2003 +++ llvm/lib/VMCore/Type.cpp Tue Sep 2 14:14:12 2003 @@ -372,6 +372,7 @@ } OpaqueType::OpaqueType() : DerivedType(OpaqueTyID) { + Recursive = false; setAbstract(true); #ifdef DEBUG_MERGE_TYPES std::cerr << "Derived new type: " << getDescription() << "\n"; @@ -426,7 +427,9 @@ void DerivedType::setDerivedTypeProperties() { std::vector TypeStack; bool isAbstract = false, isRecursive = false; - + + setAbstract(true); + setRecursive(true); getTypeProps(this, TypeStack, isAbstract, isRecursive); setAbstract(isAbstract); setRecursive(isRecursive); From lattner at cs.uiuc.edu Tue Sep 2 15:07:07 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 2 15:07:07 2003 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Type.cpp Message-ID: <200309022006.PAA29504@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Type.cpp updated: 1.53 -> 1.54 --- Log message: Don't bother doing an exhaustive recursive walk if we are at the limit of what we need to know anyway. This reduces the 2002-07-08-HugePerformanceProblem.llx down to 3.210u:0.010s, which is back in the acceptable range again --- Diffs of the changes: Index: llvm/lib/VMCore/Type.cpp diff -u llvm/lib/VMCore/Type.cpp:1.53 llvm/lib/VMCore/Type.cpp:1.54 --- llvm/lib/VMCore/Type.cpp:1.53 Tue Sep 2 14:14:12 2003 +++ llvm/lib/VMCore/Type.cpp Tue Sep 2 15:06:29 2003 @@ -372,7 +372,7 @@ } OpaqueType::OpaqueType() : DerivedType(OpaqueTyID) { - Recursive = false; + setRecursive(false); setAbstract(true); #ifdef DEBUG_MERGE_TYPES std::cerr << "Derived new type: " << getDescription() << "\n"; @@ -413,8 +413,10 @@ TypeStack.push_back(Ty); // Add us to the stack.. for (Type::subtype_iterator I = Ty->subtype_begin(), E = Ty->subtype_end(); - I != E; ++I) + I != E; ++I) { getTypeProps(*I, TypeStack, isAbstract, isRecursive); + if (isAbstract && isRecursive) break; + } TypeStack.pop_back(); // Remove self from stack... } From criswell at cs.uiuc.edu Tue Sep 2 15:16:02 2003 From: criswell at cs.uiuc.edu (John Criswell) Date: Tue Sep 2 15:16:02 2003 Subject: [llvm-commits] CVS: llvm/include/Support/FileUtilities.h Message-ID: <200309022015.PAA25885@choi.cs.uiuc.edu> Changes in directory llvm/include/Support: FileUtilities.h updated: 1.2 -> 1.3 --- Log message: Added the MakeFileExecutable() method. This method takes a filename and gives it execute access while respecting the user's umask. --- Diffs of the changes: Index: llvm/include/Support/FileUtilities.h diff -u llvm/include/Support/FileUtilities.h:1.2 llvm/include/Support/FileUtilities.h:1.3 --- llvm/include/Support/FileUtilities.h:1.2 Thu Aug 7 16:28:47 2003 +++ llvm/include/Support/FileUtilities.h Tue Sep 2 15:14:57 2003 @@ -36,4 +36,19 @@ /// std::string getUniqueFilename(const std::string &FilenameBase); +/// +/// Method: MakeFileExecutable() +/// +/// Description: +/// This method turns on whatever access attributes are needed to make the +/// specified file executable. +/// +/// Return value: +/// True - The operation succeeded. +/// False - The operation failed. +/// +/// Notes: +/// In case of failure, the file's access attributes are unspecified. +/// +bool MakeFileExecutable (const std::string & Filename); #endif From criswell at cs.uiuc.edu Tue Sep 2 15:16:05 2003 From: criswell at cs.uiuc.edu (John Criswell) Date: Tue Sep 2 15:16:05 2003 Subject: [llvm-commits] CVS: llvm/lib/Support/FileUtilities.cpp Message-ID: <200309022015.PAA25878@choi.cs.uiuc.edu> Changes in directory llvm/lib/Support: FileUtilities.cpp updated: 1.3 -> 1.4 --- Log message: Added the MakeFileExecutable() method. This method takes a filename and gives it execute access while respecting the user's umask. --- Diffs of the changes: Index: llvm/lib/Support/FileUtilities.cpp diff -u llvm/lib/Support/FileUtilities.cpp:1.3 llvm/lib/Support/FileUtilities.cpp:1.4 --- llvm/lib/Support/FileUtilities.cpp:1.3 Thu Aug 7 16:35:41 2003 +++ llvm/lib/Support/FileUtilities.cpp Tue Sep 2 15:14:55 2003 @@ -7,6 +7,8 @@ #include "Support/FileUtilities.h" #include "Config/unistd.h" +#include "Config/sys/stat.h" +#include "Config/sys/types.h" #include #include #include @@ -90,3 +92,51 @@ delete[] FNBuffer; return Result; } + +/// +/// Method: MakeFileExecutable () +/// +/// Description: +/// This method makes the specified filename executable by giving it +/// execute permission. +/// +/// For the UNIX version of this method, we turn on all of the read and +/// execute bits and then turn off anything specified in the umask. This +/// should help ensure that access to the file remains at the level that +/// the user desires. +/// +bool +MakeFileExecutable (const std::string & Filename) +{ + // Permissions masking value of the user + mode_t mask; + + // Permissions currently enabled on the file + struct stat fstat; + + // + // Grab the umask value from the operating system. We want to use it when + // changing the file's permissions. + // + // Note: + // Umask() is one of those annoying system calls. You have to call it + // to get the current value and then set it back. + // + mask = umask (0x777); + umask (mask); + + // + // Go fetch the file's current permission bits. We want to *add* execute + // access to the file. + // + if ((stat (Filename.c_str(), &fstat)) == -1) + { + return false; + } + + // Make the script executable... + chmod(Filename.c_str(), (fstat.st_mode | (0111 & ~mask))); + + return true; +} + From criswell at cs.uiuc.edu Tue Sep 2 15:18:02 2003 From: criswell at cs.uiuc.edu (John Criswell) Date: Tue Sep 2 15:18:02 2003 Subject: [llvm-commits] CVS: llvm/tools/gccld/gccld.cpp Message-ID: <200309022017.PAA25900@choi.cs.uiuc.edu> Changes in directory llvm/tools/gccld: gccld.cpp updated: 1.42 -> 1.43 --- Log message: Modified the code so that it uses the MakeFileExecutable() method. The new library code now adds all execute bits that are allowed by the umask value to the file's current permission bits. --- Diffs of the changes: Index: llvm/tools/gccld/gccld.cpp diff -u llvm/tools/gccld/gccld.cpp:1.42 llvm/tools/gccld/gccld.cpp:1.43 --- llvm/tools/gccld/gccld.cpp:1.42 Fri Aug 29 09:46:12 2003 +++ llvm/tools/gccld/gccld.cpp Tue Sep 2 15:17:20 2003 @@ -21,6 +21,7 @@ #include "llvm/Target/TargetData.h" #include "llvm/Transforms/IPO.h" #include "llvm/Transforms/Scalar.h" +#include "Support/FileUtilities.h" #include "Support/CommandLine.h" #include "Support/Signals.h" #include @@ -433,9 +434,6 @@ Out.close(); if (!LinkAsLibrary) { - // Permissions masking value of the user - mode_t mask; - // Output the script to start the program... std::ofstream Out2(OutputFilename.c_str()); if (!Out2.good()) @@ -444,22 +442,11 @@ Out2 << "#!/bin/sh\nlli -q -abort-on-exception $0.bc $*\n"; Out2.close(); - // - // Grab the umask value from the operating system. We want to use it when - // changing the file's permissions. - // - // Note: - // Umask() is one of those annoying system calls. You have to call it - // to get the current value and then set it back. - // - mask = umask (0); - umask (mask); - // Make the script executable... - chmod(OutputFilename.c_str(), (0755 & ~mask)); + MakeFileExecutable (OutputFilename); // Make the bytecode file directly executable in LLEE as well - chmod(RealBytecodeOutput.c_str(), (0755 & ~mask)); + MakeFileExecutable (RealBytecodeOutput); } return 0; From criswell at cs.uiuc.edu Tue Sep 2 15:31:02 2003 From: criswell at cs.uiuc.edu (John Criswell) Date: Tue Sep 2 15:31:02 2003 Subject: [llvm-commits] CVS: llvm/lib/Support/FileUtilities.cpp Message-ID: <200309022030.PAA26342@choi.cs.uiuc.edu> Changes in directory llvm/lib/Support: FileUtilities.cpp updated: 1.4 -> 1.5 --- Log message: Added a description of the algorithm. Return failure if the chmod() fails. --- Diffs of the changes: Index: llvm/lib/Support/FileUtilities.cpp diff -u llvm/lib/Support/FileUtilities.cpp:1.4 llvm/lib/Support/FileUtilities.cpp:1.5 --- llvm/lib/Support/FileUtilities.cpp:1.4 Tue Sep 2 15:14:55 2003 +++ llvm/lib/Support/FileUtilities.cpp Tue Sep 2 15:30:16 2003 @@ -98,12 +98,14 @@ /// /// Description: /// This method makes the specified filename executable by giving it -/// execute permission. +/// execute permission. It respects the umask value of the process, and it +/// does not enable any unnecessary access bits. /// -/// For the UNIX version of this method, we turn on all of the read and -/// execute bits and then turn off anything specified in the umask. This -/// should help ensure that access to the file remains at the level that -/// the user desires. +/// Algorithm: +/// o Get file's current permissions. +/// o Get the process's current umask. +/// o Take the set of all execute bits and disable those found in the umask. +/// o Add the remaining permissions to the file's permissions. /// bool MakeFileExecutable (const std::string & Filename) @@ -134,8 +136,13 @@ return false; } - // Make the script executable... - chmod(Filename.c_str(), (fstat.st_mode | (0111 & ~mask))); + // + // Make the file executable... + // + if ((chmod(Filename.c_str(), (fstat.st_mode | (0111 & ~mask)))) == -1) + { + return false; + } return true; } From criswell at cs.uiuc.edu Tue Sep 2 16:18:04 2003 From: criswell at cs.uiuc.edu (John Criswell) Date: Tue Sep 2 16:18:04 2003 Subject: [llvm-commits] CVS: llvm/tools/gccld/gccld.cpp Message-ID: <200309022111.QAA29591@choi.cs.uiuc.edu> Changes in directory llvm/tools/gccld: gccld.cpp updated: 1.43 -> 1.44 --- Log message: Added code that makes the bytecode file readable (needed by the generated shell script). Removed the use of sys/types.h and sys/stat.h. Modified FileExists() so that it uses the access() system call to check for file existance. This requires less header files and might even be a tad bit faster. --- Diffs of the changes: Index: llvm/tools/gccld/gccld.cpp diff -u llvm/tools/gccld/gccld.cpp:1.43 llvm/tools/gccld/gccld.cpp:1.44 --- llvm/tools/gccld/gccld.cpp:1.43 Tue Sep 2 15:17:20 2003 +++ llvm/tools/gccld/gccld.cpp Tue Sep 2 16:11:22 2003 @@ -24,12 +24,11 @@ #include "Support/FileUtilities.h" #include "Support/CommandLine.h" #include "Support/Signals.h" +#include "Config/unistd.h" #include #include #include #include -#include // For FileExists -#include namespace { cl::list @@ -78,8 +77,7 @@ // FileExists - Return true if the specified string is an openable file... static inline bool FileExists(const std::string &FN) { - struct stat StatBuf; - return stat(FN.c_str(), &StatBuf) != -1; + return access(FN.c_str(), F_OK) != -1; } @@ -445,8 +443,9 @@ // Make the script executable... MakeFileExecutable (OutputFilename); - // Make the bytecode file directly executable in LLEE as well + // Make the bytecode file readable and directly executable in LLEE as well MakeFileExecutable (RealBytecodeOutput); + MakeFileReadable (RealBytecodeOutput); } return 0; From criswell at cs.uiuc.edu Tue Sep 2 16:18:08 2003 From: criswell at cs.uiuc.edu (John Criswell) Date: Tue Sep 2 16:18:08 2003 Subject: [llvm-commits] CVS: llvm/include/Support/FileUtilities.h Message-ID: <200309022109.QAA29572@choi.cs.uiuc.edu> Changes in directory llvm/include/Support: FileUtilities.h updated: 1.3 -> 1.4 --- Log message: Added the MakeFileReadable() method. --- Diffs of the changes: Index: llvm/include/Support/FileUtilities.h diff -u llvm/include/Support/FileUtilities.h:1.3 llvm/include/Support/FileUtilities.h:1.4 --- llvm/include/Support/FileUtilities.h:1.3 Tue Sep 2 15:14:57 2003 +++ llvm/include/Support/FileUtilities.h Tue Sep 2 16:09:30 2003 @@ -51,4 +51,21 @@ /// In case of failure, the file's access attributes are unspecified. /// bool MakeFileExecutable (const std::string & Filename); + +/// +/// Method: MakeFileReadable() +/// +/// Description: +/// This method turns on whatever access attributes are needed to make the +/// specified file readable. +/// +/// Return value: +/// True - The operation succeeded. +/// False - The operation failed. +/// +/// Notes: +/// In case of failure, the file's access attributes are unspecified. +/// +bool MakeFileReadable (const std::string & Filename); + #endif From criswell at cs.uiuc.edu Tue Sep 2 16:18:11 2003 From: criswell at cs.uiuc.edu (John Criswell) Date: Tue Sep 2 16:18:11 2003 Subject: [llvm-commits] CVS: llvm/lib/Support/FileUtilities.cpp Message-ID: <200309022109.QAA29562@choi.cs.uiuc.edu> Changes in directory llvm/lib/Support: FileUtilities.cpp updated: 1.5 -> 1.6 --- Log message: Added the MakeFileReadable() method. --- Diffs of the changes: Index: llvm/lib/Support/FileUtilities.cpp diff -u llvm/lib/Support/FileUtilities.cpp:1.5 llvm/lib/Support/FileUtilities.cpp:1.6 --- llvm/lib/Support/FileUtilities.cpp:1.5 Tue Sep 2 15:30:16 2003 +++ llvm/lib/Support/FileUtilities.cpp Tue Sep 2 16:09:28 2003 @@ -147,3 +147,57 @@ return true; } +/// +/// Method: MakeFileReadable () +/// +/// Description: +/// This method makes the specified filename readable by giving it +/// read permission. It respects the umask value of the process, and it +/// does not enable any unnecessary access bits. +/// +/// Algorithm: +/// o Get file's current permissions. +/// o Get the process's current umask. +/// o Take the set of all read bits and disable those found in the umask. +/// o Add the remaining permissions to the file's permissions. +/// +bool +MakeFileReadable (const std::string & Filename) +{ + // Permissions masking value of the user + mode_t mask; + + // Permissions currently enabled on the file + struct stat fstat; + + // + // Grab the umask value from the operating system. We want to use it when + // changing the file's permissions. + // + // Note: + // Umask() is one of those annoying system calls. You have to call it + // to get the current value and then set it back. + // + mask = umask (0x777); + umask (mask); + + // + // Go fetch the file's current permission bits. We want to *add* execute + // access to the file. + // + if ((stat (Filename.c_str(), &fstat)) == -1) + { + return false; + } + + // + // Make the file executable... + // + if ((chmod(Filename.c_str(), (fstat.st_mode | (0444 & ~mask)))) == -1) + { + return false; + } + + return true; +} + From lattner at cs.uiuc.edu Tue Sep 2 16:41:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 2 16:41:01 2003 Subject: [llvm-commits] CVS: llvm/include/llvm/Type.h Message-ID: <200309022140.QAA15410@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: Type.h updated: 1.26 -> 1.27 --- Log message: Remove the "recursive bit", not only is it unused by anyone, it was also not correctly calculated, and calculating it wrong for fun seems rather pointless. --- Diffs of the changes: Index: llvm/include/llvm/Type.h diff -u llvm/include/llvm/Type.h:1.26 llvm/include/llvm/Type.h:1.27 --- llvm/include/llvm/Type.h:1.26 Tue Sep 2 11:28:03 2003 +++ llvm/include/llvm/Type.h Tue Sep 2 16:40:33 2003 @@ -73,7 +73,6 @@ PrimitiveID ID; // The current base type of this type... unsigned UID; // The unique ID number for this class bool Abstract; // True if type contains an OpaqueType - bool Recursive; // True if the type is recursive protected: /// ctor is protected, so only subclasses can create Type objects... @@ -89,10 +88,6 @@ /// inline void setAbstract(bool Val) { Abstract = Val; } - /// Types can become recursive later, if they are refined. - /// - inline void setRecursive(bool Val) { Recursive = Val; } - public: virtual void print(std::ostream &O) const; @@ -147,10 +142,6 @@ /// type that includes an opaque type somewhere in it. /// inline bool isAbstract() const { return Abstract; } - - /// isRecursive - True if the type graph contains a cycle. - /// - inline bool isRecursive() const { return Recursive; } /// isLosslesslyConvertibleTo - Return true if this type can be converted to /// 'Ty' without any reinterpretation of bits. For example, uint to int. From lattner at cs.uiuc.edu Tue Sep 2 16:42:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 2 16:42:01 2003 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Type.cpp Message-ID: <200309022141.QAA15427@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Type.cpp updated: 1.54 -> 1.55 --- Log message: Remove the "recursive bit", not only is it unused by anyone, it was also not correctly calculated, and calculating it wrong for fun seems rather pointless. This also speeds up my favorite testcase by .25 seconds. --- Diffs of the changes: Index: llvm/lib/VMCore/Type.cpp diff -u llvm/lib/VMCore/Type.cpp:1.54 llvm/lib/VMCore/Type.cpp:1.55 --- llvm/lib/VMCore/Type.cpp:1.54 Tue Sep 2 15:06:29 2003 +++ llvm/lib/VMCore/Type.cpp Tue Sep 2 16:41:05 2003 @@ -41,7 +41,7 @@ : Value(Type::TypeTy, Value::TypeVal) { ConcreteTypeDescriptions[this] = name; ID = id; - Abstract = Recursive = false; + Abstract = false; UID = CurUID++; // Assign types UID's as they are created UIDMappings.push_back(this); } @@ -136,7 +136,7 @@ return Desc; } - if (!Ty->isAbstract() && !Ty->isRecursive()) { // Base case for the recursion + if (!Ty->isAbstract()) { // Base case for the recursion std::map::iterator I = ConcreteTypeDescriptions.find(Ty); if (I != ConcreteTypeDescriptions.end()) return I->second; @@ -372,7 +372,6 @@ } OpaqueType::OpaqueType() : DerivedType(OpaqueTyID) { - setRecursive(false); setAbstract(true); #ifdef DEBUG_MERGE_TYPES std::cerr << "Derived new type: " << getDescription() << "\n"; @@ -393,8 +392,8 @@ // when it hits non-abstract types that aren't recursive. // static void getTypeProps(const Type *Ty, std::vector &TypeStack, - bool &isAbstract, bool &isRecursive) { - if (!Ty->isAbstract() && !Ty->isRecursive()) // Base case for the recursion + bool &isAbstract) { + if (!Ty->isAbstract()) // Base case for the recursion return; // Primitive = leaf type if (isa(Ty)) { // Base case for the recursion @@ -404,37 +403,32 @@ // Check to see if the Type is already on the stack... for (unsigned Slot = 0; Slot != TypeStack.size(); ++Slot) - if (TypeStack[Slot] == Ty) { // Scan for type - isRecursive = true; // We know we are recursive - return; - } + if (TypeStack[Slot] == Ty) // Scan for type + return; // is a recursive check. // Recursive case: derived type... TypeStack.push_back(Ty); // Add us to the stack.. for (Type::subtype_iterator I = Ty->subtype_begin(), E = Ty->subtype_end(); I != E; ++I) { - getTypeProps(*I, TypeStack, isAbstract, isRecursive); - if (isAbstract && isRecursive) break; + getTypeProps(*I, TypeStack, isAbstract); + if (isAbstract) break; } TypeStack.pop_back(); // Remove self from stack... } -// setDerivedTypeProperties - This function is used to calculate the -// isAbstract, isRecursive, and the Description settings for a type. The -// getTypeProps function does all the dirty work. +// setDerivedTypeProperties - This function is used to calculate the isAbstract +// setting for a type. The getTypeProps function does all the dirty work. // void DerivedType::setDerivedTypeProperties() { std::vector TypeStack; - bool isAbstract = false, isRecursive = false; + bool isAbstract = false; setAbstract(true); - setRecursive(true); - getTypeProps(this, TypeStack, isAbstract, isRecursive); + getTypeProps(this, TypeStack, isAbstract); setAbstract(isAbstract); - setRecursive(isRecursive); } From lattner at cs.uiuc.edu Tue Sep 2 16:56:02 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 2 16:56:02 2003 Subject: [llvm-commits] CVS: llvm/include/llvm/Type.h Message-ID: <200309022155.QAA18383@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: Type.h updated: 1.27 -> 1.28 --- Log message: New method --- Diffs of the changes: Index: llvm/include/llvm/Type.h diff -u llvm/include/llvm/Type.h:1.27 llvm/include/llvm/Type.h:1.28 --- llvm/include/llvm/Type.h:1.27 Tue Sep 2 16:40:33 2003 +++ llvm/include/llvm/Type.h Tue Sep 2 16:54:56 2003 @@ -88,6 +88,9 @@ /// inline void setAbstract(bool Val) { Abstract = Val; } + /// isTypeAbstract - This method is used to calculate the Abstract bit. + /// + bool isTypeAbstract(); public: virtual void print(std::ostream &O) const; From lattner at cs.uiuc.edu Tue Sep 2 16:57:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 2 16:57:01 2003 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Type.cpp Message-ID: <200309022156.QAA18403@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Type.cpp updated: 1.55 -> 1.56 --- Log message: Removal of explicit stack, which requires the method to be a member (so it can call setAbstract). Now that we just compute abstractness we can also return the computed value by value instead of as an argument. --- Diffs of the changes: Index: llvm/lib/VMCore/Type.cpp diff -u llvm/lib/VMCore/Type.cpp:1.55 llvm/lib/VMCore/Type.cpp:1.56 --- llvm/lib/VMCore/Type.cpp:1.55 Tue Sep 2 16:41:05 2003 +++ llvm/lib/VMCore/Type.cpp Tue Sep 2 16:56:34 2003 @@ -385,37 +385,38 @@ // Derived Type setDerivedTypeProperties Function //===----------------------------------------------------------------------===// -// getTypeProps - This is a recursive function that walks a type hierarchy -// calculating the description for a type and whether or not it is abstract or -// recursive. Worst case it will have to do a lot of traversing if you have -// some whacko opaque types, but in most cases, it will do some simple stuff -// when it hits non-abstract types that aren't recursive. +// isTypeAbstract - This is a recursive function that walks a type hierarchy +// calculating whether or not a type is abstract. Worst case it will have to do +// a lot of traversing if you have some whacko opaque types, but in most cases, +// it will do some simple stuff when it hits non-abstract types that aren't +// recursive. // -static void getTypeProps(const Type *Ty, std::vector &TypeStack, - bool &isAbstract) { - if (!Ty->isAbstract()) // Base case for the recursion - return; // Primitive = leaf type +bool Type::isTypeAbstract() { + if (!isAbstract()) // Base case for the recursion + return false; // Primitive = leaf type - if (isa(Ty)) { // Base case for the recursion - isAbstract = true; // This whole type is abstract! - return; // Opaque = leaf type - } + if (isa(this)) // Base case for the recursion + return true; // This whole type is abstract! - // Check to see if the Type is already on the stack... - for (unsigned Slot = 0; Slot != TypeStack.size(); ++Slot) - if (TypeStack[Slot] == Ty) // Scan for type - return; // is a recursive check. - - // Recursive case: derived type... - TypeStack.push_back(Ty); // Add us to the stack.. + // We have to guard against recursion. To do this, we temporarily mark this + // type as concrete, so that if we get back to here recursively we will think + // it's not abstract, and thus not scan it again. + setAbstract(false); + + // Scan all of the sub-types. If any of them are abstract, than so is this + // one! + for (Type::subtype_iterator I = subtype_begin(), E = subtype_end(); + I != E; ++I) + if (const_cast(*I)->isTypeAbstract()) { + setAbstract(true); + return true; + } + + // Restore the abstract bit. + setAbstract(true); - for (Type::subtype_iterator I = Ty->subtype_begin(), E = Ty->subtype_end(); - I != E; ++I) { - getTypeProps(*I, TypeStack, isAbstract); - if (isAbstract) break; - } - - TypeStack.pop_back(); // Remove self from stack... + // Nothing looks abstract here... + return false; } @@ -423,12 +424,8 @@ // setting for a type. The getTypeProps function does all the dirty work. // void DerivedType::setDerivedTypeProperties() { - std::vector TypeStack; - bool isAbstract = false; - setAbstract(true); - getTypeProps(this, TypeStack, isAbstract); - setAbstract(isAbstract); + setAbstract(isTypeAbstract()); } From lattner at cs.uiuc.edu Tue Sep 2 17:16:03 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 2 17:16:03 2003 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Type.cpp Message-ID: <200309022215.RAA20452@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Type.cpp updated: 1.56 -> 1.57 --- Log message: Another optimization, speed up the testcase to 2.7s --- Diffs of the changes: Index: llvm/lib/VMCore/Type.cpp diff -u llvm/lib/VMCore/Type.cpp:1.56 llvm/lib/VMCore/Type.cpp:1.57 --- llvm/lib/VMCore/Type.cpp:1.56 Tue Sep 2 16:56:34 2003 +++ llvm/lib/VMCore/Type.cpp Tue Sep 2 17:15:15 2003 @@ -208,8 +208,8 @@ TypeStack.pop_back(); // Remove self from stack... - // In order to reduce the amount of repeated computation, we cache the computd - // value for later. + // In order to reduce the amount of repeated computation, we cache the + // computed value for later. if (Ty->isAbstract()) AbstractTypeDescriptions[Ty] = Result; else @@ -348,6 +348,7 @@ for (unsigned i = 0; i < Params.size(); ++i) ParamTys.push_back(PATypeHandle(Params[i], this)); + setAbstract(true); setDerivedTypeProperties(); } @@ -358,16 +359,19 @@ assert(Types[i] != Type::VoidTy && "Void type in method prototype!!"); ETypes.push_back(PATypeHandle(Types[i], this)); } + setAbstract(true); setDerivedTypeProperties(); } ArrayType::ArrayType(const Type *ElType, unsigned NumEl) : SequentialType(ArrayTyID, ElType) { NumElements = NumEl; + setAbstract(true); setDerivedTypeProperties(); } PointerType::PointerType(const Type *E) : SequentialType(PointerTyID, E) { + setAbstract(true); setDerivedTypeProperties(); } @@ -408,8 +412,8 @@ for (Type::subtype_iterator I = subtype_begin(), E = subtype_end(); I != E; ++I) if (const_cast(*I)->isTypeAbstract()) { - setAbstract(true); - return true; + setAbstract(true); // Restore the abstract bit. + return true; // This type is abstract if subtype is abstract! } // Restore the abstract bit. @@ -424,6 +428,8 @@ // setting for a type. The getTypeProps function does all the dirty work. // void DerivedType::setDerivedTypeProperties() { + // If the type is currently thought to be abstract, rescan all of our subtypes + // to see if the type has just become concrete! setAbstract(true); setAbstract(isTypeAbstract()); } From lattner at cs.uiuc.edu Tue Sep 2 17:51:02 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 2 17:51:02 2003 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Type.cpp Message-ID: <200309022250.RAA29414@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Type.cpp updated: 1.57 -> 1.58 --- Log message: Don't return bogus references, and don't add an entry to the Concrete map unless it's not empty! --- Diffs of the changes: Index: llvm/lib/VMCore/Type.cpp diff -u llvm/lib/VMCore/Type.cpp:1.57 llvm/lib/VMCore/Type.cpp:1.58 --- llvm/lib/VMCore/Type.cpp:1.57 Tue Sep 2 17:15:15 2003 +++ llvm/lib/VMCore/Type.cpp Tue Sep 2 17:50:02 2003 @@ -39,7 +39,8 @@ Type::Type(const std::string &name, PrimitiveID id) : Value(Type::TypeTy, Value::TypeVal) { - ConcreteTypeDescriptions[this] = name; + if (!name.empty()) + ConcreteTypeDescriptions[this] = name; ID = id; Abstract = false; UID = CurUID++; // Assign types UID's as they are created @@ -202,8 +203,8 @@ break; } default: - assert(0 && "Unhandled type in getTypeDescription!"); Result = ""; + assert(0 && "Unhandled type in getTypeDescription!"); } TypeStack.pop_back(); // Remove self from stack... @@ -211,11 +212,9 @@ // In order to reduce the amount of repeated computation, we cache the // computed value for later. if (Ty->isAbstract()) - AbstractTypeDescriptions[Ty] = Result; + return AbstractTypeDescriptions[Ty] = Result; else - ConcreteTypeDescriptions[Ty] = Result; - - return Result; + return ConcreteTypeDescriptions[Ty] = Result; } From lattner at cs.uiuc.edu Tue Sep 2 17:53:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 2 17:53:01 2003 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Type.cpp Message-ID: <200309022253.RAA29955@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Type.cpp updated: 1.58 -> 1.59 --- Log message: Another small speedup, this one to: 2.42s --- Diffs of the changes: Index: llvm/lib/VMCore/Type.cpp diff -u llvm/lib/VMCore/Type.cpp:1.58 llvm/lib/VMCore/Type.cpp:1.59 --- llvm/lib/VMCore/Type.cpp:1.58 Tue Sep 2 17:50:02 2003 +++ llvm/lib/VMCore/Type.cpp Tue Sep 2 17:52:49 2003 @@ -429,8 +429,8 @@ void DerivedType::setDerivedTypeProperties() { // If the type is currently thought to be abstract, rescan all of our subtypes // to see if the type has just become concrete! - setAbstract(true); - setAbstract(isTypeAbstract()); + if (isAbstract()) + setAbstract(isTypeAbstract()); } From lattner at cs.uiuc.edu Tue Sep 2 18:40:02 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 2 18:40:02 2003 Subject: [llvm-commits] CVS: llvm/www/docs/LangRef.html Message-ID: <200309022338.SAA08595@tank.cs.uiuc.edu> Changes in directory llvm/www/docs: LangRef.html updated: 1.27 -> 1.28 --- Log message: hyphenation police visited here --- Diffs of the changes: Index: llvm/www/docs/LangRef.html diff -u llvm/www/docs/LangRef.html:1.27 llvm/www/docs/LangRef.html:1.28 --- llvm/www/docs/LangRef.html:1.27 Thu Aug 28 17:12:25 2003 +++ llvm/www/docs/LangRef.html Tue Sep 2 18:38:41 2003 @@ -100,8 +100,8 @@
    This document is a reference manual for the LLVM assembly language. LLVM is - an SSA based representation that provides type safety, low level operations, - flexibility, and the capability of representing 'all' high level languages + an SSA based representation that provides type safety, low-level operations, + flexibility, and the capability of representing 'all' high-level languages cleanly. It is the common code representation used throughout all phases of the LLVM compilation strategy.
    @@ -117,17 +117,17 @@ The LLVM code representation is designed to be used in three different forms: as -an in-memory compiler IR, as an on-disk bytecode representation, suitable for -fast loading by a dynamic compiler, and as a human readable assembly language -representation. This allows LLVM to provide a powerful intermediate +an in-memory compiler IR, as an on-disk bytecode representation (suitable for +fast loading by a Just-In-Time compiler), and as a human readable assembly +language representation. This allows LLVM to provide a powerful intermediate representation for efficient compiler transformations and analysis, while providing a natural means to debug and visualize the transformations. The three different forms of LLVM are all equivalent. This document describes the human readable representation and notation.

    -The LLVM representation aims to be a light weight and low level while being +The LLVM representation aims to be a light-weight and low-level while being expressive, typed, and extensible at the same time. It aims to be a "universal -IR" of sorts, by being at a low enough level that high level ideas may be +IR" of sorts, by being at a low enough level that high-level ideas may be cleanly mapped to it (similar to how microprocessors are "universal IR's", allowing many source languages to be mapped to them). By providing type information, LLVM can be used as the target of optimizations: for example, @@ -1839,7 +1839,7 @@

    Chris Lattner
    -Last modified: Thu Aug 28 17:11:50 CDT 2003 +Last modified: Tue Sep 2 18:38:09 CDT 2003 From lattner at cs.uiuc.edu Tue Sep 2 19:43:02 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 2 19:43:02 2003 Subject: [llvm-commits] CVS: llvm/www/docs/LangRef.html Message-ID: <200309030041.TAA01292@tank.cs.uiuc.edu> Changes in directory llvm/www/docs: LangRef.html updated: 1.28 -> 1.29 --- Log message: Add a WHOLE lot of updates clarifications and fixes. This is not done but getting closer. I changed the docs to reflect the goal of making unwind an instruction, not an intrinsic. --- Diffs of the changes: Index: llvm/www/docs/LangRef.html diff -u llvm/www/docs/LangRef.html:1.28 llvm/www/docs/LangRef.html:1.29 --- llvm/www/docs/LangRef.html:1.28 Tue Sep 2 18:38:41 2003 +++ llvm/www/docs/LangRef.html Tue Sep 2 19:41:47 2003 @@ -39,6 +39,7 @@
  • 'br' Instruction
  • 'switch' Instruction
  • 'invoke' Instruction +
  • 'unwind' Instruction
  • Binary Operations
      @@ -81,7 +82,6 @@
    1. 'llvm.va_start' Intrinsic
    2. 'llvm.va_end' Intrinsic
    3. 'llvm.va_copy' Intrinsic -
    4. 'llvm.unwind' Intrinsic
    @@ -167,9 +167,17 @@ LLVM uses three different forms of identifiers, for different purposes:

      -
    1. Numeric constants are represented as you would expect: 12, -3 123.421, etc. Floating point constants have an optional hexidecimal notation. -
    2. Named values are represented as a string of characters with a '%' prefix. For example, %foo, %DivisionByZero, %a.really.long.identifier. The actual regular expression used is '%[a-zA-Z$._][a-zA-Z$._0-9]*'. -
    3. Unnamed values are represented as an unsigned numeric value with a '%' prefix. For example, %12, %2, %44. +
    4. Numeric constants are represented as you would expect: 12, -3 123.421, etc. +Floating point constants have an optional hexidecimal notation. + +
    5. Named values are represented as a string of characters with a '%' prefix. +For example, %foo, %DivisionByZero, %a.really.long.identifier. The actual +regular expression used is '%[a-zA-Z$._][a-zA-Z$._0-9]*'. Identifiers +which require other characters in their names can be surrounded with quotes. In +this way, anything except a " character can be used in a name. + +
    6. Unnamed values are represented as an unsigned numeric value with a '%' +prefix. For example, %12, %2, %44.

    LLVM requires the values start with a '%' sign for two reasons: Compilers don't @@ -346,7 +354,7 @@

      - +
      [3 x [4 x int]]: 3x4 array integer values.
      [12 x [10 x float]]: 2x10 array of single precision floating point values.
      [12 x [10 x float]]: 12x10 array of single precision floating point values.
      [2 x [3 x [4 x uint]]]: 2x3x4 array of unsigned integer values.
    @@ -369,10 +377,10 @@ Where '<parameter list>' is a comma-separated list of type specifiers. Optionally, the parameter list may include a type ..., -which indicates that the function takes a variable number of arguments. Note -that there currently is no way to define a function in LLVM that takes a -variable number of arguments, but it is possible to call a function that -is vararg.

    +which indicates that the function takes a variable number of arguments. +Variable argument functions can access their arguments with the variable argument handling intrinsic functions. +

    Examples:
       -Function Structure +Functions
      LLVM functions definitions are composed of a (possibly empty) argument list, an @@ -564,7 +609,8 @@ The first basic block in program is special in two ways: it is immediately executed on entrance to the function, and it is not allowed to have predecessor basic blocks (i.e. there can not be any branches to the entry block of a -function).

      +function). Because the block can have no predecessors, it also cannot have any +PHI nodes.

      @@ -593,11 +639,12 @@ (the one exception being the 'invoke' instruction).

      -There are four different terminator instructions: the 'ret' instruction, the 'br' instruction, the 'switch' instruction, and the 'invoke' instruction.

      +href="#i_switch">switch' instruction, the 'invoke' instruction, and the 'unwind' instruction.

      @@ -628,8 +675,13 @@

      Semantics:
      When the 'ret' instruction is executed, control flow returns back to -the calling function's context. If the instruction returns a value, that value -shall be propagated into the calling function's data space.

      +the calling function's context. If the caller is a "call instruction, execution continues at the +instruction after the call. If the caller was an "invoke" instruction, execution continues at the +beginning "normal" of the destination block. If the instruction returns a +value, that value shall set the call or invoke instruction's return value.

      +

      Example:
      @@ -665,8 +717,8 @@
       
       Upon execution of a conditional 'br' instruction, the 'bool'
       argument is evaluated.  If the value is true, control flows to the
      -'iftrue' 'label' argument.  If "cond" is false,
      -control flows to the 'iffalse' 'label' argument.

      +'iftrue' label argument. If "cond" is false, +control flows to the 'iffalse' label argument.

      Example:
      @@ -685,7 +737,7 @@
       
       
      Syntax:
      -  switch int <value>, label <defaultdest> [ int <val>, label &dest>, ... ]
      +  switch uint <value>, label <defaultdest> [ int <val>, label &dest>, ... ]
       
       
      @@ -718,15 +770,15 @@
         ; Emulate a conditional br instruction
         %Val = cast bool %value to uint
      -  switch int %Val, label %truedest [int 0, label %falsedest ]
      +  switch uint %Val, label %truedest [int 0, label %falsedest ]
       
         ; Emulate an unconditional br instruction
      -  switch int 0, label %dest [ ]
      +  switch uint 0, label %dest [ ]
       
         ; Implement a jump table:
      -  switch int %val, label %otherwise [ int 0, label %onzero, 
      -                                      int 1, label %onone, 
      -                                      int 2, label %ontwo ]
      +  switch uint %val, label %otherwise [ int 0, label %onzero, 
      +                                       int 1, label %onone, 
      +                                       int 2, label %ontwo ]
       
      @@ -744,11 +796,12 @@ The 'invoke' instruction causes control to transfer to a specified function, with the possibility of control flow transfer to either the -'normal label' label or the 'exception label'. If the callee -function invokes the "ret" instruction, control -flow will return to the "normal" label. If the callee (or any indirect callees) -calls the "llvm.unwind" intrinsic, control is -interrupted, and continued at the "except" label.

      +'normal' label label or the 'exception' +label. If the callee function returns with the "ret" instruction, control flow will return to the +"normal" label. If the callee (or any indirect callees) returns with the "unwind" instruction, control is interrupted, and +continued at the dynamically nearest "except" label.

      Arguments:
      @@ -771,8 +824,8 @@
    • 'normal label': the label reached when the called function executes a 'ret' instruction. -
    • 'exception label': the label reached when a callee calls the llvm.unwind intrinsic. +
    • 'exception label': the label reached when a callee returns with the +unwind instruction.
      Semantics:
      @@ -793,6 +846,30 @@ except label %TestCleanup ; {int}:retval set
    • + +


    'unwind' Instruction