Skip to content

Commit f72d8d9

Browse files
committed
Address review feedback
1 parent 996df6f commit f72d8d9

File tree

2 files changed

+15
-32
lines changed

2 files changed

+15
-32
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,13 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
194194
return create<cir::StoreOp>(loc, val, dst, align);
195195
}
196196

197-
[[nodiscard]] cir::GlobalOp
198-
createGlobal(mlir::ModuleOp module, mlir::Location loc, mlir::StringRef name,
199-
mlir::Type type, cir::GlobalLinkageKind linkage) {
197+
[[nodiscard]] cir::GlobalOp createGlobal(mlir::ModuleOp mlirModule,
198+
mlir::Location loc,
199+
mlir::StringRef name,
200+
mlir::Type type,
201+
cir::GlobalLinkageKind linkage) {
200202
mlir::OpBuilder::InsertionGuard guard(*this);
201-
setInsertionPointToStart(module.getBody());
203+
setInsertionPointToStart(mlirModule.getBody());
202204
return create<cir::GlobalOp>(loc, name, type, linkage);
203205
}
204206

clang/lib/CIR/CodeGen/CIRGenDecl.cpp

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -275,23 +275,20 @@ CIRGenModule::getOrCreateStaticVarDecl(const VarDecl &d,
275275
assert(ty->isConstantSizeType() && "VLAs can't be static");
276276

277277
// Use the label if the variable is renamed with the asm-label extension.
278-
std::string name;
279278
if (d.hasAttr<AsmLabelAttr>())
280279
errorNYI(d.getSourceRange(), "getOrCreateStaticVarDecl: asm label");
281-
else
282-
name = getStaticDeclName(*this, d);
280+
281+
std::string name = getStaticDeclName(*this, d);
283282

284283
mlir::Type lty = getTypes().convertTypeForMem(ty);
285284
assert(!cir::MissingFeatures::addressSpace());
286285

287-
// OpenCL variables in local address space and CUDA shared
288-
// variables cannot have an initializer.
289-
mlir::Attribute init = nullptr;
290-
if (d.hasAttr<LoaderUninitializedAttr>())
286+
if (d.hasAttr<LoaderUninitializedAttr>() || d.hasAttr<CUDASharedAttr>())
291287
errorNYI(d.getSourceRange(),
292288
"getOrCreateStaticVarDecl: LoaderUninitializedAttr");
289+
assert(!cir::MissingFeatures::addressSpace());
293290

294-
init = builder.getZeroInitAttr(convertType(ty));
291+
mlir::Attribute init = builder.getZeroInitAttr(convertType(ty));
295292

296293
cir::GlobalOp gv = builder.createVersionedGlobal(
297294
getModule(), getLoc(d.getLocation()), name, lty, linkage);
@@ -443,26 +440,10 @@ void CIRGenFunction::emitStaticVarDecl(const VarDecl &d,
443440

444441
var.setAlignment(alignment.getAsAlign().value());
445442

446-
if (d.hasAttr<AnnotateAttr>())
447-
cgm.errorNYI(d.getSourceRange(), "static var annotation");
448-
449-
if (d.getAttr<PragmaClangBSSSectionAttr>())
450-
cgm.errorNYI(d.getSourceRange(), "static var BSS section attribute");
451-
if (d.getAttr<PragmaClangDataSectionAttr>())
452-
cgm.errorNYI(d.getSourceRange(), "static var Data section attribute");
453-
if (d.getAttr<PragmaClangRodataSectionAttr>())
454-
cgm.errorNYI(d.getSourceRange(), "static var Rodata section attribute");
455-
if (d.getAttr<PragmaClangRelroSectionAttr>())
456-
cgm.errorNYI(d.getSourceRange(), "static var Relro section attribute");
457-
458-
if (d.getAttr<SectionAttr>())
459-
cgm.errorNYI(d.getSourceRange(),
460-
"static var object file section attribute");
461-
462-
if (d.hasAttr<RetainAttr>())
463-
cgm.errorNYI(d.getSourceRange(), "static var retain attribute");
464-
else if (d.hasAttr<UsedAttr>())
465-
cgm.errorNYI(d.getSourceRange(), "static var used attribute");
443+
// There are a lot of attributes that need to be handled here. Until
444+
// we start to support them, we just report an error if there are any.
445+
if (d.hasAttrs())
446+
cgm.errorNYI(d.getSourceRange(), "static var with attrs");
466447

467448
if (cgm.getCodeGenOpts().KeepPersistentStorageVariables)
468449
cgm.errorNYI(d.getSourceRange(), "static var keep persistent storage");

0 commit comments

Comments
 (0)