[clang] [ItaniumCXXABI] Mark RTTI type name as global unnamed_addr (PR #111343)

via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 10 06:01:55 PDT 2024


https://github.com/luxufan updated https://github.com/llvm/llvm-project/pull/111343

>From cabe9e1ac1305d970d944183ebf10effe783f5fc Mon Sep 17 00:00:00 2001
From: luxufan <luxufan981014 at gmail.com>
Date: Mon, 7 Oct 2024 07:14:06 +0000
Subject: [PATCH 1/4] [ItaniumCXXABI] Mark RTTI type name as global
 unnamed_addr

The RTTI type name global variable should be marked as global
unnamed_addr since the address of RTTI type name global variable
 is not significant.
---
 clang/lib/CodeGen/ItaniumCXXABI.cpp                |  1 +
 clang/test/CodeGen/split-lto-unit-input.cpp        |  4 ++--
 .../RelativeVTablesABI/parent-vtable-in-comdat.cpp |  2 +-
 clang/test/CodeGenCXX/anonymous-namespaces.cpp     |  2 +-
 clang/test/CodeGenCXX/arm64.cpp                    | 12 ++++++------
 clang/test/CodeGenCXX/armv7k.cpp                   | 14 ++++----------
 .../test/CodeGenCXX/windows-itanium-type-info.cpp  | 14 ++++----------
 7 files changed, 19 insertions(+), 30 deletions(-)

diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp
index 965e09a7a760ec..4b9cd70ce4d55d 100644
--- a/clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -3532,6 +3532,7 @@ llvm::GlobalVariable *ItaniumRTTIBuilder::GetAddrOfTypeName(
       Name, Init->getType(), Linkage, Align.getAsAlign());
 
   GV->setInitializer(Init);
+  GV->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
 
   return GV;
 }
diff --git a/clang/test/CodeGen/split-lto-unit-input.cpp b/clang/test/CodeGen/split-lto-unit-input.cpp
index adfc9ac3e0f446..99de0f68f84978 100644
--- a/clang/test/CodeGen/split-lto-unit-input.cpp
+++ b/clang/test/CodeGen/split-lto-unit-input.cpp
@@ -12,8 +12,8 @@
 // CHECK-NEXT: V _ZTV1A
 // CHECK-NEXT: V _ZTV1B
 
-// CHECK-IR-DAG: _ZTS1B = linkonce_odr constant
-// CHECK-IR-DAG: _ZTS1A = linkonce_odr constant
+// CHECK-IR-DAG: _ZTS1B = linkonce_odr unnamed_addr constant
+// CHECK-IR-DAG: _ZTS1A = linkonce_odr unnamed_addr constant
 // CHECK-IR-DAG: _ZTV1B = linkonce_odr unnamed_addr constant
 // CHECK-IR-DAG: _ZTI1A = linkonce_odr constant
 // CHECK-IR-DAG: _ZTI1B = linkonce_odr constant
diff --git a/clang/test/CodeGenCXX/RelativeVTablesABI/parent-vtable-in-comdat.cpp b/clang/test/CodeGenCXX/RelativeVTablesABI/parent-vtable-in-comdat.cpp
index 341c53146d476d..6a833cf3884546 100644
--- a/clang/test/CodeGenCXX/RelativeVTablesABI/parent-vtable-in-comdat.cpp
+++ b/clang/test/CodeGenCXX/RelativeVTablesABI/parent-vtable-in-comdat.cpp
@@ -16,7 +16,7 @@
 // The VTable for A is emitted here and in a comdat section since it has no key function, and is used in this module when creating an instance of A.
 // CHECK: @_ZTV1A.local = linkonce_odr hidden unnamed_addr constant { [3 x i32] } { [3 x i32] [i32 0, i32 trunc (i64 sub (i64 ptrtoint (ptr @_ZTI1A.rtti_proxy to i64), i64 ptrtoint (ptr getelementptr inbounds ({ [3 x i32] }, ptr @_ZTV1A.local, i32 0, i32 0, i32 2) to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (ptr dso_local_equivalent @_ZN1A3fooEv to i64), i64 ptrtoint (ptr getelementptr inbounds ({ [3 x i32] }, ptr @_ZTV1A.local, i32 0, i32 0, i32 2) to i64)) to i32)] }, comdat($_ZTV1A), align 4
 // CHECK: @_ZTVN10__cxxabiv117__class_type_infoE = external global [0 x ptr]
