[clang] [llvm] [ASAN][AArch64] Asan crash fix for scalable types. (PR #155505)

Daniel Kiss via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 26 14:44:55 PDT 2025


https://github.com/DanielKristofKiss created https://github.com/llvm/llvm-project/pull/155505

Asan doesn't support scalable types yet. Compiler crashes when alloca's size comes from a scalable type.

>From b5bcb7a627e3bbad5a9aabb310130a6c3f6dcc90 Mon Sep 17 00:00:00 2001
From: Daniel Kiss <daniel.kiss at arm.com>
Date: Tue, 26 Aug 2025 23:12:39 +0200
Subject: [PATCH] [ASAN][AArch64] Asan crash fix for scalable types.

Asan doesn't support scalable types yet. Compiler crashes when alloca's size
comes from a scalable type.
---
 clang/test/CodeGen/asan-scalabe-vector.cpp           | 12 ++++++++++++
 .../Transforms/Instrumentation/AddressSanitizer.cpp  |  2 ++
 2 files changed, 14 insertions(+)
 create mode 100644 clang/test/CodeGen/asan-scalabe-vector.cpp

diff --git a/clang/test/CodeGen/asan-scalabe-vector.cpp b/clang/test/CodeGen/asan-scalabe-vector.cpp
new file mode 100644
index 0000000000000..77f46f81f5b70
--- /dev/null
+++ b/clang/test/CodeGen/asan-scalabe-vector.cpp
@@ -0,0 +1,12 @@
+// Regression test for compiler crash
+// RUN: %clang_cc1 -triple aarch64-unknown-linux-gnu -target-feature +sve -target-feature +sve2 -emit-obj -fsanitize=address -fsanitize-address-use-after-scope %s -o - | llvm-objdump -d - | FileCheck %s
+// REQUIRES: aarch64-registered-target
+
+#include <arm_sve.h>
+int biz(svfloat64_t*);
+int foo(){
+    svfloat64_t a,b,c;
+    return biz(&a)+biz(&b)+biz(&c);
+}
+
+//CHECK: 0000000000000000 <_Z3foov>:
\ No newline at end of file
diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
index 50258af5e26c3..19d6bf56e479c 100644
--- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -1406,6 +1406,8 @@ bool AddressSanitizer::isInterestingAlloca(const AllocaInst &AI) {
       (AI.getAllocatedType()->isSized() &&
        // alloca() may be called with 0 size, ignore it.
        ((!AI.isStaticAlloca()) || !getAllocaSizeInBytes(AI).isZero()) &&
+       // alloca() may be called with a scalable parameter, we can't handle it.
+       !AI.getAllocationSize(AI.getDataLayout())->isScalable() &&
        // We are only interested in allocas not promotable to registers.
        // Promotable allocas are common under -O0.
        (!ClSkipPromotableAllocas || !isAllocaPromotable(&AI)) &&



More information about the llvm-commits mailing list