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

@ -109,6 +109,13 @@ bool CallSite::hasArgument(const Value *Arg) const {
return false;
}
User::op_iterator CallSite::getCallee() const {
Instruction *II(getInstruction());
return isCall()
? cast<CallInst>(II)->op_begin()
: cast<InvokeInst>(II)->op_end() - 3; // Skip BB, BB, Function
}
#undef CALLSITE_DELEGATE_GETTER
#undef CALLSITE_DELEGATE_SETTER
@ -622,10 +629,9 @@ Instruction* CallInst::CreateFree(Value* Source, BasicBlock *InsertAtEnd) {
void InvokeInst::init(Value *Fn, BasicBlock *IfNormal, BasicBlock *IfException,
Value* const *Args, unsigned NumArgs) {
assert(NumOperands == 3+NumArgs && "NumOperands not set up?");
Use *OL = OperandList;
OL[0] = Fn;
OL[1] = IfNormal;
OL[2] = IfException;
Op<-3>() = Fn;
Op<-2>() = IfNormal;
Op<-1>() = IfException;
const FunctionType *FTy =
cast<FunctionType>(cast<PointerType>(Fn->getType())->getElementType());
FTy = FTy; // silence warning.
@ -634,12 +640,13 @@ void InvokeInst::init(Value *Fn, BasicBlock *IfNormal, BasicBlock *IfException,
(FTy->isVarArg() && NumArgs > FTy->getNumParams())) &&
"Invoking a function with bad signature");
Use *OL = OperandList;
for (unsigned i = 0, e = NumArgs; i != e; i++) {
assert((i >= FTy->getNumParams() ||
FTy->getParamType(i) == Args[i]->getType()) &&
"Invoking a function with a bad signature!");
OL[i+3] = Args[i];
OL[i] = Args[i];
}
}