Skip to content

Commit bded889

Browse files
authored
[clang][AArch64] Fix C++11 style initialization of typedef'd vectors (llvm#118956)
Previously, this hit an `llvm_unreachable()` assertion as the type of `vec_t` did not exactly match `__SVInt8_t`, as it was wrapped in a typedef. Comparing the canonical types instead allows the types to match correctly and avoids the crash. Fixes llvm#107609
1 parent b9aa155 commit bded889

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

clang/lib/CodeGen/CGExprScalar.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2102,7 +2102,8 @@ Value *ScalarExprEmitter::VisitInitListExpr(InitListExpr *E) {
21022102
Expr *InitVector = E->getInit(0);
21032103

21042104
// Initialize from another scalable vector of the same type.
2105-
if (InitVector->getType() == E->getType())
2105+
if (InitVector->getType().getCanonicalType() ==
2106+
E->getType().getCanonicalType())
21062107
return Visit(InitVector);
21072108
}
21082109

clang/test/CodeGenCXX/aarch64-sve-vector-init.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,3 +1212,20 @@ void test_copy_mf8x3(__clang_svmfloat8x3_t a) {
12121212
void test_copy_mf8x4(__clang_svmfloat8x4_t a) {
12131213
__clang_svmfloat8x4_t b{a};
12141214
}
1215+
1216+
/// Reduced from: https://github.com/llvm/llvm-project/issues/107609
1217+
using vec_t = __SVInt8_t;
1218+
1219+
// CHECK-LABEL: define dso_local void @_Z20test_copy_s8_typedefu10__SVInt8_t
1220+
// CHECK-SAME: (<vscale x 16 x i8> [[A:%.*]]) #[[ATTR0]] {
1221+
// CHECK-NEXT: entry:
1222+
// CHECK-NEXT: [[A_ADDR:%.*]] = alloca <vscale x 16 x i8>, align 16
1223+
// CHECK-NEXT: [[VEC:%.*]] = alloca <vscale x 16 x i8>, align 16
1224+
// CHECK-NEXT: store <vscale x 16 x i8> [[A]], ptr [[A_ADDR]], align 16
1225+
// CHECK-NEXT: [[TMP0:%.*]] = load <vscale x 16 x i8>, ptr [[A_ADDR]], align 16
1226+
// CHECK-NEXT: store <vscale x 16 x i8> [[TMP0]], ptr [[VEC]], align 16
1227+
// CHECK-NEXT: ret void
1228+
//
1229+
void test_copy_s8_typedef(__SVInt8_t a) {
1230+
vec_t vec{a};
1231+
}

0 commit comments

Comments
 (0)