Skip to content

Commit b5cf42b

Browse files
committed
Address code review comments
1 parent 541da71 commit b5cf42b

File tree

5 files changed

+21
-21
lines changed

5 files changed

+21
-21
lines changed

clang/lib/CIR/CodeGen/CIRGenBuilder.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,12 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy {
3535
}
3636

3737
bool isSized(mlir::Type ty) {
38-
return mlir::isa<cir::PointerType, cir::ArrayType, cir::BoolType,
39-
cir::IntType>(ty);
38+
if (mlir::isa<cir::PointerType, cir::ArrayType, cir::BoolType,
39+
cir::IntType>(ty))
40+
return true;
41+
42+
assert(0 && "Unimplemented size for type");
43+
return false;
4044
}
4145
};
4246

clang/lib/CIR/CodeGen/CIRGenTypes.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -205,13 +205,6 @@ mlir::Type CIRGenTypes::convertType(QualType type) {
205205
case Type::ConstantArray: {
206206
const ConstantArrayType *arrTy = cast<ConstantArrayType>(ty);
207207
mlir::Type elemTy = convertTypeForMem(arrTy->getElementType());
208-
209-
if (!builder.isSized(elemTy)) {
210-
cgm.errorNYI(SourceLocation(), "unimplemented size for type", type);
211-
resultType = cir::ArrayType::get(builder.getContext(), cgm.SInt32Ty, 0);
212-
break;
213-
}
214-
215208
resultType = cir::ArrayType::get(builder.getContext(), elemTy,
216209
arrTy->getSize().getZExtValue());
217210
break;

clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,8 @@ static void prepareTypeConverter(mlir::LLVMTypeConverter &converter,
573573
return mlir::LLVM::LLVMPointerType::get(type.getContext(), targetAS);
574574
});
575575
converter.addConversion([&](cir::ArrayType type) -> mlir::Type {
576-
auto ty = convertTypeForMemory(converter, dataLayout, type.getEltType());
576+
mlir::Type ty =
577+
convertTypeForMemory(converter, dataLayout, type.getEltType());
577578
return mlir::LLVM::LLVMArrayType::get(ty, type.getSize());
578579
});
579580
converter.addConversion([&](cir::BoolType type) -> mlir::Type {

clang/test/CIR/CodeGen/array.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
int a[10];
44
// CHECK: cir.global external @a : !cir.array<!cir.int<s, 32> x 10>
55

6-
int aa[10][10];
7-
// CHECK: cir.global external @aa : !cir.array<!cir.array<!cir.int<s, 32> x 10> x 10>
6+
int aa[10][5];
7+
// CHECK: cir.global external @aa : !cir.array<!cir.array<!cir.int<s, 32> x 5> x 10>
88

99
extern int b[10];
1010
// CHECK: cir.global external @b : !cir.array<!cir.int<s, 32> x 10>
1111

12-
extern int bb[10][10];
13-
// CHECK: cir.global external @bb : !cir.array<!cir.array<!cir.int<s, 32> x 10> x 10>
12+
extern int bb[10][5];
13+
// CHECK: cir.global external @bb : !cir.array<!cir.array<!cir.int<s, 32> x 5> x 10>
1414

1515
void f() {
1616
int l[10];
@@ -19,6 +19,8 @@ void f() {
1919

2020
void f2(int p[10]) {}
2121
// CHECK: cir.func @f2(%arg0: !cir.ptr<!cir.int<s, 32>>
22+
// CHECK: cir.alloca !cir.ptr<!cir.int<s, 32>>, !cir.ptr<!cir.ptr<!cir.int<s, 32>>>, ["p", init]
2223

23-
void f3(int pp[10][10]) {}
24-
// CHECK: cir.func @f3(%arg0: !cir.ptr<!cir.array<!cir.int<s, 32> x 10>>
24+
void f3(int pp[10][5]) {}
25+
// CHECK: cir.func @f3(%arg0: !cir.ptr<!cir.array<!cir.int<s, 32> x 5>>
26+
// CHECK: cir.alloca !cir.ptr<!cir.array<!cir.int<s, 32> x 5>>, !cir.ptr<!cir.ptr<!cir.array<!cir.int<s, 32> x 5>>>

clang/test/CIR/Lowering/array.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
int a[10];
44
// CHECK: @a = external dso_local global [10 x i32]
55

6-
int aa[10][10];
7-
// CHECK: @aa = external dso_local global [10 x [10 x i32]]
6+
int aa[10][5];
7+
// CHECK: @aa = external dso_local global [10 x [5 x i32]]
88

99
extern int b[10];
1010
// CHECK: @b = external dso_local global [10 x i32]
1111

12-
extern int bb[10][10];
13-
// CHECK: @bb = external dso_local global [10 x [10 x i32]]
12+
extern int bb[10][5];
13+
// CHECK: @bb = external dso_local global [10 x [5 x i32]]
1414

1515
void f() {
1616
int l[10];
@@ -20,5 +20,5 @@ void f() {
2020
void f2(int p[10]) {}
2121
// CHECK: alloca ptr, i64 1, align 8
2222

23-
void f3(int pp[10][10]) {}
23+
void f3(int pp[10][5]) {}
2424
// CHECK: alloca ptr, i64 1, align 8

0 commit comments

Comments
 (0)