From lattner at cs.uiuc.edu Mon Sep 9 00:50:01 2002 From: lattner at cs.uiuc.edu (Christopher Lattner) Date: Mon Sep 9 00:50:01 2002 Subject: [llvm-commits] CVS: llvm/www/docs/ProgrammersManual.html Message-ID: <200209090549.AAA19540@tank.cs.uiuc.edu> Changes in directory llvm/www/docs: ProgrammersManual.html updated: 1.12 -> 1.13 --- Log message: Stub out another couple sections that it looks like 426's MP1 will really need. --- Diffs of the changes: Index: llvm/www/docs/ProgrammersManual.html diff -u llvm/www/docs/ProgrammersManual.html:1.12 llvm/www/docs/ProgrammersManual.html:1.13 --- llvm/www/docs/ProgrammersManual.html:1.12 Sat Sep 7 00:33:45 2002 +++ llvm/www/docs/ProgrammersManual.html Mon Sep 9 00:49:39 2002 @@ -22,10 +22,14 @@ in a Function
  • Iterating over the Instructions in a BasicBlock +
  • Iterating over the Instructions + in a Function
  • Turning an iterator into a class pointer
  • Finding call sites: a more complex example +
  • Iterating over def-use & use-def + chains
  • Making simple changes


    Iterating over the +Instructions in a Function


    Turning an iterator into a class pointer


    Finding call sites: -a slightly more complex example -


    Finding call sites: a slightly +more complex example


    Iterating over def-use & +use-def chains

       @@ -1235,10 +1261,6 @@ Chris Lattner -<<<<<<< ProgrammersManual.html -Last modified: Fri Sep 6 18:24:38 EDT 2002 -======= -Last modified: Fri Sep 6 18:03:31 EDT 2002 ->>>>>>> 1.10 +Last modified: Mon Sep 9 00:48:53 CDT 2002 From lattner at cs.uiuc.edu Mon Sep 9 00:54:00 2002 From: lattner at cs.uiuc.edu (Christopher Lattner) Date: Mon Sep 9 00:54:00 2002 Subject: [llvm-commits] CVS: llvm/www/docs/ProgrammersManual.html Message-ID: <200209090553.AAA26101@trinity.cs.uiuc.edu> Changes in directory llvm/www/docs: ProgrammersManual.html updated: 1.13 -> 1.14 --- Log message: Clean up the isa section stub. It should not be listed twice --- Diffs of the changes: Index: llvm/www/docs/ProgrammersManual.html diff -u llvm/www/docs/ProgrammersManual.html:1.13 llvm/www/docs/ProgrammersManual.html:1.14 --- llvm/www/docs/ProgrammersManual.html:1.13 Mon Sep 9 00:49:39 2002 +++ llvm/www/docs/ProgrammersManual.html Mon Sep 9 00:53:21 2002 @@ -12,7 +12,8 @@
  • General Information
  • Helpful Hints for Common Operations
      @@ -44,11 +45,8 @@
    --->
  • Useful LLVM APIs
      -
    • isa<>, cast<>, and dyn_cast<> templates - +
    +
       + +The isa<>, cast<> and dyn_cast<> templates +
      + + + + +
    @@ -1261,6 +1270,6 @@ Chris Lattner -Last modified: Mon Sep 9 00:48:53 CDT 2002 +Last modified: Mon Sep 9 00:52:10 CDT 2002 From vadve at cs.uiuc.edu Mon Sep 9 09:55:01 2002 From: vadve at cs.uiuc.edu (Vikram Adve) Date: Mon Sep 9 09:55:01 2002 Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/SparcInstrSelection.cpp Message-ID: <200209091454.JAA29067@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Target/Sparc: SparcInstrSelection.cpp updated: 1.69 -> 1.70 --- Log message: Silly bug fix: Machine code vector could be empty for a no-op cast instruction, e.g., cast double to double. --- Diffs of the changes: Index: llvm/lib/Target/Sparc/SparcInstrSelection.cpp diff -u llvm/lib/Target/Sparc/SparcInstrSelection.cpp:1.69 llvm/lib/Target/Sparc/SparcInstrSelection.cpp:1.70 --- llvm/lib/Target/Sparc/SparcInstrSelection.cpp:1.69 Thu Sep 5 13:32:13 2002 +++ llvm/lib/Target/Sparc/SparcInstrSelection.cpp Mon Sep 9 09:54:21 2002 @@ -1555,19 +1555,23 @@ case 31: // reg: ToFloatTy(reg): case 32: // reg: ToDoubleTy(reg): case 232: // reg: ToDoubleTy(Constant): - + // If this instruction has a parent (a user) in the tree // and the user is translated as an FsMULd instruction, // then the cast is unnecessary. So check that first. // In the future, we'll want to do the same for the FdMULq instruction, // so do the check here instead of only for ToFloatTy(reg). // - if (subtreeRoot->parent() != NULL && - MachineCodeForInstruction::get(((InstructionNode*)subtreeRoot->parent())->getInstruction())[0]->getOpCode() == FSMULD) + if (subtreeRoot->parent() != NULL) { - forwardOperandNum = 0; // forward first operand to user + const MachineCodeForInstruction& mcfi = + MachineCodeForInstruction::get( + cast(subtreeRoot->parent())->getInstruction()); + if (mcfi.size() == 0 || mcfi.front()->getOpCode() == FSMULD) + forwardOperandNum = 0; // forward first operand to user } - else + + if (forwardOperandNum != 0) // we do need the cast { Value* leftVal = subtreeRoot->leftChild()->getValue(); const Type* opType = leftVal->getType(); From jstanley at cs.uiuc.edu Mon Sep 9 10:51:01 2002 From: jstanley at cs.uiuc.edu (Joel Stanley) Date: Mon Sep 9 10:51:01 2002 Subject: [llvm-commits] CVS: llvm/www/docs/ProgrammersManual.html Message-ID: <200209091550.KAA29864@trinity.cs.uiuc.edu> Changes in directory llvm/www/docs: ProgrammersManual.html updated: 1.14 -> 1.15 --- Log message: - Made distinction between object->iterator and iterator->object conversion more clear. - Added content to "Iterating over Instructions in a Function" section. --- Diffs of the changes: Index: llvm/www/docs/ProgrammersManual.html diff -u llvm/www/docs/ProgrammersManual.html:1.14 llvm/www/docs/ProgrammersManual.html:1.15 --- llvm/www/docs/ProgrammersManual.html:1.14 Mon Sep 9 00:53:21 2002 +++ llvm/www/docs/ProgrammersManual.html Mon Sep 9 10:50:33 2002 @@ -285,18 +285,39 @@


    Iterating over the Instructions in a Function


    Turning an iterator into a class -pointer

      +The LLVM compiler infrastructure have many different data structures that may be +traversed. Following the example of the C++ standard template library, the +techniques used to traverse these various data structures are all basically the +same. For a enumerable sequence of values, the XXXbegin() function (or +method) returns an iterator to the start of the sequence, the XXXend() +function returns an iterator pointing to one past the last valid element of the +sequence, and there is some XXXiterator data type that is common +between the two operations.

      + +Because the pattern for iteration is common across many different aspects of the +program representation, the standard template library algorithms may be used on +them, and it is easier to remember how to iterate. First we show a few common +examples of the data structures that need to be traversed. Other data +structures are traversed in very similar ways.

      - -


    Iterating over the -BasicBlocks in a Function


    Iterating over the
    BasicBlocks in a Function

      It's quite common to have a Function instance that you'd like to transform in some way; in particular, you'd like to manipulate its @@ -253,8 +266,9 @@ exactly equivalent to (*i).size() just like you'd expect. -


    Iterating over the -Instructions in a BasicBlock


    Iterating over the
    Instructions in a BasicBlock

      Just like when dealing with BasicBlocks in Functions, it's easy to iterate over the individual @@ -263,10 +277,10 @@
         // blk is a pointer to a BasicBlock instance
      -  for(BasicBlock::iterator i = blk->begin(), e = blk->end(); i != e; ++i) {
      +  for(BasicBlock::iterator i = blk->begin(), e = blk->end(); i != e; ++i)
            // the next statement works since operator<<(ostream&,...) 
            // is overloaded for Instruction&
      -     cerr << *i << endl;
      +     cerr << *i << "\n";
       
      However, this isn't really the best way to print out the contents of a @@ -281,21 +295,23 @@ be removed in the future, so it's best not to depend on it. To print out the pointer value for now, you must cast to void*.

      + -


    Iterating over the -Instructions in a Function


    Iterating over the
    Instructions in a Function

      If you're finding that you commonly iterate over a Function's BasicBlocks and then that BasicBlock's Instructions, InstIterator should be used instead. -You'll need to include llvm/Support/InstIterator.h, and then +You'll need to include llvm/Support/InstIterator.h, and then instantiate InstIterators explicitly in your code. Here's a small example that shows how to dump all instructions in a function to stderr (Note: Dereferencing an InstIterator yields an Instruction*, not an Instruction&!):
      -#include "llvm/Support/InstIterator.h"
      +#include "llvm/Support/InstIterator.h"
       ...
       // Suppose F is a ptr to a function
       for(inst_iterator i = inst_begin(F), e = inst_end(F); i != e; ++i)
      @@ -352,7 +368,7 @@
       
       
       BasicBlock::iterator bbi = ...;
      -BranchInst* b = dyn_cast<BranchInst>(&*bbi);
      +BranchInst* b = dyn_cast<BranchInst>(&*bbi);
       
      It's also possible to turn a class pointer into the corresponding @@ -366,7 +382,7 @@ void printNextInstruction(Instruction* inst) { BasicBlock::iterator it(inst); ++it; // after this line, it refers to the instruction after *inst. - if(it != inst->getParent()->end()) cerr << *it << endl; + if(it != inst->getParent()->end()) cerr << *it << "\n"; }
      Of course, this example is strictly pedagogical, because it'd be much @@ -411,10 +427,10 @@ public: OurFunctionPass(): callCounter(0) { } - virtual runOnFunction(Function& F) { + virtual runOnFunction(Function& F) { for(Function::iterator b = F.begin(), be = F.end(); b != be; ++b) { for(BasicBlock::iterator i = b->begin(); ie = b->end(); i != ie; ++i) { - if(CallInst* callInst = dyn_cast(&*inst)) { + if (CallInst* callInst = dyn_cast<CallInst>(&*inst)) { // we know we've encountered a call instruction, so we // need to determine if it's a call to the // function pointed to by m_func or not. @@ -1280,6 +1296,6 @@ Chris Lattner -Last modified: Mon Sep 9 11:29:35 CDT 2002 +Last modified: Mon Sep 9 14:56:55 CDT 2002 From lattner at cs.uiuc.edu Mon Sep 9 15:26:01 2002 From: lattner at cs.uiuc.edu (Christopher Lattner) Date: Mon Sep 9 15:26:01 2002 Subject: [llvm-commits] CVS: llvm/lib/Transforms/ExprTypeConvert.cpp Message-ID: <200209092025.PAA03887@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Transforms: ExprTypeConvert.cpp updated: 1.51 -> 1.52 --- Log message: Disallow creation of pointer typed shift instructions --- Diffs of the changes: Index: llvm/lib/Transforms/ExprTypeConvert.cpp diff -u llvm/lib/Transforms/ExprTypeConvert.cpp:1.51 llvm/lib/Transforms/ExprTypeConvert.cpp:1.52 --- llvm/lib/Transforms/ExprTypeConvert.cpp:1.51 Fri Aug 30 17:53:07 2002 +++ llvm/lib/Transforms/ExprTypeConvert.cpp Mon Sep 9 15:25:21 2002 @@ -1,4 +1,4 @@ -//===- ExprTypeConvert.cpp - Code to change an LLVM Expr Type ---------------=// +//===- ExprTypeConvert.cpp - Code to change an LLVM Expr Type -------------===// // // This file implements the part of level raising that checks to see if it is // possible to coerce an entire expression tree into a different type. If @@ -193,9 +193,11 @@ return false; break; case Instruction::Shr: + if (!Ty->isInteger()) return false; if (Ty->isSigned() != V->getType()->isSigned()) return false; // FALL THROUGH case Instruction::Shl: + if (!Ty->isInteger()) return false; if (!ExpressionConvertableToType(I->getOperand(0), Ty, CTMap)) return false; break; @@ -633,6 +635,7 @@ // FALL THROUGH case Instruction::Shl: assert(I->getOperand(0) == V); + if (!Ty->isInteger()) return false; return ValueConvertableToType(I, Ty, CTMap); case Instruction::Free: From lattner at cs.uiuc.edu Mon Sep 9 15:27:01 2002 From: lattner at cs.uiuc.edu (Christopher Lattner) Date: Mon Sep 9 15:27:01 2002 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Verifier.cpp Message-ID: <200209092026.PAA03901@trinity.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Verifier.cpp updated: 1.35 -> 1.36 --- Log message: Do not allow adds of pointer types, or many other operations on pointer types. --- Diffs of the changes: Index: llvm/lib/VMCore/Verifier.cpp diff -u llvm/lib/VMCore/Verifier.cpp:1.35 llvm/lib/VMCore/Verifier.cpp:1.36 --- llvm/lib/VMCore/Verifier.cpp:1.35 Thu Aug 22 18:37:09 2002 +++ llvm/lib/VMCore/Verifier.cpp Mon Sep 9 15:26:04 2002 @@ -8,7 +8,7 @@ // // * Both of a binary operator's parameters are the same type // * Verify that the indices of mem access instructions match other operands -// . Verify that arithmetic and other things are only performed on first class +// * Verify that arithmetic and other things are only performed on first class // types. Verify that shifts & logicals only happen on integrals f.e. // . All of the constants in a switch statement are of the correct type // * The code is in valid SSA form @@ -39,6 +39,7 @@ #include "llvm/iPHINode.h" #include "llvm/iTerminators.h" #include "llvm/iOther.h" +#include "llvm/iOperators.h" #include "llvm/iMemory.h" #include "llvm/SymbolTable.h" #include "llvm/PassManager.h" @@ -101,6 +102,7 @@ void visitBasicBlock(BasicBlock &BB); void visitPHINode(PHINode &PN); void visitBinaryOperator(BinaryOperator &B); + void visitShiftInst(ShiftInst &SI); void visitCallInst(CallInst &CI); void visitGetElementPtrInst(GetElementPtrInst &GEP); void visitLoadInst(LoadInst &LI); @@ -313,13 +315,45 @@ // of the same type! // void Verifier::visitBinaryOperator(BinaryOperator &B) { - Assert2(B.getOperand(0)->getType() == B.getOperand(1)->getType(), - "Both operands to a binary operator are not of the same type!", - B.getOperand(0), B.getOperand(1)); + Assert1(B.getOperand(0)->getType() == B.getOperand(1)->getType(), + "Both operands to a binary operator are not of the same type!", &B); + // Check that logical operators are only used with integral operands. + if (B.getOpcode() == Instruction::And || B.getOpcode() == Instruction::Or || + B.getOpcode() == Instruction::Xor) { + Assert1(B.getType()->isIntegral(), + "Logical operators only work with integral types!", &B); + Assert1(B.getType() == B.getOperand(0)->getType(), + "Logical operators must have same type for operands and result!", + &B); + } else if (isa(B)) { + // Check that setcc instructions return bool + Assert1(B.getType() == Type::BoolTy, + "setcc instructions must return boolean values!", &B); + } else { + // Arithmetic operators only work on integer or fp values + Assert1(B.getType() == B.getOperand(0)->getType(), + "Arithmetic operators must have same type for operands and result!", + &B); + Assert1(B.getType()->isInteger() || B.getType()->isFloatingPoint(), + "Arithmetic oeprators must have integer or fp type!", &B); + } + visitInstruction(B); } +void Verifier::visitShiftInst(ShiftInst &SI) { + Assert1(SI.getType()->isInteger(), + "Shift must return an integer result!", &SI); + Assert1(SI.getType() == SI.getOperand(0)->getType(), + "Shift return type must be same as first operand!", &SI); + Assert1(SI.getOperand(1)->getType() == Type::UByteTy, + "Second operand to shift must be ubyte type!", &SI); + visitInstruction(SI); +} + + + void Verifier::visitGetElementPtrInst(GetElementPtrInst &GEP) { const Type *ElTy = GetElementPtrInst::getIndexedType(GEP.getOperand(0)->getType(), @@ -350,7 +384,8 @@ // verifyInstruction - Verify that an instruction is well formed. // void Verifier::visitInstruction(Instruction &I) { - Assert1(I.getParent(), "Instruction not embedded in basic block!", &I); + BasicBlock *BB = I.getParent(); + Assert1(BB, "Instruction not embedded in basic block!", &I); // Check that all uses of the instruction, if they are instructions // themselves, actually have parent basic blocks. If the use is not an @@ -390,13 +425,17 @@ // Make sure that I dominates the end of pred(i) BasicBlock *Pred = PN->getIncomingBlock(i); - Assert2(DS->dominates(I.getParent(), Pred), + // Use must be dominated by by definition unless use is unreachable! + Assert2(DS->dominates(BB, Pred) || + !DS->dominates(&BB->getParent()->getEntryNode(), Pred), "Instruction does not dominate all uses!", &I, PN); } } else { - Assert2(DS->dominates(&I, Use), + // Use must be dominated by by definition unless use is unreachable! + Assert2(DS->dominates(&I, Use) || + !DS->dominates(&BB->getParent()->getEntryNode(),Use->getParent()), "Instruction does not dominate all uses!", &I, Use); } } From lattner at cs.uiuc.edu Mon Sep 9 19:40:01 2002 From: lattner at cs.uiuc.edu (Christopher Lattner) Date: Mon Sep 9 19:40:01 2002 Subject: [llvm-commits] CVS: llvm/www/docs/ProgrammersManual.html Message-ID: <200209100039.TAA20952@tank.cs.uiuc.edu> Changes in directory llvm/www/docs: ProgrammersManual.html updated: 1.17 -> 1.18 --- Log message: Write most of the isa, cast, dyn_cast section. It's not done yet though. --- Diffs of the changes: Index: llvm/www/docs/ProgrammersManual.html diff -u llvm/www/docs/ProgrammersManual.html:1.17 llvm/www/docs/ProgrammersManual.html:1.18 --- llvm/www/docs/ProgrammersManual.html:1.17 Mon Sep 9 14:58:18 2002 +++ llvm/www/docs/ProgrammersManual.html Mon Sep 9 19:39:05 2002 @@ -187,7 +187,68 @@ The isa<>, cast<> and dyn_cast<> templates

  • Finding call sites: a slightly @@ -420,7 +477,6 @@ has to override the runOnFunction method...):
    -
     Function* targetFunc = ...;
     
     class OurFunctionPass : public FunctionPass {
    @@ -430,7 +486,7 @@
         virtual runOnFunction(Function& F) {
      	for(Function::iterator b = F.begin(), be = F.end(); b != be; ++b) {
      	    for(BasicBlock::iterator i = b->begin(); ie = b->end(); i != ie; ++i) {
    - 		if (CallInst* callInst = dyn_cast<CallInst>(&*inst)) {
    + 		if (CallInst* callInst = dyn_cast<CallInst>(&*inst)) {
      		    // we know we've encountered a call instruction, so we
      		    // need to determine if it's a call to the
     	            // function pointed to by m_func or not.
    @@ -1296,6 +1352,6 @@
     Chris Lattner
     
     
    -Last modified: Mon Sep  9 14:56:55 CDT 2002
    +Last modified: Mon Sep  9 19:38:23 CDT 2002
     
     
    
    
    
    
    From lattner at cs.uiuc.edu  Mon Sep  9 22:51:03 2002
    From: lattner at cs.uiuc.edu (Christopher Lattner)
    Date: Mon Sep  9 22:51:03 2002
    Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
    Message-ID: <200209100350.WAA08261@trinity.cs.uiuc.edu>
    
    
    Changes in directory llvm/lib/Transforms/Scalar:
    
    InstructionCombining.cpp updated: 1.53 -> 1.54
    
    ---
    Log message:
    
    Hack unneccesary now that shifts of pointers are no longer legal!
    
    
    ---
    Diffs of the changes:
    
    Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
    diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.53 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.54
    --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.53	Sun Sep  8 16:39:07 2002
    +++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp	Mon Sep  9 22:50:54 2002
    @@ -492,7 +492,6 @@
       if (ConstantUInt *CUI = dyn_cast(Op1)) {
         unsigned TypeBits = Op0->getType()->getPrimitiveSize()*8;
         if (CUI->getValue() >= TypeBits &&
    -        TypeBits && // FIXME: Handle pointer operands here.  This should go away
             !(Op0->getType()->isSigned() && I.getOpcode() == Instruction::Shr))
           return ReplaceInstUsesWith(I, Constant::getNullValue(Op0->getType()));
       }
    
    
    
    
    From lattner at cs.uiuc.edu  Mon Sep  9 23:50:01 2002
    From: lattner at cs.uiuc.edu (Christopher Lattner)
    Date: Mon Sep  9 23:50:01 2002
    Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/IndVarsSimplify/- New directory
    Message-ID: <200209100449.XAA08980@trinity.cs.uiuc.edu>
    
    
    Changes in directory llvm/test/Regression/Transforms/IndVarsSimplify:
    
    - updated:  -> 
    New updated:  -> 
    directory updated:  -> 
    
    ---
    Log message:
    
    Directory /home/vadve/vadve/Research/DynOpt/CVSRepository/llvm/test/Regression/Transforms/IndVarsSimplify added to the repository
    
    
    ---
    Diffs of the changes:
    
    
    
    
    
    
    
    
    
    From lattner at cs.uiuc.edu  Mon Sep  9 23:54:00 2002
    From: lattner at cs.uiuc.edu (Christopher Lattner)
    Date: Mon Sep  9 23:54:00 2002
    Subject: [llvm-commits] CVS: llvm/lib/VMCore/Verifier.cpp
    Message-ID: <200209100453.XAA09345@trinity.cs.uiuc.edu>
    
    
    Changes in directory llvm/lib/VMCore:
    
    Verifier.cpp updated: 1.36 -> 1.37
    
    ---
    Log message:
    
    Fix typeo in assertion message
    
    
    ---
    Diffs of the changes:
    
    Index: llvm/lib/VMCore/Verifier.cpp
    diff -u llvm/lib/VMCore/Verifier.cpp:1.36 llvm/lib/VMCore/Verifier.cpp:1.37
    --- llvm/lib/VMCore/Verifier.cpp:1.36	Mon Sep  9 15:26:04 2002
    +++ llvm/lib/VMCore/Verifier.cpp	Mon Sep  9 23:52:59 2002
    @@ -336,7 +336,7 @@
                 "Arithmetic operators must have same type for operands and result!",
                 &B);
         Assert1(B.getType()->isInteger() || B.getType()->isFloatingPoint(),
    -            "Arithmetic oeprators must have integer or fp type!", &B);
    +            "Arithmetic operators must have integer or fp type!", &B);
       }
       
       visitInstruction(B);
    
    
    
    
    From lattner at cs.uiuc.edu  Mon Sep  9 23:55:01 2002
    From: lattner at cs.uiuc.edu (Christopher Lattner)
    Date: Mon Sep  9 23:55:01 2002
    Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/IndVarsSimplify/2002-09-09-PointerIndVar.ll Makefile
    Message-ID: <200209100454.XAA09523@trinity.cs.uiuc.edu>
    
    
    Changes in directory llvm/test/Regression/Transforms/IndVarsSimplify:
    
    2002-09-09-PointerIndVar.ll added (r1.1)
    Makefile added (r1.1)
    
    ---
    Log message:
    
    Add new testcase for broken indvars case
    
    
    ---
    Diffs of the changes:
    
    
    
    From lattner at cs.uiuc.edu  Mon Sep  9 23:56:01 2002
    From: lattner at cs.uiuc.edu (Christopher Lattner)
    Date: Mon Sep  9 23:56:01 2002
    Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/Makefile
    Message-ID: <200209100455.XAA09562@trinity.cs.uiuc.edu>
    
    
    Changes in directory llvm/test/Regression/Transforms:
    
    Makefile updated: 1.14 -> 1.15
    
    ---
    Log message:
    
    Run indvars tests
    
    
    ---
    Diffs of the changes:
    
    Index: llvm/test/Regression/Transforms/Makefile
    diff -u llvm/test/Regression/Transforms/Makefile:1.14 llvm/test/Regression/Transforms/Makefile:1.15
    --- llvm/test/Regression/Transforms/Makefile:1.14	Thu Jul 18 01:40:31 2002
    +++ llvm/test/Regression/Transforms/Makefile	Mon Sep  9 23:55:36 2002
    @@ -1,5 +1,5 @@
     LEVEL  = ../../..
     DIRS   = ADCE CFGSimplify ConstProp DecomposeMultiDimRefs FunctionResolve GCSE \
    -	 GlobalDCE Inline InstCombine LevelRaise LICM Mem2Reg PiNodeInserter ProfilePaths \
    -	 Reassociate SCCP SimplifyCFG
    +	 GlobalDCE IndVarSimplify Inline InstCombine LevelRaise LICM Mem2Reg \
    +	 PiNodeInserter ProfilePaths Reassociate SCCP SimplifyCFG
     include $(LEVEL)/Makefile.common
    
    
    
    
    From lattner at cs.uiuc.edu  Tue Sep 10 00:25:01 2002
    From: lattner at cs.uiuc.edu (Christopher Lattner)
    Date: Tue Sep 10 00:25:01 2002
    Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
    Message-ID: <200209100524.AAA10708@trinity.cs.uiuc.edu>
    
    
    Changes in directory llvm/lib/Transforms/Scalar:
    
    IndVarSimplify.cpp updated: 1.28 -> 1.29
    
    ---
    Log message:
    
    * Clean up code a little bit
    * Fix bug: test/Regression/Transforms/IndVarsSimplify/2002-09-09-PointerIndVar.ll
    
    
    ---
    Diffs of the changes:
    
    Index: llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
    diff -u llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1.28 llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1.29
    --- llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1.28	Thu Aug  8 14:01:26 2002
    +++ llvm/lib/Transforms/Scalar/IndVarSimplify.cpp	Tue Sep 10 00:24:05 2002
    @@ -16,18 +16,19 @@
     #include "Support/STLExtras.h"
     #include "Support/StatisticReporter.h"
     
    -static Statistic<> NumRemoved ("indvars\t\t- Number of aux indvars removed");
    -static Statistic<> NumInserted("indvars\t\t- Number of cannonical indvars added");
    -
    +namespace {
    +  Statistic<> NumRemoved ("indvars\t\t- Number of aux indvars removed");
    +  Statistic<> NumInserted("indvars\t\t- Number of cannonical indvars added");
    +}
     
     // InsertCast - Cast Val to Ty, setting a useful name on the cast if Val has a
     // name...
     //
    -static Instruction *InsertCast(Instruction *Val, const Type *Ty,
    +static Instruction *InsertCast(Value *Val, const Type *Ty,
                                    BasicBlock::iterator It) {
       Instruction *Cast = new CastInst(Val, Ty);
       if (Val->hasName()) Cast->setName(Val->getName()+"-casted");
    -  Val->getParent()->getInstList().insert(It, Cast);
    +  It->getParent()->getInstList().insert(It, Cast);
       return Cast;
     }
     
    @@ -61,7 +62,8 @@
       bool FoundIndVars = false;
       InductionVariable *Cannonical = 0;
       for (unsigned i = 0; i < IndVars.size(); ++i) {
    -    if (IndVars[i].InductionType == InductionVariable::Cannonical)
    +    if (IndVars[i].InductionType == InductionVariable::Cannonical &&
    +        !isa(IndVars[i].Phi->getType()))
           Cannonical = &IndVars[i];
         if (IndVars[i].InductionType != InductionVariable::Unknown)
           FoundIndVars = true;
    @@ -128,33 +130,39 @@
     
         DEBUG(IV->print(std::cerr));
     
    +    // Don't do math with pointers...
    +    const Type *IVTy = IV->Phi->getType();
    +    if (isa(IVTy)) IVTy = Type::ULongTy;
    +
         // Don't modify the cannonical indvar or unrecognized indvars...
         if (IV != Cannonical && IV->InductionType != InductionVariable::Unknown) {
           Instruction *Val = IterCount;
           if (!isa(IV->Step) ||   // If the step != 1
               !cast(IV->Step)->equalsInt(1)) {
    -        std::string Name;   // Create a scale by the step value...
    -        if (IV->Phi->hasName()) Name = IV->Phi->getName()+"-scale";
     
             // If the types are not compatible, insert a cast now...
    -        if (Val->getType() != IV->Step->getType())
    -          Val = InsertCast(Val, IV->Step->getType(), AfterPHIIt);
    +        if (Val->getType() != IVTy)
    +          Val = InsertCast(Val, IVTy, AfterPHIIt);
    +        if (IV->Step->getType() != IVTy)
    +          IV->Step = InsertCast(IV->Step, IVTy, AfterPHIIt);
     
    -        Val = BinaryOperator::create(Instruction::Mul, Val, IV->Step, Name);
    +        Val = BinaryOperator::create(Instruction::Mul, Val, IV->Step,
    +                                     IV->Phi->getName()+"-scale");
             // Insert the phi node at the end of the other phi nodes...
             Header->getInstList().insert(AfterPHIIt, Val);
           }
     
    -      if (!isa(IV->Start) ||   // If the start != 0
    -          !cast(IV->Start)->isNullValue()) {
    -        std::string Name;   // Create a offset by the start value...
    -        if (IV->Phi->hasName()) Name = IV->Phi->getName()+"-offset";
    -
    +      // If the start != 0
    +      if (IV->Start != Constant::getNullValue(IV->Start->getType())) {
             // If the types are not compatible, insert a cast now...
    -        if (Val->getType() != IV->Start->getType())
    -          Val = InsertCast(Val, IV->Start->getType(), AfterPHIIt);
    +        if (Val->getType() != IVTy)
    +          Val = InsertCast(Val, IVTy, AfterPHIIt);
    +        if (IV->Start->getType() != IVTy)
    +          IV->Start = InsertCast(IV->Start, IVTy, AfterPHIIt);
    +
    +        Val = BinaryOperator::create(Instruction::Add, Val, IV->Start,
    +                                     IV->Phi->getName()+"-offset");
     
    -        Val = BinaryOperator::create(Instruction::Add, Val, IV->Start, Name);
             // Insert the phi node at the end of the other phi nodes...
             Header->getInstList().insert(AfterPHIIt, Val);
           }
    
    
    
    
    From lattner at cs.uiuc.edu  Tue Sep 10 10:21:01 2002
    From: lattner at cs.uiuc.edu (Chris Lattner)
    Date: Tue Sep 10 10:21:01 2002
    Subject: [llvm-commits] CVS: llvm/www/docs/ProgrammersManual.html
    Message-ID: <200209101520.KAA05430@tank.cs.uiuc.edu>
    
    
    Changes in directory llvm/www/docs:
    
    ProgrammersManual.html updated: 1.18 -> 1.19
    
    ---
    Log message:
    
    Finish up the isa/cast/dyn_cast section
    
    
    ---
    Diffs of the changes:
    
    Index: llvm/www/docs/ProgrammersManual.html
    diff -u llvm/www/docs/ProgrammersManual.html:1.18 llvm/www/docs/ProgrammersManual.html:1.19
    --- llvm/www/docs/ProgrammersManual.html:1.18	Mon Sep  9 19:39:05 2002
    +++ llvm/www/docs/ProgrammersManual.html	Tue Sep 10 10:20:46 2002
    @@ -97,8 +97,8 @@
         
  • Important iterator invalidation semantics to be aware of -

    Written by Dinakar Dhurjati - Chris Lattner, and +

    Written by Chris Lattner, + Dinakar Dhurjati, and Joel Stanley

    @@ -235,7 +235,20 @@ pointer to it (this operator does not work with references). If the operand is not of the correct type, a null pointer is returned. Thus, this works very much like the dynamic_cast operator in C++, and should be used in the same -circumstances. An example is:

    +circumstances. Typically, the dyn_cast<> operator is used in an +if statement or some other flow control statement like this:

    + +

    +  if (AllocationInst *AI = dyn_cast<AllocationInst>(Val)) {
    +    ...
    +  }
    +

    + +This form of the if statement effectively combines together a call to +isa<> and a call to cast<> into one statement, +which is very convenient.

    + +Another common example is:

       // Loop over all of the phi nodes in a basic block
    @@ -244,12 +257,36 @@
         cerr << *PN;
     

    -Note that you should not use the dyn_cast<> operator in a series -of chained if statements, use an visitor instead... FIXME: continue.

    +Note that the dyn_cast<> operator, like C++'s +dynamic_cast or Java's instanceof operator, can be abused. In +particular you should not use big chained if/then/else blocks to check +for lots of different variants of classes. If you find yourself wanting to do +this, it is much cleaner and more efficient to use the InstVisitor class to +dispatch over the instruction type directly.

    + + +

    cast_or_null<>: + +
    The cast_or_null<> operator works just like the +cast<> operator, except that it allows for a null pointer as an +argument (which it then propogates). This can sometimes be useful, allowing you +to combine several null checks into one.

    + + +

    dyn_cast_or_null<>: +
    The dyn_cast_or_null<> operator works just like the +dyn_cast<> operator, except that it allows for a null pointer as +an argument (which it then propogates). This can sometimes be useful, allowing +you to combine several null checks into one.

    +These five templates can be used with any classes, whether they have a v-table +or not. To add support for these templates, you simply need to add +classof static methods to the class you are interested casting to. +Describing this is currently outside the scope of this document, but there are +lots of examples in the LLVM sourcebase.

    @@ -1352,6 +1389,6 @@ Chris Lattner -Last modified: Mon Sep 9 19:38:23 CDT 2002 +Last modified: Tue Sep 10 10:19:56 CDT 2002 From lattner at cs.uiuc.edu Tue Sep 10 10:27:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 10 10:27:01 2002 Subject: [llvm-commits] CVS: llvm/include/llvm/Value.h Message-ID: <200209101526.KAA15974@trinity.cs.uiuc.edu> Changes in directory llvm/include/llvm: Value.h updated: 1.35 -> 1.36 --- Log message: Eliminate setType method Now the only way to set the type of a value is in the ctor for an object --- Diffs of the changes: Index: llvm/include/llvm/Value.h diff -u llvm/include/llvm/Value.h:1.35 llvm/include/llvm/Value.h:1.36 --- llvm/include/llvm/Value.h:1.35 Sun Aug 25 17:54:55 2002 +++ llvm/include/llvm/Value.h Tue Sep 10 10:26:27 2002 @@ -55,8 +55,6 @@ void operator=(const Value &); // Do not implement Value(const Value &); // Do not implement -protected: - inline void setType(const Type *ty) { Ty = ty; } public: Value(const Type *Ty, ValueTy vty, const std::string &name = ""); virtual ~Value(); From lattner at cs.uiuc.edu Tue Sep 10 10:28:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 10 10:28:01 2002 Subject: [llvm-commits] CVS: llvm/include/llvm/Instruction.def Message-ID: <200209101527.KAA16003@trinity.cs.uiuc.edu> Changes in directory llvm/include/llvm: Instruction.def updated: 1.4 -> 1.5 --- Log message: Eliminate the GenericBinaryInst class. --- Diffs of the changes: Index: llvm/include/llvm/Instruction.def diff -u llvm/include/llvm/Instruction.def:1.4 llvm/include/llvm/Instruction.def:1.5 --- llvm/include/llvm/Instruction.def:1.4 Thu Aug 15 11:14:48 2002 +++ llvm/include/llvm/Instruction.def Tue Sep 10 10:27:31 2002 @@ -81,16 +81,16 @@ // Standard binary operators... FIRST_BINARY_INST( 6) -HANDLE_BINARY_INST( 6, Add , GenericBinaryInst) -HANDLE_BINARY_INST( 7, Sub , GenericBinaryInst) -HANDLE_BINARY_INST( 8, Mul , GenericBinaryInst) -HANDLE_BINARY_INST( 9, Div , GenericBinaryInst) -HANDLE_BINARY_INST(10, Rem , GenericBinaryInst) +HANDLE_BINARY_INST( 6, Add , BinaryOperator) +HANDLE_BINARY_INST( 7, Sub , BinaryOperator) +HANDLE_BINARY_INST( 8, Mul , BinaryOperator) +HANDLE_BINARY_INST( 9, Div , BinaryOperator) +HANDLE_BINARY_INST(10, Rem , BinaryOperator) // Logical operators... -HANDLE_BINARY_INST(11, And , GenericBinaryInst) -HANDLE_BINARY_INST(12, Or , GenericBinaryInst) -HANDLE_BINARY_INST(13, Xor , GenericBinaryInst) +HANDLE_BINARY_INST(11, And , BinaryOperator) +HANDLE_BINARY_INST(12, Or , BinaryOperator) +HANDLE_BINARY_INST(13, Xor , BinaryOperator) // Binary comparison operators... HANDLE_BINARY_INST(14, SetEQ , SetCondInst) From lattner at cs.uiuc.edu Tue Sep 10 10:35:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 10 10:35:01 2002 Subject: [llvm-commits] CVS: llvm/include/llvm/iOperators.h Message-ID: <200209101534.KAA16147@trinity.cs.uiuc.edu> Changes in directory llvm/include/llvm: iOperators.h updated: 1.12 -> 1.13 --- Log message: * Eliminate GenericBinaryInst class * Allow specifying where to insert a newly created SetCondInst --- Diffs of the changes: Index: llvm/include/llvm/iOperators.h diff -u llvm/include/llvm/iOperators.h:1.12 llvm/include/llvm/iOperators.h:1.13 --- llvm/include/llvm/iOperators.h:1.12 Sun Sep 1 14:46:36 2002 +++ llvm/include/llvm/iOperators.h Tue Sep 10 10:34:41 2002 @@ -1,34 +1,22 @@ -//===-- llvm/iBinary.h - Binary Operator node definitions --------*- C++ -*--=// +//===-- llvm/iOperators.h - Binary Operator node definitions ----*- C++ -*-===// // -// This file contains the declarations of all of the Binary Operator classes. +// This file contains the declarations of the Binary Operator classes. // //===----------------------------------------------------------------------===// -#ifndef LLVM_IBINARY_H -#define LLVM_IBINARY_H +#ifndef LLVM_IOPERATORS_H +#define LLVM_IOPERATORS_H #include "llvm/InstrTypes.h" -//===----------------------------------------------------------------------===// -// Classes to represent Binary operators -//===----------------------------------------------------------------------===// -// -// All of these classes are subclasses of the BinaryOperator class... -// - -class GenericBinaryInst : public BinaryOperator { -public: - GenericBinaryInst(BinaryOps Opcode, Value *S1, Value *S2, - const std::string &Name = "") - : BinaryOperator(Opcode, S1, S2, Name) { - } -}; - +/// SetCondInst class - Represent a setCC operator, where CC is eq, ne, lt, gt, +/// le, or ge. +/// class SetCondInst : public BinaryOperator { BinaryOps OpType; public: SetCondInst(BinaryOps Opcode, Value *LHS, Value *RHS, - const std::string &Name = ""); + const std::string &Name = "", Instruction *InsertBefore = 0); /// getInverseCondition - Return the inverse of the current condition opcode. /// For example seteq -> setne, setgt -> setle, setlt -> setge, etc... From lattner at cs.uiuc.edu Tue Sep 10 10:36:00 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 10 10:36:00 2002 Subject: [llvm-commits] CVS: llvm/include/llvm/Support/InstVisitor.h Message-ID: <200209101535.KAA16178@trinity.cs.uiuc.edu> Changes in directory llvm/include/llvm/Support: InstVisitor.h updated: 1.13 -> 1.14 --- Log message: Eliminate the GenericBinaryInst class --- Diffs of the changes: Index: llvm/include/llvm/Support/InstVisitor.h diff -u llvm/include/llvm/Support/InstVisitor.h:1.13 llvm/include/llvm/Support/InstVisitor.h:1.14 --- llvm/include/llvm/Support/InstVisitor.h:1.13 Thu Aug 22 18:37:24 2002 +++ llvm/include/llvm/Support/InstVisitor.h Tue Sep 10 10:35:23 2002 @@ -159,7 +159,6 @@ RetTy visitBranchInst(BranchInst &I) { DELEGATE(TerminatorInst);} RetTy visitSwitchInst(SwitchInst &I) { DELEGATE(TerminatorInst);} RetTy visitInvokeInst(InvokeInst &I) { DELEGATE(TerminatorInst);} - RetTy visitGenericBinaryInst(GenericBinaryInst &I){ DELEGATE(BinaryOperator);} RetTy visitSetCondInst(SetCondInst &I) { DELEGATE(BinaryOperator);} RetTy visitMallocInst(MallocInst &I) { DELEGATE(AllocationInst);} RetTy visitAllocaInst(AllocaInst &I) { DELEGATE(AllocationInst);} From lattner at cs.uiuc.edu Tue Sep 10 10:36:03 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 10 10:36:03 2002 Subject: [llvm-commits] CVS: llvm/lib/Analysis/InductionVariable.cpp Message-ID: <200209101535.KAA16191@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: InductionVariable.cpp updated: 1.18 -> 1.19 --- Log message: Clean up indvar printing --- Diffs of the changes: Index: llvm/lib/Analysis/InductionVariable.cpp diff -u llvm/lib/Analysis/InductionVariable.cpp:1.18 llvm/lib/Analysis/InductionVariable.cpp:1.19 --- llvm/lib/Analysis/InductionVariable.cpp:1.18 Fri Aug 30 17:51:40 2002 +++ llvm/lib/Analysis/InductionVariable.cpp Tue Sep 10 10:35:39 2002 @@ -160,7 +160,7 @@ case InductionVariable::Linear: o << "Linear "; break; case InductionVariable::Unknown: o << "Unrecognized "; break; } - o << "Induction Variable"; + o << "Induction Variable: "; if (Phi) { WriteAsOperand(o, Phi); o << ":\n" << Phi; @@ -169,7 +169,7 @@ } if (InductionType == InductionVariable::Unknown) return; - o << " Start ="; WriteAsOperand(o, Start); - o << " Step =" ; WriteAsOperand(o, Step); + o << " Start = "; WriteAsOperand(o, Start); + o << " Step = " ; WriteAsOperand(o, Step); o << "\n"; } From lattner at cs.uiuc.edu Tue Sep 10 10:37:00 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 10 10:37:00 2002 Subject: [llvm-commits] CVS: llvm/include/llvm/InstrTypes.h Instruction.h iMemory.h iOther.h iPHINode.h iTerminators.h Message-ID: <200209101536.KAA16219@trinity.cs.uiuc.edu> Changes in directory llvm/include/llvm: InstrTypes.h updated: 1.28 -> 1.29 Instruction.h updated: 1.33 -> 1.34 iMemory.h updated: 1.34 -> 1.35 iOther.h updated: 1.29 -> 1.30 iPHINode.h updated: 1.3 -> 1.4 iTerminators.h updated: 1.22 -> 1.23 --- Log message: Implement support for inserting an instruction into a basic block right when it is created. --- Diffs of the changes: Index: llvm/include/llvm/InstrTypes.h diff -u llvm/include/llvm/InstrTypes.h:1.28 llvm/include/llvm/InstrTypes.h:1.29 --- llvm/include/llvm/InstrTypes.h:1.28 Sun Aug 25 17:54:54 2002 +++ llvm/include/llvm/InstrTypes.h Tue Sep 10 10:36:07 2002 @@ -20,9 +20,11 @@ /// class TerminatorInst : public Instruction { protected: - TerminatorInst(Instruction::TermOps iType); + TerminatorInst(Instruction::TermOps iType, Instruction *InsertBefore = 0); TerminatorInst(const Type *Ty, Instruction::TermOps iType, - const std::string &Name = ""); + const std::string &Name = "", Instruction *InsertBefore = 0) + : Instruction(Ty, iType, Name, InsertBefore) { + } public: /// Terminators must implement the methods required by Instruction... @@ -59,23 +61,20 @@ class BinaryOperator : public Instruction { protected: - BinaryOperator(BinaryOps iType, Value *S1, Value *S2, - const std::string &Name = "") - : Instruction(S1->getType(), iType, Name) { - Operands.reserve(2); - Operands.push_back(Use(S1, this)); - Operands.push_back(Use(S2, this)); - assert(Operands[0] && Operands[1] && - Operands[0]->getType() == Operands[1]->getType()); - } + BinaryOperator(BinaryOps iType, Value *S1, Value *S2, const Type *Ty, + const std::string &Name, Instruction *InsertBefore); public: - /// create() - Construct a binary instruction, given the opcode - /// and the two operands. + /// create() - Construct a binary instruction, given the opcode and the two + /// operands. Optionally (if InstBefore is specified) insert the instruction + /// into a BasicBlock right before the specified instruction. The specified + /// Instruction is allowed to be a dereferenced end iterator. /// static BinaryOperator *create(BinaryOps Op, Value *S1, Value *S2, - const std::string &Name = ""); + const std::string &Name = "", + Instruction *InsertBefore = 0); + /// Helper functions to construct and inspect unary operations (NEG and NOT) /// via binary operators SUB and XOR: @@ -83,8 +82,10 @@ /// createNeg, createNot - Create the NEG and NOT /// instructions out of SUB and XOR instructions. /// - static BinaryOperator *createNeg(Value *Op, const std::string &Name = ""); - static BinaryOperator *createNot(Value *Op, const std::string &Name = ""); + static BinaryOperator *createNeg(Value *Op, const std::string &Name = "", + Instruction *InsertBefore = 0); + static BinaryOperator *createNot(Value *Op, const std::string &Name = "", + Instruction *InsertBefore = 0); /// isNeg, isNot - Check if the given Value is a NEG or NOT instruction. /// Index: llvm/include/llvm/Instruction.h diff -u llvm/include/llvm/Instruction.h:1.33 llvm/include/llvm/Instruction.h:1.34 --- llvm/include/llvm/Instruction.h:1.33 Fri Sep 6 16:31:57 2002 +++ llvm/include/llvm/Instruction.h Tue Sep 10 10:36:08 2002 @@ -1,4 +1,4 @@ -//===-- llvm/Instruction.h - Instruction class definition --------*- C++ -*--=// +//===-- llvm/Instruction.h - Instruction class definition -------*- C++ -*-===// // // This file contains the declaration of the Instruction class, which is the // base class for all of the LLVM instructions. @@ -25,8 +25,10 @@ void setParent(BasicBlock *P); protected: unsigned iType; // InstructionType: The opcode of the instruction + + Instruction(const Type *Ty, unsigned iType, const std::string &Name = "", + Instruction *InsertBefore = 0); public: - Instruction(const Type *Ty, unsigned iType, const std::string &Name = ""); virtual ~Instruction() { assert(Parent == 0 && "Instruction still embedded in basic block!"); } Index: llvm/include/llvm/iMemory.h diff -u llvm/include/llvm/iMemory.h:1.34 llvm/include/llvm/iMemory.h:1.35 --- llvm/include/llvm/iMemory.h:1.34 Thu Aug 22 18:37:20 2002 +++ llvm/include/llvm/iMemory.h Tue Sep 10 10:36:09 2002 @@ -21,7 +21,7 @@ class AllocationInst : public Instruction { protected: AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, - const std::string &Name = ""); + const std::string &Name = "", Instruction *InsertBefore = 0); public: // isArrayAllocation - Return true if there is an allocation size parameter @@ -64,8 +64,9 @@ //===----------------------------------------------------------------------===// struct MallocInst : public AllocationInst { - MallocInst(const Type *Ty, Value *ArraySize = 0, const std::string &Name = "") - : AllocationInst(Ty, ArraySize, Malloc, Name) {} + MallocInst(const Type *Ty, Value *ArraySize = 0, const std::string &Name = "", + Instruction *InsertBefore = 0) + : AllocationInst(Ty, ArraySize, Malloc, Name, InsertBefore) {} virtual Instruction *clone() const { return new MallocInst((Type*)getType(), (Value*)Operands[0].get()); @@ -87,8 +88,9 @@ //===----------------------------------------------------------------------===// struct AllocaInst : public AllocationInst { - AllocaInst(const Type *Ty, Value *ArraySize = 0, const std::string &Name = "") - : AllocationInst(Ty, ArraySize, Alloca, Name) {} + AllocaInst(const Type *Ty, Value *ArraySize = 0, const std::string &Name = "", + Instruction *InsertBefore = 0) + : AllocationInst(Ty, ArraySize, Alloca, Name, InsertBefore) {} virtual Instruction *clone() const { return new AllocaInst((Type*)getType(), (Value*)Operands[0].get()); @@ -110,7 +112,7 @@ //===----------------------------------------------------------------------===// struct FreeInst : public Instruction { - FreeInst(Value *Ptr); + FreeInst(Value *Ptr, Instruction *InsertBefore = 0); virtual Instruction *clone() const { return new FreeInst(Operands[0]); } @@ -137,7 +139,8 @@ Operands.push_back(Use(LI.Operands[0], this)); } public: - LoadInst(Value *Ptr, const std::string &Name = ""); + LoadInst(Value *Ptr, const std::string &Name = "", + Instruction *InsertBefore = 0); virtual Instruction *clone() const { return new LoadInst(*this); } @@ -166,7 +169,7 @@ Operands.push_back(Use(SI.Operands[1], this)); } public: - StoreInst(Value *Val, Value *Ptr); + StoreInst(Value *Val, Value *Ptr, Instruction *InsertBefore = 0); virtual Instruction *clone() const { return new StoreInst(*this); } virtual bool hasSideEffects() const { return true; } @@ -198,7 +201,7 @@ } public: GetElementPtrInst(Value *Ptr, const std::vector &Idx, - const std::string &Name = ""); + const std::string &Name = "", Instruction *InsertBefore =0); virtual Instruction *clone() const { return new GetElementPtrInst(*this); } // getType - Overload to return most specific pointer type... Index: llvm/include/llvm/iOther.h diff -u llvm/include/llvm/iOther.h:1.29 llvm/include/llvm/iOther.h:1.30 --- llvm/include/llvm/iOther.h:1.29 Sun Jul 14 17:43:35 2002 +++ llvm/include/llvm/iOther.h Tue Sep 10 10:36:10 2002 @@ -1,7 +1,7 @@ //===-- llvm/iOther.h - "Other" instruction node definitions -----*- C++ -*--=// // // This file contains the declarations for instructions that fall into the -// grandios 'other' catagory... +// grandiose 'other' catagory... // //===----------------------------------------------------------------------===// @@ -14,17 +14,18 @@ // CastInst Class //===----------------------------------------------------------------------===// -// CastInst - This class represents a cast from Operand[0] to the type of -// the instruction (i->getType()). -// +/// CastInst - This class represents a cast from Operand[0] to the type of +/// the instruction (i->getType()). +/// class CastInst : public Instruction { CastInst(const CastInst &CI) : Instruction(CI.getType(), Cast) { Operands.reserve(1); Operands.push_back(Use(CI.Operands[0], this)); } public: - CastInst(Value *S, const Type *Ty, const std::string &Name = "") - : Instruction(Ty, Cast, Name) { + CastInst(Value *S, const Type *Ty, const std::string &Name = "", + Instruction *InsertBefore = 0) + : Instruction(Ty, Cast, Name, InsertBefore) { Operands.reserve(1); Operands.push_back(Use(S, this)); } @@ -43,13 +44,14 @@ //===----------------------------------------------------------------------===// -// Classes to function calls and method invocations +// CallInst Class //===----------------------------------------------------------------------===// class CallInst : public Instruction { CallInst(const CallInst &CI); public: - CallInst(Value *M, const std::vector &Par, const std::string & = ""); + CallInst(Value *F, const std::vector &Par, + const std::string &Name = "", Instruction *InsertBefore = 0); virtual Instruction *clone() const { return new CallInst(*this); } bool hasSideEffects() const { return true; } @@ -89,8 +91,9 @@ Operands.push_back(Use(SI.Operands[1], this)); } public: - ShiftInst(OtherOps Opcode, Value *S, Value *SA, const std::string &Name = "") - : Instruction(S->getType(), Opcode, Name) { + ShiftInst(OtherOps Opcode, Value *S, Value *SA, const std::string &Name = "", + Instruction *InsertBefore = 0) + : Instruction(S->getType(), Opcode, Name, InsertBefore) { assert((Opcode == Shl || Opcode == Shr) && "ShiftInst Opcode invalid!"); Operands.reserve(2); Operands.push_back(Use(S, this)); Index: llvm/include/llvm/iPHINode.h diff -u llvm/include/llvm/iPHINode.h:1.3 llvm/include/llvm/iPHINode.h:1.4 --- llvm/include/llvm/iPHINode.h:1.3 Sun Jul 14 17:43:36 2002 +++ llvm/include/llvm/iPHINode.h Tue Sep 10 10:36:11 2002 @@ -21,26 +21,30 @@ class PHINode : public Instruction { PHINode(const PHINode &PN); public: - PHINode(const Type *Ty, const std::string &Name = ""); + PHINode(const Type *Ty, const std::string &Name = "", + Instruction *InsertBefore = 0) + : Instruction(Ty, Instruction::PHINode, Name, InsertBefore) { + } virtual Instruction *clone() const { return new PHINode(*this); } - // getNumIncomingValues - Return the number of incoming edges the PHI node has - inline unsigned getNumIncomingValues() const { return Operands.size()/2; } + /// getNumIncomingValues - Return the number of incoming edges the PHI node + /// has + unsigned getNumIncomingValues() const { return Operands.size()/2; } - // getIncomingValue - Return incoming value #x - inline const Value *getIncomingValue(unsigned i) const { + /// getIncomingValue - Return incoming value #x + const Value *getIncomingValue(unsigned i) const { return Operands[i*2]; } - inline Value *getIncomingValue(unsigned i) { + Value *getIncomingValue(unsigned i) { return Operands[i*2]; } - inline void setIncomingValue(unsigned i, Value *V) { + void setIncomingValue(unsigned i, Value *V) { Operands[i*2] = V; } - // getIncomingBlock - Return incoming basic block #x - inline const BasicBlock *getIncomingBlock(unsigned i) const { + /// getIncomingBlock - Return incoming basic block #x + const BasicBlock *getIncomingBlock(unsigned i) const { return (const BasicBlock*)Operands[i*2+1].get(); } inline BasicBlock *getIncomingBlock(unsigned i) { @@ -50,23 +54,23 @@ Operands[i*2+1] = (Value*)BB; } - // addIncoming - Add an incoming value to the end of the PHI list + /// addIncoming - Add an incoming value to the end of the PHI list void addIncoming(Value *D, BasicBlock *BB); - - // removeIncomingValue - Remove an incoming value. This is useful if a - // predecessor basic block is deleted. The value removed is returned. + + /// removeIncomingValue - Remove an incoming value. This is useful if a + /// predecessor basic block is deleted. The value removed is returned. Value *removeIncomingValue(const BasicBlock *BB); - // getBasicBlockIndex - Return the first index of the specified basic - // block in the value list for this PHI. Returns -1 if no instance. - // + /// getBasicBlockIndex - Return the first index of the specified basic + /// block in the value list for this PHI. Returns -1 if no instance. + /// int getBasicBlockIndex(const BasicBlock *BB) const { for (unsigned i = 0; i < Operands.size()/2; ++i) if (getIncomingBlock(i) == BB) return i; return -1; } - // Methods for support type inquiry through isa, cast, and dyn_cast: + /// Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const PHINode *) { return true; } static inline bool classof(const Instruction *I) { return I->getOpcode() == Instruction::PHINode; Index: llvm/include/llvm/iTerminators.h diff -u llvm/include/llvm/iTerminators.h:1.22 llvm/include/llvm/iTerminators.h:1.23 --- llvm/include/llvm/iTerminators.h:1.22 Thu Jul 25 10:39:05 2002 +++ llvm/include/llvm/iTerminators.h Tue Sep 10 10:36:11 2002 @@ -1,9 +1,8 @@ -//===-- llvm/iTerminators.h - Termintator instruction nodes ------*- C++ -*--=// +//===-- llvm/iTerminators.h - Termintator instruction nodes -----*- C++ -*-===// // -// This file contains the declarations for all the subclasses of the -// Instruction class, which is itself defined in the Instruction.h file. In -// between these definitions and the Instruction class are classes that expose -// the SSA properties of each instruction, and that form the SSA graph. +// This file contains the declarations for all the subclasses of the Instruction +// class which represent "terminator" instructions. Terminator instructions are +// the only instructions allowed and required to terminate a BasicBlock. // //===----------------------------------------------------------------------===// @@ -12,11 +11,6 @@ #include "llvm/InstrTypes.h" -//===----------------------------------------------------------------------===// -// Classes to represent Basic Block "Terminator" instructions -//===----------------------------------------------------------------------===// - - //===--------------------------------------------------------------------------- // ReturnInst - Return a value (possibly void), from a method. Execution does // not continue in this method any longer. @@ -30,7 +24,8 @@ } } public: - ReturnInst(Value *RetVal = 0) : TerminatorInst(Instruction::Ret) { + ReturnInst(Value *RetVal = 0, Instruction *InsertBefore = 0) + : TerminatorInst(Instruction::Ret, InsertBefore) { if (RetVal) { Operands.reserve(1); Operands.push_back(Use(RetVal, this)); @@ -74,7 +69,8 @@ BranchInst(const BranchInst &BI); public: // If cond = null, then is an unconditional br... - BranchInst(BasicBlock *IfTrue, BasicBlock *IfFalse = 0, Value *cond = 0); + BranchInst(BasicBlock *IfTrue, BasicBlock *IfFalse = 0, Value *cond = 0, + Instruction *InsertBefore = 0); virtual Instruction *clone() const { return new BranchInst(*this); } @@ -84,7 +80,7 @@ inline const Value *getCondition() const { return isUnconditional() ? 0 : Operands[2].get(); } - inline Value *getCondition() { + Value *getCondition() { return isUnconditional() ? 0 : Operands[2].get(); } @@ -133,7 +129,7 @@ // Operand[2n+1] = BasicBlock to go to on match SwitchInst(const SwitchInst &RI); public: - SwitchInst(Value *Value, BasicBlock *Default); + SwitchInst(Value *Value, BasicBlock *Default, Instruction *InsertBefore = 0); virtual Instruction *clone() const { return new SwitchInst(*this); } @@ -194,7 +190,8 @@ InvokeInst(const InvokeInst &BI); public: InvokeInst(Value *Meth, BasicBlock *IfNormal, BasicBlock *IfException, - const std::vector &Params, const std::string &Name = ""); + const std::vector &Params, const std::string &Name = "", + Instruction *InsertBefore = 0); virtual Instruction *clone() const { return new InvokeInst(*this); } From lattner at cs.uiuc.edu Tue Sep 10 10:44:02 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 10 10:44:02 2002 Subject: [llvm-commits] CVS: llvm/lib/Support/LeakDetector.cpp Message-ID: <200209101543.KAA16292@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Support: LeakDetector.cpp updated: 1.1 -> 1.2 --- Log message: Remove extra #include --- Diffs of the changes: Index: llvm/lib/Support/LeakDetector.cpp diff -u llvm/lib/Support/LeakDetector.cpp:1.1 llvm/lib/Support/LeakDetector.cpp:1.2 --- llvm/lib/Support/LeakDetector.cpp:1.1 Sun Sep 8 13:51:16 2002 +++ llvm/lib/Support/LeakDetector.cpp Tue Sep 10 10:43:30 2002 @@ -7,7 +7,6 @@ #include "Support/LeakDetector.h" #include "llvm/Value.h" #include -#include // Lazily allocate set so that release build doesn't have to do anything. static std::set *Objects = 0; From lattner at cs.uiuc.edu Tue Sep 10 10:46:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 10 10:46:01 2002 Subject: [llvm-commits] CVS: llvm/lib/VMCore/InstrTypes.cpp Instruction.cpp iBranch.cpp iCall.cpp iMemory.cpp iOperators.cpp iSwitch.cpp Message-ID: <200209101545.KAA16366@trinity.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: InstrTypes.cpp updated: 1.17 -> 1.18 Instruction.cpp updated: 1.18 -> 1.19 iBranch.cpp updated: 1.5 -> 1.6 iCall.cpp updated: 1.13 -> 1.14 iMemory.cpp updated: 1.25 -> 1.26 iOperators.cpp updated: 1.17 -> 1.18 iSwitch.cpp updated: 1.5 -> 1.6 --- Log message: Add capability to insert an instruction into a basic block immediately after it is created, as part of the ctor call. Eliminate the GenericBinaryInst class --- Diffs of the changes: Index: llvm/lib/VMCore/InstrTypes.cpp diff -u llvm/lib/VMCore/InstrTypes.cpp:1.17 llvm/lib/VMCore/InstrTypes.cpp:1.18 --- llvm/lib/VMCore/InstrTypes.cpp:1.17 Wed Jul 24 17:08:49 2002 +++ llvm/lib/VMCore/InstrTypes.cpp Tue Sep 10 10:45:53 2002 @@ -1,4 +1,4 @@ -//===-- InstrTypes.cpp - Implement Instruction subclasses --------*- C++ -*--=// +//===-- InstrTypes.cpp - Implement Instruction subclasses -------*- C++ -*-===// // // This file implements // @@ -15,25 +15,15 @@ // TerminatorInst Class //===----------------------------------------------------------------------===// -TerminatorInst::TerminatorInst(Instruction::TermOps iType) - : Instruction(Type::VoidTy, iType, "") { +TerminatorInst::TerminatorInst(Instruction::TermOps iType, Instruction *IB) + : Instruction(Type::VoidTy, iType, "", IB) { } -TerminatorInst::TerminatorInst(const Type *Ty, Instruction::TermOps iType, - const std::string &Name) - : Instruction(Ty, iType, Name) { -} - - //===----------------------------------------------------------------------===// // PHINode Class //===----------------------------------------------------------------------===// -PHINode::PHINode(const Type *Ty, const std::string &name) - : Instruction(Ty, Instruction::PHINode, name) { -} - -PHINode::PHINode(const PHINode &PN) +PHINode::PHINode(const PHINode &PN) : Instruction(PN.getType(), Instruction::PHINode) { Operands.reserve(PN.Operands.size()); for (unsigned i = 0; i < PN.Operands.size(); i+=2) { Index: llvm/lib/VMCore/Instruction.cpp diff -u llvm/lib/VMCore/Instruction.cpp:1.18 llvm/lib/VMCore/Instruction.cpp:1.19 --- llvm/lib/VMCore/Instruction.cpp:1.18 Sun Sep 8 13:59:35 2002 +++ llvm/lib/VMCore/Instruction.cpp Tue Sep 10 10:45:53 2002 @@ -9,13 +9,21 @@ #include "llvm/Type.h" #include "Support/LeakDetector.h" -Instruction::Instruction(const Type *ty, unsigned it, const std::string &Name) +Instruction::Instruction(const Type *ty, unsigned it, const std::string &Name, + Instruction *InsertBefore) : User(ty, Value::InstructionVal, Name) { Parent = 0; iType = it; // Make sure that we get added to a basicblock LeakDetector::addGarbageObject(this); + + // If requested, insert this instruction into a basic block... + if (InsertBefore) { + assert(InsertBefore->getParent() && + "Instruction to insert before is not in a basic block!"); + InsertBefore->getParent()->getInstList().insert(InsertBefore, this); + } } void Instruction::setParent(BasicBlock *P) { Index: llvm/lib/VMCore/iBranch.cpp diff -u llvm/lib/VMCore/iBranch.cpp:1.5 llvm/lib/VMCore/iBranch.cpp:1.6 --- llvm/lib/VMCore/iBranch.cpp:1.5 Tue Jun 25 11:13:05 2002 +++ llvm/lib/VMCore/iBranch.cpp Tue Sep 10 10:45:53 2002 @@ -9,8 +9,9 @@ #include "llvm/BasicBlock.h" #include "llvm/Type.h" -BranchInst::BranchInst(BasicBlock *True, BasicBlock *False, Value *Cond) - : TerminatorInst(Instruction::Br) { +BranchInst::BranchInst(BasicBlock *True, BasicBlock *False, Value *Cond, + Instruction *InsertBefore) + : TerminatorInst(Instruction::Br, InsertBefore) { assert(True != 0 && "True branch destination may not be null!!!"); Operands.reserve(False ? 3 : 1); Operands.push_back(Use(True, this)); Index: llvm/lib/VMCore/iCall.cpp diff -u llvm/lib/VMCore/iCall.cpp:1.13 llvm/lib/VMCore/iCall.cpp:1.14 --- llvm/lib/VMCore/iCall.cpp:1.13 Tue Apr 9 13:36:52 2002 +++ llvm/lib/VMCore/iCall.cpp Tue Sep 10 10:45:53 2002 @@ -14,10 +14,10 @@ //===----------------------------------------------------------------------===// CallInst::CallInst(Value *Func, const std::vector ¶ms, - const std::string &Name) + const std::string &Name, Instruction *InsertBefore) : Instruction(cast(cast(Func->getType()) ->getElementType())->getReturnType(), - Instruction::Call, Name) { + Instruction::Call, Name, InsertBefore) { Operands.reserve(1+params.size()); Operands.push_back(Use(Func, this)); @@ -46,10 +46,10 @@ InvokeInst::InvokeInst(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, const std::vector ¶ms, - const std::string &Name) + const std::string &Name, Instruction *InsertBefore) : TerminatorInst(cast(cast(Func->getType()) ->getElementType())->getReturnType(), - Instruction::Invoke, Name) { + Instruction::Invoke, Name, InsertBefore) { Operands.reserve(3+params.size()); Operands.push_back(Use(Func, this)); Operands.push_back(Use((Value*)IfNormal, this)); Index: llvm/lib/VMCore/iMemory.cpp diff -u llvm/lib/VMCore/iMemory.cpp:1.25 llvm/lib/VMCore/iMemory.cpp:1.26 --- llvm/lib/VMCore/iMemory.cpp:1.25 Thu Aug 22 18:37:09 2002 +++ llvm/lib/VMCore/iMemory.cpp Tue Sep 10 10:45:53 2002 @@ -8,14 +8,9 @@ #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" -static inline const Type *checkType(const Type *Ty) { - assert(Ty && "Invalid indices for type!"); - return Ty; -} - AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, - const std::string &Name) - : Instruction(Ty, iTy, Name) { + const std::string &Name, Instruction *InsertBef) + : Instruction(Ty, iTy, Name, InsertBef) { assert(isa(Ty) && "Can't allocate a non pointer type!"); // ArraySize defaults to 1. @@ -37,14 +32,25 @@ return getType()->getElementType(); } +//===----------------------------------------------------------------------===// +// FreeInst Implementation +//===----------------------------------------------------------------------===// + +FreeInst::FreeInst(Value *Ptr, Instruction *InsertBefore) + : Instruction(Type::VoidTy, Free, "", InsertBefore) { + assert(isa(Ptr->getType()) && "Can't free nonpointer!"); + Operands.reserve(1); + Operands.push_back(Use(Ptr, this)); +} + //===----------------------------------------------------------------------===// // LoadInst Implementation //===----------------------------------------------------------------------===// -LoadInst::LoadInst(Value *Ptr, const std::string &Name) +LoadInst::LoadInst(Value *Ptr, const std::string &Name, Instruction *InsertBef) : Instruction(cast(Ptr->getType())->getElementType(), - Load, Name) { + Load, Name, InsertBef) { Operands.reserve(1); Operands.push_back(Use(Ptr, this)); } @@ -54,8 +60,8 @@ // StoreInst Implementation //===----------------------------------------------------------------------===// -StoreInst::StoreInst(Value *Val, Value *Ptr) - : Instruction(Type::VoidTy, Store, "") { +StoreInst::StoreInst(Value *Val, Value *Ptr, Instruction *InsertBefore) + : Instruction(Type::VoidTy, Store, "", InsertBefore) { Operands.reserve(2); Operands.push_back(Use(Val, this)); @@ -67,11 +73,19 @@ // GetElementPtrInst Implementation //===----------------------------------------------------------------------===// +// checkType - Simple wrapper function to give a better assertion failure +// message on bad indexes for a gep instruction. +// +static inline const Type *checkType(const Type *Ty) { + assert(Ty && "Invalid indices for type!"); + return Ty; +} + GetElementPtrInst::GetElementPtrInst(Value *Ptr, const std::vector &Idx, - const std::string &Name) + const std::string &Name, Instruction *InBe) : Instruction(PointerType::get(checkType(getIndexedType(Ptr->getType(), Idx, true))), - GetElementPtr, Name) { + GetElementPtr, Name, InBe) { assert(getIndexedType(Ptr->getType(), Idx, true) && "gep operands invalid!"); Operands.reserve(1+Idx.size()); Operands.push_back(Use(Ptr, this)); @@ -107,15 +121,3 @@ } return CurIDX == Idx.size() ? Ptr : 0; } - - -//===----------------------------------------------------------------------===// -// FreeInst Implementation -//===----------------------------------------------------------------------===// - -FreeInst::FreeInst(Value *Ptr) : Instruction(Type::VoidTy, Free, "") { - assert(isa(Ptr->getType()) && "Can't free nonpointer!"); - Operands.reserve(1); - Operands.push_back(Use(Ptr, this)); -} - Index: llvm/lib/VMCore/iOperators.cpp diff -u llvm/lib/VMCore/iOperators.cpp:1.17 llvm/lib/VMCore/iOperators.cpp:1.18 --- llvm/lib/VMCore/iOperators.cpp:1.17 Sun Sep 1 14:46:40 2002 +++ llvm/lib/VMCore/iOperators.cpp Tue Sep 10 10:45:53 2002 @@ -7,33 +7,54 @@ #include "llvm/iOperators.h" #include "llvm/Type.h" #include "llvm/Constants.h" +#include "llvm/BasicBlock.h" //===----------------------------------------------------------------------===// // BinaryOperator Class //===----------------------------------------------------------------------===// +BinaryOperator::BinaryOperator(BinaryOps iType, Value *S1, Value *S2, + const Type *Ty, const std::string &Name, + Instruction *InsertBefore) + : Instruction(Ty, iType, Name, InsertBefore) { + Operands.reserve(2); + Operands.push_back(Use(S1, this)); + Operands.push_back(Use(S2, this)); + assert(Operands[0] && Operands[1] && + Operands[0]->getType() == Operands[1]->getType()); +} + + + + BinaryOperator *BinaryOperator::create(BinaryOps Op, Value *S1, Value *S2, - const std::string &Name) { + const std::string &Name, + Instruction *InsertBefore) { + assert(S1->getType() == S2->getType() && + "Cannot create binary operator with two operands of differing type!"); switch (Op) { // Binary comparison operators... case SetLT: case SetGT: case SetLE: case SetGE: case SetEQ: case SetNE: - return new SetCondInst(Op, S1, S2, Name); + return new SetCondInst(Op, S1, S2, Name, InsertBefore); default: - return new GenericBinaryInst(Op, S1, S2, Name); + return new BinaryOperator(Op, S1, S2, S1->getType(), Name, InsertBefore); } } -BinaryOperator *BinaryOperator::createNeg(Value *Op, const std::string &Name) { - return new GenericBinaryInst(Instruction::Sub, - Constant::getNullValue(Op->getType()), Op, Name); +BinaryOperator *BinaryOperator::createNeg(Value *Op, const std::string &Name, + Instruction *InsertBefore) { + return new BinaryOperator(Instruction::Sub, + Constant::getNullValue(Op->getType()), Op, + Op->getType(), Name, InsertBefore); } -BinaryOperator *BinaryOperator::createNot(Value *Op, const std::string &Name) { - return new GenericBinaryInst(Instruction::Xor, Op, - ConstantIntegral::getAllOnesValue(Op->getType()), - Name); +BinaryOperator *BinaryOperator::createNot(Value *Op, const std::string &Name, + Instruction *InsertBefore) { + return new BinaryOperator(Instruction::Xor, Op, + ConstantIntegral::getAllOnesValue(Op->getType()), + Op->getType(), Name, InsertBefore); } @@ -111,15 +132,12 @@ // SetCondInst Class //===----------------------------------------------------------------------===// -SetCondInst::SetCondInst(BinaryOps opType, Value *S1, Value *S2, - const std::string &Name) - : BinaryOperator(opType, S1, S2, Name) { - - OpType = opType; - setType(Type::BoolTy); // setcc instructions always return bool type. +SetCondInst::SetCondInst(BinaryOps Opcode, Value *S1, Value *S2, + const std::string &Name, Instruction *InsertBefore) + : BinaryOperator(Opcode, S1, S2, Type::BoolTy, Name, InsertBefore) { - // Make sure it's a valid type... - assert(getOpcodeName() != 0); + // Make sure it's a valid type... getInverseCondition will assert out if not. + assert(getInverseCondition(Opcode)); } // getInverseCondition - Return the inverse of the current condition opcode. Index: llvm/lib/VMCore/iSwitch.cpp diff -u llvm/lib/VMCore/iSwitch.cpp:1.5 llvm/lib/VMCore/iSwitch.cpp:1.6 --- llvm/lib/VMCore/iSwitch.cpp:1.5 Tue Jun 25 11:13:05 2002 +++ llvm/lib/VMCore/iSwitch.cpp Tue Sep 10 10:45:53 2002 @@ -7,11 +7,12 @@ #include "llvm/iTerminators.h" #include "llvm/BasicBlock.h" -SwitchInst::SwitchInst(Value *V, BasicBlock *DefDest) - : TerminatorInst(Instruction::Switch) { - assert(V && DefDest); +SwitchInst::SwitchInst(Value *V, BasicBlock *DefaultDest, + Instruction *InsertBefore) + : TerminatorInst(Instruction::Switch, InsertBefore) { + assert(V && DefaultDest); Operands.push_back(Use(V, this)); - Operands.push_back(Use(DefDest, this)); + Operands.push_back(Use(DefaultDest, this)); } SwitchInst::SwitchInst(const SwitchInst &SI) From lattner at cs.uiuc.edu Tue Sep 10 10:54:00 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 10 10:54:00 2002 Subject: [llvm-commits] CVS: llvm/lib/VMCore/AsmWriter.cpp Message-ID: <200209101553.KAA16497@trinity.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: AsmWriter.cpp updated: 1.75 -> 1.76 --- Log message: Add support for printing constpointerrefs more nicely --- Diffs of the changes: Index: llvm/lib/VMCore/AsmWriter.cpp diff -u llvm/lib/VMCore/AsmWriter.cpp:1.75 llvm/lib/VMCore/AsmWriter.cpp:1.76 --- llvm/lib/VMCore/AsmWriter.cpp:1.75 Fri Aug 16 16:17:11 2002 +++ llvm/lib/VMCore/AsmWriter.cpp Tue Sep 10 10:53:49 2002 @@ -872,6 +872,13 @@ void Constant::print(std::ostream &o) const { if (this == 0) { o << " constant value\n"; return; } + + // Handle CPR's special, because they have context information... + if (const ConstantPointerRef *CPR = dyn_cast(this)) { + CPR->getValue()->print(o); // Print as a global value, with context info. + return; + } + o << " " << getType()->getDescription() << " "; map TypeTable; From lattner at cs.uiuc.edu Tue Sep 10 12:05:00 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 10 12:05:00 2002 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp IndVarSimplify.cpp Reassociate.cpp Message-ID: <200209101704.MAA19854@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: DecomposeMultiDimRefs.cpp updated: 1.22 -> 1.23 IndVarSimplify.cpp updated: 1.29 -> 1.30 Reassociate.cpp updated: 1.9 -> 1.10 --- Log message: Simplify code (somtimes dramatically), by using the new "auto-insert" feature of instruction constructors. --- Diffs of the changes: Index: llvm/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp diff -u llvm/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp:1.22 llvm/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp:1.23 --- llvm/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp:1.22 Thu Aug 22 18:36:48 2002 +++ llvm/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp Tue Sep 10 12:04:01 2002 @@ -18,14 +18,13 @@ #include "llvm/Pass.h" #include "Support/StatisticReporter.h" -static Statistic<> NumAdded("lowerrefs\t\t- New instructions added"); - namespace { - struct DecomposePass : public BasicBlockPass { - virtual bool runOnBasicBlock(BasicBlock &BB); + Statistic<> NumAdded("lowerrefs\t\t- # of getelementptr instructions added"); - private: - static bool decomposeArrayRef(BasicBlock::iterator &BBI); + class DecomposePass : public BasicBlockPass { + static bool decomposeArrayRef(GetElementPtrInst &GEP); + public: + virtual bool runOnBasicBlock(BasicBlock &BB); }; RegisterOpt X("lowerrefs", "Decompose multi-dimensional " @@ -47,23 +46,15 @@ { bool Changed = false; for (BasicBlock::iterator II = BB.begin(); II != BB.end(); ) { - if (GetElementPtrInst *GEP = dyn_cast(&*II)) - if (GEP->getNumIndices() >= 2) { - Changed |= decomposeArrayRef(II); // always modifies II - continue; - } + Instruction *I = II; ++II; + if (GetElementPtrInst *GEP = dyn_cast(I)) + if (GEP->getNumIndices() >= 2) + Changed |= decomposeArrayRef(*GEP); // always modifies II } return Changed; } -// Check for a constant (uint) 0. -inline bool -IsZero(Value* idx) -{ - return (isa(idx) && cast(idx)->isNullValue()); -} - // For any GetElementPtrInst with 2 or more array and structure indices: // // opCode CompositeType* P, [uint|ubyte] idx1, ..., [uint|ubyte] idxN @@ -86,17 +77,11 @@ // Return value: true if the instruction was replaced; false otherwise. // bool -DecomposePass::decomposeArrayRef(BasicBlock::iterator &BBI) +DecomposePass::decomposeArrayRef(GetElementPtrInst &GEP) { - GetElementPtrInst &GEP = cast(*BBI); BasicBlock *BB = GEP.getParent(); Value *LastPtr = GEP.getPointerOperand(); - - // Remove the instruction from the stream - BB->getInstList().remove(BBI); - - // The vector of new instructions to be created - std::vector NewInsts; + Instruction *InsertPoint = GEP.getNext(); // Insert before the next insn // Process each index except the last one. User::const_op_iterator OI = GEP.idx_begin(), OE = GEP.idx_end(); @@ -105,16 +90,17 @@ // If this is the first index and is 0, skip it and move on! if (OI == GEP.idx_begin()) { - if (IsZero(*OI)) continue; - } else + if (*OI == ConstantInt::getNullValue((*OI)->getType())) + continue; + } else { // Not the first index: include initial [0] to deref the last ptr Indices.push_back(Constant::getNullValue(Type::UIntTy)); + } Indices.push_back(*OI); // New Instruction: nextPtr1 = GetElementPtr LastPtr, Indices - LastPtr = new GetElementPtrInst(LastPtr, Indices, "ptr1"); - NewInsts.push_back(cast(LastPtr)); + LastPtr = new GetElementPtrInst(LastPtr, Indices, "ptr1", InsertPoint); ++NumAdded; } @@ -127,20 +113,13 @@ Indices.push_back(Constant::getNullValue(Type::UIntTy)); Indices.push_back(*OI); - Instruction *NewI = new GetElementPtrInst(LastPtr, Indices, GEP.getName()); - NewInsts.push_back(NewI); + Value *NewVal = new GetElementPtrInst(LastPtr, Indices, GEP.getName(), + InsertPoint); // Replace all uses of the old instruction with the new - GEP.replaceAllUsesWith(NewI); - - // Now delete the old instruction... - delete &GEP; - - // Insert all of the new instructions... - BB->getInstList().insert(BBI, NewInsts.begin(), NewInsts.end()); + GEP.replaceAllUsesWith(NewVal); - // Advance the iterator to the instruction following the one just inserted... - BBI = NewInsts.back(); - ++BBI; + // Now remove and delete the old instruction... + BB->getInstList().erase(&GEP); return true; } Index: llvm/lib/Transforms/Scalar/IndVarSimplify.cpp diff -u llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1.29 llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1.30 --- llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1.29 Tue Sep 10 00:24:05 2002 +++ llvm/lib/Transforms/Scalar/IndVarSimplify.cpp Tue Sep 10 12:04:01 2002 @@ -25,11 +25,8 @@ // name... // static Instruction *InsertCast(Value *Val, const Type *Ty, - BasicBlock::iterator It) { - Instruction *Cast = new CastInst(Val, Ty); - if (Val->hasName()) Cast->setName(Val->getName()+"-casted"); - It->getParent()->getInstList().insert(It, Cast); - return Cast; + Instruction *InsertBefore) { + return new CastInst(Val, Ty, Val->getName()+"-casted", InsertBefore); } static bool TransformLoop(LoopInfo *Loops, Loop *Loop) { @@ -75,19 +72,14 @@ // Okay, we want to convert other induction variables to use a cannonical // indvar. If we don't have one, add one now... if (!Cannonical) { - // Create the PHI node for the new induction variable - PHINode *PN = new PHINode(Type::UIntTy, "cann-indvar"); - - // Insert the phi node at the end of the other phi nodes... - AfterPHIIt = ++Header->getInstList().insert(AfterPHIIt, PN); + // Create the PHI node for the new induction variable, and insert the phi + // node at the end of the other phi nodes... + PHINode *PN = new PHINode(Type::UIntTy, "cann-indvar", AfterPHIIt); // Create the increment instruction to add one to the counter... Instruction *Add = BinaryOperator::create(Instruction::Add, PN, ConstantUInt::get(Type::UIntTy,1), - "add1-indvar"); - - // Insert the add instruction after all of the PHI nodes... - Header->getInstList().insert(AfterPHIIt, Add); + "add1-indvar", AfterPHIIt); // Figure out which block is incoming and which is the backedge for the loop BasicBlock *Incoming, *BackEdgeBlock; @@ -147,9 +139,7 @@ IV->Step = InsertCast(IV->Step, IVTy, AfterPHIIt); Val = BinaryOperator::create(Instruction::Mul, Val, IV->Step, - IV->Phi->getName()+"-scale"); - // Insert the phi node at the end of the other phi nodes... - Header->getInstList().insert(AfterPHIIt, Val); + IV->Phi->getName()+"-scale", AfterPHIIt); } // If the start != 0 @@ -160,11 +150,9 @@ if (IV->Start->getType() != IVTy) IV->Start = InsertCast(IV->Start, IVTy, AfterPHIIt); + // Insert the instruction after the phi nodes... Val = BinaryOperator::create(Instruction::Add, Val, IV->Start, - IV->Phi->getName()+"-offset"); - - // Insert the phi node at the end of the other phi nodes... - Header->getInstList().insert(AfterPHIIt, Val); + IV->Phi->getName()+"-offset", AfterPHIIt); } // If the PHI node has a different type than val is, insert a cast now... Index: llvm/lib/Transforms/Scalar/Reassociate.cpp diff -u llvm/lib/Transforms/Scalar/Reassociate.cpp:1.9 llvm/lib/Transforms/Scalar/Reassociate.cpp:1.10 --- llvm/lib/Transforms/Scalar/Reassociate.cpp:1.9 Fri Jul 26 16:12:41 2002 +++ llvm/lib/Transforms/Scalar/Reassociate.cpp Tue Sep 10 12:04:02 2002 @@ -180,12 +180,9 @@ // adding it now, we are assured that the neg instructions we just // inserted dominate the instruction we are about to insert after them. // - BasicBlock::iterator NBI = cast(RHS); - - Instruction *Add = - BinaryOperator::create(Instruction::Add, LHS, RHS, I->getName()+".neg"); - BB->getInstList().insert(++NBI, Add); // Add to the basic block... - return Add; + return BinaryOperator::create(Instruction::Add, LHS, RHS, + I->getName()+".neg", + cast(RHS)->getNext()); } // Insert a 'neg' instruction that subtracts the value from zero to get the @@ -194,8 +191,8 @@ Instruction *Neg = BinaryOperator::create(Instruction::Sub, Constant::getNullValue(V->getType()), V, - V->getName()+".neg"); - BI = BB->getInstList().insert(BI, Neg); // Add to the basic block... + V->getName()+".neg", BI); + --BI; return Neg; } @@ -220,8 +217,9 @@ // Insert a new temporary instruction... (A+B)+C BinaryOperator *Tmp = BinaryOperator::create(I->getOpcode(), LHSI, RHSI->getOperand(0), - RHSI->getName()+".ra"); - BI = BB->getInstList().insert(BI, Tmp); // Add to the basic block... + RHSI->getName()+".ra", + BI); + BI = Tmp; I->setOperand(0, Tmp); I->setOperand(1, RHSI->getOperand(1)); From lattner at cs.uiuc.edu Tue Sep 10 12:05:05 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 10 12:05:05 2002 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Instrumentation/TraceValues.cpp Message-ID: <200209101704.MAA19846@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Instrumentation: TraceValues.cpp updated: 1.46 -> 1.47 --- Log message: Simplify code (somtimes dramatically), by using the new "auto-insert" feature of instruction constructors. --- Diffs of the changes: Index: llvm/lib/Transforms/Instrumentation/TraceValues.cpp diff -u llvm/lib/Transforms/Instrumentation/TraceValues.cpp:1.46 llvm/lib/Transforms/Instrumentation/TraceValues.cpp:1.47 --- llvm/lib/Transforms/Instrumentation/TraceValues.cpp:1.46 Mon Sep 2 20:07:35 2002 +++ llvm/lib/Transforms/Instrumentation/TraceValues.cpp Tue Sep 10 12:03:03 2002 @@ -208,7 +208,7 @@ } -static void InsertPrintInst(Value *V,BasicBlock *BB, BasicBlock::iterator &BBI, +static void InsertPrintInst(Value *V, BasicBlock *BB, Instruction *InsertBefore, string Message, Function *Printf, Function* HashPtrToSeqNum) { // Escape Message by replacing all % characters with %% chars. @@ -227,88 +227,59 @@ Instruction *GEP = new GetElementPtrInst(fmtVal, vector(2,ConstantUInt::get(Type::UIntTy, 0)), - "trstr"); - BBI = ++BB->getInstList().insert(BBI, GEP); + "trstr", InsertBefore); // Insert a call to the hash function if this is a pointer value if (V && isa(V->getType()) && !DisablePtrHashing) { const Type *SBP = PointerType::get(Type::SByteTy); - if (V->getType() != SBP) { // Cast pointer to be sbyte* - Instruction *I = new CastInst(V, SBP, "Hash_cast"); - BBI = ++BB->getInstList().insert(BBI, I); - V = I; - } + if (V->getType() != SBP) // Cast pointer to be sbyte* + V = new CastInst(V, SBP, "Hash_cast", InsertBefore); vector HashArgs(1, V); - V = new CallInst(HashPtrToSeqNum, HashArgs, "ptrSeqNum"); - BBI = ++BB->getInstList().insert(BBI, cast(V)); + V = new CallInst(HashPtrToSeqNum, HashArgs, "ptrSeqNum", InsertBefore); } // Insert the first print instruction to print the string flag: vector PrintArgs; PrintArgs.push_back(GEP); if (V) PrintArgs.push_back(V); - Instruction *I = new CallInst(Printf, PrintArgs, "trace"); - BBI = ++BB->getInstList().insert(BBI, I); + new CallInst(Printf, PrintArgs, "trace", InsertBefore); } static void InsertVerbosePrintInst(Value *V, BasicBlock *BB, - BasicBlock::iterator &BBI, + Instruction *InsertBefore, const string &Message, Function *Printf, Function* HashPtrToSeqNum) { std::ostringstream OutStr; if (V) WriteAsOperand(OutStr, V); - InsertPrintInst(V, BB, BBI, Message+OutStr.str()+" = ", + InsertPrintInst(V, BB, InsertBefore, Message+OutStr.str()+" = ", Printf, HashPtrToSeqNum); } static void InsertReleaseInst(Value *V, BasicBlock *BB, - BasicBlock::iterator &BBI, + Instruction *InsertBefore, Function* ReleasePtrFunc) { const Type *SBP = PointerType::get(Type::SByteTy); - if (V->getType() != SBP) { // Cast pointer to be sbyte* - Instruction *I = new CastInst(V, SBP, "RPSN_cast"); - BBI = ++BB->getInstList().insert(BBI, I); - V = I; - } + if (V->getType() != SBP) // Cast pointer to be sbyte* + V = new CastInst(V, SBP, "RPSN_cast", InsertBefore); + vector releaseArgs(1, V); - Instruction *I = new CallInst(ReleasePtrFunc, releaseArgs); - BBI = ++BB->getInstList().insert(BBI, I); + new CallInst(ReleasePtrFunc, releaseArgs, "", InsertBefore); } static void InsertRecordInst(Value *V, BasicBlock *BB, - BasicBlock::iterator &BBI, + Instruction *InsertBefore, Function* RecordPtrFunc) { const Type *SBP = PointerType::get(Type::SByteTy); - if (V->getType() != SBP) { // Cast pointer to be sbyte* - Instruction *I = new CastInst(V, SBP, "RP_cast"); - BBI = ++BB->getInstList().insert(BBI, I); - V = I; - } - vector releaseArgs(1, V); - Instruction *I = new CallInst(RecordPtrFunc, releaseArgs); - BBI = ++BB->getInstList().insert(BBI, I); -} - -static void -InsertPushOnEntryFunc(Function *M, - Function* PushOnEntryFunc) { - // Get an iterator to point to the insertion location - BasicBlock &BB = M->getEntryNode(); - BB.getInstList().insert(BB.begin(), new CallInst(PushOnEntryFunc, - vector())); -} + if (V->getType() != SBP) // Cast pointer to be sbyte* + V = new CastInst(V, SBP, "RP_cast", InsertBefore); -static void -InsertReleaseRecordedInst(BasicBlock *BB, - Function* ReleaseOnReturnFunc) { - BasicBlock::iterator BBI = --BB->end(); - BBI = ++BB->getInstList().insert(BBI, new CallInst(ReleaseOnReturnFunc, - vector())); + vector releaseArgs(1, V); + new CallInst(RecordPtrFunc, releaseArgs, "", InsertBefore); } // Look for alloca and free instructions. These are the ptrs to release. @@ -319,16 +290,11 @@ ReleasePtrSeqNumbers(BasicBlock *BB, ExternalFuncs& externalFuncs) { - for (BasicBlock::iterator II=BB->begin(); II != BB->end(); ++II) { + for (BasicBlock::iterator II=BB->begin(), IE = BB->end(); II != IE; ++II) if (FreeInst *FI = dyn_cast(&*II)) - InsertReleaseInst(FI->getOperand(0), BB,II,externalFuncs.ReleasePtrFunc); + InsertReleaseInst(FI->getOperand(0), BB, FI,externalFuncs.ReleasePtrFunc); else if (AllocaInst *AI = dyn_cast(&*II)) - { - BasicBlock::iterator nextI = ++II; - InsertRecordInst(AI, BB, nextI, externalFuncs.RecordPtrFunc); - II = --nextI; - } - } + InsertRecordInst(AI, BB, AI->getNext(), externalFuncs.RecordPtrFunc); } @@ -347,8 +313,7 @@ // Get an iterator to point to the insertion location, which is // just before the terminator instruction. // - BasicBlock::iterator InsertPos = --BB->end(); - assert(InsertPos->isTerminator()); + TerminatorInst *InsertPos = BB->getTerminator(); std::ostringstream OutStr; WriteAsOperand(OutStr, BB, false); @@ -359,21 +324,17 @@ // The print instructions must go before InsertPos, so we use the // instruction *preceding* InsertPos to check when to terminate the loop. // - if (InsertPos != BB->begin()) { // there's at least one instr before InsertPos - BasicBlock::iterator II = BB->begin(), IEincl = InsertPos; - --IEincl; - do { // do from II up to IEincl, inclusive - if (StoreInst *SI = dyn_cast(&*II)) { - assert(valuesStoredInFunction && - "Should not be printing a store instruction at function exit"); - LoadInst *LI = new LoadInst(SI->getPointerOperand(), "reload." + - SI->getPointerOperand()->getName()); - InsertPos = ++BB->getInstList().insert(InsertPos, LI); - valuesStoredInFunction->push_back(LI); - } - if (ShouldTraceValue(II)) - InsertVerbosePrintInst(II, BB, InsertPos, " ", Printf,HashPtrToSeqNum); - } while (II++ != IEincl); + for (BasicBlock::iterator II = BB->begin(); &*II != InsertPos; ++II) { + if (StoreInst *SI = dyn_cast(&*II)) { + assert(valuesStoredInFunction && + "Should not be printing a store instruction at function exit"); + LoadInst *LI = new LoadInst(SI->getPointerOperand(), "reload." + + SI->getPointerOperand()->getName(), + InsertPos); + valuesStoredInFunction->push_back(LI); + } + if (ShouldTraceValue(II)) + InsertVerbosePrintInst(II, BB, InsertPos, " ", Printf, HashPtrToSeqNum); } } @@ -381,17 +342,17 @@ Function* HashPtrToSeqNum){ // Get an iterator to point to the insertion location BasicBlock &BB = F.getEntryNode(); - BasicBlock::iterator BBI = BB.begin(); + Instruction *InsertPos = BB.begin(); std::ostringstream OutStr; WriteAsOperand(OutStr, &F, true); - InsertPrintInst(0, &BB, BBI, "ENTERING FUNCTION: " + OutStr.str(), + InsertPrintInst(0, &BB, InsertPos, "ENTERING FUNCTION: " + OutStr.str(), Printf, HashPtrToSeqNum); // Now print all the incoming arguments unsigned ArgNo = 0; for (Function::aiterator I = F.abegin(), E = F.aend(); I != E; ++I, ++ArgNo){ - InsertVerbosePrintInst(I, &BB, BBI, + InsertVerbosePrintInst(I, &BB, InsertPos, " Arg #" + utostr(ArgNo) + ": ", Printf, HashPtrToSeqNum); } @@ -402,17 +363,16 @@ Function *Printf, Function* HashPtrToSeqNum) { // Get an iterator to point to the insertion location - BasicBlock::iterator BBI = --BB->end(); - ReturnInst &Ret = cast(BB->back()); + ReturnInst *Ret = cast(BB->getTerminator()); std::ostringstream OutStr; WriteAsOperand(OutStr, BB->getParent(), true); - InsertPrintInst(0, BB, BBI, "LEAVING FUNCTION: " + OutStr.str(), + InsertPrintInst(0, BB, Ret, "LEAVING FUNCTION: " + OutStr.str(), Printf, HashPtrToSeqNum); // print the return value, if any if (BB->getParent()->getReturnType() != Type::VoidTy) - InsertPrintInst(Ret.getReturnValue(), BB, BBI, " Returning: ", + InsertPrintInst(Ret->getReturnValue(), BB, Ret, " Returning: ", Printf, HashPtrToSeqNum); } @@ -430,8 +390,9 @@ // Push a pointer set for recording alloca'd pointers at entry. if (!DisablePtrHashing) - InsertPushOnEntryFunc(&F, externalFuncs.PushOnEntryFunc); - + new CallInst(externalFuncs.PushOnEntryFunc, vector(), "", + F.getEntryNode().begin()); + for (Function::iterator BB = F.begin(); BB != F.end(); ++BB) { if (isa(BB->getTerminator())) exitBlocks.push_back(BB); // record this as an exit block @@ -451,8 +412,8 @@ // Release all recorded pointers before RETURN. Do this LAST! if (!DisablePtrHashing) - InsertReleaseRecordedInst(exitBlocks[i], - externalFuncs.ReleaseOnReturnFunc); + new CallInst(externalFuncs.ReleaseOnReturnFunc, vector(), "", + exitBlocks[i]->getTerminator()); } return true; From lattner at cs.uiuc.edu Tue Sep 10 12:05:10 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 10 12:05:10 2002 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Instrumentation/ProfilePaths/EdgeCode.cpp Message-ID: <200209101704.MAA19860@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Instrumentation/ProfilePaths: EdgeCode.cpp updated: 1.12 -> 1.13 --- Log message: Simplify code (somtimes dramatically), by using the new "auto-insert" feature of instruction constructors. --- Diffs of the changes: Index: llvm/lib/Transforms/Instrumentation/ProfilePaths/EdgeCode.cpp diff -u llvm/lib/Transforms/Instrumentation/ProfilePaths/EdgeCode.cpp:1.12 llvm/lib/Transforms/Instrumentation/ProfilePaths/EdgeCode.cpp:1.13 --- llvm/lib/Transforms/Instrumentation/ProfilePaths/EdgeCode.cpp:1.12 Wed Aug 21 17:11:33 2002 +++ llvm/lib/Transforms/Instrumentation/ProfilePaths/EdgeCode.cpp Tue Sep 10 12:03:06 2002 @@ -1,4 +1,4 @@ -//===-- EdgeCode.cpp - generate LLVM instrumentation code --------*- C++ -*--=// +//===-- EdgeCode.cpp - generate LLVM instrumentation code -----------------===// //It implements the class EdgeCode: which provides //support for inserting "appropriate" instrumentation at //designated points in the graph @@ -8,7 +8,6 @@ //===----------------------------------------------------------------------===// #include "llvm/Transforms/Instrumentation/Graph.h" -#include "llvm/BasicBlock.h" #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" #include "llvm/iMemory.h" @@ -17,14 +16,8 @@ #include "llvm/iOperators.h" #include "llvm/iPHINode.h" #include "llvm/Module.h" -#include "llvm/SymbolTable.h" -#include "llvm/GlobalVariable.h" -#include "llvm/Constants.h" -#include "llvm/BasicBlock.h" -#include "llvm/Function.h" #include #include -#include #define INSERT_LOAD_COUNT #define INSERT_STORE @@ -32,21 +25,19 @@ using std::vector; -void getTriggerCode(Module *M, BasicBlock *BB, int MethNo, Value *pathNo, - Value *cnt){ +static void getTriggerCode(Module *M, BasicBlock *BB, int MethNo, Value *pathNo, + Value *cnt, Instruction *InsertPos){ static int i=-1; i++; char gstr[100]; sprintf(gstr,"globalVar%d",i); std::string globalVarName=gstr; - SymbolTable *ST = M->getSymbolTable(); vector args; //args.push_back(PointerType::get(Type::SByteTy)); args.push_back(Type::IntTy); args.push_back(Type::IntTy); args.push_back(Type::IntTy); - const FunctionType *MTy = - FunctionType::get(Type::VoidTy, args, false); + const FunctionType *MTy = FunctionType::get(Type::VoidTy, args, false); // Function *triggerMeth = M->getOrInsertFunction("trigger", MTy); Function *trigMeth = M->getOrInsertFunction("trigger", MTy); @@ -81,12 +72,7 @@ //trargs.push_back(ConstantSInt::get(Type::IntTy,-1));//erase this trargs.push_back(pathNo); trargs.push_back(cnt); - Instruction *callInst=new CallInst(trigMeth,trargs); - - BasicBlock::InstListType& instList=BB->getInstList(); - BasicBlock::iterator here=instList.begin(); - //here = ++instList.insert(here, getElmntInst); - instList.insert(here,callInst); + Instruction *callInst=new CallInst(trigMeth, trargs, "", InsertPos); } @@ -97,160 +83,126 @@ Function *M, BasicBlock *BB, int numPaths, int MethNo){ - BasicBlock::InstListType& instList=BB->getInstList(); - BasicBlock::iterator here=instList.begin(); + Instruction *InsertPos = BB->begin(); //case: r=k code to be inserted switch(cond){ case 1:{ Value *val=ConstantSInt::get(Type::IntTy,inc); #ifdef INSERT_STORE - Instruction *stInst=new StoreInst(val, rInst); - here = ++instList.insert(here,stInst); + Instruction *stInst=new StoreInst(val, rInst, InsertPos); #endif break; } //case: r=0 to be inserted - case 2:{ - Value *val=ConstantSInt::get(Type::IntTy,0); + case 2: #ifdef INSERT_STORE - Instruction *stInst=new StoreInst(val, rInst); - here = ++instList.insert(here,stInst); + new StoreInst(ConstantSInt::getNullValue(Type::IntTy), rInst, InsertPos); #endif break; - } //r+=k case 3:{ - - Instruction *ldInst=new LoadInst(rInst, "ti1"); - Value *val=ConstantSInt::get(Type::IntTy,inc); - Instruction *addIn=BinaryOperator:: - create(Instruction::Add, ldInst, val,"ti2"); + Instruction *ldInst = new LoadInst(rInst, "ti1", InsertPos); + Value *val = ConstantSInt::get(Type::IntTy,inc); + Value *addIn = BinaryOperator::create(Instruction::Add, ldInst, val, + "ti2", InsertPos); #ifdef INSERT_STORE - Instruction *stInst=new StoreInst(addIn, rInst); -#endif - here = ++instList.insert(here,ldInst); - here = ++instList.insert(here,addIn); -#ifdef INSERT_STORE - here = ++instList.insert(here,stInst); + new StoreInst(addIn, rInst, InsertPos); #endif break; } //count[inc]++ case 4:{ - assert(inc>=0 && inc<=numPaths && "inc out of bound!"); Instruction *Idx = new GetElementPtrInst(countInst, - vector(1,ConstantUInt::get(Type::UIntTy, inc))); + vector(1,ConstantUInt::get(Type::UIntTy, inc)), + "", InsertPos); - Instruction *ldInst=new LoadInst(Idx, "ti1"); + Instruction *ldInst=new LoadInst(Idx, "ti1", InsertPos); Value *val = ConstantSInt::get(Type::IntTy, 1); Instruction *addIn = - BinaryOperator::create(Instruction::Add, ldInst, val,"ti2"); + BinaryOperator::create(Instruction::Add, ldInst, val,"ti2", InsertPos); + +#ifdef INSERT_STORE + Instruction *stInst=new StoreInst(addIn, Idx, InsertPos); +#endif //insert trigger getTriggerCode(M->getParent(), BB, MethNo, - ConstantSInt::get(Type::IntTy,inc), addIn); - here=instList.begin(); + ConstantSInt::get(Type::IntTy,inc), addIn, InsertPos); //end trigger code assert(inc>=0 && "IT MUST BE POSITIVE NOW"); -#ifdef INSERT_STORE - Instruction *stInst=new StoreInst(addIn, Idx); -#endif - here = ++instList.insert(here,Idx); - here = ++instList.insert(here,ldInst); - here = ++instList.insert(here,addIn); -#ifdef INSERT_STORE - here = ++instList.insert(here,stInst); -#endif break; } //case: count[r+inc]++ case 5:{ - + //ti1=inc+r - Instruction *ldIndex=new LoadInst(rInst, "ti1"); + Instruction *ldIndex=new LoadInst(rInst, "ti1", InsertPos); Value *val=ConstantSInt::get(Type::IntTy,inc); Instruction *addIndex=BinaryOperator:: - create(Instruction::Add, ldIndex, val,"ti2"); + create(Instruction::Add, ldIndex, val,"ti2", InsertPos); //erase following 1 line //Value *valtemp=ConstantSInt::get(Type::IntTy,999); //now load count[addIndex] Instruction *castInst=new CastInst(addIndex, - Type::UIntTy,"ctin"); + Type::UIntTy,"ctin", InsertPos); Instruction *Idx = new GetElementPtrInst(countInst, - vector(1,castInst)); + vector(1,castInst), "", + InsertPos); - Instruction *ldInst=new LoadInst(Idx, "ti3"); + Instruction *ldInst=new LoadInst(Idx, "ti3", InsertPos); Value *cons=ConstantSInt::get(Type::IntTy,1); //count[addIndex]++ - Instruction *addIn=BinaryOperator:: - create(Instruction::Add, ldInst, cons,"ti4"); - - //insert trigger - getTriggerCode(M->getParent(), BB, MethNo, addIndex, addIn); - here=instList.begin(); - //end trigger code + Value *addIn = BinaryOperator::create(Instruction::Add, ldInst, cons, + "ti4", InsertPos); #ifdef INSERT_STORE ///* - Instruction *stInst=new StoreInst(addIn, Idx); - + new StoreInst(addIn, Idx, InsertPos); //*/ #endif - here = ++instList.insert(here,ldIndex); - here = ++instList.insert(here,addIndex); - here = ++instList.insert(here,castInst); - here = ++instList.insert(here,Idx); - here = ++instList.insert(here,ldInst); - here = ++instList.insert(here,addIn); -#ifdef INSERT_STORE - here = ++instList.insert(here,stInst); -#endif + + //insert trigger + getTriggerCode(M->getParent(), BB, MethNo, addIndex, addIn, InsertPos); + //end trigger code + break; } //case: count[r]+ case 6:{ - //ti1=inc+r - Instruction *ldIndex=new LoadInst(rInst, "ti1"); + Instruction *ldIndex=new LoadInst(rInst, "ti1", InsertPos); //now load count[addIndex] - Instruction *castInst2=new CastInst(ldIndex, Type::UIntTy,"ctin"); + Instruction *castInst2=new CastInst(ldIndex, Type::UIntTy,"ctin",InsertPos); Instruction *Idx = new GetElementPtrInst(countInst, - vector(1,castInst2)); + vector(1,castInst2), "", + InsertPos); - Instruction *ldInst=new LoadInst(Idx, "ti2"); + Instruction *ldInst=new LoadInst(Idx, "ti2", InsertPos); Value *cons=ConstantSInt::get(Type::IntTy,1); //count[addIndex]++ Instruction *addIn=BinaryOperator::create(Instruction::Add, ldInst, - cons,"ti3"); + cons,"ti3", InsertPos); - //insert trigger - getTriggerCode(M->getParent(), BB, MethNo, ldIndex, addIn); - here=instList.begin(); - //end trigger code #ifdef INSERT_STORE - Instruction *stInst=new StoreInst(addIn, Idx); -#endif - here = ++instList.insert(here,ldIndex); - here = ++instList.insert(here,castInst2); - here = ++instList.insert(here,Idx); - here = instList.insert(here,ldInst); - here = instList.insert(here,addIn); -#ifdef INSERT_STORE - here = instList.insert(here,stInst); + new StoreInst(addIn, Idx, InsertPos); #endif + //insert trigger + getTriggerCode(M->getParent(), BB, MethNo, ldIndex, addIn, InsertPos); + //end trigger code + break; } @@ -288,28 +240,22 @@ vector idx; idx.push_back(ConstantUInt::get(Type::UIntTy, 0)); - Instruction *GEP = new GetElementPtrInst(rVar, idx); - Instruction *stInstr=new StoreInst(Int0, GEP); - //now push all instructions in front of the BB - BasicBlock::InstListType& instList=front->getInstList(); - BasicBlock::iterator here=instList.begin(); - here=++front->getInstList().insert(here, rVar); - here=++front->getInstList().insert(here,countVar); + BasicBlock::iterator here=front->begin(); + front->getInstList().insert(here, rVar); + front->getInstList().insert(here,countVar); //Initialize Count[...] with 0 - for(int i=0;i(1,ConstantUInt::get(Type::UIntTy, i))); - here=++front->getInstList().insert(here,GEP2); - - Instruction *stInstrC=new StoreInst(Int0, GEP2); - here=++front->getInstList().insert(here,stInstrC); + for (int i=0;i(1,ConstantUInt::get(Type::UIntTy, i)), + "", here); + new StoreInst(Int0, GEP2, here); } - here = ++front->getInstList().insert(here,GEP); - here = ++front->getInstList().insert(here,stInstr); + Instruction *GEP = new GetElementPtrInst(rVar, idx, "", here); + new StoreInst(Int0, GEP, here); } From lattner at cs.uiuc.edu Tue Sep 10 12:05:14 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 10 12:05:14 2002 Subject: [llvm-commits] CVS: llvm/lib/Transforms/ExprTypeConvert.cpp LevelRaise.cpp TransformInternals.cpp Message-ID: <200209101704.MAA19892@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Transforms: ExprTypeConvert.cpp updated: 1.52 -> 1.53 LevelRaise.cpp updated: 1.68 -> 1.69 TransformInternals.cpp updated: 1.27 -> 1.28 --- Log message: Simplify code (somtimes dramatically), by using the new "auto-insert" feature of instruction constructors. --- Diffs of the changes: Index: llvm/lib/Transforms/ExprTypeConvert.cpp diff -u llvm/lib/Transforms/ExprTypeConvert.cpp:1.52 llvm/lib/Transforms/ExprTypeConvert.cpp:1.53 --- llvm/lib/Transforms/ExprTypeConvert.cpp:1.52 Mon Sep 9 15:25:21 2002 +++ llvm/lib/Transforms/ExprTypeConvert.cpp Tue Sep 10 12:02:54 2002 @@ -101,21 +101,14 @@ // If we have a scale, apply it first... if (Expr.Var) { // Expr.Var is not neccesarily unsigned right now, insert a cast now. - if (Expr.Var->getType() != Type::UIntTy) { - Instruction *CI = new CastInst(Expr.Var, Type::UIntTy); - if (Expr.Var->hasName()) CI->setName(Expr.Var->getName()+"-uint"); - It = ++BB->getInstList().insert(It, CI); - Expr.Var = CI; - } - - if (Scale != 1) { - Instruction *ScI = - BinaryOperator::create(Instruction::Mul, Expr.Var, - ConstantUInt::get(Type::UIntTy, Scale)); - if (Expr.Var->hasName()) ScI->setName(Expr.Var->getName()+"-scl"); - It = ++BB->getInstList().insert(It, ScI); - Expr.Var = ScI; - } + if (Expr.Var->getType() != Type::UIntTy) + Expr.Var = new CastInst(Expr.Var, Type::UIntTy, + Expr.Var->getName()+"-uint", It); + + if (Scale != 1) + Expr.Var = BinaryOperator::create(Instruction::Mul, Expr.Var, + ConstantUInt::get(Type::UIntTy, Scale), + Expr.Var->getName()+"-scl", It); } else { // If we are not scaling anything, just make the offset be the "var"... @@ -126,13 +119,9 @@ // If we have an offset now, add it in... if (Offset != 0) { assert(Expr.Var && "Var must be nonnull by now!"); - - Instruction *AddI = - BinaryOperator::create(Instruction::Add, Expr.Var, - ConstantUInt::get(Type::UIntTy, Offset)); - if (Expr.Var->hasName()) AddI->setName(Expr.Var->getName()+"-off"); - It = ++BB->getInstList().insert(It, AddI); - Expr.Var = AddI; + Expr.Var = BinaryOperator::create(Instruction::Add, Expr.Var, + ConstantUInt::get(Type::UIntTy, Offset), + Expr.Var->getName()+"-off", It); } Instruction *NewI = new MallocInst(AllocTy, Expr.Var, Name); @@ -971,9 +960,8 @@ assert(LoadedTy->isFirstClassType()); if (Indices.size() != 1) { // Do not generate load X, 0 - Src = new GetElementPtrInst(Src, Indices, Name+".idx"); // Insert the GEP instruction before this load. - BIL.insert(I, cast(Src)); + Src = new GetElementPtrInst(Src, Indices, Name+".idx", I); } } @@ -1008,10 +996,9 @@ assert(Offset == 0 && "Offset changed!"); assert(NewTy == Ty && "Did not convert to correct type!"); + // Insert the GEP instruction before this store. SrcPtr = new GetElementPtrInst(SrcPtr, Indices, - SrcPtr->getName()+".idx"); - // Insert the GEP instruction before this load. - BIL.insert(I, cast(SrcPtr)); + SrcPtr->getName()+".idx", I); } Res = new StoreInst(NewVal, SrcPtr); @@ -1038,10 +1025,9 @@ assert(Offset == 0 && ValTy); + // Insert the GEP instruction before this store. SrcPtr = new GetElementPtrInst(SrcPtr, Indices, - SrcPtr->getName()+".idx"); - // Insert the GEP instruction before this load. - BIL.insert(I, cast(SrcPtr)); + SrcPtr->getName()+".idx", I); } Res = new StoreInst(Constant::getNullValue(ValTy), SrcPtr); @@ -1064,8 +1050,8 @@ if (DataSize != 1) { // Insert a multiply of the old element type is not a unit size... Index = BinaryOperator::create(Instruction::Mul, Index, - ConstantUInt::get(Type::UIntTy, DataSize)); - It = ++BIL.insert(It, cast(Index)); + ConstantUInt::get(Type::UIntTy, DataSize), + "scale", It); } // Perform the conversion now... @@ -1146,8 +1132,7 @@ // Create a cast to convert it to the right type, we know that this // is a lossless cast... // - Params[i] = new CastInst(Params[i], PTs[i], "call.resolve.cast"); - It = ++BIL.insert(It, cast(Params[i])); + Params[i] = new CastInst(Params[i], PTs[i], "call.resolve.cast", It); } Meth = NewVal; // Update call destination to new value Index: llvm/lib/Transforms/LevelRaise.cpp diff -u llvm/lib/Transforms/LevelRaise.cpp:1.68 llvm/lib/Transforms/LevelRaise.cpp:1.69 --- llvm/lib/Transforms/LevelRaise.cpp:1.68 Mon Sep 2 20:07:29 2002 +++ llvm/lib/Transforms/LevelRaise.cpp Tue Sep 10 12:02:54 2002 @@ -179,8 +179,7 @@ } GetElementPtrInst *GEP = new GetElementPtrInst(SrcPtr, Indices, - AddOp2->getName()); - BI = ++BB->getInstList().insert(BI, GEP); + AddOp2->getName(), BI); Instruction *NCI = new CastInst(GEP, AddOp1->getType()); ReplaceInstWithInst(BB->getInstList(), BI, NCI); @@ -354,11 +353,11 @@ if (ElTy) { PRINT_PEEPHOLE1("cast-for-first:in", CI); + std::string Name = CI->getName(); CI->setName(""); + // Insert the new T cast instruction... stealing old T's name GetElementPtrInst *GEP = new GetElementPtrInst(Src, Indices, - CI->getName()); - CI->setName(""); - BI = ++BB->getInstList().insert(BI, GEP); + Name, BI); // Make the old cast instruction reference the new GEP instead of // the old src value. @@ -397,10 +396,9 @@ PRINT_PEEPHOLE3("st-src-cast:in ", Pointer, Val, SI); // Insert the new T cast instruction... stealing old T's name + std::string Name(CI->getName()); CI->setName(""); CastInst *NCI = new CastInst(Val, CSPT->getElementType(), - CI->getName()); - CI->setName(""); - BI = ++BB->getInstList().insert(BI, NCI); + Name, BI); // Replace the old store with a new one! ReplaceInstWithInst(BB->getInstList(), BI, @@ -436,11 +434,10 @@ PRINT_PEEPHOLE2("load-src-cast:in ", Pointer, LI); // Create the new load instruction... loading the pre-casted value - LoadInst *NewLI = new LoadInst(CastSrc, LI->getName()); + LoadInst *NewLI = new LoadInst(CastSrc, LI->getName(), BI); // Insert the new T cast instruction... stealing old T's name CastInst *NCI = new CastInst(NewLI, LI->getType(), CI->getName()); - BI = ++BB->getInstList().insert(BI, NewLI); // Replace the old store with a new one! ReplaceInstWithInst(BB->getInstList(), BI, NCI); Index: llvm/lib/Transforms/TransformInternals.cpp diff -u llvm/lib/Transforms/TransformInternals.cpp:1.27 llvm/lib/Transforms/TransformInternals.cpp:1.28 --- llvm/lib/Transforms/TransformInternals.cpp:1.27 Fri Aug 30 17:53:08 2002 +++ llvm/lib/Transforms/TransformInternals.cpp Tue Sep 10 12:02:55 2002 @@ -141,35 +141,25 @@ if (BI) { // Generate code? BasicBlock *BB = (*BI)->getParent(); - if (Expr.Var->getType() != Type::UIntTy) { - CastInst *IdxCast = new CastInst(Expr.Var, Type::UIntTy); - if (Expr.Var->hasName()) - IdxCast->setName(Expr.Var->getName()+"-idxcast"); - *BI = ++BB->getInstList().insert(*BI, IdxCast); - Expr.Var = IdxCast; - } + if (Expr.Var->getType() != Type::UIntTy) + Expr.Var = new CastInst(Expr.Var, Type::UIntTy, + Expr.Var->getName()+"-idxcast", *BI); if (ScaleAmt && ScaleAmt != 1) { // If we have to scale up our index, do so now Value *ScaleAmtVal = ConstantUInt::get(Type::UIntTy, (unsigned)ScaleAmt); - Instruction *Scaler = BinaryOperator::create(Instruction::Mul, - Expr.Var, ScaleAmtVal); - if (Expr.Var->hasName()) - Scaler->setName(Expr.Var->getName()+"-scale"); - - *BI = ++BB->getInstList().insert(*BI, Scaler); - Expr.Var = Scaler; + Expr.Var = BinaryOperator::create(Instruction::Mul, Expr.Var, + ScaleAmtVal, + Expr.Var->getName()+"-scale",*BI); } if (Index) { // Add an offset to the index Value *IndexAmt = ConstantUInt::get(Type::UIntTy, (unsigned)Index); - Instruction *Offseter = BinaryOperator::create(Instruction::Add, - Expr.Var, IndexAmt); - if (Expr.Var->hasName()) - Offseter->setName(Expr.Var->getName()+"-offset"); - *BI = ++BB->getInstList().insert(*BI, Offseter); - Expr.Var = Offseter; + Expr.Var = BinaryOperator::create(Instruction::Add, Expr.Var, + IndexAmt, + Expr.Var->getName()+"-offset", + *BI); } } From lattner at cs.uiuc.edu Tue Sep 10 12:05:18 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 10 12:05:18 2002 Subject: [llvm-commits] CVS: llvm/lib/Transforms/IPO/FunctionResolution.cpp Message-ID: <200209101704.MAA19898@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/IPO: FunctionResolution.cpp updated: 1.10 -> 1.11 --- Log message: Simplify code (somtimes dramatically), by using the new "auto-insert" feature of instruction constructors. --- Diffs of the changes: Index: llvm/lib/Transforms/IPO/FunctionResolution.cpp diff -u llvm/lib/Transforms/IPO/FunctionResolution.cpp:1.10 llvm/lib/Transforms/IPO/FunctionResolution.cpp:1.11 --- llvm/lib/Transforms/IPO/FunctionResolution.cpp:1.10 Thu Aug 1 15:01:02 2002 +++ llvm/lib/Transforms/IPO/FunctionResolution.cpp Tue Sep 10 12:02:57 2002 @@ -60,21 +60,16 @@ for (unsigned i = 1; i < CI->getNumOperands(); ++i) { Value *V = CI->getOperand(i); - if (V->getType() != ParamTys[i-1]) { // Must insert a cast... - Instruction *Cast = new CastInst(V, ParamTys[i-1]); - BBI = ++BB->getInstList().insert(BBI, Cast); - V = Cast; - } + if (V->getType() != ParamTys[i-1]) // Must insert a cast... + V = new CastInst(V, ParamTys[i-1], "argcast", BBI); Params.push_back(V); } - Instruction *NewCall = new CallInst(Dest, Params); - // Replace the old call instruction with a new call instruction that calls // the real function. // - BBI = ++BB->getInstList().insert(BBI, NewCall); + Instruction *NewCall = new CallInst(Dest, Params, "", BBI); // Remove the old call instruction from the program... BB->getInstList().remove(BBI); @@ -104,11 +99,10 @@ // value of the function is actually USED. // if (!CI->use_empty()) { + // Insert the new cast instruction... CastInst *NewCast = new CastInst(NewCall, CI->getType(), - NewCall->getName()); + NewCall->getName(), BBI); CI->replaceAllUsesWith(NewCast); - // Insert the new cast instruction... - BB->getInstList().insert(BBI, NewCast); } } From lattner at cs.uiuc.edu Tue Sep 10 14:43:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 10 14:43:01 2002 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/LevelRaise/2002-09-10-PointerAdds.ll Message-ID: <200209101942.OAA22964@trinity.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/LevelRaise: 2002-09-10-PointerAdds.ll added (r1.1) --- Log message: New testcase for poitner problem --- Diffs of the changes: From lattner at cs.uiuc.edu Tue Sep 10 14:43:05 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 10 14:43:05 2002 Subject: [llvm-commits] CVS: llvm/lib/Transforms/ExprTypeConvert.cpp Message-ID: <200209101942.OAA23019@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Transforms: ExprTypeConvert.cpp updated: 1.53 -> 1.54 --- Log message: Fix bug: test/Regression/Transforms/LevelRaise/2002-09-10-PointerAdds.ll --- Diffs of the changes: Index: llvm/lib/Transforms/ExprTypeConvert.cpp diff -u llvm/lib/Transforms/ExprTypeConvert.cpp:1.53 llvm/lib/Transforms/ExprTypeConvert.cpp:1.54 --- llvm/lib/Transforms/ExprTypeConvert.cpp:1.53 Tue Sep 10 12:02:54 2002 +++ llvm/lib/Transforms/ExprTypeConvert.cpp Tue Sep 10 14:42:53 2002 @@ -177,6 +177,7 @@ case Instruction::Add: case Instruction::Sub: + if (!Ty->isInteger() && !Ty->isFloatingPoint()) return false; if (!ExpressionConvertableToType(I->getOperand(0), Ty, CTMap) || !ExpressionConvertableToType(I->getOperand(1), Ty, CTMap)) return false; @@ -610,6 +611,8 @@ } // FALLTHROUGH case Instruction::Sub: { + if (!Ty->isInteger() && !Ty->isFloatingPoint()) return false; + Value *OtherOp = I->getOperand((V == I->getOperand(0)) ? 1 : 0); return ValueConvertableToType(I, Ty, CTMap) && ExpressionConvertableToType(OtherOp, Ty, CTMap); From lattner at cs.uiuc.edu Tue Sep 10 14:56:00 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 10 14:56:00 2002 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/LevelRaise/2002-03-14-ConvertableToGEPHang.ll 2002-02-14-InstDelete.ll Message-ID: <200209101955.OAA23890@trinity.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/LevelRaise: 2002-03-14-ConvertableToGEPHang.ll updated: 1.2 -> 1.3 2002-02-14-InstDelete.ll (r1.1) removed --- Log message: Remove a testcase that is irrelevant now, fix a pointer adding testcase --- Diffs of the changes: Index: llvm/test/Regression/Transforms/LevelRaise/2002-03-14-ConvertableToGEPHang.ll diff -u llvm/test/Regression/Transforms/LevelRaise/2002-03-14-ConvertableToGEPHang.ll:1.2 llvm/test/Regression/Transforms/LevelRaise/2002-03-14-ConvertableToGEPHang.ll:1.3 --- llvm/test/Regression/Transforms/LevelRaise/2002-03-14-ConvertableToGEPHang.ll:1.2 Thu Aug 22 11:39:14 2002 +++ llvm/test/Regression/Transforms/LevelRaise/2002-03-14-ConvertableToGEPHang.ll Tue Sep 10 14:55:40 2002 @@ -17,6 +17,8 @@ %cast1007 = cast %Disjunct * * %reg1000 to sbyte * * ; [#uses=1] %reg110 = load sbyte * * %cast1007 ; [#uses=1] %cast1008 = cast ulong 4 to sbyte * ; [#uses=1] - %reg1001 = add sbyte * %reg110, %cast1008 ; [#uses=0] + %A = cast sbyte * %reg110 to ulong + %B = cast sbyte * %cast1008 to ulong + %reg1001 = add ulong %A, %B ; [#uses=0] ret void end From lattner at cs.uiuc.edu Tue Sep 10 14:58:00 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 10 14:58:00 2002 Subject: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y Message-ID: <200209101957.OAA24089@trinity.cs.uiuc.edu> Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.89 -> 1.90 --- Log message: Tighten up error checking in parser, disallowing instructions that f.e., add pointers together. --- Diffs of the changes: Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.89 llvm/lib/AsmParser/llvmAsmParser.y:1.90 --- llvm/lib/AsmParser/llvmAsmParser.y:1.89 Thu Aug 22 17:48:51 2002 +++ llvm/lib/AsmParser/llvmAsmParser.y Tue Sep 10 14:57:26 2002 @@ -686,6 +686,7 @@ // Binary Operators %type BinaryOps // all the binary operators +%type ArithmeticOps LogicalOps SetCondOps // Binops Subcatagories %token ADD SUB MUL DIV REM AND OR XOR %token SETLE SETGE SETLT SETGT SETEQ SETNE // Binary Comarators @@ -720,8 +721,11 @@ // Operations that are notably excluded from this list include: // RET, BR, & SWITCH because they end basic blocks and are treated specially. // -BinaryOps : ADD | SUB | MUL | DIV | REM | AND | OR | XOR; -BinaryOps : SETLE | SETGE | SETLT | SETGT | SETEQ | SETNE; +ArithmeticOps: ADD | SUB | MUL | DIV | REM; +LogicalOps : AND | OR | XOR; +SetCondOps : SETLE | SETGE | SETLT | SETGT | SETEQ | SETNE; +BinaryOps : ArithmeticOps | LogicalOps | SetCondOps; + ShiftOps : SHL | SHR; // These are some types that allow classification if we only want a particular @@ -1507,7 +1511,23 @@ // ValueRefListE - Just like ValueRefList, except that it may also be empty! ValueRefListE : ValueRefList | /*empty*/ { $$ = 0; }; -InstVal : BinaryOps Types ValueRef ',' ValueRef { +InstVal : ArithmeticOps Types ValueRef ',' ValueRef { + if (!(*$2)->isInteger() && !(*$2)->isFloatingPoint()) + ThrowException("Arithmetic operator requires integer or FP operands!"); + $$ = BinaryOperator::create($1, getVal(*$2, $3), getVal(*$2, $5)); + if ($$ == 0) + ThrowException("binary operator returned null!"); + delete $2; + } + | LogicalOps Types ValueRef ',' ValueRef { + if (!(*$2)->isIntegral()) + ThrowException("Logical operator requires integral operands!"); + $$ = BinaryOperator::create($1, getVal(*$2, $3), getVal(*$2, $5)); + if ($$ == 0) + ThrowException("binary operator returned null!"); + delete $2; + } + | SetCondOps Types ValueRef ',' ValueRef { $$ = BinaryOperator::create($1, getVal(*$2, $3), getVal(*$2, $5)); if ($$ == 0) ThrowException("binary operator returned null!"); From lattner at cs.uiuc.edu Tue Sep 10 14:58:05 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 10 14:58:05 2002 Subject: [llvm-commits] CVS: llvm/lib/VMCore/iOperators.cpp Message-ID: <200209101957.OAA24102@trinity.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: iOperators.cpp updated: 1.18 -> 1.19 --- Log message: Tighten up assertion checking for binary operators, not allowing invalid instructions to _even be created_. --- Diffs of the changes: Index: llvm/lib/VMCore/iOperators.cpp diff -u llvm/lib/VMCore/iOperators.cpp:1.18 llvm/lib/VMCore/iOperators.cpp:1.19 --- llvm/lib/VMCore/iOperators.cpp:1.18 Tue Sep 10 10:45:53 2002 +++ llvm/lib/VMCore/iOperators.cpp Tue Sep 10 14:57:53 2002 @@ -17,11 +17,36 @@ const Type *Ty, const std::string &Name, Instruction *InsertBefore) : Instruction(Ty, iType, Name, InsertBefore) { + Operands.reserve(2); Operands.push_back(Use(S1, this)); Operands.push_back(Use(S2, this)); - assert(Operands[0] && Operands[1] && - Operands[0]->getType() == Operands[1]->getType()); + assert(S1 && S2 && S1->getType() == S2->getType()); + +#ifndef NDEBUG + switch (iType) { + case Add: case Sub: + case Mul: case Div: + case Rem: + assert(Ty == S1->getType() && + "Arithmetic operation should return same type as operands!"); + assert((Ty->isInteger() || Ty->isFloatingPoint()) && + "Tried to create an arithmetic operation on a non-arithmetic type!"); + break; + case And: case Or: + case Xor: + assert(Ty == S1->getType() && + "Logical operation should return same type as operands!"); + assert(Ty->isIntegral() && + "Tried to create an logical operation on a non-integral type!"); + break; + case SetLT: case SetGT: case SetLE: + case SetGE: case SetEQ: case SetNE: + assert(Ty == Type::BoolTy && "Setcc must return bool!"); + default: + break; + } +#endif } From lattner at cs.uiuc.edu Tue Sep 10 15:05:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 10 15:05:01 2002 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/LevelRaise/2002-03-20-Crash.ll 2002-07-16-RaiseCrash2.ll 2002-03-11-IterInvalidate.ll Message-ID: <200209102004.PAA24740@trinity.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/LevelRaise: 2002-03-20-Crash.ll updated: 1.3 -> 1.4 2002-07-16-RaiseCrash2.ll updated: 1.1 -> 1.2 2002-03-11-IterInvalidate.ll (r1.1) removed --- Log message: Clean up pointer using testcases --- Diffs of the changes: Index: llvm/test/Regression/Transforms/LevelRaise/2002-03-20-Crash.ll diff -u llvm/test/Regression/Transforms/LevelRaise/2002-03-20-Crash.ll:1.3 llvm/test/Regression/Transforms/LevelRaise/2002-03-20-Crash.ll:1.4 --- llvm/test/Regression/Transforms/LevelRaise/2002-03-20-Crash.ll:1.3 Thu Aug 22 11:39:14 2002 +++ llvm/test/Regression/Transforms/LevelRaise/2002-03-20-Crash.ll Tue Sep 10 15:04:19 2002 @@ -10,8 +10,10 @@ %Village *"get_results"(%Village * %village) begin bb0: ;[#uses=1] - %cast121 = cast int 24 to %Village * ; <%Village *> [#uses=1] - %reg123 = add %Village * %village, %cast121 ; <%Village *> [#uses=1] + %cast121 = cast int 24 to ulong ; <%Village *> [#uses=1] + %A = cast %Village* %village to ulong + %reg123 = add ulong %A, %cast121 ; <%Village *> [#uses=1] + %reg123 = cast ulong %reg123 to %Village* %idx = getelementptr %Village * %reg123, uint 0, ubyte 0, uint 0 ; <%Village *> [#uses=1] %reg118 = load %Village** %idx ret %Village *%reg118 Index: llvm/test/Regression/Transforms/LevelRaise/2002-07-16-RaiseCrash2.ll diff -u llvm/test/Regression/Transforms/LevelRaise/2002-07-16-RaiseCrash2.ll:1.1 llvm/test/Regression/Transforms/LevelRaise/2002-07-16-RaiseCrash2.ll:1.2 --- llvm/test/Regression/Transforms/LevelRaise/2002-07-16-RaiseCrash2.ll:1.1 Tue Jul 16 16:33:27 2002 +++ llvm/test/Regression/Transforms/LevelRaise/2002-07-16-RaiseCrash2.ll Tue Sep 10 15:04:19 2002 @@ -5,6 +5,8 @@ implementation sbyte* %test(int* %ptr) { %A = cast int* %ptr to sbyte * - %B = add sbyte* %A, %A + %A = cast sbyte* %A to ulong + %B = add ulong %A, %A + %B = cast ulong %B to sbyte* ret sbyte * %B } From lattner at cs.uiuc.edu Tue Sep 10 17:38:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 10 17:38:01 2002 Subject: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y Message-ID: <200209102237.RAA06738@trinity.cs.uiuc.edu> Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.90 -> 1.91 --- Log message: Use explicit ctor --- Diffs of the changes: Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.90 llvm/lib/AsmParser/llvmAsmParser.y:1.91 --- llvm/lib/AsmParser/llvmAsmParser.y:1.90 Tue Sep 10 14:57:26 2002 +++ llvm/lib/AsmParser/llvmAsmParser.y Tue Sep 10 17:37:46 2002 @@ -10,6 +10,7 @@ #include "llvm/Module.h" #include "llvm/iTerminators.h" #include "llvm/iMemory.h" +#include "llvm/iOperators.h" #include "llvm/iPHINode.h" #include "Support/STLExtras.h" #include "Support/DepthFirstIterator.h" @@ -1528,7 +1529,7 @@ delete $2; } | SetCondOps Types ValueRef ',' ValueRef { - $$ = BinaryOperator::create($1, getVal(*$2, $3), getVal(*$2, $5)); + $$ = new SetCondInst($1, getVal(*$2, $3), getVal(*$2, $5)); if ($$ == 0) ThrowException("binary operator returned null!"); delete $2; From lattner at cs.uiuc.edu Tue Sep 10 17:39:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 10 17:39:01 2002 Subject: [llvm-commits] CVS: llvm/lib/Transforms/ExprTypeConvert.cpp Message-ID: <200209102238.RAA06752@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Transforms: ExprTypeConvert.cpp updated: 1.54 -> 1.55 --- Log message: Clean up code --- Diffs of the changes: Index: llvm/lib/Transforms/ExprTypeConvert.cpp diff -u llvm/lib/Transforms/ExprTypeConvert.cpp:1.54 llvm/lib/Transforms/ExprTypeConvert.cpp:1.55 --- llvm/lib/Transforms/ExprTypeConvert.cpp:1.54 Tue Sep 10 14:42:53 2002 +++ llvm/lib/Transforms/ExprTypeConvert.cpp Tue Sep 10 17:38:06 2002 @@ -124,10 +124,8 @@ Expr.Var->getName()+"-off", It); } - Instruction *NewI = new MallocInst(AllocTy, Expr.Var, Name); - assert(AllocTy == Ty); - return NewI; + return = new MallocInst(AllocTy, Expr.Var, Name); } @@ -340,7 +338,6 @@ BasicBlock *BB = I->getParent(); - BasicBlock::InstListType &BIL = BB->getInstList(); std::string Name = I->getName(); if (!Name.empty()) I->setName(""); Instruction *Res; // Result of conversion @@ -495,7 +492,7 @@ assert(Res->getType() == Ty && "Didn't convert expr to correct type!"); - BIL.insert(I, Res); + BB->getInstList().insert(I, Res); // Add the instruction to the expression map VMC.ExprMap[I] = Res; @@ -871,7 +868,6 @@ BasicBlock *BB = I->getParent(); assert(BB != 0 && "Instruction not embedded in basic block!"); - BasicBlock::InstListType &BIL = BB->getInstList(); std::string Name = I->getName(); I->setName(""); Instruction *Res; // Result of conversion @@ -1159,8 +1155,8 @@ // stream. // BasicBlock::iterator It = I; - assert(It != BIL.end() && "Instruction not in own basic block??"); - BIL.insert(It, Res); // Keep It pointing to old instruction + assert(It != BB->end() && "Instruction not in own basic block??"); + BB->getInstList().insert(It, Res); // Keep It pointing to old instruction DEBUG(cerr << "COT CREATED: " << (void*)Res << " " << Res << "In: " << (void*)I << " " << I << "Out: " << (void*)Res From lattner at cs.uiuc.edu Tue Sep 10 17:39:05 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 10 17:39:05 2002 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/ADCE.cpp LICM.cpp LowerAllocations.cpp PiNodeInsertion.cpp PromoteMemoryToRegister.cpp RaiseAllocations.cpp Message-ID: <200209102238.RAA06781@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: ADCE.cpp updated: 1.45 -> 1.46 LICM.cpp updated: 1.11 -> 1.12 LowerAllocations.cpp updated: 1.30 -> 1.31 PiNodeInsertion.cpp updated: 1.6 -> 1.7 PromoteMemoryToRegister.cpp updated: 1.29 -> 1.30 RaiseAllocations.cpp updated: 1.9 -> 1.10 --- Log message: Clean up code due to auto-insert constructors --- Diffs of the changes: Index: llvm/lib/Transforms/Scalar/ADCE.cpp diff -u llvm/lib/Transforms/Scalar/ADCE.cpp:1.45 llvm/lib/Transforms/Scalar/ADCE.cpp:1.46 --- llvm/lib/Transforms/Scalar/ADCE.cpp:1.45 Wed Aug 21 18:43:50 2002 +++ llvm/lib/Transforms/Scalar/ADCE.cpp Tue Sep 10 17:38:47 2002 @@ -240,7 +240,7 @@ // if (!AliveBlocks.count(&Func->front())) { BasicBlock *NewEntry = new BasicBlock(); - NewEntry->getInstList().push_back(new BranchInst(&Func->front())); + new BranchInst(&Func->front(), NewEntry->end()); Func->getBasicBlockList().push_front(NewEntry); AliveBlocks.insert(NewEntry); // This block is always alive! } @@ -353,9 +353,8 @@ // Delete the old terminator instruction... BB->getInstList().pop_back(); const Type *RetTy = Func->getReturnType(); - Instruction *New = new ReturnInst(RetTy != Type::VoidTy ? - Constant::getNullValue(RetTy) : 0); - BB->getInstList().push_back(New); + new ReturnInst(RetTy != Type::VoidTy ? Constant::getNullValue(RetTy) :0, + BB->end()); } BB->dropAllReferences(); Index: llvm/lib/Transforms/Scalar/LICM.cpp diff -u llvm/lib/Transforms/Scalar/LICM.cpp:1.11 llvm/lib/Transforms/Scalar/LICM.cpp:1.12 --- llvm/lib/Transforms/Scalar/LICM.cpp:1.11 Thu Aug 22 17:48:36 2002 +++ llvm/lib/Transforms/Scalar/LICM.cpp Tue Sep 10 17:38:47 2002 @@ -241,10 +241,8 @@ // No loop pre-header, insert a PHI node into header to capture all of the // incoming versions of the value. // - PHINode *LoopVal = new PHINode(Inst.getType(), InstName+".phi"); - - // Insert the new PHI node into the loop header... - Header->getInstList().push_front(LoopVal); + PHINode *LoopVal = new PHINode(Inst.getType(), InstName+".phi", + Header->begin()); // Insert cloned versions of the instruction into all of the loop preds. for (unsigned i = 0, e = LoopPreds.size(); i != e; ++i) { Index: llvm/lib/Transforms/Scalar/LowerAllocations.cpp diff -u llvm/lib/Transforms/Scalar/LowerAllocations.cpp:1.30 llvm/lib/Transforms/Scalar/LowerAllocations.cpp:1.31 --- llvm/lib/Transforms/Scalar/LowerAllocations.cpp:1.30 Thu Aug 8 14:00:34 2002 +++ llvm/lib/Transforms/Scalar/LowerAllocations.cpp Tue Sep 10 17:38:47 2002 @@ -87,8 +87,6 @@ // Loop over all of the instructions, looking for malloc or free instructions for (BasicBlock::iterator I = BB.begin(), E = BB.end(); I != E; ++I) { if (MallocInst *MI = dyn_cast(&*I)) { - BBIL.remove(I); // remove the malloc instr... - const Type *AllocTy = MI->getType()->getElementType(); // Get the number of bytes to be allocated for one element of the @@ -101,39 +99,32 @@ MallocArg = MI->getOperand(0); // Operand * 1 = Operand } else if (MI->getNumOperands()) { // Multiply it by the array size if neccesary... - MallocArg = BinaryOperator::create(Instruction::Mul,MI->getOperand(0), - MallocArg); - I = ++BBIL.insert(I, cast(MallocArg)); + MallocArg = BinaryOperator::create(Instruction::Mul, MI->getOperand(0), + MallocArg, "", I); } // Create the call to Malloc... CallInst *MCall = new CallInst(MallocFunc, - vector(1, MallocArg)); - I = BBIL.insert(I, MCall); + vector(1, MallocArg), "", I); // Create a cast instruction to convert to the right type... - CastInst *MCast = new CastInst(MCall, MI->getType()); - I = BBIL.insert(++I, MCast); + CastInst *MCast = new CastInst(MCall, MI->getType(), "", I); // Replace all uses of the old malloc inst with the cast inst MI->replaceAllUsesWith(MCast); - delete MI; // Delete the malloc inst + I = --BBIL.erase(I); // remove and delete the malloc instr... Changed = true; ++NumLowered; } else if (FreeInst *FI = dyn_cast(&*I)) { - BBIL.remove(I); - // Cast the argument to free into a ubyte*... CastInst *MCast = new CastInst(FI->getOperand(0), - PointerType::get(Type::UByteTy)); - I = ++BBIL.insert(I, MCast); + PointerType::get(Type::UByteTy), "", I); // Insert a call to the free function... - CallInst *FCall = new CallInst(FreeFunc, vector(1, MCast)); - I = BBIL.insert(I, FCall); + CallInst *FCall = new CallInst(FreeFunc, vector(1, MCast), "", I); // Delete the old free instruction - delete FI; + I = --BBIL.erase(I); Changed = true; ++NumLowered; } Index: llvm/lib/Transforms/Scalar/PiNodeInsertion.cpp diff -u llvm/lib/Transforms/Scalar/PiNodeInsertion.cpp:1.6 llvm/lib/Transforms/Scalar/PiNodeInsertion.cpp:1.7 --- llvm/lib/Transforms/Scalar/PiNodeInsertion.cpp:1.6 Thu Aug 8 14:01:26 2002 +++ llvm/lib/Transforms/Scalar/PiNodeInsertion.cpp Tue Sep 10 17:38:47 2002 @@ -148,13 +148,8 @@ // Create the Pi node... Value *Pi = Rep; - if (Rep == 0) { - PHINode *Phi = new PHINode(V->getType(), V->getName() + ".pi"); - - // Insert the Pi node in the successor basic block... - Succ->getInstList().push_front(Phi); - Pi = Phi; - } + if (Rep == 0) // Insert the Pi node in the successor basic block... + Pi = new PHINode(V->getType(), V->getName() + ".pi", Succ->begin()); // Loop over all of the uses of V, replacing ones that the Pi node // dominates with references to the Pi node itself. Index: llvm/lib/Transforms/Scalar/PromoteMemoryToRegister.cpp diff -u llvm/lib/Transforms/Scalar/PromoteMemoryToRegister.cpp:1.29 llvm/lib/Transforms/Scalar/PromoteMemoryToRegister.cpp:1.30 --- llvm/lib/Transforms/Scalar/PromoteMemoryToRegister.cpp:1.29 Thu Aug 22 18:36:48 2002 +++ llvm/lib/Transforms/Scalar/PromoteMemoryToRegister.cpp Tue Sep 10 17:38:47 2002 @@ -196,14 +196,12 @@ // If the BB already has a phi node added for the i'th alloca then we're done! if (BBPNs[AllocaNo]) return false; - // Create a PhiNode using the dereferenced type... + // Create a PhiNode using the dereferenced type... and add the phi-node to the + // BasicBlock PHINode *PN = new PHINode(Allocas[AllocaNo]->getAllocatedType(), - Allocas[AllocaNo]->getName()+".mem2reg"); + Allocas[AllocaNo]->getName()+".mem2reg", + BB->begin()); BBPNs[AllocaNo] = PN; - - // Add the phi-node to the basic-block - BB->getInstList().push_front(PN); - PhiNodes[AllocaNo].push_back(BB); return true; } Index: llvm/lib/Transforms/Scalar/RaiseAllocations.cpp diff -u llvm/lib/Transforms/Scalar/RaiseAllocations.cpp:1.9 llvm/lib/Transforms/Scalar/RaiseAllocations.cpp:1.10 --- llvm/lib/Transforms/Scalar/RaiseAllocations.cpp:1.9 Fri Jul 26 16:12:41 2002 +++ llvm/lib/Transforms/Scalar/RaiseAllocations.cpp Tue Sep 10 17:38:47 2002 @@ -108,7 +108,7 @@ bool Changed = false; BasicBlock::InstListType &BIL = BB.getInstList(); - for (BasicBlock::iterator BI = BB.begin(); BI != BB.end();) { + for (BasicBlock::iterator BI = BB.begin(); BI != BB.end(); ++BI) { Instruction *I = BI; if (CallInst *CI = dyn_cast(I)) { @@ -118,19 +118,14 @@ // If no prototype was provided for malloc, we may need to cast the // source size. - if (Source->getType() != Type::UIntTy) { - CastInst *New = new CastInst(Source, Type::UIntTy, "MallocAmtCast"); - BI = ++BIL.insert(BI, New); - Source = New; - } + if (Source->getType() != Type::UIntTy) + Source = new CastInst(Source, Type::UIntTy, "MallocAmtCast", BI); - MallocInst *MallocI = new MallocInst(PtrSByte, Source, CI->getName()); - - CI->setName(""); - ReplaceInstWithInst(BIL, BI, MallocI); + std::string Name(CI->getName()); CI->setName(""); + BI = new MallocInst(PtrSByte, Source, Name, BI); + BIL.erase(I); Changed = true; ++NumRaised; - continue; // Skip the ++BI } else if (CI->getCalledValue() == FreeFunc) { // Replace call to free? // If no prototype was provided for free, we may need to cast the // source pointer. This should be really uncommon, but it's neccesary @@ -138,21 +133,15 @@ // free((long)ptr); // Value *Source = CI->getOperand(1); - if (!isa(Source->getType())) { - CastInst *New = new CastInst(Source, PointerType::get(Type::SByteTy), - "FreePtrCast"); - BI = ++BIL.insert(BI, New); - Source = New; - } - - ReplaceInstWithInst(BIL, BI, new FreeInst(Source)); + if (!isa(Source->getType())) + Source = new CastInst(Source, PointerType::get(Type::SByteTy), + "FreePtrCast", BI); + BI = new FreeInst(Source, BI); + BIL.erase(I); Changed = true; - continue; // Skip the ++BI ++NumRaised; } } - - ++BI; } return Changed; From lattner at cs.uiuc.edu Tue Sep 10 17:39:09 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 10 17:39:09 2002 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp Message-ID: <200209102238.RAA06788@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Utils: UnifyFunctionExitNodes.cpp updated: 1.18 -> 1.19 --- Log message: Clean up code due to auto-insert constructors --- Diffs of the changes: Index: llvm/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp diff -u llvm/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp:1.18 llvm/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp:1.19 --- llvm/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp:1.18 Wed Aug 21 12:09:49 2002 +++ llvm/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp Tue Sep 10 17:38:49 2002 @@ -49,8 +49,8 @@ if (F.getReturnType() != Type::VoidTy) { // If the function doesn't return void... add a PHI node to the block... - PHINode *PN = new PHINode(F.getReturnType(), "UnifiedRetVal"); - NewRetBlock->getInstList().push_back(PN); + PHINode *PN = new PHINode(F.getReturnType(), "UnifiedRetVal", + NewRetBlock.end()); // Add an incoming element to the PHI node for every return instruction that // is merging into this new block... @@ -59,10 +59,10 @@ PN->addIncoming((*I)->getTerminator()->getOperand(0), *I); // Add a return instruction to return the result of the PHI node... - NewRetBlock->getInstList().push_back(new ReturnInst(PN)); + new ReturnInst(PN, NewRetBlock.end()); } else { // If it returns void, just add a return void instruction to the block - NewRetBlock->getInstList().push_back(new ReturnInst()); + new ReturnInst(0, NewRetBlock.end()); } // Loop over all of the blocks, replacing the return instruction with an @@ -71,7 +71,7 @@ for (vector::iterator I = ReturningBlocks.begin(), E = ReturningBlocks.end(); I != E; ++I) { (*I)->getInstList().pop_back(); // Remove the return insn - (*I)->getInstList().push_back(new BranchInst(NewRetBlock)); + new BranchInst(NewRetBlock, (*I)->end()); } ExitNode = NewRetBlock; return true; From lattner at cs.uiuc.edu Tue Sep 10 17:40:00 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 10 17:40:00 2002 Subject: [llvm-commits] CVS: llvm/lib/Transforms/FunctionInlining.cpp Message-ID: <200209102239.RAA06811@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Transforms: FunctionInlining.cpp updated: 1.33 -> 1.34 --- Log message: Clean up code due to auto-insert constructors --- Diffs of the changes: Index: llvm/lib/Transforms/FunctionInlining.cpp diff -u llvm/lib/Transforms/FunctionInlining.cpp:1.33 llvm/lib/Transforms/FunctionInlining.cpp:1.34 --- llvm/lib/Transforms/FunctionInlining.cpp:1.33 Fri Jul 26 16:12:31 2002 +++ llvm/lib/Transforms/FunctionInlining.cpp Tue Sep 10 17:38:44 2002 @@ -93,12 +93,11 @@ // PHINode *PHI = 0; if (CalledFunc->getReturnType() != Type::VoidTy) { - PHI = new PHINode(CalledFunc->getReturnType(), CI->getName()); - // The PHI node should go at the front of the new basic block to merge all // possible incoming values. // - NewBB->getInstList().push_front(PHI); + PHI = new PHINode(CalledFunc->getReturnType(), CI->getName(), + NewBB->begin()); // Anything that used the result of the function call should now use the PHI // node as their operand. @@ -164,7 +163,7 @@ } // Add a branch to the code that was after the original Call. - IBB->getInstList().push_back(new BranchInst(NewBB)); + new BranchInst(NewBB, IBB->end()); break; } case Instruction::Br: From lattner at cs.uiuc.edu Tue Sep 10 17:40:05 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 10 17:40:05 2002 Subject: [llvm-commits] CVS: llvm/www/docs/doxygen.cfg Message-ID: <200209102239.RAA06804@trinity.cs.uiuc.edu> Changes in directory llvm/www/docs: doxygen.cfg updated: 1.3 -> 1.4 --- Log message: Fix config file due to directories changing --- Diffs of the changes: Index: llvm/www/docs/doxygen.cfg diff -u llvm/www/docs/doxygen.cfg:1.3 llvm/www/docs/doxygen.cfg:1.4 --- llvm/www/docs/doxygen.cfg:1.3 Thu Aug 22 17:44:22 2002 +++ llvm/www/docs/doxygen.cfg Tue Sep 10 17:39:04 2002 @@ -302,7 +302,7 @@ # directories like "/usr/src/myproject". Separate the files or directories # with spaces. -INPUT = .. +INPUT = ../.. # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp @@ -323,7 +323,7 @@ # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. -EXCLUDE = ../test ../include/boost +EXCLUDE = ../../test ../../include/boost # If the value of the INPUT tag contains directories, you can use the # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude @@ -697,7 +697,7 @@ # contain include files that are not input files but should be processed by # the preprocessor. -INCLUDE_PATH = ../include +INCLUDE_PATH = ../../include # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard # patterns (like *.h and *.hpp) to filter out the header-files in the From lattner at cs.uiuc.edu Tue Sep 10 17:53:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 10 17:53:01 2002 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp Message-ID: <200209102252.RAA07928@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Utils: UnifyFunctionExitNodes.cpp updated: 1.19 -> 1.20 --- Log message: Fix minor problems in previous checkin --- Diffs of the changes: Index: llvm/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp diff -u llvm/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp:1.19 llvm/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp:1.20 --- llvm/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp:1.19 Tue Sep 10 17:38:49 2002 +++ llvm/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp Tue Sep 10 17:52:49 2002 @@ -50,7 +50,7 @@ if (F.getReturnType() != Type::VoidTy) { // If the function doesn't return void... add a PHI node to the block... PHINode *PN = new PHINode(F.getReturnType(), "UnifiedRetVal", - NewRetBlock.end()); + NewRetBlock->end()); // Add an incoming element to the PHI node for every return instruction that // is merging into this new block... @@ -59,10 +59,10 @@ PN->addIncoming((*I)->getTerminator()->getOperand(0), *I); // Add a return instruction to return the result of the PHI node... - new ReturnInst(PN, NewRetBlock.end()); + new ReturnInst(PN, NewRetBlock->end()); } else { // If it returns void, just add a return void instruction to the block - new ReturnInst(0, NewRetBlock.end()); + new ReturnInst(0, NewRetBlock->end()); } // Loop over all of the blocks, replacing the return instruction with an From lattner at cs.uiuc.edu Tue Sep 10 17:53:05 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 10 17:53:05 2002 Subject: [llvm-commits] CVS: llvm/lib/Transforms/ExprTypeConvert.cpp Message-ID: <200209102252.RAA07936@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Transforms: ExprTypeConvert.cpp updated: 1.55 -> 1.56 --- Log message: Fix minor problems in previous checkin --- Diffs of the changes: Index: llvm/lib/Transforms/ExprTypeConvert.cpp diff -u llvm/lib/Transforms/ExprTypeConvert.cpp:1.55 llvm/lib/Transforms/ExprTypeConvert.cpp:1.56 --- llvm/lib/Transforms/ExprTypeConvert.cpp:1.55 Tue Sep 10 17:38:06 2002 +++ llvm/lib/Transforms/ExprTypeConvert.cpp Tue Sep 10 17:52:51 2002 @@ -125,7 +125,7 @@ } assert(AllocTy == Ty); - return = new MallocInst(AllocTy, Expr.Var, Name); + return new MallocInst(AllocTy, Expr.Var, Name); } From lattner at cs.uiuc.edu Tue Sep 10 18:04:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 10 18:04:01 2002 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/InstCombine/shift.ll Message-ID: <200209102303.SAA08603@trinity.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/InstCombine: shift.ll updated: 1.3 -> 1.4 --- Log message: Check for cannonicalization of shl X, 1 -> add X, X --- Diffs of the changes: Index: llvm/test/Regression/Transforms/InstCombine/shift.ll diff -u llvm/test/Regression/Transforms/InstCombine/shift.ll:1.3 llvm/test/Regression/Transforms/InstCombine/shift.ll:1.4 --- llvm/test/Regression/Transforms/InstCombine/shift.ll:1.3 Fri Aug 2 14:27:58 2002 +++ llvm/test/Regression/Transforms/InstCombine/shift.ll Tue Sep 10 18:03:10 2002 @@ -33,3 +33,7 @@ ret uint %B } +uint %test6(uint %A) { + %B = shl uint %A, ubyte 1 ;; convert to an add instruction + ret uint %B +} From lattner at cs.uiuc.edu Tue Sep 10 18:05:02 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 10 18:05:02 2002 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp Message-ID: <200209102304.SAA08629@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: InstructionCombining.cpp updated: 1.54 -> 1.55 --- Log message: Add cannonicalization of shl X, 1 -> add X, X --- Diffs of the changes: Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.54 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.55 --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.54 Mon Sep 9 22:50:54 2002 +++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Tue Sep 10 18:04:09 2002 @@ -490,10 +490,18 @@ // a signed value. // if (ConstantUInt *CUI = dyn_cast(Op1)) { - unsigned TypeBits = Op0->getType()->getPrimitiveSize()*8; - if (CUI->getValue() >= TypeBits && - !(Op0->getType()->isSigned() && I.getOpcode() == Instruction::Shr)) - return ReplaceInstUsesWith(I, Constant::getNullValue(Op0->getType())); + if (I.getOpcode() == Instruction::Shr) { + unsigned TypeBits = Op0->getType()->getPrimitiveSize()*8; + if (CUI->getValue() >= TypeBits && !(Op0->getType()->isSigned())) + return ReplaceInstUsesWith(I, Constant::getNullValue(Op0->getType())); + } + + // Check to see if we are shifting left by 1. If so, turn it into an add + // instruction. + if (I.getOpcode() == Instruction::Shl && CUI->equalsInt(1)) + // Convert 'shl int %X, 2' to 'add int %X, %X' + return BinaryOperator::create(Instruction::Add, Op0, Op0, I.getName()); + } return 0; } From lattner at cs.uiuc.edu Tue Sep 10 18:32:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 10 18:32:01 2002 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/RaiseAllocations.cpp Message-ID: <200209102331.SAA09603@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: RaiseAllocations.cpp updated: 1.10 -> 1.11 --- Log message: Fix bug in previous checkin --- Diffs of the changes: Index: llvm/lib/Transforms/Scalar/RaiseAllocations.cpp diff -u llvm/lib/Transforms/Scalar/RaiseAllocations.cpp:1.10 llvm/lib/Transforms/Scalar/RaiseAllocations.cpp:1.11 --- llvm/lib/Transforms/Scalar/RaiseAllocations.cpp:1.10 Tue Sep 10 17:38:47 2002 +++ llvm/lib/Transforms/Scalar/RaiseAllocations.cpp Tue Sep 10 18:31:12 2002 @@ -123,6 +123,7 @@ std::string Name(CI->getName()); CI->setName(""); BI = new MallocInst(PtrSByte, Source, Name, BI); + CI->replaceAllUsesWith(BI); BIL.erase(I); Changed = true; ++NumRaised; From lattner at cs.uiuc.edu Tue Sep 10 18:32:05 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 10 18:32:05 2002 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp Message-ID: <200209102331.SAA09618@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Utils: UnifyFunctionExitNodes.cpp updated: 1.20 -> 1.21 --- Log message: Fix bugs in previous checkins --- Diffs of the changes: Index: llvm/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp diff -u llvm/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp:1.20 llvm/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp:1.21 --- llvm/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp:1.20 Tue Sep 10 17:52:49 2002 +++ llvm/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp Tue Sep 10 18:31:28 2002 @@ -49,8 +49,8 @@ if (F.getReturnType() != Type::VoidTy) { // If the function doesn't return void... add a PHI node to the block... - PHINode *PN = new PHINode(F.getReturnType(), "UnifiedRetVal", - NewRetBlock->end()); + PHINode *PN = new PHINode(F.getReturnType(), "UnifiedRetVal"); + NewRetBlock->getInstList().push_back(PN); // Add an incoming element to the PHI node for every return instruction that // is merging into this new block... @@ -59,7 +59,7 @@ PN->addIncoming((*I)->getTerminator()->getOperand(0), *I); // Add a return instruction to return the result of the PHI node... - new ReturnInst(PN, NewRetBlock->end()); + NewRetBlock->getInstList().push_back(new ReturnInst(PN)); } else { // If it returns void, just add a return void instruction to the block new ReturnInst(0, NewRetBlock->end()); @@ -71,7 +71,7 @@ for (vector::iterator I = ReturningBlocks.begin(), E = ReturningBlocks.end(); I != E; ++I) { (*I)->getInstList().pop_back(); // Remove the return insn - new BranchInst(NewRetBlock, (*I)->end()); + (*I)->getInstList().push_back(new BranchInst(NewRetBlock)); } ExitNode = NewRetBlock; return true; From lattner at cs.uiuc.edu Tue Sep 10 18:47:00 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 10 18:47:00 2002 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/ADCE.cpp Message-ID: <200209102346.SAA10061@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: ADCE.cpp updated: 1.46 -> 1.47 --- Log message: Fix the last of the silly bugs I just introduced. :( --- Diffs of the changes: Index: llvm/lib/Transforms/Scalar/ADCE.cpp diff -u llvm/lib/Transforms/Scalar/ADCE.cpp:1.46 llvm/lib/Transforms/Scalar/ADCE.cpp:1.47 --- llvm/lib/Transforms/Scalar/ADCE.cpp:1.46 Tue Sep 10 17:38:47 2002 +++ llvm/lib/Transforms/Scalar/ADCE.cpp Tue Sep 10 18:46:10 2002 @@ -240,7 +240,7 @@ // if (!AliveBlocks.count(&Func->front())) { BasicBlock *NewEntry = new BasicBlock(); - new BranchInst(&Func->front(), NewEntry->end()); + NewEntry->getInstList().push_back(new BranchInst(&Func->front())); Func->getBasicBlockList().push_front(NewEntry); AliveBlocks.insert(NewEntry); // This block is always alive! } @@ -353,8 +353,8 @@ // Delete the old terminator instruction... BB->getInstList().pop_back(); const Type *RetTy = Func->getReturnType(); - new ReturnInst(RetTy != Type::VoidTy ? Constant::getNullValue(RetTy) :0, - BB->end()); + BB->getInstList().push_back(new ReturnInst(RetTy != Type::VoidTy ? + Constant::getNullValue(RetTy) : 0)); } BB->dropAllReferences(); From lattner at cs.uiuc.edu Tue Sep 10 18:56:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 10 18:56:01 2002 Subject: [llvm-commits] CVS: llvm/include/llvm/iTerminators.h Message-ID: <200209102355.SAA10180@trinity.cs.uiuc.edu> Changes in directory llvm/include/llvm: iTerminators.h updated: 1.23 -> 1.24 --- Log message: Add convenience ctor to BranchInst --- Diffs of the changes: Index: llvm/include/llvm/iTerminators.h diff -u llvm/include/llvm/iTerminators.h:1.23 llvm/include/llvm/iTerminators.h:1.24 --- llvm/include/llvm/iTerminators.h:1.23 Tue Sep 10 10:36:11 2002 +++ llvm/include/llvm/iTerminators.h Tue Sep 10 18:54:56 2002 @@ -69,8 +69,9 @@ BranchInst(const BranchInst &BI); public: // If cond = null, then is an unconditional br... - BranchInst(BasicBlock *IfTrue, BasicBlock *IfFalse = 0, Value *cond = 0, + BranchInst(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *cond = 0, Instruction *InsertBefore = 0); + BranchInst(BasicBlock *IfTrue, Instruction *InsertBefore = 0); virtual Instruction *clone() const { return new BranchInst(*this); } From lattner at cs.uiuc.edu Tue Sep 10 18:56:05 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 10 18:56:05 2002 Subject: [llvm-commits] CVS: llvm/lib/VMCore/iBranch.cpp Message-ID: <200209102355.SAA10188@trinity.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: iBranch.cpp updated: 1.6 -> 1.7 --- Log message: Add convenience ctor to BranchInst --- Diffs of the changes: Index: llvm/lib/VMCore/iBranch.cpp diff -u llvm/lib/VMCore/iBranch.cpp:1.6 llvm/lib/VMCore/iBranch.cpp:1.7 --- llvm/lib/VMCore/iBranch.cpp:1.6 Tue Sep 10 10:45:53 2002 +++ llvm/lib/VMCore/iBranch.cpp Tue Sep 10 18:54:58 2002 @@ -26,6 +26,13 @@ "May only branch on boolean predicates!!!!"); } +BranchInst::BranchInst(BasicBlock *True, Instruction *InsertBefore) + : TerminatorInst(Instruction::Br, InsertBefore) { + assert(True != 0 && "True branch destination may not be null!!!"); + Operands.reserve(1); + Operands.push_back(Use(True, this)); +} + BranchInst::BranchInst(const BranchInst &BI) : TerminatorInst(Instruction::Br) { Operands.reserve(BI.Operands.size()); Operands.push_back(Use(BI.Operands[0], this)); From lattner at cs.uiuc.edu Tue Sep 10 19:23:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 10 19:23:01 2002 Subject: [llvm-commits] CVS: llvm/lib/VMCore/iMemory.cpp Message-ID: <200209110022.TAA12151@trinity.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: iMemory.cpp updated: 1.26 -> 1.27 --- Log message: Allocation insts always have one operand --- Diffs of the changes: Index: llvm/lib/VMCore/iMemory.cpp diff -u llvm/lib/VMCore/iMemory.cpp:1.26 llvm/lib/VMCore/iMemory.cpp:1.27 --- llvm/lib/VMCore/iMemory.cpp:1.26 Tue Sep 10 10:45:53 2002 +++ llvm/lib/VMCore/iMemory.cpp Tue Sep 10 19:22:39 2002 @@ -24,8 +24,7 @@ } bool AllocationInst::isArrayAllocation() const { - return getNumOperands() == 1 && - getOperand(0) != ConstantUInt::get(Type::UIntTy, 1); + return getOperand(0) != ConstantUInt::get(Type::UIntTy, 1); } const Type *AllocationInst::getAllocatedType() const { From lattner at cs.uiuc.edu Tue Sep 10 20:17:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 10 20:17:01 2002 Subject: [llvm-commits] CVS: llvm/include/llvm/DerivedTypes.h Message-ID: <200209110116.UAA13597@trinity.cs.uiuc.edu> Changes in directory llvm/include/llvm: DerivedTypes.h updated: 1.27 -> 1.28 --- Log message: Convert index type for getelementptr instruction from uint to long --- Diffs of the changes: Index: llvm/include/llvm/DerivedTypes.h diff -u llvm/include/llvm/DerivedTypes.h:1.27 llvm/include/llvm/DerivedTypes.h:1.28 --- llvm/include/llvm/DerivedTypes.h:1.27 Tue Jun 25 11:10:40 2002 +++ llvm/include/llvm/DerivedTypes.h Tue Sep 10 20:16:19 2002 @@ -264,13 +264,13 @@ return ElementType.get(); } virtual bool indexValid(const Value *V) const { - return V->getType() == Type::UIntTy; // Must be an unsigned int index + return V->getType() == Type::LongTy; // Must be a 'long' index } // getIndexType() - Return the type required of indices for this composite. // For structures, this is ubyte, for arrays, this is uint // - virtual const Type *getIndexType() const { return Type::UIntTy; } + virtual const Type *getIndexType() const { return Type::LongTy; } // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const SequentialType *T) { return true; } From lattner at cs.uiuc.edu Tue Sep 10 20:19:00 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 10 20:19:00 2002 Subject: [llvm-commits] CVS: llvm/lib/CWriter/Writer.cpp Message-ID: <200209110118.UAA13617@trinity.cs.uiuc.edu> Changes in directory llvm/lib/CWriter: Writer.cpp updated: 1.40 -> 1.41 --- Log message: - Change getelementptr instruction to use long indexes instead of uint indexes for sequential types. --- Diffs of the changes: Index: llvm/lib/CWriter/Writer.cpp diff -u llvm/lib/CWriter/Writer.cpp:1.40 llvm/lib/CWriter/Writer.cpp:1.41 --- llvm/lib/CWriter/Writer.cpp:1.40 Fri Aug 30 19:29:16 2002 +++ llvm/lib/CWriter/Writer.cpp Tue Sep 10 20:18:27 2002 @@ -916,7 +916,7 @@ } for (; I != E; ++I) - if ((*I)->getType() == Type::UIntTy) { + if ((*I)->getType() == Type::LongTy) { Out << "[((int) ("; // sign-extend from 32 (to 64) bits writeOperand(*I); Out << " * sizeof("; @@ -925,7 +925,7 @@ printType(cast(Ptr->getType())->getElementType()); Out << ")]"; } else { - Out << ".field" << cast(*I)->getValue(); + Out << ".field" << cast(*I)->getValue(); } } From lattner at cs.uiuc.edu Tue Sep 10 20:19:05 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 10 20:19:05 2002 Subject: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y Message-ID: <200209110118.UAA13622@trinity.cs.uiuc.edu> Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.91 -> 1.92 --- Log message: Recently changed getelementptr to use 'long' indexes for sequential types instead of uints. This adds a translation scheme to be backwards compatible with old .ll files. --- Diffs of the changes: Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.91 llvm/lib/AsmParser/llvmAsmParser.y:1.92 --- llvm/lib/AsmParser/llvmAsmParser.y:1.91 Tue Sep 10 17:37:46 2002 +++ llvm/lib/AsmParser/llvmAsmParser.y Tue Sep 10 20:17:27 2002 @@ -1705,6 +1705,16 @@ delete $4; delete $6; } | GETELEMENTPTR Types ValueRef IndexList { + for (unsigned i = 0, e = $4->size(); i != e; ++i) { + if ((*$4)[i]->getType() == Type::UIntTy) { + std::cerr << "WARNING: Use of uint type indexes to getelementptr " + << "instruction: replacing with casts to long type.\n"; + Instruction *I = new CastInst((*$4)[i], Type::LongTy); + CurBB->getInstList().push_back(I); + (*$4)[i] = I; + } + } + if (!isa($2->get())) ThrowException("getelementptr insn requires pointer operand!"); if (!GetElementPtrInst::getIndexedType(*$2, *$4, true)) From lattner at cs.uiuc.edu Tue Sep 10 20:21:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 10 20:21:01 2002 Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/SparcInstrSelection.cpp Message-ID: <200209110120.UAA13653@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Target/Sparc: SparcInstrSelection.cpp updated: 1.70 -> 1.71 --- Log message: - Change getelementptr instruction to use long indexes instead of uint indexes for sequential types. --- Diffs of the changes: Index: llvm/lib/Target/Sparc/SparcInstrSelection.cpp diff -u llvm/lib/Target/Sparc/SparcInstrSelection.cpp:1.70 llvm/lib/Target/Sparc/SparcInstrSelection.cpp:1.71 --- llvm/lib/Target/Sparc/SparcInstrSelection.cpp:1.70 Mon Sep 9 09:54:21 2002 +++ llvm/lib/Target/Sparc/SparcInstrSelection.cpp Tue Sep 10 20:20:07 2002 @@ -24,9 +24,6 @@ #include using std::vector; -//************************* Forward Declarations ***************************/ - - //************************ Internal Functions ******************************/ @@ -937,15 +934,6 @@ } - -// Check for a constant (uint) 0. -inline bool -IsZero(Value* idx) -{ - return (isa(idx) && cast(idx)->isNullValue()); -} - - //------------------------------------------------------------------------ // Function SetOperandsForMemInstr // @@ -1004,7 +992,8 @@ // offset. (An extra leading zero offset, if any, can be ignored.) // Generate code sequence to compute address from index. // - bool firstIdxIsZero = IsZero(idxVec[0]); + bool firstIdxIsZero = + (idxVec[0] == Constant::getNullValue(idxVec[0]->getType())); assert(idxVec.size() == 1U + firstIdxIsZero && "Array refs must be lowered before Instruction Selection"); From lattner at cs.uiuc.edu Tue Sep 10 20:21:06 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 10 20:21:06 2002 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp Message-ID: <200209110120.UAA13659@trinity.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/InstrSelection: InstrSelectionSupport.cpp updated: 1.28 -> 1.29 --- Log message: - Change getelementptr instruction to use long indexes instead of uint indexes for sequential types. --- Diffs of the changes: Index: llvm/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp diff -u llvm/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp:1.28 llvm/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp:1.29 --- llvm/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp:1.28 Mon Sep 2 20:06:35 2002 +++ llvm/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp Tue Sep 10 20:20:03 2002 @@ -113,12 +113,12 @@ FoldGetElemChain(InstrTreeNode* ptrNode, vector& chainIdxVec) { InstructionNode* gepNode = dyn_cast(ptrNode); - if (gepNode == NULL) - return NULL; // ptr value is not computed in this tree - GetElementPtrInst* gepInst = - dyn_cast(gepNode->getInstruction()); - if (gepInst == NULL) // ptr value does not come from GEP instruction + dyn_cast_or_null(gepNode->getInstruction()); + + // ptr value is not computed in this tree or ptr value does not come from GEP + // instruction + if (gepInst == NULL) return NULL; // Return NULL if we don't fold any instructions in. @@ -149,8 +149,8 @@ ptrVal = gepInst->getPointerOperand(); // Check for a leading [0] index, if any. It will be discarded later. - ConstantUInt* CV = dyn_cast((Value*) *firstIdx); - hasLeadingZero = bool(CV && CV->getValue() == 0); + hasLeadingZero = (*firstIdx == + Constant::getNullValue((*firstIdx)->getType())); // Insert its index vector at the start, skipping any leading [0] chainIdxVec.insert(chainIdxVec.begin(), @@ -168,7 +168,7 @@ // If the first getElementPtr instruction had a leading [0], add it back. // Note that this instruction is the *last* one successfully folded above. if (ptrVal && hasLeadingZero) - chainIdxVec.insert(chainIdxVec.begin(), ConstantUInt::get(Type::UIntTy,0)); + chainIdxVec.insert(chainIdxVec.begin(), ConstantSInt::get(Type::LongTy,0)); return ptrVal; } From lattner at cs.uiuc.edu Tue Sep 10 20:21:10 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 10 20:21:10 2002 Subject: [llvm-commits] CVS: llvm/lib/Target/TargetData.cpp Message-ID: <200209110120.UAA13665@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Target: TargetData.cpp updated: 1.21 -> 1.22 --- Log message: - Change getelementptr instruction to use long indexes instead of uint indexes for sequential types. --- Diffs of the changes: Index: llvm/lib/Target/TargetData.cpp diff -u llvm/lib/Target/TargetData.cpp:1.21 llvm/lib/Target/TargetData.cpp:1.22 --- llvm/lib/Target/TargetData.cpp:1.21 Sat Aug 24 09:44:58 2002 +++ llvm/lib/Target/TargetData.cpp Tue Sep 10 20:20:05 2002 @@ -157,17 +157,17 @@ assert(isa(Ty) && "Illegal argument for getIndexedOffset()"); uint64_t Result = 0; - for (unsigned CurIDX = 0; CurIDX < Idx.size(); ++CurIDX) { - if (Idx[CurIDX]->getType() == Type::UIntTy) { + for (unsigned CurIDX = 0; CurIDX != Idx.size(); ++CurIDX) { + if (Idx[CurIDX]->getType() == Type::LongTy) { // Update Ty to refer to current element Ty = cast(Ty)->getElementType(); // Get the array index and the size of each array element. // Both must be known constants, or this will fail. // Also, the product needs to be sign-extended from 32 to 64 bits. - uint64_t elementSize = this->getTypeSize(Ty); - uint64_t arrayIdx = cast(Idx[CurIDX])->getValue(); - Result += (uint64_t) (int) (arrayIdx * elementSize); // sign-extend + int64_t elementSize = (int64_t)getTypeSize(Ty); + int64_t arrayIdx = cast(Idx[CurIDX])->getValue(); + Result += (uint64_t)(arrayIdx * elementSize); } else if (const StructType *STy = dyn_cast(Ty)) { assert(Idx[CurIDX]->getType() == Type::UByteTy && "Illegal struct idx"); From lattner at cs.uiuc.edu Tue Sep 10 20:22:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 10 20:22:01 2002 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp InstructionCombining.cpp Message-ID: <200209110121.UAA13716@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: DecomposeMultiDimRefs.cpp updated: 1.23 -> 1.24 InstructionCombining.cpp updated: 1.55 -> 1.56 --- Log message: - Change getelementptr instruction to use long indexes instead of uint indexes for sequential types. --- Diffs of the changes: Index: llvm/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp diff -u llvm/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp:1.23 llvm/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp:1.24 --- llvm/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp:1.23 Tue Sep 10 12:04:01 2002 +++ llvm/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp Tue Sep 10 20:21:33 2002 @@ -94,7 +94,7 @@ continue; } else { // Not the first index: include initial [0] to deref the last ptr - Indices.push_back(Constant::getNullValue(Type::UIntTy)); + Indices.push_back(Constant::getNullValue(Type::LongTy)); } Indices.push_back(*OI); @@ -110,7 +110,7 @@ // Get the final index vector, including an initial [0] as before. std::vector Indices; - Indices.push_back(Constant::getNullValue(Type::UIntTy)); + Indices.push_back(Constant::getNullValue(Type::LongTy)); Indices.push_back(*OI); Value *NewVal = new GetElementPtrInst(LastPtr, Indices, GEP.getName(), Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.55 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.56 --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.55 Tue Sep 10 18:04:09 2002 +++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Tue Sep 10 20:21:33 2002 @@ -649,7 +649,7 @@ // Is it 'getelementptr %P, uint 0' or 'getelementptr %P' // If so, eliminate the noop. if ((GEP.getNumOperands() == 2 && - GEP.getOperand(1) == Constant::getNullValue(Type::UIntTy)) || + GEP.getOperand(1) == Constant::getNullValue(Type::LongTy)) || GEP.getNumOperands() == 1) return ReplaceInstUsesWith(GEP, GEP.getOperand(0)); @@ -669,7 +669,7 @@ *cast(GEP.getOperand(1)); assert(Indices[0] != 0 && "Constant folding of uint's failed!?"); - } else if (*GEP.idx_begin() == ConstantUInt::get(Type::UIntTy, 0)) { + } else if (*GEP.idx_begin() == ConstantUInt::getNullValue(Type::LongTy)) { // Otherwise we can do the fold if the first index of the GEP is a zero Indices.insert(Indices.end(), Src->idx_begin(), Src->idx_end()); Indices.insert(Indices.end(), GEP.idx_begin()+1, GEP.idx_end()); From lattner at cs.uiuc.edu Tue Sep 10 20:22:05 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 10 20:22:05 2002 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp Message-ID: <200209110121.UAA13678@trinity.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Constants.cpp updated: 1.26 -> 1.27 --- Log message: Give better assertion message for error conditions --- Diffs of the changes: Index: llvm/lib/VMCore/Constants.cpp diff -u llvm/lib/VMCore/Constants.cpp:1.26 llvm/lib/VMCore/Constants.cpp:1.27 --- llvm/lib/VMCore/Constants.cpp:1.26 Mon Sep 2 20:08:13 2002 +++ llvm/lib/VMCore/Constants.cpp Tue Sep 10 20:21:04 2002 @@ -174,10 +174,14 @@ } ConstantSInt::ConstantSInt(const Type *Ty, int64_t V) : ConstantInt(Ty, V) { + assert(Ty->isInteger() && Ty->isSigned() && + "Illegal type for unsigned integer constant!"); assert(isValueValidForType(Ty, V) && "Value too large for type!"); } ConstantUInt::ConstantUInt(const Type *Ty, uint64_t V) : ConstantInt(Ty, V) { + assert(Ty->isInteger() && Ty->isUnsigned() && + "Illegal type for unsigned integer constant!"); assert(isValueValidForType(Ty, V) && "Value too large for type!"); } From lattner at cs.uiuc.edu Tue Sep 10 20:22:10 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 10 20:22:10 2002 Subject: [llvm-commits] CVS: llvm/tools/lli/Execution.cpp Message-ID: <200209110121.UAA13723@trinity.cs.uiuc.edu> Changes in directory llvm/tools/lli: Execution.cpp updated: 1.63 -> 1.64 --- Log message: - Change getelementptr instruction to use long indexes instead of uint indexes for sequential types. --- Diffs of the changes: Index: llvm/tools/lli/Execution.cpp diff -u llvm/tools/lli/Execution.cpp:1.63 llvm/tools/lli/Execution.cpp:1.64 --- llvm/tools/lli/Execution.cpp:1.63 Mon Sep 2 20:08:28 2002 +++ llvm/tools/lli/Execution.cpp Tue Sep 10 20:21:35 2002 @@ -822,7 +822,7 @@ } else if (const SequentialType *ST = cast(Ty)) { // Get the index number for the array... which must be uint type... - assert((*I)->getType() == Type::UIntTy); + assert((*I)->getType() == Type::LongTy); unsigned Idx = getOperandValue(*I, SF).UIntVal; if (const ArrayType *AT = dyn_cast(ST)) if (Idx >= AT->getNumElements() && ArrayChecksEnabled) { From lattner at cs.uiuc.edu Tue Sep 10 20:22:15 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 10 20:22:15 2002 Subject: [llvm-commits] CVS: llvm/lib/Transforms/ExprTypeConvert.cpp LevelRaise.cpp TransformInternals.cpp Message-ID: <200209110121.UAA13731@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Transforms: ExprTypeConvert.cpp updated: 1.56 -> 1.57 LevelRaise.cpp updated: 1.69 -> 1.70 TransformInternals.cpp updated: 1.28 -> 1.29 --- Log message: - Change getelementptr instruction to use long indexes instead of uint indexes for sequential types. --- Diffs of the changes: Index: llvm/lib/Transforms/ExprTypeConvert.cpp diff -u llvm/lib/Transforms/ExprTypeConvert.cpp:1.56 llvm/lib/Transforms/ExprTypeConvert.cpp:1.57 --- llvm/lib/Transforms/ExprTypeConvert.cpp:1.56 Tue Sep 10 17:52:51 2002 +++ llvm/lib/Transforms/ExprTypeConvert.cpp Tue Sep 10 20:21:23 2002 @@ -233,8 +233,8 @@ const Type *BaseType = GEP->getPointerOperand()->getType(); const Type *ElTy = 0; - while (!Indices.empty() && isa(Indices.back()) && - cast(Indices.back())->getValue() == 0) { + while (!Indices.empty() && + Indices.back() == Constant::getNullValue(Indices.back()->getType())){ Indices.pop_back(); ElTy = GetElementPtrInst::getIndexedType(BaseType, Indices, true); if (ElTy == PVTy) @@ -245,11 +245,11 @@ if (ElTy) break; // Found a number of zeros we can strip off! // Otherwise, we can convert a GEP from one form to the other iff the - // current gep is of the form 'getelementptr sbyte*, unsigned N + // current gep is of the form 'getelementptr sbyte*, long N // and we could convert this to an appropriate GEP for the new type. // if (GEP->getNumOperands() == 2 && - GEP->getOperand(1)->getType() == Type::UIntTy && + GEP->getOperand(1)->getType() == Type::LongTy && GEP->getType() == PointerType::get(Type::SByteTy)) { // Do not Check to see if our incoming pointer can be converted @@ -272,12 +272,12 @@ } // Otherwise, it could be that we have something like this: - // getelementptr [[sbyte] *] * %reg115, uint %reg138 ; [sbyte]** + // getelementptr [[sbyte] *] * %reg115, long %reg138 ; [sbyte]** // and want to convert it into something like this: - // getelemenptr [[int] *] * %reg115, uint %reg138 ; [int]** + // getelemenptr [[int] *] * %reg115, long %reg138 ; [int]** // if (GEP->getNumOperands() == 2 && - GEP->getOperand(1)->getType() == Type::UIntTy && + GEP->getOperand(1)->getType() == Type::LongTy && TD.getTypeSize(PTy->getElementType()) == TD.getTypeSize(GEP->getType()->getElementType())) { const PointerType *NewSrcTy = PointerType::get(PVTy); @@ -425,21 +425,20 @@ const Type *BaseType = GEP->getPointerOperand()->getType(); const Type *PVTy = cast(Ty)->getElementType(); Res = 0; - while (!Indices.empty() && isa(Indices.back()) && - cast(Indices.back())->getValue() == 0) { + while (!Indices.empty() && + Indices.back() == Constant::getNullValue(Indices.back()->getType())){ Indices.pop_back(); if (GetElementPtrInst::getIndexedType(BaseType, Indices, true) == PVTy) { - if (Indices.size() == 0) { - Res = new CastInst(GEP->getPointerOperand(), BaseType); // NOOP - } else { + if (Indices.size() == 0) + Res = new CastInst(GEP->getPointerOperand(), BaseType); // NOOP CAST + else Res = new GetElementPtrInst(GEP->getPointerOperand(), Indices, Name); - } break; } } if (Res == 0 && GEP->getNumOperands() == 2 && - GEP->getOperand(1)->getType() == Type::UIntTy && + GEP->getOperand(1)->getType() == Type::LongTy && GEP->getType() == PointerType::get(Type::SByteTy)) { // Otherwise, we can convert a GEP from one form to the other iff the @@ -749,7 +748,7 @@ // if (DataSize != 1) { TempScale = BinaryOperator::create(Instruction::Mul, Index, - ConstantUInt::get(Type::UIntTy, + ConstantSInt::get(Type::LongTy, DataSize)); Index = TempScale; } @@ -952,7 +951,7 @@ if (const CompositeType *CT = dyn_cast(LoadedTy)) { std::vector Indices; - Indices.push_back(ConstantUInt::get(Type::UIntTy, 0)); + Indices.push_back(ConstantSInt::get(Type::LongTy, 0)); unsigned Offset = 0; // No offset, get first leaf. LoadedTy = getStructOffsetType(CT, Offset, Indices, false); @@ -988,7 +987,7 @@ const StructType *SElTy = cast(ElTy); std::vector Indices; - Indices.push_back(ConstantUInt::get(Type::UIntTy, 0)); + Indices.push_back(Constant::getNullValue(Type::LongTy)); unsigned Offset = 0; const Type *Ty = getStructOffsetType(ElTy, Offset, Indices, false); @@ -1017,7 +1016,7 @@ if (isa(ValTy)) { std::vector Indices; - Indices.push_back(ConstantUInt::get(Type::UIntTy, 0)); + Indices.push_back(Constant::getNullValue(Type::LongTy)); unsigned Offset = 0; ValTy = getStructOffsetType(ValTy, Offset, Indices, false); @@ -1049,7 +1048,7 @@ if (DataSize != 1) { // Insert a multiply of the old element type is not a unit size... Index = BinaryOperator::create(Instruction::Mul, Index, - ConstantUInt::get(Type::UIntTy, DataSize), + ConstantSInt::get(Type::LongTy, DataSize), "scale", It); } Index: llvm/lib/Transforms/LevelRaise.cpp diff -u llvm/lib/Transforms/LevelRaise.cpp:1.69 llvm/lib/Transforms/LevelRaise.cpp:1.70 --- llvm/lib/Transforms/LevelRaise.cpp:1.69 Tue Sep 10 12:02:54 2002 +++ llvm/lib/Transforms/LevelRaise.cpp Tue Sep 10 20:21:23 2002 @@ -323,7 +323,7 @@ // Build the index vector, full of all zeros std::vector Indices; - Indices.push_back(ConstantUInt::get(Type::UIntTy, 0)); + Indices.push_back(ConstantSInt::get(Type::LongTy, 0)); while (CurCTy && !isa(CurCTy)) { if (const StructType *CurSTy = dyn_cast(CurCTy)) { // Check for a zero element struct type... if we have one, bail. @@ -338,7 +338,7 @@ } // Insert a zero to index through this type... - Indices.push_back(ConstantUInt::get(CurCTy->getIndexType(), 0)); + Indices.push_back(Constant::getNullValue(CurCTy->getIndexType())); // Did we find what we're looking for? if (ElTy->isLosslesslyConvertableTo(DestPointedTy)) break; Index: llvm/lib/Transforms/TransformInternals.cpp diff -u llvm/lib/Transforms/TransformInternals.cpp:1.28 llvm/lib/Transforms/TransformInternals.cpp:1.29 --- llvm/lib/Transforms/TransformInternals.cpp:1.28 Tue Sep 10 12:02:55 2002 +++ llvm/lib/Transforms/TransformInternals.cpp Tue Sep 10 20:21:23 2002 @@ -66,7 +66,7 @@ NextType = ATy->getElementType(); unsigned ChildSize = TD.getTypeSize(NextType); - Indices.push_back(ConstantUInt::get(Type::UIntTy, Offset/ChildSize)); + Indices.push_back(ConstantSInt::get(Type::LongTy, Offset/ChildSize)); ThisOffset = (Offset/ChildSize)*ChildSize; } else { Offset = 0; // Return the offset that we were able to acheive @@ -141,13 +141,13 @@ if (BI) { // Generate code? BasicBlock *BB = (*BI)->getParent(); - if (Expr.Var->getType() != Type::UIntTy) - Expr.Var = new CastInst(Expr.Var, Type::UIntTy, + if (Expr.Var->getType() != Type::LongTy) + Expr.Var = new CastInst(Expr.Var, Type::LongTy, Expr.Var->getName()+"-idxcast", *BI); if (ScaleAmt && ScaleAmt != 1) { // If we have to scale up our index, do so now - Value *ScaleAmtVal = ConstantUInt::get(Type::UIntTy, + Value *ScaleAmtVal = ConstantSInt::get(Type::LongTy, (unsigned)ScaleAmt); Expr.Var = BinaryOperator::create(Instruction::Mul, Expr.Var, ScaleAmtVal, @@ -155,7 +155,7 @@ } if (Index) { // Add an offset to the index - Value *IndexAmt = ConstantUInt::get(Type::UIntTy, (unsigned)Index); + Value *IndexAmt = ConstantSInt::get(Type::LongTy, (unsigned)Index); Expr.Var = BinaryOperator::create(Instruction::Add, Expr.Var, IndexAmt, Expr.Var->getName()+"-offset", @@ -168,14 +168,14 @@ } else if (Offset >= (int)ElSize || -Offset >= (int)ElSize) { // Calculate the index that we are entering into the array cell with unsigned Index = Offset/ElSize; - Indices.push_back(ConstantUInt::get(Type::UIntTy, Index)); + Indices.push_back(ConstantSInt::get(Type::LongTy, Index)); Offset -= (int)(Index*ElSize); // Consume part of the offset } else if (isa(CompTy) || Indices.empty()) { // Must be indexing a small amount into the first cell of the array // Just index into element zero of the array here. // - Indices.push_back(ConstantUInt::get(Type::UIntTy, 0)); + Indices.push_back(ConstantSInt::get(Type::LongTy, 0)); } else { return 0; // Hrm. wierd, can't handle this case. Bail } From lattner at cs.uiuc.edu Tue Sep 10 20:23:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 10 20:23:01 2002 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Instrumentation/TraceValues.cpp Message-ID: <200209110122.UAA13737@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Instrumentation: TraceValues.cpp updated: 1.47 -> 1.48 --- Log message: - Change getelementptr instruction to use long indexes instead of uint indexes for sequential types. --- Diffs of the changes: Index: llvm/lib/Transforms/Instrumentation/TraceValues.cpp diff -u llvm/lib/Transforms/Instrumentation/TraceValues.cpp:1.47 llvm/lib/Transforms/Instrumentation/TraceValues.cpp:1.48 --- llvm/lib/Transforms/Instrumentation/TraceValues.cpp:1.47 Tue Sep 10 12:03:03 2002 +++ llvm/lib/Transforms/Instrumentation/TraceValues.cpp Tue Sep 10 20:21:26 2002 @@ -226,7 +226,7 @@ // Turn the format string into an sbyte * Instruction *GEP = new GetElementPtrInst(fmtVal, - vector(2,ConstantUInt::get(Type::UIntTy, 0)), + vector(2,ConstantSInt::get(Type::LongTy, 0)), "trstr", InsertBefore); // Insert a call to the hash function if this is a pointer value From lattner at cs.uiuc.edu Tue Sep 10 20:23:06 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Sep 10 20:23:06 2002 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Instrumentation/ProfilePaths/EdgeCode.cpp Message-ID: <200209110122.UAA13743@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Instrumentation/ProfilePaths: EdgeCode.cpp updated: 1.13 -> 1.14 --- Log message: - Change getelementptr instruction to use long indexes instead of uint indexes for sequential types. --- Diffs of the changes: Index: llvm/lib/Transforms/Instrumentation/ProfilePaths/EdgeCode.cpp diff -u llvm/lib/Transforms/Instrumentation/ProfilePaths/EdgeCode.cpp:1.13 llvm/lib/Transforms/Instrumentation/ProfilePaths/EdgeCode.cpp:1.14 --- llvm/lib/Transforms/Instrumentation/ProfilePaths/EdgeCode.cpp:1.13 Tue Sep 10 12:03:06 2002 +++ llvm/lib/Transforms/Instrumentation/ProfilePaths/EdgeCode.cpp Tue Sep 10 20:21:29 2002 @@ -55,9 +55,9 @@ //M->getGlobalList().push_back(gbl); - vector elargs; - elargs.push_back(ConstantUInt::get(Type::UIntTy, 0)); - elargs.push_back(ConstantUInt::get(Type::UIntTy, 0)); + //vector elargs; + //elargs.push_back(ConstantSInt::get(Type::LongTy, 0)); + //elargs.push_back(ConstantSInt::get(Type::LongTy, 0)); // commented out bb name frm which its called //Instruction *getElmntInst=new GetElementPtrInst(gbl,elargs,"elmntInst"); @@ -119,7 +119,7 @@ assert(inc>=0 && inc<=numPaths && "inc out of bound!"); Instruction *Idx = new GetElementPtrInst(countInst, - vector(1,ConstantUInt::get(Type::UIntTy, inc)), + vector(1,ConstantSInt::get(Type::LongTy, inc)), "", InsertPos); Instruction *ldInst=new LoadInst(Idx, "ti1", InsertPos); @@ -154,7 +154,7 @@ //now load count[addIndex] Instruction *castInst=new CastInst(addIndex, - Type::UIntTy,"ctin", InsertPos); + Type::LongTy,"ctin", InsertPos); Instruction *Idx = new GetElementPtrInst(countInst, vector(1,castInst), "", InsertPos); @@ -184,7 +184,7 @@ Instruction *ldIndex=new LoadInst(rInst, "ti1", InsertPos); //now load count[addIndex] - Instruction *castInst2=new CastInst(ldIndex, Type::UIntTy,"ctin",InsertPos); + Instruction *castInst2=new CastInst(ldIndex, Type::LongTy,"ctin",InsertPos); Instruction *Idx = new GetElementPtrInst(countInst, vector(1,castInst2), "", InsertPos); @@ -236,10 +236,6 @@ Value *Int0 = ConstantInt::get(Type::IntTy, 0); - //store uint 0, uint *%R, uint 0 - vector idx; - idx.push_back(ConstantUInt::get(Type::UIntTy, 0)); - //now push all instructions in front of the BB BasicBlock::iterator here=front->begin(); front->getInstList().insert(here, rVar); @@ -249,13 +245,13 @@ for (int i=0;i(1,ConstantUInt::get(Type::UIntTy, i)), + vector(1,ConstantSInt::get(Type::LongTy, i)), "", here); new StoreInst(Int0, GEP2, here); } - Instruction *GEP = new GetElementPtrInst(rVar, idx, "", here); - new StoreInst(Int0, GEP, here); + //store uint 0, uint *%R + new StoreInst(Int0, rVar, here); } From jstanley at cs.uiuc.edu Wed Sep 11 15:52:01 2002 From: jstanley at cs.uiuc.edu (Joel Stanley) Date: Wed Sep 11 15:52:01 2002 Subject: [llvm-commits] CVS: llvm/www/docs/ProgrammersManual.html Message-ID: <200209112051.PAA24909@tank.cs.uiuc.edu> Changes in directory llvm/www/docs: ProgrammersManual.html updated: 1.19 -> 1.20 --- Log message: --- Diffs of the changes: Index: llvm/www/docs/ProgrammersManual.html diff -u llvm/www/docs/ProgrammersManual.html:1.19 llvm/www/docs/ProgrammersManual.html:1.20 --- llvm/www/docs/ProgrammersManual.html:1.19 Tue Sep 10 10:20:46 2002 +++ llvm/www/docs/ProgrammersManual.html Wed Sep 11 15:50:04 2002 @@ -543,6 +543,45 @@


    Iterating over def-use & use-def chains

      +Frequently, we might have an instance of the Value Class and we want to +determine which Users use the Value. The list of +all Users of a particular Value is called a +def-use chain. For example, let's say we have a +Function* named F to a particular function +foo. Finding all of the instructions that use +foo is as simple as iterating over the def-use chain of +F: + +
      +Function* F = ...;
      +
      +for(Value::use_iterator i = F->use_begin(), e = F->use_end(); i != e; ++i) {
      +    if(Instruction* i = dyn_cast<Instruction>(*i)) {
      +        cerr << "F is used in instruction:\n\t";
      +        cerr << *i << "\n";
      +    }
      +}
      +
      + +Alternately, it's common to have an instance of the User Class and need to know what +Values are used by it. The list of all Values used +by a User is known as a use-def chain. Instances of +class Instruction are common Users, so we might want +to iterate over all of the values that a particular instruction uses +(that is, the operands of the particular Instruction): + +
      +Instruction* pi = ...;
      +
      +for(User::op_iterator i = pi->op_begin(), e = pi->op_end(); i != e; ++i) {
      +    Value* v = i->get();
      +    ...
      +}
      +
      + + -Last modified: Tue Sep 10 10:19:56 CDT 2002 +Last modified: Wed Sep 11 15:48:49 CDT 2002 From jstanley at cs.uiuc.edu Wed Sep 11 17:33:01 2002 From: jstanley at cs.uiuc.edu (Joel Stanley) Date: Wed Sep 11 17:33:01 2002 Subject: [llvm-commits] CVS: llvm/www/docs/ProgrammersManual.html Message-ID: <200209112232.RAA00673@tank.cs.uiuc.edu> Changes in directory llvm/www/docs: ProgrammersManual.html updated: 1.20 -> 1.21 --- Log message: - Added content to use-def/def-use section - Added content to subsection "Creating and inserting new Instructions" --- Diffs of the changes: Index: llvm/www/docs/ProgrammersManual.html diff -u llvm/www/docs/ProgrammersManual.html:1.20 llvm/www/docs/ProgrammersManual.html:1.21 --- llvm/www/docs/ProgrammersManual.html:1.20 Wed Sep 11 15:50:04 2002 +++ llvm/www/docs/ProgrammersManual.html Wed Sep 11 17:32:24 2002 @@ -34,9 +34,12 @@
  • Making simple changes +


    Creating and inserting + new Instructions

      + +Instantiating Instructions + +

      Creation of Instructions is straightforward: simply call the +constructor for the kind of instruction to instantiate and provide the +necessary parameters. For example, an AllocaInst only +requires a (const-ptr-to) Type. Thus: + +

      AllocaInst* ai = new AllocaInst(Type::IntTy);
      + +will create an AllocaInst instance that represents the +allocation of one integer in the current stack frame, at runtime. +Each Instruction subclass is likely to have varying default +parameters which change the semantics of the instruction, so refer to +the
      doxygen documentation for +the subclass of Instruction that you're interested in +instantiating.

      + +

      Naming values

      + +

      +It is very useful to name the values of instructions when you're able +to, as this facilitates the debugging of your transformations. If you +end up looking at generated LLVM machine code, you definitely want to +have logical names associated with the results of instructions! By +supplying a value for the Name (default) parameter of the +Instruction constructor, you associate a logical name with +the result of the instruction's execution at runtime. For example, +say that I'm writing a transformation that dynamically allocates space +for an integer on the stack, and that integer is going to be used as +some kind of index by some other code. To accomplish this, I place an +AllocaInst at the first point in the first +BasicBlock of some Function, and I'm intending to +use it within the same Function. I might do: + +

      AllocaInst* pa = new AllocaInst(Type::IntTy, 0, "indexLoc");
      + +where indexLoc is now the logical name of the instruction's +execution value, which is a pointer to an integer on the runtime +stack. +

      + +

      Inserting instructions

      + +

      +There are essentially two ways to insert an Instruction into +an existing sequence of instructions that form a BasicBlock: +

        +
      • Insertion into an explicit instruction list + +

        Given a BasicBlock* pb, an Instruction* pi within +that BasicBlock, and a newly-created instruction +we wish to insert before *pi, we do the following: + +

        +BasicBlock* pb = ...;
        +Instruction* pi = ...;
        +Instruction* newInst = new Instruction(...);
        +pb->getInstList().insert(pi, newInst); // inserts newInst before pi in pb
        +
        +

        + +
      • Insertion into an implicit instruction list +

        +Instruction instances that are already in +BasicBlocks are implicitly associated with an existing +instruction list: the instruction list of the enclosing basic block. +Thus, we could have accomplished the same thing as the above code +without being given a BasicBlock by doing: +

        +Instruction* pi = ...;
        +Instruction* newInst = new Instruction(...);
        +pi->getParent()->getInstList().insert(pi, newInst);
        +
        +In fact, this sequence of steps occurs so frequently that the +Instruction class and Instruction-derived classes +provide constructors which take (as a default parameter) a pointer to +an Instruction which the newly-created Instruction +should precede. That is, Instruction constructors are +capable of inserting the newly-created instance into the +BasicBlock of a provided instruction, immediately before that +instruction. Using an Instruction constructor with a +insertBefore (default) parameter, the above code becomes: +
        +Instruction* pi = ...;
        +Instruction* newInst = new Instruction(..., pi);
        +
        +which is much cleaner, especially if you're creating a lot of +instructions and adding them to BasicBlocks. +

        +

        + + + +


      Deleting + Instructions


      Replacing an + Instruction with another Value

      @@ -1428,6 +1540,6 @@ Chris Lattner -Last modified: Wed Sep 11 15:48:49 CDT 2002 +Last modified: Wed Sep 11 17:31:03 CDT 2002 From brukman at cs.uiuc.edu Wed Sep 11 17:40:00 2002 From: brukman at cs.uiuc.edu (Michael Brukman) Date: Wed Sep 11 17:40:00 2002 Subject: [llvm-commits] CVS: llvm/lib/Reoptimizer/Mapping/getLLVMinfo.cpp Message-ID: <200209112239.RAA21749@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Reoptimizer/Mapping: getLLVMinfo.cpp updated: 1.5 -> 1.6 --- Log message: Someone switched from using unsigned int to uint64_t but forgot to include Support/DataTypes.h, preventing compilation. (Or just forgot to check it in). --- Diffs of the changes: Index: llvm/lib/Reoptimizer/Mapping/getLLVMinfo.cpp diff -u llvm/lib/Reoptimizer/Mapping/getLLVMinfo.cpp:1.5 llvm/lib/Reoptimizer/Mapping/getLLVMinfo.cpp:1.6 --- llvm/lib/Reoptimizer/Mapping/getLLVMinfo.cpp:1.5 Sun Sep 8 15:26:15 2002 +++ llvm/lib/Reoptimizer/Mapping/getLLVMinfo.cpp Wed Sep 11 17:39:55 2002 @@ -13,6 +13,7 @@ #include "llvm/Module.h" #include "llvm/Function.h" #include "llvm/Instruction.h" +#include "Support/DataTypes.h" #include #include #include From brukman at cs.uiuc.edu Wed Sep 11 17:41:01 2002 From: brukman at cs.uiuc.edu (Michael Brukman) Date: Wed Sep 11 17:41:01 2002 Subject: [llvm-commits] CVS: llvm/include/llvm/Reoptimizer/Mapping/LLVMinfo.h Message-ID: <200209112240.RAA21756@trinity.cs.uiuc.edu> Changes in directory llvm/include/llvm/Reoptimizer/Mapping: LLVMinfo.h updated: 1.3 -> 1.4 --- Log message: Someone switched from using unsigned int to uint64_t but forgot to include Support/DataTypes.h, preventing compilation. (Or just forgot to check it in). --- Diffs of the changes: Index: llvm/include/llvm/Reoptimizer/Mapping/LLVMinfo.h diff -u llvm/include/llvm/Reoptimizer/Mapping/LLVMinfo.h:1.3 llvm/include/llvm/Reoptimizer/Mapping/LLVMinfo.h:1.4 --- llvm/include/llvm/Reoptimizer/Mapping/LLVMinfo.h:1.3 Sun Sep 8 15:32:11 2002 +++ llvm/include/llvm/Reoptimizer/Mapping/LLVMinfo.h Wed Sep 11 17:39:41 2002 @@ -1,4 +1,5 @@ #include "llvm/Instruction.h" +#include "Support/DataTypes.h" #include using std::vector; From sabre at nondot.org Wed Sep 11 17:50:01 2002 From: sabre at nondot.org (Chris Lattner) Date: Wed Sep 11 17:50:01 2002 Subject: [llvm-commits] CVS: llvm/lib/Reoptimizer/Mapping/getLLVMinfo.cpp In-Reply-To: <200209112239.RAA21749@trinity.cs.uiuc.edu> Message-ID: > Someone switched from using unsigned int to uint64_t but forgot to include > Support/DataTypes.h, preventing compilation. (Or just forgot to check it in). > #include "llvm/Module.h" > #include "llvm/Function.h" > #include "llvm/Instruction.h" > +#include "Support/DataTypes.h" > #include > #include > #include A comment (and I know that this has nothing to do with YOUR checkin): Most of these #includes are redundant. You can probably get away with just: #include "llvm/Module.h" #include "Support/DataTypes.h" #include Because Module includes Function, Function.h includes BasicBlock.h, BasicBlock.h includes Instruction.h etc. If you could, please prune these #includes if you get a chance... -Chris http://llvm.cs.uiuc.edu/ http://www.nondot.org/~sabre/Projects/ From brukman at cs.uiuc.edu Wed Sep 11 17:58:00 2002 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Wed Sep 11 17:58:00 2002 Subject: [llvm-commits] CVS: llvm/lib/Reoptimizer/Mapping/getLLVMinfo.cpp In-Reply-To: Message-ID: On Wed, 11 Sep 2002, Chris Lattner wrote: > A comment (and I know that this has nothing to do with YOUR checkin): Most > of these #includes are redundant. You can probably get away with just: > > #include "llvm/Module.h" > #include "Support/DataTypes.h" > #include > > Because Module includes Function, Function.h includes BasicBlock.h, > BasicBlock.h includes Instruction.h etc. > > If you could, please prune these #includes if you get a chance... Would it make sense to do this on a larger scale? There are a couple files that include both Module and Function, for instance. On the other hand, each file lists what it uses, and if anytime something is refactored, it'll lead to a lot of broken code (correct me if I'm wrong). -m From sabre at nondot.org Wed Sep 11 18:24:00 2002 From: sabre at nondot.org (Chris Lattner) Date: Wed Sep 11 18:24:00 2002 Subject: [llvm-commits] CVS: llvm/lib/Reoptimizer/Mapping/getLLVMinfo.cpp In-Reply-To: Message-ID: > > If you could, please prune these #includes if you get a chance... > > Would it make sense to do this on a larger scale? There are a couple files > that include both Module and Function, for instance. Yes, please. Including lots of .h files is a very bad idea for lots of reasons (slows down compilation, adds false dependencies, etc) for C++ files, but especially for .h files. > On the other hand, each file lists what it uses, and if anytime something > is refactored, it'll lead to a lot of broken code (correct me if I'm > wrong). That's true, but when refactoring code, it's good to be aware of what .h files are needed or not anyway, so there it usually isn't an issue. If you make sure to compile the code before checking it in, the compiler will tell you if you are missing a .h file. Unfortunately it won't tell you if you have an extraneous one. This is a low priority activity, but if you notice lots of #includes in .cpp files, pruning them is always useful. Pruning unneccesary #includes from .h files is VERY important though. :) -Chris http://llvm.cs.uiuc.edu/ http://www.nondot.org/~sabre/Projects/ From brukman at cs.uiuc.edu Thu Sep 12 11:06:01 2002 From: brukman at cs.uiuc.edu (Michael Brukman) Date: Thu Sep 12 11:06:01 2002 Subject: [llvm-commits] CVS: llvm/Makefile.common Message-ID: <200209121605.LAA28634@trinity.cs.uiuc.edu> Changes in directory llvm: Makefile.common updated: 1.42 -> 1.43 --- Log message: Compiling with "gmake" should produce less output. The compilation/linking flags are always the same anyway, who wants to see so much text on the screen? Compiling with "gmake VERBOSE=1" should produce all the output you're used to. Basically it checks for VERBOSE being defined, and if it is, sets VERB appropriately. VERB is then prepended in a bunch of key places such that when VERB is "@", the command is not echoed, when VERB is not set to anything, it's as before. One thing I could not get rid of is "gmake[1]: Entering directory ", but running "gmake -s" suppresses it all, and shows just the interesting stuff. Now output (when running "gmake -s" will look something like): ======= Linking target debug library ======= Compiling Writer.cpp Compiling getLLVMinfo.cpp Compiling as.cpp Compiling dis.cpp Compiling opt.cpp Compiling gccas.cpp --- Diffs of the changes: Index: llvm/Makefile.common diff -u llvm/Makefile.common:1.42 llvm/Makefile.common:1.43 --- llvm/Makefile.common:1.42 Thu Aug 29 18:28:46 2002 +++ llvm/Makefile.common Thu Sep 12 11:05:39 2002 @@ -97,6 +97,13 @@ TOOLDEBUG := $(BUILD_ROOT_TOP)/tools/Debug TOOLRELEASE := $(BUILD_ROOT_TOP)/tools/Release +# Verbosity levels +ifdef VERBOSE +VERB := +else +VERB := @ +endif + #--------------------------------------------------------- # Compilation options... #--------------------------------------------------------- @@ -167,7 +174,7 @@ clean :: $(addsuffix /.makeclean , $(DIRS)) %/.makeall %/.makeclean %/.makeinstall: - cd $(@D); $(MAKE) $(subst $(@D)/.make,,$@) + $(VERB) cd $(@D); $(MAKE) $(subst $(@D)/.make,,$@) endif #--------------------------------------------------------- @@ -224,27 +231,28 @@ $(LIBNAME_O): $(ObjectsO) $(LibSubDirs) $(LIBRELEASE)/.dir @echo ======= Linking $(LIBRARYNAME) release library ======= - $(MakeSOO) -o $@ $(ObjectsO) $(LibSubDirs) $(LibLinkOpts) + $(VERB) $(MakeSOO) -o $@ $(ObjectsO) $(LibSubDirs) $(LibLinkOpts) $(LIBNAME_G): $(ObjectsG) $(LibSubDirs) $(LIBDEBUG)/.dir @echo ======= Linking $(LIBRARYNAME) debug library ======= - $(MakeSO) -g -o $@ $(ObjectsG) $(LibSubDirs) $(LibLinkOpts) + $(VERB) $(MakeSO) -g -o $@ $(ObjectsG) $(LibSubDirs) $(LibLinkOpts) $(LIBNAME_AO): $(ObjectsO) $(LibSubDirs) $(LIBRELEASE)/.dir @echo ======= Linking $(LIBRARYNAME) release library ======= @rm -f $@ - $(AR) $@ $(ObjectsO) $(LibSubDirs) + $(VERB) $(AR) $@ $(ObjectsO) $(LibSubDirs) $(LIBNAME_AG): $(ObjectsG) $(LibSubDirs) $(LIBDEBUG)/.dir @echo ======= Linking $(LIBRARYNAME) debug library ======= @rm -f $@ - $(AR) $@ $(ObjectsG) $(LibSubDirs) + $(VERB) $(AR) $@ $(ObjectsG) $(LibSubDirs) $(LIBNAME_OBJO): $(ObjectsO) $(LibSubDirs) $(LIBRELEASE)/.dir - $(Relink) -o $@ $(ObjectsO) $(LibSubDirs) + @echo "Linking $@" + $(VERB) $(Relink) -o $@ $(ObjectsO) $(LibSubDirs) $(LIBNAME_OBJG): $(ObjectsG) $(LibSubDirs) $(LIBDEBUG)/.dir - $(Relink) -o $@ $(ObjectsG) $(LibSubDirs) + $(VERB) $(Relink) -o $@ $(ObjectsG) $(LibSubDirs) endif @@ -293,13 +301,13 @@ all:: $(TOOLEXENAMES) clean:: - rm -f $(TOOLEXENAMES) + $(VERB) rm -f $(TOOLEXENAMES) $(TOOLEXENAME_G): $(ObjectsG) $(USED_LIB_PATHS_G) $(BUILD_ROOT_TOP)/tools/Debug/.dir - $(LinkG) -o $@ $(ObjectsG) $(USED_LIBS_OPTIONS_G) $(TOOLLINKOPTS) + $(VERB) $(LinkG) -o $@ $(ObjectsG) $(USED_LIBS_OPTIONS_G) $(TOOLLINKOPTS) $(TOOLEXENAME_O): $(ObjectsO) $(USED_LIB_PATHS_O) $(BUILD_ROOT_TOP)/tools/Release/.dir - $(LinkO) -o $@ $(ObjectsG) $(USED_LIBS_OPTIONS_O) $(TOOLLINKOPTS) + $(VERB) $(LinkO) -o $@ $(ObjectsG) $(USED_LIBS_OPTIONS_O) $(TOOLLINKOPTS) endif @@ -311,21 +319,23 @@ # Create dependencies for the *.cpp files... $(BUILD_ROOT)/Depend/%.d: %.cpp $(BUILD_ROOT)/Depend/.dir - $(Depend) $< | sed 's|$*\.o *|$(BUILD_ROOT)/Release/& $(BUILD_ROOT)/Debug/& $(BUILD_ROOT)/Depend/$(@F)|g' > $@ + $(VERB) $(Depend) $< | sed 's|$*\.o *|$(BUILD_ROOT)/Release/& $(BUILD_ROOT)/Debug/& $(BUILD_ROOT)/Depend/$(@F)|g' > $@ # Create dependencies for the *.c files... $(BUILD_ROOT)/Depend/%.d: %.c $(BUILD_ROOT)/Depend/.dir - $(Depend) $< | sed 's|$*\.o *|Release/& Debug/& Depend/$(@F)|g' > $@ + $(VERB) $(Depend) $< | sed 's|$*\.o *|Release/& Debug/& Depend/$(@F)|g' > $@ # Create .o files in the ObjectFiles directory from the .cpp and .c files... $(BUILD_ROOT)/Release/%.o: %.cpp $(BUILD_ROOT)/Release/.dir - $(CompileO) $< -o $@ + @echo "Compiling $<" + $(VERB) $(CompileO) $< -o $@ #Release/%.o: %.c Release/.dir Depend/.dir # $(CompileOC) $< -o $@ $(BUILD_ROOT)/Debug/%.o: %.cpp $(BUILD_ROOT)/Debug/.dir - $(CompileG) $< -o $@ + @echo "Compiling $<" + $(VERB) $(CompileG) $< -o $@ #Debug/%.o: %.c Debug/.dir # $(CompileGC) $< -o $@ @@ -338,19 +348,19 @@ # Rule for building the bison parsers... %.cpp %.h : %.y - bison -v -d -p $(<:%Parser.y=%) $(basename $@).y - mv -f $(basename $@).tab.c $(basename $@).cpp - mv -f $(basename $@).tab.h $(basename $@).h + $(VERB) bison -v -d -p $(<:%Parser.y=%) $(basename $@).y + $(VERB) mv -f $(basename $@).tab.c $(basename $@).cpp + $(VERB) mv -f $(basename $@).tab.h $(basename $@).h # To create the directories... %/.dir: - mkdir -p $(@D) + $(VERB) mkdir -p $(@D) @date > $@ # Clean nukes the tree clean:: - rm -rf $(BUILD_ROOT)/Debug $(BUILD_ROOT)/Release $(BUILD_ROOT)/Depend - rm -f core *.o *.d *.so *~ *.flc + $(VERB) rm -rf $(BUILD_ROOT)/Debug $(BUILD_ROOT)/Release $(BUILD_ROOT)/Depend + $(VERB) rm -f core *.o *.d *.so *~ *.flc # If dependancies were generated for the file that included this file, # include the dependancies now... From lattner at cs.uiuc.edu Thu Sep 12 12:03:00 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Sep 12 12:03:00 2002 Subject: [llvm-commits] CVS: llvm/Makefile.common Message-ID: <200209121702.MAA00499@trinity.cs.uiuc.edu> Changes in directory llvm: Makefile.common updated: 1.43 -> 1.44 --- Log message: Make sure to print a message when linking a tool --- Diffs of the changes: Index: llvm/Makefile.common diff -u llvm/Makefile.common:1.43 llvm/Makefile.common:1.44 --- llvm/Makefile.common:1.43 Thu Sep 12 11:05:39 2002 +++ llvm/Makefile.common Thu Sep 12 12:02:40 2002 @@ -304,9 +304,11 @@ $(VERB) rm -f $(TOOLEXENAMES) $(TOOLEXENAME_G): $(ObjectsG) $(USED_LIB_PATHS_G) $(BUILD_ROOT_TOP)/tools/Debug/.dir + @echo ======= Linking $(TOOLNAME) debug executable ======= $(VERB) $(LinkG) -o $@ $(ObjectsG) $(USED_LIBS_OPTIONS_G) $(TOOLLINKOPTS) $(TOOLEXENAME_O): $(ObjectsO) $(USED_LIB_PATHS_O) $(BUILD_ROOT_TOP)/tools/Release/.dir + @echo ======= Linking $(TOOLNAME) release executable ======= $(VERB) $(LinkO) -o $@ $(ObjectsG) $(USED_LIBS_OPTIONS_O) $(TOOLLINKOPTS) endif From lattner at cs.uiuc.edu Thu Sep 12 12:07:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Sep 12 12:07:01 2002 Subject: [llvm-commits] CVS: llvm/www/docs/WritingAnLLVMPass.html Message-ID: <200209121706.MAA00617@trinity.cs.uiuc.edu> Changes in directory llvm/www/docs: WritingAnLLVMPass.html updated: 1.7 -> 1.8 --- Log message: Add a new BasicBlockPass::doInitialization/Finalization(Function &) pair of methods that may be useful for BasicBlockPasses. --- Diffs of the changes: Index: llvm/www/docs/WritingAnLLVMPass.html diff -u llvm/www/docs/WritingAnLLVMPass.html:1.7 llvm/www/docs/WritingAnLLVMPass.html:1.8 --- llvm/www/docs/WritingAnLLVMPass.html:1.7 Sun Sep 8 22:48:46 2002 +++ llvm/www/docs/WritingAnLLVMPass.html Thu Sep 12 12:06:43 2002 @@ -25,13 +25,19 @@
    • The FunctionPass class
    • The BasicBlockPass class
    • Pass Registration @@ -424,8 +430,8 @@ should return true if they modified the program, or false if they didn't.

      -


      The doInitialization -method


      The +doInitialization(Module &) method


      The doFinalization method


      The doFinalization(Module &) method


      The +doInitialization(Function &) method


      The runOnBasicBlock method


      The doFinalization(Function +&) method

      @@ -1164,6 +1203,6 @@
      Chris Lattner
      -Last modified: Thu Sep 5 15:06:01 CDT 2002 +Last modified: Thu Sep 12 11:46:40 CDT 2002
      From lattner at cs.uiuc.edu Thu Sep 12 12:08:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Sep 12 12:08:01 2002 Subject: [llvm-commits] CVS: llvm/include/llvm/Pass.h Message-ID: <200209121707.MAA00624@trinity.cs.uiuc.edu> Changes in directory llvm/include/llvm: Pass.h updated: 1.26 -> 1.27 --- Log message: Add a new BasicBlockPass::doInitialization/Finalization(Function &) pair of methods that may be useful for BasicBlockPasses. --- Diffs of the changes: Index: llvm/include/llvm/Pass.h diff -u llvm/include/llvm/Pass.h:1.26 llvm/include/llvm/Pass.h:1.27 --- llvm/include/llvm/Pass.h:1.26 Thu Sep 5 21:14:47 2002 +++ llvm/include/llvm/Pass.h Thu Sep 12 12:06:38 2002 @@ -250,15 +250,36 @@ /// 3. Optimizations conform to all of the contstraints of FunctionPass's. /// struct BasicBlockPass : public FunctionPass { + /// doInitialization - Virtual method overridden by subclasses to do + /// any neccesary per-module initialization. + /// + virtual bool doInitialization(Module &M) { return false; } + + /// doInitialization - Virtual method overridden by BasicBlockPass subclasses + /// to do any neccesary per-function initialization. + /// + virtual bool doInitialization(Function &F) { return false; } + /// runOnBasicBlock - Virtual method overriden by subclasses to do the /// per-basicblock processing of the pass. /// virtual bool runOnBasicBlock(BasicBlock &BB) = 0; - /// To run this pass on a function, we simply call runOnBasicBlock once for - /// each function. + /// doFinalization - Virtual method overriden by BasicBlockPass subclasses to + /// do any post processing needed after all passes have run. /// - virtual bool runOnFunction(Function &F); + virtual bool doFinalization(Function &F) { return false; } + + /// doFinalization - Virtual method overriden by subclasses to do any post + /// processing needed after all passes have run. + /// + virtual bool doFinalization(Module &M) { return false; } + + + // To run this pass on a function, we simply call runOnBasicBlock once for + // each function. + // + bool runOnFunction(Function &F); /// To run directly on the basic block, we initialize, runOnBasicBlock, then /// finalize. From lattner at cs.uiuc.edu Thu Sep 12 12:08:07 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Sep 12 12:08:07 2002 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Pass.cpp PassManagerT.h Message-ID: <200209121707.MAA00655@trinity.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Pass.cpp updated: 1.35 -> 1.36 PassManagerT.h updated: 1.26 -> 1.27 --- Log message: Add a new BasicBlockPass::doInitialization/Finalization(Function &) pair of methods that may be useful for BasicBlockPasses. --- Diffs of the changes: Index: llvm/lib/VMCore/Pass.cpp diff -u llvm/lib/VMCore/Pass.cpp:1.35 llvm/lib/VMCore/Pass.cpp:1.36 --- llvm/lib/VMCore/Pass.cpp:1.35 Fri Aug 30 15:23:45 2002 +++ llvm/lib/VMCore/Pass.cpp Thu Sep 12 12:06:40 2002 @@ -341,18 +341,20 @@ // function. // bool BasicBlockPass::runOnFunction(Function &F) { - bool Changed = false; + bool Changed = doInitialization(F); for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I) Changed |= runOnBasicBlock(*I); - return Changed; + return Changed | doFinalization(F); } // To run directly on the basic block, we initialize, runOnBasicBlock, then // finalize. // bool BasicBlockPass::run(BasicBlock &BB) { - Module &M = *BB.getParent()->getParent(); - return doInitialization(M) | runOnBasicBlock(BB) | doFinalization(M); + Function &F = *BB.getParent(); + Module &M = *F.getParent(); + return doInitialization(M) | doInitialization(F) | runOnBasicBlock(BB) | + doFinalization(F) | doFinalization(M); } void BasicBlockPass::addToPassManager(PassManagerT *PM, Index: llvm/lib/VMCore/PassManagerT.h diff -u llvm/lib/VMCore/PassManagerT.h:1.26 llvm/lib/VMCore/PassManagerT.h:1.27 --- llvm/lib/VMCore/PassManagerT.h:1.26 Sun Sep 8 14:00:07 2002 +++ llvm/lib/VMCore/PassManagerT.h Thu Sep 12 12:06:40 2002 @@ -525,7 +525,9 @@ // Implement the BasicBlockPass interface... virtual bool doInitialization(Module &M); + virtual bool doInitialization(Function &F); virtual bool runOnBasicBlock(BasicBlock &BB); + virtual bool doFinalization(Function &F); virtual bool doFinalization(Module &M); virtual void getAnalysisUsage(AnalysisUsage &AU) const { @@ -657,8 +659,22 @@ return Changed; } +inline bool PassManagerTraits::doInitialization(Function &F) { + bool Changed = false; + for (unsigned i = 0, e = ((PMType*)this)->Passes.size(); i != e; ++i) + ((PMType*)this)->Passes[i]->doInitialization(F); + return Changed; +} + inline bool PassManagerTraits::runOnBasicBlock(BasicBlock &BB) { return ((PMType*)this)->runOnUnit(&BB); +} + +inline bool PassManagerTraits::doFinalization(Function &F) { + bool Changed = false; + for (unsigned i = 0, e = ((PMType*)this)->Passes.size(); i != e; ++i) + ((PMType*)this)->Passes[i]->doFinalization(F); + return Changed; } inline bool PassManagerTraits::doFinalization(Module &M) { From lattner at cs.uiuc.edu Thu Sep 12 12:19:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Sep 12 12:19:01 2002 Subject: [llvm-commits] CVS: llvm/www/docs/ProgrammersManual.html Message-ID: <200209121718.MAA07534@tank.cs.uiuc.edu> Changes in directory llvm/www/docs: ProgrammersManual.html updated: 1.21 -> 1.22 --- Log message: Add some information about the Instruction class and Instruction.def --- Diffs of the changes: Index: llvm/www/docs/ProgrammersManual.html diff -u llvm/www/docs/ProgrammersManual.html:1.21 llvm/www/docs/ProgrammersManual.html:1.22 --- llvm/www/docs/ProgrammersManual.html:1.21 Wed Sep 11 17:32:24 2002 +++ llvm/www/docs/ProgrammersManual.html Thu Sep 12 12:18:46 2002 @@ -901,6 +901,17 @@ getOperand()/getNumOperands() and op_begin()/op_end() methods).

      +An important file for the Instruction class is the +llvm/Instruction.def file. This file contains some meta-data about the +various different types of instructions in LLVM. It describes the enum values +that are used as opcodes (for example Instruction::Add and +Instruction::SetLE), as well as the concrete sub-classes of +Instruction that implement the instruction (for example BinaryOperator and SetCondInst). Unfortunately, the use of macros in +this file confused doxygen, so these enum values don't show up correctly in the +doxygen output.

      +


      Important Public Members of @@ -920,6 +931,14 @@ Returns the opcode for the Instruction.

      +

    • Instruction *clone() const

      + +Returns another instance of the specified instruction, identical in all ways to +the original except that the instruction has no parent (ie it's not embedded +into a BasicBlock), and it has no name.

      + + + -Last modified: Wed Sep 11 17:31:03 CDT 2002 +Last modified: Thu Sep 12 12:18:04 CDT 2002 From lattner at cs.uiuc.edu Thu Sep 12 14:01:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Sep 12 14:01:01 2002 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp Message-ID: <200209121900.OAA02645@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Utils: UnifyFunctionExitNodes.cpp updated: 1.21 -> 1.22 --- Log message: Fix bug I introduced with one of my previous changes. Thanks fly out to Nick for noticing it! :) --- Diffs of the changes: Index: llvm/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp diff -u llvm/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp:1.21 llvm/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp:1.22 --- llvm/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp:1.21 Tue Sep 10 18:31:28 2002 +++ llvm/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp Thu Sep 12 14:00:43 2002 @@ -62,7 +62,7 @@ NewRetBlock->getInstList().push_back(new ReturnInst(PN)); } else { // If it returns void, just add a return void instruction to the block - new ReturnInst(0, NewRetBlock->end()); + NewRetBlock->getInstList().push_back(new ReturnInst()); } // Loop over all of the blocks, replacing the return instruction with an From lattner at cs.uiuc.edu Thu Sep 12 14:07:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Sep 12 14:07:01 2002 Subject: [llvm-commits] CVS: llvm/www/docs/ProgrammersManual.html Message-ID: <200209121906.OAA02712@trinity.cs.uiuc.edu> Changes in directory llvm/www/docs: ProgrammersManual.html updated: 1.22 -> 1.23 --- Log message: Incorporate information about deleting instructions from a basic block, contributed by Tanya. --- Diffs of the changes: Index: llvm/www/docs/ProgrammersManual.html diff -u llvm/www/docs/ProgrammersManual.html:1.22 llvm/www/docs/ProgrammersManual.html:1.23 --- llvm/www/docs/ProgrammersManual.html:1.22 Thu Sep 12 12:18:46 2002 +++ llvm/www/docs/ProgrammersManual.html Thu Sep 12 14:06:51 2002 @@ -620,7 +620,7 @@ allocation of one integer in the current stack frame, at runtime. Each Instruction subclass is likely to have varying default parameters which change the semantics of the instruction, so refer to -the doxygen documentation for +the doxygen documentation for the subclass of Instruction that you're interested in instantiating.

      @@ -701,7 +701,23 @@


      Deleting - Instructions


    • Replacing an @@ -1559,6 +1575,6 @@
      Chris Lattner -Last modified: Thu Sep 12 12:18:04 CDT 2002 +Last modified: Thu Sep 12 14:06:40 CDT 2002 From lattner at cs.uiuc.edu Thu Sep 12 14:09:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Sep 12 14:09:01 2002 Subject: [llvm-commits] CVS: llvm/www/docs/ProgrammersManual.html Message-ID: <200209121908.OAA11088@tank.cs.uiuc.edu> Changes in directory llvm/www/docs: ProgrammersManual.html updated: 1.23 -> 1.24 --- Log message: Add a that was missing and caused the document to get a little whacky --- Diffs of the changes: Index: llvm/www/docs/ProgrammersManual.html diff -u llvm/www/docs/ProgrammersManual.html:1.23 llvm/www/docs/ProgrammersManual.html:1.24 --- llvm/www/docs/ProgrammersManual.html:1.23 Thu Sep 12 14:06:51 2002 +++ llvm/www/docs/ProgrammersManual.html Thu Sep 12 14:08:16 2002 @@ -697,7 +697,7 @@ instructions and adding them to BasicBlocks.

      - +


      Deleting @@ -1575,6 +1575,6 @@
      Chris Lattner -Last modified: Thu Sep 12 14:06:40 CDT 2002 +Last modified: Thu Sep 12 14:07:53 CDT 2002 From lattner at cs.uiuc.edu Thu Sep 12 15:28:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Sep 12 15:28:01 2002 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp Message-ID: <200209122027.PAA05077@trinity.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/InstrSelection: InstrSelectionSupport.cpp updated: 1.29 -> 1.30 --- Log message: Fix a bug I introduced into the code generator. :( --- Diffs of the changes: Index: llvm/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp diff -u llvm/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp:1.29 llvm/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp:1.30 --- llvm/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp:1.29 Tue Sep 10 20:20:03 2002 +++ llvm/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp Thu Sep 12 15:27:10 2002 @@ -114,7 +114,7 @@ { InstructionNode* gepNode = dyn_cast(ptrNode); GetElementPtrInst* gepInst = - dyn_cast_or_null(gepNode->getInstruction()); + dyn_cast_or_null(gepNode ? gepNode->getInstruction() :0); // ptr value is not computed in this tree or ptr value does not come from GEP // instruction From lattner at cs.uiuc.edu Thu Sep 12 15:35:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Sep 12 15:35:01 2002 Subject: [llvm-commits] CVS: llvm/lib/CWriter/Writer.cpp Message-ID: <200209122034.PAA06048@trinity.cs.uiuc.edu> Changes in directory llvm/lib/CWriter: Writer.cpp updated: 1.41 -> 1.42 --- Log message: Fix a bug introduced by the Getelementptr change --- Diffs of the changes: Index: llvm/lib/CWriter/Writer.cpp diff -u llvm/lib/CWriter/Writer.cpp:1.41 llvm/lib/CWriter/Writer.cpp:1.42 --- llvm/lib/CWriter/Writer.cpp:1.41 Tue Sep 10 20:18:27 2002 +++ llvm/lib/CWriter/Writer.cpp Thu Sep 12 15:34:47 2002 @@ -925,7 +925,7 @@ printType(cast(Ptr->getType())->getElementType()); Out << ")]"; } else { - Out << ".field" << cast(*I)->getValue(); + Out << ".field" << cast(*I)->getValue(); } } From lattner at cs.uiuc.edu Fri Sep 13 08:51:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Sep 13 08:51:01 2002 Subject: [llvm-commits] CVS: llvm/test/Programs/MultiSource/Makefile.multisrc Message-ID: <200209131350.IAA11078@trinity.cs.uiuc.edu> Changes in directory llvm/test/Programs/MultiSource: Makefile.multisrc updated: 1.14 -> 1.15 --- Log message: Build multiple source programs by simply compiling them, assembling them with the "dumb" assembler, linking the raw bytecode, then running the bytecode through gccas. This allows us to do timings and get performance data for gccas on the entire multisource program. --- Diffs of the changes: Index: llvm/test/Programs/MultiSource/Makefile.multisrc diff -u llvm/test/Programs/MultiSource/Makefile.multisrc:1.14 llvm/test/Programs/MultiSource/Makefile.multisrc:1.15 --- llvm/test/Programs/MultiSource/Makefile.multisrc:1.14 Wed Aug 21 18:52:36 2002 +++ llvm/test/Programs/MultiSource/Makefile.multisrc Fri Sep 13 08:50:48 2002 @@ -24,23 +24,37 @@ include $(LEVEL)/test/Programs/Makefile.programs # Figure out what object files we want to build... -LObjs := $(sort $(addsuffix .bc, $(basename $(Source)))) +LObjs := $(sort $(addsuffix .rbc, $(basename $(Source)))) LObjects := $(addprefix Output/,$(LObjs)) NObjs := $(sort $(addsuffix .o, $(basename $(Source)))) NObjects := $(addprefix Output/,$(NObjs)) .PRECIOUS: $(LObjects) $(NObjects) Output/%.linked.bc +.PRECIOUS: Output/%.linked.rbc Output/%.linked.rll Output/%.o: %.c Output/.dir $(CC) $(CPPFLAGS) -O $(CFLAGS) -c $< -o $@ +# Raw bytecode files are files created by simply linking the output of the GCC +# frontend without running gccas. +# +Output/%.rbc: Output/%.ll $(LAS) + $(LAS) -f $< -o $@ + + # Output/*.linked.bc is all of the bytecode files of the program linked together # without any libraries linked in... # -Output/%.linked.bc: $(LObjects) +Output/%.linked.rbc: $(LObjects) $(LLINK) -f $(LObjects) | opt -funcresolve > $@ +Output/%.linked.rll: Output/%.linked.rbc $(LDIS) + $(LDIS) -f $< -o $@ + +Output/%.linked.bc: Output/%.linked.rll $(LGCCAS) + $(LGCCAS) $< -o $@ + # Link the program to the libraries it uses, then perform postlink # optimization... Output/%.llvm Output/%.llvm.bc: Output/%.linked.bc @@ -56,7 +70,6 @@ -ls -l Output/$(PROG).llvm.bc $(HOME)/LLVMPrograms/$(PROG).llvm.bc -cp $(HOME)/LLVMPrograms/$(PROG).llvm.bc $(HOME)/LLVMPrograms/$(PROG).llvm.old.bc cp Output/$(PROG).llvm.bc $(HOME)/LLVMPrograms - ds: Output/$(PROG).linked.bc $(LANALYZE) -datastructure $< -t From lattner at cs.uiuc.edu Fri Sep 13 09:34:00 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Sep 13 09:34:00 2002 Subject: [llvm-commits] CVS: llvm/include/Support/CommandLine.h Message-ID: <200209131433.JAA11912@trinity.cs.uiuc.edu> Changes in directory llvm/include/Support: CommandLine.h updated: 1.8 -> 1.9 --- Log message: Checkin patch written by Casey Carter, enabling support for the redhat GCC 2.96 compiler. --- Diffs of the changes: Index: llvm/include/Support/CommandLine.h diff -u llvm/include/Support/CommandLine.h:1.8 llvm/include/Support/CommandLine.h:1.9 --- llvm/include/Support/CommandLine.h:1.8 Wed Aug 7 13:36:27 2002 +++ llvm/include/Support/CommandLine.h Fri Sep 13 09:33:39 2002 @@ -562,6 +562,10 @@ template static void opt(const char *Str, Opt &O) { O.setArgStr(Str); } }; +template struct applicator { + template + static void opt(const char *Str, Opt &O) { O.setArgStr(Str); } +}; template<> struct applicator { template static void opt(const char *Str, Opt &O) { O.setArgStr(Str); } From lattner at cs.uiuc.edu Fri Sep 13 09:42:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Sep 13 09:42:01 2002 Subject: [llvm-commits] CVS: llvm/tools/lli/Execution.cpp Message-ID: <200209131441.JAA12050@trinity.cs.uiuc.edu> Changes in directory llvm/tools/lli: Execution.cpp updated: 1.64 -> 1.65 --- Log message: Another portability patch graciously provided by Casey Carter --- Diffs of the changes: Index: llvm/tools/lli/Execution.cpp diff -u llvm/tools/lli/Execution.cpp:1.64 llvm/tools/lli/Execution.cpp:1.65 --- llvm/tools/lli/Execution.cpp:1.64 Tue Sep 10 20:21:35 2002 +++ llvm/tools/lli/Execution.cpp Fri Sep 13 09:41:38 2002 @@ -1153,7 +1153,7 @@ if (int SigNo = sigsetjmp(SignalRecoverBuffer, 1)) { --SF.CurInst; // Back up to erroring instruction if (SigNo != SIGINT) { - cout << "EXCEPTION OCCURRED [" << _sys_siglistp[SigNo] << "]:\n"; + cout << "EXCEPTION OCCURRED [" << strsignal(SigNo) << "]:\n"; printStackTrace(); // If -abort-on-exception was specified, terminate LLI instead of trying // to debug it. From lattner at cs.uiuc.edu Fri Sep 13 09:48:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Sep 13 09:48:01 2002 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Pass.cpp Message-ID: <200209131447.JAA12200@trinity.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Pass.cpp updated: 1.36 -> 1.37 --- Log message: Another portability fix provided via Casey Carter: ISSUE: getTimeRecord in lib/VMCore/Pass.cpp uses timeval and gettimeofday() without including sys/time.h. ACTION: Include sys/time.h. --- Diffs of the changes: Index: llvm/lib/VMCore/Pass.cpp diff -u llvm/lib/VMCore/Pass.cpp:1.36 llvm/lib/VMCore/Pass.cpp:1.37 --- llvm/lib/VMCore/Pass.cpp:1.36 Thu Sep 12 12:06:40 2002 +++ llvm/lib/VMCore/Pass.cpp Fri Sep 13 09:47:12 2002 @@ -13,6 +13,7 @@ #include "Support/TypeInfo.h" #include #include +#include #include #include From lattner at cs.uiuc.edu Fri Sep 13 09:58:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Sep 13 09:58:01 2002 Subject: [llvm-commits] CVS: llvm/lib/Support/Signals.cpp Message-ID: <200209131457.JAA12854@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Support: Signals.cpp updated: 1.2 -> 1.3 --- Log message: Submitted by Casey Carter: ISSUE: Linux doesn't have any steenking SIGEMT signal, as referred to in lib/Support/Signals.cpp. ACTION: Wrap the use with a #ifdef SIGEMT / #endif. --- Diffs of the changes: Index: llvm/lib/Support/Signals.cpp diff -u llvm/lib/Support/Signals.cpp:1.2 llvm/lib/Support/Signals.cpp:1.3 --- llvm/lib/Support/Signals.cpp:1.2 Tue Jun 25 15:51:26 2002 +++ llvm/lib/Support/Signals.cpp Fri Sep 13 09:57:24 2002 @@ -24,8 +24,10 @@ // KillSigs - Signals that are synchronous with the program that will cause it // to die. static const int KillSigs[] = { - SIGILL, SIGTRAP, SIGABRT, SIGEMT, SIGFPE, - SIGBUS, SIGSEGV, SIGSYS, SIGXCPU, SIGXFSZ + SIGILL, SIGTRAP, SIGABRT, SIGFPE, SIGBUS, SIGSEGV, SIGSYS, SIGXCPU, SIGXFSZ +#ifdef SIGEMT + , SIGEMT +#endif }; static const int *KillSigsEnd = KillSigs + sizeof(KillSigs)/sizeof(KillSigs[0]); From lattner at cs.uiuc.edu Fri Sep 13 10:39:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Sep 13 10:39:01 2002 Subject: [llvm-commits] CVS: llvm/include/Support/DataTypes.h Message-ID: <200209131538.KAA12880@trinity.cs.uiuc.edu> Changes in directory llvm/include/Support: DataTypes.h updated: 1.2 -> 1.3 --- Log message: Add better linux support by using the right macro. This still should be autoconfiscated, but for now this is sufficient. --- Diffs of the changes: Index: llvm/include/Support/DataTypes.h diff -u llvm/include/Support/DataTypes.h:1.2 llvm/include/Support/DataTypes.h:1.3 --- llvm/include/Support/DataTypes.h:1.2 Thu May 23 10:48:12 2002 +++ llvm/include/Support/DataTypes.h Fri Sep 13 10:37:58 2002 @@ -21,7 +21,7 @@ #include -#ifdef LINUX +#ifdef __linux__ #define __STDC_LIMIT_MACROS 1 #include // Defined by ISO C 99 #include From lattner at cs.uiuc.edu Fri Sep 13 11:03:00 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Sep 13 11:03:00 2002 Subject: [llvm-commits] CVS: llvm/Makefile.common Message-ID: <200209131602.LAA14124@trinity.cs.uiuc.edu> Changes in directory llvm: Makefile.common updated: 1.44 -> 1.45 --- Log message: Build with -D_GNU_SOURCE to enable gnu extensions in header files --- Diffs of the changes: Index: llvm/Makefile.common diff -u llvm/Makefile.common:1.44 llvm/Makefile.common:1.45 --- llvm/Makefile.common:1.44 Thu Sep 12 12:02:40 2002 +++ llvm/Makefile.common Fri Sep 13 11:02:26 2002 @@ -118,6 +118,9 @@ PROFILE = endif +# Allow gnu extensions... +CPPFLAGS += -D_GNU_SOURCE + # -Wno-unused-parameter CompileCommonOpts := $(PROFILE) -Wall -W -Wwrite-strings -Wno-unused -I$(LEVEL)/include From lattner at cs.uiuc.edu Fri Sep 13 16:42:00 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Sep 13 16:42:00 2002 Subject: [llvm-commits] CVS: llvm/Makefile.common Message-ID: <200209132141.QAA29674@trinity.cs.uiuc.edu> Changes in directory llvm: Makefile.common updated: 1.45 -> 1.46 --- Log message: Link .so files correctly on either linux or solaris --- Diffs of the changes: Index: llvm/Makefile.common diff -u llvm/Makefile.common:1.45 llvm/Makefile.common:1.46 --- llvm/Makefile.common:1.45 Fri Sep 13 11:02:26 2002 +++ llvm/Makefile.common Fri Sep 13 16:41:07 2002 @@ -139,11 +139,6 @@ LinkG := $(Link) -g -L $(LIBDEBUG) LinkO := $(Link) -O3 -L $(LIBRELEASE) -# Create a .so file from a .o files... -#MakeSO := $(CXX) -shared $(PROFILE) -MakeSO := $(CXX) -G $(PROFILE) -MakeSOO := $(MakeSO) -O3 - # Create one .o file from a bunch of .o files... Relink = ld -r @@ -198,6 +193,23 @@ # of it. For this reason, sometimes it's useful to use libraries as .a files. ifdef LIBRARYNAME + +# Figure out how to make a .so file on this platform. This is really gross and +# should be autoconfiscated (automake actually), but should hopefully work on +# linux and solaris. +# + +# Create a .so file from a .o files... +UNAME := $(shell uname) + +ifeq ($(UNAME), SunOS) +MakeSO := $(CXX) -G $(PROFILE) +else +MakeSO := $(CXX) -shared $(PROFILE) +endif + +MakeSOO := $(MakeSO) -O3 + LIBNAME_O := $(LIBRELEASE)/lib$(LIBRARYNAME).so LIBNAME_G := $(LIBDEBUG)/lib$(LIBRARYNAME).so From lattner at cs.uiuc.edu Fri Sep 13 16:52:00 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Sep 13 16:52:00 2002 Subject: [llvm-commits] CVS: llvm/include/Support/DataTypes.h Message-ID: <200209132151.QAA01207@trinity.cs.uiuc.edu> Changes in directory llvm/include/Support: DataTypes.h updated: 1.3 -> 1.4 --- Log message: Try to work well on multiple platforms. --- Diffs of the changes: Index: llvm/include/Support/DataTypes.h diff -u llvm/include/Support/DataTypes.h:1.3 llvm/include/Support/DataTypes.h:1.4 --- llvm/include/Support/DataTypes.h:1.3 Fri Sep 13 10:37:58 2002 +++ llvm/include/Support/DataTypes.h Fri Sep 13 16:51:25 2002 @@ -7,6 +7,7 @@ // LITTLE_ENDIAN: is #define'd if the host is little endian // int64_t : is a typedef for the signed 64 bit system type // uint64_t : is a typedef for the unsigned 64 bit system type +// INT64_MAX : is a #define specifying the max value for int64_t's // // No library is required when using these functinons. // @@ -15,22 +16,29 @@ // TODO: This file sucks. Not only does it not work, but this stuff should be // autoconfiscated anyways. Major FIXME - #ifndef LLVM_SUPPORT_DATATYPES_H #define LLVM_SUPPORT_DATATYPES_H +#define __STDC_LIMIT_MACROS 1 #include #ifdef __linux__ -#define __STDC_LIMIT_MACROS 1 -#include // Defined by ISO C 99 #include +#endif -#else +#ifdef __sparc__ #include #ifdef _LITTLE_ENDIAN #define LITTLE_ENDIAN 1 +#else +#define BIG_ENDIAN 1 #endif #endif +#ifndef LITTLE_ENDIAN +#if !defined(BIG_ENDIAN) || !defined(INT64_MAX) +#error "include/Support/DataTypes.h could not determine endianness!" #endif +#endif + +#endif /* LLVM_SUPPORT_DATATYPES_H */ From lattner at cs.uiuc.edu Fri Sep 13 17:15:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Sep 13 17:15:01 2002 Subject: [llvm-commits] CVS: llvm/Makefile.Linux Makefile.SunOS Makefile.common Message-ID: <200209132214.RAA03879@trinity.cs.uiuc.edu> Changes in directory llvm: Makefile.Linux added (r1.1) Makefile.SunOS added (r1.1) Makefile.common updated: 1.46 -> 1.47 --- Log message: Factor platform specific makefile directives out into their own makefile fragments. This is gross, but having tons of confusing conditionals all throughout the build system seems worst. Credits got to Casey Carter for the idea. --- Diffs of the changes: Index: llvm/Makefile.common diff -u llvm/Makefile.common:1.46 llvm/Makefile.common:1.47 --- llvm/Makefile.common:1.46 Fri Sep 13 16:41:07 2002 +++ llvm/Makefile.common Fri Sep 13 17:14:47 2002 @@ -46,6 +46,14 @@ # #ENABLE_OPTIMIZED = 1 + +# Figure out how to do platform specific stuff on this platform. This is really +# gross and should be autoconfiscated (automake actually), but should hopefully +# work on Linux and solaris (SunOS). +# +UNAME := $(shell uname) +include $(LEVEL)/Makefile.$(UNAME) + ifdef SHARED_LIBRARY # if SHARED_LIBRARY is specified, the default is to build the dynamic lib dynamic :: @@ -142,6 +150,10 @@ # Create one .o file from a bunch of .o files... Relink = ld -r +# MakeSO - Create a .so file from a .o files... +MakeSO := $(CXX) $(MakeSharedObjectOption) $(PROFILE) +MakeSOO := $(MakeSO) -O3 + # Create dependancy file from CPP file, send to stdout. Depend := $(CXX) -MM -I$(LEVEL)/include $(CPPFLAGS) @@ -193,23 +205,6 @@ # of it. For this reason, sometimes it's useful to use libraries as .a files. ifdef LIBRARYNAME - -# Figure out how to make a .so file on this platform. This is really gross and -# should be autoconfiscated (automake actually), but should hopefully work on -# linux and solaris. -# - -# Create a .so file from a .o files... -UNAME := $(shell uname) - -ifeq ($(UNAME), SunOS) -MakeSO := $(CXX) -G $(PROFILE) -else -MakeSO := $(CXX) -shared $(PROFILE) -endif - -MakeSOO := $(MakeSO) -O3 - LIBNAME_O := $(LIBRELEASE)/lib$(LIBRARYNAME).so LIBNAME_G := $(LIBDEBUG)/lib$(LIBRARYNAME).so From lattner at cs.uiuc.edu Fri Sep 13 17:19:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Sep 13 17:19:01 2002 Subject: [llvm-commits] CVS: llvm/include/Support/DataTypes.h Message-ID: <200209132218.RAA04273@trinity.cs.uiuc.edu> Changes in directory llvm/include/Support: DataTypes.h updated: 1.4 -> 1.5 --- Log message: Tighten up sanity checking --- Diffs of the changes: Index: llvm/include/Support/DataTypes.h diff -u llvm/include/Support/DataTypes.h:1.4 llvm/include/Support/DataTypes.h:1.5 --- llvm/include/Support/DataTypes.h:1.4 Fri Sep 13 16:51:25 2002 +++ llvm/include/Support/DataTypes.h Fri Sep 13 17:18:26 2002 @@ -35,10 +35,8 @@ #endif #endif -#ifndef LITTLE_ENDIAN -#if !defined(BIG_ENDIAN) || !defined(INT64_MAX) +#if (!defined(LITTLE_ENDIAN) && !defined(BIG_ENDIAN)) || !defined(INT64_MAX) #error "include/Support/DataTypes.h could not determine endianness!" -#endif #endif #endif /* LLVM_SUPPORT_DATATYPES_H */ From lattner at cs.uiuc.edu Fri Sep 13 17:21:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Sep 13 17:21:01 2002 Subject: [llvm-commits] CVS: llvm/tools/lli/Makefile Message-ID: <200209132220.RAA04376@trinity.cs.uiuc.edu> Changes in directory llvm/tools/lli: Makefile updated: 1.16 -> 1.17 --- Log message: Export symbols for linux --- Diffs of the changes: Index: llvm/tools/lli/Makefile diff -u llvm/tools/lli/Makefile:1.16 llvm/tools/lli/Makefile:1.17 --- llvm/tools/lli/Makefile:1.16 Tue Jul 23 12:50:51 2002 +++ llvm/tools/lli/Makefile Fri Sep 13 17:20:19 2002 @@ -1,6 +1,10 @@ LEVEL = ../.. TOOLNAME = lli USEDLIBS = bcreader vmcore analysis.a support.a target.a transforms.a -TOOLLINKOPTS = -ldl + +# Have gcc tell the linker to export symbols from the program so that +# dynamically loaded modules can be linked against them. +# +TOOLLINKOPTS = -ldl $(ExportSymbols) include $(LEVEL)/Makefile.common From lattner at cs.uiuc.edu Fri Sep 13 17:26:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Sep 13 17:26:01 2002 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp Message-ID: <200209132225.RAA05396@trinity.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Constants.cpp updated: 1.27 -> 1.28 --- Log message: include/llvm/DataTypes.h includes this #define so we don't need it anymore --- Diffs of the changes: Index: llvm/lib/VMCore/Constants.cpp diff -u llvm/lib/VMCore/Constants.cpp:1.27 llvm/lib/VMCore/Constants.cpp:1.28 --- llvm/lib/VMCore/Constants.cpp:1.27 Tue Sep 10 20:21:04 2002 +++ llvm/lib/VMCore/Constants.cpp Fri Sep 13 17:24:57 2002 @@ -4,7 +4,6 @@ // //===----------------------------------------------------------------------===// -#define __STDC_LIMIT_MACROS // Get defs for INT64_MAX and friends... #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" #include "llvm/iMemory.h" From lattner at cs.uiuc.edu Fri Sep 13 17:26:07 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Sep 13 17:26:07 2002 Subject: [llvm-commits] CVS: llvm/lib/AsmParser/ParserInternals.h Message-ID: <200209132225.RAA05408@trinity.cs.uiuc.edu> Changes in directory llvm/lib/AsmParser: ParserInternals.h updated: 1.27 -> 1.28 --- Log message: include/llvm/DataTypes.h includes this #define so we don't need it anymore --- Diffs of the changes: Index: llvm/lib/AsmParser/ParserInternals.h diff -u llvm/lib/AsmParser/ParserInternals.h:1.27 llvm/lib/AsmParser/ParserInternals.h:1.28 --- llvm/lib/AsmParser/ParserInternals.h:1.27 Fri Aug 16 16:14:40 2002 +++ llvm/lib/AsmParser/ParserInternals.h Fri Sep 13 17:25:00 2002 @@ -8,8 +8,6 @@ #ifndef PARSER_INTERNALS_H #define PARSER_INTERNALS_H -#define __STDC_LIMIT_MACROS -#include "llvm/BasicBlock.h" #include "llvm/Constants.h" #include "llvm/iOther.h" #include "llvm/Function.h" From lattner at cs.uiuc.edu Fri Sep 13 17:29:00 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Sep 13 17:29:00 2002 Subject: [llvm-commits] CVS: llvm/include/llvm/iMemory.h Message-ID: <200209132228.RAA07198@trinity.cs.uiuc.edu> Changes in directory llvm/include/llvm: iMemory.h updated: 1.35 -> 1.36 --- Log message: Change the MallocInst & AllocaInst ctors to take the allocated type, not the pointer type returned. --- Diffs of the changes: Index: llvm/include/llvm/iMemory.h diff -u llvm/include/llvm/iMemory.h:1.35 llvm/include/llvm/iMemory.h:1.36 --- llvm/include/llvm/iMemory.h:1.35 Tue Sep 10 10:36:09 2002 +++ llvm/include/llvm/iMemory.h Fri Sep 13 17:28:50 2002 @@ -63,13 +63,15 @@ // MallocInst Class //===----------------------------------------------------------------------===// -struct MallocInst : public AllocationInst { +class MallocInst : public AllocationInst { + MallocInst(const MallocInst &MI); +public: MallocInst(const Type *Ty, Value *ArraySize = 0, const std::string &Name = "", Instruction *InsertBefore = 0) : AllocationInst(Ty, ArraySize, Malloc, Name, InsertBefore) {} virtual Instruction *clone() const { - return new MallocInst((Type*)getType(), (Value*)Operands[0].get()); + return new MallocInst(*this); } // Methods for support type inquiry through isa, cast, and dyn_cast: @@ -87,13 +89,15 @@ // AllocaInst Class //===----------------------------------------------------------------------===// -struct AllocaInst : public AllocationInst { +class AllocaInst : public AllocationInst { + AllocaInst(const AllocaInst &); +public: AllocaInst(const Type *Ty, Value *ArraySize = 0, const std::string &Name = "", Instruction *InsertBefore = 0) : AllocationInst(Ty, ArraySize, Alloca, Name, InsertBefore) {} virtual Instruction *clone() const { - return new AllocaInst((Type*)getType(), (Value*)Operands[0].get()); + return new AllocaInst(*this); } // Methods for support type inquiry through isa, cast, and dyn_cast: From lattner at cs.uiuc.edu Fri Sep 13 17:30:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Sep 13 17:30:01 2002 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/RaiseAllocations.cpp Message-ID: <200209132229.RAA07508@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: RaiseAllocations.cpp updated: 1.11 -> 1.12 --- Log message: Change the MallocInst & AllocaInst ctors to take the allocated type, not the pointer type returned. --- Diffs of the changes: Index: llvm/lib/Transforms/Scalar/RaiseAllocations.cpp diff -u llvm/lib/Transforms/Scalar/RaiseAllocations.cpp:1.11 llvm/lib/Transforms/Scalar/RaiseAllocations.cpp:1.12 --- llvm/lib/Transforms/Scalar/RaiseAllocations.cpp:1.11 Tue Sep 10 18:31:12 2002 +++ llvm/lib/Transforms/Scalar/RaiseAllocations.cpp Fri Sep 13 17:28:33 2002 @@ -113,7 +113,6 @@ if (CallInst *CI = dyn_cast(I)) { if (CI->getCalledValue() == MallocFunc) { // Replace call to malloc? - const Type *PtrSByte = PointerType::get(Type::SByteTy); Value *Source = CI->getOperand(1); // If no prototype was provided for malloc, we may need to cast the @@ -122,7 +121,7 @@ Source = new CastInst(Source, Type::UIntTy, "MallocAmtCast", BI); std::string Name(CI->getName()); CI->setName(""); - BI = new MallocInst(PtrSByte, Source, Name, BI); + BI = new MallocInst(Type::SByteTy, Source, Name, BI); CI->replaceAllUsesWith(BI); BIL.erase(I); Changed = true; From lattner at cs.uiuc.edu Fri Sep 13 17:30:07 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Sep 13 17:30:07 2002 Subject: [llvm-commits] CVS: llvm/lib/VMCore/iMemory.cpp Message-ID: <200209132229.RAA07502@trinity.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: iMemory.cpp updated: 1.27 -> 1.28 --- Log message: Change the MallocInst & AllocaInst ctors to take the allocated type, not the pointer type returned. --- Diffs of the changes: Index: llvm/lib/VMCore/iMemory.cpp diff -u llvm/lib/VMCore/iMemory.cpp:1.27 llvm/lib/VMCore/iMemory.cpp:1.28 --- llvm/lib/VMCore/iMemory.cpp:1.27 Tue Sep 10 19:22:39 2002 +++ llvm/lib/VMCore/iMemory.cpp Fri Sep 13 17:28:30 2002 @@ -10,8 +10,7 @@ AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, const std::string &Name, Instruction *InsertBef) - : Instruction(Ty, iTy, Name, InsertBef) { - assert(isa(Ty) && "Can't allocate a non pointer type!"); + : Instruction(PointerType::get(Ty), iTy, Name, InsertBef) { // ArraySize defaults to 1. if (!ArraySize) ArraySize = ConstantUInt::get(Type::UIntTy, 1); @@ -29,6 +28,16 @@ const Type *AllocationInst::getAllocatedType() const { return getType()->getElementType(); +} + +AllocaInst::AllocaInst(const AllocaInst &AI) + : AllocationInst(AI.getType()->getElementType(), (Value*)AI.getOperand(0), + Instruction::Alloca) { +} + +MallocInst::MallocInst(const MallocInst &MI) + : AllocationInst(MI.getType()->getElementType(), (Value*)MI.getOperand(0), + Instruction::Malloc) { } //===----------------------------------------------------------------------===// From lattner at cs.uiuc.edu Fri Sep 13 17:30:13 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Sep 13 17:30:13 2002 Subject: [llvm-commits] CVS: llvm/lib/Transforms/IPO/PoolAllocate.cpp MutateStructTypes.cpp Message-ID: <200209132229.RAA07516@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/IPO: PoolAllocate.cpp updated: 1.40 -> 1.41 MutateStructTypes.cpp updated: 1.28 -> 1.29 --- Log message: Change the MallocInst & AllocaInst ctors to take the allocated type, not the pointer type returned. --- Diffs of the changes: Index: llvm/lib/Transforms/IPO/PoolAllocate.cpp diff -u llvm/lib/Transforms/IPO/PoolAllocate.cpp:1.40 llvm/lib/Transforms/IPO/PoolAllocate.cpp:1.41 --- llvm/lib/Transforms/IPO/PoolAllocate.cpp:1.40 Thu Aug 8 14:01:21 2002 +++ llvm/lib/Transforms/IPO/PoolAllocate.cpp Fri Sep 13 17:28:36 2002 @@ -1639,9 +1639,8 @@ "Pool type should not be abstract anymore!"); // Add an allocation and a free for each pool... - AllocaInst *PoolAlloc - = new AllocaInst(PointerType::get(PI.PoolType), 0, - CurModule->getTypeName(PI.PoolType)); + AllocaInst *PoolAlloc = new AllocaInst(PI.PoolType, 0, + CurModule->getTypeName(PI.PoolType)); PI.Handle = PoolAlloc; EntryNodeInsts.push_back(PoolAlloc); AllocationInst *AI = Allocs[i]->getAllocation(); Index: llvm/lib/Transforms/IPO/MutateStructTypes.cpp diff -u llvm/lib/Transforms/IPO/MutateStructTypes.cpp:1.28 llvm/lib/Transforms/IPO/MutateStructTypes.cpp:1.29 --- llvm/lib/Transforms/IPO/MutateStructTypes.cpp:1.28 Thu Aug 22 18:36:46 2002 +++ llvm/lib/Transforms/IPO/MutateStructTypes.cpp Fri Sep 13 17:28:36 2002 @@ -399,12 +399,14 @@ // Memory Instructions case Instruction::Alloca: NewI = - new AllocaInst(ConvertType(I.getType()), + new MallocInst( + ConvertType(cast(I.getType())->getElementType()), I.getNumOperands() ? ConvertValue(I.getOperand(0)) :0); break; case Instruction::Malloc: NewI = - new MallocInst(ConvertType(I.getType()), + new MallocInst( + ConvertType(cast(I.getType())->getElementType()), I.getNumOperands() ? ConvertValue(I.getOperand(0)) :0); break; From lattner at cs.uiuc.edu Fri Sep 13 17:30:18 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Sep 13 17:30:18 2002 Subject: [llvm-commits] CVS: llvm/lib/Transforms/ExprTypeConvert.cpp Message-ID: <200209132229.RAA07526@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Transforms: ExprTypeConvert.cpp updated: 1.57 -> 1.58 --- Log message: Change the MallocInst & AllocaInst ctors to take the allocated type, not the pointer type returned. --- Diffs of the changes: Index: llvm/lib/Transforms/ExprTypeConvert.cpp diff -u llvm/lib/Transforms/ExprTypeConvert.cpp:1.57 llvm/lib/Transforms/ExprTypeConvert.cpp:1.58 --- llvm/lib/Transforms/ExprTypeConvert.cpp:1.57 Tue Sep 10 20:21:23 2002 +++ llvm/lib/Transforms/ExprTypeConvert.cpp Fri Sep 13 17:28:40 2002 @@ -125,7 +125,7 @@ } assert(AllocTy == Ty); - return new MallocInst(AllocTy, Expr.Var, Name); + return new MallocInst(AllocTy->getElementType(), Expr.Var, Name); } From lattner at cs.uiuc.edu Fri Sep 13 17:30:24 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Sep 13 17:30:24 2002 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Reader/ReadInst.cpp Message-ID: <200209132229.RAA07533@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Reader: ReadInst.cpp updated: 1.37 -> 1.38 --- Log message: Change the MallocInst & AllocaInst ctors to take the allocated type, not the pointer type returned. --- Diffs of the changes: Index: llvm/lib/Bytecode/Reader/ReadInst.cpp diff -u llvm/lib/Bytecode/Reader/ReadInst.cpp:1.37 llvm/lib/Bytecode/Reader/ReadInst.cpp:1.38 --- llvm/lib/Bytecode/Reader/ReadInst.cpp:1.37 Thu Aug 22 18:36:36 2002 +++ llvm/lib/Bytecode/Reader/ReadInst.cpp Fri Sep 13 17:28:43 2002 @@ -329,13 +329,19 @@ case Instruction::Malloc: if (Raw.NumOperands > 2) return true; V = Raw.NumOperands ? getValue(Type::UIntTy, Raw.Arg1) : 0; - Res = new MallocInst(Raw.Ty, V); + if (const PointerType *PTy = dyn_cast(Raw.Ty)) + Res = new MallocInst(PTy->getElementType(), V); + else + return true; return false; case Instruction::Alloca: if (Raw.NumOperands > 2) return true; V = Raw.NumOperands ? getValue(Type::UIntTy, Raw.Arg1) : 0; - Res = new AllocaInst(Raw.Ty, V); + if (const PointerType *PTy = dyn_cast(Raw.Ty)) + Res = new AllocaInst(PTy->getElementType(), V); + else + return true; return false; case Instruction::Free: From lattner at cs.uiuc.edu Fri Sep 13 17:30:30 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Sep 13 17:30:30 2002 Subject: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y Message-ID: <200209132229.RAA07543@trinity.cs.uiuc.edu> Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.92 -> 1.93 --- Log message: Change the MallocInst & AllocaInst ctors to take the allocated type, not the pointer type returned. --- Diffs of the changes: Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.92 llvm/lib/AsmParser/llvmAsmParser.y:1.93 --- llvm/lib/AsmParser/llvmAsmParser.y:1.92 Tue Sep 10 20:17:27 2002 +++ llvm/lib/AsmParser/llvmAsmParser.y Fri Sep 13 17:28:45 2002 @@ -1630,22 +1630,19 @@ }; MemoryInst : MALLOC Types { - $$ = new MallocInst(PointerType::get(*$2)); + $$ = new MallocInst(*$2); delete $2; } | MALLOC Types ',' UINT ValueRef { - const Type *Ty = PointerType::get(*$2); - $$ = new MallocInst(Ty, getVal($4, $5)); + $$ = new MallocInst(*$2, getVal($4, $5)); delete $2; } | ALLOCA Types { - $$ = new AllocaInst(PointerType::get(*$2)); + $$ = new AllocaInst(*$2); delete $2; } | ALLOCA Types ',' UINT ValueRef { - const Type *Ty = PointerType::get(*$2); - Value *ArrSize = getVal($4, $5); - $$ = new AllocaInst(Ty, ArrSize); + $$ = new AllocaInst(*$2, getVal($4, $5)); delete $2; } | FREE ResolvedVal { From lattner at cs.uiuc.edu Fri Sep 13 18:31:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Sep 13 18:31:01 2002 Subject: [llvm-commits] CVS: llvm/tools/lli/Execution.cpp ExternalFunctions.cpp Message-ID: <200209132330.SAA10464@trinity.cs.uiuc.edu> Changes in directory llvm/tools/lli: Execution.cpp updated: 1.65 -> 1.66 ExternalFunctions.cpp updated: 1.32 -> 1.33 --- Log message: * Fix a bug that was causing lli to misrun: test/Regression/Transforms/DecomposeMultiDimRefs/mixedindices.c * Eliminate unneccesary #include --- Diffs of the changes: Index: llvm/tools/lli/Execution.cpp diff -u llvm/tools/lli/Execution.cpp:1.65 llvm/tools/lli/Execution.cpp:1.66 --- llvm/tools/lli/Execution.cpp:1.65 Fri Sep 13 09:41:38 2002 +++ llvm/tools/lli/Execution.cpp Fri Sep 13 18:30:42 2002 @@ -823,7 +823,7 @@ // Get the index number for the array... which must be uint type... assert((*I)->getType() == Type::LongTy); - unsigned Idx = getOperandValue(*I, SF).UIntVal; + unsigned Idx = getOperandValue(*I, SF).LongVal; if (const ArrayType *AT = dyn_cast(ST)) if (Idx >= AT->getNumElements() && ArrayChecksEnabled) { cerr << "Out of range memory access to element #" << Idx Index: llvm/tools/lli/ExternalFunctions.cpp diff -u llvm/tools/lli/ExternalFunctions.cpp:1.32 llvm/tools/lli/ExternalFunctions.cpp:1.33 --- llvm/tools/lli/ExternalFunctions.cpp:1.32 Fri Aug 2 18:08:32 2002 +++ llvm/tools/lli/ExternalFunctions.cpp Fri Sep 13 18:30:42 2002 @@ -14,7 +14,6 @@ #include "llvm/DerivedTypes.h" #include #include -#include #include #include #include From brukman at cs.uiuc.edu Fri Sep 13 21:07:00 2002 From: brukman at cs.uiuc.edu (Michael Brukman) Date: Fri Sep 13 21:07:00 2002 Subject: [llvm-commits] CVS: llvm/lib/Transforms/IPO/MutateStructTypes.cpp Message-ID: <200209140206.VAA15997@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/IPO: MutateStructTypes.cpp updated: 1.29 -> 1.30 --- Log message: Following Chris's advice, I'm pruning some unnecessary .h includes that I'm noticing. Since Module includes Function, and eventually, BasicBlock and GlobalVariable, the last three are unnecessary to be included directly. --- Diffs of the changes: Index: llvm/lib/Transforms/IPO/MutateStructTypes.cpp diff -u llvm/lib/Transforms/IPO/MutateStructTypes.cpp:1.29 llvm/lib/Transforms/IPO/MutateStructTypes.cpp:1.30 --- llvm/lib/Transforms/IPO/MutateStructTypes.cpp:1.29 Fri Sep 13 17:28:36 2002 +++ llvm/lib/Transforms/IPO/MutateStructTypes.cpp Fri Sep 13 21:06:53 2002 @@ -14,9 +14,6 @@ #include "llvm/Transforms/IPO/MutateStructTypes.h" #include "llvm/DerivedTypes.h" #include "llvm/Module.h" -#include "llvm/Function.h" -#include "llvm/BasicBlock.h" -#include "llvm/GlobalVariable.h" #include "llvm/SymbolTable.h" #include "llvm/iPHINode.h" #include "llvm/iMemory.h" From brukman at cs.uiuc.edu Fri Sep 13 21:08:01 2002 From: brukman at cs.uiuc.edu (Michael Brukman) Date: Fri Sep 13 21:08:01 2002 Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/EmitAssembly.cpp Message-ID: <200209140207.VAA16012@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Target/Sparc: EmitAssembly.cpp updated: 1.58 -> 1.59 --- Log message: Again, including Module makes Function unnecessary. --- Diffs of the changes: Index: llvm/lib/Target/Sparc/EmitAssembly.cpp diff -u llvm/lib/Target/Sparc/EmitAssembly.cpp:1.58 llvm/lib/Target/Sparc/EmitAssembly.cpp:1.59 --- llvm/lib/Target/Sparc/EmitAssembly.cpp:1.58 Thu Sep 5 13:28:10 2002 +++ llvm/lib/Target/Sparc/EmitAssembly.cpp Fri Sep 13 21:07:43 2002 @@ -18,8 +18,6 @@ #include "llvm/GlobalVariable.h" #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" -#include "llvm/BasicBlock.h" -#include "llvm/Function.h" #include "llvm/Module.h" #include "llvm/SlotCalculator.h" #include "llvm/Pass.h" From brukman at cs.uiuc.edu Fri Sep 13 21:09:01 2002 From: brukman at cs.uiuc.edu (Michael Brukman) Date: Fri Sep 13 21:09:01 2002 Subject: [llvm-commits] CVS: llvm/lib/Reoptimizer/Mapping/getLLVMinfo.cpp Message-ID: <200209140208.VAA16057@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Reoptimizer/Mapping: getLLVMinfo.cpp updated: 1.6 -> 1.7 --- Log message: Removing more unnecessary includes, here makes unnecessary. --- Diffs of the changes: Index: llvm/lib/Reoptimizer/Mapping/getLLVMinfo.cpp diff -u llvm/lib/Reoptimizer/Mapping/getLLVMinfo.cpp:1.6 llvm/lib/Reoptimizer/Mapping/getLLVMinfo.cpp:1.7 --- llvm/lib/Reoptimizer/Mapping/getLLVMinfo.cpp:1.6 Wed Sep 11 17:39:55 2002 +++ llvm/lib/Reoptimizer/Mapping/getLLVMinfo.cpp Fri Sep 13 21:08:26 2002 @@ -11,11 +11,6 @@ #include "llvm/Reoptimizer/Mapping/LLVMinfo.h" #include "llvm/Module.h" -#include "llvm/Function.h" -#include "llvm/Instruction.h" -#include "Support/DataTypes.h" -#include -#include #include using std::map; using std::pair; From brukman at cs.uiuc.edu Fri Sep 13 21:20:01 2002 From: brukman at cs.uiuc.edu (Michael Brukman) Date: Fri Sep 13 21:20:01 2002 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Writer/WriteInst.cpp Message-ID: <200209140219.VAA17475@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Writer: WriteInst.cpp updated: 1.24 -> 1.25 --- Log message: On the quest of eliminating unnecessary includes. --- Diffs of the changes: Index: llvm/lib/Bytecode/Writer/WriteInst.cpp diff -u llvm/lib/Bytecode/Writer/WriteInst.cpp:1.24 llvm/lib/Bytecode/Writer/WriteInst.cpp:1.25 --- llvm/lib/Bytecode/Writer/WriteInst.cpp:1.24 Fri Jul 26 13:40:10 2002 +++ llvm/lib/Bytecode/Writer/WriteInst.cpp Fri Sep 13 21:18:57 2002 @@ -11,8 +11,6 @@ #include "WriterInternals.h" #include "llvm/Module.h" -#include "llvm/Function.h" -#include "llvm/BasicBlock.h" #include "llvm/DerivedTypes.h" #include "llvm/iOther.h" #include "llvm/iTerminators.h" From brukman at cs.uiuc.edu Fri Sep 13 22:04:01 2002 From: brukman at cs.uiuc.edu (Michael Brukman) Date: Fri Sep 13 22:04:01 2002 Subject: [llvm-commits] CVS: llvm/tools/llc/llc.cpp Message-ID: <200209140303.WAA18109@trinity.cs.uiuc.edu> Changes in directory llvm/tools/llc: llc.cpp updated: 1.56 -> 1.57 --- Log message: Function.h is unnecessary when Module.h is included. --- Diffs of the changes: Index: llvm/tools/llc/llc.cpp diff -u llvm/tools/llc/llc.cpp:1.56 llvm/tools/llc/llc.cpp:1.57 --- llvm/tools/llc/llc.cpp:1.56 Tue Jul 30 16:43:22 2002 +++ llvm/tools/llc/llc.cpp Fri Sep 13 22:03:22 2002 @@ -14,7 +14,6 @@ #include "llvm/Bytecode/WriteBytecodePass.h" #include "llvm/Transforms/IPO.h" #include "llvm/Module.h" -#include "llvm/Function.h" #include "llvm/PassManager.h" #include "Support/CommandLine.h" #include "Support/Signals.h" From brukman at cs.uiuc.edu Fri Sep 13 22:05:01 2002 From: brukman at cs.uiuc.edu (Michael Brukman) Date: Fri Sep 13 22:05:01 2002 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/RaiseAllocations.cpp SymbolStripping.cpp Message-ID: <200209140304.WAA18126@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: RaiseAllocations.cpp updated: 1.12 -> 1.13 SymbolStripping.cpp updated: 1.19 -> 1.20 --- Log message: Function.h is unnecessary when Module.h is included. --- Diffs of the changes: Index: llvm/lib/Transforms/Scalar/RaiseAllocations.cpp diff -u llvm/lib/Transforms/Scalar/RaiseAllocations.cpp:1.12 llvm/lib/Transforms/Scalar/RaiseAllocations.cpp:1.13 --- llvm/lib/Transforms/Scalar/RaiseAllocations.cpp:1.12 Fri Sep 13 17:28:33 2002 +++ llvm/lib/Transforms/Scalar/RaiseAllocations.cpp Fri Sep 13 22:04:02 2002 @@ -8,7 +8,6 @@ #include "llvm/Transforms/Scalar.h" #include "llvm/Transforms/Utils/BasicBlockUtils.h" #include "llvm/Module.h" -#include "llvm/Function.h" #include "llvm/DerivedTypes.h" #include "llvm/iMemory.h" #include "llvm/iOther.h" Index: llvm/lib/Transforms/Scalar/SymbolStripping.cpp diff -u llvm/lib/Transforms/Scalar/SymbolStripping.cpp:1.19 llvm/lib/Transforms/Scalar/SymbolStripping.cpp:1.20 --- llvm/lib/Transforms/Scalar/SymbolStripping.cpp:1.19 Fri Jul 26 16:12:42 2002 +++ llvm/lib/Transforms/Scalar/SymbolStripping.cpp Fri Sep 13 22:04:02 2002 @@ -16,7 +16,6 @@ #include "llvm/Transforms/Scalar.h" #include "llvm/Module.h" -#include "llvm/Function.h" #include "llvm/SymbolTable.h" #include "llvm/Pass.h" From vadve at cs.uiuc.edu Sat Sep 14 05:44:01 2002 From: vadve at cs.uiuc.edu (vadve at cs.uiuc.edu) Date: Sat Sep 14 05:44:01 2002 Subject: [llvm-commits] CVS: llvm/include/Support/DataTypes.h Message-ID: <200209141043.FAA01958@morpheus.cs.uiuc.edu> Changes in directory llvm/include/Support: DataTypes.h updated: 1.5 -> 1.6 --- Log message: Add support for MacOS and (hopefully) other BSD derivatives. --- Diffs of the changes: Index: llvm/include/Support/DataTypes.h diff -u llvm/include/Support/DataTypes.h:1.5 llvm/include/Support/DataTypes.h:1.6 --- llvm/include/Support/DataTypes.h:1.5 Fri Sep 13 17:18:26 2002 +++ llvm/include/Support/DataTypes.h Sat Sep 14 05:42:59 2002 @@ -23,7 +23,11 @@ #include #ifdef __linux__ -#include +# include +#else +#if (BSD >= 199103) +# include +#endif #endif #ifdef __sparc__ From vadve at cs.uiuc.edu Sat Sep 14 06:58:01 2002 From: vadve at cs.uiuc.edu (vadve at cs.uiuc.edu) Date: Sat Sep 14 06:58:01 2002 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/RegAllocCommon.h Message-ID: <200209141157.GAA02745@morpheus.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: RegAllocCommon.h (r1.6) removed --- Log message: Moving to lib/CodeGen/RegAlloc. --- Diffs of the changes: From vadve at cs.uiuc.edu Sat Sep 14 06:58:08 2002 From: vadve at cs.uiuc.edu (vadve at cs.uiuc.edu) Date: Sat Sep 14 06:58:08 2002 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/RegAlloc/RegAllocCommon.h Message-ID: <200209141157.GAA02763@morpheus.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/RegAlloc: RegAllocCommon.h added (r1.1) --- Log message: Moved here from include/llvm/CodeGen since it is only used here. --- Diffs of the changes: From vadve at cs.uiuc.edu Sat Sep 14 07:02:01 2002 From: vadve at cs.uiuc.edu (vadve at cs.uiuc.edu) Date: Sat Sep 14 07:02:01 2002 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/RegAlloc/RegAllocCommon.h Message-ID: <200209141201.HAA02804@morpheus.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/RegAlloc: RegAllocCommon.h updated: 1.7 -> 1.8 --- Log message: Moved here from include/llvm/CodeGen because it is only used here. --- Diffs of the changes: Index: llvm/lib/CodeGen/RegAlloc/RegAllocCommon.h diff -u /dev/null llvm/lib/CodeGen/RegAlloc/RegAllocCommon.h:1.8 --- /dev/null Sat Sep 14 07:01:54 2002 +++ llvm/lib/CodeGen/RegAlloc/RegAllocCommon.h Sat Sep 14 07:01:50 2002 @@ -0,0 +1,18 @@ + + +#ifndef REG_ALLOC_COMMON_H +#define REG_ALLOC_COMMON_H + +// set DEBUG_RA for printing out debug messages +// if DEBUG_RA is 1 normal output messages +// if DEBUG_RA is 2 extensive debug info for each instr + +enum RegAllocDebugLevel_t { + RA_DEBUG_None = 0, + RA_DEBUG_Normal = 1, + RA_DEBUG_Verbose = 2, +}; + +extern RegAllocDebugLevel_t DEBUG_RA; + +#endif From lattner at cs.uiuc.edu Sat Sep 14 14:34:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Sep 14 14:34:01 2002 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Instrumentation/ProfilePaths/EdgeCode.cpp Message-ID: <200209141933.OAA27523@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Instrumentation/ProfilePaths: EdgeCode.cpp updated: 1.14 -> 1.15 --- Log message: Fix bug I introduced --- Diffs of the changes: Index: llvm/lib/Transforms/Instrumentation/ProfilePaths/EdgeCode.cpp diff -u llvm/lib/Transforms/Instrumentation/ProfilePaths/EdgeCode.cpp:1.14 llvm/lib/Transforms/Instrumentation/ProfilePaths/EdgeCode.cpp:1.15 --- llvm/lib/Transforms/Instrumentation/ProfilePaths/EdgeCode.cpp:1.14 Tue Sep 10 20:21:29 2002 +++ llvm/lib/Transforms/Instrumentation/ProfilePaths/EdgeCode.cpp Sat Sep 14 14:33:16 2002 @@ -282,9 +282,6 @@ TerminatorInst *TI=BB1->getTerminator(); BasicBlock *newBB=new BasicBlock(ctr, BB1->getParent()); - //get code for the new BB - edgeCode->getCode(rInst, countInst, BB1->getParent(), newBB, numPaths, Methno); - //Is terminator a branch instruction? //then we need to change branch destinations to include new BB @@ -309,6 +306,10 @@ Instruction *newBI2=new BranchInst(BB2); newBB->getInstList().push_back(newBI2); } + + //get code for the new BB + edgeCode->getCode(rInst, countInst, BB1->getParent(), newBB, numPaths, Methno); + //std::cerr<<"After casting\n"; //get code for the new BB From lattner at cs.uiuc.edu Sat Sep 14 14:53:00 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Sep 14 14:53:00 2002 Subject: [llvm-commits] CVS: llvm/include/Support/DataTypes.h Message-ID: <200209141952.OAA28234@trinity.cs.uiuc.edu> Changes in directory llvm/include/Support: DataTypes.h updated: 1.6 -> 1.7 --- Log message: Fix to work correctly under linux --- Diffs of the changes: Index: llvm/include/Support/DataTypes.h diff -u llvm/include/Support/DataTypes.h:1.6 llvm/include/Support/DataTypes.h:1.7 --- llvm/include/Support/DataTypes.h:1.6 Sat Sep 14 05:42:59 2002 +++ llvm/include/Support/DataTypes.h Sat Sep 14 14:52:49 2002 @@ -23,20 +23,29 @@ #include #ifdef __linux__ -# include +# include +# if BYTE_ORDER == LITTLE_ENDIAN +# undef BIG_ENDIAN +# else +# undef LITTLE_ENDIAN +# endif #else -#if (BSD >= 199103) -# include -#endif +# if (BSD >= 199103) +# include +# endif #endif #ifdef __sparc__ -#include -#ifdef _LITTLE_ENDIAN -#define LITTLE_ENDIAN 1 -#else -#define BIG_ENDIAN 1 +# include +# ifdef _LITTLE_ENDIAN +# define LITTLE_ENDIAN 1 +# else +# define BIG_ENDIAN 1 +# endif #endif + +#if (defined(LITTLE_ENDIAN) && defined(BIG_ENDIAN)) +#error "Cannot define both LITTLE_ENDIAN and BIG_ENDIAN!" #endif #if (!defined(LITTLE_ENDIAN) && !defined(BIG_ENDIAN)) || !defined(INT64_MAX) From hldnbrnd at cs.uiuc.edu Sat Sep 14 16:37:01 2002 From: hldnbrnd at cs.uiuc.edu (Nicholas Hildenbrandt) Date: Sat Sep 14 16:37:01 2002 Subject: [llvm-commits] CVS: llvm/lib/CWriter/Writer.cpp Message-ID: <200209142136.QAA02148@trinity.cs.uiuc.edu> Changes in directory llvm/lib/CWriter: Writer.cpp updated: 1.42 -> 1.43 --- Log message: Fixed problem with printing struct definitions in the correct order. This allows for the Regression/Transforms/ScalarReplacement/scalarize.c to run correctly. --- Diffs of the changes: Index: llvm/lib/CWriter/Writer.cpp diff -u llvm/lib/CWriter/Writer.cpp:1.42 llvm/lib/CWriter/Writer.cpp:1.43 --- llvm/lib/CWriter/Writer.cpp:1.42 Thu Sep 12 15:34:47 2002 +++ llvm/lib/CWriter/Writer.cpp Sat Sep 14 16:36:24 2002 @@ -36,6 +36,8 @@ const Module *TheModule; map TypeNames; std::set MangledGlobals; + std::set StructPrinted; + public: CWriter(ostream &o) : Out(o) {} @@ -72,6 +74,7 @@ private : bool nameAllUsedStructureTypes(Module &M); + void parseStruct(const Type *Ty); void printModule(Module *M); void printSymbolTable(const SymbolTable &ST); void printGlobal(const GlobalVariable *GV); @@ -568,33 +571,65 @@ SymbolTable::type_const_iterator I = ST.type_begin(TI->first); SymbolTable::type_const_iterator End = ST.type_end(TI->first); - for (; I != End; ++I) - if (const Type *Ty = dyn_cast(I->second)) { - string Name = "struct l_" + makeNameProper(I->first); - Out << Name << ";\n"; - TypeNames.insert(std::make_pair(Ty, Name)); + for (; I != End; ++I){ + const Value *V = I->second; + if (const Type *Ty = dyn_cast(V)) { + if (const Type *STy = dyn_cast(V)) { + string Name = "struct l_" + makeNameProper(I->first); + Out << Name << ";\n"; + TypeNames.insert(std::make_pair(STy, Name)); + } + else { + string Name = "l_" + makeNameProper(I->first); + Out << "typedef "; + printType(Ty, Name, true); + Out << ";\n"; + } } + } } Out << "\n"; + // Loop over all structures then push them into the stack so they are + // printed in the correct order. for (SymbolTable::const_iterator TI = ST.begin(); TI != ST.end(); ++TI) { SymbolTable::type_const_iterator I = ST.type_begin(TI->first); SymbolTable::type_const_iterator End = ST.type_end(TI->first); for (; I != End; ++I) { - const Value *V = I->second; - if (const Type *Ty = dyn_cast(V)) { - string Name = "l_" + makeNameProper(I->first); - if (isa(Ty)) - Name = "struct " + makeNameProper(Name); - else - Out << "typedef "; + if (const StructType *STy = dyn_cast(I->second)) + parseStruct(STy); + } + } +} - printType(Ty, Name, true); - Out << ";\n"; - } +// Push the struct onto the stack and recursively push all structs +// this one depends on. +void CWriter::parseStruct(const Type *Ty) { + if (const StructType *STy = dyn_cast(Ty)){ + //Check to see if we have already printed this struct + if (StructPrinted.find(STy) == StructPrinted.end()){ + for (StructType::ElementTypes::const_iterator + I = STy->getElementTypes().begin(), + E = STy->getElementTypes().end(); I != E; ++I) { + const Type *Ty1 = dyn_cast(I->get()); + if (isa(Ty1) || isa(Ty1)) + parseStruct(Ty1); + } + + //Print struct + StructPrinted.insert(STy); + string Name = TypeNames[STy]; + printType(STy, Name, true); + Out << ";\n"; } + } + // If it is an array check it's type and continue + else if (const ArrayType *ATy = dyn_cast(Ty)){ + const Type *Ty1 = ATy->getElementType(); + if (isa(Ty1) || isa(Ty1)) + parseStruct(Ty1); } } From vadve at cs.uiuc.edu Sat Sep 14 17:19:01 2002 From: vadve at cs.uiuc.edu (vadve at cs.uiuc.edu) Date: Sat Sep 14 17:19:01 2002 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/RegAllocCommon.h Message-ID: <200209142218.RAA04298@morpheus.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: RegAllocCommon.h updated: 1.7 -> 1.8 --- Log message: Break RA_DEBUG option into several levels to get better output. --- Diffs of the changes: Index: llvm/include/llvm/CodeGen/RegAllocCommon.h diff -u /dev/null llvm/include/llvm/CodeGen/RegAllocCommon.h:1.8 --- /dev/null Sat Sep 14 17:18:41 2002 +++ llvm/include/llvm/CodeGen/RegAllocCommon.h Sat Sep 14 17:18:37 2002 @@ -0,0 +1,23 @@ +//===-- RegAllocCommon.h --------------------------------------------------===// +// +// Shared declarations for register allocation. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CODEGEN_REGALLOCCOMMON_H +#define LLVM_CODEGEN_REGALLOCCOMMON_H + +#include "Support/CommandLine.h" + +enum RegAllocDebugLevel_t { + RA_DEBUG_None = 0, + RA_DEBUG_Results = 1, + RA_DEBUG_Coloring = 2, + RA_DEBUG_Interference = 3, + RA_DEBUG_LiveRanges = 4, + RA_DEBUG_Verbose = 5 +}; + +extern RegAllocDebugLevel_t DEBUG_RA; + +#endif From vadve at cs.uiuc.edu Sat Sep 14 17:30:01 2002 From: vadve at cs.uiuc.edu (vadve at cs.uiuc.edu) Date: Sat Sep 14 17:30:01 2002 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/RegAlloc/RegAllocCommon.h Message-ID: <200209142229.RAA04510@morpheus.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/RegAlloc: RegAllocCommon.h (r1.8) removed --- Log message: Moving back to include/llvm/CodeGen until uses of DEBUG_RA in Sparc code can be eliminated. --- Diffs of the changes: From sabre at nondot.org Sat Sep 14 17:47:00 2002 From: sabre at nondot.org (Chris Lattner) Date: Sat Sep 14 17:47:00 2002 Subject: [llvm-commits] CVS: llvm/lib/CWriter/Writer.cpp In-Reply-To: <200209142136.QAA02148@trinity.cs.uiuc.edu> Message-ID: > Fixed problem with printing struct definitions in the correct order. > This allows for the > Regression/Transforms/ScalarReplacement/scalarize.c to run correctly. The change looks great. One comment though: The StructPrinted set is only used during the printing phase. Could you please move it so that instead of being part of the main CWriter object, it would be a temporary in the caller of parseStruct? ParseStruct would have to be modified to take the set as an argument (by reference) but other than that, everything should stay the same. Thanks again for fixing this bug! -Chris http://llvm.cs.uiuc.edu/ http://www.nondot.org/~sabre/Projects/ From vadve at cs.uiuc.edu Sat Sep 14 18:05:00 2002 From: vadve at cs.uiuc.edu (vadve at cs.uiuc.edu) Date: Sat Sep 14 18:05:00 2002 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/RegAllocCommon.h Message-ID: <200209142304.SAA04652@morpheus.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: RegAllocCommon.h updated: 1.8 -> 1.9 --- Log message: Remove unnecessary include. --- Diffs of the changes: Index: llvm/include/llvm/CodeGen/RegAllocCommon.h diff -u llvm/include/llvm/CodeGen/RegAllocCommon.h:1.8 llvm/include/llvm/CodeGen/RegAllocCommon.h:1.9 --- llvm/include/llvm/CodeGen/RegAllocCommon.h:1.8 Sat Sep 14 17:18:37 2002 +++ llvm/include/llvm/CodeGen/RegAllocCommon.h Sat Sep 14 18:04:52 2002 @@ -7,8 +7,6 @@ #ifndef LLVM_CODEGEN_REGALLOCCOMMON_H #define LLVM_CODEGEN_REGALLOCCOMMON_H -#include "Support/CommandLine.h" - enum RegAllocDebugLevel_t { RA_DEBUG_None = 0, RA_DEBUG_Results = 1, From vadve at cs.uiuc.edu Sat Sep 14 18:06:01 2002 From: vadve at cs.uiuc.edu (vadve at cs.uiuc.edu) Date: Sat Sep 14 18:06:01 2002 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/RegAlloc/IGNode.cpp InterferenceGraph.cpp LiveRangeInfo.cpp Makefile PhyRegAlloc.cpp RegClass.cpp Message-ID: <200209142305.SAA04672@morpheus.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/RegAlloc: IGNode.cpp updated: 1.6 -> 1.7 InterferenceGraph.cpp updated: 1.8 -> 1.9 LiveRangeInfo.cpp updated: 1.26 -> 1.27 Makefile updated: 1.1 -> 1.2 PhyRegAlloc.cpp updated: 1.74 -> 1.75 RegClass.cpp updated: 1.16 -> 1.17 --- Log message: Break RA_DEBUG option into several levels to get better control over debug output. --- Diffs of the changes: Index: llvm/lib/CodeGen/RegAlloc/IGNode.cpp diff -u llvm/lib/CodeGen/RegAlloc/IGNode.cpp:1.6 llvm/lib/CodeGen/RegAlloc/IGNode.cpp:1.7 --- llvm/lib/CodeGen/RegAlloc/IGNode.cpp:1.6 Mon Feb 4 22:20:07 2002 +++ llvm/lib/CodeGen/RegAlloc/IGNode.cpp Sat Sep 14 18:05:33 2002 @@ -1,3 +1,9 @@ +//===-- IGNode.cpp -------------------------------------------------------===// +// +// class IGNode for coloring-based register allocation for LLVM. +// +//===----------------------------------------------------------------------===// + #include "llvm/CodeGen/IGNode.h" #include #include Index: llvm/lib/CodeGen/RegAlloc/InterferenceGraph.cpp diff -u llvm/lib/CodeGen/RegAlloc/InterferenceGraph.cpp:1.8 llvm/lib/CodeGen/RegAlloc/InterferenceGraph.cpp:1.9 --- llvm/lib/CodeGen/RegAlloc/InterferenceGraph.cpp:1.8 Mon Apr 29 12:41:45 2002 +++ llvm/lib/CodeGen/RegAlloc/InterferenceGraph.cpp Sat Sep 14 18:05:33 2002 @@ -1,6 +1,12 @@ +//===-- InterferenceGraph.cpp ---------------------------------------------===// +// +// Interference graph for coloring-based register allocation for LLVM. +// +//===----------------------------------------------------------------------===// + #include "llvm/CodeGen/InterferenceGraph.h" -#include "Support/STLExtras.h" #include "llvm/CodeGen/RegAllocCommon.h" +#include "Support/STLExtras.h" #include using std::cerr; @@ -14,7 +20,7 @@ { IG = NULL; Size = 0; - if( DEBUG_RA) { + if( DEBUG_RA >= RA_DEBUG_Interference) { cerr << "Interference graph created!\n"; } } @@ -76,17 +82,15 @@ IGNode *const IGNode1 = LR1->getUserIGNode(); IGNode *const IGNode2 = LR2->getUserIGNode(); - if( DEBUG_RA) { - assertIGNode( IGNode1 ); - assertIGNode( IGNode2 ); - } + assertIGNode( IGNode1 ); + assertIGNode( IGNode2 ); const unsigned int row = IGNode1->getIndex(); const unsigned int col = IGNode2->getIndex(); char *val; - if( DEBUG_RA > 1) + if( DEBUG_RA >= RA_DEBUG_Interference > 1) cerr << "setting intf for: [" << row << "][" << col << "]\n"; ( row > col) ? val = &IG[row][col]: val = &IG[col][row]; @@ -107,11 +111,8 @@ const LiveRange *const LR2 ) const { assert(LR1 != LR2); - - if( DEBUG_RA) { - assertIGNode( LR1->getUserIGNode() ); - assertIGNode( LR2->getUserIGNode() ); - } + assertIGNode( LR1->getUserIGNode() ); + assertIGNode( LR2->getUserIGNode() ); const unsigned int row = LR1->getUserIGNode()->getIndex(); const unsigned int col = LR2->getUserIGNode()->getIndex(); @@ -144,7 +145,7 @@ assertIGNode( DestNode ); assertIGNode( SrcNode ); - if( DEBUG_RA > 1) { + if( DEBUG_RA >= RA_DEBUG_Interference > 1) { cerr << "Merging LRs: \""; printSet(*LR1); cerr << "\" and \""; printSet(*LR2); cerr << "\"\n"; Index: llvm/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp diff -u llvm/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp:1.26 llvm/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp:1.27 --- llvm/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp:1.26 Mon Jul 8 18:07:26 2002 +++ llvm/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp Sat Sep 14 18:05:33 2002 @@ -1,4 +1,11 @@ +//===-- LiveRangeInfo.cpp -------------------------------------------------===// +// +// Live range construction for coloring-based register allocation for LLVM. +// +//===----------------------------------------------------------------------===// + #include "llvm/CodeGen/LiveRangeInfo.h" +#include "llvm/CodeGen/RegAllocCommon.h" #include "llvm/CodeGen/RegClass.h" #include "llvm/CodeGen/MachineInstr.h" #include "llvm/CodeGen/MachineCodeForBasicBlock.h" @@ -6,7 +13,6 @@ #include "llvm/Function.h" #include "llvm/BasicBlock.h" #include "Support/SetOperations.h" -#include "llvm/CodeGen/RegAllocCommon.h" using std::cerr; LiveRangeInfo::LiveRangeInfo(const Function *F, const TargetMachine &tm, @@ -80,8 +86,8 @@ //--------------------------------------------------------------------------- void LiveRangeInfo::constructLiveRanges() { - if (DEBUG_RA) - cerr << "Consturcting Live Ranges ...\n"; + if (DEBUG_RA >= RA_DEBUG_LiveRanges) + cerr << "Constructing Live Ranges ...\n"; // first find the live ranges for all incoming args of the function since // those LRs start from the start of the function @@ -97,8 +103,8 @@ ArgRange->setRegClass(RegClassList[rcid]); - if( DEBUG_RA > 1) - cerr << " adding LiveRange for argument " << RAV(AI) << "\n"; + if( DEBUG_RA >= RA_DEBUG_LiveRanges) + cerr << " Adding LiveRange for argument " << RAV(AI) << "\n"; } // Now suggest hardware registers for these function args @@ -133,7 +139,7 @@ // iterate over MI operands to find defs for (MachineInstr::val_op_iterator OpI = MInst->begin(), OpE = MInst->end(); OpI != OpE; ++OpI) { - if(DEBUG_RA) { + if(DEBUG_RA >= RA_DEBUG_LiveRanges) { MachineOperand::MachineOperandType OpTyp = OpI.getMachineOperand().getOperandType(); @@ -161,7 +167,7 @@ DefRange->insert(Def); // add the instruction (def) to it LiveRangeMap[ Def ] = DefRange; // update the map - if (DEBUG_RA > 1) + if (DEBUG_RA >= RA_DEBUG_LiveRanges) cerr << " creating a LR for def: " << RAV(Def) << "\n"; // set the register class of the new live range @@ -174,7 +180,7 @@ OpI.getMachineOperand().getVRegValue(), isCC ); - if (isCC && DEBUG_RA) + if (isCC && DEBUG_RA >= RA_DEBUG_LiveRanges) cerr << "\a**created a LR for a CC reg:" << RAV(OpI.getMachineOperand().getVRegValue()); @@ -185,9 +191,8 @@ // to the merged set LiveRangeMap[Def] = DefRange; - if (DEBUG_RA > 1) - cerr << " added to an existing LR for def: " - << RAV(Def) << "\n"; + if (DEBUG_RA >= RA_DEBUG_LiveRanges) + cerr << " Added to existing LR for def: " << RAV(Def) << "\n"; } } // if isDef() @@ -205,7 +210,7 @@ suggestRegs4CallRets(); - if( DEBUG_RA) + if( DEBUG_RA >= RA_DEBUG_LiveRanges) cerr << "Initial Live Ranges constructed!\n"; } @@ -260,8 +265,8 @@ //--------------------------------------------------------------------------- void LiveRangeInfo::coalesceLRs() { - if(DEBUG_RA) - cerr << "\nCoalscing LRs ...\n"; + if(DEBUG_RA >= RA_DEBUG_LiveRanges) + cerr << "\nCoalescing LRs ...\n"; for(Function::const_iterator BBI = Meth->begin(), BBE = Meth->end(); BBI != BBE; ++BBI) { @@ -275,7 +280,7 @@ const MachineInstr * MInst = *MInstIterator; - if( DEBUG_RA > 1) { + if( DEBUG_RA >= RA_DEBUG_LiveRanges) { cerr << " *Iterating over machine instr "; MInst->dump(); cerr << "\n"; @@ -296,7 +301,7 @@ LiveRange *LROfUse = getLiveRangeForValue( *UseI ); if (!LROfUse) { // if LR of use is not found //don't warn about labels - if (!isa(*UseI) && DEBUG_RA) + if (!isa(*UseI) && DEBUG_RA >= RA_DEBUG_LiveRanges) cerr << " !! Warning: No LR for use " << RAV(*UseI) << "\n"; continue; // ignore and continue } @@ -331,8 +336,8 @@ } // for all machine instructions } // for all BBs - if (DEBUG_RA) - cerr << "\nCoalscing Done!\n"; + if (DEBUG_RA >= RA_DEBUG_LiveRanges) + cerr << "\nCoalescing Done!\n"; } @@ -347,8 +352,9 @@ cerr << "\nPrinting Live Ranges from Hash Map:\n"; for( ; HMI != LiveRangeMap.end(); ++HMI) { if (HMI->first && HMI->second) { - cerr << " " << RAV(HMI->first) << "\t: "; - printSet(*HMI->second); cerr << "\n"; + cerr << " Value* " << RAV(HMI->first) << "\t: "; + cerr << "LR# " << HMI->second->getUserIGNode()->getIndex(); + cerr << "\t:Values = "; printSet(*HMI->second); cerr << "\n"; } } } Index: llvm/lib/CodeGen/RegAlloc/Makefile diff -u llvm/lib/CodeGen/RegAlloc/Makefile:1.1 llvm/lib/CodeGen/RegAlloc/Makefile:1.2 --- llvm/lib/CodeGen/RegAlloc/Makefile:1.1 Fri Sep 14 19:31:44 2001 +++ llvm/lib/CodeGen/RegAlloc/Makefile Sat Sep 14 18:05:33 2002 @@ -4,4 +4,6 @@ LIBRARYNAME = regalloc +BUILD_ARCHIVE = 1 + include $(LEVEL)/Makefile.common Index: llvm/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp diff -u llvm/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp:1.74 llvm/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp:1.75 --- llvm/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp:1.74 Fri Aug 9 15:07:59 2002 +++ llvm/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp Sat Sep 14 18:05:33 2002 @@ -5,6 +5,7 @@ //===----------------------------------------------------------------------===// #include "llvm/CodeGen/RegisterAllocation.h" +#include "llvm/CodeGen/RegAllocCommon.h" #include "llvm/CodeGen/PhyRegAlloc.h" #include "llvm/CodeGen/MachineInstr.h" #include "llvm/CodeGen/MachineInstrAnnot.h" @@ -17,24 +18,25 @@ #include "llvm/Function.h" #include "llvm/Type.h" #include "llvm/iOther.h" -#include "llvm/CodeGen/RegAllocCommon.h" -#include "Support/CommandLine.h" #include "Support/STLExtras.h" #include using std::cerr; using std::vector; RegAllocDebugLevel_t DEBUG_RA; + static cl::opt DRA_opt("dregalloc", cl::Hidden, cl::location(DEBUG_RA), cl::desc("enable register allocation debugging information"), cl::values( - clEnumValN(RA_DEBUG_None , "n", "disable debug output"), - clEnumValN(RA_DEBUG_Normal , "y", "enable debug output"), - clEnumValN(RA_DEBUG_Verbose, "v", "enable extra debug output"), + clEnumValN(RA_DEBUG_None , "n", "disable debug output"), + clEnumValN(RA_DEBUG_Results, "y", "debug output for allocation results"), + clEnumValN(RA_DEBUG_Coloring, "c", "debug output for graph coloring step"), + clEnumValN(RA_DEBUG_Interference,"ig","debug output for interference graphs"), + clEnumValN(RA_DEBUG_LiveRanges , "lr","debug output for live ranges"), + clEnumValN(RA_DEBUG_Verbose, "v", "extra debug output"), 0)); - //---------------------------------------------------------------------------- // RegisterAllocation pass front end... //---------------------------------------------------------------------------- @@ -104,7 +106,7 @@ // and IGNodeList (one in each IG). The actual nodes will be pushed later. //---------------------------------------------------------------------------- void PhyRegAlloc::createIGNodeListsAndIGs() { - if (DEBUG_RA) cerr << "Creating LR lists ...\n"; + if (DEBUG_RA >= RA_DEBUG_LiveRanges) cerr << "Creating LR lists ...\n"; // hash map iterator LiveRangeMapType::const_iterator HMI = LRI.getLiveRangeMap()->begin(); @@ -116,18 +118,16 @@ if (HMI->first) { LiveRange *L = HMI->second; // get the LiveRange if (!L) { - if (DEBUG_RA) { - cerr << "\n*?!?Warning: Null liver range found for: " - << RAV(HMI->first) << "\n"; - } + if (DEBUG_RA) + cerr << "\n**** ?!?WARNING: NULL LIVE RANGE FOUND FOR: " + << RAV(HMI->first) << "****\n"; continue; } - // if the Value * is not null, and LR - // is not yet written to the IGNodeList + + // if the Value * is not null, and LR is not yet written to the IGNodeList if (!(L->getUserIGNode()) ) { RegClass *const RC = // RegClass of first value in the LR RegClassList[ L->getRegClass()->getID() ]; - RC->addLRToIG(L); // add this LR to an IG } } @@ -137,19 +137,17 @@ for ( unsigned rc=0; rc < NumOfRegClasses ; rc++) RegClassList[rc]->createInterferenceGraph(); - if (DEBUG_RA) - cerr << "LRLists Created!\n"; + if (DEBUG_RA >= RA_DEBUG_LiveRanges) cerr << "LRLists Created!\n"; } - - //---------------------------------------------------------------------------- // This method will add all interferences at for a given instruction. // Interence occurs only if the LR of Def (Inst or Arg) is of the same reg // class as that of live var. The live var passed to this function is the // LVset AFTER the instruction //---------------------------------------------------------------------------- + void PhyRegAlloc::addInterference(const Value *Def, const ValueSet *LVSet, bool isCallInst) { @@ -173,26 +171,16 @@ cerr << "< Def=" << RAV(Def) << ", Lvar=" << RAV(*LIt) << "> "; // get the live range corresponding to live var - // + // LiveRange *LROfVar = LRI.getLiveRangeForValue(*LIt); // LROfVar can be null if it is a const since a const // doesn't have a dominating def - see Assumptions above // - if (LROfVar) { - if (LROfDef == LROfVar) // do not set interf for same LR - continue; - - // if 2 reg classes are the same set interference - // - if (RCOfDef == LROfVar->getRegClass()) { - RCOfDef->setInterference( LROfDef, LROfVar); - } else if (DEBUG_RA >= RA_DEBUG_Verbose) { - // we will not have LRs for values not explicitly allocated in the - // instruction stream (e.g., constants) - cerr << " warning: no live range for " << RAV(*LIt) << "\n"; - } - } + if (LROfVar) + if (LROfDef != LROfVar) // do not set interf for same LR + if (RCOfDef == LROfVar->getRegClass()) // 2 reg classes are the same + RCOfDef->setInterference( LROfDef, LROfVar); } } @@ -208,7 +196,7 @@ void PhyRegAlloc::setCallInterferences(const MachineInstr *MInst, const ValueSet *LVSetAft) { - if (DEBUG_RA) + if (DEBUG_RA >= RA_DEBUG_Interference) cerr << "\n For call inst: " << *MInst; ValueSet::const_iterator LIt = LVSetAft->begin(); @@ -221,18 +209,17 @@ // LiveRange *const LR = LRI.getLiveRangeForValue(*LIt ); - if (LR && DEBUG_RA) { - cerr << "\n\tLR Aft Call: "; - printSet(*LR); - } - // LR can be null if it is a const since a const // doesn't have a dominating def - see Assumptions above // - if (LR ) { + if (LR ) { + if (DEBUG_RA >= RA_DEBUG_Interference) { + cerr << "\n\tLR after Call: "; + printSet(*LR); + } LR->setCallInterference(); - if (DEBUG_RA) { - cerr << "\n ++Added call interf for LR: " ; + if (DEBUG_RA >= RA_DEBUG_Interference) { + cerr << "\n ++After adding call interference for LR: " ; printSet(*LR); } } @@ -274,7 +261,8 @@ void PhyRegAlloc::buildInterferenceGraphs() { - if (DEBUG_RA) cerr << "Creating interference graphs ...\n"; + if (DEBUG_RA >= RA_DEBUG_Interference) + cerr << "Creating interference graphs ...\n"; unsigned BBLoopDepthCost; for (Function::const_iterator BBI = Meth->begin(), BBE = Meth->end(); @@ -351,9 +339,8 @@ // addInterferencesForArgs(); - if (DEBUG_RA) - cerr << "Interference graphs calculted!\n"; - + if (DEBUG_RA >= RA_DEBUG_Interference) + cerr << "Interference graphs calculated!\n"; } @@ -403,15 +390,16 @@ //---------------------------------------------------------------------------- // This method will add interferences for incoming arguments to a function. //---------------------------------------------------------------------------- + void PhyRegAlloc::addInterferencesForArgs() { // get the InSet of root BB const ValueSet &InSet = LVI->getInSetOfBB(&Meth->front()); - for (Function::const_aiterator AI = Meth->abegin(); AI != Meth->aend(); ++AI) { + for (Function::const_aiterator AI=Meth->abegin(); AI != Meth->aend(); ++AI) { // add interferences between args and LVars at start addInterference(AI, &InSet, false); - if (DEBUG_RA >= RA_DEBUG_Verbose) + if (DEBUG_RA >= RA_DEBUG_Interference) cerr << " - %% adding interference for argument " << RAV(AI) << "\n"; } } @@ -442,8 +430,8 @@ for (AdIt = IBef.begin(); AdIt != IBef.end() ; ++AdIt) { if (DEBUG_RA) { - if (OrigMI) cerr << "For MInst: " << *OrigMI; - cerr << msg << " PREPENDed instr: " << **AdIt << "\n"; + if (OrigMI) cerr << "For MInst:\n " << *OrigMI; + cerr << msg << "PREPENDed instr:\n " << **AdIt << "\n"; } MII = MIVec.insert(MII, *AdIt); ++MII; @@ -464,8 +452,8 @@ for ( AdIt = IAft.begin(); AdIt != IAft.end() ; ++AdIt ) { if (DEBUG_RA) { - if (OrigMI) cerr << "For MInst: " << *OrigMI; - cerr << msg << " APPENDed instr: " << **AdIt << "\n"; + if (OrigMI) cerr << "For MInst:\n " << *OrigMI; + cerr << msg << "APPENDed instr:\n " << **AdIt << "\n"; } ++MII; // insert before the next instruction MII = MIVec.insert(MII, *AdIt); @@ -674,9 +662,9 @@ AI.InstrnsAfter.insert(AI.InstrnsAfter.begin(), MIAft.begin(), MIAft.end()); if (DEBUG_RA) { - cerr << "\nFor Inst " << *MInst; - cerr << " - SPILLED LR: "; printSet(*LR); - cerr << "\n - Added Instructions:"; + cerr << "\nFor Inst:\n " << *MInst; + cerr << "SPILLED LR# " << LR->getUserIGNode()->getIndex(); + cerr << "; added Instructions:"; for_each(MIBef.begin(), MIBef.end(), std::mem_fun(&MachineInstr::dump)); for_each(MIAft.begin(), MIAft.end(), std::mem_fun(&MachineInstr::dump)); } @@ -1015,8 +1003,6 @@ void PhyRegAlloc::markUnusableSugColors() { - if (DEBUG_RA ) cerr << "\nmarking unusable suggested colors ...\n"; - // hash map iterator LiveRangeMapType::const_iterator HMI = (LRI.getLiveRangeMap())->begin(); LiveRangeMapType::const_iterator HMIEnd = (LRI.getLiveRangeMap())->end(); @@ -1048,7 +1034,7 @@ //---------------------------------------------------------------------------- void PhyRegAlloc::allocateStackSpace4SpilledLRs() { - if (DEBUG_RA) cerr << "\nsetting LR stack offsets ...\n"; + if (DEBUG_RA) cerr << "\nSetting LR stack offsets for spills...\n"; LiveRangeMapType::const_iterator HMI = LRI.getLiveRangeMap()->begin(); LiveRangeMapType::const_iterator HMIEnd = LRI.getLiveRangeMap()->end(); @@ -1056,8 +1042,13 @@ for ( ; HMI != HMIEnd ; ++HMI) { if (HMI->first && HMI->second) { LiveRange *L = HMI->second; // get the LiveRange - if (!L->hasColor()) // NOTE: ** allocating the size of long Type ** - L->setSpillOffFromFP(mcInfo.allocateSpilledValue(TM, Type::LongTy)); + if (!L->hasColor()) { // NOTE: ** allocating the size of long Type ** + int stackOffset = mcInfo.allocateSpilledValue(TM, Type::LongTy); + L->setSpillOffFromFP(stackOffset); + if (DEBUG_RA) + cerr << " LR# " << L->getUserIGNode()->getIndex() + << ": stack-offset = " << stackOffset << "\n"; + } } } // for all LR's in hash map } @@ -1077,7 +1068,7 @@ // LRI.constructLiveRanges(); // create LR info - if (DEBUG_RA) + if (DEBUG_RA >= RA_DEBUG_LiveRanges) LRI.printLiveRanges(); createIGNodeListsAndIGs(); // create IGNode list and IGs @@ -1085,7 +1076,7 @@ buildInterferenceGraphs(); // build IGs in all reg classes - if (DEBUG_RA) { + if (DEBUG_RA >= RA_DEBUG_LiveRanges) { // print all LRs in all reg classes for ( unsigned rc=0; rc < NumOfRegClasses ; rc++) RegClassList[rc]->printIGNodeList(); @@ -1099,7 +1090,7 @@ LRI.coalesceLRs(); // coalesce all live ranges - if (DEBUG_RA) { + if (DEBUG_RA >= RA_DEBUG_LiveRanges) { // print all LRs in all reg classes for ( unsigned rc=0; rc < NumOfRegClasses ; rc++) RegClassList[ rc ]->printIGNodeList(); @@ -1139,8 +1130,8 @@ updateMachineCode(); if (DEBUG_RA) { + cerr << "\n**** Machine Code After Register Allocation:\n\n"; MachineCodeForMethod::get(Meth).dump(); - printMachineCode(); // only for DEBUGGING } } Index: llvm/lib/CodeGen/RegAlloc/RegClass.cpp diff -u llvm/lib/CodeGen/RegAlloc/RegClass.cpp:1.16 llvm/lib/CodeGen/RegAlloc/RegClass.cpp:1.17 --- llvm/lib/CodeGen/RegAlloc/RegClass.cpp:1.16 Thu May 23 10:50:03 2002 +++ llvm/lib/CodeGen/RegAlloc/RegClass.cpp Sat Sep 14 18:05:33 2002 @@ -1,3 +1,9 @@ +//===-- RegClass.cpp -----------------------------------------------------===// +// +// class RegClass for coloring-based register allocation for LLVM. +// +//===----------------------------------------------------------------------===// + #include "llvm/CodeGen/RegClass.h" #include "llvm/CodeGen/RegAllocCommon.h" using std::cerr; @@ -11,7 +17,7 @@ const ReservedColorListType *RCL) : Meth(M), MRC(Mrc), RegClassID( Mrc->getRegClassID() ), IG(this), IGNodeStack(), ReservedColorList(RCL) { - if( DEBUG_RA) + if( DEBUG_RA >= RA_DEBUG_Interference) cerr << "Created Reg Class: " << RegClassID << "\n"; IsColorUsedArr.resize(Mrc->getNumOfAllRegs()); @@ -24,7 +30,8 @@ //---------------------------------------------------------------------------- void RegClass::colorAllRegs() { - if(DEBUG_RA) cerr << "Coloring IG of reg class " << RegClassID << " ...\n"; + if(DEBUG_RA >= RA_DEBUG_Coloring) + cerr << "Coloring IG of reg class " << RegClassID << " ...\n"; // pre-color IGNodes pushAllIGNodes(); // push all IG Nodes @@ -57,7 +64,7 @@ // push non-constrained IGNodes bool PushedAll = pushUnconstrainedIGNodes(); - if( DEBUG_RA) { + if( DEBUG_RA >= RA_DEBUG_Coloring) { cerr << " Puhsed all-unconstrained IGNodes. "; if( PushedAll ) cerr << " No constrained nodes left."; cerr << "\n"; @@ -88,7 +95,7 @@ // NeedMoreSpills = !pushUnconstrainedIGNodes(); - if (DEBUG_RA) + if (DEBUG_RA >= RA_DEBUG_Coloring) cerr << "\nConstrained IG Node found !@!" << IGNodeSpill->getIndex(); } while(NeedMoreSpills); // repeat until we have pushed all @@ -129,7 +136,7 @@ IGNodeStack.push( IGNode ); // push IGNode on to the stack IGNode->pushOnStack(); // set OnStack and dec deg of neighs - if (DEBUG_RA > 1) { + if (DEBUG_RA >= RA_DEBUG_Coloring) { cerr << " pushed un-constrained IGNode " << IGNode->getIndex() ; cerr << " on to stack\n"; } @@ -230,7 +237,7 @@ MRC->colorIGNode(Node, IsColorUsedArr); } else { - if( DEBUG_RA ) { + if( DEBUG_RA >= RA_DEBUG_Coloring) { cerr << " Node " << Node->getIndex(); cerr << " already colored with color " << Node->getColor() << "\n"; } @@ -238,7 +245,7 @@ if( !Node->hasColor() ) { - if( DEBUG_RA ) { + if( DEBUG_RA >= RA_DEBUG_Coloring) { cerr << " Node " << Node->getIndex(); cerr << " - could not find a color (needs spilling)\n"; } From lattner at cs.uiuc.edu Sun Sep 15 02:09:01 2002 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun Sep 15 02:09:01 2002 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp Message-ID: <200209150708.CAA08049@trinity.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/RegAlloc: PhyRegAlloc.cpp updated: 1.75 -> 1.76 --- Log message: RegAllocCommon no longer includes CommandLine.h so we have to include it here. --- Diffs of the changes: Index: llvm/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp diff -u llvm/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp:1.75 llvm/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp:1.76 --- llvm/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp:1.75 Sat Sep 14 18:05:33 2002 +++ llvm/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp Sun Sep 15 02:07:55 2002 @@ -19,6 +19,7 @@ #include "llvm/Type.h" #include "llvm/iOther.h" #include "Support/STLExtras.h" +#include "Support/CommandLine.h" #include using std::cerr; using std::vector; From vadve at cs.uiuc.edu Sun Sep 15 10:34:01 2002 From: vadve at cs.uiuc.edu (vadve at cs.uiuc.edu) Date: Sun Sep 15 10:34:01 2002 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/RegAlloc/InterferenceGraph.cpp Message-ID: <200209151533.KAA06367@morpheus.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/RegAlloc: InterferenceGraph.cpp updated: 1.9 -> 1.10 --- Log message: Fix typos in previous checkin. --- Diffs of the changes: Index: llvm/lib/CodeGen/RegAlloc/InterferenceGraph.cpp diff -u llvm/lib/CodeGen/RegAlloc/InterferenceGraph.cpp:1.9 llvm/lib/CodeGen/RegAlloc/InterferenceGraph.cpp:1.10 --- llvm/lib/CodeGen/RegAlloc/InterferenceGraph.cpp:1.9 Sat Sep 14 18:05:33 2002 +++ llvm/lib/CodeGen/RegAlloc/InterferenceGraph.cpp Sun Sep 15 10:33:48 2002 @@ -90,7 +90,7 @@ char *val; - if( DEBUG_RA >= RA_DEBUG_Interference > 1) + if( DEBUG_RA >= RA_DEBUG_Interference) cerr << "setting intf for: [" << row << "][" << col << "]\n"; ( row > col) ? val = &IG[row][col]: val = &IG[col][row]; @@ -145,7 +145,7 @@ assertIGNode( DestNode ); assertIGNode( SrcNode ); - if( DEBUG_RA >= RA_DEBUG_Interference > 1) { + if( DEBUG_RA >= RA_DEBUG_Interference) { cerr << "Merging LRs: \""; printSet(*LR1); cerr << "\" and \""; printSet(*LR2); cerr << "\"\n"; From vadve at cs.uiuc.edu Sun Sep 15 11:34:01 2002 From: vadve at cs.uiuc.edu (vadve at cs.uiuc.edu) Date: Sun Sep 15 11:34:01 2002 Subject: [llvm-commits] CVS: llvm/makellvm Message-ID: <200209151633.LAA06911@morpheus.cs.uiuc.edu> Changes in directory llvm: makellvm added (r1.1) --- Log message: Shell-script to build current directory and then link one tool (default: opt) --- Diffs of the changes: From vadve at cs.uiuc.edu Sun Sep 15 11:46:01 2002 From: vadve at cs.uiuc.edu (vadve at cs.uiuc.edu) Date: Sun Sep 15 11:46:01 2002 Subject: [llvm-commits] CVS: llvm/cvsupdate Message-ID: <200209151645.LAA07001@morpheus.cs.uiuc.edu> Changes in directory llvm: cvsupdate updated: 1.2 -> 1.3 --- Log message: Check error condition after cvs returns. Also remove -c option. --- Diffs of the changes: Index: llvm/cvsupdate diff -u llvm/cvsupdate:1.2 llvm/cvsupdate:1.3 --- llvm/cvsupdate:1.2 Mon Apr 29 14:11:01 2002 +++ llvm/cvsupdate Sun Sep 15 11:45:10 2002 @@ -1,4 +1,4 @@ -#!/bin/csh -f -c +#!/bin/csh -f # # This script updates the entire tree, saves the output in cvs.out, # and then separately prints out the files that had merge conflicts, @@ -31,6 +31,11 @@ if ($doit == 1) then /bin/mv -f cvs.out cvs.out.bak cvs update -P -d >& cvs.out + if ($status != 0) then + echo "ERROR: CVS update failed: " + cat cvs.out + exit 1 + endif else echo ""; echo "Not updating files."; echo "" endif From vadve at cs.uiuc.edu Sun Sep 15 11:59:01 2002 From: vadve at cs.uiuc.edu (vadve at cs.uiuc.edu) Date: Sun Sep 15 11:59:01 2002 Subject: [llvm-commits] CVS: llvm/makellvm Message-ID: <200209151658.LAA07212@morpheus.cs.uiuc.edu> Changes in directory llvm: makellvm updated: 1.1 -> 1.2 --- Log message: Use much better method to find the llvmbase directory. Also, add -h option to print usage information. --- Diffs of the changes: Index: llvm/makellvm diff -u llvm/makellvm:1.1 llvm/makellvm:1.2 --- llvm/makellvm:1.1 Sun Sep 15 11:33:32 2002 +++ llvm/makellvm Sun Sep 15 11:58:30 2002 @@ -1,9 +1,16 @@ #!/bin/csh -f -set LLVMDIR = $HOME/llvm + ## LLVMDIR is simply the directory where this script resides! +set THISEXEC = $0 ## cannot use :h on $0 for some reason +set LLVMDIR = $THISEXEC:h set EXEC = opt if ($#argv > 0) then + if (&& $argv[1] == "-h") then + echo 'USAGE: makellvm [toolname] (toolname defaults to "opt").' + exit 0 + endif + set EXEC = NO_SUCH_TOOL set TOOLS = `grep DIRS ${LLVMDIR}/tools/Makefile | sed 's/DIRS[ ]*=[ ]*//'` foreach T ( $TOOLS ) From vadve at cs.uiuc.edu Sun Sep 15 13:23:01 2002 From: vadve at cs.uiuc.edu (vadve at cs.uiuc.edu) Date: Sun Sep 15 13:23:01 2002 Subject: [llvm-commits] CVS: llvm/makellvm Message-ID: <200209151822.NAA08536@morpheus.cs.uiuc.edu> Changes in directory llvm: makellvm updated: 1.2 -> 1.3 --- Log message: Simplify significantly (and fix syntax error). --- Diffs of the changes: Index: llvm/makellvm diff -u llvm/makellvm:1.2 llvm/makellvm:1.3 --- llvm/makellvm:1.2 Sun Sep 15 11:58:30 2002 +++ llvm/makellvm Sun Sep 15 13:22:47 2002 @@ -6,20 +6,11 @@ set EXEC = opt if ($#argv > 0) then - if (&& $argv[1] == "-h") then + if ($argv[1] == "-h") then echo 'USAGE: makellvm [toolname] (toolname defaults to "opt").' exit 0 endif - - set EXEC = NO_SUCH_TOOL - set TOOLS = `grep DIRS ${LLVMDIR}/tools/Makefile | sed 's/DIRS[ ]*=[ ]*//'` - foreach T ( $TOOLS ) - if ($argv[1] == "$T") then - set EXEC = $T - shift argv - break - endif - end + set EXEC = $argv[1] endif gnumake && (cd $LLVMDIR/tools/$EXEC && gnumake) From ashukla at cs.uiuc.edu Sun Sep 15 15:36:01 2002 From: ashukla at cs.uiuc.edu (Anand Shukla) Date: Sun Sep 15 15:36:01 2002 Subject: [llvm-commits] CVS: llvm/lib/Reoptimizer/Trigger/Trigger.cpp Message-ID: <200209152035.PAA12936@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Reoptimizer/Trigger: Trigger.cpp updated: 1.6 -> 1.7 --- Log message: Updated trigger function: it removes fall through branches and modifies other branches appropriately! --- Diffs of the changes: Index: llvm/lib/Reoptimizer/Trigger/Trigger.cpp diff -u llvm/lib/Reoptimizer/Trigger/Trigger.cpp:1.6 llvm/lib/Reoptimizer/Trigger/Trigger.cpp:1.7 --- llvm/lib/Reoptimizer/Trigger/Trigger.cpp:1.6 Thu Aug 1 03:00:11 2002 +++ llvm/lib/Reoptimizer/Trigger/Trigger.cpp Sun Sep 15 15:35:05 2002 @@ -7,8 +7,9 @@ // //===----------------------------------------------------------------------===// -#include "llvm/Transforms/Instrumentation/Graph.h" #include "llvm/Reoptimizer/TraceCache.h" +#include "llvm/Reoptimizer/VirtualMem.h" +#include "llvm/Reoptimizer/InstrUtils.h" #include "llvm/Reoptimizer/Mapping/LLVMinfo.h" #include "llvm/Bytecode/Reader.h" #include "llvm/Module.h" @@ -20,14 +21,23 @@ #include #include +using std::vector; + extern int llvm_length; extern const unsigned char LLVMBytecode[]; extern void** llvmFunctionTable[]; -uint64_t getBranchAddr(TraceCache &tempTrace, uint64_t n){ - - return tempTrace.getBranchAddr(std::make_pair(n,n)); + +void getBBtrace(vector &vBB, int pathNo, Function *M); + +void printTrace(vector &vBB, int pn){ + std::cerr<<"Path no:"<::iterator VVI = vBB.begin(), VVE = vBB.end(); + VVI!=VVE; ++VVI) + std::cerr<<*VVI; + std::cerr<<"End of path----\n"; } + extern "C" void trigger(int mn, int pn, int cnt){ static bool initialized = false; //so module is read just once static Module *M; @@ -57,299 +67,367 @@ assert(M && "Module unparsed!"); assert(funcList[mn] && "Function not parsed!"); - - - /* for(Module::iterator FI=M->begin(), FE=M->end(); FI!=FE; ++FI){ - for(Function::iterator BI=FI->begin(), BE=FI->end(); BI!=BE; ++BI){ - for( BasicBlock::iterator II=BI->begin(), IE=BI->end(); II!=IE; ++II){ - std::cerr<<"I:\t"< check = getLLVMInstrInfo(II); - for(unsigned i=0; i vBB; - - //std::cerr<<"Meth: "< traceInstructions; - std::vector > outB; - unsigned count=0; - //std::cerr<<"traceInstructions and outB\n"; - for(std::vector::iterator VBI=vBB.begin(); VBI!=vBB.end(); ++VBI){ - std::pair BBinfo=getBasicBlockInfo(*VBI); - //std::cerr<<"BB start and end: "< inB; - //std::cerr<<"inB\n"; - for(BasicBlock::pred_iterator inBI = pred_begin(vBB[0]), inBE=pred_end(vBB[0]); - inBI!=inBE; ++inBI){ - //std::cerr<<"gets here\n"; - vector inBMI = - getLLVMInstrInfo((Instruction *)((*inBI)->getTerminator())); - //std::cerr<<"gets here2\n"; - for(unsigned i=0; ifront() || + isa(vBB[vBB.size()-1]->getTerminator())){ + //std::cerr<<"Found a path starting with root!\n"; + return; } - newTrace.addTrace(firstInstructionAdd , &traceInstructions[0], - traceInstructions.size(), inB , outB ,pn); - - - //std::cerr<<"------------------------------------ path --------\n"; - //for(std::vector::iterator VBI=vBB.begin(); VBI!=vBB.end(); - //++VBI){ - //BasicBlock *BB=*VBI; - //std::cerr<<*BB; - - //TerminatorInst *tti = BB->getTerminator(); - //std::cerr<<*tti; - //std::vector vt = getLLVMInstrInfo(tti); - //for(vector::iterator VI = vt.begin(), VE = vt.end(); - //VI!=VE; ++VI){ - //unsigned int a = *VI;//(unsigned int *)*VI; - //std::cerr<<"add:"<<(void *)*VI<<"\n";//a<<"\n";//<<" inst:"<<*a<<"\n"; - //} - - // std::cerr<<"--------- BB end\n"; - //} - //std::cerr<<"\n--------------\n"; - -} - -using std::vector; - -void getPathFrmNode(Node *n, vector &vBB, int pathNo, Graph g, - vector &stDummy, vector &exDummy, - vector &be, - double strand){ - Graph::nodeList nlist=g.getNodeList(n); - - //printGraph(g); - int maxCount=-9999999; - bool isStart=false; - - if(*n==*g.getRoot())//its root: so first node of path - isStart=true; - - double edgeRnd=0; - Node *nextRoot=n; - for(Graph::nodeList::iterator NLI=nlist.begin(), NLE=nlist.end(); NLI!=NLE; - ++NLI){ - if(NLI->weight>maxCount && NLI->weight<=pathNo){ - maxCount=NLI->weight; - nextRoot=NLI->element; - edgeRnd=NLI->randId; - if(isStart) - strand=NLI->randId; + //check if loop is not formed + TerminatorInst *Tcheck = vBB[vBB.size()-1]->getTerminator(); + BranchInst *Bcheck = cast(Tcheck); + if(Bcheck->isConditional()){ + if((vBB[0] != Bcheck->getSuccessor(0)) && + (vBB[0] != Bcheck->getSuccessor(1))){ + std::cerr<<"Not a loop!\n"; + return; } } - - if(!isStart) - assert(strand!=-1 && "strand not assigned!"); - - assert(!(*nextRoot==*n && pathNo>0) && "No more BBs to go"); - assert(!(*nextRoot==*g.getExit() && pathNo-maxCount!=0) && "Reached exit"); - - //std::cerr<<"inserting############ \n"; - //std::cerr<<*(n->getElement()); - vBB.push_back(n->getElement()); - - if(pathNo-maxCount==0 && *nextRoot==*g.getExit()){ - - //look for strnd and edgeRnd now: - bool has1=false, has2=false; - //check if exit has it - for(vector::iterator VI=exDummy.begin(), VE=exDummy.end(); VI!=VE; - ++VI){ - if(VI->getRandId()==edgeRnd){ - has2=true; - break; - } + else{ + if(vBB[0] != Bcheck->getSuccessor(0)){ + std::cerr<<"Not a loop!\n"; + return; } + } + + static VirtualMem *vm = new VirtualMem(); + static TraceCache *tr = new TraceCache(); - //check if start has it - for(vector::iterator VI=stDummy.begin(), VE=stDummy.end(); VI!=VE; - ++VI){ - if(VI->getRandId()==strand){ - has1=true; - break; - } - } + std::pair firtBBLimits = getBasicBlockInfo(*(vBB.begin())); + uint64_t startAddr = firtBBLimits.first; - if(has1){ - //find backedge with endpoint vBB[1] - for(vector::iterator VI=be.begin(), VE=be.end(); VI!=VE; ++VI){ - assert(vBB.size()>0 && "vector too small"); - if( VI->getSecond()->getElement() == vBB[1] ){ - //vBB[0]=VI->getFirst()->getElement(); - vBB.erase(vBB.begin()); - break; - } - } - } + assert(startAddr && "startAddr should have been defined!"); - if(has2){ - //find backedge with startpoint vBB[vBB.size()-1] - for(vector::iterator VI=be.begin(), VE=be.end(); VI!=VE; ++VI){ - assert(vBB.size()>0 && "vector too small"); - if( VI->getFirst()->getElement() == vBB[vBB.size()-1] && - VI->getSecond()->getElement() == vBB[0]){ - //vBB.push_back(VI->getSecond()->getElement()); - break; - } - } - } - else - vBB.push_back(nextRoot->getElement()); - + //return if SAME trace already there! + if(tr->hasTraceAddr(startAddr) && tr->hasTraceId(pn)){ + std::cerr<<"Trace exists!!!\n"; return; } - assert(pathNo-maxCount>=0); - - return getPathFrmNode(nextRoot, vBB, pathNo-maxCount, g, stDummy, - exDummy, be, strand); -} - - -static Node *findBB(std::vector &st, BasicBlock *BB){ - for(std::vector::iterator si=st.begin(); si!=st.end(); ++si){ - if(((*si)->getElement())==BB){ - return *si; - } + if(tr->hasTraceAddr(startAddr)){ + std::cerr<<"Removing old trace!\n"; + tr->removeTrace(startAddr); } - return NULL; -} -void getBBtrace(vector &vBB, int pathNo, Function *M){ - //step 1: create graph - //Transform the cfg s.t. we have just one exit node + //the trace of instructions + vector trace; - //std::cerr<< "Inside bbtrace! path:"<dump(); - - std::vector nodes; - std::vector edges; - Node *tmp; - Node *exitNode=0, *startNode=0; - static std::map graphMap; - static std::map > stMap, exMap, beMap; - - if(!graphMap[M]){ - BasicBlock *ExitNode = 0; - for (Function::iterator I = M->begin(), E = M->end(); I != E; ++I){ - if (isa(I->getTerminator())) { - ExitNode = I; - break; - } - } + //map of call instructions + std::map callMap; - assert(ExitNode!=0 && "exitnode not found"); - - //iterating over BBs and making graph - //The nodes must be uniquely identified: - //That is, no two nodes must hav same BB* + //map of branches + std::map branchMap; //branch at index, was located at PC - //First enter just nodes: later enter edges - for(Function::iterator BB = M->begin(), BE=M->end(); BB != BE; ++BB){ - Node *nd=new Node(BB); - nodes.push_back(nd); - if(&*BB==ExitNode) - exitNode=nd; - if(&*BB==&M->front()) - startNode=nd; - } - - assert(exitNode!=0 && startNode!=0 && "Start or exit not found!"); - - for (Function::iterator BB = M->begin(), BE=M->end(); BB != BE; ++BB){ - Node *nd=findBB(nodes, BB); - assert(nd && "No node for this edge!"); - - for(BasicBlock::succ_iterator s=succ_begin(&*BB), se=succ_end(&*BB); - s!=se; ++s){ - Node *nd2=findBB(nodes,*s); - assert(nd2 && "No node for this edge!"); - Edge ed(nd,nd2,0); - edges.push_back(ed); + int instIndex = 0; + + //Now iterate ove trace of BBs, and insert them into the cache + for(vector::iterator VBI = vBB.begin(), VBE = vBB.end(); + VBI!=VBE; ++VBI){ + + //Take the first instr of the basic block, and insert + //all instructions uptil the end of basic block in the trace + std::pair bbInst = getBasicBlockInfo(*VBI); + + //set various flags + bool isCondBranch = false; + bool hasNextBB = false; + bool hasTrueIndex = false; + + //see if terminator is a conditional branch + TerminatorInst *TI = (*VBI)->getTerminator(); + if(isa(TI)){ + BranchInst *BI = cast(TI); + if(BI->isConditional()){ + isCondBranch = true; + + //see if next BB is in vBB + if(VBI != vBB.end()-1 && BI->getSuccessor(0) == *(VBI+1) ){ + hasNextBB = true; + hasTrueIndex = true; + } + else if(VBI != vBB.end()-1 && BI->getSuccessor(1) == *(VBI+1) ) + hasNextBB = true; + } + else{//is unconditional branch + assert(BI->isUnconditional() && "Ought to be unconditional branch!"); + if(VBI != vBB.end()-1 && BI->getSuccessor(0) == *(VBI+1) ){ + hasNextBB = true; + } + } + } + + if(VBI != vBB.end()-1){//so its NOT last BB + assert(hasNextBB && "Next BB not in sequence!"); + } + + //Now, the last inst corresponding to the BB MAY or MAY NOT be included + //in the returned addresses. So leave last two instructions + //Now if unconditional branch, then read until last 2, + //if unconditional branch + //then read until last 4 + int skipIndex = (isCondBranch ? 4:2); + + std::cerr<<"From->to"<<(void *)bbInst.first<<"->"<<(void *)(bbInst.second-4*skipIndex)<<"\n"; + + for(uint64_t addr = bbInst.first, endAddr = bbInst.second; + addr<=endAddr-4*skipIndex; addr+=4, instIndex++){ + unsigned inst = vm->readInstrFrmVm(addr); + + trace.push_back(inst); + //handle call instructions later! + if(isCallInstr(inst)){ + callMap[instIndex] = addr; + std::cerr<<(void *)inst; + std::cerr<<"\t\tcall is index:"<readInstrFrmVm(bbInst.second-12); + unsigned int br1, ds1, br2, ds2; + uint64_t addrbr1, addrbr2; + if(isBranchInstr(instrCheck)){ + br1 = instrCheck; + addrbr1 = bbInst.second-12; + ds1 = vm->readInstrFrmVm(bbInst.second-8); + br2 = vm->readInstrFrmVm(bbInst.second-4); + addrbr2 = bbInst.second-4; + ds2 = vm->readInstrFrmVm(bbInst.second); + } + else{ + trace.push_back(instrCheck); + + if(isCallInstr(instrCheck)){ + callMap[instIndex] = bbInst.second - 12; + std::cerr<<(void *)instrCheck; + std::cerr<<"\t\tcall is index:"<readInstrFrmVm(bbInst.second-8); + addrbr1 = bbInst.second-8; + ds1 = vm->readInstrFrmVm(bbInst.second-4); + br2 = vm->readInstrFrmVm(bbInst.second); + addrbr2 = bbInst.second; + ds2 = vm->readInstrFrmVm(bbInst.second+4); + } + + assert(isBranchInstr(br1) && isBranchInstr(br2) && "Not a branch!"); + + if(hasNextBB){ + //eliminate one of the branches! + std::vector::iterator VBNext = VBI+1; + std::pair bbDest = getBasicBlockInfo(*VBNext); + //get branch br1 and br2 targets to check if any matches bbDest + uint64_t tar1, tar2; + if(isNonDepJump(br1)) + tar1 = getNonDepJmpTarget(br1, addrbr1); + else if(isDepJump(br1)) + tar1 = getDepJmpTarget(br1, addrbr1); + else if(isBPR(br1)) + tar1 = getBPRTarget(br1, addrbr1); + else{ + std::cerr<<(void *)br1<<"\n"; + assert(false && "Branch not handled 1!"); + } + + if(isNonDepJump(br2)) + tar2 = getNonDepJmpTarget(br2, addrbr2); + else if(isDepJump(br2)) + tar2 = getDepJmpTarget(br2, addrbr2); + else + assert(false && "Branch not handled!"); + + assert( (tar1 == bbDest.first || tar2 == bbDest.first) && + "No destination matched for consecutive BBs"); + + if(tar1 == bbDest.first){ + //check that second branch is ba, or bn + assert( (isBranchAlways(br2) || isBranchNever(br2) ) && + "Branch 2 should have been branch always, or branch never!"); + + //so invert branch condition, make it second branch, + //and eliminate first branch! + + //take the target of br2 and inverted condition of br1 + std::pair invertedBranch = + vm->getInvertedBranch(br1, br2); + + //insert ds1, br2, ds2 in the trace (in that order) + //store branches and PCs for later correction in branchMap + + trace.push_back(ds1); + instIndex++; + if(invertedBranch.first != 0){ + trace.push_back(invertedBranch.first); + instIndex++; + } + trace.push_back(invertedBranch.second); + branchMap[instIndex] = addrbr2; + trace.push_back(ds2); + //trace.push_back(ds1); + instIndex += 2; + } + else{ + //erase second branch + //insert into trace br1, ds1, ds2 + + trace.push_back(br1); + //store branch index and PC for later correction in branchMap + branchMap[instIndex] = addrbr1; + if(isBPR(br1)){ + trace.push_back(0); + instIndex++; + } + trace.push_back(ds1); + trace.push_back(ds2); + + instIndex += 3; + } + } + else{//So it must be last BB in sequence! + + //check that it points to first BB + std::pair bbDest = getBasicBlockInfo(*(vBB.begin())); + //get branch br1 and br2 targets to check if any matches bbDest + uint64_t tar1, tar2; + if(isNonDepJump(br1)) + tar1 = getNonDepJmpTarget(br1, addrbr1); + else if(isDepJump(br1)) + tar1 = getDepJmpTarget(br1, addrbr1); + else + assert(false && "Branch not handled!"); + + if(isNonDepJump(br2)) + tar2 = getNonDepJmpTarget(br2, addrbr2); + else if(isDepJump(br2)) + tar2 = getDepJmpTarget(br2, addrbr2); + else + assert(false && "Branch not handled!"); + + assert( (tar1 == bbDest.first || tar2 == bbDest.first) && + "Last BB must point to first BB"); + + //insert code + trace.push_back(br1); + branchMap[instIndex] = addrbr1; + if(isBPR(br1)){ + trace.push_back(0); + instIndex++; + } + + trace.push_back(ds1); + + trace.push_back(br2); + branchMap[instIndex+2] = addrbr2; + if(isBPR(br2)){ + trace.push_back(0); + instIndex++; + } + + trace.push_back(ds2); + instIndex += 4; + } + } + //is unconditional branch + else{ + unsigned int instrCheck = vm->readInstrFrmVm(bbInst.second-4); + unsigned int br1, ds1; + uint64_t addrbr1; + if(isBranchInstr(instrCheck)){ + br1 = instrCheck; + addrbr1 = bbInst.second-4; + ds1 = vm->readInstrFrmVm(bbInst.second); + } + else{ + trace.push_back(instrCheck); + + if(isCallInstr(instrCheck)){ + callMap[instIndex] = bbInst.second - 4; + std::cerr<<(void *)instrCheck; + std::cerr<<"\t\tcall is index:"<readInstrFrmVm(bbInst.second); + addrbr1 = bbInst.second; + ds1 = vm->readInstrFrmVm(bbInst.second+4); + } + + std::cerr<<"Branch: "<<(void *)br1<<"\n"; + assert( (isBranchAlways(br1) || isBranchNever(br1) ) && + "Unconditional branch: should be branch always, or branch never!"); + + //now do fancy stuff! + //if branch points to the next BB, then erase it + if(hasNextBB){ + std::pair bbDest = getBasicBlockInfo(*(VBI+1)); + + //get branch br1 target to check if it matches bbDest + uint64_t tar1, tar2; + + if(isNonDepJump(br1)) + tar1 = getNonDepJmpTarget(br1, addrbr1); + else if(isDepJump(br1)) + tar1 = getDepJmpTarget(br1, addrbr1); + else if(isBPR(br1)) + tar1 = getBPRTarget(br1, addrbr1); + else{ + std::cerr<<(void *)br1<<"\n"; + assert(false && "Branch not handled!"); + } + + //copy ds1, and tht's all + trace.push_back(ds1); + instIndex++; + } + else{ + //Must be last BB. check for coninuity! + std::pair bbDest = + getBasicBlockInfo(*(vBB.begin())); + + uint64_t tar1; + if(isNonDepJump(br1)) + tar1 = getNonDepJmpTarget(br1, addrbr1); + else if(isDepJump(br1)) + tar1 = getDepJmpTarget(br1, addrbr1); + else if(isBPR(br1)) + tar1 = getBPRTarget(br1, addrbr1); + else{ + std::cerr<<(void *)br1<<"\n"; + assert(false && "Branch not handled!"); + } + + assert(tar1 == bbDest.first && "Last BB must point to first BB"); + trace.push_back(br1); + branchMap[instIndex] = addrbr1; + trace.push_back(ds1); + + instIndex += 2; } } - - graphMap[M]= new Graph(nodes,edges, startNode, exitNode); - - Graph *g = graphMap[M]; - - if (M->size() <= 1) return; //uninstrumented - - //step 2: getBackEdges - //vector be; - std::map nodePriority; - g->getBackEdges(beMap[M], nodePriority); - - //step 3: add dummy edges - //vector stDummy; - //vector exDummy; - addDummyEdges(stMap[M], exMap[M], *g, beMap[M]); - - //step 4: value assgn to edges - int numPaths = valueAssignmentToEdges(*g, nodePriority); - //printGraph(*g); } - - //print graph - //printGraph(g); - - //step 5: now travel from root, select max(edge) < pathNo, - //and go on until reach the exit - return getPathFrmNode(graphMap[M]->getRoot(), vBB, pathNo, *graphMap[M], stMap[M], exMap[M], beMap[M], -1); + + //Now add trace to cache, and we are all set! + if(!tr->addTrace(startAddr, trace, pn, callMap, branchMap)) + std::cerr<<"^^^^^^^^^^************** Trace could not be added!!!\n"; } From ashukla at cs.uiuc.edu Sun Sep 15 15:37:02 2002 From: ashukla at cs.uiuc.edu (Anand Shukla) Date: Sun Sep 15 15:37:02 2002 Subject: [llvm-commits] CVS: llvm/lib/Reoptimizer/TraceCache/InstrUtils.cpp Message-ID: <200209152036.PAA12968@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Reoptimizer/TraceCache: InstrUtils.cpp added (r1.1) --- Log message: TraceCache.cpp is reorganized and split into multiple files --- Diffs of the changes: From ashukla at cs.uiuc.edu Sun Sep 15 15:37:08 2002 From: ashukla at cs.uiuc.edu (Anand Shukla) Date: Sun Sep 15 15:37:08 2002 Subject: [llvm-commits] CVS: llvm/lib/Reoptimizer/TraceCache/VirtualMem.cpp Message-ID: <200209152036.PAA12982@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Reoptimizer/TraceCache: VirtualMem.cpp added (r1.1) --- Log message: TraceCache.cpp is reorganized and split into multiple files --- Diffs of the changes: From ashukla at cs.uiuc.edu Sun Sep 15 15:37:15 2002 From: ashukla at cs.uiuc.edu (Anand Shukla) Date: Sun Sep 15 15:37:15 2002 Subject: [llvm-commits] CVS: llvm/lib/Reoptimizer/TraceCache/MemoryManager.cpp Message-ID: <200209152036.PAA12995@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Reoptimizer/TraceCache: MemoryManager.cpp added (r1.1) --- Log message: TraceCache.cpp is reorganized and split into multiple files --- Diffs of the changes: From ashukla at cs.uiuc.edu Sun Sep 15 15:38:01 2002 From: ashukla at cs.uiuc.edu (Anand Shukla) Date: Sun Sep 15 15:38:01 2002 Subject: [llvm-commits] CVS: llvm/lib/Reoptimizer/TraceCache/Makefile Message-ID: <200209152037.PAA13014@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Reoptimizer/TraceCache: Makefile added (r1.1) --- Log message: TraceCache.cpp is reorganized and split into multiple files --- Diffs of the changes: From ashukla at cs.uiuc.edu Sun Sep 15 15:39:00 2002 From: ashukla at cs.uiuc.edu (Anand Shukla) Date: Sun Sep 15 15:39:00 2002 Subject: [llvm-commits] CVS: llvm/lib/Reoptimizer/Makefile Message-ID: <200209152038.PAA13036@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Reoptimizer: Makefile updated: 1.5 -> 1.6 --- Log message: Added TraceCache --- Diffs of the changes: Index: llvm/lib/Reoptimizer/Makefile diff -u llvm/lib/Reoptimizer/Makefile:1.5 llvm/lib/Reoptimizer/Makefile:1.6 --- llvm/lib/Reoptimizer/Makefile:1.5 Tue Aug 27 17:04:09 2002 +++ llvm/lib/Reoptimizer/Makefile Sun Sep 15 15:38:43 2002 @@ -1,4 +1,4 @@ LEVEL = ../.. -DIRS = Mapping +DIRS = Mapping TraceCache include $(LEVEL)/Makefile.common From ashukla at cs.uiuc.edu Sun Sep 15 15:41:01 2002 From: ashukla at cs.uiuc.edu (Anand Shukla) Date: Sun Sep 15 15:41:01 2002 Subject: [llvm-commits] CVS: llvm/include/llvm/Reoptimizer/InstrUtils.h Message-ID: <200209152040.PAA13053@trinity.cs.uiuc.edu> Changes in directory llvm/include/llvm/Reoptimizer: InstrUtils.h added (r1.1) --- Log message: Interface for modifying Sparc instructions --- Diffs of the changes: From ashukla at cs.uiuc.edu Sun Sep 15 15:41:08 2002 From: ashukla at cs.uiuc.edu (Anand Shukla) Date: Sun Sep 15 15:41:08 2002 Subject: [llvm-commits] CVS: llvm/include/llvm/Reoptimizer/TraceCache.h Message-ID: <200209152040.PAA13066@trinity.cs.uiuc.edu> Changes in directory llvm/include/llvm/Reoptimizer: TraceCache.h updated: 1.1 -> 1.2 --- Log message: Modified addTrace, and other interface functions --- Diffs of the changes: Index: llvm/include/llvm/Reoptimizer/TraceCache.h diff -u llvm/include/llvm/Reoptimizer/TraceCache.h:1.1 llvm/include/llvm/Reoptimizer/TraceCache.h:1.2 --- llvm/include/llvm/Reoptimizer/TraceCache.h:1.1 Thu Aug 1 02:18:26 2002 +++ llvm/include/llvm/Reoptimizer/TraceCache.h Sun Sep 15 15:40:41 2002 @@ -6,40 +6,13 @@ #ifndef LLVM_TRACECACHE_H #define LLVM_TRACECACHE_H - #include #include #include #include -//two kinds of branches being handled for now -//BIcc, and BPcc instructions -//(sparcV9 manual, pg 146-150) - -inline bool isBranchInstr(unsigned y) { - if (y & 0xc0000000) return false; - - switch ((y >> 22) & 0x7) { - case 1: - case 2: - case 3: - case 5: - case 6: - return true; - default: - return false; - } -} - -#define isNonDepJump(y) ((y & 0x01c00000) == 4194304) -#define isDepJump(y) ((y & 0x01c00000) == 8388608) - -#define getNonDepJmpTarget(y, oldAdd) (oldAdd+4*(((y&262144)==262144) ? ((y&0x0007ffff)|0xfffffffffff80000) : (y&0x0007ffff))) -#define getDepJmpTarget(y, oldAdd) (oldAdd+4*(((y&2097152)==2097152) ? ((y&0x003fffff)|0xffffffffffc00000) : (y&0x003fffff))) -#define getDepJumpInstr(a, to, pc) ((a&0xffc00000)|(((to-pc)/4)&0x003fffff)) -#define getUndepJumpInstr(a, to, pc) ((a&0xfff80000)|(((to-pc)/4)&0x0007ffff)) - -const int globalMemSize = 10000; +class VirtualMem; +class MemoryManager; class TraceCache{ private: @@ -48,99 +21,71 @@ std::map traceId; std::map reverseTraceId; + std::map > + tracesFirstInstruction; + std::map reverseMap; //map frm trace addr to original addr //for a given outgoing address (outside trace cache), //the addresses IN THE trace cache //that point to that address - std::map > outMaps; + //std::map > outMaps; //same for incoming addresses - std::map > inMaps; + //std::map > inMaps; std::list allocationOrder; bool isLimitSet; //this must be set during initialization!!! - int limit, currSize, fp; //fp is file pointer - - uint64_t memStart, memEnd; + int limit, currSize; //fp is file pointer //gets addr of target in branch - //uint64_t getBranchAddr(const std::pair &n); + uint64_t getBranchAddr(const std::pair &n); //change every address in F pointing to frm to "to" void changeAddr(uint64_t frm, uint64_t to); - //Memory management: right now very trivial - //list of free memory ranges: sorted order - std::list > freeMemList; - void memoryInitialize(); //initialize - uint64_t getMemory(int sz); //return a pointer to memory of size sz - void freeTraceMemory(uint64_t toRemove, int size);//size is no if instructions - //reading/modifying process space VM - void intializeVM(); - void copyToVM(unsigned int trace[], - uint64_t traceStartAddr, int sz); - unsigned int readInstrFrmVm(uint64_t frm); - void writeInstToVM(uint64_t dest, unsigned int newInstr); + //void intializeVM(); + //void copyToVM(unsigned int trace[], + // uint64_t traceStartAddr, int sz); + //unsigned int readInstrFrmVm(uint64_t frm); + //void writeInstToVM(uint64_t dest, unsigned int newInstr); public: + void setLimit(int n); + int getLimit() { return limit;} + + bool hasMaxSize(){ return isLimitSet;} + bool hasTraceAddr(uint64_t n){ return (traces.find(n)!=traces.end()); } + bool hasTraceId(int n) { return (traceId.find(n)!=traceId.end()); } + //constructors - //if trace is to have smaller size than the default size TraceCache(int limitSize); - //if trace is to have default size (of 10K instructions) TraceCache(); //add trace of a given size - //return false if cannot allocate - - //Arguments: - // instAddr: the address of start of trace in the ORIGINAL machine code - // trace[]: an array of "instructions" - // sz: size of trace[] - // inBranches: the Addressess of instructions in the ORIGINAL code which - // have branch targets as instAddr - // outBranches: the Address of instructions inserted in the trace - // (e.g. &trace[3], &trace[7] etc) which have branches/jumps - // traceUnisId: some unique number for identifying the trace: ordinarily, - // instAddr will be used to identify the trace, but sometimes - // another identification can be used for the trace, such as - // "path no". In this case, traceUnisId must be path_no. - - // Note that only one trace can exist in the trace cachestarting with a given - // instAddr. To add another trace with same instAddr, the earlier trace MUST - // be removed first! - bool addTrace(uint64_t instAddr, unsigned int trace[], int sz, - std::vector &inBranches, - std::vector > &outBranches, - int traceUniqId); + //return null if cannot allocate + //return an address where trace can be allocated otherwise + //the trace allocation is done by the calling program:starting + //at the address returned. The trace cache stiches the program + //addresses to jump to the new location for addresses that use the + //basic block bb as target + + bool addTrace(uint64_t instAddr, + std::vector &trace, + int traceUniqId, + std::map &callMap, + std::map &branchMap); + + //bool addTrace(uint64_t instAddr, unsigned int trace[], int sz, + // std::vector &inBranches, + // std::vector > &outBranches, int traceUniqId); - //remove trace starting with address n (this wil lbe instAddr of the trace - //added earlier. + //remove trace starting with address n void removeTrace(uint64_t n); - //reset limit of a trace whose limit was set earlier. This - //new limit MUST NOT be smaller than "current" size of trace (sum of traces - // currently in trace) - void setLimit(int n); - - //get the size of trace - int getLimit() { return limit;} - - //if trace has a max size - bool hasMaxSize(){ return isLimitSet;} - - //Does the traceCache contain a trace starting with a given instAddr - //instAddr is the address in the original machine code - bool hasTraceAddr(uint64_t instAddr){ - return (traces.find(instAddr)!=traces.end()); - } - - //Does the traceCache have a trace with given uniqueID - bool hasTraceId(int n) { return (traceId.find(n)!=traceId.end()); } - - uint64_t getBranchAddr(const std::pair &n); - + VirtualMem *vm; + MemoryManager *mm; }; #endif From ashukla at cs.uiuc.edu Sun Sep 15 15:42:00 2002 From: ashukla at cs.uiuc.edu (Anand Shukla) Date: Sun Sep 15 15:42:00 2002 Subject: [llvm-commits] CVS: llvm/include/llvm/Reoptimizer/VirtualMem.h Message-ID: <200209152041.PAA13078@trinity.cs.uiuc.edu> Changes in directory llvm/include/llvm/Reoptimizer: VirtualMem.h added (r1.1) --- Log message: interface to manipulate program image --- Diffs of the changes: From ashukla at cs.uiuc.edu Sun Sep 15 15:43:01 2002 From: ashukla at cs.uiuc.edu (Anand Shukla) Date: Sun Sep 15 15:43:01 2002 Subject: [llvm-commits] CVS: llvm/lib/Reoptimizer/TraceCache/TraceCache.cpp Message-ID: <200209152035.PAA12952@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Reoptimizer/TraceCache: TraceCache.cpp updated: 1.4 -> 1.5 --- Log message: TraceCache.cpp is reorganized and split into multiple files --- Diffs of the changes: Index: llvm/lib/Reoptimizer/TraceCache/TraceCache.cpp diff -u llvm/lib/Reoptimizer/TraceCache/TraceCache.cpp:1.4 llvm/lib/Reoptimizer/TraceCache/TraceCache.cpp:1.5 --- llvm/lib/Reoptimizer/TraceCache/TraceCache.cpp:1.4 Thu Aug 1 02:23:24 2002 +++ llvm/lib/Reoptimizer/TraceCache/TraceCache.cpp Sun Sep 15 15:35:50 2002 @@ -17,42 +17,37 @@ // //===----------------------------------------------------------------------===// +#include "MemoryManager.h" #include "llvm/Reoptimizer/TraceCache.h" -//#include -#include -//#include -//#include -//#include -#include -#include +#include "llvm/Reoptimizer/VirtualMem.h" +#include "llvm/Reoptimizer/InstrUtils.h" #include #include #include -using std::cerr; -int dummyFunction(int i); //the function that provides memory! +using std::cerr; TraceCache::TraceCache(int limitSize){ - memoryInitialize(); + mm = new MemoryManager(); - assert(limitSize <= globalMemSize && "can't allocate this large space"); + assert(limitSize <= mm->getMemSize() && "can't allocate this large space"); limit = limitSize; isLimitSet = true; currSize = 0; - intializeVM(); + vm = new VirtualMem(); } TraceCache::TraceCache(){ - memoryInitialize(); + mm = new MemoryManager(); - isLimitSet = true; //making limit as the globalSize + isLimitSet = true; //making limit as the size of memory currSize = 0; - limit = globalMemSize; + limit = mm->getMemSize(); - intializeVM(); + vm = new VirtualMem(); } void TraceCache::setLimit(int n) { @@ -61,127 +56,74 @@ limit = n; } -void TraceCache::intializeVM(){ - //open file pointer - char ctr[25]; - int pid = getpid(); - sprintf(ctr, "/proc/%d/as",pid); - fp = open(ctr, O_RDWR); - assert(fp>=0 && "Error opening file!"); -} - -void TraceCache::copyToVM(unsigned int trace[], - uint64_t traceStartAddr, int sz){ - //copy sz instructions starting from - //location trace to virtual memory address traceStartAddr - lseek(fp, traceStartAddr, SEEK_SET); - write(fp, &trace[0], 4*sz); -} - -unsigned int TraceCache::readInstrFrmVm(uint64_t frm){ - lseek(fp, frm, SEEK_SET); - unsigned int instr=0; - read(fp, &instr, 4); - return instr; -} - -void TraceCache::writeInstToVM(uint64_t dest, unsigned int newInstr){ - lseek(fp, dest, SEEK_SET); - write(fp, &newInstr, 4); -} +//add an array of instructions (trace[]), whose first instruction +//has address instrAddr in the original program +//size of array is sz (number of instructions) +// returns false if cannot assign space to trace +//Do the following: +//1. Insert a jump at location instrAddr with target as new trace +bool TraceCache::addTrace(uint64_t instAddr, + std::vector &trace, + int traceUniqId, + std::map &callMap, + std::map &branchMap){ + + //remove trace if its already there + if(hasTraceAddr(instAddr)) + removeTrace(instAddr); -//Memory management algorithm: -// -//Maintain a list: every element of list is -//a range [a, b] of free memory. The list is kept sorted: i.e. -// if [a,b], [c, d] are two adjacent nodes in the list in that order -// then b= sz-1 -// -if b-a == sz-1, then erase the node [a, b] -// -if b-a > sz-1, then reset a = a+sz -// -if no such node [a, b] is found, memory can not be allocated! -// -//Deallocating a memory beginning at location "toRemove" of size "sz": -//find the first node [a, b] in free list such that toRemove < a -// -if such a node is found -// -if a == toRemove + sz, then "combine" the two memory locations -// i.e, set a = toRemove -// -else insert a new node [toRemove, toRemove+sz-1] before [a, b] -// -no such node is found => insert [toRemove, toRemove+sz-1] at the end - -void TraceCache::memoryInitialize(){ - memStart = (uint64_t)&dummyFunction; - memEnd = (uint64_t)&dummyFunction+globalMemSize*4; - std::cerr<<"Dummy address :"<<(void *)memStart<<"\n"; - freeMemList.push_back(std::make_pair(memStart, memEnd)); -} + int sz = trace.size(); -//allocate the first free memory -//returns 0 if no memory can be assigned -uint64_t TraceCache::getMemory(int sz){ - //find a pair in freeMemList whose range>sz - - sz *= 4; //changing sz to bytes! - - assert(sz>0 && "memory of zero size requested!"); - for(std::list >::iterator LI = - freeMemList.begin(), LE = freeMemList.end(); LI!=LE; ++LI){ - - if(LI->second - LI->first >= sz-1){ - uint64_t temp = LI->first; - - //reassign the pair - if(LI->second - LI->first == sz-1) - freeMemList.erase(LI); - else - LI->first += sz; - - return temp; - } + while(isLimitSet && currSize+sz>limit){ + if(currSize == 0) + return false; + + //erase first addr from queue + assert(allocationOrder.size()>0 && "No entries in trace!"); + uint64_t addr = allocationOrder.front(); + allocationOrder.pop_front(); + removeTrace(addr); } - return 0; -} + uint64_t traceStartAddr = mm->getMemory(trace.size()); -void TraceCache::freeTraceMemory(uint64_t toRemove, int size){ - //iterate over the free list, until find nodes (a, b), (c, d) - //such that b < toRemove < c - - size *= 4; //changing sixe to bytes! + if(traceStartAddr == 0) return false; //could not allocate space! - assert(size>0 && "Non positive size of memory!"); + //copy trace to the memory + vm->copyToVM(trace, traceStartAddr); + + traces[instAddr] = traceStartAddr; + traceId[traceUniqId] = traceStartAddr; + reverseTraceId[instAddr] = traceUniqId; + traceSize[instAddr] = sz; + reverseMap[traceStartAddr] = instAddr; + currSize += sz; - for(std::list >::iterator LI = - freeMemList.begin(), LE = freeMemList.end(); LI!=LE; ++LI){ - - //since the list is sorted: insert it at first location - //which is greater than toRemove - if(toRemove < LI->first){ - assert(toRemove + size-1 < LI->first && - "Cannot have overlapping memory locations"); - - if(toRemove + size == LI->first){ - //combine the two free areas - LI->first = toRemove; - return; - } - freeMemList.insert(LI, std::make_pair(toRemove, toRemove+size-1)); - return; - } - } + //add instAddr to queue + allocationOrder.push_back(instAddr); - //toRemove MUST have been the largest!!! - freeMemList.push_back(std::make_pair(toRemove, toRemove + size - 1)); -} + //copy the first instruction of the trace in the original code + //and write a jump instruction in its place + tracesFirstInstruction[instAddr] = + std::make_pair(vm->readInstrFrmVm(instAddr), + vm->readInstrFrmVm(instAddr+4)); + + //Now write branch instruction with target as + //traceStartAddr at the address instAddr + vm->writeBranchInstruction(instAddr, traceStartAddr); -//add an array of instructions (trace[]), whose first instruction -//has address instrAddr in the original program -//size of array is sz (number of instructions) -// returns false if cannot assign space to trace + //now set correctly all branches + vm->setBranches(branchMap, traceStartAddr); + + //set correctly all calls + vm->setCalls(callMap, traceStartAddr); + + doFlush(traceStartAddr, traceStartAddr+4*sz); + return true; +} +/* bool TraceCache::addTrace(uint64_t instAddr, unsigned int trace[], int sz, std::vector &inBranches, std::vector > &outBranches, int traceUniqId){ @@ -201,11 +143,12 @@ removeTrace(addr); } - uint64_t traceStartAddr = getMemory(sz); + uint64_t traceStartAddr = mm->getMemory(sz); if(traceStartAddr == 0) return false; //could not allocate space! - copyToVM(trace, traceStartAddr, sz); + //copy trace to the memory + vm->copyToVM(trace, traceStartAddr, sz); traces[instAddr] = traceStartAddr; traceId[traceUniqId] = traceStartAddr; @@ -217,52 +160,19 @@ //add instAddr to queue allocationOrder.push_back(instAddr); - //for every inBranch, change branch address to trace - for(std::vector::iterator VI = inBranches.begin(), - VE = inBranches.end(); VI!=VE; ++VI){ - changeAddr(*VI, traceStartAddr); - inMaps[traceStartAddr].push_back(*VI); - //later, when trace is removed, - //point all addresses in inMaps[trace] to point to - //reverseMap[trace] - } - - //for outgoing branch addresses in traceCache - //change addresses within the trace that point to - //instAddr to now point to trace - for(std::vector::iterator VI = outMaps[instAddr].begin(), - VE = outMaps[instAddr].end(); VI!=VE; ++VI){ - changeAddr(*VI, traceStartAddr); - inMaps[traceStartAddr].push_back(*VI); - //later when trace is removed, point all addresses in - //inMaps[trace] to point to - //reverseMap[trace] - } - - //For every outgoing branch, see if its in the trace - //if in the trace => change to one in the trace - //if not in trace => add the addr of outgoing branch - // to outMap[branch] - for(std::vector >::iterator VI = - outBranches.begin(), VE = outBranches.end(); VI!=VE; ++VI){ - uint64_t branchAddr = getBranchAddr(*VI); - assert(VI->second > (uint64_t)trace && - "The outBranch reference is erroneous"); - uint64_t addrTarget = (VI->second-(uint64_t)trace)+traceStartAddr; - if(hasTraceAddr(branchAddr)){ - changeAddr(addrTarget, traces[branchAddr]); - inMaps[traces[branchAddr]].push_back(addrTarget); - } - else{ - outMaps[branchAddr].push_back(addrTarget); - //set the target right in existing one - changeAddr(addrTarget, branchAddr); - } - } + //copy the first instruction of the trace in the original code + //and write a jump instruction in its place + tracesFirstInstruction[instAddr] = + std::make_pair(vm->readInstrFrmVm(instAddr), + vm->readInstrFrmVm(instAddr+4)); + + //Now write branch instruction with target as + //traceStartAddr at the address instAddr + vm->writeBranchInstruction(instAddr, traceStartAddr); return true; } - +*/ void TraceCache::removeTrace(uint64_t n){ //if no trace, do nothing if(traces.find(n) == traces.end()) @@ -270,31 +180,11 @@ uint64_t toRemove = traces[n]; - //restitch - for(std::vector::iterator VI = inMaps[toRemove].begin(), - VE = inMaps[toRemove].end(); VI!=VE; ++VI){ - assert(reverseMap[toRemove]==n && "two addresses should match!"); - changeAddr(*VI, n); - } - - inMaps.erase(toRemove); - - //remove entries of this trace from every outMaps - for(std::map >::iterator MI = outMaps.begin(), - ME = outMaps.end(); MI!=ME; ++MI){ - bool changed=true; - while(changed){ - changed=false; - for(std::vector::iterator VI = MI->second.begin(), - VE = MI->second.end(); VI!=VE; ++VI){ - if(*VI>=toRemove && *VIsecond.erase(VI); - changed=true; - break; - } - } - } - } + //put back the original instruction at n + assert(tracesFirstInstruction.find(n) != tracesFirstInstruction.end() && + "Starting instruction not found!"); + vm->writeInstToVM(n, tracesFirstInstruction[n].first); + vm->writeInstToVM(n+4, tracesFirstInstruction[n].second); //remove n from queue std::list::iterator LI = std::find(allocationOrder.begin(), @@ -303,7 +193,7 @@ allocationOrder.erase(LI); //free up memory in tracecache - freeTraceMemory(toRemove, traceSize[n]); + mm->freeTraceMemory(toRemove, traceSize[n]); currSize -= traceSize[n]; //remove allocated spaces to n @@ -312,68 +202,11 @@ reverseTraceId.erase(n); traceSize.erase(n); reverseMap.erase(toRemove); - -} - - -//two kinds of branches being handled for now -//BIcc, and BPcc instructions -//(sparcV9 manual, pg 146-150) - -//#define isBranchInstr(y) ((y & 0xc0000000) == 0) -//#define isNonDepJump(y) ((y & 0x01c00000) == 4194304) -//#define isDepJump(y) ((y & 0x01c00000) == 8388608) - -//#define getNonDepJmpTarget(y, oldAdd) (oldAdd+4*(((y&262144)==262144) ? ((y&0x0007ffff)|0xfffffffffff80000) : (y&0x0007ffff))) -//#define getDepJmpTarget(y, oldAdd) (oldAdd+4*(((y&2097152)==2097152) ? ((y&0x003fffff)|0xffffffffffc00000) : (y&0x003fffff))) - -//#define getDepJumpInstr(a, to, pc) ((a&0xffc00000)|(((to-pc)/4)&0x003fffff)) -//#define getUndepJumpInstr(a, to, pc) ((a&0xfff80000)|(((to-pc)/4)&0x0007ffff)) - -void TraceCache::changeAddr(uint64_t frm, uint64_t to){ - unsigned int instr = readInstrFrmVm(frm); - //std::cerr<<"Instruction at: "<<(void *)frm<<" Is:"<<(void *)instr<<"\n"; - //check if instr is a jump - assert(isBranchInstr(instr) && "Not a jump instruction"); - - //std::cerr<<"\t frm Address: "<<(void *)frm<<"\n"; - //std::cerr<<"\t to address: "<<(void *)to<<"\n"; - - if(isNonDepJump(instr)){ - unsigned int newInstr = getUndepJumpInstr(instr, to, frm); - writeInstToVM(frm, newInstr); - std::cerr<<"New instruction:"<<(void *)newInstr<<"\n"; - } - - else if(isDepJump(instr)){ - unsigned int newInstr = getDepJumpInstr(instr, to, frm); - writeInstToVM(frm, newInstr); - std::cerr<<"New instruction:"<<(void *)newInstr<<"\n"; - } + tracesFirstInstruction.erase(n); - else - assert(0 && "This jump/branch not yet handled!"); } - - -uint64_t TraceCache::getBranchAddr(const std::pair &n){ - - unsigned int instr = readInstrFrmVm(n.second); - assert(isBranchInstr(instr) && "Not a branch Instr"); - - //only handles BIcc and BPcc instructions for now - //(sparcV9 manual, pg 146-150) - if(isNonDepJump(instr)) - return getNonDepJmpTarget(instr, n.first); - else if(isDepJump(instr)) - return getDepJmpTarget(instr, n.first); - - assert(0 && "This branch type is not yet handled!"); -} - - #undef ANAND_TRACE_CACHE_TEST_CODE #ifdef ANAND_TRACE_CACHE_TEST_CODE @@ -438,8 +271,8 @@ std::cerr<10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - for(int j=0; j<20; j++){ - if(j>10) - i+=1; - else - i+=2; - } - return i; -} + From ashukla at cs.uiuc.edu Sun Sep 15 15:44:00 2002 From: ashukla at cs.uiuc.edu (Anand Shukla) Date: Sun Sep 15 15:44:00 2002 Subject: [llvm-commits] CVS: llvm/lib/Reoptimizer/TraceCache/MemoryManager.h Message-ID: <200209152043.PAA13101@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Reoptimizer/TraceCache: MemoryManager.h added (r1.1) --- Log message: Inteface to MemoryManager.cpp --- Diffs of the changes: From vadve at cs.uiuc.edu Sun Sep 15 16:52:01 2002 From: vadve at cs.uiuc.edu (vadve at cs.uiuc.edu) Date: Sun Sep 15 16:52:01 2002 Subject: [llvm-commits] CVS: llvm/lib/CWriter/Writer.cpp Message-ID: <200209152151.QAA11790@morpheus.cs.uiuc.edu> Changes in directory llvm/lib/CWriter: Writer.cpp updated: 1.43 -> 1.44 --- Log message: No longer need to sign-extend array indices to 64 bits since they are now longs and not unsigned ints. --- Diffs of the changes: Index: llvm/lib/CWriter/Writer.cpp diff -u llvm/lib/CWriter/Writer.cpp:1.43 llvm/lib/CWriter/Writer.cpp:1.44 --- llvm/lib/CWriter/Writer.cpp:1.43 Sat Sep 14 16:36:24 2002 +++ llvm/lib/CWriter/Writer.cpp Sun Sep 15 16:51:04 2002 @@ -952,13 +952,9 @@ for (; I != E; ++I) if ((*I)->getType() == Type::LongTy) { - Out << "[((int) ("; // sign-extend from 32 (to 64) bits + Out << "["; writeOperand(*I); - Out << " * sizeof("; - printType(cast(Ptr->getType())->getElementType()); - Out << "))) / sizeof("; - printType(cast(Ptr->getType())->getElementType()); - Out << ")]"; + Out << "]"; } else { Out << ".field" << cast(*I)->getValue(); } From ashukla at cs.uiuc.edu Sun Sep 15 17:34:00 2002 From: ashukla at cs.uiuc.edu (Anand Shukla) Date: Sun Sep 15 17:34:00 2002 Subject: [llvm-commits] CVS: llvm/lib/Reoptimizer/TraceCache/InstrUtils.cpp Message-ID: <200209152233.RAA14423@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Reoptimizer/TraceCache: InstrUtils.cpp updated: 1.1 -> 1.2 --- Log message: Made InstrUtils.cpp compatible with old gcc --- Diffs of the changes: Index: llvm/lib/Reoptimizer/TraceCache/InstrUtils.cpp diff -u llvm/lib/Reoptimizer/TraceCache/InstrUtils.cpp:1.1 llvm/lib/Reoptimizer/TraceCache/InstrUtils.cpp:1.2 --- llvm/lib/Reoptimizer/TraceCache/InstrUtils.cpp:1.1 Sun Sep 15 15:36:07 2002 +++ llvm/lib/Reoptimizer/TraceCache/InstrUtils.cpp Sun Sep 15 17:33:48 2002 @@ -7,7 +7,6 @@ #include "llvm/Reoptimizer/InstrUtils.h" #include #include -//#include bool isNonDepJump(unsigned int y){ return ((y & 0x01c00000) == 4194304); @@ -18,11 +17,11 @@ } uint64_t getNonDepJmpTarget(unsigned int y, uint64_t oldAdd){ - return (oldAdd+4*(((y&262144)==262144) ? ((y&0x0007ffff)|0xfffffffffff80000) : (y&0x0007ffff))); + return (oldAdd+4ull*(((y&262144ull)==262144ull) ? ((y&0x0007ffffull)|0xfffffffffff80000ull) : (y&0x0007ffffull))); } uint64_t getDepJmpTarget(unsigned int y, uint64_t oldAdd){ - return (oldAdd+4*(((y&2097152)==2097152) ? ((y&0x003fffff)|0xffffffffffc00000) : (y&0x003fffff))); + return (oldAdd+4ull*(((y&2097152ull)==2097152ull) ? ((y&0x003fffffull)|0xffffffffffc00000ull) : (y&0x003fffffull))); } /* @@ -62,7 +61,7 @@ } uint64_t getCallTarget(unsigned int y, uint64_t oldAdd){ - uint64_t toRet = (oldAdd + 4*(((y&536870912)==536870912)?(0xffffffffc0000000|(y&0x3fffffff)):(y&0x3fffffff))); + uint64_t toRet = (oldAdd + 4ull*(((y&536870912ull)==536870912ull)?(0xffffffffc0000000ull|(y&0x3fffffffull)):(y&0x3fffffffull))); std::cerr<<"\t\t\tCall Target:"<<(void *)toRet<<"\n"; return toRet; } @@ -95,19 +94,9 @@ } uint64_t getBPRTarget(unsigned int b, uint64_t oldAdd){ - return (oldAdd+4*(((b&2097152)==2097152)?(0xffffffffffff0000|((b&3145728)>>6)|(b&16383)):(((b&3145728)>>6)|(b&16383)))); + return (oldAdd+4ull*(((b&2097152ull)==2097152ull)?(0xffffffffffff0000ull|((b&3145728ull)>>6)|(b&16383ull)):(((b&3145728ull)>>6)|(b&16383ull)))); } -// unsigned int getBPRInstr(unsigned int b, uint64_t to, uint64_t frm){ -// //frame = 2^32-1-(2^21+2^20+2^14-1) -// unsigned int frame = b&4291805184; -// uint64_t target = (to-frm)/4; -// assert((target&(2147483647))<32768 && "Target out of range!"); -// unsigned int hi = ((target & (2147483648))>>10)|((target&(16384))<<6); -// unsigned lo = target&(16383); -// return (frame|hi|lo); -// } - std::pair getBPRInstr(unsigned int b, uint64_t to, uint64_t frm){ @@ -122,10 +111,10 @@ frm+=4; uint64_t target = (to-frm)/4; //target < 2^21 - assert((target&(0x7fffffffffffffff))<2097152 && "Target out of range!"); + assert((target&(0x7fffffffffffffffull))<2097152 && "Target out of range!"); unsigned int inst = - ((target & (2097151))|((target&(0x8000000000000000))>>42)); + ((target & (2097151))|((target&(0x8000000000000000ull))>>42)); inst = inst|(0x00800000);//skeleton filled in @@ -150,7 +139,8 @@ } void doFlush(uint64_t st_addr, uint64_t end_addr){ - for(uint64_t i = st_addr; i<=end_addr; i+=8){ - asm("flush %0"::"r" (i)); - } + return; + //for(uint64_t i = st_addr; i<=end_addr; i+=8){ + //asm("flush %0"::"r" (i)); + //} } From brukman at cs.uiuc.edu Sun Sep 15 21:15:01 2002 From: brukman at cs.uiuc.edu (Michael Brukman) Date: Sun Sep 15 21:15:01 2002 Subject: [llvm-commits] CVS: llvm/lib/Reoptimizer/Trigger/Trigger.cpp Message-ID: <200209160214.VAA24767@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Reoptimizer/Trigger: Trigger.cpp updated: 1.7 -> 1.8 --- Log message: Eliminated unnecessary #includes. --- Diffs of the changes: Index: llvm/lib/Reoptimizer/Trigger/Trigger.cpp diff -u llvm/lib/Reoptimizer/Trigger/Trigger.cpp:1.7 llvm/lib/Reoptimizer/Trigger/Trigger.cpp:1.8 --- llvm/lib/Reoptimizer/Trigger/Trigger.cpp:1.7 Sun Sep 15 15:35:05 2002 +++ llvm/lib/Reoptimizer/Trigger/Trigger.cpp Sun Sep 15 21:14:33 2002 @@ -13,12 +13,8 @@ #include "llvm/Reoptimizer/Mapping/LLVMinfo.h" #include "llvm/Bytecode/Reader.h" #include "llvm/Module.h" -#include "llvm/BasicBlock.h" #include "llvm/iTerminators.h" #include "llvm/Support/CFG.h" -#include "llvm/Function.h" -#include -#include #include using std::vector; From brukman at cs.uiuc.edu Sun Sep 15 21:16:01 2002 From: brukman at cs.uiuc.edu (Michael Brukman) Date: Sun Sep 15 21:16:01 2002 Subject: [llvm-commits] CVS: llvm/include/llvm/Reoptimizer/TraceCache.h Message-ID: <200209160215.VAA24783@trinity.cs.uiuc.edu> Changes in directory llvm/include/llvm/Reoptimizer: TraceCache.h updated: 1.2 -> 1.3 --- Log message: Since it uses uint64_t, it needs DataTypes.h to compile. --- Diffs of the changes: Index: llvm/include/llvm/Reoptimizer/TraceCache.h diff -u llvm/include/llvm/Reoptimizer/TraceCache.h:1.2 llvm/include/llvm/Reoptimizer/TraceCache.h:1.3 --- llvm/include/llvm/Reoptimizer/TraceCache.h:1.2 Sun Sep 15 15:40:41 2002 +++ llvm/include/llvm/Reoptimizer/TraceCache.h Sun Sep 15 21:15:24 2002 @@ -6,6 +6,7 @@ #ifndef LLVM_TRACECACHE_H #define LLVM_TRACECACHE_H +#include "Support/DataTypes.h" #include #include #include