[clang] [llvm] [PAC] Fix address discrimination for type info vtable pointers (PR #102199)

Daniil Kovalev via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 17 03:34:19 PDT 2024


https://github.com/kovdan01 updated https://github.com/llvm/llvm-project/pull/102199

>From 0c20bcdf35f3c15024986da50cafb2a8c155e3cf Mon Sep 17 00:00:00 2001
From: Daniil Kovalev <dkovalev at accesssoftek.com>
Date: Tue, 6 Aug 2024 20:48:02 +0300
Subject: [PATCH 1/5] [PAC] Fix address discrimination for type info vtable
 pointers

In #99726, `-fptrauth-type-info-vtable-pointer-discrimination` was introduced,
which is intended to enable type and address discrimination for type_info
vtable pointers. However, some codegen logic for actually enabling address
discrimination was missing. This patch addresses the issue.

Fixes #101716
---
 clang/lib/CodeGen/ItaniumCXXABI.cpp           | 20 ++++++++++++++++---
 .../CodeGenCXX/ptrauth-type-info-vtable.cpp   |  2 +-
 llvm/include/llvm/IR/Constants.h              | 18 +++++++++++------
 .../AArch64/ptrauth-type-info-vptr-discr.ll   | 20 +++++++++++++++++++
 4 files changed, 50 insertions(+), 10 deletions(-)
 create mode 100644 llvm/test/CodeGen/AArch64/ptrauth-type-info-vptr-discr.ll

diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp
index 9b5227772125b2..13aeb3e75d6843 100644
--- a/clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -3955,9 +3955,23 @@ void ItaniumRTTIBuilder::BuildVTablePointer(const Type *Ty) {
                                                           VTable, Two);
   }
 
-  if (auto &Schema = CGM.getCodeGenOpts().PointerAuth.CXXTypeInfoVTablePointer)
-    VTable = CGM.getConstantSignedPointer(VTable, Schema, nullptr, GlobalDecl(),
-                                          QualType(Ty, 0));
+  if (const auto &Schema =
+          CGM.getCodeGenOpts().PointerAuth.CXXTypeInfoVTablePointer) {
+    llvm::PointerType *PtrTy = llvm::PointerType::get(
+        CGM.getLLVMContext(),
+        CGM.getModule().getDataLayout().getProgramAddressSpace());
+    llvm::Constant *StorageAddress =
+        (Schema.isAddressDiscriminated()
+             ? llvm::ConstantExpr::getIntToPtr(
+                   llvm::ConstantInt::get(
+                       CGM.IntPtrTy,
+                       llvm::ConstantPtrAuth::
+                           AddrDiscriminator_CXXTypeInfoVTablePointer),
+                   PtrTy)
+             : nullptr);
+    VTable = CGM.getConstantSignedPointer(VTable, Schema, StorageAddress,
+                                          GlobalDecl(), QualType(Ty, 0));
+  }
 
   Fields.push_back(VTable);
 }
diff --git a/clang/test/CodeGenCXX/ptrauth-type-info-vtable.cpp b/clang/test/CodeGenCXX/ptrauth-type-info-vtable.cpp
index 174aeda89d1755..61eef73b5be2a4 100644
--- a/clang/test/CodeGenCXX/ptrauth-type-info-vtable.cpp
+++ b/clang/test/CodeGenCXX/ptrauth-type-info-vtable.cpp
@@ -65,7 +65,7 @@ extern "C" int disc_std_type_info = __builtin_ptrauth_string_discriminator("_ZTV
 
 // NODISC: @_ZTI10TestStruct = constant { ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), i32 2), ptr @_ZTS10TestStruct }, align 8
 
-// DISC: @_ZTI10TestStruct = constant { ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), i32 2, i64 [[STDTYPEINFO_DISC]]), ptr @_ZTS10TestStruct }, align 8
+// DISC: @_ZTI10TestStruct = constant { ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), i32 2, i64 [[STDTYPEINFO_DISC]], ptr inttoptr (i64 1 to ptr)), ptr @_ZTS10TestStruct }, align 8
 
 struct TestStruct {
   virtual ~TestStruct();
diff --git a/llvm/include/llvm/IR/Constants.h b/llvm/include/llvm/IR/Constants.h
index 2788751e8b62a1..aaa1c197651a66 100644
--- a/llvm/include/llvm/IR/Constants.h
+++ b/llvm/include/llvm/IR/Constants.h
@@ -1056,12 +1056,18 @@ class ConstantPtrAuth final : public Constant {
     return !getAddrDiscriminator()->isNullValue();
   }
 
-  /// A constant value for the address discriminator which has special
-  /// significance to ctors/dtors lowering. Regular address discrimination can't
-  /// be applied for them since uses of llvm.global_{c|d}tors are disallowed
-  /// (see Verifier::visitGlobalVariable) and we can't emit getelementptr
-  /// expressions referencing these special arrays.
-  enum { AddrDiscriminator_CtorsDtors = 1 };
+  /// Constant values for the address discriminator which have special
+  /// significance to lowering in some contexts.
+  /// - For ctors/dtors, regular address discrimination can't
+  ///   be applied for them since uses of llvm.global_{c|d}tors are disallowed
+  ///   (see Verifier::visitGlobalVariable) and we can't emit getelementptr
+  ///   expressions referencing these special arrays.
+  /// - For vtable pointers of std::type_info and classes derived from it,
+  ///   we do not know the storage address when emitting ptrauth constant.
+  enum {
+    AddrDiscriminator_CtorsDtors = 1,
+    AddrDiscriminator_CXXTypeInfoVTablePointer = 1
+  };
 
   /// Whether the address uses a special address discriminator.
   /// These discriminators can't be used in real pointer-auth values; they
diff --git a/llvm/test/CodeGen/AArch64/ptrauth-type-info-vptr-discr.ll b/llvm/test/CodeGen/AArch64/ptrauth-type-info-vptr-discr.ll
new file mode 100644
index 00000000000000..b25a32f856b7ab
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/ptrauth-type-info-vptr-discr.ll
@@ -0,0 +1,20 @@
+; RUN: llc -mtriple aarch64-linux-gnu    -mattr=+pauth -filetype=asm -o - %s | FileCheck --check-prefix=ELF %s
+; RUN: llc -mtriple aarch64-apple-darwin -mattr=+pauth -filetype=asm -o - %s | FileCheck --check-prefix=MACHO %s
+
+; ELF-LABEL:   _ZTI10Disc:
+; ELF-NEXT:      .xword  (_ZTVN10__cxxabiv117__class_type_infoE+16)@AUTH(da,45546,addr)
+; ELF-LABEL:   _ZTI10NoDisc:
+; ELF-NEXT:      .xword  (_ZTVN10__cxxabiv117__class_type_infoE+16)@AUTH(da,45546)
+
+; MACHO-LABEL: __ZTI10Disc:
+; MACHO-NEXT:    .quad   (__ZTVN10__cxxabiv117__class_type_infoE+16)@AUTH(da,45546,addr)
+; MACHO-LABEL: __ZTI10NoDisc:
+; MACHO-NEXT:    .quad   (__ZTVN10__cxxabiv117__class_type_infoE+16)@AUTH(da,45546)
+
+ at _ZTVN10__cxxabiv117__class_type_infoE = external global [0 x ptr]
+
+ at _ZTS10Disc   = constant [4 x i8] c"Disc", align 1
+ at _ZTI10Disc   = constant { ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), i32 2, i64 45546, ptr inttoptr (i64 1 to ptr)), ptr @_ZTS10Disc }, align 8
+
+ at _ZTS10NoDisc = constant [6 x i8] c"NoDisc", align 1
+ at _ZTI10NoDisc = constant { ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), i32 2, i64 45546), ptr @_ZTS10NoDisc }, align 8

>From 130ff558e146a0da1ed542b62b9cb46b4d102327 Mon Sep 17 00:00:00 2001
From: Daniil Kovalev <dkovalev at accesssoftek.com>
Date: Mon, 16 Sep 2024 18:19:25 +0300
Subject: [PATCH 2/5] Use real addr instead of placeholder for signed type info
 vt ptrs

---
 clang/lib/CodeGen/ItaniumCXXABI.cpp           | 43 +++++++++++++------
 .../CodeGenCXX/ptrauth-type-info-vtable.cpp   |  2 +-
 llvm/include/llvm/IR/Constants.h              | 18 +++-----
 .../AArch64/ptrauth-type-info-vptr-discr.ll   |  2 +-
 4 files changed, 38 insertions(+), 27 deletions(-)

diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp
index 21168cd485ef12..ed253be1ad257a 100644
--- a/clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -3975,18 +3975,9 @@ void ItaniumRTTIBuilder::BuildVTablePointer(const Type *Ty) {
 
   if (const auto &Schema =
           CGM.getCodeGenOpts().PointerAuth.CXXTypeInfoVTablePointer) {
-    llvm::PointerType *PtrTy = llvm::PointerType::get(
-        CGM.getLLVMContext(),
-        CGM.getModule().getDataLayout().getProgramAddressSpace());
-    llvm::Constant *StorageAddress =
-        (Schema.isAddressDiscriminated()
-             ? llvm::ConstantExpr::getIntToPtr(
-                   llvm::ConstantInt::get(
-                       CGM.IntPtrTy,
-                       llvm::ConstantPtrAuth::
-                           AddrDiscriminator_CXXTypeInfoVTablePointer),
-                   PtrTy)
-             : nullptr);
+    // If address discrimination is enabled, we'll re-write that to actual
+    // storage address later in ItaniumRTTIBuilder::BuildTypeInfo.
+    llvm::Constant *StorageAddress = nullptr;
     VTable = CGM.getConstantSignedPointer(VTable, Schema, StorageAddress,
                                           GlobalDecl(), QualType(Ty, 0));
   }
@@ -4107,6 +4098,7 @@ llvm::Constant *ItaniumRTTIBuilder::BuildTypeInfo(
       llvm::GlobalValue::DLLStorageClassTypes DLLStorageClass) {
   // Add the vtable pointer.
   BuildVTablePointer(cast<Type>(Ty));
+  size_t VTablePointerIdx = Fields.size() - 1;
 
   // And the name.
   llvm::GlobalVariable *TypeName = GetAddrOfTypeName(Ty, Linkage);
@@ -4222,7 +4214,6 @@ llvm::Constant *ItaniumRTTIBuilder::BuildTypeInfo(
   }
 
   llvm::Constant *Init = llvm::ConstantStruct::getAnon(Fields);
-
   SmallString<256> Name;
   llvm::raw_svector_ostream Out(Name);
   CGM.getCXXABI().getMangleContext().mangleCXXRTTI(Ty, Out);
@@ -4231,6 +4222,32 @@ llvm::Constant *ItaniumRTTIBuilder::BuildTypeInfo(
   llvm::GlobalVariable *GV =
       new llvm::GlobalVariable(M, Init->getType(),
                                /*isConstant=*/true, Linkage, Init, Name);
+  if (const auto &Schema =
+          CGM.getCodeGenOpts().PointerAuth.CXXTypeInfoVTablePointer) {
+    if (Schema.isAddressDiscriminated()) {
+      // If type info vtable pointer is signed with address discrimination
+      // enabled, we need to place actual storage address (which was unknown
+      // during construction in ItaniumRTTIBuilder::BuildVTablePointer) in the
+      // corresponding field.
+      ConstantInitBuilder Builder(CGM);
+      auto InitBuilder = Builder.beginStruct();
+      for (size_t I = 0; I < Fields.size(); ++I) {
+        if (I != VTablePointerIdx) {
+          InitBuilder.add(Fields[I]);
+          continue;
+        }
+        auto *SignedVTablePointer = cast<llvm::ConstantPtrAuth>(Fields[I]);
+        llvm::Constant *UnsignedVtablePointer =
+            SignedVTablePointer->getPointer();
+        llvm::Constant *StorageAddress =
+            InitBuilder.getAddrOfCurrentPosition(CGM.UnqualPtrTy);
+        InitBuilder.add(CGM.getConstantSignedPointer(
+            UnsignedVtablePointer, Schema, StorageAddress, GlobalDecl(),
+            QualType(cast<Type>(Ty), 0)));
+      }
+      InitBuilder.finishAndSetAsInitializer(GV);
+    }
+  }
 
   // Export the typeinfo in the same circumstances as the vtable is exported.
   auto GVDLLStorageClass = DLLStorageClass;
diff --git a/clang/test/CodeGenCXX/ptrauth-type-info-vtable.cpp b/clang/test/CodeGenCXX/ptrauth-type-info-vtable.cpp
index 61eef73b5be2a4..bb692484c94ece 100644
--- a/clang/test/CodeGenCXX/ptrauth-type-info-vtable.cpp
+++ b/clang/test/CodeGenCXX/ptrauth-type-info-vtable.cpp
@@ -65,7 +65,7 @@ extern "C" int disc_std_type_info = __builtin_ptrauth_string_discriminator("_ZTV
 
 // NODISC: @_ZTI10TestStruct = constant { ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), i32 2), ptr @_ZTS10TestStruct }, align 8
 
-// DISC: @_ZTI10TestStruct = constant { ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), i32 2, i64 [[STDTYPEINFO_DISC]], ptr inttoptr (i64 1 to ptr)), ptr @_ZTS10TestStruct }, align 8
+// DISC: @_ZTI10TestStruct = constant { ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), i32 2, i64 [[STDTYPEINFO_DISC]], ptr @_ZTI10TestStruct), ptr @_ZTS10TestStruct }, align 8
 
 struct TestStruct {
   virtual ~TestStruct();
diff --git a/llvm/include/llvm/IR/Constants.h b/llvm/include/llvm/IR/Constants.h
index a49d13b6568696..3b16aa039a5087 100644
--- a/llvm/include/llvm/IR/Constants.h
+++ b/llvm/include/llvm/IR/Constants.h
@@ -1067,18 +1067,12 @@ class ConstantPtrAuth final : public Constant {
     return !getAddrDiscriminator()->isNullValue();
   }
 
-  /// Constant values for the address discriminator which have special
-  /// significance to lowering in some contexts.
-  /// - For ctors/dtors, regular address discrimination can't
-  ///   be applied for them since uses of llvm.global_{c|d}tors are disallowed
-  ///   (see Verifier::visitGlobalVariable) and we can't emit getelementptr
-  ///   expressions referencing these special arrays.
-  /// - For vtable pointers of std::type_info and classes derived from it,
-  ///   we do not know the storage address when emitting ptrauth constant.
-  enum {
-    AddrDiscriminator_CtorsDtors = 1,
-    AddrDiscriminator_CXXTypeInfoVTablePointer = 1
-  };
+  /// A constant value for the address discriminator which has special
+  /// significance to ctors/dtors lowering. Regular address discrimination can't
+  /// be applied for them since uses of llvm.global_{c|d}tors are disallowed
+  /// (see Verifier::visitGlobalVariable) and we can't emit getelementptr
+  /// expressions referencing these special arrays.
+  enum { AddrDiscriminator_CtorsDtors = 1 };
 
   /// Whether the address uses a special address discriminator.
   /// These discriminators can't be used in real pointer-auth values; they
diff --git a/llvm/test/CodeGen/AArch64/ptrauth-type-info-vptr-discr.ll b/llvm/test/CodeGen/AArch64/ptrauth-type-info-vptr-discr.ll
index b25a32f856b7ab..704cccdc1107a1 100644
--- a/llvm/test/CodeGen/AArch64/ptrauth-type-info-vptr-discr.ll
+++ b/llvm/test/CodeGen/AArch64/ptrauth-type-info-vptr-discr.ll
@@ -14,7 +14,7 @@
 @_ZTVN10__cxxabiv117__class_type_infoE = external global [0 x ptr]
 
 @_ZTS10Disc   = constant [4 x i8] c"Disc", align 1
- at _ZTI10Disc   = constant { ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), i32 2, i64 45546, ptr inttoptr (i64 1 to ptr)), ptr @_ZTS10Disc }, align 8
+ at _ZTI10Disc   = constant { ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), i32 2, i64 45546, ptr @_ZTI10Disc), ptr @_ZTS10Disc }, align 8
 
 @_ZTS10NoDisc = constant [6 x i8] c"NoDisc", align 1
 @_ZTI10NoDisc = constant { ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), i32 2, i64 45546), ptr @_ZTS10NoDisc }, align 8

>From 55fc2c822f8f543d335e443a13860ae72fb5ce6d Mon Sep 17 00:00:00 2001
From: Daniil Kovalev <dkovalev at accesssoftek.com>
Date: Mon, 30 Sep 2024 07:51:09 +0300
Subject: [PATCH 3/5] Address review comments

---
 clang/lib/CodeGen/ItaniumCXXABI.cpp | 35 +++++++++++------------------
 1 file changed, 13 insertions(+), 22 deletions(-)

diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp
index ed253be1ad257a..43a4a22abc7b2f 100644
--- a/clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -4098,7 +4098,8 @@ llvm::Constant *ItaniumRTTIBuilder::BuildTypeInfo(
       llvm::GlobalValue::DLLStorageClassTypes DLLStorageClass) {
   // Add the vtable pointer.
   BuildVTablePointer(cast<Type>(Ty));
-  size_t VTablePointerIdx = Fields.size() - 1;
+  assert(Fields.size() == 1);
+  size_t VTablePointerIdx = 0;
 
   // And the name.
   llvm::GlobalVariable *TypeName = GetAddrOfTypeName(Ty, Linkage);
@@ -4213,15 +4214,14 @@ llvm::Constant *ItaniumRTTIBuilder::BuildTypeInfo(
     break;
   }
 
-  llvm::Constant *Init = llvm::ConstantStruct::getAnon(Fields);
   SmallString<256> Name;
   llvm::raw_svector_ostream Out(Name);
   CGM.getCXXABI().getMangleContext().mangleCXXRTTI(Ty, Out);
   llvm::Module &M = CGM.getModule();
   llvm::GlobalVariable *OldGV = M.getNamedGlobal(Name);
-  llvm::GlobalVariable *GV =
-      new llvm::GlobalVariable(M, Init->getType(),
-                               /*isConstant=*/true, Linkage, Init, Name);
+  llvm::GlobalVariable *GV = new llvm::GlobalVariable(
+      M, llvm::ConstantStruct::getTypeForElements(Fields),
+      /*isConstant=*/true, Linkage, /*Initializer=*/nullptr, Name);
   if (const auto &Schema =
           CGM.getCodeGenOpts().PointerAuth.CXXTypeInfoVTablePointer) {
     if (Schema.isAddressDiscriminated()) {
@@ -4229,25 +4229,16 @@ llvm::Constant *ItaniumRTTIBuilder::BuildTypeInfo(
       // enabled, we need to place actual storage address (which was unknown
       // during construction in ItaniumRTTIBuilder::BuildVTablePointer) in the
       // corresponding field.
-      ConstantInitBuilder Builder(CGM);
-      auto InitBuilder = Builder.beginStruct();
-      for (size_t I = 0; I < Fields.size(); ++I) {
-        if (I != VTablePointerIdx) {
-          InitBuilder.add(Fields[I]);
-          continue;
-        }
-        auto *SignedVTablePointer = cast<llvm::ConstantPtrAuth>(Fields[I]);
-        llvm::Constant *UnsignedVtablePointer =
-            SignedVTablePointer->getPointer();
-        llvm::Constant *StorageAddress =
-            InitBuilder.getAddrOfCurrentPosition(CGM.UnqualPtrTy);
-        InitBuilder.add(CGM.getConstantSignedPointer(
-            UnsignedVtablePointer, Schema, StorageAddress, GlobalDecl(),
-            QualType(cast<Type>(Ty), 0)));
-      }
-      InitBuilder.finishAndSetAsInitializer(GV);
+      llvm::Constant *UnsignedVtablePointer =
+          cast<llvm::ConstantPtrAuth>(Fields[VTablePointerIdx])->getPointer();
+      assert(VTablePointerIdx == 0 && "Expected 0 offset for StorageAddress");
+      llvm::Constant *StorageAddress = GV;
+      Fields[VTablePointerIdx] = CGM.getConstantSignedPointer(
+          UnsignedVtablePointer, Schema, StorageAddress, GlobalDecl(),
+          QualType(cast<Type>(Ty), 0));
     }
   }
+  GV->replaceInitializer(llvm::ConstantStruct::getAnon(Fields));
 
   // Export the typeinfo in the same circumstances as the vtable is exported.
   auto GVDLLStorageClass = DLLStorageClass;

>From b08172fa576e5bb7849aa13d503180cfef5bcd0b Mon Sep 17 00:00:00 2001
From: Daniil Kovalev <dkovalev at accesssoftek.com>
Date: Thu, 17 Oct 2024 12:42:11 +0300
Subject: [PATCH 4/5] Construct GV before BuildVTablePointer call

---
 clang/lib/CodeGen/ItaniumCXXABI.cpp           | 55 +++++++------------
 .../CodeGenCXX/ptrauth-type-info-vtable.cpp   |  5 +-
 .../AArch64/ptrauth-type-info-vptr-discr.ll   |  7 ++-
 3 files changed, 26 insertions(+), 41 deletions(-)

diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp
index 6002e4db3b0a90..89f9457523824a 100644
--- a/clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -3437,7 +3437,7 @@ class ItaniumRTTIBuilder {
   llvm::Constant *GetAddrOfExternalRTTIDescriptor(QualType Ty);
 
   /// BuildVTablePointer - Build the vtable pointer for the given type.
-  void BuildVTablePointer(const Type *Ty);
+  void BuildVTablePointer(const Type *Ty, llvm::Constant *StorageAddress);
 
   /// BuildSIClassTypeInfo - Build an abi::__si_class_type_info, used for single
   /// inheritance, according to the Itanium C++ ABI, 2.9.5p6b.
@@ -3834,7 +3834,8 @@ static bool CanUseSingleInheritance(const CXXRecordDecl *RD) {
   return true;
 }
 
-void ItaniumRTTIBuilder::BuildVTablePointer(const Type *Ty) {
+void ItaniumRTTIBuilder::BuildVTablePointer(const Type *Ty,
+                                            llvm::Constant *StorageAddress) {
   // abi::__class_type_info.
   static const char * const ClassTypeInfo =
     "_ZTVN10__cxxabiv117__class_type_infoE";
@@ -3982,13 +3983,11 @@ void ItaniumRTTIBuilder::BuildVTablePointer(const Type *Ty) {
   }
 
   if (const auto &Schema =
-          CGM.getCodeGenOpts().PointerAuth.CXXTypeInfoVTablePointer) {
-    // If address discrimination is enabled, we'll re-write that to actual
-    // storage address later in ItaniumRTTIBuilder::BuildTypeInfo.
-    llvm::Constant *StorageAddress = nullptr;
-    VTable = CGM.getConstantSignedPointer(VTable, Schema, StorageAddress,
-                                          GlobalDecl(), QualType(Ty, 0));
-  }
+          CGM.getCodeGenOpts().PointerAuth.CXXTypeInfoVTablePointer)
+    VTable = CGM.getConstantSignedPointer(
+        VTable, Schema,
+        Schema.isAddressDiscriminated() ? StorageAddress : nullptr,
+        GlobalDecl(), QualType(Ty, 0));
 
   Fields.push_back(VTable);
 }
@@ -4104,10 +4103,18 @@ llvm::Constant *ItaniumRTTIBuilder::BuildTypeInfo(
       llvm::GlobalVariable::LinkageTypes Linkage,
       llvm::GlobalValue::VisibilityTypes Visibility,
       llvm::GlobalValue::DLLStorageClassTypes DLLStorageClass) {
+  SmallString<256> Name;
+  llvm::raw_svector_ostream Out(Name);
+  CGM.getCXXABI().getMangleContext().mangleCXXRTTI(Ty, Out);
+  llvm::Module &M = CGM.getModule();
+  llvm::GlobalVariable *OldGV = M.getNamedGlobal(Name);
+  // int8 is an arbitrary type to be replaced later with replaceInitializer.
+  llvm::GlobalVariable *GV =
+      new llvm::GlobalVariable(M, CGM.Int8Ty, /*isConstant=*/true, Linkage,
+                               /*Initializer=*/nullptr, Name);
+
   // Add the vtable pointer.
-  BuildVTablePointer(cast<Type>(Ty));
-  assert(Fields.size() == 1);
-  size_t VTablePointerIdx = 0;
+  BuildVTablePointer(cast<Type>(Ty), GV);
 
   // And the name.
   llvm::GlobalVariable *TypeName = GetAddrOfTypeName(Ty, Linkage);
@@ -4225,30 +4232,6 @@ llvm::Constant *ItaniumRTTIBuilder::BuildTypeInfo(
     llvm_unreachable("HLSL doesn't support RTTI");
   }
 
-  SmallString<256> Name;
-  llvm::raw_svector_ostream Out(Name);
-  CGM.getCXXABI().getMangleContext().mangleCXXRTTI(Ty, Out);
-  llvm::Module &M = CGM.getModule();
-  llvm::GlobalVariable *OldGV = M.getNamedGlobal(Name);
-  llvm::GlobalVariable *GV = new llvm::GlobalVariable(
-      M, llvm::ConstantStruct::getTypeForElements(Fields),
-      /*isConstant=*/true, Linkage, /*Initializer=*/nullptr, Name);
-  if (const auto &Schema =
-          CGM.getCodeGenOpts().PointerAuth.CXXTypeInfoVTablePointer) {
-    if (Schema.isAddressDiscriminated()) {
-      // If type info vtable pointer is signed with address discrimination
-      // enabled, we need to place actual storage address (which was unknown
-      // during construction in ItaniumRTTIBuilder::BuildVTablePointer) in the
-      // corresponding field.
-      llvm::Constant *UnsignedVtablePointer =
-          cast<llvm::ConstantPtrAuth>(Fields[VTablePointerIdx])->getPointer();
-      assert(VTablePointerIdx == 0 && "Expected 0 offset for StorageAddress");
-      llvm::Constant *StorageAddress = GV;
-      Fields[VTablePointerIdx] = CGM.getConstantSignedPointer(
-          UnsignedVtablePointer, Schema, StorageAddress, GlobalDecl(),
-          QualType(cast<Type>(Ty), 0));
-    }
-  }
   GV->replaceInitializer(llvm::ConstantStruct::getAnon(Fields));
 
   // Export the typeinfo in the same circumstances as the vtable is exported.
diff --git a/clang/test/CodeGenCXX/ptrauth-type-info-vtable.cpp b/clang/test/CodeGenCXX/ptrauth-type-info-vtable.cpp
index bb692484c94ece..f4396e40270399 100644
--- a/clang/test/CodeGenCXX/ptrauth-type-info-vtable.cpp
+++ b/clang/test/CodeGenCXX/ptrauth-type-info-vtable.cpp
@@ -60,13 +60,14 @@ static_assert(__has_feature(ptrauth_type_info_vtable_pointer_discrimination) ==
 extern "C" int disc_std_type_info = __builtin_ptrauth_string_discriminator("_ZTVSt9type_info");
 
 // CHECK: @_ZTV10TestStruct = unnamed_addr constant { [4 x ptr] } { [4 x ptr] [ptr null, ptr @_ZTI10TestStruct, ptr ptrauth (ptr @_ZN10TestStructD1Ev, i32 0, i64 52216, ptr getelementptr inbounds ({ [4 x ptr] }, ptr @_ZTV10TestStruct, i32 0, i32 0, i32 2)), ptr ptrauth (ptr @_ZN10TestStructD0Ev, i32 0, i64 39671, ptr getelementptr inbounds ({ [4 x ptr] }, ptr @_ZTV10TestStruct, i32 0, i32 0, i32 3))] }, align 8
-// CHECK: @_ZTVN10__cxxabiv117__class_type_infoE = external global [0 x ptr]
-// CHECK: @_ZTS10TestStruct = constant [13 x i8] c"10TestStruct\00", align 1
 
 // NODISC: @_ZTI10TestStruct = constant { ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), i32 2), ptr @_ZTS10TestStruct }, align 8
 
 // DISC: @_ZTI10TestStruct = constant { ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), i32 2, i64 [[STDTYPEINFO_DISC]], ptr @_ZTI10TestStruct), ptr @_ZTS10TestStruct }, align 8
 
+// CHECK: @_ZTVN10__cxxabiv117__class_type_infoE = external global [0 x ptr]
+// CHECK: @_ZTS10TestStruct = constant [13 x i8] c"10TestStruct\00", align 1
+
 struct TestStruct {
   virtual ~TestStruct();
   int a;
diff --git a/llvm/test/CodeGen/AArch64/ptrauth-type-info-vptr-discr.ll b/llvm/test/CodeGen/AArch64/ptrauth-type-info-vptr-discr.ll
index 704cccdc1107a1..fbd777911aecb2 100644
--- a/llvm/test/CodeGen/AArch64/ptrauth-type-info-vptr-discr.ll
+++ b/llvm/test/CodeGen/AArch64/ptrauth-type-info-vptr-discr.ll
@@ -11,10 +11,11 @@
 ; MACHO-LABEL: __ZTI10NoDisc:
 ; MACHO-NEXT:    .quad   (__ZTVN10__cxxabiv117__class_type_infoE+16)@AUTH(da,45546)
 
- at _ZTVN10__cxxabiv117__class_type_infoE = external global [0 x ptr]
 
- at _ZTS10Disc   = constant [4 x i8] c"Disc", align 1
 @_ZTI10Disc   = constant { ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), i32 2, i64 45546, ptr @_ZTI10Disc), ptr @_ZTS10Disc }, align 8
+ at _ZTS10Disc   = constant [4 x i8] c"Disc", align 1
 
- at _ZTS10NoDisc = constant [6 x i8] c"NoDisc", align 1
 @_ZTI10NoDisc = constant { ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), i32 2, i64 45546), ptr @_ZTS10NoDisc }, align 8
+ at _ZTS10NoDisc = constant [6 x i8] c"NoDisc", align 1
+
+ at _ZTVN10__cxxabiv117__class_type_infoE = external global [0 x ptr]

>From c9d26dd6dd7648c25e44e576891e838a418eacae Mon Sep 17 00:00:00 2001
From: Daniil Kovalev <dkovalev at accesssoftek.com>
Date: Thu, 17 Oct 2024 13:28:28 +0300
Subject: [PATCH 5/5] Fix tests

---
 ...child-inheritted-from-parent-in-comdat.cpp |   2 +-
 .../inlined-key-function.cpp                  |   2 +-
 .../parent-and-child-in-comdats.cpp           |   4 +-
 .../parent-vtable-in-comdat.cpp               |   4 +-
 .../simple-vtable-definition.cpp              |   2 +-
 .../RelativeVTablesABI/type-info.cpp          |   4 +-
 clang/test/CodeGenCXX/armv7k.cpp              |   6 +-
 .../CodeGenCXX/dynamic-cast-address-space.cpp |   4 +-
 clang/test/CodeGenCXX/exceptions-no-rtti.cpp  |   2 +-
 .../CodeGenCXX/implicit-record-visibility.cpp |   2 +-
 ...default-visibility-export-mapping-rtti.cpp | 480 +++++++++---------
 clang/test/CodeGenCXX/modules-vtable.cppm     |  12 +-
 clang/test/CodeGenCXX/ptrauth-rtti-layout.cpp |   4 +-
 ...rauth-vtable-virtual-inheritance-thunk.cpp |  26 +-
 clang/test/CodeGenCXX/rtti-linkage.cpp        |  64 +--
 clang/test/CodeGenCXX/rtti-visibility.cpp     |   6 +-
 clang/test/CodeGenCXX/symbol-partition.cpp    |   2 +-
 clang/test/CodeGenCXX/type_visibility.cpp     |  36 +-
 .../typeinfo-with-address-space.cpp           |   4 +-
 .../test/CodeGenCXX/visibility-ms-compat.cpp  |  12 +-
 .../CodeGenCXX/vtable-align-address-space.cpp |   2 +-
 clang/test/CodeGenCXX/vtable-align.cpp        |   4 +-
 .../vtable-available-externally.cpp           |   2 +-
 .../CodeGenCXX/vtable-key-function-arm.cpp    |  24 +-
 .../CodeGenCXX/vtable-key-function-ios.cpp    |  16 +-
 .../vtable-key-function-win-comdat.cpp        |   6 +-
 .../test/CodeGenCXX/weak-extern-typeinfo.cpp  |  14 +-
 .../CodeGenCXX/windows-itanium-type-info.cpp  |   2 +-
 clang/test/CodeGenObjCXX/rtti.mm              |   9 +-
 clang/test/Modules/pr97313.cppm               |   6 +-
 clang/test/SemaCXX/typeid-ref.cpp             |   2 +-
 31 files changed, 383 insertions(+), 382 deletions(-)

diff --git a/clang/test/CodeGenCXX/RelativeVTablesABI/child-inheritted-from-parent-in-comdat.cpp b/clang/test/CodeGenCXX/RelativeVTablesABI/child-inheritted-from-parent-in-comdat.cpp
index bb86d459b02eaf..e6a945618badc4 100644
--- a/clang/test/CodeGenCXX/RelativeVTablesABI/child-inheritted-from-parent-in-comdat.cpp
+++ b/clang/test/CodeGenCXX/RelativeVTablesABI/child-inheritted-from-parent-in-comdat.cpp
@@ -4,8 +4,8 @@
 // RUN: %clang_cc1 %s -triple=aarch64-unknown-fuchsia -O1 -o - -emit-llvm -fhalf-no-semantic-interposition | FileCheck %s
 
 // The inline function is emitted in each module with the same comdat
-// CHECK: $_ZTS1A = comdat any
 // CHECK: $_ZTI1A = comdat any
+// CHECK: $_ZTS1A = comdat any
 // CHECK: $_ZTI1B.rtti_proxy = comdat any
 
 // The VTable is emitted everywhere used
diff --git a/clang/test/CodeGenCXX/RelativeVTablesABI/inlined-key-function.cpp b/clang/test/CodeGenCXX/RelativeVTablesABI/inlined-key-function.cpp
index d5d9a85d4e22f4..70f8289e9df37a 100644
--- a/clang/test/CodeGenCXX/RelativeVTablesABI/inlined-key-function.cpp
+++ b/clang/test/CodeGenCXX/RelativeVTablesABI/inlined-key-function.cpp
@@ -4,8 +4,8 @@
 // RUN: %clang_cc1 %s -triple=aarch64-unknown-fuchsia -O1 -o - -emit-llvm | FileCheck %s
 
 // CHECK: $_ZTV1A = comdat any
-// CHECK: $_ZTS1A = comdat any
 // CHECK: $_ZTI1A = comdat any
+// CHECK: $_ZTS1A = comdat any
 // CHECK: $_ZTI1A.rtti_proxy = comdat any
 
 // The VTable is linkonce_odr and in a comdat here bc it’s key function is inline defined.
diff --git a/clang/test/CodeGenCXX/RelativeVTablesABI/parent-and-child-in-comdats.cpp b/clang/test/CodeGenCXX/RelativeVTablesABI/parent-and-child-in-comdats.cpp
index a033ac41868f56..c1b9a9398219a8 100644
--- a/clang/test/CodeGenCXX/RelativeVTablesABI/parent-and-child-in-comdats.cpp
+++ b/clang/test/CodeGenCXX/RelativeVTablesABI/parent-and-child-in-comdats.cpp
@@ -8,12 +8,12 @@
 // CHECK: $_ZN1A3fooEv = comdat any
 // CHECK: $_ZN1B3fooEv = comdat any
 // CHECK: $_ZTV1A = comdat any
-// CHECK: $_ZTS1A = comdat any
 // CHECK: $_ZTI1A = comdat any
+// CHECK: $_ZTS1A = comdat any
 // CHECK: $_ZTI1A.rtti_proxy = comdat any
 // CHECK: $_ZTV1B = comdat any
-// CHECK: $_ZTS1B = comdat any
 // CHECK: $_ZTI1B = comdat any
+// CHECK: $_ZTS1B = comdat any
 // CHECK: $_ZTI1B.rtti_proxy = comdat any
 
 // Both the vtables for A and B are emitted and in their own comdats.
diff --git a/clang/test/CodeGenCXX/RelativeVTablesABI/parent-vtable-in-comdat.cpp b/clang/test/CodeGenCXX/RelativeVTablesABI/parent-vtable-in-comdat.cpp
index 341c53146d476d..d6eda793cc5b4b 100644
--- a/clang/test/CodeGenCXX/RelativeVTablesABI/parent-vtable-in-comdat.cpp
+++ b/clang/test/CodeGenCXX/RelativeVTablesABI/parent-vtable-in-comdat.cpp
@@ -7,17 +7,17 @@
 // A::foo() has a comdat since it is an inline function
 // CHECK: $_ZN1A3fooEv = comdat any
 // CHECK: $_ZTV1A = comdat any
+// CHECK: $_ZTI1A = comdat any
 // CHECK: $_ZTS1A = comdat any
 
 // The VTable for A has its own comdat section bc it has no key function
-// CHECK: $_ZTI1A = comdat any
 // CHECK: $_ZTI1A.rtti_proxy = comdat any
 
 // 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: @_ZTI1A = linkonce_odr constant { ptr, ptr } { ptr getelementptr inbounds (i8, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i32 8), ptr @_ZTS1A }, comdat, align 8
 // 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: @_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/RelativeVTablesABI/simple-vtable-definition.cpp b/clang/test/CodeGenCXX/RelativeVTablesABI/simple-vtable-definition.cpp
index ad8018ee176712..9dcb1c30e56275 100644
--- a/clang/test/CodeGenCXX/RelativeVTablesABI/simple-vtable-definition.cpp
+++ b/clang/test/CodeGenCXX/RelativeVTablesABI/simple-vtable-definition.cpp
@@ -9,9 +9,9 @@
 // The vtable definition itself is private so we can take relative references to
 // it. The vtable symbol will be exposed through a public alias.
 // CHECK: @_ZTV1A.local = internal 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)] }, align 4
+// CHECK: @_ZTI1A ={{.*}} constant { ptr, ptr } { ptr getelementptr inbounds (i8, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i32 8), ptr @_ZTS1A }, align 8
 // CHECK: @_ZTVN10__cxxabiv117__class_type_infoE = external global [0 x ptr]
 // CHECK: @_ZTS1A ={{.*}} constant [3 x i8] c"1A\00", align 1
-// CHECK: @_ZTI1A ={{.*}} constant { ptr, ptr } { ptr getelementptr inbounds (i8, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i32 8), ptr @_ZTS1A }, align 8
 
 // The rtti should be in a comdat
 // CHECK: @_ZTI1A.rtti_proxy = {{.*}}comdat
diff --git a/clang/test/CodeGenCXX/RelativeVTablesABI/type-info.cpp b/clang/test/CodeGenCXX/RelativeVTablesABI/type-info.cpp
index fc5ee5096433ed..c471e5dbd7b33c 100644
--- a/clang/test/CodeGenCXX/RelativeVTablesABI/type-info.cpp
+++ b/clang/test/CodeGenCXX/RelativeVTablesABI/type-info.cpp
@@ -5,12 +5,12 @@
 // CHECK: $_ZTI1A.rtti_proxy = comdat any
 // CHECK: $_ZTI1B.rtti_proxy = comdat any
 
+// CHECK: @_ZTI1A ={{.*}} constant { ptr, ptr } { ptr getelementptr inbounds (i8, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i32 8), ptr @_ZTS1A }, align 8
 // CHECK: @_ZTVN10__cxxabiv117__class_type_infoE = external global [0 x ptr]
 // CHECK: @_ZTS1A ={{.*}} constant [3 x i8] c"1A\00", align 1
-// CHECK: @_ZTI1A ={{.*}} constant { ptr, ptr } { ptr getelementptr inbounds (i8, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i32 8), ptr @_ZTS1A }, align 8
+// CHECK: @_ZTI1B ={{.*}} constant { ptr, ptr, ptr } { ptr getelementptr inbounds (i8, ptr @_ZTVN10__cxxabiv120__si_class_type_infoE, i32 8), ptr @_ZTS1B, ptr @_ZTI1A }, align 8
 // CHECK: @_ZTVN10__cxxabiv120__si_class_type_infoE = external global [0 x ptr]
 // CHECK: @_ZTS1B ={{.*}} constant [3 x i8] c"1B\00", align 1
-// CHECK: @_ZTI1B ={{.*}} constant { ptr, ptr, ptr } { ptr getelementptr inbounds (i8, ptr @_ZTVN10__cxxabiv120__si_class_type_infoE, i32 8), ptr @_ZTS1B, ptr @_ZTI1A }, align 8
 // CHECK: @_ZTI1A.rtti_proxy = linkonce_odr hidden unnamed_addr constant ptr @_ZTI1A, comdat
 // CHECK: @_ZTI1B.rtti_proxy = linkonce_odr hidden unnamed_addr constant ptr @_ZTI1B, comdat
 
diff --git a/clang/test/CodeGenCXX/armv7k.cpp b/clang/test/CodeGenCXX/armv7k.cpp
index a4a243c162ea3f..7aa9fd7944cfdf 100644
--- a/clang/test/CodeGenCXX/armv7k.cpp
+++ b/clang/test/CodeGenCXX/armv7k.cpp
@@ -50,17 +50,17 @@ 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 }
+  // CHECK-GLOBALS: @_ZTSN5test21BE = linkonce_odr hidden constant
 
   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
+  // CHECK-GLOBALS: @_ZTSPN5test21BE = linkonce_odr hidden constant
 
   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 }
