[llvm] f5f0930 - [GVN] Fix crash when svcount is used with globals-aa (#184347)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 3 21:24:21 PST 2026
Author: Madhur Amilkanthwar
Date: 2026-03-04T10:54:16+05:30
New Revision: f5f0930c4715749df5a92f2b055647450f5308d4
URL: https://github.com/llvm/llvm-project/commit/f5f0930c4715749df5a92f2b055647450f5308d4
DIFF: https://github.com/llvm/llvm-project/commit/f5f0930c4715749df5a92f2b055647450f5308d4.diff
LOG: [GVN] Fix crash when svcount is used with globals-aa (#184347)
When -globals-aa is used, `analyzeLoadAvailiability` calls
`analyzeLoadClobberringStore` which in turn calls
`isFirstClassAggregateOrScalableType` which is using
`isa<ScalableVectorType>`. Ideally it should use type's isScalableType()
method.
The crash does not occur when default (BasicAA) is used because
`analyzeLoadAvailiability` function does not take the load clobbering
path as BasicAA returns `Def`.
Fixes #159368
Added:
llvm/test/Transforms/GVN/svcount-access.ll
Modified:
llvm/lib/Transforms/Utils/VNCoercion.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Utils/VNCoercion.cpp b/llvm/lib/Transforms/Utils/VNCoercion.cpp
index 03306daeeafce..0dabd065b6723 100644
--- a/llvm/lib/Transforms/Utils/VNCoercion.cpp
+++ b/llvm/lib/Transforms/Utils/VNCoercion.cpp
@@ -10,7 +10,7 @@ using namespace llvm;
using namespace VNCoercion;
static bool isFirstClassAggregateOrScalableType(Type *Ty) {
- return Ty->isStructTy() || Ty->isArrayTy() || isa<ScalableVectorType>(Ty);
+ return Ty->isStructTy() || Ty->isArrayTy() || Ty->isScalableTy();
}
/// Return true if coerceAvailableValueToLoadType will succeed.
diff --git a/llvm/test/Transforms/GVN/svcount-access.ll b/llvm/test/Transforms/GVN/svcount-access.ll
new file mode 100644
index 0000000000000..75a913c9b6763
--- /dev/null
+++ b/llvm/test/Transforms/GVN/svcount-access.ll
@@ -0,0 +1,16 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 6
+; RUN: opt -passes=gvn -aa-pipeline=globals-aa -S < %s | FileCheck %s
+
+define target("aarch64.svcount") @test_alloca_store_reload(target("aarch64.svcount") %val) nounwind {
+; CHECK-LABEL: define target("aarch64.svcount") @test_alloca_store_reload(
+; CHECK-SAME: target("aarch64.svcount") [[VAL:%.*]]) #[[ATTR0:[0-9]+]] {
+; CHECK-NEXT: [[PTR:%.*]] = alloca target("aarch64.svcount"), align 1
+; CHECK-NEXT: store target("aarch64.svcount") [[VAL]], ptr [[PTR]], align 2
+; CHECK-NEXT: [[RES:%.*]] = load target("aarch64.svcount"), ptr [[PTR]], align 2
+; CHECK-NEXT: ret target("aarch64.svcount") [[RES]]
+;
+ %ptr = alloca target("aarch64.svcount"), align 1
+ store target("aarch64.svcount") %val, ptr %ptr
+ %res = load target("aarch64.svcount"), ptr %ptr
+ ret target("aarch64.svcount") %res
+}
More information about the llvm-commits
mailing list