From lattner at cs.uiuc.edu Mon Feb 9 10:03:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Feb 9 10:03:02 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/Makefile.programs Message-ID: <200402091602.KAA23211@apoc.cs.uiuc.edu> Changes in directory llvm/test/Programs: Makefile.programs updated: 1.111 -> 1.112 --- Log message: Fix EH support in the JIT with linear scan --- Diffs of the changes: (+1 -2) Index: llvm/test/Programs/Makefile.programs diff -u llvm/test/Programs/Makefile.programs:1.111 llvm/test/Programs/Makefile.programs:1.112 --- llvm/test/Programs/Makefile.programs:1.111 Sun Feb 8 13:54:33 2004 +++ llvm/test/Programs/Makefile.programs Mon Feb 9 10:02:40 2004 @@ -287,7 +287,6 @@ LLI_OPTS = -force-interpreter=true $(EXTRA_LLI_OPTS) JIT_OPTS = -force-interpreter=false $(EXTRA_LLI_OPTS) -JIT_LS_OPTS = -force-interpreter=false -regalloc=linearscan $(EXTRA_LLI_OPTS) # If the program requires exception handling support, enable (potentially @@ -321,7 +320,7 @@ $(PROGRAMS_TO_TEST:%=Output/%.out-jit-ls): \ Output/%.out-jit-ls: Output/%.llvm.bc $(LLI) - -$(RUNSAFELY) $(STDIN_FILENAME) $@ $(LLI) $(JIT_LS_OPTS) $< $(RUN_OPTIONS) + -$(RUNSAFELY) $(STDIN_FILENAME) $@ $(LLI) -regalloc=linearscan $(JIT_OPTS) $< $(RUN_OPTIONS) ifdef PROGRAM_REQUIRED_TO_EXIT_OK @if test \! -f $@.exitok; then echo "TEST (jit-ls): $* FAILED!"; rm -f $@; fi endif From lattner at cs.uiuc.edu Mon Feb 9 10:36:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Feb 9 10:36:02 2004 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Type.cpp Message-ID: <200402091635.KAA10563@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Type.cpp updated: 1.90 -> 1.91 --- Log message: Code cleanup in preparation for later changes. Now that ContainedTy's are consistent across the various type classes, we can factor out a LOT more almost-identical code. Also, add a couple of temporary statistics. --- Diffs of the changes: (+75 -107) Index: llvm/lib/VMCore/Type.cpp diff -u llvm/lib/VMCore/Type.cpp:1.90 llvm/lib/VMCore/Type.cpp:1.91 --- llvm/lib/VMCore/Type.cpp:1.90 Sun Feb 8 23:40:24 2004 +++ llvm/lib/VMCore/Type.cpp Mon Feb 9 10:35:14 2004 @@ -17,10 +17,14 @@ #include "Support/DepthFirstIterator.h" #include "Support/StringExtras.h" #include "Support/STLExtras.h" +#include "Support/Statistic.h" #include using namespace llvm; +static Statistic<> NumSlowTypes("type", "numslowtypes"); +static Statistic<> NumTypeEquals("type", "numtypeequals"); + // DEBUG_MERGE_TYPES - Enable this #define to see how and when derived types are // created and later destroyed, all in an effort to make sure that there is only // a single canonical version of a type. @@ -521,6 +525,19 @@ return TypesEqual(Ty, Ty2, EqTypes); } +/// TypeHasCycleThroughItself - Return true if the specified type has a cycle +/// back to itself. +static bool TypeHasCycleThroughItself(const Type *Ty) { + std::set VisitedTypes; + for (Type::subtype_iterator I = Ty->subtype_begin(), + E = Ty->subtype_end(); I != E; ++I) + for (df_ext_iterator > + DFI = df_ext_begin(I->get(), VisitedTypes), + E = df_ext_end(I->get(), VisitedTypes); DFI != E; ++DFI) + if (*DFI == Ty) + return true; // Found a cycle through ty! + return false; +} //===----------------------------------------------------------------------===// @@ -529,15 +546,15 @@ // TypeMap - Make sure that only one instance of a particular type may be // created on any given run of the compiler... note that this involves updating -// our map if an abstract type gets refined somehow... +// our map if an abstract type gets refined somehow. // namespace llvm { template class TypeMap { - typedef std::map MapTy; - MapTy Map; + std::map Map; + public: - typedef typename MapTy::iterator iterator; + typedef typename std::map::iterator iterator; ~TypeMap() { print("ON EXIT"); } inline TypeClass *get(const ValType &V) { @@ -562,41 +579,39 @@ /// type with its new components. We must now either merge the type away with /// some other type or reinstall it in the map with it's new configuration. /// The specified iterator tells us what the type USED to look like. - void finishRefinement(iterator TyIt) { + void finishRefinement(TypeClass *Ty, const DerivedType *OldType, + const Type *NewType) { + assert((Ty->isAbstract() || !OldType->isAbstract()) && + "Refining a non-abstract type!"); +#ifdef DEBUG_MERGE_TYPES + std::cerr << "refineAbstractTy(" << (void*)OldType << "[" << *OldType + << "], " << (void*)NewType << " [" << *NewType << "])\n"; +#endif + // Make a temporary type holder for the type so that it doesn't disappear on // us when we erase the entry from the map. - PATypeHolder TyHolder = TyIt->second; - TypeClass *Ty = cast((Type*)TyHolder.get()); + PATypeHolder TyHolder = Ty; + + // Look up our current type map entry.. + iterator TyIt = getEntryForType(Ty); // The old record is now out-of-date, because one of the children has been // updated. Remove the obsolete entry from the map. Map.erase(TyIt); - // Determine whether there is a cycle through the type graph which passes - // back through this type. Other cycles are ok though. - bool HasTypeCycle = false; - { - std::set VisitedTypes; - for (Type::subtype_iterator I = Ty->subtype_begin(), - E = Ty->subtype_end(); I != E; ++I) { - for (df_ext_iterator > - DFI = df_ext_begin(I->get(), VisitedTypes), - E = df_ext_end(I->get(), VisitedTypes); DFI != E; ++DFI) - if (*DFI == Ty) { - HasTypeCycle = true; - goto FoundCycle; - } + // Find the type element we are refining... + for (unsigned i = 0, e = Ty->ContainedTys.size(); i != e; ++i) + if (Ty->ContainedTys[i] == OldType) { + Ty->ContainedTys[i].removeUserFromConcrete(); + Ty->ContainedTys[i] = NewType; } - } - FoundCycle: - - ValType Key = ValType::get(Ty); - + // If there are no cycles going through this node, we can do a simple, // efficient lookup in the map, instead of an inefficient nasty linear // lookup. - if (!HasTypeCycle) { - iterator I = Map.find(Key); + bool TypeHasCycle = TypeHasCycleThroughItself(Ty); + if (!TypeHasCycle) { + iterator I = Map.find(ValType::get(Ty)); if (I != Map.end()) { // We already have this type in the table. Get rid of the newly refined // type. @@ -609,11 +624,18 @@ } } else { + ++NumSlowTypes; + + unsigned TypeHash = ValType::hashTypeStructure(Ty); + + + // Now we check to see if there is an existing entry in the table which is // structurally identical to the newly refined type. If so, this type // gets refined to the pre-existing type. // - for (iterator I = Map.begin(), E = Map.end(); I != E; ++I) + for (iterator I = Map.begin(), E = Map.end(); I != E; ++I) { + ++NumTypeEquals; if (TypesEqual(Ty, I->second)) { assert(Ty->isAbstract() && "Replacing a non-abstract type?"); TypeClass *NewTy = cast((Type*)I->second.get()); @@ -622,11 +644,12 @@ Ty->refineAbstractTypeTo(NewTy); return; } + } } // If there is no existing type of the same structure, we reinsert an // updated record into the map. - Map.insert(std::make_pair(Key, Ty)); + Map.insert(std::make_pair(ValType::get(Ty), Ty)); // If the type is currently thought to be abstract, rescan all of our // subtypes to see if the type has just become concrete! @@ -654,8 +677,8 @@ #ifdef DEBUG_MERGE_TYPES std::cerr << "TypeMap<>::" << Arg << " table contents:\n"; unsigned i = 0; - for (typename MapTy::const_iterator I = Map.begin(), E = Map.end(); - I != E; ++I) + for (typename std::map::const_iterator I + = Map.begin(), E = Map.end(); I != E; ++I) std::cerr << " " << (++i) << ". " << (void*)I->second.get() << " " << *I->second.get() << "\n"; #endif @@ -686,6 +709,10 @@ static FunctionValType get(const FunctionType *FT); + static unsigned hashTypeStructure(const FunctionType *FT) { + return 0; + } + // Subclass should override this... to update self as usual void doRefinement(const DerivedType *OldType, const Type *NewType) { if (RetTy == OldType) RetTy = NewType; @@ -746,6 +773,10 @@ return ArrayValType(AT->getElementType(), AT->getNumElements()); } + static unsigned hashTypeStructure(const ArrayType *AT) { + return 0; + } + // Subclass should override this... to update self as usual void doRefinement(const DerivedType *OldType, const Type *NewType) { assert(ValTy == OldType); @@ -798,6 +829,10 @@ return StructValType(ElTypes); } + static unsigned hashTypeStructure(const StructType *ST) { + return 0; + } + // Subclass should override this... to update self as usual void doRefinement(const DerivedType *OldType, const Type *NewType) { for (unsigned i = 0; i < ElTypes.size(); ++i) @@ -844,6 +879,10 @@ return PointerValType(PT->getElementType()); } + static unsigned hashTypeStructure(const PointerType *PT) { + return 0; + } + // Subclass should override this... to update self as usual void doRefinement(const DerivedType *OldType, const Type *NewType) { assert(ValTy == OldType); @@ -1017,26 +1056,7 @@ // void FunctionType::refineAbstractType(const DerivedType *OldType, const Type *NewType) { - assert((isAbstract() || !OldType->isAbstract()) && - "Refining a non-abstract type!"); -#ifdef DEBUG_MERGE_TYPES - std::cerr << "FunctionTy::refineAbstractTy(" << (void*)OldType << "[" - << *OldType << "], " << (void*)NewType << " [" - << *NewType << "])\n"; -#endif - - // Look up our current type map entry.. - TypeMap::iterator TMI = - FunctionTypes.getEntryForType(this); - - // Find the type element we are refining... - for (unsigned i = 0, e = ContainedTys.size(); i != e; ++i) - if (ContainedTys[i] == OldType) { - ContainedTys[i].removeUserFromConcrete(); - ContainedTys[i] = NewType; - } - - FunctionTypes.finishRefinement(TMI); + FunctionTypes.finishRefinement(this, OldType, NewType); } void FunctionType::typeBecameConcrete(const DerivedType *AbsTy) { @@ -1050,23 +1070,7 @@ // void ArrayType::refineAbstractType(const DerivedType *OldType, const Type *NewType) { - assert((isAbstract() || !OldType->isAbstract()) && - "Refining a non-abstract type!"); -#ifdef DEBUG_MERGE_TYPES - std::cerr << "ArrayTy::refineAbstractTy(" << (void*)OldType << "[" - << *OldType << "], " << (void*)NewType << " [" - << *NewType << "])\n"; -#endif - - // Look up our current type map entry.. - TypeMap::iterator TMI = - ArrayTypes.getEntryForType(this); - - assert(getElementType() == OldType); - ContainedTys[0].removeUserFromConcrete(); - ContainedTys[0] = NewType; - - ArrayTypes.finishRefinement(TMI); + ArrayTypes.finishRefinement(this, OldType, NewType); } void ArrayType::typeBecameConcrete(const DerivedType *AbsTy) { @@ -1080,27 +1084,7 @@ // void StructType::refineAbstractType(const DerivedType *OldType, const Type *NewType) { - assert((isAbstract() || !OldType->isAbstract()) && - "Refining a non-abstract type!"); -#ifdef DEBUG_MERGE_TYPES - std::cerr << "StructTy::refineAbstractTy(" << (void*)OldType << "[" - << *OldType << "], " << (void*)NewType << " [" - << *NewType << "])\n"; -#endif - - // Look up our current type map entry.. - TypeMap::iterator TMI = - StructTypes.getEntryForType(this); - - for (int i = ContainedTys.size()-1; i >= 0; --i) - if (ContainedTys[i] == OldType) { - ContainedTys[i].removeUserFromConcrete(); - - // Update old type to new type in the array... - ContainedTys[i] = NewType; - } - - StructTypes.finishRefinement(TMI); + StructTypes.finishRefinement(this, OldType, NewType); } void StructType::typeBecameConcrete(const DerivedType *AbsTy) { @@ -1113,23 +1097,7 @@ // void PointerType::refineAbstractType(const DerivedType *OldType, const Type *NewType) { - assert((isAbstract() || !OldType->isAbstract()) && - "Refining a non-abstract type!"); -#ifdef DEBUG_MERGE_TYPES - std::cerr << "PointerTy::refineAbstractTy(" << (void*)OldType << "[" - << *OldType << "], " << (void*)NewType << " [" - << *NewType << "])\n"; -#endif - - // Look up our current type map entry.. - TypeMap::iterator TMI = - PointerTypes.getEntryForType(this); - - assert(ContainedTys[0] == OldType); - ContainedTys[0].removeUserFromConcrete(); - ContainedTys[0] = NewType; - - PointerTypes.finishRefinement(TMI); + PointerTypes.finishRefinement(this, OldType, NewType); } void PointerType::typeBecameConcrete(const DerivedType *AbsTy) { From lattner at cs.uiuc.edu Mon Feb 9 11:22:03 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Feb 9 11:22:03 2004 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Reader/ConstantReader.cpp Message-ID: <200402091721.LAA31742@zion.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Reader: ConstantReader.cpp updated: 1.73 -> 1.74 --- Log message: This debugging hook is no longer needed. --- Diffs of the changes: (+0 -2) Index: llvm/lib/Bytecode/Reader/ConstantReader.cpp diff -u llvm/lib/Bytecode/Reader/ConstantReader.cpp:1.73 llvm/lib/Bytecode/Reader/ConstantReader.cpp:1.74 --- llvm/lib/Bytecode/Reader/ConstantReader.cpp:1.73 Sun Feb 8 22:37:28 2004 +++ llvm/lib/Bytecode/Reader/ConstantReader.cpp Mon Feb 9 11:20:52 2004 @@ -89,7 +89,6 @@ // something and when we reread the type later, we can replace the opaque type // with a new resolved concrete type. // -namespace llvm { void debug_type_tables(); } void BytecodeParser::parseTypeConstants(const unsigned char *&Buf, const unsigned char *EndBuf, TypeValuesListTy &Tab, @@ -129,7 +128,6 @@ for (unsigned i = 0; i < NumEntries; ++i) { BCR_TRACE(5, (void*)Tab[i].get() << " - " << Tab[i].get() << "\n"); } - debug_type_tables(); } From criswell at cs.uiuc.edu Mon Feb 9 11:26:03 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Mon Feb 9 11:26:03 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/SingleSource/CustomChecked/Makefile Message-ID: <200402091725.LAA30027@choi.cs.uiuc.edu> Changes in directory llvm/test/Programs/SingleSource/CustomChecked: Makefile updated: 1.10 -> 1.11 --- Log message: We get unreferenced cxa_demangle errors if we don't compile with libstdc++. I've looked at the GCC 3.3 native libsupc++ and libstdc++: libsupc++ doesn't define cxa_demangle at all while libstdc++ has it listed as an undefined symbol. So, I think linking with the full libstdc++ is correct. --- Diffs of the changes: (+1 -1) Index: llvm/test/Programs/SingleSource/CustomChecked/Makefile diff -u llvm/test/Programs/SingleSource/CustomChecked/Makefile:1.10 llvm/test/Programs/SingleSource/CustomChecked/Makefile:1.11 --- llvm/test/Programs/SingleSource/CustomChecked/Makefile:1.10 Fri Dec 19 17:25:15 2003 +++ llvm/test/Programs/SingleSource/CustomChecked/Makefile Mon Feb 9 11:25:36 2004 @@ -6,7 +6,7 @@ include $(LEVEL)/test/Programs/SingleSource/Makefile.singlesrc -LIBS += -lsupc++ +LIBS += -lstdc++ LDFLAGS += -lm LLI_RUN := $(addsuffix .run-lli, $(PREFIXED_PROGRAMS_TO_TEST)) From criswell at cs.uiuc.edu Mon Feb 9 11:27:02 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Mon Feb 9 11:27:02 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/MultiSource/Applications/lambda-0.1.3/Makefile Message-ID: <200402091726.LAA30089@choi.cs.uiuc.edu> Changes in directory llvm/test/Programs/MultiSource/Applications/lambda-0.1.3: Makefile updated: 1.3 -> 1.4 --- Log message: Link with libstdc++ instead of libsupc++. The original lambda links with libstdc++, and we don't link correctly without it. --- Diffs of the changes: (+2 -2) Index: llvm/test/Programs/MultiSource/Applications/lambda-0.1.3/Makefile diff -u llvm/test/Programs/MultiSource/Applications/lambda-0.1.3/Makefile:1.3 llvm/test/Programs/MultiSource/Applications/lambda-0.1.3/Makefile:1.4 --- llvm/test/Programs/MultiSource/Applications/lambda-0.1.3/Makefile:1.3 Fri Feb 6 12:34:46 2004 +++ llvm/test/Programs/MultiSource/Applications/lambda-0.1.3/Makefile Mon Feb 9 11:26:26 2004 @@ -1,6 +1,6 @@ LEVEL = ../../../../.. PROG = lambda -LDFLAGS = -lsupc++ -LIBS += -lsupc++ +LDFLAGS += -lstdc++ +LIBS += -lstdc++ STDIN_FILENAME=$(BUILD_SRC_DIR)/input include ../../Makefile.multisrc From gaeke at gally.cs.uiuc.edu Mon Feb 9 11:40:03 2004 From: gaeke at gally.cs.uiuc.edu (Brian Gaeke) Date: Mon Feb 9 11:40:03 2004 Subject: [llvm-commits] CVS: llvm/Makefile Makefile.rules Message-ID: <200402091739.i19Hd3415924@gally.cs.uiuc.edu> Changes in directory llvm: Makefile updated: 1.20 -> 1.21 Makefile.rules updated: 1.177 -> 1.178 --- Log message: Fix bug in installation process: MKDIR must respect DESTDIR. --- Diffs of the changes: (+5 -5) Index: llvm/Makefile diff -u llvm/Makefile:1.20 llvm/Makefile:1.21 --- llvm/Makefile:1.20 Sun Feb 8 01:44:30 2004 +++ llvm/Makefile Mon Feb 9 11:38:51 2004 @@ -32,7 +32,7 @@ .PHONY: install-includes install-includes: - $(MKDIR) $(includedir)/llvm + $(MKDIR) $(DESTDIR)$(includedir)/llvm cd include && find * '!' '(' -name '*~' -o -name .cvsignore ')' -print | grep -v CVS | pax -rwdvpe $(DESTDIR)$(includedir)/llvm install:: install-includes Index: llvm/Makefile.rules diff -u llvm/Makefile.rules:1.177 llvm/Makefile.rules:1.178 --- llvm/Makefile.rules:1.177 Wed Feb 4 15:41:23 2004 +++ llvm/Makefile.rules Mon Feb 9 11:38:52 2004 @@ -548,7 +548,7 @@ @${ECHO} ======= Finished building $(LIBRARYNAME) dynamic debug library ======= install-dynamic-library: $(LIBNAME_CUR) - $(MKDIR) $(libdir) + $(MKDIR) $(DESTDIR)$(libdir) $(VERB) $(LIBTOOL) --mode=install $(INSTALL) $(LIBNAME_CUR) $(DESTDIR)$(libdir)/lib$(LIBRARYNAME)$(SHLIBEXT) # @@ -573,7 +573,7 @@ @${ECHO} ======= Finished building $(LIBRARYNAME) archive debug library ======= install-archive-library: $(LIBNAME_ACUR) - $(MKDIR) $(libdir) + $(MKDIR) $(DESTDIR)$(libdir) $(VERB) $(LIBTOOL) --mode=install $(INSTALL) $(LIBNAME_ACUR) $(DESTDIR)$(libdir)/lib$(LIBRARYNAME).a # @@ -603,7 +603,7 @@ $(VERB) $(Relink) -o $@ $(RObjectsG) $(LibSubDirs) install-single-object-library: $(LIBNAME_OBJCUR) - $(MKDIR) $(libdir) + $(MKDIR) $(DESTDIR)$(libdir) $(VERB) $(LIBTOOL) --mode=install $(INSTALL) $(LIBNAME_OBJCUR) $(DESTDIR)$(libdir)/$(LIBRARYNAME).o endif @@ -686,7 +686,7 @@ @${ECHO} ======= Finished building $(TOOLNAME) profile executable ======= install:: $(TOOLEXENAMES) - $(MKDIR) $(bindir) + $(MKDIR) $(DESTDIR)$(bindir) $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) -c -m 0755 $(TOOLEXENAMES) $(DESTDIR)$(bindir)/$(TOOLNAME) endif From lattner at cs.uiuc.edu Mon Feb 9 12:33:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Feb 9 12:33:01 2004 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Type.cpp Message-ID: <200402091832.MAA31945@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Type.cpp updated: 1.91 -> 1.92 --- Log message: Implement the hashing scheme in an attempt to speed up the "slow" case in type resolution. Unfortunately it doesn't help. Also delete some dead debugging code. --- Diffs of the changes: (+68 -50) Index: llvm/lib/VMCore/Type.cpp diff -u llvm/lib/VMCore/Type.cpp:1.91 llvm/lib/VMCore/Type.cpp:1.92 --- llvm/lib/VMCore/Type.cpp:1.91 Mon Feb 9 10:35:14 2004 +++ llvm/lib/VMCore/Type.cpp Mon Feb 9 12:32:40 2004 @@ -22,8 +22,9 @@ using namespace llvm; -static Statistic<> NumSlowTypes("type", "numslowtypes"); -static Statistic<> NumTypeEquals("type", "numtypeequals"); +static Statistic<> NumSlowTypes("type", "num slow types"); +static Statistic<> NumTypeEqualsCalls("type", "num typeequals calls"); +static Statistic<> NumTypeEquals("type", "num types actually equal"); // DEBUG_MERGE_TYPES - Enable this #define to see how and when derived types are // created and later destroyed, all in an effort to make sure that there is only @@ -553,6 +554,9 @@ class TypeMap { std::map Map; + /// TypesByHash - Keep track of each type by its structure hash value. + /// + std::multimap TypesByHash; public: typedef typename std::map::iterator iterator; ~TypeMap() { print("ON EXIT"); } @@ -562,17 +566,22 @@ return I != Map.end() ? cast((Type*)I->second.get()) : 0; } - inline void add(const ValType &V, TypeClass *T) { - Map.insert(std::make_pair(V, T)); + inline void add(const ValType &V, TypeClass *Ty) { + Map.insert(std::make_pair(V, Ty)); + + // If this type has a cycle, remember it. + TypesByHash.insert(std::make_pair(ValType::hashTypeStructure(Ty), Ty)); print("add"); } - iterator getEntryForType(TypeClass *Ty) { - iterator I = Map.find(ValType::get(Ty)); - if (I == Map.end()) print("ERROR!"); - assert(I != Map.end() && "Didn't find type entry!"); - assert(I->second.get() == (const Type*)Ty && "Type entry wrong?"); - return I; + void RemoveFromTypesByHash(unsigned Hash, const Type *Ty) { + std::multimap::iterator I = + TypesByHash.lower_bound(Hash); + while (I->second != Ty) { + ++I; + assert(I != TypesByHash.end() && I->first == Hash); + } + TypesByHash.erase(I); } /// finishRefinement - This method is called after we have updated an existing @@ -592,19 +601,23 @@ // us when we erase the entry from the map. PATypeHolder TyHolder = Ty; - // Look up our current type map entry.. - iterator TyIt = getEntryForType(Ty); - // The old record is now out-of-date, because one of the children has been // updated. Remove the obsolete entry from the map. - Map.erase(TyIt); + Map.erase(ValType::get(Ty)); - // Find the type element we are refining... + // Remember the structural hash for the type before we start hacking on it, + // in case we need it later. Also, check to see if the type HAD a cycle + // through it, if so, we know it will when we hack on it. + unsigned OldTypeHash = ValType::hashTypeStructure(Ty); + + // Find the type element we are refining... and change it now! for (unsigned i = 0, e = Ty->ContainedTys.size(); i != e; ++i) if (Ty->ContainedTys[i] == OldType) { Ty->ContainedTys[i].removeUserFromConcrete(); Ty->ContainedTys[i] = NewType; } + + unsigned TypeHash = ValType::hashTypeStructure(Ty); // If there are no cycles going through this node, we can do a simple, // efficient lookup in the map, instead of an inefficient nasty linear @@ -619,6 +632,7 @@ TypeClass *NewTy = cast((Type*)I->second.get()); // Refined to a different type altogether? + RemoveFromTypesByHash(TypeHash, Ty); Ty->refineAbstractTypeTo(NewTy); return; } @@ -626,27 +640,50 @@ } else { ++NumSlowTypes; - unsigned TypeHash = ValType::hashTypeStructure(Ty); - - - // Now we check to see if there is an existing entry in the table which is // structurally identical to the newly refined type. If so, this type // gets refined to the pre-existing type. // - for (iterator I = Map.begin(), E = Map.end(); I != E; ++I) { - ++NumTypeEquals; - if (TypesEqual(Ty, I->second)) { - assert(Ty->isAbstract() && "Replacing a non-abstract type?"); - TypeClass *NewTy = cast((Type*)I->second.get()); - - // Refined to a different type altogether? - Ty->refineAbstractTypeTo(NewTy); - return; + std::multimap::iterator I,E, Entry; + tie(I, E) = TypesByHash.equal_range(TypeHash); + Entry = E; + for (; I != E; ++I) { + ++NumTypeEqualsCalls; + if (I->second != Ty) { + if (TypesEqual(Ty, I->second)) { + ++NumTypeEquals; + + assert(Ty->isAbstract() && "Replacing a non-abstract type?"); + TypeClass *NewTy = cast((Type*)I->second.get()); + + if (Entry == E) { + // Find the location of Ty in the TypesByHash structure. + while (I->second != Ty) { + ++I; + assert(I != E && "Structure doesn't contain type??"); + } + Entry = I; + } + + TypesByHash.erase(Entry); + Ty->refineAbstractTypeTo(NewTy); + return; + } + } else { + // Remember the position of + Entry = I; } } } + // If we succeeded, we need to insert the type into the cycletypes table. + // There are several cases here, depending on whether the original type + // had the same hash code and was itself cyclic. + if (TypeHash != OldTypeHash) { + RemoveFromTypesByHash(OldTypeHash, Ty); + TypesByHash.insert(std::make_pair(TypeHash, Ty)); + } + // If there is no existing type of the same structure, we reinsert an // updated record into the map. Map.insert(std::make_pair(ValType::get(Ty), Ty)); @@ -662,17 +699,6 @@ } } - void remove(const ValType &OldVal) { - iterator I = Map.find(OldVal); - assert(I != Map.end() && "TypeMap::remove, element not found!"); - Map.erase(I); - } - - void remove(iterator I) { - assert(I != Map.end() && "Cannot remove invalid iterator pointer!"); - Map.erase(I); - } - void print(const char *Arg) const { #ifdef DEBUG_MERGE_TYPES std::cerr << "TypeMap<>::" << Arg << " table contents:\n"; @@ -710,7 +736,7 @@ static FunctionValType get(const FunctionType *FT); static unsigned hashTypeStructure(const FunctionType *FT) { - return 0; + return FT->getNumParams()*2+FT->isVarArg(); } // Subclass should override this... to update self as usual @@ -774,7 +800,7 @@ } static unsigned hashTypeStructure(const ArrayType *AT) { - return 0; + return AT->getNumElements(); } // Subclass should override this... to update self as usual @@ -830,7 +856,7 @@ } static unsigned hashTypeStructure(const StructType *ST) { - return 0; + return ST->getNumElements(); } // Subclass should override this... to update self as usual @@ -913,14 +939,6 @@ return PT; } -namespace llvm { -void debug_type_tables() { - FunctionTypes.dump(); - ArrayTypes.dump(); - StructTypes.dump(); - PointerTypes.dump(); -} -} //===----------------------------------------------------------------------===// // Derived Type Refinement Functions From gaeke at cs.uiuc.edu Mon Feb 9 12:43:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Mon Feb 9 12:43:01 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/InstrSched/SchedGraph.cpp Message-ID: <200402091842.MAA09346@seraph.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/InstrSched: SchedGraph.cpp updated: 1.54 -> 1.55 --- Log message: Make SchedGraph::dump() use SchedGraphNodeCommon's const_iterator instead of randomly groping about inside its outEdges array. Make SchedGraph::addDummyEdges() use getNumOutEdges() instead of outEdges.size(). Get rid of ifdefed-out code in SchedGraph::buildGraph(). --- Diffs of the changes: (+14 -25) Index: llvm/lib/CodeGen/InstrSched/SchedGraph.cpp diff -u llvm/lib/CodeGen/InstrSched/SchedGraph.cpp:1.54 llvm/lib/CodeGen/InstrSched/SchedGraph.cpp:1.55 --- llvm/lib/CodeGen/InstrSched/SchedGraph.cpp:1.54 Sun Dec 14 07:24:16 2003 +++ llvm/lib/CodeGen/InstrSched/SchedGraph.cpp Mon Feb 9 12:42:05 2004 @@ -100,26 +100,24 @@ } void SchedGraph::dump() const { - std::cerr << " Sched Graph for Basic Block: "; - std::cerr << MBB.getBasicBlock()->getName() - << " (" << MBB.getBasicBlock() << ")"; - - std::cerr << "\n\n Actual Root nodes : "; - for (unsigned i=0, N=graphRoot->outEdges.size(); i < N; i++) - std::cerr << graphRoot->outEdges[i]->getSink()->getNodeId() - << ((i == N-1)? "" : ", "); - + std::cerr << " Sched Graph for Basic Block: " + << MBB.getBasicBlock()->getName() + << " (" << MBB.getBasicBlock() << ")" + << "\n\n Actual Root nodes: "; + for (SchedGraphNodeCommon::const_iterator I = graphRoot->beginOutEdges(), + E = graphRoot->endOutEdges(); + I != E; ++I) { + std::cerr << (*I)->getSink ()->getNodeId (); + if (I + 1 != E) { std::cerr << ", "; } + } std::cerr << "\n Graph Nodes:\n"; - for (const_iterator I=begin(); I != end(); ++I) + for (const_iterator I = begin(), E = end(); I != E; ++I) std::cerr << "\n" << *I->second; - std::cerr << "\n"; } - - void SchedGraph::addDummyEdges() { - assert(graphRoot->outEdges.size() == 0); + assert(graphRoot->getNumOutEdges() == 0); for (const_iterator I=begin(); I != end(); ++I) { SchedGraphNode* node = (*I).second; @@ -635,19 +633,10 @@ // Then add incoming def-use (SSA) edges for each machine instruction. for (unsigned i=0, N=MBB.size(); i < N; i++) addEdgesForInstruction(*MBB[i], valueToDefVecMap, target); - -#ifdef NEED_SEPARATE_NONSSA_EDGES_CODE - // Then add non-SSA edges for all VM instructions in the block. - // We assume that all machine instructions that define a value are - // generated from the VM instruction corresponding to that value. - // TODO: This could probably be done much more efficiently. - for (BasicBlock::const_iterator II = bb->begin(); II != bb->end(); ++II) - this->addNonSSAEdgesForValue(*II, target); -#endif //NEED_SEPARATE_NONSSA_EDGES_CODE - + // Then add edges for dependences on machine registers this->addMachineRegEdges(regToRefVecMap, target); - + // Finally, add edges from the dummy root and to dummy leaf this->addDummyEdges(); } From gaeke at cs.uiuc.edu Mon Feb 9 12:43:03 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Mon Feb 9 12:43:03 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/InstrSched/InstrScheduling.cpp Message-ID: <200402091842.MAA09361@seraph.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/InstrSched: InstrScheduling.cpp updated: 1.62 -> 1.63 --- Log message: Move InstrSchedule's iterator begin/end methods inline. --- Diffs of the changes: (+4 -28) Index: llvm/lib/CodeGen/InstrSched/InstrScheduling.cpp diff -u llvm/lib/CodeGen/InstrSched/InstrScheduling.cpp:1.62 llvm/lib/CodeGen/InstrSched/InstrScheduling.cpp:1.63 --- llvm/lib/CodeGen/InstrSched/InstrScheduling.cpp:1.62 Tue Nov 11 16:41:32 2003 +++ llvm/lib/CodeGen/InstrSched/InstrScheduling.cpp Mon Feb 9 12:42:46 2004 @@ -149,10 +149,10 @@ typedef ScheduleIterator iterator; typedef ScheduleIterator const_iterator; - iterator begin(); - const_iterator begin() const; - iterator end(); - const_iterator end() const; + iterator begin() { return iterator::begin(*this); } + const_iterator begin() const { return const_iterator::begin(*this); } + iterator end() { return iterator::end(*this); } + const_iterator end() const { return const_iterator::end(*this); } public: // constructors and destructor /*ctor*/ InstrSchedule (unsigned int _nslots, @@ -278,30 +278,6 @@ ScheduleIterator<_NodeType>::end(const InstrSchedule& _schedule) { return _Self(_schedule, _schedule.groups.size(), 0); -} - -InstrSchedule::iterator -InstrSchedule::begin() -{ - return iterator::begin(*this); -} - -InstrSchedule::const_iterator -InstrSchedule::begin() const -{ - return const_iterator::begin(*this); -} - -InstrSchedule::iterator -InstrSchedule::end() -{ - return iterator::end(*this); -} - -InstrSchedule::const_iterator -InstrSchedule::end() const -{ - return const_iterator::end( *this); } From gaeke at cs.uiuc.edu Mon Feb 9 12:44:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Mon Feb 9 12:44:01 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/SchedGraphCommon.h Message-ID: <200402091843.MAA09373@seraph.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: SchedGraphCommon.h updated: 1.9 -> 1.10 --- Log message: SchedGraph doesn't need to be friends with SchedGraphNodeCommon anymore. --- Diffs of the changes: (+0 -1) Index: llvm/include/llvm/CodeGen/SchedGraphCommon.h diff -u llvm/include/llvm/CodeGen/SchedGraphCommon.h:1.9 llvm/include/llvm/CodeGen/SchedGraphCommon.h:1.10 --- llvm/include/llvm/CodeGen/SchedGraphCommon.h:1.9 Tue Jan 20 11:49:42 2004 +++ llvm/include/llvm/CodeGen/SchedGraphCommon.h Mon Feb 9 12:43:06 2004 @@ -72,7 +72,6 @@ virtual void print(std::ostream &os) const = 0; protected: - friend class SchedGraph; friend class SchedGraphCommon; friend class SchedGraphEdge; // give access for adding edges From lattner at cs.uiuc.edu Mon Feb 9 12:55:03 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Feb 9 12:55:03 2004 Subject: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y Message-ID: <200402091854.MAA03023@zion.cs.uiuc.edu> Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.154 -> 1.155 --- Log message: When resolving upreferences, if multiple uprefs will be resolved to the same type at the same time, resolve the upreferences to each other before resolving it to the outer type. This shaves off some time from the testcase in PR224, from 25.41s -> 21.72s. --- Diffs of the changes: (+24 -6) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.154 llvm/lib/AsmParser/llvmAsmParser.y:1.155 --- llvm/lib/AsmParser/llvmAsmParser.y:1.154 Sun Feb 8 22:37:27 2004 +++ llvm/lib/AsmParser/llvmAsmParser.y Mon Feb 9 12:53:54 2004 @@ -626,6 +626,13 @@ UR_OUT("Type '" << Ty->getDescription() << "' newly formed. Resolving upreferences.\n" << UpRefs.size() << " upreferences active!\n"); + + // If we find any resolvable upreferences (i.e., those whose NestingLevel goes + // to zero), we resolve them all together before we resolve them to Ty. At + // the end of the loop, if there is anything to resolve to Ty, it will be in + // this variable. + OpaqueType *TypeToResolve = 0; + for (unsigned i = 0; i != UpRefs.size(); ++i) { UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", " << UpRefs[i].second->getDescription() << ") = " @@ -636,16 +643,27 @@ UpRefs[i].LastContainedTy = Ty; UR_OUT(" Uplevel Ref Level = " << Level << "\n"); if (Level == 0) { // Upreference should be resolved! - UR_OUT(" * Resolving upreference for " - << UpRefs[i].second->getDescription() << "\n"; - std::string OldName = UpRefs[i].UpRefTy->getDescription()); - UpRefs[i].UpRefTy->refineAbstractTypeTo(Ty); - UR_OUT(" * Type '" << OldName << "' refined upreference to: " - << (const void*)Ty << ", " << Ty->getDescription() << "\n"); + if (!TypeToResolve) { + TypeToResolve = UpRefs[i].UpRefTy; + } else { + UR_OUT(" * Resolving upreference for " + << UpRefs[i].second->getDescription() << "\n"; + std::string OldName = UpRefs[i].UpRefTy->getDescription()); + UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve); + UR_OUT(" * Type '" << OldName << "' refined upreference to: " + << (const void*)Ty << ", " << Ty->getDescription() << "\n"); + } UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list... --i; // Do not skip the next element... } } + } + + if (TypeToResolve) { + UR_OUT(" * Resolving upreference for " + << UpRefs[i].second->getDescription() << "\n"; + std::string OldName = UpRefs[i].UpRefTy->getDescription()); + TypeToResolve->refineAbstractTypeTo(Ty); } return Ty; From lattner at cs.uiuc.edu Mon Feb 9 14:24:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Feb 9 14:24:01 2004 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Type.cpp Message-ID: <200402092023.OAA27060@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Type.cpp updated: 1.92 -> 1.93 --- Log message: Speed up type resolution some more. On the testcase in PR224, for example, this speeds up a release llvm-as from 21.95s to 11.21s, because before it would do an expensive traversal of the type-graph of every type resolved. --- Diffs of the changes: (+27 -8) Index: llvm/lib/VMCore/Type.cpp diff -u llvm/lib/VMCore/Type.cpp:1.92 llvm/lib/VMCore/Type.cpp:1.93 --- llvm/lib/VMCore/Type.cpp:1.92 Mon Feb 9 12:32:40 2004 +++ llvm/lib/VMCore/Type.cpp Mon Feb 9 14:23:44 2004 @@ -526,17 +526,36 @@ return TypesEqual(Ty, Ty2, EqTypes); } +// TypeHasCycleThrough - Return true there is a path from CurTy to TargetTy in +// the type graph. We know that Ty is an abstract type, so if we ever reach a +// non-abstract type, we know that we don't need to search the subgraph. +static bool TypeHasCycleThrough(const Type *TargetTy, const Type *CurTy, + std::set &VisitedTypes) { + if (TargetTy == CurTy) return true; + if (!CurTy->isAbstract()) return false; + + std::set::iterator VTI = VisitedTypes.lower_bound(CurTy); + if (VTI != VisitedTypes.end() && *VTI == CurTy) + return false; + VisitedTypes.insert(VTI, CurTy); + + for (Type::subtype_iterator I = CurTy->subtype_begin(), + E = CurTy->subtype_end(); I != E; ++I) + if (TypeHasCycleThrough(TargetTy, *I, VisitedTypes)) + return true; + return false; +} + + /// TypeHasCycleThroughItself - Return true if the specified type has a cycle /// back to itself. static bool TypeHasCycleThroughItself(const Type *Ty) { + assert(Ty->isAbstract() && "This code assumes that Ty was abstract!"); std::set VisitedTypes; - for (Type::subtype_iterator I = Ty->subtype_begin(), - E = Ty->subtype_end(); I != E; ++I) - for (df_ext_iterator > - DFI = df_ext_begin(I->get(), VisitedTypes), - E = df_ext_end(I->get(), VisitedTypes); DFI != E; ++DFI) - if (*DFI == Ty) - return true; // Found a cycle through ty! + for (Type::subtype_iterator I = Ty->subtype_begin(), E = Ty->subtype_end(); + I != E; ++I) + if (TypeHasCycleThrough(Ty, *I, VisitedTypes)) + return true; return false; } @@ -622,7 +641,7 @@ // If there are no cycles going through this node, we can do a simple, // efficient lookup in the map, instead of an inefficient nasty linear // lookup. - bool TypeHasCycle = TypeHasCycleThroughItself(Ty); + bool TypeHasCycle = Ty->isAbstract() && TypeHasCycleThroughItself(Ty); if (!TypeHasCycle) { iterator I = Map.find(ValType::get(Ty)); if (I != Map.end()) { From lattner at cs.uiuc.edu Mon Feb 9 15:02:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Feb 9 15:02:02 2004 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Type.cpp Message-ID: <200402092101.PAA04384@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Type.cpp updated: 1.93 -> 1.94 --- Log message: Remove the statistics --- Diffs of the changes: (+0 -11) Index: llvm/lib/VMCore/Type.cpp diff -u llvm/lib/VMCore/Type.cpp:1.93 llvm/lib/VMCore/Type.cpp:1.94 --- llvm/lib/VMCore/Type.cpp:1.93 Mon Feb 9 14:23:44 2004 +++ llvm/lib/VMCore/Type.cpp Mon Feb 9 15:01:23 2004 @@ -17,15 +17,9 @@ #include "Support/DepthFirstIterator.h" #include "Support/StringExtras.h" #include "Support/STLExtras.h" -#include "Support/Statistic.h" #include - using namespace llvm; -static Statistic<> NumSlowTypes("type", "num slow types"); -static Statistic<> NumTypeEqualsCalls("type", "num typeequals calls"); -static Statistic<> NumTypeEquals("type", "num types actually equal"); - // DEBUG_MERGE_TYPES - Enable this #define to see how and when derived types are // created and later destroyed, all in an effort to make sure that there is only // a single canonical version of a type. @@ -657,8 +651,6 @@ } } else { - ++NumSlowTypes; - // Now we check to see if there is an existing entry in the table which is // structurally identical to the newly refined type. If so, this type // gets refined to the pre-existing type. @@ -667,11 +659,8 @@ tie(I, E) = TypesByHash.equal_range(TypeHash); Entry = E; for (; I != E; ++I) { - ++NumTypeEqualsCalls; if (I->second != Ty) { if (TypesEqual(Ty, I->second)) { - ++NumTypeEquals; - assert(Ty->isAbstract() && "Replacing a non-abstract type?"); TypeClass *NewTy = cast((Type*)I->second.get()); From lattner at cs.uiuc.edu Mon Feb 9 15:04:05 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Feb 9 15:04:05 2004 Subject: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y Message-ID: <200402092103.PAA05168@zion.cs.uiuc.edu> Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.155 -> 1.156 --- Log message: It turns out that the two dimensional vectors were causing big slowdowns in this for programs with lots of types (like the testcase in PR224). The problem was that the type ID that the outer vector was using was not very dense (as many types are getting resolved), so the vector is large and gets reallocated a lot. Since there are a lot of values in the program (the .ll file is 10M), each reallocation has to copy the subvectors, which is also quite slow (this wouldn't be a problem if C++ supported move semantics, but it doesn't, at least not yet :( Changing the outer data structure to a map speeds a release build of llvm-as up from 11.21s to 5.13s on the testcase in PR224. --- Diffs of the changes: (+34 -32) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.155 llvm/lib/AsmParser/llvmAsmParser.y:1.156 --- llvm/lib/AsmParser/llvmAsmParser.y:1.155 Mon Feb 9 12:53:54 2004 +++ llvm/lib/AsmParser/llvmAsmParser.y Mon Feb 9 15:03:38 2004 @@ -57,14 +57,14 @@ // destroyed when the function is completed. // typedef std::vector ValueList; // Numbered defs -static void ResolveDefinitions(std::vector &LateResolvers, - std::vector *FutureLateResolvers = 0); +static void ResolveDefinitions(std::map &LateResolvers, + std::map *FutureLateResolvers = 0); static struct PerModuleInfo { Module *CurrentModule; - std::vector Values; // Module level numbered definitions - std::vector LateResolveValues; - std::vector Types; + std::map Values; // Module level numbered definitions + std::map LateResolveValues; + std::vector Types; std::map LateResolveTypes; // GlobalRefs - This maintains a mapping between 's and forward @@ -142,8 +142,8 @@ static struct PerFunctionInfo { Function *CurrentFunction; // Pointer to current function being created - std::vector Values; // Keep track of numbered definitions - std::vector LateResolveValues; + std::map Values; // Keep track of numbered definitions + std::map LateResolveValues; std::vector Types; std::map LateResolveTypes; SymbolTable LocalSymtab; @@ -170,11 +170,11 @@ FID = ValID::create((char*)CurrentFunction->getName().c_str()); } else { unsigned Slot = CurrentFunction->getType()->getUniqueID(); - assert(CurModule.Values.size() > Slot && "Function not inserted?"); // Figure out which slot number if is... + ValueList &List = CurModule.Values[Slot]; for (unsigned i = 0; ; ++i) { - assert(i < CurModule.Values[Slot].size() && "Function not found!"); - if (CurModule.Values[Slot][i] == CurrentFunction) { + assert(i < List.size() && "Function not found!"); + if (List[i] == CurrentFunction) { FID = ValID::create((int)i); break; } @@ -198,16 +198,15 @@ //===----------------------------------------------------------------------===// static int InsertValue(Value *D, - std::vector &ValueTab = CurFun.Values) { + std::map &ValueTab = CurFun.Values) { if (D->hasName()) return -1; // Is this a numbered definition? // Yes, insert the value into the value table... unsigned type = D->getType()->getUniqueID(); - if (ValueTab.size() <= type) - ValueTab.resize(type+1, ValueList()); //printf("Values[%d][%d] = %d\n", type, ValueTab[type].size(), D); - ValueTab[type].push_back(D); - return ValueTab[type].size()-1; + ValueList &List = ValueTab[type]; + List.push_back(D); + return List.size()-1; } // TODO: FIXME when Type are not const @@ -297,20 +296,21 @@ unsigned Num = (unsigned)D.Num; // Module constants occupy the lowest numbered slots... - if (type < CurModule.Values.size()) { - if (Num < CurModule.Values[type].size()) - return CurModule.Values[type][Num]; - - Num -= CurModule.Values[type].size(); + std::map::iterator VI = CurModule.Values.find(type); + if (VI != CurModule.Values.end()) { + if (Num < VI->second.size()) + return VI->second[Num]; + Num -= VI->second.size(); } // Make sure that our type is within bounds - if (CurFun.Values.size() <= type) return 0; + VI = CurFun.Values.find(type); + if (VI == CurFun.Values.end()) return 0; // Check that the number is within bounds... - if (CurFun.Values[type].size() <= Num) return 0; + if (VI->second.size() <= Num) return 0; - return CurFun.Values[type][Num]; + return VI->second[Num]; } case ValID::NameVal: { // Is it a named definition? @@ -415,18 +415,20 @@ // time (forward branches, phi functions for loops, etc...) resolve the // defs now... // -static void ResolveDefinitions(std::vector &LateResolvers, - std::vector *FutureLateResolvers) { +static void ResolveDefinitions(std::map &LateResolvers, + std::map *FutureLateResolvers) { // Loop over LateResolveDefs fixing up stuff that couldn't be resolved - for (unsigned ty = 0; ty < LateResolvers.size(); ty++) { - while (!LateResolvers[ty].empty()) { - Value *V = LateResolvers[ty].back(); + for (std::map::iterator LRI = LateResolvers.begin(), + E = LateResolvers.end(); LRI != E; ++LRI) { + ValueList &List = LRI->second; + while (!List.empty()) { + Value *V = List.back(); + List.pop_back(); assert(!isa(V) && "Types should be in LateResolveTypes!"); - - LateResolvers[ty].pop_back(); ValID &DID = getValIDFromPlaceHolder(V); - Value *TheRealValue = getValNonImprovising(Type::getUniqueIDType(ty),DID); + Value *TheRealValue = + getValNonImprovising(Type::getUniqueIDType(LRI->first), DID); if (TheRealValue) { V->replaceAllUsesWith(TheRealValue); delete V; @@ -662,7 +664,7 @@ if (TypeToResolve) { UR_OUT(" * Resolving upreference for " << UpRefs[i].second->getDescription() << "\n"; - std::string OldName = UpRefs[i].UpRefTy->getDescription()); + std::string OldName = TypeToResolve->getDescription()); TypeToResolve->refineAbstractTypeTo(Ty); } From lattner at cs.uiuc.edu Mon Feb 9 15:17:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Feb 9 15:17:02 2004 Subject: [llvm-commits] CVS: llvm/docs/ReleaseNotes.html Message-ID: <200402092116.PAA07628@zion.cs.uiuc.edu> Changes in directory llvm/docs: ReleaseNotes.html updated: 1.115 -> 1.116 --- Log message: QOI bug fixed --- Diffs of the changes: (+2 -1) Index: llvm/docs/ReleaseNotes.html diff -u llvm/docs/ReleaseNotes.html:1.115 llvm/docs/ReleaseNotes.html:1.116 --- llvm/docs/ReleaseNotes.html:1.115 Sun Feb 8 16:23:33 2004 +++ llvm/docs/ReleaseNotes.html Mon Feb 9 15:16:16 2004 @@ -115,6 +115,7 @@
  • [llvmgcc] C front-end does not compile "extern inline" into linkonce
  • Bytecode format inconsistent
  • [loadvn/inline/scalarrepl] Slow optimizations with extremely large basic blocks
  • +
  • [asmparser] Really slow parsing of types with complex upreferences
  • @@ -597,7 +598,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/02/08 22:23:33 $ + Last modified: $Date: 2004/02/09 21:16:16 $ From lattner at cs.uiuc.edu Mon Feb 9 15:24:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Feb 9 15:24:01 2004 Subject: [llvm-commits] CVS: llvm/docs/ReleaseNotes.html Message-ID: <200402092123.PAA08671@zion.cs.uiuc.edu> Changes in directory llvm/docs: ReleaseNotes.html updated: 1.116 -> 1.117 --- Log message: Many things have been fixed, so move them out of the "known problems" section Also, PR137 is a code quality PR, not a bug --- Diffs of the changes: (+3 -33) Index: llvm/docs/ReleaseNotes.html diff -u llvm/docs/ReleaseNotes.html:1.116 llvm/docs/ReleaseNotes.html:1.117 --- llvm/docs/ReleaseNotes.html:1.116 Mon Feb 9 15:16:16 2004 +++ llvm/docs/ReleaseNotes.html Mon Feb 9 15:22:51 2004 @@ -158,6 +158,7 @@
  • [constantmerge] Merging globals can cause use of invalid pointers!
  • [bcreader] Bytecode reader misreads 'long -9223372036854775808'!
  • +
  • Tail duplication does not update SSA form correctly.
  • VMCore mishandles double -0.0
  • [X86] X86 backend code generates -0.0 as +0.0
  • [loopsimplify] Loopsimplify incorrectly updates dominator information
  • @@ -165,6 +166,7 @@ +

    Bugs in the C/C++ front-end:

      @@ -250,18 +252,7 @@ does not link objects/archives in the order specified on the command line. - -
    1. - -Tail duplication does not update SSA form correctly. - -
    2. - -
    3. [lowerinvoke] The -lowerinvoke pass -does not insert calls to setjmp/longjmp.
    4. - - @@ -288,21 +279,6 @@ with the largest union member. - -
    5. - -Functions marked "extern inline" are not compiled into LLVM with linkonce -linkage. - -
    6. - - -
    7. -The memory management functions in the libc runtime -need weak linkage so that they can be -overridden. - -
    8. @@ -471,12 +447,6 @@ @@ -598,7 +568,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
      - Last modified: $Date: 2004/02/09 21:16:16 $ + Last modified: $Date: 2004/02/09 21:22:51 $ From lattner at cs.uiuc.edu Mon Feb 9 15:27:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Feb 9 15:27:01 2004 Subject: [llvm-commits] CVS: llvm-www/releases/1.1/docs/ReleaseNotes.html Message-ID: <200402092126.PAA09564@zion.cs.uiuc.edu> Changes in directory llvm-www/releases/1.1/docs: ReleaseNotes.html updated: 1.21 -> 1.22 --- Log message: Update for some things that are fixed in 1.2 --- Diffs of the changes: (+5 -24) Index: llvm-www/releases/1.1/docs/ReleaseNotes.html diff -u llvm-www/releases/1.1/docs/ReleaseNotes.html:1.21 llvm-www/releases/1.1/docs/ReleaseNotes.html:1.22 --- llvm-www/releases/1.1/docs/ReleaseNotes.html:1.21 Sun Feb 8 15:20:56 2004 +++ llvm-www/releases/1.1/docs/ReleaseNotes.html Mon Feb 9 15:26:09 2004 @@ -339,11 +339,6 @@ - - -
      @@ -429,25 +424,14 @@ union member. -
    9. - -Functions marked "extern inline" are not compiled into LLVM with linkonce -linkage. - -
    10. - - -
    11. -The memory management functions in the libc runtime -need weak linkage so that they can be -overridden. - -
    12. - Bugs in 1.1 fixed in 1.2: @@ -620,9 +604,6 @@
    13. The C++ front-end inherits all problems afflicting the C front-end.
    14. -
    15. Code is generated for empty classes. -
    16. - Bugs in 1.1 fixed in 1.2:
      • [llvmg++] Dynamically initialized constants cannot be marked 'constant'
      • @@ -763,7 +744,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
        - Last modified: $Date: 2004/02/08 21:20:56 $ + Last modified: $Date: 2004/02/09 21:26:09 $ From criswell at cs.uiuc.edu Mon Feb 9 16:16:02 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Mon Feb 9 16:16:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/EmitAssembly.cpp Message-ID: <200402092215.QAA30194@choi.cs.uiuc.edu> Changes in directory llvm/lib/Target/Sparc: EmitAssembly.cpp updated: 1.101 -> 1.102 --- Log message: Fix PR#226: When emitting padding, always emit it as bytes. Bytes can be placed into any alignment situation. --- Diffs of the changes: (+5 -8) Index: llvm/lib/Target/Sparc/EmitAssembly.cpp diff -u llvm/lib/Target/Sparc/EmitAssembly.cpp:1.101 llvm/lib/Target/Sparc/EmitAssembly.cpp:1.102 --- llvm/lib/Target/Sparc/EmitAssembly.cpp:1.101 Thu Jan 15 16:44:19 2004 +++ llvm/lib/Target/Sparc/EmitAssembly.cpp Mon Feb 9 16:15:33 2004 @@ -184,14 +184,11 @@ } void PrintZeroBytesToPad(int numBytes) { - for (/* no init */; numBytes >= 8; numBytes -= 8) - printSingleConstantValue(Constant::getNullValue(Type::ULongTy)); - - if (numBytes >= 4) { - printSingleConstantValue(Constant::getNullValue(Type::UIntTy)); - numBytes -= 4; - } - + // + // Always use single unsigned bytes for padding. We don't know upon + // what data size the beginning address is aligned, so using anything + // other than a byte may cause alignment errors in the assembler. + // while (numBytes--) printSingleConstantValue(Constant::getNullValue(Type::UByteTy)); } From alkis at cs.uiuc.edu Mon Feb 9 16:42:02 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Mon Feb 9 16:42:02 2004 Subject: [llvm-commits] CVS: llvm/include/Support/ilist Message-ID: <200402092241.QAA01510@zion.cs.uiuc.edu> Changes in directory llvm/include/Support: ilist updated: 1.17 -> 1.18 --- Log message: Add global methods that prevent us from using ilist::iterators as random access iterators. --- Diffs of the changes: (+12 -0) Index: llvm/include/Support/ilist diff -u llvm/include/Support/ilist:1.17 llvm/include/Support/ilist:1.18 --- llvm/include/Support/ilist:1.17 Sat Feb 7 18:51:31 2004 +++ llvm/include/Support/ilist Mon Feb 9 16:40:50 2004 @@ -156,6 +156,18 @@ pointer getNodePtrUnchecked() const { return NodePtr; } }; +// do not implement. this is to catch errors when people try to use +// them as random access iterators +template +void operator-(int, ilist_iterator); +template +void operator-(ilist_iterator,int); + +template +void operator+(int, ilist_iterator); +template +void operator+(ilist_iterator,int); + //===----------------------------------------------------------------------===// // ilist_compat_iterator - Compatibility iterator for intrusive list. // This makes an ilist act like an std::list, where you have to From lattner at cs.uiuc.edu Mon Feb 9 16:49:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Feb 9 16:49:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/LowerInvoke.cpp Message-ID: <200402092248.QAA05308@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: LowerInvoke.cpp updated: 1.9 -> 1.10 --- Log message: Only add the global variable with the abort message if an unwind actually occurs in the program. --- Diffs of the changes: (+26 -14) Index: llvm/lib/Transforms/Scalar/LowerInvoke.cpp diff -u llvm/lib/Transforms/Scalar/LowerInvoke.cpp:1.9 llvm/lib/Transforms/Scalar/LowerInvoke.cpp:1.10 --- llvm/lib/Transforms/Scalar/LowerInvoke.cpp:1.9 Sun Feb 8 16:27:33 2004 +++ llvm/lib/Transforms/Scalar/LowerInvoke.cpp Mon Feb 9 16:48:47 2004 @@ -49,6 +49,7 @@ // Used for both models. Function *WriteFn; Function *AbortFn; + Constant *AbortMessageInit; Value *AbortMessage; unsigned AbortMessageLength; @@ -76,6 +77,7 @@ // current module. bool LowerInvoke::doInitialization(Module &M) { const Type *VoidPtrTy = PointerType::get(Type::SByteTy); + AbortMessage = 0; if (ExpensiveEHSupport) { // Insert a type for the linked list of jump buffers. Unfortunately, we // don't know the size of the target's setjmp buffer, so we make a guess. @@ -115,17 +117,17 @@ Constant *Msg = ConstantArray::get("ERROR: Exception thrown, but not caught!\n"); AbortMessageLength = Msg->getNumOperands()-1; // don't include \0 + AbortMessageInit = Msg; GlobalVariable *MsgGV = M.getGlobalVariable("abort.msg", Msg->getType()); if (MsgGV && (!MsgGV->hasInitializer() || MsgGV->getInitializer() != Msg)) MsgGV = 0; - if (!MsgGV) - MsgGV = new GlobalVariable(Msg->getType(), true, - GlobalValue::InternalLinkage, - Msg, "abort.msg", &M); - std::vector GEPIdx(2, Constant::getNullValue(Type::LongTy)); - AbortMessage = - ConstantExpr::getGetElementPtr(ConstantPointerRef::get(MsgGV), GEPIdx); + + if (MsgGV) { + std::vector GEPIdx(2, Constant::getNullValue(Type::LongTy)); + AbortMessage = + ConstantExpr::getGetElementPtr(ConstantPointerRef::get(MsgGV), GEPIdx); + } } else { // The abort message for cheap EH support tells the user that EH is not @@ -134,18 +136,17 @@ ConstantArray::get("Exception handler needed, but not enabled. Recompile" " program with -enable-correct-eh-support.\n"); AbortMessageLength = Msg->getNumOperands()-1; // don't include \0 + AbortMessageInit = Msg; GlobalVariable *MsgGV = M.getGlobalVariable("abort.msg", Msg->getType()); if (MsgGV && (!MsgGV->hasInitializer() || MsgGV->getInitializer() != Msg)) MsgGV = 0; - if (!MsgGV) - MsgGV = new GlobalVariable(Msg->getType(), true, - GlobalValue::InternalLinkage, - Msg, "abort.msg", &M); - std::vector GEPIdx(2, Constant::getNullValue(Type::LongTy)); - AbortMessage = - ConstantExpr::getGetElementPtr(ConstantPointerRef::get(MsgGV), GEPIdx); + if (MsgGV) { + std::vector GEPIdx(2, Constant::getNullValue(Type::LongTy)); + AbortMessage = + ConstantExpr::getGetElementPtr(ConstantPointerRef::get(MsgGV), GEPIdx); + } } // We need the 'write' and 'abort' functions for both models. @@ -173,6 +174,17 @@ void LowerInvoke::writeAbortMessage(Instruction *IB) { if (WriteFn) { + if (!AbortMessage) { + GlobalVariable *MsgGV = new GlobalVariable(AbortMessageInit->getType(), + true, + GlobalValue::InternalLinkage, + AbortMessageInit, "abort.msg", + WriteFn->getParent()); + std::vector GEPIdx(2, Constant::getNullValue(Type::LongTy)); + AbortMessage = + ConstantExpr::getGetElementPtr(ConstantPointerRef::get(MsgGV), GEPIdx); + } + // These are the arguments we WANT... std::vector Args; Args.push_back(ConstantInt::get(Type::IntTy, 2)); From lattner at cs.uiuc.edu Mon Feb 9 16:53:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Feb 9 16:53:02 2004 Subject: [llvm-commits] CVS: llvm/test/Regression/CodeGen/X86/2003-08-03-ReservedWordFunction.llx Message-ID: <200402092252.QAA06493@zion.cs.uiuc.edu> Changes in directory llvm/test/Regression/CodeGen/X86: 2003-08-03-ReservedWordFunction.llx added (r1.1) --- Log message: Move this testcase out of /home/vadve/lattner/cvs/llvm/test/Programs/LLVMSource, as it fails. --- Diffs of the changes: (+13 -0) Index: llvm/test/Regression/CodeGen/X86/2003-08-03-ReservedWordFunction.llx diff -c /dev/null llvm/test/Regression/CodeGen/X86/2003-08-03-ReservedWordFunction.llx:1.1 *** /dev/null Mon Feb 9 16:52:35 2004 --- llvm/test/Regression/CodeGen/X86/2003-08-03-ReservedWordFunction.llx Mon Feb 9 16:52:25 2004 *************** *** 0 **** --- 1,13 ---- + ; This testcase ensures the code emitter does something about the fact that + ; we can have collisions with keywords + + ; RUN: llvm-as < %s | llc | not grep '^byte:' + + void %byte() { + ret void + } + int %main() { + call void %byte() + ret int 0 + } + From lattner at cs.uiuc.edu Mon Feb 9 16:54:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Feb 9 16:54:01 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/LLVMSource/InvokeUnwind.ll Makefile 2003-08-03-ReservedWordFunction.ll Message-ID: <200402092253.QAA06526@zion.cs.uiuc.edu> Changes in directory llvm/test/Programs/LLVMSource: InvokeUnwind.ll updated: 1.1 -> 1.2 Makefile updated: 1.2 -> 1.3 2003-08-03-ReservedWordFunction.ll (r1.2) removed --- Log message: 2003-08-03-ReservedWordFunction.ll fails, move it to a regression test, will file PR soon. InvokeUnwind needed serious 'bring up to speed' work. Enable exceptions for InvokeUnwind test --- Diffs of the changes: (+4 -6) Index: llvm/test/Programs/LLVMSource/InvokeUnwind.ll diff -u llvm/test/Programs/LLVMSource/InvokeUnwind.ll:1.1 llvm/test/Programs/LLVMSource/InvokeUnwind.ll:1.2 --- llvm/test/Programs/LLVMSource/InvokeUnwind.ll:1.1 Sun Aug 24 07:54:06 2003 +++ llvm/test/Programs/LLVMSource/InvokeUnwind.ll Mon Feb 9 16:53:14 2004 @@ -1,17 +1,13 @@ -; Test to make sure the invoke instruction and llvm.unwind intrinsic are -; working... +; Test to make sure the invoke instruction and unwind are working... implementation -declare void %llvm.unwind() declare void %abort() internal void %throw(bool %ShouldThrow) { br bool %ShouldThrow, label %Throw, label %NoThrow Throw: - call void %llvm.unwind() - call void %abort() ;;; dead - ret void + unwind NoThrow: ret void } Index: llvm/test/Programs/LLVMSource/Makefile diff -u llvm/test/Programs/LLVMSource/Makefile:1.2 llvm/test/Programs/LLVMSource/Makefile:1.3 --- llvm/test/Programs/LLVMSource/Makefile:1.2 Tue Jan 13 16:10:05 2004 +++ llvm/test/Programs/LLVMSource/Makefile Mon Feb 9 16:53:14 2004 @@ -6,6 +6,8 @@ LEVEL = ../../.. DISABLE_FOR_LLVM_PROGRAMS := 1 PROGRAM_REQUIRED_TO_EXIT_OK := 1 +REQUIRES_EH_SUPPORT := 1 + PROGRAMS_TO_TEST := $(basename $(wildcard *.ll)) include $(LEVEL)/test/Programs/Makefile.programs From brukman at cs.uiuc.edu Mon Feb 9 17:19:01 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Mon Feb 9 17:19:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/SparcTargetMachine.cpp Message-ID: <200402092318.RAA16422@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/Sparc: SparcTargetMachine.cpp updated: 1.98 -> 1.99 --- Log message: Doxygenify comments. --- Diffs of the changes: (+9 -12) Index: llvm/lib/Target/Sparc/SparcTargetMachine.cpp diff -u llvm/lib/Target/Sparc/SparcTargetMachine.cpp:1.98 llvm/lib/Target/Sparc/SparcTargetMachine.cpp:1.99 --- llvm/lib/Target/Sparc/SparcTargetMachine.cpp:1.98 Tue Jan 13 13:26:21 2004 +++ llvm/lib/Target/Sparc/SparcTargetMachine.cpp Mon Feb 9 17:18:42 2004 @@ -120,9 +120,9 @@ jitInfo(*this) { } -// addPassesToEmitAssembly - This method controls the entire code generation -// process for the ultra sparc. -// +/// addPassesToEmitAssembly - This method controls the entire code generation +/// process for the ultra sparc. +/// bool SparcTargetMachine::addPassesToEmitAssembly(PassManager &PM, std::ostream &Out) { @@ -176,7 +176,6 @@ // function output is pipelined with all of the rest of code generation stuff, // allowing machine code representations for functions to be free'd after the // function has been emitted. - // PM.add(createAsmPrinterPass(Out, *this)); PM.add(createSparcMachineCodeDestructionPass()); // Free mem no longer needed @@ -187,9 +186,9 @@ return false; } -// addPassesToJITCompile - This method controls the JIT method of code -// generation for the UltraSparc. -// +/// addPassesToJITCompile - This method controls the JIT method of code +/// generation for the UltraSparc. +/// void SparcJITInfo::addPassesToJITCompile(FunctionPassManager &PM) { const TargetData &TD = TM.getTargetData(); @@ -230,11 +229,9 @@ PM.add(createPeepholeOptsPass(TM)); } -//---------------------------------------------------------------------------- -// allocateSparcTargetMachine - Allocate and return a subclass of TargetMachine -// that implements the Sparc backend. (the llvm/CodeGen/Sparc.h interface) -//---------------------------------------------------------------------------- - +/// allocateSparcTargetMachine - Allocate and return a subclass of TargetMachine +/// that implements the Sparc backend. (the llvm/CodeGen/Sparc.h interface) +/// TargetMachine *llvm::allocateSparcTargetMachine(const Module &M, IntrinsicLowering *IL) { return new SparcTargetMachine(IL); From gaeke at cs.uiuc.edu Mon Feb 9 19:11:02 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Mon Feb 9 19:11:02 2004 Subject: [llvm-commits] CVS: llvm/Makefile Message-ID: <200402100110.TAA11662@psmith.cs.uiuc.edu> Changes in directory llvm: Makefile updated: 1.21 -> 1.22 --- Log message: Should fix pr220 - "make install" doesn't install header files when BUILD_SRC_ROOT != BUILD_OBJ_ROOT --- Diffs of the changes: (+3 -0) Index: llvm/Makefile diff -u llvm/Makefile:1.21 llvm/Makefile:1.22 --- llvm/Makefile:1.21 Mon Feb 9 11:38:51 2004 +++ llvm/Makefile Mon Feb 9 19:10:01 2004 @@ -34,6 +34,9 @@ install-includes: $(MKDIR) $(DESTDIR)$(includedir)/llvm cd include && find * '!' '(' -name '*~' -o -name .cvsignore ')' -print | grep -v CVS | pax -rwdvpe $(DESTDIR)$(includedir)/llvm +ifneq ($(BUILD_SRC_ROOT),$(BUILD_OBJ_ROOT)) + cd $(BUILD_SRC_ROOT)/include && find * '!' '(' -name '*~' -o -name .cvsignore ')' -print | grep -v CVS | pax -rwdvpe $(DESTDIR)$(includedir)/llvm +endif install:: install-includes From gaeke at gally.cs.uiuc.edu Mon Feb 9 21:59:02 2004 From: gaeke at gally.cs.uiuc.edu (Brian Gaeke) Date: Mon Feb 9 21:59:02 2004 Subject: [llvm-commits] CVS: llvm/llvm.spec Message-ID: <200402100358.i1A3w1I22414@gally.cs.uiuc.edu> Changes in directory llvm: llvm.spec added (r1.1) --- Log message: RPM spec file for LLVM tools and libraries. --- Diffs of the changes: (+56 -0) Index: llvm/llvm.spec diff -c /dev/null llvm/llvm.spec:1.1 *** /dev/null Mon Feb 9 21:58:01 2004 --- llvm/llvm.spec Mon Feb 9 21:57:51 2004 *************** *** 0 **** --- 1,56 ---- + Summary: Static and JIT research compiler infrastructure + Name: llvm + Version: 1.2 + Release: 0 + License: U of Illinois/NCSA Open Source License + Group: Development/Languages + Source0: llvm.tar.gz + URL: http://llvm.cs.uiuc.edu/releases/index.html + #BuildRequires: llvm-gcc + # (someday...) + BuildRoot: %{_tmppath}/%{name}-root + Requires: /sbin/ldconfig + + %description + LLVM is a new infrastructure designed for compile-time, link-time, runtime, + and "idle-time" optimization of programs from arbitrary programming languages. + LLVM is written in C++ and has been developed since 2000 at the + University of Illinois. It currently supports compilation of C and C++ + programs, using front-ends derived from GCC 3.4. + + %prep + %setup -q -n llvm + + %build + ./configure \ + --prefix=%{_prefix} \ + --bindir=%{_bindir} \ + --datadir=%{_datadir} \ + --includedir=%{_includedir} \ + --libdir=%{_libdir} + make + + %install + rm -rf %{buildroot} + make install DESTDIR=%{buildroot} + + %clean + rm -rf %{buildroot} + + %post -p /sbin/ldconfig + + %postun -p /sbin/ldconfig + + %files + %defattr(-, root, root) + %doc CREDITS.TXT LICENSE.TXT README.txt docs/*.{html,css,gif,jpg} docs/CommandGuide + %{_bindir}/* + %{_libdir}/*.o + %{_libdir}/*.a + %{_libdir}/*.so + %{_includedir}/llvm + + %changelog + * Mon Feb 09 2003 Brian R. Gaeke + - Initial working version of RPM spec file. + From elicjs at falcon.mufi.hu Mon Feb 9 22:04:01 2004 From: elicjs at falcon.mufi.hu (Todd Hansen) Date: Mon Feb 9 22:04:01 2004 Subject: [llvm-commits] Promote someone else's online business and cash in big Message-ID: <0x1--x-8u-7p3$cex--$y@g0o4oy.m0k> An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20040209/d8a352f6/attachment.html From 1enndkjtzv at bwl.uni-kiel.de Mon Feb 9 22:04:04 2004 From: 1enndkjtzv at bwl.uni-kiel.de (Cara Leonard) Date: Mon Feb 9 22:04:04 2004 Subject: [llvm-commits] How to cash in on other people's success Message-ID: An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20040209/96a9d7fe/attachment.html From lattner at cs.uiuc.edu Mon Feb 9 23:17:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Feb 9 23:17:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/EmitAssembly.cpp Message-ID: <200402100516.XAA28590@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/Sparc: EmitAssembly.cpp updated: 1.102 -> 1.103 --- Log message: Fix PR228: [sparc] Boolean constants are emitted as true and false I will observe that the concept of using WriteAsOperand is completely broken, but then we all knew that, didn't we? --- Diffs of the changes: (+2 -0) Index: llvm/lib/Target/Sparc/EmitAssembly.cpp diff -u llvm/lib/Target/Sparc/EmitAssembly.cpp:1.102 llvm/lib/Target/Sparc/EmitAssembly.cpp:1.103 --- llvm/lib/Target/Sparc/EmitAssembly.cpp:1.102 Mon Feb 9 16:15:33 2004 +++ llvm/lib/Target/Sparc/EmitAssembly.cpp Mon Feb 9 23:16:44 2004 @@ -340,6 +340,8 @@ toAsm << "\t! " << CV->getType()->getDescription() << " value: " << Val << "\n"; + } else if (const ConstantBool *CB = dyn_cast(CV)) { + toAsm << (int)CB->getValue() << "\n"; } else { WriteAsOperand(toAsm, CV, false, false) << "\n"; } From lattner at cs.uiuc.edu Mon Feb 9 23:21:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Feb 9 23:21:01 2004 Subject: [llvm-commits] CVS: llvm/docs/ReleaseNotes.html Message-ID: <200402100520.XAA29891@zion.cs.uiuc.edu> Changes in directory llvm/docs: ReleaseNotes.html updated: 1.117 -> 1.118 --- Log message: Bug fixed --- Diffs of the changes: (+2 -1) Index: llvm/docs/ReleaseNotes.html diff -u llvm/docs/ReleaseNotes.html:1.117 llvm/docs/ReleaseNotes.html:1.118 --- llvm/docs/ReleaseNotes.html:1.117 Mon Feb 9 15:22:51 2004 +++ llvm/docs/ReleaseNotes.html Mon Feb 9 23:19:54 2004 @@ -163,6 +163,7 @@
      • [X86] X86 backend code generates -0.0 as +0.0
      • [loopsimplify] Loopsimplify incorrectly updates dominator information
      • [pruneeh] -pruneeh pass removes invoke instructions it shouldn't
      • +
      • [sparc] Boolean constants are emitted as true and false
    @@ -568,7 +569,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/02/09 21:22:51 $ + Last modified: $Date: 2004/02/10 05:19:54 $ From lattner at cs.uiuc.edu Mon Feb 9 23:22:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Feb 9 23:22:01 2004 Subject: [llvm-commits] CVS: llvm-www/releases/1.1/docs/ReleaseNotes.html Message-ID: <200402100521.XAA30903@zion.cs.uiuc.edu> Changes in directory llvm-www/releases/1.1/docs: ReleaseNotes.html updated: 1.22 -> 1.23 --- Log message: Bug found. Brian probably hates me right now. --- Diffs of the changes: (+3 -1) Index: llvm-www/releases/1.1/docs/ReleaseNotes.html diff -u llvm-www/releases/1.1/docs/ReleaseNotes.html:1.22 llvm-www/releases/1.1/docs/ReleaseNotes.html:1.23 --- llvm-www/releases/1.1/docs/ReleaseNotes.html:1.22 Mon Feb 9 15:26:09 2004 +++ llvm-www/releases/1.1/docs/ReleaseNotes.html Mon Feb 9 23:20:54 2004 @@ -678,6 +678,8 @@ support the unwind instruction, so code that throws a C++ exception or calls the C longjmp function will abort. +
  • [sparc] Boolean constants are emitted as true and false
  • +
  • The llc program can crash on legal code. @@ -744,7 +746,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/02/09 21:26:09 $ + Last modified: $Date: 2004/02/10 05:20:54 $ From gaeke at cs.uiuc.edu Mon Feb 9 23:23:02 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Mon Feb 9 23:23:02 2004 Subject: [llvm-commits] CVS: llvm/docs/ReleaseNotes.html Message-ID: <200402100522.XAA31167@zion.cs.uiuc.edu> Changes in directory llvm/docs: ReleaseNotes.html updated: 1.118 -> 1.119 --- Log message: Mention install, RPM, autoconf improvements --- Diffs of the changes: (+10 -3) Index: llvm/docs/ReleaseNotes.html diff -u llvm/docs/ReleaseNotes.html:1.118 llvm/docs/ReleaseNotes.html:1.119 --- llvm/docs/ReleaseNotes.html:1.118 Mon Feb 9 23:19:54 2004 +++ llvm/docs/ReleaseNotes.html Mon Feb 9 23:22:23 2004 @@ -120,14 +120,21 @@
    -In this release, the following build problems were fixed: +LLVM gained several improvements to its build and installation +infrastructure in this release. There is now +a autoconf/AutoRegen.sh script that you can run to rebuild the +configure script and its associated files +(Bug 105) as well as beta support +for "make install" (Bug 208 and +Bug 220) and RPM package generation +(Bug 203). +Additionally, in this release, the following build problems were fixed:
    1. [build] Makefiles break if C frontend target string has unexpected value
    2. [build] hard-wired assumption that shared-library extension is ".so"
    3. make tools-only doesn't make lib/Support
    4. -
    5. [build] Usage of autoconf is awkward
    @@ -569,7 +576,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/02/10 05:19:54 $ + Last modified: $Date: 2004/02/10 05:22:23 $ From lattner at cs.uiuc.edu Tue Feb 10 10:26:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 10 10:26:01 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/Makefile.programs Message-ID: <200402101625.KAA02881@zion.cs.uiuc.edu> Changes in directory llvm/test/Programs: Makefile.programs updated: 1.112 -> 1.113 --- Log message: Give bugpoint a chance of actually working out-of-the-box, by linking in libraries so that all symbols (such as __main) are resolved. This should make the 'bugpoint-gccas' "just work". --- Diffs of the changes: (+16 -2) Index: llvm/test/Programs/Makefile.programs diff -u llvm/test/Programs/Makefile.programs:1.112 llvm/test/Programs/Makefile.programs:1.113 --- llvm/test/Programs/Makefile.programs:1.112 Mon Feb 9 10:02:40 2004 +++ llvm/test/Programs/Makefile.programs Tue Feb 10 10:25:44 2004 @@ -201,6 +201,12 @@ Output/%.llvm.stripped.bc: Output/%.llvm.bc $(LOPT) $(LOPT) -mstrip $< -o $@ -f + +$(PROGRAMS_TO_TEST:%=Output/%.noopt-linked.bc): \ +Output/%.noopt-linked.bc: Output/%.linked.rll $(LGCCAS) + $(LGCCAS) $(STATS) -disable-opt $< -o $@ + + ifndef DISABLE_FOR_LLVM_PROGRAMS # Rule to produce final program bytecode file from linked, optimized, bytecode. # Link the program to the libraries it uses, then perform postlink @@ -221,6 +227,14 @@ $(LOPT) -q $(OPTPASSES) < $@ > $@.tmp $(MV) -f $@.tmp $@ endif + +$(PROGRAMS_TO_TEST:%=Output/%.noopt-llvm.bc): \ +Output/%.noopt-llvm.bc: Output/%.noopt-linked.bc $(LGCCLDPROG) + $(LGCCLD) -disable-opt $(STATS) $< -lc $(LIBS) -lcrtend -o Output/$*.noopt-llvm + +$(PROGRAMS_TO_TEST:%=Output/%.noopt-llvm): \ +Output/%.noopt-llvm: Output/%.noopt-linked.bc $(LGCCLDPROG) + $(LGCCLD) -disable-opt $(STATS) $< -lc $(LIBS) -lcrtend -o Output/$*.noopt-llvm endif # ifndef DISABLE_FOR_LLVM_PROGRAMS # Targets to get the pass arguments that gccas and gccld are using... @@ -344,12 +358,12 @@ # Rules to bugpoint the GCCAS, GCCLD, LLC, or LLI commands... $(PROGRAMS_TO_TEST:%=Output/%.bugpoint-gccas): \ -Output/%.bugpoint-gccas: Output/%.linked.rll $(LBUGPOINT) \ +Output/%.bugpoint-gccas: Output/%.noopt-llvm.bc $(LBUGPOINT) \ Output/gccas-pass-args Output/%.out-nat $(LBUGPOINT) $< `cat Output/gccas-pass-args` $(BUGPOINT_OPTIONS) $(PROGRAMS_TO_TEST:%=Output/%.bugpoint-gccld): \ -Output/%.bugpoint-gccld: Output/%.linked.bc $(LBUGPOINT) \ +Output/%.bugpoint-gccld: Output/%.noopt-llvm.bc $(LBUGPOINT) \ Output/gccld-pass-args Output/%.out-nat $(LBUGPOINT) $< `cat Output/gccld-pass-args` $(BUGPOINT_OPTIONS) From lattner at cs.uiuc.edu Tue Feb 10 10:27:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 10 10:27:02 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/External/SPEC/Makefile.spec Message-ID: <200402101626.KAA02896@zion.cs.uiuc.edu> Changes in directory llvm/test/Programs/External/SPEC: Makefile.spec updated: 1.21 -> 1.22 --- Log message: Give bugpoint a chance of actually working out-of-the-box, by linking in libraries so that all symbols (such as __main) are resolved. This should make the 'bugpoint-gccas' "just work". --- Diffs of the changes: (+4 -4) Index: llvm/test/Programs/External/SPEC/Makefile.spec diff -u llvm/test/Programs/External/SPEC/Makefile.spec:1.21 llvm/test/Programs/External/SPEC/Makefile.spec:1.22 --- llvm/test/Programs/External/SPEC/Makefile.spec:1.21 Thu Dec 18 21:32:09 2003 +++ llvm/test/Programs/External/SPEC/Makefile.spec Tue Feb 10 10:25:53 2004 @@ -46,8 +46,8 @@ include $(LEVEL)/test/Programs/MultiSource/Makefile.multisrc # Do not pass -Wall to compile commands... -LCCFLAGS := -O2 -LCXXFLAGS := -O2 +LCCFLAGS := -O3 +LCXXFLAGS := -O3 CPPFLAGS += -DSPEC_CPU2000 -I $(SPEC_BENCH_DIR)/src/ SPEC_SANDBOX := $(LLVM_SRC_ROOT)/test/Programs/External/SPEC/Sandbox.sh @@ -133,14 +133,14 @@ # Rules to bugpoint the GCCAS, GCCLD, LLC, or LLI commands... $(PROGRAMS_TO_TEST:%=Output/%.bugpoint-gccas): \ -Output/%.bugpoint-gccas: Output/%.linked.rll $(LBUGPOINT) \ +Output/%.bugpoint-gccas: Output/%.noopt-llvm.bc $(LBUGPOINT) \ Output/gccas-pass-args Output/%.out-nat $(SPEC_SANDBOX) bugpoint-$(RUN_TYPE) $@ $(REF_IN_DIR) \ $(LBUGPOINT) ../../$< `cat Output/gccas-pass-args` $(BUGPOINT_OPTIONS) @echo "===> Leaving Output/bugpoint-$(RUN_TYPE)" $(PROGRAMS_TO_TEST:%=Output/%.bugpoint-gccld): \ -Output/%.bugpoint-gccld: Output/%.linked.bc $(LBUGPOINT) \ +Output/%.bugpoint-gccld: Output/%.noopt-llvm.bc $(LBUGPOINT) \ Output/gccld-pass-args Output/%.out-nat $(SPEC_SANDBOX) bugpoint-$(RUN_TYPE) $@ $(REF_IN_DIR) \ $(LBUGPOINT) ../../$< `cat Output/gccld-pass-args` $(BUGPOINT_OPTIONS) From brukman at cs.uiuc.edu Tue Feb 10 10:40:04 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Tue Feb 10 10:40:04 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/iOther.h Message-ID: <200402101639.KAA03135@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: iOther.h updated: 1.43 -> 1.44 --- Log message: Doxygen-ify comments, make function prototypes more consistent in format. --- Diffs of the changes: (+8 -5) Index: llvm/include/llvm/iOther.h diff -u llvm/include/llvm/iOther.h:1.43 llvm/include/llvm/iOther.h:1.44 --- llvm/include/llvm/iOther.h:1.43 Sun Dec 7 23:29:33 2003 +++ llvm/include/llvm/iOther.h Tue Feb 10 10:39:05 2004 @@ -56,6 +56,9 @@ // CallInst Class //===----------------------------------------------------------------------===// +/// CallInst - This class represents a function call, abstracting a target +/// machine's calling convention. +/// class CallInst : public Instruction { CallInst(const CallInst &CI); public: @@ -63,10 +66,10 @@ const std::string &Name = "", Instruction *InsertBefore = 0); // Alternate CallInst ctors w/ no actuals & one actual, respectively. - CallInst(Value *F, const std::string &Name = "", - Instruction *InsertBefore = 0); + CallInst(Value *F, const std::string &Name = "", + Instruction *InsertBefore = 0); CallInst(Value *F, Value *Actual, const std::string& Name = "", - Instruction* InsertBefore = 0); + Instruction *InsertBefore = 0); virtual Instruction *clone() const { return new CallInst(*this); } bool mayWriteToMemory() const { return true; } @@ -95,8 +98,8 @@ // ShiftInst Class //===----------------------------------------------------------------------===// -// ShiftInst - This class represents left and right shift instructions. -// +/// ShiftInst - This class represents left and right shift instructions. +/// class ShiftInst : public Instruction { ShiftInst(const ShiftInst &SI) : Instruction(SI.getType(), SI.getOpcode()) { Operands.reserve(2); From criswell at cs.uiuc.edu Tue Feb 10 11:22:00 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Tue Feb 10 11:22:00 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/External/SPEC/CINT95/ Message-ID: <200402101721.LAA01452@choi.cs.uiuc.edu> Changes in directory llvm/test/Programs/External/SPEC/CINT95: --- Log message: Directory /home/vadve/shared/PublicCVS/llvm/test/Programs/External/SPEC/CINT95 added to the repository --- Diffs of the changes: (+0 -0) From criswell at cs.uiuc.edu Tue Feb 10 11:23:02 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Tue Feb 10 11:23:02 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/External/SPEC/CINT95/099.go/ Message-ID: <200402101722.LAA01476@choi.cs.uiuc.edu> Changes in directory llvm/test/Programs/External/SPEC/CINT95/099.go: --- Log message: Directory /home/vadve/shared/PublicCVS/llvm/test/Programs/External/SPEC/CINT95/099.go added to the repository --- Diffs of the changes: (+0 -0) From criswell at cs.uiuc.edu Tue Feb 10 11:23:06 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Tue Feb 10 11:23:06 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/External/SPEC/CINT95/130.li/ Message-ID: <200402101722.LAA01487@choi.cs.uiuc.edu> Changes in directory llvm/test/Programs/External/SPEC/CINT95/130.li: --- Log message: Directory /home/vadve/shared/PublicCVS/llvm/test/Programs/External/SPEC/CINT95/130.li added to the repository --- Diffs of the changes: (+0 -0) From criswell at cs.uiuc.edu Tue Feb 10 11:24:03 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Tue Feb 10 11:24:03 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/External/SPEC/CINT95/099.go/Makefile Message-ID: <200402101723.LAA01500@choi.cs.uiuc.edu> Changes in directory llvm/test/Programs/External/SPEC/CINT95/099.go: Makefile added (r1.1) --- Log message: Adding SPEC95 integer benchmark. --- Diffs of the changes: (+6 -0) Index: llvm/test/Programs/External/SPEC/CINT95/099.go/Makefile diff -c /dev/null llvm/test/Programs/External/SPEC/CINT95/099.go/Makefile:1.1 *** /dev/null Tue Feb 10 11:23:10 2004 --- llvm/test/Programs/External/SPEC/CINT95/099.go/Makefile Tue Feb 10 11:23:00 2004 *************** *** 0 **** --- 1,6 ---- + LEVEL = ../../../../../.. + BM=099.go + STDIN_FILENAME = /dev/null + STDOUT_FILENAME = null.out + RUN_OPTIONS = 40 19 + include ../../Makefile.spec95 From criswell at cs.uiuc.edu Tue Feb 10 11:24:06 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Tue Feb 10 11:24:06 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/External/SPEC/CINT95/130.li/Makefile Message-ID: <200402101723.LAA01512@choi.cs.uiuc.edu> Changes in directory llvm/test/Programs/External/SPEC/CINT95/130.li: Makefile added (r1.1) --- Log message: Adding SPEC95 integer benchmark. --- Diffs of the changes: (+5 -0) Index: llvm/test/Programs/External/SPEC/CINT95/130.li/Makefile diff -c /dev/null llvm/test/Programs/External/SPEC/CINT95/130.li/Makefile:1.1 *** /dev/null Tue Feb 10 11:23:26 2004 --- llvm/test/Programs/External/SPEC/CINT95/130.li/Makefile Tue Feb 10 11:23:16 2004 *************** *** 0 **** --- 1,5 ---- + LEVEL = ../../../../../.. + REQUIRES_EH_SUPPORT = 1 + STDIN_FILENAME := test.lsp + STDOUT_FILENAME := test.out + include ../../Makefile.spec95 From lattner at cs.uiuc.edu Tue Feb 10 11:37:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 10 11:37:01 2004 Subject: [llvm-commits] CVS: llvm/runtime/libprofile/BlockProfiling.c CommonProfiling.c FunctionProfiling.c Profiling.h Message-ID: <200402101736.LAA05133@zion.cs.uiuc.edu> Changes in directory llvm/runtime/libprofile: BlockProfiling.c updated: 1.1 -> 1.2 CommonProfiling.c updated: 1.3 -> 1.4 FunctionProfiling.c updated: 1.1 -> 1.2 Profiling.h updated: 1.1 -> 1.2 --- Log message: Make the initialization calls return argc. --- Diffs of the changes: (+13 -9) Index: llvm/runtime/libprofile/BlockProfiling.c diff -u llvm/runtime/libprofile/BlockProfiling.c:1.1 llvm/runtime/libprofile/BlockProfiling.c:1.2 --- llvm/runtime/libprofile/BlockProfiling.c:1.1 Tue Oct 28 12:56:51 2003 +++ llvm/runtime/libprofile/BlockProfiling.c Tue Feb 10 11:36:25 2004 @@ -34,10 +34,11 @@ /* llvm_start_block_profiling - This is the main entry point of the block * profiling library. It is responsible for setting up the atexit handler. */ -void llvm_start_block_profiling(int argc, const char **argv, - unsigned *arrayStart, unsigned numElements) { - save_arguments(argc, argv); +int llvm_start_block_profiling(int argc, const char **argv, + unsigned *arrayStart, unsigned numElements) { + int Ret = save_arguments(argc, argv); ArrayStart = arrayStart; NumElements = numElements; atexit(BlockProfAtExitHandler); + return Ret; } Index: llvm/runtime/libprofile/CommonProfiling.c diff -u llvm/runtime/libprofile/CommonProfiling.c:1.3 llvm/runtime/libprofile/CommonProfiling.c:1.4 --- llvm/runtime/libprofile/CommonProfiling.c:1.3 Tue Oct 28 16:45:25 2003 +++ llvm/runtime/libprofile/CommonProfiling.c Tue Feb 10 11:36:25 2004 @@ -27,9 +27,9 @@ /* save_arguments - Save argc and argv as passed into the program for the file * we output. */ -void save_arguments(int argc, const char **argv) { +int save_arguments(int argc, const char **argv) { unsigned Length, i; - if (SavedArgs || !argv) return; /* This can be called multiple times */ + if (SavedArgs || !argv) return argc; /* This can be called multiple times */ for (Length = 0, i = 0; i != (unsigned)argc; ++i) Length += strlen(argv[i])+1; @@ -43,6 +43,8 @@ } SavedArgsLength = Length; + + return argc; } Index: llvm/runtime/libprofile/FunctionProfiling.c diff -u llvm/runtime/libprofile/FunctionProfiling.c:1.1 llvm/runtime/libprofile/FunctionProfiling.c:1.2 --- llvm/runtime/libprofile/FunctionProfiling.c:1.1 Tue Oct 28 12:56:51 2003 +++ llvm/runtime/libprofile/FunctionProfiling.c Tue Feb 10 11:36:25 2004 @@ -32,10 +32,11 @@ /* llvm_start_func_profiling - This is the main entry point of the function * profiling library. It is responsible for setting up the atexit handler. */ -void llvm_start_func_profiling(int argc, const char **argv, - unsigned *arrayStart, unsigned numElements) { - save_arguments(argc, argv); +int llvm_start_func_profiling(int argc, const char **argv, + unsigned *arrayStart, unsigned numElements) { + int Ret = save_arguments(argc, argv); ArrayStart = arrayStart; NumElements = numElements; atexit(FuncProfAtExitHandler); + return Ret; } Index: llvm/runtime/libprofile/Profiling.h diff -u llvm/runtime/libprofile/Profiling.h:1.1 llvm/runtime/libprofile/Profiling.h:1.2 --- llvm/runtime/libprofile/Profiling.h:1.1 Tue Oct 28 12:56:51 2003 +++ llvm/runtime/libprofile/Profiling.h Tue Feb 10 11:36:25 2004 @@ -18,7 +18,7 @@ /* save_arguments - Save argc and argv as passed into the program for the file * we output. */ -void save_arguments(int argc, const char **argv); +int save_arguments(int argc, const char **argv); enum ProfilingType { Arguments = 1, /* The command line argument block */ From lattner at cs.uiuc.edu Tue Feb 10 11:42:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 10 11:42:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Instrumentation/BlockProfiling.cpp Message-ID: <200402101741.LAA05643@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Instrumentation: BlockProfiling.cpp updated: 1.5 -> 1.6 --- Log message: initialization calls now return argc. If the program uses the argc value passed into main, make sure they use the return value of the init call instead of the one passed in. --- Diffs of the changes: (+24 -17) Index: llvm/lib/Transforms/Instrumentation/BlockProfiling.cpp diff -u llvm/lib/Transforms/Instrumentation/BlockProfiling.cpp:1.5 llvm/lib/Transforms/Instrumentation/BlockProfiling.cpp:1.6 --- llvm/lib/Transforms/Instrumentation/BlockProfiling.cpp:1.5 Fri Jan 9 00:11:48 2004 +++ llvm/lib/Transforms/Instrumentation/BlockProfiling.cpp Tue Feb 10 11:41:01 2004 @@ -31,7 +31,7 @@ const Type *ArgVTy = PointerType::get(PointerType::get(Type::SByteTy)); const Type *UIntPtr = PointerType::get(Type::UIntTy); Module &M = *MainFn->getParent(); - Function *InitFn = M.getOrInsertFunction(FnName, Type::VoidTy, Type::IntTy, + Function *InitFn = M.getOrInsertFunction(FnName, Type::IntTy, Type::IntTy, ArgVTy, UIntPtr, Type::UIntTy, 0); // This could force argc and argv into programs that wouldn't otherwise have @@ -45,38 +45,45 @@ BasicBlock::iterator InsertPos = Entry->begin(); while (isa(InsertPos)) ++InsertPos; + ConstantPointerRef *ArrayCPR = ConstantPointerRef::get(Array); + std::vector GEPIndices(2, Constant::getNullValue(Type::LongTy)); + Args[2] = ConstantExpr::getGetElementPtr(ArrayCPR, GEPIndices); + + unsigned NumElements = + cast(Array->getType()->getElementType())->getNumElements(); + Args[3] = ConstantUInt::get(Type::UIntTy, NumElements); + + Instruction *InitCall = new CallInst(InitFn, Args, "newargc", InsertPos); + + // If argc or argv are not available in main, just pass null values in. Function::aiterator AI; switch (MainFn->asize()) { default: case 2: AI = MainFn->abegin(); ++AI; if (AI->getType() != ArgVTy) { - Args[1] = new CastInst(AI, ArgVTy, "argv.cast", InsertPos); + InitCall->setOperand(2, new CastInst(AI, ArgVTy, "argv.cast", InitCall)); } else { - Args[1] = AI; + InitCall->setOperand(2, AI); } case 1: AI = MainFn->abegin(); + // If the program looked at argc, have it look at the return value of the + // init call instead. if (AI->getType() != Type::IntTy) { - Args[0] = new CastInst(AI, Type::IntTy, "argc.cast", InsertPos); + if (!AI->use_empty()) + AI->replaceAllUsesWith(new CastInst(InitCall, AI->getType(), "", + InsertPos)); + InitCall->setOperand(1, new CastInst(AI, Type::IntTy, "argc.cast", + InitCall)); } else { - Args[0] = AI; + AI->replaceAllUsesWith(InitCall); + InitCall->setOperand(1, AI); } - case 0: - break; + case 0: break; } - - ConstantPointerRef *ArrayCPR = ConstantPointerRef::get(Array); - std::vector GEPIndices(2, Constant::getNullValue(Type::LongTy)); - Args[2] = ConstantExpr::getGetElementPtr(ArrayCPR, GEPIndices); - - unsigned NumElements = - cast(Array->getType()->getElementType())->getNumElements(); - Args[3] = ConstantUInt::get(Type::UIntTy, NumElements); - - new CallInst(InitFn, Args, "", InsertPos); } static void IncrementCounterInBlock(BasicBlock *BB, unsigned CounterNum, From criswell at cs.uiuc.edu Tue Feb 10 11:49:03 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Tue Feb 10 11:49:03 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/External/SPEC/CINT95/147.vortex/ Message-ID: <200402101748.LAA03847@choi.cs.uiuc.edu> Changes in directory llvm/test/Programs/External/SPEC/CINT95/147.vortex: --- Log message: Directory /home/vadve/shared/PublicCVS/llvm/test/Programs/External/SPEC/CINT95/147.vortex added to the repository --- Diffs of the changes: (+0 -0) From criswell at cs.uiuc.edu Tue Feb 10 11:50:04 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Tue Feb 10 11:50:04 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/External/SPEC/CINT95/147.vortex/Makefile Message-ID: <200402101749.LAA03858@choi.cs.uiuc.edu> Changes in directory llvm/test/Programs/External/SPEC/CINT95/147.vortex: Makefile added (r1.1) --- Log message: Adding 147.vortex SPEC95 integer benchmark. --- Diffs of the changes: (+18 -0) Index: llvm/test/Programs/External/SPEC/CINT95/147.vortex/Makefile diff -c /dev/null llvm/test/Programs/External/SPEC/CINT95/147.vortex/Makefile:1.1 *** /dev/null Tue Feb 10 11:49:18 2004 --- llvm/test/Programs/External/SPEC/CINT95/147.vortex/Makefile Tue Feb 10 11:49:08 2004 *************** *** 0 **** --- 1,18 ---- + LEVEL = ../../../../../.. + + STDIN_FILENAME := vortex.in + STDOUT_FILENAME := vortex.out + + include ../../Makefile.spec95 + + ifeq ($(ARCH),Sparc) + ## SPEC portability note for vortex says to use this flag on 64-bit machines + CPPFLAGS += -DSPEC_CPU2000_LP64 + + # If we're on sparc, use the Big Endian input file + RUN_OPTIONS = bendian.raw + else + # Use the Little Endian input file + RUN_OPTIONS = lendian.raw + endif + From criswell at cs.uiuc.edu Tue Feb 10 12:03:02 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Tue Feb 10 12:03:02 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/External/SPEC/CINT95/129.compress/Makefile Message-ID: <200402101802.MAA04055@choi.cs.uiuc.edu> Changes in directory llvm/test/Programs/External/SPEC/CINT95/129.compress: Makefile added (r1.1) --- Log message: Addition of 129.compress SPEC95 integer benchmark. --- Diffs of the changes: (+5 -0) Index: llvm/test/Programs/External/SPEC/CINT95/129.compress/Makefile diff -c /dev/null llvm/test/Programs/External/SPEC/CINT95/129.compress/Makefile:1.1 *** /dev/null Tue Feb 10 12:02:17 2004 --- llvm/test/Programs/External/SPEC/CINT95/129.compress/Makefile Tue Feb 10 12:02:07 2004 *************** *** 0 **** --- 1,5 ---- + LEVEL = ../../../../../.. + STDIN_FILENAME := test.in + STDOUT_FILENAME := test.out + include ../../Makefile.spec95 + From lattner at cs.uiuc.edu Tue Feb 10 12:03:14 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 10 12:03:14 2004 Subject: [llvm-commits] CVS: llvm/runtime/libprofile/CommonProfiling.c Message-ID: <200402101801.MAA07195@zion.cs.uiuc.edu> Changes in directory llvm/runtime/libprofile: CommonProfiling.c updated: 1.4 -> 1.5 --- Log message: Allow the program to take a '-llvmprof-output filename' option to specify where to output the profiling data, if llvmprof.out is not good enough. --- Diffs of the changes: (+30 -2) Index: llvm/runtime/libprofile/CommonProfiling.c diff -u llvm/runtime/libprofile/CommonProfiling.c:1.4 llvm/runtime/libprofile/CommonProfiling.c:1.5 --- llvm/runtime/libprofile/CommonProfiling.c:1.4 Tue Feb 10 11:36:25 2004 +++ llvm/runtime/libprofile/CommonProfiling.c Tue Feb 10 12:01:00 2004 @@ -24,6 +24,8 @@ static char *SavedArgs = 0; static unsigned SavedArgsLength = 0; +static const char *OutputFilename = "llvmprof.out"; + /* save_arguments - Save argc and argv as passed into the program for the file * we output. */ @@ -31,6 +33,30 @@ unsigned Length, i; if (SavedArgs || !argv) return argc; /* This can be called multiple times */ + /* Check to see if there are any arguments passed into the program for the + * profiler. If there are, strip them off and remember their settings. + */ + while (argc > 1 && !strncmp(argv[1], "-llvmprof-", 10)) { + /* Ok, we have an llvmprof argument. Remove it from the arg list and decide + * what to do with it. + */ + const char *Arg = argv[1]; + memmove(&argv[1], &argv[2], (argc-2)*sizeof(char*)); + --argc; + + if (!strcmp(Arg, "-llvmprof-output")) { + if (argc == 1) + puts("-llvmprof-output requires a filename argument!"); + else { + OutputFilename = strdup(argv[1]); + memmove(&argv[1], &argv[2], (argc-2)*sizeof(char*)); + --argc; + } + } else { + printf("Unknown option to the profiler runtime: '%s' - ignored.\n", Arg); + } + } + for (Length = 0, i = 0; i != (unsigned)argc; ++i) Length += strlen(argv[i])+1; @@ -63,9 +89,11 @@ */ if (OutFile == -1) { off_t Offset; - OutFile = open("llvmprof.out", O_CREAT | O_WRONLY | O_APPEND, 0666); + OutFile = open(OutputFilename, O_CREAT | O_WRONLY | O_APPEND, 0666); if (OutFile == -1) { - perror("LLVM profiling: while opening 'llvmprof.out'"); + fprintf(stderr, "LLVM profiling runtime: while opening '%s': ", + OutputFilename); + perror(""); return; } From criswell at cs.uiuc.edu Tue Feb 10 12:03:18 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Tue Feb 10 12:03:18 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/External/SPEC/CINT95/129.compress/ Message-ID: <200402101801.MAA04044@choi.cs.uiuc.edu> Changes in directory llvm/test/Programs/External/SPEC/CINT95/129.compress: --- Log message: Directory /home/vadve/shared/PublicCVS/llvm/test/Programs/External/SPEC/CINT95/129.compress added to the repository --- Diffs of the changes: (+0 -0) From lattner at cs.uiuc.edu Tue Feb 10 12:03:32 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 10 12:03:32 2004 Subject: [llvm-commits] CVS: llvm/utils/profile.pl Message-ID: <200402101802.MAA07208@zion.cs.uiuc.edu> Changes in directory llvm/utils: profile.pl updated: 1.4 -> 1.5 --- Log message: Make block profiling the default add a new -function argument Add a new -o argument to specify where to put llvmprof.out data --- Diffs of the changes: (+21 -6) Index: llvm/utils/profile.pl diff -u llvm/utils/profile.pl:1.4 llvm/utils/profile.pl:1.5 --- llvm/utils/profile.pl:1.4 Sat Nov 1 23:17:32 2003 +++ llvm/utils/profile.pl Tue Feb 10 12:01:50 2004 @@ -8,14 +8,19 @@ # Syntax: profile.pl [OPTIONS] bytecodefile # # OPTIONS may include one or more of the following: -# -block - Enable basic block level profiling +# -block - Enable basicblock-level profiling +# -function - Enable function-level profiling +# -o - Emit profiling information to the specified file, instead +# of llvmprof.out # # Any unrecognized options are passed into the invocation of llvm-prof # -my $ProfilePass = "-insert-function-profiling"; +my $ProfilePass = "-insert-block-profiling"; my $LLVMProfOpts = ""; +my $ProgramOpts = ""; +my $ProfileFile = ""; # Parse arguments... while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) { @@ -24,12 +29,22 @@ # List command line options here... if (/^-?-block$/) { $ProfilePass = "-insert-block-profiling"; next; } + if (/^-?-function$/) { $ProfilePass = "-insert-function-profiling"; next; } + if (/^-?-o$/) { # Read -o filename... + die "-o option requires a filename argument!" if (!scalar(@ARGV)); + $ProgramOpts .= " -llvmprof-output $ARGV[0]"; + $ProfileFile = $ARGV[0]; + shift; + next; + } if (/^-?-help$/) { print "OVERVIEW: profile.pl - Instrumentation and profile printer.\n\n"; print "USAGE: profile.pl [options] program.bc \n\n"; print "OPTIONS:\n"; - print " -block - Enable basic block level profiling\n"; - print " -help - Print this usage information\n"; + print " -block - Enable basicblock-level profiling\n"; + print " -function - Enable function-level profiling\n"; + print " -o - Specify an output file other than llvm-prof.out.\n"; + print " -help - Print this usage information\n"; print "\nAll other options are passed into llvm-prof.\n"; exit 1; } @@ -51,6 +66,6 @@ my $LibProfPath = $LLIPath . "/../../lib/Debug/libprofile_rt.so"; system "opt -q $ProfilePass < $BytecodeFile | lli -fake-argv0 '$BytecodeFile'" . - " -load $LibProfPath - " . (join ' ', @ARGV); + " -load $LibProfPath -$ProgramOpts " . (join ' ', @ARGV); -system "llvm-prof $LLVMProfOpts $BytecodeFile"; +system "llvm-prof $LLVMProfOpts $BytecodeFile $ProfileFile"; From lattner at cs.uiuc.edu Tue Feb 10 12:05:04 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 10 12:05:04 2004 Subject: [llvm-commits] CVS: llvm/docs/CommandGuide/llvm-prof.html Message-ID: <200402101804.MAA07590@zion.cs.uiuc.edu> Changes in directory llvm/docs/CommandGuide: llvm-prof.html updated: 1.3 -> 1.4 --- Log message: Fix documentation bugs --- Diffs of the changes: (+7 -6) Index: llvm/docs/CommandGuide/llvm-prof.html diff -u llvm/docs/CommandGuide/llvm-prof.html:1.3 llvm/docs/CommandGuide/llvm-prof.html:1.4 --- llvm/docs/CommandGuide/llvm-prof.html:1.3 Thu Nov 6 14:29:33 2003 +++ llvm/docs/CommandGuide/llvm-prof.html Tue Feb 10 12:04:24 2004 @@ -10,18 +10,19 @@ llvm-prof

    SYNOPSIS

    -llvm-prof [options] [bytecode file] [LLVM passes] +llvm-prof [options] [bytecode file] [llvmprof.out]

    DESCRIPTION

    -The llvm-prof tool reads in an 'llvmprof.out' file, a bytecode -file for the program, and produces a human readable report, suitable for -determining where the program hotspots are.

    +The llvm-prof tool reads in an 'llvmprof.out' file (which can +optionally use a specific file with the third program argument), a bytecode file +for the program, and produces a human readable report, suitable for determining +where the program hotspots are.

    -This program is often used in conjunction with the utils/profile.sh +This program is often used in conjunction with the utils/profile.pl script. This script automatically instruments a program, runs it with the JIT, then runs llvm-prof to format a report. To get more information about -utils/profile.sh, execute it with the --help option.

    +utils/profile.pl, execute it with the --help option.

    OPTIONS

    From brukman at cs.uiuc.edu Tue Feb 10 12:45:02 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Tue Feb 10 12:45:02 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/iMemory.h Message-ID: <200402101844.MAA07845@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: iMemory.h updated: 1.43 -> 1.44 --- Log message: * Added class comments * Doxygenified existing comments * Compactified code to be more consistent --- Diffs of the changes: (+32 -20) Index: llvm/include/llvm/iMemory.h diff -u llvm/include/llvm/iMemory.h:1.43 llvm/include/llvm/iMemory.h:1.44 --- llvm/include/llvm/iMemory.h:1.43 Sun Nov 16 14:21:15 2003 +++ llvm/include/llvm/iMemory.h Tue Feb 10 12:44:16 2004 @@ -24,35 +24,36 @@ //===----------------------------------------------------------------------===// // AllocationInst Class //===----------------------------------------------------------------------===// -// -// AllocationInst - This class is the common base class of MallocInst and -// AllocaInst. -// + +/// AllocationInst - This class is the common base class of MallocInst and +/// AllocaInst. +/// class AllocationInst : public Instruction { protected: AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, const std::string &Name = "", Instruction *InsertBefore = 0); public: - // isArrayAllocation - Return true if there is an allocation size parameter - // to the allocation instruction that is not 1. - // + /// isArrayAllocation - Return true if there is an allocation size parameter + /// to the allocation instruction that is not 1. + /// bool isArrayAllocation() const; - // getArraySize - Get the number of element allocated, for a simple allocation - // of a single element, this will return a constant 1 value. - // + /// getArraySize - Get the number of element allocated, for a simple + /// allocation of a single element, this will return a constant 1 value. + /// inline const Value *getArraySize() const { return Operands[0]; } inline Value *getArraySize() { return Operands[0]; } - // getType - Overload to return most specific pointer type... + /// getType - Overload to return most specific pointer type + /// inline const PointerType *getType() const { return reinterpret_cast(Instruction::getType()); } - // getAllocatedType - Return the type that is being allocated by the - // instruction. - // + /// getAllocatedType - Return the type that is being allocated by the + /// instruction. + /// const Type *getAllocatedType() const; virtual Instruction *clone() const = 0; @@ -73,6 +74,8 @@ // MallocInst Class //===----------------------------------------------------------------------===// +/// MallocInst - an instruction to allocated memory on the heap +/// class MallocInst : public AllocationInst { MallocInst(const MallocInst &MI); public: @@ -99,6 +102,8 @@ // AllocaInst Class //===----------------------------------------------------------------------===// +/// AllocaInst - an instruction to allocate memory on the stack +/// class AllocaInst : public AllocationInst { AllocaInst(const AllocaInst &); public: @@ -125,6 +130,8 @@ // FreeInst Class //===----------------------------------------------------------------------===// +/// FreeInst - an instruction to deallocate memory +/// struct FreeInst : public Instruction { FreeInst(Value *Ptr, Instruction *InsertBefore = 0); @@ -147,6 +154,8 @@ // LoadInst Class //===----------------------------------------------------------------------===// +/// LoadInst - an instruction for reading from memory +/// class LoadInst : public Instruction { LoadInst(const LoadInst &LI) : Instruction(LI.getType(), Load) { Volatile = LI.isVolatile(); @@ -161,6 +170,7 @@ /// isVolatile - Return true if this is a load from a volatile memory /// location. + /// bool isVolatile() const { return Volatile; } /// setVolatile - Specify whether this is a volatile load or not. @@ -190,6 +200,8 @@ // StoreInst Class //===----------------------------------------------------------------------===// +/// StoreInst - an instruction for storing to memory +/// class StoreInst : public Instruction { StoreInst(const StoreInst &SI) : Instruction(SI.getType(), Store) { Volatile = SI.isVolatile(); @@ -206,6 +218,7 @@ /// isVolatile - Return true if this is a load from a volatile memory /// location. + /// bool isVolatile() const { return Volatile; } /// setVolatile - Specify whether this is a volatile load or not. @@ -235,6 +248,9 @@ // GetElementPtrInst Class //===----------------------------------------------------------------------===// +/// GetElementPtrInst - an instruction for type-safe pointer arithmetic to +/// access elements of arrays and structs +/// class GetElementPtrInst : public Instruction { GetElementPtrInst(const GetElementPtrInst &EPI) : Instruction(reinterpret_cast(EPI.getType()), GetElementPtr) { @@ -262,12 +278,8 @@ const std::vector &Indices, bool AllowStructLeaf = false); - inline op_iterator idx_begin() { - return op_begin()+1; - } - inline const_op_iterator idx_begin() const { - return op_begin()+1; - } + inline op_iterator idx_begin() { return op_begin()+1; } + inline const_op_iterator idx_begin() const { return op_begin()+1; } inline op_iterator idx_end() { return op_end(); } inline const_op_iterator idx_end() const { return op_end(); } From lattner at cs.uiuc.edu Tue Feb 10 12:58:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 10 12:58:02 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/Makefile.programs Message-ID: <200402101857.MAA08181@zion.cs.uiuc.edu> Changes in directory llvm/test/Programs: Makefile.programs updated: 1.113 -> 1.114 --- Log message: Add rules for building and printing profile information: make profile - (builds an Output/test.prof profile database) make print-profile - (runs llvm-prof on it) --- Diffs of the changes: (+28 -0) Index: llvm/test/Programs/Makefile.programs diff -u llvm/test/Programs/Makefile.programs:1.113 llvm/test/Programs/Makefile.programs:1.114 --- llvm/test/Programs/Makefile.programs:1.113 Tue Feb 10 10:25:44 2004 +++ llvm/test/Programs/Makefile.programs Tue Feb 10 12:57:39 2004 @@ -107,6 +107,10 @@ LLCLSDIFFS := $(addsuffix .diff-llc-ls, $(PREFIXED_PROGRAMS_TO_TEST)) CBEDIFFS := $(addsuffix .diff-cbe, $(PREFIXED_PROGRAMS_TO_TEST)) +# Profiles for the program. +PROFOUTPUT := $(addsuffix .prof, $(PREFIXED_PROGRAMS_TO_TEST)) +PRINTPROFOUTPUT := $(addsuffix .printprof, $(PREFIXED_PROGRAMS_TO_TEST)) + # Build Program outputs: .PRECIOUS: Output/%.out-lli Output/%.out-jit Output/%.out-llc Output/%.out-llc-ls .PRECIOUS: Output/%.out-nat Output/%.out-cbe @@ -119,6 +123,9 @@ # Regardless of what other options are specified, build the program's bytecode # representation. all:: $(BYTECODE) +profile:: $(PROFOUTPUT) +print-profile:: $(PRINTPROFOUTPUT) + ifdef RUN_GCC_ONLY DISABLE_DIFFS = 1 @@ -376,6 +383,27 @@ $(LBUGPOINT) $< -run-jit $(BUGPOINT_OPTIONS) endif + + +# +# Rules to generate profiling information +# +$(PROGRAMS_TO_TEST:%=Output/%.llvm-prof.bc): \ +Output/%.llvm-prof.bc: Output/%.llvm.bc + $(LOPT) -insert-block-profiling $< -o $@ -f + +$(PROGRAMS_TO_TEST:%=Output/%.prof): \ +Output/%.prof: Output/%.llvm-prof.bc Output/%.out-nat + @rm -f $@ + -$(RUNSAFELY) $(STDIN_FILENAME) Output/$*.out-prof $(LLI) $(JIT_OPTS) \ + -fake-argv0 'Output/$*.llvm.bc' -load $(LEVEL)/lib/Debug/libprofile_rt.so $< -llvmprof-output $@ $(RUN_OPTIONS) + @cmp -s Output/$*.out-prof Output/$*.out-nat || \ + printf "***\n***\n*** WARNING: Output of profiled program (Output/$*.out-prof)\n*** doesn't match the output of the native program (Output/$*.out-nat)!\n***\n***\n"; + +$(PROGRAMS_TO_TEST:%=Output/%.printprof): \ +Output/%.printprof: Output/%.llvm.bc Output/%.prof + $(LPROF) $< Output/$*.prof + # # Rules to diff test output... From lattner at cs.uiuc.edu Tue Feb 10 13:15:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 10 13:15:01 2004 Subject: [llvm-commits] CVS: llvm/runtime/libprofile/CommonProfiling.c Message-ID: <200402101914.NAA08978@zion.cs.uiuc.edu> Changes in directory llvm/runtime/libprofile: CommonProfiling.c updated: 1.5 -> 1.6 --- Log message: Make sure to copy the null terminator at the end of the argv list. Some programs use it instead of argc. --- Diffs of the changes: (+2 -2) Index: llvm/runtime/libprofile/CommonProfiling.c diff -u llvm/runtime/libprofile/CommonProfiling.c:1.5 llvm/runtime/libprofile/CommonProfiling.c:1.6 --- llvm/runtime/libprofile/CommonProfiling.c:1.5 Tue Feb 10 12:01:00 2004 +++ llvm/runtime/libprofile/CommonProfiling.c Tue Feb 10 13:14:44 2004 @@ -41,7 +41,7 @@ * what to do with it. */ const char *Arg = argv[1]; - memmove(&argv[1], &argv[2], (argc-2)*sizeof(char*)); + memmove(&argv[1], &argv[2], (argc-1)*sizeof(char*)); --argc; if (!strcmp(Arg, "-llvmprof-output")) { @@ -49,7 +49,7 @@ puts("-llvmprof-output requires a filename argument!"); else { OutputFilename = strdup(argv[1]); - memmove(&argv[1], &argv[2], (argc-2)*sizeof(char*)); + memmove(&argv[1], &argv[2], (argc-1)*sizeof(char*)); --argc; } } else { From lattner at cs.uiuc.edu Tue Feb 10 13:16:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 10 13:16:02 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/Makefile.programs Message-ID: <200402101915.NAA08991@zion.cs.uiuc.edu> Changes in directory llvm/test/Programs: Makefile.programs updated: 1.114 -> 1.115 --- Log message: Add dependencies, so that profile info is rebuilt when certain things are changed --- Diffs of the changes: (+5 -3) Index: llvm/test/Programs/Makefile.programs diff -u llvm/test/Programs/Makefile.programs:1.114 llvm/test/Programs/Makefile.programs:1.115 --- llvm/test/Programs/Makefile.programs:1.114 Tue Feb 10 12:57:39 2004 +++ llvm/test/Programs/Makefile.programs Tue Feb 10 13:15:08 2004 @@ -392,16 +392,18 @@ Output/%.llvm-prof.bc: Output/%.llvm.bc $(LOPT) -insert-block-profiling $< -o $@ -f +LIBPROFILESO := $(LEVEL)/lib/Debug/libprofile_rt.so + $(PROGRAMS_TO_TEST:%=Output/%.prof): \ -Output/%.prof: Output/%.llvm-prof.bc Output/%.out-nat +Output/%.prof: Output/%.llvm-prof.bc Output/%.out-nat $(LIBPROFILESO) @rm -f $@ -$(RUNSAFELY) $(STDIN_FILENAME) Output/$*.out-prof $(LLI) $(JIT_OPTS) \ - -fake-argv0 'Output/$*.llvm.bc' -load $(LEVEL)/lib/Debug/libprofile_rt.so $< -llvmprof-output $@ $(RUN_OPTIONS) + -fake-argv0 'Output/$*.llvm.bc' -load $(LIBPROFILESO) $< -llvmprof-output $@ $(RUN_OPTIONS) @cmp -s Output/$*.out-prof Output/$*.out-nat || \ printf "***\n***\n*** WARNING: Output of profiled program (Output/$*.out-prof)\n*** doesn't match the output of the native program (Output/$*.out-nat)!\n***\n***\n"; $(PROGRAMS_TO_TEST:%=Output/%.printprof): \ -Output/%.printprof: Output/%.llvm.bc Output/%.prof +Output/%.printprof: Output/%.llvm.bc Output/%.prof $(LPROF) $(LPROF) $< Output/$*.prof From gaeke at gally.cs.uiuc.edu Tue Feb 10 13:18:03 2004 From: gaeke at gally.cs.uiuc.edu (Brian Gaeke) Date: Tue Feb 10 13:18:03 2004 Subject: [llvm-commits] CVS: reopt/lib/LightWtProfiling/TraceToFunction.cpp Message-ID: <200402101917.i1AJHQJ16078@gally.cs.uiuc.edu> Changes in directory reopt/lib/LightWtProfiling: TraceToFunction.cpp updated: 1.21 -> 1.22 --- Log message: Change to use new version of BasicBlock constructor. --- Diffs of the changes: (+1 -1) Index: reopt/lib/LightWtProfiling/TraceToFunction.cpp diff -u reopt/lib/LightWtProfiling/TraceToFunction.cpp:1.21 reopt/lib/LightWtProfiling/TraceToFunction.cpp:1.22 --- reopt/lib/LightWtProfiling/TraceToFunction.cpp:1.21 Thu Jan 15 13:40:08 2004 +++ reopt/lib/LightWtProfiling/TraceToFunction.cpp Tue Feb 10 13:17:15 2004 @@ -422,7 +422,7 @@ // the function. So create new entry basic block to serve as source // for old entry's initial phi node. if (srcB == T.getEntryBasicBlock ()) { - BasicBlock *FEntry = new BasicBlock ("entryfixup", dstB); + BasicBlock *FEntry = new BasicBlock ("entryfixup", 0, dstB); FEntry->getInstList ().push_back (new BranchInst (dstB)); // Replace the references to the trace's predecessor with a // reference to FEntry now. This is kind of a dodge because we From gaeke at gally.cs.uiuc.edu Tue Feb 10 13:18:06 2004 From: gaeke at gally.cs.uiuc.edu (Brian Gaeke) Date: Tue Feb 10 13:18:06 2004 Subject: [llvm-commits] CVS: reopt/lib/Mapping/getLLVMinfo.cpp Message-ID: <200402101917.i1AJHZD16097@gally.cs.uiuc.edu> Changes in directory reopt/lib/Mapping: getLLVMinfo.cpp updated: 1.24 -> 1.25 --- Log message: Clarify comment for getReverseBBMap(). --- Diffs of the changes: (+5 -4) Index: reopt/lib/Mapping/getLLVMinfo.cpp diff -u reopt/lib/Mapping/getLLVMinfo.cpp:1.24 reopt/lib/Mapping/getLLVMinfo.cpp:1.25 --- reopt/lib/Mapping/getLLVMinfo.cpp:1.24 Mon Jan 5 14:13:37 2004 +++ reopt/lib/Mapping/getLLVMinfo.cpp Tue Feb 10 13:17:25 2004 @@ -147,11 +147,12 @@ } /// getReverseBBMap - Look up the given 64-bit address ADDR in the -/// reverse BB map for the Module. If it is found, return true, and -/// set BB to the BasicBlock that corresponds to it. Otherwise, return -/// false. +/// map for the given Module which maps machine-code memory addresses back to +/// their corresponding LLVM BasicBlocks. If ADDR is found in the map, +/// return true, and set BB to the BasicBlock that corresponds to it. +/// Otherwise, return false, and leave BB untouched. /// -bool getReverseBBMap(uint64_t addr, Module *M, BasicBlock* &bb){ +bool getReverseBBMap(uint64_t addr, Module *M, BasicBlock* &bb) { static Module *lastUsedModule = NULL; if (lastUsedModule != M) { // First time we see a given Module, create the table we use to From gaeke at gally.cs.uiuc.edu Tue Feb 10 13:18:31 2004 From: gaeke at gally.cs.uiuc.edu (Brian Gaeke) Date: Tue Feb 10 13:18:31 2004 Subject: [llvm-commits] CVS: reopt/lib/LightWtProfiling/SLI.cpp Message-ID: <200402101917.i1AJHgm16112@gally.cs.uiuc.edu> Changes in directory reopt/lib/LightWtProfiling: SLI.cpp updated: 1.14 -> 1.15 --- Log message: Give doInstrumentation() more proper comments, and rename its parameters to have more easily-recognizable names. Give some assertions better messages. --- Diffs of the changes: (+34 -18) Index: reopt/lib/LightWtProfiling/SLI.cpp diff -u reopt/lib/LightWtProfiling/SLI.cpp:1.14 reopt/lib/LightWtProfiling/SLI.cpp:1.15 --- reopt/lib/LightWtProfiling/SLI.cpp:1.14 Fri Jan 16 11:02:02 2004 +++ reopt/lib/LightWtProfiling/SLI.cpp Tue Feb 10 13:17:01 2004 @@ -196,29 +196,45 @@ // } // } -void doInstrumentation(uint64_t addr1, uint64_t addr2, VirtualMem *vm){ - uint64_t endAddr = addr2; +/// doInstrumentation - Perform second-level instrumentation on a "hot" loop. +/// brTarget is the address of the beginning of the loop, and branchAddr +/// is the address of the branch that branches back brTarget, ending the +/// loop. +/// +void doInstrumentation(uint64_t brTarget, uint64_t branchAddr, VirtualMem *vm){ + uint64_t endAddr = branchAddr; // Make sure we have already parsed the LLVM bytecode and have the - // resulting LLVM Module handy. + // resulting LLVM Module handy. This is where we usually first read + // in the bytecode. if (!M) initModules(); - //get BB address - BasicBlock *root=NULL, *end=NULL; - assert(getReverseBBMap(addr1, M, root) && "Not found root"); - while(!getReverseBBMap(addr2, M, end)) - addr2 -= 4; - - assert(root && end && "No root or end found"); - - //find backedges - std::map backEdges; //edge from key->value + // Try to get the LLVM BasicBlocks that correspond to the beginning + // and end of the hot loop. We can be pretty sure that the brTarget begins + // a BasicBlock, but since branchAddr ends a basic block, we must scan + // backwards hoping to find the beginning of its basic block. + BasicBlock *root = 0, *end = 0; + // FIXME: Rewrite as: + // MappingInfo::reconstruct(M)->getBasicBlockForAddress (brTarget); + // returning either NULL or a valid BB *. + assert(getReverseBBMap(brTarget, M, root) + && "Branch target's BasicBlock not found in map!"); + assert(root && "Branch target mapped to NULL BasicBlock?"); + while(!getReverseBBMap(branchAddr, M, end)) + branchAddr -= 4; // Scan backwards until we find it. + assert(end && "Back-edge branch mapped to NULL BasicBlock?"); + + // Find all the back edges in the CFG of the function where the loop starts, + // putting them in backEdges, which will then contain a (source, + // sink) pair for every edge. + std::map backEdges; getBackEdges(backEdges, root->getParent()); - //end node + // Now we have to find the back-edge in the CFG corresponding to the loop + // we want to instrument. assert(backEdges.find(end) != backEdges.end() && - "No backedge with end found"); + "Can't find back-edge to instrument in CFG."); //get forward edges std::map forward; @@ -336,7 +352,7 @@ uint64_t target = getBranchTarget(instr, addr); trace.push_back(instr); trace.push_back(vm->readInstrFrmVm(addr+4, tr, tr2)); - if(target == addr1){ + if(target == brTarget){ trace[index] = getBranchInst(instr, (uint64_t)(intptr_t)&trace[0], (uint64_t)(intptr_t)&trace[index]); @@ -407,10 +423,10 @@ } - if(!tr->addTrace(addr1, endAddr, trace, 0, callMap, branchMap, tr2)) + if(!tr->addTrace(brTarget, endAddr, trace, 0, callMap, branchMap, tr2)) std::cerr << "Could not add!\n"; - DEBUG(std::cerr << "Added-SLI-trace\t" << (void *)addr1 << "\t" + DEBUG(std::cerr << "Added-SLI-trace\t" << (void *)brTarget << "\t" << (void *)endAddr << "\t" << trace.size() << "\n"); for (std::map::iterator MI = toInline.begin(), From criswell at cs.uiuc.edu Tue Feb 10 13:46:04 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Tue Feb 10 13:46:04 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/External/SPEC/CINT95/132.ijpeg/ Message-ID: <200402101945.NAA31269@choi.cs.uiuc.edu> Changes in directory llvm/test/Programs/External/SPEC/CINT95/132.ijpeg: --- Log message: Directory /home/vadve/shared/PublicCVS/llvm/test/Programs/External/SPEC/CINT95/132.ijpeg added to the repository --- Diffs of the changes: (+0 -0) From criswell at cs.uiuc.edu Tue Feb 10 13:47:01 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Tue Feb 10 13:47:01 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/External/SPEC/CINT95/132.ijpeg/Makefile Message-ID: <200402101946.NAA31283@choi.cs.uiuc.edu> Changes in directory llvm/test/Programs/External/SPEC/CINT95/132.ijpeg: Makefile added (r1.1) --- Log message: Checkin of 132.ijpeg SPEC95 integer benchmark. --- Diffs of the changes: (+8 -0) Index: llvm/test/Programs/External/SPEC/CINT95/132.ijpeg/Makefile diff -c /dev/null llvm/test/Programs/External/SPEC/CINT95/132.ijpeg/Makefile:1.1 *** /dev/null Tue Feb 10 13:46:06 2004 --- llvm/test/Programs/External/SPEC/CINT95/132.ijpeg/Makefile Tue Feb 10 13:45:56 2004 *************** *** 0 **** --- 1,8 ---- + LEVEL = ../../../../../.. + STDIN_FILENAME := specmun.ppm + STDOUT_FILENAME := specmun.out + CPPFLAGS += -DNO_SYSERRLIST + + Source=libpbm1.c libpbm2.c libpbm3.c libpbm4.c libpbm5.c libpgm1.c libpgm2.c libppm1.c libppm2.c libppm3.c libppm4.c libppm5.c spec_image.c spec_jmemdst.c spec_jmemsrc.c spec_main.c rdppm.c wrppm.c rdgif.c wrgif.c rdtarga.c wrtarga.c rdbmp.c wrbmp.c jcapi.c jcparam.c jdatadst.c jcmaster.c jcmarker.c jcmainct.c jcprepct.c jccoefct.c jccolor.c jcsample.c jchuff.c jcdctmgr.c jfdctfst.c jfdctflt.c jfdctint.c jdapi.c jdatasrc.c jdmaster.c jdmarker.c jdmainct.c jdcoefct.c jdpostct.c jddctmgr.c jidctfst.c jidctflt.c jidctint.c jidctred.c jdhuff.c jdsample.c jdcolor.c jquant1.c jquant2.c jdmerge.c jcomapi.c jutils.c jerror.c jmemmgr.c jmemnobs.c + include ../../Makefile.spec95 + From lattner at cs.uiuc.edu Tue Feb 10 13:47:05 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 10 13:47:05 2004 Subject: [llvm-commits] CVS: llvm/test/Makefile.tests Message-ID: <200402101946.NAA30995@zion.cs.uiuc.edu> Changes in directory llvm/test: Makefile.tests updated: 1.86 -> 1.87 --- Log message: Right, define the LPROF variable --- Diffs of the changes: (+1 -0) Index: llvm/test/Makefile.tests diff -u llvm/test/Makefile.tests:1.86 llvm/test/Makefile.tests:1.87 --- llvm/test/Makefile.tests:1.86 Fri Jan 16 15:53:23 2004 +++ llvm/test/Makefile.tests Tue Feb 10 13:46:14 2004 @@ -45,6 +45,7 @@ LDIS = $(LLVMTOOLCURRENT)/llvm-dis LOPT = $(LLVMTOOLCURRENT)/opt LLINK = $(LLVMTOOLCURRENT)/llvm-link +LPROF = $(LLVMTOOLCURRENT)/llvm-prof LANALYZE = $(LLVMTOOLCURRENT)/analyze LBUGPOINT= $(LLVMTOOLCURRENT)/bugpoint From lattner at cs.uiuc.edu Tue Feb 10 14:26:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 10 14:26:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86InstrInfo.cpp Message-ID: <200402102025.OAA02695@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86InstrInfo.cpp updated: 1.19 -> 1.20 --- Log message: Tighten up checks --- Diffs of the changes: (+2 -2) Index: llvm/lib/Target/X86/X86InstrInfo.cpp diff -u llvm/lib/Target/X86/X86InstrInfo.cpp:1.19 llvm/lib/Target/X86/X86InstrInfo.cpp:1.20 --- llvm/lib/Target/X86/X86InstrInfo.cpp:1.19 Sun Feb 1 02:22:16 2004 +++ llvm/lib/Target/X86/X86InstrInfo.cpp Tue Feb 10 14:25:13 2004 @@ -42,8 +42,8 @@ // Make sure the instruction is EXACTLY `xchg ax, ax' if (MI.getOpcode() == X86::XCHGrr16) { const MachineOperand &op0 = MI.getOperand(0), &op1 = MI.getOperand(1); - if (op0.isMachineRegister() && op0.getMachineRegNum() == X86::AX && - op1.isMachineRegister() && op1.getMachineRegNum() == X86::AX) { + if (op0.isPhysicalRegister() && op0.getReg() == X86::AX && + op1.isPhysicalRegister() && op1.getReg() == X86::AX) { return true; } } From lattner at cs.uiuc.edu Tue Feb 10 14:31:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 10 14:31:01 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/MachineInstr.h Message-ID: <200402102030.OAA02805@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: MachineInstr.h updated: 1.122 -> 1.123 --- Log message: Simplify condition, this does not change the predicate at all though --- Diffs of the changes: (+3 -1) Index: llvm/include/llvm/CodeGen/MachineInstr.h diff -u llvm/include/llvm/CodeGen/MachineInstr.h:1.122 llvm/include/llvm/CodeGen/MachineInstr.h:1.123 --- llvm/include/llvm/CodeGen/MachineInstr.h:1.122 Wed Feb 4 16:17:40 2004 +++ llvm/include/llvm/CodeGen/MachineInstr.h Tue Feb 10 14:30:40 2004 @@ -233,7 +233,9 @@ return (opType == MO_VirtualRegister || opType == MO_MachineRegister) && (unsigned)regNum < MRegisterInfo::FirstVirtualRegister; } - bool isRegister() const { return isVirtualRegister() || isPhysicalRegister();} + bool isRegister() const { + return opType == MO_VirtualRegister || opType == MO_MachineRegister; + } bool isMachineRegister() const { return !isVirtualRegister(); } bool isMachineBasicBlock() const { return opType == MO_MachineBasicBlock; } bool isPCRelativeDisp() const { return opType == MO_PCRelativeDisp; } From lattner at cs.uiuc.edu Tue Feb 10 14:32:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 10 14:32:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/FloatingPoint.cpp X86InstrInfo.cpp Message-ID: <200402102031.OAA02820@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: FloatingPoint.cpp updated: 1.19 -> 1.20 X86InstrInfo.cpp updated: 1.20 -> 1.21 --- Log message: Don't use MachineOperator::is(Phys|Virt)Register --- Diffs of the changes: (+3 -3) Index: llvm/lib/Target/X86/FloatingPoint.cpp diff -u llvm/lib/Target/X86/FloatingPoint.cpp:1.19 llvm/lib/Target/X86/FloatingPoint.cpp:1.20 --- llvm/lib/Target/X86/FloatingPoint.cpp:1.19 Tue Feb 3 01:27:34 2004 +++ llvm/lib/Target/X86/FloatingPoint.cpp Tue Feb 10 14:31:28 2004 @@ -357,7 +357,7 @@ } static unsigned getFPReg(const MachineOperand &MO) { - assert(MO.isPhysicalRegister() && "Expected an FP register!"); + assert(MO.isRegister() && "Expected an FP register!"); unsigned Reg = MO.getReg(); assert(Reg >= X86::FP0 && Reg <= X86::FP6 && "Expected FP register!"); return Reg - X86::FP0; Index: llvm/lib/Target/X86/X86InstrInfo.cpp diff -u llvm/lib/Target/X86/X86InstrInfo.cpp:1.20 llvm/lib/Target/X86/X86InstrInfo.cpp:1.21 --- llvm/lib/Target/X86/X86InstrInfo.cpp:1.20 Tue Feb 10 14:25:13 2004 +++ llvm/lib/Target/X86/X86InstrInfo.cpp Tue Feb 10 14:31:28 2004 @@ -42,8 +42,8 @@ // Make sure the instruction is EXACTLY `xchg ax, ax' if (MI.getOpcode() == X86::XCHGrr16) { const MachineOperand &op0 = MI.getOperand(0), &op1 = MI.getOperand(1); - if (op0.isPhysicalRegister() && op0.getReg() == X86::AX && - op1.isPhysicalRegister() && op1.getReg() == X86::AX) { + if (op0.isRegister() && op0.getReg() == X86::AX && + op1.isRegister() && op1.getReg() == X86::AX) { return true; } } From lattner at cs.uiuc.edu Tue Feb 10 14:36:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 10 14:36:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp Message-ID: <200402102035.OAA05903@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/Sparc: SparcV9CodeEmitter.cpp updated: 1.49 -> 1.50 --- Log message: Remove use of isPhysicalRegister --- Diffs of the changes: (+1 -1) Index: llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp diff -u llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp:1.49 llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp:1.50 --- llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp:1.49 Sat Dec 20 03:17:40 2003 +++ llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp Tue Feb 10 14:35:42 2004 @@ -660,7 +660,7 @@ std::cerr << "ERROR: PC relative disp unhandled:" << MO << "\n"; abort(); } - } else if (MO.isPhysicalRegister() || + } else if (MO.getType() == MachineOperand::MO_MachineRegister || MO.getType() == MachineOperand::MO_CCRegister) { // This is necessary because the Sparc backend doesn't actually lay out From lattner at cs.uiuc.edu Tue Feb 10 14:42:03 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 10 14:42:03 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveVariables.cpp PrologEpilogInserter.cpp RegAllocLocal.cpp Message-ID: <200402102041.OAA13914@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveVariables.cpp updated: 1.19 -> 1.20 PrologEpilogInserter.cpp updated: 1.16 -> 1.17 RegAllocLocal.cpp updated: 1.40 -> 1.41 --- Log message: Eliminate users of MachineOperand::isPhysicalRegister --- Diffs of the changes: (+8 -5) Index: llvm/lib/CodeGen/LiveVariables.cpp diff -u llvm/lib/CodeGen/LiveVariables.cpp:1.19 llvm/lib/CodeGen/LiveVariables.cpp:1.20 --- llvm/lib/CodeGen/LiveVariables.cpp:1.19 Sun Feb 8 19:43:23 2004 +++ llvm/lib/CodeGen/LiveVariables.cpp Tue Feb 10 14:41:10 2004 @@ -234,7 +234,8 @@ if (MO.isUse()) { if (MO.isVirtualRegister() && !MO.getVRegValueOrNull()) { HandleVirtRegUse(getVarInfo(MO.getReg()), MBB, MI); - } else if (MO.isPhysicalRegister() && + } else if (MO.isRegister() && + MRegisterInfo::isPhysicalRegister(MO.getReg()) && AllocatablePhysicalRegisters[MO.getReg()]) { HandlePhysRegUse(MO.getReg(), MI); } @@ -257,7 +258,8 @@ VRInfo.DefBlock = MBB; // Created here... VRInfo.DefInst = MI; VRInfo.Kills.push_back(std::make_pair(MBB, MI)); // Defaults to dead - } else if (MO.isPhysicalRegister() && + } else if (MO.isRegister() && + MRegisterInfo::isPhysicalRegister(MO.getReg()) && AllocatablePhysicalRegisters[MO.getReg()]) { HandlePhysRegDef(MO.getReg(), MI); } Index: llvm/lib/CodeGen/PrologEpilogInserter.cpp diff -u llvm/lib/CodeGen/PrologEpilogInserter.cpp:1.16 llvm/lib/CodeGen/PrologEpilogInserter.cpp:1.17 --- llvm/lib/CodeGen/PrologEpilogInserter.cpp:1.16 Sun Dec 14 07:24:16 2003 +++ llvm/lib/CodeGen/PrologEpilogInserter.cpp Tue Feb 10 14:41:10 2004 @@ -118,7 +118,8 @@ MachineOperand &MO = (*I)->getOperand(i); assert(!MO.isVirtualRegister() && "Register allocation must be performed!"); - if (MO.isPhysicalRegister() && MO.isDef()) + if (MO.isRegister() && MO.isDef() && + MRegisterInfo::isPhysicalRegister(MO.getReg())) ModifiedRegs[MO.getReg()] = true; // Register is modified } ++I; Index: llvm/lib/CodeGen/RegAllocLocal.cpp diff -u llvm/lib/CodeGen/RegAllocLocal.cpp:1.40 llvm/lib/CodeGen/RegAllocLocal.cpp:1.41 --- llvm/lib/CodeGen/RegAllocLocal.cpp:1.40 Sun Feb 8 20:12:04 2004 +++ llvm/lib/CodeGen/RegAllocLocal.cpp Tue Feb 10 14:41:10 2004 @@ -556,8 +556,8 @@ // Loop over all of the operands of the instruction, spilling registers that // are defined, and marking explicit destinations in the PhysRegsUsed map. for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) - if (MI->getOperand(i).isDef() && - MI->getOperand(i).isPhysicalRegister()) { + if (MI->getOperand(i).isDef() && MI->getOperand(i).isRegister() && + MRegisterInfo::isPhysicalRegister(MI->getOperand(i).getReg())) { unsigned Reg = MI->getOperand(i).getAllocatedRegNum(); spillPhysReg(MBB, I, Reg, true); // Spill any existing value in the reg PhysRegsUsed[Reg] = 0; // It is free and reserved now From lattner at cs.uiuc.edu Tue Feb 10 14:43:00 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 10 14:43:00 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/MachineInstr.h Message-ID: <200402102042.OAA14145@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: MachineInstr.h updated: 1.123 -> 1.124 --- Log message: Eliminate MachineOperand::isPhysicalRegister. The X86 backend should use MRegisterInfo::isPhysicalRegister(MO.getReg()) and the Sparc backend should use isMachineRegister() --- Diffs of the changes: (+0 -4) Index: llvm/include/llvm/CodeGen/MachineInstr.h diff -u llvm/include/llvm/CodeGen/MachineInstr.h:1.123 llvm/include/llvm/CodeGen/MachineInstr.h:1.124 --- llvm/include/llvm/CodeGen/MachineInstr.h:1.123 Tue Feb 10 14:30:40 2004 +++ llvm/include/llvm/CodeGen/MachineInstr.h Tue Feb 10 14:42:11 2004 @@ -229,10 +229,6 @@ return (opType == MO_VirtualRegister || opType == MO_MachineRegister) && regNum >= MRegisterInfo::FirstVirtualRegister; } - bool isPhysicalRegister() const { - return (opType == MO_VirtualRegister || opType == MO_MachineRegister) - && (unsigned)regNum < MRegisterInfo::FirstVirtualRegister; - } bool isRegister() const { return opType == MO_VirtualRegister || opType == MO_MachineRegister; } From lattner at cs.uiuc.edu Tue Feb 10 14:48:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 10 14:48:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp Message-ID: <200402102047.OAA17143@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/Sparc: SparcV9CodeEmitter.cpp updated: 1.50 -> 1.51 --- Log message: Remvoe use of MO.isVirtualRegister(), turn an assertion into an assert() --- Diffs of the changes: (+3 -5) Index: llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp diff -u llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp:1.50 llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp:1.51 --- llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp:1.50 Tue Feb 10 14:35:42 2004 +++ llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp Tue Feb 10 14:47:24 2004 @@ -594,11 +594,9 @@ MachineOperand &MO) { int64_t rv = 0; // Return value; defaults to 0 for unhandled cases // or things that get fixed up later by the JIT. - - if (MO.isVirtualRegister()) { - std::cerr << "ERROR: virtual register found in machine code.\n"; - abort(); - } else if (MO.isPCRelativeDisp()) { + assert(MO.getType() != MachineOperand::MO_VirtualRegister && + "ERROR: virtual register found in machine code."); + if (MO.isPCRelativeDisp()) { DEBUG(std::cerr << "PCRelativeDisp: "); Value *V = MO.getVRegValue(); if (BasicBlock *BB = dyn_cast(V)) { From lattner at cs.uiuc.edu Tue Feb 10 14:56:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 10 14:56:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/PeepholeOptimizer.cpp Message-ID: <200402102055.OAA20072@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: PeepholeOptimizer.cpp updated: 1.10 -> 1.11 --- Log message: Remove uses of MachineOperand::isVirtualRegister --- Diffs of the changes: (+6 -3) Index: llvm/lib/Target/X86/PeepholeOptimizer.cpp diff -u llvm/lib/Target/X86/PeepholeOptimizer.cpp:1.10 llvm/lib/Target/X86/PeepholeOptimizer.cpp:1.11 --- llvm/lib/Target/X86/PeepholeOptimizer.cpp:1.10 Wed Feb 4 16:17:40 2004 +++ llvm/lib/Target/X86/PeepholeOptimizer.cpp Tue Feb 10 14:55:47 2004 @@ -191,7 +191,8 @@ MachineInstr *MI = *I; for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { MachineOperand &MO = MI->getOperand(i); - if (MO.isVirtualRegister() && MO.isDef() && !MO.isUse()) + if (MO.isRegister() && MO.isDef() && !MO.isUse() && + MRegisterInfo::isVirtualRegister(MO.getReg())) setDefinition(MO.getReg(), MI); } } @@ -250,7 +251,8 @@ /// register, return the machine instruction defining it, otherwise, return /// null. MachineInstr *getDefiningInst(MachineOperand &MO) { - if (MO.isDef() || !MO.isVirtualRegister()) return 0; + if (MO.isDef() || !MO.isRegister() || + !MRegisterInfo::isVirtualRegister(MO.getReg())) return 0; return UDC->getDefinition(MO.getReg()); } @@ -391,7 +393,8 @@ DefInst->getOpcode() == X86::MOVrr32) { // Don't propagate physical registers into PHI nodes... if (MI->getOpcode() != X86::PHI || - DefInst->getOperand(1).isVirtualRegister()) + (DefInst->getOperand(1).isRegister() && + MRegisterInfo::isVirtualRegister(DefInst->getOperand(1).getReg()))) Changed = Propagate(MI, i, DefInst, 1); } From lattner at cs.uiuc.edu Tue Feb 10 15:13:05 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 10 15:13:05 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/SparcInstrInfo.h Message-ID: <200402102112.PAA24437@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/Sparc: SparcInstrInfo.h updated: 1.1 -> 1.2 --- Log message: Stop using this method --- Diffs of the changes: (+1 -1) Index: llvm/lib/Target/Sparc/SparcInstrInfo.h diff -u llvm/lib/Target/Sparc/SparcInstrInfo.h:1.1 llvm/lib/Target/Sparc/SparcInstrInfo.h:1.2 --- llvm/lib/Target/Sparc/SparcInstrInfo.h:1.1 Wed Dec 17 16:04:00 2003 +++ llvm/lib/Target/Sparc/SparcInstrInfo.h Tue Feb 10 15:12:06 2004 @@ -65,7 +65,7 @@ if (MI.getOpcode() == V9::SETHI && MI.getNumOperands() == 2) { const MachineOperand &op0 = MI.getOperand(0), &op1 = MI.getOperand(1); if (op0.isImmediate() && op0.getImmedValue() == 0 && - op1.isMachineRegister() && + op1.getType() == MachineOperand::MO_MachineRegister && op1.getMachineRegNum() == SparcIntRegClass::g0) { return true; From lattner at cs.uiuc.edu Tue Feb 10 15:13:09 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 10 15:13:09 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervals.cpp LiveVariables.cpp PHIElimination.cpp PrologEpilogInserter.cpp RegAllocLinearScan.cpp RegAllocLocal.cpp RegAllocSimple.cpp Message-ID: <200402102112.PAA24458@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveIntervals.cpp updated: 1.46 -> 1.47 LiveVariables.cpp updated: 1.20 -> 1.21 PHIElimination.cpp updated: 1.14 -> 1.15 PrologEpilogInserter.cpp updated: 1.17 -> 1.18 RegAllocLinearScan.cpp updated: 1.43 -> 1.44 RegAllocLocal.cpp updated: 1.41 -> 1.42 RegAllocSimple.cpp updated: 1.47 -> 1.48 --- Log message: Do not use MachineOperand::isVirtualRegister either! --- Diffs of the changes: (+29 -27) Index: llvm/lib/CodeGen/LiveIntervals.cpp diff -u llvm/lib/CodeGen/LiveIntervals.cpp:1.46 llvm/lib/CodeGen/LiveIntervals.cpp:1.47 --- llvm/lib/CodeGen/LiveIntervals.cpp:1.46 Thu Feb 5 16:55:25 2004 +++ llvm/lib/CodeGen/LiveIntervals.cpp Tue Feb 10 15:12:22 2004 @@ -115,7 +115,8 @@ for (int i = mi->getNumOperands() - 1; i >= 0; --i) { MachineOperand& mop = mi->getOperand(i); - if (mop.isVirtualRegister()) { + if (mop.isRegister() && + MRegisterInfo::isVirtualRegister(mop.getReg())) { unsigned reg = mop.getAllocatedRegNum(); Reg2IntervalMap::iterator r2iit = r2iMap_.find(reg); assert(r2iit != r2iMap_.end()); Index: llvm/lib/CodeGen/LiveVariables.cpp diff -u llvm/lib/CodeGen/LiveVariables.cpp:1.20 llvm/lib/CodeGen/LiveVariables.cpp:1.21 --- llvm/lib/CodeGen/LiveVariables.cpp:1.20 Tue Feb 10 14:41:10 2004 +++ llvm/lib/CodeGen/LiveVariables.cpp Tue Feb 10 15:12:22 2004 @@ -231,11 +231,10 @@ // Process all explicit uses... for (unsigned i = 0; i != NumOperandsToProcess; ++i) { MachineOperand &MO = MI->getOperand(i); - if (MO.isUse()) { - if (MO.isVirtualRegister() && !MO.getVRegValueOrNull()) { + if (MO.isUse() && MO.isRegister()) { + if (MRegisterInfo::isVirtualRegister(MO.getReg())){ HandleVirtRegUse(getVarInfo(MO.getReg()), MBB, MI); - } else if (MO.isRegister() && - MRegisterInfo::isPhysicalRegister(MO.getReg()) && + } else if (MRegisterInfo::isPhysicalRegister(MO.getReg()) && AllocatablePhysicalRegisters[MO.getReg()]) { HandlePhysRegUse(MO.getReg(), MI); } @@ -250,16 +249,15 @@ // Process all explicit defs... for (unsigned i = 0; i != NumOperandsToProcess; ++i) { MachineOperand &MO = MI->getOperand(i); - if (MO.isDef()) { - if (MO.isVirtualRegister()) { + if (MO.isDef() && MO.isRegister()) { + if (MRegisterInfo::isVirtualRegister(MO.getReg())) { VarInfo &VRInfo = getVarInfo(MO.getReg()); assert(VRInfo.DefBlock == 0 && "Variable multiply defined!"); VRInfo.DefBlock = MBB; // Created here... VRInfo.DefInst = MI; VRInfo.Kills.push_back(std::make_pair(MBB, MI)); // Defaults to dead - } else if (MO.isRegister() && - MRegisterInfo::isPhysicalRegister(MO.getReg()) && + } else if (MRegisterInfo::isPhysicalRegister(MO.getReg()) && AllocatablePhysicalRegisters[MO.getReg()]) { HandlePhysRegDef(MO.getReg(), MI); } Index: llvm/lib/CodeGen/PHIElimination.cpp diff -u llvm/lib/CodeGen/PHIElimination.cpp:1.14 llvm/lib/CodeGen/PHIElimination.cpp:1.15 --- llvm/lib/CodeGen/PHIElimination.cpp:1.14 Sun Dec 14 07:24:17 2003 +++ llvm/lib/CodeGen/PHIElimination.cpp Tue Feb 10 15:12:22 2004 @@ -73,7 +73,7 @@ // Unlink the PHI node from the basic block... but don't delete the PHI yet MBB.erase(MBB.begin()); - assert(MI->getOperand(0).isVirtualRegister() && + assert(MRegisterInfo::isVirtualRegister(MI->getOperand(0).getReg()) && "PHI node doesn't write virt reg?"); unsigned DestReg = MI->getOperand(0).getAllocatedRegNum(); @@ -174,7 +174,7 @@ MachineInstr *PrevInst = *(I-1); for (unsigned i = 0, e = PrevInst->getNumOperands(); i != e; ++i) { MachineOperand &MO = PrevInst->getOperand(i); - if (MO.isVirtualRegister() && MO.getReg() == IncomingReg) + if (MO.isRegister() && MO.getReg() == IncomingReg) if (MO.isDef()) { HaveNotEmitted = false; break; @@ -183,7 +183,7 @@ } if (HaveNotEmitted) { // If the copy has not already been emitted, do it. - assert(opVal.isVirtualRegister() && + assert(MRegisterInfo::isVirtualRegister(opVal.getReg()) && "Machine PHI Operands must all be virtual registers!"); unsigned SrcReg = opVal.getReg(); RegInfo->copyRegToReg(opBlock, I, IncomingReg, SrcReg, RC); Index: llvm/lib/CodeGen/PrologEpilogInserter.cpp diff -u llvm/lib/CodeGen/PrologEpilogInserter.cpp:1.17 llvm/lib/CodeGen/PrologEpilogInserter.cpp:1.18 --- llvm/lib/CodeGen/PrologEpilogInserter.cpp:1.17 Tue Feb 10 14:41:10 2004 +++ llvm/lib/CodeGen/PrologEpilogInserter.cpp Tue Feb 10 15:12:22 2004 @@ -116,12 +116,12 @@ } else { for (unsigned i = 0, e = (*I)->getNumOperands(); i != e; ++i) { MachineOperand &MO = (*I)->getOperand(i); - assert(!MO.isVirtualRegister() && - "Register allocation must be performed!"); - if (MO.isRegister() && MO.isDef() && - MRegisterInfo::isPhysicalRegister(MO.getReg())) + if (MO.isRegister() && MO.isDef()) { + assert(MRegisterInfo::isPhysicalRegister(MO.getReg()) && + "Register allocation must be performed!"); ModifiedRegs[MO.getReg()] = true; // Register is modified - } + } + } ++I; } Index: llvm/lib/CodeGen/RegAllocLinearScan.cpp diff -u llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.43 llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.44 --- llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.43 Fri Feb 6 12:08:18 2004 +++ llvm/lib/CodeGen/RegAllocLinearScan.cpp Tue Feb 10 15:12:22 2004 @@ -405,8 +405,9 @@ for (unsigned i = 0, e = (*currentInstr_)->getNumOperands(); i != e; ++i) { MachineOperand& op = (*currentInstr_)->getOperand(i); - if (op.isVirtualRegister()) { - unsigned virtReg = op.getAllocatedRegNum(); + if (op.isRegister() && + MRegisterInfo::isVirtualRegister(op.getReg())) { + unsigned virtReg = op.getReg(); Virt2PhysMap::const_iterator it = v2pMap_.find(virtReg); if (it != v2pMap_.end()) { DEBUG(std::cerr << "\t\t\t%reg" << it->first @@ -441,7 +442,8 @@ "registers:\n"); for (unsigned i = 0; i != numOperands; ++i) { MachineOperand& op = (*currentInstr_)->getOperand(i); - if (op.isVirtualRegister() && op.isUse()) { + if (op.isRegister() && op.isUse() && + MRegisterInfo::isVirtualRegister(op.getReg())) { unsigned virtReg = op.getAllocatedRegNum(); unsigned physReg = 0; Virt2PhysMap::iterator it = v2pMap_.find(virtReg); @@ -471,9 +473,10 @@ "registers:\n"); for (unsigned i = 0; i != numOperands; ++i) { MachineOperand& op = (*currentInstr_)->getOperand(i); - if (op.isVirtualRegister()) { + if (op.isRegister() && + MRegisterInfo::isVirtualRegister(op.getReg())) { assert(!op.isUse() && "we should not have uses here!"); - unsigned virtReg = op.getAllocatedRegNum(); + unsigned virtReg = op.getReg(); unsigned physReg = 0; Virt2PhysMap::iterator it = v2pMap_.find(virtReg); if (it != v2pMap_.end()) { Index: llvm/lib/CodeGen/RegAllocLocal.cpp diff -u llvm/lib/CodeGen/RegAllocLocal.cpp:1.41 llvm/lib/CodeGen/RegAllocLocal.cpp:1.42 --- llvm/lib/CodeGen/RegAllocLocal.cpp:1.41 Tue Feb 10 14:41:10 2004 +++ llvm/lib/CodeGen/RegAllocLocal.cpp Tue Feb 10 15:12:22 2004 @@ -522,8 +522,8 @@ // for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) if (MI->getOperand(i).isUse() && - !MI->getOperand(i).isDef() && - MI->getOperand(i).isVirtualRegister()){ + !MI->getOperand(i).isDef() && MI->getOperand(i).isRegister() && + MRegisterInfo::isVirtualRegister(MI->getOperand(i).getReg())) { unsigned VirtSrcReg = MI->getOperand(i).getAllocatedRegNum(); unsigned PhysSrcReg = reloadVirtReg(MBB, I, VirtSrcReg); MI->SetMachineOperandReg(i, PhysSrcReg); // Assign the input register @@ -589,8 +589,8 @@ // we need to scavenge a register. // for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) - if (MI->getOperand(i).isDef() && - MI->getOperand(i).isVirtualRegister()) { + if (MI->getOperand(i).isDef() && MI->getOperand(i).isRegister() && + MRegisterInfo::isVirtualRegister(MI->getOperand(i).getReg())) { unsigned DestVirtReg = MI->getOperand(i).getAllocatedRegNum(); unsigned DestPhysReg; Index: llvm/lib/CodeGen/RegAllocSimple.cpp diff -u llvm/lib/CodeGen/RegAllocSimple.cpp:1.47 llvm/lib/CodeGen/RegAllocSimple.cpp:1.48 --- llvm/lib/CodeGen/RegAllocSimple.cpp:1.47 Sun Dec 14 07:24:16 2003 +++ llvm/lib/CodeGen/RegAllocSimple.cpp Tue Feb 10 15:12:22 2004 @@ -174,7 +174,7 @@ for (int i = MI->getNumOperands() - 1; i >= 0; --i) { MachineOperand &op = MI->getOperand(i); - if (op.isVirtualRegister()) { + if (op.isRegister() && MRegisterInfo::isVirtualRegister(op.getReg())) { unsigned virtualReg = (unsigned) op.getAllocatedRegNum(); DEBUG(std::cerr << "op: " << op << "\n"); DEBUG(std::cerr << "\t inst[" << i << "]: "; From criswell at cs.uiuc.edu Tue Feb 10 15:14:02 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Tue Feb 10 15:14:02 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/External/SPEC/CINT95/132.ijpeg/Makefile Message-ID: <200402102113.PAA00442@choi.cs.uiuc.edu> Changes in directory llvm/test/Programs/External/SPEC/CINT95/132.ijpeg: Makefile updated: 1.1 -> 1.2 --- Log message: Added a macro definition that works around a shortcoming in the benchmark. The benchmark uses "extern char * sys_errlist[]," but under Linux, that variable is defined with __const qualifiers. This hack removes those qualifiers and restores peace and order to the galaxy... --- Diffs of the changes: (+4 -1) Index: llvm/test/Programs/External/SPEC/CINT95/132.ijpeg/Makefile diff -u llvm/test/Programs/External/SPEC/CINT95/132.ijpeg/Makefile:1.1 llvm/test/Programs/External/SPEC/CINT95/132.ijpeg/Makefile:1.2 --- llvm/test/Programs/External/SPEC/CINT95/132.ijpeg/Makefile:1.1 Tue Feb 10 13:45:56 2004 +++ llvm/test/Programs/External/SPEC/CINT95/132.ijpeg/Makefile Tue Feb 10 15:12:53 2004 @@ -1,7 +1,10 @@ LEVEL = ../../../../../.. STDIN_FILENAME := specmun.ppm STDOUT_FILENAME := specmun.out -CPPFLAGS += -DNO_SYSERRLIST + +# This line nukes the __const's found in /usr/include/stdio.h that prevent the +# extern char * sys_errlist variable from linking properly. +CPPFLAGS += -D__const="" Source=libpbm1.c libpbm2.c libpbm3.c libpbm4.c libpbm5.c libpgm1.c libpgm2.c libppm1.c libppm2.c libppm3.c libppm4.c libppm5.c spec_image.c spec_jmemdst.c spec_jmemsrc.c spec_main.c rdppm.c wrppm.c rdgif.c wrgif.c rdtarga.c wrtarga.c rdbmp.c wrbmp.c jcapi.c jcparam.c jdatadst.c jcmaster.c jcmarker.c jcmainct.c jcprepct.c jccoefct.c jccolor.c jcsample.c jchuff.c jcdctmgr.c jfdctfst.c jfdctflt.c jfdctint.c jdapi.c jdatasrc.c jdmaster.c jdmarker.c jdmainct.c jdcoefct.c jdpostct.c jddctmgr.c jidctfst.c jidctflt.c jidctint.c jidctred.c jdhuff.c jdsample.c jdcolor.c jquant1.c jquant2.c jdmerge.c jcomapi.c jutils.c jerror.c jmemmgr.c jmemnobs.c include ../../Makefile.spec95 From lattner at cs.uiuc.edu Tue Feb 10 15:19:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 10 15:19:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/PeepholeOptimizer.cpp Message-ID: <200402102118.PAA31772@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: PeepholeOptimizer.cpp updated: 1.11 -> 1.12 --- Log message: Add #include --- Diffs of the changes: (+1 -0) Index: llvm/lib/Target/X86/PeepholeOptimizer.cpp diff -u llvm/lib/Target/X86/PeepholeOptimizer.cpp:1.11 llvm/lib/Target/X86/PeepholeOptimizer.cpp:1.12 --- llvm/lib/Target/X86/PeepholeOptimizer.cpp:1.11 Tue Feb 10 14:55:47 2004 +++ llvm/lib/Target/X86/PeepholeOptimizer.cpp Tue Feb 10 15:18:45 2004 @@ -14,6 +14,7 @@ #include "X86.h" #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/MachineInstrBuilder.h" +#include "llvm/Target/MRegisterInfo.h" #include "Support/Statistic.h" using namespace llvm; From lattner at cs.uiuc.edu Tue Feb 10 15:20:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 10 15:20:02 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveVariables.cpp Message-ID: <200402102119.PAA31881@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveVariables.cpp updated: 1.21 -> 1.22 --- Log message: Add #include --- Diffs of the changes: (+1 -0) Index: llvm/lib/CodeGen/LiveVariables.cpp diff -u llvm/lib/CodeGen/LiveVariables.cpp:1.21 llvm/lib/CodeGen/LiveVariables.cpp:1.22 --- llvm/lib/CodeGen/LiveVariables.cpp:1.21 Tue Feb 10 15:12:22 2004 +++ llvm/lib/CodeGen/LiveVariables.cpp Tue Feb 10 15:18:55 2004 @@ -28,6 +28,7 @@ #include "llvm/CodeGen/LiveVariables.h" #include "llvm/CodeGen/MachineInstr.h" +#include "llvm/Target/MRegisterInfo.h" #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Support/CFG.h" From lattner at cs.uiuc.edu Tue Feb 10 15:20:06 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 10 15:20:06 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/AliasAnalysis.h Message-ID: <200402102119.PAA32350@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis: AliasAnalysis.h updated: 1.9 -> 1.10 --- Log message: Remove some unneeded stuff --- Diffs of the changes: (+1 -3) Index: llvm/include/llvm/Analysis/AliasAnalysis.h diff -u llvm/include/llvm/Analysis/AliasAnalysis.h:1.9 llvm/include/llvm/Analysis/AliasAnalysis.h:1.10 --- llvm/include/llvm/Analysis/AliasAnalysis.h:1.9 Fri Jan 30 16:15:41 2004 +++ llvm/include/llvm/Analysis/AliasAnalysis.h Tue Feb 10 15:19:49 2004 @@ -31,15 +31,13 @@ #define LLVM_ANALYSIS_ALIAS_ANALYSIS_H #include "llvm/Support/CallSite.h" -#include "llvm/Pass.h" +#include "llvm/Pass.h" // Need this for IncludeFile namespace llvm { class LoadInst; class StoreInst; class TargetData; -class AnalysisUsage; -class Pass; class AliasAnalysis { const TargetData *TD; From lattner at cs.uiuc.edu Tue Feb 10 15:22:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 10 15:22:01 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/MachineInstr.h Message-ID: <200402102121.PAA00421@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: MachineInstr.h updated: 1.124 -> 1.125 --- Log message: Remove and simplify some of the bewildering collection of isFOORegister methods which have strangely different semantics in different backends, and noone knew what any did. Getting rid of these ALSO allows the dependence of MachineInstr.h on MRegisterInfo.h to be removed, which makes me much happier, and probably alkis too. :) --- Diffs of the changes: (+8 -14) Index: llvm/include/llvm/CodeGen/MachineInstr.h diff -u llvm/include/llvm/CodeGen/MachineInstr.h:1.124 llvm/include/llvm/CodeGen/MachineInstr.h:1.125 --- llvm/include/llvm/CodeGen/MachineInstr.h:1.124 Tue Feb 10 14:42:11 2004 +++ llvm/include/llvm/CodeGen/MachineInstr.h Tue Feb 10 15:21:17 2004 @@ -16,9 +16,9 @@ #ifndef LLVM_CODEGEN_MACHINEINSTR_H #define LLVM_CODEGEN_MACHINEINSTR_H -#include "llvm/Target/MRegisterInfo.h" #include "Support/Annotation.h" #include "Support/iterator" +#include namespace llvm { @@ -220,19 +220,13 @@ bool isPCRelative() const { return (flags & PCRELATIVE) != 0; } - // This is to finally stop caring whether we have a virtual or machine - // register -- an easier interface is to simply call both virtual and machine - // registers essentially the same, yet be able to distinguish when - // necessary. Thus the instruction selector can just add registers without - // abandon, and the register allocator won't be confused. - bool isVirtualRegister() const { - return (opType == MO_VirtualRegister || opType == MO_MachineRegister) - && regNum >= MRegisterInfo::FirstVirtualRegister; - } - bool isRegister() const { - return opType == MO_VirtualRegister || opType == MO_MachineRegister; - } - bool isMachineRegister() const { return !isVirtualRegister(); } + /// isRegister - Return true if this operand is a register operand. + /// + /// Note: In the sparc backend, this only returns true for "machine + /// registers", not for "virtual registers". + /// + bool isRegister() const { return opType == MO_MachineRegister; } + bool isMachineBasicBlock() const { return opType == MO_MachineBasicBlock; } bool isPCRelativeDisp() const { return opType == MO_PCRelativeDisp; } bool isImmediate() const { From lattner at cs.uiuc.edu Tue Feb 10 15:44:03 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 10 15:44:03 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/MachineInstr.h Message-ID: <200402102143.PAA12246@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: MachineInstr.h updated: 1.125 -> 1.126 --- Log message: Urg, the X86 backend DOES use virtual register operands. :( --- Diffs of the changes: (+7 -4) Index: llvm/include/llvm/CodeGen/MachineInstr.h diff -u llvm/include/llvm/CodeGen/MachineInstr.h:1.125 llvm/include/llvm/CodeGen/MachineInstr.h:1.126 --- llvm/include/llvm/CodeGen/MachineInstr.h:1.125 Tue Feb 10 15:21:17 2004 +++ llvm/include/llvm/CodeGen/MachineInstr.h Tue Feb 10 15:43:11 2004 @@ -220,12 +220,15 @@ bool isPCRelative() const { return (flags & PCRELATIVE) != 0; } - /// isRegister - Return true if this operand is a register operand. + /// isRegister - Return true if this operand is a register operand. The X86 + /// backend currently can't decide whether to use MO_MR or MO_VR to represent + /// them, so we accept both. /// - /// Note: In the sparc backend, this only returns true for "machine - /// registers", not for "virtual registers". + /// Note: The sparc backend should not use this method. /// - bool isRegister() const { return opType == MO_MachineRegister; } + bool isRegister() const { + return opType == MO_MachineRegister || opType == MO_VirtualRegister; + } bool isMachineBasicBlock() const { return opType == MO_MachineBasicBlock; } bool isPCRelativeDisp() const { return opType == MO_PCRelativeDisp; } From criswell at cs.uiuc.edu Tue Feb 10 15:44:07 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Tue Feb 10 15:44:07 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/External/SPEC/CINT95/Makefile Message-ID: <200402102143.PAA04062@choi.cs.uiuc.edu> Changes in directory llvm/test/Programs/External/SPEC/CINT95: Makefile added (r1.1) --- Log message: Adding Makefile for compiling SPEC95 integer benchmarks. --- Diffs of the changes: (+16 -0) Index: llvm/test/Programs/External/SPEC/CINT95/Makefile diff -c /dev/null llvm/test/Programs/External/SPEC/CINT95/Makefile:1.1 *** /dev/null Tue Feb 10 15:43:58 2004 --- llvm/test/Programs/External/SPEC/CINT95/Makefile Tue Feb 10 15:43:47 2004 *************** *** 0 **** --- 1,16 ---- + LEVEL = ../../../../.. + PARALLEL_DIRS := \ + 099.go \ + 129.compress \ + 130.li \ + 147.vortex + + # These are not yet compiling/running right + # 124.m88ksim \ + # 126.gcc \ + # 132.ijpeg \ + # 134.perl \ + + # Get the $(ARCH) setting + include $(LEVEL)/Makefile.config + include ${LEVEL}/test/Programs/Makefile.programs From criswell at cs.uiuc.edu Tue Feb 10 15:45:02 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Tue Feb 10 15:45:02 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/External/SPEC/Makefile.spec95 Message-ID: <200402102144.PAA04072@choi.cs.uiuc.edu> Changes in directory llvm/test/Programs/External/SPEC: Makefile.spec95 added (r1.1) --- Log message: Makefile rules for building SPEC95 benchmarks. --- Diffs of the changes: (+176 -0) Index: llvm/test/Programs/External/SPEC/Makefile.spec95 diff -c /dev/null llvm/test/Programs/External/SPEC/Makefile.spec95:1.1 *** /dev/null Tue Feb 10 15:44:20 2004 --- llvm/test/Programs/External/SPEC/Makefile.spec95 Tue Feb 10 15:44:09 2004 *************** *** 0 **** --- 1,176 ---- + ##===- Makefile.spec ---------------------------------------*- Makefile -*-===## + # + # This makefile contains information for building SPEC as an external test. + # + ##===----------------------------------------------------------------------===## + + include $(LEVEL)/Makefile.config + + # RUN_TYPE - Either ref, test, or train. May be specified on the command line. + ifdef LARGE_PROBLEM_SIZE + RUN_TYPE := train + else + RUN_TYPE := test + endif + + ## Information the test should have provided... + ifndef STDOUT_FILENAME + STDOUT_FILENAME := standard.out + endif + ifndef LDFLAGS + LDFLAGS = -lm + endif + + # Get the current directory, the name of the benchmark, and the current + # subdirectory of the SPEC directory we are in (ie, CINT2000/164.gzip) + # + CURRENT_DIR := $(shell cd .; pwd) + BENCH_NAME := $(subst $(shell cd .. ; pwd),,$(CURRENT_DIR)) + SPEC_SUBDIR := $(subst $(shell cd ../..; pwd),,$(CURRENT_DIR)) + + # Remove any leading /'s from the paths + BENCH_NAME := $(patsubst /%,%,$(BENCH_NAME)) + SPEC_SUBDIR := $(patsubst /%,%,$(SPEC_SUBDIR)) + + SPEC_BENCH_DIR := $(SPEC95_ROOT)/$(SPEC_SUBDIR) + + PROG := $(BENCH_NAME) + ifndef Source + Source := $(wildcard $(SPEC_BENCH_DIR)/src/*.c $(SPEC_BENCH_DIR)/src/*.cc) + endif + + # Disable the default Output/%.out-* targets... + PROGRAMS_HAVE_CUSTOM_RUN_RULES := 1 + SourceDir := $(SPEC_BENCH_DIR)/src/ + + include $(LEVEL)/test/Programs/MultiSource/Makefile.multisrc + + # Do not pass -Wall to compile commands... + LCCFLAGS := -O2 + LCXXFLAGS := -O2 + + CPPFLAGS += -DSPEC_CPU2000 -I $(SPEC_BENCH_DIR)/src/ + SPEC_SANDBOX := $(LLVM_SRC_ROOT)/test/Programs/External/SPEC/Sandbox.sh + + # Information about testing the program... + REF_IN_DIR := $(SPEC_BENCH_DIR)/data/$(RUN_TYPE)/input/ + REF_OUT_DIR := $(SPEC_BENCH_DIR)/data/$(RUN_TYPE)/output/ + LOCAL_OUTPUTS := $(notdir $(wildcard $(REF_OUT_DIR)/*)) + + + # Specify how to generate output from the SPEC programs. Basically we just run + # the program in a sandbox (a special directory we create), then we cat all of + # the outputs together. + + $(PROGRAMS_TO_TEST:%=Output/%.out-nat): \ + Output/%.out-nat: Output/%.native + $(SPEC_SANDBOX) nat-$(RUN_TYPE) $@ $(REF_IN_DIR) \ + $(RUNSAFELY) $(STDIN_FILENAME) $(STDOUT_FILENAME) \ + ../../$< $(RUN_OPTIONS) + -(cd Output/nat-$(RUN_TYPE); cat $(LOCAL_OUTPUTS)) > $@ + -cp Output/nat-$(RUN_TYPE)/$(STDOUT_FILENAME).time $@.time + + $(PROGRAMS_TO_TEST:%=Output/%.out-lli): \ + Output/%.out-lli: Output/%.llvm.bc $(LLI) + $(SPEC_SANDBOX) lli-$(RUN_TYPE) $@ $(REF_IN_DIR) \ + $(RUNSAFELY) $(STDIN_FILENAME) $(STDOUT_FILENAME) \ + $(LLI) $(LLI_OPTS) ../../$< $(RUN_OPTIONS) + -(cd Output/lli-$(RUN_TYPE); cat $(LOCAL_OUTPUTS)) > $@ + -cp Output/lli-$(RUN_TYPE)/$(STDOUT_FILENAME).time $@.time + + $(PROGRAMS_TO_TEST:%=Output/%.out-jit): \ + Output/%.out-jit: Output/%.llvm.bc $(LLI) + $(SPEC_SANDBOX) jit-$(RUN_TYPE) $@ $(REF_IN_DIR) \ + $(RUNSAFELY) $(STDIN_FILENAME) $(STDOUT_FILENAME) \ + $(LLI) $(JIT_OPTS) ../../$< $(RUN_OPTIONS) + -(cd Output/jit-$(RUN_TYPE); cat $(LOCAL_OUTPUTS)) > $@ + -cp Output/jit-$(RUN_TYPE)/$(STDOUT_FILENAME).time $@.time + + $(PROGRAMS_TO_TEST:%=Output/%.out-llc): \ + Output/%.out-llc: Output/%.llc + $(SPEC_SANDBOX) llc-$(RUN_TYPE) $@ $(REF_IN_DIR) \ + $(RUNSAFELY) $(STDIN_FILENAME) $(STDOUT_FILENAME) \ + ../../$< $(RUN_OPTIONS) + -(cd Output/llc-$(RUN_TYPE); cat $(LOCAL_OUTPUTS)) > $@ + -cp Output/llc-$(RUN_TYPE)/$(STDOUT_FILENAME).time $@.time + + $(PROGRAMS_TO_TEST:%=Output/%.out-llc-ls): \ + Output/%.out-llc-ls: Output/%.llc-ls + $(SPEC_SANDBOX) llc-ls-$(RUN_TYPE) $@ $(REF_IN_DIR) \ + $(RUNSAFELY) $(STDIN_FILENAME) $(STDOUT_FILENAME) \ + ../../$< $(RUN_OPTIONS) + -(cd Output/llc-ls-$(RUN_TYPE); cat $(LOCAL_OUTPUTS)) > $@ + -cp Output/llc-ls-$(RUN_TYPE)/$(STDOUT_FILENAME).time $@.time + + $(PROGRAMS_TO_TEST:%=Output/%.out-cbe): \ + Output/%.out-cbe: Output/%.cbe + $(SPEC_SANDBOX) cbe-$(RUN_TYPE) $@ $(REF_IN_DIR) \ + $(RUNSAFELY) $(STDIN_FILENAME) $(STDOUT_FILENAME) \ + ../../$< $(RUN_OPTIONS) + -(cd Output/cbe-$(RUN_TYPE); cat $(LOCAL_OUTPUTS)) > $@ + -cp Output/cbe-$(RUN_TYPE)/$(STDOUT_FILENAME).time $@.time + + $(PROGRAMS_TO_TEST:%=Output/%.trace-out-llc): \ + Output/%.trace-out-llc: Output/%.trace.llc + $(SPEC_SANDBOX) llc-$(RUN_TYPE) $@ $(REF_IN_DIR) \ + $(RUNSAFELY) $(STDIN_FILENAME) $(STDOUT_FILENAME) \ + ../../$< $(RUN_OPTIONS) + -(cd Output/llc-$(RUN_TYPE); cat $(LOCAL_OUTPUTS)) > $@ + -cp Output/llc-$(RUN_TYPE)/$(STDOUT_FILENAME).time $@.time + + $(PROGRAMS_TO_TEST:%=Output/%.trace-out-cbe): \ + Output/%.trace-out-cbe: Output/%.trace.cbe + $(SPEC_SANDBOX) cbe-$(RUN_TYPE) $@ $(REF_IN_DIR) \ + $(RUNSAFELY) $(STDIN_FILENAME) $(STDOUT_FILENAME) \ + ../../$< $(RUN_OPTIONS) + -(cd Output/cbe-$(RUN_TYPE); cat $(LOCAL_OUTPUTS)) > $@ + -cp Output/cbe-$(RUN_TYPE)/$(STDOUT_FILENAME).time $@.time + + + # Specify stdin, reference output, and command line options for the program... + BUGPOINT_OPTIONS += -input=$(STDIN_FILENAME) -output=../$*.out-nat + BUGPOINT_OPTIONS += --args -- $(RUN_OPTIONS) + + # Rules to bugpoint the GCCAS, GCCLD, LLC, or LLI commands... + $(PROGRAMS_TO_TEST:%=Output/%.bugpoint-gccas): \ + Output/%.bugpoint-gccas: Output/%.linked.rll $(LBUGPOINT) \ + Output/gccas-pass-args Output/%.out-nat + $(SPEC_SANDBOX) bugpoint-$(RUN_TYPE) $@ $(REF_IN_DIR) \ + $(LBUGPOINT) ../../$< `cat Output/gccas-pass-args` $(BUGPOINT_OPTIONS) + @echo "===> Leaving Output/bugpoint-$(RUN_TYPE)" + + $(PROGRAMS_TO_TEST:%=Output/%.bugpoint-gccld): \ + Output/%.bugpoint-gccld: Output/%.linked.bc $(LBUGPOINT) \ + Output/gccld-pass-args Output/%.out-nat + $(SPEC_SANDBOX) bugpoint-$(RUN_TYPE) $@ $(REF_IN_DIR) \ + $(LBUGPOINT) ../../$< `cat Output/gccld-pass-args` $(BUGPOINT_OPTIONS) + @echo "===> Leaving Output/bugpoint-$(RUN_TYPE)" + + $(PROGRAMS_TO_TEST:%=Output/%.bugpoint-llc): \ + Output/%.bugpoint-llc: Output/%.llvm.bc $(LBUGPOINT) Output/%.out-nat + $(SPEC_SANDBOX) bugpoint-$(RUN_TYPE) $@ $(REF_IN_DIR) \ + $(LBUGPOINT) ../../$< -run-llc $(BUGPOINT_OPTIONS) + @echo "===> Leaving Output/bugpoint-$(RUN_TYPE)" + + $(PROGRAMS_TO_TEST:%=Output/%.bugpoint-jit): \ + Output/%.bugpoint-jit: Output/%.llvm.bc $(LBUGPOINT) Output/%.out-nat + $(SPEC_SANDBOX) bugpoint-$(RUN_TYPE) $@ $(REF_IN_DIR) \ + $(LBUGPOINT) ../../$< -run-jit $(BUGPOINT_OPTIONS) + @echo "===> Leaving Output/bugpoint-$(RUN_TYPE)" + + + + + + $(PROGRAMS_TO_TEST:%=Output/%.out-tracing): \ + Output/%.out-tracing: Output/%.trace + $(SPEC_SANDBOX) trace-$(RUN_TYPE) $@ $(REF_IN_DIR) \ + $(RUNSAFELY) $(STDIN_FILENAME) $(STDOUT_FILENAME) \ + ../../$< $(RUN_OPTIONS) + -(cd Output/trace-$(RUN_TYPE); cat $(LOCAL_OUTPUTS)) > $@ + -cp Output/trace-$(RUN_TYPE)/$(STDOUT_FILENAME).time $@.time + + $(PROGRAMS_TO_TEST:%=Output/%.performance): \ + Output/%.performance: Output/%.out-llc Output/%.out-tracing + -$(TIMESCRIPT) $* Output/$*.out-llc.time Output/$*.out-tracing.time $@ + From criswell at cs.uiuc.edu Tue Feb 10 15:48:01 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Tue Feb 10 15:48:01 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/External/SPEC/Makefile Message-ID: <200402102147.PAA04095@choi.cs.uiuc.edu> Changes in directory llvm/test/Programs/External/SPEC: Makefile updated: 1.5 -> 1.6 --- Log message: Added the SPEC95 integer benchmarks to the default list of tests to test. --- Diffs of the changes: (+1 -1) Index: llvm/test/Programs/External/SPEC/Makefile diff -u llvm/test/Programs/External/SPEC/Makefile:1.5 llvm/test/Programs/External/SPEC/Makefile:1.6 --- llvm/test/Programs/External/SPEC/Makefile:1.5 Thu Dec 18 10:42:05 2003 +++ llvm/test/Programs/External/SPEC/Makefile Tue Feb 10 15:47:22 2004 @@ -1,3 +1,3 @@ LEVEL = ../../../.. -DIRS := CFP2000 CINT2000 +DIRS := CINT95 CFP2000 CINT2000 include ${LEVEL}/test/Programs/Makefile.programs From brukman at cs.uiuc.edu Tue Feb 10 15:49:03 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Tue Feb 10 15:49:03 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Type.h Message-ID: <200402102148.PAA17255@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: Type.h updated: 1.38 -> 1.39 --- Log message: Doxygenify comment. --- Diffs of the changes: (+1 -1) Index: llvm/include/llvm/Type.h diff -u llvm/include/llvm/Type.h:1.38 llvm/include/llvm/Type.h:1.39 --- llvm/include/llvm/Type.h:1.38 Sun Feb 8 23:40:14 2004 +++ llvm/include/llvm/Type.h Tue Feb 10 15:48:12 2004 @@ -142,7 +142,7 @@ /// isSigned - Return whether an integral numeric type is signed. This is /// true for SByteTy, ShortTy, IntTy, LongTy. Note that this is not true for /// Float and Double. - // + /// virtual bool isSigned() const { return 0; } /// isUnsigned - Return whether a numeric type is unsigned. This is not quite From brukman at cs.uiuc.edu Tue Feb 10 15:51:03 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Tue Feb 10 15:51:03 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/DerivedTypes.h Message-ID: <200402102150.PAA18992@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: DerivedTypes.h updated: 1.53 -> 1.54 --- Log message: Sprinkle liberally with comments, saute with doxygen until readable. --- Diffs of the changes: (+77 -61) Index: llvm/include/llvm/DerivedTypes.h diff -u llvm/include/llvm/DerivedTypes.h:1.53 llvm/include/llvm/DerivedTypes.h:1.54 --- llvm/include/llvm/DerivedTypes.h:1.53 Sun Feb 8 23:40:14 2004 +++ llvm/include/llvm/DerivedTypes.h Tue Feb 10 15:49:59 2004 @@ -53,9 +53,10 @@ /// void notifyUsesThatTypeBecameConcrete(); - // dropAllTypeUses - When this (abstract) type is resolved to be equal to - // another (more concrete) type, we must eliminate all references to other - // types, to avoid some circular reference problems. + /// dropAllTypeUses - When this (abstract) type is resolved to be equal to + /// another (more concrete) type, we must eliminate all references to other + /// types, to avoid some circular reference problems. + /// void dropAllTypeUses(); public: @@ -65,27 +66,27 @@ // are managed by (add|remove)AbstractTypeUser. See comments in // AbstractTypeUser.h for more information. - // addAbstractTypeUser - Notify an abstract type that there is a new user of - // it. This function is called primarily by the PATypeHandle class. - // + /// addAbstractTypeUser - Notify an abstract type that there is a new user of + /// it. This function is called primarily by the PATypeHandle class. + /// void addAbstractTypeUser(AbstractTypeUser *U) const { assert(isAbstract() && "addAbstractTypeUser: Current type not abstract!"); AbstractTypeUsers.push_back(U); } - // 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 annihilated, because there is no way to get a reference to it ever - // again. - // + /// 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 annihilated, because there is no way to get a reference to it ever + /// again. + /// void removeAbstractTypeUser(AbstractTypeUser *U) const; - // refineAbstractTypeTo - This function is used to when it is discovered that - // the 'this' abstract type is actually equivalent to the NewType specified. - // This causes all users of 'this' to switch to reference the more concrete - // type NewType and for 'this' to be deleted. - // + /// refineAbstractTypeTo - This function is used to when it is discovered that + /// the 'this' abstract type is actually equivalent to the NewType specified. + /// This causes all users of 'this' to switch to reference the more concrete + /// type NewType and for 'this' to be deleted. + /// void refineAbstractTypeTo(const Type *NewType); void addRef() const { @@ -117,8 +118,8 @@ }; - - +/// FunctionType - Class to represent function types +/// class FunctionType : public DerivedType { friend class TypeMap; bool isVarArgs; @@ -126,17 +127,19 @@ FunctionType(const FunctionType &); // Do not implement const FunctionType &operator=(const FunctionType &); // Do not implement protected: - // This should really be private, but it squelches a bogus warning - // from GCC to make them protected: warning: `class FunctionType' only - // defines private constructors and has no friends - - // Private ctor - Only can be created by a static member... + /// This should really be private, but it squelches a bogus warning + /// from GCC to make them protected: warning: `class FunctionType' only + /// defines private constructors and has no friends + /// + /// Private ctor - Only can be created by a static member... + /// FunctionType(const Type *Result, const std::vector &Params, bool IsVarArgs); public: /// FunctionType::get - This static method is the primary way of constructing /// a FunctionType + /// static FunctionType *get(const Type *Result, const std::vector &Params, bool isVarArg); @@ -151,9 +154,9 @@ // Parameter type accessors... const Type *getParamType(unsigned i) const { return ContainedTys[i+1]; } - // getNumParams - Return the number of fixed parameters this function type - // requires. This does not consider varargs. - // + /// getNumParams - Return the number of fixed parameters this function type + /// requires. This does not consider varargs. + /// unsigned getNumParams() const { return ContainedTys.size()-1; } // Implement the AbstractTypeUser interface. @@ -171,16 +174,16 @@ }; -// CompositeType - Common super class of ArrayType, StructType, and PointerType -// +/// CompositeType - Common super class of ArrayType, StructType, and PointerType +/// 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 - // element. - // + /// getTypeAtIndex - Given an index value into the type, return the type of + /// the element. + /// virtual const Type *getTypeAtIndex(const Value *V) const = 0; virtual bool indexValid(const Value *V) const = 0; @@ -197,22 +200,26 @@ }; +/// StructType - Class to represent struct types +/// class StructType : public CompositeType { friend class TypeMap; StructType(const StructType &); // Do not implement const StructType &operator=(const StructType &); // Do not implement protected: - // This should really be private, but it squelches a bogus warning - // from GCC to make them protected: warning: `class StructType' only - // defines private constructors and has no friends - - // Private ctor - Only can be created by a static member... + /// This should really be private, but it squelches a bogus warning + /// from GCC to make them protected: warning: `class StructType' only + /// defines private constructors and has no friends + /// + /// Private ctor - Only can be created by a static member... + /// StructType(const std::vector &Types); public: /// StructType::get - This static method is the primary way to create a /// StructType. + /// static StructType *get(const std::vector &Params); // Iterator access to the elements @@ -227,9 +234,9 @@ return ContainedTys[N]; } - // getTypeAtIndex - Given an index value into the type, return the type of the - // element. For a structure type, this must be a constant value... - // + /// getTypeAtIndex - Given an index value into the type, return the type of + /// the element. For a structure type, this must be a constant value... + /// virtual const Type *getTypeAtIndex(const Value *V) const ; virtual bool indexValid(const Value *V) const; @@ -248,12 +255,12 @@ }; -// SequentialType - This is the superclass of the array and pointer type -// classes. Both of these represent "arrays" in memory. The array type -// represents a specifically sized array, pointer types are unsized/unknown size -// arrays. SequentialType holds the common features of both, which stem from -// the fact that both lay their components out in memory identically. -// +/// SequentialType - This is the superclass of the array and pointer type +/// classes. Both of these represent "arrays" in memory. The array type +/// represents a specifically sized array, pointer types are unsized/unknown +/// size arrays. SequentialType holds the common features of both, which stem +/// from the fact that both lay their components out in memory identically. +/// class SequentialType : public CompositeType { SequentialType(const SequentialType &); // Do not implement! const SequentialType &operator=(const SequentialType &); // Do not implement! @@ -266,9 +273,9 @@ public: inline const Type *getElementType() const { return ContainedTys[0]; } - // getTypeAtIndex - Given an index value into the type, return the type of the - // element. For sequential types, there is only one subtype... - // + /// getTypeAtIndex - Given an index value into the type, return the type of + /// the element. For sequential types, there is only one subtype... + /// virtual const Type *getTypeAtIndex(const Value *V) const { return ContainedTys[0]; } @@ -288,6 +295,8 @@ }; +/// ArrayType - Class to represent array types +/// class ArrayType : public SequentialType { friend class TypeMap; unsigned NumElements; @@ -295,16 +304,18 @@ ArrayType(const ArrayType &); // Do not implement const ArrayType &operator=(const ArrayType &); // Do not implement protected: - // This should really be private, but it squelches a bogus warning - // 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... + /// This should really be private, but it squelches a bogus warning + /// 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: /// ArrayType::get - This static method is the primary way to construct an /// ArrayType + /// static ArrayType *get(const Type *ElementType, unsigned NumElements); inline unsigned getNumElements() const { return NumElements; } @@ -324,7 +335,8 @@ }; - +/// PointerType - Class to represent pointers +/// class PointerType : public SequentialType { friend class TypeMap; PointerType(const PointerType &); // Do not implement @@ -356,19 +368,22 @@ }; +/// OpaqueType - Class to represent abstract types +/// class OpaqueType : public DerivedType { 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 - // defines private constructors and has no friends - - // Private ctor - Only can be created by a static member... + /// This should really be private, but it squelches a bogus warning + /// from GCC to make them protected: warning: `class OpaqueType' only + /// defines private constructors and has no friends + /// + /// Private ctor - Only can be created by a static member... OpaqueType(); public: - // OpaqueType::get - Static factory method for the OpaqueType class... + /// OpaqueType::get - Static factory method for the OpaqueType class... + /// static OpaqueType *get() { return new OpaqueType(); // All opaque types are distinct } @@ -429,6 +444,7 @@ /// abstract types. Before every access to the Type*, we check to see if the /// type we are pointing to is forwarding to a new type. If so, we drop our /// reference to the type. +/// inline const Type* PATypeHolder::get() const { const Type *NewTy = Ty->getForwardedType(); if (!NewTy) return Ty; From lattner at cs.uiuc.edu Tue Feb 10 16:12:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 10 16:12:02 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/ProfileInfo.h Message-ID: <200402102211.QAA17908@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis: ProfileInfo.h added (r1.1) --- Log message: An initial implementation of an LLVM ProfileInfo class which is designed to eventually allow Passes to use profiling information to direct them. --- Diffs of the changes: (+43 -0) Index: llvm/include/llvm/Analysis/ProfileInfo.h diff -c /dev/null llvm/include/llvm/Analysis/ProfileInfo.h:1.1 *** /dev/null Tue Feb 10 16:11:52 2004 --- llvm/include/llvm/Analysis/ProfileInfo.h Tue Feb 10 16:11:42 2004 *************** *** 0 **** --- 1,43 ---- + //===- llvm/Analysis/ProfileInfo.h - Profile Info Interface -----*- C++ -*-===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by the LLVM research group and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // This file defines the generic ProfileInfo interface, which is used as the + // common interface used by all clients of profiling information, and + // implemented either by making static guestimations, or by actually reading in + // profiling information gathered by running the program. + // + // Note that to be useful, all profile-based optimizations should preserve + // ProfileInfo, which requires that they notify it when changes to the CFG are + // made. + // + //===----------------------------------------------------------------------===// + + #ifndef LLVM_ANALYSIS_PROFILEINFO_H + #define LLVM_ANALYSIS_PROFILEINFO_H + + namespace llvm { + class BasicBlock; + + struct ProfileInfo { + virtual ~ProfileInfo(); // We want to be subclassed + + //===------------------------------------------------------------------===// + /// Profile Information Queries + /// + virtual unsigned getExecutionCount(BasicBlock *BB) = 0; + + //===------------------------------------------------------------------===// + /// Analysis Update Methods + /// + + }; + + } // End llvm namespace + + #endif From lattner at cs.uiuc.edu Tue Feb 10 16:13:03 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 10 16:13:03 2004 Subject: [llvm-commits] CVS: llvm/lib/Analysis/ProfileInfo.cpp Message-ID: <200402102212.QAA17918@zion.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: ProfileInfo.cpp added (r1.1) --- Log message: An initial implementation of an LLVM ProfileInfo class which is designed to eventually allow Passes to use profiling information to direct them. --- Diffs of the changes: (+42 -0) Index: llvm/lib/Analysis/ProfileInfo.cpp diff -c /dev/null llvm/lib/Analysis/ProfileInfo.cpp:1.1 *** /dev/null Tue Feb 10 16:12:01 2004 --- llvm/lib/Analysis/ProfileInfo.cpp Tue Feb 10 16:11:21 2004 *************** *** 0 **** --- 1,42 ---- + //===- ProfileInfo.cpp - Profile Info Interface ---------------------------===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by the LLVM research group and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // This file implements the abstract ProfileInfo interface, and the default + // "no profile" implementation. + // + //===----------------------------------------------------------------------===// + + #include "llvm/Analysis/ProfileInfo.h" + #include "llvm/Pass.h" + using namespace llvm; + + // Register the AliasAnalysis interface, providing a nice name to refer to. + namespace { + RegisterAnalysisGroup Z("Profile Information"); + } + + ProfileInfo::~ProfileInfo() {} + + + //===----------------------------------------------------------------------===// + // NoProfile ProfileInfo implementation + // + + namespace { + struct NoProfileInfo : public ImmutablePass, public ProfileInfo { + unsigned getExecutionCount(BasicBlock *BB) { return 0; } + }; + + // Register this pass... + RegisterOpt + X("no-profile", "No Profile Information"); + + // Declare that we implement the AliasAnalysis interface + RegisterAnalysisGroup Y; + } // End of anonymous namespace From criswell at cs.uiuc.edu Tue Feb 10 16:30:02 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Tue Feb 10 16:30:02 2004 Subject: [llvm-commits] CVS: llvm/Makefile.config.in Message-ID: <200402102229.QAA22601@choi.cs.uiuc.edu> Changes in directory llvm: Makefile.config.in updated: 1.19 -> 1.20 --- Log message: Added support for configuring SPEC95. --- Diffs of the changes: (+2 -0) Index: llvm/Makefile.config.in diff -u llvm/Makefile.config.in:1.19 llvm/Makefile.config.in:1.20 --- llvm/Makefile.config.in:1.19 Thu Jan 22 16:53:48 2004 +++ llvm/Makefile.config.in Tue Feb 10 16:29:03 2004 @@ -84,11 +84,13 @@ # Set the USE_SPEC variable to enable the use of the SPEC benchmarks. # You must provide the SPEC benchmarks on your own. @USE_SPEC@ + at USE_SPEC95@ # Path to the SPEC benchmarks. If you have the SPEC benchmarks, place the # path here. #SPEC_ROOT := /home/vadve/shared/benchmarks/speccpu2000/benchspec SPEC_ROOT := @SPEC_ROOT@ +SPEC95_ROOT := @SPEC95_ROOT@ # Path to the PAPI code. This is used by the reoptimizer only. #PAPIDIR := /home/vadve/shared/papi-2.3.4.1 From criswell at cs.uiuc.edu Tue Feb 10 16:30:08 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Tue Feb 10 16:30:08 2004 Subject: [llvm-commits] CVS: llvm/autoconf/configure.ac Message-ID: <200402102229.QAA22608@choi.cs.uiuc.edu> Changes in directory llvm/autoconf: configure.ac updated: 1.68 -> 1.69 --- Log message: Added support for configuring SPEC95. --- Diffs of the changes: (+24 -1) Index: llvm/autoconf/configure.ac diff -u llvm/autoconf/configure.ac:1.68 llvm/autoconf/configure.ac:1.69 --- llvm/autoconf/configure.ac:1.68 Thu Jan 22 15:55:15 2004 +++ llvm/autoconf/configure.ac Tue Feb 10 16:29:06 2004 @@ -55,6 +55,7 @@ AC_CONFIG_MAKEFILE(test/Programs/External/Makefile) AC_CONFIG_MAKEFILE(test/Programs/External/SPEC/Makefile) AC_CONFIG_MAKEFILE(test/Programs/External/SPEC/Makefile.spec) +AC_CONFIG_MAKEFILE(test/Programs/External/SPEC/Makefile.spec95) AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Makefile) AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Makefile.multisrc) AC_CONFIG_MAKEFILE(test/Programs/MultiSource/Benchmarks/FreeBench/analyzer/test.in) @@ -281,7 +282,7 @@ AC_SUBST(ENABLE_OPTIMIZED,[[ENABLE_OPTIMIZED=1]]) fi -dnl Spec Benchmarks +dnl Spec 2000 Benchmarks AC_ARG_ENABLE(spec2000,AC_HELP_STRING([--enable-spec2000],[Compile SPEC 2000 benchmarks (default is NO)]),,enableval=no) if test ${enableval} = "no" then @@ -301,6 +302,28 @@ AC_SUBST(SPEC_ROOT,[${enableval}]) fi AC_SUBST(USE_SPEC,[[USE_SPEC=1]]) +fi + +dnl Spec 95 Benchmarks +AC_ARG_ENABLE(spec95,AC_HELP_STRING([--enable-spec95],[Compile SPEC 95 benchmarks (default is NO)]),,enableval=no) +if test ${enableval} = "no" +then + if test -d /home/vadve/shared/benchmarks/spec95_sparcv9/benchspec + then + AC_SUBST(SPEC95_ROOT,[/home/vadve/shared/benchmarks/spec95_sparcv9/benchspec]) + AC_SUBST(USE_SPEC95,[[USE_SPEC95=1]]) + else + AC_SUBST(USE_SPEC95,[[]]) + AC_SUBST(SPEC95_ROOT,[]) + fi +else + if test ${enableval} = "" + then + AC_SUBST(SPEC95_ROOT,[/home/vadve/shared/benchmarks/spec95_sparcv9/benchspec]) + else + AC_SUBST(SPEC95_ROOT,[${enableval}]) + fi + AC_SUBST(USE_SPEC95,[[USE_SPEC95=1]]) fi dnl Precompiled Bytecode Option From criswell at cs.uiuc.edu Tue Feb 10 16:30:11 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Tue Feb 10 16:30:11 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/External/SPEC/Makefile Message-ID: <200402102229.QAA22625@choi.cs.uiuc.edu> Changes in directory llvm/test/Programs/External/SPEC: Makefile updated: 1.6 -> 1.7 --- Log message: Make SPEC95 configurable. --- Diffs of the changes: (+10 -1) Index: llvm/test/Programs/External/SPEC/Makefile diff -u llvm/test/Programs/External/SPEC/Makefile:1.6 llvm/test/Programs/External/SPEC/Makefile:1.7 --- llvm/test/Programs/External/SPEC/Makefile:1.6 Tue Feb 10 15:47:22 2004 +++ llvm/test/Programs/External/SPEC/Makefile Tue Feb 10 16:29:40 2004 @@ -1,3 +1,12 @@ LEVEL = ../../../.. -DIRS := CINT95 CFP2000 CINT2000 +DIRS := CFP2000 CINT2000 +include ${LEVEL}/Makefile.config + +# +# Add SPEC95 if we've got it. +# +ifeq ($(USE_SPEC95),1) +DIRS += CINT95 +endif + include ${LEVEL}/test/Programs/Makefile.programs From criswell at cs.uiuc.edu Tue Feb 10 16:35:01 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Tue Feb 10 16:35:01 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/External/Makefile Message-ID: <200402102234.QAA24475@choi.cs.uiuc.edu> Changes in directory llvm/test/Programs/External: Makefile updated: 1.4 -> 1.5 --- Log message: Allow for SPEC 2000 and SPEC 95 to be enabled independently of each other. --- Diffs of the changes: (+0 -3) Index: llvm/test/Programs/External/Makefile diff -u llvm/test/Programs/External/Makefile:1.4 llvm/test/Programs/External/Makefile:1.5 --- llvm/test/Programs/External/Makefile:1.4 Thu Dec 18 10:41:58 2003 +++ llvm/test/Programs/External/Makefile Tue Feb 10 16:34:42 2004 @@ -9,8 +9,5 @@ # Create the list of directories to compile # DIRS := SPEC -ifndef USE_SPEC -DIRS := $(filter-out SPEC/, $(DIRS)) -endif include ${LEVEL}/test/Programs/Makefile.programs From criswell at cs.uiuc.edu Tue Feb 10 16:35:06 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Tue Feb 10 16:35:06 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/External/SPEC/Makefile Message-ID: <200402102234.QAA24482@choi.cs.uiuc.edu> Changes in directory llvm/test/Programs/External/SPEC: Makefile updated: 1.7 -> 1.8 --- Log message: Allow for SPEC 2000 and SPEC 95 to be enabled independently of each other. --- Diffs of the changes: (+9 -4) Index: llvm/test/Programs/External/SPEC/Makefile diff -u llvm/test/Programs/External/SPEC/Makefile:1.7 llvm/test/Programs/External/SPEC/Makefile:1.8 --- llvm/test/Programs/External/SPEC/Makefile:1.7 Tue Feb 10 16:29:40 2004 +++ llvm/test/Programs/External/SPEC/Makefile Tue Feb 10 16:34:44 2004 @@ -1,12 +1,17 @@ LEVEL = ../../../.. -DIRS := CFP2000 CINT2000 +DIRS := CINT95 CFP2000 CINT2000 include ${LEVEL}/Makefile.config # -# Add SPEC95 if we've got it. +# Remove SPEC95 and SPEC2000 per the user's configuration # -ifeq ($(USE_SPEC95),1) -DIRS += CINT95 +ifndef USE_SPEC +DIRS := $(filter-out CFP2000/, $(DIRS)) +DIRS := $(filter-out CINT2000/, $(DIRS)) +endif + +ifndef USE_SPEC95 +DIRS := $(filter-out CINT95/, $(DIRS)) endif include ${LEVEL}/test/Programs/Makefile.programs From criswell at cs.uiuc.edu Tue Feb 10 16:37:01 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Tue Feb 10 16:37:01 2004 Subject: [llvm-commits] CVS: llvm/configure Message-ID: <200402102236.QAA25051@choi.cs.uiuc.edu> Changes in directory llvm: configure updated: 1.71 -> 1.72 --- Log message: Updated to handle the new SPEC95 configuration options. --- Diffs of the changes: (+71 -29) Index: llvm/configure diff -u llvm/configure:1.71 llvm/configure:1.72 --- llvm/configure:1.71 Thu Jan 22 15:55:02 2004 +++ llvm/configure Tue Feb 10 16:36:35 2004 @@ -465,7 +465,7 @@ #endif" ac_unique_file=""Makefile.config.in"" -ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS subdirs INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os OS LLVMGCCDIR ARCH CXX CXXFLAGS LDFLAGS CPPFLAGS ac_ct_CXX EXEEXT OBJEXT CC CFLAGS ac_ct_CC CPP ifGNUmake LEX LEXLIB LEX_OUTPUT_ROOT YACC BISON EGREP LN_S ECHO AR ac_ct_AR RANLIB ac_ct_RANLIB STRIP ac_ct_STRIP CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL DOT ETAGS ETAGSFLAGS PYTHON QMTEST ALLOCA MMAP_FILE ENABLE_OPTIMIZED SPEC_ROOT USE_SPEC UPB DISABLE_LLC_DIFFS JIT LLVMCC1 LLVMCC1PLUS BCR PAPIDIR SHLIBEXT LIBOBJS LTLIBOBJS' +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS subdirs INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os OS LLVMGCCDIR ARCH CXX CXXFLAGS LDFLAGS CPPFLAGS ac_ct_CXX EXEEXT OBJEXT CC CFLAGS ac_ct_CC CPP ifGNUmake LEX LEXLIB LEX_OUTPUT_ROOT YACC BISON EGREP LN_S ECHO AR ac_ct_AR RANLIB ac_ct_RANLIB STRIP ac_ct_STRIP CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL DOT ETAGS ETAGSFLAGS PYTHON QMTEST ALLOCA MMAP_FILE ENABLE_OPTIMIZED SPEC_ROOT USE_SPEC SPEC95_ROOT USE_SPEC95 UPB DISABLE_LLC_DIFFS JIT LLVMCC1 LLVMCC1PLUS BCR PAPIDIR SHLIBEXT LIBOBJS LTLIBOBJS' ac_subst_files='' # Initialize some variables set by options. @@ -1032,6 +1032,7 @@ --disable-libtool-lock avoid locking (might break parallel builds) --enable-optimized Compile with optimizations enabled (default is NO) --enable-spec2000 Compile SPEC 2000 benchmarks (default is NO) + --enable-spec95 Compile SPEC 95 benchmarks (default is NO) --enable-precompiled_bytecode Use pre-compiled bytecode (default is NO) --enable-llc_diffs Enable LLC Diffs when testing (default is YES) @@ -1614,6 +1615,9 @@ ac_config_commands="$ac_config_commands test/Programs/External/SPEC/Makefile.spec" + ac_config_commands="$ac_config_commands test/Programs/External/SPEC/Makefile.spec95" + + ac_config_commands="$ac_config_commands test/Programs/MultiSource/Makefile" @@ -4036,7 +4040,7 @@ ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 4039 "configure"' > conftest.$ac_ext + echo '#line 4043 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -4877,7 +4881,7 @@ # Provide some information about the compiler. -echo "$as_me:4880:" \ +echo "$as_me:4884:" \ "checking for Fortran 77 compiler version" >&5 ac_compiler=`set X $ac_compile; echo $2` { (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 @@ -5882,11 +5886,11 @@ -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:5885: $lt_compile\"" >&5) + (eval echo "\"\$as_me:5889: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:5889: \$? = $ac_status" >&5 + echo "$as_me:5893: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -6114,11 +6118,11 @@ -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:6117: $lt_compile\"" >&5) + (eval echo "\"\$as_me:6121: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:6121: \$? = $ac_status" >&5 + echo "$as_me:6125: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -6181,11 +6185,11 @@ -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:6184: $lt_compile\"" >&5) + (eval echo "\"\$as_me:6188: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:6188: \$? = $ac_status" >&5 + echo "$as_me:6192: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -8193,7 +8197,7 @@ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext <&5) + (eval echo "\"\$as_me:10430: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:10430: \$? = $ac_status" >&5 + echo "$as_me:10434: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -10490,11 +10494,11 @@ -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:10493: $lt_compile\"" >&5) + (eval echo "\"\$as_me:10497: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:10497: \$? = $ac_status" >&5 + echo "$as_me:10501: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -11733,7 +11737,7 @@ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext <&5) + (eval echo "\"\$as_me:12660: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:12660: \$? = $ac_status" >&5 + echo "$as_me:12664: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -12720,11 +12724,11 @@ -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:12723: $lt_compile\"" >&5) + (eval echo "\"\$as_me:12727: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:12727: \$? = $ac_status" >&5 + echo "$as_me:12731: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -14660,11 +14664,11 @@ -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:14663: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14667: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:14667: \$? = $ac_status" >&5 + echo "$as_me:14671: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -14892,11 +14896,11 @@ -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:14895: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14899: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:14899: \$? = $ac_status" >&5 + echo "$as_me:14903: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -14959,11 +14963,11 @@ -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:14962: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14966: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:14966: \$? = $ac_status" >&5 + echo "$as_me:14970: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -16971,7 +16975,7 @@ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext < Changes in directory llvm/test/Programs/External/SPEC/CINT95/132.ijpeg: Makefile updated: 1.2 -> 1.3 --- Log message: Corrected the options to match what is given in SPEC. --- Diffs of the changes: (+1 -0) Index: llvm/test/Programs/External/SPEC/CINT95/132.ijpeg/Makefile diff -u llvm/test/Programs/External/SPEC/CINT95/132.ijpeg/Makefile:1.2 llvm/test/Programs/External/SPEC/CINT95/132.ijpeg/Makefile:1.3 --- llvm/test/Programs/External/SPEC/CINT95/132.ijpeg/Makefile:1.2 Tue Feb 10 15:12:53 2004 +++ llvm/test/Programs/External/SPEC/CINT95/132.ijpeg/Makefile Tue Feb 10 17:01:55 2004 @@ -1,6 +1,7 @@ LEVEL = ../../../../../.. STDIN_FILENAME := specmun.ppm STDOUT_FILENAME := specmun.out +RUN_OPTIONS := -image_file specmun.ppm -compression.quality 90 -compression.optimize_coding 0 -compression.smoothing_factor 90 -difference.image 1 -difference.x_stride 10 -difference.y_stride 10 -verbose 1 -GO.findoptcomp # This line nukes the __const's found in /usr/include/stdio.h that prevent the # extern char * sys_errlist variable from linking properly. From criswell at cs.uiuc.edu Tue Feb 10 17:03:11 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Tue Feb 10 17:03:11 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/External/SPEC/CINT95/Makefile Message-ID: <200402102302.RAA28073@choi.cs.uiuc.edu> Changes in directory llvm/test/Programs/External/SPEC/CINT95: Makefile updated: 1.1 -> 1.2 --- Log message: Enable 132.ijpeg as it now works. --- Diffs of the changes: (+1 -1) Index: llvm/test/Programs/External/SPEC/CINT95/Makefile diff -u llvm/test/Programs/External/SPEC/CINT95/Makefile:1.1 llvm/test/Programs/External/SPEC/CINT95/Makefile:1.2 --- llvm/test/Programs/External/SPEC/CINT95/Makefile:1.1 Tue Feb 10 15:43:47 2004 +++ llvm/test/Programs/External/SPEC/CINT95/Makefile Tue Feb 10 17:02:12 2004 @@ -3,12 +3,12 @@ 099.go \ 129.compress \ 130.li \ + 132.ijpeg \ 147.vortex # These are not yet compiling/running right # 124.m88ksim \ # 126.gcc \ -# 132.ijpeg \ # 134.perl \ # Get the $(ARCH) setting From lattner at cs.uiuc.edu Tue Feb 10 19:18:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 10 19:18:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Utils/SimplifyCFG.cpp Message-ID: <200402110117.TAA10046@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Utils: SimplifyCFG.cpp updated: 1.20 -> 1.21 --- Log message: The hasConstantReferences predicate always returns false. --- Diffs of the changes: (+53 -56) Index: llvm/lib/Transforms/Utils/SimplifyCFG.cpp diff -u llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.20 llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.21 --- llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.20 Sun Feb 8 15:43:53 2004 +++ llvm/lib/Transforms/Utils/SimplifyCFG.cpp Tue Feb 10 19:17:07 2004 @@ -105,9 +105,9 @@ assert(BB->getTerminator() && "Degenerate basic block encountered!"); assert(&BB->getParent()->front() != BB && "Can't Simplify entry block!"); - // Check to see if the first instruction in this block is just an - // 'llvm.unwind'. If so, replace any invoke instructions which use this as an - // exception destination with call instructions. + // Check to see if the first instruction in this block is just an unwind. If + // so, replace any invoke instructions which use this as an exception + // destination with call instructions. // if (UnwindInst *UI = dyn_cast(BB->getTerminator())) if (BB->begin() == BasicBlock::iterator(UI)) { // Empty block? @@ -136,8 +136,7 @@ } // Remove basic blocks that have no predecessors... which are unreachable. - if (pred_begin(BB) == pred_end(BB) && - !BB->hasConstantReferences()) { + if (pred_begin(BB) == pred_end(BB)) { //cerr << "Removing BB: \n" << BB; // Loop through all of our successors and make sure they know that one @@ -237,64 +236,62 @@ // pred, and if there is only one distinct successor of the predecessor, and // if there are no PHI nodes. // - if (!BB->hasConstantReferences()) { - pred_iterator PI(pred_begin(BB)), PE(pred_end(BB)); - BasicBlock *OnlyPred = *PI++; - for (; PI != PE; ++PI) // Search all predecessors, see if they are all same - if (*PI != OnlyPred) { - OnlyPred = 0; // There are multiple different predecessors... + pred_iterator PI(pred_begin(BB)), PE(pred_end(BB)); + BasicBlock *OnlyPred = *PI++; + for (; PI != PE; ++PI) // Search all predecessors, see if they are all same + if (*PI != OnlyPred) { + OnlyPred = 0; // There are multiple different predecessors... + break; + } + + BasicBlock *OnlySucc = 0; + if (OnlyPred && OnlyPred != BB && // Don't break self loops + OnlyPred->getTerminator()->getOpcode() != Instruction::Invoke) { + // Check to see if there is only one distinct successor... + succ_iterator SI(succ_begin(OnlyPred)), SE(succ_end(OnlyPred)); + OnlySucc = BB; + for (; SI != SE; ++SI) + if (*SI != OnlySucc) { + OnlySucc = 0; // There are multiple distinct successors! break; } - - BasicBlock *OnlySucc = 0; - if (OnlyPred && OnlyPred != BB && // Don't break self loops - OnlyPred->getTerminator()->getOpcode() != Instruction::Invoke) { - // Check to see if there is only one distinct successor... - succ_iterator SI(succ_begin(OnlyPred)), SE(succ_end(OnlyPred)); - OnlySucc = BB; - for (; SI != SE; ++SI) - if (*SI != OnlySucc) { - OnlySucc = 0; // There are multiple distinct successors! - break; - } - } + } - if (OnlySucc) { - //cerr << "Merging: " << BB << "into: " << OnlyPred; - TerminatorInst *Term = OnlyPred->getTerminator(); - - // Resolve any PHI nodes at the start of the block. They are all - // guaranteed to have exactly one entry if they exist, unless there are - // multiple duplicate (but guaranteed to be equal) entries for the - // incoming edges. This occurs when there are multiple edges from - // OnlyPred to OnlySucc. - // - while (PHINode *PN = dyn_cast(&BB->front())) { - PN->replaceAllUsesWith(PN->getIncomingValue(0)); - BB->getInstList().pop_front(); // Delete the phi node... - } + if (OnlySucc) { + //cerr << "Merging: " << BB << "into: " << OnlyPred; + TerminatorInst *Term = OnlyPred->getTerminator(); + + // Resolve any PHI nodes at the start of the block. They are all + // guaranteed to have exactly one entry if they exist, unless there are + // multiple duplicate (but guaranteed to be equal) entries for the + // incoming edges. This occurs when there are multiple edges from + // OnlyPred to OnlySucc. + // + while (PHINode *PN = dyn_cast(&BB->front())) { + PN->replaceAllUsesWith(PN->getIncomingValue(0)); + BB->getInstList().pop_front(); // Delete the phi node... + } - // Delete the unconditional branch from the predecessor... - OnlyPred->getInstList().pop_back(); + // Delete the unconditional branch from the predecessor... + OnlyPred->getInstList().pop_back(); - // Move all definitions in the successor to the predecessor... - OnlyPred->getInstList().splice(OnlyPred->end(), BB->getInstList()); + // Move all definitions in the successor to the predecessor... + OnlyPred->getInstList().splice(OnlyPred->end(), BB->getInstList()); - // Make all PHI nodes that referred to BB now refer to Pred as their - // source... - BB->replaceAllUsesWith(OnlyPred); - - std::string OldName = BB->getName(); - - // Erase basic block from the function... - M->getBasicBlockList().erase(BB); - - // Inherit predecessors name if it exists... - if (!OldName.empty() && !OnlyPred->hasName()) - OnlyPred->setName(OldName); + // Make all PHI nodes that referred to BB now refer to Pred as their + // source... + BB->replaceAllUsesWith(OnlyPred); + + std::string OldName = BB->getName(); + + // Erase basic block from the function... + M->getBasicBlockList().erase(BB); + + // Inherit predecessors name if it exists... + if (!OldName.empty() && !OnlyPred->hasName()) + OnlyPred->setName(OldName); - return true; - } + return true; } return Changed; From lattner at cs.uiuc.edu Tue Feb 10 19:18:06 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 10 19:18:06 2004 Subject: [llvm-commits] CVS: llvm/lib/VMCore/BasicBlock.cpp Message-ID: <200402110117.TAA10061@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: BasicBlock.cpp updated: 1.41 -> 1.42 --- Log message: Remove obsolete method --- Diffs of the changes: (+0 -13) Index: llvm/lib/VMCore/BasicBlock.cpp diff -u llvm/lib/VMCore/BasicBlock.cpp:1.41 llvm/lib/VMCore/BasicBlock.cpp:1.42 --- llvm/lib/VMCore/BasicBlock.cpp:1.41 Tue Feb 3 21:57:50 2004 +++ llvm/lib/VMCore/BasicBlock.cpp Tue Feb 10 19:17:33 2004 @@ -120,19 +120,6 @@ I->dropAllReferences(); } -// hasConstantReferences() - This predicate is true if there is a -// reference to this basic block in the constant pool for this method. For -// example, if a block is reached through a switch table, that table resides -// in the constant pool, and the basic block is reference from it. -// -bool BasicBlock::hasConstantReferences() const { - for (use_const_iterator I = use_begin(), E = use_end(); I != E; ++I) - if (isa((Value*)*I)) - return true; - - return false; -} - // removePredecessor - This method is used to notify a BasicBlock that the // specified Predecessor of the block is no longer able to reach it. This is // actually not used to update the Predecessor list, but is actually used to From lattner at cs.uiuc.edu Tue Feb 10 19:19:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 10 19:19:02 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/BasicBlock.h Message-ID: <200402110118.TAA10372@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: BasicBlock.h updated: 1.37 -> 1.38 --- Log message: Remove long obsolete method. switch instructions are first class entities in the CFG, and have been for a LOOOONG time. --- Diffs of the changes: (+0 -7) Index: llvm/include/llvm/BasicBlock.h diff -u llvm/include/llvm/BasicBlock.h:1.37 llvm/include/llvm/BasicBlock.h:1.38 --- llvm/include/llvm/BasicBlock.h:1.37 Tue Feb 3 21:57:34 2004 +++ llvm/include/llvm/BasicBlock.h Tue Feb 10 19:17:58 2004 @@ -133,13 +133,6 @@ return V->getValueType() == Value::BasicBlockVal; } - /// hasConstantReferences() - This predicate is true if there is a - /// reference to this basic block in the constant pool for this method. For - /// example, if a block is reached through a switch table, that table resides - /// in the constant pool, and the basic block is reference from it. - /// - bool hasConstantReferences() const; - /// dropAllReferences() - This function causes all the subinstructions to "let /// go" of all references that they are maintaining. This allows one to /// 'delete' a whole class at a time, even though there may be circular From lattner at cs.uiuc.edu Tue Feb 10 21:09:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 10 21:09:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/Target.td Message-ID: <200402110308.VAA27661@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target: Target.td updated: 1.24 -> 1.25 --- Log message: Expose the "Other" value type to tablegen targets --- Diffs of the changes: (+1 -0) Index: llvm/lib/Target/Target.td diff -u llvm/lib/Target/Target.td:1.24 llvm/lib/Target/Target.td:1.25 --- llvm/lib/Target/Target.td:1.24 Tue Oct 21 10:17:13 2003 +++ llvm/lib/Target/Target.td Tue Feb 10 21:08:45 2004 @@ -25,6 +25,7 @@ int Value = value; } +def OtherVT: ValueType<0 , 0>; // "Other" value def i1 : ValueType<1 , 1>; // One bit boolean value def i8 : ValueType<8 , 2>; // 8-bit integer value def i16 : ValueType<16 , 3>; // 16-bit integer value From lattner at cs.uiuc.edu Tue Feb 10 21:30:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 10 21:30:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Support/Mangler.cpp Message-ID: <200402110329.VAA04719@zion.cs.uiuc.edu> Changes in directory llvm/lib/Support: Mangler.cpp updated: 1.8 -> 1.9 --- Log message: Initialize the count instance variable. --- Diffs of the changes: (+1 -1) Index: llvm/lib/Support/Mangler.cpp diff -u llvm/lib/Support/Mangler.cpp:1.8 llvm/lib/Support/Mangler.cpp:1.9 --- llvm/lib/Support/Mangler.cpp:1.8 Sun Dec 14 15:35:53 2003 +++ llvm/lib/Support/Mangler.cpp Tue Feb 10 21:29:16 2004 @@ -81,7 +81,7 @@ } Mangler::Mangler(Module &m, bool addUnderscorePrefix) - : M(m), AddUnderscorePrefix(addUnderscorePrefix) { + : M(m), AddUnderscorePrefix(addUnderscorePrefix), Count(0) { // Calculate which global values have names that will collide when we throw // away type information. std::set FoundNames; From lattner at cs.uiuc.edu Tue Feb 10 21:36:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 10 21:36:01 2004 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/SimplifyCFG/PhiEliminate.ll Message-ID: <200402110335.VAA05972@zion.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/SimplifyCFG: PhiEliminate.ll added (r1.1) --- Log message: New feature testcase for simplifycfg. --- Diffs of the changes: (+35 -0) Index: llvm/test/Regression/Transforms/SimplifyCFG/PhiEliminate.ll diff -c /dev/null llvm/test/Regression/Transforms/SimplifyCFG/PhiEliminate.ll:1.1 *** /dev/null Tue Feb 10 21:35:14 2004 --- llvm/test/Regression/Transforms/SimplifyCFG/PhiEliminate.ll Tue Feb 10 21:35:04 2004 *************** *** 0 **** --- 1,35 ---- + ; Test a bunch of cases where the cfg simplification code should + ; be able to fold PHI nodes into computation in common cases. Folding the PHI + ; nodes away allows the branches to be eliminated, performing a simple form of + ; 'if conversion'. + + ; RUN: llvm-as < %s | opt -simplifycfg | llvm-dis > Output/%s.xform + ; RUN: not grep phi Output/%s.xform && grep ret Output/%s.xform + + declare void %use(bool) + declare void %use(int) + + void %test(bool %c, int %V) { + br bool %c, label %T, label %F + T: + br label %F + F: + %B1 = phi bool [true, %0], [false, %T] + %B2 = phi bool [true, %T], [false, %0] + %I1 = phi int [1, %T], [0, %0] + %I2 = phi int [1, %0], [0, %T] + %I3 = phi int [17, %T], [0, %0] + %I4 = phi int [17, %T], [5, %0] + %I5 = phi int [%V, %T], [0, %0] + %I6 = phi int [%V, %0], [0, %T] + call void %use(bool %B1) + call void %use(bool %B2) + call void %use(int %I1) + call void %use(int %I2) + call void %use(int %I3) + call void %use(int %I4) + call void %use(int %I5) + call void %use(int %I6) + ret void + } + From lattner at cs.uiuc.edu Tue Feb 10 21:37:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 10 21:37:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Utils/SimplifyCFG.cpp Message-ID: <200402110336.VAA05995@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Utils: SimplifyCFG.cpp updated: 1.21 -> 1.22 --- Log message: Implement SimplifyCFG/PhiEliminate.ll Having a proper 'select' instruction would allow the elimination of a lot of the special case cruft in this patch, but we don't have one yet. --- Diffs of the changes: (+234 -5) Index: llvm/lib/Transforms/Utils/SimplifyCFG.cpp diff -u llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.21 llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.22 --- llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.21 Tue Feb 10 19:17:07 2004 +++ llvm/lib/Transforms/Utils/SimplifyCFG.cpp Tue Feb 10 21:36:04 2004 @@ -12,11 +12,8 @@ //===----------------------------------------------------------------------===// #include "llvm/Transforms/Utils/Local.h" -#include "llvm/Constant.h" -#include "llvm/Intrinsics.h" -#include "llvm/iPHINode.h" -#include "llvm/iTerminators.h" -#include "llvm/iOther.h" +#include "llvm/Constants.h" +#include "llvm/Instructions.h" #include "llvm/Support/CFG.h" #include #include @@ -89,6 +86,119 @@ return false; } +/// GetIfCondition - Given a basic block (BB) with two predecessors (and +/// presumably PHI nodes in it), check to see if the merge at this block is due +/// to an "if condition". If so, return the boolean condition that determines +/// which entry into BB will be taken. Also, return by references the block +/// that will be entered from if the condition is true, and the block that will +/// be entered if the condition is false. +/// +/// +static Value *GetIfCondition(BasicBlock *BB, + BasicBlock *&IfTrue, BasicBlock *&IfFalse) { + assert(std::distance(pred_begin(BB), pred_end(BB)) == 2 && + "Function can only handle blocks with 2 predecessors!"); + BasicBlock *Pred1 = *pred_begin(BB); + BasicBlock *Pred2 = *++pred_begin(BB); + + // We can only handle branches. Other control flow will be lowered to + // branches if possible anyway. + if (!isa(Pred1->getTerminator()) || + !isa(Pred2->getTerminator())) + return 0; + BranchInst *Pred1Br = cast(Pred1->getTerminator()); + BranchInst *Pred2Br = cast(Pred2->getTerminator()); + + // Eliminate code duplication by ensuring that Pred1Br is conditional if + // either are. + if (Pred2Br->isConditional()) { + // If both branches are conditional, we don't have an "if statement". In + // reality, we could transform this case, but since the condition will be + // required anyway, we stand no chance of eliminating it, so the xform is + // probably not profitable. + if (Pred1Br->isConditional()) + return 0; + + std::swap(Pred1, Pred2); + std::swap(Pred1Br, Pred2Br); + } + + if (Pred1Br->isConditional()) { + // If we found a conditional branch predecessor, make sure that it branches + // to BB and Pred2Br. If it doesn't, this isn't an "if statement". + if (Pred1Br->getSuccessor(0) == BB && + Pred1Br->getSuccessor(1) == Pred2) { + IfTrue = Pred1; + IfFalse = Pred2; + } else if (Pred1Br->getSuccessor(0) == Pred2 && + Pred1Br->getSuccessor(1) == BB) { + IfTrue = Pred2; + IfFalse = Pred1; + } else { + // We know that one arm of the conditional goes to BB, so the other must + // go somewhere unrelated, and this must not be an "if statement". + return 0; + } + + // The only thing we have to watch out for here is to make sure that Pred2 + // doesn't have incoming edges from other blocks. If it does, the condition + // doesn't dominate BB. + if (++pred_begin(Pred2) != pred_end(Pred2)) + return 0; + + return Pred1Br->getCondition(); + } + + // Ok, if we got here, both predecessors end with an unconditional branch to + // BB. Don't panic! If both blocks only have a single (identical) + // predecessor, and THAT is a conditional branch, then we're all ok! + if (pred_begin(Pred1) == pred_end(Pred1) || + ++pred_begin(Pred1) != pred_end(Pred1) || + pred_begin(Pred2) == pred_end(Pred2) || + ++pred_begin(Pred2) != pred_end(Pred2) || + *pred_begin(Pred1) != *pred_begin(Pred2)) + return 0; + + // Otherwise, if this is a conditional branch, then we can use it! + BasicBlock *CommonPred = *pred_begin(Pred1); + if (BranchInst *BI = dyn_cast(CommonPred->getTerminator())) { + assert(BI->isConditional() && "Two successors but not conditional?"); + if (BI->getSuccessor(0) == Pred1) { + IfTrue = Pred1; + IfFalse = Pred2; + } else { + IfTrue = Pred2; + IfFalse = Pred1; + } + return BI->getCondition(); + } + return 0; +} + + +// If we have a merge point of an "if condition" as accepted above, return true +// if the specified value dominates the block. We don't handle the true +// generality of domination here, just a special case which works well enough +// for us. +static bool DominatesMergePoint(Value *V, BasicBlock *BB) { + if (Instruction *I = dyn_cast(V)) { + BasicBlock *PBB = I->getParent(); + // If this instruction is defined in a block that contains an unconditional + // branch to BB, then it must be in the 'conditional' part of the "if + // statement". + if (isa(PBB->getTerminator()) && + cast(PBB->getTerminator())->isUnconditional() && + cast(PBB->getTerminator())->getSuccessor(0) == BB) + return false; + + // We also don't want to allow wierd loops that might have the "if + // condition" in the bottom of this block. + if (PBB == BB) return false; + } + + // Non-instructions all dominate instructions. + return true; +} // SimplifyCFG - This function is used to do simplification of a CFG. For // example, it adjusts branches to branches to eliminate the extra hop, it @@ -293,6 +403,125 @@ return true; } + + // If there is a trivial two-entry PHI node in this basic block, and we can + // eliminate it, do so now. + if (PHINode *PN = dyn_cast(BB->begin())) + if (PN->getNumIncomingValues() == 2) { + // Ok, this is a two entry PHI node. Check to see if this is a simple "if + // statement", which has a very simple dominance structure. Basically, we + // are trying to find the condition that is being branched on, which + // subsequently causes this merge to happen. We really want control + // dependence information for this check, but simplifycfg can't keep it up + // to date, and this catches most of the cases we care about anyway. + // + BasicBlock *IfTrue, *IfFalse; + if (Value *IfCond = GetIfCondition(BB, IfTrue, IfFalse)) { + //std::cerr << "FOUND IF CONDITION! " << *IfCond << " T: " + // << IfTrue->getName() << " F: " << IfFalse->getName() << "\n"; + + // Figure out where to insert instructions as necessary. + BasicBlock::iterator AfterPHIIt = BB->begin(); + while (isa(AfterPHIIt)) ++AfterPHIIt; + + BasicBlock::iterator I = BB->begin(); + while (PHINode *PN = dyn_cast(I)) { + ++I; + + // If we can eliminate this PHI by directly computing it based on the + // condition, do so now. We can't eliminate PHI nodes where the + // incoming values are defined in the conditional parts of the branch, + // so check for this. + // + if (DominatesMergePoint(PN->getIncomingValue(0), BB) && + DominatesMergePoint(PN->getIncomingValue(1), BB)) { + Value *TrueVal = + PN->getIncomingValue(PN->getIncomingBlock(0) == IfFalse); + Value *FalseVal = + PN->getIncomingValue(PN->getIncomingBlock(0) == IfTrue); + + // FIXME: when we have a 'select' statement, we can be completely + // generic and clean here and let the instcombine pass clean up + // after us, by folding the select instructions away when possible. + // + if (TrueVal == FalseVal) { + // Degenerate case... + PN->replaceAllUsesWith(TrueVal); + BB->getInstList().erase(PN); + Changed = true; + } else if (isa(TrueVal) && + isa(FalseVal)) { + if (TrueVal == ConstantBool::True) { + // The PHI node produces the same thing as the condition. + PN->replaceAllUsesWith(IfCond); + } else { + // The PHI node produces the inverse of the condition. Insert a + // "NOT" instruction, which is really a XOR. + Value *InverseCond = + BinaryOperator::createNot(IfCond, IfCond->getName()+".inv", + AfterPHIIt); + PN->replaceAllUsesWith(InverseCond); + } + BB->getInstList().erase(PN); + Changed = true; + } else if (isa(TrueVal) && isa(FalseVal)){ + // If this is a PHI of two constant integers, we insert a cast of + // the boolean to the integer type in question, giving us 0 or 1. + // Then we multiply this by the difference of the two constants, + // giving us 0 if false, and the difference if true. We add this + // result to the base constant, giving us our final value. We + // rely on the instruction combiner to eliminate many special + // cases, like turning multiplies into shifts when possible. + std::string Name = PN->getName(); PN->setName(""); + Value *TheCast = new CastInst(IfCond, TrueVal->getType(), + Name, AfterPHIIt); + Constant *TheDiff = ConstantExpr::get(Instruction::Sub, + cast(TrueVal), + cast(FalseVal)); + Value *V = TheCast; + if (TheDiff != ConstantInt::get(TrueVal->getType(), 1)) + V = BinaryOperator::create(Instruction::Mul, TheCast, + TheDiff, TheCast->getName()+".scale", + AfterPHIIt); + if (!cast(FalseVal)->isNullValue()) + V = BinaryOperator::create(Instruction::Add, V, FalseVal, + V->getName()+".offs", AfterPHIIt); + PN->replaceAllUsesWith(V); + BB->getInstList().erase(PN); + Changed = true; + } else if (isa(FalseVal) && + cast(FalseVal)->isNullValue()) { + // If the false condition is an integral zero value, we can + // compute the PHI by multiplying the condition by the other + // value. + std::string Name = PN->getName(); PN->setName(""); + Value *TheCast = new CastInst(IfCond, TrueVal->getType(), + Name+".c", AfterPHIIt); + Value *V = BinaryOperator::create(Instruction::Mul, TrueVal, + TheCast, Name, AfterPHIIt); + PN->replaceAllUsesWith(V); + BB->getInstList().erase(PN); + Changed = true; + } else if (isa(TrueVal) && + cast(TrueVal)->isNullValue()) { + // If the true condition is an integral zero value, we can compute + // the PHI by multiplying the inverse condition by the other + // value. + std::string Name = PN->getName(); PN->setName(""); + Value *NotCond = BinaryOperator::createNot(IfCond, Name+".inv", + AfterPHIIt); + Value *TheCast = new CastInst(NotCond, TrueVal->getType(), + Name+".inv", AfterPHIIt); + Value *V = BinaryOperator::create(Instruction::Mul, FalseVal, + TheCast, Name, AfterPHIIt); + PN->replaceAllUsesWith(V); + BB->getInstList().erase(PN); + Changed = true; + } + } + } + } + } return Changed; } From lattner at cs.uiuc.edu Tue Feb 10 21:58:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 10 21:58:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Analysis/ValueNumbering.cpp Message-ID: <200402110357.VAA10718@zion.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: ValueNumbering.cpp updated: 1.9 -> 1.10 --- Log message: Simplify implementation, and probably speed things up too. --- Diffs of the changes: (+6 -9) Index: llvm/lib/Analysis/ValueNumbering.cpp diff -u llvm/lib/Analysis/ValueNumbering.cpp:1.9 llvm/lib/Analysis/ValueNumbering.cpp:1.10 --- llvm/lib/Analysis/ValueNumbering.cpp:1.9 Wed Dec 10 23:05:56 2003 +++ llvm/lib/Analysis/ValueNumbering.cpp Tue Feb 10 21:57:16 2004 @@ -15,9 +15,9 @@ #include "llvm/Analysis/ValueNumbering.h" #include "llvm/Support/InstVisitor.h" #include "llvm/BasicBlock.h" +#include "llvm/Instructions.h" #include "llvm/Pass.h" #include "llvm/Type.h" -#include "llvm/iMemory.h" namespace llvm { @@ -104,17 +104,14 @@ for (Value::use_iterator UI = Op->use_begin(), UE = Op->use_end(); UI != UE; ++UI) - if (Instruction *Other = dyn_cast(*UI)) - // Check to see if this new cast is not I, but has the same operand... - if (Other != &I && Other->getOpcode() == I.getOpcode() && - Other->getOperand(0) == Op && // Is the operand the same? + if (CastInst *Other = dyn_cast(*UI)) + // Check that the types are the same, since this code handles casts... + if (Other->getType() == I.getType() && // Is it embedded in the same function? (This could be false if LHS // is a constant or global!) Other->getParent()->getParent() == F && - - // Check that the types are the same, since this code handles casts... - Other->getType() == I.getType()) { - + // Check to see if this new cast is not I. + Other != &I) { // These instructions are identical. Add to list... RetVals.push_back(Other); } From lattner at cs.uiuc.edu Tue Feb 10 22:49:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 10 22:49:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Analysis/ProfileInfo.cpp Message-ID: <200402110448.WAA13441@zion.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: ProfileInfo.cpp updated: 1.1 -> 1.2 --- Log message: Make sure to register the 'no profile' implementation as the default for ProfileInfo --- Diffs of the changes: (+1 -1) Index: llvm/lib/Analysis/ProfileInfo.cpp diff -u llvm/lib/Analysis/ProfileInfo.cpp:1.1 llvm/lib/Analysis/ProfileInfo.cpp:1.2 --- llvm/lib/Analysis/ProfileInfo.cpp:1.1 Tue Feb 10 16:11:21 2004 +++ llvm/lib/Analysis/ProfileInfo.cpp Tue Feb 10 22:47:54 2004 @@ -38,5 +38,5 @@ X("no-profile", "No Profile Information"); // Declare that we implement the AliasAnalysis interface - RegisterAnalysisGroup Y; + RegisterAnalysisGroup Y; } // End of anonymous namespace From alkis at cs.uiuc.edu Tue Feb 10 22:53:01 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Tue Feb 10 22:53:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp Message-ID: <200402110452.WAA14291@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/Sparc: SparcV9CodeEmitter.cpp updated: 1.51 -> 1.52 --- Log message: Remove assert as it is meaningless. MachineOperands can be tagged as MO_VirtualRegister but actually be representing a physical register. --- Diffs of the changes: (+0 -2) Index: llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp diff -u llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp:1.51 llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp:1.52 --- llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp:1.51 Tue Feb 10 14:47:24 2004 +++ llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp Tue Feb 10 22:52:30 2004 @@ -594,8 +594,6 @@ MachineOperand &MO) { int64_t rv = 0; // Return value; defaults to 0 for unhandled cases // or things that get fixed up later by the JIT. - assert(MO.getType() != MachineOperand::MO_VirtualRegister && - "ERROR: virtual register found in machine code."); if (MO.isPCRelativeDisp()) { DEBUG(std::cerr << "PCRelativeDisp: "); Value *V = MO.getVRegValue(); From lattner at cs.uiuc.edu Tue Feb 10 22:54:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 10 22:54:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/BasicBlockPlacement.cpp Message-ID: <200402110453.WAA14320@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: BasicBlockPlacement.cpp added (r1.1) --- Log message: Add an _embarassingly simple_ implementation of basic block layout. This is more of a testcase for profiling information than anything that should reasonably be used, but it's a starting point. When I have more time I will whip this into better shape. --- Diffs of the changes: (+141 -0) Index: llvm/lib/Transforms/Scalar/BasicBlockPlacement.cpp diff -c /dev/null llvm/lib/Transforms/Scalar/BasicBlockPlacement.cpp:1.1 *** /dev/null Tue Feb 10 22:53:30 2004 --- llvm/lib/Transforms/Scalar/BasicBlockPlacement.cpp Tue Feb 10 22:53:20 2004 *************** *** 0 **** --- 1,141 ---- + //===-- BasicBlockPlacement.cpp - Basic Block Code Layout optimization ----===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by the LLVM research group and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // This file implements a very simple profile guided basic block placement + // algorithm. The idea is to put frequently executed blocks together at the + // start of the function, and hopefully increase the number of fall-through + // conditional branches. If there is no profile information for a particular + // function, this pass basically orders blocks in depth-first order + // + // The algorithm implemented here is basically "Algo1" from "Profile Guided Code + // Positioning" by Pettis and Hansen, except that it uses basic block counts + // instead of edge counts. This should be improved in many ways, but is very + // simple for now. + // + // Basically we "place" the entry block, then loop over all successors in a DFO, + // placing the most frequently executed successor until we run out of blocks. I + // told you this was _extremely_ simplistic. :) This is also much slower than it + // could be. When it becomes important, this pass will be rewritten to use a + // better algorithm, and then we can worry about efficiency. + // + //===----------------------------------------------------------------------===// + + #include "llvm/Analysis/ProfileInfo.h" + #include "llvm/Function.h" + #include "llvm/Pass.h" + #include "llvm/Support/CFG.h" + #include "Support/Statistic.h" + #include + using namespace llvm; + + namespace { + Statistic<> NumMoved("block-placement", "Number of basic blocks moved"); + + struct BlockPlacement : public FunctionPass { + virtual bool runOnFunction(Function &F); + + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.setPreservesCFG(); + AU.addRequired(); + //AU.addPreserved(); // Does this work? + } + private: + /// PI - The profile information that is guiding us. + /// + ProfileInfo *PI; + + /// NumMovedBlocks - Every time we move a block, increment this counter. + /// + unsigned NumMovedBlocks; + + /// PlacedBlocks - Every time we place a block, remember it so we don't get + /// into infinite loops. + std::set PlacedBlocks; + + /// InsertPos - This an iterator to the next place we want to insert a + /// block. + Function::iterator InsertPos; + + /// PlaceBlocks - Recursively place the specified blocks and any unplaced + /// successors. + void PlaceBlocks(BasicBlock *BB); + }; + + RegisterOpt X("block-placement", + "Profile Guided Basic Block Placement"); + } + + bool BlockPlacement::runOnFunction(Function &F) { + PI = &getAnalysis(); + + NumMovedBlocks = 0; + InsertPos = F.begin(); + + // Recursively place all blocks. + PlaceBlocks(F.begin()); + + // If there are any unreachable blocks, move them to the end. + + PlacedBlocks.clear(); + NumMoved += NumMovedBlocks; + return NumMovedBlocks != 0; + } + + + /// PlaceBlocks - Recursively place the specified blocks and any unplaced + /// successors. + void BlockPlacement::PlaceBlocks(BasicBlock *BB) { + assert(!PlacedBlocks.count(BB) && "Already placed this block!"); + PlacedBlocks.insert(BB); + + // Place the specified block. + if (&*InsertPos != BB) { + // Use splice to move the block into the right place. This avoids having to + // remove the block from the function then readd it, which causes a bunch of + // symbol table traffic that is entirely pointless. + Function::BasicBlockListType &Blocks = BB->getParent()->getBasicBlockList(); + Blocks.splice(InsertPos, Blocks, BB); + + ++NumMovedBlocks; + } else { + // This block is already in the right place, we don't have to do anything. + ++InsertPos; + } + + // Keep placing successors until we run out of ones to place. Note that this + // loop is very inefficient (N^2) for blocks with many successors, like switch + // statements. FIXME! + while (1) { + // Okay, now place any unplaced successors. + succ_iterator SI = succ_begin(BB), E = succ_end(BB); + + // Scan for the first unplaced successor. + for (; SI != E && PlacedBlocks.count(*SI); ++SI) + /*empty*/; + if (SI == E) return; // No more successors to place. + + unsigned MaxExecutionCount = PI->getExecutionCount(*SI); + BasicBlock *MaxSuccessor = *SI; + + // Scan for more frequently executed successors + for (; SI != E; ++SI) + if (!PlacedBlocks.count(*SI)) { + unsigned Count = PI->getExecutionCount(*SI); + if (Count > MaxExecutionCount || + // Prefer to not disturb the code. + (Count == MaxExecutionCount && *SI == &*InsertPos)) { + MaxExecutionCount = Count; + MaxSuccessor = *SI; + } + } + + // Now that we picked the maximally executed successor, place it. + PlaceBlocks(MaxSuccessor); + } + } From lattner at cs.uiuc.edu Tue Feb 10 23:00:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 10 23:00:02 2004 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/BlockPlacement/ Message-ID: <200402110459.WAA14436@zion.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/BlockPlacement: --- Log message: Directory /home/vadve/shared/PublicCVS/llvm/test/Regression/Transforms/BlockPlacement added to the repository --- Diffs of the changes: (+0 -0) From lattner at cs.uiuc.edu Tue Feb 10 23:01:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 10 23:01:01 2004 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/BlockPlacement/basictest.ll Message-ID: <200402110500.XAA14510@zion.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/BlockPlacement: basictest.ll added (r1.1) --- Log message: Basic functionality testing. --- Diffs of the changes: (+12 -0) Index: llvm/test/Regression/Transforms/BlockPlacement/basictest.ll diff -c /dev/null llvm/test/Regression/Transforms/BlockPlacement/basictest.ll:1.1 *** /dev/null Tue Feb 10 23:00:37 2004 --- llvm/test/Regression/Transforms/BlockPlacement/basictest.ll Tue Feb 10 23:00:27 2004 *************** *** 0 **** --- 1,12 ---- + ; RUN: llvm-as < %s | opt -block-placement -disable-output -print + + int %test() { + + br bool true, label %X, label %Y + A: + ret int 0 + X: + br label %A + Y: + br label %A + } From lattner at cs.uiuc.edu Tue Feb 10 23:22:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 10 23:22:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/BasicBlockPlacement.cpp Message-ID: <200402110521.XAA15987@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: BasicBlockPlacement.cpp updated: 1.1 -> 1.2 --- Log message: Remove obsolete comment. Unreachable blocks will automatically be left at the end of the function. --- Diffs of the changes: (+0 -2) Index: llvm/lib/Transforms/Scalar/BasicBlockPlacement.cpp diff -u llvm/lib/Transforms/Scalar/BasicBlockPlacement.cpp:1.1 llvm/lib/Transforms/Scalar/BasicBlockPlacement.cpp:1.2 --- llvm/lib/Transforms/Scalar/BasicBlockPlacement.cpp:1.1 Tue Feb 10 22:53:20 2004 +++ llvm/lib/Transforms/Scalar/BasicBlockPlacement.cpp Tue Feb 10 23:20:50 2004 @@ -80,8 +80,6 @@ // Recursively place all blocks. PlaceBlocks(F.begin()); - // If there are any unreachable blocks, move them to the end. - PlacedBlocks.clear(); NumMoved += NumMovedBlocks; return NumMovedBlocks != 0; From lattner at cs.uiuc.edu Tue Feb 10 23:55:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 10 23:55:02 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/ProfileInfoLoader.h Message-ID: <200402110554.XAA22558@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis: ProfileInfoLoader.h added (r1.1) --- Log message: Factor this code out of llvm-prof --- Diffs of the changes: (+65 -0) Index: llvm/include/llvm/Analysis/ProfileInfoLoader.h diff -c /dev/null llvm/include/llvm/Analysis/ProfileInfoLoader.h:1.1 *** /dev/null Tue Feb 10 23:54:19 2004 --- llvm/include/llvm/Analysis/ProfileInfoLoader.h Tue Feb 10 23:54:08 2004 *************** *** 0 **** --- 1,65 ---- + //===- ProfileInfoLoader.h - Load & convert profile information -*- C++ -*-===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by the LLVM research group and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // The ProfileInfoLoader class is used to load and represent profiling + // information read in from the dump file. If conversions between formats are + // needed, it can also do this. + // + //===----------------------------------------------------------------------===// + + #ifndef LLVM_ANALYSIS_PROFILEINFOLOADER_H + #define LLVM_ANALYSIS_PROFILEINFOLOADER_H + + #include + #include + #include + + namespace llvm { + + class Module; + class Function; + class BasicBlock; + + class ProfileInfoLoader { + Module &M; + std::vector CommandLines; + std::vector FunctionCounts; + std::vector BlockCounts; + public: + // ProfileInfoLoader ctor - Read the specified profiling data file, exiting + // the program if the file is invalid or broken. + ProfileInfoLoader(const char *ToolName, const std::string &Filename, + Module &M); + + unsigned getNumExecutions() const { return CommandLines.size(); } + const std::string &getExecution(unsigned i) const { return CommandLines[i]; } + + // getFunctionCounts - This method is used by consumers of function counting + // information. If we do not directly have function count information, we + // compute it from other, more refined, types of profile information. + // + void getFunctionCounts(std::vector > &Counts); + + // hasAccurateBlockCounts - Return true if we can synthesize accurate block + // frequency information from whatever we have. + // + bool hasAccurateBlockCounts() const { + return !BlockCounts.empty(); + } + + // getBlockCounts - This method is used by consumers of block counting + // information. If we do not directly have block count information, we + // compute it from other, more refined, types of profile information. + // + void getBlockCounts(std::vector > &Counts); + }; + + } // End llvm namespace + + #endif From lattner at cs.uiuc.edu Tue Feb 10 23:55:08 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 10 23:55:08 2004 Subject: [llvm-commits] CVS: llvm/lib/Analysis/ProfileInfoLoader.cpp Message-ID: <200402110554.XAA22659@zion.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: ProfileInfoLoader.cpp added (r1.1) --- Log message: Factor this code out of llvm-prof --- Diffs of the changes: (+180 -0) Index: llvm/lib/Analysis/ProfileInfoLoader.cpp diff -c /dev/null llvm/lib/Analysis/ProfileInfoLoader.cpp:1.1 *** /dev/null Tue Feb 10 23:54:35 2004 --- llvm/lib/Analysis/ProfileInfoLoader.cpp Tue Feb 10 23:54:25 2004 *************** *** 0 **** --- 1,180 ---- + //===- ProfileInfoLoad.cpp - Load profile information from disk -----------===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by the LLVM research group and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // The ProfileInfoLoader class is used to load and represent profiling + // information read in from the dump file. + // + //===----------------------------------------------------------------------===// + + #include "llvm/Analysis/ProfileInfoLoader.h" + #include "llvm/Module.h" + #include + using namespace llvm; + + enum ProfilingType { + ArgumentInfo = 1, // The command line argument block + FunctionInfo = 2, // Function profiling information + BlockInfo = 3, // Block profiling information + }; + + // ByteSwap - Byteswap 'Var' if 'Really' is true. + // + static inline unsigned ByteSwap(unsigned Var, bool Really) { + if (!Really) return Var; + return ((Var & (255<< 0)) << 24) | + ((Var & (255<< 8)) << 8) | + ((Var & (255<<16)) >> 8) | + ((Var & (255<<24)) >> 24); + } + + static void ReadProfilingBlock(const char *ToolName, FILE *F, + bool ShouldByteSwap, + std::vector &Data) { + // Read the number of entries... + unsigned NumEntries; + if (fread(&NumEntries, sizeof(unsigned), 1, F) != 1) { + std::cerr << ToolName << ": data packet truncated!\n"; + perror(0); + exit(1); + } + NumEntries = ByteSwap(NumEntries, ShouldByteSwap); + + // Read the counts... + std::vector TempSpace(NumEntries); + + // Read in the block of data... + if (fread(&TempSpace[0], sizeof(unsigned)*NumEntries, 1, F) != 1) { + std::cerr << ToolName << ": data packet truncated!\n"; + perror(0); + exit(1); + } + + // Make sure we have enough space... + if (Data.size() < NumEntries) + Data.resize(NumEntries); + + // Accumulate the data we just read into the data. + if (!ShouldByteSwap) { + for (unsigned i = 0; i != NumEntries; ++i) + Data[i] += TempSpace[i]; + } else { + for (unsigned i = 0; i != NumEntries; ++i) + Data[i] += ByteSwap(TempSpace[i], true); + } + } + + // ProfileInfoLoader ctor - Read the specified profiling data file, exiting the + // program if the file is invalid or broken. + // + ProfileInfoLoader::ProfileInfoLoader(const char *ToolName, + const std::string &Filename, + Module &TheModule) : M(TheModule) { + FILE *F = fopen(Filename.c_str(), "r"); + if (F == 0) { + std::cerr << ToolName << ": Error opening '" << Filename << ": "; + perror(0); + exit(1); + } + + // Keep reading packets until we run out of them. + unsigned PacketType; + while (fread(&PacketType, sizeof(unsigned), 1, F) == 1) { + // If the low eight bits of the packet are zero, we must be dealing with an + // endianness mismatch. Byteswap all words read from the profiling + // information. + bool ShouldByteSwap = (char)PacketType == 0; + PacketType = ByteSwap(PacketType, ShouldByteSwap); + + switch (PacketType) { + case ArgumentInfo: { + unsigned ArgLength; + if (fread(&ArgLength, sizeof(unsigned), 1, F) != 1) { + std::cerr << ToolName << ": arguments packet truncated!\n"; + perror(0); + exit(1); + } + ArgLength = ByteSwap(ArgLength, ShouldByteSwap); + + // Read in the arguments... + std::vector Chars(ArgLength+4); + + if (ArgLength) + if (fread(&Chars[0], (ArgLength+3) & ~3, 1, F) != 1) { + std::cerr << ToolName << ": arguments packet truncated!\n"; + perror(0); + exit(1); + } + CommandLines.push_back(std::string(&Chars[0], &Chars[ArgLength])); + break; + } + + case FunctionInfo: + ReadProfilingBlock(ToolName, F, ShouldByteSwap, FunctionCounts); + break; + + case BlockInfo: + ReadProfilingBlock(ToolName, F, ShouldByteSwap, BlockCounts); + break; + + default: + std::cerr << ToolName << ": Unknown packet type #" << PacketType << "!\n"; + exit(1); + } + } + + fclose(F); + } + + + // getFunctionCounts - This method is used by consumers of function counting + // information. If we do not directly have function count information, we + // compute it from other, more refined, types of profile information. + // + void ProfileInfoLoader::getFunctionCounts(std::vector > &Counts) { + if (FunctionCounts.empty()) { + // Synthesize function frequency information from the number of times their + // entry blocks were executed. + std::vector > BlockCounts; + getBlockCounts(BlockCounts); + + for (unsigned i = 0, e = BlockCounts.size(); i != e; ++i) + if (&BlockCounts[i].first->getParent()->front() == BlockCounts[i].first) + Counts.push_back(std::make_pair(BlockCounts[i].first->getParent(), + BlockCounts[i].second)); + return; + } + + unsigned Counter = 0; + for (Module::iterator I = M.begin(), E = M.end(); + I != E && Counter != FunctionCounts.size(); ++I) + if (!I->isExternal()) + Counts.push_back(std::make_pair(I, FunctionCounts[Counter++])); + } + + // getBlockCounts - This method is used by consumers of block counting + // information. If we do not directly have block count information, we + // compute it from other, more refined, types of profile information. + // + void ProfileInfoLoader::getBlockCounts(std::vector > &Counts) { + if (BlockCounts.empty()) { + std::cerr << "Block counts not available, and no synthesis " + << "is implemented yet!\n"; + return; + } + + unsigned Counter = 0; + for (Module::iterator F = M.begin(), E = M.end(); F != E; ++F) + for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) { + Counts.push_back(std::make_pair(BB, BlockCounts[Counter++])); + if (Counter == BlockCounts.size()) + return; + } + } From alkis at cs.uiuc.edu Tue Feb 10 23:56:02 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Tue Feb 10 23:56:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp Message-ID: <200402110555.XAA22885@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/Sparc: SparcV9CodeEmitter.cpp updated: 1.52 -> 1.53 --- Log message: Fix previous broken commit. A MachineOperand may have opType == MO_VirtualRegister but if the register number is one of a physical register is it considered as a physical register. --- Diffs of the changes: (+4 -2) Index: llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp diff -u llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp:1.52 llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp:1.53 --- llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp:1.52 Tue Feb 10 22:52:30 2004 +++ llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp Tue Feb 10 23:55:00 2004 @@ -29,6 +29,7 @@ #include "llvm/CodeGen/MachineFunctionInfo.h" #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/MachineInstr.h" +#include "llvm/Target/MRegisterInfo.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetData.h" #include "Support/Debug.h" @@ -656,9 +657,10 @@ std::cerr << "ERROR: PC relative disp unhandled:" << MO << "\n"; abort(); } - } else if (MO.getType() == MachineOperand::MO_MachineRegister || - MO.getType() == MachineOperand::MO_CCRegister) + } else if (MO.isRegister() || MO.getType() == MachineOperand::MO_CCRegister) { + assert(MRegisterInfo::isPhysicalRegister(MO.getReg()) && + "virtual register in machine code!"); // This is necessary because the Sparc backend doesn't actually lay out // registers in the real fashion -- it skips those that it chooses not to // allocate, i.e. those that are the FP, SP, etc. From lattner at cs.uiuc.edu Tue Feb 10 23:57:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Feb 10 23:57:02 2004 Subject: [llvm-commits] CVS: llvm/tools/llvm-prof/Makefile llvm-prof.cpp ProfileInfo.cpp ProfileInfo.h Message-ID: <200402110556.XAA23110@zion.cs.uiuc.edu> Changes in directory llvm/tools/llvm-prof: Makefile updated: 1.1 -> 1.2 llvm-prof.cpp updated: 1.16 -> 1.17 ProfileInfo.cpp (r1.6) removed ProfileInfo.h (r1.5) removed --- Log message: Factor profile information loading OUT of llvm-prof into libanalysis --- Diffs of the changes: (+3 -4) Index: llvm/tools/llvm-prof/Makefile diff -u llvm/tools/llvm-prof/Makefile:1.1 llvm/tools/llvm-prof/Makefile:1.2 --- llvm/tools/llvm-prof/Makefile:1.1 Tue Oct 28 13:16:35 2003 +++ llvm/tools/llvm-prof/Makefile Tue Feb 10 23:56:07 2004 @@ -9,5 +9,5 @@ LEVEL = ../.. TOOLNAME = llvm-prof -USEDLIBS = bcreader vmcore support.a +USEDLIBS = analysis.a bcreader vmcore support.a include $(LEVEL)/Makefile.common Index: llvm/tools/llvm-prof/llvm-prof.cpp diff -u llvm/tools/llvm-prof/llvm-prof.cpp:1.16 llvm/tools/llvm-prof/llvm-prof.cpp:1.17 --- llvm/tools/llvm-prof/llvm-prof.cpp:1.16 Tue Nov 11 16:41:34 2003 +++ llvm/tools/llvm-prof/llvm-prof.cpp Tue Feb 10 23:56:07 2004 @@ -13,12 +13,11 @@ // //===----------------------------------------------------------------------===// -#include "ProfileInfo.h" #include "llvm/Module.h" #include "llvm/Assembly/AsmAnnotationWriter.h" +#include "llvm/Analysis/ProfileInfoLoader.h" #include "llvm/Bytecode/Reader.h" #include "Support/CommandLine.h" -#include #include #include #include @@ -92,7 +91,7 @@ } // Read the profiling information - ProfileInfo PI(argv[0], ProfileDataFile, *M); + ProfileInfoLoader PI(argv[0], ProfileDataFile, *M); std::map FuncFreqs; std::map BlockFreqs; From alkis at cs.uiuc.edu Wed Feb 11 00:06:06 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Wed Feb 11 00:06:06 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp Message-ID: <200402110605.AAA23226@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/Sparc: SparcV9CodeEmitter.cpp updated: 1.53 -> 1.54 --- Log message: Remove assert as the only integer registers on the sparc are physical. --- Diffs of the changes: (+0 -3) Index: llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp diff -u llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp:1.53 llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp:1.54 --- llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp:1.53 Tue Feb 10 23:55:00 2004 +++ llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp Wed Feb 11 00:04:51 2004 @@ -29,7 +29,6 @@ #include "llvm/CodeGen/MachineFunctionInfo.h" #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/MachineInstr.h" -#include "llvm/Target/MRegisterInfo.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetData.h" #include "Support/Debug.h" @@ -659,8 +658,6 @@ } } else if (MO.isRegister() || MO.getType() == MachineOperand::MO_CCRegister) { - assert(MRegisterInfo::isPhysicalRegister(MO.getReg()) && - "virtual register in machine code!"); // This is necessary because the Sparc backend doesn't actually lay out // registers in the real fashion -- it skips those that it chooses not to // allocate, i.e. those that are the FP, SP, etc. From lattner at cs.uiuc.edu Wed Feb 11 00:11:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Feb 11 00:11:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Analysis/ProfileInfo.cpp Message-ID: <200402110610.AAA23917@zion.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: ProfileInfo.cpp updated: 1.2 -> 1.3 --- Log message: Fix copy-and-pastos --- Diffs of the changes: (+2 -2) Index: llvm/lib/Analysis/ProfileInfo.cpp diff -u llvm/lib/Analysis/ProfileInfo.cpp:1.2 llvm/lib/Analysis/ProfileInfo.cpp:1.3 --- llvm/lib/Analysis/ProfileInfo.cpp:1.2 Tue Feb 10 22:47:54 2004 +++ llvm/lib/Analysis/ProfileInfo.cpp Wed Feb 11 00:10:18 2004 @@ -16,7 +16,7 @@ #include "llvm/Pass.h" using namespace llvm; -// Register the AliasAnalysis interface, providing a nice name to refer to. +// Register the ProfileInfo interface, providing a nice name to refer to. namespace { RegisterAnalysisGroup Z("Profile Information"); } @@ -37,6 +37,6 @@ RegisterOpt X("no-profile", "No Profile Information"); - // Declare that we implement the AliasAnalysis interface + // Declare that we implement the ProfileInfo interface RegisterAnalysisGroup Y; } // End of anonymous namespace From lattner at cs.uiuc.edu Wed Feb 11 00:11:14 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Feb 11 00:11:14 2004 Subject: [llvm-commits] CVS: llvm/lib/Analysis/ProfileInfoLoaderPass.cpp Message-ID: <200402110610.AAA23925@zion.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: ProfileInfoLoaderPass.cpp added (r1.1) --- Log message: Add skeleton profileinfoloader pass. This will be enhanced to actually LOAD a profile tommorow. :) --- Diffs of the changes: (+58 -0) Index: llvm/lib/Analysis/ProfileInfoLoaderPass.cpp diff -c /dev/null llvm/lib/Analysis/ProfileInfoLoaderPass.cpp:1.1 *** /dev/null Wed Feb 11 00:10:45 2004 --- llvm/lib/Analysis/ProfileInfoLoaderPass.cpp Wed Feb 11 00:10:05 2004 *************** *** 0 **** --- 1,58 ---- + //===- ProfileInfoLoaderPass.cpp - LLVM Pass to load profile info ---------===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by the LLVM research group and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // This file implements a concrete implementation of profiling information that + // loads the information from a profile dump file. + // + //===----------------------------------------------------------------------===// + + #include "llvm/Pass.h" + #include "llvm/Analysis/ProfileInfo.h" + #include "llvm/Analysis/ProfileInfoLoader.h" + using namespace llvm; + + namespace { + class LoaderPass : public Pass, public ProfileInfo { + std::string Filename; + public: + LoaderPass(const std::string &filename = "llvmprof.out") + : Filename(filename) {} + + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.setPreservesAll(); + } + + virtual const char *getPassName() const { + return "Profiling information loader"; + } + + /// run - Load the profile information from the specified file. + virtual bool run(Module &M); + + unsigned getExecutionCount(BasicBlock *BB) { return 0; } + }; + + RegisterOpt + X("profile-loader", "Load profile information from llvmprof.out"); + + RegisterAnalysisGroup Y; + } // End of anonymous namespace + + + /// createProfileLoaderPass - This function returns a Pass that loads the + /// profiling information for the module from the specified filename, making it + /// available to the optimizers. + Pass *llvm::createProfileLoaderPass(const std::string &Filename) { + return new LoaderPass(Filename); + } + + bool LoaderPass::run(Module &M) { + + return false; + } From lattner at cs.uiuc.edu Wed Feb 11 00:12:11 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Feb 11 00:12:11 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/ProfileInfo.h Message-ID: <200402110611.AAA24210@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis: ProfileInfo.h updated: 1.1 -> 1.2 --- Log message: Add an important prototype --- Diffs of the changes: (+8 -0) Index: llvm/include/llvm/Analysis/ProfileInfo.h diff -u llvm/include/llvm/Analysis/ProfileInfo.h:1.1 llvm/include/llvm/Analysis/ProfileInfo.h:1.2 --- llvm/include/llvm/Analysis/ProfileInfo.h:1.1 Tue Feb 10 16:11:42 2004 +++ llvm/include/llvm/Analysis/ProfileInfo.h Wed Feb 11 00:11:06 2004 @@ -21,8 +21,16 @@ #ifndef LLVM_ANALYSIS_PROFILEINFO_H #define LLVM_ANALYSIS_PROFILEINFO_H +#include + namespace llvm { class BasicBlock; + class Pass; + + /// createProfileLoaderPass - This function returns a Pass that loads the + /// profiling information for the module from the specified filename, making + /// it available to the optimizers. + Pass *createProfileLoaderPass(const std::string &Filename); struct ProfileInfo { virtual ~ProfileInfo(); // We want to be subclassed From criswell at cs.uiuc.edu Wed Feb 11 10:48:02 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Wed Feb 11 10:48:02 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/External/SPEC/CINT95/126.gcc/ Message-ID: <200402111647.KAA32099@choi.cs.uiuc.edu> Changes in directory llvm/test/Programs/External/SPEC/CINT95/126.gcc: --- Log message: Directory /home/vadve/shared/PublicCVS/llvm/test/Programs/External/SPEC/CINT95/126.gcc added to the repository --- Diffs of the changes: (+0 -0) From criswell at cs.uiuc.edu Wed Feb 11 10:48:08 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Wed Feb 11 10:48:08 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/External/SPEC/CINT95/Makefile Message-ID: <200402111647.KAA32116@choi.cs.uiuc.edu> Changes in directory llvm/test/Programs/External/SPEC/CINT95: Makefile updated: 1.2 -> 1.3 --- Log message: Adding 126.gcc SPEC95 integer benchmark. --- Diffs of the changes: (+1 -0) Index: llvm/test/Programs/External/SPEC/CINT95/Makefile diff -u llvm/test/Programs/External/SPEC/CINT95/Makefile:1.2 llvm/test/Programs/External/SPEC/CINT95/Makefile:1.3 --- llvm/test/Programs/External/SPEC/CINT95/Makefile:1.2 Tue Feb 10 17:02:12 2004 +++ llvm/test/Programs/External/SPEC/CINT95/Makefile Wed Feb 11 10:47:29 2004 @@ -1,6 +1,7 @@ LEVEL = ../../../../.. PARALLEL_DIRS := \ 099.go \ + 126.gcc \ 129.compress \ 130.li \ 132.ijpeg \ From criswell at cs.uiuc.edu Wed Feb 11 10:48:13 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Wed Feb 11 10:48:13 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/External/SPEC/CINT95/126.gcc/Makefile Message-ID: <200402111647.KAA32123@choi.cs.uiuc.edu> Changes in directory llvm/test/Programs/External/SPEC/CINT95/126.gcc: Makefile added (r1.1) --- Log message: Adding 126.gcc SPEC95 integer benchmark. --- Diffs of the changes: (+8 -0) Index: llvm/test/Programs/External/SPEC/CINT95/126.gcc/Makefile diff -c /dev/null llvm/test/Programs/External/SPEC/CINT95/126.gcc/Makefile:1.1 *** /dev/null Wed Feb 11 10:47:40 2004 --- llvm/test/Programs/External/SPEC/CINT95/126.gcc/Makefile Wed Feb 11 10:47:30 2004 *************** *** 0 **** --- 1,8 ---- + LEVEL = ../../../../../.. + CPPFLAGS += -DSPEC -I$(SPEC95_ROOT)/CINT95/126.gcc/src/src.alt + RUN_OPTIONS := -quiet -funroll-loops -fforce-mem -fcse-follow-jumps -fcse-skip-blocks -fexpensive-optimizations -fstrength-reduce -fpeephole -fschedule-insns -finline-functions -fschedule-insns2 -O -o - + STDIN_FILENAME = cccp.i + STDOUT_FILENAME = cccp.s + + include ../../Makefile.spec95 + From alkis at cs.uiuc.edu Wed Feb 11 11:56:01 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Wed Feb 11 11:56:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/LiveVar/BBLiveVar.h BBLiveVar.cpp Message-ID: <200402111755.LAA23506@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/Sparc/LiveVar: BBLiveVar.h updated: 1.25 -> 1.26 BBLiveVar.cpp updated: 1.41 -> 1.42 --- Log message: Increase constness. --- Diffs of the changes: (+6 -4) Index: llvm/lib/Target/Sparc/LiveVar/BBLiveVar.h diff -u llvm/lib/Target/Sparc/LiveVar/BBLiveVar.h:1.25 llvm/lib/Target/Sparc/LiveVar/BBLiveVar.h:1.26 --- llvm/lib/Target/Sparc/LiveVar/BBLiveVar.h:1.25 Tue Nov 11 16:41:32 2003 +++ llvm/lib/Target/Sparc/LiveVar/BBLiveVar.h Wed Feb 11 11:55:09 2004 @@ -35,7 +35,7 @@ class BBLiveVar { const BasicBlock &BB; // pointer to BasicBlock - MachineBasicBlock &MBB; // Pointer to MachineBasicBlock + const MachineBasicBlock &MBB; // Pointer to MachineBasicBlock unsigned POID; // Post-Order ID ValueSet DefSet; // Def set (with no preceding uses) for LV analysis @@ -61,12 +61,12 @@ void calcDefUseSets(); // calculates the Def & Use sets for this BB public: - BBLiveVar(const BasicBlock &BB, MachineBasicBlock &MBB, unsigned POID); + BBLiveVar(const BasicBlock &BB, const MachineBasicBlock &MBB, unsigned POID); inline bool isInSetChanged() const { return InSetChanged; } inline bool isOutSetChanged() const { return OutSetChanged; } - MachineBasicBlock &getMachineBasicBlock() const { return MBB; } + const MachineBasicBlock &getMachineBasicBlock() const { return MBB; } inline unsigned getPOId() const { return POID; } Index: llvm/lib/Target/Sparc/LiveVar/BBLiveVar.cpp diff -u llvm/lib/Target/Sparc/LiveVar/BBLiveVar.cpp:1.41 llvm/lib/Target/Sparc/LiveVar/BBLiveVar.cpp:1.42 --- llvm/lib/Target/Sparc/LiveVar/BBLiveVar.cpp:1.41 Fri Jan 9 12:15:24 2004 +++ llvm/lib/Target/Sparc/LiveVar/BBLiveVar.cpp Wed Feb 11 11:55:09 2004 @@ -21,7 +21,9 @@ namespace llvm { -BBLiveVar::BBLiveVar(const BasicBlock &bb, MachineBasicBlock &mbb, unsigned id) +BBLiveVar::BBLiveVar(const BasicBlock &bb, + const MachineBasicBlock &mbb, + unsigned id) : BB(bb), MBB(mbb), POID(id) { InSetChanged = OutSetChanged = false; From lattner at cs.uiuc.edu Wed Feb 11 12:22:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Feb 11 12:22:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Analysis/ProfileInfoLoaderPass.cpp Message-ID: <200402111821.MAA27497@zion.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: ProfileInfoLoaderPass.cpp updated: 1.1 -> 1.2 --- Log message: Actually load profiling information now! Block layout can use real, live, actual profile info, and works! :) --- Diffs of the changes: (+20 -4) Index: llvm/lib/Analysis/ProfileInfoLoaderPass.cpp diff -u llvm/lib/Analysis/ProfileInfoLoaderPass.cpp:1.1 llvm/lib/Analysis/ProfileInfoLoaderPass.cpp:1.2 --- llvm/lib/Analysis/ProfileInfoLoaderPass.cpp:1.1 Wed Feb 11 00:10:05 2004 +++ llvm/lib/Analysis/ProfileInfoLoaderPass.cpp Wed Feb 11 12:21:05 2004 @@ -15,14 +15,22 @@ #include "llvm/Pass.h" #include "llvm/Analysis/ProfileInfo.h" #include "llvm/Analysis/ProfileInfoLoader.h" +#include "Support/CommandLine.h" using namespace llvm; namespace { + cl::opt + ProfileInfoFilename("profile-info-file", cl::init("llvmprof.out"), + cl::desc("")); + class LoaderPass : public Pass, public ProfileInfo { std::string Filename; + std::map ExecutionCounts; public: - LoaderPass(const std::string &filename = "llvmprof.out") - : Filename(filename) {} + LoaderPass(const std::string &filename = "") + : Filename(filename) { + if (filename.empty()) Filename = ProfileInfoFilename; + } virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesAll(); @@ -35,7 +43,10 @@ /// run - Load the profile information from the specified file. virtual bool run(Module &M); - unsigned getExecutionCount(BasicBlock *BB) { return 0; } + virtual unsigned getExecutionCount(BasicBlock *BB) { + std::map::iterator I = ExecutionCounts.find(BB); + return I != ExecutionCounts.end() ? I->second : 0; + } }; RegisterOpt @@ -53,6 +64,11 @@ } bool LoaderPass::run(Module &M) { - + ProfileInfoLoader PIL("opt", Filename, M); + if (PIL.hasAccurateBlockCounts()) { + std::vector > Counts; + PIL.getBlockCounts(Counts); + ExecutionCounts.insert(Counts.begin(), Counts.end()); + } return false; } From lattner at cs.uiuc.edu Wed Feb 11 12:22:07 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Feb 11 12:22:07 2004 Subject: [llvm-commits] CVS: llvm/lib/Analysis/ProfileInfoLoader.cpp Message-ID: <200402111821.MAA27507@zion.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: ProfileInfoLoader.cpp updated: 1.1 -> 1.2 --- Log message: Fix a typeo --- Diffs of the changes: (+1 -1) Index: llvm/lib/Analysis/ProfileInfoLoader.cpp diff -u llvm/lib/Analysis/ProfileInfoLoader.cpp:1.1 llvm/lib/Analysis/ProfileInfoLoader.cpp:1.2 --- llvm/lib/Analysis/ProfileInfoLoader.cpp:1.1 Tue Feb 10 23:54:25 2004 +++ llvm/lib/Analysis/ProfileInfoLoader.cpp Wed Feb 11 12:20:41 2004 @@ -77,7 +77,7 @@ Module &TheModule) : M(TheModule) { FILE *F = fopen(Filename.c_str(), "r"); if (F == 0) { - std::cerr << ToolName << ": Error opening '" << Filename << ": "; + std::cerr << ToolName << ": Error opening '" << Filename << "': "; perror(0); exit(1); } From gaeke at cs.uiuc.edu Wed Feb 11 12:38:02 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed Feb 11 12:38:02 2004 Subject: [llvm-commits] CVS: llvm/tools/bugpoint/BugDriver.h ExecutionDriver.cpp Message-ID: <200402111837.MAA32213@zion.cs.uiuc.edu> Changes in directory llvm/tools/bugpoint: BugDriver.h updated: 1.22 -> 1.23 ExecutionDriver.cpp updated: 1.34 -> 1.35 --- Log message: Add check-exit-code option, defaulting to true. Add ProgramExitedNonzero argument to executeProgram(), and make it tell its caller whether the program exited nonzero. Move executeProgramWithCBE() out of line, to ExecutionDriver.cpp, and remove its extra arguments which are always defaulted. Make it turn off check-exit-code if the program exits nonzero while generating a reference output. Make diffProgram() assume that any nonzero exit code is a failure, if check-exit-code is turned on. --- Diffs of the changes: (+36 -9) Index: llvm/tools/bugpoint/BugDriver.h diff -u llvm/tools/bugpoint/BugDriver.h:1.22 llvm/tools/bugpoint/BugDriver.h:1.23 --- llvm/tools/bugpoint/BugDriver.h:1.22 Tue Nov 11 16:41:34 2003 +++ llvm/tools/bugpoint/BugDriver.h Wed Feb 11 12:37:32 2004 @@ -178,17 +178,13 @@ std::string executeProgram(std::string RequestedOutputFilename = "", std::string Bytecode = "", const std::string &SharedObjects = "", - AbstractInterpreter *AI = 0); + AbstractInterpreter *AI = 0, + bool *ProgramExitedNonzero = 0); /// executeProgramWithCBE - Used to create reference output with the C /// backend, if reference output is not provided. /// - std::string executeProgramWithCBE(std::string OutputFile = "", - std::string BytecodeFile = "", - const std::string &SharedObj = "") { - return executeProgram(OutputFile, BytecodeFile, SharedObj, - (AbstractInterpreter*)cbe); - } + std::string executeProgramWithCBE(std::string OutputFile = ""); /// diffProgram - This method executes the specified module and diffs the /// output against the file specified by ReferenceOutputFile. If the output Index: llvm/tools/bugpoint/ExecutionDriver.cpp diff -u llvm/tools/bugpoint/ExecutionDriver.cpp:1.34 llvm/tools/bugpoint/ExecutionDriver.cpp:1.35 --- llvm/tools/bugpoint/ExecutionDriver.cpp:1.34 Tue Jan 13 21:38:37 2004 +++ llvm/tools/bugpoint/ExecutionDriver.cpp Wed Feb 11 12:37:32 2004 @@ -49,6 +49,11 @@ 0), cl::init(AutoPick)); + cl::opt + CheckProgramExitCode("check-exit-code", + cl::desc("Assume nonzero exit code is failure (default on)"), + cl::init(true)); + cl::opt InputFile("input", cl::init("/dev/null"), cl::desc("Filename to pipe in as stdin (default: /dev/null)")); @@ -137,7 +142,8 @@ std::string BugDriver::executeProgram(std::string OutputFile, std::string BytecodeFile, const std::string &SharedObj, - AbstractInterpreter *AI) { + AbstractInterpreter *AI, + bool *ProgramExitedNonzero) { if (AI == 0) AI = Interpreter; assert(AI && "Interpreter should have been created already!"); bool CreatedBytecode = false; @@ -167,6 +173,8 @@ int RetVal = AI->ExecuteProgram(BytecodeFile, InputArgv, InputFile, OutputFile, SharedObjs); + if (ProgramExitedNonzero != 0) + *ProgramExitedNonzero = (RetVal != 0); // Remove the temporary bytecode file. if (CreatedBytecode) removeFile(BytecodeFile); @@ -175,6 +183,22 @@ return OutputFile; } +/// executeProgramWithCBE - Used to create reference output with the C +/// backend, if reference output is not provided. +/// +std::string BugDriver::executeProgramWithCBE(std::string OutputFile) { + bool ProgramExitedNonzero; + std::string outFN = executeProgram(OutputFile, "", "", + (AbstractInterpreter*)cbe, + &ProgramExitedNonzero); + if (ProgramExitedNonzero) { + std::cerr + << "Warning: While generating reference output, program exited with\n" + << "non-zero exit code. This will NOT be treated as a failure.\n"; + CheckProgramExitCode = false; + } + return outFN; +} std::string BugDriver::compileSharedObject(const std::string &BytecodeFile) { assert(Interpreter && "Interpreter should have been created already!"); @@ -211,8 +235,15 @@ bool BugDriver::diffProgram(const std::string &BytecodeFile, const std::string &SharedObject, bool RemoveBytecode) { + bool ProgramExitedNonzero; + // Execute the program, generating an output file... - std::string Output = executeProgram("", BytecodeFile, SharedObject); + std::string Output = executeProgram("", BytecodeFile, SharedObject, 0, + &ProgramExitedNonzero); + + // If we're checking the program exit code, assume anything nonzero is bad. + if (CheckProgramExitCode && ProgramExitedNonzero) + return true; std::string Error; bool FilesDifferent = false; From gaeke at cs.uiuc.edu Wed Feb 11 12:41:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed Feb 11 12:41:01 2004 Subject: [llvm-commits] CVS: llvm/docs/CommandGuide/bugpoint.html Message-ID: <200402111840.MAA32402@zion.cs.uiuc.edu> Changes in directory llvm/docs/CommandGuide: bugpoint.html updated: 1.20 -> 1.21 --- Log message: add description of -check-exit-code --- Diffs of the changes: (+4 -0) Index: llvm/docs/CommandGuide/bugpoint.html diff -u llvm/docs/CommandGuide/bugpoint.html:1.20 llvm/docs/CommandGuide/bugpoint.html:1.21 --- llvm/docs/CommandGuide/bugpoint.html:1.20 Mon Jan 26 15:26:54 2004 +++ llvm/docs/CommandGuide/bugpoint.html Wed Feb 11 12:40:04 2004 @@ -175,6 +175,10 @@ part of the -args option, not as options to bugpoint itself.

    +

  • -check-exit-code={true,false}
    + Assume a non-zero exit code or core dump from the test program is + a failure. Defaults to true.

    +

  • -disable-{adce,dce,simplifycfg}
    Do not run the specified passes to clean up and reduce the size of the test program. By default, bugpoint uses these passes internally From gaeke at cs.uiuc.edu Wed Feb 11 12:46:03 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed Feb 11 12:46:03 2004 Subject: [llvm-commits] CVS: llvm/docs/CommandGuide/bugpoint.html Message-ID: <200402111845.MAA00895@zion.cs.uiuc.edu> Changes in directory llvm/docs/CommandGuide: bugpoint.html updated: 1.21 -> 1.22 --- Log message: add advice bullet about -check-exit-code --- Diffs of the changes: (+5 -0) Index: llvm/docs/CommandGuide/bugpoint.html diff -u llvm/docs/CommandGuide/bugpoint.html:1.21 llvm/docs/CommandGuide/bugpoint.html:1.22 --- llvm/docs/CommandGuide/bugpoint.html:1.21 Wed Feb 11 12:40:04 2004 +++ llvm/docs/CommandGuide/bugpoint.html Wed Feb 11 12:44:55 2004 @@ -152,6 +152,11 @@ bugpoint crashes before you see its "All input ok" message, you might try llvm-link -v on the same set of input files. If that also crashes, you may be experiencing a linker bug. + +
  • If your program is supposed to crash, bugpoint will be + confused. One way to deal with this is to cause bugpoint to ignore the exit + code from your program, by giving it the -check-exit-code=false + option. From gaeke at cs.uiuc.edu Wed Feb 11 12:53:03 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed Feb 11 12:53:03 2004 Subject: [llvm-commits] CVS: llvm/utils/check-each-file Message-ID: <200402111852.MAA01075@zion.cs.uiuc.edu> Changes in directory llvm/utils: check-each-file updated: 1.2 -> 1.3 --- Log message: Fix bug in initial check - when recompiling everything with llvm-native-gcc, you have to erase the program and re-run the linker, too, before running the checker. --- Diffs of the changes: (+2 -0) Index: llvm/utils/check-each-file diff -u llvm/utils/check-each-file:1.2 llvm/utils/check-each-file:1.3 --- llvm/utils/check-each-file:1.2 Sun Feb 8 02:01:00 2004 +++ llvm/utils/check-each-file Wed Feb 11 12:52:05 2004 @@ -115,6 +115,8 @@ do rm -f $f && gmake $f CC=llvm-native-gcc done +rm -f $program +$linker if $checker then echo "Sorry, I can't help you, $program is OK when compiled with llvm-native-gcc" From lattner at cs.uiuc.edu Wed Feb 11 13:04:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Feb 11 13:04:02 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/Makefile.programs Message-ID: <200402111903.NAA02706@zion.cs.uiuc.edu> Changes in directory llvm/test/Programs: Makefile.programs updated: 1.115 -> 1.116 --- Log message: The rule to generate profile info doesn't work right for spec --- Diffs of the changes: (+10 -9) Index: llvm/test/Programs/Makefile.programs diff -u llvm/test/Programs/Makefile.programs:1.115 llvm/test/Programs/Makefile.programs:1.116 --- llvm/test/Programs/Makefile.programs:1.115 Tue Feb 10 13:15:08 2004 +++ llvm/test/Programs/Makefile.programs Wed Feb 11 13:03:44 2004 @@ -382,15 +382,6 @@ Output/%.bugpoint-jit: Output/%.llvm.bc $(LBUGPOINT) Output/%.out-nat $(LBUGPOINT) $< -run-jit $(BUGPOINT_OPTIONS) -endif - - -# -# Rules to generate profiling information -# -$(PROGRAMS_TO_TEST:%=Output/%.llvm-prof.bc): \ -Output/%.llvm-prof.bc: Output/%.llvm.bc - $(LOPT) -insert-block-profiling $< -o $@ -f LIBPROFILESO := $(LEVEL)/lib/Debug/libprofile_rt.so @@ -401,6 +392,16 @@ -fake-argv0 'Output/$*.llvm.bc' -load $(LIBPROFILESO) $< -llvmprof-output $@ $(RUN_OPTIONS) @cmp -s Output/$*.out-prof Output/$*.out-nat || \ printf "***\n***\n*** WARNING: Output of profiled program (Output/$*.out-prof)\n*** doesn't match the output of the native program (Output/$*.out-nat)!\n***\n***\n"; + +endif + + +# +# Rules to generate profiling information +# +$(PROGRAMS_TO_TEST:%=Output/%.llvm-prof.bc): \ +Output/%.llvm-prof.bc: Output/%.llvm.bc + $(LOPT) -insert-block-profiling $< -o $@ -f $(PROGRAMS_TO_TEST:%=Output/%.printprof): \ Output/%.printprof: Output/%.llvm.bc Output/%.prof $(LPROF) From lattner at cs.uiuc.edu Wed Feb 11 13:10:04 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Feb 11 13:10:04 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/External/SPEC/Makefile.spec Makefile.spec95 Message-ID: <200402111909.NAA03296@zion.cs.uiuc.edu> Changes in directory llvm/test/Programs/External/SPEC: Makefile.spec updated: 1.22 -> 1.23 Makefile.spec95 updated: 1.1 -> 1.2 --- Log message: Update profiling target to work with spec. These two files should share some make rules... --- Diffs of the changes: (+28 -0) Index: llvm/test/Programs/External/SPEC/Makefile.spec diff -u llvm/test/Programs/External/SPEC/Makefile.spec:1.22 llvm/test/Programs/External/SPEC/Makefile.spec:1.23 --- llvm/test/Programs/External/SPEC/Makefile.spec:1.22 Tue Feb 10 10:25:53 2004 +++ llvm/test/Programs/External/SPEC/Makefile.spec Wed Feb 11 13:09:00 2004 @@ -160,6 +160,20 @@ +LIBPROFILESO = $(LEVEL)/lib/Debug/libprofile_rt.so + +$(PROGRAMS_TO_TEST:%=Output/%.prof): \ +Output/%.prof: Output/%.llvm-prof.bc Output/%.out-nat $(LIBPROFILESO) + @rm -f $@ + $(SPEC_SANDBOX) profile-$(RUN_TYPE) Output/$*.out-prof $(REF_IN_DIR) \ + $(RUNSAFELY) $(STDIN_FILENAME) $(STDOUT_FILENAME) $(LLI) $(JIT_OPTS)\ + -fake-argv0 '../$*.llvm.bc' -load ../../$(LIBPROFILESO) ../../$< -llvmprof-output ../../$@ $(RUN_OPTIONS) + -(cd Output/profile-$(RUN_TYPE); cat $(LOCAL_OUTPUTS)) > Output/$*.out-prof + -cp Output/profile-$(RUN_TYPE)/$(STDOUT_FILENAME).time $@.time + @cmp -s Output/$*.out-prof Output/$*.out-nat || \ + printf "***\n***\n*** WARNING: Output of profiled program (Output/$*.out-prof)\n*** doesn't match the output of the native program (Output/$*.out-nat)!\n***\n***\n"; + + $(PROGRAMS_TO_TEST:%=Output/%.out-tracing): \ Index: llvm/test/Programs/External/SPEC/Makefile.spec95 diff -u llvm/test/Programs/External/SPEC/Makefile.spec95:1.1 llvm/test/Programs/External/SPEC/Makefile.spec95:1.2 --- llvm/test/Programs/External/SPEC/Makefile.spec95:1.1 Tue Feb 10 15:44:09 2004 +++ llvm/test/Programs/External/SPEC/Makefile.spec95 Wed Feb 11 13:09:00 2004 @@ -159,6 +159,20 @@ @echo "===> Leaving Output/bugpoint-$(RUN_TYPE)" +LIBPROFILESO = $(LEVEL)/lib/Debug/libprofile_rt.so + +$(PROGRAMS_TO_TEST:%=Output/%.prof): \ +Output/%.prof: Output/%.llvm-prof.bc Output/%.out-nat $(LIBPROFILESO) + @rm -f $@ + $(SPEC_SANDBOX) profile-$(RUN_TYPE) Output/$*.out-prof $(REF_IN_DIR) \ + $(RUNSAFELY) $(STDIN_FILENAME) $(STDOUT_FILENAME) $(LLI) $(JIT_OPTS)\ + -fake-argv0 '../$*.llvm.bc' -load ../../$(LIBPROFILESO) ../../$< -llvmprof-output ../../$@ $(RUN_OPTIONS) + -(cd Output/profile-$(RUN_TYPE); cat $(LOCAL_OUTPUTS)) > Output/$*.out-prof + -cp Output/profile-$(RUN_TYPE)/$(STDOUT_FILENAME).time $@.time + @cmp -s Output/$*.out-prof Output/$*.out-nat || \ + printf "***\n***\n*** WARNING: Output of profiled program (Output/$*.out-prof)\n*** doesn't match the output of the native program (Output/$*.out-nat)!\n***\n***\n"; + + From lattner at cs.uiuc.edu Wed Feb 11 13:15:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Feb 11 13:15:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Analysis/ProfileInfoLoaderPass.cpp Message-ID: <200402111914.NAA03804@zion.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: ProfileInfoLoaderPass.cpp updated: 1.2 -> 1.3 --- Log message: Cosmetic improvements to this option. --- Diffs of the changes: (+2 -1) Index: llvm/lib/Analysis/ProfileInfoLoaderPass.cpp diff -u llvm/lib/Analysis/ProfileInfoLoaderPass.cpp:1.2 llvm/lib/Analysis/ProfileInfoLoaderPass.cpp:1.3 --- llvm/lib/Analysis/ProfileInfoLoaderPass.cpp:1.2 Wed Feb 11 12:21:05 2004 +++ llvm/lib/Analysis/ProfileInfoLoaderPass.cpp Wed Feb 11 13:14:04 2004 @@ -21,7 +21,8 @@ namespace { cl::opt ProfileInfoFilename("profile-info-file", cl::init("llvmprof.out"), - cl::desc("")); + cl::value_desc("filename"), + cl::desc("Profile file loaded by -profile-loader")); class LoaderPass : public Pass, public ProfileInfo { std::string Filename; From lattner at cs.uiuc.edu Wed Feb 11 13:27:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Feb 11 13:27:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/Printer.cpp Message-ID: <200402111926.NAA04251@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: Printer.cpp updated: 1.78 -> 1.79 --- Log message: s/getOpCode/getOpcode --- Diffs of the changes: (+11 -11) Index: llvm/lib/Target/X86/Printer.cpp diff -u llvm/lib/Target/X86/Printer.cpp:1.78 llvm/lib/Target/X86/Printer.cpp:1.79 --- llvm/lib/Target/X86/Printer.cpp:1.78 Wed Feb 4 16:17:40 2004 +++ llvm/lib/Target/X86/Printer.cpp Wed Feb 11 13:26:28 2004 @@ -594,7 +594,7 @@ unsigned Reg = MI->getOperand(0).getReg(); - O << TII.getName(MI->getOpCode()) << " "; + O << TII.getName(MI->getOpcode()) << " "; printOp(MI->getOperand(0)); if (MI->getNumOperands() == 2 && (!MI->getOperand(1).isRegister() || @@ -627,7 +627,7 @@ (MI->getNumOperands() == 3 && MI->getOperand(2).isImmediate())) && "Bad format for MRMDestReg!"); - O << TII.getName(MI->getOpCode()) << " "; + O << TII.getName(MI->getOpcode()) << " "; printOp(MI->getOperand(0)); O << ", "; printOp(MI->getOperand(1)); @@ -646,7 +646,7 @@ assert(isMem(MI, 0) && MI->getNumOperands() == 4+1 && MI->getOperand(4).isRegister() && "Bad format for MRMDestMem!"); - O << TII.getName(MI->getOpCode()) << " " << sizePtr(Desc) << " "; + O << TII.getName(MI->getOpcode()) << " " << sizePtr(Desc) << " "; printMemReference(MI, 0); O << ", "; printOp(MI->getOperand(4)); @@ -676,7 +676,7 @@ (MI->getOperand(2).isImmediate()))) && "Bad format for MRMSrcReg!"); - O << TII.getName(MI->getOpCode()) << " "; + O << TII.getName(MI->getOpcode()) << " "; printOp(MI->getOperand(0)); O << ", "; printOp(MI->getOperand(1)); @@ -701,7 +701,7 @@ MI->getOperand(0).getReg() != MI->getOperand(1).getReg()) O << "**"; - O << TII.getName(MI->getOpCode()) << " "; + O << TII.getName(MI->getOpcode()) << " "; printOp(MI->getOperand(0)); O << ", " << sizePtr(Desc) << " "; printMemReference(MI, MI->getNumOperands()-4); @@ -732,7 +732,7 @@ MI->getOperand(0).getReg() != MI->getOperand(1).getReg()) O << "**"; - O << TII.getName(MI->getOpCode()) << " "; + O << TII.getName(MI->getOpcode()) << " "; printOp(MI->getOperand(0)); if (MI->getOperand(MI->getNumOperands()-1).isImmediate()) { O << ", "; @@ -767,7 +767,7 @@ // is misassembled by gas in intel_syntax mode as its 32-bit // equivalent "fstp DWORD PTR [...]". Workaround: Output the raw // opcode bytes instead of the instruction. - if (MI->getOpCode() == X86::FSTPr80) { + if (MI->getOpcode() == X86::FSTPr80) { if ((MI->getOperand(0).getReg() == X86::ESP) && (MI->getOperand(1).getImmedValue() == 1)) { if (Op3.isImmediate() && @@ -788,7 +788,7 @@ // misassembled by gas in intel_syntax mode as its 32-bit // equivalent "fld DWORD PTR [...]". Workaround: Output the raw // opcode bytes instead of the instruction. - if (MI->getOpCode() == X86::FLDr80 && + if (MI->getOpcode() == X86::FLDr80 && MI->getOperand(0).getReg() == X86::ESP && MI->getOperand(1).getImmedValue() == 1) { if (Op3.isImmediate() && Op3.getImmedValue() >= -128 && @@ -808,7 +808,7 @@ // 64 bit modes." libopcodes disassembles it as "fild DWORD PTR // [...]", which is wrong. Workaround: Output the raw opcode bytes // instead of the instruction. - if (MI->getOpCode() == X86::FILDr64 && + if (MI->getOpcode() == X86::FILDr64 && MI->getOperand(0).getReg() == X86::ESP && MI->getOperand(1).getImmedValue() == 1) { if (Op3.isImmediate() && Op3.getImmedValue() >= -128 && @@ -829,7 +829,7 @@ // "fistpll DWORD PTR [...]", which is wrong. Workaround: Output // "fistpll DWORD PTR " instead, which is what libopcodes is // expecting to see. - if (MI->getOpCode() == X86::FISTPr64) { + if (MI->getOpcode() == X86::FISTPr64) { O << "fistpll DWORD PTR "; printMemReference(MI, 0); if (MI->getNumOperands() == 5) { @@ -839,7 +839,7 @@ O << "\t# "; } - O << TII.getName(MI->getOpCode()) << " "; + O << TII.getName(MI->getOpcode()) << " "; O << sizePtr(Desc) << " "; printMemReference(MI, 0); if (MI->getNumOperands() == 5) { From gaeke at cs.uiuc.edu Wed Feb 11 13:48:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed Feb 11 13:48:01 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Target/TargetInstrInfo.h Message-ID: <200402111947.NAA05933@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Target: TargetInstrInfo.h updated: 1.53 -> 1.54 --- Log message: Fix typos in comments. --- Diffs of the changes: (+2 -2) Index: llvm/include/llvm/Target/TargetInstrInfo.h diff -u llvm/include/llvm/Target/TargetInstrInfo.h:1.53 llvm/include/llvm/Target/TargetInstrInfo.h:1.54 --- llvm/include/llvm/Target/TargetInstrInfo.h:1.53 Sun Dec 28 11:35:08 2003 +++ llvm/include/llvm/Target/TargetInstrInfo.h Wed Feb 11 13:47:43 2004 @@ -73,7 +73,7 @@ const char * Name; // Assembly language mnemonic for the opcode. int numOperands; // Number of args; -1 if variable #args int resultPos; // Position of the result; -1 if no result - unsigned maxImmedConst; // Largest +ve constant in IMMMED field or 0. + unsigned maxImmedConst; // Largest +ve constant in IMMED field or 0. bool immedIsSignExtended; // Is IMMED field sign-extended? If so, // smallest -ve value is -(maxImmedConst+1). unsigned numDelaySlots; // Number of delay slots after instruction @@ -261,7 +261,7 @@ virtual bool constantFitsInImmedField(MachineOpCode opCode, int64_t intValue) const; - // Return the largest +ve constant that can be held in the IMMMED field + // Return the largest positive constant that can be held in the IMMED field // of this machine instruction. // isSignExtended is set to true if the value is sign-extended before use // (this is true for all immediate fields in SPARC instructions). From lattner at cs.uiuc.edu Wed Feb 11 14:45:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Feb 11 14:45:02 2004 Subject: [llvm-commits] CVS: llvm/include/Support/GraphWriter.h Message-ID: <200402112044.OAA07574@zion.cs.uiuc.edu> Changes in directory llvm/include/Support: GraphWriter.h updated: 1.18 -> 1.19 --- Log message: If a node has more than 64 outgoing edges, make the edges go from the 'truncated' block, instead of dropping them entirely. --- Diffs of the changes: (+3 -1) Index: llvm/include/Support/GraphWriter.h diff -u llvm/include/Support/GraphWriter.h:1.18 llvm/include/Support/GraphWriter.h:1.19 --- llvm/include/Support/GraphWriter.h:1.18 Sun Nov 16 14:21:13 2003 +++ llvm/include/Support/GraphWriter.h Wed Feb 11 14:44:17 2004 @@ -117,7 +117,7 @@ } if (EI != EE) - O << "|truncated..."; + O << "|truncated..."; O << "}"; } O << "}\"];\n"; // Finish printing the "node" line @@ -126,6 +126,8 @@ EI = GTraits::child_begin(Node); for (unsigned i = 0; EI != EE && i != 64; ++EI, ++i) writeEdge(Node, i, EI); + for (; EI != EE; ++EI) + writeEdge(Node, 64, EI); } void writeEdge(NodeType *Node, unsigned edgeidx, child_iterator EI) { From gaeke at cs.uiuc.edu Wed Feb 11 14:48:02 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed Feb 11 14:48:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/LiveVar/BBLiveVar.cpp FunctionLiveVarInfo.cpp Message-ID: <200402112047.OAA08024@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/Sparc/LiveVar: BBLiveVar.cpp updated: 1.42 -> 1.43 FunctionLiveVarInfo.cpp updated: 1.51 -> 1.52 --- Log message: MachineInstr::getOpCode() --> getOpcode() in SPARC back-end. --- Diffs of the changes: (+4 -4) Index: llvm/lib/Target/Sparc/LiveVar/BBLiveVar.cpp diff -u llvm/lib/Target/Sparc/LiveVar/BBLiveVar.cpp:1.42 llvm/lib/Target/Sparc/LiveVar/BBLiveVar.cpp:1.43 --- llvm/lib/Target/Sparc/LiveVar/BBLiveVar.cpp:1.42 Wed Feb 11 11:55:09 2004 +++ llvm/lib/Target/Sparc/LiveVar/BBLiveVar.cpp Wed Feb 11 14:47:34 2004 @@ -78,7 +78,7 @@ // Put Phi operands in UseSet for the incoming edge, not node. // They must not "hide" later defs, and must be handled specially // during set propagation over the CFG. - if (MI->getOpCode() == V9::PHI) { // for a phi node + if (MI->getOpcode() == V9::PHI) { // for a phi node const Value *ArgVal = Op; const BasicBlock *PredBB = cast(*++OpI); // next ptr is BB @@ -97,7 +97,7 @@ // do for implicit operands as well for (unsigned i = 0; i < MI->getNumImplicitRefs(); ++i) { - assert(MI->getOpCode() != V9::PHI && "Phi cannot have implicit operands"); + assert(MI->getOpcode() != V9::PHI && "Phi cannot have implicit operands"); const Value *Op = MI->getImplicitRef(i); if (Op->getType() == Type::LabelTy) // don't process labels Index: llvm/lib/Target/Sparc/LiveVar/FunctionLiveVarInfo.cpp diff -u llvm/lib/Target/Sparc/LiveVar/FunctionLiveVarInfo.cpp:1.51 llvm/lib/Target/Sparc/LiveVar/FunctionLiveVarInfo.cpp:1.52 --- llvm/lib/Target/Sparc/LiveVar/FunctionLiveVarInfo.cpp:1.51 Sun Dec 14 07:24:17 2003 +++ llvm/lib/Target/Sparc/LiveVar/FunctionLiveVarInfo.cpp Wed Feb 11 14:47:34 2004 @@ -295,12 +295,12 @@ // If the current machine instruction has delay slots, mark values // used by this instruction as live before and after each delay slot // instruction (After(MI) is the same as Before(MI+1) except for last MI). - if (unsigned DS = TM.getInstrInfo().getNumDelaySlots(MI->getOpCode())) { + if (unsigned DS = TM.getInstrInfo().getNumDelaySlots(MI->getOpcode())) { MachineBasicBlock::const_iterator fwdMII = MII.base(); // ptr to *next* MI for (unsigned i = 0; i < DS; ++i, ++fwdMII) { assert(fwdMII != MIVec.end() && "Missing instruction in delay slot?"); MachineInstr* DelaySlotMI = *fwdMII; - if (! TM.getInstrInfo().isNop(DelaySlotMI->getOpCode())) { + if (! TM.getInstrInfo().isNop(DelaySlotMI->getOpcode())) { set_union(*MInst2LVSetBI[DelaySlotMI], *NewSet); if (i+1 == DS) set_union(*MInst2LVSetAI[DelaySlotMI], *NewSet); From gaeke at cs.uiuc.edu Wed Feb 11 14:48:08 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed Feb 11 14:48:08 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/RegAlloc/LiveRangeInfo.cpp PhyRegAlloc.cpp Message-ID: <200402112047.OAA08033@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/Sparc/RegAlloc: LiveRangeInfo.cpp updated: 1.48 -> 1.49 PhyRegAlloc.cpp updated: 1.132 -> 1.133 --- Log message: MachineInstr::getOpCode() --> getOpcode() in SPARC back-end. --- Diffs of the changes: (+18 -18) Index: llvm/lib/Target/Sparc/RegAlloc/LiveRangeInfo.cpp diff -u llvm/lib/Target/Sparc/RegAlloc/LiveRangeInfo.cpp:1.48 llvm/lib/Target/Sparc/RegAlloc/LiveRangeInfo.cpp:1.49 --- llvm/lib/Target/Sparc/RegAlloc/LiveRangeInfo.cpp:1.48 Sun Dec 14 07:24:15 2003 +++ llvm/lib/Target/Sparc/RegAlloc/LiveRangeInfo.cpp Wed Feb 11 14:47:34 2004 @@ -176,8 +176,8 @@ // If the machine instruction is a call/return instruction, add it to // CallRetInstrList for processing its args, ret value, and ret addr. // - if(TM.getInstrInfo().isReturn(MInst->getOpCode()) || - TM.getInstrInfo().isCall(MInst->getOpCode())) + if(TM.getInstrInfo().isReturn(MInst->getOpcode()) || + TM.getInstrInfo().isCall(MInst->getOpcode())) CallRetInstrList.push_back(MInst); // iterate over explicit MI operands and create a new LR @@ -243,7 +243,7 @@ std::vector::iterator It = CallRetInstrList.begin(); for( ; It != CallRetInstrList.end(); ++It) { MachineInstr *MInst = *It; - MachineOpCode OpCode = MInst->getOpCode(); + MachineOpCode OpCode = MInst->getOpcode(); if ((TM.getInstrInfo()).isReturn(OpCode)) MRI.suggestReg4RetValue(MInst, *this); Index: llvm/lib/Target/Sparc/RegAlloc/PhyRegAlloc.cpp diff -u llvm/lib/Target/Sparc/RegAlloc/PhyRegAlloc.cpp:1.132 llvm/lib/Target/Sparc/RegAlloc/PhyRegAlloc.cpp:1.133 --- llvm/lib/Target/Sparc/RegAlloc/PhyRegAlloc.cpp:1.132 Wed Jan 28 13:05:43 2004 +++ llvm/lib/Target/Sparc/RegAlloc/PhyRegAlloc.cpp Wed Feb 11 14:47:34 2004 @@ -237,7 +237,7 @@ // get the LV set after the instruction const ValueSet &LVSetAI = LVI->getLiveVarSetAfterMInst(MInst, BB); - bool isCallInst = TM.getInstrInfo().isCall(MInst->getOpCode()); + bool isCallInst = TM.getInstrInfo().isCall(MInst->getOpcode()); if (isCallInst) { // set the isCallInterference flag of each live range which extends @@ -262,7 +262,7 @@ // another. This must be done because pseudo-instructions may be // expanded to multiple instructions by the assembler, so all the // operands must get distinct registers. - if (TM.getInstrInfo().isPseudoInstr(MInst->getOpCode())) + if (TM.getInstrInfo().isPseudoInstr(MInst->getOpcode())) addInterf4PseudoInstr(MInst); // Also add interference for any implicit definitions in a machine @@ -443,7 +443,7 @@ void PhyRegAlloc::updateInstruction(MachineBasicBlock::iterator& MII, MachineBasicBlock &MBB) { MachineInstr* MInst = *MII; - unsigned Opcode = MInst->getOpCode(); + unsigned Opcode = MInst->getOpcode(); // Reset tmp stack positions so they can be reused for each machine instr. MF->getInfo()->popAllTempValues(); @@ -506,7 +506,7 @@ // their assigned registers or insert spill code, as appropriate. // Also, fix operands of call/return instructions. for (MachineBasicBlock::iterator MII = MBB.begin(); MII != MBB.end(); ++MII) - if (! TM.getInstrInfo().isDummyPhiInstr((*MII)->getOpCode())) + if (! TM.getInstrInfo().isDummyPhiInstr((*MII)->getOpcode())) updateInstruction(MII, MBB); // Now, move code out of delay slots of branches and returns if needed. @@ -526,14 +526,14 @@ for (MachineBasicBlock::iterator MII = MBB.begin(); MII != MBB.end(); ++MII) if (unsigned delaySlots = - TM.getInstrInfo().getNumDelaySlots((*MII)->getOpCode())) { + TM.getInstrInfo().getNumDelaySlots((*MII)->getOpcode())) { MachineInstr *MInst = *MII, *DelaySlotMI = *(MII+1); // Check the 2 conditions above: // (1) Does a branch need instructions added after it? // (2) O/w does delay slot instr. need instrns before or after? - bool isBranch = (TM.getInstrInfo().isBranch(MInst->getOpCode()) || - TM.getInstrInfo().isReturn(MInst->getOpCode())); + bool isBranch = (TM.getInstrInfo().isBranch(MInst->getOpcode()) || + TM.getInstrInfo().isReturn(MInst->getOpcode())); bool cond1 = (isBranch && AddedInstrMap.count(MInst) && AddedInstrMap[MInst].InstrnsAfter.size() > 0); @@ -575,7 +575,7 @@ MachineInstr *MInst = *MII; // do not process Phis - if (TM.getInstrInfo().isDummyPhiInstr(MInst->getOpCode())) + if (TM.getInstrInfo().isDummyPhiInstr(MInst->getOpcode())) continue; // if there are any added instructions... @@ -583,11 +583,11 @@ AddedInstrns &CallAI = AddedInstrMap[MInst]; #ifndef NDEBUG - bool isBranch = (TM.getInstrInfo().isBranch(MInst->getOpCode()) || - TM.getInstrInfo().isReturn(MInst->getOpCode())); + bool isBranch = (TM.getInstrInfo().isBranch(MInst->getOpcode()) || + TM.getInstrInfo().isReturn(MInst->getOpcode())); assert((!isBranch || AddedInstrMap[MInst].InstrnsAfter.size() <= - TM.getInstrInfo().getNumDelaySlots(MInst->getOpCode())) && + TM.getInstrInfo().getNumDelaySlots(MInst->getOpcode())) && "Cannot put more than #delaySlots instrns after " "branch or return! Need to handle temps differently."); #endif @@ -638,9 +638,9 @@ MachineInstr *MInst = *MII; const BasicBlock *BB = MBB.getBasicBlock(); - assert((! TM.getInstrInfo().isCall(MInst->getOpCode()) || OpNum == 0) && + assert((! TM.getInstrInfo().isCall(MInst->getOpcode()) || OpNum == 0) && "Outgoing arg of a call must be handled elsewhere (func arg ok)"); - assert(! TM.getInstrInfo().isReturn(MInst->getOpCode()) && + assert(! TM.getInstrInfo().isReturn(MInst->getOpcode()) && "Return value of a ret must be handled elsewhere"); MachineOperand& Op = MInst->getOperand(OpNum); @@ -659,7 +659,7 @@ // trample those! Verify that the set is included in the LV set before MInst. if (MII != MBB.begin()) { MachineInstr *PredMI = *(MII-1); - if (unsigned DS = TM.getInstrInfo().getNumDelaySlots(PredMI->getOpCode())) + if (unsigned DS = TM.getInstrInfo().getNumDelaySlots(PredMI->getOpcode())) assert(set_difference(LVI->getLiveVarSetBeforeMInst(PredMI), LVSetBef) .empty() && "Live-var set before branch should be included in " "live-var set of each delay slot instruction!"); @@ -745,7 +745,7 @@ std::vector &instrnsAfter, MachineInstr *CallMI, const BasicBlock *BB) { - assert(TM.getInstrInfo().isCall(CallMI->getOpCode())); + assert(TM.getInstrInfo().isCall(CallMI->getOpcode())); // hash set to record which registers were saved/restored hash_set PushedRegSet; From gaeke at cs.uiuc.edu Wed Feb 11 14:48:14 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed Feb 11 14:48:14 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/InstrSelection/InstrSelectionSupport.cpp Message-ID: <200402112047.OAA08015@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/Sparc/InstrSelection: InstrSelectionSupport.cpp updated: 1.61 -> 1.62 --- Log message: MachineInstr::getOpCode() --> getOpcode() in SPARC back-end. --- Diffs of the changes: (+1 -1) Index: llvm/lib/Target/Sparc/InstrSelection/InstrSelectionSupport.cpp diff -u llvm/lib/Target/Sparc/InstrSelection/InstrSelectionSupport.cpp:1.61 llvm/lib/Target/Sparc/InstrSelection/InstrSelectionSupport.cpp:1.62 --- llvm/lib/Target/Sparc/InstrSelection/InstrSelectionSupport.cpp:1.61 Fri Jan 9 00:22:34 2004 +++ llvm/lib/Target/Sparc/InstrSelection/InstrSelectionSupport.cpp Wed Feb 11 14:47:33 2004 @@ -129,7 +129,7 @@ { std::vector MVec; - MachineOpCode opCode = minstr->getOpCode(); + MachineOpCode opCode = minstr->getOpcode(); const TargetInstrInfo& instrInfo = target.getInstrInfo(); int resultPos = instrInfo.getResultPos(opCode); int immedPos = instrInfo.getImmedConstantPos(opCode); From gaeke at cs.uiuc.edu Wed Feb 11 14:48:19 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed Feb 11 14:48:19 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/EmitAssembly.cpp PeepholeOpts.cpp PrologEpilogCodeInserter.cpp SparcInstrSelection.cpp SparcRegInfo.cpp Message-ID: <200402112047.OAA08008@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/Sparc: EmitAssembly.cpp updated: 1.103 -> 1.104 PeepholeOpts.cpp updated: 1.17 -> 1.18 PrologEpilogCodeInserter.cpp updated: 1.32 -> 1.33 SparcInstrSelection.cpp updated: 1.130 -> 1.131 SparcRegInfo.cpp updated: 1.116 -> 1.117 --- Log message: MachineInstr::getOpCode() --> getOpcode() in SPARC back-end. --- Diffs of the changes: (+18 -18) Index: llvm/lib/Target/Sparc/EmitAssembly.cpp diff -u llvm/lib/Target/Sparc/EmitAssembly.cpp:1.103 llvm/lib/Target/Sparc/EmitAssembly.cpp:1.104 --- llvm/lib/Target/Sparc/EmitAssembly.cpp:1.103 Mon Feb 9 23:16:44 2004 +++ llvm/lib/Target/Sparc/EmitAssembly.cpp Wed Feb 11 14:47:31 2004 @@ -566,7 +566,7 @@ inline bool SparcAsmPrinter::OpIsBranchTargetLabel(const MachineInstr *MI, unsigned int opNum) { - switch (MI->getOpCode()) { + switch (MI->getOpcode()) { case V9::JMPLCALLr: case V9::JMPLCALLi: case V9::JMPLRETr: @@ -580,9 +580,9 @@ inline bool SparcAsmPrinter::OpIsMemoryAddressBase(const MachineInstr *MI, unsigned int opNum) { - if (Target.getInstrInfo().isLoad(MI->getOpCode())) + if (Target.getInstrInfo().isLoad(MI->getOpcode())) return (opNum == 0); - else if (Target.getInstrInfo().isStore(MI->getOpCode())) + else if (Target.getInstrInfo().isStore(MI->getOpcode())) return (opNum == 1); else return false; @@ -601,15 +601,15 @@ const MachineOperand& mop = MI->getOperand(opNum); if (OpIsBranchTargetLabel(MI, opNum)) { - PrintOp1PlusOp2(mop, MI->getOperand(opNum+1), MI->getOpCode()); + PrintOp1PlusOp2(mop, MI->getOperand(opNum+1), MI->getOpcode()); return 2; } else if (OpIsMemoryAddressBase(MI, opNum)) { toAsm << "["; - PrintOp1PlusOp2(mop, MI->getOperand(opNum+1), MI->getOpCode()); + PrintOp1PlusOp2(mop, MI->getOperand(opNum+1), MI->getOpcode()); toAsm << "]"; return 2; } else { - printOneOperand(mop, MI->getOpCode()); + printOneOperand(mop, MI->getOpcode()); return 1; } } @@ -691,7 +691,7 @@ } void SparcAsmPrinter::emitMachineInst(const MachineInstr *MI) { - unsigned Opcode = MI->getOpCode(); + unsigned Opcode = MI->getOpcode(); if (Target.getInstrInfo().isDummyPhiInstr(Opcode)) return; // IGNORE PHI NODES Index: llvm/lib/Target/Sparc/PeepholeOpts.cpp diff -u llvm/lib/Target/Sparc/PeepholeOpts.cpp:1.17 llvm/lib/Target/Sparc/PeepholeOpts.cpp:1.18 --- llvm/lib/Target/Sparc/PeepholeOpts.cpp:1.17 Wed Dec 17 16:08:20 2003 +++ llvm/lib/Target/Sparc/PeepholeOpts.cpp Wed Feb 11 14:47:32 2004 @@ -32,7 +32,7 @@ if (BBI != mvec.begin()) { const TargetInstrInfo& mii = target.getInstrInfo(); MachineInstr* predMI = *(BBI-1); - if (unsigned ndelay = mii.getNumDelaySlots(predMI->getOpCode())) { + if (unsigned ndelay = mii.getNumDelaySlots(predMI->getOpcode())) { // This instruction is in a delay slot of its predecessor, so // replace it with a nop. By replacing in place, we save having // to update the I-I maps. @@ -61,12 +61,12 @@ //---------------------------------------------------------------------------- static bool IsUselessCopy(const TargetMachine &target, const MachineInstr* MI) { - if (MI->getOpCode() == V9::FMOVS || MI->getOpCode() == V9::FMOVD) { + 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 || - MI->getOpCode() == V9::ADDi || MI->getOpCode() == V9::ORi) { + } else if (MI->getOpcode() == V9::ADDr || MI->getOpcode() == V9::ORr || + MI->getOpcode() == V9::ADDi || MI->getOpcode() == V9::ORi) { unsigned srcWithDestReg; for (srcWithDestReg = 0; srcWithDestReg < 2; ++srcWithDestReg) Index: llvm/lib/Target/Sparc/PrologEpilogCodeInserter.cpp diff -u llvm/lib/Target/Sparc/PrologEpilogCodeInserter.cpp:1.32 llvm/lib/Target/Sparc/PrologEpilogCodeInserter.cpp:1.33 --- llvm/lib/Target/Sparc/PrologEpilogCodeInserter.cpp:1.32 Wed Nov 12 18:18:04 2003 +++ llvm/lib/Target/Sparc/PrologEpilogCodeInserter.cpp Wed Feb 11 14:47:32 2004 @@ -155,7 +155,7 @@ // Remove the NOPs in the delay slots of the return instruction unsigned numNOPs = 0; - while (termMvec.back()->getOpCode() == V9::NOP) + while (termMvec.back()->getOpcode() == V9::NOP) { assert( termMvec.back() == MBB.back()); delete MBB.pop_back(); @@ -166,7 +166,7 @@ // Check that we found the right number of NOPs and have the right // number of instructions to replace them. - unsigned ndelays = MII.getNumDelaySlots(termMvec.back()->getOpCode()); + unsigned ndelays = MII.getNumDelaySlots(termMvec.back()->getOpcode()); assert(numNOPs == ndelays && "Missing NOPs in delay slots?"); assert(ndelays == 1 && "Cannot use epilog code for delay slots?"); Index: llvm/lib/Target/Sparc/SparcInstrSelection.cpp diff -u llvm/lib/Target/Sparc/SparcInstrSelection.cpp:1.130 llvm/lib/Target/Sparc/SparcInstrSelection.cpp:1.131 --- llvm/lib/Target/Sparc/SparcInstrSelection.cpp:1.130 Mon Jan 12 12:08:18 2004 +++ llvm/lib/Target/Sparc/SparcInstrSelection.cpp Wed Feb 11 14:47:32 2004 @@ -874,7 +874,7 @@ if (firstNewInstr < mvec.size()) { cost = 0; for (unsigned i=firstNewInstr; i < mvec.size(); ++i) - cost += target.getInstrInfo().minLatency(mvec[i]->getOpCode()); + cost += target.getInstrInfo().minLatency(mvec[i]->getOpcode()); } return cost; @@ -1918,7 +1918,7 @@ const MachineCodeForInstruction& mcfi = MachineCodeForInstruction::get( cast(subtreeRoot->parent())->getInstruction()); - if (mcfi.size() == 0 || mcfi.front()->getOpCode() == V9::FSMULD) + if (mcfi.size() == 0 || mcfi.front()->getOpcode() == V9::FSMULD) forwardOperandNum = 0; // forward first operand to user } Index: llvm/lib/Target/Sparc/SparcRegInfo.cpp diff -u llvm/lib/Target/Sparc/SparcRegInfo.cpp:1.116 llvm/lib/Target/Sparc/SparcRegInfo.cpp:1.117 --- llvm/lib/Target/Sparc/SparcRegInfo.cpp:1.116 Fri Jan 9 10:17:09 2004 +++ llvm/lib/Target/Sparc/SparcRegInfo.cpp Wed Feb 11 14:47:33 2004 @@ -312,7 +312,7 @@ void SparcRegInfo::suggestReg4RetAddr(MachineInstr *RetMI, LiveRangeInfo& LRI) const { - assert(target.getInstrInfo().isReturn(RetMI->getOpCode())); + assert(target.getInstrInfo().isReturn(RetMI->getOpcode())); // return address is always mapped to i7 so set it immediately RetMI->SetRegForOperand(0, getUnifiedRegNum(IntRegClassID, @@ -570,7 +570,7 @@ //--------------------------------------------------------------------------- void SparcRegInfo::suggestRegs4CallArgs(MachineInstr *CallMI, LiveRangeInfo& LRI) const { - assert ( (target.getInstrInfo()).isCall(CallMI->getOpCode()) ); + assert ( (target.getInstrInfo()).isCall(CallMI->getOpcode()) ); CallArgsDescriptor* argDesc = CallArgsDescriptor::get(CallMI); @@ -639,7 +639,7 @@ void SparcRegInfo::suggestReg4RetValue(MachineInstr *RetMI, LiveRangeInfo& LRI) const { - assert( (target.getInstrInfo()).isReturn( RetMI->getOpCode() ) ); + assert( (target.getInstrInfo()).isReturn( RetMI->getOpcode() ) ); suggestReg4RetAddr(RetMI, LRI); From brukman at cs.uiuc.edu Wed Feb 11 18:02:01 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Wed Feb 11 18:02:01 2004 Subject: [llvm-commits] CVS: llvm/utils/TableGen/FileLexer.l Message-ID: <200402120001.SAA20788@zion.cs.uiuc.edu> Changes in directory llvm/utils/TableGen: FileLexer.l updated: 1.17 -> 1.18 --- Log message: * Convert C comments to C++ style (why are some one way, some another?!) * Delete extra space, extra blank comment lines * Convert function comments to doxygen --- Diffs of the changes: (+14 -30) Index: llvm/utils/TableGen/FileLexer.l diff -u llvm/utils/TableGen/FileLexer.l:1.17 llvm/utils/TableGen/FileLexer.l:1.18 --- llvm/utils/TableGen/FileLexer.l:1.17 Tue Nov 11 16:41:34 2003 +++ llvm/utils/TableGen/FileLexer.l Wed Feb 11 18:00:46 2004 @@ -1,4 +1,4 @@ -/*===-- FileLexer.l - Scanner for TableGen Files ----------------*- C++ -*-===// +//===-- FileLexer.l - Scanner for TableGen Files ----------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -10,7 +10,7 @@ // This file defines a simple flex scanner for TableGen files. This is pretty // straight-forward, except for the magic to handle file inclusion. // -//===----------------------------------------------------------------------===*/ +//===----------------------------------------------------------------------===// %option prefix="File" %option yylineno @@ -38,7 +38,8 @@ // Global variable recording the location of the include directory std::string IncludeDirectory; -// ParseInt - This has to handle the special case of binary numbers 0b0101 +/// ParseInt - This has to handle the special case of binary numbers 0b0101 +/// static int ParseInt(const char *Str) { if (Str[0] == '0' && Str[1] == 'b') return strtol(Str+2, 0, 2); @@ -60,7 +61,6 @@ static std::vector IncludeStack; - std::ostream &err() { if (IncludeStack.empty()) return std::cerr << "At end of input: "; @@ -72,19 +72,8 @@ << Filelineno << ": "; } - - -// -// Function: ParseFile() -// -// Description: -// This function begins the parsing of the specified tablegen file. -// -// Inputs: -// Filename - A string containing the name of the file to parse. -// IncludeDir - A string containing the directory from which include -// files can be found. -// +/// ParseFile - this function begins the parsing of the specified tablegen file. +/// void ParseFile(const std::string &Filename, const std::string & IncludeDir) { FILE *F = stdin; if (Filename != "-") { @@ -99,10 +88,8 @@ IncludeStack.push_back(IncludeRec("", stdin)); } - // // Record the location of the include directory so that the lexer can find // it later. - // IncludeDirectory = IncludeDir; Filein = F; @@ -111,8 +98,9 @@ Filein = stdin; } -// HandleInclude - This function is called when an include directive is -// encountered in the input stream... +/// HandleInclude - This function is called when an include directive is +/// encountered in the input stream... +/// static void HandleInclude(const char *Buffer) { unsigned Length = yyleng; assert(Buffer[Length-1] == '"'); @@ -133,14 +121,11 @@ // Open the new input file... yyin = fopen(Filename.c_str(), "r"); if (yyin == 0) { - // // If we couldn't find the file in the current directory, look for it in // the include directories. // - // NOTE: - // Right now, there is only one directory. We need to eventually add - // support for more. - // + // NOTE: Right now, there is only one directory. We need to eventually add + // support for more. Filename = IncludeDirectory + "/" + Filename; yyin = fopen(Filename.c_str(), "r"); if (yyin == 0) { @@ -157,10 +142,9 @@ yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE)); } - -// yywrap - This is called when the lexer runs out of input in one of the files. -// Switch back to an includer if an includee has run out of input. -// +/// yywrap - This is called when the lexer runs out of input in one of the +/// files. Switch back to an includer if an includee has run out of input. +/// extern "C" int yywrap() { if (IncludeStack.back().File != stdin) From brukman at cs.uiuc.edu Wed Feb 11 18:04:02 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Wed Feb 11 18:04:02 2004 Subject: [llvm-commits] CVS: llvm/utils/TableGen/FileLexer.l Message-ID: <200402120003.SAA25242@zion.cs.uiuc.edu> Changes in directory llvm/utils/TableGen: FileLexer.l updated: 1.18 -> 1.19 --- Log message: Ooops, top-level C++-comments aren't recognized by flex. --- Diffs of the changes: (+2 -2) Index: llvm/utils/TableGen/FileLexer.l diff -u llvm/utils/TableGen/FileLexer.l:1.18 llvm/utils/TableGen/FileLexer.l:1.19 --- llvm/utils/TableGen/FileLexer.l:1.18 Wed Feb 11 18:00:46 2004 +++ llvm/utils/TableGen/FileLexer.l Wed Feb 11 18:03:08 2004 @@ -1,4 +1,4 @@ -//===-- FileLexer.l - Scanner for TableGen Files ----------------*- C++ -*-===// +/*===-- FileLexer.l - Scanner for TableGen Files ----------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -10,7 +10,7 @@ // This file defines a simple flex scanner for TableGen files. This is pretty // straight-forward, except for the magic to handle file inclusion. // -//===----------------------------------------------------------------------===// +//===----------------------------------------------------------------------===*/ %option prefix="File" %option yylineno From gaeke at cs.uiuc.edu Wed Feb 11 19:35:02 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed Feb 11 19:35:02 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/MachineInstr.h Message-ID: <200402120134.TAA10686@kain.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: MachineInstr.h updated: 1.126 -> 1.127 --- Log message: Remove getOpCode(). Help doxygenify some comments. --- Diffs of the changes: (+5 -11) Index: llvm/include/llvm/CodeGen/MachineInstr.h diff -u llvm/include/llvm/CodeGen/MachineInstr.h:1.126 llvm/include/llvm/CodeGen/MachineInstr.h:1.127 --- llvm/include/llvm/CodeGen/MachineInstr.h:1.126 Tue Feb 10 15:43:11 2004 +++ llvm/include/llvm/CodeGen/MachineInstr.h Wed Feb 11 19:34:03 2004 @@ -375,19 +375,13 @@ /// MachineInstr(MachineBasicBlock *MBB, int Opcode, unsigned numOps); - - // The opcode. - // + /// Accessors for opcode and associated flags. + /// const int getOpcode() const { return opCode; } - const int getOpCode() const { return opCode; } - - // Opcode flags. - // - unsigned getOpCodeFlags() const { return opCodeFlags; } + unsigned getOpCodeFlags() const { return opCodeFlags; } - // - // Access to explicit operands of the instruction - // + /// Access to explicit operands of the instruction. + /// unsigned getNumOperands() const { return operands.size() - numImplicitRefs; } const MachineOperand& getOperand(unsigned i) const { From gaeke at cs.uiuc.edu Wed Feb 11 19:35:08 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed Feb 11 19:35:08 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/InstrSched/InstrScheduling.cpp SchedGraph.cpp SchedGraph.h SchedPriorities.cpp Message-ID: <200402120134.TAA10703@kain.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/InstrSched: InstrScheduling.cpp updated: 1.63 -> 1.64 SchedGraph.cpp updated: 1.55 -> 1.56 SchedGraph.h updated: 1.38 -> 1.39 SchedPriorities.cpp updated: 1.29 -> 1.30 --- Log message: getOpCode() --> getOpcode(). --- Diffs of the changes: (+53 -53) Index: llvm/lib/CodeGen/InstrSched/InstrScheduling.cpp diff -u llvm/lib/CodeGen/InstrSched/InstrScheduling.cpp:1.63 llvm/lib/CodeGen/InstrSched/InstrScheduling.cpp:1.64 --- llvm/lib/CodeGen/InstrSched/InstrScheduling.cpp:1.63 Mon Feb 9 12:42:46 2004 +++ llvm/lib/CodeGen/InstrSched/InstrScheduling.cpp Wed Feb 11 19:34:05 2004 @@ -424,7 +424,7 @@ // Append the instruction to the vector of choices for current cycle. // Increment numInClass[c] for the sched class to which the instr belongs. choiceVec.push_back(node); - const InstrSchedClass& sc = schedInfo.getSchedClass(node->getOpCode()); + const InstrSchedClass& sc = schedInfo.getSchedClass(node->getOpcode()); assert(sc < numInClass.size()); numInClass[sc]++; } @@ -478,7 +478,7 @@ choicesForSlot[s].erase(node); // and decrement the instr count for the sched class to which it belongs - const InstrSchedClass& sc = schedInfo.getSchedClass(node->getOpCode()); + const InstrSchedClass& sc = schedInfo.getSchedClass(node->getOpcode()); assert(sc < numInClass.size()); numInClass[sc]--; } @@ -498,7 +498,7 @@ if (!createIfMissing) return 0; DelaySlotInfo *dinfo = - new DelaySlotInfo(bn, getInstrInfo().getNumDelaySlots(bn->getOpCode())); + new DelaySlotInfo(bn, getInstrInfo().getNumDelaySlots(bn->getOpcode())); return delaySlotInfoForBranches[bn] = dinfo; } @@ -537,19 +537,19 @@ SchedulingManager::updateEarliestStartTimes(const SchedGraphNode* node, cycles_t schedTime) { - if (schedInfo.numBubblesAfter(node->getOpCode()) > 0) + if (schedInfo.numBubblesAfter(node->getOpcode()) > 0) { // Update next earliest time before which *nothing* can issue. nextEarliestIssueTime = std::max(nextEarliestIssueTime, - curTime + 1 + schedInfo.numBubblesAfter(node->getOpCode())); + curTime + 1 + schedInfo.numBubblesAfter(node->getOpcode())); } const std::vector& - conflictVec = schedInfo.getConflictList(node->getOpCode()); + conflictVec = schedInfo.getConflictList(node->getOpcode()); for (unsigned i=0; i < conflictVec.size(); i++) { MachineOpCode toOp = conflictVec[i]; - cycles_t est=schedTime + schedInfo.getMinIssueGap(node->getOpCode(),toOp); + cycles_t est=schedTime + schedInfo.getMinIssueGap(node->getOpcode(),toOp); assert(toOp < (int) nextEarliestStartTime.size()); if (nextEarliestStartTime[toOp] < est) nextEarliestStartTime[toOp] = est; @@ -630,8 +630,8 @@ // some NOPs from delay slots. Also, PHIs are not included in the schedule. unsigned numInstr = 0; for (MachineBasicBlock::iterator I=MBB.begin(); I != MBB.end(); ++I) - if (! mii.isNop((*I)->getOpCode()) && - ! mii.isDummyPhiInstr((*I)->getOpCode())) + if (! mii.isNop((*I)->getOpcode()) && + ! mii.isDummyPhiInstr((*I)->getOpcode())) ++numInstr; assert(S.isched.getNumInstructions() >= numInstr && "Lost some non-NOP instructions during scheduling!"); @@ -643,7 +643,7 @@ // First find the dummy instructions at the start of the basic block MachineBasicBlock::iterator I = MBB.begin(); for ( ; I != MBB.end(); ++I) - if (! mii.isDummyPhiInstr((*I)->getOpCode())) + if (! mii.isDummyPhiInstr((*I)->getOpcode())) break; // Erase all except the dummy PHI instructions from MBB, and @@ -726,7 +726,7 @@ if (nextNode == NULL) break; // no more instructions for this cycle - if (S.getInstrInfo().getNumDelaySlots(nextNode->getOpCode()) > 0) { + if (S.getInstrInfo().getNumDelaySlots(nextNode->getOpcode()) > 0) { delaySlotInfo = S.getDelaySlotInfoForInstr(nextNode); if (delaySlotInfo != NULL) { if (indexForBreakingNode < S.nslots) @@ -736,7 +736,7 @@ else indexForDelayedInstr = S.getNumChoices(); } - } else if (S.schedInfo.breaksIssueGroup(nextNode->getOpCode())) { + } else if (S.schedInfo.breaksIssueGroup(nextNode->getOpcode())) { if (indexForBreakingNode < S.nslots) // have a breaking instruction already so throw this one away nextNode = NULL; @@ -747,7 +747,7 @@ if (nextNode != NULL) { S.addChoice(nextNode); - if (S.schedInfo.isSingleIssue(nextNode->getOpCode())) { + if (S.schedInfo.isSingleIssue(nextNode->getOpcode())) { assert(S.getNumChoices() == 1 && "Prioritizer returned invalid instr for this cycle!"); break; @@ -772,7 +772,7 @@ // This is the common case, so handle it separately for efficiency. if (S.getNumChoices() == 1) { - MachineOpCode opCode = S.getChoice(0)->getOpCode(); + MachineOpCode opCode = S.getChoice(0)->getOpcode(); unsigned int s; for (s=startSlot; s < S.nslots; s++) if (S.schedInfo.instrCanUseSlot(opCode, s)) @@ -781,7 +781,7 @@ S.addChoiceToSlot(s, S.getChoice(0)); } else { for (unsigned i=0; i < S.getNumChoices(); i++) { - MachineOpCode opCode = S.getChoice(i)->getOpCode(); + MachineOpCode opCode = S.getChoice(i)->getOpcode(); for (unsigned int s=startSlot; s < S.nslots; s++) if (S.schedInfo.instrCanUseSlot(opCode, s)) S.addChoiceToSlot(s, S.getChoice(i)); @@ -799,7 +799,7 @@ assert(delaySlotInfo != NULL && "No delay slot info for instr?"); const SchedGraphNode* delayedNode = S.getChoice(indexForDelayedInstr); - MachineOpCode delayOpCode = delayedNode->getOpCode(); + MachineOpCode delayOpCode = delayedNode->getOpcode(); unsigned ndelays= S.getInstrInfo().getNumDelaySlots(delayOpCode); unsigned delayedNodeSlot = S.nslots; @@ -817,7 +817,7 @@ for (unsigned i=0; i < S.getNumChoices() - 1; i++) { // Try to assign every other instruction to a lower numbered // slot than delayedNodeSlot. - MachineOpCode opCode =S.getChoice(i)->getOpCode(); + MachineOpCode opCode =S.getChoice(i)->getOpcode(); bool noSlotFound = true; unsigned int s; for (s=startSlot; s < delayedNodeSlot; s++) @@ -867,7 +867,7 @@ // Find the last possible slot for this instruction. for (int s = S.nslots-1; s >= (int) startSlot; s--) - if (S.schedInfo.instrCanUseSlot(breakingNode->getOpCode(), s)) { + if (S.schedInfo.instrCanUseSlot(breakingNode->getOpcode(), s)) { breakingSlot = s; break; } @@ -880,7 +880,7 @@ for (unsigned i=0; i < S.getNumChoices() && i < indexForBreakingNode; i++) { - MachineOpCode opCode =S.getChoice(i)->getOpCode(); + MachineOpCode opCode =S.getChoice(i)->getOpcode(); // If a higher priority instruction cannot be assigned to // any earlier slots, don't schedule the breaking instruction. @@ -914,7 +914,7 @@ // group, only assign them to slots lower than the breaking slot. // Otherwise, just ignore the instruction. for (unsigned i=indexForBreakingNode+1; i < S.getNumChoices(); i++) { - MachineOpCode opCode = S.getChoice(i)->getOpCode(); + MachineOpCode opCode = S.getChoice(i)->getOpcode(); for (unsigned int s=startSlot; s < nslotsToUse; s++) if (S.schedInfo.instrCanUseSlot(opCode, s)) S.addChoiceToSlot(s, S.getChoice(i)); @@ -1026,11 +1026,11 @@ assert(! node->isDummyNode()); // don't put a branch in the delay slot of another branch - if (S.getInstrInfo().isBranch(node->getOpCode())) + if (S.getInstrInfo().isBranch(node->getOpcode())) return false; // don't put a single-issue instruction in the delay slot of a branch - if (S.schedInfo.isSingleIssue(node->getOpCode())) + if (S.schedInfo.isSingleIssue(node->getOpcode())) return false; // don't put a load-use dependence in the delay slot of a branch @@ -1039,13 +1039,13 @@ for (SchedGraphNode::const_iterator EI = node->beginInEdges(); EI != node->endInEdges(); ++EI) if (! ((SchedGraphNode*)(*EI)->getSrc())->isDummyNode() - && mii.isLoad(((SchedGraphNode*)(*EI)->getSrc())->getOpCode()) + && mii.isLoad(((SchedGraphNode*)(*EI)->getSrc())->getOpcode()) && (*EI)->getDepType() == SchedGraphEdge::CtrlDep) return false; // for now, don't put an instruction that does not have operand // interlocks in the delay slot of a branch - if (! S.getInstrInfo().hasOperandInterlock(node->getOpCode())) + if (! S.getInstrInfo().hasOperandInterlock(node->getOpcode())) return false; // Finally, if the instruction precedes the branch, we make sure the @@ -1102,7 +1102,7 @@ { const TargetInstrInfo& mii = S.getInstrInfo(); unsigned ndelays = - mii.getNumDelaySlots(brNode->getOpCode()); + mii.getNumDelaySlots(brNode->getOpcode()); if (ndelays == 0) return; @@ -1117,10 +1117,10 @@ for (sg_pred_iterator P = pred_begin(brNode); P != pred_end(brNode) && sdelayNodeVec.size() < ndelays; ++P) if (! (*P)->isDummyNode() && - ! mii.isNop((*P)->getOpCode()) && + ! mii.isNop((*P)->getOpcode()) && NodeCanFillDelaySlot(S, *P, brNode, /*pred*/ true)) { - if (mii.maxLatency((*P)->getOpCode()) > 1) + if (mii.maxLatency((*P)->getOpcode()) > 1) mdelayNodeVec.push_back(*P); else sdelayNodeVec.push_back(*P); @@ -1133,12 +1133,12 @@ // while (sdelayNodeVec.size() < ndelays && mdelayNodeVec.size() > 0) { unsigned lmin = - mii.maxLatency(mdelayNodeVec[0]->getOpCode()); + mii.maxLatency(mdelayNodeVec[0]->getOpcode()); unsigned minIndex = 0; for (unsigned i=1; i < mdelayNodeVec.size(); i++) { unsigned li = - mii.maxLatency(mdelayNodeVec[i]->getOpCode()); + mii.maxLatency(mdelayNodeVec[i]->getOpcode()); if (lmin >= li) { lmin = li; @@ -1166,7 +1166,7 @@ std::vector nopNodeVec; // this will hold unused NOPs const TargetInstrInfo& mii = S.getInstrInfo(); const MachineInstr* brInstr = node->getMachineInstr(); - unsigned ndelays= mii.getNumDelaySlots(brInstr->getOpCode()); + unsigned ndelays= mii.getNumDelaySlots(brInstr->getOpcode()); assert(ndelays > 0 && "Unnecessary call to replace NOPs"); // Remove the NOPs currently in delay slots from the graph. @@ -1182,14 +1182,14 @@ // and USE THEM. We'll throw away the unused alternatives below // for (unsigned i=firstDelaySlotIdx; i < firstDelaySlotIdx + ndelays; ++i) - if (! mii.isNop(MBB[i]->getOpCode())) + if (! mii.isNop(MBB[i]->getOpcode())) sdelayNodeVec.insert(sdelayNodeVec.begin(), graph->getGraphNodeForInstr(MBB[i])); // Then find the NOPs and keep only as many as are needed. // Put the rest in nopNodeVec to be deleted. for (unsigned i=firstDelaySlotIdx; i < firstDelaySlotIdx + ndelays; ++i) - if (mii.isNop(MBB[i]->getOpCode())) + if (mii.isNop(MBB[i]->getOpcode())) if (sdelayNodeVec.size() < ndelays) sdelayNodeVec.push_back(graph->getGraphNodeForInstr(MBB[i])); else { @@ -1256,7 +1256,7 @@ // unsigned first = 0; while (first < termMvec.size() && - ! mii.isBranch(termMvec[first]->getOpCode())) + ! mii.isBranch(termMvec[first]->getOpcode())) { ++first; } @@ -1283,7 +1283,7 @@ delayNodeVec.clear(); for (unsigned i=0; i < MBB.size(); ++i) if (MBB[i] != brInstr && - mii.getNumDelaySlots(MBB[i]->getOpCode()) > 0) + mii.getNumDelaySlots(MBB[i]->getOpcode()) > 0) { SchedGraphNode* node = graph->getGraphNodeForInstr(MBB[i]); ReplaceNopsWithUsefulInstr(S, node, delayNodeVec, graph); @@ -1321,10 +1321,10 @@ for (unsigned i=0; i < delayNodeVec.size(); i++) { const SchedGraphNode* dnode = delayNodeVec[i]; if ( ! S.isScheduled(dnode) - && S.schedInfo.instrCanUseSlot(dnode->getOpCode(), nextSlot) - && instrIsFeasible(S, dnode->getOpCode())) + && S.schedInfo.instrCanUseSlot(dnode->getOpcode(), nextSlot) + && instrIsFeasible(S, dnode->getOpcode())) { - assert(S.getInstrInfo().hasOperandInterlock(dnode->getOpCode()) + assert(S.getInstrInfo().hasOperandInterlock(dnode->getOpcode()) && "Instructions without interlocks not yet supported " "when filling branch delay slots"); S.scheduleInstr(dnode, nextSlot, nextTime); Index: llvm/lib/CodeGen/InstrSched/SchedGraph.cpp diff -u llvm/lib/CodeGen/InstrSched/SchedGraph.cpp:1.55 llvm/lib/CodeGen/InstrSched/SchedGraph.cpp:1.56 --- llvm/lib/CodeGen/InstrSched/SchedGraph.cpp:1.55 Mon Feb 9 12:42:05 2004 +++ llvm/lib/CodeGen/InstrSched/SchedGraph.cpp Wed Feb 11 19:34:05 2004 @@ -55,7 +55,7 @@ int indexInBB, const TargetMachine& Target) : SchedGraphNodeCommon(NID,indexInBB), MBB(mbb), MI(mbb ? (*mbb)[indexInBB] : 0) { if (MI) { - MachineOpCode mopCode = MI->getOpCode(); + MachineOpCode mopCode = MI->getOpcode(); latency = Target.getInstrInfo().hasResultInterlock(mopCode) ? Target.getInstrInfo().minLatency(mopCode) : Target.getInstrInfo().maxLatency(mopCode); @@ -140,8 +140,8 @@ // Find the first branch instr in the sequence of machine instrs for term // unsigned first = 0; - while (! mii.isBranch(termMvec[first]->getOpCode()) && - ! mii.isReturn(termMvec[first]->getOpCode())) + while (! mii.isBranch(termMvec[first]->getOpcode()) && + ! mii.isReturn(termMvec[first]->getOpcode())) ++first; assert(first < termMvec.size() && "No branch instructions for terminator? Ok, but weird!"); @@ -159,8 +159,8 @@ assert(toNode && "No node for instr generated for branch/ret?"); for (unsigned j = i-1; j != 0; --j) - if (mii.isBranch(termMvec[j-1]->getOpCode()) || - mii.isReturn(termMvec[j-1]->getOpCode())) { + if (mii.isBranch(termMvec[j-1]->getOpcode()) || + mii.isReturn(termMvec[j-1]->getOpcode())) { SchedGraphNode* brNode = getGraphNodeForInstr(termMvec[j-1]); assert(brNode && "No node for instr generated for branch/ret?"); (void) new SchedGraphEdge(brNode, toNode, SchedGraphEdge::CtrlDep, @@ -198,7 +198,7 @@ // the terminator) that also have delay slots, add an outgoing edge // from the instruction to the instructions in the delay slots. // - unsigned d = mii.getNumDelaySlots(MBB[i]->getOpCode()); + unsigned d = mii.getNumDelaySlots(MBB[i]->getOpcode()); assert(i+d < N && "Insufficient delay slots for instruction?"); for (unsigned j=1; j <= d; j++) { @@ -242,12 +242,12 @@ // so simply look at all pairs i]>. // for (unsigned im=0, NM=memNodeVec.size(); im < NM; im++) { - MachineOpCode fromOpCode = memNodeVec[im]->getOpCode(); + MachineOpCode fromOpCode = memNodeVec[im]->getOpcode(); int fromType = (mii.isCall(fromOpCode)? SG_CALL_REF : (mii.isLoad(fromOpCode)? SG_LOAD_REF : SG_STORE_REF)); for (unsigned jm=im+1; jm < NM; jm++) { - MachineOpCode toOpCode = memNodeVec[jm]->getOpCode(); + MachineOpCode toOpCode = memNodeVec[jm]->getOpcode(); int toType = (mii.isCall(toOpCode)? SG_CALL_REF : (mii.isLoad(toOpCode)? SG_LOAD_REF : SG_STORE_REF)); @@ -274,7 +274,7 @@ // so simply look at all pairs i]>. // for (unsigned ic=0, NC=callDepNodeVec.size(); ic < NC; ic++) - if (mii.isCall(callDepNodeVec[ic]->getOpCode())) { + if (mii.isCall(callDepNodeVec[ic]->getOpcode())) { // Add SG_CALL_REF edges from all preds to this instruction. for (unsigned jc=0; jc < ic; jc++) (void) new SchedGraphEdge(callDepNodeVec[jc], callDepNodeVec[ic], @@ -292,7 +292,7 @@ // Find the call instruction nodes and put them in a vector. std::vector callNodeVec; for (unsigned im=0, NM=memNodeVec.size(); im < NM; im++) - if (mii.isCall(memNodeVec[im]->getOpCode())) + if (mii.isCall(memNodeVec[im]->getOpcode())) callNodeVec.push_back(memNodeVec[im]); // Now walk the entire basic block, looking for CC instructions *and* @@ -302,14 +302,14 @@ // int lastCallNodeIdx = -1; for (unsigned i=0, N=bbMvec.size(); i < N; i++) - if (mii.isCall(bbMvec[i]->getOpCode())) { + if (mii.isCall(bbMvec[i]->getOpcode())) { ++lastCallNodeIdx; for ( ; lastCallNodeIdx < (int)callNodeVec.size(); ++lastCallNodeIdx) if (callNodeVec[lastCallNodeIdx]->getMachineInstr() == bbMvec[i]) break; assert(lastCallNodeIdx < (int)callNodeVec.size() && "Missed Call?"); } - else if (mii.isCCInstr(bbMvec[i]->getOpCode())) { + else if (mii.isCCInstr(bbMvec[i]->getOpcode())) { // Add incoming/outgoing edges from/to preceding/later calls SchedGraphNode* ccNode = this->getGraphNodeForInstr(bbMvec[i]); int j=0; @@ -469,7 +469,7 @@ ValueToDefVecMap& valueToDefVecMap) { const TargetInstrInfo& mii = target.getInstrInfo(); - MachineOpCode opCode = node->getOpCode(); + MachineOpCode opCode = node->getOpcode(); if (mii.isCall(opCode) || mii.isCCInstr(opCode)) callDepNodeVec.push_back(node); @@ -554,7 +554,7 @@ // Build graph nodes for each VM instruction and gather def/use info. // Do both those together in a single pass over all machine instructions. for (unsigned i=0; i < MBB.size(); i++) - if (!mii.isDummyPhiInstr(MBB[i]->getOpCode())) { + if (!mii.isDummyPhiInstr(MBB[i]->getOpcode())) { SchedGraphNode* node = new SchedGraphNode(getNumNodes(), &MBB, i, target); noteGraphNodeForInstr(MBB[i], node); Index: llvm/lib/CodeGen/InstrSched/SchedGraph.h diff -u llvm/lib/CodeGen/InstrSched/SchedGraph.h:1.38 llvm/lib/CodeGen/InstrSched/SchedGraph.h:1.39 --- llvm/lib/CodeGen/InstrSched/SchedGraph.h:1.38 Tue Jan 20 11:49:30 2004 +++ llvm/lib/CodeGen/InstrSched/SchedGraph.h Wed Feb 11 19:34:05 2004 @@ -48,7 +48,7 @@ // Accessor methods const MachineInstr* getMachineInstr() const { return MI; } - const MachineOpCode getOpCode() const { return MI->getOpCode(); } + const MachineOpCode getOpcode() const { return MI->getOpcode(); } bool isDummyNode() const { return (MI == NULL); } MachineBasicBlock &getMachineBasicBlock() const { return *MBB; } Index: llvm/lib/CodeGen/InstrSched/SchedPriorities.cpp diff -u llvm/lib/CodeGen/InstrSched/SchedPriorities.cpp:1.29 llvm/lib/CodeGen/InstrSched/SchedPriorities.cpp:1.30 --- llvm/lib/CodeGen/InstrSched/SchedPriorities.cpp:1.29 Tue Nov 11 16:41:33 2003 +++ llvm/lib/CodeGen/InstrSched/SchedPriorities.cpp Wed Feb 11 19:34:05 2004 @@ -211,7 +211,7 @@ // it becomes empty. nextChoice = candsAsHeap.getNode(mcands[nextIdx]); if (getEarliestReadyTimeForNode(nextChoice) > curTime - || ! instrIsFeasible(S, nextChoice->getMachineInstr()->getOpCode())) + || ! instrIsFeasible(S, nextChoice->getMachineInstr()->getOpcode())) { mcands.erase(mcands.begin() + nextIdx); nextIdx = -1; From alkis at cs.uiuc.edu Wed Feb 11 20:28:02 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Wed Feb 11 20:28:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/LiveVar/FunctionLiveVarInfo.cpp BBLiveVar.cpp Message-ID: <200402120227.UAA03515@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/Sparc/LiveVar: FunctionLiveVarInfo.cpp updated: 1.52 -> 1.53 BBLiveVar.cpp updated: 1.43 -> 1.44 --- Log message: Change MachineBasicBlock's vector of MachineInstr pointers into an ilist of MachineInstr objects. This allows constant time removal and insertion of MachineInstr instances from anywhere in each MachineBasicBlock. It also allows for constant time splicing of MachineInstrs into or out of MachineBasicBlocks. --- Diffs of the changes: (+3 -3) Index: llvm/lib/Target/Sparc/LiveVar/FunctionLiveVarInfo.cpp diff -u llvm/lib/Target/Sparc/LiveVar/FunctionLiveVarInfo.cpp:1.52 llvm/lib/Target/Sparc/LiveVar/FunctionLiveVarInfo.cpp:1.53 --- llvm/lib/Target/Sparc/LiveVar/FunctionLiveVarInfo.cpp:1.52 Wed Feb 11 14:47:34 2004 +++ llvm/lib/Target/Sparc/LiveVar/FunctionLiveVarInfo.cpp Wed Feb 11 20:27:09 2004 @@ -283,7 +283,7 @@ for (MachineBasicBlock::const_reverse_iterator MII = MIVec.rbegin(), MIE = MIVec.rend(); MII != MIE; ++MII) { // MI is cur machine inst - const MachineInstr *MI = *MII; + const MachineInstr *MI = &*MII; MInst2LVSetAI[MI] = SetAI; // record in After Inst map @@ -299,7 +299,7 @@ MachineBasicBlock::const_iterator fwdMII = MII.base(); // ptr to *next* MI for (unsigned i = 0; i < DS; ++i, ++fwdMII) { assert(fwdMII != MIVec.end() && "Missing instruction in delay slot?"); - MachineInstr* DelaySlotMI = *fwdMII; + const MachineInstr* DelaySlotMI = fwdMII; if (! TM.getInstrInfo().isNop(DelaySlotMI->getOpcode())) { set_union(*MInst2LVSetBI[DelaySlotMI], *NewSet); if (i+1 == DS) Index: llvm/lib/Target/Sparc/LiveVar/BBLiveVar.cpp diff -u llvm/lib/Target/Sparc/LiveVar/BBLiveVar.cpp:1.43 llvm/lib/Target/Sparc/LiveVar/BBLiveVar.cpp:1.44 --- llvm/lib/Target/Sparc/LiveVar/BBLiveVar.cpp:1.43 Wed Feb 11 14:47:34 2004 +++ llvm/lib/Target/Sparc/LiveVar/BBLiveVar.cpp Wed Feb 11 20:27:09 2004 @@ -41,7 +41,7 @@ // iterate over all the machine instructions in BB for (MachineBasicBlock::const_reverse_iterator MII = MBB.rbegin(), MIE = MBB.rend(); MII != MIE; ++MII) { - const MachineInstr *MI = *MII; + const MachineInstr *MI = &*MII; if (DEBUG_LV >= LV_DEBUG_Verbose) { std::cerr << " *Iterating over machine instr "; From alkis at cs.uiuc.edu Wed Feb 11 20:28:09 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Wed Feb 11 20:28:09 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86TargetMachine.cpp X86RegisterInfo.h X86RegisterInfo.cpp X86CodeEmitter.cpp Printer.cpp PeepholeOptimizer.cpp InstSelectSimple.cpp FloatingPoint.cpp Message-ID: <200402120227.UAA03501@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86TargetMachine.cpp updated: 1.46 -> 1.47 X86RegisterInfo.h updated: 1.18 -> 1.19 X86RegisterInfo.cpp updated: 1.41 -> 1.42 X86CodeEmitter.cpp updated: 1.47 -> 1.48 Printer.cpp updated: 1.79 -> 1.80 PeepholeOptimizer.cpp updated: 1.12 -> 1.13 InstSelectSimple.cpp updated: 1.154 -> 1.155 FloatingPoint.cpp updated: 1.20 -> 1.21 --- Log message: Change MachineBasicBlock's vector of MachineInstr pointers into an ilist of MachineInstr objects. This allows constant time removal and insertion of MachineInstr instances from anywhere in each MachineBasicBlock. It also allows for constant time splicing of MachineInstrs into or out of MachineBasicBlocks. --- Diffs of the changes: (+86 -86) Index: llvm/lib/Target/X86/X86TargetMachine.cpp diff -u llvm/lib/Target/X86/X86TargetMachine.cpp:1.46 llvm/lib/Target/X86/X86TargetMachine.cpp:1.47 --- llvm/lib/Target/X86/X86TargetMachine.cpp:1.46 Sun Feb 8 19:47:10 2004 +++ llvm/lib/Target/X86/X86TargetMachine.cpp Wed Feb 11 20:27:09 2004 @@ -104,9 +104,6 @@ if (!DisableOutput) PM.add(createX86CodePrinterPass(Out, *this)); - // Delete machine code for this function - PM.add(createMachineCodeDeleter()); - return false; // success! } Index: llvm/lib/Target/X86/X86RegisterInfo.h diff -u llvm/lib/Target/X86/X86RegisterInfo.h:1.18 llvm/lib/Target/X86/X86RegisterInfo.h:1.19 --- llvm/lib/Target/X86/X86RegisterInfo.h:1.18 Tue Nov 11 16:41:33 2003 +++ llvm/lib/Target/X86/X86RegisterInfo.h Wed Feb 11 20:27:09 2004 @@ -28,25 +28,26 @@ /// Code Generation virtual methods... int storeRegToStackSlot(MachineBasicBlock &MBB, - MachineBasicBlock::iterator &MBBI, + MachineInstr* MI, unsigned SrcReg, int FrameIndex, const TargetRegisterClass *RC) const; int loadRegFromStackSlot(MachineBasicBlock &MBB, - MachineBasicBlock::iterator &MBBI, + MachineInstr* MI, unsigned DestReg, int FrameIndex, const TargetRegisterClass *RC) const; - int copyRegToReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI, + int copyRegToReg(MachineBasicBlock &MBB, + MachineInstr* MI, unsigned DestReg, unsigned SrcReg, const TargetRegisterClass *RC) const; int eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, - MachineBasicBlock::iterator &I) const; + MachineInstr* MI) const; int eliminateFrameIndex(MachineFunction &MF, - MachineBasicBlock::iterator &II) const; + MachineInstr* MI) const; int processFunctionBeforeFrameFinalized(MachineFunction &MF) const; Index: llvm/lib/Target/X86/X86RegisterInfo.cpp diff -u llvm/lib/Target/X86/X86RegisterInfo.cpp:1.41 llvm/lib/Target/X86/X86RegisterInfo.cpp:1.42 --- llvm/lib/Target/X86/X86RegisterInfo.cpp:1.41 Wed Feb 4 16:17:40 2004 +++ llvm/lib/Target/X86/X86RegisterInfo.cpp Wed Feb 11 20:27:09 2004 @@ -47,37 +47,35 @@ } int X86RegisterInfo::storeRegToStackSlot(MachineBasicBlock &MBB, - MachineBasicBlock::iterator &MBBI, + MachineInstr* MI, unsigned SrcReg, int FrameIdx, const TargetRegisterClass *RC) const { static const unsigned Opcode[] = { X86::MOVrm8, X86::MOVrm16, X86::MOVrm32, X86::FSTPr80 }; - MachineInstr *MI = addFrameReference(BuildMI(Opcode[getIdx(RC)], 5), + MachineInstr *I = addFrameReference(BuildMI(Opcode[getIdx(RC)], 5), FrameIdx).addReg(SrcReg); - MBBI = MBB.insert(MBBI, MI)+1; + MBB.insert(MI, I); return 1; } int X86RegisterInfo::loadRegFromStackSlot(MachineBasicBlock &MBB, - MachineBasicBlock::iterator &MBBI, + MachineInstr* MI, unsigned DestReg, int FrameIdx, const TargetRegisterClass *RC) const{ static const unsigned Opcode[] = { X86::MOVmr8, X86::MOVmr16, X86::MOVmr32, X86::FLDr80 }; - MachineInstr *MI = addFrameReference(BuildMI(Opcode[getIdx(RC)], 4, DestReg), - FrameIdx); - MBBI = MBB.insert(MBBI, MI)+1; + unsigned OC = Opcode[getIdx(RC)]; + MBB.insert(MI, addFrameReference(BuildMI(OC, 4, DestReg), FrameIdx)); return 1; } int X86RegisterInfo::copyRegToReg(MachineBasicBlock &MBB, - MachineBasicBlock::iterator &MBBI, + MachineInstr* MI, unsigned DestReg, unsigned SrcReg, const TargetRegisterClass *RC) const { static const unsigned Opcode[] = { X86::MOVrr8, X86::MOVrr16, X86::MOVrr32, X86::FpMOV }; - MachineInstr *MI = BuildMI(Opcode[getIdx(RC)],1,DestReg).addReg(SrcReg); - MBBI = MBB.insert(MBBI, MI)+1; + MBB.insert(MI, BuildMI(Opcode[getIdx(RC)],1,DestReg).addReg(SrcReg)); return 1; } @@ -95,8 +93,8 @@ int X86RegisterInfo::eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, - MachineBasicBlock::iterator &I) const { - MachineInstr *New = 0, *Old = *I;; + MachineInstr* I) const { + MachineInstr *New = 0, *Old = I; if (hasFP(MF)) { // If we have a frame pointer, turn the adjcallstackup instruction into a // 'sub ESP, ' and the adjcallstackdown instruction into 'add ESP, @@ -119,20 +117,19 @@ } if (New) { - *I = New; // Replace the pseudo instruction with a new instruction... - delete Old; + // Replace the pseudo instruction with a new instruction... + MBB.insert(MBB.erase(I), New); return 0; } else { - I = MBB.erase(I);// Just delete the pseudo instruction... - delete Old; + MBB.erase(I); return -1; } } int X86RegisterInfo::eliminateFrameIndex(MachineFunction &MF, - MachineBasicBlock::iterator &II) const { + MachineInstr* II) const { unsigned i = 0; - MachineInstr &MI = **II; + MachineInstr &MI = *II; while (!MI.getOperand(i).isFrameIndex()) { ++i; assert(i < MI.getNumOperands() && "Instr doesn't have FrameIndex operand!"); @@ -182,13 +179,13 @@ if (NumBytes) { // adjust stack pointer: ESP -= numbytes MI= BuildMI(X86::SUBri32, 1, X86::ESP, MOTy::UseAndDef).addZImm(NumBytes); - MBBI = MBB.insert(MBBI, MI)+1; + MBB.insert(MBBI, MI); } // Save EBP into the appropriate stack slot... MI = addRegOffset(BuildMI(X86::MOVrm32, 5), // mov [ESP-], EBP X86::ESP, EBPOffset+NumBytes).addReg(X86::EBP); - MBBI = MBB.insert(MBBI, MI)+1; + MBB.insert(MBBI, MI); // Update EBP with the new base value... if (NumBytes == 0) // mov EBP, ESP @@ -196,7 +193,7 @@ else // lea EBP, [ESP+StackSize] MI = addRegOffset(BuildMI(X86::LEAr32, 5, X86::EBP), X86::ESP, NumBytes); - MBBI = MBB.insert(MBBI, MI)+1; + MBB.insert(MBBI, MI); } else { // When we have no frame pointer, we reserve argument space for call sites @@ -226,9 +223,9 @@ MachineBasicBlock &MBB) const { unsigned oldSize = MBB.size(); const MachineFrameInfo *MFI = MF.getFrameInfo(); - MachineBasicBlock::iterator MBBI = MBB.end()-1; + MachineBasicBlock::iterator MBBI = MBB.end(); --MBBI; MachineInstr *MI; - assert((*MBBI)->getOpcode() == X86::RET && + assert(MBBI->getOpcode() == X86::RET && "Can only insert epilog into returning blocks"); if (hasFP(MF)) { @@ -238,18 +235,18 @@ // mov ESP, EBP MI = BuildMI(X86::MOVrr32, 1,X86::ESP).addReg(X86::EBP); - MBBI = 1+MBB.insert(MBBI, MI); + MBB.insert(MBBI, MI); // mov EBP, [ESP-] MI = addRegOffset(BuildMI(X86::MOVmr32, 5, X86::EBP), X86::ESP, EBPOffset); - MBBI = 1+MBB.insert(MBBI, MI); + MBB.insert(MBBI, MI); } else { // Get the number of bytes allocated from the FrameInfo... unsigned NumBytes = MFI->getStackSize(); if (NumBytes) { // adjust stack pointer back: ESP += numbytes MI =BuildMI(X86::ADDri32, 1, X86::ESP, MOTy::UseAndDef).addZImm(NumBytes); - MBBI = 1+MBB.insert(MBBI, MI); + MBB.insert(MBBI, MI); } } return MBB.size() - oldSize; Index: llvm/lib/Target/X86/X86CodeEmitter.cpp diff -u llvm/lib/Target/X86/X86CodeEmitter.cpp:1.47 llvm/lib/Target/X86/X86CodeEmitter.cpp:1.48 --- llvm/lib/Target/X86/X86CodeEmitter.cpp:1.47 Wed Feb 4 16:17:40 2004 +++ llvm/lib/Target/X86/X86CodeEmitter.cpp Wed Feb 11 20:27:09 2004 @@ -212,8 +212,6 @@ bool X86TargetMachine::addPassesToEmitMachineCode(FunctionPassManager &PM, MachineCodeEmitter &MCE) { PM.add(new Emitter(MCE)); - // Delete machine code for this function - PM.add(createMachineCodeDeleter()); return false; } @@ -242,7 +240,7 @@ BasicBlockAddrs[MBB.getBasicBlock()] = Addr; for (MachineBasicBlock::iterator I = MBB.begin(), E = MBB.end(); I != E; ++I) - emitInstruction(**I); + emitInstruction(*I); } Index: llvm/lib/Target/X86/Printer.cpp diff -u llvm/lib/Target/X86/Printer.cpp:1.79 llvm/lib/Target/X86/Printer.cpp:1.80 --- llvm/lib/Target/X86/Printer.cpp:1.79 Wed Feb 11 13:26:28 2004 +++ llvm/lib/Target/X86/Printer.cpp Wed Feb 11 20:27:09 2004 @@ -365,7 +365,7 @@ II != E; ++II) { // Print the assembly for the instruction. O << "\t"; - printMachineInstruction(*II); + printMachineInstruction(II); } } Index: llvm/lib/Target/X86/PeepholeOptimizer.cpp diff -u llvm/lib/Target/X86/PeepholeOptimizer.cpp:1.12 llvm/lib/Target/X86/PeepholeOptimizer.cpp:1.13 --- llvm/lib/Target/X86/PeepholeOptimizer.cpp:1.12 Tue Feb 10 15:18:45 2004 +++ llvm/lib/Target/X86/PeepholeOptimizer.cpp Wed Feb 11 20:27:09 2004 @@ -50,8 +50,11 @@ bool PH::PeepholeOptimize(MachineBasicBlock &MBB, MachineBasicBlock::iterator &I) { - MachineInstr *MI = *I; - MachineInstr *Next = (I+1 != MBB.end()) ? *(I+1) : 0; + assert(I != MBB.end()); + MachineBasicBlock::iterator NextI = I; ++NextI; + + MachineInstr *MI = I; + MachineInstr *Next = (NextI != MBB.end()) ? &*NextI : (MachineInstr*)0; unsigned Size = 0; switch (MI->getOpcode()) { case X86::MOVrr8: @@ -59,7 +62,6 @@ case X86::MOVrr32: // Destroy X = X copies... if (MI->getOperand(0).getReg() == MI->getOperand(1).getReg()) { I = MBB.erase(I); - delete MI; return true; } return false; @@ -82,8 +84,8 @@ } unsigned R0 = MI->getOperand(0).getReg(); unsigned R1 = MI->getOperand(1).getReg(); - *I = BuildMI(Opcode, 2, R0).addReg(R1).addZImm((char)Val); - delete MI; + I = MBB.insert(MBB.erase(I), + BuildMI(Opcode, 2, R0).addReg(R1).addZImm((char)Val)); return true; } } @@ -114,8 +116,8 @@ case X86::XORri32: Opcode = X86::XORri32b; break; } unsigned R0 = MI->getOperand(0).getReg(); - *I = BuildMI(Opcode, 1, R0, MOTy::UseAndDef).addZImm((char)Val); - delete MI; + I = MBB.insert(MBB.erase(I), + BuildMI(Opcode, 1, R0, MOTy::UseAndDef).addZImm((char)Val)); return true; } } @@ -132,8 +134,8 @@ if (Val == 0) { // mov EAX, 0 -> xor EAX, EAX static const unsigned Opcode[] ={X86::XORrr8,X86::XORrr16,X86::XORrr32}; unsigned Reg = MI->getOperand(0).getReg(); - *I = BuildMI(Opcode[Size], 2, Reg).addReg(Reg).addReg(Reg); - delete MI; + I = MBB.insert(MBB.erase(I), + BuildMI(Opcode[Size], 2, Reg).addReg(Reg).addReg(Reg)); return true; } else if (Val == -1) { // mov EAX, -1 -> or EAX, -1 // TODO: 'or Reg, -1' has a smaller encoding than 'mov Reg, -1' @@ -145,8 +147,6 @@ if (Next->getOpcode() == X86::BSWAPr32 && MI->getOperand(0).getReg() == Next->getOperand(0).getReg()) { I = MBB.erase(MBB.erase(I)); - delete MI; - delete Next; return true; } return false; @@ -189,12 +189,11 @@ virtual bool runOnMachineFunction(MachineFunction &MF) { for (MachineFunction::iterator BI = MF.begin(), E = MF.end(); BI!=E; ++BI) for (MachineBasicBlock::iterator I = BI->begin(); I != BI->end(); ++I) { - MachineInstr *MI = *I; - for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { - MachineOperand &MO = MI->getOperand(i); + for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) { + MachineOperand &MO = I->getOperand(i); if (MO.isRegister() && MO.isDef() && !MO.isUse() && MRegisterInfo::isVirtualRegister(MO.getReg())) - setDefinition(MO.getReg(), MI); + setDefinition(MO.getReg(), I); } } return false; @@ -377,8 +376,10 @@ bool SSAPH::PeepholeOptimize(MachineBasicBlock &MBB, MachineBasicBlock::iterator &I) { - MachineInstr *MI = *I; - MachineInstr *Next = (I+1 != MBB.end()) ? *(I+1) : 0; + MachineBasicBlock::iterator NextI = I; ++NextI; + + MachineInstr *MI = I; + MachineInstr *Next = (NextI != MBB.end()) ? &*NextI : (MachineInstr*)0; bool Changed = false; Index: llvm/lib/Target/X86/InstSelectSimple.cpp diff -u llvm/lib/Target/X86/InstSelectSimple.cpp:1.154 llvm/lib/Target/X86/InstSelectSimple.cpp:1.155 --- llvm/lib/Target/X86/InstSelectSimple.cpp:1.154 Sun Feb 8 22:37:30 2004 +++ llvm/lib/Target/X86/InstSelectSimple.cpp Wed Feb 11 20:27:09 2004 @@ -37,23 +37,21 @@ /// instruction at as well as a basic block. This is the version for when you /// have a destination register in mind. inline static MachineInstrBuilder BMI(MachineBasicBlock *MBB, - MachineBasicBlock::iterator &I, + MachineBasicBlock::iterator I, int Opcode, unsigned NumOperands, unsigned DestReg) { - assert(I >= MBB->begin() && I <= MBB->end() && "Bad iterator!"); MachineInstr *MI = new MachineInstr(Opcode, NumOperands+1, true, true); - I = MBB->insert(I, MI)+1; + MBB->insert(I, MI); return MachineInstrBuilder(MI).addReg(DestReg, MOTy::Def); } /// BMI - A special BuildMI variant that takes an iterator to insert the /// instruction at as well as a basic block. inline static MachineInstrBuilder BMI(MachineBasicBlock *MBB, - MachineBasicBlock::iterator &I, + MachineBasicBlock::iterator I, int Opcode, unsigned NumOperands) { - assert(I >= MBB->begin() && I <= MBB->end() && "Bad iterator!"); MachineInstr *MI = new MachineInstr(Opcode, NumOperands, true, true); - I = MBB->insert(I, MI)+1; + MBB->insert(I, MI); return MachineInstrBuilder(MI); } @@ -541,19 +539,19 @@ MachineBasicBlock *MBB = MBBMap[I]; // Loop over all of the PHI nodes in the LLVM basic block... - unsigned NumPHIs = 0; + MachineInstr* instr = MBB->begin(); for (BasicBlock::const_iterator I = BB->begin(); PHINode *PN = const_cast(dyn_cast(I)); ++I) { // Create a new machine instr PHI node, and insert it. unsigned PHIReg = getReg(*PN); MachineInstr *PhiMI = BuildMI(X86::PHI, PN->getNumOperands(), PHIReg); - MBB->insert(MBB->begin()+NumPHIs++, PhiMI); + MBB->insert(instr, PhiMI); MachineInstr *LongPhiMI = 0; if (PN->getType() == Type::LongTy || PN->getType() == Type::ULongTy) { LongPhiMI = BuildMI(X86::PHI, PN->getNumOperands(), PHIReg+1); - MBB->insert(MBB->begin()+NumPHIs++, LongPhiMI); + MBB->insert(instr, LongPhiMI); } // PHIValues - Map of blocks to incoming virtual registers. We use this @@ -588,7 +586,7 @@ MachineBasicBlock::iterator PI = PredMBB->begin(); // Skip over any PHI nodes though! - while (PI != PredMBB->end() && (*PI)->getOpcode() == X86::PHI) + while (PI != PredMBB->end() && PI->getOpcode() == X86::PHI) ++PI; ValReg = getReg(Val, PredMBB, PI); Index: llvm/lib/Target/X86/FloatingPoint.cpp diff -u llvm/lib/Target/X86/FloatingPoint.cpp:1.20 llvm/lib/Target/X86/FloatingPoint.cpp:1.21 --- llvm/lib/Target/X86/FloatingPoint.cpp:1.20 Tue Feb 10 14:31:28 2004 +++ llvm/lib/Target/X86/FloatingPoint.cpp Wed Feb 11 20:27:09 2004 @@ -118,7 +118,7 @@ // Emit an fxch to update the runtime processors version of the state MachineInstr *MI = BuildMI(X86::FXCH, 1).addReg(STReg); - I = 1+MBB->insert(I, MI); + MBB->insert(I, MI); NumFXCH++; } } @@ -129,7 +129,7 @@ pushReg(AsReg); // New register on top of stack MachineInstr *MI = BuildMI(X86::FLDrr, 1).addReg(STReg); - I = 1+MBB->insert(I, MI); + MBB->insert(I, MI); } // popStackAfter - Pop the current value off of the top of the FP stack @@ -193,12 +193,17 @@ MBB = &BB; for (MachineBasicBlock::iterator I = BB.begin(); I != BB.end(); ++I) { - MachineInstr *MI = *I; + MachineInstr *MI = I; unsigned Flags = TII.get(MI->getOpcode()).TSFlags; if ((Flags & X86II::FPTypeMask) == X86II::NotFP) continue; // Efficiently ignore non-fp insts! - MachineInstr *PrevMI = I == BB.begin() ? 0 : *(I-1); + MachineInstr *PrevMI = 0; + if (I != BB.begin()) { + MachineBasicBlock::iterator tmp = I; + --tmp; + PrevMI = tmp; + } ++NumFP; // Keep track of # of pseudo instrs DEBUG(std::cerr << "\nFPInst:\t"; @@ -242,15 +247,17 @@ } // Print out all of the instructions expanded to if -debug - DEBUG(if (*I == PrevMI) { + DEBUG(if (&*I == PrevMI) { std::cerr<< "Just deleted pseudo instruction\n"; } else { MachineBasicBlock::iterator Start = I; // Rewind to first instruction newly inserted. - while (Start != BB.begin() && *(Start-1) != PrevMI) --Start; + while (Start != BB.begin() && + --Start != MachineBasicBlock::iterator(PrevMI)); + ++Start; std::cerr << "Inserted instructions:\n\t"; - (*Start)->print(std::cerr, MF.getTarget()); - while (++Start != I+1); + Start->print(std::cerr, MF.getTarget()); + while (++Start != I); ++Start; } dumpStack(); ); @@ -344,15 +351,15 @@ RegMap[Stack[--StackTop]] = ~0; // Update state // Check to see if there is a popping version of this instruction... - int Opcode = Lookup(PopTable, ARRAY_SIZE(PopTable), (*I)->getOpcode()); + int Opcode = Lookup(PopTable, ARRAY_SIZE(PopTable), I->getOpcode()); if (Opcode != -1) { - (*I)->setOpcode(Opcode); + I->setOpcode(Opcode); if (Opcode == X86::FUCOMPPr) - (*I)->RemoveOperand(0); + I->RemoveOperand(0); } else { // Insert an explicit pop MachineInstr *MI = BuildMI(X86::FSTPrr, 1).addReg(X86::ST0); - I = MBB->insert(I+1, MI); + I = MBB->insert(++I, MI); } } @@ -371,7 +378,7 @@ /// handleZeroArgFP - ST(0) = fld0 ST(0) = flds /// void FPS::handleZeroArgFP(MachineBasicBlock::iterator &I) { - MachineInstr *MI = *I; + MachineInstr *MI = I; unsigned DestReg = getFPReg(MI->getOperand(0)); MI->RemoveOperand(0); // Remove the explicit ST(0) operand @@ -382,7 +389,7 @@ /// handleOneArgFP - fst , ST(0) /// void FPS::handleOneArgFP(MachineBasicBlock::iterator &I) { - MachineInstr *MI = *I; + MachineInstr *MI = I; assert((MI->getNumOperands() == 5 || MI->getNumOperands() == 1) && "Can only handle fst* & ftst instructions!"); @@ -418,7 +425,7 @@ /// handleOneArgFPRW - fchs - ST(0) = -ST(0) /// void FPS::handleOneArgFPRW(MachineBasicBlock::iterator &I) { - MachineInstr *MI = *I; + MachineInstr *MI = I; assert(MI->getNumOperands() == 2 && "Can only handle fst* instructions!"); // Is this the last use of the source register? @@ -503,7 +510,7 @@ void FPS::handleTwoArgFP(MachineBasicBlock::iterator &I) { ASSERT_SORTED(ForwardST0Table); ASSERT_SORTED(ReverseST0Table); ASSERT_SORTED(ForwardSTiTable); ASSERT_SORTED(ReverseSTiTable); - MachineInstr *MI = *I; + MachineInstr *MI = I; unsigned NumOperands = MI->getNumOperands(); assert(NumOperands == 3 || @@ -588,7 +595,8 @@ unsigned NotTOS = (TOS == Op0) ? Op1 : Op0; // Replace the old instruction with a new instruction - *I = BuildMI(Opcode, 1).addReg(getSTReg(NotTOS)); + MBB->remove(I); + I = MBB->insert(I, BuildMI(Opcode, 1).addReg(getSTReg(NotTOS))); // If both operands are killed, pop one off of the stack in addition to // overwriting the other one. @@ -617,7 +625,7 @@ Stack[--StackTop] = ~0; MachineInstr *MI = BuildMI(X86::FSTPrr, 1).addReg(STReg); - I = MBB->insert(I+1, MI); + I = MBB->insert(++I, MI); } } } @@ -639,7 +647,7 @@ /// instructions. /// void FPS::handleSpecialFP(MachineBasicBlock::iterator &I) { - MachineInstr *MI = *I; + MachineInstr *MI = I; switch (MI->getOpcode()) { default: assert(0 && "Unknown SpecialFP instruction!"); case X86::FpGETRESULT: // Appears immediately after a call returning FP type! @@ -675,6 +683,6 @@ } } - I = MBB->erase(I)-1; // Remove the pseudo instruction - delete MI; + I = MBB->erase(I); // Remove the pseudo instruction + --I; } From alkis at cs.uiuc.edu Wed Feb 11 20:28:15 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Wed Feb 11 20:28:15 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/InstrSelection/InstrSelection.cpp Message-ID: <200402120227.UAA03522@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/Sparc/InstrSelection: InstrSelection.cpp updated: 1.68 -> 1.69 --- Log message: Change MachineBasicBlock's vector of MachineInstr pointers into an ilist of MachineInstr objects. This allows constant time removal and insertion of MachineInstr instances from anywhere in each MachineBasicBlock. It also allows for constant time splicing of MachineInstrs into or out of MachineBasicBlocks. --- Diffs of the changes: (+1 -4) Index: llvm/lib/Target/Sparc/InstrSelection/InstrSelection.cpp diff -u llvm/lib/Target/Sparc/InstrSelection/InstrSelection.cpp:1.68 llvm/lib/Target/Sparc/InstrSelection/InstrSelection.cpp:1.69 --- llvm/lib/Target/Sparc/InstrSelection/InstrSelection.cpp:1.68 Sun Dec 28 15:23:38 2003 +++ llvm/lib/Target/Sparc/InstrSelection/InstrSelection.cpp Wed Feb 11 20:27:09 2004 @@ -283,10 +283,7 @@ break; } - // find the position of first machine instruction generated by the - // terminator of this BB - MachineBasicBlock::iterator MCIt = - std::find(MBB->begin(), MBB->end(), FirstMIOfTerm); + MachineBasicBlock::iterator MCIt = FirstMIOfTerm; assert(MCIt != MBB->end() && "Start inst of terminator not found"); From alkis at cs.uiuc.edu Wed Feb 11 20:28:21 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Wed Feb 11 20:28:21 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/RegAlloc/PhyRegAlloc.cpp LiveRangeInfo.cpp Message-ID: <200402120227.UAA03504@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/Sparc/RegAlloc: PhyRegAlloc.cpp updated: 1.133 -> 1.134 LiveRangeInfo.cpp updated: 1.49 -> 1.50 --- Log message: Change MachineBasicBlock's vector of MachineInstr pointers into an ilist of MachineInstr objects. This allows constant time removal and insertion of MachineInstr instances from anywhere in each MachineBasicBlock. It also allows for constant time splicing of MachineInstrs into or out of MachineBasicBlocks. --- Diffs of the changes: (+38 -47) Index: llvm/lib/Target/Sparc/RegAlloc/PhyRegAlloc.cpp diff -u llvm/lib/Target/Sparc/RegAlloc/PhyRegAlloc.cpp:1.133 llvm/lib/Target/Sparc/RegAlloc/PhyRegAlloc.cpp:1.134 --- llvm/lib/Target/Sparc/RegAlloc/PhyRegAlloc.cpp:1.133 Wed Feb 11 14:47:34 2004 +++ llvm/lib/Target/Sparc/RegAlloc/PhyRegAlloc.cpp Wed Feb 11 20:27:09 2004 @@ -233,7 +233,7 @@ // iterate over all the machine instructions in BB for ( ; MII != MBB.end(); ++MII) { - const MachineInstr *MInst = *MII; + const MachineInstr *MInst = MII; // get the LV set after the instruction const ValueSet &LVSetAI = LVI->getLiveVarSetAfterMInst(MInst, BB); @@ -355,25 +355,13 @@ MII = MBB.insert(MII, newMI); } -// used by: updateMachineCode (1 time) -inline void DeleteInstruction(MachineBasicBlock& MBB, - MachineBasicBlock::iterator& MII) { - MII = MBB.erase(MII); -} - -// used by: updateMachineCode (1 time) -inline void SubstituteInPlace(MachineInstr* newMI, MachineBasicBlock& MBB, - MachineBasicBlock::iterator MII) { - *MII = newMI; -} - // used by: updateMachineCode (2 times) inline void PrependInstructions(std::vector &IBef, MachineBasicBlock& MBB, MachineBasicBlock::iterator& MII, const std::string& msg) { if (!IBef.empty()) { - MachineInstr* OrigMI = *MII; + MachineInstr* OrigMI = MII; std::vector::iterator AdIt; for (AdIt = IBef.begin(); AdIt != IBef.end() ; ++AdIt) { if (DEBUG_RA) { @@ -391,7 +379,7 @@ MachineBasicBlock::iterator& MII, const std::string& msg) { if (!IAft.empty()) { - MachineInstr* OrigMI = *MII; + MachineInstr* OrigMI = MII; std::vector::iterator AdIt; for ( AdIt = IAft.begin(); AdIt != IAft.end() ; ++AdIt ) { if (DEBUG_RA) { @@ -442,14 +430,14 @@ /// void PhyRegAlloc::updateInstruction(MachineBasicBlock::iterator& MII, MachineBasicBlock &MBB) { - MachineInstr* MInst = *MII; + MachineInstr* MInst = MII; unsigned Opcode = MInst->getOpcode(); // Reset tmp stack positions so they can be reused for each machine instr. MF->getInfo()->popAllTempValues(); // Mark the operands for which regs have been allocated. - bool instrNeedsSpills = markAllocatedRegs(*MII); + bool instrNeedsSpills = markAllocatedRegs(MII); #ifndef NDEBUG // Mark that the operands have been updated. Later, @@ -506,7 +494,7 @@ // their assigned registers or insert spill code, as appropriate. // Also, fix operands of call/return instructions. for (MachineBasicBlock::iterator MII = MBB.begin(); MII != MBB.end(); ++MII) - if (! TM.getInstrInfo().isDummyPhiInstr((*MII)->getOpcode())) + if (! TM.getInstrInfo().isDummyPhiInstr(MII->getOpcode())) updateInstruction(MII, MBB); // Now, move code out of delay slots of branches and returns if needed. @@ -523,56 +511,58 @@ // // If the annul bit of the branch is set, neither of these is legal! // If so, we need to handle spill differently but annulling is not yet used. - for (MachineBasicBlock::iterator MII = MBB.begin(); - MII != MBB.end(); ++MII) + for (MachineBasicBlock::iterator MII = MBB.begin(); MII != MBB.end(); ++MII) if (unsigned delaySlots = - TM.getInstrInfo().getNumDelaySlots((*MII)->getOpcode())) { - MachineInstr *MInst = *MII, *DelaySlotMI = *(MII+1); + TM.getInstrInfo().getNumDelaySlots(MII->getOpcode())) { + MachineBasicBlock::iterator DelaySlotMI = MII; ++DelaySlotMI; + assert(DelaySlotMI != MBB.end() && "no instruction for delay slot"); // Check the 2 conditions above: // (1) Does a branch need instructions added after it? // (2) O/w does delay slot instr. need instrns before or after? - bool isBranch = (TM.getInstrInfo().isBranch(MInst->getOpcode()) || - TM.getInstrInfo().isReturn(MInst->getOpcode())); + bool isBranch = (TM.getInstrInfo().isBranch(MII->getOpcode()) || + TM.getInstrInfo().isReturn(MII->getOpcode())); bool cond1 = (isBranch && - AddedInstrMap.count(MInst) && - AddedInstrMap[MInst].InstrnsAfter.size() > 0); + AddedInstrMap.count(MII) && + AddedInstrMap[MII].InstrnsAfter.size() > 0); bool cond2 = (AddedInstrMap.count(DelaySlotMI) && (AddedInstrMap[DelaySlotMI].InstrnsBefore.size() > 0 || AddedInstrMap[DelaySlotMI].InstrnsAfter.size() > 0)); if (cond1 || cond2) { - assert((MInst->getOpCodeFlags() & AnnulFlag) == 0 && + assert((MII->getOpCodeFlags() & AnnulFlag) == 0 && "FIXME: Moving an annulled delay slot instruction!"); assert(delaySlots==1 && "InsertBefore does not yet handle >1 delay slots!"); - InsertBefore(DelaySlotMI, MBB, MII); // MII pts back to branch - - // In case (1), delete it and don't replace with anything! - // Otherwise (i.e., case (2) only) replace it with a NOP. - if (cond1) { - DeleteInstruction(MBB, ++MII); // MII now points to next inst. - --MII; // reset MII for ++MII of loop - } - else - SubstituteInPlace(BuildMI(TM.getInstrInfo().getNOPOpCode(),1), - MBB, MII+1); // replace with NOP if (DEBUG_RA) { std::cerr << "\nRegAlloc: Moved instr. with added code: " << *DelaySlotMI - << " out of delay slots of instr: " << *MInst; + << " out of delay slots of instr: " << *MII; + } + + // move instruction before branch + MBB.insert(MII, MBB.remove(DelaySlotMI)); + + // On cond1 we are done (we already moved the + // instruction out of the delay slot). On cond2 we need + // to insert a nop in place of the moved instruction + if (cond2) { + MBB.insert(MII, BuildMI(TM.getInstrInfo().getNOPOpCode(),1)); } } - else + else { // For non-branch instr with delay slots (probably a call), move // InstrAfter to the instr. in the last delay slot. - move2DelayedInstr(*MII, *(MII+delaySlots)); - } + MachineBasicBlock::iterator tmp = MII; + std::advance(tmp, delaySlots); + move2DelayedInstr(MII, tmp); + } + } // Finally iterate over all instructions in BB and insert before/after for (MachineBasicBlock::iterator MII=MBB.begin(); MII != MBB.end(); ++MII) { - MachineInstr *MInst = *MII; + MachineInstr *MInst = MII; // do not process Phis if (TM.getInstrInfo().isDummyPhiInstr(MInst->getOpcode())) @@ -635,7 +625,7 @@ MachineBasicBlock::iterator& MII, MachineBasicBlock &MBB, const unsigned OpNum) { - MachineInstr *MInst = *MII; + MachineInstr *MInst = MII; const BasicBlock *BB = MBB.getBasicBlock(); assert((! TM.getInstrInfo().isCall(MInst->getOpcode()) || OpNum == 0) && @@ -658,7 +648,8 @@ // include all live variables before that branch or return -- we don't want to // trample those! Verify that the set is included in the LV set before MInst. if (MII != MBB.begin()) { - MachineInstr *PredMI = *(MII-1); + MachineBasicBlock::iterator PredMI = MII; + --PredMI; if (unsigned DS = TM.getInstrInfo().getNumDelaySlots(PredMI->getOpcode())) assert(set_difference(LVI->getLiveVarSetBeforeMInst(PredMI), LVSetBef) .empty() && "Live-var set before branch should be included in " Index: llvm/lib/Target/Sparc/RegAlloc/LiveRangeInfo.cpp diff -u llvm/lib/Target/Sparc/RegAlloc/LiveRangeInfo.cpp:1.49 llvm/lib/Target/Sparc/RegAlloc/LiveRangeInfo.cpp:1.50 --- llvm/lib/Target/Sparc/RegAlloc/LiveRangeInfo.cpp:1.49 Wed Feb 11 14:47:34 2004 +++ llvm/lib/Target/Sparc/RegAlloc/LiveRangeInfo.cpp Wed Feb 11 20:27:09 2004 @@ -171,7 +171,7 @@ // iterate over all the machine instructions in BB for(MachineBasicBlock::iterator MInstIterator = MBB.begin(); MInstIterator != MBB.end(); ++MInstIterator) { - MachineInstr *MInst = *MInstIterator; + MachineInstr *MInst = MInstIterator; // If the machine instruction is a call/return instruction, add it to // CallRetInstrList for processing its args, ret value, and ret addr. @@ -330,7 +330,7 @@ // iterate over all the machine instructions in BB for(MachineBasicBlock::iterator MII = MBB.begin(); MII != MBB.end(); ++MII){ - const MachineInstr *MI = *MII; + const MachineInstr *MI = MII; if( DEBUG_RA >= RA_DEBUG_LiveRanges) { std::cerr << " *Iterating over machine instr "; From alkis at cs.uiuc.edu Wed Feb 11 20:28:26 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Wed Feb 11 20:28:26 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp PrologEpilogCodeInserter.cpp PeepholeOpts.cpp MappingInfo.cpp EmitAssembly.cpp Message-ID: <200402120227.UAA03538@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/Sparc: SparcV9CodeEmitter.cpp updated: 1.54 -> 1.55 PrologEpilogCodeInserter.cpp updated: 1.33 -> 1.34 PeepholeOpts.cpp updated: 1.18 -> 1.19 MappingInfo.cpp updated: 1.15 -> 1.16 EmitAssembly.cpp updated: 1.104 -> 1.105 --- Log message: Change MachineBasicBlock's vector of MachineInstr pointers into an ilist of MachineInstr objects. This allows constant time removal and insertion of MachineInstr instances from anywhere in each MachineBasicBlock. It also allows for constant time splicing of MachineInstrs into or out of MachineBasicBlocks. --- Diffs of the changes: (+13 -21) Index: llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp diff -u llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp:1.54 llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp:1.55 --- llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp:1.54 Wed Feb 11 00:04:51 2004 +++ llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp Wed Feb 11 20:27:09 2004 @@ -778,7 +778,7 @@ currBB = MBB.getBasicBlock(); BBLocations[currBB] = MCE.getCurrentPCValue(); for (MachineBasicBlock::iterator I = MBB.begin(), E = MBB.end(); I != E; ++I){ - unsigned binCode = getBinaryCodeForInstr(**I); + unsigned binCode = getBinaryCodeForInstr(*I); if (binCode == (1 << 30)) { // this is an invalid call: the addr is out of bounds. that means a code // sequence has already been emitted, and this is a no-op Index: llvm/lib/Target/Sparc/PrologEpilogCodeInserter.cpp diff -u llvm/lib/Target/Sparc/PrologEpilogCodeInserter.cpp:1.33 llvm/lib/Target/Sparc/PrologEpilogCodeInserter.cpp:1.34 --- llvm/lib/Target/Sparc/PrologEpilogCodeInserter.cpp:1.33 Wed Feb 11 14:47:32 2004 +++ llvm/lib/Target/Sparc/PrologEpilogCodeInserter.cpp Wed Feb 11 20:27:09 2004 @@ -157,12 +157,12 @@ unsigned numNOPs = 0; while (termMvec.back()->getOpcode() == V9::NOP) { - assert( termMvec.back() == MBB.back()); - delete MBB.pop_back(); + assert( termMvec.back() == &MBB.back()); termMvec.pop_back(); + MBB.erase(&MBB.back()); ++numNOPs; } - assert(termMvec.back() == MBB.back()); + assert(termMvec.back() == &MBB.back()); // Check that we found the right number of NOPs and have the right // number of instructions to replace them. Index: llvm/lib/Target/Sparc/PeepholeOpts.cpp diff -u llvm/lib/Target/Sparc/PeepholeOpts.cpp:1.18 llvm/lib/Target/Sparc/PeepholeOpts.cpp:1.19 --- llvm/lib/Target/Sparc/PeepholeOpts.cpp:1.18 Wed Feb 11 14:47:32 2004 +++ llvm/lib/Target/Sparc/PeepholeOpts.cpp Wed Feb 11 20:27:09 2004 @@ -31,14 +31,14 @@ // Check if this instruction is in a delay slot of its predecessor. if (BBI != mvec.begin()) { const TargetInstrInfo& mii = target.getInstrInfo(); - MachineInstr* predMI = *(BBI-1); + MachineBasicBlock::iterator predMI = BBI; --predMI; if (unsigned ndelay = mii.getNumDelaySlots(predMI->getOpcode())) { // This instruction is in a delay slot of its predecessor, so // replace it with a nop. By replacing in place, we save having // to update the I-I maps. // assert(ndelay == 1 && "Not yet handling multiple-delay-slot targets"); - (*BBI)->replace(mii.getNOPOpCode(), 0); + BBI->replace(mii.getNOPOpCode(), 0); return; } } @@ -99,7 +99,7 @@ RemoveUselessCopies(MachineBasicBlock& mvec, MachineBasicBlock::iterator& BBI, const TargetMachine& target) { - if (IsUselessCopy(target, *BBI)) { + if (IsUselessCopy(target, BBI)) { DeleteInstruction(mvec, BBI, target); return true; } @@ -148,16 +148,8 @@ assert(MBB && "MachineBasicBlock object not found for specified block!"); MachineBasicBlock &mvec = *MBB; - // Iterate over all machine instructions in the BB - // Use a reverse iterator to allow deletion of MI or any instruction after it. - // Insertions or deletions *before* MI are not safe. - // - for (MachineBasicBlock::reverse_iterator RI=mvec.rbegin(), - 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); - } + for (MachineBasicBlock::iterator I = mvec.begin(), E = mvec.end(); I != E; ) + visit(mvec, I++); return true; } Index: llvm/lib/Target/Sparc/MappingInfo.cpp diff -u llvm/lib/Target/Sparc/MappingInfo.cpp:1.15 llvm/lib/Target/Sparc/MappingInfo.cpp:1.16 --- llvm/lib/Target/Sparc/MappingInfo.cpp:1.15 Tue Nov 11 16:41:33 2003 +++ llvm/lib/Target/Sparc/MappingInfo.cpp Wed Feb 11 20:27:09 2004 @@ -153,7 +153,7 @@ for (MachineFunction::iterator BI = MF.begin(), BE = MF.end(); BI != BE; ++BI) { MachineBasicBlock &miBB = *BI; - key[miBB[0]] = i; + key[&miBB.front()] = i; i = i+(miBB.size()); } } @@ -174,7 +174,7 @@ unsigned j = 0; for(MachineBasicBlock::iterator miI = miBB.begin(), miE = miBB.end(); miI != miE; ++miI, ++j) { - key[*miI] = j; + key[miI] = j; } } } @@ -195,7 +195,7 @@ BI != BE; ++BI, ++bb) { MachineBasicBlock &miBB = *BI; writeNumber(bb); - writeNumber(BBkey[miBB[0]]); + writeNumber(BBkey[&miBB.front()]); writeNumber(miBB.size()); } } Index: llvm/lib/Target/Sparc/EmitAssembly.cpp diff -u llvm/lib/Target/Sparc/EmitAssembly.cpp:1.104 llvm/lib/Target/Sparc/EmitAssembly.cpp:1.105 --- llvm/lib/Target/Sparc/EmitAssembly.cpp:1.104 Wed Feb 11 14:47:31 2004 +++ llvm/lib/Target/Sparc/EmitAssembly.cpp Wed Feb 11 20:27:09 2004 @@ -721,7 +721,7 @@ // Loop over all of the instructions in the basic block... for (MachineBasicBlock::const_iterator MII = MBB.begin(), MIE = MBB.end(); MII != MIE; ++MII) - emitMachineInst(*MII); + emitMachineInst(MII); toAsm << "\n"; // Separate BB's with newlines } From alkis at cs.uiuc.edu Wed Feb 11 20:28:32 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Wed Feb 11 20:28:32 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/InstrSched/SchedGraph.cpp InstrScheduling.cpp Message-ID: <200402120227.UAA03558@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/InstrSched: SchedGraph.cpp updated: 1.56 -> 1.57 InstrScheduling.cpp updated: 1.64 -> 1.65 --- Log message: Change MachineBasicBlock's vector of MachineInstr pointers into an ilist of MachineInstr objects. This allows constant time removal and insertion of MachineInstr instances from anywhere in each MachineBasicBlock. It also allows for constant time splicing of MachineInstrs into or out of MachineBasicBlocks. --- Diffs of the changes: (+24 -23) Index: llvm/lib/CodeGen/InstrSched/SchedGraph.cpp diff -u llvm/lib/CodeGen/InstrSched/SchedGraph.cpp:1.56 llvm/lib/CodeGen/InstrSched/SchedGraph.cpp:1.57 --- llvm/lib/CodeGen/InstrSched/SchedGraph.cpp:1.56 Wed Feb 11 19:34:05 2004 +++ llvm/lib/CodeGen/InstrSched/SchedGraph.cpp Wed Feb 11 20:27:10 2004 @@ -53,7 +53,8 @@ SchedGraphNode::SchedGraphNode(unsigned NID, MachineBasicBlock *mbb, int indexInBB, const TargetMachine& Target) - : SchedGraphNodeCommon(NID,indexInBB), MBB(mbb), MI(mbb ? (*mbb)[indexInBB] : 0) { + : SchedGraphNodeCommon(NID,indexInBB), MBB(mbb), + MI(mbb ? &(*mbb)[indexInBB] : (MachineInstr*)0) { if (MI) { MachineOpCode mopCode = MI->getOpcode(); latency = Target.getInstrInfo().hasResultInterlock(mopCode) @@ -183,10 +184,10 @@ // all preceding instructions in the basic block. Use 0 latency again. // for (unsigned i=0, N=MBB.size(); i < N; i++) { - if (MBB[i] == termMvec[first]) // reached the first branch + if (&MBB[i] == termMvec[first]) // reached the first branch break; - SchedGraphNode* fromNode = this->getGraphNodeForInstr(MBB[i]); + SchedGraphNode* fromNode = this->getGraphNodeForInstr(&MBB[i]); if (fromNode == NULL) continue; // dummy instruction, e.g., PHI @@ -198,11 +199,11 @@ // the terminator) that also have delay slots, add an outgoing edge // from the instruction to the instructions in the delay slots. // - unsigned d = mii.getNumDelaySlots(MBB[i]->getOpcode()); + unsigned d = mii.getNumDelaySlots(MBB[i].getOpcode()); assert(i+d < N && "Insufficient delay slots for instruction?"); for (unsigned j=1; j <= d; j++) { - SchedGraphNode* toNode = this->getGraphNodeForInstr(MBB[i+j]); + SchedGraphNode* toNode = this->getGraphNodeForInstr(&MBB[i+j]); assert(toNode && "No node for machine instr in delay slot?"); (void) new SchedGraphEdge(fromNode, toNode, SchedGraphEdge::CtrlDep, @@ -554,9 +555,9 @@ // Build graph nodes for each VM instruction and gather def/use info. // Do both those together in a single pass over all machine instructions. for (unsigned i=0; i < MBB.size(); i++) - if (!mii.isDummyPhiInstr(MBB[i]->getOpcode())) { + if (!mii.isDummyPhiInstr(MBB[i].getOpcode())) { SchedGraphNode* node = new SchedGraphNode(getNumNodes(), &MBB, i, target); - noteGraphNodeForInstr(MBB[i], node); + noteGraphNodeForInstr(&MBB[i], node); // Remember all register references and value defs findDefUseInfoAtInstr(target, node, memNodeVec, callDepNodeVec, @@ -632,7 +633,7 @@ // Then add incoming def-use (SSA) edges for each machine instruction. for (unsigned i=0, N=MBB.size(); i < N; i++) - addEdgesForInstruction(*MBB[i], valueToDefVecMap, target); + addEdgesForInstruction(MBB[i], valueToDefVecMap, target); // Then add edges for dependences on machine registers this->addMachineRegEdges(regToRefVecMap, target); Index: llvm/lib/CodeGen/InstrSched/InstrScheduling.cpp diff -u llvm/lib/CodeGen/InstrSched/InstrScheduling.cpp:1.64 llvm/lib/CodeGen/InstrSched/InstrScheduling.cpp:1.65 --- llvm/lib/CodeGen/InstrSched/InstrScheduling.cpp:1.64 Wed Feb 11 19:34:05 2004 +++ llvm/lib/CodeGen/InstrSched/InstrScheduling.cpp Wed Feb 11 20:27:10 2004 @@ -630,8 +630,8 @@ // some NOPs from delay slots. Also, PHIs are not included in the schedule. unsigned numInstr = 0; for (MachineBasicBlock::iterator I=MBB.begin(); I != MBB.end(); ++I) - if (! mii.isNop((*I)->getOpcode()) && - ! mii.isDummyPhiInstr((*I)->getOpcode())) + if (! mii.isNop(I->getOpcode()) && + ! mii.isDummyPhiInstr(I->getOpcode())) ++numInstr; assert(S.isched.getNumInstructions() >= numInstr && "Lost some non-NOP instructions during scheduling!"); @@ -643,12 +643,12 @@ // First find the dummy instructions at the start of the basic block MachineBasicBlock::iterator I = MBB.begin(); for ( ; I != MBB.end(); ++I) - if (! mii.isDummyPhiInstr((*I)->getOpcode())) + if (! mii.isDummyPhiInstr(I->getOpcode())) break; - // Erase all except the dummy PHI instructions from MBB, and + // Remove all except the dummy PHI instructions from MBB, and // pre-allocate create space for the ones we will put back in. - MBB.erase(I, MBB.end()); + while (I != MBB.end()) MBB.remove(I); InstrSchedule::const_iterator NIend = S.isched.end(); for (InstrSchedule::const_iterator NI = S.isched.begin(); NI != NIend; ++NI) @@ -1175,25 +1175,25 @@ // unsigned int firstDelaySlotIdx = node->getOrigIndexInBB() + 1; MachineBasicBlock& MBB = node->getMachineBasicBlock(); - assert(MBB[firstDelaySlotIdx - 1] == brInstr && + assert(&MBB[firstDelaySlotIdx - 1] == brInstr && "Incorrect instr. index in basic block for brInstr"); // First find all useful instructions already in the delay slots // and USE THEM. We'll throw away the unused alternatives below // for (unsigned i=firstDelaySlotIdx; i < firstDelaySlotIdx + ndelays; ++i) - if (! mii.isNop(MBB[i]->getOpcode())) + if (! mii.isNop(MBB[i].getOpcode())) sdelayNodeVec.insert(sdelayNodeVec.begin(), - graph->getGraphNodeForInstr(MBB[i])); + graph->getGraphNodeForInstr(&MBB[i])); // Then find the NOPs and keep only as many as are needed. // Put the rest in nopNodeVec to be deleted. for (unsigned i=firstDelaySlotIdx; i < firstDelaySlotIdx + ndelays; ++i) - if (mii.isNop(MBB[i]->getOpcode())) + if (mii.isNop(MBB[i].getOpcode())) if (sdelayNodeVec.size() < ndelays) - sdelayNodeVec.push_back(graph->getGraphNodeForInstr(MBB[i])); + sdelayNodeVec.push_back(graph->getGraphNodeForInstr(&MBB[i])); else { - nopNodeVec.push_back(graph->getGraphNodeForInstr(MBB[i])); + nopNodeVec.push_back(graph->getGraphNodeForInstr(&MBB[i])); //remove the MI from the Machine Code For Instruction const TerminatorInst *TI = MBB.getBasicBlock()->getTerminator(); @@ -1202,7 +1202,7 @@ for(MachineCodeForInstruction::iterator mciI=llvmMvec.begin(), mciE=llvmMvec.end(); mciI!=mciE; ++mciI){ - if (*mciI==MBB[i]) + if (*mciI == &MBB[i]) llvmMvec.erase(mciI); } } @@ -1282,10 +1282,10 @@ // delayNodeVec.clear(); for (unsigned i=0; i < MBB.size(); ++i) - if (MBB[i] != brInstr && - mii.getNumDelaySlots(MBB[i]->getOpcode()) > 0) + if (&MBB[i] != brInstr && + mii.getNumDelaySlots(MBB[i].getOpcode()) > 0) { - SchedGraphNode* node = graph->getGraphNodeForInstr(MBB[i]); + SchedGraphNode* node = graph->getGraphNodeForInstr(&MBB[i]); ReplaceNopsWithUsefulInstr(S, node, delayNodeVec, graph); } } From alkis at cs.uiuc.edu Wed Feb 11 20:28:38 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Wed Feb 11 20:28:38 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Target/MRegisterInfo.h Message-ID: <200402120227.UAA03583@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Target: MRegisterInfo.h updated: 1.28 -> 1.29 --- Log message: Change MachineBasicBlock's vector of MachineInstr pointers into an ilist of MachineInstr objects. This allows constant time removal and insertion of MachineInstr instances from anywhere in each MachineBasicBlock. It also allows for constant time splicing of MachineInstrs into or out of MachineBasicBlocks. --- Diffs of the changes: (+8 -7) Index: llvm/include/llvm/Target/MRegisterInfo.h diff -u llvm/include/llvm/Target/MRegisterInfo.h:1.28 llvm/include/llvm/Target/MRegisterInfo.h:1.29 --- llvm/include/llvm/Target/MRegisterInfo.h:1.28 Sun Feb 1 11:14:20 2004 +++ llvm/include/llvm/Target/MRegisterInfo.h Wed Feb 11 20:27:10 2004 @@ -16,13 +16,14 @@ #ifndef LLVM_TARGET_MREGISTERINFO_H #define LLVM_TARGET_MREGISTERINFO_H -#include "llvm/CodeGen/MachineBasicBlock.h" #include namespace llvm { class Type; +class MachineBasicBlock; class MachineFunction; +class MachineInstr; /// MRegisterDesc - This record contains all of the information known about a /// particular register. The AliasSet field (if not null) contains a pointer to @@ -226,17 +227,17 @@ // virtual int storeRegToStackSlot(MachineBasicBlock &MBB, - MachineBasicBlock::iterator &MBBI, + MachineInstr* MI, unsigned SrcReg, int FrameIndex, const TargetRegisterClass *RC) const = 0; virtual int loadRegFromStackSlot(MachineBasicBlock &MBB, - MachineBasicBlock::iterator &MBBI, + MachineInstr* MI, unsigned DestReg, int FrameIndex, const TargetRegisterClass *RC) const = 0; virtual int copyRegToReg(MachineBasicBlock &MBB, - MachineBasicBlock::iterator &MBBI, + MachineInstr* MI, unsigned DestReg, unsigned SrcReg, const TargetRegisterClass *RC) const = 0; @@ -260,8 +261,8 @@ /// instructions added to (negative if removed from) the basic block. /// virtual int eliminateCallFramePseudoInstr(MachineFunction &MF, - MachineBasicBlock &MBB, - MachineBasicBlock::iterator &I) const { + MachineBasicBlock &MBB, + MachineInstr* MI) const { assert(getCallFrameSetupOpcode()== -1 && getCallFrameDestroyOpcode()== -1 && "eliminateCallFramePseudoInstr must be implemented if using" " call frame setup/destroy pseudo instructions!"); @@ -289,7 +290,7 @@ /// added to (negative if removed from) the basic block. /// virtual int eliminateFrameIndex(MachineFunction &MF, - MachineBasicBlock::iterator &II) const = 0; + MachineInstr* MI) const = 0; /// emitProlog/emitEpilog - These methods insert prolog and epilog code into /// the function. The return value is the number of instructions From alkis at cs.uiuc.edu Wed Feb 11 20:28:44 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Wed Feb 11 20:28:44 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PowerPCTargetMachine.cpp PowerPCRegisterInfo.h PowerPCRegisterInfo.cpp Message-ID: <200402120227.UAA03549@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PowerPCTargetMachine.cpp updated: 1.4 -> 1.5 PowerPCRegisterInfo.h updated: 1.1 -> 1.2 PowerPCRegisterInfo.cpp updated: 1.1 -> 1.2 --- Log message: Change MachineBasicBlock's vector of MachineInstr pointers into an ilist of MachineInstr objects. This allows constant time removal and insertion of MachineInstr instances from anywhere in each MachineBasicBlock. It also allows for constant time splicing of MachineInstrs into or out of MachineBasicBlocks. --- Diffs of the changes: (+26 -22) Index: llvm/lib/Target/PowerPC/PowerPCTargetMachine.cpp diff -u llvm/lib/Target/PowerPC/PowerPCTargetMachine.cpp:1.4 llvm/lib/Target/PowerPC/PowerPCTargetMachine.cpp:1.5 --- llvm/lib/Target/PowerPC/PowerPCTargetMachine.cpp:1.4 Mon Feb 2 13:06:36 2004 +++ llvm/lib/Target/PowerPC/PowerPCTargetMachine.cpp Wed Feb 11 20:27:10 2004 @@ -45,7 +45,6 @@ PM.add(createRegisterAllocator()); PM.add(createPrologEpilogCodeInserter()); // - PM.add(createMachineCodeDeleter()); return true; // change to `return false' when this actually works. } Index: llvm/lib/Target/PowerPC/PowerPCRegisterInfo.h diff -u llvm/lib/Target/PowerPC/PowerPCRegisterInfo.h:1.1 llvm/lib/Target/PowerPC/PowerPCRegisterInfo.h:1.2 --- llvm/lib/Target/PowerPC/PowerPCRegisterInfo.h:1.1 Wed Jan 21 15:13:19 2004 +++ llvm/lib/Target/PowerPC/PowerPCRegisterInfo.h Wed Feb 11 20:27:10 2004 @@ -27,25 +27,25 @@ /// Code Generation virtual methods... int storeRegToStackSlot(MachineBasicBlock &MBB, - MachineBasicBlock::iterator &MBBI, + MachineInstr* MBBI, unsigned SrcReg, int FrameIndex, const TargetRegisterClass *RC) const; int loadRegFromStackSlot(MachineBasicBlock &MBB, - MachineBasicBlock::iterator &MBBI, + MachineInstr* MBBI, unsigned DestReg, int FrameIndex, const TargetRegisterClass *RC) const; - int copyRegToReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI, + int copyRegToReg(MachineBasicBlock &MBB, MachineInstr* MBBI, unsigned DestReg, unsigned SrcReg, const TargetRegisterClass *RC) const; int eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, - MachineBasicBlock::iterator &I) const; + MachineInstr* I) const; int eliminateFrameIndex(MachineFunction &MF, - MachineBasicBlock::iterator &II) const; + MachineInstr* II) const; int processFunctionBeforeFrameFinalized(MachineFunction &MF) const; Index: llvm/lib/Target/PowerPC/PowerPCRegisterInfo.cpp diff -u llvm/lib/Target/PowerPC/PowerPCRegisterInfo.cpp:1.1 llvm/lib/Target/PowerPC/PowerPCRegisterInfo.cpp:1.2 --- llvm/lib/Target/PowerPC/PowerPCRegisterInfo.cpp:1.1 Wed Jan 21 15:13:19 2004 +++ llvm/lib/Target/PowerPC/PowerPCRegisterInfo.cpp Wed Feb 11 20:27:10 2004 @@ -21,45 +21,50 @@ : PowerPCGenRegisterInfo(PowerPC::ADJCALLSTACKDOWN, PowerPC::ADJCALLSTACKUP) {} -int PowerPCRegisterInfo::storeRegToStackSlot(MachineBasicBlock &MBB, - MachineBasicBlock::iterator &MBBI, - unsigned SrcReg, int FrameIdx, - const TargetRegisterClass *RC) const { +int PowerPCRegisterInfo::storeRegToStackSlot( + MachineBasicBlock &MBB, + MachineInstr* MBBI, + unsigned SrcReg, int FrameIdx, + const TargetRegisterClass *RC) const +{ abort(); return -1; } -int PowerPCRegisterInfo::loadRegFromStackSlot(MachineBasicBlock &MBB, - MachineBasicBlock::iterator &MBBI, - unsigned DestReg, int FrameIdx, - const TargetRegisterClass *RC) const{ +int PowerPCRegisterInfo::loadRegFromStackSlot( + MachineBasicBlock &MBB, + MachineInstr* MBBI, + unsigned DestReg, int FrameIdx, + const TargetRegisterClass *RC) const +{ abort(); return -1; } int PowerPCRegisterInfo::copyRegToReg(MachineBasicBlock &MBB, - MachineBasicBlock::iterator &MBBI, - unsigned DestReg, unsigned SrcReg, - const TargetRegisterClass *RC) const { + MachineInstr* MBBI, + unsigned DestReg, unsigned SrcReg, + const TargetRegisterClass *RC) const { abort(); return -1; } int PowerPCRegisterInfo::eliminateCallFramePseudoInstr(MachineFunction &MF, - MachineBasicBlock &MBB, - MachineBasicBlock::iterator &I) const { + MachineBasicBlock &MBB, + MachineInstr* I) const { abort(); return -1; } int PowerPCRegisterInfo::eliminateFrameIndex(MachineFunction &MF, - MachineBasicBlock::iterator &II) const { + MachineInstr* II) const { abort(); return -1; } -int PowerPCRegisterInfo::processFunctionBeforeFrameFinalized(MachineFunction &MF) - const { +int PowerPCRegisterInfo::processFunctionBeforeFrameFinalized( + MachineFunction &MF) const +{ abort(); return -1; } From alkis at cs.uiuc.edu Wed Feb 11 20:28:50 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Wed Feb 11 20:28:50 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/MachineInstr.h MachineFunction.h MachineBasicBlock.h Message-ID: <200402120227.UAA03601@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: MachineInstr.h updated: 1.127 -> 1.128 MachineFunction.h updated: 1.31 -> 1.32 MachineBasicBlock.h updated: 1.13 -> 1.14 --- Log message: Change MachineBasicBlock's vector of MachineInstr pointers into an ilist of MachineInstr objects. This allows constant time removal and insertion of MachineInstr instances from anywhere in each MachineBasicBlock. It also allows for constant time splicing of MachineInstrs into or out of MachineBasicBlocks. --- Diffs of the changes: (+36 -19) Index: llvm/include/llvm/CodeGen/MachineInstr.h diff -u llvm/include/llvm/CodeGen/MachineInstr.h:1.127 llvm/include/llvm/CodeGen/MachineInstr.h:1.128 --- llvm/include/llvm/CodeGen/MachineInstr.h:1.127 Wed Feb 11 19:34:03 2004 +++ llvm/include/llvm/CodeGen/MachineInstr.h Wed Feb 11 20:27:10 2004 @@ -28,6 +28,8 @@ class TargetMachine; class GlobalValue; +template class ilist_traits; + typedef int MachineOpCode; //===----------------------------------------------------------------------===// @@ -353,12 +355,24 @@ unsigned opCodeFlags; // flags modifying instrn behavior std::vector operands; // the operands unsigned numImplicitRefs; // number of implicit operands - + MachineInstr* prev, *next; // links for our intrusive list // OperandComplete - Return true if it's illegal to add a new operand bool OperandsComplete() const; MachineInstr(const MachineInstr &); // DO NOT IMPLEMENT void operator=(const MachineInstr&); // DO NOT IMPLEMENT + +private: + // Intrusive list support + // + friend class ilist_traits; + MachineInstr() { /* this is for ilist use only to create the sentinel */ } + MachineInstr* getPrev() const { return prev; } + MachineInstr* getNext() const { return next; } + + void setPrev(MachineInstr* mi) { prev = mi; } + void setNext(MachineInstr* mi) { next = mi; } + public: MachineInstr(int Opcode, unsigned numOperands); Index: llvm/include/llvm/CodeGen/MachineFunction.h diff -u llvm/include/llvm/CodeGen/MachineFunction.h:1.31 llvm/include/llvm/CodeGen/MachineFunction.h:1.32 --- llvm/include/llvm/CodeGen/MachineFunction.h:1.31 Sat Dec 20 04:18:58 2003 +++ llvm/include/llvm/CodeGen/MachineFunction.h Wed Feb 11 20:27:10 2004 @@ -20,7 +20,6 @@ #include "llvm/CodeGen/MachineBasicBlock.h" #include "Support/Annotation.h" -#include "Support/ilist" namespace llvm { Index: llvm/include/llvm/CodeGen/MachineBasicBlock.h diff -u llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.13 llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.14 --- llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.13 Tue Nov 11 16:41:31 2003 +++ llvm/include/llvm/CodeGen/MachineBasicBlock.h Wed Feb 11 20:27:10 2004 @@ -14,16 +14,17 @@ #ifndef LLVM_CODEGEN_MACHINEBASICBLOCK_H #define LLVM_CODEGEN_MACHINEBASICBLOCK_H -#include +#include "llvm/CodeGen/MachineInstr.h" +#include "Support/ilist" namespace llvm { class BasicBlock; -class MachineInstr; -template struct ilist_traits; class MachineBasicBlock { - std::vector Insts; +public: + typedef ilist Instructions; + Instructions Insts; MachineBasicBlock *Prev, *Next; const BasicBlock *BB; public: @@ -35,19 +36,27 @@ /// const BasicBlock *getBasicBlock() const { return BB; } - typedef std::vector::iterator iterator; - typedef std::vector::const_iterator const_iterator; + typedef ilist::iterator iterator; + typedef ilist::const_iterator const_iterator; typedef std::reverse_iterator const_reverse_iterator; typedef std::reverse_iterator reverse_iterator; unsigned size() const { return Insts.size(); } bool empty() const { return Insts.empty(); } - MachineInstr * operator[](unsigned i) const { return Insts[i]; } - MachineInstr *&operator[](unsigned i) { return Insts[i]; } + const MachineInstr& operator[](unsigned i) const { + const_iterator it = Insts.begin(); + std::advance(it, i); + return *it; + } + MachineInstr& operator[](unsigned i) { + iterator it = Insts.begin(); + std::advance(it, i); + return *it; + } - MachineInstr *front() const { return Insts.front(); } - MachineInstr *back() const { return Insts.back(); } + MachineInstr& front() { return Insts.front(); } + MachineInstr& back() { return Insts.back(); } iterator begin() { return Insts.begin(); } const_iterator begin() const { return Insts.begin(); } @@ -64,16 +73,11 @@ iterator insert(iterator I, MachineInstr *M) { return Insts.insert(I, M); } // erase - Remove the specified element or range from the instruction list. - // These functions do not delete any instructions removed. + // These functions delete any instructions removed. // iterator erase(iterator I) { return Insts.erase(I); } iterator erase(iterator I, iterator E) { return Insts.erase(I, E); } - - MachineInstr *pop_back() { - MachineInstr *R = back(); - Insts.pop_back(); - return R; - } + MachineInstr* remove(iterator &I) { return Insts.remove(I); } private: // Methods used to maintain doubly linked list of blocks... friend class ilist_traits; From alkis at cs.uiuc.edu Wed Feb 11 20:28:56 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Wed Feb 11 20:28:56 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/TwoAddressInstructionPass.cpp RegAllocSimple.cpp RegAllocLocal.cpp RegAllocLinearScan.cpp PrologEpilogInserter.cpp PHIElimination.cpp MachineFunction.cpp MachineCodeForInstruction.cpp LiveVariables.cpp LiveIntervals.cpp Message-ID: <200402120227.UAA03590@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: TwoAddressInstructionPass.cpp updated: 1.13 -> 1.14 RegAllocSimple.cpp updated: 1.48 -> 1.49 RegAllocLocal.cpp updated: 1.42 -> 1.43 RegAllocLinearScan.cpp updated: 1.44 -> 1.45 PrologEpilogInserter.cpp updated: 1.18 -> 1.19 PHIElimination.cpp updated: 1.15 -> 1.16 MachineFunction.cpp updated: 1.48 -> 1.49 MachineCodeForInstruction.cpp updated: 1.11 -> 1.12 LiveVariables.cpp updated: 1.22 -> 1.23 LiveIntervals.cpp updated: 1.47 -> 1.48 --- Log message: Change MachineBasicBlock's vector of MachineInstr pointers into an ilist of MachineInstr objects. This allows constant time removal and insertion of MachineInstr instances from anywhere in each MachineBasicBlock. It also allows for constant time splicing of MachineInstrs into or out of MachineBasicBlocks. --- Diffs of the changes: (+91 -125) Index: llvm/lib/CodeGen/TwoAddressInstructionPass.cpp diff -u llvm/lib/CodeGen/TwoAddressInstructionPass.cpp:1.13 llvm/lib/CodeGen/TwoAddressInstructionPass.cpp:1.14 --- llvm/lib/CodeGen/TwoAddressInstructionPass.cpp:1.13 Wed Feb 4 23:04:39 2004 +++ llvm/lib/CodeGen/TwoAddressInstructionPass.cpp Wed Feb 11 20:27:10 2004 @@ -84,9 +84,8 @@ for (MachineFunction::iterator mbbi = MF.begin(), mbbe = MF.end(); mbbi != mbbe; ++mbbi) { - for (MachineBasicBlock::iterator mii = mbbi->begin(); - mii != mbbi->end(); ++mii) { - MachineInstr* mi = *mii; + for (MachineBasicBlock::iterator mi = mbbi->begin(), me = mbbi->end(); + mi != me; ++mi) { unsigned opcode = mi->getOpcode(); // ignore if it is not a two-address instruction @@ -132,10 +131,11 @@ const TargetRegisterClass* rc = MF.getSSARegMap()->getRegClass(regA); - unsigned Added = MRI.copyRegToReg(*mbbi, mii, regA, regB, rc); + unsigned Added = MRI.copyRegToReg(*mbbi, mi, regA, regB, rc); numInstrsAdded += Added; - MachineInstr* prevMi = *(mii - 1); + MachineBasicBlock::iterator prevMi = mi; + --prevMi; DEBUG(std::cerr << "\t\tadded instruction: "; prevMi->print(std::cerr, TM)); Index: llvm/lib/CodeGen/RegAllocSimple.cpp diff -u llvm/lib/CodeGen/RegAllocSimple.cpp:1.48 llvm/lib/CodeGen/RegAllocSimple.cpp:1.49 --- llvm/lib/CodeGen/RegAllocSimple.cpp:1.48 Tue Feb 10 15:12:22 2004 +++ llvm/lib/CodeGen/RegAllocSimple.cpp Wed Feb 11 20:27:10 2004 @@ -150,12 +150,10 @@ void RegAllocSimple::AllocateBasicBlock(MachineBasicBlock &MBB) { // loop over each instruction - for (MachineBasicBlock::iterator I = MBB.begin(); I != MBB.end(); ++I) { + for (MachineBasicBlock::iterator MI = MBB.begin(); MI != MBB.end(); ++MI) { // Made to combat the incorrect allocation of r2 = add r1, r1 std::map Virt2PhysRegMap; - MachineInstr *MI = *I; - RegsUsed.resize(MRegisterInfo::FirstVirtualRegister); // a preliminary pass that will invalidate any registers that @@ -197,11 +195,11 @@ } else { physReg = getFreeReg(virtualReg); } - ++I; - spillVirtReg(MBB, I, virtualReg, physReg); - --I; + ++MI; + spillVirtReg(MBB, MI, virtualReg, physReg); + --MI; } else { - physReg = reloadVirtReg(MBB, I, virtualReg); + physReg = reloadVirtReg(MBB, MI, virtualReg); Virt2PhysRegMap[virtualReg] = physReg; } } Index: llvm/lib/CodeGen/RegAllocLocal.cpp diff -u llvm/lib/CodeGen/RegAllocLocal.cpp:1.42 llvm/lib/CodeGen/RegAllocLocal.cpp:1.43 --- llvm/lib/CodeGen/RegAllocLocal.cpp:1.42 Tue Feb 10 15:12:22 2004 +++ llvm/lib/CodeGen/RegAllocLocal.cpp Wed Feb 11 20:27:10 2004 @@ -496,9 +496,8 @@ void RA::AllocateBasicBlock(MachineBasicBlock &MBB) { // loop over each instruction - MachineBasicBlock::iterator I = MBB.begin(); - for (; I != MBB.end(); ++I) { - MachineInstr *MI = *I; + MachineBasicBlock::iterator MI = MBB.begin(); + for (; MI != MBB.end(); ++MI) { const TargetInstrDescriptor &TID = TM->getInstrInfo().get(MI->getOpcode()); DEBUG(std::cerr << "\nStarting RegAlloc of: " << *MI; std::cerr << " Regs have values: "; @@ -525,7 +524,7 @@ !MI->getOperand(i).isDef() && MI->getOperand(i).isRegister() && MRegisterInfo::isVirtualRegister(MI->getOperand(i).getReg())) { unsigned VirtSrcReg = MI->getOperand(i).getAllocatedRegNum(); - unsigned PhysSrcReg = reloadVirtReg(MBB, I, VirtSrcReg); + unsigned PhysSrcReg = reloadVirtReg(MBB, MI, VirtSrcReg); MI->SetMachineOperandReg(i, PhysSrcReg); // Assign the input register } @@ -559,7 +558,7 @@ if (MI->getOperand(i).isDef() && MI->getOperand(i).isRegister() && MRegisterInfo::isPhysicalRegister(MI->getOperand(i).getReg())) { unsigned Reg = MI->getOperand(i).getAllocatedRegNum(); - spillPhysReg(MBB, I, Reg, true); // Spill any existing value in the reg + spillPhysReg(MBB, MI, Reg, true); // Spill any existing value in the reg PhysRegsUsed[Reg] = 0; // It is free and reserved now PhysRegsUseOrder.push_back(Reg); for (const unsigned *AliasSet = RegInfo->getAliasSet(Reg); @@ -573,7 +572,7 @@ for (const unsigned *ImplicitDefs = TID.ImplicitDefs; *ImplicitDefs; ++ImplicitDefs) { unsigned Reg = *ImplicitDefs; - spillPhysReg(MBB, I, Reg); + spillPhysReg(MBB, MI, Reg); PhysRegsUseOrder.push_back(Reg); PhysRegsUsed[Reg] = 0; // It is free and reserved now for (const unsigned *AliasSet = RegInfo->getAliasSet(Reg); @@ -596,7 +595,7 @@ // If DestVirtReg already has a value, use it. if (!(DestPhysReg = getOrInsertVirt2PhysRegMapSlot(DestVirtReg))) - DestPhysReg = getReg(MBB, I, DestVirtReg); + DestPhysReg = getReg(MBB, MI, DestVirtReg); markVirtRegModified(DestVirtReg); MI->SetMachineOperandReg(i, DestPhysReg); // Assign the output register } @@ -628,15 +627,15 @@ // Rewind the iterator to point to the first flow control instruction... const TargetInstrInfo &TII = TM->getInstrInfo(); - I = MBB.end(); - while (I != MBB.begin() && TII.isTerminatorInstr((*(I-1))->getOpcode())) - --I; + MI = MBB.end(); + while (MI != MBB.begin() && TII.isTerminatorInstr((--MI)->getOpcode())); + ++MI; // Spill all physical registers holding virtual registers now. for (unsigned i = 0, e = RegInfo->getNumRegs(); i != e; ++i) if (PhysRegsUsed[i] != -1) if (unsigned VirtReg = PhysRegsUsed[i]) - spillVirtReg(MBB, I, VirtReg, i); + spillVirtReg(MBB, MI, VirtReg, i); else removePhysReg(i); Index: llvm/lib/CodeGen/RegAllocLinearScan.cpp diff -u llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.44 llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.45 --- llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.44 Tue Feb 10 15:12:22 2004 +++ llvm/lib/CodeGen/RegAllocLinearScan.cpp Wed Feb 11 20:27:10 2004 @@ -396,15 +396,15 @@ for (currentInstr_ = currentMbb_->begin(); currentInstr_ != currentMbb_->end(); ) { DEBUG(std::cerr << "\tinstruction: "; - (*currentInstr_)->print(std::cerr, *tm_);); + currentInstr_->print(std::cerr, *tm_);); // use our current mapping and actually replace and // virtual register with its allocated physical registers DEBUG(std::cerr << "\t\treplacing virtual registers with mapped " "physical registers:\n"); - for (unsigned i = 0, e = (*currentInstr_)->getNumOperands(); + for (unsigned i = 0, e = currentInstr_->getNumOperands(); i != e; ++i) { - MachineOperand& op = (*currentInstr_)->getOperand(i); + MachineOperand& op = currentInstr_->getOperand(i); if (op.isRegister() && MRegisterInfo::isVirtualRegister(op.getReg())) { unsigned virtReg = op.getReg(); @@ -412,20 +412,19 @@ if (it != v2pMap_.end()) { DEBUG(std::cerr << "\t\t\t%reg" << it->first << " -> " << mri_->getName(it->second) << '\n'); - (*currentInstr_)->SetMachineOperandReg(i, it->second); + currentInstr_->SetMachineOperandReg(i, it->second); } } } unsigned srcReg, dstReg; - if (tii.isMoveInstr(**currentInstr_, srcReg, dstReg) && + if (tii.isMoveInstr(*currentInstr_, srcReg, dstReg) && ((MRegisterInfo::isPhysicalRegister(srcReg) && MRegisterInfo::isPhysicalRegister(dstReg) && srcReg == dstReg) || (MRegisterInfo::isVirtualRegister(srcReg) && MRegisterInfo::isVirtualRegister(dstReg) && v2ssMap_[srcReg] == v2ssMap_[dstReg]))) { - delete *currentInstr_; currentInstr_ = currentMbb_->erase(currentInstr_); ++numPeep; DEBUG(std::cerr << "\t\tdeleting instruction\n"); @@ -436,12 +435,12 @@ Regs toClear; Regs toSpill; - const unsigned numOperands = (*currentInstr_)->getNumOperands(); + const unsigned numOperands = currentInstr_->getNumOperands(); DEBUG(std::cerr << "\t\tloading temporarily used operands to " "registers:\n"); for (unsigned i = 0; i != numOperands; ++i) { - MachineOperand& op = (*currentInstr_)->getOperand(i); + MachineOperand& op = currentInstr_->getOperand(i); if (op.isRegister() && op.isUse() && MRegisterInfo::isVirtualRegister(op.getReg())) { unsigned virtReg = op.getAllocatedRegNum(); @@ -460,7 +459,7 @@ else toClear.push_back(it); } - (*currentInstr_)->SetMachineOperandReg(i, physReg); + currentInstr_->SetMachineOperandReg(i, physReg); } } @@ -472,7 +471,7 @@ DEBUG(std::cerr << "\t\tassigning temporarily defined operands to " "registers:\n"); for (unsigned i = 0; i != numOperands; ++i) { - MachineOperand& op = (*currentInstr_)->getOperand(i); + MachineOperand& op = currentInstr_->getOperand(i); if (op.isRegister() && MRegisterInfo::isVirtualRegister(op.getReg())) { assert(!op.isUse() && "we should not have uses here!"); @@ -489,7 +488,7 @@ // this instruction toSpill.push_back(it); } - (*currentInstr_)->SetMachineOperandReg(i, physReg); + currentInstr_->SetMachineOperandReg(i, physReg); } } ++currentInstr_; // spills will go after this instruction Index: llvm/lib/CodeGen/PrologEpilogInserter.cpp diff -u llvm/lib/CodeGen/PrologEpilogInserter.cpp:1.18 llvm/lib/CodeGen/PrologEpilogInserter.cpp:1.19 --- llvm/lib/CodeGen/PrologEpilogInserter.cpp:1.18 Tue Feb 10 15:12:22 2004 +++ llvm/lib/CodeGen/PrologEpilogInserter.cpp Wed Feb 11 20:27:10 2004 @@ -105,17 +105,17 @@ for (MachineFunction::iterator BB = Fn.begin(), E = Fn.end(); BB != E; ++BB) for (MachineBasicBlock::iterator I = BB->begin(); I != BB->end(); ) - if ((*I)->getOpcode() == FrameSetupOpcode || - (*I)->getOpcode() == FrameDestroyOpcode) { - assert((*I)->getNumOperands() == 1 && "Call Frame Setup/Destroy Pseudo" + if (I->getOpcode() == FrameSetupOpcode || + I->getOpcode() == FrameDestroyOpcode) { + assert(I->getNumOperands() == 1 && "Call Frame Setup/Destroy Pseudo" " instructions should have a single immediate argument!"); - unsigned Size = (*I)->getOperand(0).getImmedValue(); + unsigned Size = I->getOperand(0).getImmedValue(); if (Size > MaxCallFrameSize) MaxCallFrameSize = Size; HasCalls = true; - RegInfo->eliminateCallFramePseudoInstr(Fn, *BB, I); + RegInfo->eliminateCallFramePseudoInstr(Fn, *BB, I++); } else { - for (unsigned i = 0, e = (*I)->getNumOperands(); i != e; ++i) { - MachineOperand &MO = (*I)->getOperand(i); + for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) { + MachineOperand &MO = I->getOperand(i); if (MO.isRegister() && MO.isDef()) { assert(MRegisterInfo::isPhysicalRegister(MO.getReg()) && "Register allocation must be performed!"); @@ -174,8 +174,9 @@ const TargetInstrInfo &TII = Fn.getTarget().getInstrInfo(); for (MachineFunction::iterator FI = Fn.begin(), E = Fn.end(); FI != E; ++FI) { // If last instruction is a return instruction, add an epilogue - if (!FI->empty() && TII.isReturn(FI->back()->getOpcode())) { - MBB = FI; I = MBB->end()-1; + if (!FI->empty() && TII.isReturn(FI->back().getOpcode())) { + MBB = FI; + I = MBB->end(); --I; for (unsigned i = 0, e = RegsToSave.size(); i != e; ++i) { const TargetRegisterClass *RC = RegInfo->getRegClass(RegsToSave[i]); @@ -235,7 +236,7 @@ const TargetInstrInfo &TII = Fn.getTarget().getInstrInfo(); for (MachineFunction::iterator I = Fn.begin(), E = Fn.end(); I != E; ++I) { // If last instruction is a return instruction, add an epilogue - if (!I->empty() && TII.isReturn(I->back()->getOpcode())) + if (!I->empty() && TII.isReturn(I->back().getOpcode())) Fn.getTarget().getRegisterInfo()->emitEpilogue(Fn, *I); } } @@ -253,8 +254,8 @@ for (MachineFunction::iterator BB = Fn.begin(), E = Fn.end(); BB != E; ++BB) for (MachineBasicBlock::iterator I = BB->begin(); I != BB->end(); ++I) - for (unsigned i = 0, e = (*I)->getNumOperands(); i != e; ++i) - if ((*I)->getOperand(i).isFrameIndex()) { + for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) + if (I->getOperand(i).isFrameIndex()) { // If this instruction has a FrameIndex operand, we need to use that // target machine register info object to eliminate it. MRI.eliminateFrameIndex(Fn, I); Index: llvm/lib/CodeGen/PHIElimination.cpp diff -u llvm/lib/CodeGen/PHIElimination.cpp:1.15 llvm/lib/CodeGen/PHIElimination.cpp:1.16 --- llvm/lib/CodeGen/PHIElimination.cpp:1.15 Tue Feb 10 15:12:22 2004 +++ llvm/lib/CodeGen/PHIElimination.cpp Wed Feb 11 20:27:10 2004 @@ -61,18 +61,18 @@ /// predecessor basic blocks. /// bool PNE::EliminatePHINodes(MachineFunction &MF, MachineBasicBlock &MBB) { - if (MBB.empty() || MBB.front()->getOpcode() != TargetInstrInfo::PHI) + if (MBB.empty() || MBB.front().getOpcode() != TargetInstrInfo::PHI) return false; // Quick exit for normal case... LiveVariables *LV = getAnalysisToUpdate(); const TargetInstrInfo &MII = MF.getTarget().getInstrInfo(); const MRegisterInfo *RegInfo = MF.getTarget().getRegisterInfo(); - while (MBB.front()->getOpcode() == TargetInstrInfo::PHI) { - MachineInstr *MI = MBB.front(); + while (MBB.front().getOpcode() == TargetInstrInfo::PHI) { // Unlink the PHI node from the basic block... but don't delete the PHI yet - MBB.erase(MBB.begin()); - + MachineBasicBlock::iterator begin = MBB.begin(); + MachineInstr *MI = MBB.remove(begin); + assert(MRegisterInfo::isVirtualRegister(MI->getOperand(0).getReg()) && "PHI node doesn't write virt reg?"); @@ -88,13 +88,13 @@ // MachineBasicBlock::iterator AfterPHIsIt = MBB.begin(); while (AfterPHIsIt != MBB.end() && - (*AfterPHIsIt)->getOpcode() == TargetInstrInfo::PHI) + AfterPHIsIt->getOpcode() == TargetInstrInfo::PHI) ++AfterPHIsIt; // Skip over all of the PHI nodes... RegInfo->copyRegToReg(MBB, AfterPHIsIt, DestReg, IncomingReg, RC); // Update live variable information if there is any... if (LV) { - MachineInstr *PHICopy = *(AfterPHIsIt-1); + MachineInstr *PHICopy = --AfterPHIsIt; // Add information to LiveVariables to know that the incoming value is // killed. Note that because the value is defined in several places (once @@ -149,13 +149,13 @@ if (I != opBlock.begin()) { // Handle empty blocks --I; // must backtrack over ALL the branches in the previous block - while (MII.isTerminatorInstr((*I)->getOpcode()) && + while (MII.isTerminatorInstr(I->getOpcode()) && I != opBlock.begin()) --I; // move back to the first branch instruction so new instructions // are inserted right in front of it and not in front of a non-branch - if (!MII.isTerminatorInstr((*I)->getOpcode())) + if (!MII.isTerminatorInstr(I->getOpcode())) ++I; } @@ -171,7 +171,8 @@ bool HaveNotEmitted = true; if (I != opBlock.begin()) { - MachineInstr *PrevInst = *(I-1); + MachineBasicBlock::iterator PrevInst = I; + --PrevInst; for (unsigned i = 0, e = PrevInst->getNumOperands(); i != e; ++i) { MachineOperand &MO = PrevInst->getOperand(i); if (MO.isRegister() && MO.getReg() == IncomingReg) @@ -238,10 +239,10 @@ // Loop over all of the PHIs in this successor, checking to see if // the register is being used... for (MachineBasicBlock::iterator BBI = MBB->begin(), E=MBB->end(); - BBI != E && (*BBI)->getOpcode() == TargetInstrInfo::PHI; + BBI != E && BBI->getOpcode() == TargetInstrInfo::PHI; ++BBI) - for (unsigned i = 1, e = (*BBI)->getNumOperands(); i < e; i += 2) - if ((*BBI)->getOperand(i).getReg() == SrcReg) { + for (unsigned i = 1, e = BBI->getNumOperands(); i < e; i += 2) + if (BBI->getOperand(i).getReg() == SrcReg) { ValueIsLive = true; break; } @@ -251,8 +252,11 @@ // we can add a kill marker to the copy we inserted saying that it // kills the incoming value! // - if (!ValueIsLive) - LV->addVirtualRegisterKilled(SrcReg, &opBlock, *(I-1)); + if (!ValueIsLive) { + MachineBasicBlock::iterator Prev = I; + --Prev; + LV->addVirtualRegisterKilled(SrcReg, &opBlock, Prev); + } } } } @@ -260,7 +264,6 @@ // really delete the PHI instruction now! delete MI; } - return true; } Index: llvm/lib/CodeGen/MachineFunction.cpp diff -u llvm/lib/CodeGen/MachineFunction.cpp:1.48 llvm/lib/CodeGen/MachineFunction.cpp:1.49 --- llvm/lib/CodeGen/MachineFunction.cpp:1.48 Sat Jan 31 23:25:07 2004 +++ llvm/lib/CodeGen/MachineFunction.cpp Wed Feb 11 20:27:10 2004 @@ -62,34 +62,6 @@ return new Printer(OS, Banner); } -namespace { - struct Deleter : public MachineFunctionPass { - const char *getPassName() const { return "Machine Code Deleter"; } - - bool runOnMachineFunction(MachineFunction &MF) { - // Delete all of the MachineInstrs out of the function. When the sparc - // backend gets fixed, this can be dramatically simpler, but actually - // putting this stuff into the MachineBasicBlock destructor! - for (MachineFunction::iterator BB = MF.begin(), E = MF.end(); BB != E; - ++BB) - while (!BB->empty()) - delete BB->pop_back(); - - // Delete the annotation from the function now. - MachineFunction::destruct(MF.getFunction()); - return true; - } - }; -} - -/// MachineCodeDeletion Pass - This pass deletes all of the machine code for -/// the current function, which should happen after the function has been -/// emitted to a .s file or to memory. -FunctionPass *llvm::createMachineCodeDeleter() { - return new Deleter(); -} - - //===---------------------------------------------------------------------===// // MachineFunction implementation //===---------------------------------------------------------------------===// @@ -127,7 +99,7 @@ OS << "\n" << LBB->getName() << " (" << (const void*)LBB << "):\n"; for (MachineBasicBlock::const_iterator I = BB->begin(); I != BB->end();++I){ OS << "\t"; - (*I)->print(OS, Target); + I->print(OS, Target); } } OS << "\nEnd function \"" << Fn->getName() << "\"\n\n"; Index: llvm/lib/CodeGen/MachineCodeForInstruction.cpp diff -u llvm/lib/CodeGen/MachineCodeForInstruction.cpp:1.11 llvm/lib/CodeGen/MachineCodeForInstruction.cpp:1.12 --- llvm/lib/CodeGen/MachineCodeForInstruction.cpp:1.11 Sat Jan 10 13:16:26 2004 +++ llvm/lib/CodeGen/MachineCodeForInstruction.cpp Wed Feb 11 20:27:10 2004 @@ -60,9 +60,8 @@ for (unsigned i=0, N=tempVec.size(); i < N; i++) delete tempVec[i]; - // Free the MachineInstr objects allocated, if any. - for (unsigned i=0, N = size(); i < N; i++) - delete (*this)[i]; + // do not free the MachineInstr objects allocated. they are managed + // by the ilist in MachineBasicBlock // Free the CallArgsDescriptor if it exists. delete callArgsDesc; Index: llvm/lib/CodeGen/LiveVariables.cpp diff -u llvm/lib/CodeGen/LiveVariables.cpp:1.22 llvm/lib/CodeGen/LiveVariables.cpp:1.23 --- llvm/lib/CodeGen/LiveVariables.cpp:1.22 Tue Feb 10 15:18:55 2004 +++ llvm/lib/CodeGen/LiveVariables.cpp Wed Feb 11 20:27:10 2004 @@ -213,7 +213,7 @@ // Loop over all of the instructions, processing them. for (MachineBasicBlock::iterator I = MBB->begin(), E = MBB->end(); I != E; ++I) { - MachineInstr *MI = *I; + MachineInstr *MI = I; const TargetInstrDescriptor &MID = TII.get(MI->getOpcode()); // Process all of the operands of the instruction... @@ -275,9 +275,8 @@ MachineBasicBlock *Succ = BBMap.find(*SI)->second.first; // PHI nodes are guaranteed to be at the top of the block... - for (MachineBasicBlock::iterator I = Succ->begin(), E = Succ->end(); - I != E && (*I)->getOpcode() == TargetInstrInfo::PHI; ++I) { - MachineInstr *MI = *I; + for (MachineBasicBlock::iterator MI = Succ->begin(), ME = Succ->end(); + MI != ME && MI->getOpcode() == TargetInstrInfo::PHI; ++MI) { for (unsigned i = 1; ; i += 2) if (MI->getOperand(i+1).getMachineBasicBlock() == MBB) { MachineOperand &MO = MI->getOperand(i); Index: llvm/lib/CodeGen/LiveIntervals.cpp diff -u llvm/lib/CodeGen/LiveIntervals.cpp:1.47 llvm/lib/CodeGen/LiveIntervals.cpp:1.48 --- llvm/lib/CodeGen/LiveIntervals.cpp:1.47 Tue Feb 10 15:12:22 2004 +++ llvm/lib/CodeGen/LiveIntervals.cpp Wed Feb 11 20:27:10 2004 @@ -92,7 +92,7 @@ for (MachineBasicBlock::iterator mi = mbb->begin(), miEnd = mbb->end(); mi != miEnd; ++mi) { - inserted = mi2iMap_.insert(std::make_pair(*mi, miIndex)).second; + inserted = mi2iMap_.insert(std::make_pair(mi, miIndex)).second; assert(inserted && "multiple MachineInstr -> index mappings"); miIndex += 2; } @@ -109,12 +109,10 @@ const MachineBasicBlock* mbb = mbbi; unsigned loopDepth = loopInfo.getLoopDepth(mbb->getBasicBlock()); - for (MachineBasicBlock::const_iterator mii = mbb->begin(), - mie = mbb->end(); mii != mie; ++mii) { - MachineInstr* mi = *mii; - + for (MachineBasicBlock::const_iterator mi = mbb->begin(), + mie = mbb->end(); mi != mie; ++mi) { for (int i = mi->getNumOperands() - 1; i >= 0; --i) { - MachineOperand& mop = mi->getOperand(i); + const MachineOperand& mop = mi->getOperand(i); if (mop.isRegister() && MRegisterInfo::isVirtualRegister(mop.getReg())) { unsigned reg = mop.getAllocatedRegNum(); @@ -169,8 +167,8 @@ if (vi.AliveBlocks[i]) { MachineBasicBlock* mbb = lv_->getIndexMachineBasicBlock(i); if (!mbb->empty()) { - interval->addRange(getInstructionIndex(mbb->front()), - getInstructionIndex(mbb->back()) + 1); + interval->addRange(getInstructionIndex(&mbb->front()), + getInstructionIndex(&mbb->back()) + 1); } } } @@ -181,7 +179,7 @@ // we consider defs to happen at the second time slot of the // instruction - unsigned instrIndex = getInstructionIndex(*mi) + 1; + unsigned instrIndex = getInstructionIndex(mi) + 1; bool killedInDefiningBasicBlock = false; for (int i = 0, e = vi.Kills.size(); i != e; ++i) { @@ -189,8 +187,8 @@ MachineInstr* killerInstr = vi.Kills[i].second; unsigned start = (mbb == killerBlock ? instrIndex : - getInstructionIndex(killerBlock->front())); - unsigned end = (killerInstr == *mi ? + getInstructionIndex(&killerBlock->front())); + unsigned end = (killerInstr == mi ? instrIndex + 1 : // dead getInstructionIndex(killerInstr) + 1); // killed // we do not want to add invalid ranges. these can happen when @@ -204,7 +202,7 @@ } if (!killedInDefiningBasicBlock) { - unsigned end = getInstructionIndex(mbb->back()) + 1; + unsigned end = getInstructionIndex(&mbb->back()) + 1; interval->addRange(instrIndex, end); } } @@ -221,10 +219,10 @@ // we consider defs to happen at the second time slot of the // instruction unsigned start, end; - start = end = getInstructionIndex(*mi) + 1; + start = end = getInstructionIndex(mi) + 1; // a variable can be dead by the instruction defining it - for (KillIter ki = lv_->dead_begin(*mi), ke = lv_->dead_end(*mi); + for (KillIter ki = lv_->dead_begin(mi), ke = lv_->dead_end(mi); ki != ke; ++ki) { if (reg == ki->second) { DEBUG(std::cerr << " dead\n"); @@ -237,7 +235,7 @@ do { ++mi; end += 2; - for (KillIter ki = lv_->killed_begin(*mi), ke = lv_->killed_end(*mi); + for (KillIter ki = lv_->killed_begin(mi), ke = lv_->killed_end(mi); ki != ke; ++ki) { if (reg == ki->second) { DEBUG(std::cerr << " killed\n"); @@ -301,19 +299,18 @@ for (MachineBasicBlock::iterator mi = mbb->begin(), miEnd = mbb->end(); mi != miEnd; ++mi) { - MachineInstr* instr = *mi; const TargetInstrDescriptor& tid = - tm_->getInstrInfo().get(instr->getOpcode()); - DEBUG(std::cerr << "\t[" << getInstructionIndex(instr) << "] "; - instr->print(std::cerr, *tm_);); + tm_->getInstrInfo().get(mi->getOpcode()); + DEBUG(std::cerr << "\t[" << getInstructionIndex(mi) << "] "; + mi->print(std::cerr, *tm_);); // handle implicit defs for (const unsigned* id = tid.ImplicitDefs; *id; ++id) handleRegisterDef(mbb, mi, *id); // handle explicit defs - for (int i = instr->getNumOperands() - 1; i >= 0; --i) { - MachineOperand& mop = instr->getOperand(i); + for (int i = mi->getNumOperands() - 1; i >= 0; --i) { + MachineOperand& mop = mi->getOperand(i); // handle register defs - build intervals if (mop.isRegister() && mop.isDef()) handleRegisterDef(mbb, mi, mop.getAllocatedRegNum()); @@ -336,15 +333,14 @@ const TargetInstrInfo& tii = tm_->getInstrInfo(); - for (MachineFunction::const_iterator mbbi = mf_->begin(), - mbbe = mf_->end(); mbbi != mbbe; ++mbbi) { - const MachineBasicBlock* mbb = mbbi; + for (MachineFunction::iterator mbbi = mf_->begin(), mbbe = mf_->end(); + mbbi != mbbe; ++mbbi) { + MachineBasicBlock* mbb = mbbi; DEBUG(std::cerr << "machine basic block: " << mbb->getBasicBlock()->getName() << "\n"); - for (MachineBasicBlock::const_iterator mii = mbb->begin(), - mie = mbb->end(); mii != mie; ++mii) { - MachineInstr* mi = *mii; + for (MachineBasicBlock::iterator mi = mbb->begin(), mie = mbb->end(); + mi != mie; ++mi) { const TargetInstrDescriptor& tid = tm_->getInstrInfo().get(mi->getOpcode()); DEBUG(std::cerr << "\t\tinstruction[" From gaeke at cs.uiuc.edu Wed Feb 11 22:02:02 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed Feb 11 22:02:02 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/MachineInstr.h Message-ID: <200402120401.WAA05859@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: MachineInstr.h updated: 1.128 -> 1.129 --- Log message: Remove these MachineOpCodeFlags and their accessor - they are never set. --- Diffs of the changes: (+1 -13) Index: llvm/include/llvm/CodeGen/MachineInstr.h diff -u llvm/include/llvm/CodeGen/MachineInstr.h:1.128 llvm/include/llvm/CodeGen/MachineInstr.h:1.129 --- llvm/include/llvm/CodeGen/MachineInstr.h:1.128 Wed Feb 11 20:27:10 2004 +++ llvm/include/llvm/CodeGen/MachineInstr.h Wed Feb 11 22:00:55 2004 @@ -33,17 +33,6 @@ typedef int MachineOpCode; //===----------------------------------------------------------------------===// -/// Special flags on instructions that modify the opcode. -/// These flags are unused for now, but having them enforces that some -/// changes will be needed if they are used. -/// -enum MachineOpCodeFlags { - AnnulFlag, /// 1 if annul bit is set on a branch - PredTakenFlag, /// 1 if branch should be predicted taken - PredNotTakenFlag /// 1 if branch should be predicted not taken -}; - -//===----------------------------------------------------------------------===// /// MOTy - MachineOperandType - This namespace contains an enum that describes /// how the machine operand is used by the instruction: is it read, defined, or /// both? Note that the MachineInstr/Operator class currently uses bool @@ -389,10 +378,9 @@ /// MachineInstr(MachineBasicBlock *MBB, int Opcode, unsigned numOps); - /// Accessors for opcode and associated flags. + /// Accessors for opcode. /// const int getOpcode() const { return opCode; } - unsigned getOpCodeFlags() const { return opCodeFlags; } /// Access to explicit operands of the instruction. /// From gaeke at cs.uiuc.edu Wed Feb 11 22:02:08 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed Feb 11 22:02:08 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/RegAlloc/PhyRegAlloc.cpp Message-ID: <200402120401.WAA05899@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/Sparc/RegAlloc: PhyRegAlloc.cpp updated: 1.134 -> 1.135 --- Log message: Remove this MachineOpCodeFlags assertion - its test can never be false. --- Diffs of the changes: (+0 -2) Index: llvm/lib/Target/Sparc/RegAlloc/PhyRegAlloc.cpp diff -u llvm/lib/Target/Sparc/RegAlloc/PhyRegAlloc.cpp:1.134 llvm/lib/Target/Sparc/RegAlloc/PhyRegAlloc.cpp:1.135 --- llvm/lib/Target/Sparc/RegAlloc/PhyRegAlloc.cpp:1.134 Wed Feb 11 20:27:09 2004 +++ llvm/lib/Target/Sparc/RegAlloc/PhyRegAlloc.cpp Wed Feb 11 22:01:07 2004 @@ -530,8 +530,6 @@ AddedInstrMap[DelaySlotMI].InstrnsAfter.size() > 0)); if (cond1 || cond2) { - assert((MII->getOpCodeFlags() & AnnulFlag) == 0 && - "FIXME: Moving an annulled delay slot instruction!"); assert(delaySlots==1 && "InsertBefore does not yet handle >1 delay slots!"); From gaeke at cs.uiuc.edu Wed Feb 11 22:16:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed Feb 11 22:16:01 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/MachineInstr.h Message-ID: <200402120415.WAA06079@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: MachineInstr.h updated: 1.129 -> 1.130 --- Log message: Express one of MachineOperand's many constructors in terms of another, by means of default arguments. --- Diffs of the changes: (+1 -7) Index: llvm/include/llvm/CodeGen/MachineInstr.h diff -u llvm/include/llvm/CodeGen/MachineInstr.h:1.129 llvm/include/llvm/CodeGen/MachineInstr.h:1.130 --- llvm/include/llvm/CodeGen/MachineInstr.h:1.129 Wed Feb 11 22:00:55 2004 +++ llvm/include/llvm/CodeGen/MachineInstr.h Wed Feb 11 22:15:00 2004 @@ -129,13 +129,7 @@ int regNum; // register number for an explicit register // will be set for a value after reg allocation private: - MachineOperand() - : immedVal(0), - flags(0), - opType(MO_VirtualRegister), - regNum(-1) {} - - MachineOperand(int64_t ImmVal, MachineOperandType OpTy) + MachineOperand(int64_t ImmVal = 0, MachineOperandType OpTy = MO_VirtualRegister) : immedVal(ImmVal), flags(0), opType(OpTy), From gaeke at cs.uiuc.edu Wed Feb 11 22:27:02 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed Feb 11 22:27:02 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/MachineInstr.h Message-ID: <200402120426.WAA06310@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: MachineInstr.h updated: 1.130 -> 1.131 --- Log message: Add one more doxygen comment. --- Diffs of the changes: (+2 -4) Index: llvm/include/llvm/CodeGen/MachineInstr.h diff -u llvm/include/llvm/CodeGen/MachineInstr.h:1.130 llvm/include/llvm/CodeGen/MachineInstr.h:1.131 --- llvm/include/llvm/CodeGen/MachineInstr.h:1.130 Wed Feb 11 22:15:00 2004 +++ llvm/include/llvm/CodeGen/MachineInstr.h Wed Feb 11 22:26:49 2004 @@ -192,9 +192,8 @@ return *this; } - // Accessor methods. Caller is responsible for checking the - // operand type before invoking the corresponding accessor. - // + /// getType - Returns the MachineOperandType for this operand. + /// MachineOperandType getType() const { return opType; } /// isPCRelative - This returns the value of the PCRELATIVE flag, which @@ -203,7 +202,6 @@ /// MachineBasicBlock, GlobalAddress, ExternalSymbol /// bool isPCRelative() const { return (flags & PCRELATIVE) != 0; } - /// isRegister - Return true if this operand is a register operand. The X86 /// backend currently can't decide whether to use MO_MR or MO_VR to represent From alkis at cs.uiuc.edu Thu Feb 12 02:12:01 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Thu Feb 12 02:12:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PowerPCRegisterInfo.h PowerPCRegisterInfo.cpp Message-ID: <200402120811.CAA25963@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PowerPCRegisterInfo.h updated: 1.2 -> 1.3 PowerPCRegisterInfo.cpp updated: 1.2 -> 1.3 --- Log message: Change interface so that we can add to the end of a basic block without getting an assertion from ilist that we are dereferencing ilist::end(). --- Diffs of the changes: (+10 -10) Index: llvm/lib/Target/PowerPC/PowerPCRegisterInfo.h diff -u llvm/lib/Target/PowerPC/PowerPCRegisterInfo.h:1.2 llvm/lib/Target/PowerPC/PowerPCRegisterInfo.h:1.3 --- llvm/lib/Target/PowerPC/PowerPCRegisterInfo.h:1.2 Wed Feb 11 20:27:10 2004 +++ llvm/lib/Target/PowerPC/PowerPCRegisterInfo.h Thu Feb 12 02:11:04 2004 @@ -27,25 +27,25 @@ /// Code Generation virtual methods... int storeRegToStackSlot(MachineBasicBlock &MBB, - MachineInstr* MBBI, + MachineBasicBlock::iterator MBBI, unsigned SrcReg, int FrameIndex, const TargetRegisterClass *RC) const; int loadRegFromStackSlot(MachineBasicBlock &MBB, - MachineInstr* MBBI, + MachineBasicBlock::iterator MBBI, unsigned DestReg, int FrameIndex, const TargetRegisterClass *RC) const; - int copyRegToReg(MachineBasicBlock &MBB, MachineInstr* MBBI, + int copyRegToReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, unsigned DestReg, unsigned SrcReg, const TargetRegisterClass *RC) const; int eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, - MachineInstr* I) const; + MachineBasicBlock::iterator I) const; int eliminateFrameIndex(MachineFunction &MF, - MachineInstr* II) const; + MachineBasicBlock::iterator II) const; int processFunctionBeforeFrameFinalized(MachineFunction &MF) const; Index: llvm/lib/Target/PowerPC/PowerPCRegisterInfo.cpp diff -u llvm/lib/Target/PowerPC/PowerPCRegisterInfo.cpp:1.2 llvm/lib/Target/PowerPC/PowerPCRegisterInfo.cpp:1.3 --- llvm/lib/Target/PowerPC/PowerPCRegisterInfo.cpp:1.2 Wed Feb 11 20:27:10 2004 +++ llvm/lib/Target/PowerPC/PowerPCRegisterInfo.cpp Thu Feb 12 02:11:04 2004 @@ -23,7 +23,7 @@ int PowerPCRegisterInfo::storeRegToStackSlot( MachineBasicBlock &MBB, - MachineInstr* MBBI, + MachineBasicBlock::iterator MBBI, unsigned SrcReg, int FrameIdx, const TargetRegisterClass *RC) const { @@ -33,7 +33,7 @@ int PowerPCRegisterInfo::loadRegFromStackSlot( MachineBasicBlock &MBB, - MachineInstr* MBBI, + MachineBasicBlock::iterator MBBI, unsigned DestReg, int FrameIdx, const TargetRegisterClass *RC) const { @@ -42,7 +42,7 @@ } int PowerPCRegisterInfo::copyRegToReg(MachineBasicBlock &MBB, - MachineInstr* MBBI, + MachineBasicBlock::iterator MBBI, unsigned DestReg, unsigned SrcReg, const TargetRegisterClass *RC) const { abort(); @@ -51,13 +51,13 @@ int PowerPCRegisterInfo::eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, - MachineInstr* I) const { + MachineBasicBlock::iterator I) const { abort(); return -1; } int PowerPCRegisterInfo::eliminateFrameIndex(MachineFunction &MF, - MachineInstr* II) const { + MachineBasicBlock::iterator II) const { abort(); return -1; } From alkis at cs.uiuc.edu Thu Feb 12 02:12:09 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Thu Feb 12 02:12:09 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86RegisterInfo.h X86RegisterInfo.cpp Message-ID: <200402120811.CAA25957@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86RegisterInfo.h updated: 1.19 -> 1.20 X86RegisterInfo.cpp updated: 1.42 -> 1.43 --- Log message: Change interface so that we can add to the end of a basic block without getting an assertion from ilist that we are dereferencing ilist::end(). --- Diffs of the changes: (+10 -10) Index: llvm/lib/Target/X86/X86RegisterInfo.h diff -u llvm/lib/Target/X86/X86RegisterInfo.h:1.19 llvm/lib/Target/X86/X86RegisterInfo.h:1.20 --- llvm/lib/Target/X86/X86RegisterInfo.h:1.19 Wed Feb 11 20:27:09 2004 +++ llvm/lib/Target/X86/X86RegisterInfo.h Thu Feb 12 02:10:44 2004 @@ -28,26 +28,26 @@ /// Code Generation virtual methods... int storeRegToStackSlot(MachineBasicBlock &MBB, - MachineInstr* MI, + MachineBasicBlock::iterator MI, unsigned SrcReg, int FrameIndex, const TargetRegisterClass *RC) const; int loadRegFromStackSlot(MachineBasicBlock &MBB, - MachineInstr* MI, + MachineBasicBlock::iterator MI, unsigned DestReg, int FrameIndex, const TargetRegisterClass *RC) const; int copyRegToReg(MachineBasicBlock &MBB, - MachineInstr* MI, + MachineBasicBlock::iterator MI, unsigned DestReg, unsigned SrcReg, const TargetRegisterClass *RC) const; int eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, - MachineInstr* MI) const; + MachineBasicBlock::iterator MI) const; int eliminateFrameIndex(MachineFunction &MF, - MachineInstr* MI) const; + MachineBasicBlock::iterator MI) const; int processFunctionBeforeFrameFinalized(MachineFunction &MF) const; Index: llvm/lib/Target/X86/X86RegisterInfo.cpp diff -u llvm/lib/Target/X86/X86RegisterInfo.cpp:1.42 llvm/lib/Target/X86/X86RegisterInfo.cpp:1.43 --- llvm/lib/Target/X86/X86RegisterInfo.cpp:1.42 Wed Feb 11 20:27:09 2004 +++ llvm/lib/Target/X86/X86RegisterInfo.cpp Thu Feb 12 02:10:45 2004 @@ -47,7 +47,7 @@ } int X86RegisterInfo::storeRegToStackSlot(MachineBasicBlock &MBB, - MachineInstr* MI, + MachineBasicBlock::iterator MI, unsigned SrcReg, int FrameIdx, const TargetRegisterClass *RC) const { static const unsigned Opcode[] = @@ -59,7 +59,7 @@ } int X86RegisterInfo::loadRegFromStackSlot(MachineBasicBlock &MBB, - MachineInstr* MI, + MachineBasicBlock::iterator MI, unsigned DestReg, int FrameIdx, const TargetRegisterClass *RC) const{ static const unsigned Opcode[] = @@ -70,7 +70,7 @@ } int X86RegisterInfo::copyRegToReg(MachineBasicBlock &MBB, - MachineInstr* MI, + MachineBasicBlock::iterator MI, unsigned DestReg, unsigned SrcReg, const TargetRegisterClass *RC) const { static const unsigned Opcode[] = @@ -93,7 +93,7 @@ int X86RegisterInfo::eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, - MachineInstr* I) const { + MachineBasicBlock::iterator I) const { MachineInstr *New = 0, *Old = I; if (hasFP(MF)) { // If we have a frame pointer, turn the adjcallstackup instruction into a @@ -127,7 +127,7 @@ } int X86RegisterInfo::eliminateFrameIndex(MachineFunction &MF, - MachineInstr* II) const { + MachineBasicBlock::iterator II) const { unsigned i = 0; MachineInstr &MI = *II; while (!MI.getOperand(i).isFrameIndex()) { From alkis at cs.uiuc.edu Thu Feb 12 02:12:17 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Thu Feb 12 02:12:17 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Target/MRegisterInfo.h Message-ID: <200402120811.CAA25961@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Target: MRegisterInfo.h updated: 1.29 -> 1.30 --- Log message: Change interface so that we can add to the end of a basic block without getting an assertion from ilist that we are dereferencing ilist::end(). --- Diffs of the changes: (+6 -6) Index: llvm/include/llvm/Target/MRegisterInfo.h diff -u llvm/include/llvm/Target/MRegisterInfo.h:1.29 llvm/include/llvm/Target/MRegisterInfo.h:1.30 --- llvm/include/llvm/Target/MRegisterInfo.h:1.29 Wed Feb 11 20:27:10 2004 +++ llvm/include/llvm/Target/MRegisterInfo.h Thu Feb 12 02:11:04 2004 @@ -17,11 +17,11 @@ #define LLVM_TARGET_MREGISTERINFO_H #include +#include "llvm/CodeGen/MachineBasicBlock.h" namespace llvm { class Type; -class MachineBasicBlock; class MachineFunction; class MachineInstr; @@ -227,17 +227,17 @@ // virtual int storeRegToStackSlot(MachineBasicBlock &MBB, - MachineInstr* MI, + MachineBasicBlock::iterator MI, unsigned SrcReg, int FrameIndex, const TargetRegisterClass *RC) const = 0; virtual int loadRegFromStackSlot(MachineBasicBlock &MBB, - MachineInstr* MI, + MachineBasicBlock::iterator MI, unsigned DestReg, int FrameIndex, const TargetRegisterClass *RC) const = 0; virtual int copyRegToReg(MachineBasicBlock &MBB, - MachineInstr* MI, + MachineBasicBlock::iterator MI, unsigned DestReg, unsigned SrcReg, const TargetRegisterClass *RC) const = 0; @@ -262,7 +262,7 @@ /// virtual int eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, - MachineInstr* MI) const { + MachineBasicBlock::iterator MI) const { assert(getCallFrameSetupOpcode()== -1 && getCallFrameDestroyOpcode()== -1 && "eliminateCallFramePseudoInstr must be implemented if using" " call frame setup/destroy pseudo instructions!"); @@ -290,7 +290,7 @@ /// added to (negative if removed from) the basic block. /// virtual int eliminateFrameIndex(MachineFunction &MF, - MachineInstr* MI) const = 0; + MachineBasicBlock::iterator MI) const = 0; /// emitProlog/emitEpilog - These methods insert prolog and epilog code into /// the function. The return value is the number of instructions From y5cvnwyuo at iiyama.de Thu Feb 12 02:24:02 2004 From: y5cvnwyuo at iiyama.de (Stephan Schaffer) Date: Thu Feb 12 02:24:02 2004 Subject: [llvm-commits] Make a secure income with Google Message-ID: An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20040212/31875dfa/attachment.html From f0gdrtxvof at giga.de Thu Feb 12 02:24:11 2004 From: f0gdrtxvof at giga.de (Joan Brand) Date: Thu Feb 12 02:24:11 2004 Subject: [llvm-commits] Enjoy life, don't work Message-ID: An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20040212/fb1dd622/attachment.html From lattner at cs.uiuc.edu Thu Feb 12 10:06:05 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Feb 12 10:06:05 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/MachineInstr.h Message-ID: <200402121605.KAA32590@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: MachineInstr.h updated: 1.131 -> 1.132 --- Log message: Remove a dead field from MachineInstr! --- Diffs of the changes: (+0 -1) Index: llvm/include/llvm/CodeGen/MachineInstr.h diff -u llvm/include/llvm/CodeGen/MachineInstr.h:1.131 llvm/include/llvm/CodeGen/MachineInstr.h:1.132 --- llvm/include/llvm/CodeGen/MachineInstr.h:1.131 Wed Feb 11 22:26:49 2004 +++ llvm/include/llvm/CodeGen/MachineInstr.h Thu Feb 12 10:05:03 2004 @@ -333,7 +333,6 @@ class MachineInstr { int opCode; // the opcode - unsigned opCodeFlags; // flags modifying instrn behavior std::vector operands; // the operands unsigned numImplicitRefs; // number of implicit operands MachineInstr* prev, *next; // links for our intrusive list From lattner at cs.uiuc.edu Thu Feb 12 10:06:15 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Feb 12 10:06:15 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/MachineInstr.cpp Message-ID: <200402121604.KAA32578@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: MachineInstr.cpp updated: 1.84 -> 1.85 --- Log message: This field is never read --- Diffs of the changes: (+0 -3) Index: llvm/lib/CodeGen/MachineInstr.cpp diff -u llvm/lib/CodeGen/MachineInstr.cpp:1.84 llvm/lib/CodeGen/MachineInstr.cpp:1.85 --- llvm/lib/CodeGen/MachineInstr.cpp:1.84 Wed Feb 4 16:17:40 2004 +++ llvm/lib/CodeGen/MachineInstr.cpp Thu Feb 12 10:04:49 2004 @@ -30,7 +30,6 @@ // Constructor for instructions with variable #operands MachineInstr::MachineInstr(MachineOpCode OpCode, unsigned numOperands) : opCode(OpCode), - opCodeFlags(0), operands(numOperands, MachineOperand()), numImplicitRefs(0) { @@ -44,7 +43,6 @@ MachineInstr::MachineInstr(MachineOpCode Opcode, unsigned numOperands, bool XX, bool YY) : opCode(Opcode), - opCodeFlags(0), numImplicitRefs(0) { operands.reserve(numOperands); @@ -56,7 +54,6 @@ MachineInstr::MachineInstr(MachineBasicBlock *MBB, MachineOpCode Opcode, unsigned numOperands) : opCode(Opcode), - opCodeFlags(0), numImplicitRefs(0) { assert(MBB && "Cannot use inserting ctor with null basic block!"); From lattner at cs.uiuc.edu Thu Feb 12 10:10:04 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Feb 12 10:10:04 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/MachineInstr.cpp Message-ID: <200402121609.KAA08890@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: MachineInstr.cpp updated: 1.85 -> 1.86 --- Log message: Rename the opCode instance variable to Opcode --- Diffs of the changes: (+15 -29) Index: llvm/lib/CodeGen/MachineInstr.cpp diff -u llvm/lib/CodeGen/MachineInstr.cpp:1.85 llvm/lib/CodeGen/MachineInstr.cpp:1.86 --- llvm/lib/CodeGen/MachineInstr.cpp:1.85 Thu Feb 12 10:04:49 2004 +++ llvm/lib/CodeGen/MachineInstr.cpp Thu Feb 12 10:09:31 2004 @@ -28,11 +28,8 @@ extern const TargetInstrDescriptor *TargetInstrDescriptors; // Constructor for instructions with variable #operands -MachineInstr::MachineInstr(MachineOpCode OpCode, unsigned numOperands) - : opCode(OpCode), - operands(numOperands, MachineOperand()), - numImplicitRefs(0) -{ +MachineInstr::MachineInstr(MachineOpCode opcode, unsigned numOperands) + : Opcode(opcode), operands(numOperands, MachineOperand()), numImplicitRefs(0){ } /// MachineInstr ctor - This constructor only does a _reserve_ of the operands, @@ -40,22 +37,18 @@ /// add* methods below to fill up the operands, instead of the Set methods. /// Eventually, the "resizing" ctors will be phased out. /// -MachineInstr::MachineInstr(MachineOpCode Opcode, unsigned numOperands, +MachineInstr::MachineInstr(MachineOpCode opcode, unsigned numOperands, bool XX, bool YY) - : opCode(Opcode), - numImplicitRefs(0) -{ + : Opcode(opcode), numImplicitRefs(0) { operands.reserve(numOperands); } /// MachineInstr ctor - Work exactly the same as the ctor above, except that the /// MachineInstr is created and added to the end of the specified basic block. /// -MachineInstr::MachineInstr(MachineBasicBlock *MBB, MachineOpCode Opcode, +MachineInstr::MachineInstr(MachineBasicBlock *MBB, MachineOpCode opcode, unsigned numOperands) - : opCode(Opcode), - numImplicitRefs(0) -{ + : Opcode(opcode), numImplicitRefs(0) { assert(MBB && "Cannot use inserting ctor with null basic block!"); operands.reserve(numOperands); MBB->push_back(this); // Add instruction to end of basic block! @@ -63,9 +56,8 @@ // OperandComplete - Return true if it's illegal to add a new operand -bool MachineInstr::OperandsComplete() const -{ - int NumOperands = TargetInstrDescriptors[opCode].numOperands; +bool MachineInstr::OperandsComplete() const { + int NumOperands = TargetInstrDescriptors[Opcode].numOperands; if (NumOperands >= 0 && getNumOperands() >= (unsigned)NumOperands) return true; // Broken: we have all the operands of this instruction! return false; @@ -77,11 +69,10 @@ // This only resets the size of the operand vector and initializes it. // The new operands must be set explicitly later. // -void MachineInstr::replace(MachineOpCode Opcode, unsigned numOperands) -{ +void MachineInstr::replace(MachineOpCode opcode, unsigned numOperands) { assert(getNumImplicitRefs() == 0 && "This is probably broken because implicit refs are going to be lost."); - opCode = Opcode; + Opcode = opcode; operands.clear(); operands.resize(numOperands, MachineOperand()); } @@ -98,10 +89,9 @@ void MachineInstr::SetMachineOperandConst(unsigned i, MachineOperand::MachineOperandType operandType, - int64_t intValue) -{ + int64_t intValue) { assert(i < getNumOperands()); // must be explicit op - assert(TargetInstrDescriptors[opCode].resultPos != (int) i && + assert(TargetInstrDescriptors[Opcode].resultPos != (int) i && "immed. constant cannot be defined"); operands[i].opType = operandType; @@ -119,16 +109,12 @@ operands[i].regNum = regNum; } -void -MachineInstr::SetRegForOperand(unsigned i, int regNum) -{ +void MachineInstr::SetRegForOperand(unsigned i, int regNum) { assert(i < getNumOperands()); // must be explicit op operands[i].setRegForValue(regNum); } -void -MachineInstr::SetRegForImplicitRef(unsigned i, int regNum) -{ +void MachineInstr::SetRegForImplicitRef(unsigned i, int regNum) { getImplicitOp(i).setRegForValue(regNum); } @@ -327,7 +313,7 @@ std::ostream &operator<<(std::ostream& os, const MachineInstr& MI) { - os << TargetInstrDescriptors[MI.opCode].Name; + os << TargetInstrDescriptors[MI.getOpcode()].Name; for (unsigned i=0, N=MI.getNumOperands(); i < N; i++) { os << "\t" << MI.getOperand(i); From lattner at cs.uiuc.edu Thu Feb 12 10:11:06 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Feb 12 10:11:06 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/MachineInstr.h Message-ID: <200402121610.KAA08904@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: MachineInstr.h updated: 1.132 -> 1.133 --- Log message: Rename the opCode instance variable to Opcode --- Diffs of the changes: (+3 -3) Index: llvm/include/llvm/CodeGen/MachineInstr.h diff -u llvm/include/llvm/CodeGen/MachineInstr.h:1.132 llvm/include/llvm/CodeGen/MachineInstr.h:1.133 --- llvm/include/llvm/CodeGen/MachineInstr.h:1.132 Thu Feb 12 10:05:03 2004 +++ llvm/include/llvm/CodeGen/MachineInstr.h Thu Feb 12 10:09:53 2004 @@ -332,7 +332,7 @@ //===----------------------------------------------------------------------===// class MachineInstr { - int opCode; // the opcode + int Opcode; // the opcode std::vector operands; // the operands unsigned numImplicitRefs; // number of implicit operands MachineInstr* prev, *next; // links for our intrusive list @@ -371,7 +371,7 @@ /// Accessors for opcode. /// - const int getOpcode() const { return opCode; } + const int getOpcode() const { return Opcode; } /// Access to explicit operands of the instruction. /// @@ -591,7 +591,7 @@ /// setOpcode - Replace the opcode of the current instruction with a new one. /// - void setOpcode(unsigned Op) { opCode = Op; } + void setOpcode(unsigned Op) { Opcode = Op; } /// RemoveOperand - Erase an operand from an instruction, leaving it with one /// fewer operand than it started with. From lattner at cs.uiuc.edu Thu Feb 12 11:02:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Feb 12 11:02:02 2004 Subject: [llvm-commits] CVS: llvm/docs/LangRef.html Message-ID: <200402121701.LAA11029@zion.cs.uiuc.edu> Changes in directory llvm/docs: LangRef.html updated: 1.43 -> 1.44 --- Log message: Document the llvm.memcpy intrinsic. Clean up some of the formatting of other sections --- Diffs of the changes: (+109 -23) Index: llvm/docs/LangRef.html diff -u llvm/docs/LangRef.html:1.43 llvm/docs/LangRef.html:1.44 --- llvm/docs/LangRef.html:1.43 Mon Jan 5 23:31:32 2004 +++ llvm/docs/LangRef.html Thu Feb 12 11:01:32 2004 @@ -95,6 +95,11 @@
  • 'llvm.va_copy' Intrinsic
  • +
  • Standard C Library Intrinsics +
      +
    1. 'llvm.memcpy' Intrinsic
    2. +
    +
  • Debugger intrinsics
  • @@ -1594,23 +1599,31 @@
    -

    LLVM supports the notion of an "intrinsic function". These -functions have well known names and semantics, and are required to -follow certain restrictions. Overall, these instructions represent an -extension mechanism for the LLVM language that does not require -changing all of the transformations in LLVM to add to the language (or -the bytecode reader/writer, the parser, etc...).

    -

    Intrinsic function names must all start with an "llvm." -prefix, this prefix is reserved in LLVM for intrinsic names, thus -functions may not be named this. Intrinsic functions must always be -external functions: you cannot define the body of intrinsic functions. -Intrinsic functions may only be used in call or invoke instructions: it -is illegal to take the address of an intrinsic function. Additionally, -because intrinsic functions are part of the LLVM language, it is -required that they all be documented here if any are added.

    -

    Unless an intrinsic function is target-specific, there must be a -lowering pass to eliminate the intrinsic or all backends must support -the intrinsic function.

    + +

    LLVM supports the notion of an "intrinsic function". These functions have +well known names and semantics, and are required to follow certain +restrictions. Overall, these instructions represent an extension mechanism for +the LLVM language that does not require changing all of the transformations in +LLVM to add to the language (or the bytecode reader/writer, the parser, +etc...).

    + +

    Intrinsic function names must all start with an "llvm." prefix, this +prefix is reserved in LLVM for intrinsic names, thus functions may not be named +this. Intrinsic functions must always be external functions: you cannot define +the body of intrinsic functions. Intrinsic functions may only be used in call +or invoke instructions: it is illegal to take the address of an intrinsic +function. Additionally, because intrinsic functions are part of the LLVM +language, it is required that they all be documented here if any are added.

    + + +

    +Adding an intrinsic to LLVM is straight-forward if it is possible to express the +concept in LLVM directly (ie, code generator support is not _required_). To do +this, extend the default implementation of the IntrinsicLowering class to handle +the intrinsic. Code generators use this class to lower intrinsics they do not +understand to raw LLVM instructions that they do. +

    +
    @@ -1631,11 +1644,26 @@

    This example shows how the vanext instruction and the variable argument handling intrinsic functions are used.

    -
    int %test(int %X, ...) {
    ; Initialize variable argument processing
    %ap = call sbyte*()* %llvm.va_start()

    ; Read a single integer argument
    %tmp = vaarg sbyte* %ap, int

    ; Advance to the next argument
    %ap2 = vanext sbyte* %ap, int

    ; Demonstrate usage of llvm.va_copy and llvm.va_end
    %aq = call sbyte* (sbyte*)* %llvm.va_copy(sbyte* %ap2)
    call void %llvm.va_end(sbyte* %aq)

    ; Stop processing of arguments.
    call void %llvm.va_end(sbyte* %ap2)
    ret int %tmp
    }
    +
    +int %test(int %X, ...) {
    +  ; Initialize variable argument processing
    +  %ap = call sbyte* %llvm.va_start()
    +
    +  ; Read a single integer argument
    +  %tmp = vaarg sbyte* %ap, int
    +
    +  ; Advance to the next argument
    +  %ap2 = vanext sbyte* %ap, int
    +
    +  ; Demonstrate usage of llvm.va_copy and llvm.va_end
    +  %aq = call sbyte* %llvm.va_copy(sbyte* %ap2)
    +  call void %llvm.va_end(sbyte* %aq)
    +
    +  ; Stop processing of arguments.
    +  call void %llvm.va_end(sbyte* %ap2)
    +  ret int %tmp
    +}
    +
    @@ -1704,6 +1732,64 @@ complex and require memory allocation, for example.

    + + + +
    +

    + +

    + +
    + + + + +
    + +
    Syntax:
    +
    +  call void (sbyte*, sbyte*, uint, uint)* %llvm.memcpy(sbyte* <dest>, sbyte* <src>,
    +                                                       uint <len>, uint <align>)
    +
    + +
    Overview:
    + +

    +The 'llvm.memcpy' intrinsic copies a block of memory from the source +location to the destination location. +

    + +

    +Note that, unlike the standard libc function, the llvm.memcpy intrinsic +does not return a value, and takes an extra alignment argument. +

    + +
    Arguments:
    + +

    +The first argument is a pointer to the destination, the second is a pointer to +the source. The third argument is an (arbitrarily sized) integer argument +specifying the number of bytes to copy, and the fourth argument is the alignment +of the source and destination locations. +

    + +
    Semantics:
    + +

    +The 'llvm.memcpy' intrinsic copies a block of memory from the source +location to the destination location, which are not allowed to overlap. It +copies "len" bytes of memory over. If the argument is known to be aligned to +some boundary, this can be specified as the fourth argument, otherwise it should +be set to 0 or 1. +

    +
    + +
    @@ -1725,6 +1811,6 @@ +Last modified: $Date: 2004/02/12 17:01:32 $
    From lattner at cs.uiuc.edu Thu Feb 12 11:02:17 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Feb 12 11:02:17 2004 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Function.cpp IntrinsicLowering.cpp Verifier.cpp Message-ID: <200402121701.LAA10646@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Function.cpp updated: 1.62 -> 1.63 IntrinsicLowering.cpp updated: 1.5 -> 1.6 Verifier.cpp updated: 1.78 -> 1.79 --- Log message: Implement the llvm.memcpy intrinsic --- Diffs of the changes: (+20 -1) Index: llvm/lib/VMCore/Function.cpp diff -u llvm/lib/VMCore/Function.cpp:1.62 llvm/lib/VMCore/Function.cpp:1.63 --- llvm/lib/VMCore/Function.cpp:1.62 Sat Jan 10 15:42:24 2004 +++ llvm/lib/VMCore/Function.cpp Thu Feb 12 11:01:08 2004 @@ -217,6 +217,9 @@ case 'l': if (getName() == "llvm.longjmp") return Intrinsic::longjmp; break; + case 'm': + if (getName() == "llvm.memcpy") return Intrinsic::memcpy; + break; case 's': if (getName() == "llvm.setjmp") return Intrinsic::setjmp; if (getName() == "llvm.sigsetjmp") return Intrinsic::sigsetjmp; Index: llvm/lib/VMCore/IntrinsicLowering.cpp diff -u llvm/lib/VMCore/IntrinsicLowering.cpp:1.5 llvm/lib/VMCore/IntrinsicLowering.cpp:1.6 --- llvm/lib/VMCore/IntrinsicLowering.cpp:1.5 Wed Jan 14 14:41:29 2004 +++ llvm/lib/VMCore/IntrinsicLowering.cpp Thu Feb 12 11:01:09 2004 @@ -13,8 +13,8 @@ #include "llvm/IntrinsicLowering.h" #include "llvm/Constant.h" +#include "llvm/DerivedTypes.h" #include "llvm/Module.h" -#include "llvm/Type.h" #include "llvm/iOther.h" using namespace llvm; @@ -57,6 +57,20 @@ if (CI->getType() != Type::VoidTy) CI->replaceAllUsesWith(Constant::getNullValue(CI->getType())); break; // Simply strip out debugging intrinsics + + case Intrinsic::memcpy: { + // The memcpy intrinsic take an extra alignment argument that the memcpy + // libc function does not. + const FunctionType *CFT = Callee->getFunctionType(); + FunctionType *FT = + FunctionType::get(*CFT->param_begin(), + std::vector(CFT->param_begin(), CFT->param_end()-1), + false); + Function *MemCpy = M->getOrInsertFunction("memcpy", FT); + new CallInst(MemCpy, std::vector(CI->op_begin()+1, CI->op_end()-1), + CI->getName(), CI); + break; + } } assert(CI->use_empty() && Index: llvm/lib/VMCore/Verifier.cpp diff -u llvm/lib/VMCore/Verifier.cpp:1.78 llvm/lib/VMCore/Verifier.cpp:1.79 --- llvm/lib/VMCore/Verifier.cpp:1.78 Tue Jan 13 23:42:52 2004 +++ llvm/lib/VMCore/Verifier.cpp Thu Feb 12 11:01:09 2004 @@ -561,6 +561,8 @@ case Intrinsic::dbg_region_end: NumArgs = 1; break; case Intrinsic::dbg_func_start: NumArgs = 1; break; case Intrinsic::dbg_declare: NumArgs = 1; break; + + case Intrinsic::memcpy: NumArgs = 4; break; case Intrinsic::alpha_ctlz: NumArgs = 1; break; case Intrinsic::alpha_cttz: NumArgs = 1; break; From lattner at cs.uiuc.edu Thu Feb 12 11:55:03 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Feb 12 11:55:03 2004 Subject: [llvm-commits] CVS: llvm/test/Regression/CodeGen/X86/2004-02-12-Memcpy.llx Message-ID: <200402121753.LAA09207@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/CodeGen/X86: 2004-02-12-Memcpy.llx added (r1.1) --- Log message: Test that we get rep movs when calling memcpy --- Diffs of the changes: (+24 -0) Index: llvm/test/Regression/CodeGen/X86/2004-02-12-Memcpy.llx diff -c /dev/null llvm/test/Regression/CodeGen/X86/2004-02-12-Memcpy.llx:1.1 *** /dev/null Thu Feb 12 11:53:53 2004 --- llvm/test/Regression/CodeGen/X86/2004-02-12-Memcpy.llx Thu Feb 12 11:53:43 2004 *************** *** 0 **** --- 1,24 ---- + ; RUN: llvm-as < %s | llc -march=x86 | grep movs + declare sbyte* %llvm.memcpy(sbyte* %A, sbyte* %B, uint %amt, uint %align) + + %A = global [1000 x int] zeroinitializer + %B = global [1000 x int] zeroinitializer + + + void %main() { + ; dword copy + call sbyte* %llvm.memcpy(sbyte* cast (int* getelementptr ([1000 x int]* %A, long 0, long 0) to sbyte*), + sbyte* cast (int* getelementptr ([1000 x int]* %B, long 0, long 0) to sbyte*), + uint 4000, uint 4) + + ; word copy + call sbyte* %llvm.memcpy(sbyte* cast (int* getelementptr ([1000 x int]* %A, long 0, long 0) to sbyte*), + sbyte* cast (int* getelementptr ([1000 x int]* %B, long 0, long 0) to sbyte*), + uint 4000, uint 2) + + ; byte copy + call sbyte* %llvm.memcpy(sbyte* cast (int* getelementptr ([1000 x int]* %A, long 0, long 0) to sbyte*), + sbyte* cast (int* getelementptr ([1000 x int]* %B, long 0, long 0) to sbyte*), + uint 4000, uint 1) + ret void + } From lattner at cs.uiuc.edu Thu Feb 12 11:55:11 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Feb 12 11:55:11 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/InstSelectSimple.cpp X86CodeEmitter.cpp X86InstrInfo.h X86InstrInfo.td Message-ID: <200402121753.LAA14016@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: InstSelectSimple.cpp updated: 1.155 -> 1.156 X86CodeEmitter.cpp updated: 1.48 -> 1.49 X86InstrInfo.h updated: 1.31 -> 1.32 X86InstrInfo.td updated: 1.19 -> 1.20 --- Log message: Add support for the rep movs[bwd] instructions, and emit them when code generating the llvm.memcpy intrinsic. --- Diffs of the changes: (+85 -15) Index: llvm/lib/Target/X86/InstSelectSimple.cpp diff -u llvm/lib/Target/X86/InstSelectSimple.cpp:1.155 llvm/lib/Target/X86/InstSelectSimple.cpp:1.156 --- llvm/lib/Target/X86/InstSelectSimple.cpp:1.155 Wed Feb 11 20:27:09 2004 +++ llvm/lib/Target/X86/InstSelectSimple.cpp Thu Feb 12 11:53:22 2004 @@ -1157,6 +1157,7 @@ case Intrinsic::va_start: case Intrinsic::va_copy: case Intrinsic::va_end: + case Intrinsic::memcpy: // We directly implement these intrinsics break; default: @@ -1187,6 +1188,58 @@ BuildMI(BB, X86::MOVrr32, 1, TmpReg1).addReg(TmpReg2); return; case Intrinsic::va_end: return; // Noop on X86 + + case Intrinsic::memcpy: { + assert(CI.getNumOperands() == 5 && "Illegal llvm.memcpy call!"); + unsigned Align = 1; + if (ConstantInt *AlignC = dyn_cast(CI.getOperand(4))) { + Align = AlignC->getRawValue(); + if (Align == 0) Align = 1; + } + + // Turn the byte code into # iterations + unsigned ByteReg = getReg(CI.getOperand(3)); + unsigned CountReg; + + switch (Align & 3) { + case 2: // WORD aligned + CountReg = makeAnotherReg(Type::IntTy); + BuildMI(BB, X86::SHRir32, 2, CountReg).addReg(ByteReg).addZImm(1); + break; + case 0: // DWORD aligned + CountReg = makeAnotherReg(Type::IntTy); + BuildMI(BB, X86::SHRir32, 2, CountReg).addReg(ByteReg).addZImm(2); + break; + case 1: // BYTE aligned + case 3: // BYTE aligned + CountReg = ByteReg; + break; + } + + // No matter what the alignment is, we put the source in ESI, the + // destination in EDI, and the count in ECX. + TmpReg1 = getReg(CI.getOperand(1)); + TmpReg2 = getReg(CI.getOperand(2)); + BuildMI(BB, X86::MOVrr32, 1, X86::ECX).addReg(CountReg); + BuildMI(BB, X86::MOVrr32, 1, X86::EDI).addReg(TmpReg1); + BuildMI(BB, X86::MOVrr32, 1, X86::ESI).addReg(TmpReg2); + + unsigned Bytes = getReg(CI.getOperand(3)); + switch (Align & 3) { + case 1: // BYTE aligned + case 3: // BYTE aligned + BuildMI(BB, X86::REP_MOVSB, 0); + break; + case 2: // WORD aligned + BuildMI(BB, X86::REP_MOVSW, 0); + break; + case 0: // DWORD aligned + BuildMI(BB, X86::REP_MOVSD, 0); + break; + } + + return; + } default: assert(0 && "Error: unknown intrinsics should have been lowered!"); } Index: llvm/lib/Target/X86/X86CodeEmitter.cpp diff -u llvm/lib/Target/X86/X86CodeEmitter.cpp:1.48 llvm/lib/Target/X86/X86CodeEmitter.cpp:1.49 --- llvm/lib/Target/X86/X86CodeEmitter.cpp:1.48 Wed Feb 11 20:27:09 2004 +++ llvm/lib/Target/X86/X86CodeEmitter.cpp Thu Feb 12 11:53:22 2004 @@ -470,6 +470,9 @@ unsigned Opcode = MI.getOpcode(); const TargetInstrDescriptor &Desc = II->get(Opcode); + // Emit the repeat opcode prefix as needed. + if ((Desc.TSFlags & X86II::Op0Mask) == X86II::REP) MCE.emitByte(0xF3); + // Emit instruction prefixes if necessary if (Desc.TSFlags & X86II::OpSize) MCE.emitByte(0x66);// Operand size... @@ -477,6 +480,7 @@ case X86II::TB: MCE.emitByte(0x0F); // Two-byte opcode prefix break; + case X86II::REP: break; // already handled. case X86II::D8: case X86II::D9: case X86II::DA: case X86II::DB: case X86II::DC: case X86II::DD: case X86II::DE: case X86II::DF: MCE.emitByte(0xD8+ Index: llvm/lib/Target/X86/X86InstrInfo.h diff -u llvm/lib/Target/X86/X86InstrInfo.h:1.31 llvm/lib/Target/X86/X86InstrInfo.h:1.32 --- llvm/lib/Target/X86/X86InstrInfo.h:1.31 Fri Jan 30 16:24:18 2004 +++ llvm/lib/Target/X86/X86InstrInfo.h Thu Feb 12 11:53:22 2004 @@ -86,9 +86,9 @@ OpSize = 1 << 5, // Op0Mask - There are several prefix bytes that are used to form two byte - // opcodes. These are currently 0x0F, and 0xD8-0xDF. This mask is used to - // obtain the setting of this field. If no bits in this field is set, there - // is no prefix byte for obtaining a multibyte opcode. + // opcodes. These are currently 0x0F, 0xF3, and 0xD8-0xDF. This mask is + // used to obtain the setting of this field. If no bits in this field is + // set, there is no prefix byte for obtaining a multibyte opcode. // Op0Shift = 6, Op0Mask = 0xF << Op0Shift, @@ -97,12 +97,16 @@ // starts with a 0x0F byte before the real opcode. TB = 1 << Op0Shift, + // REP - The 0xF3 prefix byte indicating repetition of the following + // instruction. + REP = 2 << Op0Shift, + // D8-DF - These escape opcodes are used by the floating point unit. These // values must remain sequential. - D8 = 2 << Op0Shift, D9 = 3 << Op0Shift, - DA = 4 << Op0Shift, DB = 5 << Op0Shift, - DC = 6 << Op0Shift, DD = 7 << Op0Shift, - DE = 8 << Op0Shift, DF = 9 << Op0Shift, + D8 = 3 << Op0Shift, D9 = 4 << Op0Shift, + DA = 5 << Op0Shift, DB = 6 << Op0Shift, + DC = 7 << Op0Shift, DD = 8 << Op0Shift, + DE = 9 << Op0Shift, DF = 10 << Op0Shift, //===------------------------------------------------------------------===// // This three-bit field describes the size of a memory operand. Zero is Index: llvm/lib/Target/X86/X86InstrInfo.td diff -u llvm/lib/Target/X86/X86InstrInfo.td:1.19 llvm/lib/Target/X86/X86InstrInfo.td:1.20 --- llvm/lib/Target/X86/X86InstrInfo.td:1.19 Wed Feb 4 11:21:04 2004 +++ llvm/lib/Target/X86/X86InstrInfo.td Thu Feb 12 11:53:22 2004 @@ -92,14 +92,15 @@ // emitter that various prefix bytes are required. class OpSize { bit hasOpSizePrefix = 1; } class TB { bits<4> Prefix = 1; } -class D8 { bits<4> Prefix = 2; } -class D9 { bits<4> Prefix = 3; } -class DA { bits<4> Prefix = 4; } -class DB { bits<4> Prefix = 5; } -class DC { bits<4> Prefix = 6; } -class DD { bits<4> Prefix = 7; } -class DE { bits<4> Prefix = 8; } -class DF { bits<4> Prefix = 9; } +class REP { bits<4> Prefix = 2; } +class D8 { bits<4> Prefix = 3; } +class D9 { bits<4> Prefix = 4; } +class DA { bits<4> Prefix = 5; } +class DB { bits<4> Prefix = 6; } +class DC { bits<4> Prefix = 7; } +class DD { bits<4> Prefix = 8; } +class DE { bits<4> Prefix = 9; } +class DF { bits<4> Prefix = 10; } @@ -171,6 +172,14 @@ def LEAr16 : X86Inst<"lea", 0x8D, MRMSrcMem, Arg16>, OpSize; // R16 = lea [mem] def LEAr32 : X86Inst<"lea", 0x8D, MRMSrcMem, Arg32>; // R32 = lea [mem] + + +def REP_MOVSB : X86Inst<"rep movsb", 0xA4, RawFrm, NoArg>, REP, + Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>; +def REP_MOVSW : X86Inst<"rep movsw", 0xA5, RawFrm, NoArg>, REP, OpSize, + Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>; +def REP_MOVSD : X86Inst<"rep movsd", 0xA5, RawFrm, NoArg>, REP, + Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>; //===----------------------------------------------------------------------===// // Move Instructions... From lattner at cs.uiuc.edu Thu Feb 12 11:58:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Feb 12 11:58:01 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Intrinsics.h Message-ID: <200402121757.LAA14349@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: Intrinsics.h updated: 1.15 -> 1.16 --- Log message: Urg, check in header I forgot. :( --- Diffs of the changes: (+6 -0) Index: llvm/include/llvm/Intrinsics.h diff -u llvm/include/llvm/Intrinsics.h:1.15 llvm/include/llvm/Intrinsics.h:1.16 --- llvm/include/llvm/Intrinsics.h:1.15 Mon Jan 5 23:32:17 2004 +++ llvm/include/llvm/Intrinsics.h Thu Feb 12 11:57:11 2004 @@ -44,6 +44,12 @@ dbg_func_start, // Start of a function dbg_declare, // Declare a local object + // Standard libc functions... + memcpy, + + // Standard libm functions... + + //===------------------------------------------------------------------===// // This section defines intrinsic functions used to represent Alpha // instructions... From lattner at cs.uiuc.edu Thu Feb 12 12:11:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Feb 12 12:11:02 2004 Subject: [llvm-commits] CVS: llvm/docs/LangRef.html Message-ID: <200402121810.MAA09389@apoc.cs.uiuc.edu> Changes in directory llvm/docs: LangRef.html updated: 1.44 -> 1.45 --- Log message: Add support for the llvm.memmove intrinsic. Patch graciously contributed by Reid Spencer! --- Diffs of the changes: (+48 -1) Index: llvm/docs/LangRef.html diff -u llvm/docs/LangRef.html:1.44 llvm/docs/LangRef.html:1.45 --- llvm/docs/LangRef.html:1.44 Thu Feb 12 11:01:32 2004 +++ llvm/docs/LangRef.html Thu Feb 12 12:09:57 2004 @@ -98,6 +98,7 @@
  • Standard C Library Intrinsics
    1. 'llvm.memcpy' Intrinsic
    2. +
    3. 'llvm.memmove' Intrinsic
  • Debugger intrinsics @@ -1790,6 +1791,52 @@ + + + +
    + +
    Syntax:
    +
    +  call void (sbyte*, sbyte*, uint, uint)* %llvm.memmove(sbyte* <dest>, sbyte* <src>,
    +                                                       uint <len>, uint <align>)
    +
    + +
    Overview:
    + +

    +The 'llvm.memmove' intrinsic moves a block of memory from the source +location to the destination location. It is similar to the 'llvm.memcpy' +intrinsic but allows the two memory locations to overlap. +

    + +

    +Note that, unlike the standard libc function, the llvm.memmove intrinsic +does not return a value, and takes an extra alignment argument. +

    + +
    Arguments:
    + +

    +The first argument is a pointer to the destination, the second is a pointer to +the source. The third argument is an (arbitrarily sized) integer argument +specifying the number of bytes to copy, and the fourth argument is the alignment +of the source and destination locations. +

    + +
    Semantics:
    + +

    +The 'llvm.memmove' intrinsic copies a block of memory from the source +location to the destination location, which may overlap. It +copies "len" bytes of memory over. If the argument is known to be aligned to +some boundary, this can be specified as the fourth argument, otherwise it should +be set to 0 or 1. +

    +
    +
    @@ -1811,6 +1858,6 @@ +Last modified: $Date: 2004/02/12 18:09:57 $
    From lattner at cs.uiuc.edu Thu Feb 12 12:11:10 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Feb 12 12:11:10 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Intrinsics.h Message-ID: <200402121810.MAA09382@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: Intrinsics.h updated: 1.16 -> 1.17 --- Log message: Add support for the llvm.memmove intrinsic. Patch graciously contributed by Reid Spencer! --- Diffs of the changes: (+3 -1) Index: llvm/include/llvm/Intrinsics.h diff -u llvm/include/llvm/Intrinsics.h:1.16 llvm/include/llvm/Intrinsics.h:1.17 --- llvm/include/llvm/Intrinsics.h:1.16 Thu Feb 12 11:57:11 2004 +++ llvm/include/llvm/Intrinsics.h Thu Feb 12 12:10:10 2004 @@ -45,7 +45,9 @@ dbg_declare, // Declare a local object // Standard libc functions... - memcpy, + memcpy, // Used to copy non-overlapping memory blocks + memmove, // Used to copy overlapping memory blocks + // Standard libm functions... From lattner at cs.uiuc.edu Thu Feb 12 12:12:03 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Feb 12 12:12:03 2004 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Function.cpp IntrinsicLowering.cpp Verifier.cpp Message-ID: <200402121811.MAA32516@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Function.cpp updated: 1.63 -> 1.64 IntrinsicLowering.cpp updated: 1.6 -> 1.7 Verifier.cpp updated: 1.79 -> 1.80 --- Log message: Add support for the llvm.memmove intrinsic Patch graciously contributed by Reid Spencer! --- Diffs of the changes: (+15 -0) Index: llvm/lib/VMCore/Function.cpp diff -u llvm/lib/VMCore/Function.cpp:1.63 llvm/lib/VMCore/Function.cpp:1.64 --- llvm/lib/VMCore/Function.cpp:1.63 Thu Feb 12 11:01:08 2004 +++ llvm/lib/VMCore/Function.cpp Thu Feb 12 12:11:20 2004 @@ -219,6 +219,7 @@ break; case 'm': if (getName() == "llvm.memcpy") return Intrinsic::memcpy; + if (getName() == "llvm.memmove") return Intrinsic::memmove; break; case 's': if (getName() == "llvm.setjmp") return Intrinsic::setjmp; Index: llvm/lib/VMCore/IntrinsicLowering.cpp diff -u llvm/lib/VMCore/IntrinsicLowering.cpp:1.6 llvm/lib/VMCore/IntrinsicLowering.cpp:1.7 --- llvm/lib/VMCore/IntrinsicLowering.cpp:1.6 Thu Feb 12 11:01:09 2004 +++ llvm/lib/VMCore/IntrinsicLowering.cpp Thu Feb 12 12:11:20 2004 @@ -71,6 +71,19 @@ CI->getName(), CI); break; } + case Intrinsic::memmove: { + // The memmove intrinsic take an extra alignment argument that the memcpy + // libc function does not. + const FunctionType *CFT = Callee->getFunctionType(); + FunctionType *FT = + FunctionType::get(*CFT->param_begin(), + std::vector(CFT->param_begin(), CFT->param_end()-1), + false); + Function *MemMove = M->getOrInsertFunction("memmove", FT); + new CallInst(MemMove, std::vector(CI->op_begin()+1, CI->op_end()-1), + CI->getName(), CI); + break; + } } assert(CI->use_empty() && Index: llvm/lib/VMCore/Verifier.cpp diff -u llvm/lib/VMCore/Verifier.cpp:1.79 llvm/lib/VMCore/Verifier.cpp:1.80 --- llvm/lib/VMCore/Verifier.cpp:1.79 Thu Feb 12 11:01:09 2004 +++ llvm/lib/VMCore/Verifier.cpp Thu Feb 12 12:11:20 2004 @@ -563,6 +563,7 @@ case Intrinsic::dbg_declare: NumArgs = 1; break; case Intrinsic::memcpy: NumArgs = 4; break; + case Intrinsic::memmove: NumArgs = 4; break; case Intrinsic::alpha_ctlz: NumArgs = 1; break; case Intrinsic::alpha_cttz: NumArgs = 1; break; From criswell at cs.uiuc.edu Thu Feb 12 12:13:03 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Thu Feb 12 12:13:03 2004 Subject: [llvm-commits] CVS: llvm/docs/TableGenFundamentals.html Message-ID: <200402121812.MAA31846@choi.cs.uiuc.edu> Changes in directory llvm/docs: TableGenFundamentals.html updated: 1.3 -> 1.4 --- Log message: Fixed minor typos. --- Diffs of the changes: (+10 -10) Index: llvm/docs/TableGenFundamentals.html diff -u llvm/docs/TableGenFundamentals.html:1.3 llvm/docs/TableGenFundamentals.html:1.4 --- llvm/docs/TableGenFundamentals.html:1.3 Fri Feb 6 00:37:00 2004 +++ llvm/docs/TableGenFundamentals.html Thu Feb 12 12:11:53 2004 @@ -299,7 +299,7 @@
  • "string" - The 'string' type represents an ordered sequence of characters of arbitrary length.
  • -
  • "bits<n>" - A 'bits' type is a arbitrary, but fixed, +
  • "bits<n>" - A 'bits' type is an arbitrary, but fixed, size integer that is broken up into individual bits. This type is useful because it can handle some bits being defined while others are undefined.
  • @@ -363,7 +363,7 @@

    -Note that all of the values have rules specifying how they convert to to values +Note that all of the values have rules specifying how they convert to values for different types. These rules allow you to assign a value like "7" to a "bits<4>" value, for example.

    @@ -387,8 +387,8 @@ href="templateargs">template arguments". If the record has superclasses, they are specified as a comma seperated list that starts with a colon character (":"). If value definitions or let -expressions are needed for the class they are enclosed in curly braces -("{}"), otherwise the record ends with a semicolon. Here is a simple TableGen +expressions are needed for the class, they are enclosed in curly braces +("{}"); otherwise, the record ends with a semicolon. Here is a simple TableGen file:

    @@ -408,7 +408,7 @@

    In general, classes are useful for collecting together the commonality between a -group of records, and isolating it in a single places. Also, classes permit the +group of records and isolating it in a single place. Also, classes permit the specification of default values for their subclasses, allowing the subclasses to override them as they wish.

    @@ -423,7 +423,7 @@

    Value definitions define named entries in records. A value must be defined -before it can be referred to as the operand for another value definition, or +before it can be referred to as the operand for another value definition or before the value is reset with a let expression. A value is defined by specifying a TableGen type and a name. If an initial value is available, it may be specified after the type with an @@ -439,9 +439,9 @@

    A record-level let expression is used to change the value of a value definition in a record. This is primarily useful when a superclass defines a value that a -derived class or definitions wants to override. Let expressions consist of the -'let' keyword, followed by a value name, an equal sign ("="), and a new -value for example, a new class could be added to the example above, redefining +derived class or definition wants to override. Let expressions consist of the +'let' keyword followed by a value name, an equal sign ("="), and a new +value. For example, a new class could be added to the example above, redefining the V field for all of its subclasses:

    @@ -646,7 +646,7 @@
       
    Chris Lattner
    The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/02/06 06:37:00 $ + Last modified: $Date: 2004/02/12 18:11:53 $
    From alkis at cs.uiuc.edu Thu Feb 12 12:50:04 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Thu Feb 12 12:50:04 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/MachineInstr.h MachineBasicBlock.h Message-ID: <200402121849.MAA13644@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: MachineInstr.h updated: 1.133 -> 1.134 MachineBasicBlock.h updated: 1.14 -> 1.15 --- Log message: Add parent pointer to MachineInstr that points to owning MachineBasicBlock. Also change opcode to a short and numImplicitRefs to an unsigned char so that overall MachineInstr's size stays the same. --- Diffs of the changes: (+61 -16) Index: llvm/include/llvm/CodeGen/MachineInstr.h diff -u llvm/include/llvm/CodeGen/MachineInstr.h:1.133 llvm/include/llvm/CodeGen/MachineInstr.h:1.134 --- llvm/include/llvm/CodeGen/MachineInstr.h:1.133 Thu Feb 12 10:09:53 2004 +++ llvm/include/llvm/CodeGen/MachineInstr.h Thu Feb 12 12:49:07 2004 @@ -17,7 +17,7 @@ #define LLVM_CODEGEN_MACHINEINSTR_H #include "Support/Annotation.h" -#include "Support/iterator" +#include "Support/ilist" #include namespace llvm { @@ -29,8 +29,9 @@ class GlobalValue; template class ilist_traits; +template class ilist; -typedef int MachineOpCode; +typedef short MachineOpCode; //===----------------------------------------------------------------------===// /// MOTy - MachineOperandType - This namespace contains an enum that describes @@ -332,10 +333,11 @@ //===----------------------------------------------------------------------===// class MachineInstr { - int Opcode; // the opcode + short Opcode; // the opcode + unsigned char numImplicitRefs; // number of implicit operands std::vector operands; // the operands - unsigned numImplicitRefs; // number of implicit operands MachineInstr* prev, *next; // links for our intrusive list + MachineBasicBlock* parent; // pointer to the owning basic block // OperandComplete - Return true if it's illegal to add a new operand bool OperandsComplete() const; @@ -346,29 +348,26 @@ // Intrusive list support // friend class ilist_traits; - MachineInstr() { /* this is for ilist use only to create the sentinel */ } - MachineInstr* getPrev() const { return prev; } - MachineInstr* getNext() const { return next; } - - void setPrev(MachineInstr* mi) { prev = mi; } - void setNext(MachineInstr* mi) { next = mi; } public: - MachineInstr(int Opcode, unsigned numOperands); + MachineInstr(short Opcode, unsigned numOperands); /// MachineInstr ctor - This constructor only does a _reserve_ of the /// operands, not a resize for them. It is expected that if you use this that /// you call add* methods below to fill up the operands, instead of the Set /// methods. Eventually, the "resizing" ctors will be phased out. /// - MachineInstr(int Opcode, unsigned numOperands, bool XX, bool YY); + MachineInstr(short Opcode, unsigned numOperands, bool XX, bool YY); /// MachineInstr ctor - Work exactly the same as the ctor above, except that /// the MachineInstr is created and added to the end of the specified basic /// block. /// - MachineInstr(MachineBasicBlock *MBB, int Opcode, unsigned numOps); + MachineInstr(MachineBasicBlock *MBB, short Opcode, unsigned numOps); + const MachineBasicBlock* getParent() const { return parent; } + MachineBasicBlock* getParent() { return parent; } + /// Accessors for opcode. /// const int getOpcode() const { return Opcode; } @@ -587,7 +586,7 @@ /// simply replace() and then set new operands with Set.*Operand methods /// below. /// - void replace(int Opcode, unsigned numOperands); + void replace(short Opcode, unsigned numOperands); /// setOpcode - Replace the opcode of the current instruction with a new one. /// @@ -695,6 +694,51 @@ } }; +// ilist_traits +template <> +class ilist_traits +{ + typedef ilist_traits self; + + // this is only set by the MachineBasicBlock owning the ilist + friend class MachineBasicBlock; + MachineBasicBlock* parent; + +public: + ilist_traits() : parent(0) { } + + static MachineInstr* getPrev(MachineInstr* N) { return N->prev; } + static MachineInstr* getNext(MachineInstr* N) { return N->next; } + + static const MachineInstr* + getPrev(const MachineInstr* N) { return N->prev; } + + static const MachineInstr* + getNext(const MachineInstr* N) { return N->next; } + + static void setPrev(MachineInstr* N, MachineInstr* prev) { N->prev = prev; } + static void setNext(MachineInstr* N, MachineInstr* next) { N->next = next; } + + static MachineInstr* createNode() { return new MachineInstr(0, 0); } + + void addNodeToList(MachineInstr* N) { + assert(N->parent == 0 && "machine instruction already in a basic block"); + N->parent = parent; + } + + void removeNodeFromList(MachineInstr* N) { + assert(N->parent != 0 && "machine instruction not in a basic block"); + N->parent = 0; + } + + void transferNodesFromList(iplist& toList, + ilist_iterator first, + ilist_iterator last) { + if (parent != toList.parent) + for (; first != last; ++first) + first->parent = toList.parent; + } +}; //===----------------------------------------------------------------------===// // Debugging Support Index: llvm/include/llvm/CodeGen/MachineBasicBlock.h diff -u llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.14 llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.15 --- llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.14 Wed Feb 11 20:27:10 2004 +++ llvm/include/llvm/CodeGen/MachineBasicBlock.h Thu Feb 12 12:49:07 2004 @@ -15,7 +15,6 @@ #define LLVM_CODEGEN_MACHINEBASICBLOCK_H #include "llvm/CodeGen/MachineInstr.h" -#include "Support/ilist" namespace llvm { @@ -28,7 +27,9 @@ MachineBasicBlock *Prev, *Next; const BasicBlock *BB; public: - MachineBasicBlock(const BasicBlock *bb = 0) : Prev(0), Next(0), BB(bb) {} + MachineBasicBlock(const BasicBlock *bb = 0) : Prev(0), Next(0), BB(bb) { + Insts.parent = this; + } ~MachineBasicBlock() {} /// getBasicBlock - Return the LLVM basic block that this instance From alkis at cs.uiuc.edu Thu Feb 12 12:50:12 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Thu Feb 12 12:50:12 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Target/TargetInstrInfo.h Message-ID: <200402121849.MAA13633@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Target: TargetInstrInfo.h updated: 1.54 -> 1.55 --- Log message: Add parent pointer to MachineInstr that points to owning MachineBasicBlock. Also change opcode to a short and numImplicitRefs to an unsigned char so that overall MachineInstr's size stays the same. --- Diffs of the changes: (+1 -1) Index: llvm/include/llvm/Target/TargetInstrInfo.h diff -u llvm/include/llvm/Target/TargetInstrInfo.h:1.54 llvm/include/llvm/Target/TargetInstrInfo.h:1.55 --- llvm/include/llvm/Target/TargetInstrInfo.h:1.54 Wed Feb 11 13:47:43 2004 +++ llvm/include/llvm/Target/TargetInstrInfo.h Thu Feb 12 12:49:07 2004 @@ -33,7 +33,7 @@ // Data types used to define information about a single machine instruction //--------------------------------------------------------------------------- -typedef int MachineOpCode; +typedef short MachineOpCode; typedef unsigned InstrSchedClass; const MachineOpCode INVALID_MACHINE_OPCODE = -1; From alkis at cs.uiuc.edu Thu Feb 12 12:50:19 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Thu Feb 12 12:50:19 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/MachineInstr.cpp Message-ID: <200402121849.MAA13628@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: MachineInstr.cpp updated: 1.86 -> 1.87 --- Log message: Add parent pointer to MachineInstr that points to owning MachineBasicBlock. Also change opcode to a short and numImplicitRefs to an unsigned char so that overall MachineInstr's size stays the same. --- Diffs of the changes: (+14 -7) Index: llvm/lib/CodeGen/MachineInstr.cpp diff -u llvm/lib/CodeGen/MachineInstr.cpp:1.86 llvm/lib/CodeGen/MachineInstr.cpp:1.87 --- llvm/lib/CodeGen/MachineInstr.cpp:1.86 Thu Feb 12 10:09:31 2004 +++ llvm/lib/CodeGen/MachineInstr.cpp Thu Feb 12 12:49:06 2004 @@ -28,8 +28,11 @@ extern const TargetInstrDescriptor *TargetInstrDescriptors; // Constructor for instructions with variable #operands -MachineInstr::MachineInstr(MachineOpCode opcode, unsigned numOperands) - : Opcode(opcode), operands(numOperands, MachineOperand()), numImplicitRefs(0){ +MachineInstr::MachineInstr(short opcode, unsigned numOperands) + : Opcode(opcode), + numImplicitRefs(0), + operands(numOperands, MachineOperand()), + parent(0) { } /// MachineInstr ctor - This constructor only does a _reserve_ of the operands, @@ -37,18 +40,22 @@ /// add* methods below to fill up the operands, instead of the Set methods. /// Eventually, the "resizing" ctors will be phased out. /// -MachineInstr::MachineInstr(MachineOpCode opcode, unsigned numOperands, +MachineInstr::MachineInstr(short opcode, unsigned numOperands, bool XX, bool YY) - : Opcode(opcode), numImplicitRefs(0) { + : Opcode(opcode), + numImplicitRefs(0), + parent(0) { operands.reserve(numOperands); } /// MachineInstr ctor - Work exactly the same as the ctor above, except that the /// MachineInstr is created and added to the end of the specified basic block. /// -MachineInstr::MachineInstr(MachineBasicBlock *MBB, MachineOpCode opcode, +MachineInstr::MachineInstr(MachineBasicBlock *MBB, short opcode, unsigned numOperands) - : Opcode(opcode), numImplicitRefs(0) { + : Opcode(opcode), + numImplicitRefs(0), + parent(0) { assert(MBB && "Cannot use inserting ctor with null basic block!"); operands.reserve(numOperands); MBB->push_back(this); // Add instruction to end of basic block! @@ -69,7 +76,7 @@ // This only resets the size of the operand vector and initializes it. // The new operands must be set explicitly later. // -void MachineInstr::replace(MachineOpCode opcode, unsigned numOperands) { +void MachineInstr::replace(short opcode, unsigned numOperands) { assert(getNumImplicitRefs() == 0 && "This is probably broken because implicit refs are going to be lost."); Opcode = opcode; From alkis at cs.uiuc.edu Thu Feb 12 13:13:02 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Thu Feb 12 13:13:02 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/MachineInstr.h MachineBasicBlock.h Message-ID: <200402121912.NAA28256@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: MachineInstr.h updated: 1.134 -> 1.135 MachineBasicBlock.h updated: 1.15 -> 1.16 --- Log message: Move ilist_trairs in MachineBasicBlock. --- Diffs of the changes: (+49 -47) Index: llvm/include/llvm/CodeGen/MachineInstr.h diff -u llvm/include/llvm/CodeGen/MachineInstr.h:1.134 llvm/include/llvm/CodeGen/MachineInstr.h:1.135 --- llvm/include/llvm/CodeGen/MachineInstr.h:1.134 Thu Feb 12 12:49:07 2004 +++ llvm/include/llvm/CodeGen/MachineInstr.h Thu Feb 12 13:12:03 2004 @@ -17,7 +17,7 @@ #define LLVM_CODEGEN_MACHINEINSTR_H #include "Support/Annotation.h" -#include "Support/ilist" +#include "Support/iterator" #include namespace llvm { @@ -348,6 +348,7 @@ // Intrusive list support // friend class ilist_traits; + MachineInstr() : Opcode(0), numImplicitRefs(0) { /* used only by ilist */ } public: MachineInstr(short Opcode, unsigned numOperands); @@ -691,52 +692,6 @@ } const_val_op_iterator end() const { return const_val_op_iterator::end(this); - } -}; - -// ilist_traits -template <> -class ilist_traits -{ - typedef ilist_traits self; - - // this is only set by the MachineBasicBlock owning the ilist - friend class MachineBasicBlock; - MachineBasicBlock* parent; - -public: - ilist_traits() : parent(0) { } - - static MachineInstr* getPrev(MachineInstr* N) { return N->prev; } - static MachineInstr* getNext(MachineInstr* N) { return N->next; } - - static const MachineInstr* - getPrev(const MachineInstr* N) { return N->prev; } - - static const MachineInstr* - getNext(const MachineInstr* N) { return N->next; } - - static void setPrev(MachineInstr* N, MachineInstr* prev) { N->prev = prev; } - static void setNext(MachineInstr* N, MachineInstr* next) { N->next = next; } - - static MachineInstr* createNode() { return new MachineInstr(0, 0); } - - void addNodeToList(MachineInstr* N) { - assert(N->parent == 0 && "machine instruction already in a basic block"); - N->parent = parent; - } - - void removeNodeFromList(MachineInstr* N) { - assert(N->parent != 0 && "machine instruction not in a basic block"); - N->parent = 0; - } - - void transferNodesFromList(iplist& toList, - ilist_iterator first, - ilist_iterator last) { - if (parent != toList.parent) - for (; first != last; ++first) - first->parent = toList.parent; } }; Index: llvm/include/llvm/CodeGen/MachineBasicBlock.h diff -u llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.15 llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.16 --- llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.15 Thu Feb 12 12:49:07 2004 +++ llvm/include/llvm/CodeGen/MachineBasicBlock.h Thu Feb 12 13:12:03 2004 @@ -15,8 +15,55 @@ #define LLVM_CODEGEN_MACHINEBASICBLOCK_H #include "llvm/CodeGen/MachineInstr.h" +#include "Support/ilist" namespace llvm { + +// ilist_traits +template <> +class ilist_traits +{ + typedef ilist_traits self; + + // this is only set by the MachineBasicBlock owning the ilist + friend class MachineBasicBlock; + MachineBasicBlock* parent; + +public: + ilist_traits() : parent(0) { } + + static MachineInstr* getPrev(MachineInstr* N) { return N->prev; } + static MachineInstr* getNext(MachineInstr* N) { return N->next; } + + static const MachineInstr* + getPrev(const MachineInstr* N) { return N->prev; } + + static const MachineInstr* + getNext(const MachineInstr* N) { return N->next; } + + static void setPrev(MachineInstr* N, MachineInstr* prev) { N->prev = prev; } + static void setNext(MachineInstr* N, MachineInstr* next) { N->next = next; } + + static MachineInstr* createNode() { return new MachineInstr(0, 0); } + + void addNodeToList(MachineInstr* N) { + assert(N->parent == 0 && "machine instruction already in a basic block"); + N->parent = parent; + } + + void removeNodeFromList(MachineInstr* N) { + assert(N->parent != 0 && "machine instruction not in a basic block"); + N->parent = 0; + } + + void transferNodesFromList(iplist& toList, + ilist_iterator first, + ilist_iterator last) { + if (parent != toList.parent) + for (; first != last; ++first) + first->parent = toList.parent; + } +}; class BasicBlock; From lattner at cs.uiuc.edu Thu Feb 12 15:05:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Feb 12 15:05:01 2004 Subject: [llvm-commits] CVS: gcc-3.4/gcc/llvm-expand.c Message-ID: <200402122104.PAA00730@zion.cs.uiuc.edu> Changes in directory gcc-3.4/gcc: llvm-expand.c updated: 1.8 -> 1.9 --- Log message: Make llvm_copy_aggregate emit a call to llvm.memcpy if the copied aggregate is large. Also implement the __builtin_memcpy intrinsic in GCC in terms of llvm.memcpy. Also fix an apparent bug in the llvm_expand_call code which used a value that was never defined. --- Diffs of the changes: (+64 -18) Index: gcc-3.4/gcc/llvm-expand.c diff -u gcc-3.4/gcc/llvm-expand.c:1.8 gcc-3.4/gcc/llvm-expand.c:1.9 --- gcc-3.4/gcc/llvm-expand.c:1.8 Thu Feb 5 10:05:45 2004 +++ gcc-3.4/gcc/llvm-expand.c Thu Feb 12 15:04:48 2004 @@ -307,21 +307,45 @@ } } +static void EmitMemcpy(llvm_function *Fn, llvm_value *DestPtr, + llvm_value *SrcPtr, llvm_value *Size, + unsigned Alignment) { + static llvm_function *llvm_memcpy_fn = 0; + static llvm_type *size_tTy = 0; + + llvm_instruction *I; + if (!llvm_memcpy_fn) { + llvm_type *FnTy = llvm_type_create_function(4, VoidTy); + FnTy->Elements[1] = FnTy->Elements[2] = VoidPtrTy; + FnTy->Elements[3] = size_tTy = llvm_type_get_from_tree(size_type_node); + FnTy->Elements[4] = UIntTy; + FnTy = llvm_type_get_cannonical_function(FnTy); + llvm_memcpy_fn = CreateIntrinsicFnWithType("llvm.memcpy", FnTy); + } + + I = llvm_instruction_new(VoidTy, "", O_Call, 5); + I->Operands[0] = G2V(llvm_memcpy_fn); + I->Operands[1] = cast_if_type_not_equal(Fn, DestPtr, VoidPtrTy); + I->Operands[2] = cast_if_type_not_equal(Fn, SrcPtr, VoidPtrTy); + I->Operands[3] = cast_if_type_not_equal(Fn, Size, size_tTy); + I->Operands[4] = llvm_constant_new_integral(UIntTy, Alignment); + append_inst(Fn, I); +} + + /* llvm_copy_aggregate - Given two pointers to structures, copy *SrcPtr into * *DestPtr, element by element. * - * FIXME: for objects of non-trivial complexity, we could instead call a - * "assignment" function to perform the copy. This could save a lot of code - * space. We would have to mark the generated function as linkonce. */ static void llvm_copy_aggregate(llvm_function *Fn, llvm_value *DestPtr, llvm_value *SrcPtr, int isSourceVolatile, - int isDestVolatile) { + int isDestVolatile, unsigned Alignment) { llvm_type *ObjTy; unsigned i; assert(DestPtr && SrcPtr && "Cannot copy from null ptr!"); assert(DestPtr->Ty == SrcPtr->Ty && "Cannot copy incompatible structs!"); - if (DestPtr == SrcPtr) return; /* X = X; --> Noop */ + if (DestPtr == SrcPtr && !isSourceVolatile && !isDestVolatile) + return; /* X = X; --> Noop */ /* Get the type of the object being copied... */ ObjTy = GET_POINTER_TYPE_ELEMENT(DestPtr->Ty); @@ -334,6 +358,15 @@ return; } + /* If this is a large object copy, emit a call to the llvm.memcpy intrinsic. + */ + if (llvm_type_get_size(ObjTy) > 128) { + EmitMemcpy(Fn, DestPtr, SrcPtr, + llvm_constant_new_integral(LongTy, llvm_type_get_size(ObjTy)), + Alignment); + return; + } + /* Copy aggregate values recursively... */ switch (ObjTy->ID) { case StructTyID: @@ -345,7 +378,7 @@ llvm_constant_long_0, FieldNo)); llvm_copy_aggregate(Fn, DestElPtr, SrcElPtr, - isSourceVolatile, isDestVolatile); + isSourceVolatile, isDestVolatile, 1); } break; @@ -357,7 +390,7 @@ llvm_value *SrcElPtr = append_inst(Fn, create_gep3(SrcPtr, llvm_constant_long_0, FieldNo)); llvm_copy_aggregate(Fn, DestElPtr, SrcElPtr, - isSourceVolatile, isDestVolatile); + isSourceVolatile, isDestVolatile, 1); } break; } @@ -2764,7 +2797,7 @@ /* If this argument is passed by invisible reference... */ if (isPassedByInvisibleReference(TREE_TYPE(TREE_VALUE(arg)))) { /* Get the address of the parameters passed in. */ - llvm_value *ArgAddr = llvm_expand_lvalue_expr(Fn, TREE_VALUE(arg), 0, 0); + ArgVal = llvm_expand_lvalue_expr(Fn, TREE_VALUE(arg), 0, 0); if (ArgTy) ArgVal = cast_if_type_not_equal(Fn, ArgVal, ArgTy); Call->Operands[NumArgs+ArgOffset] = ArgVal; CalledFuncType->Elements[1+NumArgs] = ArgVal->Ty; @@ -3934,6 +3967,20 @@ return CreateIntrinsicFnWithType(Name, FnTy); } +static llvm_value *llvm_expand_builtin_memcpy(llvm_function *Fn, tree arglist) { + llvm_value *Op0, *Op1, *Op2; + + Op0 = llvm_expand_expr(Fn, TREE_VALUE(arglist), 0); + arglist = TREE_CHAIN(arglist); + Op1 = llvm_expand_expr(Fn, TREE_VALUE(arglist), 0); + arglist = TREE_CHAIN(arglist); + Op2 = llvm_expand_expr(Fn, TREE_VALUE(arglist), 0); + + EmitMemcpy(Fn, Op0, Op1, Op2, 1); + return Op0; +} + + static void llvm_expand_builtin_va_start(llvm_function *Fn, tree exp) { tree arglist = TREE_OPERAND (exp, 1); @@ -4094,7 +4141,6 @@ case BUILT_IN_ATAN2F: case BUILT_IN_ATAN2L: case BUILT_IN_MEMSET: - case BUILT_IN_MEMCPY: case BUILT_IN_MEMCMP: case BUILT_IN_BCMP: case BUILT_IN_BZERO: @@ -4142,6 +4188,10 @@ case BUILT_IN_NEARBYINTF: case BUILT_IN_NEARBYINTL: return llvm_expand_call (Fn, exp, DestLoc); + + case BUILT_IN_MEMCPY: + assert(DestLoc == 0 && "memcpy doesn't return aggregate!"); + return llvm_expand_builtin_memcpy(Fn, arglist); default: break; } @@ -4395,12 +4445,6 @@ return target; break; - case BUILT_IN_MEMCPY: - target = expand_builtin_memcpy (arglist, target, mode); - if (target) - return target; - break; - case BUILT_IN_MEMSET: target = expand_builtin_memset (exp, target, mode); if (target) @@ -5459,8 +5503,9 @@ Result = ReadBitField(Fn, Result, BitStart, BitSize); } else if (DestLoc) { /* Generating structure, using value */ + unsigned Align = TYPE_ALIGN(TREE_TYPE(exp))/8; assert(BitSize == 0 && "Invalid bitfield read of composite value!"); - llvm_copy_aggregate(Fn, DestLoc, op0, expVolatile, 0); + llvm_copy_aggregate(Fn, DestLoc, op0, expVolatile, 0, Align); } } break; /* Generating structure, ignoring value */ @@ -5487,7 +5532,8 @@ if (!isDestTyComposite) { /* Return a normal scalar by loading it */ Result = append_inst(Fn, create_load_inst("tmp", op0, expVolatile)); } else { - llvm_copy_aggregate(Fn, DestLoc, op0, expVolatile, 0); + unsigned Align = TYPE_ALIGN(TREE_TYPE(exp))/8; + llvm_copy_aggregate(Fn, DestLoc, op0, expVolatile, 0, Align); } break; } @@ -5948,7 +5994,7 @@ */ if (DestLoc) llvm_copy_aggregate(Fn, DestLoc, op0, - TYPE_VOLATILE(TREE_TYPE(TREE_OPERAND (exp, 0))), 0); + TYPE_VOLATILE(TREE_TYPE(TREE_OPERAND (exp, 0))), 0,1); break; From lattner at cs.uiuc.edu Thu Feb 12 15:08:03 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Feb 12 15:08:03 2004 Subject: [llvm-commits] CVS: llvm/test/Regression/CFrontend/2004-02-12-LargeAggregateCopy.c.tr Message-ID: <200402122107.PAA00801@zion.cs.uiuc.edu> Changes in directory llvm/test/Regression/CFrontend: 2004-02-12-LargeAggregateCopy.c.tr added (r1.1) --- Log message: New testcase for PR233: [llvmgcc] Structure copies result in a LOT of code --- Diffs of the changes: (+8 -0) Index: llvm/test/Regression/CFrontend/2004-02-12-LargeAggregateCopy.c.tr diff -c /dev/null llvm/test/Regression/CFrontend/2004-02-12-LargeAggregateCopy.c.tr:1.1 *** /dev/null Thu Feb 12 15:07:02 2004 --- llvm/test/Regression/CFrontend/2004-02-12-LargeAggregateCopy.c.tr Thu Feb 12 15:06:52 2004 *************** *** 0 **** --- 1,8 ---- + // RUN: %llvmgcc -xc %s -c -o - | llvm-dis | grep llvm.memcpy + + struct X { int V[10000]; }; + struct X Global1, Global2; + void test() { + Global2 = Global1; + } + From lattner at cs.uiuc.edu Thu Feb 12 15:19:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Feb 12 15:19:02 2004 Subject: [llvm-commits] CVS: llvm/docs/LangRef.html Message-ID: <200402122118.PAA03774@zion.cs.uiuc.edu> Changes in directory llvm/docs: LangRef.html updated: 1.45 -> 1.46 --- Log message: Be a bit more specific about what the alignment value means and the restrictions on it --- Diffs of the changes: (+13 -1) Index: llvm/docs/LangRef.html diff -u llvm/docs/LangRef.html:1.45 llvm/docs/LangRef.html:1.46 --- llvm/docs/LangRef.html:1.45 Thu Feb 12 12:09:57 2004 +++ llvm/docs/LangRef.html Thu Feb 12 15:18:15 2004 @@ -1779,6 +1779,12 @@ of the source and destination locations.

    +

    +If the call to this intrinisic has an alignment value that is not 0 or 1, then +the caller guarantees that the size of the copy is a multiple of the alignment +and that both the source and destination pointers are aligned to that boundary. +

    +
    Semantics:

    @@ -1826,6 +1832,12 @@ of the source and destination locations.

    +

    +If the call to this intrinisic has an alignment value that is not 0 or 1, then +the caller guarantees that the size of the copy is a multiple of the alignment +and that both the source and destination pointers are aligned to that boundary. +

    +
    Semantics:

    @@ -1858,6 +1870,6 @@

    +Last modified: $Date: 2004/02/12 21:18:15 $ From lattner at cs.uiuc.edu Thu Feb 12 15:22:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Feb 12 15:22:02 2004 Subject: [llvm-commits] CVS: llvm-www/releases/1.1/docs/ReleaseNotes.html Message-ID: <200402122121.PAA11875@zion.cs.uiuc.edu> Changes in directory llvm-www/releases/1.1/docs: ReleaseNotes.html updated: 1.23 -> 1.24 --- Log message: Bug --- Diffs of the changes: (+3 -1) Index: llvm-www/releases/1.1/docs/ReleaseNotes.html diff -u llvm-www/releases/1.1/docs/ReleaseNotes.html:1.23 llvm-www/releases/1.1/docs/ReleaseNotes.html:1.24 --- llvm-www/releases/1.1/docs/ReleaseNotes.html:1.23 Mon Feb 9 23:20:54 2004 +++ llvm-www/releases/1.1/docs/ReleaseNotes.html Thu Feb 12 15:21:28 2004 @@ -436,6 +436,8 @@
  • [llvm-gcc] miscompilation of 'X = Y = Z' with aggregate values
  • + +
  • [llvmgcc] Structure copies result in a LOT of code
  • @@ -746,7 +748,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/02/10 05:20:54 $ + Last modified: $Date: 2004/02/12 21:21:28 $ From lattner at cs.uiuc.edu Thu Feb 12 15:22:09 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Feb 12 15:22:09 2004 Subject: [llvm-commits] CVS: llvm/docs/ReleaseNotes.html Message-ID: <200402122121.PAA10955@zion.cs.uiuc.edu> Changes in directory llvm/docs: ReleaseNotes.html updated: 1.119 -> 1.120 --- Log message: New features --- Diffs of the changes: (+3 -1) Index: llvm/docs/ReleaseNotes.html diff -u llvm/docs/ReleaseNotes.html:1.119 llvm/docs/ReleaseNotes.html:1.120 --- llvm/docs/ReleaseNotes.html:1.119 Mon Feb 9 23:22:23 2004 +++ llvm/docs/ReleaseNotes.html Thu Feb 12 15:21:17 2004 @@ -145,6 +145,7 @@
    1. [loopsimplify] Many pointless phi nodes are created
    2. The X86 backend didn't generate fchs to negate floating point numbers
    3. +
    4. The X86 backend didn't expand memcpy() into the rep movs instruction
    @@ -184,6 +185,7 @@
  • [llvmg++] Dynamically initialized constants cannot be marked 'constant'
  • [llvmgcc] floating-point unary minus is incorrect for +0.0
  • [llvm-gcc] miscompilation of 'X = Y = Z' with aggregate values
  • +
  • [llvmgcc] Structure copies result in a LOT of code
  • @@ -576,7 +578,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/02/10 05:22:23 $ + Last modified: $Date: 2004/02/12 21:21:17 $ From lattner at cs.uiuc.edu Thu Feb 12 17:14:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Feb 12 17:14:01 2004 Subject: [llvm-commits] CVS: llvm/lib/CWriter/Writer.cpp Message-ID: <200402122313.RAA29794@zion.cs.uiuc.edu> Changes in directory llvm/lib/CWriter: Writer.cpp updated: 1.154 -> 1.155 --- Log message: Add support for memcpy and memmove intrinsics. Why isn't the cwriter using the intrinsiclowering code?? :( --- Diffs of the changes: (+18 -0) Index: llvm/lib/CWriter/Writer.cpp diff -u llvm/lib/CWriter/Writer.cpp:1.154 llvm/lib/CWriter/Writer.cpp:1.155 --- llvm/lib/CWriter/Writer.cpp:1.154 Sun Feb 8 22:37:29 2004 +++ llvm/lib/CWriter/Writer.cpp Thu Feb 12 17:13:33 2004 @@ -1302,6 +1302,24 @@ // exception throw. Out << "abort()"; return; + case Intrinsic::memcpy: + Out << "memcpy("; + writeOperand(I.getOperand(1)); + Out << ", "; + writeOperand(I.getOperand(2)); + Out << ", "; + writeOperand(I.getOperand(3)); + Out << ")"; + return; + case Intrinsic::memmove: + Out << "memmove("; + writeOperand(I.getOperand(1)); + Out << ", "; + writeOperand(I.getOperand(2)); + Out << ", "; + writeOperand(I.getOperand(3)); + Out << ")"; + return; } } visitCallSite(&I); From alkis at evlogimenos.com Thu Feb 12 18:34:02 2004 From: alkis at evlogimenos.com (Alkis Evlogimenos) Date: Thu Feb 12 18:34:02 2004 Subject: [llvm-commits] CVS: llvm/docs/ReleaseNotes.html In-Reply-To: <200402122121.PAA10955@zion.cs.uiuc.edu> References: <200402122121.PAA10955@zion.cs.uiuc.edu> Message-ID: <200402121830.26564.alkis@evlogimenos.com> On Thursday 12 February 2004 03:21 pm, Chris Lattner wrote: > > Changes in directory llvm/docs: > > ReleaseNotes.html updated: 1.119 -> 1.120 > > --- > Log message: > > New features > > > --- > Diffs of the changes: (+3 -1) > > Index: llvm/docs/ReleaseNotes.html > diff -u llvm/docs/ReleaseNotes.html:1.119 llvm/docs/ReleaseNotes.html:1.120 > --- llvm/docs/ReleaseNotes.html:1.119 Mon Feb 9 23:22:23 2004 > +++ llvm/docs/ReleaseNotes.html Thu Feb 12 15:21:17 2004 > @@ -145,6 +145,7 @@ >
      >
    1. [loopsimplify] Many pointless phi nodes are created
    2. >
    3. The X86 backend didn't generate fchs to negate floating point numbers
    4. > +
    5. The X86 backend didn't expand memcpy() into the rep movs instruction
    6. >
    Does gcc do this? Is it faster than the normal code due to implementation or because the code is much more compact? -- Alkis From sabre at nondot.org Thu Feb 12 22:33:02 2004 From: sabre at nondot.org (Chris Lattner) Date: Thu Feb 12 22:33:02 2004 Subject: [llvm-commits] CVS: llvm/docs/ReleaseNotes.html In-Reply-To: <200402121830.26564.alkis@evlogimenos.com> Message-ID: On Thu, 12 Feb 2004, Alkis Evlogimenos wrote: > > Index: llvm/docs/ReleaseNotes.html > > diff -u llvm/docs/ReleaseNotes.html:1.119 llvm/docs/ReleaseNotes.html:1.120 > > --- llvm/docs/ReleaseNotes.html:1.119 Mon Feb 9 23:22:23 2004 > > +++ llvm/docs/ReleaseNotes.html Thu Feb 12 15:21:17 2004 > > @@ -145,6 +145,7 @@ > >
      > >
    1. [loopsimplify] Many pointless phi nodes are created
    2. > >
    3. The X86 backend didn't generate fchs to negate floating point numbers
    4. > > +
    5. The X86 backend didn't expand memcpy() into the rep movs instruction
    6. > >
    > > Does gcc do this? Is it faster than the normal code due to > implementation or because the code is much more compact? Yes, GCC does it. Both. Also it's typical for the hardware to implement prefetching for large copies... -Chris -- http://llvm.cs.uiuc.edu/ http://www.nondot.org/~sabre/Projects/ From gaeke at cs.uiuc.edu Thu Feb 12 22:40:25 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Thu Feb 12 22:40:25 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/MachineInstr.cpp Message-ID: <200402130439.WAA07351@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: MachineInstr.cpp updated: 1.87 -> 1.88 --- Log message: Add head-of-file comments and Doxygen comments. Tighten up a lot of whitespace. Rename SetMachineOperandConst's formal parameters to match other methods here. Mark some methods as being used only by the SPARC back-end. Fix a missing-paren bug in OutputValue(). --- Diffs of the changes: (+32 -36) Index: llvm/lib/CodeGen/MachineInstr.cpp diff -u llvm/lib/CodeGen/MachineInstr.cpp:1.87 llvm/lib/CodeGen/MachineInstr.cpp:1.88 --- llvm/lib/CodeGen/MachineInstr.cpp:1.87 Thu Feb 12 12:49:06 2004 +++ llvm/lib/CodeGen/MachineInstr.cpp Thu Feb 12 22:39:32 2004 @@ -6,7 +6,12 @@ // the University of Illinois Open Source License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// -// +// +// Methods common to all machine instructions. +// +// FIXME: Now that MachineInstrs have parent pointers, they should always +// print themselves using their MachineFunction's TargetMachine. +// //===----------------------------------------------------------------------===// #include "llvm/CodeGen/MachineInstr.h" @@ -40,11 +45,8 @@ /// add* methods below to fill up the operands, instead of the Set methods. /// Eventually, the "resizing" ctors will be phased out. /// -MachineInstr::MachineInstr(short opcode, unsigned numOperands, - bool XX, bool YY) - : Opcode(opcode), - numImplicitRefs(0), - parent(0) { +MachineInstr::MachineInstr(short opcode, unsigned numOperands, bool XX, bool YY) + : Opcode(opcode), numImplicitRefs(0), parent(0) { operands.reserve(numOperands); } @@ -53,16 +55,14 @@ /// MachineInstr::MachineInstr(MachineBasicBlock *MBB, short opcode, unsigned numOperands) - : Opcode(opcode), - numImplicitRefs(0), - parent(0) { + : Opcode(opcode), numImplicitRefs(0), parent(0) { assert(MBB && "Cannot use inserting ctor with null basic block!"); operands.reserve(numOperands); MBB->push_back(this); // Add instruction to end of basic block! } - -// OperandComplete - Return true if it's illegal to add a new operand +/// OperandComplete - Return true if it's illegal to add a new operand +/// bool MachineInstr::OperandsComplete() const { int NumOperands = TargetInstrDescriptors[Opcode].numOperands; if (NumOperands >= 0 && getNumOperands() >= (unsigned)NumOperands) @@ -70,12 +70,10 @@ return false; } - -// -// Support for replacing opcode and operands of a MachineInstr in place. -// This only resets the size of the operand vector and initializes it. -// The new operands must be set explicitly later. -// +/// replace - Support for replacing opcode and operands of a MachineInstr in +/// place. This only resets the size of the operand vector and initializes it. +/// The new operands must be set explicitly later. +/// void MachineInstr::replace(short opcode, unsigned numOperands) { assert(getNumImplicitRefs() == 0 && "This is probably broken because implicit refs are going to be lost."); @@ -95,13 +93,13 @@ void MachineInstr::SetMachineOperandConst(unsigned i, - MachineOperand::MachineOperandType operandType, + MachineOperand::MachineOperandType opTy, int64_t intValue) { assert(i < getNumOperands()); // must be explicit op assert(TargetInstrDescriptors[Opcode].resultPos != (int) i && "immed. constant cannot be defined"); - operands[i].opType = operandType; + operands[i].opType = opTy; operands[i].value = NULL; operands[i].immedVal = intValue; operands[i].regNum = -1; @@ -116,19 +114,24 @@ operands[i].regNum = regNum; } +// Used only by the SPARC back-end. void MachineInstr::SetRegForOperand(unsigned i, int regNum) { assert(i < getNumOperands()); // must be explicit op operands[i].setRegForValue(regNum); } +// Used only by the SPARC back-end. void MachineInstr::SetRegForImplicitRef(unsigned i, int regNum) { getImplicitOp(i).setRegForValue(regNum); } - -// Substitute all occurrences of Value* oldVal with newVal in all operands -// and all implicit refs. -// If defsOnly == true, substitute defs only. +/// substituteValue - Substitute all occurrences of Value* oldVal with newVal +/// in all operands and all implicit refs. If defsOnly == true, substitute defs +/// only. +/// +/// FIXME: Fold this into its single caller, at SparcInstrSelection.cpp:2865, +/// or make it a static function in that file. +/// unsigned MachineInstr::substituteValue(const Value* oldVal, Value* newVal, bool defsOnly, bool notDefsAndUses, @@ -168,20 +171,16 @@ return numSubst; } - -void -MachineInstr::dump() const -{ +void MachineInstr::dump() const { std::cerr << " " << *this; } -static inline std::ostream& -OutputValue(std::ostream &os, const Value* val) -{ +static inline std::ostream& OutputValue(std::ostream &os, const Value* val) { os << "(val "; os << (void*) val; // print address always if (val && val->hasName()) - os << " " << val->getName() << ")"; // print name also, if available + os << " " << val->getName(); // print name also, if available + os << ")"; return os; } @@ -317,9 +316,7 @@ OS << "\n"; } - -std::ostream &operator<<(std::ostream& os, const MachineInstr& MI) -{ +std::ostream &operator<<(std::ostream& os, const MachineInstr& MI) { os << TargetInstrDescriptors[MI.getOpcode()].Name; for (unsigned i=0, N=MI.getNumOperands(); i < N; i++) { @@ -349,8 +346,7 @@ return os << "\n"; } -std::ostream &operator<<(std::ostream &OS, const MachineOperand &MO) -{ +std::ostream &operator<<(std::ostream &OS, const MachineOperand &MO) { if (MO.isHiBits32()) OS << "%lm("; else if (MO.isLoBits32()) From gaeke at cs.uiuc.edu Thu Feb 12 22:41:27 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Thu Feb 12 22:41:27 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/MachineFunction.cpp Message-ID: <200402130440.WAA07371@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: MachineFunction.cpp updated: 1.49 -> 1.50 --- Log message: Refactor MachineFunction::print() into MachineBasicBlock::print(). Add MachineBasicBlock::dump(). --- Diffs of the changes: (+12 -8) Index: llvm/lib/CodeGen/MachineFunction.cpp diff -u llvm/lib/CodeGen/MachineFunction.cpp:1.49 llvm/lib/CodeGen/MachineFunction.cpp:1.50 --- llvm/lib/CodeGen/MachineFunction.cpp:1.49 Wed Feb 11 20:27:10 2004 +++ llvm/lib/CodeGen/MachineFunction.cpp Thu Feb 12 22:39:55 2004 @@ -94,17 +94,21 @@ // Print Constant Pool getConstantPool()->print(OS); - for (const_iterator BB = begin(); BB != end(); ++BB) { - const BasicBlock *LBB = BB->getBasicBlock(); - OS << "\n" << LBB->getName() << " (" << (const void*)LBB << "):\n"; - for (MachineBasicBlock::const_iterator I = BB->begin(); I != BB->end();++I){ - OS << "\t"; - I->print(OS, Target); - } - } + for (const_iterator BB = begin(); BB != end(); ++BB) + BB->print(OS); OS << "\nEnd function \"" << Fn->getName() << "\"\n\n"; } +void MachineBasicBlock::dump() const { print(std::cerr); } + +void MachineBasicBlock::print(std::ostream &OS) const { + const BasicBlock *LBB = getBasicBlock(); + OS << "\n" << LBB->getName() << " (" << (const void*)LBB << "):\n"; + for (const_iterator I = begin(); I != end(); ++I) { + OS << "\t"; + I->print(OS, MachineFunction::get(LBB->getParent()).getTarget()); + } +} // The next two methods are used to construct and to retrieve // the MachineCodeForFunction object for the given function. From gaeke at cs.uiuc.edu Thu Feb 12 22:41:34 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Thu Feb 12 22:41:34 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/MachineBasicBlock.h Message-ID: <200402130440.WAA07765@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: MachineBasicBlock.h updated: 1.16 -> 1.17 --- Log message: Include . Add prototypes for MachineBasicBlock's dump() and print() methods. --- Diffs of the changes: (+5 -0) Index: llvm/include/llvm/CodeGen/MachineBasicBlock.h diff -u llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.16 llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.17 --- llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.16 Thu Feb 12 13:12:03 2004 +++ llvm/include/llvm/CodeGen/MachineBasicBlock.h Thu Feb 12 22:40:15 2004 @@ -16,6 +16,7 @@ #include "llvm/CodeGen/MachineInstr.h" #include "Support/ilist" +#include namespace llvm { @@ -126,6 +127,10 @@ iterator erase(iterator I) { return Insts.erase(I); } iterator erase(iterator I, iterator E) { return Insts.erase(I, E); } MachineInstr* remove(iterator &I) { return Insts.remove(I); } + + // Debugging methods. + void dump() const; + void print(std::ostream &OS) const; private: // Methods used to maintain doubly linked list of blocks... friend class ilist_traits; From gaeke at cs.uiuc.edu Thu Feb 12 22:50:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Thu Feb 12 22:50:01 2004 Subject: [llvm-commits] CVS: llvm/include/Support/Statistic.h Message-ID: <200402130449.WAA07996@zion.cs.uiuc.edu> Changes in directory llvm/include/Support: Statistic.h updated: 1.9 -> 1.10 --- Log message: Update the example here in the header file. I don't know about you guys, but I rarely read the .html manuals :-) --- Diffs of the changes: (+2 -2) Index: llvm/include/Support/Statistic.h diff -u llvm/include/Support/Statistic.h:1.9 llvm/include/Support/Statistic.h:1.10 --- llvm/include/Support/Statistic.h:1.9 Wed Jan 14 17:37:22 2004 +++ llvm/include/Support/Statistic.h Thu Feb 12 22:49:04 2004 @@ -15,9 +15,9 @@ // This is useful for reporting information like the number of instructions // simplified, optimized or removed by various transformations, like this: // -// static Statistic<> NumInstEliminated("GCSE - Number of instructions killed"); +// static Statistic<> NumInstsKilled("gcse", "Number of instructions killed"); // -// Later, in the code: ++NumInstEliminated; +// Later, in the code: ++NumInstsKilled; // //===----------------------------------------------------------------------===// From gaeke at cs.uiuc.edu Thu Feb 12 23:49:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Thu Feb 12 23:49:01 2004 Subject: [llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp Message-ID: <200402130548.XAA13709@zion.cs.uiuc.edu> Changes in directory llvm/lib/ExecutionEngine/Interpreter: Execution.cpp updated: 1.122 -> 1.123 --- Log message: The Interpreter was failing the AtExit UnitTest. This fixes it. --- Diffs of the changes: (+4 -0) Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.122 llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.123 --- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.122 Sun Feb 8 15:44:28 2004 +++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp Thu Feb 12 23:48:00 2004 @@ -523,6 +523,10 @@ //===----------------------------------------------------------------------===// void Interpreter::exitCalled(GenericValue GV) { + // runAtExitHandlers() assumes there are no stack frames, but + // if exit() was called, then it had a stack frame. Blow away + // the stack before interpreting atexit handlers. + ECStack.clear (); runAtExitHandlers (); exit (GV.IntVal); } From lattner at cs.uiuc.edu Fri Feb 13 00:10:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 00:10:01 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/SingleSource/Regression/C++/EH/Makefile Message-ID: <200402130609.AAA15005@zion.cs.uiuc.edu> Changes in directory llvm/test/Programs/SingleSource/Regression/C++/EH: Makefile updated: 1.6 -> 1.7 --- Log message: Fix testing problems with the "new" C++ frontend --- Diffs of the changes: (+1 -1) Index: llvm/test/Programs/SingleSource/Regression/C++/EH/Makefile diff -u llvm/test/Programs/SingleSource/Regression/C++/EH/Makefile:1.6 llvm/test/Programs/SingleSource/Regression/C++/EH/Makefile:1.7 --- llvm/test/Programs/SingleSource/Regression/C++/EH/Makefile:1.6 Sun Feb 8 13:46:38 2004 +++ llvm/test/Programs/SingleSource/Regression/C++/EH/Makefile Fri Feb 13 00:09:36 2004 @@ -3,5 +3,5 @@ include $(LEVEL)/test/Programs/SingleSource/Makefile.singlesrc CFLAGS += -std=c99 -LIBS = -lsupc++ +LIBS = -lstdc++ From lattner at cs.uiuc.edu Fri Feb 13 00:19:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 00:19:02 2004 Subject: [llvm-commits] CVS: llvm/lib/CWriter/Writer.cpp Message-ID: <200402130618.AAA29551@zion.cs.uiuc.edu> Changes in directory llvm/lib/CWriter: Writer.cpp updated: 1.155 -> 1.156 --- Log message: Fine grainify namespacification, prune #includes --- Diffs of the changes: (+4 -9) Index: llvm/lib/CWriter/Writer.cpp diff -u llvm/lib/CWriter/Writer.cpp:1.155 llvm/lib/CWriter/Writer.cpp:1.156 --- llvm/lib/CWriter/Writer.cpp:1.155 Thu Feb 12 17:13:33 2004 +++ llvm/lib/CWriter/Writer.cpp Fri Feb 13 00:18:21 2004 @@ -7,7 +7,8 @@ // //===----------------------------------------------------------------------===// // -// This library converts LLVM code to C code, compilable by GCC. +// This library converts LLVM code to C code, compilable by GCC and other C +// compilers. // //===----------------------------------------------------------------------===// @@ -24,15 +25,11 @@ #include "llvm/Support/CallSite.h" #include "llvm/Support/GetElementPtrTypeIterator.h" #include "llvm/Support/InstVisitor.h" -#include "llvm/Support/InstIterator.h" #include "llvm/Support/Mangler.h" #include "Support/StringExtras.h" -#include "Support/STLExtras.h" -#include "Config/config.h" #include #include - -namespace llvm { +using namespace llvm; namespace { class CWriter : public Pass, public InstVisitor { @@ -1476,6 +1473,4 @@ // External Interface declaration //===----------------------------------------------------------------------===// -Pass *createWriteToCPass(std::ostream &o) { return new CWriter(o); } - -} // End llvm namespace +Pass *llvm::createWriteToCPass(std::ostream &o) { return new CWriter(o); } From gaeke at cs.uiuc.edu Fri Feb 13 00:19:11 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Fri Feb 13 00:19:11 2004 Subject: [llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Interpreter.h Message-ID: <200402130618.AAA30934@zion.cs.uiuc.edu> Changes in directory llvm/lib/ExecutionEngine/Interpreter: Interpreter.h updated: 1.59 -> 1.60 --- Log message: Fix off-by-one in Interpreter::getFirstVarArg(), which was punishing any attempts by LLI to use varargs (possibly left over from the introduction of IntrinsicLowering??) --- Diffs of the changes: (+1 -1) Index: llvm/lib/ExecutionEngine/Interpreter/Interpreter.h diff -u llvm/lib/ExecutionEngine/Interpreter/Interpreter.h:1.59 llvm/lib/ExecutionEngine/Interpreter/Interpreter.h:1.60 --- llvm/lib/ExecutionEngine/Interpreter/Interpreter.h:1.59 Sun Dec 28 03:44:37 2003 +++ llvm/lib/ExecutionEngine/Interpreter/Interpreter.h Fri Feb 13 00:18:39 2004 @@ -159,7 +159,7 @@ } GenericValue *getFirstVarArg () { - return &(ECStack[ECStack.size () - 2].VarArgs[0]); + return &(ECStack.back ().VarArgs[0]); } //FIXME: private: From lattner at cs.uiuc.edu Fri Feb 13 00:22:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 00:22:02 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/SingleSource/UnitTests/SetjmpLongjmp/Makefile Message-ID: <200402130621.AAA31731@zion.cs.uiuc.edu> Changes in directory llvm/test/Programs/SingleSource/UnitTests/SetjmpLongjmp: Makefile updated: 1.4 -> 1.5 --- Log message: c++ tests require c++ std library! --- Diffs of the changes: (+1 -0) Index: llvm/test/Programs/SingleSource/UnitTests/SetjmpLongjmp/Makefile diff -u llvm/test/Programs/SingleSource/UnitTests/SetjmpLongjmp/Makefile:1.4 llvm/test/Programs/SingleSource/UnitTests/SetjmpLongjmp/Makefile:1.5 --- llvm/test/Programs/SingleSource/UnitTests/SetjmpLongjmp/Makefile:1.4 Sun Feb 8 13:52:41 2004 +++ llvm/test/Programs/SingleSource/UnitTests/SetjmpLongjmp/Makefile Fri Feb 13 00:20:58 2004 @@ -1,6 +1,7 @@ # Programs/SingleSource/UnitTests/SetjmpLongjmp/Makefile LEVEL = ../../../../.. REQUIRES_EH_SUPPORT = 1 +LIBS = -lstdc++ include $(LEVEL)/test/Programs/SingleSource/Makefile.singlesrc From lattner at cs.uiuc.edu Fri Feb 13 10:06:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 10:06:02 2004 Subject: [llvm-commits] CVS: llvm/test/Regression/Analysis/DSGraph/2004-02-13-memcpy.ll Message-ID: <200402131605.KAA23299@zion.cs.uiuc.edu> Changes in directory llvm/test/Regression/Analysis/DSGraph: 2004-02-13-memcpy.ll added (r1.1) --- Log message: New testcase for support for memcpy/memmove --- Diffs of the changes: (+13 -0) Index: llvm/test/Regression/Analysis/DSGraph/2004-02-13-memcpy.ll diff -c /dev/null llvm/test/Regression/Analysis/DSGraph/2004-02-13-memcpy.ll:1.1 *** /dev/null Fri Feb 13 10:05:01 2004 --- llvm/test/Regression/Analysis/DSGraph/2004-02-13-memcpy.ll Fri Feb 13 10:04:51 2004 *************** *** 0 **** --- 1,13 ---- + ; RUN: analyze %s -datastructure-gc -dsgc-check-flags=X:SM + + declare void %llvm.memcpy(sbyte*, sbyte*, uint, uint) + + void %test() { + %X = alloca int + %Y = alloca int + %x = cast int* %X to sbyte* + %y = cast int* %Y to sbyte* + store int 4, int* %X + call void %llvm.memcpy(sbyte* %x, sbyte* %y, uint 4, uint 4) + ret void + } From lattner at cs.uiuc.edu Fri Feb 13 10:10:05 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 10:10:05 2004 Subject: [llvm-commits] CVS: llvm/test/Regression/Analysis/DSGraph/2004-02-13-memcpy.ll Message-ID: <200402131609.KAA24064@zion.cs.uiuc.edu> Changes in directory llvm/test/Regression/Analysis/DSGraph: 2004-02-13-memcpy.ll updated: 1.1 -> 1.2 --- Log message: Right, memcpy READS memory too :) --- Diffs of the changes: (+1 -1) Index: llvm/test/Regression/Analysis/DSGraph/2004-02-13-memcpy.ll diff -u llvm/test/Regression/Analysis/DSGraph/2004-02-13-memcpy.ll:1.1 llvm/test/Regression/Analysis/DSGraph/2004-02-13-memcpy.ll:1.2 --- llvm/test/Regression/Analysis/DSGraph/2004-02-13-memcpy.ll:1.1 Fri Feb 13 10:04:51 2004 +++ llvm/test/Regression/Analysis/DSGraph/2004-02-13-memcpy.ll Fri Feb 13 10:09:37 2004 @@ -1,4 +1,4 @@ -; RUN: analyze %s -datastructure-gc -dsgc-check-flags=X:SM +; RUN: analyze %s -datastructure-gc -dsgc-check-flags=X:SMR declare void %llvm.memcpy(sbyte*, sbyte*, uint, uint) From lattner at cs.uiuc.edu Fri Feb 13 10:11:05 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 10:11:05 2004 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/Local.cpp Message-ID: <200402131610.KAA24079@zion.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: Local.cpp updated: 1.78 -> 1.79 --- Log message: Restructure code to handle memcpy/memmove --- Diffs of the changes: (+33 -28) Index: llvm/lib/Analysis/DataStructure/Local.cpp diff -u llvm/lib/Analysis/DataStructure/Local.cpp:1.78 llvm/lib/Analysis/DataStructure/Local.cpp:1.79 --- llvm/lib/Analysis/DataStructure/Local.cpp:1.78 Sat Feb 7 19:51:48 2004 +++ llvm/lib/Analysis/DataStructure/Local.cpp Fri Feb 13 10:09:54 2004 @@ -17,6 +17,7 @@ #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" #include "llvm/Instructions.h" +#include "llvm/Intrinsics.h" #include "llvm/Support/GetElementPtrTypeIterator.h" #include "llvm/Support/InstVisitor.h" #include "llvm/Target/TargetData.h" @@ -456,39 +457,43 @@ // Special case handling of certain libc allocation functions here. if (Function *F = CS.getCalledFunction()) if (F->isExternal()) - if (F->getName() == "calloc") { - setDestTo(*CS.getInstruction(), - createNode()->setHeapNodeMarker()->setModifiedMarker()); - return; - } else if (F->getName() == "realloc") { - DSNodeHandle RetNH = getValueDest(*CS.getInstruction()); - RetNH.mergeWith(getValueDest(**CS.arg_begin())); - if (DSNode *N = RetNH.getNode()) - N->setHeapNodeMarker()->setModifiedMarker()->setReadMarker(); - return; - } else if (F->getName() == "memset") { - // Merge the first argument with the return value, and mark the memory + switch (F->getIntrinsicID()) { + case Intrinsic::memmove: + case Intrinsic::memcpy: { + // Merge the first & second arguments, and mark the memory read and // modified. - DSNodeHandle RetNH = getValueDest(*CS.getInstruction()); - RetNH.mergeWith(getValueDest(**CS.arg_begin())); - if (DSNode *N = RetNH.getNode()) - N->setModifiedMarker(); - return; - } else if (F->getName() == "memmove") { - // Merge the first & second arguments with the result, and mark the - // memory read and modified. - DSNodeHandle RetNH = getValueDest(*CS.getInstruction()); - RetNH.mergeWith(getValueDest(**CS.arg_begin())); + DSNodeHandle RetNH = getValueDest(**CS.arg_begin()); RetNH.mergeWith(getValueDest(**(CS.arg_begin()+1))); if (DSNode *N = RetNH.getNode()) N->setModifiedMarker()->setReadMarker(); return; - } else if (F->getName() == "bzero") { - // Mark the memory modified. - DSNodeHandle H = getValueDest(**CS.arg_begin()); - if (DSNode *N = H.getNode()) - N->setModifiedMarker(); - return; + } + default: + if (F->getName() == "calloc") { + setDestTo(*CS.getInstruction(), + createNode()->setHeapNodeMarker()->setModifiedMarker()); + return; + } else if (F->getName() == "realloc") { + DSNodeHandle RetNH = getValueDest(*CS.getInstruction()); + RetNH.mergeWith(getValueDest(**CS.arg_begin())); + if (DSNode *N = RetNH.getNode()) + N->setHeapNodeMarker()->setModifiedMarker()->setReadMarker(); + return; + } else if (F->getName() == "memset") { + // Merge the first argument with the return value, and mark the memory + // modified. + DSNodeHandle RetNH = getValueDest(*CS.getInstruction()); + RetNH.mergeWith(getValueDest(**CS.arg_begin())); + if (DSNode *N = RetNH.getNode()) + N->setModifiedMarker(); + return; + } else if (F->getName() == "bzero") { + // Mark the memory modified. + DSNodeHandle H = getValueDest(**CS.arg_begin()); + if (DSNode *N = H.getNode()) + N->setModifiedMarker(); + return; + } } From lattner at cs.uiuc.edu Fri Feb 13 10:16:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 10:16:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/SparcInstrSelection.cpp Message-ID: <200402131615.KAA24568@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/Sparc: SparcInstrSelection.cpp updated: 1.131 -> 1.132 --- Log message: Squish warning --- Diffs of the changes: (+2 -2) Index: llvm/lib/Target/Sparc/SparcInstrSelection.cpp diff -u llvm/lib/Target/Sparc/SparcInstrSelection.cpp:1.131 llvm/lib/Target/Sparc/SparcInstrSelection.cpp:1.132 --- llvm/lib/Target/Sparc/SparcInstrSelection.cpp:1.131 Wed Feb 11 14:47:32 2004 +++ llvm/lib/Target/Sparc/SparcInstrSelection.cpp Fri Feb 13 10:14:50 2004 @@ -2006,7 +2006,7 @@ { maskUnsignedResult = true; MachineOpCode forceOp = ((checkCast && BothFloatToDouble(subtreeRoot)) - ? V9::FSMULD + ? (MachineOpCode)V9::FSMULD : INVALID_MACHINE_OPCODE); Instruction* mulInstr = subtreeRoot->getInstruction(); CreateMulInstruction(target, mulInstr->getParent()->getParent(), @@ -2024,7 +2024,7 @@ { maskUnsignedResult = true; MachineOpCode forceOp = ((checkCast && BothFloatToDouble(subtreeRoot)) - ? V9::FSMULD + ? (MachineOpCode)V9::FSMULD : INVALID_MACHINE_OPCODE); Instruction* mulInstr = subtreeRoot->getInstruction(); CreateMulInstruction(target, mulInstr->getParent()->getParent(), From lattner at cs.uiuc.edu Fri Feb 13 10:17:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 10:17:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/LowerInvoke.cpp Message-ID: <200402131616.KAA25214@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: LowerInvoke.cpp updated: 1.10 -> 1.11 --- Log message: Expose a pass ID that can be 'required' --- Diffs of the changes: (+2 -0) Index: llvm/lib/Transforms/Scalar/LowerInvoke.cpp diff -u llvm/lib/Transforms/Scalar/LowerInvoke.cpp:1.10 llvm/lib/Transforms/Scalar/LowerInvoke.cpp:1.11 --- llvm/lib/Transforms/Scalar/LowerInvoke.cpp:1.10 Mon Feb 9 16:48:47 2004 +++ llvm/lib/Transforms/Scalar/LowerInvoke.cpp Fri Feb 13 10:16:16 2004 @@ -70,6 +70,8 @@ X("lowerinvoke", "Lower invoke and unwind, for unwindless code generators"); } +const PassInfo *llvm::LowerInvokePassID = X.getPassInfo(); + // Public Interface To the LowerInvoke pass. FunctionPass *llvm::createLowerInvokePass() { return new LowerInvoke(); } From lattner at cs.uiuc.edu Fri Feb 13 10:17:10 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 10:17:10 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Transforms/Scalar.h Message-ID: <200402131616.KAA25352@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Transforms: Scalar.h updated: 1.31 -> 1.32 --- Log message: Expose a pass ID for lower-invoke --- Diffs of the changes: (+1 -2) Index: llvm/include/llvm/Transforms/Scalar.h diff -u llvm/include/llvm/Transforms/Scalar.h:1.31 llvm/include/llvm/Transforms/Scalar.h:1.32 --- llvm/include/llvm/Transforms/Scalar.h:1.31 Tue Nov 11 16:41:31 2003 +++ llvm/include/llvm/Transforms/Scalar.h Fri Feb 13 10:16:35 2004 @@ -260,8 +260,7 @@ // into calls to abort(). // FunctionPass *createLowerInvokePass(); - - +extern const PassInfo *LowerInvokePassID; //===----------------------------------------------------------------------===// // From brukman at cs.uiuc.edu Fri Feb 13 10:24:01 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Fri Feb 13 10:24:01 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Transforms/Scalar.h Message-ID: <200402131623.KAA26603@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Transforms: Scalar.h updated: 1.32 -> 1.33 --- Log message: Fix spelling of `tendency'. --- Diffs of the changes: (+1 -1) Index: llvm/include/llvm/Transforms/Scalar.h diff -u llvm/include/llvm/Transforms/Scalar.h:1.32 llvm/include/llvm/Transforms/Scalar.h:1.33 --- llvm/include/llvm/Transforms/Scalar.h:1.32 Fri Feb 13 10:16:35 2004 +++ llvm/include/llvm/Transforms/Scalar.h Fri Feb 13 10:23:14 2004 @@ -117,7 +117,7 @@ //===----------------------------------------------------------------------===// // // InstructionCombining - Combine instructions to form fewer, simple -// instructions. This pass does not modify the CFG, and has a tendancy to +// instructions. This pass does not modify the CFG, and has a tendency to // make instructions dead, so a subsequent DCE pass is useful. // // This pass combines things like: From lattner at cs.uiuc.edu Fri Feb 13 10:35:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 10:35:02 2004 Subject: [llvm-commits] CVS: llvm/utils/TableGen/FileLexer.l Message-ID: <200402131634.KAA27116@zion.cs.uiuc.edu> Changes in directory llvm/utils/TableGen: FileLexer.l updated: 1.19 -> 1.20 --- Log message: Fix buggy error message problem --- Diffs of the changes: (+3 -2) Index: llvm/utils/TableGen/FileLexer.l diff -u llvm/utils/TableGen/FileLexer.l:1.19 llvm/utils/TableGen/FileLexer.l:1.20 --- llvm/utils/TableGen/FileLexer.l:1.19 Wed Feb 11 18:03:08 2004 +++ llvm/utils/TableGen/FileLexer.l Fri Feb 13 10:33:56 2004 @@ -126,12 +126,13 @@ // // NOTE: Right now, there is only one directory. We need to eventually add // support for more. - Filename = IncludeDirectory + "/" + Filename; - yyin = fopen(Filename.c_str(), "r"); + std::string NextFilename = IncludeDirectory + "/" + Filename; + yyin = fopen(NextFilename.c_str(), "r"); if (yyin == 0) { err() << "Could not find include file '" << Filename << "'!\n"; abort(); } + Filename = NextFilename; } // Add the file to our include stack... From lattner at cs.uiuc.edu Fri Feb 13 10:38:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 10:38:02 2004 Subject: [llvm-commits] CVS: llvm/utils/TableGen/FileLexer.l FileParser.y TableGen.cpp Message-ID: <200402131637.KAA27592@zion.cs.uiuc.edu> Changes in directory llvm/utils/TableGen: FileLexer.l updated: 1.20 -> 1.21 FileParser.y updated: 1.26 -> 1.27 TableGen.cpp updated: 1.24 -> 1.25 --- Log message: exit(1) instead of abort()'ing on error --- Diffs of the changes: (+27 -27) Index: llvm/utils/TableGen/FileLexer.l diff -u llvm/utils/TableGen/FileLexer.l:1.20 llvm/utils/TableGen/FileLexer.l:1.21 --- llvm/utils/TableGen/FileLexer.l:1.20 Fri Feb 13 10:33:56 2004 +++ llvm/utils/TableGen/FileLexer.l Fri Feb 13 10:37:43 2004 @@ -130,7 +130,7 @@ yyin = fopen(NextFilename.c_str(), "r"); if (yyin == 0) { err() << "Could not find include file '" << Filename << "'!\n"; - abort(); + exit(1); } Filename = NextFilename; } @@ -214,7 +214,7 @@ "/*" { ++CommentDepth; } "/"+[^*]* /* eat up /'s not followed by *'s */ "*"+"/" { if (!--CommentDepth) { BEGIN(INITIAL); } } -<> { err() << "Unterminated comment!\n"; abort(); } +<> { err() << "Unterminated comment!\n"; exit(1); } . { return Filetext[0]; } Index: llvm/utils/TableGen/FileParser.y diff -u llvm/utils/TableGen/FileParser.y:1.26 llvm/utils/TableGen/FileParser.y:1.27 --- llvm/utils/TableGen/FileParser.y:1.26 Tue Nov 11 16:41:34 2003 +++ llvm/utils/TableGen/FileParser.y Fri Feb 13 10:37:43 2004 @@ -51,7 +51,7 @@ err() << "New definition of '" << RV.getName() << "' of type '" << *RV.getType() << "' is incompatible with previous " << "definition of type '" << *ERV->getType() << "'!\n"; - abort(); + exit(1); } } else { CurRec->addValue(RV); @@ -61,7 +61,7 @@ static void addSuperClass(Record *SC) { if (CurRec->isSubClassOf(SC)) { err() << "Already subclass of '" << SC->getName() << "'!\n"; - abort(); + exit(1); } CurRec->addSuperClass(SC); } @@ -73,7 +73,7 @@ RecordVal *RV = CurRec->getValue(ValName); if (RV == 0) { err() << "Value '" << ValName << "' unknown!\n"; - abort(); + exit(1); } // If we are assigning to a subset of the bits in the value... then we must be @@ -84,7 +84,7 @@ BitsInit *CurVal = dynamic_cast(RV->getValue()); if (CurVal == 0) { err() << "Value '" << ValName << "' is not a bits type!\n"; - abort(); + exit(1); } // Convert the incoming value to a bits type of the appropriate size... @@ -92,7 +92,7 @@ if (BI == 0) { V->convertInitializerTo(new BitsRecTy(BitList->size())); err() << "Initializer '" << *V << "' not compatible with bit range!\n"; - abort(); + exit(1); } // We should have a BitsInit type now... @@ -107,7 +107,7 @@ if (NewVal->getBit(Bit)) { err() << "Cannot set bit #" << Bit << " of value '" << ValName << "' more than once!\n"; - abort(); + exit(1); } NewVal->setBit(Bit, BInit->getBit(i)); } @@ -122,7 +122,7 @@ if (RV->setValue(V)) { err() << "Value '" << ValName << "' of type '" << *RV->getType() << "' is incompatible with initializer '" << *V << "'!\n"; - abort(); + exit(1); } } @@ -137,7 +137,7 @@ // Ensure that an appropriate number of template arguments are specified... if (TArgs.size() < TemplateArgs.size()) { err() << "ERROR: More template args specified than expected!\n"; - abort(); + exit(1); } else { // This class expects template arguments... // Loop over all of the template arguments, setting them to the specified // value or leaving them as the default as necessary. @@ -149,7 +149,7 @@ err() << "ERROR: Value not specified for template argument #" << i << " (" << TArgs[i] << ") of subclass '" << SC->getName() << "'!\n"; - abort(); + exit(1); } } } @@ -206,7 +206,7 @@ $$ = Records.getClass(*$1); if ($$ == 0) { err() << "Couldn't find class '" << *$1 << "'!\n"; - abort(); + exit(1); } delete $1; }; @@ -252,7 +252,7 @@ if (Bit == 0) { err() << "Element #" << i << " (" << *(*$2)[i] << ") is not convertable to a bit!\n"; - abort(); + exit(1); } Init->setBit($2->size()-i-1, Bit); } @@ -265,7 +265,7 @@ $$ = new DefInit(D); } else { err() << "Variable not defined: '" << *$1 << "'!\n"; - abort(); + exit(1); } delete $1; @@ -273,7 +273,7 @@ $$ = $1->convertInitializerBitRange(*$3); if ($$ == 0) { err() << "Invalid bit range for value '" << *$1 << "'!\n"; - abort(); + exit(1); } delete $3; } | '[' ValueList ']' { @@ -282,7 +282,7 @@ } | Value '.' ID { if (!$1->getFieldType(*$3)) { err() << "Cannot access field '" << *$3 << "' of value '" << *$1 << "!\n"; - abort(); + exit(1); } $$ = new FieldInit($1, *$3); delete $3; @@ -290,7 +290,7 @@ Record *D = Records.getDef(*$2); if (D == 0) { err() << "Invalid def '" << *$2 << "'!\n"; - abort(); + exit(1); } $$ = new DagInit(D, *$3); delete $2; delete $3; @@ -326,7 +326,7 @@ } | INTVAL '-' INTVAL { if ($1 < $3 || $1 < 0 || $3 < 0) { err() << "Invalid bit range: " << $1 << "-" << $3 << "!\n"; - abort(); + exit(1); } $$ = new std::vector(); for (int i = $1; i >= $3; --i) @@ -335,7 +335,7 @@ $2 = -$2; if ($1 < $2 || $1 < 0 || $2 < 0) { err() << "Invalid bit range: " << $1 << "-" << $2 << "!\n"; - abort(); + exit(1); } $$ = new std::vector(); for (int i = $1; i >= $2; --i) @@ -345,7 +345,7 @@ } | RBitList ',' INTVAL '-' INTVAL { if ($3 < $5 || $3 < 0 || $5 < 0) { err() << "Invalid bit range: " << $3 << "-" << $5 << "!\n"; - abort(); + exit(1); } $$ = $1; for (int i = $3; i >= $5; --i) @@ -354,7 +354,7 @@ $4 = -$4; if ($3 < $4 || $3 < 0 || $4 < 0) { err() << "Invalid bit range: " << $3 << "-" << $4 << "!\n"; - abort(); + exit(1); } $$ = $1; for (int i = $3; i >= $4; --i) @@ -472,7 +472,7 @@ ClassInst : CLASS ObjectBody { if (Records.getClass($2->getName())) { err() << "Class '" << $2->getName() << "' already defined!\n"; - abort(); + exit(1); } Records.addClass($$ = $2); }; @@ -481,12 +481,12 @@ if (!$2->getTemplateArgs().empty()) { err() << "Def '" << $2->getName() << "' is not permitted to have template arguments!\n"; - abort(); + exit(1); } // If ObjectBody has template arguments, it's an error. if (Records.getDef($2->getName())) { err() << "Def '" << $2->getName() << "' already defined!\n"; - abort(); + exit(1); } Records.addDef($$ = $2); }; @@ -520,5 +520,5 @@ int yyerror(const char *ErrorMsg) { err() << "Error parsing: " << ErrorMsg << "\n"; - abort(); + exit(1); } Index: llvm/utils/TableGen/TableGen.cpp diff -u llvm/utils/TableGen/TableGen.cpp:1.24 llvm/utils/TableGen/TableGen.cpp:1.25 --- llvm/utils/TableGen/TableGen.cpp:1.24 Thu Feb 5 21:19:17 2004 +++ llvm/utils/TableGen/TableGen.cpp Fri Feb 13 10:37:43 2004 @@ -97,7 +97,7 @@ } std::cerr << "Cannot find requested bit!\n"; - abort(); + exit(1); return 0; } @@ -273,7 +273,7 @@ if (RangeBegin == InstsB && RangeEnd == InstsE) { std::cerr << "Error: Could not distinguish among the following insts!:\n"; PrintRange(InstsB, InstsE); - abort(); + exit(1); } #if 0 From lattner at cs.uiuc.edu Fri Feb 13 10:41:00 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 10:41:00 2004 Subject: [llvm-commits] CVS: llvm/docs/ReleaseNotes.html Message-ID: <200402131640.KAA28068@zion.cs.uiuc.edu> Changes in directory llvm/docs: ReleaseNotes.html updated: 1.120 -> 1.121 --- Log message: Bug fix --- Diffs of the changes: (+2 -1) Index: llvm/docs/ReleaseNotes.html diff -u llvm/docs/ReleaseNotes.html:1.120 llvm/docs/ReleaseNotes.html:1.121 --- llvm/docs/ReleaseNotes.html:1.120 Thu Feb 12 15:21:17 2004 +++ llvm/docs/ReleaseNotes.html Fri Feb 13 10:40:24 2004 @@ -172,6 +172,7 @@
  • [loopsimplify] Loopsimplify incorrectly updates dominator information
  • [pruneeh] -pruneeh pass removes invoke instructions it shouldn't
  • [sparc] Boolean constants are emitted as true and false
  • +
  • Tablegen aborts on errors
  • @@ -578,7 +579,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/02/12 21:21:17 $ + Last modified: $Date: 2004/02/13 16:40:24 $ From criswell at cs.uiuc.edu Fri Feb 13 10:47:02 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Fri Feb 13 10:47:02 2004 Subject: [llvm-commits] CVS: llvm/LICENSE.TXT Message-ID: <200402131646.KAA07920@choi.cs.uiuc.edu> Changes in directory llvm: LICENSE.TXT updated: 1.4 -> 1.5 --- Log message: Updated to list all code/directories that have additional or alternate licensing information. Also added note to indicate that warrany disclaimer and the no-endorsement clause applies to everything. --- Diffs of the changes: (+37 -0) Index: llvm/LICENSE.TXT diff -u llvm/LICENSE.TXT:1.4 llvm/LICENSE.TXT:1.5 --- llvm/LICENSE.TXT:1.4 Mon Oct 27 11:56:26 2003 +++ llvm/LICENSE.TXT Fri Feb 13 10:46:05 2004 @@ -49,3 +49,40 @@ have its own individual LICENSE.TXT file in the directory in which it appears. This file will describe the copyrights, license, and restrictions which apply to that code. + +The disclaimer of warranty in the University of Illinois Open Source License +applies to all code in the LLVM Distribution, and nothing in any of the +other licenses gives permission to use the names of the LLVM Team or the +University of Illinois to endorse or promote products derived from this +Software. + +The following pieces of software have additional or alternate copyrights, +licenses, and/or restrictions: + +Program Directory +------- --------- +Autoconf: llvm/autoconf + llvm/projects/ModuleMaker/autoconf + llvm/projects/sample/autoconf +Burg: llvm/utils/Burg + llvm/test/Programs/MultiSource/Applications/Burg +Aha: llvm/test/Programs/MultiSource/Applications/aha +SGEFA: llvm/test/Programs/MultiSource/Applications/sgefa +SIOD: llvm/test/Programs/MultiSource/Applications/siod +Lambda: llvm/test/Programs/MultiSource/Applications/lambda-0.1.3 +Fhourstones: llvm/test/Programs/MultiSource/Benchmarks/Fhourstones +McCat: llvm/test/Programs/MultiSource/Benchmarks/McCat +Olden: llvm/test/Programs/MultiSource/Benchmarks/Olden +OptimizerEval: llvm/test/Programs/MultiSource/Benchmarks/OptimizerEval +Ptrdist: llvm/test/Programs/MultiSource/Benchmarks/Ptrdist +LLUBenchmark: llvm/test/Programs/MultiSource/Benchmarks/llubenchmark +SIM: llvm/test/Programs/MultiSource/Benchmarks/sim +Dhrystone: llvm/test/Programs/SingleSource/Benchmarks/Dhrystone +SingleSource Tests: llvm/test/Programs/SingleSource/Benchmarks/Misc + llvm/test/Programs/SingleSource/CustomChecked + llvm/test/Programs/SingleSource/Gizmos +Boost: llvm/include/boost +GNU Libc: llvm/runtime/GCCLibraries/libc +Zlib Library: llvm/runtime/zlib +PNG Library: llvm/runtime/libpng + From lattner at cs.uiuc.edu Fri Feb 13 10:47:10 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 10:47:10 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/IPO/PruneEH.cpp Message-ID: <200402131646.KAA29085@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/IPO: PruneEH.cpp updated: 1.11 -> 1.12 --- Log message: Intrinsic functions cannot throw --- Diffs of the changes: (+1 -1) Index: llvm/lib/Transforms/IPO/PruneEH.cpp diff -u llvm/lib/Transforms/IPO/PruneEH.cpp:1.11 llvm/lib/Transforms/IPO/PruneEH.cpp:1.12 --- llvm/lib/Transforms/IPO/PruneEH.cpp:1.11 Sun Feb 8 15:43:47 2004 +++ llvm/lib/Transforms/IPO/PruneEH.cpp Fri Feb 13 10:46:46 2004 @@ -53,7 +53,7 @@ bool SCCMightThrow = false; for (unsigned i = 0, e = SCC.size(); !SCCMightThrow && i != e; ++i) if (Function *F = SCC[i]->getFunction()) - if (F->isExternal()) { + if (F->isExternal() && !F->getIntrinsicID()) { SCCMightThrow = true; } else { // Check to see if this function performs an unwind or calls an From lattner at cs.uiuc.edu Fri Feb 13 10:48:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 10:48:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Utils/InlineFunction.cpp Message-ID: <200402131647.KAA29096@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Utils: InlineFunction.cpp updated: 1.23 -> 1.24 --- Log message: Fix compilation of 126.gcc: intrinsic functions cannot throw, so they are not allowed in invoke instructions. Thus, if we are inlining a call to an intrinsic function into an invoke site, we don't need to turn the call into an invoke! --- Diffs of the changes: (+32 -27) Index: llvm/lib/Transforms/Utils/InlineFunction.cpp diff -u llvm/lib/Transforms/Utils/InlineFunction.cpp:1.23 llvm/lib/Transforms/Utils/InlineFunction.cpp:1.24 --- llvm/lib/Transforms/Utils/InlineFunction.cpp:1.23 Sun Feb 8 15:43:53 2004 +++ llvm/lib/Transforms/Utils/InlineFunction.cpp Fri Feb 13 10:47:35 2004 @@ -123,34 +123,39 @@ // We only need to check for function calls: inlined invoke instructions // require no special handling... if (CallInst *CI = dyn_cast(I)) { - // Convert this function call into an invoke instruction... + // Convert this function call into an invoke instruction... if it's + // not an intrinsic function call (which are known to not throw). + if (CI->getCalledFunction() && + CI->getCalledFunction()->getIntrinsicID()) { + ++I; + } else { + // First, split the basic block... + BasicBlock *Split = BB->splitBasicBlock(CI, CI->getName()+".noexc"); + + // Next, create the new invoke instruction, inserting it at the end + // of the old basic block. + InvokeInst *II = + new InvokeInst(CI->getCalledValue(), Split, InvokeDest, + std::vector(CI->op_begin()+1, CI->op_end()), + CI->getName(), BB->getTerminator()); - // First, split the basic block... - BasicBlock *Split = BB->splitBasicBlock(CI, CI->getName()+".noexc"); - - // Next, create the new invoke instruction, inserting it at the end - // of the old basic block. - InvokeInst *II = - new InvokeInst(CI->getCalledValue(), Split, InvokeDest, - std::vector(CI->op_begin()+1, CI->op_end()), - CI->getName(), BB->getTerminator()); - - // Make sure that anything using the call now uses the invoke! - CI->replaceAllUsesWith(II); - - // Delete the unconditional branch inserted by splitBasicBlock - BB->getInstList().pop_back(); - Split->getInstList().pop_front(); // Delete the original call - - // Update any PHI nodes in the exceptional block to indicate that - // there is now a new entry in them. - unsigned i = 0; - for (BasicBlock::iterator I = InvokeDest->begin(); - PHINode *PN = dyn_cast(I); ++I, ++i) - PN->addIncoming(InvokeDestPHIValues[i], BB); - - // This basic block is now complete, start scanning the next one. - break; + // Make sure that anything using the call now uses the invoke! + CI->replaceAllUsesWith(II); + + // Delete the unconditional branch inserted by splitBasicBlock + BB->getInstList().pop_back(); + Split->getInstList().pop_front(); // Delete the original call + + // Update any PHI nodes in the exceptional block to indicate that + // there is now a new entry in them. + unsigned i = 0; + for (BasicBlock::iterator I = InvokeDest->begin(); + PHINode *PN = dyn_cast(I); ++I, ++i) + PN->addIncoming(InvokeDestPHIValues[i], BB); + + // This basic block is now complete, start scanning the next one. + break; + } } else { ++I; } From lattner at cs.uiuc.edu Fri Feb 13 11:04:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 11:04:02 2004 Subject: [llvm-commits] CVS: llvm/docs/ReleaseNotes.html Message-ID: <200402131703.LAA01152@zion.cs.uiuc.edu> Changes in directory llvm/docs: ReleaseNotes.html updated: 1.121 -> 1.122 --- Log message: Bug fixed --- Diffs of the changes: (+2 -1) Index: llvm/docs/ReleaseNotes.html diff -u llvm/docs/ReleaseNotes.html:1.121 llvm/docs/ReleaseNotes.html:1.122 --- llvm/docs/ReleaseNotes.html:1.121 Fri Feb 13 10:40:24 2004 +++ llvm/docs/ReleaseNotes.html Fri Feb 13 11:03:01 2004 @@ -173,6 +173,7 @@
  • [pruneeh] -pruneeh pass removes invoke instructions it shouldn't
  • [sparc] Boolean constants are emitted as true and false
  • Tablegen aborts on errors
  • +
  • [inliner] Error inlining intrinsic calls into invoke instructions
  • @@ -579,7 +580,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/02/13 16:40:24 $ + Last modified: $Date: 2004/02/13 17:03:01 $ From lattner at cs.uiuc.edu Fri Feb 13 11:04:11 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 11:04:11 2004 Subject: [llvm-commits] CVS: llvm-www/releases/1.1/docs/ReleaseNotes.html Message-ID: <200402131703.LAA01537@zion.cs.uiuc.edu> Changes in directory llvm-www/releases/1.1/docs: ReleaseNotes.html updated: 1.24 -> 1.25 --- Log message: Bug found --- Diffs of the changes: (+2 -1) Index: llvm-www/releases/1.1/docs/ReleaseNotes.html diff -u llvm-www/releases/1.1/docs/ReleaseNotes.html:1.24 llvm-www/releases/1.1/docs/ReleaseNotes.html:1.25 --- llvm-www/releases/1.1/docs/ReleaseNotes.html:1.24 Thu Feb 12 15:21:28 2004 +++ llvm-www/releases/1.1/docs/ReleaseNotes.html Fri Feb 13 11:03:11 2004 @@ -391,6 +391,7 @@
  • make tools-only doesn't make lib/Support
  • [loopsimplify] Loopsimplify incorrectly updates dominator information
  • [pruneeh] -pruneeh pass removes invoke instructions it shouldn't
  • +
  • [inliner] Error inlining intrinsic calls into invoke instructions
  • @@ -748,7 +749,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/02/12 21:21:28 $ + Last modified: $Date: 2004/02/13 17:03:11 $ From criswell at cs.uiuc.edu Fri Feb 13 11:17:00 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Fri Feb 13 11:17:00 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/External/SPEC/CINT95/124.m88ksim/ Message-ID: <200402131716.LAA09982@choi.cs.uiuc.edu> Changes in directory llvm/test/Programs/External/SPEC/CINT95/124.m88ksim: --- Log message: Directory /home/vadve/shared/PublicCVS/llvm/test/Programs/External/SPEC/CINT95/124.m88ksim added to the repository --- Diffs of the changes: (+0 -0) From criswell at cs.uiuc.edu Fri Feb 13 11:18:02 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Fri Feb 13 11:18:02 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/External/SPEC/CINT95/124.m88ksim/Makefile builtins.h Message-ID: <200402131717.LAA09998@choi.cs.uiuc.edu> Changes in directory llvm/test/Programs/External/SPEC/CINT95/124.m88ksim: Makefile added (r1.1) builtins.h added (r1.1) --- Log message: Initial commit of 124.m88ksim SPEC95 integer benchmark. The builtins.h header file is here to ensure that the benchmark finds it during compilation. It needs to exist but needs not contain any code. --- Diffs of the changes: (+102 -0) Index: llvm/test/Programs/External/SPEC/CINT95/124.m88ksim/Makefile diff -c /dev/null llvm/test/Programs/External/SPEC/CINT95/124.m88ksim/Makefile:1.1 *** /dev/null Fri Feb 13 11:17:15 2004 --- llvm/test/Programs/External/SPEC/CINT95/124.m88ksim/Makefile Fri Feb 13 11:17:05 2004 *************** *** 0 **** --- 1,102 ---- + LEVEL = ../../../../../.. + STDIN_FILENAME := ctl.raw + STDOUT_FILENAME := test.out + + Source := addd.c \ + adds.c \ + alignd.c \ + aligns.c \ + asm.c \ + asmcmdstr.c \ + bf.c \ + bm.c \ + br.c \ + bs.c \ + ckiob.c \ + classify.c \ + cm.c \ + cmdparser.c \ + cmdstruct.c \ + cmmu.c \ + cmmu_atc.c \ + cmmu_cache.c \ + cmmu_ctl.c \ + cmmu_debug.c \ + cmmu_func.c \ + cmmu_init.c \ + converters.c \ + ctlregs.c \ + dc.c \ + dis.c \ + divd.c \ + divs.c \ + dmem.c \ + dpath.c \ + fadd.c \ + fadd64.c \ + fadds.c \ + fcdi.c \ + fcds.c \ + fcid.c \ + fcis.c \ + fcmp.c \ + fcmp64.c \ + fcmps.c \ + fcsd.c \ + fcsi.c \ + fdiv.c \ + fdiv64.c \ + fdivs.c \ + floaterr.c \ + flt.c \ + fmul.c \ + fmul64.c \ + fmuls.c \ + fpunimp.c \ + fsub.c \ + fsub64.c \ + fsubs.c \ + go.c \ + he.c \ + id.c \ + instab.c \ + int.c \ + interface.c \ + lo.c \ + main.c \ + map.c \ + md.c \ + mem.c \ + mm.c \ + multd.c \ + mults.c \ + normalized.c \ + normalizes.c \ + opn_output.c \ + pc.c \ + rd.c \ + reserved.c \ + reserves.c \ + returnd.c \ + returns.c \ + rm.c \ + round.c \ + roundd.c \ + rounds.c \ + runsim.c \ + sdsr.c \ + show.c \ + signals.c \ + sim_io.c \ + sim_printf.c \ + simload.c \ + simtime.c \ + stats.c \ + symbols.c \ + sysVbcs.c \ + sysface.c \ + table.c \ + trap.c \ + updstat.c + + include ../../Makefile.spec95 From criswell at cs.uiuc.edu Fri Feb 13 11:18:11 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Fri Feb 13 11:18:11 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/External/SPEC/CINT95/134.perl/ Message-ID: <200402131717.LAA10011@choi.cs.uiuc.edu> Changes in directory llvm/test/Programs/External/SPEC/CINT95/134.perl: --- Log message: Directory /home/vadve/shared/PublicCVS/llvm/test/Programs/External/SPEC/CINT95/134.perl added to the repository --- Diffs of the changes: (+0 -0) From criswell at cs.uiuc.edu Fri Feb 13 11:42:02 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Fri Feb 13 11:42:02 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/External/SPEC/CINT95/126.gcc/Makefile Message-ID: <200402131741.LAA10909@choi.cs.uiuc.edu> Changes in directory llvm/test/Programs/External/SPEC/CINT95/126.gcc: Makefile updated: 1.1 -> 1.2 --- Log message: Attempt at removing _builtin_next_arg use. --- Diffs of the changes: (+1 -1) Index: llvm/test/Programs/External/SPEC/CINT95/126.gcc/Makefile diff -u llvm/test/Programs/External/SPEC/CINT95/126.gcc/Makefile:1.1 llvm/test/Programs/External/SPEC/CINT95/126.gcc/Makefile:1.2 --- llvm/test/Programs/External/SPEC/CINT95/126.gcc/Makefile:1.1 Wed Feb 11 10:47:30 2004 +++ llvm/test/Programs/External/SPEC/CINT95/126.gcc/Makefile Fri Feb 13 11:40:55 2004 @@ -1,5 +1,5 @@ LEVEL = ../../../../../.. -CPPFLAGS += -DSPEC -I$(SPEC95_ROOT)/CINT95/126.gcc/src/src.alt +CPPFLAGS += -U_STDARG_H -DSPEC -I$(SPEC95_ROOT)/CINT95/126.gcc/src/src.alt RUN_OPTIONS := -quiet -funroll-loops -fforce-mem -fcse-follow-jumps -fcse-skip-blocks -fexpensive-optimizations -fstrength-reduce -fpeephole -fschedule-insns -finline-functions -fschedule-insns2 -O -o - STDIN_FILENAME = cccp.i STDOUT_FILENAME = cccp.s From alkis at cs.uiuc.edu Fri Feb 13 12:08:02 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri Feb 13 12:08:02 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/SSARegMap.h Message-ID: <200402131807.MAA26806@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: SSARegMap.h updated: 1.8 -> 1.9 --- Log message: Add getNumVirtualRegs(). Whitespace cleanups. --- Diffs of the changes: (+9 -5) Index: llvm/include/llvm/CodeGen/SSARegMap.h diff -u llvm/include/llvm/CodeGen/SSARegMap.h:1.8 llvm/include/llvm/CodeGen/SSARegMap.h:1.9 --- llvm/include/llvm/CodeGen/SSARegMap.h:1.8 Tue Nov 11 16:41:31 2003 +++ llvm/include/llvm/CodeGen/SSARegMap.h Fri Feb 13 12:07:06 2004 @@ -1,17 +1,17 @@ //===-- llvm/CodeGen/SSARegMap.h --------------------------------*- C++ -*-===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// -// +// // Map register numbers to register classes that are correctly sized (typed) to // hold the information. Assists register allocation. Contained by // MachineFunction, should be deleted by register allocator when it is no // longer needed. -// +// //===----------------------------------------------------------------------===// #ifndef LLVM_CODEGEN_SSAREGMAP_H @@ -26,7 +26,7 @@ class SSARegMap { std::vector RegClassMap; - unsigned rescale(unsigned Reg) { + unsigned rescale(unsigned Reg) { return Reg - MRegisterInfo::FirstVirtualRegister; } @@ -43,6 +43,10 @@ unsigned createVirtualRegister(const TargetRegisterClass *RegClass) { RegClassMap.push_back(RegClass); return RegClassMap.size()+MRegisterInfo::FirstVirtualRegister-1; + } + + unsigned getNumVirtualRegs() const { + return RegClassMap.size(); } }; From alkis at cs.uiuc.edu Fri Feb 13 12:21:02 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri Feb 13 12:21:02 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/RegAllocLocal.cpp Message-ID: <200402131820.MAA31430@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: RegAllocLocal.cpp updated: 1.43 -> 1.44 --- Log message: Use getNumVirtualRegs(). Whitespace cleanups. --- Diffs of the changes: (+34 -41) Index: llvm/lib/CodeGen/RegAllocLocal.cpp diff -u llvm/lib/CodeGen/RegAllocLocal.cpp:1.43 llvm/lib/CodeGen/RegAllocLocal.cpp:1.44 --- llvm/lib/CodeGen/RegAllocLocal.cpp:1.43 Wed Feb 11 20:27:10 2004 +++ llvm/lib/CodeGen/RegAllocLocal.cpp Fri Feb 13 12:20:47 2004 @@ -1,10 +1,10 @@ //===-- RegAllocLocal.cpp - A BasicBlock generic register allocator -------===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This register allocator allocates registers to a basic block at a time, @@ -30,7 +30,7 @@ namespace { Statistic<> NumSpilled ("ra-local", "Number of registers spilled"); Statistic<> NumReloaded("ra-local", "Number of registers reloaded"); - cl::opt DisableKill("disable-kill", cl::Hidden, + cl::opt DisableKill("disable-kill", cl::Hidden, cl::desc("Disable register kill in local-ra")); class RA : public MachineFunctionPass { @@ -58,13 +58,7 @@ && "VirtReg not in map!"); return Virt2PhysRegMap[VirtReg-MRegisterInfo::FirstVirtualRegister]; } - unsigned &getOrInsertVirt2PhysRegMapSlot(unsigned VirtReg) { - assert(VirtReg >= MRegisterInfo::FirstVirtualRegister &&"Illegal VREG #"); - if (VirtReg-MRegisterInfo::FirstVirtualRegister >= Virt2PhysRegMap.size()) - Virt2PhysRegMap.resize(VirtReg-MRegisterInfo::FirstVirtualRegister+1); - return Virt2PhysRegMap[VirtReg-MRegisterInfo::FirstVirtualRegister]; - } - + // PhysRegsUsed - This array is effectively a map, containing entries for // each physical register that currently has a value (ie, it is in // Virt2PhysRegMap). The value mapped to is the virtual register @@ -73,7 +67,7 @@ // because it is used by a future instruction. If the entry for a physical // register is -1, then the physical register is "not in the map". // - int PhysRegsUsed[MRegisterInfo::FirstVirtualRegister]; + std::vector PhysRegsUsed; // PhysRegsUseOrder - This contains a list of the physical registers that // currently have a virtual register value in them. This list provides an @@ -102,7 +96,7 @@ bool isVirtRegModified(unsigned Reg) const { assert(MRegisterInfo::isVirtualRegister(Reg) && "Illegal VirtReg!"); assert(Reg - MRegisterInfo::FirstVirtualRegister < VirtRegModified.size() - && "Illegal virtual register!"); + && "Illegal virtual register!"); return VirtRegModified[Reg - MRegisterInfo::FirstVirtualRegister]; } @@ -111,14 +105,14 @@ if (PhysRegsUseOrder.back() == Reg) return; // Already most recently used for (unsigned i = PhysRegsUseOrder.size(); i != 0; --i) - if (areRegsEqual(Reg, PhysRegsUseOrder[i-1])) { - unsigned RegMatch = PhysRegsUseOrder[i-1]; // remove from middle - PhysRegsUseOrder.erase(PhysRegsUseOrder.begin()+i-1); - // Add it to the end of the list - PhysRegsUseOrder.push_back(RegMatch); - if (RegMatch == Reg) - return; // Found an exact match, exit early - } + if (areRegsEqual(Reg, PhysRegsUseOrder[i-1])) { + unsigned RegMatch = PhysRegsUseOrder[i-1]; // remove from middle + PhysRegsUseOrder.erase(PhysRegsUseOrder.begin()+i-1); + // Add it to the end of the list + PhysRegsUseOrder.push_back(RegMatch); + if (RegMatch == Reg) + return; // Found an exact match, exit early + } } public: @@ -128,7 +122,7 @@ virtual void getAnalysisUsage(AnalysisUsage &AU) const { if (!DisableKill) - AU.addRequired(); + AU.addRequired(); AU.addRequiredID(PHIEliminationID); AU.addRequiredID(TwoAddressInstructionPassID); MachineFunctionPass::getAnalysisUsage(AU); @@ -190,7 +184,7 @@ /// the way or spilled to memory. /// void liberatePhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator &I, - unsigned PhysReg); + unsigned PhysReg); /// isPhysRegAvailable - Return true if the specified physical register is /// free and available for use. This also includes checking to see if @@ -202,14 +196,14 @@ /// specified register class. If not, return 0. /// unsigned getFreeReg(const TargetRegisterClass *RC); - + /// getReg - Find a physical register to hold the specified virtual /// register. If all compatible physical registers are used, this method /// spills the last used virtual register to the stack, and uses that /// register. /// unsigned getReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator &I, - unsigned VirtReg); + unsigned VirtReg); /// reloadVirtReg - This method loads the specified virtual register into a /// physical register, returning the physical register chosen. This updates @@ -242,7 +236,7 @@ } -/// removePhysReg - This method marks the specified physical register as no +/// removePhysReg - This method marks the specified physical register as no /// longer being in use. /// void RA::removePhysReg(unsigned PhysReg) { @@ -319,7 +313,7 @@ // Update information to note the fact that this register was just used, and // it holds VirtReg. PhysRegsUsed[PhysReg] = VirtReg; - getOrInsertVirt2PhysRegMapSlot(VirtReg) = PhysReg; + getVirt2PhysRegMapSlot(VirtReg) = PhysReg; PhysRegsUseOrder.push_back(PhysReg); // New use of PhysReg } @@ -364,7 +358,7 @@ /// or spilled to memory. /// void RA::liberatePhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator &I, - unsigned PhysReg) { + unsigned PhysReg) { // FIXME: This code checks to see if a register is available, but it really // wants to know if a reg is available BEFORE the instruction executes. If // called after killed operands are freed, it runs the risk of reallocating a @@ -386,12 +380,12 @@ if (unsigned NewReg = getFreeReg(RC)) { // Emit the code to copy the value... RegInfo->copyRegToReg(MBB, I, NewReg, PhysReg, RC); - + // Update our internal state to indicate that PhysReg is available and Reg // isn't. getVirt2PhysRegMapSlot[VirtReg] = 0; removePhysReg(PhysReg); // Free the physreg - + // Move reference over to new register... assignVirtToPhysReg(VirtReg, NewReg); return; @@ -407,7 +401,7 @@ /// the last used virtual register to the stack, and uses that register. /// unsigned RA::getReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator &I, - unsigned VirtReg) { + unsigned VirtReg) { const TargetRegisterClass *RC = MF->getSSARegMap()->getRegClass(VirtReg); // First check to see if we have a free register of the requested type... @@ -423,7 +417,7 @@ for (unsigned i = 0; PhysReg == 0; ++i) { assert(i != PhysRegsUseOrder.size() && "Couldn't find a register of the appropriate class!"); - + unsigned R = PhysRegsUseOrder[i]; // We can only use this register if it holds a virtual register (ie, it @@ -471,7 +465,7 @@ unsigned RA::reloadVirtReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator &I, unsigned VirtReg) { - if (unsigned PR = getOrInsertVirt2PhysRegMapSlot(VirtReg)) { + if (unsigned PR = getVirt2PhysRegMapSlot(VirtReg)) { MarkPhysRegRecentlyUsed(PR); return PR; // Already have this value available! } @@ -527,7 +521,7 @@ unsigned PhysSrcReg = reloadVirtReg(MBB, MI, VirtSrcReg); MI->SetMachineOperandReg(i, PhysSrcReg); // Assign the input register } - + if (!DisableKill) { // If this instruction is the last user of anything in registers, kill the // value, freeing the register being used, so it doesn't need to be @@ -594,7 +588,7 @@ unsigned DestPhysReg; // If DestVirtReg already has a value, use it. - if (!(DestPhysReg = getOrInsertVirt2PhysRegMapSlot(DestVirtReg))) + if (!(DestPhysReg = getVirt2PhysRegMapSlot(DestVirtReg))) DestPhysReg = getReg(MBB, MI, DestVirtReg); markVirtRegModified(DestVirtReg); MI->SetMachineOperandReg(i, DestPhysReg); // Assign the output register @@ -648,7 +642,7 @@ } assert(AllOk && "Virtual registers still in phys regs?"); #endif - + // Clear any physical register which appear live at the end of the basic // block, but which do not hold any virtual registers. e.g., the stack // pointer. @@ -664,12 +658,11 @@ TM = &Fn.getTarget(); RegInfo = TM->getRegisterInfo(); - memset(PhysRegsUsed, -1, RegInfo->getNumRegs()*sizeof(unsigned)); + PhysRegsUsed.assign(RegInfo->getNumRegs(), -1); - // Reserve some space for a moderate number of registers. If we know what the - // max virtual register number was we could use that instead and save some - // runtime overhead... - Virt2PhysRegMap.resize(1024); + // initialize the virtual->physical register map to have a 'null' + // mapping for all virtual registers + Virt2PhysRegMap.assign(MF->getSSARegMap()->getNumVirtualRegs(), 0); if (!DisableKill) LV = &getAnalysis(); @@ -680,6 +673,7 @@ AllocateBasicBlock(*MBB); StackSlotForVirtReg.clear(); + PhysRegsUsed.clear(); VirtRegModified.clear(); Virt2PhysRegMap.clear(); return true; @@ -688,4 +682,3 @@ FunctionPass *llvm::createLocalRegisterAllocator() { return new RA(); } - From alkis at cs.uiuc.edu Fri Feb 13 14:06:01 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri Feb 13 14:06:01 2004 Subject: [llvm-commits] CVS: llvm/Makefile.rules Message-ID: <200402132005.OAA17841@zion.cs.uiuc.edu> Changes in directory llvm: Makefile.rules updated: 1.178 -> 1.179 --- Log message: Define DEPRECATED so that it can be used in function and variable declarations. --- Diffs of the changes: (+3 -0) Index: llvm/Makefile.rules diff -u llvm/Makefile.rules:1.178 llvm/Makefile.rules:1.179 --- llvm/Makefile.rules:1.178 Mon Feb 9 11:38:52 2004 +++ llvm/Makefile.rules Fri Feb 13 14:05:44 2004 @@ -289,6 +289,9 @@ # Pull in limit macros from stdint.h, even in C++: CPPFLAGS += -D__STDC_LIMIT_MACROS +### FIXME: this is GCC specific +CPPFLAGS += -DDEPRECATED='__attribute__ ((deprecated))' + CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused CompileOptimizeOpts := -O3 -DNDEBUG -finline-functions From lattner at cs.uiuc.edu Fri Feb 13 14:06:12 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 14:06:12 2004 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/Local.cpp Message-ID: <200402132005.OAA17830@zion.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: Local.cpp updated: 1.79 -> 1.80 --- Log message: Add support for fopen/fclose. Specifically with fopen, we were marking all of the operands as incomplete, though fopen is known to only read them. This just adds fclose for symmetry, though it doesn't gain anything. This makes the dsgraphs for 181.mcf much more precise. --- Diffs of the changes: (+27 -0) Index: llvm/lib/Analysis/DataStructure/Local.cpp diff -u llvm/lib/Analysis/DataStructure/Local.cpp:1.79 llvm/lib/Analysis/DataStructure/Local.cpp:1.80 --- llvm/lib/Analysis/DataStructure/Local.cpp:1.79 Fri Feb 13 10:09:54 2004 +++ llvm/lib/Analysis/DataStructure/Local.cpp Fri Feb 13 14:05:32 2004 @@ -493,6 +493,33 @@ if (DSNode *N = H.getNode()) N->setModifiedMarker(); return; + } else if (F->getName() == "fopen" && CS.arg_end()-CS.arg_begin() == 2){ + // fopen reads the mode argument strings. + CallSite::arg_iterator AI = CS.arg_begin(); + DSNodeHandle Path = getValueDest(**AI); + DSNodeHandle Mode = getValueDest(**++AI); + if (DSNode *N = Path.getNode()) N->setReadMarker(); + if (DSNode *N = Mode.getNode()) N->setReadMarker(); + + // fopen allocates in an unknown way and writes to the file + // descriptor. Also, merge the allocated type into the node. + DSNodeHandle Result = getValueDest(*CS.getInstruction()); + Result.getNode()->setModifiedMarker()->setUnknownNodeMarker(); + const Type *RetTy = F->getFunctionType()->getReturnType(); + if (const PointerType *PTy = dyn_cast(RetTy)) + Result.getNode()->mergeTypeInfo(PTy->getElementType(), + Result.getOffset()); + return; + } else if (F->getName() == "fclose" && CS.arg_end()-CS.arg_begin() ==1){ + // fclose reads and deallocates the memory in an unknown way for the + // file descriptor. It merges the FILE type into the descriptor. + DSNodeHandle H = getValueDest(**CS.arg_begin()); + H.getNode()->setReadMarker()->setUnknownNodeMarker(); + + const Type *ArgTy = *F->getFunctionType()->param_begin(); + if (const PointerType *PTy = dyn_cast(ArgTy)) + H.getNode()->mergeTypeInfo(PTy->getElementType(), H.getOffset()); + return; } } From alkis at cs.uiuc.edu Fri Feb 13 14:07:02 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri Feb 13 14:07:02 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/MachineBasicBlock.h Message-ID: <200402132006.OAA17851@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: MachineBasicBlock.h updated: 1.17 -> 1.18 --- Log message: Mark MachineBasicBlock::operator[] deprecated. --- Diffs of the changes: (+20 -10) Index: llvm/include/llvm/CodeGen/MachineBasicBlock.h diff -u llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.17 llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.18 --- llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.17 Thu Feb 12 22:40:15 2004 +++ llvm/include/llvm/CodeGen/MachineBasicBlock.h Fri Feb 13 14:05:56 2004 @@ -93,16 +93,11 @@ unsigned size() const { return Insts.size(); } bool empty() const { return Insts.empty(); } - const MachineInstr& operator[](unsigned i) const { - const_iterator it = Insts.begin(); - std::advance(it, i); - return *it; - } - MachineInstr& operator[](unsigned i) { - iterator it = Insts.begin(); - std::advance(it, i); - return *it; - } + // This is a really inefficient way of accessing a basic + // block. These methods will be removed when all of their uses are + // eliminated. + inline const MachineInstr& operator[](unsigned i) const DEPRECATED; + inline MachineInstr& operator[](unsigned i) DEPRECATED; MachineInstr& front() { return Insts.front(); } MachineInstr& back() { return Insts.back(); } @@ -140,6 +135,21 @@ void setPrev(MachineBasicBlock *P) { Prev = P; } void setNext(MachineBasicBlock *N) { Next = N; } }; + +const MachineInstr& MachineBasicBlock::operator[](unsigned i) const +{ + const_iterator it = Insts.begin(); + std::advance(it, i); + return *it; +} + +MachineInstr& MachineBasicBlock::operator[](unsigned i) +{ + iterator it = Insts.begin(); + std::advance(it, i); + return *it; +} + } // End llvm namespace From alkis at cs.uiuc.edu Fri Feb 13 15:02:03 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri Feb 13 15:02:03 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/TwoAddressInstructionPass.cpp RegAllocSimple.cpp RegAllocLocal.cpp RegAllocLinearScan.cpp PHIElimination.cpp MachineInstr.cpp LiveIntervals.cpp Message-ID: <200402132101.PAA25817@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: TwoAddressInstructionPass.cpp updated: 1.14 -> 1.15 RegAllocSimple.cpp updated: 1.49 -> 1.50 RegAllocLocal.cpp updated: 1.44 -> 1.45 RegAllocLinearScan.cpp updated: 1.45 -> 1.46 PHIElimination.cpp updated: 1.16 -> 1.17 MachineInstr.cpp updated: 1.88 -> 1.89 LiveIntervals.cpp updated: 1.48 -> 1.49 --- Log message: Remove getAllocatedRegNum(). Use getReg() instead. --- Diffs of the changes: (+22 -22) Index: llvm/lib/CodeGen/TwoAddressInstructionPass.cpp diff -u llvm/lib/CodeGen/TwoAddressInstructionPass.cpp:1.14 llvm/lib/CodeGen/TwoAddressInstructionPass.cpp:1.15 --- llvm/lib/CodeGen/TwoAddressInstructionPass.cpp:1.14 Wed Feb 11 20:27:10 2004 +++ llvm/lib/CodeGen/TwoAddressInstructionPass.cpp Fri Feb 13 15:01:20 2004 @@ -97,14 +97,14 @@ DEBUG(std::cerr << "\tinstruction: "; mi->print(std::cerr, TM)); assert(mi->getOperand(1).isRegister() && - mi->getOperand(1).getAllocatedRegNum() && + mi->getOperand(1).getReg() && mi->getOperand(1).isUse() && "two address instruction invalid"); // if the two operands are the same we just remove the use // and mark the def as def&use - if (mi->getOperand(0).getAllocatedRegNum() == - mi->getOperand(1).getAllocatedRegNum()) { + if (mi->getOperand(0).getReg() == + mi->getOperand(1).getReg()) { } else { MadeChange = true; @@ -114,8 +114,8 @@ // to: // a = b // a = a op c - unsigned regA = mi->getOperand(0).getAllocatedRegNum(); - unsigned regB = mi->getOperand(1).getAllocatedRegNum(); + unsigned regA = mi->getOperand(0).getReg(); + unsigned regB = mi->getOperand(1).getReg(); assert(MRegisterInfo::isVirtualRegister(regA) && MRegisterInfo::isVirtualRegister(regB) && @@ -127,7 +127,7 @@ // because we are in SSA form. for (unsigned i = 1; i != mi->getNumOperands(); ++i) assert(!mi->getOperand(i).isRegister() || - mi->getOperand(i).getAllocatedRegNum() != (int)regA); + mi->getOperand(i).getReg() != regA); const TargetRegisterClass* rc = MF.getSSARegMap()->getRegClass(regA); Index: llvm/lib/CodeGen/RegAllocSimple.cpp diff -u llvm/lib/CodeGen/RegAllocSimple.cpp:1.49 llvm/lib/CodeGen/RegAllocSimple.cpp:1.50 --- llvm/lib/CodeGen/RegAllocSimple.cpp:1.49 Wed Feb 11 20:27:10 2004 +++ llvm/lib/CodeGen/RegAllocSimple.cpp Fri Feb 13 15:01:20 2004 @@ -173,7 +173,7 @@ MachineOperand &op = MI->getOperand(i); if (op.isRegister() && MRegisterInfo::isVirtualRegister(op.getReg())) { - unsigned virtualReg = (unsigned) op.getAllocatedRegNum(); + unsigned virtualReg = (unsigned) op.getReg(); DEBUG(std::cerr << "op: " << op << "\n"); DEBUG(std::cerr << "\t inst[" << i << "]: "; MI->print(std::cerr, *TM)); @@ -187,11 +187,11 @@ // must be same register number as the first operand // This maps a = b + c into b += c, and saves b into a's spot assert(MI->getOperand(1).isRegister() && - MI->getOperand(1).getAllocatedRegNum() && + MI->getOperand(1).getReg() && MI->getOperand(1).isUse() && "Two address instruction invalid!"); - physReg = MI->getOperand(1).getAllocatedRegNum(); + physReg = MI->getOperand(1).getReg(); } else { physReg = getFreeReg(virtualReg); } @@ -205,7 +205,7 @@ } MI->SetMachineOperandReg(i, physReg); DEBUG(std::cerr << "virt: " << virtualReg << - ", phys: " << op.getAllocatedRegNum() << "\n"); + ", phys: " << op.getReg() << "\n"); } } RegClassIdx.clear(); Index: llvm/lib/CodeGen/RegAllocLocal.cpp diff -u llvm/lib/CodeGen/RegAllocLocal.cpp:1.44 llvm/lib/CodeGen/RegAllocLocal.cpp:1.45 --- llvm/lib/CodeGen/RegAllocLocal.cpp:1.44 Fri Feb 13 12:20:47 2004 +++ llvm/lib/CodeGen/RegAllocLocal.cpp Fri Feb 13 15:01:20 2004 @@ -517,7 +517,7 @@ if (MI->getOperand(i).isUse() && !MI->getOperand(i).isDef() && MI->getOperand(i).isRegister() && MRegisterInfo::isVirtualRegister(MI->getOperand(i).getReg())) { - unsigned VirtSrcReg = MI->getOperand(i).getAllocatedRegNum(); + unsigned VirtSrcReg = MI->getOperand(i).getReg(); unsigned PhysSrcReg = reloadVirtReg(MBB, MI, VirtSrcReg); MI->SetMachineOperandReg(i, PhysSrcReg); // Assign the input register } @@ -551,7 +551,7 @@ for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) if (MI->getOperand(i).isDef() && MI->getOperand(i).isRegister() && MRegisterInfo::isPhysicalRegister(MI->getOperand(i).getReg())) { - unsigned Reg = MI->getOperand(i).getAllocatedRegNum(); + unsigned Reg = MI->getOperand(i).getReg(); spillPhysReg(MBB, MI, Reg, true); // Spill any existing value in the reg PhysRegsUsed[Reg] = 0; // It is free and reserved now PhysRegsUseOrder.push_back(Reg); @@ -584,7 +584,7 @@ for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) if (MI->getOperand(i).isDef() && MI->getOperand(i).isRegister() && MRegisterInfo::isVirtualRegister(MI->getOperand(i).getReg())) { - unsigned DestVirtReg = MI->getOperand(i).getAllocatedRegNum(); + unsigned DestVirtReg = MI->getOperand(i).getReg(); unsigned DestPhysReg; // If DestVirtReg already has a value, use it. Index: llvm/lib/CodeGen/RegAllocLinearScan.cpp diff -u llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.45 llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.46 --- llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.45 Wed Feb 11 20:27:10 2004 +++ llvm/lib/CodeGen/RegAllocLinearScan.cpp Fri Feb 13 15:01:20 2004 @@ -443,7 +443,7 @@ MachineOperand& op = currentInstr_->getOperand(i); if (op.isRegister() && op.isUse() && MRegisterInfo::isVirtualRegister(op.getReg())) { - unsigned virtReg = op.getAllocatedRegNum(); + unsigned virtReg = op.getReg(); unsigned physReg = 0; Virt2PhysMap::iterator it = v2pMap_.find(virtReg); if (it != v2pMap_.end()) { Index: llvm/lib/CodeGen/PHIElimination.cpp diff -u llvm/lib/CodeGen/PHIElimination.cpp:1.16 llvm/lib/CodeGen/PHIElimination.cpp:1.17 --- llvm/lib/CodeGen/PHIElimination.cpp:1.16 Wed Feb 11 20:27:10 2004 +++ llvm/lib/CodeGen/PHIElimination.cpp Fri Feb 13 15:01:20 2004 @@ -76,7 +76,7 @@ assert(MRegisterInfo::isVirtualRegister(MI->getOperand(0).getReg()) && "PHI node doesn't write virt reg?"); - unsigned DestReg = MI->getOperand(0).getAllocatedRegNum(); + unsigned DestReg = MI->getOperand(0).getReg(); // Create a new register for the incoming PHI arguments const TargetRegisterClass *RC = MF.getSSARegMap()->getRegClass(DestReg); Index: llvm/lib/CodeGen/MachineInstr.cpp diff -u llvm/lib/CodeGen/MachineInstr.cpp:1.88 llvm/lib/CodeGen/MachineInstr.cpp:1.89 --- llvm/lib/CodeGen/MachineInstr.cpp:1.88 Thu Feb 12 22:39:32 2004 +++ llvm/lib/CodeGen/MachineInstr.cpp Fri Feb 13 15:01:20 2004 @@ -187,7 +187,7 @@ static inline void OutputReg(std::ostream &os, unsigned RegNo, const MRegisterInfo *MRI = 0) { if (MRI) { - if (RegNo < MRegisterInfo::FirstVirtualRegister) + if (MRegisterInfo::isPhysicalRegister(RegNo)) os << "%" << MRI->get(RegNo).Name; else os << "%reg" << RegNo; @@ -219,14 +219,14 @@ OS << "=="; } if (MO.hasAllocatedReg()) - OutputReg(OS, MO.getAllocatedRegNum(), MRI); + OutputReg(OS, MO.getReg(), MRI); break; case MachineOperand::MO_CCRegister: OS << "%ccreg"; OutputValue(OS, MO.getVRegValue()); if (MO.hasAllocatedReg()) { OS << "=="; - OutputReg(OS, MO.getAllocatedRegNum(), MRI); + OutputReg(OS, MO.getReg(), MRI); } break; case MachineOperand::MO_MachineRegister: @@ -360,7 +360,7 @@ { case MachineOperand::MO_VirtualRegister: if (MO.hasAllocatedReg()) - OutputReg(OS, MO.getAllocatedRegNum()); + OutputReg(OS, MO.getReg()); if (MO.getVRegValue()) { if (MO.hasAllocatedReg()) OS << "=="; @@ -373,7 +373,7 @@ OutputValue(OS, MO.getVRegValue()); if (MO.hasAllocatedReg()) { OS << "=="; - OutputReg(OS, MO.getAllocatedRegNum()); + OutputReg(OS, MO.getReg()); } break; case MachineOperand::MO_MachineRegister: Index: llvm/lib/CodeGen/LiveIntervals.cpp diff -u llvm/lib/CodeGen/LiveIntervals.cpp:1.48 llvm/lib/CodeGen/LiveIntervals.cpp:1.49 --- llvm/lib/CodeGen/LiveIntervals.cpp:1.48 Wed Feb 11 20:27:10 2004 +++ llvm/lib/CodeGen/LiveIntervals.cpp Fri Feb 13 15:01:20 2004 @@ -115,7 +115,7 @@ const MachineOperand& mop = mi->getOperand(i); if (mop.isRegister() && MRegisterInfo::isVirtualRegister(mop.getReg())) { - unsigned reg = mop.getAllocatedRegNum(); + unsigned reg = mop.getReg(); Reg2IntervalMap::iterator r2iit = r2iMap_.find(reg); assert(r2iit != r2iMap_.end()); r2iit->second->weight += pow(10.0F, loopDepth); @@ -313,7 +313,7 @@ MachineOperand& mop = mi->getOperand(i); // handle register defs - build intervals if (mop.isRegister() && mop.isDef()) - handleRegisterDef(mbb, mi, mop.getAllocatedRegNum()); + handleRegisterDef(mbb, mi, mop.getReg()); } } } From alkis at cs.uiuc.edu Fri Feb 13 15:02:13 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri Feb 13 15:02:13 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp SparcRegInfo.h SparcRegInfo.cpp PeepholeOpts.cpp EmitAssembly.cpp Message-ID: <200402132101.PAA25789@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/Sparc: SparcV9CodeEmitter.cpp updated: 1.55 -> 1.56 SparcRegInfo.h updated: 1.8 -> 1.9 SparcRegInfo.cpp updated: 1.117 -> 1.118 PeepholeOpts.cpp updated: 1.19 -> 1.20 EmitAssembly.cpp updated: 1.105 -> 1.106 --- Log message: Remove getAllocatedRegNum(). Use getReg() instead. --- Diffs of the changes: (+8 -9) Index: llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp diff -u llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp:1.55 llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp:1.56 --- llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp:1.55 Wed Feb 11 20:27:09 2004 +++ llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp Fri Feb 13 15:01:20 2004 @@ -661,7 +661,7 @@ // This is necessary because the Sparc backend doesn't actually lay out // registers in the real fashion -- it skips those that it chooses not to // allocate, i.e. those that are the FP, SP, etc. - unsigned fakeReg = MO.getAllocatedRegNum(); + unsigned fakeReg = MO.getReg(); unsigned realRegByClass = getRealRegNum(fakeReg, MI); DEBUG(std::cerr << MO << ": Reg[" << std::dec << fakeReg << "] => " << realRegByClass << " (LLC: " Index: llvm/lib/Target/Sparc/SparcRegInfo.h diff -u llvm/lib/Target/Sparc/SparcRegInfo.h:1.8 llvm/lib/Target/Sparc/SparcRegInfo.h:1.9 --- llvm/lib/Target/Sparc/SparcRegInfo.h:1.8 Thu Jan 15 12:17:07 2004 +++ llvm/lib/Target/Sparc/SparcRegInfo.h Fri Feb 13 15:01:20 2004 @@ -86,7 +86,7 @@ // getZeroRegNum - returns the register that contains always zero this is the // unified register number // - virtual int getZeroRegNum() const; + virtual unsigned getZeroRegNum() const; // getCallAddressReg - returns the reg used for pushing the address when a // function is called. This can be used for other purposes between calls Index: llvm/lib/Target/Sparc/SparcRegInfo.cpp diff -u llvm/lib/Target/Sparc/SparcRegInfo.cpp:1.117 llvm/lib/Target/Sparc/SparcRegInfo.cpp:1.118 --- llvm/lib/Target/Sparc/SparcRegInfo.cpp:1.117 Wed Feb 11 14:47:33 2004 +++ llvm/lib/Target/Sparc/SparcRegInfo.cpp Fri Feb 13 15:01:20 2004 @@ -52,7 +52,7 @@ // getZeroRegNum - returns the register that contains always zero. // this is the unified register number // -int SparcRegInfo::getZeroRegNum() const { +unsigned SparcRegInfo::getZeroRegNum() const { return getUnifiedRegNum(SparcRegInfo::IntRegClassID, SparcIntRegClass::g0); } Index: llvm/lib/Target/Sparc/PeepholeOpts.cpp diff -u llvm/lib/Target/Sparc/PeepholeOpts.cpp:1.19 llvm/lib/Target/Sparc/PeepholeOpts.cpp:1.20 --- llvm/lib/Target/Sparc/PeepholeOpts.cpp:1.19 Wed Feb 11 20:27:09 2004 +++ llvm/lib/Target/Sparc/PeepholeOpts.cpp Fri Feb 13 15:01:20 2004 @@ -63,16 +63,15 @@ 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()); + MI->getOperand(0).getReg() == MI->getOperand(1).getReg()); } else if (MI->getOpcode() == V9::ADDr || MI->getOpcode() == V9::ORr || MI->getOpcode() == V9::ADDi || MI->getOpcode() == V9::ORi) { unsigned srcWithDestReg; for (srcWithDestReg = 0; srcWithDestReg < 2; ++srcWithDestReg) if (MI->getOperand(srcWithDestReg).hasAllocatedReg() && - MI->getOperand(srcWithDestReg).getAllocatedRegNum() - == MI->getOperand(2).getAllocatedRegNum()) + MI->getOperand(srcWithDestReg).getReg() + == MI->getOperand(2).getReg()) break; if (srcWithDestReg == 2) @@ -82,7 +81,7 @@ unsigned otherOp = 1 - srcWithDestReg; return (// either operand otherOp is register %g0 (MI->getOperand(otherOp).hasAllocatedReg() && - MI->getOperand(otherOp).getAllocatedRegNum() == + MI->getOperand(otherOp).getReg() == target.getRegInfo().getZeroRegNum()) || // or operand otherOp == 0 Index: llvm/lib/Target/Sparc/EmitAssembly.cpp diff -u llvm/lib/Target/Sparc/EmitAssembly.cpp:1.105 llvm/lib/Target/Sparc/EmitAssembly.cpp:1.106 --- llvm/lib/Target/Sparc/EmitAssembly.cpp:1.105 Wed Feb 11 20:27:09 2004 +++ llvm/lib/Target/Sparc/EmitAssembly.cpp Fri Feb 13 15:01:20 2004 @@ -637,7 +637,7 @@ case MachineOperand::MO_CCRegister: case MachineOperand::MO_MachineRegister: { - int regNum = (int)mop.getAllocatedRegNum(); + int regNum = (int)mop.getReg(); if (regNum == Target.getRegInfo().getInvalidRegNum()) { // better to print code with NULL registers than to die From alkis at cs.uiuc.edu Fri Feb 13 15:02:22 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri Feb 13 15:02:22 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/InstrSelection/InstrSelectionSupport.cpp Message-ID: <200402132101.PAA25764@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/Sparc/InstrSelection: InstrSelectionSupport.cpp updated: 1.62 -> 1.63 --- Log message: Remove getAllocatedRegNum(). Use getReg() instead. --- Diffs of the changes: (+2 -1) Index: llvm/lib/Target/Sparc/InstrSelection/InstrSelectionSupport.cpp diff -u llvm/lib/Target/Sparc/InstrSelection/InstrSelectionSupport.cpp:1.62 llvm/lib/Target/Sparc/InstrSelection/InstrSelectionSupport.cpp:1.63 --- llvm/lib/Target/Sparc/InstrSelection/InstrSelectionSupport.cpp:1.62 Wed Feb 11 14:47:33 2004 +++ llvm/lib/Target/Sparc/InstrSelection/InstrSelectionSupport.cpp Fri Feb 13 15:01:19 2004 @@ -71,7 +71,8 @@ opType = isSigned? MachineOperand::MO_SignExtendedImmed : MachineOperand::MO_UnextendedImmed; getImmedValue = intValue; - } else if (intValue == 0 && target.getRegInfo().getZeroRegNum() >= 0) { + } else if (intValue == 0 && + target.getRegInfo().getZeroRegNum() != (unsigned)-1) { opType = MachineOperand::MO_MachineRegister; getMachineRegNum = target.getRegInfo().getZeroRegNum(); } From alkis at cs.uiuc.edu Fri Feb 13 15:02:30 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri Feb 13 15:02:30 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/InstrSched/SchedGraph.cpp Message-ID: <200402132101.PAA25786@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/InstrSched: SchedGraph.cpp updated: 1.57 -> 1.58 --- Log message: Remove getAllocatedRegNum(). Use getReg() instead. --- Diffs of the changes: (+4 -4) Index: llvm/lib/CodeGen/InstrSched/SchedGraph.cpp diff -u llvm/lib/CodeGen/InstrSched/SchedGraph.cpp:1.57 llvm/lib/CodeGen/InstrSched/SchedGraph.cpp:1.58 --- llvm/lib/CodeGen/InstrSched/SchedGraph.cpp:1.57 Wed Feb 11 20:27:10 2004 +++ llvm/lib/CodeGen/InstrSched/SchedGraph.cpp Fri Feb 13 15:01:20 2004 @@ -487,11 +487,11 @@ // if this references a register other than the hardwired // "zero" register, record the reference. if (mop.hasAllocatedReg()) { - int regNum = mop.getAllocatedRegNum(); + unsigned regNum = mop.getReg(); // If this is not a dummy zero register, record the reference in order if (regNum != target.getRegInfo().getZeroRegNum()) - regToRefVecMap[mop.getAllocatedRegNum()] + regToRefVecMap[mop.getReg()] .push_back(std::make_pair(node, i)); // If this is a volatile register, add the instruction to callDepVec @@ -528,9 +528,9 @@ for (unsigned i=0, N = MI.getNumImplicitRefs(); i != N; ++i) { const MachineOperand& mop = MI.getImplicitOp(i); if (mop.hasAllocatedReg()) { - int regNum = mop.getAllocatedRegNum(); + unsigned regNum = mop.getReg(); if (regNum != target.getRegInfo().getZeroRegNum()) - regToRefVecMap[mop.getAllocatedRegNum()] + regToRefVecMap[mop.getReg()] .push_back(std::make_pair(node, i + MI.getNumOperands())); continue; // nothing more to do } From alkis at cs.uiuc.edu Fri Feb 13 15:02:39 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri Feb 13 15:02:39 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/MachineInstr.h Message-ID: <200402132101.PAA25822@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: MachineInstr.h updated: 1.135 -> 1.136 --- Log message: Remove getAllocatedRegNum(). Use getReg() instead. --- Diffs of the changes: (+1 -4) Index: llvm/include/llvm/CodeGen/MachineInstr.h diff -u llvm/include/llvm/CodeGen/MachineInstr.h:1.135 llvm/include/llvm/CodeGen/MachineInstr.h:1.136 --- llvm/include/llvm/CodeGen/MachineInstr.h:1.135 Thu Feb 12 13:12:03 2004 +++ llvm/include/llvm/CodeGen/MachineInstr.h Fri Feb 13 15:01:20 2004 @@ -277,15 +277,12 @@ } // used to get the reg number if when one is allocated - int getAllocatedRegNum() const { + unsigned getReg() const { assert(hasAllocatedReg()); return regNum; } // ********** TODO: get rid of this duplicate code! *********** - unsigned getReg() const { - return getAllocatedRegNum(); - } void setReg(unsigned Reg) { assert(hasAllocatedReg() && "This operand cannot have a register number!"); regNum = Reg; From alkis at cs.uiuc.edu Fri Feb 13 15:02:48 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri Feb 13 15:02:48 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Target/TargetRegInfo.h Message-ID: <200402132101.PAA25810@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Target: TargetRegInfo.h updated: 1.47 -> 1.48 --- Log message: Remove getAllocatedRegNum(). Use getReg() instead. --- Diffs of the changes: (+1 -1) Index: llvm/include/llvm/Target/TargetRegInfo.h diff -u llvm/include/llvm/Target/TargetRegInfo.h:1.47 llvm/include/llvm/Target/TargetRegInfo.h:1.48 --- llvm/include/llvm/Target/TargetRegInfo.h:1.47 Tue Nov 11 16:41:31 2003 +++ llvm/include/llvm/Target/TargetRegInfo.h Fri Feb 13 15:01:20 2004 @@ -149,7 +149,7 @@ // returns the register that is hardwired to zero if any (-1 if none) // - virtual int getZeroRegNum() const = 0; + virtual unsigned getZeroRegNum() const = 0; // Number of registers used for passing int args (usually 6: %o0 - %o5) // and float args (usually 32: %f0 - %f31) From alkis at cs.uiuc.edu Fri Feb 13 15:02:56 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri Feb 13 15:02:56 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/RegAlloc/PhyRegAlloc.cpp LiveRangeInfo.cpp Message-ID: <200402132101.PAA25759@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/Sparc/RegAlloc: PhyRegAlloc.cpp updated: 1.135 -> 1.136 LiveRangeInfo.cpp updated: 1.50 -> 1.51 --- Log message: Remove getAllocatedRegNum(). Use getReg() instead. --- Diffs of the changes: (+5 -7) Index: llvm/lib/Target/Sparc/RegAlloc/PhyRegAlloc.cpp diff -u llvm/lib/Target/Sparc/RegAlloc/PhyRegAlloc.cpp:1.135 llvm/lib/Target/Sparc/RegAlloc/PhyRegAlloc.cpp:1.136 --- llvm/lib/Target/Sparc/RegAlloc/PhyRegAlloc.cpp:1.135 Wed Feb 11 22:01:07 2004 +++ llvm/lib/Target/Sparc/RegAlloc/PhyRegAlloc.cpp Fri Feb 13 15:01:19 2004 @@ -1019,12 +1019,11 @@ // explicit and implicit operands are set. for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) if (MI->getOperand(i).hasAllocatedReg()) - markRegisterUsed(MI->getOperand(i).getAllocatedRegNum(), RC, RegType,MRI); + markRegisterUsed(MI->getOperand(i).getReg(), RC, RegType,MRI); for (unsigned i = 0, e = MI->getNumImplicitRefs(); i != e; ++i) if (MI->getImplicitOp(i).hasAllocatedReg()) - markRegisterUsed(MI->getImplicitOp(i).getAllocatedRegNum(), RC, - RegType,MRI); + markRegisterUsed(MI->getImplicitOp(i).getReg(), RC, RegType,MRI); // Add all of the scratch registers that are used to save values across the // instruction (e.g., for saving state register values). Index: llvm/lib/Target/Sparc/RegAlloc/LiveRangeInfo.cpp diff -u llvm/lib/Target/Sparc/RegAlloc/LiveRangeInfo.cpp:1.50 llvm/lib/Target/Sparc/RegAlloc/LiveRangeInfo.cpp:1.51 --- llvm/lib/Target/Sparc/RegAlloc/LiveRangeInfo.cpp:1.50 Wed Feb 11 20:27:09 2004 +++ llvm/lib/Target/Sparc/RegAlloc/LiveRangeInfo.cpp Fri Feb 13 15:01:19 2004 @@ -194,9 +194,8 @@ // set it directly in the LiveRange if (OpI.getMachineOperand().hasAllocatedReg()) { unsigned getClassId; - LR->setColor(MRI.getClassRegNum( - OpI.getMachineOperand().getAllocatedRegNum(), - getClassId)); + LR->setColor(MRI.getClassRegNum(OpI.getMachineOperand().getReg(), + getClassId)); } } @@ -212,7 +211,7 @@ if (MInst->getImplicitOp(i).hasAllocatedReg()) { unsigned getClassId; LR->setColor(MRI.getClassRegNum( - MInst->getImplicitOp(i).getAllocatedRegNum(), + MInst->getImplicitOp(i).getReg(), getClassId)); } } From alkis at cs.uiuc.edu Fri Feb 13 15:03:05 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri Feb 13 15:03:05 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86InstrInfo.cpp Message-ID: <200402132101.PAA25752@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86InstrInfo.cpp updated: 1.21 -> 1.22 --- Log message: Remove getAllocatedRegNum(). Use getReg() instead. --- Diffs of the changes: (+2 -2) Index: llvm/lib/Target/X86/X86InstrInfo.cpp diff -u llvm/lib/Target/X86/X86InstrInfo.cpp:1.21 llvm/lib/Target/X86/X86InstrInfo.cpp:1.22 --- llvm/lib/Target/X86/X86InstrInfo.cpp:1.21 Tue Feb 10 14:31:28 2004 +++ llvm/lib/Target/X86/X86InstrInfo.cpp Fri Feb 13 15:01:19 2004 @@ -61,8 +61,8 @@ MI.getOperand(0).isRegister() && MI.getOperand(1).isRegister() && "invalid register-register move instruction"); - sourceReg = MI.getOperand(1).getAllocatedRegNum(); - destReg = MI.getOperand(0).getAllocatedRegNum(); + sourceReg = MI.getOperand(1).getReg(); + destReg = MI.getOperand(0).getReg(); return true; } return false; From criswell at cs.uiuc.edu Fri Feb 13 15:10:05 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Fri Feb 13 15:10:05 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/External/SPEC/CINT95/126.gcc/Makefile Message-ID: <200402132109.PAA24848@choi.cs.uiuc.edu> Changes in directory llvm/test/Programs/External/SPEC/CINT95/126.gcc: Makefile updated: 1.2 -> 1.3 --- Log message: Fix for removing builtin_next_arg from being called. Basically, we want bytetypes.h from src.alt to get included, but not the stdard in src.alt. Adding the directory to the secondary include path gets us the right combination. --- Diffs of the changes: (+1 -1) Index: llvm/test/Programs/External/SPEC/CINT95/126.gcc/Makefile diff -u llvm/test/Programs/External/SPEC/CINT95/126.gcc/Makefile:1.2 llvm/test/Programs/External/SPEC/CINT95/126.gcc/Makefile:1.3 --- llvm/test/Programs/External/SPEC/CINT95/126.gcc/Makefile:1.2 Fri Feb 13 11:40:55 2004 +++ llvm/test/Programs/External/SPEC/CINT95/126.gcc/Makefile Fri Feb 13 15:08:57 2004 @@ -1,5 +1,5 @@ LEVEL = ../../../../../.. -CPPFLAGS += -U_STDARG_H -DSPEC -I$(SPEC95_ROOT)/CINT95/126.gcc/src/src.alt +CPPFLAGS += -DSPEC -idirafter $(SPEC95_ROOT)/CINT95/126.gcc/src/src.alt RUN_OPTIONS := -quiet -funroll-loops -fforce-mem -fcse-follow-jumps -fcse-skip-blocks -fexpensive-optimizations -fstrength-reduce -fpeephole -fschedule-insns -finline-functions -fschedule-insns2 -O -o - STDIN_FILENAME = cccp.i STDOUT_FILENAME = cccp.s From o8cwwns at fer.hr Fri Feb 13 15:15:01 2004 From: o8cwwns at fer.hr (Bruce Rhoades) Date: Fri Feb 13 15:15:01 2004 Subject: [llvm-commits] Complete guide outlining how to set up, maintain and track Google AdWords Campaigns Message-ID: <722els7-q347-g8ck831-t$27z6@l717mb> An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20040213/01217d10/attachment.html From 43hyemkccu at cc.okayama-u.ac.jp Fri Feb 13 15:15:10 2004 From: 43hyemkccu at cc.okayama-u.ac.jp (Jackie Shearer) Date: Fri Feb 13 15:15:10 2004 Subject: [llvm-commits] A real online business Message-ID: An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20040213/c0873282/attachment.html From lattner at cs.uiuc.edu Fri Feb 13 15:23:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 15:23:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/Local.cpp Message-ID: <200402132122.PAA31784@zion.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: Local.cpp updated: 1.80 -> 1.81 --- Log message: Add support for a bunch more functions --- Diffs of the changes: (+56 -0) Index: llvm/lib/Analysis/DataStructure/Local.cpp diff -u llvm/lib/Analysis/DataStructure/Local.cpp:1.80 llvm/lib/Analysis/DataStructure/Local.cpp:1.81 --- llvm/lib/Analysis/DataStructure/Local.cpp:1.80 Fri Feb 13 14:05:32 2004 +++ llvm/lib/Analysis/DataStructure/Local.cpp Fri Feb 13 15:21:48 2004 @@ -520,6 +520,62 @@ if (const PointerType *PTy = dyn_cast(ArgTy)) H.getNode()->mergeTypeInfo(PTy->getElementType(), H.getOffset()); return; + } else if (F->getName() == "fflush" && CS.arg_end()-CS.arg_begin() ==1){ + // fclose reads and writes the memory for the file descriptor. It + // merges the FILE type into the descriptor. + DSNodeHandle H = getValueDest(**CS.arg_begin()); + H.getNode()->setReadMarker()->setModifiedMarker(); + + const Type *ArgTy = *F->getFunctionType()->param_begin(); + if (const PointerType *PTy = dyn_cast(ArgTy)) + H.getNode()->mergeTypeInfo(PTy->getElementType(), H.getOffset()); + return; + } else if (F->getName() == "fgets" && CS.arg_end()-CS.arg_begin() == 3){ + // fclose reads and writes the memory for the file descriptor. It + // merges the FILE type into the descriptor, and writes to the + // argument. It returns the argument as well. + CallSite::arg_iterator AI = CS.arg_begin(); + DSNodeHandle H = getValueDest(**AI); + if (DSNode *N = H.getNode()) + N->setModifiedMarker(); // Writes buffer + H.mergeWith(getValueDest(*CS.getInstruction())); // Returns buffer + ++AI; ++AI; + + // Reads and writes file descriptor, merge in FILE type. + H = getValueDest(**CS.arg_begin()); + if (DSNode *N = H.getNode()) + N->setReadMarker()->setModifiedMarker(); + const Type *ArgTy = *(F->getFunctionType()->param_begin()+2); + if (const PointerType *PTy = dyn_cast(ArgTy)) + H.getNode()->mergeTypeInfo(PTy->getElementType(), H.getOffset()); + return; + } else if (F->getName() == "printf" || F->getName() == "fprintf") { + CallSite::arg_iterator AI = CS.arg_begin(), E = CS.arg_end(); + + if (F->getName() == "fprintf") { + // fprintf reads and writes the FILE argument, and applies the type + // to it. + DSNodeHandle H = getValueDest(**AI); + if (DSNode *N = H.getNode()) { + N->setModifiedMarker(); + const Type *ArgTy = (*AI)->getType(); + if (const PointerType *PTy = dyn_cast(ArgTy)) + N->mergeTypeInfo(PTy->getElementType(), H.getOffset()); + } + } + + for (; AI != E; ++AI) { + // printf reads all pointer arguments. + if (isPointerType((*AI)->getType())) + if (DSNode *N = getValueDest(**AI).getNode()) + N->setReadMarker(); + } + + } else if (F->getName() == "exit") { + // Nothing to do! + } else { + std::cerr << "WARNING: Call to unknown external function '" + << F->getName() << "' will cause pessimistic results!\n"; } } From criswell at cs.uiuc.edu Fri Feb 13 15:38:02 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Fri Feb 13 15:38:02 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/External/SPEC/CINT95/124.m88ksim/ctl.big ctl.lit Makefile Message-ID: <200402132137.PAA27213@choi.cs.uiuc.edu> Changes in directory llvm/test/Programs/External/SPEC/CINT95/124.m88ksim: ctl.big added (r1.1) ctl.lit added (r1.1) Makefile updated: 1.1 -> 1.2 --- Log message: Add the pre-processed input files ctl.big and ctl.lit (for big and little endian, of course). Adjust the Makefile to run the program with the correct inputs and command line options. --- Diffs of the changes: (+22 -1) Index: llvm/test/Programs/External/SPEC/CINT95/124.m88ksim/ctl.big diff -c /dev/null llvm/test/Programs/External/SPEC/CINT95/124.m88ksim/ctl.big:1.1 *** /dev/null Fri Feb 13 15:37:11 2004 --- llvm/test/Programs/External/SPEC/CINT95/124.m88ksim/ctl.big Fri Feb 13 15:37:00 2004 *************** *** 0 **** --- 1,8 ---- + lo dhry.big + cacheoff + br _exit + g + g + sd + q + Index: llvm/test/Programs/External/SPEC/CINT95/124.m88ksim/ctl.lit diff -c /dev/null llvm/test/Programs/External/SPEC/CINT95/124.m88ksim/ctl.lit:1.1 *** /dev/null Fri Feb 13 15:37:11 2004 --- llvm/test/Programs/External/SPEC/CINT95/124.m88ksim/ctl.lit Fri Feb 13 15:37:00 2004 *************** *** 0 **** --- 1,8 ---- + lo dhry.lit + cacheoff + br _exit + g + g + sd + q + Index: llvm/test/Programs/External/SPEC/CINT95/124.m88ksim/Makefile diff -u llvm/test/Programs/External/SPEC/CINT95/124.m88ksim/Makefile:1.1 llvm/test/Programs/External/SPEC/CINT95/124.m88ksim/Makefile:1.2 --- llvm/test/Programs/External/SPEC/CINT95/124.m88ksim/Makefile:1.1 Fri Feb 13 11:17:05 2004 +++ llvm/test/Programs/External/SPEC/CINT95/124.m88ksim/Makefile Fri Feb 13 15:37:00 2004 @@ -1,5 +1,10 @@ LEVEL = ../../../../../.. -STDIN_FILENAME := ctl.raw +RUN_OPTIONS = -c +ifeq ($(ARCH),Sparc) +STDIN_FILENAME := ctl.big +else +STDIN_FILENAME := ctl.lit +endif STDOUT_FILENAME := test.out Source := addd.c \ From lattner at cs.uiuc.edu Fri Feb 13 15:53:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 15:53:02 2004 Subject: [llvm-commits] CVS: poolalloc/test/TEST.poolalloc.Makefile Message-ID: <200402132152.PAA06265@zion.cs.uiuc.edu> Changes in directory poolalloc/test: TEST.poolalloc.Makefile updated: 1.9 -> 1.10 --- Log message: Add a hack to support running spec through the pool allocator --- Diffs of the changes: (+19 -1) Index: poolalloc/test/TEST.poolalloc.Makefile diff -u poolalloc/test/TEST.poolalloc.Makefile:1.9 poolalloc/test/TEST.poolalloc.Makefile:1.10 --- poolalloc/test/TEST.poolalloc.Makefile:1.9 Sun Nov 16 13:40:39 2003 +++ poolalloc/test/TEST.poolalloc.Makefile Fri Feb 13 15:52:08 2004 @@ -44,10 +44,28 @@ Output/%.poolalloc.cbe: Output/%.poolalloc.cbe.c $(PA_RT_O) -$(CC) $(CFLAGS) $< $(PA_RT_O) $(LLCLIBS) $(LDFLAGS) -lstdc++ -o $@ -# This rule runs the generated executable, generating timing information + +ifndef PROGRAMS_HAVE_CUSTOM_RUN_RULES + +# This rule runs the generated executable, generating timing information, for +# normal test programs $(PROGRAMS_TO_TEST:%=Output/%.poolalloc.out-cbe): \ Output/%.poolalloc.out-cbe: Output/%.poolalloc.cbe -$(RUNSAFELY) $(STDIN_FILENAME) $@ $< $(RUN_OPTIONS) +else + +# This rule runs the generated executable, generating timing information, for +# SPEC +$(PROGRAMS_TO_TEST:%=Output/%.poolalloc.out-cbe): \ +Output/%.poolalloc.out-cbe: Output/%.poolalloc.cbe + $(SPEC_SANDBOX) poolalloccbe-$(RUN_TYPE) $@ $(REF_IN_DIR) \ + $(RUNSAFELY) $(STDIN_FILENAME) $(STDOUT_FILENAME) \ + ../../$< $(RUN_OPTIONS) + -(cd Output/poolalloccbe-$(RUN_TYPE); cat $(LOCAL_OUTPUTS)) > $@ + -cp Output/poolalloccbe-$(RUN_TYPE)/$(STDOUT_FILENAME).time $@.time + +endif + # This rule diffs the post-poolallocated version to make sure we didn't break # the program! From criswell at cs.uiuc.edu Fri Feb 13 15:58:03 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Fri Feb 13 15:58:03 2004 Subject: [llvm-commits] CVS: llvm/Makefile.config.in Message-ID: <200402132157.PAA14830@choi.cs.uiuc.edu> Changes in directory llvm: Makefile.config.in updated: 1.20 -> 1.21 --- Log message: Added check for target machine endian-ness and put the result into Makefile.config (ENDIAN variable is set to big or little). --- Diffs of the changes: (+3 -0) Index: llvm/Makefile.config.in diff -u llvm/Makefile.config.in:1.20 llvm/Makefile.config.in:1.21 --- llvm/Makefile.config.in:1.20 Tue Feb 10 16:29:03 2004 +++ llvm/Makefile.config.in Fri Feb 13 15:57:29 2004 @@ -11,6 +11,9 @@ # Target hardware architecture ARCH=@ARCH@ +# Endian-ness of the target +ENDIAN=@ENDIAN@ + # Path to the C++ compiler to use. This is an optional setting, which defaults # to whatever your gmake defaults to. # From criswell at cs.uiuc.edu Fri Feb 13 15:58:12 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Fri Feb 13 15:58:12 2004 Subject: [llvm-commits] CVS: llvm/autoconf/configure.ac Message-ID: <200402132157.PAA14818@choi.cs.uiuc.edu> Changes in directory llvm/autoconf: configure.ac updated: 1.69 -> 1.70 --- Log message: Added check for target machine endian-ness and put the result into Makefile.config (ENDIAN variable is set to big or little). --- Diffs of the changes: (+3 -0) Index: llvm/autoconf/configure.ac diff -u llvm/autoconf/configure.ac:1.69 llvm/autoconf/configure.ac:1.70 --- llvm/autoconf/configure.ac:1.69 Tue Feb 10 16:29:06 2004 +++ llvm/autoconf/configure.ac Fri Feb 13 15:57:03 2004 @@ -244,6 +244,9 @@ dnl Check for various C features AC_C_PRINTF_A +dnl Check for the endianness of the target +AC_C_BIGENDIAN(AC_SUBST([ENDIAN],[big]),AC_SUBST([ENDIAN],[little])) + dnl Check for C++ extensions AC_CXX_HAVE_HASH_MAP AC_CXX_HAVE_HASH_SET From criswell at cs.uiuc.edu Fri Feb 13 15:58:21 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Fri Feb 13 15:58:21 2004 Subject: [llvm-commits] CVS: llvm/configure Message-ID: <200402132157.PAA14811@choi.cs.uiuc.edu> Changes in directory llvm: configure updated: 1.72 -> 1.73 --- Log message: Added check for target machine endian-ness and put the result into Makefile.config (ENDIAN variable is set to big or little). --- Diffs of the changes: (+205 -1) Index: llvm/configure diff -u llvm/configure:1.72 llvm/configure:1.73 --- llvm/configure:1.72 Tue Feb 10 16:36:35 2004 +++ llvm/configure Fri Feb 13 15:56:57 2004 @@ -465,7 +465,7 @@ #endif" ac_unique_file=""Makefile.config.in"" -ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS subdirs INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os OS LLVMGCCDIR ARCH CXX CXXFLAGS LDFLAGS CPPFLAGS ac_ct_CXX EXEEXT OBJEXT CC CFLAGS ac_ct_CC CPP ifGNUmake LEX LEXLIB LEX_OUTPUT_ROOT YACC BISON EGREP LN_S ECHO AR ac_ct_AR RANLIB ac_ct_RANLIB STRIP ac_ct_STRIP CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL DOT ETAGS ETAGSFLAGS PYTHON QMTEST ALLOCA MMAP_FILE ENABLE_OPTIMIZED SPEC_ROOT USE_SPEC SPEC95_ROOT USE_SPEC95 UPB DISABLE_LLC_DIFFS JIT LLVMCC1 LLVMCC1PLUS BCR PAPIDIR SHLIBEXT LIBOBJS LTLIBOBJS' +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS subdirs INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os OS LLVMGCCDIR ARCH CXX CXXFLAGS LDFLAGS CPPFLAGS ac_ct_CXX EXEEXT OBJEXT CC CFLAGS ac_ct_CC CPP ifGNUmake LEX LEXLIB LEX_OUTPUT_ROOT YACC BISON EGREP LN_S ECHO AR ac_ct_AR RANLIB ac_ct_RANLIB STRIP ac_ct_STRIP CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL DOT ETAGS ETAGSFLAGS PYTHON QMTEST ENDIAN ALLOCA MMAP_FILE ENABLE_OPTIMIZED SPEC_ROOT USE_SPEC SPEC95_ROOT USE_SPEC95 UPB DISABLE_LLC_DIFFS JIT LLVMCC1 LLVMCC1PLUS BCR PAPIDIR SHLIBEXT LIBOBJS LTLIBOBJS' ac_subst_files='' # Initialize some variables set by options. @@ -19481,6 +19481,209 @@ fi +echo "$as_me:$LINENO: checking whether byte ordering is bigendian" >&5 +echo $ECHO_N "checking whether byte ordering is bigendian... $ECHO_C" >&6 +if test "${ac_cv_c_bigendian+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # See if sys/param.h defines the BYTE_ORDER macro. +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include + +int +main () +{ +#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN + bogus endian macros +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + # It does; now see whether it defined to BIG_ENDIAN or not. +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include + +int +main () +{ +#if BYTE_ORDER != BIG_ENDIAN + not big endian +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_c_bigendian=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_c_bigendian=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +# It does not; compile a test program. +if test "$cross_compiling" = yes; then + # try to guess the endianness by grepping values into an object file + ac_cv_c_bigendian=unknown + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +short ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; +short ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; +void _ascii () { char *s = (char *) ascii_mm; s = (char *) ascii_ii; } +short ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; +short ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; +void _ebcdic () { char *s = (char *) ebcdic_mm; s = (char *) ebcdic_ii; } +int +main () +{ + _ascii (); _ebcdic (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + if grep BIGenDianSyS conftest.$ac_objext >/dev/null ; then + ac_cv_c_bigendian=yes +fi +if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then + if test "$ac_cv_c_bigendian" = unknown; then + ac_cv_c_bigendian=no + else + # finding both strings is unlikely to happen, but who knows? + ac_cv_c_bigendian=unknown + fi +fi +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.$ac_objext conftest.$ac_ext +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +int +main () +{ + /* Are we little or big endian? From Harbison&Steele. */ + union + { + long l; + char c[sizeof (long)]; + } u; + u.l = 1; + exit (u.c[sizeof (long) - 1] == 1); +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_c_bigendian=no +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_c_bigendian=yes +fi +rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_c_bigendian" >&5 +echo "${ECHO_T}$ac_cv_c_bigendian" >&6 +case $ac_cv_c_bigendian in + yes) + ENDIAN=big + ;; + no) + ENDIAN=little + ;; + *) + { { echo "$as_me:$LINENO: error: unknown endianness +presetting ac_cv_c_bigendian=no (or yes) will help" >&5 +echo "$as_me: error: unknown endianness +presetting ac_cv_c_bigendian=no (or yes) will help" >&2;} + { (exit 1); exit 1; }; } ;; +esac + + echo "$as_me:$LINENO: checking whether the compiler implements namespaces" >&5 echo $ECHO_N "checking whether the compiler implements namespaces... $ECHO_C" >&6 if test "${ac_cv_cxx_namespaces+set}" = set; then @@ -22460,6 +22663,7 @@ s, at ETAGSFLAGS@,$ETAGSFLAGS,;t t s, at PYTHON@,$PYTHON,;t t s, at QMTEST@,$QMTEST,;t t +s, at ENDIAN@,$ENDIAN,;t t s, at ALLOCA@,$ALLOCA,;t t s, at MMAP_FILE@,$MMAP_FILE,;t t s, at ENABLE_OPTIMIZED@,$ENABLE_OPTIMIZED,;t t From criswell at cs.uiuc.edu Fri Feb 13 16:00:03 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Fri Feb 13 16:00:03 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/External/SPEC/CINT95/124.m88ksim/Makefile Message-ID: <200402132159.PAA15001@choi.cs.uiuc.edu> Changes in directory llvm/test/Programs/External/SPEC/CINT95/124.m88ksim: Makefile updated: 1.2 -> 1.3 --- Log message: Switch to using the ENDIAN variable for determing which input file to use. --- Diffs of the changes: (+1 -1) Index: llvm/test/Programs/External/SPEC/CINT95/124.m88ksim/Makefile diff -u llvm/test/Programs/External/SPEC/CINT95/124.m88ksim/Makefile:1.2 llvm/test/Programs/External/SPEC/CINT95/124.m88ksim/Makefile:1.3 --- llvm/test/Programs/External/SPEC/CINT95/124.m88ksim/Makefile:1.2 Fri Feb 13 15:37:00 2004 +++ llvm/test/Programs/External/SPEC/CINT95/124.m88ksim/Makefile Fri Feb 13 15:59:15 2004 @@ -1,6 +1,6 @@ LEVEL = ../../../../../.. RUN_OPTIONS = -c -ifeq ($(ARCH),Sparc) +ifeq ($(ENDIAN),big) STDIN_FILENAME := ctl.big else STDIN_FILENAME := ctl.lit From lattner at cs.uiuc.edu Fri Feb 13 16:04:03 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 16:04:03 2004 Subject: [llvm-commits] CVS: poolalloc/test/TEST.poolalloc.report Message-ID: <200402132203.QAA08797@zion.cs.uiuc.edu> Changes in directory poolalloc/test: TEST.poolalloc.report updated: 1.8 -> 1.9 --- Log message: Clean up the report a bit --- Diffs of the changes: (+1 -0) Index: poolalloc/test/TEST.poolalloc.report diff -u poolalloc/test/TEST.poolalloc.report:1.8 poolalloc/test/TEST.poolalloc.report:1.9 --- poolalloc/test/TEST.poolalloc.report:1.8 Sun Nov 16 13:40:39 2003 +++ poolalloc/test/TEST.poolalloc.report Fri Feb 13 16:03:07 2004 @@ -6,6 +6,7 @@ # Sort by program name $SortCol = 0; +$TrimRepeatedPrefix = 1; sub Ratio { my ($Cols, $Col) = @_; From lattner at cs.uiuc.edu Fri Feb 13 16:05:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 16:05:01 2004 Subject: [llvm-commits] CVS: llvm/test/Regression/CFrontend/2004-02-13-IllegalVararg.c.tr Message-ID: <200402132204.QAA09327@zion.cs.uiuc.edu> Changes in directory llvm/test/Regression/CFrontend: 2004-02-13-IllegalVararg.c.tr added (r1.1) --- Log message: New testcase. The CFE should not generate illegal LLVM intrinsics, even if the input program is horribly broken (like 126.gcc). --- Diffs of the changes: (+11 -0) Index: llvm/test/Regression/CFrontend/2004-02-13-IllegalVararg.c.tr diff -c /dev/null llvm/test/Regression/CFrontend/2004-02-13-IllegalVararg.c.tr:1.1 *** /dev/null Fri Feb 13 16:04:51 2004 --- llvm/test/Regression/CFrontend/2004-02-13-IllegalVararg.c.tr Fri Feb 13 16:04:41 2004 *************** *** 0 **** --- 1,11 ---- + // RUN: %llvmgcc -xc %s -c -o - | llc + + #include + + float test(int X, ...) { + va_list ap; + float F; + va_start(ap, X); + F = va_arg(ap, float); + return F; + } From lattner at cs.uiuc.edu Fri Feb 13 16:14:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 16:14:01 2004 Subject: [llvm-commits] CVS: gcc-3.4/gcc/llvm-expand.c Message-ID: <200402132213.QAA11586@zion.cs.uiuc.edu> Changes in directory gcc-3.4/gcc: llvm-expand.c updated: 1.9 -> 1.10 --- Log message: Fix: test/Regression/CFrontend/2004-02-13-IllegalVararg.c.tr --- Diffs of the changes: (+17 -2) Index: gcc-3.4/gcc/llvm-expand.c diff -u gcc-3.4/gcc/llvm-expand.c:1.9 gcc-3.4/gcc/llvm-expand.c:1.10 --- gcc-3.4/gcc/llvm-expand.c:1.9 Thu Feb 12 15:04:48 2004 +++ gcc-3.4/gcc/llvm-expand.c Fri Feb 13 16:12:53 2004 @@ -241,9 +241,24 @@ llvm_type *ArgTy) { llvm_value *VAList = append_inst(Fn, create_load_inst("valist", VAListPtr,0)); llvm_value *Result; - llvm_instruction *VA = llvm_instruction_new(ArgTy, "tmp", O_VAArg, 1); + llvm_instruction *VA; + llvm_type *ActualTy = ArgTy; + /* Make sure to promote types as needed, even though it's illegal to + * va_arg(float). Since we decimate structures, we might have a float value + * being passed through as vararg. + */ assert(llvm_type_is_scalar(ArgTy) && "Not a scalar type?"); + switch (ActualTy->ID) { + case FloatTyID: ActualTy = DoubleTy; break; + case SByteTyID: ActualTy = IntTy; break; + case ShortTyID: ActualTy = IntTy; break; + case UByteTyID: ActualTy = UIntTy; break; + case UShortTyID: ActualTy = UIntTy; break; + default: break; + } + + VA = llvm_instruction_new(ActualTy, "tmp", O_VAArg, 1); VA->Operands[0] = VAList; Result = append_inst(Fn, VA); @@ -251,7 +266,7 @@ /* Update the valist */ VA = llvm_instruction_new(VAList->Ty, "vanextlist", O_VANext, 1); VA->Operands[0] = VAList; - VA->x.VANext.ArgTy = ArgTy; + VA->x.VANext.ArgTy = ActualTy; VAList = append_inst(Fn, VA); append_inst(Fn, create_store_inst(VAList, VAListPtr, 0)); From criswell at cs.uiuc.edu Fri Feb 13 16:32:01 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Fri Feb 13 16:32:01 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/External/SPEC/CINT95/124.m88ksim/ctl.big ctl.lit Message-ID: <200402132231.QAA31330@choi.cs.uiuc.edu> Changes in directory llvm/test/Programs/External/SPEC/CINT95/124.m88ksim: ctl.big (r1.1) removed ctl.lit (r1.1) removed --- Log message: Remove these from the tree. I've generated them and put them into our local SPEC tree in fear of the SPEC police. :) And it clears out unwanted clutter too. --- Diffs of the changes: (+0 -0) From lattner at cs.uiuc.edu Fri Feb 13 16:37:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 16:37:01 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/Makefile.programs Message-ID: <200402132236.QAA14977@zion.cs.uiuc.edu> Changes in directory llvm/test/Programs: Makefile.programs updated: 1.116 -> 1.117 --- Log message: Run llvm-dis with filename and -o option isntead of pipes. It's more efficient, and this way llvm-dis doesn't leave cruft around if it crashes --- Diffs of the changes: (+2 -2) Index: llvm/test/Programs/Makefile.programs diff -u llvm/test/Programs/Makefile.programs:1.116 llvm/test/Programs/Makefile.programs:1.117 --- llvm/test/Programs/Makefile.programs:1.116 Wed Feb 11 13:03:44 2004 +++ llvm/test/Programs/Makefile.programs Fri Feb 13 16:36:05 2004 @@ -259,7 +259,7 @@ # $(PROGRAMS_TO_TEST:%=Output/%.cbe.c): \ Output/%.cbe.c: Output/%.llvm.bc $(LDIS) - -$(LDIS) -c < $< > $@ + -$(LDIS) -c $< -o $@ -f $(PROGRAMS_TO_TEST:%=Output/%.cbe): \ Output/%.cbe: Output/%.cbe.c @@ -383,7 +383,7 @@ $(LBUGPOINT) $< -run-jit $(BUGPOINT_OPTIONS) -LIBPROFILESO := $(LEVEL)/lib/Debug/libprofile_rt.so +LIBPROFILESO = $(LEVEL)/lib/Debug/libprofile_rt.so $(PROGRAMS_TO_TEST:%=Output/%.prof): \ Output/%.prof: Output/%.llvm-prof.bc Output/%.out-nat $(LIBPROFILESO) From criswell at cs.uiuc.edu Fri Feb 13 16:46:01 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Fri Feb 13 16:46:01 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/External/SPEC/CINT95/147.vortex/Makefile Message-ID: <200402132245.QAA31694@choi.cs.uiuc.edu> Changes in directory llvm/test/Programs/External/SPEC/CINT95/147.vortex: Makefile updated: 1.1 -> 1.2 --- Log message: Corrected the 147.vortex Makefile. The input file is now specified on the command line and is chosen by the endian of the target. The SPEC_CPU2000_LP64 is used only for Sparc, although this macro is probably incorrect. :( --- Diffs of the changes: (+9 -7) Index: llvm/test/Programs/External/SPEC/CINT95/147.vortex/Makefile diff -u llvm/test/Programs/External/SPEC/CINT95/147.vortex/Makefile:1.1 llvm/test/Programs/External/SPEC/CINT95/147.vortex/Makefile:1.2 --- llvm/test/Programs/External/SPEC/CINT95/147.vortex/Makefile:1.1 Tue Feb 10 11:49:08 2004 +++ llvm/test/Programs/External/SPEC/CINT95/147.vortex/Makefile Fri Feb 13 16:45:44 2004 @@ -1,18 +1,20 @@ LEVEL = ../../../../../.. -STDIN_FILENAME := vortex.in -STDOUT_FILENAME := vortex.out +include $(LEVEL)/Makefile.config -include ../../Makefile.spec95 +STDOUT_FILENAME := vortex.out +LDFLAGS += -lm +LIBS += -lm ifeq ($(ARCH),Sparc) ## SPEC portability note for vortex says to use this flag on 64-bit machines CPPFLAGS += -DSPEC_CPU2000_LP64 +endif - # If we're on sparc, use the Big Endian input file - RUN_OPTIONS = bendian.raw +ifeq ($(ENDIAN), big) + RUN_OPTIONS = vortex.in.big else - # Use the Little Endian input file - RUN_OPTIONS = lendian.raw + RUN_OPTIONS = vortex.in.little endif +include ../../Makefile.spec95 From lattner at cs.uiuc.edu Fri Feb 13 17:01:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 17:01:01 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Assembly/CWriter.h Message-ID: <200402132300.RAA18931@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Assembly: CWriter.h updated: 1.5 -> 1.6 --- Log message: Change access to the cwriter --- Diffs of the changes: (+2 -2) Index: llvm/include/llvm/Assembly/CWriter.h diff -u llvm/include/llvm/Assembly/CWriter.h:1.5 llvm/include/llvm/Assembly/CWriter.h:1.6 --- llvm/include/llvm/Assembly/CWriter.h:1.5 Tue Nov 11 16:41:31 2003 +++ llvm/include/llvm/Assembly/CWriter.h Fri Feb 13 17:00:45 2004 @@ -19,8 +19,8 @@ namespace llvm { -class Pass; -Pass *createWriteToCPass(std::ostream &o); +class PassManager; +void AddPassesToWriteC(PassManager &PM, std::ostream &o); } // End llvm namespace From lattner at cs.uiuc.edu Fri Feb 13 17:01:11 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 17:01:11 2004 Subject: [llvm-commits] CVS: llvm/lib/CWriter/Writer.cpp Message-ID: <200402132300.RAA18909@zion.cs.uiuc.edu> Changes in directory llvm/lib/CWriter: Writer.cpp updated: 1.156 -> 1.157 --- Log message: Make the cwriter use the lowerinvoke pass so that it can either use "disabled exceptions" or "expensive exceptions" controlled by an option. Also refactor and eliminate a bunch of cruft. This is a temporary solution and causes millions of warnings to pour out of programs that use exceptions, but it should fix the problem with sparc and the 'write' declaration (PR190). Subsequent changes will make this stink much less --- Diffs of the changes: (+49 -124) Index: llvm/lib/CWriter/Writer.cpp diff -u llvm/lib/CWriter/Writer.cpp:1.156 llvm/lib/CWriter/Writer.cpp:1.157 --- llvm/lib/CWriter/Writer.cpp:1.156 Fri Feb 13 00:18:21 2004 +++ llvm/lib/CWriter/Writer.cpp Fri Feb 13 17:00:29 2004 @@ -18,10 +18,12 @@ #include "llvm/Module.h" #include "llvm/Instructions.h" #include "llvm/Pass.h" +#include "llvm/PassManager.h" #include "llvm/SymbolTable.h" #include "llvm/Intrinsics.h" #include "llvm/Analysis/FindUsedTypes.h" #include "llvm/Analysis/ConstantsScanner.h" +#include "llvm/Transforms/Scalar.h" #include "llvm/Support/CallSite.h" #include "llvm/Support/GetElementPtrTypeIterator.h" #include "llvm/Support/InstVisitor.h" @@ -40,34 +42,31 @@ std::map TypeNames; std::set MangledGlobals; - bool needsMalloc, emittedInvoke; + bool needsMalloc; std::map FPConstantMap; public: CWriter(std::ostream &o) : Out(o) {} void getAnalysisUsage(AnalysisUsage &AU) const { - AU.setPreservesAll(); AU.addRequired(); } - virtual bool run(Module &M) { - // Initialize - TheModule = &M; - FUT = &getAnalysis(); - - // Ensure that all structure types have names... - bool Changed = nameAllUsedStructureTypes(M); - Mang = new Mangler(M); + virtual const char *getPassName() const { return "C backend"; } - // Run... - printModule(&M); + bool doInitialization(Module &M); + bool run(Module &M) { + doInitialization(M); + + for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) + if (!I->isExternal()) + printFunction(*I); // Free memory... delete Mang; TypeNames.clear(); MangledGlobals.clear(); - return false; + return true; } std::ostream &printType(std::ostream &Out, const Type *Ty, @@ -85,7 +84,7 @@ void printContainedStructs(const Type *Ty, std::set &); void printFunctionSignature(const Function *F, bool Prototype); - void printFunction(Function *); + void printFunction(Function &); void printConstant(Constant *CPV); void printConstantArray(ConstantArray *CPA); @@ -604,42 +603,27 @@ << "#endif\n\n"; } -// generateProcessorSpecificCode - This is where we add conditional compilation -// directives to cater to specific processors as need be. -// -static void generateProcessorSpecificCode(std::ostream& Out) { - // According to ANSI C, longjmp'ing to a setjmp could invalidate any - // non-volatile variable in the scope of the setjmp. For now, we are not - // doing analysis to determine which variables need to be marked volatile, so - // we just mark them all. - // - // HOWEVER, many targets implement setjmp by saving and restoring the register - // file, so they DON'T need variables to be marked volatile, and this is a - // HUGE pessimization for them. For this reason, on known-good processors, we - // do not emit volatile qualifiers. - Out << "#if defined(__386__) || defined(__i386__) || \\\n" - << " defined(i386) || defined(WIN32)\n" - << "/* setjmp does not require variables to be marked volatile */" - << "#define VOLATILE_FOR_SETJMP\n" - << "#else\n" - << "#define VOLATILE_FOR_SETJMP volatile\n" - << "#endif\n\n"; -} - +bool CWriter::doInitialization(Module &M) { + // Initialize + TheModule = &M; + FUT = &getAnalysis(); + + // Ensure that all structure types have names... + bool Changed = nameAllUsedStructureTypes(M); + Mang = new Mangler(M); -void CWriter::printModule(Module *M) { // Calculate which global values have names that will collide when we throw // away type information. { // Scope to delete the FoundNames set when we are done with it... std::set FoundNames; - for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I) + for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) if (I->hasName()) // If the global has a name... if (FoundNames.count(I->getName())) // And the name is already used MangledGlobals.insert(I); // Mangle the name else FoundNames.insert(I->getName()); // Otherwise, keep track of name - for (Module::giterator I = M->gbegin(), E = M->gend(); I != E; ++I) + for (Module::giterator I = M.gbegin(), E = M.gend(); I != E; ++I) if (I->hasName()) // If the global has a name... if (FoundNames.count(I->getName())) // And the name is already used MangledGlobals.insert(I); // Mangle the name @@ -652,7 +636,6 @@ Out << "#include \n"; // Varargs support Out << "#include \n"; // Unwind support generateCompilerSpecificCode(Out); - generateProcessorSpecificCode(Out); // Provide a definition for `bool' if not compiling with a C++ compiler. Out << "\n" @@ -662,11 +645,6 @@ << "typedef unsigned long long ConstantDoubleTy;\n" << "typedef unsigned int ConstantFloatTy;\n" - << "\n\n/* Support for the invoke instruction */\n" - << "extern struct __llvm_jmpbuf_list_t {\n" - << " jmp_buf buf; struct __llvm_jmpbuf_list_t *next;\n" - << "} *__llvm_jmpbuf_list;\n" - << "\n\n/* Global Declarations */\n"; // First output all the declarations for the program, because C requires @@ -674,12 +652,12 @@ // // Loop over the symbol table, emitting all named constants... - printSymbolTable(M->getSymbolTable()); + printSymbolTable(M.getSymbolTable()); // Global variable declarations... - if (!M->gempty()) { + if (!M.gempty()) { Out << "\n/* External Global Variable Declarations */\n"; - for (Module::giterator I = M->gbegin(), E = M->gend(); I != E; ++I) { + for (Module::giterator I = M.gbegin(), E = M.gend(); I != E; ++I) { if (I->hasExternalLinkage()) { Out << "extern "; printType(Out, I->getType()->getElementType(), Mang->getValueName(I)); @@ -689,15 +667,16 @@ } // Function declarations - if (!M->empty()) { + if (!M.empty()) { Out << "\n/* Function Declarations */\n"; needsMalloc = true; - for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I) { + for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) { // If the function is external and the name collides don't print it. // Sometimes the bytecode likes to have multiple "declarations" for // external functions if ((I->hasInternalLinkage() || !MangledGlobals.count(I)) && - !I->getIntrinsicID()) { + !I->getIntrinsicID() && + I->getName() != "setjmp" && I->getName() != "longjmp") { printFunctionSignature(I, true); if (I->hasWeakLinkage()) Out << " __ATTRIBUTE_WEAK__"; Out << ";\n"; @@ -712,9 +691,9 @@ } // Output the global variable declarations - if (!M->gempty()) { + if (!M.gempty()) { Out << "\n\n/* Global Variable Declarations */\n"; - for (Module::giterator I = M->gbegin(), E = M->gend(); I != E; ++I) + for (Module::giterator I = M.gbegin(), E = M.gend(); I != E; ++I) if (!I->isExternal()) { Out << "extern "; printType(Out, I->getType()->getElementType(), Mang->getValueName(I)); @@ -728,9 +707,9 @@ } // Output the global variable definitions and contents... - if (!M->gempty()) { + if (!M.gempty()) { Out << "\n\n/* Global Variable Definitions and Initialization */\n"; - for (Module::giterator I = M->gbegin(), E = M->gend(); I != E; ++I) + for (Module::giterator I = M.gbegin(), E = M.gend(); I != E; ++I) if (!I->isExternal()) { if (I->hasInternalLinkage()) Out << "static "; @@ -755,28 +734,14 @@ } // Output all floating point constants that cannot be printed accurately... - printFloatingPointConstants(*M); + printFloatingPointConstants(M); - // Output all of the functions... - emittedInvoke = false; - if (!M->empty()) { + if (!M.empty()) Out << "\n\n/* Function Bodies */\n"; - for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I) - printFunction(I); - } - - // If the program included an invoke instruction, we need to output the - // support code for it here! - if (emittedInvoke) { - Out << "\n/* More support for the invoke instruction */\n" - << "struct __llvm_jmpbuf_list_t *__llvm_jmpbuf_list " - << "__attribute__((common)) = 0;\n"; - } - - // Done with global FP constants - FPConstantMap.clear(); + return false; } + /// Output all floating point constants that cannot be printed accurately... void CWriter::printFloatingPointConstants(Module &M) { union { @@ -963,36 +928,23 @@ printType(Out, F->getReturnType(), FunctionInnards.str()); } -void CWriter::printFunction(Function *F) { - if (F->isExternal()) return; - - printFunctionSignature(F, false); +void CWriter::printFunction(Function &F) { + printFunctionSignature(&F, false); Out << " {\n"; - // Determine whether or not the function contains any invoke instructions. - bool HasInvoke = false; - for (Function::iterator I = F->begin(), E = F->end(); I != E; ++I) - if (isa(I->getTerminator())) { - HasInvoke = true; - break; - } - // print local variable information for the function - for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I) + for (inst_iterator I = inst_begin(&F), E = inst_end(&F); I != E; ++I) if (const AllocaInst *AI = isDirectAlloca(*I)) { Out << " "; - if (HasInvoke) Out << "VOLATILE_FOR_SETJMP "; printType(Out, AI->getAllocatedType(), Mang->getValueName(AI)); Out << "; /* Address exposed local */\n"; } else if ((*I)->getType() != Type::VoidTy && !isInlinableInst(**I)) { Out << " "; - if (HasInvoke) Out << "VOLATILE_FOR_SETJMP "; printType(Out, (*I)->getType(), Mang->getValueName(*I)); Out << ";\n"; if (isa(*I)) { // Print out PHI node temporaries as well... Out << " "; - if (HasInvoke) Out << "VOLATILE_FOR_SETJMP "; printType(Out, (*I)->getType(), Mang->getValueName(*I)+"__PHI_TEMPORARY"); Out << ";\n"; @@ -1002,7 +954,7 @@ Out << "\n"; // print the basic blocks - for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) { + for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) { BasicBlock *Prev = BB->getPrev(); // Don't print the label for the basic block if there are no uses, or if the @@ -1080,43 +1032,12 @@ } void CWriter::visitInvokeInst(InvokeInst &II) { - Out << " {\n" - << " struct __llvm_jmpbuf_list_t Entry;\n" - << " Entry.next = __llvm_jmpbuf_list;\n" - << " if (setjmp(Entry.buf)) {\n" - << " __llvm_jmpbuf_list = Entry.next;\n"; - printBranchToBlock(II.getParent(), II.getUnwindDest(), 4); - Out << " }\n" - << " __llvm_jmpbuf_list = &Entry;\n" - << " "; - - if (II.getType() != Type::VoidTy) outputLValue(&II); - visitCallSite(&II); - Out << ";\n" - << " __llvm_jmpbuf_list = Entry.next;\n" - << " }\n"; - printBranchToBlock(II.getParent(), II.getNormalDest(), 0); - emittedInvoke = true; + assert(0 && "Lowerinvoke pass didn't work!"); } void CWriter::visitUnwindInst(UnwindInst &I) { - // The unwind instructions causes a control flow transfer out of the current - // function, unwinding the stack until a caller who used the invoke - // instruction is found. In this context, we code generated the invoke - // instruction to add an entry to the top of the jmpbuf_list. Thus, here we - // just have to longjmp to the specified handler. - Out << " if (__llvm_jmpbuf_list == 0) { /* unwind */\n" - << "#ifdef _LP64\n" - << " extern signed long long write();\n" - << "#else\n" - << " extern write();\n" - << "#endif\n" - << " ((void (*)(int, void*, unsigned))write)(2,\n" - << " \"throw found with no handler!\\n\", 31); abort();\n" - << " }\n" - << " longjmp(__llvm_jmpbuf_list->buf, 1);\n"; - emittedInvoke = true; + assert(0 && "Lowerinvoke pass didn't work!"); } bool isGotoCodeNecessary(BasicBlock *From, BasicBlock *To) { @@ -1473,4 +1394,8 @@ // External Interface declaration //===----------------------------------------------------------------------===// -Pass *llvm::createWriteToCPass(std::ostream &o) { return new CWriter(o); } +void llvm::AddPassesToWriteC(PassManager &PM, std::ostream &o) { + PM.add(createLowerInvokePass()); + //PM.add(createLowerAllocationsPass()); + PM.add(new CWriter(o)); +} From lattner at cs.uiuc.edu Fri Feb 13 17:02:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 17:02:01 2004 Subject: [llvm-commits] CVS: llvm/tools/llvm-dis/Makefile llvm-dis.cpp Message-ID: <200402132301.RAA18962@zion.cs.uiuc.edu> Changes in directory llvm/tools/llvm-dis: Makefile updated: 1.12 -> 1.13 llvm-dis.cpp updated: 1.37 -> 1.38 --- Log message: Change how we create the cwriter, and add a buttload of libraries that it now needs. This will be fixed shortly --- Diffs of the changes: (+2 -2) Index: llvm/tools/llvm-dis/Makefile diff -u llvm/tools/llvm-dis/Makefile:1.12 llvm/tools/llvm-dis/Makefile:1.13 --- llvm/tools/llvm-dis/Makefile:1.12 Mon Oct 20 17:27:27 2003 +++ llvm/tools/llvm-dis/Makefile Fri Feb 13 17:01:14 2004 @@ -9,5 +9,5 @@ LEVEL = ../.. TOOLNAME = llvm-dis -USEDLIBS = bcreader cwriter ipa.a vmcore support.a +USEDLIBS = cwriter ipa.a scalaropts.a target.a transformutils analysis.a bcreader vmcore support.a include $(LEVEL)/Makefile.common Index: llvm/tools/llvm-dis/llvm-dis.cpp diff -u llvm/tools/llvm-dis/llvm-dis.cpp:1.37 llvm/tools/llvm-dis/llvm-dis.cpp:1.38 --- llvm/tools/llvm-dis/llvm-dis.cpp:1.37 Tue Nov 11 22:59:59 2003 +++ llvm/tools/llvm-dis/llvm-dis.cpp Fri Feb 13 17:01:14 2004 @@ -122,7 +122,7 @@ Passes.add(new PrintModulePass(Out)); break; case c: // Convert LLVM to C - Passes.add(createWriteToCPass(*Out)); + AddPassesToWriteC(Passes, *Out); break; } From lattner at cs.uiuc.edu Fri Feb 13 17:02:10 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 17:02:10 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/Makefile.programs Message-ID: <200402132301.RAA18975@zion.cs.uiuc.edu> Changes in directory llvm/test/Programs: Makefile.programs updated: 1.117 -> 1.118 --- Log message: The cbackend now uses the lower-invoke pass, so it supports the -enable-correct-eh-support option --- Diffs of the changes: (+5 -1) Index: llvm/test/Programs/Makefile.programs diff -u llvm/test/Programs/Makefile.programs:1.117 llvm/test/Programs/Makefile.programs:1.118 --- llvm/test/Programs/Makefile.programs:1.117 Fri Feb 13 16:36:05 2004 +++ llvm/test/Programs/Makefile.programs Fri Feb 13 17:01:36 2004 @@ -254,12 +254,16 @@ sed 's/Pass Arguments: //' < $@.1 > $@ +ifdef REQUIRES_EH_SUPPORT +CBEFLAGS += -enable-correct-eh-support +endif + # # Rules to compile the program for the C Back End # $(PROGRAMS_TO_TEST:%=Output/%.cbe.c): \ Output/%.cbe.c: Output/%.llvm.bc $(LDIS) - -$(LDIS) -c $< -o $@ -f + -$(LDIS) $(CBEFLAGS) -c $< -o $@ -f $(PROGRAMS_TO_TEST:%=Output/%.cbe): \ Output/%.cbe: Output/%.cbe.c From lattner at cs.uiuc.edu Fri Feb 13 17:19:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 17:19:01 2004 Subject: [llvm-commits] CVS: llvm/lib/CWriter/CTargetMachine.h Writer.cpp Message-ID: <200402132318.RAA20559@zion.cs.uiuc.edu> Changes in directory llvm/lib/CWriter: CTargetMachine.h added (r1.1) Writer.cpp updated: 1.157 -> 1.158 --- Log message: Convert the C backend into a target, for use with LLC. This allows us to use the lowerallocations pass to eliminate malloc/free warnings and hackish code --- Diffs of the changes: (+51 -30) Index: llvm/lib/CWriter/CTargetMachine.h diff -c /dev/null llvm/lib/CWriter/CTargetMachine.h:1.1 *** /dev/null Fri Feb 13 17:18:58 2004 --- llvm/lib/CWriter/CTargetMachine.h Fri Feb 13 17:18:48 2004 *************** *** 0 **** --- 1,39 ---- + //===-- CTargetMachine.h - TargetMachine for the C backend ------*- C++ -*-===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by the LLVM research group and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // This file declares the TargetMachine that is used by the C backend. + // + //===----------------------------------------------------------------------===// + + #ifndef CTARGETMACHINE_H + #define CTARGETMACHINE_H + + #include "llvm/Target/TargetMachine.h" + + namespace llvm { + class IntrinsicLowering; + + struct CTargetMachine : public TargetMachine { + CTargetMachine(const Module &M, IntrinsicLowering *IL) : + TargetMachine("CBackend", IL) {} + + virtual const TargetInstrInfo &getInstrInfo() const { abort(); } + virtual const TargetFrameInfo &getFrameInfo() const { abort(); } + virtual const TargetSchedInfo &getSchedInfo() const { abort(); } + virtual const TargetRegInfo &getRegInfo() const { abort(); } + virtual const TargetCacheInfo &getCacheInfo() const { abort(); } + + // This is the only thing that actually does anything here. + virtual bool addPassesToEmitAssembly(PassManager &PM, std::ostream &Out); + }; + + } // End llvm namespace + + + #endif Index: llvm/lib/CWriter/Writer.cpp diff -u llvm/lib/CWriter/Writer.cpp:1.157 llvm/lib/CWriter/Writer.cpp:1.158 --- llvm/lib/CWriter/Writer.cpp:1.157 Fri Feb 13 17:00:29 2004 +++ llvm/lib/CWriter/Writer.cpp Fri Feb 13 17:18:48 2004 @@ -12,7 +12,8 @@ // //===----------------------------------------------------------------------===// -#include "llvm/Assembly/CWriter.h" +#include "CTargetMachine.h" +#include "llvm/Target/TargetMachineImpls.h" #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" #include "llvm/Module.h" @@ -42,7 +43,6 @@ std::map TypeNames; std::set MangledGlobals; - bool needsMalloc; std::map FPConstantMap; public: @@ -669,7 +669,6 @@ // Function declarations if (!M.empty()) { Out << "\n/* Function Declarations */\n"; - needsMalloc = true; for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) { // If the function is external and the name collides don't print it. // Sometimes the bytecode likes to have multiple "declarations" for @@ -684,12 +683,6 @@ } } - // Print Malloc prototype if needed - if (needsMalloc) { - Out << "\n/* Malloc to make sun happy */\n"; - Out << "extern void * malloc();\n\n"; - } - // Output the global variable declarations if (!M.gempty()) { Out << "\n\n/* Global Variable Declarations */\n"; @@ -873,11 +866,6 @@ void CWriter::printFunctionSignature(const Function *F, bool Prototype) { - // If the program provides its own malloc prototype we don't need - // to include the general one. - if (Mang->getValueName(F) == "malloc") - needsMalloc = false; - if (F->hasInternalLinkage()) Out << "static "; if (F->hasLinkOnceLinkage()) Out << "inline "; @@ -1264,17 +1252,7 @@ } void CWriter::visitMallocInst(MallocInst &I) { - Out << "("; - printType(Out, I.getType()); - Out << ")malloc(sizeof("; - printType(Out, I.getType()->getElementType()); - Out << ")"; - - if (I.isArrayAllocation()) { - Out << " * " ; - writeOperand(I.getOperand(0)); - } - Out << ")"; + assert(0 && "lowerallocations pass didn't work!"); } void CWriter::visitAllocaInst(AllocaInst &I) { @@ -1291,9 +1269,7 @@ } void CWriter::visitFreeInst(FreeInst &I) { - Out << "free((char*)"; - writeOperand(I.getOperand(0)); - Out << ")"; + assert(0 && "lowerallocations pass didn't work!"); } void CWriter::printIndexingExpression(Value *Ptr, gep_type_iterator I, @@ -1394,8 +1370,14 @@ // External Interface declaration //===----------------------------------------------------------------------===// -void llvm::AddPassesToWriteC(PassManager &PM, std::ostream &o) { +bool CTargetMachine::addPassesToEmitAssembly(PassManager &PM, std::ostream &o) { + PM.add(createLowerAllocationsPass()); PM.add(createLowerInvokePass()); - //PM.add(createLowerAllocationsPass()); PM.add(new CWriter(o)); + return false; +} + +TargetMachine *llvm::allocateCTargetMachine(const Module &M, + IntrinsicLowering *IL) { + return new CTargetMachine(M, IL); } From lattner at cs.uiuc.edu Fri Feb 13 17:20:00 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 17:20:00 2004 Subject: [llvm-commits] CVS: llvm/tools/llc/Makefile llc.cpp Message-ID: <200402132319.RAA20688@zion.cs.uiuc.edu> Changes in directory llvm/tools/llc: Makefile updated: 1.46 -> 1.47 llc.cpp updated: 1.89 -> 1.90 --- Log message: Add support for -march=c --- Diffs of the changes: (+14 -7) Index: llvm/tools/llc/Makefile diff -u llvm/tools/llc/Makefile:1.46 llvm/tools/llc/Makefile:1.47 --- llvm/tools/llc/Makefile:1.46 Sat Feb 7 23:49:29 2004 +++ llvm/tools/llc/Makefile Fri Feb 13 17:19:09 2004 @@ -8,7 +8,8 @@ ##===----------------------------------------------------------------------===## LEVEL = ../.. TOOLNAME = llc -USEDLIBS = sparc \ +USEDLIBS = cwriter \ + sparc \ x86 \ powerpc \ selectiondag \ @@ -18,6 +19,7 @@ codegen \ target.a \ livevar \ + ipa.a \ transforms.a \ scalaropts.a \ analysis.a \ Index: llvm/tools/llc/llc.cpp diff -u llvm/tools/llc/llc.cpp:1.89 llvm/tools/llc/llc.cpp:1.90 --- llvm/tools/llc/llc.cpp:1.89 Mon Feb 2 13:06:12 2004 +++ llvm/tools/llc/llc.cpp Fri Feb 13 17:19:09 2004 @@ -37,13 +37,14 @@ static cl::opt Force("f", cl::desc("Overwrite output files")); -enum ArchName { noarch, x86, Sparc, PowerPC }; +enum ArchName { noarch, X86, Sparc, PowerPC, CBackend }; static cl::opt Arch("march", cl::desc("Architecture to generate assembly for:"), cl::Prefix, - cl::values(clEnumVal(x86, " IA-32 (Pentium and above)"), - clEnumValN(Sparc, "sparc", " SPARC V9"), - clEnumValN(PowerPC, "powerpc", " PowerPC"), + cl::values(clEnumValN(X86, "x86", " IA-32 (Pentium and above)"), + clEnumValN(Sparc, "sparc", " SPARC V9"), + clEnumValN(PowerPC, "powerpc", " PowerPC"), + clEnumValN(CBackend, "c", " C backend"), 0), cl::init(noarch)); @@ -82,7 +83,10 @@ TargetMachine* (*TargetMachineAllocator)(const Module&, IntrinsicLowering *) = 0; switch (Arch) { - case x86: + case CBackend: + TargetMachineAllocator = allocateCTargetMachine; + break; + case X86: TargetMachineAllocator = allocateX86TargetMachine; break; case Sparc: @@ -116,7 +120,8 @@ TargetMachineAllocator = allocatePowerPCTargetMachine; #else std::cerr << argv[0] << ": module does not specify a target to use. " - << "You must use the -march option.\n"; + << "You must use the -march option. If no native target is " + << "available, use -march=c to emit C code.\n"; return 1; #endif } From lattner at cs.uiuc.edu Fri Feb 13 17:21:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 17:21:02 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Assembly/CWriter.h Message-ID: <200402132320.RAA20718@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Assembly: CWriter.h (r1.6) removed --- Log message: The cbackend has never had anything to do with llvm assembly writing --- Diffs of the changes: (+0 -0) From lattner at cs.uiuc.edu Fri Feb 13 17:23:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 17:23:01 2004 Subject: [llvm-commits] CVS: llvm/tools/llvm-dis/Makefile llvm-dis.cpp Message-ID: <200402132322.RAA20956@zion.cs.uiuc.edu> Changes in directory llvm/tools/llvm-dis: Makefile updated: 1.13 -> 1.14 llvm-dis.cpp updated: 1.38 -> 1.39 --- Log message: Mercilessly rip the cbackend out of llvm-dis. Leave a helpful error message for those who have not heard the news. --- Diffs of the changes: (+9 -18) Index: llvm/tools/llvm-dis/Makefile diff -u llvm/tools/llvm-dis/Makefile:1.13 llvm/tools/llvm-dis/Makefile:1.14 --- llvm/tools/llvm-dis/Makefile:1.13 Fri Feb 13 17:01:14 2004 +++ llvm/tools/llvm-dis/Makefile Fri Feb 13 17:22:40 2004 @@ -9,5 +9,5 @@ LEVEL = ../.. TOOLNAME = llvm-dis -USEDLIBS = cwriter ipa.a scalaropts.a target.a transformutils analysis.a bcreader vmcore support.a +USEDLIBS = bcreader vmcore support.a include $(LEVEL)/Makefile.common Index: llvm/tools/llvm-dis/llvm-dis.cpp diff -u llvm/tools/llvm-dis/llvm-dis.cpp:1.38 llvm/tools/llvm-dis/llvm-dis.cpp:1.39 --- llvm/tools/llvm-dis/llvm-dis.cpp:1.38 Fri Feb 13 17:01:14 2004 +++ llvm/tools/llvm-dis/llvm-dis.cpp Fri Feb 13 17:22:40 2004 @@ -20,7 +20,6 @@ #include "llvm/Module.h" #include "llvm/PassManager.h" #include "llvm/Bytecode/Reader.h" -#include "llvm/Assembly/CWriter.h" #include "llvm/Assembly/PrintModulePass.h" #include "Support/CommandLine.h" #include "Support/Signals.h" @@ -56,6 +55,11 @@ std::ostream *Out = &std::cout; // Default to printing to stdout... std::string ErrorMessage; + if (WriteMode == c) { + std::cerr << "ERROR: llvm-dis no longer contains the C backend. Use 'llc -march=c' instead!\n"; + exit(1); + } + std::auto_ptr M(ParseBytecodeFile(InputFilename, &ErrorMessage)); if (M.get() == 0) { std::cerr << argv[0] << ": "; @@ -84,14 +88,10 @@ int Len = IFN.length(); if (IFN[Len-3] == '.' && IFN[Len-2] == 'b' && IFN[Len-1] == 'c') { // Source ends in .bc - OutputFilename = std::string(IFN.begin(), IFN.end()-3); + OutputFilename = std::string(IFN.begin(), IFN.end()-3)+".ll"; } else { - OutputFilename = IFN; // Append a .ll to it + OutputFilename = IFN+".ll"; } - if (WriteMode == c) - OutputFilename += ".c"; - else - OutputFilename += ".ll"; if (!Force && std::ifstream(OutputFilename.c_str())) { // If force is not specified, make sure not to overwrite a file! @@ -116,16 +116,7 @@ // All that dis does is write the assembly or C out to a file... // PassManager Passes; - - switch (WriteMode) { - case LLVM: // Output LLVM assembly - Passes.add(new PrintModulePass(Out)); - break; - case c: // Convert LLVM to C - AddPassesToWriteC(Passes, *Out); - break; - } - + Passes.add(new PrintModulePass(Out)); Passes.run(*M.get()); if (Out != &std::cout) { From lattner at cs.uiuc.edu Fri Feb 13 17:25:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 17:25:01 2004 Subject: [llvm-commits] CVS: llvm/tools/llvm-dis/llvm-dis.cpp Message-ID: <200402132324.RAA21572@zion.cs.uiuc.edu> Changes in directory llvm/tools/llvm-dis: llvm-dis.cpp updated: 1.39 -> 1.40 --- Log message: Do not advertise our -c option anymore --- Diffs of the changes: (+2 -1) Index: llvm/tools/llvm-dis/llvm-dis.cpp diff -u llvm/tools/llvm-dis/llvm-dis.cpp:1.39 llvm/tools/llvm-dis/llvm-dis.cpp:1.40 --- llvm/tools/llvm-dis/llvm-dis.cpp:1.39 Fri Feb 13 17:22:40 2004 +++ llvm/tools/llvm-dis/llvm-dis.cpp Fri Feb 13 17:24:46 2004 @@ -48,7 +48,8 @@ WriteMode(cl::desc("Specify the output format:"), cl::values(clEnumValN(LLVM, "llvm", "Output LLVM assembly"), clEnumVal(c, "Output C code for program"), - 0)); + 0), + cl::ReallyHidden); int main(int argc, char **argv) { cl::ParseCommandLineOptions(argc, argv, " llvm .bc -> .ll disassembler\n"); From lattner at cs.uiuc.edu Fri Feb 13 17:27:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 17:27:02 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/Makefile.programs Message-ID: <200402132326.RAA21628@zion.cs.uiuc.edu> Changes in directory llvm/test/Programs: Makefile.programs updated: 1.118 -> 1.119 --- Log message: The Cbackend is now in LLC! --- Diffs of the changes: (+4 -9) Index: llvm/test/Programs/Makefile.programs diff -u llvm/test/Programs/Makefile.programs:1.118 llvm/test/Programs/Makefile.programs:1.119 --- llvm/test/Programs/Makefile.programs:1.118 Fri Feb 13 17:01:36 2004 +++ llvm/test/Programs/Makefile.programs Fri Feb 13 17:26:12 2004 @@ -253,9 +253,10 @@ $(LGCCLD) -disable-inlining Output/gccld.test.bc -o Output/gccld.test-out -debug-pass=Arguments > $@.1 2>&1 sed 's/Pass Arguments: //' < $@.1 > $@ - +# If the program requires exception handling support, enable (potentially +# expensive) support for it. ifdef REQUIRES_EH_SUPPORT -CBEFLAGS += -enable-correct-eh-support +LLCFLAGS += -enable-correct-eh-support endif # @@ -263,17 +264,11 @@ # $(PROGRAMS_TO_TEST:%=Output/%.cbe.c): \ Output/%.cbe.c: Output/%.llvm.bc $(LDIS) - -$(LDIS) $(CBEFLAGS) -c $< -o $@ -f + -$(LLC) $(LLCFLAGS) -march=c $< -o $@ -f $(PROGRAMS_TO_TEST:%=Output/%.cbe): \ Output/%.cbe: Output/%.cbe.c -$(CC) $< $(LDFLAGS) $(CFLAGS) -fno-strict-aliasing -O2 -o $@ - -# If the program requires exception handling support, enable (potentially -# expensive) support for it. -ifdef REQUIRES_EH_SUPPORT -LLCFLAGS += -enable-correct-eh-support -endif # # Compile a linked program to machine code with LLC. From lattner at cs.uiuc.edu Fri Feb 13 17:29:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 17:29:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/CBackend/ Message-ID: <200402132328.RAA21683@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/CBackend: --- Log message: Directory /home/vadve/shared/PublicCVS/llvm/lib/Target/CBackend added to the repository --- Diffs of the changes: (+0 -0) From lattner at cs.uiuc.edu Fri Feb 13 17:30:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 17:30:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/Makefile Message-ID: <200402132329.RAA22349@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target: Makefile updated: 1.10 -> 1.11 --- Log message: CBackend now lives here --- Diffs of the changes: (+1 -1) Index: llvm/lib/Target/Makefile diff -u llvm/lib/Target/Makefile:1.10 llvm/lib/Target/Makefile:1.11 --- llvm/lib/Target/Makefile:1.10 Wed Jan 21 15:16:10 2004 +++ llvm/lib/Target/Makefile Fri Feb 13 17:29:20 2004 @@ -7,7 +7,7 @@ # ##===----------------------------------------------------------------------===## LEVEL = ../.. -DIRS = Sparc X86 PowerPC +DIRS = CBackend X86 Sparc PowerPC LIBRARYNAME = target BUILD_ARCHIVE = 1 From lattner at cs.uiuc.edu Fri Feb 13 17:30:11 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 17:30:11 2004 Subject: [llvm-commits] CVS: llvm/lib/Makefile Message-ID: <200402132329.RAA22362@zion.cs.uiuc.edu> Changes in directory llvm/lib: Makefile updated: 1.17 -> 1.18 --- Log message: CBackend is no longer here --- Diffs of the changes: (+1 -1) Index: llvm/lib/Makefile diff -u llvm/lib/Makefile:1.17 llvm/lib/Makefile:1.18 --- llvm/lib/Makefile:1.17 Sun Jan 4 23:25:59 2004 +++ llvm/lib/Makefile Fri Feb 13 17:29:37 2004 @@ -8,7 +8,7 @@ ##===----------------------------------------------------------------------===## LEVEL = .. -PARALLEL_DIRS = VMCore Analysis Transforms AsmParser Bytecode CodeGen Target CWriter ExecutionEngine Debugger +PARALLEL_DIRS = VMCore Analysis Transforms AsmParser Bytecode CodeGen Target ExecutionEngine Debugger include $(LEVEL)/Makefile.common From lattner at cs.uiuc.edu Fri Feb 13 17:31:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 17:31:01 2004 Subject: [llvm-commits] CVS: llvm/lib/CWriter/CTargetMachine.h Writer.cpp Makefile Message-ID: <200402132330.RAA22385@zion.cs.uiuc.edu> Changes in directory llvm/lib/CWriter: CTargetMachine.h (r1.1) removed Writer.cpp (r1.158) removed Makefile (r1.2) removed --- Log message: The CWriter has been moved to lib/Target/CBackend --- Diffs of the changes: (+0 -0) From lattner at cs.uiuc.edu Fri Feb 13 17:32:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 17:32:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/CBackend/Makefile Message-ID: <200402132331.RAA22418@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/CBackend: Makefile updated: 1.2 -> 1.3 --- Log message: Moved directory, update makefile --- Diffs of the changes: (+2 -4) Index: llvm/lib/Target/CBackend/Makefile diff -u llvm/lib/Target/CBackend/Makefile:1.2 llvm/lib/Target/CBackend/Makefile:1.3 --- llvm/lib/Target/CBackend/Makefile:1.2 Mon Oct 20 17:26:56 2003 +++ llvm/lib/Target/CBackend/Makefile Fri Feb 13 17:31:12 2004 @@ -1,4 +1,4 @@ -##===- lib/CWriter/Makefile --------------------------------*- Makefile -*-===## +##===- lib/Target/CBackend/Makefile ------------------------*- Makefile -*-===## # # The LLVM Compiler Infrastructure # @@ -7,9 +7,7 @@ # ##===----------------------------------------------------------------------===## -LEVEL = ../.. - +LEVEL = ../../.. LIBRARYNAME = cwriter - include $(LEVEL)/Makefile.common From lattner at cs.uiuc.edu Fri Feb 13 17:34:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 17:34:01 2004 Subject: [llvm-commits] CVS: llvm/test/Regression/CBackend/2003-06-23-PromotedExprs.llx 2003-06-28-LinkOnceGlobalVars.llx Message-ID: <200402132333.RAA22551@zion.cs.uiuc.edu> Changes in directory llvm/test/Regression/CBackend: 2003-06-23-PromotedExprs.llx updated: 1.4 -> 1.5 2003-06-28-LinkOnceGlobalVars.llx updated: 1.2 -> 1.3 --- Log message: Update tests --- Diffs of the changes: (+2 -2) Index: llvm/test/Regression/CBackend/2003-06-23-PromotedExprs.llx diff -u llvm/test/Regression/CBackend/2003-06-23-PromotedExprs.llx:1.4 llvm/test/Regression/CBackend/2003-06-23-PromotedExprs.llx:1.5 --- llvm/test/Regression/CBackend/2003-06-23-PromotedExprs.llx:1.4 Fri Sep 26 11:43:51 2003 +++ llvm/test/Regression/CBackend/2003-06-23-PromotedExprs.llx Fri Feb 13 17:33:17 2004 @@ -1,5 +1,5 @@ -; RUN: llvm-as < %s | llvm-dis -c > %t1.cbe.c +; RUN: llvm-as < %s | llc -march=c > %t1.cbe.c ; RUN: gcc -B/usr/bin/ %t1.cbe.c -o %t1.cbe ; RUN: %t1.cbe Index: llvm/test/Regression/CBackend/2003-06-28-LinkOnceGlobalVars.llx diff -u llvm/test/Regression/CBackend/2003-06-28-LinkOnceGlobalVars.llx:1.2 llvm/test/Regression/CBackend/2003-06-28-LinkOnceGlobalVars.llx:1.3 --- llvm/test/Regression/CBackend/2003-06-28-LinkOnceGlobalVars.llx:1.2 Mon Sep 15 15:01:53 2003 +++ llvm/test/Regression/CBackend/2003-06-28-LinkOnceGlobalVars.llx Fri Feb 13 17:33:17 2004 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llvm-dis -c | grep common | grep X +; RUN: llvm-as < %s | llc -march=c | grep common | grep X %X = linkonce global int 5 From lattner at cs.uiuc.edu Fri Feb 13 17:36:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 17:36:01 2004 Subject: [llvm-commits] CVS: llvm/test/QMTest/llvm.py Message-ID: <200402132335.RAA22593@zion.cs.uiuc.edu> Changes in directory llvm/test/QMTest: llvm.py updated: 1.25 -> 1.26 --- Log message: update qmtest to for llvm-dis -> llc move of the cwriter --- Diffs of the changes: (+3 -2) Index: llvm/test/QMTest/llvm.py diff -u llvm/test/QMTest/llvm.py:1.25 llvm/test/QMTest/llvm.py:1.26 --- llvm/test/QMTest/llvm.py:1.25 Tue Nov 25 16:05:45 2003 +++ llvm/test/QMTest/llvm.py Fri Feb 13 17:34:59 2004 @@ -224,6 +224,7 @@ # as = buildroot + '/tools/' + context['buildtype'] + '/llvm-as' dis = buildroot + '/tools/' + context['buildtype'] + '/llvm-dis' + llc = buildroot + '/tools/' + context['buildtype'] + '/llc' # # Use the LLVM assembler to assemble the program. @@ -233,9 +234,9 @@ return # - # Use the LLVM disassembler to convert the program to C code. + # Convert the program to C code. # - if (ExecProgram ((dis, bcfile, '-f', '-c', '-o', objfile))): + if (ExecProgram ((llc, bcfile, '-f', '-march=c', '-o', objfile))): fail = 1 result.Fail ('Failed to convert ' + bcfile + ' to C code.') else: From lattner at cs.uiuc.edu Fri Feb 13 17:37:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 17:37:01 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Target/TargetMachineImpls.h Message-ID: <200402132336.RAA22612@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Target: TargetMachineImpls.h updated: 1.9 -> 1.10 --- Log message: Make sure to provide a prototype for the cbackend --- Diffs of the changes: (+8 -0) Index: llvm/include/llvm/Target/TargetMachineImpls.h diff -u llvm/include/llvm/Target/TargetMachineImpls.h:1.9 llvm/include/llvm/Target/TargetMachineImpls.h:1.10 --- llvm/include/llvm/Target/TargetMachineImpls.h:1.9 Mon Feb 2 13:05:08 2004 +++ llvm/include/llvm/Target/TargetMachineImpls.h Fri Feb 13 17:36:03 2004 @@ -21,6 +21,14 @@ class Module; class IntrinsicLowering; + // allocateCTargetMachine - Allocate and return a subclass of TargetMachine + // that implements emits C code. This takes ownership of the + // IntrinsicLowering pointer, deleting it when the target machine is + // destroyed. + // + TargetMachine *allocateCTargetMachine(const Module &M, + IntrinsicLowering *IL = 0); + // allocateSparcTargetMachine - Allocate and return a subclass of // TargetMachine that implements the Sparc backend. This takes ownership of // the IntrinsicLowering pointer, deleting it when the target machine is From lattner at cs.uiuc.edu Fri Feb 13 17:37:11 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 17:37:11 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/InstSelectSimple.cpp Message-ID: <200402132336.RAA22630@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: InstSelectSimple.cpp updated: 1.156 -> 1.157 --- Log message: There is no need to emit a shift if the size is constant, which is common --- Diffs of the changes: (+14 -7) Index: llvm/lib/Target/X86/InstSelectSimple.cpp diff -u llvm/lib/Target/X86/InstSelectSimple.cpp:1.156 llvm/lib/Target/X86/InstSelectSimple.cpp:1.157 --- llvm/lib/Target/X86/InstSelectSimple.cpp:1.156 Thu Feb 12 11:53:22 2004 +++ llvm/lib/Target/X86/InstSelectSimple.cpp Fri Feb 13 17:36:47 2004 @@ -1198,21 +1198,29 @@ } // Turn the byte code into # iterations - unsigned ByteReg = getReg(CI.getOperand(3)); + unsigned ByteReg; unsigned CountReg; switch (Align & 3) { case 2: // WORD aligned - CountReg = makeAnotherReg(Type::IntTy); - BuildMI(BB, X86::SHRir32, 2, CountReg).addReg(ByteReg).addZImm(1); + if (ConstantInt *I = dyn_cast(CI.getOperand(3))) { + CountReg = getReg(ConstantUInt::get(Type::UIntTy, I->getRawValue()/2)); + } else { + CountReg = makeAnotherReg(Type::IntTy); + BuildMI(BB, X86::SHRir32, 2, CountReg).addReg(ByteReg).addZImm(1); + } break; case 0: // DWORD aligned - CountReg = makeAnotherReg(Type::IntTy); - BuildMI(BB, X86::SHRir32, 2, CountReg).addReg(ByteReg).addZImm(2); + if (ConstantInt *I = dyn_cast(CI.getOperand(3))) { + CountReg = getReg(ConstantUInt::get(Type::UIntTy, I->getRawValue()/4)); + } else { + CountReg = makeAnotherReg(Type::IntTy); + BuildMI(BB, X86::SHRir32, 2, CountReg).addReg(ByteReg).addZImm(2); + } break; case 1: // BYTE aligned case 3: // BYTE aligned - CountReg = ByteReg; + CountReg = getReg(CI.getOperand(3)); break; } @@ -1224,7 +1232,6 @@ BuildMI(BB, X86::MOVrr32, 1, X86::EDI).addReg(TmpReg1); BuildMI(BB, X86::MOVrr32, 1, X86::ESI).addReg(TmpReg2); - unsigned Bytes = getReg(CI.getOperand(3)); switch (Align & 3) { case 1: // BYTE aligned case 3: // BYTE aligned From lattner at cs.uiuc.edu Fri Feb 13 17:40:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 17:40:02 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/Makefile.programs Message-ID: <200402132339.RAA23840@zion.cs.uiuc.edu> Changes in directory llvm/test/Programs: Makefile.programs updated: 1.119 -> 1.120 --- Log message: Fix dependency --- Diffs of the changes: (+1 -1) Index: llvm/test/Programs/Makefile.programs diff -u llvm/test/Programs/Makefile.programs:1.119 llvm/test/Programs/Makefile.programs:1.120 --- llvm/test/Programs/Makefile.programs:1.119 Fri Feb 13 17:26:12 2004 +++ llvm/test/Programs/Makefile.programs Fri Feb 13 17:39:16 2004 @@ -263,7 +263,7 @@ # Rules to compile the program for the C Back End # $(PROGRAMS_TO_TEST:%=Output/%.cbe.c): \ -Output/%.cbe.c: Output/%.llvm.bc $(LDIS) +Output/%.cbe.c: Output/%.llvm.bc $(LLC) -$(LLC) $(LLCFLAGS) -march=c $< -o $@ -f $(PROGRAMS_TO_TEST:%=Output/%.cbe): \ From lattner at cs.uiuc.edu Fri Feb 13 17:40:12 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 17:40:12 2004 Subject: [llvm-commits] CVS: poolalloc/test/TEST.poolalloc.Makefile Message-ID: <200402132339.RAA23909@zion.cs.uiuc.edu> Changes in directory poolalloc/test: TEST.poolalloc.Makefile updated: 1.10 -> 1.11 --- Log message: Change CBE generation rule --- Diffs of the changes: (+2 -2) Index: poolalloc/test/TEST.poolalloc.Makefile diff -u poolalloc/test/TEST.poolalloc.Makefile:1.10 poolalloc/test/TEST.poolalloc.Makefile:1.11 --- poolalloc/test/TEST.poolalloc.Makefile:1.10 Fri Feb 13 15:52:08 2004 +++ poolalloc/test/TEST.poolalloc.Makefile Fri Feb 13 17:39:28 2004 @@ -36,8 +36,8 @@ # This rule compiles the new .bc file into a .c file using CBE $(PROGRAMS_TO_TEST:%=Output/%.poolalloc.cbe.c): \ -Output/%.poolalloc.cbe.c: Output/%.$(TEST).transformed.bc $(LDIS) - -$(LDIS) -c -f $< -o $@ +Output/%.poolalloc.cbe.c: Output/%.$(TEST).transformed.bc $(LLC) + -$(LLC) -march=c -f $< -o $@ # This rule compiles the .c file into an executable using $CC $(PROGRAMS_TO_TEST:%=Output/%.poolalloc.cbe): \ From brukman at cs.uiuc.edu Fri Feb 13 17:47:01 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Fri Feb 13 17:47:01 2004 Subject: [llvm-commits] CVS: llvm/tools/llvm-dis/llvm-dis.cpp Message-ID: <200402132346.RAA30397@zion.cs.uiuc.edu> Changes in directory llvm/tools/llvm-dis: llvm-dis.cpp updated: 1.40 -> 1.41 --- Log message: Break a line that's over 80cols into two. --- Diffs of the changes: (+2 -1) Index: llvm/tools/llvm-dis/llvm-dis.cpp diff -u llvm/tools/llvm-dis/llvm-dis.cpp:1.40 llvm/tools/llvm-dis/llvm-dis.cpp:1.41 --- llvm/tools/llvm-dis/llvm-dis.cpp:1.40 Fri Feb 13 17:24:46 2004 +++ llvm/tools/llvm-dis/llvm-dis.cpp Fri Feb 13 17:46:47 2004 @@ -57,7 +57,8 @@ std::string ErrorMessage; if (WriteMode == c) { - std::cerr << "ERROR: llvm-dis no longer contains the C backend. Use 'llc -march=c' instead!\n"; + std::cerr << "ERROR: llvm-dis no longer contains the C backend. " + << "Use 'llc -march=c' instead!\n"; exit(1); } From lattner at cs.uiuc.edu Fri Feb 13 18:31:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 18:31:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Support/Mangler.cpp Message-ID: <200402140030.SAA27862@zion.cs.uiuc.edu> Changes in directory llvm/lib/Support: Mangler.cpp updated: 1.9 -> 1.10 --- Log message: Fix the logic in the name mangler. If there are two symbols named 'X', and one is external, make sure to mangle the *internal* one, not external one --- Diffs of the changes: (+27 -12) Index: llvm/lib/Support/Mangler.cpp diff -u llvm/lib/Support/Mangler.cpp:1.9 llvm/lib/Support/Mangler.cpp:1.10 --- llvm/lib/Support/Mangler.cpp:1.9 Tue Feb 10 21:29:16 2004 +++ llvm/lib/Support/Mangler.cpp Fri Feb 13 18:30:23 2004 @@ -80,22 +80,37 @@ return name; } +void Mangler::InsertName(GlobalValue *GV, + std::map &Names) { + if (!GV->hasName()) { // We must mangle unnamed globals. + MangledGlobals.insert(GV); + return; + } + + // Figure out if this is already used. + GlobalValue *&ExistingValue = Names[GV->getName()]; + if (!ExistingValue) { + ExistingValue = GV; + } else { + // If GV is external but the existing one is static, mangle the existing one + if (GV->hasExternalLinkage() && !ExistingValue->hasExternalLinkage()) { + MangledGlobals.insert(ExistingValue); + ExistingValue = GV; + } else { + // Otherwise, mangle GV + MangledGlobals.insert(GV); + } + } +} + + Mangler::Mangler(Module &m, bool addUnderscorePrefix) : M(m), AddUnderscorePrefix(addUnderscorePrefix), Count(0) { // Calculate which global values have names that will collide when we throw // away type information. - std::set FoundNames; + std::map Names; for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) - if (I->hasName()) // If the global has a name... - if (FoundNames.count(I->getName())) // And the name is already used - MangledGlobals.insert(I); // Mangle the name - else - FoundNames.insert(I->getName()); // Otherwise, keep track of name - + InsertName(I, Names); for (Module::giterator I = M.gbegin(), E = M.gend(); I != E; ++I) - if (I->hasName()) // If the global has a name... - if (FoundNames.count(I->getName())) // And the name is already used - MangledGlobals.insert(I); // Mangle the name - else - FoundNames.insert(I->getName()); // Otherwise, keep track of name + InsertName(I, Names); } From lattner at cs.uiuc.edu Fri Feb 13 18:31:15 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 18:31:15 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Support/Mangler.h Message-ID: <200402140030.SAA27870@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Support: Mangler.h updated: 1.8 -> 1.9 --- Log message: Add method --- Diffs of the changes: (+7 -9) Index: llvm/include/llvm/Support/Mangler.h diff -u llvm/include/llvm/Support/Mangler.h:1.8 llvm/include/llvm/Support/Mangler.h:1.9 --- llvm/include/llvm/Support/Mangler.h:1.8 Tue Nov 11 16:41:31 2003 +++ llvm/include/llvm/Support/Mangler.h Fri Feb 13 18:30:31 2004 @@ -1,4 +1,4 @@ -//===-- Mangler.h - Self-contained c/asm llvm name mangler ------*- C++ -*-===// +//===-- Mangler.h - Self-contained llvm name mangler ------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,25 +7,21 @@ // //===----------------------------------------------------------------------===// // -// Unified name mangler for CWriter and assembly backends. +// Unified name mangler for various backends. // //===----------------------------------------------------------------------===// #ifndef LLVM_SUPPORT_MANGLER_H #define LLVM_SUPPORT_MANGLER_H -namespace llvm { - -class Value; -class Module; - -} // End llvm namespace - #include #include #include namespace llvm { +class Value; +class Module; +class GlobalValue; class Mangler { /// This keeps track of which global values have had their names @@ -40,6 +36,8 @@ ValueMap Memo; unsigned Count; + + void InsertName(GlobalValue *GV, std::map &Names); public: // Mangler ctor - if AddUnderscorePrefix is true, then all public global From lattner at cs.uiuc.edu Fri Feb 13 18:32:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 18:32:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/CBackend/Writer.cpp Message-ID: <200402140031.SAA27910@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/CBackend: Writer.cpp updated: 1.158 -> 1.159 --- Log message: Use intrinsic lowering like the rest of the backends. Get rid of crufty hacky code that worked around problems in the mangler --- Diffs of the changes: (+40 -63) Index: llvm/lib/Target/CBackend/Writer.cpp diff -u llvm/lib/Target/CBackend/Writer.cpp:1.158 llvm/lib/Target/CBackend/Writer.cpp:1.159 --- llvm/lib/Target/CBackend/Writer.cpp:1.158 Fri Feb 13 17:18:48 2004 +++ llvm/lib/Target/CBackend/Writer.cpp Fri Feb 13 18:31:10 2004 @@ -22,6 +22,7 @@ #include "llvm/PassManager.h" #include "llvm/SymbolTable.h" #include "llvm/Intrinsics.h" +#include "llvm/IntrinsicLowering.h" #include "llvm/Analysis/FindUsedTypes.h" #include "llvm/Analysis/ConstantsScanner.h" #include "llvm/Transforms/Scalar.h" @@ -37,16 +38,16 @@ namespace { class CWriter : public Pass, public InstVisitor { std::ostream &Out; + IntrinsicLowering &IL; Mangler *Mang; const Module *TheModule; FindUsedTypes *FUT; std::map TypeNames; - std::set MangledGlobals; std::map FPConstantMap; public: - CWriter(std::ostream &o) : Out(o) {} + CWriter(std::ostream &o, IntrinsicLowering &il) : Out(o), IL(il) {} void getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired(); @@ -56,6 +57,9 @@ bool doInitialization(Module &M); bool run(Module &M) { + // First pass, lower all unhandled intrinsics. + lowerIntrinsics(M); + doInitialization(M); for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) @@ -65,7 +69,6 @@ // Free memory... delete Mang; TypeNames.clear(); - MangledGlobals.clear(); return true; } @@ -77,6 +80,8 @@ void writeOperandInternal(Value *Operand); private : + void lowerIntrinsics(Module &M); + bool nameAllUsedStructureTypes(Module &M); void printModule(Module *M); void printFloatingPointConstants(Module &M); @@ -160,6 +165,7 @@ void printIndexingExpression(Value *Ptr, gep_type_iterator I, gep_type_iterator E); }; +} // Pass the Type* and the variable name and this prints out the variable // declaration. @@ -612,25 +618,6 @@ bool Changed = nameAllUsedStructureTypes(M); Mang = new Mangler(M); - // Calculate which global values have names that will collide when we throw - // away type information. - { // Scope to delete the FoundNames set when we are done with it... - std::set FoundNames; - for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) - if (I->hasName()) // If the global has a name... - if (FoundNames.count(I->getName())) // And the name is already used - MangledGlobals.insert(I); // Mangle the name - else - FoundNames.insert(I->getName()); // Otherwise, keep track of name - - for (Module::giterator I = M.gbegin(), E = M.gend(); I != E; ++I) - if (I->hasName()) // If the global has a name... - if (FoundNames.count(I->getName())) // And the name is already used - MangledGlobals.insert(I); // Mangle the name - else - FoundNames.insert(I->getName()); // Otherwise, keep track of name - } - // get declaration for alloca Out << "/* Provide Declarations */\n"; Out << "#include \n"; // Varargs support @@ -670,11 +657,8 @@ if (!M.empty()) { Out << "\n/* Function Declarations */\n"; for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) { - // If the function is external and the name collides don't print it. - // Sometimes the bytecode likes to have multiple "declarations" for - // external functions - if ((I->hasInternalLinkage() || !MangledGlobals.count(I)) && - !I->getIntrinsicID() && + // Don't print declarations for intrinsic functions. + if (!I->getIntrinsicID() && I->getName() != "setjmp" && I->getName() != "longjmp") { printFunctionSignature(I, true); if (I->hasWeakLinkage()) Out << " __ATTRIBUTE_WEAK__"; @@ -1162,12 +1146,39 @@ writeOperand(I.getOperand(0)); } +void CWriter::lowerIntrinsics(Module &M) { + for (Module::iterator F = M.begin(), E = M.end(); F != E; ++F) + for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) + for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ) + if (CallInst *CI = dyn_cast(I++)) + if (Function *F = CI->getCalledFunction()) + switch (F->getIntrinsicID()) { + case Intrinsic::not_intrinsic: + case Intrinsic::va_start: + case Intrinsic::va_copy: + case Intrinsic::va_end: + // We directly implement these intrinsics + break; + default: + // All other intrinsic calls we must lower. + Instruction *Before = CI->getPrev(); + IL.LowerIntrinsicCall(CI); + if (Before) { // Move iterator to instruction after call + I = Before; ++I; + } else { + I = BB->begin(); + } + } +} + + + void CWriter::visitCallInst(CallInst &I) { // Handle intrinsic function calls first... if (Function *F = I.getCalledFunction()) if (Intrinsic::ID ID = (Intrinsic::ID)F->getIntrinsicID()) { switch (ID) { - default: assert(0 && "Unknown LLVM intrinsic!"); + default: assert(0 && "Unknown LLVM intrinsic!"); case Intrinsic::va_start: Out << "0; "; @@ -1194,38 +1205,6 @@ writeOperand(I.getOperand(1)); Out << ")"; return; - case Intrinsic::setjmp: - case Intrinsic::sigsetjmp: - // This intrinsic should never exist in the program, but until we get - // setjmp/longjmp transformations going on, we should codegen it to - // something reasonable. This will allow code that never calls longjmp - // to work. - Out << "0"; - return; - case Intrinsic::longjmp: - case Intrinsic::siglongjmp: - // Longjmp is not implemented, and never will be. It would cause an - // exception throw. - Out << "abort()"; - return; - case Intrinsic::memcpy: - Out << "memcpy("; - writeOperand(I.getOperand(1)); - Out << ", "; - writeOperand(I.getOperand(2)); - Out << ", "; - writeOperand(I.getOperand(3)); - Out << ")"; - return; - case Intrinsic::memmove: - Out << "memmove("; - writeOperand(I.getOperand(1)); - Out << ", "; - writeOperand(I.getOperand(2)); - Out << ", "; - writeOperand(I.getOperand(3)); - Out << ")"; - return; } } visitCallSite(&I); @@ -1364,8 +1343,6 @@ Out << ");\n va_end(Tmp); }"; } -} - //===----------------------------------------------------------------------===// // External Interface declaration //===----------------------------------------------------------------------===// @@ -1373,7 +1350,7 @@ bool CTargetMachine::addPassesToEmitAssembly(PassManager &PM, std::ostream &o) { PM.add(createLowerAllocationsPass()); PM.add(createLowerInvokePass()); - PM.add(new CWriter(o)); + PM.add(new CWriter(o, getIntrinsicLowering())); return false; } From alkis at cs.uiuc.edu Fri Feb 13 18:45:02 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri Feb 13 18:45:02 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/RegAllocLinearScan.cpp LiveIntervals.cpp Message-ID: <200402140044.SAA02980@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: RegAllocLinearScan.cpp updated: 1.46 -> 1.47 LiveIntervals.cpp updated: 1.49 -> 1.50 --- Log message: Use std::numeric_limits::infinity() instead of std::numeric_limits::max() for weighting preallocated intervals. --- Diffs of the changes: (+2 -2) Index: llvm/lib/CodeGen/RegAllocLinearScan.cpp diff -u llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.46 llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.47 --- llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.46 Fri Feb 13 15:01:20 2004 +++ llvm/lib/CodeGen/RegAllocLinearScan.cpp Fri Feb 13 18:44:07 2004 @@ -641,7 +641,7 @@ DEBUG(std::cerr << "\t\tassigning stack slot at interval "<< *cur << ":\n"); - float minWeight = std::numeric_limits::max(); + float minWeight = std::numeric_limits::infinity(); unsigned minReg = 0; const TargetRegisterClass* rc = mf_->getSSARegMap()->getRegClass(cur->reg); for (TargetRegisterClass::iterator i = rc->allocation_order_begin(*mf_); Index: llvm/lib/CodeGen/LiveIntervals.cpp diff -u llvm/lib/CodeGen/LiveIntervals.cpp:1.49 llvm/lib/CodeGen/LiveIntervals.cpp:1.50 --- llvm/lib/CodeGen/LiveIntervals.cpp:1.49 Fri Feb 13 15:01:20 2004 +++ llvm/lib/CodeGen/LiveIntervals.cpp Fri Feb 13 18:44:07 2004 @@ -436,7 +436,7 @@ LiveIntervals::Interval::Interval(unsigned r) : reg(r), weight((MRegisterInfo::isPhysicalRegister(r) ? - std::numeric_limits::max() : 0.0F)) + std::numeric_limits::infinity() : 0.0F)) { } From lattner at cs.uiuc.edu Fri Feb 13 19:08:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 19:08:02 2004 Subject: [llvm-commits] CVS: llvm/docs/GettingStarted.html HowToSubmitABug.html Message-ID: <200402140107.TAA26547@zion.cs.uiuc.edu> Changes in directory llvm/docs: GettingStarted.html updated: 1.49 -> 1.50 HowToSubmitABug.html updated: 1.11 -> 1.12 --- Log message: Updates for the C backend's movement --- Diffs of the changes: (+7 -7) Index: llvm/docs/GettingStarted.html diff -u llvm/docs/GettingStarted.html:1.49 llvm/docs/GettingStarted.html:1.50 --- llvm/docs/GettingStarted.html:1.49 Sun Feb 8 01:49:04 2004 +++ llvm/docs/GettingStarted.html Fri Feb 13 19:07:17 2004 @@ -911,8 +911,7 @@ LLVM assembly to LLVM bytecode.

    llvm-dis
    The disassembler transforms the LLVM - bytecode to human readable LLVM assembly. Additionally, it can convert - LLVM bytecode to C, which is enabled with the -c option.

    + bytecode to human readable LLVM assembly.

    llvm-link
    llvm-link, not surprisingly, links multiple LLVM modules into a single program.

    @@ -926,8 +925,9 @@ functionality was compiled in), and will execute the code much faster than the interpreter.

    -

    llc
    llc is the LLVM backend compiler, - which translates LLVM bytecode to a SPARC or x86 assembly file.

    +

    llc
    llc is the LLVM backend compiler, which + translates LLVM bytecode to a SPARC or x86 assembly file, or to C code (with + the -march=c option).

    llvmgcc
    llvmgcc is a GCC-based C frontend that has been retargeted to emit LLVM code as the machine code output. It @@ -1147,7 +1147,7 @@ Chris Lattner
    The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/02/08 07:49:04 $ + Last modified: $Date: 2004/02/14 01:07:17 $ Index: llvm/docs/HowToSubmitABug.html diff -u llvm/docs/HowToSubmitABug.html:1.11 llvm/docs/HowToSubmitABug.html:1.12 --- llvm/docs/HowToSubmitABug.html:1.11 Thu Jan 15 13:03:47 2004 +++ llvm/docs/HowToSubmitABug.html Fri Feb 13 19:07:17 2004 @@ -281,7 +281,7 @@
  • Regenerate the shared object from the safe bytecode file:
    -  llvm-dis -c safe.bc -o safe.c
    + llc -march=c safe.bc -o safe.c
    gcc -shared safe.c -o safe.so
  • @@ -315,7 +315,7 @@ Chris Lattner
    The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/01/15 19:03:47 $ + Last modified: $Date: 2004/02/14 01:07:17 $ From alkis at cs.uiuc.edu Fri Feb 13 19:18:01 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri Feb 13 19:18:01 2004 Subject: [llvm-commits] CVS: llvm/include/Support/STLExtras.h Message-ID: <200402140117.TAA31452@zion.cs.uiuc.edu> Changes in directory llvm/include/Support: STLExtras.h updated: 1.13 -> 1.14 --- Log message: Add next() and prior() iterator utility functions. Unlike std::advance they do not modify the passed iterator but return a copy. next(myIt) returns copy of myIt incremented once next(myIt, n) returns copy of myIt incremented n times prior(myIt) returns copy of myIt decremented once prior(myIt, n) returns copy of myIt decremented n times While at it remove obsolete implementation of mapped_iterator. --- Diffs of the changes: (+37 -23) Index: llvm/include/Support/STLExtras.h diff -u llvm/include/Support/STLExtras.h:1.13 llvm/include/Support/STLExtras.h:1.14 --- llvm/include/Support/STLExtras.h:1.13 Sat Nov 22 21:50:31 2003 +++ llvm/include/Support/STLExtras.h Fri Feb 13 19:17:28 2004 @@ -75,7 +75,6 @@ // // It turns out that this is disturbingly similar to boost::transform_iterator // -#if 1 template class mapped_iterator { RootIt current; @@ -131,28 +130,6 @@ return mapped_iterator<_Iterator, Func>(X.getCurrent() - N); } -#else - -// This fails to work, because some iterators are not classes, for example -// vector iterators are commonly value_type **'s -template -class mapped_iterator : public RootIt { - UnaryFunc Fn; -public: - typedef typename UnaryFunc::result_type value_type; - typedef typename UnaryFunc::result_type *pointer; - typedef void reference; // Can't modify value returned by fn - - typedef mapped_iterator _Self; - typedef RootIt super; - inline explicit mapped_iterator(const RootIt &I) : super(I) {} - inline mapped_iterator(const super &It) : super(It) {} - - inline value_type operator*() const { // All this work to do - return Fn(super::operator*()); // this little thing - } -}; -#endif // map_iterator - Provide a convenient way to create mapped_iterators, just like // make_pair is useful for creating pairs... @@ -160,6 +137,43 @@ template inline mapped_iterator map_iterator(const ItTy &I, FuncTy F) { return mapped_iterator(I, F); +} + + +// next/prior - These functions unlike std::advance do not modify the +// passed iterator but return a copy. +// +// next(myIt) returns copy of myIt incremented once +// next(myIt, n) returns copy of myIt incremented n times +// prior(myIt) returns copy of myIt decremented once +// prior(myIt, n) returns copy of myIt decremented n times + +template +inline ItTy next(ItTy it, Dist n) +{ + std::advance(it, n); + return it; +} + +template +inline ItTy next(ItTy it) +{ + std::advance(it, 1); + return it; +} + +template +inline ItTy prior(ItTy it, Dist n) +{ + std::advance(it, -n); + return it; +} + +template +inline ItTy prior(ItTy it) +{ + std::advance(it, -1); + return it; } From alkis at cs.uiuc.edu Fri Feb 13 19:19:00 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri Feb 13 19:19:00 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86RegisterInfo.cpp PeepholeOptimizer.cpp FloatingPoint.cpp Message-ID: <200402140118.TAA00814@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86RegisterInfo.cpp updated: 1.43 -> 1.44 PeepholeOptimizer.cpp updated: 1.13 -> 1.14 FloatingPoint.cpp updated: 1.21 -> 1.22 --- Log message: Use newly added next() and prior() utility functions. --- Diffs of the changes: (+9 -8) Index: llvm/lib/Target/X86/X86RegisterInfo.cpp diff -u llvm/lib/Target/X86/X86RegisterInfo.cpp:1.43 llvm/lib/Target/X86/X86RegisterInfo.cpp:1.44 --- llvm/lib/Target/X86/X86RegisterInfo.cpp:1.43 Thu Feb 12 02:10:45 2004 +++ llvm/lib/Target/X86/X86RegisterInfo.cpp Fri Feb 13 19:18:32 2004 @@ -24,6 +24,7 @@ #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetFrameInfo.h" #include "Support/CommandLine.h" +#include "Support/STLExtras.h" namespace llvm { @@ -223,7 +224,7 @@ MachineBasicBlock &MBB) const { unsigned oldSize = MBB.size(); const MachineFrameInfo *MFI = MF.getFrameInfo(); - MachineBasicBlock::iterator MBBI = MBB.end(); --MBBI; + MachineBasicBlock::iterator MBBI = prior(MBB.end()); MachineInstr *MI; assert(MBBI->getOpcode() == X86::RET && "Can only insert epilog into returning blocks"); Index: llvm/lib/Target/X86/PeepholeOptimizer.cpp diff -u llvm/lib/Target/X86/PeepholeOptimizer.cpp:1.13 llvm/lib/Target/X86/PeepholeOptimizer.cpp:1.14 --- llvm/lib/Target/X86/PeepholeOptimizer.cpp:1.13 Wed Feb 11 20:27:09 2004 +++ llvm/lib/Target/X86/PeepholeOptimizer.cpp Fri Feb 13 19:18:32 2004 @@ -16,6 +16,8 @@ #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/Target/MRegisterInfo.h" #include "Support/Statistic.h" +#include "Support/STLExtras.h" + using namespace llvm; namespace { @@ -51,7 +53,7 @@ bool PH::PeepholeOptimize(MachineBasicBlock &MBB, MachineBasicBlock::iterator &I) { assert(I != MBB.end()); - MachineBasicBlock::iterator NextI = I; ++NextI; + MachineBasicBlock::iterator NextI = next(I); MachineInstr *MI = I; MachineInstr *Next = (NextI != MBB.end()) ? &*NextI : (MachineInstr*)0; @@ -376,7 +378,7 @@ bool SSAPH::PeepholeOptimize(MachineBasicBlock &MBB, MachineBasicBlock::iterator &I) { - MachineBasicBlock::iterator NextI = I; ++NextI; + MachineBasicBlock::iterator NextI = next(I); MachineInstr *MI = I; MachineInstr *Next = (NextI != MBB.end()) ? &*NextI : (MachineInstr*)0; Index: llvm/lib/Target/X86/FloatingPoint.cpp diff -u llvm/lib/Target/X86/FloatingPoint.cpp:1.21 llvm/lib/Target/X86/FloatingPoint.cpp:1.22 --- llvm/lib/Target/X86/FloatingPoint.cpp:1.21 Wed Feb 11 20:27:09 2004 +++ llvm/lib/Target/X86/FloatingPoint.cpp Fri Feb 13 19:18:32 2004 @@ -42,6 +42,7 @@ #include "Support/Debug.h" #include "Support/DepthFirstIterator.h" #include "Support/Statistic.h" +#include "Support/STLExtras.h" #include #include using namespace llvm; @@ -199,11 +200,8 @@ continue; // Efficiently ignore non-fp insts! MachineInstr *PrevMI = 0; - if (I != BB.begin()) { - MachineBasicBlock::iterator tmp = I; - --tmp; - PrevMI = tmp; - } + if (I != BB.begin()) + PrevMI = prior(I); ++NumFP; // Keep track of # of pseudo instrs DEBUG(std::cerr << "\nFPInst:\t"; From alkis at cs.uiuc.edu Fri Feb 13 19:19:10 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri Feb 13 19:19:10 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/RegAlloc/PhyRegAlloc.cpp Message-ID: <200402140118.TAA00823@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/Sparc/RegAlloc: PhyRegAlloc.cpp updated: 1.136 -> 1.137 --- Log message: Use newly added next() and prior() utility functions. --- Diffs of the changes: (+3 -5) Index: llvm/lib/Target/Sparc/RegAlloc/PhyRegAlloc.cpp diff -u llvm/lib/Target/Sparc/RegAlloc/PhyRegAlloc.cpp:1.136 llvm/lib/Target/Sparc/RegAlloc/PhyRegAlloc.cpp:1.137 --- llvm/lib/Target/Sparc/RegAlloc/PhyRegAlloc.cpp:1.136 Fri Feb 13 15:01:19 2004 +++ llvm/lib/Target/Sparc/RegAlloc/PhyRegAlloc.cpp Fri Feb 13 19:18:33 2004 @@ -514,7 +514,7 @@ for (MachineBasicBlock::iterator MII = MBB.begin(); MII != MBB.end(); ++MII) if (unsigned delaySlots = TM.getInstrInfo().getNumDelaySlots(MII->getOpcode())) { - MachineBasicBlock::iterator DelaySlotMI = MII; ++DelaySlotMI; + MachineBasicBlock::iterator DelaySlotMI = next(MII); assert(DelaySlotMI != MBB.end() && "no instruction for delay slot"); // Check the 2 conditions above: @@ -552,8 +552,7 @@ else { // For non-branch instr with delay slots (probably a call), move // InstrAfter to the instr. in the last delay slot. - MachineBasicBlock::iterator tmp = MII; - std::advance(tmp, delaySlots); + MachineBasicBlock::iterator tmp = next(MII, delaySlots); move2DelayedInstr(MII, tmp); } } @@ -646,8 +645,7 @@ // include all live variables before that branch or return -- we don't want to // trample those! Verify that the set is included in the LV set before MInst. if (MII != MBB.begin()) { - MachineBasicBlock::iterator PredMI = MII; - --PredMI; + MachineBasicBlock::iterator PredMI = prior(MII); if (unsigned DS = TM.getInstrInfo().getNumDelaySlots(PredMI->getOpcode())) assert(set_difference(LVI->getLiveVarSetBeforeMInst(PredMI), LVSetBef) .empty() && "Live-var set before branch should be included in " From alkis at cs.uiuc.edu Fri Feb 13 19:19:20 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri Feb 13 19:19:20 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/TwoAddressInstructionPass.cpp PHIElimination.cpp Message-ID: <200402140118.TAA00835@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: TwoAddressInstructionPass.cpp updated: 1.15 -> 1.16 PHIElimination.cpp updated: 1.17 -> 1.18 --- Log message: Use newly added next() and prior() utility functions. --- Diffs of the changes: (+5 -6) Index: llvm/lib/CodeGen/TwoAddressInstructionPass.cpp diff -u llvm/lib/CodeGen/TwoAddressInstructionPass.cpp:1.15 llvm/lib/CodeGen/TwoAddressInstructionPass.cpp:1.16 --- llvm/lib/CodeGen/TwoAddressInstructionPass.cpp:1.15 Fri Feb 13 15:01:20 2004 +++ llvm/lib/CodeGen/TwoAddressInstructionPass.cpp Fri Feb 13 19:18:34 2004 @@ -38,6 +38,7 @@ #include "llvm/Target/TargetMachine.h" #include "Support/Debug.h" #include "Support/Statistic.h" +#include "Support/STLExtras.h" #include using namespace llvm; @@ -134,8 +135,7 @@ unsigned Added = MRI.copyRegToReg(*mbbi, mi, regA, regB, rc); numInstrsAdded += Added; - MachineBasicBlock::iterator prevMi = mi; - --prevMi; + MachineBasicBlock::iterator prevMi = prior(mi); DEBUG(std::cerr << "\t\tadded instruction: "; prevMi->print(std::cerr, TM)); Index: llvm/lib/CodeGen/PHIElimination.cpp diff -u llvm/lib/CodeGen/PHIElimination.cpp:1.17 llvm/lib/CodeGen/PHIElimination.cpp:1.18 --- llvm/lib/CodeGen/PHIElimination.cpp:1.17 Fri Feb 13 15:01:20 2004 +++ llvm/lib/CodeGen/PHIElimination.cpp Fri Feb 13 19:18:34 2004 @@ -20,6 +20,7 @@ #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Support/CFG.h" +#include "Support/STLExtras.h" namespace llvm { @@ -171,8 +172,7 @@ bool HaveNotEmitted = true; if (I != opBlock.begin()) { - MachineBasicBlock::iterator PrevInst = I; - --PrevInst; + MachineBasicBlock::iterator PrevInst = prior(I); for (unsigned i = 0, e = PrevInst->getNumOperands(); i != e; ++i) { MachineOperand &MO = PrevInst->getOperand(i); if (MO.isRegister() && MO.getReg() == IncomingReg) @@ -253,8 +253,7 @@ // kills the incoming value! // if (!ValueIsLive) { - MachineBasicBlock::iterator Prev = I; - --Prev; + MachineBasicBlock::iterator Prev = prior(I); LV->addVirtualRegisterKilled(SrcReg, &opBlock, Prev); } } From alkis at cs.uiuc.edu Fri Feb 13 19:19:30 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri Feb 13 19:19:30 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/PeepholeOpts.cpp Message-ID: <200402140118.TAA00828@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/Sparc: PeepholeOpts.cpp updated: 1.20 -> 1.21 --- Log message: Use newly added next() and prior() utility functions. --- Diffs of the changes: (+2 -1) Index: llvm/lib/Target/Sparc/PeepholeOpts.cpp diff -u llvm/lib/Target/Sparc/PeepholeOpts.cpp:1.20 llvm/lib/Target/Sparc/PeepholeOpts.cpp:1.21 --- llvm/lib/Target/Sparc/PeepholeOpts.cpp:1.20 Fri Feb 13 15:01:20 2004 +++ llvm/lib/Target/Sparc/PeepholeOpts.cpp Fri Feb 13 19:18:34 2004 @@ -19,6 +19,7 @@ #include "llvm/CodeGen/MachineInstr.h" #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetMachine.h" +#include "Support/STLExtras.h" namespace llvm { @@ -31,7 +32,7 @@ // Check if this instruction is in a delay slot of its predecessor. if (BBI != mvec.begin()) { const TargetInstrInfo& mii = target.getInstrInfo(); - MachineBasicBlock::iterator predMI = BBI; --predMI; + MachineBasicBlock::iterator predMI = prior(BBI); if (unsigned ndelay = mii.getNumDelaySlots(predMI->getOpcode())) { // This instruction is in a delay slot of its predecessor, so // replace it with a nop. By replacing in place, we save having From lattner at cs.uiuc.edu Fri Feb 13 20:48:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 20:48:01 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Intrinsics.h Message-ID: <200402140247.UAA27016@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: Intrinsics.h updated: 1.17 -> 1.18 --- Log message: Add llvm.memset/frameaddress/returnaddress intrinsics. --- Diffs of the changes: (+9 -4) Index: llvm/include/llvm/Intrinsics.h diff -u llvm/include/llvm/Intrinsics.h:1.17 llvm/include/llvm/Intrinsics.h:1.18 --- llvm/include/llvm/Intrinsics.h:1.17 Thu Feb 12 12:10:10 2004 +++ llvm/include/llvm/Intrinsics.h Fri Feb 13 20:47:12 2004 @@ -31,6 +31,15 @@ va_end, // Used to implement the va_end macro in C va_copy, // Used to implement the va_copy macro in C + // Code generator intrinsics... + returnaddress, // Yields the return address of a dynamic call frame + frameaddress, // Yields the frame address of a dynamic call frame + + // Standard libc functions... + memcpy, // Copy non-overlapping memory blocks + memmove, // Copy potentially overlapping memory blocks + memset, // Fill memory with a byte value + // Setjmp/Longjmp intrinsics... setjmp, // Used to represent a setjmp call in C longjmp, // Used to represent a longjmp call in C @@ -43,10 +52,6 @@ dbg_region_end, // End of a region dbg_func_start, // Start of a function dbg_declare, // Declare a local object - - // Standard libc functions... - memcpy, // Used to copy non-overlapping memory blocks - memmove, // Used to copy overlapping memory blocks // Standard libm functions... From lattner at cs.uiuc.edu Fri Feb 13 20:48:11 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 20:48:11 2004 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Function.cpp IntrinsicLowering.cpp Verifier.cpp Message-ID: <200402140247.UAA27027@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Function.cpp updated: 1.64 -> 1.65 IntrinsicLowering.cpp updated: 1.7 -> 1.8 Verifier.cpp updated: 1.80 -> 1.81 --- Log message: Add llvm.memset/frameaddress/returnaddress intrinsics. --- Diffs of the changes: (+43 -9) Index: llvm/lib/VMCore/Function.cpp diff -u llvm/lib/VMCore/Function.cpp:1.64 llvm/lib/VMCore/Function.cpp:1.65 --- llvm/lib/VMCore/Function.cpp:1.64 Thu Feb 12 12:11:20 2004 +++ llvm/lib/VMCore/Function.cpp Fri Feb 13 20:47:16 2004 @@ -214,12 +214,19 @@ if (getName() == "llvm.dbg.func.start") return Intrinsic::dbg_func_start; if (getName() == "llvm.dbg.declare") return Intrinsic::dbg_declare; break; + case 'f': + if (getName() == "llvm.frameaddress") return Intrinsic::frameaddress; + break; case 'l': if (getName() == "llvm.longjmp") return Intrinsic::longjmp; break; case 'm': if (getName() == "llvm.memcpy") return Intrinsic::memcpy; if (getName() == "llvm.memmove") return Intrinsic::memmove; + if (getName() == "llvm.memset") return Intrinsic::memset; + break; + case 'r': + if (getName() == "llvm.returnaddress") return Intrinsic::returnaddress; break; case 's': if (getName() == "llvm.setjmp") return Intrinsic::setjmp; Index: llvm/lib/VMCore/IntrinsicLowering.cpp diff -u llvm/lib/VMCore/IntrinsicLowering.cpp:1.7 llvm/lib/VMCore/IntrinsicLowering.cpp:1.8 --- llvm/lib/VMCore/IntrinsicLowering.cpp:1.7 Thu Feb 12 12:11:20 2004 +++ llvm/lib/VMCore/IntrinsicLowering.cpp Fri Feb 13 20:47:17 2004 @@ -12,7 +12,7 @@ //===----------------------------------------------------------------------===// #include "llvm/IntrinsicLowering.h" -#include "llvm/Constant.h" +#include "llvm/Constants.h" #include "llvm/DerivedTypes.h" #include "llvm/Module.h" #include "llvm/iOther.h" @@ -49,6 +49,12 @@ new CallInst(M->getOrInsertFunction("abort", Type::VoidTy, 0), "", CI); break; + case Intrinsic::returnaddress: + case Intrinsic::frameaddress: + CI->replaceAllUsesWith(ConstantPointerNull::get( + cast(CI->getType()))); + break; + case Intrinsic::dbg_stoppoint: case Intrinsic::dbg_region_start: case Intrinsic::dbg_region_end: @@ -72,7 +78,7 @@ break; } case Intrinsic::memmove: { - // The memmove intrinsic take an extra alignment argument that the memcpy + // The memmove intrinsic take an extra alignment argument that the memmove // libc function does not. const FunctionType *CFT = Callee->getFunctionType(); FunctionType *FT = @@ -81,6 +87,19 @@ false); Function *MemMove = M->getOrInsertFunction("memmove", FT); new CallInst(MemMove, std::vector(CI->op_begin()+1, CI->op_end()-1), + CI->getName(), CI); + break; + } + case Intrinsic::memset: { + // The memset intrinsic take an extra alignment argument that the memset + // libc function does not. + const FunctionType *CFT = Callee->getFunctionType(); + FunctionType *FT = + FunctionType::get(*CFT->param_begin(), + std::vector(CFT->param_begin(), CFT->param_end()-1), + false); + Function *MemSet = M->getOrInsertFunction("memset", FT); + new CallInst(MemSet, std::vector(CI->op_begin()+1, CI->op_end()-1), CI->getName(), CI); break; } Index: llvm/lib/VMCore/Verifier.cpp diff -u llvm/lib/VMCore/Verifier.cpp:1.80 llvm/lib/VMCore/Verifier.cpp:1.81 --- llvm/lib/VMCore/Verifier.cpp:1.80 Thu Feb 12 12:11:20 2004 +++ llvm/lib/VMCore/Verifier.cpp Fri Feb 13 20:47:17 2004 @@ -41,17 +41,14 @@ #include "llvm/Analysis/Verifier.h" #include "llvm/Assembly/Writer.h" +#include "llvm/Constants.h" #include "llvm/Pass.h" #include "llvm/Module.h" #include "llvm/DerivedTypes.h" -#include "llvm/iPHINode.h" -#include "llvm/iTerminators.h" -#include "llvm/iOther.h" -#include "llvm/iOperators.h" -#include "llvm/iMemory.h" -#include "llvm/SymbolTable.h" -#include "llvm/PassManager.h" +#include "llvm/Instructions.h" #include "llvm/Intrinsics.h" +#include "llvm/PassManager.h" +#include "llvm/SymbolTable.h" #include "llvm/Analysis/Dominators.h" #include "llvm/Support/CFG.h" #include "llvm/Support/InstVisitor.h" @@ -551,6 +548,16 @@ case Intrinsic::va_end: NumArgs = 1; break; case Intrinsic::va_copy: NumArgs = 1; break; + case Intrinsic::returnaddress: + case Intrinsic::frameaddress: + Assert1(isa(FT->getReturnType()), + "llvm.(frame|return)address must return pointers", IF); + Assert1(FT->getNumParams() == 1 && isa(CI.getOperand(1)), + "llvm.(frame|return)address require a single constant integer argument", + &CI); + NumArgs = 1; + break; + case Intrinsic::setjmp: NumArgs = 1; break; case Intrinsic::longjmp: NumArgs = 2; break; case Intrinsic::sigsetjmp: NumArgs = 2; break; @@ -564,6 +571,7 @@ case Intrinsic::memcpy: NumArgs = 4; break; case Intrinsic::memmove: NumArgs = 4; break; + case Intrinsic::memset: NumArgs = 4; break; case Intrinsic::alpha_ctlz: NumArgs = 1; break; case Intrinsic::alpha_cttz: NumArgs = 1; break; From lattner at cs.uiuc.edu Fri Feb 13 20:52:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 20:52:01 2004 Subject: [llvm-commits] CVS: llvm/test/Regression/CodeGen/X86/2004-02-13-FrameReturnAddress.llx Message-ID: <200402140251.UAA27196@zion.cs.uiuc.edu> Changes in directory llvm/test/Regression/CodeGen/X86: 2004-02-13-FrameReturnAddress.llx added (r1.1) --- Log message: Test that the code generator supports these intrinsics --- Diffs of the changes: (+14 -0) Index: llvm/test/Regression/CodeGen/X86/2004-02-13-FrameReturnAddress.llx diff -c /dev/null llvm/test/Regression/CodeGen/X86/2004-02-13-FrameReturnAddress.llx:1.1 *** /dev/null Fri Feb 13 20:51:51 2004 --- llvm/test/Regression/CodeGen/X86/2004-02-13-FrameReturnAddress.llx Fri Feb 13 20:51:40 2004 *************** *** 0 **** --- 1,14 ---- + ; RUN: llvm-as < %s | llc + + declare sbyte* %llvm.returnaddress(uint) + declare sbyte* %llvm.frameaddress(uint) + + sbyte *%test1() { + %X = call sbyte* %llvm.returnaddress(uint 0) + ret sbyte* %X + } + + sbyte *%test2() { + %X = call sbyte* %llvm.frameaddress(uint 0) + ret sbyte* %X + } From lattner at cs.uiuc.edu Fri Feb 13 20:56:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 20:56:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/CBackend/Writer.cpp Message-ID: <200402140255.UAA27535@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/CBackend: Writer.cpp updated: 1.159 -> 1.160 --- Log message: Add support for the returnaddress and frameaddress intrinsics --- Diffs of the changes: (+12 -0) Index: llvm/lib/Target/CBackend/Writer.cpp diff -u llvm/lib/Target/CBackend/Writer.cpp:1.159 llvm/lib/Target/CBackend/Writer.cpp:1.160 --- llvm/lib/Target/CBackend/Writer.cpp:1.159 Fri Feb 13 18:31:10 2004 +++ llvm/lib/Target/CBackend/Writer.cpp Fri Feb 13 20:55:36 2004 @@ -1157,6 +1157,8 @@ case Intrinsic::va_start: case Intrinsic::va_copy: case Intrinsic::va_end: + case Intrinsic::returnaddress: + case Intrinsic::frameaddress: // We directly implement these intrinsics break; default: @@ -1202,6 +1204,16 @@ Out << "0;"; Out << "va_copy(*(va_list*)&" << Mang->getValueName(&I) << ", "; Out << "*(va_list*)&"; + writeOperand(I.getOperand(1)); + Out << ")"; + return; + case Intrinsic::returnaddress: + Out << "__builtin_return_address("; + writeOperand(I.getOperand(1)); + Out << ")"; + return; + case Intrinsic::frameaddress: + Out << "__builtin_frame_address("; writeOperand(I.getOperand(1)); Out << ")"; return; From lattner at cs.uiuc.edu Fri Feb 13 20:56:11 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 20:56:11 2004 Subject: [llvm-commits] CVS: llvm/test/Regression/CBackend/2004-02-13-FrameReturnAddress.llx Message-ID: <200402140255.UAA27544@zion.cs.uiuc.edu> Changes in directory llvm/test/Regression/CBackend: 2004-02-13-FrameReturnAddress.llx added (r1.1) --- Log message: Add a testcase for the frameaddress and returnaddress intrinsics. --- Diffs of the changes: (+14 -0) Index: llvm/test/Regression/CBackend/2004-02-13-FrameReturnAddress.llx diff -c /dev/null llvm/test/Regression/CBackend/2004-02-13-FrameReturnAddress.llx:1.1 *** /dev/null Fri Feb 13 20:55:57 2004 --- llvm/test/Regression/CBackend/2004-02-13-FrameReturnAddress.llx Fri Feb 13 20:55:47 2004 *************** *** 0 **** --- 1,14 ---- + ; RUN: llvm-as < %s | llc -march=c | grep builtin_return_address + + declare sbyte* %llvm.returnaddress(uint) + declare sbyte* %llvm.frameaddress(uint) + + sbyte *%test1() { + %X = call sbyte* %llvm.returnaddress(uint 0) + ret sbyte* %X + } + + sbyte *%test2() { + %X = call sbyte* %llvm.frameaddress(uint 0) + ret sbyte* %X + } From lattner at cs.uiuc.edu Fri Feb 13 21:47:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 21:47:01 2004 Subject: [llvm-commits] CVS: llvm/test/Regression/CFrontend/2004-02-13-Memset.c.tr Message-ID: <200402140346.VAA13439@zion.cs.uiuc.edu> Changes in directory llvm/test/Regression/CFrontend: 2004-02-13-Memset.c.tr added (r1.1) --- Log message: Test that the CFE compiles memset and bzero to llvm.memset --- Diffs of the changes: (+6 -0) Index: llvm/test/Regression/CFrontend/2004-02-13-Memset.c.tr diff -c /dev/null llvm/test/Regression/CFrontend/2004-02-13-Memset.c.tr:1.1 *** /dev/null Fri Feb 13 21:46:48 2004 --- llvm/test/Regression/CFrontend/2004-02-13-Memset.c.tr Fri Feb 13 21:46:37 2004 *************** *** 0 **** --- 1,6 ---- + // RUN: %llvmgcc -xc %s -c -o - | llvm-dis | grep llvm.memset | wc -l | grep 3 + + void test(int* X, char *Y) { + memset(X, 4, 1000); + bzero(Y, 100); + } From lattner at cs.uiuc.edu Fri Feb 13 22:07:04 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 22:07:04 2004 Subject: [llvm-commits] CVS: llvm/test/Regression/CFrontend/2004-02-13-BuiltinFrameReturnAddress.c.tr Message-ID: <200402140406.WAA22156@zion.cs.uiuc.edu> Changes in directory llvm/test/Regression/CFrontend: 2004-02-13-BuiltinFrameReturnAddress.c.tr added (r1.1) --- Log message: Testcase for builtin frame/return address --- Diffs of the changes: (+8 -0) Index: llvm/test/Regression/CFrontend/2004-02-13-BuiltinFrameReturnAddress.c.tr diff -c /dev/null llvm/test/Regression/CFrontend/2004-02-13-BuiltinFrameReturnAddress.c.tr:1.1 *** /dev/null Fri Feb 13 22:06:59 2004 --- llvm/test/Regression/CFrontend/2004-02-13-BuiltinFrameReturnAddress.c.tr Fri Feb 13 22:06:48 2004 *************** *** 0 **** --- 1,8 ---- + // RUN: %llvmgcc -xc %s -c -o - | llvm-dis | grep 'llvm.*address' | wc -l | grep 4 + + void *test1() { + return __builtin_return_address(1); + } + void *test2() { + return __builtin_frame_address(0); + } From lattner at cs.uiuc.edu Fri Feb 13 22:09:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 22:09:01 2004 Subject: [llvm-commits] CVS: gcc-3.4/gcc/llvm-expand.c Message-ID: <200402140408.WAA22179@zion.cs.uiuc.edu> Changes in directory gcc-3.4/gcc: llvm-expand.c updated: 1.10 -> 1.11 --- Log message: Implement __builtin_frame_address/__builtin_return_address Implement __builtin_memcpy/__builtin_bzero --- Diffs of the changes: (+97 -17) Index: gcc-3.4/gcc/llvm-expand.c diff -u gcc-3.4/gcc/llvm-expand.c:1.10 gcc-3.4/gcc/llvm-expand.c:1.11 --- gcc-3.4/gcc/llvm-expand.c:1.10 Fri Feb 13 16:12:53 2004 +++ gcc-3.4/gcc/llvm-expand.c Fri Feb 13 22:07:54 2004 @@ -347,6 +347,34 @@ append_inst(Fn, I); } +/* EmitMemset - Fill the specified destination with SIZE bytes of VAL. If an + * alignment is known of the destination pointer and size, it may be specified. + */ +static void EmitMemset(llvm_function *Fn, llvm_value *DestPtr, llvm_value *Val, + llvm_value *Size, unsigned Alignment) { + static llvm_function *llvm_memset_fn = 0; + static llvm_type *size_tTy = 0; + + llvm_instruction *I; + if (!llvm_memset_fn) { + llvm_type *FnTy = llvm_type_create_function(4, VoidTy); + FnTy->Elements[1] = VoidPtrTy; + FnTy->Elements[2] = UByteTy; + FnTy->Elements[3] = size_tTy = llvm_type_get_from_tree(size_type_node); + FnTy->Elements[4] = UIntTy; + FnTy = llvm_type_get_cannonical_function(FnTy); + llvm_memset_fn = CreateIntrinsicFnWithType("llvm.memset", FnTy); + } + + I = llvm_instruction_new(VoidTy, "", O_Call, 5); + I->Operands[0] = G2V(llvm_memset_fn); + I->Operands[1] = cast_if_type_not_equal(Fn, DestPtr, VoidPtrTy); + I->Operands[2] = cast_if_type_not_equal(Fn, Val, UByteTy); + I->Operands[3] = cast_if_type_not_equal(Fn, Size, size_tTy); + I->Operands[4] = llvm_constant_new_integral(UIntTy, Alignment); + append_inst(Fn, I); +} + /* llvm_copy_aggregate - Given two pointers to structures, copy *SrcPtr into * *DestPtr, element by element. @@ -3772,7 +3800,7 @@ * If the size of the array is too small (i.e. we didn't know the size, * so we said it was zero), make it larger. */ - if (FieldOffset >= Size) + if ((unsigned)FieldOffset >= Size) { /* * Increase the size of the LLVM array type. @@ -4122,6 +4150,54 @@ return append_inst(Fn, create_alloca_inst("tmp", SByteTy, Size)); } +static llvm_value *llvm_expand_builtin_return_frame_address(llvm_function *Fn, + tree arglist, + int isFrameAddress){ + static llvm_function *BRAFn = 0, *BFAFn = 0; + llvm_function *TheFn; + llvm_value *Arg; + llvm_instruction *TheCall; + if (arglist == 0) + return llvm_constant_get_null(VoidPtrTy); + if (!host_integerp(TREE_VALUE(arglist), 1)) { + if (isFrameAddress) + error("invalid arg to `__builtin_frame_address'"); + else + error("invalid arg to `__builtin_return_address'"); + return llvm_constant_get_null(VoidPtrTy); + } + + Arg = llvm_expand_expr(Fn, TREE_VALUE(arglist), 0); + assert(llvm_value_is_constant(Arg) && "No constant to builtinreturnaddress?"); + + if (!isFrameAddress) { + if (BRAFn == 0) { + llvm_type *FnTy = llvm_type_create_function(1, VoidPtrTy); + FnTy->Elements[1] = UIntTy; + FnTy = llvm_type_get_cannonical_function(FnTy); + BRAFn = CreateIntrinsicFnWithType("llvm.returnaddress", FnTy); + } + + TheFn = BRAFn; + } else { + if (BFAFn == 0) { + llvm_type *FnTy = llvm_type_create_function(1, VoidPtrTy); + FnTy->Elements[1] = UIntTy; + FnTy = llvm_type_get_cannonical_function(FnTy); + BFAFn = CreateIntrinsicFnWithType("llvm.frameaddress", FnTy); + } + + TheFn = BFAFn; + } + + TheCall = llvm_instruction_new(VoidPtrTy, "tmp", O_Call, 2); + TheCall->Operands[0] = G2V(TheFn); + TheCall->Operands[1] = cast_if_type_not_equal(Fn, Arg, UIntTy); + append_inst(Fn, TheCall); + return D2V(TheCall); +} + + /* llvm_expand_builtin - This is patterned off of expand_builtin. */ static llvm_value *llvm_expand_builtin(llvm_function *Fn, tree exp, llvm_value *DestLoc) { @@ -4155,10 +4231,8 @@ case BUILT_IN_ATAN2: case BUILT_IN_ATAN2F: case BUILT_IN_ATAN2L: - case BUILT_IN_MEMSET: case BUILT_IN_MEMCMP: case BUILT_IN_BCMP: - case BUILT_IN_BZERO: case BUILT_IN_INDEX: case BUILT_IN_RINDEX: case BUILT_IN_STRCHR: @@ -4207,6 +4281,23 @@ case BUILT_IN_MEMCPY: assert(DestLoc == 0 && "memcpy doesn't return aggregate!"); return llvm_expand_builtin_memcpy(Fn, arglist); + + case BUILT_IN_BZERO: { + llvm_value *Op0 = llvm_expand_expr(Fn, TREE_VALUE(arglist), 0); + llvm_value *Op1 = llvm_expand_expr(Fn, TREE_VALUE(TREE_CHAIN(arglist)), 0); + EmitMemset(Fn, Op0, llvm_constant_get_null(UByteTy), Op1, 0); + return 0; + } + case BUILT_IN_MEMSET: { + llvm_value *Op0, *Op1, *Op2; + Op0 = llvm_expand_expr(Fn, TREE_VALUE(arglist), 0); + arglist = TREE_CHAIN(arglist); + Op1 = llvm_expand_expr(Fn, TREE_VALUE(arglist), 0); + arglist = TREE_CHAIN(arglist); + Op2 = llvm_expand_expr(Fn, TREE_VALUE(arglist), 0); + EmitMemset(Fn, Op0, Op1, Op2, 0); + return Op0; + } default: break; } @@ -4332,11 +4423,12 @@ case BUILT_IN_ALLOCA: return llvm_expand_builtin_alloca(Fn, arglist); -#if 0 case BUILT_IN_FRAME_ADDRESS: case BUILT_IN_RETURN_ADDRESS: - return expand_builtin_frame_address (exp); + return llvm_expand_builtin_return_frame_address(Fn, arglist, + fcode == BUILT_IN_FRAME_ADDRESS); +#if 0 /* Returns the address of the area where the structure is returned. 0 otherwise. */ case BUILT_IN_AGGREGATE_INCOMING_ADDRESS: @@ -4456,18 +4548,6 @@ case BUILT_IN_RINDEX: case BUILT_IN_STRRCHR: target = expand_builtin_strrchr (arglist, target, mode); - if (target) - return target; - break; - - case BUILT_IN_MEMSET: - target = expand_builtin_memset (exp, target, mode); - if (target) - return target; - break; - - case BUILT_IN_BZERO: - target = expand_builtin_bzero (exp); if (target) return target; break; From lattner at cs.uiuc.edu Fri Feb 13 22:09:11 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 22:09:11 2004 Subject: [llvm-commits] CVS: llvm/docs/ReleaseNotes.html Message-ID: <200402140408.WAA22580@zion.cs.uiuc.edu> Changes in directory llvm/docs: ReleaseNotes.html updated: 1.122 -> 1.123 --- Log message: builtin_return/frame_address now work --- Diffs of the changes: (+2 -2) Index: llvm/docs/ReleaseNotes.html diff -u llvm/docs/ReleaseNotes.html:1.122 llvm/docs/ReleaseNotes.html:1.123 --- llvm/docs/ReleaseNotes.html:1.122 Fri Feb 13 11:03:01 2004 +++ llvm/docs/ReleaseNotes.html Fri Feb 13 22:08:29 2004 @@ -330,7 +330,6 @@
  • Constraints: Constraints for asm operands.
  • Asm Labels: Specifying the assembler name to use for a C symbol.
  • Explicit Reg Vars: Defining variables residing in specified registers.
  • -
  • Return Address: Getting the return or frame address of a function.
  • Vector Extensions: Using vector instructions through built-in functions.
  • Target Builtins: Built-in functions specific to particular targets.
  • Thread-Local: Per-thread variables.
  • @@ -424,6 +423,7 @@
  • Alternate Keywords:__const__, __asm__, etc., for header files.
  • Incomplete Enums: enum foo;, with details to follow.
  • Function Names: Printable strings which are the name of the current function.
  • +
  • Return Address: Getting the return or frame address of a function.
  • Unnamed Fields: Unnamed struct/union fields within structs/unions.
  • Attribute Syntax: Formal syntax for attributes.
  • @@ -580,7 +580,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/02/13 17:03:01 $ + Last modified: $Date: 2004/02/14 04:08:29 $ From lattner at cs.uiuc.edu Fri Feb 13 22:09:21 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 22:09:21 2004 Subject: [llvm-commits] CVS: llvm/docs/LangRef.html Message-ID: <200402140408.WAA22587@zion.cs.uiuc.edu> Changes in directory llvm/docs: LangRef.html updated: 1.46 -> 1.47 --- Log message: Document new intrinsics --- Diffs of the changes: (+164 -2) Index: llvm/docs/LangRef.html diff -u llvm/docs/LangRef.html:1.46 llvm/docs/LangRef.html:1.47 --- llvm/docs/LangRef.html:1.46 Thu Feb 12 15:18:15 2004 +++ llvm/docs/LangRef.html Fri Feb 13 22:08:35 2004 @@ -95,10 +95,17 @@
  • 'llvm.va_copy' Intrinsic
  • +
  • Code Generator Intrinsics +
      +
    1. 'llvm.returnaddress' Intrinsic
    2. +
    3. 'llvm.frameaddress' Intrinsic
    4. +
    +
  • Standard C Library Intrinsics
    1. 'llvm.memcpy' Intrinsic
    2. 'llvm.memmove' Intrinsic
    3. +
    4. 'llvm.memset' Intrinsic
  • Debugger intrinsics @@ -1735,12 +1742,116 @@ + +
    +

    +These intrinsics are provided by LLVM to expose special features that may only +be implemented with code generator support. +

    + +
    + + +
    + +
    Syntax:
    +
    +  call void* ()* %llvm.returnaddress(uint <level>)
    +
    + +
    Overview:
    + +

    +The 'llvm.returnaddress' intrinsic returns a target-specific value +indicating the return address of the current function or one of its callers. +

    + +
    Arguments:
    + +

    +The argument to this intrinsic indicates which function to return the address +for. Zero indicates the calling function, one indicates its caller, etc. The +argument is required to be a constant integer value. +

    + +
    Semantics:
    + +

    +The 'llvm.returnaddress' intrinsic either returns a pointer indicating +the return address of the specified call frame, or zero if it cannot be +identified. The value returned by this intrinsic is likely to be incorrect or 0 +for arguments other than zero, so it should only be used for debugging purposes. +

    + +

    +Note that calling this intrinsic does not prevent function inlining or other +aggressive transformations, so the value returned may not that of the obvious +source-language caller. +

    +
    + + + + + +
    + +
    Syntax:
    +
    +  call void* ()* %llvm.frameaddress(uint <level>)
    +
    + +
    Overview:
    + +

    +The 'llvm.frameaddress' intrinsic returns the target-specific frame +pointer value for the specified stack frame. +

    + +
    Arguments:
    + +

    +The argument to this intrinsic indicates which function to return the frame +pointer for. Zero indicates the calling function, one indicates its caller, +etc. The argument is required to be a constant integer value. +

    + +
    Semantics:
    + +

    +The 'llvm.frameaddress' intrinsic either returns a pointer indicating +the frame address of the specified call frame, or zero if it cannot be +identified. The value returned by this intrinsic is likely to be incorrect or 0 +for arguments other than zero, so it should only be used for debugging purposes. +

    +

    +Note that calling this intrinsic does not prevent function inlining or other +aggressive transformations, so the value returned may not that of the obvious +source-language caller. +

    +
    + + + + +
    +

    +LLVM provides intrinsics for a few important standard C library functions. +These intrinsics allow source-language front-ends to pass information about the +alignment of the pointer arguments to the code generator, providing opportunity +for more efficient code generation.

    @@ -1850,6 +1961,57 @@ + + + +
    + +
    Syntax:
    +
    +  call void (sbyte*, ubyte, uint, uint)* %llvm.memset(sbyte* <dest>, ubyte <val>,
    +                                                      uint <len>, uint <align>)
    +
    + +
    Overview:
    + +

    +The 'llvm.memset' intrinsic fills a block of memory with a particular +byte value. +

    + +

    +Note that, unlike the standard libc function, the llvm.memset intrinsic +does not return a value, and takes an extra alignment argument. +

    + +
    Arguments:
    + +

    +The first argument is a pointer to the destination to fill, the second is the +byte value to fill it with, the third argument is an (arbitrarily sized) integer +argument specifying the number of bytes to fill, and the fourth argument is the +known alignment of destination location. +

    + +

    +If the call to this intrinisic has an alignment value that is not 0 or 1, then +the caller guarantees that the size of the copy is a multiple of the alignment +and that the destination pointer is aligned to that boundary. +

    + +
    Semantics:
    + +

    +The 'llvm.memset' intrinsic fills "len" bytes of memory starting at the +destination location. If the argument is known to be aligned to some boundary, +this can be specified as the fourth argument, otherwise it should be set to 0 or +1. +

    +
    + +
    Debugger Intrinsics @@ -1870,6 +2032,6 @@ +Last modified: $Date: 2004/02/14 04:08:35 $
    From lattner at cs.uiuc.edu Fri Feb 13 22:13:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 22:13:01 2004 Subject: [llvm-commits] CVS: llvm/docs/ReleaseNotes.html Message-ID: <200402140412.WAA23420@zion.cs.uiuc.edu> Changes in directory llvm/docs: ReleaseNotes.html updated: 1.123 -> 1.124 --- Log message: These should be mentioned --- Diffs of the changes: (+3 -4) Index: llvm/docs/ReleaseNotes.html diff -u llvm/docs/ReleaseNotes.html:1.123 llvm/docs/ReleaseNotes.html:1.124 --- llvm/docs/ReleaseNotes.html:1.123 Fri Feb 13 22:08:29 2004 +++ llvm/docs/ReleaseNotes.html Fri Feb 13 22:12:41 2004 @@ -99,6 +99,7 @@
    1. Exception handling support in the X86 & Sparc native code generators
    2. +
    3. The C/C++ front-end now support the GCC __builtin_return_address and __builtin_frame_address extensions.
    @@ -450,9 +451,7 @@ -
    - Bugs -
    +
    Bugs
    @@ -580,7 +579,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/02/14 04:08:29 $ + Last modified: $Date: 2004/02/14 04:12:41 $ From lattner at cs.uiuc.edu Fri Feb 13 22:27:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 22:27:01 2004 Subject: [llvm-commits] CVS: llvm/test/Regression/CFrontend/2004-02-13-StringInit.c.tr Message-ID: <200402140426.WAA31788@zion.cs.uiuc.edu> Changes in directory llvm/test/Regression/CFrontend: 2004-02-13-StringInit.c.tr added (r1.1) --- Log message: new testcase for llvm.memset generation --- Diffs of the changes: (+7 -0) Index: llvm/test/Regression/CFrontend/2004-02-13-StringInit.c.tr diff -c /dev/null llvm/test/Regression/CFrontend/2004-02-13-StringInit.c.tr:1.1 *** /dev/null Fri Feb 13 22:26:25 2004 --- llvm/test/Regression/CFrontend/2004-02-13-StringInit.c.tr Fri Feb 13 22:26:15 2004 *************** *** 0 **** --- 1,7 ---- + // RUN: %llvmgcc -xc %s -c -o - | llvm-dis | grep llvm.memset + + char test(int X) { + char str[10000] = "abc"; // tail should be memset. + return str[X]; + } + From lattner at cs.uiuc.edu Fri Feb 13 22:27:11 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 22:27:11 2004 Subject: [llvm-commits] CVS: gcc-3.4/gcc/llvm-expand.c Message-ID: <200402140426.WAA31847@zion.cs.uiuc.edu> Changes in directory gcc-3.4/gcc: llvm-expand.c updated: 1.11 -> 1.12 --- Log message: Use a memset instead of an explicit loop to initialize arrays in tests like test/Regression/CFrontend/2004-02-13-StringInit.c.tr --- Diffs of the changes: (+43 -32) Index: gcc-3.4/gcc/llvm-expand.c diff -u gcc-3.4/gcc/llvm-expand.c:1.11 gcc-3.4/gcc/llvm-expand.c:1.12 --- gcc-3.4/gcc/llvm-expand.c:1.11 Fri Feb 13 22:07:54 2004 +++ gcc-3.4/gcc/llvm-expand.c Fri Feb 13 22:26:31 2004 @@ -3903,6 +3903,9 @@ if (Size-TailStart < 16) TailStart = Size; + /* FIXME: If tailstart is obscenely large, we are better off starting with + * an initialized global and memcpy'ing it over. + */ for (i = 0; i != TailStart; ++i) { /* Make a getelementptr instruction that addresses the field */ OffsetInst = create_gep3(target, llvm_constant_long_0, @@ -3911,41 +3914,49 @@ append_inst(Fn, create_store_inst(Elements[i], Offset, isVolatile)); } - /* If there is tail padding to emit, add the loop now. */ + /* If there is tail padding to emit, add the loop or memset call now. */ if (TailStart != Size) { llvm_value *Val = Elements[i]; - llvm_basicblock *FromBlock = - llvm_ilist_back(llvm_basicblock, Fn->BasicBlocks); - llvm_basicblock *Loop = llvm_basicblock_new("initializeloop"); - llvm_basicblock *After = llvm_basicblock_new("continue"); - llvm_instruction *PHI; - llvm_value *SetNE; - - /* Output the branch to the loop block, and the loop block itself. */ - append_inst(Fn, create_uncond_branch(Loop)); - llvm_emit_label(Fn, Loop); - - /* Create the PHI node now */ - PHI = llvm_instruction_new(LongTy, "idx", O_PHINode, 4); - PHI->Operands[0] = llvm_constant_new_integral(LongTy, TailStart); - PHI->Operands[1] = D2V(FromBlock); - PHI->Operands[3] = D2V(Loop); - append_inst(Fn, PHI); - - /* Make a getelementptr & store to the fields */ - OffsetInst = create_gep3(target, llvm_constant_long_0, D2V(PHI)); - Offset = append_inst(Fn, OffsetInst); /* Add it to the program */ - append_inst(Fn, create_store_inst(Val, Offset, isVolatile)); - - /* Add one to the counter, add it to the PHI operand */ - PHI->Operands[2] = - append_inst(Fn, create_binary_inst("tmp", O_Add, D2V(PHI), - llvm_constant_new_integral(LongTy, 1))); - /* Add a setne instruction to test for loop termination */ - SetNE = append_inst(Fn, create_binary_inst("hasmore", O_SetNE, D2V(PHI), + if (llvm_type_get_size(Val->Ty) == 1) { + llvm_value *DestPtr = + append_inst(Fn, create_gep3(target, llvm_constant_long_0, + llvm_constant_new_integral(LongTy, TailStart))); + EmitMemset(Fn, DestPtr, Val, + llvm_constant_new_integral(LongTy, Size-TailStart), 1); + } else { + llvm_basicblock *FromBlock = + llvm_ilist_back(llvm_basicblock, Fn->BasicBlocks); + llvm_basicblock *Loop = llvm_basicblock_new("initializeloop"); + llvm_basicblock *After = llvm_basicblock_new("continue"); + llvm_instruction *PHI; + llvm_value *SetNE; + + /* Output the branch to the loop block, and the loop block itself. */ + append_inst(Fn, create_uncond_branch(Loop)); + llvm_emit_label(Fn, Loop); + + /* Create the PHI node now */ + PHI = llvm_instruction_new(LongTy, "idx", O_PHINode, 4); + PHI->Operands[0] = llvm_constant_new_integral(LongTy, TailStart); + PHI->Operands[1] = D2V(FromBlock); + PHI->Operands[3] = D2V(Loop); + append_inst(Fn, PHI); + + /* Make a getelementptr & store to the fields */ + OffsetInst = create_gep3(target, llvm_constant_long_0, D2V(PHI)); + Offset = append_inst(Fn, OffsetInst); /* Add it to the program */ + append_inst(Fn, create_store_inst(Val, Offset, isVolatile)); + + /* Add one to the counter, add it to the PHI operand */ + PHI->Operands[2] = + append_inst(Fn, create_binary_inst("tmp", O_Add, D2V(PHI), + llvm_constant_new_integral(LongTy, 1))); + /* Add a setne instruction to test for loop termination */ + SetNE = append_inst(Fn, create_binary_inst("hasmore",O_SetNE,D2V(PHI), llvm_constant_new_integral(LongTy, Size-1))); - append_inst(Fn, create_cond_branch(SetNE, Loop, After)); - llvm_emit_label(Fn, After); + append_inst(Fn, create_cond_branch(SetNE, Loop, After)); + llvm_emit_label(Fn, After); + } } } } From lattner at cs.uiuc.edu Fri Feb 13 22:46:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 22:46:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86InstrInfo.td Message-ID: <200402140445.WAA10456@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86InstrInfo.td updated: 1.20 -> 1.21 --- Log message: add 'rep stos[bwd]' instructions --- Diffs of the changes: (+7 -0) Index: llvm/lib/Target/X86/X86InstrInfo.td diff -u llvm/lib/Target/X86/X86InstrInfo.td:1.20 llvm/lib/Target/X86/X86InstrInfo.td:1.21 --- llvm/lib/Target/X86/X86InstrInfo.td:1.20 Thu Feb 12 11:53:22 2004 +++ llvm/lib/Target/X86/X86InstrInfo.td Fri Feb 13 22:45:37 2004 @@ -181,6 +181,13 @@ def REP_MOVSD : X86Inst<"rep movsd", 0xA5, RawFrm, NoArg>, REP, Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>; +def REP_STOSB : X86Inst<"rep stosb", 0xAA, RawFrm, NoArg>, REP, + Imp<[ECX,EDI], [ECX,EDI]>; +def REP_STOSW : X86Inst<"rep stosw", 0xAB, RawFrm, NoArg>, REP, OpSize, + Imp<[ECX,EDI], [ECX,EDI]>; +def REP_STOSD : X86Inst<"rep stosd", 0xAB, RawFrm, NoArg>, REP, + Imp<[ECX,EDI], [ECX,EDI]>; + //===----------------------------------------------------------------------===// // Move Instructions... // From lattner at cs.uiuc.edu Fri Feb 13 22:47:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 22:47:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/InstSelectSimple.cpp Message-ID: <200402140446.WAA10547@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: InstSelectSimple.cpp updated: 1.157 -> 1.158 --- Log message: Codegen llvm.memset into rep stos[bwd]. Simplify code for llvm.memcpy --- Diffs of the changes: (+66 -12) Index: llvm/lib/Target/X86/InstSelectSimple.cpp diff -u llvm/lib/Target/X86/InstSelectSimple.cpp:1.157 llvm/lib/Target/X86/InstSelectSimple.cpp:1.158 --- llvm/lib/Target/X86/InstSelectSimple.cpp:1.157 Fri Feb 13 17:36:47 2004 +++ llvm/lib/Target/X86/InstSelectSimple.cpp Fri Feb 13 22:46:05 2004 @@ -1158,6 +1158,7 @@ case Intrinsic::va_copy: case Intrinsic::va_end: case Intrinsic::memcpy: + case Intrinsic::memset: // We directly implement these intrinsics break; default: @@ -1200,7 +1201,7 @@ // Turn the byte code into # iterations unsigned ByteReg; unsigned CountReg; - + unsigned Opcode; switch (Align & 3) { case 2: // WORD aligned if (ConstantInt *I = dyn_cast(CI.getOperand(3))) { @@ -1209,6 +1210,7 @@ CountReg = makeAnotherReg(Type::IntTy); BuildMI(BB, X86::SHRir32, 2, CountReg).addReg(ByteReg).addZImm(1); } + Opcode = X86::REP_MOVSW; break; case 0: // DWORD aligned if (ConstantInt *I = dyn_cast(CI.getOperand(3))) { @@ -1217,10 +1219,12 @@ CountReg = makeAnotherReg(Type::IntTy); BuildMI(BB, X86::SHRir32, 2, CountReg).addReg(ByteReg).addZImm(2); } + Opcode = X86::REP_MOVSD; break; case 1: // BYTE aligned case 3: // BYTE aligned CountReg = getReg(CI.getOperand(3)); + Opcode = X86::REP_MOVSB; break; } @@ -1231,20 +1235,70 @@ BuildMI(BB, X86::MOVrr32, 1, X86::ECX).addReg(CountReg); BuildMI(BB, X86::MOVrr32, 1, X86::EDI).addReg(TmpReg1); BuildMI(BB, X86::MOVrr32, 1, X86::ESI).addReg(TmpReg2); + BuildMI(BB, Opcode, 0); + return; + } + case Intrinsic::memset: { + assert(CI.getNumOperands() == 5 && "Illegal llvm.memset call!"); + unsigned Align = 1; + if (ConstantInt *AlignC = dyn_cast(CI.getOperand(4))) { + Align = AlignC->getRawValue(); + if (Align == 0) Align = 1; + } - switch (Align & 3) { - case 1: // BYTE aligned - case 3: // BYTE aligned - BuildMI(BB, X86::REP_MOVSB, 0); - break; - case 2: // WORD aligned - BuildMI(BB, X86::REP_MOVSW, 0); - break; - case 0: // DWORD aligned - BuildMI(BB, X86::REP_MOVSD, 0); - break; + // Turn the byte code into # iterations + unsigned ByteReg; + unsigned CountReg; + unsigned Opcode; + if (ConstantInt *ValC = dyn_cast(CI.getOperand(2))) { + unsigned Val = ValC->getRawValue() & 255; + + // If the value is a constant, then we can potentially use larger copies. + switch (Align & 3) { + case 2: // WORD aligned + if (ConstantInt *I = dyn_cast(CI.getOperand(3))) { + CountReg = getReg(ConstantUInt::get(Type::UIntTy, I->getRawValue()/2)); + } else { + CountReg = makeAnotherReg(Type::IntTy); + BuildMI(BB, X86::SHRir32, 2, CountReg).addReg(ByteReg).addZImm(1); + } + BuildMI(BB, X86::MOVir16, 1, X86::AX).addZImm((Val << 8) | Val); + Opcode = X86::REP_STOSW; + break; + case 0: // DWORD aligned + if (ConstantInt *I = dyn_cast(CI.getOperand(3))) { + CountReg = getReg(ConstantUInt::get(Type::UIntTy, I->getRawValue()/4)); + } else { + CountReg = makeAnotherReg(Type::IntTy); + BuildMI(BB, X86::SHRir32, 2, CountReg).addReg(ByteReg).addZImm(2); + } + Val = (Val << 8) | Val; + BuildMI(BB, X86::MOVir32, 1, X86::EAX).addZImm((Val << 16) | Val); + Opcode = X86::REP_STOSD; + break; + case 1: // BYTE aligned + case 3: // BYTE aligned + CountReg = getReg(CI.getOperand(3)); + BuildMI(BB, X86::MOVir8, 1, X86::AL).addZImm(Val); + Opcode = X86::REP_STOSB; + break; + } + } else { + // If it's not a constant value we are storing, just fall back. We could + // try to be clever to form 16 bit and 32 bit values, but we don't yet. + unsigned ValReg = getReg(CI.getOperand(2)); + BuildMI(BB, X86::MOVrr8, 1, X86::AL).addReg(ValReg); + CountReg = getReg(CI.getOperand(3)); + Opcode = X86::REP_STOSB; } + // No matter what the alignment is, we put the source in ESI, the + // destination in EDI, and the count in ECX. + TmpReg1 = getReg(CI.getOperand(1)); + //TmpReg2 = getReg(CI.getOperand(2)); + BuildMI(BB, X86::MOVrr32, 1, X86::ECX).addReg(CountReg); + BuildMI(BB, X86::MOVrr32, 1, X86::EDI).addReg(TmpReg1); + BuildMI(BB, Opcode, 0); return; } From lattner at cs.uiuc.edu Fri Feb 13 22:48:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 22:48:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86InstrInfo.td Message-ID: <200402140447.WAA10770@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86InstrInfo.td updated: 1.21 -> 1.22 --- Log message: Urg, right. These need an input value... --- Diffs of the changes: (+3 -3) Index: llvm/lib/Target/X86/X86InstrInfo.td diff -u llvm/lib/Target/X86/X86InstrInfo.td:1.21 llvm/lib/Target/X86/X86InstrInfo.td:1.22 --- llvm/lib/Target/X86/X86InstrInfo.td:1.21 Fri Feb 13 22:45:37 2004 +++ llvm/lib/Target/X86/X86InstrInfo.td Fri Feb 13 22:47:23 2004 @@ -182,11 +182,11 @@ Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>; def REP_STOSB : X86Inst<"rep stosb", 0xAA, RawFrm, NoArg>, REP, - Imp<[ECX,EDI], [ECX,EDI]>; + Imp<[AL,ECX,EDI], [ECX,EDI]>; def REP_STOSW : X86Inst<"rep stosw", 0xAB, RawFrm, NoArg>, REP, OpSize, - Imp<[ECX,EDI], [ECX,EDI]>; + Imp<[AX,ECX,EDI], [ECX,EDI]>; def REP_STOSD : X86Inst<"rep stosd", 0xAB, RawFrm, NoArg>, REP, - Imp<[ECX,EDI], [ECX,EDI]>; + Imp<[EAX,ECX,EDI], [ECX,EDI]>; //===----------------------------------------------------------------------===// // Move Instructions... From lattner at cs.uiuc.edu Fri Feb 13 22:53:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Feb 13 22:53:01 2004 Subject: [llvm-commits] CVS: llvm/lib/VMCore/IntrinsicLowering.cpp Message-ID: <200402140452.WAA14666@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: IntrinsicLowering.cpp updated: 1.8 -> 1.9 --- Log message: A target that doesn't support these intrinsics will still meet spec (the intrinsic will always produce zero), but it will behave unexpectedly, so warn like GCC does. --- Diffs of the changes: (+3 -0) Index: llvm/lib/VMCore/IntrinsicLowering.cpp diff -u llvm/lib/VMCore/IntrinsicLowering.cpp:1.8 llvm/lib/VMCore/IntrinsicLowering.cpp:1.9 --- llvm/lib/VMCore/IntrinsicLowering.cpp:1.8 Fri Feb 13 20:47:17 2004 +++ llvm/lib/VMCore/IntrinsicLowering.cpp Fri Feb 13 22:52:06 2004 @@ -51,6 +51,9 @@ case Intrinsic::returnaddress: case Intrinsic::frameaddress: + std::cerr << "WARNING: this target does not support the llvm." + << (Callee->getIntrinsicID() == Intrinsic::returnaddress ? + "return" : "frame") << "address intrinsic.\n"; CI->replaceAllUsesWith(ConstantPointerNull::get( cast(CI->getType()))); break; From lattner at cs.uiuc.edu Sat Feb 14 00:01:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Feb 14 00:01:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/InstSelectSimple.cpp Printer.cpp X86RegisterInfo.cpp Message-ID: <200402140600.AAA03506@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: InstSelectSimple.cpp updated: 1.158 -> 1.159 Printer.cpp updated: 1.80 -> 1.81 X86RegisterInfo.cpp updated: 1.44 -> 1.45 --- Log message: finegrainify namespacification, fix 80col prob --- Diffs of the changes: (+5 -14) Index: llvm/lib/Target/X86/InstSelectSimple.cpp diff -u llvm/lib/Target/X86/InstSelectSimple.cpp:1.158 llvm/lib/Target/X86/InstSelectSimple.cpp:1.159 --- llvm/lib/Target/X86/InstSelectSimple.cpp:1.158 Fri Feb 13 22:46:05 2004 +++ llvm/lib/Target/X86/InstSelectSimple.cpp Sat Feb 14 00:00:36 2004 @@ -1257,7 +1257,7 @@ switch (Align & 3) { case 2: // WORD aligned if (ConstantInt *I = dyn_cast(CI.getOperand(3))) { - CountReg = getReg(ConstantUInt::get(Type::UIntTy, I->getRawValue()/2)); + CountReg =getReg(ConstantUInt::get(Type::UIntTy, I->getRawValue()/2)); } else { CountReg = makeAnotherReg(Type::IntTy); BuildMI(BB, X86::SHRir32, 2, CountReg).addReg(ByteReg).addZImm(1); @@ -1267,7 +1267,7 @@ break; case 0: // DWORD aligned if (ConstantInt *I = dyn_cast(CI.getOperand(3))) { - CountReg = getReg(ConstantUInt::get(Type::UIntTy, I->getRawValue()/4)); + CountReg =getReg(ConstantUInt::get(Type::UIntTy, I->getRawValue()/4)); } else { CountReg = makeAnotherReg(Type::IntTy); BuildMI(BB, X86::SHRir32, 2, CountReg).addReg(ByteReg).addZImm(2); Index: llvm/lib/Target/X86/Printer.cpp diff -u llvm/lib/Target/X86/Printer.cpp:1.80 llvm/lib/Target/X86/Printer.cpp:1.81 --- llvm/lib/Target/X86/Printer.cpp:1.80 Wed Feb 11 20:27:09 2004 +++ llvm/lib/Target/X86/Printer.cpp Sat Feb 14 00:00:36 2004 @@ -28,8 +28,7 @@ #include "Support/Statistic.h" #include "Support/StringExtras.h" #include "Support/CommandLine.h" - -namespace llvm { +using namespace llvm; namespace { Statistic<> EmittedInsts("asm-printer", "Number of machine instrs printed"); @@ -91,7 +90,7 @@ /// using the given target machine description. This should work /// regardless of whether the function is in SSA form. /// -FunctionPass *createX86CodePrinterPass(std::ostream &o,TargetMachine &tm){ +FunctionPass *llvm::createX86CodePrinterPass(std::ostream &o,TargetMachine &tm){ return new Printer(o, tm); } @@ -946,5 +945,3 @@ delete Mang; return false; // success } - -} // End llvm namespace Index: llvm/lib/Target/X86/X86RegisterInfo.cpp diff -u llvm/lib/Target/X86/X86RegisterInfo.cpp:1.44 llvm/lib/Target/X86/X86RegisterInfo.cpp:1.45 --- llvm/lib/Target/X86/X86RegisterInfo.cpp:1.44 Fri Feb 13 19:18:32 2004 +++ llvm/lib/Target/X86/X86RegisterInfo.cpp Sat Feb 14 00:00:36 2004 @@ -26,7 +26,7 @@ #include "Support/CommandLine.h" #include "Support/STLExtras.h" -namespace llvm { +using namespace llvm; namespace { cl::opt @@ -253,12 +253,8 @@ return MBB.size() - oldSize; } -} // End llvm namespace - #include "X86GenRegisterInfo.inc" -namespace llvm { - const TargetRegisterClass* X86RegisterInfo::getRegClassForType(const Type* Ty) const { switch (Ty->getPrimitiveID()) { @@ -278,5 +274,3 @@ case Type::DoubleTyID: return &RFPInstance; } } - -} // End llvm namespace From w04oosq at cc.uab.es Sat Feb 14 05:32:01 2004 From: w04oosq at cc.uab.es (Ben Kay) Date: Sat Feb 14 05:32:01 2004 Subject: [llvm-commits] Complete guide outlining how to set up, maintain and track Google AdWords Campaigns Message-ID: <6f-ob-f-tv-$52g-v5@239o7c1.y9i1> An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20040214/393bb943/attachment.html From a21vlz at msn.com Sat Feb 14 12:57:01 2004 From: a21vlz at msn.com (Tricia Ritter) Date: Sat Feb 14 12:57:01 2004 Subject: [llvm-commits] weight |oss (ID:2w9) Message-ID: An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20040214/a1796437/attachment.html From lattner at cs.uiuc.edu Sat Feb 14 13:28:00 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Feb 14 13:28:00 2004 Subject: [llvm-commits] CVS: llvm/docs/LangRef.html Message-ID: <200402141927.NAA12810@zion.cs.uiuc.edu> Changes in directory llvm/docs: LangRef.html updated: 1.47 -> 1.48 --- Log message: fix typeo --- Diffs of the changes: (+2 -2) Index: llvm/docs/LangRef.html diff -u llvm/docs/LangRef.html:1.47 llvm/docs/LangRef.html:1.48 --- llvm/docs/LangRef.html:1.47 Fri Feb 13 22:08:35 2004 +++ llvm/docs/LangRef.html Sat Feb 14 13:27:26 2004 @@ -752,7 +752,7 @@ Instruction
    Syntax:
    -
      switch uint <value>, label <defaultdest> [ int <val>, label &dest>, ... ]
    +
      switch uint <value>, label <defaultdest> [ int <val>, label <dest>, ... ]
    Overview:

    The 'switch' instruction is used to transfer control flow to one of several different places. It is a generalization of the 'br' @@ -2032,6 +2032,6 @@

    +Last modified: $Date: 2004/02/14 19:27:26 $
    From lattner at cs.uiuc.edu Sat Feb 14 13:50:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Feb 14 13:50:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PowerPCRegisterInfo.cpp PowerPCRegisterInfo.h Message-ID: <200402141949.NAA01836@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PowerPCRegisterInfo.cpp updated: 1.3 -> 1.4 PowerPCRegisterInfo.h updated: 1.3 -> 1.4 --- Log message: The prologue/epilogue related method calls have no reason to return a value, make them return void. --- Diffs of the changes: (+20 -30) Index: llvm/lib/Target/PowerPC/PowerPCRegisterInfo.cpp diff -u llvm/lib/Target/PowerPC/PowerPCRegisterInfo.cpp:1.3 llvm/lib/Target/PowerPC/PowerPCRegisterInfo.cpp:1.4 --- llvm/lib/Target/PowerPC/PowerPCRegisterInfo.cpp:1.3 Thu Feb 12 02:11:04 2004 +++ llvm/lib/Target/PowerPC/PowerPCRegisterInfo.cpp Sat Feb 14 13:49:25 2004 @@ -14,8 +14,7 @@ #include "PowerPC.h" #include "PowerPCRegisterInfo.h" #include "llvm/Type.h" - -namespace llvm { +using namespace llvm; PowerPCRegisterInfo::PowerPCRegisterInfo() : PowerPCGenRegisterInfo(PowerPC::ADJCALLSTACKDOWN, @@ -49,43 +48,35 @@ return -1; } -int PowerPCRegisterInfo::eliminateCallFramePseudoInstr(MachineFunction &MF, - MachineBasicBlock &MBB, - MachineBasicBlock::iterator I) const { +void PowerPCRegisterInfo:: +eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, + MachineBasicBlock::iterator I) const { abort(); - return -1; } -int PowerPCRegisterInfo::eliminateFrameIndex(MachineFunction &MF, - MachineBasicBlock::iterator II) const { +void +PowerPCRegisterInfo::eliminateFrameIndex(MachineFunction &MF, + MachineBasicBlock::iterator II) const { abort(); - return -1; } -int PowerPCRegisterInfo::processFunctionBeforeFrameFinalized( - MachineFunction &MF) const -{ +void PowerPCRegisterInfo::processFunctionBeforeFrameFinalized( + MachineFunction &MF) const { abort(); - return -1; } -int PowerPCRegisterInfo::emitPrologue(MachineFunction &MF) const { +void PowerPCRegisterInfo::emitPrologue(MachineFunction &MF) const { abort(); - return -1; } -int PowerPCRegisterInfo::emitEpilogue(MachineFunction &MF, - MachineBasicBlock &MBB) const { +void PowerPCRegisterInfo::emitEpilogue(MachineFunction &MF, + MachineBasicBlock &MBB) const { abort(); - return -1; } -} // end namespace llvm #include "PowerPCGenRegisterInfo.inc" -namespace llvm { - const TargetRegisterClass* PowerPCRegisterInfo::getRegClassForType(const Type* Ty) const { switch (Ty->getPrimitiveID()) { @@ -106,4 +97,3 @@ } } -} // end namespace llvm Index: llvm/lib/Target/PowerPC/PowerPCRegisterInfo.h diff -u llvm/lib/Target/PowerPC/PowerPCRegisterInfo.h:1.3 llvm/lib/Target/PowerPC/PowerPCRegisterInfo.h:1.4 --- llvm/lib/Target/PowerPC/PowerPCRegisterInfo.h:1.3 Thu Feb 12 02:11:04 2004 +++ llvm/lib/Target/PowerPC/PowerPCRegisterInfo.h Sat Feb 14 13:49:25 2004 @@ -40,17 +40,17 @@ unsigned DestReg, unsigned SrcReg, const TargetRegisterClass *RC) const; - int eliminateCallFramePseudoInstr(MachineFunction &MF, - MachineBasicBlock &MBB, - MachineBasicBlock::iterator I) const; + void eliminateCallFramePseudoInstr(MachineFunction &MF, + MachineBasicBlock &MBB, + MachineBasicBlock::iterator I) const; - int eliminateFrameIndex(MachineFunction &MF, - MachineBasicBlock::iterator II) const; + void eliminateFrameIndex(MachineFunction &MF, + MachineBasicBlock::iterator II) const; - int processFunctionBeforeFrameFinalized(MachineFunction &MF) const; + void processFunctionBeforeFrameFinalized(MachineFunction &MF) const; - int emitPrologue(MachineFunction &MF) const; - int emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const; + void emitPrologue(MachineFunction &MF) const; + void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const; }; } // end namespace llvm From lattner at cs.uiuc.edu Sat Feb 14 13:50:12 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Feb 14 13:50:12 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Target/MRegisterInfo.h Message-ID: <200402141949.NAA01824@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Target: MRegisterInfo.h updated: 1.30 -> 1.31 --- Log message: The prologue/epilogue related method calls have no reason to return a value, make them return void. --- Diffs of the changes: (+10 -11) Index: llvm/include/llvm/Target/MRegisterInfo.h diff -u llvm/include/llvm/Target/MRegisterInfo.h:1.30 llvm/include/llvm/Target/MRegisterInfo.h:1.31 --- llvm/include/llvm/Target/MRegisterInfo.h:1.30 Thu Feb 12 02:11:04 2004 +++ llvm/include/llvm/Target/MRegisterInfo.h Sat Feb 14 13:49:05 2004 @@ -260,14 +260,14 @@ /// setup/destroy pseudo instructions. The return value is the number of /// instructions added to (negative if removed from) the basic block. /// - virtual int eliminateCallFramePseudoInstr(MachineFunction &MF, - MachineBasicBlock &MBB, - MachineBasicBlock::iterator MI) const { + virtual void + eliminateCallFramePseudoInstr(MachineFunction &MF, + MachineBasicBlock &MBB, + MachineBasicBlock::iterator MI) const { assert(getCallFrameSetupOpcode()== -1 && getCallFrameDestroyOpcode()== -1 && "eliminateCallFramePseudoInstr must be implemented if using" " call frame setup/destroy pseudo instructions!"); assert(0 && "Call Frame Pseudo Instructions do not exist on this target!"); - return -1; } /// processFunctionBeforeFrameFinalized - This method is called immediately @@ -277,8 +277,7 @@ /// is the number of instructions added to (negative if removed from) the /// basic block /// - virtual int processFunctionBeforeFrameFinalized(MachineFunction &MF) const { - return 0; + virtual void processFunctionBeforeFrameFinalized(MachineFunction &MF) const { } /// eliminateFrameIndex - This method must be overriden to eliminate abstract @@ -289,16 +288,16 @@ /// finished product. The return value is the number of instructions /// added to (negative if removed from) the basic block. /// - virtual int eliminateFrameIndex(MachineFunction &MF, - MachineBasicBlock::iterator MI) const = 0; + virtual void eliminateFrameIndex(MachineFunction &MF, + MachineBasicBlock::iterator MI) const = 0; /// emitProlog/emitEpilog - These methods insert prolog and epilog code into /// the function. The return value is the number of instructions /// added to (negative if removed from) the basic block (entry for prologue). /// - virtual int emitPrologue(MachineFunction &MF) const = 0; - virtual int emitEpilogue(MachineFunction &MF, - MachineBasicBlock &MBB) const = 0; + virtual void emitPrologue(MachineFunction &MF) const = 0; + virtual void emitEpilogue(MachineFunction &MF, + MachineBasicBlock &MBB) const = 0; }; } // End llvm namespace From lattner at cs.uiuc.edu Sat Feb 14 13:51:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Feb 14 13:51:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86RegisterInfo.cpp X86RegisterInfo.h Message-ID: <200402141950.NAA02092@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86RegisterInfo.cpp updated: 1.45 -> 1.46 X86RegisterInfo.h updated: 1.20 -> 1.21 --- Log message: The prologue/epilogue related method calls have no reason to return a value, make them return void. This allows us to avoid some costly MBB.size() calls --- Diffs of the changes: (+23 -33) Index: llvm/lib/Target/X86/X86RegisterInfo.cpp diff -u llvm/lib/Target/X86/X86RegisterInfo.cpp:1.45 llvm/lib/Target/X86/X86RegisterInfo.cpp:1.46 --- llvm/lib/Target/X86/X86RegisterInfo.cpp:1.45 Sat Feb 14 00:00:36 2004 +++ llvm/lib/Target/X86/X86RegisterInfo.cpp Sat Feb 14 13:49:54 2004 @@ -25,7 +25,6 @@ #include "llvm/Target/TargetFrameInfo.h" #include "Support/CommandLine.h" #include "Support/STLExtras.h" - using namespace llvm; namespace { @@ -92,14 +91,14 @@ return NoFPElim || MF.getFrameInfo()->hasVarSizedObjects(); } -int X86RegisterInfo::eliminateCallFramePseudoInstr(MachineFunction &MF, - MachineBasicBlock &MBB, - MachineBasicBlock::iterator I) const { - MachineInstr *New = 0, *Old = I; +void X86RegisterInfo:: +eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, + MachineBasicBlock::iterator I) const { if (hasFP(MF)) { // If we have a frame pointer, turn the adjcallstackup instruction into a // 'sub ESP, ' and the adjcallstackdown instruction into 'add ESP, // ' + MachineInstr *Old = I; unsigned Amount = Old->getOperand(0).getImmedValue(); if (Amount != 0) { // We need to keep the stack aligned properly. To do this, we round the @@ -108,26 +107,23 @@ unsigned Align = MF.getTarget().getFrameInfo().getStackAlignment(); Amount = (Amount+Align-1)/Align*Align; + MachineInstr *New; if (Old->getOpcode() == X86::ADJCALLSTACKDOWN) { New=BuildMI(X86::SUBri32, 1, X86::ESP, MOTy::UseAndDef).addZImm(Amount); } else { assert(Old->getOpcode() == X86::ADJCALLSTACKUP); New=BuildMI(X86::ADDri32, 1, X86::ESP, MOTy::UseAndDef).addZImm(Amount); } + + // Replace the pseudo instruction with a new instruction... + MBB.insert(I, New); } } - if (New) { - // Replace the pseudo instruction with a new instruction... - MBB.insert(MBB.erase(I), New); - return 0; - } else { - MBB.erase(I); - return -1; - } + MBB.erase(I); } -int X86RegisterInfo::eliminateFrameIndex(MachineFunction &MF, +void X86RegisterInfo::eliminateFrameIndex(MachineFunction &MF, MachineBasicBlock::iterator II) const { unsigned i = 0; MachineInstr &MI = *II; @@ -150,27 +146,24 @@ Offset += MF.getFrameInfo()->getStackSize(); MI.SetMachineOperandConst(i+3, MachineOperand::MO_SignExtendedImmed, Offset); - return 0; } -int X86RegisterInfo::processFunctionBeforeFrameFinalized(MachineFunction &MF) - const { +void +X86RegisterInfo::processFunctionBeforeFrameFinalized(MachineFunction &MF) const{ if (hasFP(MF)) { // Create a frame entry for the EBP register that must be saved. int FrameIdx = MF.getFrameInfo()->CreateStackObject(4, 4); assert(FrameIdx == MF.getFrameInfo()->getObjectIndexEnd()-1 && "Slot for EBP register must be last in order to be found!"); } - return 0; } -int X86RegisterInfo::emitPrologue(MachineFunction &MF) const { +void X86RegisterInfo::emitPrologue(MachineFunction &MF) const { MachineBasicBlock &MBB = MF.front(); // Prolog goes in entry BB MachineBasicBlock::iterator MBBI = MBB.begin(); MachineFrameInfo *MFI = MF.getFrameInfo(); MachineInstr *MI; - unsigned oldSize = MBB.size(); // Get the number of bytes to allocate from the FrameInfo unsigned NumBytes = MFI->getStackSize(); if (hasFP(MF)) { @@ -217,12 +210,10 @@ MBB.insert(MBBI, MI); } } - return MBB.size() - oldSize; } -int X86RegisterInfo::emitEpilogue(MachineFunction &MF, - MachineBasicBlock &MBB) const { - unsigned oldSize = MBB.size(); +void X86RegisterInfo::emitEpilogue(MachineFunction &MF, + MachineBasicBlock &MBB) const { const MachineFrameInfo *MFI = MF.getFrameInfo(); MachineBasicBlock::iterator MBBI = prior(MBB.end()); MachineInstr *MI; @@ -250,7 +241,6 @@ MBB.insert(MBBI, MI); } } - return MBB.size() - oldSize; } #include "X86GenRegisterInfo.inc" Index: llvm/lib/Target/X86/X86RegisterInfo.h diff -u llvm/lib/Target/X86/X86RegisterInfo.h:1.20 llvm/lib/Target/X86/X86RegisterInfo.h:1.21 --- llvm/lib/Target/X86/X86RegisterInfo.h:1.20 Thu Feb 12 02:10:44 2004 +++ llvm/lib/Target/X86/X86RegisterInfo.h Sat Feb 14 13:49:54 2004 @@ -42,17 +42,17 @@ unsigned DestReg, unsigned SrcReg, const TargetRegisterClass *RC) const; - int eliminateCallFramePseudoInstr(MachineFunction &MF, - MachineBasicBlock &MBB, - MachineBasicBlock::iterator MI) const; + void eliminateCallFramePseudoInstr(MachineFunction &MF, + MachineBasicBlock &MBB, + MachineBasicBlock::iterator MI) const; - int eliminateFrameIndex(MachineFunction &MF, - MachineBasicBlock::iterator MI) const; + void eliminateFrameIndex(MachineFunction &MF, + MachineBasicBlock::iterator MI) const; - int processFunctionBeforeFrameFinalized(MachineFunction &MF) const; + void processFunctionBeforeFrameFinalized(MachineFunction &MF) const; - int emitPrologue(MachineFunction &MF) const; - int emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const; + void emitPrologue(MachineFunction &MF) const; + void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const; }; } // End llvm namespace From lattner at cs.uiuc.edu Sat Feb 14 14:12:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Feb 14 14:12:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86RegisterInfo.cpp Message-ID: <200402142011.OAA12120@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86RegisterInfo.cpp updated: 1.46 -> 1.47 --- Log message: There is no reason to align the stack pointer if there are no callees of this function! --- Diffs of the changes: (+12 -10) Index: llvm/lib/Target/X86/X86RegisterInfo.cpp diff -u llvm/lib/Target/X86/X86RegisterInfo.cpp:1.46 llvm/lib/Target/X86/X86RegisterInfo.cpp:1.47 --- llvm/lib/Target/X86/X86RegisterInfo.cpp:1.46 Sat Feb 14 13:49:54 2004 +++ llvm/lib/Target/X86/X86RegisterInfo.cpp Sat Feb 14 14:11:07 2004 @@ -190,16 +190,18 @@ MBB.insert(MBBI, MI); } else { - // When we have no frame pointer, we reserve argument space for call sites - // in the function immediately on entry to the current function. This - // eliminates the need for add/sub ESP brackets around call sites. - // - NumBytes += MFI->getMaxCallFrameSize(); - - // Round the size to a multiple of the alignment (don't forget the 4 byte - // offset though). - unsigned Align = MF.getTarget().getFrameInfo().getStackAlignment(); - NumBytes = ((NumBytes+4)+Align-1)/Align*Align - 4; + if (MFI->hasCalls()) { + // When we have no frame pointer, we reserve argument space for call sites + // in the function immediately on entry to the current function. This + // eliminates the need for add/sub ESP brackets around call sites. + // + NumBytes += MFI->getMaxCallFrameSize(); + + // Round the size to a multiple of the alignment (don't forget the 4 byte + // offset though). + unsigned Align = MF.getTarget().getFrameInfo().getStackAlignment(); + NumBytes = ((NumBytes+4)+Align-1)/Align*Align - 4; + } // Update frame info to pretend that this is part of the stack... MFI->setStackSize(NumBytes); From lattner at cs.uiuc.edu Sat Feb 14 14:12:16 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Feb 14 14:12:16 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/PrologEpilogInserter.cpp Message-ID: <200402142011.OAA12094@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: PrologEpilogInserter.cpp updated: 1.19 -> 1.20 --- Log message: There is no reason to align the stack pointer if there are no callees of this function! --- Diffs of the changes: (+5 -2) Index: llvm/lib/CodeGen/PrologEpilogInserter.cpp diff -u llvm/lib/CodeGen/PrologEpilogInserter.cpp:1.19 llvm/lib/CodeGen/PrologEpilogInserter.cpp:1.20 --- llvm/lib/CodeGen/PrologEpilogInserter.cpp:1.19 Wed Feb 11 20:27:10 2004 +++ llvm/lib/CodeGen/PrologEpilogInserter.cpp Sat Feb 14 14:10:59 2004 @@ -216,8 +216,11 @@ FFI->setObjectOffset(i, -Offset); // Set the computed offset } - // Align the final stack pointer offset... - Offset = (Offset+StackAlignment-1)/StackAlignment*StackAlignment; + // Align the final stack pointer offset, but only if there are calls in the + // function. This ensures that any calls to subroutines have their stack + // frames suitable aligned. + if (FFI->hasCalls()) + Offset = (Offset+StackAlignment-1)/StackAlignment*StackAlignment; // Set the final value of the stack pointer... FFI->setStackSize(Offset-TFI.getOffsetOfLocalArea()); From lattner at cs.uiuc.edu Sat Feb 14 15:07:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Feb 14 15:07:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86InstrInfo.td Message-ID: <200402142106.PAA24637@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86InstrInfo.td updated: 1.22 -> 1.23 --- Log message: Add support for the 'pop' instruction --- Diffs of the changes: (+2 -1) Index: llvm/lib/Target/X86/X86InstrInfo.td diff -u llvm/lib/Target/X86/X86InstrInfo.td:1.22 llvm/lib/Target/X86/X86InstrInfo.td:1.23 --- llvm/lib/Target/X86/X86InstrInfo.td:1.22 Fri Feb 13 22:47:23 2004 +++ llvm/lib/Target/X86/X86InstrInfo.td Sat Feb 14 15:06:02 2004 @@ -161,7 +161,8 @@ //===----------------------------------------------------------------------===// // Miscellaneous Instructions... // -def LEAVE : X86Inst<"leave", 0xC9, RawFrm, NoArg>, Imp<[EBP], [EBP]>; +def LEAVE : X86Inst<"leave", 0xC9, RawFrm, NoArg>, Imp<[EBP,ESP],[EBP,ESP]>; +def POPr32 : X86Inst<"pop", 0x58, AddRegFrm, Arg32>, Imp<[ESP],[ESP]>; let isTwoAddress = 1 in // R32 = bswap R32 def BSWAPr32 : X86Inst<"bswap", 0xC8, AddRegFrm, Arg32>, TB; From gaeke at cs.uiuc.edu Sat Feb 14 16:20:02 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Sat Feb 14 16:20:02 2004 Subject: [llvm-commits] CVS: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp Message-ID: <200402142219.QAA19559@seraph.cs.uiuc.edu> Changes in directory reopt/lib/LightWtProfiling: UnpackTraceFunction.cpp updated: 1.37 -> 1.38 --- Log message: Perform ilistification for Sparc backend-specific stuff in UnpackTraceFunction. --- Diffs of the changes: (+3 -5) Index: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp diff -u reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.37 reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.38 --- reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.37 Fri Jan 30 15:54:10 2004 +++ reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp Sat Feb 14 16:19:25 2004 @@ -116,9 +116,9 @@ const MachineInstr *SparcReoptInfo::containsReturnInstr (MachineBasicBlock &B) { for (MachineBasicBlock::const_reverse_iterator i = B.rbegin (), e = B.rend (); i != e; ++i) { - const MachineInstr *MI = *i; - if (MI->getOpcode () == V9::JMPLRETi) - return MI; + const MachineInstr &MI = *i; + if (MI.getOpcode () == V9::JMPLRETi) + return &*i; } return 0; } @@ -349,9 +349,7 @@ // Erase the contents of MBB. while (!MBB.empty ()) { MachineBasicBlock::iterator MBBI = MBB.begin (); - MachineInstr *MI = *MBBI; MBB.erase (MBBI); - delete MI; } // Insert copies from each live-out variable's reg. in the trace // to its reg. in the matrix function. From alkis at cs.uiuc.edu Sat Feb 14 17:34:01 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat Feb 14 17:34:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Support/LeakDetector.cpp Message-ID: <200402142333.RAA04599@zion.cs.uiuc.edu> Changes in directory llvm/lib/Support: LeakDetector.cpp updated: 1.6 -> 1.7 --- Log message: Modularize implementation of LeakDetector into a typed template implementation class. This makes the code simpler and allows for more types to be added easily. It also implements caching for generic objects (it was only available for llvm objects). --- Diffs of the changes: (+76 -59) Index: llvm/lib/Support/LeakDetector.cpp diff -u llvm/lib/Support/LeakDetector.cpp:1.6 llvm/lib/Support/LeakDetector.cpp:1.7 --- llvm/lib/Support/LeakDetector.cpp:1.6 Sun Dec 14 15:35:53 2003 +++ llvm/lib/Support/LeakDetector.cpp Sat Feb 14 17:33:39 2004 @@ -16,75 +16,92 @@ #include using namespace llvm; -// Lazily allocate set so that release build doesn't have to do anything. -static std::set *Objects = 0; -static std::set *LLVMObjects = 0; - -// Because the most common usage pattern, by far, is to add a garbage object, -// then remove it immediately, we optimize this case. When an object is added, -// it is not added to the set immediately, it is added to the CachedValue Value. -// If it is immediately removed, no set search need be performed. -// -static const Value *CachedValue; +namespace { -void LeakDetector::addGarbageObjectImpl(void *Object) { - if (Objects == 0) - Objects = new std::set(); - assert(Objects->count(Object) == 0 && "Object already in set!"); - Objects->insert(Object); + template + struct LeakDetectorImpl { + LeakDetectorImpl(const char* const name) : Cache(0), Name(name) { } + + // Because the most common usage pattern, by far, is to add a + // garbage object, then remove it immediately, we optimize this + // case. When an object is added, it is not added to the set + // immediately, it is added to the CachedValue Value. If it is + // immediately removed, no set search need be performed. + void addGarbage(const T* o) { + if (Cache) { + assert(Ts.count(Cache) == 0 && "Object already in set!"); + Ts.insert(Cache); + } + Cache = o; + } + + void removeGarbage(const T* o) { + if (o == Cache) + Cache = 0; // Cache hit + else + Ts.erase(o); + } + + bool hasGarbage(const std::string& Message) { + addGarbage(0); // Flush the Cache + + assert(Cache == 0 && "No value should be cached anymore!"); + + if (!Ts.empty()) { + std::cerr + << "Leaked " << Name << " objects found: " << Message << ":\n\t"; + std::copy(Ts.begin(), Ts.end(), + std::ostream_iterator(std::cerr, " ")); + std::cerr << '\n'; + + // Clear out results so we don't get duplicate warnings on + // next call... + Ts.clear(); + return true; + } + return false; + } + + private: + std::set Ts; + const T* Cache; + const char* const Name; + }; + + typedef LeakDetectorImpl Objects; + typedef LeakDetectorImpl LLVMObjects; + + Objects& getObjects() { + static Objects o("GENERIC"); + return o; + } + + LLVMObjects& getLLVMObjects() { + static LLVMObjects o("LLVM"); + return o; + } } -void LeakDetector::removeGarbageObjectImpl(void *Object) { - if (Objects) - Objects->erase(Object); +void LeakDetector::addGarbageObjectImpl(void *Object) { + getObjects().addGarbage(Object); } void LeakDetector::addGarbageObjectImpl(const Value *Object) { - if (CachedValue) { - if (LLVMObjects == 0) - LLVMObjects = new std::set(); - assert(LLVMObjects->count(CachedValue) == 0 && "Object already in set!"); - LLVMObjects->insert(CachedValue); - } - CachedValue = Object; + getLLVMObjects().addGarbage(Object); +} + +void LeakDetector::removeGarbageObjectImpl(void *Object) { + getObjects().removeGarbage(Object); } void LeakDetector::removeGarbageObjectImpl(const Value *Object) { - if (Object == CachedValue) - CachedValue = 0; // Cache hit! - else if (LLVMObjects) - LLVMObjects->erase(Object); + getLLVMObjects().removeGarbage(Object); } void LeakDetector::checkForGarbageImpl(const std::string &Message) { - if (CachedValue) // Flush the cache to the set... - addGarbageObjectImpl((Value*)0); - - assert(CachedValue == 0 && "No value should be cached anymore!"); - - if ((Objects && !Objects->empty()) || (LLVMObjects && !LLVMObjects->empty())){ - std::cerr << "Leaked objects found: " << Message << "\n"; - - if (Objects && !Objects->empty()) { - std::cerr << " Non-Value objects leaked:"; - for (std::set::iterator I = Objects->begin(), - E = Objects->end(); I != E; ++I) - std::cerr << " " << *I; - } - - if (LLVMObjects && !LLVMObjects->empty()) { - std::cerr << " LLVM Value subclasses leaked:"; - for (std::set::iterator I = LLVMObjects->begin(), - E = LLVMObjects->end(); I != E; ++I) - std::cerr << **I << "\n"; - } - - std::cerr << "This is probably because you removed an LLVM value " - << "(Instruction, BasicBlock, \netc), but didn't delete it. " - << "Please check your code for memory leaks.\n"; - - // Clear out results so we don't get duplicate warnings on next call... - delete Objects; delete LLVMObjects; - Objects = 0; LLVMObjects = 0; - } + // use non-short-circuit version so that both checks are performed + if (getObjects().hasGarbage(Message) | + getLLVMObjects().hasGarbage(Message)) + std::cerr << "\nThis is probably because you removed an object, but didn't " + "delete it. Please check your code for memory leaks.\n"; } From alkis at cs.uiuc.edu Sat Feb 14 18:04:02 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat Feb 14 18:04:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PowerPCTargetMachine.cpp Message-ID: <200402150003.SAA07784@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PowerPCTargetMachine.cpp updated: 1.5 -> 1.6 --- Log message: Add back machine code deleter pass until we get a MachineCode pass that will be responsible for the creation of MachineFunctions and will be required by all MachineFunctionPass passes. --- Diffs of the changes: (+1 -0) Index: llvm/lib/Target/PowerPC/PowerPCTargetMachine.cpp diff -u llvm/lib/Target/PowerPC/PowerPCTargetMachine.cpp:1.5 llvm/lib/Target/PowerPC/PowerPCTargetMachine.cpp:1.6 --- llvm/lib/Target/PowerPC/PowerPCTargetMachine.cpp:1.5 Wed Feb 11 20:27:10 2004 +++ llvm/lib/Target/PowerPC/PowerPCTargetMachine.cpp Sat Feb 14 18:03:15 2004 @@ -45,6 +45,7 @@ PM.add(createRegisterAllocator()); PM.add(createPrologEpilogCodeInserter()); // + PM.add(createMachineCodeDeleter()); return true; // change to `return false' when this actually works. } From alkis at cs.uiuc.edu Sat Feb 14 18:04:15 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat Feb 14 18:04:15 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/MachineFunction.cpp Message-ID: <200402150003.SAA07790@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: MachineFunction.cpp updated: 1.50 -> 1.51 --- Log message: Add back machine code deleter pass until we get a MachineCode pass that will be responsible for the creation of MachineFunctions and will be required by all MachineFunctionPass passes. --- Diffs of the changes: (+21 -0) Index: llvm/lib/CodeGen/MachineFunction.cpp diff -u llvm/lib/CodeGen/MachineFunction.cpp:1.50 llvm/lib/CodeGen/MachineFunction.cpp:1.51 --- llvm/lib/CodeGen/MachineFunction.cpp:1.50 Thu Feb 12 22:39:55 2004 +++ llvm/lib/CodeGen/MachineFunction.cpp Sat Feb 14 18:03:15 2004 @@ -62,6 +62,27 @@ return new Printer(OS, Banner); } +namespace { + struct Deleter : public MachineFunctionPass { + const char *getPassName() const { return "Machine Code Deleter"; } + + bool runOnMachineFunction(MachineFunction &MF) { + // Delete the annotation from the function now. + MachineFunction::destruct(MF.getFunction()); + return true; + } + }; +} + +/// MachineCodeDeletion Pass - This pass deletes all of the machine code for +/// the current function, which should happen after the function has been +/// emitted to a .s file or to memory. +FunctionPass *llvm::createMachineCodeDeleter() { + return new Deleter(); +} + + + //===---------------------------------------------------------------------===// // MachineFunction implementation //===---------------------------------------------------------------------===// From alkis at cs.uiuc.edu Sat Feb 14 18:04:28 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat Feb 14 18:04:28 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86TargetMachine.cpp X86CodeEmitter.cpp Message-ID: <200402150003.SAA07785@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86TargetMachine.cpp updated: 1.47 -> 1.48 X86CodeEmitter.cpp updated: 1.49 -> 1.50 --- Log message: Add back machine code deleter pass until we get a MachineCode pass that will be responsible for the creation of MachineFunctions and will be required by all MachineFunctionPass passes. --- Diffs of the changes: (+5 -0) Index: llvm/lib/Target/X86/X86TargetMachine.cpp diff -u llvm/lib/Target/X86/X86TargetMachine.cpp:1.47 llvm/lib/Target/X86/X86TargetMachine.cpp:1.48 --- llvm/lib/Target/X86/X86TargetMachine.cpp:1.47 Wed Feb 11 20:27:09 2004 +++ llvm/lib/Target/X86/X86TargetMachine.cpp Sat Feb 14 18:03:15 2004 @@ -104,6 +104,9 @@ if (!DisableOutput) PM.add(createX86CodePrinterPass(Out, *this)); + // Delete machine code for this function + PM.add(createMachineCodeDeleter()); + return false; // success! } Index: llvm/lib/Target/X86/X86CodeEmitter.cpp diff -u llvm/lib/Target/X86/X86CodeEmitter.cpp:1.49 llvm/lib/Target/X86/X86CodeEmitter.cpp:1.50 --- llvm/lib/Target/X86/X86CodeEmitter.cpp:1.49 Thu Feb 12 11:53:22 2004 +++ llvm/lib/Target/X86/X86CodeEmitter.cpp Sat Feb 14 18:03:15 2004 @@ -212,6 +212,8 @@ bool X86TargetMachine::addPassesToEmitMachineCode(FunctionPassManager &PM, MachineCodeEmitter &MCE) { PM.add(new Emitter(MCE)); + // Delete machine code for this function + PM.add(createMachineCodeDeleter()); return false; } From lattner at cs.uiuc.edu Sat Feb 14 18:15:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Feb 14 18:15:02 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/PrologEpilogInserter.cpp Message-ID: <200402150014.SAA08586@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: PrologEpilogInserter.cpp updated: 1.20 -> 1.21 --- Log message: Allow for fixed objects to reside in the local area, and if they don't to not clobber them by allocating other objects in the same space! --- Diffs of the changes: (+13 -6) Index: llvm/lib/CodeGen/PrologEpilogInserter.cpp diff -u llvm/lib/CodeGen/PrologEpilogInserter.cpp:1.20 llvm/lib/CodeGen/PrologEpilogInserter.cpp:1.21 --- llvm/lib/CodeGen/PrologEpilogInserter.cpp:1.20 Sat Feb 14 14:10:59 2004 +++ llvm/lib/CodeGen/PrologEpilogInserter.cpp Sat Feb 14 18:14:20 2004 @@ -24,8 +24,7 @@ #include "llvm/Target/MRegisterInfo.h" #include "llvm/Target/TargetFrameInfo.h" #include "llvm/Target/TargetInstrInfo.h" - -namespace llvm { +using namespace llvm; namespace { struct PEI : public MachineFunctionPass { @@ -72,7 +71,7 @@ /// createPrologEpilogCodeInserter - This function returns a pass that inserts /// prolog and epilog code, and eliminates abstract frame references. /// -FunctionPass *createPrologEpilogCodeInserter() { return new PEI(); } +FunctionPass *llvm::createPrologEpilogCodeInserter() { return new PEI(); } /// saveCallerSavedRegisters - Scan the function for modified caller saved @@ -203,8 +202,18 @@ unsigned StackAlignment = TFI.getStackAlignment(); - // Start at the beginning of the local area... + // Start at the beginning of the local area. int Offset = TFI.getOffsetOfLocalArea(); + + // Check to see if there are any fixed sized objects that are preallocated in + // the local area. We currently don't support filling in holes in between + // fixed sized objects, so we just skip to the end of the last fixed sized + // preallocated object. + for (int i = FFI->getObjectIndexBegin(); i != 0; ++i) { + int FixedOff = -FFI->getObjectOffset(i); + if (FixedOff > Offset) Offset = FixedOff; + } + for (unsigned i = 0, e = FFI->getObjectIndexEnd(); i != e; ++i) { Offset += FFI->getObjectSize(i); // Allocate Size bytes... @@ -265,5 +274,3 @@ break; } } - -} // End llvm namespace From lattner at cs.uiuc.edu Sat Feb 14 18:16:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Feb 14 18:16:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86RegisterInfo.cpp Message-ID: <200402150015.SAA08614@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86RegisterInfo.cpp updated: 1.47 -> 1.48 --- Log message: Fix the 'have a framepointer' case, so that the frame pointer always points to the old saved EBP. --- Diffs of the changes: (+10 -8) Index: llvm/lib/Target/X86/X86RegisterInfo.cpp diff -u llvm/lib/Target/X86/X86RegisterInfo.cpp:1.47 llvm/lib/Target/X86/X86RegisterInfo.cpp:1.48 --- llvm/lib/Target/X86/X86RegisterInfo.cpp:1.47 Sat Feb 14 14:11:07 2004 +++ llvm/lib/Target/X86/X86RegisterInfo.cpp Sat Feb 14 18:15:37 2004 @@ -144,6 +144,8 @@ if (!hasFP(MF)) Offset += MF.getFrameInfo()->getStackSize(); + else + Offset += 4; // Skip the saved EBP MI.SetMachineOperandConst(i+3, MachineOperand::MO_SignExtendedImmed, Offset); } @@ -152,9 +154,9 @@ X86RegisterInfo::processFunctionBeforeFrameFinalized(MachineFunction &MF) const{ if (hasFP(MF)) { // Create a frame entry for the EBP register that must be saved. - int FrameIdx = MF.getFrameInfo()->CreateStackObject(4, 4); - assert(FrameIdx == MF.getFrameInfo()->getObjectIndexEnd()-1 && - "Slot for EBP register must be last in order to be found!"); + int FrameIdx = MF.getFrameInfo()->CreateFixedObject(4, -8); + assert(FrameIdx == MF.getFrameInfo()->getObjectIndexBegin() && + "Slot for EBP register must be last in order to be found!"); } } @@ -169,7 +171,7 @@ if (hasFP(MF)) { // Get the offset of the stack slot for the EBP register... which is // guaranteed to be the last slot by processFunctionBeforeFrameFinalized. - int EBPOffset = MFI->getObjectOffset(MFI->getObjectIndexEnd()-1)+4; + int EBPOffset = MFI->getObjectOffset(MFI->getObjectIndexBegin())+4; if (NumBytes) { // adjust stack pointer: ESP -= numbytes MI= BuildMI(X86::SUBri32, 1, X86::ESP, MOTy::UseAndDef).addZImm(NumBytes); @@ -182,10 +184,10 @@ MBB.insert(MBBI, MI); // Update EBP with the new base value... - if (NumBytes == 0) // mov EBP, ESP + if (NumBytes == 4) // mov EBP, ESP MI = BuildMI(X86::MOVrr32, 2, X86::EBP).addReg(X86::ESP); else // lea EBP, [ESP+StackSize] - MI = addRegOffset(BuildMI(X86::LEAr32, 5, X86::EBP), X86::ESP, NumBytes); + MI = addRegOffset(BuildMI(X86::LEAr32, 5, X86::EBP), X86::ESP,NumBytes-4); MBB.insert(MBBI, MI); @@ -231,8 +233,8 @@ MI = BuildMI(X86::MOVrr32, 1,X86::ESP).addReg(X86::EBP); MBB.insert(MBBI, MI); - // mov EBP, [ESP-] - MI = addRegOffset(BuildMI(X86::MOVmr32, 5, X86::EBP), X86::ESP, EBPOffset); + // pop EBP + MI = BuildMI(X86::POPr32, 0, X86::EBP); MBB.insert(MBBI, MI); } else { // Get the number of bytes allocated from the FrameInfo... From lattner at cs.uiuc.edu Sat Feb 14 18:22:04 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Feb 14 18:22:04 2004 Subject: [llvm-commits] CVS: llvm/test/Regression/CodeGen/X86/2004-02-14-InefficientStackPointer.llx Message-ID: <200402150021.SAA08828@zion.cs.uiuc.edu> Changes in directory llvm/test/Regression/CodeGen/X86: 2004-02-14-InefficientStackPointer.llx added (r1.1) --- Log message: New testcase for PR237: [x86] wierd stack/frame pointer manipulation --- Diffs of the changes: (+5 -0) Index: llvm/test/Regression/CodeGen/X86/2004-02-14-InefficientStackPointer.llx diff -c /dev/null llvm/test/Regression/CodeGen/X86/2004-02-14-InefficientStackPointer.llx:1.1 *** /dev/null Sat Feb 14 18:21:14 2004 --- llvm/test/Regression/CodeGen/X86/2004-02-14-InefficientStackPointer.llx Sat Feb 14 18:21:04 2004 *************** *** 0 **** --- 1,5 ---- + ; RUN: llvm-as < %s | llc -march=x86 | grep ESP | not grep sub + + int %test(int %X) { + ret int %X + } From lattner at cs.uiuc.edu Sat Feb 14 18:24:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Feb 14 18:24:01 2004 Subject: [llvm-commits] CVS: llvm/docs/ReleaseNotes.html Message-ID: <200402150023.SAA09284@zion.cs.uiuc.edu> Changes in directory llvm/docs: ReleaseNotes.html updated: 1.124 -> 1.125 --- Log message: New code quality fix --- Diffs of the changes: (+2 -1) Index: llvm/docs/ReleaseNotes.html diff -u llvm/docs/ReleaseNotes.html:1.124 llvm/docs/ReleaseNotes.html:1.125 --- llvm/docs/ReleaseNotes.html:1.124 Fri Feb 13 22:12:41 2004 +++ llvm/docs/ReleaseNotes.html Sat Feb 14 18:23:15 2004 @@ -147,6 +147,7 @@
  • [loopsimplify] Many pointless phi nodes are created
  • The X86 backend didn't generate fchs to negate floating point numbers
  • The X86 backend didn't expand memcpy() into the rep movs instruction
  • +
  • [x86] wierd stack/frame pointer manipulation
  • @@ -579,7 +580,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/02/14 04:12:41 $ + Last modified: $Date: 2004/02/15 00:23:15 $ From vpakos at altavista.com Sat Feb 14 18:34:01 2004 From: vpakos at altavista.com (Harrison Connelly) Date: Sat Feb 14 18:34:01 2004 Subject: [llvm-commits] 9 weight |oss Message-ID: <9661ll-70$-7r1@yawuh> An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20040214/76966905/attachment.html From alkis at cs.uiuc.edu Sat Feb 14 18:47:01 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat Feb 14 18:47:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/FloatingPoint.cpp Message-ID: <200402150046.SAA10792@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: FloatingPoint.cpp updated: 1.22 -> 1.23 --- Log message: Fix problem in DEBUG code. I could be pointing past the end and dereferencing it causes an assertion error. --- Diffs of the changes: (+14 -14) Index: llvm/lib/Target/X86/FloatingPoint.cpp diff -u llvm/lib/Target/X86/FloatingPoint.cpp:1.22 llvm/lib/Target/X86/FloatingPoint.cpp:1.23 --- llvm/lib/Target/X86/FloatingPoint.cpp:1.22 Fri Feb 13 19:18:32 2004 +++ llvm/lib/Target/X86/FloatingPoint.cpp Sat Feb 14 18:46:41 2004 @@ -245,20 +245,20 @@ } // Print out all of the instructions expanded to if -debug - DEBUG(if (&*I == PrevMI) { - std::cerr<< "Just deleted pseudo instruction\n"; - } else { - MachineBasicBlock::iterator Start = I; - // Rewind to first instruction newly inserted. - while (Start != BB.begin() && - --Start != MachineBasicBlock::iterator(PrevMI)); - ++Start; - std::cerr << "Inserted instructions:\n\t"; - Start->print(std::cerr, MF.getTarget()); - while (++Start != I); ++Start; - } - dumpStack(); - ); + DEBUG( + MachineBasicBlock::iterator PrevI(PrevMI); + if (I == PrevI) { + std::cerr<< "Just deleted pseudo instruction\n"; + } else { + MachineBasicBlock::iterator Start = I; + // Rewind to first instruction newly inserted. + while (Start != BB.begin() && prior(Start) != PrevI) --Start; + std::cerr << "Inserted instructions:\n\t"; + Start->print(std::cerr, MF.getTarget()); + while (++Start != next(I)); + } + dumpStack(); + ); Changed = true; } From lattner at cs.uiuc.edu Sat Feb 14 19:05:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Feb 14 19:05:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/InstSelectSimple.cpp Message-ID: <200402150104.TAA11841@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: InstSelectSimple.cpp updated: 1.159 -> 1.160 --- Log message: Implement llvm.(frame|return)address(0) correctly. They are used by the LLVM JIT, among other applications --- Diffs of the changes: (+25 -0) Index: llvm/lib/Target/X86/InstSelectSimple.cpp diff -u llvm/lib/Target/X86/InstSelectSimple.cpp:1.159 llvm/lib/Target/X86/InstSelectSimple.cpp:1.160 --- llvm/lib/Target/X86/InstSelectSimple.cpp:1.159 Sat Feb 14 00:00:36 2004 +++ llvm/lib/Target/X86/InstSelectSimple.cpp Sat Feb 14 19:04:03 2004 @@ -62,6 +62,7 @@ MachineFunction *F; // The function we are compiling into MachineBasicBlock *BB; // The current MBB we are compiling int VarArgsFrameIndex; // FrameIndex for start of varargs area + int ReturnAddressIndex; // FrameIndex for the return address std::map RegMap; // Mapping between Val's and SSA Regs @@ -86,6 +87,10 @@ BB = &F->front(); + // Set up a frame object for the return address. This is used by the + // llvm.returnaddress & llvm.frameaddress intrinisics. + ReturnAddressIndex = F->getFrameInfo()->CreateFixedObject(4, -4); + // Copy incoming arguments off of the stack... LoadArgumentsToVirtualRegs(Fn); @@ -1157,6 +1162,8 @@ case Intrinsic::va_start: case Intrinsic::va_copy: case Intrinsic::va_end: + case Intrinsic::returnaddress: + case Intrinsic::frameaddress: case Intrinsic::memcpy: case Intrinsic::memset: // We directly implement these intrinsics @@ -1189,6 +1196,24 @@ BuildMI(BB, X86::MOVrr32, 1, TmpReg1).addReg(TmpReg2); return; case Intrinsic::va_end: return; // Noop on X86 + + case Intrinsic::returnaddress: + case Intrinsic::frameaddress: + TmpReg1 = getReg(CI); + if (cast(CI.getOperand(1))->isNullValue()) { + if (ID == Intrinsic::returnaddress) { + // Just load the return address + addFrameReference(BuildMI(BB, X86::MOVmr32, 4, TmpReg1), + ReturnAddressIndex); + } else { + addFrameReference(BuildMI(BB, X86::LEAr32, 4, TmpReg1), + ReturnAddressIndex, -4); + } + } else { + // Values other than zero are not implemented yet. + BuildMI(BB, X86::MOVir32, 1, TmpReg1).addZImm(0); + } + return; case Intrinsic::memcpy: { assert(CI.getNumOperands() == 5 && "Illegal llvm.memcpy call!"); From lattner at cs.uiuc.edu Sat Feb 14 19:16:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Feb 14 19:16:01 2004 Subject: [llvm-commits] CVS: llvm-www/status/index.html Message-ID: <200402150115.TAA12342@zion.cs.uiuc.edu> Changes in directory llvm-www/status: index.html updated: 1.37 -> 1.38 --- Log message: bug fixed a long time ago --- Diffs of the changes: (+2 -2) Index: llvm-www/status/index.html diff -u llvm-www/status/index.html:1.37 llvm-www/status/index.html:1.38 --- llvm-www/status/index.html:1.37 Mon Dec 15 18:10:48 2003 +++ llvm-www/status/index.html Sat Feb 14 19:15:45 2004 @@ -156,7 +156,7 @@ ./build CC=llvm-gcc lrh lrh = Linux Red Hat, there are many such targets. - Compile fails: see bug 141 and + Compile fails: see bug 141 and bug 82 for details. @@ -454,7 +454,7 @@
    Misha Brukman
    The LLVM Compiler Infrastructure
    - Last modified: $Date: 2003/12/16 00:10:48 $ + Last modified: $Date: 2004/02/15 01:15:45 $ From lattner at cs.uiuc.edu Sat Feb 14 19:22:00 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Feb 14 19:22:00 2004 Subject: [llvm-commits] CVS: llvm/test/Regression/CodeGen/X86/2004-02-13-FrameReturnAddress.llx Message-ID: <200402150121.TAA12557@zion.cs.uiuc.edu> Changes in directory llvm/test/Regression/CodeGen/X86: 2004-02-13-FrameReturnAddress.llx updated: 1.1 -> 1.2 --- Log message: Test for actual support, not just for lack of crashage --- Diffs of the changes: (+1 -1) Index: llvm/test/Regression/CodeGen/X86/2004-02-13-FrameReturnAddress.llx diff -u llvm/test/Regression/CodeGen/X86/2004-02-13-FrameReturnAddress.llx:1.1 llvm/test/Regression/CodeGen/X86/2004-02-13-FrameReturnAddress.llx:1.2 --- llvm/test/Regression/CodeGen/X86/2004-02-13-FrameReturnAddress.llx:1.1 Fri Feb 13 20:51:40 2004 +++ llvm/test/Regression/CodeGen/X86/2004-02-13-FrameReturnAddress.llx Sat Feb 14 19:21:39 2004 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llc +; RUN: llvm-as < %s | llc -march=x86 | grep ESP | grep '\[' declare sbyte* %llvm.returnaddress(uint) declare sbyte* %llvm.frameaddress(uint) From lattner at cs.uiuc.edu Sat Feb 14 20:20:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Feb 14 20:20:01 2004 Subject: [llvm-commits] CVS: gcc-3.4/gcc/llvm-representation.c Message-ID: <200402150219.UAA13233@zion.cs.uiuc.edu> Changes in directory gcc-3.4/gcc: llvm-representation.c updated: 1.1 -> 1.2 --- Log message: Implement PR205: [llvmgcc] C front-end does not emit 'zeroinitializer' when possible --- Diffs of the changes: (+27 -0) Index: gcc-3.4/gcc/llvm-representation.c diff -u gcc-3.4/gcc/llvm-representation.c:1.1 gcc-3.4/gcc/llvm-representation.c:1.2 --- gcc-3.4/gcc/llvm-representation.c:1.1 Thu Jan 8 16:35:32 2004 +++ gcc-3.4/gcc/llvm-representation.c Sat Feb 14 20:19:44 2004 @@ -442,11 +442,38 @@ llvm_constant_aggregate_print(CA, stderr); } +static int isNullConstant(llvm_value *V) { + switch (V->VTy) { + case ConstantAggregate: { + llvm_constant_aggregate *CA = (llvm_constant_aggregate*)V; + unsigned i, e; + if (V->Ty->ID == StructTyID) { + e = V->Ty->NumElements; + } else { + assert(V->Ty->ID == ArrayTyID && "Invalid aggregate type!"); + e = V->Ty->x.Array.Size; + } + for (i = 0; i != e; ++i) + if (!isNullConstant(CA->Initializers[i])) return 0; + return 1; + } + default: return 0; + case Constant: + return !strcmp("0", V2C(V)->Repr); + } +} + void llvm_constant_aggregate_print(llvm_constant_aggregate *CE, FILE *F) { unsigned i; llvm_type *Ty = G2V(CE)->Ty; llvm_value **Elements = CE->Initializers; + + if (isNullConstant((llvm_value*)CE)) { + fprintf(F, "zeroinitializer"); + return; + } + if (Ty->ID == StructTyID) { fprintf(F, "{ "); for (i = 0; i != Ty->NumElements; ++i) { From lattner at cs.uiuc.edu Sat Feb 14 20:20:13 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Feb 14 20:20:13 2004 Subject: [llvm-commits] CVS: llvm/test/Regression/CFrontend/2004-02-14-ZeroInitializer.c.tr Message-ID: <200402150219.UAA13219@zion.cs.uiuc.edu> Changes in directory llvm/test/Regression/CFrontend: 2004-02-14-ZeroInitializer.c.tr added (r1.1) --- Log message: Testcase for PR205: [llvmgcc] C front-end does not emit 'zeroinitializer' when possible --- Diffs of the changes: (+4 -0) Index: llvm/test/Regression/CFrontend/2004-02-14-ZeroInitializer.c.tr diff -c /dev/null llvm/test/Regression/CFrontend/2004-02-14-ZeroInitializer.c.tr:1.1 *** /dev/null Sat Feb 14 20:19:18 2004 --- llvm/test/Regression/CFrontend/2004-02-14-ZeroInitializer.c.tr Sat Feb 14 20:19:08 2004 *************** *** 0 **** --- 1,4 ---- + // RUN: %llvmgcc -xc %s -S -o - | grep zeroinitializer + + int X[1000]; + From lattner at cs.uiuc.edu Sat Feb 14 20:27:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Feb 14 20:27:01 2004 Subject: [llvm-commits] CVS: gcc-3.4/gcc/llvm-representation.c Message-ID: <200402150226.UAA13406@zion.cs.uiuc.edu> Changes in directory gcc-3.4/gcc: llvm-representation.c updated: 1.2 -> 1.3 --- Log message: Oh yeah, 0.0 is a zero value too. :) This shrinks harness.ll from 336K -> 137K. --- Diffs of the changes: (+1 -1) Index: gcc-3.4/gcc/llvm-representation.c diff -u gcc-3.4/gcc/llvm-representation.c:1.2 gcc-3.4/gcc/llvm-representation.c:1.3 --- gcc-3.4/gcc/llvm-representation.c:1.2 Sat Feb 14 20:19:44 2004 +++ gcc-3.4/gcc/llvm-representation.c Sat Feb 14 20:26:46 2004 @@ -459,7 +459,7 @@ } default: return 0; case Constant: - return !strcmp("0", V2C(V)->Repr); + return !strcmp("0", V2C(V)->Repr) || !strcmp("0.0", V2C(V)->Repr); } } From lattner at cs.uiuc.edu Sat Feb 14 20:47:00 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Feb 14 20:47:00 2004 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp Message-ID: <200402150246.UAA31706@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Constants.cpp updated: 1.74 -> 1.75 --- Log message: Keep a cache of non-abstract null arrays and structs. This speeds up llvm-dis from 16.57 -> 13.46s on 129.compress. --- Diffs of the changes: (+19 -2) Index: llvm/lib/VMCore/Constants.cpp diff -u llvm/lib/VMCore/Constants.cpp:1.74 llvm/lib/VMCore/Constants.cpp:1.75 --- llvm/lib/VMCore/Constants.cpp:1.74 Sun Feb 8 22:37:31 2004 +++ llvm/lib/VMCore/Constants.cpp Sat Feb 14 20:46:46 2004 @@ -64,6 +64,8 @@ delete this; } +static std::map NullValues; + // Static constructor to create a '0' constant of arbitrary type... Constant *Constant::getNullValue(const Type *Ty) { switch (Ty->getPrimitiveID()) { @@ -117,18 +119,33 @@ return ConstantPointerNull::get(cast(Ty)); case Type::StructTyID: { + if (!Ty->isAbstract()) + if (Constant *V = NullValues[Ty]) + return V; + const StructType *ST = cast(Ty); std::vector Elements; Elements.resize(ST->getNumElements()); for (unsigned i = 0, e = ST->getNumElements(); i != e; ++i) Elements[i] = Constant::getNullValue(ST->getElementType(i)); - return ConstantStruct::get(ST, Elements); + Constant *Ret = ConstantStruct::get(ST, Elements); + if (!Ty->isAbstract()) + NullValues[Ty] = Ret; + return Ret; } case Type::ArrayTyID: { + if (!Ty->isAbstract()) + if (Constant *V = NullValues[Ty]) + return V; + const ArrayType *AT = cast(Ty); Constant *El = Constant::getNullValue(AT->getElementType()); unsigned NumElements = AT->getNumElements(); - return ConstantArray::get(AT, std::vector(NumElements, El)); + Constant *Ret = ConstantArray::get(AT, + std::vector(NumElements, El)); + if (!Ty->isAbstract()) + NullValues[Ty] = Ret; + return Ret; } default: // Function, Type, Label, or Opaque type? From lattner at cs.uiuc.edu Sat Feb 14 21:11:00 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Feb 14 21:11:00 2004 Subject: [llvm-commits] CVS: gcc-3.4/gcc/llvm-representation.c Message-ID: <200402150310.VAA24383@zion.cs.uiuc.edu> Changes in directory gcc-3.4/gcc: llvm-representation.c updated: 1.3 -> 1.4 --- Log message: Fix the C front-end version of PR239: LLVM needs a new ConstantAggregateZero class Instead of creating gigantic arrays of "zero" values, just use a string constant that contains "zeroinitializer". Also, increase what we consider to be null constants. --- Diffs of the changes: (+4 -14) Index: gcc-3.4/gcc/llvm-representation.c diff -u gcc-3.4/gcc/llvm-representation.c:1.3 gcc-3.4/gcc/llvm-representation.c:1.4 --- gcc-3.4/gcc/llvm-representation.c:1.3 Sat Feb 14 20:26:46 2004 +++ gcc-3.4/gcc/llvm-representation.c Sat Feb 14 21:10:29 2004 @@ -338,20 +338,9 @@ else if (llvm_type_is_fp(Ty)) return llvm_constant_new(Ty, "0.0"); /* new null fp value */ else if (Ty->ID == StructTyID) { - llvm_value **Vals = - (llvm_value**)xmalloc(sizeof(llvm_value*) * Ty->NumElements); - unsigned i; - for (i = 0; i != Ty->NumElements; ++i) - Vals[i] = llvm_constant_get_null(Ty->Elements[i]); - return G2V(llvm_constant_aggregate_new(Ty, Vals)); + return llvm_constant_new(Ty, "zeroinitializer"); } else if (Ty->ID == ArrayTyID) { - llvm_value **Vals = - (llvm_value**)xmalloc(sizeof(llvm_value*) * Ty->x.Array.Size); - unsigned i; - llvm_value *El = llvm_constant_get_null(Ty->Elements[0]); - for (i = 0; i != Ty->x.Array.Size; ++i) - Vals[i] = El; - return G2V(llvm_constant_aggregate_new(Ty, Vals)); + return llvm_constant_new(Ty, "zeroinitializer"); } else return llvm_constant_new(Ty, "0"); /* New zero integral or FP */ } @@ -459,7 +448,8 @@ } default: return 0; case Constant: - return !strcmp("0", V2C(V)->Repr) || !strcmp("0.0", V2C(V)->Repr); + return !strcmp("0", V2C(V)->Repr) || !strcmp("0.0", V2C(V)->Repr) || + !strcmp("null", V2C(V)->Repr) || !strcmp("zeroinitializer", V2C(V)->Repr); } } From lattner at cs.uiuc.edu Sat Feb 14 22:04:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Feb 14 22:04:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Instrumentation/EmitFunctions.cpp Message-ID: <200402150403.WAA25321@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Instrumentation: EmitFunctions.cpp updated: 1.14 -> 1.15 --- Log message: Remove dependence on the return type of ConstantArray::get --- Diffs of the changes: (+1 -1) Index: llvm/lib/Transforms/Instrumentation/EmitFunctions.cpp diff -u llvm/lib/Transforms/Instrumentation/EmitFunctions.cpp:1.14 llvm/lib/Transforms/Instrumentation/EmitFunctions.cpp:1.15 --- llvm/lib/Transforms/Instrumentation/EmitFunctions.cpp:1.14 Tue Nov 11 16:41:33 2003 +++ llvm/lib/Transforms/Instrumentation/EmitFunctions.cpp Sat Feb 14 22:02:59 2004 @@ -89,7 +89,7 @@ cstruct, "llvmFunctionTable"); M.getGlobalList().push_back(gb); - ConstantArray *constArray = ConstantArray::get(ArrayType::get(Type::SByteTy, + Constant *constArray = ConstantArray::get(ArrayType::get(Type::SByteTy, sBCons.size()), sBCons); From lattner at cs.uiuc.edu Sat Feb 14 22:06:00 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Feb 14 22:06:00 2004 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp Message-ID: <200402150405.WAA25352@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Constants.cpp updated: 1.75 -> 1.76 --- Log message: Remove dependence on the return type of ConstantArray::get --- Diffs of the changes: (+1 -1) Index: llvm/lib/VMCore/Constants.cpp diff -u llvm/lib/VMCore/Constants.cpp:1.75 llvm/lib/VMCore/Constants.cpp:1.76 --- llvm/lib/VMCore/Constants.cpp:1.75 Sat Feb 14 20:46:46 2004 +++ llvm/lib/VMCore/Constants.cpp Sat Feb 14 22:05:31 2004 @@ -434,7 +434,7 @@ Values.push_back(Val); } - ConstantArray *Replacement = ConstantArray::get(getType(), Values); + Constant *Replacement = ConstantArray::get(getType(), Values); assert(Replacement != this && "I didn't contain From!"); // Everyone using this now uses the replacement... From lattner at cs.uiuc.edu Sat Feb 14 22:07:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Feb 14 22:07:01 2004 Subject: [llvm-commits] CVS: llvm/projects/Stacker/lib/compiler/StackerCompiler.cpp Message-ID: <200402150406.WAA25697@zion.cs.uiuc.edu> Changes in directory llvm/projects/Stacker/lib/compiler: StackerCompiler.cpp updated: 1.3 -> 1.4 --- Log message: Remove dependence on the return type of ConstantArray::get --- Diffs of the changes: (+7 -7) Index: llvm/projects/Stacker/lib/compiler/StackerCompiler.cpp diff -u llvm/projects/Stacker/lib/compiler/StackerCompiler.cpp:1.3 llvm/projects/Stacker/lib/compiler/StackerCompiler.cpp:1.4 --- llvm/projects/Stacker/lib/compiler/StackerCompiler.cpp:1.3 Sun Nov 23 20:57:25 2003 +++ llvm/projects/Stacker/lib/compiler/StackerCompiler.cpp Sat Feb 14 22:05:58 2004 @@ -173,7 +173,7 @@ TheExit = new Function( exit_type, GlobalValue::ExternalLinkage, "exit", TheModule); - ConstantArray* str_format = ConstantArray::get("%s"); + Constant* str_format = ConstantArray::get("%s"); StrFormat = new GlobalVariable( /*type=*/ArrayType::get( Type::SByteTy, 3 ), /*isConstant=*/true, @@ -183,7 +183,7 @@ /*parent=*/TheModule ); - ConstantArray* in_str_format = ConstantArray::get(" %as"); + Constant* in_str_format = ConstantArray::get(" %as"); InStrFormat = new GlobalVariable( /*type=*/ArrayType::get( Type::SByteTy, 5 ), /*isConstant=*/true, @@ -193,7 +193,7 @@ /*parent=*/TheModule ); - ConstantArray* num_format = ConstantArray::get("%d"); + Constant* num_format = ConstantArray::get("%d"); NumFormat = new GlobalVariable( /*type=*/ArrayType::get( Type::SByteTy, 3 ), /*isConstant=*/true, @@ -203,7 +203,7 @@ /*parent=*/TheModule ); - ConstantArray* in_num_format = ConstantArray::get(" %d"); + Constant* in_num_format = ConstantArray::get(" %d"); InNumFormat = new GlobalVariable( /*type=*/ArrayType::get( Type::SByteTy, 4 ), /*isConstant=*/true, @@ -213,7 +213,7 @@ /*parent=*/TheModule ); - ConstantArray* chr_format = ConstantArray::get("%c"); + Constant* chr_format = ConstantArray::get("%c"); ChrFormat = new GlobalVariable( /*type=*/ArrayType::get( Type::SByteTy, 3 ), /*isConstant=*/true, @@ -223,7 +223,7 @@ /*parent=*/TheModule ); - ConstantArray* in_chr_format = ConstantArray::get(" %c"); + Constant* in_chr_format = ConstantArray::get(" %c"); InChrFormat = new GlobalVariable( /*type=*/ArrayType::get( Type::SByteTy, 4 ), /*isConstant=*/true, @@ -413,7 +413,7 @@ ArrayType* char_array = ArrayType::get( Type::SByteTy, len + 1 ); // Create an initializer for the value - ConstantArray* initVal = ConstantArray::get( value ); + Constant* initVal = ConstantArray::get( value ); // Create an internal linkage global variable to hold the constant. GlobalVariable* strconst = new GlobalVariable( From lattner at cs.uiuc.edu Sat Feb 14 22:08:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Feb 14 22:08:01 2004 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp Message-ID: <200402150407.WAA25900@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Constants.cpp updated: 1.76 -> 1.77 --- Log message: Remove dependence on return type of ConstantStruct::get --- Diffs of the changes: (+1 -1) Index: llvm/lib/VMCore/Constants.cpp diff -u llvm/lib/VMCore/Constants.cpp:1.76 llvm/lib/VMCore/Constants.cpp:1.77 --- llvm/lib/VMCore/Constants.cpp:1.76 Sat Feb 14 22:05:31 2004 +++ llvm/lib/VMCore/Constants.cpp Sat Feb 14 22:07:32 2004 @@ -459,7 +459,7 @@ Values.push_back(Val); } - ConstantStruct *Replacement = ConstantStruct::get(getType(), Values); + Constant *Replacement = ConstantStruct::get(getType(), Values); assert(Replacement != this && "I didn't contain From!"); // Everyone using this now uses the replacement... From lattner at cs.uiuc.edu Sat Feb 14 22:08:12 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Feb 14 22:08:12 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Instrumentation/EmitFunctions.cpp Message-ID: <200402150407.WAA25892@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Instrumentation: EmitFunctions.cpp updated: 1.15 -> 1.16 --- Log message: Remove dependence on return type of ConstantStruct::get --- Diffs of the changes: (+1 -1) Index: llvm/lib/Transforms/Instrumentation/EmitFunctions.cpp diff -u llvm/lib/Transforms/Instrumentation/EmitFunctions.cpp:1.15 llvm/lib/Transforms/Instrumentation/EmitFunctions.cpp:1.16 --- llvm/lib/Transforms/Instrumentation/EmitFunctions.cpp:1.15 Sat Feb 14 22:02:59 2004 +++ llvm/lib/Transforms/Instrumentation/EmitFunctions.cpp Sat Feb 14 22:07:26 2004 @@ -82,7 +82,7 @@ } StructType *sttype = StructType::get(vType); - ConstantStruct *cstruct = ConstantStruct::get(sttype, vConsts); + Constant *cstruct = ConstantStruct::get(sttype, vConsts); GlobalVariable *gb = new GlobalVariable(cstruct->getType(), true, GlobalValue::ExternalLinkage, From lattner at cs.uiuc.edu Sat Feb 14 22:15:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Feb 14 22:15:01 2004 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp Message-ID: <200402150414.WAA07084@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Constants.cpp updated: 1.77 -> 1.78 --- Log message: ConstantArray::get and ConstantStruct::get now just return pointers to 'Constant', instead of specific subclass pointers. In the future, these will return an instance of ConstantAggregateZero if all of the inputs are zeros. --- Diffs of the changes: (+4 -4) Index: llvm/lib/VMCore/Constants.cpp diff -u llvm/lib/VMCore/Constants.cpp:1.77 llvm/lib/VMCore/Constants.cpp:1.78 --- llvm/lib/VMCore/Constants.cpp:1.77 Sat Feb 14 22:07:32 2004 +++ llvm/lib/VMCore/Constants.cpp Sat Feb 14 22:14:47 2004 @@ -786,7 +786,7 @@ static ValueMap, ArrayType, ConstantArray> ArrayConstants; -ConstantArray *ConstantArray::get(const ArrayType *Ty, +Constant *ConstantArray::get(const ArrayType *Ty, const std::vector &V) { return ArrayConstants.getOrCreate(Ty, V); } @@ -802,7 +802,7 @@ // contain the specified string. A null terminator is added to the specified // string so that it may be used in a natural way... // -ConstantArray *ConstantArray::get(const std::string &Str) { +Constant *ConstantArray::get(const std::string &Str) { std::vector ElementVals; for (unsigned i = 0; i < Str.length(); ++i) @@ -866,8 +866,8 @@ static ValueMap, StructType, ConstantStruct> StructConstants; -ConstantStruct *ConstantStruct::get(const StructType *Ty, - const std::vector &V) { +Constant *ConstantStruct::get(const StructType *Ty, + const std::vector &V) { return StructConstants.getOrCreate(Ty, V); } From lattner at cs.uiuc.edu Sat Feb 14 22:15:13 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Feb 14 22:15:13 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Constants.h Message-ID: <200402150414.WAA07076@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: Constants.h updated: 1.41 -> 1.42 --- Log message: ConstantArray::get and ConstantStruct::get now just return pointers to 'Constant', instead of specific subclass pointers. In the future, these will return an instance of ConstantAggregateZero if all of the inputs are zeros. --- Diffs of the changes: (+3 -4) Index: llvm/include/llvm/Constants.h diff -u llvm/include/llvm/Constants.h:1.41 llvm/include/llvm/Constants.h:1.42 --- llvm/include/llvm/Constants.h:1.41 Mon Feb 2 12:53:04 2004 +++ llvm/include/llvm/Constants.h Sat Feb 14 22:14:40 2004 @@ -321,8 +321,8 @@ ConstantArray(const ArrayType *T, const std::vector &Val); public: /// get() - Static factory methods - Return objects of the specified value - static ConstantArray *get(const ArrayType *T, const std::vector &); - static ConstantArray *get(const std::string &Initializer); + static Constant *get(const ArrayType *T, const std::vector &); + static Constant *get(const std::string &Initializer); /// getType - Specialize the getType() method to always return an ArrayType, /// which reduces the amount of casting needed in parts of the compiler. @@ -383,8 +383,7 @@ ConstantStruct(const StructType *T, const std::vector &Val); public: /// get() - Static factory methods - Return objects of the specified value - static ConstantStruct *get(const StructType *T, - const std::vector &V); + static Constant *get(const StructType *T, const std::vector &V); /// getType() specialization - Reduce amount of casting... inline const StructType *getType() const { From lattner at cs.uiuc.edu Sat Feb 14 23:48:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Feb 14 23:48:01 2004 Subject: [llvm-commits] CVS: llvm/docs/ReleaseNotes.html Message-ID: <200402150547.XAA26573@zion.cs.uiuc.edu> Changes in directory llvm/docs: ReleaseNotes.html updated: 1.125 -> 1.126 --- Log message: Bug fixed --- Diffs of the changes: (+2 -1) Index: llvm/docs/ReleaseNotes.html diff -u llvm/docs/ReleaseNotes.html:1.125 llvm/docs/ReleaseNotes.html:1.126 --- llvm/docs/ReleaseNotes.html:1.125 Sat Feb 14 18:23:15 2004 +++ llvm/docs/ReleaseNotes.html Sat Feb 14 23:47:37 2004 @@ -117,6 +117,7 @@
  • Bytecode format inconsistent
  • [loadvn/inline/scalarrepl] Slow optimizations with extremely large basic blocks
  • [asmparser] Really slow parsing of types with complex upreferences
  • +
  • [llvmgcc] C front-end does not emit 'zeroinitializer' when possible
  • @@ -580,7 +581,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/02/15 00:23:15 $ + Last modified: $Date: 2004/02/15 05:47:37 $ From lattner at cs.uiuc.edu Sat Feb 14 23:53:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Feb 14 23:53:01 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/MachineFrameInfo.h Message-ID: <200402150552.XAA26631@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: MachineFrameInfo.h updated: 1.9 -> 1.10 --- Log message: finegrainify namespacification --- Diffs of the changes: (+2 -7) Index: llvm/include/llvm/CodeGen/MachineFrameInfo.h diff -u llvm/include/llvm/CodeGen/MachineFrameInfo.h:1.9 llvm/include/llvm/CodeGen/MachineFrameInfo.h:1.10 --- llvm/include/llvm/CodeGen/MachineFrameInfo.h:1.9 Tue Nov 11 16:41:31 2003 +++ llvm/include/llvm/CodeGen/MachineFrameInfo.h Sat Feb 14 23:52:36 2004 @@ -38,18 +38,13 @@ #ifndef LLVM_CODEGEN_MACHINEFRAMEINFO_H #define LLVM_CODEGEN_MACHINEFRAMEINFO_H -namespace llvm { +#include +namespace llvm { class TargetData; class TargetRegisterClass; class Type; class MachineFunction; - -} - -#include - -namespace llvm { class MachineFrameInfo { From lattner at cs.uiuc.edu Sat Feb 14 23:53:13 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Feb 14 23:53:13 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Constants.h Message-ID: <200402150552.XAA26618@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: Constants.h updated: 1.42 -> 1.43 --- Log message: Add a new ConstantAggregateZero class, to fix PR239. This makes zero initializers for constant structs and arrays take constant space, instead of space proportinal to the number of elements. This reduces the memory usage of the LLVM compiler by hundreds of megabytes when compiling some nasty SPEC95 benchmarks. --- Diffs of the changes: (+36 -20) Index: llvm/include/llvm/Constants.h diff -u llvm/include/llvm/Constants.h:1.42 llvm/include/llvm/Constants.h:1.43 --- llvm/include/llvm/Constants.h:1.42 Sat Feb 14 22:14:40 2004 +++ llvm/include/llvm/Constants.h Sat Feb 14 23:52:14 2004 @@ -309,6 +309,36 @@ } }; +//===--------------------------------------------------------------------------- +/// ConstantAggregateZero - All zero aggregate value +/// +class ConstantAggregateZero : public Constant { + friend struct ConstantCreator; + ConstantAggregateZero(const ConstantAggregateZero &); // DO NOT IMPLEMENT +protected: + ConstantAggregateZero(const Type *Ty) : Constant(Ty) {} +public: + /// get() - static factory method for creating a null aggregate. It is + /// illegal to call this method with a non-aggregate type. + static Constant *get(const Type *Ty); + + /// isNullValue - Return true if this is the value that would be returned by + /// getNullValue. + virtual bool isNullValue() const { return true; } + + virtual void destroyConstant(); + virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, + bool DisableChecking = false); + + /// Methods for support type inquiry through isa, cast, and dyn_cast: + /// + static inline bool classof(const ConstantAggregateZero *) { return true; } + static bool classof(const Constant *CPV); + static inline bool classof(const Value *V) { + return isa(V) && classof(cast(V)); + } +}; + //===--------------------------------------------------------------------------- /// ConstantArray - Constant Array Declarations @@ -345,19 +375,9 @@ inline const std::vector &getValues() const { return Operands; } /// isNullValue - Return true if this is the value that would be returned by - /// getNullValue. - virtual bool isNullValue() const { - // FIXME: This should be made to be MUCH faster. Just check against well - // known null value! - if (getNumOperands()) { - const Constant *First = cast(getOperand(0)); - if (!First->isNullValue()) return false; - for (unsigned i = 1, e = getNumOperands(); i != e; ++i) - if (cast(getOperand(i)) != First) - return false; - } - return true; - } + /// getNullValue. This always returns false because zero arrays are always + /// created as ConstantAggregateZero objects. + virtual bool isNullValue() const { return false; } virtual void destroyConstant(); virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, @@ -395,14 +415,10 @@ inline const std::vector &getValues() const { return Operands; } /// isNullValue - Return true if this is the value that would be returned by - /// getNullValue. + /// getNullValue. This always returns false because zero structs are always + /// created as ConstantAggregateZero objects. virtual bool isNullValue() const { - // FIXME: This should be made to be MUCH faster. Just check against well - // known null value! - for (unsigned i = 0, e = getNumOperands(); i != e; ++i) - if (!cast(getOperand(i))->isNullValue()) - return false; - return true; + return false; } virtual void destroyConstant(); From lattner at cs.uiuc.edu Sat Feb 14 23:54:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Feb 14 23:54:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/Local.cpp Message-ID: <200402150553.XAA26667@zion.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: Local.cpp updated: 1.81 -> 1.82 --- Log message: No need to scan zero initializers. This should make DSA a bit faster. --- Diffs of the changes: (+2 -0) Index: llvm/lib/Analysis/DataStructure/Local.cpp diff -u llvm/lib/Analysis/DataStructure/Local.cpp:1.81 llvm/lib/Analysis/DataStructure/Local.cpp:1.82 --- llvm/lib/Analysis/DataStructure/Local.cpp:1.81 Fri Feb 13 15:21:48 2004 +++ llvm/lib/Analysis/DataStructure/Local.cpp Sat Feb 14 23:53:42 2004 @@ -681,6 +681,8 @@ DSNodeHandle NewNH(NH.getNode(), NH.getOffset()+SL->MemberOffsets[i]); MergeConstantInitIntoNode(NewNH, cast(CS->getOperand(i))); } + } else if (ConstantAggregateZero *CAZ = dyn_cast(C)) { + // Noop } else { assert(0 && "Unknown constant type!"); } From lattner at cs.uiuc.edu Sat Feb 14 23:54:17 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Feb 14 23:54:17 2004 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp Message-ID: <200402150553.XAA26650@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Constants.cpp updated: 1.78 -> 1.79 --- Log message: Add a new ConstantAggregateZero class, to fix PR239. This makes zero initializers for constant structs and arrays take constant space, instead of space proportinal to the number of elements. This reduces the memory usage of the LLVM compiler by hundreds of megabytes when compiling some nasty SPEC95 benchmarks. --- Diffs of the changes: (+70 -36) Index: llvm/lib/VMCore/Constants.cpp diff -u llvm/lib/VMCore/Constants.cpp:1.78 llvm/lib/VMCore/Constants.cpp:1.79 --- llvm/lib/VMCore/Constants.cpp:1.78 Sat Feb 14 22:14:47 2004 +++ llvm/lib/VMCore/Constants.cpp Sat Feb 14 23:53:04 2004 @@ -64,8 +64,6 @@ delete this; } -static std::map NullValues; - // Static constructor to create a '0' constant of arbitrary type... Constant *Constant::getNullValue(const Type *Ty) { switch (Ty->getPrimitiveID()) { @@ -118,35 +116,9 @@ case Type::PointerTyID: return ConstantPointerNull::get(cast(Ty)); - case Type::StructTyID: { - if (!Ty->isAbstract()) - if (Constant *V = NullValues[Ty]) - return V; - - const StructType *ST = cast(Ty); - std::vector Elements; - Elements.resize(ST->getNumElements()); - for (unsigned i = 0, e = ST->getNumElements(); i != e; ++i) - Elements[i] = Constant::getNullValue(ST->getElementType(i)); - Constant *Ret = ConstantStruct::get(ST, Elements); - if (!Ty->isAbstract()) - NullValues[Ty] = Ret; - return Ret; - } - case Type::ArrayTyID: { - if (!Ty->isAbstract()) - if (Constant *V = NullValues[Ty]) - return V; - - const ArrayType *AT = cast(Ty); - Constant *El = Constant::getNullValue(AT->getElementType()); - unsigned NumElements = AT->getNumElements(); - Constant *Ret = ConstantArray::get(AT, - std::vector(NumElements, El)); - if (!Ty->isAbstract()) - NullValues[Ty] = Ret; - return Ret; - } + case Type::StructTyID: + case Type::ArrayTyID: + return ConstantAggregateZero::get(Ty); default: // Function, Type, Label, or Opaque type? assert(0 && "Cannot create a null constant of that type!"); @@ -347,11 +319,15 @@ return ((Ty == Type::FloatTy || Ty == Type::DoubleTy) && !isa(CPV)); } +bool ConstantAggregateZero::classof(const Constant *CPV) { + return (isa(CPV->getType()) || isa(CPV->getType())) && + CPV->isNullValue(); +} bool ConstantArray::classof(const Constant *CPV) { - return isa(CPV->getType()) && !isa(CPV); + return isa(CPV->getType()) && !CPV->isNullValue(); } bool ConstantStruct::classof(const Constant *CPV) { - return isa(CPV->getType()) && !isa(CPV); + return isa(CPV->getType()) && !CPV->isNullValue(); } bool ConstantPointerNull::classof(const Constant *CPV) { @@ -765,6 +741,50 @@ } } +//---- ConstantAggregateZero::get() implementation... +// +namespace llvm { + // ConstantAggregateZero does not take extra "value" argument... + template + struct ConstantCreator { + static ConstantAggregateZero *create(const Type *Ty, const ValType &V){ + return new ConstantAggregateZero(Ty); + } + }; + + template<> + struct ConvertConstantType { + static void convert(ConstantAggregateZero *OldC, const Type *NewTy) { + // Make everyone now use a constant of the new type... + Constant *New = ConstantAggregateZero::get(NewTy); + assert(New != OldC && "Didn't replace constant??"); + OldC->uncheckedReplaceAllUsesWith(New); + OldC->destroyConstant(); // This constant is now dead, destroy it. + } + }; +} + +static ValueMap AggZeroConstants; + +Constant *ConstantAggregateZero::get(const Type *Ty) { + return AggZeroConstants.getOrCreate(Ty, 0); +} + +// destroyConstant - Remove the constant from the constant table... +// +void ConstantAggregateZero::destroyConstant() { + AggZeroConstants.remove(this); + destroyConstantImpl(); +} + +void ConstantAggregateZero::replaceUsesOfWithOnConstant(Value *From, Value *To, + bool DisableChecking) { + assert(0 && "No uses!"); + abort(); +} + + + //---- ConstantArray::get() implementation... // namespace llvm { @@ -787,8 +807,17 @@ ConstantArray> ArrayConstants; Constant *ConstantArray::get(const ArrayType *Ty, - const std::vector &V) { - return ArrayConstants.getOrCreate(Ty, V); + const std::vector &V) { + // If this is an all-zero array, return a ConstantAggregateZero object + if (!V.empty()) { + Constant *C = V[0]; + if (!C->isNullValue()) + return ArrayConstants.getOrCreate(Ty, V); + for (unsigned i = 1, e = V.size(); i != e; ++i) + if (V[i] != C) + return ArrayConstants.getOrCreate(Ty, V); + } + return ConstantAggregateZero::get(Ty); } // destroyConstant - Remove the constant from the constant table... @@ -868,7 +897,12 @@ Constant *ConstantStruct::get(const StructType *Ty, const std::vector &V) { - return StructConstants.getOrCreate(Ty, V); + // Create a ConstantAggregateZero value if all elements are zeros... + for (unsigned i = 0, e = V.size(); i != e; ++i) + if (!V[i]->isNullValue()) + return StructConstants.getOrCreate(Ty, V); + + return ConstantAggregateZero::get(Ty); } // destroyConstant - Remove the constant from the constant table... From lattner at cs.uiuc.edu Sat Feb 14 23:55:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Feb 14 23:55:01 2004 Subject: [llvm-commits] CVS: llvm/lib/ExecutionEngine/ExecutionEngine.cpp Message-ID: <200402150554.XAA26680@zion.cs.uiuc.edu> Changes in directory llvm/lib/ExecutionEngine: ExecutionEngine.cpp updated: 1.47 -> 1.48 --- Log message: Make the JIT zero out globals with memset instead of an element at a time. This should speed it up a bit on a lot of programs --- Diffs of the changes: (+4 -0) Index: llvm/lib/ExecutionEngine/ExecutionEngine.cpp diff -u llvm/lib/ExecutionEngine/ExecutionEngine.cpp:1.47 llvm/lib/ExecutionEngine/ExecutionEngine.cpp:1.48 --- llvm/lib/ExecutionEngine/ExecutionEngine.cpp:1.47 Sun Feb 8 13:33:23 2004 +++ llvm/lib/ExecutionEngine/ExecutionEngine.cpp Sat Feb 14 23:54:06 2004 @@ -406,6 +406,10 @@ GenericValue Val = getConstantValue(Init); StoreValueToMemory(Val, (GenericValue*)Addr, Init->getType()); return; + } else if (isa(Init)) { + unsigned Size = getTargetData().getTypeSize(Init->getType()); + memset(Addr, 0, Size); + return; } switch (Init->getType()->getPrimitiveID()) { From lattner at cs.uiuc.edu Sat Feb 14 23:55:13 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Feb 14 23:55:13 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/CBackend/Writer.cpp Message-ID: <200402150554.XAA26691@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/CBackend: Writer.cpp updated: 1.160 -> 1.161 --- Log message: Add support for the new ConstantAggregateZero class --- Diffs of the changes: (+39 -11) Index: llvm/lib/Target/CBackend/Writer.cpp diff -u llvm/lib/Target/CBackend/Writer.cpp:1.160 llvm/lib/Target/CBackend/Writer.cpp:1.161 --- llvm/lib/Target/CBackend/Writer.cpp:1.160 Fri Feb 13 20:55:36 2004 +++ llvm/lib/Target/CBackend/Writer.cpp Sat Feb 14 23:54:27 2004 @@ -475,22 +475,50 @@ } case Type::ArrayTyID: - printConstantArray(cast(CPV)); + if (isa(CPV)) { + const ArrayType *AT = cast(CPV->getType()); + Out << "{"; + if (AT->getNumElements()) { + Out << " "; + Constant *CZ = Constant::getNullValue(AT->getElementType()); + printConstant(CZ); + for (unsigned i = 1, e = AT->getNumElements(); i != e; ++i) { + Out << ", "; + printConstant(CZ); + } + } + Out << " }"; + } else { + printConstantArray(cast(CPV)); + } break; - case Type::StructTyID: { - Out << "{"; - if (CPV->getNumOperands()) { - Out << " "; - printConstant(cast(CPV->getOperand(0))); - for (unsigned i = 1, e = CPV->getNumOperands(); i != e; ++i) { - Out << ", "; - printConstant(cast(CPV->getOperand(i))); + case Type::StructTyID: + if (isa(CPV)) { + const StructType *ST = cast(CPV->getType()); + Out << "{"; + if (ST->getNumElements()) { + Out << " "; + printConstant(Constant::getNullValue(ST->getElementType(0))); + for (unsigned i = 1, e = ST->getNumElements(); i != e; ++i) { + Out << ", "; + printConstant(Constant::getNullValue(ST->getElementType(i))); + } + } + Out << " }"; + } else { + Out << "{"; + if (CPV->getNumOperands()) { + Out << " "; + printConstant(cast(CPV->getOperand(0))); + for (unsigned i = 1, e = CPV->getNumOperands(); i != e; ++i) { + Out << ", "; + printConstant(cast(CPV->getOperand(i))); + } } + Out << " }"; } - Out << " }"; break; - } case Type::PointerTyID: if (isa(CPV)) { From lattner at cs.uiuc.edu Sat Feb 14 23:56:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Feb 14 23:56:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Utils/Linker.cpp ValueMapper.cpp Message-ID: <200402150555.XAA26741@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Utils: Linker.cpp updated: 1.66 -> 1.67 ValueMapper.cpp updated: 1.10 -> 1.11 --- Log message: Adjustments to support the new ConstantAggregateZero class --- Diffs of the changes: (+21 -8) Index: llvm/lib/Transforms/Utils/Linker.cpp diff -u llvm/lib/Transforms/Utils/Linker.cpp:1.66 llvm/lib/Transforms/Utils/Linker.cpp:1.67 --- llvm/lib/Transforms/Utils/Linker.cpp:1.66 Mon Jan 12 13:10:58 2004 +++ llvm/lib/Transforms/Utils/Linker.cpp Sat Feb 14 23:55:12 2004 @@ -284,7 +284,8 @@ // Check to see if it's a constant that we are interesting in transforming... if (const Constant *CPV = dyn_cast(In)) { - if (!isa(CPV->getType()) && !isa(CPV)) + if ((!isa(CPV->getType()) && !isa(CPV)) || + isa(CPV)) return const_cast(CPV); // Simple constants stay identical... Constant *Result = 0; @@ -796,12 +797,24 @@ // Merge the initializer... Inits.reserve(NewSize); - ConstantArray *I = cast(G1->getInitializer()); - for (unsigned i = 0, e = T1->getNumElements(); i != e; ++i) - Inits.push_back(cast(I->getValues()[i])); - I = cast(G2->getInitializer()); - for (unsigned i = 0, e = T2->getNumElements(); i != e; ++i) - Inits.push_back(cast(I->getValues()[i])); + if (ConstantArray *I = dyn_cast(G1->getInitializer())) { + for (unsigned i = 0, e = T1->getNumElements(); i != e; ++i) + Inits.push_back(cast(I->getValues()[i])); + } else { + assert(isa(G1->getInitializer())); + Constant *CV = Constant::getNullValue(T1->getElementType()); + for (unsigned i = 0, e = T1->getNumElements(); i != e; ++i) + Inits.push_back(CV); + } + if (ConstantArray *I = dyn_cast(G2->getInitializer())) { + for (unsigned i = 0, e = T2->getNumElements(); i != e; ++i) + Inits.push_back(cast(I->getValues()[i])); + } else { + assert(isa(G2->getInitializer())); + Constant *CV = Constant::getNullValue(T2->getElementType()); + for (unsigned i = 0, e = T2->getNumElements(); i != e; ++i) + Inits.push_back(CV); + } NG->setInitializer(ConstantArray::get(NewType, Inits)); Inits.clear(); Index: llvm/lib/Transforms/Utils/ValueMapper.cpp diff -u llvm/lib/Transforms/Utils/ValueMapper.cpp:1.10 llvm/lib/Transforms/Utils/ValueMapper.cpp:1.11 --- llvm/lib/Transforms/Utils/ValueMapper.cpp:1.10 Mon Jan 12 13:10:58 2004 +++ llvm/lib/Transforms/Utils/ValueMapper.cpp Sat Feb 14 23:55:13 2004 @@ -28,7 +28,7 @@ if (Constant *C = const_cast(dyn_cast(V))) { if (isa(C) || isa(C) || - isa(C)) + isa(C) || isa(C)) return VMSlot = C; // Primitive constants map directly else if (ConstantPointerRef *CPR = dyn_cast(C)) { GlobalValue *MV = cast(MapValue((Value*)CPR->getValue(),VM)); From lattner at cs.uiuc.edu Sat Feb 14 23:56:13 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Feb 14 23:56:13 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp SCCP.cpp Message-ID: <200402150555.XAA26732@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: InstructionCombining.cpp updated: 1.151 -> 1.152 SCCP.cpp updated: 1.88 -> 1.89 --- Log message: Adjustments to support the new ConstantAggregateZero class --- Diffs of the changes: (+9 -5) Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.151 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.152 --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.151 Sun Feb 8 15:43:50 2004 +++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Sat Feb 14 23:55:10 2004 @@ -2088,11 +2088,13 @@ // addressing... for (unsigned i = 2, e = CE->getNumOperands(); i != e; ++i) if (ConstantUInt *CU = dyn_cast(CE->getOperand(i))) { - ConstantStruct *CS = cast(C); + ConstantStruct *CS = dyn_cast(C); + if (CS == 0) return 0; if (CU->getValue() >= CS->getValues().size()) return 0; C = cast(CS->getValues()[CU->getValue()]); } else if (ConstantSInt *CS = dyn_cast(CE->getOperand(i))) { - ConstantArray *CA = cast(C); + ConstantArray *CA = dyn_cast(C); + if (CA == 0) return 0; if ((uint64_t)CS->getValue() >= CA->getValues().size()) return 0; C = cast(CA->getValues()[CS->getValue()]); } else Index: llvm/lib/Transforms/Scalar/SCCP.cpp diff -u llvm/lib/Transforms/Scalar/SCCP.cpp:1.88 llvm/lib/Transforms/Scalar/SCCP.cpp:1.89 --- llvm/lib/Transforms/Scalar/SCCP.cpp:1.88 Mon Jan 12 13:08:43 2004 +++ llvm/lib/Transforms/Scalar/SCCP.cpp Sat Feb 14 23:55:10 2004 @@ -689,14 +689,16 @@ // addressing... for (unsigned i = 2, e = CE->getNumOperands(); i != e; ++i) if (ConstantUInt *CU = dyn_cast(CE->getOperand(i))) { - ConstantStruct *CS = cast(C); + ConstantStruct *CS = dyn_cast(C); + if (CS == 0) return 0; if (CU->getValue() >= CS->getValues().size()) return 0; C = cast(CS->getValues()[CU->getValue()]); } else if (ConstantSInt *CS = dyn_cast(CE->getOperand(i))) { - ConstantArray *CA = cast(C); + ConstantArray *CA = dyn_cast(C); + if (CA == 0) return 0; if ((uint64_t)CS->getValue() >= CA->getValues().size()) return 0; C = cast(CA->getValues()[CS->getValue()]); - } else + } else return 0; return C; } From lattner at cs.uiuc.edu Sat Feb 14 23:56:24 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Feb 14 23:56:24 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/EmitAssembly.cpp Message-ID: <200402150555.XAA26723@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/Sparc: EmitAssembly.cpp updated: 1.106 -> 1.107 --- Log message: Adjustments to support the new ConstantAggregateZero class --- Diffs of the changes: (+3 -2) Index: llvm/lib/Target/Sparc/EmitAssembly.cpp diff -u llvm/lib/Target/Sparc/EmitAssembly.cpp:1.106 llvm/lib/Target/Sparc/EmitAssembly.cpp:1.107 --- llvm/lib/Target/Sparc/EmitAssembly.cpp:1.106 Fri Feb 13 15:01:20 2004 +++ llvm/lib/Target/Sparc/EmitAssembly.cpp Sat Feb 14 23:55:07 2004 @@ -387,8 +387,9 @@ } assert(sizeSoFar == cvsLayout->StructSize && "Layout of constant struct may be incorrect!"); - } - else + } else if (isa(CV)) { + PrintZeroBytesToPad(Target.getTargetData().getTypeSize(CV->getType())); + } else printSingleConstantValue(CV); if (numPadBytesAfter) From lattner at cs.uiuc.edu Sat Feb 14 23:56:36 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Feb 14 23:56:36 2004 Subject: [llvm-commits] CVS: llvm/lib/VMCore/AsmWriter.cpp SlotCalculator.cpp Message-ID: <200402150555.XAA26750@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: AsmWriter.cpp updated: 1.121 -> 1.122 SlotCalculator.cpp updated: 1.51 -> 1.52 --- Log message: Adjustments to support the new ConstantAggregateZero class --- Diffs of the changes: (+4 -11) Index: llvm/lib/VMCore/AsmWriter.cpp diff -u llvm/lib/VMCore/AsmWriter.cpp:1.121 llvm/lib/VMCore/AsmWriter.cpp:1.122 --- llvm/lib/VMCore/AsmWriter.cpp:1.121 Sun Feb 8 22:37:31 2004 +++ llvm/lib/VMCore/AsmWriter.cpp Sat Feb 14 23:55:15 2004 @@ -288,12 +288,9 @@ "assuming that double is 64 bits!"); Out << "0x" << utohexstr(*(uint64_t*)Ptr); + } else if (isa(CV)) { + Out << "zeroinitializer"; } else if (const ConstantArray *CA = dyn_cast(CV)) { - if (CA->getNumOperands() > 5 && CA->isNullValue()) { - Out << "zeroinitializer"; - return; - } - // As a special case, print the array as a string if it is an array of // ubytes or an array of sbytes with positive values. // @@ -339,11 +336,6 @@ Out << " ]"; } } else if (const ConstantStruct *CS = dyn_cast(CV)) { - if (CS->getNumOperands() > 5 && CS->isNullValue()) { - Out << "zeroinitializer"; - return; - } - Out << "{"; if (CS->getNumOperands()) { Out << " "; Index: llvm/lib/VMCore/SlotCalculator.cpp diff -u llvm/lib/VMCore/SlotCalculator.cpp:1.51 llvm/lib/VMCore/SlotCalculator.cpp:1.52 --- llvm/lib/VMCore/SlotCalculator.cpp:1.51 Sun Feb 8 18:15:41 2004 +++ llvm/lib/VMCore/SlotCalculator.cpp Sat Feb 14 23:55:15 2004 @@ -146,7 +146,8 @@ TypePlane &Plane = Table[plane]; unsigned FirstNonStringID = 0; for (unsigned i = 0, e = Plane.size(); i != e; ++i) - if (cast(Plane[i])->isString()) { + if (isa(Plane[i]) || + cast(Plane[i])->isString()) { // Check to see if we have to shuffle this string around. If not, // don't do anything. if (i != FirstNonStringID) { From lattner at cs.uiuc.edu Sun Feb 15 00:01:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun Feb 15 00:01:02 2004 Subject: [llvm-commits] CVS: llvm/docs/ReleaseNotes.html Message-ID: <200402150600.AAA27202@zion.cs.uiuc.edu> Changes in directory llvm/docs: ReleaseNotes.html updated: 1.126 -> 1.127 --- Log message: QOI bug fixed --- Diffs of the changes: (+2 -1) Index: llvm/docs/ReleaseNotes.html diff -u llvm/docs/ReleaseNotes.html:1.126 llvm/docs/ReleaseNotes.html:1.127 --- llvm/docs/ReleaseNotes.html:1.126 Sat Feb 14 23:47:37 2004 +++ llvm/docs/ReleaseNotes.html Sun Feb 15 00:00:04 2004 @@ -118,6 +118,7 @@
  • [loadvn/inline/scalarrepl] Slow optimizations with extremely large basic blocks
  • [asmparser] Really slow parsing of types with complex upreferences
  • [llvmgcc] C front-end does not emit 'zeroinitializer' when possible
  • +
  • LLVM is now much more memory efficient when handling large zero initialized arrays
  • @@ -581,7 +582,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/02/15 05:47:37 $ + Last modified: $Date: 2004/02/15 06:00:04 $ From alkis at cs.uiuc.edu Sun Feb 15 04:25:01 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sun Feb 15 04:25:01 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervals.cpp RegAllocLinearScan.cpp Message-ID: <200402151024.EAA26355@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveIntervals.cpp updated: 1.50 -> 1.51 RegAllocLinearScan.cpp updated: 1.47 -> 1.48 --- Log message: Eliminate the use of spill (reserved) registers. --- Diffs of the changes: (+317 -336) Index: llvm/lib/CodeGen/LiveIntervals.cpp diff -u llvm/lib/CodeGen/LiveIntervals.cpp:1.50 llvm/lib/CodeGen/LiveIntervals.cpp:1.51 --- llvm/lib/CodeGen/LiveIntervals.cpp:1.50 Fri Feb 13 18:44:07 2004 +++ llvm/lib/CodeGen/LiveIntervals.cpp Sun Feb 15 04:24:21 2004 @@ -30,6 +30,7 @@ #include "Support/CommandLine.h" #include "Support/Debug.h" #include "Support/Statistic.h" +#include "Support/STLExtras.h" #include #include #include @@ -42,6 +43,8 @@ Statistic<> numIntervals("liveintervals", "Number of intervals"); Statistic<> numJoined ("liveintervals", "Number of joined intervals"); + Statistic<> numPeep ("liveintervals", "Number of identity moves " + "eliminated after coalescing"); cl::opt join("join-liveintervals", @@ -64,7 +67,7 @@ { mbbi2mbbMap_.clear(); mi2iMap_.clear(); - r2iMap_.clear(); + i2miMap_.clear(); r2iMap_.clear(); r2rMap_.clear(); intervals_.clear(); @@ -74,7 +77,7 @@ /// runOnMachineFunction - Register allocate the whole function /// bool LiveIntervals::runOnMachineFunction(MachineFunction &fn) { - DEBUG(std::cerr << "Machine Function\n"); + DEBUG(std::cerr << "MACHINE FUNCTION: "; fn.print(std::cerr)); mf_ = &fn; tm_ = &fn.getTarget(); mri_ = tm_->getRegisterInfo(); @@ -94,47 +97,110 @@ mi != miEnd; ++mi) { inserted = mi2iMap_.insert(std::make_pair(mi, miIndex)).second; assert(inserted && "multiple MachineInstr -> index mappings"); + i2miMap_.push_back(mi); miIndex += 2; } } computeIntervals(); - // compute spill weights + numIntervals += intervals_.size(); + + // join intervals if requested + if (join) joinIntervals(); + + // perform a final pass over the instructions and compute spill + // weights, coalesce virtual registers and remove identity moves const LoopInfo& loopInfo = getAnalysis(); const TargetInstrInfo& tii = tm_->getInstrInfo(); - for (MachineFunction::const_iterator mbbi = mf_->begin(), - mbbe = mf_->end(); mbbi != mbbe; ++mbbi) { - const MachineBasicBlock* mbb = mbbi; + for (MachineFunction::iterator mbbi = mf_->begin(), mbbe = mf_->end(); + mbbi != mbbe; ++mbbi) { + MachineBasicBlock* mbb = mbbi; unsigned loopDepth = loopInfo.getLoopDepth(mbb->getBasicBlock()); - for (MachineBasicBlock::const_iterator mi = mbb->begin(), - mie = mbb->end(); mi != mie; ++mi) { - for (int i = mi->getNumOperands() - 1; i >= 0; --i) { - const MachineOperand& mop = mi->getOperand(i); - if (mop.isRegister() && - MRegisterInfo::isVirtualRegister(mop.getReg())) { - unsigned reg = mop.getReg(); - Reg2IntervalMap::iterator r2iit = r2iMap_.find(reg); - assert(r2iit != r2iMap_.end()); - r2iit->second->weight += pow(10.0F, loopDepth); + for (MachineBasicBlock::iterator mii = mbb->begin(), mie = mbb->end(); + mii != mie; ) { + for (unsigned i = 0; i < mii->getNumOperands(); ++i) { + const MachineOperand& mop = mii->getOperand(i); + if (mop.isRegister()) { + // replace register with representative register + unsigned reg = rep(mop.getReg()); + mii->SetMachineOperandReg(i, reg); + + if (MRegisterInfo::isVirtualRegister(reg)) { + Reg2IntervalMap::iterator r2iit = r2iMap_.find(reg); + assert(r2iit != r2iMap_.end()); + r2iit->second->weight += pow(10.0F, loopDepth); + } + } + } + + // if the move is now an identity move delete it + unsigned srcReg, dstReg; + if (tii.isMoveInstr(*mii, srcReg, dstReg) && srcReg == dstReg) { + // remove index -> MachineInstr and + // MachineInstr -> index mappings + Mi2IndexMap::iterator mi2i = mi2iMap_.find(mii); + if (mi2i != mi2iMap_.end()) { + i2miMap_[mi2i->second/2] = 0; + mi2iMap_.erase(mi2i); } + mii = mbbi->erase(mii); + ++numPeep; } + else + ++mii; } } - // join intervals if requested - if (join) joinIntervals(); - - numIntervals += intervals_.size(); - intervals_.sort(StartPointComp()); + DEBUG(std::cerr << "*** INTERVALS ***\n"); DEBUG(std::copy(intervals_.begin(), intervals_.end(), std::ostream_iterator(std::cerr, "\n"))); + DEBUG(std::cerr << "*** MACHINEINSTRS ***\n"); + DEBUG( + for (unsigned i = 0; i != i2miMap_.size(); ++i) { + if (const MachineInstr* mi = i2miMap_[i]) { + std:: cerr << i*2 << '\t'; + mi->print(std::cerr, *tm_); + } + }); + return true; } +void LiveIntervals::updateSpilledInterval(Interval& li) +{ + assert(li.weight != std::numeric_limits::infinity() && + "attempt to spill already spilled interval!"); + Interval::Ranges oldRanges; + swap(oldRanges, li.ranges); + + for (Interval::Ranges::iterator i = oldRanges.begin(), e = oldRanges.end(); + i != e; ++i) { + unsigned index = i->first & ~1; + unsigned end = i->second; + + for (; index < end; index += 2) { + // skip deleted instructions + while (!getInstructionFromIndex(index)) index += 2; + MachineInstr* mi = getInstructionFromIndex(index); + for (unsigned i = 0; i < mi->getNumOperands(); ++i) { + MachineOperand& mop = mi->getOperand(i); + if (mop.isRegister()) { + unsigned reg = mop.getReg(); + if (rep(reg) == li.reg) { + li.addRange(index, index + 2); + } + } + } + } + } + // the new spill weight is now infinity as it cannot be spilled again + li.weight = std::numeric_limits::infinity(); +} + void LiveIntervals::printRegName(unsigned reg) const { if (MRegisterInfo::isPhysicalRegister(reg)) @@ -277,9 +343,16 @@ unsigned LiveIntervals::getInstructionIndex(MachineInstr* instr) const { - assert(mi2iMap_.find(instr) != mi2iMap_.end() && - "instruction not assigned a number"); - return mi2iMap_.find(instr)->second; + Mi2IndexMap::const_iterator it = mi2iMap_.find(instr); + return it == mi2iMap_.end() ? std::numeric_limits::max() : it->second; +} + +MachineInstr* LiveIntervals::getInstructionFromIndex(unsigned index) const +{ + index /= 2; // convert index to vector index + assert(index < i2miMap_.size() && + "index does not correspond to an instruction"); + return i2miMap_[index]; } /// computeIntervals - computes the live intervals for virtual @@ -288,20 +361,19 @@ /// which a variable is live void LiveIntervals::computeIntervals() { - DEBUG(std::cerr << "computing live intervals:\n"); + DEBUG(std::cerr << "*** COMPUTING LIVE INTERVALS ***\n"); for (MbbIndex2MbbMap::iterator it = mbbi2mbbMap_.begin(), itEnd = mbbi2mbbMap_.end(); it != itEnd; ++it) { MachineBasicBlock* mbb = it->second; - DEBUG(std::cerr << "machine basic block: " - << mbb->getBasicBlock()->getName() << "\n"); + DEBUG(std::cerr << mbb->getBasicBlock()->getName() << ":\n"); for (MachineBasicBlock::iterator mi = mbb->begin(), miEnd = mbb->end(); mi != miEnd; ++mi) { const TargetInstrDescriptor& tid = tm_->getInstrInfo().get(mi->getOpcode()); - DEBUG(std::cerr << "\t[" << getInstructionIndex(mi) << "] "; + DEBUG(std::cerr << "[" << getInstructionIndex(mi) << "]\t"; mi->print(std::cerr, *tm_);); // handle implicit defs @@ -329,22 +401,20 @@ void LiveIntervals::joinIntervals() { - DEBUG(std::cerr << "joining compatible intervals:\n"); + DEBUG(std::cerr << "** JOINING INTERVALS ***\n"); const TargetInstrInfo& tii = tm_->getInstrInfo(); for (MachineFunction::iterator mbbi = mf_->begin(), mbbe = mf_->end(); mbbi != mbbe; ++mbbi) { MachineBasicBlock* mbb = mbbi; - DEBUG(std::cerr << "machine basic block: " - << mbb->getBasicBlock()->getName() << "\n"); + DEBUG(std::cerr << mbb->getBasicBlock()->getName() << ":\n"); for (MachineBasicBlock::iterator mi = mbb->begin(), mie = mbb->end(); mi != mie; ++mi) { const TargetInstrDescriptor& tid = tm_->getInstrInfo().get(mi->getOpcode()); - DEBUG(std::cerr << "\t\tinstruction[" - << getInstructionIndex(mi) << "]: "; + DEBUG(std::cerr << "[" << getInstructionIndex(mi) << "]\t"; mi->print(std::cerr, *tm_);); // we only join virtual registers with allocatable Index: llvm/lib/CodeGen/RegAllocLinearScan.cpp diff -u llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.47 llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.48 --- llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.47 Fri Feb 13 18:44:07 2004 +++ llvm/lib/CodeGen/RegAllocLinearScan.cpp Sun Feb 15 04:24:21 2004 @@ -27,46 +27,37 @@ #include "Support/DepthFirstIterator.h" #include "Support/Statistic.h" #include "Support/STLExtras.h" +#include using namespace llvm; namespace { Statistic<> numSpilled ("ra-linearscan", "Number of registers spilled"); Statistic<> numReloaded("ra-linearscan", "Number of registers reloaded"); - Statistic<> numPeep ("ra-linearscan", - "Number of identity moves eliminated"); class PhysRegTracker { private: const MRegisterInfo* mri_; - std::vector reserved_; std::vector regUse_; public: PhysRegTracker(MachineFunction* mf) : mri_(mf ? mf->getTarget().getRegisterInfo() : NULL) { if (mri_) { - reserved_.assign(mri_->getNumRegs(), false); regUse_.assign(mri_->getNumRegs(), 0); } } PhysRegTracker(const PhysRegTracker& rhs) : mri_(rhs.mri_), - reserved_(rhs.reserved_), regUse_(rhs.regUse_) { } const PhysRegTracker& operator=(const PhysRegTracker& rhs) { mri_ = rhs.mri_; - reserved_ = rhs.reserved_; regUse_ = rhs.regUse_; return *this; } - void reservePhysReg(unsigned physReg) { - reserved_[physReg] = true; - } - void addPhysRegUse(unsigned physReg) { ++regUse_[physReg]; for (const unsigned* as = mri_->getAliasSet(physReg); *as; ++as) { @@ -85,16 +76,8 @@ } } - bool isPhysRegReserved(unsigned physReg) const { - return reserved_[physReg]; - } - bool isPhysRegAvail(unsigned physReg) const { - return regUse_[physReg] == 0 && !isPhysRegReserved(physReg); - } - - bool isReservedPhysRegAvail(unsigned physReg) const { - return regUse_[physReg] == 0 && isPhysRegReserved(physReg); + return regUse_[physReg] == 0; } }; @@ -104,10 +87,8 @@ const TargetMachine* tm_; const MRegisterInfo* mri_; LiveIntervals* li_; - MachineFunction::iterator currentMbb_; - MachineBasicBlock::iterator currentInstr_; - typedef std::vector IntervalPtrs; - IntervalPtrs unhandled_, fixed_, active_, inactive_; + typedef std::list IntervalPtrs; + IntervalPtrs unhandled_, fixed_, active_, inactive_, handled_; PhysRegTracker prt_; @@ -146,7 +127,7 @@ private: /// initIntervalSets - initializa the four interval sets: /// unhandled, fixed, active and inactive - void initIntervalSets(const LiveIntervals::Intervals& li); + void initIntervalSets(LiveIntervals::Intervals& li); /// processActiveIntervals - expire old intervals and move /// non-overlapping ones to the incative list @@ -164,6 +145,10 @@ /// is available, or spill. void assignRegOrStackSlotAtInterval(IntervalPtrs::value_type cur); + /// addSpillCode - adds spill code for interval. The interval + /// must be modified by LiveIntervals::updateIntervalForSpill. + void addSpillCode(IntervalPtrs::value_type li, int slot); + /// /// register handling helpers /// @@ -173,11 +158,6 @@ /// 0 unsigned getFreePhysReg(IntervalPtrs::value_type cur); - /// getFreeTempPhysReg - return a free temprorary physical - /// register for this virtual register if we have one (should - /// never return 0) - unsigned getFreeTempPhysReg(unsigned virtReg); - /// assignVirt2PhysReg - assigns the free physical register to /// the virtual register passed as arguments Virt2PhysMap::iterator @@ -189,22 +169,13 @@ void clearVirtReg(Virt2PhysMap::iterator it); /// assignVirt2StackSlot - assigns this virtual register to a - /// stack slot - void assignVirt2StackSlot(unsigned virtReg); + /// stack slot. returns the stack slot + int assignVirt2StackSlot(unsigned virtReg); /// getStackSlot - returns the offset of the specified /// register on the stack int getStackSlot(unsigned virtReg); - /// spillVirtReg - spills the virtual register - void spillVirtReg(Virt2PhysMap::iterator it); - - /// loadPhysReg - loads to the physical register the value of - /// the virtual register specifed. Virtual register must have - /// an assigned stack slot - Virt2PhysMap::iterator - loadVirt2PhysReg(unsigned virtReg, unsigned physReg); - void printVirtRegAssignment() const { std::cerr << "register assignment:\n"; @@ -235,21 +206,6 @@ std::cerr << mri_->getName(reg) << '\n'; } } - -// void printFreeRegs(const char* const str, -// const TargetRegisterClass* rc) const { -// if (str) std::cerr << str << ':'; -// for (TargetRegisterClass::iterator i = -// rc->allocation_order_begin(*mf_); -// i != rc->allocation_order_end(*mf_); ++i) { -// unsigned reg = *i; -// if (!regUse_[reg]) { -// std::cerr << ' ' << mri_->getName(reg); -// if (reserved_[reg]) std::cerr << "*"; -// } -// } -// std::cerr << '\n'; -// } }; } @@ -261,7 +217,7 @@ active_.clear(); inactive_.clear(); fixed_.clear(); - + handled_.clear(); } bool RA::runOnMachineFunction(MachineFunction &fn) { @@ -273,24 +229,6 @@ initIntervalSets(li_->getIntervals()); - // FIXME: this will work only for the X86 backend. I need to - // device an algorthm to select the minimal (considering register - // aliasing) number of temp registers to reserve so that we have 2 - // registers for each register class available. - - // reserve R8: CH, CL - // R16: CX, DI, - // R32: ECX, EDI, - // RFP: FP5, FP6 - prt_.reservePhysReg( 8); /* CH */ - prt_.reservePhysReg( 9); /* CL */ - prt_.reservePhysReg(10); /* CX */ - prt_.reservePhysReg(12); /* DI */ - prt_.reservePhysReg(18); /* ECX */ - prt_.reservePhysReg(19); /* EDI */ - prt_.reservePhysReg(28); /* FP5 */ - prt_.reservePhysReg(29); /* FP6 */ - // linear scan algorithm DEBUG(std::cerr << "Machine Function\n"); @@ -304,19 +242,19 @@ IntervalPtrs::value_type cur; if (fixed_.empty()) { cur = unhandled_.front(); - unhandled_.erase(unhandled_.begin()); + unhandled_.pop_front(); } else if (unhandled_.empty()) { cur = fixed_.front(); - fixed_.erase(fixed_.begin()); + fixed_.pop_front(); } else if (unhandled_.front()->start() < fixed_.front()->start()) { cur = unhandled_.front(); - unhandled_.erase(unhandled_.begin()); + unhandled_.pop_front(); } else { cur = fixed_.front(); - fixed_.erase(fixed_.begin()); + fixed_.pop_front(); } DEBUG(std::cerr << *cur << '\n'); @@ -328,6 +266,7 @@ if (MRegisterInfo::isPhysicalRegister(cur->reg)) { prt_.addPhysRegUse(cur->reg); active_.push_back(cur); + handled_.push_back(cur); } // otherwise we are allocating a virtual register. try to find // a free physical register or spill an interval in order to @@ -349,166 +288,53 @@ prt_.delPhysRegUse(reg); } - typedef LiveIntervals::Reg2RegMap Reg2RegMap; - const Reg2RegMap& r2rMap = li_->getJoinedRegMap(); - - DEBUG(printVirtRegAssignment()); - DEBUG(std::cerr << "Performing coalescing on joined intervals\n"); - // perform coalescing if we were passed joined intervals - for(Reg2RegMap::const_iterator i = r2rMap.begin(), e = r2rMap.end(); - i != e; ++i) { - unsigned reg = i->first; - unsigned rep = li_->rep(reg); - - assert((MRegisterInfo::isPhysicalRegister(rep) || - v2pMap_.count(rep) || v2ssMap_.count(rep)) && - "representative register is not allocated!"); - - assert(MRegisterInfo::isVirtualRegister(reg) && - !v2pMap_.count(reg) && !v2ssMap_.count(reg) && - "coalesced register is already allocated!"); - - if (MRegisterInfo::isPhysicalRegister(rep)) { - v2pMap_.insert(std::make_pair(reg, rep)); - } - else { - Virt2PhysMap::const_iterator pr = v2pMap_.find(rep); - if (pr != v2pMap_.end()) { - v2pMap_.insert(std::make_pair(reg, pr->second)); - } - else { - Virt2StackSlotMap::const_iterator ss = v2ssMap_.find(rep); - assert(ss != v2ssMap_.end()); - v2ssMap_.insert(std::make_pair(reg, ss->second)); - } - } - } - DEBUG(printVirtRegAssignment()); DEBUG(std::cerr << "finished register allocation\n"); const TargetInstrInfo& tii = tm_->getInstrInfo(); DEBUG(std::cerr << "Rewrite machine code:\n"); - for (currentMbb_ = mf_->begin(); currentMbb_ != mf_->end(); ++currentMbb_) { + for (MachineFunction::iterator mbbi = mf_->begin(), mbbe = mf_->end(); + mbbi != mbbe; ++mbbi) { instrAdded_ = 0; - for (currentInstr_ = currentMbb_->begin(); - currentInstr_ != currentMbb_->end(); ) { - DEBUG(std::cerr << "\tinstruction: "; - currentInstr_->print(std::cerr, *tm_);); + for (MachineBasicBlock::iterator mii = mbbi->begin(), mie = mbbi->end(); + mii != mie; ++mii) { + DEBUG(std::cerr << '\t'; mii->print(std::cerr, *tm_)); - // use our current mapping and actually replace and + // use our current mapping and actually replace every // virtual register with its allocated physical registers DEBUG(std::cerr << "\t\treplacing virtual registers with mapped " "physical registers:\n"); - for (unsigned i = 0, e = currentInstr_->getNumOperands(); + for (unsigned i = 0, e = mii->getNumOperands(); i != e; ++i) { - MachineOperand& op = currentInstr_->getOperand(i); - if (op.isRegister() && - MRegisterInfo::isVirtualRegister(op.getReg())) { - unsigned virtReg = op.getReg(); - Virt2PhysMap::const_iterator it = v2pMap_.find(virtReg); - if (it != v2pMap_.end()) { - DEBUG(std::cerr << "\t\t\t%reg" << it->first - << " -> " << mri_->getName(it->second) << '\n'); - currentInstr_->SetMachineOperandReg(i, it->second); - } - } - } - - unsigned srcReg, dstReg; - if (tii.isMoveInstr(*currentInstr_, srcReg, dstReg) && - ((MRegisterInfo::isPhysicalRegister(srcReg) && - MRegisterInfo::isPhysicalRegister(dstReg) && - srcReg == dstReg) || - (MRegisterInfo::isVirtualRegister(srcReg) && - MRegisterInfo::isVirtualRegister(dstReg) && - v2ssMap_[srcReg] == v2ssMap_[dstReg]))) { - currentInstr_ = currentMbb_->erase(currentInstr_); - ++numPeep; - DEBUG(std::cerr << "\t\tdeleting instruction\n"); - continue; - } - - typedef std::vector Regs; - Regs toClear; - Regs toSpill; - - const unsigned numOperands = currentInstr_->getNumOperands(); - - DEBUG(std::cerr << "\t\tloading temporarily used operands to " - "registers:\n"); - for (unsigned i = 0; i != numOperands; ++i) { - MachineOperand& op = currentInstr_->getOperand(i); - if (op.isRegister() && op.isUse() && - MRegisterInfo::isVirtualRegister(op.getReg())) { - unsigned virtReg = op.getReg(); - unsigned physReg = 0; - Virt2PhysMap::iterator it = v2pMap_.find(virtReg); - if (it != v2pMap_.end()) { - physReg = it->second; - } - else { - physReg = getFreeTempPhysReg(virtReg); - it = loadVirt2PhysReg(virtReg, physReg); - // we will clear uses that are not also defs - // before we allocate registers the defs - if (op.isDef()) - toSpill.push_back(it); - else - toClear.push_back(it); - } - currentInstr_->SetMachineOperandReg(i, physReg); - } - } - - DEBUG(std::cerr << "\t\tclearing temporarily used but not defined " - "operands:\n"); - std::for_each(toClear.begin(), toClear.end(), - std::bind1st(std::mem_fun(&RA::clearVirtReg), this)); - - DEBUG(std::cerr << "\t\tassigning temporarily defined operands to " - "registers:\n"); - for (unsigned i = 0; i != numOperands; ++i) { - MachineOperand& op = currentInstr_->getOperand(i); + MachineOperand& op = mii->getOperand(i); if (op.isRegister() && MRegisterInfo::isVirtualRegister(op.getReg())) { - assert(!op.isUse() && "we should not have uses here!"); unsigned virtReg = op.getReg(); - unsigned physReg = 0; Virt2PhysMap::iterator it = v2pMap_.find(virtReg); - if (it != v2pMap_.end()) { - physReg = it->second; - } - else { - physReg = getFreeTempPhysReg(virtReg); - it = assignVirt2PhysReg(virtReg, physReg); - // need to spill this after we are done with - // this instruction - toSpill.push_back(it); - } - currentInstr_->SetMachineOperandReg(i, physReg); + assert(it != v2pMap_.end() && + "all virtual registers must be allocated"); + unsigned physReg = it->second; + assert(MRegisterInfo::isPhysicalRegister(physReg)); + DEBUG(std::cerr << "\t\t\t%reg" << virtReg + << " -> " << mri_->getName(physReg) << '\n'); + mii->SetMachineOperandReg(i, physReg); } } - ++currentInstr_; // spills will go after this instruction - - DEBUG(std::cerr << "\t\tspilling temporarily defined operands:\n"); - std::for_each(toSpill.begin(), toSpill.end(), - std::bind1st(std::mem_fun(&RA::spillVirtReg), this)); } } return true; } -void RA::initIntervalSets(const LiveIntervals::Intervals& li) +void RA::initIntervalSets(LiveIntervals::Intervals& li) { assert(unhandled_.empty() && fixed_.empty() && active_.empty() && inactive_.empty() && "interval sets should be empty on initialization"); - for (LiveIntervals::Intervals::const_iterator i = li.begin(), e = li.end(); + for (LiveIntervals::Intervals::iterator i = li.begin(), e = li.end(); i != e; ++i) { if (MRegisterInfo::isPhysicalRegister(i->reg)) fixed_.push_back(&*i); @@ -629,17 +455,22 @@ } unsigned physReg = getFreePhysReg(cur); - // if we find a free register, we are done: restore original - // register tracker, assign this virtual to the free physical - // register and add this interval to the active list. + // restore the physical register tracker + prt_ = backupPrt; + // if we find a free register, we are done: assign this virtual to + // the free physical register and add this interval to the active + // list. if (physReg) { - prt_ = backupPrt; assignVirt2PhysReg(cur->reg, physReg); active_.push_back(cur); + handled_.push_back(cur); return; } DEBUG(std::cerr << "\t\tassigning stack slot at interval "<< *cur << ":\n"); + // push the current interval back to unhandled since we are going + // to re-run at least this iteration + unhandled_.push_front(cur); float minWeight = std::numeric_limits::infinity(); unsigned minReg = 0; @@ -647,7 +478,7 @@ for (TargetRegisterClass::iterator i = rc->allocation_order_begin(*mf_); i != rc->allocation_order_end(*mf_); ++i) { unsigned reg = *i; - if (!prt_.isPhysRegReserved(reg) && minWeight > spillWeights_[reg]) { + if (minWeight > spillWeights_[reg]) { minWeight = spillWeights_[reg]; minReg = reg; } @@ -655,61 +486,197 @@ DEBUG(std::cerr << "\t\t\tregister with min weight: " << mri_->getName(minReg) << " (" << minWeight << ")\n"); - // if the current has the minimum weight, we are done: restore - // original register tracker and assign a stack slot to this - // virtual register + // if the current has the minimum weight, we need to modify it, + // push it back in unhandled and let the linear scan algorithm run + // again if (cur->weight < minWeight) { - prt_ = backupPrt; - DEBUG(std::cerr << "\t\t\t\tspilling: " << *cur << '\n'); - assignVirt2StackSlot(cur->reg); + DEBUG(std::cerr << "\t\t\t\tspilling(c): " << *cur;); + int slot = assignVirt2StackSlot(cur->reg); + li_->updateSpilledInterval(*cur); + addSpillCode(cur, slot); + DEBUG(std::cerr << "[ " << *cur << " ]\n"); return; } + // otherwise we spill all intervals aliasing the register with + // minimum weight, rollback to the interval with the earliest + // start point and let the linear scan algorithm run again std::vector toSpill(mri_->getNumRegs(), false); toSpill[minReg] = true; for (const unsigned* as = mri_->getAliasSet(minReg); *as; ++as) toSpill[*as] = true; + unsigned earliestStart = cur->start(); - std::vector spilled; for (IntervalPtrs::iterator i = active_.begin(); - i != active_.end(); ) { + i != active_.end(); ++i) { unsigned reg = (*i)->reg; if (MRegisterInfo::isVirtualRegister(reg) && toSpill[v2pMap_[reg]] && cur->overlaps(**i)) { - spilled.push_back(v2pMap_[reg]); - DEBUG(std::cerr << "\t\t\t\tspilling : " << **i << '\n'); - assignVirt2StackSlot(reg); - i = active_.erase(i); - } - else { - ++i; + DEBUG(std::cerr << "\t\t\t\tspilling(a): " << **i); + int slot = assignVirt2StackSlot((*i)->reg); + li_->updateSpilledInterval(**i); + addSpillCode(*i, slot); + DEBUG(std::cerr << "[ " << **i << " ]\n"); + earliestStart = std::min(earliestStart, (*i)->start()); } } for (IntervalPtrs::iterator i = inactive_.begin(); - i != inactive_.end(); ) { + i != inactive_.end(); ++i) { unsigned reg = (*i)->reg; if (MRegisterInfo::isVirtualRegister(reg) && toSpill[v2pMap_[reg]] && cur->overlaps(**i)) { - DEBUG(std::cerr << "\t\t\t\tspilling : " << **i << '\n'); - assignVirt2StackSlot(reg); - i = inactive_.erase(i); + DEBUG(std::cerr << "\t\t\t\tspilling(i): " << **i << '\n'); + int slot = assignVirt2StackSlot((*i)->reg); + li_->updateSpilledInterval(**i); + addSpillCode(*i, slot); + DEBUG(std::cerr << "[ " << **i << " ]\n"); + earliestStart = std::min(earliestStart, (*i)->start()); + } + } + + DEBUG(std::cerr << "\t\t\t\trolling back to: " << earliestStart << '\n'); + // scan handled in reverse order and undo each one, restoring the + // state of unhandled and fixed + while (!handled_.empty()) { + IntervalPtrs::value_type i = handled_.back(); + // if this interval starts before t we are done + if (i->start() < earliestStart) + break; + DEBUG(std::cerr << "\t\t\t\t\tundo changes for: " << *i << '\n'); + handled_.pop_back(); + IntervalPtrs::iterator it; + if ((it = find(active_.begin(), active_.end(), i)) != active_.end()) { + active_.erase(it); + if (MRegisterInfo::isPhysicalRegister(i->reg)) { + fixed_.push_front(i); + prt_.delPhysRegUse(i->reg); + } + else { + Virt2PhysMap::iterator v2pIt = v2pMap_.find(i->reg); + clearVirtReg(v2pIt); + unhandled_.push_front(i); + prt_.delPhysRegUse(v2pIt->second); + } + } + else if ((it = find(inactive_.begin(), inactive_.end(), i)) != inactive_.end()) { + inactive_.erase(it); + if (MRegisterInfo::isPhysicalRegister(i->reg)) + fixed_.push_front(i); + else { + Virt2PhysMap::iterator v2pIt = v2pMap_.find(i->reg); + clearVirtReg(v2pIt); + unhandled_.push_front(i); + } } else { - ++i; + if (MRegisterInfo::isPhysicalRegister(i->reg)) + fixed_.push_front(i); + else { + Virt2PhysMap::iterator v2pIt = v2pMap_.find(i->reg); + clearVirtReg(v2pIt); + unhandled_.push_front(i); + } + } + } + + // scan the rest and undo each interval that expired after t and + // insert it in active (the next iteration of the algorithm will + // put it in inactive if required) + IntervalPtrs::iterator i = handled_.begin(), e = handled_.end(); + for (; i != e; ++i) { + if (!(*i)->expiredAt(earliestStart) && (*i)->expiredAt(cur->start())) { + DEBUG(std::cerr << "\t\t\t\t\tundo changes for: " << **i << '\n'); + active_.push_back(*i); + if (MRegisterInfo::isPhysicalRegister((*i)->reg)) + prt_.addPhysRegUse((*i)->reg); + else { + assert(v2pMap_.count((*i)->reg)); + prt_.addPhysRegUse(v2pMap_.find((*i)->reg)->second); + } } } +} - physReg = getFreePhysReg(cur); - assert(physReg && "no free physical register after spill?"); +void RA::addSpillCode(IntervalPtrs::value_type li, int slot) +{ + // We scan the instructions corresponding to each range. We load + // when we have a use and spill at end of basic blocks or end of + // ranges only if the register was modified. + const TargetRegisterClass* rc = mf_->getSSARegMap()->getRegClass(li->reg); + + for (LiveIntervals::Interval::Ranges::iterator i = li->ranges.begin(), + e = li->ranges.end(); i != e; ++i) { + unsigned index = i->first & ~1; + unsigned end = i->second; + + entry: + bool dirty = false, loaded = false; + + // skip deleted instructions. getInstructionFromIndex returns + // null if the instruction was deleted (because of coalescing + // for example) + while (!li_->getInstructionFromIndex(index)) index += 2; + MachineBasicBlock::iterator mi = li_->getInstructionFromIndex(index); + MachineBasicBlock* mbb = mi->getParent(); + + for (; index < end; index += 2) { + // ignore deleted instructions + while (!li_->getInstructionFromIndex(index)) index += 2; + + // if we changed basic block we need to start over + mi = li_->getInstructionFromIndex(index); + if (mbb != mi->getParent()) { + if (dirty) { + mi = li_->getInstructionFromIndex(index-2); + assert(mbb == mi->getParent() && + "rewound to wrong instruction?"); + DEBUG(std::cerr << "add store for reg" << li->reg << " to " + "stack slot " << slot << " after: "; + mi->print(std::cerr, *tm_)); + ++numSpilled; + mri_->storeRegToStackSlot(*mi->getParent(), + next(mi), li->reg, slot, rc); + } + goto entry; + } - prt_ = backupPrt; - for (unsigned i = 0; i < spilled.size(); ++i) - prt_.delPhysRegUse(spilled[i]); + // if it is used in this instruction load it + for (unsigned i = 0; i < mi->getNumOperands(); ++i) { + MachineOperand& mop = mi->getOperand(i); + if (mop.isRegister() && mop.getReg() == li->reg && + mop.isUse() && !loaded) { + loaded = true; + DEBUG(std::cerr << "add load for reg" << li->reg + << " from stack slot " << slot << " before: "; + mi->print(std::cerr, *tm_)); + ++numReloaded; + mri_->loadRegFromStackSlot(*mi->getParent(), + mi, li->reg, slot, rc); + } + } - assignVirt2PhysReg(cur->reg, physReg); - active_.push_back(cur); + // if it is defined in this instruction mark as dirty + for (unsigned i = 0; i < mi->getNumOperands(); ++i) { + MachineOperand& mop = mi->getOperand(i); + if (mop.isRegister() && mop.getReg() == li->reg && + mop.isDef()) + dirty = loaded = true; + } + } + if (dirty) { + mi = li_->getInstructionFromIndex(index-2); + assert(mbb == mi->getParent() && + "rewound to wrong instruction?"); + DEBUG(std::cerr << "add store for reg" << li->reg << " to " + "stack slot " << slot << " after: "; + mi->print(std::cerr, *tm_)); + ++numSpilled; + mri_->storeRegToStackSlot(*mi->getParent(), + next(mi), li->reg, slot, rc); + } + } } unsigned RA::getFreePhysReg(IntervalPtrs::value_type cur) @@ -730,27 +697,6 @@ return 0; } -unsigned RA::getFreeTempPhysReg(unsigned virtReg) -{ - DEBUG(std::cerr << "\t\tgetting free temporary physical register: "); - - const TargetRegisterClass* rc = mf_->getSSARegMap()->getRegClass(virtReg); - // go in reverse allocation order for the temp registers - typedef std::reverse_iterator TRCRevIter; - for (TRCRevIter - i(rc->allocation_order_end(*mf_)), - e(rc->allocation_order_begin(*mf_)); i != e; ++i) { - unsigned reg = *i; - if (prt_.isReservedPhysRegAvail(reg)) { - DEBUG(std::cerr << mri_->getName(reg) << '\n'); - return reg; - } - } - - assert(0 && "no free temporary physical register?"); - return 0; -} - RA::Virt2PhysMap::iterator RA::assignVirt2PhysReg(unsigned virtReg, unsigned physReg) { @@ -768,62 +714,27 @@ assert(it != v2pMap_.end() && "attempting to clear a not allocated virtual register"); unsigned physReg = it->second; - prt_.delPhysRegUse(physReg); v2pMap_.erase(it); DEBUG(std::cerr << "\t\t\tcleared register " << mri_->getName(physReg) << "\n"); } -void RA::assignVirt2StackSlot(unsigned virtReg) + +int RA::assignVirt2StackSlot(unsigned virtReg) { const TargetRegisterClass* rc = mf_->getSSARegMap()->getRegClass(virtReg); int frameIndex = mf_->getFrameInfo()->CreateStackObject(rc); bool inserted = v2ssMap_.insert(std::make_pair(virtReg, frameIndex)).second; - assert(inserted && - "attempt to assign stack slot to already assigned register?"); - // if the virtual register was previously assigned clear the mapping - // and free the virtual register - Virt2PhysMap::iterator it = v2pMap_.find(virtReg); - if (it != v2pMap_.end()) { - clearVirtReg(it); - } + assert(inserted && "attempt to assign stack slot to spilled register!"); + return frameIndex; } int RA::getStackSlot(unsigned virtReg) { - Virt2StackSlotMap::iterator it = v2ssMap_.find(virtReg); - assert(it != v2ssMap_.end() && - "attempt to get stack slot on register that does not live on the stack"); - return it->second; -} - -void RA::spillVirtReg(Virt2PhysMap::iterator it) -{ - assert(it != v2pMap_.end() && - "attempt to spill a not allocated virtual register"); - unsigned virtReg = it->first; - DEBUG(std::cerr << "\t\t\tspilling register: " << virtReg); - const TargetRegisterClass* rc = mf_->getSSARegMap()->getRegClass(virtReg); - int frameIndex = getStackSlot(virtReg); - DEBUG(std::cerr << " to stack slot #" << frameIndex << '\n'); - ++numSpilled; - instrAdded_ += mri_->storeRegToStackSlot(*currentMbb_, currentInstr_, - it->second, frameIndex, rc); - clearVirtReg(it); -} - -RA::Virt2PhysMap::iterator -RA::loadVirt2PhysReg(unsigned virtReg, unsigned physReg) -{ - DEBUG(std::cerr << "\t\t\tloading register: " << virtReg); - const TargetRegisterClass* rc = mf_->getSSARegMap()->getRegClass(virtReg); - int frameIndex = getStackSlot(virtReg); - DEBUG(std::cerr << " from stack slot #" << frameIndex << '\n'); - ++numReloaded; - instrAdded_ += mri_->loadRegFromStackSlot(*currentMbb_, currentInstr_, - physReg, frameIndex, rc); - return assignVirt2PhysReg(virtReg, physReg); + assert(v2ssMap_.count(virtReg) && + "attempt to get stack slot for a non spilled register"); + return v2ssMap_.find(virtReg)->second; } FunctionPass* llvm::createLinearScanRegisterAllocator() { From alkis at cs.uiuc.edu Sun Feb 15 04:25:17 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sun Feb 15 04:25:17 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/LiveIntervals.h Message-ID: <200402151024.EAA26354@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: LiveIntervals.h updated: 1.16 -> 1.17 --- Log message: Eliminate the use of spill (reserved) registers. --- Diffs of the changes: (+10 -7) Index: llvm/include/llvm/CodeGen/LiveIntervals.h diff -u llvm/include/llvm/CodeGen/LiveIntervals.h:1.16 llvm/include/llvm/CodeGen/LiveIntervals.h:1.17 --- llvm/include/llvm/CodeGen/LiveIntervals.h:1.16 Sat Jan 31 13:59:32 2004 +++ llvm/include/llvm/CodeGen/LiveIntervals.h Sun Feb 15 04:24:12 2004 @@ -100,6 +100,9 @@ typedef std::map Mi2IndexMap; Mi2IndexMap mi2iMap_; + typedef std::vector Index2MiMap; + Index2MiMap i2miMap_; + typedef std::map Reg2IntervalMap; Reg2IntervalMap r2iMap_; @@ -114,14 +117,13 @@ /// runOnMachineFunction - pass entry point virtual bool runOnMachineFunction(MachineFunction&); - Intervals& getIntervals() { return intervals_; } + unsigned getInstructionIndex(MachineInstr* instr) const; - const Reg2RegMap& getJoinedRegMap() const { - return r2rMap_; - } + MachineInstr* getInstructionFromIndex(unsigned index) const; - /// rep - returns the representative of this register - unsigned rep(unsigned reg); + Intervals& getIntervals() { return intervals_; } + + void updateSpilledInterval(Interval& i); private: /// computeIntervals - compute live intervals @@ -151,7 +153,8 @@ bool overlapsAliases(const Interval& lhs, const Interval& rhs) const; - unsigned getInstructionIndex(MachineInstr* instr) const; + /// rep - returns the representative of this register + unsigned rep(unsigned reg); void printRegName(unsigned reg) const; }; From huqx338caq at sam.hi-ho.ne.jp Sun Feb 15 14:10:04 2004 From: huqx338caq at sam.hi-ho.ne.jp (Quincy Shafer) Date: Sun Feb 15 14:10:04 2004 Subject: [llvm-commits] No more scams Message-ID: An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20040215/89bcda07/attachment.html From jmxfkfzx at mxa.mesh.ne.jp Sun Feb 15 14:10:23 2004 From: jmxfkfzx at mxa.mesh.ne.jp (Hubert Nichols) Date: Sun Feb 15 14:10:23 2004 Subject: [llvm-commits] Have your cake and eat it too Message-ID: An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20040215/cdb2289e/attachment.html From alkis at cs.uiuc.edu Sun Feb 15 15:38:01 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sun Feb 15 15:38:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86CodeEmitter.cpp Printer.cpp PeepholeOptimizer.cpp Message-ID: <200402152137.PAA32426@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86CodeEmitter.cpp updated: 1.50 -> 1.51 Printer.cpp updated: 1.81 -> 1.82 PeepholeOptimizer.cpp updated: 1.14 -> 1.15 --- Log message: Make dense maps keyed on physical registers smallerusing MRegisterInfo::getNumRegs() instead of MRegisterInfo::FirstVirtualRegister. Also use MRegisterInfo::is{Physical,Virtual}Register where appropriate. --- Diffs of the changes: (+3 -3) Index: llvm/lib/Target/X86/X86CodeEmitter.cpp diff -u llvm/lib/Target/X86/X86CodeEmitter.cpp:1.50 llvm/lib/Target/X86/X86CodeEmitter.cpp:1.51 --- llvm/lib/Target/X86/X86CodeEmitter.cpp:1.50 Sat Feb 14 18:03:15 2004 +++ llvm/lib/Target/X86/X86CodeEmitter.cpp Sun Feb 15 15:37:17 2004 @@ -329,7 +329,7 @@ case X86::ST4: case X86::ST5: case X86::ST6: case X86::ST7: return RegNo-X86::ST0; default: - assert(RegNo >= MRegisterInfo::FirstVirtualRegister && + assert(MRegisterInfo::isVirtualRegister(RegNo) && "Unknown physical register!"); assert(0 && "Register allocator hasn't allocated reg correctly yet!"); return 0; Index: llvm/lib/Target/X86/Printer.cpp diff -u llvm/lib/Target/X86/Printer.cpp:1.81 llvm/lib/Target/X86/Printer.cpp:1.82 --- llvm/lib/Target/X86/Printer.cpp:1.81 Sat Feb 14 00:00:36 2004 +++ llvm/lib/Target/X86/Printer.cpp Sun Feb 15 15:37:17 2004 @@ -399,7 +399,7 @@ } // FALLTHROUGH case MachineOperand::MO_MachineRegister: - if (MO.getReg() < MRegisterInfo::FirstVirtualRegister) + if (MRegisterInfo::isPhysicalRegister(MO.getReg())) // Bug Workaround: See note in Printer::doInitialization about %. O << "%" << RI.get(MO.getReg()).Name; else Index: llvm/lib/Target/X86/PeepholeOptimizer.cpp diff -u llvm/lib/Target/X86/PeepholeOptimizer.cpp:1.14 llvm/lib/Target/X86/PeepholeOptimizer.cpp:1.15 --- llvm/lib/Target/X86/PeepholeOptimizer.cpp:1.14 Fri Feb 13 19:18:32 2004 +++ llvm/lib/Target/X86/PeepholeOptimizer.cpp Sun Feb 15 15:37:17 2004 @@ -164,7 +164,7 @@ // getDefinition - Return the machine instruction that defines the specified // SSA virtual register. MachineInstr *getDefinition(unsigned Reg) { - assert(Reg >= MRegisterInfo::FirstVirtualRegister && + assert(MRegisterInfo::isVirtualRegister(Reg) && "use-def chains only exist for SSA registers!"); assert(Reg - MRegisterInfo::FirstVirtualRegister < DefiningInst.size() && "Unknown register number!"); From alkis at cs.uiuc.edu Sun Feb 15 15:38:13 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sun Feb 15 15:38:13 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/RegAllocSimple.cpp RegAllocLocal.cpp PrologEpilogInserter.cpp LiveVariables.cpp Message-ID: <200402152137.PAA32437@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: RegAllocSimple.cpp updated: 1.50 -> 1.51 RegAllocLocal.cpp updated: 1.45 -> 1.46 PrologEpilogInserter.cpp updated: 1.21 -> 1.22 LiveVariables.cpp updated: 1.23 -> 1.24 --- Log message: Make dense maps keyed on physical registers smallerusing MRegisterInfo::getNumRegs() instead of MRegisterInfo::FirstVirtualRegister. Also use MRegisterInfo::is{Physical,Virtual}Register where appropriate. --- Diffs of the changes: (+6 -7) Index: llvm/lib/CodeGen/RegAllocSimple.cpp diff -u llvm/lib/CodeGen/RegAllocSimple.cpp:1.50 llvm/lib/CodeGen/RegAllocSimple.cpp:1.51 --- llvm/lib/CodeGen/RegAllocSimple.cpp:1.50 Fri Feb 13 15:01:20 2004 +++ llvm/lib/CodeGen/RegAllocSimple.cpp Sun Feb 15 15:37:17 2004 @@ -154,7 +154,7 @@ // Made to combat the incorrect allocation of r2 = add r1, r1 std::map Virt2PhysRegMap; - RegsUsed.resize(MRegisterInfo::FirstVirtualRegister); + RegsUsed.resize(RegInfo->getNumRegs()); // a preliminary pass that will invalidate any registers that // are used by the instruction (including implicit uses) Index: llvm/lib/CodeGen/RegAllocLocal.cpp diff -u llvm/lib/CodeGen/RegAllocLocal.cpp:1.45 llvm/lib/CodeGen/RegAllocLocal.cpp:1.46 --- llvm/lib/CodeGen/RegAllocLocal.cpp:1.45 Fri Feb 13 15:01:20 2004 +++ llvm/lib/CodeGen/RegAllocLocal.cpp Sun Feb 15 15:37:17 2004 @@ -53,7 +53,7 @@ std::vector Virt2PhysRegMap; unsigned &getVirt2PhysRegMapSlot(unsigned VirtReg) { - assert(VirtReg >= MRegisterInfo::FirstVirtualRegister &&"Illegal VREG #"); + assert(MRegisterInfo::isVirtualRegister(VirtReg) &&"Illegal VREG #"); assert(VirtReg-MRegisterInfo::FirstVirtualRegister ModifiedRegs(MRegisterInfo::FirstVirtualRegister); + std::vector ModifiedRegs(RegInfo->getNumRegs()); unsigned MaxCallFrameSize = 0; bool HasCalls = false; Index: llvm/lib/CodeGen/LiveVariables.cpp diff -u llvm/lib/CodeGen/LiveVariables.cpp:1.23 llvm/lib/CodeGen/LiveVariables.cpp:1.24 --- llvm/lib/CodeGen/LiveVariables.cpp:1.23 Wed Feb 11 20:27:10 2004 +++ llvm/lib/CodeGen/LiveVariables.cpp Sun Feb 15 15:37:17 2004 @@ -187,10 +187,9 @@ // physical register. This is a purely local property, because all physical // register references as presumed dead across basic blocks. // - MachineInstr *PhysRegInfoA[MRegisterInfo::FirstVirtualRegister]; - bool PhysRegUsedA[MRegisterInfo::FirstVirtualRegister]; - std::fill(PhysRegInfoA, PhysRegInfoA+MRegisterInfo::FirstVirtualRegister, - (MachineInstr*)0); + MachineInstr *PhysRegInfoA[RegInfo->getNumRegs()]; + bool PhysRegUsedA[RegInfo->getNumRegs()]; + std::fill(PhysRegInfoA, PhysRegInfoA+RegInfo->getNumRegs(), (MachineInstr*)0); PhysRegInfo = PhysRegInfoA; PhysRegUsed = PhysRegUsedA; From lattner at cs.uiuc.edu Sun Feb 15 15:39:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun Feb 15 15:39:01 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/RegAllocSimple.cpp Message-ID: <200402152138.PAA00821@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: RegAllocSimple.cpp updated: 1.51 -> 1.52 --- Log message: Finegrainify namespacification Remove one of the operands of a two operand instruction --- Diffs of the changes: (+12 -8) Index: llvm/lib/CodeGen/RegAllocSimple.cpp diff -u llvm/lib/CodeGen/RegAllocSimple.cpp:1.51 llvm/lib/CodeGen/RegAllocSimple.cpp:1.52 --- llvm/lib/CodeGen/RegAllocSimple.cpp:1.51 Sun Feb 15 15:37:17 2004 +++ llvm/lib/CodeGen/RegAllocSimple.cpp Sun Feb 15 15:38:28 2004 @@ -25,8 +25,7 @@ #include "Support/Debug.h" #include "Support/Statistic.h" #include - -namespace llvm { +using namespace llvm; namespace { Statistic<> NumSpilled ("ra-simple", "Number of registers spilled"); @@ -183,7 +182,9 @@ unsigned physReg = Virt2PhysRegMap[virtualReg]; if (physReg == 0) { if (op.isDef()) { - if (TM->getInstrInfo().isTwoAddrInstr(MI->getOpcode()) && i == 0) { + if (!TM->getInstrInfo().isTwoAddrInstr(MI->getOpcode()) || i) { + physReg = getFreeReg(virtualReg); + } else { // must be same register number as the first operand // This maps a = b + c into b += c, and saves b into a's spot assert(MI->getOperand(1).isRegister() && @@ -192,8 +193,13 @@ "Two address instruction invalid!"); physReg = MI->getOperand(1).getReg(); - } else { - physReg = getFreeReg(virtualReg); + + ++MI; + spillVirtReg(MBB, MI, virtualReg, physReg); + --MI; + MI->getOperand(1).setDef(); + MI->RemoveOperand(0); + break; // This is the last operand to process } ++MI; spillVirtReg(MBB, MI, virtualReg, physReg); @@ -231,8 +237,6 @@ return true; } -FunctionPass *createSimpleRegisterAllocator() { +FunctionPass *llvm::createSimpleRegisterAllocator() { return new RegAllocSimple(); } - -} // End llvm namespace From alkis at cs.uiuc.edu Sun Feb 15 15:51:01 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sun Feb 15 15:51:01 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/TwoAddressInstructionPass.cpp Message-ID: <200402152150.PAA07486@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: TwoAddressInstructionPass.cpp updated: 1.16 -> 1.17 --- Log message: This pass should not require phi elimination or live variable analysis. It should only preserve them and update LiveVariables if it already ran. --- Diffs of the changes: (+15 -15) Index: llvm/lib/CodeGen/TwoAddressInstructionPass.cpp diff -u llvm/lib/CodeGen/TwoAddressInstructionPass.cpp:1.16 llvm/lib/CodeGen/TwoAddressInstructionPass.cpp:1.17 --- llvm/lib/CodeGen/TwoAddressInstructionPass.cpp:1.16 Fri Feb 13 19:18:34 2004 +++ llvm/lib/CodeGen/TwoAddressInstructionPass.cpp Sun Feb 15 15:50:32 2004 @@ -65,9 +65,7 @@ void TwoAddressInstructionPass::getAnalysisUsage(AnalysisUsage &AU) const { AU.addPreserved(); - AU.addRequired(); AU.addPreservedID(PHIEliminationID); - AU.addRequiredID(PHIEliminationID); MachineFunctionPass::getAnalysisUsage(AU); } @@ -79,7 +77,7 @@ const TargetMachine &TM = MF.getTarget(); const MRegisterInfo &MRI = *TM.getRegisterInfo(); const TargetInstrInfo &TII = TM.getInstrInfo(); - LiveVariables &LV = getAnalysis(); + LiveVariables* LV = getAnalysisToUpdate(); bool MadeChange = false; @@ -139,18 +137,20 @@ DEBUG(std::cerr << "\t\tadded instruction: "; prevMi->print(std::cerr, TM)); - // update live variables for regA - assert(Added == 1 && - "Cannot handle multi-instruction copies yet!"); - LiveVariables::VarInfo& varInfo = LV.getVarInfo(regA); - varInfo.DefInst = prevMi; - - // update live variables for regB - if (LV.removeVirtualRegisterKilled(regB, &*mbbi, mi)) - LV.addVirtualRegisterKilled(regB, &*mbbi, prevMi); - - if (LV.removeVirtualRegisterDead(regB, &*mbbi, mi)) - LV.addVirtualRegisterDead(regB, &*mbbi, prevMi); + if (LV) { + // update live variables for regA + assert(Added == 1 && + "Cannot handle multi-instruction copies yet!"); + LiveVariables::VarInfo& varInfo = LV->getVarInfo(regA); + varInfo.DefInst = prevMi; + + // update live variables for regB + if (LV->removeVirtualRegisterKilled(regB, &*mbbi, mi)) + LV->addVirtualRegisterKilled(regB, &*mbbi, prevMi); + + if (LV->removeVirtualRegisterDead(regB, &*mbbi, mi)) + LV->addVirtualRegisterDead(regB, &*mbbi, prevMi); + } // replace all occurences of regB with regA for (unsigned i = 1, e = mi->getNumOperands(); i != e; ++i) { From lattner at cs.uiuc.edu Sun Feb 15 16:15:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun Feb 15 16:15:01 2004 Subject: [llvm-commits] CVS: llvm/test/Regression/CBackend/2004-02-15-PreexistingExternals.llx Message-ID: <200402152214.QAA14974@zion.cs.uiuc.edu> Changes in directory llvm/test/Regression/CBackend: 2004-02-15-PreexistingExternals.llx added (r1.1) --- Log message: New testcase --- Diffs of the changes: (+16 -0) Index: llvm/test/Regression/CBackend/2004-02-15-PreexistingExternals.llx diff -c /dev/null llvm/test/Regression/CBackend/2004-02-15-PreexistingExternals.llx:1.1 *** /dev/null Sun Feb 15 16:14:57 2004 --- llvm/test/Regression/CBackend/2004-02-15-PreexistingExternals.llx Sun Feb 15 16:14:46 2004 *************** *** 0 **** --- 1,16 ---- + ; The intrinsic lowering pass was lowering intrinsics like llvm.memcpy to + ; explicitly specified prototypes, inserting a new function if the old one + ; didn't exist. This caused there to be two external memcpy functions in + ; this testcase for example, which caused the CBE to mangle one, screwing + ; everything up. :( Test that this does not happen anymore. + ; + ; RUN: llvm-as < %s | llc -march=c | not grep _memcpy + + declare void %llvm.memcpy(sbyte*, sbyte*, uint,uint) + declare float* %memcpy(int*, uint,int) + + int %test(sbyte *%A, sbyte* %B, int* %C) { + call float* %memcpy(int* %C, uint 4, int 17) + call void %llvm.memcpy(sbyte* %A, sbyte* %B, uint 123, uint 14) + ret int 7 + } From lattner at cs.uiuc.edu Sun Feb 15 16:17:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun Feb 15 16:17:01 2004 Subject: [llvm-commits] CVS: llvm/lib/VMCore/IntrinsicLowering.cpp Message-ID: <200402152216.QAA15763@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: IntrinsicLowering.cpp updated: 1.9 -> 1.10 --- Log message: Refactor code. Now the intrinsic lowering pass tries to recycle preexisting prototypes, even if they don't precisely match what it would prefer to use. This fixes: CBackend/2004-02-15-PreexistingExternals.llx compiling it into: ltmp_0_30 = memcpy(l14_C, 4u, 17); ltmp_1_30 = memcpy(((int *)l27_A), ((unsigned )(long)l27_B), ((int )123u)); instead of: ltmp_0_30 = memcpy(l14_C, 4u, 17); ltmp_1_27 = l43_memcpy(l27_A, l27_B, 123u); Which does the wrong thing as you could imagine. --- Diffs of the changes: (+63 -35) Index: llvm/lib/VMCore/IntrinsicLowering.cpp diff -u llvm/lib/VMCore/IntrinsicLowering.cpp:1.9 llvm/lib/VMCore/IntrinsicLowering.cpp:1.10 --- llvm/lib/VMCore/IntrinsicLowering.cpp:1.9 Fri Feb 13 22:52:06 2004 +++ llvm/lib/VMCore/IntrinsicLowering.cpp Sun Feb 15 16:16:39 2004 @@ -18,6 +18,49 @@ #include "llvm/iOther.h" using namespace llvm; +/// ReplaceCallWith - This function is used when we want to lower an intrinsic +/// call to a call of an external function. This handles hard cases such as +/// when there was already a prototype for the external function, and if that +/// prototype doesn't match the arguments we expect to pass in. +template +static CallInst *ReplaceCallWith(const char *NewFn, CallInst *CI, + ArgIt ArgBegin, ArgIt ArgEnd, + const Type *RetTy, Function *&FCache) { + if (!FCache) { + // If we haven't already looked up this function, check to see if the + // program already contains a function with this name. + Module *M = CI->getParent()->getParent()->getParent(); + FCache = M->getNamedFunction(NewFn); + if (!FCache) { + // It doesn't already exist in the program, insert a new definition now. + std::vector ParamTys; + for (ArgIt I = ArgBegin; I != ArgEnd; ++I) + ParamTys.push_back((*I)->getType()); + FCache = M->getOrInsertFunction(NewFn, + FunctionType::get(RetTy, ParamTys, false)); + } + } + + const FunctionType *FT = FCache->getFunctionType(); + std::vector Operands; + unsigned ArgNo = 0; + for (ArgIt I = ArgBegin; I != ArgEnd && ArgNo != FT->getNumParams(); + ++I, ++ArgNo) { + Value *Arg = *I; + if (Arg->getType() != FT->getParamType(ArgNo)) + Arg = new CastInst(Arg, FT->getParamType(ArgNo), Arg->getName(), CI); + Operands.push_back(Arg); + } + // Pass nulls into any additional arguments... + for (; ArgNo != FT->getNumParams(); ++ArgNo) + Operands.push_back(Constant::getNullValue(FT->getParamType(ArgNo))); + + std::string Name = CI->getName(); CI->setName(""); + if (FT->getReturnType() == Type::VoidTy) Name.clear(); + return new CallInst(FCache, Operands, Name, CI); +} + + void DefaultIntrinsicLowering::LowerIntrinsicCall(CallInst *CI) { Function *Callee = CI->getCalledFunction(); assert(Callee && "Cannot lower an indirect call!"); @@ -34,9 +77,10 @@ << Callee->getName() << "'!\n"; abort(); - // The default implementation of setjmp/longjmp transforms setjmp into a - // noop that always returns zero and longjmp into a call to abort. This - // allows code that never longjmps to work correctly. + // The setjmp/longjmp intrinsics should only exist in the code if it was + // never optimized (ie, right out of the CFE), or if it has been hacked on + // by the lowerinvoke pass. In both cases, the right thing to do is to + // convert the call to an explicit setjmp or longjmp call. case Intrinsic::setjmp: case Intrinsic::sigsetjmp: if (CI->getType() != Type::VoidTy) @@ -46,7 +90,9 @@ case Intrinsic::longjmp: case Intrinsic::siglongjmp: // Insert the call to abort - new CallInst(M->getOrInsertFunction("abort", Type::VoidTy, 0), "", CI); + static Function *AbortFCache = 0; + ReplaceCallWith("abort", CI, CI->op_end(), CI->op_end(), Type::VoidTy, + AbortFCache); break; case Intrinsic::returnaddress: @@ -67,47 +113,29 @@ CI->replaceAllUsesWith(Constant::getNullValue(CI->getType())); break; // Simply strip out debugging intrinsics - case Intrinsic::memcpy: { + case Intrinsic::memcpy: // The memcpy intrinsic take an extra alignment argument that the memcpy // libc function does not. - const FunctionType *CFT = Callee->getFunctionType(); - FunctionType *FT = - FunctionType::get(*CFT->param_begin(), - std::vector(CFT->param_begin(), CFT->param_end()-1), - false); - Function *MemCpy = M->getOrInsertFunction("memcpy", FT); - new CallInst(MemCpy, std::vector(CI->op_begin()+1, CI->op_end()-1), - CI->getName(), CI); + static Function *MemcpyFCache = 0; + ReplaceCallWith("memcpy", CI, CI->op_begin()+1, CI->op_end()-1, + (*(CI->op_begin()+1))->getType(), MemcpyFCache); break; - } - case Intrinsic::memmove: { + case Intrinsic::memmove: // The memmove intrinsic take an extra alignment argument that the memmove // libc function does not. - const FunctionType *CFT = Callee->getFunctionType(); - FunctionType *FT = - FunctionType::get(*CFT->param_begin(), - std::vector(CFT->param_begin(), CFT->param_end()-1), - false); - Function *MemMove = M->getOrInsertFunction("memmove", FT); - new CallInst(MemMove, std::vector(CI->op_begin()+1, CI->op_end()-1), - CI->getName(), CI); + static Function *MemmoveFCache = 0; + ReplaceCallWith("memmove", CI, CI->op_begin()+1, CI->op_end()-1, + (*(CI->op_begin()+1))->getType(), MemmoveFCache); break; - } - case Intrinsic::memset: { + case Intrinsic::memset: // The memset intrinsic take an extra alignment argument that the memset // libc function does not. - const FunctionType *CFT = Callee->getFunctionType(); - FunctionType *FT = - FunctionType::get(*CFT->param_begin(), - std::vector(CFT->param_begin(), CFT->param_end()-1), - false); - Function *MemSet = M->getOrInsertFunction("memset", FT); - new CallInst(MemSet, std::vector(CI->op_begin()+1, CI->op_end()-1), - CI->getName(), CI); + static Function *MemsetFCache = 0; + ReplaceCallWith("memset", CI, CI->op_begin()+1, CI->op_end()-1, + (*(CI->op_begin()+1))->getType(), MemsetFCache); break; } - } - + assert(CI->use_empty() && "Lowering should have eliminated any uses of the intrinsic call!"); CI->getParent()->getInstList().erase(CI); From lattner at cs.uiuc.edu Sun Feb 15 16:25:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun Feb 15 16:25:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/LowerInvoke.cpp Message-ID: <200402152224.QAA18262@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: LowerInvoke.cpp updated: 1.11 -> 1.12 --- Log message: Instead of producing calls to setjmp/longjmp, produce uses of the llvm.setjmp/llvm.longjmp intrinsics. --- Diffs of the changes: (+2 -2) Index: llvm/lib/Transforms/Scalar/LowerInvoke.cpp diff -u llvm/lib/Transforms/Scalar/LowerInvoke.cpp:1.11 llvm/lib/Transforms/Scalar/LowerInvoke.cpp:1.12 --- llvm/lib/Transforms/Scalar/LowerInvoke.cpp:1.11 Fri Feb 13 10:16:16 2004 +++ llvm/lib/Transforms/Scalar/LowerInvoke.cpp Sun Feb 15 16:24:27 2004 @@ -108,9 +108,9 @@ GlobalValue::LinkOnceLinkage, Constant::getNullValue(PtrJBList), "llvm.sjljeh.jblist", &M); - SetJmpFn = M.getOrInsertFunction("setjmp", Type::IntTy, + SetJmpFn = M.getOrInsertFunction("llvm.setjmp", Type::IntTy, PointerType::get(JmpBufTy), 0); - LongJmpFn = M.getOrInsertFunction("longjmp", Type::VoidTy, + LongJmpFn = M.getOrInsertFunction("llvm.longjmp", Type::VoidTy, PointerType::get(JmpBufTy), Type::IntTy, 0); From lattner at cs.uiuc.edu Sun Feb 15 16:26:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun Feb 15 16:26:01 2004 Subject: [llvm-commits] CVS: llvm/lib/VMCore/IntrinsicLowering.cpp Message-ID: <200402152225.QAA18454@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: IntrinsicLowering.cpp updated: 1.10 -> 1.11 --- Log message: By default, llvm.setjmp/llvm.longjmp intrinsics get lowered to their libc counterparts --- Diffs of the changes: (+15 -3) Index: llvm/lib/VMCore/IntrinsicLowering.cpp diff -u llvm/lib/VMCore/IntrinsicLowering.cpp:1.10 llvm/lib/VMCore/IntrinsicLowering.cpp:1.11 --- llvm/lib/VMCore/IntrinsicLowering.cpp:1.10 Sun Feb 15 16:16:39 2004 +++ llvm/lib/VMCore/IntrinsicLowering.cpp Sun Feb 15 16:24:51 2004 @@ -81,13 +81,25 @@ // never optimized (ie, right out of the CFE), or if it has been hacked on // by the lowerinvoke pass. In both cases, the right thing to do is to // convert the call to an explicit setjmp or longjmp call. - case Intrinsic::setjmp: - case Intrinsic::sigsetjmp: + case Intrinsic::setjmp: { + static Function *SetjmpFCache = 0; + Value *V = ReplaceCallWith("setjmp", CI, CI->op_begin()+1, CI->op_end(), + Type::IntTy, SetjmpFCache); if (CI->getType() != Type::VoidTy) - CI->replaceAllUsesWith(Constant::getNullValue(CI->getType())); + CI->replaceAllUsesWith(V); break; + } + case Intrinsic::sigsetjmp: + if (CI->getType() != Type::VoidTy) + CI->replaceAllUsesWith(Constant::getNullValue(CI->getType())); + break; case Intrinsic::longjmp: + static Function *LongjmpFCache = 0; + ReplaceCallWith("longjmp", CI, CI->op_begin()+1, CI->op_end(), + Type::VoidTy, LongjmpFCache); + break; + case Intrinsic::siglongjmp: // Insert the call to abort static Function *AbortFCache = 0; From lattner at cs.uiuc.edu Sun Feb 15 16:52:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun Feb 15 16:52:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/CBackend/Writer.cpp Message-ID: <200402152251.QAA26783@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/CBackend: Writer.cpp updated: 1.161 -> 1.162 --- Log message: Now that the lowerinvoke pass inserts calls to llvm.setjmp/llvm.longjmp, some hacks can be banished. Also, this gives us the opportunity to emit special code for the setjmp/longjmps which alows the elimination of one GCC warning for every setjmp/longjmp site (which is often THOUSANDS in C++ programs). Yaay! --- Diffs of the changes: (+15 -2) Index: llvm/lib/Target/CBackend/Writer.cpp diff -u llvm/lib/Target/CBackend/Writer.cpp:1.161 llvm/lib/Target/CBackend/Writer.cpp:1.162 --- llvm/lib/Target/CBackend/Writer.cpp:1.161 Sat Feb 14 23:54:27 2004 +++ llvm/lib/Target/CBackend/Writer.cpp Sun Feb 15 16:51:47 2004 @@ -686,8 +686,7 @@ Out << "\n/* Function Declarations */\n"; for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) { // Don't print declarations for intrinsic functions. - if (!I->getIntrinsicID() && - I->getName() != "setjmp" && I->getName() != "longjmp") { + if (!I->getIntrinsicID()) { printFunctionSignature(I, true); if (I->hasWeakLinkage()) Out << " __ATTRIBUTE_WEAK__"; Out << ";\n"; @@ -1187,6 +1186,8 @@ case Intrinsic::va_end: case Intrinsic::returnaddress: case Intrinsic::frameaddress: + case Intrinsic::setjmp: + case Intrinsic::longjmp: // We directly implement these intrinsics break; default: @@ -1243,6 +1244,18 @@ case Intrinsic::frameaddress: Out << "__builtin_frame_address("; writeOperand(I.getOperand(1)); + Out << ")"; + return; + case Intrinsic::setjmp: + Out << "setjmp(*(jmp_buf*)"; + writeOperand(I.getOperand(1)); + Out << ")"; + return; + case Intrinsic::longjmp: + Out << "longjmp(*(jmp_buf*)"; + writeOperand(I.getOperand(1)); + Out << ", "; + writeOperand(I.getOperand(2)); Out << ")"; return; } From lattner at cs.uiuc.edu Sun Feb 15 16:55:00 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun Feb 15 16:55:00 2004 Subject: [llvm-commits] CVS: llvm/tools/llc/llc.cpp Message-ID: <200402152254.QAA28312@zion.cs.uiuc.edu> Changes in directory llvm/tools/llc: llc.cpp updated: 1.90 -> 1.91 --- Log message: When the user runs 'llc foo.bc -march=c', write the output to "foo.cbe.c", not to "foo.s". --- Diffs of the changes: (+5 -1) Index: llvm/tools/llc/llc.cpp diff -u llvm/tools/llc/llc.cpp:1.90 llvm/tools/llc/llc.cpp:1.91 --- llvm/tools/llc/llc.cpp:1.90 Fri Feb 13 17:19:09 2004 +++ llvm/tools/llc/llc.cpp Sun Feb 15 16:54:19 2004 @@ -164,7 +164,11 @@ Out = &std::cout; } else { OutputFilename = GetFileNameRoot(InputFilename); - OutputFilename += ".s"; + + if (Arch != CBackend) + OutputFilename += ".s"; + else + OutputFilename += ".cbe.c"; if (!Force && std::ifstream(OutputFilename.c_str())) { // If force is not specified, make sure not to overwrite a file! From lattner at cs.uiuc.edu Sun Feb 15 16:56:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun Feb 15 16:56:01 2004 Subject: [llvm-commits] CVS: llvm/test/Regression/CodeGen/CBackend/ Message-ID: <200402152255.QAA28413@zion.cs.uiuc.edu> Changes in directory llvm/test/Regression/CodeGen/CBackend: --- Log message: Directory /home/vadve/shared/PublicCVS/llvm/test/Regression/CodeGen/CBackend added to the repository --- Diffs of the changes: (+0 -0) From lattner at cs.uiuc.edu Sun Feb 15 16:57:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun Feb 15 16:57:02 2004 Subject: [llvm-commits] CVS: llvm/test/Regression/CBackend/2002-05-16-NameCollide.ll 2002-05-21-MissingReturn.ll 2002-08-19-ConstPointerRef.ll 2002-08-19-ConstantExpr.ll 2002-08-19-DataPointer.ll 2002-08-19-FunctionPointer.ll 2002-08-19-HardConstantExpr.ll 2002-08-20-RecursiveTypes.ll 2002-08-20-UnnamedArgument.ll 2002-08-26-IndirectCallTest.ll 2002-08-30-StructureOrderingTest.ll 2002-09-20-ArrayTypeFailure.ll 2002-09-20-VarArgPrototypes.ll 2002-10-15-OpaqueTypeProblem.ll 2002-10-16-External.ll 2002-10-30-FunctionPointerAlloca.ll 2002-11-06-PrintEscaped.ll 2003-05-12-IntegerSizeWarning.ll 2003-05-13-VarArgFunction.ll 2003-05-31-MissingStructName.ll 2003-06-01-NullPointerType.ll 2003-06-11-HexConstant.ll 2003-06-11-LiteralStringProblem.ll 2003-06-23-PromotedExprs.llx 2003-06-28-InvokeSupport.ll 2003-06-28-LinkOnceGlobalVars.llx 2003-10-12-NANGlobalInits.ll 2003-10-23-UnusedType.ll 2003-10-23-ZeroArgVarargs.ll 2003-10-28-CastToPtrToStruct.ll 2003-11-21-ConstantShiftExpr.ll 2004-02-13-FrameR! eturnAddress.llx 2004-02-15-PreexistingExternals.llx Message-ID: <200402152256.QAA28707@zion.cs.uiuc.edu> Changes in directory llvm/test/Regression/CBackend: 2002-05-16-NameCollide.ll (r1.1) removed 2002-05-21-MissingReturn.ll (r1.1) removed 2002-08-19-ConstPointerRef.ll (r1.1) removed 2002-08-19-ConstantExpr.ll (r1.2) removed 2002-08-19-DataPointer.ll (r1.1) removed 2002-08-19-FunctionPointer.ll (r1.1) removed 2002-08-19-HardConstantExpr.ll (r1.2) removed 2002-08-20-RecursiveTypes.ll (r1.1) removed 2002-08-20-UnnamedArgument.ll (r1.1) removed 2002-08-26-IndirectCallTest.ll (r1.2) removed 2002-08-30-StructureOrderingTest.ll (r1.1) removed 2002-09-20-ArrayTypeFailure.ll (r1.1) removed 2002-09-20-VarArgPrototypes.ll (r1.1) removed 2002-10-15-OpaqueTypeProblem.ll (r1.2) removed 2002-10-16-External.ll (r1.1) removed 2002-10-30-FunctionPointerAlloca.ll (r1.1) removed 2002-11-06-PrintEscaped.ll (r1.1) removed 2003-05-12-IntegerSizeWarning.ll (r1.1) removed 2003-05-13-VarArgFunction.ll (r1.1) removed 2003-05-31-MissingStructName.ll (r1.1) removed 2003-06-01-NullPointerType.ll (r1.1) removed 2003-06-11-HexConstant.ll (r1.1) removed 2003-06-11-LiteralStringProblem.ll (r1.1) removed 2003-06-23-PromotedExprs.llx (r1.5) removed 2003-06-28-InvokeSupport.ll (r1.1) removed 2003-06-28-LinkOnceGlobalVars.llx (r1.3) removed 2003-10-12-NANGlobalInits.ll (r1.1) removed 2003-10-23-UnusedType.ll (r1.1) removed 2003-10-23-ZeroArgVarargs.ll (r1.1) removed 2003-10-28-CastToPtrToStruct.ll (r1.1) removed 2003-11-21-ConstantShiftExpr.ll (r1.2) removed 2004-02-13-FrameReturnAddress.llx (r1.1) removed 2004-02-15-PreexistingExternals.llx (r1.1) removed --- Log message: Moving CBE tests to test/Regression/CodeGen/CBackend --- Diffs of the changes: (+0 -0) From lattner at cs.uiuc.edu Sun Feb 15 17:10:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun Feb 15 17:10:01 2004 Subject: [llvm-commits] CVS: llvm/docs/ReleaseNotes.html Message-ID: <200402152309.RAA32465@zion.cs.uiuc.edu> Changes in directory llvm/docs: ReleaseNotes.html updated: 1.127 -> 1.128 --- Log message: Document bug 240 --- Diffs of the changes: (+7 -7) Index: llvm/docs/ReleaseNotes.html diff -u llvm/docs/ReleaseNotes.html:1.127 llvm/docs/ReleaseNotes.html:1.128 --- llvm/docs/ReleaseNotes.html:1.127 Sun Feb 15 00:00:04 2004 +++ llvm/docs/ReleaseNotes.html Sun Feb 15 17:09:07 2004 @@ -262,12 +262,12 @@
  • LLVM cannot handle structures with more than 256 elements.
  • -
  • -The gccld program - -does not link objects/archives in the order specified on the command line. - -
  • +
  • The gccld program does not link objects/archives in the order specified on the command line.
  • + +
  • The lower-invoke pass does not mark +values live across a setjmp as volatile. This missing feature only effects +targets whose setjmp/longjmp libraries do not save and restore the entire +register file.
  • @@ -582,7 +582,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/02/15 06:00:04 $ + Last modified: $Date: 2004/02/15 23:09:07 $ From lattner at cs.uiuc.edu Sun Feb 15 17:34:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun Feb 15 17:34:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Support/LeakDetector.cpp Message-ID: <200402152333.RAA02080@zion.cs.uiuc.edu> Changes in directory llvm/lib/Support: LeakDetector.cpp updated: 1.7 -> 1.8 --- Log message: Fix a bug in the recent rewrite of the leakdetector that caused all of the nightly tests to be really messed up. The problem was that the new leakdetector was depending on undefined behavior: the order of destruction of static objects. --- Diffs of the changes: (+10 -7) Index: llvm/lib/Support/LeakDetector.cpp diff -u llvm/lib/Support/LeakDetector.cpp:1.7 llvm/lib/Support/LeakDetector.cpp:1.8 --- llvm/lib/Support/LeakDetector.cpp:1.7 Sat Feb 14 17:33:39 2004 +++ llvm/lib/Support/LeakDetector.cpp Sun Feb 15 17:33:48 2004 @@ -17,7 +17,6 @@ using namespace llvm; namespace { - template struct LeakDetectorImpl { LeakDetectorImpl(const char* const name) : Cache(0), Name(name) { } @@ -64,21 +63,25 @@ private: std::set Ts; - const T* Cache; - const char* const Name; + const T* Cache; + const char* const Name; }; typedef LeakDetectorImpl Objects; typedef LeakDetectorImpl LLVMObjects; Objects& getObjects() { - static Objects o("GENERIC"); - return o; + static Objects *o = 0; + if (o == 0) + o = new Objects("GENERIC"); + return *o; } LLVMObjects& getLLVMObjects() { - static LLVMObjects o("LLVM"); - return o; + static LLVMObjects *o = 0; + if (o == 0) + o = new LLVMObjects("LLVM"); + return *o; } } From lattner at cs.uiuc.edu Sun Feb 15 19:21:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun Feb 15 19:21:01 2004 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/InstCombine/xor.ll Message-ID: <200402160120.TAA06950@zion.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/InstCombine: xor.ll updated: 1.10 -> 1.11 --- Log message: Test for xor chains --- Diffs of the changes: (+6 -0) Index: llvm/test/Regression/Transforms/InstCombine/xor.ll diff -u llvm/test/Regression/Transforms/InstCombine/xor.ll:1.10 llvm/test/Regression/Transforms/InstCombine/xor.ll:1.11 --- llvm/test/Regression/Transforms/InstCombine/xor.ll:1.10 Tue Nov 4 19:05:22 2003 +++ llvm/test/Regression/Transforms/InstCombine/xor.ll Sun Feb 15 19:19:52 2004 @@ -122,3 +122,9 @@ %C = sub uint 123, %B ret uint %C } + +uint %test19(uint %A, uint %B) { + %C = xor uint %A, %B + %D = xor uint %C, %A ; A terms cancel, D = B + ret uint %D +} From lattner at cs.uiuc.edu Sun Feb 15 19:21:14 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun Feb 15 19:21:14 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp Message-ID: <200402160120.TAA07034@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: InstructionCombining.cpp updated: 1.152 -> 1.153 --- Log message: Implement Transforms/InstCombine/xor.ll:test19 --- Diffs of the changes: (+13 -2) Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.152 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.153 --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.152 Sat Feb 14 23:55:10 2004 +++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Sun Feb 15 19:20:27 2004 @@ -1002,15 +1002,26 @@ return Changed ? &I : 0; } +// XorSelf - Implements: X ^ X --> 0 +struct XorSelf { + Value *RHS; + XorSelf(Value *rhs) : RHS(rhs) {} + bool shouldApply(Value *LHS) const { return LHS == RHS; } + Instruction *apply(BinaryOperator &Xor) const { + return &Xor; + } +}; Instruction *InstCombiner::visitXor(BinaryOperator &I) { bool Changed = SimplifyCommutative(I); Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1); - // xor X, X = 0 - if (Op0 == Op1) + // xor X, X = 0, even if X is nested in a sequence of Xor's. + if (Instruction *Result = AssociativeOpt(I, XorSelf(Op1))) { + assert(Result == &I && "AssociativeOpt didn't work?"); return ReplaceInstUsesWith(I, Constant::getNullValue(I.getType())); + } if (ConstantIntegral *RHS = dyn_cast(Op1)) { // xor X, 0 == X From lattner at cs.uiuc.edu Sun Feb 15 21:54:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun Feb 15 21:54:01 2004 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/InstCombine/xor.ll Message-ID: <200402160353.VAA03499@zion.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/InstCombine: xor.ll updated: 1.11 -> 1.12 --- Log message: Add a test for the "swap idiom", which LLVM should be able to unravel. --- Diffs of the changes: (+14 -0) Index: llvm/test/Regression/Transforms/InstCombine/xor.ll diff -u llvm/test/Regression/Transforms/InstCombine/xor.ll:1.11 llvm/test/Regression/Transforms/InstCombine/xor.ll:1.12 --- llvm/test/Regression/Transforms/InstCombine/xor.ll:1.11 Sun Feb 15 19:19:52 2004 +++ llvm/test/Regression/Transforms/InstCombine/xor.ll Sun Feb 15 21:53:44 2004 @@ -3,6 +3,9 @@ ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep 'xor ' +%G1 = global uint 0 +%G2 = global uint 0 + implementation bool %test0(bool %A) { @@ -128,3 +131,14 @@ %D = xor uint %C, %A ; A terms cancel, D = B ret uint %D } + +void %test20(uint %A, uint %B) { ; The "swap idiom" + %tmp.2 = xor uint %B, %A + %tmp.5 = xor uint %tmp.2, %B + %tmp.8 = xor uint %tmp.5, %tmp.2 + store uint %tmp.8, uint* %G1 ; tmp.8 = B + store uint %tmp.5, uint* %G2 ; tmp.5 = A + ret void +} + + From lattner at cs.uiuc.edu Sun Feb 15 21:55:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun Feb 15 21:55:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp Message-ID: <200402160354.VAA03512@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: InstructionCombining.cpp updated: 1.153 -> 1.154 --- Log message: Teach LLVM to unravel the "swap idiom". This implements: Regression/Transforms/InstCombine/xor.ll:test20 --- Diffs of the changes: (+13 -2) Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.153 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.154 --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.153 Sun Feb 15 19:20:27 2004 +++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Sun Feb 15 21:54:20 2004 @@ -1086,7 +1086,7 @@ ConstantIntegral::getAllOnesValue(I.getType())); if (Instruction *Op1I = dyn_cast(Op1)) - if (Op1I->getOpcode() == Instruction::Or) + if (Op1I->getOpcode() == Instruction::Or) { if (Op1I->getOperand(0) == Op0) { // B^(B|A) == (A|B)^B cast(Op1I)->swapOperands(); I.swapOperands(); @@ -1094,7 +1094,13 @@ } else if (Op1I->getOperand(1) == Op0) { // B^(A|B) == (A|B)^B I.swapOperands(); std::swap(Op0, Op1); - } + } + } else if (Op1I->getOpcode() == Instruction::Xor) { + if (Op0 == Op1I->getOperand(0)) // A^(A^B) == B + return ReplaceInstUsesWith(I, Op1I->getOperand(1)); + else if (Op0 == Op1I->getOperand(1)) // A^(B^A) == B + return ReplaceInstUsesWith(I, Op1I->getOperand(0)); + } if (Instruction *Op0I = dyn_cast(Op0)) if (Op0I->getOpcode() == Instruction::Or && Op0I->hasOneUse()) { @@ -1106,6 +1112,11 @@ return BinaryOperator::create(Instruction::And, Op0I->getOperand(0), NotB); } + } else if (Op0I->getOpcode() == Instruction::Xor) { + if (Op1 == Op0I->getOperand(0)) // (A^B)^A == B + return ReplaceInstUsesWith(I, Op0I->getOperand(1)); + else if (Op1 == Op0I->getOperand(1)) // (B^A)^A == B + return ReplaceInstUsesWith(I, Op0I->getOperand(0)); } // (A & C1)^(B & C2) -> (A & C1)|(B & C2) iff C1^C2 == 0 From lattner at cs.uiuc.edu Sun Feb 15 23:07:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun Feb 15 23:07:01 2004 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/InstCombine/phi.ll Message-ID: <200402160506.XAA08798@zion.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/InstCombine: phi.ll updated: 1.7 -> 1.8 --- Log message: A new testcase for a situation that occurs in 181.mcf --- Diffs of the changes: (+12 -0) Index: llvm/test/Regression/Transforms/InstCombine/phi.ll diff -u llvm/test/Regression/Transforms/InstCombine/phi.ll:1.7 llvm/test/Regression/Transforms/InstCombine/phi.ll:1.8 --- llvm/test/Regression/Transforms/InstCombine/phi.ll:1.7 Tue Sep 16 10:29:34 2003 +++ llvm/test/Regression/Transforms/InstCombine/phi.ll Sun Feb 15 23:06:36 2004 @@ -43,3 +43,15 @@ br label %Loop } +bool %test4(bool %A) { + br bool %A, label %BB1, label %BB2 +BB1: + br label %Ret +BB2: + br label %Ret +Ret: + %B = phi int [1000, %BB1], [123, %BB2] + %C = cast int %B to bool + ret bool %C +} + From lattner at cs.uiuc.edu Sun Feb 15 23:08:00 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun Feb 15 23:08:00 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp Message-ID: <200402160507.XAA08813@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: InstructionCombining.cpp updated: 1.154 -> 1.155 --- Log message: Fold PHI nodes of constants which are only used by a single cast. This implements phi.ll:test4 --- Diffs of the changes: (+29 -0) Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.154 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.155 --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.154 Sun Feb 15 21:54:20 2004 +++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Sun Feb 15 23:07:08 2004 @@ -1968,6 +1968,35 @@ Instruction *InstCombiner::visitPHINode(PHINode &PN) { if (Value *V = hasConstantValue(&PN)) return ReplaceInstUsesWith(PN, V); + + // If the only user of this instruction is a cast instruction, and all of the + // incoming values are constants, change this PHI to merge together the casted + // constants. + if (PN.hasOneUse()) + if (CastInst *CI = dyn_cast(PN.use_back())) + if (CI->getType() != PN.getType()) { // noop casts will be folded + bool AllConstant = true; + for (unsigned i = 0, e = PN.getNumIncomingValues(); i != e; ++i) + if (!isa(PN.getIncomingValue(i))) { + AllConstant = false; + break; + } + if (AllConstant) { + // Make a new PHI with all casted values. + PHINode *New = new PHINode(CI->getType(), PN.getName(), &PN); + for (unsigned i = 0, e = PN.getNumIncomingValues(); i != e; ++i) { + Constant *OldArg = cast(PN.getIncomingValue(i)); + New->addIncoming(ConstantExpr::getCast(OldArg, New->getType()), + PN.getIncomingBlock(i)); + } + + // Update the cast instruction. + CI->setOperand(0, New); + WorkList.push_back(CI); // revisit the cast instruction to fold. + WorkList.push_back(New); // Make sure to revisit the new Phi + return &PN; // PN is now dead! + } + } return 0; }