Skip to content
This repository was archived by the owner on Sep 15, 2025. It is now read-only.

Commit b60b014

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:9370271ec5de into amd-gfx:a9743de9eb8f
Local branch amd-gfx a9743de Merged main:427f120f60be into amd-gfx:551632636316 Remote branch main 9370271 [Support] Redefine endianness::native (llvm#67876)
2 parents a9743de + 9370271 commit b60b014

File tree

23 files changed

+153
-52
lines changed

23 files changed

+153
-52
lines changed

clang/lib/CodeGen/CGVTables.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -640,8 +640,16 @@ void CodeGenVTables::addRelativeComponent(ConstantArrayBuilder &builder,
640640
// want the stub/proxy to be emitted for properly calculating the offset.
641641
// Examples where there would be no symbol emitted are available_externally
642642
// and private linkages.
643-
auto stubLinkage = vtableHasLocalLinkage ? llvm::GlobalValue::InternalLinkage
644-
: llvm::GlobalValue::ExternalLinkage;
643+
//
644+
// `internal` linkage results in STB_LOCAL Elf binding while still manifesting a
645+
// local symbol.
646+
//
647+
// `linkonce_odr` linkage results in a STB_DEFAULT Elf binding but also allows for
648+
// the rtti_proxy to be transparently replaced with a GOTPCREL reloc by a
649+
// target that supports this replacement.
650+
auto stubLinkage = vtableHasLocalLinkage
651+
? llvm::GlobalValue::InternalLinkage
652+
: llvm::GlobalValue::LinkOnceODRLinkage;
645653

646654
llvm::Constant *target;
647655
if (auto *func = dyn_cast<llvm::Function>(globalVal)) {

clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -899,6 +899,14 @@ void NullabilityChecker::checkPostCall(const CallEvent &Call,
899899
const NullabilityState *TrackedNullability =
900900
State->get<NullabilityMap>(Region);
901901

902+
// ObjCMessageExpr gets the actual type through
903+
// Sema::getMessageSendResultType, instead of using the return type of
904+
// MethodDecl directly. The final type is generated by considering the
905+
// nullability of receiver and MethodDecl together. Thus, The type of
906+
// ObjCMessageExpr is prefer.
907+
if (const Expr *E = Call.getOriginExpr())
908+
ReturnType = E->getType();
909+
902910
if (!TrackedNullability &&
903911
getNullabilityAnnotation(ReturnType) == Nullability::Nullable) {
904912
State = State->set<NullabilityMap>(Region, Nullability::Nullable);
@@ -1053,7 +1061,7 @@ void NullabilityChecker::checkPostObjCMessage(const ObjCMethodCall &M,
10531061
}
10541062

10551063
// No tracked information. Use static type information for return value.
1056-
Nullability RetNullability = getNullabilityAnnotation(RetType);
1064+
Nullability RetNullability = getNullabilityAnnotation(Message->getType());
10571065

10581066
// Properties might be computed, which means the property value could
10591067
// theoretically change between calls even in commonly-observed cases like

clang/test/Analysis/nullability.mm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ - (void)takesUnspecified:(int *)p;
5555
@property(readonly, nullable) void (^propReturnsNullableBlock)(void);
5656
@property(readonly, nullable) int *propReturnsNullable;
5757
@property(readonly) int *propReturnsUnspecified;
58+
+ (nullable TestObject *)getNullableObject;
5859
@end
5960

6061
TestObject * getUnspecifiedTestObject();
@@ -256,6 +257,12 @@ void testObjCPropertyReadNullability() {
256257
case 8:
257258
[o takesNonnullBlock:o.propReturnsNullableBlock]; // expected-warning {{Nullable pointer is passed to a callee that requires a non-null 1st parameter}}
258259
break;
260+
case 9:
261+
[o takesNonnull:getNullableTestObject().propReturnsNonnull]; // expected-warning {{Nullable pointer is passed to a callee that requires a non-null 1st parameter}}
262+
break;
263+
case 10:
264+
[o takesNonnull:[TestObject getNullableObject].propReturnsNonnull]; // expected-warning {{Nullable pointer is passed to a callee that requires a non-null 1st parameter}}
265+
break;
259266
}
260267
}
261268

clang/test/CodeGenCXX/RelativeVTablesABI/child-vtable-in-comdat.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
// CHECK-DAG: $_ZTS1B = comdat any
99
// CHECK-DAG: $_ZTI1B = comdat any
1010
// CHECK-DAG: $_ZTI1B.rtti_proxy = comdat any
11-
// CHECK-DAG: $_ZTI1A.rtti_proxy = comdat any
1211

1312
// VTable for B is emitted here since we access it when creating an instance of B. The VTable is also linkonce_odr and in its own comdat.
1413
// CHECK-DAG: @_ZTV1B.local = linkonce_odr hidden unnamed_addr constant { [3 x i32] } { [3 x i32] [i32 0, i32 trunc (i64 sub (i64 ptrtoint (ptr @_ZTI1B.rtti_proxy to i64), i64 ptrtoint (ptr getelementptr inbounds ({ [3 x i32] }, ptr @_ZTV1B.local, i32 0, i32 0, i32 2) to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (ptr dso_local_equivalent @_ZN1B3fooEv to i64), i64 ptrtoint (ptr getelementptr inbounds ({ [3 x i32] }, ptr @_ZTV1B.local, i32 0, i32 0, i32 2) to i64)) to i32)] }, comdat($_ZTV1B), align 4
@@ -18,7 +17,7 @@
1817
// CHECK-DAG: @_ZTS1B =
1918
// CHECK-DAG: @_ZTI1A =
2019
// CHECK-DAG: @_ZTI1B =
21-
// CHECK-DAG: @_ZTI1B.rtti_proxy = hidden unnamed_addr constant ptr @_ZTI1B, comdat
20+
// CHECK-DAG: @_ZTI1B.rtti_proxy = linkonce_odr hidden unnamed_addr constant ptr @_ZTI1B, comdat
2221

2322
// We will emit a vtable for B here, so it does have an alias, but we will not
2423
// emit one for A.

clang/test/CodeGenCXX/RelativeVTablesABI/parent-vtable-in-comdat.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
// CHECK: @_ZTVN10__cxxabiv117__class_type_infoE = external global [0 x ptr]
1919
// CHECK: @_ZTS1A = linkonce_odr constant [3 x i8] c"1A\00", comdat, align 1
2020
// CHECK: @_ZTI1A = linkonce_odr constant { ptr, ptr } { ptr getelementptr inbounds (i8, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i32 8), ptr @_ZTS1A }, comdat, align 8
21-
// CHECK: @_ZTI1A.rtti_proxy = hidden unnamed_addr constant ptr @_ZTI1A, comdat
21+
// CHECK: @_ZTI1A.rtti_proxy = linkonce_odr hidden unnamed_addr constant ptr @_ZTI1A, comdat
2222
// CHECK: @_ZTV1A = linkonce_odr unnamed_addr alias { [3 x i32] }, ptr @_ZTV1A.local
2323

2424
// CHECK: define linkonce_odr void @_ZN1A3fooEv(ptr {{.*}}%this) unnamed_addr #{{[0-9]+}} comdat

clang/test/CodeGenCXX/RelativeVTablesABI/relative-vtables-hwasan.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
/// hwasan-instrumented.
77
// CHECK-DAG: @_ZTV1A.local = private 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)] }, no_sanitize_hwaddress, align 4
88
// CHECK-DAG: @_ZTV1A = unnamed_addr alias { [3 x i32] }, ptr @_ZTV1A.local
9-
// CHECK-DAG: @_ZTI1A.rtti_proxy = hidden unnamed_addr constant ptr @_ZTI1A, no_sanitize_hwaddress, comdat
9+
// CHECK-DAG: @_ZTI1A.rtti_proxy = linkonce_odr hidden unnamed_addr constant ptr @_ZTI1A, no_sanitize_hwaddress, comdat
1010

1111
class A {
1212
public:
@@ -22,7 +22,7 @@ void A_foo(A *a) {
2222
/// If the vtable happens to be hidden, then the alias is not needed. In this
2323
/// case, the original vtable struct itself should be unsanitized.
2424
// CHECK-DAG: @_ZTV1B = hidden unnamed_addr constant { [3 x i32] } { [3 x i32] [i32 0, i32 trunc (i64 sub (i64 ptrtoint (ptr @_ZTI1B.rtti_proxy to i64), i64 ptrtoint (ptr getelementptr inbounds ({ [3 x i32] }, ptr @_ZTV1B, i32 0, i32 0, i32 2) to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (ptr dso_local_equivalent @_ZN1B3fooEv to i64), i64 ptrtoint (ptr getelementptr inbounds ({ [3 x i32] }, ptr @_ZTV1B, i32 0, i32 0, i32 2) to i64)) to i32)] }, no_sanitize_hwaddress, align 4
25-
// CHECK-DAG: @_ZTI1B.rtti_proxy = hidden unnamed_addr constant ptr @_ZTI1B, no_sanitize_hwaddress, comdat
25+
// CHECK-DAG: @_ZTI1B.rtti_proxy = linkonce_odr hidden unnamed_addr constant ptr @_ZTI1B, no_sanitize_hwaddress, comdat
2626

2727
class __attribute__((visibility("hidden"))) B {
2828
public:

clang/test/CodeGenCXX/RelativeVTablesABI/simple-vtable-definition.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// CHECK: @_ZTI1A ={{.*}} constant { ptr, ptr } { ptr getelementptr inbounds (i8, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i32 8), ptr @_ZTS1A }, align 8
1515

1616
// The rtti should be in a comdat
17-
// CHECK: @_ZTI1A.rtti_proxy = hidden unnamed_addr constant ptr @_ZTI1A, comdat
17+
// CHECK: @_ZTI1A.rtti_proxy = {{.*}}comdat
1818

1919
// The vtable symbol is exposed through an alias.
2020
// @_ZTV1A = dso_local unnamed_addr alias { [3 x i32] }, ptr @_ZTV1A.local

clang/test/CodeGenCXX/RelativeVTablesABI/type-info.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
// CHECK: @_ZTVN10__cxxabiv120__si_class_type_infoE = external global [0 x ptr]
1414
// CHECK: @_ZTS1B ={{.*}} constant [3 x i8] c"1B\00", align 1
1515
// 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
16-
// CHECK: @_ZTI1A.rtti_proxy = hidden unnamed_addr constant ptr @_ZTI1A, comdat
17-
// CHECK: @_ZTI1B.rtti_proxy = hidden unnamed_addr constant ptr @_ZTI1B, comdat
16+
// CHECK: @_ZTI1A.rtti_proxy = linkonce_odr hidden unnamed_addr constant ptr @_ZTI1A, comdat
17+
// CHECK: @_ZTI1B.rtti_proxy = linkonce_odr hidden unnamed_addr constant ptr @_ZTI1B, comdat
1818

1919
// CHECK: define {{.*}}ptr @_Z11getTypeInfov() local_unnamed_addr
2020
// CHECK-NEXT: entry:

libcxx/test/libcxx/ranges/range.adaptors/range.lazy.split/no_unique_address.compile.pass.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
//===----------------------------------------------------------------------===//
88

99
// UNSUPPORTED: c++03, c++11, c++14, c++17
10-
11-
// clang-cl and cl currently don't support [[no_unique_address]]
12-
// XFAIL: msvc
10+
// XFAIL: msvc && (clang-16 || clang-17)
1311

1412
// class lazy_split_view {
1513
// _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View();

libcxx/test/libcxx/ranges/range.adaptors/range.split/no_unique_address.compile.pass.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
//===----------------------------------------------------------------------===//
88

99
// UNSUPPORTED: c++03, c++11, c++14, c++17
10-
11-
// clang-cl and cl currently don't support [[no_unique_address]]
12-
// XFAIL: msvc
10+
// XFAIL: msvc && (clang-16 || clang-17)
1311

1412
// class split_view {
1513
// _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View();

0 commit comments

Comments
 (0)