Remove unnecesary &*'s
authorChris Lattner <sabre@nondot.org>
Wed, 23 Apr 2003 16:37:45 +0000 (16:37 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 23 Apr 2003 16:37:45 +0000 (16:37 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5872 91177308-0d34-0410-b5e6-96231b3b80d8

19 files changed:
lib/Transforms/IPO/InlineSimple.cpp
lib/Transforms/Instrumentation/ProfilePaths/EdgeCode.cpp
lib/Transforms/Instrumentation/ProfilePaths/InstLoops.cpp
lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp
lib/Transforms/Instrumentation/ProfilePaths/RetracePath.cpp
lib/Transforms/Instrumentation/TraceValues.cpp
lib/Transforms/Scalar/ADCE.cpp
lib/Transforms/Scalar/CorrelatedExprs.cpp
lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp
lib/Transforms/Scalar/IndVarSimplify.cpp
lib/Transforms/Scalar/LICM.cpp
lib/Transforms/Scalar/Reassociate.cpp
lib/Transforms/Scalar/SCCP.cpp
lib/Transforms/Utils/BreakCriticalEdges.cpp
lib/Transforms/Utils/LoopSimplify.cpp
lib/Transforms/Utils/LowerAllocations.cpp
lib/Transforms/Utils/Mem2Reg.cpp
lib/Transforms/Utils/SimplifyCFG.cpp
lib/VMCore/BasicBlock.cpp

index afa4890f035e6ed839760a960f52615014f9350b..a2dbf2ef4cf4f1a25ded8e30d4b4e319e79bfe67 100644 (file)
@@ -169,7 +169,7 @@ static inline bool ShouldInlineFunction(const CallInst *CI, const Function *F) {
 
 static inline bool DoFunctionInlining(BasicBlock *BB) {
   for (BasicBlock::iterator I = BB->begin(); I != BB->end(); ++I) {
-    if (CallInst *CI = dyn_cast<CallInst>(&*I)) {
+    if (CallInst *CI = dyn_cast<CallInst>(I)) {
       // Check to see if we should inline this function
       Function *F = CI->getCalledFunction();
       if (F && ShouldInlineFunction(CI, F)) {
index 8fabbc9ca39155504ca737272985f28de72f1269..61c60ec7c5e1e81f0d1df81cdae4647f6b4bb76d 100644 (file)
@@ -386,7 +386,7 @@ void insertBB(Edge ed,
   for(BasicBlock::iterator BB2Inst = BB2->begin(), BBend = BB2->end(); 
       BB2Inst != BBend; ++BB2Inst){
    
-    if(PHINode *phiInst=dyn_cast<PHINode>(&*BB2Inst)){
+    if(PHINode *phiInst=dyn_cast<PHINode>(BB2Inst)){
       int bbIndex=phiInst->getBasicBlockIndex(BB1);
       assert(bbIndex>=0);
       phiInst->setIncomingBlock(bbIndex, newBB);
index c876238a1e1634dece70b87ed21eb6322b6ccf20..64075c8024e011bbfbc98dcb6ec5e4349ff37db4 100644 (file)
@@ -133,7 +133,7 @@ void getBackEdgesVisit(BasicBlock *u,
         for(BasicBlock::iterator BB2Inst = BB->begin(), BBend = BB->end(); 
             BB2Inst != BBend; ++BB2Inst){
         
-          if(PHINode *phiInst=dyn_cast<PHINode>(&*BB2Inst)){
+          if (PHINode *phiInst = dyn_cast<PHINode>(BB2Inst)){
             int bbIndex = phiInst->getBasicBlockIndex(u);
             if(bbIndex>=0){
               phiInst->setIncomingBlock(bbIndex, newBB);
index 57b17a590ff36788d2e155c25b9adedda54402cf..79b94e8755ccb9d1733994b349dcc1ec3ba271f3 100644 (file)
@@ -87,7 +87,7 @@ bool ProfilePaths::runOnFunction(Function &F){
     nodes.push_back(nd); 
     if(&*BB == ExitNode)
       exitNode=nd;
-    if(&*BB==F.begin())
+    if(BB==F.begin())
       startNode=nd;
   }
 
index c222bdfb34401bad66cd9720e754cd077bd13d18..805250fd9a07b4e1621271e1a1cc98298b0fe107 100644 (file)
@@ -140,7 +140,7 @@ void getBBtrace(vector<BasicBlock *> &vBB, int pathNo, Function *M){//,
     BasicBlock *ExitNode = 0;
     for (Function::iterator I = M->begin(), E = M->end(); I != E; ++I){
       if (isa<ReturnInst>(I->getTerminator())) {
-        ExitNode = &*I;
+        ExitNode = I;
         break;
       }
     }
@@ -160,7 +160,7 @@ void getBBtrace(vector<BasicBlock *> &vBB, int pathNo, Function *M){//,
       if(BB->size()==3 || BB->size() ==2){
         for(BasicBlock::iterator II = BB->begin(), IE = BB->end();
             II != IE; ++II){
-          if(CallInst *callInst = dyn_cast<CallInst>(&*II)){
+          if(CallInst *callInst = dyn_cast<CallInst>(II)){
             //std::cerr<<*callInst;
             Function *calledFunction = callInst->getCalledFunction();
             if(calledFunction && calledFunction->getName() == "trigger"){
@@ -199,7 +199,7 @@ void getBBtrace(vector<BasicBlock *> &vBB, int pathNo, Function *M){//,
         continue;
       
       //if(BB->size()==3)
-      //if(CallInst *callInst = dyn_cast<CallInst>(&*BB->getInstList().begin()))
+      //if(CallInst *callInst = dyn_cast<CallInst>(BB->getInstList().begin()))
       //if(callInst->getCalledFunction()->getName() == "trigger")
       //continue;
       
@@ -216,20 +216,20 @@ void getBBtrace(vector<BasicBlock *> &vBB, int pathNo, Function *M){//,
       Node *nd=findBB(nodes, BB);
       assert(nd && "No node for this edge!");
       
-      for(BasicBlock::succ_iterator s=succ_begin(&*BB), se=succ_end(&*BB); 
+      for(BasicBlock::succ_iterator s=succ_begin(BB), se=succ_end(BB); 
           s!=se; ++s){
         
         if(triggerBBs[*s] == 9){
           //if(!pathReg[M]){ //Get the path register for this!
           //if(BB->size()>8)
-          //  if(LoadInst *ldInst = dyn_cast<LoadInst>(&*BB->getInstList().begin()))
+          //  if(LoadInst *ldInst = dyn_cast<LoadInst>(BB->getInstList().begin()))
           //    pathReg[M] = ldInst->getPointerOperand();
           //}
           continue;
         }
         //if((*s)->size()==3)
         //if(CallInst *callInst = 
-        //   dyn_cast<CallInst>(&*(*s)->getInstList().begin()))
+        //   dyn_cast<CallInst>((*s)->getInstList().begin()))
         //  if(callInst->getCalledFunction()->getName() == "trigger")
         //    continue;
         
@@ -284,11 +284,11 @@ void getBBtrace(vector<BasicBlock *> &vBB, int pathNo, Function *M){//,
         VBI != VBE; ++VBI){
       for(BasicBlock::iterator BBI = (*VBI)->begin(), BBE = (*VBI)->end();
           BBI != BBE; ++BBI){
-        if(LoadInst *ldInst = dyn_cast<LoadInst>(&*BBI)){
+        if(LoadInst *ldInst = dyn_cast<LoadInst>(BBI)){
           if(pathReg[M] == ldInst->getPointerOperand())
             instToErase.push_back(ldInst);
         }
-        else if(StoreInst *stInst = dyn_cast<StoreInst>(&*BBI)){
+        else if(StoreInst *stInst = dyn_cast<StoreInst>(BBI)){
           if(pathReg[M] == stInst->getPointerOperand())
             instToErase.push_back(stInst);
         }
index 75149ce91232c5895ae4f1713b08d1c346adfb7b..499bc4cf9d0a40466157a5cde74452d1373d0c13 100644 (file)
@@ -298,9 +298,9 @@ ReleasePtrSeqNumbers(BasicBlock *BB,
                      ExternalFuncs& externalFuncs) {
   
   for (BasicBlock::iterator II=BB->begin(), IE = BB->end(); II != IE; ++II)
-    if (FreeInst *FI = dyn_cast<FreeInst>(&*II))
+    if (FreeInst *FI = dyn_cast<FreeInst>(II))
       InsertReleaseInst(FI->getOperand(0), BB, FI,externalFuncs.ReleasePtrFunc);
-    else if (AllocaInst *AI = dyn_cast<AllocaInst>(&*II))
+    else if (AllocaInst *AI = dyn_cast<AllocaInst>(II))
       InsertRecordInst(AI, BB, AI->getNext(), externalFuncs.RecordPtrFunc);
 }  
 
@@ -332,7 +332,7 @@ static void TraceValuesAtBBExit(BasicBlock *BB,
   // instruction *preceding* InsertPos to check when to terminate the loop.
   // 
   for (BasicBlock::iterator II = BB->begin(); &*II != InsertPos; ++II) {
-    if (StoreInst *SI = dyn_cast<StoreInst>(&*II)) {
+    if (StoreInst *SI = dyn_cast<StoreInst>(II)) {
       assert(valuesStoredInFunction &&
              "Should not be printing a store instruction at function exit");
       LoadInst *LI = new LoadInst(SI->getPointerOperand(), "reload." +
index e7bc1357ffe641ef125c67908072449d082d3b13..5e2a2755fb7551f61370dcb236c4d714a8c0a3e1 100644 (file)
@@ -119,7 +119,7 @@ bool ADCE::dropReferencesOfDeadInstructionsInLiveBlock(BasicBlock *BB) {
   for (BasicBlock::iterator I = BB->begin(), E = --BB->end(); I != E; )
     if (!LiveSet.count(I)) {              // Is this instruction alive?
       I->dropAllReferences();             // Nope, drop references... 
-      if (PHINode *PN = dyn_cast<PHINode>(&*I)) {
+      if (PHINode *PN = dyn_cast<PHINode>(I)) {
         // We don't want to leave PHI nodes in the program that have
         // #arguments != #predecessors, so we remove them now.
         //
@@ -310,7 +310,7 @@ bool ADCE::doADCE() {
               // should be identical to the incoming values for LastDead.
               //
               for (BasicBlock::iterator II = NextAlive->begin();
-                   PHINode *PN = dyn_cast<PHINode>(&*II); ++II) {
+                   PHINode *PN = dyn_cast<PHINode>(II); ++II) {
                 // Get the incoming value for LastDead...
                 int OldIdx = PN->getBasicBlockIndex(LastDead);
                 assert(OldIdx != -1 && "LastDead is not a pred of NextAlive!");
index cb8bd6109c131843a6a207eeec02ef6cce913208..c560e8369752c4e2d452c8c7b7034453c6e5a3c3 100644 (file)
@@ -450,11 +450,11 @@ bool CEE::ForwardCorrelatedEdgeDestination(TerminatorInst *TI, unsigned SuccNo,
     
   // Put the newly discovered information into the RegionInfo...
   for (BasicBlock::iterator I = OldSucc->begin(), E = OldSucc->end(); I!=E; ++I)
-    if (PHINode *PN = dyn_cast<PHINode>(&*I)) {
+    if (PHINode *PN = dyn_cast<PHINode>(I)) {
       int OpNum = PN->getBasicBlockIndex(BB);
       assert(OpNum != -1 && "PHI doesn't have incoming edge for predecessor!?");
       PropagateEquality(PN, PN->getIncomingValue(OpNum), NewRI);      
-    } else if (SetCondInst *SCI = dyn_cast<SetCondInst>(&*I)) {
+    } else if (SetCondInst *SCI = dyn_cast<SetCondInst>(I)) {
       Relation::KnownResult Res = getSetCCResult(SCI, NewRI);
       if (Res == Relation::Unknown) return false;
       PropagateEquality(SCI, ConstantBool::get(Res), NewRI);
@@ -563,7 +563,7 @@ void CEE::ForwardSuccessorTo(TerminatorInst *TI, unsigned SuccNo,
   // node with a new value.
   //
   for (BasicBlock::iterator I = OldSucc->begin();
-       PHINode *PN = dyn_cast<PHINode>(&*I); ) {
+       PHINode *PN = dyn_cast<PHINode>(I); ) {
 
     // Get the value flowing across the old edge and remove the PHI node entry
     // for this edge: we are about to remove the edge!  Don't remove the PHI
@@ -993,7 +993,7 @@ void CEE::ComputeReplacements(RegionInfo &RI) {
 bool CEE::SimplifyBasicBlock(BasicBlock &BB, const RegionInfo &RI) {
   bool Changed = false;
   for (BasicBlock::iterator I = BB.begin(), E = BB.end(); I != E; ) {
-    Instruction *Inst = &*I++;
+    Instruction *Inst = I++;
 
     // Convert instruction arguments to canonical forms...
     Changed |= SimplifyInstruction(Inst, RI);
index d0f47d8b8069a1f580a1b00438c495ea2ce32356..65cf465acd9134b8d0b9793103acb29d1513e00a 100644 (file)
@@ -44,7 +44,7 @@ DecomposePass::runOnBasicBlock(BasicBlock &BB)
 {
   bool changed = false;
   for (BasicBlock::iterator II = BB.begin(); II != BB.end(); )
-    if (GetElementPtrInst *gep = dyn_cast<GetElementPtrInst>(&*II++)) // pre-inc
+    if (GetElementPtrInst *gep = dyn_cast<GetElementPtrInst>(II++)) // pre-inc
       if (gep->getNumIndices() >= 2)
         changed |= DecomposeArrayRef(gep); // always modifies II
   return changed;
index ff2b9939c70cdd952207c5e893a63ccad91d81d2..993e533abc726f33bef660bd106fce2e76a45a6f 100644 (file)
@@ -45,7 +45,7 @@ static bool TransformLoop(LoopInfo *Loops, Loop *Loop) {
   //
   std::vector<InductionVariable> IndVars;    // Induction variables for block
   BasicBlock::iterator AfterPHIIt = Header->begin();
-  for (; PHINode *PN = dyn_cast<PHINode>(&*AfterPHIIt); ++AfterPHIIt)
+  for (; PHINode *PN = dyn_cast<PHINode>(AfterPHIIt); ++AfterPHIIt)
     IndVars.push_back(InductionVariable(PN, Loops));
   // AfterPHIIt now points to first nonphi instruction...
 
index 3df11a5ca2856491fd2f3a2d2bc1ff4aef34de5b..9069338e32353357c5f0772a59cf4f1772943ffa 100644 (file)
@@ -319,12 +319,12 @@ void LICM::PromoteValuesInLoop() {
     // Rewrite all loads and stores in the block of the pointer...
     for (BasicBlock::iterator II = (*I)->begin(), E = (*I)->end();
          II != E; ++II) {
-      if (LoadInst *L = dyn_cast<LoadInst>(&*II)) {
+      if (LoadInst *L = dyn_cast<LoadInst>(II)) {
         std::map<Value*, AllocaInst*>::iterator
           I = ValueToAllocaMap.find(L->getOperand(0));
         if (I != ValueToAllocaMap.end())
           L->setOperand(0, I->second);    // Rewrite load instruction...
-      } else if (StoreInst *S = dyn_cast<StoreInst>(&*II)) {
+      } else if (StoreInst *S = dyn_cast<StoreInst>(II)) {
         std::map<Value*, AllocaInst*>::iterator
           I = ValueToAllocaMap.find(S->getOperand(1));
         if (I != ValueToAllocaMap.end())
index df0a64188f3e751def73c3922d8d0f3cb30775a2..3414c410ac8d1e5aa0b8676558456f859282218a 100644 (file)
@@ -224,7 +224,7 @@ bool Reassociate::ReassociateBB(BasicBlock *BB) {
     // the two operands are sorted incorrectly, fix it now.
     //
     if (BI->isAssociative()) {
-      BinaryOperator *I = cast<BinaryOperator>(&*BI);
+      BinaryOperator *I = cast<BinaryOperator>(BI);
       if (!I->use_empty()) {
         // Make sure that we don't have a tree-shaped computation.  If we do,
         // linearize it.  Convert (A+B)+(C+D) into ((A+B)+C)+D
index 66818bc3b63bbbe2c7fbfcc009ac44aba250b170..77b41f4e360a494a6127a32e015005fc5d77dd2b 100644 (file)
@@ -474,7 +474,7 @@ void SCCP::visitTerminatorInst(TerminatorInst &TI) {
       // constant now may not be.
       //
       for (BasicBlock::iterator I = Succ->begin();
-           PHINode *PN = dyn_cast<PHINode>(&*I); ++I)
+           PHINode *PN = dyn_cast<PHINode>(I); ++I)
         visitPHINode(*PN);
     }
 }
index c44f9d324ecab7001ebac2306951d92cc6513d84..a87dbce2a0919ba2ea47bafec20f002d0cbb309c 100644 (file)
@@ -85,7 +85,7 @@ void SplitCriticalEdge(TerminatorInst *TI, unsigned SuccNum, Pass *P) {
   // merge incoming values from NewBB instead of from TIBB.
   //
   for (BasicBlock::iterator I = DestBB->begin();
-       PHINode *PN = dyn_cast<PHINode>(&*I); ++I) {
+       PHINode *PN = dyn_cast<PHINode>(I); ++I) {
     // We no longer enter through TIBB, now we come in through NewBB.
     PN->replaceUsesOfWith(TIBB, NewBB);
   }
index 5a68dda1af3a0ac40b81320fd7c2304622ca5187..d5988b16526780eecdd770fbb5a5399168401825 100644 (file)
@@ -132,7 +132,7 @@ BasicBlock *Preheaders::SplitBlockPredecessors(BasicBlock *BB,
   //
   if (!Preds.empty()) {  // Is the loop not obviously dead?
     for (BasicBlock::iterator I = BB->begin();
-         PHINode *PN = dyn_cast<PHINode>(&*I); ++I) {
+         PHINode *PN = dyn_cast<PHINode>(I); ++I) {
       
       // Create the new PHI node, insert it into NewBB at the end of the block
       PHINode *NewPHI = new PHINode(PN->getType(), PN->getName()+".ph", BI);
@@ -160,7 +160,7 @@ BasicBlock *Preheaders::SplitBlockPredecessors(BasicBlock *BB,
     
   } else {                       // Otherwise the loop is dead...
     for (BasicBlock::iterator I = BB->begin();
-         PHINode *PN = dyn_cast<PHINode>(&*I); ++I)
+         PHINode *PN = dyn_cast<PHINode>(I); ++I)
       // Insert dummy values as the incoming value...
       PN->addIncoming(Constant::getNullValue(PN->getType()), NewBB);
   }  
index 0148134d03b37e30554f99f281d992a975cecb3f..68fb74efaf650c34f4ba8eb3f3b96061d2ac2e9b 100644 (file)
@@ -85,7 +85,7 @@ bool LowerAllocations::runOnBasicBlock(BasicBlock &BB) {
 
   // 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<MallocInst>(&*I)) {
+    if (MallocInst *MI = dyn_cast<MallocInst>(I)) {
       const Type *AllocTy = MI->getType()->getElementType();
       
       // Get the number of bytes to be allocated for one element of the
@@ -114,7 +114,7 @@ bool LowerAllocations::runOnBasicBlock(BasicBlock &BB) {
       I = --BBIL.erase(I);         // remove and delete the malloc instr...
       Changed = true;
       ++NumLowered;
-    } else if (FreeInst *FI = dyn_cast<FreeInst>(&*I)) {
+    } else if (FreeInst *FI = dyn_cast<FreeInst>(I)) {
       // Cast the argument to free into a ubyte*...
       CastInst *MCast = new CastInst(FI->getOperand(0), 
                                      PointerType::get(Type::UByteTy), "", I);
index 848c4d670668fe43c29f1ccf623925b7bfd29a0a..6bd859a4037baa0ac9a3032aad96c1286b1bd917 100644 (file)
@@ -43,7 +43,7 @@ bool PromotePass::runOnFunction(Function &F) {
   // Find allocas that are safe to promote, by looking at all instructions in
   // the entry node
   for (BasicBlock::iterator I = BB.begin(), E = --BB.end(); I != E; ++I)
-    if (AllocaInst *AI = dyn_cast<AllocaInst>(&*I))       // Is it an alloca?
+    if (AllocaInst *AI = dyn_cast<AllocaInst>(I))       // Is it an alloca?
       if (isAllocaPromotable(AI, TD))
         Allocas.push_back(AI);
 
index 25d835684b27c829b016da597b89d5eda8dc6a2c..e1910446de2ac7e3781a6e740f74a8e553dfc8db 100644 (file)
@@ -40,7 +40,7 @@ static bool PropagatePredecessorsForPHIs(BasicBlock *BB, BasicBlock *Succ) {
       // Loop over all of the PHI nodes checking to see if there are
       // incompatible values coming in.
       for (BasicBlock::iterator I = Succ->begin();
-           PHINode *PN = dyn_cast<PHINode>(&*I); ++I) {
+           PHINode *PN = dyn_cast<PHINode>(I); ++I) {
         // Loop up the entries in the PHI node for BB and for *PI if the values
         // coming in are non-equal, we cannot merge these two blocks (instead we
         // should insert a conditional move or something, then merge the
@@ -56,7 +56,7 @@ static bool PropagatePredecessorsForPHIs(BasicBlock *BB, BasicBlock *Succ) {
 
   // Loop over all of the PHI nodes in the successor BB
   for (BasicBlock::iterator I = Succ->begin();
-       PHINode *PN = dyn_cast<PHINode>(&*I); ++I) {
+       PHINode *PN = dyn_cast<PHINode>(I); ++I) {
     Value *OldVal = PN->removeIncomingValue(BB, false);
     assert(OldVal && "No entry in PHI for Pred BB!");
 
index 89f9a27f8da8279bc0075b4df3ef0f707649e352..04f4e1cfc0d95863954562eb28ec2adae62c30a8 100644 (file)
@@ -196,7 +196,7 @@ void BasicBlock::removePredecessor(BasicBlock *Pred) {
   } else {
     // Okay, now we know that we need to remove predecessor #pred_idx from all
     // PHI nodes.  Iterate over each PHI node fixing them up
-    for (iterator II = begin(); PHINode *PN = dyn_cast<PHINode>(&*II); ++II)
+    for (iterator II = begin(); PHINode *PN = dyn_cast<PHINode>(II); ++II)
       PN->removeIncomingValue(Pred);
   }
 }
@@ -243,7 +243,7 @@ BasicBlock *BasicBlock::splitBasicBlock(iterator I) {
     // incoming values...
     BasicBlock *Successor = *I;
     for (BasicBlock::iterator II = Successor->begin();
-         PHINode *PN = dyn_cast<PHINode>(&*II); ++II) {
+         PHINode *PN = dyn_cast<PHINode>(II); ++II) {
       int IDX = PN->getBasicBlockIndex(this);
       while (IDX != -1) {
         PN->setIncomingBlock((unsigned)IDX, New);