summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2015-04-22 18:16:49 +0000
committerDavid Blaikie <dblaikie@gmail.com>2015-04-22 18:16:49 +0000
commitd2db881e8552ec3e5a1b20f91e8d07d6424d6855 (patch)
tree58adcc7630cf4f69e534702e06a532f15d32e227 /llvm/lib
parent037b700b7f0caecabc745217fd421c8bca06f6eb (diff)
downloadbcm5719-llvm-d2db881e8552ec3e5a1b20f91e8d07d6424d6855.tar.gz
bcm5719-llvm-d2db881e8552ec3e5a1b20f91e8d07d6424d6855.zip
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. llvm-svn: 235533
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/AsmParser/LLParser.cpp2
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp13
-rw-r--r--llvm/lib/IR/Instructions.cpp37
-rw-r--r--llvm/lib/IR/Verifier.cpp6
-rw-r--r--llvm/lib/Transforms/Utils/ValueMapper.cpp13
-rw-r--r--llvm/lib/Transforms/Vectorize/BBVectorize.cpp12
6 files changed, 32 insertions, 51 deletions
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp
index 64bf7cdc919..8e2842bd720 100644
--- a/llvm/lib/AsmParser/LLParser.cpp
+++ b/llvm/lib/AsmParser/LLParser.cpp
@@ -5223,7 +5223,7 @@ bool LLParser::ParseCall(Instruction *&Inst, PerFunctionState &PFS,
// Finish off the Attribute and check them
AttributeSet PAL = AttributeSet::get(Context, Attrs);
- CallInst *CI = CallInst::Create(Ty, Callee, Args);
+ CallInst *CI = CallInst::Create(Callee, Args);
CI->setTailCallKind(TCK);
CI->setCallingConv(CC);
CI->setAttributes(PAL);
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index a16be24a5b5..162dd2c4c74 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -4207,11 +4207,12 @@ std::error_code BitcodeReader::ParseFunctionBody(Function *F) {
PointerType *OpTy = dyn_cast<PointerType>(Callee->getType());
if (!OpTy)
return Error("Callee is not a pointer type");
- if (!FTy) {
- FTy = dyn_cast<FunctionType>(OpTy->getElementType());
- if (!FTy)
- return Error("Callee is not of pointer to function type");
- } else if (OpTy->getElementType() != FTy)
+ FunctionType *PFTy = dyn_cast<FunctionType>(OpTy->getElementType());
+ if (!PFTy)
+ return Error("Callee is not of pointer to function type");
+ if (!FTy)
+ FTy = PFTy;
+ if (PFTy != FTy)
return Error("Explicit call type does not match pointee type of "
"callee operand");
if (Record.size() < FTy->getNumParams() + OpNum)
@@ -4242,7 +4243,7 @@ std::error_code BitcodeReader::ParseFunctionBody(Function *F) {
}
}
- I = CallInst::Create(FTy, Callee, Args);
+ I = CallInst::Create(Callee, Args);
InstructionList.push_back(I);
cast<CallInst>(I)->setCallingConv(
static_cast<CallingConv::ID>((~(1U << 14) & CCInfo) >> 1));
diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp
index aa878ea436e..b2898429239 100644
--- a/llvm/lib/IR/Instructions.cpp
+++ b/llvm/lib/IR/Instructions.cpp
@@ -263,13 +263,14 @@ void LandingPadInst::addClause(Constant *Val) {
CallInst::~CallInst() {
}
-void CallInst::init(FunctionType *FTy, Value *Func, ArrayRef<Value *> Args,
- const Twine &NameStr) {
- this->FTy = FTy;
+void CallInst::init(Value *Func, ArrayRef<Value *> Args, const Twine &NameStr) {
assert(NumOperands == Args.size() + 1 && "NumOperands not set up?");
Op<-1>() = Func;
#ifndef NDEBUG
+ FunctionType *FTy =
+ cast<FunctionType>(cast<PointerType>(Func->getType())->getElementType());
+
assert((Args.size() == FTy->getNumParams() ||
(FTy->isVarArg() && Args.size() > FTy->getNumParams())) &&
"Calling a function with bad signature!");
@@ -285,12 +286,15 @@ void CallInst::init(FunctionType *FTy, Value *Func, ArrayRef<Value *> Args,
}
void CallInst::init(Value *Func, const Twine &NameStr) {
- FTy =
- cast<FunctionType>(cast<PointerType>(Func->getType())->getElementType());
assert(NumOperands == 1 && "NumOperands not set up?");
Op<-1>() = Func;
+#ifndef NDEBUG
+ FunctionType *FTy =
+ cast<FunctionType>(cast<PointerType>(Func->getType())->getElementType());
+
assert(FTy->getNumParams() == 0 && "Calling a function with bad signature");
+#endif
setName(NameStr);
}
@@ -316,10 +320,10 @@ CallInst::CallInst(Value *Func, const Twine &Name,
}
CallInst::CallInst(const CallInst &CI)
- : Instruction(CI.getType(), Instruction::Call,
- OperandTraits<CallInst>::op_end(this) - CI.getNumOperands(),
- CI.getNumOperands()),
- AttributeList(CI.AttributeList), FTy(CI.FTy) {
+ : Instruction(CI.getType(), Instruction::Call,
+ OperandTraits<CallInst>::op_end(this) - CI.getNumOperands(),
+ CI.getNumOperands()) {
+ setAttributes(CI.getAttributes());
setTailCallKind(CI.getTailCallKind());
setCallingConv(CI.getCallingConv());
@@ -539,14 +543,15 @@ Instruction* CallInst::CreateFree(Value* Source, BasicBlock *InsertAtEnd) {
void InvokeInst::init(Value *Fn, BasicBlock *IfNormal, BasicBlock *IfException,
ArrayRef<Value *> Args, const Twine &NameStr) {
- FTy = cast<FunctionType>(cast<PointerType>(Fn->getType())->getElementType());
-
assert(NumOperands == 3 + Args.size() && "NumOperands not set up?");
Op<-3>() = Fn;
Op<-2>() = IfNormal;
Op<-1>() = IfException;
#ifndef NDEBUG
+ FunctionType *FTy =
+ cast<FunctionType>(cast<PointerType>(Fn->getType())->getElementType());
+
assert(((Args.size() == FTy->getNumParams()) ||
(FTy->isVarArg() && Args.size() > FTy->getNumParams())) &&
"Invoking a function with bad signature");
@@ -562,11 +567,11 @@ void InvokeInst::init(Value *Fn, BasicBlock *IfNormal, BasicBlock *IfException,
}
InvokeInst::InvokeInst(const InvokeInst &II)
- : TerminatorInst(II.getType(), Instruction::Invoke,
- OperandTraits<InvokeInst>::op_end(this) -
- II.getNumOperands(),
- II.getNumOperands()),
- AttributeList(II.AttributeList), FTy(II.FTy) {
+ : TerminatorInst(II.getType(), Instruction::Invoke,
+ OperandTraits<InvokeInst>::op_end(this)
+ - II.getNumOperands(),
+ II.getNumOperands()) {
+ setAttributes(II.getAttributes());
setCallingConv(II.getCallingConv());
std::copy(II.op_begin(), II.op_end(), op_begin());
SubclassOptionalData = II.SubclassOptionalData;
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index 7001c556d20..e14f1036912 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -2120,11 +2120,7 @@ void Verifier::VerifyCallSite(CallSite CS) {
Assert(FPTy->getElementType()->isFunctionTy(),
"Called function is not pointer to function type!", I);
-
- Assert(FPTy->getElementType() == CS.getFunctionType(),
- "Called function is not the same type as the call!", I);
-
- FunctionType *FTy = CS.getFunctionType();
+ FunctionType *FTy = cast<FunctionType>(FPTy->getElementType());
// Verify that the correct number of arguments are being passed
if (FTy->isVarArg())
diff --git a/llvm/lib/Transforms/Utils/ValueMapper.cpp b/llvm/lib/Transforms/Utils/ValueMapper.cpp
index a70d6d769b7..54c76887234 100644
--- a/llvm/lib/Transforms/Utils/ValueMapper.cpp
+++ b/llvm/lib/Transforms/Utils/ValueMapper.cpp
@@ -13,7 +13,6 @@
//===----------------------------------------------------------------------===//
#include "llvm/Transforms/Utils/ValueMapper.h"
-#include "llvm/IR/CallSite.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/InlineAsm.h"
@@ -385,16 +384,6 @@ void llvm::RemapInstruction(Instruction *I, ValueToValueMapTy &VMap,
}
// If the instruction's type is being remapped, do so now.
- if (auto CS = CallSite(I)) {
- SmallVector<Type *, 3> Tys;
- FunctionType *Old = CS.getFunctionType();
- unsigned NumOld = Old->getNumParams();
- assert(NumOld <= CS.arg_size());
- for (unsigned i = 0; i != NumOld; ++i)
- Tys.push_back(CS.getArgument(i)->getType());
- CS.mutateFunctionType(FunctionType::get(
- TypeMapper ? TypeMapper->remapType(I->getType()) : I->getType(), Tys,
- Old->isVarArg()));
- } else if (TypeMapper)
+ if (TypeMapper)
I->mutateType(TypeMapper->remapType(I->getType()));
}
diff --git a/llvm/lib/Transforms/Vectorize/BBVectorize.cpp b/llvm/lib/Transforms/Vectorize/BBVectorize.cpp
index 6f0180e7db0..29fb01f1b2e 100644
--- a/llvm/lib/Transforms/Vectorize/BBVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/BBVectorize.cpp
@@ -3103,17 +3103,7 @@ namespace {
else if (H->hasName())
K->takeName(H);
- if (auto CS = CallSite(K)) {
- SmallVector<Type *, 3> Tys;
- FunctionType *Old = CS.getFunctionType();
- unsigned NumOld = Old->getNumParams();
- assert(NumOld <= ReplacedOperands.size());
- for (unsigned i = 0; i != NumOld; ++i)
- Tys.push_back(ReplacedOperands[i]->getType());
- CS.mutateFunctionType(
- FunctionType::get(getVecTypeForPair(L->getType(), H->getType()),
- Tys, Old->isVarArg()));
- } else if (!isa<StoreInst>(K))
+ if (!isa<StoreInst>(K))
K->mutateType(getVecTypeForPair(L->getType(), H->getType()));
unsigned KnownIDs[] = {
OpenPOWER on IntegriCloud