CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
120 lines
4.1 KiB
Objective-C
120 lines
4.1 KiB
Objective-C
// RUN: rm -rf %t
|
|
// RUN: split-file %s %t
|
|
|
|
// Test 1: Check IR from library implementation (visibility attributes)
|
|
// RUN: %clang_cc1 -triple arm64-apple-darwin -fobjc-arc \
|
|
// RUN: -fobjc-direct-precondition-thunk -emit-llvm -o - %t/foo.m \
|
|
// RUN: -I %t | FileCheck %s --check-prefix=FOO_M
|
|
|
|
// Test 2: Check IR from main (consumer)
|
|
// RUN: %clang_cc1 -triple arm64-apple-darwin -fobjc-arc \
|
|
// RUN: -fobjc-direct-precondition-thunk -emit-llvm -o - %t/main.m \
|
|
// RUN: -I %t | FileCheck %s --check-prefix=MAIN_M
|
|
|
|
//--- foo.h
|
|
// Header for libFoo
|
|
__attribute__((objc_root_class))
|
|
@interface Foo
|
|
// Direct properties with default hidden visibility
|
|
@property (nonatomic, direct) int privateValue;
|
|
|
|
// Direct properties with explicit default visibility
|
|
@property (nonatomic, direct) int exportedValue __attribute__((visibility("default")));
|
|
|
|
+ (instancetype)alloc;
|
|
- (instancetype)initWithprivateValue:(int)x exportedValue:(int)y;
|
|
// Default hidden visibility
|
|
- (int)instanceMethod:(int)x __attribute__((objc_direct));
|
|
+ (int)classMethod:(int)x __attribute__((objc_direct));
|
|
|
|
// Explicit default visibility (should be exported)
|
|
- (int)exportedInstanceMethod:(int)x __attribute__((objc_direct, visibility("default")));
|
|
+ (int)exportedClassMethod:(int)x __attribute__((objc_direct, visibility("default")));
|
|
@end
|
|
|
|
//--- foo.m
|
|
|
|
// libFoo does not have thunks because the true implementation is not used internally.
|
|
// FOO_M-NOT: @{{.*}}_thunk
|
|
#import "foo.h"
|
|
|
|
@implementation Foo
|
|
|
|
// FOO_M-LABEL: define internal ptr @"\01-[Foo initWithprivateValue:exportedValue:]"
|
|
- (instancetype)initWithprivateValue:(int)x exportedValue:(int)y {
|
|
_privateValue = x;
|
|
_exportedValue = y;
|
|
return self;
|
|
}
|
|
|
|
// FOO_M-LABEL: define hidden i32 @"-[Foo instanceMethod:]D"
|
|
- (int)instanceMethod:(int)x {
|
|
// Compiler is smart enough to know that self is non-nil, so we dispatch to
|
|
// true implementation.
|
|
// FOO_M: call i32 @"-[Foo privateValue]D"
|
|
// FOO_M: call i32 @"-[Foo exportedValue]D"
|
|
return x + [self privateValue] + [self exportedValue];
|
|
}
|
|
|
|
// Hidden property getter and setter (default visibility)
|
|
// FOO_M-LABEL: define hidden i32 @"-[Foo privateValue]D"
|
|
|
|
// Exported property getter and setter (explicit default visibility)
|
|
// FOO_M-LABEL: define dso_local i32 @"-[Foo exportedValue]D"
|
|
|
|
// FOO_M-LABEL: define hidden i32 @"+[Foo classMethod:]D"
|
|
+ (int)classMethod:(int)x {
|
|
return x * 3;
|
|
}
|
|
|
|
// FOO_M-LABEL: define dso_local i32 @"-[Foo exportedInstanceMethod:]D"
|
|
- (int)exportedInstanceMethod:(int)x {
|
|
// FOO_M: call i32 @"-[Foo privateValue]D"
|
|
// FOO_M: call i32 @"-[Foo exportedValue]D"
|
|
return x + [self privateValue] + [self exportedValue];
|
|
}
|
|
|
|
// FOO_M-LABEL: define dso_local i32 @"+[Foo exportedClassMethod:]D"
|
|
+ (int)exportedClassMethod:(int)x {
|
|
return x * 5;
|
|
}
|
|
|
|
// Hidden property getter and setter (default visibility)
|
|
// FOO_M-LABEL: define hidden void @"-[Foo setPrivateValue:]D"
|
|
|
|
// Exported property getter and setter (explicit default visibility)
|
|
// FOO_M-LABEL: define dso_local void @"-[Foo setExportedValue:]D"
|
|
|
|
@end
|
|
|
|
//--- main.m
|
|
// Consumer of libFoo (separate linkage unit)
|
|
#import "foo.h"
|
|
|
|
int printf(const char *, ...);
|
|
|
|
int main() {
|
|
Foo *obj = [[Foo alloc] initWithprivateValue:10 exportedValue:20];
|
|
printf("Allocated Foo\n");
|
|
|
|
// MAIN_M: call void @"-[Foo setExportedValue:]D_thunk"
|
|
[obj setExportedValue:30];
|
|
|
|
// MAIN_M: call i32 @"-[Foo exportedValue]D_thunk"
|
|
printf("Reset exportedValue: %d\n", [obj exportedValue]);
|
|
|
|
// MAIN_M: call i32 @"-[Foo exportedInstanceMethod:]D_thunk"
|
|
printf("Exported instance: %d\n", [obj exportedInstanceMethod:10]);
|
|
|
|
// MAIN_M: call i32 @"+[Foo exportedClassMethod:]D_thunk"
|
|
printf("Exported class: %d\n", [Foo exportedClassMethod:10]);
|
|
|
|
return 0;
|
|
}
|
|
|
|
// Thunks are generated during compilation
|
|
// MAIN_M-LABEL: define linkonce_odr hidden void @"-[Foo setExportedValue:]D_thunk"
|
|
// MAIN_M-LABEL: define linkonce_odr hidden i32 @"-[Foo exportedValue]D_thunk"
|
|
// MAIN_M-LABEL: define linkonce_odr hidden i32 @"-[Foo exportedInstanceMethod:]D_thunk"
|
|
// MAIN_M-LABEL: define linkonce_odr hidden i32 @"+[Foo exportedClassMethod:]D_thunk"
|