X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=docs%2FProgrammersManual.html;h=716d364ed5699a2c73ca2c84ca93dbf3aee094be;hb=9eb698b96d8b753b2f5025baae0712167cf7fb03;hp=66bca9b7757dc8dc122be4a12aa86ab434a098ec;hpb=10d64b95a121e69dbd70f7ed9fa660085f13f779;p=oota-llvm.git diff --git a/docs/ProgrammersManual.html b/docs/ProgrammersManual.html index 66bca9b7757..716d364ed56 100644 --- a/docs/ProgrammersManual.html +++ b/docs/ProgrammersManual.html @@ -103,6 +103,8 @@ complex example the same way
std::set<Instruction*> worklist; -worklist.insert(inst_begin(F), inst_end(F)); +// or better yet, SmallPtrSet<Instruction*, 64> worklist; + +for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I) + worklist.insert(&*I);
-Instruction* pinst = &*i; +Instruction *pinst = &*i;
-Instruction* pinst = i; +Instruction *pinst = i;
-Function* F = ...; +Function *F = ...; for (Value::use_iterator i = F->use_begin(), e = F->use_end(); i != e; ++i) if (Instruction *Inst = dyn_cast<Instruction>(*i)) { @@ -1694,10 +1698,10 @@ the particular Instruction):+ + + +-Instruction* pi = ...; +Instruction *pi = ...; for (User::op_iterator i = pi->op_begin(), e = pi->op_end(); i != e; ++i) { - Value* v = *i; + Value *v = *i; // ... }@@ -1710,6 +1714,36 @@ for (User::op_iterator i = pi->op_begin(), e = pi->op_end(); i != e; ++i)+ ++ +Iterating over the predecessors and successors of a block is quite easy +with the routines defined in "llvm/Support/CFG.h". Just use code like +this to iterate over all predecessors of BB:
+ +++ ++#include "llvm/Support/CFG.h" +BasicBlock *BB = ...; + +for (pred_iterator PI = pred_begin(BB), E = pred_end(BB); PI != E; ++PI) { + BasicBlock *Pred = *PI; + // ... +} ++Similarly, to iterate over successors use +succ_iterator/succ_begin/succ_end.
+ +Making simple changes @@ -1883,9 +1917,7 @@ erase function to remove your instruction. For example:Instruction *I = .. ; -BasicBlock *BB = I->getParent(); - -BB->getInstList().erase(I); +I->eraseFromParent();