Skip to content

Commit 7d486df

Browse files
committed
Address code review comments
1 parent 50b178f commit 7d486df

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h

+8-1
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,12 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
165165
return createLoad(loc, addr);
166166
}
167167

168+
169+
cir::PtrStrideOp createPtrStride(mlir::Location loc, mlir::Value base,
170+
mlir::Value stride) {
171+
return create<cir::PtrStrideOp>(loc, base.getType(), base, stride);
172+
}
173+
168174
//===--------------------------------------------------------------------===//
169175
// Cast/Conversion Operators
170176
//===--------------------------------------------------------------------===//
@@ -337,4 +343,5 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
337343

338344
} // namespace cir
339345

340-
#endif
346+
#endif
347+

clang/lib/CIR/CodeGen/CIRGenExprAggregate.cpp

+11-9
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ class AggExprEmitter : public StmtVisitor<AggExprEmitter> {
3131
AggValueSlot ensureSlot(mlir::Location loc, QualType t) {
3232
if (!dest.isIgnored())
3333
return dest;
34-
llvm_unreachable("Slot for ignored address NTI");
34+
35+
cgf.cgm.errorNYI(loc, "Slot for ignored address");
36+
return dest;
3537
}
3638

3739
public:
@@ -89,7 +91,8 @@ void AggExprEmitter::emitArrayInit(Address destPtr, cir::ArrayType arrayTy,
8991
cgf.getContext().getAsArrayType(arrayQTy)->getElementType();
9092

9193
if (elementType.isDestructedType()) {
92-
llvm_unreachable("dtorKind NYI");
94+
cgf.cgm.errorNYI(loc, "dtorKind NYI");
95+
return;
9396
}
9497

9598
const QualType elementPtrType = cgf.getContext().getPointerType(elementType);
@@ -123,8 +126,7 @@ void AggExprEmitter::emitArrayInit(Address destPtr, cir::ArrayType arrayTy,
123126
// Advance to the next element.
124127
if (i > 0) {
125128
one = builder.getConstantInt(loc, cgf.PtrDiffTy, i);
126-
element =
127-
builder.create<cir::PtrStrideOp>(loc, cirElementPtrType, begin, one);
129+
element = builder.createPtrStride(loc, begin, one);
128130
}
129131

130132
const Address address = Address(element, cirElementType, elementAlign);
@@ -152,8 +154,8 @@ void AggExprEmitter::emitArrayInit(Address destPtr, cir::ArrayType arrayTy,
152154

153155
// Allocate the temporary variable
154156
// to store the pointer to first unitialized element
155-
auto tmpAddr = cgf.createTempAlloca(
156-
cirElementPtrType, cgf.getPointerAlign(), loc, "arrayinit.temp", false);
157+
const Address tmpAddr = cgf.createTempAlloca(
158+
cirElementPtrType, cgf.getPointerAlign(), loc, "arrayinit.temp", /*insertIntoFnEntryBlock=*/ false);
157159
LValue tmpLV = LValue::makeAddr(tmpAddr, elementPtrType);
158160
cgf.emitStoreThroughLValue(RValue::get(element), tmpLV);
159161

@@ -173,8 +175,8 @@ void AggExprEmitter::emitArrayInit(Address destPtr, cir::ArrayType arrayTy,
173175

174176
// Advance pointer and store them to temporary variable
175177
one = builder.getConstantInt(loc, cgf.PtrDiffTy, 1);
176-
auto nextElement = builder.create<cir::PtrStrideOp>(
177-
loc, cirElementPtrType, currentElement, one);
178+
cir::PtrStrideOp nextElement = builder.createPtrStride(
179+
loc, currentElement, one);
178180
cgf.emitStoreThroughLValue(RValue::get(nextElement), tmpLV);
179181
}
180182
}
@@ -223,7 +225,7 @@ void AggExprEmitter::emitNullInitializationToLValue(mlir::Location loc,
223225

224226
if (cgf.hasScalarEvaluationKind(type)) {
225227
// For non-aggregates, we can store the appropriate null constant.
226-
auto null = cgf.cgm.emitNullConstant(type, loc);
228+
mlir::Value null = cgf.cgm.emitNullConstant(type, loc);
227229
if (lv.isSimple()) {
228230
cgf.emitStoreOfScalar(null, lv, /* isInitialization */ true);
229231
return;

0 commit comments

Comments
 (0)