Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion clang/lib/CodeGen/ItaniumCXXABI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3532,7 +3532,6 @@ llvm::GlobalVariable *ItaniumRTTIBuilder::GetAddrOfTypeName(
Name, Init->getType(), Linkage, Align.getAsAlign());

GV->setInitializer(Init);

return GV;
}

Expand Down Expand Up @@ -4097,6 +4096,7 @@ llvm::Constant *ItaniumRTTIBuilder::BuildTypeInfo(
// And the name.
llvm::GlobalVariable *TypeName = GetAddrOfTypeName(Ty, Linkage);
llvm::Constant *TypeNameField;
llvm::GlobalValue::UnnamedAddr Scope;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scope isn't a very clear name here. Maybe rename this to something like UnnamedAddrScope?


// If we're supposed to demote the visibility, be sure to set a flag
// to use a string comparison for type_info comparisons.
Expand All @@ -4111,8 +4111,10 @@ llvm::Constant *ItaniumRTTIBuilder::BuildTypeInfo(
TypeNameField = llvm::ConstantExpr::getAdd(TypeNameField, flag);
TypeNameField =
llvm::ConstantExpr::getIntToPtr(TypeNameField, CGM.GlobalsInt8PtrTy);
Scope = llvm::GlobalValue::UnnamedAddr::Global;
} else {
TypeNameField = TypeName;
Scope = llvm::GlobalValue::UnnamedAddr::Local;
}
Fields.push_back(TypeNameField);

Expand Down Expand Up @@ -4271,6 +4273,9 @@ llvm::Constant *ItaniumRTTIBuilder::BuildTypeInfo(
TypeName->setPartition(CGM.getCodeGenOpts().SymbolPartition);
GV->setPartition(CGM.getCodeGenOpts().SymbolPartition);

TypeName->setUnnamedAddr(Scope);
GV->setUnnamedAddr(Scope);

return GV;
}

Expand Down
8 changes: 4 additions & 4 deletions clang/test/CodeGen/split-lto-unit-input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
// CHECK-NEXT: V _ZTV1A
// CHECK-NEXT: V _ZTV1B

// CHECK-IR-DAG: _ZTS1B = linkonce_odr constant
// CHECK-IR-DAG: _ZTS1A = linkonce_odr constant
// CHECK-IR-DAG: _ZTS1B = linkonce_odr local_unnamed_addr constant
// CHECK-IR-DAG: _ZTS1A = linkonce_odr local_unnamed_addr constant
// CHECK-IR-DAG: _ZTV1B = linkonce_odr unnamed_addr constant
// CHECK-IR-DAG: _ZTI1A = linkonce_odr constant
// CHECK-IR-DAG: _ZTI1B = linkonce_odr constant
// CHECK-IR-DAG: _ZTI1A = linkonce_odr local_unnamed_addr constant
// CHECK-IR-DAG: _ZTI1B = linkonce_odr local_unnamed_addr constant
// CHECK-IR-DAG: _ZTV1A = linkonce_odr unnamed_addr constant

struct A {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Cross comdat example
// Parent VTable is in a comdat section.

// RUN: %clang_cc1 %s -triple=aarch64 -o - -emit-llvm -fexperimental-relative-c++-abi-vtables | FileCheck %s
// RUN: %clang_cc1 %s -triple=x86_64 -o - -emit-llvm -fexperimental-relative-c++-abi-vtables | FileCheck %s
// RUN: %clang_cc1 %s -triple=aarch64 -o - -emit-llvm -fexperimental-relative-c++-abi-vtables | FileCheck %s

// A::foo() has a comdat since it is an inline function
// CHECK: $_ZN1A3fooEv = comdat any
Expand All @@ -16,8 +16,8 @@
// The VTable for A is emitted here and in a comdat section since it has no key function, and is used in this module when creating an instance of A.
// CHECK: @_ZTV1A.local = linkonce_odr hidden unnamed_addr constant { [3 x i32] } { [3 x i32] [i32 0, i32 trunc (i64 sub (i64 ptrtoint (ptr @_ZTI1A.rtti_proxy to i64), i64 ptrtoint (ptr getelementptr inbounds ({ [3 x i32] }, ptr @_ZTV1A.local, i32 0, i32 0, i32 2) to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (ptr dso_local_equivalent @_ZN1A3fooEv to i64), i64 ptrtoint (ptr getelementptr inbounds ({ [3 x i32] }, ptr @_ZTV1A.local, i32 0, i32 0, i32 2) to i64)) to i32)] }, comdat($_ZTV1A), align 4
// CHECK: @_ZTVN10__cxxabiv117__class_type_infoE = external global [0 x ptr]
// CHECK: @_ZTS1A = linkonce_odr constant [3 x i8] c"1A\00", comdat, align 1
// CHECK: @_ZTI1A = linkonce_odr constant { ptr, ptr } { ptr getelementptr inbounds (i8, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i32 8), ptr @_ZTS1A }, comdat, align 8
// CHECK: @_ZTS1A = linkonce_odr local_unnamed_addr constant [3 x i8] c"1A\00", comdat, align 1
// CHECK: @_ZTI1A = linkonce_odr local_unnamed_addr constant { ptr, ptr } { ptr getelementptr inbounds (i8, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i32 8), ptr @_ZTS1A }, comdat, align 8
// CHECK: @_ZTI1A.rtti_proxy = linkonce_odr hidden unnamed_addr constant ptr @_ZTI1A, comdat
// CHECK: @_ZTV1A = linkonce_odr unnamed_addr alias { [3 x i32] }, ptr @_ZTV1A.local

Expand Down
2 changes: 1 addition & 1 deletion clang/test/CodeGenCXX/anonymous-namespaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace {
int D::d = f();

// Check for generation of a VTT with internal linkage
// CHECK-1: @_ZTSN12_GLOBAL__N_11X1EE = internal constant
// CHECK-1: @_ZTSN12_GLOBAL__N_11X1EE = internal local_unnamed_addr constant
struct X {
struct EBase { };
struct E : public virtual EBase { virtual ~E() {} };
Expand Down
28 changes: 14 additions & 14 deletions clang/test/CodeGenCXX/arm64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,43 +43,43 @@ namespace test2 {
virtual void foo();
};
void A::foo() {}
// CHECK-GLOBALS-DAG: @_ZTSN5test21AE ={{.*}} constant [11 x i8]
// CHECK-GLOBALS-DAG: @_ZTIN5test21AE ={{.*}} constant { {{.*}}, ptr @_ZTSN5test21AE }
// CHECK-GLOBALS-DAG: @_ZTSN5test21AE ={{.*}} local_unnamed_addr constant [11 x i8]
// CHECK-GLOBALS-DAG: @_ZTIN5test21AE ={{.*}} local_unnamed_addr constant { {{.*}}, ptr @_ZTSN5test21AE }

struct __attribute__((visibility("hidden"))) B {};
const std::type_info &b0 = typeid(B);
// CHECK-GLOBALS-DAG: @_ZTSN5test21BE = linkonce_odr hidden constant
// CHECK-GLOBALS-DAG: @_ZTIN5test21BE = linkonce_odr hidden constant { {{.*}}, ptr @_ZTSN5test21BE }
// CHECK-GLOBALS-DAG: @_ZTSN5test21BE = linkonce_odr hidden local_unnamed_addr constant
// CHECK-GLOBALS-DAG: @_ZTIN5test21BE = linkonce_odr hidden local_unnamed_addr constant { {{.*}}, ptr @_ZTSN5test21BE }

const std::type_info &b1 = typeid(B*);
// CHECK-GLOBALS-DAG: @_ZTSPN5test21BE = linkonce_odr hidden constant
// CHECK-GLOBALS-DAG: @_ZTIPN5test21BE = linkonce_odr hidden constant { {{.*}}, ptr @_ZTSPN5test21BE, i32 0, ptr @_ZTIN5test21BE
// CHECK-GLOBALS-DAG: @_ZTSPN5test21BE = linkonce_odr hidden local_unnamed_addr constant
// CHECK-GLOBALS-DAG: @_ZTIPN5test21BE = linkonce_odr hidden local_unnamed_addr constant { {{.*}}, ptr @_ZTSPN5test21BE, i32 0, ptr @_ZTIN5test21BE

struct C {};
const std::type_info &c0 = typeid(C);
// CHECK-GLOBALS-DAG: @_ZTSN5test21CE = linkonce_odr hidden constant
// CHECK-GLOBALS-DAG: @_ZTIN5test21CE = linkonce_odr hidden constant { {{.*}}, ptr inttoptr (i64 add (i64 ptrtoint (ptr @_ZTSN5test21CE to i64), i64 -9223372036854775808) to ptr) }
// CHECK-GLOBALS-DAG: @_ZTSN5test21CE = linkonce_odr hidden unnamed_addr constant
// CHECK-GLOBALS-DAG: @_ZTIN5test21CE = linkonce_odr hidden unnamed_addr constant { {{.*}}, ptr inttoptr (i64 add (i64 ptrtoint (ptr @_ZTSN5test21CE to i64), i64 -9223372036854775808) to ptr) }

const std::type_info &c1 = typeid(C*);
// CHECK-GLOBALS-DAG: @_ZTSPN5test21CE = linkonce_odr hidden constant
// CHECK-GLOBALS-DAG: @_ZTIPN5test21CE = linkonce_odr hidden constant { {{.*}}, ptr inttoptr (i64 add (i64 ptrtoint (ptr @_ZTSPN5test21CE to i64), i64 -9223372036854775808) to ptr), i32 0, ptr @_ZTIN5test21CE
// CHECK-GLOBALS-DAG: @_ZTSPN5test21CE = linkonce_odr hidden unnamed_addr constant
// CHECK-GLOBALS-DAG: @_ZTIPN5test21CE = linkonce_odr hidden unnamed_addr constant { {{.*}}, ptr inttoptr (i64 add (i64 ptrtoint (ptr @_ZTSPN5test21CE to i64), i64 -9223372036854775808) to ptr), i32 0, ptr @_ZTIN5test21CE

// This class is explicitly-instantiated, but that instantiation
// doesn't guarantee to emit RTTI, so we can still demote the visibility.
template <class T> class D {};
template class D<int>;
const std::type_info &d0 = typeid(D<int>);
// CHECK-GLOBALS-DAG: @_ZTSN5test21DIiEE = linkonce_odr hidden constant
// CHECK-GLOBALS-DAG: @_ZTIN5test21DIiEE = linkonce_odr hidden constant { {{.*}}, ptr inttoptr (i64 add (i64 ptrtoint (ptr @_ZTSN5test21DIiEE to i64), i64 -9223372036854775808) to ptr) }
// CHECK-GLOBALS-DAG: @_ZTSN5test21DIiEE = linkonce_odr hidden unnamed_addr constant
// CHECK-GLOBALS-DAG: @_ZTIN5test21DIiEE = linkonce_odr hidden unnamed_addr constant { {{.*}}, ptr inttoptr (i64 add (i64 ptrtoint (ptr @_ZTSN5test21DIiEE to i64), i64 -9223372036854775808) to ptr) }

// This class is explicitly-instantiated and *does* guarantee to
// emit RTTI, so we're stuck with having to use default visibility.
template <class T> class E {
virtual void foo() {}
};
template class E<int>;
// CHECK-GLOBALS-DAG: @_ZTSN5test21EIiEE = weak_odr constant [14 x i8]
// CHECK-GLOBALS-DAG: @_ZTIN5test21EIiEE = weak_odr constant { {{.*}}, ptr inttoptr (i64 add (i64 ptrtoint (ptr @_ZTSN5test21EIiEE to i64), i64 -9223372036854775808) to ptr) }
// CHECK-GLOBALS-DAG: @_ZTSN5test21EIiEE = weak_odr unnamed_addr constant [14 x i8]
// CHECK-GLOBALS-DAG: @_ZTIN5test21EIiEE = weak_odr unnamed_addr constant { {{.*}}, ptr inttoptr (i64 add (i64 ptrtoint (ptr @_ZTSN5test21EIiEE to i64), i64 -9223372036854775808) to ptr) }

}

Expand Down
Loading