Skip to content

Commit 1eb6c2b

Browse files
authored
[clang][bytecode] Reject vectors with non-primitive element types (#155597)
This happens for e.g. arm's float8 types.
1 parent c5e1ac4 commit 1eb6c2b

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,11 +1376,17 @@ bool Compiler<Emitter>::VisitComplexBinOp(const BinaryOperator *E) {
13761376

13771377
template <class Emitter>
13781378
bool Compiler<Emitter>::VisitVectorBinOp(const BinaryOperator *E) {
1379+
const Expr *LHS = E->getLHS();
1380+
const Expr *RHS = E->getRHS();
13791381
assert(!E->isCommaOp() &&
13801382
"Comma op should be handled in VisitBinaryOperator");
13811383
assert(E->getType()->isVectorType());
1382-
assert(E->getLHS()->getType()->isVectorType());
1383-
assert(E->getRHS()->getType()->isVectorType());
1384+
assert(LHS->getType()->isVectorType());
1385+
assert(RHS->getType()->isVectorType());
1386+
1387+
// We can only handle vectors with primitive element types.
1388+
if (!canClassify(LHS->getType()->castAs<VectorType>()->getElementType()))
1389+
return false;
13841390

13851391
// Prepare storage for result.
13861392
if (!Initializing && !E->isCompoundAssignmentOp() && !E->isAssignmentOp()) {
@@ -1391,8 +1397,6 @@ bool Compiler<Emitter>::VisitVectorBinOp(const BinaryOperator *E) {
13911397
return false;
13921398
}
13931399

1394-
const Expr *LHS = E->getLHS();
1395-
const Expr *RHS = E->getRHS();
13961400
const auto *VecTy = E->getType()->getAs<VectorType>();
13971401
auto Op = E->isCompoundAssignmentOp()
13981402
? BinaryOperator::getOpForCompoundAssignment(E->getOpcode())

clang/test/CodeGenCXX/int64_uint64.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66
// RUN: -target-feature +neon \
77
// RUN: -emit-llvm -w -O1 -o - %s | FileCheck --check-prefix=CHECK-AARCH64 %s
88

9+
// RUN: %clang_cc1 -triple arm-linux-guneabi \
10+
// RUN: -target-cpu cortex-a8 -fexperimental-new-constant-interpreter \
11+
// RUN: -emit-llvm -w -O1 -o - %s | FileCheck --check-prefix=CHECK-ARM %s
12+
13+
// RUN: %clang_cc1 -triple arm64-linux-gnueabi \
14+
// RUN: -target-feature +neon -fexperimental-new-constant-interpreter \
15+
// RUN: -emit-llvm -w -O1 -o - %s | FileCheck --check-prefix=CHECK-AARCH64 %s
16+
917
// REQUIRES: aarch64-registered-target || arm-registered-target
1018

1119
// Test if int64_t and uint64_t can be correctly mangled.

0 commit comments

Comments
 (0)