+  // CHECK-GLOBALS: @_ZTSN5test21CE = linkonce_odr constant [11 x i8] c"N5test21CE\00"
 }
 
 // va_list should be based on "char *" rather than "ptr".
diff --git a/clang/test/CodeGenCXX/dynamic-cast-address-space.cpp b/clang/test/CodeGenCXX/dynamic-cast-address-space.cpp
index d0c87d9dfda5f7..271d9ede79d0c4 100644
--- a/clang/test/CodeGenCXX/dynamic-cast-address-space.cpp
+++ b/clang/test/CodeGenCXX/dynamic-cast-address-space.cpp
@@ -10,17 +10,17 @@ B fail;
 // CHECK: @_ZTV1B = linkonce_odr unnamed_addr addrspace(1) constant { [3 x ptr addrspace(1)] } { [3 x ptr addrspace(1)] [ptr addrspace(1) null, ptr addrspace(1) @_ZTI1B, ptr addrspace(1) addrspacecast (ptr @_ZN1A1fEv to ptr addrspace(1))] }, comdat, align 8
 // CHECK: @fail = addrspace(1) global { ptr addrspace(1) } { ptr addrspace(1) getelementptr inbounds inrange(-16, 8) ({ [3 x ptr addrspace(1)] }, ptr addrspace(1) @_ZTV1B, i32 0, i32 0, i32 2) }, align 8
 // CHECK: @_ZTI1A = external addrspace(1) constant ptr addrspace(1)
+// CHECK: @_ZTI1B = linkonce_odr addrspace(1) constant { ptr addrspace(1), ptr addrspace(1), ptr addrspace(1) } { ptr addrspace(1) getelementptr inbounds (ptr addrspace(1), ptr addrspace(1) @_ZTVN10__cxxabiv120__si_class_type_infoE, i64 2), ptr addrspace(1) @_ZTS1B, ptr addrspace(1) @_ZTI1A }, comdat, align 8
 // CHECK: @_ZTVN10__cxxabiv120__si_class_type_infoE = external addrspace(1) global [0 x ptr addrspace(1)]
 // CHECK: @_ZTS1B = linkonce_odr addrspace(1) constant [3 x i8] c"1B\00", comdat, align 1
-// CHECK: @_ZTI1B = linkonce_odr addrspace(1) constant { ptr addrspace(1), ptr addrspace(1), ptr addrspace(1) } { ptr addrspace(1) getelementptr inbounds (ptr addrspace(1), ptr addrspace(1) @_ZTVN10__cxxabiv120__si_class_type_infoE, i64 2), ptr addrspace(1) @_ZTS1B, ptr addrspace(1) @_ZTI1A }, comdat, align 8
 // CHECK: @__oclc_ABI_version = weak_odr hidden local_unnamed_addr addrspace(4) constant i32 500
 //.
 // WITH-NONZERO-DEFAULT-AS: @_ZTV1B = linkonce_odr unnamed_addr addrspace(1) constant { [3 x ptr addrspace(1)] } { [3 x ptr addrspace(1)] [ptr addrspace(1) null, ptr addrspace(1) @_ZTI1B, ptr addrspace(1) addrspacecast (ptr addrspace(4) @_ZN1A1fEv to ptr addrspace(1))] }, comdat, align 8
 // WITH-NONZERO-DEFAULT-AS: @fail = addrspace(1) global { ptr addrspace(1) } { ptr addrspace(1) getelementptr inbounds inrange(-16, 8) ({ [3 x ptr addrspace(1)] }, ptr addrspace(1) @_ZTV1B, i32 0, i32 0, i32 2) }, align 8
 // WITH-NONZERO-DEFAULT-AS: @_ZTI1A = external addrspace(1) constant ptr addrspace(1)
+// WITH-NONZERO-DEFAULT-AS: @_ZTI1B = linkonce_odr addrspace(1) constant { ptr addrspace(1), ptr addrspace(1), ptr addrspace(1) } { ptr addrspace(1) getelementptr inbounds (ptr addrspace(1), ptr addrspace(1) @_ZTVN10__cxxabiv120__si_class_type_infoE, i64 2), ptr addrspace(1) @_ZTS1B, ptr addrspace(1) @_ZTI1A }, comdat, align 8
 // WITH-NONZERO-DEFAULT-AS: @_ZTVN10__cxxabiv120__si_class_type_infoE = external addrspace(1) global [0 x ptr addrspace(1)]
 // WITH-NONZERO-DEFAULT-AS: @_ZTS1B = linkonce_odr addrspace(1) constant [3 x i8] c"1B\00", comdat, align 1
-// WITH-NONZERO-DEFAULT-AS: @_ZTI1B = linkonce_odr addrspace(1) constant { ptr addrspace(1), ptr addrspace(1), ptr addrspace(1) } { ptr addrspace(1) getelementptr inbounds (ptr addrspace(1), ptr addrspace(1) @_ZTVN10__cxxabiv120__si_class_type_infoE, i64 2), ptr addrspace(1) @_ZTS1B, ptr addrspace(1) @_ZTI1A }, comdat, align 8
 //.
 // CHECK-LABEL: define dso_local noundef nonnull align 8 dereferenceable(8) ptr @_Z1fP1A(
 // CHECK-SAME: ptr noundef [[A:%.*]]) #[[ATTR0:[0-9]+]] personality ptr @__gxx_personality_v0 {
diff --git a/clang/test/CodeGenCXX/exceptions-no-rtti.cpp b/clang/test/CodeGenCXX/exceptions-no-rtti.cpp
index 7c73285b948f16..a3d969665bdc71 100644
--- a/clang/test/CodeGenCXX/exceptions-no-rtti.cpp
+++ b/clang/test/CodeGenCXX/exceptions-no-rtti.cpp
@@ -3,8 +3,8 @@
 // CHECK: @_ZTIN5test11AE = linkonce_odr constant
 // CHECK: @_ZTIN5test11BE = linkonce_odr constant
 // CHECK: @_ZTIN5test11CE = linkonce_odr constant
-// CHECK: @_ZTIN5test11DE = linkonce_odr constant
 // CHECK: @_ZTIPN5test11DE = linkonce_odr constant {{.*}} @_ZTIN5test11DE
