mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-12 13:30:51 +00:00
check for correct usage of the byval attribute
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@38506 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a289511090
commit
b91025b619
@ -361,6 +361,10 @@ void Verifier::visitFunction(Function &F) {
|
||||
|
||||
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 @@ void Verifier::visitFunction(Function &F) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
2
test/Verifier/byval-1.ll
Normal file
2
test/Verifier/byval-1.ll
Normal file
@ -0,0 +1,2 @@
|
||||
; RUN: not llvm-as < %s -o /dev/null -f
|
||||
declare void @h(i32* byval %num)
|
2
test/Verifier/byval-2.ll
Normal file
2
test/Verifier/byval-2.ll
Normal file
@ -0,0 +1,2 @@
|
||||
; RUN: not llvm-as < %s -o /dev/null -f
|
||||
declare void @h(i32* %num) byval
|
2
test/Verifier/byval-3.ll
Normal file
2
test/Verifier/byval-3.ll
Normal file
@ -0,0 +1,2 @@
|
||||
; RUN: not llvm-as < %s -o /dev/null -f
|
||||
declare void @h(i32 byval %num)
|
4
test/Verifier/byval-4.ll
Normal file
4
test/Verifier/byval-4.ll
Normal file
@ -0,0 +1,4 @@
|
||||
; RUN: llvm-as < %s -o /dev/null -f
|
||||
%struct.foo = type { i64 }
|
||||
|
||||
declare void @h(%struct.foo* byval %num)
|
Loading…
Reference in New Issue
Block a user