Revert "[opaque pointer type] Avoid using PointerType::getElementType for a few cases of CallInst"

This reverts commit r235458.

It looks like this might be breaking something LTO-ish. Looking into it
& will recommit with a fix/test case/etc once I've got more to go on.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235533 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Blaikie
2015-04-22 18:16:49 +00:00
parent c61f7144eb
commit cfe6126e17
8 changed files with 46 additions and 116 deletions

View File

@@ -194,14 +194,6 @@ public:
CALLSITE_DELEGATE_SETTER(setCallingConv(CC));
}
FunctionType *getFunctionType() const {
CALLSITE_DELEGATE_GETTER(getFunctionType());
}
void mutateFunctionType(FunctionType *Ty) const {
CALLSITE_DELEGATE_SETTER(mutateFunctionType(Ty));
}
/// getAttributes/setAttributes - get or set the parameter attributes of
/// the call.
const AttributeSet &getAttributes() const {

View File

@@ -1284,26 +1284,14 @@ public:
///
class CallInst : public Instruction {
AttributeSet AttributeList; ///< parameter attributes for call
FunctionType *FTy;
CallInst(const CallInst &CI);
void init(Value *Func, ArrayRef<Value *> Args, const Twine &NameStr) {
init(cast<FunctionType>(
cast<PointerType>(Func->getType())->getElementType()),
Func, Args, NameStr);
}
void init(FunctionType *FTy, Value *Func, ArrayRef<Value *> Args,
const Twine &NameStr);
void init(Value *Func, ArrayRef<Value *> Args, const Twine &NameStr);
void init(Value *Func, const Twine &NameStr);
/// Construct a CallInst given a range of arguments.
/// \brief Construct a CallInst from a range of arguments
inline CallInst(FunctionType *Ty, Value *Func, ArrayRef<Value *> Args,
inline CallInst(Value *Func, ArrayRef<Value *> Args,
const Twine &NameStr, Instruction *InsertBefore);
inline CallInst(Value *Func, ArrayRef<Value *> Args, const Twine &NameStr,
Instruction *InsertBefore)
: CallInst(cast<FunctionType>(
cast<PointerType>(Func->getType())->getElementType()),
Func, Args, NameStr, InsertBefore) {}
/// Construct a CallInst given a range of arguments.
/// \brief Construct a CallInst from a range of arguments
@@ -1320,15 +1308,8 @@ public:
ArrayRef<Value *> Args,
const Twine &NameStr = "",
Instruction *InsertBefore = nullptr) {
return Create(cast<FunctionType>(
cast<PointerType>(Func->getType())->getElementType()),
Func, Args, NameStr, InsertBefore);
}
static CallInst *Create(FunctionType *Ty, Value *Func, ArrayRef<Value *> Args,
const Twine &NameStr = "",
Instruction *InsertBefore = nullptr) {
return new (unsigned(Args.size() + 1))
CallInst(Ty, Func, Args, NameStr, InsertBefore);
return new(unsigned(Args.size() + 1))
CallInst(Func, Args, NameStr, InsertBefore);
}
static CallInst *Create(Value *Func,
ArrayRef<Value *> Args,
@@ -1366,11 +1347,9 @@ public:
~CallInst() override;
FunctionType *getFunctionType() const { return FTy; }
void mutateFunctionType(FunctionType *FTy) {
mutateType(FTy->getReturnType());
this->FTy = FTy;
FunctionType *getFunctionType() const {
return cast<FunctionType>(
cast<PointerType>(getCalledValue()->getType())->getElementType());
}
// Note that 'musttail' implies 'tail'.
@@ -1554,14 +1533,6 @@ public:
/// setCalledFunction - Set the function called.
void setCalledFunction(Value* Fn) {
setCalledFunction(
cast<FunctionType>(cast<PointerType>(Fn->getType())->getElementType()),
Fn);
}
void setCalledFunction(FunctionType *FTy, Value *Fn) {
this->FTy = FTy;
assert(FTy == cast<FunctionType>(
cast<PointerType>(Fn->getType())->getElementType()));
Op<-1>() = Fn;
}
@@ -1602,12 +1573,14 @@ CallInst::CallInst(Value *Func, ArrayRef<Value *> Args,
init(Func, Args, NameStr);
}
CallInst::CallInst(FunctionType *Ty, Value *Func, ArrayRef<Value *> Args,
CallInst::CallInst(Value *Func, ArrayRef<Value *> Args,
const Twine &NameStr, Instruction *InsertBefore)
: Instruction(Ty->getReturnType(), Instruction::Call,
OperandTraits<CallInst>::op_end(this) - (Args.size() + 1),
unsigned(Args.size() + 1), InsertBefore) {
init(Ty, Func, Args, NameStr);
: Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
->getElementType())->getReturnType(),
Instruction::Call,
OperandTraits<CallInst>::op_end(this) - (Args.size() + 1),
unsigned(Args.size() + 1), InsertBefore) {
init(Func, Args, NameStr);
}
@@ -3061,7 +3034,6 @@ DEFINE_TRANSPARENT_OPERAND_ACCESSORS(IndirectBrInst, Value)
///
class InvokeInst : public TerminatorInst {
AttributeSet AttributeList;
FunctionType *FTy;
InvokeInst(const InvokeInst &BI);
void init(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException,
ArrayRef<Value *> Args, const Twine &NameStr);
@@ -3102,13 +3074,6 @@ public:
/// Provide fast operand accessors
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
FunctionType *getFunctionType() const { return FTy; }
void mutateFunctionType(FunctionType *FTy) {
mutateType(FTy->getReturnType());
this->FTy = FTy;
}
/// getNumArgOperands - Return the number of invoke arguments.
///
unsigned getNumArgOperands() const { return getNumOperands() - 3; }
@@ -3258,14 +3223,6 @@ public:
/// setCalledFunction - Set the function called.
void setCalledFunction(Value* Fn) {
setCalledFunction(
cast<FunctionType>(cast<PointerType>(Fn->getType())->getElementType()),
Fn);
}
void setCalledFunction(FunctionType *FTy, Value *Fn) {
this->FTy = FTy;
assert(FTy == cast<FunctionType>(
cast<PointerType>(Fn->getType())->getElementType()));
Op<-3>() = Fn;
}