Skip to content

Commit f97add5

Browse files
committed
Prevent name clash of global variable for static variable initialization
1 parent e703db1 commit f97add5

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

tools/cgeist/Lib/clang-mlir.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -844,8 +844,9 @@ ValueCategory MLIRScanner::VisitVarDecl(clang::VarDecl *decl) {
844844
auto name = Glob.CGM.getMangledName(decl);
845845
auto globalOp = gbuilder.create<mlir::memref::GlobalOp>(
846846
module->getLoc(),
847-
builder.getStringAttr(function.getName() + "@static@" + name +
848-
"@init"),
847+
builder.getStringAttr(
848+
function.getName() + "@static@" + name + "@init@" +
849+
to_string(reinterpret_cast<long long unsigned int>(decl))),
849850
/*sym_visibility*/ mlir::StringAttr(), mlir::TypeAttr::get(mr),
850851
init_value, mlir::UnitAttr(), /*alignment*/ nullptr);
851852
SymbolTable::setSymbolVisibility(globalOp,

0 commit comments

Comments
 (0)