- Assert1(I->getType() != Type::VoidTy || !I->hasName(),
- "Instruction has a name, but provides a void value!", I);
+ // Check that void typed values don't have names
+ Assert1(I.getType() != Type::VoidTy || !I.hasName(),
+ "Instruction has a name, but provides a void value!", &I);
+
+ // Check that a definition dominates all of its uses.
+ //
+ for (User::use_iterator UI = I.use_begin(), UE = I.use_end();
+ UI != UE; ++UI) {
+ Instruction *Use = cast<Instruction>(*UI);
+
+ // PHI nodes are more difficult than other nodes because they actually
+ // "use" the value in the predecessor basic blocks they correspond to.
+ if (PHINode *PN = dyn_cast<PHINode>(Use)) {
+ for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i)
+ if (&I == PN->getIncomingValue(i)) {
+ // Make sure that I dominates the end of pred(i)
+ BasicBlock *Pred = PN->getIncomingBlock(i);
+
+ Assert2(DS->dominates(I.getParent(), Pred),
+ "Instruction does not dominate all uses!",
+ &I, PN);
+ }
+
+ } else {
+ Assert2(DS->dominates(&I, Use),
+ "Instruction does not dominate all uses!", &I, Use);
+ }
+ }