llvm.org GIT mirror llvm / e408e25
Remove unnecesary &*'s git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5872 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 17 years ago
19 changed file(s) with 37 addition(s) and 37 deletion(s). Raw diff Collapse all Expand all
168168
169169 static inline bool DoFunctionInlining(BasicBlock *BB) {
170170 for (BasicBlock::iterator I = BB->begin(); I != BB->end(); ++I) {
171 if (CallInst *CI = dyn_cast(&*I)) {
171 if (CallInst *CI = dyn_cast(I)) {
172172 // Check to see if we should inline this function
173173 Function *F = CI->getCalledFunction();
174174 if (F && ShouldInlineFunction(CI, F)) {
385385 for(BasicBlock::iterator BB2Inst = BB2->begin(), BBend = BB2->end();
386386 BB2Inst != BBend; ++BB2Inst){
387387
388 if(PHINode *phiInst=dyn_cast(&*BB2Inst)){
388 if(PHINode *phiInst=dyn_cast(BB2Inst)){
389389 int bbIndex=phiInst->getBasicBlockIndex(BB1);
390390 assert(bbIndex>=0);
391391 phiInst->setIncomingBlock(bbIndex, newBB);
132132 for(BasicBlock::iterator BB2Inst = BB->begin(), BBend = BB->end();
133133 BB2Inst != BBend; ++BB2Inst){
134134
135 if(PHINode *phiInst=dyn_cast(&*BB2Inst)){
135 if (PHINode *phiInst = dyn_cast(BB2Inst)){
136136 int bbIndex = phiInst->getBasicBlockIndex(u);
137137 if(bbIndex>=0){
138138 phiInst->setIncomingBlock(bbIndex, newBB);
8686 nodes.push_back(nd);
8787 if(&*BB == ExitNode)
8888 exitNode=nd;
89 if(&*BB==F.begin())
89 if(BB==F.begin())
9090 startNode=nd;
9191 }
9292
139139 BasicBlock *ExitNode = 0;
140140 for (Function::iterator I = M->begin(), E = M->end(); I != E; ++I){
141141 if (isa(I->getTerminator())) {
142 ExitNode = &*I;
142 ExitNode = I;
143143 break;
144144 }
145145 }
159159 if(BB->size()==3 || BB->size() ==2){
160160 for(BasicBlock::iterator II = BB->begin(), IE = BB->end();
161161 II != IE; ++II){
162 if(CallInst *callInst = dyn_cast(&*II)){
162 if(CallInst *callInst = dyn_cast(II)){
163163 //std::cerr<<*callInst;
164164 Function *calledFunction = callInst->getCalledFunction();
165165 if(calledFunction && calledFunction->getName() == "trigger"){
198198 continue;
199199
200200 //if(BB->size()==3)
201 //if(CallInst *callInst = dyn_cast(&*BB->getInstList().begin()))
201 //if(CallInst *callInst = dyn_cast(BB->getInstList().begin()))
202202 //if(callInst->getCalledFunction()->getName() == "trigger")
203203 //continue;
204204
215215 Node *nd=findBB(nodes, BB);
216216 assert(nd && "No node for this edge!");
217217
218 for(BasicBlock::succ_iterator s=succ_begin(&*BB), se=succ_end(&*BB);
218 for(BasicBlock::succ_iterator s=succ_begin(BB), se=succ_end(BB);
219219 s!=se; ++s){
220220
221221 if(triggerBBs[*s] == 9){
222222 //if(!pathReg[M]){ //Get the path register for this!
223223 //if(BB->size()>8)
224 // if(LoadInst *ldInst = dyn_cast(&*BB->getInstList().begin()))
224 // if(LoadInst *ldInst = dyn_cast(BB->getInstList().begin()))
225225 // pathReg[M] = ldInst->getPointerOperand();
226226 //}
227227 continue;
228228 }
229229 //if((*s)->size()==3)
230230 //if(CallInst *callInst =
231 // dyn_cast(&*(*s)->getInstList().begin()))
231 // dyn_cast((*s)->getInstList().begin()))
232232 // if(callInst->getCalledFunction()->getName() == "trigger")
233233 // continue;
234234
283283 VBI != VBE; ++VBI){
284284 for(BasicBlock::iterator BBI = (*VBI)->begin(), BBE = (*VBI)->end();
285285 BBI != BBE; ++BBI){
286 if(LoadInst *ldInst = dyn_cast(&*BBI)){
286 if(LoadInst *ldInst = dyn_cast(BBI)){
287287 if(pathReg[M] == ldInst->getPointerOperand())
288288 instToErase.push_back(ldInst);
289289 }
290 else if(StoreInst *stInst = dyn_cast(&*BBI)){
290 else if(StoreInst *stInst = dyn_cast(BBI)){
291291 if(pathReg[M] == stInst->getPointerOperand())
292292 instToErase.push_back(stInst);
293293 }
297297 ExternalFuncs& externalFuncs) {
298298
299299 for (BasicBlock::iterator II=BB->begin(), IE = BB->end(); II != IE; ++II)
300 if (FreeInst *FI = dyn_cast(&*II))
300 if (FreeInst *FI = dyn_cast(II))
301301 InsertReleaseInst(FI->getOperand(0), BB, FI,externalFuncs.ReleasePtrFunc);
302 else if (AllocaInst *AI = dyn_cast(&*II))
302 else if (AllocaInst *AI = dyn_cast(II))
303303 InsertRecordInst(AI, BB, AI->getNext(), externalFuncs.RecordPtrFunc);
304304 }
305305
331331 // instruction *preceding* InsertPos to check when to terminate the loop.
332332 //
333333 for (BasicBlock::iterator II = BB->begin(); &*II != InsertPos; ++II) {
334 if (StoreInst *SI = dyn_cast(&*II)) {
334 if (StoreInst *SI = dyn_cast(II)) {
335335 assert(valuesStoredInFunction &&
336336 "Should not be printing a store instruction at function exit");
337337 LoadInst *LI = new LoadInst(SI->getPointerOperand(), "reload." +
118118 for (BasicBlock::iterator I = BB->begin(), E = --BB->end(); I != E; )
119119 if (!LiveSet.count(I)) { // Is this instruction alive?
120120 I->dropAllReferences(); // Nope, drop references...
121 if (PHINode *PN = dyn_cast(&*I)) {
121 if (PHINode *PN = dyn_cast(I)) {
122122 // We don't want to leave PHI nodes in the program that have
123123 // #arguments != #predecessors, so we remove them now.
124124 //
309309 // should be identical to the incoming values for LastDead.
310310 //
311311 for (BasicBlock::iterator II = NextAlive->begin();
312 PHINode *PN = dyn_cast(&*II); ++II) {
312 PHINode *PN = dyn_cast(II); ++II) {
313313 // Get the incoming value for LastDead...
314314 int OldIdx = PN->getBasicBlockIndex(LastDead);
315315 assert(OldIdx != -1 && "LastDead is not a pred of NextAlive!");
449449
450450 // Put the newly discovered information into the RegionInfo...
451451 for (BasicBlock::iterator I = OldSucc->begin(), E = OldSucc->end(); I!=E; ++I)
452 if (PHINode *PN = dyn_cast(&*I)) {
452 if (PHINode *PN = dyn_cast(I)) {
453453 int OpNum = PN->getBasicBlockIndex(BB);
454454 assert(OpNum != -1 && "PHI doesn't have incoming edge for predecessor!?");
455455 PropagateEquality(PN, PN->getIncomingValue(OpNum), NewRI);
456 } else if (SetCondInst *SCI = dyn_cast(&*I)) {
456 } else if (SetCondInst *SCI = dyn_cast(I)) {
457457 Relation::KnownResult Res = getSetCCResult(SCI, NewRI);
458458 if (Res == Relation::Unknown) return false;
459459 PropagateEquality(SCI, ConstantBool::get(Res), NewRI);
562562 // node with a new value.
563563 //
564564 for (BasicBlock::iterator I = OldSucc->begin();
565 PHINode *PN = dyn_cast(&*I); ) {
565 PHINode *PN = dyn_cast(I); ) {
566566
567567 // Get the value flowing across the old edge and remove the PHI node entry
568568 // for this edge: we are about to remove the edge! Don't remove the PHI
992992 bool CEE::SimplifyBasicBlock(BasicBlock &BB, const RegionInfo &RI) {
993993 bool Changed = false;
994994 for (BasicBlock::iterator I = BB.begin(), E = BB.end(); I != E; ) {
995 Instruction *Inst = &*I++;
995 Instruction *Inst = I++;
996996
997997 // Convert instruction arguments to canonical forms...
998998 Changed |= SimplifyInstruction(Inst, RI);
4343 {
4444 bool changed = false;
4545 for (BasicBlock::iterator II = BB.begin(); II != BB.end(); )
46 if (GetElementPtrInst *gep = dyn_cast(&*II++)) // pre-inc
46 if (GetElementPtrInst *gep = dyn_cast(II++)) // pre-inc
4747 if (gep->getNumIndices() >= 2)
4848 changed |= DecomposeArrayRef(gep); // always modifies II
4949 return changed;
4444 //
4545 std::vector IndVars; // Induction variables for block
4646 BasicBlock::iterator AfterPHIIt = Header->begin();
47 for (; PHINode *PN = dyn_cast(&*AfterPHIIt); ++AfterPHIIt)
47 for (; PHINode *PN = dyn_cast(AfterPHIIt); ++AfterPHIIt)
4848 IndVars.push_back(InductionVariable(PN, Loops));
4949 // AfterPHIIt now points to first nonphi instruction...
5050
318318 // Rewrite all loads and stores in the block of the pointer...
319319 for (BasicBlock::iterator II = (*I)->begin(), E = (*I)->end();
320320 II != E; ++II) {
321 if (LoadInst *L = dyn_cast(&*II)) {
321 if (LoadInst *L = dyn_cast(II)) {
322322 std::map::iterator
323323 I = ValueToAllocaMap.find(L->getOperand(0));
324324 if (I != ValueToAllocaMap.end())
325325 L->setOperand(0, I->second); // Rewrite load instruction...
326 } else if (StoreInst *S = dyn_cast(&*II)) {
326 } else if (StoreInst *S = dyn_cast(II)) {
327327 std::map::iterator
328328 I = ValueToAllocaMap.find(S->getOperand(1));
329329 if (I != ValueToAllocaMap.end())
223223 // the two operands are sorted incorrectly, fix it now.
224224 //
225225 if (BI->isAssociative()) {
226 BinaryOperator *I = cast(&*BI);
226 BinaryOperator *I = cast(BI);
227227 if (!I->use_empty()) {
228228 // Make sure that we don't have a tree-shaped computation. If we do,
229229 // linearize it. Convert (A+B)+(C+D) into ((A+B)+C)+D
473473 // constant now may not be.
474474 //
475475 for (BasicBlock::iterator I = Succ->begin();
476 PHINode *PN = dyn_cast(&*I); ++I)
476 PHINode *PN = dyn_cast(I); ++I)
477477 visitPHINode(*PN);
478478 }
479479 }
8484 // merge incoming values from NewBB instead of from TIBB.
8585 //
8686 for (BasicBlock::iterator I = DestBB->begin();
87 PHINode *PN = dyn_cast(&*I); ++I) {
87 PHINode *PN = dyn_cast(I); ++I) {
8888 // We no longer enter through TIBB, now we come in through NewBB.
8989 PN->replaceUsesOfWith(TIBB, NewBB);
9090 }
131131 //
132132 if (!Preds.empty()) { // Is the loop not obviously dead?
133133 for (BasicBlock::iterator I = BB->begin();
134 PHINode *PN = dyn_cast(&*I); ++I) {
134 PHINode *PN = dyn_cast(I); ++I) {
135135
136136 // Create the new PHI node, insert it into NewBB at the end of the block
137137 PHINode *NewPHI = new PHINode(PN->getType(), PN->getName()+".ph", BI);
159159
160160 } else { // Otherwise the loop is dead...
161161 for (BasicBlock::iterator I = BB->begin();
162 PHINode *PN = dyn_cast(&*I); ++I)
162 PHINode *PN = dyn_cast(I); ++I)
163163 // Insert dummy values as the incoming value...
164164 PN->addIncoming(Constant::getNullValue(PN->getType()), NewBB);
165165 }
8484
8585 // Loop over all of the instructions, looking for malloc or free instructions
8686 for (BasicBlock::iterator I = BB.begin(), E = BB.end(); I != E; ++I) {
87 if (MallocInst *MI = dyn_cast(&*I)) {
87 if (MallocInst *MI = dyn_cast(I)) {
8888 const Type *AllocTy = MI->getType()->getElementType();
8989
9090 // Get the number of bytes to be allocated for one element of the
113113 I = --BBIL.erase(I); // remove and delete the malloc instr...
114114 Changed = true;
115115 ++NumLowered;
116 } else if (FreeInst *FI = dyn_cast(&*I)) {
116 } else if (FreeInst *FI = dyn_cast(I)) {
117117 // Cast the argument to free into a ubyte*...
118118 CastInst *MCast = new CastInst(FI->getOperand(0),
119119 PointerType::get(Type::UByteTy), "", I);
4242 // Find allocas that are safe to promote, by looking at all instructions in
4343 // the entry node
4444 for (BasicBlock::iterator I = BB.begin(), E = --BB.end(); I != E; ++I)
45 if (AllocaInst *AI = dyn_cast(&*I)) // Is it an alloca?
45 if (AllocaInst *AI = dyn_cast(I)) // Is it an alloca?
4646 if (isAllocaPromotable(AI, TD))
4747 Allocas.push_back(AI);
4848
3939 // Loop over all of the PHI nodes checking to see if there are
4040 // incompatible values coming in.
4141 for (BasicBlock::iterator I = Succ->begin();
42 PHINode *PN = dyn_cast(&*I); ++I) {
42 PHINode *PN = dyn_cast(I); ++I) {
4343 // Loop up the entries in the PHI node for BB and for *PI if the values
4444 // coming in are non-equal, we cannot merge these two blocks (instead we
4545 // should insert a conditional move or something, then merge the
5555
5656 // Loop over all of the PHI nodes in the successor BB
5757 for (BasicBlock::iterator I = Succ->begin();
58 PHINode *PN = dyn_cast(&*I); ++I) {
58 PHINode *PN = dyn_cast(I); ++I) {
5959 Value *OldVal = PN->removeIncomingValue(BB, false);
6060 assert(OldVal && "No entry in PHI for Pred BB!");
6161
195195 } else {
196196 // Okay, now we know that we need to remove predecessor #pred_idx from all
197197 // PHI nodes. Iterate over each PHI node fixing them up
198 for (iterator II = begin(); PHINode *PN = dyn_cast(&*II); ++II)
198 for (iterator II = begin(); PHINode *PN = dyn_cast(II); ++II)
199199 PN->removeIncomingValue(Pred);
200200 }
201201 }
242242 // incoming values...
243243 BasicBlock *Successor = *I;
244244 for (BasicBlock::iterator II = Successor->begin();
245 PHINode *PN = dyn_cast(&*II); ++II) {
245 PHINode *PN = dyn_cast(II); ++II) {
246246 int IDX = PN->getBasicBlockIndex(this);
247247 while (IDX != -1) {
248248 PN->setIncomingBlock((unsigned)IDX, New);