Skip to content

Commit

Permalink
fix upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
HerrCai0907 committed Nov 14, 2024
1 parent f80cb39 commit 2e0d8f3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
4 changes: 2 additions & 2 deletions clang/lib/CIR/CodeGen/CIRGenExprAgg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ class AggExprEmitter : public StmtVisitor<AggExprEmitter> {
assert(llvm::isa<InitListExpr>(subExpr));
llvm::SmallVector<mlir::Value> inits{};
for (auto *init : llvm::cast<InitListExpr>(subExpr)->inits()) {
RValue tmpInit = CGF.buildAnyExprToTemp(init);
RValue tmpInit = CGF.emitAnyExprToTemp(init);
if (tmpInit.isScalar()) {
inits.push_back(tmpInit.getScalarVal());
} else if (tmpInit.isComplex()) {
Expand All @@ -321,7 +321,7 @@ class AggExprEmitter : public StmtVisitor<AggExprEmitter> {
}
}
AggValueSlot dest = EnsureSlot(loc, E->getType());
builder.create<mlir::cir::InitListCtor>(loc, dest.getPointer(), inits);
builder.create<cir::InitListCtor>(loc, dest.getPointer(), inits);
}

void VisitExprWithCleanups(ExprWithCleanups *E);
Expand Down
17 changes: 8 additions & 9 deletions clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4387,12 +4387,12 @@ class CIRSignBitOpLowering : public mlir::OpConversionPattern<cir::SignBitOp> {
};

class CIRInitListCtorLowering
: public mlir::OpConversionPattern<mlir::cir::InitListCtor> {
: public mlir::OpConversionPattern<cir::InitListCtor> {
public:
using OpConversionPattern<mlir::cir::InitListCtor>::OpConversionPattern;
using OpConversionPattern<cir::InitListCtor>::OpConversionPattern;

mlir::LogicalResult
matchAndRewrite(mlir::cir::InitListCtor op, OpAdaptor adaptor,
matchAndRewrite(cir::InitListCtor op, OpAdaptor adaptor,
mlir::ConversionPatternRewriter &rewriter) const override {
auto loc = op.getLoc();
const bool inbounds = true;
Expand All @@ -4402,9 +4402,8 @@ class CIRInitListCtorLowering
mlir::LLVM::LLVMPointerType::get(rewriter.getContext());

// initlist object
auto initListType = mlir::cast<mlir::cir::StructType>(
mlir::cast<mlir::cir::PointerType>(op->getOperand(0).getType())
.getPointee());
auto initListType = mlir::cast<cir::StructType>(
mlir::cast<cir::PointerType>(op->getOperand(0).getType()).getPointee());
assert(initListType.getMembers().size() == 2U);
auto initListLLVMType = getTypeConverter()->convertType(initListType);
mlir::Value initlist = adaptor.getOperands()[0];
Expand Down Expand Up @@ -4434,16 +4433,16 @@ class CIRInitListCtorLowering
initArgStoragePtr);
}
// rewrite
assert(mlir::isa<mlir::cir::PointerType>(initListType.getMembers()[0]));
assert(mlir::isa<cir::PointerType>(initListType.getMembers()[0]));
auto llvmStartType = getTypeConverter()->convertType(
(mlir::cast<mlir::cir::PointerType>(initListType.getMembers()[0])));
(mlir::cast<cir::PointerType>(initListType.getMembers()[0])));
auto llvmStartElement = rewriter.create<mlir::LLVM::GEPOp>(
loc, llvmStartType, initListLLVMType, initlist,
llvm::SmallVector<mlir::LLVM::GEPArg>{0, 0}, inbounds);
rewriter.create<mlir::LLVM::StoreOp>(loc, llvmArrayPtr, llvmStartElement);

auto endType = initListType.getMembers()[1];
if (mlir::dyn_cast<mlir::cir::PointerType>(endType)) {
if (mlir::dyn_cast<cir::PointerType>(endType)) {
auto llvmEndOfArray = rewriter.create<mlir::LLVM::GEPOp>(
loc, llvmPtrType, llvmArrayType, llvmArrayPtr,
llvm::SmallVector<mlir::LLVM::GEPArg>{0, argListSize}, inbounds);
Expand Down
2 changes: 1 addition & 1 deletion clang/test/CIR/CodeGen/initlist-ptr-ptr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void test() {
// LLVM: [[ELEM_ARRAY_PTR:%.*]] = alloca [2 x ptr], align 8,
// LLVM: store ptr @.str, ptr [[ELEM_ARRAY_PTR]], align 8,
// LLVM: [[PTR_SECOND_ELEM:%.*]] = getelementptr inbounds [2 x ptr], ptr [[ELEM_ARRAY_PTR]], i32 1,
// LLVM: store ptr @.str1, ptr [[PTR_SECOND_ELEM]], align 8,
// LLVM: store ptr @.str.1, ptr [[PTR_SECOND_ELEM]], align 8,
// LLVM: [[INIT_START_FLD_PTR:%.*]] = getelementptr inbounds %"class.std::initializer_list<const char *>", ptr [[INIT_STRUCT]], i32 0, i32 0,
// LLVM: store ptr [[ELEM_ARRAY_PTR]], ptr [[INIT_START_FLD_PTR]], align 8,
// LLVM: [[ELEM_ARRAY_END:%.*]] = getelementptr inbounds [2 x ptr], ptr [[ELEM_ARRAY_PTR]], i32 0, i32 2,
Expand Down

0 comments on commit 2e0d8f3

Please sign in to comment.