summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZhou Sheng <zhousheng00@gmail.com>2007-06-07 06:12:03 +0000
committerZhou Sheng <zhousheng00@gmail.com>2007-06-07 06:12:03 +0000
commit0ae22e99c894f4fee36f721d64ada9d843b96486 (patch)
treefc25b366443aedc5acd9f71beb2250d05638f925
parentbe9859eea25461256c18b7424304e325c452d955 (diff)
downloadbcm5719-llvm-0ae22e99c894f4fee36f721d64ada9d843b96486.tar.gz
bcm5719-llvm-0ae22e99c894f4fee36f721d64ada9d843b96486.zip
Add assert to check if the attributes ZExt/SExt, NoAlias are apply to the
correct type of parameters. llvm-svn: 37486
-rw-r--r--llvm/lib/VMCore/Verifier.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/llvm/lib/VMCore/Verifier.cpp b/llvm/lib/VMCore/Verifier.cpp
index 7e92eb303d7..ef7b3f8dbbc 100644
--- a/llvm/lib/VMCore/Verifier.cpp
+++ b/llvm/lib/VMCore/Verifier.cpp
@@ -46,6 +46,7 @@
#include "llvm/Pass.h"
#include "llvm/Module.h"
#include "llvm/ModuleProvider.h"
+#include "llvm/ParameterAttributes.h"
#include "llvm/DerivedTypes.h"
#include "llvm/InlineAsm.h"
#include "llvm/Instructions.h"
@@ -358,6 +359,20 @@ void Verifier::visitFunction(Function &F) {
FT->getNumParams() > 0 && isa<PointerType>(FT->getParamType(0))),
"Invalid struct-return function!", &F);
+ if (const ParamAttrsList *Attrs = FT->getParamAttrs()) {
+ unsigned Idx = 1;
+ for (FunctionType::param_iterator I = FT->param_begin(),
+ E = FT->param_end(); I != E; ++I, ++Idx) {
+ if (Attrs->paramHasAttr(Idx, ParamAttr::ZExt) ||
+ Attrs->paramHasAttr(Idx, ParamAttr::SExt))
+ Assert1(FT->getParamType(Idx-1)->isInteger(),
+ "Attribute ZExt should only apply to Integer type!", &F);
+ if (Attrs->paramHasAttr(Idx, ParamAttr::NoAlias))
+ Assert1(isa<PointerType>(FT->getParamType(Idx-1)),
+ "Attribute NoAlias should only apply to Pointer type!", &F);
+ }
+ }
+
// Check that this function meets the restrictions on this calling convention.
switch (F.getCallingConv()) {
default:
OpenPOWER on IntegriCloud