-// CHECK: @_ZTS1A = linkonce_odr constant [3 x i8] c"1A\00", comdat, align 1
+// CHECK: @_ZTS1A = linkonce_odr unnamed_addr constant [3 x i8] c"1A\00", comdat, align 1
 // CHECK: @_ZTI1A = linkonce_odr constant { ptr, ptr } { ptr getelementptr inbounds (i8, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i32 8), ptr @_ZTS1A }, comdat, align 8
 // CHECK: @_ZTI1A.rtti_proxy = linkonce_odr hidden unnamed_addr constant ptr @_ZTI1A, comdat
 // CHECK: @_ZTV1A = linkonce_odr unnamed_addr alias { [3 x i32] }, ptr @_ZTV1A.local
diff --git a/clang/test/CodeGenCXX/anonymous-namespaces.cpp b/clang/test/CodeGenCXX/anonymous-namespaces.cpp
index f40039c2a4f400..eb185be52c15a4 100644
--- a/clang/test/CodeGenCXX/anonymous-namespaces.cpp
+++ b/clang/test/CodeGenCXX/anonymous-namespaces.cpp
@@ -29,7 +29,7 @@ namespace {
   int D::d = f();
 
   // Check for generation of a VTT with internal linkage
-  // CHECK-1: @_ZTSN12_GLOBAL__N_11X1EE = internal constant
+  // CHECK-1: @_ZTSN12_GLOBAL__N_11X1EE = internal unnamed_addr constant
   struct X { 
     struct EBase { };
     struct E : public virtual EBase { virtual ~E() {} };
diff --git a/clang/test/CodeGenCXX/arm64.cpp b/clang/test/CodeGenCXX/arm64.cpp
index 338b7db9e001f2..f452cf9a8b5072 100644
--- a/clang/test/CodeGenCXX/arm64.cpp
+++ b/clang/test/CodeGenCXX/arm64.cpp
@@ -48,20 +48,20 @@ namespace test2 {
 
   struct __attribute__((visibility("hidden"))) B {};
   const std::type_info &b0 = typeid(B);
-  // CHECK-GLOBALS-DAG: @_ZTSN5test21BE = linkonce_odr hidden constant
+  // CHECK-GLOBALS-DAG: @_ZTSN5test21BE = linkonce_odr hidden unnamed_addr constant
   // CHECK-GLOBALS-DAG: @_ZTIN5test21BE = linkonce_odr hidden constant { {{.*}}, ptr @_ZTSN5test21BE }
 
   const std::type_info &b1 = typeid(B*);
-  // CHECK-GLOBALS-DAG: @_ZTSPN5test21BE = linkonce_odr hidden constant
+  // CHECK-GLOBALS-DAG: @_ZTSPN5test21BE = linkonce_odr hidden unnamed_addr constant
   // CHECK-GLOBALS-DAG: @_ZTIPN5test21BE = linkonce_odr hidden constant { {{.*}}, ptr @_ZTSPN5test21BE, i32 0, ptr @_ZTIN5test21BE
 
   struct C {};
   const std::type_info &c0 = typeid(C);
-  // CHECK-GLOBALS-DAG: @_ZTSN5test21CE = linkonce_odr hidden constant
+  // CHECK-GLOBALS-DAG: @_ZTSN5test21CE = linkonce_odr hidden unnamed_addr constant
   // CHECK-GLOBALS-DAG: @_ZTIN5test21CE = linkonce_odr hidden constant { {{.*}}, ptr inttoptr (i64 add (i64 ptrtoint (ptr @_ZTSN5test21CE to i64), i64 -9223372036854775808) to ptr) }
 
   const std::type_info &c1 = typeid(C*);
-  // CHECK-GLOBALS-DAG: @_ZTSPN5test21CE = linkonce_odr hidden constant
+  // CHECK-GLOBALS-DAG: @_ZTSPN5test21CE = linkonce_odr hidden unnamed_addr constant
   // CHECK-GLOBALS-DAG: @_ZTIPN5test21CE = linkonce_odr hidden constant { {{.*}}, ptr inttoptr (i64 add (i64 ptrtoint (ptr @_ZTSPN5test21CE to i64), i64 -9223372036854775808) to ptr), i32 0, ptr @_ZTIN5test21CE
 
   // This class is explicitly-instantiated, but that instantiation
@@ -69,7 +69,7 @@ namespace test2 {
   template <class T> class D {};
   template class D<int>;
   const std::type_info &d0 = typeid(D<int>);
-  // CHECK-GLOBALS-DAG: @_ZTSN5test21DIiEE = linkonce_odr hidden constant
+  // CHECK-GLOBALS-DAG: @_ZTSN5test21DIiEE = linkonce_odr hidden unnamed_addr constant
   // CHECK-GLOBALS-DAG: @_ZTIN5test21DIiEE = linkonce_odr hidden constant { {{.*}}, ptr inttoptr (i64 add (i64 ptrtoint (ptr @_ZTSN5test21DIiEE to i64), i64 -9223372036854775808) to ptr) }
 
   // This class is explicitly-instantiated and *does* guarantee to
@@ -78,7 +78,7 @@ namespace test2 {
     virtual void foo() {}
   };
   template class E<int>;
-  // CHECK-GLOBALS-DAG: @_ZTSN5test21EIiEE = weak_odr constant [14 x i8]
+  // CHECK-GLOBALS-DAG: @_ZTSN5test21EIiEE = weak_odr unnamed_addr constant [14 x i8]
   // CHECK-GLOBALS-DAG: @_ZTIN5test21EIiEE = weak_odr constant { {{.*}}, ptr inttoptr (i64 add (i64 ptrtoint (ptr @_ZTSN5test21EIiEE to i64), i64 -9223372036854775808) to ptr) }
 
 }
diff --git a/clang/test/CodeGenCXX/armv7k.cpp b/clang/test/CodeGenCXX/armv7k.cpp
index a4a243c162ea3f..a8496c85bc0733 100644
--- a/clang/test/CodeGenCXX/armv7k.cpp
+++ b/clang/test/CodeGenCXX/armv7k.cpp
@@ -1,3 +1,4 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5
 // RUN: %clang_cc1 %s -triple=thumbv7k-apple-watchos -emit-llvm -o - -target-abi aapcs16 | FileCheck %s
 // RUN: %clang_cc1 %s -triple=thumbv7k-apple-watchos -emit-llvm -o - -target-abi aapcs16 | FileCheck -check-prefix=CHECK-GLOBALS %s
 
@@ -10,7 +11,6 @@ struct A {
 };
 
 void f() {
-  // CHECK: call i32 @__cxa_guard_acquire(ptr
   static A a;
 }
 
@@ -31,8 +31,6 @@ namespace test1 {
   int test() {
     return sizeof(B);
   }
-  // CHECK: define{{.*}} i32 @_ZN5test14testEv()
-  // CHECK: ret i32 12
 }
 
 namespace std {
@@ -50,20 +48,16 @@ namespace test2 {
 
   struct __attribute__((visibility("hidden"))) B {};
   const std::type_info &b0 = typeid(B);
-  // CHECK-GLOBALS: @_ZTSN5test21BE = linkonce_odr hidden constant
-  // CHECK-GLOBALS: @_ZTIN5test21BE = linkonce_odr hidden constant { {{.*}}, ptr @_ZTSN5test21BE }
 
   const std::type_info &b1 = typeid(B*);
-  // CHECK-GLOBALS: @_ZTSPN5test21BE = linkonce_odr hidden constant
-  // CHECK-GLOBALS: @_ZTIPN5test21BE = linkonce_odr hidden constant { {{.*}}, ptr @_ZTSPN5test21BE, i32 0, ptr @_ZTIN5test21BE
 
   struct C {};
   const std::type_info &c0 = typeid(C);
-  // CHECK-GLOBALS: @_ZTSN5test21CE = linkonce_odr constant [11 x i8] c"N5test21CE\00"
-  // CHECK-GLOBALS: @_ZTIN5test21CE = linkonce_odr constant { {{.*}}, ptr @_ZTSN5test21CE }
 }
 
 // va_list should be based on "char *" rather than "ptr".
 
-// CHECK: define{{.*}} void @_Z11whatsVaListPc
 void whatsVaList(__builtin_va_list l) {}
+//// NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
+// CHECK: {{.*}}
+// CHECK-GLOBALS: {{.*}}
diff --git a/clang/test/CodeGenCXX/windows-itanium-type-info.cpp b/clang/test/CodeGenCXX/windows-itanium-type-info.cpp
index 20bd78df509837..709059cc7f06c6 100644
--- a/clang/test/CodeGenCXX/windows-itanium-type-info.cpp
+++ b/clang/test/CodeGenCXX/windows-itanium-type-info.cpp
@@ -1,3 +1,4 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5
 // RUN: %clang_cc1 -triple i686-windows-itanium -fdeclspec -fcxx-exceptions -emit-llvm %s -o - | FileCheck %s
 // RUN: %clang_cc1 -triple i686-windows-itanium -fdeclspec -fcxx-exceptions -fno-rtti -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-EH-IMPORT
 
@@ -24,17 +25,9 @@ void f() {
   throw base();
 }
 
-// CHECK-DAG: @_ZTIi = dso_local dllexport constant
-// CHECK-DAG: @_ZTSi = dso_local dllexport constant
 
-// CHECK-DAG: @_ZTI7derived = dso_local dllexport constant
-// CHECK-DAG: @_ZTS7derived = dso_local dllexport constant
-// CHECK-DAG: @_ZTV7derived = dso_local dllexport unnamed_addr constant
 
-// CHECK-DAG: @_ZTI4base = external dllimport constant
 
-// CHECK-EH-IMPORT: @_ZTS4base = linkonce_odr dso_local constant
-// CHECK-EH-IMPORT: @_ZTI4base = linkonce_odr dso_local constant
 
 struct __declspec(dllimport) gatekeeper {};
 struct zuul : gatekeeper {
@@ -42,5 +35,6 @@ struct zuul : gatekeeper {
 };
 zuul::~zuul() {}
 
-// CHECK-DAG: @_ZTI10gatekeeper = linkonce_odr dso_local constant
-// CHECK-DAG: @_ZTS10gatekeeper = linkonce_odr dso_local constant
+//// NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
+// CHECK: {{.*}}
+// CHECK-EH-IMPORT: {{.*}}

>From 08ced2b22304f3338440a180c5711cc505a1584f Mon Sep 17 00:00:00 2001
From: luxufan <luxufan981014 at gmail.com>
Date: Mon, 7 Oct 2024 08:08:44 +0000
Subject: [PATCH 2/4] restore test file

---
 clang/test/CodeGenCXX/armv7k.cpp | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/clang/test/CodeGenCXX/armv7k.cpp b/clang/test/CodeGenCXX/armv7k.cpp
index a8496c85bc0733..a4a243c162ea3f 100644
--- a/clang/test/CodeGenCXX/armv7k.cpp
+++ b/clang/test/CodeGenCXX/armv7k.cpp
@@ -1,4 +1,3 @@
-// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5
 // RUN: %clang_cc1 %s -triple=thumbv7k-apple-watchos -emit-llvm -o - -target-abi aapcs16 | FileCheck %s
 // RUN: %clang_cc1 %s -triple=thumbv7k-apple-watchos -emit-llvm -o - -target-abi aapcs16 | FileCheck -check-prefix=CHECK-GLOBALS %s
 
@@ -11,6 +10,7 @@ struct A {
 };
 
 void f() {
+  // CHECK: call i32 @__cxa_guard_acquire(ptr
   static A a;
 }
 
@@ -31,6 +31,8 @@ namespace test1 {
   int test() {
     return sizeof(B);
   }
+  // CHECK: define{{.*}} i32 @_ZN5test14testEv()
+  // CHECK: ret i32 12
 }
 
 namespace std {
@@ -48,16 +50,20 @@ namespace test2 {
 
   struct __attribute__((visibility("hidden"))) B {};
   const std::type_info &b0 = typeid(B);
+  // CHECK-GLOBALS: @_ZTSN5test21BE = linkonce_odr hidden constant
+  // CHECK-GLOBALS: @_ZTIN5test21BE = linkonce_odr hidden constant { {{.*}}, ptr @_ZTSN5test21BE }
 
   const std::type_info &b1 = typeid(B*);
+  // CHECK-GLOBALS: @_ZTSPN5test21BE = linkonce_odr hidden constant
+  // CHECK-GLOBALS: @_ZTIPN5test21BE = linkonce_odr hidden constant { {{.*}}, ptr @_ZTSPN5test21BE, i32 0, ptr @_ZTIN5test21BE
 
   struct C {};
   const std::type_info &c0 = typeid(C);
+  // CHECK-GLOBALS: @_ZTSN5test21CE = linkonce_odr constant [11 x i8] c"N5test21CE\00"
+  // CHECK-GLOBALS: @_ZTIN5test21CE = linkonce_odr constant { {{.*}}, ptr @_ZTSN5test21CE }
 }
 
 // va_list should be based on "char *" rather than "ptr".
 
+// CHECK: define{{.*}} void @_Z11whatsVaListPc
 void whatsVaList(__builtin_va_list l) {}
-//// NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
-// CHECK: {{.*}}
-// CHECK-GLOBALS: {{.*}}

>From 8b865cc807636ba1c08290c403eaefe555c4edcd Mon Sep 17 00:00:00 2001
From: luxufan <luxufan981014 at gmail.com>
Date: Mon, 7 Oct 2024 08:09:56 +0000
Subject: [PATCH 3/4] restore test file

---
 .../test/CodeGenCXX/windows-itanium-type-info.cpp  | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/clang/test/CodeGenCXX/windows-itanium-type-info.cpp b/clang/test/CodeGenCXX/windows-itanium-type-info.cpp
index 709059cc7f06c6..20bd78df509837 100644
--- a/clang/test/CodeGenCXX/windows-itanium-type-info.cpp
+++ b/clang/test/CodeGenCXX/windows-itanium-type-info.cpp
@@ -1,4 +1,3 @@
-// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5
 // RUN: %clang_cc1 -triple i686-windows-itanium -fdeclspec -fcxx-exceptions -emit-llvm %s -o - | FileCheck %s
 // RUN: %clang_cc1 -triple i686-windows-itanium -fdeclspec -fcxx-exceptions -fno-rtti -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-EH-IMPORT
 
@@ -25,9 +24,17 @@ void f() {
   throw base();
 }
 
+// CHECK-DAG: @_ZTIi = dso_local dllexport constant
+// CHECK-DAG: @_ZTSi = dso_local dllexport constant
 
+// CHECK-DAG: @_ZTI7derived = dso_local dllexport constant
+// CHECK-DAG: @_ZTS7derived = dso_local dllexport constant
+// CHECK-DAG: @_ZTV7derived = dso_local dllexport unnamed_addr constant
 
+// CHECK-DAG: @_ZTI4base = external dllimport constant
 
+// CHECK-EH-IMPORT: @_ZTS4base = linkonce_odr dso_local constant
+// CHECK-EH-IMPORT: @_ZTI4base = linkonce_odr dso_local constant
 
 struct __declspec(dllimport) gatekeeper {};
 struct zuul : gatekeeper {
@@ -35,6 +42,5 @@ struct zuul : gatekeeper {
 };
 zuul::~zuul() {}
 
-//// NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
-// CHECK: {{.*}}
-// CHECK-EH-IMPORT: {{.*}}
+// CHECK-DAG: @_ZTI10gatekeeper = linkonce_odr dso_local constant
+// CHECK-DAG: @_ZTS10gatekeeper = linkonce_odr dso_local constant

>From 568cc74a784708c9eb42958e500564933dd12147 Mon Sep 17 00:00:00 2001
From: Xufan Lu <luxufan at ulam.inesc-id.pt>
Date: Thu, 10 Oct 2024 14:01:24 +0100
Subject: [PATCH 4/4] Mark unnamed_addr if no RTTI uniqueness otherwise
 local_unnamed_addr

---
 clang/lib/CodeGen/ItaniumCXXABI.cpp           |  8 ++++++--
 clang/test/CodeGen/split-lto-unit-input.cpp   |  8 ++++----
 .../parent-vtable-in-comdat.cpp               |  6 +++---
 .../test/CodeGenCXX/anonymous-namespaces.cpp  |  2 +-
 clang/test/CodeGenCXX/arm64.cpp               | 20 +++++++++----------
 5 files changed, 24 insertions(+), 20 deletions(-)

diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp
index 4b9cd70ce4d55d..542a50780d45af 100644
--- a/clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -3532,8 +3532,6 @@ llvm::GlobalVariable *ItaniumRTTIBuilder::GetAddrOfTypeName(
       Name, Init->getType(), Linkage, Align.getAsAlign());
 
   GV->setInitializer(Init);
-  GV->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
-
   return GV;
 }
 
@@ -4098,6 +4096,7 @@ llvm::Constant *ItaniumRTTIBuilder::BuildTypeInfo(
   // And the name.
   llvm::GlobalVariable *TypeName = GetAddrOfTypeName(Ty, Linkage);
   llvm::Constant *TypeNameField;
+  llvm::GlobalValue::UnnamedAddr Scope;
 
   // If we're supposed to demote the visibility, be sure to set a flag
   // to use a string comparison for type_info comparisons.
@@ -4112,8 +4111,10 @@ llvm::Constant *ItaniumRTTIBuilder::BuildTypeInfo(
     TypeNameField = llvm::ConstantExpr::getAdd(TypeNameField, flag);
     TypeNameField =
         llvm::ConstantExpr::getIntToPtr(TypeNameField, CGM.GlobalsInt8PtrTy);
+    Scope = llvm::GlobalValue::UnnamedAddr::Global;
   } else {
     TypeNameField = TypeName;
+    Scope = llvm::GlobalValue::UnnamedAddr::Local;
   }
   Fields.push_back(TypeNameField);
 
@@ -4272,6 +4273,9 @@ llvm::Constant *ItaniumRTTIBuilder::BuildTypeInfo(
   TypeName->setPartition(CGM.getCodeGenOpts().SymbolPartition);
   GV->setPartition(CGM.getCodeGenOpts().SymbolPartition);
 
+  TypeName->setUnnamedAddr(Scope);
+  GV->setUnnamedAddr(Scope);
+
   return GV;
 }
 
diff --git a/clang/test/CodeGen/split-lto-unit-input.cpp b/clang/test/CodeGen/split-lto-unit-input.cpp
index 99de0f68f84978..a641f18d804262 100644
--- a/clang/test/CodeGen/split-lto-unit-input.cpp
+++ b/clang/test/CodeGen/split-lto-unit-input.cpp
@@ -12,11 +12,11 @@
 // CHECK-NEXT: V _ZTV1A
 // CHECK-NEXT: V _ZTV1B
 
-// CHECK-IR-DAG: _ZTS1B = linkonce_odr unnamed_addr constant
-// CHECK-IR-DAG: _ZTS1A = linkonce_odr unnamed_addr constant
+// CHECK-IR-DAG: _ZTS1B = linkonce_odr local_unnamed_addr constant
+// CHECK-IR-DAG: _ZTS1A = linkonce_odr local_unnamed_addr constant
 // CHECK-IR-DAG: _ZTV1B = linkonce_odr unnamed_addr constant
-// CHECK-IR-DAG: _ZTI1A = linkonce_odr constant
-// CHECK-IR-DAG: _ZTI1B = linkonce_odr constant
+// CHECK-IR-DAG: _ZTI1A = linkonce_odr local_unnamed_addr constant
+// CHECK-IR-DAG: _ZTI1B = linkonce_odr local_unnamed_addr constant
 // CHECK-IR-DAG: _ZTV1A = linkonce_odr unnamed_addr constant
 
 struct A {
diff --git a/clang/test/CodeGenCXX/RelativeVTablesABI/parent-vtable-in-comdat.cpp b/clang/test/CodeGenCXX/RelativeVTablesABI/parent-vtable-in-comdat.cpp
index 6a833cf3884546..a7320b014233c0 100644
--- a/clang/test/CodeGenCXX/RelativeVTablesABI/parent-vtable-in-comdat.cpp
+++ b/clang/test/CodeGenCXX/RelativeVTablesABI/parent-vtable-in-comdat.cpp
@@ -1,8 +1,8 @@
 // Cross comdat example
 // Parent VTable is in a comdat section.
 
-// RUN: %clang_cc1 %s -triple=aarch64 -o - -emit-llvm -fexperimental-relative-c++-abi-vtables | FileCheck %s
 // RUN: %clang_cc1 %s -triple=x86_64 -o - -emit-llvm -fexperimental-relative-c++-abi-vtables | FileCheck %s
+// RUN: %clang_cc1 %s -triple=aarch64 -o - -emit-llvm -fexperimental-relative-c++-abi-vtables | FileCheck %s
 
 // A::foo() has a comdat since it is an inline function
 // CHECK: $_ZN1A3fooEv = comdat any
@@ -16,8 +16,8 @@
 // The VTable for A is emitted here and in a comdat section since it has no key function, and is used in this module when creating an instance of A.
 // CHECK: @_ZTV1A.local = linkonce_odr hidden unnamed_addr constant { [3 x i32] } { [3 x i32] [i32 0, i32 trunc (i64 sub (i64 ptrtoint (ptr @_ZTI1A.rtti_proxy to i64), i64 ptrtoint (ptr getelementptr inbounds ({ [3 x i32] }, ptr @_ZTV1A.local, i32 0, i32 0, i32 2) to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (ptr dso_local_equivalent @_ZN1A3fooEv to i64), i64 ptrtoint (ptr getelementptr inbounds ({ [3 x i32] }, ptr @_ZTV1A.local, i32 0, i32 0, i32 2) to i64)) to i32)] }, comdat($_ZTV1A), align 4
 // CHECK: @_ZTVN10__cxxabiv117__class_type_infoE = external global [0 x ptr]
-// CHECK: @_ZTS1A = linkonce_odr unnamed_addr constant [3 x i8] c"1A\00", comdat, align 1
-// CHECK: @_ZTI1A = linkonce_odr constant { ptr, ptr } { ptr getelementptr inbounds (i8, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i32 8), ptr @_ZTS1A }, comdat, align 8
+// CHECK: @_ZTS1A = linkonce_odr local_unnamed_addr constant [3 x i8] c"1A\00", comdat, align 1
+// CHECK: @_ZTI1A = linkonce_odr local_unnamed_addr constant { ptr, ptr } { ptr getelementptr inbounds (i8, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i32 8), ptr @_ZTS1A }, comdat, align 8
 // CHECK: @_ZTI1A.rtti_proxy = linkonce_odr hidden unnamed_addr constant ptr @_ZTI1A, comdat
 // CHECK: @_ZTV1A = linkonce_odr unnamed_addr alias { [3 x i32] }, ptr @_ZTV1A.local
 
diff --git a/clang/test/CodeGenCXX/anonymous-namespaces.cpp b/clang/test/CodeGenCXX/anonymous-namespaces.cpp
index eb185be52c15a4..d5cf6d9f62648e 100644
--- a/clang/test/CodeGenCXX/anonymous-namespaces.cpp
+++ b/clang/test/CodeGenCXX/anonymous-namespaces.cpp
@@ -29,7 +29,7 @@ namespace {
   int D::d = f();
 
   // Check for generation of a VTT with internal linkage
-  // CHECK-1: @_ZTSN12_GLOBAL__N_11X1EE = internal unnamed_addr constant
+  // CHECK-1: @_ZTSN12_GLOBAL__N_11X1EE = internal local_unnamed_addr constant
   struct X { 
     struct EBase { };
     struct E : public virtual EBase { virtual ~E() {} };
diff --git a/clang/test/CodeGenCXX/arm64.cpp b/clang/test/CodeGenCXX/arm64.cpp
index f452cf9a8b5072..17e5d52de6b7ef 100644
--- a/clang/test/CodeGenCXX/arm64.cpp
+++ b/clang/test/CodeGenCXX/arm64.cpp
@@ -43,26 +43,26 @@ namespace test2 {
     virtual void foo();
   };
   void A::foo() {}
-  // CHECK-GLOBALS-DAG: @_ZTSN5test21AE ={{.*}} constant [11 x i8]
-  // CHECK-GLOBALS-DAG: @_ZTIN5test21AE ={{.*}} constant { {{.*}}, ptr @_ZTSN5test21AE }
+  // CHECK-GLOBALS-DAG: @_ZTSN5test21AE ={{.*}} local_unnamed_addr constant [11 x i8]
+  // CHECK-GLOBALS-DAG: @_ZTIN5test21AE ={{.*}} local_unnamed_addr constant { {{.*}}, ptr @_ZTSN5test21AE }
 
   struct __attribute__((visibility("hidden"))) B {};
   const std::type_info &b0 = typeid(B);
-  // CHECK-GLOBALS-DAG: @_ZTSN5test21BE = linkonce_odr hidden unnamed_addr constant
-  // CHECK-GLOBALS-DAG: @_ZTIN5test21BE = linkonce_odr hidden constant { {{.*}}, ptr @_ZTSN5test21BE }
+  // CHECK-GLOBALS-DAG: @_ZTSN5test21BE = linkonce_odr hidden local_unnamed_addr constant
+  // CHECK-GLOBALS-DAG: @_ZTIN5test21BE = linkonce_odr hidden local_unnamed_addr constant { {{.*}}, ptr @_ZTSN5test21BE }
 
   const std::type_info &b1 = typeid(B*);
-  // CHECK-GLOBALS-DAG: @_ZTSPN5test21BE = linkonce_odr hidden unnamed_addr constant
-  // CHECK-GLOBALS-DAG: @_ZTIPN5test21BE = linkonce_odr hidden constant { {{.*}}, ptr @_ZTSPN5test21BE, i32 0, ptr @_ZTIN5test21BE
+  // CHECK-GLOBALS-DAG: @_ZTSPN5test21BE = linkonce_odr hidden local_unnamed_addr constant
+  // CHECK-GLOBALS-DAG: @_ZTIPN5test21BE = linkonce_odr hidden local_unnamed_addr constant { {{.*}}, ptr @_ZTSPN5test21BE, i32 0, ptr @_ZTIN5test21BE
 
   struct C {};
   const std::type_info &c0 = typeid(C);
   // CHECK-GLOBALS-DAG: @_ZTSN5test21CE = linkonce_odr hidden unnamed_addr constant
-  // CHECK-GLOBALS-DAG: @_ZTIN5test21CE = linkonce_odr hidden constant { {{.*}}, ptr inttoptr (i64 add (i64 ptrtoint (ptr @_ZTSN5test21CE to i64), i64 -9223372036854775808) to ptr) }
+  // CHECK-GLOBALS-DAG: @_ZTIN5test21CE = linkonce_odr hidden unnamed_addr constant { {{.*}}, ptr inttoptr (i64 add (i64 ptrtoint (ptr @_ZTSN5test21CE to i64), i64 -9223372036854775808) to ptr) }
 
   const std::type_info &c1 = typeid(C*);
   // CHECK-GLOBALS-DAG: @_ZTSPN5test21CE = linkonce_odr hidden unnamed_addr constant
-  // CHECK-GLOBALS-DAG: @_ZTIPN5test21CE = linkonce_odr hidden constant { {{.*}}, ptr inttoptr (i64 add (i64 ptrtoint (ptr @_ZTSPN5test21CE to i64), i64 -9223372036854775808) to ptr), i32 0, ptr @_ZTIN5test21CE
+  // CHECK-GLOBALS-DAG: @_ZTIPN5test21CE = linkonce_odr hidden unnamed_addr constant { {{.*}}, ptr inttoptr (i64 add (i64 ptrtoint (ptr @_ZTSPN5test21CE to i64), i64 -9223372036854775808) to ptr), i32 0, ptr @_ZTIN5test21CE
 
   // This class is explicitly-instantiated, but that instantiation
   // doesn't guarantee to emit RTTI, so we can still demote the visibility.
@@ -70,7 +70,7 @@ namespace test2 {
   template class D<int>;
   const std::type_info &d0 = typeid(D<int>);
   // CHECK-GLOBALS-DAG: @_ZTSN5test21DIiEE = linkonce_odr hidden unnamed_addr constant
-  // CHECK-GLOBALS-DAG: @_ZTIN5test21DIiEE = linkonce_odr hidden constant { {{.*}}, ptr inttoptr (i64 add (i64 ptrtoint (ptr @_ZTSN5test21DIiEE to i64), i64 -9223372036854775808) to ptr) }
+  // CHECK-GLOBALS-DAG: @_ZTIN5test21DIiEE = linkonce_odr hidden unnamed_addr constant { {{.*}}, ptr inttoptr (i64 add (i64 ptrtoint (ptr @_ZTSN5test21DIiEE to i64), i64 -9223372036854775808) to ptr) }
 
   // This class is explicitly-instantiated and *does* guarantee to
   // emit RTTI, so we're stuck with having to use default visibility.
@@ -79,7 +79,7 @@ namespace test2 {
   };
   template class E<int>;
   // CHECK-GLOBALS-DAG: @_ZTSN5test21EIiEE = weak_odr unnamed_addr constant [14 x i8]
-  // CHECK-GLOBALS-DAG: @_ZTIN5test21EIiEE = weak_odr constant { {{.*}}, ptr inttoptr (i64 add (i64 ptrtoint (ptr @_ZTSN5test21EIiEE to i64), i64 -9223372036854775808) to ptr) }
+  // CHECK-GLOBALS-DAG: @_ZTIN5test21EIiEE = weak_odr unnamed_addr constant { {{.*}}, ptr inttoptr (i64 add (i64 ptrtoint (ptr @_ZTSN5test21EIiEE to i64), i64 -9223372036854775808) to ptr) }
 
 }
 



More information about the cfe-commits mailing list