+// CHECK: @_ZTIN5test11DE = linkonce_odr constant
 
 // PR6974: this shouldn't crash
 namespace test0 {
diff --git a/clang/test/CodeGenCXX/implicit-record-visibility.cpp b/clang/test/CodeGenCXX/implicit-record-visibility.cpp
index ef388c7b8316a0..84ad822702d39b 100644
--- a/clang/test/CodeGenCXX/implicit-record-visibility.cpp
+++ b/clang/test/CodeGenCXX/implicit-record-visibility.cpp
@@ -7,6 +7,6 @@
 // under -fvisibility=hidden the type of function f, due to its va_list (aka
 // __builtin_va_list, aka __va_list_tag (*)[1]) parameter would be hidden:
 
-// CHECK: @_ZTSFvP13__va_list_tagE = linkonce_odr constant
 // CHECK: @_ZTIFvP13__va_list_tagE = linkonce_odr constant
+// CHECK: @_ZTSFvP13__va_list_tagE = linkonce_odr constant
 void f(va_list) { (void)typeid(f); }
diff --git a/clang/test/CodeGenCXX/mdefault-visibility-export-mapping-rtti.cpp b/clang/test/CodeGenCXX/mdefault-visibility-export-mapping-rtti.cpp
index 1af105e915e636..2fc0a6a4ee608e 100644
--- a/clang/test/CodeGenCXX/mdefault-visibility-export-mapping-rtti.cpp
+++ b/clang/test/CodeGenCXX/mdefault-visibility-export-mapping-rtti.cpp
@@ -16,20 +16,20 @@
 // C is an incomplete class type, so any direct or indirect pointer types should have 
 // internal linkage, as should the type info for C itself.
 struct C;
+// CHECK: @_ZTIP1C = internal constant
 // CHECK: @_ZTSP1C = internal constant
-// CHECK: @_ZTS1C = internal constant
 // CHECK: @_ZTI1C = internal constant
-// CHECK: @_ZTIP1C = internal constant
-// CHECK: @_ZTSPP1C = internal constant
+// CHECK: @_ZTS1C = internal constant
 // CHECK: @_ZTIPP1C = internal constant
+// CHECK: @_ZTSPP1C = internal constant
 
 struct __attribute__((type_visibility("default"))) D;
+// CHECK: @_ZTIP1D = internal constant
 // CHECK: @_ZTSP1D = internal constant
-// CHECK: @_ZTS1D = internal constant
 // CHECK: @_ZTI1D = internal constant
-// CHECK: @_ZTIP1D = internal constant
-// CHECK: @_ZTSPP1D = internal constant
+// CHECK: @_ZTS1D = internal constant
 // CHECK: @_ZTIPP1D = internal constant
+// CHECK: @_ZTSPP1D = internal constant
 
 void __attribute__((visibility("default"))) tfunc() {
   (void)typeid(C *);
@@ -46,12 +46,12 @@ void s::foo() {}
 // UNSPECIFIED-DEF: @_ZTV1s = unnamed_addr constant
 // UNSPECIFIED-HID: @_ZTV1s = hidden unnamed_addr constant
 // UNSPECIFIED-EXP: @_ZTV1s = dllexport unnamed_addr constant
-// UNSPECIFIED-DEF: @_ZTS1s = constant
-// UNSPECIFIED-HID: @_ZTS1s = hidden constant
-// UNSPECIFIED-EXP: @_ZTS1s = dllexport constant
 // UNSPECIFIED-DEF: @_ZTI1s = constant
 // UNSPECIFIED-HID: @_ZTI1s = hidden constant
 // UNSPECIFIED-EXP: @_ZTI1s = dllexport constant
+// UNSPECIFIED-DEF: @_ZTS1s = constant
+// UNSPECIFIED-HID: @_ZTS1s = hidden constant
+// UNSPECIFIED-EXP: @_ZTS1s = dllexport constant
 
 // explicit default visibility RTTI & vtable
 struct __attribute__((type_visibility("default"))) t {
@@ -61,12 +61,12 @@ void t::foo() {}
 // EXPLICIT-DEF: @_ZTV1t = unnamed_addr constant
 // EXPLICIT-HID: @_ZTV1t = hidden unnamed_addr constant
 // EXPLICIT-EXP: @_ZTV1t = dllexport unnamed_addr constant
-// EXPLICIT-DEF: @_ZTS1t = constant
-// EXPLICIT-HID: @_ZTS1t = hidden constant
-// EXPLICIT-EXP: @_ZTS1t = dllexport constant
 // EXPLICIT-DEF: @_ZTI1t = constant
 // EXPLICIT-HID: @_ZTI1t = hidden constant
 // EXPLICIT-EXP: @_ZTI1t = dllexport constant
+// EXPLICIT-DEF: @_ZTS1t = constant
+// EXPLICIT-HID: @_ZTS1t = hidden constant
+// EXPLICIT-EXP: @_ZTS1t = dllexport constant
 
 #ifdef FUNDAMENTAL_IS_EXPLICIT
 #define TYPE_VIS __attribute__((type_visibility("default")))
@@ -86,511 +86,511 @@ __fundamental_type_info::~__fundamental_type_info() {}
 
 // __cxxabiv1::__fundamental_type_info
 // FUND-DEF: @_ZTVN10__cxxabiv123__fundamental_type_infoE = unnamed_addr constant
-// FUND-DEF: @_ZTSN10__cxxabiv123__fundamental_type_infoE = constant
 // FUND-DEF: @_ZTIN10__cxxabiv123__fundamental_type_infoE = constant
+// FUND-DEF: @_ZTSN10__cxxabiv123__fundamental_type_infoE = constant
 // FUND-HID: @_ZTVN10__cxxabiv123__fundamental_type_infoE = hidden unnamed_addr constant
-// FUND-HID: @_ZTSN10__cxxabiv123__fundamental_type_infoE = hidden constant
 // FUND-HID: @_ZTIN10__cxxabiv123__fundamental_type_infoE = hidden constant
+// FUND-HID: @_ZTSN10__cxxabiv123__fundamental_type_infoE = hidden constant
 // FUND-EXP: @_ZTVN10__cxxabiv123__fundamental_type_infoE = dllexport unnamed_addr constant
-// FUND-EXP: @_ZTSN10__cxxabiv123__fundamental_type_infoE = dllexport constant
 // FUND-EXP: @_ZTIN10__cxxabiv123__fundamental_type_infoE = dllexport constant
+// FUND-EXP: @_ZTSN10__cxxabiv123__fundamental_type_infoE = dllexport constant
 
 // void
-// FUND-DEF: @_ZTSv = constant
 // FUND-DEF: @_ZTIv = constant
-// FUND-DEF: @_ZTSPv = constant
+// FUND-DEF: @_ZTSv = constant
 // FUND-DEF: @_ZTIPv = constant
-// FUND-DEF: @_ZTSPKv = constant
+// FUND-DEF: @_ZTSPv = constant
 // FUND-DEF: @_ZTIPKv = constant
-// FUND-HID: @_ZTSv = hidden constant
+// FUND-DEF: @_ZTSPKv = constant
 // FUND-HID: @_ZTIv = hidden constant
-// FUND-HID: @_ZTSPv = hidden constant
+// FUND-HID: @_ZTSv = hidden constant
 // FUND-HID: @_ZTIPv = hidden constant
-// FUND-HID: @_ZTSPKv = hidden constant
+// FUND-HID: @_ZTSPv = hidden constant
 // FUND-HID: @_ZTIPKv = hidden constant
-// FUND-EXP: @_ZTSv = dllexport constant
+// FUND-HID: @_ZTSPKv = hidden constant
 // FUND-EXP: @_ZTIv = dllexport constant
-// FUND-EXP: @_ZTSPv = dllexport constant
+// FUND-EXP: @_ZTSv = dllexport constant
 // FUND-EXP: @_ZTIPv = dllexport constant
-// FUND-EXP: @_ZTSPKv = dllexport constant
+// FUND-EXP: @_ZTSPv = dllexport constant
 // FUND-EXP: @_ZTIPKv = dllexport constant
+// FUND-EXP: @_ZTSPKv = dllexport constant
 
 // std::nullptr_t
-// FUND-DEF: @_ZTSDn = constant
 // FUND-DEF: @_ZTIDn = constant
-// FUND-DEF: @_ZTSPDn = constant
+// FUND-DEF: @_ZTSDn = constant
 // FUND-DEF: @_ZTIPDn = constant
-// FUND-DEF: @_ZTSPKDn = constant
+// FUND-DEF: @_ZTSPDn = constant
 // FUND-DEF: @_ZTIPKDn = constant
-// FUND-HID: @_ZTSDn = hidden constant
+// FUND-DEF: @_ZTSPKDn = constant
 // FUND-HID: @_ZTIDn = hidden constant
-// FUND-HID: @_ZTSPDn = hidden constant
+// FUND-HID: @_ZTSDn = hidden constant
 // FUND-HID: @_ZTIPDn = hidden constant
-// FUND-HID: @_ZTSPKDn = hidden constant
+// FUND-HID: @_ZTSPDn = hidden constant
 // FUND-HID: @_ZTIPKDn = hidden constant
-// FUND-EXP: @_ZTSDn = dllexport constant
+// FUND-HID: @_ZTSPKDn = hidden constant
 // FUND-EXP: @_ZTIDn = dllexport constant
-// FUND-EXP: @_ZTSPDn = dllexport constant
+// FUND-EXP: @_ZTSDn = dllexport constant
 // FUND-EXP: @_ZTIPDn = dllexport constant
-// FUND-EXP: @_ZTSPKDn = dllexport constant
+// FUND-EXP: @_ZTSPDn = dllexport constant
 // FUND-EXP: @_ZTIPKDn = dllexport constant
+// FUND-EXP: @_ZTSPKDn = dllexport constant
 
 // bool
-// FUND-DEF: @_ZTSb = constant
 // FUND-DEF: @_ZTIb = constant
-// FUND-DEF: @_ZTSPb = constant
+// FUND-DEF: @_ZTSb = constant
 // FUND-DEF: @_ZTIPb = constant
-// FUND-DEF: @_ZTSPKb = constant
+// FUND-DEF: @_ZTSPb = constant
 // FUND-DEF: @_ZTIPKb = constant
-// FUND-HID: @_ZTSb = hidden constant
+// FUND-DEF: @_ZTSPKb = constant
 // FUND-HID: @_ZTIb = hidden constant
-// FUND-HID: @_ZTSPb = hidden constant
+// FUND-HID: @_ZTSb = hidden constant
 // FUND-HID: @_ZTIPb = hidden constant
-// FUND-HID: @_ZTSPKb = hidden constant
+// FUND-HID: @_ZTSPb = hidden constant
 // FUND-HID: @_ZTIPKb = hidden constant
-// FUND-EXP: @_ZTSb = dllexport constant
+// FUND-HID: @_ZTSPKb = hidden constant
 // FUND-EXP: @_ZTIb = dllexport constant
-// FUND-EXP: @_ZTSPb = dllexport constant
+// FUND-EXP: @_ZTSb = dllexport constant
 // FUND-EXP: @_ZTIPb = dllexport constant
-// FUND-EXP: @_ZTSPKb = dllexport constant
+// FUND-EXP: @_ZTSPb = dllexport constant
 // FUND-EXP: @_ZTIPKb = dllexport constant
+// FUND-EXP: @_ZTSPKb = dllexport constant
 
 // wchar_t
-// FUND-DEF: @_ZTSw = constant
 // FUND-DEF: @_ZTIw = constant
-// FUND-DEF: @_ZTSPw = constant
+// FUND-DEF: @_ZTSw = constant
 // FUND-DEF: @_ZTIPw = constant
-// FUND-DEF: @_ZTSPKw = constant
+// FUND-DEF: @_ZTSPw = constant
 // FUND-DEF: @_ZTIPKw = constant
-// FUND-HID: @_ZTSw = hidden constant
+// FUND-DEF: @_ZTSPKw = constant
 // FUND-HID: @_ZTIw = hidden constant
-// FUND-HID: @_ZTSPw = hidden constant
+// FUND-HID: @_ZTSw = hidden constant
 // FUND-HID: @_ZTIPw = hidden constant
-// FUND-HID: @_ZTSPKw = hidden constant
+// FUND-HID: @_ZTSPw = hidden constant
 // FUND-HID: @_ZTIPKw = hidden constant
-// FUND-EXP: @_ZTSw = dllexport constant
+// FUND-HID: @_ZTSPKw = hidden constant
 // FUND-EXP: @_ZTIw = dllexport constant
-// FUND-EXP: @_ZTSPw = dllexport constant
+// FUND-EXP: @_ZTSw = dllexport constant
 // FUND-EXP: @_ZTIPw = dllexport constant
-// FUND-EXP: @_ZTSPKw = dllexport constant
+// FUND-EXP: @_ZTSPw = dllexport constant
 // FUND-EXP: @_ZTIPKw = dllexport constant
+// FUND-EXP: @_ZTSPKw = dllexport constant
 
 // char
-// FUND-DEF: @_ZTSc = constant
 // FUND-DEF: @_ZTIc = constant
-// FUND-DEF: @_ZTSPc = constant
+// FUND-DEF: @_ZTSc = constant
 // FUND-DEF: @_ZTIPc = constant
-// FUND-DEF: @_ZTSPKc = constant
+// FUND-DEF: @_ZTSPc = constant
 // FUND-DEF: @_ZTIPKc = constant
-// FUND-HID: @_ZTSc = hidden constant
+// FUND-DEF: @_ZTSPKc = constant
 // FUND-HID: @_ZTIc = hidden constant
-// FUND-HID: @_ZTSPc = hidden constant
+// FUND-HID: @_ZTSc = hidden constant
 // FUND-HID: @_ZTIPc = hidden constant
-// FUND-HID: @_ZTSPKc = hidden constant
+// FUND-HID: @_ZTSPc = hidden constant
 // FUND-HID: @_ZTIPKc = hidden constant
-// FUND-EXP: @_ZTSc = dllexport constant
+// FUND-HID: @_ZTSPKc = hidden constant
 // FUND-EXP: @_ZTIc = dllexport constant
-// FUND-EXP: @_ZTSPc = dllexport constant
+// FUND-EXP: @_ZTSc = dllexport constant
 // FUND-EXP: @_ZTIPc = dllexport constant
-// FUND-EXP: @_ZTSPKc = dllexport constant
+// FUND-EXP: @_ZTSPc = dllexport constant
 // FUND-EXP: @_ZTIPKc = dllexport constant
+// FUND-EXP: @_ZTSPKc = dllexport constant
 
 // unsigned char
-// FUND-DEF: @_ZTSh = constant
 // FUND-DEF: @_ZTIh = constant
-// FUND-DEF: @_ZTSPh = constant
+// FUND-DEF: @_ZTSh = constant
 // FUND-DEF: @_ZTIPh = constant
-// FUND-DEF: @_ZTSPKh = constant
+// FUND-DEF: @_ZTSPh = constant
 // FUND-DEF: @_ZTIPKh = constant
-// FUND-HID: @_ZTSh = hidden constant
+// FUND-DEF: @_ZTSPKh = constant
 // FUND-HID: @_ZTIh = hidden constant
-// FUND-HID: @_ZTSPh = hidden constant
+// FUND-HID: @_ZTSh = hidden constant
 // FUND-HID: @_ZTIPh = hidden constant
-// FUND-HID: @_ZTSPKh = hidden constant
+// FUND-HID: @_ZTSPh = hidden constant
 // FUND-HID: @_ZTIPKh = hidden constant
-// FUND-EXP: @_ZTSh = dllexport constant
+// FUND-HID: @_ZTSPKh = hidden constant
 // FUND-EXP: @_ZTIh = dllexport constant
-// FUND-EXP: @_ZTSPh = dllexport constant
+// FUND-EXP: @_ZTSh = dllexport constant
 // FUND-EXP: @_ZTIPh = dllexport constant
-// FUND-EXP: @_ZTSPKh = dllexport constant
+// FUND-EXP: @_ZTSPh = dllexport constant
 // FUND-EXP: @_ZTIPKh = dllexport constant
+// FUND-EXP: @_ZTSPKh = dllexport constant
 
 // signed char
-// FUND-DEF: @_ZTSa = constant
 // FUND-DEF: @_ZTIa = constant
-// FUND-DEF: @_ZTSPa = constant
+// FUND-DEF: @_ZTSa = constant
 // FUND-DEF: @_ZTIPa = constant
-// FUND-DEF: @_ZTSPKa = constant
+// FUND-DEF: @_ZTSPa = constant
 // FUND-DEF: @_ZTIPKa = constant
-// FUND-HID: @_ZTSa = hidden constant
+// FUND-DEF: @_ZTSPKa = constant
 // FUND-HID: @_ZTIa = hidden constant
-// FUND-HID: @_ZTSPa = hidden constant
+// FUND-HID: @_ZTSa = hidden constant
 // FUND-HID: @_ZTIPa = hidden constant
-// FUND-HID: @_ZTSPKa = hidden constant
+// FUND-HID: @_ZTSPa = hidden constant
 // FUND-HID: @_ZTIPKa = hidden constant
-// FUND-EXP: @_ZTSa = dllexport constant
+// FUND-HID: @_ZTSPKa = hidden constant
 // FUND-EXP: @_ZTIa = dllexport constant
-// FUND-EXP: @_ZTSPa = dllexport constant
+// FUND-EXP: @_ZTSa = dllexport constant
 // FUND-EXP: @_ZTIPa = dllexport constant
-// FUND-EXP: @_ZTSPKa = dllexport constant
+// FUND-EXP: @_ZTSPa = dllexport constant
 // FUND-EXP: @_ZTIPKa = dllexport constant
+// FUND-EXP: @_ZTSPKa = dllexport constant
 
 // short
-// FUND-DEF: @_ZTSs = constant
 // FUND-DEF: @_ZTIs = constant
-// FUND-DEF: @_ZTSPs = constant
+// FUND-DEF: @_ZTSs = constant
 // FUND-DEF: @_ZTIPs = constant
-// FUND-DEF: @_ZTSPKs = constant
+// FUND-DEF: @_ZTSPs = constant
 // FUND-DEF: @_ZTIPKs = constant
-// FUND-HID: @_ZTSs = hidden constant
+// FUND-DEF: @_ZTSPKs = constant
 // FUND-HID: @_ZTIs = hidden constant
-// FUND-HID: @_ZTSPs = hidden constant
+// FUND-HID: @_ZTSs = hidden constant
 // FUND-HID: @_ZTIPs = hidden constant
-// FUND-HID: @_ZTSPKs = hidden constant
+// FUND-HID: @_ZTSPs = hidden constant
 // FUND-HID: @_ZTIPKs = hidden constant
-// FUND-EXP: @_ZTSs = dllexport constant
+// FUND-HID: @_ZTSPKs = hidden constant
 // FUND-EXP: @_ZTIs = dllexport constant
-// FUND-EXP: @_ZTSPs = dllexport constant
+// FUND-EXP: @_ZTSs = dllexport constant
 // FUND-EXP: @_ZTIPs = dllexport constant
-// FUND-EXP: @_ZTSPKs = dllexport constant
+// FUND-EXP: @_ZTSPs = dllexport constant
 // FUND-EXP: @_ZTIPKs = dllexport constant
+// FUND-EXP: @_ZTSPKs = dllexport constant
 
 // unsigned short
-// FUND-DEF: @_ZTSt = constant
 // FUND-DEF: @_ZTIt = constant
-// FUND-DEF: @_ZTSPt = constant
+// FUND-DEF: @_ZTSt = constant
 // FUND-DEF: @_ZTIPt = constant
-// FUND-DEF: @_ZTSPKt = constant
+// FUND-DEF: @_ZTSPt = constant
 // FUND-DEF: @_ZTIPKt = constant
-// FUND-HID: @_ZTSt = hidden constant
+// FUND-DEF: @_ZTSPKt = constant
 // FUND-HID: @_ZTIt = hidden constant
-// FUND-HID: @_ZTSPt = hidden constant
+// FUND-HID: @_ZTSt = hidden constant
 // FUND-HID: @_ZTIPt = hidden constant
-// FUND-HID: @_ZTSPKt = hidden constant
+// FUND-HID: @_ZTSPt = hidden constant
 // FUND-HID: @_ZTIPKt = hidden constant
-// FUND-EXP: @_ZTSt = dllexport constant
+// FUND-HID: @_ZTSPKt = hidden constant
 // FUND-EXP: @_ZTIt = dllexport constant
-// FUND-EXP: @_ZTSPt = dllexport constant
+// FUND-EXP: @_ZTSt = dllexport constant
 // FUND-EXP: @_ZTIPt = dllexport constant
-// FUND-EXP: @_ZTSPKt = dllexport constant
+// FUND-EXP: @_ZTSPt = dllexport constant
 // FUND-EXP: @_ZTIPKt = dllexport constant
+// FUND-EXP: @_ZTSPKt = dllexport constant
 
 // int
-// FUND-DEF: @_ZTSi = constant
 // FUND-DEF: @_ZTIi = constant
-// FUND-DEF: @_ZTSPi = constant
+// FUND-DEF: @_ZTSi = constant
 // FUND-DEF: @_ZTIPi = constant
-// FUND-DEF: @_ZTSPKi = constant
+// FUND-DEF: @_ZTSPi = constant
 // FUND-DEF: @_ZTIPKi = constant
-// FUND-HID: @_ZTSi = hidden constant
+// FUND-DEF: @_ZTSPKi = constant
 // FUND-HID: @_ZTIi = hidden constant
-// FUND-HID: @_ZTSPi = hidden constant
+// FUND-HID: @_ZTSi = hidden constant
 // FUND-HID: @_ZTIPi = hidden constant
-// FUND-HID: @_ZTSPKi = hidden constant
+// FUND-HID: @_ZTSPi = hidden constant
 // FUND-HID: @_ZTIPKi = hidden constant
-// FUND-EXP: @_ZTSi = dllexport constant
+// FUND-HID: @_ZTSPKi = hidden constant
 // FUND-EXP: @_ZTIi = dllexport constant
-// FUND-EXP: @_ZTSPi = dllexport constant
+// FUND-EXP: @_ZTSi = dllexport constant
 // FUND-EXP: @_ZTIPi = dllexport constant
-// FUND-EXP: @_ZTSPKi = dllexport constant
+// FUND-EXP: @_ZTSPi = dllexport constant
 // FUND-EXP: @_ZTIPKi = dllexport constant
+// FUND-EXP: @_ZTSPKi = dllexport constant
 
 // unsigned int
-// FUND-DEF: @_ZTSj = constant
 // FUND-DEF: @_ZTIj = constant
-// FUND-DEF: @_ZTSPj = constant
+// FUND-DEF: @_ZTSj = constant
 // FUND-DEF: @_ZTIPj = constant
-// FUND-DEF: @_ZTSPKj = constant
+// FUND-DEF: @_ZTSPj = constant
 // FUND-DEF: @_ZTIPKj = constant
-// FUND-HID: @_ZTSj = hidden constant
+// FUND-DEF: @_ZTSPKj = constant
 // FUND-HID: @_ZTIj = hidden constant
-// FUND-HID: @_ZTSPj = hidden constant
+// FUND-HID: @_ZTSj = hidden constant
 // FUND-HID: @_ZTIPj = hidden constant
-// FUND-HID: @_ZTSPKj = hidden constant
+// FUND-HID: @_ZTSPj = hidden constant
 // FUND-HID: @_ZTIPKj = hidden constant
-// FUND-EXP: @_ZTSj = dllexport constant
+// FUND-HID: @_ZTSPKj = hidden constant
 // FUND-EXP: @_ZTIj = dllexport constant
-// FUND-EXP: @_ZTSPj = dllexport constant
+// FUND-EXP: @_ZTSj = dllexport constant
 // FUND-EXP: @_ZTIPj = dllexport constant
-// FUND-EXP: @_ZTSPKj = dllexport constant
+// FUND-EXP: @_ZTSPj = dllexport constant
 // FUND-EXP: @_ZTIPKj = dllexport constant
+// FUND-EXP: @_ZTSPKj = dllexport constant
 
 // long
-// FUND-DEF: @_ZTSl = constant
 // FUND-DEF: @_ZTIl = constant
-// FUND-DEF: @_ZTSPl = constant
+// FUND-DEF: @_ZTSl = constant
 // FUND-DEF: @_ZTIPl = constant
-// FUND-DEF: @_ZTSPKl = constant
+// FUND-DEF: @_ZTSPl = constant
 // FUND-DEF: @_ZTIPKl = constant
-// FUND-HID: @_ZTSl = hidden constant
+// FUND-DEF: @_ZTSPKl = constant
 // FUND-HID: @_ZTIl = hidden constant
-// FUND-HID: @_ZTSPl = hidden constant
+// FUND-HID: @_ZTSl = hidden constant
 // FUND-HID: @_ZTIPl = hidden constant
-// FUND-HID: @_ZTSPKl = hidden constant
+// FUND-HID: @_ZTSPl = hidden constant
 // FUND-HID: @_ZTIPKl = hidden constant
-// FUND-EXP: @_ZTSl = dllexport constant
+// FUND-HID: @_ZTSPKl = hidden constant
 // FUND-EXP: @_ZTIl = dllexport constant
-// FUND-EXP: @_ZTSPl = dllexport constant
+// FUND-EXP: @_ZTSl = dllexport constant
 // FUND-EXP: @_ZTIPl = dllexport constant
-// FUND-EXP: @_ZTSPKl = dllexport constant
+// FUND-EXP: @_ZTSPl = dllexport constant
 // FUND-EXP: @_ZTIPKl = dllexport constant
+// FUND-EXP: @_ZTSPKl = dllexport constant
 
 // unsigned long
-// FUND-DEF: @_ZTSm = constant
 // FUND-DEF: @_ZTIm = constant
-// FUND-DEF: @_ZTSPm = constant
+// FUND-DEF: @_ZTSm = constant
 // FUND-DEF: @_ZTIPm = constant
-// FUND-DEF: @_ZTSPKm = constant
+// FUND-DEF: @_ZTSPm = constant
 // FUND-DEF: @_ZTIPKm = constant
-// FUND-HID: @_ZTSm = hidden constant
+// FUND-DEF: @_ZTSPKm = constant
 // FUND-HID: @_ZTIm = hidden constant
-// FUND-HID: @_ZTSPm = hidden constant
+// FUND-HID: @_ZTSm = hidden constant
 // FUND-HID: @_ZTIPm = hidden constant
-// FUND-HID: @_ZTSPKm = hidden constant
+// FUND-HID: @_ZTSPm = hidden constant
 // FUND-HID: @_ZTIPKm = hidden constant
-// FUND-EXP: @_ZTSm = dllexport constant
+// FUND-HID: @_ZTSPKm = hidden constant
 // FUND-EXP: @_ZTIm = dllexport constant
-// FUND-EXP: @_ZTSPm = dllexport constant
+// FUND-EXP: @_ZTSm = dllexport constant
 // FUND-EXP: @_ZTIPm = dllexport constant
-// FUND-EXP: @_ZTSPKm = dllexport constant
+// FUND-EXP: @_ZTSPm = dllexport constant
 // FUND-EXP: @_ZTIPKm = dllexport constant
+// FUND-EXP: @_ZTSPKm = dllexport constant
 
 // long long
-// FUND-DEF: @_ZTSx = constant
 // FUND-DEF: @_ZTIx = constant
-// FUND-DEF: @_ZTSPx = constant
+// FUND-DEF: @_ZTSx = constant
 // FUND-DEF: @_ZTIPx = constant
-// FUND-DEF: @_ZTSPKx = constant
+// FUND-DEF: @_ZTSPx = constant
 // FUND-DEF: @_ZTIPKx = constant
-// FUND-HID: @_ZTSx = hidden constant
+// FUND-DEF: @_ZTSPKx = constant
 // FUND-HID: @_ZTIx = hidden constant
-// FUND-HID: @_ZTSPx = hidden constant
+// FUND-HID: @_ZTSx = hidden constant
 // FUND-HID: @_ZTIPx = hidden constant
-// FUND-HID: @_ZTSPKx = hidden constant
+// FUND-HID: @_ZTSPx = hidden constant
 // FUND-HID: @_ZTIPKx = hidden constant
-// FUND-EXP: @_ZTSx = dllexport constant
+// FUND-HID: @_ZTSPKx = hidden constant
 // FUND-EXP: @_ZTIx = dllexport constant
-// FUND-EXP: @_ZTSPx = dllexport constant
+// FUND-EXP: @_ZTSx = dllexport constant
 // FUND-EXP: @_ZTIPx = dllexport constant
-// FUND-EXP: @_ZTSPKx = dllexport constant
+// FUND-EXP: @_ZTSPx = dllexport constant
 // FUND-EXP: @_ZTIPKx = dllexport constant
+// FUND-EXP: @_ZTSPKx = dllexport constant
 
 // unsigned long long
-// FUND-DEF: @_ZTSy = constant
 // FUND-DEF: @_ZTIy = constant
-// FUND-DEF: @_ZTSPy = constant
+// FUND-DEF: @_ZTSy = constant
 // FUND-DEF: @_ZTIPy = constant
-// FUND-DEF: @_ZTSPKy = constant
+// FUND-DEF: @_ZTSPy = constant
 // FUND-DEF: @_ZTIPKy = constant
-// FUND-HID: @_ZTSy = hidden constant
+// FUND-DEF: @_ZTSPKy = constant
 // FUND-HID: @_ZTIy = hidden constant
-// FUND-HID: @_ZTSPy = hidden constant
+// FUND-HID: @_ZTSy = hidden constant
 // FUND-HID: @_ZTIPy = hidden constant
-// FUND-HID: @_ZTSPKy = hidden constant
+// FUND-HID: @_ZTSPy = hidden constant
 // FUND-HID: @_ZTIPKy = hidden constant
-// FUND-EXP: @_ZTSy = dllexport constant
+// FUND-HID: @_ZTSPKy = hidden constant
 // FUND-EXP: @_ZTIy = dllexport constant
-// FUND-EXP: @_ZTSPy = dllexport constant
+// FUND-EXP: @_ZTSy = dllexport constant
 // FUND-EXP: @_ZTIPy = dllexport constant
-// FUND-EXP: @_ZTSPKy = dllexport constant
+// FUND-EXP: @_ZTSPy = dllexport constant
 // FUND-EXP: @_ZTIPKy = dllexport constant
+// FUND-EXP: @_ZTSPKy = dllexport constant
 
 // __int128
-// FUND-DEF: @_ZTSn = constant
 // FUND-DEF: @_ZTIn = constant
-// FUND-DEF: @_ZTSPn = constant
+// FUND-DEF: @_ZTSn = constant
 // FUND-DEF: @_ZTIPn = constant
-// FUND-DEF: @_ZTSPKn = constant
+// FUND-DEF: @_ZTSPn = constant
 // FUND-DEF: @_ZTIPKn = constant
-// FUND-HID: @_ZTSn = hidden constant
+// FUND-DEF: @_ZTSPKn = constant
 // FUND-HID: @_ZTIn = hidden constant
-// FUND-HID: @_ZTSPn = hidden constant
+// FUND-HID: @_ZTSn = hidden constant
 // FUND-HID: @_ZTIPn = hidden constant
-// FUND-HID: @_ZTSPKn = hidden constant
+// FUND-HID: @_ZTSPn = hidden constant
 // FUND-HID: @_ZTIPKn = hidden constant
-// FUND-EXP: @_ZTSn = dllexport constant
+// FUND-HID: @_ZTSPKn = hidden constant
 // FUND-EXP: @_ZTIn = dllexport constant
-// FUND-EXP: @_ZTSPn = dllexport constant
+// FUND-EXP: @_ZTSn = dllexport constant
 // FUND-EXP: @_ZTIPn = dllexport constant
-// FUND-EXP: @_ZTSPKn = dllexport constant
+// FUND-EXP: @_ZTSPn = dllexport constant
 // FUND-EXP: @_ZTIPKn = dllexport constant
+// FUND-EXP: @_ZTSPKn = dllexport constant
 
 // unsigned __int128
-// FUND-DEF: @_ZTSo = constant
 // FUND-DEF: @_ZTIo = constant
-// FUND-DEF: @_ZTSPo = constant
+// FUND-DEF: @_ZTSo = constant
 // FUND-DEF: @_ZTIPo = constant
-// FUND-DEF: @_ZTSPKo = constant
+// FUND-DEF: @_ZTSPo = constant
 // FUND-DEF: @_ZTIPKo = constant
-// FUND-HID: @_ZTSo = hidden constant
+// FUND-DEF: @_ZTSPKo = constant
 // FUND-HID: @_ZTIo = hidden constant
-// FUND-HID: @_ZTSPo = hidden constant
+// FUND-HID: @_ZTSo = hidden constant
 // FUND-HID: @_ZTIPo = hidden constant
-// FUND-HID: @_ZTSPKo = hidden constant
+// FUND-HID: @_ZTSPo = hidden constant
 // FUND-HID: @_ZTIPKo = hidden constant
-// FUND-EXP: @_ZTSo = dllexport constant
+// FUND-HID: @_ZTSPKo = hidden constant
 // FUND-EXP: @_ZTIo = dllexport constant
-// FUND-EXP: @_ZTSPo = dllexport constant
+// FUND-EXP: @_ZTSo = dllexport constant
 // FUND-EXP: @_ZTIPo = dllexport constant
-// FUND-EXP: @_ZTSPKo = dllexport constant
+// FUND-EXP: @_ZTSPo = dllexport constant
 // FUND-EXP: @_ZTIPKo = dllexport constant
+// FUND-EXP: @_ZTSPKo = dllexport constant
 
 // half
-// FUND-DEF: @_ZTSDh = constant
 // FUND-DEF: @_ZTIDh = constant
-// FUND-DEF: @_ZTSPDh = constant
+// FUND-DEF: @_ZTSDh = constant
 // FUND-DEF: @_ZTIPDh = constant
-// FUND-DEF: @_ZTSPKDh = constant
+// FUND-DEF: @_ZTSPDh = constant
 // FUND-DEF: @_ZTIPKDh = constant
-// FUND-HID: @_ZTSDh = hidden constant
+// FUND-DEF: @_ZTSPKDh = constant
 // FUND-HID: @_ZTIDh = hidden constant
-// FUND-HID: @_ZTSPDh = hidden constant
+// FUND-HID: @_ZTSDh = hidden constant
 // FUND-HID: @_ZTIPDh = hidden constant
-// FUND-HID: @_ZTSPKDh = hidden constant
+// FUND-HID: @_ZTSPDh = hidden constant
 // FUND-HID: @_ZTIPKDh = hidden constant
-// FUND-EXP: @_ZTSDh = dllexport constant
+// FUND-HID: @_ZTSPKDh = hidden constant
 // FUND-EXP: @_ZTIDh = dllexport constant
-// FUND-EXP: @_ZTSPDh = dllexport constant
+// FUND-EXP: @_ZTSDh = dllexport constant
 // FUND-EXP: @_ZTIPDh = dllexport constant
-// FUND-EXP: @_ZTSPKDh = dllexport constant
+// FUND-EXP: @_ZTSPDh = dllexport constant
 // FUND-EXP: @_ZTIPKDh = dllexport constant
+// FUND-EXP: @_ZTSPKDh = dllexport constant
 
 // float
-// FUND-DEF: @_ZTSf = constant
 // FUND-DEF: @_ZTIf = constant
-// FUND-DEF: @_ZTSPf = constant
+// FUND-DEF: @_ZTSf = constant
 // FUND-DEF: @_ZTIPf = constant
-// FUND-DEF: @_ZTSPKf = constant
+// FUND-DEF: @_ZTSPf = constant
 // FUND-DEF: @_ZTIPKf = constant
-// FUND-HID: @_ZTSf = hidden constant
+// FUND-DEF: @_ZTSPKf = constant
 // FUND-HID: @_ZTIf = hidden constant
-// FUND-HID: @_ZTSPf = hidden constant
+// FUND-HID: @_ZTSf = hidden constant
 // FUND-HID: @_ZTIPf = hidden constant
-// FUND-HID: @_ZTSPKf = hidden constant
+// FUND-HID: @_ZTSPf = hidden constant
 // FUND-HID: @_ZTIPKf = hidden constant
-// FUND-EXP: @_ZTSf = dllexport constant
+// FUND-HID: @_ZTSPKf = hidden constant
 // FUND-EXP: @_ZTIf = dllexport constant
-// FUND-EXP: @_ZTSPf = dllexport constant
+// FUND-EXP: @_ZTSf = dllexport constant
 // FUND-EXP: @_ZTIPf = dllexport constant
-// FUND-EXP: @_ZTSPKf = dllexport constant
+// FUND-EXP: @_ZTSPf = dllexport constant
 // FUND-EXP: @_ZTIPKf = dllexport constant
+// FUND-EXP: @_ZTSPKf = dllexport constant
 
 // double
-// FUND-DEF: @_ZTSd = constant
 // FUND-DEF: @_ZTId = constant
-// FUND-DEF: @_ZTSPd = constant
+// FUND-DEF: @_ZTSd = constant
 // FUND-DEF: @_ZTIPd = constant
-// FUND-DEF: @_ZTSPKd = constant
+// FUND-DEF: @_ZTSPd = constant
 // FUND-DEF: @_ZTIPKd = constant
-// FUND-HID: @_ZTSd = hidden constant
+// FUND-DEF: @_ZTSPKd = constant
 // FUND-HID: @_ZTId = hidden constant
-// FUND-HID: @_ZTSPd = hidden constant
+// FUND-HID: @_ZTSd = hidden constant
 // FUND-HID: @_ZTIPd = hidden constant
-// FUND-HID: @_ZTSPKd = hidden constant
+// FUND-HID: @_ZTSPd = hidden constant
 // FUND-HID: @_ZTIPKd = hidden constant
-// FUND-EXP: @_ZTSd = dllexport constant
+// FUND-HID: @_ZTSPKd = hidden constant
 // FUND-EXP: @_ZTId = dllexport constant
-// FUND-EXP: @_ZTSPd = dllexport constant
+// FUND-EXP: @_ZTSd = dllexport constant
 // FUND-EXP: @_ZTIPd = dllexport constant
-// FUND-EXP: @_ZTSPKd = dllexport constant
+// FUND-EXP: @_ZTSPd = dllexport constant
 // FUND-EXP: @_ZTIPKd = dllexport constant
+// FUND-EXP: @_ZTSPKd = dllexport constant
 
 // long double
-// FUND-DEF: @_ZTSe = constant
 // FUND-DEF: @_ZTIe = constant
-// FUND-DEF: @_ZTSPe = constant
+// FUND-DEF: @_ZTSe = constant
 // FUND-DEF: @_ZTIPe = constant
-// FUND-DEF: @_ZTSPKe = constant
+// FUND-DEF: @_ZTSPe = constant
 // FUND-DEF: @_ZTIPKe = constant
-// FUND-HID: @_ZTSe = hidden constant
+// FUND-DEF: @_ZTSPKe = constant
 // FUND-HID: @_ZTIe = hidden constant
-// FUND-HID: @_ZTSPe = hidden constant
+// FUND-HID: @_ZTSe = hidden constant
 // FUND-HID: @_ZTIPe = hidden constant
-// FUND-HID: @_ZTSPKe = hidden constant
+// FUND-HID: @_ZTSPe = hidden constant
 // FUND-HID: @_ZTIPKe = hidden constant
-// FUND-EXP: @_ZTSe = dllexport constant
+// FUND-HID: @_ZTSPKe = hidden constant
 // FUND-EXP: @_ZTIe = dllexport constant
-// FUND-EXP: @_ZTSPe = dllexport constant
+// FUND-EXP: @_ZTSe = dllexport constant
 // FUND-EXP: @_ZTIPe = dllexport constant
-// FUND-EXP: @_ZTSPKe = dllexport constant
+// FUND-EXP: @_ZTSPe = dllexport constant
 // FUND-EXP: @_ZTIPKe = dllexport constant
+// FUND-EXP: @_ZTSPKe = dllexport constant
 
 // __ieee128
-// FUND-DEF: @_ZTSu9__ieee128 = constant
 // FUND-DEF: @_ZTIu9__ieee128 = constant
-// FUND-DEF: @_ZTSPu9__ieee128 = constant
+// FUND-DEF: @_ZTSu9__ieee128 = constant
 // FUND-DEF: @_ZTIPu9__ieee128 = constant
-// FUND-DEF: @_ZTSPKu9__ieee128 = constant
+// FUND-DEF: @_ZTSPu9__ieee128 = constant
 // FUND-DEF: @_ZTIPKu9__ieee128 = constant
-// FUND-HID: @_ZTSu9__ieee128 = hidden constant
+// FUND-DEF: @_ZTSPKu9__ieee128 = constant
 // FUND-HID: @_ZTIu9__ieee128 = hidden constant
-// FUND-HID: @_ZTSPu9__ieee128 = hidden constant
+// FUND-HID: @_ZTSu9__ieee128 = hidden constant
 // FUND-HID: @_ZTIPu9__ieee128 = hidden constant
-// FUND-HID: @_ZTSPKu9__ieee128 = hidden constant
+// FUND-HID: @_ZTSPu9__ieee128 = hidden constant
 // FUND-HID: @_ZTIPKu9__ieee128 = hidden constant
-// FUND-EXP: @_ZTSu9__ieee128 = dllexport constant
+// FUND-HID: @_ZTSPKu9__ieee128 = hidden constant
 // FUND-EXP: @_ZTIu9__ieee128 = dllexport constant
-// FUND-EXP: @_ZTSPu9__ieee128 = dllexport constant
+// FUND-EXP: @_ZTSu9__ieee128 = dllexport constant
 // FUND-EXP: @_ZTIPu9__ieee128 = dllexport constant
-// FUND-EXP: @_ZTSPKu9__ieee128 = dllexport constant
+// FUND-EXP: @_ZTSPu9__ieee128 = dllexport constant
 // FUND-EXP: @_ZTIPKu9__ieee128 = dllexport constant
+// FUND-EXP: @_ZTSPKu9__ieee128 = dllexport constant
 
 // char8_t
-// FUND-DEF: @_ZTSDu = constant
 // FUND-DEF: @_ZTIDu = constant
-// FUND-DEF: @_ZTSPDu = constant
+// FUND-DEF: @_ZTSDu = constant
 // FUND-DEF: @_ZTIPDu = constant
-// FUND-DEF: @_ZTSPKDu = constant
+// FUND-DEF: @_ZTSPDu = constant
 // FUND-DEF: @_ZTIPKDu = constant
-// FUND-HID: @_ZTSDu = hidden constant
+// FUND-DEF: @_ZTSPKDu = constant
 // FUND-HID: @_ZTIDu = hidden constant
-// FUND-HID: @_ZTSPDu = hidden constant
+// FUND-HID: @_ZTSDu = hidden constant
 // FUND-HID: @_ZTIPDu = hidden constant
-// FUND-HID: @_ZTSPKDu = hidden constant
+// FUND-HID: @_ZTSPDu = hidden constant
 // FUND-HID: @_ZTIPKDu = hidden constant
-// FUND-EXP: @_ZTSDu = dllexport constant
+// FUND-HID: @_ZTSPKDu = hidden constant
 // FUND-EXP: @_ZTIDu = dllexport constant
-// FUND-EXP: @_ZTSPDu = dllexport constant
+// FUND-EXP: @_ZTSDu = dllexport constant
 // FUND-EXP: @_ZTIPDu = dllexport constant
-// FUND-EXP: @_ZTSPKDu = dllexport constant
+// FUND-EXP: @_ZTSPDu = dllexport constant
 // FUND-EXP: @_ZTIPKDu = dllexport constant
+// FUND-EXP: @_ZTSPKDu = dllexport constant
 
 // char16_t
-// FUND-DEF: @_ZTSDs = constant
 // FUND-DEF: @_ZTIDs = constant
-// FUND-DEF: @_ZTSPDs = constant
+// FUND-DEF: @_ZTSDs = constant
 // FUND-DEF: @_ZTIPDs = constant
-// FUND-DEF: @_ZTSPKDs = constant
+// FUND-DEF: @_ZTSPDs = constant
 // FUND-DEF: @_ZTIPKDs = constant
-// FUND-HID: @_ZTSDs = hidden constant
+// FUND-DEF: @_ZTSPKDs = constant
 // FUND-HID: @_ZTIDs = hidden constant
-// FUND-HID: @_ZTSPDs = hidden constant
+// FUND-HID: @_ZTSDs = hidden constant
 // FUND-HID: @_ZTIPDs = hidden constant
-// FUND-HID: @_ZTSPKDs = hidden constant
+// FUND-HID: @_ZTSPDs = hidden constant
 // FUND-HID: @_ZTIPKDs = hidden constant
-// FUND-EXP: @_ZTSDs = dllexport constant
+// FUND-HID: @_ZTSPKDs = hidden constant
 // FUND-EXP: @_ZTIDs = dllexport constant
-// FUND-EXP: @_ZTSPDs = dllexport constant
+// FUND-EXP: @_ZTSDs = dllexport constant
 // FUND-EXP: @_ZTIPDs = dllexport constant
-// FUND-EXP: @_ZTSPKDs = dllexport constant
+// FUND-EXP: @_ZTSPDs = dllexport constant
 // FUND-EXP: @_ZTIPKDs = dllexport constant
+// FUND-EXP: @_ZTSPKDs = dllexport constant
 
 // char32_t
-// FUND-DEF: @_ZTSDi = constant
 // FUND-DEF: @_ZTIDi = constant
-// FUND-DEF: @_ZTSPDi = constant
+// FUND-DEF: @_ZTSDi = constant
 // FUND-DEF: @_ZTIPDi = constant
-// FUND-DEF: @_ZTSPKDi = constant
+// FUND-DEF: @_ZTSPDi = constant
 // FUND-DEF: @_ZTIPKDi = constant
-// FUND-HID: @_ZTSDi = hidden constant
+// FUND-DEF: @_ZTSPKDi = constant
 // FUND-HID: @_ZTIDi = hidden constant
-// FUND-HID: @_ZTSPDi = hidden constant
+// FUND-HID: @_ZTSDi = hidden constant
 // FUND-HID: @_ZTIPDi = hidden constant
-// FUND-HID: @_ZTSPKDi = hidden constant
+// FUND-HID: @_ZTSPDi = hidden constant
 // FUND-HID: @_ZTIPKDi = hidden constant
-// FUND-EXP: @_ZTSDi = dllexport constant
+// FUND-HID: @_ZTSPKDi = hidden constant
 // FUND-EXP: @_ZTIDi = dllexport constant
-// FUND-EXP: @_ZTSPDi = dllexport constant
+// FUND-EXP: @_ZTSDi = dllexport constant
 // FUND-EXP: @_ZTIPDi = dllexport constant
-// FUND-EXP: @_ZTSPKDi = dllexport constant
+// FUND-EXP: @_ZTSPDi = dllexport constant
 // FUND-EXP: @_ZTIPKDi = dllexport constant
+// FUND-EXP: @_ZTSPKDi = dllexport constant
diff --git a/clang/test/CodeGenCXX/modules-vtable.cppm b/clang/test/CodeGenCXX/modules-vtable.cppm
index 5cc3504d72628f..6589b9f3c5d649 100644
--- a/clang/test/CodeGenCXX/modules-vtable.cppm
+++ b/clang/test/CodeGenCXX/modules-vtable.cppm
@@ -40,13 +40,13 @@ inline
 Base::~Base() {}
 
 // CHECK: @_ZTVW3Mod4Base = unnamed_addr constant
-// CHECK: @_ZTSW3Mod4Base = constant
 // CHECK: @_ZTIW3Mod4Base = constant
+// CHECK: @_ZTSW3Mod4Base = constant
 
 // With the new Itanium C++ ABI, the linkage of vtables in modules don't need to be linkonce ODR.
 // CHECK-INLINE: @_ZTVW3Mod4Base = {{.*}}unnamed_addr constant
-// CHECK-INLINE: @_ZTSW3Mod4Base = {{.*}}constant
 // CHECK-INLINE: @_ZTIW3Mod4Base = {{.*}}constant
+// CHECK-INLINE: @_ZTSW3Mod4Base = {{.*}}constant
 
 module :private;
 int private_use() {
@@ -61,12 +61,12 @@ int use() {
     return 43;
 }
 
-// CHECK-NOT: @_ZTSW3Mod4Base
 // CHECK-NOT: @_ZTIW3Mod4Base
+// CHECK-NOT: @_ZTSW3Mod4Base
 // CHECK: @_ZTVW3Mod4Base = external
 
-// CHECK-INLINE-NOT: @_ZTSW3Mod4Base
 // CHECK-INLINE-NOT: @_ZTIW3Mod4Base
+// CHECK-INLINE-NOT: @_ZTSW3Mod4Base
 // CHECK-INLINE: @_ZTVW3Mod4Base = external
 
 // Check the case that the declaration of the key function comes from another
@@ -86,8 +86,8 @@ int a_use() {
 }
 
 // CHECK: @_ZTVW1M1C = unnamed_addr constant
-// CHECK: @_ZTSW1M1C = constant
 // CHECK: @_ZTIW1M1C = constant
+// CHECK: @_ZTSW1M1C = constant
 
 //--- M-B.cppm
 export module M:B;
@@ -101,5 +101,5 @@ int b_use() {
 }
 
 // CHECK: @_ZTVW1M1C = external
-// CHECK-NOT: @_ZTSW1M1C
 // CHECK-NOT: @_ZTIW1M1C
+// CHECK-NOT: @_ZTSW1M1C
diff --git a/clang/test/CodeGenCXX/ptrauth-rtti-layout.cpp b/clang/test/CodeGenCXX/ptrauth-rtti-layout.cpp
index 2b633addd677e0..b50e0908f9db88 100644
--- a/clang/test/CodeGenCXX/ptrauth-rtti-layout.cpp
+++ b/clang/test/CodeGenCXX/ptrauth-rtti-layout.cpp
@@ -5,12 +5,12 @@
 
 struct A { int a; };
 
+// DARWIN: @_ZTI1A = linkonce_odr hidden constant { ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), i32 2), ptr inttoptr (i64 add (i64 ptrtoint (ptr @_ZTS1A to i64), i64 -9223372036854775808) to ptr) }
 // DARWIN: @_ZTVN10__cxxabiv117__class_type_infoE = external global [0 x ptr]
 // DARWIN: @_ZTS1A = linkonce_odr hidden constant [3 x i8] c"1A\00"
-// DARWIN: @_ZTI1A = linkonce_odr hidden constant { ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), i32 2), ptr inttoptr (i64 add (i64 ptrtoint (ptr @_ZTS1A to i64), i64 -9223372036854775808) to ptr) }
 
+// ELF: @_ZTI1A = linkonce_odr constant { ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), i32 2), ptr @_ZTS1A }
 // ELF: @_ZTVN10__cxxabiv117__class_type_infoE = external global [0 x ptr]
 // ELF: @_ZTS1A = linkonce_odr constant [3 x i8] c"1A\00"
-// ELF: @_ZTI1A = linkonce_odr constant { ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), i32 2), ptr @_ZTS1A }
 
 auto ATI = typeid(A);
diff --git a/clang/test/CodeGenCXX/ptrauth-vtable-virtual-inheritance-thunk.cpp b/clang/test/CodeGenCXX/ptrauth-vtable-virtual-inheritance-thunk.cpp
index 031bb48608af7c..b5c15a29eb6b95 100644
--- a/clang/test/CodeGenCXX/ptrauth-vtable-virtual-inheritance-thunk.cpp
+++ b/clang/test/CodeGenCXX/ptrauth-vtable-virtual-inheritance-thunk.cpp
@@ -94,30 +94,30 @@
 // CHECK-SAME: ptr ptrauth (ptr @_ZN1AD1Ev, i32 0, i64 2043, ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV1A, i32 0, i32 0, i32 5)),
 // CHECK-SAME: ptr ptrauth (ptr @_ZN1AD0Ev, i32 0, i64 63674, ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV1A, i32 0, i32 0, i32 6))] }, align 8
 
+// CHECK: @_ZTI1A = constant { ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), i32 2), ptr @_ZTS1A }, align 8
+
 // CHECK: @_ZTVN10__cxxabiv117__class_type_infoE = external global [0 x ptr]
 
 // CHECK: @_ZTS1A = constant [3 x i8] c"1A\00", align 1
 
-// CHECK: @_ZTI1A = constant { ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), i32 2), ptr @_ZTS1A }, align 8
+// CHECK: @_ZTI1C = constant { ptr, ptr, i32, i32, ptr, i64 } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv121__vmi_class_type_infoE, i64 2), i32 2), ptr @_ZTS1C, i32 0, i32 1, ptr @_ZTI1B, i64 -6141 }, align 8
 
 // CHECK: @_ZTVN10__cxxabiv121__vmi_class_type_infoE = external global [0 x ptr]
 
 // CHECK: @_ZTS1C = constant [3 x i8] c"1C\00", align 1
 
+// DARWIN: @_ZTI1B = linkonce_odr hidden constant { ptr, ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv120__si_class_type_infoE, i64 2), i32 2), ptr inttoptr (i64 add (i64 ptrtoint (ptr @_ZTS1B to i64), i64 -9223372036854775808) to ptr), ptr @_ZTI1A }, align 8
+// ELF:    @_ZTI1B = linkonce_odr constant { ptr, ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv120__si_class_type_infoE, i64 2), i32 2), ptr @_ZTS1B, ptr @_ZTI1A }, comdat, align 8
+
 // CHECK: @_ZTVN10__cxxabiv120__si_class_type_infoE = external global [0 x ptr]
 
 // DARWIN: @_ZTS1B = linkonce_odr hidden constant [3 x i8] c"1B\00", align 1
 // ELF:    @_ZTS1B = linkonce_odr constant [3 x i8] c"1B\00", comdat, align 1
 
-// DARWIN: @_ZTI1B = linkonce_odr hidden constant { ptr, ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv120__si_class_type_infoE, i64 2), i32 2), ptr inttoptr (i64 add (i64 ptrtoint (ptr @_ZTS1B to i64), i64 -9223372036854775808) to ptr), ptr @_ZTI1A }, align 8
-// ELF:    @_ZTI1B = linkonce_odr constant { ptr, ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv120__si_class_type_infoE, i64 2), i32 2), ptr @_ZTS1B, ptr @_ZTI1A }, comdat, align 8
-
-// CHECK: @_ZTI1C = constant { ptr, ptr, i32, i32, ptr, i64 } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv121__vmi_class_type_infoE, i64 2), i32 2), ptr @_ZTS1C, i32 0, i32 1, ptr @_ZTI1B, i64 -6141 }, align 8
+// CHECK: @_ZTI1D = constant { ptr, ptr, i32, i32, ptr, i64 } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv121__vmi_class_type_infoE, i64 2), i32 2), ptr @_ZTS1D, i32 0, i32 1, ptr @_ZTI1B, i64 -6141 }, align 8
 
 // CHECK: @_ZTS1D = constant [3 x i8] c"1D\00", align 1
 
-// CHECK: @_ZTI1D = constant { ptr, ptr, i32, i32, ptr, i64 } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv121__vmi_class_type_infoE, i64 2), i32 2), ptr @_ZTS1D, i32 0, i32 1, ptr @_ZTI1B, i64 -6141 }, align 8
-
 // CHECK: @_ZTV1E = unnamed_addr constant { [7 x ptr] } { [7 x ptr] [ptr null, ptr @_ZTI1E,
 // CHECK-SAME: ptr ptrauth (ptr @_ZN1E1fEv, i32 0, i64 28408, ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV1E, i32 0, i32 0, i32 2)),
 // CHECK-SAME: ptr ptrauth (ptr @_ZN1E1gEv, i32 0, i64 22926, ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV1E, i32 0, i32 0, i32 3)),
@@ -125,10 +125,10 @@
 // CHECK-SAME: ptr ptrauth (ptr @_ZN1ED1Ev, i32 0, i64 5817, ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV1E, i32 0, i32 0, i32 5)),
 // CHECK-SAME: ptr ptrauth (ptr @_ZN1ED0Ev, i32 0, i64 26464, ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV1E, i32 0, i32 0, i32 6))] }, align 8
 
-// CHECK: @_ZTS1E = constant [3 x i8] c"1E\00", align 1
-
 // CHECK: @_ZTI1E = constant { ptr, ptr } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), i32 2), ptr @_ZTS1E }, align 8
 
+// CHECK: @_ZTS1E = constant [3 x i8] c"1E\00", align 1
+
 // CHECK: @_ZTC1F0_1C = unnamed_addr constant { [5 x ptr], [11 x ptr] } { [5 x ptr] [ptr inttoptr (i64 16 to ptr), ptr null, ptr @_ZTI1C,
 // CHECK-SAME: ptr ptrauth (ptr @_ZN1CD1Ev, i32 0, i64 31214, ptr getelementptr inbounds ({ [5 x ptr], [11 x ptr] }, ptr @_ZTC1F0_1C, i32 0, i32 0, i32 3)),
 // CHECK-SAME: ptr ptrauth (ptr @_ZN1CD0Ev, i32 0, i64 8507, ptr getelementptr inbounds ({ [5 x ptr], [11 x ptr] }, ptr @_ZTC1F0_1C, i32 0, i32 0, i32 4))], [11 x ptr] [ptr inttoptr (i64 -16 to ptr), ptr null, ptr null, ptr null, ptr inttoptr (i64 -16 to ptr), ptr @_ZTI1C,
@@ -149,10 +149,10 @@
 // CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N1DD1Ev, i32 0, i64 2043, ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC1F8_1D, i32 0, i32 1, i32 9)),
 // CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N1DD0Ev, i32 0, i64 63674, ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC1F8_1D, i32 0, i32 1, i32 10))] }, align 8
 
-// CHECK: @_ZTS1F = constant [3 x i8] c"1F\00", align 1
-
 // CHECK: @_ZTI1F = constant { ptr, ptr, i32, i32, ptr, i64, ptr, i64, ptr, i64 } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv121__vmi_class_type_infoE, i64 2), i32 2), ptr @_ZTS1F, i32 3, i32 3, ptr @_ZTI1C, i64 2, ptr @_ZTI1D, i64 2050, ptr @_ZTI1E, i64 -8189 }, align 8
 
+// CHECK: @_ZTS1F = constant [3 x i8] c"1F\00", align 1
+
 // CHECK: @_ZTC1G0_1C = unnamed_addr constant { [5 x ptr], [11 x ptr] } { [5 x ptr] [ptr inttoptr (i64 24 to ptr), ptr null, ptr @_ZTI1C,
 // CHECK-SAME: ptr ptrauth (ptr @_ZN1CD1Ev, i32 0, i64 31214, ptr getelementptr inbounds ({ [5 x ptr], [11 x ptr] }, ptr @_ZTC1G0_1C, i32 0, i32 0, i32 3)),
 // CHECK-SAME: ptr ptrauth (ptr @_ZN1CD0Ev, i32 0, i64 8507, ptr getelementptr inbounds ({ [5 x ptr], [11 x ptr] }, ptr @_ZTC1G0_1C, i32 0, i32 0, i32 4))], [11 x ptr] [ptr inttoptr (i64 -24 to ptr), ptr null, ptr null, ptr null, ptr inttoptr (i64 -24 to ptr), ptr @_ZTI1C,
@@ -173,10 +173,10 @@
 // CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N1DD1Ev, i32 0, i64 2043, ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC1G8_1D, i32 0, i32 1, i32 9)),
 // CHECK-SAME: ptr ptrauth (ptr @_ZTv0_n48_N1DD0Ev, i32 0, i64 63674, ptr getelementptr inbounds ({ [7 x ptr], [11 x ptr] }, ptr @_ZTC1G8_1D, i32 0, i32 1, i32 10))] }, align 8
 
-// CHECK: @_ZTS1G = constant [3 x i8] c"1G\00", align 1
-
 // CHECK: @_ZTI1G = constant { ptr, ptr, i32, i32, ptr, i64, ptr, i64, ptr, i64 } { ptr ptrauth (ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv121__vmi_class_type_infoE, i64 2), i32 2), ptr @_ZTS1G, i32 3, i32 3, ptr @_ZTI1E, i64 -8189, ptr @_ZTI1C, i64 2, ptr @_ZTI1D, i64 2050 }, align 8
 
+// CHECK: @_ZTS1G = constant [3 x i8] c"1G\00", align 1
+
 // CHECK: @_ZTV1B = linkonce_odr unnamed_addr constant { [7 x ptr] } { [7 x ptr] [ptr null, ptr @_ZTI1B,
 // CHECK-SAME: ptr ptrauth (ptr @_ZN1A1fEv, i32 0, i64 55636, ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV1B, i32 0, i32 0, i32 2)),
 // CHECK-SAME: ptr ptrauth (ptr @_ZN1A1gEv, i32 0, i64 19402, ptr getelementptr inbounds ({ [7 x ptr] }, ptr @_ZTV1B, i32 0, i32 0, i32 3)),
diff --git a/clang/test/CodeGenCXX/rtti-linkage.cpp b/clang/test/CodeGenCXX/rtti-linkage.cpp
index ca50a1bc6f01a7..03e7cdedd3462c 100644
--- a/clang/test/CodeGenCXX/rtti-linkage.cpp
+++ b/clang/test/CodeGenCXX/rtti-linkage.cpp
@@ -3,73 +3,73 @@
 
 #include <typeinfo>
 
+// CHECK-BOTH: _ZTIP1C = internal constant
 // CHECK-BOTH: _ZTSP1C = internal constant
-// CHECK-BOTH: _ZTS1C = internal constant
 // CHECK-BOTH: _ZTI1C = internal constant
-// CHECK-BOTH: _ZTIP1C = internal constant
-// CHECK-BOTH: _ZTSPP1C = internal constant
+// CHECK-BOTH: _ZTS1C = internal constant
 // CHECK-BOTH: _ZTIPP1C = internal constant
-// CHECK-BOTH: _ZTSM1Ci = internal constant
+// CHECK-BOTH: _ZTSPP1C = internal constant
 // CHECK-BOTH: _ZTIM1Ci = internal constant
-// CHECK-BOTH: _ZTSPM1Ci = internal constant
+// CHECK-BOTH: _ZTSM1Ci = internal constant
 // CHECK-BOTH: _ZTIPM1Ci = internal constant
-// CHECK-BOTH: _ZTSM1CS_ = internal constant
+// CHECK-BOTH: _ZTSPM1Ci = internal constant
 // CHECK-BOTH: _ZTIM1CS_ = internal constant
-// CHECK-BOTH: _ZTSM1CPS_ = internal constant
+// CHECK-BOTH: _ZTSM1CS_ = internal constant
 // CHECK-BOTH: _ZTIM1CPS_ = internal constant
+// CHECK-BOTH: _ZTSM1CPS_ = internal constant
+// CHECK-BOTH: _ZTIM1A1C = internal constant
 // CHECK-BOTH: _ZTSM1A1C = internal constant
-// CHECK: _ZTS1A = linkonce_odr constant
-// CHECK-WITH-HIDDEN: _ZTS1A = linkonce_odr hidden constant
 // CHECK: _ZTI1A = linkonce_odr constant
 // CHECK-WITH-HIDDEN: _ZTI1A = linkonce_odr hidden constant
-// CHECK-BOTH: _ZTIM1A1C = internal constant
-// CHECK-BOTH: _ZTSM1AP1C = internal constant
+// CHECK: _ZTS1A = linkonce_odr constant
+// CHECK-WITH-HIDDEN: _ZTS1A = linkonce_odr hidden constant
 // CHECK-BOTH: _ZTIM1AP1C = internal constant
+// CHECK-BOTH: _ZTSM1AP1C = internal constant
 
 // CHECK-WITH-HIDDEN: _ZTSFN12_GLOBAL__N_11DEvE = internal constant
-// CHECK-WITH-HIDDEN: @_ZTSPK2T4 = linkonce_odr hidden constant 
-// CHECK-WITH-HIDDEN: @_ZTS2T4 = linkonce_odr hidden constant 
-// CHECK-WITH-HIDDEN: @_ZTI2T4 = linkonce_odr hidden constant 
-// CHECK-WITH-HIDDEN: @_ZTIPK2T4 = linkonce_odr hidden constant 
-// CHECK-WITH-HIDDEN: @_ZTSZ2t5vE1A = internal constant
+// CHECK-WITH-HIDDEN: @_ZTIPK2T4 = linkonce_odr hidden constant
+// CHECK-WITH-HIDDEN: @_ZTSPK2T4 = linkonce_odr hidden constant
+// CHECK-WITH-HIDDEN: @_ZTI2T4 = linkonce_odr hidden constant
+// CHECK-WITH-HIDDEN: @_ZTS2T4 = linkonce_odr hidden constant
 // CHECK-WITH-HIDDEN: @_ZTIZ2t5vE1A = internal constant
-// CHECK-WITH-HIDDEN: @_ZTSZ2t6vE1A = linkonce_odr hidden constant
+// CHECK-WITH-HIDDEN: @_ZTSZ2t5vE1A = internal constant
 // CHECK-WITH-HIDDEN: @_ZTIZ2t6vE1A = linkonce_odr hidden constant
+// CHECK-WITH-HIDDEN: @_ZTSZ2t6vE1A = linkonce_odr hidden constant
+// CHECK-WITH-HIDDEN: @_ZTIPZ2t7vE1A = linkonce_odr hidden constant
 // CHECK-WITH-HIDDEN: @_ZTSPZ2t7vE1A = linkonce_odr hidden constant
-// CHECK-WITH-HIDDEN: @_ZTSZ2t7vE1A = linkonce_odr hidden constant
 // CHECK-WITH-HIDDEN: @_ZTIZ2t7vE1A = linkonce_odr hidden constant
-// CHECK-WITH-HIDDEN: @_ZTIPZ2t7vE1A = linkonce_odr hidden constant
+// CHECK-WITH-HIDDEN: @_ZTSZ2t7vE1A = linkonce_odr hidden constant
 
-// CHECK: _ZTSN12_GLOBAL__N_11DE = internal constant
 // CHECK: _ZTIN12_GLOBAL__N_11DE = internal constant
-// CHECK: _ZTSPN12_GLOBAL__N_11DE = internal constant
+// CHECK: _ZTSN12_GLOBAL__N_11DE = internal constant
 // CHECK: _ZTIPN12_GLOBAL__N_11DE = internal constant
-// CHECK: _ZTSFN12_GLOBAL__N_11DEvE = internal constant
+// CHECK: _ZTSPN12_GLOBAL__N_11DE = internal constant
 // CHECK: _ZTIFN12_GLOBAL__N_11DEvE = internal constant
-// CHECK: _ZTSFvN12_GLOBAL__N_11DEE = internal constant
+// CHECK: _ZTSFN12_GLOBAL__N_11DEvE = internal constant
 // CHECK: _ZTIFvN12_GLOBAL__N_11DEE = internal constant
+// CHECK: _ZTSFvN12_GLOBAL__N_11DEE = internal constant
+// CHECK: _ZTIPFvvE = linkonce_odr constant
 // CHECK: _ZTSPFvvE = linkonce_odr constant
-// CHECK: _ZTSFvvE = linkonce_odr constant
 // CHECK: _ZTIFvvE = linkonce_odr constant
-// CHECK: _ZTIPFvvE = linkonce_odr constant
-// CHECK: _ZTSN12_GLOBAL__N_11EE = internal constant
+// CHECK: _ZTSFvvE = linkonce_odr constant
 // CHECK: _ZTIN12_GLOBAL__N_11EE = internal constant
-// CHECK: _ZTSA10_i = linkonce_odr constant
+// CHECK: _ZTSN12_GLOBAL__N_11EE = internal constant
 // CHECK: _ZTIA10_i = linkonce_odr constant
+// CHECK: _ZTSA10_i = linkonce_odr constant
 // CHECK: _ZTI1TILj0EE = linkonce_odr constant
 // CHECK: _ZTI1TILj1EE = weak_odr constant
 // CHECK: _ZTI1TILj2EE = external constant
-// CHECK: _ZTSZ2t5vE1A = internal constant
 // CHECK: _ZTIZ2t5vE1A = internal constant
-// CHECK: _ZTS1B ={{.*}} constant
+// CHECK: _ZTSZ2t5vE1A = internal constant
 // CHECK: _ZTI1B ={{.*}} constant
+// CHECK: _ZTS1B ={{.*}} constant
 // CHECK: _ZTS1F = linkonce_odr constant
-// CHECK: _ZTSZ2t6vE1A = linkonce_odr constant
 // CHECK: _ZTIZ2t6vE1A = linkonce_odr constant
+// CHECK: _ZTSZ2t6vE1A = linkonce_odr constant
+// CHECK: _ZTIPZ2t7vE1A = linkonce_odr constant
 // CHECK: _ZTSPZ2t7vE1A = linkonce_odr constant
-// CHECK: _ZTSZ2t7vE1A = linkonce_odr constant
 // CHECK: _ZTIZ2t7vE1A = linkonce_odr constant
-// CHECK: _ZTIPZ2t7vE1A = linkonce_odr constant
+// CHECK: _ZTSZ2t7vE1A = linkonce_odr constant
 
 // CHECK: _ZTIN12_GLOBAL__N_11DE
 
diff --git a/clang/test/CodeGenCXX/rtti-visibility.cpp b/clang/test/CodeGenCXX/rtti-visibility.cpp
index 5945be5c73a260..1813fee658c72e 100644
--- a/clang/test/CodeGenCXX/rtti-visibility.cpp
+++ b/clang/test/CodeGenCXX/rtti-visibility.cpp
@@ -6,10 +6,10 @@
 
 namespace Test1 {
   // A is explicitly marked hidden, so all RTTI data should also be marked hidden.
-  // CHECK-TEST1: @_ZTSN5Test11AE = linkonce_odr hidden constant
   // CHECK-TEST1: @_ZTIN5Test11AE = linkonce_odr hidden constant
-  // CHECK-TEST1: @_ZTSPN5Test11AE = linkonce_odr hidden constant
+  // CHECK-TEST1: @_ZTSN5Test11AE = linkonce_odr hidden constant
   // CHECK-TEST1: @_ZTIPN5Test11AE = linkonce_odr hidden constant
+  // CHECK-TEST1: @_ZTSPN5Test11AE = linkonce_odr hidden constant
   struct __attribute__((visibility("hidden"))) A { };
 
   void f() {
@@ -20,8 +20,8 @@ namespace Test1 {
 
 namespace Test2 {
   // A is weak, so its linkage should be linkoce_odr, but not marked hidden.
-  // CHECK-TEST2: @_ZTSN5Test21AE = linkonce_odr constant
   // CHECK-TEST2: @_ZTIN5Test21AE = linkonce_odr constant
+  // CHECK-TEST2: @_ZTSN5Test21AE = linkonce_odr constant
   struct A { };
   void f() {
     (void)typeid(A);
diff --git a/clang/test/CodeGenCXX/symbol-partition.cpp b/clang/test/CodeGenCXX/symbol-partition.cpp
index ecc58e2a847dc1..cefeeac63f0147 100644
--- a/clang/test/CodeGenCXX/symbol-partition.cpp
+++ b/clang/test/CodeGenCXX/symbol-partition.cpp
@@ -2,8 +2,8 @@
 
 // CHECK: @gv = {{.*}}, partition "foo"
 // CHECK: @_ZTV1S = {{.*}}, partition "foo"
-// CHECK: @_ZTS1S = {{.*}}, partition "foo"
 // CHECK: @_ZTI1S = {{.*}}, partition "foo"
+// CHECK: @_ZTS1S = {{.*}}, partition "foo"
 
 // CHECK: @_Z5ifuncv = {{.*}}, partition "foo"
 
diff --git a/clang/test/CodeGenCXX/type_visibility.cpp b/clang/test/CodeGenCXX/type_visibility.cpp
index 13aafcff0fa13e..00833e36944df2 100644
--- a/clang/test/CodeGenCXX/type_visibility.cpp
+++ b/clang/test/CodeGenCXX/type_visibility.cpp
@@ -26,12 +26,12 @@ namespace temp0 {
   template struct B<A>;
   // FUNS-LABEL:        define weak_odr void @_ZN5temp01BINS_1AEE3fooEv(
   // VARS:        @_ZTVN5temp01BINS_1AEEE = weak_odr unnamed_addr constant
-  // VARS:        @_ZTSN5temp01BINS_1AEEE = weak_odr constant
   // VARS:        @_ZTIN5temp01BINS_1AEEE = weak_odr constant
+  // VARS:        @_ZTSN5temp01BINS_1AEEE = weak_odr constant
   // FUNS-HIDDEN-LABEL: define weak_odr hidden void @_ZN5temp01BINS_1AEE3fooEv(
   // VARS-HIDDEN: @_ZTVN5temp01BINS_1AEEE = weak_odr hidden unnamed_addr constant
-  // VARS-HIDDEN: @_ZTSN5temp01BINS_1AEEE = weak_odr hidden constant
   // VARS-HIDDEN: @_ZTIN5temp01BINS_1AEEE = weak_odr hidden constant
+  // VARS-HIDDEN: @_ZTSN5temp01BINS_1AEEE = weak_odr hidden constant
 }
 
 namespace temp1 {
@@ -43,12 +43,12 @@ namespace temp1 {
   template struct B<A>;
   // FUNS-LABEL:        define weak_odr void @_ZN5temp11BINS_1AEE3fooEv(
   // VARS:        @_ZTVN5temp11BINS_1AEEE = weak_odr unnamed_addr constant
-  // VARS:        @_ZTSN5temp11BINS_1AEEE = weak_odr constant
   // VARS:        @_ZTIN5temp11BINS_1AEEE = weak_odr constant
+  // VARS:        @_ZTSN5temp11BINS_1AEEE = weak_odr constant
   // FUNS-HIDDEN-LABEL: define weak_odr hidden void @_ZN5temp11BINS_1AEE3fooEv(
   // VARS-HIDDEN: @_ZTVN5temp11BINS_1AEEE = weak_odr unnamed_addr constant
-  // VARS-HIDDEN: @_ZTSN5temp11BINS_1AEEE = weak_odr constant
   // VARS-HIDDEN: @_ZTIN5temp11BINS_1AEEE = weak_odr constant
+  // VARS-HIDDEN: @_ZTSN5temp11BINS_1AEEE = weak_odr constant
 }
 
 namespace temp2 {
@@ -60,12 +60,12 @@ namespace temp2 {
   template struct B<A>;
   // FUNS-LABEL:        define weak_odr void @_ZN5temp21BINS_1AEE3fooEv(
   // VARS:        @_ZTVN5temp21BINS_1AEEE = weak_odr unnamed_addr constant
-  // VARS:        @_ZTSN5temp21BINS_1AEEE = weak_odr constant
   // VARS:        @_ZTIN5temp21BINS_1AEEE = weak_odr constant
+  // VARS:        @_ZTSN5temp21BINS_1AEEE = weak_odr constant
   // FUNS-HIDDEN-LABEL: define weak_odr hidden void @_ZN5temp21BINS_1AEE3fooEv(
   // VARS-HIDDEN: @_ZTVN5temp21BINS_1AEEE = weak_odr hidden unnamed_addr constant
-  // VARS-HIDDEN: @_ZTSN5temp21BINS_1AEEE = weak_odr hidden constant
   // VARS-HIDDEN: @_ZTIN5temp21BINS_1AEEE = weak_odr hidden constant
+  // VARS-HIDDEN: @_ZTSN5temp21BINS_1AEEE = weak_odr hidden constant
 }
 
 namespace temp3 {
@@ -77,12 +77,12 @@ namespace temp3 {
   template struct B<A>;
   // FUNS-LABEL:        define weak_odr hidden void @_ZN5temp31BINS_1AEE3fooEv(
   // VARS:        @_ZTVN5temp31BINS_1AEEE = weak_odr hidden unnamed_addr constant
-  // VARS:        @_ZTSN5temp31BINS_1AEEE = weak_odr hidden constant
   // VARS:        @_ZTIN5temp31BINS_1AEEE = weak_odr hidden constant
+  // VARS:        @_ZTSN5temp31BINS_1AEEE = weak_odr hidden constant
   // FUNS-HIDDEN-LABEL: define weak_odr hidden void @_ZN5temp31BINS_1AEE3fooEv(
   // VARS-HIDDEN: @_ZTVN5temp31BINS_1AEEE = weak_odr hidden unnamed_addr constant
-  // VARS-HIDDEN: @_ZTSN5temp31BINS_1AEEE = weak_odr hidden constant
   // VARS-HIDDEN: @_ZTIN5temp31BINS_1AEEE = weak_odr hidden constant
+  // VARS-HIDDEN: @_ZTSN5temp31BINS_1AEEE = weak_odr hidden constant
 }
 
 namespace temp4 {
@@ -94,12 +94,12 @@ namespace temp4 {
   template struct B<A>;
   // FUNS-LABEL:        define weak_odr void @_ZN5temp41BINS_1AEE3fooEv(
   // VARS:        @_ZTVN5temp41BINS_1AEEE = weak_odr hidden unnamed_addr constant
-  // VARS:        @_ZTSN5temp41BINS_1AEEE = weak_odr hidden constant
   // VARS:        @_ZTIN5temp41BINS_1AEEE = weak_odr hidden constant
+  // VARS:        @_ZTSN5temp41BINS_1AEEE = weak_odr hidden constant
   // FUNS-HIDDEN-LABEL: define weak_odr hidden void @_ZN5temp41BINS_1AEE3fooEv(
   // VARS-HIDDEN: @_ZTVN5temp41BINS_1AEEE = weak_odr hidden unnamed_addr constant
-  // VARS-HIDDEN: @_ZTSN5temp41BINS_1AEEE = weak_odr hidden constant
   // VARS-HIDDEN: @_ZTIN5temp41BINS_1AEEE = weak_odr hidden constant
+  // VARS-HIDDEN: @_ZTSN5temp41BINS_1AEEE = weak_odr hidden constant
 }
 
 namespace type0 {
@@ -110,12 +110,12 @@ namespace type0 {
   void A::foo() {}
   // FUNS-LABEL:        define void @_ZN5type01A3fooEv(
   // VARS:        @_ZTVN5type01AE = unnamed_addr constant
-  // VARS:        @_ZTSN5type01AE = constant
   // VARS:        @_ZTIN5type01AE = constant
+  // VARS:        @_ZTSN5type01AE = constant
   // FUNS-HIDDEN-LABEL: define hidden void @_ZN5type01A3fooEv(
   // VARS-HIDDEN: @_ZTVN5type01AE = unnamed_addr constant
-  // VARS-HIDDEN: @_ZTSN5type01AE = constant
   // VARS-HIDDEN: @_ZTIN5type01AE = constant
+  // VARS-HIDDEN: @_ZTSN5type01AE = constant
 }
 
 namespace type1 {
@@ -126,12 +126,12 @@ namespace type1 {
   void A::foo() {}
   // FUNS-LABEL:        define hidden void @_ZN5type11A3fooEv(
   // VARS:        @_ZTVN5type11AE = unnamed_addr constant
-  // VARS:        @_ZTSN5type11AE = constant
   // VARS:        @_ZTIN5type11AE = constant
+  // VARS:        @_ZTSN5type11AE = constant
   // FUNS-HIDDEN-LABEL: define hidden void @_ZN5type11A3fooEv(
   // VARS-HIDDEN: @_ZTVN5type11AE = unnamed_addr constant
-  // VARS-HIDDEN: @_ZTSN5type11AE = constant
   // VARS-HIDDEN: @_ZTIN5type11AE = constant
+  // VARS-HIDDEN: @_ZTSN5type11AE = constant
 }
 
 namespace type2 {
@@ -142,12 +142,12 @@ namespace type2 {
   void A::foo() {}
   // FUNS-LABEL:        define void @_ZN5type21A3fooEv(
   // VARS:        @_ZTVN5type21AE = hidden unnamed_addr constant
-  // VARS:        @_ZTSN5type21AE = hidden constant
   // VARS:        @_ZTIN5type21AE = hidden constant
+  // VARS:        @_ZTSN5type21AE = hidden constant
   // FUNS-HIDDEN-LABEL: define hidden void @_ZN5type21A3fooEv(
   // VARS-HIDDEN: @_ZTVN5type21AE = hidden unnamed_addr constant
-  // VARS-HIDDEN: @_ZTSN5type21AE = hidden constant
   // VARS-HIDDEN: @_ZTIN5type21AE = hidden constant
+  // VARS-HIDDEN: @_ZTSN5type21AE = hidden constant
 }
 
 namespace type3 {
@@ -158,11 +158,11 @@ namespace type3 {
   void A::foo() {}
   // FUNS-LABEL:        define void @_ZN5type31A3fooEv(
   // VARS:        @_ZTVN5type31AE = hidden unnamed_addr constant
-  // VARS:        @_ZTSN5type31AE = hidden constant
   // VARS:        @_ZTIN5type31AE = hidden constant
+  // VARS:        @_ZTSN5type31AE = hidden constant
   // FUNS-HIDDEN-LABEL: define void @_ZN5type31A3fooEv(
   // VARS-HIDDEN: @_ZTVN5type31AE = hidden unnamed_addr constant
-  // VARS-HIDDEN: @_ZTSN5type31AE = hidden constant
   // VARS-HIDDEN: @_ZTIN5type31AE = hidden constant
+  // VARS-HIDDEN: @_ZTSN5type31AE = hidden constant
 }
 
diff --git a/clang/test/CodeGenCXX/typeinfo-with-address-space.cpp b/clang/test/CodeGenCXX/typeinfo-with-address-space.cpp
index 60eb8f17f91fd1..68eb5cb4864765 100644
--- a/clang/test/CodeGenCXX/typeinfo-with-address-space.cpp
+++ b/clang/test/CodeGenCXX/typeinfo-with-address-space.cpp
@@ -15,12 +15,12 @@ class B : A {
 // NO-AS: @_ZTISt9type_info = external constant ptr
 // AS: @_ZTIi = external addrspace(1) constant ptr addrspace(1)
 // NO-AS: @_ZTIi = external constant ptr
+// AS: @_ZTI1A = linkonce_odr addrspace(1) constant { ptr addrspace(1), ptr addrspace(1) } { ptr addrspace(1) getelementptr inbounds (ptr addrspace(1), ptr addrspace(1) @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), ptr addrspace(1) @_ZTS1A }, comdat, align 8
+// NO-AS: @_ZTI1A = linkonce_odr constant { ptr, ptr } { ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), ptr @_ZTS1A }, comdat, align 8
 // AS: @_ZTVN10__cxxabiv117__class_type_infoE = external addrspace(1) global [0 x ptr addrspace(1)]
 // NO-AS: @_ZTVN10__cxxabiv117__class_type_infoE = external global [0 x ptr]
 // AS: @_ZTS1A = linkonce_odr addrspace(1) constant [3 x i8] c"1A\00", comdat, align 1
 // NO-AS: @_ZTS1A = linkonce_odr constant [3 x i8] c"1A\00", comdat, align 1
-// AS: @_ZTI1A = linkonce_odr addrspace(1) constant { ptr addrspace(1), ptr addrspace(1) } { ptr addrspace(1) getelementptr inbounds (ptr addrspace(1), ptr addrspace(1) @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), ptr addrspace(1) @_ZTS1A }, comdat, align 8
-// NO-AS: @_ZTI1A = linkonce_odr constant { ptr, ptr } { ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), ptr @_ZTS1A }, comdat, align 8
 // AS: @_ZTIf = external addrspace(1) constant ptr addrspace(1)
 // NO-AS: @_ZTIf = external constant ptr
 
diff --git a/clang/test/CodeGenCXX/visibility-ms-compat.cpp b/clang/test/CodeGenCXX/visibility-ms-compat.cpp
index 525691358832f8..0344803909cd44 100644
--- a/clang/test/CodeGenCXX/visibility-ms-compat.cpp
+++ b/clang/test/CodeGenCXX/visibility-ms-compat.cpp
@@ -24,8 +24,8 @@ namespace test0 {
   // CHECK: declare void @_ZN5test01A3barEv()
 
   const std::type_info &ti = typeid(A);
-  // CHECK-GLOBAL: @_ZTSN5test01AE = linkonce_odr constant
   // CHECK-GLOBAL: @_ZTIN5test01AE = linkonce_odr constant
+  // CHECK-GLOBAL: @_ZTSN5test01AE = linkonce_odr constant
   // CHECK-GLOBAL: @_ZN5test02tiE = hidden constant
 }
 
@@ -40,8 +40,8 @@ namespace test1 {
   // CHECK: declare hidden void @_ZN5test11A3barEv()
 
   const std::type_info &ti = typeid(A);
-  // CHECK-GLOBAL: @_ZTSN5test11AE = linkonce_odr hidden constant
   // CHECK-GLOBAL: @_ZTIN5test11AE = linkonce_odr hidden constant
+  // CHECK-GLOBAL: @_ZTSN5test11AE = linkonce_odr hidden constant
   // CHECK-GLOBAL: @_ZN5test12tiE = hidden constant
 }
 
@@ -56,8 +56,8 @@ namespace test2 {
   // CHECK: declare void @_ZN5test21A3barEv()
 
   const std::type_info &ti = typeid(A);
-  // CHECK-GLOBAL: @_ZTSN5test21AE = linkonce_odr constant
   // CHECK-GLOBAL: @_ZTIN5test21AE = linkonce_odr constant
+  // CHECK-GLOBAL: @_ZTSN5test21AE = linkonce_odr constant
   // CHECK-GLOBAL: @_ZN5test22tiE = hidden constant
 }
 
@@ -73,8 +73,8 @@ namespace test3 {
   // CHECK: declare void @_ZN5test31BINS_1AEE3barEv()
 
   const std::type_info &ti = typeid(B<A>);
-  // CHECK-GLOBAL: @_ZTSN5test31BINS_1AEEE = linkonce_odr constant
   // CHECK-GLOBAL: @_ZTIN5test31BINS_1AEEE = linkonce_odr constant
+  // CHECK-GLOBAL: @_ZTSN5test31BINS_1AEEE = linkonce_odr constant
 }
 
 namespace test4 {
@@ -89,8 +89,8 @@ namespace test4 {
   // CHECK: declare void @_ZN5test41BINS_1AEE3barEv()
 
   const std::type_info &ti = typeid(B<A>);
-  // CHECK-GLOBAL: @_ZTSN5test41BINS_1AEEE = linkonce_odr constant
   // CHECK-GLOBAL: @_ZTIN5test41BINS_1AEEE = linkonce_odr constant
+  // CHECK-GLOBAL: @_ZTSN5test41BINS_1AEEE = linkonce_odr constant
 }
 
 namespace test5 {
@@ -105,6 +105,6 @@ namespace test5 {
   // CHECK: declare hidden void @_ZN5test51BINS_1AEE3barEv()
 
   const std::type_info &ti = typeid(B<A>);
-  // CHECK-GLOBAL: @_ZTSN5test51BINS_1AEEE = linkonce_odr hidden constant
   // CHECK-GLOBAL: @_ZTIN5test51BINS_1AEEE = linkonce_odr hidden constant
+  // CHECK-GLOBAL: @_ZTSN5test51BINS_1AEEE = linkonce_odr hidden constant
 }
diff --git a/clang/test/CodeGenCXX/vtable-align-address-space.cpp b/clang/test/CodeGenCXX/vtable-align-address-space.cpp
index 5eac0bd75dc5ef..5eccf0a0d77d82 100644
--- a/clang/test/CodeGenCXX/vtable-align-address-space.cpp
+++ b/clang/test/CodeGenCXX/vtable-align-address-space.cpp
@@ -9,5 +9,5 @@ struct A {
 void A::f() {}
 
 // CHECK: @_ZTV1A ={{.*}} unnamed_addr addrspace(1) constant { [5 x ptr addrspace(1)] } { [5 x ptr addrspace(1)] [ptr addrspace(1) null, ptr addrspace(1) @_ZTI1A, ptr addrspace(1) addrspacecast (ptr @_ZN1A1fEv to ptr addrspace(1)), ptr addrspace(1) addrspacecast (ptr @_ZN1A1gEv to ptr addrspace(1)), ptr addrspace(1) addrspacecast (ptr @_ZN1A1hEv to ptr addrspace(1))]
-// CHECK: @_ZTS1A ={{.*}} constant [3 x i8] c"1A\00", align 1
 // CHECK: @_ZTI1A ={{.*}} addrspace(1) constant { ptr addrspace(1), ptr addrspace(1) } { ptr addrspace(1) getelementptr inbounds (ptr addrspace(1), ptr addrspace(1) @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), ptr addrspace(1) @_ZTS1A }, align 8
+// CHECK: @_ZTS1A ={{.*}} constant [3 x i8] c"1A\00", align 1
diff --git a/clang/test/CodeGenCXX/vtable-align.cpp b/clang/test/CodeGenCXX/vtable-align.cpp
index fb8ff1a582ec83..f1d5e09b9730b2 100644
--- a/clang/test/CodeGenCXX/vtable-align.cpp
+++ b/clang/test/CodeGenCXX/vtable-align.cpp
@@ -10,8 +10,8 @@ struct A {
 void A::f() {}
 
 // CHECK-32: @_ZTV1A ={{.*}} unnamed_addr constant { [5 x ptr] } { [5 x ptr] [ptr null, ptr @_ZTI1A, ptr @_ZN1A1fEv, ptr @_ZN1A1gEv, ptr @_ZN1A1hEv] }, align 4
-// CHECK-32: @_ZTS1A ={{.*}} constant [3 x i8] c"1A\00", align 1
 // CHECK-32: @_ZTI1A ={{.*}} constant { ptr, ptr } { ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i32 2), ptr @_ZTS1A }, align 4
+// CHECK-32: @_ZTS1A ={{.*}} constant [3 x i8] c"1A\00", align 1
 // CHECK-64: @_ZTV1A ={{.*}} unnamed_addr constant { [5 x ptr] } { [5 x ptr] [ptr null, ptr @_ZTI1A, ptr @_ZN1A1fEv, ptr @_ZN1A1gEv, ptr @_ZN1A1hEv] }, align 8
-// CHECK-64: @_ZTS1A ={{.*}} constant [3 x i8] c"1A\00", align 1
 // CHECK-64: @_ZTI1A ={{.*}} constant { ptr, ptr } { ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), ptr @_ZTS1A }, align 8
+// CHECK-64: @_ZTS1A ={{.*}} constant [3 x i8] c"1A\00", align 1
diff --git a/clang/test/CodeGenCXX/vtable-available-externally.cpp b/clang/test/CodeGenCXX/vtable-available-externally.cpp
index ab105260bc75aa..4415e24f3f1cb6 100644
--- a/clang/test/CodeGenCXX/vtable-available-externally.cpp
+++ b/clang/test/CodeGenCXX/vtable-available-externally.cpp
@@ -49,8 +49,8 @@ void g() {
 // This tests mainly that the typeinfo and typename constants have their linkage
 // updated correctly.
 
-// CHECK-TEST2: @_ZTSN5Test21AE ={{.*}} constant
 // CHECK-TEST2: @_ZTIN5Test21AE ={{.*}} constant
+// CHECK-TEST2: @_ZTSN5Test21AE ={{.*}} constant
 // CHECK-TEST2: @_ZTVN5Test21AE ={{.*}} unnamed_addr constant
 namespace Test2 {
   struct A {
diff --git a/clang/test/CodeGenCXX/vtable-key-function-arm.cpp b/clang/test/CodeGenCXX/vtable-key-function-arm.cpp
index a054fd87c8ea73..83889bf9f8dbc5 100644
--- a/clang/test/CodeGenCXX/vtable-key-function-arm.cpp
+++ b/clang/test/CodeGenCXX/vtable-key-function-arm.cpp
@@ -90,8 +90,8 @@ struct Test2a {
 // V-table should be defined with strong linkage.
 Test2a::Test2a() { use(typeid(Test2a)); }
 // CHECK:      @_ZTV6Test2a ={{.*}} unnamed_addr constant
-// CHECK-LATE: @_ZTS6Test2a ={{.*}} constant
 // CHECK-LATE: @_ZTI6Test2a ={{.*}} constant
+// CHECK-LATE: @_ZTS6Test2a ={{.*}} constant
 
 // 'bar' becomes the key function when 'foo' is defined inline.
 void Test2a::bar() {}
@@ -111,8 +111,8 @@ void Test2b::bar() {}
 // V-table should be defined with strong linkage.
 Test2b::Test2b() { use(typeid(Test2b)); }
 // CHECK:      @_ZTV6Test2b ={{.*}} unnamed_addr constant
-// CHECK-LATE: @_ZTS6Test2b ={{.*}} constant
 // CHECK-LATE: @_ZTI6Test2b ={{.*}} constant
+// CHECK-LATE: @_ZTS6Test2b ={{.*}} constant
 
 inline void Test2b::foo() {}
 
@@ -131,8 +131,8 @@ inline void Test2c::foo() {}
 // V-table should be defined with strong linkage.
 Test2c::Test2c() { use(typeid(Test2c)); }
 // CHECK: @_ZTV6Test2c ={{.*}} unnamed_addr constant
-// CHECK: @_ZTS6Test2c ={{.*}} constant
 // CHECK: @_ZTI6Test2c ={{.*}} constant
+// CHECK: @_ZTS6Test2c ={{.*}} constant
 
 /*** Test3a ******************************************************************/
 
@@ -145,8 +145,8 @@ struct Test3a {
 // V-table should be defined with weak linkage.
 Test3a::Test3a() { use(typeid(Test3a)); }
 // CHECK:      @_ZTV6Test3a = linkonce_odr unnamed_addr constant
-// CHECK-LATE: @_ZTS6Test3a = linkonce_odr constant
 // CHECK-LATE: @_ZTI6Test3a = linkonce_odr constant
+// CHECK-LATE: @_ZTS6Test3a = linkonce_odr constant
 
 // There ceases to be a key function after these declarations.
 inline void Test3a::bar() {}
@@ -166,8 +166,8 @@ inline void Test3b::bar() {}
 // V-table should be defined with weak linkage.
 Test3b::Test3b() { use(typeid(Test3b)); }
 // CHECK:      @_ZTV6Test3b = linkonce_odr unnamed_addr constant
-// CHECK-LATE: @_ZTS6Test3b = linkonce_odr constant
 // CHECK-LATE: @_ZTI6Test3b = linkonce_odr constant
+// CHECK-LATE: @_ZTS6Test3b = linkonce_odr constant
 
 inline void Test3b::foo() {}
 
@@ -186,8 +186,8 @@ inline void Test3c::foo() {}
 // V-table should be defined with weak linkage.
 Test3c::Test3c() { use(typeid(Test3c)); }
 // CHECK: @_ZTV6Test3c = linkonce_odr unnamed_addr constant
-// CHECK: @_ZTS6Test3c = linkonce_odr constant
 // CHECK: @_ZTI6Test3c = linkonce_odr constant
+// CHECK: @_ZTS6Test3c = linkonce_odr constant
 
 /*** Test4a ******************************************************************/
 
@@ -200,8 +200,8 @@ template <class T> struct Test4a {
 // V-table should be defined with weak linkage.
 template <> Test4a<int>::Test4a() { use(typeid(Test4a)); }
 // CHECK: @_ZTV6Test4aIiE = linkonce_odr unnamed_addr constant
-// CHECK: @_ZTS6Test4aIiE = linkonce_odr constant
 // CHECK: @_ZTI6Test4aIiE = linkonce_odr constant
+// CHECK: @_ZTS6Test4aIiE = linkonce_odr constant
 
 // There ceases to be a key function after these declarations.
 template <> inline void Test4a<int>::bar() {}
@@ -221,8 +221,8 @@ template <> inline void Test4b<int>::bar() {}
 // V-table should be defined with weak linkage.
 template <> Test4b<int>::Test4b() { use(typeid(Test4b)); }
 // CHECK: @_ZTV6Test4bIiE = linkonce_odr unnamed_addr constant
-// CHECK: @_ZTS6Test4bIiE = linkonce_odr constant
 // CHECK: @_ZTI6Test4bIiE = linkonce_odr constant
+// CHECK: @_ZTS6Test4bIiE = linkonce_odr constant
 
 template <> inline void Test4b<int>::foo() {}
 
@@ -241,8 +241,8 @@ template <> inline void Test4c<int>::foo() {}
 // V-table should be defined with weak linkage.
 template <> Test4c<int>::Test4c() { use(typeid(Test4c)); }
 // CHECK: @_ZTV6Test4cIiE = linkonce_odr unnamed_addr constant
-// CHECK: @_ZTS6Test4cIiE = linkonce_odr constant
 // CHECK: @_ZTI6Test4cIiE = linkonce_odr constant
+// CHECK: @_ZTS6Test4cIiE = linkonce_odr constant
 
 /*** Test5a ******************************************************************/
 
@@ -258,8 +258,8 @@ template <> inline void Test5a<int>::foo();
 // V-table should be defined with weak linkage.
 template <> Test5a<int>::Test5a() { use(typeid(Test5a)); }
 // CHECK: @_ZTV6Test5aIiE = linkonce_odr unnamed_addr constant
-// CHECK: @_ZTS6Test5aIiE = linkonce_odr constant
 // CHECK: @_ZTI6Test5aIiE = linkonce_odr constant
+// CHECK: @_ZTS6Test5aIiE = linkonce_odr constant
 
 // There ceases to be a key function after these declarations.
 template <> inline void Test5a<int>::bar() {}
@@ -280,8 +280,8 @@ template <> inline void Test5b<int>::bar() {}
 // V-table should be defined with weak linkage.
 template <> Test5b<int>::Test5b() { use(typeid(Test5b)); }
 // CHECK: @_ZTV6Test5bIiE = linkonce_odr unnamed_addr constant
-// CHECK: @_ZTS6Test5bIiE = linkonce_odr constant
 // CHECK: @_ZTI6Test5bIiE = linkonce_odr constant
+// CHECK: @_ZTS6Test5bIiE = linkonce_odr constant
 
 template <> inline void Test5a<int>::foo();
 template <> inline void Test5b<int>::foo() {}
@@ -303,5 +303,5 @@ template <> inline void Test5c<int>::foo() {}
 // V-table should be defined with weak linkage.
 template <> Test5c<int>::Test5c() { use(typeid(Test5c)); }
 // CHECK: @_ZTV6Test5cIiE = linkonce_odr unnamed_addr constant
-// CHECK: @_ZTS6Test5cIiE = linkonce_odr constant
 // CHECK: @_ZTI6Test5cIiE = linkonce_odr constant
+// CHECK: @_ZTS6Test5cIiE = linkonce_odr constant
diff --git a/clang/test/CodeGenCXX/vtable-key-function-ios.cpp b/clang/test/CodeGenCXX/vtable-key-function-ios.cpp
index ff2793ad51f948..43abfb62c73a6c 100644
--- a/clang/test/CodeGenCXX/vtable-key-function-ios.cpp
+++ b/clang/test/CodeGenCXX/vtable-key-function-ios.cpp
@@ -63,8 +63,8 @@ struct Test1a {
 // V-table needs to be defined weakly.
 Test1a::Test1a() { use(typeid(Test1a)); }
 // CHECK:      @_ZTV6Test1a = linkonce_odr {{(dso_local )?}}unnamed_addr constant 
-// CHECK-LATE: @_ZTS6Test1a = linkonce_odr {{(dso_local )?}}constant
 // CHECK-LATE: @_ZTI6Test1a = linkonce_odr {{(dso_local )?}}constant
+// CHECK-LATE: @_ZTS6Test1a = linkonce_odr {{(dso_local )?}}constant
 
 // This defines the key function.
 inline void Test1a::foo() {}
@@ -83,8 +83,8 @@ inline void Test1b::foo() {}
 // V-table should be defined weakly..
 Test1b::Test1b() { use(typeid(Test1b)); }
 // CHECK: @_ZTV6Test1b = linkonce_odr {{(dso_local )?}}unnamed_addr constant 
-// CHECK: @_ZTS6Test1b = linkonce_odr {{(dso_local )?}}constant
 // CHECK: @_ZTI6Test1b = linkonce_odr {{(dso_local )?}}constant
+// CHECK: @_ZTS6Test1b = linkonce_odr {{(dso_local )?}}constant
 
 /*** Test2a ******************************************************************/
 
@@ -97,8 +97,8 @@ struct Test2a {
 // V-table should be defined with weak linkage.
 Test2a::Test2a() { use(typeid(Test2a)); }
 // CHECK:      @_ZTV6Test2a = linkonce_odr {{(dso_local )?}}unnamed_addr constant
-// CHECK-LATE: @_ZTS6Test2a = linkonce_odr {{(dso_local )?}}constant
 // CHECK-LATE: @_ZTI6Test2a = linkonce_odr {{(dso_local )?}}constant
+// CHECK-LATE: @_ZTS6Test2a = linkonce_odr {{(dso_local )?}}constant
 
 void Test2a::bar() {}
 inline void Test2a::foo() {}
@@ -116,8 +116,8 @@ void Test2b::bar() {}
 // V-table should be defined with weak linkage.
 Test2b::Test2b() { use(typeid(Test2b)); }
 // CHECK:      @_ZTV6Test2b = linkonce_odr {{(dso_local )?}}unnamed_addr constant
-// CHECK-LATE: @_ZTS6Test2b = linkonce_odr {{(dso_local )?}}constant
 // CHECK-LATE: @_ZTI6Test2b = linkonce_odr {{(dso_local )?}}constant
+// CHECK-LATE: @_ZTS6Test2b = linkonce_odr {{(dso_local )?}}constant
 
 inline void Test2b::foo() {}
 
@@ -135,8 +135,8 @@ inline void Test2c::foo() {}
 // V-table should be defined with weak linkage.
 Test2c::Test2c() { use(typeid(Test2c)); }
 // CHECK: @_ZTV6Test2c = linkonce_odr {{(dso_local )?}}unnamed_addr constant
-// CHECK: @_ZTS6Test2c = linkonce_odr {{(dso_local )?}}constant
 // CHECK: @_ZTI6Test2c = linkonce_odr {{(dso_local )?}}constant
+// CHECK: @_ZTS6Test2c = linkonce_odr {{(dso_local )?}}constant
 
 /*** Test3a ******************************************************************/
 
@@ -149,8 +149,8 @@ struct Test3a {
 // V-table should be defined with weak linkage.
 Test3a::Test3a() { use(typeid(Test3a)); }
 // CHECK:      @_ZTV6Test3a = linkonce_odr {{(dso_local )?}}unnamed_addr constant
-// CHECK-LATE: @_ZTS6Test3a = linkonce_odr {{(dso_local )?}}constant
 // CHECK-LATE: @_ZTI6Test3a = linkonce_odr {{(dso_local )?}}constant
+// CHECK-LATE: @_ZTS6Test3a = linkonce_odr {{(dso_local )?}}constant
 
 // This defines the key function.
 inline void Test3a::bar() {}
@@ -169,8 +169,8 @@ inline void Test3b::bar() {}
 // V-table should be defined with weak linkage.
 Test3b::Test3b() { use(typeid(Test3b)); }
 // CHECK:      @_ZTV6Test3b = linkonce_odr {{(dso_local )?}}unnamed_addr constant
-// CHECK-LATE: @_ZTS6Test3b = linkonce_odr {{(dso_local )?}}constant
 // CHECK-LATE: @_ZTI6Test3b = linkonce_odr {{(dso_local )?}}constant
+// CHECK-LATE: @_ZTS6Test3b = linkonce_odr {{(dso_local )?}}constant
 
 // This defines the key function.
 inline void Test3b::foo() {}
@@ -190,5 +190,5 @@ inline void Test3c::foo() {}
 // V-table should be defined with weak linkage.
 Test3c::Test3c() { use(typeid(Test3c)); }
 // CHECK: @_ZTV6Test3c = linkonce_odr {{(dso_local )?}}unnamed_addr constant
-// CHECK: @_ZTS6Test3c = linkonce_odr {{(dso_local )?}}constant
 // CHECK: @_ZTI6Test3c = linkonce_odr {{(dso_local )?}}constant
+// CHECK: @_ZTS6Test3c = linkonce_odr {{(dso_local )?}}constant
diff --git a/clang/test/CodeGenCXX/vtable-key-function-win-comdat.cpp b/clang/test/CodeGenCXX/vtable-key-function-win-comdat.cpp
index dd4fd9f8754a8d..b3de2f63499995 100644
--- a/clang/test/CodeGenCXX/vtable-key-function-win-comdat.cpp
+++ b/clang/test/CodeGenCXX/vtable-key-function-win-comdat.cpp
@@ -15,11 +15,11 @@ Test1a::Test1a() { use(typeid(Test1a)); }
 inline void Test1a::foo() {}
 
 // CHECK:     $_ZTV6Test1a = comdat any
-// CHECK:     $_ZTS6Test1a = comdat any
 // CHECK:     $_ZTI6Test1a = comdat any
-// CHECK-NOT: $_ZTS6Test1a.1 = comdat any
+// CHECK:     $_ZTS6Test1a = comdat any
 // CHECK-NOT: $_ZTI6Test1a.1 = comdat any
+// CHECK-NOT: $_ZTS6Test1a.1 = comdat any
 
 // CHECK: @_ZTV6Test1a = linkonce_odr dso_local unnamed_addr constant {{.*}} ptr @_ZTI6Test1a
-// CHECK: @_ZTS6Test1a = linkonce_odr dso_local constant
 // CHECK: @_ZTI6Test1a = linkonce_odr dso_local constant {{.*}} ptr @_ZTS6Test1a
+// CHECK: @_ZTS6Test1a = linkonce_odr dso_local constant
diff --git a/clang/test/CodeGenCXX/weak-extern-typeinfo.cpp b/clang/test/CodeGenCXX/weak-extern-typeinfo.cpp
index 932d36f4abbd2b..8c948d16c90ec5 100644
--- a/clang/test/CodeGenCXX/weak-extern-typeinfo.cpp
+++ b/clang/test/CodeGenCXX/weak-extern-typeinfo.cpp
@@ -30,17 +30,17 @@ class V2 : public virtual V1 {
 void V1::foo() { }
 void V2::foo() { }
 
-// CHECK: @_ZTS1A = weak_odr {{(dso_local |hidden )?}}constant
 // CHECK: @_ZTI1A = weak_odr {{(dso_local |hidden )?}}constant
-// CHECK: @_ZTS1B = weak_odr {{(dso_local |hidden )?}}constant
+// CHECK: @_ZTS1A = weak_odr {{(dso_local |hidden )?}}constant
 // CHECK: @_ZTI1B = weak_odr {{(dso_local |hidden )?}}constant
+// CHECK: @_ZTS1B = weak_odr {{(dso_local |hidden )?}}constant
+// CHECK: @_ZTI1C = weak_odr {{(dso_local |hidden )?}}constant
 // CHECK: @_ZTS1C = weak_odr {{(dso_local |hidden )?}}constant
-// CHECK: @_ZTS2T1 = linkonce_odr {{(dso_local |hidden )?}}constant
 // CHECK: @_ZTI2T1 = linkonce_odr {{(dso_local |hidden )?}}constant
-// CHECK: @_ZTS1T = linkonce_odr {{(dso_local |hidden )?}}constant
+// CHECK: @_ZTS2T1 = linkonce_odr {{(dso_local |hidden )?}}constant
 // CHECK: @_ZTI1T = linkonce_odr {{(dso_local |hidden )?}}constant
-// CHECK: @_ZTI1C = weak_odr {{(dso_local |hidden )?}}constant
-// CHECK: @_ZTS2V1 = weak_odr {{(dso_local |hidden )?}}constant
+// CHECK: @_ZTS1T = linkonce_odr {{(dso_local |hidden )?}}constant
 // CHECK: @_ZTI2V1 = weak_odr {{(dso_local |hidden )?}}constant
-// CHECK: @_ZTS2V2 = weak_odr {{(dso_local |hidden )?}}constant
+// CHECK: @_ZTS2V1 = weak_odr {{(dso_local |hidden )?}}constant
 // CHECK: @_ZTI2V2 = weak_odr {{(dso_local |hidden )?}}constant
+// CHECK: @_ZTS2V2 = weak_odr {{(dso_local |hidden )?}}constant
diff --git a/clang/test/CodeGenCXX/windows-itanium-type-info.cpp b/clang/test/CodeGenCXX/windows-itanium-type-info.cpp
index 20bd78df509837..95b7b3a4b29e25 100644
--- a/clang/test/CodeGenCXX/windows-itanium-type-info.cpp
+++ b/clang/test/CodeGenCXX/windows-itanium-type-info.cpp
@@ -33,8 +33,8 @@ void f() {
 
 // CHECK-DAG: @_ZTI4base = external dllimport constant
 
-// CHECK-EH-IMPORT: @_ZTS4base = linkonce_odr dso_local constant
 // CHECK-EH-IMPORT: @_ZTI4base = linkonce_odr dso_local constant
+// CHECK-EH-IMPORT: @_ZTS4base = linkonce_odr dso_local constant
 
 struct __declspec(dllimport) gatekeeper {};
 struct zuul : gatekeeper {
diff --git a/clang/test/CodeGenObjCXX/rtti.mm b/clang/test/CodeGenObjCXX/rtti.mm
index ee3df349af18d6..2fc6f8722f4398 100644
--- a/clang/test/CodeGenObjCXX/rtti.mm
+++ b/clang/test/CodeGenObjCXX/rtti.mm
@@ -4,19 +4,20 @@
 
 namespace std { class type_info; }
 
-// CHECK: @_ZTI1A = linkonce_odr constant {{.*}}@_ZTVN10__cxxabiv117__class_type_infoE{{.*}}@_ZTS1A
 @interface A
 @end
 
-// CHECK: @_ZTI1B = linkonce_odr constant {{.*}}@_ZTVN10__cxxabiv120__si_class_type_infoE{{.*}}@_ZTS1B{{.*}}@_ZTI1A
 @interface B : A
 @end
 
 // CHECK: @_ZTIP1B = linkonce_odr constant {{.*}}@_ZTVN10__cxxabiv119__pointer_type_infoE{{.*}}@_ZTSP1B{{.*}}, i32 0, {{.*}}@_ZTI1B
-// CHECK: @_ZTI11objc_object = linkonce_odr constant {{.*}}@_ZTVN10__cxxabiv117__class_type_infoE{{.*}}@_ZTS11objc_object
+// CHECK: @_ZTI1B = linkonce_odr constant {{.*}}@_ZTVN10__cxxabiv120__si_class_type_infoE{{.*}}@_ZTS1B{{.*}}@_ZTI1A
+// CHECK: @_ZTI1A = linkonce_odr constant {{.*}}@_ZTVN10__cxxabiv117__class_type_infoE{{.*}}@_ZTS1A
+
 // CHECK: @_ZTIP11objc_object = linkonce_odr constant {{.*}}@_ZTVN10__cxxabiv119__pointer_type_infoE{{.*}}@_ZTSP11objc_object{{.*}}@_ZTI11objc_object
-// CHECK: @_ZTI10objc_class = linkonce_odr constant {{.*}}@_ZTVN10__cxxabiv117__class_type_infoE{{.*}}@_ZTS10objc_class
+// CHECK: @_ZTI11objc_object = linkonce_odr constant {{.*}}@_ZTVN10__cxxabiv117__class_type_infoE{{.*}}@_ZTS11objc_object
 // CHECK: @_ZTIP10objc_class = linkonce_odr constant {{.*}}@_ZTVN10__cxxabiv119__pointer_type_infoE{{.*}}@_ZTSP10objc_class{{.*}}@_ZTI10objc_class
+// CHECK: @_ZTI10objc_class = linkonce_odr constant {{.*}}@_ZTVN10__cxxabiv117__class_type_infoE{{.*}}@_ZTS10objc_class
 
 @protocol P;
 
diff --git a/clang/test/Modules/pr97313.cppm b/clang/test/Modules/pr97313.cppm
index ebbd0ee4e2c655..32c7112da091ec 100644
--- a/clang/test/Modules/pr97313.cppm
+++ b/clang/test/Modules/pr97313.cppm
@@ -107,12 +107,12 @@ auto v6 = new Template<NonTemplate>();
 // CHECK: @_ZTVW3Mod11NonTemplate = {{.*}}external
 // CHECK: @_ZTVW3Mod8TemplateIcE = {{.*}}external
 // CHECK: @_ZTVW3Mod8TemplateIjE = {{.*}}weak_odr
-// CHECK: @_ZTSW3Mod8TemplateIjE = {{.*}}weak_odr
 // CHECK: @_ZTIW3Mod8TemplateIjE = {{.*}}weak_odr
+// CHECK: @_ZTSW3Mod8TemplateIjE = {{.*}}weak_odr
 // CHECK: @_ZTVW3Mod8TemplateIdE = {{.*}}external
 // CHECK: @_ZTVW3Mod8TemplateIiE = {{.*}}linkonce_odr
-// CHECK: @_ZTSW3Mod8TemplateIiE = {{.*}}linkonce_odr
 // CHECK: @_ZTIW3Mod8TemplateIiE = {{.*}}linkonce_odr
+// CHECK: @_ZTSW3Mod8TemplateIiE = {{.*}}linkonce_odr
 // CHECK: @_ZTVW3Mod8TemplateIS_11NonTemplateE = {{.*}}linkonce_odr
-// CHECK: @_ZTSW3Mod8TemplateIS_11NonTemplateE = {{.*}}linkonce_odr
 // CHECK: @_ZTIW3Mod8TemplateIS_11NonTemplateE = {{.*}}linkonce_odr
+// CHECK: @_ZTSW3Mod8TemplateIS_11NonTemplateE = {{.*}}linkonce_odr
diff --git a/clang/test/SemaCXX/typeid-ref.cpp b/clang/test/SemaCXX/typeid-ref.cpp
index f788b04077ecac..025816c42512e1 100644
--- a/clang/test/SemaCXX/typeid-ref.cpp
+++ b/clang/test/SemaCXX/typeid-ref.cpp
@@ -6,7 +6,7 @@ namespace std {
 struct X { };
 
 void f() {
-  // CHECK: @_ZTS1X = linkonce_odr {{(dso_local |hidden )?}}constant
   // CHECK: @_ZTI1X = linkonce_odr {{(dso_local |hidden )?}}constant
+  // CHECK: @_ZTS1X = linkonce_odr {{(dso_local |hidden )?}}constant
   (void)typeid(X&);
 }



More information about the cfe-commits mailing list