@@ -237,21 +237,6 @@ CIRGenModule::CIRGenModule(mlir::MLIRContext &mlirContext,
237237
238238CIRGenModule::~CIRGenModule () = default ;
239239
240- bool CIRGenModule::isTypeConstant (QualType ty, bool excludeCtor,
241- bool excludeDtor) {
242- if (!ty.isConstant (astContext) && !ty->isReferenceType ())
243- return false ;
244-
245- if (astContext.getLangOpts ().CPlusPlus ) {
246- if (const CXXRecordDecl *record =
247- astContext.getBaseElementType (ty)->getAsCXXRecordDecl ())
248- return excludeCtor && !record->hasMutableFields () &&
249- (record->hasTrivialDestructor () || excludeDtor);
250- }
251-
252- return true ;
253- }
254-
255240// / FIXME: this could likely be a common helper and not necessarily related
256241// / with codegen.
257242// / Return the best known alignment for an unknown pointer to a
@@ -393,7 +378,8 @@ bool CIRGenModule::MayBeEmittedEagerly(const ValueDecl *global) {
393378 if (langOpts.OpenMP && langOpts.OpenMPUseTLS &&
394379 getASTContext ().getTargetInfo ().isTLSSupported () &&
395380 isa<VarDecl>(global) &&
396- !global->getType ().isConstantStorage (getASTContext (), false , false ) &&
381+ !global->getType ().isConstantStorage (
382+ getASTContext (), /* ExcludeCtor=*/ false , /* ExcludeDtor=*/ false ) &&
397383 !OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration (global))
398384 return false ;
399385
@@ -1205,7 +1191,8 @@ CIRGenModule::getOrCreateCIRGlobal(StringRef mangledName, mlir::Type ty,
12051191 // FIXME: This code is overly simple and should be merged with other global
12061192 // handling.
12071193 gv.setAlignmentAttr (getSize (astContext.getDeclAlign (d)));
1208- gv.setConstant (isTypeConstant (d->getType (), false , false ));
1194+ gv.setConstant (d->getType ().isConstantStorage (
1195+ astContext, /* ExcludeCtor=*/ false , /* ExcludeDtor=*/ false ));
12091196 // TODO(cir): setLinkageForGV(GV, D);
12101197
12111198 if (d->getTLSKind ()) {
@@ -1399,7 +1386,8 @@ void CIRGenModule::emitGlobalVarDefinition(const clang::VarDecl *d,
13991386 // TODO: Update this when we have interface to check constexpr
14001387 // destructor.
14011388 d->needsDestruction (getASTContext ()) ||
1402- !d->getType ().isConstantStorage (getASTContext (), true , true )))
1389+ !d->getType ().isConstantStorage (getASTContext (), /* ExcludeCtor=*/ true ,
1390+ /* ExcludeDtor=*/ true )))
14031391 return ;
14041392
14051393 const VarDecl *initDecl;
@@ -1569,9 +1557,11 @@ void CIRGenModule::emitGlobalVarDefinition(const clang::VarDecl *d,
15691557 emitter->finalize (gv);
15701558
15711559 // TODO(cir): If it is safe to mark the global 'constant', do so now.
1572- gv.setConstant ((d->hasAttr <CUDAConstantAttr>() && langOpts.CUDAIsDevice ) ||
1573- (!needsGlobalCtor && !needsGlobalDtor &&
1574- isTypeConstant (d->getType (), true , true )));
1560+ gv.setConstant (
1561+ (d->hasAttr <CUDAConstantAttr>() && langOpts.CUDAIsDevice ) ||
1562+ (!needsGlobalCtor && !needsGlobalDtor &&
1563+ d->getType ().isConstantStorage (getASTContext (), /* ExcludeCtor=*/ true ,
1564+ /* ExcludeDtor=*/ true )));
15751565
15761566 // If it is in a read-only section, mark it 'constant'.
15771567 if (const SectionAttr *sa = d->getAttr <SectionAttr>())
@@ -1963,7 +1953,7 @@ CIRGenModule::getAddrOfGlobalTemporary(const MaterializeTemporaryExpr *expr,
19631953 emitter->emitForInitializer (*value, addrSpace, materializedType);
19641954
19651955 isConstant = materializedType.isConstantStorage (
1966- getASTContext (), /* ExcludeCtor*/ value, /* ExcludeDtor*/ false );
1956+ getASTContext (), /* ExcludeCtor= */ value, /* ExcludeDtor= */ false );
19671957
19681958 type = mlir::cast<mlir::TypedAttr>(initialValue).getType ();
19691959 } else {
0 commit comments