https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/155597
This happens for e.g. arm's float8 types. >From 6d8f645682cfc888d083b8b19cc30fa80c27b209 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]> Date: Wed, 27 Aug 2025 13:27:37 +0200 Subject: [PATCH] [clang][bytecode] Reject vectors with non-primitive element types This happens for e.g. arm's float8 types. --- clang/lib/AST/ByteCode/Compiler.cpp | 12 ++++++++---- clang/test/CodeGenCXX/int64_uint64.cpp | 8 ++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp index 8ed9e64f5f8ff..c314f0a132196 100644 --- a/clang/lib/AST/ByteCode/Compiler.cpp +++ b/clang/lib/AST/ByteCode/Compiler.cpp @@ -1376,11 +1376,17 @@ bool Compiler<Emitter>::VisitComplexBinOp(const BinaryOperator *E) { template <class Emitter> bool Compiler<Emitter>::VisitVectorBinOp(const BinaryOperator *E) { + const Expr *LHS = E->getLHS(); + const Expr *RHS = E->getRHS(); assert(!E->isCommaOp() && "Comma op should be handled in VisitBinaryOperator"); assert(E->getType()->isVectorType()); - assert(E->getLHS()->getType()->isVectorType()); - assert(E->getRHS()->getType()->isVectorType()); + assert(LHS->getType()->isVectorType()); + assert(RHS->getType()->isVectorType()); + + // We can only handle vectors with primitive element types. + if (!canClassify(LHS->getType()->castAs<VectorType>()->getElementType())) + return false; // Prepare storage for result. if (!Initializing && !E->isCompoundAssignmentOp() && !E->isAssignmentOp()) { @@ -1391,8 +1397,6 @@ bool Compiler<Emitter>::VisitVectorBinOp(const BinaryOperator *E) { return false; } - const Expr *LHS = E->getLHS(); - const Expr *RHS = E->getRHS(); const auto *VecTy = E->getType()->getAs<VectorType>(); auto Op = E->isCompoundAssignmentOp() ? BinaryOperator::getOpForCompoundAssignment(E->getOpcode()) diff --git a/clang/test/CodeGenCXX/int64_uint64.cpp b/clang/test/CodeGenCXX/int64_uint64.cpp index f4fd9ea76147f..8046ea9376d9e 100644 --- a/clang/test/CodeGenCXX/int64_uint64.cpp +++ b/clang/test/CodeGenCXX/int64_uint64.cpp @@ -6,6 +6,14 @@ // RUN: -target-feature +neon \ // RUN: -emit-llvm -w -O1 -o - %s | FileCheck --check-prefix=CHECK-AARCH64 %s +// RUN: %clang_cc1 -triple arm-linux-guneabi \ +// RUN: -target-cpu cortex-a8 -fexperimental-new-constant-interpreter \ +// RUN: -emit-llvm -w -O1 -o - %s | FileCheck --check-prefix=CHECK-ARM %s + +// RUN: %clang_cc1 -triple arm64-linux-gnueabi \ +// RUN: -target-feature +neon -fexperimental-new-constant-interpreter \ +// RUN: -emit-llvm -w -O1 -o - %s | FileCheck --check-prefix=CHECK-AARCH64 %s + // REQUIRES: aarch64-registered-target || arm-registered-target // Test if int64_t and uint64_t can be correctly mangled. _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
