[clang] [clang][bytecode] Check primtypes in CopyArray op (PR #195628)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Mon May 4 03:14:25 PDT 2026
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/195628
None
>From cf2b2121d84a2cfb9ff34bee9c5d175a4f3481f8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Mon, 4 May 2026 12:13:35 +0200
Subject: [PATCH] [clang][bytecode] Check primtypes in CopyArray op
---
clang/lib/AST/ByteCode/Interp.h | 6 ++++++
clang/test/AST/ByteCode/vectors.cpp | 9 +++++++++
2 files changed, 15 insertions(+)
diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h
index f89ff3f18ce9d..2d0efff1439b8 100644
--- a/clang/lib/AST/ByteCode/Interp.h
+++ b/clang/lib/AST/ByteCode/Interp.h
@@ -3430,6 +3430,12 @@ inline bool CopyArray(InterpState &S, CodePtr OpPC, uint32_t SrcIndex,
if (!SrcPtr.isBlockPointer() || !DestPtr.isBlockPointer())
return false;
+ const Descriptor *SrcDesc = SrcPtr.getFieldDesc();
+ const Descriptor *DestDesc = DestPtr.getFieldDesc();
+ if (!SrcDesc->isPrimitiveArray() || !DestDesc->isPrimitiveArray() ||
+ SrcDesc->getPrimType() != Name || DestDesc->getPrimType() != Name)
+ return false;
+
for (uint32_t I = 0; I != Size; ++I) {
const Pointer &SP = SrcPtr.atIndex(SrcIndex + I);
diff --git a/clang/test/AST/ByteCode/vectors.cpp b/clang/test/AST/ByteCode/vectors.cpp
index db18d8360f36a..d09e9e05cde5a 100644
--- a/clang/test/AST/ByteCode/vectors.cpp
+++ b/clang/test/AST/ByteCode/vectors.cpp
@@ -184,3 +184,12 @@ namespace CopyArrayDummy {
*(T *)&s = (T){0, 1, 2, 3};
}
}
+
+namespace CopyArrayCast {
+ typedef float __m128 __attribute__((__vector_size__(16)));
+ constexpr __m128 foo{1.0f, 2.0f, 3.0f, 4.0f};
+
+ typedef long T __attribute__((vector_size(4 * sizeof(long))));
+
+ void bar(void) { *(T *)&foo = (T{0, 1, 2, 3}); }
+}
More information about the cfe-commits
mailing list