From lattner at cs.uiuc.edu Mon Jun 28 01:32:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Jun 28 01:32:01 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/Passes.h Message-ID: <200406280631.BAA23148@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis: Passes.h added (r1.1) --- Log message: Add new header --- Diffs of the changes: (+29 -0) Index: llvm/include/llvm/Analysis/Passes.h diff -c /dev/null llvm/include/llvm/Analysis/Passes.h:1.1 *** /dev/null Mon Jun 28 01:31:36 2004 --- llvm/include/llvm/Analysis/Passes.h Mon Jun 28 01:31:26 2004 *************** *** 0 **** --- 1,29 ---- + //===-- llvm/Analysis/Passes.h - Constructors for analyses ------*- C++ -*-===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by the LLVM research group and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // This header file defines prototypes for accessor functions that expose passes + // in the analysis libraries. + // + //===----------------------------------------------------------------------===// + + #ifndef LLVM_ANALYSIS_PASSES_H + #define LLVM_ANALYSIS_PASSES_H + + namespace llvm { + class Pass; + + //===--------------------------------------------------------------------===// + // + // createGlobalsModRefPass - This function creates and returns an instance of + // the GlobalsModRef alias analysis pass. + // + Pass *createGlobalsModRefPass(); + } + + #endif From lattner at cs.uiuc.edu Mon Jun 28 01:34:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Jun 28 01:34:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Analysis/IPA/GlobalsModRef.cpp Message-ID: <200406280633.BAA23166@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/IPA: GlobalsModRef.cpp added (r1.1) --- Log message: Initial checkin of a simple mod/ref analysis for global variables. This is still overly conservative and uses very simple data structures, but it is a start, and allows elimination of a lot of loads. --- Diffs of the changes: (+327 -0) Index: llvm/lib/Analysis/IPA/GlobalsModRef.cpp diff -c /dev/null llvm/lib/Analysis/IPA/GlobalsModRef.cpp:1.1 *** /dev/null Mon Jun 28 01:33:23 2004 --- llvm/lib/Analysis/IPA/GlobalsModRef.cpp Mon Jun 28 01:33:13 2004 *************** *** 0 **** --- 1,327 ---- + //===- GlobalsModRef.cpp - Simple Mod/Ref Analysis for Globals ------------===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by the LLVM research group and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // This simple pass provides alias and mod/ref information for global values + // that do not have their address taken. For this simple (but very common) + // case, we can provide pretty accurate and useful information. + // + //===----------------------------------------------------------------------===// + + #define DEBUG_TYPE "globalsmodref" + #include "llvm/Analysis/Passes.h" + #include "llvm/Module.h" + #include "llvm/Pass.h" + #include "llvm/Instructions.h" + #include "llvm/Constants.h" + #include "llvm/Analysis/AliasAnalysis.h" + #include "llvm/Analysis/CallGraph.h" + #include "Support/Debug.h" + #include "Support/Statistic.h" + #include "Support/SCCIterator.h" + #include + using namespace llvm; + + namespace { + Statistic<> + NumNonAddrTakenGlobalVars("globalsmodref-aa", + "Number of global vars without address taken"); + Statistic<> + NumNonAddrTakenFunctions("globalsmodref-aa", + "Number of functions without address taken"); + + class GlobalsModRef : public Pass, public AliasAnalysis { + /// ModRefFns - One instance of this record is kept for each global without + /// its address taken. + struct ModRefFns { + /// RefFns/ModFns - Sets of functions that and write globals. + std::set RefFns, ModFns; + }; + + /// NonAddressTakenGlobals - A map of globals that do not have their + /// addresses taken to their record. + std::map NonAddressTakenGlobals; + + /// FunctionInfo - For each function, keep track of what globals are + /// modified or read. + std::map, unsigned> FunctionInfo; + + public: + bool run(Module &M) { + InitializeAliasAnalysis(this); // set up super class + AnalyzeGlobals(M); // find non-addr taken globals + AnalyzeCallGraph(getAnalysis(), M); // Propagate on CG + return false; + } + + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AliasAnalysis::getAnalysisUsage(AU); + AU.addRequired(); + AU.setPreservesAll(); // Does not transform code + } + + //------------------------------------------------ + // Implement the AliasAnalysis API + // + AliasResult alias(const Value *V1, unsigned V1Size, + const Value *V2, unsigned V2Size); + ModRefResult getModRefInfo(CallSite CS, Value *P, unsigned Size); + bool hasNoModRefInfoForCalls() const { return false; } + + virtual void deleteValue(Value *V); + virtual void copyValue(Value *From, Value *To); + + private: + void AnalyzeGlobals(Module &M); + void AnalyzeCallGraph(CallGraph &CG, Module &M); + bool AnalyzeUsesOfGlobal(Value *V, std::vector &Readers, + std::vector &Writers); + }; + + RegisterOpt X("globalsmodref-aa", + "Simple mod/ref analysis for globals"); + RegisterAnalysisGroup Y; + } + + Pass *llvm::createGlobalsModRefPass() { return new GlobalsModRef(); } + + + /// AnalyzeGlobalUses - Scan through the users of all of the internal + /// GlobalValue's in the program. If none of them have their "Address taken" + /// (really, their address passed to something nontrivial), record this fact, + /// and record the functions that they are used directly in. + void GlobalsModRef::AnalyzeGlobals(Module &M) { + std::vector Readers, Writers; + for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) + if (I->hasInternalLinkage()) { + if (!AnalyzeUsesOfGlobal(I, Readers, Writers)) { + // Remember that we are tracking this global, and the mod/ref fns + ModRefFns &E = NonAddressTakenGlobals[I]; + E.RefFns.insert(Readers.begin(), Readers.end()); + E.ModFns.insert(Writers.begin(), Writers.end()); + ++NumNonAddrTakenFunctions; + } + Readers.clear(); Writers.clear(); + } + + for (Module::giterator I = M.gbegin(), E = M.gend(); I != E; ++I) + // FIXME: it is kinda dumb to track aliasing properties for constant + // globals, it will never be particularly useful anyways, 'cause they can + // never be modified (and the optimizer knows this already)! + if (I->hasInternalLinkage()) { + if (!AnalyzeUsesOfGlobal(I, Readers, Writers)) { + // Remember that we are tracking this global, and the mod/ref fns + ModRefFns &E = NonAddressTakenGlobals[I]; + E.RefFns.insert(Readers.begin(), Readers.end()); + E.ModFns.insert(Writers.begin(), Writers.end()); + ++NumNonAddrTakenGlobalVars; + } + Readers.clear(); Writers.clear(); + } + } + + /// AnalyzeUsesOfGlobal - Look at all of the users of the specified global value + /// derived pointer. If this is used by anything complex (i.e., the address + /// escapes), return true. Also, while we are at it, keep track of those + /// functions that read and write to the value. + bool GlobalsModRef::AnalyzeUsesOfGlobal(Value *V, + std::vector &Readers, + std::vector &Writers) { + //if (!isa(V->getType())) return true; + + for (Value::use_iterator UI = V->use_begin(), E = V->use_end(); UI != E; ++UI) + if (LoadInst *LI = dyn_cast(*UI)) { + Readers.push_back(LI->getParent()->getParent()); + } else if (StoreInst *SI = dyn_cast(*UI)) { + if (V == SI->getOperand(0)) return true; // Storing the pointer + Writers.push_back(SI->getParent()->getParent()); + } else if (GetElementPtrInst *GEP = dyn_cast(*UI)) { + if (AnalyzeUsesOfGlobal(GEP, Readers, Writers)) return true; + } else if (CallInst *CI = dyn_cast(*UI)) { + // Make sure that this is just the function being called, not that it is + // passing into the function. + for (unsigned i = 1, e = CI->getNumOperands(); i != e; ++i) + if (CI->getOperand(i) == V) return true; + } else if (CallInst *CI = dyn_cast(*UI)) { + // Make sure that this is just the function being called, not that it is + // passing into the function. + for (unsigned i = 1, e = CI->getNumOperands(); i != e; ++i) + if (CI->getOperand(i) == V) return true; + } else if (InvokeInst *II = dyn_cast(*UI)) { + // Make sure that this is just the function being called, not that it is + // passing into the function. + for (unsigned i = 3, e = II->getNumOperands(); i != e; ++i) + if (II->getOperand(i) == V) return true; + } else if (ConstantExpr *CE = dyn_cast(*UI)) { + if (CE->getOpcode() == Instruction::GetElementPtr || + CE->getOpcode() == Instruction::Cast) { + if (AnalyzeUsesOfGlobal(CE, Readers, Writers)) + return true; + } else { + return true; + } + } else if (ConstantPointerRef *CPR = dyn_cast(*UI)) { + if (AnalyzeUsesOfGlobal(CPR, Readers, Writers)) return true; + } else { + return true; + } + return false; + } + + /// AnalyzeCallGraph - At this point, we know the functions where globals are + /// immediately stored to and read from. Propagate this information up the call + /// graph to all callers. + void GlobalsModRef::AnalyzeCallGraph(CallGraph &CG, Module &M) { + if (NonAddressTakenGlobals.empty()) return; // Don't bother, nothing to do. + + // Invert the NonAddressTakenGlobals map into the FunctionInfo map. + for (std::map::iterator I = + NonAddressTakenGlobals.begin(), E = NonAddressTakenGlobals.end(); + I != E; ++I) { + GlobalValue *GV = I->first; + ModRefFns &MRInfo = I->second; + for (std::set::iterator I = MRInfo.RefFns.begin(), + E = MRInfo.RefFns.begin(); I != E; ++I) + FunctionInfo[std::make_pair(*I, GV)] |= Ref; + MRInfo.RefFns.clear(); + for (std::set::iterator I = MRInfo.ModFns.begin(), + E = MRInfo.ModFns.begin(); I != E; ++I) + FunctionInfo[std::make_pair(*I, GV)] |= Mod; + MRInfo.ModFns.clear(); + } + + // We do a bottom-up SCC traversal of the call graph. In other words, we + // visit all callees before callers (leaf-first). + for (scc_iterator I = scc_begin(&CG), E = scc_end(&CG); + I != E; ++I) { + std::map ModRefProperties; + const std::vector &SCC = *I; + + // Collect the mod/ref properties due to called functions. + for (unsigned i = 0, e = SCC.size(); i != e; ++i) + for (CallGraphNode::iterator CI = SCC[i]->begin(), E = SCC[i]->end(); + CI != E; ++CI) { + if (Function *Callee = (*CI)->getFunction()) { + // Otherwise, combine the callee properties into our accumulated set. + std::map, unsigned>::iterator + CI = FunctionInfo.lower_bound(std::make_pair(Callee, + (GlobalValue*)0)); + for (;CI != FunctionInfo.end() && CI->first.first == Callee; ++CI) + ModRefProperties[CI->first.second] |= CI->second; + } else { + // For now assume that external functions could mod/ref anything, + // since they could call into an escaping function that mod/refs an + // internal. FIXME: We need better tracking! + for (std::map::iterator GI = + NonAddressTakenGlobals.begin(), + E = NonAddressTakenGlobals.end(); GI != E; ++GI) + ModRefProperties[GI->first] = ModRef; + goto Out; + } + } + Out: + // Set all functions in the CFG to have these properties. FIXME: it would + // be better to use union find to only store these properties once, + // PARTICULARLY if it's the universal set. + for (unsigned i = 0, e = SCC.size(); i != e; ++i) + if (Function *F = SCC[i]->getFunction()) { + for (std::map::iterator I = + ModRefProperties.begin(), E = ModRefProperties.end(); + I != E; ++I) + FunctionInfo[std::make_pair(F, I->first)] = I->second; + } + } + } + + + + /// getUnderlyingObject - This traverses the use chain to figure out what object + /// the specified value points to. If the value points to, or is derived from, + /// a global object, return it. + static const GlobalValue *getUnderlyingObject(const Value *V) { + //if (!isa(V->getType())) return 0; + + // If we are at some type of object... return it. + if (const GlobalValue *GV = dyn_cast(V)) return GV; + + // Traverse through different addressing mechanisms... + if (const Instruction *I = dyn_cast(V)) { + if (isa(I) || isa(I)) + return getUnderlyingObject(I->getOperand(0)); + } else if (const ConstantExpr *CE = dyn_cast(V)) { + if (CE->getOpcode() == Instruction::Cast || + CE->getOpcode() == Instruction::GetElementPtr) + return getUnderlyingObject(CE->getOperand(0)); + } else if (const ConstantPointerRef *CPR = dyn_cast(V)) { + return CPR->getValue(); + } + return 0; + } + + /// alias - If one of the pointers is to a global that we are tracking, and the + /// other is some random pointer, we know there cannot be an alias, because the + /// address of the global isn't taken. + AliasAnalysis::AliasResult + GlobalsModRef::alias(const Value *V1, unsigned V1Size, + const Value *V2, unsigned V2Size) { + GlobalValue *GV1 = const_cast(getUnderlyingObject(V1)); + GlobalValue *GV2 = const_cast(getUnderlyingObject(V2)); + + // If the global's address is taken, pretend we don't know it's a pointer to + // the global. + if (GV1 && !NonAddressTakenGlobals.count(GV1)) GV1 = 0; + if (GV2 && !NonAddressTakenGlobals.count(GV2)) GV2 = 0; + + if ((GV1 || GV2) && GV1 != GV2) + return NoAlias; + + return AliasAnalysis::alias(V1, V1Size, V2, V2Size); + } + + AliasAnalysis::ModRefResult + GlobalsModRef::getModRefInfo(CallSite CS, Value *P, unsigned Size) { + unsigned Known = ModRef; + + // If we are asking for mod/ref info of a direct call with a pointer to a + // global, return information if we have it. + if (GlobalValue *GV = const_cast(getUnderlyingObject(P))) + if (GV->hasInternalLinkage()) + if (Function *F = CS.getCalledFunction()) { + std::map, unsigned>::iterator + it = FunctionInfo.find(std::make_pair(F, GV)); + if (it != FunctionInfo.end()) + Known = it->second; + } + + if (Known == NoModRef) + return NoModRef; // No need to query other mod/ref analyses + return ModRefResult(Known & AliasAnalysis::getModRefInfo(CS, P, Size)); + } + + + //===----------------------------------------------------------------------===// + // Methods to update the analysis as a result of the client transformation. + // + void GlobalsModRef::deleteValue(Value *V) { + if (GlobalValue *GV = dyn_cast(V)) { + std::map::iterator I = + NonAddressTakenGlobals.find(GV); + if (I != NonAddressTakenGlobals.end()) + NonAddressTakenGlobals.erase(I); + } + } + + void GlobalsModRef::copyValue(Value *From, Value *To) { + if (GlobalValue *FromGV = dyn_cast(From)) + if (GlobalValue *ToGV = dyn_cast(To)) { + std::map::iterator I = + NonAddressTakenGlobals.find(FromGV); + if (I != NonAddressTakenGlobals.end()) + NonAddressTakenGlobals[ToGV] = I->second; + } + } From lattner at cs.uiuc.edu Mon Jun 28 12:12:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Jun 28 12:12:02 2004 Subject: [llvm-commits] CVS: llvm/docs/index.html Message-ID: <200406281711.MAA06255@apoc.cs.uiuc.edu> Changes in directory llvm/docs: index.html updated: 1.17 -> 1.18 --- Log message: Building the C FE is a user-level process --- Diffs of the changes: (+2 -2) Index: llvm/docs/index.html diff -u llvm/docs/index.html:1.17 llvm/docs/index.html:1.18 --- llvm/docs/index.html:1.17 Wed Jun 2 14:24:10 2004 +++ llvm/docs/index.html Mon Jun 28 12:11:10 2004 @@ -94,6 +94,7 @@
  • LLVM Command Guide
  • LLVM Assembly Language
  • LLVM Test Suite Guide
  • +
  • Building the LLVM C/C++ front-end
  • @@ -125,7 +126,6 @@
      -
    • Building the LLVM C/C++ front-end
    • Submitting a bug
    • Open projects
    • @@ -181,7 +181,7 @@ John Criswell
      LLVM Compiler Infrastructure
      - Last modified: $Date: 2004/06/02 19:24:10 $ + Last modified: $Date: 2004/06/28 17:11:10 $ From lattner at cs.uiuc.edu Mon Jun 28 12:13:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Jun 28 12:13:01 2004 Subject: [llvm-commits] CVS: llvm-www/releases/download.html Message-ID: <200406281712.MAA07129@apoc.cs.uiuc.edu> Changes in directory llvm-www/releases: download.html updated: 1.14 -> 1.15 --- Log message: Add a link to the CFE build instrs from the CFE download page --- Diffs of the changes: (+6 -2) Index: llvm-www/releases/download.html diff -u llvm-www/releases/download.html:1.14 llvm-www/releases/download.html:1.15 --- llvm-www/releases/download.html:1.14 Fri Mar 19 22:55:29 2004 +++ llvm-www/releases/download.html Mon Jun 28 12:11:52 2004 @@ -24,12 +24,16 @@
      -If you'd like access to the "latest and greatest" in LLVM development, please +

      If you'd like access to the "latest and greatest" in LLVM development, please see the instructions for accessing the LLVM CVS Repository. The major changes and improvements that CVS contains relative to the previous release are listed in the Release Notes for the -next release. +next release.

      + +

      Note that if you intend to build the LLVM C front-end from source, you must +follow the instructions in the "how to +build the C front-end" document.

      From lattner at cs.uiuc.edu Mon Jun 28 12:15:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Jun 28 12:15:01 2004 Subject: [llvm-commits] CVS: llvm/docs/GettingStarted.html Message-ID: <200406281714.MAA07821@apoc.cs.uiuc.edu> Changes in directory llvm/docs: GettingStarted.html updated: 1.61 -> 1.62 --- Log message: Add a link to the CFE build instrs next to the CFE download instructions --- Diffs of the changes: (+6 -2) Index: llvm/docs/GettingStarted.html diff -u llvm/docs/GettingStarted.html:1.61 llvm/docs/GettingStarted.html:1.62 --- llvm/docs/GettingStarted.html:1.61 Tue Jun 22 13:48:58 2004 +++ llvm/docs/GettingStarted.html Mon Jun 28 12:14:01 2004 @@ -457,9 +457,13 @@

      If you would like to get the GCC front end source code, you can also get it from the CVS repository:

      -
      cvs -z3 -d :pserver:anon at llvm-cvs.cs.uiuc.edu:/var/cvs/llvm co llvm-gcc
      +
      +  cvs -z3 -d :pserver:anon at llvm-cvs.cs.uiuc.edu:/var/cvs/llvm co llvm-gcc
       
      +

      Please note that you must follow these +instructions to successfully build the LLVM C front-end.

      + @@ -1227,7 +1231,7 @@ Chris Lattner
      The LLVM Compiler Infrastructure
      - Last modified: $Date: 2004/06/22 18:48:58 $ + Last modified: $Date: 2004/06/28 17:14:01 $ From lattner at cs.uiuc.edu Mon Jun 28 14:21:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Jun 28 14:21:02 2004 Subject: [llvm-commits] CVS: llvm/docs/AliasAnalysis.html Message-ID: <200406281919.OAA08801@apoc.cs.uiuc.edu> Changes in directory llvm/docs: AliasAnalysis.html updated: 1.20 -> 1.21 --- Log message: document new pass --- Diffs of the changes: (+22 -1) Index: llvm/docs/AliasAnalysis.html diff -u llvm/docs/AliasAnalysis.html:1.20 llvm/docs/AliasAnalysis.html:1.21 --- llvm/docs/AliasAnalysis.html:1.20 Mon Jun 21 17:52:48 2004 +++ llvm/docs/AliasAnalysis.html Mon Jun 28 14:19:47 2004 @@ -690,6 +690,27 @@ + + + +
      + +

      This pass implements a simple context-sensitive mod/ref and alias analysis +for internal global variables that don't "have their address taken". If a +global does not have its address taken, the pass knows that no pointers alias +the global. +

      + +

      The real power of this pass is that it provides context-sensitive mod/ref +information for call instructions. This allows the optimizer to know that +calls to a function do not clobber or read the value of the global, allowing +loads and stores to be eliminated.

      + +

      Note that this pass is somewhat limited in its scope (only support +non-address taken globals), but is very quick analysis.

      +
      @@ -916,7 +937,7 @@ Chris Lattner
      LLVM Compiler Infrastructure
      - Last modified: $Date: 2004/06/21 22:52:48 $ + Last modified: $Date: 2004/06/28 19:19:47 $ From lattner at cs.uiuc.edu Mon Jun 28 17:08:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Jun 28 17:08:01 2004 Subject: [llvm-commits] CVS: llvm-www/RandomBoxes/001-C++Compiler.html Message-ID: <200406282207.RAA09363@apoc.cs.uiuc.edu> Changes in directory llvm-www/RandomBoxes: 001-C++Compiler.html updated: 1.2 -> 1.3 --- Log message: Add a link --- Diffs of the changes: (+1 -1) Index: llvm-www/RandomBoxes/001-C++Compiler.html diff -u llvm-www/RandomBoxes/001-C++Compiler.html:1.2 llvm-www/RandomBoxes/001-C++Compiler.html:1.3 --- llvm-www/RandomBoxes/001-C++Compiler.html:1.2 Fri May 28 14:24:58 2004 +++ llvm-www/RandomBoxes/001-C++Compiler.html Mon Jun 28 17:07:13 2004 @@ -1,4 +1,4 @@ Did you know that LLVM has a GCC 3.4 compatible C++ front-end and a great optimizer? We find that LLVM is able to compile C++ into substantially better code than GCC (for example). Also, because LLVM code can be converted to C, -you can even use LLVM as a C++-to-C translator. +you can even use LLVM as a C++-to-C translator. From lattner at cs.uiuc.edu Mon Jun 28 19:15:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Jun 28 19:15:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/InstSelectSimple.cpp Message-ID: <200406290014.TAA12690@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: InstSelectSimple.cpp updated: 1.268 -> 1.269 --- Log message: Fix a regression from r1.224. In particular, codegen a cast from double -> float as a truncation by going through memory. This truncation was being skipped, which caused 175.vpr to fail after aggressive register promotion. --- Diffs of the changes: (+11 -4) Index: llvm/lib/Target/X86/InstSelectSimple.cpp diff -u llvm/lib/Target/X86/InstSelectSimple.cpp:1.268 llvm/lib/Target/X86/InstSelectSimple.cpp:1.269 --- llvm/lib/Target/X86/InstSelectSimple.cpp:1.268 Sun Jun 20 02:47:25 2004 +++ llvm/lib/Target/X86/InstSelectSimple.cpp Mon Jun 28 19:14:38 2004 @@ -405,8 +405,10 @@ BuildMI(*MBB, IPt, X86::MOV32ri, 1, Reg).addGlobalAddress(GV); return Reg; } else if (CastInst *CI = dyn_cast(V)) { - // Do not emit noop casts at all. - if (getClassB(CI->getType()) == getClassB(CI->getOperand(0)->getType())) + // Do not emit noop casts at all, unless it's a double -> float cast. + if (getClassB(CI->getType()) == getClassB(CI->getOperand(0)->getType()) && + (CI->getType() != Type::FloatTy || + CI->getOperand(0)->getType() != Type::DoubleTy)) return getReg(CI->getOperand(0), MBB, IPt); } else if (AllocaInst *AI = dyn_castFixedAlloca(V)) { // If the alloca address couldn't be folded into the instruction addressing, @@ -3116,8 +3118,13 @@ unsigned DestClass = getClassB(CI.getType()); // Noop casts are not emitted: getReg will return the source operand as the // register to use for any uses of the noop cast. - if (DestClass == SrcClass) - return; + if (DestClass == SrcClass) { + // The only detail in this plan is that casts from double -> float are + // truncating operations that we have to codegen through memory (despite + // the fact that the source/dest registers are the same class). + if (CI.getType() != Type::FloatTy || Op->getType() != Type::DoubleTy) + return; + } // If this is a cast from a 32-bit integer to a Long type, and the only uses // of the case are GEP instructions, then the cast does not need to be From gaeke at cs.uiuc.edu Mon Jun 28 23:45:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Mon Jun 28 23:45:01 2004 Subject: [llvm-commits] CVS: llvm-gcc/gcc/llvm-expand.c Message-ID: <200406290443.XAA12960@seraph.cs.uiuc.edu> Changes in directory llvm-gcc/gcc: llvm-expand.c updated: 1.45 -> 1.46 --- Log message: Fix PR389: http://llvm.cs.uiuc.edu/PR389 on sparc (also tested on ppc): don't assume that longs print out in their entirety as 8 hex digits. --- Diffs of the changes: (+4 -4) Index: llvm-gcc/gcc/llvm-expand.c diff -u llvm-gcc/gcc/llvm-expand.c:1.45 llvm-gcc/gcc/llvm-expand.c:1.46 --- llvm-gcc/gcc/llvm-expand.c:1.45 Sun Jun 20 13:59:59 2004 +++ llvm-gcc/gcc/llvm-expand.c Mon Jun 28 23:43:42 2004 @@ -5034,12 +5034,12 @@ *BufPtr++ = '0'; *BufPtr++ = 'x'; if (!(BYTES_BIG_ENDIAN)) { /* If little endian */ - sprintf(Buffer+2, "%08lX", RealArr[1]); - sprintf(Buffer+10, "%08lX", RealArr[0]); + sprintf(Buffer+2, "%08X", (int)RealArr[1]); + sprintf(Buffer+10, "%08X", (int)RealArr[0]); *(Buffer+18) = 0; /* Null terminate */ } else { - sprintf(Buffer+2, "%08lX", RealArr[0]); - sprintf(Buffer+10, "%08lX", RealArr[1]); + sprintf(Buffer+2, "%08X", (int)RealArr[0]); + sprintf(Buffer+10, "%08X", (int)RealArr[1]); *(Buffer+18) = 0; /* Null terminate */ } From lattner at cs.uiuc.edu Tue Jun 29 01:58:00 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Jun 29 01:58:00 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervals.cpp Message-ID: <200406290657.BAA17427@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveIntervals.cpp updated: 1.79 -> 1.80 --- Log message: Do not dereference end iterators. It hurts when you do that. --- Diffs of the changes: (+2 -3) Index: llvm/lib/CodeGen/LiveIntervals.cpp diff -u llvm/lib/CodeGen/LiveIntervals.cpp:1.79 llvm/lib/CodeGen/LiveIntervals.cpp:1.80 --- llvm/lib/CodeGen/LiveIntervals.cpp:1.79 Thu Jun 24 19:13:11 2004 +++ llvm/lib/CodeGen/LiveIntervals.cpp Tue Jun 29 01:56:51 2004 @@ -356,8 +356,7 @@ } // a variable can only be killed by subsequent instructions - do { - ++mi; + for (++mi; mi != e; ++mi) { baseIndex += InstrSlots::NUM; for (KillIter ki = lv_->killed_begin(mi), ke = lv_->killed_end(mi); ki != ke; ++ki) { @@ -367,7 +366,7 @@ goto exit; } } - } while (mi != e); + } exit: assert(start < end && "did not find end of interval?"); From lattner at cs.uiuc.edu Tue Jun 29 02:17:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Jun 29 02:17:01 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervals.cpp Message-ID: <200406290716.CAA18621@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveIntervals.cpp updated: 1.80 -> 1.81 --- Log message: In line with the previous patch, do not assert out if analyzing a dead basic block. --- Diffs of the changes: (+4 -1) Index: llvm/lib/CodeGen/LiveIntervals.cpp diff -u llvm/lib/CodeGen/LiveIntervals.cpp:1.80 llvm/lib/CodeGen/LiveIntervals.cpp:1.81 --- llvm/lib/CodeGen/LiveIntervals.cpp:1.80 Tue Jun 29 01:56:51 2004 +++ llvm/lib/CodeGen/LiveIntervals.cpp Tue Jun 29 02:16:23 2004 @@ -368,8 +368,11 @@ } } + // LiveVariables does not compute information for dead basic blocks. + DEBUG(std::cerr << "Didn't find the end of the interval. Must be in a " + "dead block."); + end = getDefIndex(start)+1; exit: - assert(start < end && "did not find end of interval?"); interval.addRange(start, end); DEBUG(std::cerr << '\n'); } From lattner at cs.uiuc.edu Tue Jun 29 02:18:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Jun 29 02:18:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86TargetMachine.cpp Message-ID: <200406290717.CAA18634@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86TargetMachine.cpp updated: 1.57 -> 1.58 --- Log message: I believe that the code generator now properly handles dead basic blocks. If not, this is a bug, and should be fixed. --- Diffs of the changes: (+0 -8) Index: llvm/lib/Target/X86/X86TargetMachine.cpp diff -u llvm/lib/Target/X86/X86TargetMachine.cpp:1.57 llvm/lib/Target/X86/X86TargetMachine.cpp:1.58 --- llvm/lib/Target/X86/X86TargetMachine.cpp:1.57 Sun Jun 20 02:49:54 2004 +++ llvm/lib/Target/X86/X86TargetMachine.cpp Tue Jun 29 02:17:12 2004 @@ -65,10 +65,6 @@ // FIXME: Implement the invoke/unwind instructions! PM.add(createLowerInvokePass()); - // FIXME: The code generator does not properly handle functions with - // unreachable basic blocks. - PM.add(createCFGSimplificationPass()); - // FIXME: Implement the switch instruction in the instruction selector! PM.add(createLowerSwitchPass()); @@ -126,10 +122,6 @@ // FIXME: Implement the invoke/unwind instructions! PM.add(createLowerInvokePass()); - // FIXME: The code generator does not properly handle functions with - // unreachable basic blocks. - PM.add(createCFGSimplificationPass()); - // FIXME: Implement the switch instruction in the instruction selector! PM.add(createLowerSwitchPass()); From vadve at cs.uiuc.edu Tue Jun 29 09:21:01 2004 From: vadve at cs.uiuc.edu (Vikram Adve) Date: Tue Jun 29 09:21:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Instrumentation/TraceBasicBlocks.cpp Message-ID: <200406291420.JAA13020@psmith.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Instrumentation: TraceBasicBlocks.cpp updated: 1.3 -> 1.4 --- Log message: Restoring this file. --- Diffs of the changes: (+76 -0) Index: llvm/lib/Transforms/Instrumentation/TraceBasicBlocks.cpp diff -u /dev/null llvm/lib/Transforms/Instrumentation/TraceBasicBlocks.cpp:1.4 --- /dev/null Tue Jun 29 09:20:38 2004 +++ llvm/lib/Transforms/Instrumentation/TraceBasicBlocks.cpp Tue Jun 29 09:20:27 2004 @@ -0,0 +1,76 @@ +//===- TraceBasicBlocks.cpp - Insert basic-block trace instrumentation ----===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This pass instruments the specified program with calls into a runtime +// library that cause it to output a trace of basic blocks as a side effect +// of normal execution. +// +//===----------------------------------------------------------------------===// + +#include "llvm/Constants.h" +#include "llvm/DerivedTypes.h" +#include "llvm/Module.h" +#include "llvm/Pass.h" +#include "llvm/Transforms/Utils/BasicBlockUtils.h" +#include "llvm/iOther.h" +#include "llvm/iMemory.h" +#include "llvm/iPHINode.h" +#include "ProfilingUtils.h" +#include "Support/Debug.h" +#include +using namespace llvm; + +namespace { + class TraceBasicBlocks : public Pass { + bool run(Module &M); + }; + + RegisterOpt X("trace-basic-blocks", + "Insert instrumentation for basic block tracing"); +} + +static void InsertInstrumentationCall (BasicBlock *BB, + const std::string FnName, + unsigned BBNumber) { + DEBUG (std::cerr << "InsertInstrumentationCall (\"" << BB->getName () + << "\", \"" << FnName << "\", " << BBNumber << ")\n"); + Module &M = *BB->getParent ()->getParent (); + Function *InstrFn = M.getOrInsertFunction (FnName, Type::VoidTy, + Type::UIntTy, 0); + std::vector Args (1); + Args[0] = ConstantUInt::get (Type::UIntTy, BBNumber); + + // Insert the call after any alloca or PHI instructions... + BasicBlock::iterator InsertPos = BB->begin(); + while (isa(InsertPos) || isa(InsertPos)) + ++InsertPos; + + Instruction *InstrCall = new CallInst (InstrFn, Args, "", InsertPos); +} + +bool TraceBasicBlocks::run(Module &M) { + Function *Main = M.getMainFunction(); + if (Main == 0) { + std::cerr << "WARNING: cannot insert basic-block trace instrumentation" + << " into a module with no main function!\n"; + return false; // No main, no instrumentation! + } + + unsigned BBNumber = 0; + for (Module::iterator F = M.begin(), E = M.end(); F != E; ++F) + for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) { + InsertInstrumentationCall (BB, "llvm_trace_basic_block", BBNumber); + ++BBNumber; + } + + // Add the initialization call to main. + InsertProfilingInitCall(Main, "llvm_start_basic_block_tracing"); + return true; +} + From alkis at cs.uiuc.edu Tue Jun 29 12:31:01 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Tue Jun 29 12:31:01 2004 Subject: [llvm-commits] CVS: llvm-java/tools/classdump/classdump.cpp Message-ID: <200406291730.MAA22626@zion.cs.uiuc.edu> Changes in directory llvm-java/tools/classdump: classdump.cpp updated: 1.8 -> 1.9 --- Log message: Make classdump utility take classfile as argument. --- Diffs of the changes: (+6 -2) Index: llvm-java/tools/classdump/classdump.cpp diff -u llvm-java/tools/classdump/classdump.cpp:1.8 llvm-java/tools/classdump/classdump.cpp:1.9 --- llvm-java/tools/classdump/classdump.cpp:1.8 Sat May 29 03:34:42 2004 +++ llvm-java/tools/classdump/classdump.cpp Tue Jun 29 12:29:52 2004 @@ -17,11 +17,15 @@ #include #include +#include #include #include using namespace llvm; +static cl::opt +InputFilename(cl::Positional, cl::desc(""), cl::init("-")); + int main(int argc, char* argv[]) { PrintStackTraceOnErrorSignal(); @@ -29,8 +33,8 @@ "class dump utility"); try { - std::auto_ptr cf( - Java::ClassFile::readClassFile(std::cin)); + std::ifstream in(InputFilename.c_str()); + std::auto_ptr cf(Java::ClassFile::readClassFile(in)); cf->dump(std::cout); } From brukman at cs.uiuc.edu Tue Jun 29 14:30:01 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Tue Jun 29 14:30:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/Printer.cpp Message-ID: <200406291929.OAA15467@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: Printer.cpp updated: 1.101 -> 1.102 --- Log message: Convert tabs to spaces. --- Diffs of the changes: (+17 -18) Index: llvm/lib/Target/X86/Printer.cpp diff -u llvm/lib/Target/X86/Printer.cpp:1.101 llvm/lib/Target/X86/Printer.cpp:1.102 --- llvm/lib/Target/X86/Printer.cpp:1.101 Thu Jun 24 19:13:11 2004 +++ llvm/lib/Target/X86/Printer.cpp Tue Jun 29 14:28:53 2004 @@ -102,8 +102,7 @@ bool printImplUsesAfter(const TargetInstrDescriptor &Desc, const bool LC); bool printImplDefsAfter(const TargetInstrDescriptor &Desc, const bool LC); void printMachineInstruction(const MachineInstr *MI); - void printOp(const MachineOperand &MO, - bool elideOffsetKeyword = false); + void printOp(const MachineOperand &MO, bool elideOffsetKeyword = false); void printMemReference(const MachineInstr *MI, unsigned Op); void printConstantPool(MachineConstantPool *MCP); bool runOnMachineFunction(MachineFunction &F); @@ -381,7 +380,7 @@ O << ".LBB" << CurrentFnName << "_" << I->getNumber() << ":\t# " << I->getBasicBlock()->getName() << "\n"; for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end(); - II != E; ++II) { + II != E; ++II) { // Print the assembly for the instruction. O << "\t"; printMachineInstruction(II); @@ -409,7 +408,7 @@ void Printer::printOp(const MachineOperand &MO, - bool elideOffsetKeyword /* = false */) { + bool elideOffsetKeyword /* = false */) { const MRegisterInfo &RI = *TM.getRegisterInfo(); switch (MO.getType()) { case MachineOperand::MO_VirtualRegister: @@ -506,10 +505,10 @@ if (DispVal) { if (NeedPlus) if (DispVal > 0) - O << " + "; + O << " + "; else { - O << " - "; - DispVal = -DispVal; + O << " - "; + DispVal = -DispVal; } O << DispVal; } @@ -673,9 +672,9 @@ // assert(MI->getNumOperands() == 0 || (MI->getNumOperands() == 1 && - (MI->getOperand(0).isMachineBasicBlock() || - MI->getOperand(0).isGlobalAddress() || - MI->getOperand(0).isExternalSymbol() || + (MI->getOperand(0).isMachineBasicBlock() || + MI->getOperand(0).isGlobalAddress() || + MI->getOperand(0).isExternalSymbol() || MI->getOperand(0).isImmediate())) && "Illegal raw instruction!"); O << TII.getName(MI->getOpcode()) << " "; @@ -707,9 +706,9 @@ (MI->getNumOperands() == 2 && (MI->getOperand(1).getVRegValueOrNull() || MI->getOperand(1).isImmediate() || - MI->getOperand(1).isRegister() || - MI->getOperand(1).isGlobalAddress() || - MI->getOperand(1).isExternalSymbol()))) && + MI->getOperand(1).isRegister() || + MI->getOperand(1).isGlobalAddress() || + MI->getOperand(1).isExternalSymbol()))) && "Illegal form for AddRegFrm instruction!"); unsigned Reg = MI->getOperand(0).getReg(); @@ -720,10 +719,10 @@ printOp(MI->getOperand(0)); if (MI->getNumOperands() == 2 && - (!MI->getOperand(1).isRegister() || - MI->getOperand(1).getVRegValueOrNull() || - MI->getOperand(1).isGlobalAddress() || - MI->getOperand(1).isExternalSymbol())) { + (!MI->getOperand(1).isRegister() || + MI->getOperand(1).getVRegValueOrNull() || + MI->getOperand(1).isGlobalAddress() || + MI->getOperand(1).isExternalSymbol())) { O << ", "; printOp(MI->getOperand(1)); } @@ -855,7 +854,7 @@ MI->getOperand(1).isRegister() || MI->getOperand(1).isImmediate())&& "Bad MRMSxR format!"); assert((MI->getNumOperands() < 3 || - (MI->getOperand(1).isRegister() && MI->getOperand(2).isImmediate())) && + (MI->getOperand(1).isRegister() && MI->getOperand(2).isImmediate())) && "Bad MRMSxR format!"); if (MI->getNumOperands() > 1 && MI->getOperand(1).isRegister() && From brukman at cs.uiuc.edu Tue Jun 29 14:44:01 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Tue Jun 29 14:44:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/Printer.cpp Message-ID: <200406291943.OAA15517@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: Printer.cpp updated: 1.102 -> 1.103 --- Log message: Fix associativity of parameters to assert(): now it actually makes sense. --- Diffs of the changes: (+3 -2) Index: llvm/lib/Target/X86/Printer.cpp diff -u llvm/lib/Target/X86/Printer.cpp:1.102 llvm/lib/Target/X86/Printer.cpp:1.103 --- llvm/lib/Target/X86/Printer.cpp:1.102 Tue Jun 29 14:28:53 2004 +++ llvm/lib/Target/X86/Printer.cpp Tue Jun 29 14:43:20 2004 @@ -823,8 +823,9 @@ // register reference for the mod/rm field, it's a memory reference. // assert(MI->getOperand(0).isRegister() && - (MI->getNumOperands() == 1+4 && isMem(MI, 1)) || -(MI->getNumOperands() == 2+4 && MI->getOperand(5).isImmediate() && isMem(MI, 1)) + ((MI->getNumOperands() == 1+4 && isMem(MI, 1)) || + (MI->getNumOperands() == 2+4 && MI->getOperand(5).isImmediate() && + isMem(MI, 1))) && "Bad format for MRMSrcMem!"); O << TII.getName(MI->getOpcode()) << " "; printOp(MI->getOperand(0)); From alkis at cs.uiuc.edu Tue Jun 29 14:50:02 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Tue Jun 29 14:50:02 2004 Subject: [llvm-commits] CVS: llvm-java/tools/class2llvm/class2llvm.cpp Message-ID: <200406291949.OAA16466@zion.cs.uiuc.edu> Changes in directory llvm-java/tools/class2llvm: class2llvm.cpp updated: 1.4 -> 1.5 --- Log message: Make class2llvm utility take classfile as argument. --- Diffs of the changes: (+6 -2) Index: llvm-java/tools/class2llvm/class2llvm.cpp diff -u llvm-java/tools/class2llvm/class2llvm.cpp:1.4 llvm-java/tools/class2llvm/class2llvm.cpp:1.5 --- llvm-java/tools/class2llvm/class2llvm.cpp:1.4 Sat May 29 03:34:42 2004 +++ llvm-java/tools/class2llvm/class2llvm.cpp Tue Jun 29 14:48:50 2004 @@ -20,11 +20,15 @@ #include #include +#include #include #include using namespace llvm; +static cl::opt +InputFilename(cl::Positional, cl::desc(""), cl::init("-")); + int main(int argc, char* argv[]) { PrintStackTraceOnErrorSignal(); @@ -32,8 +36,8 @@ "classfile to llvm utility"); try { - std::auto_ptr cf( - Java::ClassFile::readClassFile(std::cin)); + std::ifstream in(InputFilename.c_str()); + std::auto_ptr cf(Java::ClassFile::readClassFile(in)); Java::Compiler compiler; From alkis at cs.uiuc.edu Tue Jun 29 15:22:01 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Tue Jun 29 15:22:01 2004 Subject: [llvm-commits] CVS: llvm-java/lib/ClassFile/ClassFile.cpp Message-ID: <200406292021.PAA28798@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/ClassFile: ClassFile.cpp updated: 1.10 -> 1.11 --- Log message: java.lang.Object does not have a super class so don't throw an exception when we detect that it doesn't have one. --- Diffs of the changes: (+6 -3) Index: llvm-java/lib/ClassFile/ClassFile.cpp diff -u llvm-java/lib/ClassFile/ClassFile.cpp:1.10 llvm-java/lib/ClassFile/ClassFile.cpp:1.11 --- llvm-java/lib/ClassFile/ClassFile.cpp:1.10 Thu May 27 14:37:27 2004 +++ llvm-java/lib/ClassFile/ClassFile.cpp Tue Jun 29 15:21:34 2004 @@ -156,7 +156,7 @@ throw ClassFileSemanticError( "Representation of this class is not of type ConstantClass"); superClass_ = dynamic_cast(cPool_[readU2(is)]); - if (!superClass_) + if (!superClass_ && thisClass_->getName()->str() != "java/lang/Object") throw ClassFileSemanticError( "Representation of super class is not of type ConstantClass"); readClasses(interfaces_, cPool_, is); @@ -177,8 +177,11 @@ { os << "Minor version: " << getMinorVersion() << '\n' << "Major version: " << getMajorVersion() << "\n\n" - << "class " << *getThisClass() << " (" << *getSuperClass() << ")\n" - << "Flags:"; + << "class " << *getThisClass(); + if (getSuperClass()) + os << " (" << *getSuperClass() << ")\n"; + + os << "Flags:"; if (isPublic()) os << " public"; if (isFinal()) os << " final"; if (isSuper()) os << " super"; From alkis at cs.uiuc.edu Tue Jun 29 15:27:01 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Tue Jun 29 15:27:01 2004 Subject: [llvm-commits] CVS: llvm-java/lib/ClassFile/ClassFile.cpp Message-ID: <200406292026.PAA28854@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/ClassFile: ClassFile.cpp updated: 1.11 -> 1.12 --- Log message: Really read name index for fields. --- Diffs of the changes: (+1 -0) Index: llvm-java/lib/ClassFile/ClassFile.cpp diff -u llvm-java/lib/ClassFile/ClassFile.cpp:1.11 llvm-java/lib/ClassFile/ClassFile.cpp:1.12 --- llvm-java/lib/ClassFile/ClassFile.cpp:1.11 Tue Jun 29 15:21:34 2004 +++ llvm-java/lib/ClassFile/ClassFile.cpp Tue Jun 29 15:26:06 2004 @@ -393,6 +393,7 @@ Field::Field(const ConstantPool& cp, std::istream& is) { accessFlags_ = readU2(is); + name_ = dynamic_cast(cp[readU2(is)]); if (!name_) throw ClassFileSemanticError( "Representation of field name is not of type ConstantUtf8"); From gaeke at cs.uiuc.edu Tue Jun 29 16:57:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Tue Jun 29 16:57:01 2004 Subject: [llvm-commits] CVS: reopt/tools/dumptrace/Makefile dumptrace.cpp Message-ID: <200406292156.QAA20186@kain.cs.uiuc.edu> Changes in directory reopt/tools/dumptrace: Makefile added (r1.1) dumptrace.cpp added (r1.1) --- Log message: New trace dumping utility --- Diffs of the changes: (+188 -0) Index: reopt/tools/dumptrace/Makefile diff -c /dev/null reopt/tools/dumptrace/Makefile:1.1 *** /dev/null Tue Jun 29 16:56:25 2004 --- reopt/tools/dumptrace/Makefile Tue Jun 29 16:56:14 2004 *************** *** 0 **** --- 1,8 ---- + LEVEL = ../.. + TOOLNAME = dumptrace + LLVMLIBS = vmcore bcreader analysis.a transformutils.a support.a + + TOOLLINKOPTS = $(PLATFORMLIBDL) + + include $(LEVEL)/Makefile.common + Index: reopt/tools/dumptrace/dumptrace.cpp diff -c /dev/null reopt/tools/dumptrace/dumptrace.cpp:1.1 *** /dev/null Tue Jun 29 16:56:25 2004 --- reopt/tools/dumptrace/dumptrace.cpp Tue Jun 29 16:56:14 2004 *************** *** 0 **** --- 1,180 ---- + //===- dumptrace.cpp - Dump the BasicBlocks of a trace --------------------===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by the LLVM research group and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for + // details. + // + //===----------------------------------------------------------------------===// + // + // A simple program for testing TraceToFunction. This reads in a trace + // from a file, converts it to a function, and tries to verify the + // function. + // + //===----------------------------------------------------------------------===// + + #include "llvm/Analysis/Trace.h" + #include "llvm/Analysis/Verifier.h" + #include "llvm/Assembly/Writer.h" + #include "llvm/Bytecode/Reader.h" + #include "reopt/TraceToFunction.h" + #include "llvm/Module.h" + #include "Support/CommandLine.h" + #include "Support/FileUtilities.h" + #include "Support/StringExtras.h" + #include + #include + #include + #include + using namespace llvm; + + namespace { + cl::opt TraceFile("trace", + cl::desc("Name of file containing trace"), + cl::value_desc("traceFileName")); + cl::opt BytecodeFile("bc", + cl::desc("Name of file containing module"), + cl::value_desc("bytecodeFileName")); + }; + + //----------------------------------------------------------------------------// + + namespace { + cl::opt Quiet("q", cl::desc("Be quiet"), cl::init(false)); + }; + + /// getBasicBlockByNum - Returns the basic block in F whose index is + /// bbNum. + /// + BasicBlock *getBasicBlockByNum (Function *F, int bbNum) { + Function::iterator block = F->begin(); + std::advance (block, bbNum); + return block; + } + + /// ReadTraceFromFile - Given a module, read a trace for some function + /// in that module from the named file. Returns the Trace object, or a null + /// pointer (and sets ErrorStr) if there was an error. + /// + Trace *ReadTraceFromFile (Module *M, const std::string &filename, + std::string *ErrorStr) { + std::ifstream in (filename.c_str ()); + if (!in.good()) { + if (ErrorStr) + *ErrorStr = std::string("Can't open '") + filename + "': " + + strerror(errno); + return 0; + } + char functionName[160]; + in.getline(functionName, 160, '\n'); + Function *F = M->getNamedFunction (functionName); + if (!F) { + if (ErrorStr) + *ErrorStr = std::string("Function '") + functionName + + "' not found in module"; + return 0; + } + if (!Quiet) + std::cerr << "Function name: '" << functionName << "'\n" + << "Basic blocks: "; + std::vector vBB; + do { + int basicBlockNum; + in >> basicBlockNum; + if (!in.eof ()) { + if (!Quiet) std::cerr << basicBlockNum << " "; + vBB.push_back (getBasicBlockByNum (F, basicBlockNum)); + } + } while (!in.eof ()); + if (!Quiet) std::cerr << "\n"; + return new Trace (vBB); + } + + /// getBasicBlockIndex - Returns the index of BB in its parent function. + /// + int getBasicBlockIndex (BasicBlock *BB) { + int bbNum = 0; + Function *F = BB->getParent (); + Function::iterator block = F->begin(); + while (&*block != BB) { + ++block; + ++bbNum; + } + return bbNum; + } + + //----------------------------------------------------------------------------// + + int main (int argc, char **argv) { + // Get command line arguments. + cl::ParseCommandLineOptions(argc, argv, " trace basic block dumper\n"); + + // Read bytecode file. + std::string err; + Module *M = ParseBytecodeFile (BytecodeFile, &err); + if (!M) { + std::cerr << "Error reading bytecode: " << err << "\n"; + exit (1); + } + + // Read trace file. + std::vector vBB; + Trace *T = ReadTraceFromFile (M, TraceFile, &err); + if (!T) { + std::cerr << "Error reading trace: " << err << "\n"; + exit (1); + } + + // Print the trace blocks. + std::cout << "Trace blocks:\n"; + for (Trace::iterator i = T->begin(), e = T->end(); i != e; ++i) + std::cout << **i << "\n"; + std::cout << "\n"; + + // Print the values used which are defined outside the trace. + std::cout << "Values used which are defined outside the trace:\n"; + for (Trace::iterator i = T->begin(), e = T->end(); i != e; ++i) { + BasicBlock *BB = *i; + for (BasicBlock::iterator Inst = BB->begin(), BE = BB->end(); Inst != BE; + ++Inst) { + for (User::op_iterator Op = Inst->op_begin (), OE = Inst->op_end(); + Op != OE; ++Op) { + Value *UsedValue = *Op; + if (Instruction *DefiningInst = dyn_cast(UsedValue)) { + if (!T->contains(DefiningInst->getParent())) { + std::cout << "Use on trace of "; + WriteAsOperand (std::cout, DefiningInst, true, true, M); + std::cout << ", which is defined off-trace in block %" + << DefiningInst->getParent()->getName() << ":\n" << *Inst; + } + } + } + } + } + std::cout << "\n"; + + // Print values defined inside the trace which are used outside the trace + std::cout << "Values defined inside the trace which are used outside the trace:\n"; + for (Trace::iterator i = T->begin(), e = T->end(); i != e; ++i) { + BasicBlock *BB = *i; + for (BasicBlock::iterator Inst = BB->begin(), BE = BB->end(); Inst != BE; + ++Inst) { + for (Value::use_iterator UI = Inst->use_begin(), UE = Inst->use_end(); + UI != UE; ++UI) { + User *UsingEntity = *UI; + if (Instruction *UsingInst = dyn_cast(UsingEntity)) { + if (!T->contains(UsingInst->getParent())) { + std::cout << "Trace defines "; + WriteAsOperand(std::cout, Inst, true, true, M); + std::cout << ", which is used off-trace in block %" + << UsingInst->getParent()->getName() << " by:\n" << *UsingInst; + } + } + } + } + } + std::cout << "\n"; + + return 0; + } From gaeke at cs.uiuc.edu Tue Jun 29 16:57:04 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Tue Jun 29 16:57:04 2004 Subject: [llvm-commits] CVS: reopt/tools/dumptrace/ Message-ID: <200406292156.QAA20172@kain.cs.uiuc.edu> Changes in directory reopt/tools/dumptrace: --- Log message: Directory /home/vadve/shared/InternalCVS/reopt/tools/dumptrace added to the repository --- Diffs of the changes: (+0 -0) From llvm at cs.uiuc.edu Tue Jun 29 18:18:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Tue Jun 29 18:18:01 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Bytecode/Analyzer.h Message-ID: <200406292317.SAA29817@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Bytecode: Analyzer.h updated: 1.7 -> 1.8 --- Log message: Adjust comments to match code. Allow analysis to return the module created by the bcreader. --- Diffs of the changes: (+13 -6) Index: llvm/include/llvm/Bytecode/Analyzer.h diff -u llvm/include/llvm/Bytecode/Analyzer.h:1.7 llvm/include/llvm/Bytecode/Analyzer.h:1.8 --- llvm/include/llvm/Bytecode/Analyzer.h:1.7 Fri Jun 11 10:10:38 2004 +++ llvm/include/llvm/Bytecode/Analyzer.h Tue Jun 29 18:17:34 2004 @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// // -// This functionality is implemented by the lib/Bytecode/Analysis library. -// This library is used to read VM bytecode files from a file or memory buffer +// This functionality is implemented by the lib/Bytecode/Reader library. +// It is used to read VM bytecode files from a file or memory buffer // and print out a diagnostic analysis of the contents of the file. It is // intended for three uses: (a) understanding the bytecode format, (b) ensuring // correctness of bytecode format, (c) statistical analysis of generated @@ -25,7 +25,9 @@ namespace llvm { +// Forward declarations class Function; +class Module; /// This structure is used to contain the output of the Bytecode Analysis /// library. It simply contains fields to hold each item of the analysis @@ -91,16 +93,20 @@ /// The content of the bytecode dump std::string BytecodeDump; + /// The content of the progressive verification + std::string VerifyInfo; + /// Flags for what should be done - bool dumpBytecode; ///< If true, BytecodeDump has contents - bool detailedResults; ///< If true, FunctionInfo has contents + bool dumpBytecode; ///< If true, BytecodeDump has contents + bool detailedResults; ///< If true, FunctionInfo has contents + bool progressiveVerify; ///< If true, VerifyInfo has contents }; /// This function is the main entry point into the bytecode analysis library. It /// allows you to simply provide a \p filename and storage for the \p Results /// that will be filled in with the analysis results. /// @brief Analyze contents of a bytecode File -void AnalyzeBytecodeFile( +Module* AnalyzeBytecodeFile( const std::string& Filename, ///< The name of the bytecode file to read BytecodeAnalysis& Results, ///< The results of the analysis std::string* ErrorStr = 0 ///< Errors, if any. @@ -111,9 +117,10 @@ /// assumed to contain a complete bytecode file. The \p Buffer is analyzed and /// the \p Results are filled in. /// @brief Analyze contents of a bytecode buffer. -void AnalyzeBytecodeBuffer( +Module* AnalyzeBytecodeBuffer( const unsigned char* Buffer, ///< Pointer to start of bytecode buffer unsigned BufferSize, ///< Size of the bytecode buffer + const std::string& ModuleID, ///< Identifier for the module BytecodeAnalysis& Results, ///< The results of the analysis std::string* ErrorStr = 0 ///< Errors, if any. ); From llvm at cs.uiuc.edu Tue Jun 29 18:20:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Tue Jun 29 18:20:01 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Bytecode/BytecodeHandler.h Message-ID: <200406292319.SAA29857@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Bytecode: BytecodeHandler.h updated: 1.1 -> 1.2 --- Log message: Fix include guard Adjust comments Make handlers for constants provide useful information. --- Diffs of the changes: (+20 -9) Index: llvm/include/llvm/Bytecode/BytecodeHandler.h diff -u llvm/include/llvm/Bytecode/BytecodeHandler.h:1.1 llvm/include/llvm/Bytecode/BytecodeHandler.h:1.2 --- llvm/include/llvm/Bytecode/BytecodeHandler.h:1.1 Thu Jun 24 21:32:27 2004 +++ llvm/include/llvm/Bytecode/BytecodeHandler.h Tue Jun 29 18:18:52 2004 @@ -13,8 +13,8 @@ // //===----------------------------------------------------------------------===// -#ifndef BYTECODE_BYTECODEHANDLER_H -#define BYTECODE_BYTECODEHANDLER_H +#ifndef LLVM_BYTECODE_BYTECODEHANDLER_H +#define LLVM_BYTECODE_BYTECODEHANDLER_H #include "llvm/Module.h" @@ -24,6 +24,7 @@ class StructType; class PointerType; class ConstantArray; +class Module; /// This class provides the interface for handling bytecode events during /// reading of bytecode. The methods on this interface are invoked by the @@ -70,7 +71,7 @@ /// This method is called at the beginning of a parse before anything is /// read in order to give the handler a chance to initialize. /// @brief Handle the start of a bytecode parse - virtual void handleStart( unsigned byteSize ); + virtual void handleStart( Module* Mod, unsigned byteSize ); /// This method is called at the end of a parse after everything has been /// read in order to give the handler a chance to terminate. @@ -127,6 +128,11 @@ Function* Func ///< The function being declared ); + /// This method is called when a global variable is initialized with + /// its constant value. Because of forward referencing, etc. this is + /// done towards the end of the module globals block + virtual void handleGlobalInitializer(GlobalVariable*, Constant* ); + /// This method is called at the end of the module globals block. /// @brief Handle end of module globals block. virtual void handleModuleGlobalsEnd(); @@ -226,26 +232,31 @@ /// @brief Handle a constant expression virtual void handleConstantExpression( unsigned Opcode, ///< Opcode of primary expression operator - const Type* Typ, ///< Type of the expression - std::vector > ArgVec ///< expression args + std::vector ArgVec, ///< expression args + Constant* C ///< The constant value ); /// @brief Handle a constant array virtual void handleConstantArray( const ArrayType* AT, ///< Type of the array - std::vector& ElementSlots ///< Slot nums for array values + std::vector& ElementSlots,///< Slot nums for array values + unsigned TypeSlot, ///< Slot # of type + Constant* Val ///< The constant value ); /// @brief Handle a constant structure - virtual void handleConstantStruct( + virtual void handleConstantStruct( const StructType* ST, ///< Type of the struct - std::vector& ElementSlots ///< Slot nums for struct values + std::vector& ElementSlots,///< Slot nums for struct values + Constant* Val ///< The constant value ); /// @brief Handle a constant pointer virtual void handleConstantPointer( const PointerType* PT, ///< Type of the pointer - unsigned Slot ///< Slot num of initializer value + unsigned Slot, ///< Slot num of initializer value + GlobalValue* GV, ///< Referenced global value + Constant* Val ///< Value of constant ); /// @brief Handle a constant strings (array special case) From llvm at cs.uiuc.edu Tue Jun 29 18:21:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Tue Jun 29 18:21:01 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Bytecode/Reader.h Message-ID: <200406292320.SAA29904@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Bytecode: Reader.h updated: 1.16 -> 1.17 --- Log message: Provide support for the BytecodeHandler interface which will be called by the bcreader if one is supplied to the bytecode reader's interface functions. --- Diffs of the changes: (+9 -2) Index: llvm/include/llvm/Bytecode/Reader.h diff -u llvm/include/llvm/Bytecode/Reader.h:1.16 llvm/include/llvm/Bytecode/Reader.h:1.17 --- llvm/include/llvm/Bytecode/Reader.h:1.16 Tue Nov 11 16:41:31 2003 +++ llvm/include/llvm/Bytecode/Reader.h Tue Jun 29 18:20:03 2004 @@ -25,16 +25,23 @@ namespace llvm { +// Forward declare the handler class +class BytecodeHandler; + /// getBytecodeModuleProvider - lazy function-at-a-time loading from a file /// -ModuleProvider *getBytecodeModuleProvider(const std::string &Filename); +ModuleProvider *getBytecodeModuleProvider( + const std::string &Filename, ///< Name of file to be read + BytecodeHandler* H = 0 ///< Optional handler for reader events +); /// getBytecodeBufferModuleProvider - lazy function-at-a-time loading from a /// buffer /// ModuleProvider *getBytecodeBufferModuleProvider(const unsigned char *Buffer, unsigned BufferSize, - const std::string &ModuleID=""); + const std::string &ModuleID="", + BytecodeHandler* H = 0); /// ParseBytecodeFile - Parse the given bytecode file /// From llvm at cs.uiuc.edu Tue Jun 29 18:22:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Tue Jun 29 18:22:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Makefile Message-ID: <200406292321.SAA29932@zion.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode: Makefile updated: 1.3 -> 1.4 --- Log message: Remove newly defunct Analyzer directory. --- Diffs of the changes: (+1 -1) Index: llvm/lib/Bytecode/Makefile diff -u llvm/lib/Bytecode/Makefile:1.3 llvm/lib/Bytecode/Makefile:1.4 --- llvm/lib/Bytecode/Makefile:1.3 Mon Jun 7 12:53:43 2004 +++ llvm/lib/Bytecode/Makefile Tue Jun 29 18:21:16 2004 @@ -7,7 +7,7 @@ # ##===----------------------------------------------------------------------===## LEVEL = ../.. -DIRS = Analyzer Reader Writer +DIRS = Reader Writer include $(LEVEL)/Makefile.common From llvm at cs.uiuc.edu Tue Jun 29 18:23:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Tue Jun 29 18:23:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Analyzer/Analyzer.cpp AnalyzerInternals.h AnalyzerWrappers.cpp Dumper.cpp Makefile Parser.cpp Parser.h Message-ID: <200406292322.SAA29954@zion.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Analyzer: Analyzer.cpp (r1.6) removed AnalyzerInternals.h (r1.3) removed AnalyzerWrappers.cpp (r1.7) removed Dumper.cpp (r1.4) removed Makefile (r1.1) removed Parser.cpp (r1.6) removed Parser.h (r1.5) removed --- Log message: Analyzer moved to ../Reader directory. --- Diffs of the changes: (+0 -0) From llvm at cs.uiuc.edu Tue Jun 29 18:24:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Tue Jun 29 18:24:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Reader/Analyzer.cpp Message-ID: <200406292323.SAA30700@zion.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Reader: Analyzer.cpp updated: 1.6 -> 1.7 --- Log message: Merge Dumper.cpp and AnalyzerWrappers.cpp into this file. Also, adjust the dumping facility to produce useful output. --- Diffs of the changes: (+377 -63) Index: llvm/lib/Bytecode/Reader/Analyzer.cpp diff -u llvm/lib/Bytecode/Reader/Analyzer.cpp:1.6 llvm/lib/Bytecode/Reader/Analyzer.cpp:1.7 --- llvm/lib/Bytecode/Reader/Analyzer.cpp:1.6 Fri Jun 11 10:10:38 2004 +++ llvm/lib/Bytecode/Reader/Analyzer.cpp Tue Jun 29 18:23:12 2004 @@ -1,4 +1,4 @@ -//===-- BytecodeHandler.cpp - Parsing Handler -------------------*- C++ -*-===// +//===-- Analyzer.cpp - Analysis and Dumping of Bytecode 000000---*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,33 +7,62 @@ // //===----------------------------------------------------------------------===// // -// This header file defines the BytecodeHandler class that gets called by the -// AbstractBytecodeParser when parsing events occur. +// This file implements the AnalyzerHandler class and PrintBytecodeAnalysis +// function which together comprise the basic functionality of the llmv-abcd +// tool. The AnalyzerHandler collects information about the bytecode file into +// the BytecodeAnalysis structure. The PrintBytecodeAnalysis function prints +// out the content of that structure. +// @see include/llvm/Bytecode/Analysis.h // //===----------------------------------------------------------------------===// -#include "AnalyzerInternals.h" -#include +#include "Reader.h" +#include "llvm/Constants.h" +#include "llvm/DerivedTypes.h" +#include "llvm/Module.h" +#include "llvm/Analysis/Verifier.h" +#include "llvm/Bytecode/Analyzer.h" +#include "llvm/Bytecode/BytecodeHandler.h" +#include +#include using namespace llvm; - namespace { +/// @brief Bytecode reading handler for analyzing bytecode. class AnalyzerHandler : public BytecodeHandler { - BytecodeAnalysis& bca; - BytecodeAnalysis::BytecodeFunctionInfo* currFunc; + BytecodeAnalysis& bca; ///< The structure in which data is recorded + std::ostringstream dump; ///< A convenience for dumping data. + /// @brief Keeps track of current function + BytecodeAnalysis::BytecodeFunctionInfo* currFunc; + Module* M; ///< Keeps track of current module + +/// @name Constructor +/// @{ public: + /// The only way to construct an AnalyzerHandler. All that is needed is a + /// reference to the BytecodeAnalysis structure where the output will be + /// placed. AnalyzerHandler(BytecodeAnalysis& TheBca) : bca(TheBca) + , dump() , currFunc(0) { } - virtual bool handleError(const std::string& str ) { - return false; +/// @} +/// @name BytecodeHandler Implementations +/// @{ +public: + virtual void handleError(const std::string& str ) { + dump << "ERROR: " << str << "\n"; + bca.BytecodeDump = dump.str() ; } - virtual void handleStart() { + virtual void handleStart( Module* Mod, unsigned theSize ) { + M = Mod; + dump << "Bytecode {\n"; + bca.byteSize = theSize; bca.ModuleId.clear(); bca.numBlocks = 0; bca.numTypes = 0; @@ -72,6 +101,9 @@ } virtual void handleFinish() { + dump << "} End Bytecode\n"; + bca.BytecodeDump = dump.str() ; + bca.fileDensity = double(bca.byteSize) / double( bca.numTypes + bca.numValues ); double globalSize = 0.0; globalSize += double(bca.BlockSizes[BytecodeFormat::ConstantPool]); @@ -81,83 +113,157 @@ bca.numGlobalVars ); bca.functionDensity = double(bca.BlockSizes[BytecodeFormat::Function]) / double(bca.numFunctions); + + if ( bca.progressiveVerify ) { + try { + verifyModule(*M, ThrowExceptionAction); + } catch ( std::string& msg ) { + bca.VerifyInfo += "Verify at Finish: " + msg + "\n"; + } + } } virtual void handleModuleBegin(const std::string& id) { + dump << " Module " << id << " {\n"; bca.ModuleId = id; } - virtual void handleModuleEnd(const std::string& id) { } + virtual void handleModuleEnd(const std::string& id) { + dump << " } End Module " << id << "\n"; + if ( bca.progressiveVerify ) { + try { + verifyModule(*M, ThrowExceptionAction); + } catch ( std::string& msg ) { + bca.VerifyInfo += "Verify at EndModule: " + msg + "\n"; + } + } + } virtual void handleVersionInfo( unsigned char RevisionNum, ///< Byte code revision number Module::Endianness Endianness, ///< Endianness indicator Module::PointerSize PointerSize ///< PointerSize indicator - ) { } + ) { + dump << " RevisionNum: " << int(RevisionNum) + << " Endianness: " << Endianness + << " PointerSize: " << PointerSize << "\n"; + } - virtual void handleModuleGlobalsBegin(unsigned size) { } + virtual void handleModuleGlobalsBegin() { + dump << " BLOCK: ModuleGlobalInfo {\n"; + } virtual void handleGlobalVariable( - const Type* ElemType, ///< The type of the global variable - bool isConstant, ///< Whether the GV is constant or not - GlobalValue::LinkageTypes ///< The linkage type of the GV + const Type* ElemType, + bool isConstant, + GlobalValue::LinkageTypes Linkage, + unsigned SlotNum, + unsigned initSlot ) { bca.numGlobalVars++; bca.numValues++; - } - virtual void handleInitializedGV( - const Type* ElemType, ///< The type of the global variable - bool isConstant, ///< Whether the GV is constant or not - GlobalValue::LinkageTypes,///< The linkage type of the GV - unsigned initSlot ///< Slot number of GV's initializer - ) { - bca.numGlobalVars++; - bca.numValues++; + dump << " GV: " + << ( initSlot == 0 ? "Uni" : "I" ) << "nitialized, " + << ( isConstant? "Constant, " : "Variable, ") + << " Linkage=" << Linkage << " Type=" + << ElemType->getDescription() + << " Slot=" << SlotNum << " InitSlot=" << initSlot + << "\n"; } - virtual void handleType( const Type* Ty ) { bca.numTypes++; } + virtual void handleType( const Type* Ty ) { + bca.numTypes++; + dump << " Type: " << Ty->getDescription() << "\n"; + } virtual void handleFunctionDeclaration( - Function* Func, ///< The function - const FunctionType* FuncType ///< The type of the function + Function* Func ///< The function ) { bca.numFunctions++; bca.numValues++; + dump << " Function Decl: " << Func->getType()->getDescription() << "\n"; } - virtual void handleModuleGlobalsEnd() { } + virtual void handleGlobalInitializer(GlobalVariable* GV, Constant* CV) { + dump << " Initializer: GV="; + GV->print(dump); + dump << " CV="; + CV->print(dump); + dump << "\n"; + } + + virtual void handleModuleGlobalsEnd() { + dump << " } END BLOCK: ModuleGlobalInfo\n"; + if ( bca.progressiveVerify ) { + try { + verifyModule(*M, ThrowExceptionAction); + } catch ( std::string& msg ) { + bca.VerifyInfo += "Verify at EndModuleGlobalInfo: " + msg + "\n"; + } + } + } - virtual void handleCompactionTableBegin() { } + virtual void handleCompactionTableBegin() { + dump << " BLOCK: CompactionTable {\n"; + } virtual void handleCompactionTablePlane( unsigned Ty, unsigned NumEntries) { bca.numCmpctnTables++; + dump << " Plane: Ty=" << Ty << " Size=" << NumEntries << "\n"; } virtual void handleCompactionTableType( unsigned i, unsigned TypSlot, - const Type* ) {} + const Type* Ty ) { + dump << " Type: " << i << " Slot:" << TypSlot + << " is " << Ty->getDescription() << "\n"; + } virtual void handleCompactionTableValue( unsigned i, + unsigned TypSlot, unsigned ValSlot, - const Type* ) { } + const Type* Ty ) { + dump << " Value: " << i << " TypSlot: " << TypSlot + << " ValSlot:" << ValSlot << " is " << Ty->getDescription() + << "\n"; + } - virtual void handleCompactionTableEnd() { } + virtual void handleCompactionTableEnd() { + dump << " } END BLOCK: CompactionTable\n"; + } - virtual void handleSymbolTableBegin() { bca.numSymTab++; } + virtual void handleSymbolTableBegin(Function* CF, SymbolTable* ST) { + bca.numSymTab++; + dump << " BLOCK: SymbolTable {\n"; + } - virtual void handleSymbolTablePlane( unsigned Ty, unsigned NumEntries, - const Type* Typ) { } + virtual void handleSymbolTablePlane(unsigned Ty, unsigned NumEntries, + const Type* Typ) { + dump << " Plane: Ty=" << Ty << " Size=" << NumEntries + << " Type: " << Typ->getDescription() << "\n"; + } - virtual void handleSymbolTableType( unsigned i, unsigned slot, - const std::string& name ) { } + virtual void handleSymbolTableType(unsigned i, unsigned slot, + const std::string& name ) { + dump << " Type " << i << " Slot=" << slot + << " Name: " << name << "\n"; + } - virtual void handleSymbolTableValue( unsigned i, unsigned slot, - const std::string& name ) { } + virtual void handleSymbolTableValue(unsigned i, unsigned slot, + const std::string& name ) { + dump << " Value " << i << " Slot=" << slot + << " Name: " << name << "\n"; + } - virtual void handleSymbolTableEnd() { } + virtual void handleSymbolTableEnd() { + dump << " } END BLOCK: SymbolTable\n"; + } - virtual void handleFunctionBegin( Function* Func, unsigned Size) { + virtual void handleFunctionBegin(Function* Func, unsigned Size) { + dump << "BLOCK: Function {\n"; + dump << " Linkage: " << Func->getLinkage() << "\n"; + dump << " Type: " << Func->getType()->getDescription() << "\n"; const FunctionType* FType = cast(Func->getType()->getElementType()); currFunc = &bca.FunctionInfo[Func]; @@ -175,21 +281,38 @@ currFunc->vbrCount64 = 0; currFunc->vbrCompBytes = 0; currFunc->vbrExpdBytes = 0; + } virtual void handleFunctionEnd( Function* Func) { + dump << "} END BLOCK: Function\n"; currFunc->density = double(currFunc->byteSize) / double(currFunc->numInstructions+currFunc->numBasicBlocks); + + if ( bca.progressiveVerify ) { + try { + verifyModule(*M, ThrowExceptionAction); + } catch ( std::string& msg ) { + bca.VerifyInfo += "Verify at EndFunction: " + msg + "\n"; + } + } } virtual void handleBasicBlockBegin( unsigned blocknum) { + dump << " BLOCK: BasicBlock #" << blocknum << "{\n"; bca.numBasicBlocks++; bca.numValues++; if ( currFunc ) currFunc->numBasicBlocks++; } virtual bool handleInstruction( unsigned Opcode, const Type* iType, - std::vector& Operands, unsigned Size) { + std::vector& Operands, unsigned Size){ + dump << " INST: OpCode=" + << Instruction::getOpcodeName(Opcode) << " Type=" + << iType->getDescription() << "\n"; + for ( unsigned i = 0; i < Operands.size(); ++i ) + dump << " Op#" << i << " Slot=" << Operands[i] << "\n"; + bca.numInstructions++; bca.numValues++; bca.instructionSize += Size; @@ -204,46 +327,100 @@ return Instruction::isTerminator(Opcode); } - virtual void handleBasicBlockEnd(unsigned blocknum) { } + virtual void handleBasicBlockEnd(unsigned blocknum) { + dump << " } END BLOCK: BasicBlock #" << blocknum << "{\n"; + } - virtual void handleGlobalConstantsBegin() { } + virtual void handleGlobalConstantsBegin() { + dump << " BLOCK: GlobalConstants {\n"; + } - virtual void handleConstantExpression( unsigned Opcode, const Type* Typ, - std::vector > ArgVec ) { + virtual void handleConstantExpression( unsigned Opcode, + std::vector ArgVec, Constant* C ) { + dump << " EXPR: " << Instruction::getOpcodeName(Opcode) << "\n"; + for ( unsigned i = 0; i < ArgVec.size(); ++i ) { + dump << " Arg#" << i << " "; ArgVec[i]->print(dump); dump << "\n"; + } + dump << " Value="; + C->print(dump); + dump << "\n"; bca.numConstants++; bca.numValues++; } virtual void handleConstantValue( Constant * c ) { + dump << " VALUE: "; + c->print(dump); + dump << "\n"; bca.numConstants++; bca.numValues++; } virtual void handleConstantArray( const ArrayType* AT, - std::vector& Elements ) { + std::vector& Elements, + unsigned TypeSlot, + Constant* ArrayVal ) { + dump << " ARRAY: " << AT->getDescription() + << " TypeSlot=" << TypeSlot << "\n"; + for ( unsigned i = 0; i < Elements.size(); ++i ) { + dump << " #" << i; + Elements[i]->print(dump); + dump << "\n"; + } + dump << " Value="; + ArrayVal->print(dump); + dump << "\n"; + bca.numConstants++; bca.numValues++; } virtual void handleConstantStruct( const StructType* ST, - std::vector& ElementSlots) + std::vector& Elements, + Constant* StructVal) { + dump << " STRUC: " << ST->getDescription() << "\n"; + for ( unsigned i = 0; i < Elements.size(); ++i ) { + dump << " #" << i << " "; Elements[i]->print(dump); dump << "\n"; + } + dump << " Value="; + StructVal->print(dump); + dump << "\n"; bca.numConstants++; bca.numValues++; } - virtual void handleConstantPointer( const PointerType* PT, unsigned Slot) { + virtual void handleConstantPointer( const PointerType* PT, + unsigned Slot, GlobalValue* GV, Constant* PtrVal) { + dump << " PNTR: " << PT->getDescription() + << " Slot=" << Slot << " GlobalValue="; + GV->print(dump); + dump << "\n Value="; + PtrVal->print(dump); + dump << "\n"; bca.numConstants++; bca.numValues++; } virtual void handleConstantString( const ConstantArray* CA ) { + dump << " STRNG: "; + CA->print(dump); + dump << "\n"; bca.numConstants++; bca.numValues++; } - virtual void handleGlobalConstantsEnd() { } + virtual void handleGlobalConstantsEnd() { + dump << " } END BLOCK: GlobalConstants\n"; + if ( bca.progressiveVerify ) { + try { + verifyModule(*M, ThrowExceptionAction); + } catch ( std::string& msg ) { + bca.VerifyInfo += "Verify at EndGlobalConstants: " + msg + "\n"; + } + } + } virtual void handleAlignment(unsigned numBytes) { bca.numAlignment += numBytes; @@ -278,20 +455,157 @@ } }; + +/// @brief Utility for printing a titled unsigned value with +/// an aligned colon. +inline static void print(std::ostream& Out, const char*title, + unsigned val, bool nl = true ) { + Out << std::setw(30) << std::right << title + << std::setw(0) << ": " + << std::setw(9) << val << "\n"; +} + +/// @brief Utility for printing a titled double value with an +/// aligned colon +inline static void print(std::ostream&Out, const char*title, + double val ) { + Out << std::setw(30) << std::right << title + << std::setw(0) << ": " + << std::setw(9) << std::setprecision(6) << val << "\n" ; +} + +/// @brief Utility for printing a titled double value with a +/// percentage and aligned colon. +inline static void print(std::ostream&Out, const char*title, + double top, double bot ) { + Out << std::setw(30) << std::right << title + << std::setw(0) << ": " + << std::setw(9) << std::setprecision(6) << top + << " (" << std::left << std::setw(0) << std::setprecision(4) + << (top/bot)*100.0 << "%)\n"; } -void llvm::BytecodeAnalyzer::AnalyzeBytecode( - const unsigned char *Buf, - unsigned Length, - BytecodeAnalysis& bca, - const std::string &ModuleID -) +/// @brief Utility for printing a titled string value with +/// an aligned colon. +inline static void print(std::ostream&Out, const char*title, + std::string val, bool nl = true) { + Out << std::setw(30) << std::right << title + << std::setw(0) << ": " + << std::left << val << (nl ? "\n" : ""); +} + +} + +namespace llvm { + +/// This function prints the contents of rhe BytecodeAnalysis structure in +/// a human legible form. +/// @brief Print BytecodeAnalysis structure to an ostream +void PrintBytecodeAnalysis(BytecodeAnalysis& bca, std::ostream& Out ) +{ + print(Out, "Bytecode Analysis Of Module", bca.ModuleId); + print(Out, "File Size", bca.byteSize); + print(Out, "Bytecode Compression Index",std::string("TBD")); + print(Out, "Number Of Bytecode Blocks", bca.numBlocks); + print(Out, "Number Of Types", bca.numTypes); + print(Out, "Number Of Values", bca.numValues); + print(Out, "Number Of Constants", bca.numConstants); + print(Out, "Number Of Global Variables", bca.numGlobalVars); + print(Out, "Number Of Functions", bca.numFunctions); + print(Out, "Number Of Basic Blocks", bca.numBasicBlocks); + print(Out, "Number Of Instructions", bca.numInstructions); + print(Out, "Number Of Operands", bca.numOperands); + print(Out, "Number Of Compaction Tables", bca.numCmpctnTables); + print(Out, "Number Of Symbol Tables", bca.numSymTab); + print(Out, "Long Instructions", bca.longInstructions); + print(Out, "Instruction Size", bca.instructionSize); + print(Out, "Average Instruction Size", + double(bca.instructionSize)/double(bca.numInstructions)); + print(Out, "Maximum Type Slot Number", bca.maxTypeSlot); + print(Out, "Maximum Value Slot Number", bca.maxValueSlot); + print(Out, "Bytes Thrown To Alignment", double(bca.numAlignment), + double(bca.byteSize)); + print(Out, "File Density (bytes/def)", bca.fileDensity); + print(Out, "Globals Density (bytes/def)", bca.globalsDensity); + print(Out, "Function Density (bytes/func)", bca.functionDensity); + print(Out, "Number of VBR 32-bit Integers", bca.vbrCount32); + print(Out, "Number of VBR 64-bit Integers", bca.vbrCount64); + print(Out, "Number of VBR Compressed Bytes", bca.vbrCompBytes); + print(Out, "Number of VBR Expanded Bytes", bca.vbrExpdBytes); + print(Out, "VBR Savings", + double(bca.vbrExpdBytes)-double(bca.vbrCompBytes), + double(bca.byteSize)); + + if ( bca.detailedResults ) { + print(Out, "Module Bytes", + double(bca.BlockSizes[BytecodeFormat::Module]), + double(bca.byteSize)); + print(Out, "Function Bytes", + double(bca.BlockSizes[BytecodeFormat::Function]), + double(bca.byteSize)); + print(Out, "Constant Pool Bytes", + double(bca.BlockSizes[BytecodeFormat::ConstantPool]), + double(bca.byteSize)); + print(Out, "Symbol Table Bytes", + double(bca.BlockSizes[BytecodeFormat::SymbolTable]), + double(bca.byteSize)); + print(Out, "Module Global Info Bytes", + double(bca.BlockSizes[BytecodeFormat::ModuleGlobalInfo]), + double(bca.byteSize)); + print(Out, "Global Type Plane Bytes", + double(bca.BlockSizes[BytecodeFormat::GlobalTypePlane]), + double(bca.byteSize)); + print(Out, "Basic Block Bytes", + double(bca.BlockSizes[BytecodeFormat::BasicBlock]), + double(bca.byteSize)); + print(Out, "Instruction List Bytes", + double(bca.BlockSizes[BytecodeFormat::InstructionList]), + double(bca.byteSize)); + print(Out, "Compaction Table Bytes", + double(bca.BlockSizes[BytecodeFormat::CompactionTable]), + double(bca.byteSize)); + + std::map::iterator I = + bca.FunctionInfo.begin(); + std::map::iterator E = + bca.FunctionInfo.end(); + + while ( I != E ) { + Out << std::left << std::setw(0); + Out << "Function: " << I->second.name << "\n"; + print(Out, "Type:", I->second.description); + print(Out, "Byte Size", I->second.byteSize); + print(Out, "Instructions", I->second.numInstructions); + print(Out, "Long Instructions", I->second.longInstructions); + print(Out, "Instruction Size", I->second.instructionSize); + print(Out, "Average Instruction Size", + double(I->second.instructionSize)/double(I->second.numInstructions)); + print(Out, "Basic Blocks", I->second.numBasicBlocks); + print(Out, "Operand", I->second.numOperands); + print(Out, "Function Density", I->second.density); + print(Out, "Number of VBR 32-bit Integers", I->second.vbrCount32); + print(Out, "Number of VBR 64-bit Integers", I->second.vbrCount64); + print(Out, "Number of VBR Compressed Bytes", I->second.vbrCompBytes); + print(Out, "Number of VBR Expanded Bytes", I->second.vbrExpdBytes); + print(Out, "VBR Savings", + double(I->second.vbrExpdBytes)-double(I->second.vbrCompBytes), + double(I->second.byteSize)); + ++I; + } + } + + if ( bca.dumpBytecode ) + Out << bca.BytecodeDump; + + if ( bca.progressiveVerify ) + Out << bca.VerifyInfo; +} + +BytecodeHandler* createBytecodeAnalyzerHandler(BytecodeAnalysis& bca) { - bca.byteSize = Length; - AnalyzerHandler TheHandler(bca); - AbstractBytecodeParser TheParser(&TheHandler, true, true, true); - TheParser.ParseBytecode( Buf, Length, ModuleID ); - TheParser.ParseAllFunctionBodies(); + return new AnalyzerHandler(bca); +} + } // vim: sw=2 From llvm at cs.uiuc.edu Tue Jun 29 18:25:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Tue Jun 29 18:25:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Reader/ReaderWrappers.cpp Message-ID: <200406292324.SAA32323@zion.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Reader: ReaderWrappers.cpp updated: 1.22 -> 1.23 --- Log message: Adjustments to allow Bytecode Reading to support the BytecodeHandler interface which is called by the reader if a BytecodeHandler is provided. --- Diffs of the changes: (+68 -15) Index: llvm/lib/Bytecode/Reader/ReaderWrappers.cpp diff -u llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.22 llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.23 --- llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.22 Thu May 27 19:24:41 2004 +++ llvm/lib/Bytecode/Reader/ReaderWrappers.cpp Tue Jun 29 18:24:14 2004 @@ -12,8 +12,9 @@ // //===----------------------------------------------------------------------===// +#include "llvm/Bytecode/Analyzer.h" #include "llvm/Bytecode/Reader.h" -#include "ReaderInternals.h" +#include "Reader.h" #include "llvm/Module.h" #include "llvm/Instructions.h" #include "Support/FileUtilities.h" @@ -29,7 +30,7 @@ namespace { /// BytecodeFileReader - parses a bytecode file from a file /// - class BytecodeFileReader : public BytecodeParser { + class BytecodeFileReader : public BytecodeReader { private: unsigned char *Buffer; unsigned Length; @@ -38,7 +39,7 @@ void operator=(const BytecodeFileReader &BFR); // Do not implement public: - BytecodeFileReader(const std::string &Filename); + BytecodeFileReader(const std::string &Filename, llvm::BytecodeHandler* H=0); ~BytecodeFileReader(); }; } @@ -47,7 +48,10 @@ return ::strerror(savedErrNum) + std::string(", while trying to ") + descr; } -BytecodeFileReader::BytecodeFileReader(const std::string &Filename) { +BytecodeFileReader::BytecodeFileReader(const std::string &Filename, + llvm::BytecodeHandler* H ) + : BytecodeReader(H) +{ Buffer = (unsigned char*)ReadFileIntoAddressSpace(Filename, Length); if (Buffer == 0) throw "Error reading file '" + Filename + "'."; @@ -73,7 +77,7 @@ namespace { /// BytecodeBufferReader - parses a bytecode file from a buffer /// - class BytecodeBufferReader : public BytecodeParser { + class BytecodeBufferReader : public BytecodeReader { private: const unsigned char *Buffer; bool MustDelete; @@ -83,7 +87,8 @@ public: BytecodeBufferReader(const unsigned char *Buf, unsigned Length, - const std::string &ModuleID); + const std::string &ModuleID, + llvm::BytecodeHandler* Handler = 0); ~BytecodeBufferReader(); }; @@ -91,7 +96,9 @@ BytecodeBufferReader::BytecodeBufferReader(const unsigned char *Buf, unsigned Length, - const std::string &ModuleID) + const std::string &ModuleID, + llvm::BytecodeHandler* H ) + : BytecodeReader(H) { // If not aligned, allocate a new buffer to hold the bytecode... const unsigned char *ParseBegin = 0; @@ -125,7 +132,7 @@ namespace { /// BytecodeStdinReader - parses a bytecode file from stdin /// - class BytecodeStdinReader : public BytecodeParser { + class BytecodeStdinReader : public BytecodeReader { private: std::vector FileData; unsigned char *FileBuf; @@ -134,11 +141,13 @@ void operator=(const BytecodeStdinReader &BFR); // Do not implement public: - BytecodeStdinReader(); + BytecodeStdinReader( llvm::BytecodeHandler* H = 0 ); }; } -BytecodeStdinReader::BytecodeStdinReader() { +BytecodeStdinReader::BytecodeStdinReader( BytecodeHandler* H ) + : BytecodeReader(H) +{ int BlockSize; unsigned char Buffer[4096*4]; @@ -238,8 +247,10 @@ ModuleProvider* llvm::getBytecodeBufferModuleProvider(const unsigned char *Buffer, unsigned Length, - const std::string &ModuleID) { - return CheckVarargs(new BytecodeBufferReader(Buffer, Length, ModuleID)); + const std::string &ModuleID, + BytecodeHandler* H ) { + return CheckVarargs( + new BytecodeBufferReader(Buffer, Length, ModuleID, H)); } /// ParseBytecodeBuffer - Parse a given bytecode buffer @@ -259,11 +270,12 @@ /// getBytecodeModuleProvider - lazy function-at-a-time loading from a file /// -ModuleProvider *llvm::getBytecodeModuleProvider(const std::string &Filename) { +ModuleProvider *llvm::getBytecodeModuleProvider(const std::string &Filename, + BytecodeHandler* H) { if (Filename != std::string("-")) // Read from a file... - return CheckVarargs(new BytecodeFileReader(Filename)); + return CheckVarargs(new BytecodeFileReader(Filename,H)); else // Read from stdin - return CheckVarargs(new BytecodeStdinReader()); + return CheckVarargs(new BytecodeStdinReader(H)); } /// ParseBytecodeFile - Parse the given bytecode file @@ -279,3 +291,44 @@ } } +namespace llvm { +extern BytecodeHandler* createBytecodeAnalyzerHandler(BytecodeAnalysis& bca ); +} + +// AnalyzeBytecodeFile - analyze one file +Module* llvm::AnalyzeBytecodeFile(const std::string &Filename, + BytecodeAnalysis& bca, + std::string *ErrorStr) +{ + try { + BytecodeHandler* analyzerHandler = createBytecodeAnalyzerHandler(bca); + std::auto_ptr AMP( + getBytecodeModuleProvider(Filename,analyzerHandler)); + return AMP->releaseModule(); + } catch (std::string &err) { + if (ErrorStr) *ErrorStr = err; + return 0; + } +} + +// AnalyzeBytecodeBuffer - analyze a buffer +Module* llvm::AnalyzeBytecodeBuffer( + const unsigned char* Buffer, ///< Pointer to start of bytecode buffer + unsigned Length, ///< Size of the bytecode buffer + const std::string& ModuleID, ///< Identifier for the module + BytecodeAnalysis& bca, ///< The results of the analysis + std::string* ErrorStr ///< Errors, if any. + ) +{ + try { + BytecodeHandler* hdlr = createBytecodeAnalyzerHandler(bca); + std::auto_ptr + AMP(getBytecodeBufferModuleProvider(Buffer, Length, ModuleID, hdlr)); + return AMP->releaseModule(); + } catch (std::string &err) { + if (ErrorStr) *ErrorStr = err; + return 0; + } +} + +// vim: sw=2 ai From llvm at cs.uiuc.edu Tue Jun 29 18:31:02 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Tue Jun 29 18:31:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Reader/Reader.cpp Message-ID: <200406292329.SAA32373@zion.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Reader: Reader.cpp updated: 1.107 -> 1.108 --- Log message: MAJOR REWRITE. - stop passing Buf/BufEnd to every function (now member vars) - internalize things that used to be in a header file that no one else included/needed. - Remove defunct BCR_TRACE lines - Standardize error handling with the PARSE_ERROR macro. - Integrate ConstantReader.cpp and InstructionReader.cpp and reorgnize the definition order so that gcc has a chance at optimizing this module - Standardize case and style of method names. - Eliminate unneeded header files - Prepare for Type != Value (bug122: http://llvm.cs.uiuc.edu/PR122 ) change by splitting Types into their own data structures. - Implement the BytecodeHandler interface calls. - Provide default implementation of BytecodeHandler interface. --- Diffs of the changes: (+1356 -327) Index: llvm/lib/Bytecode/Reader/Reader.cpp diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.107 llvm/lib/Bytecode/Reader/Reader.cpp:1.108 --- llvm/lib/Bytecode/Reader/Reader.cpp:1.107 Thu Jun 17 13:17:58 2004 +++ llvm/lib/Bytecode/Reader/Reader.cpp Tue Jun 29 18:29:38 2004 @@ -16,45 +16,163 @@ // //===----------------------------------------------------------------------===// -#include "ReaderInternals.h" -#include "llvm/Bytecode/Reader.h" +#include "Reader.h" +#include "llvm/Bytecode/BytecodeHandler.h" +#include "llvm/BasicBlock.h" +#include "llvm/Constants.h" +#include "llvm/iMemory.h" +#include "llvm/iOther.h" +#include "llvm/iPHINode.h" +#include "llvm/iTerminators.h" #include "llvm/Bytecode/Format.h" -#include "llvm/Module.h" +#include "llvm/Support/GetElementPtrTypeIterator.h" #include "Support/StringExtras.h" -using namespace llvm; +#include -unsigned BytecodeParser::getTypeSlot(const Type *Ty) { - if (Ty->isPrimitiveType()) - return Ty->getTypeID(); +using namespace llvm; - // Scan the compaction table for the type if needed. - if (CompactionTable.size() > Type::TypeTyID) { - std::vector &Plane = CompactionTable[Type::TypeTyID]; - if (!Plane.empty()) { - std::vector::iterator I = find(Plane.begin(), Plane.end(), - const_cast(Ty)); - if (I == Plane.end()) - throw std::string("Couldn't find type specified in compaction table!"); - return Type::FirstDerivedTyID + (&*I - &Plane[0]); - } +/// A convenience macro for calling the handler. Makes maintenance easier in +/// case the interface to handler methods changes. +#define HANDLE(method) \ + if ( Handler ) Handler->handle ## method + +/// A convenience macro for handling parsing errors. +#define PARSE_ERROR(inserters) { \ + std::ostringstream errormsg; \ + errormsg << inserters; \ + throw std::string(errormsg.str()); \ } - // Check the function level types first... - TypeValuesListTy::iterator I = find(FunctionTypeValues.begin(), - FunctionTypeValues.end(), Ty); - if (I != FunctionTypeValues.end()) - return Type::FirstDerivedTyID + ModuleTypeValues.size() + - (&*I - &FunctionTypeValues[0]); - - I = find(ModuleTypeValues.begin(), ModuleTypeValues.end(), Ty); - if (I == ModuleTypeValues.end()) - throw std::string("Didn't find type in ModuleTypeValues."); - return Type::FirstDerivedTyID + (&*I - &ModuleTypeValues[0]); +/// @brief A class for maintaining the slot number definition +/// as a placeholder for the actual definition. +template +class PlaceholderDef : public SuperType { + unsigned ID; + PlaceholderDef(); // DO NOT IMPLEMENT + void operator=(const PlaceholderDef &); // DO NOT IMPLEMENT +public: + PlaceholderDef(const Type *Ty, unsigned id) : SuperType(Ty), ID(id) {} + unsigned getID() { return ID; } +}; + +struct ConstantPlaceHolderHelper : public ConstantExpr { + ConstantPlaceHolderHelper(const Type *Ty) + : ConstantExpr(Instruction::UserOp1, Constant::getNullValue(Ty), Ty) {} +}; + +typedef PlaceholderDef ConstPHolder; + +//===----------------------------------------------------------------------===// +// Bytecode Reading Methods +//===----------------------------------------------------------------------===// + +inline bool BytecodeReader::moreInBlock() { + return At < BlockEnd; +} + +inline void BytecodeReader::checkPastBlockEnd(const char * block_name) { + if ( At > BlockEnd ) + PARSE_ERROR("Attempt to read past the end of " << block_name << " block."); +} + +inline void BytecodeReader::align32() { + BufPtr Save = At; + At = (const unsigned char *)((unsigned long)(At+3) & (~3UL)); + if ( At > Save ) + HANDLE(Alignment( At - Save )); + if (At > BlockEnd) + PARSE_ERROR("Ran out of data while aligning!"); } -const Type *BytecodeParser::getType(unsigned ID) { - //cerr << "Looking up Type ID: " << ID << "\n"; +inline unsigned BytecodeReader::read_uint() { + if (At+4 > BlockEnd) + PARSE_ERROR("Ran out of data reading uint!"); + At += 4; + return At[-4] | (At[-3] << 8) | (At[-2] << 16) | (At[-1] << 24); +} + +inline unsigned BytecodeReader::read_vbr_uint() { + unsigned Shift = 0; + unsigned Result = 0; + BufPtr Save = At; + + do { + if (At == BlockEnd) + PARSE_ERROR("Ran out of data reading vbr_uint!"); + Result |= (unsigned)((*At++) & 0x7F) << Shift; + Shift += 7; + } while (At[-1] & 0x80); + HANDLE(VBR32(At-Save)); + return Result; +} + +inline uint64_t BytecodeReader::read_vbr_uint64() { + unsigned Shift = 0; + uint64_t Result = 0; + BufPtr Save = At; + + do { + if (At == BlockEnd) + PARSE_ERROR("Ran out of data reading vbr_uint64!"); + Result |= (uint64_t)((*At++) & 0x7F) << Shift; + Shift += 7; + } while (At[-1] & 0x80); + HANDLE(VBR64(At-Save)); + return Result; +} + +inline int64_t BytecodeReader::read_vbr_int64() { + uint64_t R = read_vbr_uint64(); + if (R & 1) { + if (R != 1) + return -(int64_t)(R >> 1); + else // There is no such thing as -0 with integers. "-0" really means + // 0x8000000000000000. + return 1LL << 63; + } else + return (int64_t)(R >> 1); +} + +inline std::string BytecodeReader::read_str() { + unsigned Size = read_vbr_uint(); + const unsigned char *OldAt = At; + At += Size; + if (At > BlockEnd) // Size invalid? + PARSE_ERROR("Ran out of data reading a string!"); + return std::string((char*)OldAt, Size); +} +inline void BytecodeReader::read_data(void *Ptr, void *End) { + unsigned char *Start = (unsigned char *)Ptr; + unsigned Amount = (unsigned char *)End - Start; + if (At+Amount > BlockEnd) + PARSE_ERROR("Ran out of data!"); + std::copy(At, At+Amount, Start); + At += Amount; +} + +inline void BytecodeReader::read_block(unsigned &Type, unsigned &Size) { + Type = read_uint(); + Size = read_uint(); + BlockStart = At; + if ( At + Size > BlockEnd ) + PARSE_ERROR("Attempt to size a block past end of memory"); + BlockEnd = At + Size; + HANDLE(Block( Type, BlockStart, Size )); +} + +//===----------------------------------------------------------------------===// +// IR Lookup Methods +//===----------------------------------------------------------------------===// + +inline bool BytecodeReader::hasImplicitNull(unsigned TyID ) { + if (!hasExplicitPrimitiveZeros) + return TyID != Type::LabelTyID && TyID != Type::TypeTyID && + TyID != Type::VoidTyID; + return TyID >= Type::FirstDerivedTyID; +} + +const Type *BytecodeReader::getType(unsigned ID) { if (ID < Type::FirstDerivedTyID) if (const Type *T = Type::getPrimitiveType((Type::TypeID)ID)) return T; // Asked for a primitive type... @@ -62,98 +180,124 @@ // Otherwise, derived types need offset... ID -= Type::FirstDerivedTyID; - if (CompactionTable.size() > Type::TypeTyID && - !CompactionTable[Type::TypeTyID].empty()) { - if (ID >= CompactionTable[Type::TypeTyID].size()) - throw std::string("Type ID out of range for compaction table!"); - return cast(CompactionTable[Type::TypeTyID][ID]); + if (!CompactionTypes.empty()) { + if (ID >= CompactionTypes.size()) + PARSE_ERROR("Type ID out of range for compaction table!"); + return CompactionTypes[ID]; } // Is it a module-level type? - if (ID < ModuleTypeValues.size()) - return ModuleTypeValues[ID].get(); + if (ID < ModuleTypes.size()) + return ModuleTypes[ID].get(); - // Nope, is it a function-level type? - ID -= ModuleTypeValues.size(); - if (ID < FunctionTypeValues.size()) - return FunctionTypeValues[ID].get(); + // Nope, is it a function-level type? + ID -= ModuleTypes.size(); + if (ID < FunctionTypes.size()) + return FunctionTypes[ID].get(); - throw std::string("Illegal type reference!"); + PARSE_ERROR("Illegal type reference!"); + return Type::VoidTy; } -static inline bool hasImplicitNull(unsigned TyID, bool EncodesPrimitiveZeros) { - if (!EncodesPrimitiveZeros) - return TyID != Type::LabelTyID && TyID != Type::TypeTyID && - TyID != Type::VoidTyID; - return TyID >= Type::FirstDerivedTyID; -} +unsigned BytecodeReader::getTypeSlot(const Type *Ty) { + if (Ty->isPrimitiveType()) + return Ty->getTypeID(); -unsigned BytecodeParser::insertValue(Value *Val, unsigned type, - ValueTable &ValueTab) { - assert((!isa(Val) || !cast(Val)->isNullValue()) || - !hasImplicitNull(type, hasExplicitPrimitiveZeros) && - "Cannot read null values from bytecode!"); - assert(type != Type::TypeTyID && "Types should never be insertValue'd!"); + // Scan the compaction table for the type if needed. + if (!CompactionTypes.empty()) { + std::vector::const_iterator I = + find(CompactionTypes.begin(), CompactionTypes.end(), Ty); + + if (I == CompactionTypes.end()) + PARSE_ERROR("Couldn't find type specified in compaction table!"); + return Type::FirstDerivedTyID + (&*I - &CompactionTypes[0]); + } - if (ValueTab.size() <= type) - ValueTab.resize(type+1); + // Check the function level types first... + TypeListTy::iterator I = find(FunctionTypes.begin(), FunctionTypes.end(), Ty); - if (!ValueTab[type]) ValueTab[type] = new ValueList(); + if (I != FunctionTypes.end()) + return Type::FirstDerivedTyID + ModuleTypes.size() + + (&*I - &FunctionTypes[0]); + + // Check the module level types now... + I = find(ModuleTypes.begin(), ModuleTypes.end(), Ty); + if (I == ModuleTypes.end()) + PARSE_ERROR("Didn't find type in ModuleTypes."); + return Type::FirstDerivedTyID + (&*I - &ModuleTypes[0]); +} - //cerr << "insertValue Values[" << type << "][" << ValueTab[type].size() - // << "] = " << Val << "\n"; - ValueTab[type]->push_back(Val); +const Type *BytecodeReader::getGlobalTableType(unsigned Slot) { + if (Slot < Type::FirstDerivedTyID) { + const Type *Ty = Type::getPrimitiveType((Type::TypeID)Slot); + assert(Ty && "Not a primitive type ID?"); + return Ty; + } + Slot -= Type::FirstDerivedTyID; + if (Slot >= ModuleTypes.size()) + PARSE_ERROR("Illegal compaction table type reference!"); + return ModuleTypes[Slot]; +} - bool HasOffset = hasImplicitNull(type, hasExplicitPrimitiveZeros); - return ValueTab[type]->size()-1 + HasOffset; +unsigned BytecodeReader::getGlobalTableTypeSlot(const Type *Ty) { + if (Ty->isPrimitiveType()) + return Ty->getTypeID(); + TypeListTy::iterator I = find(ModuleTypes.begin(), + ModuleTypes.end(), Ty); + if (I == ModuleTypes.end()) + PARSE_ERROR("Didn't find type in ModuleTypes."); + return Type::FirstDerivedTyID + (&*I - &ModuleTypes[0]); } -Value *BytecodeParser::getValue(unsigned type, unsigned oNum, bool Create) { +Value * BytecodeReader::getValue(unsigned type, unsigned oNum, bool Create) { assert(type != Type::TypeTyID && "getValue() cannot get types!"); assert(type != Type::LabelTyID && "getValue() cannot get blocks!"); unsigned Num = oNum; // If there is a compaction table active, it defines the low-level numbers. // If not, the module values define the low-level numbers. - if (CompactionTable.size() > type && !CompactionTable[type].empty()) { - if (Num < CompactionTable[type].size()) - return CompactionTable[type][Num]; - Num -= CompactionTable[type].size(); + if (CompactionValues.size() > type && !CompactionValues[type].empty()) { + if (Num < CompactionValues[type].size()) + return CompactionValues[type][Num]; + Num -= CompactionValues[type].size(); } else { - // If the type plane was compactified, figure out the global type ID. + // By default, the global type id is the type id passed in unsigned GlobalTyID = type; - if (CompactionTable.size() > Type::TypeTyID && - !CompactionTable[Type::TypeTyID].empty() && - type >= Type::FirstDerivedTyID) { - std::vector &TypePlane = CompactionTable[Type::TypeTyID]; - const Type *Ty = cast(TypePlane[type-Type::FirstDerivedTyID]); - TypeValuesListTy::iterator I = - find(ModuleTypeValues.begin(), ModuleTypeValues.end(), Ty); - assert(I != ModuleTypeValues.end()); - GlobalTyID = Type::FirstDerivedTyID + (&*I - &ModuleTypeValues[0]); + + // If the type plane was compactified, figure out the global type ID + // by adding the derived type ids and the distance. + if (CompactionValues.size() > Type::TypeTyID && + !CompactionTypes.empty() && + type >= Type::FirstDerivedTyID) { + const Type *Ty = CompactionTypes[type-Type::FirstDerivedTyID]; + TypeListTy::iterator I = + find(ModuleTypes.begin(), ModuleTypes.end(), Ty); + assert(I != ModuleTypes.end()); + GlobalTyID = Type::FirstDerivedTyID + (&*I - &ModuleTypes[0]); } - if (hasImplicitNull(GlobalTyID, hasExplicitPrimitiveZeros)) { + if (hasImplicitNull(GlobalTyID)) { if (Num == 0) - return Constant::getNullValue(getType(type)); + return Constant::getNullValue(getType(type)); --Num; } if (GlobalTyID < ModuleValues.size() && ModuleValues[GlobalTyID]) { if (Num < ModuleValues[GlobalTyID]->size()) - return ModuleValues[GlobalTyID]->getOperand(Num); + return ModuleValues[GlobalTyID]->getOperand(Num); Num -= ModuleValues[GlobalTyID]->size(); } } - if (Values.size() > type && Values[type] && Num < Values[type]->size()) - return Values[type]->getOperand(Num); + if (FunctionValues.size() > type && + FunctionValues[type] && + Num < FunctionValues[type]->size()) + return FunctionValues[type]->getOperand(Num); if (!Create) return 0; // Do not create a placeholder? std::pair KeyValue(type, oNum); - std::map, Value*>::iterator I = - ForwardReferences.lower_bound(KeyValue); + ForwardReferenceMap::iterator I = ForwardReferences.lower_bound(KeyValue); if (I != ForwardReferences.end() && I->first == KeyValue) return I->second; // We have already created this placeholder @@ -162,32 +306,27 @@ return Val; } -/// getBasicBlock - Get a particular numbered basic block, which might be a -/// forward reference. This works together with ParseBasicBlock to handle these -/// forward references in a clean manner. -/// -BasicBlock *BytecodeParser::getBasicBlock(unsigned ID) { - // Make sure there is room in the table... - if (ParsedBasicBlocks.size() <= ID) ParsedBasicBlocks.resize(ID+1); - - // First check to see if this is a backwards reference, i.e., ParseBasicBlock - // has already created this block, or if the forward reference has already - // been created. - if (ParsedBasicBlocks[ID]) - return ParsedBasicBlocks[ID]; +Value* BytecodeReader::getGlobalTableValue(const Type *Ty, unsigned SlotNo) { + // FIXME: getTypeSlot is inefficient! + unsigned TyID = getGlobalTableTypeSlot(Ty); + + if (TyID != Type::LabelTyID) { + if (SlotNo == 0) + return Constant::getNullValue(Ty); + --SlotNo; + } - // Otherwise, the basic block has not yet been created. Do so and add it to - // the ParsedBasicBlocks list. - return ParsedBasicBlocks[ID] = new BasicBlock(); + if (TyID >= ModuleValues.size() || ModuleValues[TyID] == 0 || + SlotNo >= ModuleValues[TyID]->size()) { + PARSE_ERROR("Corrupt compaction table entry!" + << TyID << ", " << SlotNo << ": " << ModuleValues.size() << ", " + << (void*)ModuleValues[TyID] << ", " + << ModuleValues[TyID]->size() << "\n"); + } + return ModuleValues[TyID]->getOperand(SlotNo); } -/// getConstantValue - Just like getValue, except that it returns a null pointer -/// only on error. It always returns a constant (meaning that if the value is -/// defined, but is not a constant, that is an error). If the specified -/// constant hasn't been parsed yet, a placeholder is defined and used. Later, -/// after the real value is parsed, the placeholder is eliminated. -/// -Constant *BytecodeParser::getConstantValue(unsigned TypeSlot, unsigned Slot) { +Constant* BytecodeReader::getConstantValue(unsigned TypeSlot, unsigned Slot) { if (Value *V = getValue(TypeSlot, Slot, false)) if (Constant *C = dyn_cast(V)) return C; // If we already have the value parsed, just return it @@ -196,19 +335,17 @@ // to infest bytecode files. return ConstantPointerRef::get(GV); else - throw std::string("Reference of a value is expected to be a constant!"); + PARSE_ERROR("Reference of a value is expected to be a constant!"); const Type *Ty = getType(TypeSlot); std::pair Key(Ty, Slot); ConstantRefsType::iterator I = ConstantFwdRefs.lower_bound(Key); if (I != ConstantFwdRefs.end() && I->first == Key) { - BCR_TRACE(5, "Previous forward ref found!\n"); return I->second; } else { // Create a placeholder for the constant reference and // keep track of the fact that we have a forward ref to recycle it - BCR_TRACE(5, "Creating new forward ref to a constant!\n"); Constant *C = new ConstPHolder(Ty, Slot); // Keep track of the fact that we have a forward ref to recycle it @@ -217,12 +354,418 @@ } } +//===----------------------------------------------------------------------===// +// IR Construction Methods +//===----------------------------------------------------------------------===// + +unsigned BytecodeReader::insertValue( + Value *Val, unsigned type, ValueTable &ValueTab) { + assert((!isa(Val) || !cast(Val)->isNullValue()) || + !hasImplicitNull(type) && + "Cannot read null values from bytecode!"); + assert(type != Type::TypeTyID && "Types should never be insertValue'd!"); + + if (ValueTab.size() <= type) + ValueTab.resize(type+1); + + if (!ValueTab[type]) ValueTab[type] = new ValueList(); + + ValueTab[type]->push_back(Val); + + bool HasOffset = hasImplicitNull(type); + return ValueTab[type]->size()-1 + HasOffset; +} + +void BytecodeReader::insertArguments(Function* F ) { + const FunctionType *FT = F->getFunctionType(); + Function::aiterator AI = F->abegin(); + for (FunctionType::param_iterator It = FT->param_begin(); + It != FT->param_end(); ++It, ++AI) + insertValue(AI, getTypeSlot(AI->getType()), FunctionValues); +} + +//===----------------------------------------------------------------------===// +// Bytecode Parsing Methods +//===----------------------------------------------------------------------===// + +void BytecodeReader::ParseInstruction(std::vector &Oprnds, + BasicBlock* BB) { + BufPtr SaveAt = At; + + // Clear instruction data + Oprnds.clear(); + unsigned iType = 0; + unsigned Opcode = 0; + unsigned Op = read_uint(); + + // bits Instruction format: Common to all formats + // -------------------------- + // 01-00: Opcode type, fixed to 1. + // 07-02: Opcode + Opcode = (Op >> 2) & 63; + Oprnds.resize((Op >> 0) & 03); + + // Extract the operands + switch (Oprnds.size()) { + case 1: + // bits Instruction format: + // -------------------------- + // 19-08: Resulting type plane + // 31-20: Operand #1 (if set to (2^12-1), then zero operands) + // + iType = (Op >> 8) & 4095; + Oprnds[0] = (Op >> 20) & 4095; + if (Oprnds[0] == 4095) // Handle special encoding for 0 operands... + Oprnds.resize(0); + break; + case 2: + // bits Instruction format: + // -------------------------- + // 15-08: Resulting type plane + // 23-16: Operand #1 + // 31-24: Operand #2 + // + iType = (Op >> 8) & 255; + Oprnds[0] = (Op >> 16) & 255; + Oprnds[1] = (Op >> 24) & 255; + break; + case 3: + // bits Instruction format: + // -------------------------- + // 13-08: Resulting type plane + // 19-14: Operand #1 + // 25-20: Operand #2 + // 31-26: Operand #3 + // + iType = (Op >> 8) & 63; + Oprnds[0] = (Op >> 14) & 63; + Oprnds[1] = (Op >> 20) & 63; + Oprnds[2] = (Op >> 26) & 63; + break; + case 0: + At -= 4; // Hrm, try this again... + Opcode = read_vbr_uint(); + Opcode >>= 2; + iType = read_vbr_uint(); + + unsigned NumOprnds = read_vbr_uint(); + Oprnds.resize(NumOprnds); + + if (NumOprnds == 0) + PARSE_ERROR("Zero-argument instruction found; this is invalid."); + + for (unsigned i = 0; i != NumOprnds; ++i) + Oprnds[i] = read_vbr_uint(); + align32(); + break; + } + + // Get the type of the instruction + const Type *InstTy = getType(iType); + + // Hae enough to inform the handler now + HANDLE(Instruction(Opcode, InstTy, Oprnds, At-SaveAt)); + + // Declare the resulting instruction we'll build. + Instruction *Result = 0; + + // Handle binary operators + if (Opcode >= Instruction::BinaryOpsBegin && + Opcode < Instruction::BinaryOpsEnd && Oprnds.size() == 2) + Result = BinaryOperator::create((Instruction::BinaryOps)Opcode, + getValue(iType, Oprnds[0]), + getValue(iType, Oprnds[1])); + + switch (Opcode) { + default: + if (Result == 0) PARSE_ERROR("Illegal instruction read!"); + break; + case Instruction::VAArg: + Result = new VAArgInst(getValue(iType, Oprnds[0]), getType(Oprnds[1])); + break; + case Instruction::VANext: + Result = new VANextInst(getValue(iType, Oprnds[0]), getType(Oprnds[1])); + break; + case Instruction::Cast: + Result = new CastInst(getValue(iType, Oprnds[0]), getType(Oprnds[1])); + break; + case Instruction::Select: + Result = new SelectInst(getValue(Type::BoolTyID, Oprnds[0]), + getValue(iType, Oprnds[1]), + getValue(iType, Oprnds[2])); + break; + case Instruction::PHI: { + if (Oprnds.size() == 0 || (Oprnds.size() & 1)) + PARSE_ERROR("Invalid phi node encountered!\n"); + + PHINode *PN = new PHINode(InstTy); + PN->op_reserve(Oprnds.size()); + for (unsigned i = 0, e = Oprnds.size(); i != e; i += 2) + PN->addIncoming(getValue(iType, Oprnds[i]), getBasicBlock(Oprnds[i+1])); + Result = PN; + break; + } + + case Instruction::Shl: + case Instruction::Shr: + Result = new ShiftInst((Instruction::OtherOps)Opcode, + getValue(iType, Oprnds[0]), + getValue(Type::UByteTyID, Oprnds[1])); + break; + case Instruction::Ret: + if (Oprnds.size() == 0) + Result = new ReturnInst(); + else if (Oprnds.size() == 1) + Result = new ReturnInst(getValue(iType, Oprnds[0])); + else + PARSE_ERROR("Unrecognized instruction!"); + break; + + case Instruction::Br: + if (Oprnds.size() == 1) + Result = new BranchInst(getBasicBlock(Oprnds[0])); + else if (Oprnds.size() == 3) + Result = new BranchInst(getBasicBlock(Oprnds[0]), + getBasicBlock(Oprnds[1]), getValue(Type::BoolTyID , Oprnds[2])); + else + PARSE_ERROR("Invalid number of operands for a 'br' instruction!"); + break; + case Instruction::Switch: { + if (Oprnds.size() & 1) + PARSE_ERROR("Switch statement with odd number of arguments!"); + + SwitchInst *I = new SwitchInst(getValue(iType, Oprnds[0]), + getBasicBlock(Oprnds[1])); + for (unsigned i = 2, e = Oprnds.size(); i != e; i += 2) + I->addCase(cast(getValue(iType, Oprnds[i])), + getBasicBlock(Oprnds[i+1])); + Result = I; + break; + } + + case Instruction::Call: { + if (Oprnds.size() == 0) + PARSE_ERROR("Invalid call instruction encountered!"); + + Value *F = getValue(iType, Oprnds[0]); + + // Check to make sure we have a pointer to function type + const PointerType *PTy = dyn_cast(F->getType()); + if (PTy == 0) PARSE_ERROR("Call to non function pointer value!"); + const FunctionType *FTy = dyn_cast(PTy->getElementType()); + if (FTy == 0) PARSE_ERROR("Call to non function pointer value!"); + + std::vector Params; + if (!FTy->isVarArg()) { + FunctionType::param_iterator It = FTy->param_begin(); + + for (unsigned i = 1, e = Oprnds.size(); i != e; ++i) { + if (It == FTy->param_end()) + PARSE_ERROR("Invalid call instruction!"); + Params.push_back(getValue(getTypeSlot(*It++), Oprnds[i])); + } + if (It != FTy->param_end()) + PARSE_ERROR("Invalid call instruction!"); + } else { + Oprnds.erase(Oprnds.begin(), Oprnds.begin()+1); + + unsigned FirstVariableOperand; + if (Oprnds.size() < FTy->getNumParams()) + PARSE_ERROR("Call instruction missing operands!"); + + // Read all of the fixed arguments + for (unsigned i = 0, e = FTy->getNumParams(); i != e; ++i) + Params.push_back(getValue(getTypeSlot(FTy->getParamType(i)),Oprnds[i])); + + FirstVariableOperand = FTy->getNumParams(); + + if ((Oprnds.size()-FirstVariableOperand) & 1) // Must be pairs of type/value + PARSE_ERROR("Invalid call instruction!"); + + for (unsigned i = FirstVariableOperand, e = Oprnds.size(); + i != e; i += 2) + Params.push_back(getValue(Oprnds[i], Oprnds[i+1])); + } + + Result = new CallInst(F, Params); + break; + } + case Instruction::Invoke: { + if (Oprnds.size() < 3) PARSE_ERROR("Invalid invoke instruction!"); + Value *F = getValue(iType, Oprnds[0]); + + // Check to make sure we have a pointer to function type + const PointerType *PTy = dyn_cast(F->getType()); + if (PTy == 0) PARSE_ERROR("Invoke to non function pointer value!"); + const FunctionType *FTy = dyn_cast(PTy->getElementType()); + if (FTy == 0) PARSE_ERROR("Invoke to non function pointer value!"); + + std::vector Params; + BasicBlock *Normal, *Except; + + if (!FTy->isVarArg()) { + Normal = getBasicBlock(Oprnds[1]); + Except = getBasicBlock(Oprnds[2]); + + FunctionType::param_iterator It = FTy->param_begin(); + for (unsigned i = 3, e = Oprnds.size(); i != e; ++i) { + if (It == FTy->param_end()) + PARSE_ERROR("Invalid invoke instruction!"); + Params.push_back(getValue(getTypeSlot(*It++), Oprnds[i])); + } + if (It != FTy->param_end()) + PARSE_ERROR("Invalid invoke instruction!"); + } else { + Oprnds.erase(Oprnds.begin(), Oprnds.begin()+1); + + Normal = getBasicBlock(Oprnds[0]); + Except = getBasicBlock(Oprnds[1]); + + unsigned FirstVariableArgument = FTy->getNumParams()+2; + for (unsigned i = 2; i != FirstVariableArgument; ++i) + Params.push_back(getValue(getTypeSlot(FTy->getParamType(i-2)), + Oprnds[i])); + + if (Oprnds.size()-FirstVariableArgument & 1) // Must be type/value pairs + PARSE_ERROR("Invalid invoke instruction!"); + + for (unsigned i = FirstVariableArgument; i < Oprnds.size(); i += 2) + Params.push_back(getValue(Oprnds[i], Oprnds[i+1])); + } + + Result = new InvokeInst(F, Normal, Except, Params); + break; + } + case Instruction::Malloc: + if (Oprnds.size() > 2) PARSE_ERROR("Invalid malloc instruction!"); + if (!isa(InstTy)) + PARSE_ERROR("Invalid malloc instruction!"); + + Result = new MallocInst(cast(InstTy)->getElementType(), + Oprnds.size() ? getValue(Type::UIntTyID, + Oprnds[0]) : 0); + break; + + case Instruction::Alloca: + if (Oprnds.size() > 2) PARSE_ERROR("Invalid alloca instruction!"); + if (!isa(InstTy)) + PARSE_ERROR("Invalid alloca instruction!"); + + Result = new AllocaInst(cast(InstTy)->getElementType(), + Oprnds.size() ? getValue(Type::UIntTyID, + Oprnds[0]) :0); + break; + case Instruction::Free: + if (!isa(InstTy)) + PARSE_ERROR("Invalid free instruction!"); + Result = new FreeInst(getValue(iType, Oprnds[0])); + break; + case Instruction::GetElementPtr: { + if (Oprnds.size() == 0 || !isa(InstTy)) + PARSE_ERROR("Invalid getelementptr instruction!"); + + std::vector Idx; + + const Type *NextTy = InstTy; + for (unsigned i = 1, e = Oprnds.size(); i != e; ++i) { + const CompositeType *TopTy = dyn_cast_or_null(NextTy); + if (!TopTy) PARSE_ERROR("Invalid getelementptr instruction!"); + + unsigned ValIdx = Oprnds[i]; + unsigned IdxTy = 0; + if (!hasRestrictedGEPTypes) { + // Struct indices are always uints, sequential type indices can be any + // of the 32 or 64-bit integer types. The actual choice of type is + // encoded in the low two bits of the slot number. + if (isa(TopTy)) + IdxTy = Type::UIntTyID; + else { + switch (ValIdx & 3) { + default: + case 0: IdxTy = Type::UIntTyID; break; + case 1: IdxTy = Type::IntTyID; break; + case 2: IdxTy = Type::ULongTyID; break; + case 3: IdxTy = Type::LongTyID; break; + } + ValIdx >>= 2; + } + } else { + IdxTy = isa(TopTy) ? Type::UByteTyID : Type::LongTyID; + } + + Idx.push_back(getValue(IdxTy, ValIdx)); + + // Convert ubyte struct indices into uint struct indices. + if (isa(TopTy) && hasRestrictedGEPTypes) + if (ConstantUInt *C = dyn_cast(Idx.back())) + Idx[Idx.size()-1] = ConstantExpr::getCast(C, Type::UIntTy); + + NextTy = GetElementPtrInst::getIndexedType(InstTy, Idx, true); + } + + Result = new GetElementPtrInst(getValue(iType, Oprnds[0]), Idx); + break; + } + + case 62: // volatile load + case Instruction::Load: + if (Oprnds.size() != 1 || !isa(InstTy)) + PARSE_ERROR("Invalid load instruction!"); + Result = new LoadInst(getValue(iType, Oprnds[0]), "", Opcode == 62); + break; + + case 63: // volatile store + case Instruction::Store: { + if (!isa(InstTy) || Oprnds.size() != 2) + PARSE_ERROR("Invalid store instruction!"); + + Value *Ptr = getValue(iType, Oprnds[1]); + const Type *ValTy = cast(Ptr->getType())->getElementType(); + Result = new StoreInst(getValue(getTypeSlot(ValTy), Oprnds[0]), Ptr, + Opcode == 63); + break; + } + case Instruction::Unwind: + if (Oprnds.size() != 0) PARSE_ERROR("Invalid unwind instruction!"); + Result = new UnwindInst(); + break; + } // end switch(Opcode) + + unsigned TypeSlot; + if (Result->getType() == InstTy) + TypeSlot = iType; + else + TypeSlot = getTypeSlot(Result->getType()); + + insertValue(Result, TypeSlot, FunctionValues); + BB->getInstList().push_back(Result); +} + +/// getBasicBlock - Get a particular numbered basic block, which might be a +/// forward reference. This works together with ParseBasicBlock to handle these +/// forward references in a clean manner. +BasicBlock *BytecodeReader::getBasicBlock(unsigned ID) { + // Make sure there is room in the table... + if (ParsedBasicBlocks.size() <= ID) ParsedBasicBlocks.resize(ID+1); + + // First check to see if this is a backwards reference, i.e., ParseBasicBlock + // has already created this block, or if the forward reference has already + // been created. + if (ParsedBasicBlocks[ID]) + return ParsedBasicBlocks[ID]; + + // Otherwise, the basic block has not yet been created. Do so and add it to + // the ParsedBasicBlocks list. + return ParsedBasicBlocks[ID] = new BasicBlock(); +} + /// ParseBasicBlock - In LLVM 1.0 bytecode files, we used to output one /// basicblock at a time. This method reads in one of the basicblock packets. -BasicBlock *BytecodeParser::ParseBasicBlock(const unsigned char *&Buf, - const unsigned char *EndBuf, - unsigned BlockNo) { - BasicBlock *BB; +BasicBlock *BytecodeReader::ParseBasicBlock( unsigned BlockNo) { + HANDLE(BasicBlockBegin( BlockNo )); + + BasicBlock *BB = 0; + if (ParsedBasicBlocks.size() == BlockNo) ParsedBasicBlocks.push_back(BB = new BasicBlock()); else if (ParsedBasicBlocks[BlockNo] == 0) @@ -230,24 +773,23 @@ else BB = ParsedBasicBlocks[BlockNo]; - std::vector Args; - while (Buf < EndBuf) - ParseInstruction(Buf, EndBuf, Args, BB); + std::vector Operands; + while ( moreInBlock() ) + ParseInstruction(Operands, BB); + HANDLE(BasicBlockEnd( BlockNo )); return BB; } - /// ParseInstructionList - Parse all of the BasicBlock's & Instruction's in the /// body of a function. In post 1.0 bytecode files, we no longer emit basic /// block individually, in order to avoid per-basic-block overhead. -unsigned BytecodeParser::ParseInstructionList(Function *F, - const unsigned char *&Buf, - const unsigned char *EndBuf) { +unsigned BytecodeReader::ParseInstructionList(Function* F) { unsigned BlockNo = 0; std::vector Args; - while (Buf < EndBuf) { + while ( moreInBlock() ) { + HANDLE(BasicBlockBegin( BlockNo )); BasicBlock *BB; if (ParsedBasicBlocks.size() == BlockNo) ParsedBasicBlocks.push_back(BB = new BasicBlock()); @@ -255,24 +797,25 @@ BB = ParsedBasicBlocks[BlockNo] = new BasicBlock(); else BB = ParsedBasicBlocks[BlockNo]; + HANDLE(BasicBlockEnd( BlockNo )); ++BlockNo; F->getBasicBlockList().push_back(BB); // Read instructions into this basic block until we get to a terminator - while (Buf < EndBuf && !BB->getTerminator()) - ParseInstruction(Buf, EndBuf, Args, BB); + while ( moreInBlock() && !BB->getTerminator()) + ParseInstruction(Args, BB); if (!BB->getTerminator()) - throw std::string("Non-terminated basic block found!"); + PARSE_ERROR("Non-terminated basic block found!"); } return BlockNo; } -void BytecodeParser::ParseSymbolTable(const unsigned char *&Buf, - const unsigned char *EndBuf, - SymbolTable *ST, - Function *CurrentFunction) { +void BytecodeReader::ParseSymbolTable(Function *CurrentFunction, + SymbolTable *ST) { + HANDLE(SymbolTableBegin(CurrentFunction,ST)); + // Allow efficient basic block lookup by number. std::vector BBMap; if (CurrentFunction) @@ -280,18 +823,16 @@ E = CurrentFunction->end(); I != E; ++I) BBMap.push_back(I); - while (Buf < EndBuf) { + while ( moreInBlock() ) { // Symtab block header: [num entries][type id number] - unsigned NumEntries = read_vbr_uint(Buf, EndBuf); - unsigned Typ = read_vbr_uint(Buf, EndBuf); + unsigned NumEntries = read_vbr_uint(); + unsigned Typ = read_vbr_uint(); const Type *Ty = getType(Typ); - BCR_TRACE(3, "Plane Type: '" << *Ty << "' with " << NumEntries << - " entries\n"); for (unsigned i = 0; i != NumEntries; ++i) { // Symtab entry: [def slot #][name] - unsigned slot = read_vbr_uint(Buf, EndBuf); - std::string Name = read_str(Buf, EndBuf); + unsigned slot = read_vbr_uint(); + std::string Name = read_str(); Value *V = 0; if (Typ == Type::TypeTyID) @@ -303,76 +844,444 @@ V = getValue(Typ, slot, false); // Find mapping... } if (V == 0) - throw "Failed value look-up for name '" + Name + "'"; - BCR_TRACE(4, "Map: '" << Name << "' to #" << slot << ":" << *V; - if (!isa(V)) std::cerr << "\n"); + PARSE_ERROR("Failed value look-up for name '" << Name << "'"); V->setName(Name, ST); } } + checkPastBlockEnd("Symbol Table"); + HANDLE(SymbolTableEnd()); +} + +void BytecodeReader::ParseCompactionTable() { + + HANDLE(CompactionTableBegin()); + + while ( moreInBlock() ) { + unsigned NumEntries = read_vbr_uint(); + unsigned Ty; + + if ((NumEntries & 3) == 3) { + NumEntries >>= 2; + Ty = read_vbr_uint(); + } else { + Ty = NumEntries >> 2; + NumEntries &= 3; + } + + if (Ty >= CompactionValues.size()) + CompactionValues.resize(Ty+1); + + if (!CompactionValues[Ty].empty()) + PARSE_ERROR("Compaction table plane contains multiple entries!"); + + HANDLE(CompactionTablePlane( Ty, NumEntries )); + + if (Ty == Type::TypeTyID) { + for (unsigned i = 0; i != NumEntries; ++i) { + unsigned TypeSlot = read_vbr_uint(); + const Type *Typ = getGlobalTableType(TypeSlot); + CompactionTypes.push_back(Typ); + HANDLE(CompactionTableType( i, TypeSlot, Typ )); + } + CompactionTypes.resize(NumEntries+Type::FirstDerivedTyID); + } else { + const Type *Typ = getType(Ty); + // Push the implicit zero + CompactionValues[Ty].push_back(Constant::getNullValue(Typ)); + for (unsigned i = 0; i != NumEntries; ++i) { + unsigned ValSlot = read_vbr_uint(); + Value *V = getGlobalTableValue(Typ, ValSlot); + CompactionValues[Ty].push_back(V); + HANDLE(CompactionTableValue( i, Ty, ValSlot, Typ )); + } + } + } + HANDLE(CompactionTableEnd()); +} + +// Parse a single type constant. +const Type *BytecodeReader::ParseTypeConstant() { + unsigned PrimType = read_vbr_uint(); + + const Type *Result = 0; + if ((Result = Type::getPrimitiveType((Type::TypeID)PrimType))) + return Result; + + switch (PrimType) { + case Type::FunctionTyID: { + const Type *RetType = getType(read_vbr_uint()); + + unsigned NumParams = read_vbr_uint(); + + std::vector Params; + while (NumParams--) + Params.push_back(getType(read_vbr_uint())); + + bool isVarArg = Params.size() && Params.back() == Type::VoidTy; + if (isVarArg) Params.pop_back(); + + Result = FunctionType::get(RetType, Params, isVarArg); + break; + } + case Type::ArrayTyID: { + unsigned ElTyp = read_vbr_uint(); + const Type *ElementType = getType(ElTyp); + + unsigned NumElements = read_vbr_uint(); + + Result = ArrayType::get(ElementType, NumElements); + break; + } + case Type::StructTyID: { + std::vector Elements; + unsigned Typ = read_vbr_uint(); + while (Typ) { // List is terminated by void/0 typeid + Elements.push_back(getType(Typ)); + Typ = read_vbr_uint(); + } + + Result = StructType::get(Elements); + break; + } + case Type::PointerTyID: { + unsigned ElTyp = read_vbr_uint(); + Result = PointerType::get(getType(ElTyp)); + break; + } + + case Type::OpaqueTyID: { + Result = OpaqueType::get(); + break; + } + + default: + PARSE_ERROR("Don't know how to deserialize primitive type" << PrimType << "\n"); + break; + } + HANDLE(Type( Result )); + return Result; +} + +// ParseTypeConstants - We have to use this weird code to handle recursive +// types. We know that recursive types will only reference the current slab of +// values in the type plane, but they can forward reference types before they +// have been read. For example, Type #0 might be '{ Ty#1 }' and Type #1 might +// be 'Ty#0*'. When reading Type #0, type number one doesn't exist. To fix +// this ugly problem, we pessimistically insert an opaque type for each type we +// are about to read. This means that forward references will resolve to +// something and when we reread the type later, we can replace the opaque type +// with a new resolved concrete type. +// +void BytecodeReader::ParseTypeConstants(TypeListTy &Tab, unsigned NumEntries){ + assert(Tab.size() == 0 && "should not have read type constants in before!"); + + // Insert a bunch of opaque types to be resolved later... + Tab.reserve(NumEntries); + for (unsigned i = 0; i != NumEntries; ++i) + Tab.push_back(OpaqueType::get()); + + // Loop through reading all of the types. Forward types will make use of the + // opaque types just inserted. + // + for (unsigned i = 0; i != NumEntries; ++i) { + const Type *NewTy = ParseTypeConstant(), *OldTy = Tab[i].get(); + if (NewTy == 0) PARSE_ERROR("Couldn't parse type!"); + + // Don't directly push the new type on the Tab. Instead we want to replace + // the opaque type we previously inserted with the new concrete value. This + // approach helps with forward references to types. The refinement from the + // abstract (opaque) type to the new type causes all uses of the abstract + // type to use the concrete type (NewTy). This will also cause the opaque + // type to be deleted. + cast(const_cast(OldTy))->refineAbstractTypeTo(NewTy); + + // This should have replaced the old opaque type with the new type in the + // value table... or with a preexisting type that was already in the system. + // Let's just make sure it did. + assert(Tab[i] != OldTy && "refineAbstractType didn't work!"); + } +} + +Constant *BytecodeReader::ParseConstantValue( unsigned TypeID) { + // We must check for a ConstantExpr before switching by type because + // a ConstantExpr can be of any type, and has no explicit value. + // + // 0 if not expr; numArgs if is expr + unsigned isExprNumArgs = read_vbr_uint(); + + if (isExprNumArgs) { + // FIXME: Encoding of constant exprs could be much more compact! + std::vector ArgVec; + ArgVec.reserve(isExprNumArgs); + unsigned Opcode = read_vbr_uint(); + + // Read the slot number and types of each of the arguments + for (unsigned i = 0; i != isExprNumArgs; ++i) { + unsigned ArgValSlot = read_vbr_uint(); + unsigned ArgTypeSlot = read_vbr_uint(); + + // Get the arg value from its slot if it exists, otherwise a placeholder + ArgVec.push_back(getConstantValue(ArgTypeSlot, ArgValSlot)); + } + + // Construct a ConstantExpr of the appropriate kind + if (isExprNumArgs == 1) { // All one-operand expressions + assert(Opcode == Instruction::Cast); + Constant* Result = ConstantExpr::getCast(ArgVec[0], getType(TypeID)); + HANDLE(ConstantExpression(Opcode, ArgVec, Result)); + return Result; + } else if (Opcode == Instruction::GetElementPtr) { // GetElementPtr + std::vector IdxList(ArgVec.begin()+1, ArgVec.end()); + + if (hasRestrictedGEPTypes) { + const Type *BaseTy = ArgVec[0]->getType(); + generic_gep_type_iterator::iterator> + GTI = gep_type_begin(BaseTy, IdxList.begin(), IdxList.end()), + E = gep_type_end(BaseTy, IdxList.begin(), IdxList.end()); + for (unsigned i = 0; GTI != E; ++GTI, ++i) + if (isa(*GTI)) { + if (IdxList[i]->getType() != Type::UByteTy) + PARSE_ERROR("Invalid index for getelementptr!"); + IdxList[i] = ConstantExpr::getCast(IdxList[i], Type::UIntTy); + } + } + + Constant* Result = ConstantExpr::getGetElementPtr(ArgVec[0], IdxList); + HANDLE(ConstantExpression(Opcode, ArgVec, Result)); + return Result; + } else if (Opcode == Instruction::Select) { + assert(ArgVec.size() == 3); + Constant* Result = ConstantExpr::getSelect(ArgVec[0], ArgVec[1], + ArgVec[2]); + HANDLE(ConstantExpression(Opcode, ArgVec, Result)); + return Result; + } else { // All other 2-operand expressions + Constant* Result = ConstantExpr::get(Opcode, ArgVec[0], ArgVec[1]); + HANDLE(ConstantExpression(Opcode, ArgVec, Result)); + return Result; + } + } + + // Ok, not an ConstantExpr. We now know how to read the given type... + const Type *Ty = getType(TypeID); + switch (Ty->getTypeID()) { + case Type::BoolTyID: { + unsigned Val = read_vbr_uint(); + if (Val != 0 && Val != 1) + PARSE_ERROR("Invalid boolean value read."); + Constant* Result = ConstantBool::get(Val == 1); + HANDLE(ConstantValue(Result)); + return Result; + } + + case Type::UByteTyID: // Unsigned integer types... + case Type::UShortTyID: + case Type::UIntTyID: { + unsigned Val = read_vbr_uint(); + if (!ConstantUInt::isValueValidForType(Ty, Val)) + PARSE_ERROR("Invalid unsigned byte/short/int read."); + Constant* Result = ConstantUInt::get(Ty, Val); + HANDLE(ConstantValue(Result)); + return Result; + } + + case Type::ULongTyID: { + Constant* Result = ConstantUInt::get(Ty, read_vbr_uint64()); + HANDLE(ConstantValue(Result)); + return Result; + } + + case Type::SByteTyID: // Signed integer types... + case Type::ShortTyID: + case Type::IntTyID: { + case Type::LongTyID: + int64_t Val = read_vbr_int64(); + if (!ConstantSInt::isValueValidForType(Ty, Val)) + PARSE_ERROR("Invalid signed byte/short/int/long read."); + Constant* Result = ConstantSInt::get(Ty, Val); + HANDLE(ConstantValue(Result)); + return Result; + } + + case Type::FloatTyID: { + float F; + read_data(&F, &F+1); + Constant* Result = ConstantFP::get(Ty, F); + HANDLE(ConstantValue(Result)); + return Result; + } + + case Type::DoubleTyID: { + double Val; + read_data(&Val, &Val+1); + Constant* Result = ConstantFP::get(Ty, Val); + HANDLE(ConstantValue(Result)); + return Result; + } + + case Type::TypeTyID: + PARSE_ERROR("Type constants shouldn't live in constant table!"); + break; + + case Type::ArrayTyID: { + const ArrayType *AT = cast(Ty); + unsigned NumElements = AT->getNumElements(); + unsigned TypeSlot = getTypeSlot(AT->getElementType()); + std::vector Elements; + Elements.reserve(NumElements); + while (NumElements--) // Read all of the elements of the constant. + Elements.push_back(getConstantValue(TypeSlot, + read_vbr_uint())); + Constant* Result = ConstantArray::get(AT, Elements); + HANDLE(ConstantArray(AT, Elements, TypeSlot, Result)); + return Result; + } + + case Type::StructTyID: { + const StructType *ST = cast(Ty); + + std::vector Elements; + Elements.reserve(ST->getNumElements()); + for (unsigned i = 0; i != ST->getNumElements(); ++i) + Elements.push_back(getConstantValue(ST->getElementType(i), + read_vbr_uint())); + + Constant* Result = ConstantStruct::get(ST, Elements); + HANDLE(ConstantStruct(ST, Elements, Result)); + return Result; + } + + case Type::PointerTyID: { // ConstantPointerRef value... + const PointerType *PT = cast(Ty); + unsigned Slot = read_vbr_uint(); + + // Check to see if we have already read this global variable... + Value *Val = getValue(TypeID, Slot, false); + GlobalValue *GV; + if (Val) { + if (!(GV = dyn_cast(Val))) + PARSE_ERROR("Value of ConstantPointerRef not in ValueTable!"); + } else { + PARSE_ERROR("Forward references are not allowed here."); + } + + Constant* Result = ConstantPointerRef::get(GV); + HANDLE(ConstantPointer(PT, Slot, GV, Result)); + return Result; + } - if (Buf > EndBuf) throw std::string("Tried to read past end of buffer."); + default: + PARSE_ERROR("Don't know how to deserialize constant value of type '"+ + Ty->getDescription()); + break; + } } -void BytecodeParser::ResolveReferencesToConstant(Constant *NewV, unsigned Slot){ +void BytecodeReader::ResolveReferencesToConstant(Constant *NewV, unsigned Slot){ ConstantRefsType::iterator I = ConstantFwdRefs.find(std::make_pair(NewV->getType(), Slot)); if (I == ConstantFwdRefs.end()) return; // Never forward referenced? - BCR_TRACE(3, "Mutating forward refs!\n"); Value *PH = I->second; // Get the placeholder... PH->replaceAllUsesWith(NewV); delete PH; // Delete the old placeholder ConstantFwdRefs.erase(I); // Remove the map entry for it } -void BytecodeParser::ParseFunction(const unsigned char *&Buf, - const unsigned char *EndBuf) { - if (FunctionSignatureList.empty()) - throw std::string("FunctionSignatureList empty!"); - - Function *F = FunctionSignatureList.back(); - FunctionSignatureList.pop_back(); +void BytecodeReader::ParseStringConstants(unsigned NumEntries, ValueTable &Tab){ + for (; NumEntries; --NumEntries) { + unsigned Typ = read_vbr_uint(); + const Type *Ty = getType(Typ); + if (!isa(Ty)) + PARSE_ERROR("String constant data invalid!"); + + const ArrayType *ATy = cast(Ty); + if (ATy->getElementType() != Type::SByteTy && + ATy->getElementType() != Type::UByteTy) + PARSE_ERROR("String constant data invalid!"); + + // Read character data. The type tells us how long the string is. + char Data[ATy->getNumElements()]; + read_data(Data, Data+ATy->getNumElements()); + + std::vector Elements(ATy->getNumElements()); + if (ATy->getElementType() == Type::SByteTy) + for (unsigned i = 0, e = ATy->getNumElements(); i != e; ++i) + Elements[i] = ConstantSInt::get(Type::SByteTy, (signed char)Data[i]); + else + for (unsigned i = 0, e = ATy->getNumElements(); i != e; ++i) + Elements[i] = ConstantUInt::get(Type::UByteTy, (unsigned char)Data[i]); - // Save the information for future reading of the function - LazyFunctionLoadMap[F] = LazyFunctionInfo(Buf, EndBuf); - // Pretend we've `parsed' this function - Buf = EndBuf; + // Create the constant, inserting it as needed. + Constant *C = ConstantArray::get(ATy, Elements); + unsigned Slot = insertValue(C, Typ, Tab); + ResolveReferencesToConstant(C, Slot); + HANDLE(ConstantString(cast(C))); + } } -void BytecodeParser::materializeFunction(Function* F) { - // Find {start, end} pointers and slot in the map. If not there, we're done. - std::map::iterator Fi = - LazyFunctionLoadMap.find(F); - if (Fi == LazyFunctionLoadMap.end()) return; +void BytecodeReader::ParseConstantPool(ValueTable &Tab, + TypeListTy &TypeTab) { + HANDLE(GlobalConstantsBegin()); + while ( moreInBlock() ) { + unsigned NumEntries = read_vbr_uint(); + unsigned Typ = read_vbr_uint(); + if (Typ == Type::TypeTyID) { + ParseTypeConstants(TypeTab, NumEntries); + } else if (Typ == Type::VoidTyID) { + assert(&Tab == &ModuleValues && "Cannot read strings in functions!"); + ParseStringConstants(NumEntries, Tab); + } else { + for (unsigned i = 0; i < NumEntries; ++i) { + Constant *C = ParseConstantValue(Typ); + assert(C && "ParseConstantValue returned NULL!"); + unsigned Slot = insertValue(C, Typ, Tab); + + // If we are reading a function constant table, make sure that we adjust + // the slot number to be the real global constant number. + // + if (&Tab != &ModuleValues && Typ < ModuleValues.size() && + ModuleValues[Typ]) + Slot += ModuleValues[Typ]->size(); + ResolveReferencesToConstant(C, Slot); + } + } + } + checkPastBlockEnd("Constant Pool"); + HANDLE(GlobalConstantsEnd()); +} - const unsigned char *Buf = Fi->second.Buf; - const unsigned char *EndBuf = Fi->second.EndBuf; - LazyFunctionLoadMap.erase(Fi); +void BytecodeReader::ParseFunctionBody(Function* F ) { + unsigned FuncSize = BlockEnd - At; GlobalValue::LinkageTypes Linkage = GlobalValue::ExternalLinkage; - unsigned LinkageType = read_vbr_uint(Buf, EndBuf); - if (LinkageType > 4) - throw std::string("Invalid linkage type for Function."); + unsigned LinkageType = read_vbr_uint(); switch (LinkageType) { case 0: Linkage = GlobalValue::ExternalLinkage; break; case 1: Linkage = GlobalValue::WeakLinkage; break; case 2: Linkage = GlobalValue::AppendingLinkage; break; case 3: Linkage = GlobalValue::InternalLinkage; break; case 4: Linkage = GlobalValue::LinkOnceLinkage; break; + default: + PARSE_ERROR("Invalid linkage type for Function."); + Linkage = GlobalValue::InternalLinkage; + break; } - F->setLinkage(Linkage); + F->setLinkage( Linkage ); + HANDLE(FunctionBegin(F,FuncSize)); // Keep track of how many basic blocks we have read in... unsigned BlockNum = 0; bool InsertedArguments = false; - while (Buf < EndBuf) { + BufPtr MyEnd = BlockEnd; + while ( At < MyEnd ) { unsigned Type, Size; - const unsigned char *OldBuf = Buf; - readBlock(Buf, EndBuf, Type, Size); + BufPtr OldAt = At; + read_block(Type, Size); switch (Type) { case BytecodeFormat::ConstantPool: @@ -380,21 +1289,15 @@ // Insert arguments into the value table before we parse the first basic // block in the function, but after we potentially read in the // compaction table. - const FunctionType *FT = F->getFunctionType(); - Function::aiterator AI = F->abegin(); - for (FunctionType::param_iterator It = FT->param_begin(); - It != FT->param_end(); ++It, ++AI) - insertValue(AI, getTypeSlot(AI->getType()), Values); + insertArguments(F); InsertedArguments = true; } - BCR_TRACE(2, "BLOCK BytecodeFormat::ConstantPool: {\n"); - ParseConstantPool(Buf, Buf+Size, Values, FunctionTypeValues); + ParseConstantPool(FunctionValues, FunctionTypes); break; case BytecodeFormat::CompactionTable: - BCR_TRACE(2, "BLOCK BytecodeFormat::CompactionTable: {\n"); - ParseCompactionTable(Buf, Buf+Size); + ParseCompactionTable(); break; case BytecodeFormat::BasicBlock: { @@ -402,16 +1305,11 @@ // Insert arguments into the value table before we parse the first basic // block in the function, but after we potentially read in the // compaction table. - const FunctionType *FT = F->getFunctionType(); - Function::aiterator AI = F->abegin(); - for (FunctionType::param_iterator It = FT->param_begin(); - It != FT->param_end(); ++It, ++AI) - insertValue(AI, getTypeSlot(AI->getType()), Values); + insertArguments(F); InsertedArguments = true; } - BCR_TRACE(2, "BLOCK BytecodeFormat::BasicBlock: {\n"); - BasicBlock *BB = ParseBasicBlock(Buf, Buf+Size, BlockNum++); + BasicBlock *BB = ParseBasicBlock(BlockNum++); F->getBasicBlockList().push_back(BB); break; } @@ -421,41 +1319,36 @@ // list for the function, but after we potentially read in the compaction // table. if (!InsertedArguments) { - const FunctionType *FT = F->getFunctionType(); - Function::aiterator AI = F->abegin(); - for (FunctionType::param_iterator It = FT->param_begin(); - It != FT->param_end(); ++It, ++AI) - insertValue(AI, getTypeSlot(AI->getType()), Values); + insertArguments(F); InsertedArguments = true; } - BCR_TRACE(2, "BLOCK BytecodeFormat::InstructionList: {\n"); - if (BlockNum) throw std::string("Already parsed basic blocks!"); - BlockNum = ParseInstructionList(F, Buf, Buf+Size); + if (BlockNum) + PARSE_ERROR("Already parsed basic blocks!"); + BlockNum = ParseInstructionList(F); break; } case BytecodeFormat::SymbolTable: - BCR_TRACE(2, "BLOCK BytecodeFormat::SymbolTable: {\n"); - ParseSymbolTable(Buf, Buf+Size, &F->getSymbolTable(), F); + ParseSymbolTable(F, &F->getSymbolTable()); break; default: - BCR_TRACE(2, "BLOCK :ignored! {\n"); - Buf += Size; - if (OldBuf > Buf) - throw std::string("Wrapped around reading bytecode."); + At += Size; + if (OldAt > At) + PARSE_ERROR("Wrapped around reading bytecode."); break; } - BCR_TRACE(2, "} end block\n"); + BlockEnd = MyEnd; // Malformed bc file if read past end of block. - align32(Buf, EndBuf); + align32(); } // Make sure there were no references to non-existant basic blocks. if (BlockNum != ParsedBasicBlocks.size()) - throw std::string("Illegal basic block operand reference"); + PARSE_ERROR("Illegal basic block operand reference"); + ParsedBasicBlocks.clear(); // Resolve forward references. Replace any uses of a forward reference value @@ -496,128 +1389,152 @@ } // Clear out function-level types... - FunctionTypeValues.clear(); - CompactionTable.clear(); - freeTable(Values); + FunctionTypes.clear(); + CompactionTypes.clear(); + CompactionValues.clear(); + freeTable(FunctionValues); + + HANDLE(FunctionEnd(F)); } -void BytecodeParser::ParseCompactionTable(const unsigned char *&Buf, - const unsigned char *End) { +void BytecodeReader::ParseFunctionLazily() { + if (FunctionSignatureList.empty()) + PARSE_ERROR("FunctionSignatureList empty!"); - while (Buf != End) { - unsigned NumEntries = read_vbr_uint(Buf, End); - unsigned Ty; + Function *Func = FunctionSignatureList.back(); + FunctionSignatureList.pop_back(); - if ((NumEntries & 3) == 3) { - NumEntries >>= 2; - Ty = read_vbr_uint(Buf, End); - } else { - Ty = NumEntries >> 2; - NumEntries &= 3; - } + // Save the information for future reading of the function + LazyFunctionLoadMap[Func] = LazyFunctionInfo(BlockStart, BlockEnd); - if (Ty >= CompactionTable.size()) - CompactionTable.resize(Ty+1); + // Pretend we've `parsed' this function + At = BlockEnd; +} - if (!CompactionTable[Ty].empty()) - throw std::string("Compaction table plane contains multiple entries!"); - - if (Ty == Type::TypeTyID) { - for (unsigned i = 0; i != NumEntries; ++i) { - const Type *Typ = getGlobalTableType(read_vbr_uint(Buf, End)); - CompactionTable[Type::TypeTyID].push_back(const_cast(Typ)); - } +void BytecodeReader::ParseFunction(Function* Func) { + // Find {start, end} pointers and slot in the map. If not there, we're done. + LazyFunctionMap::iterator Fi = LazyFunctionLoadMap.find(Func); - CompactionTable.resize(NumEntries+Type::FirstDerivedTyID); - } else { - const Type *Typ = getType(Ty); - // Push the implicit zero - CompactionTable[Ty].push_back(Constant::getNullValue(Typ)); - for (unsigned i = 0; i != NumEntries; ++i) { - Value *V = getGlobalTableValue(Typ, read_vbr_uint(Buf, End)); - CompactionTable[Ty].push_back(V); - } - } + // Make sure we found it + if ( Fi == LazyFunctionLoadMap.end() ) { + PARSE_ERROR("Unrecognized function of type " << Func->getType()->getDescription()); + return; } + BlockStart = At = Fi->second.Buf; + BlockEnd = Fi->second.EndBuf; + assert(Fi->first == Func); + + LazyFunctionLoadMap.erase(Fi); + + this->ParseFunctionBody( Func ); } +void BytecodeReader::ParseAllFunctionBodies() { + LazyFunctionMap::iterator Fi = LazyFunctionLoadMap.begin(); + LazyFunctionMap::iterator Fe = LazyFunctionLoadMap.end(); + + while ( Fi != Fe ) { + Function* Func = Fi->first; + BlockStart = At = Fi->second.Buf; + BlockEnd = Fi->second.EndBuf; + this->ParseFunctionBody(Func); + ++Fi; + } +} +void BytecodeReader::ParseGlobalTypes() { + ValueTable T; + ParseConstantPool(T, ModuleTypes); +} -void BytecodeParser::ParseModuleGlobalInfo(const unsigned char *&Buf, - const unsigned char *End) { - if (!FunctionSignatureList.empty()) - throw std::string("Two ModuleGlobalInfo packets found!"); +void BytecodeReader::ParseModuleGlobalInfo() { + + HANDLE(ModuleGlobalsBegin()); // Read global variables... - unsigned VarType = read_vbr_uint(Buf, End); + unsigned VarType = read_vbr_uint(); while (VarType != Type::VoidTyID) { // List is terminated by Void // VarType Fields: bit0 = isConstant, bit1 = hasInitializer, bit2,3,4 = // Linkage, bit4+ = slot# unsigned SlotNo = VarType >> 5; unsigned LinkageID = (VarType >> 2) & 7; + bool isConstant = VarType & 1; + bool hasInitializer = VarType & 2; GlobalValue::LinkageTypes Linkage; switch (LinkageID) { - default: assert(0 && "Unknown linkage type!"); case 0: Linkage = GlobalValue::ExternalLinkage; break; case 1: Linkage = GlobalValue::WeakLinkage; break; case 2: Linkage = GlobalValue::AppendingLinkage; break; case 3: Linkage = GlobalValue::InternalLinkage; break; case 4: Linkage = GlobalValue::LinkOnceLinkage; break; + default: + PARSE_ERROR("Unknown linkage type: " << LinkageID); + Linkage = GlobalValue::InternalLinkage; + break; } const Type *Ty = getType(SlotNo); - if (!isa(Ty)) - throw std::string("Global not pointer type! Ty = " + - Ty->getDescription()); + if ( !Ty ) { + PARSE_ERROR("Global has no type! SlotNo=" << SlotNo); + } + + if ( !isa(Ty)) { + PARSE_ERROR("Global not a pointer type! Ty= " << Ty->getDescription()); + } const Type *ElTy = cast(Ty)->getElementType(); // Create the global variable... - GlobalVariable *GV = new GlobalVariable(ElTy, VarType & 1, Linkage, + GlobalVariable *GV = new GlobalVariable(ElTy, isConstant, Linkage, 0, "", TheModule); - BCR_TRACE(2, "Global Variable of type: " << *Ty << "\n"); insertValue(GV, SlotNo, ModuleValues); - if (VarType & 2) // Does it have an initializer? - GlobalInits.push_back(std::make_pair(GV, read_vbr_uint(Buf, End))); - VarType = read_vbr_uint(Buf, End); + unsigned initSlot = 0; + if (hasInitializer) { + initSlot = read_vbr_uint(); + GlobalInits.push_back(std::make_pair(GV, initSlot)); + } + + // Notify handler about the global value. + HANDLE(GlobalVariable( ElTy, isConstant, Linkage, SlotNo, initSlot )); + + // Get next item + VarType = read_vbr_uint(); } // Read the function objects for all of the functions that are coming - unsigned FnSignature = read_vbr_uint(Buf, End); + unsigned FnSignature = read_vbr_uint(); while (FnSignature != Type::VoidTyID) { // List is terminated by Void const Type *Ty = getType(FnSignature); if (!isa(Ty) || - !isa(cast(Ty)->getElementType())) - throw std::string("Function not ptr to func type! Ty = " + + !isa(cast(Ty)->getElementType())) { + PARSE_ERROR( "Function not a pointer to function type! Ty = " + Ty->getDescription()); + // FIXME: what should Ty be if handler continues? + } // We create functions by passing the underlying FunctionType to create... - Ty = cast(Ty)->getElementType(); + const FunctionType* FTy = + cast(cast(Ty)->getElementType()); - // When the ModuleGlobalInfo section is read, we load the type of each - // function and the 'ModuleValues' slot that it lands in. We then load a - // placeholder into its slot to reserve it. When the function is loaded, - // this placeholder is replaced. - - // Insert the placeholder... - Function *Func = new Function(cast(Ty), - GlobalValue::InternalLinkage, "", TheModule); + // Insert the place hodler + Function* Func = new Function(FTy, GlobalValue::InternalLinkage, + "", TheModule); insertValue(Func, FnSignature, ModuleValues); - // Keep track of this information in a list that is emptied as functions are - // loaded... - // + // Save this for later so we know type of lazily instantiated functions FunctionSignatureList.push_back(Func); - FnSignature = read_vbr_uint(Buf, End); - BCR_TRACE(2, "Function of type: " << Ty << "\n"); + HANDLE(FunctionDeclaration(Func)); + + // Get Next function signature + FnSignature = read_vbr_uint(); } if (hasInconsistentModuleGlobalInfo) - align32(Buf, End); + align32(); // Now that the function signature list is set up, reverse it so that we can // remove elements efficiently from the back of the vector. @@ -626,12 +1543,13 @@ // This is for future proofing... in the future extra fields may be added that // we don't understand, so we transparently ignore them. // - Buf = End; + At = BlockEnd; + + HANDLE(ModuleGlobalsEnd()); } -void BytecodeParser::ParseVersionInfo(const unsigned char *&Buf, - const unsigned char *EndBuf) { - unsigned Version = read_vbr_uint(Buf, EndBuf); +void BytecodeReader::ParseVersionInfo() { + unsigned Version = read_vbr_uint(); // Unpack version number: low four bits are for flags, top bits = version Module::Endianness Endianness; @@ -671,71 +1589,69 @@ break; default: - throw std::string("Unknown bytecode version number!"); + PARSE_ERROR("Unknown bytecode version number: " << RevisionNum); } if (hasNoEndianness) Endianness = Module::AnyEndianness; if (hasNoPointerSize) PointerSize = Module::AnyPointerSize; - TheModule->setEndianness(Endianness); - TheModule->setPointerSize(PointerSize); - BCR_TRACE(1, "Bytecode Rev = " << (unsigned)RevisionNum << "\n"); - BCR_TRACE(1, "Endianness/PointerSize = " << Endianness << "," - << PointerSize << "\n"); + HANDLE(VersionInfo(RevisionNum, Endianness, PointerSize )); } -void BytecodeParser::ParseModule(const unsigned char *Buf, - const unsigned char *EndBuf) { +void BytecodeReader::ParseModule() { unsigned Type, Size; - readBlock(Buf, EndBuf, Type, Size); - if (Type != BytecodeFormat::Module || Buf+Size != EndBuf) - throw std::string("Expected Module packet! B: "+ - utostr((unsigned)(intptr_t)Buf) + ", S: "+utostr(Size)+ - " E: "+utostr((unsigned)(intptr_t)EndBuf)); // Hrm, not a class? - BCR_TRACE(0, "BLOCK BytecodeFormat::Module: {\n"); - FunctionSignatureList.clear(); // Just in case... + FunctionSignatureList.clear(); // Just in case... // Read into instance variables... - ParseVersionInfo(Buf, EndBuf); - align32(Buf, EndBuf); + ParseVersionInfo(); + align32(); /// FIXME: Is this redundant? VI is first and 4 bytes! + + bool SeenModuleGlobalInfo = false; + bool SeenGlobalTypePlane = false; + BufPtr MyEnd = BlockEnd; + while (At < MyEnd) { + BufPtr OldAt = At; + read_block(Type, Size); - while (Buf < EndBuf) { - const unsigned char *OldBuf = Buf; - readBlock(Buf, EndBuf, Type, Size); switch (Type) { + case BytecodeFormat::GlobalTypePlane: - BCR_TRACE(1, "BLOCK BytecodeFormat::GlobalTypePlane: {\n"); - ParseGlobalTypes(Buf, Buf+Size); + if ( SeenGlobalTypePlane ) + PARSE_ERROR("Two GlobalTypePlane Blocks Encountered!"); + + ParseGlobalTypes(); + SeenGlobalTypePlane = true; break; - case BytecodeFormat::ModuleGlobalInfo: - BCR_TRACE(1, "BLOCK BytecodeFormat::ModuleGlobalInfo: {\n"); - ParseModuleGlobalInfo(Buf, Buf+Size); + case BytecodeFormat::ModuleGlobalInfo: + if ( SeenModuleGlobalInfo ) + PARSE_ERROR("Two ModuleGlobalInfo Blocks Encountered!"); + ParseModuleGlobalInfo(); + SeenModuleGlobalInfo = true; break; case BytecodeFormat::ConstantPool: - BCR_TRACE(1, "BLOCK BytecodeFormat::ConstantPool: {\n"); - ParseConstantPool(Buf, Buf+Size, ModuleValues, ModuleTypeValues); + ParseConstantPool(ModuleValues, ModuleTypes); break; - case BytecodeFormat::Function: { - BCR_TRACE(1, "BLOCK BytecodeFormat::Function: {\n"); - ParseFunction(Buf, Buf+Size); + case BytecodeFormat::Function: + ParseFunctionLazily(); break; - } case BytecodeFormat::SymbolTable: - BCR_TRACE(1, "BLOCK BytecodeFormat::SymbolTable: {\n"); - ParseSymbolTable(Buf, Buf+Size, &TheModule->getSymbolTable(), 0); + ParseSymbolTable(0, &TheModule->getSymbolTable()); break; + default: - Buf += Size; - if (OldBuf > Buf) throw std::string("Expected Module Block!"); + At += Size; + if (OldAt > At) { + PARSE_ERROR("Unexpected Block of Type" << Type << "encountered!" ); + } break; } - BCR_TRACE(1, "} end block\n"); - align32(Buf, EndBuf); + BlockEnd = MyEnd; + align32(); } // After the module constant pool has been read, we can safely initialize @@ -747,38 +1663,151 @@ // Look up the initializer value... // FIXME: Preserve this type ID! - unsigned TypeSlot = getTypeSlot(GV->getType()->getElementType()); + + const llvm::PointerType* GVType = GV->getType(); + unsigned TypeSlot = getTypeSlot(GVType->getElementType()); if (Constant *CV = getConstantValue(TypeSlot, Slot)) { if (GV->hasInitializer()) - throw std::string("Global *already* has an initializer?!"); + PARSE_ERROR("Global *already* has an initializer?!"); + HANDLE(GlobalInitializer(GV,CV)); GV->setInitializer(CV); } else - throw std::string("Cannot find initializer value."); + PARSE_ERROR("Cannot find initializer value."); } + /// Make sure we pulled them all out. If we didn't then there's a declaration + /// but a missing body. That's not allowed. if (!FunctionSignatureList.empty()) - throw std::string("Function expected, but bytecode stream ended!"); - - BCR_TRACE(0, "} end block\n\n"); + PARSE_ERROR( + "Function declared, but bytecode stream ended before definition"); } -void BytecodeParser::ParseBytecode(const unsigned char *Buf, unsigned Length, - const std::string &ModuleID) { +void BytecodeReader::ParseBytecode( + BufPtr Buf, unsigned Length, + const std::string &ModuleID) { + + try { + At = MemStart = BlockStart = Buf; + MemEnd = BlockEnd = Buf + Length; + + // Create the module + TheModule = new Module(ModuleID); + + HANDLE(Start(TheModule, Length)); + + // Read and check signature... + unsigned Sig = read_uint(); + if (Sig != ('l' | ('l' << 8) | ('v' << 16) | ('m' << 24))) { + PARSE_ERROR("Invalid bytecode signature: " << Sig); + } + + + // Tell the handler we're starting a module + HANDLE(ModuleBegin(ModuleID)); + + // Get the module block and size and verify + unsigned Type, Size; + read_block(Type, Size); + if ( Type != BytecodeFormat::Module ) { + PARSE_ERROR("Expected Module Block! At: " << unsigned(intptr_t(At)) + << ", Type:" << Type << ", Size:" << Size); + } + if ( At + Size != MemEnd ) { + PARSE_ERROR("Invalid Top Level Block Length! At: " + << unsigned(intptr_t(At)) << ", Type:" << Type << ", Size:" << Size); + } - unsigned char *EndBuf = (unsigned char*)(Buf + Length); + // Parse the module contents + this->ParseModule(); - // Read and check signature... - unsigned Sig = read(Buf, EndBuf); - if (Sig != ('l' | ('l' << 8) | ('v' << 16) | ('m' << 24))) - throw std::string("Invalid bytecode signature!"); + // Tell the handler we're done + HANDLE(ModuleEnd(ModuleID)); - TheModule = new Module(ModuleID); - try { - ParseModule(Buf, EndBuf); - } catch (std::string &Error) { - freeState(); // Must destroy handles before deleting module! + // Check for missing functions + if ( hasFunctions() ) + PARSE_ERROR("Function expected, but bytecode stream ended!"); + + // Tell the handler we're + HANDLE(Finish()); + + } catch (std::string& errstr ) { + HANDLE(Error(errstr)); + freeState(); delete TheModule; TheModule = 0; throw; + } catch (...) { + std::string msg("Unknown Exception Occurred"); + HANDLE(Error(msg)); + freeState(); + delete TheModule; + TheModule = 0; + throw msg; } } + +//===----------------------------------------------------------------------===// +//=== Default Implementations of Handler Methods +//===----------------------------------------------------------------------===// + +BytecodeHandler::~BytecodeHandler() {} +void BytecodeHandler::handleError(const std::string& str ) { } +void BytecodeHandler::handleStart(Module*m, unsigned Length ) { } +void BytecodeHandler::handleFinish() { } +void BytecodeHandler::handleModuleBegin(const std::string& id) { } +void BytecodeHandler::handleModuleEnd(const std::string& id) { } +void BytecodeHandler::handleVersionInfo( unsigned char RevisionNum, + Module::Endianness Endianness, Module::PointerSize PointerSize) { } +void BytecodeHandler::handleModuleGlobalsBegin() { } +void BytecodeHandler::handleGlobalVariable( + const Type* ElemType, bool isConstant, GlobalValue::LinkageTypes, + unsigned SlotNo, unsigned initSlot ) { } +void BytecodeHandler::handleType( const Type* Ty ) {} +void BytecodeHandler::handleFunctionDeclaration( + Function* Func ) {} +void BytecodeHandler::handleGlobalInitializer(GlobalVariable*, Constant* ) {} +void BytecodeHandler::handleModuleGlobalsEnd() { } +void BytecodeHandler::handleCompactionTableBegin() { } +void BytecodeHandler::handleCompactionTablePlane( + unsigned Ty, unsigned NumEntries) {} +void BytecodeHandler::handleCompactionTableType( + unsigned i, unsigned TypSlot, const Type* ) {} +void BytecodeHandler::handleCompactionTableValue( + unsigned i, unsigned TypSlot, unsigned ValSlot, const Type* ) {} +void BytecodeHandler::handleCompactionTableEnd() { } +void BytecodeHandler::handleSymbolTableBegin(Function*, SymbolTable*) { } +void BytecodeHandler::handleSymbolTablePlane( unsigned Ty, unsigned NumEntries, + const Type* Typ) { } +void BytecodeHandler::handleSymbolTableType( unsigned i, unsigned slot, + const std::string& name ) { } +void BytecodeHandler::handleSymbolTableValue( unsigned i, unsigned slot, + const std::string& name ) { } +void BytecodeHandler::handleSymbolTableEnd() { } +void BytecodeHandler::handleFunctionBegin( Function* Func, + unsigned Size ) {} +void BytecodeHandler::handleFunctionEnd( Function* Func) { } +void BytecodeHandler::handleBasicBlockBegin( unsigned blocknum) { } +bool BytecodeHandler::handleInstruction( unsigned Opcode, const Type* iType, + std::vector& Operands, unsigned Size) { + return Instruction::isTerminator(Opcode); + } +void BytecodeHandler::handleBasicBlockEnd(unsigned blocknum) { } +void BytecodeHandler::handleGlobalConstantsBegin() { } +void BytecodeHandler::handleConstantExpression( unsigned Opcode, + std::vector ArgVec, Constant* Val) { } +void BytecodeHandler::handleConstantValue( Constant * c ) { } +void BytecodeHandler::handleConstantArray( const ArrayType* AT, + std::vector& Elements, unsigned TypeSlot, Constant* Val ) { } +void BytecodeHandler::handleConstantStruct( const StructType* ST, + std::vector& ElementSlots, Constant* Val ) { } +void BytecodeHandler::handleConstantPointer( + const PointerType* PT, unsigned TypeSlot, GlobalValue*, Constant* Val) { } +void BytecodeHandler::handleConstantString( const ConstantArray* CA ) {} +void BytecodeHandler::handleGlobalConstantsEnd() {} +void BytecodeHandler::handleAlignment(unsigned numBytes) {} +void BytecodeHandler::handleBlock( + unsigned BType, const unsigned char* StartPtr, unsigned Size) {} +void BytecodeHandler::handleVBR32(unsigned Size ) {} +void BytecodeHandler::handleVBR64(unsigned Size ) {} + +// vim: sw=2 From llvm at cs.uiuc.edu Tue Jun 29 18:32:03 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Tue Jun 29 18:32:03 2004 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Reader/Reader.h Message-ID: <200406292331.SAA32412@zion.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Reader: Reader.h added (r1.1) --- Log message: This is a slimming down of the previous ReaderInternals.h that just declares the BytecodeReader class. --- Diffs of the changes: (+470 -0) Index: llvm/lib/Bytecode/Reader/Reader.h diff -c /dev/null llvm/lib/Bytecode/Reader/Reader.h:1.1 *** /dev/null Tue Jun 29 18:31:11 2004 --- llvm/lib/Bytecode/Reader/Reader.h Tue Jun 29 18:31:01 2004 *************** *** 0 **** --- 1,470 ---- + //===-- Reader.h - Interface To Bytecode Reading ----------------*- C++ -*-===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by Reid Spencer and is distributed under the + // University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // This header file defines the interface to the Bytecode Reader which is + // responsible for correctly interpreting bytecode files (backwards compatible) + // and materializing a module from the bytecode read. + // + //===----------------------------------------------------------------------===// + + #ifndef BYTECODE_PARSER_H + #define BYTECODE_PARSER_H + + #include "llvm/Constants.h" + #include "llvm/DerivedTypes.h" + #include "llvm/GlobalValue.h" + #include "llvm/Function.h" + #include "llvm/ModuleProvider.h" + #include + #include + + namespace llvm { + + class BytecodeHandler; ///< Forward declare the handler interface + + /// This class defines the interface for parsing a buffer of bytecode. The + /// parser itself takes no action except to call the various functions of + /// the handler interface. The parser's sole responsibility is the correct + /// interpretation of the bytecode buffer. The handler is responsible for + /// instantiating and keeping track of all values. As a convenience, the parser + /// is responsible for materializing types and will pass them through the + /// handler interface as necessary. + /// @see BytecodeHandler + /// @brief Bytecode Reader interface + class BytecodeReader : public ModuleProvider { + + /// @name Constructors + /// @{ + public: + /// @brief Default constructor. By default, no handler is used. + BytecodeReader( + BytecodeHandler* h = 0 + ) { + Handler = h; + } + + ~BytecodeReader() { freeState(); } + + /// @} + /// @name Types + /// @{ + public: + /// @brief A convenience type for the buffer pointer + typedef const unsigned char* BufPtr; + + /// @brief The type used for a vector of potentially abstract types + typedef std::vector TypeListTy; + + /// This type provides a vector of Value* via the User class for + /// storage of Values that have been constructed when reading the + /// bytecode. Because of forward referencing, constant replacement + /// can occur so we ensure that our list of Value* is updated + /// properly through those transitions. This ensures that the + /// correct Value* is in our list when it comes time to associate + /// constants with global variables at the end of reading the + /// globals section. + /// @brief A list of values as a User of those Values. + struct ValueList : public User { + ValueList() : User(Type::TypeTy, Value::TypeVal) {} + + // vector compatibility methods + unsigned size() const { return getNumOperands(); } + void push_back(Value *V) { Operands.push_back(Use(V, this)); } + Value *back() const { return Operands.back(); } + void pop_back() { Operands.pop_back(); } + bool empty() const { return Operands.empty(); } + // must override this + virtual void print(std::ostream& os) const { + for ( unsigned i = 0; i < size(); i++ ) { + os << i << " "; + getOperand(i)->print(os); + os << "\n"; + } + } + }; + + /// @brief A 2 dimensional table of values + typedef std::vector ValueTable; + + /// This map is needed so that forward references to constants can be looked + /// up by Type and slot number when resolving those references. + /// @brief A mapping of a Type/slot pair to a Constant*. + typedef std::map, Constant*> ConstantRefsType; + + /// For lazy read-in of functions, we need to save the location in the + /// data stream where the function is located. This structure provides that + /// information. Lazy read-in is used mostly by the JIT which only wants to + /// resolve functions as it needs them. + /// @brief Keeps pointers to function contents for later use. + struct LazyFunctionInfo { + const unsigned char *Buf, *EndBuf; + LazyFunctionInfo(const unsigned char *B = 0, const unsigned char *EB = 0) + : Buf(B), EndBuf(EB) {} + }; + + /// @brief A mapping of functions to their LazyFunctionInfo for lazy reading. + typedef std::map LazyFunctionMap; + + /// @brief A list of global variables and the slot number that initializes + /// them. + typedef std::vector > GlobalInitsList; + + /// This type maps a typeslot/valueslot pair to the corresponding Value*. + /// It is used for dealing with forward references as values are read in. + /// @brief A map for dealing with forward references of values. + typedef std::map,Value*> ForwardReferenceMap; + + /// @} + /// @name Methods + /// @{ + public: + /// This function completely parses a bytecode buffer given by the \p Buf + /// and \p Length parameters. The + /// @brief Main interface to parsing a bytecode buffer. + void ParseBytecode( + const unsigned char *Buf, ///< Beginning of the bytecode buffer + unsigned Length, ///< Length of the bytecode buffer + const std::string &ModuleID ///< An identifier for the module constructed. + ); + + /// The ParseAllFunctionBodies method parses through all the previously + /// unparsed functions in the bytecode file. If you want to completely parse + /// a bytecode file, this method should be called after Parsebytecode because + /// Parsebytecode only records the locations in the bytecode file of where + /// the function definitions are located. This function uses that information + /// to materialize the functions. + /// @see ParseBytecode + /// @brief Parse all function bodies + void ParseAllFunctionBodies (); + + /// The ParserFunction method lazily parses one function. Use this method to + /// casue the parser to parse a specific function in the module. Note that + /// this will remove the function from what is to be included by + /// ParseAllFunctionBodies. + /// @see ParseAllFunctionBodies + /// @see ParseBytecode + /// @brief Parse the next function of specific type + void ParseFunction (Function* Func) ; + + /// This method is abstract in the parent ModuleProvider class. Its + /// implementation is identical to the ParseFunction method. + /// @see ParseFunction + /// @brief Make a specific function materialize. + virtual void materializeFunction(Function *F) { + LazyFunctionMap::iterator Fi = LazyFunctionLoadMap.find(F); + if (Fi == LazyFunctionLoadMap.end()) return; + ParseFunction(F); + } + + /// This method is abstract in the parent ModuleProvider class. Its + /// implementation is identical to ParseAllFunctionBodies. + /// @see ParseAllFunctionBodies + /// @brief Make the whole module materialize + virtual Module* materializeModule() { + ParseAllFunctionBodies(); + return TheModule; + } + + /// This method is provided by the parent ModuleProvde class and overriden + /// here. It simply releases the module from its provided and frees up our + /// state. + /// @brief Release our hold on the generated module + Module* releaseModule() { + // Since we're losing control of this Module, we must hand it back complete + Module *M = ModuleProvider::releaseModule(); + freeState(); + return M; + } + + /// @} + /// @name Parsing Units For Subclasses + /// @{ + protected: + /// @brief Parse whole module scope + void ParseModule(); + + /// @brief Parse the version information block + void ParseVersionInfo(); + + /// @brief Parse the ModuleGlobalInfo block + void ParseModuleGlobalInfo(); + + /// @brief Parse a symbol table + void ParseSymbolTable( Function* Func, SymbolTable *ST); + + /// This function parses LLVM functions lazily. It obtains the type of the + /// function and records where the body of the function is in the bytecode + /// buffer. The caller can then use the ParseNextFunction and + /// ParseAllFunctionBodies to get handler events for the functions. + /// @brief Parse functions lazily. + void ParseFunctionLazily(); + + /// @brief Parse a function body + void ParseFunctionBody(Function* Func); + + /// @brief Parse a compaction table + void ParseCompactionTable(); + + /// @brief Parse global types + void ParseGlobalTypes(); + + /// @returns The basic block constructed. + /// @brief Parse a basic block (for LLVM 1.0 basic block blocks) + BasicBlock* ParseBasicBlock(unsigned BlockNo); + + /// @returns Rhe number of basic blocks encountered. + /// @brief parse an instruction list (for post LLVM 1.0 instruction lists + /// with blocks differentiated by terminating instructions. + unsigned ParseInstructionList( + Function* F ///< The function into which BBs will be inserted + ); + + /// This method parses a single instruction. The instruction is + /// inserted at the end of the \p BB provided. The arguments of + /// the instruction are provided in the \p Args vector. + /// @brief Parse a single instruction. + void ParseInstruction( + std::vector& Args, ///< The arguments to be filled in + BasicBlock* BB ///< The BB the instruction goes in + ); + + /// @brief Parse the whole constant pool + void ParseConstantPool(ValueTable& Values, TypeListTy& Types); + + /// @brief Parse a single constant value + Constant* ParseConstantValue(unsigned TypeID); + + /// @brief Parse a block of types constants + void ParseTypeConstants(TypeListTy &Tab, unsigned NumEntries); + + /// @brief Parse a single type constant + const Type *ParseTypeConstant(); + + /// @brief Parse a string constants block + void ParseStringConstants(unsigned NumEntries, ValueTable &Tab); + + /// @} + /// @name Data + /// @{ + private: + BufPtr MemStart; ///< Start of the memory buffer + BufPtr MemEnd; ///< End of the memory buffer + BufPtr BlockStart; ///< Start of current block being parsed + BufPtr BlockEnd; ///< End of current block being parsed + BufPtr At; ///< Where we're currently parsing at + + // Information about the module, extracted from the bytecode revision number. + unsigned char RevisionNum; // The rev # itself + + // Flags to distinguish LLVM 1.0 & 1.1 bytecode formats (revision #0) + + // Revision #0 had an explicit alignment of data only for the ModuleGlobalInfo + // block. This was fixed to be like all other blocks in 1.2 + bool hasInconsistentModuleGlobalInfo; + + // Revision #0 also explicitly encoded zero values for primitive types like + // int/sbyte/etc. + bool hasExplicitPrimitiveZeros; + + // Flags to control features specific the LLVM 1.2 and before (revision #1) + + // LLVM 1.2 and earlier required that getelementptr structure indices were + // ubyte constants and that sequential type indices were longs. + bool hasRestrictedGEPTypes; + + /// CompactionTable - If a compaction table is active in the current function, + /// this is the mapping that it contains. + std::vector CompactionTypes; + + /// @brief If a compaction table is active in the current function, + /// this is the mapping that it contains. + std::vector > CompactionValues; + + /// @brief This vector is used to deal with forward references to types in + /// a module. + TypeListTy ModuleTypes; + + /// @brief This vector is used to deal with forward references to types in + /// a function. + TypeListTy FunctionTypes; + + /// When the ModuleGlobalInfo section is read, we create a Function object + /// for each function in the module. When the function is loaded, after the + /// module global info is read, this Function is populated. Until then, the + /// functions in this vector just hold the function signature. + std::vector FunctionSignatureList; + + /// @brief This is the table of values belonging to the current function + ValueTable FunctionValues; + + /// @brief This is the table of values belonging to the module (global) + ValueTable ModuleValues; + + /// @brief This keeps track of function level forward references. + ForwardReferenceMap ForwardReferences; + + /// @brief The basic blocks we've parsed, while parsing a function. + std::vector ParsedBasicBlocks; + + /// This maintains a mapping between 's and + /// forward references to constants. Such values may be referenced before they + /// are defined, and if so, the temporary object that they represent is held + /// here. + /// @brief Temporary place for forward references to constants. + ConstantRefsType ConstantFwdRefs; + + /// Constant values are read in after global variables. Because of this, we + /// must defer setting the initializers on global variables until after module + /// level constants have been read. In the mean time, this list keeps track of + /// what we must do. + GlobalInitsList GlobalInits; + + // For lazy reading-in of functions, we need to save away several pieces of + // information about each function: its begin and end pointer in the buffer + // and its FunctionSlot. + LazyFunctionMap LazyFunctionLoadMap; + + /// This stores the parser's handler which is used for handling tasks other + /// just than reading bytecode into the IR. If this is non-null, calls on + /// the (polymorphic) BytecodeHandler interface (see llvm/Bytecode/Handler.h) + /// will be made to report the logical structure of the bytecode file. What + /// the handler does with the events it receives is completely orthogonal to + /// the business of parsing the bytecode and building the IR. This is used, + /// for example, by the llvm-abcd tool for analysis of byte code. + /// @brief Handler for parsing events. + BytecodeHandler* Handler; + + /// @} + /// @name Implementation Details + /// @{ + private: + /// @brief Determines if this module has a function or not. + bool hasFunctions() { return ! FunctionSignatureList.empty(); } + + /// @brief Determines if the type id has an implicit null value. + bool hasImplicitNull(unsigned TyID ); + + /// @brief Converts a type slot number to its Type* + const Type *getType(unsigned ID); + + /// @brief Converts a Type* to its type slot number + unsigned getTypeSlot(const Type *Ty); + + /// @brief Converts a normal type slot number to a compacted type slot num. + unsigned getCompactionTypeSlot(unsigned type); + + /// This is just like getType, but when a compaction table is in use, it is + /// ignored. Also, no forward references or other fancy features are + /// supported. + const Type *getGlobalTableType(unsigned Slot); + + /// This is just like getTypeSlot, but when a compaction table is in use, + /// it is ignored. + unsigned getGlobalTableTypeSlot(const Type *Ty); + + /// Retrieve a value of a given type and slot number, possibly creating + /// it if it doesn't already exist. + Value* getValue(unsigned TypeID, unsigned num, bool Create = true); + + /// This is just like getValue, but when a compaction table is in use, it + /// is ignored. Also, no forward references or other fancy features are + /// supported. + Value *getGlobalTableValue(const Type *Ty, unsigned SlotNo); + + /// This function is used when construction phi, br, switch, and other + /// instructions that reference basic blocks. Blocks are numbered + /// sequentially as they appear in the function. + /// @brief Get a basic block for current function + BasicBlock *getBasicBlock(unsigned ID); + + /// Just like getValue, except that it returns a null pointer + /// only on error. It always returns a constant (meaning that if the value is + /// defined, but is not a constant, that is an error). If the specified + /// constant hasn't been parsed yet, a placeholder is defined and used. + /// Later, after the real value is parsed, the placeholder is eliminated. + Constant* getConstantValue(unsigned typeSlot, unsigned valSlot); + + /// @brief Convenience function for getting a constant value when + /// the Type has already been resolved. + Constant* getConstantValue(const Type *Ty, unsigned valSlot) { + return getConstantValue(getTypeSlot(Ty), valSlot); + } + + /// As values are created, they are inserted into the appropriate place + /// with this method. The ValueTable argument must be one of ModuleValues + /// or FunctionValues data members of this class. + /// @brief Insert a newly created value + unsigned insertValue(Value *V, unsigned Type, ValueTable &Table); + + /// @brief Insert the arguments of a function. + void insertArguments(Function* F ); + + /// @brief Resolve all references to the placeholder (if any) for the + /// given constant. + void ResolveReferencesToConstant(Constant *C, unsigned Slot); + + /// @brief Release our memory. + void freeState() { + freeTable(FunctionValues); + freeTable(ModuleValues); + } + + /// @brief Free a table, making sure to free the ValueList in the table. + void freeTable(ValueTable &Tab) { + while (!Tab.empty()) { + delete Tab.back(); + Tab.pop_back(); + } + } + + BytecodeReader(const BytecodeReader &); // DO NOT IMPLEMENT + void operator=(const BytecodeReader &); // DO NOT IMPLEMENT + + /// @} + /// @name Reader Primitives + /// @{ + private: + + /// @brief Is there more to parse in the current block? + inline bool moreInBlock(); + + /// @brief Have we read past the end of the block + inline void checkPastBlockEnd(const char * block_name); + + /// @brief Align to 32 bits + inline void align32(); + + /// @brief Read an unsigned integer as 32-bits + inline unsigned read_uint(); + + /// @brief Read an unsigned integer with variable bit rate encoding + inline unsigned read_vbr_uint(); + + /// @brief Read an unsigned 64-bit integer with variable bit rate encoding. + inline uint64_t read_vbr_uint64(); + + /// @brief Read a signed 64-bit integer with variable bit rate encoding. + inline int64_t read_vbr_int64(); + + /// @brief Read a string + inline std::string read_str(); + + /// @brief Read an arbitrary data chunk of fixed length + inline void read_data(void *Ptr, void *End); + + /// Read a bytecode block header + inline void read_block(unsigned &Type, unsigned &Size); + + /// @} + }; + + } // End llvm namespace + + // vim: sw=2 + #endif From llvm at cs.uiuc.edu Tue Jun 29 18:33:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Tue Jun 29 18:33:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Reader/AnalyzerInternals.h AnalyzerWrappers.cpp ConstantReader.cpp Dumper.cpp InstructionReader.cpp Parser.cpp Parser.h ReaderInternals.h ReaderPrimitives.h Message-ID: <200406292332.SAA32506@zion.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Reader: AnalyzerInternals.h (r1.3) removed AnalyzerWrappers.cpp (r1.7) removed ConstantReader.cpp (r1.77) removed Dumper.cpp (r1.4) removed InstructionReader.cpp (r1.72) removed Parser.cpp (r1.6) removed Parser.h (r1.5) removed ReaderInternals.h (r1.80) removed ReaderPrimitives.h (r1.5) removed --- Log message: Remove files no longer needed. ConstantReader and InstructionReader were integrated into Reader. Parser.* was just a bad idea. AnalyzerInternals.h is no longer needed. ReaderPrimitives.h was integrated into Reader.h and Reader.cpp. Dumper.cpp was integrated into Analyzer.cpp. ReaderInternals.h became Reader.h. AnalyzerWrappers.cpp was integerated into ReaderWrappers.cpp --- Diffs of the changes: (+0 -0) From llvm at cs.uiuc.edu Tue Jun 29 18:34:00 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Tue Jun 29 18:34:00 2004 Subject: [llvm-commits] CVS: llvm/tools/llvm-abcd/Makefile Message-ID: <200406292333.SAA32563@zion.cs.uiuc.edu> Changes in directory llvm/tools/llvm-abcd: Makefile updated: 1.1 -> 1.2 --- Log message: The analyzer code now lives in the bcreader library. The bcanalyzer lib is no more. --- Diffs of the changes: (+1 -1) Index: llvm/tools/llvm-abcd/Makefile diff -u llvm/tools/llvm-abcd/Makefile:1.1 llvm/tools/llvm-abcd/Makefile:1.2 --- llvm/tools/llvm-abcd/Makefile:1.1 Mon Jun 7 12:53:43 2004 +++ llvm/tools/llvm-abcd/Makefile Tue Jun 29 18:33:31 2004 @@ -9,5 +9,5 @@ LEVEL = ../.. TOOLNAME = llvm-abcd -USEDLIBS = bcanalyzer vmcore support.a +USEDLIBS = bcreader vmcore support.a include $(LEVEL)/Makefile.common From llvm at cs.uiuc.edu Tue Jun 29 18:35:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Tue Jun 29 18:35:01 2004 Subject: [llvm-commits] CVS: llvm/tools/llvm-abcd/llvm-abcd.cpp Message-ID: <200406292334.SAA32611@zion.cs.uiuc.edu> Changes in directory llvm/tools/llvm-abcd: llvm-abcd.cpp updated: 1.4 -> 1.5 --- Log message: Implement verification feature. Ensure output occurs even in the face of an error. --- Diffs of the changes: (+20 -4) Index: llvm/tools/llvm-abcd/llvm-abcd.cpp diff -u llvm/tools/llvm-abcd/llvm-abcd.cpp:1.4 llvm/tools/llvm-abcd/llvm-abcd.cpp:1.5 --- llvm/tools/llvm-abcd/llvm-abcd.cpp:1.4 Thu Jun 10 13:38:44 2004 +++ llvm/tools/llvm-abcd/llvm-abcd.cpp Tue Jun 29 18:34:27 2004 @@ -29,6 +29,7 @@ // the bytecode file (-dump option). //===----------------------------------------------------------------------===// +#include "llvm/Analysis/Verifier.h" #include "llvm/Bytecode/Analyzer.h" #include "Support/CommandLine.h" #include "llvm/System/Signals.h" @@ -41,7 +42,8 @@ InputFilename(cl::Positional, cl::desc(""), cl::init("-")); static cl::opt NoDetails ("nodetails", cl::desc("Skip detailed output")); -static cl::opt Dump ("dump", cl::desc("Detailed output")); +static cl::opt Dump ("dump", cl::desc("Dump low level bytecode trace")); +static cl::opt Verify ("verify", cl::desc("Progressively verify module")); int main(int argc, char **argv) @@ -59,9 +61,25 @@ /// Determine what to generate bca.dumpBytecode = Dump; bca.detailedResults = !NoDetails; + bca.progressiveVerify = Verify; /// Analyze the bytecode file - AnalyzeBytecodeFile(InputFilename, bca, &ErrorMessage); + Module* M = AnalyzeBytecodeFile(InputFilename, bca, &ErrorMessage); + + // All that abcd does is write the gathered statistics to the output + PrintBytecodeAnalysis(bca,*Out); + + if ( M && Verify ) { + std::string verificationMsg; + try { + verifyModule( *M, ThrowExceptionAction ); + } catch (std::string& errmsg ) { + verificationMsg = errmsg; + } + if ( verificationMsg.length() > 0 ) + std::cerr << "Final Verification Message: " << verificationMsg << "\n"; + } + // If there was an error, print it and stop. if ( ErrorMessage.size() ) { @@ -69,8 +87,6 @@ return 1; } - // All that abcd does is write the gathered statistics to the output - PrintBytecodeAnalysis(bca,*Out); if (Out != &std::cout) { ((std::ofstream*)Out)->close(); From llvm at cs.uiuc.edu Tue Jun 29 18:40:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Tue Jun 29 18:40:01 2004 Subject: [llvm-commits] CVS: llvm/docs/ReleaseNotes.html Message-ID: <200406292339.SAA00493@zion.cs.uiuc.edu> Changes in directory llvm/docs: ReleaseNotes.html updated: 1.208 -> 1.209 --- Log message: Fix order and line length of fixed bugs. --- Diffs of the changes: (+15 -9) Index: llvm/docs/ReleaseNotes.html diff -u llvm/docs/ReleaseNotes.html:1.208 llvm/docs/ReleaseNotes.html:1.209 --- llvm/docs/ReleaseNotes.html:1.208 Sun Jun 27 19:44:45 2004 +++ llvm/docs/ReleaseNotes.html Tue Jun 29 18:39:24 2004 @@ -262,37 +262,43 @@

      Bugs in the LLVM Core:

        -
      1. [vmcore] Linker causes erroneous -asssertion
      2. [loopsimplify] Loop simplify incorrectly updates dominator information
      3. [tailduplicate] DemoteRegToStack breaks SSA form
      4. [X86] JIT miscompiles unsigned short to floating point cast
      5. +
      6. [jit] abort, don't warn, when +missing external functions encountered
      7. +
      8. [vmcore] Linker causes erroneous +asssertion
      9. [adce] Crash handling unreachable code that unwinds
      10. [sparc] LLC can't emit 2 functions of the same name, both having constant pools
      11. [livevar] Live variables missed physical register use of aliased definition
      12. -
      13. Verifier misses malformed switch instruction
      14. -
      15. [jit] abort, don't warn, when missing external functions encountered
      16. -
      17. [X86] stackifier crash on floating point setcc X, X
      18. +
      19. Verifier misses malformed switch +instruction
      20. +
      21. [asmwriter] Asm writer aborts if +an instruction is not embedded into a function
      22. +
      23. [X86] stackifier crash on floating +point setcc X, X

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

        -
      1. [llvmgcc] miscompilation of staticly initialized unsigned bitfields
      2. -
      3. [llvmgcc] Crash on use of undeclared -enum type
      4. [llvmgcc] Variable length array indexing miscompiled
      5. +
      6. [llvmgcc] Crash on use of undeclared +enum type
      7. [llvmgcc] Errors handling function prototypes that take opaque structs by-value
      8. [llvmgcc] Crash compiling variable length array of structures
      9. +
      10. [llvmgcc] miscompilation of staticly +initialized unsigned bitfields
      @@ -739,7 +745,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
      - Last modified: $Date: 2004/06/28 00:44:45 $ + Last modified: $Date: 2004/06/29 23:39:24 $ From gaeke at cs.uiuc.edu Wed Jun 30 01:12:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed Jun 30 01:12:01 2004 Subject: [llvm-commits] CVS: reopt/lib/TraceIO/ Message-ID: <200406300610.BAA05969@kain.cs.uiuc.edu> Changes in directory reopt/lib/TraceIO: --- Log message: Directory /home/vadve/shared/InternalCVS/reopt/lib/TraceIO added to the repository --- Diffs of the changes: (+0 -0) From gaeke at cs.uiuc.edu Wed Jun 30 01:34:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed Jun 30 01:34:01 2004 Subject: [llvm-commits] CVS: reopt/lib/TraceIO/Makefile TraceReader.cpp TraceWriter.cpp Message-ID: <200406300633.BAA17048@kain.cs.uiuc.edu> Changes in directory reopt/lib/TraceIO: Makefile added (r1.1) TraceReader.cpp added (r1.1) TraceWriter.cpp added (r1.1) --- Log message: The trace writer (from the LightWtProfiling dir) and the trace reader (from ttftest, merged with the one from dumptrace) have been moved to this new Trace I/O library. --- Diffs of the changes: (+128 -0) Index: reopt/lib/TraceIO/Makefile diff -c /dev/null reopt/lib/TraceIO/Makefile:1.1 *** /dev/null Wed Jun 30 01:33:29 2004 --- reopt/lib/TraceIO/Makefile Wed Jun 30 01:33:18 2004 *************** *** 0 **** --- 1,4 ---- + LEVEL = ../.. + LIBRARYNAME = traceio + + include $(LEVEL)/Makefile.common Index: reopt/lib/TraceIO/TraceReader.cpp diff -c /dev/null reopt/lib/TraceIO/TraceReader.cpp:1.1 *** /dev/null Wed Jun 30 01:33:29 2004 --- reopt/lib/TraceIO/TraceReader.cpp Wed Jun 30 01:33:18 2004 *************** *** 0 **** --- 1,58 ---- + + #include "Support/CommandLine.h" + #include "Support/Debug.h" + #include "llvm/Analysis/Trace.h" + #include "llvm/Module.h" + #include + #include + using namespace llvm; + + namespace llvm { + + /// getBasicBlockByNum - Returns the basic block in F whose index is + /// bbNum. + /// + BasicBlock *getBasicBlockByNum (Function *F, int bbNum) { + Function::iterator block = F->begin(); + std::advance (block, bbNum); + return block; + } + + /// ReadTraceFromFile - Given a module, read a trace for some function + /// in that module from the named file. Returns the Trace object, or a null + /// pointer (and sets ErrorStr) if there was an error. + /// + Trace *ReadTraceFromFile (Module *M, const std::string &filename, + std::string *ErrorStr) { + std::ifstream in (filename.c_str ()); + if (!in.good()) { + if (ErrorStr) + *ErrorStr = std::string("Can't open '") + filename + "': " + + strerror(errno); + return 0; + } + char functionName[160]; + in.getline(functionName, 160, '\n'); + Function *F = M->getNamedFunction (functionName); + if (!F) { + if (ErrorStr) + *ErrorStr = std::string("Function '") + functionName + + "' not found in module"; + return 0; + } + DEBUG (std::cerr << "Reading trace for function: '" << functionName << "'\n" + << "Basic blocks: "); + std::vector vBB; + do { + int basicBlockNum; + in >> basicBlockNum; + if (!in.eof ()) { + DEBUG (std::cerr << basicBlockNum << " "); + vBB.push_back (getBasicBlockByNum (F, basicBlockNum)); + } + } while (!in.eof ()); + DEBUG (std::cerr << "\n"); + return new Trace (vBB); + } + + }; // end namespace llvm Index: reopt/lib/TraceIO/TraceWriter.cpp diff -c /dev/null reopt/lib/TraceIO/TraceWriter.cpp:1.1 *** /dev/null Wed Jun 30 01:33:29 2004 --- reopt/lib/TraceIO/TraceWriter.cpp Wed Jun 30 01:33:18 2004 *************** *** 0 **** --- 1,66 ---- + //===-- LightWtProfiling/TraceWriter.cpp -------------------------*- C++ -*--=// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by the LLVM research group and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // This file exports a method which can be used to save a trace to + // disk, along with the module it refers to. + // + //===----------------------------------------------------------------------===// + + #include "llvm/Analysis/Trace.h" + #include "llvm/Bytecode/Writer.h" + #include "llvm/Function.h" + #include "Support/FileUtilities.h" + #include "Support/StringExtras.h" + #include + using namespace llvm; + + namespace llvm { + + /// getBasicBlockIndex - Returns the index of BB in its parent function. + /// + static inline int getBasicBlockIndex (BasicBlock *BB) { + int bbNum = 0; + Function *F = BB->getParent (); + Function::iterator block = F->begin(); + while (&*block != BB) { + ++block; + ++bbNum; + } + return bbNum; + } + + void WriteTraceToFile (Trace *Tr) { + assert (Tr); + + // Get unique filename for trace & corresponding module. + std::string traceFileName, bytecodeFileName; + Function *F = Tr->getFunction (); + unsigned count = 0; + do { + ++count; + traceFileName = F->getName () + ".trace" + utostr (count) + ".txt"; + bytecodeFileName = F->getName () + ".trace" + utostr (count) + ".bc"; + } while (FileOpenable(traceFileName) || FileOpenable(bytecodeFileName)); + + // Write out trace. + std::ofstream out (traceFileName.c_str ()); + out << F->getName () << "\n"; + for (Trace::iterator i = Tr->begin (), e = Tr->end (); i != e; ++i) + out << getBasicBlockIndex (*i) << " "; + out << "\n"; + out.close (); + + // Write out bytecode. FIXME: Should extract function F (as w/ + // 'extract' tool) and write out only F, not its entire module. + std::ofstream bout (bytecodeFileName.c_str ()); + WriteBytecodeToFile(F->getParent (), bout); + bout.close (); + } + + } // end namespace llvm From gaeke at cs.uiuc.edu Wed Jun 30 01:34:09 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed Jun 30 01:34:09 2004 Subject: [llvm-commits] CVS: reopt/include/reopt/TraceJIT.h Message-ID: <200406300633.BAA16919@kain.cs.uiuc.edu> Changes in directory reopt/include/reopt: TraceJIT.h added (r1.1) --- Log message: This header file containing the reoptimizer's JIT's public interface was moved to include/reopt from lib/TraceJIT. --- Diffs of the changes: (+109 -0) Index: reopt/include/reopt/TraceJIT.h diff -c /dev/null reopt/include/reopt/TraceJIT.h:1.1 *** /dev/null Wed Jun 30 01:33:27 2004 --- reopt/include/reopt/TraceJIT.h Wed Jun 30 01:33:17 2004 *************** *** 0 **** --- 1,109 ---- + //===-- TraceJIT.h - Class definition for the TraceJIT ----------*- C++ -*-===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by the LLVM research group and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // This file defines the top-level TraceJIT data structure. + // + //===----------------------------------------------------------------------===// + + #ifndef TRACEJIT_H + #define TRACEJIT_H + + #include "llvm/ExecutionEngine/ExecutionEngine.h" + #include "llvm/PassManager.h" + #include "Support/DataTypes.h" + #include + + namespace llvm { + + class Function; + class GlobalValue; + class Constant; + class TargetMachine; + class TargetJITInfo; + class MachineCodeEmitter; + class TraceFunction; + class UnpackTraceFunction; + + class TraceJIT : public ExecutionEngine { + TargetMachine &TM; // The current target we are compiling to + TargetJITInfo &TJI; // The TargetJITInfo for the current target + + FunctionPassManager PM; // Passes to compile a TraceFunction + MachineCodeEmitter *MCE; // Optimized trace code emitter + UnpackTraceFunction *UTF; // TraceFunction unpacker + + /// PendingGlobals - Global variables which have had memory allocated for them + /// while a function was code generated, but which have not been initialized + /// yet. + std::vector PendingGlobals; + + TraceJIT(ModuleProvider *MP, TargetMachine &tm, TargetJITInfo &tji); + public: + ~TraceJIT(); + + /// create - Create an return a new TraceJIT compiler if there is one available + /// for the current target. Otherwise, return null. If the TraceJIT is created + /// successfully, it takes responsibility for deleting the specified + /// IntrinsicLowering implementation. + /// + static TraceJIT *create(ModuleProvider *MP, IntrinsicLowering *IL = 0); + + /// run - Start execution with the specified function and arguments. + /// + virtual GenericValue runFunction(Function *F, + const std::vector &ArgValues); + + /// getPointerToNamedFunction - This method returns the address of the + /// specified function by using the dlsym function call. As such it is only + /// useful for resolving library symbols, not code generated symbols. + /// + void *getPointerToNamedFunction(const std::string &Name); + + // CompilationCallback - Invoked the first time that a call site is found, + // which causes lazy compilation of the target function. + // + static void CompilationCallback(); + + /// getPointerToFunction - This returns the address of the specified function, + /// compiling it if necessary. + /// + void *getPointerToFunction(Function *F); + + /// getOrEmitGlobalVariable - Return the address of the specified global + /// variable, possibly emitting it to memory if needed. This is used by the + /// Emitter. + void *getOrEmitGlobalVariable(const GlobalVariable *GV); + + /// getPointerToFunctionOrStub - If the specified function has been + /// code-gen'd, return a pointer to the function. If not, compile it, or use + /// a stub to implement lazy compilation if available. + /// + void *getPointerToFunctionOrStub(Function *F); + + /// recompileAndRelinkFunction - This method is used to force a function + /// which has already been compiled, to be compiled again, possibly + /// after it has been modified. Then the entry to the old copy is overwritten + /// with a branch to the new copy. If there was no old copy, this acts + /// just like TraceJIT::getPointerToFunction(). + /// + void *recompileAndRelinkFunction(Function *F); + + uint64_t compileTraceFunction (TraceFunction *TF); + + MachineCodeEmitter *getEmitter() { return MCE; } + private: + void addPassesToReoptimizeTrace (FunctionPassManager &PM); + void maybeAddInternalGlobal (GlobalValue *GV, unsigned int &Counter); + void addInternalGlobalMappings (Module &M); + void runJITOnFunction (Function *F); + }; + + } // End llvm namespace + + #endif From gaeke at cs.uiuc.edu Wed Jun 30 01:34:13 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed Jun 30 01:34:13 2004 Subject: [llvm-commits] CVS: reopt/lib/TraceJIT/TraceJIT.h Message-ID: <200406300633.BAA16912@kain.cs.uiuc.edu> Changes in directory reopt/lib/TraceJIT: TraceJIT.h (r1.3) removed --- Log message: This header file containing the reoptimizer's JIT's public interface was moved to include/reopt from lib/TraceJIT. --- Diffs of the changes: (+0 -0) From gaeke at cs.uiuc.edu Wed Jun 30 01:34:18 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed Jun 30 01:34:18 2004 Subject: [llvm-commits] CVS: reopt/lib/Makefile Message-ID: <200406300633.BAA16762@kain.cs.uiuc.edu> Changes in directory reopt/lib: Makefile updated: 1.22 -> 1.23 --- Log message: Build the TraceIO library. --- Diffs of the changes: (+1 -1) Index: reopt/lib/Makefile diff -u reopt/lib/Makefile:1.22 reopt/lib/Makefile:1.23 --- reopt/lib/Makefile:1.22 Wed May 26 16:24:00 2004 +++ reopt/lib/Makefile Wed Jun 30 01:33:09 2004 @@ -1,5 +1,5 @@ LEVEL = .. -DIRS := BinInterface Mapping TraceCache Trigger LightWtProfiling Inst Optimizations TraceToFunction TraceJIT +DIRS := BinInterface Mapping TraceCache Trigger LightWtProfiling Inst Optimizations TraceToFunction TraceJIT TraceIO include $(LEVEL)/Makefile.config From gaeke at cs.uiuc.edu Wed Jun 30 01:35:02 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed Jun 30 01:35:02 2004 Subject: [llvm-commits] CVS: reopt/include/reopt/TraceIO.h Message-ID: <200406300633.BAA16906@kain.cs.uiuc.edu> Changes in directory reopt/include/reopt: TraceIO.h added (r1.1) --- Log message: This is a new header file containing the trace I/O library's public interface. --- Diffs of the changes: (+21 -0) Index: reopt/include/reopt/TraceIO.h diff -c /dev/null reopt/include/reopt/TraceIO.h:1.1 *** /dev/null Wed Jun 30 01:33:26 2004 --- reopt/include/reopt/TraceIO.h Wed Jun 30 01:33:16 2004 *************** *** 0 **** --- 1,21 ---- + #include + + namespace llvm { + + class Trace; + class Module; + + /// ReadTraceFromFile - Given a module, read a trace for some function + /// in that module from the named file. Returns the Trace object, or a null + /// pointer (and sets ErrorStr) if there was an error. + /// + Trace *ReadTraceFromFile (Module *M, const std::string &filename, + std::string *ErrorStr); + + /// WriteTraceToFile - Write a trace out to a text file, along with the + /// module it came from. + /// + void WriteTraceToFile (Trace *T); + + }; // end namespace llvm + From gaeke at cs.uiuc.edu Wed Jun 30 01:35:06 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed Jun 30 01:35:06 2004 Subject: [llvm-commits] CVS: reopt/tools/dumptrace/dumptrace.cpp Message-ID: <200406300633.BAA16899@kain.cs.uiuc.edu> Changes in directory reopt/tools/dumptrace: dumptrace.cpp updated: 1.1 -> 1.2 --- Log message: Trim and sort #includes in both these source files. Both these tools now use the trace reader from the traceIO library. --- Diffs of the changes: (+3 -76) Index: reopt/tools/dumptrace/dumptrace.cpp diff -u reopt/tools/dumptrace/dumptrace.cpp:1.1 reopt/tools/dumptrace/dumptrace.cpp:1.2 --- reopt/tools/dumptrace/dumptrace.cpp:1.1 Tue Jun 29 16:56:14 2004 +++ reopt/tools/dumptrace/dumptrace.cpp Wed Jun 30 01:33:15 2004 @@ -14,19 +14,14 @@ // //===----------------------------------------------------------------------===// +#include "Support/CommandLine.h" #include "llvm/Analysis/Trace.h" -#include "llvm/Analysis/Verifier.h" #include "llvm/Assembly/Writer.h" #include "llvm/Bytecode/Reader.h" -#include "reopt/TraceToFunction.h" #include "llvm/Module.h" -#include "Support/CommandLine.h" -#include "Support/FileUtilities.h" -#include "Support/StringExtras.h" -#include -#include +#include "reopt/TraceIO.h" #include -#include +#include using namespace llvm; namespace { @@ -38,74 +33,6 @@ cl::value_desc("bytecodeFileName")); }; -//----------------------------------------------------------------------------// - -namespace { - cl::opt Quiet("q", cl::desc("Be quiet"), cl::init(false)); -}; - -/// getBasicBlockByNum - Returns the basic block in F whose index is -/// bbNum. -/// -BasicBlock *getBasicBlockByNum (Function *F, int bbNum) { - Function::iterator block = F->begin(); - std::advance (block, bbNum); - return block; -} - -/// ReadTraceFromFile - Given a module, read a trace for some function -/// in that module from the named file. Returns the Trace object, or a null -/// pointer (and sets ErrorStr) if there was an error. -/// -Trace *ReadTraceFromFile (Module *M, const std::string &filename, - std::string *ErrorStr) { - std::ifstream in (filename.c_str ()); - if (!in.good()) { - if (ErrorStr) - *ErrorStr = std::string("Can't open '") + filename + "': " - + strerror(errno); - return 0; - } - char functionName[160]; - in.getline(functionName, 160, '\n'); - Function *F = M->getNamedFunction (functionName); - if (!F) { - if (ErrorStr) - *ErrorStr = std::string("Function '") + functionName - + "' not found in module"; - return 0; - } - if (!Quiet) - std::cerr << "Function name: '" << functionName << "'\n" - << "Basic blocks: "; - std::vector vBB; - do { - int basicBlockNum; - in >> basicBlockNum; - if (!in.eof ()) { - if (!Quiet) std::cerr << basicBlockNum << " "; - vBB.push_back (getBasicBlockByNum (F, basicBlockNum)); - } - } while (!in.eof ()); - if (!Quiet) std::cerr << "\n"; - return new Trace (vBB); -} - -/// getBasicBlockIndex - Returns the index of BB in its parent function. -/// -int getBasicBlockIndex (BasicBlock *BB) { - int bbNum = 0; - Function *F = BB->getParent (); - Function::iterator block = F->begin(); - while (&*block != BB) { - ++block; - ++bbNum; - } - return bbNum; -} - -//----------------------------------------------------------------------------// - int main (int argc, char **argv) { // Get command line arguments. cl::ParseCommandLineOptions(argc, argv, " trace basic block dumper\n"); From gaeke at cs.uiuc.edu Wed Jun 30 01:35:12 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed Jun 30 01:35:12 2004 Subject: [llvm-commits] CVS: reopt/lib/TraceJIT/TraceJIT.cpp TraceJITEmitter.cpp TraceJITGlobals.cpp TraceJITIntercept.cpp Message-ID: <200406300633.BAA16857@kain.cs.uiuc.edu> Changes in directory reopt/lib/TraceJIT: TraceJIT.cpp updated: 1.2 -> 1.3 TraceJITEmitter.cpp updated: 1.2 -> 1.3 TraceJITGlobals.cpp updated: 1.2 -> 1.3 TraceJITIntercept.cpp updated: 1.1 -> 1.2 --- Log message: TraceJIT.h moved to include/reopt. --- Diffs of the changes: (+4 -4) Index: reopt/lib/TraceJIT/TraceJIT.cpp diff -u reopt/lib/TraceJIT/TraceJIT.cpp:1.2 reopt/lib/TraceJIT/TraceJIT.cpp:1.3 --- reopt/lib/TraceJIT/TraceJIT.cpp:1.2 Thu Jun 3 00:42:45 2004 +++ reopt/lib/TraceJIT/TraceJIT.cpp Wed Jun 30 01:33:12 2004 @@ -12,7 +12,7 @@ // //===----------------------------------------------------------------------===// -#include "TraceJIT.h" +#include "reopt/TraceJIT.h" #include "../LightWtProfiling/ReoptimizerInternal.h" #include "reopt/TraceToFunction.h" #include "reopt/UnpackTraceFunction.h" Index: reopt/lib/TraceJIT/TraceJITEmitter.cpp diff -u reopt/lib/TraceJIT/TraceJITEmitter.cpp:1.2 reopt/lib/TraceJIT/TraceJITEmitter.cpp:1.3 --- reopt/lib/TraceJIT/TraceJITEmitter.cpp:1.2 Tue Jun 8 13:53:58 2004 +++ reopt/lib/TraceJIT/TraceJITEmitter.cpp Wed Jun 30 01:33:12 2004 @@ -17,7 +17,7 @@ // //===----------------------------------------------------------------------===// -#include "TraceJIT.h" +#include "reopt/TraceJIT.h" #include "reopt/ScratchMemory.h" #include "reopt/VirtualMem.h" #include "reopt/InstrUtils.h" Index: reopt/lib/TraceJIT/TraceJITGlobals.cpp diff -u reopt/lib/TraceJIT/TraceJITGlobals.cpp:1.2 reopt/lib/TraceJIT/TraceJITGlobals.cpp:1.3 --- reopt/lib/TraceJIT/TraceJITGlobals.cpp:1.2 Tue Jun 8 13:53:59 2004 +++ reopt/lib/TraceJIT/TraceJITGlobals.cpp Wed Jun 30 01:33:12 2004 @@ -13,7 +13,7 @@ // //===----------------------------------------------------------------------===// -#include "TraceJIT.h" +#include "reopt/TraceJIT.h" #include "llvm/Module.h" #include "Support/Debug.h" using namespace llvm; Index: reopt/lib/TraceJIT/TraceJITIntercept.cpp diff -u reopt/lib/TraceJIT/TraceJITIntercept.cpp:1.1 reopt/lib/TraceJIT/TraceJITIntercept.cpp:1.2 --- reopt/lib/TraceJIT/TraceJITIntercept.cpp:1.1 Wed May 26 16:25:13 2004 +++ reopt/lib/TraceJIT/TraceJITIntercept.cpp Wed Jun 30 01:33:12 2004 @@ -15,7 +15,7 @@ // //===----------------------------------------------------------------------===// -#include "TraceJIT.h" +#include "reopt/TraceJIT.h" #include "Support/DynamicLinker.h" #include #include From gaeke at cs.uiuc.edu Wed Jun 30 01:35:15 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed Jun 30 01:35:15 2004 Subject: [llvm-commits] CVS: reopt/tools/ttftest/ttftest.cpp Message-ID: <200406300633.BAA16892@kain.cs.uiuc.edu> Changes in directory reopt/tools/ttftest: ttftest.cpp updated: 1.5 -> 1.6 --- Log message: Trim and sort #includes in both these source files. Both these tools now use the trace reader from the traceIO library. --- Diffs of the changes: (+4 -68) Index: reopt/tools/ttftest/ttftest.cpp diff -u reopt/tools/ttftest/ttftest.cpp:1.5 reopt/tools/ttftest/ttftest.cpp:1.6 --- reopt/tools/ttftest/ttftest.cpp:1.5 Mon Jun 14 01:42:38 2004 +++ reopt/tools/ttftest/ttftest.cpp Wed Jun 30 01:33:15 2004 @@ -14,19 +14,15 @@ // //===----------------------------------------------------------------------===// +#include "Support/CommandLine.h" #include "llvm/Analysis/Trace.h" #include "llvm/Analysis/Verifier.h" #include "llvm/Assembly/Writer.h" #include "llvm/Bytecode/Reader.h" -#include "reopt/TraceToFunction.h" #include "llvm/Module.h" -#include "Support/CommandLine.h" -#include "Support/FileUtilities.h" -#include "Support/StringExtras.h" +#include "reopt/TraceIO.h" +#include "reopt/TraceToFunction.h" #include -#include -#include -#include using namespace llvm; namespace { @@ -36,71 +32,11 @@ cl::opt BytecodeFile("bc", cl::desc("Name of file containing module"), cl::value_desc("bytecodeFileName")); - cl::opt Quiet("q", cl::desc("Be quiet"), cl::init(false)); cl::opt PrintLiveSets("print-live", cl::desc("Print live-in/out sets to stdout"), cl::init(false)); + cl::opt Quiet("q", cl::desc("Be quiet"), cl::init(false)); }; -/// getBasicBlockByNum - Returns the basic block in F whose index is -/// bbNum. -/// -BasicBlock *getBasicBlockByNum (Function *F, int bbNum) { - Function::iterator block = F->begin(); - std::advance (block, bbNum); - return block; -} - -/// ReadTraceFromFile - Given a module, read a trace for some function -/// in that module from the named file. Returns the Trace object, or a null -/// pointer (and sets ErrorStr) if there was an error. -/// -Trace *ReadTraceFromFile (Module *M, const std::string &filename, - std::string *ErrorStr) { - std::ifstream in (filename.c_str ()); - if (!in.good()) { - if (ErrorStr) - *ErrorStr = std::string("Can't open '") + filename + "': " - + strerror(errno); - return 0; - } - char functionName[160]; - in.getline(functionName, 160, '\n'); - Function *F = M->getNamedFunction (functionName); - if (!F) { - if (ErrorStr) - *ErrorStr = std::string("Function '") + functionName - + "' not found in module"; - return 0; - } - if (!Quiet) - std::cerr << "Function name: '" << functionName << "'\n" - << "Basic blocks: "; - std::vector vBB; - do { - int basicBlockNum; - in >> basicBlockNum; - if (!in.eof ()) { - if (!Quiet) std::cerr << basicBlockNum << " "; - vBB.push_back (getBasicBlockByNum (F, basicBlockNum)); - } - } while (!in.eof ()); - if (!Quiet) std::cerr << "\n"; - return new Trace (vBB); -} - -/// getBasicBlockIndex - Returns the index of BB in its parent function. -/// -int getBasicBlockIndex (BasicBlock *BB) { - int bbNum = 0; - Function *F = BB->getParent (); - Function::iterator block = F->begin(); - while (&*block != BB) { - ++block; - ++bbNum; - } - return bbNum; -} - void printLiveSet (std::ostream &OS, const std::string Banner, LiveVariableSet &S, TraceFunction *TF, bool printCorrespondingValues = true) { From gaeke at cs.uiuc.edu Wed Jun 30 01:35:19 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed Jun 30 01:35:19 2004 Subject: [llvm-commits] CVS: reopt/tools/Makefile Message-ID: <200406300633.BAA16870@kain.cs.uiuc.edu> Changes in directory reopt/tools: Makefile updated: 1.4 -> 1.5 --- Log message: Build dumptrace by default. --- Diffs of the changes: (+1 -1) Index: reopt/tools/Makefile diff -u reopt/tools/Makefile:1.4 reopt/tools/Makefile:1.5 --- reopt/tools/Makefile:1.4 Wed May 19 03:47:01 2004 +++ reopt/tools/Makefile Wed Jun 30 01:33:13 2004 @@ -1,6 +1,6 @@ LEVEL := .. -DIRS := ttftest +DIRS := ttftest dumptrace include $(LEVEL)/Makefile.config From gaeke at cs.uiuc.edu Wed Jun 30 01:35:24 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed Jun 30 01:35:24 2004 Subject: [llvm-commits] CVS: reopt/tools/ttftest/Makefile Message-ID: <200406300633.BAA16878@kain.cs.uiuc.edu> Changes in directory reopt/tools/ttftest: Makefile updated: 1.1 -> 1.2 --- Log message: Link with the TraceIO library, which requires bcwriter. --- Diffs of the changes: (+2 -2) Index: reopt/tools/ttftest/Makefile diff -u reopt/tools/ttftest/Makefile:1.1 reopt/tools/ttftest/Makefile:1.2 --- reopt/tools/ttftest/Makefile:1.1 Mon May 17 16:25:25 2004 +++ reopt/tools/ttftest/Makefile Wed Jun 30 01:33:14 2004 @@ -1,7 +1,7 @@ LEVEL = ../.. TOOLNAME = ttftest -USEDLIBS = tracetofunction -LLVMLIBS = vmcore bcreader analysis.a transformutils.a support.a +USEDLIBS = tracetofunction traceio +LLVMLIBS = vmcore bcreader bcwriter analysis.a transformutils.a support.a TOOLLINKOPTS = $(PLATFORMLIBDL) From gaeke at cs.uiuc.edu Wed Jun 30 01:35:28 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed Jun 30 01:35:28 2004 Subject: [llvm-commits] CVS: reopt/tools/dumptrace/Makefile Message-ID: <200406300633.BAA16885@kain.cs.uiuc.edu> Changes in directory reopt/tools/dumptrace: Makefile updated: 1.1 -> 1.2 --- Log message: Link with the TraceIO library, which requires bcwriter. --- Diffs of the changes: (+2 -1) Index: reopt/tools/dumptrace/Makefile diff -u reopt/tools/dumptrace/Makefile:1.1 reopt/tools/dumptrace/Makefile:1.2 --- reopt/tools/dumptrace/Makefile:1.1 Tue Jun 29 16:56:14 2004 +++ reopt/tools/dumptrace/Makefile Wed Jun 30 01:33:14 2004 @@ -1,6 +1,7 @@ LEVEL = ../.. TOOLNAME = dumptrace -LLVMLIBS = vmcore bcreader analysis.a transformutils.a support.a +USEDLIBS = traceio +LLVMLIBS = vmcore bcreader bcwriter analysis.a transformutils.a support.a TOOLLINKOPTS = $(PLATFORMLIBDL) From gaeke at cs.uiuc.edu Wed Jun 30 01:36:02 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed Jun 30 01:36:02 2004 Subject: [llvm-commits] CVS: reopt/lib/LightWtProfiling/ReoptimizerInternal.h Message-ID: <200406300633.BAA16773@kain.cs.uiuc.edu> Changes in directory reopt/lib/LightWtProfiling: ReoptimizerInternal.h updated: 1.6 -> 1.7 --- Log message: WriteTraceToFile's public prototype is now in reopt/TraceIO.h, because TraceWriter.cpp moved to the TraceIO library. We don't need to declare it here. --- Diffs of the changes: (+0 -4) Index: reopt/lib/LightWtProfiling/ReoptimizerInternal.h diff -u reopt/lib/LightWtProfiling/ReoptimizerInternal.h:1.6 reopt/lib/LightWtProfiling/ReoptimizerInternal.h:1.7 --- reopt/lib/LightWtProfiling/ReoptimizerInternal.h:1.6 Sun Jun 27 21:28:05 2004 +++ reopt/lib/LightWtProfiling/ReoptimizerInternal.h Wed Jun 30 01:33:10 2004 @@ -156,10 +156,6 @@ bool optimizeTrace (std::vector &vBB, uint64_t a); -// TraceWriter.cpp ////////////////////////////////////////////////////// - -void WriteTraceToFile (Trace *T); - }; // end namespace llvm #endif // REOPTIMIZERINTERNAL_H From gaeke at cs.uiuc.edu Wed Jun 30 01:36:07 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed Jun 30 01:36:07 2004 Subject: [llvm-commits] CVS: reopt/lib/LightWtProfiling/TraceWriter.cpp Message-ID: <200406300633.BAA16956@kain.cs.uiuc.edu> Changes in directory reopt/lib/LightWtProfiling: TraceWriter.cpp (r1.3) removed --- Log message: The trace writer has been incorporated into the trace I/O library. --- Diffs of the changes: (+0 -0) From gaeke at cs.uiuc.edu Wed Jun 30 01:36:11 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed Jun 30 01:36:11 2004 Subject: [llvm-commits] CVS: reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp Message-ID: <200406300633.BAA16785@kain.cs.uiuc.edu> Changes in directory reopt/lib/LightWtProfiling: RuntimeOptimizations.cpp updated: 1.45 -> 1.46 --- Log message: TraceJIT.h moved to include/reopt. We now include TraceIO.h to get the trace writer's prototype. --- Diffs of the changes: (+2 -1) Index: reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp diff -u reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp:1.45 reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp:1.46 --- reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp:1.45 Sun Jun 27 21:28:05 2004 +++ reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp Wed Jun 30 01:33:11 2004 @@ -14,11 +14,12 @@ //===----------------------------------------------------------------------===// #include "ReoptimizerInternal.h" -#include "../TraceJIT/TraceJIT.h" +#include "reopt/TraceJIT.h" #include "reopt/UnpackTraceFunction.h" #include "reopt/TraceToFunction.h" #include "reopt/VirtualMem.h" #include "reopt/InstrUtils.h" +#include "reopt/TraceIO.h" #include "Support/Debug.h" #include "llvm/Analysis/Verifier.h" #include "llvm/Assembly/PrintModulePass.h" From jmanton at cs.uiuc.edu Wed Jun 30 13:14:01 2004 From: jmanton at cs.uiuc.edu (Jonathan Manton) Date: Wed Jun 30 13:14:01 2004 Subject: [llvm-commits] CVS: llvm/docs/WritingAnLLVMPass.html Message-ID: <200406301810.NAA19321@zion.cs.uiuc.edu> Changes in directory llvm/docs: WritingAnLLVMPass.html updated: 1.29 -> 1.30 --- Log message: Fixed the tutorial to indicate that we needed to use the llvm namespace. --- Diffs of the changes: (+11 -1) Index: llvm/docs/WritingAnLLVMPass.html diff -u llvm/docs/WritingAnLLVMPass.html:1.29 llvm/docs/WritingAnLLVMPass.html:1.30 --- llvm/docs/WritingAnLLVMPass.html:1.29 Tue Jun 22 03:02:25 2004 +++ llvm/docs/WritingAnLLVMPass.html Wed Jun 30 13:10:30 2004 @@ -204,6 +204,14 @@ href="http://llvm.cs.uiuc.edu/doxygen/classllvm_1_1Function.html">Function's.

      Next we have:

      +
      +using namespace llvm;
      +
      +

      ... which is required because the functions from the include files +live in the llvm namespace. +

      + +

      Next we have:

       namespace {
      @@ -259,6 +267,8 @@
       #include "llvm/Pass.h"
       #include "llvm/Function.h"
       
      +using namespace llvm;
      +
       namespace {
         struct Hello : public FunctionPass {
           virtual bool runOnFunction(Function &F) {
      @@ -1471,7 +1481,7 @@
       
         Chris Lattner
      The LLVM Compiler Infrastructure
      - Last modified: $Date: 2004/06/22 08:02:25 $ + Last modified: $Date: 2004/06/30 18:10:30 $ From lattner at cs.uiuc.edu Wed Jun 30 16:28:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Jun 30 16:28:01 2004 Subject: [llvm-commits] CVS: llvm-www/pubs/2003-10-01-LLVA.ppt 2003-10-01-LLVA.html Message-ID: <200406302127.QAA21430@zion.cs.uiuc.edu> Changes in directory llvm-www/pubs: 2003-10-01-LLVA.ppt added (r1.1) 2003-10-01-LLVA.html updated: 1.4 -> 1.5 --- Log message: Add the slides for the micro talk --- Diffs of the changes: (+2 -0) Index: llvm-www/pubs/2003-10-01-LLVA.ppt Index: llvm-www/pubs/2003-10-01-LLVA.html diff -u llvm-www/pubs/2003-10-01-LLVA.html:1.4 llvm-www/pubs/2003-10-01-LLVA.html:1.5 --- llvm-www/pubs/2003-10-01-LLVA.html:1.4 Tue Oct 21 19:26:00 2003 +++ llvm-www/pubs/2003-10-01-LLVA.html Wed Jun 30 16:26:58 2004 @@ -56,6 +56,8 @@ Architecture (PS)
    • LLVA: A Low-level Virtual Instruction Set Architecture (PDF)
    • +
    • LLVA: A Low-level Virtual Instruction Set + Architecture slides (PPT)
    • BibTeX Entry:

      From llvm at cs.uiuc.edu Wed Jun 30 21:34:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Wed Jun 30 21:34:01 2004 Subject: [llvm-commits] CVS: llvm/docs/CommandGuide/llvm-abcd.html Message-ID: <200407010232.VAA23199@zion.cs.uiuc.edu> Changes in directory llvm/docs/CommandGuide: llvm-abcd.html added (r1.1) --- Log message: Added a command page for the llvm-abcd tool. --- Diffs of the changes: (+44 -0) Index: llvm/docs/CommandGuide/llvm-abcd.html diff -c /dev/null llvm/docs/CommandGuide/llvm-abcd.html:1.1 *** /dev/null Wed Jun 30 21:32:52 2004 --- llvm/docs/CommandGuide/llvm-abcd.html Wed Jun 30 21:32:42 2004 *************** *** 0 **** --- 1,44 ---- + + LLVM: llvm-abcd tool + + +
      +

      LLVM: llvm-abcd tool

      +
      +

      NAME

      llvm-abcd +

      SYNOPSIS

      llvm-abcd [options] [filename] +

      DESCRIPTION

      The llvm-abcd command is a small utility for analyzing + bytecode files. The abcd acronym stands for analysis of + bytecode displayer. The tool reads a bytecode file (such as + generated with the llvm-abcd tool) and produces statistical and low level + bytecode format dumps. This tool is probably not of much interest or utility except + for those working directly with the bytecode format. Most LLVM users can just ignore + this tool. +

      If filename is omitted or is -, then llvm-abcd reads its input from + standard input. This is useful for combining llvm-abcd in a pipeline. +

      +

      OPTIONS

      +
        +
      • -nodetails
        Causes llvm-abcd to abbreviate its output by writing + out only a module level summary. The details for individual functions are not + displayed. +

        +
      • -dump
        Causes llvm-abcd to dump the bytecode in a human readable + format. This format is significantly different from LLVM assembly and provides + details about the encoding of the bytecode file. +

        +
      • -verify
        Causes llvm-abcd to verify the module produced by + by reading the bytecode. This ensures that the statistics generated are reliable. +

        +
      • -help
        Print a summary of command line options. +

      +

      EXIT STATUS

      If llvm-abcd succeeds, it will exit with 0. + Otherwise, if an error occurs, it will exit with a non-zero value, usually 1. +

      SEE ALSO

      llvm-dis + LLVM Bytecode File Format + +
      + Maintained by Reid Spencer. + From lattner at cs.uiuc.edu Wed Jun 30 23:10:00 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Jun 30 23:10:00 2004 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/SimplifyCFG/InvokeEliminate.ll Message-ID: <200407010409.XAA03745@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/SimplifyCFG: InvokeEliminate.ll updated: 1.2 -> 1.3 --- Log message: Fix testcase. For some reason this was failing only with a release build and not with a debug build? Rather testrunner only caught it in that case. --- Diffs of the changes: (+1 -3) Index: llvm/test/Regression/Transforms/SimplifyCFG/InvokeEliminate.ll diff -u llvm/test/Regression/Transforms/SimplifyCFG/InvokeEliminate.ll:1.2 llvm/test/Regression/Transforms/SimplifyCFG/InvokeEliminate.ll:1.3 --- llvm/test/Regression/Transforms/SimplifyCFG/InvokeEliminate.ll:1.2 Tue Sep 16 10:29:52 2003 +++ llvm/test/Regression/Transforms/SimplifyCFG/InvokeEliminate.ll Wed Jun 30 23:09:14 2004 @@ -6,14 +6,12 @@ ; RUN: llvm-as < %s | opt -simplifycfg | llvm-dis | not egrep 'invoke|br' declare void %bar() -declare void %llvm.unwind() int %test() { invoke void %bar() to label %Ok except label %Rethrow Ok: ret int 0 Rethrow: - call void %llvm.unwind() - br label %Ok + unwind } From lattner at cs.uiuc.edu Wed Jun 30 23:11:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Jun 30 23:11:01 2004 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/LevelRaise/2003-01-30-ShiftCrash.ll Message-ID: <200407010410.XAA03775@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/LevelRaise: 2003-01-30-ShiftCrash.ll updated: 1.2 -> 1.3 --- Log message: -debug option does not exist in a release build --- Diffs of the changes: (+1 -1) Index: llvm/test/Regression/Transforms/LevelRaise/2003-01-30-ShiftCrash.ll diff -u llvm/test/Regression/Transforms/LevelRaise/2003-01-30-ShiftCrash.ll:1.2 llvm/test/Regression/Transforms/LevelRaise/2003-01-30-ShiftCrash.ll:1.3 --- llvm/test/Regression/Transforms/LevelRaise/2003-01-30-ShiftCrash.ll:1.2 Tue Sep 16 10:29:37 2003 +++ llvm/test/Regression/Transforms/LevelRaise/2003-01-30-ShiftCrash.ll Wed Jun 30 23:10:15 2004 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | opt -raise -debug -raise-start-inst=cast459 +; RUN: llvm-as < %s | opt -raise -raise-start-inst=cast459 int %deflateInit2_({ ubyte*, uint, ulong, ubyte*, uint, ulong, sbyte*, { \4, int, ubyte*, ulong, ubyte*, int, int, ubyte, ubyte, int, uint, uint, uint, ubyte*, ulong, ushort*, ushort*, uint, uint, uint, uint, uint, long, uint, uint, int, uint, uint, uint, uint, uint, uint, int, int, uint, int, [573 x { { ushort }, { ushort } }], [61 x { { ushort }, { ushort } }], [39 x { { ushort }, { ushort } }], { { { ushort }, { ushort } }*, int, { int }* }, { { { ushort }, { ushort } }*, int, { int }* }, { { { ushort }, { ushort } }*, int, { int }* }, [16 x ushort], [573 x int], int, int, [573 x ubyte], ubyte*, uint, uint, ushort*, ulong, ulong, uint, int, ushort, int }*, sbyte* (sbyte*, uint, uint)*, void (sbyte*, sbyte*)*, sbyte*, int, ulong, ulong }* %strm, int %level, int %method, int %windowBits, int %memLevel, int %strategy, sbyte* %version, int %stream_size) { bb0: ; No predecessors! From lattner at cs.uiuc.edu Wed Jun 30 23:12:00 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Jun 30 23:12:00 2004 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/ConstProp/calls.ll Message-ID: <200407010411.XAA03812@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/ConstProp: calls.ll updated: 1.2 -> 1.3 --- Log message: Fix testcase --- Diffs of the changes: (+3 -3) Index: llvm/test/Regression/Transforms/ConstProp/calls.ll diff -u llvm/test/Regression/Transforms/ConstProp/calls.ll:1.2 llvm/test/Regression/Transforms/ConstProp/calls.ll:1.3 --- llvm/test/Regression/Transforms/ConstProp/calls.ll:1.2 Fri Jun 11 01:16:13 2004 +++ llvm/test/Regression/Transforms/ConstProp/calls.ll Wed Jun 30 23:11:35 2004 @@ -4,7 +4,7 @@ declare double %sin(double) declare double %tan(double) declare double %sqrt(double) -declare bool %llvm.isnan(double) +declare bool %llvm.isunordered(double, double) double %T() { %A = call double %cos(double 0.0) @@ -18,8 +18,8 @@ } bool %TNAN() { - %A = call bool %llvm.isnan(double 0x7FF8000000000000) ;; it's a nan! - %B = call bool %llvm.isnan(double 123.0) + %A = call bool %llvm.isunordered(double 0x7FF8000000000000, double 1.0) ;; it's a nan! + %B = call bool %llvm.isunordered(double 123.0, double 1.0) %C = or bool %A, %B ret bool %C } From lattner at cs.uiuc.edu Wed Jun 30 23:25:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Jun 30 23:25:01 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveVariables.cpp Message-ID: <200407010424.XAA04059@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveVariables.cpp updated: 1.33 -> 1.34 --- Log message: Instead of building a private numbering of MBB's use brg's nifty auto-numbering. Also convert df_iterator -> df_ext_iterator for subsequent stuff I'm doing. --- Diffs of the changes: (+5 -5) Index: llvm/lib/CodeGen/LiveVariables.cpp diff -u llvm/lib/CodeGen/LiveVariables.cpp:1.33 llvm/lib/CodeGen/LiveVariables.cpp:1.34 --- llvm/lib/CodeGen/LiveVariables.cpp:1.33 Thu Jun 24 16:31:16 2004 +++ llvm/lib/CodeGen/LiveVariables.cpp Wed Jun 30 23:24:29 2004 @@ -178,9 +178,8 @@ } // Build BBMap... - unsigned BBNum = 0; for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I) - BBMap[I] = BBNum++; + BBMap[I] = I->getNumber(); // PhysRegInfo - Keep track of which instruction was the last use of a // physical register. This is a purely local property, because all physical @@ -201,8 +200,9 @@ // nodes, which are treated as a special case). // MachineBasicBlock *Entry = MF.begin(); - for (df_iterator DFI = df_begin(Entry), E = df_end(Entry); - DFI != E; ++DFI) { + std::set Visited; + for (df_ext_iterator DFI = df_ext_begin(Entry, Visited), + E = df_ext_end(Entry, Visited); DFI != E; ++DFI) { MachineBasicBlock *MBB = *DFI; unsigned BBNum = getMachineBasicBlockIndex(MBB); @@ -310,7 +310,7 @@ RegistersKilled.insert(std::make_pair(VirtRegInfo[i].Kills[j].second, i + MRegisterInfo::FirstVirtualRegister)); } - + return false; } From lattner at cs.uiuc.edu Wed Jun 30 23:31:00 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Jun 30 23:31:00 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervals.cpp LiveVariables.cpp PHIElimination.cpp Message-ID: <200407010429.XAA05572@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveIntervals.cpp updated: 1.81 -> 1.82 LiveVariables.cpp updated: 1.34 -> 1.35 PHIElimination.cpp updated: 1.27 -> 1.28 --- Log message: Start using MBB numbers directly instead of going through the live variables map. --- Diffs of the changes: (+4 -4) Index: llvm/lib/CodeGen/LiveIntervals.cpp diff -u llvm/lib/CodeGen/LiveIntervals.cpp:1.81 llvm/lib/CodeGen/LiveIntervals.cpp:1.82 --- llvm/lib/CodeGen/LiveIntervals.cpp:1.81 Tue Jun 29 02:16:23 2004 +++ llvm/lib/CodeGen/LiveIntervals.cpp Wed Jun 30 23:29:47 2004 @@ -96,7 +96,7 @@ unsigned miIndex = 0; for (MachineFunction::iterator mbb = mf_->begin(), mbbEnd = mf_->end(); mbb != mbbEnd; ++mbb) { - unsigned mbbIdx = lv_->getMachineBasicBlockIndex(mbb); + unsigned mbbIdx = mbb->getNumber(); bool inserted = mbbi2mbbMap_.insert(std::make_pair(mbbIdx, mbb)).second; assert(inserted && "multiple index -> MachineBasicBlock"); Index: llvm/lib/CodeGen/LiveVariables.cpp diff -u llvm/lib/CodeGen/LiveVariables.cpp:1.34 llvm/lib/CodeGen/LiveVariables.cpp:1.35 --- llvm/lib/CodeGen/LiveVariables.cpp:1.34 Wed Jun 30 23:24:29 2004 +++ llvm/lib/CodeGen/LiveVariables.cpp Wed Jun 30 23:29:47 2004 @@ -70,7 +70,7 @@ void LiveVariables::MarkVirtRegAliveInBlock(VarInfo &VRInfo, MachineBasicBlock *MBB) { - unsigned BBNum = getMachineBasicBlockIndex(MBB); + unsigned BBNum = MBB->getNumber(); // Check to see if this basic block is one of the killing blocks. If so, // remove it... @@ -204,7 +204,7 @@ for (df_ext_iterator DFI = df_ext_begin(Entry, Visited), E = df_ext_end(Entry, Visited); DFI != E; ++DFI) { MachineBasicBlock *MBB = *DFI; - unsigned BBNum = getMachineBasicBlockIndex(MBB); + unsigned BBNum = MBB->getNumber(); // Loop over all of the instructions, processing them. for (MachineBasicBlock::iterator I = MBB->begin(), E = MBB->end(); Index: llvm/lib/CodeGen/PHIElimination.cpp diff -u llvm/lib/CodeGen/PHIElimination.cpp:1.27 llvm/lib/CodeGen/PHIElimination.cpp:1.28 --- llvm/lib/CodeGen/PHIElimination.cpp:1.27 Wed Jun 2 00:57:12 2004 +++ llvm/lib/CodeGen/PHIElimination.cpp Wed Jun 30 23:29:47 2004 @@ -226,7 +226,7 @@ MachineBasicBlock *SuccMBB = *SI; // Is it alive in this successor? - unsigned SuccIdx = LV->getMachineBasicBlockIndex(SuccMBB); + unsigned SuccIdx = SuccMBB->getNumber(); if (SuccIdx < InRegVI.AliveBlocks.size() && InRegVI.AliveBlocks[SuccIdx]) { ValueIsLive = true; From lattner at cs.uiuc.edu Thu Jul 1 01:02:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Jul 1 01:02:02 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/MachineFunction.h Message-ID: <200407010601.BAA17498@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: MachineFunction.h updated: 1.36 -> 1.37 --- Log message: Change the implementation of the autonumbering for MBB's a bit to provide the reverse mapping as well as the mapping from MBB->unsigned --- Diffs of the changes: (+33 -6) Index: llvm/include/llvm/CodeGen/MachineFunction.h diff -u llvm/include/llvm/CodeGen/MachineFunction.h:1.36 llvm/include/llvm/CodeGen/MachineFunction.h:1.37 --- llvm/include/llvm/CodeGen/MachineFunction.h:1.36 Fri Jun 4 09:51:25 2004 +++ llvm/include/llvm/CodeGen/MachineFunction.h Thu Jul 1 01:01:36 2004 @@ -82,8 +82,10 @@ // Keep track of constants which are spilled to memory MachineConstantPool *ConstantPool; - // Function-level unique numbering for MachineBasicBlocks - int NextMBBNumber; + // Function-level unique numbering for MachineBasicBlocks. When a + // MachineBasicBlock is inserted into a MachineFunction is it automatically + // numbered and this vector keeps track of the mapping from ID's to MBB's. + std::vector MBBNumbering; public: MachineFunction(const Function *Fn, const TargetMachine &TM); @@ -118,10 +120,15 @@ /// MachineFunctionInfo *getInfo() const { return MFInfo; } - /// getNextMBBNumber - Returns the next unique number to be assigned - /// to a MachineBasicBlock in this MachineFunction. - /// - int getNextMBBNumber() { return NextMBBNumber++; } + /// getBlockNumbered - MachineBasicBlocks are automatically numbered when they + /// are inserted into the machine function. The block number for a machine + /// basic block can be found by using the MBB::getBlockNumber method, this + /// method provides the inverse mapping. + MachineBasicBlock *getBlockNumbered(unsigned N) { + assert(N < MBBNumbering.size() && "Illegal block number"); + assert(MBBNumbering[N] && "Block was removed from the machine function!"); + return MBBNumbering[N]; + } /// print - Print out the MachineFunction in a format suitable for debugging /// to the specified stream. @@ -177,6 +184,26 @@ MachineBasicBlock &front() { return BasicBlocks.front(); } const MachineBasicBlock & back() const { return BasicBlocks.back(); } MachineBasicBlock & back() { return BasicBlocks.back(); } + + //===--------------------------------------------------------------------===// + // Internal functions used to automatically number MachineBasicBlocks + // + + /// getNextMBBNumber - Returns the next unique number to be assigned + /// to a MachineBasicBlock in this MachineFunction. + /// + unsigned addToMBBNumbering(MachineBasicBlock *MBB) { + MBBNumbering.push_back(MBB); + return MBBNumbering.size()-1; + } + + /// removeFromMBBNumbering - Remove the specific machine basic block from our + /// tracker, this is only really to be used by the MachineBasicBlock + /// implementation. + void removeFromMBBNumbering(unsigned N) { + assert(N < MBBNumbering.size() && "Illegal basic block #"); + MBBNumbering[N] = 0; + } }; } // End llvm namespace From lattner at cs.uiuc.edu Thu Jul 1 01:03:00 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Jul 1 01:03:00 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/MachineFunction.cpp Message-ID: <200407010602.BAA17520@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: MachineFunction.cpp updated: 1.60 -> 1.61 --- Log message: Instance var no longer exists --- Diffs of the changes: (+1 -1) Index: llvm/lib/CodeGen/MachineFunction.cpp diff -u llvm/lib/CodeGen/MachineFunction.cpp:1.60 llvm/lib/CodeGen/MachineFunction.cpp:1.61 --- llvm/lib/CodeGen/MachineFunction.cpp:1.60 Fri Jun 11 01:37:11 2004 +++ llvm/lib/CodeGen/MachineFunction.cpp Thu Jul 1 01:02:07 2004 @@ -106,7 +106,7 @@ MachineFunction::MachineFunction(const Function *F, const TargetMachine &TM) - : Annotation(MF_AID), Fn(F), Target(TM), NextMBBNumber(0) { + : Annotation(MF_AID), Fn(F), Target(TM) { SSARegMapping = new SSARegMap(); MFInfo = new MachineFunctionInfo(*this); FrameInfo = new MachineFrameInfo(); From lattner at cs.uiuc.edu Thu Jul 1 01:03:05 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Jul 1 01:03:05 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/MachineBasicBlock.cpp Message-ID: <200407010602.BAA17515@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: MachineBasicBlock.cpp updated: 1.16 -> 1.17 --- Log message: Change MBB autonumber a bit to get the reverse mapping as well as a forward mapping --- Diffs of the changes: (+6 -10) Index: llvm/lib/CodeGen/MachineBasicBlock.cpp diff -u llvm/lib/CodeGen/MachineBasicBlock.cpp:1.16 llvm/lib/CodeGen/MachineBasicBlock.cpp:1.17 --- llvm/lib/CodeGen/MachineBasicBlock.cpp:1.16 Thu Jun 24 19:13:11 2004 +++ llvm/lib/CodeGen/MachineBasicBlock.cpp Thu Jul 1 01:02:27 2004 @@ -29,27 +29,23 @@ // MBBs start out as #-1. When a MBB is added to a MachineFunction, it // gets the next available unique MBB number. If it is removed from a // MachineFunction, it goes back to being #-1. -void ilist_traits::addNodeToList (MachineBasicBlock* N) -{ +void ilist_traits::addNodeToList(MachineBasicBlock* N) { assert(N->Parent == 0 && "machine instruction already in a basic block"); N->Parent = Parent; - N->Number = Parent->getNextMBBNumber(); + N->Number = Parent->addToMBBNumbering(N); LeakDetector::removeGarbageObject(N); - - } -void ilist_traits::removeNodeFromList (MachineBasicBlock* N) -{ +void ilist_traits::removeNodeFromList(MachineBasicBlock* N) { assert(N->Parent != 0 && "machine instruction not in a basic block"); - N->Parent = 0; + N->Parent->removeFromMBBNumbering(N->Number); N->Number = -1; + N->Parent = 0; LeakDetector::addGarbageObject(N); } -MachineInstr* ilist_traits::createNode() -{ +MachineInstr* ilist_traits::createNode() { MachineInstr* dummy = new MachineInstr(0, 0); LeakDetector::removeGarbageObject(dummy); return dummy; From lattner at cs.uiuc.edu Thu Jul 1 01:16:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Jul 1 01:16:01 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervals.cpp LiveVariables.cpp Message-ID: <200407010615.BAA28614@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveIntervals.cpp updated: 1.82 -> 1.83 LiveVariables.cpp updated: 1.35 -> 1.36 --- Log message: Now that MachineFunction/MachineBasicBlock keep a mapping of blocks to ID #'s use them instead of a local LiveVariables numbering --- Diffs of the changes: (+1 -21) Index: llvm/lib/CodeGen/LiveIntervals.cpp diff -u llvm/lib/CodeGen/LiveIntervals.cpp:1.82 llvm/lib/CodeGen/LiveIntervals.cpp:1.83 --- llvm/lib/CodeGen/LiveIntervals.cpp:1.82 Wed Jun 30 23:29:47 2004 +++ llvm/lib/CodeGen/LiveIntervals.cpp Thu Jul 1 01:15:32 2004 @@ -292,7 +292,7 @@ if (interval.empty()) { for (unsigned i = 0, e = vi.AliveBlocks.size(); i != e; ++i) { if (vi.AliveBlocks[i]) { - MachineBasicBlock* mbb = lv_->getIndexMachineBasicBlock(i); + MachineBasicBlock* mbb = mf_->getBlockNumbered(i); if (!mbb->empty()) { interval.addRange( getInstructionIndex(&mbb->front()), Index: llvm/lib/CodeGen/LiveVariables.cpp diff -u llvm/lib/CodeGen/LiveVariables.cpp:1.35 llvm/lib/CodeGen/LiveVariables.cpp:1.36 --- llvm/lib/CodeGen/LiveVariables.cpp:1.35 Wed Jun 30 23:29:47 2004 +++ llvm/lib/CodeGen/LiveVariables.cpp Thu Jul 1 01:15:32 2004 @@ -37,22 +37,6 @@ static RegisterAnalysis X("livevars", "Live Variable Analysis"); -/// getIndexMachineBasicBlock() - Given a block index, return the -/// MachineBasicBlock corresponding to it. -MachineBasicBlock *LiveVariables::getIndexMachineBasicBlock(unsigned Idx) { - if (BBIdxMap.empty()) { - BBIdxMap.resize(BBMap.size()); - for (std::map::iterator I = BBMap.begin(), - E = BBMap.end(); I != E; ++I) { - assert(BBIdxMap.size() > I->second && "Indices are not sequential"); - assert(BBIdxMap[I->second] == 0 && "Multiple idx collision!"); - BBIdxMap[I->second] = I->first; - } - } - assert(Idx < BBIdxMap.size() && "BB Index out of range!"); - return BBIdxMap[Idx]; -} - LiveVariables::VarInfo &LiveVariables::getVarInfo(unsigned RegIdx) { assert(MRegisterInfo::isVirtualRegister(RegIdx) && "getVarInfo: not a virtual register!"); @@ -177,10 +161,6 @@ AllocatablePhysicalRegisters[*I] = true; // The reg is allocatable! } - // Build BBMap... - for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I) - BBMap[I] = I->getNumber(); - // PhysRegInfo - Keep track of which instruction was the last use of a // physical register. This is a purely local property, because all physical // register references as presumed dead across basic blocks. From lattner at cs.uiuc.edu Thu Jul 1 01:16:08 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Jul 1 01:16:08 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/LiveVariables.h Message-ID: <200407010615.BAA28603@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: LiveVariables.h updated: 1.14 -> 1.15 --- Log message: Now that we have happy mappings from MBBs->numbers, use them instead of keeping a LV private map --- Diffs of the changes: (+0 -23) Index: llvm/include/llvm/CodeGen/LiveVariables.h diff -u llvm/include/llvm/CodeGen/LiveVariables.h:1.14 llvm/include/llvm/CodeGen/LiveVariables.h:1.15 --- llvm/include/llvm/CodeGen/LiveVariables.h:1.14 Sat May 1 16:23:35 2004 +++ llvm/include/llvm/CodeGen/LiveVariables.h Thu Jul 1 01:14:57 2004 @@ -99,16 +99,6 @@ std::vector AllocatablePhysicalRegisters; private: // Intermediate data structures - - /// BBMap - This provides a numbering of the basic blocks in the function. - /// - std::map BBMap; - - /// BBIdxMap - This contains the inverse mapping of BBMap, going from block ID - /// numbers to the corresponding MachineBasicBlock. This is lazily computed - /// when the getIndexMachineBasicBlock() method is called. - std::vector BBIdxMap; - const MRegisterInfo *RegInfo; MachineInstr **PhysRegInfo; @@ -121,17 +111,6 @@ virtual bool runOnMachineFunction(MachineFunction &MF); - /// getMachineBasicBlockIndex - Turn a MachineBasicBlock into an index number - /// suitable for use with VarInfo's. - /// - unsigned getMachineBasicBlockIndex(MachineBasicBlock *MBB) const { - return BBMap.find(MBB)->second; - } - - /// getIndexMachineBasicBlock() - Given a block index, return the - /// MachineBasicBlock corresponding to it. - MachineBasicBlock *getIndexMachineBasicBlock(unsigned Idx); - /// killed_iterator - Iterate over registers killed by a machine instruction /// typedef std::multimap::iterator killed_iterator; @@ -253,8 +232,6 @@ VirtRegInfo.clear(); RegistersKilled.clear(); RegistersDead.clear(); - BBMap.clear(); - BBIdxMap.clear(); } /// getVarInfo - Return the VarInfo structure for the specified VIRTUAL From lattner at cs.uiuc.edu Thu Jul 1 01:30:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Jul 1 01:30:02 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/MachineFunction.cpp Message-ID: <200407010629.BAA32352@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: MachineFunction.cpp updated: 1.61 -> 1.62 --- Log message: Make sure that we destroy the MBB's, with all of their instructions, before any other data structures --- Diffs of the changes: (+1 -0) Index: llvm/lib/CodeGen/MachineFunction.cpp diff -u llvm/lib/CodeGen/MachineFunction.cpp:1.61 llvm/lib/CodeGen/MachineFunction.cpp:1.62 --- llvm/lib/CodeGen/MachineFunction.cpp:1.61 Thu Jul 1 01:02:07 2004 +++ llvm/lib/CodeGen/MachineFunction.cpp Thu Jul 1 01:29:07 2004 @@ -115,6 +115,7 @@ } MachineFunction::~MachineFunction() { + BasicBlocks.clear(); delete SSARegMapping; delete MFInfo; delete FrameInfo; From gaeke at cs.uiuc.edu Thu Jul 1 03:41:02 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Thu Jul 1 03:41:02 2004 Subject: [llvm-commits] CVS: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp Message-ID: <200407010839.DAA00368@kain.cs.uiuc.edu> Changes in directory reopt/lib/LightWtProfiling: UnpackTraceFunction.cpp updated: 1.89 -> 1.90 --- Log message: Support live-out values which are spilled in the MatrixFn. (This appears to fix Stanford/Towers.) Minor refactorings. --- Diffs of the changes: (+29 -10) Index: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp diff -u reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.89 reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.90 --- reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.89 Fri Jun 25 23:56:14 2004 +++ reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp Thu Jul 1 03:39:48 2004 @@ -338,12 +338,15 @@ const SparcV9RegInfo &TRI = *TM->getRegInfo (); std::vector mvec; static const unsigned sp = SparcV9::o6, fp = SparcV9::i6, g1 = SparcV9::g1, - g2 = SparcV9::g2; - - assert (Target.AllocState == AllocInfo::Allocated - && "Live-out values must be in regs in the matrixFn"); + g2 = SparcV9::g2, g3 = SparcV9::g3; + + assert ((Target.AllocState == AllocInfo::Allocated + || Target.AllocState == AllocInfo::Spilled) + && "Live-out values must be in regs or spilled in the matrixFn"); + mvec.clear (); - if (RegsToSave.find (Target.Placement) == RegsToSave.end ()) { + if (Target.AllocState == AllocInfo::Allocated + && RegsToSave.find (Target.Placement) == RegsToSave.end ()) { DEBUG (std::cerr << "addLiveOutCopy: Adding live-out's matrixFn " << RegStr (Target.Placement) << " to RegsToSave set\n"); RegsToSave.insert (Target.Placement); @@ -360,16 +363,32 @@ DEBUG (std::cerr << "addLiveOutCopy: " << liveOutValue->getName() << " is a constant in TraceFn\n"); // Copy the constant to the register. - copyConstantToRegister (MF, cast (liveOutTraceValue), g1, + copyConstantToRegister (MF, cast (liveOutTraceValue), R, g2, mvec); } else if (Source.AllocState == AllocInfo::Spilled) { // Copy live-out value from TraceFn's stack to the register. TRI.cpMem2RegMI (mvec, fp, Source.Placement, R, RegType, g2); } - // Copy the live-out value from the register to the place on the - // stack from which it will be restored to MatrixFn's register. - TRI.cpReg2MemMI (mvec, R, sp, stackOffsetForReg (Target.Placement), - RegType, g2); + + // Most live-outs are in registers in MatrixFn. They get saved on TraceFn's + // stack (so sp is the base reg for the store) and reloaded from their + // individual slots (computed by stackOffsetForReg). + unsigned BaseReg = sp; + int Offset = stackOffsetForReg(Target.Placement); + if (Target.AllocState == AllocInfo::Spilled) { + // Since this live-out is spilled in MatrixFn, we'll need to copy the + // live-out value from the register to the place where it lives on + // MatrixFn's stack, so MatrixFn's frame pointer will be the base + // register. But first we need to load it from the stack (FIXME: we + // should only do this once!) + TRI.cpMem2RegMI (mvec, sp, stackOffsetForReg (fp), g3, TRI.getRegType(g3), + g2); + DEBUG (std::cerr << "addLiveOutCopy: loading matrixFn's frame pointer; " + << "value is spilled at offset = " << Target.Placement << "\n"); + BaseReg = g3; + Offset = Target.Placement; + } + TRI.cpReg2MemMI (mvec, R, BaseReg, Offset, RegType, g2); for (std::vector::iterator vi = mvec.begin (), ve = mvec.end (); vi != ve; ++vi) MBB.push_back (*vi); From brukman at cs.uiuc.edu Thu Jul 1 08:53:01 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Thu Jul 1 08:53:01 2004 Subject: [llvm-commits] CVS: llvm/docs/CommandGuide/llvm-abcd.html Message-ID: <200407011352.IAA02479@zion.cs.uiuc.edu> Changes in directory llvm/docs/CommandGuide: llvm-abcd.html updated: 1.1 -> 1.2 --- Log message: Make links relative instead of absolute. --- Diffs of the changes: (+3 -4) Index: llvm/docs/CommandGuide/llvm-abcd.html diff -u llvm/docs/CommandGuide/llvm-abcd.html:1.1 llvm/docs/CommandGuide/llvm-abcd.html:1.2 --- llvm/docs/CommandGuide/llvm-abcd.html:1.1 Wed Jun 30 21:32:42 2004 +++ llvm/docs/CommandGuide/llvm-abcd.html Thu Jul 1 08:52:35 2004 @@ -34,10 +34,9 @@

      EXIT STATUS

      If llvm-abcd succeeds, it will exit with 0. Otherwise, if an error occurs, it will exit with a non-zero value, usually 1. -

      SEE ALSO

      llvm-dis -LLVM Bytecode File Format +

      SEE ALSO

      +llvm-dis +LLVM Bytecode File Format
      Maintained by Reid Spencer. From criswell at cs.uiuc.edu Thu Jul 1 09:07:01 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Thu Jul 1 09:07:01 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/MultiSource/Applications/Makefile Message-ID: <200407011406.JAA13483@seraph.cs.uiuc.edu> Changes in directory llvm/test/Programs/MultiSource/Applications: Makefile updated: 1.10 -> 1.11 --- Log message: Add treecc and hdb to the list run for all platforms. The tests run to completion on Sparc/Solaris 8. The treecc program seems to pass. The hdb program fails the JIT and llc tests. --- Diffs of the changes: (+2 -2) Index: llvm/test/Programs/MultiSource/Applications/Makefile diff -u llvm/test/Programs/MultiSource/Applications/Makefile:1.10 llvm/test/Programs/MultiSource/Applications/Makefile:1.11 --- llvm/test/Programs/MultiSource/Applications/Makefile:1.10 Tue Jun 1 15:36:39 2004 +++ llvm/test/Programs/MultiSource/Applications/Makefile Thu Jul 1 09:05:51 2004 @@ -4,9 +4,9 @@ include $(LEVEL)/Makefile.config -PARALLEL_DIRS = Burg aha sgefa siod lambda-0.1.3 d spiff +PARALLEL_DIRS = Burg aha sgefa siod lambda-0.1.3 d spiff hbd treecc ifeq ($(OS),Linux) -PARALLEL_DIRS += kimwitu++ treecc hbd obsequi +PARALLEL_DIRS += kimwitu++ obsequi endif include $(LEVEL)/test/Programs/Makefile.programs From brukman at cs.uiuc.edu Thu Jul 1 09:48:01 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Thu Jul 1 09:48:01 2004 Subject: [llvm-commits] CVS: llvm/docs/CommandGuide/llvmgxx.html Message-ID: <200407011447.JAA06730@zion.cs.uiuc.edu> Changes in directory llvm/docs/CommandGuide: llvmgxx.html updated: 1.4 -> 1.5 --- Log message: Fix link to llvmgcc. --- Diffs of the changes: (+1 -1) Index: llvm/docs/CommandGuide/llvmgxx.html diff -u llvm/docs/CommandGuide/llvmgxx.html:1.4 llvm/docs/CommandGuide/llvmgxx.html:1.5 --- llvm/docs/CommandGuide/llvmgxx.html:1.4 Sun Oct 19 13:23:05 2003 +++ llvm/docs/CommandGuide/llvmgxx.html Thu Jul 1 09:47:05 2004 @@ -96,7 +96,7 @@

      SEE ALSO

      -llvmg++, +llvmgcc, gccas, gccld From brukman at cs.uiuc.edu Thu Jul 1 09:52:02 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Thu Jul 1 09:52:02 2004 Subject: [llvm-commits] CVS: llvm/docs/CommandGuide/llvmgcc.pod llvmgxx.pod Message-ID: <200407011451.JAA09853@zion.cs.uiuc.edu> Changes in directory llvm/docs/CommandGuide: llvmgcc.pod added (r1.1) llvmgxx.pod added (r1.1) --- Log message: Add llvm-g++ and llvm-gcc pod documentation. --- Diffs of the changes: (+176 -0) Index: llvm/docs/CommandGuide/llvmgcc.pod diff -c /dev/null llvm/docs/CommandGuide/llvmgcc.pod:1.1 *** /dev/null Thu Jul 1 09:51:36 2004 --- llvm/docs/CommandGuide/llvmgcc.pod Thu Jul 1 09:51:26 2004 *************** *** 0 **** --- 1,88 ---- + + =pod + + =head1 NAME + + llvmgcc - LLVM C front-end + + =head1 SYNOPSIS + + llvmgcc [options] filename + + =head1 DESCRIPTION + + The B command is the LLVM C front end. It is a modified + version of gcc that takes C programs and compiles them into LLVM + bytecode or assembly language, depending upon the options. + + Unless the B<-S> option is specified, B will use the + L program to perform some optimizations and create an + LLVM bytecode file. Unless the B<-c> option is specified, B + will also use the L program to perform further + optimizations and link the resulting bytecode file(s) with support + libraries to create an executable program. + + Being derived from the GNU Compiler Collection, B has many + of gcc's features and accepts most of gcc's options. It handles a + number of gcc's extensions to the C programming language. + + =head1 OPTIONS + + =over + + =item B<--help> + + Print a summary of command line options. + + =item B<-S> + + Do not generate an LLVM bytecode file. Rather, compile the source + file into an LLVM assembly language file. + + =item B<-c> + + Do not generate a linked executable. Rather, compile the source + file into an LLVM bytecode file. This bytecode file can then be + linked with other bytecode files later on to generate a full LLVM + executable. + + =item B<-o> I + + Specify the output file to be I. + + =item B<-I> I + + Add a directory to the header file search path. This option can be + repeated. + + =item B<-L> I + + Add I to the library search path. This option can be + repeated. + + =item B<-l>I + + Link in the library libI.[bc | a | so]. This library should + be a bytecode library. + + =item B<-Wl,>I
      -
      - - -

      Basic Commands

      - - -
      -
      llvm-as -
      - Assemble a human-readable LLVM program into LLVM bytecode. -

      - -

      llvm-dis -
      - Disassemble an LLVM bytecode file into human-readable form. -

      - -

      analyze -
      - Analyze an LLVM bytecode file. -

      - -

      opt -
      - Optimize an LLVM bytecode file. -

      - -

      llc -
      - Compile an LLVM bytecode program into native machine code. -

      - -

      lli -
      - Run an LLVM bytecode program using either an interpreter or a - JIT compiler. -

      - -

      llvm-link -
      - Link several LLVM bytecode files together into one LLVM - bytecode file. -

      - -

      llvm-nm -
      - Print out the names and types of symbols in an LLVM bytecode file. -

      - -

      llvm-prof -
      - Transform raw 'llvmprof.out' data into a human readable report. -

      -

      - -
      - - -

      C and C++ Front-end Commands

      - - -
      -
      llvmgcc -
      - GCC-based C front end for LLVM. -

      - -

      llvmg++ -
      - GCC-based C++ front end for LLVM. -

      - -

      gccas -
      - LLVM assembler used by GCC and other native compiler tools. -

      - -

      gccld -
      - LLVM linker used by GCC and other native compiler tools. -
      - - -

      Debugging Tools

      - - -
      -
      bugpoint -
      - Trace an LLVM bytecode program and reduce its failure to a - simple testcase. -

      - -

      extract -
      - Extract a function from an LLVM bytecode file. -
      -
      - - -
      -Maintained by the -LLVM Team.
      -Last modified: $Date: 2003/11/30 05:46:14 $ -
      +

      This document is the reference manual for the LLVM utilities. It will +show you how to use the LLVM commands and what their options are. Note that in +the descriptions below, `bytecode' and `program' refer to LLVM bytecode files +and assembly programs, respectively.

      + + + +
    + + + + + +
    + +
      + +
    • llvm-as - + assemble a human-readable program into bytecode
    • + +
    • llvm-dis - + disassemble a bytecode file into human-readable form
    • + +
    • analyze - + analyze a bytecode file
    • + +
    • opt - + optimize a bytecode file
    • + +
    • llc - + compile a bytecode program into native machine code
    • + +
    • lli - + run a bytecode program using either an interpreter or a JIT compiler
    • + +
    • llvm-link + link several bytecode files into one
    • + +
    • llvm-nm + print out the names and types of symbols in a bytecode file
    • + +
    • llvm-prof - + transform raw `llvmprof.out' data into a human-readable report
    • + +
    + +
    + + + + + +
    + +
      + +
    • llvmgcc - + GCC-based C front end for LLVM + +
    • llvmg++ - + GCC-based C++ front end for LLVM
    • + +
    • gccas - + optimizing assembler used by llvm-g++ and llvm-gcc
    • + +
    • gccld - + optimizing linker used by llvm-g++ and llvm-gcc
    • + +
    + +
    + + + + + + +
    + +
      + +
    • bugpoint - + automatic test-case reducer
    • + +
    • extract - + extract a function from an LLVM bytecode file
    • + +
    + +
    + + + +
    +
    + Valid CSS! + Valid HTML 4.01! + + John Criswell
    + LLVM Compiler Infrastructure
    + Last modified: $Date: 2004/07/01 16:04:49 $ +
    From brukman at cs.uiuc.edu Thu Jul 1 12:00:02 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Thu Jul 1 12:00:02 2004 Subject: [llvm-commits] CVS: llvm/docs/CommandGuide/index.html Message-ID: <200407011659.LAA22945@zion.cs.uiuc.edu> Changes in directory llvm/docs/CommandGuide: index.html updated: 1.13 -> 1.14 --- Log message: Mention llvm-abcd, point out difference between it and `analyze'. --- Diffs of the changes: (+6 -2) Index: llvm/docs/CommandGuide/index.html diff -u llvm/docs/CommandGuide/index.html:1.13 llvm/docs/CommandGuide/index.html:1.14 --- llvm/docs/CommandGuide/index.html:1.13 Thu Jul 1 11:04:49 2004 +++ llvm/docs/CommandGuide/index.html Thu Jul 1 11:59:05 2004 @@ -43,7 +43,7 @@ disassemble a bytecode file into human-readable form
  • analyze - - analyze a bytecode file
  • + analyze a program compiled to bytecode
  • opt - optimize a bytecode file
  • @@ -110,6 +110,10 @@
  • extract - extract a function from an LLVM bytecode file
  • +
  • llvm-abcd - + bytecode analyzer (analyzes the binary encoding itself, not the program it + represents)
  • + @@ -125,7 +129,7 @@ John Criswell
    LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/07/01 16:04:49 $ + Last modified: $Date: 2004/07/01 16:59:05 $ From brukman at cs.uiuc.edu Thu Jul 1 12:22:02 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Thu Jul 1 12:22:02 2004 Subject: [llvm-commits] CVS: llvm/docs/index.html Message-ID: <200407011721.MAA26325@zion.cs.uiuc.edu> Changes in directory llvm/docs: index.html updated: 1.18 -> 1.19 --- Log message: Fix grammar in Stacker doc description. --- Diffs of the changes: (+4 -4) Index: llvm/docs/index.html diff -u llvm/docs/index.html:1.18 llvm/docs/index.html:1.19 --- llvm/docs/index.html:1.18 Mon Jun 28 12:11:10 2004 +++ llvm/docs/index.html Thu Jul 1 12:20:53 2004 @@ -111,9 +111,9 @@
  • Source Level Debugging with LLVM
  • TableGen Fundamentals
  • -
  • The Stacker Cronicles - This document describes -both the Stacker language and LLVM frontend, but also some details about LLVM -useful for those writing front-ends.
  • +
  • The Stacker Cronicles - describes both the +Stacker language and LLVM frontend, as well as some details about LLVM useful +for those writing front-ends.
  • Command Line Library
  • Extending LLVM
  • Coding Standards
  • @@ -181,7 +181,7 @@ John Criswell
    LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/06/28 17:11:10 $ + Last modified: $Date: 2004/07/01 17:20:53 $ From lattner at cs.uiuc.edu Thu Jul 1 12:34:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Jul 1 12:34:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/TargetData.cpp Message-ID: <200407011733.MAA01616@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target: TargetData.cpp updated: 1.46 -> 1.47 --- Log message: Handle targets where alignment can be bigger than the size of the data. Contributed by Vladimir Prus! --- Diffs of the changes: (+4 -4) Index: llvm/lib/Target/TargetData.cpp diff -u llvm/lib/Target/TargetData.cpp:1.46 llvm/lib/Target/TargetData.cpp:1.47 --- llvm/lib/Target/TargetData.cpp:1.46 Thu Jun 17 13:19:28 2004 +++ llvm/lib/Target/TargetData.cpp Thu Jul 1 12:32:59 2004 @@ -168,19 +168,19 @@ Size = TD->getPointerSize(); Alignment = TD->getPointerAlignment(); return; case Type::ArrayTyID: { - const ArrayType *ATy = (const ArrayType *)Ty; + const ArrayType *ATy = cast(Ty); + unsigned AlignedSize = (Size + Alignment - 1)/Alignment*Alignment; getTypeInfo(ATy->getElementType(), TD, Size, Alignment); - Size *= ATy->getNumElements(); + Size = AlignedSize*ATy->getNumElements(); return; } case Type::StructTyID: { // Get the layout annotation... which is lazily created on demand. - const StructLayout *Layout = TD->getStructLayout((const StructType*)Ty); + const StructLayout *Layout = TD->getStructLayout(cast(Ty)); Size = Layout->StructSize; Alignment = Layout->StructAlignment; return; } - case Type::TypeTyID: default: assert(0 && "Bad type for getTypeInfo!!!"); return; From brukman at cs.uiuc.edu Thu Jul 1 12:54:01 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Thu Jul 1 12:54:01 2004 Subject: [llvm-commits] CVS: llvm/docs/CommandGuide/gccld.pod Message-ID: <200407011753.MAA32737@zion.cs.uiuc.edu> Changes in directory llvm/docs/CommandGuide: gccld.pod added (r1.1) --- Log message: gccld enters the Hall of POD. --- Diffs of the changes: (+177 -0) Index: llvm/docs/CommandGuide/gccld.pod diff -c /dev/null llvm/docs/CommandGuide/gccld.pod:1.1 *** /dev/null Thu Jul 1 12:53:37 2004 --- llvm/docs/CommandGuide/gccld.pod Thu Jul 1 12:53:27 2004 *************** *** 0 **** --- 1,177 ---- + + =pod + + =head1 NAME + + gccld - optimizing LLVM linker + + =head1 SYNOPSIS + + gccld [options] file1 [file2 ...] + + =head1 DESCRIPTION + + The B utility takes a set of LLVM bytecode files and links them + together into a single LLVM bytecode file. The output bytecode file can be + another bytecode library or an executable bytecode program. Using additional + options, B is able to produce native code executables. + + The B utility is primarily used by the L and + L front-ends, and as such, attempts to mimic the interface + provided by the default system linker so that it can act as a ``drop-in'' + replacement. + + The B tool performs a small set of interprocedural, post-link + optimizations on the program. + + =head2 Search Order + + When looking for objects specified on the command line, B will search for + the object first in the current directory and then in the directory specified by + the B environment variable. If it cannot find the object, + it fails. + + When looking for a library specified with the B<-l> option, B first + attempts to load a file with that name from the current directory. If that + fails, it looks for libI.bc, libI.a, or libI.I, in that order, in each directory added to the library search + path with the B<-L> option. These directories are searched in the order they + were specified. If the library cannot be located, then B looks in the + directory specified by the B environment variable. If it + does not find a library there, it fails. + + The shared library extension may be I<.so>, I<.dyld>, I<.dll>, or something + different, depending upon the system. + + The B<-L> option is global. It does not matter where it is specified in the + list of command line arguments; the directory is simply added to the search path + and is applied to all libraries, preceding or succeeding, in the command line. + + =head2 Link order + + All object files are linked first in the order they were specified on the + command line. All library files are linked next. Some libraries may not be + linked into the object program; see below. + + =head2 Library Linkage + + Object files and static bytecode objects are always linked into the output + file. Library archives (.a files) load only the objects within the archive + that define symbols needed by the output file. Hence, libraries should be + listed after the object files and libraries which need them; otherwise, the + library may not be linked in, and the dependent library will not have its + undefined symbols defined. + + =head2 Native code generation + + The B program has limited support for native code generation, when + using the B<-native> or B<-native-cbe> options. + + =head1 OPTIONS + + =over + + =item B<-help> + + Print a summary of command line options. + + =item B<-o> I + + Specify the output filename which will hold the linked bytecode. + + =item B<-stats> + + Print statistics. + + =item B<-time-passes> + + Record the amount of time needed for each pass and print it to standard + error. + + =item B<-verify> + + Verify each pass result. + + =item B<-disable-opt> + + Disable all link-time optimization passes. + + =item B<-disable-inlining> + + Do not run the inliner pass. + + =item B<-L>I + + Add directory to the list of directories to search when looking for + libraries. + + =item B<-disable-internalize> + + Do not mark all symbols as internal. + + =item B<-internalize-public-api-file> I + + Preserve the list of symbol names in the file filename. + + =item B<-internalize-public-api-list <list>> + + Preserve the symbol names in list. + + =item B<-l>I + + Specify libraries to include when linking the output file. When linking, + B will first attempt to load a file with the pathname B. If + that fails, it will then attempt to load libI.bc, libI.a, and + libI.I, in that order. + + =item B<-link-as-library> + + Link the .bc files together as a library, not an executable. + + =item B<-native> + + Generate a native machine code executable. + + When generating native executables, B first checks for a bytecode + version of the library and links it in, if necessary. If the library is + missing, B skips it. Then, B links in the same + libraries as native code. + + In this way, B should be able to link in optimized bytecode + subsets of common libraries and then link in any part of the library that + hasn't been converted to bytecode. + + =item B<-native-cbe> + + Generate a native machine code executable with the LLVM C backend. + + This option is identical to the B<-native> option, but uses the + C backend to generate code for the program instead of an LLVM native + code generator. + + =item B<-s> + + Strip symbol information from the generated executable. + + =item B<-v> + + Print information about actions taken. + + =back + + =head1 EXIT STATUS + + If B succeeds, it will exit with an exit status of 0. + Otherwise, if an error occurs, it will exit with a non-zero exit + status. + + =head1 SEE ALSO + + L, L + + =head1 AUTHORS + + Maintained by the LLVM Team (L). + + =cut + From brukman at cs.uiuc.edu Thu Jul 1 12:54:06 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Thu Jul 1 12:54:06 2004 Subject: [llvm-commits] CVS: llvm/docs/CommandGuide/llvmgcc.pod Message-ID: <200407011753.MAA29637@zion.cs.uiuc.edu> Changes in directory llvm/docs/CommandGuide: llvmgcc.pod updated: 1.1 -> 1.2 --- Log message: Make the text of the link to llvmgxx.html more appropriate: `llvmg++'. --- Diffs of the changes: (+1 -1) Index: llvm/docs/CommandGuide/llvmgcc.pod diff -u llvm/docs/CommandGuide/llvmgcc.pod:1.1 llvm/docs/CommandGuide/llvmgcc.pod:1.2 --- llvm/docs/CommandGuide/llvmgcc.pod:1.1 Thu Jul 1 09:51:26 2004 +++ llvm/docs/CommandGuide/llvmgcc.pod Thu Jul 1 12:52:58 2004 @@ -78,7 +78,7 @@ =head1 SEE ALSO -L, L, L +L, L, L =head1 AUTHORS From brukman at cs.uiuc.edu Thu Jul 1 13:01:01 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Thu Jul 1 13:01:01 2004 Subject: [llvm-commits] CVS: llvm/docs/CommandGuide/llvm-db.pod Message-ID: <200407011800.NAA06747@zion.cs.uiuc.edu> Changes in directory llvm/docs/CommandGuide: llvm-db.pod added (r1.1) --- Log message: llvm-db is in alpha stage, this document is a placeholder. --- Diffs of the changes: (+18 -0) Index: llvm/docs/CommandGuide/llvm-db.pod diff -c /dev/null llvm/docs/CommandGuide/llvm-db.pod:1.1 *** /dev/null Thu Jul 1 13:00:52 2004 --- llvm/docs/CommandGuide/llvm-db.pod Thu Jul 1 13:00:42 2004 *************** *** 0 **** --- 1,18 ---- + + =pod + + =head1 NAME + + llvm-db - LLVM debugger (alpha) + + =head1 SYNOPSIS + + Details coming soon. Please see our + L in the meantime. + + =head1 AUTHORS + + Maintained by the LLVM Team (L). + + =cut + From brukman at cs.uiuc.edu Thu Jul 1 13:01:09 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Thu Jul 1 13:01:09 2004 Subject: [llvm-commits] CVS: llvm/docs/CommandGuide/gccas.pod Message-ID: <200407011800.NAA03548@zion.cs.uiuc.edu> Changes in directory llvm/docs/CommandGuide: gccas.pod updated: 1.2 -> 1.3 --- Log message: Fix links to llvmgcc and llvmgxx --- Diffs of the changes: (+1 -1) Index: llvm/docs/CommandGuide/gccas.pod diff -u llvm/docs/CommandGuide/gccas.pod:1.2 llvm/docs/CommandGuide/gccas.pod:1.3 --- llvm/docs/CommandGuide/gccas.pod:1.2 Wed Jun 2 14:30:23 2004 +++ llvm/docs/CommandGuide/gccas.pod Thu Jul 1 12:59:53 2004 @@ -12,7 +12,7 @@ =head1 DESCRIPTION The B utility takes an LLVM assembly file generated by the -L or L front-ends and converts +L or L front-ends and converts it into an LLVM bytecode file. It is primarily used by the GCC front end, and as such, attempts to mimic the interface provided by the default system assembler so that it can act as a "drop-in" From lattner at cs.uiuc.edu Thu Jul 1 13:27:03 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Jul 1 13:27:03 2004 Subject: [llvm-commits] CVS: llvm/docs/CommandGuide/index.html Message-ID: <200407011826.NAA02416@apoc.cs.uiuc.edu> Changes in directory llvm/docs/CommandGuide: index.html updated: 1.14 -> 1.15 --- Log message: This is more of an "llvm team" thing by now --- Diffs of the changes: (+1 -2) Index: llvm/docs/CommandGuide/index.html diff -u llvm/docs/CommandGuide/index.html:1.14 llvm/docs/CommandGuide/index.html:1.15 --- llvm/docs/CommandGuide/index.html:1.14 Thu Jul 1 11:59:05 2004 +++ llvm/docs/CommandGuide/index.html Thu Jul 1 13:25:59 2004 @@ -127,9 +127,8 @@ Valid HTML 4.01! - John Criswell
    LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/07/01 16:59:05 $ + Last modified: $Date: 2004/07/01 18:25:59 $ From lattner at cs.uiuc.edu Thu Jul 1 13:28:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Jul 1 13:28:01 2004 Subject: [llvm-commits] CVS: llvm-www/header.incl Message-ID: <200407011826.NAA03109@apoc.cs.uiuc.edu> Changes in directory llvm-www: header.incl updated: 1.20 -> 1.21 --- Log message: Add direct link to command guide --- Diffs of the changes: (+1 -0) Index: llvm-www/header.incl diff -u llvm-www/header.incl:1.20 llvm-www/header.incl:1.21 --- llvm-www/header.incl:1.20 Sat Jun 26 13:58:20 2004 +++ llvm-www/header.incl Thu Jul 1 13:26:49 2004 @@ -20,6 +20,7 @@ Overview
    Features
    Documentation
    +Command Guide
    Support
    FAQ
    Publications
    From brukman at cs.uiuc.edu Thu Jul 1 13:35:04 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Thu Jul 1 13:35:04 2004 Subject: [llvm-commits] CVS: llvm-www/header.incl Message-ID: <200407011834.NAA10129@zion.cs.uiuc.edu> Changes in directory llvm-www: header.incl updated: 1.21 -> 1.22 --- Log message: Remove the colon, it's cramping the grammar style on the website. --- Diffs of the changes: (+1 -1) Index: llvm-www/header.incl diff -u llvm-www/header.incl:1.21 llvm-www/header.incl:1.22 --- llvm-www/header.incl:1.21 Thu Jul 1 13:26:49 2004 +++ llvm-www/header.incl Thu Jul 1 13:33:54 2004 @@ -37,7 +37,7 @@ LLVM 1.2

    -Try the:
    +Try the
    online demo

    From brukman at cs.uiuc.edu Thu Jul 1 13:36:03 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Thu Jul 1 13:36:03 2004 Subject: [llvm-commits] CVS: llvm/docs/CommandGuide/llvm-db.pod Message-ID: <200407011834.NAA13228@zion.cs.uiuc.edu> Changes in directory llvm/docs/CommandGuide: llvm-db.pod updated: 1.1 -> 1.2 --- Log message: Fix grammar: remove `our' as it no longer makes sense. --- Diffs of the changes: (+1 -1) Index: llvm/docs/CommandGuide/llvm-db.pod diff -u llvm/docs/CommandGuide/llvm-db.pod:1.1 llvm/docs/CommandGuide/llvm-db.pod:1.2 --- llvm/docs/CommandGuide/llvm-db.pod:1.1 Thu Jul 1 13:00:42 2004 +++ llvm/docs/CommandGuide/llvm-db.pod Thu Jul 1 13:34:46 2004 @@ -7,7 +7,7 @@ =head1 SYNOPSIS -Details coming soon. Please see our +Details coming soon. Please see L in the meantime. =head1 AUTHORS From gaeke at cs.uiuc.edu Thu Jul 1 14:27:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Thu Jul 1 14:27:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/LevelRaise.cpp Message-ID: <200407011926.OAA13524@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms: LevelRaise.cpp updated: 1.96 -> 1.97 --- Log message: Make this pass use a more specific debug message than "Processing:". --- Diffs of the changes: (+1 -1) Index: llvm/lib/Transforms/LevelRaise.cpp diff -u llvm/lib/Transforms/LevelRaise.cpp:1.96 llvm/lib/Transforms/LevelRaise.cpp:1.97 --- llvm/lib/Transforms/LevelRaise.cpp:1.96 Sun Apr 4 20:28:59 2004 +++ llvm/lib/Transforms/LevelRaise.cpp Thu Jul 1 14:26:38 2004 @@ -562,7 +562,7 @@ bool Changed = false; for (Function::iterator BB = F.begin(), BBE = F.end(); BB != BBE; ++BB) for (BasicBlock::iterator BI = BB->begin(); BI != BB->end();) { - DEBUG(std::cerr << "Processing: " << *BI); + DEBUG(std::cerr << "LevelRaising: " << *BI); if (dceInstruction(BI) || doConstantPropagation(BI)) { Changed = true; ++NumDCEorCP; From gaeke at cs.uiuc.edu Thu Jul 1 14:28:02 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Thu Jul 1 14:28:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/Reassociate.cpp Message-ID: <200407011927.OAA13565@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: Reassociate.cpp updated: 1.30 -> 1.31 --- Log message: Make this pass use a more specific debug message than "Processing:". --- Diffs of the changes: (+1 -1) Index: llvm/lib/Transforms/Scalar/Reassociate.cpp diff -u llvm/lib/Transforms/Scalar/Reassociate.cpp:1.30 llvm/lib/Transforms/Scalar/Reassociate.cpp:1.31 --- llvm/lib/Transforms/Scalar/Reassociate.cpp:1.30 Fri Jan 9 00:02:20 2004 +++ llvm/lib/Transforms/Scalar/Reassociate.cpp Thu Jul 1 14:27:10 2004 @@ -211,7 +211,7 @@ bool Changed = false; for (BasicBlock::iterator BI = BB->begin(); BI != BB->end(); ++BI) { - DEBUG(std::cerr << "Processing: " << *BI); + DEBUG(std::cerr << "Reassociating: " << *BI); if (BI->getOpcode() == Instruction::Sub && !BinaryOperator::isNeg(BI)) { // Convert a subtract into an add and a neg instruction... so that sub // instructions can be commuted with other add instructions... From gaeke at cs.uiuc.edu Thu Jul 1 14:41:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Thu Jul 1 14:41:01 2004 Subject: [llvm-commits] CVS: llvm/docs/CommandGuide/llvm-nm.pod Message-ID: <200407011940.OAA13795@zion.cs.uiuc.edu> Changes in directory llvm/docs/CommandGuide: llvm-nm.pod added (r1.1) --- Log message: llvm-nm pod format man page. --- Diffs of the changes: (+123 -0) Index: llvm/docs/CommandGuide/llvm-nm.pod diff -c /dev/null llvm/docs/CommandGuide/llvm-nm.pod:1.1 *** /dev/null Thu Jul 1 14:40:47 2004 --- llvm/docs/CommandGuide/llvm-nm.pod Thu Jul 1 14:40:36 2004 *************** *** 0 **** --- 1,123 ---- + =pod + + =head1 NAME + + llvm-nm - list LLVM bytecode file's symbol table + + =head1 SYNOPSIS + + llvm-nm [options] [filenames...] + + =head1 DESCRIPTION + + The B utility lists the names of symbols from the LLVM bytecode files, + or B archives containing LLVM bytecode files, named on the command line. + Each symbol is listed along with some simple information about its provenance. + If no filename is specified, or I<-> is used as a filename, B will + process a bytecode file on its standard input stream. + + B's default output format is the traditional BSD B output format. + Each such output record consists of an (optional) 8-digit hexadecimal address, + followed by a type code character, followed by a name, for each symbol. One + record is printed per line; fields are separated by spaces. When the address is + omitted, it is replaced by 8 spaces. + + Type code characters currently supported, and their meanings, are as follows: + + =over + + =item U + + Named object is referenced but undefined in this bytecode file + + =item C + + Common (multiple defs link together into one def) + + =item W + + Weak reference (multiple defs link together into zero or one defs) + + =item t + + Local function (text) object + + =item T + + Global function (text) object + + =item d + + Local data object + + =item D + + Global data object + + =item ? + + Something unrecognizable + + =back + + Because LLVM bytecode files typically contain objects that are not considered to + have addresses until they are linked into an executable image or dynamically + compiled "just-in-time", B does not print an address for any symbol, + even symbols which are defined in the bytecode file. + + =head1 OPTIONS + + =over + + =item B<-P> + + Use POSIX.2 output format. Alias for B<--format=posix>. + + =item B<-B> (default) + + Use BSD output format. Alias for B<--format=bsd>. + + =item B<--help> + + Print a summary of command-line options and their meanings. + + =item B<--defined-only> + + Print only symbols defined in this bytecode file (as opposed to + symbols which may be referenced by objects in this file, but not + defined in this file.) + + =item B<--extern-only>, B<-g> + + Print only symbols whose definitions are external; that is, accessible + from other bytecode files. + + =item B<--undefined-only>, B<-u> + + Print only symbols referenced but not defined in this bytecode file. + + =item B<--format=>I, B<-f> + + Select an output format; I may be I, I, or I. The + default is I. + + =back + + =head1 BUGS + + B cannot demangle C++ mangled names, like GNU B can. + + =head1 EXIT STATUS + + B exits with an exit code of zero. + + =head1 SEE ALSO + + L, L, L + + =head1 AUTHOR + + Maintained by the LLVM Team (L). + + =cut + From gaeke at cs.uiuc.edu Thu Jul 1 15:08:03 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Thu Jul 1 15:08:03 2004 Subject: [llvm-commits] CVS: llvm/docs/CommandGuide/llvm-abcd.pod Message-ID: <200407012007.PAA14158@zion.cs.uiuc.edu> Changes in directory llvm/docs/CommandGuide: llvm-abcd.pod added (r1.1) --- Log message: abcd pod document --- Diffs of the changes: (+63 -0) Index: llvm/docs/CommandGuide/llvm-abcd.pod diff -c /dev/null llvm/docs/CommandGuide/llvm-abcd.pod:1.1 *** /dev/null Thu Jul 1 15:07:25 2004 --- llvm/docs/CommandGuide/llvm-abcd.pod Thu Jul 1 15:07:15 2004 *************** *** 0 **** --- 1,63 ---- + =pod + + =head1 NAME + + llvm-abcd - bytecode file low-level dumper + + =head1 SYNOPSIS + + llvm-abcd [options] [filename] + + =head1 DESCRIPTION + + The B command is a small utility for analyzing bytecode files. The + B acronym stands for Bnalysis of ByteBode Bisplayer. The tool + reads a bytecode file (such as generated with the B tool) and produces + statistical and low level bytecode format dumps. This tool is probably not of + much interest or utility except for those working directly with the bytecode + format. Most LLVM users can just ignore this tool. + + If filename is omitted or is I<->, then B reads its input from + standard input. This is useful for combining B in a pipeline. + + =head1 OPTIONS + + =over + + =item B<--nodetails> + + Causes B to abbreviate its output by writing out only a module level + summary. The details for individual functions are not displayed. + + =item B<--dump> + + Causes B to dump the bytecode in a human readable format. This format + is significantly different from LLVM assembly and provides details about the + encoding of the bytecode file. + + =item B<--verify> + + Causes B to verify the module produced by by reading the bytecode. + This ensures that the statistics generated are reliable. + + =item B<--help> + + Print a summary of command line options. + + =back + + =head1 EXIT STATUS + + If B succeeds, it will exit with zero exit status. Otherwise, if an + error occurs, it will exit with a non-zero exit status, usually 1. + + =head1 SEE ALSO + + L, L + + =head1 AUTHOR + + Maintained by L. + + =cut + From gaeke at cs.uiuc.edu Thu Jul 1 15:12:05 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Thu Jul 1 15:12:05 2004 Subject: [llvm-commits] CVS: llvm/docs/Bugpoint.html Message-ID: <200407012010.PAA14313@zion.cs.uiuc.edu> Changes in directory llvm/docs: Bugpoint.html added (r1.1) --- Log message: bugpoint command guide has been designated a full-fledged "doc". --- Diffs of the changes: (+249 -0) Index: llvm/docs/Bugpoint.html diff -c /dev/null llvm/docs/Bugpoint.html:1.1 *** /dev/null Thu Jul 1 15:10:50 2004 --- llvm/docs/Bugpoint.html Thu Jul 1 15:10:40 2004 *************** *** 0 **** --- 1,249 ---- + + LLVM: bugpoint tool + + + +

    LLVM: bugpoint tool

    +
    + +

    NAME

    + bugpoint + +

    SYNOPSIS

    + bugpoint [options] [input LLVM ll/bc files] [LLVM passes] --args <program arguments>... + + +

    DESCRIPTION

    + + The bugpoint tool narrows down the source of + problems in LLVM tools and passes. It can be used to debug three types of + failures: optimizer crashes, miscompilations by optimizers, or bad native + code generation (including problems in the static and JIT compilers). It aims + to reduce large test cases to small, useful ones. For example, + if
    gccas crashes while optimizing a file, it + will identify the optimization (or combination of optimizations) that causes the + crash, and reduce the file down to a small example which triggers the crash.

    + + +

    Design Philosophy

    + + bugpoint is designed to be a useful tool without requiring any + hooks into the LLVM infrastructure at all. It works with any and all LLVM + passes and code generators, and does not need to "know" how they work. Because + of this, it may appear to do stupid things or miss obvious + simplifications. bugpoint is also designed to trade off programmer + time for computer time in the compiler-debugging process; consequently, it may + take a long period of (unattended) time to reduce a test case, but we feel it + is still worth it. Note that bugpoint is generally very quick unless + debugging a miscompilation where each test of the program (which requires + executing it) takes a long time.

    + + +

    Automatic Debugger Selection

    + + bugpoint reads each .bc or .ll file + specified on the command line and links them together into a single module, + called the test program. If any LLVM passes are + specified on the command line, it runs these passes on the test program. If + any of the passes crash, or if they produce malformed output (which causes the + verifier to abort), + bugpoint starts the crash debugger.

    + + Otherwise, if the -output option was not + specified, bugpoint runs the test program with the C backend (which is + assumed to generate good code) to generate a reference output. Once + bugpoint has a reference output for the test program, it tries + executing it with the selected code generator. If the + selected code generator crashes, bugpoint starts the crash debugger on the code generator. Otherwise, if the + resulting output differs from the reference output, it assumes the difference + resulted from a code generator failure, and starts the code generator debugger.

    + + Finally, if the output of the selected code generator matches the reference + output, bugpoint runs the test program after all of the LLVM passes + have been applied to it. If its output differs from the reference output, it + assumes the difference resulted from a failure in one of the LLVM passes, and + enters the miscompilation + debugger. Otherwise, there is no problem bugpoint can debug.

    + + +

    Crash debugger

    + + If an optimizer or code generator crashes, bugpoint will try as hard as + it can to reduce the list of passes (for optimizer crashes) and the size of the + test program. First, bugpoint figures out which combination of + optimizer passes triggers the bug. This is useful when debugging a problem + exposed by gccas, for example, because it runs over 38 passes.

    + + Next, bugpoint tries removing functions from the test program, to + reduce its size. Usually it is able to reduce a test program to a single + function, when debugging intraprocedural optimizations. Once the number of + functions has been reduced, it attempts to delete various edges in the control + flow graph, to reduce the size of the function as much as possible. Finally, + bugpoint deletes any individual LLVM instructions whose absence does + not eliminate the failure. At the end, bugpoint should tell you what + passes crash, give you a bytecode file, and give you instructions on how to + reproduce the failure with opt, analyze, or llc.

    + + +

    Code generator debugger

    + +

    The code generator debugger attempts to narrow down the amount of code that + is being miscompiled by the selected code generator. To + do this, it takes the test program and partitions it into two pieces: one piece + which it compiles with the C backend (into a shared object), and one piece which + it runs with either the JIT or the static LLC compiler. It uses several + techniques to reduce the amount of code pushed through the LLVM code generator, + to reduce the potential scope of the problem. After it is finished, it emits + two bytecode files (called "test" [to be compiled with the code generator] and + "safe" [to be compiled with the C backend], respectively), and instructions for + reproducing the problem. The code generator debugger assumes that the C backend + produces good code.

    + + +

    Miscompilation debugger

    + + The miscompilation debugger works similarly to the code generator + debugger. It works by splitting the test program into two pieces, running the + optimizations specified on one piece, linking the two pieces back together, + and then executing the result. + It attempts to narrow down the list of passes to the one (or few) which are + causing the miscompilation, then reduce the portion of the test program which is + being miscompiled. The miscompilation debugger assumes that the selected + code generator is working properly.

    + + +

    Advice for using bugpoint

    + + bugpoint can be a remarkably useful tool, but it sometimes works in + non-obvious ways. Here are some hints and tips:

    + +

      +
    1. In the code generator and miscompilation debuggers, bugpoint only + works with programs that have deterministic output. Thus, if the program + outputs argv[0], the date, time, or any other "random" data, bugpoint may + misinterpret differences in these data, when output, as the result of a + miscompilation. Programs should be temporarily modified to disable + outputs that are likely to vary from run to run. + +
    2. In the code generator and miscompilation debuggers, debugging will go + faster if you manually modify the program or its inputs to reduce the + runtime, but still exhibit the problem. + +
    3. bugpoint is extremely useful when working on a new optimization: + it helps track down regressions quickly. To avoid having to relink + bugpoint every time you change your optimization however, have + bugpoint dynamically load your optimization with the -load option. + +
    4. bugpoint can generate a lot of output and run for a long period of + time. It is often useful to capture the output of the program to file. For + example, in the C shell, you can type:
      + bugpoint ..... |& tee bugpoint.log +
      to get a copy of bugpoint's output in the file + bugpoint.log, as well as on your terminal. + +
    5. bugpoint cannot debug problems with the LLVM linker. If + bugpoint crashes before you see its "All input ok" message, + you might try llvm-link -v on the same set of input files. If + that also crashes, you may be experiencing a linker bug. + +
    6. If your program is supposed to crash, bugpoint will be + confused. One way to deal with this is to cause bugpoint to ignore the exit + code from your program, by giving it the -check-exit-code=false + option. + +
    + +

    OPTIONS

    + + + +

    EXIT STATUS

    + + If bugpoint succeeds in finding a problem, it will exit with 0. + Otherwise, if an error occurs, it will exit with a non-zero value. + +

    SEE ALSO

    +
    opt, + analyze + +
    + Maintained by the LLVM Team. + + From lattner at cs.uiuc.edu Thu Jul 1 15:25:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Jul 1 15:25:02 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/iMemory.h Message-ID: <200407012024.PAA04312@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: iMemory.h updated: 1.46 -> 1.47 --- Log message: Move init methods out of line to enable better assertions, contributed by Vladimir Merzliakov! --- Diffs of the changes: (+4 -14) Index: llvm/include/llvm/iMemory.h diff -u llvm/include/llvm/iMemory.h:1.46 llvm/include/llvm/iMemory.h:1.47 --- llvm/include/llvm/iMemory.h:1.46 Wed May 26 19:15:23 2004 +++ llvm/include/llvm/iMemory.h Thu Jul 1 15:22:31 2004 @@ -175,14 +175,10 @@ class LoadInst : public Instruction { LoadInst(const LoadInst &LI) : Instruction(LI.getType(), Load) { Volatile = LI.isVolatile(); - Operands.reserve(1); - Operands.push_back(Use(LI.Operands[0], this)); + init(LI.Operands[0]); } bool Volatile; // True if this is a volatile load - void init(Value *Ptr) { - Operands.reserve(1); - Operands.push_back(Use(Ptr, this)); - } + void init(Value *Ptr); public: LoadInst(Value *Ptr, const std::string &Name, Instruction *InsertBefore); LoadInst(Value *Ptr, const std::string &Name, BasicBlock *InsertAtEnd); @@ -228,16 +224,10 @@ class StoreInst : public Instruction { StoreInst(const StoreInst &SI) : Instruction(SI.getType(), Store) { Volatile = SI.isVolatile(); - Operands.reserve(2); - Operands.push_back(Use(SI.Operands[0], this)); - Operands.push_back(Use(SI.Operands[1], this)); + init(SI.Operands[0], SI.Operands[1]); } bool Volatile; // True if this is a volatile store - void init(Value *Val, Value *Ptr) { - Operands.reserve(2); - Operands.push_back(Use(Val, this)); - Operands.push_back(Use(Ptr, this)); - } + void init(Value *Val, Value *Ptr); public: StoreInst(Value *Val, Value *Ptr, Instruction *InsertBefore); StoreInst(Value *Val, Value *Ptr, BasicBlock *InsertAtEnd); From lattner at cs.uiuc.edu Thu Jul 1 15:25:11 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Jul 1 15:25:11 2004 Subject: [llvm-commits] CVS: llvm/lib/VMCore/iMemory.cpp Message-ID: <200407012024.PAA04307@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: iMemory.cpp updated: 1.40 -> 1.41 --- Log message: Add much better assertion checking for load and store insts. Contributed by Vladimir Merzliakov! --- Diffs of the changes: (+17 -0) Index: llvm/lib/VMCore/iMemory.cpp diff -u llvm/lib/VMCore/iMemory.cpp:1.40 llvm/lib/VMCore/iMemory.cpp:1.41 --- llvm/lib/VMCore/iMemory.cpp:1.40 Wed May 26 19:15:23 2004 +++ llvm/lib/VMCore/iMemory.cpp Thu Jul 1 15:23:52 2004 @@ -86,6 +86,13 @@ // LoadInst Implementation //===----------------------------------------------------------------------===// +void LoadInst::init(Value *Ptr) { + assert(Ptr && isa(Ptr->getType()) && + "Ptr must have pointer type."); + Operands.reserve(1); + Operands.push_back(Use(Ptr, this)); +} + LoadInst::LoadInst(Value *Ptr, const std::string &Name, Instruction *InsertBef) : Instruction(cast(Ptr->getType())->getElementType(), Load, Name, InsertBef), Volatile(false) { @@ -112,6 +119,7 @@ init(Ptr); } + //===----------------------------------------------------------------------===// // StoreInst Implementation //===----------------------------------------------------------------------===// @@ -138,6 +146,15 @@ init(Val, Ptr); } +void StoreInst::init(Value *Val, Value *Ptr) { + assert(isa(Ptr->getType()) && + Val->getType() == cast(Ptr->getType())->getElementType() + && "Ptr must have pointer type."); + + Operands.reserve(2); + Operands.push_back(Use(Val, this)); + Operands.push_back(Use(Ptr, this)); +} //===----------------------------------------------------------------------===// // GetElementPtrInst Implementation From gaeke at cs.uiuc.edu Thu Jul 1 15:30:02 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Thu Jul 1 15:30:02 2004 Subject: [llvm-commits] CVS: llvm/docs/CommandGuide/bugpoint.pod Message-ID: <200407012029.PAA14560@zion.cs.uiuc.edu> Changes in directory llvm/docs/CommandGuide: bugpoint.pod added (r1.1) --- Log message: bug. point. pod. --- Diffs of the changes: (+250 -0) Index: llvm/docs/CommandGuide/bugpoint.pod diff -c /dev/null llvm/docs/CommandGuide/bugpoint.pod:1.1 *** /dev/null Thu Jul 1 15:29:18 2004 --- llvm/docs/CommandGuide/bugpoint.pod Thu Jul 1 15:29:08 2004 *************** *** 0 **** --- 1,250 ---- + =pod + + =head1 NAME + + bugpoint - automatic test case reduction tool + + =head1 SYNOPSIS + + bugpoint [options] [input LLVM ll/bc files] [LLVM passes] --args + I ... + + =head1 DESCRIPTION + + The B tool narrows down the source of problems in LLVM tools and passes. + It can be used to debug three types of failures: optimizer crashes, + miscompilations by optimizers, or bad native code generation (including problems + in the static and JIT compilers). It aims to reduce large test cases to small, + useful ones. For example, if B crashes while optimizing a file, it will + identify the optimization (or combination of optimizations) that causes the + crash, and reduce the file down to a small example which triggers the crash. + + =head2 Design Philosophy + + B is designed to be a useful tool without requiring any hooks into the + LLVM infrastructure at all. It works with any and all LLVM passes and code + generators, and does not need to "know" how they work. Because of this, it may + appear to do stupid things or miss obvious simplifications. B is also + designed to trade off programmer time for computer time in the + compiler-debugging process; consequently, it may take a long period of + (unattended) time to reduce a test case, but we feel it is still worth it. Note + that B is generally very quick unless debugging a miscompilation where + each test of the program (which requires executing it) takes a long time. + + =head2 Automatic Debugger Selection + + B reads each F<.bc> or F<.ll> file specified on the command line and + links them together into a single module, called the test program. If any LLVM + passes are specified on the command line, it runs these passes on the test + program. If any of the passes crash, or if they produce malformed output (which + causes the verifier to abort), B starts the crash debugger. + + Otherwise, if the B<-output> option was not specified, B runs the test + program with the C backend (which is assumed to generate good code) to generate + a reference output. Once B has a reference output for the test + program, it tries executing it with the selected code generator. If the + selected code generator crashes, B starts the L on + the code generator. Otherwise, if the resulting output differs from the + reference output, it assumes the difference resulted from a code generator + failure, and starts the L. + + Finally, if the output of the selected code generator matches the reference + output, B runs the test program after all of the LLVM passes have been + applied to it. If its output differs from the reference output, it assumes the + difference resulted from a failure in one of the LLVM passes, and enters the + miscompilation debugger. Otherwise, there is no problem B can debug. + + =head2 Crash debugger + + If an optimizer or code generator crashes, B will try as hard as it + can to reduce the list of passes (for optimizer crashes) and the size of the + test program. First, B figures out which combination of optimizer + passes triggers the bug. This is useful when debugging a problem exposed by + B, for example, because it runs over 38 passes. + + Next, B tries removing functions from the test program, to reduce its + size. Usually it is able to reduce a test program to a single function, when + debugging intraprocedural optimizations. Once the number of functions has been + reduced, it attempts to delete various edges in the control flow graph, to + reduce the size of the function as much as possible. Finally, B + deletes any individual LLVM instructions whose absence does not eliminate the + failure. At the end, B should tell you what passes crash, give you a + bytecode file, and give you instructions on how to reproduce the failure with + B, B, or B. + + =head2 Code generator debugger + + The code generator debugger attempts to narrow down the amount of code that is + being miscompiled by the selected code generator. To do this, it takes the test + program and partitions it into two pieces: one piece which it compiles with the + C backend (into a shared object), and one piece which it runs with either the + JIT or the static compiler (B). It uses several techniques to reduce the + amount of code pushed through the LLVM code generator, to reduce the potential + scope of the problem. After it is finished, it emits two bytecode files (called + "test" [to be compiled with the code generator] and "safe" [to be compiled with + the C backend], respectively), and instructions for reproducing the problem. + The code generator debugger assumes that the C backend produces good code. + + =head2 Miscompilation debugger + + The miscompilation debugger works similarly to the code generator debugger. It + works by splitting the test program into two pieces, running the optimizations + specified on one piece, linking the two pieces back together, and then executing + the result. It attempts to narrow down the list of passes to the one (or few) + which are causing the miscompilation, then reduce the portion of the test + program which is being miscompiled. The miscompilation debugger assumes that + the selected code generator is working properly. + + =head2 Advice for using bugpoint + + B can be a remarkably useful tool, but it sometimes works in + non-obvious ways. Here are some hints and tips: + + =over + + =item * + + In the code generator and miscompilation debuggers, B only + works with programs that have deterministic output. Thus, if the program + outputs C, the date, time, or any other "random" data, B may + misinterpret differences in these data, when output, as the result of a + miscompilation. Programs should be temporarily modified to disable outputs that + are likely to vary from run to run. + + =item * + + In the code generator and miscompilation debuggers, debugging will go faster if + you manually modify the program or its inputs to reduce the runtime, but still + exhibit the problem. + + =item * + + B is extremely useful when working on a new optimization: it helps + track down regressions quickly. To avoid having to relink B every + time you change your optimization, make B dynamically load + your optimization by using the B<-load> option. + + =item * + + B can generate a lot of output and run for a long period of time. It + is often useful to capture the output of the program to file. For example, in + the C shell, you can type: + + bugpoint ... |& tee bugpoint.log + + to get a copy of B's output in the file F, as well as on + your terminal. + + =item * + + B cannot debug problems with the LLVM linker. If B crashes + before you see its C message, you might try running C on the same set of input files. If that also crashes, you may be + experiencing a linker bug. + + =item * + + If your program is supposed to crash, B will be confused. One way to + deal with this is to cause B to ignore the exit code from your + program, by giving it the B<-check-exit-code=false> option. + + =back + + =head1 OPTIONS + + =over + + =item B<--additional-so> F + + Load the dynamic shared object F into the test program whenever it is + run. This is useful if you are debugging programs which depend on non-LLVM + libraries (such as the X or curses libraries) to run. + + =item B<--args> I + + Pass all arguments specified after -args to the test program whenever it runs. + Note that if any of the I start with a '-', you should use: + + bugpoint [bugpoint args] --args -- [program args] + + The "--" right after the B<--args> option tells B to consider any + options starting with C<-> to be part of the B<--args> option, not as options to + B itself. + + =item B<--tool-args> I + + Pass all arguments specified after --tool-args to the LLVM tool under test + (B, B, etc.) whenever it runs. You should use this option in the + following way: + + bugpoint [bugpoint args] --tool-args -- [tool args] + + The "--" right after the B<--tool-args> option tells B to consider any + options starting with C<-> to be part of the B<--tool-args> option, not as + options to B itself. (See B<--args>, above.) + + =item B<--check-exit-code>=I<{true,false}> + + Assume a non-zero exit code or core dump from the test program is a failure. + Defaults to true. + + =item B<--disable-{dce,simplifycfg}> + + Do not run the specified passes to clean up and reduce the size of the test + program. By default, B uses these passes internally when attempting to + reduce test programs. If you're trying to find a bug in one of these passes, + B may crash. + + =item B<--help> + + Print a summary of command line options. + + =item B<--input> F + + Open F and redirect the standard input of the test program, whenever + it runs, to come from that file. + + =item B<--load> F + + Load the dynamic object F into B itself. This object should + register new optimization passes. Once loaded, the object will add new command + line options to enable various optimizations. To see the new complete list of + optimizations, use the B<--help> and B<--load> options together; for example: + + bugpoint --load myNewPass.so --help + + =item B<--output> F + + Whenever the test program produces output on its standard output stream, it + should match the contents of F (the "reference output"). If you + do not use this option, B will attempt to generate a reference output + by compiling the program with the C backend and running it. + + =item B<--profile-info-file> F + + Profile file loaded by B<--profile-loader>. + + =item B<--run-{int,jit,llc,cbe}> + + Whenever the test program is compiled, B should generate code for it + using the specified code generator. These options allow you to choose the + interpreter, the JIT compiler, the static native code compiler, or the C + backend, respectively. + + =back + + =head1 EXIT STATUS + + If B succeeds in finding a problem, it will exit with 0. Otherwise, + if an error occurs, it will exit with a non-zero value. + + =head1 SEE ALSO + + L, L + + =head1 AUTHOR + + Maintained by the LLVM Team (L). + + =cut + From brukman at cs.uiuc.edu Thu Jul 1 15:43:01 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Thu Jul 1 15:43:01 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Target/TargetMachine.h Message-ID: <200407012042.PAA14734@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Target: TargetMachine.h updated: 1.46 -> 1.47 --- Log message: * Doxygenify comments * Tabs-to-spaces --- Diffs of the changes: (+13 -11) Index: llvm/include/llvm/Target/TargetMachine.h diff -u llvm/include/llvm/Target/TargetMachine.h:1.46 llvm/include/llvm/Target/TargetMachine.h:1.47 --- llvm/include/llvm/Target/TargetMachine.h:1.46 Wed Jun 2 21:45:09 2004 +++ llvm/include/llvm/Target/TargetMachine.h Thu Jul 1 15:42:00 2004 @@ -47,15 +47,16 @@ void operator=(const TargetMachine&); // DO NOT IMPLEMENT protected: // Can only create subclasses... TargetMachine(const std::string &name, IntrinsicLowering *IL, - bool LittleEndian = false, - 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); + bool LittleEndian = false, + 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); - // This constructor is used for targets that support arbitrary TargetData - // layouts, like the C backend. It initializes the TargetData to match that - // of the specified module. + /// This constructor is used for targets that support arbitrary TargetData + /// layouts, like the C backend. It initializes the TargetData to match that + /// of the specified module. + /// TargetMachine(const std::string &name, IntrinsicLowering *IL, const Module &M); public: @@ -63,9 +64,10 @@ const std::string &getName() const { return Name; } - // getIntrinsicLowering - This method returns a reference to an - // IntrinsicLowering instance which should be used by the code generator to - // lower unknown intrinsic functions to the equivalent LLVM expansion. + /// getIntrinsicLowering - This method returns a reference to an + /// IntrinsicLowering instance which should be used by the code generator to + /// lower unknown intrinsic functions to the equivalent LLVM expansion. + /// IntrinsicLowering &getIntrinsicLowering() const { return *IL; } // Interfaces to the major aspects of target machine information: From lattner at cs.uiuc.edu Thu Jul 1 15:43:07 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Jul 1 15:43:07 2004 Subject: [llvm-commits] CVS: llvm/docs/Bugpoint.html Message-ID: <200407012041.PAA05037@apoc.cs.uiuc.edu> Changes in directory llvm/docs: Bugpoint.html updated: 1.1 -> 1.2 --- Log message: Fix broken links --- Diffs of the changes: (+4 -8) Index: llvm/docs/Bugpoint.html diff -u llvm/docs/Bugpoint.html:1.1 llvm/docs/Bugpoint.html:1.2 --- llvm/docs/Bugpoint.html:1.1 Thu Jul 1 15:10:40 2004 +++ llvm/docs/Bugpoint.html Thu Jul 1 15:41:43 2004 @@ -12,7 +12,7 @@

    SYNOPSIS

    bugpoint [options] [input LLVM ll/bc files] [LLVM passes] --args <program arguments>... - +

    DESCRIPTION

    The bugpoint tool narrows down the source of @@ -20,7 +20,7 @@ failures: optimizer crashes, miscompilations by optimizers, or bad native code generation (including problems in the static and JIT compilers). It aims to reduce large test cases to small, useful ones. For example, -if gccas crashes while optimizing a file, it +if gccas crashes while optimizing a file, it will identify the optimization (or combination of optimizations) that causes the crash, and reduce the file down to a small example which triggers the crash.

    @@ -84,8 +84,8 @@ bugpoint deletes any individual LLVM instructions whose absence does not eliminate the failure. At the end, bugpoint should tell you what passes crash, give you a bytecode file, and give you instructions on how to -reproduce the failure with opt, analyze, or llc.

    +reproduce the failure with opt, analyze, or llc.

    Code generator debugger

    @@ -239,10 +239,6 @@ If bugpoint succeeds in finding a problem, it will exit with 0. Otherwise, if an error occurs, it will exit with a non-zero value. -

    SEE ALSO

    -
    opt, -analyze -
    Maintained by the LLVM Team. From llvm at cs.uiuc.edu Thu Jul 1 22:20:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Thu Jul 1 22:20:01 2004 Subject: [llvm-commits] CVS: llvm/tools/llvm-bcanalyzer/ Message-ID: <200407020319.WAA17069@zion.cs.uiuc.edu> Changes in directory llvm/tools/llvm-bcanalyzer: --- Log message: Directory /var/cvs/llvm/llvm/tools/llvm-bcanalyzer added to the repository --- Diffs of the changes: (+0 -0) From llvm at cs.uiuc.edu Thu Jul 1 22:24:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Thu Jul 1 22:24:01 2004 Subject: [llvm-commits] CVS: llvm/tools/llvm-bcanalyzer/Makefile llvm-bcanalyzer.cpp Message-ID: <200407020323.WAA17126@zion.cs.uiuc.edu> Changes in directory llvm/tools/llvm-bcanalyzer: Makefile added (r1.1) llvm-bcanalyzer.cpp added (r1.1) --- Log message: Name Change: llvm-abcd -> llvm-bcanalyzer --- Diffs of the changes: (+111 -0) Index: llvm/tools/llvm-bcanalyzer/Makefile diff -c /dev/null llvm/tools/llvm-bcanalyzer/Makefile:1.1 *** /dev/null Thu Jul 1 22:23:03 2004 --- llvm/tools/llvm-bcanalyzer/Makefile Thu Jul 1 22:22:53 2004 *************** *** 0 **** --- 1,13 ---- + ##===- tools/llvm-bcanalyzer/Makefile ----------------------*- Makefile -*-===## + # + # The LLVM Compiler Infrastructure + # + # This file was developed by Reid Spencer and is distributed under the + # University of Illinois Open Source License. See LICENSE.TXT for details. + # + ##===----------------------------------------------------------------------===## + LEVEL = ../.. + + TOOLNAME = llvm-bcanalyzer + USEDLIBS = bcreader vmcore support.a + include $(LEVEL)/Makefile.common Index: llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp diff -c /dev/null llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp:1.1 *** /dev/null Thu Jul 1 22:23:03 2004 --- llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp Thu Jul 1 22:22:53 2004 *************** *** 0 **** --- 1,98 ---- + //===-- llvm-bcanalyzer.cpp - Byte Code Analyzer --------------------------===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by Reid Spencer and is distributed under the + // University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // This tool may be invoked in the following manner: + // llvm-bcanalyzer [options] - Read LLVM bytecode from stdin + // llvm-bcanalyzer [options] x.bc - Read LLVM bytecode from the x.bc file + // + // Options: + // --help - Output information about command line switches + // --nodetails - Don't print out detailed informaton about individual + // blocks and functions + // --dump - Dump low-level bytecode structure in readable format + // + // This tool provides analytical information about a bytecode file. It is + // intended as an aid to developers of bytecode reading and writing software. It + // produces on std::out a summary of the bytecode file that shows various + // statistics about the contents of the file. By default this information is + // detailed and contains information about individual bytecode blocks and the + // functions in the module. To avoid this more detailed output, use the + // -nodetails option to limit the output to just module level information. + // The tool is also able to print a bytecode file in a straight forward text + // format that shows the containment and relationships of the information in + // the bytecode file (-dump option). + //===----------------------------------------------------------------------===// + + #include "llvm/Analysis/Verifier.h" + #include "llvm/Bytecode/Analyzer.h" + #include "Support/CommandLine.h" + #include "llvm/System/Signals.h" + #include + #include + + using namespace llvm; + + static cl::opt + InputFilename(cl::Positional, cl::desc(""), cl::init("-")); + + static cl::opt NoDetails ("nodetails", cl::desc("Skip detailed output")); + static cl::opt Dump ("dump", cl::desc("Dump low level bytecode trace")); + static cl::opt Verify ("verify", cl::desc("Progressively verify module")); + + int + main(int argc, char **argv) + { + cl::ParseCommandLineOptions(argc, argv, + " llvm-bcanalyzer Analysis of ByteCode Dumper\n"); + + PrintStackTraceOnErrorSignal(); + + std::ostream* Out = &std::cout; // Default to printing to stdout... + std::istream* In = &std::cin; // Default to reading stdin + std::string ErrorMessage; + BytecodeAnalysis bca; + + /// Determine what to generate + bca.dumpBytecode = Dump; + bca.detailedResults = !NoDetails; + bca.progressiveVerify = Verify; + + /// Analyze the bytecode file + Module* M = AnalyzeBytecodeFile(InputFilename, bca, &ErrorMessage); + + // All that bcanalyzer does is write the gathered statistics to the output + PrintBytecodeAnalysis(bca,*Out); + + if ( M && Verify ) { + std::string verificationMsg; + try { + verifyModule( *M, ThrowExceptionAction ); + } catch (std::string& errmsg ) { + verificationMsg = errmsg; + } + if ( verificationMsg.length() > 0 ) + std::cerr << "Final Verification Message: " << verificationMsg << "\n"; + } + + + // If there was an error, print it and stop. + if ( ErrorMessage.size() ) { + std::cerr << argv[0] << ": " << ErrorMessage << "\n"; + return 1; + } + + + if (Out != &std::cout) { + ((std::ofstream*)Out)->close(); + delete Out; + } + return 0; + } + + // vim: sw=2 From llvm at cs.uiuc.edu Thu Jul 1 22:24:11 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Thu Jul 1 22:24:11 2004 Subject: [llvm-commits] CVS: llvm/tools/llvm-abcd/Makefile llvm-abcd.cpp Message-ID: <200407020323.WAA17117@zion.cs.uiuc.edu> Changes in directory llvm/tools/llvm-abcd: Makefile (r1.2) removed llvm-abcd.cpp (r1.5) removed --- Log message: Name Change: llvm-abcd -> llvm-bcanalyzer --- Diffs of the changes: (+0 -0) From llvm at cs.uiuc.edu Thu Jul 1 22:45:02 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Thu Jul 1 22:45:02 2004 Subject: [llvm-commits] CVS: llvm/docs/CommandGuide/llvm-bcanalyzer.pod Message-ID: <200407020344.WAA17228@zion.cs.uiuc.edu> Changes in directory llvm/docs/CommandGuide: llvm-bcanalyzer.pod added (r1.1) --- Log message: Podified documentation for the llvm-bcanalyzer tool (nee llvm-abcd). --- Diffs of the changes: (+66 -0) Index: llvm/docs/CommandGuide/llvm-bcanalyzer.pod diff -c /dev/null llvm/docs/CommandGuide/llvm-bcanalyzer.pod:1.1 *** /dev/null Thu Jul 1 22:44:24 2004 --- llvm/docs/CommandGuide/llvm-bcanalyzer.pod Thu Jul 1 22:44:14 2004 *************** *** 0 **** --- 1,66 ---- + =pod + + =head1 NAME + + llvm-bcanalyzer - LLVM bytecode analyzer + + =head1 SYNOPSIS + + llvm-bcanalyzer [options] [filename] + + =head1 DESCRIPTION + + The B command is a small utility for analyzing bytecode files. + The tool reads a bytecode file (such as generated with the B tool) and + produces a statistical report on the contents of the byteocde file. The tool + will also dump a low level but human readable version of the bytecode file. + This tool is probably not of much interest or utility except for those working + directly with the bytecode file format. Most LLVM users can just ignore + this tool. + + If F is omitted or is C<->, then B reads its input + from standard input. This is useful for combining the tool into a pipeline. + + Output is written to the standard output. + + =head1 OPTIONS + + =over + + =item B<-nodetails> + + Causes B to abbreviate its output by writing out only a module + level summary. The details for individual functions are not displayed. + + =item B<-dump> + + Causes B to dump the bytecode in a human readable format. This + format is significantly different from LLVM assembly and provides details about + the encoding of the bytecode file. + + =item B<-verify> + + Causes B to verify the module produced by by reading the + bytecode. This ensures that the statistics generated are based on a consistent + module. + + =item B<--help> + + Print a summary of command line options. + + =back + + =head1 EXIT STATUS + + If B succeeds, it will exit with 0. Otherwise, if an error + occurs, it will exit with a non-zero value, usually 1. + + =head1 SEE ALSO + + L, L + + =head1 AUTHORS + + Maintained by the LLVM Team (L). + + =cut From llvm at cs.uiuc.edu Thu Jul 1 22:46:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Thu Jul 1 22:46:01 2004 Subject: [llvm-commits] CVS: llvm/docs/CommandGuide/llvm-abcd.html Message-ID: <200407020345.WAA17270@zion.cs.uiuc.edu> Changes in directory llvm/docs/CommandGuide: llvm-abcd.html (r1.2) removed --- Log message: llvm-abcd tool name changed to llvm-bcanalyzer: see llvm-bcanalyzer.pod. --- Diffs of the changes: (+0 -0) From gaeke at cs.uiuc.edu Thu Jul 1 23:58:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Thu Jul 1 23:58:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/SparcV9/SparcV9.td SparcV9InstrSelectionSupport.h SparcV9SchedInfo.cpp Message-ID: <200407020457.XAA18000@seraph.cs.uiuc.edu> Changes in directory llvm/lib/Target/SparcV9: SparcV9.td updated: 1.32 -> 1.33 SparcV9InstrSelectionSupport.h updated: 1.17 -> 1.18 SparcV9SchedInfo.cpp updated: 1.12 -> 1.13 --- Log message: RETURN instructions are not used in the sparc backend. When in doubt, stamp it out!! --- Diffs of the changes: (+0 -9) Index: llvm/lib/Target/SparcV9/SparcV9.td diff -u llvm/lib/Target/SparcV9/SparcV9.td:1.32 llvm/lib/Target/SparcV9/SparcV9.td:1.33 --- llvm/lib/Target/SparcV9/SparcV9.td:1.32 Wed Jun 9 16:54:58 2004 +++ llvm/lib/Target/SparcV9/SparcV9.td Thu Jul 1 23:57:35 2004 @@ -667,12 +667,6 @@ def RDCCR : F3_17<2, 0b101000, "rd">; // rd %ccr, r } -// Section A.45: RETURN - p216 -let isReturn = 1 in { - def RETURNr : F3_3<2, 0b111001, "return">; // return - def RETURNi : F3_4<2, 0b111001, "return">; // return -} - // Section A.46: SAVE and RESTORE - p217 def SAVEr : F3_1<2, 0b111100, "save">; // save r, r, r def SAVEi : F3_2<2, 0b111100, "save">; // save r, i, r Index: llvm/lib/Target/SparcV9/SparcV9InstrSelectionSupport.h diff -u llvm/lib/Target/SparcV9/SparcV9InstrSelectionSupport.h:1.17 llvm/lib/Target/SparcV9/SparcV9InstrSelectionSupport.h:1.18 --- llvm/lib/Target/SparcV9/SparcV9InstrSelectionSupport.h:1.17 Thu Jun 17 13:17:10 2004 +++ llvm/lib/Target/SparcV9/SparcV9InstrSelectionSupport.h Thu Jul 1 23:57:35 2004 @@ -205,7 +205,6 @@ /* jump & return */ case V9::JMPLCALLr: return V9::JMPLCALLi; case V9::JMPLRETr: return V9::JMPLRETi; - case V9::RETURNr: return V9::RETURNi; /* save and restore */ case V9::SAVEr: return V9::SAVEi; Index: llvm/lib/Target/SparcV9/SparcV9SchedInfo.cpp diff -u llvm/lib/Target/SparcV9/SparcV9SchedInfo.cpp:1.12 llvm/lib/Target/SparcV9/SparcV9SchedInfo.cpp:1.13 --- llvm/lib/Target/SparcV9/SparcV9SchedInfo.cpp:1.12 Sun Apr 25 02:04:49 2004 +++ llvm/lib/Target/SparcV9/SparcV9SchedInfo.cpp Thu Jul 1 23:57:35 2004 @@ -457,8 +457,6 @@ //{ V9::FLUSH, true, true, 9 }, //{ V9::FLUSHW, true, true, 9 }, //{ V9::ALIGNADDR, true, true, 0 }, - { V9::RETURNr, true, true, 0 }, - { V9::RETURNi, true, true, 0 }, //{ V9::DONE, true, true, 0 }, //{ V9::RETRY, true, true, 0 }, //{ V9::TCC, true, true, 0 }, From gaeke at cs.uiuc.edu Thu Jul 1 23:59:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Thu Jul 1 23:59:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/SparcV9/SparcV9Instr.def Message-ID: <200407020457.XAA18008@seraph.cs.uiuc.edu> Changes in directory llvm/lib/Target/SparcV9: SparcV9Instr.def updated: 1.26 -> 1.27 --- Log message: Add M_TERMINATOR_FLAG to terminator instructions (branches and returns). Also, the RETURN instructions are not used in the sparcv9 backend. --- Diffs of the changes: (+48 -46) Index: llvm/lib/Target/SparcV9/SparcV9Instr.def diff -u llvm/lib/Target/SparcV9/SparcV9Instr.def:1.26 llvm/lib/Target/SparcV9/SparcV9Instr.def:1.27 --- llvm/lib/Target/SparcV9/SparcV9Instr.def:1.26 Sun Apr 25 02:04:49 2004 +++ llvm/lib/Target/SparcV9/SparcV9Instr.def Thu Jul 1 23:57:37 2004 @@ -44,7 +44,8 @@ // instr sched class (defined above) // instr class flags (defined in TargetInstrInfo.h) - +#define BRANCHFLAGS M_BRANCH_FLAG|M_TERMINATOR_FLAG +#define RETFLAGS M_RET_FLAG|M_TERMINATOR_FLAG I(NOP, "nop", 0, -1, 0, false, 0, 1, SPARC_NONE, M_NOP_FLAG) @@ -194,52 +195,52 @@ // Branch on integer comparison with zero. // Latency excludes the delay slot since it can be issued in same cycle. -I(BRZ , "brz", 2, -1, B15, true , 1, 1, SPARC_CTI, M_BRANCH_FLAG) -I(BRLEZ, "brlez", 2, -1, B15, true , 1, 1, SPARC_CTI, M_BRANCH_FLAG) -I(BRLZ , "brlz", 2, -1, B15, true , 1, 1, SPARC_CTI, M_BRANCH_FLAG) -I(BRNZ , "brnz", 2, -1, B15, true , 1, 1, SPARC_CTI, M_BRANCH_FLAG) -I(BRGZ , "brgz", 2, -1, B15, true , 1, 1, SPARC_CTI, M_BRANCH_FLAG) -I(BRGEZ, "brgez", 2, -1, B15, true , 1, 1, SPARC_CTI, M_BRANCH_FLAG) +I(BRZ , "brz", 2, -1, B15, true , 1, 1, SPARC_CTI, BRANCHFLAGS) +I(BRLEZ, "brlez", 2, -1, B15, true , 1, 1, SPARC_CTI, BRANCHFLAGS) +I(BRLZ , "brlz", 2, -1, B15, true , 1, 1, SPARC_CTI, BRANCHFLAGS) +I(BRNZ , "brnz", 2, -1, B15, true , 1, 1, SPARC_CTI, BRANCHFLAGS) +I(BRGZ , "brgz", 2, -1, B15, true , 1, 1, SPARC_CTI, BRANCHFLAGS) +I(BRGEZ, "brgez", 2, -1, B15, true , 1, 1, SPARC_CTI, BRANCHFLAGS) // Branch on integer condition code. // The first argument specifies the ICC register: %icc or %xcc // Latency includes the delay slot. -I(BA , "ba", 1, -1, B21, true , 1, 2, SPARC_CTI, M_CC_FLAG | M_BRANCH_FLAG) -I(BN , "bn", 2, -1, B21, true , 1, 2, SPARC_CTI, M_CC_FLAG | M_BRANCH_FLAG) -I(BNE , "bne", 2, -1, B21, true , 1, 2, SPARC_CTI, M_CC_FLAG | M_BRANCH_FLAG) -I(BE , "be", 2, -1, B21, true , 1, 2, SPARC_CTI, M_CC_FLAG | M_BRANCH_FLAG) -I(BG , "bg", 2, -1, B21, true , 1, 2, SPARC_CTI, M_CC_FLAG | M_BRANCH_FLAG) -I(BLE , "ble", 2, -1, B21, true , 1, 2, SPARC_CTI, M_CC_FLAG | M_BRANCH_FLAG) -I(BGE , "bge", 2, -1, B21, true , 1, 2, SPARC_CTI, M_CC_FLAG | M_BRANCH_FLAG) -I(BL , "bl", 2, -1, B21, true , 1, 2, SPARC_CTI, M_CC_FLAG | M_BRANCH_FLAG) -I(BGU , "bgu", 2, -1, B21, true , 1, 2, SPARC_CTI, M_CC_FLAG | M_BRANCH_FLAG) -I(BLEU, "bleu", 2, -1, B21, true , 1, 2, SPARC_CTI, M_CC_FLAG | M_BRANCH_FLAG) -I(BCC , "bcc", 2, -1, B21, true , 1, 2, SPARC_CTI, M_CC_FLAG | M_BRANCH_FLAG) -I(BCS , "bcs", 2, -1, B21, true , 1, 2, SPARC_CTI, M_CC_FLAG | M_BRANCH_FLAG) -I(BPOS, "bpos", 2, -1, B21, true , 1, 2, SPARC_CTI, M_CC_FLAG | M_BRANCH_FLAG) -I(BNEG, "bneg", 2, -1, B21, true , 1, 2, SPARC_CTI, M_CC_FLAG | M_BRANCH_FLAG) -I(BVC , "bvc", 2, -1, B21, true , 1, 2, SPARC_CTI, M_CC_FLAG | M_BRANCH_FLAG) -I(BVS , "bvs", 2, -1, B21, true , 1, 2, SPARC_CTI, M_CC_FLAG | M_BRANCH_FLAG) +I(BA , "ba", 1, -1, B21, true , 1, 2, SPARC_CTI, M_CC_FLAG|BRANCHFLAGS) +I(BN , "bn", 2, -1, B21, true , 1, 2, SPARC_CTI, M_CC_FLAG|BRANCHFLAGS) +I(BNE , "bne", 2, -1, B21, true , 1, 2, SPARC_CTI, M_CC_FLAG|BRANCHFLAGS) +I(BE , "be", 2, -1, B21, true , 1, 2, SPARC_CTI, M_CC_FLAG|BRANCHFLAGS) +I(BG , "bg", 2, -1, B21, true , 1, 2, SPARC_CTI, M_CC_FLAG|BRANCHFLAGS) +I(BLE , "ble", 2, -1, B21, true , 1, 2, SPARC_CTI, M_CC_FLAG|BRANCHFLAGS) +I(BGE , "bge", 2, -1, B21, true , 1, 2, SPARC_CTI, M_CC_FLAG|BRANCHFLAGS) +I(BL , "bl", 2, -1, B21, true , 1, 2, SPARC_CTI, M_CC_FLAG|BRANCHFLAGS) +I(BGU , "bgu", 2, -1, B21, true , 1, 2, SPARC_CTI, M_CC_FLAG|BRANCHFLAGS) +I(BLEU, "bleu", 2, -1, B21, true , 1, 2, SPARC_CTI, M_CC_FLAG|BRANCHFLAGS) +I(BCC , "bcc", 2, -1, B21, true , 1, 2, SPARC_CTI, M_CC_FLAG|BRANCHFLAGS) +I(BCS , "bcs", 2, -1, B21, true , 1, 2, SPARC_CTI, M_CC_FLAG|BRANCHFLAGS) +I(BPOS, "bpos", 2, -1, B21, true , 1, 2, SPARC_CTI, M_CC_FLAG|BRANCHFLAGS) +I(BNEG, "bneg", 2, -1, B21, true , 1, 2, SPARC_CTI, M_CC_FLAG|BRANCHFLAGS) +I(BVC , "bvc", 2, -1, B21, true , 1, 2, SPARC_CTI, M_CC_FLAG|BRANCHFLAGS) +I(BVS , "bvs", 2, -1, B21, true , 1, 2, SPARC_CTI, M_CC_FLAG|BRANCHFLAGS) // Branch on floating point condition code. // The first argument is the FCCn register (0 <= n <= 3). // Latency includes the delay slot. -I(FBA , "fba", 2, -1, B18, true , 1, 2, SPARC_CTI, M_CC_FLAG | M_BRANCH_FLAG) -I(FBN , "fbn", 2, -1, B18, true , 1, 2, SPARC_CTI, M_CC_FLAG | M_BRANCH_FLAG) -I(FBU , "fbu", 2, -1, B18, true , 1, 2, SPARC_CTI, M_CC_FLAG | M_BRANCH_FLAG) -I(FBG , "fbg", 2, -1, B18, true , 1, 2, SPARC_CTI, M_CC_FLAG | M_BRANCH_FLAG) -I(FBUG , "fbug", 2, -1, B18, true , 1, 2, SPARC_CTI, M_CC_FLAG | M_BRANCH_FLAG) -I(FBL , "fbl", 2, -1, B18, true , 1, 2, SPARC_CTI, M_CC_FLAG | M_BRANCH_FLAG) -I(FBUL , "fbul", 2, -1, B18, true , 1, 2, SPARC_CTI, M_CC_FLAG | M_BRANCH_FLAG) -I(FBLG , "fblg", 2, -1, B18, true , 1, 2, SPARC_CTI, M_CC_FLAG | M_BRANCH_FLAG) -I(FBNE , "fbne", 2, -1, B18, true , 1, 2, SPARC_CTI, M_CC_FLAG | M_BRANCH_FLAG) -I(FBE , "fbe", 2, -1, B18, true , 1, 2, SPARC_CTI, M_CC_FLAG | M_BRANCH_FLAG) -I(FBUE , "fbue", 2, -1, B18, true , 1, 2, SPARC_CTI, M_CC_FLAG | M_BRANCH_FLAG) -I(FBGE , "fbge", 2, -1, B18, true , 1, 2, SPARC_CTI, M_CC_FLAG | M_BRANCH_FLAG) -I(FBUGE, "fbuge", 2, -1, B18, true , 1, 2, SPARC_CTI, M_CC_FLAG | M_BRANCH_FLAG) -I(FBLE , "fble", 2, -1, B18, true , 1, 2, SPARC_CTI, M_CC_FLAG | M_BRANCH_FLAG) -I(FBULE, "fbule", 2, -1, B18, true , 1, 2, SPARC_CTI, M_CC_FLAG | M_BRANCH_FLAG) -I(FBO , "fbo", 2, -1, B18, true , 1, 2, SPARC_CTI, M_CC_FLAG | M_BRANCH_FLAG) +I(FBA , "fba", 2, -1, B18, true , 1, 2, SPARC_CTI, M_CC_FLAG|BRANCHFLAGS) +I(FBN , "fbn", 2, -1, B18, true , 1, 2, SPARC_CTI, M_CC_FLAG|BRANCHFLAGS) +I(FBU , "fbu", 2, -1, B18, true , 1, 2, SPARC_CTI, M_CC_FLAG|BRANCHFLAGS) +I(FBG , "fbg", 2, -1, B18, true , 1, 2, SPARC_CTI, M_CC_FLAG|BRANCHFLAGS) +I(FBUG , "fbug", 2, -1, B18, true , 1, 2, SPARC_CTI, M_CC_FLAG|BRANCHFLAGS) +I(FBL , "fbl", 2, -1, B18, true , 1, 2, SPARC_CTI, M_CC_FLAG|BRANCHFLAGS) +I(FBUL , "fbul", 2, -1, B18, true , 1, 2, SPARC_CTI, M_CC_FLAG|BRANCHFLAGS) +I(FBLG , "fblg", 2, -1, B18, true , 1, 2, SPARC_CTI, M_CC_FLAG|BRANCHFLAGS) +I(FBNE , "fbne", 2, -1, B18, true , 1, 2, SPARC_CTI, M_CC_FLAG|BRANCHFLAGS) +I(FBE , "fbe", 2, -1, B18, true , 1, 2, SPARC_CTI, M_CC_FLAG|BRANCHFLAGS) +I(FBUE , "fbue", 2, -1, B18, true , 1, 2, SPARC_CTI, M_CC_FLAG|BRANCHFLAGS) +I(FBGE , "fbge", 2, -1, B18, true , 1, 2, SPARC_CTI, M_CC_FLAG|BRANCHFLAGS) +I(FBUGE, "fbuge", 2, -1, B18, true , 1, 2, SPARC_CTI, M_CC_FLAG|BRANCHFLAGS) +I(FBLE , "fble", 2, -1, B18, true , 1, 2, SPARC_CTI, M_CC_FLAG|BRANCHFLAGS) +I(FBULE, "fbule", 2, -1, B18, true , 1, 2, SPARC_CTI, M_CC_FLAG|BRANCHFLAGS) +I(FBO , "fbo", 2, -1, B18, true , 1, 2, SPARC_CTI, M_CC_FLAG|BRANCHFLAGS) // Conditional move on integer comparison with zero. I(MOVRZr , "movrz", 3, 2, B12, true , 0, 2, SPARC_SINGLE, 0) @@ -517,13 +518,11 @@ // Call, Return and "Jump and link". Operand (2) for JMPL is marked as // a "result" because JMPL stores the return address for the call in it. // Latency includes the delay slot. -I(CALL, "call", 1, -1, B29, true , 1, 2, SPARC_CTI, M_CALL_FLAG) -I(JMPLCALLr, "jmpl", 3, 2, B12, true , 1, 2, SPARC_CTI, M_CALL_FLAG) -I(JMPLCALLi, "jmpl", 3, 2, B12, true , 1, 2, SPARC_CTI, M_CALL_FLAG) -I(JMPLRETr, "jmpl", 3, 2, B12, true , 1, 2, SPARC_CTI, M_RET_FLAG) -I(JMPLRETi, "jmpl", 3, 2, B12, true , 1, 2, SPARC_CTI, M_RET_FLAG) -I(RETURNr, "return", 2, -1, 0, false, 1, 2, SPARC_CTI, M_RET_FLAG) -I(RETURNi, "return", 2, -1, 0, false, 1, 2, SPARC_CTI, M_RET_FLAG) +I(CALL, "call", 1, -1, B29, true , 1, 2, SPARC_CTI, M_CALL_FLAG) +I(JMPLCALLr, "jmpl", 3, 2, B12, true , 1, 2, SPARC_CTI, M_CALL_FLAG) +I(JMPLCALLi, "jmpl", 3, 2, B12, true , 1, 2, SPARC_CTI, M_CALL_FLAG) +I(JMPLRETr, "jmpl", 3, 2, B12, true , 1, 2, SPARC_CTI, RETFLAGS) +I(JMPLRETi, "jmpl", 3, 2, B12, true , 1, 2, SPARC_CTI, RETFLAGS) // SAVE and restore instructions I(SAVEr, "save", 3, 2, B12, true , 0, 1, SPARC_SINGLE, 0) @@ -550,4 +549,7 @@ #undef B22 #undef B29 +#undef BRANCHFLAGS +#undef RETFLAGS + #undef I From gaeke at cs.uiuc.edu Fri Jul 2 00:31:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Fri Jul 2 00:31:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp Message-ID: <200407020530.AAA18177@kain.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: DecomposeMultiDimRefs.cpp updated: 1.31 -> 1.32 --- Log message: Get rid of a dead variable, and fix a typo in a comment. --- Diffs of the changes: (+1 -4) Index: llvm/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp diff -u llvm/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp:1.31 llvm/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp:1.32 --- llvm/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp:1.31 Fri Jan 9 00:02:20 2004 +++ llvm/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp Fri Jul 2 00:30:01 2004 @@ -58,7 +58,7 @@ // // opCode CompositeType* P, [uint|ubyte] idx1, ..., [uint|ubyte] idxN // -// this function generates the foll sequence: +// this function generates the following sequence: // // ptr1 = getElementPtr P, idx1 // ptr2 = getElementPtr ptr1, 0, idx2 @@ -83,9 +83,6 @@ Value *LastPtr = GEP->getPointerOperand(); Instruction *InsertPoint = GEP->getNext(); // Insert before the next insn - // The vector of new instructions to be created - std::vector NewInsts; - // Process each index except the last one. User::const_op_iterator OI = GEP->idx_begin(), OE = GEP->idx_end(); for (; OI+1 != OE; ++OI) { From lattner at cs.uiuc.edu Fri Jul 2 00:45:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Jul 2 00:45:02 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/Passes.h Message-ID: <200407020544.AAA22043@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: Passes.h updated: 1.15 -> 1.16 --- Log message: Add a new pass for code generators to use --- Diffs of the changes: (+9 -1) Index: llvm/include/llvm/CodeGen/Passes.h diff -u llvm/include/llvm/CodeGen/Passes.h:1.15 llvm/include/llvm/CodeGen/Passes.h:1.16 --- llvm/include/llvm/CodeGen/Passes.h:1.15 Sat May 8 11:14:02 2004 +++ llvm/include/llvm/CodeGen/Passes.h Fri Jul 2 00:44:13 2004 @@ -23,7 +23,15 @@ class FunctionPass; class PassInfo; class TargetMachine; - + + /// createUnreachableBlockEliminationPass - The LLVM code generator does not + /// work well with unreachable basic blocks (what live ranges make sense for a + /// block that cannot be reached?). As such, a code generator should either + /// not instruction select unreachable blocks, or it can run this pass as it's + /// last LLVM modifying pass to clean up blocks that are not reachable from + /// the entry block. + FunctionPass *createUnreachableBlockEliminationPass(); + /// MachineFunctionPrinter pass - This pass prints out the machine function to /// standard error, as a debugging tool. FunctionPass *createMachineFunctionPrinterPass(std::ostream *OS, From lattner at cs.uiuc.edu Fri Jul 2 00:45:11 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Jul 2 00:45:11 2004 Subject: [llvm-commits] CVS: llvm/test/Regression/CodeGen/X86/2003-08-23-DeadBlockTest.llx Message-ID: <200407020544.AAA22029@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/CodeGen/X86: 2003-08-23-DeadBlockTest.llx updated: 1.2 -> 1.3 --- Log message: Make this testcase more interesting --- Diffs of the changes: (+6 -5) Index: llvm/test/Regression/CodeGen/X86/2003-08-23-DeadBlockTest.llx diff -u llvm/test/Regression/CodeGen/X86/2003-08-23-DeadBlockTest.llx:1.2 llvm/test/Regression/CodeGen/X86/2003-08-23-DeadBlockTest.llx:1.3 --- llvm/test/Regression/CodeGen/X86/2003-08-23-DeadBlockTest.llx:1.2 Mon Sep 15 15:02:53 2003 +++ llvm/test/Regression/CodeGen/X86/2003-08-23-DeadBlockTest.llx Fri Jul 2 00:43:51 2004 @@ -2,11 +2,12 @@ implementation -void %test() { -entry: ret void +int %test() { +entry: ret int 7 Test: ; dead block! - call void %test() - call void %test() - ret void + %A = call int %test() + %B = call int %test() + %C = add int %A, %B + ret int %C } From lattner at cs.uiuc.edu Fri Jul 2 00:47:03 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Jul 2 00:47:03 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/UnreachableBlockElim.cpp Message-ID: <200407020546.AAA22069@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: UnreachableBlockElim.cpp added (r1.1) --- Log message: Add a trivially simple pass to delete unreachable blocks from the CFG. This pass is required to paper over problems in the code generator (primarily live variables and its clients) which doesn't really have any well defined semantics for unreachable code. The proper solution to this problem is to have instruction selectors not select blocks that are unreachable. Until we have a instruction selection framework available for use, however, we can't expect all instruction selector writers to do this. Until then, this pass should be used. --- Diffs of the changes: (+68 -0) Index: llvm/lib/CodeGen/UnreachableBlockElim.cpp diff -c /dev/null llvm/lib/CodeGen/UnreachableBlockElim.cpp:1.1 *** /dev/null Fri Jul 2 00:46:20 2004 --- llvm/lib/CodeGen/UnreachableBlockElim.cpp Fri Jul 2 00:46:10 2004 *************** *** 0 **** --- 1,68 ---- + //===-- UnreachableBlockElim.cpp - Remove unreachable blocks for codegen --===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by the LLVM research group and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // This pass is an extremely simple version of the SimplifyCFG pass. Its sole + // job is to delete LLVM basic blocks that are not reachable from the entry + // node. To do this, it performs a simple depth first traversal of the CFG, + // then deletes any unvisited nodes. + // + // Note that this pass is really a hack. In particular, the instruction + // selectors for various targets should just not generate code for unreachable + // blocks. Until LLVM has a more systematic way of defining instruction + // selectors, however, we cannot really expect them to handle additional + // complexity. + // + //===----------------------------------------------------------------------===// + + #include "llvm/CodeGen/Passes.h" + #include "llvm/Function.h" + #include "llvm/Pass.h" + #include "llvm/Support/CFG.h" + #include "Support/DepthFirstIterator.h" + using namespace llvm; + + namespace { + class UnreachableBlockElim : public FunctionPass { + virtual bool runOnFunction(Function &F); + }; + RegisterOpt + X("unreachableblockelim", "Remove unreachable blocks from the CFG"); + } + + FunctionPass *llvm::createUnreachableBlockEliminationPass() { + return new UnreachableBlockElim(); + } + + bool UnreachableBlockElim::runOnFunction(Function &F) { + std::set Reachable; + + // Mark all reachable blocks. + for (df_ext_iterator I = df_ext_begin(&F, Reachable), + E = df_ext_end(&F, Reachable); I != E; ++I) + /* Mark all reachable blocks */; + + // Loop over all dead blocks, remembering them and deleting all instructions + // in them. + std::vector DeadBlocks; + for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I) + if (!Reachable.count(I)) { + DeadBlocks.push_back(I); + for (succ_iterator SI = succ_begin(&*I), E = succ_end(&*I); SI != E; ++SI) + (*SI)->removePredecessor(I); + I->dropAllReferences(); + } + + if (DeadBlocks.empty()) return false; + + // Actually remove the blocks now. + for (unsigned i = 0, e = DeadBlocks.size(); i != e; ++i) + F.getBasicBlockList().erase(DeadBlocks[i]); + + return true; + } From lattner at cs.uiuc.edu Fri Jul 2 00:48:06 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Jul 2 00:48:06 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86TargetMachine.cpp Message-ID: <200407020546.AAA22085@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86TargetMachine.cpp updated: 1.58 -> 1.59 --- Log message: Remove dead blocks --- Diffs of the changes: (+6 -0) Index: llvm/lib/Target/X86/X86TargetMachine.cpp diff -u llvm/lib/Target/X86/X86TargetMachine.cpp:1.58 llvm/lib/Target/X86/X86TargetMachine.cpp:1.59 --- llvm/lib/Target/X86/X86TargetMachine.cpp:1.58 Tue Jun 29 02:17:12 2004 +++ llvm/lib/Target/X86/X86TargetMachine.cpp Fri Jul 2 00:46:41 2004 @@ -68,6 +68,9 @@ // FIXME: Implement the switch instruction in the instruction selector! PM.add(createLowerSwitchPass()); + // Make sure that no unreachable blocks are instruction selected. + PM.add(createUnreachableBlockEliminationPass()); + if (NoPatternISel && NoSimpleISel) PM.add(createX86SimpleInstructionSelector(*this)); else if (NoPatternISel) @@ -125,6 +128,9 @@ // FIXME: Implement the switch instruction in the instruction selector! PM.add(createLowerSwitchPass()); + // Make sure that no unreachable blocks are instruction selected. + PM.add(createUnreachableBlockEliminationPass()); + if (NoPatternISel) PM.add(createX86SimpleInstructionSelector(TM)); else From lattner at cs.uiuc.edu Fri Jul 2 00:54:47 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Jul 2 00:54:47 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervals.cpp Message-ID: <200407020552.AAA22144@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveIntervals.cpp updated: 1.83 -> 1.84 --- Log message: Revert patches 1.79 and 1.80 which had to do with dead MBB's. Now that they don't exist, we don't have to pretend to handle them. --- Diffs of the changes: (+4 -6) Index: llvm/lib/CodeGen/LiveIntervals.cpp diff -u llvm/lib/CodeGen/LiveIntervals.cpp:1.83 llvm/lib/CodeGen/LiveIntervals.cpp:1.84 --- llvm/lib/CodeGen/LiveIntervals.cpp:1.83 Thu Jul 1 01:15:32 2004 +++ llvm/lib/CodeGen/LiveIntervals.cpp Fri Jul 2 00:52:23 2004 @@ -356,7 +356,8 @@ } // a variable can only be killed by subsequent instructions - for (++mi; mi != e; ++mi) { + do { + ++mi; baseIndex += InstrSlots::NUM; for (KillIter ki = lv_->killed_begin(mi), ke = lv_->killed_end(mi); ki != ke; ++ki) { @@ -366,13 +367,10 @@ goto exit; } } - } + } while (mi != e); - // LiveVariables does not compute information for dead basic blocks. - DEBUG(std::cerr << "Didn't find the end of the interval. Must be in a " - "dead block."); - end = getDefIndex(start)+1; exit: + assert(start < end && "did not find end of interval?"); interval.addRange(start, end); DEBUG(std::cerr << '\n'); } From gaeke at cs.uiuc.edu Fri Jul 2 01:00:03 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Fri Jul 2 01:00:03 2004 Subject: [llvm-commits] CVS: llvm/tools/Makefile Message-ID: <200407020559.AAA03186@seraph.cs.uiuc.edu> Changes in directory llvm/tools: Makefile updated: 1.29 -> 1.30 --- Log message: Build llvm-bcanalyzer --- Diffs of the changes: (+1 -1) Index: llvm/tools/Makefile diff -u llvm/tools/Makefile:1.29 llvm/tools/Makefile:1.30 --- llvm/tools/Makefile:1.29 Mon Jun 7 12:53:43 2004 +++ llvm/tools/Makefile Fri Jul 2 00:59:20 2004 @@ -10,7 +10,7 @@ LEVEL := .. PARALLEL_DIRS := llvm-as llvm-dis opt gccas llc llvm-link lli gccld llvm-stub \ analyze extract bugpoint llvm-nm llvm-prof llvm-db llvm-ar \ - llvm-abcd + llvm-bcanalyzer include $(LEVEL)/Makefile.common From llvm at cs.uiuc.edu Fri Jul 2 01:28:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Fri Jul 2 01:28:01 2004 Subject: [llvm-commits] CVS: llvm/docs/OpenProjects.html Message-ID: <200407020627.BAA17820@zion.cs.uiuc.edu> Changes in directory llvm/docs: OpenProjects.html updated: 1.31 -> 1.32 --- Log message: Add a note about implementing interprocedural register allocation. --- Diffs of the changes: (+5 -1) Index: llvm/docs/OpenProjects.html diff -u llvm/docs/OpenProjects.html:1.31 llvm/docs/OpenProjects.html:1.32 --- llvm/docs/OpenProjects.html:1.31 Mon Jun 21 23:24:55 2004 +++ llvm/docs/OpenProjects.html Fri Jul 2 01:27:12 2004 @@ -303,6 +303,10 @@
  • Implement a better instruction selector
  • Implement support for the "switch" instruction without requiring the lower-switches pass.
  • +
  • Implement interprocedural register allocation. The CallGraphSCCPass can be + used to implement a bottom-up analysis that will determine the *actual* + registers clobbered by a function. Use the pass to fine tune register usage + in callers based on *actual* registers used by the callee.
  • @@ -344,7 +348,7 @@ Chris Lattner
    LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/06/22 04:24:55 $ + Last modified: $Date: 2004/07/02 06:27:12 $ From gaeke at cs.uiuc.edu Fri Jul 2 02:02:02 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Fri Jul 2 02:02:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/TargetData.cpp Message-ID: <200407020701.CAA04102@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target: TargetData.cpp updated: 1.47 -> 1.48 --- Log message: Fix use-before-def thinko --- Diffs of the changes: (+1 -1) Index: llvm/lib/Target/TargetData.cpp diff -u llvm/lib/Target/TargetData.cpp:1.47 llvm/lib/Target/TargetData.cpp:1.48 --- llvm/lib/Target/TargetData.cpp:1.47 Thu Jul 1 12:32:59 2004 +++ llvm/lib/Target/TargetData.cpp Fri Jul 2 02:01:31 2004 @@ -169,8 +169,8 @@ return; case Type::ArrayTyID: { const ArrayType *ATy = cast(Ty); - unsigned AlignedSize = (Size + Alignment - 1)/Alignment*Alignment; getTypeInfo(ATy->getElementType(), TD, Size, Alignment); + unsigned AlignedSize = (Size + Alignment - 1)/Alignment*Alignment; Size = AlignedSize*ATy->getNumElements(); return; } From alkis at cs.uiuc.edu Fri Jul 2 05:46:01 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri Jul 2 05:46:01 2004 Subject: [llvm-commits] CVS: llvm-java/include/llvm/Java/Compiler.h Message-ID: <200407021044.FAA20218@zion.cs.uiuc.edu> Changes in directory llvm-java/include/llvm/Java: Compiler.h updated: 1.5 -> 1.6 --- Log message: Don't create a new module for each classfile we compile. Instead pass it to the compiler's compile function and append to it. --- Diffs of the changes: (+1 -1) Index: llvm-java/include/llvm/Java/Compiler.h diff -u llvm-java/include/llvm/Java/Compiler.h:1.5 llvm-java/include/llvm/Java/Compiler.h:1.6 --- llvm-java/include/llvm/Java/Compiler.h:1.5 Mon May 24 20:48:00 2004 +++ llvm-java/include/llvm/Java/Compiler.h Fri Jul 2 05:44:49 2004 @@ -27,7 +27,7 @@ Compiler(); ~Compiler(); - Module* compile(const ClassFile& cf); + void compile(Module& m, const ClassFile& cf); private: // do not implement From alkis at cs.uiuc.edu Fri Jul 2 05:46:16 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri Jul 2 05:46:16 2004 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp Message-ID: <200407021044.FAA20213@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Compiler.cpp updated: 1.46 -> 1.47 --- Log message: Don't create a new module for each classfile we compile. Instead pass it to the compiler's compile function and append to it. --- Diffs of the changes: (+2 -6) Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.46 llvm-java/lib/Compiler/Compiler.cpp:1.47 --- llvm-java/lib/Compiler/Compiler.cpp:1.46 Sat Jun 12 20:06:34 2004 +++ llvm-java/lib/Compiler/Compiler.cpp Fri Jul 2 05:44:49 2004 @@ -712,17 +712,13 @@ delete compilerImpl_; } -Module* Compiler::compile(const ClassFile& cf) +void Compiler::compile(Module& m, const ClassFile& cf) { DEBUG(std::cerr << "compiling class: " << cf.getThisClass()->getName()->str() << '\n'); - Module* module = new Module(cf.getThisClass()->getName()->str()); - const Java::Methods& methods = cf.getMethods(); for (Java::Methods::const_iterator i = methods.begin(), e = methods.end(); i != e; ++i) - compilerImpl_->compileMethod(*module, cf, **i); - - return module; + compilerImpl_->compileMethod(m, cf, **i); } From alkis at cs.uiuc.edu Fri Jul 2 05:46:25 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri Jul 2 05:46:25 2004 Subject: [llvm-commits] CVS: llvm-java/tools/class2llvm/class2llvm.cpp Message-ID: <200407021044.FAA20212@zion.cs.uiuc.edu> Changes in directory llvm-java/tools/class2llvm: class2llvm.cpp updated: 1.5 -> 1.6 --- Log message: Don't create a new module for each classfile we compile. Instead pass it to the compiler's compile function and append to it. --- Diffs of the changes: (+4 -2) Index: llvm-java/tools/class2llvm/class2llvm.cpp diff -u llvm-java/tools/class2llvm/class2llvm.cpp:1.5 llvm-java/tools/class2llvm/class2llvm.cpp:1.6 --- llvm-java/tools/class2llvm/class2llvm.cpp:1.5 Tue Jun 29 14:48:50 2004 +++ llvm-java/tools/class2llvm/class2llvm.cpp Fri Jul 2 05:44:48 2004 @@ -37,15 +37,17 @@ try { std::ifstream in(InputFilename.c_str()); + std::auto_ptr cf(Java::ClassFile::readClassFile(in)); Java::Compiler compiler; - Module* module = compiler.compile(*cf); + Module module(InputFilename); + compiler.compile(module, *cf); PassManager passes; passes.add(new PrintModulePass(&std::cout)); - passes.run(*module); + passes.run(module); } catch (std::exception& e) { std::cerr << e.what() << '\n'; From alkis at cs.uiuc.edu Fri Jul 2 05:50:02 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri Jul 2 05:50:02 2004 Subject: [llvm-commits] CVS: llvm-java/tools/class2llvm/class2llvm.cpp Message-ID: <200407021049.FAA22198@zion.cs.uiuc.edu> Changes in directory llvm-java/tools/class2llvm: class2llvm.cpp updated: 1.6 -> 1.7 --- Log message: Make class2llvm accept a classfile in std::cin as well as a filename. --- Diffs of the changes: (+14 -2) Index: llvm-java/tools/class2llvm/class2llvm.cpp diff -u llvm-java/tools/class2llvm/class2llvm.cpp:1.6 llvm-java/tools/class2llvm/class2llvm.cpp:1.7 --- llvm-java/tools/class2llvm/class2llvm.cpp:1.6 Fri Jul 2 05:44:48 2004 +++ llvm-java/tools/class2llvm/class2llvm.cpp Fri Jul 2 05:49:01 2004 @@ -29,6 +29,18 @@ static cl::opt InputFilename(cl::Positional, cl::desc(""), cl::init("-")); +namespace { + + std::auto_ptr getInputStream(const std::string& fn) { + std::auto_ptr in; + if (fn == "-") in.reset(new std::istream(std::cin.rdbuf())); + else in.reset(new std::ifstream(fn.c_str())); + + return in; + } + +} + int main(int argc, char* argv[]) { PrintStackTraceOnErrorSignal(); @@ -36,9 +48,9 @@ "classfile to llvm utility"); try { - std::ifstream in(InputFilename.c_str()); + std::auto_ptr in(getInputStream(InputFilename)); - std::auto_ptr cf(Java::ClassFile::readClassFile(in)); + std::auto_ptr cf(Java::ClassFile::readClassFile(*in)); Java::Compiler compiler; From brukman at cs.uiuc.edu Fri Jul 2 10:34:06 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Fri Jul 2 10:34:06 2004 Subject: [llvm-commits] CVS: llvm/docs/CommandGuide/llvm-abcd.pod Message-ID: <200407021533.KAA06988@zion.cs.uiuc.edu> Changes in directory llvm/docs/CommandGuide: llvm-abcd.pod (r1.1) removed --- Log message: llvm-abcd has become llvm-bcanalyzer --- Diffs of the changes: (+0 -0) From brukman at cs.uiuc.edu Fri Jul 2 10:37:05 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Fri Jul 2 10:37:05 2004 Subject: [llvm-commits] CVS: llvm/docs/CommandGuide/bugpoint.pod Message-ID: <200407021536.KAA13171@zion.cs.uiuc.edu> Changes in directory llvm/docs/CommandGuide: bugpoint.pod updated: 1.1 -> 1.2 --- Log message: Simplify wording: `the bugpoint tool' can just become `bugpoint'. --- Diffs of the changes: (+7 -7) Index: llvm/docs/CommandGuide/bugpoint.pod diff -u llvm/docs/CommandGuide/bugpoint.pod:1.1 llvm/docs/CommandGuide/bugpoint.pod:1.2 --- llvm/docs/CommandGuide/bugpoint.pod:1.1 Thu Jul 1 15:29:08 2004 +++ llvm/docs/CommandGuide/bugpoint.pod Fri Jul 2 10:36:29 2004 @@ -11,13 +11,13 @@ =head1 DESCRIPTION -The B tool narrows down the source of problems in LLVM tools and passes. -It can be used to debug three types of failures: optimizer crashes, -miscompilations by optimizers, or bad native code generation (including problems -in the static and JIT compilers). It aims to reduce large test cases to small, -useful ones. For example, if B crashes while optimizing a file, it will -identify the optimization (or combination of optimizations) that causes the -crash, and reduce the file down to a small example which triggers the crash. +B narrows down the source of problems in LLVM tools and passes. It +can be used to debug three types of failures: optimizer crashes, miscompilations +by optimizers, or bad native code generation (including problems in the static +and JIT compilers). It aims to reduce large test cases to small, useful ones. +For example, if B crashes while optimizing a file, it will identify the +optimization (or combination of optimizations) that causes the crash, and reduce +the file down to a small example which triggers the crash. =head2 Design Philosophy From brukman at cs.uiuc.edu Fri Jul 2 10:39:07 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Fri Jul 2 10:39:07 2004 Subject: [llvm-commits] CVS: llvm/docs/CommandGuide/llvm-bcanalyzer.pod Message-ID: <200407021538.KAA16277@zion.cs.uiuc.edu> Changes in directory llvm/docs/CommandGuide: llvm-bcanalyzer.pod updated: 1.1 -> 1.2 --- Log message: HTML links in PODs must be absolute. --- Diffs of the changes: (+1 -1) Index: llvm/docs/CommandGuide/llvm-bcanalyzer.pod diff -u llvm/docs/CommandGuide/llvm-bcanalyzer.pod:1.1 llvm/docs/CommandGuide/llvm-bcanalyzer.pod:1.2 --- llvm/docs/CommandGuide/llvm-bcanalyzer.pod:1.1 Thu Jul 1 22:44:14 2004 +++ llvm/docs/CommandGuide/llvm-bcanalyzer.pod Fri Jul 2 10:37:53 2004 @@ -57,7 +57,7 @@ =head1 SEE ALSO -L, L +L, L =head1 AUTHORS From brukman at cs.uiuc.edu Fri Jul 2 10:41:04 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Fri Jul 2 10:41:04 2004 Subject: [llvm-commits] CVS: CVSROOT/update-www.sh Message-ID: <200407021540.KAA16318@zion.cs.uiuc.edu> Changes in directory CVSROOT: update-www.sh updated: 1.3 -> 1.4 --- Log message: Auto-generate HTML documentation from POD source on commit. --- Diffs of the changes: (+4 -0) Index: CVSROOT/update-www.sh diff -u CVSROOT/update-www.sh:1.3 CVSROOT/update-www.sh:1.4 --- CVSROOT/update-www.sh:1.3 Mon Oct 20 15:54:41 2003 +++ CVSROOT/update-www.sh Fri Jul 2 10:40:14 2004 @@ -9,5 +9,9 @@ # Update any committed files cvs -Q update -Pd +# Make the HTML docs from POD source +cd /home/vadve/shared/llvm-wwwroot/docs/CommandGuide +make + # Give access to any of the files we just checked in to the group find . -user $USER -exec chmod g+w {} \; From brukman at cs.uiuc.edu Fri Jul 2 10:43:02 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Fri Jul 2 10:43:02 2004 Subject: [llvm-commits] CVS: llvm/docs/CommandGuide/bugpoint.pod Message-ID: <200407021542.KAA16560@zion.cs.uiuc.edu> Changes in directory llvm/docs/CommandGuide: bugpoint.pod updated: 1.2 -> 1.3 --- Log message: Make `args' stand out as bold, delete confusing elipsis at the end of cmdline. --- Diffs of the changes: (+2 -2) Index: llvm/docs/CommandGuide/bugpoint.pod diff -u llvm/docs/CommandGuide/bugpoint.pod:1.2 llvm/docs/CommandGuide/bugpoint.pod:1.3 --- llvm/docs/CommandGuide/bugpoint.pod:1.2 Fri Jul 2 10:36:29 2004 +++ llvm/docs/CommandGuide/bugpoint.pod Fri Jul 2 10:42:20 2004 @@ -6,8 +6,8 @@ =head1 SYNOPSIS -bugpoint [options] [input LLVM ll/bc files] [LLVM passes] --args -I ... +bugpoint [options] [input LLVM ll/bc files] [LLVM passes] B<--args> +I =head1 DESCRIPTION From brukman at cs.uiuc.edu Fri Jul 2 10:44:01 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Fri Jul 2 10:44:01 2004 Subject: [llvm-commits] CVS: CVSROOT/update-www.sh Message-ID: <200407021543.KAA16581@zion.cs.uiuc.edu> Changes in directory CVSROOT: update-www.sh updated: 1.4 -> 1.5 --- Log message: Make silently, not everyone has the `-s' switch in their alias. :) --- Diffs of the changes: (+1 -1) Index: CVSROOT/update-www.sh diff -u CVSROOT/update-www.sh:1.4 CVSROOT/update-www.sh:1.5 --- CVSROOT/update-www.sh:1.4 Fri Jul 2 10:40:14 2004 +++ CVSROOT/update-www.sh Fri Jul 2 10:43:24 2004 @@ -11,7 +11,7 @@ # Make the HTML docs from POD source cd /home/vadve/shared/llvm-wwwroot/docs/CommandGuide -make +make -s # Give access to any of the files we just checked in to the group find . -user $USER -exec chmod g+w {} \; From brukman at cs.uiuc.edu Fri Jul 2 10:48:07 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Fri Jul 2 10:48:07 2004 Subject: [llvm-commits] CVS: llvm/docs/CommandGuide/index.html Message-ID: <200407021547.KAA16717@zion.cs.uiuc.edu> Changes in directory llvm/docs/CommandGuide: index.html updated: 1.15 -> 1.16 --- Log message: * Link to the POD-generated HTML documentation * Updated llvm-abcd to llvm-bcanalyzer --- Diffs of the changes: (+17 -17) Index: llvm/docs/CommandGuide/index.html diff -u llvm/docs/CommandGuide/index.html:1.15 llvm/docs/CommandGuide/index.html:1.16 --- llvm/docs/CommandGuide/index.html:1.15 Thu Jul 1 13:25:59 2004 +++ llvm/docs/CommandGuide/index.html Fri Jul 2 10:46:55 2004 @@ -36,31 +36,31 @@
      -
    • llvm-as - +
    • llvm-as - assemble a human-readable program into bytecode
    • -
    • llvm-dis - +
    • llvm-dis - disassemble a bytecode file into human-readable form
    • -
    • analyze - +
    • analyze - analyze a program compiled to bytecode
    • -
    • opt - +
    • opt - optimize a bytecode file
    • -
    • llc - +
    • llc - compile a bytecode program into native machine code
    • -
    • lli - +
    • lli - run a bytecode program using either an interpreter or a JIT compiler
    • -
    • llvm-link +
    • llvm-link link several bytecode files into one
    • -
    • llvm-nm +
    • llvm-nm print out the names and types of symbols in a bytecode file
    • -
    • llvm-prof - +
    • llvm-prof - transform raw `llvmprof.out' data into a human-readable report
    @@ -77,16 +77,16 @@
      -
    • llvmgcc - +
    • llvmgcc - GCC-based C front end for LLVM -
    • llvmg++ - +
    • llvmg++ - GCC-based C++ front end for LLVM
    • -
    • gccas - +
    • gccas - optimizing assembler used by llvm-g++ and llvm-gcc
    • -
    • gccld - +
    • gccld - optimizing linker used by llvm-g++ and llvm-gcc
    @@ -104,13 +104,13 @@
      -
    • bugpoint - +
    • bugpoint - automatic test-case reducer
    • -
    • extract - +
    • extract - extract a function from an LLVM bytecode file
    • -
    • llvm-abcd - +
    • llvm-bcanalyzer - bytecode analyzer (analyzes the binary encoding itself, not the program it represents)
    • @@ -128,7 +128,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!"> LLVM Compiler Infrastructure
      - Last modified: $Date: 2004/07/01 18:25:59 $ + Last modified: $Date: 2004/07/02 15:46:55 $ From brukman at cs.uiuc.edu Fri Jul 2 10:50:01 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Fri Jul 2 10:50:01 2004 Subject: [llvm-commits] CVS: llvm/docs/CommandGuide/analyze.html bugpoint.html extract.html gccas.html gccld.html llc.html lli.html llvm-as.html llvm-db.html llvm-dis.html llvm-link.html llvm-nm.html llvm-prof.html llvmgcc.html llvmgxx.html opt.html Message-ID: <200407021548.KAA16845@zion.cs.uiuc.edu> Changes in directory llvm/docs/CommandGuide: analyze.html (r1.11) removed bugpoint.html (r1.30) removed extract.html (r1.7) removed gccas.html (r1.8) removed gccld.html (r1.11) removed llc.html (r1.14) removed lli.html (r1.9) removed llvm-as.html (r1.6) removed llvm-db.html (r1.2) removed llvm-dis.html (r1.7) removed llvm-link.html (r1.6) removed llvm-nm.html (r1.3) removed llvm-prof.html (r1.5) removed llvmgcc.html (r1.4) removed llvmgxx.html (r1.5) removed opt.html (r1.12) removed --- Log message: The HTML documentation is now automatically generated from POD source. --- Diffs of the changes: (+0 -0) From brukman at cs.uiuc.edu Fri Jul 2 11:09:06 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Fri Jul 2 11:09:06 2004 Subject: [llvm-commits] CVS: llvm/docs/CommandGuide/analyze.pod bugpoint.pod extract.pod gccas.pod gccld.pod llc.pod lli.pod llvm-as.pod llvm-bcanalyzer.pod llvm-db.pod llvm-dis.pod llvm-link.pod llvm-nm.pod llvm-prof.pod llvmgcc.pod llvmgxx.pod opt.pod Message-ID: <200407021606.LAA17499@zion.cs.uiuc.edu> Changes in directory llvm/docs/CommandGuide: analyze.pod updated: 1.1 -> 1.2 bugpoint.pod updated: 1.3 -> 1.4 extract.pod updated: 1.1 -> 1.2 gccas.pod updated: 1.3 -> 1.4 gccld.pod updated: 1.1 -> 1.2 llc.pod updated: 1.1 -> 1.2 lli.pod updated: 1.1 -> 1.2 llvm-as.pod updated: 1.1 -> 1.2 llvm-bcanalyzer.pod updated: 1.2 -> 1.3 llvm-db.pod updated: 1.2 -> 1.3 llvm-dis.pod updated: 1.1 -> 1.2 llvm-link.pod updated: 1.1 -> 1.2 llvm-nm.pod updated: 1.1 -> 1.2 llvm-prof.pod updated: 1.2 -> 1.3 llvmgcc.pod updated: 1.2 -> 1.3 llvmgxx.pod updated: 1.1 -> 1.2 opt.pod updated: 1.1 -> 1.2 --- Log message: * Standardize manpage output: program name bold, options italic/emphasized * Make links in SEE ALSO section of manpages short without "the ... manpage" --- Diffs of the changes: (+36 -58) Index: llvm/docs/CommandGuide/analyze.pod diff -u llvm/docs/CommandGuide/analyze.pod:1.1 llvm/docs/CommandGuide/analyze.pod:1.2 --- llvm/docs/CommandGuide/analyze.pod:1.1 Thu Jul 1 10:25:04 2004 +++ llvm/docs/CommandGuide/analyze.pod Fri Jul 2 11:06:19 2004 @@ -1,4 +1,3 @@ - =pod =head1 NAME @@ -7,7 +6,7 @@ =head1 SYNOPSIS -analyze [options] [filename] +B [I] [I] =head1 DESCRIPTION @@ -67,12 +66,10 @@ =head1 SEE ALSO -L +L =head1 AUTHORS Maintained by the LLVM Team (L). =cut - - Index: llvm/docs/CommandGuide/bugpoint.pod diff -u llvm/docs/CommandGuide/bugpoint.pod:1.3 llvm/docs/CommandGuide/bugpoint.pod:1.4 --- llvm/docs/CommandGuide/bugpoint.pod:1.3 Fri Jul 2 10:42:20 2004 +++ llvm/docs/CommandGuide/bugpoint.pod Fri Jul 2 11:06:19 2004 @@ -6,7 +6,7 @@ =head1 SYNOPSIS -bugpoint [options] [input LLVM ll/bc files] [LLVM passes] B<--args> +B [I] [I] [I] B<--args> I =head1 DESCRIPTION @@ -240,11 +240,10 @@ =head1 SEE ALSO -L, L +L, L =head1 AUTHOR Maintained by the LLVM Team (L). =cut - Index: llvm/docs/CommandGuide/extract.pod diff -u llvm/docs/CommandGuide/extract.pod:1.1 llvm/docs/CommandGuide/extract.pod:1.2 --- llvm/docs/CommandGuide/extract.pod:1.1 Wed Jun 2 14:21:26 2004 +++ llvm/docs/CommandGuide/extract.pod Fri Jul 2 11:06:19 2004 @@ -1,4 +1,3 @@ - =pod =head1 NAME @@ -7,7 +6,7 @@ =head1 SYNOPSIS -extract [options] --func function-name [filename] +B [I] B<--func> I [I] =head1 DESCRIPTION @@ -64,11 +63,10 @@ =head1 SEE ALSO -L +L =head1 AUTHORS Maintained by the LLVM Team (L). =cut - Index: llvm/docs/CommandGuide/gccas.pod diff -u llvm/docs/CommandGuide/gccas.pod:1.3 llvm/docs/CommandGuide/gccas.pod:1.4 --- llvm/docs/CommandGuide/gccas.pod:1.3 Thu Jul 1 12:59:53 2004 +++ llvm/docs/CommandGuide/gccas.pod Fri Jul 2 11:06:19 2004 @@ -1,4 +1,3 @@ - =pod =head1 NAME @@ -7,7 +6,7 @@ =head1 SYNOPSIS -gccas [options] filename +B [I] I =head1 DESCRIPTION @@ -68,11 +67,10 @@ =head1 SEE ALSO -L, L +L, L =head1 AUTHORS Maintained by the LLVM Team (L). =cut - Index: llvm/docs/CommandGuide/gccld.pod diff -u llvm/docs/CommandGuide/gccld.pod:1.1 llvm/docs/CommandGuide/gccld.pod:1.2 --- llvm/docs/CommandGuide/gccld.pod:1.1 Thu Jul 1 12:53:27 2004 +++ llvm/docs/CommandGuide/gccld.pod Fri Jul 2 11:06:19 2004 @@ -1,4 +1,3 @@ - =pod =head1 NAME @@ -7,7 +6,7 @@ =head1 SYNOPSIS -gccld [options] file1 [file2 ...] +B [I] I =head1 DESCRIPTION @@ -167,11 +166,10 @@ =head1 SEE ALSO -L, L +L, L =head1 AUTHORS Maintained by the LLVM Team (L). =cut - Index: llvm/docs/CommandGuide/llc.pod diff -u llvm/docs/CommandGuide/llc.pod:1.1 llvm/docs/CommandGuide/llc.pod:1.2 --- llvm/docs/CommandGuide/llc.pod:1.1 Fri May 14 14:50:33 2004 +++ llvm/docs/CommandGuide/llc.pod Fri Jul 2 11:06:19 2004 @@ -1,4 +1,3 @@ - =pod =head1 NAME @@ -7,7 +6,7 @@ =head1 SYNOPSIS -llc [options] [filename] +B [I] [I] =head1 DESCRIPTION @@ -194,11 +193,10 @@ =head1 SEE ALSO -L +L =head1 AUTHORS Maintained by the LLVM Team (L). =cut - Index: llvm/docs/CommandGuide/lli.pod diff -u llvm/docs/CommandGuide/lli.pod:1.1 llvm/docs/CommandGuide/lli.pod:1.2 --- llvm/docs/CommandGuide/lli.pod:1.1 Fri May 14 14:50:33 2004 +++ llvm/docs/CommandGuide/lli.pod Fri Jul 2 11:06:19 2004 @@ -6,15 +6,15 @@ =head1 SYNOPSIS -lli [options] [filename] [args ...] +B [I] [I] [I] =head1 DESCRIPTION -B directly executes programs in LLVM bytecode format. It takes a program in -LLVM bytecode format and executes it using a just-in-time compiler, if one is -available for the current architecture, or an interpreter. B takes -all of the same code generator options as L, but they are only effective -when B is using the just-in-time compiler. +B directly executes programs in LLVM bytecode format. It takes a program +in LLVM bytecode format and executes it using a just-in-time compiler, if one is +available for the current architecture, or an interpreter. B takes all of +the same code generator options as L, but they are only effective when +B is using the just-in-time compiler. If I is not specified, then B reads the LLVM bytecode for the program from standard input. @@ -67,7 +67,7 @@ =head1 SEE ALSO -L +L =head1 AUTHOR Index: llvm/docs/CommandGuide/llvm-as.pod diff -u llvm/docs/CommandGuide/llvm-as.pod:1.1 llvm/docs/CommandGuide/llvm-as.pod:1.2 --- llvm/docs/CommandGuide/llvm-as.pod:1.1 Wed Jun 2 15:29:49 2004 +++ llvm/docs/CommandGuide/llvm-as.pod Fri Jul 2 11:06:19 2004 @@ -6,7 +6,7 @@ =head1 SYNOPSIS -llvm-as [options] [filename] +B [I] [I] =head1 DESCRIPTION @@ -77,11 +77,10 @@ =head1 SEE ALSO -L, L +L, L =head1 AUTHORS Maintained by the LLVM Team (L). =cut - Index: llvm/docs/CommandGuide/llvm-bcanalyzer.pod diff -u llvm/docs/CommandGuide/llvm-bcanalyzer.pod:1.2 llvm/docs/CommandGuide/llvm-bcanalyzer.pod:1.3 --- llvm/docs/CommandGuide/llvm-bcanalyzer.pod:1.2 Fri Jul 2 10:37:53 2004 +++ llvm/docs/CommandGuide/llvm-bcanalyzer.pod Fri Jul 2 11:06:19 2004 @@ -6,7 +6,7 @@ =head1 SYNOPSIS -llvm-bcanalyzer [options] [filename] +B [I] [I] =head1 DESCRIPTION @@ -57,7 +57,7 @@ =head1 SEE ALSO -L, L +L, L =head1 AUTHORS Index: llvm/docs/CommandGuide/llvm-db.pod diff -u llvm/docs/CommandGuide/llvm-db.pod:1.2 llvm/docs/CommandGuide/llvm-db.pod:1.3 --- llvm/docs/CommandGuide/llvm-db.pod:1.2 Thu Jul 1 13:34:46 2004 +++ llvm/docs/CommandGuide/llvm-db.pod Fri Jul 2 11:06:19 2004 @@ -1,4 +1,3 @@ - =pod =head1 NAME @@ -15,4 +14,3 @@ Maintained by the LLVM Team (L). =cut - Index: llvm/docs/CommandGuide/llvm-dis.pod diff -u llvm/docs/CommandGuide/llvm-dis.pod:1.1 llvm/docs/CommandGuide/llvm-dis.pod:1.2 --- llvm/docs/CommandGuide/llvm-dis.pod:1.1 Wed Jun 2 15:45:25 2004 +++ llvm/docs/CommandGuide/llvm-dis.pod Fri Jul 2 11:06:19 2004 @@ -6,7 +6,7 @@ =head1 SYNOPSIS -llvm-dis [options] [filename] +B [I] [I] =head1 DESCRIPTION @@ -56,11 +56,10 @@ =head1 SEE ALSO -L +L =head1 AUTHORS Maintained by the LLVM Team (L). =cut - Index: llvm/docs/CommandGuide/llvm-link.pod diff -u llvm/docs/CommandGuide/llvm-link.pod:1.1 llvm/docs/CommandGuide/llvm-link.pod:1.2 --- llvm/docs/CommandGuide/llvm-link.pod:1.1 Wed Jun 2 15:55:52 2004 +++ llvm/docs/CommandGuide/llvm-link.pod Fri Jul 2 11:06:19 2004 @@ -6,7 +6,7 @@ =head1 SYNOPSIS -llvm-link [options] filename [...] +B [I] I =head1 DESCRIPTION Index: llvm/docs/CommandGuide/llvm-nm.pod diff -u llvm/docs/CommandGuide/llvm-nm.pod:1.1 llvm/docs/CommandGuide/llvm-nm.pod:1.2 --- llvm/docs/CommandGuide/llvm-nm.pod:1.1 Thu Jul 1 14:40:36 2004 +++ llvm/docs/CommandGuide/llvm-nm.pod Fri Jul 2 11:06:19 2004 @@ -6,7 +6,7 @@ =head1 SYNOPSIS -llvm-nm [options] [filenames...] +B [I] [I] =head1 DESCRIPTION @@ -113,11 +113,10 @@ =head1 SEE ALSO -L, L, L +L, L, L =head1 AUTHOR Maintained by the LLVM Team (L). =cut - Index: llvm/docs/CommandGuide/llvm-prof.pod diff -u llvm/docs/CommandGuide/llvm-prof.pod:1.2 llvm/docs/CommandGuide/llvm-prof.pod:1.3 --- llvm/docs/CommandGuide/llvm-prof.pod:1.2 Fri May 14 13:31:13 2004 +++ llvm/docs/CommandGuide/llvm-prof.pod Fri Jul 2 11:06:19 2004 @@ -6,7 +6,7 @@ =head1 SYNOPSIS -llvm-prof [options] [bytecode file] [llvmprof.out] +B [I] [I] [I] =head1 DESCRIPTION @@ -47,12 +47,11 @@ =head1 EXIT STATUS -B returns 1 if it cannot load the bytecode file or the profile -information. Otherwise, it exits with zero. +B returns 1 if it cannot load the bytecode file or the +profile information. Otherwise, it exits with zero. =head1 AUTHOR B is maintained by the LLVM Team (L). =cut - Index: llvm/docs/CommandGuide/llvmgcc.pod diff -u llvm/docs/CommandGuide/llvmgcc.pod:1.2 llvm/docs/CommandGuide/llvmgcc.pod:1.3 --- llvm/docs/CommandGuide/llvmgcc.pod:1.2 Thu Jul 1 12:52:58 2004 +++ llvm/docs/CommandGuide/llvmgcc.pod Fri Jul 2 11:06:19 2004 @@ -1,4 +1,3 @@ - =pod =head1 NAME @@ -7,7 +6,7 @@ =head1 SYNOPSIS -llvmgcc [options] filename +B [I] I =head1 DESCRIPTION @@ -78,7 +77,7 @@ =head1 SEE ALSO -L, L, L +L, L, L =head1 AUTHORS Index: llvm/docs/CommandGuide/llvmgxx.pod diff -u llvm/docs/CommandGuide/llvmgxx.pod:1.1 llvm/docs/CommandGuide/llvmgxx.pod:1.2 --- llvm/docs/CommandGuide/llvmgxx.pod:1.1 Thu Jul 1 09:51:26 2004 +++ llvm/docs/CommandGuide/llvmgxx.pod Fri Jul 2 11:06:19 2004 @@ -1,4 +1,3 @@ - =pod =head1 NAME @@ -7,7 +6,7 @@ =head1 SYNOPSIS -llvmg++ [options] filename +B [I] I =head1 DESCRIPTION Index: llvm/docs/CommandGuide/opt.pod diff -u llvm/docs/CommandGuide/opt.pod:1.1 llvm/docs/CommandGuide/opt.pod:1.2 --- llvm/docs/CommandGuide/opt.pod:1.1 Thu Jul 1 10:25:04 2004 +++ llvm/docs/CommandGuide/opt.pod Fri Jul 2 11:06:19 2004 @@ -1,4 +1,3 @@ - =pod =head1 NAME @@ -7,7 +6,7 @@ =head1 SYNOPSIS -opt [options] [filename] +B [I] [I] =head1 DESCRIPTION @@ -89,11 +88,10 @@ =head1 SEE ALSO -L +L =head1 AUTHORS Maintained by the LLVM Team (L). =cut - From brukman at cs.uiuc.edu Fri Jul 2 11:24:05 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Fri Jul 2 11:24:05 2004 Subject: [llvm-commits] CVS: llvm/docs/ReleaseNotes.html Message-ID: <200407021623.LAA17739@zion.cs.uiuc.edu> Changes in directory llvm/docs: ReleaseNotes.html updated: 1.209 -> 1.210 --- Log message: * Wrap long lines * Mention the HTML/man page output from single POD source file --- Diffs of the changes: (+20 -18) Index: llvm/docs/ReleaseNotes.html diff -u llvm/docs/ReleaseNotes.html:1.209 llvm/docs/ReleaseNotes.html:1.210 --- llvm/docs/ReleaseNotes.html:1.209 Tue Jun 29 18:39:24 2004 +++ llvm/docs/ReleaseNotes.html Fri Jul 2 11:23:17 2004 @@ -105,9 +105,9 @@
    • LLVM now has new loop unrolling and loop unswitching passes.
    • The induction variable substitution pass performs linear function test replacement and exit value replacement optimizations.
    • -
    • LLVM now has first-class support for Accurate -Garbage Collection, enabling the use of aggressive copying and generational -collectors.
    • +
    • LLVM now has first-class support for Accurate Garbage Collection, enabling the use +of aggressive copying and generational collectors.
    • LLVM now includes an implementation of Andersen's interprocedural alias analysis algorithm.
    • Bugpoint can extract individual @@ -115,19 +115,19 @@
    • LLVM and the C front-end now work under Win32 using the Cygwin runtime libraries. This includes the JIT compiler.
    • -
    • The LLVM code generator is now being documented.
    • -
    • There is a new tool, llvm-abcd, the Analysis of ByteCode Dumper (abcd). -This tool can compute basic statistics and bytecode density statistics on a -module or function basis and also dump out bytecode in a textual format that -is lower level than assembly (values are not resolved from slot numbers). -It should only be of interest to (a) those who are working to improve the -bytecode format and (b) those who really want to understand or document the -details of the bytecode format.
    • -
    • The LLVM Bytecode file format is now - being documented.
    • -
    • LLVM now provides an llvm.isunordered intrinsic -for efficient implementation of unordered floating point comparisons.
    • +
    • The LLVM code generator is now being documented.
    • +
    • There is a new tool, llvm-bcanalyzer. This tool can compute basic +statistics and bytecode density statistics on a module or function basis and +also dump out bytecode in a textual format that is lower level than assembly +(values are not resolved from slot numbers). It should only be of interest to +(a) those who are working to improve the bytecode format and (b) those who +really want to understand or document the details of the bytecode format.
    • +
    • The LLVM Bytecode file format is now being +documented.
    • +
    • LLVM now provides an llvm.isunordered intrinsic for efficient +implementation of unordered floating point comparisons.
    • The llvmgcc front-end now supports the GCC builtins for ISO C99 floating point comparison macros (e.g., __builtin_islessequal).
    • Now that there are more source files than can fit on a 32Kbyte command @@ -136,6 +136,8 @@ passing filenames through the command line. This improves performance slightly. Simply run llvmgrep like you might egrep but leave off the file names.
    • +
    • We now generate HTML documentation and man pages for the tools from a single +source (perl-style POD files).
    • @@ -297,7 +299,7 @@ prototypes that take opaque structs by-value
    • [llvmgcc] Crash compiling variable length array of structures
    • -
    • [llvmgcc] miscompilation of staticly +
    • [llvmgcc] miscompilation of staticly initialized unsigned bitfields
    • @@ -745,7 +747,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
      - Last modified: $Date: 2004/06/29 23:39:24 $ + Last modified: $Date: 2004/07/02 16:23:17 $ From lattner at cs.uiuc.edu Fri Jul 2 13:42:04 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Jul 2 13:42:04 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/GlobalVariable.h Message-ID: <200407021841.NAA25073@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: GlobalVariable.h updated: 1.26 -> 1.27 --- Log message: Since we are in the department of redundancy department, at least be correct --- Diffs of the changes: (+1 -1) Index: llvm/include/llvm/GlobalVariable.h diff -u llvm/include/llvm/GlobalVariable.h:1.26 llvm/include/llvm/GlobalVariable.h:1.27 --- llvm/include/llvm/GlobalVariable.h:1.26 Sun Nov 16 14:21:15 2003 +++ llvm/include/llvm/GlobalVariable.h Fri Jul 2 13:41:18 2004 @@ -1,4 +1,4 @@ -//===-- llvm/Global.h - Class to represent a global variable ----*- C++ -*-===// +//===-- llvm/GlobalVariable.h - GlobalVariable class ------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // From gaeke at cs.uiuc.edu Fri Jul 2 20:18:39 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Fri Jul 2 20:18:39 2004 Subject: [llvm-commits] CVS: llvm/docs/LangRef.html Message-ID: <200407022108.QAA17128@zion.cs.uiuc.edu> Changes in directory llvm/docs: LangRef.html updated: 1.70 -> 1.71 --- Log message: Modernize example, so that you can paste it right into llvm-as --- Diffs of the changes: (+6 -3) Index: llvm/docs/LangRef.html diff -u llvm/docs/LangRef.html:1.70 llvm/docs/LangRef.html:1.71 --- llvm/docs/LangRef.html:1.70 Fri Jun 25 11:42:50 2004 +++ llvm/docs/LangRef.html Fri Jul 2 16:08:14 2004 @@ -1511,8 +1511,11 @@ %RT = type { sbyte, [10 x [20 x int]], sbyte } %ST = type { int, double, %RT } - int* "foo"(%ST* %s) { - %reg = getelementptr %ST* %s, int 1, uint 2, uint 1, int 5, int 13
      + implementation + + int* %foo(%ST* %s) { + entry: + %reg = getelementptr %ST* %s, int 1, uint 2, uint 1, int 5, int 13 ret int* %reg } @@ -2590,7 +2593,7 @@ Chris Lattner
      The LLVM Compiler Infrastructure
      - Last modified: $Date: 2004/06/25 16:42:50 $ + Last modified: $Date: 2004/07/02 21:08:14 $ From lattner at cs.uiuc.edu Fri Jul 2 20:19:15 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Jul 2 20:19:15 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp Message-ID: <200407022255.RAA18015@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: InstructionCombining.cpp updated: 1.215 -> 1.216 --- Log message: Do not call getTypeSize on a type that has no size --- Diffs of the changes: (+2 -1) Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.215 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.216 --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.215 Sun Jun 27 17:51:36 2004 +++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Fri Jul 2 17:55:47 2004 @@ -2854,7 +2854,8 @@ // If alloca'ing a zero byte object, replace the alloca with a null pointer. // Note that we only do this for alloca's, because malloc should allocate and // return a unique pointer, even for a zero byte allocation. - if (isa(AI) && TD->getTypeSize(AI.getAllocatedType()) == 0) + if (isa(AI) && AI.getAllocatedType()->isSized() && + TD->getTypeSize(AI.getAllocatedType()) == 0) return ReplaceInstUsesWith(AI, Constant::getNullValue(AI.getType())); return 0; From lattner at cs.uiuc.edu Fri Jul 2 20:19:28 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Jul 2 20:19:28 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Type.h Message-ID: <200407022320.SAA18180@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: Type.h updated: 1.45 -> 1.46 --- Log message: Fix Type::isSized() to realize that "{ opaque }" is not sized --- Diffs of the changes: (+7 -2) Index: llvm/include/llvm/Type.h diff -u llvm/include/llvm/Type.h:1.45 llvm/include/llvm/Type.h:1.46 --- llvm/include/llvm/Type.h:1.45 Thu Jun 17 13:15:25 2004 +++ llvm/include/llvm/Type.h Fri Jul 2 18:19:50 2004 @@ -206,8 +206,8 @@ /// TargetData subsystem to do this. /// bool isSized() const { - return ID != VoidTyID && ID != TypeTyID && - ID != FunctionTyID && ID != LabelTyID && ID != OpaqueTyID; + return (ID >= BoolTyID && ID <= DoubleTyID) || ID == PointerTyID || + isSizedDerivedType(); } /// getPrimitiveSize - Return the basic size of this type if it is a primative @@ -306,6 +306,11 @@ RefCountIsZero(); } private: + /// isSizedDerivedType - Derived types like structures and arrays are sized + /// iff all of the members of the type are sized as well. Since asking for + /// their size is relatively uncommon, move this operation out of line. + bool isSizedDerivedType() const; + virtual void RefCountIsZero() const { abort(); // only on derived types! } From lattner at cs.uiuc.edu Fri Jul 2 20:19:35 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Jul 2 20:19:35 2004 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Type.cpp Message-ID: <200407022320.SAA18231@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Type.cpp updated: 1.102 -> 1.103 --- Log message: Fix Type::isSized() to realize that "{ opaque }" is not sized --- Diffs of the changes: (+15 -0) Index: llvm/lib/VMCore/Type.cpp diff -u llvm/lib/VMCore/Type.cpp:1.102 llvm/lib/VMCore/Type.cpp:1.103 --- llvm/lib/VMCore/Type.cpp:1.102 Thu Jun 17 13:18:53 2004 +++ llvm/lib/VMCore/Type.cpp Fri Jul 2 18:20:17 2004 @@ -159,6 +159,21 @@ } } +/// isSizedDerivedType - Derived types like structures and arrays are sized +/// iff all of the members of the type are sized as well. Since asking for +/// their size is relatively uncommon, move this operation out of line. +bool Type::isSizedDerivedType() const { + if (const ArrayType *ATy = dyn_cast(this)) + return ATy->getElementType()->isSized(); + + if (!isa(this)) return false; + + // Okay, our struct is sized if all of the elements are... + for (subtype_iterator I = subtype_begin(), E = subtype_end(); I != E; ++I) + if (!(*I)->isSized()) return false; + + return true; +} /// getForwardedTypeInternal - This method is used to implement the union-find /// algorithm for when a type is being forwarded to another type. From lattner at cs.uiuc.edu Fri Jul 2 20:20:00 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Jul 2 20:20:00 2004 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/InstCombine/add.ll Message-ID: <200407030025.TAA27924@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/InstCombine: add.ll updated: 1.20 -> 1.21 --- Log message: Add a new testcase for folding an add into a switch --- Diffs of the changes: (+14 -0) Index: llvm/test/Regression/Transforms/InstCombine/add.ll diff -u llvm/test/Regression/Transforms/InstCombine/add.ll:1.20 llvm/test/Regression/Transforms/InstCombine/add.ll:1.21 --- llvm/test/Regression/Transforms/InstCombine/add.ll:1.20 Sun Jun 27 17:51:19 2004 +++ llvm/test/Regression/Transforms/InstCombine/add.ll Fri Jul 2 19:25:31 2004 @@ -135,3 +135,17 @@ %y = seteq uint %t, 123 ret bool %y } + +int %test22(uint %V) { + %V2 = add uint %V, 10 + switch uint %V2, label %Default [ + uint 20, label %Lab1 + uint 30, label %Lab2 + ] +Default: + ret int 123 +Lab1: + ret int 12312 +Lab2: + ret int 1231231 +} From lattner at cs.uiuc.edu Fri Jul 2 20:20:08 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Jul 2 20:20:08 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp Message-ID: <200407030026.TAA27936@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: InstructionCombining.cpp updated: 1.216 -> 1.217 --- Log message: Implement add.ll:test22, a common case in MSIL files --- Diffs of the changes: (+18 -0) Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.216 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.217 --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.216 Fri Jul 2 17:55:47 2004 +++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Fri Jul 2 19:26:11 2004 @@ -122,6 +122,7 @@ Instruction *visitFreeInst(FreeInst &FI); Instruction *visitLoadInst(LoadInst &LI); Instruction *visitBranchInst(BranchInst &BI); + Instruction *visitSwitchInst(SwitchInst &SI); // visitInstruction - Specify what to return for unhandled instructions... Instruction *visitInstruction(Instruction &I) { return 0; } @@ -3004,6 +3005,23 @@ return 0; } +Instruction *InstCombiner::visitSwitchInst(SwitchInst &SI) { + Value *Cond = SI.getCondition(); + if (Instruction *I = dyn_cast(Cond)) { + if (I->getOpcode() == Instruction::Add) + if (ConstantInt *AddRHS = dyn_cast(I->getOperand(1))) { + // change 'switch (X+4) case 1:' into 'switch (X) case -3' + for (unsigned i = 2, e = SI.getNumOperands(); i != e; i += 2) + SI.setOperand(i, ConstantExpr::getSub(cast(SI.getOperand(i)), + AddRHS)); + SI.setOperand(0, I->getOperand(0)); + WorkList.push_back(I); + return &SI; + } + } + return 0; +} + void InstCombiner::removeFromWorkList(Instruction *I) { WorkList.erase(std::remove(WorkList.begin(), WorkList.end(), I), From lattner at cs.uiuc.edu Fri Jul 2 20:23:03 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Jul 2 20:23:03 2004 Subject: [llvm-commits] CVS: llvm/lib/Support/CommandLine.cpp Message-ID: <200407030121.UAA28124@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Support: CommandLine.cpp updated: 1.44 -> 1.45 --- Log message: Fix compilation on internix --- Diffs of the changes: (+1 -0) Index: llvm/lib/Support/CommandLine.cpp diff -u llvm/lib/Support/CommandLine.cpp:1.44 llvm/lib/Support/CommandLine.cpp:1.45 --- llvm/lib/Support/CommandLine.cpp:1.44 Thu May 6 17:04:31 2004 +++ llvm/lib/Support/CommandLine.cpp Fri Jul 2 20:21:05 2004 @@ -23,6 +23,7 @@ #include #include #include +#include using namespace llvm; using namespace cl; From alkis at cs.uiuc.edu Sat Jul 3 20:32:01 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat Jul 3 20:32:01 2004 Subject: [llvm-commits] CVS: llvm/include/Support/Statistic.h Message-ID: <200407040131.UAA27129@zion.cs.uiuc.edu> Changes in directory llvm/include/Support: Statistic.h updated: 1.11 -> 1.12 --- Log message: Add more operators. --- Diffs of the changes: (+2 -0) Index: llvm/include/Support/Statistic.h diff -u llvm/include/Support/Statistic.h:1.11 llvm/include/Support/Statistic.h:1.12 --- llvm/include/Support/Statistic.h:1.11 Fri Apr 16 11:28:33 2004 +++ llvm/include/Support/Statistic.h Sat Jul 3 20:30:54 2004 @@ -80,6 +80,8 @@ DataType operator--(int) { return Value--; } const Statistic &operator+=(const DataType &V) { Value += V; return *this; } const Statistic &operator-=(const DataType &V) { Value -= V; return *this; } + const Statistic &operator*=(const DataType &V) { Value *= V; return *this; } + const Statistic &operator/=(const DataType &V) { Value /= V; return *this; } }; } // End llvm namespace From alkis at cs.uiuc.edu Sun Jul 4 03:00:01 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sun Jul 4 03:00:01 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/RegAllocLinearScan.cpp Message-ID: <200407040759.CAA28332@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: RegAllocLinearScan.cpp updated: 1.75 -> 1.76 --- Log message: Add efficiency statistic. --- Diffs of the changes: (+7 -1) Index: llvm/lib/CodeGen/RegAllocLinearScan.cpp diff -u llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.75 llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.76 --- llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.75 Mon Jun 21 08:10:56 2004 +++ llvm/lib/CodeGen/RegAllocLinearScan.cpp Sun Jul 4 02:59:06 2004 @@ -21,6 +21,7 @@ #include "llvm/Target/MRegisterInfo.h" #include "llvm/Target/TargetMachine.h" #include "Support/Debug.h" +#include "Support/Statistic.h" #include "Support/STLExtras.h" #include "LiveIntervals.h" #include "PhysRegTracker.h" @@ -33,6 +34,10 @@ using namespace llvm; namespace { + + Statistic efficiency + ("regalloc", "Ratio of intervals processed over total intervals"); + class RA : public MachineFunctionPass { private: MachineFunction* mf_; @@ -178,7 +183,7 @@ // pick the interval with the earliest start point IntervalPtrs::value_type cur = unhandled_.front(); unhandled_.pop_front(); - + ++efficiency; DEBUG(std::cerr << "\n*** CURRENT ***: " << *cur << '\n'); processActiveIntervals(cur); @@ -201,6 +206,7 @@ DEBUG(printIntervals("inactive", inactive_.begin(), inactive_.end())); // DEBUG(verifyAssignment()); } + efficiency /= li_->getIntervals().size(); // expire any remaining active intervals for (IntervalPtrs::iterator i = active_.begin(); i != active_.end(); ++i) { From alkis at cs.uiuc.edu Sun Jul 4 03:00:13 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sun Jul 4 03:00:13 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/TEST.llc.report Message-ID: <200407040759.CAA28351@zion.cs.uiuc.edu> Changes in directory llvm/test/Programs: TEST.llc.report updated: 1.11 -> 1.12 --- Log message: Use efficiency statistic. --- Diffs of the changes: (+1 -0) Index: llvm/test/Programs/TEST.llc.report diff -u llvm/test/Programs/TEST.llc.report:1.11 llvm/test/Programs/TEST.llc.report:1.12 --- llvm/test/Programs/TEST.llc.report:1.11 Tue Mar 30 16:34:02 2004 +++ llvm/test/Programs/TEST.llc.report Sun Jul 4 02:59:42 2004 @@ -27,6 +27,7 @@ ["#MCInsts", '([0-9]+).*Number of machine instrs printed'], ["#IntOrig", '([0-9]+).*Number of original intervals'], ["#IntCoal", '([0-9]+).*Number of intervals after coalescing'], + ["Eff ", '([0-9]+).*Ratio of intervals processed over total intervals'], [], # Number of transformations ["#store" , '([0-9]+).*Number of stores added'], From llvm at cs.uiuc.edu Sun Jul 4 05:48:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 05:48:01 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Type.h Message-ID: <200407041047.FAA32081@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: Type.h updated: 1.46 -> 1.47 --- Log message: Make Type have no base classes. Previously it inherited Value. Also removed the TypeTyID and TypeTy members so that the notion of the "Type Type" is no longer present in LLVM. Various other adjustments resulting from these changes were also made. --- Diffs of the changes: (+17 -15) Index: llvm/include/llvm/Type.h diff -u llvm/include/llvm/Type.h:1.46 llvm/include/llvm/Type.h:1.47 --- llvm/include/llvm/Type.h:1.46 Fri Jul 2 18:19:50 2004 +++ llvm/include/llvm/Type.h Sun Jul 4 05:46:49 2004 @@ -33,21 +33,24 @@ #ifndef LLVM_TYPE_H #define LLVM_TYPE_H -#include "llvm/Value.h" +#include "AbstractTypeUser.h" +#include "Support/Casting.h" #include "Support/GraphTraits.h" #include "Support/iterator" #include namespace llvm { +class ArrayType; class DerivedType; class FunctionType; -class ArrayType; +class OpaqueType; class PointerType; class StructType; -class OpaqueType; +class SymbolTable; +class Value; -struct Type : public Value { +struct Type { ///===-------------------------------------------------------------------===// /// Definitions of all of the base types for the Type system. Based on this /// value, you can cast to a "DerivedType" subclass (see DerivedTypes.h) @@ -55,16 +58,14 @@ /// Type::getPrimitiveType function, or else things will break! /// enum TypeID { + // PrimitiveTypes .. make sure LastPrimitiveTyID stays up to date VoidTyID = 0 , BoolTyID, // 0, 1: Basics... UByteTyID , SByteTyID, // 2, 3: 8 bit types... UShortTyID , ShortTyID, // 4, 5: 16 bit types... UIntTyID , IntTyID, // 6, 7: 32 bit types... ULongTyID , LongTyID, // 8, 9: 64 bit types... - FloatTyID , DoubleTyID, // 10,11: Floating point types... - - TypeTyID, // 12 : Type definitions - LabelTyID , // 13 : Labels... + LabelTyID , // 12 : Labels... // Derived types... see DerivedTypes.h file... // Make sure FirstDerivedTyID stays up to date!!! @@ -75,6 +76,7 @@ //... NumTypeIDs, // Must remain as last defined ID + LastPrimitiveTyID = LabelTyID, FirstDerivedTyID = FunctionTyID, }; @@ -93,7 +95,7 @@ const Type *getForwardedTypeInternal() const; protected: /// ctor is protected, so only subclasses can create Type objects... - Type(const std::string &Name, TypeID id); + Type(const std::string& Name, TypeID id ); virtual ~Type() {} @@ -193,12 +195,12 @@ /// Here are some useful little methods to query what type derived types are /// Note that all other types can just compare to see if this == Type::xxxTy; /// - inline bool isPrimitiveType() const { return ID < FirstDerivedTyID; } + inline bool isPrimitiveType() const { return ID <= LastPrimitiveTyID; } inline bool isDerivedType() const { return ID >= FirstDerivedTyID; } /// isFirstClassType - Return true if the value is holdable in a register. inline bool isFirstClassType() const { - return (ID != VoidTyID && ID < TypeTyID) || ID == PointerTyID; + return (ID != VoidTyID && ID <= LastPrimitiveTyID) || ID == PointerTyID; } /// isSized - Return true if it makes sense to take the size of this type. To @@ -272,13 +274,10 @@ *LongTy , *ULongTy; static Type *FloatTy, *DoubleTy; - static Type *TypeTy , *LabelTy; + static Type* LabelTy; /// Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const Type *T) { return true; } - static inline bool classof(const Value *V) { - return V->getValueType() == Value::TypeVal; - } #include "llvm/Type.def" @@ -401,6 +400,9 @@ template <> inline bool isa_impl(const Type &Ty) { return Ty.getTypeID() == Type::PointerTyID; } + +std::ostream &operator<<(std::ostream &OS, const Type *T); +std::ostream &operator<<(std::ostream &OS, const Type &T); } // End llvm namespace From llvm at cs.uiuc.edu Sun Jul 4 05:49:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 05:49:01 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/DerivedTypes.h Message-ID: <200407041048.FAA32124@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: DerivedTypes.h updated: 1.58 -> 1.59 --- Log message: Remove all of the classof(const Value*) methods of the derived types since the Type base class no longer derives from Value. --- Diffs of the changes: (+2 -36) Index: llvm/include/llvm/DerivedTypes.h diff -u llvm/include/llvm/DerivedTypes.h:1.58 llvm/include/llvm/DerivedTypes.h:1.59 --- llvm/include/llvm/DerivedTypes.h:1.58 Thu Jun 17 13:15:25 2004 +++ llvm/include/llvm/DerivedTypes.h Sun Jul 4 05:48:27 2004 @@ -95,9 +95,6 @@ static inline bool classof(const Type *T) { return T->isDerivedType(); } - static inline bool classof(const Value *V) { - return isa(V) && classof(cast(V)); - } }; @@ -151,9 +148,6 @@ static inline bool classof(const Type *T) { return T->getTypeID() == FunctionTyID; } - static inline bool classof(const Value *V) { - return isa(V) && classof(cast(V)); - } }; @@ -177,9 +171,6 @@ T->getTypeID() == StructTyID || T->getTypeID() == PointerTyID; } - static inline bool classof(const Value *V) { - return isa(V) && classof(cast(V)); - } }; @@ -232,9 +223,6 @@ static inline bool classof(const Type *T) { return T->getTypeID() == StructTyID; } - static inline bool classof(const Value *V) { - return isa(V) && classof(cast(V)); - } }; @@ -256,24 +244,14 @@ public: inline const Type *getElementType() const { return ContainedTys[0]; } + virtual bool indexValid(const Value *V) const; + /// getTypeAtIndex - Given an index value into the type, return the type of /// the element. For sequential types, there is only one subtype... /// virtual const Type *getTypeAtIndex(const Value *V) const { return ContainedTys[0]; } - virtual bool indexValid(const Value *V) const { - const Type *Ty = V->getType(); - switch (Ty->getTypeID()) { - case Type::IntTyID: - case Type::UIntTyID: - case Type::LongTyID: - case Type::ULongTyID: - return true; - default: - return false; - } - } // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const SequentialType *T) { return true; } @@ -281,9 +259,6 @@ return T->getTypeID() == ArrayTyID || T->getTypeID() == PointerTyID; } - static inline bool classof(const Value *V) { - return isa(V) && classof(cast(V)); - } }; @@ -321,9 +296,6 @@ static inline bool classof(const Type *T) { return T->getTypeID() == ArrayTyID; } - static inline bool classof(const Value *V) { - return isa(V) && classof(cast(V)); - } }; @@ -354,9 +326,6 @@ static inline bool classof(const Type *T) { return T->getTypeID() == PointerTyID; } - static inline bool classof(const Value *V) { - return isa(V) && classof(cast(V)); - } }; @@ -392,9 +361,6 @@ static inline bool classof(const OpaqueType *T) { return true; } static inline bool classof(const Type *T) { return T->getTypeID() == OpaqueTyID; - } - static inline bool classof(const Value *V) { - return isa(V) && classof(cast(V)); } }; From llvm at cs.uiuc.edu Sun Jul 4 05:50:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 05:50:01 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/SymbolTable.h Message-ID: <200407041049.FAA32172@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: SymbolTable.h updated: 1.35 -> 1.36 --- Log message: Constify usage of Type* on the interface to ensure SymbolTable doesn't modify types (it never should). Clean up some comments. --- Diffs of the changes: (+6 -9) Index: llvm/include/llvm/SymbolTable.h diff -u llvm/include/llvm/SymbolTable.h:1.35 llvm/include/llvm/SymbolTable.h:1.36 --- llvm/include/llvm/SymbolTable.h:1.35 Thu Jun 3 10:14:00 2004 +++ llvm/include/llvm/SymbolTable.h Sun Jul 4 05:49:41 2004 @@ -48,7 +48,7 @@ public: /// @brief A mapping of names to types. - typedef std::map TypeMap; + typedef std::map TypeMap; /// @brief An iterator over the TypeMap. typedef TypeMap::iterator type_iterator; @@ -165,7 +165,6 @@ /// @brief Insert a constant or type. inline void insert(const std::string &Name, Value *Val) { assert(Val && "Can't insert null type into symbol table!"); - assert(!isa(Val) && "Cannot insert types with this interface!"); assert(isa(Val) && "Can only insert constants into a symbol table!"); insertEntry(Name, Val->getType(), Val); @@ -176,7 +175,7 @@ /// allows a type with an existing entry in the symbol table to get /// a new name. /// @brief Insert a type under a new name. - inline void insert(const std::string &Name, Type *Typ) { + inline void insert(const std::string &Name, const Type *Typ) { assert(Typ && "Can't insert null type into symbol table!"); insertEntry(Name, Typ ); } @@ -194,7 +193,7 @@ /// the Type in the type map. If the Type is not in the symbol /// table, this method silently ignores the request. /// @brief Remove a named type from the symbol table. - void remove(Type* Typ ); + void remove(const Type* Typ ); /// Remove a constant or type with the specified name from the /// symbol table. @@ -202,7 +201,6 @@ /// @brief Remove a constant or type from the symbol table. inline Value* remove(const std::string &Name, Value *Val) { assert(Val && "Can't remove null value from symbol table!"); - assert(!isa(Val) && "Can't remove types with this interface!"); plane_iterator PI = pmap.find(Val->getType()); return removeEntry(PI, PI->second.find(Name)); } @@ -332,7 +330,7 @@ void insertEntry(const std::string &Name, const Type *Ty, Value *V); /// @brief Insert a type into the symbol table with the specified name. - void insertEntry(const std::string &Name, Type *T); + void insertEntry(const std::string &Name, const Type *T); /// Remove a specific value from a specific plane in the SymbolTable. /// @returns the removed Value. @@ -358,12 +356,11 @@ /// separate type planes for named values. That is, each named /// value is organized into a separate dictionary based on /// Type. This means that the same name can be used for different - /// types without conflict. Note that the Type::TypeTy plane is - /// not stored in this map but is in tmap. + /// types without conflict. /// @brief The mapping of types to names to values. PlaneMap pmap; - /// This is the Type::TypeTy plane. It is separated from the pmap + /// This is the type plane. It is separated from the pmap /// because the elements of the map are name/Type pairs not /// name/Value pairs and Type is not a Value. TypeMap tmap; From llvm at cs.uiuc.edu Sun Jul 4 05:52:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 05:52:01 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Type.def Message-ID: <200407041050.FAA32230@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: Type.def updated: 1.6 -> 1.7 --- Log message: There is no longer a "Type" primitive type because Values and Types are now distinct. --- Diffs of the changes: (+0 -1) Index: llvm/include/llvm/Type.def diff -u llvm/include/llvm/Type.def:1.6 llvm/include/llvm/Type.def:1.7 --- llvm/include/llvm/Type.def:1.6 Tue Nov 11 16:41:30 2003 +++ llvm/include/llvm/Type.def Sun Jul 4 05:50:43 2004 @@ -44,7 +44,6 @@ HANDLE_PRIM_TYPE(ULong , 8) HANDLE_PRIM_TYPE(Float , 4) HANDLE_PRIM_TYPE(Double, 8) -HANDLE_PRIM_TYPE(Type , 0) HANDLE_PRIM_TYPE(Label , 0) From llvm at cs.uiuc.edu Sun Jul 4 05:53:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 05:53:01 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Value.h Message-ID: <200407041052.FAA32290@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: Value.h updated: 1.53 -> 1.54 --- Log message: - Remove enumerator TypeVal since Values can't be types any more - Remove isa_impl relationship between Types and Values - Add OtherVal so "other" users can interact with Values. --- Diffs of the changes: (+1 -5) Index: llvm/include/llvm/Value.h diff -u llvm/include/llvm/Value.h:1.53 llvm/include/llvm/Value.h:1.54 --- llvm/include/llvm/Value.h:1.53 Sun Jun 27 13:38:24 2004 +++ llvm/include/llvm/Value.h Sun Jul 4 05:52:28 2004 @@ -20,7 +20,6 @@ #include "llvm/AbstractTypeUser.h" #include "llvm/Use.h" #include "Support/Casting.h" -#include namespace llvm { @@ -122,13 +121,13 @@ /// (and Instruction must be last). /// enum ValueTy { - TypeVal, // This is an instance of Type ArgumentVal, // This is an instance of Argument BasicBlockVal, // This is an instance of BasicBlock FunctionVal, // This is an instance of Function GlobalVariableVal, // This is an instance of GlobalVariable ConstantVal, // This is an instance of Constant InstructionVal, // This is an instance of Instruction + OtherVal, // This is an instance of something else }; unsigned getValueType() const { return SubclassID; @@ -185,9 +184,6 @@ // isa - Provide some specializations of isa so that we don't have to include // the subtype header files to test to see if the value is a subclass... // -template <> inline bool isa_impl(const Value &Val) { - return Val.getValueType() == Value::TypeVal; -} template <> inline bool isa_impl(const Value &Val) { return Val.getValueType() == Value::ConstantVal; } From llvm at cs.uiuc.edu Sun Jul 4 05:59:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 05:59:01 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Assembly/PrintModulePass.h Message-ID: <200407041058.FAA32728@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Assembly: PrintModulePass.h updated: 1.15 -> 1.16 --- Log message: Added #include since this header is no longer picked up from the Value.h header. --- Diffs of the changes: (+1 -0) Index: llvm/include/llvm/Assembly/PrintModulePass.h diff -u llvm/include/llvm/Assembly/PrintModulePass.h:1.15 llvm/include/llvm/Assembly/PrintModulePass.h:1.16 --- llvm/include/llvm/Assembly/PrintModulePass.h:1.15 Tue Nov 11 16:41:31 2003 +++ llvm/include/llvm/Assembly/PrintModulePass.h Sun Jul 4 05:58:20 2004 @@ -20,6 +20,7 @@ #include "llvm/Pass.h" #include "llvm/Module.h" +#include namespace llvm { From llvm at cs.uiuc.edu Sun Jul 4 06:00:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 06:00:01 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Assembly/Writer.h Message-ID: <200407041059.FAA00455@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Assembly: Writer.h updated: 1.29 -> 1.30 --- Log message: Add a new, compatible, interface function for writing types as operands. This is necessary because Types are no longer Values. --- Diffs of the changes: (+3 -0) Index: llvm/include/llvm/Assembly/Writer.h diff -u llvm/include/llvm/Assembly/Writer.h:1.29 llvm/include/llvm/Assembly/Writer.h:1.30 --- llvm/include/llvm/Assembly/Writer.h:1.29 Thu Jan 8 16:28:45 2004 +++ llvm/include/llvm/Assembly/Writer.h Sun Jul 4 05:59:05 2004 @@ -40,6 +40,9 @@ std::ostream &WriteAsOperand(std::ostream &, const Value *, bool PrintTy = true, bool PrintName = true, const Module *Context = 0); +std::ostream &WriteAsOperand(std::ostream&, const Type*, bool PrintTy = true, + bool PrintName = true, const Module* Context = 0); + } // End llvm namespace #endif From llvm at cs.uiuc.edu Sun Jul 4 06:02:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 06:02:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Reader/Analyzer.cpp Message-ID: <200407041100.GAA00657@zion.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Reader: Analyzer.cpp updated: 1.7 -> 1.8 --- Log message: Excise tabs. --- Diffs of the changes: (+31 -32) Index: llvm/lib/Bytecode/Reader/Analyzer.cpp diff -u llvm/lib/Bytecode/Reader/Analyzer.cpp:1.7 llvm/lib/Bytecode/Reader/Analyzer.cpp:1.8 --- llvm/lib/Bytecode/Reader/Analyzer.cpp:1.7 Tue Jun 29 18:23:12 2004 +++ llvm/lib/Bytecode/Reader/Analyzer.cpp Sun Jul 4 06:00:39 2004 @@ -21,7 +21,6 @@ #include "llvm/DerivedTypes.h" #include "llvm/Module.h" #include "llvm/Analysis/Verifier.h" -#include "llvm/Bytecode/Analyzer.h" #include "llvm/Bytecode/BytecodeHandler.h" #include #include @@ -116,9 +115,9 @@ if ( bca.progressiveVerify ) { try { - verifyModule(*M, ThrowExceptionAction); + verifyModule(*M, ThrowExceptionAction); } catch ( std::string& msg ) { - bca.VerifyInfo += "Verify at Finish: " + msg + "\n"; + bca.VerifyInfo += "Verify at Finish: " + msg + "\n"; } } } @@ -132,9 +131,9 @@ dump << " } End Module " << id << "\n"; if ( bca.progressiveVerify ) { try { - verifyModule(*M, ThrowExceptionAction); + verifyModule(*M, ThrowExceptionAction); } catch ( std::string& msg ) { - bca.VerifyInfo += "Verify at EndModule: " + msg + "\n"; + bca.VerifyInfo += "Verify at EndModule: " + msg + "\n"; } } } @@ -145,8 +144,8 @@ Module::PointerSize PointerSize ///< PointerSize indicator ) { dump << " RevisionNum: " << int(RevisionNum) - << " Endianness: " << Endianness - << " PointerSize: " << PointerSize << "\n"; + << " Endianness: " << Endianness + << " PointerSize: " << PointerSize << "\n"; } virtual void handleModuleGlobalsBegin() { @@ -165,11 +164,11 @@ dump << " GV: " << ( initSlot == 0 ? "Uni" : "I" ) << "nitialized, " - << ( isConstant? "Constant, " : "Variable, ") - << " Linkage=" << Linkage << " Type=" - << ElemType->getDescription() - << " Slot=" << SlotNum << " InitSlot=" << initSlot - << "\n"; + << ( isConstant? "Constant, " : "Variable, ") + << " Linkage=" << Linkage << " Type=" + << ElemType->getDescription() + << " Slot=" << SlotNum << " InitSlot=" << initSlot + << "\n"; } virtual void handleType( const Type* Ty ) { @@ -178,7 +177,7 @@ } virtual void handleFunctionDeclaration( - Function* Func ///< The function + Function* Func ///< The function ) { bca.numFunctions++; bca.numValues++; @@ -197,9 +196,9 @@ dump << " } END BLOCK: ModuleGlobalInfo\n"; if ( bca.progressiveVerify ) { try { - verifyModule(*M, ThrowExceptionAction); + verifyModule(*M, ThrowExceptionAction); } catch ( std::string& msg ) { - bca.VerifyInfo += "Verify at EndModuleGlobalInfo: " + msg + "\n"; + bca.VerifyInfo += "Verify at EndModuleGlobalInfo: " + msg + "\n"; } } } @@ -216,7 +215,7 @@ virtual void handleCompactionTableType( unsigned i, unsigned TypSlot, const Type* Ty ) { dump << " Type: " << i << " Slot:" << TypSlot - << " is " << Ty->getDescription() << "\n"; + << " is " << Ty->getDescription() << "\n"; } virtual void handleCompactionTableValue( @@ -225,8 +224,8 @@ unsigned ValSlot, const Type* Ty ) { dump << " Value: " << i << " TypSlot: " << TypSlot - << " ValSlot:" << ValSlot << " is " << Ty->getDescription() - << "\n"; + << " ValSlot:" << ValSlot << " is " << Ty->getDescription() + << "\n"; } virtual void handleCompactionTableEnd() { @@ -241,19 +240,19 @@ virtual void handleSymbolTablePlane(unsigned Ty, unsigned NumEntries, const Type* Typ) { dump << " Plane: Ty=" << Ty << " Size=" << NumEntries - << " Type: " << Typ->getDescription() << "\n"; + << " Type: " << Typ->getDescription() << "\n"; } virtual void handleSymbolTableType(unsigned i, unsigned slot, const std::string& name ) { dump << " Type " << i << " Slot=" << slot - << " Name: " << name << "\n"; + << " Name: " << name << "\n"; } virtual void handleSymbolTableValue(unsigned i, unsigned slot, const std::string& name ) { dump << " Value " << i << " Slot=" << slot - << " Name: " << name << "\n"; + << " Name: " << name << "\n"; } virtual void handleSymbolTableEnd() { @@ -291,9 +290,9 @@ if ( bca.progressiveVerify ) { try { - verifyModule(*M, ThrowExceptionAction); + verifyModule(*M, ThrowExceptionAction); } catch ( std::string& msg ) { - bca.VerifyInfo += "Verify at EndFunction: " + msg + "\n"; + bca.VerifyInfo += "Verify at EndFunction: " + msg + "\n"; } } } @@ -306,10 +305,10 @@ } virtual bool handleInstruction( unsigned Opcode, const Type* iType, - std::vector& Operands, unsigned Size){ + std::vector& Operands, unsigned Size){ dump << " INST: OpCode=" - << Instruction::getOpcodeName(Opcode) << " Type=" - << iType->getDescription() << "\n"; + << Instruction::getOpcodeName(Opcode) << " Type=" + << iType->getDescription() << "\n"; for ( unsigned i = 0; i < Operands.size(); ++i ) dump << " Op#" << i << " Slot=" << Operands[i] << "\n"; @@ -358,8 +357,8 @@ virtual void handleConstantArray( const ArrayType* AT, std::vector& Elements, - unsigned TypeSlot, - Constant* ArrayVal ) { + unsigned TypeSlot, + Constant* ArrayVal ) { dump << " ARRAY: " << AT->getDescription() << " TypeSlot=" << TypeSlot << "\n"; for ( unsigned i = 0; i < Elements.size(); ++i ) { @@ -378,7 +377,7 @@ virtual void handleConstantStruct( const StructType* ST, std::vector& Elements, - Constant* StructVal) + Constant* StructVal) { dump << " STRUC: " << ST->getDescription() << "\n"; for ( unsigned i = 0; i < Elements.size(); ++i ) { @@ -394,7 +393,7 @@ virtual void handleConstantPointer( const PointerType* PT, unsigned Slot, GlobalValue* GV, Constant* PtrVal) { dump << " PNTR: " << PT->getDescription() - << " Slot=" << Slot << " GlobalValue="; + << " Slot=" << Slot << " GlobalValue="; GV->print(dump); dump << "\n Value="; PtrVal->print(dump); @@ -415,9 +414,9 @@ dump << " } END BLOCK: GlobalConstants\n"; if ( bca.progressiveVerify ) { try { - verifyModule(*M, ThrowExceptionAction); + verifyModule(*M, ThrowExceptionAction); } catch ( std::string& msg ) { - bca.VerifyInfo += "Verify at EndGlobalConstants: " + msg + "\n"; + bca.VerifyInfo += "Verify at EndGlobalConstants: " + msg + "\n"; } } } From llvm at cs.uiuc.edu Sun Jul 4 06:02:09 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 06:02:09 2004 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Reader/ArchiveReader.cpp Message-ID: <200407041101.GAA00817@zion.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Reader: ArchiveReader.cpp updated: 1.17 -> 1.18 --- Log message: Add #include which is needed now that Value.h doesn't include it --- Diffs of the changes: (+1 -0) Index: llvm/lib/Bytecode/Reader/ArchiveReader.cpp diff -u llvm/lib/Bytecode/Reader/ArchiveReader.cpp:1.17 llvm/lib/Bytecode/Reader/ArchiveReader.cpp:1.18 --- llvm/lib/Bytecode/Reader/ArchiveReader.cpp:1.17 Thu May 27 19:24:41 2004 +++ llvm/lib/Bytecode/Reader/ArchiveReader.cpp Sun Jul 4 06:01:27 2004 @@ -20,6 +20,7 @@ #include "llvm/Module.h" #include "Support/FileUtilities.h" #include +#include using namespace llvm; namespace { From llvm at cs.uiuc.edu Sun Jul 4 06:04:02 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 06:04:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Reader/ReaderWrappers.cpp Message-ID: <200407041103.GAA00978@zion.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Reader: ReaderWrappers.cpp updated: 1.23 -> 1.24 --- Log message: Remove tabs. Move function declaration to Reader.h where it belongs. --- Diffs of the changes: (+4 -8) Index: llvm/lib/Bytecode/Reader/ReaderWrappers.cpp diff -u llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.23 llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.24 --- llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.23 Tue Jun 29 18:24:14 2004 +++ llvm/lib/Bytecode/Reader/ReaderWrappers.cpp Sun Jul 4 06:03:03 2004 @@ -88,7 +88,7 @@ public: BytecodeBufferReader(const unsigned char *Buf, unsigned Length, const std::string &ModuleID, - llvm::BytecodeHandler* Handler = 0); + llvm::BytecodeHandler* Handler = 0); ~BytecodeBufferReader(); }; @@ -97,7 +97,7 @@ BytecodeBufferReader::BytecodeBufferReader(const unsigned char *Buf, unsigned Length, const std::string &ModuleID, - llvm::BytecodeHandler* H ) + llvm::BytecodeHandler* H ) : BytecodeReader(H) { // If not aligned, allocate a new buffer to hold the bytecode... @@ -248,7 +248,7 @@ llvm::getBytecodeBufferModuleProvider(const unsigned char *Buffer, unsigned Length, const std::string &ModuleID, - BytecodeHandler* H ) { + BytecodeHandler* H ) { return CheckVarargs( new BytecodeBufferReader(Buffer, Length, ModuleID, H)); } @@ -271,7 +271,7 @@ /// getBytecodeModuleProvider - lazy function-at-a-time loading from a file /// ModuleProvider *llvm::getBytecodeModuleProvider(const std::string &Filename, - BytecodeHandler* H) { + BytecodeHandler* H) { if (Filename != std::string("-")) // Read from a file... return CheckVarargs(new BytecodeFileReader(Filename,H)); else // Read from stdin @@ -289,10 +289,6 @@ if (ErrorStr) *ErrorStr = err; return 0; } -} - -namespace llvm { -extern BytecodeHandler* createBytecodeAnalyzerHandler(BytecodeAnalysis& bca ); } // AnalyzeBytecodeFile - analyze one file From llvm at cs.uiuc.edu Sun Jul 4 06:06:00 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 06:06:00 2004 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Reader/Reader.h Message-ID: <200407041105.GAA01004@zion.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Reader: Reader.h updated: 1.1 -> 1.2 --- Log message: - Make ValueList an "OtherVal" user of Values to ensure it doesn't get mistaken for anything else. - Move function descriptions to Reader.cpp file per Chris. - Remove tabs. --- Diffs of the changes: (+51 -60) Index: llvm/lib/Bytecode/Reader/Reader.h diff -u llvm/lib/Bytecode/Reader/Reader.h:1.1 llvm/lib/Bytecode/Reader/Reader.h:1.2 --- llvm/lib/Bytecode/Reader/Reader.h:1.1 Tue Jun 29 18:31:01 2004 +++ llvm/lib/Bytecode/Reader/Reader.h Sun Jul 4 06:04:56 2004 @@ -21,6 +21,7 @@ #include "llvm/GlobalValue.h" #include "llvm/Function.h" #include "llvm/ModuleProvider.h" +#include "llvm/Bytecode/Analyzer.h" #include #include @@ -71,7 +72,7 @@ /// globals section. /// @brief A list of values as a User of those Values. struct ValueList : public User { - ValueList() : User(Type::TypeTy, Value::TypeVal) {} + ValueList() : User(Type::VoidTy, Value::OtherVal) {} // vector compatibility methods unsigned size() const { return getNumOperands(); } @@ -82,9 +83,9 @@ // must override this virtual void print(std::ostream& os) const { for ( unsigned i = 0; i < size(); i++ ) { - os << i << " "; - getOperand(i)->print(os); - os << "\n"; + os << i << " "; + getOperand(i)->print(os); + os << "\n"; } } }; @@ -124,8 +125,6 @@ /// @name Methods /// @{ public: - /// This function completely parses a bytecode buffer given by the \p Buf - /// and \p Length parameters. The /// @brief Main interface to parsing a bytecode buffer. void ParseBytecode( const unsigned char *Buf, ///< Beginning of the bytecode buffer @@ -133,24 +132,11 @@ const std::string &ModuleID ///< An identifier for the module constructed. ); - /// The ParseAllFunctionBodies method parses through all the previously - /// unparsed functions in the bytecode file. If you want to completely parse - /// a bytecode file, this method should be called after Parsebytecode because - /// Parsebytecode only records the locations in the bytecode file of where - /// the function definitions are located. This function uses that information - /// to materialize the functions. - /// @see ParseBytecode /// @brief Parse all function bodies - void ParseAllFunctionBodies (); + void ParseAllFunctionBodies(); - /// The ParserFunction method lazily parses one function. Use this method to - /// casue the parser to parse a specific function in the module. Note that - /// this will remove the function from what is to be included by - /// ParseAllFunctionBodies. - /// @see ParseAllFunctionBodies - /// @see ParseBytecode /// @brief Parse the next function of specific type - void ParseFunction (Function* Func) ; + void ParseFunction(Function* Func) ; /// This method is abstract in the parent ModuleProvider class. Its /// implementation is identical to the ParseFunction method. @@ -198,36 +184,30 @@ /// @brief Parse a symbol table void ParseSymbolTable( Function* Func, SymbolTable *ST); - /// This function parses LLVM functions lazily. It obtains the type of the - /// function and records where the body of the function is in the bytecode - /// buffer. The caller can then use the ParseNextFunction and - /// ParseAllFunctionBodies to get handler events for the functions. /// @brief Parse functions lazily. void ParseFunctionLazily(); /// @brief Parse a function body void ParseFunctionBody(Function* Func); + /// @brief Parse the type list portion of a compaction table + void BytecodeReader::ParseCompactionTypes( unsigned NumEntries ); + /// @brief Parse a compaction table void ParseCompactionTable(); /// @brief Parse global types void ParseGlobalTypes(); - /// @returns The basic block constructed. /// @brief Parse a basic block (for LLVM 1.0 basic block blocks) BasicBlock* ParseBasicBlock(unsigned BlockNo); - /// @returns Rhe number of basic blocks encountered. /// @brief parse an instruction list (for post LLVM 1.0 instruction lists /// with blocks differentiated by terminating instructions. unsigned ParseInstructionList( Function* F ///< The function into which BBs will be inserted ); - /// This method parses a single instruction. The instruction is - /// inserted at the end of the \p BB provided. The arguments of - /// the instruction are provided in the \p Args vector. /// @brief Parse a single instruction. void ParseInstruction( std::vector& Args, ///< The arguments to be filled in @@ -235,7 +215,8 @@ ); /// @brief Parse the whole constant pool - void ParseConstantPool(ValueTable& Values, TypeListTy& Types); + void ParseConstantPool(ValueTable& Values, TypeListTy& Types, + bool isFunction); /// @brief Parse a single constant value Constant* ParseConstantValue(unsigned TypeID); @@ -259,25 +240,33 @@ BufPtr BlockEnd; ///< End of current block being parsed BufPtr At; ///< Where we're currently parsing at - // Information about the module, extracted from the bytecode revision number. + /// Information about the module, extracted from the bytecode revision number. unsigned char RevisionNum; // The rev # itself - // Flags to distinguish LLVM 1.0 & 1.1 bytecode formats (revision #0) + /// Flags to distinguish LLVM 1.0 & 1.1 bytecode formats (revision #0) - // Revision #0 had an explicit alignment of data only for the ModuleGlobalInfo - // block. This was fixed to be like all other blocks in 1.2 + /// Revision #0 had an explicit alignment of data only for the ModuleGlobalInfo + /// block. This was fixed to be like all other blocks in 1.2 bool hasInconsistentModuleGlobalInfo; - // Revision #0 also explicitly encoded zero values for primitive types like - // int/sbyte/etc. + /// Revision #0 also explicitly encoded zero values for primitive types like + /// int/sbyte/etc. bool hasExplicitPrimitiveZeros; // Flags to control features specific the LLVM 1.2 and before (revision #1) - // LLVM 1.2 and earlier required that getelementptr structure indices were - // ubyte constants and that sequential type indices were longs. + /// LLVM 1.2 and earlier required that getelementptr structure indices were + /// ubyte constants and that sequential type indices were longs. bool hasRestrictedGEPTypes; + /// LLVM 1.2 and earlier had class Type deriving from Value and the Type + /// objects were located in the "Type Type" plane of various lists in read + /// by the bytecode reader. In LLVM 1.3 this is no longer the case. Types are + /// completely distinct from Values. Consequently, Types are written in fixed + /// locations in LLVM 1.3. This flag indicates that the older Type derived + /// from Value style of bytecode file is being read. + bool hasTypeDerivedFromValue; + /// CompactionTable - If a compaction table is active in the current function, /// this is the mapping that it contains. std::vector CompactionTypes; @@ -353,41 +342,36 @@ /// @brief Converts a type slot number to its Type* const Type *getType(unsigned ID); + /// @brief Converts a pre-sanitized type slot number to its Type* and + /// sanitizes the type id. + inline const Type* getSanitizedType(unsigned& ID ); + + /// @brief Read in and get a sanitized type id + inline const Type* BytecodeReader::readSanitizedType(); + /// @brief Converts a Type* to its type slot number unsigned getTypeSlot(const Type *Ty); /// @brief Converts a normal type slot number to a compacted type slot num. unsigned getCompactionTypeSlot(unsigned type); - /// This is just like getType, but when a compaction table is in use, it is - /// ignored. Also, no forward references or other fancy features are - /// supported. - const Type *getGlobalTableType(unsigned Slot); + /// @brief Gets the global type corresponding to the TypeId + const Type *getGlobalTableType(unsigned TypeId); /// This is just like getTypeSlot, but when a compaction table is in use, /// it is ignored. unsigned getGlobalTableTypeSlot(const Type *Ty); - /// Retrieve a value of a given type and slot number, possibly creating - /// it if it doesn't already exist. + /// @brief Get a value from its typeid and slot number Value* getValue(unsigned TypeID, unsigned num, bool Create = true); - /// This is just like getValue, but when a compaction table is in use, it - /// is ignored. Also, no forward references or other fancy features are - /// supported. + /// @brief Get a value from its type and slot number, ignoring compaction tables. Value *getGlobalTableValue(const Type *Ty, unsigned SlotNo); - /// This function is used when construction phi, br, switch, and other - /// instructions that reference basic blocks. Blocks are numbered - /// sequentially as they appear in the function. /// @brief Get a basic block for current function BasicBlock *getBasicBlock(unsigned ID); - /// Just like getValue, except that it returns a null pointer - /// only on error. It always returns a constant (meaning that if the value is - /// defined, but is not a constant, that is an error). If the specified - /// constant hasn't been parsed yet, a placeholder is defined and used. - /// Later, after the real value is parsed, the placeholder is eliminated. + /// @brief Get a constant value from its typeid and value slot. Constant* getConstantValue(unsigned typeSlot, unsigned valSlot); /// @brief Convenience function for getting a constant value when @@ -396,9 +380,6 @@ return getConstantValue(getTypeSlot(Ty), valSlot); } - /// As values are created, they are inserted into the appropriate place - /// with this method. The ValueTable argument must be one of ModuleValues - /// or FunctionValues data members of this class. /// @brief Insert a newly created value unsigned insertValue(Value *V, unsigned Type, ValueTable &Table); @@ -458,11 +439,21 @@ /// @brief Read an arbitrary data chunk of fixed length inline void read_data(void *Ptr, void *End); - /// Read a bytecode block header + /// @brief Read a bytecode block header inline void read_block(unsigned &Type, unsigned &Size); + /// @brief Read a type identifier and sanitize it. + inline bool read_typeid(unsigned &TypeId); + + /// @brief Recalculate type ID for pre 1.3 bytecode files. + inline bool sanitizeTypeId(unsigned &TypeId ); /// @} }; + +/// @brief A function for creating a BytecodeAnalzer as a handler +/// for the Bytecode reader. +BytecodeHandler* createBytecodeAnalyzerHandler(BytecodeAnalysis& bca ); + } // End llvm namespace From llvm at cs.uiuc.edu Sun Jul 4 06:31:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 06:31:01 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Bytecode/BytecodeHandler.h Message-ID: <200407041130.GAA02966@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Bytecode: BytecodeHandler.h updated: 1.2 -> 1.3 --- Log message: Make all the virtual function (except destructor) inline so there are default implementations without taking up a ton of space in a .cpp file. --- Diffs of the changes: (+41 -41) Index: llvm/include/llvm/Bytecode/BytecodeHandler.h diff -u llvm/include/llvm/Bytecode/BytecodeHandler.h:1.2 llvm/include/llvm/Bytecode/BytecodeHandler.h:1.3 --- llvm/include/llvm/Bytecode/BytecodeHandler.h:1.2 Tue Jun 29 18:18:52 2004 +++ llvm/include/llvm/Bytecode/BytecodeHandler.h Sun Jul 4 06:29:56 2004 @@ -66,29 +66,29 @@ /// with the error message before the parser throws an exception to /// terminate the parsing. /// @brief Handle parsing errors. - virtual void handleError(const std::string& str ); + virtual void handleError(const std::string& str ) {} /// This method is called at the beginning of a parse before anything is /// read in order to give the handler a chance to initialize. /// @brief Handle the start of a bytecode parse - virtual void handleStart( Module* Mod, unsigned byteSize ); + virtual void handleStart( Module* Mod, unsigned byteSize ) {} /// This method is called at the end of a parse after everything has been /// read in order to give the handler a chance to terminate. /// @brief Handle the end of a bytecode parse - virtual void handleFinish(); + virtual void handleFinish() {} /// This method is called at the start of a module to indicate that a /// module is being parsed. /// @brief Handle the start of a module. - virtual void handleModuleBegin(const std::string& moduleId); + virtual void handleModuleBegin(const std::string& moduleId) {} /// This method is called at the end of a module to indicate that the module /// previously being parsed has concluded. /// @brief Handle the end of a module. virtual void handleModuleEnd( const std::string& moduleId ///< An identifier for the module - ); + ) {} /// This method is called once the version information has been parsed. It /// provides the information about the version of the bytecode file being @@ -98,11 +98,11 @@ unsigned char RevisionNum, ///< Byte code revision number Module::Endianness Endianness, ///< Endianness indicator Module::PointerSize PointerSize ///< PointerSize indicator - ); + ) {} /// This method is called at the start of a module globals block which /// contains the global variables and the function placeholders - virtual void handleModuleGlobalsBegin(); + virtual void handleModuleGlobalsBegin() {} /// This method is called when a non-initialized global variable is /// recognized. Its type, constness, and linkage type are provided. @@ -113,46 +113,46 @@ GlobalValue::LinkageTypes,///< The linkage type of the GV unsigned SlotNum, ///< Slot number of GV unsigned initSlot ///< Slot number of GV's initializer (0 if none) - ); + ) {} /// This method is called when a new type is recognized. The type is /// converted from the bytecode and passed to this method. /// @brief Handle a type virtual void handleType( const Type* Ty ///< The type that was just recognized - ); + ) {} /// This method is called when the function prototype for a function is /// encountered in the module globals block. virtual void handleFunctionDeclaration( Function* Func ///< The function being declared - ); + ) {} /// This method is called when a global variable is initialized with /// its constant value. Because of forward referencing, etc. this is /// done towards the end of the module globals block - virtual void handleGlobalInitializer(GlobalVariable*, Constant* ); + virtual void handleGlobalInitializer(GlobalVariable*, Constant* ) {} /// This method is called at the end of the module globals block. /// @brief Handle end of module globals block. - virtual void handleModuleGlobalsEnd(); + virtual void handleModuleGlobalsEnd() {} /// This method is called at the beginning of a compaction table. /// @brief Handle start of compaction table. - virtual void handleCompactionTableBegin(); + virtual void handleCompactionTableBegin() {} /// @brief Handle start of a compaction table plane virtual void handleCompactionTablePlane( unsigned Ty, ///< The type of the plane (slot number) unsigned NumEntries ///< The number of entries in the plane - ); + ) {} /// @brief Handle a type entry in the compaction table virtual void handleCompactionTableType( unsigned i, ///< Index in the plane of this type unsigned TypSlot, ///< Slot number for this type const Type* ///< The type referenced by this slot - ); + ) {} /// @brief Handle a value entry in the compaction table virtual void handleCompactionTableValue( @@ -160,56 +160,56 @@ unsigned TypSlot, ///< The slot (plane) of the type of this value unsigned ValSlot, ///< The global value slot of the value const Type* ///< The resolved type of the value. - ); + ) {} /// @brief Handle end of a compaction table - virtual void handleCompactionTableEnd(); + virtual void handleCompactionTableEnd() {} /// @brief Handle start of a symbol table virtual void handleSymbolTableBegin( Function* Func, ///< The function to which the ST belongs SymbolTable* ST ///< The symbol table being filled - ); + ) {} /// @brief Handle start of a symbol table plane virtual void handleSymbolTablePlane( - unsigned Ty, ///< The slotnum of the type plane + unsigned TySlot, ///< The slotnum of the type plane unsigned NumEntries, ///< Number of entries in the plane - const Type* Ty ///< The type of this type plane - ); + const Type* Typ ///< The type of this type plane + ) {} /// @brief Handle a named type in the symbol table virtual void handleSymbolTableType( unsigned i, ///< The index of the type in this plane unsigned slot, ///< Slot number of the named type const std::string& name ///< Name of the type - ); + ) {} /// @brief Handle a named value in the symbol table virtual void handleSymbolTableValue( unsigned i, ///< The index of the value in this plane unsigned slot, ///< Slot number of the named value const std::string& name ///< Name of the value. - ); + ) {} /// @brief Handle the end of a symbol table - virtual void handleSymbolTableEnd(); + virtual void handleSymbolTableEnd() {} /// @brief Handle the beginning of a function body virtual void handleFunctionBegin( Function* Func, ///< The function being defined unsigned Size ///< The size (in bytes) of the function's bytecode - ); + ) {} /// @brief Handle the end of a function body virtual void handleFunctionEnd( Function* Func ///< The function whose definition has just finished. - ); + ) {} /// @brief Handle the beginning of a basic block virtual void handleBasicBlockBegin( unsigned blocknum ///< The block number of the block - ); + ) {} /// This method is called for each instruction that is parsed. /// @returns true if the instruction is a block terminating instruction @@ -219,22 +219,22 @@ const Type* iType, ///< Instruction type std::vector& Operands, ///< Vector of slot # operands unsigned Length ///< Length of instruction in bc bytes - ); + ) { return false; } /// @brief Handle the end of a basic block virtual void handleBasicBlockEnd( unsigned blocknum ///< The block number of the block just finished - ); + ) {} /// @brief Handle start of global constants block. - virtual void handleGlobalConstantsBegin(); + virtual void handleGlobalConstantsBegin() {} /// @brief Handle a constant expression virtual void handleConstantExpression( unsigned Opcode, ///< Opcode of primary expression operator std::vector ArgVec, ///< expression args Constant* C ///< The constant value - ); + ) {} /// @brief Handle a constant array virtual void handleConstantArray( @@ -242,14 +242,14 @@ std::vector& ElementSlots,///< Slot nums for array values unsigned TypeSlot, ///< Slot # of type Constant* Val ///< The constant value - ); + ) {} /// @brief Handle a constant structure virtual void handleConstantStruct( const StructType* ST, ///< Type of the struct std::vector& ElementSlots,///< Slot nums for struct values Constant* Val ///< The constant value - ); + ) {} /// @brief Handle a constant pointer virtual void handleConstantPointer( @@ -257,42 +257,42 @@ unsigned Slot, ///< Slot num of initializer value GlobalValue* GV, ///< Referenced global value Constant* Val ///< Value of constant - ); + ) {} /// @brief Handle a constant strings (array special case) virtual void handleConstantString( const ConstantArray* CA ///< Type of the string array - ); + ) {} /// @brief Handle a primitive constant value virtual void handleConstantValue( Constant * c ///< The constant just defined - ); + ) {} /// @brief Handle the end of the global constants - virtual void handleGlobalConstantsEnd(); + virtual void handleGlobalConstantsEnd() {} /// @brief Handle an alignment event virtual void handleAlignment( unsigned numBytes ///< The number of bytes added for alignment - ); + ) {} /// @brief Handle a bytecode block virtual void handleBlock( unsigned BType, ///< The type of block const unsigned char* StartPtr, ///< The start of the block unsigned Size ///< The size of the block - ); + ) {} /// @brief Handle a variable bit rate 32 bit unsigned virtual void handleVBR32( unsigned Size ///< Number of bytes the vbr_uint took up - ); + ) {} /// @brief Handle a variable bit rate 64 bit unsigned virtual void handleVBR64( unsigned Size ///< Number of byte sthe vbr_uint64 took up - ); + ) {} /// @} }; From llvm at cs.uiuc.edu Sun Jul 4 06:35:02 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 06:35:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Reader/Reader.cpp Message-ID: <200407041134.GAA03282@zion.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Reader: Reader.cpp updated: 1.108 -> 1.109 --- Log message: - Don't use macros to call the BytecodeHandler - Don't use PARSE_ERROR macro unnecessarily (for simple strings) - Add comments before each function - Convert for bug 122: http://llvm.cs.uiuc.edu/PR122 (Type != Value) - Handle new value range on Type::PrimitiveTypeId enumeration by augmenting the reader with a new read_typeid method and sanitizeTypeId method. - Remove BytecodeHandler's default method implementations to header file. --- Diffs of the changes: (+434 -278) Index: llvm/lib/Bytecode/Reader/Reader.cpp diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.108 llvm/lib/Bytecode/Reader/Reader.cpp:1.109 --- llvm/lib/Bytecode/Reader/Reader.cpp:1.108 Tue Jun 29 18:29:38 2004 +++ llvm/lib/Bytecode/Reader/Reader.cpp Sun Jul 4 06:33:49 2004 @@ -20,10 +20,8 @@ #include "llvm/Bytecode/BytecodeHandler.h" #include "llvm/BasicBlock.h" #include "llvm/Constants.h" -#include "llvm/iMemory.h" -#include "llvm/iOther.h" -#include "llvm/iPHINode.h" -#include "llvm/iTerminators.h" +#include "llvm/Instructions.h" +#include "llvm/SymbolTable.h" #include "llvm/Bytecode/Format.h" #include "llvm/Support/GetElementPtrTypeIterator.h" #include "Support/StringExtras.h" @@ -31,11 +29,6 @@ using namespace llvm; -/// A convenience macro for calling the handler. Makes maintenance easier in -/// case the interface to handler methods changes. -#define HANDLE(method) \ - if ( Handler ) Handler->handle ## method - /// A convenience macro for handling parsing errors. #define PARSE_ERROR(inserters) { \ std::ostringstream errormsg; \ @@ -66,31 +59,36 @@ // Bytecode Reading Methods //===----------------------------------------------------------------------===// +/// Determine if the current block being read contains any more data. inline bool BytecodeReader::moreInBlock() { return At < BlockEnd; } +/// Throw an error if we've read past the end of the current block inline void BytecodeReader::checkPastBlockEnd(const char * block_name) { if ( At > BlockEnd ) PARSE_ERROR("Attempt to read past the end of " << block_name << " block."); } +/// Align the buffer position to a 32 bit boundary inline void BytecodeReader::align32() { BufPtr Save = At; At = (const unsigned char *)((unsigned long)(At+3) & (~3UL)); if ( At > Save ) - HANDLE(Alignment( At - Save )); + if (Handler) Handler->handleAlignment( At - Save ); if (At > BlockEnd) - PARSE_ERROR("Ran out of data while aligning!"); + throw std::string("Ran out of data while aligning!"); } +/// Read a whole unsigned integer inline unsigned BytecodeReader::read_uint() { if (At+4 > BlockEnd) - PARSE_ERROR("Ran out of data reading uint!"); + throw std::string("Ran out of data reading uint!"); At += 4; return At[-4] | (At[-3] << 8) | (At[-2] << 16) | (At[-1] << 24); } +/// Read a variable-bit-rate encoded unsigned integer inline unsigned BytecodeReader::read_vbr_uint() { unsigned Shift = 0; unsigned Result = 0; @@ -98,14 +96,15 @@ do { if (At == BlockEnd) - PARSE_ERROR("Ran out of data reading vbr_uint!"); + throw std::string("Ran out of data reading vbr_uint!"); Result |= (unsigned)((*At++) & 0x7F) << Shift; Shift += 7; } while (At[-1] & 0x80); - HANDLE(VBR32(At-Save)); + if (Handler) Handler->handleVBR32(At-Save); return Result; } +/// Read a variable-bit-rate encoded unsigned 64-bit integer. inline uint64_t BytecodeReader::read_vbr_uint64() { unsigned Shift = 0; uint64_t Result = 0; @@ -113,14 +112,15 @@ do { if (At == BlockEnd) - PARSE_ERROR("Ran out of data reading vbr_uint64!"); + throw std::string("Ran out of data reading vbr_uint64!"); Result |= (uint64_t)((*At++) & 0x7F) << Shift; Shift += 7; } while (At[-1] & 0x80); - HANDLE(VBR64(At-Save)); + if (Handler) Handler->handleVBR64(At-Save); return Result; } +/// Read a variable-bit-rate encoded signed 64-bit integer. inline int64_t BytecodeReader::read_vbr_int64() { uint64_t R = read_vbr_uint64(); if (R & 1) { @@ -133,45 +133,88 @@ return (int64_t)(R >> 1); } +/// Read a pascal-style string (length followed by text) inline std::string BytecodeReader::read_str() { unsigned Size = read_vbr_uint(); const unsigned char *OldAt = At; At += Size; if (At > BlockEnd) // Size invalid? - PARSE_ERROR("Ran out of data reading a string!"); + throw std::string("Ran out of data reading a string!"); return std::string((char*)OldAt, Size); } +/// Read an arbitrary block of data inline void BytecodeReader::read_data(void *Ptr, void *End) { unsigned char *Start = (unsigned char *)Ptr; unsigned Amount = (unsigned char *)End - Start; if (At+Amount > BlockEnd) - PARSE_ERROR("Ran out of data!"); + throw std::string("Ran out of data!"); std::copy(At, At+Amount, Start); At += Amount; } +/// Read a block header and obtain its type and size inline void BytecodeReader::read_block(unsigned &Type, unsigned &Size) { Type = read_uint(); Size = read_uint(); BlockStart = At; if ( At + Size > BlockEnd ) - PARSE_ERROR("Attempt to size a block past end of memory"); + throw std::string("Attempt to size a block past end of memory"); BlockEnd = At + Size; - HANDLE(Block( Type, BlockStart, Size )); + if (Handler) Handler->handleBlock( Type, BlockStart, Size ); +} + + +/// In LLVM 1.2 and before, Types were derived from Value and so they were +/// written as part of the type planes along with any other Value. In LLVM +/// 1.3 this changed so that Type does not derive from Value. Consequently, +/// the BytecodeReader's containers for Values can't contain Types because +/// there's no inheritance relationship. This means that the "Type Type" +/// plane is defunct along with the Type::TypeTyID TypeID. In LLVM 1.3 +/// whenever a bytecode construct must have both types and values together, +/// the types are always read/written first and then the Values. Furthermore +/// since Type::TypeTyID no longer exists, its value (12) now corresponds to +/// Type::LabelTyID. In order to overcome this we must "sanitize" all the +/// type TypeIDs we encounter. For LLVM 1.3 bytecode files, there's no change. +/// For LLVM 1.2 and before, this function will decrement the type id by +/// one to account for the missing Type::TypeTyID enumerator if the value is +/// larger than 12 (Type::LabelTyID). If the value is exactly 12, then this +/// function returns true, otherwise false. This helps detect situations +/// where the pre 1.3 bytecode is indicating that what follows is a type. +/// @returns true iff type id corresponds to pre 1.3 "type type" +inline bool BytecodeReader::sanitizeTypeId(unsigned &TypeId ) { + if ( hasTypeDerivedFromValue ) { /// do nothing if 1.3 or later + if ( TypeId == Type::LabelTyID ) { + TypeId = Type::VoidTyID; // sanitize it + return true; // indicate we got TypeTyID in pre 1.3 bytecode + } else if ( TypeId > Type::LabelTyID ) + --TypeId; // shift all planes down because type type plane is missing + } + return false; +} + +/// Reads a vbr uint to read in a type id and does the necessary +/// conversion on it by calling sanitizeTypeId. +/// @returns true iff \p TypeId read corresponds to a pre 1.3 "type type" +/// @see sanitizeTypeId +inline bool BytecodeReader::read_typeid(unsigned &TypeId) { + TypeId = read_vbr_uint(); + return sanitizeTypeId(TypeId); } //===----------------------------------------------------------------------===// // IR Lookup Methods //===----------------------------------------------------------------------===// +/// Determine if a type id has an implicit null value inline bool BytecodeReader::hasImplicitNull(unsigned TyID ) { if (!hasExplicitPrimitiveZeros) - return TyID != Type::LabelTyID && TyID != Type::TypeTyID && - TyID != Type::VoidTyID; + return TyID != Type::LabelTyID && TyID != Type::VoidTyID; return TyID >= Type::FirstDerivedTyID; } +/// Obtain a type given a typeid and account for things like compaction tables, +/// function level vs module level, and the offsetting for the primitive types. const Type *BytecodeReader::getType(unsigned ID) { if (ID < Type::FirstDerivedTyID) if (const Type *T = Type::getPrimitiveType((Type::TypeID)ID)) @@ -182,7 +225,7 @@ if (!CompactionTypes.empty()) { if (ID >= CompactionTypes.size()) - PARSE_ERROR("Type ID out of range for compaction table!"); + throw std::string("Type ID out of range for compaction table!"); return CompactionTypes[ID]; } @@ -195,10 +238,31 @@ if (ID < FunctionTypes.size()) return FunctionTypes[ID].get(); - PARSE_ERROR("Illegal type reference!"); + throw std::string("Illegal type reference!"); return Type::VoidTy; } +/// Get a sanitized type id. This just makes sure that the \p ID +/// is both sanitized and not the "type type" of pre-1.3 bytecode. +/// @see sanitizeTypeId +inline const Type* BytecodeReader::getSanitizedType(unsigned& ID) { + bool isTypeType = sanitizeTypeId(ID); + assert(!isTypeType && "Invalid type id occurred"); + return getType(ID); +} + +/// This method just saves some coding. It uses read_typeid to read +/// in a sanitized type id, asserts that its not the type type, and +/// then calls getType to return the type value. +inline const Type* BytecodeReader::readSanitizedType() { + unsigned ID; + bool isTypeType = read_typeid(ID); + assert(!isTypeType && "Invalid type id occurred"); + return getType(ID); +} + +/// Get the slot number associated with a type accounting for primitive +/// types, compaction tables, and function level vs module level. unsigned BytecodeReader::getTypeSlot(const Type *Ty) { if (Ty->isPrimitiveType()) return Ty->getTypeID(); @@ -206,10 +270,10 @@ // Scan the compaction table for the type if needed. if (!CompactionTypes.empty()) { std::vector::const_iterator I = - find(CompactionTypes.begin(), CompactionTypes.end(), Ty); + find(CompactionTypes.begin(), CompactionTypes.end(), Ty); if (I == CompactionTypes.end()) - PARSE_ERROR("Couldn't find type specified in compaction table!"); + throw std::string("Couldn't find type specified in compaction table!"); return Type::FirstDerivedTyID + (&*I - &CompactionTypes[0]); } @@ -218,15 +282,18 @@ if (I != FunctionTypes.end()) return Type::FirstDerivedTyID + ModuleTypes.size() + - (&*I - &FunctionTypes[0]); + (&*I - &FunctionTypes[0]); // Check the module level types now... I = find(ModuleTypes.begin(), ModuleTypes.end(), Ty); if (I == ModuleTypes.end()) - PARSE_ERROR("Didn't find type in ModuleTypes."); + throw std::string("Didn't find type in ModuleTypes."); return Type::FirstDerivedTyID + (&*I - &ModuleTypes[0]); } +/// This is just like getType, but when a compaction table is in use, it is +/// ignored. It also ignores function level types. +/// @see getType const Type *BytecodeReader::getGlobalTableType(unsigned Slot) { if (Slot < Type::FirstDerivedTyID) { const Type *Ty = Type::getPrimitiveType((Type::TypeID)Slot); @@ -235,22 +302,25 @@ } Slot -= Type::FirstDerivedTyID; if (Slot >= ModuleTypes.size()) - PARSE_ERROR("Illegal compaction table type reference!"); + throw std::string("Illegal compaction table type reference!"); return ModuleTypes[Slot]; } +/// This is just like getTypeSlot, but when a compaction table is in use, it +/// is ignored. It also ignores function level types. unsigned BytecodeReader::getGlobalTableTypeSlot(const Type *Ty) { if (Ty->isPrimitiveType()) return Ty->getTypeID(); TypeListTy::iterator I = find(ModuleTypes.begin(), - ModuleTypes.end(), Ty); + ModuleTypes.end(), Ty); if (I == ModuleTypes.end()) - PARSE_ERROR("Didn't find type in ModuleTypes."); + throw std::string("Didn't find type in ModuleTypes."); return Type::FirstDerivedTyID + (&*I - &ModuleTypes[0]); } +/// Retrieve a value of a given type and slot number, possibly creating +/// it if it doesn't already exist. Value * BytecodeReader::getValue(unsigned type, unsigned oNum, bool Create) { - assert(type != Type::TypeTyID && "getValue() cannot get types!"); assert(type != Type::LabelTyID && "getValue() cannot get blocks!"); unsigned Num = oNum; @@ -266,25 +336,23 @@ // If the type plane was compactified, figure out the global type ID // by adding the derived type ids and the distance. - if (CompactionValues.size() > Type::TypeTyID && - !CompactionTypes.empty() && - type >= Type::FirstDerivedTyID) { + if (!CompactionTypes.empty() && type >= Type::FirstDerivedTyID) { const Type *Ty = CompactionTypes[type-Type::FirstDerivedTyID]; TypeListTy::iterator I = - find(ModuleTypes.begin(), ModuleTypes.end(), Ty); + find(ModuleTypes.begin(), ModuleTypes.end(), Ty); assert(I != ModuleTypes.end()); GlobalTyID = Type::FirstDerivedTyID + (&*I - &ModuleTypes[0]); } if (hasImplicitNull(GlobalTyID)) { if (Num == 0) - return Constant::getNullValue(getType(type)); + return Constant::getNullValue(getType(type)); --Num; } if (GlobalTyID < ModuleValues.size() && ModuleValues[GlobalTyID]) { if (Num < ModuleValues[GlobalTyID]->size()) - return ModuleValues[GlobalTyID]->getOperand(Num); + return ModuleValues[GlobalTyID]->getOperand(Num); Num -= ModuleValues[GlobalTyID]->size(); } } @@ -306,6 +374,9 @@ return Val; } +/// This is just like getValue, but when a compaction table is in use, it +/// is ignored. Also, no forward references or other fancy features are +/// supported. Value* BytecodeReader::getGlobalTableValue(const Type *Ty, unsigned SlotNo) { // FIXME: getTypeSlot is inefficient! unsigned TyID = getGlobalTableTypeSlot(Ty); @@ -319,13 +390,18 @@ if (TyID >= ModuleValues.size() || ModuleValues[TyID] == 0 || SlotNo >= ModuleValues[TyID]->size()) { PARSE_ERROR("Corrupt compaction table entry!" - << TyID << ", " << SlotNo << ": " << ModuleValues.size() << ", " - << (void*)ModuleValues[TyID] << ", " - << ModuleValues[TyID]->size() << "\n"); + << TyID << ", " << SlotNo << ": " << ModuleValues.size() << ", " + << (void*)ModuleValues[TyID] << ", " + << ModuleValues[TyID]->size() << "\n"); } return ModuleValues[TyID]->getOperand(SlotNo); } +/// Just like getValue, except that it returns a null pointer +/// only on error. It always returns a constant (meaning that if the value is +/// defined, but is not a constant, that is an error). If the specified +/// constant hasn't been parsed yet, a placeholder is defined and used. +/// Later, after the real value is parsed, the placeholder is eliminated. Constant* BytecodeReader::getConstantValue(unsigned TypeSlot, unsigned Slot) { if (Value *V = getValue(TypeSlot, Slot, false)) if (Constant *C = dyn_cast(V)) @@ -335,7 +411,7 @@ // to infest bytecode files. return ConstantPointerRef::get(GV); else - PARSE_ERROR("Reference of a value is expected to be a constant!"); + throw std::string("Reference of a value is expected to be a constant!"); const Type *Ty = getType(TypeSlot); std::pair Key(Ty, Slot); @@ -358,12 +434,14 @@ // IR Construction Methods //===----------------------------------------------------------------------===// +/// As values are created, they are inserted into the appropriate place +/// with this method. The ValueTable argument must be one of ModuleValues +/// or FunctionValues data members of this class. unsigned BytecodeReader::insertValue( Value *Val, unsigned type, ValueTable &ValueTab) { assert((!isa(Val) || !cast(Val)->isNullValue()) || - !hasImplicitNull(type) && - "Cannot read null values from bytecode!"); - assert(type != Type::TypeTyID && "Types should never be insertValue'd!"); + !hasImplicitNull(type) && + "Cannot read null values from bytecode!"); if (ValueTab.size() <= type) ValueTab.resize(type+1); @@ -376,6 +454,7 @@ return ValueTab[type]->size()-1 + HasOffset; } +/// Insert the arguments of a function as new values in the reader. void BytecodeReader::insertArguments(Function* F ) { const FunctionType *FT = F->getFunctionType(); Function::aiterator AI = F->abegin(); @@ -388,6 +467,9 @@ // Bytecode Parsing Methods //===----------------------------------------------------------------------===// +/// This method parses a single instruction. The instruction is +/// inserted at the end of the \p BB provided. The arguments of +/// the instruction are provided in the \p Args vector. void BytecodeReader::ParseInstruction(std::vector &Oprnds, BasicBlock* BB) { BufPtr SaveAt = At; @@ -452,7 +534,7 @@ Oprnds.resize(NumOprnds); if (NumOprnds == 0) - PARSE_ERROR("Zero-argument instruction found; this is invalid."); + throw std::string("Zero-argument instruction found; this is invalid."); for (unsigned i = 0; i != NumOprnds; ++i) Oprnds[i] = read_vbr_uint(); @@ -460,11 +542,10 @@ break; } - // Get the type of the instruction - const Type *InstTy = getType(iType); + const Type *InstTy = getSanitizedType(iType); // Hae enough to inform the handler now - HANDLE(Instruction(Opcode, InstTy, Oprnds, At-SaveAt)); + if (Handler) Handler->handleInstruction(Opcode, InstTy, Oprnds, At-SaveAt); // Declare the resulting instruction we'll build. Instruction *Result = 0; @@ -478,16 +559,20 @@ switch (Opcode) { default: - if (Result == 0) PARSE_ERROR("Illegal instruction read!"); + if (Result == 0) + throw std::string("Illegal instruction read!"); break; case Instruction::VAArg: - Result = new VAArgInst(getValue(iType, Oprnds[0]), getType(Oprnds[1])); + Result = new VAArgInst(getValue(iType, Oprnds[0]), + getSanitizedType(Oprnds[1])); break; case Instruction::VANext: - Result = new VANextInst(getValue(iType, Oprnds[0]), getType(Oprnds[1])); + Result = new VANextInst(getValue(iType, Oprnds[0]), + getSanitizedType(Oprnds[1])); break; case Instruction::Cast: - Result = new CastInst(getValue(iType, Oprnds[0]), getType(Oprnds[1])); + Result = new CastInst(getValue(iType, Oprnds[0]), + getSanitizedType(Oprnds[1])); break; case Instruction::Select: Result = new SelectInst(getValue(Type::BoolTyID, Oprnds[0]), @@ -496,7 +581,7 @@ break; case Instruction::PHI: { if (Oprnds.size() == 0 || (Oprnds.size() & 1)) - PARSE_ERROR("Invalid phi node encountered!\n"); + throw std::string("Invalid phi node encountered!"); PHINode *PN = new PHINode(InstTy); PN->op_reserve(Oprnds.size()); @@ -518,7 +603,7 @@ else if (Oprnds.size() == 1) Result = new ReturnInst(getValue(iType, Oprnds[0])); else - PARSE_ERROR("Unrecognized instruction!"); + throw std::string("Unrecognized instruction!"); break; case Instruction::Br: @@ -526,13 +611,13 @@ Result = new BranchInst(getBasicBlock(Oprnds[0])); else if (Oprnds.size() == 3) Result = new BranchInst(getBasicBlock(Oprnds[0]), - getBasicBlock(Oprnds[1]), getValue(Type::BoolTyID , Oprnds[2])); + getBasicBlock(Oprnds[1]), getValue(Type::BoolTyID , Oprnds[2])); else - PARSE_ERROR("Invalid number of operands for a 'br' instruction!"); + throw std::string("Invalid number of operands for a 'br' instruction!"); break; case Instruction::Switch: { if (Oprnds.size() & 1) - PARSE_ERROR("Switch statement with odd number of arguments!"); + throw std::string("Switch statement with odd number of arguments!"); SwitchInst *I = new SwitchInst(getValue(iType, Oprnds[0]), getBasicBlock(Oprnds[1])); @@ -545,15 +630,15 @@ case Instruction::Call: { if (Oprnds.size() == 0) - PARSE_ERROR("Invalid call instruction encountered!"); + throw std::string("Invalid call instruction encountered!"); Value *F = getValue(iType, Oprnds[0]); // Check to make sure we have a pointer to function type const PointerType *PTy = dyn_cast(F->getType()); - if (PTy == 0) PARSE_ERROR("Call to non function pointer value!"); + if (PTy == 0) throw std::string("Call to non function pointer value!"); const FunctionType *FTy = dyn_cast(PTy->getElementType()); - if (FTy == 0) PARSE_ERROR("Call to non function pointer value!"); + if (FTy == 0) throw std::string("Call to non function pointer value!"); std::vector Params; if (!FTy->isVarArg()) { @@ -561,17 +646,17 @@ for (unsigned i = 1, e = Oprnds.size(); i != e; ++i) { if (It == FTy->param_end()) - PARSE_ERROR("Invalid call instruction!"); + throw std::string("Invalid call instruction!"); Params.push_back(getValue(getTypeSlot(*It++), Oprnds[i])); } if (It != FTy->param_end()) - PARSE_ERROR("Invalid call instruction!"); + throw std::string("Invalid call instruction!"); } else { Oprnds.erase(Oprnds.begin(), Oprnds.begin()+1); unsigned FirstVariableOperand; if (Oprnds.size() < FTy->getNumParams()) - PARSE_ERROR("Call instruction missing operands!"); + throw std::string("Call instruction missing operands!"); // Read all of the fixed arguments for (unsigned i = 0, e = FTy->getNumParams(); i != e; ++i) @@ -580,10 +665,10 @@ FirstVariableOperand = FTy->getNumParams(); if ((Oprnds.size()-FirstVariableOperand) & 1) // Must be pairs of type/value - PARSE_ERROR("Invalid call instruction!"); + throw std::string("Invalid call instruction!"); for (unsigned i = FirstVariableOperand, e = Oprnds.size(); - i != e; i += 2) + i != e; i += 2) Params.push_back(getValue(Oprnds[i], Oprnds[i+1])); } @@ -591,14 +676,17 @@ break; } case Instruction::Invoke: { - if (Oprnds.size() < 3) PARSE_ERROR("Invalid invoke instruction!"); + if (Oprnds.size() < 3) + throw std::string("Invalid invoke instruction!"); Value *F = getValue(iType, Oprnds[0]); // Check to make sure we have a pointer to function type const PointerType *PTy = dyn_cast(F->getType()); - if (PTy == 0) PARSE_ERROR("Invoke to non function pointer value!"); + if (PTy == 0) + throw std::string("Invoke to non function pointer value!"); const FunctionType *FTy = dyn_cast(PTy->getElementType()); - if (FTy == 0) PARSE_ERROR("Invoke to non function pointer value!"); + if (FTy == 0) + throw std::string("Invoke to non function pointer value!"); std::vector Params; BasicBlock *Normal, *Except; @@ -610,11 +698,11 @@ FunctionType::param_iterator It = FTy->param_begin(); for (unsigned i = 3, e = Oprnds.size(); i != e; ++i) { if (It == FTy->param_end()) - PARSE_ERROR("Invalid invoke instruction!"); + throw std::string("Invalid invoke instruction!"); Params.push_back(getValue(getTypeSlot(*It++), Oprnds[i])); } if (It != FTy->param_end()) - PARSE_ERROR("Invalid invoke instruction!"); + throw std::string("Invalid invoke instruction!"); } else { Oprnds.erase(Oprnds.begin(), Oprnds.begin()+1); @@ -627,7 +715,7 @@ Oprnds[i])); if (Oprnds.size()-FirstVariableArgument & 1) // Must be type/value pairs - PARSE_ERROR("Invalid invoke instruction!"); + throw std::string("Invalid invoke instruction!"); for (unsigned i = FirstVariableArgument; i < Oprnds.size(); i += 2) Params.push_back(getValue(Oprnds[i], Oprnds[i+1])); @@ -637,9 +725,10 @@ break; } case Instruction::Malloc: - if (Oprnds.size() > 2) PARSE_ERROR("Invalid malloc instruction!"); + if (Oprnds.size() > 2) + throw std::string("Invalid malloc instruction!"); if (!isa(InstTy)) - PARSE_ERROR("Invalid malloc instruction!"); + throw std::string("Invalid malloc instruction!"); Result = new MallocInst(cast(InstTy)->getElementType(), Oprnds.size() ? getValue(Type::UIntTyID, @@ -647,29 +736,31 @@ break; case Instruction::Alloca: - if (Oprnds.size() > 2) PARSE_ERROR("Invalid alloca instruction!"); + if (Oprnds.size() > 2) + throw std::string("Invalid alloca instruction!"); if (!isa(InstTy)) - PARSE_ERROR("Invalid alloca instruction!"); + throw std::string("Invalid alloca instruction!"); Result = new AllocaInst(cast(InstTy)->getElementType(), Oprnds.size() ? getValue(Type::UIntTyID, - Oprnds[0]) :0); + Oprnds[0]) :0); break; case Instruction::Free: if (!isa(InstTy)) - PARSE_ERROR("Invalid free instruction!"); + throw std::string("Invalid free instruction!"); Result = new FreeInst(getValue(iType, Oprnds[0])); break; case Instruction::GetElementPtr: { if (Oprnds.size() == 0 || !isa(InstTy)) - PARSE_ERROR("Invalid getelementptr instruction!"); + throw std::string("Invalid getelementptr instruction!"); std::vector Idx; const Type *NextTy = InstTy; for (unsigned i = 1, e = Oprnds.size(); i != e; ++i) { const CompositeType *TopTy = dyn_cast_or_null(NextTy); - if (!TopTy) PARSE_ERROR("Invalid getelementptr instruction!"); + if (!TopTy) + throw std::string("Invalid getelementptr instruction!"); unsigned ValIdx = Oprnds[i]; unsigned IdxTy = 0; @@ -710,14 +801,14 @@ case 62: // volatile load case Instruction::Load: if (Oprnds.size() != 1 || !isa(InstTy)) - PARSE_ERROR("Invalid load instruction!"); + throw std::string("Invalid load instruction!"); Result = new LoadInst(getValue(iType, Oprnds[0]), "", Opcode == 62); break; case 63: // volatile store case Instruction::Store: { if (!isa(InstTy) || Oprnds.size() != 2) - PARSE_ERROR("Invalid store instruction!"); + throw std::string("Invalid store instruction!"); Value *Ptr = getValue(iType, Oprnds[1]); const Type *ValTy = cast(Ptr->getType())->getElementType(); @@ -726,7 +817,8 @@ break; } case Instruction::Unwind: - if (Oprnds.size() != 0) PARSE_ERROR("Invalid unwind instruction!"); + if (Oprnds.size() != 0) + throw std::string("Invalid unwind instruction!"); Result = new UnwindInst(); break; } // end switch(Opcode) @@ -741,9 +833,11 @@ BB->getInstList().push_back(Result); } -/// getBasicBlock - Get a particular numbered basic block, which might be a -/// forward reference. This works together with ParseBasicBlock to handle these -/// forward references in a clean manner. +/// Get a particular numbered basic block, which might be a forward reference. +/// This works together with ParseBasicBlock to handle these forward references +/// in a clean manner. This function is used when constructing phi, br, switch, +/// and other instructions that reference basic blocks. Blocks are numbered +/// sequentially as they appear in the function. BasicBlock *BytecodeReader::getBasicBlock(unsigned ID) { // Make sure there is room in the table... if (ParsedBasicBlocks.size() <= ID) ParsedBasicBlocks.resize(ID+1); @@ -759,10 +853,12 @@ return ParsedBasicBlocks[ID] = new BasicBlock(); } -/// ParseBasicBlock - In LLVM 1.0 bytecode files, we used to output one -/// basicblock at a time. This method reads in one of the basicblock packets. +/// In LLVM 1.0 bytecode files, we used to output one basicblock at a time. +/// This method reads in one of the basicblock packets. This method is not used +/// for bytecode files after LLVM 1.0 +/// @returns The basic block constructed. BasicBlock *BytecodeReader::ParseBasicBlock( unsigned BlockNo) { - HANDLE(BasicBlockBegin( BlockNo )); + if (Handler) Handler->handleBasicBlockBegin( BlockNo ); BasicBlock *BB = 0; @@ -777,19 +873,20 @@ while ( moreInBlock() ) ParseInstruction(Operands, BB); - HANDLE(BasicBlockEnd( BlockNo )); + if (Handler) Handler->handleBasicBlockEnd( BlockNo ); return BB; } -/// ParseInstructionList - Parse all of the BasicBlock's & Instruction's in the -/// body of a function. In post 1.0 bytecode files, we no longer emit basic -/// block individually, in order to avoid per-basic-block overhead. +/// Parse all of the BasicBlock's & Instruction's in the body of a function. +/// In post 1.0 bytecode files, we no longer emit basic block individually, +/// in order to avoid per-basic-block overhead. +/// @returns Rhe number of basic blocks encountered. unsigned BytecodeReader::ParseInstructionList(Function* F) { unsigned BlockNo = 0; std::vector Args; while ( moreInBlock() ) { - HANDLE(BasicBlockBegin( BlockNo )); + if (Handler) Handler->handleBasicBlockBegin( BlockNo ); BasicBlock *BB; if (ParsedBasicBlocks.size() == BlockNo) ParsedBasicBlocks.push_back(BB = new BasicBlock()); @@ -797,7 +894,7 @@ BB = ParsedBasicBlocks[BlockNo] = new BasicBlock(); else BB = ParsedBasicBlocks[BlockNo]; - HANDLE(BasicBlockEnd( BlockNo )); + if (Handler) Handler->handleBasicBlockEnd( BlockNo ); ++BlockNo; F->getBasicBlockList().push_back(BB); @@ -806,15 +903,20 @@ ParseInstruction(Args, BB); if (!BB->getTerminator()) - PARSE_ERROR("Non-terminated basic block found!"); + throw std::string("Non-terminated basic block found!"); } return BlockNo; } +/// Parse a symbol table. This works for both module level and function +/// level symbol tables. For function level symbol tables, the CurrentFunction +/// parameter must be non-zero and the ST parameter must correspond to +/// CurrentFunction's symbol table. For Module level symbol tables, the +/// CurrentFunction argument must be zero. void BytecodeReader::ParseSymbolTable(Function *CurrentFunction, - SymbolTable *ST) { - HANDLE(SymbolTableBegin(CurrentFunction,ST)); + SymbolTable *ST) { + if (Handler) Handler->handleSymbolTableBegin(CurrentFunction,ST); // Allow efficient basic block lookup by number. std::vector BBMap; @@ -823,10 +925,26 @@ E = CurrentFunction->end(); I != E; ++I) BBMap.push_back(I); + /// In LLVM 1.3 we write types separately from values so + /// The types are always first in the symbol table. This is + /// because Type no longer derives from Value. + if ( ! hasTypeDerivedFromValue ) { + // Symtab block header: [num entries] + unsigned NumEntries = read_vbr_uint(); + for ( unsigned i = 0; i < NumEntries; ++i ) { + // Symtab entry: [def slot #][name] + unsigned slot = read_vbr_uint(); + std::string Name = read_str(); + const Type* T = getType(slot); + ST->insert(Name, T); + } + } + while ( moreInBlock() ) { // Symtab block header: [num entries][type id number] unsigned NumEntries = read_vbr_uint(); - unsigned Typ = read_vbr_uint(); + unsigned Typ = 0; + bool isTypeType = read_typeid(Typ); const Type *Ty = getType(Typ); for (unsigned i = 0; i != NumEntries; ++i) { @@ -834,75 +952,104 @@ unsigned slot = read_vbr_uint(); std::string Name = read_str(); - Value *V = 0; - if (Typ == Type::TypeTyID) - V = (Value*)getType(slot); - else if (Typ == Type::LabelTyID) { - if (slot < BBMap.size()) - V = BBMap[slot]; + // if we're reading a pre 1.3 bytecode file and the type plane + // is the "type type", handle it here + if ( isTypeType ) { + const Type* T = getType(slot); + if ( T == 0 ) + PARSE_ERROR("Failed type look-up for name '" << Name << "'"); + ST->insert(Name, T); + continue; // code below must be short circuited } else { - V = getValue(Typ, slot, false); // Find mapping... + Value *V = 0; + if (Typ == Type::LabelTyID) { + if (slot < BBMap.size()) + V = BBMap[slot]; + } else { + V = getValue(Typ, slot, false); // Find mapping... + } + if (V == 0) + PARSE_ERROR("Failed value look-up for name '" << Name << "'"); + V->setName(Name, ST); } - if (V == 0) - PARSE_ERROR("Failed value look-up for name '" << Name << "'"); - - V->setName(Name, ST); } } checkPastBlockEnd("Symbol Table"); - HANDLE(SymbolTableEnd()); + if (Handler) Handler->handleSymbolTableEnd(); +} + +/// Read in the types portion of a compaction table. +void BytecodeReader::ParseCompactionTypes( unsigned NumEntries ) { + for (unsigned i = 0; i != NumEntries; ++i) { + unsigned TypeSlot = 0; + bool isTypeType = read_typeid(TypeSlot); + assert(!isTypeType && "Invalid type in compaction table: type type"); + const Type *Typ = getGlobalTableType(TypeSlot); + CompactionTypes.push_back(Typ); + if (Handler) Handler->handleCompactionTableType( i, TypeSlot, Typ ); + } } +/// Parse a compaction table. void BytecodeReader::ParseCompactionTable() { - HANDLE(CompactionTableBegin()); + if (Handler) Handler->handleCompactionTableBegin(); + + /// In LLVM 1.3 Type no longer derives from Value. So, + /// we always write them first in the compaction table + /// because they can't occupy a "type plane" where the + /// Values reside. + if ( ! hasTypeDerivedFromValue ) { + unsigned NumEntries = read_vbr_uint(); + ParseCompactionTypes( NumEntries ); + } while ( moreInBlock() ) { unsigned NumEntries = read_vbr_uint(); - unsigned Ty; + unsigned Ty = 0; + unsigned isTypeType = false; if ((NumEntries & 3) == 3) { NumEntries >>= 2; - Ty = read_vbr_uint(); + isTypeType = read_typeid(Ty); } else { Ty = NumEntries >> 2; + isTypeType = sanitizeTypeId(Ty); NumEntries &= 3; } - if (Ty >= CompactionValues.size()) - CompactionValues.resize(Ty+1); + // if we're reading a pre 1.3 bytecode file and the type plane + // is the "type type", handle it here + if ( isTypeType ) { + ParseCompactionTypes(NumEntries); + } else { + if (Ty >= CompactionValues.size()) + CompactionValues.resize(Ty+1); - if (!CompactionValues[Ty].empty()) - PARSE_ERROR("Compaction table plane contains multiple entries!"); + if (!CompactionValues[Ty].empty()) + throw std::string("Compaction table plane contains multiple entries!"); - HANDLE(CompactionTablePlane( Ty, NumEntries )); + if (Handler) Handler->handleCompactionTablePlane( Ty, NumEntries ); - if (Ty == Type::TypeTyID) { - for (unsigned i = 0; i != NumEntries; ++i) { - unsigned TypeSlot = read_vbr_uint(); - const Type *Typ = getGlobalTableType(TypeSlot); - CompactionTypes.push_back(Typ); - HANDLE(CompactionTableType( i, TypeSlot, Typ )); - } - CompactionTypes.resize(NumEntries+Type::FirstDerivedTyID); - } else { const Type *Typ = getType(Ty); // Push the implicit zero CompactionValues[Ty].push_back(Constant::getNullValue(Typ)); for (unsigned i = 0; i != NumEntries; ++i) { - unsigned ValSlot = read_vbr_uint(); - Value *V = getGlobalTableValue(Typ, ValSlot); - CompactionValues[Ty].push_back(V); - HANDLE(CompactionTableValue( i, Ty, ValSlot, Typ )); + unsigned ValSlot = read_vbr_uint(); + Value *V = getGlobalTableValue(Typ, ValSlot); + CompactionValues[Ty].push_back(V); + if (Handler) Handler->handleCompactionTableValue( i, Ty, ValSlot, Typ ); } } } - HANDLE(CompactionTableEnd()); + if (Handler) Handler->handleCompactionTableEnd(); } // Parse a single type constant. const Type *BytecodeReader::ParseTypeConstant() { - unsigned PrimType = read_vbr_uint(); + unsigned PrimType = 0; + bool isTypeType = read_typeid(PrimType); + assert(!isTypeType && "Invalid type (type type) in type constants!"); const Type *Result = 0; if ((Result = Type::getPrimitiveType((Type::TypeID)PrimType))) @@ -910,13 +1057,13 @@ switch (PrimType) { case Type::FunctionTyID: { - const Type *RetType = getType(read_vbr_uint()); + const Type *RetType = readSanitizedType(); unsigned NumParams = read_vbr_uint(); std::vector Params; - while (NumParams--) - Params.push_back(getType(read_vbr_uint())); + while (NumParams--) + Params.push_back(readSanitizedType()); bool isVarArg = Params.size() && Params.back() == Type::VoidTy; if (isVarArg) Params.pop_back(); @@ -925,28 +1072,27 @@ break; } case Type::ArrayTyID: { - unsigned ElTyp = read_vbr_uint(); - const Type *ElementType = getType(ElTyp); - + const Type *ElementType = readSanitizedType(); unsigned NumElements = read_vbr_uint(); - Result = ArrayType::get(ElementType, NumElements); break; } case Type::StructTyID: { std::vector Elements; - unsigned Typ = read_vbr_uint(); + unsigned Typ = 0; + bool isTypeType = read_typeid(Typ); + assert(!isTypeType && "Invalid element type (type type) for structure!"); while (Typ) { // List is terminated by void/0 typeid Elements.push_back(getType(Typ)); - Typ = read_vbr_uint(); + bool isTypeType = read_typeid(Typ); + assert(!isTypeType && "Invalid element type (type type) for structure!"); } Result = StructType::get(Elements); break; } case Type::PointerTyID: { - unsigned ElTyp = read_vbr_uint(); - Result = PointerType::get(getType(ElTyp)); + Result = PointerType::get(readSanitizedType()); break; } @@ -956,10 +1102,11 @@ } default: - PARSE_ERROR("Don't know how to deserialize primitive type" << PrimType << "\n"); + PARSE_ERROR("Don't know how to deserialize primitive type" + << PrimType << "\n"); break; } - HANDLE(Type( Result )); + if (Handler) Handler->handleType( Result ); return Result; } @@ -985,8 +1132,10 @@ // opaque types just inserted. // for (unsigned i = 0; i != NumEntries; ++i) { - const Type *NewTy = ParseTypeConstant(), *OldTy = Tab[i].get(); - if (NewTy == 0) PARSE_ERROR("Couldn't parse type!"); + const Type* NewTy = ParseTypeConstant(); + const Type* OldTy = Tab[i].get(); + if (NewTy == 0) + throw std::string("Couldn't parse type!"); // Don't directly push the new type on the Tab. Instead we want to replace // the opaque type we previously inserted with the new concrete value. This @@ -1003,6 +1152,7 @@ } } +/// Parse a single constant value Constant *BytecodeReader::ParseConstantValue( unsigned TypeID) { // We must check for a ConstantExpr before switching by type because // a ConstantExpr can be of any type, and has no explicit value. @@ -1019,7 +1169,9 @@ // Read the slot number and types of each of the arguments for (unsigned i = 0; i != isExprNumArgs; ++i) { unsigned ArgValSlot = read_vbr_uint(); - unsigned ArgTypeSlot = read_vbr_uint(); + unsigned ArgTypeSlot = 0; + bool isTypeType = read_typeid(ArgTypeSlot); + assert(!isTypeType && "Invalid argument type (type type) for constant value"); // Get the arg value from its slot if it exists, otherwise a placeholder ArgVec.push_back(getConstantValue(ArgTypeSlot, ArgValSlot)); @@ -1029,7 +1181,7 @@ if (isExprNumArgs == 1) { // All one-operand expressions assert(Opcode == Instruction::Cast); Constant* Result = ConstantExpr::getCast(ArgVec[0], getType(TypeID)); - HANDLE(ConstantExpression(Opcode, ArgVec, Result)); + if (Handler) Handler->handleConstantExpression(Opcode, ArgVec, Result); return Result; } else if (Opcode == Instruction::GetElementPtr) { // GetElementPtr std::vector IdxList(ArgVec.begin()+1, ArgVec.end()); @@ -1042,23 +1194,23 @@ for (unsigned i = 0; GTI != E; ++GTI, ++i) if (isa(*GTI)) { if (IdxList[i]->getType() != Type::UByteTy) - PARSE_ERROR("Invalid index for getelementptr!"); + throw std::string("Invalid index for getelementptr!"); IdxList[i] = ConstantExpr::getCast(IdxList[i], Type::UIntTy); } } Constant* Result = ConstantExpr::getGetElementPtr(ArgVec[0], IdxList); - HANDLE(ConstantExpression(Opcode, ArgVec, Result)); + if (Handler) Handler->handleConstantExpression(Opcode, ArgVec, Result); return Result; } else if (Opcode == Instruction::Select) { assert(ArgVec.size() == 3); Constant* Result = ConstantExpr::getSelect(ArgVec[0], ArgVec[1], - ArgVec[2]); - HANDLE(ConstantExpression(Opcode, ArgVec, Result)); + ArgVec[2]); + if (Handler) Handler->handleConstantExpression(Opcode, ArgVec, Result); return Result; } else { // All other 2-operand expressions Constant* Result = ConstantExpr::get(Opcode, ArgVec[0], ArgVec[1]); - HANDLE(ConstantExpression(Opcode, ArgVec, Result)); + if (Handler) Handler->handleConstantExpression(Opcode, ArgVec, Result); return Result; } } @@ -1069,9 +1221,9 @@ case Type::BoolTyID: { unsigned Val = read_vbr_uint(); if (Val != 0 && Val != 1) - PARSE_ERROR("Invalid boolean value read."); + throw std::string("Invalid boolean value read."); Constant* Result = ConstantBool::get(Val == 1); - HANDLE(ConstantValue(Result)); + if (Handler) Handler->handleConstantValue(Result); return Result; } @@ -1080,15 +1232,15 @@ case Type::UIntTyID: { unsigned Val = read_vbr_uint(); if (!ConstantUInt::isValueValidForType(Ty, Val)) - PARSE_ERROR("Invalid unsigned byte/short/int read."); + throw std::string("Invalid unsigned byte/short/int read."); Constant* Result = ConstantUInt::get(Ty, Val); - HANDLE(ConstantValue(Result)); + if (Handler) Handler->handleConstantValue(Result); return Result; } case Type::ULongTyID: { Constant* Result = ConstantUInt::get(Ty, read_vbr_uint64()); - HANDLE(ConstantValue(Result)); + if (Handler) Handler->handleConstantValue(Result); return Result; } @@ -1098,9 +1250,9 @@ case Type::LongTyID: int64_t Val = read_vbr_int64(); if (!ConstantSInt::isValueValidForType(Ty, Val)) - PARSE_ERROR("Invalid signed byte/short/int/long read."); + throw std::string("Invalid signed byte/short/int/long read."); Constant* Result = ConstantSInt::get(Ty, Val); - HANDLE(ConstantValue(Result)); + if (Handler) Handler->handleConstantValue(Result); return Result; } @@ -1108,7 +1260,7 @@ float F; read_data(&F, &F+1); Constant* Result = ConstantFP::get(Ty, F); - HANDLE(ConstantValue(Result)); + if (Handler) Handler->handleConstantValue(Result); return Result; } @@ -1116,14 +1268,10 @@ double Val; read_data(&Val, &Val+1); Constant* Result = ConstantFP::get(Ty, Val); - HANDLE(ConstantValue(Result)); + if (Handler) Handler->handleConstantValue(Result); return Result; } - case Type::TypeTyID: - PARSE_ERROR("Type constants shouldn't live in constant table!"); - break; - case Type::ArrayTyID: { const ArrayType *AT = cast(Ty); unsigned NumElements = AT->getNumElements(); @@ -1134,7 +1282,7 @@ Elements.push_back(getConstantValue(TypeSlot, read_vbr_uint())); Constant* Result = ConstantArray::get(AT, Elements); - HANDLE(ConstantArray(AT, Elements, TypeSlot, Result)); + if (Handler) Handler->handleConstantArray(AT, Elements, TypeSlot, Result); return Result; } @@ -1148,7 +1296,7 @@ read_vbr_uint())); Constant* Result = ConstantStruct::get(ST, Elements); - HANDLE(ConstantStruct(ST, Elements, Result)); + if (Handler) Handler->handleConstantStruct(ST, Elements, Result); return Result; } @@ -1161,13 +1309,13 @@ GlobalValue *GV; if (Val) { if (!(GV = dyn_cast(Val))) - PARSE_ERROR("Value of ConstantPointerRef not in ValueTable!"); + throw std::string("Value of ConstantPointerRef not in ValueTable!"); } else { - PARSE_ERROR("Forward references are not allowed here."); + throw std::string("Forward references are not allowed here."); } Constant* Result = ConstantPointerRef::get(GV); - HANDLE(ConstantPointer(PT, Slot, GV, Result)); + if (Handler) Handler->handleConstantPointer(PT, Slot, GV, Result); return Result; } @@ -1178,6 +1326,10 @@ } } +/// Resolve references for constants. This function resolves the forward +/// referenced constants in the ConstantFwdRefs map. It uses the +/// replaceAllUsesWith method of Value class to substitute the placeholder +/// instance with the actual instance. void BytecodeReader::ResolveReferencesToConstant(Constant *NewV, unsigned Slot){ ConstantRefsType::iterator I = ConstantFwdRefs.find(std::make_pair(NewV->getType(), Slot)); @@ -1189,17 +1341,20 @@ ConstantFwdRefs.erase(I); // Remove the map entry for it } +/// Parse the constant strings section. void BytecodeReader::ParseStringConstants(unsigned NumEntries, ValueTable &Tab){ for (; NumEntries; --NumEntries) { - unsigned Typ = read_vbr_uint(); + unsigned Typ = 0; + bool isTypeType = read_typeid(Typ); + assert(!isTypeType && "Invalid type (type type) for string constant"); const Type *Ty = getType(Typ); if (!isa(Ty)) - PARSE_ERROR("String constant data invalid!"); + throw std::string("String constant data invalid!"); const ArrayType *ATy = cast(Ty); if (ATy->getElementType() != Type::SByteTy && ATy->getElementType() != Type::UByteTy) - PARSE_ERROR("String constant data invalid!"); + throw std::string("String constant data invalid!"); // Read character data. The type tells us how long the string is. char Data[ATy->getNumElements()]; @@ -1217,19 +1372,37 @@ Constant *C = ConstantArray::get(ATy, Elements); unsigned Slot = insertValue(C, Typ, Tab); ResolveReferencesToConstant(C, Slot); - HANDLE(ConstantString(cast(C))); + if (Handler) Handler->handleConstantString(cast(C)); } } +/// Parse the constant pool. void BytecodeReader::ParseConstantPool(ValueTable &Tab, - TypeListTy &TypeTab) { - HANDLE(GlobalConstantsBegin()); + TypeListTy &TypeTab, + bool isFunction) { + if (Handler) Handler->handleGlobalConstantsBegin(); + + /// In LLVM 1.3 Type does not derive from Value so the types + /// do not occupy a plane. Consequently, we read the types + /// first in the constant pool. + if ( isFunction && !hasTypeDerivedFromValue ) { + unsigned NumEntries = read_vbr_uint(); + ParseTypeConstants(TypeTab, NumEntries); + } + while ( moreInBlock() ) { unsigned NumEntries = read_vbr_uint(); - unsigned Typ = read_vbr_uint(); - if (Typ == Type::TypeTyID) { + unsigned Typ = 0; + bool isTypeType = read_typeid(Typ); + + /// In LLVM 1.2 and before, Types were written to the + /// bytecode file in the "Type Type" plane (#12). + /// In 1.3 plane 12 is now the label plane. Handle this here. + if ( isTypeType ) { ParseTypeConstants(TypeTab, NumEntries); } else if (Typ == Type::VoidTyID) { + /// Use of Type::VoidTyID is a misnomer. It actually means + /// that the following plane is constant strings assert(&Tab == &ModuleValues && "Cannot read strings in functions!"); ParseStringConstants(NumEntries, Tab); } else { @@ -1249,9 +1422,12 @@ } } checkPastBlockEnd("Constant Pool"); - HANDLE(GlobalConstantsEnd()); + if (Handler) Handler->handleGlobalConstantsEnd(); } +/// Parse the contents of a function. Note that this function can be +/// called lazily by materializeFunction +/// @see materializeFunction void BytecodeReader::ParseFunctionBody(Function* F ) { unsigned FuncSize = BlockEnd - At; @@ -1265,13 +1441,13 @@ case 3: Linkage = GlobalValue::InternalLinkage; break; case 4: Linkage = GlobalValue::LinkOnceLinkage; break; default: - PARSE_ERROR("Invalid linkage type for Function."); + throw std::string("Invalid linkage type for Function."); Linkage = GlobalValue::InternalLinkage; break; } F->setLinkage( Linkage ); - HANDLE(FunctionBegin(F,FuncSize)); + if (Handler) Handler->handleFunctionBegin(F,FuncSize); // Keep track of how many basic blocks we have read in... unsigned BlockNum = 0; @@ -1289,11 +1465,11 @@ // Insert arguments into the value table before we parse the first basic // block in the function, but after we potentially read in the // compaction table. - insertArguments(F); + insertArguments(F); InsertedArguments = true; } - ParseConstantPool(FunctionValues, FunctionTypes); + ParseConstantPool(FunctionValues, FunctionTypes, true); break; case BytecodeFormat::CompactionTable: @@ -1305,7 +1481,7 @@ // Insert arguments into the value table before we parse the first basic // block in the function, but after we potentially read in the // compaction table. - insertArguments(F); + insertArguments(F); InsertedArguments = true; } @@ -1319,12 +1495,12 @@ // list for the function, but after we potentially read in the compaction // table. if (!InsertedArguments) { - insertArguments(F); + insertArguments(F); InsertedArguments = true; } if (BlockNum) - PARSE_ERROR("Already parsed basic blocks!"); + throw std::string("Already parsed basic blocks!"); BlockNum = ParseInstructionList(F); break; } @@ -1336,7 +1512,7 @@ default: At += Size; if (OldAt > At) - PARSE_ERROR("Wrapped around reading bytecode."); + throw std::string("Wrapped around reading bytecode."); break; } BlockEnd = MyEnd; @@ -1347,7 +1523,7 @@ // Make sure there were no references to non-existant basic blocks. if (BlockNum != ParsedBasicBlocks.size()) - PARSE_ERROR("Illegal basic block operand reference"); + throw std::string("Illegal basic block operand reference"); ParsedBasicBlocks.clear(); @@ -1394,12 +1570,16 @@ CompactionValues.clear(); freeTable(FunctionValues); - HANDLE(FunctionEnd(F)); + if (Handler) Handler->handleFunctionEnd(F); } +/// This function parses LLVM functions lazily. It obtains the type of the +/// function and records where the body of the function is in the bytecode +/// buffer. The caller can then use the ParseNextFunction and +/// ParseAllFunctionBodies to get handler events for the functions. void BytecodeReader::ParseFunctionLazily() { if (FunctionSignatureList.empty()) - PARSE_ERROR("FunctionSignatureList empty!"); + throw std::string("FunctionSignatureList empty!"); Function *Func = FunctionSignatureList.back(); FunctionSignatureList.pop_back(); @@ -1411,6 +1591,12 @@ At = BlockEnd; } +/// The ParserFunction method lazily parses one function. Use this method to +/// casue the parser to parse a specific function in the module. Note that +/// this will remove the function from what is to be included by +/// ParseAllFunctionBodies. +/// @see ParseAllFunctionBodies +/// @see ParseBytecode void BytecodeReader::ParseFunction(Function* Func) { // Find {start, end} pointers and slot in the map. If not there, we're done. LazyFunctionMap::iterator Fi = LazyFunctionLoadMap.find(Func); @@ -1430,6 +1616,13 @@ this->ParseFunctionBody( Func ); } +/// The ParseAllFunctionBodies method parses through all the previously +/// unparsed functions in the bytecode file. If you want to completely parse +/// a bytecode file, this method should be called after Parsebytecode because +/// Parsebytecode only records the locations in the bytecode file of where +/// the function definitions are located. This function uses that information +/// to materialize the functions. +/// @see ParseBytecode void BytecodeReader::ParseAllFunctionBodies() { LazyFunctionMap::iterator Fi = LazyFunctionLoadMap.begin(); LazyFunctionMap::iterator Fe = LazyFunctionLoadMap.end(); @@ -1443,14 +1636,17 @@ } } +/// Parse the global type list void BytecodeReader::ParseGlobalTypes() { - ValueTable T; - ParseConstantPool(T, ModuleTypes); + // Read the number of types + unsigned NumEntries = read_vbr_uint(); + ParseTypeConstants(ModuleTypes, NumEntries); } +/// Parse the Global info (types, global vars, constants) void BytecodeReader::ParseModuleGlobalInfo() { - HANDLE(ModuleGlobalsBegin()); + if (Handler) Handler->handleModuleGlobalsBegin(); // Read global variables... unsigned VarType = read_vbr_uint(); @@ -1458,6 +1654,8 @@ // VarType Fields: bit0 = isConstant, bit1 = hasInitializer, bit2,3,4 = // Linkage, bit4+ = slot# unsigned SlotNo = VarType >> 5; + bool isTypeType = sanitizeTypeId(SlotNo); + assert(!isTypeType && "Invalid type (type type) for global var!"); unsigned LinkageID = (VarType >> 2) & 7; bool isConstant = VarType & 1; bool hasInitializer = VarType & 2; @@ -1498,14 +1696,16 @@ } // Notify handler about the global value. - HANDLE(GlobalVariable( ElTy, isConstant, Linkage, SlotNo, initSlot )); + if (Handler) Handler->handleGlobalVariable( ElTy, isConstant, Linkage, SlotNo, initSlot ); // Get next item VarType = read_vbr_uint(); } // Read the function objects for all of the functions that are coming - unsigned FnSignature = read_vbr_uint(); + unsigned FnSignature = 0; + bool isTypeType = read_typeid(FnSignature); + assert(!isTypeType && "Invalid function type (type type) found"); while (FnSignature != Type::VoidTyID) { // List is terminated by Void const Type *Ty = getType(FnSignature); if (!isa(Ty) || @@ -1521,16 +1721,17 @@ // Insert the place hodler Function* Func = new Function(FTy, GlobalValue::InternalLinkage, - "", TheModule); + "", TheModule); insertValue(Func, FnSignature, ModuleValues); // Save this for later so we know type of lazily instantiated functions FunctionSignatureList.push_back(Func); - HANDLE(FunctionDeclaration(Func)); + if (Handler) Handler->handleFunctionDeclaration(Func); // Get Next function signature - FnSignature = read_vbr_uint(); + isTypeType = read_typeid(FnSignature); + assert(!isTypeType && "Invalid function type (type type) found"); } if (hasInconsistentModuleGlobalInfo) @@ -1545,9 +1746,11 @@ // At = BlockEnd; - HANDLE(ModuleGlobalsEnd()); + if (Handler) Handler->handleModuleGlobalsEnd(); } +/// Parse the version information and decode it by setting flags on the +/// Reader that enable backward compatibility of the reader. void BytecodeReader::ParseVersionInfo() { unsigned Version = read_vbr_uint(); @@ -1566,12 +1769,14 @@ hasInconsistentModuleGlobalInfo = false; hasExplicitPrimitiveZeros = false; hasRestrictedGEPTypes = false; + hasTypeDerivedFromValue = false; switch (RevisionNum) { case 0: // LLVM 1.0, 1.1 release version // Base LLVM 1.0 bytecode format. hasInconsistentModuleGlobalInfo = true; hasExplicitPrimitiveZeros = true; + // FALL THROUGH case 1: // LLVM 1.2 release version // LLVM 1.2 added explicit support for emitting strings efficiently. @@ -1584,6 +1789,12 @@ // structures and longs for sequential types. hasRestrictedGEPTypes = true; + // LLVM 1.2 and before had the Type class derive from Value class. This + // changed in release 1.3 and consequently LLVM 1.3 bytecode files are + // written differently because Types can no longer be part of the + // type planes for Values. + hasTypeDerivedFromValue = true; + // FALL THROUGH case 2: // LLVM 1.3 release version break; @@ -1595,9 +1806,10 @@ if (hasNoEndianness) Endianness = Module::AnyEndianness; if (hasNoPointerSize) PointerSize = Module::AnyPointerSize; - HANDLE(VersionInfo(RevisionNum, Endianness, PointerSize )); + if (Handler) Handler->handleVersionInfo(RevisionNum, Endianness, PointerSize ); } +/// Parse a whole module. void BytecodeReader::ParseModule() { unsigned Type, Size; @@ -1618,7 +1830,7 @@ case BytecodeFormat::GlobalTypePlane: if ( SeenGlobalTypePlane ) - PARSE_ERROR("Two GlobalTypePlane Blocks Encountered!"); + throw std::string("Two GlobalTypePlane Blocks Encountered!"); ParseGlobalTypes(); SeenGlobalTypePlane = true; @@ -1626,13 +1838,13 @@ case BytecodeFormat::ModuleGlobalInfo: if ( SeenModuleGlobalInfo ) - PARSE_ERROR("Two ModuleGlobalInfo Blocks Encountered!"); + throw std::string("Two ModuleGlobalInfo Blocks Encountered!"); ParseModuleGlobalInfo(); SeenModuleGlobalInfo = true; break; case BytecodeFormat::ConstantPool: - ParseConstantPool(ModuleValues, ModuleTypes); + ParseConstantPool(ModuleValues, ModuleTypes,false); break; case BytecodeFormat::Function: @@ -1668,20 +1880,22 @@ unsigned TypeSlot = getTypeSlot(GVType->getElementType()); if (Constant *CV = getConstantValue(TypeSlot, Slot)) { if (GV->hasInitializer()) - PARSE_ERROR("Global *already* has an initializer?!"); - HANDLE(GlobalInitializer(GV,CV)); + throw std::string("Global *already* has an initializer?!"); + if (Handler) Handler->handleGlobalInitializer(GV,CV); GV->setInitializer(CV); } else - PARSE_ERROR("Cannot find initializer value."); + throw std::string("Cannot find initializer value."); } /// Make sure we pulled them all out. If we didn't then there's a declaration /// but a missing body. That's not allowed. if (!FunctionSignatureList.empty()) - PARSE_ERROR( + throw std::string( "Function declared, but bytecode stream ended before definition"); } +/// This function completely parses a bytecode buffer given by the \p Buf +/// and \p Length parameters. void BytecodeReader::ParseBytecode( BufPtr Buf, unsigned Length, const std::string &ModuleID) { @@ -1693,7 +1907,7 @@ // Create the module TheModule = new Module(ModuleID); - HANDLE(Start(TheModule, Length)); + if (Handler) Handler->handleStart(TheModule, Length); // Read and check signature... unsigned Sig = read_uint(); @@ -1703,42 +1917,42 @@ // Tell the handler we're starting a module - HANDLE(ModuleBegin(ModuleID)); + if (Handler) Handler->handleModuleBegin(ModuleID); // Get the module block and size and verify unsigned Type, Size; read_block(Type, Size); if ( Type != BytecodeFormat::Module ) { PARSE_ERROR("Expected Module Block! At: " << unsigned(intptr_t(At)) - << ", Type:" << Type << ", Size:" << Size); + << ", Type:" << Type << ", Size:" << Size); } if ( At + Size != MemEnd ) { PARSE_ERROR("Invalid Top Level Block Length! At: " - << unsigned(intptr_t(At)) << ", Type:" << Type << ", Size:" << Size); + << unsigned(intptr_t(At)) << ", Type:" << Type << ", Size:" << Size); } // Parse the module contents this->ParseModule(); // Tell the handler we're done - HANDLE(ModuleEnd(ModuleID)); + if (Handler) Handler->handleModuleEnd(ModuleID); // Check for missing functions if ( hasFunctions() ) - PARSE_ERROR("Function expected, but bytecode stream ended!"); + throw std::string("Function expected, but bytecode stream ended!"); // Tell the handler we're - HANDLE(Finish()); + if (Handler) Handler->handleFinish(); } catch (std::string& errstr ) { - HANDLE(Error(errstr)); + if (Handler) Handler->handleError(errstr); freeState(); delete TheModule; TheModule = 0; throw; } catch (...) { std::string msg("Unknown Exception Occurred"); - HANDLE(Error(msg)); + if (Handler) Handler->handleError(msg); freeState(); delete TheModule; TheModule = 0; @@ -1751,63 +1965,5 @@ //===----------------------------------------------------------------------===// BytecodeHandler::~BytecodeHandler() {} -void BytecodeHandler::handleError(const std::string& str ) { } -void BytecodeHandler::handleStart(Module*m, unsigned Length ) { } -void BytecodeHandler::handleFinish() { } -void BytecodeHandler::handleModuleBegin(const std::string& id) { } -void BytecodeHandler::handleModuleEnd(const std::string& id) { } -void BytecodeHandler::handleVersionInfo( unsigned char RevisionNum, - Module::Endianness Endianness, Module::PointerSize PointerSize) { } -void BytecodeHandler::handleModuleGlobalsBegin() { } -void BytecodeHandler::handleGlobalVariable( - const Type* ElemType, bool isConstant, GlobalValue::LinkageTypes, - unsigned SlotNo, unsigned initSlot ) { } -void BytecodeHandler::handleType( const Type* Ty ) {} -void BytecodeHandler::handleFunctionDeclaration( - Function* Func ) {} -void BytecodeHandler::handleGlobalInitializer(GlobalVariable*, Constant* ) {} -void BytecodeHandler::handleModuleGlobalsEnd() { } -void BytecodeHandler::handleCompactionTableBegin() { } -void BytecodeHandler::handleCompactionTablePlane( - unsigned Ty, unsigned NumEntries) {} -void BytecodeHandler::handleCompactionTableType( - unsigned i, unsigned TypSlot, const Type* ) {} -void BytecodeHandler::handleCompactionTableValue( - unsigned i, unsigned TypSlot, unsigned ValSlot, const Type* ) {} -void BytecodeHandler::handleCompactionTableEnd() { } -void BytecodeHandler::handleSymbolTableBegin(Function*, SymbolTable*) { } -void BytecodeHandler::handleSymbolTablePlane( unsigned Ty, unsigned NumEntries, - const Type* Typ) { } -void BytecodeHandler::handleSymbolTableType( unsigned i, unsigned slot, - const std::string& name ) { } -void BytecodeHandler::handleSymbolTableValue( unsigned i, unsigned slot, - const std::string& name ) { } -void BytecodeHandler::handleSymbolTableEnd() { } -void BytecodeHandler::handleFunctionBegin( Function* Func, - unsigned Size ) {} -void BytecodeHandler::handleFunctionEnd( Function* Func) { } -void BytecodeHandler::handleBasicBlockBegin( unsigned blocknum) { } -bool BytecodeHandler::handleInstruction( unsigned Opcode, const Type* iType, - std::vector& Operands, unsigned Size) { - return Instruction::isTerminator(Opcode); - } -void BytecodeHandler::handleBasicBlockEnd(unsigned blocknum) { } -void BytecodeHandler::handleGlobalConstantsBegin() { } -void BytecodeHandler::handleConstantExpression( unsigned Opcode, - std::vector ArgVec, Constant* Val) { } -void BytecodeHandler::handleConstantValue( Constant * c ) { } -void BytecodeHandler::handleConstantArray( const ArrayType* AT, - std::vector& Elements, unsigned TypeSlot, Constant* Val ) { } -void BytecodeHandler::handleConstantStruct( const StructType* ST, - std::vector& ElementSlots, Constant* Val ) { } -void BytecodeHandler::handleConstantPointer( - const PointerType* PT, unsigned TypeSlot, GlobalValue*, Constant* Val) { } -void BytecodeHandler::handleConstantString( const ConstantArray* CA ) {} -void BytecodeHandler::handleGlobalConstantsEnd() {} -void BytecodeHandler::handleAlignment(unsigned numBytes) {} -void BytecodeHandler::handleBlock( - unsigned BType, const unsigned char* StartPtr, unsigned Size) {} -void BytecodeHandler::handleVBR32(unsigned Size ) {} -void BytecodeHandler::handleVBR64(unsigned Size ) {} // vim: sw=2 From llvm at cs.uiuc.edu Sun Jul 4 06:37:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 06:37:01 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/SlotCalculator.h Message-ID: <200407041136.GAA03778@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis: SlotCalculator.h (r1.20) removed --- Log message: Move SlotCalculator.h to lib/Bytecode/Writer since that is the only place that needs it after the Type != Value changes (bug 122: http://llvm.cs.uiuc.edu/PR122 ). --- Diffs of the changes: (+0 -0) From llvm at cs.uiuc.edu Sun Jul 4 06:39:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 06:39:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Writer/ConstantWriter.cpp Message-ID: <200407041138.GAA03806@zion.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Writer: ConstantWriter.cpp updated: 1.37 -> 1.38 --- Log message: - Type::TypeTyID doesn't exist any more (bug 122: http://llvm.cs.uiuc.edu/PR122 ) - Types don't have names any more, just write them on ostream directly --- Diffs of the changes: (+1 -5) Index: llvm/lib/Bytecode/Writer/ConstantWriter.cpp diff -u llvm/lib/Bytecode/Writer/ConstantWriter.cpp:1.37 llvm/lib/Bytecode/Writer/ConstantWriter.cpp:1.38 --- llvm/lib/Bytecode/Writer/ConstantWriter.cpp:1.37 Thu Jun 17 13:17:59 2004 +++ llvm/lib/Bytecode/Writer/ConstantWriter.cpp Sun Jul 4 06:37:54 2004 @@ -146,10 +146,6 @@ output_vbr(cast(CPV)->getValue(), Out); break; - case Type::TypeTyID: // Serialize type type - assert(0 && "Types should not be in the Constant!"); - break; - case Type::ArrayTyID: { const ConstantArray *CPA = cast(CPV); assert(!CPA->isString() && "Constant strings should be handled specially!"); @@ -193,7 +189,7 @@ case Type::LabelTyID: default: std::cerr << __FILE__ << ":" << __LINE__ << ": Don't know how to serialize" - << " type '" << CPV->getType()->getName() << "'\n"; + << " type '" << CPV->getType() << "'\n"; break; } return; From alkis at cs.uiuc.edu Sun Jul 4 06:43:01 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sun Jul 4 06:43:01 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/TEST.llc.report Message-ID: <200407041141.GAA04102@zion.cs.uiuc.edu> Changes in directory llvm/test/Programs: TEST.llc.report updated: 1.12 -> 1.13 --- Log message: Correctly match floating point numbers. --- Diffs of the changes: (+1 -1) Index: llvm/test/Programs/TEST.llc.report diff -u llvm/test/Programs/TEST.llc.report:1.12 llvm/test/Programs/TEST.llc.report:1.13 --- llvm/test/Programs/TEST.llc.report:1.12 Sun Jul 4 02:59:42 2004 +++ llvm/test/Programs/TEST.llc.report Sun Jul 4 06:41:46 2004 @@ -27,7 +27,7 @@ ["#MCInsts", '([0-9]+).*Number of machine instrs printed'], ["#IntOrig", '([0-9]+).*Number of original intervals'], ["#IntCoal", '([0-9]+).*Number of intervals after coalescing'], - ["Eff ", '([0-9]+).*Ratio of intervals processed over total intervals'], + ["Eff ", '(\d+\.\d+).*Ratio of intervals processed over total intervals'], [], # Number of transformations ["#store" , '([0-9]+).*Number of stores added'], From llvm at cs.uiuc.edu Sun Jul 4 06:44:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 06:44:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Writer/SlotCalculator.cpp SlotCalculator.h Message-ID: <200407041142.GAA04169@zion.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Writer: SlotCalculator.cpp updated: 1.57 -> 1.58 SlotCalculator.h updated: 1.19 -> 1.20 --- Log message: For bug 122: http://llvm.cs.uiuc.edu/PR122 : Separate Types from Values because Type no longer inherits from Value. The changes for this are too numerous to list. In essence, any data structure that contained a Value was doubled so that Types could be contained similarly. New members include Types, TypeMap, CompactionTypes, and CompactionTypeMap. Functions taking a Value* were overloaded with a variant that takes a Type* that acts on the new data structures. --- Diffs of the changes: (+236 -132) Index: llvm/lib/Bytecode/Writer/SlotCalculator.cpp diff -u llvm/lib/Bytecode/Writer/SlotCalculator.cpp:1.57 llvm/lib/Bytecode/Writer/SlotCalculator.cpp:1.58 --- llvm/lib/Bytecode/Writer/SlotCalculator.cpp:1.57 Thu Jun 24 19:35:55 2004 +++ llvm/lib/Bytecode/Writer/SlotCalculator.cpp Sun Jul 4 06:42:49 2004 @@ -14,19 +14,24 @@ // //===----------------------------------------------------------------------===// -#include "llvm/Analysis/SlotCalculator.h" +#include "SlotCalculator.h" #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" #include "llvm/iOther.h" +#include "llvm/Function.h" #include "llvm/Module.h" #include "llvm/SymbolTable.h" +#include "llvm/Type.h" #include "llvm/Analysis/ConstantsScanner.h" #include "Support/PostOrderIterator.h" #include "Support/STLExtras.h" #include +#include + using namespace llvm; #if 0 +#include #define SC_DEBUG(X) std::cerr << X #else #define SC_DEBUG(X) @@ -34,6 +39,7 @@ SlotCalculator::SlotCalculator(const Module *M ) { ModuleContainsAllFunctionConstants = false; + ModuleTypeLevel = 0; TheModule = M; // Preload table... Make sure that all of the primitive types are in the table @@ -42,7 +48,7 @@ SC_DEBUG("Inserting primitive types:\n"); for (unsigned i = 0; i < Type::FirstDerivedTyID; ++i) { assert(Type::getPrimitiveType((Type::TypeID)i)); - insertValue(Type::getPrimitiveType((Type::TypeID)i), true); + insertType(Type::getPrimitiveType((Type::TypeID)i), true); } if (M == 0) return; // Empty table... @@ -59,7 +65,7 @@ SC_DEBUG("Inserting primitive types:\n"); for (unsigned i = 0; i < Type::FirstDerivedTyID; ++i) { assert(Type::getPrimitiveType((Type::TypeID)i)); - insertValue(Type::getPrimitiveType((Type::TypeID)i), true); + insertType(Type::getPrimitiveType((Type::TypeID)i), true); } if (TheModule == 0) return; // Empty table... @@ -78,8 +84,13 @@ return I->second; } +unsigned SlotCalculator::getGlobalSlot(const Type* T) const { + std::map::const_iterator I = TypeMap.find(T); + assert(I != TypeMap.end() && "Didn't find global slot entry!"); + return I->second; +} + SlotCalculator::TypePlane &SlotCalculator::getPlane(unsigned Plane) { - unsigned PIdx = Plane; if (CompactionTable.empty()) { // No compaction table active? // fall out } else if (!CompactionTable[Plane].empty()) { // Compaction table active. @@ -89,22 +100,21 @@ // Final case: compaction table active, but this plane is not // compactified. If the type plane is compactified, unmap back to the // global type plane corresponding to "Plane". - if (!CompactionTable[Type::TypeTyID].empty()) { - const Type *Ty = cast(CompactionTable[Type::TypeTyID][Plane]); - std::map::iterator It = NodeMap.find(Ty); - assert(It != NodeMap.end() && "Type not in global constant map?"); - PIdx = It->second; + if (!CompactionTypes.empty()) { + const Type *Ty = CompactionTypes[Plane]; + TypeMapType::iterator It = TypeMap.find(Ty); + assert(It != TypeMap.end() && "Type not in global constant map?"); + Plane = It->second; } } // Okay we are just returning an entry out of the main Table. Make sure the // plane exists and return it. - if (PIdx >= Table.size()) - Table.resize(PIdx+1); - return Table[PIdx]; + if (Plane >= Table.size()) + Table.resize(Plane+1); + return Table[Plane]; } - // processModule - Process all of the module level function declarations and // types that are available. // @@ -135,28 +145,27 @@ // that contain constant strings so that the strings occur at the start of the // plane, not somewhere in the middle. // - TypePlane &Types = Table[Type::TypeTyID]; for (unsigned plane = 0, e = Table.size(); plane != e; ++plane) { if (const ArrayType *AT = dyn_cast(Types[plane])) if (AT->getElementType() == Type::SByteTy || - AT->getElementType() == Type::UByteTy) { - TypePlane &Plane = Table[plane]; - unsigned FirstNonStringID = 0; - for (unsigned i = 0, e = Plane.size(); i != e; ++i) - if (isa(Plane[i]) || - cast(Plane[i])->isString()) { - // Check to see if we have to shuffle this string around. If not, - // don't do anything. - if (i != FirstNonStringID) { - // Swap the plane entries.... - std::swap(Plane[i], Plane[FirstNonStringID]); - - // Keep the NodeMap up to date. - NodeMap[Plane[i]] = i; - NodeMap[Plane[FirstNonStringID]] = FirstNonStringID; - } - ++FirstNonStringID; - } + AT->getElementType() == Type::UByteTy) { + TypePlane &Plane = Table[plane]; + unsigned FirstNonStringID = 0; + for (unsigned i = 0, e = Plane.size(); i != e; ++i) + if (isa(Plane[i]) || + cast(Plane[i])->isString()) { + // Check to see if we have to shuffle this string around. If not, + // don't do anything. + if (i != FirstNonStringID) { + // Swap the plane entries.... + std::swap(Plane[i], Plane[FirstNonStringID]); + + // Keep the NodeMap up to date. + NodeMap[Plane[i]] = i; + NodeMap[Plane[FirstNonStringID]] = FirstNonStringID; + } + ++FirstNonStringID; + } } } @@ -178,11 +187,11 @@ F != E; ++F) { for (const_inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I){ for (unsigned op = 0, e = I->getNumOperands(); op != e; ++op) - if (isa(I->getOperand(op))) - getOrCreateSlot(I->getOperand(op)); + if (isa(I->getOperand(op))) + getOrCreateSlot(I->getOperand(op)); getOrCreateSlot(I->getType()); if (const VANextInst *VAN = dyn_cast(&*I)) - getOrCreateSlot(VAN->getArgType()); + getOrCreateSlot(VAN->getArgType()); } processSymbolTableConstants(&F->getSymbolTable()); } @@ -201,31 +210,24 @@ // all non-value types are pushed to the end of the type table, giving nice // low numbers to the types that can be used by instructions, thus reducing // the amount of explodage we suffer. - if (Table[Type::TypeTyID].size() >= 64) { - // Scan through the type table moving value types to the start of the table. - TypePlane *Types = &Table[Type::TypeTyID]; + if (Types.size() >= 64) { unsigned FirstNonValueTypeID = 0; - for (unsigned i = 0, e = Types->size(); i != e; ++i) - if (cast((*Types)[i])->isFirstClassType() || - cast((*Types)[i])->isPrimitiveType()) { + for (unsigned i = 0, e = Types.size(); i != e; ++i) + if (Types[i]->isFirstClassType() || Types[i]->isPrimitiveType()) { // Check to see if we have to shuffle this type around. If not, don't // do anything. if (i != FirstNonValueTypeID) { - assert(i != Type::TypeTyID && FirstNonValueTypeID != Type::TypeTyID && - "Cannot move around the type plane!"); - // Swap the type ID's. - std::swap((*Types)[i], (*Types)[FirstNonValueTypeID]); + std::swap(Types[i], Types[FirstNonValueTypeID]); - // Keep the NodeMap up to date. - NodeMap[(*Types)[i]] = i; - NodeMap[(*Types)[FirstNonValueTypeID]] = FirstNonValueTypeID; + // Keep the TypeMap up to date. + TypeMap[Types[i]] = i; + TypeMap[Types[FirstNonValueTypeID]] = FirstNonValueTypeID; // When we move a type, make sure to move its value plane as needed. if (Table.size() > FirstNonValueTypeID) { if (Table.size() <= i) Table.resize(i+1); std::swap(Table[i], Table[FirstNonValueTypeID]); - Types = &Table[Type::TypeTyID]; } } ++FirstNonValueTypeID; @@ -248,7 +250,7 @@ for (SymbolTable::plane_const_iterator PI = ST->plane_begin(), PE = ST->plane_end(); PI != PE; ++PI) for (SymbolTable::value_const_iterator VI = PI->second.begin(), - VE = PI->second.end(); VI != VE; ++VI) + VE = PI->second.end(); VI != VE; ++VI) getOrCreateSlot(VI->second); } @@ -262,14 +264,15 @@ for (SymbolTable::plane_const_iterator PI = ST->plane_begin(), PE = ST->plane_end(); PI != PE; ++PI) for (SymbolTable::value_const_iterator VI = PI->second.begin(), - VE = PI->second.end(); VI != VE; ++VI) + VE = PI->second.end(); VI != VE; ++VI) if (isa(VI->second)) - getOrCreateSlot(VI->second); + getOrCreateSlot(VI->second); } void SlotCalculator::incorporateFunction(const Function *F) { - assert(ModuleLevel.size() == 0 && "Module already incorporated!"); + assert((ModuleLevel.size() == 0 || + ModuleTypeLevel == 0) && "Module already incorporated!"); SC_DEBUG("begin processFunction!\n"); @@ -281,6 +284,7 @@ ModuleLevel.resize(getNumPlanes()); for (unsigned i = 0, e = getNumPlanes(); i != e; ++i) ModuleLevel[i] = getPlane(i).size(); + ModuleTypeLevel = Types.size(); // Iterate over function arguments, adding them to the value table... for(Function::const_aiterator I = F->abegin(), E = F->aend(); I != E; ++I) @@ -295,8 +299,12 @@ // Emit all of the constants that are being used by the instructions in // the function... - for_each(constant_begin(F), constant_end(F), - bind_obj(this, &SlotCalculator::getOrCreateSlot)); + constant_iterator CI = constant_begin(F); + constant_iterator CE = constant_end(F); + while ( CI != CE ) { + this->getOrCreateSlot(*CI); + ++CI; + } // If there is a symbol table, it is possible that the user has names for // constants that are not being used. In this case, we will have problems @@ -328,13 +336,15 @@ } void SlotCalculator::purgeFunction() { - assert(ModuleLevel.size() != 0 && "Module not incorporated!"); + assert((ModuleLevel.size() != 0 || + ModuleTypeLevel != 0) && "Module not incorporated!"); unsigned NumModuleTypes = ModuleLevel.size(); SC_DEBUG("begin purgeFunction!\n"); // First, free the compaction map if used. CompactionNodeMap.clear(); + CompactionTypeMap.clear(); // Next, remove values from existing type planes for (unsigned i = 0; i != NumModuleTypes; ++i) { @@ -355,8 +365,10 @@ // We don't need this state anymore, free it up. ModuleLevel.clear(); + ModuleTypeLevel = 0; // Finally, remove any type planes defined by the function... + CompactionTypes.clear(); if (!CompactionTable.empty()) { CompactionTable.clear(); } else { @@ -379,8 +391,7 @@ } static inline bool hasNullValue(unsigned TyID) { - return TyID != Type::LabelTyID && TyID != Type::TypeTyID && - TyID != Type::VoidTyID; + return TyID != Type::LabelTyID && TyID != Type::VoidTyID; } /// getOrCreateCompactionTableSlot - This method is used to build up the initial @@ -395,15 +406,13 @@ // Make sure the type is in the table. unsigned Ty; - if (!CompactionTable[Type::TypeTyID].empty()) + if (!CompactionTypes.empty()) Ty = getOrCreateCompactionTableSlot(V->getType()); else // If the type plane was decompactified, use the global plane ID Ty = getSlot(V->getType()); if (CompactionTable.size() <= Ty) CompactionTable.resize(Ty+1); - assert(!isa(V) || ModuleLevel.empty()); - TypePlane &TyPlane = CompactionTable[Ty]; // Make sure to insert the null entry if the thing we are inserting is not a @@ -422,6 +431,20 @@ return SlotNo; } +/// getOrCreateCompactionTableSlot - This method is used to build up the initial +/// approximation of the compaction table. +unsigned SlotCalculator::getOrCreateCompactionTableSlot(const Type *T) { + std::map::iterator I = + CompactionTypeMap.lower_bound(T); + if (I != CompactionTypeMap.end() && I->first == T) + return I->second; // Already exists? + + unsigned SlotNo = CompactionTypes.size(); + SC_DEBUG("Inserting Compaction Type #" << SlotNo << ": " << T << "\n"); + CompactionTypes.push_back(T); + CompactionTypeMap.insert(std::make_pair(T, SlotNo)); + return SlotNo; +} /// buildCompactionTable - Since all of the function constants and types are /// stored in the module-level constant table, we don't need to emit a function @@ -432,12 +455,13 @@ /// identifiers. void SlotCalculator::buildCompactionTable(const Function *F) { assert(CompactionNodeMap.empty() && "Compaction table already built!"); + assert(CompactionTypeMap.empty() && "Compaction types already built!"); // First step, insert the primitive types. - CompactionTable.resize(Type::TypeTyID+1); - for (unsigned i = 0; i != Type::FirstDerivedTyID; ++i) { + CompactionTable.resize(Type::LastPrimitiveTyID+1); + for (unsigned i = 0; i <= Type::LastPrimitiveTyID; ++i) { const Type *PrimTy = Type::getPrimitiveType((Type::TypeID)i); - CompactionTable[Type::TypeTyID].push_back(PrimTy); - CompactionNodeMap[PrimTy] = i; + CompactionTypes.push_back(PrimTy); + CompactionTypeMap[PrimTy] = i; } // Next, include any types used by function arguments. @@ -445,7 +469,7 @@ getOrCreateCompactionTableSlot(I->getType()); // Next, find all of the types and values that are referred to by the - // instructions in the program. + // instructions in the function. for (const_inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I) { getOrCreateCompactionTableSlot(I->getType()); for (unsigned op = 0, e = I->getNumOperands(); op != e; ++op) @@ -466,19 +490,22 @@ for (SymbolTable::plane_const_iterator PI = ST.plane_begin(), PE = ST.plane_end(); PI != PE; ++PI) for (SymbolTable::value_const_iterator VI = PI->second.begin(), - VE = PI->second.end(); VI != VE; ++VI) + VE = PI->second.end(); VI != VE; ++VI) if (isa(VI->second) || isa(VI->second)) - getOrCreateCompactionTableSlot(VI->second); + getOrCreateCompactionTableSlot(VI->second); // Now that we have all of the values in the table, and know what types are // referenced, make sure that there is at least the zero initializer in any // used type plane. Since the type was used, we will be emitting instructions // to the plane even if there are no constants in it. - CompactionTable.resize(CompactionTable[Type::TypeTyID].size()); + CompactionTable.resize(CompactionTypes.size()); for (unsigned i = 0, e = CompactionTable.size(); i != e; ++i) - if (CompactionTable[i].empty() && i != Type::VoidTyID && + if (CompactionTable[i].empty() && (i != Type::VoidTyID) && i != Type::LabelTyID) { - const Type *Ty = cast(CompactionTable[Type::TypeTyID][i]); + const Type *Ty = CompactionTypes[i]; + SC_DEBUG("Getting Null Value #" << i << " for Type " << Ty << "\n"); + assert(Ty->getTypeID() != Type::VoidTyID); + assert(Ty->getTypeID() != Type::LabelTyID); getOrCreateCompactionTableSlot(Constant::getNullValue(Ty)); } @@ -487,13 +514,13 @@ // it will not save us anything. Because we have not yet incorporated the // function body itself yet, we don't know whether or not it's a good idea to // compactify other planes. We will defer this decision until later. - TypePlane &GlobalTypes = Table[Type::TypeTyID]; + TypeList &GlobalTypes = Types; // All of the values types will be scrunched to the start of the types plane // of the global table. Figure out just how many there are. assert(!GlobalTypes.empty() && "No global types???"); unsigned NumFCTypes = GlobalTypes.size()-1; - while (!cast(GlobalTypes[NumFCTypes])->isFirstClassType()) + while (!GlobalTypes[NumFCTypes]->isFirstClassType()) --NumFCTypes; // If there are fewer that 64 types, no instructions will be exploded due to @@ -506,29 +533,27 @@ // CompactionNodeMap for non-types though. std::vector TmpCompactionTable; std::swap(CompactionTable, TmpCompactionTable); - TypePlane Types; - std::swap(Types, TmpCompactionTable[Type::TypeTyID]); + TypeList TmpTypes; + std::swap(TmpTypes, CompactionTypes); // Move each plane back over to the uncompactified plane - while (!Types.empty()) { - const Type *Ty = cast(Types.back()); - Types.pop_back(); - CompactionNodeMap.erase(Ty); // Decompactify type! - - if (Ty != Type::TypeTy) { - // Find the global slot number for this type. - int TySlot = getSlot(Ty); - assert(TySlot != -1 && "Type doesn't exist in global table?"); - - // Now we know where to put the compaction table plane. - if (CompactionTable.size() <= unsigned(TySlot)) - CompactionTable.resize(TySlot+1); - // Move the plane back into the compaction table. - std::swap(CompactionTable[TySlot], TmpCompactionTable[Types.size()]); + while (!TmpTypes.empty()) { + const Type *Ty = TmpTypes.back(); + TmpTypes.pop_back(); + CompactionTypeMap.erase(Ty); // Decompactify type! + + // Find the global slot number for this type. + int TySlot = getSlot(Ty); + assert(TySlot != -1 && "Type doesn't exist in global table?"); + + // Now we know where to put the compaction table plane. + if (CompactionTable.size() <= unsigned(TySlot)) + CompactionTable.resize(TySlot+1); + // Move the plane back into the compaction table. + std::swap(CompactionTable[TySlot], TmpCompactionTable[TmpTypes.size()]); - // And remove the empty plane we just moved in. - TmpCompactionTable.pop_back(); - } + // And remove the empty plane we just moved in. + TmpCompactionTable.pop_back(); } } } @@ -544,9 +569,9 @@ /// Note that the type plane has already been compactified if possible. /// void SlotCalculator::pruneCompactionTable() { - TypePlane &TyPlane = CompactionTable[Type::TypeTyID]; + TypeList &TyPlane = CompactionTypes; for (unsigned ctp = 0, e = CompactionTable.size(); ctp != e; ++ctp) - if (ctp != Type::TypeTyID && !CompactionTable[ctp].empty()) { + if (!CompactionTable[ctp].empty()) { TypePlane &CPlane = CompactionTable[ctp]; unsigned GlobalSlot = ctp; if (!TyPlane.empty()) @@ -603,7 +628,6 @@ } } - int SlotCalculator::getSlot(const Value *V) const { // If there is a CompactionTable active... if (!CompactionNodeMap.empty()) { @@ -626,6 +650,23 @@ return -1; } +int SlotCalculator::getSlot(const Type*T) const { + // If there is a CompactionTable active... + if (!CompactionTypeMap.empty()) { + std::map::const_iterator I = + CompactionTypeMap.find(T); + if (I != CompactionTypeMap.end()) + return (int)I->second; + // Otherwise, if it's not in the compaction table, it must be in a + // non-compactified plane. + } + + std::map::const_iterator I = TypeMap.find(T); + if (I != TypeMap.end()) + return (int)I->second; + + return -1; +} int SlotCalculator::getOrCreateSlot(const Value *V) { if (V->getType() == Type::VoidTy) return -1; @@ -665,6 +706,11 @@ return insertValue(V); } +int SlotCalculator::getOrCreateSlot(const Type* T) { + int SlotNo = getSlot(T); // Check to see if it's already in! + if (SlotNo != -1) return SlotNo; + return insertType(T); +} int SlotCalculator::insertValue(const Value *D, bool dontIgnore) { assert(D && "Can't insert a null value!"); @@ -674,7 +720,7 @@ // insert the value into the compaction map, not into the global map. if (!CompactionNodeMap.empty()) { if (D->getType() == Type::VoidTy) return -1; // Do not insert void values - assert(!isa(D) && !isa(D) && !isa(D) && + assert(!isa(D) && !isa(D) && "Types, constants, and globals should be in global SymTab!"); int Plane = getSlot(D->getType()); @@ -694,41 +740,46 @@ return -1; // We do need types unconditionally though } - // If it's a type, make sure that all subtypes of the type are included... - if (const Type *TheTy = dyn_cast(D)) { + // Okay, everything is happy, actually insert the silly value now... + return doInsertValue(D); +} - // Insert the current type before any subtypes. This is important because - // recursive types elements are inserted in a bottom up order. Changing - // this here can break things. For example: - // - // global { \2 * } { { \2 }* null } - // - int ResultSlot = doInsertValue(TheTy); - SC_DEBUG(" Inserted type: " << TheTy->getDescription() << " slot=" << - ResultSlot << "\n"); +int SlotCalculator::insertType(const Type *Ty, bool dontIgnore) { + assert(Ty && "Can't insert a null type!"); + assert(getSlot(Ty) == -1 && "Type is already in the table!"); - // Loop over any contained types in the definition... in post - // order. - // - for (po_iterator I = po_begin(TheTy), E = po_end(TheTy); - I != E; ++I) { - if (*I != TheTy) { - const Type *SubTy = *I; - // If we haven't seen this sub type before, add it to our type table! - if (getSlot(SubTy) == -1) { - SC_DEBUG(" Inserting subtype: " << SubTy->getDescription() << "\n"); - SC_DEBUG(int Slot = ); - doInsertValue(SubTy); - SC_DEBUG(" Inserted subtype: " << SubTy->getDescription() << - " slot=" << Slot << "\n"); - } + // If we are building a compaction map, and if this plane is being compacted, + // insert the value into the compaction map, not into the global map. + if (!CompactionTypeMap.empty()) { + getOrCreateCompactionTableSlot(Ty); + } + + // Insert the current type before any subtypes. This is important because + // recursive types elements are inserted in a bottom up order. Changing + // this here can break things. For example: + // + // global { \2 * } { { \2 }* null } + // + int ResultSlot = doInsertType(Ty); + SC_DEBUG(" Inserted type: " << Ty->getDescription() << " slot=" << + ResultSlot << "\n"); + + // Loop over any contained types in the definition... in post + // order. + for (po_iterator I = po_begin(Ty), E = po_end(Ty); + I != E; ++I) { + if (*I != Ty) { + const Type *SubTy = *I; + // If we haven't seen this sub type before, add it to our type table! + if (getSlot(SubTy) == -1) { + SC_DEBUG(" Inserting subtype: " << SubTy->getDescription() << "\n"); + int Slot = doInsertType(SubTy); + SC_DEBUG(" Inserted subtype: " << SubTy->getDescription() << + " slot=" << Slot << "\n"); } } - return ResultSlot; } - - // Okay, everything is happy, actually insert the silly value now... - return doInsertValue(D); + return ResultSlot; } // doInsertValue - This is a small helper function to be called only @@ -750,7 +801,7 @@ ValSlot = getGlobalSlot(Typ); if (ValSlot == -1) { // Have we already entered this type? // Nope, this is the first we have seen the type, process it. - ValSlot = insertValue(Typ, true); + ValSlot = insertType(Typ, true); assert(ValSlot != -1 && "ProcessType returned -1 for a type?"); } Ty = (unsigned)ValSlot; @@ -778,10 +829,25 @@ Table[Ty].push_back(D); SC_DEBUG(" Inserting value [" << Ty << "] = " << D << " slot=" << - DestSlot << " ["); + DestSlot << " ["); // G = Global, C = Constant, T = Type, F = Function, o = other SC_DEBUG((isa(D) ? "G" : (isa(D) ? "C" : - (isa(D) ? "T" : (isa(D) ? "F" : "o"))))); + (isa(D) ? "F" : "o")))); SC_DEBUG("]\n"); return (int)DestSlot; } + +// doInsertType - This is a small helper function to be called only +// be insertType. +// +int SlotCalculator::doInsertType(const Type *Ty) { + + // Insert node into table and NodeMap... + unsigned DestSlot = TypeMap[Ty] = Types.size(); + Types.push_back(Ty); + + SC_DEBUG(" Inserting type [" << DestSlot << "] = " << Ty << "\n" ); + return (int)DestSlot; +} + +// vim: sw=2 ai Index: llvm/lib/Bytecode/Writer/SlotCalculator.h diff -u llvm/lib/Bytecode/Writer/SlotCalculator.h:1.19 llvm/lib/Bytecode/Writer/SlotCalculator.h:1.20 --- llvm/lib/Bytecode/Writer/SlotCalculator.h:1.19 Wed May 26 02:37:11 2004 +++ llvm/lib/Bytecode/Writer/SlotCalculator.h Sun Jul 4 06:42:49 2004 @@ -26,6 +26,7 @@ namespace llvm { class Value; +class Type; class Module; class Function; class SymbolTable; @@ -34,9 +35,15 @@ class SlotCalculator { const Module *TheModule; + typedef std::vector TypeList; typedef std::vector TypePlane; std::vector Table; - std::map NodeMap; + TypeList Types; + typedef std::map NodeMapType; + NodeMapType NodeMap; + + typedef std::map TypeMapType; + TypeMapType TypeMap; /// ConstantStrings - If we are indexing for a bytecode file, this keeps track /// of all of the constants strings that need to be emitted. @@ -46,6 +53,7 @@ /// and which values belong to the currently incorporated function. /// std::vector ModuleLevel; + unsigned ModuleTypeLevel; /// ModuleContainsAllFunctionConstants - This flag is set to true if all /// function constants are incorporated into the module constant table. This @@ -57,7 +65,11 @@ /// instructions in a function body. The 'getSlot()' method automatically /// returns these entries if applicable, or the global entries if not. std::vector CompactionTable; - std::map CompactionNodeMap; + TypeList CompactionTypes; + typedef std::map CompactionNodeMapType; + CompactionNodeMapType CompactionNodeMap; + typedef std::map CompactionTypeMapType; + CompactionTypeMapType CompactionTypeMap; SlotCalculator(const SlotCalculator &); // DO NOT IMPLEMENT void operator=(const SlotCalculator &); // DO NOT IMPLEMENT @@ -70,10 +82,12 @@ /// plane. This returns < 0 on error! /// int getSlot(const Value *V) const; + int getSlot(const Type* T) const; /// getGlobalSlot - Return a slot number from the global table. This can only /// be used when a compaction table is active. unsigned getGlobalSlot(const Value *V) const; + unsigned getGlobalSlot(const Type *V) const; inline unsigned getNumPlanes() const { if (CompactionTable.empty()) @@ -81,11 +95,29 @@ else return CompactionTable.size(); } + + inline unsigned getNumTypes() const { + if (CompactionTypes.empty()) + return Types.size(); + else + return CompactionTypes.size(); + } + inline unsigned getModuleLevel(unsigned Plane) const { return Plane < ModuleLevel.size() ? ModuleLevel[Plane] : 0; } + /// Returns the number of types in the type list that are at module level + inline unsigned getModuleTypeLevel() const { + return ModuleTypeLevel; + } + TypePlane &getPlane(unsigned Plane); + TypeList& getTypes() { + if (!CompactionTypes.empty()) + return CompactionTypes; + return Types; + } /// incorporateFunction/purgeFunction - If you'd like to deal with a function, /// use these two methods to get its data into the SlotCalculator! @@ -104,21 +136,26 @@ return CompactionTable; } + const TypeList& getCompactionTypes() const { return CompactionTypes; } + private: // getOrCreateSlot - Values can be crammed into here at will... if // they haven't been inserted already, they get inserted, otherwise // they are ignored. // int getOrCreateSlot(const Value *D); + int getOrCreateSlot(const Type* T); // insertValue - Insert a value into the value table... Return the // slot that it occupies, or -1 if the declaration is to be ignored // because of the IgnoreNamedNodes flag. // int insertValue(const Value *D, bool dontIgnore = false); + int insertType(const Type* T, bool dontIgnore = false ); // doInsertValue - Small helper function to be called only be insertVal. int doInsertValue(const Value *D); + int doInsertType(const Type*T); // processModule - Process all of the module level function declarations and // types that are available. @@ -133,6 +170,7 @@ void buildCompactionTable(const Function *F); unsigned getOrCreateCompactionTableSlot(const Value *V); + unsigned getOrCreateCompactionTableSlot(const Type *V); void pruneCompactionTable(); }; From llvm at cs.uiuc.edu Sun Jul 4 06:45:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 06:45:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Writer/WriterInternals.h Message-ID: <200407041144.GAA04328@zion.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Writer: WriterInternals.h updated: 1.20 -> 1.21 --- Log message: Add new methods outputTypes and outputCompactionTypes for handling Types separately from Values. This needed for bug 122: http://llvm.cs.uiuc.edu/PR122 . --- Diffs of the changes: (+4 -2) Index: llvm/lib/Bytecode/Writer/WriterInternals.h diff -u llvm/lib/Bytecode/Writer/WriterInternals.h:1.20 llvm/lib/Bytecode/Writer/WriterInternals.h:1.21 --- llvm/lib/Bytecode/Writer/WriterInternals.h:1.20 Tue Jan 20 13:50:34 2004 +++ llvm/lib/Bytecode/Writer/WriterInternals.h Sun Jul 4 06:44:27 2004 @@ -19,10 +19,10 @@ #ifndef LLVM_LIB_BYTECODE_WRITER_WRITERINTERNALS_H #define LLVM_LIB_BYTECODE_WRITER_WRITERINTERNALS_H -#include "llvm/Bytecode/Writer.h" #include "WriterPrimitives.h" +#include "SlotCalculator.h" +#include "llvm/Bytecode/Writer.h" #include "llvm/Bytecode/Format.h" -#include "llvm/Analysis/SlotCalculator.h" #include "llvm/Instruction.h" namespace llvm { @@ -38,6 +38,7 @@ void outputConstantStrings(); void outputFunction(const Function *F); void outputCompactionTable(); + void outputCompactionTypes(unsigned StartNo); void outputCompactionTablePlane(unsigned PlaneNo, const std::vector &TypePlane, unsigned StartNo); @@ -46,6 +47,7 @@ void outputModuleInfoBlock(const Module *C); void outputSymbolTable(const SymbolTable &ST); + void outputTypes(unsigned StartNo); void outputConstantsInPlane(const std::vector &Plane, unsigned StartNo); void outputConstant(const Constant *CPV); From llvm at cs.uiuc.edu Sun Jul 4 06:47:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 06:47:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Writer/Writer.cpp Message-ID: <200407041145.GAA04482@zion.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Writer: Writer.cpp updated: 1.67 -> 1.68 --- Log message: Implement new output functions for types and compacted type planes. Also remove use of Type::TypeTyID and Type::TypeTy since Type no longer inherits Value. --- Diffs of the changes: (+68 -51) Index: llvm/lib/Bytecode/Writer/Writer.cpp diff -u llvm/lib/Bytecode/Writer/Writer.cpp:1.67 llvm/lib/Bytecode/Writer/Writer.cpp:1.68 --- llvm/lib/Bytecode/Writer/Writer.cpp:1.67 Fri Jun 25 15:52:10 2004 +++ llvm/lib/Bytecode/Writer/Writer.cpp Sun Jul 4 06:45:47 2004 @@ -61,17 +61,10 @@ output_vbr(Version, Out); align32(Out); + // The Global type plane comes first { - BytecodeBlock CPool(BytecodeFormat::GlobalTypePlane, Out); - - // Write the type plane for types first because earlier planes (e.g. for a - // primitive type like float) may have constants constructed using types - // coming later (e.g., via getelementptr from a pointer type). The type - // plane is needed before types can be fwd or bkwd referenced. - const std::vector &Plane = Table.getPlane(Type::TypeTyID); - assert(!Plane.empty() && "No types at all?"); - unsigned ValNo = Type::FirstDerivedTyID; // Start at the derived types... - outputConstantsInPlane(Plane, ValNo); // Write out the types + BytecodeBlock CPool(BytecodeFormat::GlobalTypePlane, Out ); + outputTypes(Type::FirstDerivedTyID); } // The ModuleInfoBlock follows directly after the type information @@ -88,6 +81,25 @@ outputSymbolTable(M->getSymbolTable()); } +void BytecodeWriter::outputTypes(unsigned TypeNum) +{ + // Write the type plane for types first because earlier planes (e.g. for a + // primitive type like float) may have constants constructed using types + // coming later (e.g., via getelementptr from a pointer type). The type + // plane is needed before types can be fwd or bkwd referenced. + const std::vector& Types = Table.getTypes(); + assert(!Types.empty() && "No types at all?"); + assert(TypeNum <= Types.size() && "Invalid TypeNo index"); + + unsigned NumEntries = Types.size() - TypeNum; + + // Output type header: [num entries] + output_vbr(NumEntries, Out); + + for (unsigned i = TypeNum; i < TypeNum+NumEntries; ++i) + outputType(Types[i]); +} + // Helper function for outputConstants(). // Writes out all the constants in the plane Plane starting at entry StartNo. // @@ -104,8 +116,7 @@ /*empty*/; unsigned NC = ValNo; // Number of constants - for (; NC < Plane.size() && - (isa(Plane[NC]) || isa(Plane[NC])); NC++) + for (; NC < Plane.size() && (isa(Plane[NC])); NC++) /*empty*/; NC -= ValNo; // Convert from index into count if (NC == 0) return; // Skip empty type planes... @@ -122,24 +133,16 @@ assert (Slot != -1 && "Type in constant pool but not in function!!"); output_vbr((unsigned)Slot, Out); - //cerr << "Emitting " << NC << " constants of type '" - // << Plane.front()->getType()->getName() << "' = Slot #" << Slot << "\n"; - for (unsigned i = ValNo; i < ValNo+NC; ++i) { const Value *V = Plane[i]; if (const Constant *CPV = dyn_cast(V)) { - //cerr << "Serializing value: <" << V->getType() << ">: " << V << ":" - // << Out.size() << "\n"; outputConstant(CPV); - } else { - outputType(cast(V)); } } } static inline bool hasNullValue(unsigned TyID) { - return TyID != Type::LabelTyID && TyID != Type::TypeTyID && - TyID != Type::VoidTyID; + return TyID != Type::LabelTyID && TyID != Type::VoidTyID; } void BytecodeWriter::outputConstants(bool isFunction) { @@ -149,36 +152,31 @@ unsigned NumPlanes = Table.getNumPlanes(); // Output the type plane before any constants! - if (isFunction && NumPlanes > Type::TypeTyID) { - const std::vector &Plane = Table.getPlane(Type::TypeTyID); - if (!Plane.empty()) { // Skip empty type planes... - unsigned ValNo = Table.getModuleLevel(Type::TypeTyID); - outputConstantsInPlane(Plane, ValNo); - } + if (isFunction) { + outputTypes( Table.getModuleTypeLevel() ); } // Output module-level string constants before any other constants.x if (!isFunction) outputConstantStrings(); - for (unsigned pno = 0; pno != NumPlanes; pno++) - if (pno != Type::TypeTyID) { // Type plane handled above. - const std::vector &Plane = Table.getPlane(pno); - if (!Plane.empty()) { // Skip empty type planes... - unsigned ValNo = 0; - if (isFunction) // Don't re-emit module constants - ValNo += Table.getModuleLevel(pno); - - if (hasNullValue(pno)) { - // Skip zero initializer - if (ValNo == 0) - ValNo = 1; - } - - // Write out constants in the plane - outputConstantsInPlane(Plane, ValNo); + for (unsigned pno = 0; pno != NumPlanes; pno++) { + const std::vector &Plane = Table.getPlane(pno); + if (!Plane.empty()) { // Skip empty type planes... + unsigned ValNo = 0; + if (isFunction) // Don't re-emit module constants + ValNo += Table.getModuleLevel(pno); + + if (hasNullValue(pno)) { + // Skip zero initializer + if (ValNo == 0) + ValNo = 1; } + + // Write out constants in the plane + outputConstantsInPlane(Plane, ValNo); } + } } static unsigned getEncodedLinkage(const GlobalValue *GV) { @@ -269,7 +267,7 @@ assert(StartNo < Plane.size() && End <= Plane.size()); // Do not emit the null initializer! - if (PlaneNo != Type::TypeTyID) ++StartNo; + ++StartNo; // Figure out which encoding to use. By far the most common case we have is // to emit 0-2 entries in a compaction table plane. @@ -290,18 +288,38 @@ output_vbr(Table.getGlobalSlot(Plane[i]), Out); } +void BytecodeWriter::outputCompactionTypes(unsigned StartNo) { + // Get the compaction type table from the slot calculator + const std::vector &CTypes = Table.getCompactionTypes(); + + // The compaction types may have been uncompactified back to the + // global types. If so, we just write an empty table + if (CTypes.size() == 0 ) { + output_vbr(0U, Out); + return; + } + + assert(CTypes.size() >= StartNo && "Invalid compaction types start index"); + + // Determine how many types to write + unsigned NumTypes = CTypes.size() - StartNo; + + // Output the number of types. + output_vbr(NumTypes, Out); + + for (unsigned i = StartNo; i < StartNo+NumTypes; ++i) + output_vbr(Table.getGlobalSlot(CTypes[i]), Out); +} + void BytecodeWriter::outputCompactionTable() { BytecodeBlock CTB(BytecodeFormat::CompactionTable, Out, true/*ElideIfEmpty*/); const std::vector > &CT =Table.getCompactionTable(); // First thing is first, emit the type compaction table if there is one. - if (CT.size() > Type::TypeTyID) - outputCompactionTablePlane(Type::TypeTyID, CT[Type::TypeTyID], - Type::FirstDerivedTyID); + outputCompactionTypes(Type::FirstDerivedTyID); for (unsigned i = 0, e = CT.size(); i != e; ++i) - if (i != Type::TypeTyID) - outputCompactionTablePlane(i, CT[i], 0); + outputCompactionTablePlane(i, CT[i], 0); } void BytecodeWriter::outputSymbolTable(const SymbolTable &MST) { @@ -312,9 +330,8 @@ BytecodeBlock SymTabBlock(BytecodeFormat::SymbolTable, Out, true/* ElideIfEmpty*/); - //Symtab block header: [num entries][type id number] + //Symtab block header for types: [num entries] output_vbr(MST.num_types(), Out); - output_vbr((unsigned)Table.getSlot(Type::TypeTy), Out); for (SymbolTable::type_const_iterator TI = MST.type_begin(), TE = MST.type_end(); TI != TE; ++TI ) { //Symtab entry:[def slot #][name] From llvm at cs.uiuc.edu Sun Jul 4 06:47:09 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 06:47:09 2004 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Writer/Writer.cpp Message-ID: <200407041146.GAA04539@zion.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Writer: Writer.cpp updated: 1.68 -> 1.69 --- Log message: Remove Tabs. --- Diffs of the changes: (+4 -4) Index: llvm/lib/Bytecode/Writer/Writer.cpp diff -u llvm/lib/Bytecode/Writer/Writer.cpp:1.68 llvm/lib/Bytecode/Writer/Writer.cpp:1.69 --- llvm/lib/Bytecode/Writer/Writer.cpp:1.68 Sun Jul 4 06:45:47 2004 +++ llvm/lib/Bytecode/Writer/Writer.cpp Sun Jul 4 06:46:15 2004 @@ -165,12 +165,12 @@ if (!Plane.empty()) { // Skip empty type planes... unsigned ValNo = 0; if (isFunction) // Don't re-emit module constants - ValNo += Table.getModuleLevel(pno); + ValNo += Table.getModuleLevel(pno); if (hasNullValue(pno)) { - // Skip zero initializer - if (ValNo == 0) - ValNo = 1; + // Skip zero initializer + if (ValNo == 0) + ValNo = 1; } // Write out constants in the plane From llvm at cs.uiuc.edu Sun Jul 4 06:48:00 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 06:48:00 2004 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Writer/SlotTable.cpp Message-ID: <200407041147.GAA04639@zion.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Writer: SlotTable.cpp (r1.5) removed --- Log message: Implementation of SlotTable went into header file. Note that this header is currently not being used but is retained because it will be the basis for a clean up of the SlotCalculator class. --- Diffs of the changes: (+0 -0) From llvm at cs.uiuc.edu Sun Jul 4 06:52:00 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 06:52:00 2004 Subject: [llvm-commits] CVS: llvm/lib/VMCore/AsmWriter.cpp Message-ID: <200407041150.GAA05292@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: AsmWriter.cpp updated: 1.144 -> 1.145 --- Log message: Adjust the slot machine to handle Types separately from Values. This was done by doubling up the data structures so that Type based equivalents are used. A consequence of this is overloading of function members that take a Type* instead of a Value*. Various other cleanups related to Type != Value (bug 122: http://llvm.cs.uiuc.edu/PR122 ) were also implemented. --- Diffs of the changes: (+171 -25) Index: llvm/lib/VMCore/AsmWriter.cpp diff -u llvm/lib/VMCore/AsmWriter.cpp:1.144 llvm/lib/VMCore/AsmWriter.cpp:1.145 --- llvm/lib/VMCore/AsmWriter.cpp:1.144 Sat Jun 26 14:40:40 2004 +++ llvm/lib/VMCore/AsmWriter.cpp Sun Jul 4 06:50:43 2004 @@ -46,16 +46,24 @@ /// @brief A mapping of Values to slot numbers typedef std::map ValueMap; + typedef std::map TypeMap; /// @brief A plane with next slot number and ValueMap - struct Plane { + struct ValuePlane { unsigned next_slot; ///< The next slot number to use ValueMap map; ///< The map of Value* -> unsigned - Plane() { next_slot = 0; } ///< Make sure we start at 0 + ValuePlane() { next_slot = 0; } ///< Make sure we start at 0 + }; + + struct TypePlane { + unsigned next_slot; + TypeMap map; + TypePlane() { next_slot = 0; } + void clear() { map.clear(); next_slot = 0; } }; /// @brief The map of planes by Type - typedef std::map TypedPlanes; + typedef std::map TypedPlanes; /// @} /// @name Constructors @@ -75,9 +83,11 @@ /// plane. Its an error to ask for something not in the SlotMachine. /// Its an error to ask for a Type* int getSlot(const Value *V); + int getSlot(const Type*Ty); /// Determine if a Value has a slot or not bool hasSlot(const Value* V); + bool hasSlot(const Type* Ty); /// @} /// @name Mutators @@ -103,11 +113,13 @@ /// been inserted already, they get inserted, otherwise they are ignored. /// Either way, the slot number for the Value* is returned. unsigned createSlot(const Value *V); + unsigned createSlot(const Type* Ty); /// Insert a value into the value table. Return the slot number /// that it now occupies. BadThings(TM) will happen if you insert a /// Value that's already been inserted. unsigned insertValue( const Value *V ); + unsigned insertValue( const Type* Ty); /// Add all of the module level global variables (and their initializers) /// and function declarations, but not the contents of those functions. @@ -132,9 +144,11 @@ /// @brief The TypePlanes map for the module level data TypedPlanes mMap; + TypePlane mTypes; /// @brief The TypePlanes map for the function level data TypedPlanes fMap; + TypePlane fTypes; /// @} @@ -152,6 +166,11 @@ std::map &TypeTable, SlotMachine *Machine); +static void WriteAsOperandInternal(std::ostream &Out, const Type *T, + bool PrintName, + std::map &TypeTable, + SlotMachine *Machine); + static const Module *getModuleFromVal(const Value *V) { if (const Argument *MA = dyn_cast(V)) return MA->getParent() ? MA->getParent()->getParent() : 0; @@ -166,7 +185,6 @@ } static SlotMachine *createSlotMachine(const Value *V) { - assert(!isa(V) && "Can't create an SC for a type!"); if (const Argument *FA = dyn_cast(V)) { return new SlotMachine(FA->getParent()); } else if (const Instruction *I = dyn_cast(V)) { @@ -519,11 +537,6 @@ if (Machine) { Slot = Machine->getSlot(V); } else { - if (const Type *Ty = dyn_cast(V)) { - Out << Ty->getDescription(); - return; - } - Machine = createSlotMachine(V); if (Machine == 0) Slot = Machine->getSlot(V); @@ -539,7 +552,6 @@ } } - /// WriteAsOperand - Write the name of the specified value out to the specified /// ostream. This can be useful when you just want to print int %reg126, not /// the whole instruction that generated it. @@ -556,13 +568,52 @@ if (PrintType) printTypeInt(Out, V->getType(), TypeNames); - if (const Type *Ty = dyn_cast (V)) - printTypeInt(Out, Ty, TypeNames); - WriteAsOperandInternal(Out, V, PrintName, TypeNames, 0); return Out; } +/// WriteAsOperandInternal - Write the name of the specified value out to +/// the specified ostream. This can be useful when you just want to print +/// int %reg126, not the whole instruction that generated it. +/// +static void WriteAsOperandInternal(std::ostream &Out, const Type *T, + bool PrintName, + std::map &TypeTable, + SlotMachine *Machine) { + Out << ' '; + int Slot; + if (Machine) { + Slot = Machine->getSlot(T); + if (Slot != -1) + Out << '%' << Slot; + else + Out << ""; + } else { + Out << T->getDescription(); + } +} + +/// WriteAsOperand - Write the name of the specified value out to the specified +/// ostream. This can be useful when you just want to print int %reg126, not +/// the whole instruction that generated it. +/// +std::ostream &llvm::WriteAsOperand(std::ostream &Out, const Type *Ty, + bool PrintType, bool PrintName, + const Module *Context) { + std::map TypeNames; + assert(Context != 0 && "Can't write types as operand without module context"); + + fillTypeNameTable(Context, TypeNames); + + // if (PrintType) + // printTypeInt(Out, V->getType(), TypeNames); + + printTypeInt(Out, Ty, TypeNames); + + WriteAsOperandInternal(Out, Ty, PrintName, TypeNames, 0); + return Out; +} + namespace llvm { class AssemblyWriter { @@ -1171,20 +1222,19 @@ AW->write(F); else if (const GlobalVariable *GV = dyn_cast(V)) AW->write(GV); - else if (const Type *Ty = dyn_cast(V)) - AW->write(Ty); else AW->writeOperand(V, true, true); return *this; } -CachedWriter& CachedWriter::operator<<(const Type *X) { +CachedWriter& CachedWriter::operator<<(const Type *Ty) { if (SymbolicTypes) { const Module *M = AW->getModule(); - if (M) WriteTypeSymbolic(Out, X, M); - return *this; - } else - return *this << (const Value*)X; + if (M) WriteTypeSymbolic(Out, Ty, M); + } else { + AW->write(Ty); + } + return *this; } //===----------------------------------------------------------------------===// @@ -1203,7 +1253,9 @@ : TheModule(M) ///< Saved for lazy initialization. , TheFunction(0) , mMap() + , mTypes() , fMap() + , fTypes() { } @@ -1213,7 +1265,9 @@ : TheModule( F ? F->getParent() : 0 ) ///< Saved for lazy initialization , TheFunction(F) ///< Saved for lazy initialization , mMap() + , mTypes() , fMap() + , fTypes() { } @@ -1276,6 +1330,7 @@ void SlotMachine::purgeFunction() { SC_DEBUG("begin purgeFunction!\n"); fMap.clear(); // Simply discard the function level map + fTypes.clear(); TheFunction = 0; SC_DEBUG("end purgeFunction!\n"); } @@ -1285,7 +1340,6 @@ /// Types are forbidden because Type does not inherit from Value (any more). int SlotMachine::getSlot(const Value *V) { assert( V && "Can't get slot for null Value" ); - assert( !isa(V) && "Can't get slot for a type" ); assert(!isa(V) || isa(V) && "Can't insert a non-GlobalValue Constant into SlotMachine"); @@ -1346,12 +1400,51 @@ return MVI->second; } +/// Get the slot number for a value. This function will assert if you +/// ask for a Value that hasn't previously been inserted with createSlot. +/// Types are forbidden because Type does not inherit from Value (any more). +int SlotMachine::getSlot(const Type *Ty) { + assert( Ty && "Can't get slot for null Type" ); + + // Check for uninitialized state and do lazy initialization + this->initialize(); + + if ( TheFunction ) { + // Lookup the Type in the function map + TypeMap::const_iterator FTI = fTypes.map.find(Ty); + // If the Type doesn't exist in the function map + if ( FTI == fTypes.map.end() ) { + TypeMap::const_iterator MTI = mTypes.map.find(Ty); + // If we didn't find it, it wasn't inserted + if (MTI == mTypes.map.end()) + return -1; + // We found it only at the module level + return MTI->second; + + // else the value exists in the function map + } else { + // Return the slot number as the module's contribution to + // the type plane plus the index in the function's contribution + // to the type plane. + return mTypes.next_slot + FTI->second; + } + } + + // N.B. Can get here only if either !TheFunction + + // Lookup the value in the module's map + TypeMap::const_iterator MTI = mTypes.map.find(Ty); + // Make sure we found it. + if (MTI == mTypes.map.end()) return -1; + // Return it. + return MTI->second; +} + // Create a new slot, or return the existing slot if it is already // inserted. Note that the logic here parallels getSlot but instead // of asserting when the Value* isn't found, it inserts the value. unsigned SlotMachine::createSlot(const Value *V) { assert( V && "Can't insert a null Value to SlotMachine"); - assert( !isa(V) && "Can't insert a Type into SlotMachine"); assert(!isa(V) || isa(V) && "Can't insert a non-GlobalValue Constant into SlotMachine"); @@ -1428,12 +1521,49 @@ return insertValue(V); } +// Create a new slot, or return the existing slot if it is already +// inserted. Note that the logic here parallels getSlot but instead +// of asserting when the Value* isn't found, it inserts the value. +unsigned SlotMachine::createSlot(const Type *Ty) { + assert( Ty && "Can't insert a null Type to SlotMachine"); + + if ( TheFunction ) { + // Lookup the Type in the function map + TypeMap::const_iterator FTI = fTypes.map.find(Ty); + // If the type doesn't exist in the function map + if ( FTI == fTypes.map.end() ) { + // Look up the type in the module map + TypeMap::const_iterator MTI = mTypes.map.find(Ty); + // If we didn't find it, it wasn't inserted + if ( MTI == mTypes.map.end() ) + return insertValue(Ty); + else + // We found it only at the module level + return MTI->second; + + // else the value exists in the function map + } else { + // Return the slot number as the module's contribution to + // the type plane plus the index in the function's contribution + // to the type plane. + return mTypes.next_slot + FTI->second; + } + } + + // N.B. Can only get here if !TheFunction + + // Lookup the type in the module's map + TypeMap::const_iterator MTI = mTypes.map.find(Ty); + if ( MTI != mTypes.map.end() ) + return MTI->second; + + return insertValue(Ty); +} // Low level insert function. Minimal checking is done. This // function is just for the convenience of createSlot (above). unsigned SlotMachine::insertValue(const Value *V ) { assert(V && "Can't insert a null Value into SlotMachine!"); - assert(!isa(V) && "Can't insert a Type into SlotMachine!"); assert(!isa(V) || isa(V) && "Can't insert a non-GlobalValue Constant into SlotMachine"); @@ -1450,12 +1580,12 @@ if ( TheFunction ) { TypedPlanes::iterator I = fMap.find( VTy ); if ( I == fMap.end() ) - I = fMap.insert(std::make_pair(VTy,Plane())).first; + I = fMap.insert(std::make_pair(VTy,ValuePlane())).first; DestSlot = I->second.map[V] = I->second.next_slot++; } else { TypedPlanes::iterator I = mMap.find( VTy ); if ( I == mMap.end() ) - I = mMap.insert(std::make_pair(VTy,Plane())).first; + I = mMap.insert(std::make_pair(VTy,ValuePlane())).first; DestSlot = I->second.map[V] = I->second.next_slot++; } @@ -1465,6 +1595,22 @@ SC_DEBUG((isa(V) ? 'G' : (isa(V) ? 'C' : (isa(V) ? 'F' : 'o')))); SC_DEBUG("]\n"); + return DestSlot; +} + +// Low level insert function. Minimal checking is done. This +// function is just for the convenience of createSlot (above). +unsigned SlotMachine::insertValue(const Type *Ty ) { + assert(Ty && "Can't insert a null Type into SlotMachine!"); + + unsigned DestSlot = 0; + + if ( TheFunction ) { + DestSlot = fTypes.map[Ty] = fTypes.next_slot++; + } else { + DestSlot = fTypes.map[Ty] = fTypes.next_slot++; + } + SC_DEBUG(" Inserting type [" << DestSlot << "] = " << Ty << "\n"); return DestSlot; } From llvm at cs.uiuc.edu Sun Jul 4 06:52:09 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 06:52:09 2004 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp Message-ID: <200407041151.GAA05346@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Constants.cpp updated: 1.92 -> 1.93 --- Log message: #include since its not in Value.h any more. --- Diffs of the changes: (+3 -2) Index: llvm/lib/VMCore/Constants.cpp diff -u llvm/lib/VMCore/Constants.cpp:1.92 llvm/lib/VMCore/Constants.cpp:1.93 --- llvm/lib/VMCore/Constants.cpp:1.92 Mon Jun 21 07:12:12 2004 +++ llvm/lib/VMCore/Constants.cpp Sun Jul 4 06:51:24 2004 @@ -19,6 +19,7 @@ #include "llvm/Module.h" #include "Support/StringExtras.h" #include +#include using namespace llvm; ConstantBool *ConstantBool::True = new ConstantBool(true); @@ -120,8 +121,8 @@ case Type::ArrayTyID: return ConstantAggregateZero::get(Ty); default: - // Function, Type, Label, or Opaque type? - assert(0 && "Cannot create a null constant of that type!"); + // Function, Label, or Opaque type? + assert(!"Cannot create a null constant of that type!"); return 0; } } From llvm at cs.uiuc.edu Sun Jul 4 06:54:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 06:54:01 2004 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Linker.cpp Message-ID: <200407041152.GAA05535@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Linker.cpp updated: 1.72 -> 1.73 --- Log message: - #include since its not in Value.h any more. - constify use of Type* returned from symbol table. --- Diffs of the changes: (+3 -1) Index: llvm/lib/VMCore/Linker.cpp diff -u llvm/lib/VMCore/Linker.cpp:1.72 llvm/lib/VMCore/Linker.cpp:1.73 --- llvm/lib/VMCore/Linker.cpp:1.72 Wed Jun 23 12:24:31 2004 +++ llvm/lib/VMCore/Linker.cpp Sun Jul 4 06:52:49 2004 @@ -23,6 +23,8 @@ #include "llvm/SymbolTable.h" #include "llvm/iOther.h" #include "llvm/Assembly/Writer.h" +#include + using namespace llvm; // Error - Simple wrapper function to conditionally assign to E and return true. @@ -183,7 +185,7 @@ for ( ; TI != TE; ++TI ) { const std::string &Name = TI->first; - Type *RHS = TI->second; + const Type *RHS = TI->second; // Check to see if this type name is already in the dest module... Type *Entry = DestST->lookupType(Name); From llvm at cs.uiuc.edu Sun Jul 4 06:55:00 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 06:55:00 2004 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Pass.cpp Module.cpp Verifier.cpp Message-ID: <200407041154.GAA05590@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Pass.cpp updated: 1.57 -> 1.58 Module.cpp updated: 1.50 -> 1.51 Verifier.cpp updated: 1.113 -> 1.114 --- Log message: - #include since its not in Value.h any more. --- Diffs of the changes: (+3 -0) Index: llvm/lib/VMCore/Pass.cpp diff -u llvm/lib/VMCore/Pass.cpp:1.57 llvm/lib/VMCore/Pass.cpp:1.58 --- llvm/lib/VMCore/Pass.cpp:1.57 Sun Feb 29 16:37:04 2004 +++ llvm/lib/VMCore/Pass.cpp Sun Jul 4 06:53:53 2004 @@ -19,6 +19,7 @@ #include "llvm/ModuleProvider.h" #include "Support/STLExtras.h" #include "Support/TypeInfo.h" +#include #include using namespace llvm; Index: llvm/lib/VMCore/Module.cpp diff -u llvm/lib/VMCore/Module.cpp:1.50 llvm/lib/VMCore/Module.cpp:1.51 --- llvm/lib/VMCore/Module.cpp:1.50 Tue May 25 03:52:20 2004 +++ llvm/lib/VMCore/Module.cpp Sun Jul 4 06:53:53 2004 @@ -20,6 +20,7 @@ #include "SymbolTableListTraitsImpl.h" #include #include +#include #include using namespace llvm; Index: llvm/lib/VMCore/Verifier.cpp diff -u llvm/lib/VMCore/Verifier.cpp:1.113 llvm/lib/VMCore/Verifier.cpp:1.114 --- llvm/lib/VMCore/Verifier.cpp:1.113 Thu Jun 24 16:47:35 2004 +++ llvm/lib/VMCore/Verifier.cpp Sun Jul 4 06:53:53 2004 @@ -55,6 +55,7 @@ #include "llvm/Support/InstVisitor.h" #include "Support/STLExtras.h" #include +#include #include using namespace llvm; From llvm at cs.uiuc.edu Sun Jul 4 06:56:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 06:56:01 2004 Subject: [llvm-commits] CVS: llvm/lib/VMCore/SymbolTable.cpp Message-ID: <200407041155.GAA05687@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: SymbolTable.cpp updated: 1.45 -> 1.46 --- Log message: Constify SymbolTable's use of Type* so that it never modifies them. --- Diffs of the changes: (+8 -11) Index: llvm/lib/VMCore/SymbolTable.cpp diff -u llvm/lib/VMCore/SymbolTable.cpp:1.45 llvm/lib/VMCore/SymbolTable.cpp:1.46 --- llvm/lib/VMCore/SymbolTable.cpp:1.45 Fri Jun 4 19:03:27 2004 +++ llvm/lib/VMCore/SymbolTable.cpp Sun Jul 4 06:55:08 2004 @@ -17,6 +17,7 @@ #include "llvm/Module.h" #include "Support/StringExtras.h" #include +#include using namespace llvm; @@ -86,14 +87,13 @@ Type* SymbolTable::lookupType( const std::string& Name ) const { type_const_iterator TI = tmap.find( Name ); if ( TI != tmap.end() ) - return TI->second; + return const_cast(TI->second); return 0; } // Remove a value void SymbolTable::remove(Value *N) { assert(N->hasName() && "Value doesn't have name!"); - assert(!isa(N) && "Can't remove types through this interface."); if (InternallyInconsistent) return; plane_iterator PI = pmap.find(N->getType()); @@ -110,7 +110,6 @@ Entry != Plane->second.end() && "Invalid entry to remove!"); Value *Result = Entry->second; - assert(!isa(Result) && "Can't remove types through this interface."); #if DEBUG_SYMBOL_TABLE dump(); std::cerr << " Removing Value: " << Result->getName() << "\n"; @@ -139,7 +138,7 @@ // remove - Remove a type -void SymbolTable::remove(Type* Ty ) { +void SymbolTable::remove(const Type* Ty ) { type_iterator TI = this->type_begin(); type_iterator TE = this->type_end(); @@ -157,7 +156,7 @@ if (InternallyInconsistent) return 0; assert( Entry != tmap.end() && "Invalid entry to remove!"); - Type* Result = Entry->second; + const Type* Result = Entry->second; #if DEBUG_SYMBOL_TABLE dump(); @@ -175,14 +174,13 @@ cast(Result)->removeAbstractTypeUser(this); } - return Result; + return const_cast(Result); } // insertEntry - Insert a value into the symbol table with the specified name. void SymbolTable::insertEntry(const std::string &Name, const Type *VTy, Value *V) { - assert(!isa(V) && "Can't insert types through this interface."); // Check to see if there is a naming conflict. If so, rename this value! if (lookup(VTy, Name)) { std::string UniqueName = getUniqueName(VTy, Name); @@ -225,7 +223,7 @@ // insertEntry - Insert a value into the symbol table with the specified // name... // -void SymbolTable::insertEntry(const std::string& Name, Type* T) { +void SymbolTable::insertEntry(const std::string& Name, const Type* T) { // Check to see if there is a naming conflict. If so, rename this type! std::string UniqueName = Name; @@ -261,7 +259,6 @@ // Get the name of a value std::string SymbolTable::get_name( const Value* V ) const { - assert(!isa(V) && "Can't get name of types through this interface."); value_const_iterator VI = this->value_begin( V->getType() ); value_const_iterator VE = this->value_end( V->getType() ); @@ -318,7 +315,7 @@ } for (type_iterator TI = tmap.begin(); TI != tmap.end(); ) { - Type* T = (TI++)->second; + const Type* T = (TI++)->second; remove(T); RemovedSymbol = true; } @@ -483,7 +480,7 @@ for_each(P.second.begin(), P.second.end(), DumpVal); } -static void DumpTypes(const std::pair& T ) { +static void DumpTypes(const std::pair& T ) { std::cerr << " '" << T.first << "' = "; T.second->dump(); std::cerr << "\n"; From llvm at cs.uiuc.edu Sun Jul 4 06:56:09 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 06:56:09 2004 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Value.cpp Message-ID: <200407041155.GAA05732@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Value.cpp updated: 1.43 -> 1.44 --- Log message: - #include since its not in Value.h any more. --- Diffs of the changes: (+1 -0) Index: llvm/lib/VMCore/Value.cpp diff -u llvm/lib/VMCore/Value.cpp:1.43 llvm/lib/VMCore/Value.cpp:1.44 --- llvm/lib/VMCore/Value.cpp:1.43 Sun Jun 27 13:01:38 2004 +++ llvm/lib/VMCore/Value.cpp Sun Jul 4 06:55:37 2004 @@ -17,6 +17,7 @@ #include "llvm/Constant.h" #include "Support/LeakDetector.h" #include +#include using namespace llvm; //===----------------------------------------------------------------------===// From llvm at cs.uiuc.edu Sun Jul 4 07:15:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 07:15:01 2004 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Type.cpp Message-ID: <200407041214.HAA09981@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Type.cpp updated: 1.103 -> 1.104 --- Log message: - Changes for bug 122: http://llvm.cs.uiuc.edu/PR122 - Remove Tabs - Add inserters needed since Value doesn't implement them any more - Move some functions here to avoid cyclic header file dependencies. --- Diffs of the changes: (+46 -21) Index: llvm/lib/VMCore/Type.cpp diff -u llvm/lib/VMCore/Type.cpp:1.103 llvm/lib/VMCore/Type.cpp:1.104 --- llvm/lib/VMCore/Type.cpp:1.103 Fri Jul 2 18:20:17 2004 +++ llvm/lib/VMCore/Type.cpp Sun Jul 4 07:14:17 2004 @@ -11,6 +11,7 @@ // //===----------------------------------------------------------------------===// +#include "llvm/AbstractTypeUser.h" #include "llvm/DerivedTypes.h" #include "llvm/SymbolTable.h" #include "llvm/Constants.h" @@ -18,6 +19,7 @@ #include "Support/StringExtras.h" #include "Support/STLExtras.h" #include +#include using namespace llvm; // DEBUG_MERGE_TYPES - Enable this #define to see how and when derived types are @@ -42,8 +44,8 @@ static std::map ConcreteTypeDescriptions; static std::map AbstractTypeDescriptions; -Type::Type(const std::string &name, TypeID id) - : Value(Type::TypeTy, Value::TypeVal), RefCount(0), ForwardType(0) { +Type::Type( const std::string& name, TypeID id ) + : RefCount(0), ForwardType(0) { if (!name.empty()) ConcreteTypeDescriptions[this] = name; ID = id; @@ -57,7 +59,6 @@ if (!Name.empty()) ST->insert(Name, this); } - const Type *Type::getUniqueIDType(unsigned UID) { assert(UID < UIDMappings.size() && "Type::getPrimitiveType: UID out of range!"); @@ -78,7 +79,6 @@ case LongTyID : return LongTy; case FloatTyID : return FloatTy; case DoubleTyID: return DoubleTy; - case TypeTyID : return TypeTy; case LabelTyID : return LabelTy; default: return 0; @@ -333,7 +333,7 @@ // type. // struct SignedIntType : public Type { - SignedIntType(const std::string &Name, TypeID id) : Type(Name, id) {} + SignedIntType(std::string name, TypeID id) : Type(name, id) {} // isSigned - Return whether a numeric type is signed. virtual bool isSigned() const { return 1; } @@ -345,7 +345,7 @@ }; struct UnsignedIntType : public Type { - UnsignedIntType(const std::string &N, TypeID id) : Type(N, id) {} + UnsignedIntType(std::string name, TypeID id) : Type(name,id) {} // isUnsigned - Return whether a numeric type is signed. virtual bool isUnsigned() const { return 1; } @@ -357,13 +357,9 @@ }; struct OtherType : public Type { - OtherType(const std::string &N, TypeID id) : Type(N, id) {} + OtherType(std:;string name, TypeID id) : Type(name,id) {} }; -static struct TypeType : public Type { - TypeType() : Type("type", TypeTyID) {} -} TheTypeTy; // Implement the type that is global. - //===----------------------------------------------------------------------===// // Static 'Type' data @@ -375,7 +371,7 @@ static UnsignedIntType TheUByteTy ("ubyte" , Type::UByteTyID); static SignedIntType TheShortTy ("short" , Type::ShortTyID); static UnsignedIntType TheUShortTy("ushort", Type::UShortTyID); -static SignedIntType TheIntTy ("int" , Type::IntTyID); +static SignedIntType TheIntTy ("int" , Type::IntTyID); static UnsignedIntType TheUIntTy ("uint" , Type::UIntTyID); static SignedIntType TheLongTy ("long" , Type::LongTyID); static UnsignedIntType TheULongTy ("ulong" , Type::ULongTyID); @@ -395,7 +391,6 @@ Type *Type::ULongTy = &TheULongTy; Type *Type::FloatTy = &TheFloatTy; Type *Type::DoubleTy = &TheDoubleTy; -Type *Type::TypeTy = &TheTypeTy; Type *Type::LabelTy = &TheLabelTy; @@ -490,7 +485,7 @@ // Scan all of the sub-types. If any of them are abstract, than so is this // one! - for (Type::subtype_iterator I = subtype_begin(), E = subtype_end(); + for (Type::subtype_iterator I = subtype_begin(), E = subtype_end(); I != E; ++I) if (const_cast(I->get())->isTypeAbstract()) { setAbstract(true); // Restore the abstract bit. @@ -516,7 +511,7 @@ // that assumes that two graphs are the same until proven otherwise. // static bool TypesEqual(const Type *Ty, const Type *Ty2, - std::map &EqTypes) { + std::map &EqTypes) { if (Ty == Ty2) return true; if (Ty->getTypeID() != Ty2->getTypeID()) return false; if (isa(Ty)) @@ -582,8 +577,8 @@ return false; VisitedTypes.insert(VTI, CurTy); - for (Type::subtype_iterator I = CurTy->subtype_begin(), - E = CurTy->subtype_end(); I != E; ++I) + for (Type::subtype_iterator I = CurTy->subtype_begin(), + E = CurTy->subtype_end(); I != E; ++I) if (TypeHasCycleThrough(TargetTy, *I, VisitedTypes)) return true; return false; @@ -595,7 +590,7 @@ static bool TypeHasCycleThroughItself(const Type *Ty) { assert(Ty->isAbstract() && "This code assumes that Ty was abstract!"); std::set VisitedTypes; - for (Type::subtype_iterator I = Ty->subtype_begin(), E = Ty->subtype_end(); + for (Type::subtype_iterator I = Ty->subtype_begin(), E = Ty->subtype_end(); I != E; ++I) if (TypeHasCycleThrough(Ty, *I, VisitedTypes)) return true; @@ -1144,7 +1139,7 @@ // concrete type. // void ArrayType::refineAbstractType(const DerivedType *OldType, - const Type *NewType) { + const Type *NewType) { ArrayTypes.finishRefinement(this, OldType, NewType); } @@ -1158,7 +1153,7 @@ // concrete type. // void StructType::refineAbstractType(const DerivedType *OldType, - const Type *NewType) { + const Type *NewType) { StructTypes.finishRefinement(this, OldType, NewType); } @@ -1171,10 +1166,40 @@ // concrete type. // void PointerType::refineAbstractType(const DerivedType *OldType, - const Type *NewType) { + const Type *NewType) { PointerTypes.finishRefinement(this, OldType, NewType); } void PointerType::typeBecameConcrete(const DerivedType *AbsTy) { refineAbstractType(AbsTy, AbsTy); } + +bool SequentialType::indexValid(const Value *V) const { + const Type *Ty = V->getType(); + switch (Ty->getTypeID()) { + case Type::IntTyID: + case Type::UIntTyID: + case Type::LongTyID: + case Type::ULongTyID: + return true; + default: + return false; + } +} + +namespace llvm { +std::ostream &operator<<(std::ostream &OS, const Type *T) { + if (T == 0) + OS << " value!\n"; + else + T->print(OS); + return OS; +} + +std::ostream &operator<<(std::ostream &OS, const Type &T) { + T.print(OS); + return OS; +} +} + +// vim: sw=2 From llvm at cs.uiuc.edu Sun Jul 4 07:16:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 07:16:01 2004 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Type.cpp Message-ID: <200407041215.HAA10007@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Type.cpp updated: 1.104 -> 1.105 --- Log message: Correct syntax typo .. ; -> : --- Diffs of the changes: (+1 -1) Index: llvm/lib/VMCore/Type.cpp diff -u llvm/lib/VMCore/Type.cpp:1.104 llvm/lib/VMCore/Type.cpp:1.105 --- llvm/lib/VMCore/Type.cpp:1.104 Sun Jul 4 07:14:17 2004 +++ llvm/lib/VMCore/Type.cpp Sun Jul 4 07:15:11 2004 @@ -357,7 +357,7 @@ }; struct OtherType : public Type { - OtherType(std:;string name, TypeID id) : Type(name,id) {} + OtherType(std::string name, TypeID id) : Type(name,id) {} }; From llvm at cs.uiuc.edu Sun Jul 4 07:19:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 07:19:01 2004 Subject: [llvm-commits] CVS: llvm/lib/AsmParser/Lexer.l Message-ID: <200407041217.HAA10645@zion.cs.uiuc.edu> Changes in directory llvm/lib/AsmParser: Lexer.l updated: 1.49 -> 1.50 --- Log message: Remove use of Type::TypeTy which is no longer defined. This change needed for bug 122: http://llvm.cs.uiuc.edu/PR122 since the "Type Type" concept is gone now. --- Diffs of the changes: (+1 -1) Index: llvm/lib/AsmParser/Lexer.l diff -u llvm/lib/AsmParser/Lexer.l:1.49 llvm/lib/AsmParser/Lexer.l:1.50 --- llvm/lib/AsmParser/Lexer.l:1.49 Thu May 27 12:49:14 2004 +++ llvm/lib/AsmParser/Lexer.l Sun Jul 4 07:17:44 2004 @@ -212,8 +212,8 @@ ulong { llvmAsmlval.PrimType = Type::ULongTy ; return ULONG; } float { llvmAsmlval.PrimType = Type::FloatTy ; return FLOAT; } double { llvmAsmlval.PrimType = Type::DoubleTy; return DOUBLE; } -type { llvmAsmlval.PrimType = Type::TypeTy ; return TYPE; } label { llvmAsmlval.PrimType = Type::LabelTy ; return LABEL; } +type { return TYPE; } opaque { return OPAQUE; } add { RET_TOK(BinaryOpVal, Add, ADD); } From llvm at cs.uiuc.edu Sun Jul 4 07:20:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 07:20:01 2004 Subject: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y Message-ID: <200407041219.HAA10669@zion.cs.uiuc.edu> Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.169 -> 1.170 --- Log message: - remove use of isa(Val) since there's no inheritance relationship any more. Needed for bug 122: http://llvm.cs.uiuc.edu/PR122 - #include since Value.h doesn't include it any more. --- Diffs of the changes: (+3 -4) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.169 llvm/lib/AsmParser/llvmAsmParser.y:1.170 --- llvm/lib/AsmParser/llvmAsmParser.y:1.169 Thu Jun 17 13:18:08 2004 +++ llvm/lib/AsmParser/llvmAsmParser.y Sun Jul 4 07:19:05 2004 @@ -21,9 +21,10 @@ #include "llvm/iPHINode.h" #include "llvm/Support/GetElementPtrTypeIterator.h" #include "Support/STLExtras.h" +#include +#include #include #include -#include int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit int yylex(); // declaration" of xxx warnings. @@ -236,7 +237,7 @@ case ValID::NameVal: { // Is it a named definition? std::string Name(D.Name); SymbolTable *SymTab = 0; - Value *N = 0; + Type *N = 0; if (inFunctionScope()) { SymTab = &CurFun.CurrentFunction->getSymbolTable(); N = SymTab->lookupType(Name); @@ -426,7 +427,6 @@ while (!List.empty()) { Value *V = List.back(); List.pop_back(); - assert(!isa(V) && "Types should be in LateResolveTypes!"); ValID &DID = getValIDFromPlaceHolder(V); Value *TheRealValue = @@ -501,7 +501,6 @@ // for the typeplane, false is returned. // static bool setValueName(Value *V, char *NameStr) { - assert(!isa(V) && "Can't set name of a Type with setValueName"); if (NameStr == 0) return false; std::string Name(NameStr); // Copy string From llvm at cs.uiuc.edu Sun Jul 4 07:21:00 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 07:21:00 2004 Subject: [llvm-commits] CVS: llvm/lib/Analysis/AliasAnalysis.cpp AliasAnalysisEvaluator.cpp AliasSetTracker.cpp Expressions.cpp LoopInfo.cpp ProfileInfoLoader.cpp ProfileInfoLoaderPass.cpp Trace.cpp Message-ID: <200407041220.HAA10866@zion.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: AliasAnalysis.cpp updated: 1.18 -> 1.19 AliasAnalysisEvaluator.cpp updated: 1.13 -> 1.14 AliasSetTracker.cpp updated: 1.16 -> 1.17 Expressions.cpp updated: 1.42 -> 1.43 LoopInfo.cpp updated: 1.56 -> 1.57 ProfileInfoLoader.cpp updated: 1.6 -> 1.7 ProfileInfoLoaderPass.cpp updated: 1.5 -> 1.6 Trace.cpp updated: 1.1 -> 1.2 --- Log message: Add #include since Value.h does not #include it any more. --- Diffs of the changes: (+14 -0) Index: llvm/lib/Analysis/AliasAnalysis.cpp diff -u llvm/lib/Analysis/AliasAnalysis.cpp:1.18 llvm/lib/Analysis/AliasAnalysis.cpp:1.19 --- llvm/lib/Analysis/AliasAnalysis.cpp:1.18 Sun May 23 16:15:48 2004 +++ llvm/lib/Analysis/AliasAnalysis.cpp Sun Jul 4 07:19:55 2004 @@ -28,6 +28,7 @@ #include "llvm/BasicBlock.h" #include "llvm/iMemory.h" #include "llvm/Target/TargetData.h" +#include using namespace llvm; // Register the AliasAnalysis interface, providing a nice name to refer to. Index: llvm/lib/Analysis/AliasAnalysisEvaluator.cpp diff -u llvm/lib/Analysis/AliasAnalysisEvaluator.cpp:1.13 llvm/lib/Analysis/AliasAnalysisEvaluator.cpp:1.14 --- llvm/lib/Analysis/AliasAnalysisEvaluator.cpp:1.13 Tue Apr 27 10:12:45 2004 +++ llvm/lib/Analysis/AliasAnalysisEvaluator.cpp Sun Jul 4 07:19:55 2004 @@ -26,7 +26,9 @@ #include "llvm/Assembly/Writer.h" #include "llvm/Support/InstIterator.h" #include "Support/CommandLine.h" +#include #include + using namespace llvm; namespace { Index: llvm/lib/Analysis/AliasSetTracker.cpp diff -u llvm/lib/Analysis/AliasSetTracker.cpp:1.16 llvm/lib/Analysis/AliasSetTracker.cpp:1.17 --- llvm/lib/Analysis/AliasSetTracker.cpp:1.16 Sun May 23 16:10:58 2004 +++ llvm/lib/Analysis/AliasSetTracker.cpp Sun Jul 4 07:19:55 2004 @@ -20,6 +20,7 @@ #include "llvm/Target/TargetData.h" #include "llvm/Assembly/Writer.h" #include "llvm/Support/InstIterator.h" +#include using namespace llvm; /// mergeSetIn - Merge the specified alias set into this alias set... Index: llvm/lib/Analysis/Expressions.cpp diff -u llvm/lib/Analysis/Expressions.cpp:1.42 llvm/lib/Analysis/Expressions.cpp:1.43 --- llvm/lib/Analysis/Expressions.cpp:1.42 Sat Jun 26 14:31:26 2004 +++ llvm/lib/Analysis/Expressions.cpp Sun Jul 4 07:19:55 2004 @@ -18,6 +18,8 @@ #include "llvm/Constants.h" #include "llvm/Function.h" #include "llvm/Type.h" +#include + using namespace llvm; ExprType::ExprType(Value *Val) { Index: llvm/lib/Analysis/LoopInfo.cpp diff -u llvm/lib/Analysis/LoopInfo.cpp:1.56 llvm/lib/Analysis/LoopInfo.cpp:1.57 --- llvm/lib/Analysis/LoopInfo.cpp:1.56 Tue Jun 8 16:50:30 2004 +++ llvm/lib/Analysis/LoopInfo.cpp Sun Jul 4 07:19:55 2004 @@ -22,6 +22,8 @@ #include "llvm/Support/CFG.h" #include "Support/DepthFirstIterator.h" #include +#include + using namespace llvm; static RegisterAnalysis Index: llvm/lib/Analysis/ProfileInfoLoader.cpp diff -u llvm/lib/Analysis/ProfileInfoLoader.cpp:1.6 llvm/lib/Analysis/ProfileInfoLoader.cpp:1.7 --- llvm/lib/Analysis/ProfileInfoLoader.cpp:1.6 Tue May 4 12:11:14 2004 +++ llvm/lib/Analysis/ProfileInfoLoader.cpp Sun Jul 4 07:19:55 2004 @@ -17,7 +17,9 @@ #include "llvm/Module.h" #include "llvm/InstrTypes.h" #include +#include #include + using namespace llvm; // ByteSwap - Byteswap 'Var' if 'Really' is true. Index: llvm/lib/Analysis/ProfileInfoLoaderPass.cpp diff -u llvm/lib/Analysis/ProfileInfoLoaderPass.cpp:1.5 llvm/lib/Analysis/ProfileInfoLoaderPass.cpp:1.6 --- llvm/lib/Analysis/ProfileInfoLoaderPass.cpp:1.5 Mon Mar 8 16:04:08 2004 +++ llvm/lib/Analysis/ProfileInfoLoaderPass.cpp Sun Jul 4 07:19:55 2004 @@ -18,6 +18,8 @@ #include "llvm/Analysis/ProfileInfo.h" #include "llvm/Analysis/ProfileInfoLoader.h" #include "Support/CommandLine.h" +#include + using namespace llvm; namespace { Index: llvm/lib/Analysis/Trace.cpp diff -u llvm/lib/Analysis/Trace.cpp:1.1 llvm/lib/Analysis/Trace.cpp:1.2 --- llvm/lib/Analysis/Trace.cpp:1.1 Mon Mar 8 14:57:27 2004 +++ llvm/lib/Analysis/Trace.cpp Sun Jul 4 07:19:55 2004 @@ -18,6 +18,8 @@ #include "llvm/Analysis/Trace.h" #include "llvm/Function.h" #include "llvm/Assembly/Writer.h" +#include + using namespace llvm; Function *Trace::getFunction() const { From llvm at cs.uiuc.edu Sun Jul 4 07:21:09 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 07:21:09 2004 Subject: [llvm-commits] CVS: llvm/lib/Analysis/IPA/PrintSCC.cpp Message-ID: <200407041220.HAA10868@zion.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/IPA: PrintSCC.cpp updated: 1.9 -> 1.10 --- Log message: Add #include since Value.h does not #include it any more. --- Diffs of the changes: (+1 -0) Index: llvm/lib/Analysis/IPA/PrintSCC.cpp diff -u llvm/lib/Analysis/IPA/PrintSCC.cpp:1.9 llvm/lib/Analysis/IPA/PrintSCC.cpp:1.10 --- llvm/lib/Analysis/IPA/PrintSCC.cpp:1.9 Tue Nov 11 16:41:31 2003 +++ llvm/lib/Analysis/IPA/PrintSCC.cpp Sun Jul 4 07:19:55 2004 @@ -30,6 +30,7 @@ #include "llvm/Analysis/CallGraph.h" #include "llvm/Support/CFG.h" #include "Support/SCCIterator.h" +#include namespace llvm { From llvm at cs.uiuc.edu Sun Jul 4 07:21:17 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 07:21:17 2004 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/GraphChecker.cpp Local.cpp PgmDependenceGraph.cpp Steensgaard.cpp Message-ID: <200407041220.HAA10877@zion.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: GraphChecker.cpp updated: 1.12 -> 1.13 Local.cpp updated: 1.104 -> 1.105 PgmDependenceGraph.cpp updated: 1.6 -> 1.7 Steensgaard.cpp updated: 1.38 -> 1.39 --- Log message: Add #include since Value.h does not #include it any more. --- Diffs of the changes: (+4 -0) Index: llvm/lib/Analysis/DataStructure/GraphChecker.cpp diff -u llvm/lib/Analysis/DataStructure/GraphChecker.cpp:1.12 llvm/lib/Analysis/DataStructure/GraphChecker.cpp:1.13 --- llvm/lib/Analysis/DataStructure/GraphChecker.cpp:1.12 Fri Feb 20 17:27:09 2004 +++ llvm/lib/Analysis/DataStructure/GraphChecker.cpp Sun Jul 4 07:19:55 2004 @@ -27,6 +27,7 @@ #include "llvm/Analysis/DSGraph.h" #include "Support/CommandLine.h" #include "llvm/Value.h" +#include #include using namespace llvm; Index: llvm/lib/Analysis/DataStructure/Local.cpp diff -u llvm/lib/Analysis/DataStructure/Local.cpp:1.104 llvm/lib/Analysis/DataStructure/Local.cpp:1.105 --- llvm/lib/Analysis/DataStructure/Local.cpp:1.104 Tue May 25 03:14:52 2004 +++ llvm/lib/Analysis/DataStructure/Local.cpp Sun Jul 4 07:19:55 2004 @@ -24,6 +24,7 @@ #include "Support/CommandLine.h" #include "Support/Debug.h" #include "Support/Timer.h" +#include // FIXME: This should eventually be a FunctionPass that is automatically // aggregated into a Pass. Index: llvm/lib/Analysis/DataStructure/PgmDependenceGraph.cpp diff -u llvm/lib/Analysis/DataStructure/PgmDependenceGraph.cpp:1.6 llvm/lib/Analysis/DataStructure/PgmDependenceGraph.cpp:1.7 --- llvm/lib/Analysis/DataStructure/PgmDependenceGraph.cpp:1.6 Sun Jun 27 19:27:16 2004 +++ llvm/lib/Analysis/DataStructure/PgmDependenceGraph.cpp Sun Jul 4 07:19:55 2004 @@ -28,6 +28,7 @@ #include "PgmDependenceGraph.h" #include "llvm/Analysis/PostDominators.h" #include "llvm/Function.h" +#include namespace llvm { Index: llvm/lib/Analysis/DataStructure/Steensgaard.cpp diff -u llvm/lib/Analysis/DataStructure/Steensgaard.cpp:1.38 llvm/lib/Analysis/DataStructure/Steensgaard.cpp:1.39 --- llvm/lib/Analysis/DataStructure/Steensgaard.cpp:1.38 Sun May 23 16:13:51 2004 +++ llvm/lib/Analysis/DataStructure/Steensgaard.cpp Sun Jul 4 07:19:55 2004 @@ -19,6 +19,7 @@ #include "llvm/Analysis/AliasAnalysis.h" #include "llvm/Module.h" #include "Support/Debug.h" +#include using namespace llvm; namespace { From llvm at cs.uiuc.edu Sun Jul 4 07:21:26 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 07:21:26 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/IntrinsicLowering.cpp MachineBasicBlock.cpp MachineCodeEmitter.cpp MachineFunction.cpp MachineInstr.cpp Message-ID: <200407041220.HAA10892@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: IntrinsicLowering.cpp updated: 1.19 -> 1.20 MachineBasicBlock.cpp updated: 1.17 -> 1.18 MachineCodeEmitter.cpp updated: 1.16 -> 1.17 MachineFunction.cpp updated: 1.62 -> 1.63 MachineInstr.cpp updated: 1.102 -> 1.103 --- Log message: Add #include since Value.h does not #include it any more. --- Diffs of the changes: (+8 -0) Index: llvm/lib/CodeGen/IntrinsicLowering.cpp diff -u llvm/lib/CodeGen/IntrinsicLowering.cpp:1.19 llvm/lib/CodeGen/IntrinsicLowering.cpp:1.20 --- llvm/lib/CodeGen/IntrinsicLowering.cpp:1.19 Sun Jun 20 02:48:49 2004 +++ llvm/lib/CodeGen/IntrinsicLowering.cpp Sun Jul 4 07:19:55 2004 @@ -16,6 +16,8 @@ #include "llvm/DerivedTypes.h" #include "llvm/Module.h" #include "llvm/iOther.h" +#include + using namespace llvm; template Index: llvm/lib/CodeGen/MachineBasicBlock.cpp diff -u llvm/lib/CodeGen/MachineBasicBlock.cpp:1.17 llvm/lib/CodeGen/MachineBasicBlock.cpp:1.18 --- llvm/lib/CodeGen/MachineBasicBlock.cpp:1.17 Thu Jul 1 01:02:27 2004 +++ llvm/lib/CodeGen/MachineBasicBlock.cpp Sun Jul 4 07:19:55 2004 @@ -18,6 +18,7 @@ #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetMachine.h" #include "Support/LeakDetector.h" +#include using namespace llvm; MachineBasicBlock::~MachineBasicBlock() { Index: llvm/lib/CodeGen/MachineCodeEmitter.cpp diff -u llvm/lib/CodeGen/MachineCodeEmitter.cpp:1.16 llvm/lib/CodeGen/MachineCodeEmitter.cpp:1.17 --- llvm/lib/CodeGen/MachineCodeEmitter.cpp:1.16 Fri Apr 23 12:11:13 2004 +++ llvm/lib/CodeGen/MachineCodeEmitter.cpp Sun Jul 4 07:19:55 2004 @@ -15,6 +15,8 @@ #include "llvm/CodeGen/MachineFunction.h" #include "llvm/Function.h" #include +#include + using namespace llvm; namespace { Index: llvm/lib/CodeGen/MachineFunction.cpp diff -u llvm/lib/CodeGen/MachineFunction.cpp:1.62 llvm/lib/CodeGen/MachineFunction.cpp:1.63 --- llvm/lib/CodeGen/MachineFunction.cpp:1.62 Thu Jul 1 01:29:07 2004 +++ llvm/lib/CodeGen/MachineFunction.cpp Sun Jul 4 07:19:55 2004 @@ -26,6 +26,7 @@ #include "llvm/iOther.h" #include "llvm/Type.h" #include "Support/LeakDetector.h" +#include using namespace llvm; Index: llvm/lib/CodeGen/MachineInstr.cpp diff -u llvm/lib/CodeGen/MachineInstr.cpp:1.102 llvm/lib/CodeGen/MachineInstr.cpp:1.103 --- llvm/lib/CodeGen/MachineInstr.cpp:1.102 Thu Jun 24 19:13:11 2004 +++ llvm/lib/CodeGen/MachineInstr.cpp Sun Jul 4 07:19:56 2004 @@ -21,6 +21,8 @@ #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/MRegisterInfo.h" #include "Support/LeakDetector.h" +#include + using namespace llvm; // Global variable holding an array of descriptors for machine instructions. From llvm at cs.uiuc.edu Sun Jul 4 07:21:34 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 07:21:34 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/InstrSched/InstrScheduling.cpp SchedGraph.cpp SchedGraphCommon.cpp SchedPriorities.cpp Message-ID: <200407041220.HAA10907@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/InstrSched: InstrScheduling.cpp updated: 1.71 -> 1.72 SchedGraph.cpp updated: 1.61 -> 1.62 SchedGraphCommon.cpp updated: 1.5 -> 1.6 SchedPriorities.cpp updated: 1.32 -> 1.33 --- Log message: Add #include since Value.h does not #include it any more. --- Diffs of the changes: (+4 -0) Index: llvm/lib/CodeGen/InstrSched/InstrScheduling.cpp diff -u llvm/lib/CodeGen/InstrSched/InstrScheduling.cpp:1.71 llvm/lib/CodeGen/InstrSched/InstrScheduling.cpp:1.72 --- llvm/lib/CodeGen/InstrSched/InstrScheduling.cpp:1.71 Wed Jun 2 01:06:19 2004 +++ llvm/lib/CodeGen/InstrSched/InstrScheduling.cpp Sun Jul 4 07:19:56 2004 @@ -21,6 +21,7 @@ #include "llvm/BasicBlock.h" #include "Support/CommandLine.h" #include +#include namespace llvm { Index: llvm/lib/CodeGen/InstrSched/SchedGraph.cpp diff -u llvm/lib/CodeGen/InstrSched/SchedGraph.cpp:1.61 llvm/lib/CodeGen/InstrSched/SchedGraph.cpp:1.62 --- llvm/lib/CodeGen/InstrSched/SchedGraph.cpp:1.61 Wed Jun 2 01:06:20 2004 +++ llvm/lib/CodeGen/InstrSched/SchedGraph.cpp Sun Jul 4 07:19:56 2004 @@ -22,6 +22,7 @@ #include "llvm/Target/TargetMachine.h" #include "../../Target/SparcV9/SparcV9RegInfo.h" #include "Support/STLExtras.h" +#include namespace llvm { Index: llvm/lib/CodeGen/InstrSched/SchedGraphCommon.cpp diff -u llvm/lib/CodeGen/InstrSched/SchedGraphCommon.cpp:1.5 llvm/lib/CodeGen/InstrSched/SchedGraphCommon.cpp:1.6 --- llvm/lib/CodeGen/InstrSched/SchedGraphCommon.cpp:1.5 Tue Jan 20 11:51:13 2004 +++ llvm/lib/CodeGen/InstrSched/SchedGraphCommon.cpp Sun Jul 4 07:19:56 2004 @@ -14,6 +14,7 @@ #include "llvm/CodeGen/SchedGraphCommon.h" #include "Support/STLExtras.h" +#include namespace llvm { Index: llvm/lib/CodeGen/InstrSched/SchedPriorities.cpp diff -u llvm/lib/CodeGen/InstrSched/SchedPriorities.cpp:1.32 llvm/lib/CodeGen/InstrSched/SchedPriorities.cpp:1.33 --- llvm/lib/CodeGen/InstrSched/SchedPriorities.cpp:1.32 Wed Feb 25 16:09:35 2004 +++ llvm/lib/CodeGen/InstrSched/SchedPriorities.cpp Sun Jul 4 07:19:56 2004 @@ -22,6 +22,7 @@ #include "llvm/CodeGen/MachineBasicBlock.h" #include "llvm/Support/CFG.h" #include "Support/PostOrderIterator.h" +#include namespace llvm { From llvm at cs.uiuc.edu Sun Jul 4 07:21:43 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 07:21:43 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/DAGBuilder.cpp SelectionDAG.cpp Message-ID: <200407041220.HAA10912@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/SelectionDAG: DAGBuilder.cpp updated: 1.6 -> 1.7 SelectionDAG.cpp updated: 1.6 -> 1.7 --- Log message: Add #include since Value.h does not #include it any more. --- Diffs of the changes: (+4 -0) Index: llvm/lib/CodeGen/SelectionDAG/DAGBuilder.cpp diff -u llvm/lib/CodeGen/SelectionDAG/DAGBuilder.cpp:1.6 llvm/lib/CodeGen/SelectionDAG/DAGBuilder.cpp:1.7 --- llvm/lib/CodeGen/SelectionDAG/DAGBuilder.cpp:1.6 Tue Jun 1 23:28:06 2004 +++ llvm/lib/CodeGen/SelectionDAG/DAGBuilder.cpp Sun Jul 4 07:19:56 2004 @@ -20,6 +20,8 @@ #include "llvm/CodeGen/MachineFunction.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Support/InstVisitor.h" +#include + using namespace llvm; namespace llvm { Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.6 llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.7 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.6 Thu Jun 17 13:16:35 2004 +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Sun Jul 4 07:19:56 2004 @@ -14,6 +14,8 @@ #include "llvm/CodeGen/SelectionDAG.h" #include "llvm/Type.h" +#include + using namespace llvm; SelectionDAG::~SelectionDAG() { From llvm at cs.uiuc.edu Sun Jul 4 07:22:00 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 07:22:00 2004 Subject: [llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Interpreter.h Message-ID: <200407041220.HAA10928@zion.cs.uiuc.edu> Changes in directory llvm/lib/ExecutionEngine/Interpreter: Interpreter.h updated: 1.64 -> 1.65 --- Log message: Add #include since Value.h does not #include it any more. --- Diffs of the changes: (+1 -0) Index: llvm/lib/ExecutionEngine/Interpreter/Interpreter.h diff -u llvm/lib/ExecutionEngine/Interpreter/Interpreter.h:1.64 llvm/lib/ExecutionEngine/Interpreter/Interpreter.h:1.65 --- llvm/lib/ExecutionEngine/Interpreter/Interpreter.h:1.64 Tue Apr 20 11:43:21 2004 +++ llvm/lib/ExecutionEngine/Interpreter/Interpreter.h Sun Jul 4 07:19:56 2004 @@ -21,6 +21,7 @@ #include "llvm/Support/CallSite.h" #include "llvm/Target/TargetData.h" #include "Support/DataTypes.h" +#include namespace llvm { From llvm at cs.uiuc.edu Sun Jul 4 07:22:14 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 07:22:14 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/SparcV9/RegAlloc/InterferenceGraph.cpp LiveRangeInfo.cpp PhyRegAlloc.cpp RegClass.cpp Message-ID: <200407041220.HAA10993@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/SparcV9/RegAlloc: InterferenceGraph.cpp updated: 1.19 -> 1.20 LiveRangeInfo.cpp updated: 1.53 -> 1.54 PhyRegAlloc.cpp updated: 1.151 -> 1.152 RegClass.cpp updated: 1.30 -> 1.31 --- Log message: Add #include since Value.h does not #include it any more. --- Diffs of the changes: (+4 -0) Index: llvm/lib/Target/SparcV9/RegAlloc/InterferenceGraph.cpp diff -u llvm/lib/Target/SparcV9/RegAlloc/InterferenceGraph.cpp:1.19 llvm/lib/Target/SparcV9/RegAlloc/InterferenceGraph.cpp:1.20 --- llvm/lib/Target/SparcV9/RegAlloc/InterferenceGraph.cpp:1.19 Tue Nov 11 16:41:33 2003 +++ llvm/lib/Target/SparcV9/RegAlloc/InterferenceGraph.cpp Sun Jul 4 07:19:56 2004 @@ -16,6 +16,7 @@ #include "RegAllocCommon.h" #include "Support/STLExtras.h" #include +#include namespace llvm { Index: llvm/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.cpp diff -u llvm/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.cpp:1.53 llvm/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.cpp:1.54 --- llvm/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.cpp:1.53 Wed Jun 2 00:55:00 2004 +++ llvm/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.cpp Sun Jul 4 07:19:56 2004 @@ -22,6 +22,7 @@ #include "llvm/Target/TargetInstrInfo.h" #include "../SparcV9RegInfo.h" #include "Support/SetOperations.h" +#include namespace llvm { Index: llvm/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp diff -u llvm/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp:1.151 llvm/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp:1.152 --- llvm/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp:1.151 Wed Jun 2 21:45:09 2004 +++ llvm/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp Sun Jul 4 07:19:56 2004 @@ -47,6 +47,7 @@ #include "Support/SetOperations.h" #include "Support/STLExtras.h" #include +#include namespace llvm { Index: llvm/lib/Target/SparcV9/RegAlloc/RegClass.cpp diff -u llvm/lib/Target/SparcV9/RegAlloc/RegClass.cpp:1.30 llvm/lib/Target/SparcV9/RegAlloc/RegClass.cpp:1.31 --- llvm/lib/Target/SparcV9/RegAlloc/RegClass.cpp:1.30 Wed Jun 2 21:45:09 2004 +++ llvm/lib/Target/SparcV9/RegAlloc/RegClass.cpp Sun Jul 4 07:19:56 2004 @@ -15,6 +15,7 @@ #include "RegAllocCommon.h" #include "RegClass.h" #include "../SparcV9RegInfo.h" +#include namespace llvm { From llvm at cs.uiuc.edu Sun Jul 4 07:22:22 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 07:22:22 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/InstSelectPattern.cpp X86RegisterInfo.cpp Message-ID: <200407041220.HAA11000@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: InstSelectPattern.cpp updated: 1.7 -> 1.8 X86RegisterInfo.cpp updated: 1.85 -> 1.86 --- Log message: Add #include since Value.h does not #include it any more. --- Diffs of the changes: (+3 -1) Index: llvm/lib/Target/X86/InstSelectPattern.cpp diff -u llvm/lib/Target/X86/InstSelectPattern.cpp:1.7 llvm/lib/Target/X86/InstSelectPattern.cpp:1.8 --- llvm/lib/Target/X86/InstSelectPattern.cpp:1.7 Sun Dec 28 15:23:38 2003 +++ llvm/lib/Target/X86/InstSelectPattern.cpp Sun Jul 4 07:19:56 2004 @@ -22,8 +22,8 @@ #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineFrameInfo.h" #include "llvm/CodeGen/SSARegMap.h" - #include "X86RegisterInfo.h" +#include // Include the generated instruction selector... #include "X86GenInstrSelector.inc" Index: llvm/lib/Target/X86/X86RegisterInfo.cpp diff -u llvm/lib/Target/X86/X86RegisterInfo.cpp:1.85 llvm/lib/Target/X86/X86RegisterInfo.cpp:1.86 --- llvm/lib/Target/X86/X86RegisterInfo.cpp:1.85 Mon Jun 21 16:17:44 2004 +++ llvm/lib/Target/X86/X86RegisterInfo.cpp Sun Jul 4 07:19:56 2004 @@ -26,6 +26,8 @@ #include "llvm/Target/TargetMachineImpls.h" #include "Support/CommandLine.h" #include "Support/STLExtras.h" +#include + using namespace llvm; namespace { From llvm at cs.uiuc.edu Sun Jul 4 07:22:30 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 07:22:30 2004 Subject: [llvm-commits] CVS: llvm/lib/Debugger/ProgramInfo.cpp Message-ID: <200407041220.HAA10921@zion.cs.uiuc.edu> Changes in directory llvm/lib/Debugger: ProgramInfo.cpp updated: 1.2 -> 1.3 --- Log message: Add #include since Value.h does not #include it any more. --- Diffs of the changes: (+2 -0) Index: llvm/lib/Debugger/ProgramInfo.cpp diff -u llvm/lib/Debugger/ProgramInfo.cpp:1.2 llvm/lib/Debugger/ProgramInfo.cpp:1.3 --- llvm/lib/Debugger/ProgramInfo.cpp:1.2 Wed Jan 14 11:07:46 2004 +++ llvm/lib/Debugger/ProgramInfo.cpp Sun Jul 4 07:19:56 2004 @@ -23,6 +23,8 @@ #include "Support/FileUtilities.h" #include "Support/SlowOperationInformer.h" #include "Support/STLExtras.h" +#include + using namespace llvm; /// getGlobalVariablesUsing - Return all of the global variables which have the From llvm at cs.uiuc.edu Sun Jul 4 07:22:38 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 07:22:38 2004 Subject: [llvm-commits] CVS: llvm/lib/Support/ConstantRange.cpp LeakDetector.cpp Message-ID: <200407041220.HAA10944@zion.cs.uiuc.edu> Changes in directory llvm/lib/Support: ConstantRange.cpp updated: 1.11 -> 1.12 LeakDetector.cpp updated: 1.8 -> 1.9 --- Log message: Add #include since Value.h does not #include it any more. --- Diffs of the changes: (+3 -0) Index: llvm/lib/Support/ConstantRange.cpp diff -u llvm/lib/Support/ConstantRange.cpp:1.11 llvm/lib/Support/ConstantRange.cpp:1.12 --- llvm/lib/Support/ConstantRange.cpp:1.11 Mon Mar 29 18:19:49 2004 +++ llvm/lib/Support/ConstantRange.cpp Sun Jul 4 07:19:56 2004 @@ -25,6 +25,8 @@ #include "llvm/Constants.h" #include "llvm/Instruction.h" #include "llvm/Type.h" +#include + using namespace llvm; static ConstantIntegral *Next(ConstantIntegral *CI) { Index: llvm/lib/Support/LeakDetector.cpp diff -u llvm/lib/Support/LeakDetector.cpp:1.8 llvm/lib/Support/LeakDetector.cpp:1.9 --- llvm/lib/Support/LeakDetector.cpp:1.8 Sun Feb 15 17:33:48 2004 +++ llvm/lib/Support/LeakDetector.cpp Sun Jul 4 07:19:56 2004 @@ -13,6 +13,7 @@ #include "Support/LeakDetector.h" #include "llvm/Value.h" +#include #include using namespace llvm; From llvm at cs.uiuc.edu Sun Jul 4 07:22:46 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 07:22:46 2004 Subject: [llvm-commits] CVS: llvm/lib/ExecutionEngine/JIT/JIT.cpp Message-ID: <200407041220.HAA10935@zion.cs.uiuc.edu> Changes in directory llvm/lib/ExecutionEngine/JIT: JIT.cpp updated: 1.33 -> 1.34 --- Log message: Add #include since Value.h does not #include it any more. --- Diffs of the changes: (+2 -0) Index: llvm/lib/ExecutionEngine/JIT/JIT.cpp diff -u llvm/lib/ExecutionEngine/JIT/JIT.cpp:1.33 llvm/lib/ExecutionEngine/JIT/JIT.cpp:1.34 --- llvm/lib/ExecutionEngine/JIT/JIT.cpp:1.33 Wed Apr 14 12:45:52 2004 +++ llvm/lib/ExecutionEngine/JIT/JIT.cpp Sun Jul 4 07:19:56 2004 @@ -23,6 +23,8 @@ #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetJITInfo.h" #include "Support/DynamicLinker.h" +#include + using namespace llvm; JIT::JIT(ModuleProvider *MP, TargetMachine &tm, TargetJITInfo &tji) From llvm at cs.uiuc.edu Sun Jul 4 07:22:55 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 07:22:55 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/SparcV9/InstrSelection/InstrForest.cpp InstrSelection.cpp Message-ID: <200407041220.HAA10969@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/SparcV9/InstrSelection: InstrForest.cpp updated: 1.53 -> 1.54 InstrSelection.cpp updated: 1.80 -> 1.81 --- Log message: Add #include since Value.h does not #include it any more. --- Diffs of the changes: (+2 -0) Index: llvm/lib/Target/SparcV9/InstrSelection/InstrForest.cpp diff -u llvm/lib/Target/SparcV9/InstrSelection/InstrForest.cpp:1.53 llvm/lib/Target/SparcV9/InstrSelection/InstrForest.cpp:1.54 --- llvm/lib/Target/SparcV9/InstrSelection/InstrForest.cpp:1.53 Sat Jun 26 14:36:34 2004 +++ llvm/lib/Target/SparcV9/InstrSelection/InstrForest.cpp Sun Jul 4 07:19:56 2004 @@ -28,6 +28,7 @@ #include "llvm/CodeGen/MachineInstr.h" #include "Support/STLExtras.h" #include "Config/alloca.h" +#include namespace llvm { Index: llvm/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp diff -u llvm/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp:1.80 llvm/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp:1.81 --- llvm/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp:1.80 Sun Jun 20 02:47:36 2004 +++ llvm/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp Sun Jul 4 07:19:56 2004 @@ -27,6 +27,7 @@ #include "../SparcV9RegInfo.h" #include "Support/CommandLine.h" #include "Support/LeakDetector.h" +#include namespace llvm { std::vector From llvm at cs.uiuc.edu Sun Jul 4 07:23:04 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 07:23:04 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/CBackend/Writer.cpp Message-ID: <200407041220.HAA10949@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/CBackend: Writer.cpp updated: 1.183 -> 1.184 --- Log message: Add #include since Value.h does not #include it any more. --- Diffs of the changes: (+2 -1) Index: llvm/lib/Target/CBackend/Writer.cpp diff -u llvm/lib/Target/CBackend/Writer.cpp:1.183 llvm/lib/Target/CBackend/Writer.cpp:1.184 --- llvm/lib/Target/CBackend/Writer.cpp:1.183 Sun Jun 20 02:48:07 2004 +++ llvm/lib/Target/CBackend/Writer.cpp Sun Jul 4 07:19:56 2004 @@ -35,6 +35,7 @@ #include "Support/StringExtras.h" #include "Config/config.h" #include +#include #include using namespace llvm; @@ -222,7 +223,7 @@ for (SymbolTable::type_iterator TI = MST.type_begin(), TE = MST.type_end(); TI != TE; ) { SymbolTable::type_iterator I = TI++; - if (StructType *STy = dyn_cast(I->second)) { + if (const StructType *STy = dyn_cast(I->second)) { // If this is not used, remove it from the symbol table. std::set::iterator UTI = UT.find(STy); if (UTI == UT.end()) From llvm at cs.uiuc.edu Sun Jul 4 07:24:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 07:24:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Instrumentation/ProfilePaths/Graph.cpp GraphAuxiliary.cpp InstLoops.cpp RetracePath.cpp Message-ID: <200407041220.HAA11038@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Instrumentation/ProfilePaths: Graph.cpp updated: 1.14 -> 1.15 GraphAuxiliary.cpp updated: 1.21 -> 1.22 InstLoops.cpp updated: 1.13 -> 1.14 RetracePath.cpp updated: 1.8 -> 1.9 --- Log message: Add #include since Value.h does not #include it any more. --- Diffs of the changes: (+4 -0) Index: llvm/lib/Transforms/Instrumentation/ProfilePaths/Graph.cpp diff -u llvm/lib/Transforms/Instrumentation/ProfilePaths/Graph.cpp:1.14 llvm/lib/Transforms/Instrumentation/ProfilePaths/Graph.cpp:1.15 --- llvm/lib/Transforms/Instrumentation/ProfilePaths/Graph.cpp:1.14 Tue Nov 11 16:41:33 2003 +++ llvm/lib/Transforms/Instrumentation/ProfilePaths/Graph.cpp Sun Jul 4 07:19:56 2004 @@ -16,6 +16,7 @@ #include "llvm/iTerminators.h" #include "Support/Debug.h" #include +#include using std::vector; Index: llvm/lib/Transforms/Instrumentation/ProfilePaths/GraphAuxiliary.cpp diff -u llvm/lib/Transforms/Instrumentation/ProfilePaths/GraphAuxiliary.cpp:1.21 llvm/lib/Transforms/Instrumentation/ProfilePaths/GraphAuxiliary.cpp:1.22 --- llvm/lib/Transforms/Instrumentation/ProfilePaths/GraphAuxiliary.cpp:1.21 Tue Nov 11 16:41:33 2003 +++ llvm/lib/Transforms/Instrumentation/ProfilePaths/GraphAuxiliary.cpp Sun Jul 4 07:19:56 2004 @@ -17,6 +17,7 @@ #include "llvm/iTerminators.h" #include "Support/Debug.h" #include +#include #include "Graph.h" //using std::list; Index: llvm/lib/Transforms/Instrumentation/ProfilePaths/InstLoops.cpp diff -u llvm/lib/Transforms/Instrumentation/ProfilePaths/InstLoops.cpp:1.13 llvm/lib/Transforms/Instrumentation/ProfilePaths/InstLoops.cpp:1.14 --- llvm/lib/Transforms/Instrumentation/ProfilePaths/InstLoops.cpp:1.13 Fri May 14 16:21:52 2004 +++ llvm/lib/Transforms/Instrumentation/ProfilePaths/InstLoops.cpp Sun Jul 4 07:19:56 2004 @@ -24,6 +24,7 @@ #include "llvm/Pass.h" #include "Support/Debug.h" #include "../ProfilingUtils.h" +#include namespace llvm { Index: llvm/lib/Transforms/Instrumentation/ProfilePaths/RetracePath.cpp diff -u llvm/lib/Transforms/Instrumentation/ProfilePaths/RetracePath.cpp:1.8 llvm/lib/Transforms/Instrumentation/ProfilePaths/RetracePath.cpp:1.9 --- llvm/lib/Transforms/Instrumentation/ProfilePaths/RetracePath.cpp:1.8 Tue Nov 11 16:41:33 2003 +++ llvm/lib/Transforms/Instrumentation/ProfilePaths/RetracePath.cpp Sun Jul 4 07:19:56 2004 @@ -16,6 +16,7 @@ #include "llvm/iOther.h" #include "llvm/Support/CFG.h" #include "Graph.h" +#include using std::vector; using std::map; From llvm at cs.uiuc.edu Sun Jul 4 07:24:10 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 07:24:10 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/SparcV9/SparcV9RegClassInfo.cpp SparcV9RegInfo.cpp Message-ID: <200407041220.HAA10960@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/SparcV9: SparcV9RegClassInfo.cpp updated: 1.36 -> 1.37 SparcV9RegInfo.cpp updated: 1.130 -> 1.131 --- Log message: Add #include since Value.h does not #include it any more. --- Diffs of the changes: (+2 -0) Index: llvm/lib/Target/SparcV9/SparcV9RegClassInfo.cpp diff -u llvm/lib/Target/SparcV9/SparcV9RegClassInfo.cpp:1.36 llvm/lib/Target/SparcV9/SparcV9RegClassInfo.cpp:1.37 --- llvm/lib/Target/SparcV9/SparcV9RegClassInfo.cpp:1.36 Sun Apr 25 02:04:49 2004 +++ llvm/lib/Target/SparcV9/SparcV9RegClassInfo.cpp Sun Jul 4 07:19:56 2004 @@ -19,6 +19,7 @@ #include "SparcV9RegInfo.h" #include "RegAlloc/RegAllocCommon.h" #include "RegAlloc/IGNode.h" +#include namespace llvm { Index: llvm/lib/Target/SparcV9/SparcV9RegInfo.cpp diff -u llvm/lib/Target/SparcV9/SparcV9RegInfo.cpp:1.130 llvm/lib/Target/SparcV9/SparcV9RegInfo.cpp:1.131 --- llvm/lib/Target/SparcV9/SparcV9RegInfo.cpp:1.130 Thu Jun 17 13:17:10 2004 +++ llvm/lib/Target/SparcV9/SparcV9RegInfo.cpp Sun Jul 4 07:19:56 2004 @@ -28,6 +28,7 @@ #include "SparcV9RegClassInfo.h" #include "SparcV9RegInfo.h" #include "SparcV9TargetMachine.h" +#include namespace llvm { From llvm at cs.uiuc.edu Sun Jul 4 07:24:18 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 07:24:18 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/ExprTypeConvert.cpp Message-ID: <200407041220.HAA11005@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms: ExprTypeConvert.cpp updated: 1.92 -> 1.93 --- Log message: Add #include since Value.h does not #include it any more. --- Diffs of the changes: (+1 -0) Index: llvm/lib/Transforms/ExprTypeConvert.cpp diff -u llvm/lib/Transforms/ExprTypeConvert.cpp:1.92 llvm/lib/Transforms/ExprTypeConvert.cpp:1.93 --- llvm/lib/Transforms/ExprTypeConvert.cpp:1.92 Sat Jun 19 14:01:26 2004 +++ llvm/lib/Transforms/ExprTypeConvert.cpp Sun Jul 4 07:19:56 2004 @@ -23,6 +23,7 @@ #include "Support/STLExtras.h" #include "Support/Debug.h" #include +#include using namespace llvm; static bool OperandConvertibleToType(User *U, Value *V, const Type *Ty, From llvm at cs.uiuc.edu Sun Jul 4 07:24:26 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 07:24:26 2004 Subject: [llvm-commits] CVS: llvm/projects/ModuleMaker/tools/ModuleMaker/ModuleMaker.cpp Message-ID: <200407041222.HAA11333@zion.cs.uiuc.edu> Changes in directory llvm/projects/ModuleMaker/tools/ModuleMaker: ModuleMaker.cpp updated: 1.2 -> 1.3 --- Log message: Add #include since Value.h doesn't include it any more. --- Diffs of the changes: (+1 -0) Index: llvm/projects/ModuleMaker/tools/ModuleMaker/ModuleMaker.cpp diff -u llvm/projects/ModuleMaker/tools/ModuleMaker/ModuleMaker.cpp:1.2 llvm/projects/ModuleMaker/tools/ModuleMaker/ModuleMaker.cpp:1.3 --- llvm/projects/ModuleMaker/tools/ModuleMaker/ModuleMaker.cpp:1.2 Tue Nov 11 16:41:34 2003 +++ llvm/projects/ModuleMaker/tools/ModuleMaker/ModuleMaker.cpp Sun Jul 4 07:22:14 2004 @@ -11,6 +11,7 @@ #include "llvm/Constants.h" #include "llvm/Instructions.h" #include "llvm/Bytecode/Writer.h" +#include using namespace llvm; From llvm at cs.uiuc.edu Sun Jul 4 07:24:35 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 07:24:35 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Instrumentation/BlockProfiling.cpp EdgeProfiling.cpp TraceBasicBlocks.cpp Message-ID: <200407041220.HAA11018@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Instrumentation: BlockProfiling.cpp updated: 1.7 -> 1.8 EdgeProfiling.cpp updated: 1.1 -> 1.2 TraceBasicBlocks.cpp updated: 1.4 -> 1.5 --- Log message: Add #include since Value.h does not #include it any more. --- Diffs of the changes: (+4 -0) Index: llvm/lib/Transforms/Instrumentation/BlockProfiling.cpp diff -u llvm/lib/Transforms/Instrumentation/BlockProfiling.cpp:1.7 llvm/lib/Transforms/Instrumentation/BlockProfiling.cpp:1.8 --- llvm/lib/Transforms/Instrumentation/BlockProfiling.cpp:1.7 Mon Mar 8 11:06:13 2004 +++ llvm/lib/Transforms/Instrumentation/BlockProfiling.cpp Sun Jul 4 07:19:56 2004 @@ -24,6 +24,8 @@ #include "llvm/Module.h" #include "llvm/Pass.h" #include "ProfilingUtils.h" +#include + using namespace llvm; namespace { Index: llvm/lib/Transforms/Instrumentation/EdgeProfiling.cpp diff -u llvm/lib/Transforms/Instrumentation/EdgeProfiling.cpp:1.1 llvm/lib/Transforms/Instrumentation/EdgeProfiling.cpp:1.2 --- llvm/lib/Transforms/Instrumentation/EdgeProfiling.cpp:1.1 Mon Mar 8 11:54:34 2004 +++ llvm/lib/Transforms/Instrumentation/EdgeProfiling.cpp Sun Jul 4 07:19:56 2004 @@ -23,6 +23,7 @@ #include "llvm/Pass.h" #include "llvm/Transforms/Utils/BasicBlockUtils.h" #include "ProfilingUtils.h" +#include #include using namespace llvm; Index: llvm/lib/Transforms/Instrumentation/TraceBasicBlocks.cpp diff -u llvm/lib/Transforms/Instrumentation/TraceBasicBlocks.cpp:1.4 llvm/lib/Transforms/Instrumentation/TraceBasicBlocks.cpp:1.5 --- llvm/lib/Transforms/Instrumentation/TraceBasicBlocks.cpp:1.4 Tue Jun 29 09:20:27 2004 +++ llvm/lib/Transforms/Instrumentation/TraceBasicBlocks.cpp Sun Jul 4 07:19:56 2004 @@ -23,6 +23,7 @@ #include "llvm/iPHINode.h" #include "ProfilingUtils.h" #include "Support/Debug.h" +#include #include using namespace llvm; From llvm at cs.uiuc.edu Sun Jul 4 07:24:43 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 07:24:43 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Utils/CodeExtractor.cpp SimplifyCFG.cpp ValueMapper.cpp Message-ID: <200407041220.HAA11052@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Utils: CodeExtractor.cpp updated: 1.24 -> 1.25 SimplifyCFG.cpp updated: 1.44 -> 1.45 ValueMapper.cpp updated: 1.12 -> 1.13 --- Log message: Add #include since Value.h does not #include it any more. --- Diffs of the changes: (+5 -0) Index: llvm/lib/Transforms/Utils/CodeExtractor.cpp diff -u llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.24 llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.25 --- llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.24 Wed May 26 17:50:28 2004 +++ llvm/lib/Transforms/Utils/CodeExtractor.cpp Sun Jul 4 07:19:56 2004 @@ -28,6 +28,7 @@ #include "Support/Debug.h" #include "Support/StringExtras.h" #include +#include #include using namespace llvm; Index: llvm/lib/Transforms/Utils/SimplifyCFG.cpp diff -u llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.44 llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.45 --- llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.44 Mon Jun 21 02:19:01 2004 +++ llvm/lib/Transforms/Utils/SimplifyCFG.cpp Sun Jul 4 07:19:56 2004 @@ -21,6 +21,8 @@ #include #include #include +#include + using namespace llvm; // PropagatePredecessorsForPHIs - This gets "Succ" ready to have the Index: llvm/lib/Transforms/Utils/ValueMapper.cpp diff -u llvm/lib/Transforms/Utils/ValueMapper.cpp:1.12 llvm/lib/Transforms/Utils/ValueMapper.cpp:1.13 --- llvm/lib/Transforms/Utils/ValueMapper.cpp:1.12 Wed May 19 04:08:12 2004 +++ llvm/lib/Transforms/Utils/ValueMapper.cpp Sun Jul 4 07:19:56 2004 @@ -15,6 +15,8 @@ #include "ValueMapper.h" #include "llvm/Constants.h" #include "llvm/Instruction.h" +#include + using namespace llvm; Value *llvm::MapValue(const Value *V, std::map &VM) { From llvm at cs.uiuc.edu Sun Jul 4 07:24:51 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 07:24:51 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/LowerConstantExprs.cpp Message-ID: <200407041220.HAA11039@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: LowerConstantExprs.cpp updated: 1.1 -> 1.2 --- Log message: Add #include since Value.h does not #include it any more. --- Diffs of the changes: (+1 -0) Index: llvm/lib/Transforms/Scalar/LowerConstantExprs.cpp diff -u llvm/lib/Transforms/Scalar/LowerConstantExprs.cpp:1.1 llvm/lib/Transforms/Scalar/LowerConstantExprs.cpp:1.2 --- llvm/lib/Transforms/Scalar/LowerConstantExprs.cpp:1.1 Fri Jun 25 02:48:09 2004 +++ llvm/lib/Transforms/Scalar/LowerConstantExprs.cpp Sun Jul 4 07:19:56 2004 @@ -22,6 +22,7 @@ #include "llvm/iOther.h" #include "llvm/Support/InstIterator.h" #include +#include using namespace llvm; using namespace std; From llvm at cs.uiuc.edu Sun Jul 4 07:24:59 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 07:24:59 2004 Subject: [llvm-commits] CVS: llvm/projects/Stacker/tools/stkrc/stkrc.cpp Message-ID: <200407041222.HAA11340@zion.cs.uiuc.edu> Changes in directory llvm/projects/Stacker/tools/stkrc: stkrc.cpp updated: 1.2 -> 1.3 --- Log message: Add #include since Value.h doesn't include it any more. --- Diffs of the changes: (+1 -0) Index: llvm/projects/Stacker/tools/stkrc/stkrc.cpp diff -u llvm/projects/Stacker/tools/stkrc/stkrc.cpp:1.2 llvm/projects/Stacker/tools/stkrc/stkrc.cpp:1.3 --- llvm/projects/Stacker/tools/stkrc/stkrc.cpp:1.2 Thu May 27 00:37:32 2004 +++ llvm/projects/Stacker/tools/stkrc/stkrc.cpp Sun Jul 4 07:22:14 2004 @@ -24,6 +24,7 @@ #include "Support/CommandLine.h" #include "llvm/System/Signals.h" #include +#include #include using namespace llvm; From llvm at cs.uiuc.edu Sun Jul 4 07:25:08 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 07:25:08 2004 Subject: [llvm-commits] CVS: llvm/tools/lli/lli.cpp Message-ID: <200407041221.HAA11252@zion.cs.uiuc.edu> Changes in directory llvm/tools/lli: lli.cpp updated: 1.43 -> 1.44 --- Log message: Add #include since Value.h does not include it any more. --- Diffs of the changes: (+1 -0) Index: llvm/tools/lli/lli.cpp diff -u llvm/tools/lli/lli.cpp:1.43 llvm/tools/lli/lli.cpp:1.44 --- llvm/tools/lli/lli.cpp:1.43 Thu May 27 00:39:32 2004 +++ llvm/tools/lli/lli.cpp Sun Jul 4 07:20:55 2004 @@ -21,6 +21,7 @@ #include "llvm/ExecutionEngine/GenericValue.h" #include "Support/CommandLine.h" #include "llvm/System/Signals.h" +#include using namespace llvm; From llvm at cs.uiuc.edu Sun Jul 4 07:25:16 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 07:25:16 2004 Subject: [llvm-commits] CVS: llvm/tools/bugpoint/BugDriver.cpp ExtractFunction.cpp Message-ID: <200407041221.HAA11238@zion.cs.uiuc.edu> Changes in directory llvm/tools/bugpoint: BugDriver.cpp updated: 1.33 -> 1.34 ExtractFunction.cpp updated: 1.34 -> 1.35 --- Log message: Add #include since Value.h does not include it any more. --- Diffs of the changes: (+3 -0) Index: llvm/tools/bugpoint/BugDriver.cpp diff -u llvm/tools/bugpoint/BugDriver.cpp:1.33 llvm/tools/bugpoint/BugDriver.cpp:1.34 --- llvm/tools/bugpoint/BugDriver.cpp:1.33 Wed Jun 23 12:31:12 2004 +++ llvm/tools/bugpoint/BugDriver.cpp Sun Jul 4 07:20:55 2004 @@ -22,7 +22,9 @@ #include "llvm/Support/ToolRunner.h" #include "Support/CommandLine.h" #include "Support/FileUtilities.h" +#include #include + using namespace llvm; // Anonymous namespace to define command line options for debugging. Index: llvm/tools/bugpoint/ExtractFunction.cpp diff -u llvm/tools/bugpoint/ExtractFunction.cpp:1.34 llvm/tools/bugpoint/ExtractFunction.cpp:1.35 --- llvm/tools/bugpoint/ExtractFunction.cpp:1.34 Tue May 11 16:54:13 2004 +++ llvm/tools/bugpoint/ExtractFunction.cpp Sun Jul 4 07:20:55 2004 @@ -27,6 +27,7 @@ #include "Support/CommandLine.h" #include "Support/Debug.h" #include "Support/FileUtilities.h" +#include #include using namespace llvm; From llvm at cs.uiuc.edu Sun Jul 4 07:25:24 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 07:25:24 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/SparcV9/LiveVar/BBLiveVar.cpp FunctionLiveVarInfo.cpp Message-ID: <200407041220.HAA10978@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/SparcV9/LiveVar: BBLiveVar.cpp updated: 1.46 -> 1.47 FunctionLiveVarInfo.cpp updated: 1.55 -> 1.56 --- Log message: Add #include since Value.h does not #include it any more. --- Diffs of the changes: (+2 -0) Index: llvm/lib/Target/SparcV9/LiveVar/BBLiveVar.cpp diff -u llvm/lib/Target/SparcV9/LiveVar/BBLiveVar.cpp:1.46 llvm/lib/Target/SparcV9/LiveVar/BBLiveVar.cpp:1.47 --- llvm/lib/Target/SparcV9/LiveVar/BBLiveVar.cpp:1.46 Wed Feb 25 12:44:15 2004 +++ llvm/lib/Target/SparcV9/LiveVar/BBLiveVar.cpp Sun Jul 4 07:19:56 2004 @@ -18,6 +18,7 @@ #include "llvm/Support/CFG.h" #include "Support/SetOperations.h" #include "../SparcV9Internals.h" +#include namespace llvm { Index: llvm/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp diff -u llvm/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp:1.55 llvm/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp:1.56 --- llvm/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp:1.55 Wed Jun 2 00:54:53 2004 +++ llvm/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp Sun Jul 4 07:19:56 2004 @@ -22,6 +22,7 @@ #include "Support/SetOperations.h" #include "Support/CommandLine.h" #include "BBLiveVar.h" +#include namespace llvm { From llvm at cs.uiuc.edu Sun Jul 4 07:25:33 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 07:25:33 2004 Subject: [llvm-commits] CVS: llvm/tools/llc/llc.cpp Message-ID: <200407041221.HAA11245@zion.cs.uiuc.edu> Changes in directory llvm/tools/llc: llc.cpp updated: 1.97 -> 1.98 --- Log message: Add #include since Value.h does not include it any more. --- Diffs of the changes: (+2 -1) Index: llvm/tools/llc/llc.cpp diff -u llvm/tools/llc/llc.cpp:1.97 llvm/tools/llc/llc.cpp:1.98 --- llvm/tools/llc/llc.cpp:1.97 Thu May 27 00:41:36 2004 +++ llvm/tools/llc/llc.cpp Sun Jul 4 07:20:55 2004 @@ -22,8 +22,9 @@ #include "llvm/Pass.h" #include "Support/CommandLine.h" #include "llvm/System/Signals.h" -#include #include +#include +#include using namespace llvm; From llvm at cs.uiuc.edu Sun Jul 4 07:25:42 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 07:25:42 2004 Subject: [llvm-commits] CVS: llvm/tools/analyze/AnalysisWrappers.cpp Message-ID: <200407041221.HAA11229@zion.cs.uiuc.edu> Changes in directory llvm/tools/analyze: AnalysisWrappers.cpp updated: 1.11 -> 1.12 --- Log message: Add #include since Value.h does not include it any more. --- Diffs of the changes: (+1 -0) Index: llvm/tools/analyze/AnalysisWrappers.cpp diff -u llvm/tools/analyze/AnalysisWrappers.cpp:1.11 llvm/tools/analyze/AnalysisWrappers.cpp:1.12 --- llvm/tools/analyze/AnalysisWrappers.cpp:1.11 Thu May 27 01:43:37 2004 +++ llvm/tools/analyze/AnalysisWrappers.cpp Sun Jul 4 07:20:55 2004 @@ -21,6 +21,7 @@ #include "llvm/Pass.h" #include "llvm/Analysis/InstForest.h" #include "llvm/Support/CallSite.h" +#include using namespace llvm; From llvm at cs.uiuc.edu Sun Jul 4 07:25:51 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 07:25:51 2004 Subject: [llvm-commits] CVS: llvm/tools/llvm-ar/llvm-ar.cpp Message-ID: <200407041221.HAA11259@zion.cs.uiuc.edu> Changes in directory llvm/tools/llvm-ar: llvm-ar.cpp updated: 1.12 -> 1.13 --- Log message: Add #include since Value.h does not include it any more. --- Diffs of the changes: (+1 -0) Index: llvm/tools/llvm-ar/llvm-ar.cpp diff -u llvm/tools/llvm-ar/llvm-ar.cpp:1.12 llvm/tools/llvm-ar/llvm-ar.cpp:1.13 --- llvm/tools/llvm-ar/llvm-ar.cpp:1.12 Thu May 27 00:38:45 2004 +++ llvm/tools/llvm-ar/llvm-ar.cpp Sun Jul 4 07:20:55 2004 @@ -18,6 +18,7 @@ #include "llvm/System/Signals.h" #include #include +#include #include #include #include From llvm at cs.uiuc.edu Sun Jul 4 07:26:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 07:26:01 2004 Subject: [llvm-commits] CVS: llvm/tools/llvm-prof/llvm-prof.cpp Message-ID: <200407041221.HAA11287@zion.cs.uiuc.edu> Changes in directory llvm/tools/llvm-prof: llvm-prof.cpp updated: 1.20 -> 1.21 --- Log message: Add #include since Value.h does not include it any more. --- Diffs of the changes: (+1 -0) Index: llvm/tools/llvm-prof/llvm-prof.cpp diff -u llvm/tools/llvm-prof/llvm-prof.cpp:1.20 llvm/tools/llvm-prof/llvm-prof.cpp:1.21 --- llvm/tools/llvm-prof/llvm-prof.cpp:1.20 Thu May 27 00:38:45 2004 +++ llvm/tools/llvm-prof/llvm-prof.cpp Sun Jul 4 07:20:55 2004 @@ -21,6 +21,7 @@ #include "Support/CommandLine.h" #include "llvm/System/Signals.h" #include +#include #include #include From llvm at cs.uiuc.edu Sun Jul 4 07:26:09 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 07:26:09 2004 Subject: [llvm-commits] CVS: llvm/tools/llvm-as/llvm-as.cpp Message-ID: <200407041221.HAA11266@zion.cs.uiuc.edu> Changes in directory llvm/tools/llvm-as: llvm-as.cpp updated: 1.28 -> 1.29 --- Log message: Add #include since Value.h does not include it any more. --- Diffs of the changes: (+1 -0) Index: llvm/tools/llvm-as/llvm-as.cpp diff -u llvm/tools/llvm-as/llvm-as.cpp:1.28 llvm/tools/llvm-as/llvm-as.cpp:1.29 --- llvm/tools/llvm-as/llvm-as.cpp:1.28 Fri Jun 25 15:54:43 2004 +++ llvm/tools/llvm-as/llvm-as.cpp Sun Jul 4 07:20:55 2004 @@ -22,6 +22,7 @@ #include "Support/CommandLine.h" #include "llvm/System/Signals.h" #include +#include #include using namespace llvm; From llvm at cs.uiuc.edu Sun Jul 4 07:26:18 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 07:26:18 2004 Subject: [llvm-commits] CVS: llvm/tools/llvm-nm/llvm-nm.cpp Message-ID: <200407041221.HAA11280@zion.cs.uiuc.edu> Changes in directory llvm/tools/llvm-nm: llvm-nm.cpp updated: 1.14 -> 1.15 --- Log message: Add #include since Value.h does not include it any more. --- Diffs of the changes: (+1 -0) Index: llvm/tools/llvm-nm/llvm-nm.cpp diff -u llvm/tools/llvm-nm/llvm-nm.cpp:1.14 llvm/tools/llvm-nm/llvm-nm.cpp:1.15 --- llvm/tools/llvm-nm/llvm-nm.cpp:1.14 Thu May 27 00:39:25 2004 +++ llvm/tools/llvm-nm/llvm-nm.cpp Sun Jul 4 07:20:55 2004 @@ -24,6 +24,7 @@ #include #include #include +#include using namespace llvm; From llvm at cs.uiuc.edu Sun Jul 4 07:26:26 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 07:26:26 2004 Subject: [llvm-commits] CVS: llvm/tools/llvm-link/llvm-link.cpp Message-ID: <200407041221.HAA11273@zion.cs.uiuc.edu> Changes in directory llvm/tools/llvm-link: llvm-link.cpp updated: 1.37 -> 1.38 --- Log message: Add #include since Value.h does not include it any more. --- Diffs of the changes: (+1 -0) Index: llvm/tools/llvm-link/llvm-link.cpp diff -u llvm/tools/llvm-link/llvm-link.cpp:1.37 llvm/tools/llvm-link/llvm-link.cpp:1.38 --- llvm/tools/llvm-link/llvm-link.cpp:1.37 Wed Jun 23 12:33:09 2004 +++ llvm/tools/llvm-link/llvm-link.cpp Sun Jul 4 07:20:55 2004 @@ -21,6 +21,7 @@ #include "Support/FileUtilities.h" #include "llvm/System/Signals.h" #include +#include #include using namespace llvm; From reid at x10sys.com Sun Jul 4 07:27:01 2004 From: reid at x10sys.com (Reid Spencer) Date: Sun Jul 4 07:27:01 2004 Subject: [llvm-commits] CAUTION: Type != Value Message-ID: <1088943993.15984.308.camel@bashful.x10sys.com> LLVMers, I have committed one of the major changes on the way to finishing bug 122: Type no longer derives from Value. My changes have all been committed and they pass 100% of Feature & Regression tests as well as being able to compile llvm-gcc. Please be aware of the following changes made by my commits: * Type no longer derives from Value (yeah!). Consequently, Types are smaller and hopefully faster. Types no longer have a Uses vector. * You can't use Value and Type interchangeably any more. When you mean a Type, use Type*. When you mean a Value, use Value*. * Value.h no longer #includes . I've made the necessary changes to all the .cpp files but going forward please only #include from a .cpp file * The bytecode file format changed. Types are now written separately from values * There's a new bytecode analysis tool, llvm-bcanalyzer, that will produce statistics about bytecode files. I'm pretty certain this doesn't break *anything*, but a change of this scope isn't without its subtleties. If you suspect something is broken related to these changes or you need further description/explanation, please don't hesitate to contact me. Best Regards, Reid. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20040704/3e4d3d9e/attachment.bin From alkis at cs.uiuc.edu Sun Jul 4 12:24:01 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sun Jul 4 12:24:01 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/RegAllocLinearScan.cpp Message-ID: <200407041723.MAA15107@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: RegAllocLinearScan.cpp updated: 1.76 -> 1.77 --- Log message: Correctly compute the ration of iterations/#intervals. --- Diffs of the changes: (+6 -2) Index: llvm/lib/CodeGen/RegAllocLinearScan.cpp diff -u llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.76 llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.77 --- llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.76 Sun Jul 4 02:59:06 2004 +++ llvm/lib/CodeGen/RegAllocLinearScan.cpp Sun Jul 4 12:23:35 2004 @@ -38,6 +38,9 @@ Statistic efficiency ("regalloc", "Ratio of intervals processed over total intervals"); + static unsigned numIterations = 0; + static unsigned numIntervals = 0; + class RA : public MachineFunctionPass { private: MachineFunction* mf_; @@ -183,7 +186,7 @@ // pick the interval with the earliest start point IntervalPtrs::value_type cur = unhandled_.front(); unhandled_.pop_front(); - ++efficiency; + ++numIterations; DEBUG(std::cerr << "\n*** CURRENT ***: " << *cur << '\n'); processActiveIntervals(cur); @@ -206,7 +209,8 @@ DEBUG(printIntervals("inactive", inactive_.begin(), inactive_.end())); // DEBUG(verifyAssignment()); } - efficiency /= li_->getIntervals().size(); + numIntervals += li_->getIntervals().size(); + efficiency = double(numIterations) / double(numIntervals); // expire any remaining active intervals for (IntervalPtrs::iterator i = active_.begin(); i != active_.end(); ++i) { From llvm at cs.uiuc.edu Sun Jul 4 19:59:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 4 19:59:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Reader/Analyzer.cpp Reader.cpp Reader.h ReaderWrappers.cpp Message-ID: <200407050058.TAA17267@zion.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Reader: Analyzer.cpp updated: 1.8 -> 1.9 Reader.cpp updated: 1.109 -> 1.110 Reader.h updated: 1.2 -> 1.3 ReaderWrappers.cpp updated: 1.24 -> 1.25 --- Log message: Finalize bytecode dumping. The "handleFinish" method was getting called too soon so the function data was not getting dumped (it was generated after the call handleFinish). Also cleaned up the output format for proper indentation. --- Diffs of the changes: (+38 -29) Index: llvm/lib/Bytecode/Reader/Analyzer.cpp diff -u llvm/lib/Bytecode/Reader/Analyzer.cpp:1.8 llvm/lib/Bytecode/Reader/Analyzer.cpp:1.9 --- llvm/lib/Bytecode/Reader/Analyzer.cpp:1.8 Sun Jul 4 06:00:39 2004 +++ llvm/lib/Bytecode/Reader/Analyzer.cpp Sun Jul 4 19:57:50 2004 @@ -185,9 +185,9 @@ } virtual void handleGlobalInitializer(GlobalVariable* GV, Constant* CV) { - dump << " Initializer: GV="; + dump << " Initializer: GV="; GV->print(dump); - dump << " CV="; + dump << " CV="; CV->print(dump); dump << "\n"; } @@ -204,17 +204,17 @@ } virtual void handleCompactionTableBegin() { - dump << " BLOCK: CompactionTable {\n"; + dump << " BLOCK: CompactionTable {\n"; } virtual void handleCompactionTablePlane( unsigned Ty, unsigned NumEntries) { bca.numCmpctnTables++; - dump << " Plane: Ty=" << Ty << " Size=" << NumEntries << "\n"; + dump << " Plane: Ty=" << Ty << " Size=" << NumEntries << "\n"; } virtual void handleCompactionTableType( unsigned i, unsigned TypSlot, const Type* Ty ) { - dump << " Type: " << i << " Slot:" << TypSlot + dump << " Type: " << i << " Slot:" << TypSlot << " is " << Ty->getDescription() << "\n"; } @@ -223,13 +223,13 @@ unsigned TypSlot, unsigned ValSlot, const Type* Ty ) { - dump << " Value: " << i << " TypSlot: " << TypSlot + dump << " Value: " << i << " TypSlot: " << TypSlot << " ValSlot:" << ValSlot << " is " << Ty->getDescription() << "\n"; } virtual void handleCompactionTableEnd() { - dump << " } END BLOCK: CompactionTable\n"; + dump << " } END BLOCK: CompactionTable\n"; } virtual void handleSymbolTableBegin(Function* CF, SymbolTable* ST) { @@ -260,9 +260,9 @@ } virtual void handleFunctionBegin(Function* Func, unsigned Size) { - dump << "BLOCK: Function {\n"; - dump << " Linkage: " << Func->getLinkage() << "\n"; - dump << " Type: " << Func->getType()->getDescription() << "\n"; + dump << " BLOCK: Function {\n"; + dump << " Linkage: " << Func->getLinkage() << "\n"; + dump << " Type: " << Func->getType()->getDescription() << "\n"; const FunctionType* FType = cast(Func->getType()->getElementType()); currFunc = &bca.FunctionInfo[Func]; @@ -284,7 +284,7 @@ } virtual void handleFunctionEnd( Function* Func) { - dump << "} END BLOCK: Function\n"; + dump << " } END BLOCK: Function\n"; currFunc->density = double(currFunc->byteSize) / double(currFunc->numInstructions+currFunc->numBasicBlocks); @@ -298,7 +298,7 @@ } virtual void handleBasicBlockBegin( unsigned blocknum) { - dump << " BLOCK: BasicBlock #" << blocknum << "{\n"; + dump << " BLOCK: BasicBlock #" << blocknum << "{\n"; bca.numBasicBlocks++; bca.numValues++; if ( currFunc ) currFunc->numBasicBlocks++; @@ -306,11 +306,12 @@ virtual bool handleInstruction( unsigned Opcode, const Type* iType, std::vector& Operands, unsigned Size){ - dump << " INST: OpCode=" - << Instruction::getOpcodeName(Opcode) << " Type=" - << iType->getDescription() << "\n"; + dump << " INST: OpCode=" + << Instruction::getOpcodeName(Opcode) << " Type=\"" + << iType->getDescription() << "\""; for ( unsigned i = 0; i < Operands.size(); ++i ) - dump << " Op#" << i << " Slot=" << Operands[i] << "\n"; + dump << " Op(" << i << ")=Slot(" << Operands[i] << ")"; + dump << "\n"; bca.numInstructions++; bca.numValues++; @@ -327,7 +328,7 @@ } virtual void handleBasicBlockEnd(unsigned blocknum) { - dump << " } END BLOCK: BasicBlock #" << blocknum << "{\n"; + dump << " } END BLOCK: BasicBlock #" << blocknum << "{\n"; } virtual void handleGlobalConstantsBegin() { Index: llvm/lib/Bytecode/Reader/Reader.cpp diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.109 llvm/lib/Bytecode/Reader/Reader.cpp:1.110 --- llvm/lib/Bytecode/Reader/Reader.cpp:1.109 Sun Jul 4 06:33:49 2004 +++ llvm/lib/Bytecode/Reader/Reader.cpp Sun Jul 4 19:57:50 2004 @@ -894,7 +894,6 @@ BB = ParsedBasicBlocks[BlockNo] = new BasicBlock(); else BB = ParsedBasicBlocks[BlockNo]; - if (Handler) Handler->handleBasicBlockEnd( BlockNo ); ++BlockNo; F->getBasicBlockList().push_back(BB); @@ -904,6 +903,8 @@ if (!BB->getTerminator()) throw std::string("Non-terminated basic block found!"); + + if (Handler) Handler->handleBasicBlockEnd( BlockNo-1 ); } return BlockNo; @@ -1898,7 +1899,8 @@ /// and \p Length parameters. void BytecodeReader::ParseBytecode( BufPtr Buf, unsigned Length, - const std::string &ModuleID) { + const std::string &ModuleID, + bool processFunctions) { try { At = MemStart = BlockStart = Buf; @@ -1934,14 +1936,19 @@ // Parse the module contents this->ParseModule(); - // Tell the handler we're done - if (Handler) Handler->handleModuleEnd(ModuleID); - // Check for missing functions if ( hasFunctions() ) throw std::string("Function expected, but bytecode stream ended!"); - // Tell the handler we're + // Process all the function bodies now, if requested + if ( processFunctions ) + ParseAllFunctionBodies(); + + // Tell the handler we're done with the module + if (Handler) + Handler->handleModuleEnd(ModuleID); + + // Tell the handler we're finished the parse if (Handler) Handler->handleFinish(); } catch (std::string& errstr ) { Index: llvm/lib/Bytecode/Reader/Reader.h diff -u llvm/lib/Bytecode/Reader/Reader.h:1.2 llvm/lib/Bytecode/Reader/Reader.h:1.3 --- llvm/lib/Bytecode/Reader/Reader.h:1.2 Sun Jul 4 06:04:56 2004 +++ llvm/lib/Bytecode/Reader/Reader.h Sun Jul 4 19:57:50 2004 @@ -127,9 +127,10 @@ public: /// @brief Main interface to parsing a bytecode buffer. void ParseBytecode( - const unsigned char *Buf, ///< Beginning of the bytecode buffer - unsigned Length, ///< Length of the bytecode buffer - const std::string &ModuleID ///< An identifier for the module constructed. + const unsigned char *Buf, ///< Beginning of the bytecode buffer + unsigned Length, ///< Length of the bytecode buffer + const std::string &ModuleID, ///< An identifier for the module constructed. + bool processFunctions=false ///< Process all function bodies fully. ); /// @brief Parse all function bodies Index: llvm/lib/Bytecode/Reader/ReaderWrappers.cpp diff -u llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.24 llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.25 --- llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.24 Sun Jul 4 06:03:03 2004 +++ llvm/lib/Bytecode/Reader/ReaderWrappers.cpp Sun Jul 4 19:57:50 2004 @@ -58,7 +58,7 @@ try { // Parse the bytecode we mmapped in - ParseBytecode(Buffer, Length, Filename); + ParseBytecode(Buffer, Length, Filename, H != 0); } catch (...) { UnmapFileFromAddressSpace(Buffer, Length); throw; @@ -114,7 +114,7 @@ MustDelete = false; } try { - ParseBytecode(ParseBegin, Length, ModuleID); + ParseBytecode(ParseBegin, Length, ModuleID, H != 0); } catch (...) { if (MustDelete) delete [] Buffer; throw; @@ -163,7 +163,7 @@ throw std::string("Standard Input empty!"); FileBuf = &FileData[0]; - ParseBytecode(FileBuf, FileData.size(), ""); + ParseBytecode(FileBuf, FileData.size(), "", H != 0 ); } //===----------------------------------------------------------------------===//