summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2007-11-28 17:07:01 +0000
committerDuncan Sands <baldrick@free.fr>2007-11-28 17:07:01 +0000
commit5208d1ab4ae3ea453f4363e4d4582e2df09b7927 (patch)
treee5db86677b4e4522de2cfd2bc0dec21912517b96 /llvm/lib/VMCore
parentb5452fb829347e51e51e053a4d97f3cdf9d5101f (diff)
downloadbcm5719-llvm-5208d1ab4ae3ea453f4363e4d4582e2df09b7927.tar.gz
bcm5719-llvm-5208d1ab4ae3ea453f4363e4d4582e2df09b7927.zip
Add some convenience methods for querying attributes, and
use them. llvm-svn: 44403
Diffstat (limited to 'llvm/lib/VMCore')
-rw-r--r--llvm/lib/VMCore/Function.cpp7
-rw-r--r--llvm/lib/VMCore/Instructions.cpp26
2 files changed, 18 insertions, 15 deletions
diff --git a/llvm/lib/VMCore/Function.cpp b/llvm/lib/VMCore/Function.cpp
index 023cb556f44..92853e30f9b 100644
--- a/llvm/lib/VMCore/Function.cpp
+++ b/llvm/lib/VMCore/Function.cpp
@@ -13,7 +13,6 @@
#include "llvm/Module.h"
#include "llvm/DerivedTypes.h"
-#include "llvm/ParameterAttributes.h"
#include "llvm/IntrinsicInst.h"
#include "llvm/CodeGen/ValueTypes.h"
#include "llvm/Support/LeakDetector.h"
@@ -287,12 +286,6 @@ void Function::setParamAttrs(const ParamAttrsList *attrs) {
ParamAttrs = attrs;
}
-bool Function::isStructReturn() const {
- if (ParamAttrs)
- return ParamAttrs->paramHasAttr(1, ParamAttr::StructRet);
- return false;
-}
-
const FunctionType *Function::getFunctionType() const {
return cast<FunctionType>(getType()->getElementType());
}
diff --git a/llvm/lib/VMCore/Instructions.cpp b/llvm/lib/VMCore/Instructions.cpp
index 7226f66e209..8e484910d2d 100644
--- a/llvm/lib/VMCore/Instructions.cpp
+++ b/llvm/lib/VMCore/Instructions.cpp
@@ -47,6 +47,12 @@ void CallSite::setParamAttrs(const ParamAttrsList *PAL) {
else
cast<InvokeInst>(I)->setParamAttrs(PAL);
}
+bool CallSite::paramHasAttr(uint16_t i, ParameterAttributes attr) const {
+ if (CallInst *CI = dyn_cast<CallInst>(I))
+ return CI->paramHasAttr(i, attr);
+ else
+ return cast<InvokeInst>(I)->paramHasAttr(i, attr);
+}
@@ -376,12 +382,14 @@ void CallInst::setParamAttrs(const ParamAttrsList *newAttrs) {
ParamAttrs = newAttrs;
}
-bool CallInst::isStructReturn() const {
- if (ParamAttrs)
- return ParamAttrs->paramHasAttr(1, ParamAttr::StructRet);
- return false;
+bool CallInst::paramHasAttr(uint16_t i, ParameterAttributes attr) const {
+ if (ParamAttrs && ParamAttrs->paramHasAttr(i, attr))
+ return true;
+ const Function *F = getCalledFunction();
+ return F && F->getParamAttrs() && F->getParamAttrs()->paramHasAttr(i, attr);
}
+
//===----------------------------------------------------------------------===//
// InvokeInst Implementation
//===----------------------------------------------------------------------===//
@@ -451,12 +459,14 @@ void InvokeInst::setParamAttrs(const ParamAttrsList *newAttrs) {
ParamAttrs = newAttrs;
}
-bool InvokeInst::isStructReturn() const {
- if (ParamAttrs)
- return ParamAttrs->paramHasAttr(1, ParamAttr::StructRet);
- return false;
+bool InvokeInst::paramHasAttr(uint16_t i, ParameterAttributes attr) const {
+ if (ParamAttrs && ParamAttrs->paramHasAttr(i, attr))
+ return true;
+ const Function *F = getCalledFunction();
+ return F && F->getParamAttrs() && F->getParamAttrs()->paramHasAttr(i, attr);
}
+
//===----------------------------------------------------------------------===//
// ReturnInst Implementation
//===----------------------------------------------------------------------===//
OpenPOWER on IntegriCloud