[llvm-commits] [llvm] r38506 - in /llvm/trunk: lib/VMCore/Verifier.cpp test/Verifier/byval-1.ll test/Verifier/byval-2.ll test/Verifier/byval-3.ll test/Verifier/byval-4.ll
Rafael Espindola
rafael.espindola at gmail.com
Tue Jul 10 12:28:12 PDT 2007
Author: rafael
Date: Tue Jul 10 14:28:12 2007
New Revision: 38506
URL: http://llvm.org/viewvc/llvm-project?rev=38506&view=rev
Log:
check for correct usage of the byval attribute
Added:
llvm/trunk/test/Verifier/byval-1.ll
llvm/trunk/test/Verifier/byval-2.ll
llvm/trunk/test/Verifier/byval-3.ll
llvm/trunk/test/Verifier/byval-4.ll
Modified:
llvm/trunk/lib/VMCore/Verifier.cpp
Modified: llvm/trunk/lib/VMCore/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Verifier.cpp?rev=38506&r1=38505&r2=38506&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Verifier.cpp (original)
+++ llvm/trunk/lib/VMCore/Verifier.cpp Tue Jul 10 14:28:12 2007
@@ -361,6 +361,10 @@
if (const ParamAttrsList *Attrs = FT->getParamAttrs()) {
unsigned Idx = 1;
+
+ Assert(!Attrs->paramHasAttr(0, ParamAttr::ByVal),
+ "Attribute ByVal should not apply to functions!");
+
for (FunctionType::param_iterator I = FT->param_begin(),
E = FT->param_end(); I != E; ++I, ++Idx) {
if (Attrs->paramHasAttr(Idx, ParamAttr::ZExt) ||
@@ -370,9 +374,14 @@
if (Attrs->paramHasAttr(Idx, ParamAttr::NoAlias))
Assert1(isa<PointerType>(FT->getParamType(Idx-1)),
"Attribute NoAlias should only apply to Pointer type!", &F);
- if (Attrs->paramHasAttr(Idx, ParamAttr::ByVal))
+ if (Attrs->paramHasAttr(Idx, ParamAttr::ByVal)) {
Assert1(isa<PointerType>(FT->getParamType(Idx-1)),
- "Attribute ByVal should only apply to Pointer type!", &F);
+ "Attribute ByVal should only apply to pointer to structs!", &F);
+ const PointerType *Ty =
+ cast<PointerType>(FT->getParamType(Idx-1));
+ Assert1(isa<StructType>(Ty->getElementType()),
+ "Attribute ByVal should only apply to pointer to structs!", &F);
+ }
}
}
Added: llvm/trunk/test/Verifier/byval-1.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Verifier/byval-1.ll?rev=38506&view=auto
==============================================================================
--- llvm/trunk/test/Verifier/byval-1.ll (added)
+++ llvm/trunk/test/Verifier/byval-1.ll Tue Jul 10 14:28:12 2007
@@ -0,0 +1,2 @@
+; RUN: not llvm-as < %s -o /dev/null -f
+declare void @h(i32* byval %num)
Added: llvm/trunk/test/Verifier/byval-2.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Verifier/byval-2.ll?rev=38506&view=auto
==============================================================================
--- llvm/trunk/test/Verifier/byval-2.ll (added)
+++ llvm/trunk/test/Verifier/byval-2.ll Tue Jul 10 14:28:12 2007
@@ -0,0 +1,2 @@
+; RUN: not llvm-as < %s -o /dev/null -f
+declare void @h(i32* %num) byval
Added: llvm/trunk/test/Verifier/byval-3.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Verifier/byval-3.ll?rev=38506&view=auto
==============================================================================
--- llvm/trunk/test/Verifier/byval-3.ll (added)
+++ llvm/trunk/test/Verifier/byval-3.ll Tue Jul 10 14:28:12 2007
@@ -0,0 +1,2 @@
+; RUN: not llvm-as < %s -o /dev/null -f
+declare void @h(i32 byval %num)
Added: llvm/trunk/test/Verifier/byval-4.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Verifier/byval-4.ll?rev=38506&view=auto
==============================================================================
--- llvm/trunk/test/Verifier/byval-4.ll (added)
+++ llvm/trunk/test/Verifier/byval-4.ll Tue Jul 10 14:28:12 2007
@@ -0,0 +1,4 @@
+; RUN: llvm-as < %s -o /dev/null -f
+%struct.foo = type { i64 }
+
+declare void @h(%struct.foo* byval %num)
More information about the llvm-commits
mailing list