@@ -571,9 +571,6 @@ CIRGenTypes::computeRecordLayout(const RecordDecl *D,
571571
572572 builder.lower (/* nonVirtualBaseType=*/ false );
573573
574- auto name = getRecordTypeName (D, " " );
575- auto identifier = mlir::StringAttr::get (&getMLIRContext (), name);
576-
577574 // If we're in C++, compute the base subobject type.
578575 mlir::cir::StructType *BaseTy = nullptr ;
579576 if (llvm::isa<CXXRecordDecl>(D) && !D->isUnion () &&
@@ -582,12 +579,9 @@ CIRGenTypes::computeRecordLayout(const RecordDecl *D,
582579 if (builder.astRecordLayout .getNonVirtualSize () !=
583580 builder.astRecordLayout .getSize ()) {
584581 CIRRecordLowering baseBuilder (*this , D, /* Packed=*/ builder.isPacked );
585- auto baseIdentifier =
586- mlir::StringAttr::get (&getMLIRContext (), name + " .base" );
587- *BaseTy = mlir::cir::StructType::get (
588- &getMLIRContext (), baseBuilder.fieldTypes , baseIdentifier,
589- /* body=*/ true , /* *packed=*/ false ,
590- mlir::cir::ASTRecordDeclAttr::get (&getMLIRContext (), D));
582+ auto baseIdentifier = getRecordTypeName (D, " .base" );
583+ *BaseTy = Builder.getStructTy (baseBuilder.fieldTypes , baseIdentifier,
584+ /* body=*/ true , /* packed=*/ false , D);
591585 // TODO(cir): add something like addRecordTypeName
592586
593587 // BaseTy and Ty must agree on their packedness for getCIRFieldNo to work
@@ -600,10 +594,8 @@ CIRGenTypes::computeRecordLayout(const RecordDecl *D,
600594 // Fill in the struct *after* computing the base type. Filling in the body
601595 // signifies that the type is no longer opaque and record layout is complete,
602596 // but we may need to recursively layout D while laying D out as a base type.
603- *Ty = mlir::cir::StructType::get (
604- &getMLIRContext (), builder.fieldTypes , identifier,
605- /* body=*/ true , /* *packed=*/ false ,
606- mlir::cir::ASTRecordDeclAttr::get (&getMLIRContext (), D));
597+ *Ty = Builder.getStructTy (builder.fieldTypes , getRecordTypeName (D, " " ),
598+ /* body=*/ true , /* packed=*/ false , D);
607599
608600 auto RL = std::make_unique<CIRGenRecordLayout>(
609601 Ty ? *Ty : mlir::cir::StructType{},
0 commit comments