[clang] 665984f - [clang][bytecode] Check primtypes in CopyArray op (#195628)
via cfe-commits
cfe-commits at lists.llvm.org
Mon May 4 07:22:56 PDT 2026
Author: Timm Baeder
Date: 2026-05-04T16:22:49+02:00
New Revision: 665984f5b3271b54d4e97797fa7f8ad598b2106a
URL: https://github.com/llvm/llvm-project/commit/665984f5b3271b54d4e97797fa7f8ad598b2106a
DIFF: https://github.com/llvm/llvm-project/commit/665984f5b3271b54d4e97797fa7f8ad598b2106a.diff
LOG: [clang][bytecode] Check primtypes in CopyArray op (#195628)
Added:
Modified:
clang/lib/AST/ByteCode/Interp.h
clang/test/AST/ByteCode/vectors.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h
index fca61e3b310f1..4a550fdd63bfb 100644
--- a/clang/lib/AST/ByteCode/Interp.h
+++ b/clang/lib/AST/ByteCode/Interp.h
@@ -3435,6 +3435,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