aboutsummaryrefslogtreecommitdiff
path: root/lib/VMCore
diff options
context:
space:
mode:
Diffstat (limited to 'lib/VMCore')
-rw-r--r--lib/VMCore/Function.cpp8
-rw-r--r--lib/VMCore/Instructions.cpp10
-rw-r--r--lib/VMCore/Verifier.cpp3
3 files changed, 13 insertions, 8 deletions
diff --git a/lib/VMCore/Function.cpp b/lib/VMCore/Function.cpp
index 92737f66d9..f5712e7561 100644
--- a/lib/VMCore/Function.cpp
+++ b/lib/VMCore/Function.cpp
@@ -168,10 +168,10 @@ bool Function::onlyReadsMemory() const {
return doesNotAccessMemory() || paramHasAttr(0, ParamAttr::ReadOnly);
}
-/// @brief Determine if the function returns a structure.
-bool Function::isStructReturn() const {
- return paramHasAttr(1, ParamAttr::StructRet)
- || isa<StructType>(getReturnType());
+/// @brief Determine if the function returns a structure through first
+/// pointer argument.
+bool Function::hasStructRetAttr() const {
+ return paramHasAttr(1, ParamAttr::StructRet);
}
//===----------------------------------------------------------------------===//
diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp
index dfd3b830ca..f7401ec979 100644
--- a/lib/VMCore/Instructions.cpp
+++ b/lib/VMCore/Instructions.cpp
@@ -419,8 +419,9 @@ bool CallInst::doesNotThrow() const {
return paramHasAttr(0, ParamAttr::NoUnwind);
}
-/// @brief Determine if the call returns a structure.
-bool CallInst::isStructReturn() const {
+/// @brief Determine if the call returns a structure through first
+/// pointer argument.
+bool CallInst::hasStructRetAttr() const {
// Be friendly and also check the callee.
return paramHasAttr(1, ParamAttr::StructRet);
}
@@ -560,8 +561,9 @@ void InvokeInst::setDoesNotThrow(bool doesNotThrow) {
setParamAttrs(PAL);
}
-/// @brief Determine if the call returns a structure.
-bool InvokeInst::isStructReturn() const {
+/// @brief Determine if the invoke returns a structure through first
+/// pointer argument.
+bool InvokeInst::hasStructRetAttr() const {
// Be friendly and also check the callee.
return paramHasAttr(1, ParamAttr::StructRet);
}
diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp
index 3d6832475f..9ce886cd86 100644
--- a/lib/VMCore/Verifier.cpp
+++ b/lib/VMCore/Verifier.cpp
@@ -455,6 +455,9 @@ void Verifier::visitFunction(Function &F) {
isa<StructType>(F.getReturnType()),
"Functions cannot return aggregate values!", &F);
+ Assert1(!F.hasStructRetAttr() || F.getReturnType() == Type::VoidTy,
+ "Invalid struct return type!", &F);
+
const ParamAttrsList *Attrs = F.getParamAttrs();
Assert1(!Attrs ||