Skip to content

Commit dd30c6e

Browse files
committed
Fix StructType::isScalableTy by calling back into Type::isScalableTy
1 parent c4ffee4 commit dd30c6e

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

llvm/lib/IR/Type.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -408,18 +408,11 @@ bool StructType::isScalableTy(SmallPtrSetImpl<Type *> &Visited) const {
408408
return false;
409409

410410
for (Type *Ty : elements()) {
411-
if (isa<ScalableVectorType>(Ty)) {
411+
if (Ty->isScalableTy(Visited)) {
412412
const_cast<StructType *>(this)->setSubclassData(
413413
getSubclassData() | SCDB_ContainsScalableVector);
414414
return true;
415415
}
416-
if (auto *STy = dyn_cast<StructType>(Ty)) {
417-
if (STy->isScalableTy(Visited)) {
418-
const_cast<StructType *>(this)->setSubclassData(
419-
getSubclassData() | SCDB_ContainsScalableVector);
420-
return true;
421-
}
422-
}
423416
}
424417

425418
// For structures that are opaque, return false but do not set the

llvm/test/Verifier/scalable-global-vars.ll

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,17 @@
1515
; CHECK-NEXT: ptr @ScalableVecStructGlobal
1616
@ScalableVecStructGlobal = global { i32, <vscale x 4 x i32> } zeroinitializer
1717

18+
; CHECK-NEXT: Globals cannot contain scalable types
19+
; CHECK-NEXT: ptr @StructTestGlobal
20+
%struct.test = type { <vscale x 1 x double>, <vscale x 1 x double> }
21+
@StructTestGlobal = global %struct.test zeroinitializer
22+
23+
; CHECK-NEXT: Globals cannot contain scalable types
24+
; CHECK-NEXT: ptr @StructArrayTestGlobal
25+
%struct.array.test = type { [2 x <vscale x 1 x double>] }
26+
@StructArrayTestGlobal = global %struct.array.test zeroinitializer
27+
28+
; CHECK-NEXT: Globals cannot contain scalable types
29+
; CHECK-NEXT: ptr @StructTargetTestGlobal
30+
%struct.target.test = type { target("aarch64.svcount"), target("aarch64.svcount") }
31+
@StructTargetTestGlobal = global %struct.target.test zeroinitializer

0 commit comments

Comments
 (0)