Finally land the InvokeInst operand reordering.

I have audited all getOperandNo calls now, fixing
hidden assumptions. CallSite related uglyness will
be eliminated successively.

Note this patch has a long and griveous history,
for all the back-and-forths have a look at
CallSite.h's log.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99399 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Gabor Greif
2010-03-24 13:21:49 +00:00
parent 6d6aaeca4f
commit c9f7500d17
14 changed files with 80 additions and 47 deletions

View File

@@ -2522,32 +2522,31 @@ public:
/// indirect function invocation.
///
Function *getCalledFunction() const {
return dyn_cast<Function>(getOperand(0));
return dyn_cast<Function>(Op<-3>());
}
/// getCalledValue - Get a pointer to the function that is invoked by this
/// instruction
const Value *getCalledValue() const { return getOperand(0); }
Value *getCalledValue() { return getOperand(0); }
const Value *getCalledValue() const { return Op<-3>(); }
Value *getCalledValue() { return Op<-3>(); }
/// setCalledFunction - Set the function called.
void setCalledFunction(Value* Fn) {
Op<0>() = Fn;
Op<-3>() = Fn;
}
// get*Dest - Return the destination basic blocks...
BasicBlock *getNormalDest() const {
return cast<BasicBlock>(getOperand(1));
return cast<BasicBlock>(Op<-2>());
}
BasicBlock *getUnwindDest() const {
return cast<BasicBlock>(getOperand(2));
return cast<BasicBlock>(Op<-1>());
}
void setNormalDest(BasicBlock *B) {
setOperand(1, (Value*)B);
Op<-2>() = reinterpret_cast<Value*>(B);
}
void setUnwindDest(BasicBlock *B) {
setOperand(2, (Value*)B);
Op<-1>() = reinterpret_cast<Value*>(B);
}
BasicBlock *getSuccessor(unsigned i) const {
@@ -2557,7 +2556,7 @@ public:
void setSuccessor(unsigned idx, BasicBlock *NewSucc) {
assert(idx < 2 && "Successor # out of range for invoke!");
setOperand(idx+1, (Value*)NewSucc);
*(&Op<-2>() + idx) = reinterpret_cast<Value*>(NewSucc);
}
unsigned getNumSuccessors() const { return 2; }
@@ -2570,6 +2569,7 @@ public:
static inline bool classof(const Value *V) {
return isa<Instruction>(V) && classof(cast<Instruction>(V));
}
private:
virtual BasicBlock *getSuccessorV(unsigned idx) const;
virtual unsigned getNumSuccessorsV() const;