summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/lib/IR/Instructions.cpp4
-rw-r--r--llvm/lib/Target/X86/X86FastISel.cpp10
2 files changed, 10 insertions, 4 deletions
diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp
index 59ac99b6666..3394355cfb4 100644
--- a/llvm/lib/IR/Instructions.cpp
+++ b/llvm/lib/IR/Instructions.cpp
@@ -331,6 +331,8 @@ void CallInst::addDereferenceableOrNullAttr(unsigned i, uint64_t Bytes) {
}
bool CallInst::paramHasAttr(unsigned i, Attribute::AttrKind A) const {
+ assert(i < (getNumArgOperands() + 1) && "Param index out of bounds!");
+
if (AttributeList.hasAttribute(i, A))
return true;
if (const Function *F = getCalledFunction())
@@ -575,6 +577,8 @@ bool InvokeInst::hasFnAttrImpl(Attribute::AttrKind A) const {
}
bool InvokeInst::paramHasAttr(unsigned i, Attribute::AttrKind A) const {
+ assert(i < (getNumArgOperands() + 1) && "Param index out of bounds!");
+
if (AttributeList.hasAttribute(i, A))
return true;
if (const Function *F = getCalledFunction())
diff --git a/llvm/lib/Target/X86/X86FastISel.cpp b/llvm/lib/Target/X86/X86FastISel.cpp
index 2cda8211ba9..914fd04ad6b 100644
--- a/llvm/lib/Target/X86/X86FastISel.cpp
+++ b/llvm/lib/Target/X86/X86FastISel.cpp
@@ -2817,10 +2817,12 @@ static unsigned computeBytesPoppedByCallee(const X86Subtarget *Subtarget,
if (CC == CallingConv::Fast || CC == CallingConv::GHC ||
CC == CallingConv::HiPE)
return 0;
- if (CS && !CS->paramHasAttr(1, Attribute::StructRet))
- return 0;
- if (CS && CS->paramHasAttr(1, Attribute::InReg))
- return 0;
+
+ if (CS)
+ if (CS->arg_empty() || !CS->paramHasAttr(1, Attribute::StructRet) ||
+ CS->paramHasAttr(1, Attribute::InReg))
+ return 0;
+
return 4;
}
OpenPOWER on IntegriCloud