[clang] Cir/vtable unnamed addr (PR #239708)
Konstantinos Parasyris via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 6 09:57:07 PST 2026
https://github.com/koparasy created https://github.com/llvm/llvm-project/pull/239708
Port classic codegen's vtable unnamed_addr rules to CIR:
* A vtable is marked unnamed_addr when no RTTI is emitted, since nothing (e.g. dynamic_cast) relies on its address.
* On targets that may duplicate weak vtables, a weak vtable is marked unnamed_addr even with RTTI.
Depends on #239429.
AI help was used for this PR description and the commit itself. Especially in testing.
>From 9e2322aa01cf2fab90f806abf4005954276623ac Mon Sep 17 00:00:00 2001
From: Konstantinos Parasyris <konstantinos.parasyris at intel.com>
Date: Thu, 5 Nov 2026 16:07:08 -0800
Subject: [PATCH 1/3] [CIR] Add unnamed_addr to cir.global
Add an `unnamed_addr` unit property to cir.global and lower it to the
LLVM dialect's `unnamed_addr` attribute.
The LLVM dialect models this as a three-valued enum
(`#llvm.unnamed_addr<none|local_unnamed_addr|unnamed_addr>`). CIR uses
an on/off flag instead: classic codegen only ever sets `unnamed_addr`
or nothing, never `local_unnamed_addr` (that is introduced later by
optimization passes), so the extra state is not needed.
AI modified the tests accordingly.
---
clang/include/clang/CIR/Dialect/IR/CIROps.td | 7 +++
clang/lib/CIR/CodeGen/CIRGenDecl.cpp | 2 +-
clang/lib/CIR/CodeGen/CIRGenModule.cpp | 3 +-
clang/lib/CIR/CodeGen/CIRGenVTables.cpp | 1 +
.../Dialect/Transforms/LoweringPrepare.cpp | 3 ++
.../CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp | 5 ++
clang/test/CIR/CodeGen/agg-expr-lvalue.c | 8 ++--
clang/test/CIR/CodeGen/agg-init-constexpr.cpp | 4 +-
clang/test/CIR/CodeGen/array.cpp | 12 ++---
clang/test/CIR/CodeGen/compound_literal.cpp | 4 +-
.../test/CIR/CodeGen/constexpr-ptr-offset.cpp | 6 +--
clang/test/CIR/CodeGen/embed-expr.c | 2 +-
.../CIR/CodeGen/global-const-alignment.cpp | 4 +-
.../local-const-aggregate-name-clash.cpp | 8 ++--
.../CIR/CodeGen/local-ptr-flat-offset.cpp | 2 +-
clang/test/CIR/CodeGen/loop.cpp | 4 +-
clang/test/CIR/CodeGen/no-odr-use.cpp | 12 ++---
clang/test/CIR/CodeGen/nonzeroinit-struct.cpp | 4 +-
clang/test/CIR/CodeGen/paren-init-list.cpp | 4 +-
.../CIR/CodeGen/pointer-to-member-func.cpp | 16 +++----
clang/test/CIR/CodeGen/predefined-expr.c | 38 +++++++--------
clang/test/CIR/CodeGen/source-loc.cpp | 20 ++++----
clang/test/CIR/CodeGen/statement-exprs.c | 4 +-
clang/test/CIR/CodeGen/string-literals.c | 12 ++---
clang/test/CIR/CodeGen/string-literals.cpp | 24 +++++-----
clang/test/CIR/CodeGen/struct-init.cpp | 4 +-
clang/test/CIR/CodeGen/struct.cpp | 16 +++----
clang/test/CIR/CodeGen/union-agg-init.c | 2 +-
.../CIR/CodeGen/unions-with-zero-init.cpp | 2 +-
.../CIR/CodeGen/variable-decomposition.cpp | 4 +-
clang/test/CIR/CodeGen/vtt.cpp | 2 +-
clang/test/CIR/CodeGen/wide-string.cpp | 32 ++++++-------
.../CIR/CodeGenBuiltins/builtin-printf.cpp | 8 ++--
clang/test/CIR/CodeGenCXX/new-array-init.cpp | 6 +--
clang/test/CIR/CodeGenCXX/sizeof-pack.cpp | 8 ++--
clang/test/CIR/CodeGenCXX/vtable-linkage.cpp | 4 +-
.../CodeGenHIP/string-literal-addrspace.hip | 48 +++++++++----------
.../CodeGenOpenCL/string-literal-addrspace.cl | 24 +++++-----
.../CIR/CodeGenSYCL/global-address-space.cpp | 6 +--
.../CIR/CodeGenSYCL/unique-stable-name.cpp | 32 ++++++-------
clang/test/CIR/IR/global-unnamed-addr.cir | 28 +++++++++++
clang/test/CIR/Lowering/array.cpp | 10 ++--
42 files changed, 245 insertions(+), 200 deletions(-)
create mode 100644 clang/test/CIR/IR/global-unnamed-addr.cir
diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td b/clang/include/clang/CIR/Dialect/IR/CIROps.td
index 4ffde906be3937..e8e55ac385ddb9 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIROps.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td
@@ -3486,6 +3486,11 @@ def CIR_GlobalOp : CIR_RegionBranchOpBase<"global", [
Symbol visibility in `sym_visibility` is defined in terms of MLIR's visibility
and verified to be in accordance to `linkage`.
+ The `unnamed_addr` attribute indicates that the address of the global is
+ not significant, only its contents are. Such globals may be merged with
+ other globals that have identical contents. It is lowered to LLVM's
+ `unnamed_addr` (as opposed to `local_unnamed_addr`).
+
The `dynamic_init_guard` attribute indicates that this global requires
guarded dynamic initialization via the Itanium `__cxa_guard_*` protocol
(e.g., C++ static local variables with non-constant initializers, or
@@ -3522,6 +3527,7 @@ def CIR_GlobalOp : CIR_RegionBranchOpBase<"global", [
OptionalAttr<StrAttr>:$comdat,
UnitProp:$constant,
UnitProp:$dso_local,
+ UnitProp:$unnamed_addr,
OptionalAttr<CIR_DynamicInitGuardAttr>:$dynamic_init_guard,
OptionalAttr<I64Attr>:$alignment,
OptionalAttr<ASTVarDeclInterface>:$ast,
@@ -3545,6 +3551,7 @@ def CIR_GlobalOp : CIR_RegionBranchOpBase<"global", [
(`tls_model` `=` enum($tls_model)^)?
(`tls_refs` `=` $tls_refs^)?
(`dso_local` $dso_local^)?
+ (`unnamed_addr` $unnamed_addr^)?
(`dynamic_init_guard` `` $dynamic_init_guard^)?
(` ` custom<GlobalMemorySpace>($addr_space)^ )?
$sym_name
diff --git a/clang/lib/CIR/CodeGen/CIRGenDecl.cpp b/clang/lib/CIR/CodeGen/CIRGenDecl.cpp
index 8e5510d26d94c3..b3bca0782e84c3 100644
--- a/clang/lib/CIR/CodeGen/CIRGenDecl.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenDecl.cpp
@@ -805,7 +805,7 @@ Address CIRGenModule::createUnnamedGlobalFrom(const VarDecl &d,
cir::GlobalLinkageKind::PrivateLinkage));
gv.setInitialValueAttr(constAttr);
gv.setAlignment(align.getAsAlign().value());
- // TODO(cir): Set unnamed address attribute when available in CIR
+ gv.setUnnamedAddr(true);
cacheEntry = gv;
} else if (cacheEntry.getAlignment() <
diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 4102da145b7c02..80822f17bec428 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -2293,7 +2293,7 @@ generateStringLiteral(mlir::Location loc, mlir::TypedAttr c,
gv.setLinkageAttr(
cir::GlobalLinkageKindAttr::get(cgm.getBuilder().getContext(), lt));
assert(!cir::MissingFeatures::opGlobalThreadLocal());
- assert(!cir::MissingFeatures::opGlobalUnnamedAddr());
+ gv.setUnnamedAddr(true);
CIRGenModule::setInitializer(gv, c);
if (gv.isWeakForLinker()) {
assert(cgm.supportsCOMDAT() && "Only COFF uses weak string literals");
@@ -4600,6 +4600,7 @@ cir::GlobalOp CIRGenModule::getAddrOfUnnamedGlobalConstantDecl(
CharUnits alignment = getASTContext().getTypeAlignInChars(gcd->getType());
globalOp.setAlignment(alignment.getAsAlign().value());
+ globalOp.setUnnamedAddr(true);
CIRGenModule::setInitializer(globalOp, init);
emitter.finalize(globalOp);
diff --git a/clang/lib/CIR/CodeGen/CIRGenVTables.cpp b/clang/lib/CIR/CodeGen/CIRGenVTables.cpp
index ca7a8a74a9e211..4ac07fe42c1a05 100644
--- a/clang/lib/CIR/CodeGen/CIRGenVTables.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenVTables.cpp
@@ -473,6 +473,7 @@ cir::GlobalOp CIRGenVTables::getAddrOfVTT(const CXXRecordDecl *rd) {
cir::GlobalOp vtt = cgm.createOrReplaceCXXRuntimeVariable(
cgm.getLoc(rd->getSourceRange()), name, arrayType,
cir::GlobalLinkageKind::ExternalLinkage, CharUnits::fromQuantity(align));
+ vtt.setUnnamedAddr(true);
cgm.setGVProperties(vtt, rd);
return vtt;
}
diff --git a/clang/lib/CIR/Dialect/Transforms/LoweringPrepare.cpp b/clang/lib/CIR/Dialect/Transforms/LoweringPrepare.cpp
index ffd631b9ead9d1..f54013da15daef 100644
--- a/clang/lib/CIR/Dialect/Transforms/LoweringPrepare.cpp
+++ b/clang/lib/CIR/Dialect/Transforms/LoweringPrepare.cpp
@@ -2671,6 +2671,9 @@ cir::GlobalOp LoweringPreparePass::getOrCreateConstAggregateGlobal(
gv, mlir::SymbolTable::Visibility::Private);
gv.setInitialValueAttr(constant);
gv.setAlignment(alignment);
+ // Matches classic codegen's createUnnamedGlobalFrom: only the contents of
+ // the constant matter, not its address.
+ gv.setUnnamedAddr(true);
// Keep the cached symbol table in sync with the new global so subsequent
// lookups for other base names find it.
diff --git a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
index a48dbd04de84ac..597ba7df3b0e1f 100644
--- a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
+++ b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
@@ -3334,6 +3334,11 @@ CIRToLLVMGlobalOpLowering::lowerGlobalAttributes(
lowerCIRVisibilityToLLVMVisibility(op.getGlobalVisibility()));
attributes.push_back(rewriter.getNamedAttr("visibility_", visibility));
+ if (op.getUnnamedAddr())
+ attributes.push_back(rewriter.getNamedAttr(
+ "unnamed_addr", mlir::LLVM::UnnamedAddrAttr::get(
+ getContext(), mlir::LLVM::UnnamedAddr::Global)));
+
if (op->getAttr(CUDAExternallyInitializedAttr::getMnemonic()))
attributes.push_back(rewriter.getNamedAttr("externally_initialized",
rewriter.getUnitAttr()));
diff --git a/clang/test/CIR/CodeGen/agg-expr-lvalue.c b/clang/test/CIR/CodeGen/agg-expr-lvalue.c
index 36eb0c0a34bffa..42bd0cbe72ecd7 100644
--- a/clang/test/CIR/CodeGen/agg-expr-lvalue.c
+++ b/clang/test/CIR/CodeGen/agg-expr-lvalue.c
@@ -20,11 +20,11 @@ void test_member_in_array(void) {
struct Point arr[1] = {line.start};
}
-// CIR-DAG: cir.global "private" constant cir_private @[[LINE_CONST:.*]] = #cir.const_record<{#cir.const_record<{#cir.int<1> : !s32i, #cir.int<2> : !s32i}> : !rec_Point, #cir.const_record<{#cir.int<3> : !s32i, #cir.int<4> : !s32i}> : !rec_Point}> : !rec_Line
-// CIR-DAG: cir.global "private" constant cir_private @[[MATRIX_CONST:.*]] = #cir.const_array<[#cir.const_array<[#cir.int<104> : !s8i, #cir.int<101> : !s8i, #cir.int<108> : !s8i, #cir.int<108> : !s8i, #cir.int<111> : !s8i], trailing_zeros> : !cir.array<!s8i x 6>, #cir.const_array<[#cir.int<119> : !s8i, #cir.int<111> : !s8i, #cir.int<114> : !s8i, #cir.int<108> : !s8i, #cir.int<100> : !s8i], trailing_zeros> : !cir.array<!s8i x 6>]>
+// CIR-DAG: cir.global "private" constant cir_private unnamed_addr @[[LINE_CONST:.*]] = #cir.const_record<{#cir.const_record<{#cir.int<1> : !s32i, #cir.int<2> : !s32i}> : !rec_Point, #cir.const_record<{#cir.int<3> : !s32i, #cir.int<4> : !s32i}> : !rec_Point}> : !rec_Line
+// CIR-DAG: cir.global "private" constant cir_private unnamed_addr @[[MATRIX_CONST:.*]] = #cir.const_array<[#cir.const_array<[#cir.int<104> : !s8i, #cir.int<101> : !s8i, #cir.int<108> : !s8i, #cir.int<108> : !s8i, #cir.int<111> : !s8i], trailing_zeros> : !cir.array<!s8i x 6>, #cir.const_array<[#cir.int<119> : !s8i, #cir.int<111> : !s8i, #cir.int<114> : !s8i, #cir.int<108> : !s8i, #cir.int<100> : !s8i], trailing_zeros> : !cir.array<!s8i x 6>]>
-// LLVM-DAG: @[[LINE_CONST:.*]] = private constant %struct.Line { %struct.Point { i32 1, i32 2 }, %struct.Point { i32 3, i32 4 } }
-// LLVM-DAG: @[[MATRIX_CONST:.*]] = private constant [2 x [6 x i8]] {{.*}}
+// LLVM-DAG: @[[LINE_CONST:.*]] = private unnamed_addr constant %struct.Line { %struct.Point { i32 1, i32 2 }, %struct.Point { i32 3, i32 4 } }
+// LLVM-DAG: @[[MATRIX_CONST:.*]] = private unnamed_addr constant [2 x [6 x i8]] {{.*}}
// CIR-LABEL: cir.func{{.*}} @test_member_in_array
// CIR: %[[LINE:.*]] = cir.alloca "line" {{.*}} init : !cir.ptr<!rec_Line>
diff --git a/clang/test/CIR/CodeGen/agg-init-constexpr.cpp b/clang/test/CIR/CodeGen/agg-init-constexpr.cpp
index 43809c723f9536..d89959c410991e 100644
--- a/clang/test/CIR/CodeGen/agg-init-constexpr.cpp
+++ b/clang/test/CIR/CodeGen/agg-init-constexpr.cpp
@@ -19,7 +19,7 @@ extern "C" void construct() {
WithCtor c(2,5);
}
-// CIR: cir.global "private" constant cir_private @__const.construct.tmp = #cir.const_record<{#cir.int<4> : !s32i, #cir.zero : !cir.array<!u8i x 4>, #cir.int<10> : !s64i, #cir.const_record<{#cir.int<5> : !s32i}> : !rec_HasVal, #cir.zero : !cir.array<!u8i x 4>}> : !rec_WithCtor
+// CIR: cir.global "private" constant cir_private unnamed_addr @__const.construct.tmp = #cir.const_record<{#cir.int<4> : !s32i, #cir.zero : !cir.array<!u8i x 4>, #cir.int<10> : !s64i, #cir.const_record<{#cir.int<5> : !s32i}> : !rec_HasVal, #cir.zero : !cir.array<!u8i x 4>}> : !rec_WithCtor
// CIR-LABEL: construct()
// CIR-NEXT: %[[WC_ALLOCA:.*]] = cir.alloca "c" {{.*}} : !cir.ptr<!rec_WithCtor>
// CIR-NEXT: %[[TMP_ALLOCA:.*]] = cir.alloca "tmp" {{.*}} : !cir.ptr<!rec_WithCtor>
@@ -28,7 +28,7 @@ extern "C" void construct() {
// CIR-NEXT: cir.copy %[[TMP_ALLOCA]] align(8) to %[[WC_ALLOCA]] align(8) skip_tail_padding : !cir.ptr<!rec_WithCtor>
// CIR-NEXT: cir.return
-// LLVM: @__const.construct.tmp = private constant %struct.WithCtor <{ i32 4, [4 x i8] zeroinitializer, i64 10, %struct.HasVal { i32 5 }, [4 x i8] zeroinitializer }>
+// LLVM: @__const.construct.tmp = private unnamed_addr constant %struct.WithCtor <{ i32 4, [4 x i8] zeroinitializer, i64 10, %struct.HasVal { i32 5 }, [4 x i8] zeroinitializer }>
// LLVM-LABEL: construct()
// LLVM-NEXT: %[[WC_ALLOCA:.*]] = alloca %struct.WithCtor
// LLVM-NEXT: %[[TMP_ALLOCA:.*]] = alloca %struct.WithCtor
diff --git a/clang/test/CIR/CodeGen/array.cpp b/clang/test/CIR/CodeGen/array.cpp
index 61017e019c207b..a26c6d3f547edc 100644
--- a/clang/test/CIR/CodeGen/array.cpp
+++ b/clang/test/CIR/CodeGen/array.cpp
@@ -5,12 +5,12 @@
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -emit-llvm %s -o %t.ll
// RUN: FileCheck --input-file=%t.ll %s -check-prefix=OGCG
-// CIR-DAG: cir.global "private"{{.*}}constant cir_private @[[FUNC2_ARR:.*]] = #cir.const_array<[#cir.int<5> : !s32i], trailing_zeros> : !cir.array<!s32i x 2>
-// CIR-DAG: cir.global "private"{{.*}}constant cir_private @[[FUNC3_ARR:.*]] = #cir.const_array<[#cir.int<5> : !s32i, #cir.int<6> : !s32i]> : !cir.array<!s32i x 2>
-// CIR-DAG: cir.global "private"{{.*}}constant cir_private @[[FUNC4_ARR:.*]] = #cir.const_array<[#cir.const_array<[#cir.int<5> : !s32i]> : !cir.array<!s32i x 1>, #cir.const_array<[#cir.int<6> : !s32i]> : !cir.array<!s32i x 1>]> : !cir.array<!cir.array<!s32i x 1> x 2>
-// CIR-DAG: cir.global "private"{{.*}}constant cir_private @[[FUNC5_ARR:.*]] = #cir.const_array<[#cir.const_array<[#cir.int<5> : !s32i]> : !cir.array<!s32i x 1>], trailing_zeros> : !cir.array<!cir.array<!s32i x 1> x 2>
-// CIR-DAG: cir.global "private"{{.*}}constant cir_private @[[FUNC7_ARR:.*]] = #cir.zero : !cir.array<!cir.ptr<!s32i> x 1>
-// CIR-DAG: cir.global "private"{{.*}}constant cir_private @[[COMPLEX_ARR:.*]] = #cir.const_array<[#cir.const_complex<#cir.fp<1.100000e+00> : !cir.float, #cir.fp<2.200000e+00> : !cir.float> : !cir.complex<!cir.float>, #cir.const_complex<#cir.fp<3.300000e+00> : !cir.float, #cir.fp<4.400000e+00> : !cir.float> : !cir.complex<!cir.float>]> : !cir.array<!cir.complex<!cir.float> x 2>
+// CIR-DAG: cir.global "private"{{.*}}constant cir_private unnamed_addr @[[FUNC2_ARR:.*]] = #cir.const_array<[#cir.int<5> : !s32i], trailing_zeros> : !cir.array<!s32i x 2>
+// CIR-DAG: cir.global "private"{{.*}}constant cir_private unnamed_addr @[[FUNC3_ARR:.*]] = #cir.const_array<[#cir.int<5> : !s32i, #cir.int<6> : !s32i]> : !cir.array<!s32i x 2>
+// CIR-DAG: cir.global "private"{{.*}}constant cir_private unnamed_addr @[[FUNC4_ARR:.*]] = #cir.const_array<[#cir.const_array<[#cir.int<5> : !s32i]> : !cir.array<!s32i x 1>, #cir.const_array<[#cir.int<6> : !s32i]> : !cir.array<!s32i x 1>]> : !cir.array<!cir.array<!s32i x 1> x 2>
+// CIR-DAG: cir.global "private"{{.*}}constant cir_private unnamed_addr @[[FUNC5_ARR:.*]] = #cir.const_array<[#cir.const_array<[#cir.int<5> : !s32i]> : !cir.array<!s32i x 1>], trailing_zeros> : !cir.array<!cir.array<!s32i x 1> x 2>
+// CIR-DAG: cir.global "private"{{.*}}constant cir_private unnamed_addr @[[FUNC7_ARR:.*]] = #cir.zero : !cir.array<!cir.ptr<!s32i> x 1>
+// CIR-DAG: cir.global "private"{{.*}}constant cir_private unnamed_addr @[[COMPLEX_ARR:.*]] = #cir.const_array<[#cir.const_complex<#cir.fp<1.100000e+00> : !cir.float, #cir.fp<2.200000e+00> : !cir.float> : !cir.complex<!cir.float>, #cir.const_complex<#cir.fp<3.300000e+00> : !cir.float, #cir.fp<4.400000e+00> : !cir.float> : !cir.complex<!cir.float>]> : !cir.array<!cir.complex<!cir.float> x 2>
int a[10];
// CIR: cir.global external @a = #cir.zero : !cir.array<!s32i x 10>
diff --git a/clang/test/CIR/CodeGen/compound_literal.cpp b/clang/test/CIR/CodeGen/compound_literal.cpp
index be63359515b624..8e536354f12e56 100644
--- a/clang/test/CIR/CodeGen/compound_literal.cpp
+++ b/clang/test/CIR/CodeGen/compound_literal.cpp
@@ -10,8 +10,8 @@ int foo() {
return e;
}
-// CIR-DAG: cir.global "private" constant cir_private @[[FOO4_P:.*]] = #cir.const_record<{#cir.int<5> : !s32i, #cir.int<10> : !s32i}> : !rec_Point
-// LLVM-DAG: @[[FOO4_P:.*]] = private constant %struct.Point { i32 5, i32 10 }
+// CIR-DAG: cir.global "private" constant cir_private unnamed_addr @[[FOO4_P:.*]] = #cir.const_record<{#cir.int<5> : !s32i, #cir.int<10> : !s32i}> : !rec_Point
+// LLVM-DAG: @[[FOO4_P:.*]] = private unnamed_addr constant %struct.Point { i32 5, i32 10 }
// CIR: %[[RET:.*]] = cir.alloca "__retval" {{.*}} : !cir.ptr<!s32i>
// CIR: %[[INIT:.*]] = cir.alloca "e" {{.*}} init : !cir.ptr<!s32i>
diff --git a/clang/test/CIR/CodeGen/constexpr-ptr-offset.cpp b/clang/test/CIR/CodeGen/constexpr-ptr-offset.cpp
index 5c4f0f13ef7588..28e62675fcf623 100644
--- a/clang/test/CIR/CodeGen/constexpr-ptr-offset.cpp
+++ b/clang/test/CIR/CodeGen/constexpr-ptr-offset.cpp
@@ -18,9 +18,9 @@ void test() {
(void)v;
}
-// CIR: cir.global "private" constant cir_private @__const._Z4testv.v = #cir.const_record<{#cir.global_view<@"[[STR_NAME:.*]]", [2 : i32]> : !cir.ptr<!s8i>, #cir.int<3> : !s32i, #cir.zero : !cir.array<!u8i x 4>}> : !rec_View
-// CIR: cir.global "private" constant cir_private dso_local @"[[STR_NAME]]" = #cir.const_array<"hello" : !cir.array<!s8i x 5>, trailing_zeros> : !cir.array<!s8i x 6>
-// LLVMCIR: @__const._Z4testv.v = private constant %struct.View <{ ptr getelementptr inbounds nuw (i8, ptr @[[STR_NAME:.*]], i64 2), i32 3, [4 x i8] zeroinitializer }>
+// CIR: cir.global "private" constant cir_private unnamed_addr @__const._Z4testv.v = #cir.const_record<{#cir.global_view<@"[[STR_NAME:.*]]", [2 : i32]> : !cir.ptr<!s8i>, #cir.int<3> : !s32i, #cir.zero : !cir.array<!u8i x 4>}> : !rec_View
+// CIR: cir.global "private" constant cir_private dso_local unnamed_addr @"[[STR_NAME]]" = #cir.const_array<"hello" : !cir.array<!s8i x 5>, trailing_zeros> : !cir.array<!s8i x 6>
+// LLVMCIR: @__const._Z4testv.v = private unnamed_addr constant %struct.View <{ ptr getelementptr inbounds nuw (i8, ptr @[[STR_NAME:.*]], i64 2), i32 3, [4 x i8] zeroinitializer }>
// LLVMCIR: @[[STR_NAME]] = private {{.*}}constant [6 x i8] c"hello\00"
// OGCG: @[[STR_NAME:.*]] = private {{.*}}constant [6 x i8] c"hello\00"
diff --git a/clang/test/CIR/CodeGen/embed-expr.c b/clang/test/CIR/CodeGen/embed-expr.c
index f2b7119baa8818..4e50b3d7c624e8 100644
--- a/clang/test/CIR/CodeGen/embed-expr.c
+++ b/clang/test/CIR/CodeGen/embed-expr.c
@@ -13,7 +13,7 @@ void embed_expr_on_scalar_with_constants() {
};
}
-// CIR-DAG: cir.global "private" constant cir_private @[[EMBED_A:.*]] = #cir.const_array<[#cir.int<1> : !s32i, #cir.int<2> : !s32i, #cir.int<47> : !s32i]> : !cir.array<!s32i x 3>
+// CIR-DAG: cir.global "private" constant cir_private unnamed_addr @[[EMBED_A:.*]] = #cir.const_array<[#cir.int<1> : !s32i, #cir.int<2> : !s32i, #cir.int<47> : !s32i]> : !cir.array<!s32i x 3>
// CIR: %[[A_ADDR:.*]] = cir.alloca "a" {{.*}} init : !cir.ptr<!cir.array<!s32i x 3>>
// CIR: %[[ARRAY:.*]] = cir.get_global @[[EMBED_A]] : !cir.ptr<!cir.array<!s32i x 3>>
diff --git a/clang/test/CIR/CodeGen/global-const-alignment.cpp b/clang/test/CIR/CodeGen/global-const-alignment.cpp
index 06e9b6be8ccf9f..372cde00901ad1 100644
--- a/clang/test/CIR/CodeGen/global-const-alignment.cpp
+++ b/clang/test/CIR/CodeGen/global-const-alignment.cpp
@@ -6,9 +6,9 @@
// RUN: FileCheck --check-prefix=LLVM --input-file=%t.ll %s
void use(const int *);
-// CIR-DAG: cir.global "private" constant cir_private @[[CONST_ARR_16:.*]] = #cir.const_array<[#cir.int<1> : !s32i, #cir.int<2> : !s32i, #cir.int<3> : !s32i, #cir.int<4> : !s32i]> : !cir.array<!s32i x 4> align(16)
+// CIR-DAG: cir.global "private" constant cir_private unnamed_addr @[[CONST_ARR_16:.*]] = #cir.const_array<[#cir.int<1> : !s32i, #cir.int<2> : !s32i, #cir.int<3> : !s32i, #cir.int<4> : !s32i]> : !cir.array<!s32i x 4> align(16)
// LLVM-DAG: @[[CONST_ARR_16:.*]] = private {{.*}}constant [4 x i32] [i32 1, i32 2, i32 3, i32 4], align 16
-// CIR-DAG: cir.global "private" constant cir_private @[[CONST_ARR_32:.*]] = #cir.const_array<[#cir.int<1> : !s32i, #cir.int<2> : !s32i, #cir.int<3> : !s32i, #cir.int<4> : !s32i]> : !cir.array<!s32i x 4> align(32)
+// CIR-DAG: cir.global "private" constant cir_private unnamed_addr @[[CONST_ARR_32:.*]] = #cir.const_array<[#cir.int<1> : !s32i, #cir.int<2> : !s32i, #cir.int<3> : !s32i, #cir.int<4> : !s32i]> : !cir.array<!s32i x 4> align(32)
// LLVM-DAG: @[[CONST_ARR_32:.*]] = private {{.*}}constant [4 x i32] [i32 1, i32 2, i32 3, i32 4], align 32
void f(bool condition) {
diff --git a/clang/test/CIR/CodeGen/local-const-aggregate-name-clash.cpp b/clang/test/CIR/CodeGen/local-const-aggregate-name-clash.cpp
index 099af0c366b1ac..5db03377cdf52f 100644
--- a/clang/test/CIR/CodeGen/local-const-aggregate-name-clash.cpp
+++ b/clang/test/CIR/CodeGen/local-const-aggregate-name-clash.cpp
@@ -23,15 +23,15 @@ void f(bool which) {
}
}
-// CIR-DAG: cir.global "private" constant cir_private @[[GV0:.*]] = #cir.const_array<[#cir.int<10> : !s32i, #cir.int<20> : !s32i, #cir.int<30> : !s32i, #cir.int<40> : !s32i]> : !cir.array<!s32i x 4> align(16)
-// CIR-DAG: cir.global "private" constant cir_private @[[GV1:.*]] = #cir.const_array<[#cir.int<50> : !s32i, #cir.int<60> : !s32i]> : !cir.array<!s32i x 2> align(4)
+// CIR-DAG: cir.global "private" constant cir_private unnamed_addr @[[GV0:.*]] = #cir.const_array<[#cir.int<10> : !s32i, #cir.int<20> : !s32i, #cir.int<30> : !s32i, #cir.int<40> : !s32i]> : !cir.array<!s32i x 4> align(16)
+// CIR-DAG: cir.global "private" constant cir_private unnamed_addr @[[GV1:.*]] = #cir.const_array<[#cir.int<50> : !s32i, #cir.int<60> : !s32i]> : !cir.array<!s32i x 2> align(4)
// CIR: cir.func{{.*}} @_Z1fb
// CIR: cir.get_global @[[GV0]] : !cir.ptr<!cir.array<!s32i x 4>>
// CIR: cir.get_global @[[GV1]] : !cir.ptr<!cir.array<!s32i x 2>>
-// LLVM-DAG: @[[GV0:.*]] = private constant [4 x i32] [i32 10, i32 20, i32 30, i32 40], align 16
-// LLVM-DAG: @[[GV1:.*]] = private constant [2 x i32] [i32 50, i32 60], align 4
+// LLVM-DAG: @[[GV0:.*]] = private unnamed_addr constant [4 x i32] [i32 10, i32 20, i32 30, i32 40], align 16
+// LLVM-DAG: @[[GV1:.*]] = private unnamed_addr constant [2 x i32] [i32 50, i32 60], align 4
// LLVM: define{{.*}} @_Z1fb
// LLVM: call void @llvm.memcpy.p0.p0.i64(ptr {{[^,]+}}, ptr align 16 @[[GV0]], i64 16, i1 false)
diff --git a/clang/test/CIR/CodeGen/local-ptr-flat-offset.cpp b/clang/test/CIR/CodeGen/local-ptr-flat-offset.cpp
index 1d862375240173..1e532fe9f6dbbe 100644
--- a/clang/test/CIR/CodeGen/local-ptr-flat-offset.cpp
+++ b/clang/test/CIR/CodeGen/local-ptr-flat-offset.cpp
@@ -22,7 +22,7 @@ void test() {
use(it);
}
-// CIR: cir.global "private" constant cir_private @__const._Z4testv.it =
+// CIR: cir.global "private" constant cir_private unnamed_addr @__const._Z4testv.it =
// CIR-SAME: #cir.const_record<{#cir.global_offset<@gS, 4> : !cir.ptr<!rec_S>}>
// CIR-LABEL: cir.func {{.*}} @_Z4testv()
diff --git a/clang/test/CIR/CodeGen/loop.cpp b/clang/test/CIR/CodeGen/loop.cpp
index 15525220be67f8..e18d094df0dc1c 100644
--- a/clang/test/CIR/CodeGen/loop.cpp
+++ b/clang/test/CIR/CodeGen/loop.cpp
@@ -5,8 +5,8 @@
// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o %t.ll
// RUN: FileCheck --input-file=%t.ll %s --check-prefix=OGCG
-// CIR-DAG: cir.global "private" constant cir_private @[[L5_ARR:.*]] = #cir.const_array<[#cir.int<1> : !s32i, #cir.int<2> : !s32i, #cir.int<3> : !s32i, #cir.int<4> : !s32i]>
-// LLVM-DAG: @[[L5_ARR:.*]] = private constant [4 x i32] [i32 1, i32 2, i32 3, i32 4]
+// CIR-DAG: cir.global "private" constant cir_private unnamed_addr @[[L5_ARR:.*]] = #cir.const_array<[#cir.int<1> : !s32i, #cir.int<2> : !s32i, #cir.int<3> : !s32i, #cir.int<4> : !s32i]>
+// LLVM-DAG: @[[L5_ARR:.*]] = private unnamed_addr constant [4 x i32] [i32 1, i32 2, i32 3, i32 4]
void l0() {
for (;;) {
diff --git a/clang/test/CIR/CodeGen/no-odr-use.cpp b/clang/test/CIR/CodeGen/no-odr-use.cpp
index 3b37316588a8b4..bac0734110e0eb 100644
--- a/clang/test/CIR/CodeGen/no-odr-use.cpp
+++ b/clang/test/CIR/CodeGen/no-odr-use.cpp
@@ -11,20 +11,20 @@
// RUN: %clang_cc1 -std=c++2a -emit-llvm -o %t-cxx2a.ll -triple x86_64-linux-gnu %s
// RUN: FileCheck %s --input-file=%t-cxx2a.ll --check-prefixes=OGCG,OGCG-CXX2A
-// CIR-DAG: cir.global "private" constant cir_private @[[F_A:.*]] = #cir.const_record<{#cir.int<1> : !s32i, #cir.const_array<[#cir.int<2> : !s32i, #cir.int<3> : !s32i]> : !cir.array<!s32i x 2>, #cir.const_array<[#cir.int<4> : !s32i, #cir.int<5> : !s32i, #cir.int<6> : !s32i]> : !cir.array<!s32i x 3>}> : !rec_A
-// LLVM-DAG: @[[F_A:.*]] = private constant {{.*}} { i32 1, [2 x i32] [i32 2, i32 3], [3 x i32] [i32 4, i32 5, i32 6] }
+// CIR-DAG: cir.global "private" constant cir_private unnamed_addr @[[F_A:.*]] = #cir.const_record<{#cir.int<1> : !s32i, #cir.const_array<[#cir.int<2> : !s32i, #cir.int<3> : !s32i]> : !cir.array<!s32i x 2>, #cir.const_array<[#cir.int<4> : !s32i, #cir.int<5> : !s32i, #cir.int<6> : !s32i]> : !cir.array<!s32i x 3>}> : !rec_A
+// LLVM-DAG: @[[F_A:.*]] = private unnamed_addr constant {{.*}} { i32 1, [2 x i32] [i32 2, i32 3], [3 x i32] [i32 4, i32 5, i32 6] }
// OGCG-DAG: @__const._Z1fi.a = private unnamed_addr constant {{.*}} { i32 1, [2 x i32] [i32 2, i32 3], [3 x i32] [i32 4, i32 5, i32 6] }
-// CIR-CXX11-DAG: cir.global "private" constant cir_private @_ZN7PR422765State3dmsE.const = #cir.const_array<[#cir.int<0> : !s64i, #cir.int<0> : !s64i]> : !cir.array<!s64i x 2> align(16)
+// CIR-CXX11-DAG: cir.global "private" constant cir_private unnamed_addr @_ZN7PR422765State3dmsE.const = #cir.const_array<[#cir.int<0> : !s64i, #cir.int<0> : !s64i]> : !cir.array<!s64i x 2> align(16)
// LLVM-CXX11-DAG :@_ZN7PR422765State3dmsE.const = private constant [2 x i64] zeroinitializer, align 16
// OGCG-CXX11-DAG :@_ZN7PR422765State3dmsE.const = private constant [2 x i64] zeroinitializer, align 16
-// CIR-CXX20-DAG: cir.global "private" constant cir_private @_ZN7PR422765State3dmsE = #cir.const_array<[#cir.int<0> : !s64i, #cir.int<0> : !s64i]> : !cir.array<!s64i x 2> align(16)
+// CIR-CXX20-DAG: cir.global "private" constant cir_private unnamed_addr @_ZN7PR422765State3dmsE = #cir.const_array<[#cir.int<0> : !s64i, #cir.int<0> : !s64i]> : !cir.array<!s64i x 2> align(16)
// LLVM-CXX20-DAG :@_ZN7PR422765State3dmsE = private constant [2 x i64] zeroinitializer, align 16
// OGCG-CXX20-DAG :@_ZN7PR422765State3dmsE = private constant [2 x i64] zeroinitializer, align 16
-// CIR-CXX11-DAG: cir.global "private" constant cir_private @_ZN7PR422765State1mE.const = #cir.const_array<[#cir.const_record<{#cir.global_view<@_ZN7PR422765State2f1Ev> : !s64i, #cir.int<0> : !s64i}> : !rec_anon_struct, #cir.const_record<{#cir.global_view<@_ZN7PR422765State2f2Ev> : !s64i, #cir.int<0> : !s64i}> : !rec_anon_struct]> : !cir.array<!rec_anon_struct x 2>
-// LLVM-CXX11-DAG: @_ZN7PR422765State1mE.const = private constant [2 x { i64, i64 }] [{ {{.*}} @_ZN7PR422765State2f1Ev {{.*}}, i64 0 }, { {{.*}} @_ZN7PR422765State2f2Ev {{.*}}, i64 0 }]
+// CIR-CXX11-DAG: cir.global "private" constant cir_private unnamed_addr @_ZN7PR422765State1mE.const = #cir.const_array<[#cir.const_record<{#cir.global_view<@_ZN7PR422765State2f1Ev> : !s64i, #cir.int<0> : !s64i}> : !rec_anon_struct, #cir.const_record<{#cir.global_view<@_ZN7PR422765State2f2Ev> : !s64i, #cir.int<0> : !s64i}> : !rec_anon_struct]> : !cir.array<!rec_anon_struct x 2>
+// LLVM-CXX11-DAG: @_ZN7PR422765State1mE.const = private unnamed_addr constant [2 x { i64, i64 }] [{ {{.*}} @_ZN7PR422765State2f1Ev {{.*}}, i64 0 }, { {{.*}} @_ZN7PR422765State2f2Ev {{.*}}, i64 0 }]
// OGCG-CXX11-DAG: @_ZN7PR422765State1mE.const = private unnamed_addr constant [2 x { i64, i64 }] [{ {{.*}} @_ZN7PR422765State2f1Ev {{.*}}, i64 0 }, { {{.*}} @_ZN7PR422765State2f2Ev {{.*}}, i64 0 }]
// CIR-CXX2A-DAG: cir.global constant linkonce_odr comdat @_ZN7PR422765State1mE = #cir.const_array<[#cir.const_record<{#cir.global_view<@_ZN7PR422765State2f1Ev> : !s64i, #cir.int<0> : !s64i}> : !rec_anon_struct, #cir.const_record<{#cir.global_view<@_ZN7PR422765State2f2Ev> : !s64i, #cir.int<0> : !s64i}> : !rec_anon_struct]> : !cir.array<!rec_anon_struct x 2>
diff --git a/clang/test/CIR/CodeGen/nonzeroinit-struct.cpp b/clang/test/CIR/CodeGen/nonzeroinit-struct.cpp
index 0a6cd07b518f33..858ea83f8c8c66 100644
--- a/clang/test/CIR/CodeGen/nonzeroinit-struct.cpp
+++ b/clang/test/CIR/CodeGen/nonzeroinit-struct.cpp
@@ -32,8 +32,8 @@ struct Trivial {
// LLVM-DAG: %struct.WithMemPtr = type { i32, double, { i64, i64 } }
// LLVM-DAG: %struct.Trivial = type { i32, double, i64 }
-// CIR-AFTER-DAG: cir.global "private" constant cir_private @__const.local.localT_init = #cir.const_record<{#cir.int<1> : !s32i, #cir.fp<2.200000e+00> : !cir.double, #cir.int<0> : !s64i}> : !rec_Trivial
-// CIR-AFTER-DAG: cir.global "private" constant cir_private @__const.local.localMpt_init = #cir.const_record<{#cir.int<1> : !s32i, #cir.fp<2.000000e+00> : !cir.double, #cir.const_record<{#cir.global_view<@_ZN5Other4funcEif> : !s64i, #cir.int<0> : !s64i}> : !rec_anon_struct}> : !rec_WithMemPtr
+// CIR-AFTER-DAG: cir.global "private" constant cir_private unnamed_addr @__const.local.localT_init = #cir.const_record<{#cir.int<1> : !s32i, #cir.fp<2.200000e+00> : !cir.double, #cir.int<0> : !s64i}> : !rec_Trivial
+// CIR-AFTER-DAG: cir.global "private" constant cir_private unnamed_addr @__const.local.localMpt_init = #cir.const_record<{#cir.int<1> : !s32i, #cir.fp<2.000000e+00> : !cir.double, #cir.const_record<{#cir.global_view<@_ZN5Other4funcEif> : !s64i, #cir.int<0> : !s64i}> : !rec_anon_struct}> : !rec_WithMemPtr
// LLVM-DAG: @__const.local.localMpt_init = private {{.*}}constant %struct.WithMemPtr { i32 1, double 2.000000e+00, { i64, i64 } { i64 ptrtoint (ptr @_ZN5Other4funcEif to i64), i64 0 } }
// LLVM-DAG: @__const.local.localT_init = private {{.*}}constant %struct.Trivial { i32 1, double 2.200000e+00, i64 0 }
diff --git a/clang/test/CIR/CodeGen/paren-init-list.cpp b/clang/test/CIR/CodeGen/paren-init-list.cpp
index 6689d80e6a144b..8dbb844cd44a01 100644
--- a/clang/test/CIR/CodeGen/paren-init-list.cpp
+++ b/clang/test/CIR/CodeGen/paren-init-list.cpp
@@ -12,8 +12,8 @@ struct CompleteS {
void cxx_paren_list_init_expr() { CompleteS a(1, 'a'); }
-// CIR-DAG: cir.global "private" constant cir_private @[[PAREN_A:.*]] = #cir.const_record<{#cir.int<1> : !s32i, #cir.int<97> : !s8i}> : !rec_CompleteS
-// LLVM-DAG: @[[PAREN_A:.*]] = private constant %struct.CompleteS { i32 1, i8 97 }
+// CIR-DAG: cir.global "private" constant cir_private unnamed_addr @[[PAREN_A:.*]] = #cir.const_record<{#cir.int<1> : !s32i, #cir.int<97> : !s8i}> : !rec_CompleteS
+// LLVM-DAG: @[[PAREN_A:.*]] = private unnamed_addr constant %struct.CompleteS { i32 1, i8 97 }
// CIR: %[[A_ADDR:.*]] = cir.alloca "a" {{.*}} init : !cir.ptr<!rec_CompleteS>
// CIR: %[[CONST:.*]] = cir.get_global @[[PAREN_A]] : !cir.ptr<!rec_CompleteS>
diff --git a/clang/test/CIR/CodeGen/pointer-to-member-func.cpp b/clang/test/CIR/CodeGen/pointer-to-member-func.cpp
index 188cdfa0b64049..fd2a4b764358ed 100644
--- a/clang/test/CIR/CodeGen/pointer-to-member-func.cpp
+++ b/clang/test/CIR/CodeGen/pointer-to-member-func.cpp
@@ -27,16 +27,16 @@ struct Foo {
void (Foo::*m1_ptr)(int) = &Foo::m1;
// CIR-BEFORE: cir.global external @m1_ptr = #cir.method<@_ZN3Foo2m1Ei> : !cir.method<!cir.func<(!cir.ptr<!rec_Foo>, !s32i)> in !rec_Foo>
-// CIR-AFTER-DAG: cir.global "private" constant cir_private @[[NONVIRT_RET:.*]] = #cir.const_record<{#cir.global_view<@_ZN3Foo2m1Ei> : !s64i, #cir.int<0> : !s64i}> : !rec_anon_struct
-// CIR-AFTER-X86-DAG: cir.global "private" constant cir_private @[[VIRT_RET:.*]] = #cir.const_record<{#cir.int<9> : !s64i, #cir.int<0> : !s64i}> : !rec_anon_struct
-// CIR-AFTER-ARM-DAG: cir.global "private" constant cir_private @[[VIRT_RET:.*]] = #cir.const_record<{#cir.int<8> : !s64i, #cir.int<1> : !s64i}> : !rec_anon_struct
-// CIR-AFTER-DAG: cir.global "private" constant cir_private @[[NULL_RET:.*]] = #cir.const_record<{#cir.int<0> : !s64i, #cir.int<0> : !s64i}> : !rec_anon_struct
+// CIR-AFTER-DAG: cir.global "private" constant cir_private unnamed_addr @[[NONVIRT_RET:.*]] = #cir.const_record<{#cir.global_view<@_ZN3Foo2m1Ei> : !s64i, #cir.int<0> : !s64i}> : !rec_anon_struct
+// CIR-AFTER-X86-DAG: cir.global "private" constant cir_private unnamed_addr @[[VIRT_RET:.*]] = #cir.const_record<{#cir.int<9> : !s64i, #cir.int<0> : !s64i}> : !rec_anon_struct
+// CIR-AFTER-ARM-DAG: cir.global "private" constant cir_private unnamed_addr @[[VIRT_RET:.*]] = #cir.const_record<{#cir.int<8> : !s64i, #cir.int<1> : !s64i}> : !rec_anon_struct
+// CIR-AFTER-DAG: cir.global "private" constant cir_private unnamed_addr @[[NULL_RET:.*]] = #cir.const_record<{#cir.int<0> : !s64i, #cir.int<0> : !s64i}> : !rec_anon_struct
// CIR-AFTER: cir.global external @m1_ptr = #cir.const_record<{#cir.global_view<@_ZN3Foo2m1Ei> : !s64i, #cir.int<0> : !s64i}> : !rec_anon_struct
// LLVM-DAG: @m1_ptr = global { i64, i64 } { i64 ptrtoint (ptr @_ZN3Foo2m1Ei to i64), i64 0 }
-// LLVM-DAG: @[[NONVIRT_RET:.*]] = private constant { i64, i64 } { i64 ptrtoint (ptr @_ZN3Foo2m1Ei to i64), i64 0 }
-// LLVM-X86-DAG: @[[VIRT_RET:.*]] = private constant { i64, i64 } { i64 9, i64 0 }
-// LLVM-ARM-DAG: @[[VIRT_RET:.*]] = private constant { i64, i64 } { i64 8, i64 1 }
-// LLVM-DAG: @[[NULL_RET:.*]] = private constant { i64, i64 } zeroinitializer
+// LLVM-DAG: @[[NONVIRT_RET:.*]] = private unnamed_addr constant { i64, i64 } { i64 ptrtoint (ptr @_ZN3Foo2m1Ei to i64), i64 0 }
+// LLVM-X86-DAG: @[[VIRT_RET:.*]] = private unnamed_addr constant { i64, i64 } { i64 9, i64 0 }
+// LLVM-ARM-DAG: @[[VIRT_RET:.*]] = private unnamed_addr constant { i64, i64 } { i64 8, i64 1 }
+// LLVM-DAG: @[[NULL_RET:.*]] = private unnamed_addr constant { i64, i64 } zeroinitializer
// OGCG: @m1_ptr = global { i64, i64 } { i64 ptrtoint (ptr @_ZN3Foo2m1Ei to i64), i64 0 }
// Global pointer to virtual method
diff --git a/clang/test/CIR/CodeGen/predefined-expr.c b/clang/test/CIR/CodeGen/predefined-expr.c
index a07591f78aa823..02e32a8beeacec 100644
--- a/clang/test/CIR/CodeGen/predefined-expr.c
+++ b/clang/test/CIR/CodeGen/predefined-expr.c
@@ -6,30 +6,30 @@
// RUN: FileCheck %s --input-file=%t.ll --check-prefix=OGCG
// CIR: cir.global "private" internal dso_local @staticFuncName.name = #cir.global_view<@".str.4"> : !cir.ptr<!s8i> align(8) loc(#loc1)
-// CIR: cir.global "private" constant cir_private dso_local @".str" = #cir.zero : !cir.array<!s8i x 1>
+// CIR: cir.global "private" constant cir_private dso_local unnamed_addr @".str" = #cir.zero : !cir.array<!s8i x 1>
// CIR: cir.global external @func = #cir.global_view<@".str"> : !cir.ptr<!s8i>
-// CIR: cir.global "private" constant cir_private dso_local @__func__.plainFunction = #cir.const_array<"plainFunction" : !cir.array<!s8i x 13>, trailing_zeros>
-// CIR: cir.global "private" constant cir_private dso_local @__PRETTY_FUNCTION__.plainFunction = #cir.const_array<"void plainFunction(void)" : !cir.array<!s8i x 24>, trailing_zeros>
-// CIR: cir.global "private" constant cir_private dso_local @__func__.externFunction = #cir.const_array<"externFunction" : !cir.array<!s8i x 14>, trailing_zeros>
-// CIR: cir.global "private" constant cir_private dso_local @__PRETTY_FUNCTION__.externFunction = #cir.const_array<"void externFunction(void)" : !cir.array<!s8i x 25>, trailing_zeros>
-// CIR: cir.global "private" constant cir_private dso_local @__func__.privateExternFunction = #cir.const_array<"privateExternFunction" : !cir.array<!s8i x 21>, trailing_zeros>
-// CIR: cir.global "private" constant cir_private dso_local @__PRETTY_FUNCTION__.privateExternFunction = #cir.const_array<"void privateExternFunction(void)" : !cir.array<!s8i x 32>, trailing_zeros>
-// CIR: cir.global "private" constant cir_private dso_local @".str.4" = #cir.const_array<"staticFuncName" : !cir.array<!s8i x 14>, trailing_zeros> : !cir.array<!s8i x 15>
-// CIR: cir.global "private" constant cir_private dso_local @__func__.staticFunction = #cir.const_array<"staticFunction" : !cir.array<!s8i x 14>, trailing_zeros>
-// CIR: cir.global "private" constant cir_private dso_local @__PRETTY_FUNCTION__.staticFunction = #cir.const_array<"void staticFunction(void)" : !cir.array<!s8i x 25>, trailing_zeros>
+// CIR: cir.global "private" constant cir_private dso_local unnamed_addr @__func__.plainFunction = #cir.const_array<"plainFunction" : !cir.array<!s8i x 13>, trailing_zeros>
+// CIR: cir.global "private" constant cir_private dso_local unnamed_addr @__PRETTY_FUNCTION__.plainFunction = #cir.const_array<"void plainFunction(void)" : !cir.array<!s8i x 24>, trailing_zeros>
+// CIR: cir.global "private" constant cir_private dso_local unnamed_addr @__func__.externFunction = #cir.const_array<"externFunction" : !cir.array<!s8i x 14>, trailing_zeros>
+// CIR: cir.global "private" constant cir_private dso_local unnamed_addr @__PRETTY_FUNCTION__.externFunction = #cir.const_array<"void externFunction(void)" : !cir.array<!s8i x 25>, trailing_zeros>
+// CIR: cir.global "private" constant cir_private dso_local unnamed_addr @__func__.privateExternFunction = #cir.const_array<"privateExternFunction" : !cir.array<!s8i x 21>, trailing_zeros>
+// CIR: cir.global "private" constant cir_private dso_local unnamed_addr @__PRETTY_FUNCTION__.privateExternFunction = #cir.const_array<"void privateExternFunction(void)" : !cir.array<!s8i x 32>, trailing_zeros>
+// CIR: cir.global "private" constant cir_private dso_local unnamed_addr @".str.4" = #cir.const_array<"staticFuncName" : !cir.array<!s8i x 14>, trailing_zeros> : !cir.array<!s8i x 15>
+// CIR: cir.global "private" constant cir_private dso_local unnamed_addr @__func__.staticFunction = #cir.const_array<"staticFunction" : !cir.array<!s8i x 14>, trailing_zeros>
+// CIR: cir.global "private" constant cir_private dso_local unnamed_addr @__PRETTY_FUNCTION__.staticFunction = #cir.const_array<"void staticFunction(void)" : !cir.array<!s8i x 25>, trailing_zeros>
// TODO(cir): These should be unnamed_addr
// LLVM: @staticFuncName.name = internal global ptr @.str.4, align 8
-// LLVM: @.str = private constant [1 x i8] zeroinitializer, align 1
+// LLVM: @.str = private unnamed_addr constant [1 x i8] zeroinitializer, align 1
// LLVM: @func = global ptr @.str, align 8
-// LLVM: @__func__.plainFunction = private constant [14 x i8] c"plainFunction\00"
-// LLVM: @__PRETTY_FUNCTION__.plainFunction = private constant [25 x i8] c"void plainFunction(void)\00"
-// LLVM: @__func__.externFunction = private constant [15 x i8] c"externFunction\00"
-// LLVM: @__PRETTY_FUNCTION__.externFunction = private constant [26 x i8] c"void externFunction(void)\00"
-// LLVM: @__func__.privateExternFunction = private constant [22 x i8] c"privateExternFunction\00"
-// LLVM: @__PRETTY_FUNCTION__.privateExternFunction = private constant [33 x i8] c"void privateExternFunction(void)\00"
-// LLVM: @__func__.staticFunction = private constant [15 x i8] c"staticFunction\00"
-// LLVM: @__PRETTY_FUNCTION__.staticFunction = private constant [26 x i8] c"void staticFunction(void)\00"
+// LLVM: @__func__.plainFunction = private unnamed_addr constant [14 x i8] c"plainFunction\00"
+// LLVM: @__PRETTY_FUNCTION__.plainFunction = private unnamed_addr constant [25 x i8] c"void plainFunction(void)\00"
+// LLVM: @__func__.externFunction = private unnamed_addr constant [15 x i8] c"externFunction\00"
+// LLVM: @__PRETTY_FUNCTION__.externFunction = private unnamed_addr constant [26 x i8] c"void externFunction(void)\00"
+// LLVM: @__func__.privateExternFunction = private unnamed_addr constant [22 x i8] c"privateExternFunction\00"
+// LLVM: @__PRETTY_FUNCTION__.privateExternFunction = private unnamed_addr constant [33 x i8] c"void privateExternFunction(void)\00"
+// LLVM: @__func__.staticFunction = private unnamed_addr constant [15 x i8] c"staticFunction\00"
+// LLVM: @__PRETTY_FUNCTION__.staticFunction = private unnamed_addr constant [26 x i8] c"void staticFunction(void)\00"
// OGCG: @.str = private unnamed_addr constant [1 x i8] zeroinitializer, align 1
// OGCG: @func = global ptr @.str, align 8
diff --git a/clang/test/CIR/CodeGen/source-loc.cpp b/clang/test/CIR/CodeGen/source-loc.cpp
index b01965c65e79f3..deb84f1667a5ba 100644
--- a/clang/test/CIR/CodeGen/source-loc.cpp
+++ b/clang/test/CIR/CodeGen/source-loc.cpp
@@ -25,28 +25,28 @@ namespace std {
};
}
-// CIR: cir.global "private" constant cir_private dso_local @".str" = #cir.const_array<
-// LLVM: @.str = private constant
+// CIR: cir.global "private" constant cir_private dso_local unnamed_addr @".str" = #cir.const_array<
+// LLVM: @.str = private unnamed_addr constant
// OGCG: @.str = private unnamed_addr constant
//
-// CIR: cir.global "private" constant cir_private dso_local @".str.1" = #cir.const_array<"void use1()" : !cir.array<!s8i x 11>, trailing_zeros> : !cir.array<!s8i x 12>
-// LLVM: @.str.1 = private constant [{{.*}} x i8] c"void use1
+// CIR: cir.global "private" constant cir_private dso_local unnamed_addr @".str.1" = #cir.const_array<"void use1()" : !cir.array<!s8i x 11>, trailing_zeros> : !cir.array<!s8i x 12>
+// LLVM: @.str.1 = private unnamed_addr constant [{{.*}} x i8] c"void use1
// OGCG: @.str.1 = private unnamed_addr constant [{{.*}} x i8] c"void use1
//
-// CIR: cir.global "private" constant cir_private @".constant" = #cir.const_record<{#cir.global_view<@".str"> : !cir.ptr<!s8i>, #cir.global_view<@".str.1"> : !cir.ptr<!s8i>, #cir.int<{{.*}}> : !u32i, #cir.int<{{.*}}> : !u32i}> : !rec_std3A3Asource_location3A3A__impl
-// LLVM: @.constant = private constant %"struct.std::source_location::__impl" { ptr @.str, ptr @.str.1, i32 {{.*}}, i32 {{.*}} }
+// CIR: cir.global "private" constant cir_private unnamed_addr @".constant" = #cir.const_record<{#cir.global_view<@".str"> : !cir.ptr<!s8i>, #cir.global_view<@".str.1"> : !cir.ptr<!s8i>, #cir.int<{{.*}}> : !u32i, #cir.int<{{.*}}> : !u32i}> : !rec_std3A3Asource_location3A3A__impl
+// LLVM: @.constant = private unnamed_addr constant %"struct.std::source_location::__impl" { ptr @.str, ptr @.str.1, i32 {{.*}}, i32 {{.*}} }
// OGCG: @.constant = private unnamed_addr constant %"struct.std::source_location::__impl" { ptr @.str, ptr @.str.1, i32 {{.*}}, i32 {{.*}} }
//
-// CIR: cir.global "private" constant cir_private dso_local @".str.2" = #cir.const_array<"void use2()" : !cir.array<!s8i x 11>, trailing_zeros> : !cir.array<!s8i x 12> align(1) loc(#loc1)
-// LLVM: @.str.2 = private constant [{{.*}} x i8] c"void use2
+// CIR: cir.global "private" constant cir_private dso_local unnamed_addr @".str.2" = #cir.const_array<"void use2()" : !cir.array<!s8i x 11>, trailing_zeros> : !cir.array<!s8i x 12> align(1) loc(#loc1)
+// LLVM: @.str.2 = private unnamed_addr constant [{{.*}} x i8] c"void use2
// OGCG: @.str.2 = private unnamed_addr constant [{{.*}} x i8] c"void use2
//
// Note: the naming difference between LLVM and OGCG here is because of the
// uniquification differences when we encounter duplicate names. LLVM has a
// global counter that manages these, CIR just increments the single names, each
// with its own counter. As a result, .str and .constant names don't match.
-// CIR: cir.global "private" constant cir_private @".constant.1" = #cir.const_record<{#cir.global_view<@".str"> : !cir.ptr<!s8i>, #cir.global_view<@".str.2"> : !cir.ptr<!s8i>, #cir.int<{{.*}}> : !u32i, #cir.int<{{.*}}> : !u32i}> : !rec_std3A3Asource_location3A3A__impl
-// LLVM: @.constant.1 = private constant %"struct.std::source_location::__impl" { ptr @.str, ptr @.str.2, i32 {{.*}}, i32 {{.*}} }
+// CIR: cir.global "private" constant cir_private unnamed_addr @".constant.1" = #cir.const_record<{#cir.global_view<@".str"> : !cir.ptr<!s8i>, #cir.global_view<@".str.2"> : !cir.ptr<!s8i>, #cir.int<{{.*}}> : !u32i, #cir.int<{{.*}}> : !u32i}> : !rec_std3A3Asource_location3A3A__impl
+// LLVM: @.constant.1 = private unnamed_addr constant %"struct.std::source_location::__impl" { ptr @.str, ptr @.str.2, i32 {{.*}}, i32 {{.*}} }
// OGCG: @.constant.3 = private unnamed_addr constant %"struct.std::source_location::__impl" { ptr @.str, ptr @.str.2, i32 {{.*}}, i32 {{.*}} }
diff --git a/clang/test/CIR/CodeGen/statement-exprs.c b/clang/test/CIR/CodeGen/statement-exprs.c
index 947291d8136526..26aef8e296dd10 100644
--- a/clang/test/CIR/CodeGen/statement-exprs.c
+++ b/clang/test/CIR/CodeGen/statement-exprs.c
@@ -9,8 +9,8 @@ int f19(void) {
return ({ 3;;4; });
}
-// CIR-DAG: cir.global "private" constant cir_private @[[TEST3_S:.*]] = #cir.const_record<{#cir.int<1> : !s32i}> : !rec_S
-// LLVM-DAG: @[[TEST3_S:.*]] = private constant %struct.S { i32 1 }
+// CIR-DAG: cir.global "private" constant cir_private unnamed_addr @[[TEST3_S:.*]] = #cir.const_record<{#cir.int<1> : !s32i}> : !rec_S
+// LLVM-DAG: @[[TEST3_S:.*]] = private unnamed_addr constant %struct.S { i32 1 }
// CIR: cir.func {{.*}} @f19() -> !s32i
// CIR: %[[RETVAL:.+]] = cir.alloca "__retval" {{.*}} : !cir.ptr<!s32i>
diff --git a/clang/test/CIR/CodeGen/string-literals.c b/clang/test/CIR/CodeGen/string-literals.c
index 2b4a34153a5b63..2ea8636906de4c 100644
--- a/clang/test/CIR/CodeGen/string-literals.c
+++ b/clang/test/CIR/CodeGen/string-literals.c
@@ -17,13 +17,13 @@ char g_exact[4] = "123";
// CIR: cir.global external @g_exact = #cir.const_array<"123" : !cir.array<!s8i x 3>, trailing_zeros> : !cir.array<!s8i x 4>
-// CIR: cir.global "private" constant cir_private dso_local @[[STR1_GLOBAL:.*]] = #cir.const_array<"1" : !cir.array<!s8i x 1>, trailing_zeros> : !cir.array<!s8i x 2>
-// CIR: cir.global "private" constant cir_private dso_local @[[STR2_GLOBAL:.*]] = #cir.zero : !cir.array<!s8i x 1>
-// CIR: cir.global "private" constant cir_private dso_local @[[STR3_GLOBAL:.*]] = #cir.zero : !cir.array<!s8i x 2>
+// CIR: cir.global "private" constant cir_private dso_local unnamed_addr @[[STR1_GLOBAL:.*]] = #cir.const_array<"1" : !cir.array<!s8i x 1>, trailing_zeros> : !cir.array<!s8i x 2>
+// CIR: cir.global "private" constant cir_private dso_local unnamed_addr @[[STR2_GLOBAL:.*]] = #cir.zero : !cir.array<!s8i x 1>
+// CIR: cir.global "private" constant cir_private dso_local unnamed_addr @[[STR3_GLOBAL:.*]] = #cir.zero : !cir.array<!s8i x 2>
-// LLVM: @[[STR1_GLOBAL:.*]] = private constant [2 x i8] c"1\00"
-// LLVM: @[[STR2_GLOBAL:.*]] = private constant [1 x i8] zeroinitializer
-// LLVM: @[[STR3_GLOBAL:.*]] = private constant [2 x i8] zeroinitializer
+// LLVM: @[[STR1_GLOBAL:.*]] = private unnamed_addr constant [2 x i8] c"1\00"
+// LLVM: @[[STR2_GLOBAL:.*]] = private unnamed_addr constant [1 x i8] zeroinitializer
+// LLVM: @[[STR3_GLOBAL:.*]] = private unnamed_addr constant [2 x i8] zeroinitializer
// OGCG: @[[STR1_GLOBAL:.*]] = private unnamed_addr constant [2 x i8] c"1\00"
// OGCG: @[[STR2_GLOBAL:.*]] = private unnamed_addr constant [1 x i8] zeroinitializer
diff --git a/clang/test/CIR/CodeGen/string-literals.cpp b/clang/test/CIR/CodeGen/string-literals.cpp
index 9bb14827f0565b..76d721eb40e572 100644
--- a/clang/test/CIR/CodeGen/string-literals.cpp
+++ b/clang/test/CIR/CodeGen/string-literals.cpp
@@ -21,18 +21,18 @@ char const *array[] {
};
-// CIR: cir.global "private" constant cir_private dso_local @"[[STR:.+]]" = #cir.const_array<"my" : !cir.array<!s8i x 2>, trailing_zeros> : !cir.array<!s8i x 3>
-// CIR: cir.global "private" constant cir_private dso_local @"[[STR1:.+]]" = #cir.const_array<"hands" : !cir.array<!s8i x 5>, trailing_zeros> : !cir.array<!s8i x 6>
-// CIR: cir.global "private" constant cir_private dso_local @"[[STR2:.+]]" = #cir.const_array<"are" : !cir.array<!s8i x 3>, trailing_zeros> : !cir.array<!s8i x 4>
-// CIR: cir.global "private" constant cir_private dso_local @"[[STR3:.+]]" = #cir.const_array<"typing" : !cir.array<!s8i x 6>, trailing_zeros> : !cir.array<!s8i x 7>
-// CIR: cir.global "private" constant cir_private dso_local @"[[STR4:.+]]" = #cir.const_array<"words" : !cir.array<!s8i x 5>, trailing_zeros> : !cir.array<!s8i x 6>
+// CIR: cir.global "private" constant cir_private dso_local unnamed_addr @"[[STR:.+]]" = #cir.const_array<"my" : !cir.array<!s8i x 2>, trailing_zeros> : !cir.array<!s8i x 3>
+// CIR: cir.global "private" constant cir_private dso_local unnamed_addr @"[[STR1:.+]]" = #cir.const_array<"hands" : !cir.array<!s8i x 5>, trailing_zeros> : !cir.array<!s8i x 6>
+// CIR: cir.global "private" constant cir_private dso_local unnamed_addr @"[[STR2:.+]]" = #cir.const_array<"are" : !cir.array<!s8i x 3>, trailing_zeros> : !cir.array<!s8i x 4>
+// CIR: cir.global "private" constant cir_private dso_local unnamed_addr @"[[STR3:.+]]" = #cir.const_array<"typing" : !cir.array<!s8i x 6>, trailing_zeros> : !cir.array<!s8i x 7>
+// CIR: cir.global "private" constant cir_private dso_local unnamed_addr @"[[STR4:.+]]" = #cir.const_array<"words" : !cir.array<!s8i x 5>, trailing_zeros> : !cir.array<!s8i x 6>
// CIR: cir.global external @array = #cir.const_array<[#cir.global_view<@"[[STR]]"> : !cir.ptr<!s8i>, #cir.global_view<@"[[STR1]]"> : !cir.ptr<!s8i>, #cir.global_view<@"[[STR2]]"> : !cir.ptr<!s8i>, #cir.global_view<@"[[STR3]]"> : !cir.ptr<!s8i>, #cir.global_view<@"[[STR4]]"> : !cir.ptr<!s8i>]> : !cir.array<!cir.ptr<!s8i> x 5>
-// LLVM: @[[STR:.+]] = private constant [3 x i8] c"my\00"
-// LLVM: @[[STR1:.+]] = private constant [6 x i8] c"hands\00"
-// LLVM: @[[STR2:.+]] = private constant [4 x i8] c"are\00"
-// LLVM: @[[STR3:.+]] = private constant [7 x i8] c"typing\00"
-// LLVM: @[[STR4:.+]] = private constant [6 x i8] c"words\00"
+// LLVM: @[[STR:.+]] = private unnamed_addr constant [3 x i8] c"my\00"
+// LLVM: @[[STR1:.+]] = private unnamed_addr constant [6 x i8] c"hands\00"
+// LLVM: @[[STR2:.+]] = private unnamed_addr constant [4 x i8] c"are\00"
+// LLVM: @[[STR3:.+]] = private unnamed_addr constant [7 x i8] c"typing\00"
+// LLVM: @[[STR4:.+]] = private unnamed_addr constant [6 x i8] c"words\00"
// LLVM: @array = global [5 x ptr] [ptr @[[STR]], ptr @[[STR1]], ptr @[[STR2]], ptr @[[STR3]], ptr @[[STR4]]]
// OGCG: @[[STR:.+]] = private unnamed_addr constant [3 x i8] c"my\00"
@@ -47,9 +47,9 @@ wchar_t zeroPadding[20] = L"hi";
// LLVM: @zeroPadding = global <{ i32, i32, [18 x i32] }> <{ i32 104, i32 105, [18 x i32] zeroinitializer }>
// OGCG: @zeroPadding = global [20 x i32] [i32 104, i32 105, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0]
-// CIR: cir.global "private" constant cir_private dso_local @[[STR5_GLOBAL:.*]] = #cir.const_array<"abcd" : !cir.array<!s8i x 4>, trailing_zeros> : !cir.array<!s8i x 5>
+// CIR: cir.global "private" constant cir_private dso_local unnamed_addr @[[STR5_GLOBAL:.*]] = #cir.const_array<"abcd" : !cir.array<!s8i x 4>, trailing_zeros> : !cir.array<!s8i x 5>
-// LLVM: @[[STR5_GLOBAL:.*]] = private constant [5 x i8] c"abcd\00"
+// LLVM: @[[STR5_GLOBAL:.*]] = private unnamed_addr constant [5 x i8] c"abcd\00"
// OGCG: @[[STR5_GLOBAL:.*]] = private unnamed_addr constant [5 x i8] c"abcd\00"
diff --git a/clang/test/CIR/CodeGen/struct-init.cpp b/clang/test/CIR/CodeGen/struct-init.cpp
index d602b928a77346..af0700b230a6a9 100644
--- a/clang/test/CIR/CodeGen/struct-init.cpp
+++ b/clang/test/CIR/CodeGen/struct-init.cpp
@@ -5,8 +5,8 @@
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o %t.ll
// RUN: FileCheck --check-prefix=OGCG --input-file=%t.ll %s
-// CIR-DAG: cir.global "private"{{.*}}constant cir_private @[[INIT_S1:.*]] = #cir.const_record<{#cir.int<1> : !s32i, #cir.int<2> : !s32i, #cir.int<3> : !s32i}> : !rec_S
-// CIR-DAG: cir.global "private"{{.*}}constant cir_private @[[INIT_S2:.*]] = #cir.const_record<{#cir.int<4> : !s32i, #cir.int<5> : !s32i, #cir.int<0> : !s32i}> : !rec_S
+// CIR-DAG: cir.global "private"{{.*}}constant cir_private unnamed_addr @[[INIT_S1:.*]] = #cir.const_record<{#cir.int<1> : !s32i, #cir.int<2> : !s32i, #cir.int<3> : !s32i}> : !rec_S
+// CIR-DAG: cir.global "private"{{.*}}constant cir_private unnamed_addr @[[INIT_S2:.*]] = #cir.const_record<{#cir.int<4> : !s32i, #cir.int<5> : !s32i, #cir.int<0> : !s32i}> : !rec_S
struct BitfieldStruct {
unsigned int a:4;
diff --git a/clang/test/CIR/CodeGen/struct.cpp b/clang/test/CIR/CodeGen/struct.cpp
index 0ab59692d6c2e8..e85b014b64d713 100644
--- a/clang/test/CIR/CodeGen/struct.cpp
+++ b/clang/test/CIR/CodeGen/struct.cpp
@@ -8,16 +8,16 @@
struct IncompleteS;
IncompleteS *p;
-// CIR-DAG: cir.global "private" constant cir_private @[[PAREN_A:.*]] = #cir.zero : !rec_Point
-// CIR-DAG: cir.global "private" constant cir_private @__const.{{.*}} = #cir.zero : !rec_CompleteS
-// CIR-DAG: cir.global "private" constant cir_private @__const.{{.*}} = #cir.zero : !rec_CompleteS
-// CIR-DAG: cir.global "private" constant cir_private @__const.{{.*}} = #cir.zero : !rec_CompleteS
+// CIR-DAG: cir.global "private" constant cir_private unnamed_addr @[[PAREN_A:.*]] = #cir.zero : !rec_Point
+// CIR-DAG: cir.global "private" constant cir_private unnamed_addr @__const.{{.*}} = #cir.zero : !rec_CompleteS
+// CIR-DAG: cir.global "private" constant cir_private unnamed_addr @__const.{{.*}} = #cir.zero : !rec_CompleteS
+// CIR-DAG: cir.global "private" constant cir_private unnamed_addr @__const.{{.*}} = #cir.zero : !rec_CompleteS
// CIR-DAG: cir.global external @p = #cir.ptr<null> : !cir.ptr<!rec_IncompleteS>
-// LLVM-DAG: @[[PAREN_A:.*]] = private constant %struct.Point zeroinitializer
-// LLVM-DAG: @__const.{{.*}} = private constant %struct.CompleteS zeroinitializer
-// LLVM-DAG: @__const.{{.*}} = private constant %struct.CompleteS zeroinitializer
-// LLVM-DAG: @__const.{{.*}} = private constant %struct.CompleteS zeroinitializer
+// LLVM-DAG: @[[PAREN_A:.*]] = private unnamed_addr constant %struct.Point zeroinitializer
+// LLVM-DAG: @__const.{{.*}} = private unnamed_addr constant %struct.CompleteS zeroinitializer
+// LLVM-DAG: @__const.{{.*}} = private unnamed_addr constant %struct.CompleteS zeroinitializer
+// LLVM-DAG: @__const.{{.*}} = private unnamed_addr constant %struct.CompleteS zeroinitializer
// LLVM-DAG: @p = global ptr null
// OGCG-DAG: @p = global ptr null, align 8
diff --git a/clang/test/CIR/CodeGen/union-agg-init.c b/clang/test/CIR/CodeGen/union-agg-init.c
index a0230b53fdbcda..3bdb2709b4971f 100644
--- a/clang/test/CIR/CodeGen/union-agg-init.c
+++ b/clang/test/CIR/CodeGen/union-agg-init.c
@@ -65,7 +65,7 @@ typedef union vec3 {
// LLVMCIR-DAG: @__const.ret_outer.__retval = {{.*}}%struct.outer { %union.needs_padding zeroinitializer, i32 1 }, align 8
// OGCG-DAG: @__const.ret_outer.o = {{.*}}{ { i32, [4 x i8] }, i32, [4 x i8] } { { i32, [4 x i8] } zeroinitializer, i32 1, [4 x i8] zeroinitializer }, align 8
-// CIR-DAG: cir.global "private" constant cir_private @__const.ret_outer.__retval = #cir.const_record<{#cir.zero : !rec_needs_padding, #cir.int<1> : !s32i}> : !rec_outer align(8)
+// CIR-DAG: cir.global "private" constant cir_private unnamed_addr @__const.ret_outer.__retval = #cir.const_record<{#cir.zero : !rec_needs_padding, #cir.int<1> : !s32i}> : !rec_outer align(8)
// In C mode, this does do zero padding.
vec3 ret_vec3() {
diff --git a/clang/test/CIR/CodeGen/unions-with-zero-init.cpp b/clang/test/CIR/CodeGen/unions-with-zero-init.cpp
index 2b84c18925dae5..d98fa20c98f3e5 100644
--- a/clang/test/CIR/CodeGen/unions-with-zero-init.cpp
+++ b/clang/test/CIR/CodeGen/unions-with-zero-init.cpp
@@ -38,7 +38,7 @@
// LLVM-DAG: %union.U = type { %struct.HasPtrToMember }
// This gets promoted to a constant, so it is up here.
-// CIR-AFTER-DAG: cir.global "private" constant cir_private @__const._Z1fv.inner_a2 = #cir.const_record<{#cir.int<12> : !s32i}> : !rec_inner_aggregate2
+// CIR-AFTER-DAG: cir.global "private" constant cir_private unnamed_addr @__const._Z1fv.inner_a2 = #cir.const_record<{#cir.int<12> : !s32i}> : !rec_inner_aggregate2
// LLVM-DAG: @__const._Z1fv.inner_a2 = private {{.*}}constant { i32, [4 x i8] } { i32 12, [4 x i8] {{.*}} }
struct S { int x; };
diff --git a/clang/test/CIR/CodeGen/variable-decomposition.cpp b/clang/test/CIR/CodeGen/variable-decomposition.cpp
index 18dee7526574bf..6241e0b9ffe671 100644
--- a/clang/test/CIR/CodeGen/variable-decomposition.cpp
+++ b/clang/test/CIR/CodeGen/variable-decomposition.cpp
@@ -16,8 +16,8 @@ float function() {
return a + b;
}
-// CIR-DAG: cir.global "private" constant cir_private @[[FUNC_CONST:.*]] = #cir.const_record<{#cir.int<1> : !s32i, #cir.fp<2.000000e+00> : !cir.float}> : !rec_some_struct
-// LLVM-DAG: @[[FUNC_CONST:.*]] = private constant %struct.some_struct { i32 1, float 2.000000e+00 }
+// CIR-DAG: cir.global "private" constant cir_private unnamed_addr @[[FUNC_CONST:.*]] = #cir.const_record<{#cir.int<1> : !s32i, #cir.fp<2.000000e+00> : !cir.float}> : !rec_some_struct
+// LLVM-DAG: @[[FUNC_CONST:.*]] = private unnamed_addr constant %struct.some_struct { i32 1, float 2.000000e+00 }
// CIR-LABEL: cir.func {{.*}} @_Z8functionv() -> (!cir.float {llvm.noundef})
// CIR: %[[RETVAL:.+]] = cir.alloca "__retval" {{.*}} : !cir.ptr<!cir.float>
diff --git a/clang/test/CIR/CodeGen/vtt.cpp b/clang/test/CIR/CodeGen/vtt.cpp
index 0a150f18b75acc..4b7f605edc8534 100644
--- a/clang/test/CIR/CodeGen/vtt.cpp
+++ b/clang/test/CIR/CodeGen/vtt.cpp
@@ -116,7 +116,7 @@ void D::y() {}
// CIR-COMMON-SAME: #cir.global_view<@_ZTV1D, [1 : i32, 3 : i32], address_point true> : !cir.ptr<!u8i>
// CIR-COMMON-SAME: ]> : !cir.array<!cir.ptr<!u8i> x 7> align(8)
-// LLVM-COMMON: @_ZTT1D = constant [7 x ptr] [
+// LLVM-COMMON: @_ZTT1D = unnamed_addr constant [7 x ptr] [
// LLVM-COMMON-SAME: ptr getelementptr inbounds nuw inrange(-24, 16) (i8, ptr @_ZTV1D, i64 24),
// LLVM-COMMON-SAME: ptr getelementptr inbounds nuw inrange(-24, 8) (i8, ptr @_ZTC1D0_1B, i64 24),
// LLVM-COMMON-SAME: ptr getelementptr inbounds nuw inrange(-24, 8) (i8, ptr @_ZTC1D0_1B, i64 56),
diff --git a/clang/test/CIR/CodeGen/wide-string.cpp b/clang/test/CIR/CodeGen/wide-string.cpp
index 6da5ed57998f68..bce925c876dea5 100644
--- a/clang/test/CIR/CodeGen/wide-string.cpp
+++ b/clang/test/CIR/CodeGen/wide-string.cpp
@@ -15,62 +15,62 @@ const char16_t *test_utf16() {
return u"你好世界";
}
-// CIR: cir.global "private" constant cir_private dso_local @{{.+}} = #cir.const_array<[#cir.int<20320> : !u16i, #cir.int<22909> : !u16i, #cir.int<19990> : !u16i, #cir.int<30028> : !u16i], trailing_zeros> : !cir.array<!u16i x 5>
-// LLVM: @{{.+}} = private constant [5 x i16] [i16 20320, i16 22909, i16 19990, i16 30028, i16 0]
+// CIR: cir.global "private" constant cir_private dso_local unnamed_addr @{{.+}} = #cir.const_array<[#cir.int<20320> : !u16i, #cir.int<22909> : !u16i, #cir.int<19990> : !u16i, #cir.int<30028> : !u16i], trailing_zeros> : !cir.array<!u16i x 5>
+// LLVM: @{{.+}} = private unnamed_addr constant [5 x i16] [i16 20320, i16 22909, i16 19990, i16 30028, i16 0]
// OGCG: @{{.+}} = private unnamed_addr constant [5 x i16] [i16 20320, i16 22909, i16 19990, i16 30028, i16 0]
const char32_t *test_utf32() {
return U"你好世界";
}
-// CIR: cir.global "private" constant cir_private dso_local @{{.+}} = #cir.const_array<[#cir.int<20320> : !u32i, #cir.int<22909> : !u32i, #cir.int<19990> : !u32i, #cir.int<30028> : !u32i], trailing_zeros> : !cir.array<!u32i x 5>
-// LLVM: @{{.+}} = private constant [5 x i32] [i32 20320, i32 22909, i32 19990, i32 30028, i32 0]
+// CIR: cir.global "private" constant cir_private dso_local unnamed_addr @{{.+}} = #cir.const_array<[#cir.int<20320> : !u32i, #cir.int<22909> : !u32i, #cir.int<19990> : !u32i, #cir.int<30028> : !u32i], trailing_zeros> : !cir.array<!u32i x 5>
+// LLVM: @{{.+}} = private unnamed_addr constant [5 x i32] [i32 20320, i32 22909, i32 19990, i32 30028, i32 0]
// OGCG: @{{.+}} = private unnamed_addr constant [5 x i32] [i32 20320, i32 22909, i32 19990, i32 30028, i32 0]
const char16_t *test_zero16() {
return u"\0\0\0\0";
}
-// CIR: cir.global "private" constant cir_private dso_local @{{.+}} = #cir.zero : !cir.array<!u16i x 5>
-// LLVM: @{{.+}} = private constant [5 x i16] zeroinitializer
+// CIR: cir.global "private" constant cir_private dso_local unnamed_addr @{{.+}} = #cir.zero : !cir.array<!u16i x 5>
+// LLVM: @{{.+}} = private unnamed_addr constant [5 x i16] zeroinitializer
// OGCG: @{{.+}} = private unnamed_addr constant [5 x i16] zeroinitializer
const char32_t *test_zero32() {
return U"\0\0\0\0";
}
-// CIR: cir.global "private" constant cir_private dso_local @{{.+}} = #cir.zero : !cir.array<!u32i x 5>
-// LLVM: @{{.+}} = private constant [5 x i32] zeroinitializer
+// CIR: cir.global "private" constant cir_private dso_local unnamed_addr @{{.+}} = #cir.zero : !cir.array<!u32i x 5>
+// LLVM: @{{.+}} = private unnamed_addr constant [5 x i32] zeroinitializer
// OGCG: @{{.+}} = private unnamed_addr constant [5 x i32] zeroinitializer
const wchar_t *test_wchar() {
return L"1234";
}
-// CIR: cir.global "private" constant cir_private dso_local @{{.+}} = #cir.const_array<[#cir.int<49> : !s32i, #cir.int<50> : !s32i, #cir.int<51> : !s32i, #cir.int<52> : !s32i], trailing_zeros> : !cir.array<!s32i x 5>
-// LLVM: @{{.+}} = private constant [5 x i32] [i32 49, i32 50, i32 51, i32 52, i32 0]
+// CIR: cir.global "private" constant cir_private dso_local unnamed_addr @{{.+}} = #cir.const_array<[#cir.int<49> : !s32i, #cir.int<50> : !s32i, #cir.int<51> : !s32i, #cir.int<52> : !s32i], trailing_zeros> : !cir.array<!s32i x 5>
+// LLVM: @{{.+}} = private unnamed_addr constant [5 x i32] [i32 49, i32 50, i32 51, i32 52, i32 0]
// OGCG: @{{.+}} = private unnamed_addr constant [5 x i32] [i32 49, i32 50, i32 51, i32 52, i32 0]
const wchar_t *test_wchar_zero() {
return L"";
}
-// CIR: cir.global "private" constant cir_private dso_local @{{.+}} = #cir.zero : !cir.array<!s32i x 1>
-// LLVM: @{{.+}} = private constant [1 x i32] zeroinitializer
+// CIR: cir.global "private" constant cir_private dso_local unnamed_addr @{{.+}} = #cir.zero : !cir.array<!s32i x 1>
+// LLVM: @{{.+}} = private unnamed_addr constant [1 x i32] zeroinitializer
// OGCG: @{{.+}} = private unnamed_addr constant [1 x i32] zeroinitializer
const char16_t *test_char16_typedef() {
return u"test";
}
-// CIR: cir.global "private" constant cir_private dso_local @{{.+}} = #cir.const_array<[#cir.int<116> : !u16i, #cir.int<101> : !u16i, #cir.int<115> : !u16i, #cir.int<116> : !u16i], trailing_zeros> : !cir.array<!u16i x 5>
-// LLVM: @{{.+}} = private constant [5 x i16] [i16 116, i16 101, i16 115, i16 116, i16 0]
+// CIR: cir.global "private" constant cir_private dso_local unnamed_addr @{{.+}} = #cir.const_array<[#cir.int<116> : !u16i, #cir.int<101> : !u16i, #cir.int<115> : !u16i, #cir.int<116> : !u16i], trailing_zeros> : !cir.array<!u16i x 5>
+// LLVM: @{{.+}} = private unnamed_addr constant [5 x i16] [i16 116, i16 101, i16 115, i16 116, i16 0]
// OGCG: @{{.+}} = private unnamed_addr constant [5 x i16] [i16 116, i16 101, i16 115, i16 116, i16 0]
const wchar_t *test_wchar_high_bit() {
return L"\x80000000";
}
-// CIR: cir.global "private" constant cir_private dso_local @{{.+}} = #cir.const_array<[#cir.int<-2147483648> : !s32i], trailing_zeros> : !cir.array<!s32i x 2>
-// LLVM: @{{.+}} = private constant [2 x i32] [i32 -2147483648, i32 0]
+// CIR: cir.global "private" constant cir_private dso_local unnamed_addr @{{.+}} = #cir.const_array<[#cir.int<-2147483648> : !s32i], trailing_zeros> : !cir.array<!s32i x 2>
+// LLVM: @{{.+}} = private unnamed_addr constant [2 x i32] [i32 -2147483648, i32 0]
// OGCG: @{{.+}} = private unnamed_addr constant [2 x i32] [i32 -2147483648, i32 0]
diff --git a/clang/test/CIR/CodeGenBuiltins/builtin-printf.cpp b/clang/test/CIR/CodeGenBuiltins/builtin-printf.cpp
index dd97ac963e79b7..c1925ad5857dbf 100644
--- a/clang/test/CIR/CodeGenBuiltins/builtin-printf.cpp
+++ b/clang/test/CIR/CodeGenBuiltins/builtin-printf.cpp
@@ -13,10 +13,10 @@
// RUN: %clang_cc1 -std=c++11 -triple powerpc64le-linux-gnu -emit-llvm %s -o %t-ppc.ll
// RUN: FileCheck --input-file=%t-ppc.ll %s -check-prefix=PPC-DEFAULT
-// CIR: cir.global "private" constant cir_private dso_local @".str" = #cir.const_array<"%s" : !cir.array<!s8i x 2>, trailing_zeros> : !cir.array<!s8i x 3>
-// CIR: cir.global "private" constant cir_private dso_local @".str.1" = #cir.const_array<"%s %d\0A" : !cir.array<!s8i x 6>, trailing_zeros> : !cir.array<!s8i x 7>
-// LLVM: @.str = private constant [3 x i8] c"%s\00"
-// LLVM: @.str.1 = private constant [7 x i8] c"%s %d\0A\00"
+// CIR: cir.global "private" constant cir_private dso_local unnamed_addr @".str" = #cir.const_array<"%s" : !cir.array<!s8i x 2>, trailing_zeros> : !cir.array<!s8i x 3>
+// CIR: cir.global "private" constant cir_private dso_local unnamed_addr @".str.1" = #cir.const_array<"%s %d\0A" : !cir.array<!s8i x 6>, trailing_zeros> : !cir.array<!s8i x 7>
+// LLVM: @.str = private unnamed_addr constant [3 x i8] c"%s\00"
+// LLVM: @.str.1 = private unnamed_addr constant [7 x i8] c"%s %d\0A\00"
// OGCG: @.str = private unnamed_addr constant [3 x i8] c"%s\00"
// OGCG: @.str.1 = private unnamed_addr constant [7 x i8] c"%s %d\0A\00"
diff --git a/clang/test/CIR/CodeGenCXX/new-array-init.cpp b/clang/test/CIR/CodeGenCXX/new-array-init.cpp
index 8fd9ffd8e2e115..183c9aac2a3dbf 100644
--- a/clang/test/CIR/CodeGenCXX/new-array-init.cpp
+++ b/clang/test/CIR/CodeGenCXX/new-array-init.cpp
@@ -5,9 +5,9 @@
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o %t.ll
// RUN: FileCheck --input-file=%t.ll %s -check-prefix=LLVM
-// CIR: cir.global "private" constant cir_private dso_local @[[ABC4:.*]] = #cir.const_array<"abc" : !cir.array<!s8i x 3>, trailing_zeros> : !cir.array<!s8i x 4>
-// CIR: cir.global "private" constant cir_private dso_local @[[ABC15:.*]] = #cir.const_array<"abc" : !cir.array<!s8i x 3>, trailing_zeros> : !cir.array<!s8i x 15>
-// CIR: cir.global "private" constant cir_private dso_local @[[HELLO:.*]] = #cir.const_array<"hello" : !cir.array<!s8i x 5>, trailing_zeros> : !cir.array<!s8i x 6>
+// CIR: cir.global "private" constant cir_private dso_local unnamed_addr @[[ABC4:.*]] = #cir.const_array<"abc" : !cir.array<!s8i x 3>, trailing_zeros> : !cir.array<!s8i x 4>
+// CIR: cir.global "private" constant cir_private dso_local unnamed_addr @[[ABC15:.*]] = #cir.const_array<"abc" : !cir.array<!s8i x 3>, trailing_zeros> : !cir.array<!s8i x 15>
+// CIR: cir.global "private" constant cir_private dso_local unnamed_addr @[[HELLO:.*]] = #cir.const_array<"hello" : !cir.array<!s8i x 5>, trailing_zeros> : !cir.array<!s8i x 6>
// LLVM: @[[ABC4:.*]] = {{.*}}constant [4 x i8] c"abc\00", align 1
// LLVM: @[[ABC15:.*]] = {{.*}}constant [15 x i8] c"abc\00\00\00\00\00\00
diff --git a/clang/test/CIR/CodeGenCXX/sizeof-pack.cpp b/clang/test/CIR/CodeGenCXX/sizeof-pack.cpp
index a8dd41f85ba9e2..40b3bc7b87fc65 100644
--- a/clang/test/CIR/CodeGenCXX/sizeof-pack.cpp
+++ b/clang/test/CIR/CodeGenCXX/sizeof-pack.cpp
@@ -25,11 +25,11 @@ void test() {
foo<>();
foo<S1, S2, S3>();
}
-// CIR-DAG: cir.global "private" constant cir_private @__const._Z3fooIJ2S12S22S3EEDav.values = #cir.const_array<[#cir.int<1> : !s32i, #cir.int<2> : !s32i, #cir.int<3> : !s32i], trailing_zeros> : !cir.array<!s32i x 4>
-// LLVM-DAG: @__const._Z3fooIJ2S12S22S3EEDav.values = private constant [4 x i32] [i32 1, i32 2, i32 3, i32 0]
+// CIR-DAG: cir.global "private" constant cir_private unnamed_addr @__const._Z3fooIJ2S12S22S3EEDav.values = #cir.const_array<[#cir.int<1> : !s32i, #cir.int<2> : !s32i, #cir.int<3> : !s32i], trailing_zeros> : !cir.array<!s32i x 4>
+// LLVM-DAG: @__const._Z3fooIJ2S12S22S3EEDav.values = private unnamed_addr constant [4 x i32] [i32 1, i32 2, i32 3, i32 0]
// OGCG-DAG: @__const._Z3fooIJ2S12S22S3EEDav.values = private {{.*}}constant [4 x i32] [i32 1, i32 2, i32 3, i32 0]
-// CIR-DAG: cir.global "private" constant cir_private @__const._Z3fooIJEEDav.values = #cir.zero : !cir.array<!s32i x 1>
-// LLVM-DAG: @__const._Z3fooIJEEDav.values = private constant [1 x i32] zeroinitializer
+// CIR-DAG: cir.global "private" constant cir_private unnamed_addr @__const._Z3fooIJEEDav.values = #cir.zero : !cir.array<!s32i x 1>
+// LLVM-DAG: @__const._Z3fooIJEEDav.values = private unnamed_addr constant [1 x i32] zeroinitializer
// CIR: cir.func {{.*}}@_Z3fooIJEEDav()
// CIR: %[[RETVAL:.*]] = cir.alloca "__retval" {{.*}} : !cir.ptr<!u64i>
diff --git a/clang/test/CIR/CodeGenCXX/vtable-linkage.cpp b/clang/test/CIR/CodeGenCXX/vtable-linkage.cpp
index ece1a9675761a2..2ff709f9f81522 100644
--- a/clang/test/CIR/CodeGenCXX/vtable-linkage.cpp
+++ b/clang/test/CIR/CodeGenCXX/vtable-linkage.cpp
@@ -117,7 +117,7 @@ void use_F() {
// CIR-DAG: cir.global "private" constant linkonce_odr comdat @_ZTV1C = #cir.vtable<{#cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>, #cir.global_view<@_ZTI1C> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1C1fEv> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 5>}> : !{{.*}}align(8)
// CIR-DAG: cir.global constant linkonce_odr comdat @_ZTS1C = #cir.const_array<"1C" : !cir.array<!s8i x 2>, trailing_zeros> : !cir.array<!s8i x 3> align(1)
// CIR-DAG: cir.global constant linkonce_odr comdat @_ZTI1C = #cir.typeinfo<{#cir.global_view<@_ZTVN10__cxxabiv121__vmi_class_type_infoE, [2 : i32]> : !cir.ptr<!u8i>, #cir.global_view<@_ZTS1C> : !cir.ptr<!u8i>, #cir.int<0> : !u32i, #cir.int<1> : !u32i, #cir.global_view<@_ZTI1B> : !cir.ptr<!u8i>, #cir.int<-8189> : !s64i}> : !{{.*}}align(8)
-// CIR-DAG: cir.global constant linkonce_odr comdat @_ZTT1C = #cir.const_array<[#cir.global_view<@_ZTV1C, [0 : i32, 4 : i32], address_point true> : !cir.ptr<!u8i>, #cir.global_view<@_ZTV1C, [0 : i32, 4 : i32], address_point true> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 2> align(8)
+// CIR-DAG: cir.global constant linkonce_odr comdat unnamed_addr @_ZTT1C = #cir.const_array<[#cir.global_view<@_ZTV1C, [0 : i32, 4 : i32], address_point true> : !cir.ptr<!u8i>, #cir.global_view<@_ZTV1C, [0 : i32, 4 : i32], address_point true> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 2> align(8)
// LLVM-DAG: @_ZTV1C = linkonce_odr constant { [5 x ptr] } { [5 x ptr] [ptr null, ptr null, ptr null, ptr @_ZTI1C, ptr @_ZN1C1fEv] }, comdat, align 8
// LLVM-DAG: @_ZTS1C = linkonce_odr constant [{{[0-9]}} x i8] c"1C\00", comdat, align 1
// LLVM-DAG: @_ZTI1C = linkonce_odr constant { ptr, ptr, i32, i32, ptr, i64 } { ptr getelementptr{{.*}}({{.*}}, ptr @_ZTVN10__cxxabiv121__vmi_class_type_infoE, i64 {{.*}}), ptr @_ZTS1C, i32 0, i32 1, ptr @_ZTI1B, i64 -8189 }, comdat
@@ -254,7 +254,7 @@ void use_H() {
// construction vtables.
// CIR-DAG: cir.global "private" constant external @_ZTV1IIiE : !{{.*}}align(8)
-// CIR-DAG: cir.global "private" constant external @_ZTT1IIiE : !cir.array<!cir.ptr<!u8i> x 4> align(8)
+// CIR-DAG: cir.global "private" constant external unnamed_addr @_ZTT1IIiE : !cir.array<!cir.ptr<!u8i> x 4> align(8)
// LLVM-DAG: @_ZTV1IIiE = external constant { [5 x ptr] }, align 8
// LLVM-DAG: @_ZTT1IIiE = external {{.*}}constant [4 x ptr], align 8
struct VBase1 { virtual void f(); }; struct VBase2 : virtual VBase1 {};
diff --git a/clang/test/CIR/CodeGenHIP/string-literal-addrspace.hip b/clang/test/CIR/CodeGenHIP/string-literal-addrspace.hip
index 6c1ddeb3256245..c475c1bb4b88db 100644
--- a/clang/test/CIR/CodeGenHIP/string-literal-addrspace.hip
+++ b/clang/test/CIR/CodeGenHIP/string-literal-addrspace.hip
@@ -25,31 +25,31 @@ __device__ void take(const char *);
// emits it in source order.
// CIR-SPV: cir.global "private" internal dso_local target_address_space(1) @_ZZ12static_localvE1p = #cir.global_view<@".str.3"> : !cir.ptr<!s8i, target_address_space(4)>
-// CIR-SPV: cir.global "private" constant cir_private dso_local target_address_space(1) @".str" = #cir.const_array<"hi" : !cir.array<!s8i x 2>, trailing_zeros> : !cir.array<!s8i x 3>
-// CIR-SPV: cir.global "private" constant cir_private dso_local target_address_space(1) @".str.1" = #cir.const_array<"glob" : !cir.array<!s8i x 4>, trailing_zeros> : !cir.array<!s8i x 5>
+// CIR-SPV: cir.global "private" constant cir_private dso_local unnamed_addr target_address_space(1) @".str" = #cir.const_array<"hi" : !cir.array<!s8i x 2>, trailing_zeros> : !cir.array<!s8i x 3>
+// CIR-SPV: cir.global "private" constant cir_private dso_local unnamed_addr target_address_space(1) @".str.1" = #cir.const_array<"glob" : !cir.array<!s8i x 4>, trailing_zeros> : !cir.array<!s8i x 5>
// CIR-SPV: cir.global external target_address_space(1) @gp = #cir.global_view<@".str.1"> : !cir.ptr<!s8i, target_address_space(4)>
-// CIR-SPV: cir.global "private" constant cir_private dso_local target_address_space(1) @__func__._Z9func_namev = #cir.const_array<"func_name" : !cir.array<!s8i x 9>, trailing_zeros> : !cir.array<!s8i x 10>
-// CIR-SPV: cir.global "private" constant cir_private dso_local target_address_space(1) @".str.2" = #cir.const_array<"abc" : !cir.array<!s8i x 3>, trailing_zeros> : !cir.array<!s8i x 4>
-// CIR-SPV: cir.global "private" constant cir_private dso_local target_address_space(1) @".str.3" = #cir.const_array<"st" : !cir.array<!s8i x 2>, trailing_zeros> : !cir.array<!s8i x 3>
-// CIR-SPV: cir.global "private" constant cir_private dso_local target_address_space(1) @".str.4" = #cir.const_array<[#cir.int<119> : !s32i], trailing_zeros> : !cir.array<!s32i x 2>
+// CIR-SPV: cir.global "private" constant cir_private dso_local unnamed_addr target_address_space(1) @__func__._Z9func_namev = #cir.const_array<"func_name" : !cir.array<!s8i x 9>, trailing_zeros> : !cir.array<!s8i x 10>
+// CIR-SPV: cir.global "private" constant cir_private dso_local unnamed_addr target_address_space(1) @".str.2" = #cir.const_array<"abc" : !cir.array<!s8i x 3>, trailing_zeros> : !cir.array<!s8i x 4>
+// CIR-SPV: cir.global "private" constant cir_private dso_local unnamed_addr target_address_space(1) @".str.3" = #cir.const_array<"st" : !cir.array<!s8i x 2>, trailing_zeros> : !cir.array<!s8i x 3>
+// CIR-SPV: cir.global "private" constant cir_private dso_local unnamed_addr target_address_space(1) @".str.4" = #cir.const_array<[#cir.int<119> : !s32i], trailing_zeros> : !cir.array<!s32i x 2>
// CIR-GCN: cir.global "private" internal dso_local target_address_space(1) @_ZZ12static_localvE1p = #cir.global_view<@".str.3"> : !cir.ptr<!s8i>
-// CIR-GCN: cir.global "private" constant cir_private dso_local target_address_space(4) @".str" = #cir.const_array<"hi" : !cir.array<!s8i x 2>, trailing_zeros> : !cir.array<!s8i x 3>
-// CIR-GCN: cir.global "private" constant cir_private dso_local target_address_space(4) @".str.1" = #cir.const_array<"glob" : !cir.array<!s8i x 4>, trailing_zeros> : !cir.array<!s8i x 5>
+// CIR-GCN: cir.global "private" constant cir_private dso_local unnamed_addr target_address_space(4) @".str" = #cir.const_array<"hi" : !cir.array<!s8i x 2>, trailing_zeros> : !cir.array<!s8i x 3>
+// CIR-GCN: cir.global "private" constant cir_private dso_local unnamed_addr target_address_space(4) @".str.1" = #cir.const_array<"glob" : !cir.array<!s8i x 4>, trailing_zeros> : !cir.array<!s8i x 5>
// CIR-GCN: cir.global external target_address_space(1) @gp = #cir.global_view<@".str.1"> : !cir.ptr<!s8i>
-// CIR-GCN: cir.global "private" constant cir_private dso_local target_address_space(4) @__func__._Z9func_namev = #cir.const_array<"func_name" : !cir.array<!s8i x 9>, trailing_zeros> : !cir.array<!s8i x 10>
-// CIR-GCN: cir.global "private" constant cir_private dso_local target_address_space(4) @".str.2" = #cir.const_array<"abc" : !cir.array<!s8i x 3>, trailing_zeros> : !cir.array<!s8i x 4>
-// CIR-GCN: cir.global "private" constant cir_private dso_local target_address_space(4) @".str.3" = #cir.const_array<"st" : !cir.array<!s8i x 2>, trailing_zeros> : !cir.array<!s8i x 3>
-// CIR-GCN: cir.global "private" constant cir_private dso_local target_address_space(4) @".str.4" = #cir.const_array<[#cir.int<119> : !s32i], trailing_zeros> : !cir.array<!s32i x 2>
+// CIR-GCN: cir.global "private" constant cir_private dso_local unnamed_addr target_address_space(4) @__func__._Z9func_namev = #cir.const_array<"func_name" : !cir.array<!s8i x 9>, trailing_zeros> : !cir.array<!s8i x 10>
+// CIR-GCN: cir.global "private" constant cir_private dso_local unnamed_addr target_address_space(4) @".str.2" = #cir.const_array<"abc" : !cir.array<!s8i x 3>, trailing_zeros> : !cir.array<!s8i x 4>
+// CIR-GCN: cir.global "private" constant cir_private dso_local unnamed_addr target_address_space(4) @".str.3" = #cir.const_array<"st" : !cir.array<!s8i x 2>, trailing_zeros> : !cir.array<!s8i x 3>
+// CIR-GCN: cir.global "private" constant cir_private dso_local unnamed_addr target_address_space(4) @".str.4" = #cir.const_array<[#cir.int<119> : !s32i], trailing_zeros> : !cir.array<!s32i x 2>
// LLVM-SPV: @_ZZ12static_localvE1p = internal addrspace(1) global ptr addrspace(4) addrspacecast (ptr addrspace(1) @.str.3 to ptr addrspace(4))
-// LLVM-SPV: @.str = private addrspace(1) constant [3 x i8] c"hi\00"
-// LLVM-SPV: @.str.1 = private addrspace(1) constant [5 x i8] c"glob\00"
+// LLVM-SPV: @.str = private unnamed_addr addrspace(1) constant [3 x i8] c"hi\00"
+// LLVM-SPV: @.str.1 = private unnamed_addr addrspace(1) constant [5 x i8] c"glob\00"
// LLVM-SPV: @gp = addrspace(1) externally_initialized global ptr addrspace(4) addrspacecast (ptr addrspace(1) @.str.1 to ptr addrspace(4))
-// LLVM-SPV: @__func__._Z9func_namev = private addrspace(1) constant [10 x i8] c"func_name\00"
-// LLVM-SPV: @.str.2 = private addrspace(1) constant [4 x i8] c"abc\00"
-// LLVM-SPV: @.str.3 = private addrspace(1) constant [3 x i8] c"st\00"
-// LLVM-SPV: @.str.4 = private addrspace(1) constant [2 x i32] [i32 119, i32 0]
+// LLVM-SPV: @__func__._Z9func_namev = private unnamed_addr addrspace(1) constant [10 x i8] c"func_name\00"
+// LLVM-SPV: @.str.2 = private unnamed_addr addrspace(1) constant [4 x i8] c"abc\00"
+// LLVM-SPV: @.str.3 = private unnamed_addr addrspace(1) constant [3 x i8] c"st\00"
+// LLVM-SPV: @.str.4 = private unnamed_addr addrspace(1) constant [2 x i32] [i32 119, i32 0]
// OGCG-SPV: @.str = private unnamed_addr addrspace(1) constant [3 x i8] c"hi\00"
// OGCG-SPV: @.str.1 = private unnamed_addr addrspace(1) constant [5 x i8] c"glob\00"
@@ -61,13 +61,13 @@ __device__ void take(const char *);
// OGCG-SPV: @.str.4 = private unnamed_addr addrspace(1) constant [2 x i32] [i32 119, i32 0]
// LLVM-GCN: @_ZZ12static_localvE1p = internal addrspace(1) global ptr addrspacecast (ptr addrspace(4) @.str.3 to ptr)
-// LLVM-GCN: @.str = private addrspace(4) constant [3 x i8] c"hi\00"
-// LLVM-GCN: @.str.1 = private addrspace(4) constant [5 x i8] c"glob\00"
+// LLVM-GCN: @.str = private unnamed_addr addrspace(4) constant [3 x i8] c"hi\00"
+// LLVM-GCN: @.str.1 = private unnamed_addr addrspace(4) constant [5 x i8] c"glob\00"
// LLVM-GCN: @gp = addrspace(1) externally_initialized global ptr addrspacecast (ptr addrspace(4) @.str.1 to ptr)
-// LLVM-GCN: @__func__._Z9func_namev = private addrspace(4) constant [10 x i8] c"func_name\00"
-// LLVM-GCN: @.str.2 = private addrspace(4) constant [4 x i8] c"abc\00"
-// LLVM-GCN: @.str.3 = private addrspace(4) constant [3 x i8] c"st\00"
-// LLVM-GCN: @.str.4 = private addrspace(4) constant [2 x i32] [i32 119, i32 0]
+// LLVM-GCN: @__func__._Z9func_namev = private unnamed_addr addrspace(4) constant [10 x i8] c"func_name\00"
+// LLVM-GCN: @.str.2 = private unnamed_addr addrspace(4) constant [4 x i8] c"abc\00"
+// LLVM-GCN: @.str.3 = private unnamed_addr addrspace(4) constant [3 x i8] c"st\00"
+// LLVM-GCN: @.str.4 = private unnamed_addr addrspace(4) constant [2 x i32] [i32 119, i32 0]
// OGCG-GCN: @.str = private unnamed_addr addrspace(4) constant [3 x i8] c"hi\00"
// OGCG-GCN: @.str.1 = private unnamed_addr addrspace(4) constant [5 x i8] c"glob\00"
diff --git a/clang/test/CIR/CodeGenOpenCL/string-literal-addrspace.cl b/clang/test/CIR/CodeGenOpenCL/string-literal-addrspace.cl
index c0d19ea60a98ef..677fa42a807a07 100644
--- a/clang/test/CIR/CodeGenOpenCL/string-literal-addrspace.cl
+++ b/clang/test/CIR/CodeGenOpenCL/string-literal-addrspace.cl
@@ -21,25 +21,25 @@
void take(const __constant char *);
-// CIR-SPV: cir.global "private" constant cir_private dso_local target_address_space(2) @".str" = #cir.const_array<"hi" : !cir.array<!s8i x 2>, trailing_zeros> : !cir.array<!s8i x 3>
-// CIR-SPV: cir.global "private" constant cir_private dso_local target_address_space(2) @".str.1" = #cir.const_array<"abc" : !cir.array<!s8i x 3>, trailing_zeros> : !cir.array<!s8i x 4>
-// CIR-SPV: cir.global "private" constant cir_private dso_local target_address_space(2) @__func__.func_name = #cir.const_array<"func_name" : !cir.array<!s8i x 9>, trailing_zeros> : !cir.array<!s8i x 10>
+// CIR-SPV: cir.global "private" constant cir_private dso_local unnamed_addr target_address_space(2) @".str" = #cir.const_array<"hi" : !cir.array<!s8i x 2>, trailing_zeros> : !cir.array<!s8i x 3>
+// CIR-SPV: cir.global "private" constant cir_private dso_local unnamed_addr target_address_space(2) @".str.1" = #cir.const_array<"abc" : !cir.array<!s8i x 3>, trailing_zeros> : !cir.array<!s8i x 4>
+// CIR-SPV: cir.global "private" constant cir_private dso_local unnamed_addr target_address_space(2) @__func__.func_name = #cir.const_array<"func_name" : !cir.array<!s8i x 9>, trailing_zeros> : !cir.array<!s8i x 10>
-// CIR-GCN: cir.global "private" constant cir_private dso_local target_address_space(4) @".str" = #cir.const_array<"hi" : !cir.array<!s8i x 2>, trailing_zeros> : !cir.array<!s8i x 3>
-// CIR-GCN: cir.global "private" constant cir_private dso_local target_address_space(4) @".str.1" = #cir.const_array<"abc" : !cir.array<!s8i x 3>, trailing_zeros> : !cir.array<!s8i x 4>
-// CIR-GCN: cir.global "private" constant cir_private dso_local target_address_space(4) @__func__.func_name = #cir.const_array<"func_name" : !cir.array<!s8i x 9>, trailing_zeros> : !cir.array<!s8i x 10>
+// CIR-GCN: cir.global "private" constant cir_private dso_local unnamed_addr target_address_space(4) @".str" = #cir.const_array<"hi" : !cir.array<!s8i x 2>, trailing_zeros> : !cir.array<!s8i x 3>
+// CIR-GCN: cir.global "private" constant cir_private dso_local unnamed_addr target_address_space(4) @".str.1" = #cir.const_array<"abc" : !cir.array<!s8i x 3>, trailing_zeros> : !cir.array<!s8i x 4>
+// CIR-GCN: cir.global "private" constant cir_private dso_local unnamed_addr target_address_space(4) @__func__.func_name = #cir.const_array<"func_name" : !cir.array<!s8i x 9>, trailing_zeros> : !cir.array<!s8i x 10>
-// LLVM-SPV: @.str = private addrspace(2) constant [3 x i8] c"hi\00"
-// LLVM-SPV: @.str.1 = private addrspace(2) constant [4 x i8] c"abc\00"
-// LLVM-SPV: @__func__.func_name = private addrspace(2) constant [10 x i8] c"func_name\00"
+// LLVM-SPV: @.str = private unnamed_addr addrspace(2) constant [3 x i8] c"hi\00"
+// LLVM-SPV: @.str.1 = private unnamed_addr addrspace(2) constant [4 x i8] c"abc\00"
+// LLVM-SPV: @__func__.func_name = private unnamed_addr addrspace(2) constant [10 x i8] c"func_name\00"
// OGCG-SPV: @.str = private unnamed_addr addrspace(2) constant [3 x i8] c"hi\00"
// OGCG-SPV: @.str.1 = private unnamed_addr addrspace(2) constant [4 x i8] c"abc\00"
// OGCG-SPV: @__func__.func_name = private unnamed_addr addrspace(2) constant [10 x i8] c"func_name\00"
-// LLVM-GCN: @.str = private addrspace(4) constant [3 x i8] c"hi\00"
-// LLVM-GCN: @.str.1 = private addrspace(4) constant [4 x i8] c"abc\00"
-// LLVM-GCN: @__func__.func_name = private addrspace(4) constant [10 x i8] c"func_name\00"
+// LLVM-GCN: @.str = private unnamed_addr addrspace(4) constant [3 x i8] c"hi\00"
+// LLVM-GCN: @.str.1 = private unnamed_addr addrspace(4) constant [4 x i8] c"abc\00"
+// LLVM-GCN: @__func__.func_name = private unnamed_addr addrspace(4) constant [10 x i8] c"func_name\00"
// OGCG-GCN: @.str = private unnamed_addr addrspace(4) constant [3 x i8] c"hi\00"
// OGCG-GCN: @.str.1 = private unnamed_addr addrspace(4) constant [4 x i8] c"abc\00"
diff --git a/clang/test/CIR/CodeGenSYCL/global-address-space.cpp b/clang/test/CIR/CodeGenSYCL/global-address-space.cpp
index df96b17cf80689..f2220474615f98 100644
--- a/clang/test/CIR/CodeGenSYCL/global-address-space.cpp
+++ b/clang/test/CIR/CodeGenSYCL/global-address-space.cpp
@@ -29,9 +29,9 @@ int i;
// LLVM-DAG: @gs = addrspace(1) global ptr addrspace(4) addrspacecast (ptr addrspace(1) @.str to ptr addrspace(4)), align 8
// LLVM-DAG: @i = addrspace(1) global i32 0, align 4
// LLVM-DAG: @_ZZ18static_const_localvE3foo = internal addrspace(1) constant i32 66, align 4
-// LLVM-CIR-DAG: @.str = private addrspace(1) constant [14 x i8] c"Hello, world!\00", align 1
-// LLVM-CIR-DAG: @.str.1 = private addrspace(1) constant [21 x i8] c"Another hello world!\00", align 1
-// LLVM-CIR-DAG: @.str.2 = private addrspace(1) constant [24 x i8] c"Yet another Hello world\00", align 1
+// LLVM-CIR-DAG: @.str = private unnamed_addr addrspace(1) constant [14 x i8] c"Hello, world!\00", align 1
+// LLVM-CIR-DAG: @.str.1 = private unnamed_addr addrspace(1) constant [21 x i8] c"Another hello world!\00", align 1
+// LLVM-CIR-DAG: @.str.2 = private unnamed_addr addrspace(1) constant [24 x i8] c"Yet another Hello world\00", align 1
// OGCG-DAG: @.str = private unnamed_addr addrspace(1) constant [14 x i8] c"Hello, world!\00", align 1
// OGCG-DAG: @.str.1 = private unnamed_addr addrspace(1) constant [21 x i8] c"Another hello world!\00", align 1
// OGCG-DAG: @.str.2 = private unnamed_addr addrspace(1) constant [24 x i8] c"Yet another Hello world\00", align 1
diff --git a/clang/test/CIR/CodeGenSYCL/unique-stable-name.cpp b/clang/test/CIR/CodeGenSYCL/unique-stable-name.cpp
index b074cc6241be65..ba96aa3b629d32 100644
--- a/clang/test/CIR/CodeGenSYCL/unique-stable-name.cpp
+++ b/clang/test/CIR/CodeGenSYCL/unique-stable-name.cpp
@@ -37,21 +37,21 @@ void use(const char *);
// A global initializer is constant-folded to a string literal.
const char *global_name = __builtin_sycl_unique_stable_name(int);
-// CIR-HOST: cir.global "private" constant cir_private dso_local @[[GLOBAL_STR:[^ ]+]] = #cir.const_array<"_ZTSi" : !cir.array<!s8i x 5>, trailing_zeros> : !cir.array<!s8i x 6> align(1)
+// CIR-HOST: cir.global "private" constant cir_private dso_local unnamed_addr @[[GLOBAL_STR:[^ ]+]] = #cir.const_array<"_ZTSi" : !cir.array<!s8i x 5>, trailing_zeros> : !cir.array<!s8i x 6> align(1)
// CIR-HOST: cir.global external @global_name = #cir.global_view<@[[GLOBAL_STR]]> : !cir.ptr<!s8i> align(8)
-// CIR-HOST: cir.global "private" constant cir_private dso_local @[[LAMBDA:__usn_str]] = #cir.const_array<"_ZTSZ9host_onlyvEUlvE_" : !cir.array<!s8i x 22>, trailing_zeros> : !cir.array<!s8i x 23> align(1)
-// CIR-HOST: cir.global "private" constant cir_private dso_local @[[INT:__usn_str\.[0-9]+]] = #cir.const_array<"_ZTSi" : !cir.array<!s8i x 5>, trailing_zeros> : !cir.array<!s8i x 6> align(1)
-// CIR-HOST: cir.global "private" constant cir_private dso_local @[[CONSTEXPR_STR:[^ ]+]] = #cir.const_array<"_ZTSl" : !cir.array<!s8i x 5>, trailing_zeros> : !cir.array<!s8i x 6> align(1)
-// CIR-HOST: cir.global "private" constant cir_private dso_local @[[TPL_INT:__usn_str\.[0-9]+]] = #cir.const_array<"_ZTSi" : !cir.array<!s8i x 5>, trailing_zeros> : !cir.array<!s8i x 6> align(1)
-// CIR-HOST: cir.global "private" constant cir_private dso_local @[[TPL_LAMBDA:__usn_str\.[0-9]+]] = #cir.const_array<"_ZTSZ9host_onlyvEUlvE_" : !cir.array<!s8i x 22>, trailing_zeros> : !cir.array<!s8i x 23> align(1)
+// CIR-HOST: cir.global "private" constant cir_private dso_local unnamed_addr @[[LAMBDA:__usn_str]] = #cir.const_array<"_ZTSZ9host_onlyvEUlvE_" : !cir.array<!s8i x 22>, trailing_zeros> : !cir.array<!s8i x 23> align(1)
+// CIR-HOST: cir.global "private" constant cir_private dso_local unnamed_addr @[[INT:__usn_str\.[0-9]+]] = #cir.const_array<"_ZTSi" : !cir.array<!s8i x 5>, trailing_zeros> : !cir.array<!s8i x 6> align(1)
+// CIR-HOST: cir.global "private" constant cir_private dso_local unnamed_addr @[[CONSTEXPR_STR:[^ ]+]] = #cir.const_array<"_ZTSl" : !cir.array<!s8i x 5>, trailing_zeros> : !cir.array<!s8i x 6> align(1)
+// CIR-HOST: cir.global "private" constant cir_private dso_local unnamed_addr @[[TPL_INT:__usn_str\.[0-9]+]] = #cir.const_array<"_ZTSi" : !cir.array<!s8i x 5>, trailing_zeros> : !cir.array<!s8i x 6> align(1)
+// CIR-HOST: cir.global "private" constant cir_private dso_local unnamed_addr @[[TPL_LAMBDA:__usn_str\.[0-9]+]] = #cir.const_array<"_ZTSZ9host_onlyvEUlvE_" : !cir.array<!s8i x 22>, trailing_zeros> : !cir.array<!s8i x 23> align(1)
-// CIR-LLVM-HOST: @[[GLOBAL_STR:[^ ]+]] = private constant [6 x i8] c"_ZTSi\00", align 1
+// CIR-LLVM-HOST: @[[GLOBAL_STR:[^ ]+]] = private unnamed_addr constant [6 x i8] c"_ZTSi\00", align 1
// CIR-LLVM-HOST: @global_name = global ptr @[[GLOBAL_STR]], align 8
-// CIR-LLVM-HOST: @[[LAMBDA:__usn_str]] = private constant [23 x i8] c"_ZTSZ9host_onlyvEUlvE_\00", align 1
-// CIR-LLVM-HOST: @[[INT:__usn_str\.[0-9]+]] = private constant [6 x i8] c"_ZTSi\00", align 1
-// CIR-LLVM-HOST: @[[CONSTEXPR_STR:[^ ]+]] = private constant [6 x i8] c"_ZTSl\00", align 1
-// CIR-LLVM-HOST: @[[TPL_INT:__usn_str\.[0-9]+]] = private constant [6 x i8] c"_ZTSi\00", align 1
-// CIR-LLVM-HOST: @[[TPL_LAMBDA:__usn_str\.[0-9]+]] = private constant [23 x i8] c"_ZTSZ9host_onlyvEUlvE_\00", align 1
+// CIR-LLVM-HOST: @[[LAMBDA:__usn_str]] = private unnamed_addr constant [23 x i8] c"_ZTSZ9host_onlyvEUlvE_\00", align 1
+// CIR-LLVM-HOST: @[[INT:__usn_str\.[0-9]+]] = private unnamed_addr constant [6 x i8] c"_ZTSi\00", align 1
+// CIR-LLVM-HOST: @[[CONSTEXPR_STR:[^ ]+]] = private unnamed_addr constant [6 x i8] c"_ZTSl\00", align 1
+// CIR-LLVM-HOST: @[[TPL_INT:__usn_str\.[0-9]+]] = private unnamed_addr constant [6 x i8] c"_ZTSi\00", align 1
+// CIR-LLVM-HOST: @[[TPL_LAMBDA:__usn_str\.[0-9]+]] = private unnamed_addr constant [23 x i8] c"_ZTSZ9host_onlyvEUlvE_\00", align 1
// OGCG-HOST: @[[GLOBAL_STR:[^ ]+]] = private unnamed_addr constant [6 x i8] c"_ZTSi\00", align 1
// OGCG-HOST: @global_name = global ptr @[[GLOBAL_STR]], align 8
@@ -61,11 +61,11 @@ const char *global_name = __builtin_sycl_unique_stable_name(int);
// OGCG-HOST: @[[TPL_INT:__usn_str\.[0-9]+]] = private unnamed_addr constant [6 x i8] c"_ZTSi\00", align 1
// OGCG-HOST: @[[TPL_LAMBDA:__usn_str\.[0-9]+]] = private unnamed_addr constant [23 x i8] c"_ZTSZ9host_onlyvEUlvE_\00", align 1
-// CIR-DEV: cir.global "private" constant cir_private dso_local target_address_space(1) @[[KERNEL_LAMBDA:__usn_str]] = #cir.const_array<"_ZTSZZ4mainENKUlvE_clEvEUlvE_" : !cir.array<!s8i x 29>, trailing_zeros> : !cir.array<!s8i x 30> align(1)
-// CIR-DEV: cir.global "private" constant cir_private dso_local target_address_space(1) @[[KERNEL_CONSTEXPR:[^ ]+]] = #cir.const_array<"_ZTSc" : !cir.array<!s8i x 5>, trailing_zeros> : !cir.array<!s8i x 6> align(1)
+// CIR-DEV: cir.global "private" constant cir_private dso_local unnamed_addr target_address_space(1) @[[KERNEL_LAMBDA:__usn_str]] = #cir.const_array<"_ZTSZZ4mainENKUlvE_clEvEUlvE_" : !cir.array<!s8i x 29>, trailing_zeros> : !cir.array<!s8i x 30> align(1)
+// CIR-DEV: cir.global "private" constant cir_private dso_local unnamed_addr target_address_space(1) @[[KERNEL_CONSTEXPR:[^ ]+]] = #cir.const_array<"_ZTSc" : !cir.array<!s8i x 5>, trailing_zeros> : !cir.array<!s8i x 6> align(1)
-// CIR-LLVM-DEV: @[[KERNEL_LAMBDA:__usn_str]] = private addrspace(1) constant [30 x i8] c"_ZTSZZ4mainENKUlvE_clEvEUlvE_\00", align 1
-// CIR-LLVM-DEV: @[[KERNEL_CONSTEXPR:[^ ]+]] = private addrspace(1) constant [6 x i8] c"_ZTSc\00", align 1
+// CIR-LLVM-DEV: @[[KERNEL_LAMBDA:__usn_str]] = private unnamed_addr addrspace(1) constant [30 x i8] c"_ZTSZZ4mainENKUlvE_clEvEUlvE_\00", align 1
+// CIR-LLVM-DEV: @[[KERNEL_CONSTEXPR:[^ ]+]] = private unnamed_addr addrspace(1) constant [6 x i8] c"_ZTSc\00", align 1
// OGCG-DEV: @[[KERNEL_LAMBDA:__usn_str]] = private unnamed_addr addrspace(1) constant [30 x i8] c"_ZTSZZ4mainENKUlvE_clEvEUlvE_\00", align 1
// OGCG-DEV: @[[KERNEL_CONSTEXPR:[^ ]+]] = private unnamed_addr addrspace(1) constant [6 x i8] c"_ZTSc\00", align 1
diff --git a/clang/test/CIR/IR/global-unnamed-addr.cir b/clang/test/CIR/IR/global-unnamed-addr.cir
new file mode 100644
index 00000000000000..2ce2245bc05d64
--- /dev/null
+++ b/clang/test/CIR/IR/global-unnamed-addr.cir
@@ -0,0 +1,28 @@
+// RUN: cir-opt %s --verify-roundtrip | FileCheck %s
+// RUN: cir-opt %s -cir-to-llvm -o - | FileCheck %s --check-prefix=MLIR
+// RUN: cir-translate %s -cir-to-llvmir --disable-cc-lowering -o - | FileCheck %s --check-prefix=LLVM
+
+!s8i = !cir.int<s, 8>
+!s32i = !cir.int<s, 32>
+
+module {
+ cir.global "private" constant cir_private dso_local unnamed_addr @".str" = #cir.const_array<"hi" : !cir.array<!s8i x 2>, trailing_zeros> : !cir.array<!s8i x 3> align(1)
+ // CHECK: cir.global "private" constant cir_private dso_local unnamed_addr @".str"
+ // MLIR: llvm.mlir.global private unnamed_addr constant @".str"
+ // LLVM: @.str = private unnamed_addr constant [3 x i8] c"hi\00"
+
+ cir.global "private" constant cir_private unnamed_addr target_address_space(1) @as_str = #cir.const_array<"as" : !cir.array<!s8i x 2>, trailing_zeros> : !cir.array<!s8i x 3>
+ // CHECK: cir.global "private" constant cir_private unnamed_addr target_address_space(1) @as_str
+ // MLIR: llvm.mlir.global private unnamed_addr constant @as_str{{.*}}addr_space = 1
+ // LLVM: @as_str = private unnamed_addr addrspace(1) constant [3 x i8] c"as\00"
+
+ cir.global "private" constant external unnamed_addr @ext_decl : !cir.array<!s32i x 2>
+ // CHECK: cir.global "private" constant external unnamed_addr @ext_decl : !cir.array<!s32i x 2>
+ // MLIR: llvm.mlir.global external unnamed_addr constant @ext_decl()
+ // LLVM: @ext_decl = external unnamed_addr constant [2 x i32]
+
+ cir.global external @named = #cir.int<0> : !s32i
+ // CHECK: cir.global external @named = #cir.int<0> : !s32i
+ // MLIR: llvm.mlir.global external @named(0 : i32)
+ // LLVM: @named = global i32 0
+}
diff --git a/clang/test/CIR/Lowering/array.cpp b/clang/test/CIR/Lowering/array.cpp
index 0225be03906c98..8cd8c6d4644b8f 100644
--- a/clang/test/CIR/Lowering/array.cpp
+++ b/clang/test/CIR/Lowering/array.cpp
@@ -1,11 +1,11 @@
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t-cir.ll
// RUN: FileCheck --input-file=%t-cir.ll %s
-// CHECK-DAG: @[[FUNC2_ARR:.*]] = private constant [2 x i32] [i32 5, i32 0]
-// CHECK-DAG: @[[FUNC3_ARR:.*]] = private constant [2 x i32] [i32 5, i32 6]
-// CHECK-DAG: @[[FUNC4_ARR:.*]] = private constant [2 x [1 x i32]] {{.*}}[1 x i32] [i32 5], [1 x i32] [i32 6]{{.*}}
-// CHECK-DAG: @[[FUNC5_ARR:.*]] = private constant [2 x [1 x i32]] {{.*}}[1 x i32] [i32 5], [1 x i32] zeroinitializer{{.*}}
-// CHECK-DAG: @[[FUNC7_ARR:.*]] = private constant [1 x ptr] zeroinitializer
+// CHECK-DAG: @[[FUNC2_ARR:.*]] = private unnamed_addr constant [2 x i32] [i32 5, i32 0]
+// CHECK-DAG: @[[FUNC3_ARR:.*]] = private unnamed_addr constant [2 x i32] [i32 5, i32 6]
+// CHECK-DAG: @[[FUNC4_ARR:.*]] = private unnamed_addr constant [2 x [1 x i32]] {{.*}}[1 x i32] [i32 5], [1 x i32] [i32 6]{{.*}}
+// CHECK-DAG: @[[FUNC5_ARR:.*]] = private unnamed_addr constant [2 x [1 x i32]] {{.*}}[1 x i32] [i32 5], [1 x i32] zeroinitializer{{.*}}
+// CHECK-DAG: @[[FUNC7_ARR:.*]] = private unnamed_addr constant [1 x ptr] zeroinitializer
int a[10];
// CHECK: @a = global [10 x i32] zeroinitializer
>From d0ecad019f86e49e24c4743536e686104ceebfb0 Mon Sep 17 00:00:00 2001
From: Konstantinos Parasyris <konstantinos.parasyris at intel.com>
Date: Fri, 6 Nov 2026 07:55:38 -0800
Subject: [PATCH 2/3] Fix windows
---
clang/test/CIR/IR/global-unnamed-addr.cir | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/test/CIR/IR/global-unnamed-addr.cir b/clang/test/CIR/IR/global-unnamed-addr.cir
index 2ce2245bc05d64..ab3f41be0778a6 100644
--- a/clang/test/CIR/IR/global-unnamed-addr.cir
+++ b/clang/test/CIR/IR/global-unnamed-addr.cir
@@ -5,7 +5,7 @@
!s8i = !cir.int<s, 8>
!s32i = !cir.int<s, 32>
-module {
+module attributes {cir.triple = "x86_64-unknown-linux-gnu"} {
cir.global "private" constant cir_private dso_local unnamed_addr @".str" = #cir.const_array<"hi" : !cir.array<!s8i x 2>, trailing_zeros> : !cir.array<!s8i x 3> align(1)
// CHECK: cir.global "private" constant cir_private dso_local unnamed_addr @".str"
// MLIR: llvm.mlir.global private unnamed_addr constant @".str"
>From 8c7bce6a48d582f0c975b035a43617ee3ff08b04 Mon Sep 17 00:00:00 2001
From: Konstantinos Parasyris <konstantinos.parasyris at intel.com>
Date: Fri, 6 Nov 2026 09:53:25 -0800
Subject: [PATCH 3/3] [CIR] Mark vtables unnamed_addr when their address is
insignificant
Port classic codegen's vtable unnamed_addr rules to CIR:
- A vtable is marked unnamed_addr when no RTTI is emitted, since nothing
(e.g. dynamic_cast) relies on its address.
- On targets that may duplicate weak vtables (Apple Mach-O), a weak
vtable is marked unnamed_addr even with RTTI.
This applies to complete-object vtables (getAddrOfVTable,
emitVTableDefinitions) and construction vtables. Add a
CIRGenModule::mayVTableBeDuplicated helper mirroring classic codegen.
Depends on the cir.global unnamed_addr support in #239429.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
---
clang/lib/CIR/CodeGen/CIRGenItaniumCXXABI.cpp | 7 +-
clang/lib/CIR/CodeGen/CIRGenModule.h | 5 ++
clang/lib/CIR/CodeGen/CIRGenVTables.cpp | 12 +++-
clang/test/CIR/CodeGen/multi-vtable.cpp | 12 ++--
clang/test/CIR/CodeGen/thunks.cpp | 20 +++---
clang/test/CIR/CodeGen/vtable-emission.cpp | 2 +-
.../CodeGen/vtable-thunk-undefined-callee.cpp | 2 +-
clang/test/CIR/CodeGen/vtt.cpp | 9 ++-
.../CIR/CodeGenCXX/vtable-unnamed-addr.cpp | 68 +++++++++++++++++++
9 files changed, 112 insertions(+), 25 deletions(-)
create mode 100644 clang/test/CIR/CodeGenCXX/vtable-unnamed-addr.cpp
diff --git a/clang/lib/CIR/CodeGen/CIRGenItaniumCXXABI.cpp b/clang/lib/CIR/CodeGen/CIRGenItaniumCXXABI.cpp
index 0fd20107e9c7e8..b8cc4068faa5e7 100644
--- a/clang/lib/CIR/CodeGen/CIRGenItaniumCXXABI.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenItaniumCXXABI.cpp
@@ -516,6 +516,9 @@ void CIRGenItaniumCXXABI::emitVTableDefinitions(CIRGenVTables &cgvt,
// Set the correct linkage.
vtable.setLinkage(linkage);
+ if (cgm.mayVTableBeDuplicated(linkage))
+ vtable.setUnnamedAddr(true);
+
if (cgm.supportsCOMDAT() && cir::isWeakForLinker(linkage))
vtable.setSelfComdat();
@@ -1609,8 +1612,8 @@ cir::GlobalOp CIRGenItaniumCXXABI::getAddrOfVTable(const CXXRecordDecl *rd,
cgm.getLoc(rd->getSourceRange()), name, vtableType,
cir::GlobalLinkageKind::ExternalLinkage,
cgm.getASTContext().toCharUnitsFromBits(ptrAlign));
- // LLVM codegen handles unnamedAddr
- assert(!cir::MissingFeatures::opGlobalUnnamedAddr());
+ if (!cgm.shouldEmitRTTI())
+ vtable.setUnnamedAddr(true);
// In MS C++ if you have a class with virtual functions in which you are using
// selective member import/export, then all virtual functions must be exported
diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.h b/clang/lib/CIR/CodeGen/CIRGenModule.h
index ce53b73fb163cd..2cc19601694bbe 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.h
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.h
@@ -665,6 +665,11 @@ class CIRGenModule : public CIRGenTypeCache {
/// necessary, caching the result for the given function.
cir::FuncOp getFunctionPointer(GlobalDecl GD);
+ /// Return true if a vtable with the given linkage may have more than one
+ /// address in the program, in which case its address is insignificant and it
+ /// can be marked unnamed_addr.
+ bool mayVTableBeDuplicated(cir::GlobalLinkageKind linkage) const;
+
// Return whether RTTI information should be emitted for this target.
bool shouldEmitRTTI(bool forEH = false) {
return (forEH || getLangOpts().RTTI) && !getLangOpts().CUDAIsDevice &&
diff --git a/clang/lib/CIR/CodeGen/CIRGenVTables.cpp b/clang/lib/CIR/CodeGen/CIRGenVTables.cpp
index 4ac07fe42c1a05..fba4c70973f5c3 100644
--- a/clang/lib/CIR/CodeGen/CIRGenVTables.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenVTables.cpp
@@ -342,8 +342,10 @@ cir::GlobalOp CIRGenVTables::generateConstructionVTable(
cir::GlobalOp vtable = cgm.createOrReplaceCXXRuntimeVariable(
loc, name, vtType, linkage, CharUnits::fromQuantity(align));
- // V-tables are always unnamed_addr.
- assert(!cir::MissingFeatures::opGlobalUnnamedAddr());
+ // dynamic_cast relies on a unique vtable address, so the address only
+ // becomes insignificant without RTTI or when the vtable may be duplicated.
+ if (!cgm.shouldEmitRTTI() || cgm.mayVTableBeDuplicated(vtable.getLinkage()))
+ vtable.setUnnamedAddr(true);
mlir::Attribute rtti = cgm.getAddrOfRTTIDescriptor(
loc, cgm.getASTContext().getCanonicalTagType(base.getBase()));
@@ -1104,3 +1106,9 @@ void CIRGenModule::emitVTablesOpportunistically() {
bool CIRGenModule::shouldOpportunisticallyEmitVTables() {
return codeGenOpts.OptimizationLevel > 0;
}
+
+bool CIRGenModule::mayVTableBeDuplicated(cir::GlobalLinkageKind linkage) const {
+ return getTarget().getVTableUniqueness() ==
+ VTableUniquenessKind::UniqueIfStrongLinkage &&
+ cir::isWeakForLinker(linkage);
+}
diff --git a/clang/test/CIR/CodeGen/multi-vtable.cpp b/clang/test/CIR/CodeGen/multi-vtable.cpp
index 48fb1fa88b11c8..6719939b91851a 100644
--- a/clang/test/CIR/CodeGen/multi-vtable.cpp
+++ b/clang/test/CIR/CodeGen/multi-vtable.cpp
@@ -39,7 +39,7 @@ void Child::MotherKey() {}
// Child vtable
-// CIR: cir.global "private" constant external @_ZTV5Child = #cir.vtable<{
+// CIR: cir.global "private" constant external unnamed_addr @_ZTV5Child = #cir.vtable<{
// CIR-SAME: #cir.const_array<[
// CIR-SAME: #cir.ptr<null> : !cir.ptr<!u8i>,
// CIR-SAME: #cir.ptr<null> : !cir.ptr<!u8i>,
@@ -53,7 +53,7 @@ void Child::MotherKey() {}
// CIR-SAME: ]> : !cir.array<!cir.ptr<!u8i> x 3>
// CIR-SAME: }> : [[CHILD_VTABLE_TYPE]]
-// LLVM: @_ZTV5Child = constant { [4 x ptr], [3 x ptr] } {
+// LLVM: @_ZTV5Child = unnamed_addr constant { [4 x ptr], [3 x ptr] } {
// LLVM-SAME: [4 x ptr] [
// LLVM-SAME: ptr null,
// LLVM-SAME: ptr null,
@@ -83,7 +83,7 @@ void Child::MotherKey() {}
// Mother vtable
-// CIR: cir.global "private" constant external @_ZTV6Mother = #cir.vtable<{
+// CIR: cir.global "private" constant external unnamed_addr @_ZTV6Mother = #cir.vtable<{
// CIR-SAME: #cir.const_array<[
// CIR-SAME: #cir.ptr<null> : !cir.ptr<!u8i>,
// CIR-SAME: #cir.ptr<null> : !cir.ptr<!u8i>,
@@ -92,7 +92,7 @@ void Child::MotherKey() {}
// CIR-SAME: ]> : !cir.array<!cir.ptr<!u8i> x 4>
// CIR-SAME: }> : [[MOTHER_VTABLE_TYPE]]
-// LLVM: @_ZTV6Mother = constant { [4 x ptr] } {
+// LLVM: @_ZTV6Mother = unnamed_addr constant { [4 x ptr] } {
// LLVM-SAME: [4 x ptr] [
// LLVM-SAME: ptr null,
// LLVM-SAME: ptr null,
@@ -112,7 +112,7 @@ void Child::MotherKey() {}
// Father vtable
-// CIR: cir.global "private" constant external @_ZTV6Father = #cir.vtable<{
+// CIR: cir.global "private" constant external unnamed_addr @_ZTV6Father = #cir.vtable<{
// CIR-SAME: #cir.const_array<[
// CIR-SAME: #cir.ptr<null> : !cir.ptr<!u8i>,
// CIR-SAME: #cir.ptr<null> : !cir.ptr<!u8i>,
@@ -120,7 +120,7 @@ void Child::MotherKey() {}
// CIR-SAME: ]> : !cir.array<!cir.ptr<!u8i> x 3>
// CIR-SAME: }> : [[FATHER_VTABLE_TYPE]]
-// LLVM: @_ZTV6Father = constant { [3 x ptr] } {
+// LLVM: @_ZTV6Father = unnamed_addr constant { [3 x ptr] } {
// LLVM-SAME: [3 x ptr] [
// LLVM-SAME: ptr null,
// LLVM-SAME: ptr null,
diff --git a/clang/test/CIR/CodeGen/thunks.cpp b/clang/test/CIR/CodeGen/thunks.cpp
index 3fa329f02ffc95..ecd209d47c7e18 100644
--- a/clang/test/CIR/CodeGen/thunks.cpp
+++ b/clang/test/CIR/CodeGen/thunks.cpp
@@ -151,28 +151,28 @@ void C::f(int x, ...) {}
// In CIR, all globals are emitted before functions.
// Test1 vtable: C's vtable references the thunk for B's entry.
-// CIR-DAG: cir.global "private" constant external @_ZTVN5Test11CE = #cir.vtable<{
+// CIR-DAG: cir.global "private" constant external unnamed_addr @_ZTVN5Test11CE = #cir.vtable<{
// CIR-DAG: #cir.global_view<@_ZN5Test11C1fEv> : !cir.ptr<!u8i>
// CIR-DAG: #cir.global_view<@_ZThn8_N5Test11C1fEv> : !cir.ptr<!u8i>
// Test2 vtable: C's vtable references the thunk for B's entry.
-// CIR-DAG: cir.global "private" constant external @_ZTVN5Test21CE = #cir.vtable<{
+// CIR-DAG: cir.global "private" constant external unnamed_addr @_ZTVN5Test21CE = #cir.vtable<{
// CIR-DAG: #cir.global_view<@_ZN5Test21C1gEv> : !cir.ptr<!u8i>
// CIR-DAG: #cir.global_view<@_ZThn8_N5Test21C1gEv> : !cir.ptr<!u8i>
// Test5 vtable: C's vtable references the aggregate-return thunk for B's
// entry.
-// CIR-DAG: cir.global "private" constant external @_ZTVN5Test51CE = #cir.vtable<{
+// CIR-DAG: cir.global "private" constant external unnamed_addr @_ZTVN5Test51CE = #cir.vtable<{
// CIR-DAG: #cir.global_view<@_ZN5Test51C1hEv> : !cir.ptr<!u8i>
// CIR-DAG: #cir.global_view<@_ZThn8_N5Test51C1hEv> : !cir.ptr<!u8i>
// Test4 vtable: C's vtable references the thunk for B's entry.
-// CIR-DAG: cir.global "private" constant external @_ZTVN5Test41CE = #cir.vtable<{
+// CIR-DAG: cir.global "private" constant external unnamed_addr @_ZTVN5Test41CE = #cir.vtable<{
// CIR-DAG: #cir.global_view<@_ZN5Test41C1gEi> : !cir.ptr<!u8i>
// CIR-DAG: #cir.global_view<@_ZThn8_N5Test41C1gEi> : !cir.ptr<!u8i>
// Test3 vtable: D's vtable references D1, D0, and their thunks.
-// CIR-DAG: cir.global "private" constant external @_ZTVN5Test31DE = #cir.vtable<{
+// CIR-DAG: cir.global "private" constant external unnamed_addr @_ZTVN5Test31DE = #cir.vtable<{
// CIR-DAG: #cir.global_view<@_ZN5Test31DD1Ev> : !cir.ptr<!u8i>
// CIR-DAG: #cir.global_view<@_ZN5Test31DD0Ev> : !cir.ptr<!u8i>
// CIR-DAG: #cir.global_view<@_ZThn8_N5Test31DD1Ev> : !cir.ptr<!u8i>
@@ -282,27 +282,27 @@ void C::f(int x, ...) {}
// --- LLVM checks ---
-// LLVM: @_ZTVN5Test11CE = constant { [3 x ptr], [3 x ptr] } {
+// LLVM: @_ZTVN5Test11CE = unnamed_addr constant { [3 x ptr], [3 x ptr] } {
// LLVM-SAME: [3 x ptr] [ptr null, ptr null, ptr @_ZN5Test11C1fEv],
// LLVM-SAME: [3 x ptr] [ptr inttoptr (i64 -8 to ptr), ptr null, ptr @_ZThn8_N5Test11C1fEv]
// LLVM-SAME: }
-// LLVM: @_ZTVN5Test21CE = constant { [3 x ptr], [3 x ptr] } {
+// LLVM: @_ZTVN5Test21CE = unnamed_addr constant { [3 x ptr], [3 x ptr] } {
// LLVM-SAME: [3 x ptr] [ptr null, ptr null, ptr @_ZN5Test21C1gEv],
// LLVM-SAME: [3 x ptr] [ptr inttoptr (i64 -8 to ptr), ptr null, ptr @_ZThn8_N5Test21C1gEv]
// LLVM-SAME: }
-// LLVM: @_ZTVN5Test31DE = constant { [4 x ptr], [4 x ptr] } {
+// LLVM: @_ZTVN5Test31DE = unnamed_addr constant { [4 x ptr], [4 x ptr] } {
// LLVM-SAME: [4 x ptr] [ptr null, ptr null, ptr @_ZN5Test31DD1Ev, ptr @_ZN5Test31DD0Ev],
// LLVM-SAME: [4 x ptr] [ptr inttoptr (i64 -8 to ptr), ptr null, ptr @_ZThn8_N5Test31DD1Ev, ptr @_ZThn8_N5Test31DD0Ev]
// LLVM-SAME: }
-// LLVM: @_ZTVN5Test41CE = constant { [4 x ptr], [3 x ptr] } {
+// LLVM: @_ZTVN5Test41CE = unnamed_addr constant { [4 x ptr], [3 x ptr] } {
// LLVM-SAME: [4 x ptr] [ptr null, ptr null, ptr @_ZN5Test41A1fEv, ptr @_ZN5Test41C1gEi],
// LLVM-SAME: [3 x ptr] [ptr inttoptr (i64 -8 to ptr), ptr null, ptr @_ZThn8_N5Test41C1gEi]
// LLVM-SAME: }
-// LLVM: @_ZTVN5Test51CE = constant { [3 x ptr], [3 x ptr] } {
+// LLVM: @_ZTVN5Test51CE = unnamed_addr constant { [3 x ptr], [3 x ptr] } {
// LLVM-SAME: [3 x ptr] [ptr null, ptr null, ptr @_ZN5Test51C1hEv],
// LLVM-SAME: [3 x ptr] [ptr inttoptr (i64 -8 to ptr), ptr null, ptr @_ZThn8_N5Test51C1hEv]
// LLVM-SAME: }
diff --git a/clang/test/CIR/CodeGen/vtable-emission.cpp b/clang/test/CIR/CodeGen/vtable-emission.cpp
index 814e88fad6ecbb..b91653d113fd8d 100644
--- a/clang/test/CIR/CodeGen/vtable-emission.cpp
+++ b/clang/test/CIR/CodeGen/vtable-emission.cpp
@@ -18,7 +18,7 @@ void S::key() {}
// CHECK-DAG: !rec_anon_struct = !cir.struct<{data !cir.array<!cir.ptr<!u8i> x 4>}>
// The definition of the key function should result in the vtable being emitted.
-// CHECK: cir.global "private" constant external @_ZTV1S = #cir.vtable<{
+// CHECK: cir.global "private" constant external unnamed_addr @_ZTV1S = #cir.vtable<{
// CHECK-SAME: #cir.const_array<[
// CHECK-SAME: #cir.ptr<null> : !cir.ptr<!u8i>,
// CHECK-SAME: #cir.ptr<null> : !cir.ptr<!u8i>,
diff --git a/clang/test/CIR/CodeGen/vtable-thunk-undefined-callee.cpp b/clang/test/CIR/CodeGen/vtable-thunk-undefined-callee.cpp
index 09b838ccf03e51..b2f85dc6db6ada 100644
--- a/clang/test/CIR/CodeGen/vtable-thunk-undefined-callee.cpp
+++ b/clang/test/CIR/CodeGen/vtable-thunk-undefined-callee.cpp
@@ -22,7 +22,7 @@ int Derived::f(int x) { return x; }
// The Middle-in-Derived construction vtable reaches Right::f through a virtual
// thunk, and this translation unit only declares Right::f.
-// CIR: cir.global "private" constant external @_ZTCN23ConstructionVTableThunk7DerivedE0_NS_6MiddleE = #cir.vtable<{{{.*}}#cir.global_view<@_ZTv0_n24_N23ConstructionVTableThunk5Right1fEi>
+// CIR: cir.global "private" constant external unnamed_addr @_ZTCN23ConstructionVTableThunk7DerivedE0_NS_6MiddleE = #cir.vtable<{{{.*}}#cir.global_view<@_ZTv0_n24_N23ConstructionVTableThunk5Right1fEi>
// Emitting that thunk creates the Right::f declaration on demand. It must
// become a sibling of the thunk rather than nesting inside its body, so the
diff --git a/clang/test/CIR/CodeGen/vtt.cpp b/clang/test/CIR/CodeGen/vtt.cpp
index 4b7f605edc8534..4f1d6b262ab393 100644
--- a/clang/test/CIR/CodeGen/vtt.cpp
+++ b/clang/test/CIR/CodeGen/vtt.cpp
@@ -85,7 +85,8 @@ void D::y() {}
// CIR-COMMON-SAME: ]> : !cir.array<!cir.ptr<!u8i> x 4>
// CIR-COMMON-SAME: }> : ![[REC_D_VTABLE]] align(8)
-// LLVM-COMMON: @_ZTV1D = constant { [5 x ptr], [4 x ptr], [4 x ptr] } {
+// LLVM-NO-RTTI: @_ZTV1D = unnamed_addr constant { [5 x ptr], [4 x ptr], [4 x ptr] } {
+// LLVM-RTTI: @_ZTV1D = constant { [5 x ptr], [4 x ptr], [4 x ptr] } {
// LLVM-NO-RTTI-SAME: [5 x ptr] [ptr inttoptr (i64 40 to ptr), ptr null, ptr null, ptr @_ZN1B1wEv, ptr @_ZN1D1yEv],
// LLVM-RTTI-SAME: [5 x ptr] [ptr inttoptr (i64 40 to ptr), ptr null, ptr @_ZTI1D, ptr @_ZN1B1wEv, ptr @_ZN1D1yEv],
// LLVM-NO-RTTI-SAME: [4 x ptr] [ptr inttoptr (i64 24 to ptr), ptr inttoptr (i64 -16 to ptr), ptr null, ptr @_ZN1C1xEv],
@@ -155,7 +156,8 @@ void D::y() {}
// CIR-COMMON-SAME: ]> : !cir.array<!cir.ptr<!u8i> x 4>
// CIR-COMMON-SAME: }> : ![[REC_B_OR_C_IN_D_VTABLE]]
-// LLVM-COMMON: @_ZTC1D0_1B = constant { [4 x ptr], [4 x ptr] } {
+// LLVM-NO-RTTI: @_ZTC1D0_1B = unnamed_addr constant { [4 x ptr], [4 x ptr] } {
+// LLVM-RTTI: @_ZTC1D0_1B = constant { [4 x ptr], [4 x ptr] } {
// LLVM-NO-RTTI-SAME: [4 x ptr] [ptr inttoptr (i64 40 to ptr), ptr null, ptr null, ptr @_ZN1B1wEv],
// LLVM-RTTI-SAME: [4 x ptr] [ptr inttoptr (i64 40 to ptr), ptr null, ptr @_ZTI1B, ptr @_ZN1B1wEv],
// LLVM-NO-RTTI-SAME: [4 x ptr] [ptr null, ptr inttoptr (i64 -40 to ptr), ptr null, ptr @_ZN1A1vEv]
@@ -194,7 +196,8 @@ void D::y() {}
// CIR-COMMON-SAME: ]> : !cir.array<!cir.ptr<!u8i> x 4>}>
// CIR-COMMON-SAME: : ![[REC_B_OR_C_IN_D_VTABLE]]
-// LLVM-COMMON: @_ZTC1D16_1C = constant { [4 x ptr], [4 x ptr] } {
+// LLVM-NO-RTTI: @_ZTC1D16_1C = unnamed_addr constant { [4 x ptr], [4 x ptr] } {
+// LLVM-RTTI: @_ZTC1D16_1C = constant { [4 x ptr], [4 x ptr] } {
// LLVM-NO-RTTI-SAME: [4 x ptr] [ptr inttoptr (i64 24 to ptr), ptr null, ptr null, ptr @_ZN1C1xEv],
// LLVM-RTTI-SAME: [4 x ptr] [ptr inttoptr (i64 24 to ptr), ptr null, ptr @_ZTI1C, ptr @_ZN1C1xEv],
// LLVM-NO-RTTI-SAME: [4 x ptr] [ptr null, ptr inttoptr (i64 -24 to ptr), ptr null, ptr @_ZN1A1vEv]
diff --git a/clang/test/CIR/CodeGenCXX/vtable-unnamed-addr.cpp b/clang/test/CIR/CodeGenCXX/vtable-unnamed-addr.cpp
new file mode 100644
index 00000000000000..f79cafda394b35
--- /dev/null
+++ b/clang/test/CIR/CodeGenCXX/vtable-unnamed-addr.cpp
@@ -0,0 +1,68 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++17 -fclangir -emit-cir %s -o %t.cir
+// RUN: FileCheck --check-prefix=CIR-ELF --input-file=%t.cir %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++17 -fclangir -emit-llvm %s -o %t-cir.ll
+// RUN: FileCheck --check-prefix=LLVM-ELF --input-file=%t-cir.ll %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++17 -emit-llvm %s -o %t.ll
+// RUN: FileCheck --check-prefix=LLVM-ELF --input-file=%t.ll %s
+
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++17 -fno-rtti -fclangir -emit-cir %s -o %t-nortti.cir
+// RUN: FileCheck --check-prefix=CIR-NORTTI --input-file=%t-nortti.cir %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++17 -fno-rtti -fclangir -emit-llvm %s -o %t-nortti-cir.ll
+// RUN: FileCheck --check-prefix=LLVM-NORTTI --input-file=%t-nortti-cir.ll %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++17 -fno-rtti -emit-llvm %s -o %t-nortti.ll
+// RUN: FileCheck --check-prefix=LLVM-NORTTI --input-file=%t-nortti.ll %s
+
+// RUN: %clang_cc1 -triple arm64-apple-macosx14.0.0 -std=c++17 -fclangir -emit-cir %s -o %t-darwin.cir
+// RUN: FileCheck --check-prefix=CIR-DARWIN --input-file=%t-darwin.cir %s
+// RUN: %clang_cc1 -triple arm64-apple-macosx14.0.0 -std=c++17 -fclangir -emit-llvm %s -o %t-darwin-cir.ll
+// RUN: FileCheck --check-prefix=LLVM-DARWIN --input-file=%t-darwin-cir.ll %s
+// RUN: %clang_cc1 -triple arm64-apple-macosx14.0.0 -std=c++17 -emit-llvm %s -o %t-darwin.ll
+// RUN: FileCheck --check-prefix=LLVM-DARWIN --input-file=%t-darwin.ll %s
+
+// A vtable is marked unnamed_addr when its address is insignificant: either
+// no RTTI is emitted (so dynamic_cast cannot rely on its address), or it has
+// weak linkage on a target (Mach-O) that may duplicate such vtables.
+
+// Strong vtable (key function defined in this TU).
+struct Key { virtual void f(); };
+void Key::f() {}
+
+// Weak (linkonce_odr) vtable.
+struct Weak { virtual void g() {} };
+
+// Construction vtables (_ZTC) come from a class with virtual bases.
+struct A { virtual void a() {} };
+struct B : virtual A { virtual void b() {} };
+struct C : virtual A { virtual void c() {} };
+struct D : B, C { void d(); };
+void D::d() {}
+
+void use() {
+ Weak w;
+ D x;
+}
+
+// With RTTI on ELF, vtable addresses are unique: no unnamed_addr.
+// CIR-ELF-DAG: cir.global "private" constant external @_ZTV3Key =
+// CIR-ELF-DAG: cir.global "private" constant linkonce_odr comdat @_ZTV4Weak =
+// CIR-ELF-DAG: cir.global "private" constant linkonce_odr comdat @_ZTC1D0_1B =
+// LLVM-ELF-DAG: @_ZTV3Key = constant
+// LLVM-ELF-DAG: @_ZTV4Weak = linkonce_odr constant
+// LLVM-ELF-DAG: @_ZTC1D0_1B = linkonce_odr constant
+
+// Without RTTI, every vtable is unnamed_addr.
+// CIR-NORTTI-DAG: cir.global "private" constant external unnamed_addr @_ZTV3Key =
+// CIR-NORTTI-DAG: cir.global "private" constant linkonce_odr comdat unnamed_addr @_ZTV4Weak =
+// CIR-NORTTI-DAG: cir.global "private" constant linkonce_odr comdat unnamed_addr @_ZTC1D0_1B =
+// LLVM-NORTTI-DAG: @_ZTV3Key = unnamed_addr constant
+// LLVM-NORTTI-DAG: @_ZTV4Weak = linkonce_odr unnamed_addr constant
+// LLVM-NORTTI-DAG: @_ZTC1D0_1B = linkonce_odr unnamed_addr constant
+
+// On Darwin, weak vtables may be duplicated, so they are unnamed_addr even with
+// RTTI; the strong vtable keeps a unique address.
+// CIR-DARWIN-DAG: cir.global "private" constant external @_ZTV3Key =
+// CIR-DARWIN-DAG: cir.global "private" constant linkonce_odr unnamed_addr @_ZTV4Weak =
+// CIR-DARWIN-DAG: cir.global "private" constant linkonce_odr unnamed_addr @_ZTC1D0_1B =
+// LLVM-DARWIN-DAG: @_ZTV3Key = constant
+// LLVM-DARWIN-DAG: @_ZTV4Weak = linkonce_odr unnamed_addr constant
+// LLVM-DARWIN-DAG: @_ZTC1D0_1B = linkonce_odr unnamed_addr constant
More information about the cfe-commits
mailing list