From lattner at cs.uiuc.edu Mon Apr 21 14:16:00 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Apr 21 14:16:00 2003 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp Message-ID: <200304211915.OAA30485@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Utils: PromoteMemoryToRegister.cpp updated: 1.38 -> 1.39 --- Log message: Fix bug where use still existed in dead code --- Diffs of the changes: Index: llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp diff -u llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp:1.38 llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp:1.39 --- llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp:1.38 Fri Apr 18 14:25:22 2003 +++ llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp Mon Apr 21 14:15:26 2003 @@ -168,6 +168,8 @@ // while (!I->use_empty()) { Instruction *U = cast(I->use_back()); + if (!U->use_empty()) // If uses remain in dead code segment... + U->replaceAllUsesWith(Constant::getNullValue(U->getType())); U->getParent()->getInstList().erase(U); } From lattner at cs.uiuc.edu Mon Apr 21 14:54:00 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Apr 21 14:54:00 2003 Subject: [llvm-commits] CVS: llvm/tools/gccld/gccld.cpp Message-ID: <200304211953.OAA04514@apoc.cs.uiuc.edu> Changes in directory llvm/tools/gccld: gccld.cpp updated: 1.27 -> 1.28 --- Log message: Add support for allowing the user to extend the GCCLD searchpath --- Diffs of the changes: Index: llvm/tools/gccld/gccld.cpp diff -u llvm/tools/gccld/gccld.cpp:1.27 llvm/tools/gccld/gccld.cpp:1.28 --- llvm/tools/gccld/gccld.cpp:1.27 Sat Apr 19 18:07:33 2003 +++ llvm/tools/gccld/gccld.cpp Mon Apr 21 14:53:24 2003 @@ -294,6 +294,10 @@ if (Composite.get() == 0) return PrintAndReturn(argv[0], ErrorMessage); + // If the user specied an extra search path in their environment, respect it. + if (char *SearchPath = getenv("LLVM_LIB_SEARCH_PATH")) + LibPaths.push_back(SearchPath); + for (unsigned i = 1; i < InputFilenames.size(); ++i) { std::auto_ptr M(LoadObject(InputFilenames[i], ErrorMessage)); if (M.get() == 0) From lattner at cs.uiuc.edu Mon Apr 21 16:07:02 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Apr 21 16:07:02 2003 Subject: [llvm-commits] CVS: llvm/test/Regression/Linker/2003-04-21-Linkage.ll testlink1.ll testlink2.ll Message-ID: <200304212106.QAA12473@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Linker: 2003-04-21-Linkage.ll added (r1.1) testlink1.ll updated: 1.6 -> 1.7 testlink2.ll updated: 1.7 -> 1.8 --- Log message: New testcase --- Diffs of the changes: Index: llvm/test/Regression/Linker/2003-04-21-Linkage.ll diff -c /dev/null llvm/test/Regression/Linker/2003-04-21-Linkage.ll:1.1 *** /dev/null Mon Apr 21 16:06:36 2003 --- llvm/test/Regression/Linker/2003-04-21-Linkage.ll Mon Apr 21 16:06:25 2003 *************** *** 0 **** --- 1,15 ---- + ; RUN: echo "%X = linkonce global int 5 implementation linkonce int %foo() { ret int 7 }" | as > Output/%s.1.bc + ; RUN: as < %s > Output/%s.2.bc + ; RUN: link Output/%s.[12].bc + %X = external global int + + implementation + + declare int %foo() + + void %bar() { + load int* %X + call int %foo() + ret void + } + Index: llvm/test/Regression/Linker/testlink1.ll diff -u llvm/test/Regression/Linker/testlink1.ll:1.6 llvm/test/Regression/Linker/testlink1.ll:1.7 --- llvm/test/Regression/Linker/testlink1.ll:1.6 Wed Aug 21 18:52:57 2002 +++ llvm/test/Regression/Linker/testlink1.ll Mon Apr 21 16:06:25 2003 @@ -2,9 +2,9 @@ ; RUN: as < testlink2.ll > Output/testlink2.bc ; RUN: link Output/%s.bc Output/testlink2.bc -%MyVar = uninitialized global int +%MyVar = external global int %MyIntList = global { \2 *, int } { { \2, int }* null, int 17 } - uninitialized global int ; int*:0 + external global int ; int*:0 %AConst = constant int 123 @@ -25,7 +25,7 @@ %v1 = load int* %MyVar call void %print(int %v1) ;; Should start out 4 - %idx = getelementptr { \2 *, int }* %MyIntList, uint 0, ubyte 1 + %idx = getelementptr { \2 *, int }* %MyIntList, long 0, ubyte 1 %v2 = load int* %idx call void %print(int %v2) ;; Should start out 17 Index: llvm/test/Regression/Linker/testlink2.ll diff -u llvm/test/Regression/Linker/testlink2.ll:1.7 llvm/test/Regression/Linker/testlink2.ll:1.8 --- llvm/test/Regression/Linker/testlink2.ll:1.7 Thu Aug 22 11:39:02 2002 +++ llvm/test/Regression/Linker/testlink2.ll Mon Apr 21 16:06:25 2003 @@ -3,7 +3,7 @@ ; RUN: echo %MyVar = global int 4 -%MyIntList = uninitialized global { \2 *, int } +%MyIntList = external global { \2 *, int } %AConst = constant int 123 @@ -20,7 +20,7 @@ int "foo"(int %blah) begin store int %blah, int *%MyVar - %idx = getelementptr { \2 *, int } * %MyIntList, uint 0, ubyte 1 + %idx = getelementptr { \2 *, int } * %MyIntList, long 0, ubyte 1 store int 12, int* %idx %ack = load int * %0 ;; Load from the unnamed constant From lattner at cs.uiuc.edu Mon Apr 21 16:08:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Apr 21 16:08:01 2003 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Utils/Linker.cpp Message-ID: <200304212107.QAA12507@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Utils: Linker.cpp updated: 1.38 -> 1.39 --- Log message: Fix linking a function with qualifiers to a external function declaration: Fixed bug: Linker/2003-04-21-Linkage.ll --- Diffs of the changes: Index: llvm/lib/Transforms/Utils/Linker.cpp diff -u llvm/lib/Transforms/Utils/Linker.cpp:1.38 llvm/lib/Transforms/Utils/Linker.cpp:1.39 --- llvm/lib/Transforms/Utils/Linker.cpp:1.38 Wed Apr 16 15:28:43 2003 +++ llvm/lib/Transforms/Utils/Linker.cpp Mon Apr 21 16:07:05 2003 @@ -202,6 +202,9 @@ assert(SGV->hasInitializer() || SGV->hasExternalLinkage() && "Global must either be external or have an initializer!"); + bool SGExtern = SGV->isExternal(); + bool DGExtern = DGV ? DGV->isExternal() : false; + if (!DGV || DGV->hasInternalLinkage() || SGV->hasInternalLinkage()) { // No linking to be performed, simply create an identical version of the // symbol over in the dest module... the initializer will be filled in @@ -213,7 +216,7 @@ // Make sure to remember this mapping... ValueMap.insert(std::make_pair(SGV, DGV)); - } else if (SGV->getLinkage() != DGV->getLinkage()) { + } else if (!SGExtern && !DGExtern && SGV->getLinkage() !=DGV->getLinkage()){ return Error(Err, "Global variables named '" + SGV->getName() + "' have different linkage specifiers!"); } else if (SGV->hasExternalLinkage() || SGV->hasLinkOnceLinkage() || @@ -227,6 +230,9 @@ return Error(Err, "Global Variable Collision on '" + SGV->getType()->getDescription() + "':%" + SGV->getName() + " - Global variables differ in const'ness"); + if (DGExtern) + DGV->setLinkage(SGV->getLinkage()); + // Okay, everything is cool, remember the mapping... ValueMap.insert(std::make_pair(SGV, DGV)); } else { @@ -301,20 +307,23 @@ // DF = cast_or_null(ST->lookup(SF->getType(), SF->getName())); + bool SFExtern = SF->isExternal(); + bool DFExtern = DF ? DF->isExternal() : false; + if (!DF || SF->hasInternalLinkage() || DF->hasInternalLinkage()) { - // Function does not already exist, simply insert an external function - // signature identical to SF into the dest module... + // Function does not already exist, simply insert an function signature + // identical to SF into the dest module... Function *DF = new Function(SF->getFunctionType(), SF->getLinkage(), SF->getName(), Dest); // ... and remember this mapping... ValueMap.insert(std::make_pair(SF, DF)); - } else if (SF->getLinkage() != DF->getLinkage()) { - return Error(Err, "Functions named '" + SF->getName() + - "' have different linkage specifiers!"); } else if (SF->getLinkage() == GlobalValue::AppendingLinkage) { return Error(Err, "Functions named '" + SF->getName() + "' have appending linkage!"); + } else if (!SFExtern && !DFExtern && SF->getLinkage() != DF->getLinkage()) { + return Error(Err, "Functions named '" + SF->getName() + + "' have different linkage specifiers!"); } else if (SF->getLinkage() == GlobalValue::ExternalLinkage) { // If the function has a name, and that name is already in use in the Dest // module, make sure that the name is a compatible function... @@ -324,6 +333,9 @@ return Error(Err, "Function '" + SF->getFunctionType()->getDescription() + "':\"" + SF->getName() + "\" - Function is already defined!"); + + if (DFExtern) + DF->setLinkage(SF->getLinkage()); // Otherwise, just remember this mapping... ValueMap.insert(std::make_pair(SF, DF)); From lattner at cs.uiuc.edu Mon Apr 21 16:16:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Apr 21 16:16:01 2003 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Utils/Linker.cpp Message-ID: <200304212115.QAA12925@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Utils: Linker.cpp updated: 1.39 -> 1.40 --- Log message: Fix bug: 2003-01-30-LinkerRename.ll --- Diffs of the changes: Index: llvm/lib/Transforms/Utils/Linker.cpp diff -u llvm/lib/Transforms/Utils/Linker.cpp:1.39 llvm/lib/Transforms/Utils/Linker.cpp:1.40 --- llvm/lib/Transforms/Utils/Linker.cpp:1.39 Mon Apr 21 16:07:05 2003 +++ llvm/lib/Transforms/Utils/Linker.cpp Mon Apr 21 16:15:04 2003 @@ -210,12 +210,26 @@ // symbol over in the dest module... the initializer will be filled in // later by LinkGlobalInits... // - DGV = new GlobalVariable(SGV->getType()->getElementType(), - SGV->isConstant(), SGV->getLinkage(), /*init*/0, - SGV->getName(), Dest); + GlobalVariable *NewDGV = + new GlobalVariable(SGV->getType()->getElementType(), + SGV->isConstant(), SGV->getLinkage(), /*init*/0, + SGV->getName(), Dest); + + // If the LLVM runtime renamed the global, but it is an externally visible + // symbol, DGV must be an existing global with internal linkage. Rename + // it. + if (NewDGV->getName() != SGV->getName() && !NewDGV->hasInternalLinkage()){ + assert(DGV && DGV->getName() == SGV->getName() && + DGV->hasInternalLinkage()); + DGV->setName(""); + NewDGV->setName(SGV->getName()); // Force the name back + DGV->setName(SGV->getName()); // This will cause a renaming + assert(NewDGV->getName() == SGV->getName() && + DGV->getName() != SGV->getName()); + } // Make sure to remember this mapping... - ValueMap.insert(std::make_pair(SGV, DGV)); + ValueMap.insert(std::make_pair(SGV, NewDGV)); } else if (!SGExtern && !DGExtern && SGV->getLinkage() !=DGV->getLinkage()){ return Error(Err, "Global variables named '" + SGV->getName() + "' have different linkage specifiers!"); @@ -313,11 +327,23 @@ if (!DF || SF->hasInternalLinkage() || DF->hasInternalLinkage()) { // Function does not already exist, simply insert an function signature // identical to SF into the dest module... - Function *DF = new Function(SF->getFunctionType(), SF->getLinkage(), - SF->getName(), Dest); + Function *NewDF = new Function(SF->getFunctionType(), SF->getLinkage(), + SF->getName(), Dest); + + // If the LLVM runtime renamed the function, but it is an externally + // visible symbol, DF must be an existing function with internal linkage. + // Rename it. + if (NewDF->getName() != SF->getName() && !NewDF->hasInternalLinkage()) { + assert(DF && DF->getName() == SF->getName() &&DF->hasInternalLinkage()); + DF->setName(""); + NewDF->setName(SF->getName()); // Force the name back + DF->setName(SF->getName()); // This will cause a renaming + assert(NewDF->getName() == SF->getName() && + DF->getName() != SF->getName()); + } // ... and remember this mapping... - ValueMap.insert(std::make_pair(SF, DF)); + ValueMap.insert(std::make_pair(SF, NewDF)); } else if (SF->getLinkage() == GlobalValue::AppendingLinkage) { return Error(Err, "Functions named '" + SF->getName() + "' have appending linkage!"); From lattner at cs.uiuc.edu Mon Apr 21 16:34:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Apr 21 16:34:01 2003 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/InstSelectSimple.cpp Message-ID: <200304212133.QAA14671@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: InstSelectSimple.cpp updated: 1.85 -> 1.86 --- Log message: Add support for a simple constantexpr: cast of one ptr type to another --- Diffs of the changes: Index: llvm/lib/Target/X86/InstSelectSimple.cpp diff -u llvm/lib/Target/X86/InstSelectSimple.cpp:1.85 llvm/lib/Target/X86/InstSelectSimple.cpp:1.86 --- llvm/lib/Target/X86/InstSelectSimple.cpp:1.85 Thu Jan 16 12:07:23 2003 +++ llvm/lib/Target/X86/InstSelectSimple.cpp Mon Apr 21 16:33:44 2003 @@ -307,6 +307,11 @@ emitGEPOperation(MBB, IP, CE->getOperand(0), CE->op_begin()+1, CE->op_end(), R); return; + } else if (CE->getOpcode() == Instruction::Cast && + isa(CE->getType()) && + isa(CE->getOperand(0)->getType())) { + copyConstantToRegister(MBB, IP, cast(CE->getOperand(0)), R); + return; } std::cerr << "Offending expr: " << C << "\n"; From lattner at cs.uiuc.edu Mon Apr 21 17:44:00 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Apr 21 17:44:00 2003 Subject: [llvm-commits] CVS: llvm/tools/lli/Interpreter/Execution.cpp Message-ID: <200304212243.RAA15821@apoc.cs.uiuc.edu> Changes in directory llvm/tools/lli/Interpreter: Execution.cpp updated: 1.76 -> 1.77 --- Log message: Fix wierd idiom --- Diffs of the changes: Index: llvm/tools/lli/Interpreter/Execution.cpp diff -u llvm/tools/lli/Interpreter/Execution.cpp:1.76 llvm/tools/lli/Interpreter/Execution.cpp:1.77 --- llvm/tools/lli/Interpreter/Execution.cpp:1.76 Tue Feb 25 15:14:59 2003 +++ llvm/tools/lli/Interpreter/Execution.cpp Mon Apr 21 17:43:32 2003 @@ -111,7 +111,7 @@ default: cerr << "Unhandled ConstantExpr: " << CE << "\n"; abort(); - { GenericValue V; return V; } + return GenericValue(); } } else if (Constant *CPV = dyn_cast(V)) { return TheEE->getConstantValue(CPV); From lattner at cs.uiuc.edu Mon Apr 21 17:45:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Apr 21 17:45:01 2003 Subject: [llvm-commits] CVS: llvm/tools/lli/ExecutionEngine.cpp Message-ID: <200304212244.RAA15838@apoc.cs.uiuc.edu> Changes in directory llvm/tools/lli: ExecutionEngine.cpp updated: 1.4 -> 1.5 --- Log message: Make stderr, stdout, stdin work with LLI --- Diffs of the changes: Index: llvm/tools/lli/ExecutionEngine.cpp diff -u llvm/tools/lli/ExecutionEngine.cpp:1.4 llvm/tools/lli/ExecutionEngine.cpp:1.5 --- llvm/tools/lli/ExecutionEngine.cpp:1.4 Sun Jan 12 18:58:06 2003 +++ llvm/tools/lli/ExecutionEngine.cpp Mon Apr 21 17:44:36 2003 @@ -213,6 +213,12 @@ DEBUG(std::cerr << "Global '" << I->getName() << "' -> " << (void*)GlobalAddress[I] << "\n"); + } else if (I->getName() == "stdout") { + GlobalAddress[I] = &stdout; + } else if (I->getName() == "stderr") { + GlobalAddress[I] = &stderr; + } else if (I->getName() == "stdin") { + GlobalAddress[I] = &stdin; } else { std::cerr << "Global: " << I->getName() << "\n"; assert(0 && "References to external globals not handled yet!"); From lattner at cs.uiuc.edu Mon Apr 21 17:45:02 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Apr 21 17:45:02 2003 Subject: [llvm-commits] CVS: llvm/tools/lli/Interpreter/ExternalFunctions.cpp Message-ID: <200304212244.RAA15828@apoc.cs.uiuc.edu> Changes in directory llvm/tools/lli/Interpreter: ExternalFunctions.cpp updated: 1.43 -> 1.44 --- Log message: fprintf CAN take exactly 2 args --- Diffs of the changes: Index: llvm/tools/lli/Interpreter/ExternalFunctions.cpp diff -u llvm/tools/lli/Interpreter/ExternalFunctions.cpp:1.43 llvm/tools/lli/Interpreter/ExternalFunctions.cpp:1.44 --- llvm/tools/lli/Interpreter/ExternalFunctions.cpp:1.43 Mon Mar 31 16:12:37 2003 +++ llvm/tools/lli/Interpreter/ExternalFunctions.cpp Mon Apr 21 17:43:20 2003 @@ -685,7 +685,7 @@ // int fprintf(FILE *,sbyte *, ...) - a very rough implementation to make output // useful. GenericValue lle_X_fprintf(FunctionType *M, const vector &Args) { - assert(Args.size() > 2); + assert(Args.size() >= 2); char Buffer[10000]; vector NewArgs; NewArgs.push_back(PTOGV(Buffer)); From brukman at cs.uiuc.edu Tue Apr 22 12:55:01 2003 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Tue Apr 22 12:55:01 2003 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/InstSelectSimple.cpp Message-ID: <200304221754.MAA03131@neo.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: InstSelectSimple.cpp updated: 1.86 -> 1.87 --- Log message: It's "necessary" to spell "necessarily" correctly. --- Diffs of the changes: Index: llvm/lib/Target/X86/InstSelectSimple.cpp diff -u llvm/lib/Target/X86/InstSelectSimple.cpp:1.86 llvm/lib/Target/X86/InstSelectSimple.cpp:1.87 --- llvm/lib/Target/X86/InstSelectSimple.cpp:1.86 Mon Apr 21 16:33:44 2003 +++ llvm/lib/Target/X86/InstSelectSimple.cpp Tue Apr 22 12:54:23 2003 @@ -1209,7 +1209,7 @@ // Emit the byte swap instruction... switch (Class) { case cByte: - // No byteswap neccesary for 8 bit value... + // No byteswap necessary for 8 bit value... BuildMI(BB, X86::MOVrr8, 1, DestReg).addReg(SrcReg); break; case cInt: @@ -1219,7 +1219,7 @@ case cShort: // For 16 bit we have to use an xchg instruction, because there is no - // 16-bit bswap. XCHG is neccesarily not in SSA form, so we force things + // 16-bit bswap. XCHG is necessarily not in SSA form, so we force things // into AX to do the xchg. // BuildMI(BB, X86::MOVrr16, 1, X86::AX).addReg(SrcReg); From lattner at cs.uiuc.edu Tue Apr 22 13:03:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Apr 22 13:03:01 2003 Subject: [llvm-commits] CVS: llvm/include/llvm/Module.h Message-ID: <200304221802.NAA06917@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: Module.h updated: 1.30 -> 1.31 --- Log message: Add support for tracking whether a module is 64/32 bit and big/little endian Also add a moduleID field which can be used for diagnostics --- Diffs of the changes: Index: llvm/include/llvm/Module.h diff -u llvm/include/llvm/Module.h:1.30 llvm/include/llvm/Module.h:1.31 --- llvm/include/llvm/Module.h:1.30 Wed Nov 20 12:31:31 2002 +++ llvm/include/llvm/Module.h Tue Apr 22 13:02:02 2003 @@ -50,16 +50,22 @@ typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator const_reverse_iterator; -private: - GlobalListType GlobalList; // The Global Variables - FunctionListType FunctionList; // The Functions + enum Endianness { LittleEndian, BigEndian }; + enum PointerSize { Pointer32, Pointer64 }; - GlobalValueRefMap *GVRefMap; +private: + GlobalListType GlobalList; // The Global Variables in the module + FunctionListType FunctionList; // The Functions in the module + GlobalValueRefMap *GVRefMap; // Keep track of GlobalValueRef's + SymbolTable *SymTab; // Symbol Table for the module + std::string ModuleID; // Human readable identifier for the module - SymbolTable *SymTab; + // These flags are probably not the right long-term way to handle this kind of + // target information, but it is sufficient for now. + Endianness Endian; // True if target is little endian + PointerSize PtrSize; // True if target has 32-bit pointers (false = 64-bit) - // Accessor for the underlying GlobalValRefMap... only through the - // Constant class... + // Accessor for the underlying GVRefMap... only through the Constant class... friend class Constant; friend class ConstantPointerRef; void mutateConstantPointerRef(GlobalValue *OldGV, GlobalValue *NewGV); @@ -67,8 +73,22 @@ void destroyConstantPointerRef(ConstantPointerRef *CPR); public: - Module(); + Module(const std::string &ModuleID); ~Module(); + + const std::string &getModuleIdentifier() const { return ModuleID; } + + /// Target endian information... + bool isLittleEndian() const { return Endian == LittleEndian; } + bool isBigEndian() const { return Endian == BigEndian; } + Endianness getEndianness() const { return Endian; } + void setEndianness(Endianness E) { Endian = E; } + + /// Target Pointer Size information... + bool has32BitPointers() const { return PtrSize == Pointer32; } + bool has64BitPointers() const { return PtrSize == Pointer64; } + PointerSize getPointerSize() const { return PtrSize; } + void setPointerSize(PointerSize PS) { PtrSize = PS; } /// getOrInsertFunction - Look up the specified function in the module symbol /// table. If it does not exist, add a prototype for the function and return From lattner at cs.uiuc.edu Tue Apr 22 13:03:02 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Apr 22 13:03:02 2003 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Module.cpp Message-ID: <200304221802.NAA06924@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Module.cpp updated: 1.34 -> 1.35 --- Log message: Add support for tracking whether a module is 64/32 bit and big/little endian Also add a moduleID field which can be used for diagnostics --- Diffs of the changes: Index: llvm/lib/VMCore/Module.cpp diff -u llvm/lib/VMCore/Module.cpp:1.34 llvm/lib/VMCore/Module.cpp:1.35 --- llvm/lib/VMCore/Module.cpp:1.34 Wed Apr 16 15:28:45 2003 +++ llvm/lib/VMCore/Module.cpp Tue Apr 22 13:02:04 2003 @@ -52,7 +52,8 @@ }; -Module::Module() { +Module::Module(const std::string &MID) + : ModuleID(MID), Endian(BigEndian), PtrSize(Pointer64) { FunctionList.setItemParent(this); FunctionList.setParent(this); GlobalList.setItemParent(this); From lattner at cs.uiuc.edu Tue Apr 22 13:03:03 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Apr 22 13:03:03 2003 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Utils/CloneModule.cpp Message-ID: <200304221802.NAA06937@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Utils: CloneModule.cpp updated: 1.2 -> 1.3 --- Log message: Preserve the new moduleID field --- Diffs of the changes: Index: llvm/lib/Transforms/Utils/CloneModule.cpp diff -u llvm/lib/Transforms/Utils/CloneModule.cpp:1.2 llvm/lib/Transforms/Utils/CloneModule.cpp:1.3 --- llvm/lib/Transforms/Utils/CloneModule.cpp:1.2 Wed Apr 16 15:28:43 2003 +++ llvm/lib/Transforms/Utils/CloneModule.cpp Tue Apr 22 13:02:26 2003 @@ -18,7 +18,7 @@ /// Module *CloneModule(const Module *M) { // First off, we need to create the new module... - Module *New = new Module(); + Module *New = new Module(M->getModuleIdentifier()); // Create the value map that maps things from the old module over to the new // module. From lattner at cs.uiuc.edu Tue Apr 22 13:04:00 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Apr 22 13:04:00 2003 Subject: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y Message-ID: <200304221803.NAA06973@apoc.cs.uiuc.edu> Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.105 -> 1.106 --- Log message: Preserve module source information in the ModuleID --- Diffs of the changes: Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.105 llvm/lib/AsmParser/llvmAsmParser.y:1.106 --- llvm/lib/AsmParser/llvmAsmParser.y:1.105 Wed Apr 16 15:28:31 2003 +++ llvm/lib/AsmParser/llvmAsmParser.y Tue Apr 22 13:02:52 2003 @@ -591,7 +591,8 @@ CurFilename = Filename; llvmAsmlineno = 1; // Reset the current line number... - CurModule.CurrentModule = new Module(); // Allocate a new module to read + // Allocate a new module to read + CurModule.CurrentModule = new Module(Filename); yyparse(); // Parse the file. Module *Result = ParserResult; llvmAsmin = stdin; // F is about to go away, don't use it anymore... From lattner at cs.uiuc.edu Tue Apr 22 13:04:02 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Apr 22 13:04:02 2003 Subject: [llvm-commits] CVS: llvm/include/llvm/Bytecode/Reader.h Message-ID: <200304221803.NAA06986@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Bytecode: Reader.h updated: 1.9 -> 1.10 --- Log message: Add information about the module source --- Diffs of the changes: Index: llvm/include/llvm/Bytecode/Reader.h diff -u llvm/include/llvm/Bytecode/Reader.h:1.9 llvm/include/llvm/Bytecode/Reader.h:1.10 --- llvm/include/llvm/Bytecode/Reader.h:1.9 Sat Apr 19 16:45:52 2003 +++ llvm/include/llvm/Bytecode/Reader.h Tue Apr 22 13:03:13 2003 @@ -22,6 +22,7 @@ Module *ParseBytecodeFile(const std::string &Filename, std::string *ErrorStr = 0); Module *ParseBytecodeBuffer(const unsigned char *Buffer, unsigned BufferSize, + const std::string &ModuleID, std::string *ErrorStr = 0); // ReadArchiveFile - Read bytecode files from the specfied .a file, returning From lattner at cs.uiuc.edu Tue Apr 22 13:04:03 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Apr 22 13:04:03 2003 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Reader/ReadArchive.cpp Reader.cpp ReaderInternals.h Message-ID: <200304221803.NAA06966@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Reader: ReadArchive.cpp updated: 1.1 -> 1.2 Reader.cpp updated: 1.52 -> 1.53 ReaderInternals.h updated: 1.34 -> 1.35 --- Log message: Preserve module source information in the ModuleID --- Diffs of the changes: Index: llvm/lib/Bytecode/Reader/ReadArchive.cpp diff -u llvm/lib/Bytecode/Reader/ReadArchive.cpp:1.1 llvm/lib/Bytecode/Reader/ReadArchive.cpp:1.2 --- llvm/lib/Bytecode/Reader/ReadArchive.cpp:1.1 Sat Apr 19 16:45:34 2003 +++ llvm/lib/Bytecode/Reader/ReadArchive.cpp Tue Apr 22 13:02:51 2003 @@ -82,7 +82,8 @@ } -static bool ReadArchiveBuffer(unsigned char *Buffer, unsigned Length, +static bool ReadArchiveBuffer(const std::string &Filename, + unsigned char *Buffer, unsigned Length, std::vector &Objects, std::string *ErrorStr) { if (Length < 8 || memcmp(Buffer, "!\n", 8)) @@ -107,7 +108,8 @@ return true; break; case UserObject: { - Module *M = ParseBytecodeBuffer(Buffer+sizeof(ar_hdr), Size, ErrorStr); + Module *M = ParseBytecodeBuffer(Buffer+sizeof(ar_hdr), Size, + Filename+":somefile", ErrorStr); if (!M) return true; Objects.push_back(M); break; @@ -151,7 +153,7 @@ return Error(ErrorStr, "Error mmapping file!"); // Parse the archive files we mmap'ped in - bool Result = ReadArchiveBuffer(Buffer, Length, Objects, ErrorStr); + bool Result = ReadArchiveBuffer(Filename, Buffer, Length, Objects, ErrorStr); // Unmmap the archive... munmap((char*)Buffer, Length); Index: llvm/lib/Bytecode/Reader/Reader.cpp diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.52 llvm/lib/Bytecode/Reader/Reader.cpp:1.53 --- llvm/lib/Bytecode/Reader/Reader.cpp:1.52 Sat Apr 19 16:45:17 2003 +++ llvm/lib/Bytecode/Reader/Reader.cpp Tue Apr 22 13:02:51 2003 @@ -620,14 +620,15 @@ return 0; } -Module *BytecodeParser::ParseBytecode(const uchar *Buf, const uchar *EndBuf) { +Module *BytecodeParser::ParseBytecode(const uchar *Buf, const uchar *EndBuf, + const std::string &ModuleID) { unsigned Sig; // Read and check signature... if (read(Buf, EndBuf, Sig) || Sig != ('l' | ('l' << 8) | ('v' << 16) | 'm' << 24)) return ::Error(&Error, "Invalid bytecode signature!"); - TheModule = new Module(); + TheModule = new Module(ModuleID); if (ParseModule(Buf, EndBuf)) { delete TheModule; TheModule = 0; @@ -637,7 +638,7 @@ Module *ParseBytecodeBuffer(const unsigned char *Buffer, unsigned Length, - std::string *ErrorStr) { + const std::string &ModuleID, std::string *ErrorStr){ BytecodeParser Parser; unsigned char *PtrToDelete = 0; if ((intptr_t)Buffer & 3) { // If the buffer is not 4 byte aligned... @@ -648,7 +649,7 @@ Buffer = PtrToDelete+Offset; } - Module *R = Parser.ParseBytecode(Buffer, Buffer+Length); + Module *R = Parser.ParseBytecode(Buffer, Buffer+Length, ModuleID); if (ErrorStr) *ErrorStr = Parser.getError(); delete [] PtrToDelete; // Delete alignment buffer if neccesary @@ -691,7 +692,7 @@ return Error(ErrorStr, "Error mmapping file!"); // Parse the bytecode we mmapped in - Result = ParseBytecodeBuffer(Buffer, Length, ErrorStr); + Result = ParseBytecodeBuffer(Buffer, Length, Filename, ErrorStr); // Unmmap the bytecode... munmap((char*)Buffer, Length); @@ -721,7 +722,7 @@ unsigned char *Buf = &FileData[0]; #endif - Result = ParseBytecodeBuffer(Buf, FileData.size(), ErrorStr); + Result = ParseBytecodeBuffer(Buf, FileData.size(), "", ErrorStr); #if ALIGN_PTRS munmap((char*)Buf, FileData.size()); // Free mmap'd data area Index: llvm/lib/Bytecode/Reader/ReaderInternals.h diff -u llvm/lib/Bytecode/Reader/ReaderInternals.h:1.34 llvm/lib/Bytecode/Reader/ReaderInternals.h:1.35 --- llvm/lib/Bytecode/Reader/ReaderInternals.h:1.34 Wed Apr 16 16:16:03 2003 +++ llvm/lib/Bytecode/Reader/ReaderInternals.h Tue Apr 22 13:02:51 2003 @@ -52,7 +52,8 @@ freeTable(ModuleValues); } - Module *ParseBytecode(const uchar *Buf, const uchar *EndBuf); + Module *ParseBytecode(const uchar *Buf, const uchar *EndBuf, + const std::string &ModuleID); std::string getError() const { return Error; } From lattner at cs.uiuc.edu Tue Apr 22 13:11:00 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Apr 22 13:11:00 2003 Subject: [llvm-commits] CVS: llvm/tools/lli/lli.cpp Message-ID: <200304221810.NAA07090@apoc.cs.uiuc.edu> Changes in directory llvm/tools/lli: lli.cpp updated: 1.15 -> 1.16 --- Log message: Build the appropriate target machine for the input pointer size and endianness --- Diffs of the changes: Index: llvm/tools/lli/lli.cpp diff -u llvm/tools/lli/lli.cpp:1.15 llvm/tools/lli/lli.cpp:1.16 --- llvm/tools/lli/lli.cpp:1.15 Mon Dec 23 18:39:16 2002 +++ llvm/tools/lli/lli.cpp Tue Apr 22 13:10:32 2003 @@ -75,10 +75,8 @@ } #endif - // FIXME: This should look at the PointerSize and endianness of the bytecode - // file to determine the endianness and pointer size of target machine to use. - unsigned Config = TM::PtrSize64 | TM::BigEndian; - + unsigned Config = (M->isLittleEndian() ? TM::LittleEndian : TM::BigEndian) | + (M->has32BitPointers() ? TM::PtrSize32 : TM::PtrSize64); ExecutionEngine *EE = 0; // If there is nothing that is forcing us to use the interpreter, make a JIT. From lattner at cs.uiuc.edu Tue Apr 22 13:16:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Apr 22 13:16:01 2003 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Reader/Reader.cpp Message-ID: <200304221815.NAA07179@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Reader: Reader.cpp updated: 1.53 -> 1.54 --- Log message: Add support for reading and writing pointersize/endianness to and from bytecode --- Diffs of the changes: Index: llvm/lib/Bytecode/Reader/Reader.cpp diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.53 llvm/lib/Bytecode/Reader/Reader.cpp:1.54 --- llvm/lib/Bytecode/Reader/Reader.cpp:1.53 Tue Apr 22 13:02:51 2003 +++ llvm/lib/Bytecode/Reader/Reader.cpp Tue Apr 22 13:15:08 2003 @@ -526,6 +526,11 @@ return true; } + TheModule->setEndianness(isBigEndian ? Module::BigEndian : + Module::LittleEndian); + TheModule->setPointerSize(hasLongPointers ? Module::Pointer64 : + Module::Pointer32); + BCR_TRACE(1, "Bytecode Rev = " << (unsigned)RevisionNum << "\n"); BCR_TRACE(1, "BigEndian/LongPointers = " << isBigEndian << "," << hasLongPointers << "\n"); From lattner at cs.uiuc.edu Tue Apr 22 13:16:02 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Apr 22 13:16:02 2003 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Writer/Writer.cpp Message-ID: <200304221815.NAA07186@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Writer: Writer.cpp updated: 1.32 -> 1.33 --- Log message: Add support for reading and writing pointersize/endianness to and from bytecode --- Diffs of the changes: Index: llvm/lib/Bytecode/Writer/Writer.cpp diff -u llvm/lib/Bytecode/Writer/Writer.cpp:1.32 llvm/lib/Bytecode/Writer/Writer.cpp:1.33 --- llvm/lib/Bytecode/Writer/Writer.cpp:1.32 Wed Apr 16 16:16:05 2003 +++ llvm/lib/Bytecode/Writer/Writer.cpp Tue Apr 22 13:15:10 2003 @@ -43,8 +43,8 @@ // Emit the top level CLASS block. BytecodeBlock ModuleBlock(BytecodeFormat::Module, Out); - bool isBigEndian = true; - bool hasLongPointers = true; + bool isBigEndian = M->isBigEndian(); + bool hasLongPointers = M->has64BitPointers(); // Output the version identifier... we are currently on bytecode version #2 unsigned Version = (2 << 4) | isBigEndian | (hasLongPointers << 1); From lattner at cs.uiuc.edu Tue Apr 22 13:43:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Apr 22 13:43:01 2003 Subject: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y Message-ID: <200304221842.NAA07864@apoc.cs.uiuc.edu> Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.106 -> 1.107 --- Log message: Namespacify --- Diffs of the changes: Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.106 llvm/lib/AsmParser/llvmAsmParser.y:1.107 --- llvm/lib/AsmParser/llvmAsmParser.y:1.106 Tue Apr 22 13:02:52 2003 +++ llvm/lib/AsmParser/llvmAsmParser.y Tue Apr 22 13:42:41 2003 @@ -17,20 +17,13 @@ #include #include #include -using std::list; -using std::vector; -using std::pair; -using std::map; -using std::pair; -using std::make_pair; -using std::string; int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit int yylex(); // declaration" of xxx warnings. int yyparse(); static Module *ParserResult; -string CurFilename; +std::string CurFilename; // DEBUG_UPREFS - Define this symbol if you want to enable debugging output // relating to upreferences in the input stream. @@ -55,23 +48,24 @@ // This contains info used when building the body of a function. It is // destroyed when the function is completed. // -typedef vector ValueList; // Numbered defs -static void ResolveDefinitions(vector &LateResolvers, - vector *FutureLateResolvers = 0); +typedef std::vector ValueList; // Numbered defs +static void ResolveDefinitions(std::vector &LateResolvers, + std::vector *FutureLateResolvers = 0); static struct PerModuleInfo { Module *CurrentModule; - vector Values; // Module level numbered definitions - vector LateResolveValues; - vector Types; - map LateResolveTypes; + std::vector Values; // Module level numbered definitions + std::vector LateResolveValues; + std::vector Types; + std::map LateResolveTypes; // GlobalRefs - This maintains a mapping between 's and forward // references to global values. Global values may be referenced before they // are defined, and if so, the temporary object that they represent is held // here. This is used for forward references of ConstantPointerRefs. // - typedef map, GlobalVariable*> GlobalRefsType; + typedef std::map, GlobalVariable*> GlobalRefsType; GlobalRefsType GlobalRefs; void ModuleDone() { @@ -85,7 +79,7 @@ // resolved! // if (!GlobalRefs.empty()) { - string UndefinedReferences = "Unresolved global references exist:\n"; + std::string UndefinedReferences = "Unresolved global references exist:\n"; for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end(); I != E; ++I) { @@ -108,7 +102,8 @@ void DeclareNewGlobalValue(GlobalValue *GV, ValID D) { // Check to see if there is a forward reference to this global variable... // if there is, eliminate it and patch the reference to use the new def'n. - GlobalRefsType::iterator I = GlobalRefs.find(make_pair(GV->getType(), D)); + GlobalRefsType::iterator I = + GlobalRefs.find(std::make_pair(GV->getType(), D)); if (I != GlobalRefs.end()) { GlobalVariable *OldGV = I->second; // Get the placeholder... @@ -139,10 +134,10 @@ static struct PerFunctionInfo { Function *CurrentFunction; // Pointer to current function being created - vector Values; // Keep track of numbered definitions - vector LateResolveValues; - vector Types; - map LateResolveTypes; + std::vector Values; // Keep track of numbered definitions + std::vector LateResolveValues; + std::vector Types; + std::map LateResolveTypes; bool isDeclare; // Is this function a forward declararation? inline PerFunctionInfo() { @@ -175,7 +170,8 @@ // Code to handle definitions of all the types //===----------------------------------------------------------------------===// -static int InsertValue(Value *D, vector &ValueTab = CurMeth.Values) { +static int InsertValue(Value *D, + std::vector &ValueTab = CurMeth.Values) { if (D->hasName()) return -1; // Is this a numbered definition? // Yes, insert the value into the value table... @@ -188,7 +184,7 @@ } // TODO: FIXME when Type are not const -static void InsertType(const Type *Ty, vector &Types) { +static void InsertType(const Type *Ty, std::vector &Types) { Types.push_back(Ty); } @@ -209,7 +205,7 @@ break; } case ValID::NameVal: { // Is it a named definition? - string Name(D.Name); + std::string Name(D.Name); SymbolTable *SymTab = 0; Value *N = 0; if (inFunctionScope()) { @@ -239,20 +235,20 @@ // if (DoNotImprovise) return 0; // Do we just want a null to be returned? - map &LateResolver = inFunctionScope() ? + std::map &LateResolver = inFunctionScope() ? CurMeth.LateResolveTypes : CurModule.LateResolveTypes; - map::iterator I = LateResolver.find(D); + std::map::iterator I = LateResolver.find(D); if (I != LateResolver.end()) { return I->second; } Type *Typ = OpaqueType::get(); - LateResolver.insert(make_pair(D, Typ)); + LateResolver.insert(std::make_pair(D, Typ)); return Typ; } -static Value *lookupInSymbolTable(const Type *Ty, const string &Name) { +static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) { SymbolTable &SymTab = inFunctionScope() ? CurMeth.CurrentFunction->getSymbolTable() : CurModule.CurrentModule->getSymbolTable(); @@ -291,7 +287,7 @@ } case ValID::NameVal: { // Is it a named definition? - Value *N = lookupInSymbolTable(Ty, string(D.Name)); + Value *N = lookupInSymbolTable(Ty, std::string(D.Name)); if (N == 0) return 0; D.destroy(); // Free old strdup'd memory... @@ -392,8 +388,8 @@ // time (forward branches, phi functions for loops, etc...) resolve the // defs now... // -static void ResolveDefinitions(vector &LateResolvers, - vector *FutureLateResolvers) { +static void ResolveDefinitions(std::vector &LateResolvers, + std::vector *FutureLateResolvers) { // Loop over LateResolveDefs fixing up stuff that couldn't be resolved for (unsigned ty = 0; ty < LateResolvers.size(); ty++) { while (!LateResolvers[ty].empty()) { @@ -433,17 +429,17 @@ // refering to the number can be resolved. Do this now. // static void ResolveTypeTo(char *Name, const Type *ToTy) { - vector &Types = inFunctionScope() ? + std::vector &Types = inFunctionScope() ? CurMeth.Types : CurModule.Types; ValID D; if (Name) D = ValID::create(Name); else D = ValID::create((int)Types.size()); - map &LateResolver = inFunctionScope() ? + std::map &LateResolver = inFunctionScope() ? CurMeth.LateResolveTypes : CurModule.LateResolveTypes; - map::iterator I = LateResolver.find(D); + std::map::iterator I = LateResolver.find(D); if (I != LateResolver.end()) { ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy); LateResolver.erase(I); @@ -453,7 +449,7 @@ // ResolveTypes - At this point, all types should be resolved. Any that aren't // are errors. // -static void ResolveTypes(map &LateResolveTypes) { +static void ResolveTypes(std::map &LateResolveTypes) { if (!LateResolveTypes.empty()) { const ValID &DID = LateResolveTypes.begin()->first; @@ -476,7 +472,7 @@ static bool setValueName(Value *V, char *NameStr) { if (NameStr == 0) return false; - string Name(NameStr); // Copy string + std::string Name(NameStr); // Copy string free(NameStr); // Free old string if (V->getType() == Type::VoidTy) @@ -549,7 +545,7 @@ } -static vector > UpRefs; +static std::vector > UpRefs; static PATypeHolder HandleUpRefs(const Type *ty) { PATypeHolder Ty(ty); @@ -566,7 +562,7 @@ if (Level == 0) { // Upreference should be resolved! UR_OUT(" * Resolving upreference for " << UpRefs[i].second->getDescription() << endl; - string OldName = UpRefs[i].second->getDescription()); + std::string OldName = UpRefs[i].second->getDescription()); UpRefs[i].second->refineAbstractTypeTo(Ty); UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list... UR_OUT(" * Type '" << OldName << "' refined upreference to: " @@ -586,7 +582,7 @@ // RunVMAsmParser - Define an interface to this parser //===----------------------------------------------------------------------===// // -Module *RunVMAsmParser(const string &Filename, FILE *F) { +Module *RunVMAsmParser(const std::string &Filename, FILE *F) { llvmAsmin = F; CurFilename = Filename; llvmAsmlineno = 1; // Reset the current line number... @@ -792,12 +788,12 @@ UpRTypes : '\\' EUINT64VAL { // Type UpReference if ($2 > (uint64_t)INT64_MAX) ThrowException("Value out of range!"); OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder - UpRefs.push_back(make_pair((unsigned)$2, OT)); // Add to vector... + UpRefs.push_back(std::make_pair((unsigned)$2, OT)); // Add to vector... $$ = new PATypeHolder(OT); UR_OUT("New Upreference!\n"); } | UpRTypesV '(' ArgTypeListI ')' { // Function derived type? - vector Params; + std::vector Params; mapto($3->begin(), $3->end(), std::back_inserter(Params), std::mem_fun_ref(&PATypeHandle::get)); bool isVarArg = Params.size() && Params.back() == Type::VoidTy; @@ -812,7 +808,7 @@ delete $4; } | '{' TypeListI '}' { // Structure type? - vector Elements; + std::vector Elements; mapto($2->begin(), $2->end(), std::back_inserter(Elements), std::mem_fun_ref(&PATypeHandle::get)); @@ -820,7 +816,7 @@ delete $2; } | '{' '}' { // Empty structure type? - $$ = new PATypeHolder(StructType::get(vector())); + $$ = new PATypeHolder(StructType::get(std::vector())); } | UpRTypes '*' { // Pointer type? $$ = new PATypeHolder(HandleUpRefs(PointerType::get(*$1))); @@ -831,7 +827,7 @@ // declaration type lists // TypeListI : UpRTypes { - $$ = new list(); + $$ = new std::list(); $$->push_back(*$1); delete $1; } | TypeListI ',' UpRTypes { @@ -844,10 +840,10 @@ ($$=$1)->push_back(Type::VoidTy); } | DOTDOTDOT { - ($$ = new list())->push_back(Type::VoidTy); + ($$ = new std::list())->push_back(Type::VoidTy); } | /*empty*/ { - $$ = new list(); + $$ = new std::list(); }; // ConstVal - The various declarations that go into the constant pool. This @@ -891,7 +887,7 @@ if (NumElements != -1 && NumElements != 0) ThrowException("Type mismatch: constant sized array initialized with 0" " arguments, but has size of " + itostr(NumElements) +"!"); - $$ = ConstantArray::get(ATy, vector()); + $$ = ConstantArray::get(ATy, std::vector()); delete $1; } | Types 'c' STRINGCONSTANT { @@ -907,7 +903,7 @@ ThrowException("Can't build string constant of size " + itostr((int)(EndStr-$3)) + " when array has size " + itostr(NumElements) + "!"); - vector Vals; + std::vector Vals; if (ETy == Type::SByteTy) { for (char *C = $3; C != EndStr; ++C) Vals.push_back(ConstantSInt::get(ETy, *C)); @@ -978,7 +974,7 @@ // First check to see if the forward references value is already created! PerModuleInfo::GlobalRefsType::iterator I = - CurModule.GlobalRefs.find(make_pair(PT, $2)); + CurModule.GlobalRefs.find(std::make_pair(PT, $2)); if (I != CurModule.GlobalRefs.end()) { V = I->second; // Placeholder already exists, use it... @@ -991,7 +987,7 @@ false, GlobalValue::ExternalLinkage); // Keep track of the fact that we have a forward ref to recycle it - CurModule.GlobalRefs.insert(make_pair(make_pair(PT, $2), GV)); + CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, $2), GV)); // Must temporarily push this value into the module table... CurModule.CurrentModule->getGlobalList().push_back(GV); @@ -1044,7 +1040,7 @@ if (!IdxTy) ThrowException("Index list invalid for constant getelementptr!"); - vector IdxVec; + std::vector IdxVec; for (unsigned i = 0, e = $4->size(); i != e; ++i) if (Constant *C = dyn_cast((*$4)[i])) IdxVec.push_back(C); @@ -1072,7 +1068,7 @@ ($$ = $1)->push_back($3); } | ConstVal { - $$ = new vector(); + $$ = new std::vector(); $$->push_back($1); }; @@ -1194,7 +1190,7 @@ ArgVal : Types OptVAR_ID { if (*$1 == Type::VoidTy) ThrowException("void typed arguments are invalid!"); - $$ = new pair($1, $2); + $$ = new std::pair($1, $2); }; ArgListH : ArgListH ',' ArgVal { @@ -1203,7 +1199,7 @@ delete $3; } | ArgVal { - $$ = new vector >(); + $$ = new std::vector >(); $$->push_back(*$1); delete $1; }; @@ -1213,11 +1209,12 @@ } | ArgListH ',' DOTDOTDOT { $$ = $1; - $$->push_back(pair(new PATypeHolder(Type::VoidTy),0)); + $$->push_back(std::pair(new PATypeHolder(Type::VoidTy), 0)); } | DOTDOTDOT { - $$ = new vector >(); - $$->push_back(pair(new PATypeHolder(Type::VoidTy),0)); + $$ = new std::vector >(); + $$->push_back(std::make_pair(new PATypeHolder(Type::VoidTy), (char*)0)); } | /* empty */ { $$ = 0; @@ -1227,11 +1224,11 @@ FunctionHeaderH : TypesV FuncName '(' ArgList ')' { UnEscapeLexed($2); - string FunctionName($2); + std::string FunctionName($2); - vector ParamTypeList; + std::vector ParamTypeList; if ($4) { // If there are arguments... - for (vector >::iterator I = $4->begin(); + for (std::vector >::iterator I = $4->begin(); I != $4->end(); ++I) ParamTypeList.push_back(I->first->get()); } @@ -1279,7 +1276,7 @@ $4->pop_back(); // Delete the last entry } Function::aiterator ArgIt = Fn->abegin(); - for (vector >::iterator I = $4->begin(); + for (std::vector >::iterator I =$4->begin(); I != $4->end(); ++I, ++ArgIt) { delete I->first; // Delete the typeholder... @@ -1423,7 +1420,7 @@ cast(getVal(Type::LabelTy, $6))); $$ = S; - vector >::iterator I = $8->begin(), + std::vector >::iterator I = $8->begin(), E = $8->end(); for (; I != E; ++I) S->dest_push_back(I->first, I->second); @@ -1436,9 +1433,10 @@ if (!(PFTy = dyn_cast($2->get())) || !(Ty = dyn_cast(PFTy->getElementType()))) { // Pull out the types of all of the arguments... - vector ParamTypes; + std::vector ParamTypes; if ($5) { - for (vector::iterator I = $5->begin(), E = $5->end(); I!=E; ++I) + for (std::vector::iterator I = $5->begin(), E = $5->end(); + I != E; ++I) ParamTypes.push_back((*I)->getType()); } @@ -1460,14 +1458,14 @@ // Create the call node... if (!$5) { // Has no arguments? - $$ = new InvokeInst(V, Normal, Except, vector()); + $$ = new InvokeInst(V, Normal, Except, std::vector()); } else { // Has arguments? // Loop through FunctionType's arguments and ensure they are specified // correctly! // FunctionType::ParamTypes::const_iterator I = Ty->getParamTypes().begin(); FunctionType::ParamTypes::const_iterator E = Ty->getParamTypes().end(); - vector::iterator ArgI = $5->begin(), ArgE = $5->end(); + std::vector::iterator ArgI = $5->begin(), ArgE = $5->end(); for (; ArgI != ArgE && I != E; ++ArgI, ++I) if ((*ArgI)->getType() != *I) @@ -1490,16 +1488,16 @@ if (V == 0) ThrowException("May only switch on a constant pool value!"); - $$->push_back(make_pair(V, cast(getVal($5, $6)))); + $$->push_back(std::make_pair(V, cast(getVal($5, $6)))); } | IntType ConstValueRef ',' LABEL ValueRef { - $$ = new vector >(); + $$ = new std::vector >(); Constant *V = cast(getValNonImprovising($1, $2)); if (V == 0) ThrowException("May only switch on a constant pool value!"); - $$->push_back(make_pair(V, cast(getVal($4, $5)))); + $$->push_back(std::make_pair(V, cast(getVal($4, $5)))); }; Inst : OptAssign InstVal { @@ -1510,20 +1508,20 @@ }; PHIList : Types '[' ValueRef ',' ValueRef ']' { // Used for PHI nodes - $$ = new list >(); - $$->push_back(make_pair(getVal(*$1, $3), - cast(getVal(Type::LabelTy, $5)))); + $$ = new std::list >(); + $$->push_back(std::make_pair(getVal(*$1, $3), + cast(getVal(Type::LabelTy, $5)))); delete $1; } | PHIList ',' '[' ValueRef ',' ValueRef ']' { $$ = $1; - $1->push_back(make_pair(getVal($1->front().first->getType(), $4), - cast(getVal(Type::LabelTy, $6)))); + $1->push_back(std::make_pair(getVal($1->front().first->getType(), $4), + cast(getVal(Type::LabelTy, $6)))); }; ValueRefList : ResolvedVal { // Used for call statements, and memory insts... - $$ = new vector(); + $$ = new std::vector(); $$->push_back($1); } | ValueRefList ',' ResolvedVal { @@ -1595,9 +1593,10 @@ if (!(PFTy = dyn_cast($2->get())) || !(Ty = dyn_cast(PFTy->getElementType()))) { // Pull out the types of all of the arguments... - vector ParamTypes; + std::vector ParamTypes; if ($5) { - for (vector::iterator I = $5->begin(), E = $5->end(); I!=E; ++I) + for (std::vector::iterator I = $5->begin(), E = $5->end(); + I != E; ++I) ParamTypes.push_back((*I)->getType()); } @@ -1618,14 +1617,14 @@ ThrowException("No arguments passed to a function that " "expects arguments!"); - $$ = new CallInst(V, vector()); + $$ = new CallInst(V, std::vector()); } else { // Has arguments? // Loop through FunctionType's arguments and ensure they are specified // correctly! // FunctionType::ParamTypes::const_iterator I = Ty->getParamTypes().begin(); FunctionType::ParamTypes::const_iterator E = Ty->getParamTypes().end(); - vector::iterator ArgI = $5->begin(), ArgE = $5->end(); + std::vector::iterator ArgI = $5->begin(), ArgE = $5->end(); for (; ArgI != ArgE && I != E; ++ArgI, ++I) if ((*ArgI)->getType() != *I) @@ -1648,7 +1647,7 @@ IndexList : ',' ValueRefList { $$ = $2; } | /* empty */ { - $$ = new vector(); + $$ = new std::vector(); }; MemoryInst : MALLOC Types { @@ -1744,13 +1743,14 @@ %% int yyerror(const char *ErrorMsg) { - string where = string((CurFilename == "-")? string("") : CurFilename) + std::string where + = std::string((CurFilename == "-") ? std::string("") : CurFilename) + ":" + utostr((unsigned) llvmAsmlineno) + ": "; - string errMsg = string(ErrorMsg) + string("\n") + where + " while reading "; + std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading "; if (yychar == YYEMPTY) errMsg += "end-of-file."; else - errMsg += "token: '" + string(llvmAsmtext, llvmAsmleng) + "'"; + errMsg += "token: '" + std::string(llvmAsmtext, llvmAsmleng) + "'"; ThrowException(errMsg); return 0; } From lattner at cs.uiuc.edu Tue Apr 22 13:44:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Apr 22 13:44:01 2003 Subject: [llvm-commits] CVS: llvm/test/Feature/README.txt Message-ID: <200304221843.NAA07890@apoc.cs.uiuc.edu> Changes in directory llvm/test/Feature: README.txt updated: 1.1 -> 1.2 --- Log message: ADd newline to end of file --- Diffs of the changes: Index: llvm/test/Feature/README.txt diff -u llvm/test/Feature/README.txt:1.1 llvm/test/Feature/README.txt:1.2 --- llvm/test/Feature/README.txt:1.1 Wed Jan 23 13:42:36 2002 +++ llvm/test/Feature/README.txt Tue Apr 22 13:43:23 2003 @@ -2,4 +2,5 @@ It is designed to make sure that the major components of LLVM support all of the features of LLVM, for very small examples. Entire programs should not go here. -Regression tests for individual bug fixes should go into the test/Regression dir. \ No newline at end of file +Regression tests for individual bug fixes should go into the test/Regression dir. + From lattner at cs.uiuc.edu Tue Apr 22 14:07:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Apr 22 14:07:01 2003 Subject: [llvm-commits] CVS: llvm/test/Feature/properties.ll Message-ID: <200304221906.OAA08466@apoc.cs.uiuc.edu> Changes in directory llvm/test/Feature: properties.ll added (r1.1) --- Log message: Add testcase for target information --- Diffs of the changes: Index: llvm/test/Feature/properties.ll diff -c /dev/null llvm/test/Feature/properties.ll:1.1 *** /dev/null Tue Apr 22 14:06:58 2003 --- llvm/test/Feature/properties.ll Tue Apr 22 14:06:48 2003 *************** *** 0 **** --- 1,4 ---- + + target endian = little + target pointersize = 32 + From lattner at cs.uiuc.edu Tue Apr 22 14:08:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Apr 22 14:08:01 2003 Subject: [llvm-commits] CVS: llvm/lib/AsmParser/Lexer.l llvmAsmParser.y Message-ID: <200304221907.OAA08482@apoc.cs.uiuc.edu> Changes in directory llvm/lib/AsmParser: Lexer.l updated: 1.31 -> 1.32 llvmAsmParser.y updated: 1.107 -> 1.108 --- Log message: Allow information about the target to be specified in the .ll file --- Diffs of the changes: Index: llvm/lib/AsmParser/Lexer.l diff -u llvm/lib/AsmParser/Lexer.l:1.31 llvm/lib/AsmParser/Lexer.l:1.32 --- llvm/lib/AsmParser/Lexer.l:1.31 Thu Apr 17 17:17:32 2003 +++ llvm/lib/AsmParser/Lexer.l Tue Apr 22 14:07:06 2003 @@ -19,6 +19,7 @@ %{ #include "ParserInternals.h" +#include "llvm/Module.h" #include #include "llvmAsmParser.h" #include @@ -176,6 +177,11 @@ to { return TO; } except { return EXCEPT; } not { return NOT; } /* Deprecated, turned into XOR */ +target { return TARGET; } +endian { return ENDIAN; } +pointersize { return POINTERSIZE; } +little { return LITTLE; } +big { return BIG; } void { llvmAsmlval.PrimType = Type::VoidTy ; return VOID; } bool { llvmAsmlval.PrimType = Type::BoolTy ; return BOOL; } Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.107 llvm/lib/AsmParser/llvmAsmParser.y:1.108 --- llvm/lib/AsmParser/llvmAsmParser.y:1.107 Tue Apr 22 13:42:41 2003 +++ llvm/lib/AsmParser/llvmAsmParser.y Tue Apr 22 14:07:06 2003 @@ -635,6 +635,7 @@ Instruction::TermOps TermOpVal; Instruction::MemoryOps MemOpVal; Instruction::OtherOps OtherOpVal; + Module::Endianness Endianness; } %type Module FunctionList @@ -653,6 +654,7 @@ %type JumpTable %type GlobalType // GLOBAL or CONSTANT? %type OptLinkage +%type BigOrLittle // ValueRef - Unresolved reference to a definition or BB %type ValueRef ConstValueRef SymbolicValueRef @@ -683,7 +685,7 @@ %token IMPLEMENTATION TRUE FALSE BEGINTOK ENDTOK DECLARE GLOBAL CONSTANT %token TO EXCEPT DOTDOTDOT NULL_TOK CONST INTERNAL LINKONCE APPENDING -%token OPAQUE NOT EXTERNAL +%token OPAQUE NOT EXTERNAL TARGET ENDIAN POINTERSIZE LITTLE BIG // Basic Block Terminating Operators %token RET BR SWITCH @@ -1177,7 +1179,26 @@ } delete $5; } + | ConstPool TARGET TargetDefinition { + } | /* empty: end of list */ { + }; + + + +BigOrLittle : BIG { $$ = Module::BigEndian; }; +BigOrLittle : LITTLE { $$ = Module::LittleEndian; }; + +TargetDefinition : ENDIAN '=' BigOrLittle { + CurModule.CurrentModule->setEndianness($3); + } + | POINTERSIZE '=' EUINT64VAL { + if ($3 == 32) + CurModule.CurrentModule->setPointerSize(Module::Pointer32); + else if ($3 == 64) + CurModule.CurrentModule->setPointerSize(Module::Pointer64); + else + ThrowException("Invalid pointer size: '" + utostr($3) + "'!"); }; From lattner at cs.uiuc.edu Tue Apr 22 14:08:03 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Apr 22 14:08:03 2003 Subject: [llvm-commits] CVS: llvm/lib/VMCore/AsmWriter.cpp Message-ID: <200304221907.OAA08492@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: AsmWriter.cpp updated: 1.83 -> 1.84 --- Log message: Emit information about target --- Diffs of the changes: Index: llvm/lib/VMCore/AsmWriter.cpp diff -u llvm/lib/VMCore/AsmWriter.cpp:1.83 llvm/lib/VMCore/AsmWriter.cpp:1.84 --- llvm/lib/VMCore/AsmWriter.cpp:1.83 Wed Apr 16 15:28:45 2003 +++ llvm/lib/VMCore/AsmWriter.cpp Tue Apr 22 14:07:19 2003 @@ -519,6 +519,9 @@ void AssemblyWriter::printModule(const Module *M) { + Out << "target endian = " << (M->isLittleEndian() ? "little" : "big") << "\n"; + Out << "target pointersize = " << (M->has32BitPointers() ? 32 : 64) << "\n"; + // Loop over the symbol table, emitting all named constants... printSymbolTable(M->getSymbolTable()); From lattner at cs.uiuc.edu Tue Apr 22 14:14:00 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Apr 22 14:14:00 2003 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Utils/Linker.cpp Message-ID: <200304221913.OAA08928@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Utils: Linker.cpp updated: 1.40 -> 1.41 --- Log message: Add warning when linking modules with disagreeing target properties --- Diffs of the changes: Index: llvm/lib/Transforms/Utils/Linker.cpp diff -u llvm/lib/Transforms/Utils/Linker.cpp:1.40 llvm/lib/Transforms/Utils/Linker.cpp:1.41 --- llvm/lib/Transforms/Utils/Linker.cpp:1.40 Mon Apr 21 16:15:04 2003 +++ llvm/lib/Transforms/Utils/Linker.cpp Tue Apr 22 14:13:20 2003 @@ -469,6 +469,10 @@ // shouldn't be relied on to be consistent. // bool LinkModules(Module *Dest, const Module *Src, std::string *ErrorMsg) { + if (Dest->getEndianness() != Src->getEndianness()) + std::cerr << "WARNING: Linking two modules of different endianness!\n"; + if (Dest->getPointerSize() != Src->getPointerSize()) + std::cerr << "WARNING: Linking two modules of different pointer size!\n"; // LinkTypes - Go through the symbol table of the Src module and see if any // types are named in the src module that are not named in the Dst module. From lattner at cs.uiuc.edu Tue Apr 22 14:33:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Apr 22 14:33:01 2003 Subject: [llvm-commits] CVS: llvm/utils/vim/llvm.vim Message-ID: <200304221932.OAA10832@apoc.cs.uiuc.edu> Changes in directory llvm/utils/vim: llvm.vim updated: 1.2 -> 1.3 --- Log message: Update to add new keywords --- Diffs of the changes: Index: llvm/utils/vim/llvm.vim diff -u llvm/utils/vim/llvm.vim:1.2 llvm/utils/vim/llvm.vim:1.3 --- llvm/utils/vim/llvm.vim:1.2 Wed Apr 16 15:25:57 2003 +++ llvm/utils/vim/llvm.vim Tue Apr 22 14:31:53 2003 @@ -1,7 +1,7 @@ " Vim syntax file " Language: llvm -" Maintainer: Nick Hildenbrandt -" Updated: 2002-10-07 +" Maintainer: ? +" Updated: 2003-04-22 if version < 600 syntax clear @@ -28,7 +28,8 @@ syn keyword llvmStatement declare global constant const syn keyword llvmStatement internal uninitialized external implementation syn keyword llvmStatement linkonce appending -syn keyword llvmStatement null to except not +syn keyword llvmStatement null to except not target endian pointersize +syn keyword llvmStatement big little "syn match llvmFunction /%[a-zA-Z\$._\-][a-zA-Z\$._\-0-9]*/ syn match llvmNumber /\<\d\+\>/ From lattner at cs.uiuc.edu Tue Apr 22 14:33:03 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Apr 22 14:33:03 2003 Subject: [llvm-commits] CVS: llvm/utils/emacs/llvm-mode.el Message-ID: <200304221932.OAA10839@apoc.cs.uiuc.edu> Changes in directory llvm/utils/emacs: llvm-mode.el updated: 1.2 -> 1.3 --- Log message: Update to add new keywords --- Diffs of the changes: Index: llvm/utils/emacs/llvm-mode.el diff -u llvm/utils/emacs/llvm-mode.el:1.2 llvm/utils/emacs/llvm-mode.el:1.3 --- llvm/utils/emacs/llvm-mode.el:1.2 Wed Apr 16 15:26:11 2003 +++ llvm/utils/emacs/llvm-mode.el Tue Apr 22 14:31:55 2003 @@ -2,7 +2,7 @@ ;; Description: ;; Major mode for the LLVM assembler language. ;; Updated: -;; Oct 8, 2002 +;; Apr 22, 2003 ;; Code: ;; Create mode-specific tables. @@ -28,7 +28,7 @@ ;; Hex constants '("0x[0-9A-Fa-f]+" . font-lock-preprocessor-face) ;; Keywords - '("begin\\|end\\|true\\|false\\|declare\\|global\\|constant\\|const\\|internal\\|linkonce\\|appending\\|uninitialized\\|implementation\\|\\.\\.\\.\\|null\\|to\\|except\\|not" . font-lock-keyword-face) + '("begin\\|end\\|true\\|false\\|declare\\|global\\|constant\\|const\\|internal\\|linkonce\\|appending\\|uninitialized\\|implementation\\|\\.\\.\\.\\|null\\|to\\|except\\|not\\|target\\|endian\\|little\\|big\\|pointersize" . font-lock-keyword-face) ;; Types '("void\\|bool\\|sbyte\\|ubyte\\|u?short\\|u?int\\|u?long\\|float\\|double\\|type\\|label\\|opaque" . font-lock-type-face) ;; Arithmetic and Logical Operators From lattner at cs.uiuc.edu Tue Apr 22 15:21:00 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Apr 22 15:21:00 2003 Subject: [llvm-commits] CVS: llvm/lib/CWriter/Writer.cpp Message-ID: <200304222020.PAA22144@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CWriter: Writer.cpp updated: 1.77 -> 1.78 --- Log message: Add support for the switch instruction to the CWriter --- Diffs of the changes: Index: llvm/lib/CWriter/Writer.cpp diff -u llvm/lib/CWriter/Writer.cpp:1.77 llvm/lib/CWriter/Writer.cpp:1.78 --- llvm/lib/CWriter/Writer.cpp:1.77 Wed Feb 12 14:45:00 2003 +++ llvm/lib/CWriter/Writer.cpp Tue Apr 22 15:19:52 2003 @@ -7,11 +7,7 @@ #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" #include "llvm/Module.h" -#include "llvm/iMemory.h" -#include "llvm/iTerminators.h" -#include "llvm/iPHINode.h" -#include "llvm/iOther.h" -#include "llvm/iOperators.h" +#include "llvm/Instructions.h" #include "llvm/Pass.h" #include "llvm/SymbolTable.h" #include "llvm/SlotCalculator.h" @@ -108,6 +104,7 @@ void visitReturnInst(ReturnInst &I); void visitBranchInst(BranchInst &I); + void visitSwitchInst(SwitchInst &I); void visitPHINode(PHINode &I) {} void visitBinaryOperator(Instruction &I); @@ -156,8 +153,8 @@ string CWriter::getValueName(const Value *V) { if (V->hasName()) { // Print out the label if it exists... if (isa(V) && // Do not mangle globals... - cast(V)->hasExternalLinkage())// && // Unless it's internal or - //!MangledGlobals.count(V)) // Unless the name would collide if we don't + cast(V)->hasExternalLinkage()) // Unless it's internal or + //!MangledGlobals.count(V)) // Unless the name would collide if we don't return makeNameProper(V->getName()); return "l" + utostr(V->getType()->getUniqueID()) + "_" + @@ -866,6 +863,25 @@ } Out << ";\n"; } + +void CWriter::visitSwitchInst(SwitchInst &SI) { + Out << " switch ("; + writeOperand(SI.getOperand(0)); + Out << ") {\n default: goto "; + writeOperand(SI.getDefaultDest()); + Out << ";\n"; + for (unsigned i = 2, e = SI.getNumOperands(); i != e; i += 2) { + Out << " case "; + writeOperand(SI.getOperand(i)); + Out << ":\n"; + BasicBlock *Succ = cast(SI.getOperand(i+1)); + printBranchToBlock(SI.getParent(), Succ, 2); + if (Succ == SI.getParent()->getNext()) + Out << " break;\n"; + } + Out << " }\n"; +} + static bool isGotoCodeNeccessary(BasicBlock *From, BasicBlock *To) { // If PHI nodes need copies, we need the copy code... From brukman at cs.uiuc.edu Tue Apr 22 15:21:03 2003 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Tue Apr 22 15:21:03 2003 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86RegisterInfo.def Message-ID: <200304222020.PAA22158@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86RegisterInfo.def updated: 1.12 -> 1.13 --- Log message: It's "necessary"... --- Diffs of the changes: Index: llvm/lib/Target/X86/X86RegisterInfo.def diff -u llvm/lib/Target/X86/X86RegisterInfo.def:1.12 llvm/lib/Target/X86/X86RegisterInfo.def:1.13 --- llvm/lib/Target/X86/X86RegisterInfo.def:1.12 Sun Jan 12 18:50:46 2003 +++ llvm/lib/Target/X86/X86RegisterInfo.def Tue Apr 22 15:20:11 2003 @@ -45,7 +45,7 @@ // #3: Register Flags - A bitfield of flags or'd together from the // MRegisterInfo.h file. // #4: Target Specific Flags - Another bitfield containing X86 specific flags -// as neccesary. +// as necessary. // #5: Alias set for registers aliased to this register (sets defined below). From lattner at cs.uiuc.edu Tue Apr 22 15:21:04 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Apr 22 15:21:04 2003 Subject: [llvm-commits] CVS: llvm/lib/AsmParser/Lexer.l Message-ID: <200304222020.PAA22169@apoc.cs.uiuc.edu> Changes in directory llvm/lib/AsmParser: Lexer.l updated: 1.32 -> 1.33 --- Log message: Use a union to cast int to fp --- Diffs of the changes: Index: llvm/lib/AsmParser/Lexer.l diff -u llvm/lib/AsmParser/Lexer.l:1.32 llvm/lib/AsmParser/Lexer.l:1.33 --- llvm/lib/AsmParser/Lexer.l:1.32 Tue Apr 22 14:07:06 2003 +++ llvm/lib/AsmParser/Lexer.l Tue Apr 22 15:20:28 2003 @@ -73,15 +73,17 @@ // point representation of it. // static double HexToFP(const char *Buffer) { - uint64_t Result = HexIntToVal(Buffer); - - assert(sizeof(double) == sizeof(Result) && - "Data sizes incompatible on this target!"); // Behave nicely in the face of C TBAA rules... see: // http://www.nullstone.com/htmls/category/aliastyp.htm - // - char *ProxyPointer = (char*)&Result; - return *(double*)ProxyPointer; // Cast Hex constant to double + union { + uint64_t UI; + double FP; + } UIntToFP; + UIntToFP.UI = HexIntToVal(Buffer); + + assert(sizeof(double) == sizeof(uint64_t) && + "Data sizes incompatible on this target!"); + return UIntToFP.FP; // Cast Hex constant to double } From lattner at cs.uiuc.edu Tue Apr 22 15:27:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Apr 22 15:27:01 2003 Subject: [llvm-commits] CVS: llvm/test/Programs/SingleSource/UnitTests/2003-04-22-Switch.c Message-ID: <200304222026.PAA22499@apoc.cs.uiuc.edu> Changes in directory llvm/test/Programs/SingleSource/UnitTests: 2003-04-22-Switch.c added (r1.1) --- Log message: Add new testcase for switch statement/instruction --- Diffs of the changes: Index: llvm/test/Programs/SingleSource/UnitTests/2003-04-22-Switch.c diff -c /dev/null llvm/test/Programs/SingleSource/UnitTests/2003-04-22-Switch.c:1.1 *** /dev/null Tue Apr 22 15:26:08 2003 --- llvm/test/Programs/SingleSource/UnitTests/2003-04-22-Switch.c Tue Apr 22 15:25:58 2003 *************** *** 0 **** --- 1,22 ---- + + #include + + static void func(unsigned i) { + switch (i) { + case 8: printf("C\n"); /* fall through. */ + case 0: + case 3: + case 2: printf("A\n"); break; + case 1: + case 7: + case 9: printf("B\n"); break; + default: printf("D\n"); + } + } + + + void main() { + unsigned i; + for (i = 0; i < 10; ++i) + func(i); + } From lattner at cs.uiuc.edu Tue Apr 22 15:35:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Apr 22 15:35:01 2003 Subject: [llvm-commits] CVS: llvm/tools/lli/Interpreter/Execution.cpp Message-ID: <200304222034.PAA22958@apoc.cs.uiuc.edu> Changes in directory llvm/tools/lli/Interpreter: Execution.cpp updated: 1.77 -> 1.78 --- Log message: Add support to LLI for switch instruction --- Diffs of the changes: Index: llvm/tools/lli/Interpreter/Execution.cpp diff -u llvm/tools/lli/Interpreter/Execution.cpp:1.77 llvm/tools/lli/Interpreter/Execution.cpp:1.78 --- llvm/tools/lli/Interpreter/Execution.cpp:1.77 Mon Apr 21 17:43:32 2003 +++ llvm/tools/lli/Interpreter/Execution.cpp Tue Apr 22 15:34:47 2003 @@ -635,6 +635,27 @@ SF.CurInst = SF.CurBB->begin(); // Update new instruction ptr... } +static void executeSwitch(SwitchInst &I, ExecutionContext &SF) { + GenericValue CondVal = getOperandValue(I.getOperand(0), SF); + const Type *ElTy = I.getOperand(0)->getType(); + SF.PrevBB = SF.CurBB; // Update PrevBB so that PHI nodes work... + BasicBlock *Dest = 0; + + // Check to see if any of the cases match... + for (unsigned i = 2, e = I.getNumOperands(); i != e; i += 2) { + if (executeSetEQInst(CondVal, + getOperandValue(I.getOperand(i), SF),ElTy,SF).BoolVal){ + Dest = cast(I.getOperand(i+1)); + break; + } + } + + if (!Dest) Dest = I.getDefaultDest(); // No cases matched: use default + SF.CurBB = Dest; // Update CurBB to branch destination + SF.CurInst = SF.CurBB->begin(); // Update new instruction ptr... +} + + //===----------------------------------------------------------------------===// // Memory Instruction Implementations //===----------------------------------------------------------------------===// @@ -1106,6 +1127,7 @@ // Terminators case Instruction::Ret: executeRetInst (cast(I), SF); break; case Instruction::Br: executeBrInst (cast(I), SF); break; + case Instruction::Switch: executeSwitch (cast(I), SF); break; // Memory Instructions case Instruction::Alloca: case Instruction::Malloc: executeAllocInst((AllocationInst&)I, SF); break; From lattner at cs.uiuc.edu Tue Apr 22 15:38:05 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Apr 22 15:38:05 2003 Subject: [llvm-commits] CVS: llvm/tools/lli/Interpreter/Execution.cpp Message-ID: <200304222037.PAA23062@apoc.cs.uiuc.edu> Changes in directory llvm/tools/lli/Interpreter: Execution.cpp updated: 1.78 -> 1.79 --- Log message: Get rid of extraneous arguments to implementation functions --- Diffs of the changes: Index: llvm/tools/lli/Interpreter/Execution.cpp diff -u llvm/tools/lli/Interpreter/Execution.cpp:1.78 llvm/tools/lli/Interpreter/Execution.cpp:1.79 --- llvm/tools/lli/Interpreter/Execution.cpp:1.78 Tue Apr 22 15:34:47 2003 +++ llvm/tools/lli/Interpreter/Execution.cpp Tue Apr 22 15:37:39 2003 @@ -93,7 +93,7 @@ static GenericValue executeCastOperation(Value *Src, const Type *DestTy, ExecutionContext &SF); static GenericValue executeAddInst(GenericValue Src1, GenericValue Src2, - const Type *Ty, ExecutionContext &SF); + const Type *Ty); static GenericValue getOperandValue(Value *V, ExecutionContext &SF) { @@ -107,7 +107,7 @@ case Instruction::Add: return executeAddInst(getOperandValue(CE->getOperand(0), SF), getOperandValue(CE->getOperand(1), SF), - CE->getType(), SF); + CE->getType()); default: cerr << "Unhandled ConstantExpr: " << CE << "\n"; abort(); @@ -177,7 +177,7 @@ case Type::TY##TyID: Dest.TY##Val = Src1.TY##Val OP Src2.TY##Val; break static GenericValue executeAddInst(GenericValue Src1, GenericValue Src2, - const Type *Ty, ExecutionContext &SF) { + const Type *Ty) { GenericValue Dest; switch (Ty->getPrimitiveID()) { IMPLEMENT_BINARY_OPERATOR(+, UByte); @@ -198,7 +198,7 @@ } static GenericValue executeSubInst(GenericValue Src1, GenericValue Src2, - const Type *Ty, ExecutionContext &SF) { + const Type *Ty) { GenericValue Dest; switch (Ty->getPrimitiveID()) { IMPLEMENT_BINARY_OPERATOR(-, UByte); @@ -219,7 +219,7 @@ } static GenericValue executeMulInst(GenericValue Src1, GenericValue Src2, - const Type *Ty, ExecutionContext &SF) { + const Type *Ty) { GenericValue Dest; switch (Ty->getPrimitiveID()) { IMPLEMENT_BINARY_OPERATOR(*, UByte); @@ -240,7 +240,7 @@ } static GenericValue executeDivInst(GenericValue Src1, GenericValue Src2, - const Type *Ty, ExecutionContext &SF) { + const Type *Ty) { GenericValue Dest; switch (Ty->getPrimitiveID()) { IMPLEMENT_BINARY_OPERATOR(/, UByte); @@ -261,7 +261,7 @@ } static GenericValue executeRemInst(GenericValue Src1, GenericValue Src2, - const Type *Ty, ExecutionContext &SF) { + const Type *Ty) { GenericValue Dest; switch (Ty->getPrimitiveID()) { IMPLEMENT_BINARY_OPERATOR(%, UByte); @@ -286,7 +286,7 @@ } static GenericValue executeAndInst(GenericValue Src1, GenericValue Src2, - const Type *Ty, ExecutionContext &SF) { + const Type *Ty) { GenericValue Dest; switch (Ty->getPrimitiveID()) { IMPLEMENT_BINARY_OPERATOR(&, UByte); @@ -306,7 +306,7 @@ static GenericValue executeOrInst(GenericValue Src1, GenericValue Src2, - const Type *Ty, ExecutionContext &SF) { + const Type *Ty) { GenericValue Dest; switch (Ty->getPrimitiveID()) { IMPLEMENT_BINARY_OPERATOR(|, UByte); @@ -326,7 +326,7 @@ static GenericValue executeXorInst(GenericValue Src1, GenericValue Src2, - const Type *Ty, ExecutionContext &SF) { + const Type *Ty) { GenericValue Dest; switch (Ty->getPrimitiveID()) { IMPLEMENT_BINARY_OPERATOR(^, UByte); @@ -349,7 +349,7 @@ case Type::TY##TyID: Dest.BoolVal = Src1.TY##Val OP Src2.TY##Val; break static GenericValue executeSetEQInst(GenericValue Src1, GenericValue Src2, - const Type *Ty, ExecutionContext &SF) { + const Type *Ty) { GenericValue Dest; switch (Ty->getPrimitiveID()) { IMPLEMENT_SETCC(==, UByte); @@ -370,7 +370,7 @@ } static GenericValue executeSetNEInst(GenericValue Src1, GenericValue Src2, - const Type *Ty, ExecutionContext &SF) { + const Type *Ty) { GenericValue Dest; switch (Ty->getPrimitiveID()) { IMPLEMENT_SETCC(!=, UByte); @@ -392,7 +392,7 @@ } static GenericValue executeSetLEInst(GenericValue Src1, GenericValue Src2, - const Type *Ty, ExecutionContext &SF) { + const Type *Ty) { GenericValue Dest; switch (Ty->getPrimitiveID()) { IMPLEMENT_SETCC(<=, UByte); @@ -413,7 +413,7 @@ } static GenericValue executeSetGEInst(GenericValue Src1, GenericValue Src2, - const Type *Ty, ExecutionContext &SF) { + const Type *Ty) { GenericValue Dest; switch (Ty->getPrimitiveID()) { IMPLEMENT_SETCC(>=, UByte); @@ -434,7 +434,7 @@ } static GenericValue executeSetLTInst(GenericValue Src1, GenericValue Src2, - const Type *Ty, ExecutionContext &SF) { + const Type *Ty) { GenericValue Dest; switch (Ty->getPrimitiveID()) { IMPLEMENT_SETCC(<, UByte); @@ -455,7 +455,7 @@ } static GenericValue executeSetGTInst(GenericValue Src1, GenericValue Src2, - const Type *Ty, ExecutionContext &SF) { + const Type *Ty) { GenericValue Dest; switch (Ty->getPrimitiveID()) { IMPLEMENT_SETCC(>, UByte); @@ -482,20 +482,20 @@ GenericValue R; // Result switch (I.getOpcode()) { - case Instruction::Add: R = executeAddInst (Src1, Src2, Ty, SF); break; - case Instruction::Sub: R = executeSubInst (Src1, Src2, Ty, SF); break; - case Instruction::Mul: R = executeMulInst (Src1, Src2, Ty, SF); break; - case Instruction::Div: R = executeDivInst (Src1, Src2, Ty, SF); break; - case Instruction::Rem: R = executeRemInst (Src1, Src2, Ty, SF); break; - case Instruction::And: R = executeAndInst (Src1, Src2, Ty, SF); break; - case Instruction::Or: R = executeOrInst (Src1, Src2, Ty, SF); break; - case Instruction::Xor: R = executeXorInst (Src1, Src2, Ty, SF); break; - case Instruction::SetEQ: R = executeSetEQInst(Src1, Src2, Ty, SF); break; - case Instruction::SetNE: R = executeSetNEInst(Src1, Src2, Ty, SF); break; - case Instruction::SetLE: R = executeSetLEInst(Src1, Src2, Ty, SF); break; - case Instruction::SetGE: R = executeSetGEInst(Src1, Src2, Ty, SF); break; - case Instruction::SetLT: R = executeSetLTInst(Src1, Src2, Ty, SF); break; - case Instruction::SetGT: R = executeSetGTInst(Src1, Src2, Ty, SF); break; + case Instruction::Add: R = executeAddInst (Src1, Src2, Ty); break; + case Instruction::Sub: R = executeSubInst (Src1, Src2, Ty); break; + case Instruction::Mul: R = executeMulInst (Src1, Src2, Ty); break; + case Instruction::Div: R = executeDivInst (Src1, Src2, Ty); break; + case Instruction::Rem: R = executeRemInst (Src1, Src2, Ty); break; + case Instruction::And: R = executeAndInst (Src1, Src2, Ty); break; + case Instruction::Or: R = executeOrInst (Src1, Src2, Ty); break; + case Instruction::Xor: R = executeXorInst (Src1, Src2, Ty); break; + case Instruction::SetEQ: R = executeSetEQInst(Src1, Src2, Ty); break; + case Instruction::SetNE: R = executeSetNEInst(Src1, Src2, Ty); break; + case Instruction::SetLE: R = executeSetLEInst(Src1, Src2, Ty); break; + case Instruction::SetGE: R = executeSetGEInst(Src1, Src2, Ty); break; + case Instruction::SetLT: R = executeSetLTInst(Src1, Src2, Ty); break; + case Instruction::SetGT: R = executeSetGTInst(Src1, Src2, Ty); break; default: cout << "Don't know how to handle this binary operator!\n-->" << I; R = Src1; @@ -644,7 +644,7 @@ // Check to see if any of the cases match... for (unsigned i = 2, e = I.getNumOperands(); i != e; i += 2) { if (executeSetEQInst(CondVal, - getOperandValue(I.getOperand(i), SF),ElTy,SF).BoolVal){ + getOperandValue(I.getOperand(i), SF), ElTy).BoolVal) { Dest = cast(I.getOperand(i+1)); break; } From lattner at cs.uiuc.edu Tue Apr 22 16:02:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Apr 22 16:02:01 2003 Subject: [llvm-commits] CVS: llvm/test/Programs/SingleSource/fldry.c Message-ID: <200304222101.QAA26026@apoc.cs.uiuc.edu> Changes in directory llvm/test/Programs/SingleSource: fldry.c updated: 1.1 -> 1.2 --- Log message: Don't divide by zero or print out argv[0] --- Diffs of the changes: Index: llvm/test/Programs/SingleSource/fldry.c diff -u llvm/test/Programs/SingleSource/fldry.c:1.1 llvm/test/Programs/SingleSource/fldry.c:1.2 --- llvm/test/Programs/SingleSource/fldry.c:1.1 Fri Feb 14 18:30:24 2003 +++ llvm/test/Programs/SingleSource/fldry.c Tue Apr 22 16:01:47 2003 @@ -173,9 +173,8 @@ int argc; char **argv; { - printf( "%s: calculate floating dhrystones using doubles size %d\n", - argv[0], sizeof(extended) - ); + printf("calculate floating dhrystones using doubles size %d\n", + sizeof(extended)); //fflush( stdout); Proc0(); #if 0 @@ -293,6 +292,7 @@ -- Stop Timer -- *****************/ +#if 0 #ifdef CLOCK benchtime = ( clock() - starttime - nulltime )/ CLK_TCK; printf("Dhrystone(%s) time for %ld passes = %ld\n", @@ -307,8 +307,8 @@ printf("Dhrystone(%s) time for %ld passes = %ld\n", Version, (long) LOOPS, benchtime); - printf("This machine benchmarks at %ld floating dhrystones/second\n", - ((long) LOOPS) / benchtime); + printf("This machine benchmarks at %ld floating dhrystones/second\n", + ((long) LOOPS) / benchtime); #endif #ifdef TIMES times(&tms); @@ -319,7 +319,7 @@ printf("This machine benchmarks at %ld floating dhrystones/second\n", ((long) LOOPS) * HZ / benchtime); #endif - +#endif } Proc1(PtrParIn) From lattner at cs.uiuc.edu Tue Apr 22 16:03:00 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Apr 22 16:03:00 2003 Subject: [llvm-commits] CVS: llvm/test/Programs/SingleSource/dry.c Message-ID: <200304222102.QAA26187@apoc.cs.uiuc.edu> Changes in directory llvm/test/Programs/SingleSource: dry.c updated: 1.1 -> 1.2 --- Log message: Don't print times, which messes up diffs --- Diffs of the changes: Index: llvm/test/Programs/SingleSource/dry.c diff -u llvm/test/Programs/SingleSource/dry.c:1.1 llvm/test/Programs/SingleSource/dry.c:1.2 --- llvm/test/Programs/SingleSource/dry.c:1.1 Fri Feb 14 18:30:24 2003 +++ llvm/test/Programs/SingleSource/dry.c Tue Apr 22 16:02:11 2003 @@ -284,6 +284,7 @@ -- Stop Timer -- *****************/ +#if 0 #ifdef CLOCK benchtime = ( clock() - starttime - nulltime )/ CLK_TCK; printf("Dhrystone(%s) time for %ld passes = %ld\n", @@ -310,7 +311,7 @@ printf("This machine benchmarks at %ld dhrystones/second\n", ((long) LOOPS) * HZ / benchtime); #endif - +#endif } Proc1(PtrParIn) From lattner at cs.uiuc.edu Tue Apr 22 16:17:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Apr 22 16:17:01 2003 Subject: [llvm-commits] CVS: llvm/tools/lli/Interpreter/Execution.cpp Message-ID: <200304222116.QAA27368@apoc.cs.uiuc.edu> Changes in directory llvm/tools/lli/Interpreter: Execution.cpp updated: 1.79 -> 1.80 --- Log message: Implement cast to bool --- Diffs of the changes: Index: llvm/tools/lli/Interpreter/Execution.cpp diff -u llvm/tools/lli/Interpreter/Execution.cpp:1.79 llvm/tools/lli/Interpreter/Execution.cpp:1.80 --- llvm/tools/lli/Interpreter/Execution.cpp:1.79 Tue Apr 22 15:37:39 2003 +++ llvm/tools/lli/Interpreter/Execution.cpp Tue Apr 22 16:15:56 2003 @@ -979,8 +979,10 @@ IMPLEMENT_CAST_CASE(Pointer, (PointerTy)); IMPLEMENT_CAST_CASE(Float , (float)); IMPLEMENT_CAST_CASE(Double , (double)); + IMPLEMENT_CAST_CASE(Bool , (bool)); default: cout << "Unhandled dest type for cast instruction: " << Ty << "\n"; + abort(); } return Dest; From lattner at cs.uiuc.edu Tue Apr 22 16:23:00 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Apr 22 16:23:00 2003 Subject: [llvm-commits] CVS: llvm/tools/lli/Interpreter/Execution.cpp Message-ID: <200304222122.QAA27563@apoc.cs.uiuc.edu> Changes in directory llvm/tools/lli/Interpreter: Execution.cpp updated: 1.80 -> 1.81 --- Log message: Kill using declarations Kill code for invalid operations on pointers --- Diffs of the changes: Index: llvm/tools/lli/Interpreter/Execution.cpp diff -u llvm/tools/lli/Interpreter/Execution.cpp:1.80 llvm/tools/lli/Interpreter/Execution.cpp:1.81 --- llvm/tools/lli/Interpreter/Execution.cpp:1.80 Tue Apr 22 16:15:56 2003 +++ llvm/tools/lli/Interpreter/Execution.cpp Tue Apr 22 16:22:33 2003 @@ -20,9 +20,6 @@ #include // For fmod #include #include -using std::vector; -using std::cout; -using std::cerr; Interpreter *TheEE = 0; @@ -54,7 +51,7 @@ ProfileStructureFields("profilestructfields", cl::desc("Profile Structure Field Accesses")); #include -static std::map > FieldAccessCounts; +static std::map > FieldAccessCounts; #endif sigjmp_buf SignalRecoverBuffer; @@ -109,7 +106,7 @@ getOperandValue(CE->getOperand(1), SF), CE->getType()); default: - cerr << "Unhandled ConstantExpr: " << CE << "\n"; + std::cerr << "Unhandled ConstantExpr: " << CE << "\n"; abort(); return GenericValue(); } @@ -128,23 +125,23 @@ static void printOperandInfo(Value *V, ExecutionContext &SF) { if (isa(V)) { - cout << "Constant Pool Value\n"; + std::cout << "Constant Pool Value\n"; } else if (isa(V)) { - cout << "Global Value\n"; + std::cout << "Global Value\n"; } else { unsigned TyP = V->getType()->getUniqueID(); // TypePlane for value unsigned Slot = getOperandSlot(V); - cout << "Value=" << (void*)V << " TypeID=" << TyP << " Slot=" << Slot - << " Addr=" << &SF.Values[TyP][Slot] << " SF=" << &SF - << " Contents=0x"; + std::cout << "Value=" << (void*)V << " TypeID=" << TyP << " Slot=" << Slot + << " Addr=" << &SF.Values[TyP][Slot] << " SF=" << &SF + << " Contents=0x"; const unsigned char *Buf = (const unsigned char*)&SF.Values[TyP][Slot]; for (unsigned i = 0; i < sizeof(GenericValue); ++i) { unsigned char Cur = Buf[i]; - cout << ( Cur >= 160? char((Cur>>4)+'A'-10) : char((Cur>>4) + '0')) - << ((Cur&15) >= 10? char((Cur&15)+'A'-10) : char((Cur&15) + '0')); + std::cout << ( Cur >= 160?char((Cur>>4)+'A'-10):char((Cur>>4) + '0')) + << ((Cur&15) >= 10?char((Cur&15)+'A'-10):char((Cur&15) + '0')); } - cout << "\n"; + std::cout << "\n"; } } @@ -153,7 +150,7 @@ static void SetValue(Value *V, GenericValue Val, ExecutionContext &SF) { unsigned TyP = V->getType()->getUniqueID(); // TypePlane for value - //cout << "Setting value: " << &SF.Values[TyP][getOperandSlot(V)] << "\n"; + //std::cout << "Setting value: " << &SF.Values[TyP][getOperandSlot(V)]<< "\n"; SF.Values[TyP][getOperandSlot(V)] = Val; } @@ -190,9 +187,9 @@ IMPLEMENT_BINARY_OPERATOR(+, Long); IMPLEMENT_BINARY_OPERATOR(+, Float); IMPLEMENT_BINARY_OPERATOR(+, Double); - IMPLEMENT_BINARY_OPERATOR(+, Pointer); default: - cout << "Unhandled type for Add instruction: " << Ty << "\n"; + std::cout << "Unhandled type for Add instruction: " << *Ty << "\n"; + abort(); } return Dest; } @@ -211,9 +208,9 @@ IMPLEMENT_BINARY_OPERATOR(-, Long); IMPLEMENT_BINARY_OPERATOR(-, Float); IMPLEMENT_BINARY_OPERATOR(-, Double); - IMPLEMENT_BINARY_OPERATOR(-, Pointer); default: - cout << "Unhandled type for Sub instruction: " << Ty << "\n"; + std::cout << "Unhandled type for Sub instruction: " << *Ty << "\n"; + abort(); } return Dest; } @@ -232,9 +229,9 @@ IMPLEMENT_BINARY_OPERATOR(*, Long); IMPLEMENT_BINARY_OPERATOR(*, Float); IMPLEMENT_BINARY_OPERATOR(*, Double); - IMPLEMENT_BINARY_OPERATOR(*, Pointer); default: - cout << "Unhandled type for Mul instruction: " << Ty << "\n"; + std::cout << "Unhandled type for Mul instruction: " << Ty << "\n"; + abort(); } return Dest; } @@ -253,9 +250,9 @@ IMPLEMENT_BINARY_OPERATOR(/, Long); IMPLEMENT_BINARY_OPERATOR(/, Float); IMPLEMENT_BINARY_OPERATOR(/, Double); - IMPLEMENT_BINARY_OPERATOR(/, Pointer); default: - cout << "Unhandled type for Div instruction: " << Ty << "\n"; + std::cout << "Unhandled type for Div instruction: " << *Ty << "\n"; + abort(); } return Dest; } @@ -272,7 +269,6 @@ IMPLEMENT_BINARY_OPERATOR(%, Int); IMPLEMENT_BINARY_OPERATOR(%, ULong); IMPLEMENT_BINARY_OPERATOR(%, Long); - IMPLEMENT_BINARY_OPERATOR(%, Pointer); case Type::FloatTyID: Dest.FloatVal = fmod(Src1.FloatVal, Src2.FloatVal); break; @@ -280,7 +276,8 @@ Dest.DoubleVal = fmod(Src1.DoubleVal, Src2.DoubleVal); break; default: - cout << "Unhandled type for Rem instruction: " << Ty << "\n"; + std::cout << "Unhandled type for Rem instruction: " << *Ty << "\n"; + abort(); } return Dest; } @@ -297,9 +294,9 @@ IMPLEMENT_BINARY_OPERATOR(&, Int); IMPLEMENT_BINARY_OPERATOR(&, ULong); IMPLEMENT_BINARY_OPERATOR(&, Long); - IMPLEMENT_BINARY_OPERATOR(&, Pointer); default: - cout << "Unhandled type for And instruction: " << Ty << "\n"; + std::cout << "Unhandled type for And instruction: " << *Ty << "\n"; + abort(); } return Dest; } @@ -317,9 +314,9 @@ IMPLEMENT_BINARY_OPERATOR(|, Int); IMPLEMENT_BINARY_OPERATOR(|, ULong); IMPLEMENT_BINARY_OPERATOR(|, Long); - IMPLEMENT_BINARY_OPERATOR(|, Pointer); default: - cout << "Unhandled type for Or instruction: " << Ty << "\n"; + std::cout << "Unhandled type for Or instruction: " << *Ty << "\n"; + abort(); } return Dest; } @@ -337,9 +334,9 @@ IMPLEMENT_BINARY_OPERATOR(^, Int); IMPLEMENT_BINARY_OPERATOR(^, ULong); IMPLEMENT_BINARY_OPERATOR(^, Long); - IMPLEMENT_BINARY_OPERATOR(^, Pointer); default: - cout << "Unhandled type for Xor instruction: " << Ty << "\n"; + std::cout << "Unhandled type for Xor instruction: " << *Ty << "\n"; + abort(); } return Dest; } @@ -364,7 +361,8 @@ IMPLEMENT_SETCC(==, Double); IMPLEMENT_SETCC(==, Pointer); default: - cout << "Unhandled type for SetEQ instruction: " << Ty << "\n"; + std::cout << "Unhandled type for SetEQ instruction: " << *Ty << "\n"; + abort(); } return Dest; } @@ -386,7 +384,8 @@ IMPLEMENT_SETCC(!=, Pointer); default: - cout << "Unhandled type for SetNE instruction: " << Ty << "\n"; + std::cout << "Unhandled type for SetNE instruction: " << *Ty << "\n"; + abort(); } return Dest; } @@ -407,7 +406,8 @@ IMPLEMENT_SETCC(<=, Double); IMPLEMENT_SETCC(<=, Pointer); default: - cout << "Unhandled type for SetLE instruction: " << Ty << "\n"; + std::cout << "Unhandled type for SetLE instruction: " << Ty << "\n"; + abort(); } return Dest; } @@ -428,7 +428,8 @@ IMPLEMENT_SETCC(>=, Double); IMPLEMENT_SETCC(>=, Pointer); default: - cout << "Unhandled type for SetGE instruction: " << Ty << "\n"; + std::cout << "Unhandled type for SetGE instruction: " << *Ty << "\n"; + abort(); } return Dest; } @@ -449,7 +450,8 @@ IMPLEMENT_SETCC(<, Double); IMPLEMENT_SETCC(<, Pointer); default: - cout << "Unhandled type for SetLT instruction: " << Ty << "\n"; + std::cout << "Unhandled type for SetLT instruction: " << *Ty << "\n"; + abort(); } return Dest; } @@ -470,7 +472,8 @@ IMPLEMENT_SETCC(>, Double); IMPLEMENT_SETCC(>, Pointer); default: - cout << "Unhandled type for SetGT instruction: " << Ty << "\n"; + std::cout << "Unhandled type for SetGT instruction: " << *Ty << "\n"; + abort(); } return Dest; } @@ -497,8 +500,8 @@ case Instruction::SetLT: R = executeSetLTInst(Src1, Src2, Ty); break; case Instruction::SetGT: R = executeSetGTInst(Src1, Src2, Ty); break; default: - cout << "Don't know how to handle this binary operator!\n-->" << I; - R = Src1; + std::cout << "Don't know how to handle this binary operator!\n-->" << I; + abort(); } SetValue(&I, R, SF); @@ -513,10 +516,10 @@ // Print out structure field accounting information... if (!FieldAccessCounts.empty()) { CW << "Profile Field Access Counts:\n"; - std::map >::iterator + std::map >::iterator I = FieldAccessCounts.begin(), E = FieldAccessCounts.end(); for (; I != E; ++I) { - vector &OfC = I->second; + std::vector &OfC = I->second; CW << " '" << (Value*)I->first << "'\t- Sum="; unsigned Sum = 0; @@ -533,9 +536,9 @@ CW << "\n"; CW << "Profile Field Access Percentages:\n"; - cout.precision(3); + std::cout.precision(3); for (I = FieldAccessCounts.begin(); I != E; ++I) { - vector &OfC = I->second; + std::vector &OfC = I->second; unsigned Sum = 0; for (unsigned i = 0; i < OfC.size(); ++i) Sum += OfC[i]; @@ -556,9 +559,9 @@ void Interpreter::exitCalled(GenericValue GV) { if (!QuietMode) { - cout << "Program returned "; + std::cout << "Program returned "; print(Type::IntTy, GV); - cout << " via 'void exit(int)'\n"; + std::cout << " via 'void exit(int)'\n"; } ExitCode = GV.SByteVal; @@ -588,7 +591,7 @@ CW << "Function " << M->getType() << " \"" << M->getName() << "\" returned "; print(RetTy, Result); - cout << "\n"; + std::cout << "\n"; } if (RetTy->isIntegral()) @@ -616,7 +619,7 @@ CW << "Function " << M->getType() << " \"" << M->getName() << "\" returned "; print(RetTy, Result); - cout << "\n"; + std::cout << "\n"; } } @@ -709,7 +712,7 @@ #ifdef PROFILE_STRUCTURE_FIELDS if (ProfileStructureFields) { // Do accounting for this field... - vector &OfC = FieldAccessCounts[STy]; + std::vector &OfC = FieldAccessCounts[STy]; if (OfC.size() == 0) OfC.resize(STy->getElementTypes().size()); OfC[Index]++; } @@ -724,9 +727,9 @@ unsigned Idx = getOperandValue(*I, SF).LongVal; if (const ArrayType *AT = dyn_cast(ST)) if (Idx >= AT->getNumElements() && ArrayChecksEnabled) { - cerr << "Out of range memory access to element #" << Idx - << " of a " << AT->getNumElements() << " element array." - << " Subscript #" << *I << "\n"; + std::cerr << "Out of range memory access to element #" << Idx + << " of a " << AT->getNumElements() << " element array." + << " Subscript #" << *I << "\n"; // Get outta here!!! siglongjmp(SignalRecoverBuffer, SIGTRAP); } @@ -781,7 +784,8 @@ ((uint64_t)Ptr->Untyped[7] << 56); break; default: - cout << "Cannot load value of type " << I.getType() << "!\n"; + std::cout << "Cannot load value of type " << *I.getType() << "!\n"; + abort(); } } else { switch (I.getType()->getPrimitiveID()) { @@ -812,7 +816,8 @@ ((uint64_t)Ptr->Untyped[0] << 56); break; default: - cout << "Cannot load value of type " << I.getType() << "!\n"; + std::cout << "Cannot load value of type " << *I.getType() << "!\n"; + abort(); } } @@ -834,7 +839,7 @@ void Interpreter::executeCallInst(CallInst &I, ExecutionContext &SF) { ECStack.back().Caller = &I; - vector ArgVals; + std::vector ArgVals; ArgVals.reserve(I.getNumOperands()-1); for (unsigned i = 1; i < I.getNumOperands(); ++i) { ArgVals.push_back(getOperandValue(I.getOperand(i), SF)); @@ -901,9 +906,8 @@ IMPLEMENT_SHIFT(<<, Int); IMPLEMENT_SHIFT(<<, ULong); IMPLEMENT_SHIFT(<<, Long); - IMPLEMENT_SHIFT(<<, Pointer); default: - cout << "Unhandled type for Shl instruction: " << Ty << "\n"; + std::cout << "Unhandled type for Shl instruction: " << *Ty << "\n"; } SetValue(&I, Dest, SF); } @@ -923,9 +927,9 @@ IMPLEMENT_SHIFT(>>, Int); IMPLEMENT_SHIFT(>>, ULong); IMPLEMENT_SHIFT(>>, Long); - IMPLEMENT_SHIFT(>>, Pointer); default: - cout << "Unhandled type for Shr instruction: " << Ty << "\n"; + std::cout << "Unhandled type for Shr instruction: " << *Ty << "\n"; + abort(); } SetValue(&I, Dest, SF); } @@ -952,8 +956,8 @@ IMPLEMENT_CAST(DESTTY, DESTCTY, Double) #define IMPLEMENT_CAST_CASE_END() \ - default: cout << "Unhandled cast: " << SrcTy << " to " << Ty << "\n"; \ - break; \ + default: std::cout << "Unhandled cast: " << SrcTy << " to " << Ty << "\n"; \ + abort(); \ } \ break @@ -981,7 +985,7 @@ IMPLEMENT_CAST_CASE(Double , (double)); IMPLEMENT_CAST_CASE(Bool , (bool)); default: - cout << "Unhandled dest type for cast instruction: " << Ty << "\n"; + std::cout << "Unhandled dest type for cast instruction: " << *Ty << "\n"; abort(); } @@ -1022,7 +1026,8 @@ //===----------------------------------------------------------------------===// // callMethod - Execute the specified function... // -void Interpreter::callMethod(Function *M, const vector &ArgVals) { +void Interpreter::callMethod(Function *M, + const std::vector &ArgVals) { assert((ECStack.empty() || ECStack.back().Caller == 0 || ECStack.back().Caller->getNumOperands()-1 == ArgVals.size()) && "Incorrect number of arguments passed into function call!"); @@ -1043,7 +1048,7 @@ CW << "Function " << M->getType() << " \"" << M->getName() << "\" returned "; print(RetTy, Result); - cout << "\n"; + std::cout << "\n"; if (RetTy->isIntegral()) ExitCode = Result.IntVal; // Capture the exit code of the program @@ -1108,14 +1113,14 @@ if (int SigNo = sigsetjmp(SignalRecoverBuffer, 1)) { --SF.CurInst; // Back up to erroring instruction if (SigNo != SIGINT) { - cout << "EXCEPTION OCCURRED [" << strsignal(SigNo) << "]:\n"; + std::cout << "EXCEPTION OCCURRED [" << strsignal(SigNo) << "]:\n"; printStackTrace(); // If -abort-on-exception was specified, terminate LLI instead of trying // to debug it. // if (AbortOnExceptions) exit(1); } else if (SigNo == SIGINT) { - cout << "CTRL-C Detected, execution halted.\n"; + std::cout << "CTRL-C Detected, execution halted.\n"; } InInstruction = false; return true; @@ -1146,7 +1151,8 @@ case Instruction::Shr: executeShrInst (cast(I), SF); break; case Instruction::Cast: executeCastInst (cast (I), SF); break; default: - cout << "Don't know how to execute this instruction!\n-->" << I; + std::cout << "Don't know how to execute this instruction!\n-->" << I; + abort(); } } InInstruction = false; @@ -1162,7 +1168,7 @@ void Interpreter::stepInstruction() { // Do the 'step' command if (ECStack.empty()) { - cout << "Error: no program running, cannot step!\n"; + std::cout << "Error: no program running, cannot step!\n"; return; } @@ -1176,7 +1182,7 @@ // --- UI Stuff... void Interpreter::nextInstruction() { // Do the 'next' command if (ECStack.empty()) { - cout << "Error: no program running, cannot 'next'!\n"; + std::cout << "Error: no program running, cannot 'next'!\n"; return; } @@ -1187,7 +1193,7 @@ // Step into the function... if (executeInstruction()) { // Hit a breakpoint, print current instruction, then return to user... - cout << "Breakpoint hit!\n"; + std::cout << "Breakpoint hit!\n"; printCurrentInstruction(); return; } @@ -1207,7 +1213,7 @@ void Interpreter::run() { if (ECStack.empty()) { - cout << "Error: no program running, cannot run!\n"; + std::cout << "Error: no program running, cannot run!\n"; return; } @@ -1217,16 +1223,16 @@ HitBreakpoint = executeInstruction(); } - if (HitBreakpoint) { - cout << "Breakpoint hit!\n"; - } + if (HitBreakpoint) + std::cout << "Breakpoint hit!\n"; + // Print the next instruction to execute... printCurrentInstruction(); } void Interpreter::finish() { if (ECStack.empty()) { - cout << "Error: no program running, cannot run!\n"; + std::cout << "Error: no program running, cannot run!\n"; return; } @@ -1237,9 +1243,8 @@ HitBreakpoint = executeInstruction(); } - if (HitBreakpoint) { - cout << "Breakpoint hit!\n"; - } + if (HitBreakpoint) + std::cout << "Breakpoint hit!\n"; // Print the next instruction to execute... printCurrentInstruction(); @@ -1253,33 +1258,33 @@ void Interpreter::printCurrentInstruction() { if (!ECStack.empty()) { if (ECStack.back().CurBB->begin() == ECStack.back().CurInst) // print label - WriteAsOperand(cout, ECStack.back().CurBB) << ":\n"; + WriteAsOperand(std::cout, ECStack.back().CurBB) << ":\n"; Instruction &I = *ECStack.back().CurInst; InstNumber *IN = (InstNumber*)I.getAnnotation(SlotNumberAID); assert(IN && "Instruction has no numbering annotation!"); - cout << "#" << IN->InstNum << I; + std::cout << "#" << IN->InstNum << I; } } void Interpreter::printValue(const Type *Ty, GenericValue V) { switch (Ty->getPrimitiveID()) { - case Type::BoolTyID: cout << (V.BoolVal?"true":"false"); break; + case Type::BoolTyID: std::cout << (V.BoolVal?"true":"false"); break; case Type::SByteTyID: - cout << (int)V.SByteVal << " '" << V.SByteVal << "'"; break; + std::cout << (int)V.SByteVal << " '" << V.SByteVal << "'"; break; case Type::UByteTyID: - cout << (unsigned)V.UByteVal << " '" << V.UByteVal << "'"; break; - case Type::ShortTyID: cout << V.ShortVal; break; - case Type::UShortTyID: cout << V.UShortVal; break; - case Type::IntTyID: cout << V.IntVal; break; - case Type::UIntTyID: cout << V.UIntVal; break; - case Type::LongTyID: cout << (long)V.LongVal; break; - case Type::ULongTyID: cout << (unsigned long)V.ULongVal; break; - case Type::FloatTyID: cout << V.FloatVal; break; - case Type::DoubleTyID: cout << V.DoubleVal; break; - case Type::PointerTyID:cout << (void*)GVTOP(V); break; + std::cout << (unsigned)V.UByteVal << " '" << V.UByteVal << "'"; break; + case Type::ShortTyID: std::cout << V.ShortVal; break; + case Type::UShortTyID: std::cout << V.UShortVal; break; + case Type::IntTyID: std::cout << V.IntVal; break; + case Type::UIntTyID: std::cout << V.UIntVal; break; + case Type::LongTyID: std::cout << (long)V.LongVal; break; + case Type::ULongTyID: std::cout << (unsigned long)V.ULongVal; break; + case Type::FloatTyID: std::cout << V.FloatVal; break; + case Type::DoubleTyID: std::cout << V.DoubleVal; break; + case Type::PointerTyID:std::cout << (void*)GVTOP(V); break; default: - cout << "- Don't know how to print value of this type!"; + std::cout << "- Don't know how to print value of this type!"; break; } } @@ -1302,7 +1307,7 @@ } else { // Otherwise there should be an annotation for the slot# print(PickedVal->getType(), getOperandValue(PickedVal, ECStack[CurFrame])); - cout << "\n"; + std::cout << "\n"; } } @@ -1310,10 +1315,10 @@ Value *PickedVal = ChooseOneOption(Name, LookupMatchingNames(Name)); if (!PickedVal) return; - cout << "Value: "; + std::cout << "Value: "; print(PickedVal->getType(), getOperandValue(PickedVal, ECStack[CurFrame])); - cout << "\n"; + std::cout << "\n"; printOperandInfo(PickedVal, ECStack[CurFrame]); } @@ -1330,13 +1335,13 @@ unsigned i = 0; for (Function::aiterator I = F->abegin(), E = F->aend(); I != E; ++I, ++i) { - if (i != 0) cout << ", "; + if (i != 0) std::cout << ", "; CW << *I << "="; printValue(I->getType(), getOperandValue(I, ECStack[FrameNo])); } - cout << ")\n"; + std::cout << ")\n"; if (FrameNo != int(ECStack.size()-1)) { BasicBlock::iterator I = ECStack[FrameNo].CurInst; From lattner at cs.uiuc.edu Tue Apr 22 17:01:02 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Apr 22 17:01:02 2003 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/BasicAA/2003-04-22-GEPProblem.ll Message-ID: <200304222200.RAA30223@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/BasicAA: 2003-04-22-GEPProblem.ll added (r1.1) --- Log message: New testcase --- Diffs of the changes: Index: llvm/test/Regression/Transforms/BasicAA/2003-04-22-GEPProblem.ll diff -c /dev/null llvm/test/Regression/Transforms/BasicAA/2003-04-22-GEPProblem.ll:1.1 *** /dev/null Tue Apr 22 17:00:25 2003 --- llvm/test/Regression/Transforms/BasicAA/2003-04-22-GEPProblem.ll Tue Apr 22 17:00:15 2003 *************** *** 0 **** --- 1,15 ---- + ; RUN: as < %s | opt -load-vn -gcse -instcombine | dis | grep sub + + ; BasicAA was incorrectly concluding that P1 and P2 didn't conflict! + + int %test(int *%Ptr, long %V) { + %P2 = getelementptr int* %Ptr, long 1 + %P1 = getelementptr int* %Ptr, long %V + %X = load int* %P1 + store int 5, int* %P2 + + %Y = load int* %P1 + + %Z = sub int %X, %Y + ret int %Z + } From lattner at cs.uiuc.edu Tue Apr 22 17:01:04 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Apr 22 17:01:04 2003 Subject: [llvm-commits] CVS: llvm/lib/Analysis/BasicAliasAnalysis.cpp Message-ID: <200304222200.RAA30338@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: BasicAliasAnalysis.cpp updated: 1.6 -> 1.7 --- Log message: Fix bug: BasicAA/2003-04-22-GEPProblem.ll --- Diffs of the changes: Index: llvm/lib/Analysis/BasicAliasAnalysis.cpp diff -u llvm/lib/Analysis/BasicAliasAnalysis.cpp:1.6 llvm/lib/Analysis/BasicAliasAnalysis.cpp:1.7 --- llvm/lib/Analysis/BasicAliasAnalysis.cpp:1.6 Thu Mar 6 10:37:29 2003 +++ llvm/lib/Analysis/BasicAliasAnalysis.cpp Tue Apr 22 17:00:27 2003 @@ -145,7 +145,6 @@ if (V1Size != ~0U && V2Size != ~0U) if (const GetElementPtrInst *GEP = dyn_cast(V1)) { AliasResult R = alias(GEP->getOperand(0), V1Size, V2, V2Size); - if (R == NoAlias) return NoAlias; if (R == MustAlias) { // If there is at least one non-zero constant index, we know they cannot // alias. From brukman at cs.uiuc.edu Tue Apr 22 18:01:01 2003 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Tue Apr 22 18:01:01 2003 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/ModuloScheduling/ModuloSchedGraph.cpp ModuloSchedGraph.h Message-ID: <200304222300.SAA02630@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/ModuloScheduling: ModuloSchedGraph.cpp updated: 1.4 -> 1.5 ModuloSchedGraph.h updated: 1.4 -> 1.5 --- Log message: Just some code beautification changes I had sitting around in my tree. --- Diffs of the changes: Index: llvm/lib/CodeGen/ModuloScheduling/ModuloSchedGraph.cpp diff -u llvm/lib/CodeGen/ModuloScheduling/ModuloSchedGraph.cpp:1.4 llvm/lib/CodeGen/ModuloScheduling/ModuloSchedGraph.cpp:1.5 --- llvm/lib/CodeGen/ModuloScheduling/ModuloSchedGraph.cpp:1.4 Thu Apr 10 14:19:23 2003 +++ llvm/lib/CodeGen/ModuloScheduling/ModuloSchedGraph.cpp Tue Apr 22 18:00:08 2003 @@ -19,14 +19,12 @@ #include #include #include - // FIXME: Should be using #include #include //#include #define UNIDELAY 1 - //*********************** Internal Data Structures *************************/ // The following two types need to be classes, not typedefs, so we can use @@ -52,7 +50,6 @@ // class Modulo SchedGraphNode -/*ctor*/ ModuloSchedGraphNode::ModuloSchedGraphNode(unsigned int _nodeId, const BasicBlock * _bb, const Instruction * _inst, @@ -113,8 +110,8 @@ for (unsigned int i = 0; i < defVec.size(); i++) { for (Value::use_const_iterator I = defVec[i]->getInst()->use_begin(); I != defVec[i]->getInst()->use_end(); I++) { - //for each use of a def, add a flow edge from the def instruction to the ref instruction - + //for each use of a def, add a flow edge from the def instruction to the + //ref instruction const Instruction *value = defVec[i]->getInst(); Instruction *inst = (Instruction *) (*I); @@ -969,7 +966,6 @@ int ModuloSchedGraph::computeRecII(const BasicBlock *bb) { - int RecII = 0; //os<<"begining computerRecII()"<<"\n"; @@ -1269,7 +1265,6 @@ DEBUG(std::cerr << "dumping basic block:"); DEBUG(std::cerr << (bb->hasName()? bb->getName() : "block") << " (" << bb << ")" << "\n"); - } void ModuloSchedGraph::dump(const BasicBlock * bb, std::ostream & os) @@ -1319,16 +1314,15 @@ } } -void ModuloSchedGraphSet::buildGraphsForMethod(const Function * F, - const TargetMachine & - target) +void ModuloSchedGraphSet::buildGraphsForMethod(const Function *F, + const TargetMachine &target) { for (Function::const_iterator BI = F->begin(); BI != F->end(); ++BI) addGraph(new ModuloSchedGraph(BI, target)); } -std::ostream & operator<<(std::ostream & os, - const ModuloSchedGraphNode & node) +std::ostream& operator<<(std::ostream &os, + const ModuloSchedGraphNode &node) { os << std::string(8, ' ') << "Node " << node.nodeId << " : " @@ -1347,7 +1341,6 @@ for (unsigned i = 0, N = node.outEdges.size(); i < N; i++) os << std::string(16, ' ') << *node.outEdges[i]; } - return os; } Index: llvm/lib/CodeGen/ModuloScheduling/ModuloSchedGraph.h diff -u llvm/lib/CodeGen/ModuloScheduling/ModuloSchedGraph.h:1.4 llvm/lib/CodeGen/ModuloScheduling/ModuloSchedGraph.h:1.5 --- llvm/lib/CodeGen/ModuloScheduling/ModuloSchedGraph.h:1.4 Thu Apr 10 14:19:23 2003 +++ llvm/lib/CodeGen/ModuloScheduling/ModuloSchedGraph.h Tue Apr 22 18:00:08 2003 @@ -235,14 +235,15 @@ const unsigned int getNumNodes() const { return size() + 2; } + //return wether the BasicBlock 'bb' contains a loop - bool isLoop(const BasicBlock * bb); + bool isLoop(const BasicBlock *bb); //return this basibBlock contains a loop bool isLoop(); //return the node for the input instruction - ModuloSchedGraphNode *getGraphNodeForInst(const Instruction * inst) const { + ModuloSchedGraphNode *getGraphNodeForInst(const Instruction *inst) const { const_iterator onePair = this->find(inst); return (onePair != this->end()) ? (*onePair).second : NULL; } @@ -252,10 +253,10 @@ void dump() const; // dump the basicBlock - void dump(const BasicBlock * bb); + void dump(const BasicBlock *bb); //dump the basicBlock into 'os' stream - void dump(const BasicBlock * bb, std::ostream & os); + void dump(const BasicBlock *bb, std::ostream &os); //dump the node property void dumpNodeProperty() const; @@ -287,14 +288,13 @@ (*this)[inst] = node; } - //Graph builder - + // Graph builder ModuloSchedGraphNode *getNode(const unsigned nodeId) const; - //build the graph from the basicBlock - void buildGraph(const TargetMachine & target); + // Build the graph from the basicBlock + void buildGraph(const TargetMachine &target); - //Build nodes for BasicBlock + // Build nodes for BasicBlock void buildNodesforBB(const TargetMachine &target, const BasicBlock *bb, NodeVec &memNode, From brukman at cs.uiuc.edu Tue Apr 22 18:02:00 2003 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Tue Apr 22 18:02:00 2003 Subject: [llvm-commits] CVS: llvm/include/llvm/Reoptimizer/BinInterface/bitmath.h Message-ID: <200304222301.SAA02649@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Reoptimizer/BinInterface: bitmath.h updated: 1.7 -> 1.8 --- Log message: This include is necessary to compile. --- Diffs of the changes: Index: llvm/include/llvm/Reoptimizer/BinInterface/bitmath.h diff -u llvm/include/llvm/Reoptimizer/BinInterface/bitmath.h:1.7 llvm/include/llvm/Reoptimizer/BinInterface/bitmath.h:1.8 --- llvm/include/llvm/Reoptimizer/BinInterface/bitmath.h:1.7 Thu Apr 10 15:32:49 2003 +++ llvm/include/llvm/Reoptimizer/BinInterface/bitmath.h Tue Apr 22 18:01:06 2003 @@ -19,6 +19,8 @@ #ifndef __BITMATH_H__ #define __BITMATH_H__ +#include "Support/DataTypes.h" + //********************************* // Misc functions //********************************* From brukman at cs.uiuc.edu Tue Apr 22 22:00:01 2003 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Tue Apr 22 22:00:01 2003 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Reader/ReadArchive.cpp Message-ID: <200304230259.VAA04204@neo.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Reader: ReadArchive.cpp updated: 1.2 -> 1.3 --- Log message: Fixed 'prevalent'. --- Diffs of the changes: Index: llvm/lib/Bytecode/Reader/ReadArchive.cpp diff -u llvm/lib/Bytecode/Reader/ReadArchive.cpp:1.2 llvm/lib/Bytecode/Reader/ReadArchive.cpp:1.3 --- llvm/lib/Bytecode/Reader/ReadArchive.cpp:1.2 Tue Apr 22 13:02:51 2003 +++ llvm/lib/Bytecode/Reader/ReadArchive.cpp Tue Apr 22 21:59:05 2003 @@ -3,7 +3,7 @@ // This file implements the ReadArchiveFile interface, which allows a linker to // read all of the LLVM bytecode files contained in a .a file. This file // understands the standard system .a file format. This can only handle the .a -// variant prevelant on linux systems so far, but may be extended. See +// variant prevalent on Linux systems so far, but may be extended. See // information in this source file for more information: // http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/bfd/archive.c?cvsroot=src // From lattner at cs.uiuc.edu Wed Apr 23 11:18:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Apr 23 11:18:01 2003 Subject: [llvm-commits] CVS: llvm/include/Support/Casting.h Message-ID: <200304231617.LAA21306@apoc.cs.uiuc.edu> Changes in directory llvm/include/Support: Casting.h updated: 1.3 -> 1.4 --- Log message: Allow dyn_cast to operate on things that aren't OBVIOUSLY a pointer type. These things can be converted to a pointer, like ilist_iterators --- Diffs of the changes: Index: llvm/include/Support/Casting.h diff -u llvm/include/Support/Casting.h:1.3 llvm/include/Support/Casting.h:1.4 --- llvm/include/Support/Casting.h:1.3 Wed Jul 24 15:22:09 2002 +++ llvm/include/Support/Casting.h Wed Apr 23 11:17:28 2003 @@ -211,8 +211,8 @@ // template -inline typename cast_retty::ret_type dyn_cast(Y *Val) { - return isa(Val) ? cast(Val) : 0; +inline typename cast_retty::ret_type dyn_cast(Y Val) { + return isa(Val) ? cast(Val) : 0; } // dyn_cast_or_null - Functionally identical to dyn_cast, except that a null From lattner at cs.uiuc.edu Wed Apr 23 11:19:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Apr 23 11:19:01 2003 Subject: [llvm-commits] CVS: llvm/include/Support/ilist Message-ID: <200304231618.LAA21317@apoc.cs.uiuc.edu> Changes in directory llvm/include/Support: ilist updated: 1.5 -> 1.6 --- Log message: Allow autoconversion from ilist_iterator to T* in a dyn_cast and friends --- Diffs of the changes: Index: llvm/include/Support/ilist diff -u llvm/include/Support/ilist:1.5 llvm/include/Support/ilist:1.6 --- llvm/include/Support/ilist:1.5 Mon Sep 16 11:46:17 2002 +++ llvm/include/Support/ilist Wed Apr 23 11:17:53 2003 @@ -151,6 +151,26 @@ pointer getNodePtrUnchecked() const { return NodePtr; } }; +// Allow ilist_iterators to convert into pointers to a node automatically when +// used by the dyn_cast, cast, isa mechanisms... + +template struct simplify_type; + +template struct simplify_type > { + typedef NodeTy* SimpleType; + + static SimpleType getSimplifiedValue(const ilist_iterator &Node) { + return &*Node; + } +}; +template struct simplify_type > { + typedef NodeTy* SimpleType; + + static SimpleType getSimplifiedValue(const ilist_iterator &Node) { + return &*Node; + } +}; + //===----------------------------------------------------------------------===// // From lattner at cs.uiuc.edu Wed Apr 23 11:19:03 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Apr 23 11:19:03 2003 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/LowerAllocations.cpp Message-ID: <200304231618.LAA21328@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: LowerAllocations.cpp updated: 1.33 -> 1.34 --- Log message: Minor cleanups --- Diffs of the changes: Index: llvm/lib/Transforms/Scalar/LowerAllocations.cpp diff -u llvm/lib/Transforms/Scalar/LowerAllocations.cpp:1.33 llvm/lib/Transforms/Scalar/LowerAllocations.cpp:1.34 --- llvm/lib/Transforms/Scalar/LowerAllocations.cpp:1.33 Tue Oct 1 17:38:41 2002 +++ llvm/lib/Transforms/Scalar/LowerAllocations.cpp Wed Apr 23 11:18:14 2003 @@ -15,8 +15,6 @@ #include "llvm/Target/TargetData.h" #include "Support/Statistic.h" -using std::vector; - namespace { Statistic<> NumLowered("lowerallocs", "Number of allocations lowered"); @@ -62,10 +60,11 @@ bool LowerAllocations::doInitialization(Module &M) { const FunctionType *MallocType = FunctionType::get(PointerType::get(Type::SByteTy), - vector(1, Type::UIntTy), false); + std::vector(1, Type::UIntTy), false); const FunctionType *FreeType = FunctionType::get(Type::VoidTy, - vector(1, PointerType::get(Type::SByteTy)), + std::vector(1, + PointerType::get(Type::SByteTy)), false); MallocFunc = M.getOrInsertFunction("malloc", MallocType); @@ -105,7 +104,7 @@ // Create the call to Malloc... CallInst *MCall = new CallInst(MallocFunc, - vector(1, MallocArg), "", I); + std::vector(1, MallocArg), "", I); // Create a cast instruction to convert to the right type... CastInst *MCast = new CastInst(MCall, MI->getType(), "", I); @@ -121,7 +120,8 @@ PointerType::get(Type::UByteTy), "", I); // Insert a call to the free function... - CallInst *FCall = new CallInst(FreeFunc, vector(1, MCast), "", I); + CallInst *FCall = new CallInst(FreeFunc, std::vector(1, MCast), + "", I); // Delete the old free instruction I = --BBIL.erase(I); From lattner at cs.uiuc.edu Wed Apr 23 11:19:04 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Apr 23 11:19:04 2003 Subject: [llvm-commits] CVS: llvm/test/Programs/SingleSource/UnitTests/2003-04-22-Switch.c Message-ID: <200304231618.LAA21339@apoc.cs.uiuc.edu> Changes in directory llvm/test/Programs/SingleSource/UnitTests: 2003-04-22-Switch.c updated: 1.1 -> 1.2 --- Log message: Make testcase more interesting by making PHI nodes occur due to the switch --- Diffs of the changes: Index: llvm/test/Programs/SingleSource/UnitTests/2003-04-22-Switch.c diff -u llvm/test/Programs/SingleSource/UnitTests/2003-04-22-Switch.c:1.1 llvm/test/Programs/SingleSource/UnitTests/2003-04-22-Switch.c:1.2 --- llvm/test/Programs/SingleSource/UnitTests/2003-04-22-Switch.c:1.1 Tue Apr 22 15:25:58 2003 +++ llvm/test/Programs/SingleSource/UnitTests/2003-04-22-Switch.c Wed Apr 23 11:18:37 2003 @@ -1,17 +1,19 @@ #include -static void func(unsigned i) { +static int func(unsigned i) { + int X = 4; switch (i) { - case 8: printf("C\n"); /* fall through. */ + case 8: printf("C\n"); /* fall through. */ X = 6; case 0: - case 3: + case 3: case 2: printf("A\n"); break; case 1: - case 7: + case 7: X = 7; case 9: printf("B\n"); break; - default: printf("D\n"); + default: printf("D\n"); X = 1; } + return X; } From lattner at cs.uiuc.edu Wed Apr 23 11:25:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Apr 23 11:25:01 2003 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/LowerSwitch.cpp Message-ID: <200304231624.LAA21448@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: LowerSwitch.cpp added (r1.1) --- Log message: New pass to lower switch instructions to branch instructions --- Diffs of the changes: Index: llvm/lib/Transforms/Scalar/LowerSwitch.cpp diff -c /dev/null llvm/lib/Transforms/Scalar/LowerSwitch.cpp:1.1 *** /dev/null Wed Apr 23 11:24:09 2003 --- llvm/lib/Transforms/Scalar/LowerSwitch.cpp Wed Apr 23 11:23:59 2003 *************** *** 0 **** --- 1,102 ---- + //===- LowerSwitch.cpp - Eliminate Switch instructions --------------------===// + // + // The LowerSwitch transformation rewrites switch statements with a sequence of + // branches, which allows targets to get away with not implementing the switch + // statement until it is convenient. + // + //===----------------------------------------------------------------------===// + + #include "llvm/Transforms/Scalar.h" + #include "llvm/Function.h" + #include "llvm/iTerminators.h" + #include "llvm/iOperators.h" + #include "llvm/iPHINode.h" + #include "llvm/Pass.h" + #include "Support/Statistic.h" + + namespace { + Statistic<> NumLowered("lowerswitch", "Number of SwitchInst's replaced"); + + /// LowerSwitch Pass - Replace all SwitchInst instructions with chained branch + /// instructions. Note that this cannot be a BasicBlock pass because it + /// modifies the CFG! + struct LowerSwitch : public FunctionPass { + bool runOnFunction(Function &F); + void processSwitchInst(SwitchInst *SI); + }; + + RegisterOpt + X("lowerswitch", "Lower SwitchInst's to branches"); + } + + // createLowerSwitchPass - Interface to this file... + Pass *createLowerSwitchPass() { + return new LowerSwitch(); + } + + bool LowerSwitch::runOnFunction(Function &F) { + bool Changed = false; + + for (Function::iterator I = F.begin(), E = F.end(); I != E; ) { + BasicBlock *Cur = I++; // Advance over block so we don't traverse new blocks + + if (SwitchInst *SI = dyn_cast(Cur->getTerminator())) { + Changed = true; + processSwitchInst(SI); + } + } + + return Changed; + } + + // processSwitchInst - Replace the specified switch instruction with a sequence + // of chained basic blocks. Right now we just insert an incredibly stupid + // linear sequence of branches. It would be better to do a balanced binary + // search eventually. FIXME + // + void LowerSwitch::processSwitchInst(SwitchInst *SI) { + BasicBlock *CurBlock = SI->getParent(); + BasicBlock *OrigBlock = CurBlock; + Function *F = CurBlock->getParent(); + Value *Val = SI->getOperand(0); // The value we are switching on... + + // Unlink the switch instruction from it's block. + CurBlock->getInstList().remove(SI); + + // Expand comparisons for all of the non-default cases... + for (unsigned i = 2, e = SI->getNumOperands(); i != e; i += 2) { + // Insert a new basic block after the current one... + BasicBlock *NextBlock; + if (i != e-2) { + NextBlock = new BasicBlock("switchblock"); + F->getBasicBlockList().insert(CurBlock->getNext(), NextBlock); + } else { // Last case, if it's not the value, go to default block. + NextBlock = cast(SI->getDefaultDest()); + } + + // Make the seteq instruction... + Instruction *Comp = new SetCondInst(Instruction::SetEQ, Val, + SI->getOperand(i), "switchcase"); + CurBlock->getInstList().push_back(Comp); + + // Make the conditional branch... + BasicBlock *Succ = cast(SI->getOperand(i+1)); + Instruction *Br = new BranchInst(Succ, NextBlock, Comp); + CurBlock->getInstList().push_back(Br); + + // If there were any PHI nodes in this success, rewrite one entry from + // OrigBlock to come from CurBlock. + for (BasicBlock::iterator I = Succ->begin(); + PHINode *PN = dyn_cast(I); ++I) { + int BlockIdx = PN->getBasicBlockIndex(OrigBlock); + assert(BlockIdx != -1 && "Switch didn't go to this successor??"); + PN->setIncomingBlock((unsigned)BlockIdx, CurBlock); + } + + CurBlock = NextBlock; // Move on to the next condition + } + + + // We are now done with the switch instruction, delete it. + delete SI; + } From lattner at cs.uiuc.edu Wed Apr 23 11:25:03 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Apr 23 11:25:03 2003 Subject: [llvm-commits] CVS: llvm/include/llvm/Transforms/Scalar.h Message-ID: <200304231624.LAA21459@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Transforms: Scalar.h updated: 1.14 -> 1.15 --- Log message: Add stub to create lowerSwitches pass --- Diffs of the changes: Index: llvm/include/llvm/Transforms/Scalar.h diff -u llvm/include/llvm/Transforms/Scalar.h:1.14 llvm/include/llvm/Transforms/Scalar.h:1.15 --- llvm/include/llvm/Transforms/Scalar.h:1.14 Tue Oct 8 16:06:24 2002 +++ llvm/include/llvm/Transforms/Scalar.h Wed Apr 23 11:24:19 2003 @@ -224,6 +224,11 @@ Pass *createLowerAllocationsPass(); Pass *createRaiseAllocationsPass(); +//===----------------------------------------------------------------------===// +// This pass converts SwitchInst instructions into a sequence of chained binary +// branch instructions. +// +Pass *createLowerSwitchPass(); //===----------------------------------------------------------------------===// // From lattner at cs.uiuc.edu Wed Apr 23 11:26:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Apr 23 11:26:01 2003 Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/Sparc.cpp Message-ID: <200304231625.LAA21475@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/Sparc: Sparc.cpp updated: 1.60 -> 1.61 --- Log message: Add support for the Switch instruction by running the lowerSwitch pass first --- Diffs of the changes: Index: llvm/lib/Target/Sparc/Sparc.cpp diff -u llvm/lib/Target/Sparc/Sparc.cpp:1.60 llvm/lib/Target/Sparc/Sparc.cpp:1.61 --- llvm/lib/Target/Sparc/Sparc.cpp:1.60 Tue Jan 14 15:59:15 2003 +++ llvm/lib/Target/Sparc/Sparc.cpp Wed Apr 23 11:24:53 2003 @@ -143,6 +143,9 @@ // bool UltraSparc::addPassesToEmitAssembly(PassManager &PM, std::ostream &Out) { + // FIXME: implement the switch instruction in the instruction selector. + PM.add(createLowerSwitchPass()); + // Construct and initialize the MachineFunction object for this fn. PM.add(createMachineCodeConstructionPass(*this)); From lattner at cs.uiuc.edu Wed Apr 23 11:26:04 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Apr 23 11:26:04 2003 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86TargetMachine.cpp Message-ID: <200304231625.LAA21482@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86TargetMachine.cpp updated: 1.14 -> 1.15 --- Log message: Add support for the Switch instruction by running the lowerSwitch pass first --- Diffs of the changes: Index: llvm/lib/Target/X86/X86TargetMachine.cpp diff -u llvm/lib/Target/X86/X86TargetMachine.cpp:1.14 llvm/lib/Target/X86/X86TargetMachine.cpp:1.15 --- llvm/lib/Target/X86/X86TargetMachine.cpp:1.14 Wed Feb 26 13:58:15 2003 +++ llvm/lib/Target/X86/X86TargetMachine.cpp Wed Apr 23 11:24:55 2003 @@ -6,10 +6,11 @@ #include "X86TargetMachine.h" #include "X86.h" +#include "llvm/PassManager.h" #include "llvm/Target/TargetMachineImpls.h" #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/Passes.h" -#include "llvm/PassManager.h" +#include "llvm/Transforms/Scalar.h" #include "Support/CommandLine.h" #include "Support/Statistic.h" #include @@ -45,6 +46,9 @@ /// not supported for this target. /// bool X86TargetMachine::addPassesToJITCompile(PassManager &PM) { + // FIXME: Implement the switch instruction in the instruction selector! + PM.add(createLowerSwitchPass()); + PM.add(createSimpleX86InstructionSelector(*this)); // TODO: optional optimizations go here From lattner at cs.uiuc.edu Wed Apr 23 11:26:06 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Apr 23 11:26:06 2003 Subject: [llvm-commits] CVS: llvm/www/docs/CodingStandards.html Message-ID: <200304231625.LAA21509@apoc.cs.uiuc.edu> Changes in directory llvm/www/docs: CodingStandards.html updated: 1.5 -> 1.6 --- Log message: Properly convert some &'s to &'s --- Diffs of the changes: Index: llvm/www/docs/CodingStandards.html diff -u llvm/www/docs/CodingStandards.html:1.5 llvm/www/docs/CodingStandards.html:1.6 --- llvm/www/docs/CodingStandards.html:1.5 Sun Jan 20 13:01:26 2002 +++ llvm/www/docs/CodingStandards.html Wed Apr 23 11:25:38 2003 @@ -378,9 +378,9 @@ public std::iterator { friend class container; public: - const value_type& operator*() const; + const value_type& operator*() const; const value_type* operator->() const; - const_iterator& operator++(); + const_iterator& operator++(); const_iterator operator++(int); friend bool operator==(const_iterator lhs, const_iterator rhs); @@ -408,14 +408,14 @@ There are normally only three member functions that need nontrivial implementations; the rest are just boilerplate. - const container::value_type& + const container::value_type& container::const_iterator::operator*() const { // find the element and return a reference to it } const container::value_type* container::const_iterator::operator->() const { - return &**this; + return &**this; } If there's an underlying real container, operator*() can just return a @@ -431,7 +431,7 @@ The operator->() function is just boilerplate around a call to operator*(). - container::const_iterator& + container::const_iterator& container::const_iterator::operator++() { // the incrementing logic goes here return *this; @@ -491,9 +491,9 @@ friend class container; friend class container::const_iterator; public: - value_type& operator*() const; + value_type& operator*() const; value_type* operator->() const; - iterator& operator++(); + iterator& operator++(); iterator operator++(int); friend bool operator==(iterator lhs, iterator rhs); friend bool operator!=(iterator lhs, iterator rhs); @@ -505,10 +505,10 @@ friend class container; public: const_iterator(); - const_iterator(const iterator& i); - const value_type& operator*() const; + const_iterator(const iterator& i); + const value_type& operator*() const; const value_type* operator->() const; - const_iterator& operator++(); + const_iterator& operator++(); const_iterator operator++(int); friend bool operator==(const_iterator lhs, const_iterator rhs); @@ -537,7 +537,7 @@ public std::iterator { public: //... - iterator& operator--(); + iterator& operator--(); iterator operator--(int); //... }; @@ -551,8 +551,8 @@ public std::iterator { public: //... - iterator& operator+=(difference_type rhs); - iterator& operator-=(difference_type rhs); + iterator& operator+=(difference_type rhs); + iterator& operator-=(difference_type rhs); friend iterator operator+(iterator lhs, difference_type rhs); friend iterator operator+(difference_type lhs, iterator rhs); friend iterator operator-(iterator lhs, difference_type rhs); @@ -564,13 +564,13 @@ //... }; - container::iterator& + container::iterator& container::iterator::operator+=(container::difference_type rhs) { // add rhs to iterator position return *this; } - container::iterator& + container::iterator& container::iterator::operator-=(container::difference_type rhs) { // subtract rhs from iterator position return *this; @@ -660,7 +660,7 @@
Chris Lattner
-Last modified: Sun Jan 20 13:01:02 CST 2002 +Last modified: Wed Apr 23 11:20:49 CDT 2003 From lattner at cs.uiuc.edu Wed Apr 23 11:27:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Apr 23 11:27:01 2003 Subject: [llvm-commits] CVS: llvm/www/docs/ProgrammersManual.html Message-ID: <200304231626.LAA06807@tank.cs.uiuc.edu> Changes in directory llvm/www/docs: ProgrammersManual.html updated: 1.38 -> 1.39 --- Log message: Remove documented problem that is now fixed --- Diffs of the changes: Index: llvm/www/docs/ProgrammersManual.html diff -u llvm/www/docs/ProgrammersManual.html:1.38 llvm/www/docs/ProgrammersManual.html:1.39 --- llvm/www/docs/ProgrammersManual.html:1.38 Wed Feb 26 10:38:15 2003 +++ llvm/www/docs/ProgrammersManual.html Wed Apr 23 11:26:15 2003 @@ -272,7 +272,7 @@
   // Loop over all of the phi nodes in a basic block
   BasicBlock::iterator BBI = BB->begin();
-  for (; PHINode *PN = dyn_cast<PHINode>(&*BBI); ++BBI)
+  for (; PHINode *PN = dyn_cast<PHINode>(BBI); ++BBI)
     cerr << *PN;
 

@@ -617,16 +617,6 @@

Instruction* pinst = i;
-Caveat emptor: The above syntax works only when you're not -working with dyn_cast. The template definition of dyn_cast isn't implemented to handle this yet, so you'll -still need the following in order for things to work properly: - -
-BasicBlock::iterator bbi = ...;
-BranchInst* b = dyn_cast<BranchInst>(&*bbi);
-
- It's also possible to turn a class pointer into the corresponding iterator. Usually, this conversion is quite inexpensive. The following code snippet illustrates use of the conversion constructors @@ -1745,6 +1735,6 @@ Chris Lattner -Last modified: Mon Feb 24 14:45:19 CST 2003 +Last modified: Wed Apr 23 11:21:57 CDT 2003 From lattner at cs.uiuc.edu Wed Apr 23 11:36:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Apr 23 11:36:01 2003 Subject: [llvm-commits] CVS: llvm/include/llvm/Support/InstIterator.h Message-ID: <200304231635.LAA23867@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Support: InstIterator.h updated: 1.4 -> 1.5 --- Log message: Kill unneccesary &* --- Diffs of the changes: Index: llvm/include/llvm/Support/InstIterator.h diff -u llvm/include/llvm/Support/InstIterator.h:1.4 llvm/include/llvm/Support/InstIterator.h:1.5 --- llvm/include/llvm/Support/InstIterator.h:1.4 Thu Jul 25 10:00:45 2002 +++ llvm/include/llvm/Support/InstIterator.h Wed Apr 23 11:35:30 2003 @@ -59,7 +59,7 @@ inline BBIty &getBasicBlockIterator() { return BB; } inline BIty &getInstructionIterator() { return BI; } - inline IIty operator*() const { return &*BI; } + inline IIty operator*() const { return BI; } inline IIty operator->() const { return operator*(); } inline bool operator==(const InstIterator &y) const { From lattner at cs.uiuc.edu Wed Apr 23 11:37:02 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Apr 23 11:37:02 2003 Subject: [llvm-commits] CVS: llvm/lib/Analysis/InductionVariable.cpp Message-ID: <200304231636.LAA23904@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: InductionVariable.cpp updated: 1.21 -> 1.22 --- Log message: Remove unneccesary &* --- Diffs of the changes: Index: llvm/lib/Analysis/InductionVariable.cpp diff -u llvm/lib/Analysis/InductionVariable.cpp:1.21 llvm/lib/Analysis/InductionVariable.cpp:1.22 --- llvm/lib/Analysis/InductionVariable.cpp:1.21 Fri Nov 8 18:48:39 2002 +++ llvm/lib/Analysis/InductionVariable.cpp Wed Apr 23 11:36:06 2003 @@ -213,7 +213,7 @@ DEBUG(std::cerr << "no terminator instruction!"); return NULL; } - SetCondInst *SCI = dyn_cast(&*B->getCondition()); + SetCondInst *SCI = dyn_cast(B->getCondition()); if (SCI && InductionType == Cannonical) { DEBUG(std::cerr << "sci:" << *SCI); From lattner at cs.uiuc.edu Wed Apr 23 11:37:04 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Apr 23 11:37:04 2003 Subject: [llvm-commits] CVS: llvm/lib/CWriter/Writer.cpp Message-ID: <200304231636.LAA23916@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CWriter: Writer.cpp updated: 1.78 -> 1.79 --- Log message: Remove unneccesary &* --- Diffs of the changes: Index: llvm/lib/CWriter/Writer.cpp diff -u llvm/lib/CWriter/Writer.cpp:1.78 llvm/lib/CWriter/Writer.cpp:1.79 --- llvm/lib/CWriter/Writer.cpp:1.78 Tue Apr 22 15:19:52 2003 +++ llvm/lib/CWriter/Writer.cpp Wed Apr 23 11:36:08 2003 @@ -896,7 +896,7 @@ void CWriter::printBranchToBlock(BasicBlock *CurBB, BasicBlock *Succ, unsigned Indent) { for (BasicBlock::iterator I = Succ->begin(); - PHINode *PN = dyn_cast(&*I); ++I) { + PHINode *PN = dyn_cast(I); ++I) { // now we have to do the printing Out << string(Indent, ' '); outputLValue(PN); From lattner at cs.uiuc.edu Wed Apr 23 11:37:06 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Apr 23 11:37:06 2003 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/MachineFunction.cpp Message-ID: <200304231636.LAA23923@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: MachineFunction.cpp updated: 1.38 -> 1.39 --- Log message: Remove unneccesary &* --- Diffs of the changes: Index: llvm/lib/CodeGen/MachineFunction.cpp diff -u llvm/lib/CodeGen/MachineFunction.cpp:1.38 llvm/lib/CodeGen/MachineFunction.cpp:1.39 --- llvm/lib/CodeGen/MachineFunction.cpp:1.38 Thu Jan 16 12:35:56 2003 +++ llvm/lib/CodeGen/MachineFunction.cpp Wed Apr 23 11:36:09 2003 @@ -247,7 +247,7 @@ for (Function::const_iterator BB = F->begin(), BBE = F->end(); BB !=BBE; ++BB) for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I != E; ++I) - if (const CallInst *callInst = dyn_cast(&*I)) + if (const CallInst *callInst = dyn_cast(I)) { unsigned numOperands = callInst->getNumOperands() - 1; int numExtra = (int)numOperands-frameInfo.getNumFixedOutgoingArgs(); From lattner at cs.uiuc.edu Wed Apr 23 11:37:08 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Apr 23 11:37:08 2003 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/InstrSelection/InstrSelection.cpp Message-ID: <200304231636.LAA23930@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/InstrSelection: InstrSelection.cpp updated: 1.56 -> 1.57 --- Log message: Remove unneccesary &* --- Diffs of the changes: Index: llvm/lib/CodeGen/InstrSelection/InstrSelection.cpp diff -u llvm/lib/CodeGen/InstrSelection/InstrSelection.cpp:1.56 llvm/lib/CodeGen/InstrSelection/InstrSelection.cpp:1.57 --- llvm/lib/CodeGen/InstrSelection/InstrSelection.cpp:1.56 Wed Jan 15 13:47:36 2003 +++ llvm/lib/CodeGen/InstrSelection/InstrSelection.cpp Wed Apr 23 11:36:11 2003 @@ -182,7 +182,7 @@ MachineFunction &MF = MachineFunction::get(&F); for (MachineFunction::iterator BB = MF.begin(); BB != MF.end(); ++BB) { for (BasicBlock::iterator IIt = BB->getBasicBlock()->begin(); - PHINode *PN = dyn_cast(&*IIt); ++IIt) { + PHINode *PN = dyn_cast(IIt); ++IIt) { // FIXME: This is probably wrong... Value *PhiCpRes = new PHINode(PN->getType(), "PhiCp:"); From lattner at cs.uiuc.edu Wed Apr 23 11:38:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Apr 23 11:38:01 2003 Subject: [llvm-commits] CVS: llvm/lib/Reoptimizer/LightWtProfiling/Instrument/InstLoops.cpp Message-ID: <200304231637.LAA24093@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Reoptimizer/LightWtProfiling/Instrument: InstLoops.cpp updated: 1.2 -> 1.3 --- Log message: Remove unnecesary &*'s --- Diffs of the changes: Index: llvm/lib/Reoptimizer/LightWtProfiling/Instrument/InstLoops.cpp diff -u llvm/lib/Reoptimizer/LightWtProfiling/Instrument/InstLoops.cpp:1.2 llvm/lib/Reoptimizer/LightWtProfiling/Instrument/InstLoops.cpp:1.3 --- llvm/lib/Reoptimizer/LightWtProfiling/Instrument/InstLoops.cpp:1.2 Tue Jan 14 16:34:36 2003 +++ llvm/lib/Reoptimizer/LightWtProfiling/Instrument/InstLoops.cpp Wed Apr 23 11:37:36 2003 @@ -133,7 +133,7 @@ for(BasicBlock::iterator BB2Inst = BB->begin(), BBend = BB->end(); BB2Inst != BBend; ++BB2Inst){ - if(PHINode *phiInst=dyn_cast(&*BB2Inst)){ + if (PHINode *phiInst = dyn_cast(BB2Inst)){ int bbIndex = phiInst->getBasicBlockIndex(u); if(bbIndex>=0){ phiInst->setIncomingBlock(bbIndex, newBB); From lattner at cs.uiuc.edu Wed Apr 23 11:38:03 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Apr 23 11:38:03 2003 Subject: [llvm-commits] CVS: llvm/lib/Reoptimizer/Trigger/TriggerAuxillary.cpp Message-ID: <200304231637.LAA24102@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Reoptimizer/Trigger: TriggerAuxillary.cpp updated: 1.2 -> 1.3 --- Log message: Remove unnecesary &*'s --- Diffs of the changes: Index: llvm/lib/Reoptimizer/Trigger/TriggerAuxillary.cpp diff -u llvm/lib/Reoptimizer/Trigger/TriggerAuxillary.cpp:1.2 llvm/lib/Reoptimizer/Trigger/TriggerAuxillary.cpp:1.3 --- llvm/lib/Reoptimizer/Trigger/TriggerAuxillary.cpp:1.2 Mon Feb 17 13:45:34 2003 +++ llvm/lib/Reoptimizer/Trigger/TriggerAuxillary.cpp Wed Apr 23 11:37:37 2003 @@ -52,7 +52,7 @@ for(BasicBlock::iterator II = BB->begin(), IE = BB->end(); II != IE; ++II){ //Instruction *inst = *II; - if(CallInst *cInst = dyn_cast(&*II)){ + if(CallInst *cInst = dyn_cast(II)){ // std::cerr<<*cInst<<"\n"; Function *calledFunction = cInst->getCalledFunction(); if(calledFunction && calledFunction->getName() == "trigger"){ From lattner at cs.uiuc.edu Wed Apr 23 11:38:05 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Apr 23 11:38:05 2003 Subject: [llvm-commits] CVS: llvm/lib/Transforms/IPO/FunctionInlining.cpp Message-ID: <200304231637.LAA24116@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/IPO: FunctionInlining.cpp updated: 1.41 -> 1.42 --- Log message: Remove unnecesary &*'s --- Diffs of the changes: Index: llvm/lib/Transforms/IPO/FunctionInlining.cpp diff -u llvm/lib/Transforms/IPO/FunctionInlining.cpp:1.41 llvm/lib/Transforms/IPO/FunctionInlining.cpp:1.42 --- llvm/lib/Transforms/IPO/FunctionInlining.cpp:1.41 Sun Jan 12 18:27:23 2003 +++ llvm/lib/Transforms/IPO/FunctionInlining.cpp Wed Apr 23 11:37:38 2003 @@ -169,7 +169,7 @@ static inline bool DoFunctionInlining(BasicBlock *BB) { for (BasicBlock::iterator I = BB->begin(); I != BB->end(); ++I) { - if (CallInst *CI = dyn_cast(&*I)) { + if (CallInst *CI = dyn_cast(I)) { // Check to see if we should inline this function Function *F = CI->getCalledFunction(); if (F && ShouldInlineFunction(CI, F)) { From lattner at cs.uiuc.edu Wed Apr 23 11:38:07 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Apr 23 11:38:07 2003 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Instrumentation/TraceValues.cpp Message-ID: <200304231637.LAA24127@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Instrumentation: TraceValues.cpp updated: 1.55 -> 1.56 --- Log message: Remove unnecesary &*'s --- Diffs of the changes: Index: llvm/lib/Transforms/Instrumentation/TraceValues.cpp diff -u llvm/lib/Transforms/Instrumentation/TraceValues.cpp:1.55 llvm/lib/Transforms/Instrumentation/TraceValues.cpp:1.56 --- llvm/lib/Transforms/Instrumentation/TraceValues.cpp:1.55 Wed Apr 16 15:28:40 2003 +++ llvm/lib/Transforms/Instrumentation/TraceValues.cpp Wed Apr 23 11:37:40 2003 @@ -298,9 +298,9 @@ ExternalFuncs& externalFuncs) { for (BasicBlock::iterator II=BB->begin(), IE = BB->end(); II != IE; ++II) - if (FreeInst *FI = dyn_cast(&*II)) + if (FreeInst *FI = dyn_cast(II)) InsertReleaseInst(FI->getOperand(0), BB, FI,externalFuncs.ReleasePtrFunc); - else if (AllocaInst *AI = dyn_cast(&*II)) + else if (AllocaInst *AI = dyn_cast(II)) InsertRecordInst(AI, BB, AI->getNext(), externalFuncs.RecordPtrFunc); } @@ -332,7 +332,7 @@ // instruction *preceding* InsertPos to check when to terminate the loop. // for (BasicBlock::iterator II = BB->begin(); &*II != InsertPos; ++II) { - if (StoreInst *SI = dyn_cast(&*II)) { + if (StoreInst *SI = dyn_cast(II)) { assert(valuesStoredInFunction && "Should not be printing a store instruction at function exit"); LoadInst *LI = new LoadInst(SI->getPointerOperand(), "reload." + From lattner at cs.uiuc.edu Wed Apr 23 11:38:09 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Apr 23 11:38:09 2003 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Instrumentation/ProfilePaths/EdgeCode.cpp ProfilePaths.cpp RetracePath.cpp Message-ID: <200304231637.LAA24138@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Instrumentation/ProfilePaths: EdgeCode.cpp updated: 1.19 -> 1.20 ProfilePaths.cpp updated: 1.26 -> 1.27 RetracePath.cpp updated: 1.3 -> 1.4 --- Log message: Remove unnecesary &*'s --- Diffs of the changes: Index: llvm/lib/Transforms/Instrumentation/ProfilePaths/EdgeCode.cpp diff -u llvm/lib/Transforms/Instrumentation/ProfilePaths/EdgeCode.cpp:1.19 llvm/lib/Transforms/Instrumentation/ProfilePaths/EdgeCode.cpp:1.20 --- llvm/lib/Transforms/Instrumentation/ProfilePaths/EdgeCode.cpp:1.19 Fri Feb 14 14:38:10 2003 +++ llvm/lib/Transforms/Instrumentation/ProfilePaths/EdgeCode.cpp Wed Apr 23 11:37:41 2003 @@ -386,7 +386,7 @@ for(BasicBlock::iterator BB2Inst = BB2->begin(), BBend = BB2->end(); BB2Inst != BBend; ++BB2Inst){ - if(PHINode *phiInst=dyn_cast(&*BB2Inst)){ + if(PHINode *phiInst=dyn_cast(BB2Inst)){ int bbIndex=phiInst->getBasicBlockIndex(BB1); assert(bbIndex>=0); phiInst->setIncomingBlock(bbIndex, newBB); Index: llvm/lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp diff -u llvm/lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp:1.26 llvm/lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp:1.27 --- llvm/lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp:1.26 Wed Apr 16 15:28:42 2003 +++ llvm/lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp Wed Apr 23 11:37:41 2003 @@ -87,7 +87,7 @@ nodes.push_back(nd); if(&*BB == ExitNode) exitNode=nd; - if(&*BB==F.begin()) + if(BB==F.begin()) startNode=nd; } Index: llvm/lib/Transforms/Instrumentation/ProfilePaths/RetracePath.cpp diff -u llvm/lib/Transforms/Instrumentation/ProfilePaths/RetracePath.cpp:1.3 llvm/lib/Transforms/Instrumentation/ProfilePaths/RetracePath.cpp:1.4 --- llvm/lib/Transforms/Instrumentation/ProfilePaths/RetracePath.cpp:1.3 Fri Feb 14 14:41:53 2003 +++ llvm/lib/Transforms/Instrumentation/ProfilePaths/RetracePath.cpp Wed Apr 23 11:37:41 2003 @@ -140,7 +140,7 @@ BasicBlock *ExitNode = 0; for (Function::iterator I = M->begin(), E = M->end(); I != E; ++I){ if (isa(I->getTerminator())) { - ExitNode = &*I; + ExitNode = I; break; } } @@ -160,7 +160,7 @@ if(BB->size()==3 || BB->size() ==2){ for(BasicBlock::iterator II = BB->begin(), IE = BB->end(); II != IE; ++II){ - if(CallInst *callInst = dyn_cast(&*II)){ + if(CallInst *callInst = dyn_cast(II)){ //std::cerr<<*callInst; Function *calledFunction = callInst->getCalledFunction(); if(calledFunction && calledFunction->getName() == "trigger"){ @@ -199,7 +199,7 @@ continue; //if(BB->size()==3) - //if(CallInst *callInst = dyn_cast(&*BB->getInstList().begin())) + //if(CallInst *callInst = dyn_cast(BB->getInstList().begin())) //if(callInst->getCalledFunction()->getName() == "trigger") //continue; @@ -216,20 +216,20 @@ Node *nd=findBB(nodes, BB); assert(nd && "No node for this edge!"); - for(BasicBlock::succ_iterator s=succ_begin(&*BB), se=succ_end(&*BB); + for(BasicBlock::succ_iterator s=succ_begin(BB), se=succ_end(BB); s!=se; ++s){ if(triggerBBs[*s] == 9){ //if(!pathReg[M]){ //Get the path register for this! //if(BB->size()>8) - // if(LoadInst *ldInst = dyn_cast(&*BB->getInstList().begin())) + // if(LoadInst *ldInst = dyn_cast(BB->getInstList().begin())) // pathReg[M] = ldInst->getPointerOperand(); //} continue; } //if((*s)->size()==3) //if(CallInst *callInst = - // dyn_cast(&*(*s)->getInstList().begin())) + // dyn_cast((*s)->getInstList().begin())) // if(callInst->getCalledFunction()->getName() == "trigger") // continue; @@ -284,11 +284,11 @@ VBI != VBE; ++VBI){ for(BasicBlock::iterator BBI = (*VBI)->begin(), BBE = (*VBI)->end(); BBI != BBE; ++BBI){ - if(LoadInst *ldInst = dyn_cast(&*BBI)){ + if(LoadInst *ldInst = dyn_cast(BBI)){ if(pathReg[M] == ldInst->getPointerOperand()) instToErase.push_back(ldInst); } - else if(StoreInst *stInst = dyn_cast(&*BBI)){ + else if(StoreInst *stInst = dyn_cast(BBI)){ if(pathReg[M] == stInst->getPointerOperand()) instToErase.push_back(stInst); } From lattner at cs.uiuc.edu Wed Apr 23 11:38:12 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Apr 23 11:38:12 2003 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/ADCE.cpp CorrelatedExprs.cpp DecomposeMultiDimRefs.cpp IndVarSimplify.cpp LICM.cpp LoopPreheaders.cpp LowerAllocations.cpp Mem2Reg.cpp Reassociate.cpp SCCP.cpp Message-ID: <200304231637.LAA24169@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: ADCE.cpp updated: 1.50 -> 1.51 CorrelatedExprs.cpp updated: 1.8 -> 1.9 DecomposeMultiDimRefs.cpp updated: 1.26 -> 1.27 IndVarSimplify.cpp updated: 1.32 -> 1.33 LICM.cpp updated: 1.26 -> 1.27 LoopPreheaders.cpp updated: 1.10 -> 1.11 LowerAllocations.cpp updated: 1.34 -> 1.35 Mem2Reg.cpp updated: 1.2 -> 1.3 Reassociate.cpp updated: 1.16 -> 1.17 SCCP.cpp updated: 1.64 -> 1.65 --- Log message: Remove unnecesary &*'s --- Diffs of the changes: Index: llvm/lib/Transforms/Scalar/ADCE.cpp diff -u llvm/lib/Transforms/Scalar/ADCE.cpp:1.50 llvm/lib/Transforms/Scalar/ADCE.cpp:1.51 --- llvm/lib/Transforms/Scalar/ADCE.cpp:1.50 Mon Feb 24 14:48:30 2003 +++ llvm/lib/Transforms/Scalar/ADCE.cpp Wed Apr 23 11:37:42 2003 @@ -119,7 +119,7 @@ for (BasicBlock::iterator I = BB->begin(), E = --BB->end(); I != E; ) if (!LiveSet.count(I)) { // Is this instruction alive? I->dropAllReferences(); // Nope, drop references... - if (PHINode *PN = dyn_cast(&*I)) { + if (PHINode *PN = dyn_cast(I)) { // We don't want to leave PHI nodes in the program that have // #arguments != #predecessors, so we remove them now. // @@ -310,7 +310,7 @@ // should be identical to the incoming values for LastDead. // for (BasicBlock::iterator II = NextAlive->begin(); - PHINode *PN = dyn_cast(&*II); ++II) { + PHINode *PN = dyn_cast(II); ++II) { // Get the incoming value for LastDead... int OldIdx = PN->getBasicBlockIndex(LastDead); assert(OldIdx != -1 && "LastDead is not a pred of NextAlive!"); Index: llvm/lib/Transforms/Scalar/CorrelatedExprs.cpp diff -u llvm/lib/Transforms/Scalar/CorrelatedExprs.cpp:1.8 llvm/lib/Transforms/Scalar/CorrelatedExprs.cpp:1.9 --- llvm/lib/Transforms/Scalar/CorrelatedExprs.cpp:1.8 Fri Nov 8 17:18:37 2002 +++ llvm/lib/Transforms/Scalar/CorrelatedExprs.cpp Wed Apr 23 11:37:42 2003 @@ -450,11 +450,11 @@ // Put the newly discovered information into the RegionInfo... for (BasicBlock::iterator I = OldSucc->begin(), E = OldSucc->end(); I!=E; ++I) - if (PHINode *PN = dyn_cast(&*I)) { + if (PHINode *PN = dyn_cast(I)) { int OpNum = PN->getBasicBlockIndex(BB); assert(OpNum != -1 && "PHI doesn't have incoming edge for predecessor!?"); PropagateEquality(PN, PN->getIncomingValue(OpNum), NewRI); - } else if (SetCondInst *SCI = dyn_cast(&*I)) { + } else if (SetCondInst *SCI = dyn_cast(I)) { Relation::KnownResult Res = getSetCCResult(SCI, NewRI); if (Res == Relation::Unknown) return false; PropagateEquality(SCI, ConstantBool::get(Res), NewRI); @@ -563,7 +563,7 @@ // node with a new value. // for (BasicBlock::iterator I = OldSucc->begin(); - PHINode *PN = dyn_cast(&*I); ) { + PHINode *PN = dyn_cast(I); ) { // Get the value flowing across the old edge and remove the PHI node entry // for this edge: we are about to remove the edge! Don't remove the PHI @@ -993,7 +993,7 @@ bool CEE::SimplifyBasicBlock(BasicBlock &BB, const RegionInfo &RI) { bool Changed = false; for (BasicBlock::iterator I = BB.begin(), E = BB.end(); I != E; ) { - Instruction *Inst = &*I++; + Instruction *Inst = I++; // Convert instruction arguments to canonical forms... Changed |= SimplifyInstruction(Inst, RI); Index: llvm/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp diff -u llvm/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp:1.26 llvm/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp:1.27 --- llvm/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp:1.26 Tue Oct 1 17:38:41 2002 +++ llvm/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp Wed Apr 23 11:37:42 2003 @@ -44,7 +44,7 @@ { bool changed = false; for (BasicBlock::iterator II = BB.begin(); II != BB.end(); ) - if (GetElementPtrInst *gep = dyn_cast(&*II++)) // pre-inc + if (GetElementPtrInst *gep = dyn_cast(II++)) // pre-inc if (gep->getNumIndices() >= 2) changed |= DecomposeArrayRef(gep); // always modifies II return changed; Index: llvm/lib/Transforms/Scalar/IndVarSimplify.cpp diff -u llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1.32 llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1.33 --- llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1.32 Mon Oct 21 15:00:26 2002 +++ llvm/lib/Transforms/Scalar/IndVarSimplify.cpp Wed Apr 23 11:37:42 2003 @@ -45,7 +45,7 @@ // std::vector IndVars; // Induction variables for block BasicBlock::iterator AfterPHIIt = Header->begin(); - for (; PHINode *PN = dyn_cast(&*AfterPHIIt); ++AfterPHIIt) + for (; PHINode *PN = dyn_cast(AfterPHIIt); ++AfterPHIIt) IndVars.push_back(InductionVariable(PN, Loops)); // AfterPHIIt now points to first nonphi instruction... Index: llvm/lib/Transforms/Scalar/LICM.cpp diff -u llvm/lib/Transforms/Scalar/LICM.cpp:1.26 llvm/lib/Transforms/Scalar/LICM.cpp:1.27 --- llvm/lib/Transforms/Scalar/LICM.cpp:1.26 Mon Mar 3 17:32:45 2003 +++ llvm/lib/Transforms/Scalar/LICM.cpp Wed Apr 23 11:37:42 2003 @@ -319,12 +319,12 @@ // Rewrite all loads and stores in the block of the pointer... for (BasicBlock::iterator II = (*I)->begin(), E = (*I)->end(); II != E; ++II) { - if (LoadInst *L = dyn_cast(&*II)) { + if (LoadInst *L = dyn_cast(II)) { std::map::iterator I = ValueToAllocaMap.find(L->getOperand(0)); if (I != ValueToAllocaMap.end()) L->setOperand(0, I->second); // Rewrite load instruction... - } else if (StoreInst *S = dyn_cast(&*II)) { + } else if (StoreInst *S = dyn_cast(II)) { std::map::iterator I = ValueToAllocaMap.find(S->getOperand(1)); if (I != ValueToAllocaMap.end()) Index: llvm/lib/Transforms/Scalar/LoopPreheaders.cpp diff -u llvm/lib/Transforms/Scalar/LoopPreheaders.cpp:1.10 llvm/lib/Transforms/Scalar/LoopPreheaders.cpp:1.11 --- llvm/lib/Transforms/Scalar/LoopPreheaders.cpp:1.10 Fri Feb 28 10:54:17 2003 +++ llvm/lib/Transforms/Scalar/LoopPreheaders.cpp Wed Apr 23 11:37:42 2003 @@ -132,7 +132,7 @@ // if (!Preds.empty()) { // Is the loop not obviously dead? for (BasicBlock::iterator I = BB->begin(); - PHINode *PN = dyn_cast(&*I); ++I) { + PHINode *PN = dyn_cast(I); ++I) { // Create the new PHI node, insert it into NewBB at the end of the block PHINode *NewPHI = new PHINode(PN->getType(), PN->getName()+".ph", BI); @@ -160,7 +160,7 @@ } else { // Otherwise the loop is dead... for (BasicBlock::iterator I = BB->begin(); - PHINode *PN = dyn_cast(&*I); ++I) + PHINode *PN = dyn_cast(I); ++I) // Insert dummy values as the incoming value... PN->addIncoming(Constant::getNullValue(PN->getType()), NewBB); } Index: llvm/lib/Transforms/Scalar/LowerAllocations.cpp diff -u llvm/lib/Transforms/Scalar/LowerAllocations.cpp:1.34 llvm/lib/Transforms/Scalar/LowerAllocations.cpp:1.35 --- llvm/lib/Transforms/Scalar/LowerAllocations.cpp:1.34 Wed Apr 23 11:18:14 2003 +++ llvm/lib/Transforms/Scalar/LowerAllocations.cpp Wed Apr 23 11:37:42 2003 @@ -85,7 +85,7 @@ // Loop over all of the instructions, looking for malloc or free instructions for (BasicBlock::iterator I = BB.begin(), E = BB.end(); I != E; ++I) { - if (MallocInst *MI = dyn_cast(&*I)) { + if (MallocInst *MI = dyn_cast(I)) { const Type *AllocTy = MI->getType()->getElementType(); // Get the number of bytes to be allocated for one element of the @@ -114,7 +114,7 @@ I = --BBIL.erase(I); // remove and delete the malloc instr... Changed = true; ++NumLowered; - } else if (FreeInst *FI = dyn_cast(&*I)) { + } else if (FreeInst *FI = dyn_cast(I)) { // Cast the argument to free into a ubyte*... CastInst *MCast = new CastInst(FI->getOperand(0), PointerType::get(Type::UByteTy), "", I); Index: llvm/lib/Transforms/Scalar/Mem2Reg.cpp diff -u llvm/lib/Transforms/Scalar/Mem2Reg.cpp:1.2 llvm/lib/Transforms/Scalar/Mem2Reg.cpp:1.3 --- llvm/lib/Transforms/Scalar/Mem2Reg.cpp:1.2 Mon Mar 3 11:25:16 2003 +++ llvm/lib/Transforms/Scalar/Mem2Reg.cpp Wed Apr 23 11:37:42 2003 @@ -43,7 +43,7 @@ // Find allocas that are safe to promote, by looking at all instructions in // the entry node for (BasicBlock::iterator I = BB.begin(), E = --BB.end(); I != E; ++I) - if (AllocaInst *AI = dyn_cast(&*I)) // Is it an alloca? + if (AllocaInst *AI = dyn_cast(I)) // Is it an alloca? if (isAllocaPromotable(AI, TD)) Allocas.push_back(AI); Index: llvm/lib/Transforms/Scalar/Reassociate.cpp diff -u llvm/lib/Transforms/Scalar/Reassociate.cpp:1.16 llvm/lib/Transforms/Scalar/Reassociate.cpp:1.17 --- llvm/lib/Transforms/Scalar/Reassociate.cpp:1.16 Mon Feb 24 14:48:30 2003 +++ llvm/lib/Transforms/Scalar/Reassociate.cpp Wed Apr 23 11:37:42 2003 @@ -224,7 +224,7 @@ // the two operands are sorted incorrectly, fix it now. // if (BI->isAssociative()) { - BinaryOperator *I = cast(&*BI); + BinaryOperator *I = cast(BI); if (!I->use_empty()) { // Make sure that we don't have a tree-shaped computation. If we do, // linearize it. Convert (A+B)+(C+D) into ((A+B)+C)+D Index: llvm/lib/Transforms/Scalar/SCCP.cpp diff -u llvm/lib/Transforms/Scalar/SCCP.cpp:1.64 llvm/lib/Transforms/Scalar/SCCP.cpp:1.65 --- llvm/lib/Transforms/Scalar/SCCP.cpp:1.64 Sun Nov 3 20:54:22 2002 +++ llvm/lib/Transforms/Scalar/SCCP.cpp Wed Apr 23 11:37:42 2003 @@ -474,7 +474,7 @@ // constant now may not be. // for (BasicBlock::iterator I = Succ->begin(); - PHINode *PN = dyn_cast(&*I); ++I) + PHINode *PN = dyn_cast(I); ++I) visitPHINode(*PN); } } From lattner at cs.uiuc.edu Wed Apr 23 11:38:14 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Apr 23 11:38:14 2003 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp SimplifyCFG.cpp Message-ID: <200304231637.LAA24180@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Utils: BreakCriticalEdges.cpp updated: 1.8 -> 1.9 SimplifyCFG.cpp updated: 1.10 -> 1.11 --- Log message: Remove unnecesary &*'s --- Diffs of the changes: Index: llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp diff -u llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp:1.8 llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp:1.9 --- llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp:1.8 Wed Oct 30 20:44:36 2002 +++ llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp Wed Apr 23 11:37:43 2003 @@ -85,7 +85,7 @@ // merge incoming values from NewBB instead of from TIBB. // for (BasicBlock::iterator I = DestBB->begin(); - PHINode *PN = dyn_cast(&*I); ++I) { + PHINode *PN = dyn_cast(I); ++I) { // We no longer enter through TIBB, now we come in through NewBB. PN->replaceUsesOfWith(TIBB, NewBB); } Index: llvm/lib/Transforms/Utils/SimplifyCFG.cpp diff -u llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.10 llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.11 --- llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.10 Fri Mar 7 12:13:41 2003 +++ llvm/lib/Transforms/Utils/SimplifyCFG.cpp Wed Apr 23 11:37:44 2003 @@ -40,7 +40,7 @@ // Loop over all of the PHI nodes checking to see if there are // incompatible values coming in. for (BasicBlock::iterator I = Succ->begin(); - PHINode *PN = dyn_cast(&*I); ++I) { + PHINode *PN = dyn_cast(I); ++I) { // Loop up the entries in the PHI node for BB and for *PI if the values // coming in are non-equal, we cannot merge these two blocks (instead we // should insert a conditional move or something, then merge the @@ -56,7 +56,7 @@ // Loop over all of the PHI nodes in the successor BB for (BasicBlock::iterator I = Succ->begin(); - PHINode *PN = dyn_cast(&*I); ++I) { + PHINode *PN = dyn_cast(I); ++I) { Value *OldVal = PN->removeIncomingValue(BB, false); assert(OldVal && "No entry in PHI for Pred BB!"); From lattner at cs.uiuc.edu Wed Apr 23 11:38:16 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Apr 23 11:38:16 2003 Subject: [llvm-commits] CVS: llvm/lib/VMCore/BasicBlock.cpp Message-ID: <200304231637.LAA24187@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: BasicBlock.cpp updated: 1.29 -> 1.30 --- Log message: Remove unnecesary &*'s --- Diffs of the changes: Index: llvm/lib/VMCore/BasicBlock.cpp diff -u llvm/lib/VMCore/BasicBlock.cpp:1.29 llvm/lib/VMCore/BasicBlock.cpp:1.30 --- llvm/lib/VMCore/BasicBlock.cpp:1.29 Wed Nov 20 12:33:41 2002 +++ llvm/lib/VMCore/BasicBlock.cpp Wed Apr 23 11:37:45 2003 @@ -196,7 +196,7 @@ } else { // Okay, now we know that we need to remove predecessor #pred_idx from all // PHI nodes. Iterate over each PHI node fixing them up - for (iterator II = begin(); PHINode *PN = dyn_cast(&*II); ++II) + for (iterator II = begin(); PHINode *PN = dyn_cast(II); ++II) PN->removeIncomingValue(Pred); } } @@ -243,7 +243,7 @@ // incoming values... BasicBlock *Successor = *I; for (BasicBlock::iterator II = Successor->begin(); - PHINode *PN = dyn_cast(&*II); ++II) { + PHINode *PN = dyn_cast(II); ++II) { int IDX = PN->getBasicBlockIndex(this); while (IDX != -1) { PN->setIncomingBlock((unsigned)IDX, New); From lattner at cs.uiuc.edu Wed Apr 23 11:39:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Apr 23 11:39:01 2003 Subject: [llvm-commits] CVS: llvm/tools/bugpoint/TestPasses.cpp Message-ID: <200304231638.LAA24245@apoc.cs.uiuc.edu> Changes in directory llvm/tools/bugpoint: TestPasses.cpp updated: 1.1 -> 1.2 --- Log message: Remove unnecessary &* --- Diffs of the changes: Index: llvm/tools/bugpoint/TestPasses.cpp diff -u llvm/tools/bugpoint/TestPasses.cpp:1.1 llvm/tools/bugpoint/TestPasses.cpp:1.2 --- llvm/tools/bugpoint/TestPasses.cpp:1.1 Wed Nov 20 16:28:10 2002 +++ llvm/tools/bugpoint/TestPasses.cpp Wed Apr 23 11:38:00 2003 @@ -39,7 +39,7 @@ class DeleteCalls : public BasicBlockPass { bool runOnBasicBlock(BasicBlock &BB) { for (BasicBlock::iterator I = BB.begin(), E = BB.end(); I != E; ++I) - if (CallInst *CI = dyn_cast(&*I)) { + if (CallInst *CI = dyn_cast(I)) { if (!CI->use_empty()) CI->replaceAllUsesWith(Constant::getNullValue(CI->getType())); CI->getParent()->getInstList().erase(CI); From lattner at cs.uiuc.edu Wed Apr 23 11:44:00 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Apr 23 11:44:00 2003 Subject: [llvm-commits] CVS: llvm/tools/lli/Makefile Message-ID: <200304231643.LAA25108@apoc.cs.uiuc.edu> Changes in directory llvm/tools/lli: Makefile updated: 1.22 -> 1.23 --- Log message: We now need to link libscalar to get the switch lowering pass --- Diffs of the changes: Index: llvm/tools/lli/Makefile diff -u llvm/tools/lli/Makefile:1.22 llvm/tools/lli/Makefile:1.23 --- llvm/tools/lli/Makefile:1.22 Wed Jan 22 09:41:10 2003 +++ llvm/tools/lli/Makefile Wed Apr 23 11:43:02 2003 @@ -3,8 +3,8 @@ PARALLEL_DIRS = Interpreter JIT JITLIBS = lli-jit codegen x86 -USEDLIBS = lli-interpreter $(JITLIBS) bcreader vmcore analysis.a support.a target.a -#transforms.a +USEDLIBS = lli-interpreter $(JITLIBS) bcreader vmcore scalaropts.a \ + analysis.a support.a target.a # Have gcc tell the linker to export symbols from the program so that # dynamically loaded modules can be linked against them. From lattner at cs.uiuc.edu Wed Apr 23 12:23:02 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Apr 23 12:23:02 2003 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/InstSelectSimple.cpp Message-ID: <200304231722.MAA26861@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: InstSelectSimple.cpp updated: 1.87 -> 1.88 --- Log message: Implement the constantexpr CAST instruction correctly --- Diffs of the changes: Index: llvm/lib/Target/X86/InstSelectSimple.cpp diff -u llvm/lib/Target/X86/InstSelectSimple.cpp:1.87 llvm/lib/Target/X86/InstSelectSimple.cpp:1.88 --- llvm/lib/Target/X86/InstSelectSimple.cpp:1.87 Tue Apr 22 12:54:23 2003 +++ llvm/lib/Target/X86/InstSelectSimple.cpp Wed Apr 23 12:22:12 2003 @@ -192,6 +192,11 @@ Value *Src, User::op_iterator IdxBegin, User::op_iterator IdxEnd, unsigned TargetReg); + /// emitCastOperation - Common code shared between visitCastInst and + /// constant expression cast support. + void emitCastOperation(MachineBasicBlock *BB,MachineBasicBlock::iterator&IP, + Value *Src, const Type *DestTy, unsigned TargetReg); + /// copyConstantToRegister - Output the instructions required to put the /// specified constant into the specified register. /// @@ -307,10 +312,8 @@ emitGEPOperation(MBB, IP, CE->getOperand(0), CE->op_begin()+1, CE->op_end(), R); return; - } else if (CE->getOpcode() == Instruction::Cast && - isa(CE->getType()) && - isa(CE->getOperand(0)->getType())) { - copyConstantToRegister(MBB, IP, cast(CE->getOperand(0)), R); + } else if (CE->getOpcode() == Instruction::Cast) { + emitCastOperation(MBB, IP, CE->getOperand(0), CE->getType(), R); return; } @@ -446,7 +449,7 @@ // Loop over all of the PHI nodes in the LLVM basic block... unsigned NumPHIs = 0; for (BasicBlock::const_iterator I = BB->begin(); - PHINode *PN = (PHINode*)dyn_cast(&*I); ++I) { + PHINode *PN = (PHINode*)dyn_cast(I); ++I) { // Create a new machine instr PHI node, and insert it. unsigned PHIReg = getReg(*PN); @@ -1387,22 +1390,30 @@ /// visitCastInst - Here we have various kinds of copying with or without /// sign extension going on. void ISel::visitCastInst(CastInst &CI) { - const Type *DestTy = CI.getType(); - Value *Src = CI.getOperand(0); + unsigned DestReg = getReg(CI); + MachineBasicBlock::iterator MI = BB->end(); + emitCastOperation(BB, MI, CI.getOperand(0), CI.getType(), DestReg); +} + +/// emitCastOperation - Common code shared between visitCastInst and +/// constant expression cast support. +void ISel::emitCastOperation(MachineBasicBlock *BB, + MachineBasicBlock::iterator &IP, + Value *Src, const Type *DestTy, + unsigned DestReg) { unsigned SrcReg = getReg(Src); const Type *SrcTy = Src->getType(); unsigned SrcClass = getClassB(SrcTy); - unsigned DestReg = getReg(CI); unsigned DestClass = getClassB(DestTy); // Implement casts to bool by using compare on the operand followed by set if // not zero on the result. if (DestTy == Type::BoolTy) { if (SrcClass == cFP || SrcClass == cLong) - visitInstruction(CI); + abort(); // FIXME: implement cast (long & FP) to bool - BuildMI(BB, X86::CMPri8, 2).addReg(SrcReg).addZImm(0); - BuildMI(BB, X86::SETNEr, 1, DestReg); + BMI(BB, IP, X86::CMPri8, 2).addReg(SrcReg).addZImm(0); + BMI(BB, IP, X86::SETNEr, 1, DestReg); return; } @@ -1414,11 +1425,11 @@ // getClass) by using a register-to-register move. if (SrcClass == DestClass) { if (SrcClass <= cInt || (SrcClass == cFP && SrcTy == DestTy)) { - BuildMI(BB, RegRegMove[SrcClass], 1, DestReg).addReg(SrcReg); + BMI(BB, IP, RegRegMove[SrcClass], 1, DestReg).addReg(SrcReg); } else if (SrcClass == cFP) { if (SrcTy == Type::FloatTy) { // double -> float assert(DestTy == Type::DoubleTy && "Unknown cFP member!"); - BuildMI(BB, X86::FpMOV, 1, DestReg).addReg(SrcReg); + BMI(BB, IP, X86::FpMOV, 1, DestReg).addReg(SrcReg); } else { // float -> double assert(SrcTy == Type::DoubleTy && DestTy == Type::FloatTy && "Unknown cFP member!"); @@ -1426,14 +1437,14 @@ // reading it back. unsigned FltAlign = TM.getTargetData().getFloatAlignment(); int FrameIdx = F->getFrameInfo()->CreateStackObject(4, FltAlign); - addFrameReference(BuildMI(BB, X86::FSTr32, 5), FrameIdx).addReg(SrcReg); - addFrameReference(BuildMI(BB, X86::FLDr32, 5, DestReg), FrameIdx); + addFrameReference(BMI(BB, IP, X86::FSTr32, 5), FrameIdx).addReg(SrcReg); + addFrameReference(BMI(BB, IP, X86::FLDr32, 5, DestReg), FrameIdx); } } else if (SrcClass == cLong) { - BuildMI(BB, X86::MOVrr32, 1, DestReg).addReg(SrcReg); - BuildMI(BB, X86::MOVrr32, 1, DestReg+1).addReg(SrcReg+1); + BMI(BB, IP, X86::MOVrr32, 1, DestReg).addReg(SrcReg); + BMI(BB, IP, X86::MOVrr32, 1, DestReg+1).addReg(SrcReg+1); } else { - visitInstruction(CI); + abort(); } return; } @@ -1451,21 +1462,21 @@ }; bool isUnsigned = SrcTy->isUnsigned(); - BuildMI(BB, Opc[isUnsigned][SrcClass + DestClass - 1], 1, - DestReg).addReg(SrcReg); + BMI(BB, IP, Opc[isUnsigned][SrcClass + DestClass - 1], 1, + DestReg).addReg(SrcReg); if (isLong) { // Handle upper 32 bits as appropriate... if (isUnsigned) // Zero out top bits... - BuildMI(BB, X86::MOVir32, 1, DestReg+1).addZImm(0); + BMI(BB, IP, X86::MOVir32, 1, DestReg+1).addZImm(0); else // Sign extend bottom half... - BuildMI(BB, X86::SARir32, 2, DestReg+1).addReg(DestReg).addZImm(31); + BMI(BB, IP, X86::SARir32, 2, DestReg+1).addReg(DestReg).addZImm(31); } return; } // Special case long -> int ... if (SrcClass == cLong && DestClass == cInt) { - BuildMI(BB, X86::MOVrr32, 1, DestReg).addReg(SrcReg); + BMI(BB, IP, X86::MOVrr32, 1, DestReg).addReg(SrcReg); return; } @@ -1474,8 +1485,8 @@ if ((SrcClass <= cInt || SrcClass == cLong) && DestClass <= cInt && SrcClass > DestClass) { static const unsigned AReg[] = { X86::AL, X86::AX, X86::EAX, 0, X86::EAX }; - BuildMI(BB, RegRegMove[SrcClass], 1, AReg[SrcClass]).addReg(SrcReg); - BuildMI(BB, RegRegMove[DestClass], 1, DestReg).addReg(AReg[DestClass]); + BMI(BB, IP, RegRegMove[SrcClass], 1, AReg[SrcClass]).addReg(SrcReg); + BMI(BB, IP, RegRegMove[DestClass], 1, DestReg).addReg(AReg[DestClass]); return; } @@ -1484,14 +1495,14 @@ // unsigned int -> load as 64 bit int. // unsigned long long -> more complex if (SrcTy->isUnsigned() && SrcTy != Type::UByteTy) - visitInstruction(CI); // don't handle unsigned src yet! + abort(); // don't handle unsigned src yet! // We don't have the facilities for directly loading byte sized data from // memory. Promote it to 16 bits. if (SrcClass == cByte) { unsigned TmpReg = makeAnotherReg(Type::ShortTy); - BuildMI(BB, SrcTy->isSigned() ? X86::MOVSXr16r8 : X86::MOVZXr16r8, - 1, TmpReg).addReg(SrcReg); + BMI(BB, IP, SrcTy->isSigned() ? X86::MOVSXr16r8 : X86::MOVZXr16r8, + 1, TmpReg).addReg(SrcReg); SrcTy = Type::ShortTy; // Pretend the short is our input now! SrcClass = cShort; SrcReg = TmpReg; @@ -1502,18 +1513,18 @@ F->getFrameInfo()->CreateStackObject(SrcTy, TM.getTargetData()); if (SrcClass == cLong) { - if (SrcTy == Type::ULongTy) visitInstruction(CI); - addFrameReference(BuildMI(BB, X86::MOVrm32, 5), FrameIdx).addReg(SrcReg); - addFrameReference(BuildMI(BB, X86::MOVrm32, 5), + if (SrcTy == Type::ULongTy) abort(); // FIXME: Handle ulong -> FP + addFrameReference(BMI(BB, IP, X86::MOVrm32, 5), FrameIdx).addReg(SrcReg); + addFrameReference(BMI(BB, IP, X86::MOVrm32, 5), FrameIdx, 4).addReg(SrcReg+1); } else { static const unsigned Op1[] = { X86::MOVrm8, X86::MOVrm16, X86::MOVrm32 }; - addFrameReference(BuildMI(BB, Op1[SrcClass], 5), FrameIdx).addReg(SrcReg); + addFrameReference(BMI(BB, IP, Op1[SrcClass], 5), FrameIdx).addReg(SrcReg); } static const unsigned Op2[] = { 0, X86::FILDr16, X86::FILDr32, 0, X86::FILDr64 }; - addFrameReference(BuildMI(BB, Op2[SrcClass], 5, DestReg), FrameIdx); + addFrameReference(BMI(BB, IP, Op2[SrcClass], 5, DestReg), FrameIdx); return; } @@ -1523,20 +1534,20 @@ // mode when truncating to an integer value. // int CWFrameIdx = F->getFrameInfo()->CreateStackObject(2, 2); - addFrameReference(BuildMI(BB, X86::FNSTCWm16, 4), CWFrameIdx); + addFrameReference(BMI(BB, IP, X86::FNSTCWm16, 4), CWFrameIdx); // Load the old value of the high byte of the control word... unsigned HighPartOfCW = makeAnotherReg(Type::UByteTy); - addFrameReference(BuildMI(BB, X86::MOVmr8, 4, HighPartOfCW), CWFrameIdx, 1); + addFrameReference(BMI(BB, IP, X86::MOVmr8, 4, HighPartOfCW), CWFrameIdx, 1); // Set the high part to be round to zero... - addFrameReference(BuildMI(BB, X86::MOVim8, 5), CWFrameIdx, 1).addZImm(12); + addFrameReference(BMI(BB, IP, X86::MOVim8, 5), CWFrameIdx, 1).addZImm(12); // Reload the modified control word now... - addFrameReference(BuildMI(BB, X86::FLDCWm16, 4), CWFrameIdx); + addFrameReference(BMI(BB, IP, X86::FLDCWm16, 4), CWFrameIdx); // Restore the memory image of control word to original value - addFrameReference(BuildMI(BB, X86::MOVrm8, 5), + addFrameReference(BMI(BB, IP, X86::MOVrm8, 5), CWFrameIdx, 1).addReg(HighPartOfCW); // We don't have the facilities for directly storing byte sized data to @@ -1549,7 +1560,7 @@ case cByte: StoreTy = Type::ShortTy; StoreClass = cShort; break; case cShort: StoreTy = Type::IntTy; StoreClass = cInt; break; case cInt: StoreTy = Type::LongTy; StoreClass = cLong; break; - case cLong: visitInstruction(CI); // unsigned long long -> more complex + case cLong: abort(); // FIXME: unsigned long long -> more complex default: assert(0 && "Unknown store class!"); } @@ -1559,23 +1570,23 @@ static const unsigned Op1[] = { 0, X86::FISTr16, X86::FISTr32, 0, X86::FISTPr64 }; - addFrameReference(BuildMI(BB, Op1[StoreClass], 5), FrameIdx).addReg(SrcReg); + addFrameReference(BMI(BB, IP, Op1[StoreClass], 5), FrameIdx).addReg(SrcReg); if (DestClass == cLong) { - addFrameReference(BuildMI(BB, X86::MOVmr32, 4, DestReg), FrameIdx); - addFrameReference(BuildMI(BB, X86::MOVmr32, 4, DestReg+1), FrameIdx, 4); + addFrameReference(BMI(BB, IP, X86::MOVmr32, 4, DestReg), FrameIdx); + addFrameReference(BMI(BB, IP, X86::MOVmr32, 4, DestReg+1), FrameIdx, 4); } else { static const unsigned Op2[] = { X86::MOVmr8, X86::MOVmr16, X86::MOVmr32 }; - addFrameReference(BuildMI(BB, Op2[DestClass], 4, DestReg), FrameIdx); + addFrameReference(BMI(BB, IP, Op2[DestClass], 4, DestReg), FrameIdx); } // Reload the original control word now... - addFrameReference(BuildMI(BB, X86::FLDCWm16, 4), CWFrameIdx); + addFrameReference(BMI(BB, IP, X86::FLDCWm16, 4), CWFrameIdx); return; } // Anything we haven't handled already, we can't (yet) handle at all. - visitInstruction (CI); + abort(); } // ExactLog2 - This function solves for (Val == 1 << (N-1)) and returns N. It From lattner at cs.uiuc.edu Wed Apr 23 12:58:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Apr 23 12:58:01 2003 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/InstSelectSimple.cpp Message-ID: <200304231757.MAA27471@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: InstSelectSimple.cpp updated: 1.88 -> 1.89 --- Log message: Fix iterator invalidation problem with cast instructions --- Diffs of the changes: Index: llvm/lib/Target/X86/InstSelectSimple.cpp diff -u llvm/lib/Target/X86/InstSelectSimple.cpp:1.88 llvm/lib/Target/X86/InstSelectSimple.cpp:1.89 --- llvm/lib/Target/X86/InstSelectSimple.cpp:1.88 Wed Apr 23 12:22:12 2003 +++ llvm/lib/Target/X86/InstSelectSimple.cpp Wed Apr 23 12:57:48 2003 @@ -1401,7 +1401,7 @@ MachineBasicBlock::iterator &IP, Value *Src, const Type *DestTy, unsigned DestReg) { - unsigned SrcReg = getReg(Src); + unsigned SrcReg = getReg(Src, BB, IP); const Type *SrcTy = Src->getType(); unsigned SrcClass = getClassB(SrcTy); unsigned DestClass = getClassB(DestTy); From lattner at cs.uiuc.edu Wed Apr 23 13:39:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Apr 23 13:39:01 2003 Subject: [llvm-commits] CVS: llvm/test/Regression/Linker/2003-04-23-LinkOnceLost.ll Message-ID: <200304231838.NAA30641@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Linker: 2003-04-23-LinkOnceLost.ll added (r1.1) --- Log message: New testcase --- Diffs of the changes: Index: llvm/test/Regression/Linker/2003-04-23-LinkOnceLost.ll diff -c /dev/null llvm/test/Regression/Linker/2003-04-23-LinkOnceLost.ll:1.1 *** /dev/null Wed Apr 23 13:38:34 2003 --- llvm/test/Regression/Linker/2003-04-23-LinkOnceLost.ll Wed Apr 23 13:38:24 2003 *************** *** 0 **** --- 1,8 ---- + ; This fails because the linker renames the non-opaque type not the opaque + ; one... + + ; RUN: echo "implementation linkonce void %foo() { ret void } " | as > Output/%s.2.bc + ; RUN: as < %s > Output/%s.1.bc + ; RUN: link Output/%s.[12].bc | dis | grep foo | grep linkonce + + declare void %foo() From lattner at cs.uiuc.edu Wed Apr 23 13:39:04 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Apr 23 13:39:04 2003 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Utils/Linker.cpp Message-ID: <200304231838.NAA30658@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Utils: Linker.cpp updated: 1.41 -> 1.42 --- Log message: Fix Bug: Linker/2003-04-23-LinkOnceLost.ll --- Diffs of the changes: Index: llvm/lib/Transforms/Utils/Linker.cpp diff -u llvm/lib/Transforms/Utils/Linker.cpp:1.41 llvm/lib/Transforms/Utils/Linker.cpp:1.42 --- llvm/lib/Transforms/Utils/Linker.cpp:1.41 Tue Apr 22 14:13:20 2003 +++ llvm/lib/Transforms/Utils/Linker.cpp Wed Apr 23 13:38:39 2003 @@ -230,11 +230,26 @@ // Make sure to remember this mapping... ValueMap.insert(std::make_pair(SGV, NewDGV)); - } else if (!SGExtern && !DGExtern && SGV->getLinkage() !=DGV->getLinkage()){ + } else if (SGV->isExternal()) { + // If SGV is external or if both SGV & DGV are external.. Just link the + // external globals, we aren't adding anything. + ValueMap.insert(std::make_pair(SGV, DGV)); + + } else if (DGV->isExternal()) { // If DGV is external but SGV is not... + ValueMap.insert(std::make_pair(SGV, DGV)); + DGV->setLinkage(SGV->getLinkage()); // Inherit linkage! + } else if (SGV->getLinkage() != DGV->getLinkage()) { return Error(Err, "Global variables named '" + SGV->getName() + "' have different linkage specifiers!"); - } else if (SGV->hasExternalLinkage() || SGV->hasLinkOnceLinkage() || - SGV->hasAppendingLinkage()) { + } else if (SGV->hasExternalLinkage()) { + // Allow linking two exactly identical external global variables... + if (SGV->isConstant() != DGV->isConstant() || + SGV->getInitializer() != DGV->getInitializer()) + return Error(Err, "Global Variable Collision on '" + + SGV->getType()->getDescription() + " %" + SGV->getName() + + "' - Global variables differ in const'ness"); + ValueMap.insert(std::make_pair(SGV, DGV)); + } else if (SGV->hasLinkOnceLinkage()) { // If the global variable has a name, and that name is already in use in // the Dest module, make sure that the name is a compatible global // variable... @@ -242,13 +257,13 @@ // Check to see if the two GV's have the same Const'ness... if (SGV->isConstant() != DGV->isConstant()) return Error(Err, "Global Variable Collision on '" + - SGV->getType()->getDescription() + "':%" + SGV->getName() + - " - Global variables differ in const'ness"); - if (DGExtern) - DGV->setLinkage(SGV->getLinkage()); + SGV->getType()->getDescription() + " %" + SGV->getName() + + "' - Global variables differ in const'ness"); // Okay, everything is cool, remember the mapping... ValueMap.insert(std::make_pair(SGV, DGV)); + } else if (SGV->hasAppendingLinkage()) { + assert(0 && "FIXME: Appending linkage unimplemented!"); } else { assert(0 && "Unknown linkage!"); } @@ -321,9 +336,6 @@ // DF = cast_or_null(ST->lookup(SF->getType(), SF->getName())); - bool SFExtern = SF->isExternal(); - bool DFExtern = DF ? DF->isExternal() : false; - if (!DF || SF->hasInternalLinkage() || DF->hasInternalLinkage()) { // Function does not already exist, simply insert an function signature // identical to SF into the dest module... @@ -344,30 +356,28 @@ // ... and remember this mapping... ValueMap.insert(std::make_pair(SF, NewDF)); - } else if (SF->getLinkage() == GlobalValue::AppendingLinkage) { - return Error(Err, "Functions named '" + SF->getName() + - "' have appending linkage!"); - } else if (!SFExtern && !DFExtern && SF->getLinkage() != DF->getLinkage()) { + } else if (SF->isExternal()) { + // If SF is external or if both SF & DF are external.. Just link the + // external functions, we aren't adding anything. + ValueMap.insert(std::make_pair(SF, DF)); + } else if (DF->isExternal()) { // If DF is external but SF is not... + // Link the external functions, update linkage qualifiers + ValueMap.insert(std::make_pair(SF, DF)); + DF->setLinkage(SF->getLinkage()); + + } else if (SF->getLinkage() != DF->getLinkage()) { return Error(Err, "Functions named '" + SF->getName() + "' have different linkage specifiers!"); - } else if (SF->getLinkage() == GlobalValue::ExternalLinkage) { - // If the function has a name, and that name is already in use in the Dest - // module, make sure that the name is a compatible function... - // - // Check to make sure the function is not defined in both modules... - if (!SF->isExternal() && !DF->isExternal()) - return Error(Err, "Function '" + - SF->getFunctionType()->getDescription() + "':\"" + - SF->getName() + "\" - Function is already defined!"); - - if (DFExtern) - DF->setLinkage(SF->getLinkage()); - - // Otherwise, just remember this mapping... - ValueMap.insert(std::make_pair(SF, DF)); - } else if (SF->getLinkage() == GlobalValue::LinkOnceLinkage) { + } else if (SF->hasExternalLinkage()) { + // The function is defined in both modules!! + return Error(Err, "Function '" + + SF->getFunctionType()->getDescription() + "':\"" + + SF->getName() + "\" - Function is already defined!"); + } else if (SF->hasLinkOnceLinkage()) { // Completely ignore the source function. ValueMap.insert(std::make_pair(SF, DF)); + } else { + assert(0 && "Unknown linkage configuration found!"); } } return false; From lattner at cs.uiuc.edu Wed Apr 23 13:39:07 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Apr 23 13:39:07 2003 Subject: [llvm-commits] CVS: llvm/test/Regression/Linker/testlink1.ll testlink2.ll Message-ID: <200304231838.NAA30665@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Linker: testlink1.ll updated: 1.7 -> 1.8 testlink2.ll updated: 1.8 -> 1.9 --- Log message: Tweak testcases to use linkonce as appropriate --- Diffs of the changes: Index: llvm/test/Regression/Linker/testlink1.ll diff -u llvm/test/Regression/Linker/testlink1.ll:1.7 llvm/test/Regression/Linker/testlink1.ll:1.8 --- llvm/test/Regression/Linker/testlink1.ll:1.7 Mon Apr 21 16:06:25 2003 +++ llvm/test/Regression/Linker/testlink1.ll Wed Apr 23 13:38:13 2003 @@ -12,7 +12,7 @@ %Intern2 = internal constant int 792 ; Initialized to point to external %MyVar -%MyVarPtr = global { int * } { int * %MyVar } +%MyVarPtr = linkonce global { int * } { int * %MyVar } declare int "foo"(int %blah) ;; Declared in testlink2.ll Index: llvm/test/Regression/Linker/testlink2.ll diff -u llvm/test/Regression/Linker/testlink2.ll:1.8 llvm/test/Regression/Linker/testlink2.ll:1.9 --- llvm/test/Regression/Linker/testlink2.ll:1.8 Mon Apr 21 16:06:25 2003 +++ llvm/test/Regression/Linker/testlink2.ll Wed Apr 23 13:38:13 2003 @@ -11,7 +11,7 @@ %Intern2 = constant int 12345 ;; Intern in one but not in other %MyIntListPtr = constant { {\2,int}* } { {\2,int}* %MyIntList } -%MyVarPtr = global { int * } { int * %MyVar } +%MyVarPtr = linkonce global { int * } { int * %MyVar } constant int 412 From lattner at cs.uiuc.edu Wed Apr 23 14:02:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Apr 23 14:02:01 2003 Subject: [llvm-commits] CVS: llvm/tools/lli/ExecutionEngine.cpp Message-ID: <200304231901.OAA31362@apoc.cs.uiuc.edu> Changes in directory llvm/tools/lli: ExecutionEngine.cpp updated: 1.5 -> 1.6 --- Log message: * Implement access to external variables in LLI * Implement GetElementPtr constant expressions when initializing global variables --- Diffs of the changes: Index: llvm/tools/lli/ExecutionEngine.cpp diff -u llvm/tools/lli/ExecutionEngine.cpp:1.5 llvm/tools/lli/ExecutionEngine.cpp:1.6 --- llvm/tools/lli/ExecutionEngine.cpp:1.5 Mon Apr 21 17:44:36 2003 +++ llvm/tools/lli/ExecutionEngine.cpp Wed Apr 23 14:01:49 2003 @@ -12,6 +12,7 @@ #include "llvm/Module.h" #include "llvm/Target/TargetData.h" #include "Support/Statistic.h" +#include Statistic<> NumInitBytes("lli", "Number of bytes of global vars initialized"); @@ -29,10 +30,28 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) { GenericValue Result; -#define GET_CONST_VAL(TY, CLASS) \ - case Type::TY##TyID: Result.TY##Val = cast(C)->getValue(); break + + if (ConstantExpr *CE = (ConstantExpr*)dyn_cast(C)) + switch (CE->getOpcode()) { + case Instruction::GetElementPtr: { + Result = getConstantValue(cast(CE->getOperand(0))); + std::vector Indexes(CE->op_begin()+1, CE->op_end()); + uint64_t Offset = + TD->getIndexedOffset(CE->getOperand(0)->getType(), Indexes); + + Result.LongVal += Offset; + return Result; + } + + default: + std::cerr << "ConstantExpr not handled as global var init: " << *CE + << "\n"; + abort(); + } switch (C->getType()->getPrimitiveID()) { +#define GET_CONST_VAL(TY, CLASS) \ + case Type::TY##TyID: Result.TY##Val = cast(C)->getValue(); break GET_CONST_VAL(Bool , ConstantBool); GET_CONST_VAL(UByte , ConstantUInt); GET_CONST_VAL(SByte , ConstantSInt); @@ -57,6 +76,7 @@ break; default: std::cout << "ERROR: Constant unimp for type: " << C->getType() << "\n"; + abort(); } return Result; } @@ -213,15 +233,16 @@ DEBUG(std::cerr << "Global '" << I->getName() << "' -> " << (void*)GlobalAddress[I] << "\n"); - } else if (I->getName() == "stdout") { - GlobalAddress[I] = &stdout; - } else if (I->getName() == "stderr") { - GlobalAddress[I] = &stderr; - } else if (I->getName() == "stdin") { - GlobalAddress[I] = &stdin; } else { - std::cerr << "Global: " << I->getName() << "\n"; - assert(0 && "References to external globals not handled yet!"); + // External variable reference, try to use dlsym to get a pointer to it in + // the LLI image. + if (void *SymAddr = dlsym(0, I->getName().c_str())) + GlobalAddress[I] = SymAddr; + else { + std::cerr << "Could not resolve external global address: " + << I->getName() << "\n"; + abort(); + } } // Now that all of the globals are set up in memory, loop through them all and From lattner at cs.uiuc.edu Wed Apr 23 14:10:03 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Apr 23 14:10:03 2003 Subject: [llvm-commits] CVS: llvm/lib/CWriter/Writer.cpp Message-ID: <200304231909.OAA31442@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CWriter: Writer.cpp updated: 1.79 -> 1.80 --- Log message: Fix the super obnoxious "cast to pointer from integer of different size" warnings --- Diffs of the changes: Index: llvm/lib/CWriter/Writer.cpp diff -u llvm/lib/CWriter/Writer.cpp:1.79 llvm/lib/CWriter/Writer.cpp:1.80 --- llvm/lib/CWriter/Writer.cpp:1.79 Wed Apr 23 11:36:08 2003 +++ llvm/lib/CWriter/Writer.cpp Wed Apr 23 14:09:22 2003 @@ -946,13 +946,8 @@ void CWriter::visitBinaryOperator(Instruction &I) { // binary instructions, shift instructions, setCond instructions. - if (isa(I.getType())) { - Out << "("; - printType(Out, I.getType()); - Out << ")"; - } + assert(!isa(I.getType())); - if (isa(I.getType())) Out << "(long long)"; writeOperand(I.getOperand(0)); switch (I.getOpcode()) { @@ -975,14 +970,20 @@ default: std::cerr << "Invalid operator type!" << I; abort(); } - if (isa(I.getType())) Out << "(long long)"; writeOperand(I.getOperand(1)); } void CWriter::visitCastInst(CastInst &I) { Out << "("; - printType(Out, I.getType(), string(""),/*ignoreName*/false, /*namedContext*/false); + printType(Out, I.getType(), string(""),/*ignoreName*/false, + /*namedContext*/false); Out << ")"; + if (isa(I.getType())&&I.getOperand(0)->getType()->isIntegral() || + isa(I.getOperand(0)->getType())&&I.getType()->isIntegral()) { + // Avoid "cast to pointer from integer of different size" warnings + Out << "(long)"; + } + writeOperand(I.getOperand(0)); } From lattner at cs.uiuc.edu Wed Apr 23 14:16:02 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Apr 23 14:16:02 2003 Subject: [llvm-commits] CVS: llvm/lib/CWriter/Writer.cpp Message-ID: <200304231915.OAA31623@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CWriter: Writer.cpp updated: 1.80 -> 1.81 --- Log message: Fix problem where labels were being incorrectly elided, and fix problem where PHI copies where not emitted for the default label of switch insts --- Diffs of the changes: Index: llvm/lib/CWriter/Writer.cpp diff -u llvm/lib/CWriter/Writer.cpp:1.80 llvm/lib/CWriter/Writer.cpp:1.81 --- llvm/lib/CWriter/Writer.cpp:1.80 Wed Apr 23 14:09:22 2003 +++ llvm/lib/CWriter/Writer.cpp Wed Apr 23 14:15:13 2003 @@ -817,7 +817,8 @@ for (Value::use_iterator UI = BB->use_begin(), UE = BB->use_end(); UI != UE; ++UI) if (TerminatorInst *TI = dyn_cast(*UI)) - if (TI != Prev->getTerminator()) { + if (TI != Prev->getTerminator() || + isa(Prev->getTerminator())) { NeedsLabel = true; break; } @@ -867,8 +868,8 @@ void CWriter::visitSwitchInst(SwitchInst &SI) { Out << " switch ("; writeOperand(SI.getOperand(0)); - Out << ") {\n default: goto "; - writeOperand(SI.getDefaultDest()); + Out << ") {\n default:\n"; + printBranchToBlock(SI.getParent(), SI.getDefaultDest(), 2); Out << ";\n"; for (unsigned i = 2, e = SI.getNumOperands(); i != e; i += 2) { Out << " case "; From lattner at cs.uiuc.edu Wed Apr 23 14:22:00 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Apr 23 14:22:00 2003 Subject: [llvm-commits] CVS: llvm/tools/lli/Interpreter/ExternalFunctions.cpp Message-ID: <200304231921.OAA31774@apoc.cs.uiuc.edu> Changes in directory llvm/tools/lli/Interpreter: ExternalFunctions.cpp updated: 1.44 -> 1.45 --- Log message: Add support for _IO_getc function used on linux --- Diffs of the changes: Index: llvm/tools/lli/Interpreter/ExternalFunctions.cpp diff -u llvm/tools/lli/Interpreter/ExternalFunctions.cpp:1.44 llvm/tools/lli/Interpreter/ExternalFunctions.cpp:1.45 --- llvm/tools/lli/Interpreter/ExternalFunctions.cpp:1.44 Mon Apr 21 17:43:20 2003 +++ llvm/tools/lli/Interpreter/ExternalFunctions.cpp Wed Apr 23 14:20:50 2003 @@ -666,6 +666,11 @@ return GV; } +// int _IO_getc(FILE *stream); +GenericValue lle_X__IO_getc(FunctionType *F, const vector &Args) { + return lle_X_getc(F, Args); +} + // int fputc(int C, FILE *stream); GenericValue lle_X_fputc(FunctionType *M, const vector &Args) { assert(Args.size() == 2); @@ -749,6 +754,7 @@ FuncNames["lle_X_fflush"] = lle_X_fflush; FuncNames["lle_X_fgetc"] = lle_X_getc; FuncNames["lle_X_getc"] = lle_X_getc; + FuncNames["lle_X__IO_getc"] = lle_X__IO_getc; FuncNames["lle_X_fputc"] = lle_X_fputc; FuncNames["lle_X_ungetc"] = lle_X_ungetc; FuncNames["lle_X_fprintf"] = lle_X_fprintf; From lattner at cs.uiuc.edu Wed Apr 23 14:22:05 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Apr 23 14:22:05 2003 Subject: [llvm-commits] CVS: llvm/tools/lli/Interpreter/Execution.cpp Message-ID: <200304231921.OAA31781@apoc.cs.uiuc.edu> Changes in directory llvm/tools/lli/Interpreter: Execution.cpp updated: 1.81 -> 1.82 --- Log message: Implement &|^ on bool values --- Diffs of the changes: Index: llvm/tools/lli/Interpreter/Execution.cpp diff -u llvm/tools/lli/Interpreter/Execution.cpp:1.81 llvm/tools/lli/Interpreter/Execution.cpp:1.82 --- llvm/tools/lli/Interpreter/Execution.cpp:1.81 Tue Apr 22 16:22:33 2003 +++ llvm/tools/lli/Interpreter/Execution.cpp Wed Apr 23 14:21:00 2003 @@ -286,6 +286,7 @@ const Type *Ty) { GenericValue Dest; switch (Ty->getPrimitiveID()) { + IMPLEMENT_BINARY_OPERATOR(&, Bool); IMPLEMENT_BINARY_OPERATOR(&, UByte); IMPLEMENT_BINARY_OPERATOR(&, SByte); IMPLEMENT_BINARY_OPERATOR(&, UShort); @@ -306,6 +307,7 @@ const Type *Ty) { GenericValue Dest; switch (Ty->getPrimitiveID()) { + IMPLEMENT_BINARY_OPERATOR(|, Bool); IMPLEMENT_BINARY_OPERATOR(|, UByte); IMPLEMENT_BINARY_OPERATOR(|, SByte); IMPLEMENT_BINARY_OPERATOR(|, UShort); @@ -326,6 +328,7 @@ const Type *Ty) { GenericValue Dest; switch (Ty->getPrimitiveID()) { + IMPLEMENT_BINARY_OPERATOR(^, Bool); IMPLEMENT_BINARY_OPERATOR(^, UByte); IMPLEMENT_BINARY_OPERATOR(^, SByte); IMPLEMENT_BINARY_OPERATOR(^, UShort); From lattner at cs.uiuc.edu Wed Apr 23 14:56:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Apr 23 14:56:01 2003 Subject: [llvm-commits] CVS: llvm/tools/lli/Interpreter/Execution.cpp Message-ID: <200304231955.OAA32185@apoc.cs.uiuc.edu> Changes in directory llvm/tools/lli/Interpreter: Execution.cpp updated: 1.82 -> 1.83 --- Log message: Fix a problem with setcc instructions and pointers --- Diffs of the changes: Index: llvm/tools/lli/Interpreter/Execution.cpp diff -u llvm/tools/lli/Interpreter/Execution.cpp:1.82 llvm/tools/lli/Interpreter/Execution.cpp:1.83 --- llvm/tools/lli/Interpreter/Execution.cpp:1.82 Wed Apr 23 14:21:00 2003 +++ llvm/tools/lli/Interpreter/Execution.cpp Wed Apr 23 14:55:35 2003 @@ -348,6 +348,15 @@ #define IMPLEMENT_SETCC(OP, TY) \ case Type::TY##TyID: Dest.BoolVal = Src1.TY##Val OP Src2.TY##Val; break +// Handle pointers specially because they must be compared with only as much +// width as the host has. We _do not_ want to be comparing 64 bit values when +// running on a 32-bit target, otherwise the upper 32 bits might mess up +// comparisons if they contain garbage. +#define IMPLEMENT_POINTERSETCC(OP) \ + case Type::PointerTyID: \ + Dest.BoolVal = (void*)(intptr_t)Src1.PointerVal OP \ + (void*)(intptr_t)Src2.PointerVal; break + static GenericValue executeSetEQInst(GenericValue Src1, GenericValue Src2, const Type *Ty) { GenericValue Dest; @@ -362,7 +371,7 @@ IMPLEMENT_SETCC(==, Long); IMPLEMENT_SETCC(==, Float); IMPLEMENT_SETCC(==, Double); - IMPLEMENT_SETCC(==, Pointer); + IMPLEMENT_POINTERSETCC(==); default: std::cout << "Unhandled type for SetEQ instruction: " << *Ty << "\n"; abort(); @@ -384,7 +393,7 @@ IMPLEMENT_SETCC(!=, Long); IMPLEMENT_SETCC(!=, Float); IMPLEMENT_SETCC(!=, Double); - IMPLEMENT_SETCC(!=, Pointer); + IMPLEMENT_POINTERSETCC(!=); default: std::cout << "Unhandled type for SetNE instruction: " << *Ty << "\n"; @@ -407,7 +416,7 @@ IMPLEMENT_SETCC(<=, Long); IMPLEMENT_SETCC(<=, Float); IMPLEMENT_SETCC(<=, Double); - IMPLEMENT_SETCC(<=, Pointer); + IMPLEMENT_POINTERSETCC(<=); default: std::cout << "Unhandled type for SetLE instruction: " << Ty << "\n"; abort(); @@ -429,7 +438,7 @@ IMPLEMENT_SETCC(>=, Long); IMPLEMENT_SETCC(>=, Float); IMPLEMENT_SETCC(>=, Double); - IMPLEMENT_SETCC(>=, Pointer); + IMPLEMENT_POINTERSETCC(>=); default: std::cout << "Unhandled type for SetGE instruction: " << *Ty << "\n"; abort(); @@ -451,7 +460,7 @@ IMPLEMENT_SETCC(<, Long); IMPLEMENT_SETCC(<, Float); IMPLEMENT_SETCC(<, Double); - IMPLEMENT_SETCC(<, Pointer); + IMPLEMENT_POINTERSETCC(<); default: std::cout << "Unhandled type for SetLT instruction: " << *Ty << "\n"; abort(); @@ -473,7 +482,7 @@ IMPLEMENT_SETCC(>, Long); IMPLEMENT_SETCC(>, Float); IMPLEMENT_SETCC(>, Double); - IMPLEMENT_SETCC(>, Pointer); + IMPLEMENT_POINTERSETCC(>); default: std::cout << "Unhandled type for SetGT instruction: " << *Ty << "\n"; abort(); From lattner at cs.uiuc.edu Wed Apr 23 14:57:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Apr 23 14:57:01 2003 Subject: [llvm-commits] CVS: llvm/tools/lli/Interpreter/ExternalFunctions.cpp Message-ID: <200304231956.OAA32190@apoc.cs.uiuc.edu> Changes in directory llvm/tools/lli/Interpreter: ExternalFunctions.cpp updated: 1.45 -> 1.46 --- Log message: Implement a bunch of new external functions --- Diffs of the changes: Index: llvm/tools/lli/Interpreter/ExternalFunctions.cpp diff -u llvm/tools/lli/Interpreter/ExternalFunctions.cpp:1.45 llvm/tools/lli/Interpreter/ExternalFunctions.cpp:1.46 --- llvm/tools/lli/Interpreter/ExternalFunctions.cpp:1.45 Wed Apr 23 14:20:50 2003 +++ llvm/tools/lli/Interpreter/ExternalFunctions.cpp Wed Apr 23 14:55:24 2003 @@ -225,6 +225,12 @@ return PTOGV(malloc(Args[0].UIntVal)); } +// void *calloc(uint, uint) +GenericValue lle_X_calloc(FunctionType *M, const vector &Args) { + assert(Args.size() == 2 && "calloc expects two arguments!"); + return PTOGV(calloc(Args[0].UIntVal, Args[1].UIntVal)); +} + // void free(void *) GenericValue lle_X_free(FunctionType *M, const vector &Args) { assert(Args.size() == 1); @@ -526,6 +532,46 @@ return GV; } + +//===----------------------------------------------------------------------===// +// String Functions... +//===----------------------------------------------------------------------===// + +// int strcmp(const char *S1, const char *S2); +GenericValue lle_X_strcmp(FunctionType *M, const vector &Args) { + assert(Args.size() == 2); + GenericValue Ret; + Ret.IntVal = strcmp((char*)GVTOP(Args[0]), (char*)GVTOP(Args[1])); + return Ret; +} + +// char *strcat(char *Dest, const char *src); +GenericValue lle_X_strcat(FunctionType *M, const vector &Args) { + assert(Args.size() == 2); + return PTOGV(strcat((char*)GVTOP(Args[0]), (char*)GVTOP(Args[1]))); +} + +// char *strcpy(char *Dest, const char *src); +GenericValue lle_X_strcpy(FunctionType *M, const vector &Args) { + assert(Args.size() == 2); + return PTOGV(strcpy((char*)GVTOP(Args[0]), (char*)GVTOP(Args[1]))); +} + +// long strlen(const char *src); +GenericValue lle_X_strlen(FunctionType *M, const vector &Args) { + assert(Args.size() == 1); + GenericValue Ret; + Ret.LongVal = strlen((char*)GVTOP(Args[0])); + return Ret; +} + +// void *memset(void *S, int C, size_t N) +GenericValue lle_X_memset(FunctionType *M, const vector &Args) { + assert(Args.size() == 3); + return PTOGV(memset(GVTOP(Args[0]), Args[1].IntVal, Args[2].UIntVal)); +} + + //===----------------------------------------------------------------------===// // IO Functions... //===----------------------------------------------------------------------===// @@ -727,6 +773,7 @@ FuncNames["lle_X_exit"] = lle_X_exit; FuncNames["lle_X_abort"] = lle_X_abort; FuncNames["lle_X_malloc"] = lle_X_malloc; + FuncNames["lle_X_calloc"] = lle_X_calloc; FuncNames["lle_X_free"] = lle_X_free; FuncNames["lle_X_atoi"] = lle_X_atoi; FuncNames["lle_X_pow"] = lle_X_pow; @@ -745,6 +792,13 @@ FuncNames["lle_X_sscanf"] = lle_X_sscanf; FuncNames["lle_X_scanf"] = lle_X_scanf; FuncNames["lle_i_clock"] = lle_i_clock; + + FuncNames["lle_X_strcmp"] = lle_X_strcmp; + FuncNames["lle_X_strcat"] = lle_X_strcat; + FuncNames["lle_X_strcpy"] = lle_X_strcpy; + FuncNames["lle_X_strlen"] = lle_X_strlen; + FuncNames["lle_X_memset"] = lle_X_memset; + FuncNames["lle_X_fopen"] = lle_X_fopen; FuncNames["lle_X_fclose"] = lle_X_fclose; FuncNames["lle_X_feof"] = lle_X_feof; From lattner at cs.uiuc.edu Wed Apr 23 15:24:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Apr 23 15:24:01 2003 Subject: [llvm-commits] CVS: llvm/tools/lli/Interpreter/ExternalFunctions.cpp Message-ID: <200304232023.PAA32474@apoc.cs.uiuc.edu> Changes in directory llvm/tools/lli/Interpreter: ExternalFunctions.cpp updated: 1.46 -> 1.47 --- Log message: Add memcpy --- Diffs of the changes: Index: llvm/tools/lli/Interpreter/ExternalFunctions.cpp diff -u llvm/tools/lli/Interpreter/ExternalFunctions.cpp:1.46 llvm/tools/lli/Interpreter/ExternalFunctions.cpp:1.47 --- llvm/tools/lli/Interpreter/ExternalFunctions.cpp:1.46 Wed Apr 23 14:55:24 2003 +++ llvm/tools/lli/Interpreter/ExternalFunctions.cpp Wed Apr 23 15:23:16 2003 @@ -571,6 +571,12 @@ return PTOGV(memset(GVTOP(Args[0]), Args[1].IntVal, Args[2].UIntVal)); } +// void *memcpy(void *Dest, void *src, size_t Size); +GenericValue lle_X_memcpy(FunctionType *M, const vector &Args) { + assert(Args.size() == 3); + return PTOGV(memcpy((char*)GVTOP(Args[0]), (char*)GVTOP(Args[1]), + Args[2].UIntVal)); +} //===----------------------------------------------------------------------===// // IO Functions... @@ -798,6 +804,7 @@ FuncNames["lle_X_strcpy"] = lle_X_strcpy; FuncNames["lle_X_strlen"] = lle_X_strlen; FuncNames["lle_X_memset"] = lle_X_memset; + FuncNames["lle_X_memcpy"] = lle_X_memcpy; FuncNames["lle_X_fopen"] = lle_X_fopen; FuncNames["lle_X_fclose"] = lle_X_fclose; From lattner at cs.uiuc.edu Wed Apr 23 15:32:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Apr 23 15:32:01 2003 Subject: [llvm-commits] CVS: llvm/tools/bugpoint/ExecutionDriver.cpp Message-ID: <200304232031.PAA32577@apoc.cs.uiuc.edu> Changes in directory llvm/tools/bugpoint: ExecutionDriver.cpp updated: 1.2 -> 1.3 --- Log message: Allow specifying an input file for the program being executed --- Diffs of the changes: Index: llvm/tools/bugpoint/ExecutionDriver.cpp diff -u llvm/tools/bugpoint/ExecutionDriver.cpp:1.2 llvm/tools/bugpoint/ExecutionDriver.cpp:1.3 --- llvm/tools/bugpoint/ExecutionDriver.cpp:1.2 Mon Dec 23 18:44:34 2002 +++ llvm/tools/bugpoint/ExecutionDriver.cpp Wed Apr 23 15:31:37 2003 @@ -34,6 +34,10 @@ clEnumValN(RunLLC, "run-llc", "Compile with LLC"), clEnumValN(RunCBE, "run-cbe", "Compile with CBE"), 0)); + + cl::opt + InputFile("input", cl::init("/dev/null"), + cl::desc("Filename to pipe in as stdin (default: /dev/null)")); } /// AbstractInterpreter Class - Subclasses of this class are used to execute @@ -86,7 +90,7 @@ }; return RunProgramWithTimeout(LLIPath, Args, - "/dev/null", OutputFile, OutputFile); + InputFile, OutputFile, OutputFile); } From lattner at cs.uiuc.edu Wed Apr 23 15:41:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Apr 23 15:41:01 2003 Subject: [llvm-commits] CVS: llvm/tools/gccas/gccas.cpp Message-ID: <200304232040.PAA32737@apoc.cs.uiuc.edu> Changes in directory llvm/tools/gccas: gccas.cpp updated: 1.58 -> 1.59 --- Log message: The new CFrontend generates LOTs of basic blocks that just fall through and do other funky stuff. Clean it up early. --- Diffs of the changes: Index: llvm/tools/gccas/gccas.cpp diff -u llvm/tools/gccas/gccas.cpp:1.58 llvm/tools/gccas/gccas.cpp:1.59 --- llvm/tools/gccas/gccas.cpp:1.58 Fri Apr 18 18:38:09 2003 +++ llvm/tools/gccas/gccas.cpp Wed Apr 23 15:40:42 2003 @@ -70,6 +70,7 @@ addPass(PM, createDeadTypeEliminationPass()); // Eliminate dead types addPass(PM, createConstantMergePass()); // Merge dup global constants addPass(PM, createVerifierPass()); // Verify that input is correct + addPass(PM, createCFGSimplificationPass()); // Merge & remove BBs addPass(PM, createDeadInstEliminationPass()); // Remove Dead code/vars addPass(PM, createRaiseAllocationsPass()); // call %malloc -> malloc inst addPass(PM, createIndVarSimplifyPass()); // Simplify indvars From lattner at cs.uiuc.edu Wed Apr 23 15:42:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Apr 23 15:42:01 2003 Subject: [llvm-commits] CVS: llvm/tools/lli/ExecutionEngine.cpp Message-ID: <200304232041.PAA32747@apoc.cs.uiuc.edu> Changes in directory llvm/tools/lli: ExecutionEngine.cpp updated: 1.6 -> 1.7 --- Log message: Fix bug where pointers were assumed to always be 64 bits in size! --- Diffs of the changes: Index: llvm/tools/lli/ExecutionEngine.cpp diff -u llvm/tools/lli/ExecutionEngine.cpp:1.6 llvm/tools/lli/ExecutionEngine.cpp:1.7 --- llvm/tools/lli/ExecutionEngine.cpp:1.6 Wed Apr 23 14:01:49 2003 +++ llvm/tools/lli/ExecutionEngine.cpp Wed Apr 23 15:41:01 2003 @@ -92,6 +92,7 @@ case Type::ShortTyID: Ptr->Untyped[0] = Val.UShortVal & 255; Ptr->Untyped[1] = (Val.UShortVal >> 8) & 255; break; + Store4BytesLittleEndian: case Type::FloatTyID: case Type::UIntTyID: case Type::IntTyID: Ptr->Untyped[0] = Val.UIntVal & 255; @@ -99,10 +100,11 @@ Ptr->Untyped[2] = (Val.UIntVal >> 16) & 255; Ptr->Untyped[3] = (Val.UIntVal >> 24) & 255; break; + case Type::PointerTyID: if (CurMod.has32BitPointers()) + goto Store4BytesLittleEndian; case Type::DoubleTyID: case Type::ULongTyID: - case Type::LongTyID: - case Type::PointerTyID: Ptr->Untyped[0] = Val.ULongVal & 255; + case Type::LongTyID: 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; @@ -123,6 +125,7 @@ case Type::ShortTyID: Ptr->Untyped[1] = Val.UShortVal & 255; Ptr->Untyped[0] = (Val.UShortVal >> 8) & 255; break; + Store4BytesBigEndian: case Type::FloatTyID: case Type::UIntTyID: case Type::IntTyID: Ptr->Untyped[3] = Val.UIntVal & 255; @@ -130,10 +133,11 @@ Ptr->Untyped[1] = (Val.UIntVal >> 16) & 255; Ptr->Untyped[0] = (Val.UIntVal >> 24) & 255; break; + case Type::PointerTyID: if (CurMod.has32BitPointers()) + goto Store4BytesBigEndian; case Type::DoubleTyID: case Type::ULongTyID: - case Type::LongTyID: - case Type::PointerTyID: Ptr->Untyped[7] = Val.ULongVal & 255; + case Type::LongTyID: 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; From lattner at cs.uiuc.edu Wed Apr 23 15:42:04 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Apr 23 15:42:04 2003 Subject: [llvm-commits] CVS: llvm/tools/bugpoint/Miscompilation.cpp Message-ID: <200304232041.PAA32758@apoc.cs.uiuc.edu> Changes in directory llvm/tools/bugpoint: Miscompilation.cpp updated: 1.1 -> 1.2 --- Log message: Print where reference output goes --- Diffs of the changes: Index: llvm/tools/bugpoint/Miscompilation.cpp diff -u llvm/tools/bugpoint/Miscompilation.cpp:1.1 llvm/tools/bugpoint/Miscompilation.cpp:1.2 --- llvm/tools/bugpoint/Miscompilation.cpp:1.1 Mon Dec 23 17:50:16 2002 +++ llvm/tools/bugpoint/Miscompilation.cpp Wed Apr 23 15:41:18 2003 @@ -43,7 +43,7 @@ std::cout << "Generating reference output from raw program..."; Output = executeProgram("bugpoint.reference.out"); CreatedOutput = true; - std::cout << " done!\n"; + std::cout << " done! Reference output is: bugpoint.reference.out.\n"; } else if (diffProgram(Output)) { std::cout << "\n*** Input program does not match reference diff!\n" << " Must be problem with input source!\n"; From lattner at cs.uiuc.edu Thu Apr 24 10:55:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Apr 24 10:55:01 2003 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Utils/CloneModule.cpp Message-ID: <200304241554.KAA20751@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Utils: CloneModule.cpp updated: 1.3 -> 1.4 --- Log message: Make sure to preserve endiannes and pointer size when cloning modules! --- Diffs of the changes: Index: llvm/lib/Transforms/Utils/CloneModule.cpp diff -u llvm/lib/Transforms/Utils/CloneModule.cpp:1.3 llvm/lib/Transforms/Utils/CloneModule.cpp:1.4 --- llvm/lib/Transforms/Utils/CloneModule.cpp:1.3 Tue Apr 22 13:02:26 2003 +++ llvm/lib/Transforms/Utils/CloneModule.cpp Thu Apr 24 10:54:40 2003 @@ -19,6 +19,8 @@ Module *CloneModule(const Module *M) { // First off, we need to create the new module... Module *New = new Module(M->getModuleIdentifier()); + New->setEndianness(M->getEndianness()); + New->setPointerSize(M->getPointerSize()); // Create the value map that maps things from the old module over to the new // module. From lattner at cs.uiuc.edu Thu Apr 24 12:03:02 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Apr 24 12:03:02 2003 Subject: [llvm-commits] CVS: llvm/tools/bugpoint/BugDriver.cpp BugDriver.h CrashDebugger.cpp ExecutionDriver.cpp Miscompilation.cpp OptimizerDriver.cpp Message-ID: <200304241702.MAA21597@apoc.cs.uiuc.edu> Changes in directory llvm/tools/bugpoint: BugDriver.cpp updated: 1.2 -> 1.3 BugDriver.h updated: 1.4 -> 1.5 CrashDebugger.cpp updated: 1.4 -> 1.5 ExecutionDriver.cpp updated: 1.3 -> 1.4 Miscompilation.cpp updated: 1.2 -> 1.3 OptimizerDriver.cpp updated: 1.3 -> 1.4 --- Log message: Implement support for bugpoint to identify which FUNCTION an optimization is miscompiling. --- Diffs of the changes: Index: llvm/tools/bugpoint/BugDriver.cpp diff -u llvm/tools/bugpoint/BugDriver.cpp:1.2 llvm/tools/bugpoint/BugDriver.cpp:1.3 --- llvm/tools/bugpoint/BugDriver.cpp:1.2 Mon Dec 23 17:49:59 2002 +++ llvm/tools/bugpoint/BugDriver.cpp Thu Apr 24 12:02:17 2003 @@ -14,6 +14,20 @@ #include "llvm/Pass.h" #include +/// getPassesString - Turn a list of passes into a string which indicates the +/// command line options that must be passed to add the passes. +/// +std::string getPassesString(const std::vector &Passes) { + std::string Result; + for (unsigned i = 0, e = Passes.size(); i != e; ++i) { + if (i) Result += " "; + Result += "-"; + Result += Passes[i]->getPassArgument(); + } + return Result; +} + + /// ParseInputFile - Given a bytecode or assembly input filename, parse and /// return it, or return null if not possible. /// Index: llvm/tools/bugpoint/BugDriver.h diff -u llvm/tools/bugpoint/BugDriver.h:1.4 llvm/tools/bugpoint/BugDriver.h:1.5 --- llvm/tools/bugpoint/BugDriver.h:1.4 Fri Feb 28 10:13:20 2003 +++ llvm/tools/bugpoint/BugDriver.h Thu Apr 24 12:02:17 2003 @@ -17,11 +17,17 @@ class AbstractInterpreter; class Instruction; +class ReduceMiscompilingPasses; +class ReduceMiscompilingFunctions; + class BugDriver { const std::string ToolName; // Name of bugpoint Module *Program; // The raw program, linked together std::vector PassesToRun; AbstractInterpreter *Interpreter; // How to run the program + + friend class ReduceMiscompilingPasses; + friend class ReduceMiscompilingFunctions; public: BugDriver(const char *toolname) : ToolName(toolname), Program(0), Interpreter(0) {} @@ -81,7 +87,7 @@ /// EmitProgressBytecode - This function is used to output the current Program /// to a file named "bugpoing-ID.bc". /// - void EmitProgressBytecode(const PassInfo *Pass, const std::string &ID); + void EmitProgressBytecode(const std::string &ID, bool NoFlyer = false); /// runPasses - Run the specified passes on Program, outputting a bytecode /// file and writting the filename into OutputFile if successful. If the @@ -148,7 +154,13 @@ /// is different, true is returned. /// bool diffProgram(const std::string &ReferenceOutputFile, - const std::string &BytecodeFile = ""); + const std::string &BytecodeFile = "", + bool RemoveBytecode = false); }; + +/// getPassesString - Turn a list of passes into a string which indicates the +/// command line options that must be passed to add the passes. +/// +std::string getPassesString(const std::vector &Passes); #endif Index: llvm/tools/bugpoint/CrashDebugger.cpp diff -u llvm/tools/bugpoint/CrashDebugger.cpp:1.4 llvm/tools/bugpoint/CrashDebugger.cpp:1.5 --- llvm/tools/bugpoint/CrashDebugger.cpp:1.4 Fri Feb 28 10:13:20 2003 +++ llvm/tools/bugpoint/CrashDebugger.cpp Thu Apr 24 12:02:17 2003 @@ -11,6 +11,23 @@ #include "llvm/Pass.h" #include +#if 0 +class DebugCrashes : public ListReducer { + BugDriver &BD; +public: + DebugCrashes(BugDriver &bd) : BD(bd) {} + + // doTest - Return true iff running the "removed" passes succeeds, and running + // the "Kept" passes fail when run on the output of the "removed" passes. If + // we return true, we update the current module of bugpoint. + // + virtual bool doTest(const std::vector &Removed, + const std::vector &Kept) { + return BD.runPasses(Kept); + } +}; +#endif + /// debugCrash - This method is called when some pass crashes on input. It /// attempts to prune down the testcase to something reasonable, and figure /// out exactly which pass is crashing. @@ -18,7 +35,11 @@ bool BugDriver::debugCrash() { std::cout << "\n*** Debugging optimizer crash!\n"; - // Determine which pass causes the optimizer to crash... using binary search +#if 0 + // Reduce the list of passes which causes the optimizer to crash... + DebugCrashes(*this).reduceList(PassesToRun); +#endif + unsigned LastToPass = 0, LastToCrash = PassesToRun.size(); while (LastToPass != LastToCrash) { unsigned Mid = (LastToCrash+LastToPass+1) / 2; @@ -65,6 +86,9 @@ removeFile(Filename); } + PassesToRun.clear(); + PassesToRun.push_back(CrashingPass); + return debugPassCrash(CrashingPass); } @@ -83,7 +107,7 @@ /// crashes, but it smaller. /// bool BugDriver::debugPassCrash(const PassInfo *Pass) { - EmitProgressBytecode(Pass, "passinput"); + EmitProgressBytecode("passinput"); bool Reduced = false, AnyReduction = false; if (CountFunctions(Program) > 1) { @@ -124,7 +148,7 @@ } if (Reduced) { - EmitProgressBytecode(Pass, "reduced-function"); + EmitProgressBytecode("reduced-function"); Reduced = false; } @@ -196,7 +220,7 @@ } if (Reduced) { - EmitProgressBytecode(Pass, "reduced-simplified"); + EmitProgressBytecode("reduced-simplified"); Reduced = false; } Index: llvm/tools/bugpoint/ExecutionDriver.cpp diff -u llvm/tools/bugpoint/ExecutionDriver.cpp:1.3 llvm/tools/bugpoint/ExecutionDriver.cpp:1.4 --- llvm/tools/bugpoint/ExecutionDriver.cpp:1.3 Wed Apr 23 15:31:37 2003 +++ llvm/tools/bugpoint/ExecutionDriver.cpp Thu Apr 24 12:02:17 2003 @@ -164,7 +164,8 @@ /// different, true is returned. /// bool BugDriver::diffProgram(const std::string &ReferenceOutputFile, - const std::string &BytecodeFile) { + const std::string &BytecodeFile, + bool RemoveBytecode) { // Execute the program, generating an output file... std::string Output = executeProgram("", BytecodeFile); @@ -192,5 +193,6 @@ } while (C1 != EOF); removeFile(Output); + if (RemoveBytecode) removeFile(BytecodeFile); return FilesDifferent; } Index: llvm/tools/bugpoint/Miscompilation.cpp diff -u llvm/tools/bugpoint/Miscompilation.cpp:1.2 llvm/tools/bugpoint/Miscompilation.cpp:1.3 --- llvm/tools/bugpoint/Miscompilation.cpp:1.2 Wed Apr 23 15:41:18 2003 +++ llvm/tools/bugpoint/Miscompilation.cpp Thu Apr 24 12:02:17 2003 @@ -8,6 +8,8 @@ #include "SystemUtils.h" #include "llvm/Pass.h" #include "llvm/Module.h" +#include "llvm/Transforms/Utils/Cloning.h" +#include "llvm/Transforms/Utils/Linker.h" #include "Support/CommandLine.h" // Anonymous namespace to define command line options for miscompilation @@ -24,6 +26,322 @@ "(for miscompilation detection)")); } +template +struct ListReducer { + enum TestResult { + NoFailure, // No failure of the predicate was detected + KeepSuffix, // The suffix alone satisfies the predicate + KeepPrefix, // The prefix alone satisfies the predicate + }; + + // doTest - This virtual function should be overriden by subclasses to + // implement the test desired. The testcase is only required to test to see + // if the Kept list still satisfies the property, but if it is going to check + // the prefix anyway, it can. + // + virtual TestResult doTest(const std::vector &Prefix, + const std::vector &Kept) = 0; + + // reduceList - This function attempts to reduce the length of the specified + // list while still maintaining the "test" property. This is the core of the + // "work" that bugpoint does. + // + void reduceList(std::vector &TheList) { + unsigned MidTop = TheList.size(); + while (MidTop > 1) { + unsigned Mid = MidTop / 2; + std::vector Prefix(TheList.begin()+Mid, TheList.end()); + std::vector Kept (TheList.begin(), TheList.begin()+Mid); + + switch (doTest(Prefix, Kept)) { + case KeepSuffix: + // The property still holds. We can just drop the prefix elements, and + // shorten the list to the "kept" elements. + TheList.swap(Kept); + MidTop = TheList.size(); + break; + case KeepPrefix: + // The predicate still holds, shorten the list to the prefix elements. + TheList.swap(Prefix); + MidTop = TheList.size(); + break; + case NoFailure: + // Otherwise the property doesn't hold. Some of the elements we removed + // must be neccesary to maintain the property. + MidTop = Mid; + break; + } + } + } +}; + +class ReduceMiscompilingPasses : public ListReducer { + BugDriver &BD; +public: + ReduceMiscompilingPasses(BugDriver &bd) : BD(bd) {} + + virtual TestResult doTest(const std::vector &Prefix, + const std::vector &Kept); +}; + +ReduceMiscompilingPasses::TestResult +ReduceMiscompilingPasses::doTest(const std::vector &Prefix, + const std::vector &Kept) { + // First, run the program with just the Kept passes. If it is still broken + // with JUST the kept passes, discard the prefix passes. + std::cout << "Checking to see if '" << getPassesString(Kept) + << "' compile correctly: "; + + std::string BytecodeResult; + if (BD.runPasses(Kept, BytecodeResult, false/*delete*/, true/*quiet*/)) { + std::cerr << BD.getToolName() << ": Error running this sequence of passes" + << " on the input program!\n"; + exit(1); + } + + // Check to see if the finished program matches the reference output... + if (BD.diffProgram(Output, BytecodeResult, true /*delete bytecode*/)) { + std::cout << "nope.\n"; + return KeepSuffix; // Miscompilation detected! + } + std::cout << "yup.\n"; // No miscompilation! + + if (Prefix.empty()) return NoFailure; + + // First, run the program with just the Kept passes. If it is still broken + // with JUST the kept passes, discard the prefix passes. + std::cout << "Checking to see if '" << getPassesString(Prefix) + << "' compile correctly: "; + + // If it is not broken with the kept passes, it's possible that the prefix + // passes must be run before the kept passes to break it. If the program + // WORKS after the prefix passes, but then fails if running the prefix AND + // kept passes, we can update our bytecode file to include the result of the + // prefix passes, then discard the prefix passes. + // + if (BD.runPasses(Prefix, BytecodeResult, false/*delete*/, true/*quiet*/)) { + std::cerr << BD.getToolName() << ": Error running this sequence of passes" + << " on the input program!\n"; + exit(1); + } + + // If the prefix maintains the predicate by itself, only keep the prefix! + if (BD.diffProgram(Output, BytecodeResult)) { + std::cout << "nope.\n"; + removeFile(BytecodeResult); + return KeepPrefix; + } + std::cout << "yup.\n"; // No miscompilation! + + // Ok, so now we know that the prefix passes work, try running the suffix + // passes on the result of the prefix passes. + // + Module *PrefixOutput = BD.ParseInputFile(BytecodeResult); + if (PrefixOutput == 0) { + std::cerr << BD.getToolName() << ": Error reading bytecode file '" + << BytecodeResult << "'!\n"; + exit(1); + } + removeFile(BytecodeResult); // No longer need the file on disk + + std::cout << "Checking to see if '" << getPassesString(Kept) + << "' passes compile correctly after the '" + << getPassesString(Prefix) << "' passes: "; + + Module *OriginalInput = BD.Program; + BD.Program = PrefixOutput; + if (BD.runPasses(Kept, BytecodeResult, false/*delete*/, true/*quiet*/)) { + std::cerr << BD.getToolName() << ": Error running this sequence of passes" + << " on the input program!\n"; + exit(1); + } + + // Run the result... + if (BD.diffProgram(Output, BytecodeResult, true/*delete bytecode*/)) { + std::cout << "nope.\n"; + delete OriginalInput; // We pruned down the original input... + return KeepPrefix; + } + + // Otherwise, we must not be running the bad pass anymore. + std::cout << "yup.\n"; // No miscompilation! + BD.Program = OriginalInput; // Restore original program + delete PrefixOutput; // Free experiment + return NoFailure; +} + +static void PrintFunctionList(const std::vector &Funcs) { + for (unsigned i = 0, e = Funcs.size(); i != e; ++i) { + if (i) std::cout << ", "; + std::cout << Funcs[i]->getName(); + } +} + + +class ReduceMiscompilingFunctions : public ListReducer { + BugDriver &BD; +public: + ReduceMiscompilingFunctions(BugDriver &bd) : BD(bd) {} + + virtual TestResult doTest(const std::vector &Prefix, + const std::vector &Kept) { + if (TestFuncs(Kept, false)) + return KeepSuffix; + if (TestFuncs(Prefix, false)) + return KeepPrefix; + return NoFailure; + } + + bool TestFuncs(const std::vector &Prefix, bool EmitBytecode); +}; + +// DeleteFunctionBody - "Remove" the function by deleting all of it's basic +// blocks, making it external. +// +static void DeleteFunctionBody(Function *F) { + // First, break circular use/def chain references... + for (Function::iterator I = F->begin(), E = F->end(); I != E; ++I) + I->dropAllReferences(); + + // Next, delete all of the basic blocks. + F->getBasicBlockList().clear(); + + assert(F->isExternal() && "This didn't make the function external!"); +} + + +bool ReduceMiscompilingFunctions::TestFuncs(const std::vector &Funcs, + bool EmitBytecode) { + // Test to see if the function is misoptimized if we ONLY run it on the + // functions listed in Funcs. + if (!EmitBytecode) { + std::cout << "Checking to see if the program is misoptimized when these " + << "functions are run\nthrough the passes: "; + PrintFunctionList(Funcs); + std::cout << "\n"; + } else { + std::cout <<"Outputting reduced bytecode files which expose the problem:\n"; + } + + // First step: clone the module for the two halves of the program we want. + Module *ToOptimize = CloneModule(BD.Program); + + // Second step: Make sure functions & globals are all external so that linkage + // between the two modules will work. + for (Module::iterator I = ToOptimize->begin(), E = ToOptimize->end();I!=E;++I) + I->setLinkage(GlobalValue::ExternalLinkage); + for (Module::giterator I = ToOptimize->gbegin(), E = ToOptimize->gend(); + I != E; ++I) + I->setLinkage(GlobalValue::ExternalLinkage); + + // Third step: make a clone of the externalized program for the non-optimized + // part. + Module *ToNotOptimize = CloneModule(ToOptimize); + + // Fourth step: Remove the test functions from the ToNotOptimize module, and + // all of the global variables. + for (unsigned i = 0, e = Funcs.size(); i != e; ++i) { + Function *TNOF = ToNotOptimize->getFunction(Funcs[i]->getName(), + Funcs[i]->getFunctionType()); + assert(TNOF && "Function doesn't exist in module!"); + DeleteFunctionBody(TNOF); // Function is now external in this module! + } + for (Module::giterator I = ToNotOptimize->gbegin(), E = ToNotOptimize->gend(); + I != E; ++I) + I->setInitializer(0); // Delete the initializer to make it external + + if (EmitBytecode) { + std::cout << " Non-optimized portion: "; + std::swap(BD.Program, ToNotOptimize); + BD.EmitProgressBytecode("tonotoptimize", true); + std::swap(BD.Program, ToNotOptimize); + } + + // Fifth step: Remove all functions from the ToOptimize module EXCEPT for the + // ones specified in Funcs. We know which ones these are because they are + // non-external in ToOptimize, but external in ToNotOptimize. + // + for (Module::iterator I = ToOptimize->begin(), E = ToOptimize->end();I!=E;++I) + if (!I->isExternal()) { + Function *TNOF = ToNotOptimize->getFunction(I->getName(), + I->getFunctionType()); + assert(TNOF && "Function doesn't exist in ToNotOptimize module??"); + if (!TNOF->isExternal()) + DeleteFunctionBody(I); + } + + if (EmitBytecode) { + std::cout << " Portion that is input to optimizer: "; + std::swap(BD.Program, ToOptimize); + BD.EmitProgressBytecode("tooptimize"); + std::swap(BD.Program, ToOptimize); + } + + // Sixth step: Run the optimization passes on ToOptimize, producing a + // transformed version of the functions being tested. + Module *OldProgram = BD.Program; + BD.Program = ToOptimize; + + if (!EmitBytecode) + std::cout << " Optimizing functions being tested: "; + std::string BytecodeResult; + if (BD.runPasses(BD.PassesToRun, BytecodeResult, false/*delete*/, + true/*quiet*/)) { + std::cerr << BD.getToolName() << ": Error running this sequence of passes" + << " on the input program!\n"; + exit(1); + } + + if (!EmitBytecode) + std::cout << "done.\n"; + + delete BD.Program; // Delete the old "ToOptimize" module + BD.Program = BD.ParseInputFile(BytecodeResult); + + if (EmitBytecode) { + std::cout << " 'tooptimize' after being optimized: "; + BD.EmitProgressBytecode("optimized", true); + } + + if (BD.Program == 0) { + std::cerr << BD.getToolName() << ": Error reading bytecode file '" + << BytecodeResult << "'!\n"; + exit(1); + } + removeFile(BytecodeResult); // No longer need the file on disk + + // Seventh step: Link the optimized part of the program back to the + // unoptimized part of the program. + // + if (LinkModules(BD.Program, ToNotOptimize, &BytecodeResult)) { + std::cerr << BD.getToolName() << ": Error linking modules together:" + << BytecodeResult << "\n"; + exit(1); + } + delete ToNotOptimize; // We are done with this module... + + if (EmitBytecode) { + std::cout << " Program as tested: "; + BD.EmitProgressBytecode("linked", true); + delete BD.Program; + BD.Program = OldProgram; + return false; // We don't need to actually execute the program here. + } + + std::cout << " Checking to see if the merged program executes correctly: "; + + // Eighth step: Execute the program. If it does not match the expected + // output, then 'Funcs' are being misoptimized! + bool Broken = BD.diffProgram(Output); + + delete BD.Program; // Delete the hacked up program + BD.Program = OldProgram; // Restore the original + + std::cout << (Broken ? "nope.\n" : "yup.\n"); + return Broken; +} + + /// debugMiscompilation - This method is used when the passes selected are not /// crashing, but the generated output is semantically different from the /// input. @@ -50,92 +368,42 @@ return false; // Problem found } - // Figure out which transformation is the first to miscompile the input - // program. We do a binary search here in case there are a large number of - // passes involved. - // - unsigned LastGood = 0, LastBad = PassesToRun.size(); - while (LastGood != LastBad) { - unsigned Mid = (LastBad+LastGood+1) / 2; - std::vector P(PassesToRun.begin(), - PassesToRun.begin()+Mid); - std::cout << "Checking to see if the first " << Mid << " passes are ok: "; - - std::string BytecodeResult; - if (runPasses(P, BytecodeResult, false, true)) { - std::cerr << ToolName << ": Error running this sequence of passes" - << " on the input program!\n"; - exit(1); - } - - // Check to see if the finished program matches the reference output... - if (diffProgram(Output, BytecodeResult)) { - std::cout << "nope.\n"; - LastBad = Mid-1; // Miscompilation detected! - } else { - std::cout << "yup.\n"; - LastGood = Mid; // No miscompilation! - } - - // We are now done with the optimized output... so remove it. - removeFile(BytecodeResult); - } + // Figure out which transformations miscompile the input program. + unsigned OldSize = PassesToRun.size(); + ReduceMiscompilingPasses(*this).reduceList(PassesToRun); // Make sure something was miscompiled... - if (LastBad >= PassesToRun.size()) { + if (PassesToRun.size() == OldSize) { std::cerr << "*** Optimized program matches reference output! No problem " << "detected...\nbugpoint can't help you with your problem!\n"; return false; } - // Calculate which pass it is that miscompiles... - const PassInfo *ThePass = PassesToRun[LastBad]; - - std::cout << "\n*** Found miscompiling pass '-" << ThePass->getPassArgument() - << "': " << ThePass->getPassName() << "\n"; - - if (LastGood != 0) { - std::vector P(PassesToRun.begin(), - PassesToRun.begin()+LastGood); - std::string Filename; - std::cout << "Running good passes to get input for pass:"; - if (runPasses(P, Filename, false, true)) { - std::cerr << "ERROR: Running the first " << LastGood - << " passes crashed!\n"; - return true; - } - std::cout << " done!\n"; - - // Assuming everything was successful, we now have a valid bytecode file in - // OutputName. Use it for "Program" Instead. - delete Program; - Program = ParseInputFile(Filename); - - // Delete the file now. - removeFile(Filename); - } + std::cout << "\n*** Found miscompiling pass" + << (PassesToRun.size() == 1 ? "" : "es") << ": " + << getPassesString(PassesToRun) << "\n"; + EmitProgressBytecode("passinput"); + + + // Okay, now that we have reduced the list of passes which are causing the + // failure, see if we can pin down which functions are being + // miscompiled... first build a list of all of the non-external functions in + // the program. + std::vector MiscompiledFunctions; + for (Module::iterator I = Program->begin(), E = Program->end(); I != E; ++I) + if (!I->isExternal()) + MiscompiledFunctions.push_back(I); + + // Do the reduction... + ReduceMiscompilingFunctions(*this).reduceList(MiscompiledFunctions); + + std::cout << "\n*** The following functions are being miscompiled: "; + PrintFunctionList(MiscompiledFunctions); + std::cout << "\n"; - bool Result = debugPassMiscompilation(ThePass, Output); + // Output a bunch of bytecode files for the user... + ReduceMiscompilingFunctions(*this).TestFuncs(MiscompiledFunctions, true); if (CreatedOutput) removeFile(Output); - return Result; -} - -/// debugPassMiscompilation - This method is called when the specified pass -/// miscompiles Program as input. It tries to reduce the testcase to something -/// that smaller that still miscompiles the program. ReferenceOutput contains -/// the filename of the file containing the output we are to match. -/// -bool BugDriver::debugPassMiscompilation(const PassInfo *Pass, - const std::string &ReferenceOutput) { - EmitProgressBytecode(Pass, "passinput"); - - // Loop over all of the functions in the program, attempting to find one that - // is being miscompiled. We do this by extracting the function into a module, - // running the "bad" optimization on that module, then linking it back into - // the program. If the program fails the diff, the function got misoptimized. - // - - return false; } Index: llvm/tools/bugpoint/OptimizerDriver.cpp diff -u llvm/tools/bugpoint/OptimizerDriver.cpp:1.3 llvm/tools/bugpoint/OptimizerDriver.cpp:1.4 --- llvm/tools/bugpoint/OptimizerDriver.cpp:1.3 Wed Jan 22 17:24:11 2003 +++ llvm/tools/bugpoint/OptimizerDriver.cpp Thu Apr 24 12:02:17 2003 @@ -35,8 +35,7 @@ /// EmitProgressBytecode - This function is used to output the current Program /// to a file named "bugpoing-ID.bc". /// -void BugDriver::EmitProgressBytecode(const PassInfo *Pass, - const std::string &ID) { +void BugDriver::EmitProgressBytecode(const std::string &ID, bool NoFlyer) { // Output the input to the current pass to a bytecode file, emit a message // telling the user how to reproduce it: opt -foo blah.bc // @@ -47,9 +46,13 @@ } std::cout << "Emitted bytecode to '" << Filename << "'\n"; + if (NoFlyer) return; std::cout << "\n*** You can reproduce the problem with: "; - unsigned PassType = Pass->getPassType(); + unsigned PassType = PassesToRun[0]->getPassType(); + for (unsigned i = 1, e = PassesToRun.size(); i != e; ++i) + PassType &= PassesToRun[i]->getPassType(); + if (PassType & PassInfo::Analysis) std::cout << "analyze"; else if (PassType & PassInfo::Optimization) @@ -58,7 +61,8 @@ std::cout << "llc"; else std::cout << "bugpoint"; - std::cout << " " << Filename << " -" << Pass->getPassArgument() << "\n"; + std::cout << " " << Filename << " "; + std::cout << getPassesString(PassesToRun) << "\n"; } /// FIXME: This should be parameterizable!! From lattner at cs.uiuc.edu Thu Apr 24 12:16:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Apr 24 12:16:01 2003 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Utils/CloneModule.cpp Message-ID: <200304241715.MAA22019@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Utils: CloneModule.cpp updated: 1.4 -> 1.5 --- Log message: Make sure that the cloned module retains the type symbol table entries! --- Diffs of the changes: Index: llvm/lib/Transforms/Utils/CloneModule.cpp diff -u llvm/lib/Transforms/Utils/CloneModule.cpp:1.4 llvm/lib/Transforms/Utils/CloneModule.cpp:1.5 --- llvm/lib/Transforms/Utils/CloneModule.cpp:1.4 Thu Apr 24 10:54:40 2003 +++ llvm/lib/Transforms/Utils/CloneModule.cpp Thu Apr 24 12:15:33 2003 @@ -8,6 +8,7 @@ #include "llvm/Transforms/Utils/Cloning.h" #include "llvm/Module.h" #include "llvm/DerivedTypes.h" +#include "llvm/SymbolTable.h" #include "llvm/Constant.h" #include "ValueMapper.h" @@ -21,6 +22,14 @@ Module *New = new Module(M->getModuleIdentifier()); New->setEndianness(M->getEndianness()); New->setPointerSize(M->getPointerSize()); + + // Copy all of the type symbol table entries over... + const SymbolTable &SymTab = M->getSymbolTable(); + SymbolTable::const_iterator TypeI = SymTab.find(Type::TypeTy); + if (TypeI != SymTab.end()) + for (SymbolTable::VarMap::const_iterator I = TypeI->second.begin(), + E = TypeI->second.end(); I != E; ++I) + New->addTypeName(I->first, cast(I->second)); // Create the value map that maps things from the old module over to the new // module. From lattner at cs.uiuc.edu Thu Apr 24 12:53:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Apr 24 12:53:01 2003 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp Message-ID: <200304241752.MAA24463@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Utils: PromoteMemoryToRegister.cpp updated: 1.39 -> 1.40 --- Log message: Fix iterator invalidation problem --- Diffs of the changes: Index: llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp diff -u llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp:1.39 llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp:1.40 --- llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp:1.39 Mon Apr 21 14:15:26 2003 +++ llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp Thu Apr 24 12:52:20 2003 @@ -201,8 +201,13 @@ // because it is an unreachable predecessor), that all PHI nodes will have the // correct number of entries for their predecessors. Value *NullVal = Constant::getNullValue(PN->getType()); - for (pred_iterator PI = pred_begin(BB), PE = pred_end(BB); PI != PE; ++PI) - PN->addIncoming(NullVal, *PI); + + // This is neccesary because adding incoming values to the PHI node adds uses + // to the basic blocks being used, which can invalidate the predecessor + // iterator! + std::vector Preds(pred_begin(BB), pred_end(BB)); + for (unsigned i = 0, e = Preds.size(); i != e; ++i) + PN->addIncoming(NullVal, Preds[i]); BBPNs[AllocaNo] = PN; PhiNodes[AllocaNo].push_back(BB); From lattner at cs.uiuc.edu Thu Apr 24 13:26:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Apr 24 13:26:01 2003 Subject: [llvm-commits] CVS: llvm/lib/Transforms/ExprTypeConvert.cpp LevelRaise.cpp TransformInternals.cpp TransformInternals.h Message-ID: <200304241825.NAA26243@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms: ExprTypeConvert.cpp updated: 1.69 -> 1.70 LevelRaise.cpp updated: 1.76 -> 1.77 TransformInternals.cpp updated: 1.32 -> 1.33 TransformInternals.h updated: 1.16 -> 1.17 --- Log message: Make the levelraise pass be well behaved w.r.t the TargetData that the current PassMAnager provides. --- Diffs of the changes: Index: llvm/lib/Transforms/ExprTypeConvert.cpp diff -u llvm/lib/Transforms/ExprTypeConvert.cpp:1.69 llvm/lib/Transforms/ExprTypeConvert.cpp:1.70 --- llvm/lib/Transforms/ExprTypeConvert.cpp:1.69 Thu Feb 13 21:07:17 2003 +++ llvm/lib/Transforms/ExprTypeConvert.cpp Thu Apr 24 13:25:27 2003 @@ -18,10 +18,11 @@ using std::cerr; static bool OperandConvertableToType(User *U, Value *V, const Type *Ty, - ValueTypeCache &ConvertedTypes); + ValueTypeCache &ConvertedTypes, + const TargetData &TD); static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal, - ValueMapCache &VMC); + ValueMapCache &VMC, const TargetData &TD); // Peephole Malloc instructions: we take a look at the use chain of the // malloc instruction, and try to find out if the following conditions hold: @@ -35,7 +36,8 @@ // element. TODO: This comment is out of date WRT arrays // static bool MallocConvertableToType(MallocInst *MI, const Type *Ty, - ValueTypeCache &CTMap) { + ValueTypeCache &CTMap, + const TargetData &TD) { if (!isa(Ty)) return false; // Malloc always returns pointers // Deal with the type to allocate, not the pointer type... @@ -73,7 +75,8 @@ static Instruction *ConvertMallocToType(MallocInst *MI, const Type *Ty, const std::string &Name, - ValueMapCache &VMC){ + ValueMapCache &VMC, + const TargetData &TD){ BasicBlock *BB = MI->getParent(); BasicBlock::iterator It = BB->end(); @@ -131,7 +134,7 @@ // ExpressionConvertableToType - Return true if it is possible bool ExpressionConvertableToType(Value *V, const Type *Ty, - ValueTypeCache &CTMap) { + ValueTypeCache &CTMap, const TargetData &TD) { // Expression type must be holdable in a register. if (!Ty->isFirstClassType()) return false; @@ -172,8 +175,8 @@ case Instruction::Add: case Instruction::Sub: if (!Ty->isInteger() && !Ty->isFloatingPoint()) return false; - if (!ExpressionConvertableToType(I->getOperand(0), Ty, CTMap) || - !ExpressionConvertableToType(I->getOperand(1), Ty, CTMap)) + if (!ExpressionConvertableToType(I->getOperand(0), Ty, CTMap, TD) || + !ExpressionConvertableToType(I->getOperand(1), Ty, CTMap, TD)) return false; break; case Instruction::Shr: @@ -182,27 +185,27 @@ // FALL THROUGH case Instruction::Shl: if (!Ty->isInteger()) return false; - if (!ExpressionConvertableToType(I->getOperand(0), Ty, CTMap)) + if (!ExpressionConvertableToType(I->getOperand(0), Ty, CTMap, TD)) return false; break; case Instruction::Load: { LoadInst *LI = cast(I); if (!ExpressionConvertableToType(LI->getPointerOperand(), - PointerType::get(Ty), CTMap)) + PointerType::get(Ty), CTMap, TD)) return false; break; } case Instruction::PHINode: { PHINode *PN = cast(I); for (unsigned i = 0; i < PN->getNumIncomingValues(); ++i) - if (!ExpressionConvertableToType(PN->getIncomingValue(i), Ty, CTMap)) + if (!ExpressionConvertableToType(PN->getIncomingValue(i), Ty, CTMap, TD)) return false; break; } case Instruction::Malloc: - if (!MallocConvertableToType(cast(I), Ty, CTMap)) + if (!MallocConvertableToType(cast(I), Ty, CTMap, TD)) return false; break; @@ -258,10 +261,10 @@ // the appropriate size... if so, allow it. // std::vector Indices; - const Type *ElTy = ConvertableToGEP(PTy, I->getOperand(1), Indices); + const Type *ElTy = ConvertableToGEP(PTy, I->getOperand(1), Indices, TD); if (ElTy == PVTy) { if (!ExpressionConvertableToType(I->getOperand(0), - PointerType::get(ElTy), CTMap)) + PointerType::get(ElTy), CTMap, TD)) return false; // Can't continue, ExConToTy might have polluted set! break; } @@ -278,7 +281,7 @@ TD.getTypeSize(PTy->getElementType()) == TD.getTypeSize(GEP->getType()->getElementType())) { const PointerType *NewSrcTy = PointerType::get(PVTy); - if (!ExpressionConvertableToType(I->getOperand(0), NewSrcTy, CTMap)) + if (!ExpressionConvertableToType(I->getOperand(0), NewSrcTy, CTMap, TD)) return false; break; } @@ -300,7 +303,7 @@ const FunctionType *NewTy = FunctionType::get(Ty, ArgTys, FT->isVarArg()); if (!ExpressionConvertableToType(I->getOperand(0), - PointerType::get(NewTy), CTMap)) + PointerType::get(NewTy), CTMap, TD)) return false; break; } @@ -313,14 +316,15 @@ // recursion. // for (Value::use_iterator It = I->use_begin(), E = I->use_end(); It != E; ++It) - if (!OperandConvertableToType(*It, I, Ty, CTMap)) + if (!OperandConvertableToType(*It, I, Ty, CTMap, TD)) return false; return true; } -Value *ConvertExpressionToType(Value *V, const Type *Ty, ValueMapCache &VMC) { +Value *ConvertExpressionToType(Value *V, const Type *Ty, ValueMapCache &VMC, + const TargetData &TD) { if (V->getType() == Ty) return V; // Already where we need to be? ValueMapCache::ExprMapTy::iterator VMCI = VMC.ExprMap.find(V); @@ -373,8 +377,8 @@ Dummy, Dummy, Name); VMC.ExprMap[I] = Res; // Add node to expression eagerly - Res->setOperand(0, ConvertExpressionToType(I->getOperand(0), Ty, VMC)); - Res->setOperand(1, ConvertExpressionToType(I->getOperand(1), Ty, VMC)); + Res->setOperand(0, ConvertExpressionToType(I->getOperand(0), Ty, VMC, TD)); + Res->setOperand(1, ConvertExpressionToType(I->getOperand(1), Ty, VMC, TD)); break; case Instruction::Shl: @@ -382,7 +386,7 @@ Res = new ShiftInst(cast(I)->getOpcode(), Dummy, I->getOperand(1), Name); VMC.ExprMap[I] = Res; - Res->setOperand(0, ConvertExpressionToType(I->getOperand(0), Ty, VMC)); + Res->setOperand(0, ConvertExpressionToType(I->getOperand(0), Ty, VMC, TD)); break; case Instruction::Load: { @@ -391,7 +395,7 @@ Res = new LoadInst(Constant::getNullValue(PointerType::get(Ty)), Name); VMC.ExprMap[I] = Res; Res->setOperand(0, ConvertExpressionToType(LI->getPointerOperand(), - PointerType::get(Ty), VMC)); + PointerType::get(Ty), VMC, TD)); assert(Res->getOperand(0)->getType() == PointerType::get(Ty)); assert(Ty == Res->getType()); assert(Res->getType()->isFirstClassType() && "Load of structure or array!"); @@ -408,7 +412,7 @@ Value *OldVal = OldPN->getIncomingValue(0); ValueHandle OldValHandle(VMC, OldVal); OldPN->removeIncomingValue(BB, false); - Value *V = ConvertExpressionToType(OldVal, Ty, VMC); + Value *V = ConvertExpressionToType(OldVal, Ty, VMC, TD); NewPN->addIncoming(V, BB); } Res = NewPN; @@ -416,7 +420,7 @@ } case Instruction::Malloc: { - Res = ConvertMallocToType(cast(I), Ty, Name, VMC); + Res = ConvertMallocToType(cast(I), Ty, Name, VMC, TD); break; } @@ -468,14 +472,14 @@ // std::vector Indices; const Type *ElTy = ConvertableToGEP(NewSrcTy, I->getOperand(1), - Indices, &It); + Indices, TD, &It); if (ElTy) { assert(ElTy == PVTy && "Internal error, setup wrong!"); Res = new GetElementPtrInst(Constant::getNullValue(NewSrcTy), Indices, Name); VMC.ExprMap[I] = Res; Res->setOperand(0, ConvertExpressionToType(I->getOperand(0), - NewSrcTy, VMC)); + NewSrcTy, VMC, TD)); } } @@ -491,7 +495,7 @@ Indices, Name); VMC.ExprMap[I] = Res; Res->setOperand(0, ConvertExpressionToType(I->getOperand(0), - NewSrcTy, VMC)); + NewSrcTy, VMC, TD)); } @@ -519,7 +523,7 @@ std::vector(I->op_begin()+1, I->op_end()), Name); VMC.ExprMap[I] = Res; - Res->setOperand(0, ConvertExpressionToType(I->getOperand(0), NewPTy, VMC)); + Res->setOperand(0, ConvertExpressionToType(I->getOperand(0),NewPTy,VMC,TD)); break; } default: @@ -541,7 +545,7 @@ unsigned NumUses = I->use_size(); for (unsigned It = 0; It < NumUses; ) { unsigned OldSize = NumUses; - ConvertOperandToType(*(I->use_begin()+It), I, Res, VMC); + ConvertOperandToType(*(I->use_begin()+It), I, Res, VMC, TD); NumUses = I->use_size(); if (NumUses == OldSize) ++It; } @@ -556,7 +560,8 @@ // ValueConvertableToType - Return true if it is possible bool ValueConvertableToType(Value *V, const Type *Ty, - ValueTypeCache &ConvertedTypes) { + ValueTypeCache &ConvertedTypes, + const TargetData &TD) { ValueTypeCache::iterator I = ConvertedTypes.find(V); if (I != ConvertedTypes.end()) return I->second == Ty; ConvertedTypes[V] = Ty; @@ -566,7 +571,7 @@ // if (V->getType() != Ty) { for (Value::use_iterator I = V->use_begin(), E = V->use_end(); I != E; ++I) - if (!OperandConvertableToType(*I, V, Ty, ConvertedTypes)) + if (!OperandConvertableToType(*I, V, Ty, ConvertedTypes, TD)) return false; } @@ -584,7 +589,8 @@ // the expression, not the static current type. // static bool OperandConvertableToType(User *U, Value *V, const Type *Ty, - ValueTypeCache &CTMap) { + ValueTypeCache &CTMap, + const TargetData &TD) { // if (V->getType() == Ty) return true; // Operand already the right type? // Expression type must be holdable in a register. @@ -630,11 +636,11 @@ if (isa(Ty)) { Value *IndexVal = I->getOperand(V == I->getOperand(0) ? 1 : 0); std::vector Indices; - if (const Type *ETy = ConvertableToGEP(Ty, IndexVal, Indices)) { + if (const Type *ETy = ConvertableToGEP(Ty, IndexVal, Indices, TD)) { const Type *RetTy = PointerType::get(ETy); // Only successful if we can convert this type to the required type - if (ValueConvertableToType(I, RetTy, CTMap)) { + if (ValueConvertableToType(I, RetTy, CTMap, TD)) { CTMap[I] = RetTy; return true; } @@ -648,13 +654,13 @@ if (!Ty->isInteger() && !Ty->isFloatingPoint()) return false; Value *OtherOp = I->getOperand((V == I->getOperand(0)) ? 1 : 0); - return ValueConvertableToType(I, Ty, CTMap) && - ExpressionConvertableToType(OtherOp, Ty, CTMap); + return ValueConvertableToType(I, Ty, CTMap, TD) && + ExpressionConvertableToType(OtherOp, Ty, CTMap, TD); } case Instruction::SetEQ: case Instruction::SetNE: { Value *OtherOp = I->getOperand((V == I->getOperand(0)) ? 1 : 0); - return ExpressionConvertableToType(OtherOp, Ty, CTMap); + return ExpressionConvertableToType(OtherOp, Ty, CTMap, TD); } case Instruction::Shr: if (Ty->isSigned() != V->getType()->isSigned()) return false; @@ -662,7 +668,7 @@ case Instruction::Shl: if (I->getOperand(1) == V) return false; // Cannot change shift amount type if (!Ty->isInteger()) return false; - return ValueConvertableToType(I, Ty, CTMap); + return ValueConvertableToType(I, Ty, CTMap, TD); case Instruction::Free: assert(I->getOperand(0) == V); @@ -681,7 +687,7 @@ if (const CompositeType *CT = dyn_cast(LoadedTy)) { unsigned Offset = 0; // No offset, get first leaf. std::vector Indices; // Discarded... - LoadedTy = getStructOffsetType(CT, Offset, Indices, false); + LoadedTy = getStructOffsetType(CT, Offset, Indices, TD, false); assert(Offset == 0 && "Offset changed from zero???"); } @@ -691,7 +697,7 @@ if (TD.getTypeSize(LoadedTy) != TD.getTypeSize(LI->getType())) return false; - return ValueConvertableToType(LI, LoadedTy, CTMap); + return ValueConvertableToType(LI, LoadedTy, CTMap, TD); } return false; @@ -722,7 +728,7 @@ if (const StructType *SElTy = dyn_cast(ElTy)) { unsigned Offset = 0; std::vector Indices; - ElTy = getStructOffsetType(ElTy, Offset, Indices, false); + ElTy = getStructOffsetType(ElTy, Offset, Indices, TD, false); assert(Offset == 0 && "Offset changed!"); if (ElTy == 0) // Element at offset zero in struct doesn't exist! return false; // Can only happen for {}* @@ -738,7 +744,7 @@ // Can convert the store if we can convert the pointer operand to match // the new value type... return ExpressionConvertableToType(I->getOperand(1), PointerType::get(Ty), - CTMap); + CTMap, TD); } else if (const PointerType *PT = dyn_cast(Ty)) { const Type *ElTy = PT->getElementType(); assert(V == I->getOperand(1)); @@ -749,7 +755,7 @@ // unsigned Offset = 0; std::vector Indices; - ElTy = getStructOffsetType(ElTy, Offset, Indices, false); + ElTy = getStructOffsetType(ElTy, Offset, Indices, TD, false); assert(Offset == 0 && "Offset changed!"); if (ElTy == 0) // Element at offset zero in struct doesn't exist! return false; // Can only happen for {}* @@ -761,7 +767,7 @@ return false; // Can convert store if the incoming value is convertable... - return ExpressionConvertableToType(I->getOperand(0), ElTy, CTMap); + return ExpressionConvertableToType(I->getOperand(0), ElTy, CTMap, TD); } return false; } @@ -795,20 +801,20 @@ // be converted to the appropriate size... if so, allow it. // std::vector Indices; - const Type *ElTy = ConvertableToGEP(Ty, Index, Indices); + const Type *ElTy = ConvertableToGEP(Ty, Index, Indices, TD); delete TempScale; // Free our temporary multiply if we made it if (ElTy == 0) return false; // Cannot make conversion... - return ValueConvertableToType(I, PointerType::get(ElTy), CTMap); + return ValueConvertableToType(I, PointerType::get(ElTy), CTMap, TD); } return false; case Instruction::PHINode: { PHINode *PN = cast(I); for (unsigned i = 0; i < PN->getNumIncomingValues(); ++i) - if (!ExpressionConvertableToType(PN->getIncomingValue(i), Ty, CTMap)) + if (!ExpressionConvertableToType(PN->getIncomingValue(i), Ty, CTMap, TD)) return false; - return ValueConvertableToType(PN, Ty, CTMap); + return ValueConvertableToType(PN, Ty, CTMap, TD); } case Instruction::Call: { @@ -859,7 +865,7 @@ // converted. We succeed if we can change the return type if // neccesary... // - return ValueConvertableToType(I, FTy->getReturnType(), CTMap); + return ValueConvertableToType(I, FTy->getReturnType(), CTMap, TD); } const PointerType *MPtr = cast(I->getOperand(0)->getType()); @@ -879,13 +885,14 @@ } -void ConvertValueToNewType(Value *V, Value *NewVal, ValueMapCache &VMC) { +void ConvertValueToNewType(Value *V, Value *NewVal, ValueMapCache &VMC, + const TargetData &TD) { ValueHandle VH(VMC, V); unsigned NumUses = V->use_size(); for (unsigned It = 0; It < NumUses; ) { unsigned OldSize = NumUses; - ConvertOperandToType(*(V->use_begin()+It), V, NewVal, VMC); + ConvertOperandToType(*(V->use_begin()+It), V, NewVal, VMC, TD); NumUses = V->use_size(); if (NumUses == OldSize) ++It; } @@ -894,7 +901,7 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal, - ValueMapCache &VMC) { + ValueMapCache &VMC, const TargetData &TD) { if (isa(U)) return; // Valuehandles don't let go of operands... if (VMC.OperandsMapped.count(U)) return; @@ -944,7 +951,7 @@ std::vector Indices; BasicBlock::iterator It = I; - if (const Type *ETy = ConvertableToGEP(NewTy, IndexVal, Indices, &It)) { + if (const Type *ETy = ConvertableToGEP(NewTy, IndexVal, Indices, TD,&It)){ // If successful, convert the add to a GEP //const Type *RetTy = PointerType::get(ETy); // First operand is actually the given pointer... @@ -965,7 +972,7 @@ unsigned OtherIdx = (OldVal == I->getOperand(0)) ? 1 : 0; Value *OtherOp = I->getOperand(OtherIdx); - Value *NewOther = ConvertExpressionToType(OtherOp, NewTy, VMC); + Value *NewOther = ConvertExpressionToType(OtherOp, NewTy, VMC, TD); Res->setOperand(OtherIdx, NewOther); Res->setOperand(!OtherIdx, NewVal); @@ -996,7 +1003,7 @@ Indices.push_back(ConstantSInt::get(Type::LongTy, 0)); unsigned Offset = 0; // No offset, get first leaf. - LoadedTy = getStructOffsetType(CT, Offset, Indices, false); + LoadedTy = getStructOffsetType(CT, Offset, Indices, TD, false); assert(LoadedTy->isFirstClassType()); if (Indices.size() != 1) { // Do not generate load X, 0 @@ -1032,7 +1039,7 @@ Indices.push_back(Constant::getNullValue(Type::LongTy)); unsigned Offset = 0; - const Type *Ty = getStructOffsetType(ElTy, Offset, Indices, false); + const Type *Ty = getStructOffsetType(ElTy, Offset, Indices, TD,false); assert(Offset == 0 && "Offset changed!"); assert(NewTy == Ty && "Did not convert to correct type!"); @@ -1049,7 +1056,7 @@ Res = new StoreInst(NewVal, Constant::getNullValue(NewPT)); VMC.ExprMap[I] = Res; Res->setOperand(1, ConvertExpressionToType(I->getOperand(1), - NewPT, VMC)); + NewPT, VMC, TD)); } } else { // Replace the source pointer const Type *ValTy = cast(NewTy)->getElementType(); @@ -1061,7 +1068,7 @@ Indices.push_back(Constant::getNullValue(Type::LongTy)); unsigned Offset = 0; - ValTy = getStructOffsetType(ValTy, Offset, Indices, false); + ValTy = getStructOffsetType(ValTy, Offset, Indices, TD, false); assert(Offset == 0 && ValTy); @@ -1072,7 +1079,8 @@ Res = new StoreInst(Constant::getNullValue(ValTy), SrcPtr); VMC.ExprMap[I] = Res; - Res->setOperand(0, ConvertExpressionToType(I->getOperand(0), ValTy, VMC)); + Res->setOperand(0, ConvertExpressionToType(I->getOperand(0), + ValTy, VMC, TD)); } break; } @@ -1097,7 +1105,7 @@ // Perform the conversion now... // std::vector Indices; - const Type *ElTy = ConvertableToGEP(NewVal->getType(), Index, Indices, &It); + const Type *ElTy = ConvertableToGEP(NewVal->getType(),Index,Indices,TD,&It); assert(ElTy != 0 && "GEP Conversion Failure!"); Res = new GetElementPtrInst(NewVal, Indices, Name); assert(Res->getType() == PointerType::get(ElTy) && @@ -1115,7 +1123,7 @@ // std::vector Indices; const Type *ElTy = ConvertableToGEP(NewVal->getType(), I->getOperand(1), - Indices, &It); + Indices, TD, &It); assert(ElTy != 0 && "GEP Conversion Failure!"); Res = new GetElementPtrInst(NewVal, Indices, Name); @@ -1140,7 +1148,7 @@ BasicBlock *BB = OldPN->getIncomingBlock(0); Value *OldVal = OldPN->getIncomingValue(0); OldPN->removeIncomingValue(BB, false); - Value *V = ConvertExpressionToType(OldVal, NewTy, VMC); + Value *V = ConvertExpressionToType(OldVal, NewTy, VMC, TD); NewPN->addIncoming(V, BB); } Res = NewPN; @@ -1211,7 +1219,7 @@ VMC.ExprMap[I] = Res; if (I->getType() != Res->getType()) - ConvertValueToNewType(I, Res, VMC); + ConvertValueToNewType(I, Res, VMC, TD); else { for (unsigned It = 0; It < I->use_size(); ) { User *Use = *(I->use_begin()+It); Index: llvm/lib/Transforms/LevelRaise.cpp diff -u llvm/lib/Transforms/LevelRaise.cpp:1.76 llvm/lib/Transforms/LevelRaise.cpp:1.77 --- llvm/lib/Transforms/LevelRaise.cpp:1.76 Wed Nov 20 12:34:35 2002 +++ llvm/lib/Transforms/LevelRaise.cpp Thu Apr 24 13:25:27 2003 @@ -62,6 +62,28 @@ do { PRINT_PEEPHOLE(ID, 0, I1); PRINT_PEEPHOLE(ID, 1, I2); \ PRINT_PEEPHOLE(ID, 2, I3); PRINT_PEEPHOLE(ID, 3, I4); } while (0) +namespace { + struct RPR : public FunctionPass { + virtual bool runOnFunction(Function &F); + + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.setPreservesCFG(); + AU.addRequired(); + } + + private: + bool DoRaisePass(Function &F); + bool PeepholeOptimize(BasicBlock *BB, BasicBlock::iterator &BI); + }; + + RegisterOpt X("raise", "Raise Pointer References"); +} + +Pass *createRaisePointerReferencesPass() { + return new RPR(); +} + + // isReinterpretingCast - Return true if the cast instruction specified will // cause the operand to be "reinterpreted". A value is reinterpreted if the @@ -80,7 +102,8 @@ // %t2 = cast * %t3 to {<...>}* // static bool HandleCastToPointer(BasicBlock::iterator BI, - const PointerType *DestPTy) { + const PointerType *DestPTy, + const TargetData &TD) { CastInst &CI = cast(*BI); if (CI.use_empty()) return false; @@ -101,7 +124,7 @@ std::vector Indices; Value *Src = CI.getOperand(0); - const Type *Result = ConvertableToGEP(DestPTy, Src, Indices, &BI); + const Type *Result = ConvertableToGEP(DestPTy, Src, Indices, TD, &BI); if (Result == 0) return false; // Not convertable... PRINT_PEEPHOLE2("cast-add-to-gep:in", Src, CI); @@ -155,7 +178,8 @@ // %t2 = cast * %t3 to {<...>}* // static bool PeepholeOptimizeAddCast(BasicBlock *BB, BasicBlock::iterator &BI, - Value *AddOp1, CastInst *AddOp2) { + Value *AddOp1, CastInst *AddOp2, + const TargetData &TD) { const CompositeType *CompTy; Value *OffsetVal = AddOp2->getOperand(0); Value *SrcPtr = 0; // Of type pointer to struct... @@ -172,7 +196,7 @@ return false; std::vector Indices; - if (!ConvertableToGEP(SrcPtr->getType(), OffsetVal, Indices, &BI)) + if (!ConvertableToGEP(SrcPtr->getType(), OffsetVal, Indices, TD, &BI)) return false; // Not convertable... perhaps next time if (getPointedToComposite(AddOp1->getType())) { // case 1 @@ -190,8 +214,9 @@ return true; } -static bool PeepholeOptimize(BasicBlock *BB, BasicBlock::iterator &BI) { +bool RPR::PeepholeOptimize(BasicBlock *BB, BasicBlock::iterator &BI) { Instruction *I = BI; + const TargetData &TD = getAnalysis(); if (CastInst *CI = dyn_cast(I)) { Value *Src = CI->getOperand(0); @@ -230,13 +255,13 @@ // destination type of the cast... // ConvertedTypes[CI] = CI->getType(); // Make sure the cast doesn't change - if (ExpressionConvertableToType(Src, DestTy, ConvertedTypes)) { + if (ExpressionConvertableToType(Src, DestTy, ConvertedTypes, TD)) { PRINT_PEEPHOLE3("CAST-SRC-EXPR-CONV:in ", Src, CI, BB->getParent()); DEBUG(cerr << "\nCONVERTING SRC EXPR TYPE:\n"); { // ValueMap must be destroyed before function verified! ValueMapCache ValueMap; - Value *E = ConvertExpressionToType(Src, DestTy, ValueMap); + Value *E = ConvertExpressionToType(Src, DestTy, ValueMap, TD); if (Constant *CPV = dyn_cast(E)) CI->replaceAllUsesWith(CPV); @@ -258,13 +283,13 @@ ConvertedTypes.clear(); // Make sure the source doesn't change type ConvertedTypes[Src] = Src->getType(); - if (ValueConvertableToType(CI, Src->getType(), ConvertedTypes)) { + if (ValueConvertableToType(CI, Src->getType(), ConvertedTypes, TD)) { PRINT_PEEPHOLE3("CAST-DEST-EXPR-CONV:in ", Src, CI, BB->getParent()); DEBUG(cerr << "\nCONVERTING EXPR TYPE:\n"); { // ValueMap must be destroyed before function verified! ValueMapCache ValueMap; - ConvertValueToNewType(CI, Src, ValueMap); // This will delete CI! + ConvertValueToNewType(CI, Src, ValueMap, TD); // This will delete CI! } PRINT_PEEPHOLE1("CAST-DEST-EXPR-CONV:out", Src); @@ -283,7 +308,7 @@ // so, convert the add into a getelementptr instruction... // if (const PointerType *DestPTy = dyn_cast(DestTy)) { - if (HandleCastToPointer(BI, DestPTy)) { + if (HandleCastToPointer(BI, DestPTy, TD)) { BI = BB->begin(); // Rescan basic block. BI might be invalidated. ++NumGEPInstFormed; return true; @@ -454,7 +479,7 @@ isa(I->getOperand(1))) { if (PeepholeOptimizeAddCast(BB, BI, I->getOperand(0), - cast(I->getOperand(1)))) { + cast(I->getOperand(1)), TD)) { ++NumGEPInstFormed; return true; } @@ -500,7 +525,7 @@ -static bool DoRaisePass(Function &F) { +bool RPR::DoRaisePass(Function &F) { bool Changed = false; for (Function::iterator BB = F.begin(), BBE = F.end(); BB != BBE; ++BB) for (BasicBlock::iterator BI = BB->begin(); BI != BB->end();) { @@ -520,17 +545,14 @@ } -// RaisePointerReferences::doit - Raise a function representation to a higher -// level. -// -static bool doRPR(Function &F) { +// runOnFunction - Raise a function representation to a higher level. +bool RPR::runOnFunction(Function &F) { DEBUG(cerr << "\n\n\nStarting to work on Function '" << F.getName() << "'\n"); // Insert casts for all incoming pointer pointer values that are treated as // arrays... // bool Changed = false, LocalChange; - // If the StartInst option was specified, then Peephole optimize that // instruction first if it occurs in this function. @@ -559,24 +581,3 @@ return Changed; } - -namespace { - struct RaisePointerReferences : public FunctionPass { - - // FIXME: constructor should save and use target data here!! - RaisePointerReferences(const TargetData &TD) {} - - virtual bool runOnFunction(Function &F) { return doRPR(F); } - - virtual void getAnalysisUsage(AnalysisUsage &AU) const { - AU.setPreservesCFG(); - } - }; -} - -Pass *createRaisePointerReferencesPass(const TargetData &TD) { - return new RaisePointerReferences(TD); -} - -static RegisterOpt -X("raise", "Raise Pointer References", createRaisePointerReferencesPass); Index: llvm/lib/Transforms/TransformInternals.cpp diff -u llvm/lib/Transforms/TransformInternals.cpp:1.32 llvm/lib/Transforms/TransformInternals.cpp:1.33 --- llvm/lib/Transforms/TransformInternals.cpp:1.32 Wed Jan 22 20:39:10 2003 +++ llvm/lib/Transforms/TransformInternals.cpp Thu Apr 24 13:25:27 2003 @@ -11,15 +11,9 @@ #include "llvm/Function.h" #include "llvm/iOther.h" -// TargetData Hack: Eventually we will have annotations given to us by the -// backend so that we know stuff about type size and alignments. For now -// though, just use this, because it happens to match the model that GCC uses. -// -const TargetData TD("LevelRaise: Should be GCC though!"); - - static const Type *getStructOffsetStep(const StructType *STy, uint64_t &Offset, - std::vector &Indices) { + std::vector &Indices, + const TargetData &TD) { assert(Offset < TD.getTypeSize(STy) && "Offset not in composite!"); const StructLayout *SL = TD.getStructLayout(STy); @@ -52,7 +46,7 @@ // const Type *getStructOffsetType(const Type *Ty, unsigned &Offset, std::vector &Indices, - bool StopEarly) { + const TargetData &TD, bool StopEarly) { if (Offset == 0 && StopEarly && !Indices.empty()) return Ty; // Return the leaf type @@ -60,7 +54,7 @@ const Type *NextType; if (const StructType *STy = dyn_cast(Ty)) { ThisOffset = Offset; - NextType = getStructOffsetStep(STy, ThisOffset, Indices); + NextType = getStructOffsetStep(STy, ThisOffset, Indices, TD); } else if (const ArrayType *ATy = dyn_cast(Ty)) { assert(Offset < TD.getTypeSize(ATy) && "Offset not in composite!"); @@ -75,7 +69,7 @@ unsigned SubOffs = Offset - ThisOffset; const Type *LeafTy = getStructOffsetType(NextType, SubOffs, - Indices, StopEarly); + Indices, TD, StopEarly); Offset = ThisOffset + SubOffs; return LeafTy; } @@ -87,6 +81,7 @@ // const Type *ConvertableToGEP(const Type *Ty, Value *OffsetVal, std::vector &Indices, + const TargetData &TD, BasicBlock::iterator *BI) { const CompositeType *CompTy = dyn_cast(Ty); if (CompTy == 0) return 0; @@ -116,7 +111,7 @@ if (const StructType *StructTy = dyn_cast(CompTy)) { // Step into the appropriate element of the structure... uint64_t ActualOffset = (Offset < 0) ? 0 : (uint64_t)Offset; - NextTy = getStructOffsetStep(StructTy, ActualOffset, Indices); + NextTy = getStructOffsetStep(StructTy, ActualOffset, Indices, TD); Offset -= ActualOffset; } else { const Type *ElTy = cast(CompTy)->getElementType(); Index: llvm/lib/Transforms/TransformInternals.h diff -u llvm/lib/Transforms/TransformInternals.h:1.16 llvm/lib/Transforms/TransformInternals.h:1.17 --- llvm/lib/Transforms/TransformInternals.h:1.16 Mon Sep 16 13:32:33 2002 +++ llvm/lib/Transforms/TransformInternals.h Thu Apr 24 13:25:27 2003 @@ -15,14 +15,6 @@ #include #include -// TargetData Hack: Eventually we will have annotations given to us by the -// backend so that we know stuff about type size and alignments. For now -// though, just use this, because it happens to match the model that GCC uses. -// -// FIXME: This should use annotations -// -extern const TargetData TD; - static inline int64_t getConstantValue(const ConstantInt *CPI) { if (const ConstantSInt *CSI = dyn_cast(CPI)) return CSI->getValue(); @@ -49,6 +41,7 @@ // const Type *ConvertableToGEP(const Type *Ty, Value *V, std::vector &Indices, + const TargetData &TD, BasicBlock::iterator *BI = 0); @@ -112,14 +105,18 @@ }; -bool ExpressionConvertableToType(Value *V, const Type *Ty, ValueTypeCache &Map); -Value *ConvertExpressionToType(Value *V, const Type *Ty, ValueMapCache &VMC); +bool ExpressionConvertableToType(Value *V, const Type *Ty, ValueTypeCache &Map, + const TargetData &TD); +Value *ConvertExpressionToType(Value *V, const Type *Ty, ValueMapCache &VMC, + const TargetData &TD); // ValueConvertableToType - Return true if it is possible bool ValueConvertableToType(Value *V, const Type *Ty, - ValueTypeCache &ConvertedTypes); + ValueTypeCache &ConvertedTypes, + const TargetData &TD); -void ConvertValueToNewType(Value *V, Value *NewVal, ValueMapCache &VMC); +void ConvertValueToNewType(Value *V, Value *NewVal, ValueMapCache &VMC, + const TargetData &TD); // getStructOffsetType - Return a vector of offsets that are to be used to index @@ -135,6 +132,6 @@ // const Type *getStructOffsetType(const Type *Ty, unsigned &Offset, std::vector &Offsets, - bool StopEarly = true); + const TargetData &TD, bool StopEarly = true); #endif From lattner at cs.uiuc.edu Thu Apr 24 13:26:06 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Apr 24 13:26:06 2003 Subject: [llvm-commits] CVS: llvm/include/llvm/Transforms/RaisePointerReferences.h Message-ID: <200304241825.NAA26254@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Transforms: RaisePointerReferences.h updated: 1.4 -> 1.5 --- Log message: LevelRaise now gets TD from passmanager --- Diffs of the changes: Index: llvm/include/llvm/Transforms/RaisePointerReferences.h diff -u llvm/include/llvm/Transforms/RaisePointerReferences.h:1.4 llvm/include/llvm/Transforms/RaisePointerReferences.h:1.5 --- llvm/include/llvm/Transforms/RaisePointerReferences.h:1.4 Tue Jul 23 12:58:42 2002 +++ llvm/include/llvm/Transforms/RaisePointerReferences.h Thu Apr 24 13:25:42 2003 @@ -10,12 +10,11 @@ #define LLVM_TRANSFORMS_LEVELCHANGE_H class Pass; -class TargetData; // RaisePointerReferences - Try to eliminate as many pointer arithmetic // expressions as possible, by converting expressions to use getelementptr and // friends. // -Pass *createRaisePointerReferencesPass(const TargetData &TD); +Pass *createRaisePointerReferencesPass(); #endif From lattner at cs.uiuc.edu Thu Apr 24 13:27:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Apr 24 13:27:01 2003 Subject: [llvm-commits] CVS: llvm/tools/gccas/gccas.cpp Message-ID: <200304241826.NAA26269@apoc.cs.uiuc.edu> Changes in directory llvm/tools/gccas: gccas.cpp updated: 1.59 -> 1.60 --- Log message: LevelRaise now gets target data from passmanager --- Diffs of the changes: Index: llvm/tools/gccas/gccas.cpp diff -u llvm/tools/gccas/gccas.cpp:1.59 llvm/tools/gccas/gccas.cpp:1.60 --- llvm/tools/gccas/gccas.cpp:1.59 Wed Apr 23 15:40:42 2003 +++ llvm/tools/gccas/gccas.cpp Thu Apr 24 13:26:03 2003 @@ -23,9 +23,6 @@ #include namespace { - // FIXME: This should eventually be parameterized... - TargetData TD("gccas target"); - cl::opt InputFilename(cl::Positional,cl::desc(""),cl::init("-")); @@ -74,7 +71,7 @@ addPass(PM, createDeadInstEliminationPass()); // Remove Dead code/vars addPass(PM, createRaiseAllocationsPass()); // call %malloc -> malloc inst addPass(PM, createIndVarSimplifyPass()); // Simplify indvars - addPass(PM, createRaisePointerReferencesPass(TD));// Recover type information + addPass(PM, createRaisePointerReferencesPass());// Recover type information addPass(PM, createInstructionCombiningPass()); // Combine silly seq's addPass(PM, createPromoteMemoryToRegister()); // Promote alloca's to regs addPass(PM, createReassociatePass()); // Reassociate expressions @@ -96,6 +93,9 @@ int main(int argc, char **argv) { cl::ParseCommandLineOptions(argc, argv, " llvm .s -> .o assembler for GCC\n"); + + // FIXME: This should eventually be parameterized... + TargetData TD("gccas target"); std::auto_ptr M; try { From lattner at cs.uiuc.edu Thu Apr 24 13:37:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Apr 24 13:37:01 2003 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/PreOpts/PreSelection.cpp Message-ID: <200304241836.NAA28071@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/PreOpts: PreSelection.cpp updated: 1.8 -> 1.9 --- Log message: Trivial cleanup --- Diffs of the changes: Index: llvm/lib/CodeGen/PreOpts/PreSelection.cpp diff -u llvm/lib/CodeGen/PreOpts/PreSelection.cpp:1.8 llvm/lib/CodeGen/PreOpts/PreSelection.cpp:1.9 --- llvm/lib/CodeGen/PreOpts/PreSelection.cpp:1.8 Wed Apr 16 15:28:33 2003 +++ llvm/lib/CodeGen/PreOpts/PreSelection.cpp Thu Apr 24 13:35:51 2003 @@ -150,13 +150,13 @@ void visitOneOperand(Instruction &I, Constant* CV, unsigned opNum, Instruction& insertBefore); // iworks on one operand }; -} // end anonymous namespace + // Register the pass... + RegisterOpt X("preselect", + "Specialize LLVM code for a target machine", + createPreSelectionPass); +} // end anonymous namespace -// Register the pass... -static RegisterOpt X("preselect", - "Specialize LLVM code for a target machine", - createPreSelectionPass); //------------------------------------------------------------------------------ // Helper functions used by methods of class PreSelection From lattner at cs.uiuc.edu Thu Apr 24 13:37:05 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Apr 24 13:37:05 2003 Subject: [llvm-commits] CVS: llvm/tools/bugpoint/OptimizerDriver.cpp Message-ID: <200304241836.NAA28233@apoc.cs.uiuc.edu> Changes in directory llvm/tools/bugpoint: OptimizerDriver.cpp updated: 1.4 -> 1.5 --- Log message: Remove support for "target data" pass ctors --- Diffs of the changes: Index: llvm/tools/bugpoint/OptimizerDriver.cpp diff -u llvm/tools/bugpoint/OptimizerDriver.cpp:1.4 llvm/tools/bugpoint/OptimizerDriver.cpp:1.5 --- llvm/tools/bugpoint/OptimizerDriver.cpp:1.4 Thu Apr 24 12:02:17 2003 +++ llvm/tools/bugpoint/OptimizerDriver.cpp Thu Apr 24 13:36:36 2003 @@ -65,9 +65,6 @@ std::cout << getPassesString(PassesToRun) << "\n"; } -/// FIXME: This should be parameterizable!! -static TargetData TD("bugpoint target"); - static void RunChild(Module *Program,const std::vector &Passes, const std::string &OutFilename) { std::ofstream OutFile(OutFilename.c_str()); @@ -80,8 +77,6 @@ for (unsigned i = 0, e = Passes.size(); i != e; ++i) { if (Passes[i]->getNormalCtor()) PM.add(Passes[i]->getNormalCtor()()); - else if (Passes[i]->getDataCtor()) - PM.add(Passes[i]->getDataCtor()(TD)); // Provide dummy target data... else std::cerr << "Cannot create pass yet: " << Passes[i]->getPassName() << "\n"; From lattner at cs.uiuc.edu Thu Apr 24 13:37:08 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Apr 24 13:37:08 2003 Subject: [llvm-commits] CVS: llvm/tools/gccas/gccas.cpp Message-ID: <200304241836.NAA28240@apoc.cs.uiuc.edu> Changes in directory llvm/tools/gccas: gccas.cpp updated: 1.60 -> 1.61 --- Log message: Remove support for "target data" pass ctors --- Diffs of the changes: Index: llvm/tools/gccas/gccas.cpp diff -u llvm/tools/gccas/gccas.cpp:1.60 llvm/tools/gccas/gccas.cpp:1.61 --- llvm/tools/gccas/gccas.cpp:1.60 Thu Apr 24 13:26:03 2003 +++ llvm/tools/gccas/gccas.cpp Thu Apr 24 13:36:37 2003 @@ -94,9 +94,6 @@ int main(int argc, char **argv) { cl::ParseCommandLineOptions(argc, argv, " llvm .s -> .o assembler for GCC\n"); - // FIXME: This should eventually be parameterized... - TargetData TD("gccas target"); - std::auto_ptr M; try { // Parse the file now... From lattner at cs.uiuc.edu Thu Apr 24 13:37:12 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Apr 24 13:37:12 2003 Subject: [llvm-commits] CVS: llvm/tools/llc/llc.cpp Message-ID: <200304241836.NAA28248@apoc.cs.uiuc.edu> Changes in directory llvm/tools/llc: llc.cpp updated: 1.65 -> 1.66 --- Log message: Remove support for "target data" pass ctors --- Diffs of the changes: Index: llvm/tools/llc/llc.cpp diff -u llvm/tools/llc/llc.cpp:1.65 llvm/tools/llc/llc.cpp:1.66 --- llvm/tools/llc/llc.cpp:1.65 Tue Jan 14 16:57:15 2003 +++ llvm/tools/llc/llc.cpp Thu Apr 24 13:36:39 2003 @@ -200,8 +200,6 @@ { // handle other passes as normal optimization passes if (Opt->getNormalCtor()) Passes.add(Opt->getNormalCtor()()); - else if (Opt->getDataCtor()) - Passes.add(Opt->getDataCtor()(Target.getTargetData())); else if (Opt->getTargetCtor()) Passes.add(Opt->getTargetCtor()(Target)); else From lattner at cs.uiuc.edu Thu Apr 24 13:37:15 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Apr 24 13:37:15 2003 Subject: [llvm-commits] CVS: llvm/tools/opt/opt.cpp Message-ID: <200304241836.NAA28262@apoc.cs.uiuc.edu> Changes in directory llvm/tools/opt: opt.cpp updated: 1.79 -> 1.80 --- Log message: Remove support for "target data" pass ctors --- Diffs of the changes: Index: llvm/tools/opt/opt.cpp diff -u llvm/tools/opt/opt.cpp:1.79 llvm/tools/opt/opt.cpp:1.80 --- llvm/tools/opt/opt.cpp:1.79 Wed Apr 16 18:02:16 2003 +++ llvm/tools/opt/opt.cpp Thu Apr 24 13:36:41 2003 @@ -68,9 +68,6 @@ cl::ParseCommandLineOptions(argc, argv, " llvm .bc -> .bc modular optimizer\n"); - // FIXME: The choice of target should be controllable on the command line. - TargetData TD("opt target"); - // Allocate a full target machine description only if necessary... // FIXME: The choice of target should be controllable on the command line. std::auto_ptr target; @@ -122,8 +119,6 @@ if (Opt->getNormalCtor()) Passes.add(Opt->getNormalCtor()()); - else if (Opt->getDataCtor()) - Passes.add(Opt->getDataCtor()(TD)); // Provide dummy target data... else if (Opt->getTargetCtor()) { #if 0 if (target.get() == NULL) From lattner at cs.uiuc.edu Thu Apr 24 13:42:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Apr 24 13:42:01 2003 Subject: [llvm-commits] CVS: llvm/include/llvm/Support/PassNameParser.h Message-ID: <200304241841.NAA29166@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Support: PassNameParser.h updated: 1.4 -> 1.5 --- Log message: Remove support for "targetdata pass ctors" --- Diffs of the changes: Index: llvm/include/llvm/Support/PassNameParser.h diff -u llvm/include/llvm/Support/PassNameParser.h:1.4 llvm/include/llvm/Support/PassNameParser.h:1.5 --- llvm/include/llvm/Support/PassNameParser.h:1.4 Fri Dec 6 22:41:22 2002 +++ llvm/include/llvm/Support/PassNameParser.h Thu Apr 24 13:41:13 2003 @@ -48,8 +48,7 @@ // Ignore non-selectable and non-constructible passes! Ignore // non-optimizations. return P->getPassArgument() == 0 || *P->getPassArgument() == 0 || - (P->getNormalCtor() == 0 && P->getDataCtor() == 0 && - P->getTargetCtor() == 0) || + (P->getNormalCtor() == 0 && P->getTargetCtor() == 0) || ignorablePassImpl(P); } From lattner at cs.uiuc.edu Thu Apr 24 13:42:06 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Apr 24 13:42:06 2003 Subject: [llvm-commits] CVS: llvm/include/llvm/PassSupport.h Message-ID: <200304241841.NAA29179@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: PassSupport.h updated: 1.10 -> 1.11 --- Log message: Remove support for "targetdata pass ctors" --- Diffs of the changes: Index: llvm/include/llvm/PassSupport.h diff -u llvm/include/llvm/PassSupport.h:1.10 llvm/include/llvm/PassSupport.h:1.11 --- llvm/include/llvm/PassSupport.h:1.10 Mon Feb 24 18:00:50 2003 +++ llvm/include/llvm/PassSupport.h Thu Apr 24 13:41:30 2003 @@ -16,7 +16,6 @@ // No need to include Pass.h, we are being included by it! -class TargetData; class TargetMachine; //===--------------------------------------------------------------------------- @@ -33,7 +32,6 @@ std::vector ItfImpl;// Interfaces implemented by this pass Pass *(*NormalCtor)(); // No argument ctor - Pass *(*DataCtor)(const TargetData&);// Ctor taking const TargetData object... Pass *(*TargetCtor)(TargetMachine&); // Ctor taking TargetMachine object... public: @@ -50,10 +48,9 @@ /// through RegisterPass. PassInfo(const char *name, const char *arg, const std::type_info &ti, unsigned pt, Pass *(*normal)() = 0, - Pass *(*datactor)(const TargetData &) = 0, Pass *(*targetctor)(TargetMachine &) = 0) : PassName(name), PassArgument(arg), TypeInfo(ti), PassType(pt), - NormalCtor(normal), DataCtor(datactor), TargetCtor(targetctor) { + NormalCtor(normal), TargetCtor(targetctor) { } /// getPassName - Return the friendly name for the pass, never returns null @@ -97,14 +94,6 @@ return NormalCtor(); } - /// getDataCtor - Return a pointer to a function that creates an instance of - /// the pass and returns it. This returns a constructor for a version of the - /// pass that takes a TargetData object as a parameter. - /// - Pass *(*getDataCtor() const)(const TargetData &) { - return DataCtor; - } - /// getTargetCtor - Return a pointer to a function that creates an instance of /// the pass and returns it. This returns a constructor for a version of the /// pass that takes a TargetMachine object as a parameter. @@ -171,8 +160,6 @@ template Pass *callDefaultCtor() { return new PassName(); } -template -Pass *callTargetDataCtor(const TargetData &TD) { return new PassName(TD); } template struct RegisterPass : public RegisterPassBase { @@ -189,18 +176,11 @@ registerPass(new PassInfo(Name, PassArg, typeid(PassName), PassTy, ctor)); } - // Register Pass using TargetData constructor... - RegisterPass(const char *PassArg, const char *Name, unsigned PassTy, - Pass *(*datactor)(const TargetData &)) { - registerPass(new PassInfo(Name, PassArg, typeid(PassName), PassTy, - 0, datactor)); - } - // Register Pass using TargetMachine constructor... RegisterPass(const char *PassArg, const char *Name, unsigned PassTy, Pass *(*targetctor)(TargetMachine &)) { registerPass(new PassInfo(Name, PassArg, typeid(PassName), PassTy, - 0, 0, targetctor)); + 0, targetctor)); } // Generic constructor version that has an unknown ctor type... @@ -229,20 +209,12 @@ PassInfo::Optimization, ctor)); } - /// Register Pass using TargetData constructor... - /// - RegisterOpt(const char *PassArg, const char *Name, - Pass *(*datactor)(const TargetData &)) { - registerPass(new PassInfo(Name, PassArg, typeid(PassName), - PassInfo::Optimization, 0, datactor)); - } - /// Register Pass using TargetMachine constructor... /// RegisterOpt(const char *PassArg, const char *Name, Pass *(*targetctor)(TargetMachine &)) { registerPass(new PassInfo(Name, PassArg, typeid(PassName), - PassInfo::Optimization, 0, 0, targetctor)); + PassInfo::Optimization, 0, targetctor)); } }; @@ -280,14 +252,6 @@ RegisterLLC(const char *PassArg, const char *Name, Pass *(*ctor)()) { registerPass(new PassInfo(Name, PassArg, typeid(PassName), PassInfo::LLC, ctor)); - } - - /// Register Pass using TargetData constructor... - /// - RegisterLLC(const char *PassArg, const char *Name, - Pass *(*datactor)(const TargetData &)) { - registerPass(new PassInfo(Name, PassArg, typeid(PassName), - PassInfo::LLC, 0, datactor)); } /// Register Pass using TargetMachine constructor... From lattner at cs.uiuc.edu Thu Apr 24 14:09:02 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Apr 24 14:09:02 2003 Subject: [llvm-commits] CVS: llvm/include/llvm/Target/TargetData.h Message-ID: <200304241908.OAA00360@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Target: TargetData.h updated: 1.13 -> 1.14 --- Log message: Add new targetdata ctor to create a targetdata appropriate to the module --- Diffs of the changes: Index: llvm/include/llvm/Target/TargetData.h diff -u llvm/include/llvm/Target/TargetData.h:1.13 llvm/include/llvm/Target/TargetData.h:1.14 --- llvm/include/llvm/Target/TargetData.h:1.13 Tue Jan 14 15:29:37 2003 +++ llvm/include/llvm/Target/TargetData.h Thu Apr 24 14:08:45 2003 @@ -38,7 +38,7 @@ static Annotation *TypeAnFactory(AnnotationID, const Annotable *, void *); public: - TargetData(const std::string &TargetName = "SparcV9", + TargetData(const std::string &TargetName = "Default Target", bool LittleEndian = false, unsigned char SubWordDataSize = 1, unsigned char IntRegSize = 8, @@ -47,6 +47,7 @@ unsigned char FloatAl = 4, unsigned char LongAl = 8, unsigned char IntAl = 4, unsigned char ShortAl = 2, unsigned char ByteAl = 1); + TargetData(const std::string &ToolName, const Module *M); ~TargetData(); // Not virtual, do not subclass this class /// Target endianness... From lattner at cs.uiuc.edu Thu Apr 24 14:10:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Apr 24 14:10:01 2003 Subject: [llvm-commits] CVS: llvm/lib/Target/TargetData.cpp Message-ID: <200304241909.OAA00371@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target: TargetData.cpp updated: 1.27 -> 1.28 --- Log message: add a new targetdata ctor to create a target data appropriate to the module --- Diffs of the changes: Index: llvm/lib/Target/TargetData.cpp diff -u llvm/lib/Target/TargetData.cpp:1.27 llvm/lib/Target/TargetData.cpp:1.28 --- llvm/lib/Target/TargetData.cpp:1.27 Tue Feb 25 14:27:09 2003 +++ llvm/lib/Target/TargetData.cpp Thu Apr 24 14:09:05 2003 @@ -11,6 +11,7 @@ //===----------------------------------------------------------------------===// #include "llvm/Target/TargetData.h" +#include "llvm/Module.h" #include "llvm/DerivedTypes.h" #include "llvm/Constants.h" @@ -101,6 +102,23 @@ IntAlignment = IntAl; ShortAlignment = ShortAl; ByteAlignment = ByteAl; +} + +TargetData::TargetData(const std::string &ToolName, const Module *M) + : AID(AnnotationManager::getID("TargetData::" + ToolName)) { + AnnotationManager::registerAnnotationFactory(AID, TypeAnFactory, this); + + LittleEndian = M->isLittleEndian(); + SubWordDataSize = 1; + IntegerRegSize = 8; + PointerSize = M->has32BitPointers() ? 32 : 64; + PointerAlignment = PointerSize; + DoubleAlignment = 8; + FloatAlignment = 4; + LongAlignment = 8; + IntAlignment = 4; + ShortAlignment = 2; + ByteAlignment = 1; } TargetData::~TargetData() { From lattner at cs.uiuc.edu Thu Apr 24 14:11:05 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Apr 24 14:11:05 2003 Subject: [llvm-commits] CVS: llvm/tools/analyze/analyze.cpp Message-ID: <200304241910.OAA00399@apoc.cs.uiuc.edu> Changes in directory llvm/tools/analyze: analyze.cpp updated: 1.50 -> 1.51 --- Log message: Make sure to create a target data that matches the Module's target properties. --- Diffs of the changes: Index: llvm/tools/analyze/analyze.cpp diff -u llvm/tools/analyze/analyze.cpp:1.50 llvm/tools/analyze/analyze.cpp:1.51 --- llvm/tools/analyze/analyze.cpp:1.50 Mon Feb 24 14:07:54 2003 +++ llvm/tools/analyze/analyze.cpp Thu Apr 24 14:10:05 2003 @@ -15,6 +15,7 @@ #include "llvm/Bytecode/Reader.h" #include "llvm/Assembly/Parser.h" #include "llvm/Analysis/Verifier.h" +#include "llvm/Target/TargetData.h" #include "llvm/Support/PassNameParser.h" #include "Support/Timer.h" #include @@ -125,6 +126,9 @@ // about to build... // PassManager Passes; + + // Add an appropriate TargetData instance for this module... + Passes.add(new TargetData("analyze", CurMod)); // Make sure the input LLVM is well formed. Passes.add(createVerifierPass()); From lattner at cs.uiuc.edu Thu Apr 24 14:11:11 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Apr 24 14:11:11 2003 Subject: [llvm-commits] CVS: llvm/tools/bugpoint/OptimizerDriver.cpp Message-ID: <200304241910.OAA00406@apoc.cs.uiuc.edu> Changes in directory llvm/tools/bugpoint: OptimizerDriver.cpp updated: 1.5 -> 1.6 --- Log message: Make sure to create a target data that matches the Module's target properties. --- Diffs of the changes: Index: llvm/tools/bugpoint/OptimizerDriver.cpp diff -u llvm/tools/bugpoint/OptimizerDriver.cpp:1.5 llvm/tools/bugpoint/OptimizerDriver.cpp:1.6 --- llvm/tools/bugpoint/OptimizerDriver.cpp:1.5 Thu Apr 24 13:36:36 2003 +++ llvm/tools/bugpoint/OptimizerDriver.cpp Thu Apr 24 14:10:06 2003 @@ -74,6 +74,9 @@ } PassManager PM; + // Make sure that the appropriate target data is always used... + PM.add(new TargetData("bugpoint", Program)); + for (unsigned i = 0, e = Passes.size(); i != e; ++i) { if (Passes[i]->getNormalCtor()) PM.add(Passes[i]->getNormalCtor()()); From lattner at cs.uiuc.edu Thu Apr 24 14:11:14 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Apr 24 14:11:14 2003 Subject: [llvm-commits] CVS: llvm/tools/gccas/gccas.cpp Message-ID: <200304241910.OAA00413@apoc.cs.uiuc.edu> Changes in directory llvm/tools/gccas: gccas.cpp updated: 1.61 -> 1.62 --- Log message: Make sure to create a target data that matches the Module's target properties. --- Diffs of the changes: Index: llvm/tools/gccas/gccas.cpp diff -u llvm/tools/gccas/gccas.cpp:1.61 llvm/tools/gccas/gccas.cpp:1.62 --- llvm/tools/gccas/gccas.cpp:1.61 Thu Apr 24 13:36:37 2003 +++ llvm/tools/gccas/gccas.cpp Thu Apr 24 14:10:07 2003 @@ -66,8 +66,8 @@ addPass(PM, createGlobalDCEPass()); // Kill unused uinit g-vars addPass(PM, createDeadTypeEliminationPass()); // Eliminate dead types addPass(PM, createConstantMergePass()); // Merge dup global constants - addPass(PM, createVerifierPass()); // Verify that input is correct addPass(PM, createCFGSimplificationPass()); // Merge & remove BBs + addPass(PM, createVerifierPass()); // Verify that input is correct addPass(PM, createDeadInstEliminationPass()); // Remove Dead code/vars addPass(PM, createRaiseAllocationsPass()); // call %malloc -> malloc inst addPass(PM, createIndVarSimplifyPass()); // Simplify indvars @@ -144,6 +144,9 @@ // a little bit. Do this now. // PassManager Passes; + + // Add an appropriate TargetData instance for this module... + Passes.add(new TargetData("gccas", M.get())); // Add all of the transformation passes to the pass manager to do the cleanup // and optimization of the GCC output. From lattner at cs.uiuc.edu Thu Apr 24 14:11:18 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Apr 24 14:11:18 2003 Subject: [llvm-commits] CVS: llvm/tools/opt/opt.cpp Message-ID: <200304241910.OAA00420@apoc.cs.uiuc.edu> Changes in directory llvm/tools/opt: opt.cpp updated: 1.80 -> 1.81 --- Log message: Make sure to create a target data that matches the Module's target properties. --- Diffs of the changes: Index: llvm/tools/opt/opt.cpp diff -u llvm/tools/opt/opt.cpp:1.80 llvm/tools/opt/opt.cpp:1.81 --- llvm/tools/opt/opt.cpp:1.80 Thu Apr 24 13:36:41 2003 +++ llvm/tools/opt/opt.cpp Thu Apr 24 14:10:09 2003 @@ -113,6 +113,9 @@ // PassManager Passes; + // Add an appropriate TargetData instance for this module... + Passes.add(new TargetData("opt", M.get())); + // Create a new optimization pass for each one specified on the command line for (unsigned i = 0; i < OptimizationList.size(); ++i) { const PassInfo *Opt = OptimizationList[i]; From lattner at cs.uiuc.edu Thu Apr 24 14:14:00 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Apr 24 14:14:00 2003 Subject: [llvm-commits] CVS: llvm/tools/gccld/gccld.cpp Message-ID: <200304241913.OAA00548@apoc.cs.uiuc.edu> Changes in directory llvm/tools/gccld: gccld.cpp updated: 1.28 -> 1.29 --- Log message: Make sure to create a target data that matches the Module's target properties. --- Diffs of the changes: Index: llvm/tools/gccld/gccld.cpp diff -u llvm/tools/gccld/gccld.cpp:1.28 llvm/tools/gccld/gccld.cpp:1.29 --- llvm/tools/gccld/gccld.cpp:1.28 Mon Apr 21 14:53:24 2003 +++ llvm/tools/gccld/gccld.cpp Thu Apr 24 14:13:02 2003 @@ -18,6 +18,7 @@ #include "llvm/PassManager.h" #include "llvm/Bytecode/Reader.h" #include "llvm/Bytecode/WriteBytecodePass.h" +#include "llvm/Target/TargetData.h" #include "llvm/Transforms/IPO.h" #include "llvm/Transforms/Scalar.h" #include "Support/CommandLine.h" @@ -325,6 +326,9 @@ // a little bit. Do this now. // PassManager Passes; + + // Add an appropriate TargetData instance for this module... + Passes.add(new TargetData("gccas", Composite.get())); // Linking modules together can lead to duplicated global constants, only keep // one copy of each constant... From lattner at cs.uiuc.edu Thu Apr 24 14:33:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Apr 24 14:33:01 2003 Subject: [llvm-commits] CVS: llvm/tools/bugpoint/Miscompilation.cpp Message-ID: <200304241932.OAA00900@apoc.cs.uiuc.edu> Changes in directory llvm/tools/bugpoint: Miscompilation.cpp updated: 1.3 -> 1.4 --- Log message: Allow bugpoint to try new an different methods for pruning down lists --- Diffs of the changes: Index: llvm/tools/bugpoint/Miscompilation.cpp diff -u llvm/tools/bugpoint/Miscompilation.cpp:1.3 llvm/tools/bugpoint/Miscompilation.cpp:1.4 --- llvm/tools/bugpoint/Miscompilation.cpp:1.3 Thu Apr 24 12:02:17 2003 +++ llvm/tools/bugpoint/Miscompilation.cpp Thu Apr 24 14:32:42 2003 @@ -72,6 +72,30 @@ break; } } + + // Okay, we trimmed as much off the top and the bottom of the list as we + // could. If there is more two elements in the list, try deleting interior + // elements and testing that. + // + if (TheList.size() > 2) { + bool Changed = true; + std::vector EmptyList; + while (Changed) { + Changed = false; + std::vector TrimmedList; + for (unsigned i = 1; i < TheList.size()-1; ++i) { // Check interior elts + std::vector TestList(TheList); + TestList.erase(TestList.begin()+i); + + if (doTest(EmptyList, TestList) == KeepSuffix) { + // We can trim down the list! + TheList.swap(TestList); + --i; // Don't skip an element of the list + Changed = true; + } + } + } + } } }; @@ -187,7 +211,7 @@ const std::vector &Kept) { if (TestFuncs(Kept, false)) return KeepSuffix; - if (TestFuncs(Prefix, false)) + if (!Prefix.empty() && TestFuncs(Prefix, false)) return KeepPrefix; return NoFailure; } From lattner at cs.uiuc.edu Thu Apr 24 15:08:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Apr 24 15:08:01 2003 Subject: [llvm-commits] CVS: llvm/lib/VMCore/PassManagerT.h Message-ID: <200304242007.PAA01393@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: PassManagerT.h updated: 1.37 -> 1.38 --- Log message: Fix a nasty bug where the ConstantMerge pass was invalidating the TargetData pass even though it was immutable. Immutable passes should never end up in CurrentAnalyses! --- Diffs of the changes: Index: llvm/lib/VMCore/PassManagerT.h diff -u llvm/lib/VMCore/PassManagerT.h:1.37 llvm/lib/VMCore/PassManagerT.h:1.38 --- llvm/lib/VMCore/PassManagerT.h:1.37 Wed Feb 26 13:10:57 2003 +++ llvm/lib/VMCore/PassManagerT.h Thu Apr 24 15:07:38 2003 @@ -332,12 +332,32 @@ } } + Pass *getImmutablePassOrNull(const PassInfo *ID) const { + for (unsigned i = 0, e = ImmutablePasses.size(); i != e; ++i) { + const PassInfo *IPID = ImmutablePasses[i]->getPassInfo(); + if (IPID == ID) + return ImmutablePasses[i]; + + // This pass is the current implementation of all of the interfaces it + // implements as well. + // + const std::vector &II = + IPID->getInterfacesImplemented(); + for (unsigned j = 0, e = II.size(); j != e; ++j) + if (II[j] == ID) return ImmutablePasses[i]; + } + return 0; + } + Pass *getAnalysisOrNullDown(const PassInfo *ID) const { std::map::const_iterator I = CurrentAnalyses.find(ID); if (I != CurrentAnalyses.end()) return I->second; // Found it. + if (Pass *P = getImmutablePassOrNull(ID)) + return P; + if (Batcher) return ((AnalysisResolver*)Batcher)->getAnalysisOrNullDown(ID); return 0; @@ -350,6 +370,8 @@ if (Parent) // Try scanning... return Parent->getAnalysisOrNullUp(ID); + else if (!ImmutablePasses.empty()) + return getImmutablePassOrNull(ID); return 0; } @@ -386,7 +408,9 @@ if (Parent) { Parent->markPassUsed(P, this); } else { - assert(0 && "Pass available but not found! " + assert(getAnalysisOrNullUp(P) && + dynamic_cast(getAnalysisOrNullUp(P)) && + "Pass available but not found! " "Perhaps this is a module pass requiring a function pass?"); } } @@ -556,18 +580,6 @@ // Initialize the immutable pass... IP->initializePass(); - - // Add this pass to the currently available set... - if (const PassInfo *PI = IP->getPassInfo()) { - CurrentAnalyses[PI] = IP; - - // This pass is the current implementation of all of the interfaces it - // implements as well. - // - const std::vector &II = PI->getInterfacesImplemented(); - for (unsigned i = 0, e = II.size(); i != e; ++i) - CurrentAnalyses[II[i]] = IP; - } } }; From lattner at cs.uiuc.edu Thu Apr 24 15:17:03 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Apr 24 15:17:03 2003 Subject: [llvm-commits] CVS: llvm/tools/bugpoint/ListReducer.h Miscompilation.cpp Message-ID: <200304242016.PAA03039@apoc.cs.uiuc.edu> Changes in directory llvm/tools/bugpoint: ListReducer.h added (r1.1) Miscompilation.cpp updated: 1.4 -> 1.5 --- Log message: Move the ListReducer Class into it's own header file instead of living in Miscompilation.cpp --- Diffs of the changes: Index: llvm/tools/bugpoint/ListReducer.h diff -c /dev/null llvm/tools/bugpoint/ListReducer.h:1.1 *** /dev/null Thu Apr 24 15:16:44 2003 --- llvm/tools/bugpoint/ListReducer.h Thu Apr 24 15:16:29 2003 *************** *** 0 **** --- 1,86 ---- + //===- ListReducer.h - Trim down list while retaining property --*- C++ -*-===// + // + // This class is to be used as a base class for operations that want to zero in + // on a subset of the input which still causes the bug we are tracking. + // + //===----------------------------------------------------------------------===// + + #ifndef BUGPOINT_LIST_REDUCER_H + #define BUGPOINT_LIST_REDUCER_H + + #include + + template + struct ListReducer { + enum TestResult { + NoFailure, // No failure of the predicate was detected + KeepSuffix, // The suffix alone satisfies the predicate + KeepPrefix, // The prefix alone satisfies the predicate + }; + + // doTest - This virtual function should be overriden by subclasses to + // implement the test desired. The testcase is only required to test to see + // if the Kept list still satisfies the property, but if it is going to check + // the prefix anyway, it can. + // + virtual TestResult doTest(const std::vector &Prefix, + const std::vector &Kept) = 0; + + // reduceList - This function attempts to reduce the length of the specified + // list while still maintaining the "test" property. This is the core of the + // "work" that bugpoint does. + // + void reduceList(std::vector &TheList) { + unsigned MidTop = TheList.size(); + while (MidTop > 1) { + unsigned Mid = MidTop / 2; + std::vector Prefix(TheList.begin()+Mid, TheList.end()); + std::vector Kept (TheList.begin(), TheList.begin()+Mid); + + switch (doTest(Prefix, Kept)) { + case KeepSuffix: + // The property still holds. We can just drop the prefix elements, and + // shorten the list to the "kept" elements. + TheList.swap(Kept); + MidTop = TheList.size(); + break; + case KeepPrefix: + // The predicate still holds, shorten the list to the prefix elements. + TheList.swap(Prefix); + MidTop = TheList.size(); + break; + case NoFailure: + // Otherwise the property doesn't hold. Some of the elements we removed + // must be neccesary to maintain the property. + MidTop = Mid; + break; + } + } + + // Okay, we trimmed as much off the top and the bottom of the list as we + // could. If there is more two elements in the list, try deleting interior + // elements and testing that. + // + if (TheList.size() > 2) { + bool Changed = true; + std::vector EmptyList; + while (Changed) { + Changed = false; + std::vector TrimmedList; + for (unsigned i = 1; i < TheList.size()-1; ++i) { // Check interior elts + std::vector TestList(TheList); + TestList.erase(TestList.begin()+i); + + if (doTest(EmptyList, TestList) == KeepSuffix) { + // We can trim down the list! + TheList.swap(TestList); + --i; // Don't skip an element of the list + Changed = true; + } + } + } + } + } + }; + + #endif Index: llvm/tools/bugpoint/Miscompilation.cpp diff -u llvm/tools/bugpoint/Miscompilation.cpp:1.4 llvm/tools/bugpoint/Miscompilation.cpp:1.5 --- llvm/tools/bugpoint/Miscompilation.cpp:1.4 Thu Apr 24 14:32:42 2003 +++ llvm/tools/bugpoint/Miscompilation.cpp Thu Apr 24 15:16:29 2003 @@ -6,6 +6,7 @@ #include "BugDriver.h" #include "SystemUtils.h" +#include "ListReducer.h" #include "llvm/Pass.h" #include "llvm/Module.h" #include "llvm/Transforms/Utils/Cloning.h" @@ -25,79 +26,6 @@ Output("output", cl::desc("Specify a reference program output " "(for miscompilation detection)")); } - -template -struct ListReducer { - enum TestResult { - NoFailure, // No failure of the predicate was detected - KeepSuffix, // The suffix alone satisfies the predicate - KeepPrefix, // The prefix alone satisfies the predicate - }; - - // doTest - This virtual function should be overriden by subclasses to - // implement the test desired. The testcase is only required to test to see - // if the Kept list still satisfies the property, but if it is going to check - // the prefix anyway, it can. - // - virtual TestResult doTest(const std::vector &Prefix, - const std::vector &Kept) = 0; - - // reduceList - This function attempts to reduce the length of the specified - // list while still maintaining the "test" property. This is the core of the - // "work" that bugpoint does. - // - void reduceList(std::vector &TheList) { - unsigned MidTop = TheList.size(); - while (MidTop > 1) { - unsigned Mid = MidTop / 2; - std::vector Prefix(TheList.begin()+Mid, TheList.end()); - std::vector Kept (TheList.begin(), TheList.begin()+Mid); - - switch (doTest(Prefix, Kept)) { - case KeepSuffix: - // The property still holds. We can just drop the prefix elements, and - // shorten the list to the "kept" elements. - TheList.swap(Kept); - MidTop = TheList.size(); - break; - case KeepPrefix: - // The predicate still holds, shorten the list to the prefix elements. - TheList.swap(Prefix); - MidTop = TheList.size(); - break; - case NoFailure: - // Otherwise the property doesn't hold. Some of the elements we removed - // must be neccesary to maintain the property. - MidTop = Mid; - break; - } - } - - // Okay, we trimmed as much off the top and the bottom of the list as we - // could. If there is more two elements in the list, try deleting interior - // elements and testing that. - // - if (TheList.size() > 2) { - bool Changed = true; - std::vector EmptyList; - while (Changed) { - Changed = false; - std::vector TrimmedList; - for (unsigned i = 1; i < TheList.size()-1; ++i) { // Check interior elts - std::vector TestList(TheList); - TestList.erase(TestList.begin()+i); - - if (doTest(EmptyList, TestList) == KeepSuffix) { - // We can trim down the list! - TheList.swap(TestList); - --i; // Don't skip an element of the list - Changed = true; - } - } - } - } - } -}; class ReduceMiscompilingPasses : public ListReducer { BugDriver &BD; From lattner at cs.uiuc.edu Thu Apr 24 17:24:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Apr 24 17:24:01 2003 Subject: [llvm-commits] CVS: llvm/tools/bugpoint/BugDriver.cpp Message-ID: <200304242223.RAA05966@apoc.cs.uiuc.edu> Changes in directory llvm/tools/bugpoint: BugDriver.cpp updated: 1.3 -> 1.4 --- Log message: Move function from Miscompilation.cpp --- Diffs of the changes: Index: llvm/tools/bugpoint/BugDriver.cpp diff -u llvm/tools/bugpoint/BugDriver.cpp:1.3 llvm/tools/bugpoint/BugDriver.cpp:1.4 --- llvm/tools/bugpoint/BugDriver.cpp:1.3 Thu Apr 24 12:02:17 2003 +++ llvm/tools/bugpoint/BugDriver.cpp Thu Apr 24 17:23:34 2003 @@ -27,6 +27,19 @@ return Result; } +// DeleteFunctionBody - "Remove" the function by deleting all of it's basic +// blocks, making it external. +// +void DeleteFunctionBody(Function *F) { + // First, break circular use/def chain references... + for (Function::iterator I = F->begin(), E = F->end(); I != E; ++I) + I->dropAllReferences(); + + // Next, delete all of the basic blocks. + F->getBasicBlockList().clear(); + + assert(F->isExternal() && "This didn't make the function external!"); +} /// ParseInputFile - Given a bytecode or assembly input filename, parse and /// return it, or return null if not possible. From lattner at cs.uiuc.edu Thu Apr 24 17:25:00 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Apr 24 17:25:00 2003 Subject: [llvm-commits] CVS: llvm/tools/bugpoint/ListReducer.h Message-ID: <200304242224.RAA05999@apoc.cs.uiuc.edu> Changes in directory llvm/tools/bugpoint: ListReducer.h updated: 1.1 -> 1.2 --- Log message: Allow reducer interfaces to mutate the lists passed in --- Diffs of the changes: Index: llvm/tools/bugpoint/ListReducer.h diff -u llvm/tools/bugpoint/ListReducer.h:1.1 llvm/tools/bugpoint/ListReducer.h:1.2 --- llvm/tools/bugpoint/ListReducer.h:1.1 Thu Apr 24 15:16:29 2003 +++ llvm/tools/bugpoint/ListReducer.h Thu Apr 24 17:23:56 2003 @@ -23,8 +23,8 @@ // if the Kept list still satisfies the property, but if it is going to check // the prefix anyway, it can. // - virtual TestResult doTest(const std::vector &Prefix, - const std::vector &Kept) = 0; + virtual TestResult doTest(std::vector &Prefix, + std::vector &Kept) = 0; // reduceList - This function attempts to reduce the length of the specified // list while still maintaining the "test" property. This is the core of the From lattner at cs.uiuc.edu Thu Apr 24 17:26:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Apr 24 17:26:01 2003 Subject: [llvm-commits] CVS: llvm/tools/bugpoint/BugDriver.h CrashDebugger.cpp Message-ID: <200304242225.RAA06109@apoc.cs.uiuc.edu> Changes in directory llvm/tools/bugpoint: BugDriver.h updated: 1.5 -> 1.6 CrashDebugger.cpp updated: 1.5 -> 1.6 --- Log message: Use the list reducer to improve convergence speed and to support crashes that only occur when multiple passes interact or when multiple functions exist in a module --- Diffs of the changes: Index: llvm/tools/bugpoint/BugDriver.h diff -u llvm/tools/bugpoint/BugDriver.h:1.5 llvm/tools/bugpoint/BugDriver.h:1.6 --- llvm/tools/bugpoint/BugDriver.h:1.5 Thu Apr 24 12:02:17 2003 +++ llvm/tools/bugpoint/BugDriver.h Thu Apr 24 17:24:58 2003 @@ -17,8 +17,10 @@ class AbstractInterpreter; class Instruction; +class DebugCrashes; class ReduceMiscompilingPasses; class ReduceMiscompilingFunctions; +class ReduceCrashingFunctions; class BugDriver { const std::string ToolName; // Name of bugpoint @@ -26,8 +28,11 @@ std::vector PassesToRun; AbstractInterpreter *Interpreter; // How to run the program + // FIXME: sort out public/private distinctions... + friend class DebugCrashes; friend class ReduceMiscompilingPasses; friend class ReduceMiscompilingFunctions; + friend class ReduceCrashingFunctions; public: BugDriver(const char *toolname) : ToolName(toolname), Program(0), Interpreter(0) {} @@ -52,12 +57,6 @@ /// bool debugCrash(); - /// debugPassCrash - This method is called when the specified pass crashes on - /// Program as input. It tries to reduce the testcase to something that still - /// crashes, but it smaller. - /// - bool debugPassCrash(const PassInfo *PI); - /// debugMiscompilation - This method is used when the passes selected are not /// crashing, but the generated output is semantically different from the /// input. @@ -162,5 +161,10 @@ /// command line options that must be passed to add the passes. /// std::string getPassesString(const std::vector &Passes); + +// DeleteFunctionBody - "Remove" the function by deleting all of it's basic +// blocks, making it external. +// +void DeleteFunctionBody(Function *F); #endif Index: llvm/tools/bugpoint/CrashDebugger.cpp diff -u llvm/tools/bugpoint/CrashDebugger.cpp:1.5 llvm/tools/bugpoint/CrashDebugger.cpp:1.6 --- llvm/tools/bugpoint/CrashDebugger.cpp:1.5 Thu Apr 24 12:02:17 2003 +++ llvm/tools/bugpoint/CrashDebugger.cpp Thu Apr 24 17:24:58 2003 @@ -6,12 +6,14 @@ #include "BugDriver.h" #include "SystemUtils.h" +#include "ListReducer.h" #include "llvm/Module.h" +#include "llvm/Transforms/Utils/Cloning.h" #include "llvm/Bytecode/Writer.h" #include "llvm/Pass.h" #include +#include -#if 0 class DebugCrashes : public ListReducer { BugDriver &BD; public: @@ -21,140 +23,148 @@ // the "Kept" passes fail when run on the output of the "removed" passes. If // we return true, we update the current module of bugpoint. // - virtual bool doTest(const std::vector &Removed, - const std::vector &Kept) { - return BD.runPasses(Kept); + virtual TestResult doTest(std::vector &Removed, + std::vector &Kept); +}; + +DebugCrashes::TestResult +DebugCrashes::doTest(std::vector &Prefix, + std::vector &Suffix) { + std::string PrefixOutput; + if (!Prefix.empty()) { + std::cout << "Checking to see if these passes crash: " + << getPassesString(Prefix) << ": "; + if (BD.runPasses(Prefix, PrefixOutput)) + return KeepPrefix; + } + + std::cout << "Checking to see if these passes crash: " + << getPassesString(Suffix) << ": "; + Module *OrigProgram = BD.Program; + BD.Program = BD.ParseInputFile(PrefixOutput); + if (BD.Program == 0) { + std::cerr << BD.getToolName() << ": Error reading bytecode file '" + << PrefixOutput << "'!\n"; + exit(1); + } + removeFile(PrefixOutput); + + if (BD.runPasses(Suffix)) { + delete OrigProgram; // The suffix crashes alone... + return KeepSuffix; + } + + // Nothing failed, restore state... + delete BD.Program; + BD.Program = OrigProgram; + return NoFailure; +} + +class ReduceCrashingFunctions : public ListReducer { + BugDriver &BD; +public: + ReduceCrashingFunctions(BugDriver &bd) : BD(bd) {} + + virtual TestResult doTest(std::vector &Prefix, + std::vector &Kept) { + if (TestFuncs(Kept)) + return KeepSuffix; + if (!Prefix.empty() && TestFuncs(Prefix)) + return KeepPrefix; + return NoFailure; } + + bool TestFuncs(std::vector &Prefix); }; -#endif + +bool ReduceCrashingFunctions::TestFuncs(std::vector &Funcs) { + // Clone the program to try hacking it appart... + Module *M = CloneModule(BD.Program); + + // Convert list to set for fast lookup... + std::set Functions; + for (unsigned i = 0, e = Funcs.size(); i != e; ++i) { + Function *CMF = M->getFunction(Funcs[i]->getName(), + Funcs[i]->getFunctionType()); + assert(CMF && "Function not in module?!"); + Functions.insert(CMF); + } + + std::cout << "Checking for crash with only these functions:"; + for (unsigned i = 0, e = Funcs.size(); i != e; ++i) + std::cout << " " << Funcs[i]->getName(); + std::cout << ": "; + + // Loop over and delete any functions which we aren't supposed to be playing + // with... + for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I) + if (I->isExternal() && !Functions.count(I)) + DeleteFunctionBody(I); + + // Try running the hacked up program... + std::swap(BD.Program, M); + if (BD.runPasses(BD.PassesToRun)) { + delete M; // It crashed, keep the trimmed version... + + // Make sure to use function pointers that point into the now-current + // module. + Funcs.assign(Functions.begin(), Functions.end()); + return true; + } + delete BD.Program; // It didn't crash, revert... + BD.Program = M; + return false; +} + /// debugCrash - This method is called when some pass crashes on input. It /// attempts to prune down the testcase to something reasonable, and figure /// out exactly which pass is crashing. /// bool BugDriver::debugCrash() { + bool AnyReduction = false; std::cout << "\n*** Debugging optimizer crash!\n"; -#if 0 // Reduce the list of passes which causes the optimizer to crash... + unsigned OldSize = PassesToRun.size(); DebugCrashes(*this).reduceList(PassesToRun); -#endif - - unsigned LastToPass = 0, LastToCrash = PassesToRun.size(); - while (LastToPass != LastToCrash) { - unsigned Mid = (LastToCrash+LastToPass+1) / 2; - std::vector P(PassesToRun.begin(), - PassesToRun.begin()+Mid); - std::cout << "Checking to see if the first " << Mid << " passes crash: "; - - if (runPasses(P)) - LastToCrash = Mid-1; - else - LastToPass = Mid; - } - // Make sure something crashed. :) - if (LastToCrash >= PassesToRun.size()) { + if (PassesToRun.size() == OldSize) { // Make sure something crashed. :) std::cerr << "ERROR: No passes crashed!\n"; return true; } - // Calculate which pass it is that crashes... - const PassInfo *CrashingPass = PassesToRun[LastToCrash]; - - std::cout << "\n*** Found crashing pass '-" << CrashingPass->getPassArgument() - << "': " << CrashingPass->getPassName() << "\n"; + std::cout << "\n*** Found crashing pass" + << (PassesToRun.size() == 1 ? ": " : "es: ") + << getPassesString(PassesToRun) << "\n"; - // Compile the program with just the passes that don't crash. - if (LastToPass != 0) { // Don't bother doing this if the first pass crashes... - std::vector P(PassesToRun.begin(), - PassesToRun.begin()+LastToPass); - std::string Filename; - std::cout << "Running passes that don't crash to get input for pass: "; - if (runPasses(P, Filename)) { - std::cerr << "ERROR: Running the first " << LastToPass - << " passes crashed this time!\n"; - return true; - } - - // Assuming everything was successful, we now have a valid bytecode file in - // OutputName. Use it for "Program" Instead. - delete Program; - Program = ParseInputFile(Filename); - - // Delete the file now. - removeFile(Filename); - } - - PassesToRun.clear(); - PassesToRun.push_back(CrashingPass); - - return debugPassCrash(CrashingPass); -} - -/// CountFunctions - return the number of non-external functions defined in the -/// module. -static unsigned CountFunctions(Module *M) { - unsigned N = 0; - for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I) - if (!I->isExternal()) - ++N; - return N; -} - -/// debugPassCrash - This method is called when the specified pass crashes on -/// Program as input. It tries to reduce the testcase to something that still -/// crashes, but it smaller. -/// -bool BugDriver::debugPassCrash(const PassInfo *Pass) { EmitProgressBytecode("passinput"); - bool Reduced = false, AnyReduction = false; - - if (CountFunctions(Program) > 1) { - // Attempt to reduce the input program down to a single function that still - // crashes. Do this by removing everything except for that one function... - // - std::cout << "\n*** Attempting to reduce the testcase to one function\n"; - - for (Module::iterator I = Program->begin(), E = Program->end(); I != E; ++I) - if (!I->isExternal()) { - // Extract one function from the module... - Module *M = extractFunctionFromModule(I); - - // Make the function the current program... - std::swap(Program, M); - - // Find out if the pass still crashes on this pass... - std::cout << "Checking function '" << I->getName() << "': "; - if (runPass(Pass)) { - // Yup, it does, we delete the old module, and continue trying to - // reduce the testcase... - delete M; - - Reduced = AnyReduction = true; - break; - } - - // This pass didn't crash on this function, try the next one. - delete Program; - Program = M; - } + + // Now try to reduce the number of functions in the module to something small. + std::vector Functions; + for (Module::iterator I = Program->begin(), E = Program->end(); I != E; ++I) + if (!I->isExternal()) + Functions.push_back(I); - if (CountFunctions(Program) > 1) { - std::cout << "\n*** Couldn't reduce testcase to one function.\n" - << " Attempting to remove individual functions.\n"; - std::cout << "XXX Individual function removal unimplemented!\n"; + if (Functions.size() > 1) { + std::cout << "\n*** Attempting to reduce the number of functions " + "in the testcase\n"; + + OldSize = Functions.size(); + ReduceCrashingFunctions(*this).reduceList(Functions); + + if (Functions.size() < OldSize) { + EmitProgressBytecode("reduced-function"); + AnyReduction = true; } } - if (Reduced) { - EmitProgressBytecode("reduced-function"); - Reduced = false; - } - // FIXME: This should attempt to delete entire basic blocks at a time to speed // up convergence... + // FIXME: This should use the list reducer to converge faster by deleting + // larger chunks of instructions at a time! + bool Reduced = false; unsigned Simplification = 4; do { --Simplification; @@ -186,7 +196,7 @@ // Find out if the pass still crashes on this pass... std::cout << "Checking instruction '" << I->getName() << "': "; - if (runPass(Pass)) { + if (runPasses(PassesToRun)) { // Yup, it does, we delete the old module, and continue trying to // reduce the testcase... delete M; @@ -209,7 +219,7 @@ std::swap(Program, M); // Find out if the pass still crashes on the cleaned up program... - if (runPass(Pass)) { + if (runPasses(PassesToRun)) { // Yup, it does, keep the reduced version... delete M; Reduced = AnyReduction = true; From lattner at cs.uiuc.edu Thu Apr 24 17:26:05 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Apr 24 17:26:05 2003 Subject: [llvm-commits] CVS: llvm/tools/bugpoint/Miscompilation.cpp Message-ID: <200304242225.RAA06094@apoc.cs.uiuc.edu> Changes in directory llvm/tools/bugpoint: Miscompilation.cpp updated: 1.5 -> 1.6 --- Log message: Adjust to match new ListReducer interface Move function to generic code --- Diffs of the changes: Index: llvm/tools/bugpoint/Miscompilation.cpp diff -u llvm/tools/bugpoint/Miscompilation.cpp:1.5 llvm/tools/bugpoint/Miscompilation.cpp:1.6 --- llvm/tools/bugpoint/Miscompilation.cpp:1.5 Thu Apr 24 15:16:29 2003 +++ llvm/tools/bugpoint/Miscompilation.cpp Thu Apr 24 17:24:22 2003 @@ -32,13 +32,13 @@ public: ReduceMiscompilingPasses(BugDriver &bd) : BD(bd) {} - virtual TestResult doTest(const std::vector &Prefix, - const std::vector &Kept); + virtual TestResult doTest(std::vector &Prefix, + std::vector &Kept); }; ReduceMiscompilingPasses::TestResult -ReduceMiscompilingPasses::doTest(const std::vector &Prefix, - const std::vector &Kept) { +ReduceMiscompilingPasses::doTest(std::vector &Prefix, + std::vector &Kept) { // First, run the program with just the Kept passes. If it is still broken // with JUST the kept passes, discard the prefix passes. std::cout << "Checking to see if '" << getPassesString(Kept) @@ -135,8 +135,8 @@ public: ReduceMiscompilingFunctions(BugDriver &bd) : BD(bd) {} - virtual TestResult doTest(const std::vector &Prefix, - const std::vector &Kept) { + virtual TestResult doTest(std::vector &Prefix, + std::vector &Kept) { if (TestFuncs(Kept, false)) return KeepSuffix; if (!Prefix.empty() && TestFuncs(Prefix, false)) @@ -146,21 +146,6 @@ bool TestFuncs(const std::vector &Prefix, bool EmitBytecode); }; - -// DeleteFunctionBody - "Remove" the function by deleting all of it's basic -// blocks, making it external. -// -static void DeleteFunctionBody(Function *F) { - // First, break circular use/def chain references... - for (Function::iterator I = F->begin(), E = F->end(); I != E; ++I) - I->dropAllReferences(); - - // Next, delete all of the basic blocks. - F->getBasicBlockList().clear(); - - assert(F->isExternal() && "This didn't make the function external!"); -} - bool ReduceMiscompilingFunctions::TestFuncs(const std::vector &Funcs, bool EmitBytecode) { From lattner at cs.uiuc.edu Thu Apr 24 17:54:00 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Apr 24 17:54:00 2003 Subject: [llvm-commits] CVS: llvm/tools/bugpoint/BugDriver.h Message-ID: <200304242253.RAA07736@apoc.cs.uiuc.edu> Changes in directory llvm/tools/bugpoint: BugDriver.h updated: 1.6 -> 1.7 --- Log message: Remove dead functions --- Diffs of the changes: Index: llvm/tools/bugpoint/BugDriver.h diff -u llvm/tools/bugpoint/BugDriver.h:1.6 llvm/tools/bugpoint/BugDriver.h:1.7 --- llvm/tools/bugpoint/BugDriver.h:1.6 Thu Apr 24 17:24:58 2003 +++ llvm/tools/bugpoint/BugDriver.h Thu Apr 24 17:53:24 2003 @@ -110,19 +110,6 @@ return runPasses(PassesToRun, Filename, DeleteOutput); } - /// runPass - Run only the specified pass on the program. - /// - bool runPass(const PassInfo *P, bool DeleteOutput = true) const { - return runPasses(std::vector(1, P), DeleteOutput); - } - - /// extractFunctionFromModule - This method is used to extract the specified - /// (non-external) function from the current program, slim down the module, - /// and then return it. This does not modify Program at all, it modifies a - /// copy, which it returns. - /// - Module *extractFunctionFromModule(Function *F) const; - /// deleteInstructionFromProgram - This method clones the current Program and /// deletes the specified instruction from the cloned module. It then runs a /// series of cleanup passes (ADCE and SimplifyCFG) to eliminate any code From lattner at cs.uiuc.edu Thu Apr 24 17:54:05 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Apr 24 17:54:05 2003 Subject: [llvm-commits] CVS: llvm/tools/bugpoint/BugDriver.cpp Message-ID: <200304242253.RAA07780@apoc.cs.uiuc.edu> Changes in directory llvm/tools/bugpoint: BugDriver.cpp updated: 1.4 -> 1.5 --- Log message: Make sure that deleted functions have external linkage --- Diffs of the changes: Index: llvm/tools/bugpoint/BugDriver.cpp diff -u llvm/tools/bugpoint/BugDriver.cpp:1.4 llvm/tools/bugpoint/BugDriver.cpp:1.5 --- llvm/tools/bugpoint/BugDriver.cpp:1.4 Thu Apr 24 17:23:34 2003 +++ llvm/tools/bugpoint/BugDriver.cpp Thu Apr 24 17:53:01 2003 @@ -37,7 +37,7 @@ // Next, delete all of the basic blocks. F->getBasicBlockList().clear(); - + F->setLinkage(GlobalValue::ExternalLinkage); assert(F->isExternal() && "This didn't make the function external!"); } From lattner at cs.uiuc.edu Thu Apr 24 17:55:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Apr 24 17:55:01 2003 Subject: [llvm-commits] CVS: llvm/tools/bugpoint/CrashDebugger.cpp Message-ID: <200304242254.RAA07970@apoc.cs.uiuc.edu> Changes in directory llvm/tools/bugpoint: CrashDebugger.cpp updated: 1.6 -> 1.7 --- Log message: The big fix is this change: - if (I->isExternal() && !Functions.count(I)) + if (!I->isExternal() && !Functions.count(I)) We were not actually deleting any functions from the module! --- Diffs of the changes: Index: llvm/tools/bugpoint/CrashDebugger.cpp diff -u llvm/tools/bugpoint/CrashDebugger.cpp:1.6 llvm/tools/bugpoint/CrashDebugger.cpp:1.7 --- llvm/tools/bugpoint/CrashDebugger.cpp:1.6 Thu Apr 24 17:24:58 2003 +++ llvm/tools/bugpoint/CrashDebugger.cpp Thu Apr 24 17:54:06 2003 @@ -87,7 +87,7 @@ Function *CMF = M->getFunction(Funcs[i]->getName(), Funcs[i]->getFunctionType()); assert(CMF && "Function not in module?!"); - Functions.insert(CMF); + Functions.insert(CMF); } std::cout << "Checking for crash with only these functions:"; @@ -98,7 +98,7 @@ // Loop over and delete any functions which we aren't supposed to be playing // with... for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I) - if (I->isExternal() && !Functions.count(I)) + if (!I->isExternal() && !Functions.count(I)) DeleteFunctionBody(I); // Try running the hacked up program... @@ -129,11 +129,6 @@ unsigned OldSize = PassesToRun.size(); DebugCrashes(*this).reduceList(PassesToRun); - if (PassesToRun.size() == OldSize) { // Make sure something crashed. :) - std::cerr << "ERROR: No passes crashed!\n"; - return true; - } - std::cout << "\n*** Found crashing pass" << (PassesToRun.size() == 1 ? ": " : "es: ") << getPassesString(PassesToRun) << "\n"; @@ -164,7 +159,6 @@ // FIXME: This should use the list reducer to converge faster by deleting // larger chunks of instructions at a time! - bool Reduced = false; unsigned Simplification = 4; do { --Simplification; @@ -200,7 +194,7 @@ // Yup, it does, we delete the old module, and continue trying to // reduce the testcase... delete M; - Reduced = AnyReduction = true; + AnyReduction = true; goto TryAgain; // I wish I had a multi-level break here! } @@ -222,17 +216,15 @@ if (runPasses(PassesToRun)) { // Yup, it does, keep the reduced version... delete M; - Reduced = AnyReduction = true; + AnyReduction = true; } else { delete Program; // Otherwise, restore the original module... Program = M; } } - if (Reduced) { + if (AnyReduction) EmitProgressBytecode("reduced-simplified"); - Reduced = false; - } return false; } From lattner at cs.uiuc.edu Thu Apr 24 17:55:05 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Apr 24 17:55:05 2003 Subject: [llvm-commits] CVS: llvm/tools/bugpoint/ExtractFunction.cpp Message-ID: <200304242254.RAA08004@apoc.cs.uiuc.edu> Changes in directory llvm/tools/bugpoint: ExtractFunction.cpp updated: 1.4 -> 1.5 --- Log message: Remove dead functions --- Diffs of the changes: Index: llvm/tools/bugpoint/ExtractFunction.cpp diff -u llvm/tools/bugpoint/ExtractFunction.cpp:1.4 llvm/tools/bugpoint/ExtractFunction.cpp:1.5 --- llvm/tools/bugpoint/ExtractFunction.cpp:1.4 Fri Mar 7 12:17:13 2003 +++ llvm/tools/bugpoint/ExtractFunction.cpp Thu Apr 24 17:53:11 2003 @@ -15,31 +15,6 @@ #include "llvm/Type.h" #include "llvm/Constant.h" -/// extractFunctionFromModule - This method is used to extract the specified -/// (non-external) function from the current program, slim down the module, and -/// then return it. This does not modify Program at all, it modifies a copy, -/// which it returns. -Module *BugDriver::extractFunctionFromModule(Function *F) const { - Module *Result = CloneModule(Program); - - // Translate from the old module to the new copied module... - Module::iterator RFI = Result->begin(); // Get iterator to corresponding fn - std::advance(RFI, std::distance(Program->begin(), Module::iterator(F))); - - // In addition to just parsing the input from GCC, we also want to spiff it up - // a little bit. Do this now. - // - PassManager Passes; - Passes.add(createFunctionExtractionPass(RFI)); // Extract the function - Passes.add(createGlobalDCEPass()); // Delete unreachable globals - Passes.add(createFunctionResolvingPass()); // Delete prototypes - Passes.add(createDeadTypeEliminationPass()); // Remove dead types... - Passes.add(createVerifierPass()); - Passes.run(*Result); - return Result; -} - - /// deleteInstructionFromProgram - This method clones the current Program and /// deletes the specified instruction from the cloned module. It then runs a /// series of cleanup passes (ADCE and SimplifyCFG) to eliminate any code which @@ -69,9 +44,7 @@ // Remove the instruction from the program. I->getParent()->getInstList().erase(I); - // In addition to just parsing the input from GCC, we also want to spiff it up - // a little bit. Do this now. - // + // Spiff up the output a little bit. PassManager Passes; if (Simplification > 2) Passes.add(createAggressiveDCEPass()); // Remove dead code... From lattner at cs.uiuc.edu Thu Apr 24 18:52:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Apr 24 18:52:01 2003 Subject: [llvm-commits] CVS: llvm/tools/bugpoint/BugDriver.h CrashDebugger.cpp Message-ID: <200304242351.SAA09498@apoc.cs.uiuc.edu> Changes in directory llvm/tools/bugpoint: BugDriver.h updated: 1.7 -> 1.8 CrashDebugger.cpp updated: 1.7 -> 1.8 --- Log message: Speed up convergence significantly and also reduce the size of testcases by making large portions of a function's CFG dead at a time. --- Diffs of the changes: Index: llvm/tools/bugpoint/BugDriver.h diff -u llvm/tools/bugpoint/BugDriver.h:1.7 llvm/tools/bugpoint/BugDriver.h:1.8 --- llvm/tools/bugpoint/BugDriver.h:1.7 Thu Apr 24 17:53:24 2003 +++ llvm/tools/bugpoint/BugDriver.h Thu Apr 24 18:51:38 2003 @@ -21,6 +21,7 @@ class ReduceMiscompilingPasses; class ReduceMiscompilingFunctions; class ReduceCrashingFunctions; +class ReduceCrashingBlocks; class BugDriver { const std::string ToolName; // Name of bugpoint @@ -33,6 +34,7 @@ friend class ReduceMiscompilingPasses; friend class ReduceMiscompilingFunctions; friend class ReduceCrashingFunctions; + friend class ReduceCrashingBlocks; public: BugDriver(const char *toolname) : ToolName(toolname), Program(0), Interpreter(0) {} Index: llvm/tools/bugpoint/CrashDebugger.cpp diff -u llvm/tools/bugpoint/CrashDebugger.cpp:1.7 llvm/tools/bugpoint/CrashDebugger.cpp:1.8 --- llvm/tools/bugpoint/CrashDebugger.cpp:1.7 Thu Apr 24 17:54:06 2003 +++ llvm/tools/bugpoint/CrashDebugger.cpp Thu Apr 24 18:51:38 2003 @@ -8,9 +8,17 @@ #include "SystemUtils.h" #include "ListReducer.h" #include "llvm/Module.h" +#include "llvm/PassManager.h" +#include "llvm/Pass.h" +#include "llvm/Constant.h" +#include "llvm/iTerminators.h" +#include "llvm/Type.h" +#include "llvm/SymbolTable.h" +#include "llvm/Support/CFG.h" +#include "llvm/Analysis/Verifier.h" +#include "llvm/Transforms/Scalar.h" #include "llvm/Transforms/Utils/Cloning.h" #include "llvm/Bytecode/Writer.h" -#include "llvm/Pass.h" #include #include @@ -117,6 +125,108 @@ } +/// ReduceCrashingBlocks reducer - This works by setting the terminators of all +/// terminators except the specified basic blocks to a 'ret' instruction, then +/// running the simplify-cfg pass. This has the effect of chopping up the CFG +/// really fast which can reduce large functions quickly. +/// +class ReduceCrashingBlocks : public ListReducer { + BugDriver &BD; +public: + ReduceCrashingBlocks(BugDriver &bd) : BD(bd) {} + + virtual TestResult doTest(std::vector &Prefix, + std::vector &Kept) { + if (TestBlocks(Kept)) + return KeepSuffix; + if (!Prefix.empty() && TestBlocks(Prefix)) + return KeepPrefix; + return NoFailure; + } + + bool TestBlocks(std::vector &Prefix); +}; + +bool ReduceCrashingBlocks::TestBlocks(std::vector &BBs) { + // Clone the program to try hacking it appart... + Module *M = CloneModule(BD.Program); + + // Convert list to set for fast lookup... + std::set Blocks; + for (unsigned i = 0, e = BBs.size(); i != e; ++i) { + // Convert the basic block from the original module to the new module... + Function *F = BBs[i]->getParent(); + Function *CMF = M->getFunction(F->getName(), F->getFunctionType()); + assert(CMF && "Function not in module?!"); + + // Get the mapped basic block... + Function::iterator CBI = CMF->begin(); + std::advance(CBI, std::distance(F->begin(), Function::iterator(BBs[i]))); + Blocks.insert(CBI); + } + + std::cout << "Checking for crash with only these blocks:"; + for (unsigned i = 0, e = Blocks.size(); i != e; ++i) + std::cout << " " << BBs[i]->getName(); + std::cout << ": "; + + // Loop over and delete any hack up any blocks that are not listed... + for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I) + for (Function::iterator BB = I->begin(), E = I->end(); BB != E; ++BB) + if (!Blocks.count(BB) && !isa(BB->getTerminator())) { + // Loop over all of the successors of this block, deleting any PHI nodes + // that might include it. + for (succ_iterator SI = succ_begin(BB), E = succ_end(BB); SI != E; ++SI) + (*SI)->removePredecessor(BB); + + // Delete the old terminator instruction... + BB->getInstList().pop_back(); + + // Add a new return instruction of the appropriate type... + const Type *RetTy = BB->getParent()->getReturnType(); + ReturnInst *RI = new ReturnInst(RetTy == Type::VoidTy ? 0 : + Constant::getNullValue(RetTy)); + BB->getInstList().push_back(RI); + } + + // The CFG Simplifier pass may delete one of the basic blocks we are + // interested in. If it does we need to take the block out of the list. Make + // a "persistent mapping" by turning basic blocks into pairs. + // This won't work well if blocks are unnamed, but that is just the risk we + // have to take. + std::vector > BlockInfo; + + for (std::set::iterator I = Blocks.begin(), E = Blocks.end(); + I != E; ++I) + BlockInfo.push_back(std::make_pair((*I)->getParent(), (*I)->getName())); + + // Now run the CFG simplify pass on the function... + PassManager Passes; + Passes.add(createCFGSimplificationPass()); + Passes.add(createVerifierPass()); + Passes.run(*M); + + // Try running on the hacked up program... + std::swap(BD.Program, M); + if (BD.runPasses(BD.PassesToRun)) { + delete M; // It crashed, keep the trimmed version... + + // Make sure to use basic block pointers that point into the now-current + // module, and that they don't include any deleted blocks. + BBs.clear(); + for (unsigned i = 0, e = BlockInfo.size(); i != e; ++i) { + SymbolTable &ST = BlockInfo[i].first->getSymbolTable(); + SymbolTable::iterator I = ST.find(Type::LabelTy); + if (I != ST.end() && I->second.count(BlockInfo[i].second)) + BBs.push_back(cast(I->second[BlockInfo[i].second])); + } + return true; + } + delete BD.Program; // It didn't crash, revert... + BD.Program = M; + return false; +} + /// debugCrash - This method is called when some pass crashes on input. It /// attempts to prune down the testcase to something reasonable, and figure /// out exactly which pass is crashing. @@ -154,8 +264,16 @@ } } - // FIXME: This should attempt to delete entire basic blocks at a time to speed - // up convergence... + // Attempt to delete entire basic blocks at a time to speed up + // convergence... this actually works by setting the terminator of the blocks + // to a return instruction then running simplifycfg, which can potentially + // shrinks the code dramatically quickly + // + std::vector Blocks; + for (Module::iterator I = Program->begin(), E = Program->end(); I != E; ++I) + for (Function::iterator FI = I->begin(), E = I->end(); FI != E; ++FI) + Blocks.push_back(FI); + ReduceCrashingBlocks(*this).reduceList(Blocks); // FIXME: This should use the list reducer to converge faster by deleting // larger chunks of instructions at a time! From lattner at cs.uiuc.edu Thu Apr 24 19:47:00 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Apr 24 19:47:00 2003 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/Mem2Reg/2003-04-24-MultipleIdenticalSuccessors.ll Message-ID: <200304250046.TAA09962@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/Mem2Reg: 2003-04-24-MultipleIdenticalSuccessors.ll added (r1.1) --- Log message: New testcase --- Diffs of the changes: Index: llvm/test/Regression/Transforms/Mem2Reg/2003-04-24-MultipleIdenticalSuccessors.ll diff -c /dev/null llvm/test/Regression/Transforms/Mem2Reg/2003-04-24-MultipleIdenticalSuccessors.ll:1.1 *** /dev/null Thu Apr 24 19:46:25 2003 --- llvm/test/Regression/Transforms/Mem2Reg/2003-04-24-MultipleIdenticalSuccessors.ll Thu Apr 24 19:46:14 2003 *************** *** 0 **** --- 1,15 ---- + ; Mem2reg used to only add one incoming value to a PHI node, even if it had + ; multiple incoming edges from a block. + ; + ; RUN: as < %s | opt -mem2reg -disable-output + + int %test(bool %c1, bool %c2) { + %X = alloca int + br bool %c1, label %Exit, label %B2 + B2: + store int 2, int* %X + br bool %c2, label %Exit, label %Exit + Exit: + %Y = load int *%X + ret int %Y + } From lattner at cs.uiuc.edu Thu Apr 24 19:54:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Apr 24 19:54:01 2003 Subject: [llvm-commits] CVS: llvm/tools/bugpoint/ExtractFunction.cpp Message-ID: <200304250053.TAA10204@apoc.cs.uiuc.edu> Changes in directory llvm/tools/bugpoint: ExtractFunction.cpp updated: 1.5 -> 1.6 --- Log message: When cleaning up the final bytecode file, make sure to run DTE as well --- Diffs of the changes: Index: llvm/tools/bugpoint/ExtractFunction.cpp diff -u llvm/tools/bugpoint/ExtractFunction.cpp:1.5 llvm/tools/bugpoint/ExtractFunction.cpp:1.6 --- llvm/tools/bugpoint/ExtractFunction.cpp:1.5 Thu Apr 24 17:53:11 2003 +++ llvm/tools/bugpoint/ExtractFunction.cpp Thu Apr 24 19:52:30 2003 @@ -64,11 +64,12 @@ /// before handing it to the user... /// Module *BugDriver::performFinalCleanups() const { + Module *M = CloneModule(Program); PassManager CleanupPasses; CleanupPasses.add(createFunctionResolvingPass()); CleanupPasses.add(createGlobalDCEPass()); + CleanupPasses.add(createDeadTypeEliminationPass()); CleanupPasses.add(createVerifierPass()); - Module *M = CloneModule(Program); CleanupPasses.run(*M); return M; } From lattner at cs.uiuc.edu Thu Apr 24 19:54:05 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Apr 24 19:54:05 2003 Subject: [llvm-commits] CVS: llvm/tools/bugpoint/CrashDebugger.cpp Message-ID: <200304250053.TAA10211@apoc.cs.uiuc.edu> Changes in directory llvm/tools/bugpoint: CrashDebugger.cpp updated: 1.8 -> 1.9 --- Log message: Big programs have tons of global variable initializers, and most passes don't care about them. Try to delete them if it doesn't affect the passes. --- Diffs of the changes: Index: llvm/tools/bugpoint/CrashDebugger.cpp diff -u llvm/tools/bugpoint/CrashDebugger.cpp:1.8 llvm/tools/bugpoint/CrashDebugger.cpp:1.9 --- llvm/tools/bugpoint/CrashDebugger.cpp:1.8 Thu Apr 24 18:51:38 2003 +++ llvm/tools/bugpoint/CrashDebugger.cpp Thu Apr 24 19:53:05 2003 @@ -244,6 +244,36 @@ << getPassesString(PassesToRun) << "\n"; EmitProgressBytecode("passinput"); + + // See if we can get away with nuking all of the global variable initializers + // in the program... + if (Program->gbegin() != Program->gend()) { + Module *M = CloneModule(Program); + bool DeletedInit = false; + for (Module::giterator I = M->gbegin(), E = M->gend(); I != E; ++I) + if (I->hasInitializer()) { + I->setInitializer(0); + I->setLinkage(GlobalValue::ExternalLinkage); + DeletedInit = true; + } + + if (!DeletedInit) { + delete M; // No change made... + } else { + // See if the program still causes a crash... + std::cout << "\nChecking to see if we can delete global inits: "; + std::swap(Program, M); + if (runPasses(PassesToRun)) { // Still crashes? + AnyReduction = true; + delete M; + std::cout << "\n*** Able to remove all global initializers!\n"; + } else { // No longer crashes? + delete Program; // Restore program. + Program = M; + std::cout << " - Removing all global inits hides problem!\n"; + } + } + } // Now try to reduce the number of functions in the module to something small. std::vector Functions; From lattner at cs.uiuc.edu Thu Apr 24 19:56:00 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Apr 24 19:56:00 2003 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp Message-ID: <200304250055.TAA10302@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Utils: PromoteMemoryToRegister.cpp updated: 1.40 -> 1.41 --- Log message: Fix bug: mem2reg/2003-04-24-MultipleIdenticalSuccessors.ll --- Diffs of the changes: Index: llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp diff -u llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp:1.40 llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp:1.41 --- llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp:1.40 Thu Apr 24 12:52:20 2003 +++ llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp Thu Apr 24 19:54:58 2003 @@ -222,13 +222,14 @@ std::vector &BBPNs = NewPhiNodes[BB]; for (unsigned k = 0; k != BBPNs.size(); ++k) if (PHINode *PN = BBPNs[k]) { - int BBI = PN->getBasicBlockIndex(Pred); - assert(BBI >= 0 && "Predecessor not in basic block yet!"); - - // At this point we can assume that the array has phi nodes.. let's update - // the incoming data. - PN->setIncomingValue(BBI, IncomingVals[k]); - + // The PHI node may have multiple entries for this predecessor. We must + // make sure we update all of them. + for (unsigned i = 0, e = PN->getNumOperands(); i != e; i += 2) { + if (PN->getOperand(i+1) == Pred) + // At this point we can assume that the array has phi nodes.. let's + // update the incoming data. + PN->setOperand(i, IncomingVals[k]); + } // also note that the active variable IS designated by the phi node IncomingVals[k] = PN; } From lattner at cs.uiuc.edu Thu Apr 24 21:51:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Apr 24 21:51:01 2003 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/SCCP.cpp Message-ID: <200304250250.VAA11664@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: SCCP.cpp updated: 1.65 -> 1.66 --- Log message: Minor non-functional changes: * Spell propagate right * Improve performance of phi node handling * Delete using directive * Other minor changes --- Diffs of the changes: Index: llvm/lib/Transforms/Scalar/SCCP.cpp diff -u llvm/lib/Transforms/Scalar/SCCP.cpp:1.65 llvm/lib/Transforms/Scalar/SCCP.cpp:1.66 --- llvm/lib/Transforms/Scalar/SCCP.cpp:1.65 Wed Apr 23 11:37:42 2003 +++ llvm/lib/Transforms/Scalar/SCCP.cpp Thu Apr 24 21:50:03 2003 @@ -17,17 +17,13 @@ #include "llvm/Transforms/Scalar.h" #include "llvm/ConstantHandling.h" #include "llvm/Function.h" -#include "llvm/iPHINode.h" -#include "llvm/iMemory.h" -#include "llvm/iTerminators.h" -#include "llvm/iOther.h" +#include "llvm/Instructions.h" #include "llvm/Pass.h" #include "llvm/Support/InstVisitor.h" #include "Support/STLExtras.h" #include "Support/Statistic.h" #include #include -using std::cerr; // InstVal class - This class represents the different lattice values that an // instruction may occupy. It is a simple class with value semantics. @@ -111,9 +107,8 @@ // the users of the instruction are updated later. // inline bool markConstant(Instruction *I, Constant *V) { - DEBUG(cerr << "markConstant: " << V << " = " << I); - if (ValueState[I].markConstant(V)) { + DEBUG(std::cerr << "markConstant: " << V << " = " << I); InstWorkList.push_back(I); return true; } @@ -127,7 +122,7 @@ inline bool markOverdefined(Value *V) { if (ValueState[V].markOverdefined()) { if (Instruction *I = dyn_cast(V)) { - DEBUG(cerr << "markOverdefined: " << V); + DEBUG(std::cerr << "markOverdefined: " << V); InstWorkList.push_back(I); // Only instructions go on the work list } return true; @@ -161,10 +156,19 @@ // work list if it is not already executable... // void markExecutable(BasicBlock *BB) { - if (BBExecutable.count(BB)) return; - DEBUG(cerr << "Marking BB Executable: " << *BB); - BBExecutable.insert(BB); // Basic block is executable! - BBWorkList.push_back(BB); // Add the block to the work list! + if (BBExecutable.count(BB)) { + // BB is already executable, but we may have just made an edge feasible + // that wasn't before. Add the PHI nodes to the work list so that they + // can be rechecked. + for (BasicBlock::iterator I = BB->begin(); + PHINode *PN = dyn_cast(I); ++I) + InstWorkList.push_back(PN); + + } else { + DEBUG(std::cerr << "Marking BB Executable: " << *BB); + BBExecutable.insert(BB); // Basic block is executable! + BBWorkList.push_back(BB); // Add the block to the work list! + } } @@ -193,7 +197,7 @@ void visitInstruction(Instruction &I) { // If a new instruction is added to LLVM that we don't handle... - cerr << "SCCP: Don't know how to handle: " << I; + std::cerr << "SCCP: Don't know how to handle: " << I; markOverdefined(&I); // Just in case } @@ -214,12 +218,12 @@ void OperandChangedState(User *U) { // Only instructions use other variable values! Instruction &I = cast(*U); - if (!BBExecutable.count(I.getParent())) return;// Inst not executable yet! - visit(I); + if (BBExecutable.count(I.getParent())) // Inst is executable? + visit(I); } }; - RegisterOpt X("sccp", "Sparse Conditional Constant Propogation"); + RegisterOpt X("sccp", "Sparse Conditional Constant Propagation"); } // end anonymous namespace @@ -248,8 +252,7 @@ Instruction *I = InstWorkList.back(); InstWorkList.pop_back(); - DEBUG(cerr << "\nPopped off I-WL: " << I); - + DEBUG(std::cerr << "\nPopped off I-WL: " << I); // "I" got into the work list because it either made the transition from // bottom to constant, or to Overdefined. @@ -265,13 +268,7 @@ BasicBlock *BB = BBWorkList.back(); BBWorkList.pop_back(); - DEBUG(cerr << "\nPopped off BBWL: " << BB); - - // If this block only has a single successor, mark it as executable as - // well... if not, terminate the do loop. - // - if (BB->getTerminator()->getNumSuccessors() == 1) - markExecutable(BB->getTerminator()->getSuccessor(0)); + DEBUG(std::cerr << "\nPopped off BBWL: " << BB); // Notify all instructions in this basic block that they are newly // executable. @@ -282,7 +279,7 @@ if (DebugFlag) { for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I) if (!BBExecutable.count(I)) - cerr << "BasicBlock Dead:" << *I; + std::cerr << "BasicBlock Dead:" << *I; } // Iterate over all of the instructions in a function, replacing them with @@ -295,7 +292,7 @@ InstVal &IV = ValueState[&Inst]; if (IV.isConstant()) { Constant *Const = IV.getConstant(); - DEBUG(cerr << "Constant: " << Const << " = " << Inst); + DEBUG(std::cerr << "Constant: " << Const << " = " << Inst); // Replaces all of the uses of a variable with uses of the constant. Inst.replaceAllUsesWith(Const); @@ -325,7 +322,7 @@ // successors are reachable from a given terminator instruction. // void SCCP::getFeasibleSuccessors(TerminatorInst &TI, std::vector &Succs) { - assert(Succs.size() == TI.getNumSuccessors() && "Succs vector wrong size!"); + Succs.resize(TI.getNumSuccessors()); if (BranchInst *BI = dyn_cast(&TI)) { if (BI->isUnconditional()) { Succs[0] = true; @@ -362,7 +359,7 @@ Succs[0] = true; } } else { - cerr << "SCCP: Don't know how to handle: " << TI; + std::cerr << "SCCP: Don't know how to handle: " << TI; Succs.assign(TI.getNumSuccessors(), true); } } @@ -379,7 +376,7 @@ // Check to make sure this edge itself is actually feasible now... TerminatorInst *FT = From->getTerminator(); - std::vector SuccFeasible(FT->getNumSuccessors()); + std::vector SuccFeasible; getFeasibleSuccessors(*FT, SuccFeasible); // Check all edges from From to To. If any are feasible, return true. @@ -409,10 +406,8 @@ // 7. If a conditional branch has a value that is overdefined, make all // successors executable. // - void SCCP::visitPHINode(PHINode &PN) { - unsigned NumValues = PN.getNumIncomingValues(), i; - InstVal *OperandIV = 0; + if (getValueState(&PN).isOverdefined()) return; // Quick exit // Look at all of the executable operands of the PHI node. If any of them // are overdefined, the PHI becomes overdefined as well. If they are all @@ -420,24 +415,25 @@ // constant. If they are constant and don't agree, the PHI is overdefined. // If there are no executable operands, the PHI remains undefined. // - for (i = 0; i < NumValues; ++i) { + Constant *OperandVal = 0; + for (unsigned i = 0, e = PN.getNumIncomingValues(); i != e; ++i) { + InstVal &IV = getValueState(PN.getIncomingValue(i)); + if (IV.isUndefined()) continue; // Doesn't influence PHI node. + if (IV.isOverdefined()) { // PHI node becomes overdefined! + markOverdefined(&PN); + return; + } + if (isEdgeFeasible(PN.getIncomingBlock(i), PN.getParent())) { - InstVal &IV = getValueState(PN.getIncomingValue(i)); - if (IV.isUndefined()) continue; // Doesn't influence PHI node. - if (IV.isOverdefined()) { // PHI node becomes overdefined! - markOverdefined(&PN); - return; - } - - if (OperandIV == 0) { // Grab the first value... - OperandIV = &IV; + if (OperandVal == 0) { // Grab the first value... + OperandVal = IV.getConstant(); } else { // Another value is being merged in! // There is already a reachable operand. If we conflict with it, // then the PHI node becomes overdefined. If we agree with it, we // can continue on. - + // Check to see if there are two different constants merging... - if (IV.getConstant() != OperandIV->getConstant()) { + if (IV.getConstant() != OperandVal) { // Yes there is. This means the PHI node is not constant. // You must be overdefined poor PHI. // @@ -449,18 +445,16 @@ } // If we exited the loop, this means that the PHI node only has constant - // arguments that agree with each other(and OperandIV is a pointer to one - // of their InstVal's) or OperandIV is null because there are no defined - // incoming arguments. If this is the case, the PHI remains undefined. - // - if (OperandIV) { - assert(OperandIV->isConstant() && "Should only be here for constants!"); - markConstant(&PN, OperandIV->getConstant()); // Aquire operand value - } + // arguments that agree with each other(and OperandVal is the constant) or + // OperandVal is null because there are no defined incoming arguments. If + // this is the case, the PHI remains undefined. + // + if (OperandVal) + markConstant(&PN, OperandVal); // Aquire operand value } void SCCP::visitTerminatorInst(TerminatorInst &TI) { - std::vector SuccFeasible(TI.getNumSuccessors()); + std::vector SuccFeasible; getFeasibleSuccessors(TI, SuccFeasible); // Mark all feasible successors executable... @@ -468,14 +462,6 @@ if (SuccFeasible[i]) { BasicBlock *Succ = TI.getSuccessor(i); markExecutable(Succ); - - // Visit all of the PHI nodes that merge values from this block... - // Because this edge may be new executable, and PHI nodes that used to be - // constant now may not be. - // - for (BasicBlock::iterator I = Succ->begin(); - PHINode *PN = dyn_cast(I); ++I) - visitPHINode(*PN); } } From lattner at cs.uiuc.edu Thu Apr 24 21:51:07 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Apr 24 21:51:07 2003 Subject: [llvm-commits] CVS: llvm/include/llvm/Target/TargetData.h Message-ID: <200304250250.VAA11676@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Target: TargetData.h updated: 1.14 -> 1.15 --- Log message: Default ctor doesn't provide name --- Diffs of the changes: Index: llvm/include/llvm/Target/TargetData.h diff -u llvm/include/llvm/Target/TargetData.h:1.14 llvm/include/llvm/Target/TargetData.h:1.15 --- llvm/include/llvm/Target/TargetData.h:1.14 Thu Apr 24 14:08:45 2003 +++ llvm/include/llvm/Target/TargetData.h Thu Apr 24 21:50:19 2003 @@ -38,7 +38,7 @@ static Annotation *TypeAnFactory(AnnotationID, const Annotable *, void *); public: - TargetData(const std::string &TargetName = "Default Target", + TargetData(const std::string &TargetName = "", bool LittleEndian = false, unsigned char SubWordDataSize = 1, unsigned char IntRegSize = 8, From lattner at cs.uiuc.edu Thu Apr 24 21:51:11 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Apr 24 21:51:11 2003 Subject: [llvm-commits] CVS: llvm/lib/Target/TargetData.cpp Message-ID: <200304250250.VAA11686@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target: TargetData.cpp updated: 1.28 -> 1.29 --- Log message: Allow for easy detection of when a "default" TargetData is created by the passmanager, which is never the right thing to do. --- Diffs of the changes: Index: llvm/lib/Target/TargetData.cpp diff -u llvm/lib/Target/TargetData.cpp:1.28 llvm/lib/Target/TargetData.cpp:1.29 --- llvm/lib/Target/TargetData.cpp:1.28 Thu Apr 24 14:09:05 2003 +++ llvm/lib/Target/TargetData.cpp Thu Apr 24 21:50:45 2003 @@ -91,6 +91,13 @@ : AID(AnnotationManager::getID("TargetData::" + TargetName)) { AnnotationManager::registerAnnotationFactory(AID, TypeAnFactory, this); + // If this assert triggers, a pass "required" TargetData information, but the + // top level tool did not provide once for it. We do not want to default + // construct, or else we might end up using a bad endianness or pointer size! + // + assert(!TargetName.empty() && + "ERROR: Tool did not specify a target data to use!"); + LittleEndian = isLittleEndian; SubWordDataSize = SubWordSize; IntegerRegSize = IntRegSize; From lattner at cs.uiuc.edu Thu Apr 24 21:52:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Apr 24 21:52:01 2003 Subject: [llvm-commits] CVS: llvm/include/llvm/ConstantHandling.h Message-ID: <200304250251.VAA11713@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: ConstantHandling.h updated: 1.24 -> 1.25 --- Log message: *** Huge: Make constantexprs be handled correctly, conservatively --- Diffs of the changes: Index: llvm/include/llvm/ConstantHandling.h diff -u llvm/include/llvm/ConstantHandling.h:1.24 llvm/include/llvm/ConstantHandling.h:1.25 --- llvm/include/llvm/ConstantHandling.h:1.24 Thu Apr 17 14:22:47 2003 +++ llvm/include/llvm/ConstantHandling.h Thu Apr 24 21:51:46 2003 @@ -112,10 +112,13 @@ // we just want to make sure to hit the cache instead of doing it indirectly, // if possible... // - static inline ConstRules *get(const Constant &V) { - return (ConstRules*)V.getType()->getOrCreateAnnotation(AID); + static inline ConstRules *get(const Constant &V1, const Constant &V2) { + if (isa(V1) || isa(V2)) + return getConstantExprRules(); + return (ConstRules*)V1.getType()->getOrCreateAnnotation(AID); } private: + static ConstRules *getConstantExprRules(); static Annotation *find(AnnotationID AID, const Annotable *Ty, void *); ConstRules(const ConstRules &); // Do not implement @@ -126,60 +129,60 @@ // Standard binary operators... inline Constant *operator+(const Constant &V1, const Constant &V2) { assert(V1.getType() == V2.getType() && "Constant types must be identical!"); - return ConstRules::get(V1)->add(&V1, &V2); + return ConstRules::get(V1, V2)->add(&V1, &V2); } inline Constant *operator-(const Constant &V1, const Constant &V2) { assert(V1.getType() == V2.getType() && "Constant types must be identical!"); - return ConstRules::get(V1)->sub(&V1, &V2); + return ConstRules::get(V1, V2)->sub(&V1, &V2); } inline Constant *operator*(const Constant &V1, const Constant &V2) { assert(V1.getType() == V2.getType() && "Constant types must be identical!"); - return ConstRules::get(V1)->mul(&V1, &V2); + return ConstRules::get(V1, V2)->mul(&V1, &V2); } inline Constant *operator/(const Constant &V1, const Constant &V2) { assert(V1.getType() == V2.getType() && "Constant types must be identical!"); - return ConstRules::get(V1)->div(&V1, &V2); + return ConstRules::get(V1, V2)->div(&V1, &V2); } inline Constant *operator%(const Constant &V1, const Constant &V2) { assert(V1.getType() == V2.getType() && "Constant types must be identical!"); - return ConstRules::get(V1)->rem(&V1, &V2); + return ConstRules::get(V1, V2)->rem(&V1, &V2); } // Logical Operators... inline Constant *operator&(const Constant &V1, const Constant &V2) { assert(V1.getType() == V2.getType() && "Constant types must be identical!"); - return ConstRules::get(V1)->op_and(&V1, &V2); + return ConstRules::get(V1, V2)->op_and(&V1, &V2); } inline Constant *operator|(const Constant &V1, const Constant &V2) { assert(V1.getType() == V2.getType() && "Constant types must be identical!"); - return ConstRules::get(V1)->op_or(&V1, &V2); + return ConstRules::get(V1, V2)->op_or(&V1, &V2); } inline Constant *operator^(const Constant &V1, const Constant &V2) { assert(V1.getType() == V2.getType() && "Constant types must be identical!"); - return ConstRules::get(V1)->op_xor(&V1, &V2); + return ConstRules::get(V1, V2)->op_xor(&V1, &V2); } // Shift Instructions... inline Constant *operator<<(const Constant &V1, const Constant &V2) { assert(V1.getType()->isInteger() && V2.getType() == Type::UByteTy); - return ConstRules::get(V1)->shl(&V1, &V2); + return ConstRules::get(V1, V2)->shl(&V1, &V2); } inline Constant *operator>>(const Constant &V1, const Constant &V2) { assert(V1.getType()->isInteger() && V2.getType() == Type::UByteTy); - return ConstRules::get(V1)->shr(&V1, &V2); + return ConstRules::get(V1, V2)->shr(&V1, &V2); } inline ConstantBool *operator<(const Constant &V1, const Constant &V2) { assert(V1.getType() == V2.getType() && "Constant types must be identical!"); - return ConstRules::get(V1)->lessthan(&V1, &V2); + return ConstRules::get(V1, V2)->lessthan(&V1, &V2); } @@ -194,12 +197,16 @@ inline ConstantBool *operator>=(const Constant &V1, const Constant &V2) { - return (V1 < V2)->inverted(); // !(V1 < V2) + if (ConstantBool *V = (V1 < V2)) + return V->inverted(); // !(V1 < V2) + return 0; } inline ConstantBool *operator<=(const Constant &V1, const Constant &V2) { - return (V1 > V2)->inverted(); // !(V1 > V2) + if (ConstantBool *V = (V1 > V2)) + return V->inverted(); // !(V1 > V2) + return 0; } From lattner at cs.uiuc.edu Thu Apr 24 21:53:00 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Apr 24 21:53:00 2003 Subject: [llvm-commits] CVS: llvm/lib/VMCore/ConstantHandling.cpp Message-ID: <200304250252.VAA11730@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: ConstantHandling.cpp updated: 1.25 -> 1.26 --- Log message: ** CORRECTLY, conservatively handle constant expressions --- Diffs of the changes: Index: llvm/lib/VMCore/ConstantHandling.cpp diff -u llvm/lib/VMCore/ConstantHandling.cpp:1.25 llvm/lib/VMCore/ConstantHandling.cpp:1.26 --- llvm/lib/VMCore/ConstantHandling.cpp:1.25 Thu Apr 17 14:24:18 2003 +++ llvm/lib/VMCore/ConstantHandling.cpp Thu Apr 24 21:52:06 2003 @@ -47,7 +47,7 @@ switch (I->getOpcode()) { case Instruction::Cast: - return ConstRules::get(*Op0)->castTo(Op0, I->getType()); + return ConstRules::get(*Op0, *Op0)->castTo(Op0, I->getType()); case Instruction::Add: return *Op0 + *Op1; case Instruction::Sub: return *Op0 - *Op1; case Instruction::Mul: return *Op0 * *Op1; @@ -107,7 +107,7 @@ } } - return ConstRules::get(*V)->castTo(V, DestTy); + return ConstRules::get(*V, *V)->castTo(V, DestTy); } Constant *ConstantFoldBinaryInstruction(unsigned Opcode, const Constant *V1, @@ -554,4 +554,9 @@ default: return new EmptyRules(); } +} + +ConstRules *ConstRules::getConstantExprRules() { + static EmptyRules CERules; + return &CERules; } From lattner at cs.uiuc.edu Thu Apr 24 22:17:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Apr 24 22:17:01 2003 Subject: [llvm-commits] CVS: llvm/tools/bugpoint/ListReducer.h Message-ID: <200304250316.WAA12120@apoc.cs.uiuc.edu> Changes in directory llvm/tools/bugpoint: ListReducer.h updated: 1.2 -> 1.3 --- Log message: Rename Kept -> Suffix FIX problem where we were incorrectly putting the prefix of the list into the "suffix" list. --- Diffs of the changes: Index: llvm/tools/bugpoint/ListReducer.h diff -u llvm/tools/bugpoint/ListReducer.h:1.2 llvm/tools/bugpoint/ListReducer.h:1.3 --- llvm/tools/bugpoint/ListReducer.h:1.2 Thu Apr 24 17:23:56 2003 +++ llvm/tools/bugpoint/ListReducer.h Thu Apr 24 22:16:33 2003 @@ -34,14 +34,14 @@ unsigned MidTop = TheList.size(); while (MidTop > 1) { unsigned Mid = MidTop / 2; - std::vector Prefix(TheList.begin()+Mid, TheList.end()); - std::vector Kept (TheList.begin(), TheList.begin()+Mid); + std::vector Prefix(TheList.begin(), TheList.begin()+Mid); + std::vector Suffix(TheList.begin()+Mid, TheList.end()); - switch (doTest(Prefix, Kept)) { + switch (doTest(Prefix, Suffix)) { case KeepSuffix: // The property still holds. We can just drop the prefix elements, and // shorten the list to the "kept" elements. - TheList.swap(Kept); + TheList.swap(Suffix); MidTop = TheList.size(); break; case KeepPrefix: From lattner at cs.uiuc.edu Thu Apr 24 22:17:06 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Apr 24 22:17:06 2003 Subject: [llvm-commits] CVS: llvm/tools/bugpoint/Miscompilation.cpp Message-ID: <200304250316.WAA12125@apoc.cs.uiuc.edu> Changes in directory llvm/tools/bugpoint: Miscompilation.cpp updated: 1.6 -> 1.7 --- Log message: Rename Kept -> Suffix Fix problem where we accidentally returned KeepPrefix instead of KeepSuffix! --- Diffs of the changes: Index: llvm/tools/bugpoint/Miscompilation.cpp diff -u llvm/tools/bugpoint/Miscompilation.cpp:1.6 llvm/tools/bugpoint/Miscompilation.cpp:1.7 --- llvm/tools/bugpoint/Miscompilation.cpp:1.6 Thu Apr 24 17:24:22 2003 +++ llvm/tools/bugpoint/Miscompilation.cpp Thu Apr 24 22:16:05 2003 @@ -38,14 +38,14 @@ ReduceMiscompilingPasses::TestResult ReduceMiscompilingPasses::doTest(std::vector &Prefix, - std::vector &Kept) { - // First, run the program with just the Kept passes. If it is still broken + std::vector &Suffix) { + // First, run the program with just the Suffix passes. If it is still broken // with JUST the kept passes, discard the prefix passes. - std::cout << "Checking to see if '" << getPassesString(Kept) + std::cout << "Checking to see if '" << getPassesString(Suffix) << "' compile correctly: "; std::string BytecodeResult; - if (BD.runPasses(Kept, BytecodeResult, false/*delete*/, true/*quiet*/)) { + if (BD.runPasses(Suffix, BytecodeResult, false/*delete*/, true/*quiet*/)) { std::cerr << BD.getToolName() << ": Error running this sequence of passes" << " on the input program!\n"; exit(1); @@ -60,8 +60,8 @@ if (Prefix.empty()) return NoFailure; - // First, run the program with just the Kept passes. If it is still broken - // with JUST the kept passes, discard the prefix passes. + // Next, see if the program is broken if we run the "prefix" passes first, + // then seperately run the "kept" passes. std::cout << "Checking to see if '" << getPassesString(Prefix) << "' compile correctly: "; @@ -96,13 +96,13 @@ } removeFile(BytecodeResult); // No longer need the file on disk - std::cout << "Checking to see if '" << getPassesString(Kept) + std::cout << "Checking to see if '" << getPassesString(Suffix) << "' passes compile correctly after the '" << getPassesString(Prefix) << "' passes: "; Module *OriginalInput = BD.Program; BD.Program = PrefixOutput; - if (BD.runPasses(Kept, BytecodeResult, false/*delete*/, true/*quiet*/)) { + if (BD.runPasses(Suffix, BytecodeResult, false/*delete*/, true/*quiet*/)) { std::cerr << BD.getToolName() << ": Error running this sequence of passes" << " on the input program!\n"; exit(1); @@ -112,7 +112,7 @@ if (BD.diffProgram(Output, BytecodeResult, true/*delete bytecode*/)) { std::cout << "nope.\n"; delete OriginalInput; // We pruned down the original input... - return KeepPrefix; + return KeepSuffix; } // Otherwise, we must not be running the bad pass anymore. @@ -136,8 +136,8 @@ ReduceMiscompilingFunctions(BugDriver &bd) : BD(bd) {} virtual TestResult doTest(std::vector &Prefix, - std::vector &Kept) { - if (TestFuncs(Kept, false)) + std::vector &Suffix) { + if (TestFuncs(Suffix, false)) return KeepSuffix; if (!Prefix.empty() && TestFuncs(Prefix, false)) return KeepPrefix; From lattner at cs.uiuc.edu Thu Apr 24 22:36:00 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Apr 24 22:36:00 2003 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/SCCP.cpp Message-ID: <200304250335.WAA12336@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: SCCP.cpp updated: 1.66 -> 1.67 --- Log message: Fix major problem with PHI node traversal: rechecking PHIs should go into the visit function. The worklist is for when their lattice value changes. --- Diffs of the changes: Index: llvm/lib/Transforms/Scalar/SCCP.cpp diff -u llvm/lib/Transforms/Scalar/SCCP.cpp:1.66 llvm/lib/Transforms/Scalar/SCCP.cpp:1.67 --- llvm/lib/Transforms/Scalar/SCCP.cpp:1.66 Thu Apr 24 21:50:03 2003 +++ llvm/lib/Transforms/Scalar/SCCP.cpp Thu Apr 24 22:35:10 2003 @@ -162,7 +162,7 @@ // can be rechecked. for (BasicBlock::iterator I = BB->begin(); PHINode *PN = dyn_cast(I); ++I) - InstWorkList.push_back(PN); + visitPHINode(*PN); } else { DEBUG(std::cerr << "Marking BB Executable: " << *BB); From lattner at cs.uiuc.edu Thu Apr 24 22:57:00 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Apr 24 22:57:00 2003 Subject: [llvm-commits] CVS: llvm/test/Programs/Makefile.programs Message-ID: <200304250356.WAA12643@apoc.cs.uiuc.edu> Changes in directory llvm/test/Programs: Makefile.programs updated: 1.36 -> 1.37 --- Log message: Add targets to make it trivially easy to run bugpoint on a program --- Diffs of the changes: Index: llvm/test/Programs/Makefile.programs diff -u llvm/test/Programs/Makefile.programs:1.36 llvm/test/Programs/Makefile.programs:1.37 --- llvm/test/Programs/Makefile.programs:1.36 Fri Feb 28 13:39:49 2003 +++ llvm/test/Programs/Makefile.programs Thu Apr 24 22:56:37 2003 @@ -164,6 +164,23 @@ Output/%.llvm: Output/%.linked.bc $(LGCCLD) $(STATS) $< -lgcc -lc $(LIBS) -o Output/$*.llvm +# Targets to get the pass arguments that gccas and gccld are using... +Output/gccas-pass-args: $(LGCCAS) + $(LGCCAS) /dev/null -o /dev/null -debug-pass=Arguments > $@.1 2>&1 + sed 's/Pass Arguments: //' < $@.1 > $@ +Output/gccld-pass-args: $(LGCCLD) + $(LGCCLD) /dev/null -o /dev/null -debug-pass=Arguments > $@.1 2>&1 + sed 's/Pass Arguments: //' < $@.1 > $@ + + +# Rules to bugpoint the GCCAS or GCCLD command... +$(PROGRAMS_TO_TEST:%=Output/%.bugpoint-gccas): \ +Output/%.bugpoint-gccas: Output/%.linked.rll $(LBUGPOINT) Output/gccas-pass-args + $(LBUGPOINT) $< `cat Output/gccas-pass-args` $(BUGPOINT_OPTIONS) +$(PROGRAMS_TO_TEST:%=Output/%.bugpoint-gccld): \ +Output/%.bugpoint-gccld: Output/%.linked.bc $(LBUGPOINT) Output/gccld-pass-args + $(LBUGPOINT) $< `cat Output/gccld-pass-args` $(BUGPOINT_OPTIONS) + # # Rules to compile the program for the C Back End # @@ -179,6 +196,7 @@ RUN_OPTIONS += 2>&1 ifdef INPUT_FILENAME RUN_OPTIONS += < $(INPUT_FILENAME) +BUGPOINT_OPTIONS += -input $(INPUT_FILENAME) endif # Rules to build the test output... From lattner at cs.uiuc.edu Thu Apr 24 22:58:00 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Apr 24 22:58:00 2003 Subject: [llvm-commits] CVS: llvm/test/Programs/MultiSource/Makefile.multisrc Message-ID: <200304250357.WAA12655@apoc.cs.uiuc.edu> Changes in directory llvm/test/Programs/MultiSource: Makefile.multisrc updated: 1.25 -> 1.26 --- Log message: Make it _super_ easy to run bugpoint on multisource programs --- Diffs of the changes: Index: llvm/test/Programs/MultiSource/Makefile.multisrc diff -u llvm/test/Programs/MultiSource/Makefile.multisrc:1.25 llvm/test/Programs/MultiSource/Makefile.multisrc:1.26 --- llvm/test/Programs/MultiSource/Makefile.multisrc:1.25 Fri Feb 14 18:30:42 2003 +++ llvm/test/Programs/MultiSource/Makefile.multisrc Thu Apr 24 22:57:08 2003 @@ -34,6 +34,9 @@ Output/%.o: %.c Output/.dir $(CC) $(CPPFLAGS) -O $(CFLAGS) -c $< -o $@ +bugpoint-gccas: Output/$(PROG).bugpoint-gccas +bugpoint-gccld: Output/$(PROG).bugpoint-gccld + # Raw bytecode files are files created by simply linking the output of the GCC # frontend without running gccas. # From lattner at cs.uiuc.edu Thu Apr 24 23:22:00 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Apr 24 23:22:00 2003 Subject: [llvm-commits] CVS: llvm/tools/lli/Interpreter/Execution.cpp Message-ID: <200304250421.XAA15150@apoc.cs.uiuc.edu> Changes in directory llvm/tools/lli/Interpreter: Execution.cpp updated: 1.83 -> 1.84 --- Log message: Fix problem where we would read 64 bits worth of pointer information, even on 32 bit targets! --- Diffs of the changes: Index: llvm/tools/lli/Interpreter/Execution.cpp diff -u llvm/tools/lli/Interpreter/Execution.cpp:1.83 llvm/tools/lli/Interpreter/Execution.cpp:1.84 --- llvm/tools/lli/Interpreter/Execution.cpp:1.83 Wed Apr 23 14:55:35 2003 +++ llvm/tools/lli/Interpreter/Execution.cpp Thu Apr 24 23:21:19 2003 @@ -6,12 +6,8 @@ #include "Interpreter.h" #include "ExecutionAnnotations.h" -#include "llvm/GlobalVariable.h" -#include "llvm/Function.h" -#include "llvm/iPHINode.h" -#include "llvm/iOther.h" -#include "llvm/iTerminators.h" -#include "llvm/iMemory.h" +#include "llvm/Module.h" +#include "llvm/Instructions.h" #include "llvm/DerivedTypes.h" #include "llvm/Constants.h" #include "llvm/Assembly/Writer.h" @@ -776,6 +772,7 @@ case Type::ShortTyID: Result.UShortVal = (unsigned)Ptr->Untyped[0] | ((unsigned)Ptr->Untyped[1] << 8); break; + Load4BytesLittleEndian: case Type::FloatTyID: case Type::UIntTyID: case Type::IntTyID: Result.UIntVal = (unsigned)Ptr->Untyped[0] | @@ -783,10 +780,11 @@ ((unsigned)Ptr->Untyped[2] << 16) | ((unsigned)Ptr->Untyped[3] << 24); break; + case Type::PointerTyID: if (getModule().has32BitPointers()) + goto Load4BytesLittleEndian; case Type::DoubleTyID: case Type::ULongTyID: - case Type::LongTyID: - case Type::PointerTyID: Result.ULongVal = (uint64_t)Ptr->Untyped[0] | + case Type::LongTyID: Result.ULongVal = (uint64_t)Ptr->Untyped[0] | ((uint64_t)Ptr->Untyped[1] << 8) | ((uint64_t)Ptr->Untyped[2] << 16) | ((uint64_t)Ptr->Untyped[3] << 24) | @@ -808,6 +806,7 @@ case Type::ShortTyID: Result.UShortVal = (unsigned)Ptr->Untyped[1] | ((unsigned)Ptr->Untyped[0] << 8); break; + Load4BytesBigEndian: case Type::FloatTyID: case Type::UIntTyID: case Type::IntTyID: Result.UIntVal = (unsigned)Ptr->Untyped[3] | @@ -815,10 +814,11 @@ ((unsigned)Ptr->Untyped[1] << 16) | ((unsigned)Ptr->Untyped[0] << 24); break; + case Type::PointerTyID: if (getModule().has32BitPointers()) + goto Load4BytesBigEndian; case Type::DoubleTyID: case Type::ULongTyID: - case Type::LongTyID: - case Type::PointerTyID: Result.ULongVal = (uint64_t)Ptr->Untyped[7] | + case Type::LongTyID: Result.ULongVal = (uint64_t)Ptr->Untyped[7] | ((uint64_t)Ptr->Untyped[6] << 8) | ((uint64_t)Ptr->Untyped[5] << 16) | ((uint64_t)Ptr->Untyped[4] << 24) | From lattner at cs.uiuc.edu Fri Apr 25 00:23:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Apr 25 00:23:01 2003 Subject: [llvm-commits] CVS: llvm/tools/llc/llc.cpp Message-ID: <200304250522.AAA20605@apoc.cs.uiuc.edu> Changes in directory llvm/tools/llc: llc.cpp updated: 1.66 -> 1.67 --- Log message: Make sure to add a targetdata instance to the passmanager, and make it match the one in use by the TargetMachine --- Diffs of the changes: Index: llvm/tools/llc/llc.cpp diff -u llvm/tools/llc/llc.cpp:1.66 llvm/tools/llc/llc.cpp:1.67 --- llvm/tools/llc/llc.cpp:1.66 Thu Apr 24 13:36:39 2003 +++ llvm/tools/llc/llc.cpp Fri Apr 25 00:22:29 2003 @@ -173,6 +173,7 @@ assert(target.get() && "Could not allocate target machine!"); TargetMachine &Target = *target.get(); + const TargetData &TD = Target.getTargetData(); // Load the module to be compiled... std::auto_ptr M(ParseBytecodeFile(InputFilename)); @@ -184,6 +185,10 @@ // Build up all of the passes that we want to do to the module... PassManager Passes; + + Passes.add(new TargetData("llc", TD.isLittleEndian(), TD.getSubWordDataSize(), + TD.getIntegerRegSize(), TD.getPointerSize(), + TD.getPointerAlignment())); // Create a new optimization pass for each one specified on the command line // Deal specially with tracing passes, which must be run differently than opt. From lattner at cs.uiuc.edu Fri Apr 25 00:24:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Apr 25 00:24:01 2003 Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/SparcInstrInfo.cpp SparcInstrSelection.cpp Message-ID: <200304250523.AAA20653@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/Sparc: SparcInstrInfo.cpp updated: 1.38 -> 1.39 SparcInstrSelection.cpp updated: 1.86 -> 1.87 --- Log message: Fix obvious type-o --- Diffs of the changes: Index: llvm/lib/Target/Sparc/SparcInstrInfo.cpp diff -u llvm/lib/Target/Sparc/SparcInstrInfo.cpp:1.38 llvm/lib/Target/Sparc/SparcInstrInfo.cpp:1.39 --- llvm/lib/Target/Sparc/SparcInstrInfo.cpp:1.38 Wed Jan 15 15:36:50 2003 +++ llvm/lib/Target/Sparc/SparcInstrInfo.cpp Fri Apr 25 00:23:09 2003 @@ -443,7 +443,7 @@ if (opSize > destSize || (val->getType()->isSigned() - && destSize < target.getTargetData().getIntegerRegize())) + && destSize < target.getTargetData().getIntegerRegSize())) { // operand is larger than dest, // OR both are equal but smaller than the full register size // AND operand is signed, so it may have extra sign bits: Index: llvm/lib/Target/Sparc/SparcInstrSelection.cpp diff -u llvm/lib/Target/Sparc/SparcInstrSelection.cpp:1.86 llvm/lib/Target/Sparc/SparcInstrSelection.cpp:1.87 --- llvm/lib/Target/Sparc/SparcInstrSelection.cpp:1.86 Wed Jan 15 15:36:50 2003 +++ llvm/lib/Target/Sparc/SparcInstrSelection.cpp Fri Apr 25 00:23:10 2003 @@ -759,7 +759,7 @@ Value* shiftDest = destVal; unsigned opSize = target.getTargetData().getTypeSize(argVal1->getType()); if ((shiftOpCode == SLL || shiftOpCode == SLLX) - && opSize < target.getTargetData().getIntegerRegize()) + && opSize < target.getTargetData().getIntegerRegSize()) { // put SLL result into a temporary shiftDest = new TmpInstruction(argVal1, optArgVal2, "sllTmp"); mcfi.addTemp(shiftDest); @@ -2305,7 +2305,7 @@ .addReg(dest, MOTy::Def); mvec.push_back(M); } - else if (destSize < target.getTargetData().getIntegerRegize()) + else if (destSize < target.getTargetData().getIntegerRegSize()) assert(0 && "Unsupported type size: 32 < size < 64 bits"); } } From lattner at cs.uiuc.edu Fri Apr 25 00:24:06 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Apr 25 00:24:06 2003 Subject: [llvm-commits] CVS: llvm/include/llvm/Target/TargetData.h Message-ID: <200304250523.AAA20674@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Target: TargetData.h updated: 1.15 -> 1.16 --- Log message: Fix method name type-o --- Diffs of the changes: Index: llvm/include/llvm/Target/TargetData.h diff -u llvm/include/llvm/Target/TargetData.h:1.15 llvm/include/llvm/Target/TargetData.h:1.16 --- llvm/include/llvm/Target/TargetData.h:1.15 Thu Apr 24 21:50:19 2003 +++ llvm/include/llvm/Target/TargetData.h Fri Apr 25 00:23:27 2003 @@ -64,7 +64,7 @@ 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 getIntegerRegSize() 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 Fri Apr 25 00:27:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Apr 25 00:27:01 2003 Subject: [llvm-commits] CVS: llvm/tools/llc/llc.cpp Message-ID: <200304250526.AAA20725@apoc.cs.uiuc.edu> Changes in directory llvm/tools/llc: llc.cpp updated: 1.67 -> 1.68 --- Log message: Kill using declarations --- Diffs of the changes: Index: llvm/tools/llc/llc.cpp diff -u llvm/tools/llc/llc.cpp:1.67 llvm/tools/llc/llc.cpp:1.68 --- llvm/tools/llc/llc.cpp:1.67 Fri Apr 25 00:22:29 2003 +++ llvm/tools/llc/llc.cpp Fri Apr 25 00:26:11 2003 @@ -21,8 +21,6 @@ #include "Support/Signals.h" #include #include -using std::string; -using std::cerr; //------------------------------------------------------------------------------ // Option declarations for LLC. @@ -43,10 +41,10 @@ // within the corresponding llc passes, and target-specific options // and back-end code generation options are specified with the target machine. // -static cl::opt +static cl::opt InputFilename(cl::Positional, cl::desc(""), cl::init("-")); -static cl::opt +static cl::opt OutputFilename("o", cl::desc("Output filename"), cl::value_desc("filename")); static cl::opt Force("f", cl::desc("Overwrite output files")); @@ -55,7 +53,7 @@ DumpAsm("d", cl::desc("Print bytecode before native code generation"), cl::Hidden); -static cl::opt +static cl::opt TraceLibPath("tracelibpath", cl::desc("Path to libinstr for trace code"), cl::value_desc("directory"), cl::Hidden); @@ -66,14 +64,14 @@ // GetFileNameRoot - Helper function to get the basename of a filename... -static inline string -GetFileNameRoot(const string &InputFilename) +static inline std::string +GetFileNameRoot(const std::string &InputFilename) { - string IFN = InputFilename; - string outputFilename; + std::string IFN = InputFilename; + std::string outputFilename; int Len = IFN.length(); if (IFN[Len-3] == '.' && IFN[Len-2] == 'b' && IFN[Len-1] == 'c') { - outputFilename = string(IFN.begin(), IFN.end()-3); // s/.bc/.s/ + outputFilename = std::string(IFN.begin(), IFN.end()-3); // s/.bc/.s/ } else { outputFilename = IFN; } @@ -116,7 +114,7 @@ // If we still didn't get it, cancel trying to link it in... if (TraceModule == 0) - cerr << "Warning, could not load trace routines to link into program!\n"; + std::cerr <<"WARNING: couldn't load trace routines to link into program!\n"; else { // Link in the trace routines... if this fails, don't panic, because the @@ -124,23 +122,23 @@ // std::auto_ptr TraceRoutines(TraceModule); if (LinkModules(&M, TraceRoutines.get(), &ErrorMessage)) - cerr << "Warning: Error linking in trace routines: " - << ErrorMessage << "\n"; + std::cerr << "WARNING: Error linking in trace routines: " + << ErrorMessage << "\n"; } // Write out the module with tracing code just before code generation assert (InputFilename != "-" && "Cannot write out traced bytecode when reading input from stdin"); - string TraceFilename = GetFileNameRoot(InputFilename) + ".trace.bc"; + std::string TraceFilename = GetFileNameRoot(InputFilename) + ".trace.bc"; std::ofstream Out(TraceFilename.c_str()); if (!Out.good()) - cerr << "Error opening '" << TraceFilename - << "'!: Skipping output of trace code as bytecode\n"; + std::cerr << "Error opening '" << TraceFilename + << "'!: Skipping output of trace code as bytecode\n"; else { - cerr << "Emitting trace code to '" << TraceFilename - << "' for comparison...\n"; + std::cerr << "Emitting trace code to '" << TraceFilename + << "' for comparison...\n"; WriteBytecodeToFile(&M, Out); } @@ -179,7 +177,7 @@ std::auto_ptr M(ParseBytecodeFile(InputFilename)); if (M.get() == 0) { - cerr << argv[0] << ": bytecode didn't read correctly.\n"; + std::cerr << argv[0] << ": bytecode didn't read correctly.\n"; return 1; } @@ -208,8 +206,8 @@ else if (Opt->getTargetCtor()) Passes.add(Opt->getTargetCtor()(Target)); else - cerr << argv[0] << ": cannot create pass: " - << Opt->getPassName() << "\n"; + std::cerr << argv[0] << ": cannot create pass: " + << Opt->getPassName() << "\n"; } } @@ -227,7 +225,7 @@ // If LLVM dumping after transformations is requested, add it to the pipeline if (DumpAsm) - Passes.add(new PrintFunctionPass("Code after xformations: \n", &cerr)); + Passes.add(new PrintFunctionPass("Code after xformations: \n", &std::cerr)); // Strip all of the symbols from the bytecode so that it will be smaller... Passes.add(createSymbolStrippingPass()); @@ -238,9 +236,9 @@ { // Specified an output filename? if (!Force && std::ifstream(OutputFilename.c_str())) { // If force is not specified, make sure not to overwrite a file! - cerr << argv[0] << ": error opening '" << OutputFilename - << "': file exists!\n" - << "Use -f command line argument to force output\n"; + std::cerr << argv[0] << ": error opening '" << OutputFilename + << "': file exists!\n" + << "Use -f command line argument to force output\n"; return 1; } Out = new std::ofstream(OutputFilename.c_str()); @@ -258,22 +256,23 @@ } else { - string OutputFilename = GetFileNameRoot(InputFilename); + std::string OutputFilename = GetFileNameRoot(InputFilename); OutputFilename += ".s"; if (!Force && std::ifstream(OutputFilename.c_str())) { // If force is not specified, make sure not to overwrite a file! - cerr << argv[0] << ": error opening '" << OutputFilename - << "': file exists!\n" - << "Use -f command line argument to force output\n"; + std::cerr << argv[0] << ": error opening '" << OutputFilename + << "': file exists!\n" + << "Use -f command line argument to force output\n"; return 1; } Out = new std::ofstream(OutputFilename.c_str()); if (!Out->good()) { - cerr << argv[0] << ": error opening " << OutputFilename << "!\n"; + std::cerr << argv[0] << ": error opening " << OutputFilename + << "!\n"; delete Out; return 1; } @@ -286,8 +285,8 @@ // Ask the target to add backend passes as neccesary if (Target.addPassesToEmitAssembly(Passes, *Out)) { - cerr << argv[0] << ": target '" << Target.getName() - << " does not support static compilation!\n"; + std::cerr << argv[0] << ": target '" << Target.getName() + << " does not support static compilation!\n"; } else { // Run our queue of passes all at once now, efficiently. Passes.run(*M.get()); From lattner at cs.uiuc.edu Fri Apr 25 01:07:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Apr 25 01:07:01 2003 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86TargetMachine.cpp Message-ID: <200304250606.BAA25662@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86TargetMachine.cpp updated: 1.15 -> 1.16 --- Log message: Fix compatibility bug: X86 aligns doubles to 4 bytes, not 8! --- Diffs of the changes: Index: llvm/lib/Target/X86/X86TargetMachine.cpp diff -u llvm/lib/Target/X86/X86TargetMachine.cpp:1.15 llvm/lib/Target/X86/X86TargetMachine.cpp:1.16 --- llvm/lib/Target/X86/X86TargetMachine.cpp:1.15 Wed Apr 23 11:24:55 2003 +++ llvm/lib/Target/X86/X86TargetMachine.cpp Fri Apr 25 01:05:57 2003 @@ -37,6 +37,7 @@ (Config & TM::EndianMask) == TM::LittleEndian, 1, 4, (Config & TM::PtrSizeMask) == TM::PtrSize64 ? 8 : 4, + (Config & TM::PtrSizeMask) == TM::PtrSize64 ? 8 : 4, (Config & TM::PtrSizeMask) == TM::PtrSize64 ? 8 : 4), FrameInfo(TargetFrameInfo::StackGrowsDown, 8/*16 for SSE*/, 4) { } From lattner at cs.uiuc.edu Fri Apr 25 01:07:08 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Apr 25 01:07:08 2003 Subject: [llvm-commits] CVS: llvm/tools/llc/llc.cpp Message-ID: <200304250606.BAA25671@apoc.cs.uiuc.edu> Changes in directory llvm/tools/llc: llc.cpp updated: 1.68 -> 1.69 --- Log message: Make sure to copy double alignment as well --- Diffs of the changes: Index: llvm/tools/llc/llc.cpp diff -u llvm/tools/llc/llc.cpp:1.68 llvm/tools/llc/llc.cpp:1.69 --- llvm/tools/llc/llc.cpp:1.68 Fri Apr 25 00:26:11 2003 +++ llvm/tools/llc/llc.cpp Fri Apr 25 01:06:13 2003 @@ -186,7 +186,7 @@ Passes.add(new TargetData("llc", TD.isLittleEndian(), TD.getSubWordDataSize(), TD.getIntegerRegSize(), TD.getPointerSize(), - TD.getPointerAlignment())); + TD.getPointerAlignment(), TD.getDoubleAlignment())); // Create a new optimization pass for each one specified on the command line // Deal specially with tracing passes, which must be run differently than opt. From lattner at cs.uiuc.edu Fri Apr 25 01:07:14 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Apr 25 01:07:14 2003 Subject: [llvm-commits] CVS: llvm/lib/Target/TargetData.cpp Message-ID: <200304250606.BAA25682@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target: TargetData.cpp updated: 1.29 -> 1.30 --- Log message: Whoops, 32 bit targets have _4_ byte pointers, not _32_ byte pointers! --- Diffs of the changes: Index: llvm/lib/Target/TargetData.cpp diff -u llvm/lib/Target/TargetData.cpp:1.29 llvm/lib/Target/TargetData.cpp:1.30 --- llvm/lib/Target/TargetData.cpp:1.29 Thu Apr 24 21:50:45 2003 +++ llvm/lib/Target/TargetData.cpp Fri Apr 25 01:06:43 2003 @@ -104,6 +104,8 @@ PointerSize = PtrSize; PointerAlignment = PtrAl; DoubleAlignment = DoubleAl; + assert(DoubleAlignment == PtrAl && + "Double alignment and pointer alignment agree for now!"); FloatAlignment = FloatAl; LongAlignment = LongAl; IntAlignment = IntAl; @@ -118,9 +120,9 @@ LittleEndian = M->isLittleEndian(); SubWordDataSize = 1; IntegerRegSize = 8; - PointerSize = M->has32BitPointers() ? 32 : 64; + PointerSize = M->has32BitPointers() ? 4 : 8; PointerAlignment = PointerSize; - DoubleAlignment = 8; + DoubleAlignment = PointerSize; FloatAlignment = 4; LongAlignment = 8; IntAlignment = 4; From lattner at cs.uiuc.edu Fri Apr 25 01:16:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Apr 25 01:16:01 2003 Subject: [llvm-commits] CVS: llvm/tools/lli/Interpreter/Interpreter.cpp Message-ID: <200304250615.BAA27068@apoc.cs.uiuc.edu> Changes in directory llvm/tools/lli/Interpreter: Interpreter.cpp updated: 1.1 -> 1.2 --- Log message: MAke sure that LLI properly configures align_of(double) --- Diffs of the changes: Index: llvm/tools/lli/Interpreter/Interpreter.cpp diff -u llvm/tools/lli/Interpreter/Interpreter.cpp:1.1 llvm/tools/lli/Interpreter/Interpreter.cpp:1.2 --- llvm/tools/lli/Interpreter/Interpreter.cpp:1.1 Mon Dec 23 18:01:02 2002 +++ llvm/tools/lli/Interpreter/Interpreter.cpp Fri Apr 25 01:15:05 2003 @@ -27,6 +27,7 @@ CurFrame(-1), TD("lli", (Config & TM::EndianMask) == TM::LittleEndian, 1, 4, (Config & TM::PtrSizeMask) == TM::PtrSize64 ? 8 : 4, + (Config & TM::PtrSizeMask) == TM::PtrSize64 ? 8 : 4, (Config & TM::PtrSizeMask) == TM::PtrSize64 ? 8 : 4) { setTargetData(TD); From lattner at cs.uiuc.edu Fri Apr 25 13:00:00 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Apr 25 13:00:00 2003 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/BasicAA/2003-04-25-GEPCrash.ll Message-ID: <200304251759.MAA15270@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/BasicAA: 2003-04-25-GEPCrash.ll added (r1.1) --- Log message: New testcase --- Diffs of the changes: Index: llvm/test/Regression/Transforms/BasicAA/2003-04-25-GEPCrash.ll diff -c /dev/null llvm/test/Regression/Transforms/BasicAA/2003-04-25-GEPCrash.ll:1.1 *** /dev/null Fri Apr 25 12:59:12 2003 --- llvm/test/Regression/Transforms/BasicAA/2003-04-25-GEPCrash.ll Fri Apr 25 12:59:02 2003 *************** *** 0 **** --- 1,7 ---- + ; RUN: as < %s | opt -basicaa -aa-eval -disable-output + ; Test for a bug in BasicAA which caused a crash when querying equality of P1&P2 + void %test([17 x ushort]* %mask_bits) { + %P1 = getelementptr [17 x ushort]* %mask_bits, long 0, long 0 + %P2 = getelementptr [17 x ushort]* %mask_bits, long 252645134, long 0 + ret void + } From lattner at cs.uiuc.edu Fri Apr 25 13:04:00 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Apr 25 13:04:00 2003 Subject: [llvm-commits] CVS: llvm/lib/Analysis/BasicAliasAnalysis.cpp Message-ID: <200304251803.NAA15400@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: BasicAliasAnalysis.cpp updated: 1.7 -> 1.8 --- Log message: Fix BasicAA/2003-04-25-GEPCrash.ll --- Diffs of the changes: Index: llvm/lib/Analysis/BasicAliasAnalysis.cpp diff -u llvm/lib/Analysis/BasicAliasAnalysis.cpp:1.7 llvm/lib/Analysis/BasicAliasAnalysis.cpp:1.8 --- llvm/lib/Analysis/BasicAliasAnalysis.cpp:1.7 Tue Apr 22 17:00:27 2003 +++ llvm/lib/Analysis/BasicAliasAnalysis.cpp Fri Apr 25 13:03:06 2003 @@ -294,11 +294,11 @@ } } - int Offset1 = getTargetData().getIndexedOffset(GEPPointerTy, Indices1); - int Offset2 = getTargetData().getIndexedOffset(GEPPointerTy, Indices2); + int64_t Offset1 = getTargetData().getIndexedOffset(GEPPointerTy, Indices1); + int64_t Offset2 = getTargetData().getIndexedOffset(GEPPointerTy, Indices2); assert(Offset1 < Offset2 &&"There is at least one different constant here!"); - if ((unsigned)(Offset2-Offset1) >= SizeMax) { + if ((uint64_t)(Offset2-Offset1) >= SizeMax) { //std::cerr << "Determined that these two GEP's don't alias [" // << SizeMax << " bytes]: \n" << *GEP1 << *GEP2; return NoAlias; From lattner at cs.uiuc.edu Fri Apr 25 13:24:00 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Apr 25 13:24:00 2003 Subject: [llvm-commits] CVS: llvm/tools/lli/Interpreter/ExternalFunctions.cpp Message-ID: <200304251823.NAA17640@apoc.cs.uiuc.edu> Changes in directory llvm/tools/lli/Interpreter: ExternalFunctions.cpp updated: 1.47 -> 1.48 --- Log message: Add __strdup --- Diffs of the changes: Index: llvm/tools/lli/Interpreter/ExternalFunctions.cpp diff -u llvm/tools/lli/Interpreter/ExternalFunctions.cpp:1.47 llvm/tools/lli/Interpreter/ExternalFunctions.cpp:1.48 --- llvm/tools/lli/Interpreter/ExternalFunctions.cpp:1.47 Wed Apr 23 15:23:16 2003 +++ llvm/tools/lli/Interpreter/ExternalFunctions.cpp Fri Apr 25 13:23:38 2003 @@ -565,6 +565,12 @@ return Ret; } +// char *__strdup(const char *src); +GenericValue lle_X___strdup(FunctionType *M, const vector &Args) { + assert(Args.size() == 1); + return PTOGV(strdup((char*)GVTOP(Args[0]))); +} + // void *memset(void *S, int C, size_t N) GenericValue lle_X_memset(FunctionType *M, const vector &Args) { assert(Args.size() == 3); @@ -803,6 +809,7 @@ FuncNames["lle_X_strcat"] = lle_X_strcat; FuncNames["lle_X_strcpy"] = lle_X_strcpy; FuncNames["lle_X_strlen"] = lle_X_strlen; + FuncNames["lle_X___strdup"] = lle_X___strdup; FuncNames["lle_X_memset"] = lle_X_memset; FuncNames["lle_X_memcpy"] = lle_X_memcpy; From lattner at cs.uiuc.edu Fri Apr 25 13:29:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Apr 25 13:29:01 2003 Subject: [llvm-commits] CVS: llvm/tools/lli/Interpreter/ExternalFunctions.cpp Message-ID: <200304251828.NAA18150@apoc.cs.uiuc.edu> Changes in directory llvm/tools/lli/Interpreter: ExternalFunctions.cpp updated: 1.48 -> 1.49 --- Log message: Only do the %ld -> %lld promotion when running a 64 bit bytecode on a 32 bit host --- Diffs of the changes: Index: llvm/tools/lli/Interpreter/ExternalFunctions.cpp diff -u llvm/tools/lli/Interpreter/ExternalFunctions.cpp:1.48 llvm/tools/lli/Interpreter/ExternalFunctions.cpp:1.49 --- llvm/tools/lli/Interpreter/ExternalFunctions.cpp:1.48 Fri Apr 25 13:23:38 2003 +++ llvm/tools/lli/Interpreter/ExternalFunctions.cpp Fri Apr 25 13:28:44 2003 @@ -377,7 +377,8 @@ case 'u': case 'o': case 'x': case 'X': if (HowLong >= 1) { - if (HowLong == 1) { + if (HowLong == 1 && TheInterpreter->getModule().has64BitPointers() && + sizeof(long) < sizeof(long long)) { // Make sure we use %lld with a 64 bit argument because we might be // compiling LLI on a 32 bit compiler. unsigned Size = strlen(FmtBuf); From lattner at cs.uiuc.edu Fri Apr 25 13:34:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Apr 25 13:34:01 2003 Subject: [llvm-commits] CVS: llvm/test/Programs/SingleSource/dry.c Message-ID: <200304251833.NAA18309@apoc.cs.uiuc.edu> Changes in directory llvm/test/Programs/SingleSource: dry.c updated: 1.2 -> 1.3 --- Log message: * Switch to use the "clock" function to get time * Reduce the size of the testcase to run reasonably in LLI * Print some progress messages --- Diffs of the changes: Index: llvm/test/Programs/SingleSource/dry.c diff -u llvm/test/Programs/SingleSource/dry.c:1.2 llvm/test/Programs/SingleSource/dry.c:1.3 --- llvm/test/Programs/SingleSource/dry.c:1.2 Tue Apr 22 16:02:11 2003 +++ llvm/test/Programs/SingleSource/dry.c Fri Apr 25 13:33:25 2003 @@ -88,7 +88,7 @@ /*#define MYSTRFNS */ /* Accuracy of timings and human fatigue controlled by next two lines */ -#define LOOPS 300000 /* Use this for slow or 16 bit machines */ +#define LOOPS 10000 /* Use this for slow or 16 bit machines */ /*#define LOOPS 900000 /* Use this for faster machines */ /* Compiler dependent options */ @@ -96,8 +96,8 @@ #undef NOSTRUCTASSIGN /* Define if compiler can't assign structures */ /* define only one of the next three defines */ -/*#define CLOCK */ -#define TIMES /* Use times(2) time function */ +#define CLOCK +/*#define TIMES /* Use times(2) time function */ /*#define TIME /* Use time(2) time function */ /* define the granularity of your times(2) function (when used) */ @@ -256,6 +256,7 @@ #endif for (i = 0; i < LOOPS; ++i) { + if ((i & 127) == 0) printf("making progress: %d\n", i); Proc5(); Proc4(); IntLoc1 = 2; From lattner at cs.uiuc.edu Fri Apr 25 13:37:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Apr 25 13:37:01 2003 Subject: [llvm-commits] CVS: llvm/test/Programs/SingleSource/fldry.c Message-ID: <200304251836.NAA18641@apoc.cs.uiuc.edu> Changes in directory llvm/test/Programs/SingleSource: fldry.c updated: 1.2 -> 1.3 --- Log message: * Reduce testcase size to work with LLI reasonably * Use clock instead of time() * don't use long doubles, use doubles instead --- Diffs of the changes: Index: llvm/test/Programs/SingleSource/fldry.c diff -u llvm/test/Programs/SingleSource/fldry.c:1.2 llvm/test/Programs/SingleSource/fldry.c:1.3 --- llvm/test/Programs/SingleSource/fldry.c:1.2 Tue Apr 22 16:01:47 2003 +++ llvm/test/Programs/SingleSource/fldry.c Fri Apr 25 13:36:10 2003 @@ -80,7 +80,7 @@ /* #define the type of float we will use: */ #ifndef extended -#define extended long double +#define extended double #endif /* Define if should use homemade str* functions. */ @@ -88,7 +88,7 @@ /*#define MYSTRFNS*/ /* Accuracy of timings and human fatigue controlled by next two lines */ -#define LOOPS 150000 /* Use this for slow or 16 bit machines */ +#define LOOPS 15000 /* Use this for slow or 16 bit machines */ //#define LOOPS 900000 /* Use this for faster machines */ /* Compiler dependent options */ @@ -96,9 +96,9 @@ #undef NOSTRUCTASSIGN /* Define if compiler can't assign structures */ /* define only one of the next three defines */ -/*#define CLOCK*/ +#define CLOCK /*#define TIMES /* Use times(2) time function */ -#define TIME /* Use time(2) time function */ +/*#define TIME /* Use time(2) time function */ /* define the granularity of your times(2) function (when used) */ /*#define HZ 50 /* times(2) returns 1/50 second (europe?) */ @@ -264,6 +264,7 @@ #endif for (i = 0; i < LOOPS; ++i) { + if ((i & 255) == 0) printf("Making progress: %d\n", i); Proc5(); Proc4(); IntLoc1 = 2.0; From lattner at cs.uiuc.edu Fri Apr 25 13:45:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Apr 25 13:45:01 2003 Subject: [llvm-commits] CVS: llvm/test/Regression/CFrontend/2003-02-12-NonlocalGoto.c Message-ID: <200304251844.NAA20450@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/CFrontend: 2003-02-12-NonlocalGoto.c updated: 1.1 -> 1.2 --- Log message: Add comment --- Diffs of the changes: Index: llvm/test/Regression/CFrontend/2003-02-12-NonlocalGoto.c diff -u llvm/test/Regression/CFrontend/2003-02-12-NonlocalGoto.c:1.1 llvm/test/Regression/CFrontend/2003-02-12-NonlocalGoto.c:1.2 --- llvm/test/Regression/CFrontend/2003-02-12-NonlocalGoto.c:1.1 Wed Feb 12 15:45:39 2003 +++ llvm/test/Regression/CFrontend/2003-02-12-NonlocalGoto.c Fri Apr 25 13:44:30 2003 @@ -1,3 +1,7 @@ + +/* It is unlikely that LLVM will ever support nested functions, but if it does, + here is a testcase. */ + main() { __label__ l; From lattner at cs.uiuc.edu Fri Apr 25 14:50:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Apr 25 14:50:01 2003 Subject: [llvm-commits] CVS: llvm/test/Regression/CFrontend/2002-07-29-Casts.c Message-ID: <200304251949.OAA23969@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/CFrontend: 2002-07-29-Casts.c updated: 1.1 -> 1.2 --- Log message: Fix bugs in testcase --- Diffs of the changes: Index: llvm/test/Regression/CFrontend/2002-07-29-Casts.c diff -u llvm/test/Regression/CFrontend/2002-07-29-Casts.c:1.1 llvm/test/Regression/CFrontend/2002-07-29-Casts.c:1.2 --- llvm/test/Regression/CFrontend/2002-07-29-Casts.c:1.1 Mon Jul 29 14:39:52 2002 +++ llvm/test/Regression/CFrontend/2002-07-29-Casts.c Fri Apr 25 14:49:36 2003 @@ -7,8 +7,8 @@ { char c1; short s1, ssf1, ssd1; - uint8_t ubs0; - int8_t bs0; + unsigned char ubs0; + signed char bs0; unsigned char ubc0, uc2; unsigned short us2, usf1, usd1; int ic3, is3, sif1, sid1; @@ -24,8 +24,8 @@ s1 = (short) (argc >= 3)? atoi(argv[2]) : -769; /* 0xf7ff = -769 */ ubc0 = (unsigned char) c1; /* 100 = 'd' */ - ubs0 = (uint8_t) s1; /* 0xff = 255 */ - bs0 = (int8_t) s1; /* 0xff = -1 */ + ubs0 = (unsigned char) s1; /* 0xff = 255 */ + bs0 = (signed char) s1; /* 0xff = -1 */ uc2 = (unsigned char) c1; /* 100 = 'd' */ us2 = (unsigned short) s1; /* 0xf7ff = 64767 */ From lattner at cs.uiuc.edu Fri Apr 25 15:10:04 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Apr 25 15:10:04 2003 Subject: [llvm-commits] CVS: llvm/test/Regression/Assembler/2003-04-25-UnresolvedGlobalReference.ll Message-ID: <200304252009.PAA25801@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Assembler: 2003-04-25-UnresolvedGlobalReference.ll added (r1.1) --- Log message: New testcase --- Diffs of the changes: Index: llvm/test/Regression/Assembler/2003-04-25-UnresolvedGlobalReference.ll diff -c /dev/null llvm/test/Regression/Assembler/2003-04-25-UnresolvedGlobalReference.ll:1.1 *** /dev/null Fri Apr 25 15:09:27 2003 --- llvm/test/Regression/Assembler/2003-04-25-UnresolvedGlobalReference.ll Fri Apr 25 15:09:17 2003 *************** *** 0 **** --- 1,7 ---- + ; There should be absolutely no problem with this testcase. + + implementation + + int %test(int %arg1, int %arg2) { + ret int cast (int (int, int)* %test to int) + } From lattner at cs.uiuc.edu Fri Apr 25 16:48:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Apr 25 16:48:01 2003 Subject: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y Message-ID: <200304252147.QAA26549@apoc.cs.uiuc.edu> Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.108 -> 1.109 --- Log message: Fix bug: Assembler/2003-04-25-UnresolvedGlobalReference.ll --- Diffs of the changes: Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.108 llvm/lib/AsmParser/llvmAsmParser.y:1.109 --- llvm/lib/AsmParser/llvmAsmParser.y:1.108 Tue Apr 22 14:07:06 2003 +++ llvm/lib/AsmParser/llvmAsmParser.y Fri Apr 25 16:47:33 2003 @@ -156,6 +156,25 @@ // resolve the branches now... ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues); + // Make sure to resolve any constant expr references that might exist within + // the function we just declared itself. + ValID FID; + if (CurrentFunction->hasName()) { + FID = ValID::create((char*)CurrentFunction->getName().c_str()); + } else { + unsigned Slot = CurrentFunction->getType()->getUniqueID(); + assert(CurModule.Values.size() > Slot && "Function not inserted?"); + // Figure out which slot number if is... + for (unsigned i = 0; ; ++i) { + assert(i < CurModule.Values[Slot].size() && "Function not found!"); + if (CurModule.Values[Slot][i] == CurrentFunction) { + FID = ValID::create((int)i); + break; + } + } + } + CurModule.DeclareNewGlobalValue(CurrentFunction, FID); + Values.clear(); // Clear out function local definitions Types.clear(); CurrentFunction = 0; @@ -964,7 +983,6 @@ Value *V = getValNonImprovising(Ty, $2); CurMeth.CurrentFunction = SavedCurFn; - // If this is an initializer for a constant pointer, which is referencing a // (currently) undefined variable, create a stub now that shall be replaced From lattner at cs.uiuc.edu Fri Apr 25 17:00:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Apr 25 17:00:01 2003 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/InstSelectSimple.cpp Message-ID: <200304252159.QAA26807@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: InstSelectSimple.cpp updated: 1.89 -> 1.90 --- Log message: Fix bogus assert --- Diffs of the changes: Index: llvm/lib/Target/X86/InstSelectSimple.cpp diff -u llvm/lib/Target/X86/InstSelectSimple.cpp:1.89 llvm/lib/Target/X86/InstSelectSimple.cpp:1.90 --- llvm/lib/Target/X86/InstSelectSimple.cpp:1.89 Wed Apr 23 12:57:48 2003 +++ llvm/lib/Target/X86/InstSelectSimple.cpp Fri Apr 25 16:58:54 2003 @@ -28,8 +28,8 @@ #include /// BMI - A special BuildMI variant that takes an iterator to insert the -/// instruction at as well as a basic block. -/// this is the version for when you have a destination register in mind. +/// instruction at as well as a basic block. This is the version for when you +/// have a destination register in mind. inline static MachineInstrBuilder BMI(MachineBasicBlock *MBB, MachineBasicBlock::iterator &I, MachineOpCode Opcode, @@ -47,7 +47,7 @@ MachineBasicBlock::iterator &I, MachineOpCode Opcode, unsigned NumOperands) { - assert(I > MBB->begin() && I <= MBB->end() && "Bad iterator!"); + assert(I >= MBB->begin() && I <= MBB->end() && "Bad iterator!"); MachineInstr *MI = new MachineInstr(Opcode, NumOperands, true, true); I = MBB->insert(I, MI)+1; return MachineInstrBuilder(MI); From lattner at cs.uiuc.edu Fri Apr 25 17:09:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Apr 25 17:09:01 2003 Subject: [llvm-commits] CVS: llvm/tools/bugpoint/ExtractFunction.cpp Message-ID: <200304252208.RAA27958@apoc.cs.uiuc.edu> Changes in directory llvm/tools/bugpoint: ExtractFunction.cpp updated: 1.6 -> 1.7 --- Log message: Add options to disable simplification with passes, in case one of them crashes --- Diffs of the changes: Index: llvm/tools/bugpoint/ExtractFunction.cpp diff -u llvm/tools/bugpoint/ExtractFunction.cpp:1.6 llvm/tools/bugpoint/ExtractFunction.cpp:1.7 --- llvm/tools/bugpoint/ExtractFunction.cpp:1.6 Thu Apr 24 19:52:30 2003 +++ llvm/tools/bugpoint/ExtractFunction.cpp Fri Apr 25 17:08:12 2003 @@ -14,6 +14,19 @@ #include "llvm/Analysis/Verifier.h" #include "llvm/Type.h" #include "llvm/Constant.h" +#include "Support/CommandLine.h" + +namespace { + cl::opt + NoADCE("disable-adce", + cl::desc("Do not use the -adce pass to reduce testcases")); + cl::opt + NoDCE ("disable-dce", + cl::desc("Do not use the -dce pass to reduce testcases")); + cl::opt + NoSCFG("disable-simplifycfg", + cl::desc("Do not use the -simplifycfg pass to reduce testcases")); +} /// deleteInstructionFromProgram - This method clones the current Program and /// deletes the specified instruction from the cloned module. It then runs a @@ -46,12 +59,12 @@ // Spiff up the output a little bit. PassManager Passes; - if (Simplification > 2) + if (Simplification > 2 && !NoADCE) Passes.add(createAggressiveDCEPass()); // Remove dead code... //Passes.add(createInstructionCombiningPass()); - if (Simplification > 1) + if (Simplification > 1 && !NoDCE) Passes.add(createDeadCodeEliminationPass()); - if (Simplification) + if (Simplification && !NoSCFG) Passes.add(createCFGSimplificationPass()); // Delete dead control flow Passes.add(createVerifierPass()); From lattner at cs.uiuc.edu Fri Apr 25 17:54:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Apr 25 17:54:01 2003 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/ADCE/2003-04-25-PHIPostDominateProblem.ll Message-ID: <200304252253.RAA30532@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/ADCE: 2003-04-25-PHIPostDominateProblem.ll added (r1.1) --- Log message: New testcase --- Diffs of the changes: Index: llvm/test/Regression/Transforms/ADCE/2003-04-25-PHIPostDominateProblem.ll diff -c /dev/null llvm/test/Regression/Transforms/ADCE/2003-04-25-PHIPostDominateProblem.ll:1.1 *** /dev/null Fri Apr 25 17:53:23 2003 --- llvm/test/Regression/Transforms/ADCE/2003-04-25-PHIPostDominateProblem.ll Fri Apr 25 17:53:12 2003 *************** *** 0 **** --- 1,37 ---- + ; THis testcase caused an assertion failure because a PHI node did not have + ; entries for it's postdominator. But I think this can only happen when the + ; PHI node is dead, so we just avoid patching up dead PHI nodes. + + ; RUN: as < %s | opt -adce + + target endian = little + target pointersize = 32 + + implementation ; Functions: + + void %dead_test8() { + entry: ; No predecessors! + br label %loopentry + + loopentry: ; preds = %entry, %endif + %k.1 = phi int [ %k.0, %endif ], [ 0, %entry ] ; [#uses=1] + br bool false, label %no_exit, label %return + + no_exit: ; preds = %loopentry + br bool false, label %then, label %else + + then: ; preds = %no_exit + br label %endif + + else: ; preds = %no_exit + %dec = add int %k.1, -1 ; [#uses=1] + br label %endif + + endif: ; preds = %else, %then + %k.0 = phi int [ %dec, %else ], [ 0, %then ] ; [#uses=1] + store int 2, int* null + br label %loopentry + + return: ; preds = %loopentry + ret void + } From lattner at cs.uiuc.edu Fri Apr 25 17:54:07 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Apr 25 17:54:07 2003 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/ADCE.cpp Message-ID: <200304252253.RAA30541@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: ADCE.cpp updated: 1.51 -> 1.52 --- Log message: Fix bug: ADCE/2003-04-25-PHIPostDominateProblem.ll --- Diffs of the changes: Index: llvm/lib/Transforms/Scalar/ADCE.cpp diff -u llvm/lib/Transforms/Scalar/ADCE.cpp:1.51 llvm/lib/Transforms/Scalar/ADCE.cpp:1.52 --- llvm/lib/Transforms/Scalar/ADCE.cpp:1.51 Wed Apr 23 11:37:42 2003 +++ llvm/lib/Transforms/Scalar/ADCE.cpp Fri Apr 25 17:53:27 2003 @@ -310,15 +310,16 @@ // should be identical to the incoming values for LastDead. // for (BasicBlock::iterator II = NextAlive->begin(); - PHINode *PN = dyn_cast(II); ++II) { - // Get the incoming value for LastDead... - int OldIdx = PN->getBasicBlockIndex(LastDead); - assert(OldIdx != -1 && "LastDead is not a pred of NextAlive!"); - Value *InVal = PN->getIncomingValue(OldIdx); - - // Add an incoming value for BB now... - PN->addIncoming(InVal, BB); - } + PHINode *PN = dyn_cast(II); ++II) + if (LiveSet.count(PN)) { // Only modify live phi nodes + // Get the incoming value for LastDead... + int OldIdx = PN->getBasicBlockIndex(LastDead); + assert(OldIdx != -1 &&"LastDead is not a pred of NextAlive!"); + Value *InVal = PN->getIncomingValue(OldIdx); + + // Add an incoming value for BB now... + PN->addIncoming(InVal, BB); + } } } From lattner at cs.uiuc.edu Fri Apr 25 18:15:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Apr 25 18:15:01 2003 Subject: [llvm-commits] CVS: llvm/lib/VMCore/BasicBlock.cpp Message-ID: <200304252314.SAA01102@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: BasicBlock.cpp updated: 1.30 -> 1.31 --- Log message: Fix a bug that occurred when removing the last predecessor INTO an infinite loop --- Diffs of the changes: Index: llvm/lib/VMCore/BasicBlock.cpp diff -u llvm/lib/VMCore/BasicBlock.cpp:1.30 llvm/lib/VMCore/BasicBlock.cpp:1.31 --- llvm/lib/VMCore/BasicBlock.cpp:1.30 Wed Apr 23 11:37:45 2003 +++ llvm/lib/VMCore/BasicBlock.cpp Fri Apr 25 18:14:19 2003 @@ -186,7 +186,11 @@ // If the PHI _HAD_ two uses, replace PHI node with its now *single* value if (max_idx == 2) { - PN->replaceAllUsesWith(PN->getOperand(0)); + if (PN->getOperand(0) != PN) + PN->replaceAllUsesWith(PN->getOperand(0)); + else + // We are left with an infinite loop with no entries: kill the PHI. + PN->replaceAllUsesWith(Constant::getNullValue(PN->getType())); getInstList().pop_front(); // Remove the PHI node } From lattner at cs.uiuc.edu Fri Apr 25 18:28:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Apr 25 18:28:01 2003 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/LoopPreheaders/2003-04-25-AssertFail.ll Message-ID: <200304252327.SAA02980@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/LoopPreheaders: 2003-04-25-AssertFail.ll added (r1.1) --- Log message: New testcase that crashes preheaders --- Diffs of the changes: Index: llvm/test/Regression/Transforms/LoopPreheaders/2003-04-25-AssertFail.ll diff -c /dev/null llvm/test/Regression/Transforms/LoopPreheaders/2003-04-25-AssertFail.ll:1.1 *** /dev/null Fri Apr 25 18:27:02 2003 --- llvm/test/Regression/Transforms/LoopPreheaders/2003-04-25-AssertFail.ll Fri Apr 25 18:26:52 2003 *************** *** 0 **** --- 1,22 ---- + ; RUN: as < %s | opt -preheaders + + implementation ; Functions: + + int %yylex() { ; No predecessors! + br label %loopentry.0 + + loopentry.0: ; preds = %0, %yy_find_action, %else.4 + br label %loopexit.2 + + loopexit.2: ; preds = %loopentry.0, %else.4, %loopexit.2 + br bool false, label %loopexit.2, label %else.4 + + yy_find_action: ; preds = %loopexit.2, %else.4 + br label %else.4 + + else.4: ; preds = %yy_find_action + switch uint 0, label %loopexit.2 [ + uint 2, label %yy_find_action + uint 0, label %loopentry.0 + ] + } From lattner at cs.uiuc.edu Fri Apr 25 18:40:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Apr 25 18:40:01 2003 Subject: [llvm-commits] CVS: llvm/include/llvm/Support/CFG.h Message-ID: <200304252339.SAA03198@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Support: CFG.h updated: 1.8 -> 1.9 --- Log message: Remove long-dead obsolete cruft --- Diffs of the changes: Index: llvm/include/llvm/Support/CFG.h diff -u llvm/include/llvm/Support/CFG.h:1.8 llvm/include/llvm/Support/CFG.h:1.9 --- llvm/include/llvm/Support/CFG.h:1.8 Thu Oct 10 17:31:31 2002 +++ llvm/include/llvm/Support/CFG.h Fri Apr 25 18:39:08 2003 @@ -26,15 +26,7 @@ typedef PredIterator<_Ptr,_USE_iterator> _Self; typedef typename super::pointer pointer; - inline void advancePastConstants() { - // TODO: This is bad - // Loop to ignore constant pool references - while (It != BB->use_end() && !isa(*It)) - ++It; - } - inline PredIterator(_Ptr *bb) : BB(bb), It(bb->use_begin()) { - advancePastConstants(); } inline PredIterator(_Ptr *bb, bool) : BB(bb), It(bb->use_end()) {} @@ -43,13 +35,13 @@ inline pointer operator*() const { assert(It != BB->use_end() && "pred_iterator out of range!"); - return cast(*It)->getParent(); + return cast(*It)->getParent(); } inline pointer *operator->() const { return &(operator*()); } inline _Self& operator++() { // Preincrement assert(It != BB->use_end() && "pred_iterator out of range!"); - ++It; advancePastConstants(); + ++It; return *this; } From lattner at cs.uiuc.edu Sat Apr 26 12:39:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Apr 26 12:39:01 2003 Subject: [llvm-commits] CVS: llvm/include/llvm/Support/CFG.h Message-ID: <200304261738.MAA15592@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Support: CFG.h updated: 1.9 -> 1.10 --- Log message: Revert last checkin. Note that PHI nodes can use basic blocks also! --- Diffs of the changes: Index: llvm/include/llvm/Support/CFG.h diff -u llvm/include/llvm/Support/CFG.h:1.9 llvm/include/llvm/Support/CFG.h:1.10 --- llvm/include/llvm/Support/CFG.h:1.9 Fri Apr 25 18:39:08 2003 +++ llvm/include/llvm/Support/CFG.h Sat Apr 26 12:38:26 2003 @@ -26,7 +26,14 @@ typedef PredIterator<_Ptr,_USE_iterator> _Self; typedef typename super::pointer pointer; + inline void advancePastConstants() { + // Loop to ignore non terminator uses (for example PHI nodes)... + while (It != BB->use_end() && !isa(*It)) + ++It; + } + inline PredIterator(_Ptr *bb) : BB(bb), It(bb->use_begin()) { + advancePastConstants(); } inline PredIterator(_Ptr *bb, bool) : BB(bb), It(bb->use_end()) {} @@ -41,7 +48,7 @@ inline _Self& operator++() { // Preincrement assert(It != BB->use_end() && "pred_iterator out of range!"); - ++It; + ++It; advancePastConstants(); return *this; } From lattner at cs.uiuc.edu Sat Apr 26 12:45:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Apr 26 12:45:01 2003 Subject: [llvm-commits] CVS: llvm/test/Regression/CBackend/2002-10-15-OpaqueTypeProblem.ll Message-ID: <200304261744.MAA16347@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/CBackend: 2002-10-15-OpaqueTypeProblem.ll updated: 1.1 -> 1.2 --- Log message: Whoever checked this testcase in apparently never tested it. --- Diffs of the changes: Index: llvm/test/Regression/CBackend/2002-10-15-OpaqueTypeProblem.ll diff -u llvm/test/Regression/CBackend/2002-10-15-OpaqueTypeProblem.ll:1.1 llvm/test/Regression/CBackend/2002-10-15-OpaqueTypeProblem.ll:1.2 --- llvm/test/Regression/CBackend/2002-10-15-OpaqueTypeProblem.ll:1.1 Tue Oct 15 19:08:08 2002 +++ llvm/test/Regression/CBackend/2002-10-15-OpaqueTypeProblem.ll Sat Apr 26 12:44:17 2003 @@ -1,4 +1,5 @@ -struct Comm; -typedef struct Comm* MPI_Comm; -MPI_Comm* thing; + %MPI_Comm = type %struct.Comm* + %struct.Comm = type opaque +%thing = global %MPI_Comm* null ; <%MPI_Comm**> [#uses=0] +implementation ; Functions: From lattner at cs.uiuc.edu Sat Apr 26 14:35:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Apr 26 14:35:01 2003 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/LoopPreheaders/2003-04-25-AssertFail.ll Message-ID: <200304261934.OAA17091@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/LoopPreheaders: 2003-04-25-AssertFail.ll updated: 1.1 -> 1.2 --- Log message: Add comment to testcase --- Diffs of the changes: Index: llvm/test/Regression/Transforms/LoopPreheaders/2003-04-25-AssertFail.ll diff -u llvm/test/Regression/Transforms/LoopPreheaders/2003-04-25-AssertFail.ll:1.1 llvm/test/Regression/Transforms/LoopPreheaders/2003-04-25-AssertFail.ll:1.2 --- llvm/test/Regression/Transforms/LoopPreheaders/2003-04-25-AssertFail.ll:1.1 Fri Apr 25 18:26:52 2003 +++ llvm/test/Regression/Transforms/LoopPreheaders/2003-04-25-AssertFail.ll Sat Apr 26 14:33:51 2003 @@ -1,3 +1,6 @@ +; This testcase exposed a problem with the loop identification pass (LoopInfo). +; Basically, it was incorrectly calculating the loop nesting information. +; ; RUN: as < %s | opt -preheaders implementation ; Functions: From lattner at cs.uiuc.edu Sat Apr 26 14:35:07 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Apr 26 14:35:07 2003 Subject: [llvm-commits] CVS: llvm/lib/Analysis/LoopInfo.cpp Message-ID: <200304261934.OAA17288@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: LoopInfo.cpp updated: 1.35 -> 1.36 --- Log message: Fix bug: LoopPreheaders/2003-04-25-AssertFail.ll --- Diffs of the changes: Index: llvm/lib/Analysis/LoopInfo.cpp diff -u llvm/lib/Analysis/LoopInfo.cpp:1.35 llvm/lib/Analysis/LoopInfo.cpp:1.36 --- llvm/lib/Analysis/LoopInfo.cpp:1.35 Fri Feb 28 10:54:45 2003 +++ llvm/lib/Analysis/LoopInfo.cpp Sat Apr 26 14:34:18 2003 @@ -128,12 +128,12 @@ std::vector TodoStack; // Scan the predecessors of BB, checking to see if BB dominates any of - // them. + // them. This identifies backedges which target this node... for (pred_iterator I = pred_begin(BB), E = pred_end(BB); I != E; ++I) if (DS.dominates(BB, *I)) // If BB dominates it's predecessor... TodoStack.push_back(*I); - if (TodoStack.empty()) return 0; // Doesn't dominate any predecessors... + if (TodoStack.empty()) return 0; // No backedges to this block... // Create a new loop to represent this basic block... Loop *L = new Loop(BB); @@ -144,8 +144,29 @@ TodoStack.pop_back(); if (!L->contains(X)) { // As of yet unprocessed?? + // Check to see if this block already belongs to a loop. If this occurs + // then we have a case where a loop that is supposed to be a child of the + // current loop was processed before the current loop. When this occurs, + // this child loop gets added to a part of the current loop, making it a + // sibling to the current loop. We have to reparent this loop. + if (Loop *SubLoop = const_cast(getLoopFor(X))) + if (SubLoop->getHeader() == X && X != BB) { + // Remove the subloop from it's current parent... + assert(SubLoop->ParentLoop && SubLoop->ParentLoop != L); + Loop *SLP = SubLoop->ParentLoop; // SubLoopParent + std::vector::iterator I = + std::find(SLP->SubLoops.begin(), SLP->SubLoops.end(), SubLoop); + assert(I != SLP->SubLoops.end() && "SubLoop not a child of parent?"); + SLP->SubLoops.erase(I); // Remove from parent... + + // Add the subloop to THIS loop... + SubLoop->ParentLoop = L; + L->SubLoops.push_back(SubLoop); + } + + // Normal case, add the block to our loop... L->Blocks.push_back(X); - + // Add all of the predecessors of X to the end of the work stack... TodoStack.insert(TodoStack.end(), pred_begin(X), pred_end(X)); } From lattner at cs.uiuc.edu Sat Apr 26 14:37:00 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Apr 26 14:37:00 2003 Subject: [llvm-commits] CVS: llvm/www/docs/ChrisNotes.txt Message-ID: <200304261936.OAA17373@apoc.cs.uiuc.edu> Changes in directory llvm/www/docs: ChrisNotes.txt updated: 1.28 -> 1.29 --- Log message: Switch insns actually DO work. --- Diffs of the changes: Index: llvm/www/docs/ChrisNotes.txt diff -u llvm/www/docs/ChrisNotes.txt:1.28 llvm/www/docs/ChrisNotes.txt:1.29 --- llvm/www/docs/ChrisNotes.txt:1.28 Tue Sep 24 11:15:36 2002 +++ llvm/www/docs/ChrisNotes.txt Sat Apr 26 14:36:06 2003 @@ -1,14 +1,11 @@ * Rewrite the llvm parser/lexer in http://www.antlr.org when time permits. They actually do C++. Imagine that. -* pred/succ iterators on basic blocks don't handle switch statements correctly * Need a way to attach bytecode block info at various levels of asm code. * Recognize and save comments in assembly and bytecode format * Encode line number table in bytecode (like #line), optional table * Encode negative relative offsets in the bytecode file -* Implement switch to switch on a constant pool array of type: - [{ label, int }] or [label] (lookup vs index switch) * Apparently bison has a %pure_parser option. Maybe useful for AsmParser * Implement the following derived types: From lattner at cs.uiuc.edu Sat Apr 26 14:45:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Apr 26 14:45:01 2003 Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/SparcInstrInfo.cpp SparcInstrSelection.cpp Message-ID: <200304261944.OAA17418@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/Sparc: SparcInstrInfo.cpp updated: 1.39 -> 1.40 SparcInstrSelection.cpp updated: 1.87 -> 1.88 --- Log message: IntegerRegSize is always 8 for sparc --- Diffs of the changes: Index: llvm/lib/Target/Sparc/SparcInstrInfo.cpp diff -u llvm/lib/Target/Sparc/SparcInstrInfo.cpp:1.39 llvm/lib/Target/Sparc/SparcInstrInfo.cpp:1.40 --- llvm/lib/Target/Sparc/SparcInstrInfo.cpp:1.39 Fri Apr 25 00:23:09 2003 +++ llvm/lib/Target/Sparc/SparcInstrInfo.cpp Sat Apr 26 14:44:35 2003 @@ -441,9 +441,7 @@ uint64_t C = GetConstantValueAsUnsignedInt(val, isValidConstant); assert(isValidConstant && "Unrecognized constant"); - if (opSize > destSize || - (val->getType()->isSigned() - && destSize < target.getTargetData().getIntegerRegSize())) + if (opSize > destSize || (val->getType()->isSigned() && destSize < 8)) { // operand is larger than dest, // OR both are equal but smaller than the full register size // AND operand is signed, so it may have extra sign bits: Index: llvm/lib/Target/Sparc/SparcInstrSelection.cpp diff -u llvm/lib/Target/Sparc/SparcInstrSelection.cpp:1.87 llvm/lib/Target/Sparc/SparcInstrSelection.cpp:1.88 --- llvm/lib/Target/Sparc/SparcInstrSelection.cpp:1.87 Fri Apr 25 00:23:10 2003 +++ llvm/lib/Target/Sparc/SparcInstrSelection.cpp Sat Apr 26 14:44:35 2003 @@ -758,8 +758,7 @@ // Value* shiftDest = destVal; unsigned opSize = target.getTargetData().getTypeSize(argVal1->getType()); - if ((shiftOpCode == SLL || shiftOpCode == SLLX) - && opSize < target.getTargetData().getIntegerRegSize()) + if ((shiftOpCode == SLL || shiftOpCode == SLLX) && opSize < 8) { // put SLL result into a temporary shiftDest = new TmpInstruction(argVal1, optArgVal2, "sllTmp"); mcfi.addTemp(shiftDest); @@ -2305,7 +2304,7 @@ .addReg(dest, MOTy::Def); mvec.push_back(M); } - else if (destSize < target.getTargetData().getIntegerRegSize()) + else if (destSize < 8) assert(0 && "Unsupported type size: 32 < size < 64 bits"); } } From lattner at cs.uiuc.edu Sat Apr 26 14:48:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Apr 26 14:48:01 2003 Subject: [llvm-commits] CVS: llvm/lib/Target/TargetMachine.cpp Message-ID: <200304261947.OAA17451@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target: TargetMachine.cpp updated: 1.17 -> 1.18 --- Log message: The promotion rules are the same for all targets, they are set by the C standard. --- Diffs of the changes: Index: llvm/lib/Target/TargetMachine.cpp diff -u llvm/lib/Target/TargetMachine.cpp:1.17 llvm/lib/Target/TargetMachine.cpp:1.18 --- llvm/lib/Target/TargetMachine.cpp:1.17 Sat Dec 28 20:50:31 2002 +++ llvm/lib/Target/TargetMachine.cpp Sat Apr 26 14:47:36 2003 @@ -20,16 +20,10 @@ // function TargetMachine::findOptimalStorageSize // -// Purpose: -// This default implementation assumes that all sub-word data items use -// space equal to optSizeForSubWordData, and all other primitive data -// items use space according to the type. -// unsigned TargetMachine::findOptimalStorageSize(const Type *Ty) const { - // Round integral values smaller than SubWordDataSize up to SubWordDataSize - if (Ty->isIntegral() && - Ty->getPrimitiveSize() < DataLayout.getSubWordDataSize()) - return DataLayout.getSubWordDataSize(); + // All integer types smaller than ints promote to 4 byte integers. + if (Ty->isIntegral() && Ty->getPrimitiveSize() < 4) + return 4; return DataLayout.getTypeSize(Ty); } From lattner at cs.uiuc.edu Sat Apr 26 15:12:00 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Apr 26 15:12:00 2003 Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/Sparc.cpp Message-ID: <200304262011.PAA18870@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/Sparc: Sparc.cpp updated: 1.61 -> 1.62 --- Log message: Remove two fields from TargetData which are target specific. --- Diffs of the changes: Index: llvm/lib/Target/Sparc/Sparc.cpp diff -u llvm/lib/Target/Sparc/Sparc.cpp:1.61 llvm/lib/Target/Sparc/Sparc.cpp:1.62 --- llvm/lib/Target/Sparc/Sparc.cpp:1.61 Wed Apr 23 11:24:53 2003 +++ llvm/lib/Target/Sparc/Sparc.cpp Sat Apr 26 15:11:01 2003 @@ -129,7 +129,7 @@ //--------------------------------------------------------------------------- UltraSparc::UltraSparc() - : TargetMachine("UltraSparc-Native", false, 4), + : TargetMachine("UltraSparc-Native", false), schedInfo(*this), regInfo(*this), frameInfo(*this), From lattner at cs.uiuc.edu Sat Apr 26 15:12:06 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Apr 26 15:12:06 2003 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86TargetMachine.cpp Message-ID: <200304262011.PAA18877@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86TargetMachine.cpp updated: 1.16 -> 1.17 --- Log message: Remove two fields from TargetData which are target specific. --- Diffs of the changes: Index: llvm/lib/Target/X86/X86TargetMachine.cpp diff -u llvm/lib/Target/X86/X86TargetMachine.cpp:1.16 llvm/lib/Target/X86/X86TargetMachine.cpp:1.17 --- llvm/lib/Target/X86/X86TargetMachine.cpp:1.16 Fri Apr 25 01:05:57 2003 +++ llvm/lib/Target/X86/X86TargetMachine.cpp Sat Apr 26 15:11:04 2003 @@ -35,7 +35,6 @@ X86TargetMachine::X86TargetMachine(unsigned Config) : TargetMachine("X86", (Config & TM::EndianMask) == TM::LittleEndian, - 1, 4, (Config & TM::PtrSizeMask) == TM::PtrSize64 ? 8 : 4, (Config & TM::PtrSizeMask) == TM::PtrSize64 ? 8 : 4, (Config & TM::PtrSizeMask) == TM::PtrSize64 ? 8 : 4), From lattner at cs.uiuc.edu Sat Apr 26 15:12:11 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Apr 26 15:12:11 2003 Subject: [llvm-commits] CVS: llvm/tools/llc/llc.cpp Message-ID: <200304262011.PAA18884@apoc.cs.uiuc.edu> Changes in directory llvm/tools/llc: llc.cpp updated: 1.69 -> 1.70 --- Log message: Remove two fields from TargetData which are target specific. --- Diffs of the changes: Index: llvm/tools/llc/llc.cpp diff -u llvm/tools/llc/llc.cpp:1.69 llvm/tools/llc/llc.cpp:1.70 --- llvm/tools/llc/llc.cpp:1.69 Fri Apr 25 01:06:13 2003 +++ llvm/tools/llc/llc.cpp Sat Apr 26 15:11:06 2003 @@ -184,8 +184,7 @@ // Build up all of the passes that we want to do to the module... PassManager Passes; - Passes.add(new TargetData("llc", TD.isLittleEndian(), TD.getSubWordDataSize(), - TD.getIntegerRegSize(), TD.getPointerSize(), + Passes.add(new TargetData("llc", TD.isLittleEndian(), TD.getPointerSize(), TD.getPointerAlignment(), TD.getDoubleAlignment())); // Create a new optimization pass for each one specified on the command line From lattner at cs.uiuc.edu Sat Apr 26 15:12:17 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Apr 26 15:12:17 2003 Subject: [llvm-commits] CVS: llvm/tools/lli/Interpreter/Interpreter.cpp Message-ID: <200304262011.PAA18891@apoc.cs.uiuc.edu> Changes in directory llvm/tools/lli/Interpreter: Interpreter.cpp updated: 1.2 -> 1.3 --- Log message: Remove two fields from TargetData which are target specific. --- Diffs of the changes: Index: llvm/tools/lli/Interpreter/Interpreter.cpp diff -u llvm/tools/lli/Interpreter/Interpreter.cpp:1.2 llvm/tools/lli/Interpreter/Interpreter.cpp:1.3 --- llvm/tools/lli/Interpreter/Interpreter.cpp:1.2 Fri Apr 25 01:15:05 2003 +++ llvm/tools/lli/Interpreter/Interpreter.cpp Sat Apr 26 15:11:09 2003 @@ -25,7 +25,6 @@ bool DebugMode, bool TraceMode) : ExecutionEngine(M), ExitCode(0), Debug(DebugMode), Trace(TraceMode), CurFrame(-1), TD("lli", (Config & TM::EndianMask) == TM::LittleEndian, - 1, 4, (Config & TM::PtrSizeMask) == TM::PtrSize64 ? 8 : 4, (Config & TM::PtrSizeMask) == TM::PtrSize64 ? 8 : 4, (Config & TM::PtrSizeMask) == TM::PtrSize64 ? 8 : 4) { From lattner at cs.uiuc.edu Sat Apr 26 15:12:22 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Apr 26 15:12:22 2003 Subject: [llvm-commits] CVS: llvm/include/llvm/Target/TargetData.h TargetMachine.h Message-ID: <200304262011.PAA18898@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Target: TargetData.h updated: 1.16 -> 1.17 TargetMachine.h updated: 1.29 -> 1.30 --- Log message: Remove two fields from TargetData which are target specific. --- Diffs of the changes: Index: llvm/include/llvm/Target/TargetData.h diff -u llvm/include/llvm/Target/TargetData.h:1.16 llvm/include/llvm/Target/TargetData.h:1.17 --- llvm/include/llvm/Target/TargetData.h:1.16 Fri Apr 25 00:23:27 2003 +++ llvm/include/llvm/Target/TargetData.h Sat Apr 26 15:10:54 2003 @@ -24,7 +24,6 @@ class TargetData : public ImmutablePass { bool LittleEndian; // Defaults to false - unsigned char SubWordDataSize; // Defaults to 1 byte (no rounding up) unsigned char ByteAlignment; // Defaults to 1 bytes unsigned char ShortAlignment; // Defaults to 2 bytes unsigned char IntAlignment; // Defaults to 4 bytes @@ -32,7 +31,6 @@ unsigned char FloatAlignment; // Defaults to 4 bytes unsigned char DoubleAlignment; // Defaults to 8 bytes unsigned char PointerSize; // Defaults to 8 bytes - unsigned char IntegerRegSize; // Defaults to PointerSize = 8 bytes unsigned char PointerAlignment; // Defaults to 8 bytes AnnotationID AID; // AID for structure layout annotation @@ -40,8 +38,6 @@ public: TargetData(const std::string &TargetName = "", bool LittleEndian = false, - unsigned char SubWordDataSize = 1, - unsigned char IntRegSize = 8, unsigned char PtrSize = 8, unsigned char PtrAl = 8, unsigned char DoubleAl = 8, unsigned char FloatAl = 4, unsigned char LongAl = 8, @@ -55,7 +51,6 @@ bool isBigEndian() const { return !LittleEndian; } /// Target alignment constraints - unsigned char getSubWordDataSize() const { return SubWordDataSize; } unsigned char getByteAlignment() const { return ByteAlignment; } unsigned char getShortAlignment() const { return ShortAlignment; } unsigned char getIntAlignment() const { return IntAlignment; } @@ -64,7 +59,6 @@ unsigned char getDoubleAlignment() const { return DoubleAlignment; } unsigned char getPointerAlignment() const { return PointerAlignment; } unsigned char getPointerSize() const { return PointerSize; } - unsigned char getIntegerRegSize() const { return IntegerRegSize; } AnnotationID getStructLayoutAID() const { return AID; } // getTypeSize - Return the number of bytes neccesary to hold the specified Index: llvm/include/llvm/Target/TargetMachine.h diff -u llvm/include/llvm/Target/TargetMachine.h:1.29 llvm/include/llvm/Target/TargetMachine.h:1.30 --- llvm/include/llvm/Target/TargetMachine.h:1.29 Sun Jan 12 18:21:32 2003 +++ llvm/include/llvm/Target/TargetMachine.h Sat Apr 26 15:10:54 2003 @@ -35,12 +35,11 @@ protected: TargetMachine(const std::string &name, // Can only create subclasses... bool LittleEndian = false, - unsigned char SubWordSize = 1, unsigned char IntRegSize = 8, unsigned char PtrSize = 8, unsigned char PtrAl = 8, unsigned char DoubleAl = 8, unsigned char FloatAl = 4, unsigned char LongAl = 8, unsigned char IntAl = 4, unsigned char ShortAl = 2, unsigned char ByteAl = 1) - : Name(name), DataLayout(name, LittleEndian, SubWordSize, IntRegSize, + : Name(name), DataLayout(name, LittleEndian, PtrSize, PtrAl, DoubleAl, FloatAl, LongAl, IntAl, ShortAl, ByteAl) {} public: From lattner at cs.uiuc.edu Sat Apr 26 15:12:28 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Apr 26 15:12:28 2003 Subject: [llvm-commits] CVS: llvm/lib/Target/TargetData.cpp Message-ID: <200304262011.PAA18904@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target: TargetData.cpp updated: 1.30 -> 1.31 --- Log message: Remove two fields from TargetData which are target specific. --- Diffs of the changes: Index: llvm/lib/Target/TargetData.cpp diff -u llvm/lib/Target/TargetData.cpp:1.30 llvm/lib/Target/TargetData.cpp:1.31 --- llvm/lib/Target/TargetData.cpp:1.30 Fri Apr 25 01:06:43 2003 +++ llvm/lib/Target/TargetData.cpp Sat Apr 26 15:10:58 2003 @@ -82,8 +82,7 @@ //===----------------------------------------------------------------------===// TargetData::TargetData(const std::string &TargetName, - bool isLittleEndian, unsigned char SubWordSize, - unsigned char IntRegSize, unsigned char PtrSize, + bool isLittleEndian, unsigned char PtrSize, unsigned char PtrAl, unsigned char DoubleAl, unsigned char FloatAl, unsigned char LongAl, unsigned char IntAl, unsigned char ShortAl, @@ -99,8 +98,6 @@ "ERROR: Tool did not specify a target data to use!"); LittleEndian = isLittleEndian; - SubWordDataSize = SubWordSize; - IntegerRegSize = IntRegSize; PointerSize = PtrSize; PointerAlignment = PtrAl; DoubleAlignment = DoubleAl; @@ -118,8 +115,6 @@ AnnotationManager::registerAnnotationFactory(AID, TypeAnFactory, this); LittleEndian = M->isLittleEndian(); - SubWordDataSize = 1; - IntegerRegSize = 8; PointerSize = M->has32BitPointers() ? 4 : 8; PointerAlignment = PointerSize; DoubleAlignment = PointerSize; From lattner at cs.uiuc.edu Sat Apr 26 15:30:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Apr 26 15:30:01 2003 Subject: [llvm-commits] CVS: llvm/test/Regression/Linker/2003-04-26-NullPtrLinkProblem.ll Message-ID: <200304262029.PAA22542@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Linker: 2003-04-26-NullPtrLinkProblem.ll added (r1.1) --- Log message: New testcase distilled from a problem identified by sumant --- Diffs of the changes: Index: llvm/test/Regression/Linker/2003-04-26-NullPtrLinkProblem.ll diff -c /dev/null llvm/test/Regression/Linker/2003-04-26-NullPtrLinkProblem.ll:1.1 *** /dev/null Sat Apr 26 15:29:19 2003 --- llvm/test/Regression/Linker/2003-04-26-NullPtrLinkProblem.ll Sat Apr 26 15:29:09 2003 *************** *** 0 **** --- 1,19 ---- + ; This one fails because the LLVM runtime is allowing two null pointers of + ; the same type to be created! + + ; RUN: echo "%T = type int" | as > Output/%s.2.bc + ; RUN: as < %s > Output/%s.1.bc + ; RUN: link Output/%s.[12].bc + + %T = type opaque + + declare %T* %create() + + implementation + + void %test() { + %X = call %T* %create() + %v = seteq %T* %X, null + ret void + } + From lattner at cs.uiuc.edu Sat Apr 26 15:45:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Apr 26 15:45:01 2003 Subject: [llvm-commits] CVS: llvm/test/Programs/SingleSource/UnitTests/2002-12-13-MishaTest.c Message-ID: <200304262044.PAA23299@apoc.cs.uiuc.edu> Changes in directory llvm/test/Programs/SingleSource/UnitTests: 2002-12-13-MishaTest.c added (r1.1) --- Log message: Check in an old testcase for a problem reported by misha --- Diffs of the changes: Index: llvm/test/Programs/SingleSource/UnitTests/2002-12-13-MishaTest.c diff -c /dev/null llvm/test/Programs/SingleSource/UnitTests/2002-12-13-MishaTest.c:1.1 *** /dev/null Sat Apr 26 15:44:42 2003 --- llvm/test/Programs/SingleSource/UnitTests/2002-12-13-MishaTest.c Sat Apr 26 15:44:32 2003 *************** *** 0 **** --- 1,25 ---- + + #include + sum(to, from, count) + short *to, *from; + short count; + { + int i; + for (i = 0; i != count; ++i) + *to += *from++; + } + + #define NUM 2 + int main() { + short Array[NUM]; + short Sum = 0; + int i; + + for (i = 0; i != NUM; ++i) + Array[i] = i; + + sum(&Sum, Array, NUM); + + printf("Sum is %d\n", Sum); + return 0; + } From lattner at cs.uiuc.edu Sun Apr 27 17:57:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun Apr 27 17:57:01 2003 Subject: [llvm-commits] CVS: llvm/lib/Transforms/LevelRaise.cpp Message-ID: <200304272256.RAA16354@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms: LevelRaise.cpp updated: 1.77 -> 1.78 --- Log message: Avoid naming things exactly the same --- Diffs of the changes: Index: llvm/lib/Transforms/LevelRaise.cpp diff -u llvm/lib/Transforms/LevelRaise.cpp:1.77 llvm/lib/Transforms/LevelRaise.cpp:1.78 --- llvm/lib/Transforms/LevelRaise.cpp:1.77 Thu Apr 24 13:25:27 2003 +++ llvm/lib/Transforms/LevelRaise.cpp Sun Apr 27 17:55:56 2003 @@ -505,7 +505,7 @@ // Create a new cast, inserting it right before the function call... CastInst *NewCast = new CastInst(CI->getCalledValue(), NewPFunTy, - CI->getCalledValue()->getName(), CI); + CI->getCalledValue()->getName()+"_c",CI); // Create a new call instruction... CallInst *NewCall = new CallInst(NewCast, From lattner at cs.uiuc.edu Sun Apr 27 20:24:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun Apr 27 20:24:01 2003 Subject: [llvm-commits] CVS: llvm/lib/Transforms/IPO/FunctionResolution.cpp Message-ID: <200304280123.UAA19652@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/IPO: FunctionResolution.cpp updated: 1.25 -> 1.26 --- Log message: Fix several bugs: * Warnings were emitted all of the time and were really annoying * Functions could not be resolved unless they had external linkage. Linkonce linkage was not allowed * ConstantPointerRef's were not handled when linking functions we now actually handle cast (CPR) to X -> cast (NewCPR) to X --- Diffs of the changes: Index: llvm/lib/Transforms/IPO/FunctionResolution.cpp diff -u llvm/lib/Transforms/IPO/FunctionResolution.cpp:1.25 llvm/lib/Transforms/IPO/FunctionResolution.cpp:1.26 --- llvm/lib/Transforms/IPO/FunctionResolution.cpp:1.25 Fri Apr 18 19:15:27 2003 +++ llvm/lib/Transforms/IPO/FunctionResolution.cpp Sun Apr 27 20:23:29 2003 @@ -128,7 +128,7 @@ const FunctionType *OldMT = Old->getFunctionType(); const FunctionType *ConcreteMT = Concrete->getFunctionType(); - if (OldMT->getParamTypes().size() < ConcreteMT->getParamTypes().size() && + if (OldMT->getParamTypes().size() > ConcreteMT->getParamTypes().size() && !ConcreteMT->isVarArg()) if (!Old->use_empty()) { std::cerr << "WARNING: Linking function '" << Old->getName() @@ -155,14 +155,13 @@ return Changed; } - // Attempt to convert all of the uses of the old function to the - // concrete form of the function. If there is a use of the fn that - // we don't understand here we punt to avoid making a bad - // transformation. + // Attempt to convert all of the uses of the old function to the concrete + // form of the function. If there is a use of the fn that we don't + // understand here we punt to avoid making a bad transformation. // - // At this point, we know that the return values are the same for - // our two functions and that the Old function has no varargs fns - // specified. In otherwords it's just (...) + // At this point, we know that the return values are the same for our two + // functions and that the Old function has no varargs fns specified. In + // otherwords it's just (...) // for (unsigned i = 0; i < Old->use_size(); ) { User *U = *(Old->use_begin()+i); @@ -183,6 +182,18 @@ << " argument or something!" << CI; ++i; } + } else if (ConstantPointerRef *CPR = dyn_cast(U)) { + if (CPR->use_size() == 1 && isa(CPR->use_back()) && + cast(CPR->use_back())->getOpcode() == + Instruction::Cast) { + ConstantExpr *CE = cast(CPR->use_back()); + Constant *NewCPR = ConstantPointerRef::get(Concrete); + CE->replaceAllUsesWith(ConstantExpr::getCast(NewCPR,CE->getType())); + CPR->destroyConstant(); + } else { + std::cerr << "Cannot convert use of function: " << CPR << "\n"; + ++i; + } } else { std::cerr << "Cannot convert use of function: " << U << "\n"; ++i; @@ -337,7 +348,7 @@ GlobalValue *GV = cast(PI->second); assert(PI->first == GV->getName() && "Global name and symbol table do not agree!"); - if (GV->hasExternalLinkage()) // Only resolve decls to external fns + if (!GV->hasInternalLinkage()) // Only resolve decls to external fns Globals[PI->first].push_back(GV); } } From lattner at cs.uiuc.edu Sun Apr 27 20:26:00 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun Apr 27 20:26:00 2003 Subject: [llvm-commits] CVS: llvm/lib/Transforms/LevelRaise.cpp Message-ID: <200304280125.UAA19666@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms: LevelRaise.cpp updated: 1.78 -> 1.79 --- Log message: Create constant expression casts instead of constant instructions if possible --- Diffs of the changes: Index: llvm/lib/Transforms/LevelRaise.cpp diff -u llvm/lib/Transforms/LevelRaise.cpp:1.78 llvm/lib/Transforms/LevelRaise.cpp:1.79 --- llvm/lib/Transforms/LevelRaise.cpp:1.78 Sun Apr 27 17:55:56 2003 +++ llvm/lib/Transforms/LevelRaise.cpp Sun Apr 27 20:25:38 2003 @@ -504,8 +504,18 @@ PointerType *NewPFunTy = PointerType::get(NewFT); // Create a new cast, inserting it right before the function call... - CastInst *NewCast = new CastInst(CI->getCalledValue(), NewPFunTy, - CI->getCalledValue()->getName()+"_c",CI); + Value *NewCast; + Constant *ConstantCallSrc = 0; + if (Constant *CS = dyn_cast(CI->getCalledValue())) + ConstantCallSrc = CS; + else if (GlobalValue *GV = dyn_cast(CI->getCalledValue())) + ConstantCallSrc = ConstantPointerRef::get(GV); + + if (ConstantCallSrc) + NewCast = ConstantExpr::getCast(ConstantCallSrc, NewPFunTy); + else + NewCast = new CastInst(CI->getCalledValue(), NewPFunTy, + CI->getCalledValue()->getName()+"_c",CI); // Create a new call instruction... CallInst *NewCall = new CallInst(NewCast, From lattner at cs.uiuc.edu Sun Apr 27 22:30:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun Apr 27 22:30:01 2003 Subject: [llvm-commits] CVS: llvm/tools/llc/llc.cpp Message-ID: <200304280329.WAA22361@apoc.cs.uiuc.edu> Changes in directory llvm/tools/llc: llc.cpp updated: 1.70 -> 1.71 --- Log message: Add a new option to disable stripping of bytecode files --- Diffs of the changes: Index: llvm/tools/llc/llc.cpp diff -u llvm/tools/llc/llc.cpp:1.70 llvm/tools/llc/llc.cpp:1.71 --- llvm/tools/llc/llc.cpp:1.70 Sat Apr 26 15:11:06 2003 +++ llvm/tools/llc/llc.cpp Sun Apr 27 22:28:56 2003 @@ -50,6 +50,10 @@ static cl::opt Force("f", cl::desc("Overwrite output files")); static cl::opt +DisableStrip("disable-strip", + cl::desc("Do not strip the LLVM bytecode included in the executable")); + +static cl::opt DumpAsm("d", cl::desc("Print bytecode before native code generation"), cl::Hidden); @@ -227,7 +231,8 @@ Passes.add(new PrintFunctionPass("Code after xformations: \n", &std::cerr)); // Strip all of the symbols from the bytecode so that it will be smaller... - Passes.add(createSymbolStrippingPass()); + if (!DisableStrip) + Passes.add(createSymbolStrippingPass()); // Figure out where we are going to send the output... std::ostream *Out = 0; From lattner at cs.uiuc.edu Sun Apr 27 22:41:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun Apr 27 22:41:01 2003 Subject: [llvm-commits] CVS: llvm/www/www-index.html Message-ID: <200304280340.WAA07731@tank.cs.uiuc.edu> Changes in directory llvm/www: www-index.html updated: 1.19 -> 1.20 --- Log message: Fix grammar --- Diffs of the changes: Index: llvm/www/www-index.html diff -u llvm/www/www-index.html:1.19 llvm/www/www-index.html:1.20 --- llvm/www/www-index.html:1.19 Fri Mar 7 12:04:06 2003 +++ llvm/www/www-index.html Sun Apr 27 22:40:20 2003 @@ -222,7 +222,7 @@ - Added a new open projects - page, listing possibly improvements to LLVM. + page, listing some desired improvements to LLVM. Jan 22nd, 2003 From lattner at cs.uiuc.edu Sun Apr 27 22:43:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun Apr 27 22:43:01 2003 Subject: [llvm-commits] CVS: llvm/www/docs/OpenProjects.html Message-ID: <200304280342.WAA07769@tank.cs.uiuc.edu> Changes in directory llvm/www/docs: OpenProjects.html updated: 1.4 -> 1.5 --- Log message: Remove implemented project, add a new one --- Diffs of the changes: Index: llvm/www/docs/OpenProjects.html diff -u llvm/www/docs/OpenProjects.html:1.4 llvm/www/docs/OpenProjects.html:1.5 --- llvm/www/docs/OpenProjects.html:1.4 Sat Mar 8 17:59:05 2003 +++ llvm/www/docs/OpenProjects.html Sun Apr 27 22:42:31 2003 @@ -149,9 +149,7 @@
  1. Improve the efficiency of the bytecode loader/writer, allow streaming lazy loading of functions from the bytecode (for use by the JIT, for example)
    -
  2. Rework the PassManager -
  3. Do not encode zero intializers for large arrays into the bytecode - +
  4. Rework the PassManager to be more flexible
  5. Some transformations and analyses only work on reducible flow graphs. It would be nice to have a transformation which could be "required" by these passes which makes irreducible graphs reducible. This can easily be accomplished @@ -262,6 +260,8 @@
  6. Implement a global register allocator
  7. Implement a better instruction selector
  8. Implement a static compiler in addition to the JIT (easy project) +
  9. Implement support for the "switch" instruction without requiring the + lower-switches pass.