Skip to content

Commit 2c9ce5e

Browse files
committed
Mangle global variable names
1 parent c598551 commit 2c9ce5e

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

clang/lib/CIR/CodeGen/CIRGenModule.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,8 +367,9 @@ void CIRGenModule::emitGlobalVarDefinition(const clang::VarDecl *vd,
367367
const QualType astTy = vd->getType();
368368
const mlir::Type type = convertType(vd->getType());
369369
if (clang::IdentifierInfo *identifier = vd->getIdentifier()) {
370+
StringRef name = getMangledName(GlobalDecl(vd));
370371
auto varOp = builder.create<cir::GlobalOp>(getLoc(vd->getSourceRange()),
371-
identifier->getName(), type);
372+
name, type);
372373
// TODO(CIR): This code for processing initial values is a placeholder
373374
// until class ConstantEmitter is upstreamed and the code for processing
374375
// constant expressions is filled out. Only the most basic handling of

clang/test/CIR/global-var-linkage.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
int aaaa;
55
// CHECK: cir.global external @aaaa
66
static int bbbb;
7-
// CHECK: cir.global internal @bbbb
7+
// CHECK: cir.global internal @_ZL4bbbb
88
inline int cccc;
99
// CHECK: cir.global linkonce_odr @cccc
1010
[[gnu::selectany]] int dddd;

0 commit comments

Comments
 (0)