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

via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 26 14:45:26 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-transforms

Author: Daniel Kiss (DanielKristofKiss)

<details>
<summary>Changes</summary>

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

---
Full diff: https://github.com/llvm/llvm-project/pull/155505.diff


2 Files Affected:

- (added) clang/test/CodeGen/asan-scalabe-vector.cpp (+12) 
- (modified) llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp (+2) 


``````````diff
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)) &&

``````````

</details>


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


More information about the llvm-commits mailing list