aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/Verifier.cpp
diff options
context:
space:
mode:
authorJay Foad <jay.foad@amd.com>2024-11-22 10:02:43 +0000
committerGitHub <noreply@github.com>2024-11-22 10:02:43 +0000
commit294c5cb2bea88fa048e00757188749f074c5b09f (patch)
tree941650e4fd8254d4c42293fe76005f20270512b5 /llvm/lib/IR/Verifier.cpp
parentef206446f2bbcb1bacc73d7611a96c457f59499f (diff)
downloadllvm-294c5cb2bea88fa048e00757188749f074c5b09f.zip
llvm-294c5cb2bea88fa048e00757188749f074c5b09f.tar.gz
llvm-294c5cb2bea88fa048e00757188749f074c5b09f.tar.bz2
[IR] Add TargetExtType::CanBeLocal property (#99016)
Add a property to allow marking target extension types that cannot be used in an alloca instruction or byval argument, similar to CanBeGlobal for global variables. --------- Co-authored-by: Nikita Popov <github@npopov.com>
Diffstat (limited to 'llvm/lib/IR/Verifier.cpp')
-rw-r--r--llvm/lib/IR/Verifier.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index 5c0ccf7..6783463 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -2026,11 +2026,15 @@ void Verifier::verifyParameterAttrs(AttributeSet Attrs, Type *Ty,
"huge alignment values are unsupported", V);
}
if (Attrs.hasAttribute(Attribute::ByVal)) {
+ Type *ByValTy = Attrs.getByValType();
SmallPtrSet<Type *, 4> Visited;
- Check(Attrs.getByValType()->isSized(&Visited),
+ Check(ByValTy->isSized(&Visited),
"Attribute 'byval' does not support unsized types!", V);
- Check(DL.getTypeAllocSize(Attrs.getByValType()).getKnownMinValue() <
- (1ULL << 32),
+ // Check if it is or contains a target extension type that disallows being
+ // used on the stack.
+ Check(!ByValTy->containsNonLocalTargetExtType(),
+ "'byval' argument has illegal target extension type", V);
+ Check(DL.getTypeAllocSize(ByValTy).getKnownMinValue() < (1ULL << 32),
"huge 'byval' arguments are unsupported", V);
}
if (Attrs.hasAttribute(Attribute::ByRef)) {
@@ -4323,9 +4327,13 @@ void Verifier::verifySwiftErrorValue(const Value *SwiftErrorVal) {
}
void Verifier::visitAllocaInst(AllocaInst &AI) {
+ Type *Ty = AI.getAllocatedType();
SmallPtrSet<Type*, 4> Visited;
- Check(AI.getAllocatedType()->isSized(&Visited),
- "Cannot allocate unsized type", &AI);
+ Check(Ty->isSized(&Visited), "Cannot allocate unsized type", &AI);
+ // Check if it's a target extension type that disallows being used on the
+ // stack.
+ Check(!Ty->containsNonLocalTargetExtType(),
+ "Alloca has illegal target extension type", &AI);
Check(AI.getArraySize()->getType()->isIntegerTy(),
"Alloca array size must have integer type", &AI);
if (MaybeAlign A = AI.getAlign()) {
@@ -4334,8 +4342,7 @@ void Verifier::visitAllocaInst(AllocaInst &AI) {
}
if (AI.isSwiftError()) {
- Check(AI.getAllocatedType()->isPointerTy(),
- "swifterror alloca must have pointer type", &AI);
+ Check(Ty->isPointerTy(), "swifterror alloca must have pointer type", &AI);
Check(!AI.isArrayAllocation(),
"swifterror alloca must not be array allocation", &AI);
verifySwiftErrorValue(&AI);