llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) <details> <summary>Changes</summary> We shouldn't try to do the memcpy if the semantics don't match. --- Full diff: https://github.com/llvm/llvm-project/pull/202204.diff 2 Files Affected: - (modified) clang/lib/AST/ByteCode/InterpBuiltin.cpp (+11-5) - (modified) clang/test/AST/ByteCode/codegen.cpp (+2) ``````````diff diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp index 501c7f76a0376..95e2d91a98b94 100644 --- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp +++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp @@ -6693,15 +6693,21 @@ static bool copyComposite(InterpState &S, CodePtr OpPC, const Pointer &Src, if (DestDesc->isPrimitiveArray()) { if (!SrcDesc->isPrimitiveArray()) return false; + // For floating types, check the actual QualType so we don't accidentally + // mix up semantics. + if (SrcDesc->getPrimType() == PT_Float) { + if (!S.getASTContext().hasSimilarType(SrcDesc->getElemQualType(), + DestDesc->getElemQualType())) + return false; + } + assert(SrcDesc->isPrimitiveArray()); assert(SrcDesc->getNumElems() == DestDesc->getNumElems()); + assert(SrcDesc->getPrimType() == DestDesc->getPrimType()); PrimType ET = DestDesc->getPrimType(); for (unsigned I = 0, N = DestDesc->getNumElems(); I != N; ++I) { - Pointer DestElem = Dest.atIndex(I); - TYPE_SWITCH(ET, { - DestElem.deref<T>() = Src.elem<T>(I); - DestElem.initialize(); - }); + TYPE_SWITCH(ET, { Dest.elem<T>(I) = Src.elem<T>(I); }); + Dest.initializeElement(I); } return true; } diff --git a/clang/test/AST/ByteCode/codegen.cpp b/clang/test/AST/ByteCode/codegen.cpp index c2d2a6ef22bdc..972d883ce1d73 100644 --- a/clang/test/AST/ByteCode/codegen.cpp +++ b/clang/test/AST/ByteCode/codegen.cpp @@ -148,3 +148,5 @@ X test24() { // CHECK: _Z6test24v // CHECK-NOT: eh.resume // CHECK-NOT: unreachable + +auto MemcpySemantics = *(_Complex double *)&(float[2]){}; `````````` </details> https://github.com/llvm/llvm-project/pull/202204 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
