[llvm] [DebugInfo] Fix crash in declare-to-assign when memcpy writes to scalable-vector alloca (PR #194107)
Orlando Cazalet-Hyams via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 30 07:22:26 PDT 2026
================
@@ -0,0 +1,93 @@
+; RUN: opt -passes=declare-to-assign %s -S | FileCheck %s
+
+;; Check that declare-to-assign does not crash when a fixed-size memcpy writes
+;; into a scalable-vector alloca. getAssignmentInfoImpl must bail out when the
+;; destination alloca's type is scalable, not only when the store size itself is
+;; scalable. The dbg.declare for the scalable alloca should be preserved as-is.
+;;
+;; Derived from: https://github.com/llvm/llvm-project/issues/192728
+;; #include <string.h>
+;; #include <riscv_vector.h>
+;; vint32m1_t get_i32x4(int* v) {
+;; vint32m1_t r;
+;; memcpy(&r, v, 16);
+;; return r;
+;; }
+;; Compiled with: clang -target riscv64-unknown-linux-gnu -march=rv64gcv -O1 -g
+
+;; The scalable-vector alloca must not receive a DIAssignID (i.e. declare-to-assign
+;; must leave it alone), and its dbg.declare must be preserved as-is.
+; CHECK-LABEL: @get_i32x4(
+; CHECK: = alloca <vscale x 2 x i32>, align 4
+; CHECK-SAME: {{$}}
+; CHECK: #dbg_declare(ptr %3,
+
+target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128"
+target triple = "riscv64-unknown-linux-gnu"
+
+define dso_local <vscale x 2 x i32> @get_i32x4(ptr noundef %0) #0 !dbg !16 {
+ %2 = alloca ptr, align 8
+ %3 = alloca <vscale x 2 x i32>, align 4
+ store ptr %0, ptr %2, align 8, !tbaa !31
+ #dbg_declare(ptr %2, !29, !DIExpression(), !34)
----------------
OCHyams wrote:
do we need this dbg_declare (associated with the non-scalable alloca)?
https://github.com/llvm/llvm-project/pull/194107
More information about the llvm-commits
mailing list