From lattner at cs.uiuc.edu Mon Oct 14 01:13:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Oct 14 01:13:01 2002 Subject: [llvm-commits] CVS: llvm/test/Makefile.tests Message-ID: <200210140612.BAA04778@apoc.cs.uiuc.edu> Changes in directory llvm/test: Makefile.tests updated: 1.46 -> 1.47 --- Log message: MAke sure llc output is regenerated if the LLC binary changes. --- Diffs of the changes: Index: llvm/test/Makefile.tests diff -u llvm/test/Makefile.tests:1.46 llvm/test/Makefile.tests:1.47 --- llvm/test/Makefile.tests:1.46 Mon Sep 30 14:23:22 2002 +++ llvm/test/Makefile.tests Mon Oct 14 01:12:10 2002 @@ -90,7 +90,7 @@ # Compile a linked program to machine code for this processor. # -Output/%.llc.s: Output/%.llvm.bc +Output/%.llc.s: Output/%.llvm.bc $(LLC) $(LLC) $(LLCFLAGS) -f $< -o $@ # Assemble (and link) an LLVM-linked program using the system assembler... From lattner at cs.uiuc.edu Mon Oct 14 01:15:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Oct 14 01:15:01 2002 Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/EmitAssembly.cpp Message-ID: <200210140614.BAA04791@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/Sparc: EmitAssembly.cpp updated: 1.61 -> 1.62 --- Log message: Allow emission of names that start with an underscore. This is needed to interface with code that uses symbols in the ansi-c protected namespace. In most cases this comes from system header files, such as stdio.h. In particular, without this change, a reference to the __iob symbol is mangled into ll_iob, which is not resolved by libc. --- Diffs of the changes: Index: llvm/lib/Target/Sparc/EmitAssembly.cpp diff -u llvm/lib/Target/Sparc/EmitAssembly.cpp:1.61 llvm/lib/Target/Sparc/EmitAssembly.cpp:1.62 --- llvm/lib/Target/Sparc/EmitAssembly.cpp:1.61 Sat Oct 12 19:32:18 2002 +++ llvm/lib/Target/Sparc/EmitAssembly.cpp Mon Oct 14 01:14:18 2002 @@ -15,7 +15,6 @@ #include "llvm/CodeGen/MachineInstr.h" #include "llvm/CodeGen/MachineCodeForBasicBlock.h" #include "llvm/CodeGen/MachineCodeForMethod.h" -#include "llvm/GlobalVariable.h" #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" #include "llvm/Module.h" @@ -23,7 +22,6 @@ #include "llvm/Pass.h" #include "llvm/Assembly/Writer.h" #include "Support/StringExtras.h" -#include using std::string; namespace { @@ -110,16 +108,15 @@ toAsm << "\n"; } - static std::string getValidSymbolName(const string &S) { + static string getValidSymbolName(const string &S) { string Result; // Symbol names in Sparc assembly language have these rules: // (a) Must match { letter | _ | . | $ } { letter | _ | . | $ | digit }* // (b) A name beginning in "." is treated as a local name. - // (c) Names beginning with "_" are reserved by ANSI C and shd not be used. // - if (S[0] == '_' || isdigit(S[0])) - Result += "ll"; + if (isdigit(S[0])) + Result = "ll"; for (unsigned i = 0; i < S.size(); ++i) { @@ -186,10 +183,9 @@ // ConstantExprToString() - Convert a ConstantExpr to an asm expression // and return this as a string. - std::string ConstantExprToString(const ConstantExpr* CE, - const TargetMachine& target) { - std::string S; - + string ConstantExprToString(const ConstantExpr* CE, + const TargetMachine& target) { + string S; switch(CE->getOpcode()) { case Instruction::GetElementPtr: { // generate a symbolic expression for the byte address @@ -225,13 +221,13 @@ // valToExprString - Helper function for ConstantExprToString(). // Appends result to argument string S. // - std::string valToExprString(const Value* V, const TargetMachine& target) { - std::string S; + string valToExprString(const Value* V, const TargetMachine& target) { + string S; bool failed = false; if (const Constant* CV = dyn_cast(V)) { // symbolic or known if (const ConstantBool *CB = dyn_cast(CV)) - S += std::string(CB == ConstantBool::True ? "1" : "0"); + S += string(CB == ConstantBool::True ? "1" : "0"); else if (const ConstantSInt *CI = dyn_cast(CV)) S += itostr(CI->getValue()); else if (const ConstantUInt *CI = dyn_cast(CV)) @@ -547,7 +543,7 @@ void PrintZeroBytesToPad (int numBytes); void printSingleConstantValue (const Constant* CV); void printConstantValueOnly (const Constant* CV, int numPadBytes = 0); - void printConstant (const Constant* CV, std::string valID = ""); + void printConstant (const Constant* CV, string valID = ""); static void FoldConstants (const Module &M, hash_set &moduleConstants); From lattner at cs.uiuc.edu Mon Oct 14 01:21:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Oct 14 01:21:01 2002 Subject: [llvm-commits] CVS: llvm/test/Programs/MultiSource/OptimizerEval/main.c Message-ID: <200210140620.BAA04876@apoc.cs.uiuc.edu> Changes in directory llvm/test/Programs/MultiSource/OptimizerEval: main.c updated: 1.1 -> 1.2 --- Log message: Change the timing loop count to be an amout that is reasonable to run with an llc generated binary on trinity. --- Diffs of the changes: Index: llvm/test/Programs/MultiSource/OptimizerEval/main.c diff -u llvm/test/Programs/MultiSource/OptimizerEval/main.c:1.1 llvm/test/Programs/MultiSource/OptimizerEval/main.c:1.2 --- llvm/test/Programs/MultiSource/OptimizerEval/main.c:1.1 Wed Jan 23 14:25:09 2002 +++ llvm/test/Programs/MultiSource/OptimizerEval/main.c Mon Oct 14 01:20:09 2002 @@ -3,7 +3,7 @@ #define CUTOFF 2.552 -#define SLOW_FACTOR 2.0 +#define SLOW_FACTOR 10.0 /* SLOW_FACTOR was 100.0 for stock benchmark */ clock_t ticks_per_sec = 0; From vadve at cs.uiuc.edu Mon Oct 14 09:54:00 2002 From: vadve at cs.uiuc.edu (Vikram Adve) Date: Mon Oct 14 09:54:00 2002 Subject: [llvm-commits] CVS: llvm/test/Regression/LLC/yyparse.Burg.BadRegAlloc.ll Message-ID: <200210141453.JAA03768@psmith.cs.uiuc.edu> Changes in directory llvm/test/Regression/LLC: yyparse.Burg.BadRegAlloc.ll added (r1.1) --- Log message: Test case that shows some poor results for register allocation. --- Diffs of the changes: From vadve at cs.uiuc.edu Mon Oct 14 11:32:01 2002 From: vadve at cs.uiuc.edu (Vikram Adve) Date: Mon Oct 14 11:32:01 2002 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp Message-ID: <200210141631.LAA04956@psmith.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/InstrSelection: InstrSelectionSupport.cpp updated: 1.34 -> 1.35 --- Log message: Significant improvement: GEP used by a load or store no longer generates a separate ADD; instead just use the indexed load/store instruction! Also, a bug fix: folding a GEP with a leading non-zero index with its predecessor was incorrect: now it only happens if the predecessor is pointing to an indexable type (aka SequentialType). --- Diffs of the changes: Index: llvm/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp diff -u llvm/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp:1.34 llvm/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp:1.35 --- llvm/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp:1.34 Sun Sep 29 17:55:05 2002 +++ llvm/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp Mon Oct 14 11:30:55 2002 @@ -154,14 +154,14 @@ assert((*firstIdx)->getType() == Type::LongTy && "INTERNAL ERROR: Structure index for a pointer type!"); - // If the last instruction had a leading non-zero index, - // check if the current one ends with an array index. If not, - // the code is not type-safe and we would create an illegal GEP + // If the last instruction had a leading non-zero index, check if the + // current one references a sequential (i.e., indexable) type. + // If not, the code is not type-safe and we would create an illegal GEP // by folding them, so don't fold any more instructions. // if (lastInstHasLeadingNonZero) - if (firstIdx != lastIdx && (*(lastIdx-1))->getType() != Type::LongTy) - break; // cannot fold in any preceding getElementPtr instrs. + if (! isa(gepInst->getType()->getElementType())) + break; // cannot fold in any preceding getElementPtr instrs. // Check that all offsets are constant for this instruction for (OI = firstIdx; allConstantOffsets && OI != lastIdx; ++OI) @@ -198,6 +198,56 @@ //--------------------------------------------------------------------------- +// Function: GetGEPInstArgs +// +// Purpose: +// Helper function for GetMemInstArgs that handles the final getElementPtr +// instruction used by (or same as) the memory operation. +// Extracts the indices of the current instruction and tries to fold in +// preceding ones if all indices of the current one are constant. +//--------------------------------------------------------------------------- + +Value* +GetGEPInstArgs(InstructionNode* gepNode, + vector& idxVec, + bool& allConstantIndices) +{ + allConstantIndices = true; + GetElementPtrInst* gepI = cast(gepNode->getInstruction()); + + // Default pointer is the one from the current instruction. + Value* ptrVal = gepI->getPointerOperand(); + InstrTreeNode* ptrChild = gepNode->leftChild(); + + // Extract the index vector of the GEP instructin. + // If all indices are constant and first index is zero, try to fold + // in preceding GEPs with all constant indices. + for (User::op_iterator OI=gepI->idx_begin(), OE=gepI->idx_end(); + allConstantIndices && OI != OE; ++OI) + if (! isa(*OI)) + allConstantIndices = false; // note: this also terminates loop! + + // If we have only constant indices, fold chains of constant indices + // in this and any preceding GetElemPtr instructions. + bool foldedGEPs = false; + bool leadingNonZeroIdx = gepI && ! IsZero(*gepI->idx_begin()); + if (allConstantIndices) + if (Value* newPtr = FoldGetElemChain(ptrChild, idxVec, leadingNonZeroIdx)) + { + ptrVal = newPtr; + foldedGEPs = true; + } + + // Append the index vector of the current instruction. + // Skip the leading [0] index if preceding GEPs were folded into this. + idxVec.insert(idxVec.end(), + gepI->idx_begin() + (foldedGEPs && !leadingNonZeroIdx), + gepI->idx_end()); + + return ptrVal; +} + +//--------------------------------------------------------------------------- // Function: GetMemInstArgs // // Purpose: @@ -215,11 +265,11 @@ //--------------------------------------------------------------------------- Value* -GetMemInstArgs(const InstructionNode* memInstrNode, +GetMemInstArgs(InstructionNode* memInstrNode, vector& idxVec, bool& allConstantIndices) { - allConstantIndices = true; + allConstantIndices = false; Instruction* memInst = memInstrNode->getInstruction(); assert(idxVec.size() == 0 && "Need empty vector to return indices"); @@ -229,40 +279,28 @@ InstrTreeNode* ptrChild = (memInst->getOpcode() == Instruction::Store ? memInstrNode->rightChild() : memInstrNode->leftChild()); - + // Default pointer is the one from the current instruction. Value* ptrVal = ptrChild->getValue(); - // GEP is the only indexed memory instruction. Extract its index vector. - // Also, if all indices are constant and first index is zero, try to fold - // in preceding GEPs with all constant indices. - GetElementPtrInst* gepI = dyn_cast(memInst); - if (gepI) - for (User::op_iterator OI=gepI->idx_begin(), OE=gepI->idx_end(); - allConstantIndices && OI != OE; ++OI) - if (! isa(*OI)) - allConstantIndices = false; // note: this also terminates loop! - - // If we have only constant indices, fold chains of constant indices - // in this and any preceding GetElemPtr instructions. - bool foldedGEPs = false; - bool leadingNonZeroIdx = gepI && ! IsZero(*gepI->idx_begin()); - if (allConstantIndices) - if (Value* newPtr = FoldGetElemChain(ptrChild, idxVec, leadingNonZeroIdx)) - { - ptrVal = newPtr; - foldedGEPs = true; - } - - // Append the index vector of the current instruction, if any. - // Skip the leading [0] index if preceding GEPs were folded into this. - if (gepI) - idxVec.insert(idxVec.end(), - gepI->idx_begin() + (foldedGEPs && !leadingNonZeroIdx), - gepI->idx_end()); + // Find the "last" GetElemPtr instruction: this one or the immediate child. + // There will be none if this is a load or a store from a scalar pointer. + InstructionNode* gepNode = NULL; + if (isa(memInst)) + gepNode = memInstrNode; + else if (isa(ptrChild) && isa(ptrVal)) + { // Child of load/store is a GEP and memInst is its only use. + // Use its indices and mark it as folded. + gepNode = cast(ptrChild); + gepNode->markFoldedIntoParent(); + } - return ptrVal; + // If there are no indices, return the current pointer. + // Else extract the pointer from the GEP and fold the indices. + return (gepNode)? GetGEPInstArgs(gepNode, idxVec, allConstantIndices) + : ptrVal; } + //------------------------------------------------------------------------ // Function Set2OperandsFromInstr From vadve at cs.uiuc.edu Mon Oct 14 11:32:03 2002 From: vadve at cs.uiuc.edu (Vikram Adve) Date: Mon Oct 14 11:32:03 2002 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/InstrSelectionSupport.h Message-ID: <200210141631.LAA04970@psmith.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: InstrSelectionSupport.h updated: 1.14 -> 1.15 --- Log message: Removed misleading const keyword. --- Diffs of the changes: Index: llvm/include/llvm/CodeGen/InstrSelectionSupport.h diff -u llvm/include/llvm/CodeGen/InstrSelectionSupport.h:1.14 llvm/include/llvm/CodeGen/InstrSelectionSupport.h:1.15 --- llvm/include/llvm/CodeGen/InstrSelectionSupport.h:1.14 Sun Sep 29 17:55:45 2002 +++ llvm/include/llvm/CodeGen/InstrSelectionSupport.h Mon Oct 14 11:31:27 2002 @@ -53,7 +53,7 @@ // Returns true/false in allConstantIndices if all indices are/aren't const. //--------------------------------------------------------------------------- -Value* GetMemInstArgs (const InstructionNode* memInstrNode, +Value* GetMemInstArgs (InstructionNode* memInstrNode, vector& idxVec, bool& allConstantIndices); From vadve at cs.uiuc.edu Mon Oct 14 11:33:01 2002 From: vadve at cs.uiuc.edu (Vikram Adve) Date: Mon Oct 14 11:33:01 2002 Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/SparcRegInfo.cpp Message-ID: <200210141632.LAA04992@psmith.cs.uiuc.edu> Changes in directory llvm/lib/Target/Sparc: SparcRegInfo.cpp updated: 1.73 -> 1.74 --- Log message: Print "circular" warning message only in debug mode. --- Diffs of the changes: Index: llvm/lib/Target/Sparc/SparcRegInfo.cpp diff -u llvm/lib/Target/Sparc/SparcRegInfo.cpp:1.73 llvm/lib/Target/Sparc/SparcRegInfo.cpp:1.74 --- llvm/lib/Target/Sparc/SparcRegInfo.cpp:1.73 Sat Oct 12 19:05:30 2002 +++ llvm/lib/Target/Sparc/SparcRegInfo.cpp Mon Oct 14 11:32:49 2002 @@ -1733,9 +1733,8 @@ cpMem2RegMI(OrdVec, getFramePointer(), StackOff, DReg, RegType); - cerr << "\nFixed CIRCULAR references by reordering"; - if( DEBUG_RA ) { + cerr << "\nFixed CIRCULAR references by reordering:"; cerr << "\nBefore CIRCULAR Reordering:\n"; cerr << *UnordInst; cerr << *OrdInst; From vadve at cs.uiuc.edu Mon Oct 14 11:34:01 2002 From: vadve at cs.uiuc.edu (Vikram Adve) Date: Mon Oct 14 11:34:01 2002 Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/SparcInstrSelection.cpp Message-ID: <200210141633.LAA04997@psmith.cs.uiuc.edu> Changes in directory llvm/lib/Target/Sparc: SparcInstrSelection.cpp updated: 1.75 -> 1.76 --- Log message: Removed misleading const keyword. --- Diffs of the changes: Index: llvm/lib/Target/Sparc/SparcInstrSelection.cpp diff -u llvm/lib/Target/Sparc/SparcInstrSelection.cpp:1.75 llvm/lib/Target/Sparc/SparcInstrSelection.cpp:1.76 --- llvm/lib/Target/Sparc/SparcInstrSelection.cpp:1.75 Sat Oct 12 19:18:57 2002 +++ llvm/lib/Target/Sparc/SparcInstrSelection.cpp Mon Oct 14 11:32:24 2002 @@ -938,7 +938,7 @@ static void SetOperandsForMemInstr(vector& mvec, - const InstructionNode* vmInstrNode, + InstructionNode* vmInstrNode, const TargetMachine& target) { Instruction* memInst = vmInstrNode->getInstruction(); From vadve at cs.uiuc.edu Mon Oct 14 11:39:01 2002 From: vadve at cs.uiuc.edu (Vikram Adve) Date: Mon Oct 14 11:39:01 2002 Subject: [llvm-commits] CVS: llvm/test/Programs/MultiSource/Burg/ Message-ID: <200210141638.LAA05045@psmith.cs.uiuc.edu> Changes in directory llvm/test/Programs/MultiSource/Burg: --- Log message: Directory /home/vadve/vadve/Research/DynOpt/CVSRepository/llvm/test/Programs/MultiSource/Burg added to the repository --- Diffs of the changes: From vadve at cs.uiuc.edu Mon Oct 14 11:40:01 2002 From: vadve at cs.uiuc.edu (Vikram Adve) Date: Mon Oct 14 11:40:01 2002 Subject: [llvm-commits] CVS: llvm/test/Programs/MultiSource/Burg/be.c b.h burs.c closure.c COPYRIGHT delta.c doc.tex fe.c fe.h gram.y item.c lex.c list.c main.c Makefile Makefile.burg map.c nonterminal.c operator.c pattern.c plank.c queue.c README rule.c sample.gr string.c symtab.c table.c trim.c zalloc.c Message-ID: <200210141639.LAA05055@psmith.cs.uiuc.edu> Changes in directory llvm/test/Programs/MultiSource/Burg: be.c added (r1.1) b.h added (r1.1) burs.c added (r1.1) closure.c added (r1.1) COPYRIGHT added (r1.1) delta.c added (r1.1) doc.tex added (r1.1) fe.c added (r1.1) fe.h added (r1.1) gram.y added (r1.1) item.c added (r1.1) lex.c added (r1.1) list.c added (r1.1) main.c added (r1.1) Makefile added (r1.1) Makefile.burg added (r1.1) map.c added (r1.1) nonterminal.c added (r1.1) operator.c added (r1.1) pattern.c added (r1.1) plank.c added (r1.1) queue.c added (r1.1) README added (r1.1) rule.c added (r1.1) sample.gr added (r1.1) string.c added (r1.1) symtab.c added (r1.1) table.c added (r1.1) trim.c added (r1.1) zalloc.c added (r1.1) --- Log message: Sources, Makefiles and other files for Burg. Only the Makefile has been modified to work in our test harness. The original Makefile is in Makefile.burg. The test runs use the sample.gr file included in the release. --- Diffs of the changes: From vadve at cs.uiuc.edu Mon Oct 14 11:41:01 2002 From: vadve at cs.uiuc.edu (Vikram Adve) Date: Mon Oct 14 11:41:01 2002 Subject: [llvm-commits] CVS: llvm/Makefile.common Message-ID: <200210141640.LAA05073@psmith.cs.uiuc.edu> Changes in directory llvm: Makefile.common updated: 1.60 -> 1.61 --- Log message: Allow the Source variable to be overridden completely if needed. --- Diffs of the changes: Index: llvm/Makefile.common diff -u llvm/Makefile.common:1.60 llvm/Makefile.common:1.61 --- llvm/Makefile.common:1.60 Wed Sep 25 12:15:22 2002 +++ llvm/Makefile.common Mon Oct 14 11:40:04 2002 @@ -126,7 +126,7 @@ # Special tools used while building the LLVM tree. Burg is built as part of the # utils directory. # -BURG := $(TOOLDEBUG)/burg +BURG := $(LEVEL)/utils/Burg/burg.$(UNAME) RunBurg := $(BURG) $(BURG_OPTS) @@ -198,7 +198,9 @@ # source files... # The local Makefile can list other Source files via ExtraSource = ... # +ifndef Source Source := $(ExtraSource) $(wildcard *.cpp *.c *.y *.l) +endif Objs := $(sort $(patsubst Debug/%.o, %.o, $(addsuffix .o,$(basename $(Source))))) ObjectsO := $(addprefix $(BUILD_ROOT)/Release/,$(Objs)) From vadve at cs.uiuc.edu Mon Oct 14 11:43:01 2002 From: vadve at cs.uiuc.edu (Vikram Adve) Date: Mon Oct 14 11:43:01 2002 Subject: [llvm-commits] CVS: llvm/test/Programs/Makefile.programs Message-ID: <200210141642.LAA05198@psmith.cs.uiuc.edu> Changes in directory llvm/test/Programs: Makefile.programs updated: 1.16 -> 1.17 --- Log message: Simplify DISABLE_CBE and DISABLE_LLI flags. --- Diffs of the changes: Index: llvm/test/Programs/Makefile.programs diff -u llvm/test/Programs/Makefile.programs:1.16 llvm/test/Programs/Makefile.programs:1.17 --- llvm/test/Programs/Makefile.programs:1.16 Wed Oct 2 16:41:09 2002 +++ llvm/test/Programs/Makefile.programs Mon Oct 14 11:42:09 2002 @@ -73,8 +73,8 @@ ifdef RUN_GCC_ONLY DISABLE_LLC = 1 -DISABLE_CBE_DIFFS = 1 -ENABLE_LLI_DIFFS = +DISABLE_CBE = 1 +ENABLE_LLI = all:: $(GCCOUTPUT) endif @@ -88,11 +88,11 @@ all:: $(LLCDIFFS) endif -ifndef DISABLE_CBE_DIFFS +ifndef DISABLE_CBE all:: $(CBEDIFFS) endif -ifdef ENABLE_LLI_DIFFS +ifdef ENABLE_LLI all:: $(LLIDIFFS) endif From lattner at cs.uiuc.edu Mon Oct 14 17:42:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Oct 14 17:42:01 2002 Subject: [llvm-commits] CVS: llvm/include/llvm/Target/TargetData.h Message-ID: <200210142241.RAA06431@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Target: TargetData.h updated: 1.10 -> 1.11 --- Log message: - Add an endianness field to the TargetData datastructure --- Diffs of the changes: Index: llvm/include/llvm/Target/TargetData.h diff -u llvm/include/llvm/Target/TargetData.h:1.10 llvm/include/llvm/Target/TargetData.h:1.11 --- llvm/include/llvm/Target/TargetData.h:1.10 Wed Sep 25 18:46:56 2002 +++ llvm/include/llvm/Target/TargetData.h Mon Oct 14 17:41:09 2002 @@ -23,6 +23,7 @@ class StructLayout; class TargetData : public ImmutablePass { + bool LittleEndian; // Defaults to false unsigned char ByteAlignment; // Defaults to 1 bytes unsigned char ShortAlignment; // Defaults to 2 bytes unsigned char IntAlignment; // Defaults to 4 bytes @@ -37,6 +38,7 @@ static Annotation *TypeAnFactory(AnnotationID, const Annotable *, void *); public: TargetData(const std::string &TargetName = "SparcV9", + bool LittleEndian = false, unsigned char IntRegSize = 8, unsigned char PtrSize = 8, unsigned char PtrAl = 8, unsigned char DoubleAl = 8, @@ -45,6 +47,11 @@ unsigned char ByteAl = 1); ~TargetData(); // Not virtual, do not subclass this class + /// Target endianness... + bool isLittleEndian() const { return LittleEndian; } + bool isBigEndian() const { return !LittleEndian; } + + /// Target alignment constraints unsigned char getByteAlignment() const { return ByteAlignment; } unsigned char getShortAlignment() const { return ShortAlignment; } unsigned char getIntAlignment() const { return IntAlignment; } @@ -52,8 +59,8 @@ unsigned char getFloatAlignment() const { return FloatAlignment; } unsigned char getDoubleAlignment() const { return DoubleAlignment; } unsigned char getPointerAlignment() const { return PointerAlignment; } - unsigned char getPointerSize() const { return PointerSize; } - unsigned char getIntegerRegize() const { return IntegerRegSize; } + unsigned char getPointerSize() const { return PointerSize; } + unsigned char getIntegerRegize() const { return IntegerRegSize; } AnnotationID getStructLayoutAID() const { return AID; } // getTypeSize - Return the number of bytes neccesary to hold the specified From lattner at cs.uiuc.edu Mon Oct 14 17:42:02 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Oct 14 17:42:02 2002 Subject: [llvm-commits] CVS: llvm/lib/Target/TargetData.cpp Message-ID: <200210142241.RAA06438@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target: TargetData.cpp updated: 1.24 -> 1.25 --- Log message: - Add an endianness field to the TargetData datastructure --- Diffs of the changes: Index: llvm/lib/Target/TargetData.cpp diff -u llvm/lib/Target/TargetData.cpp:1.24 llvm/lib/Target/TargetData.cpp:1.25 --- llvm/lib/Target/TargetData.cpp:1.24 Sun Oct 13 16:47:44 2002 +++ llvm/lib/Target/TargetData.cpp Mon Oct 14 17:41:13 2002 @@ -81,14 +81,16 @@ //===----------------------------------------------------------------------===// TargetData::TargetData(const std::string &TargetName, - unsigned char IntRegSize, unsigned char PtrSize, - unsigned char PtrAl, unsigned char DoubleAl, - unsigned char FloatAl, unsigned char LongAl, - unsigned char IntAl, unsigned char ShortAl, - unsigned char ByteAl) + bool isLittleEndian, + unsigned char IntRegSize, unsigned char PtrSize, + unsigned char PtrAl, unsigned char DoubleAl, + unsigned char FloatAl, unsigned char LongAl, + unsigned char IntAl, unsigned char ShortAl, + unsigned char ByteAl) : AID(AnnotationManager::getID("TargetData::" + TargetName)) { AnnotationManager::registerAnnotationFactory(AID, TypeAnFactory, this); + LittleEndian = isLittleEndian; IntegerRegSize = IntRegSize; PointerSize = PtrSize; PointerAlignment = PtrAl; From vadve at cs.uiuc.edu Mon Oct 14 21:00:01 2002 From: vadve at cs.uiuc.edu (Vikram Adve) Date: Mon Oct 14 21:00:01 2002 Subject: [llvm-commits] CVS: llvm/Makefile.common Message-ID: <200210150159.UAA07203@psmith.cs.uiuc.edu> Changes in directory llvm: Makefile.common updated: 1.61 -> 1.62 --- Log message: Remove outdated line which of course cvs merging never detects... --- Diffs of the changes: Index: llvm/Makefile.common diff -u llvm/Makefile.common:1.61 llvm/Makefile.common:1.62 --- llvm/Makefile.common:1.61 Mon Oct 14 11:40:04 2002 +++ llvm/Makefile.common Mon Oct 14 20:59:45 2002 @@ -126,7 +126,7 @@ # Special tools used while building the LLVM tree. Burg is built as part of the # utils directory. # -BURG := $(LEVEL)/utils/Burg/burg.$(UNAME) +BURG := $(TOOLDEBUG)/burg RunBurg := $(BURG) $(BURG_OPTS) From vadve at cs.uiuc.edu Mon Oct 14 21:07:00 2002 From: vadve at cs.uiuc.edu (Vikram Adve) Date: Mon Oct 14 21:07:00 2002 Subject: [llvm-commits] CVS: llvm/test/Programs/MultiSource/Burg/Makefile Message-ID: <200210150206.VAA07690@psmith.cs.uiuc.edu> Changes in directory llvm/test/Programs/MultiSource/Burg: Makefile updated: 1.1 -> 1.2 --- Log message: Change a rule order so default target remains "all". --- Diffs of the changes: Index: llvm/test/Programs/MultiSource/Burg/Makefile diff -u llvm/test/Programs/MultiSource/Burg/Makefile:1.1 llvm/test/Programs/MultiSource/Burg/Makefile:1.2 --- llvm/test/Programs/MultiSource/Burg/Makefile:1.1 Mon Oct 14 11:39:23 2002 +++ llvm/test/Programs/MultiSource/Burg/Makefile Mon Oct 14 21:05:58 2002 @@ -21,11 +21,10 @@ ## $(VERB) mv -f $(basename $@).tab.c $(basename $@).cpp ## $(VERB) mv -f $(basename $@).tab.h $(basename $@).h +include ../Makefile.multisrc y.tab.c y.tab.h: gram.y yacc -d $< - -include ../Makefile.multisrc Source := $(patsubst gram.%,,$(Source)) From vadve at cs.uiuc.edu Mon Oct 14 21:13:00 2002 From: vadve at cs.uiuc.edu (Vikram Adve) Date: Mon Oct 14 21:13:00 2002 Subject: [llvm-commits] CVS: llvm/test/Programs/Makefile.programs Message-ID: <200210150212.VAA07987@psmith.cs.uiuc.edu> Changes in directory llvm/test/Programs: Makefile.programs updated: 1.17 -> 1.18 --- Log message: Don't try to run llc diffs on Linux. --- Diffs of the changes: Index: llvm/test/Programs/Makefile.programs diff -u llvm/test/Programs/Makefile.programs:1.17 llvm/test/Programs/Makefile.programs:1.18 --- llvm/test/Programs/Makefile.programs:1.17 Mon Oct 14 11:42:09 2002 +++ llvm/test/Programs/Makefile.programs Mon Oct 14 21:12:31 2002 @@ -78,6 +78,10 @@ all:: $(GCCOUTPUT) endif +ifeq ($(UNAME),Linux) +DISABLE_LLC_DIFFS = 1 +endif + ifndef DISABLE_LLC all:: $(LLCCODEGEN) else From lattner at cs.uiuc.edu Tue Oct 15 14:51:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Oct 15 14:51:01 2002 Subject: [llvm-commits] CVS: llvm/test/Programs/Makefile.programs Message-ID: <200210151950.OAA03416@apoc.cs.uiuc.edu> Changes in directory llvm/test/Programs: Makefile.programs updated: 1.18 -> 1.19 --- Log message: This is unneccesary, it's defined in Makefile.Linux at the top level --- Diffs of the changes: Index: llvm/test/Programs/Makefile.programs diff -u llvm/test/Programs/Makefile.programs:1.18 llvm/test/Programs/Makefile.programs:1.19 --- llvm/test/Programs/Makefile.programs:1.18 Mon Oct 14 21:12:31 2002 +++ llvm/test/Programs/Makefile.programs Tue Oct 15 14:49:52 2002 @@ -78,10 +78,6 @@ all:: $(GCCOUTPUT) endif -ifeq ($(UNAME),Linux) -DISABLE_LLC_DIFFS = 1 -endif - ifndef DISABLE_LLC all:: $(LLCCODEGEN) else From lattner at cs.uiuc.edu Tue Oct 15 14:57:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Oct 15 14:57:01 2002 Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/EmitAssembly.cpp Message-ID: <200210151956.OAA03866@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/Sparc: EmitAssembly.cpp updated: 1.62 -> 1.63 --- Log message: Make sure to escape \'s when they are output --- Diffs of the changes: Index: llvm/lib/Target/Sparc/EmitAssembly.cpp diff -u llvm/lib/Target/Sparc/EmitAssembly.cpp:1.62 llvm/lib/Target/Sparc/EmitAssembly.cpp:1.63 --- llvm/lib/Target/Sparc/EmitAssembly.cpp:1.62 Mon Oct 14 01:14:18 2002 +++ llvm/lib/Target/Sparc/EmitAssembly.cpp Tue Oct 15 14:56:24 2002 @@ -586,6 +586,8 @@ if (C == '"') { Result += "\\\""; + } else if (C == '\\') { + Result += "\\\\"; } else if (isprint(C)) { Result += C; } else { From lattner at cs.uiuc.edu Tue Oct 15 15:35:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Oct 15 15:35:01 2002 Subject: [llvm-commits] CVS: llvm/tools/lli/Execution.cpp Interpreter.h Message-ID: <200210152034.PAA06615@trinity.cs.uiuc.edu> Changes in directory llvm/tools/lli: Execution.cpp updated: 1.67 -> 1.68 Interpreter.h updated: 1.22 -> 1.23 --- Log message: - Fix LLI so that it simulates the endianness of the target machine correctly, despite the fact that the host machine might not be the same. --- Diffs of the changes: Index: llvm/tools/lli/Execution.cpp diff -u llvm/tools/lli/Execution.cpp:1.67 llvm/tools/lli/Execution.cpp:1.68 --- llvm/tools/lli/Execution.cpp:1.67 Wed Oct 2 16:10:48 2002 +++ llvm/tools/lli/Execution.cpp Tue Oct 15 15:34:05 2002 @@ -83,7 +83,7 @@ } #define GET_CONST_VAL(TY, CLASS) \ - case Type::TY##TyID: Result.TY##Val = cast(CPV)->getValue(); break + case Type::TY##TyID: Result.TY##Val = cast(C)->getValue(); break // Operations used by constant expr implementations... static GenericValue executeCastOperation(Value *Src, const Type *DestTy, @@ -94,6 +94,37 @@ static GenericValue executeAddInst(GenericValue Src1, GenericValue Src2, const Type *Ty, ExecutionContext &SF); +static GenericValue getConstantValue(const Constant *C) { + GenericValue Result; + switch (C->getType()->getPrimitiveID()) { + GET_CONST_VAL(Bool , ConstantBool); + GET_CONST_VAL(UByte , ConstantUInt); + GET_CONST_VAL(SByte , ConstantSInt); + GET_CONST_VAL(UShort , ConstantUInt); + GET_CONST_VAL(Short , ConstantSInt); + GET_CONST_VAL(UInt , ConstantUInt); + GET_CONST_VAL(Int , ConstantSInt); + GET_CONST_VAL(ULong , ConstantUInt); + GET_CONST_VAL(Long , ConstantSInt); + GET_CONST_VAL(Float , ConstantFP); + GET_CONST_VAL(Double , ConstantFP); + case Type::PointerTyID: + if (isa(C)) { + Result.PointerVal = 0; + } else if (const ConstantPointerRef *CPR = dyn_cast(C)){ + GlobalAddress *Address = + (GlobalAddress*)CPR->getValue()->getOrCreateAnnotation(GlobalAddressAID); + Result.PointerVal = (PointerTy)Address->Ptr; + } else { + assert(0 && "Unknown constant pointer type!"); + } + break; + default: + cout << "ERROR: Constant unimp for type: " << C->getType() << "\n"; + } + return Result; +} + static GenericValue getOperandValue(Value *V, ExecutionContext &SF) { if (ConstantExpr *CE = dyn_cast(V)) { switch (CE->getOpcode()) { @@ -112,32 +143,7 @@ { GenericValue V; return V; } } } else if (Constant *CPV = dyn_cast(V)) { - GenericValue Result; - switch (CPV->getType()->getPrimitiveID()) { - GET_CONST_VAL(Bool , ConstantBool); - GET_CONST_VAL(UByte , ConstantUInt); - GET_CONST_VAL(SByte , ConstantSInt); - GET_CONST_VAL(UShort , ConstantUInt); - GET_CONST_VAL(Short , ConstantSInt); - GET_CONST_VAL(UInt , ConstantUInt); - GET_CONST_VAL(Int , ConstantSInt); - GET_CONST_VAL(ULong , ConstantUInt); - GET_CONST_VAL(Long , ConstantSInt); - GET_CONST_VAL(Float , ConstantFP); - GET_CONST_VAL(Double , ConstantFP); - case Type::PointerTyID: - if (isa(CPV)) { - Result.PointerVal = 0; - } else if (ConstantPointerRef *CPR = dyn_cast(CPV)) { - return getOperandValue(CPR->getValue(), SF); - } else { - assert(0 && "Unknown constant pointer type!"); - } - break; - default: - cout << "ERROR: Constant unimp for type: " << CPV->getType() << "\n"; - } - return Result; + return getConstantValue(CPV); } else if (GlobalValue *GV = dyn_cast(V)) { GlobalAddress *Address = (GlobalAddress*)GV->getOrCreateAnnotation(GlobalAddressAID); @@ -197,30 +203,21 @@ initializeSignalHandlers(); } +static void StoreValueToMemory(GenericValue Val, GenericValue *Ptr, + const Type *Ty); + // InitializeMemory - Recursive function to apply a Constant value into the // specified memory location... // static void InitializeMemory(const Constant *Init, char *Addr) { -#define INITIALIZE_MEMORY(TYID, CLASS, TY) \ - case Type::TYID##TyID: { \ - TY Tmp = cast(Init)->getValue(); \ - memcpy(Addr, &Tmp, sizeof(TY)); \ - } return - switch (Init->getType()->getPrimitiveID()) { - INITIALIZE_MEMORY(Bool , ConstantBool, bool); - INITIALIZE_MEMORY(UByte , ConstantUInt, unsigned char); - INITIALIZE_MEMORY(SByte , ConstantSInt, signed char); - INITIALIZE_MEMORY(UShort , ConstantUInt, unsigned short); - INITIALIZE_MEMORY(Short , ConstantSInt, signed short); - INITIALIZE_MEMORY(UInt , ConstantUInt, unsigned int); - INITIALIZE_MEMORY(Int , ConstantSInt, signed int); - INITIALIZE_MEMORY(ULong , ConstantUInt, uint64_t); - INITIALIZE_MEMORY(Long , ConstantSInt, int64_t); - INITIALIZE_MEMORY(Float , ConstantFP , float); - INITIALIZE_MEMORY(Double , ConstantFP , double); -#undef INITIALIZE_MEMORY + if (Init->getType()->isFirstClassType()) { + GenericValue Val = getConstantValue(Init); + StoreValueToMemory(Val, (GenericValue*)Addr, Init->getType()); + return; + } + switch (Init->getType()->getPrimitiveID()) { case Type::ArrayTyID: { const ConstantArray *CPA = cast(Init); const vector &Val = CPA->getValues(); @@ -241,19 +238,6 @@ return; } - case Type::PointerTyID: - if (isa(Init)) { - *(void**)Addr = 0; - } else if (const ConstantPointerRef *CPR = - dyn_cast(Init)) { - GlobalAddress *Address = - (GlobalAddress*)CPR->getValue()->getOrCreateAnnotation(GlobalAddressAID); - *(void**)Addr = (GenericValue*)Address->Ptr; - } else { - assert(0 && "Unknown Constant pointer type!"); - } - return; - default: CW << "Bad Type: " << Init->getType() << "\n"; assert(0 && "Unknown constant type to initialize memory with!"); @@ -854,47 +838,144 @@ GenericValue *Ptr = (GenericValue*)SRC.PointerVal; GenericValue Result; - switch (I.getType()->getPrimitiveID()) { - case Type::BoolTyID: - case Type::UByteTyID: - case Type::SByteTyID: Result.SByteVal = Ptr->SByteVal; break; - case Type::UShortTyID: - case Type::ShortTyID: Result.ShortVal = Ptr->ShortVal; break; - case Type::UIntTyID: - case Type::IntTyID: Result.IntVal = Ptr->IntVal; break; - case Type::ULongTyID: - case Type::LongTyID: Result.ULongVal = Ptr->ULongVal; break; - case Type::PointerTyID: Result.PointerVal = Ptr->PointerVal; break; - case Type::FloatTyID: Result.FloatVal = Ptr->FloatVal; break; - case Type::DoubleTyID: Result.DoubleVal = Ptr->DoubleVal; break; - default: - cout << "Cannot load value of type " << I.getType() << "!\n"; + if (TD.isLittleEndian()) { + switch (I.getType()->getPrimitiveID()) { + case Type::BoolTyID: + case Type::UByteTyID: + case Type::SByteTyID: Result.Untyped[0] = Ptr->UByteVal; break; + case Type::UShortTyID: + case Type::ShortTyID: Result.Untyped[0] = Ptr->UShortVal & 255; + Result.Untyped[1] = (Ptr->UShortVal >> 8) & 255; + break; + case Type::FloatTyID: + case Type::UIntTyID: + case Type::IntTyID: Result.Untyped[0] = Ptr->UIntVal & 255; + Result.Untyped[1] = (Ptr->UIntVal >> 8) & 255; + Result.Untyped[2] = (Ptr->UIntVal >> 16) & 255; + Result.Untyped[3] = (Ptr->UIntVal >> 24) & 255; + break; + case Type::DoubleTyID: + case Type::ULongTyID: + case Type::LongTyID: + case Type::PointerTyID: Result.Untyped[0] = Ptr->ULongVal & 255; + Result.Untyped[1] = (Ptr->ULongVal >> 8) & 255; + Result.Untyped[2] = (Ptr->ULongVal >> 16) & 255; + Result.Untyped[3] = (Ptr->ULongVal >> 24) & 255; + Result.Untyped[4] = (Ptr->ULongVal >> 32) & 255; + Result.Untyped[5] = (Ptr->ULongVal >> 40) & 255; + Result.Untyped[6] = (Ptr->ULongVal >> 48) & 255; + Result.Untyped[7] = (Ptr->ULongVal >> 56) & 255; + break; + default: + cout << "Cannot load value of type " << I.getType() << "!\n"; + } + } else { + switch (I.getType()->getPrimitiveID()) { + case Type::BoolTyID: + case Type::UByteTyID: + case Type::SByteTyID: Result.Untyped[0] = Ptr->UByteVal; break; + case Type::UShortTyID: + case Type::ShortTyID: Result.Untyped[1] = Ptr->UShortVal & 255; + Result.Untyped[0] = (Ptr->UShortVal >> 8) & 255; + break; + case Type::FloatTyID: + case Type::UIntTyID: + case Type::IntTyID: Result.Untyped[3] = Ptr->UIntVal & 255; + Result.Untyped[2] = (Ptr->UIntVal >> 8) & 255; + Result.Untyped[1] = (Ptr->UIntVal >> 16) & 255; + Result.Untyped[0] = (Ptr->UIntVal >> 24) & 255; + break; + case Type::DoubleTyID: + case Type::ULongTyID: + case Type::LongTyID: + case Type::PointerTyID: Result.Untyped[7] = Ptr->ULongVal & 255; + Result.Untyped[6] = (Ptr->ULongVal >> 8) & 255; + Result.Untyped[5] = (Ptr->ULongVal >> 16) & 255; + Result.Untyped[4] = (Ptr->ULongVal >> 24) & 255; + Result.Untyped[3] = (Ptr->ULongVal >> 32) & 255; + Result.Untyped[2] = (Ptr->ULongVal >> 40) & 255; + Result.Untyped[1] = (Ptr->ULongVal >> 48) & 255; + Result.Untyped[0] = (Ptr->ULongVal >> 56) & 255; + break; + default: + cout << "Cannot load value of type " << I.getType() << "!\n"; + } } SetValue(&I, Result, SF); } +static void StoreValueToMemory(GenericValue Val, GenericValue *Ptr, + const Type *Ty) { + if (TD.isLittleEndian()) { + switch (Ty->getPrimitiveID()) { + case Type::BoolTyID: + case Type::UByteTyID: + case Type::SByteTyID: Ptr->Untyped[0] = Val.UByteVal; break; + case Type::UShortTyID: + case Type::ShortTyID: Ptr->Untyped[0] = Val.UShortVal & 255; + Ptr->Untyped[1] = (Val.UShortVal >> 8) & 255; + break; + case Type::FloatTyID: + case Type::UIntTyID: + case Type::IntTyID: Ptr->Untyped[0] = Val.UIntVal & 255; + Ptr->Untyped[1] = (Val.UIntVal >> 8) & 255; + Ptr->Untyped[2] = (Val.UIntVal >> 16) & 255; + Ptr->Untyped[3] = (Val.UIntVal >> 24) & 255; + break; + case Type::DoubleTyID: + case Type::ULongTyID: + case Type::LongTyID: + case Type::PointerTyID: Ptr->Untyped[0] = Val.ULongVal & 255; + Ptr->Untyped[1] = (Val.ULongVal >> 8) & 255; + Ptr->Untyped[2] = (Val.ULongVal >> 16) & 255; + Ptr->Untyped[3] = (Val.ULongVal >> 24) & 255; + Ptr->Untyped[4] = (Val.ULongVal >> 32) & 255; + Ptr->Untyped[5] = (Val.ULongVal >> 40) & 255; + Ptr->Untyped[6] = (Val.ULongVal >> 48) & 255; + Ptr->Untyped[7] = (Val.ULongVal >> 56) & 255; + break; + default: + cout << "Cannot load value of type " << Ty << "!\n"; + } + } else { + switch (Ty->getPrimitiveID()) { + case Type::BoolTyID: + case Type::UByteTyID: + case Type::SByteTyID: Ptr->Untyped[0] = Val.UByteVal; break; + case Type::UShortTyID: + case Type::ShortTyID: Ptr->Untyped[1] = Val.UShortVal & 255; + Ptr->Untyped[0] = (Val.UShortVal >> 8) & 255; + break; + case Type::FloatTyID: + case Type::UIntTyID: + case Type::IntTyID: Ptr->Untyped[3] = Val.UIntVal & 255; + Ptr->Untyped[2] = (Val.UIntVal >> 8) & 255; + Ptr->Untyped[1] = (Val.UIntVal >> 16) & 255; + Ptr->Untyped[0] = (Val.UIntVal >> 24) & 255; + break; + case Type::DoubleTyID: + case Type::ULongTyID: + case Type::LongTyID: + case Type::PointerTyID: Ptr->Untyped[7] = Val.ULongVal & 255; + Ptr->Untyped[6] = (Val.ULongVal >> 8) & 255; + Ptr->Untyped[5] = (Val.ULongVal >> 16) & 255; + Ptr->Untyped[4] = (Val.ULongVal >> 24) & 255; + Ptr->Untyped[3] = (Val.ULongVal >> 32) & 255; + Ptr->Untyped[2] = (Val.ULongVal >> 40) & 255; + Ptr->Untyped[1] = (Val.ULongVal >> 48) & 255; + Ptr->Untyped[0] = (Val.ULongVal >> 56) & 255; + break; + default: + cout << "Cannot load value of type " << Ty << "!\n"; + } + } +} + static void executeStoreInst(StoreInst &I, ExecutionContext &SF) { - GenericValue SRC = getOperandValue(I.getPointerOperand(), SF); - GenericValue *Ptr = (GenericValue *)SRC.PointerVal; GenericValue Val = getOperandValue(I.getOperand(0), SF); - - switch (I.getOperand(0)->getType()->getPrimitiveID()) { - case Type::BoolTyID: - case Type::UByteTyID: - case Type::SByteTyID: Ptr->SByteVal = Val.SByteVal; break; - case Type::UShortTyID: - case Type::ShortTyID: Ptr->ShortVal = Val.ShortVal; break; - case Type::UIntTyID: - case Type::IntTyID: Ptr->IntVal = Val.IntVal; break; - case Type::ULongTyID: - case Type::LongTyID: Ptr->LongVal = Val.LongVal; break; - case Type::PointerTyID: Ptr->PointerVal = Val.PointerVal; break; - case Type::FloatTyID: Ptr->FloatVal = Val.FloatVal; break; - case Type::DoubleTyID: Ptr->DoubleVal = Val.DoubleVal; break; - default: - cout << "Cannot store value of type " << I.getType() << "!\n"; - } + GenericValue SRC = getOperandValue(I.getPointerOperand(), SF); + StoreValueToMemory(Val, (GenericValue *)SRC.PointerVal, I.getType()); } Index: llvm/tools/lli/Interpreter.h diff -u llvm/tools/lli/Interpreter.h:1.22 llvm/tools/lli/Interpreter.h:1.23 --- llvm/tools/lli/Interpreter.h:1.22 Wed Oct 2 16:11:16 2002 +++ llvm/tools/lli/Interpreter.h Tue Oct 15 15:34:05 2002 @@ -37,6 +37,7 @@ double DoubleVal; float FloatVal; PointerTy PointerVal; + unsigned char Untyped[8]; }; // AllocaHolder - Object to track all of the blocks of memory allocated by From lattner at cs.uiuc.edu Tue Oct 15 16:12:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Oct 15 16:12:01 2002 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/ADCE/2002-07-17-PHIAssertion.ll Message-ID: <200210152111.QAA07796@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/ADCE: 2002-07-17-PHIAssertion.ll updated: 1.3 -> 1.4 --- Log message: Fix testcase --- Diffs of the changes: Index: llvm/test/Regression/Transforms/ADCE/2002-07-17-PHIAssertion.ll diff -u llvm/test/Regression/Transforms/ADCE/2002-07-17-PHIAssertion.ll:1.3 llvm/test/Regression/Transforms/ADCE/2002-07-17-PHIAssertion.ll:1.4 --- llvm/test/Regression/Transforms/ADCE/2002-07-17-PHIAssertion.ll:1.3 Mon Jul 29 18:41:21 2002 +++ llvm/test/Regression/Transforms/ADCE/2002-07-17-PHIAssertion.ll Tue Oct 15 16:10:53 2002 @@ -2,8 +2,8 @@ ; ; RUN: as < %s | opt -adce -%bk = internal uninitialized global uint ; [#uses=2] -%hufts = internal uninitialized global uint ; [#uses=1] +%bk = external global uint ; [#uses=2] +%hufts = external global uint ; [#uses=1] implementation ; Functions: From lattner at cs.uiuc.edu Tue Oct 15 16:15:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Oct 15 16:15:01 2002 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/DecomposeMultiDimRefs/multidim.ll Message-ID: <200210152114.QAA08095@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/DecomposeMultiDimRefs: multidim.ll updated: 1.4 -> 1.5 --- Log message: Cleanup testcase --- Diffs of the changes: Index: llvm/test/Regression/Transforms/DecomposeMultiDimRefs/multidim.ll diff -u llvm/test/Regression/Transforms/DecomposeMultiDimRefs/multidim.ll:1.4 llvm/test/Regression/Transforms/DecomposeMultiDimRefs/multidim.ll:1.5 --- llvm/test/Regression/Transforms/DecomposeMultiDimRefs/multidim.ll:1.4 Thu Aug 22 11:39:05 2002 +++ llvm/test/Regression/Transforms/DecomposeMultiDimRefs/multidim.ll Tue Oct 15 16:14:24 2002 @@ -9,17 +9,17 @@ declare int "printf"(sbyte *, ...) -declare int "ArrayRef"([100 x int] * %Array, uint %I, uint %J) +declare int "ArrayRef"([100 x int] * %Array, long %I, long %J) implementation int "test"([20 x [10 x [5 x int]]] * %A) begin - %idx = getelementptr [20 x [10 x [5 x int]]] * %A, uint 1, uint 2, uint 3, uint 4 + %idx = getelementptr [20 x [10 x [5 x int]]] * %A, long 1, long 2, long 3, long 4 %i = load int* %idx ;; same as above but via a GEP - %iptr = getelementptr [20 x [10 x [5 x int]]] * %A, uint 1, uint 2, uint 3, uint 4 + %iptr = getelementptr [20 x [10 x [5 x int]]] * %A, long 1, long 2, long 3, long 4 %ii= load int* %iptr ;; EXPECTED RESULT: decomposed indices for above LOAD or GEP @@ -35,10 +35,10 @@ begin bb0: ;[#uses=2] %reg112 = add int %base, 1 ; [#uses=1] - %reg164-idxcast = cast int %reg112 to uint ; [#uses=1] + %reg164-idxcast = cast int %reg112 to long ; [#uses=1] ;; Store to a structure field - %idx1 = getelementptr %Mixed_struct * %M, uint 0, ubyte 3, uint %reg164-idxcast, ubyte 0 + %idx1 = getelementptr %Mixed_struct * %M, long 0, ubyte 3, long %reg164-idxcast, ubyte 0 store sbyte 81, sbyte* %idx1 ;; EXPECTED RESULT: decomposed indices for above STORE @@ -47,7 +47,7 @@ ;; store sbyte 81, {sbyte,float}* %ptr2, uint 0, ubyte 0 ;; Store to an array field within a structure - %idx2 = getelementptr %Mixed_struct * %M, uint 0, ubyte 1, uint %reg164-idxcast + %idx2 = getelementptr %Mixed_struct * %M, long 0, ubyte 1, long %reg164-idxcast store double 2.17, double* %idx2 ;; EXPECTED RESULT: decomposed indices for above STORE @@ -62,29 +62,29 @@ begin bb0: ;[#uses=1] %Array = alloca [100 x [100 x int]] - %ArraySlice = getelementptr [100 x [100 x int]]* %Array, uint 0, uint 0 - %trstrP = getelementptr [34 x sbyte] * %trstr, uint 0, uint 0 + %ArraySlice = getelementptr [100 x [100 x int]]* %Array, long 0, long 0 + %trstrP = getelementptr [34 x sbyte] * %trstr, long 0, long 0 %trace = call int (sbyte *, ...) * %printf( sbyte * %trstrP ) - %eltVal = call int %ArrayRef([100 x int]* %ArraySlice, uint 8, uint 12) + %eltVal = call int %ArrayRef([100 x int]* %ArraySlice, long 8, long 12) ret int %eltVal ;; ret int 0 end -int "ArrayRef"([100 x int] * %Array, uint %I, uint %J) +int "ArrayRef"([100 x int] * %Array, long %I, long %J) begin bb0: ;[#uses=3] - %idx = getelementptr [100 x int]* %Array, uint %I, uint %J ; [#uses=1] + %idx = getelementptr [100 x int]* %Array, long %I, long %J ; [#uses=1] %reg121 = load int* %idx - ret int %reg121; + ret int %reg121 end -sbyte "PtrRef"(sbyte** %argv, uint %I, uint %J) +sbyte "PtrRef"(sbyte** %argv, long %I, long %J) begin bb0: ;[#uses=3] - %idx = getelementptr sbyte** %argv, uint %I, uint %J + %idx = getelementptr sbyte** %argv, long %I, long %J %reg222 = load sbyte* %idx ret sbyte %reg222; end From lattner at cs.uiuc.edu Tue Oct 15 16:19:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Oct 15 16:19:01 2002 Subject: [llvm-commits] CVS: llvm/test/Regression/Assembler/2002-10-15-NameClash.ll Message-ID: <200210152118.QAA08377@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Assembler: 2002-10-15-NameClash.ll added (r1.1) --- Log message: New testcase --- Diffs of the changes: From lattner at cs.uiuc.edu Tue Oct 15 16:21:00 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Oct 15 16:21:00 2002 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/Makefile Message-ID: <200210152120.QAA10370@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms: Makefile updated: 1.18 -> 1.19 --- Log message: Fix typo --- Diffs of the changes: Index: llvm/test/Regression/Transforms/Makefile diff -u llvm/test/Regression/Transforms/Makefile:1.18 llvm/test/Regression/Transforms/Makefile:1.19 --- llvm/test/Regression/Transforms/Makefile:1.18 Thu Sep 26 14:53:02 2002 +++ llvm/test/Regression/Transforms/Makefile Tue Oct 15 16:20:18 2002 @@ -8,7 +8,7 @@ FunctionResolve \ GCSE \ GlobalDCE \ - IndVarSimplify \ + IndVarsSimplify \ Inline \ InstCombine \ LevelRaise \ From lattner at cs.uiuc.edu Tue Oct 15 16:22:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Oct 15 16:22:01 2002 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/Reassociate/looptest.ll Message-ID: <200210152121.QAA10571@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/Reassociate: looptest.ll updated: 1.1 -> 1.2 --- Log message: Cleanup test --- Diffs of the changes: Index: llvm/test/Regression/Transforms/Reassociate/looptest.ll diff -u llvm/test/Regression/Transforms/Reassociate/looptest.ll:1.1 llvm/test/Regression/Transforms/Reassociate/looptest.ll:1.2 --- llvm/test/Regression/Transforms/Reassociate/looptest.ll:1.1 Wed May 8 17:20:55 2002 +++ llvm/test/Regression/Transforms/Reassociate/looptest.ll Tue Oct 15 16:21:42 2002 @@ -38,7 +38,7 @@ %reg117 = phi uint [ %reg118, %bb4 ], [ 0, %bb3 ] ; [#uses=2] %reg113 = add uint %reg115, %reg117 ; [#uses=1] %reg114 = add uint %reg113, %reg116 ; [#uses=1] - %cast227 = getelementptr [4 x sbyte]* %.LC0, uint 0, uint 0 ; [#uses=1] + %cast227 = getelementptr [4 x sbyte]* %.LC0, long 0, long 0 ; [#uses=1] call int (sbyte*, ...)* %printf( sbyte* %cast227, uint %reg114 ) ; :0 [#uses=0] %reg118 = add uint %reg117, 1 ; [#uses=2] %cond224 = setne uint %reg118, %Num ; [#uses=1] From lattner at cs.uiuc.edu Tue Oct 15 16:27:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Oct 15 16:27:01 2002 Subject: [llvm-commits] CVS: llvm/include/llvm/Function.h SymbolTable.h Message-ID: <200210152126.QAA11211@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: Function.h updated: 1.37 -> 1.38 SymbolTable.h updated: 1.18 -> 1.19 --- Log message: - Eliminate SymbolTable::ParentSymTab, ST::localLookup, and Function::ParentSymTab. These aren't needed at all. --- Diffs of the changes: Index: llvm/include/llvm/Function.h diff -u llvm/include/llvm/Function.h:1.37 llvm/include/llvm/Function.h:1.38 --- llvm/include/llvm/Function.h:1.37 Wed Oct 9 18:11:32 2002 +++ llvm/include/llvm/Function.h Tue Oct 15 16:26:24 2002 @@ -57,7 +57,7 @@ BasicBlockListType BasicBlocks; // The basic blocks ArgumentListType ArgumentList; // The formal arguments - SymbolTable *SymTab, *ParentSymTab; + SymbolTable *SymTab; friend class SymbolTableListTraits; Index: llvm/include/llvm/SymbolTable.h diff -u llvm/include/llvm/SymbolTable.h:1.18 llvm/include/llvm/SymbolTable.h:1.19 --- llvm/include/llvm/SymbolTable.h:1.18 Sun Apr 28 14:49:58 2002 +++ llvm/include/llvm/SymbolTable.h Tue Oct 15 16:26:24 2002 @@ -25,32 +25,15 @@ public: typedef std::map VarMap; typedef std::map super; -private: - SymbolTable *ParentSymTab; - - friend class Function; - inline void setParentSymTab(SymbolTable *P) { ParentSymTab = P; } - -public: typedef VarMap::iterator type_iterator; typedef VarMap::const_iterator type_const_iterator; - inline SymbolTable(SymbolTable *P = 0) { - ParentSymTab = P; - InternallyInconsistent = false; - } + inline SymbolTable() : InternallyInconsistent(false) {} ~SymbolTable(); - SymbolTable *getParentSymTab() { return ParentSymTab; } - // lookup - Returns null on failure... Value *lookup(const Type *Ty, const std::string &name); - - // localLookup - Look in this symbol table without falling back on parent, - // if non-existing. Returns null on failure... - // - Value *localLookup(const Type *Ty, const std::string &name); // insert - Add named definition to the symbol table... inline void insert(Value *N) { From lattner at cs.uiuc.edu Tue Oct 15 16:27:03 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Oct 15 16:27:03 2002 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Function.cpp Module.cpp SymbolTable.cpp Message-ID: <200210152126.QAA11222@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Function.cpp updated: 1.33 -> 1.34 Module.cpp updated: 1.29 -> 1.30 SymbolTable.cpp updated: 1.25 -> 1.26 --- Log message: - Eliminate SymbolTable::ParentSymTab, ST::localLookup, and Function::ParentSymTab. These aren't needed at all. --- Diffs of the changes: Index: llvm/lib/VMCore/Function.cpp diff -u llvm/lib/VMCore/Function.cpp:1.33 llvm/lib/VMCore/Function.cpp:1.34 --- llvm/lib/VMCore/Function.cpp:1.33 Sun Oct 13 15:53:14 2002 +++ llvm/lib/VMCore/Function.cpp Tue Oct 15 16:26:29 2002 @@ -84,7 +84,7 @@ BasicBlocks.setParent(this); ArgumentList.setItemParent(this); ArgumentList.setParent(this); - ParentSymTab = SymTab = 0; + SymTab = 0; // Create the arguments vector, all arguments start out unnamed. for (unsigned i = 0, e = Ty->getNumParams(); i != e; ++i) { @@ -127,10 +127,6 @@ Parent = parent; if (getParent()) LeakDetector::removeGarbageObject(this); - - // Relink symbol tables together... - ParentSymTab = Parent ? Parent->getSymbolTableSure() : 0; - if (SymTab) SymTab->setParentSymTab(ParentSymTab); } const FunctionType *Function::getFunctionType() const { @@ -142,7 +138,7 @@ } SymbolTable *Function::getSymbolTableSure() { - if (!SymTab) SymTab = new SymbolTable(ParentSymTab); + if (!SymTab) SymTab = new SymbolTable(); return SymTab; } Index: llvm/lib/VMCore/Module.cpp diff -u llvm/lib/VMCore/Module.cpp:1.29 llvm/lib/VMCore/Module.cpp:1.30 --- llvm/lib/VMCore/Module.cpp:1.29 Sun Sep 8 13:59:35 2002 +++ llvm/lib/VMCore/Module.cpp Tue Oct 15 16:26:29 2002 @@ -75,7 +75,7 @@ } SymbolTable *Module::getSymbolTableSure() { - if (!SymTab) SymTab = new SymbolTable(0); + if (!SymTab) SymTab = new SymbolTable(); return SymTab; } Index: llvm/lib/VMCore/SymbolTable.cpp diff -u llvm/lib/VMCore/SymbolTable.cpp:1.25 llvm/lib/VMCore/SymbolTable.cpp:1.26 --- llvm/lib/VMCore/SymbolTable.cpp:1.25 Tue Jun 25 11:13:00 2002 +++ llvm/lib/VMCore/SymbolTable.cpp Tue Oct 15 16:26:29 2002 @@ -72,7 +72,7 @@ // lookup - Returns null on failure... -Value *SymbolTable::localLookup(const Type *Ty, const string &Name) { +Value *SymbolTable::lookup(const Type *Ty, const string &Name) { iterator I = find(Ty); if (I != end()) { // We have symbols in that plane... type_iterator J = I->second.find(Name); @@ -83,13 +83,6 @@ return 0; } -// lookup - Returns null on failure... -Value *SymbolTable::lookup(const Type *Ty, const string &Name) { - Value *LV = localLookup(Ty, Name); - if (LV) return LV; - return ParentSymTab ? ParentSymTab->lookup(Ty, Name) : 0; -} - void SymbolTable::remove(Value *N) { assert(N->hasName() && "Value doesn't have name!"); if (InternallyInconsistent) return; @@ -154,7 +147,7 @@ void SymbolTable::insertEntry(const string &Name, const Type *VTy, Value *V) { // Check to see if there is a naming conflict. If so, rename this value! - if (localLookup(VTy, Name)) { + if (lookup(VTy, Name)) { string UniqueName = getUniqueName(VTy, Name); assert(InternallyInconsistent == false && "Infinite loop inserting entry!"); InternallyInconsistent = true; @@ -339,9 +332,4 @@ void SymbolTable::dump() const { std::cout << "Symbol table dump:\n"; for_each(begin(), end(), DumpPlane); - - if (ParentSymTab) { - std::cout << "Parent "; - ParentSymTab->dump(); - } } From lattner at cs.uiuc.edu Tue Oct 15 16:41:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Oct 15 16:41:01 2002 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/LevelRaise/2002-05-23-MissedRaise.ll 2002-07-16-MissedRaise.ll Message-ID: <200210152140.QAA13344@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/LevelRaise: 2002-05-23-MissedRaise.ll updated: 1.1 -> 1.2 2002-07-16-MissedRaise.ll updated: 1.1 -> 1.2 --- Log message: Clean up testcases --- Diffs of the changes: Index: llvm/test/Regression/Transforms/LevelRaise/2002-05-23-MissedRaise.ll diff -u llvm/test/Regression/Transforms/LevelRaise/2002-05-23-MissedRaise.ll:1.1 llvm/test/Regression/Transforms/LevelRaise/2002-05-23-MissedRaise.ll:1.2 --- llvm/test/Regression/Transforms/LevelRaise/2002-05-23-MissedRaise.ll:1.1 Thu May 23 13:51:27 2002 +++ llvm/test/Regression/Transforms/LevelRaise/2002-05-23-MissedRaise.ll Tue Oct 15 16:39:49 2002 @@ -7,7 +7,7 @@ uint %addfile(%FILE* %f) { %cast255 = cast %FILE* %f to sbyte* ; [#uses=1] - %reg2421 = getelementptr sbyte* %cast255, uint 24 ; [#uses=1] + %reg2421 = getelementptr sbyte* %cast255, long 24 ; [#uses=1] %reg130 = load sbyte* %reg2421 ; [#uses=1] %cast250 = cast sbyte %reg130 to uint ; [#uses=1] ret uint %cast250 Index: llvm/test/Regression/Transforms/LevelRaise/2002-07-16-MissedRaise.ll diff -u llvm/test/Regression/Transforms/LevelRaise/2002-07-16-MissedRaise.ll:1.1 llvm/test/Regression/Transforms/LevelRaise/2002-07-16-MissedRaise.ll:1.2 --- llvm/test/Regression/Transforms/LevelRaise/2002-07-16-MissedRaise.ll:1.1 Tue Jul 16 14:10:00 2002 +++ llvm/test/Regression/Transforms/LevelRaise/2002-07-16-MissedRaise.ll Tue Oct 15 16:39:49 2002 @@ -16,9 +16,9 @@ void %reverse(%Tree %t) { bb0: ;[#uses=0] %cast219 = cast %Tree %t to sbyte*** ; [#uses=2] - %reg2221 = getelementptr sbyte*** %cast219, uint 6 ; [#uses=1] + %reg2221 = getelementptr sbyte*** %cast219, long 6 ; [#uses=1] %reg108 = load sbyte*** %reg2221 ; [#uses=2] - %reg247 = getelementptr sbyte*** %cast219, uint 5 ; [#uses=1] + %reg247 = getelementptr sbyte*** %cast219, long 5 ; [#uses=1] store sbyte** %reg108, sbyte*** %reg247 ret void } From lattner at cs.uiuc.edu Tue Oct 15 16:42:00 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Oct 15 16:42:00 2002 Subject: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y Message-ID: <200210152141.QAA13370@apoc.cs.uiuc.edu> Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.97 -> 1.98 --- Log message: - Fix bug: Assembler/2002-10-15-NameClash.ll - Clean up code a bit, s/Method/Function/ --- Diffs of the changes: Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.97 llvm/lib/AsmParser/llvmAsmParser.y:1.98 --- llvm/lib/AsmParser/llvmAsmParser.y:1.97 Sun Oct 13 22:28:42 2002 +++ llvm/lib/AsmParser/llvmAsmParser.y Tue Oct 15 16:41:14 2002 @@ -1210,50 +1210,50 @@ string FunctionName($3); vector ParamTypeList; - if ($5) + if ($5) { // If there are arguments... for (vector >::iterator I = $5->begin(); I != $5->end(); ++I) ParamTypeList.push_back(I->first->get()); + } bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy; if (isVarArg) ParamTypeList.pop_back(); - const FunctionType *MT = FunctionType::get(*$2, ParamTypeList, isVarArg); - const PointerType *PMT = PointerType::get(MT); + const FunctionType *FT = FunctionType::get(*$2, ParamTypeList, isVarArg); + const PointerType *PFT = PointerType::get(FT); delete $2; - Function *M = 0; - if (SymbolTable *ST = CurModule.CurrentModule->getSymbolTable()) { - // Is the function already in symtab? - if (Value *V = ST->lookup(PMT, FunctionName)) { - M = cast(V); - - // Yes it is. If this is the case, either we need to be a forward decl, - // or it needs to be. - if (!CurMeth.isDeclare && !M->isExternal()) - ThrowException("Redefinition of function '" + FunctionName + "'!"); - - // Make sure that we keep track of the internal marker, even if there was - // a previous "declare". - if ($1) - M->setInternalLinkage(true); - - // If we found a preexisting function prototype, remove it from the - // module, so that we don't get spurious conflicts with global & local - // variables. - // - CurModule.CurrentModule->getFunctionList().remove(M); - } - } - - if (M == 0) { // Not already defined? - M = new Function(MT, $1, FunctionName); - InsertValue(M, CurModule.Values); - CurModule.DeclareNewGlobalValue(M, ValID::create($3)); + Function *Fn = 0; + // Is the function already in symtab? + if ((Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) { + // Yes it is. If this is the case, either we need to be a forward decl, + // or it needs to be. + if (!CurMeth.isDeclare && !Fn->isExternal()) + ThrowException("Redefinition of function '" + FunctionName + "'!"); + + // Make sure that we keep track of the internal marker, even if there was + // a previous "declare". + if ($1) + Fn->setInternalLinkage(true); + + // If we found a preexisting function prototype, remove it from the + // module, so that we don't get spurious conflicts with global & local + // variables. + // + CurModule.CurrentModule->getFunctionList().remove(Fn); + + // Make sure to strip off any argument names so we can't get conflicts... + for (Function::aiterator AI = Fn->abegin(), AE = Fn->aend(); AI != AE; ++AI) + AI->setName(""); + + } else { // Not already defined? + Fn = new Function(FT, $1, FunctionName); + InsertValue(Fn, CurModule.Values); + CurModule.DeclareNewGlobalValue(Fn, ValID::create($3)); } free($3); // Free strdup'd memory! - CurMeth.FunctionStart(M); + CurMeth.FunctionStart(Fn); // Add all of the arguments we parsed to the function... if ($5) { // Is null if empty... @@ -1263,7 +1263,7 @@ delete $5->back().first; $5->pop_back(); // Delete the last entry } - Function::aiterator ArgIt = M->abegin(); + Function::aiterator ArgIt = Fn->abegin(); for (vector >::iterator I = $5->begin(); I != $5->end(); ++I, ++ArgIt) { delete I->first; // Delete the typeholder... @@ -1411,11 +1411,11 @@ } | INVOKE TypesV ValueRef '(' ValueRefListE ')' TO ResolvedVal EXCEPT ResolvedVal { - const PointerType *PMTy; + const PointerType *PFTy; const FunctionType *Ty; - if (!(PMTy = dyn_cast($2->get())) || - !(Ty = dyn_cast(PMTy->getElementType()))) { + if (!(PFTy = dyn_cast($2->get())) || + !(Ty = dyn_cast(PFTy->getElementType()))) { // Pull out the types of all of the arguments... vector ParamTypes; if ($5) { @@ -1427,11 +1427,11 @@ if (isVarArg) ParamTypes.pop_back(); Ty = FunctionType::get($2->get(), ParamTypes, isVarArg); - PMTy = PointerType::get(Ty); + PFTy = PointerType::get(Ty); } delete $2; - Value *V = getVal(PMTy, $3); // Get the function we're calling... + Value *V = getVal(PFTy, $3); // Get the function we're calling... BasicBlock *Normal = dyn_cast($8); BasicBlock *Except = dyn_cast($10); @@ -1570,11 +1570,11 @@ delete $2; // Free the list... } | CALL TypesV ValueRef '(' ValueRefListE ')' { - const PointerType *PMTy; + const PointerType *PFTy; const FunctionType *Ty; - if (!(PMTy = dyn_cast($2->get())) || - !(Ty = dyn_cast(PMTy->getElementType()))) { + if (!(PFTy = dyn_cast($2->get())) || + !(Ty = dyn_cast(PFTy->getElementType()))) { // Pull out the types of all of the arguments... vector ParamTypes; if ($5) { @@ -1586,11 +1586,11 @@ if (isVarArg) ParamTypes.pop_back(); Ty = FunctionType::get($2->get(), ParamTypes, isVarArg); - PMTy = PointerType::get(Ty); + PFTy = PointerType::get(Ty); } delete $2; - Value *V = getVal(PMTy, $3); // Get the function we're calling... + Value *V = getVal(PFTy, $3); // Get the function we're calling... // Create the call node... if (!$5) { // Has no arguments? From ashukla at cs.uiuc.edu Tue Oct 15 17:15:00 2002 From: ashukla at cs.uiuc.edu (Anand Shukla) Date: Tue Oct 15 17:15:00 2002 Subject: [llvm-commits] CVS: llvm/lib/Reoptimizer/Trigger/Trigger.cpp Message-ID: <200210152214.RAA00781@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Reoptimizer/Trigger: Trigger.cpp updated: 1.13 -> 1.14 --- Log message: Added defn for llvm_reopt --- Diffs of the changes: Index: llvm/lib/Reoptimizer/Trigger/Trigger.cpp diff -u llvm/lib/Reoptimizer/Trigger/Trigger.cpp:1.13 llvm/lib/Reoptimizer/Trigger/Trigger.cpp:1.14 --- llvm/lib/Reoptimizer/Trigger/Trigger.cpp:1.13 Tue Oct 8 11:29:48 2002 +++ llvm/lib/Reoptimizer/Trigger/Trigger.cpp Tue Oct 15 17:14:28 2002 @@ -29,9 +29,12 @@ extern const unsigned char LLVMBytecode[]; extern void** llvmFunctionTable[]; +int reopt_threshold; + #ifdef GET_TRACE_TIME static struct timeval llvm_trace_time; +static struct timeval llvm_trigger_time; extern "C" void llvm_time_start(){ gettimeofday(&llvm_trace_time, (void *)0); @@ -48,6 +51,23 @@ f_out<front() || isa(vBB[vBB.size()-1]->getTerminator())){ //std::cerr<<"Found a path starting with root!\n"; +#ifdef GET_TRACE_TIME + llvm_trigger_time_end(); +#endif return; } @@ -136,13 +161,19 @@ if(Bcheck->isConditional()){ if((vBB[0] != Bcheck->getSuccessor(0)) && (vBB[0] != Bcheck->getSuccessor(1))){ - std::cerr<<"Not a loop!\n"; + std::cerr<<"llvm:: Not a loop!\n"; +#ifdef GET_TRACE_TIME + llvm_trigger_time_end(); +#endif return; } } else{ if(vBB[0] != Bcheck->getSuccessor(0)){ - std::cerr<<"Not a loop!\n"; + std::cerr<<"llvm:: Not a loop!\n"; +#ifdef GET_TRACE_TIME + llvm_trigger_time_end(); +#endif return; } } @@ -158,11 +189,14 @@ //return if SAME trace already there! if(tr->hasTraceAddr(startAddr) && tr->hasTraceId(pn)){ std::cerr<<"Trace exists!!!\n"; +#ifdef GET_TRACE_TIME + llvm_trigger_time_end(); +#endif return; } if(tr->hasTraceAddr(startAddr)){ - std::cerr<<"Removing old trace!\n"; + std::cerr<<"llvm:: Removing old trace!\n"; tr->removeTrace(startAddr); } @@ -228,7 +262,7 @@ //then read until last 4 int skipIndex = (isCondBranch ? 4:2); - std::cerr<<"From->to\t"<<(void *)bbInst.first<<"->"<<(void *)(bbInst.second-4*skipIndex)<<"\n"; + std::cerr<<"llvm:: From->to\t"<<(void *)bbInst.first<<"->"<<(void *)(bbInst.second-4*skipIndex)<<"\n"; for(uint64_t addr = bbInst.first, endAddr = bbInst.second; addr<=endAddr-4*skipIndex; addr+=4, instIndex++){ @@ -433,6 +467,10 @@ //Now add trace to cache, and we are all set! if(!tr->addTrace(startAddr, trace, pn, callMap, branchMap)) std::cerr<<"^^^^^^^^^^************** Trace could not be added!!!\n"; + +#ifdef GET_TRACE_TIME + llvm_trigger_time_end(); +#endif } From lattner at cs.uiuc.edu Tue Oct 15 19:09:00 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Oct 15 19:09:00 2002 Subject: [llvm-commits] CVS: llvm/test/Regression/CBackend/2002-10-15-OpaqueTypeProblem.ll Message-ID: <200210160008.TAA20188@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/CBackend: 2002-10-15-OpaqueTypeProblem.ll added (r1.1) --- Log message: New testcase --- Diffs of the changes: From lattner at cs.uiuc.edu Tue Oct 15 19:09:02 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Oct 15 19:09:02 2002 Subject: [llvm-commits] CVS: llvm/lib/CWriter/Writer.cpp Message-ID: <200210160008.TAA20197@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CWriter: Writer.cpp updated: 1.63 -> 1.64 --- Log message: Fix bug: test/Regression/CBackend/2002-10-15-OpaqueTypeProblem.ll --- Diffs of the changes: Index: llvm/lib/CWriter/Writer.cpp diff -u llvm/lib/CWriter/Writer.cpp:1.63 llvm/lib/CWriter/Writer.cpp:1.64 --- llvm/lib/CWriter/Writer.cpp:1.63 Fri Oct 11 16:40:44 2002 +++ llvm/lib/CWriter/Writer.cpp Tue Oct 15 19:08:22 2002 @@ -196,12 +196,12 @@ } // Check to see if the type is named. - if (!IgnoreName) { + if (!IgnoreName || isa(Ty)) { map::iterator I = TypeNames.find(Ty); if (I != TypeNames.end()) { return Out << I->second << " " << NameSoFar; } - } + } switch (Ty->getPrimitiveID()) { case Type::FunctionTyID: { @@ -256,6 +256,14 @@ unsigned NumElements = ATy->getNumElements(); return printType(ATy->getElementType(), NameSoFar + "[" + utostr(NumElements) + "]"); + } + + case Type::OpaqueTyID: { + static int Count = 0; + string TyName = "struct opaque_" + itostr(Count++); + assert(TypeNames.find(Ty) == TypeNames.end()); + TypeNames[Ty] = TyName; + return Out << TyName << " " << NameSoFar; } default: assert(0 && "Unhandled case in getTypeProps!"); From lattner at cs.uiuc.edu Tue Oct 15 20:18:00 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Oct 15 20:18:00 2002 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/DSGraph.h Message-ID: <200210160117.UAA20701@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis: DSGraph.h updated: 1.4 -> 1.5 --- Log message: Allow direct access to mergemap for printing --- Diffs of the changes: Index: llvm/include/llvm/Analysis/DSGraph.h diff -u llvm/include/llvm/Analysis/DSGraph.h:1.4 llvm/include/llvm/Analysis/DSGraph.h:1.5 --- llvm/include/llvm/Analysis/DSGraph.h:1.4 Thu Oct 10 17:31:02 2002 +++ llvm/include/llvm/Analysis/DSGraph.h Tue Oct 15 20:17:16 2002 @@ -192,6 +192,11 @@ return 0; } + int getMergeMapLabel(unsigned i) { + assert(i < MergeMap.size() && "MergeMap index out of range!"); + return MergeMap[i]; + } + /// setLink - Set the link at the specified offset to the specified /// NodeHandle, replacing what was there. It is uncommon to use this method, /// instead one of the higher level methods should be used, below. From lattner at cs.uiuc.edu Tue Oct 15 20:19:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Oct 15 20:19:01 2002 Subject: [llvm-commits] CVS: llvm/include/Support/GraphWriter.h Message-ID: <200210160118.UAA20715@apoc.cs.uiuc.edu> Changes in directory llvm/include/Support: GraphWriter.h updated: 1.3 -> 1.4 --- Log message: - Generic graph printing infrastructure changes: * Only print outgoing edges from a cell if the destination isn't null. This is important for DSGraphs, which have sources with no edges. * Allow Node attributes to override shape of the node --- Diffs of the changes: Index: llvm/include/Support/GraphWriter.h diff -u llvm/include/Support/GraphWriter.h:1.3 llvm/include/Support/GraphWriter.h:1.4 --- llvm/include/Support/GraphWriter.h:1.3 Thu Oct 10 17:29:51 2002 +++ llvm/include/Support/GraphWriter.h Tue Oct 15 20:18:14 2002 @@ -69,9 +69,9 @@ std::string NodeAttributes = DOTTraits::getNodeAttributes(Node); - O << "\tNode" << (void*)Node << " ["; + O << "\tNode" << (void*)Node << " [shape=record,"; if (!NodeAttributes.empty()) O << NodeAttributes << ","; - O << "shape=record,label=\"{" + O << "label=\"{" << DOT::EscapeString(DOTTraits::getNodeLabel(Node, G)); // Print out the fields of the current node... @@ -94,23 +94,24 @@ // Output all of the edges now EI = GTraits::child_begin(Node); for (unsigned i = 0; EI != EE && i != 64; ++EI, ++i) { - NodeType *TargetNode = *EI; - O << "\tNode" << (void*)Node << ":g" << i << " -> Node" - << (void*)TargetNode; - if (DOTTraits::edgeTargetsEdgeSource(Node, EI)) { - typename GTraits::ChildIteratorType TargetIt = - DOTTraits::getEdgeTarget(Node, EI); - // Figure out which edge this targets... - unsigned Offset = std::distance(GTraits::child_begin(TargetNode), - TargetIt); - if (Offset > 64) Offset = 64; // Targetting the trancated part? - O << ":g" << Offset; + if (NodeType *TargetNode = *EI) { + O << "\tNode" << (void*)Node << ":g" << i << " -> Node" + << (void*)TargetNode; + if (DOTTraits::edgeTargetsEdgeSource(Node, EI)) { + typename GTraits::ChildIteratorType TargetIt = + DOTTraits::getEdgeTarget(Node, EI); + // Figure out which edge this targets... + unsigned Offset = std::distance(GTraits::child_begin(TargetNode), + TargetIt); + if (Offset > 64) Offset = 64; // Targetting the trancated part? + O << ":g" << Offset; + } + + std::string EdgeAttributes = DOTTraits::getEdgeAttributes(Node, EI); + if (!EdgeAttributes.empty()) + O << "[" << EdgeAttributes << "]"; + O << ";\n"; } - - std::string EdgeAttributes = DOTTraits::getEdgeAttributes(Node, EI); - if (!EdgeAttributes.empty()) - O << "[" << EdgeAttributes << "]"; - O << ";\n"; } } From lattner at cs.uiuc.edu Tue Oct 15 20:19:02 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Oct 15 20:19:02 2002 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/Printer.cpp Message-ID: <200210160118.UAA20724@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: Printer.cpp updated: 1.13 -> 1.14 --- Log message: - DSGraph Printing Improvements: * Print edge source labels again * Override node shape to be Mrecord again, instead of just record. --- Diffs of the changes: Index: llvm/lib/Analysis/DataStructure/Printer.cpp diff -u llvm/lib/Analysis/DataStructure/Printer.cpp:1.13 llvm/lib/Analysis/DataStructure/Printer.cpp:1.14 --- llvm/lib/Analysis/DataStructure/Printer.cpp:1.13 Sun Oct 13 14:31:57 2002 +++ llvm/lib/Analysis/DataStructure/Printer.cpp Tue Oct 15 20:18:27 2002 @@ -177,8 +177,7 @@ } static const char *getGraphProperties(DSGraph *G) { - return "\tnode [shape=Mrecord];\n" - "\tedge [arrowtail=\"dot\"];\n" + return "\tedge [arrowtail=\"dot\"];\n" "\tsize=\"10,7.5\";\n" "\trotate=\"90\";\n"; } @@ -188,12 +187,13 @@ } static std::string getNodeAttributes(DSNode *N) { - return "";//fontname=Courier"; + return "shape=Mrecord";//fontname=Courier"; } - //static int getEdgeSourceLabel(DSNode *Node, node_iterator I) { - // return MergeMap[i]; - // } + static int getEdgeSourceLabel(DSNode *Node, DSNode::iterator I) { + assert(Node == I.getNode() && "Iterator not for this node!"); + return Node->getMergeMapLabel(I.getLink()); + } }; @@ -205,7 +205,7 @@ if (F.good()) { WriteGraph(F, this); - print(F); + //print(F); O << " [" << getGraphSize() << "+" << getFunctionCalls().size() << "]\n"; } else { O << " error opening file for writing!\n"; From lattner at cs.uiuc.edu Tue Oct 15 20:35:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Oct 15 20:35:01 2002 Subject: [llvm-commits] CVS: llvm/include/Support/GraphWriter.h Message-ID: <200210160134.UAA20890@apoc.cs.uiuc.edu> Changes in directory llvm/include/Support: GraphWriter.h updated: 1.4 -> 1.5 --- Log message: * Significantly refactor GraphWriter into a class. --- Diffs of the changes: Index: llvm/include/Support/GraphWriter.h diff -u llvm/include/Support/GraphWriter.h:1.4 llvm/include/Support/GraphWriter.h:1.5 --- llvm/include/Support/GraphWriter.h:1.4 Tue Oct 15 20:18:14 2002 +++ llvm/include/Support/GraphWriter.h Tue Oct 15 20:34:18 2002 @@ -49,74 +49,102 @@ } template -std::ostream &WriteGraph(std::ostream &O, const GraphType &G) { - typedef DOTGraphTraits DOTTraits; - typedef GraphTraits GTraits; - typedef typename GTraits::NodeType NodeType; - typedef typename GTraits::nodes_iterator node_iterator; - - O << "digraph foo {\n"; // Graph name doesn't matter - std::string GraphName = DOTTraits::getGraphName(G); - if (!GraphName.empty()) - O << "\tlabel=\"" << DOT::EscapeString(GraphName) << "\";\n"; - O << DOTTraits::getGraphProperties(G); - O << "\n"; - - // Loop over the graph in DFO, printing it out... - for (node_iterator I = GTraits::nodes_begin(G), E = GTraits::nodes_end(G); - I != E; ++I) { - NodeType *Node = &*I; +class GraphWriter { + std::ostream &O; + const GraphType &G; + + typedef DOTGraphTraits DOTTraits; + typedef GraphTraits GTraits; + typedef typename GTraits::NodeType NodeType; + typedef typename GTraits::nodes_iterator node_iterator; + typedef typename GTraits::ChildIteratorType child_iterator; +public: + GraphWriter(std::ostream &o, const GraphType &g, + const std::string &Name) : O(o), G(g) { + if (Name.empty()) + O << "digraph foo {\n"; // Graph name doesn't matter + else + O << "digraph " << Name << " {\n"; + + std::string GraphName = DOTTraits::getGraphName(G); + if (!GraphName.empty()) + O << "\tlabel=\"" << DOT::EscapeString(GraphName) << "\";\n"; + O << DOTTraits::getGraphProperties(G); + O << "\n"; - std::string NodeAttributes = DOTTraits::getNodeAttributes(Node); + writeNodes(); + } + + ~GraphWriter() { + // Finish off the graph + O << "}\n"; + } + void writeNodes() { + // Loop over the graph, printing it out... + for (node_iterator I = GTraits::nodes_begin(G), E = GTraits::nodes_end(G); + I != E; ++I) + writeNode(&*I); + } + + void writeNode(NodeType *Node) { + std::string NodeAttributes = DOTTraits::getNodeAttributes(Node); + O << "\tNode" << (void*)Node << " [shape=record,"; if (!NodeAttributes.empty()) O << NodeAttributes << ","; O << "label=\"{" << DOT::EscapeString(DOTTraits::getNodeLabel(Node, G)); // Print out the fields of the current node... - typename GTraits::ChildIteratorType EI = GTraits::child_begin(Node); - typename GTraits::ChildIteratorType EE = GTraits::child_end(Node); + child_iterator EI = GTraits::child_begin(Node); + child_iterator EE = GTraits::child_end(Node); if (EI != EE) { O << "|{"; - + for (unsigned i = 0; EI != EE && i != 64; ++EI, ++i) { if (i) O << "|"; O << "" << DOTTraits::getEdgeSourceLabel(Node, EI); } - + if (EI != EE) O << "|truncated..."; O << "}"; } O << "}\"];\n"; // Finish printing the "node" line - + // Output all of the edges now EI = GTraits::child_begin(Node); - for (unsigned i = 0; EI != EE && i != 64; ++EI, ++i) { - if (NodeType *TargetNode = *EI) { - O << "\tNode" << (void*)Node << ":g" << i << " -> Node" - << (void*)TargetNode; - if (DOTTraits::edgeTargetsEdgeSource(Node, EI)) { - typename GTraits::ChildIteratorType TargetIt = - DOTTraits::getEdgeTarget(Node, EI); - // Figure out which edge this targets... - unsigned Offset = std::distance(GTraits::child_begin(TargetNode), - TargetIt); - if (Offset > 64) Offset = 64; // Targetting the trancated part? - O << ":g" << Offset; - } - - std::string EdgeAttributes = DOTTraits::getEdgeAttributes(Node, EI); - if (!EdgeAttributes.empty()) - O << "[" << EdgeAttributes << "]"; - O << ";\n"; + for (unsigned i = 0; EI != EE && i != 64; ++EI, ++i) + writeEdge(Node, i, EI); + } + + void writeEdge(NodeType *Node, unsigned edgeidx, child_iterator EI) { + if (NodeType *TargetNode = *EI) { + O << "\tNode" << (void*)Node << ":g" << edgeidx << " -> Node" + << (void*)TargetNode; + if (DOTTraits::edgeTargetsEdgeSource(Node, EI)) { + child_iterator TargetIt = DOTTraits::getEdgeTarget(Node, EI); + + // Figure out which edge this targets... + unsigned Offset = std::distance(GTraits::child_begin(TargetNode), + TargetIt); + if (Offset > 64) Offset = 64; // Targetting the truncated part? + O << ":g" << Offset; } + + std::string EdgeAttributes = DOTTraits::getEdgeAttributes(Node, EI); + if (!EdgeAttributes.empty()) + O << "[" << EdgeAttributes << "]"; + O << ";\n"; } } +}; - // Finish off the graph - O << "}\n"; +template +std::ostream &WriteGraph(std::ostream &O, const GraphType &G, + const std::string &Name = "") { + // Start the graph emission process... + GraphWriter W(O, G, Name); return O; } From lattner at cs.uiuc.edu Tue Oct 15 20:35:02 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Oct 15 20:35:02 2002 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/Printer.cpp Message-ID: <200210160134.UAA20897@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: Printer.cpp updated: 1.14 -> 1.15 --- Log message: Specify the graph name --- Diffs of the changes: Index: llvm/lib/Analysis/DataStructure/Printer.cpp diff -u llvm/lib/Analysis/DataStructure/Printer.cpp:1.14 llvm/lib/Analysis/DataStructure/Printer.cpp:1.15 --- llvm/lib/Analysis/DataStructure/Printer.cpp:1.14 Tue Oct 15 20:18:27 2002 +++ llvm/lib/Analysis/DataStructure/Printer.cpp Tue Oct 15 20:34:28 2002 @@ -204,7 +204,7 @@ std::ofstream F(Filename.c_str()); if (F.good()) { - WriteGraph(F, this); + WriteGraph(F, this, "DataStructures"); //print(F); O << " [" << getGraphSize() << "+" << getFunctionCalls().size() << "]\n"; } else { From lattner at cs.uiuc.edu Tue Oct 15 20:44:00 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Oct 15 20:44:00 2002 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/DSGraphTraits.h Message-ID: <200210160143.UAA21038@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis: DSGraphTraits.h updated: 1.7 -> 1.8 --- Log message: The second element of the iterator is really an offset, not a link --- Diffs of the changes: Index: llvm/include/llvm/Analysis/DSGraphTraits.h diff -u llvm/include/llvm/Analysis/DSGraphTraits.h:1.7 llvm/include/llvm/Analysis/DSGraphTraits.h:1.8 --- llvm/include/llvm/Analysis/DSGraphTraits.h:1.7 Sun Oct 13 14:31:34 2002 +++ llvm/include/llvm/Analysis/DSGraphTraits.h Tue Oct 15 20:43:09 2002 @@ -17,42 +17,44 @@ class DSNodeIterator : public forward_iterator { friend class DSNode; DSNode * const Node; - unsigned Link; + unsigned Offset; typedef DSNodeIterator _Self; - DSNodeIterator(DSNode *N) : Node(N), Link(0) {} // begin iterator + DSNodeIterator(DSNode *N) : Node(N), Offset(0) {} // begin iterator DSNodeIterator(DSNode *N, bool) // Create end iterator - : Node(N), Link(N->getSize()) { + : Node(N), Offset(N->getSize()) { } public: + DSNodeIterator(const DSNodeHandle &NH) + : Node(NH.getNode()), Offset(NH.getOffset()) {} bool operator==(const _Self& x) const { - return Link == x.Link; + return Offset == x.Offset; } bool operator!=(const _Self& x) const { return !operator==(x); } const _Self &operator=(const _Self &I) { assert(I.Node == Node && "Cannot assign iterators to two different nodes!"); - Link = I.Link; + Offset = I.Offset; return *this; } pointer operator*() const { - DSNodeHandle *NH = Node->getLink(Link); + DSNodeHandle *NH = Node->getLink(Offset); return NH ? NH->getNode() : 0; } pointer operator->() const { return operator*(); } _Self& operator++() { // Preincrement - ++Link; + ++Offset; return *this; } _Self operator++(int) { // Postincrement _Self tmp = *this; ++*this; return tmp; } - unsigned getLink() const { return Link; } + unsigned getOffset() const { return Offset; } DSNode *getNode() const { return Node; } }; From lattner at cs.uiuc.edu Tue Oct 15 20:44:02 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Oct 15 20:44:02 2002 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/Printer.cpp Message-ID: <200210160143.UAA21045@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: Printer.cpp updated: 1.15 -> 1.16 --- Log message: The second element of the iterator is really an offset, not a link --- Diffs of the changes: Index: llvm/lib/Analysis/DataStructure/Printer.cpp diff -u llvm/lib/Analysis/DataStructure/Printer.cpp:1.15 llvm/lib/Analysis/DataStructure/Printer.cpp:1.16 --- llvm/lib/Analysis/DataStructure/Printer.cpp:1.15 Tue Oct 15 20:34:28 2002 +++ llvm/lib/Analysis/DataStructure/Printer.cpp Tue Oct 15 20:43:11 2002 @@ -192,7 +192,7 @@ static int getEdgeSourceLabel(DSNode *Node, DSNode::iterator I) { assert(Node == I.getNode() && "Iterator not for this node!"); - return Node->getMergeMapLabel(I.getLink()); + return Node->getMergeMapLabel(I.getOffset()); } }; From lattner at cs.uiuc.edu Tue Oct 15 20:46:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Oct 15 20:46:01 2002 Subject: [llvm-commits] CVS: llvm/include/Support/DOTGraphTraits.h GraphWriter.h Message-ID: <200210160145.UAA21124@apoc.cs.uiuc.edu> Changes in directory llvm/include/Support: DOTGraphTraits.h updated: 1.2 -> 1.3 GraphWriter.h updated: 1.5 -> 1.6 --- Log message: * Add new DOTGraphTraits::addCustomGraphFeatures method --- Diffs of the changes: Index: llvm/include/Support/DOTGraphTraits.h diff -u llvm/include/Support/DOTGraphTraits.h:1.2 llvm/include/Support/DOTGraphTraits.h:1.3 --- llvm/include/Support/DOTGraphTraits.h:1.2 Thu Oct 10 17:29:10 2002 +++ llvm/include/Support/DOTGraphTraits.h Tue Oct 15 20:44:59 2002 @@ -60,6 +60,15 @@ /// edge. template static EdgeIter getEdgeTarget(void *Node, EdgeIter I) { return I; } + + /// addCustomGraphFeatures - If a graph is made up of more than just + /// straight-forward nodes and edges, this is the place to put all of the + /// custom stuff neccesary. The GraphWriter object, instantiated with your + /// GraphType is passed in as an argument. You may call arbitrary methods on + /// it to add things to the output graph. + /// + template + static void addCustomGraphFeatures(void *Graph, GraphWriter &GW) {} }; Index: llvm/include/Support/GraphWriter.h diff -u llvm/include/Support/GraphWriter.h:1.5 llvm/include/Support/GraphWriter.h:1.6 --- llvm/include/Support/GraphWriter.h:1.5 Tue Oct 15 20:34:18 2002 +++ llvm/include/Support/GraphWriter.h Tue Oct 15 20:44:59 2002 @@ -72,7 +72,11 @@ O << DOTTraits::getGraphProperties(G); O << "\n"; + // Emit all of the nodes in the graph... writeNodes(); + + // Output any customizations on the graph + DOTTraits::addCustomGraphFeatures(G, *this); } ~GraphWriter() { From lattner at cs.uiuc.edu Tue Oct 15 21:04:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Oct 15 21:04:01 2002 Subject: [llvm-commits] CVS: llvm/include/Support/GraphWriter.h Message-ID: <200210160203.VAA21349@apoc.cs.uiuc.edu> Changes in directory llvm/include/Support: GraphWriter.h updated: 1.6 -> 1.7 --- Log message: * Factor printing code again, add emitSimpleNode method --- Diffs of the changes: Index: llvm/include/Support/GraphWriter.h diff -u llvm/include/Support/GraphWriter.h:1.6 llvm/include/Support/GraphWriter.h:1.7 --- llvm/include/Support/GraphWriter.h:1.6 Tue Oct 15 20:44:59 2002 +++ llvm/include/Support/GraphWriter.h Tue Oct 15 21:03:18 2002 @@ -124,8 +124,7 @@ void writeEdge(NodeType *Node, unsigned edgeidx, child_iterator EI) { if (NodeType *TargetNode = *EI) { - O << "\tNode" << (void*)Node << ":g" << edgeidx << " -> Node" - << (void*)TargetNode; + int DestPort = -1; if (DOTTraits::edgeTargetsEdgeSource(Node, EI)) { child_iterator TargetIt = DOTTraits::getEdgeTarget(Node, EI); @@ -133,14 +132,36 @@ unsigned Offset = std::distance(GTraits::child_begin(TargetNode), TargetIt); if (Offset > 64) Offset = 64; // Targetting the truncated part? - O << ":g" << Offset; + DestPort = (int)Offset; } - - std::string EdgeAttributes = DOTTraits::getEdgeAttributes(Node, EI); - if (!EdgeAttributes.empty()) - O << "[" << EdgeAttributes << "]"; - O << ";\n"; + + emitEdge((void *)Node, edgeidx, (void*)TargetNode, DestPort, + DOTTraits::getEdgeAttributes(Node, EI)); } + } + + /// emitSimpleNode - Outputs a simple (non-record) node + void emitSimpleNode(void *ID, const std::string &Attr, + const std::string &Label) { + O << "\tNode" << ID << "[ "; + if (!Attr.empty()) + O << Attr << ","; + O << " label =\"" << DOT::EscapeString(Label) << "\"];\n"; + } + + /// emitEdge - Output an edge from a simple node into the graph... + void emitEdge(void *SrcNodeID, int SrcNodePort, + void *DestNodeID, int DestNodePort, const std::string &Attrs) { + O << "\tNode" << SrcNodeID; + if (SrcNodePort >= 0) + O << ":g" << SrcNodePort; + O << " -> Node" << (void*)DestNodeID; + if (DestNodePort >= 0) + O << ":g" << DestNodePort; + + if (!Attrs.empty()) + O << "[" << Attrs << "]"; + O << ";\n"; } }; From lattner at cs.uiuc.edu Tue Oct 15 21:05:00 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Oct 15 21:05:00 2002 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/Printer.cpp Message-ID: <200210160204.VAA21360@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: Printer.cpp updated: 1.16 -> 1.17 --- Log message: * Print the "return" node in the graphs --- Diffs of the changes: Index: llvm/lib/Analysis/DataStructure/Printer.cpp diff -u llvm/lib/Analysis/DataStructure/Printer.cpp:1.16 llvm/lib/Analysis/DataStructure/Printer.cpp:1.17 --- llvm/lib/Analysis/DataStructure/Printer.cpp:1.16 Tue Oct 15 20:43:11 2002 +++ llvm/lib/Analysis/DataStructure/Printer.cpp Tue Oct 15 21:04:36 2002 @@ -146,7 +146,7 @@ O << "\tNode0x1" << "[ plaintext=circle, label =\"" << escapeLabel("returning") << "\"];\n"; writeEdge(O, (void*)1, "", -1, RetNode, "arrowtail=tee,color=gray63"); - } + } // Output all of the call nodes... for (unsigned i = 0, e = FunctionCalls.size(); i != e; ++i) { @@ -193,6 +193,23 @@ static int getEdgeSourceLabel(DSNode *Node, DSNode::iterator I) { assert(Node == I.getNode() && "Iterator not for this node!"); return Node->getMergeMapLabel(I.getOffset()); + } + + /// addCustomGraphFeatures - Use this graph writing hook to emit call nodes + /// and the return node. + /// + static void addCustomGraphFeatures(DSGraph *G, GraphWriter &GW) { + // Output the returned value pointer... + if (G->getRetNode().getNode() != 0) { + // Output the return node... + GW.emitSimpleNode((void*)1, "plaintext=circle", "returning"); + + // Add edge from return node to real destination + int RetEdgeDest = G->getRetNode().getOffset(); + if (RetEdgeDest == 0) RetEdgeDest = -1; + GW.emitEdge((void*)1, -1, G->getRetNode().getNode(), + RetEdgeDest, "arrowtail=tee,color=gray63"); + } } }; From lattner at cs.uiuc.edu Wed Oct 16 15:09:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Oct 16 15:09:01 2002 Subject: [llvm-commits] CVS: llvm/test/Regression/CBackend/2002-10-16-External.ll Message-ID: <200210162008.PAA25624@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/CBackend: 2002-10-16-External.ll added (r1.1) --- Log message: New testcase --- Diffs of the changes: From lattner at cs.uiuc.edu Wed Oct 16 15:09:07 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Oct 16 15:09:07 2002 Subject: [llvm-commits] CVS: llvm/lib/CWriter/Writer.cpp Message-ID: <200210162008.PAA25640@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CWriter: Writer.cpp updated: 1.64 -> 1.65 --- Log message: Fix bug: CBackend/2002-10-16-External.ll --- Diffs of the changes: Index: llvm/lib/CWriter/Writer.cpp diff -u llvm/lib/CWriter/Writer.cpp:1.64 llvm/lib/CWriter/Writer.cpp:1.65 --- llvm/lib/CWriter/Writer.cpp:1.64 Tue Oct 15 19:08:22 2002 +++ llvm/lib/CWriter/Writer.cpp Wed Oct 16 15:08:47 2002 @@ -572,17 +572,16 @@ // Output the global variable definitions and contents... if (!M->gempty()) { Out << "\n\n/* Global Variable Definitions and Initialization */\n"; - for (Module::giterator I = M->gbegin(), E = M->gend(); I != E; ++I) { - if (I->hasInternalLinkage()) - Out << "static "; - printType(I->getType()->getElementType(), getValueName(I)); + for (Module::giterator I = M->gbegin(), E = M->gend(); I != E; ++I) + if (!I->isExternal()) { + if (I->hasInternalLinkage()) + Out << "static "; + printType(I->getType()->getElementType(), getValueName(I)); - if (I->hasInitializer()) { Out << " = " ; writeOperand(I->getInitializer()); + Out << ";\n"; } - Out << ";\n"; - } } // Output all of the functions... From lattner at cs.uiuc.edu Wed Oct 16 15:16:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Oct 16 15:16:01 2002 Subject: [llvm-commits] CVS: llvm/include/Support/GraphWriter.h Message-ID: <200210162015.PAA25679@apoc.cs.uiuc.edu> Changes in directory llvm/include/Support: GraphWriter.h updated: 1.7 -> 1.8 --- Log message: Allow simple nodes to have outgoing edges --- Diffs of the changes: Index: llvm/include/Support/GraphWriter.h diff -u llvm/include/Support/GraphWriter.h:1.7 llvm/include/Support/GraphWriter.h:1.8 --- llvm/include/Support/GraphWriter.h:1.7 Tue Oct 15 21:03:18 2002 +++ llvm/include/Support/GraphWriter.h Wed Oct 16 15:15:38 2002 @@ -141,17 +141,28 @@ } /// emitSimpleNode - Outputs a simple (non-record) node - void emitSimpleNode(void *ID, const std::string &Attr, - const std::string &Label) { + void emitSimpleNode(const void *ID, const std::string &Attr, + const std::string &Label, unsigned NumEdgeSources = 0) { O << "\tNode" << ID << "[ "; if (!Attr.empty()) O << Attr << ","; - O << " label =\"" << DOT::EscapeString(Label) << "\"];\n"; + O << " label =\"{" << DOT::EscapeString(Label); + if (NumEdgeSources) { + O << "|{"; + + for (unsigned i = 0; i != NumEdgeSources; ++i) { + if (i) O << "|"; + O << ""; + } + O << "}"; + } + O << "}\"];\n"; } /// emitEdge - Output an edge from a simple node into the graph... - void emitEdge(void *SrcNodeID, int SrcNodePort, - void *DestNodeID, int DestNodePort, const std::string &Attrs) { + void emitEdge(const void *SrcNodeID, int SrcNodePort, + const void *DestNodeID, int DestNodePort, + const std::string &Attrs) { O << "\tNode" << SrcNodeID; if (SrcNodePort >= 0) O << ":g" << SrcNodePort; From lattner at cs.uiuc.edu Wed Oct 16 15:17:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Oct 16 15:17:01 2002 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/Printer.cpp Message-ID: <200210162016.PAA25690@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: Printer.cpp updated: 1.17 -> 1.18 --- Log message: Make sure to print out the call nodes as well --- Diffs of the changes: Index: llvm/lib/Analysis/DataStructure/Printer.cpp diff -u llvm/lib/Analysis/DataStructure/Printer.cpp:1.17 llvm/lib/Analysis/DataStructure/Printer.cpp:1.18 --- llvm/lib/Analysis/DataStructure/Printer.cpp:1.17 Tue Oct 15 21:04:36 2002 +++ llvm/lib/Analysis/DataStructure/Printer.cpp Wed Oct 16 15:16:16 2002 @@ -210,9 +210,22 @@ GW.emitEdge((void*)1, -1, G->getRetNode().getNode(), RetEdgeDest, "arrowtail=tee,color=gray63"); } + + // Output all of the call nodes... + const std::vector > &FCs = G->getFunctionCalls(); + for (unsigned i = 0, e = FCs.size(); i != e; ++i) { + const std::vector &Call = FCs[i]; + GW.emitSimpleNode(&Call, "shape=record", "call", Call.size()); + + for (unsigned j = 0, e = Call.size(); j != e; ++j) + if (Call[j].getNode()) { + int EdgeDest = Call[j].getOffset(); + if (EdgeDest == 0) EdgeDest = -1; + GW.emitEdge(&Call, j, Call[j].getNode(), EdgeDest, "color=gray63"); + } + } } }; - void DSGraph::writeGraphToFile(std::ostream &O, const string &GraphName) { From hldnbrnd at cs.uiuc.edu Wed Oct 16 17:13:01 2002 From: hldnbrnd at cs.uiuc.edu (Nicholas Hildenbrandt) Date: Wed Oct 16 17:13:01 2002 Subject: [llvm-commits] CVS: llvm/www/docs/TestStatus.html Message-ID: <200210162212.RAA09093@tank.cs.uiuc.edu> Changes in directory llvm/www/docs: TestStatus.html updated: 1.6 -> 1.7 --- Log message: changes --- Diffs of the changes: Index: llvm/www/docs/TestStatus.html diff -u llvm/www/docs/TestStatus.html:1.6 llvm/www/docs/TestStatus.html:1.7 --- llvm/www/docs/TestStatus.html:1.6 Sun Oct 13 20:08:06 2002 +++ llvm/www/docs/TestStatus.html Wed Oct 16 17:12:31 2002 @@ -63,7 +63,7 @@ Olden-treaddXXX Olden-tspXXX Olden-voronoiXXOInfinite loop -OptimizerEvalXXO +OptimizerEvalXXOIt is a timing test, so not matching is expected. sgefaXXXBoth native and cbe seg fault simXXO From jstanley at cs.uiuc.edu Wed Oct 16 18:27:00 2002 From: jstanley at cs.uiuc.edu (Joel Stanley) Date: Wed Oct 16 18:27:00 2002 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/Dominators.h Message-ID: <200210162326.SAA21228@choi.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis: Dominators.h updated: 1.27 -> 1.28 --- Log message: Added partial specialization of GraphTraits for the DominatorTree class. --- Diffs of the changes: Index: llvm/include/llvm/Analysis/Dominators.h diff -u llvm/include/llvm/Analysis/Dominators.h:1.27 llvm/include/llvm/Analysis/Dominators.h:1.28 --- llvm/include/llvm/Analysis/Dominators.h:1.27 Tue Oct 8 14:12:05 2002 +++ llvm/include/llvm/Analysis/Dominators.h Wed Oct 16 18:26:00 2002 @@ -19,6 +19,7 @@ #define LLVM_ANALYSIS_DOMINATORS_H #include "llvm/Pass.h" +#include "Support/GraphTraits.h" #include class Instruction; @@ -341,6 +342,24 @@ void calculate(const DominatorSet &DS); }; +//===------------------------------------- +// DominatorTree GraphTraits specialization so the DominatorTree can be +// iterable by generic graph iterators. + +template <> struct GraphTraits { + typedef DominatorTree::Node NodeType; + typedef NodeType::iterator ChildIteratorType; + + static NodeType *getEntryNode(DominatorTree *DT) { + return DT->getNode(DT->getRoot()); + } + static inline ChildIteratorType child_begin(NodeType* N) { + return N->begin(); + } + static inline ChildIteratorType child_end(NodeType* N) { + return N->end(); + } +}; //===----------------------------------------------------------------------===// // From lattner at cs.uiuc.edu Wed Oct 16 19:17:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Oct 16 19:17:01 2002 Subject: [llvm-commits] CVS: llvm/include/Support/DOTGraphTraits.h Message-ID: <200210170016.TAA26967@apoc.cs.uiuc.edu> Changes in directory llvm/include/Support: DOTGraphTraits.h updated: 1.3 -> 1.4 --- Log message: As wierd as it feels to type it, const void* is more generic than void* --- Diffs of the changes: Index: llvm/include/Support/DOTGraphTraits.h diff -u llvm/include/Support/DOTGraphTraits.h:1.3 llvm/include/Support/DOTGraphTraits.h:1.4 --- llvm/include/Support/DOTGraphTraits.h:1.3 Tue Oct 15 20:44:59 2002 +++ llvm/include/Support/DOTGraphTraits.h Wed Oct 16 19:16:39 2002 @@ -21,45 +21,55 @@ /// getGraphName - Return the label for the graph as a whole. Printed at the /// top of the graph. /// - static std::string getGraphName(void *Graph) { return ""; } + static std::string getGraphName(const void *Graph) { return ""; } /// getGraphProperties - Return any custom properties that should be included /// in the top level graph structure for dot. By default, we resize the graph /// to fit on a letter size page. /// - static std::string getGraphProperties(void *Graph) { + static std::string getGraphProperties(const void *Graph) { return "\tsize=\"7.5,10\";\n"; // Size to fit on a page } /// getNodeLabel - Given a node and a pointer to the top level graph, return /// the label to print in the node. - static std::string getNodeLabel(void *Node, void *Graph) { return ""; } + static std::string getNodeLabel(const void *Node, const void *Graph) { + return ""; + } /// If you want to specify custom node attributes, this is the place to do so /// - static std::string getNodeAttributes(void *Node) { return ""; } + static std::string getNodeAttributes(const void *Node) { return ""; } /// If you want to override the dot attributes printed for a particular edge, /// override this method. template - static std::string getEdgeAttributes(void *Node, EdgeIter EI) { return ""; } + static std::string getEdgeAttributes(const void *Node, EdgeIter EI) { + return ""; + } /// getEdgeSourceLabel - If you want to label the edge source itself, /// implement this method. template - static std::string getEdgeSourceLabel(void *Node, EdgeIter I) { return ""; } + static std::string getEdgeSourceLabel(const void *Node, EdgeIter I) { + return ""; + } /// edgeTargetsEdgeSource - This method returns true if this outgoing edge /// should actually target another edge source, not a node. If this method is /// implemented, getEdgeTarget should be implemented. template - static bool edgeTargetsEdgeSource(void *Node, EdgeIter I) { return false; } + static bool edgeTargetsEdgeSource(const void *Node, EdgeIter I) { + return false; + } /// getEdgeTarget - If edgeTargetsEdgeSource returns true, this method is /// called to determine which outgoing edge of Node is the target of this /// edge. template - static EdgeIter getEdgeTarget(void *Node, EdgeIter I) { return I; } + static EdgeIter getEdgeTarget(const void *Node, EdgeIter I) { + return I; + } /// addCustomGraphFeatures - If a graph is made up of more than just /// straight-forward nodes and edges, this is the place to put all of the @@ -68,7 +78,7 @@ /// it to add things to the output graph. /// template - static void addCustomGraphFeatures(void *Graph, GraphWriter &GW) {} + static void addCustomGraphFeatures(const void *Graph, GraphWriter &GW) {} }; From lattner at cs.uiuc.edu Wed Oct 16 20:01:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Oct 16 20:01:01 2002 Subject: [llvm-commits] CVS: llvm/include/Support/GraphWriter.h Message-ID: <200210170100.UAA27053@apoc.cs.uiuc.edu> Changes in directory llvm/include/Support: GraphWriter.h updated: 1.8 -> 1.9 --- Log message: Break up the GraphWriter into smaller chunks to be used in different ways --- Diffs of the changes: Index: llvm/include/Support/GraphWriter.h diff -u llvm/include/Support/GraphWriter.h:1.8 llvm/include/Support/GraphWriter.h:1.9 --- llvm/include/Support/GraphWriter.h:1.8 Wed Oct 16 15:15:38 2002 +++ llvm/include/Support/GraphWriter.h Wed Oct 16 19:59:59 2002 @@ -59,8 +59,9 @@ typedef typename GTraits::nodes_iterator node_iterator; typedef typename GTraits::ChildIteratorType child_iterator; public: - GraphWriter(std::ostream &o, const GraphType &g, - const std::string &Name) : O(o), G(g) { + GraphWriter(std::ostream &o, const GraphType &g) : O(o), G(g) {} + + void writeHeader(const std::string &Name) { if (Name.empty()) O << "digraph foo {\n"; // Graph name doesn't matter else @@ -71,15 +72,9 @@ O << "\tlabel=\"" << DOT::EscapeString(GraphName) << "\";\n"; O << DOTTraits::getGraphProperties(G); O << "\n"; - - // Emit all of the nodes in the graph... - writeNodes(); - - // Output any customizations on the graph - DOTTraits::addCustomGraphFeatures(G, *this); } - ~GraphWriter() { + void writeFooter() { // Finish off the graph O << "}\n"; } @@ -180,7 +175,19 @@ std::ostream &WriteGraph(std::ostream &O, const GraphType &G, const std::string &Name = "") { // Start the graph emission process... - GraphWriter W(O, G, Name); + GraphWriter W(O, G); + + // Output the header for the graph... + W.writeHeader(Name); + + // Emit all of the nodes in the graph... + W.writeNodes(); + + // Output any customizations on the graph + DOTGraphTraits::addCustomGraphFeatures(G, W); + + // Output the end of the graph + W.writeFooter(); return O; } From lattner at cs.uiuc.edu Wed Oct 16 20:02:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Oct 16 20:02:01 2002 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/DSGraph.h DSGraphTraits.h Message-ID: <200210170101.UAA27079@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis: DSGraph.h updated: 1.5 -> 1.6 DSGraphTraits.h updated: 1.8 -> 1.9 --- Log message: Be const correct. Handle both DSGraph* and const DSGraph*'s --- Diffs of the changes: Index: llvm/include/llvm/Analysis/DSGraph.h diff -u llvm/include/llvm/Analysis/DSGraph.h:1.5 llvm/include/llvm/Analysis/DSGraph.h:1.6 --- llvm/include/llvm/Analysis/DSGraph.h:1.5 Tue Oct 15 20:17:16 2002 +++ llvm/include/llvm/Analysis/DSGraph.h Wed Oct 16 20:01:06 2002 @@ -157,8 +157,9 @@ // Iterator for graph interface... typedef DSNodeIterator iterator; - inline iterator begin(); // Defined in DSGraphTraits.h - inline iterator end(); + typedef DSNodeIterator const_iterator; + inline iterator begin() const; // Defined in DSGraphTraits.h + inline iterator end() const; //===-------------------------------------------------- // Accessors @@ -192,7 +193,7 @@ return 0; } - int getMergeMapLabel(unsigned i) { + int getMergeMapLabel(unsigned i) const { assert(i < MergeMap.size() && "MergeMap index out of range!"); return MergeMap[i]; } @@ -418,7 +419,7 @@ void print(std::ostream &O) const; void dump() const; - void writeGraphToFile(std::ostream &O, const std::string &GraphName); + void writeGraphToFile(std::ostream &O, const std::string &GraphName) const; // maskNodeTypes - Apply a mask to all of the node types in the graph. This // is useful for clearing out markers like Scalar or Incomplete. Index: llvm/include/llvm/Analysis/DSGraphTraits.h diff -u llvm/include/llvm/Analysis/DSGraphTraits.h:1.8 llvm/include/llvm/Analysis/DSGraphTraits.h:1.9 --- llvm/include/llvm/Analysis/DSGraphTraits.h:1.8 Tue Oct 15 20:43:09 2002 +++ llvm/include/llvm/Analysis/DSGraphTraits.h Wed Oct 16 20:01:06 2002 @@ -14,15 +14,15 @@ #include "Support/iterator" #include "Support/STLExtras.h" -class DSNodeIterator : public forward_iterator { +class DSNodeIterator : public forward_iterator { friend class DSNode; - DSNode * const Node; + const DSNode * const Node; unsigned Offset; typedef DSNodeIterator _Self; - DSNodeIterator(DSNode *N) : Node(N), Offset(0) {} // begin iterator - DSNodeIterator(DSNode *N, bool) // Create end iterator + DSNodeIterator(const DSNode *N) : Node(N), Offset(0) {} // begin iterator + DSNodeIterator(const DSNode *N, bool) // Create end iterator : Node(N), Offset(N->getSize()) { } public: @@ -41,7 +41,7 @@ } pointer operator*() const { - DSNodeHandle *NH = Node->getLink(Offset); + const DSNodeHandle *NH = Node->getLink(Offset); return NH ? NH->getNode() : 0; } pointer operator->() const { return operator*(); } @@ -55,12 +55,12 @@ } unsigned getOffset() const { return Offset; } - DSNode *getNode() const { return Node; } + const DSNode *getNode() const { return Node; } }; // Provide iterators for DSNode... -inline DSNode::iterator DSNode::begin() { return DSNodeIterator(this); } -inline DSNode::iterator DSNode::end() { return DSNodeIterator(this, false); } +inline DSNode::iterator DSNode::begin() const { return DSNodeIterator(this); } +inline DSNode::iterator DSNode::end() const { return DSNodeIterator(this, false); } template <> struct GraphTraits { typedef DSNode NodeType; @@ -71,7 +71,8 @@ static ChildIteratorType child_end(NodeType *N) { return N->end(); } }; -static DSNode &dereference(DSNode *N) { return *N; } +static DSNode &dereference ( DSNode *N) { return *N; } +static const DSNode &dereferenceC(const DSNode *N) { return *N; } template <> struct GraphTraits { typedef DSNode NodeType; @@ -82,11 +83,35 @@ // nodes_iterator/begin/end - Allow iteration over all nodes in the graph typedef mapped_iterator::iterator, DerefFun> nodes_iterator; - static nodes_iterator nodes_begin(DSGraph *G) { return map_iterator(G->getNodes().begin(), DerefFun(dereference));} - static nodes_iterator nodes_end (DSGraph *G) { return map_iterator(G->getNodes().end(), DerefFun(dereference)); } + static nodes_iterator nodes_begin(DSGraph *G) { + return map_iterator(G->getNodes().begin(), DerefFun(dereference)); + } + static nodes_iterator nodes_end(DSGraph *G) { + return map_iterator(G->getNodes().end(), DerefFun(dereference)); + } static ChildIteratorType child_begin(NodeType *N) { return N->begin(); } static ChildIteratorType child_end(NodeType *N) { return N->end(); } +}; + +template <> struct GraphTraits { + typedef const DSNode NodeType; + typedef DSNode::iterator ChildIteratorType; + + typedef std::pointer_to_unary_function DerefFun; + + // nodes_iterator/begin/end - Allow iteration over all nodes in the graph + typedef mapped_iterator::const_iterator, + DerefFun> nodes_iterator; + static nodes_iterator nodes_begin(const DSGraph *G) { + return map_iterator(G->getNodes().begin(), DerefFun(dereferenceC)); + } + static nodes_iterator nodes_end(const DSGraph *G) { + return map_iterator(G->getNodes().end(), DerefFun(dereferenceC)); + } + + static ChildIteratorType child_begin(const NodeType *N) { return N->begin(); } + static ChildIteratorType child_end(const NodeType *N) { return N->end(); } }; #endif From lattner at cs.uiuc.edu Wed Oct 16 20:03:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Oct 16 20:03:01 2002 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/Printer.cpp Message-ID: <200210170102.UAA27100@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: Printer.cpp updated: 1.18 -> 1.19 --- Log message: Cleanup data structure graph printer, eliminate hard coded printing in favor of generic printer. --- Diffs of the changes: Index: llvm/lib/Analysis/DataStructure/Printer.cpp diff -u llvm/lib/Analysis/DataStructure/Printer.cpp:1.18 llvm/lib/Analysis/DataStructure/Printer.cpp:1.19 --- llvm/lib/Analysis/DataStructure/Printer.cpp:1.18 Wed Oct 16 15:16:16 2002 +++ llvm/lib/Analysis/DataStructure/Printer.cpp Wed Oct 16 20:02:46 2002 @@ -57,140 +57,30 @@ return OS.str(); } -static string getValueName(Value *V, Function &F) { - std::stringstream OS; - WriteAsOperand(OS, V, true, true, F.getParent()); - return OS.str(); -} - - - -static void replaceIn(string &S, char From, const string &To) { - for (unsigned i = 0; i < S.size(); ) - if (S[i] == From) { - S.replace(S.begin()+i, S.begin()+i+1, - To.begin(), To.end()); - i += To.size(); - } else { - ++i; - } -} - -static std::string escapeLabel(const std::string &In) { - std::string Label(In); - replaceIn(Label, '\\', "\\\\"); // Escape caption... - replaceIn(Label, '\n', "\\n"); - replaceIn(Label, ' ', "\\ "); - replaceIn(Label, '{', "\\{"); - replaceIn(Label, '}', "\\}"); - return Label; -} - -static void writeEdge(std::ostream &O, const void *SrcNode, - const char *SrcNodePortName, int SrcNodeIdx, - const DSNodeHandle &VS, - const std::string &EdgeAttr = "") { - O << "\tNode" << SrcNode << SrcNodePortName; - if (SrcNodeIdx != -1) O << SrcNodeIdx; - O << " -> Node" << (void*)VS.getNode(); - if (VS.getOffset()) O << ":g" << VS.getOffset(); - - if (!EdgeAttr.empty()) - O << "[" << EdgeAttr << "]"; - O << ";\n"; -} - -void DSNode::print(std::ostream &O, const DSGraph *G) const { - std::string Caption = escapeLabel(getCaption(this, G)); - - O << "\tNode" << (void*)this << " [ label =\"{" << Caption; - - unsigned Size = getSize(); - if (Size > 64) Size = 64; // Don't print out HUGE graph nodes! - - if (getSize() != 0) { - O << "|{"; - for (unsigned i = 0; i < Size; ++i) { - if (i) O << "|"; - O << "" << (int)MergeMap[i]; - } - if (Size != getSize()) - O << "|truncated..."; - O << "}"; - } - O << "}\"];\n"; - - for (unsigned i = 0; i != Size; ++i) - if (const DSNodeHandle *DSN = getLink(i)) - writeEdge(O, this, ":g", i, *DSN); -} - -void DSGraph::print(std::ostream &O) const { - O << "digraph DataStructures {\n" - << "\tnode [shape=Mrecord];\n" - << "\tedge [arrowtail=\"dot\"];\n" - << "\tsize=\"10,7.5\";\n" - << "\trotate=\"90\";\n"; - - if (Func != 0) - O << "\tlabel=\"Function\\ " << Func->getName() << "\";\n\n"; - - // Output all of the nodes... - for (unsigned i = 0, e = Nodes.size(); i != e; ++i) - Nodes[i]->print(O, this); - - O << "\n"; - - // Output the returned value pointer... - if (RetNode != 0) { - O << "\tNode0x1" << "[ plaintext=circle, label =\"" - << escapeLabel("returning") << "\"];\n"; - writeEdge(O, (void*)1, "", -1, RetNode, "arrowtail=tee,color=gray63"); - } - - // Output all of the call nodes... - for (unsigned i = 0, e = FunctionCalls.size(); i != e; ++i) { - const std::vector &Call = FunctionCalls[i]; - O << "\tNode" << (void*)&Call << " [shape=record,label=\"{call|{"; - for (unsigned j = 0, e = Call.size(); j != e; ++j) { - if (j) O << "|"; - O << ""; - } - O << "}}\"];\n"; - - for (unsigned j = 0, e = Call.size(); j != e; ++j) - if (Call[j].getNode()) - writeEdge(O, &Call, ":g", j, Call[j], "color=gray63"); - } - - - O << "}\n"; -} - template<> -struct DOTGraphTraits : public DefaultDOTGraphTraits { - static std::string getGraphName(DSGraph *G) { +struct DOTGraphTraits : public DefaultDOTGraphTraits { + static std::string getGraphName(const DSGraph *G) { if (G->hasFunction()) return "Function " + G->getFunction().getName(); else return "Non-function graph"; } - static const char *getGraphProperties(DSGraph *G) { + static const char *getGraphProperties(const DSGraph *G) { return "\tedge [arrowtail=\"dot\"];\n" "\tsize=\"10,7.5\";\n" "\trotate=\"90\";\n"; } - static std::string getNodeLabel(DSNode *Node, DSGraph *Graph) { + static std::string getNodeLabel(const DSNode *Node, const DSGraph *Graph) { return getCaption(Node, Graph); } - static std::string getNodeAttributes(DSNode *N) { + static std::string getNodeAttributes(const DSNode *N) { return "shape=Mrecord";//fontname=Courier"; } - static int getEdgeSourceLabel(DSNode *Node, DSNode::iterator I) { + static int getEdgeSourceLabel(const DSNode *Node, DSNode::iterator I) { assert(Node == I.getNode() && "Iterator not for this node!"); return Node->getMergeMapLabel(I.getOffset()); } @@ -198,7 +88,8 @@ /// addCustomGraphFeatures - Use this graph writing hook to emit call nodes /// and the return node. /// - static void addCustomGraphFeatures(DSGraph *G, GraphWriter &GW) { + static void addCustomGraphFeatures(const DSGraph *G, + GraphWriter &GW) { // Output the returned value pointer... if (G->getRetNode().getNode() != 0) { // Output the return node... @@ -227,15 +118,22 @@ } }; +void DSNode::print(std::ostream &O, const DSGraph *G) const { + GraphWriter W(O, G); + W.writeNode(this); +} + +void DSGraph::print(std::ostream &O) const { + WriteGraph(O, this, "DataStructures"); +} -void DSGraph::writeGraphToFile(std::ostream &O, const string &GraphName) { +void DSGraph::writeGraphToFile(std::ostream &O, const string &GraphName) const { string Filename = GraphName + ".dot"; O << "Writing '" << Filename << "'..."; std::ofstream F(Filename.c_str()); if (F.good()) { - WriteGraph(F, this, "DataStructures"); - //print(F); + print(F); O << " [" << getGraphSize() << "+" << getFunctionCalls().size() << "]\n"; } else { O << " error opening file for writing!\n"; From lattner at cs.uiuc.edu Wed Oct 16 20:37:00 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Oct 16 20:37:00 2002 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/Dominators.h Message-ID: <200210170136.UAA27730@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis: Dominators.h updated: 1.28 -> 1.29 --- Log message: Use the forward declaration for GraphTraits instead of #including the header --- Diffs of the changes: Index: llvm/include/llvm/Analysis/Dominators.h diff -u llvm/include/llvm/Analysis/Dominators.h:1.28 llvm/include/llvm/Analysis/Dominators.h:1.29 --- llvm/include/llvm/Analysis/Dominators.h:1.28 Wed Oct 16 18:26:00 2002 +++ llvm/include/llvm/Analysis/Dominators.h Wed Oct 16 20:36:08 2002 @@ -19,9 +19,10 @@ #define LLVM_ANALYSIS_DOMINATORS_H #include "llvm/Pass.h" -#include "Support/GraphTraits.h" #include class Instruction; + +template struct GraphTraits; //===----------------------------------------------------------------------===// // From lattner at cs.uiuc.edu Wed Oct 16 23:23:00 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Oct 16 23:23:00 2002 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/DSGraph.h Message-ID: <200210170422.XAA29802@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis: DSGraph.h updated: 1.6 -> 1.7 --- Log message: * Remove a lot of obsolete #if 0'd code * Add a simple getNodeForValue method to access the ValueMap. --- Diffs of the changes: Index: llvm/include/llvm/Analysis/DSGraph.h diff -u llvm/include/llvm/Analysis/DSGraph.h:1.6 llvm/include/llvm/Analysis/DSGraph.h:1.7 --- llvm/include/llvm/Analysis/DSGraph.h:1.6 Wed Oct 16 20:01:06 2002 +++ llvm/include/llvm/Analysis/DSGraph.h Wed Oct 16 23:22:16 2002 @@ -347,37 +347,6 @@ // std::vector > FunctionCalls; -#if 0 - // OrigFunctionCalls - This vector retains a copy of the original function - // calls of the current graph. This is needed to support top-down inlining - // after bottom-up inlining is complete, since the latter deletes call nodes. - // - std::vector > OrigFunctionCalls; - - // PendingCallers - This vector records all unresolved callers of the - // current function, i.e., ones whose graphs have not been inlined into - // the current graph. As long as there are unresolved callers, the nodes - // for formal arguments in the current graph cannot be eliminated, and - // nodes in the graph reachable from the formal argument nodes or - // global variable nodes must be considered incomplete. - std::set PendingCallers; -#endif - -protected: - -#if 0 - // clone all the call nodes and save the copies in OrigFunctionCalls - void saveOrigFunctionCalls() { - assert(OrigFunctionCalls.size() == 0 && "Do this only once!"); - OrigFunctionCalls = FunctionCalls; - } - - // get the saved copies of the original function call nodes - std::vector > &getOrigFunctionCalls() { - return OrigFunctionCalls; - } -#endif - void operator=(const DSGraph &); // DO NOT IMPLEMENT public: DSGraph() : Func(0) {} // Create a new, empty, DSGraph. @@ -410,6 +379,11 @@ return FunctionCalls; } + /// getNodeForValue - Given a value that is used or defined in the body of the + /// current function, return the DSNode that it points to. + /// + DSNodeHandle &getNodeForValue(Value *V) { return ValueMap[V]; } + const DSNodeHandle &getRetNode() const { return RetNode; } DSNodeHandle &getRetNode() { return RetNode; } @@ -451,20 +425,6 @@ // inlining graphs. // void removeDeadNodes(bool KeepAllGlobals = false, bool KeepCalls = true); - -#if 0 - // AddCaller - add a known caller node into the graph and mark it pending. - // getCallers - get a vector of the functions that call this one - // getCallersPending - get a matching vector of bools indicating if each - // caller's DSGraph has been resolved into this one. - // - void addCaller(Function &caller) { - PendingCallers.insert(&caller); - } - std::set &getPendingCallers() { - return PendingCallers; - } -#endif // cloneInto - Clone the specified DSGraph into the current graph, returning // the Return node of the graph. The translated ValueMap for the old function From lattner at cs.uiuc.edu Wed Oct 16 23:24:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Oct 16 23:24:01 2002 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/DataStructure.h Message-ID: <200210170423.XAA29813@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis: DataStructure.h updated: 1.43 -> 1.44 --- Log message: * Add data structures to BU pass to keep track of call sites for functions * Reenable the TD analysis --- Diffs of the changes: Index: llvm/include/llvm/Analysis/DataStructure.h diff -u llvm/include/llvm/Analysis/DataStructure.h:1.43 llvm/include/llvm/Analysis/DataStructure.h:1.44 --- llvm/include/llvm/Analysis/DataStructure.h:1.43 Wed Oct 2 17:14:17 2002 +++ llvm/include/llvm/Analysis/DataStructure.h Wed Oct 16 23:23:05 2002 @@ -11,11 +11,11 @@ class Type; class DSGraph; +class DSNodeHandle; class LocalDataStructures; // A collection of local graphs for a program class BUDataStructures; // A collection of bu graphs for a program class TDDataStructures; // A collection of td graphs for a program - // FIXME: move this stuff to a private header namespace DataStructureAnalysis { // isPointerType - Return true if this first class type is big enough to hold @@ -63,8 +63,19 @@ // only performs a "Bottom Up" propogation (hence the name). // class BUDataStructures : public Pass { +public: + struct CallSite { + Function *Caller; + std::vector Context; + + CallSite(Function &C, const std::vector &Con) + : Caller(&C), Context(Con) {} + }; + +private: // DSInfo, one graph for each function std::map DSInfo; + std::map > CallSites; public: ~BUDataStructures() { releaseMemory(); } @@ -77,6 +88,12 @@ return *I->second; } + const std::vector *getCallSites(const Function &F) const { + std::map >::const_iterator I + = CallSites.find(&F); + return I != CallSites.end() ? &I->second : 0; + } + // print - Print out the analysis results... void print(std::ostream &O, const Module *M) const; @@ -92,8 +109,6 @@ DSGraph &calculateGraph(Function &F); }; - -#if 0 // TDDataStructures - Analysis that computes new data structure graphs // for each function using the closed graphs for the callers computed // by the bottom-up pass. @@ -126,11 +141,10 @@ } private: DSGraph &calculateGraph(Function &F); - void pushGraphIntoCallee(DSGraph &callerGraph, DSGraph &calleeGraph, - std::map &OldValMap, - std::map &OldNodeMap); + + void ResolveCallSite(DSGraph &Graph, + const BUDataStructures::CallSite &CallSite); }; -#endif #if 0 // GlobalDSGraph - A common graph for all the globals and their outgoing links From lattner at cs.uiuc.edu Wed Oct 16 23:25:00 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Oct 16 23:25:00 2002 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp Message-ID: <200210170424.XAA29827@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: BottomUpClosure.cpp updated: 1.14 -> 1.15 --- Log message: * Add data structures and code to track the call sites for each function --- Diffs of the changes: Index: llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp diff -u llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.14 llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.15 --- llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.14 Thu Oct 3 16:55:28 2002 +++ llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp Wed Oct 16 23:24:08 2002 @@ -10,9 +10,7 @@ #include "llvm/Analysis/DataStructure.h" #include "llvm/Analysis/DSGraph.h" #include "llvm/Module.h" -//#include "llvm/DerivedTypes.h" #include "Support/Statistic.h" -//#include using std::map; static RegisterAnalysis @@ -32,6 +30,9 @@ // our memory... here... // void BUDataStructures::releaseMemory() { + // Delete all call site information + CallSites.clear(); + for (map::iterator I = DSInfo.begin(), E = DSInfo.end(); I != E; ++I) delete I->second; @@ -151,6 +152,10 @@ for (unsigned c = 0; c != Callees.size(); ++c) { // Must be a function type, so this cast MUST succeed. Function &FI = cast(*Callees[c]); + + // Record that this is a call site of FI. + CallSites[&FI].push_back(CallSite(F, Call)); + if (&FI == &F) { // Self recursion... simply link up the formal arguments with the // actual arguments... @@ -165,6 +170,7 @@ // Erase the entry in the callees vector Callees.erase(Callees.begin()+c--); + } else if (!FI.isExternal()) { DEBUG(std::cerr << "\t[BU] In " << F.getName() << " inlining: " << FI.getName() << "\n"); From lattner at cs.uiuc.edu Wed Oct 16 23:25:02 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Oct 16 23:25:02 2002 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/Printer.cpp Message-ID: <200210170424.XAA29838@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: Printer.cpp updated: 1.19 -> 1.20 --- Log message: Reenable printing of TD analysis --- Diffs of the changes: Index: llvm/lib/Analysis/DataStructure/Printer.cpp diff -u llvm/lib/Analysis/DataStructure/Printer.cpp:1.19 llvm/lib/Analysis/DataStructure/Printer.cpp:1.20 --- llvm/lib/Analysis/DataStructure/Printer.cpp:1.19 Wed Oct 16 20:02:46 2002 +++ llvm/lib/Analysis/DataStructure/Printer.cpp Wed Oct 16 23:24:30 2002 @@ -170,14 +170,13 @@ #endif } -#if 0 void TDDataStructures::print(std::ostream &O, const Module *M) const { printCollection(*this, O, M, "td."); - +#if 0 for (Module::const_iterator I = M->begin(), E = M->end(); I != E; ++I) if (!I->isExternal()) { (*getDSGraph(*I).GlobalsGraph)->writeGraphToFile(O, "gg.program"); break; } -} #endif +} From lattner at cs.uiuc.edu Wed Oct 16 23:28:00 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Oct 16 23:28:00 2002 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/TopDownClosure.cpp Message-ID: <200210170427.XAA29849@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: TopDownClosure.cpp updated: 1.5 -> 1.6 --- Log message: * First try at implementing TD pass this does not merge global nodes yet, among other things. * Significant rewrite of TD pass to avoid potentially N^2 algorithms if possible. It is still not complete, but at least it's checked in now. --- Diffs of the changes: Index: llvm/lib/Analysis/DataStructure/TopDownClosure.cpp diff -u llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.5 llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.6 --- llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.5 Tue Oct 1 17:33:50 2002 +++ llvm/lib/Analysis/DataStructure/TopDownClosure.cpp Wed Oct 16 23:26:54 2002 @@ -8,12 +8,13 @@ //===----------------------------------------------------------------------===// #include "llvm/Analysis/DataStructure.h" +#include "llvm/Analysis/DSGraph.h" #include "llvm/Module.h" #include "llvm/DerivedTypes.h" #include "Support/Statistic.h" using std::map; +using std::vector; -#if 0 static RegisterAnalysis Y("tddatastructure", "Top-down Data Structure Analysis Closure"); @@ -41,40 +42,12 @@ return false; } - -// ResolveArguments - Resolve the formal and actual arguments for a function -// call by merging the nodes for the actual arguments at the call site Call[] -// (these were copied over from the caller's graph into the callee's graph -// by cloneInto, and the nodes can be found from OldNodeMap) with the -// corresponding nodes for the formal arguments in the callee. -// -static void ResolveArguments(std::vector &Call, - Function &callee, - std::map &CalleeValueMap, - std::map OldNodeMap, - bool ignoreNodeMap) { - // Resolve all of the function formal arguments... - Function::aiterator AI = callee.abegin(); - for (unsigned i = 2, e = Call.size(); i != e; ++i) { - // Advance the argument iterator to the first pointer argument... - while (!isa(AI->getType())) ++AI; - - // TD ...Merge the formal arg scalar with the actual arg node - DSNode* actualArg = Call[i]; - DSNode *nodeForActual = ignoreNodeMap? actualArg : OldNodeMap[actualArg]; - assert(nodeForActual && "No node found for actual arg in callee graph!"); - - DSNode *nodeForFormal = CalleeValueMap[AI]->getLink(0); - if (nodeForFormal) - nodeForFormal->mergeWith(nodeForActual); - ++AI; - } -} +#if 0 // MergeGlobalNodes - Merge all existing global nodes with globals // inlined from the callee or with globals from the GlobalsGraph. // -static void MergeGlobalNodes(DSGraph& Graph, +static void MergeGlobalNodes(DSGraph &Graph, map &OldValMap) { map &ValMap = Graph.getValueMap(); for (map::iterator I = ValMap.begin(), E = ValMap.end(); @@ -97,63 +70,34 @@ } } -// Helper function to push a caller's graph into the calleeGraph, -// once per call between the caller and the callee. -// Remove each such resolved call from the OrigFunctionCalls vector. -// NOTE: This may produce O(N^2) behavior because it uses linear search -// through the vector OrigFunctionCalls to find all calls to this callee. -// -void TDDataStructures::pushGraphIntoCallee(DSGraph &callerGraph, - DSGraph &calleeGraph, - std::map &OldValMap, - std::map &OldNodeMap) { - - Function& caller = callerGraph.getFunction(); - - // Loop over all function calls in the caller to find those to this callee - std::vector >& FunctionCalls = - callerGraph.getOrigFunctionCalls(); - - for (unsigned i = 0, ei = FunctionCalls.size(); i != ei; ++i) { - - std::vector& Call = FunctionCalls[i]; - assert(Call.size() >= 2 && "No function pointer in Call?"); - DSNodeHandle& callee = Call[1]; - std::vector funcPtrs(callee->getGlobals()); - - // Loop over the function pointers in the call, looking for the callee - for (unsigned f = 0; f != funcPtrs.size(); ++f) { - - // Must be a function type, so this cast MUST succeed. - Function &callee = cast(*funcPtrs[f]); - if (&callee != &calleeGraph.getFunction()) - continue; - - // Found a call to the callee. Inline its graph - // copy caller pointer because inlining may modify the callers vector - - // Merge actual arguments from the caller with formals in the callee. - // Don't use the old->new node map if this is a self-recursive call. - ResolveArguments(Call, callee, calleeGraph.getValueMap(), OldNodeMap, - /*ignoreNodeMap*/ &caller == &callee); +#endif - // If its not a self-recursive call, merge global nodes in the inlined - // graph with the corresponding global nodes in the current graph - if (&caller != &callee) - MergeGlobalNodes(calleeGraph, OldValMap); +/// ResolveCallSite - This method is used to link the actual arguments together +/// with the formal arguments for a function call in the top-down closure. This +/// method assumes that the call site arguments have been mapped into nodes +/// local to the specified graph. +/// +void TDDataStructures::ResolveCallSite(DSGraph &Graph, + const BUDataStructures::CallSite &CallSite) { + // Resolve all of the function formal arguments... + Function &F = Graph.getFunction(); + Function::aiterator AI = F.abegin(); - // Merge returned node in the caller with the "return" node in callee - if (Call[0]) - calleeGraph.getRetNode()->mergeWith(OldNodeMap[Call[0]]); - - // Erase the entry in the globals vector - funcPtrs.erase(funcPtrs.begin()+f--); - - } // for each function pointer in the call node - } // for each original call node + for (unsigned i = 2, e = CallSite.Context.size(); i != e; ++i, ++AI) { + // Advance the argument iterator to the first pointer argument... + while (!DataStructureAnalysis::isPointerType(AI->getType())) ++AI; + + // TD ...Merge the formal arg scalar with the actual arg node + DSNodeHandle &NodeForFormal = Graph.getNodeForValue(AI); + if (NodeForFormal.getNode()) + NodeForFormal.mergeWith(CallSite.Context[i]); + } + + // Merge returned node in the caller with the "return" node in callee + if (CallSite.Context[0].getNode() && Graph.getRetNode().getNode()) + Graph.getRetNode().mergeWith(CallSite.Context[0]); } - DSGraph &TDDataStructures::calculateGraph(Function &F) { // Make sure this graph has not already been calculated, or that we don't get // into an infinite loop with mutually recursive functions. @@ -161,62 +105,84 @@ DSGraph *&Graph = DSInfo[&F]; if (Graph) return *Graph; - // Copy the local version into DSInfo... - DSGraph& BUGraph = getAnalysis().getDSGraph(F); + BUDataStructures &BU = getAnalysis(); + DSGraph &BUGraph = BU.getDSGraph(F); Graph = new DSGraph(BUGraph); - // Find the callers of this function recorded during the BU pass - std::set &PendingCallers = BUGraph.getPendingCallers(); + const vector *CallSitesP = BU.getCallSites(F); + if (CallSitesP == 0) { + DEBUG(std::cerr << " [TD] No callers for: " << F.getName() << "\n"); + return *Graph; // If no call sites, the graph is the same as the BU graph! + } + // Loop over all call sites of this function, merging each one into this + // graph. + // DEBUG(std::cerr << " [TD] Inlining callers for: " << F.getName() << "\n"); - - for (std::set::iterator I=PendingCallers.begin(), - E=PendingCallers.end(); I != E; ++I) { - Function& caller = **I; - assert(! caller.isExternal() && "Externals unexpected in callers list"); - - DEBUG(std::cerr << "\t [TD] Inlining " << caller.getName() - << " into callee: " << F.getName() << "\n"); + const vector &CallSites = *CallSitesP; + for (unsigned c = 0, ce = CallSites.size(); c != ce; ++c) { + const BUDataStructures::CallSite &CallSite = CallSites[c]; // Copy + Function &Caller = *CallSite.Caller; + assert(!Caller.isExternal() && "Externals function cannot 'call'!"); - // These two maps keep track of where scalars in the old graph _used_ - // to point to, and of new nodes matching nodes of the old graph. - // These remain empty if no other graph is inlined (i.e., self-recursive). - std::map OldNodeMap; - std::map OldValMap; + DEBUG(std::cerr << "\t [TD] Inlining caller #" << c << " '" + << Caller.getName() << "' into callee: " << F.getName() << "\n"); - if (&caller == &F) { + if (&Caller == &F) { // Self-recursive call: this can happen after a cycle of calls is inlined. - pushGraphIntoCallee(*Graph, *Graph, OldValMap, OldNodeMap); - } - else { - // Recursively compute the graph for the caller. That should + ResolveCallSite(*Graph, CallSite); + } else { + // Recursively compute the graph for the Caller. That should // be fully resolved except if there is mutual recursion... // - DSGraph &callerGraph = calculateGraph(caller); // Graph to inline + DSGraph &CG = calculateGraph(Caller); // Graph to inline - DEBUG(std::cerr << "\t\t[TD] Got graph for " << caller.getName() + DEBUG(std::cerr << "\t\t[TD] Got graph for " << Caller.getName() << " in: " << F.getName() << "\n"); - // Clone the caller's graph into the current graph, keeping + // These two maps keep track of where scalars in the old graph _used_ + // to point to, and of new nodes matching nodes of the old graph. + std::map OldValMap; + std::map OldNodeMap; + + // Clone the Caller's graph into the current graph, keeping // track of where scalars in the old graph _used_ to point... - // Do this here because it only needs to happens once for each caller! - // Strip scalars but not allocas since they are visible in callee. + // Do this here because it only needs to happens once for each Caller! + // Strip scalars but not allocas since they are alive in callee. // - DSNode *RetVal = Graph->cloneInto(callerGraph, OldValMap, OldNodeMap, - /*StripScalars*/ true, - /*StripAllocas*/ false, - /*CopyCallers*/ true, - /*CopyOrigCalls*/ false); + DSNodeHandle RetVal = Graph->cloneInto(CG, OldValMap, OldNodeMap, + /*StripScalars*/ true, + /*StripAllocas*/ false, + /*CopyCallers*/ true, + /*CopyOrigCalls*/false); + + // Make a temporary copy of the call site, and transform the argument node + // pointers. + BUDataStructures::CallSite TmpCallSite = CallSite; + for (unsigned i = 0, e = CallSite.Context.size(); i != e; ++i) { + const DSNode *OldNode = TmpCallSite.Context[i].getNode(); + TmpCallSite.Context[i].setNode(OldNodeMap[OldNode]); + } - pushGraphIntoCallee(callerGraph, *Graph, OldValMap, OldNodeMap); + ResolveCallSite(*Graph, CallSite); + +#if 0 + // If its not a self-recursive call, merge global nodes in the inlined + // graph with the corresponding global nodes in the current graph + if (&caller != &callee) + MergeGlobalNodes(calleeGraph, OldValMap); +#endif } } + +#if 0 // Recompute the Incomplete markers and eliminate unreachable nodes. Graph->maskIncompleteMarkers(); Graph->markIncompleteNodes(/*markFormals*/ ! F.hasInternalLinkage() /*&& FIXME: NEED TO CHECK IF ALL CALLERS FOUND!*/); Graph->removeDeadNodes(/*KeepAllGlobals*/ false, /*KeepCalls*/ false); +#endif DEBUG(std::cerr << " [TD] Done inlining callers for: " << F.getName() << " [" << Graph->getGraphSize() << "+" << Graph->getFunctionCalls().size() @@ -224,4 +190,3 @@ return *Graph; } -#endif From lattner at cs.uiuc.edu Wed Oct 16 23:58:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Oct 16 23:58:01 2002 Subject: [llvm-commits] CVS: llvm/lib/Transforms/IPO/PoolAllocate.cpp Message-ID: <200210170457.XAA30053@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/IPO: PoolAllocate.cpp updated: 1.42 -> 1.43 --- Log message: Really disable pool allocator --- Diffs of the changes: Index: llvm/lib/Transforms/IPO/PoolAllocate.cpp diff -u llvm/lib/Transforms/IPO/PoolAllocate.cpp:1.42 llvm/lib/Transforms/IPO/PoolAllocate.cpp:1.43 --- llvm/lib/Transforms/IPO/PoolAllocate.cpp:1.42 Thu Oct 10 15:33:46 2002 +++ llvm/lib/Transforms/IPO/PoolAllocate.cpp Wed Oct 16 23:57:09 2002 @@ -6,6 +6,9 @@ // //===----------------------------------------------------------------------===// +#if 1 +#include "llvm/Pass.h" +#else #include "llvm/Transforms/IPO.h" #include "llvm/Transforms/Utils/CloneFunction.h" #include "llvm/Analysis/DataStructure.h" @@ -26,8 +29,6 @@ using std::map; using std::string; using std::set; - -#if 0 // DEBUG_CREATE_POOLS - Enable this to turn on debug output for the pool // creation phase in the top level function of a transformed data structure. From lattner at cs.uiuc.edu Wed Oct 16 23:58:04 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Oct 16 23:58:04 2002 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/TopDownClosure.cpp Message-ID: <200210170457.XAA30066@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: TopDownClosure.cpp updated: 1.6 -> 1.7 --- Log message: Enable incompleteness marking --- Diffs of the changes: Index: llvm/lib/Analysis/DataStructure/TopDownClosure.cpp diff -u llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.6 llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.7 --- llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.6 Wed Oct 16 23:26:54 2002 +++ llvm/lib/Analysis/DataStructure/TopDownClosure.cpp Wed Oct 16 23:57:28 2002 @@ -176,11 +176,11 @@ } -#if 0 // Recompute the Incomplete markers and eliminate unreachable nodes. Graph->maskIncompleteMarkers(); - Graph->markIncompleteNodes(/*markFormals*/ ! F.hasInternalLinkage() + Graph->markIncompleteNodes(/*markFormals*/ !F.hasInternalLinkage() /*&& FIXME: NEED TO CHECK IF ALL CALLERS FOUND!*/); +#if 0 Graph->removeDeadNodes(/*KeepAllGlobals*/ false, /*KeepCalls*/ false); #endif From lattner at cs.uiuc.edu Wed Oct 16 23:58:06 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Oct 16 23:58:06 2002 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/DataStructure.cpp Message-ID: <200210170457.XAA30077@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: DataStructure.cpp updated: 1.22 -> 1.23 --- Log message: Remove obsolete code --- Diffs of the changes: Index: llvm/lib/Analysis/DataStructure/DataStructure.cpp diff -u llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.22 llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.23 --- llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.22 Thu Oct 3 16:55:28 2002 +++ llvm/lib/Analysis/DataStructure/DataStructure.cpp Wed Oct 16 23:57:43 2002 @@ -447,15 +447,6 @@ // Copy the function calls list... CopyFunctionCallsList(G.FunctionCalls, FunctionCalls, OldNodeMap); -#if 0 - if (CopyOrigCalls) - CopyFunctionCallsList(G.OrigFunctionCalls, OrigFunctionCalls, OldNodeMap); - - // Copy the list of unresolved callers - if (CopyCallers) - PendingCallers.insert(G.PendingCallers.begin(), G.PendingCallers.end()); -#endif - // Return the returned node pointer... return DSNodeHandle(OldNodeMap[G.RetNode.getNode()], G.RetNode.getOffset()); } From lattner at cs.uiuc.edu Wed Oct 16 23:59:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Oct 16 23:59:01 2002 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp Message-ID: <200210170458.XAA30089@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: BottomUpClosure.cpp updated: 1.15 -> 1.16 --- Log message: Remove obsolete code --- Diffs of the changes: Index: llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp diff -u llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.15 llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.16 --- llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.15 Wed Oct 16 23:24:08 2002 +++ llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp Wed Oct 16 23:58:10 2002 @@ -113,9 +113,6 @@ #if 0 // Populate the GlobalsGraph with globals from this one. Graph->GlobalsGraph->cloneGlobals(*Graph, /*cloneCalls*/ false); - - // Save a copy of the original call nodes for the top-down pass - Graph->saveOrigFunctionCalls(); #endif // Start resolving calls... @@ -123,16 +120,6 @@ DEBUG(std::cerr << " [BU] Inlining: " << F.getName() << "\n"); -#if 0 - // Add F to the PendingCallers list of each direct callee for use in the - // top-down pass so we don't have to compute this again. We don't want - // to do it for indirect callees inlined later, so remember which calls - // are in the original FCs set. - std::set directCallees; - for (unsigned i = 0; i < FCs.size(); ++i) - directCallees.insert(FCs[i][1]); // ptr to function node -#endif - bool Inlined; do { Inlined = false; @@ -209,12 +196,6 @@ // MergeGlobalNodes(*Graph, OldValMap); -#if 0 - // If this was an original call, add F to the PendingCallers list - if (directCallees.find(Call[1]) != directCallees.end()) - GI.addCaller(F); -#endif - // Erase the entry in the Callees vector Callees.erase(Callees.begin()+c--); @@ -249,13 +230,6 @@ Graph->removeDeadNodes(/*KeepAllGlobals*/ true, /*KeepCalls*/ true); } } while (Inlined && !FCs.empty()); - -#if 0 - // Copy any unresolved call nodes into the Globals graph and - // filter out unresolved call nodes inlined from the callee. - if (!FCs.empty()) - Graph->GlobalsGraph->cloneCalls(*Graph); -#endif Graph->maskIncompleteMarkers(); Graph->markIncompleteNodes(); From lattner at cs.uiuc.edu Thu Oct 17 11:23:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Oct 17 11:23:01 2002 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Instrumentation/TraceValues.cpp Message-ID: <200210171622.LAA12961@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Instrumentation: TraceValues.cpp updated: 1.49 -> 1.50 --- Log message: * Apparently string::find doesn't work right on our sun boxes. Work around this. --- Diffs of the changes: Index: llvm/lib/Transforms/Instrumentation/TraceValues.cpp diff -u llvm/lib/Transforms/Instrumentation/TraceValues.cpp:1.49 llvm/lib/Transforms/Instrumentation/TraceValues.cpp:1.50 --- llvm/lib/Transforms/Instrumentation/TraceValues.cpp:1.49 Sun Oct 13 14:39:15 2002 +++ llvm/lib/Transforms/Instrumentation/TraceValues.cpp Thu Oct 17 11:22:08 2002 @@ -212,10 +212,15 @@ string Message, Function *Printf, Function* HashPtrToSeqNum) { // Escape Message by replacing all % characters with %% chars. - unsigned Offset = 0; - while ((Offset = Message.find('%', Offset)) != string::npos) { - Message.replace(Offset, 1, "%%"); - Offset += 2; // Skip over the new %'s + string Tmp; + std::swap(Tmp, Message); + string::iterator I = std::find(Tmp.begin(), Tmp.end(), '%'); + while (I != Tmp.end()) { + Message.append(Tmp.begin(), I); + Message += "%%"; + ++I; // Make sure to erase the % as well... + Tmp.erase(Tmp.begin(), I); + I = std::find(Tmp.begin(), Tmp.end(), '%'); } Module *Mod = BB->getParent()->getParent(); From lattner at cs.uiuc.edu Thu Oct 17 15:11:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Oct 17 15:11:01 2002 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp DataStructure.cpp TopDownClosure.cpp Message-ID: <200210172010.PAA32367@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: BottomUpClosure.cpp updated: 1.16 -> 1.17 DataStructure.cpp updated: 1.23 -> 1.24 TopDownClosure.cpp updated: 1.7 -> 1.8 --- Log message: * Make the DSGraph cloner automatically merge global nodes * BUClosure doesn't have to worry about global nodes * TDClosure now works with global nodes * Reenable DNE on TD pass, now that globals work right --- Diffs of the changes: Index: llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp diff -u llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.16 llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.17 --- llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.16 Wed Oct 16 23:58:10 2002 +++ llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp Thu Oct 17 15:09:52 2002 @@ -71,35 +71,6 @@ } } -// MergeGlobalNodes - Merge all existing global nodes with globals -// inlined from the callee or with globals from the GlobalsGraph. -// -static void MergeGlobalNodes(DSGraph &Graph, - map &OldValMap) { - map &ValMap = Graph.getValueMap(); - for (map::iterator I = ValMap.begin(), E = ValMap.end(); - I != E; ++I) - if (GlobalValue *GV = dyn_cast(I->first)) { - map::iterator NHI = OldValMap.find(GV); - if (NHI != OldValMap.end()) // was it inlined from the callee? - I->second.mergeWith(NHI->second); -#if 0 - else // get it from the GlobalsGraph - I->second.mergeWith(Graph.cloneGlobalInto(GV)); -#endif - } - - // Add unused inlined global nodes into the value map - for (map::iterator I = OldValMap.begin(), - E = OldValMap.end(); I != E; ++I) - if (isa(I->first)) { - DSNodeHandle &NH = ValMap[I->first]; // If global is not in ValMap... - if (NH.getNode() == 0) - NH = I->second; // Add the one just inlined. - } - -} - DSGraph &BUDataStructures::calculateGraph(Function &F) { // Make sure this graph has not already been calculated, or that we don't get // into an infinite loop with mutually recursive functions. @@ -190,11 +161,6 @@ if (Call[0].getNode()) // Handle the return value if present RetVal.mergeWith(Call[0]); - - // Merge global value nodes in the inlined graph with the global - // value nodes in the current graph if there are duplicates. - // - MergeGlobalNodes(*Graph, OldValMap); // Erase the entry in the Callees vector Callees.erase(Callees.begin()+c--); Index: llvm/lib/Analysis/DataStructure/DataStructure.cpp diff -u llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.23 llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.24 --- llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.23 Wed Oct 16 23:57:43 2002 +++ llvm/lib/Analysis/DataStructure/DataStructure.cpp Thu Oct 17 15:09:52 2002 @@ -439,13 +439,24 @@ for (unsigned i = FN, e = Nodes.size(); i != e; ++i) Nodes[i]->NodeType &= ~StripBits; - // Copy the value map... + // Copy the value map... and merge all of the global nodes... for (std::map::const_iterator I = G.ValueMap.begin(), - E = G.ValueMap.end(); I != E; ++I) - OldValMap[I->first] = DSNodeHandle(OldNodeMap[I->second.getNode()], - I->second.getOffset()); + E = G.ValueMap.end(); I != E; ++I) { + DSNodeHandle &H = OldValMap[I->first]; + H = DSNodeHandle(OldNodeMap[I->second.getNode()], I->second.getOffset()); + + if (isa(I->first)) { // Is this a global? + std::map::iterator GVI = ValueMap.find(I->first); + if (GVI != ValueMap.end()) { // Is the global value in this fun already? + GVI->second.mergeWith(H); + } else { + ValueMap[I->first] = H; // Add global pointer to this graph + } + } + } // Copy the function calls list... CopyFunctionCallsList(G.FunctionCalls, FunctionCalls, OldNodeMap); + // Return the returned node pointer... return DSNodeHandle(OldNodeMap[G.RetNode.getNode()], G.RetNode.getOffset()); Index: llvm/lib/Analysis/DataStructure/TopDownClosure.cpp diff -u llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.7 llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.8 --- llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.7 Wed Oct 16 23:57:28 2002 +++ llvm/lib/Analysis/DataStructure/TopDownClosure.cpp Thu Oct 17 15:09:52 2002 @@ -165,13 +165,6 @@ } ResolveCallSite(*Graph, CallSite); - -#if 0 - // If its not a self-recursive call, merge global nodes in the inlined - // graph with the corresponding global nodes in the current graph - if (&caller != &callee) - MergeGlobalNodes(calleeGraph, OldValMap); -#endif } } @@ -180,9 +173,7 @@ Graph->maskIncompleteMarkers(); Graph->markIncompleteNodes(/*markFormals*/ !F.hasInternalLinkage() /*&& FIXME: NEED TO CHECK IF ALL CALLERS FOUND!*/); -#if 0 Graph->removeDeadNodes(/*KeepAllGlobals*/ false, /*KeepCalls*/ false); -#endif DEBUG(std::cerr << " [TD] Done inlining callers for: " << F.getName() << " [" << Graph->getGraphSize() << "+" << Graph->getFunctionCalls().size() From lattner at cs.uiuc.edu Thu Oct 17 15:54:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Oct 17 15:54:01 2002 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/TopDownClosure.cpp Message-ID: <200210172053.PAA32527@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: TopDownClosure.cpp updated: 1.8 -> 1.9 --- Log message: Remove more obsolete code --- Diffs of the changes: Index: llvm/lib/Analysis/DataStructure/TopDownClosure.cpp diff -u llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.8 llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.9 --- llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.8 Thu Oct 17 15:09:52 2002 +++ llvm/lib/Analysis/DataStructure/TopDownClosure.cpp Thu Oct 17 15:53:12 2002 @@ -42,36 +42,6 @@ return false; } -#if 0 - -// MergeGlobalNodes - Merge all existing global nodes with globals -// inlined from the callee or with globals from the GlobalsGraph. -// -static void MergeGlobalNodes(DSGraph &Graph, - map &OldValMap) { - map &ValMap = Graph.getValueMap(); - for (map::iterator I = ValMap.begin(), E = ValMap.end(); - I != E; ++I) - if (GlobalValue* GV = dyn_cast(I->first)) { - map:: iterator NHI = OldValMap.find(GV); - if (NHI != OldValMap.end()) // was it inlined from the callee? - I->second->mergeWith(NHI->second); - else // get it from the GlobalsGraph - I->second->mergeWith(Graph.cloneGlobalInto(GV)); - } - - // Add unused inlined global nodes into the value map - for (map::iterator I = OldValMap.begin(), - E = OldValMap.end(); I != E; ++I) - if (isa(I->first)) { - DSNodeHandle &NH = ValMap[I->first]; // If global is not in ValMap... - if (NH == 0) - NH = I->second; // Add the one just inlined. - } -} - -#endif - /// ResolveCallSite - This method is used to link the actual arguments together /// with the formal arguments for a function call in the top-down closure. This /// method assumes that the call site arguments have been mapped into nodes @@ -167,7 +137,6 @@ ResolveCallSite(*Graph, CallSite); } } - // Recompute the Incomplete markers and eliminate unreachable nodes. Graph->maskIncompleteMarkers(); From lattner at cs.uiuc.edu Thu Oct 17 16:04:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Oct 17 16:04:01 2002 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/DSGraph.h Message-ID: <200210172103.QAA00451@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis: DSGraph.h updated: 1.7 -> 1.8 --- Log message: Add interface for mod/ref info to be captures by dsgraphs --- Diffs of the changes: Index: llvm/include/llvm/Analysis/DSGraph.h diff -u llvm/include/llvm/Analysis/DSGraph.h:1.7 llvm/include/llvm/Analysis/DSGraph.h:1.8 --- llvm/include/llvm/Analysis/DSGraph.h:1.7 Wed Oct 16 23:22:16 2002 +++ llvm/include/llvm/Analysis/DSGraph.h Thu Oct 17 16:03:49 2002 @@ -136,6 +136,8 @@ NewNode = 1 << 2, // This node was allocated with malloc GlobalNode = 1 << 3, // This node was allocated by a global var decl Incomplete = 1 << 4, // This node may not be complete + Modified = 1 << 5, // This node is modified in this context + Read = 1 << 6, // This node is read in this context }; /// NodeType - A union of the above bits. "Shadow" nodes do not add any flags @@ -164,14 +166,24 @@ //===-------------------------------------------------- // Accessors - // getSize - Return the maximum number of bytes occupied by this object... + /// getSize - Return the maximum number of bytes occupied by this object... + /// unsigned getSize() const { return MergeMap.size(); } // getTypeEntries - Return the possible types and their offsets in this object const std::vector &getTypeEntries() const { return TypeEntries; } - // getReferrers - Return a list of the pointers to this node... + /// getReferrers - Return a list of the pointers to this node... + /// const std::vector &getReferrers() const { return Referrers; } + + /// isModified - Return true if this node may be modified in this context + /// + bool isModified() const { return (NodeType & Modified) != 0; } + + /// isRead - Return true if this node may be read in this context + /// + bool isRead() const { return (NodeType & Read) != 0; } /// hasLink - Return true if this memory object has a link at the specified From lattner at cs.uiuc.edu Thu Oct 17 17:14:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Oct 17 17:14:01 2002 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/Local.cpp Message-ID: <200210172213.RAA00683@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: Local.cpp updated: 1.14 -> 1.15 --- Log message: Calculate mod/ref info --- Diffs of the changes: Index: llvm/lib/Analysis/DataStructure/Local.cpp diff -u llvm/lib/Analysis/DataStructure/Local.cpp:1.14 llvm/lib/Analysis/DataStructure/Local.cpp:1.15 --- llvm/lib/Analysis/DataStructure/Local.cpp:1.14 Wed Oct 2 17:14:38 2002 +++ llvm/lib/Analysis/DataStructure/Local.cpp Thu Oct 17 17:13:19 2002 @@ -328,12 +328,15 @@ void GraphBuilder::visitLoadInst(LoadInst &LI) { DSNodeHandle &Ptr = getValueDest(*LI.getOperand(0)); + Ptr.getNode()->NodeType |= DSNode::Read; + if (isPointerType(LI.getType())) getValueNode(LI).addEdgeTo(getLink(Ptr, 0, LI.getType())); } void GraphBuilder::visitStoreInst(StoreInst &SI) { DSNodeHandle &Dest = getValueDest(*SI.getOperand(1)); + Dest.getNode()->NodeType |= DSNode::Modified; // Avoid adding edges from null, or processing non-"pointer" stores if (isPointerType(SI.getOperand(0)->getType()) && From lattner at cs.uiuc.edu Thu Oct 17 17:14:03 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Oct 17 17:14:03 2002 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/Printer.cpp Message-ID: <200210172213.RAA00702@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: Printer.cpp updated: 1.20 -> 1.21 --- Log message: Print Mod/ref info --- Diffs of the changes: Index: llvm/lib/Analysis/DataStructure/Printer.cpp diff -u llvm/lib/Analysis/DataStructure/Printer.cpp:1.20 llvm/lib/Analysis/DataStructure/Printer.cpp:1.21 --- llvm/lib/Analysis/DataStructure/Printer.cpp:1.20 Wed Oct 16 23:24:30 2002 +++ llvm/lib/Analysis/DataStructure/Printer.cpp Thu Oct 17 17:13:28 2002 @@ -39,6 +39,8 @@ if (N->NodeType & DSNode::NewNode ) OS << "N"; if (N->NodeType & DSNode::GlobalNode) OS << "G"; if (N->NodeType & DSNode::Incomplete) OS << "I"; + if (N->NodeType & DSNode::Modified ) OS << "M"; + if (N->NodeType & DSNode::Read ) OS << "R"; for (unsigned i = 0, e = N->getGlobals().size(); i != e; ++i) { WriteAsOperand(OS, N->getGlobals()[i], false, true, M); From lattner at cs.uiuc.edu Fri Oct 18 09:56:00 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Oct 18 09:56:00 2002 Subject: [llvm-commits] CVS: llvm/include/Support/GraphWriter.h Message-ID: <200210181455.JAA04727@apoc.cs.uiuc.edu> Changes in directory llvm/include/Support: GraphWriter.h updated: 1.9 -> 1.10 --- Log message: Don't emit braces around something without outgoing edges --- Diffs of the changes: Index: llvm/include/Support/GraphWriter.h diff -u llvm/include/Support/GraphWriter.h:1.9 llvm/include/Support/GraphWriter.h:1.10 --- llvm/include/Support/GraphWriter.h:1.9 Wed Oct 16 19:59:59 2002 +++ llvm/include/Support/GraphWriter.h Fri Oct 18 09:55:44 2002 @@ -141,7 +141,9 @@ O << "\tNode" << ID << "[ "; if (!Attr.empty()) O << Attr << ","; - O << " label =\"{" << DOT::EscapeString(Label); + O << " label =\""; + if (NumEdgeSources) O << "{"; + O << DOT::EscapeString(Label); if (NumEdgeSources) { O << "|{"; @@ -149,9 +151,9 @@ if (i) O << "|"; O << ""; } - O << "}"; + O << "}}"; } - O << "}\"];\n"; + O << "\"];\n"; } /// emitEdge - Output an edge from a simple node into the graph... From lattner at cs.uiuc.edu Fri Oct 18 13:23:00 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Oct 18 13:23:00 2002 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/DSGraph.h Message-ID: <200210181822.NAA06143@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis: DSGraph.h updated: 1.8 -> 1.9 --- Log message: Convert typerec to be a structure instead of a pair --- Diffs of the changes: Index: llvm/include/llvm/Analysis/DSGraph.h diff -u llvm/include/llvm/Analysis/DSGraph.h:1.8 llvm/include/llvm/Analysis/DSGraph.h:1.9 --- llvm/include/llvm/Analysis/DSGraph.h:1.8 Thu Oct 17 16:03:49 2002 +++ llvm/include/llvm/Analysis/DSGraph.h Fri Oct 18 13:22:44 2002 @@ -120,7 +120,23 @@ /// different types can be represented by this single DSNode. This vector is /// kept sorted. /// - typedef std::pair TypeRec; + struct TypeRec { + const Type *Ty; + unsigned Offset; + + TypeRec() : Ty(0), Offset(0) {} + TypeRec(const Type *T, unsigned O) : Ty(T), Offset(O) {} + + bool operator<(const TypeRec &TR) const { + // Sort first by offset! + return Offset < TR.Offset || (Offset == TR.Offset && Ty < TR.Ty); + } + bool operator==(const TypeRec &TR) const { + return Ty == TR.Ty && Offset == TR.Offset; + } + bool operator!=(const TypeRec &TR) const { return !operator==(TR); } + }; + std::vector TypeEntries; /// Globals - The list of global values that are merged into this node. From lattner at cs.uiuc.edu Fri Oct 18 13:23:03 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Oct 18 13:23:03 2002 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/DataStructure.cpp Local.cpp Printer.cpp Message-ID: <200210181822.NAA06154@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: DataStructure.cpp updated: 1.24 -> 1.25 Local.cpp updated: 1.15 -> 1.16 Printer.cpp updated: 1.21 -> 1.22 --- Log message: Convert typerec to be a structure instead of a pair --- Diffs of the changes: Index: llvm/lib/Analysis/DataStructure/DataStructure.cpp diff -u llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.24 llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.25 --- llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.24 Thu Oct 17 15:09:52 2002 +++ llvm/lib/Analysis/DataStructure/DataStructure.cpp Fri Oct 18 13:22:46 2002 @@ -61,7 +61,7 @@ } } - TypeEntries.push_back(std::make_pair(T, 0)); + TypeEntries.push_back(TypeRec(T, 0)); } // DSNode copy constructor... do not copy over the referrers list! @@ -323,9 +323,9 @@ // If this merging into node has more than just void nodes in it, merge! assert(!N->TypeEntries.empty() && "TypeEntries is empty for a node?"); - if (N->TypeEntries.size() != 1 || N->TypeEntries[0].first != Type::VoidTy) { + if (N->TypeEntries.size() != 1 || N->TypeEntries[0].Ty != Type::VoidTy) { // If the current node just has a Void entry in it, remove it. - if (TypeEntries.size() == 1 && TypeEntries[0].first == Type::VoidTy) + if (TypeEntries.size() == 1 && TypeEntries[0].Ty == Type::VoidTy) TypeEntries.clear(); // Adjust all of the type entries we are merging in by the offset... and add @@ -334,7 +334,7 @@ if (NOffset != 0) { // This case is common enough to optimize for // Offset all of the TypeEntries in N with their new offset for (unsigned i = 0, e = N->TypeEntries.size(); i != e; ++i) - N->TypeEntries[i].second += NOffset; + N->TypeEntries[i].Offset += NOffset; } MergeSortedVectors(TypeEntries, N->TypeEntries); Index: llvm/lib/Analysis/DataStructure/Local.cpp diff -u llvm/lib/Analysis/DataStructure/Local.cpp:1.15 llvm/lib/Analysis/DataStructure/Local.cpp:1.16 --- llvm/lib/Analysis/DataStructure/Local.cpp:1.15 Thu Oct 17 17:13:19 2002 +++ llvm/lib/Analysis/DataStructure/Local.cpp Fri Oct 18 13:22:46 2002 @@ -413,4 +413,3 @@ DSInfo.insert(std::make_pair(I, new DSGraph(*I))); return false; } - Index: llvm/lib/Analysis/DataStructure/Printer.cpp diff -u llvm/lib/Analysis/DataStructure/Printer.cpp:1.21 llvm/lib/Analysis/DataStructure/Printer.cpp:1.22 --- llvm/lib/Analysis/DataStructure/Printer.cpp:1.21 Thu Oct 17 17:13:28 2002 +++ llvm/lib/Analysis/DataStructure/Printer.cpp Fri Oct 18 13:22:46 2002 @@ -28,9 +28,9 @@ Module *M = G && &G->getFunction() ? G->getFunction().getParent() : 0; for (unsigned i = 0, e = N->getTypeEntries().size(); i != e; ++i) { - WriteTypeSymbolic(OS, N->getTypeEntries()[i].first, M); - if (N->getTypeEntries()[i].second) - OS << "@" << N->getTypeEntries()[i].second; + WriteTypeSymbolic(OS, N->getTypeEntries()[i].Ty, M); + if (N->getTypeEntries()[i].Offset) + OS << "@" << N->getTypeEntries()[i].Offset; OS << "\n"; } From vadve at cs.uiuc.edu Sun Oct 20 13:05:01 2002 From: vadve at cs.uiuc.edu (Vikram Adve) Date: Sun Oct 20 13:05:01 2002 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/DSGraph.h Message-ID: <200210201804.NAA27298@psmith.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis: DSGraph.h updated: 1.9 -> 1.10 --- Log message: Added a first-class representation for each call site that can be used in the DS graphs. --- Diffs of the changes: Index: llvm/include/llvm/Analysis/DSGraph.h diff -u llvm/include/llvm/Analysis/DSGraph.h:1.9 llvm/include/llvm/Analysis/DSGraph.h:1.10 --- llvm/include/llvm/Analysis/DSGraph.h:1.9 Fri Oct 18 13:22:44 2002 +++ llvm/include/llvm/Analysis/DSGraph.h Sun Oct 20 13:04:43 2002 @@ -10,8 +10,10 @@ #include #include +#include class Function; +class CallInst; class Value; class GlobalValue; class Type; @@ -20,6 +22,7 @@ class DSGraph; // A graph for a function class DSNodeIterator; // Data structure graph traversal iterator + //===----------------------------------------------------------------------===// /// DSNodeHandle - Implement a "handle" to a data structure node that takes care /// of all of the add/un'refing of the node to prevent the backpointers in the @@ -351,6 +354,35 @@ //===----------------------------------------------------------------------===// +/// DSCallSite - Representation of a call site via its call instruction, +/// the DSNode handle for the callee function (or function pointer), and +/// the DSNode handles for the function arguments. +/// +class DSCallSite: public std::vector { + Function* caller; + CallInst* callInst; + DSCallSite(); // do not implement + +public: + DSCallSite(Function& _caller, CallInst& _callInst) + : caller(&_caller), callInst(&_callInst) { } + + // Copy constructor with helper for cloning nodes. The helper should be a + // model of unary_function, i.e., it + // should take a pointer to DSNodeHandle and return a fresh DSNodeHandle. + // If no helper is specified, this defaults to a simple copy constructor. + template + DSCallSite::DSCallSite(const DSCallSite& FromCall, + _CopierFunction nodeCopier = *(_CopierFunction*) 0); + + Function& getCaller() const { return *caller; } + CallInst& getCallInst() const { return *callInst; } + DSNodeHandle getReturnValueNode() const { return (*this)[0]; } + DSNodeHandle getCalleeNode() const { return (*this)[1]; } +}; + + +//===----------------------------------------------------------------------===// /// DSGraph - The graph that represents a function. /// class DSGraph { @@ -373,7 +405,7 @@ // call, the second is the function scalar being invoked, and the rest are // pointer arguments to the function. // - std::vector > FunctionCalls; + std::vector FunctionCalls; void operator=(const DSGraph &); // DO NOT IMPLEMENT public: @@ -400,10 +432,10 @@ std::map &getValueMap() { return ValueMap; } const std::map &getValueMap() const { return ValueMap;} - std::vector > &getFunctionCalls() { + std::vector &getFunctionCalls() { return FunctionCalls; } - const std::vector > &getFunctionCalls() const { + const std::vector &getFunctionCalls() const { return FunctionCalls; } From vadve at cs.uiuc.edu Sun Oct 20 13:08:01 2002 From: vadve at cs.uiuc.edu (Vikram Adve) Date: Sun Oct 20 13:08:01 2002 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp DataStructure.cpp Local.cpp Printer.cpp Steensgaard.cpp TopDownClosure.cpp Message-ID: <200210201807.NAA27336@psmith.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: BottomUpClosure.cpp updated: 1.17 -> 1.18 DataStructure.cpp updated: 1.25 -> 1.26 Local.cpp updated: 1.16 -> 1.17 Printer.cpp updated: 1.22 -> 1.23 Steensgaard.cpp updated: 1.2 -> 1.3 TopDownClosure.cpp updated: 1.9 -> 1.10 --- Log message: Added a first-class representation for each call site that can be used in the DS graphs. Essentially, what was vector before is now a DSCallSite with the same vector, plus pointers to the CallInst and the caller Function. The special-purpose class BUDataStructure::CallSite is no longer needed. --- Diffs of the changes: Index: llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp diff -u llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.17 llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.18 --- llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.17 Thu Oct 17 15:09:52 2002 +++ llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp Sun Oct 20 13:07:37 2002 @@ -56,7 +56,7 @@ // ResolveArguments - Resolve the formal and actual arguments for a function // call. // -static void ResolveArguments(std::vector &Call, Function &F, +static void ResolveArguments(DSCallSite &Call, Function &F, map &ValueMap) { // Resolve all of the function arguments... Function::aiterator AI = F.abegin(); @@ -87,7 +87,7 @@ #endif // Start resolving calls... - std::vector > &FCs = Graph->getFunctionCalls(); + std::vector &FCs = Graph->getFunctionCalls(); DEBUG(std::cerr << " [BU] Inlining: " << F.getName() << "\n"); @@ -97,14 +97,14 @@ for (unsigned i = 0; i != FCs.size(); ++i) { // Copy the call, because inlining graphs may invalidate the FCs vector. - std::vector Call = FCs[i]; + DSCallSite Call = FCs[i]; // If the function list is complete... - if ((Call[1].getNode()->NodeType & DSNode::Incomplete) == 0) { + if ((Call.getCalleeNode().getNode()->NodeType & DSNode::Incomplete)==0) { // Start inlining all of the functions we can... some may not be // inlinable if they are external... // - std::vector Callees(Call[1].getNode()->getGlobals()); + std::vector Callees(Call.getCalleeNode().getNode()->getGlobals()); // Loop over the functions, inlining whatever we can... for (unsigned c = 0; c != Callees.size(); ++c) { @@ -112,7 +112,8 @@ Function &FI = cast(*Callees[c]); // Record that this is a call site of FI. - CallSites[&FI].push_back(CallSite(F, Call)); + assert(&Call.getCaller() == &F && "Invalid caller in DSCallSite?"); + CallSites[&FI].push_back(DSCallSite(Call)); if (&FI == &F) { // Self recursion... simply link up the formal arguments with the @@ -120,8 +121,8 @@ DEBUG(std::cerr << "\t[BU] Self Inlining: " << F.getName() << "\n"); - if (Call[0].getNode()) // Handle the return value if present... - Graph->getRetNode().mergeWith(Call[0]); + if (Call.getReturnValueNode().getNode()) // Handle the return value if present... + Graph->getRetNode().mergeWith(Call.getReturnValueNode()); // Resolve the arguments in the call to the actual values... ResolveArguments(Call, F, Graph->getValueMap()); @@ -159,8 +160,8 @@ // Resolve the arguments in the call to the actual values... ResolveArguments(Call, FI, OldValMap); - if (Call[0].getNode()) // Handle the return value if present - RetVal.mergeWith(Call[0]); + if (Call.getReturnValueNode().getNode()) // Handle the return value if present + RetVal.mergeWith(Call.getReturnValueNode()); // Erase the entry in the Callees vector Callees.erase(Callees.begin()+c--); @@ -178,7 +179,7 @@ // Erase the call if it is resolvable... FCs.erase(FCs.begin()+i--); // Don't skip a the next call... Inlined = true; - } else if (Callees.size() != Call[1].getNode()->getGlobals().size()) { + } else if (Callees.size() != Call.getCalleeNode().getNode()->getGlobals().size()) { // Was able to inline SOME, but not all of the functions. Construct a // new global node here. // Index: llvm/lib/Analysis/DataStructure/DataStructure.cpp diff -u llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.25 llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.26 --- llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.25 Fri Oct 18 13:22:46 2002 +++ llvm/lib/Analysis/DataStructure/DataStructure.cpp Sun Oct 20 13:07:37 2002 @@ -351,6 +351,21 @@ } } + +template +DSCallSite::DSCallSite(const DSCallSite& FromCall, + _CopierFunction nodeCopier) + : std::vector(), + caller(&FromCall.getCaller()), + callInst(&FromCall.getCallInst()) { + + reserve(FromCall.size()); + for (unsigned j = 0, ej = FromCall.size(); j != ej; ++j) + push_back((&nodeCopier == (_CopierFunction*) 0)? DSNodeHandle(FromCall[j]) + : nodeCopier(&FromCall[j])); +} + + //===----------------------------------------------------------------------===// // DSGraph Implementation //===----------------------------------------------------------------------===// @@ -378,23 +393,22 @@ // dump - Allow inspection of graph in a debugger. void DSGraph::dump() const { print(std::cerr); } + +DSNodeHandle copyHelper(const DSNodeHandle* fromNode, + std::map *NodeMap) { + return DSNodeHandle((*NodeMap)[fromNode->getNode()], fromNode->getOffset()); +} + // Helper function used to clone a function list. -// -static void CopyFunctionCallsList(const vector >&fromCalls, - vector > &toCalls, +// +static void CopyFunctionCallsList(const vector& fromCalls, + vector &toCalls, std::map &NodeMap) { - unsigned FC = toCalls.size(); // FirstCall toCalls.reserve(FC+fromCalls.size()); - for (unsigned i = 0, ei = fromCalls.size(); i != ei; ++i) { - toCalls.push_back(vector()); - - const vector &CurCall = fromCalls[i]; - toCalls.back().reserve(CurCall.size()); - for (unsigned j = 0, ej = fromCalls[i].size(); j != ej; ++j) - toCalls[FC+i].push_back(DSNodeHandle(NodeMap[CurCall[j].getNode()], - CurCall[j].getOffset())); - } + for (unsigned i = 0, ei = fromCalls.size(); i != ei; ++i) + toCalls.push_back(DSCallSite(fromCalls[i], + std::bind2nd(std::ptr_fun(©Helper), &NodeMap))); } /// remapLinks - Change all of the Links in the current node according to the @@ -404,6 +418,7 @@ Links[i].setNode(OldNodeMap[Links[i].getNode()]); } + // cloneInto - Clone the specified DSGraph into the current graph, returning the // Return node of the graph. The translated ValueMap for the old function is // filled into the OldValMap member. If StripLocals is set to true, Scalar and @@ -532,9 +547,9 @@ // Mark stuff passed into functions calls as being incomplete... for (unsigned i = 0, e = FunctionCalls.size(); i != e; ++i) { - vector &Args = FunctionCalls[i]; + DSCallSite &Args = FunctionCalls[i]; // Then the return value is certainly incomplete! - markIncompleteNode(Args[0].getNode()); + markIncompleteNode(Args.getReturnValueNode().getNode()); // The call does not make the function argument incomplete... @@ -590,7 +605,7 @@ return false; } -static void removeIdenticalCalls(vector > &Calls, +static void removeIdenticalCalls(vector &Calls, const std::string &where) { // Remove trivially identical function calls unsigned NumFns = Calls.size(); @@ -665,7 +680,7 @@ // the simple iterative loop in the first few lines below suffice. // static void markGlobalsIteration(std::set& GlobalNodes, - vector > &Calls, + vector &Calls, std::set &Alive, bool FilterCalls) { @@ -723,7 +738,7 @@ GlobalNodes.insert(G.getNodes()[i]); // Add all call nodes to the same set - vector > &Calls = G.getFunctionCalls(); + vector &Calls = G.getFunctionCalls(); if (FilterCalls) { for (unsigned i = 0, e = Calls.size(); i != e; ++i) for (unsigned j = 0, e = Calls[i].size(); j != e; ++j) @@ -963,15 +978,15 @@ // void GlobalDSGraph::cloneCalls(DSGraph& Graph) { std::map NodeCache; - vector >& FromCalls =Graph.FunctionCalls; + vector& FromCalls =Graph.FunctionCalls; FunctionCalls.reserve(FunctionCalls.size() + FromCalls.size()); for (int i = 0, ei = FromCalls.size(); i < ei; ++i) { - FunctionCalls.push_back(vector()); - FunctionCalls.back().reserve(FromCalls[i].size()); + DSCallSite& callCopy = FunctionCalls.back(); + callCopy.reserve(FromCalls[i].size()); for (unsigned j = 0, ej = FromCalls[i].size(); j != ej; ++j) - FunctionCalls.back().push_back + callCopy.push_back ((FromCalls[i][j] && (FromCalls[i][j]->NodeType & ExternalTypeBits)) ? cloneNodeInto(FromCalls[i][j], NodeCache, true) : 0); Index: llvm/lib/Analysis/DataStructure/Local.cpp diff -u llvm/lib/Analysis/DataStructure/Local.cpp:1.16 llvm/lib/Analysis/DataStructure/Local.cpp:1.17 --- llvm/lib/Analysis/DataStructure/Local.cpp:1.16 Fri Oct 18 13:22:46 2002 +++ llvm/lib/Analysis/DataStructure/Local.cpp Sun Oct 20 13:07:37 2002 @@ -61,12 +61,12 @@ vector &Nodes; DSNodeHandle &RetNode; // Node that gets returned... map &ValueMap; - vector > &FunctionCalls; + vector &FunctionCalls; public: GraphBuilder(DSGraph &g, vector &nodes, DSNodeHandle &retNode, map &vm, - vector > &fc) + vector &fc) : G(g), Nodes(nodes), RetNode(retNode), ValueMap(vm), FunctionCalls(fc) { // Create scalar nodes for all pointer arguments... @@ -356,8 +356,8 @@ void GraphBuilder::visitCallInst(CallInst &CI) { // Add a new function call entry... - FunctionCalls.push_back(vector()); - vector &Args = FunctionCalls.back(); + FunctionCalls.push_back(DSCallSite(G.getFunction(), CI)); + DSCallSite &Args = FunctionCalls.back(); // Set up the return value... if (isPointerType(CI.getType())) Index: llvm/lib/Analysis/DataStructure/Printer.cpp diff -u llvm/lib/Analysis/DataStructure/Printer.cpp:1.22 llvm/lib/Analysis/DataStructure/Printer.cpp:1.23 --- llvm/lib/Analysis/DataStructure/Printer.cpp:1.22 Fri Oct 18 13:22:46 2002 +++ llvm/lib/Analysis/DataStructure/Printer.cpp Sun Oct 20 13:07:37 2002 @@ -105,9 +105,9 @@ } // Output all of the call nodes... - const std::vector > &FCs = G->getFunctionCalls(); + const std::vector &FCs = G->getFunctionCalls(); for (unsigned i = 0, e = FCs.size(); i != e; ++i) { - const std::vector &Call = FCs[i]; + const DSCallSite &Call = FCs[i]; GW.emitSimpleNode(&Call, "shape=record", "call", Call.size()); for (unsigned j = 0, e = Call.size(); j != e; ++j) Index: llvm/lib/Analysis/DataStructure/Steensgaard.cpp diff -u llvm/lib/Analysis/DataStructure/Steensgaard.cpp:1.2 llvm/lib/Analysis/DataStructure/Steensgaard.cpp:1.3 --- llvm/lib/Analysis/DataStructure/Steensgaard.cpp:1.2 Wed Oct 2 17:14:38 2002 +++ llvm/lib/Analysis/DataStructure/Steensgaard.cpp Sun Oct 20 13:07:37 2002 @@ -63,7 +63,7 @@ } private: - void ResolveFunctionCall(Function *F, const std::vector &Call, + void ResolveFunctionCall(Function *F, const DSCallSite &Call, DSNodeHandle &RetVal); }; @@ -81,14 +81,14 @@ /// and the return value for the call site context-insensitively. /// void Steens::ResolveFunctionCall(Function *F, - const std::vector &Call, + const DSCallSite &Call, DSNodeHandle &RetVal) { assert(ResultGraph != 0 && "Result graph not allocated!"); std::map &ValMap = ResultGraph->getValueMap(); - // Handle the return value of the function... which is Call[0] - if (Call[0].getNode() && RetVal.getNode()) - RetVal.mergeWith(Call[0]); + // Handle the return value of the function... + if (Call.getReturnValueNode().getNode() && RetVal.getNode()) + RetVal.mergeWith(Call.getReturnValueNode()); // Loop over all pointer arguments, resolving them to their provided pointers unsigned ArgIdx = 2; // Skip retval and function to call... @@ -154,13 +154,13 @@ // Now that we have all of the graphs inlined, we can go about eliminating // call nodes... // - std::vector > &Calls = + std::vector &Calls = ResultGraph->getFunctionCalls(); for (unsigned i = 0; i != Calls.size(); ) { - std::vector &CurCall = Calls[i]; + DSCallSite &CurCall = Calls[i]; // Loop over the called functions, eliminating as many as possible... - std::vector CallTargets = CurCall[1].getNode()->getGlobals(); + std::vector CallTargets = CurCall.getCalleeNode().getNode()->getGlobals(); for (unsigned c = 0; c != CallTargets.size(); ) { // If we can eliminate this function call, do so! bool Eliminated = false; Index: llvm/lib/Analysis/DataStructure/TopDownClosure.cpp diff -u llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.9 llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.10 --- llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.9 Thu Oct 17 15:53:12 2002 +++ llvm/lib/Analysis/DataStructure/TopDownClosure.cpp Sun Oct 20 13:07:37 2002 @@ -48,24 +48,24 @@ /// local to the specified graph. /// void TDDataStructures::ResolveCallSite(DSGraph &Graph, - const BUDataStructures::CallSite &CallSite) { + const DSCallSite &CallSite) { // Resolve all of the function formal arguments... Function &F = Graph.getFunction(); Function::aiterator AI = F.abegin(); - for (unsigned i = 2, e = CallSite.Context.size(); i != e; ++i, ++AI) { + for (unsigned i = 2, e = CallSite.size(); i != e; ++i, ++AI) { // Advance the argument iterator to the first pointer argument... while (!DataStructureAnalysis::isPointerType(AI->getType())) ++AI; // TD ...Merge the formal arg scalar with the actual arg node DSNodeHandle &NodeForFormal = Graph.getNodeForValue(AI); if (NodeForFormal.getNode()) - NodeForFormal.mergeWith(CallSite.Context[i]); + NodeForFormal.mergeWith(CallSite[i]); } // Merge returned node in the caller with the "return" node in callee - if (CallSite.Context[0].getNode() && Graph.getRetNode().getNode()) - Graph.getRetNode().mergeWith(CallSite.Context[0]); + if (CallSite.getReturnValueNode().getNode() && Graph.getRetNode().getNode()) + Graph.getRetNode().mergeWith(CallSite.getReturnValueNode()); } DSGraph &TDDataStructures::calculateGraph(Function &F) { @@ -79,7 +79,7 @@ DSGraph &BUGraph = BU.getDSGraph(F); Graph = new DSGraph(BUGraph); - const vector *CallSitesP = BU.getCallSites(F); + const vector *CallSitesP = BU.getCallSites(F); if (CallSitesP == 0) { DEBUG(std::cerr << " [TD] No callers for: " << F.getName() << "\n"); return *Graph; // If no call sites, the graph is the same as the BU graph! @@ -89,10 +89,10 @@ // graph. // DEBUG(std::cerr << " [TD] Inlining callers for: " << F.getName() << "\n"); - const vector &CallSites = *CallSitesP; + const vector &CallSites = *CallSitesP; for (unsigned c = 0, ce = CallSites.size(); c != ce; ++c) { - const BUDataStructures::CallSite &CallSite = CallSites[c]; // Copy - Function &Caller = *CallSite.Caller; + const DSCallSite &CallSite = CallSites[c]; // Copy + Function &Caller = CallSite.getCaller(); assert(!Caller.isExternal() && "Externals function cannot 'call'!"); DEBUG(std::cerr << "\t [TD] Inlining caller #" << c << " '" @@ -128,10 +128,10 @@ // Make a temporary copy of the call site, and transform the argument node // pointers. - BUDataStructures::CallSite TmpCallSite = CallSite; - for (unsigned i = 0, e = CallSite.Context.size(); i != e; ++i) { - const DSNode *OldNode = TmpCallSite.Context[i].getNode(); - TmpCallSite.Context[i].setNode(OldNodeMap[OldNode]); + DSCallSite TmpCallSite = CallSite; + for (unsigned i = 0, e = CallSite.size(); i != e; ++i) { + const DSNode *OldNode = TmpCallSite[i].getNode(); + TmpCallSite[i].setNode(OldNodeMap[OldNode]); } ResolveCallSite(*Graph, CallSite); From vadve at cs.uiuc.edu Sun Oct 20 13:10:00 2002 From: vadve at cs.uiuc.edu (Vikram Adve) Date: Sun Oct 20 13:10:00 2002 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/DataStructure.h Message-ID: <200210201809.NAA27352@psmith.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis: DataStructure.h updated: 1.44 -> 1.45 --- Log message: Added a first-class representation for each call site that can be used in the DS graphs in DSGraph.h. With that, the special-purpose class BUDataStructure::CallSite is no longer needed here. --- Diffs of the changes: Index: llvm/include/llvm/Analysis/DataStructure.h diff -u llvm/include/llvm/Analysis/DataStructure.h:1.44 llvm/include/llvm/Analysis/DataStructure.h:1.45 --- llvm/include/llvm/Analysis/DataStructure.h:1.44 Wed Oct 16 23:23:05 2002 +++ llvm/include/llvm/Analysis/DataStructure.h Sun Oct 20 13:08:55 2002 @@ -12,6 +12,7 @@ class Type; class DSGraph; class DSNodeHandle; +class DSCallSite; class LocalDataStructures; // A collection of local graphs for a program class BUDataStructures; // A collection of bu graphs for a program class TDDataStructures; // A collection of td graphs for a program @@ -63,19 +64,10 @@ // only performs a "Bottom Up" propogation (hence the name). // class BUDataStructures : public Pass { -public: - struct CallSite { - Function *Caller; - std::vector Context; - - CallSite(Function &C, const std::vector &Con) - : Caller(&C), Context(Con) {} - }; - private: // DSInfo, one graph for each function std::map DSInfo; - std::map > CallSites; + std::map > CallSites; public: ~BUDataStructures() { releaseMemory(); } @@ -88,8 +80,8 @@ return *I->second; } - const std::vector *getCallSites(const Function &F) const { - std::map >::const_iterator I + const std::vector *getCallSites(const Function &F) const { + std::map >::const_iterator I = CallSites.find(&F); return I != CallSites.end() ? &I->second : 0; } @@ -143,7 +135,7 @@ DSGraph &calculateGraph(Function &F); void ResolveCallSite(DSGraph &Graph, - const BUDataStructures::CallSite &CallSite); + const DSCallSite &CallSite); }; #if 0 From lattner at cs.uiuc.edu Sun Oct 20 15:29:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun Oct 20 15:29:01 2002 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/DSGraph.h Message-ID: <200210202028.PAA20516@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis: DSGraph.h updated: 1.10 -> 1.11 --- Log message: Add isArray flag --- Diffs of the changes: Index: llvm/include/llvm/Analysis/DSGraph.h diff -u llvm/include/llvm/Analysis/DSGraph.h:1.10 llvm/include/llvm/Analysis/DSGraph.h:1.11 --- llvm/include/llvm/Analysis/DSGraph.h:1.10 Sun Oct 20 13:04:43 2002 +++ llvm/include/llvm/Analysis/DSGraph.h Sun Oct 20 15:28:35 2002 @@ -119,13 +119,12 @@ /// std::vector Referrers; - /// TypeEntries - As part of the merging process of this algorithm, nodes of - /// different types can be represented by this single DSNode. This vector is - /// kept sorted. - /// + /// TypeRec - This structure is used to represent a single type that is held + /// in a DSNode. struct TypeRec { - const Type *Ty; - unsigned Offset; + const Type *Ty; // The type itself... + unsigned Offset; // The offset in the node + bool isArray; // Have we accessed an array of elements? TypeRec() : Ty(0), Offset(0) {} TypeRec(const Type *T, unsigned O) : Ty(T), Offset(O) {} @@ -140,6 +139,10 @@ bool operator!=(const TypeRec &TR) const { return !operator==(TR); } }; + /// TypeEntries - As part of the merging process of this algorithm, nodes of + /// different types can be represented by this single DSNode. This vector is + /// kept sorted. + /// std::vector TypeEntries; /// Globals - The list of global values that are merged into this node. From lattner at cs.uiuc.edu Sun Oct 20 15:30:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun Oct 20 15:30:01 2002 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/Printer.cpp Message-ID: <200210202029.PAA20529@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: Printer.cpp updated: 1.23 -> 1.24 --- Log message: Print the array flag --- Diffs of the changes: Index: llvm/lib/Analysis/DataStructure/Printer.cpp diff -u llvm/lib/Analysis/DataStructure/Printer.cpp:1.23 llvm/lib/Analysis/DataStructure/Printer.cpp:1.24 --- llvm/lib/Analysis/DataStructure/Printer.cpp:1.23 Sun Oct 20 13:07:37 2002 +++ llvm/lib/Analysis/DataStructure/Printer.cpp Sun Oct 20 15:29:10 2002 @@ -31,6 +31,8 @@ WriteTypeSymbolic(OS, N->getTypeEntries()[i].Ty, M); if (N->getTypeEntries()[i].Offset) OS << "@" << N->getTypeEntries()[i].Offset; + if (N->getTypeEntries()[i].isArray) + Os << " array"; OS << "\n"; } From lattner at cs.uiuc.edu Sun Oct 20 15:33:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun Oct 20 15:33:01 2002 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp Message-ID: <200210202032.PAA20551@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: BottomUpClosure.cpp updated: 1.18 -> 1.19 --- Log message: Avoid extra callSite copy --- Diffs of the changes: Index: llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp diff -u llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.18 llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.19 --- llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.18 Sun Oct 20 13:07:37 2002 +++ llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp Sun Oct 20 15:32:13 2002 @@ -113,7 +113,7 @@ // Record that this is a call site of FI. assert(&Call.getCaller() == &F && "Invalid caller in DSCallSite?"); - CallSites[&FI].push_back(DSCallSite(Call)); + CallSites[&FI].push_back(Call); if (&FI == &F) { // Self recursion... simply link up the formal arguments with the From lattner at cs.uiuc.edu Sun Oct 20 15:40:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun Oct 20 15:40:01 2002 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/DataStructure.cpp Message-ID: <200210202039.PAA20662@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: DataStructure.cpp updated: 1.26 -> 1.27 --- Log message: This function can be static --- Diffs of the changes: Index: llvm/lib/Analysis/DataStructure/DataStructure.cpp diff -u llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.26 llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.27 --- llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.26 Sun Oct 20 13:07:37 2002 +++ llvm/lib/Analysis/DataStructure/DataStructure.cpp Sun Oct 20 15:39:31 2002 @@ -394,8 +394,8 @@ void DSGraph::dump() const { print(std::cerr); } -DSNodeHandle copyHelper(const DSNodeHandle* fromNode, - std::map *NodeMap) { +static DSNodeHandle copyHelper(const DSNodeHandle* fromNode, + std::map *NodeMap) { return DSNodeHandle((*NodeMap)[fromNode->getNode()], fromNode->getOffset()); } From lattner at cs.uiuc.edu Sun Oct 20 15:40:04 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun Oct 20 15:40:04 2002 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/Printer.cpp Message-ID: <200210202039.PAA20667@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: Printer.cpp updated: 1.24 -> 1.25 --- Log message: Fix previous checkin :( --- Diffs of the changes: Index: llvm/lib/Analysis/DataStructure/Printer.cpp diff -u llvm/lib/Analysis/DataStructure/Printer.cpp:1.24 llvm/lib/Analysis/DataStructure/Printer.cpp:1.25 --- llvm/lib/Analysis/DataStructure/Printer.cpp:1.24 Sun Oct 20 15:29:10 2002 +++ llvm/lib/Analysis/DataStructure/Printer.cpp Sun Oct 20 15:39:17 2002 @@ -32,7 +32,7 @@ if (N->getTypeEntries()[i].Offset) OS << "@" << N->getTypeEntries()[i].Offset; if (N->getTypeEntries()[i].isArray) - Os << " array"; + OS << " array"; OS << "\n"; } From vadve at cs.uiuc.edu Sun Oct 20 16:40:00 2002 From: vadve at cs.uiuc.edu (Vikram Adve) Date: Sun Oct 20 16:40:00 2002 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/DSGraph.h Message-ID: <200210202139.QAA28636@psmith.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis: DSGraph.h updated: 1.11 -> 1.12 --- Log message: Remove spurious caller pointer in DSCallSite. Also add functions to access pointer argument nodes cleanly. --- Diffs of the changes: Index: llvm/include/llvm/Analysis/DSGraph.h diff -u llvm/include/llvm/Analysis/DSGraph.h:1.11 llvm/include/llvm/Analysis/DSGraph.h:1.12 --- llvm/include/llvm/Analysis/DSGraph.h:1.11 Sun Oct 20 15:28:35 2002 +++ llvm/include/llvm/Analysis/DSGraph.h Sun Oct 20 16:39:47 2002 @@ -362,26 +362,27 @@ /// the DSNode handles for the function arguments. /// class DSCallSite: public std::vector { - Function* caller; CallInst* callInst; DSCallSite(); // do not implement public: - DSCallSite(Function& _caller, CallInst& _callInst) - : caller(&_caller), callInst(&_callInst) { } + DSCallSite(CallInst& _callInst) : callInst(&_callInst) { } // Copy constructor with helper for cloning nodes. The helper should be a // model of unary_function, i.e., it // should take a pointer to DSNodeHandle and return a fresh DSNodeHandle. // If no helper is specified, this defaults to a simple copy constructor. template - DSCallSite::DSCallSite(const DSCallSite& FromCall, - _CopierFunction nodeCopier = *(_CopierFunction*) 0); + DSCallSite(const DSCallSite& FromCall, + _CopierFunction nodeCopier = *(_CopierFunction*) 0); - Function& getCaller() const { return *caller; } - CallInst& getCallInst() const { return *callInst; } - DSNodeHandle getReturnValueNode() const { return (*this)[0]; } - DSNodeHandle getCalleeNode() const { return (*this)[1]; } + Function& getCaller() const; + CallInst& getCallInst() const { return *callInst; } + DSNodeHandle getReturnValueNode() const { return (*this)[0]; } + DSNodeHandle getCalleeNode() const { return (*this)[1]; } + unsigned getNumPtrArgs() const { return (size() - 2); } + DSNodeHandle getPtrArgNode(unsigned i) const { assert(i < getNumPtrArgs()); + return (*this)[i+2]; } }; From vadve at cs.uiuc.edu Sun Oct 20 16:42:00 2002 From: vadve at cs.uiuc.edu (Vikram Adve) Date: Sun Oct 20 16:42:00 2002 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp DataStructure.cpp Local.cpp Steensgaard.cpp TopDownClosure.cpp Message-ID: <200210202141.QAA28664@psmith.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: BottomUpClosure.cpp updated: 1.19 -> 1.20 DataStructure.cpp updated: 1.27 -> 1.28 Local.cpp updated: 1.17 -> 1.18 Steensgaard.cpp updated: 1.3 -> 1.4 TopDownClosure.cpp updated: 1.10 -> 1.11 --- Log message: Remove spurious caller pointer in DSCallSite. Also add functions to access pointer argument nodes cleanly. --- Diffs of the changes: Index: llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp diff -u llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.19 llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.20 --- llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.19 Sun Oct 20 15:32:13 2002 +++ llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp Sun Oct 20 16:41:02 2002 @@ -60,13 +60,13 @@ map &ValueMap) { // Resolve all of the function arguments... Function::aiterator AI = F.abegin(); - for (unsigned i = 2, e = Call.size(); i != e; ++i) { + for (unsigned i = 0, e = Call.getNumPtrArgs(); i != e; ++i) { // Advance the argument iterator to the first pointer argument... while (!isPointerType(AI->getType())) ++AI; // Add the link from the argument scalar to the provided value DSNodeHandle &NN = ValueMap[AI]; - NN.addEdgeTo(Call[i]); + NN.addEdgeTo(Call.getPtrArgNode(i)); ++AI; } } @@ -111,10 +111,6 @@ // Must be a function type, so this cast MUST succeed. Function &FI = cast(*Callees[c]); - // Record that this is a call site of FI. - assert(&Call.getCaller() == &F && "Invalid caller in DSCallSite?"); - CallSites[&FI].push_back(Call); - if (&FI == &F) { // Self recursion... simply link up the formal arguments with the // actual arguments... @@ -142,6 +138,11 @@ DEBUG(std::cerr << "\t\t[BU] Got graph for " << FI.getName() << " in: " << F.getName() << "\n"); + + // Record that the original DSCallSite was a call site of FI. + // This may or may not have been known when the DSCallSite was + // originally created. + CallSites[&FI].push_back(Call); // Clone the callee's graph into the current graph, keeping // track of where scalars in the old graph _used_ to point, Index: llvm/lib/Analysis/DataStructure/DataStructure.cpp diff -u llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.27 llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.28 --- llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.27 Sun Oct 20 15:39:31 2002 +++ llvm/lib/Analysis/DataStructure/DataStructure.cpp Sun Oct 20 16:41:02 2002 @@ -6,6 +6,8 @@ #include "llvm/Analysis/DSGraph.h" #include "llvm/Function.h" +#include "llvm/BasicBlock.h" +#include "llvm/iOther.h" #include "llvm/DerivedTypes.h" #include "llvm/Target/TargetData.h" #include "Support/STLExtras.h" @@ -351,12 +353,15 @@ } } +// Define here to avoid including iOther.h and BasicBlock.h in DSGraph.h +Function& DSCallSite::getCaller() const { + return * callInst->getParent()->getParent(); +} template DSCallSite::DSCallSite(const DSCallSite& FromCall, _CopierFunction nodeCopier) : std::vector(), - caller(&FromCall.getCaller()), callInst(&FromCall.getCallInst()) { reserve(FromCall.size()); @@ -547,15 +552,15 @@ // Mark stuff passed into functions calls as being incomplete... for (unsigned i = 0, e = FunctionCalls.size(); i != e; ++i) { - DSCallSite &Args = FunctionCalls[i]; + DSCallSite &Call = FunctionCalls[i]; // Then the return value is certainly incomplete! - markIncompleteNode(Args.getReturnValueNode().getNode()); + markIncompleteNode(Call.getReturnValueNode().getNode()); // The call does not make the function argument incomplete... // All arguments to the function call are incomplete though! - for (unsigned i = 2, e = Args.size(); i != e; ++i) - markIncompleteNode(Args[i].getNode()); + for (unsigned i = 0, e = Call.getNumPtrArgs(); i != e; ++i) + markIncompleteNode(Call.getPtrArgNode(i).getNode()); } // Mark all of the nodes pointed to by global or cast nodes as incomplete... Index: llvm/lib/Analysis/DataStructure/Local.cpp diff -u llvm/lib/Analysis/DataStructure/Local.cpp:1.17 llvm/lib/Analysis/DataStructure/Local.cpp:1.18 --- llvm/lib/Analysis/DataStructure/Local.cpp:1.17 Sun Oct 20 13:07:37 2002 +++ llvm/lib/Analysis/DataStructure/Local.cpp Sun Oct 20 16:41:02 2002 @@ -356,7 +356,7 @@ void GraphBuilder::visitCallInst(CallInst &CI) { // Add a new function call entry... - FunctionCalls.push_back(DSCallSite(G.getFunction(), CI)); + FunctionCalls.push_back(DSCallSite(CI)); DSCallSite &Args = FunctionCalls.back(); // Set up the return value... Index: llvm/lib/Analysis/DataStructure/Steensgaard.cpp diff -u llvm/lib/Analysis/DataStructure/Steensgaard.cpp:1.3 llvm/lib/Analysis/DataStructure/Steensgaard.cpp:1.4 --- llvm/lib/Analysis/DataStructure/Steensgaard.cpp:1.3 Sun Oct 20 13:07:37 2002 +++ llvm/lib/Analysis/DataStructure/Steensgaard.cpp Sun Oct 20 16:41:02 2002 @@ -91,14 +91,14 @@ RetVal.mergeWith(Call.getReturnValueNode()); // Loop over all pointer arguments, resolving them to their provided pointers - unsigned ArgIdx = 2; // Skip retval and function to call... + unsigned PtrArgIdx = 0; for (Function::aiterator AI = F->abegin(), AE = F->aend(); AI != AE; ++AI) { std::map::iterator I = ValMap.find(AI); if (I != ValMap.end()) // If its a pointer argument... - I->second.addEdgeTo(Call[ArgIdx++]); + I->second.addEdgeTo(Call.getPtrArgNode(PtrArgIdx++)); } - assert(ArgIdx == Call.size() && "Argument resolution mismatch!"); + assert(PtrArgIdx == Call.getNumPtrArgs() && "Argument resolution mismatch!"); } Index: llvm/lib/Analysis/DataStructure/TopDownClosure.cpp diff -u llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.10 llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.11 --- llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.10 Sun Oct 20 13:07:37 2002 +++ llvm/lib/Analysis/DataStructure/TopDownClosure.cpp Sun Oct 20 16:41:02 2002 @@ -53,14 +53,14 @@ Function &F = Graph.getFunction(); Function::aiterator AI = F.abegin(); - for (unsigned i = 2, e = CallSite.size(); i != e; ++i, ++AI) { + for (unsigned i = 0, e = CallSite.getNumPtrArgs(); i != e; ++i, ++AI) { // Advance the argument iterator to the first pointer argument... while (!DataStructureAnalysis::isPointerType(AI->getType())) ++AI; // TD ...Merge the formal arg scalar with the actual arg node DSNodeHandle &NodeForFormal = Graph.getNodeForValue(AI); if (NodeForFormal.getNode()) - NodeForFormal.mergeWith(CallSite[i]); + NodeForFormal.mergeWith(CallSite.getPtrArgNode(i)); } // Merge returned node in the caller with the "return" node in callee @@ -68,6 +68,13 @@ Graph.getRetNode().mergeWith(CallSite.getReturnValueNode()); } + +static DSNodeHandle copyHelper(const DSNodeHandle* fromNode, + std::map *NodeMap) { + return DSNodeHandle((*NodeMap)[fromNode->getNode()], fromNode->getOffset()); +} + + DSGraph &TDDataStructures::calculateGraph(Function &F) { // Make sure this graph has not already been calculated, or that we don't get // into an infinite loop with mutually recursive functions. @@ -128,12 +135,8 @@ // Make a temporary copy of the call site, and transform the argument node // pointers. - DSCallSite TmpCallSite = CallSite; - for (unsigned i = 0, e = CallSite.size(); i != e; ++i) { - const DSNode *OldNode = TmpCallSite[i].getNode(); - TmpCallSite[i].setNode(OldNodeMap[OldNode]); - } - + DSCallSite TmpCallSite(CallSite, std::bind2nd(std::ptr_fun(©Helper), + &OldNodeMap)); ResolveCallSite(*Graph, CallSite); } } From vadve at cs.uiuc.edu Sun Oct 20 16:46:01 2002 From: vadve at cs.uiuc.edu (Vikram Adve) Date: Sun Oct 20 16:46:01 2002 Subject: [llvm-commits] CVS: llvm/Makefile.common Message-ID: <200210202145.QAA28684@psmith.cs.uiuc.edu> Changes in directory llvm: Makefile.common updated: 1.62 -> 1.63 --- Log message: Warn when we are linking an executable without symbols. --- Diffs of the changes: Index: llvm/Makefile.common diff -u llvm/Makefile.common:1.62 llvm/Makefile.common:1.63 --- llvm/Makefile.common:1.62 Mon Oct 14 20:59:45 2002 +++ llvm/Makefile.common Sun Oct 20 16:45:49 2002 @@ -142,8 +142,10 @@ # By default, strip symbol information from executable ifdef KEEP_SYMBOLS STRIP = +WARN_MSG = else STRIP = -s +WARN_MSG = "(without symbols) " endif # Allow gnu extensions... @@ -397,7 +399,7 @@ $(VERB) rm -f $(TOOLEXENAMES) $(TOOLEXENAME_G): $(ObjectsG) $(USED_LIB_PATHS_G) $(BUILD_ROOT_TOP)/tools/Debug/.dir - @echo ======= Linking $(TOOLNAME) debug executable ======= + @echo ======= Linking $(TOOLNAME) debug executable $(WARN_MSG) ======= $(VERB) $(LinkG) -o $@ $(ObjectsG) $(USED_LIBS_OPTIONS_G) $(TOOLLINKOPTS) $(TOOLEXENAME_O): $(ObjectsO) $(USED_LIB_PATHS_O) $(BUILD_ROOT_TOP)/tools/Release/.dir From lattner at cs.uiuc.edu Sun Oct 20 17:12:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun Oct 20 17:12:01 2002 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp Message-ID: <200210202211.RAA21898@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: BottomUpClosure.cpp updated: 1.20 -> 1.21 --- Log message: Split some long lines --- Diffs of the changes: Index: llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp diff -u llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.20 llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.21 --- llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.20 Sun Oct 20 16:41:02 2002 +++ llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp Sun Oct 20 17:11:17 2002 @@ -104,7 +104,8 @@ // Start inlining all of the functions we can... some may not be // inlinable if they are external... // - std::vector Callees(Call.getCalleeNode().getNode()->getGlobals()); + std::vector Callees = + Call.getCalleeNode().getNode()->getGlobals(); // Loop over the functions, inlining whatever we can... for (unsigned c = 0; c != Callees.size(); ++c) { @@ -114,10 +115,10 @@ if (&FI == &F) { // Self recursion... simply link up the formal arguments with the // actual arguments... - DEBUG(std::cerr << "\t[BU] Self Inlining: " << F.getName() << "\n"); - if (Call.getReturnValueNode().getNode()) // Handle the return value if present... + // Handle the return value if present... + if (Call.getReturnValueNode().getNode()) Graph->getRetNode().mergeWith(Call.getReturnValueNode()); // Resolve the arguments in the call to the actual values... From lattner at cs.uiuc.edu Sun Oct 20 17:13:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun Oct 20 17:13:01 2002 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/Local.cpp Message-ID: <200210202212.RAA21915@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: Local.cpp updated: 1.18 -> 1.19 --- Log message: Avoid extra copy --- Diffs of the changes: Index: llvm/lib/Analysis/DataStructure/Local.cpp diff -u llvm/lib/Analysis/DataStructure/Local.cpp:1.18 llvm/lib/Analysis/DataStructure/Local.cpp:1.19 --- llvm/lib/Analysis/DataStructure/Local.cpp:1.18 Sun Oct 20 16:41:02 2002 +++ llvm/lib/Analysis/DataStructure/Local.cpp Sun Oct 20 17:12:06 2002 @@ -216,7 +216,6 @@ } - /// getLink - This method is used to return the specified link in the /// specified node if one exists. If a link does not already exist (it's /// null), then we create a new node, link it, then return it. We must @@ -356,7 +355,7 @@ void GraphBuilder::visitCallInst(CallInst &CI) { // Add a new function call entry... - FunctionCalls.push_back(DSCallSite(CI)); + FunctionCalls.push_back(CI); DSCallSite &Args = FunctionCalls.back(); // Set up the return value... From lattner at cs.uiuc.edu Sun Oct 20 17:13:04 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun Oct 20 17:13:04 2002 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/DataStructure.cpp Message-ID: <200210202212.RAA21920@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: DataStructure.cpp updated: 1.28 -> 1.29 --- Log message: Simplify code a bit, add comment flyer --- Diffs of the changes: Index: llvm/lib/Analysis/DataStructure/DataStructure.cpp diff -u llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.28 llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.29 --- llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.28 Sun Oct 20 16:41:02 2002 +++ llvm/lib/Analysis/DataStructure/DataStructure.cpp Sun Oct 20 17:11:44 2002 @@ -6,7 +6,6 @@ #include "llvm/Analysis/DSGraph.h" #include "llvm/Function.h" -#include "llvm/BasicBlock.h" #include "llvm/iOther.h" #include "llvm/DerivedTypes.h" #include "llvm/Target/TargetData.h" @@ -353,21 +352,23 @@ } } +//===----------------------------------------------------------------------===// +// DSCallSite Implementation +//===----------------------------------------------------------------------===// + // Define here to avoid including iOther.h and BasicBlock.h in DSGraph.h -Function& DSCallSite::getCaller() const { - return * callInst->getParent()->getParent(); +Function &DSCallSite::getCaller() const { + return *callInst->getParent()->getParent(); } -template -DSCallSite::DSCallSite(const DSCallSite& FromCall, - _CopierFunction nodeCopier) - : std::vector(), - callInst(&FromCall.getCallInst()) { +template +DSCallSite::DSCallSite(const DSCallSite &FromCall, CopyFunctor nodeCopier) + : callInst(&FromCall.getCallInst()) { reserve(FromCall.size()); for (unsigned j = 0, ej = FromCall.size(); j != ej; ++j) - push_back((&nodeCopier == (_CopierFunction*) 0)? DSNodeHandle(FromCall[j]) - : nodeCopier(&FromCall[j])); + push_back(&nodeCopier == 0 ? DSNodeHandle(FromCall[j]) + : nodeCopier(&FromCall[j])); } From lattner at cs.uiuc.edu Sun Oct 20 21:09:02 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun Oct 20 21:09:02 2002 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/DSGraph.h Message-ID: <200210210208.VAA23965@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis: DSGraph.h updated: 1.12 -> 1.13 --- Log message: - Make DSCallSite not inherit from std::vector. Renamed methods slightly. Make copy ctor have two versions to avoid dealing with conditional template argument. DSCallSite ctor now takes all arguments instead of taking one and being populated later. --- Diffs of the changes: Index: llvm/include/llvm/Analysis/DSGraph.h diff -u llvm/include/llvm/Analysis/DSGraph.h:1.12 llvm/include/llvm/Analysis/DSGraph.h:1.13 --- llvm/include/llvm/Analysis/DSGraph.h:1.12 Sun Oct 20 16:39:47 2002 +++ llvm/include/llvm/Analysis/DSGraph.h Sun Oct 20 21:08:00 2002 @@ -47,6 +47,7 @@ bool operator<(const DSNodeHandle &H) const { // Allow sorting return N < H.N || (N == H.N && Offset < H.Offset); } + bool operator>(const DSNodeHandle &H) const { return H < *this; } bool operator==(const DSNodeHandle &H) const { // Allow comparison return N == H.N && Offset == H.Offset; } @@ -361,28 +362,66 @@ /// the DSNode handle for the callee function (or function pointer), and /// the DSNode handles for the function arguments. /// -class DSCallSite: public std::vector { - CallInst* callInst; - DSCallSite(); // do not implement +class DSCallSite { + CallInst *Inst; // Actual call site + DSNodeHandle RetVal; // Returned value + DSNodeHandle Callee; // The function node called + std::vector CallArgs; // The pointer arguments + DSCallSite(); // DO NOT IMPLEMENT public: - DSCallSite(CallInst& _callInst) : callInst(&_callInst) { } + /// Note - This ctor destroys the argument vector passed in. On exit, the + /// argument vector is empty. + /// + DSCallSite(CallInst &inst, const DSNodeHandle &rv, const DSNodeHandle &callee, + std::vector &Args) + : Inst(&inst), RetVal(rv), Callee(callee) { + Args.swap(CallArgs); + } + + /// Copy constructor with helper for cloning nodes. The helper should be a + /// model of unary_function, i.e., it + /// should take a pointer to DSNodeHandle and return a fresh DSNodeHandle. + /// If no helper is specified, this defaults to a simple copy constructor. + /// + template + DSCallSite(const DSCallSite &FromCall, CopyFunctor nodeCopier); + DSCallSite(const DSCallSite &DSCS) + : Inst(DSCS.Inst), RetVal(DSCS.RetVal), + Callee(DSCS.Callee), CallArgs(DSCS.CallArgs) {} + + // Accessor functions... + Function &getCaller() const; + CallInst &getCallInst() const { return *Inst; } + DSNodeHandle &getRetVal() { return RetVal; } + DSNodeHandle &getCallee() { return Callee; } + const DSNodeHandle &getRetVal() const { return RetVal; } + const DSNodeHandle &getCallee() const { return Callee; } + unsigned getNumPtrArgs() const { return CallArgs.size(); } + + DSNodeHandle &getPtrArg(unsigned i) { + assert(i < CallArgs.size() && "Argument to getPtrArgNode is out of range!"); + return CallArgs[i]; + } + const DSNodeHandle &getPtrArg(unsigned i) const { + assert(i < CallArgs.size() && "Argument to getPtrArgNode is out of range!"); + return CallArgs[i]; + } + + bool operator<(const DSCallSite &CS) const { + if (Inst < CS.Inst) return true; + if (Inst > CS.Inst) return false; + if (RetVal < CS.RetVal) return true; + if (RetVal > CS.RetVal) return false; + if (Callee < CS.Callee) return true; + if (Callee > CS.Callee) return false; + return CallArgs < CS.CallArgs; + } - // Copy constructor with helper for cloning nodes. The helper should be a - // model of unary_function, i.e., it - // should take a pointer to DSNodeHandle and return a fresh DSNodeHandle. - // If no helper is specified, this defaults to a simple copy constructor. - template - DSCallSite(const DSCallSite& FromCall, - _CopierFunction nodeCopier = *(_CopierFunction*) 0); - - Function& getCaller() const; - CallInst& getCallInst() const { return *callInst; } - DSNodeHandle getReturnValueNode() const { return (*this)[0]; } - DSNodeHandle getCalleeNode() const { return (*this)[1]; } - unsigned getNumPtrArgs() const { return (size() - 2); } - DSNodeHandle getPtrArgNode(unsigned i) const { assert(i < getNumPtrArgs()); - return (*this)[i+2]; } + bool operator==(const DSCallSite &CS) const { + return Inst == CS.Inst && RetVal == CS.RetVal && Callee == CS.Callee && + CallArgs == CS.CallArgs; + } }; From lattner at cs.uiuc.edu Sun Oct 20 21:09:06 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun Oct 20 21:09:06 2002 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp DataStructure.cpp Local.cpp Printer.cpp Steensgaard.cpp TopDownClosure.cpp Message-ID: <200210210208.VAA23982@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: BottomUpClosure.cpp updated: 1.21 -> 1.22 DataStructure.cpp updated: 1.29 -> 1.30 Local.cpp updated: 1.19 -> 1.20 Printer.cpp updated: 1.25 -> 1.26 Steensgaard.cpp updated: 1.4 -> 1.5 TopDownClosure.cpp updated: 1.11 -> 1.12 --- Log message: - Make DSCallSite not inherit from std::vector. Renamed methods slightly. Make copy ctor have two versions to avoid dealing with conditional template argument. DSCallSite ctor now takes all arguments instead of taking one and being populated later. --- Diffs of the changes: Index: llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp diff -u llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.21 llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.22 --- llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.21 Sun Oct 20 17:11:17 2002 +++ llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp Sun Oct 20 21:08:03 2002 @@ -66,7 +66,7 @@ // Add the link from the argument scalar to the provided value DSNodeHandle &NN = ValueMap[AI]; - NN.addEdgeTo(Call.getPtrArgNode(i)); + NN.addEdgeTo(Call.getPtrArg(i)); ++AI; } } @@ -100,12 +100,12 @@ DSCallSite Call = FCs[i]; // If the function list is complete... - if ((Call.getCalleeNode().getNode()->NodeType & DSNode::Incomplete)==0) { + if ((Call.getCallee().getNode()->NodeType & DSNode::Incomplete)==0) { // Start inlining all of the functions we can... some may not be // inlinable if they are external... // std::vector Callees = - Call.getCalleeNode().getNode()->getGlobals(); + Call.getCallee().getNode()->getGlobals(); // Loop over the functions, inlining whatever we can... for (unsigned c = 0; c != Callees.size(); ++c) { @@ -118,8 +118,8 @@ DEBUG(std::cerr << "\t[BU] Self Inlining: " << F.getName() << "\n"); // Handle the return value if present... - if (Call.getReturnValueNode().getNode()) - Graph->getRetNode().mergeWith(Call.getReturnValueNode()); + if (Call.getRetVal().getNode()) + Graph->getRetNode().mergeWith(Call.getRetVal()); // Resolve the arguments in the call to the actual values... ResolveArguments(Call, F, Graph->getValueMap()); @@ -162,8 +162,8 @@ // Resolve the arguments in the call to the actual values... ResolveArguments(Call, FI, OldValMap); - if (Call.getReturnValueNode().getNode()) // Handle the return value if present - RetVal.mergeWith(Call.getReturnValueNode()); + if (Call.getRetVal().getNode())// Handle the return value if present + RetVal.mergeWith(Call.getRetVal()); // Erase the entry in the Callees vector Callees.erase(Callees.begin()+c--); @@ -181,7 +181,8 @@ // Erase the call if it is resolvable... FCs.erase(FCs.begin()+i--); // Don't skip a the next call... Inlined = true; - } else if (Callees.size() != Call.getCalleeNode().getNode()->getGlobals().size()) { + } else if (Callees.size() != + Call.getCallee().getNode()->getGlobals().size()) { // Was able to inline SOME, but not all of the functions. Construct a // new global node here. // Index: llvm/lib/Analysis/DataStructure/DataStructure.cpp diff -u llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.29 llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.30 --- llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.29 Sun Oct 20 17:11:44 2002 +++ llvm/lib/Analysis/DataStructure/DataStructure.cpp Sun Oct 20 21:08:03 2002 @@ -358,17 +358,19 @@ // Define here to avoid including iOther.h and BasicBlock.h in DSGraph.h Function &DSCallSite::getCaller() const { - return *callInst->getParent()->getParent(); + return *Inst->getParent()->getParent(); } template DSCallSite::DSCallSite(const DSCallSite &FromCall, CopyFunctor nodeCopier) - : callInst(&FromCall.getCallInst()) { + : Inst(FromCall.Inst) { - reserve(FromCall.size()); - for (unsigned j = 0, ej = FromCall.size(); j != ej; ++j) - push_back(&nodeCopier == 0 ? DSNodeHandle(FromCall[j]) - : nodeCopier(&FromCall[j])); + RetVal = nodeCopier(&RetVal); + Callee = nodeCopier(&Callee); + + CallArgs.reserve(FromCall.CallArgs.size()); + for (unsigned j = 0, ej = FromCall.CallArgs.size(); j != ej; ++j) + CallArgs.push_back(nodeCopier(&FromCall.CallArgs[j])); } @@ -555,13 +557,13 @@ for (unsigned i = 0, e = FunctionCalls.size(); i != e; ++i) { DSCallSite &Call = FunctionCalls[i]; // Then the return value is certainly incomplete! - markIncompleteNode(Call.getReturnValueNode().getNode()); + markIncompleteNode(Call.getRetVal().getNode()); // The call does not make the function argument incomplete... // All arguments to the function call are incomplete though! for (unsigned i = 0, e = Call.getNumPtrArgs(); i != e; ++i) - markIncompleteNode(Call.getPtrArgNode(i).getNode()); + markIncompleteNode(Call.getPtrArg(i).getNode()); } // Mark all of the nodes pointed to by global or cast nodes as incomplete... @@ -693,7 +695,7 @@ // Iterate, marking globals or cast nodes alive until no new live nodes // are added to Alive std::set Visiting; // Used to identify cycles - std::set::iterator I=GlobalNodes.begin(), E=GlobalNodes.end(); + std::set::iterator I = GlobalNodes.begin(), E = GlobalNodes.end(); for (size_t liveCount = 0; liveCount < Alive.size(); ) { liveCount = Alive.size(); for ( ; I != E; ++I) @@ -708,24 +710,39 @@ // Since all call nodes must be live if any one is live, we have to mark // all nodes of the call as live and continue the iteration (via recursion). if (FilterCalls) { - bool recurse = false; - for (int i = 0, ei = Calls.size(); i < ei; ++i) { + bool Recurse = false; + for (unsigned i = 0, ei = Calls.size(); i < ei; ++i) { bool CallIsDead = true, CallHasDeadArg = false; - for (unsigned j = 0, ej = Calls[i].size(); j != ej; ++j) { - bool argIsDead = Calls[i][j].getNode() == 0 || - Alive.count(Calls[i][j].getNode()) == 0; - CallHasDeadArg |= (Calls[i][j].getNode() != 0 && argIsDead); - CallIsDead &= argIsDead; + DSCallSite &CS = Calls[i]; + for (unsigned j = 0, ej = CS.getNumPtrArgs(); j != ej; ++j) + if (DSNode *N = CS.getPtrArg(j).getNode()) { + bool ArgIsDead = !Alive.count(N); + CallHasDeadArg |= ArgIsDead; + CallIsDead &= ArgIsDead; + } + + if (DSNode *N = CS.getRetVal().getNode()) { + bool RetIsDead = !Alive.count(N); + CallHasDeadArg |= RetIsDead; + CallIsDead &= RetIsDead; } + + DSNode *N = CS.getCallee().getNode(); + bool FnIsDead = !Alive.count(N); + CallHasDeadArg |= FnIsDead; + CallIsDead &= FnIsDead; + if (!CallIsDead && CallHasDeadArg) { // Some node in this call is live and another is dead. // Mark all nodes of call as live and iterate once more. - recurse = true; - for (unsigned j = 0, ej = Calls[i].size(); j != ej; ++j) - markAlive(Calls[i][j].getNode(), Alive); + Recurse = true; + for (unsigned j = 0, ej = CS.getNumPtrArgs(); j != ej; ++j) + markAlive(CS.getPtrArg(j).getNode(), Alive); + markAlive(CS.getRetVal().getNode(), Alive); + markAlive(CS.getCallee().getNode(), Alive); } } - if (recurse) + if (Recurse) markGlobalsIteration(GlobalNodes, Calls, Alive, FilterCalls); } } @@ -746,10 +763,15 @@ // Add all call nodes to the same set vector &Calls = G.getFunctionCalls(); if (FilterCalls) { - for (unsigned i = 0, e = Calls.size(); i != e; ++i) - for (unsigned j = 0, e = Calls[i].size(); j != e; ++j) - if (Calls[i][j].getNode()) - GlobalNodes.insert(Calls[i][j].getNode()); + for (unsigned i = 0, e = Calls.size(); i != e; ++i) { + for (unsigned j = 0, e = Calls[i].getNumPtrArgs(); j != e; ++j) + if (DSNode *N = Calls[i].getPtrArg(j).getNode()) + GlobalNodes.insert(N); + if (DSNode *N = Calls[i].getRetVal().getNode()) + GlobalNodes.insert(N); + if (DSNode *N = Calls[i].getCallee().getNode()) + GlobalNodes.insert(N); + } } // Iterate and recurse until no new live node are discovered. @@ -766,8 +788,9 @@ if (FilterCalls) for (int ei = Calls.size(), i = ei-1; i >= 0; --i) { bool CallIsDead = true; - for (unsigned j = 0, ej = Calls[i].size(); CallIsDead && j != ej; ++j) - CallIsDead = Alive.count(Calls[i][j].getNode()) == 0; + for (unsigned j = 0, ej = Calls[i].getNumPtrArgs(); + CallIsDead && j != ej; ++j) + CallIsDead = Alive.count(Calls[i].getPtrArg(j).getNode()) == 0; if (CallIsDead) Calls.erase(Calls.begin() + i); // remove the call entirely } @@ -793,9 +816,12 @@ // If KeepCalls, mark all nodes reachable by call nodes as alive... if (KeepCalls) - for (unsigned i = 0, e = FunctionCalls.size(); i != e; ++i) - for (unsigned j = 0, e = FunctionCalls[i].size(); j != e; ++j) - markAlive(FunctionCalls[i][j].getNode(), Alive); + for (unsigned i = 0, e = FunctionCalls.size(); i != e; ++i) { + for (unsigned j = 0, e = FunctionCalls[i].getNumPtrArgs(); j != e; ++j) + markAlive(FunctionCalls[i].getPtrArg(j).getNode(), Alive); + markAlive(FunctionCalls[i].getRetVal().getNode(), Alive); + markAlive(FunctionCalls[i].getCallee().getNode(), Alive); + } #if 0 for (unsigned i = 0, e = OrigFunctionCalls.size(); i != e; ++i) @@ -817,7 +843,7 @@ // Mark all globals or cast nodes that can reach a live node as alive. // This also marks all nodes reachable from such nodes as alive. // Of course, if KeepAllGlobals is specified, they would be live already. - if (! KeepAllGlobals) + if (!KeepAllGlobals) markGlobalsAlive(*this, Alive, ! KeepCalls); // Loop over all unreachable nodes, dropping their references... Index: llvm/lib/Analysis/DataStructure/Local.cpp diff -u llvm/lib/Analysis/DataStructure/Local.cpp:1.19 llvm/lib/Analysis/DataStructure/Local.cpp:1.20 --- llvm/lib/Analysis/DataStructure/Local.cpp:1.19 Sun Oct 20 17:12:06 2002 +++ llvm/lib/Analysis/DataStructure/Local.cpp Sun Oct 20 21:08:03 2002 @@ -257,6 +257,7 @@ /// object, pointing the scalar to it. /// void GraphBuilder::handleAlloc(AllocationInst &AI, DSNode::NodeTy NodeType) { + //DSNode *New = createNode(NodeType, Type::VoidTy); DSNode *New = createNode(NodeType, AI.getAllocatedType()); // Make the scalar point to the new node... @@ -354,28 +355,30 @@ } void GraphBuilder::visitCallInst(CallInst &CI) { - // Add a new function call entry... - FunctionCalls.push_back(CI); - DSCallSite &Args = FunctionCalls.back(); - // Set up the return value... + DSNodeHandle RetVal; if (isPointerType(CI.getType())) - Args.push_back(getLink(getValueNode(CI), 0, CI.getType())); - else - Args.push_back(DSNodeHandle()); + RetVal = getLink(getValueNode(CI), 0, CI.getType()); - unsigned Start = 0; + DSNodeHandle Callee; // Special case for a direct call, avoid creating spurious scalar node... - if (GlobalValue *GV = dyn_cast(CI.getOperand(0))) { - Args.push_back(getGlobalNode(*GV)); - Start = 1; - } + if (GlobalValue *GV = dyn_cast(CI.getOperand(0))) + Callee = getGlobalNode(*GV); + else + Callee = getLink(getValueNode(*CI.getOperand(0)), 0, + CI.getOperand(0)->getType()); + + std::vector Args; + Args.reserve(CI.getNumOperands()-1); - // Pass the arguments in... - for (unsigned i = Start, e = CI.getNumOperands(); i != e; ++i) + // Calculate the arguments vector... + for (unsigned i = 1, e = CI.getNumOperands(); i != e; ++i) if (isPointerType(CI.getOperand(i)->getType())) Args.push_back(getLink(getValueNode(*CI.getOperand(i)), 0, CI.getOperand(i)->getType())); + + // Add a new function call entry... + FunctionCalls.push_back(DSCallSite(CI, RetVal, Callee, Args)); } /// Handle casts... Index: llvm/lib/Analysis/DataStructure/Printer.cpp diff -u llvm/lib/Analysis/DataStructure/Printer.cpp:1.25 llvm/lib/Analysis/DataStructure/Printer.cpp:1.26 --- llvm/lib/Analysis/DataStructure/Printer.cpp:1.25 Sun Oct 20 15:39:17 2002 +++ llvm/lib/Analysis/DataStructure/Printer.cpp Sun Oct 20 21:08:03 2002 @@ -110,13 +110,13 @@ const std::vector &FCs = G->getFunctionCalls(); for (unsigned i = 0, e = FCs.size(); i != e; ++i) { const DSCallSite &Call = FCs[i]; - GW.emitSimpleNode(&Call, "shape=record", "call", Call.size()); + GW.emitSimpleNode(&Call, "shape=record", "call", Call.getNumPtrArgs()+2); - for (unsigned j = 0, e = Call.size(); j != e; ++j) - if (Call[j].getNode()) { - int EdgeDest = Call[j].getOffset(); + for (unsigned j = 0, e = Call.getNumPtrArgs(); j != e; ++j) + if (DSNode *N = Call.getPtrArg(j).getNode()) { + int EdgeDest = Call.getPtrArg(j).getOffset(); if (EdgeDest == 0) EdgeDest = -1; - GW.emitEdge(&Call, j, Call[j].getNode(), EdgeDest, "color=gray63"); + GW.emitEdge(&Call, j+2, N, EdgeDest, "color=gray63"); } } } Index: llvm/lib/Analysis/DataStructure/Steensgaard.cpp diff -u llvm/lib/Analysis/DataStructure/Steensgaard.cpp:1.4 llvm/lib/Analysis/DataStructure/Steensgaard.cpp:1.5 --- llvm/lib/Analysis/DataStructure/Steensgaard.cpp:1.4 Sun Oct 20 16:41:02 2002 +++ llvm/lib/Analysis/DataStructure/Steensgaard.cpp Sun Oct 20 21:08:03 2002 @@ -87,15 +87,15 @@ std::map &ValMap = ResultGraph->getValueMap(); // Handle the return value of the function... - if (Call.getReturnValueNode().getNode() && RetVal.getNode()) - RetVal.mergeWith(Call.getReturnValueNode()); + if (Call.getRetVal().getNode() && RetVal.getNode()) + RetVal.mergeWith(Call.getRetVal()); // Loop over all pointer arguments, resolving them to their provided pointers unsigned PtrArgIdx = 0; for (Function::aiterator AI = F->abegin(), AE = F->aend(); AI != AE; ++AI) { std::map::iterator I = ValMap.find(AI); if (I != ValMap.end()) // If its a pointer argument... - I->second.addEdgeTo(Call.getPtrArgNode(PtrArgIdx++)); + I->second.addEdgeTo(Call.getPtrArg(PtrArgIdx++)); } assert(PtrArgIdx == Call.getNumPtrArgs() && "Argument resolution mismatch!"); @@ -160,7 +160,8 @@ DSCallSite &CurCall = Calls[i]; // Loop over the called functions, eliminating as many as possible... - std::vector CallTargets = CurCall.getCalleeNode().getNode()->getGlobals(); + std::vector CallTargets = + CurCall.getCallee().getNode()->getGlobals(); for (unsigned c = 0; c != CallTargets.size(); ) { // If we can eliminate this function call, do so! bool Eliminated = false; Index: llvm/lib/Analysis/DataStructure/TopDownClosure.cpp diff -u llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.11 llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.12 --- llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.11 Sun Oct 20 16:41:02 2002 +++ llvm/lib/Analysis/DataStructure/TopDownClosure.cpp Sun Oct 20 21:08:03 2002 @@ -60,12 +60,12 @@ // TD ...Merge the formal arg scalar with the actual arg node DSNodeHandle &NodeForFormal = Graph.getNodeForValue(AI); if (NodeForFormal.getNode()) - NodeForFormal.mergeWith(CallSite.getPtrArgNode(i)); + NodeForFormal.mergeWith(CallSite.getPtrArg(i)); } // Merge returned node in the caller with the "return" node in callee - if (CallSite.getReturnValueNode().getNode() && Graph.getRetNode().getNode()) - Graph.getRetNode().mergeWith(CallSite.getReturnValueNode()); + if (CallSite.getRetVal().getNode() && Graph.getRetNode().getNode()) + Graph.getRetNode().mergeWith(CallSite.getRetVal()); } From lattner at cs.uiuc.edu Sun Oct 20 21:10:02 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun Oct 20 21:10:02 2002 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/DSGraph.h Message-ID: <200210210209.VAA23993@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis: DSGraph.h updated: 1.13 -> 1.14 --- Log message: Two callsites are equivalent even if they are from two completely different call instructions --- Diffs of the changes: Index: llvm/include/llvm/Analysis/DSGraph.h diff -u llvm/include/llvm/Analysis/DSGraph.h:1.13 llvm/include/llvm/Analysis/DSGraph.h:1.14 --- llvm/include/llvm/Analysis/DSGraph.h:1.13 Sun Oct 20 21:08:00 2002 +++ llvm/include/llvm/Analysis/DSGraph.h Sun Oct 20 21:09:03 2002 @@ -409,8 +409,6 @@ } bool operator<(const DSCallSite &CS) const { - if (Inst < CS.Inst) return true; - if (Inst > CS.Inst) return false; if (RetVal < CS.RetVal) return true; if (RetVal > CS.RetVal) return false; if (Callee < CS.Callee) return true; @@ -419,7 +417,7 @@ } bool operator==(const DSCallSite &CS) const { - return Inst == CS.Inst && RetVal == CS.RetVal && Callee == CS.Callee && + return RetVal == CS.RetVal && Callee == CS.Callee && CallArgs == CS.CallArgs; } }; From lattner at cs.uiuc.edu Sun Oct 20 21:20:00 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun Oct 20 21:20:00 2002 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/DataStructure.cpp Message-ID: <200210210219.VAA24167@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: DataStructure.cpp updated: 1.30 -> 1.31 --- Log message: Fix bug with prior checkin --- Diffs of the changes: Index: llvm/lib/Analysis/DataStructure/DataStructure.cpp diff -u llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.30 llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.31 --- llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.30 Sun Oct 20 21:08:03 2002 +++ llvm/lib/Analysis/DataStructure/DataStructure.cpp Sun Oct 20 21:18:55 2002 @@ -365,8 +365,8 @@ DSCallSite::DSCallSite(const DSCallSite &FromCall, CopyFunctor nodeCopier) : Inst(FromCall.Inst) { - RetVal = nodeCopier(&RetVal); - Callee = nodeCopier(&Callee); + RetVal = nodeCopier(&FromCall.RetVal); + Callee = nodeCopier(&FromCall.Callee); CallArgs.reserve(FromCall.CallArgs.size()); for (unsigned j = 0, ej = FromCall.CallArgs.size(); j != ej; ++j) From lattner at cs.uiuc.edu Sun Oct 20 21:39:00 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun Oct 20 21:39:00 2002 Subject: [llvm-commits] CVS: llvm/www/docs/ProgrammersManual.html Message-ID: <200210210238.VAA14710@tank.cs.uiuc.edu> Changes in directory llvm/www/docs: ProgrammersManual.html updated: 1.34 -> 1.35 --- Log message: Add a link to C++ in a nutshell book --- Diffs of the changes: Index: llvm/www/docs/ProgrammersManual.html diff -u llvm/www/docs/ProgrammersManual.html:1.34 llvm/www/docs/ProgrammersManual.html:1.35 --- llvm/www/docs/ProgrammersManual.html:1.34 Tue Oct 1 18:17:09 2002 +++ llvm/www/docs/ProgrammersManual.html Sun Oct 20 21:38:02 2002 @@ -163,7 +163,13 @@
  1. Dinkumware C++ Library reference - an excellent reference for the STL and other parts of -the standard C++ library.
    +the standard C++ library. + +
  2. C++ In a Nutshell - This is an +O'Reilly book in the making. It has a decent Standard Library +Reference that rivals Dinkumware's, and is actually free until the book is +published.
  3. C++ Frequently Asked Questions @@ -1763,6 +1769,6 @@ Chris Lattner -Last modified: Tue Oct 1 18:15:43 CDT 2002 +Last modified: Sun Oct 20 21:37:06 CDT 2002