Skip to content

Commit 7383934

Browse files
committed
Rename to CanBeLocal. Check byval arguments.
1 parent c2eda0a commit 7383934

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

llvm/include/llvm/IR/DerivedTypes.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -769,8 +769,9 @@ class TargetExtType : public Type {
769769
HasZeroInit = 1U << 0,
770770
/// This type may be used as the value type of a global variable.
771771
CanBeGlobal = 1U << 1,
772-
/// This type may be used as the allocated type of an alloca instruction.
773-
CanBeAlloca = 1U << 2,
772+
/// This type may be allocated on the stack, either as the allocated type
773+
// of an alloca instruction or as a byval function parameter.
774+
CanBeLocal = 1U << 2,
774775
};
775776

776777
/// Returns true if the target extension type contains the given property.

llvm/lib/IR/Type.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -827,13 +827,13 @@ static TargetTypeInfo getTargetTypeInfo(const TargetExtType *Ty) {
827827
if (Name.starts_with("spirv."))
828828
return TargetTypeInfo(PointerType::get(C, 0), TargetExtType::HasZeroInit,
829829
TargetExtType::CanBeGlobal,
830-
TargetExtType::CanBeAlloca);
830+
TargetExtType::CanBeLocal);
831831

832832
// Opaque types in the AArch64 name space.
833833
if (Name == "aarch64.svcount")
834834
return TargetTypeInfo(ScalableVectorType::get(Type::getInt1Ty(C), 16),
835835
TargetExtType::HasZeroInit,
836-
TargetExtType::CanBeAlloca);
836+
TargetExtType::CanBeLocal);
837837

838838
return TargetTypeInfo(Type::getVoidTy(C));
839839
}

llvm/lib/IR/Verifier.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2021,6 +2021,12 @@ void Verifier::verifyParameterAttrs(AttributeSet Attrs, Type *Ty,
20212021
SmallPtrSet<Type *, 4> Visited;
20222022
Check(Attrs.getByValType()->isSized(&Visited),
20232023
"Attribute 'byval' does not support unsized types!", V);
2024+
// Check if it's a target extension type that disallows being used on the
2025+
// stack.
2026+
if (auto *TTy = dyn_cast<TargetExtType>(Attrs.getByValType())) {
2027+
Check(TTy->hasProperty(TargetExtType::CanBeLocal),
2028+
"'byval' argument has illegal target extension type", V);
2029+
}
20242030
Check(DL.getTypeAllocSize(Attrs.getByValType()).getKnownMinValue() <
20252031
(1ULL << 32),
20262032
"huge 'byval' arguments are unsupported", V);
@@ -4285,10 +4291,10 @@ void Verifier::visitAllocaInst(AllocaInst &AI) {
42854291
SmallPtrSet<Type*, 4> Visited;
42864292
Check(AI.getAllocatedType()->isSized(&Visited),
42874293
"Cannot allocate unsized type", &AI);
4288-
// Check if it's a target extension type that disallows being used in an
4289-
// alloca.
4294+
// Check if it's a target extension type that disallows being used on the
4295+
// stack.
42904296
if (auto *TTy = dyn_cast<TargetExtType>(AI.getAllocatedType())) {
4291-
Check(TTy->hasProperty(TargetExtType::CanBeAlloca),
4297+
Check(TTy->hasProperty(TargetExtType::CanBeLocal),
42924298
"Alloca has illegal target extension type", &AI);
42934299
}
42944300
Check(AI.getArraySize()->getType()->isIntegerTy(),

llvm/test/Assembler/target-type-properties.ll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
; RUN: not llvm-as < %t/zeroinit-error.ll -o /dev/null 2>&1 | FileCheck --check-prefix=CHECK-ZEROINIT %s
33
; RUN: not llvm-as < %t/global-var.ll -o /dev/null 2>&1 | FileCheck --check-prefix=CHECK-GLOBALVAR %s
44
; RUN: not llvm-as < %t/alloca.ll -o /dev/null 2>&1 | FileCheck --check-prefix=CHECK-ALLOCA %s
5+
; RUN: not llvm-as < %t/byval.ll -o /dev/null 2>&1 | FileCheck --check-prefix=CHECK-BYVAL %s
56
; Check target extension type properties are verified in the assembler.
67

78
;--- zeroinit-error.ll
@@ -22,3 +23,7 @@ define void @foo() {
2223
; CHECK-ALLOCA: Alloca has illegal target extension type
2324
ret void
2425
}
26+
27+
;--- byval.ll
28+
declare void @foo(ptr byval(target("spirv.Image")))
29+
; CHECK-BYVAL: 'byval' argument has illegal target extension type

0 commit comments

Comments
 (0)