1 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -Wno-objc-root-class -emit-llvm -o - %s | FileCheck %s
3 // -- classref for the message send in main()
5 // The class is declared with objc_class_stub, so LSB of the class pointer
8 // CHECK-LABEL: @"OBJC_CLASSLIST_REFERENCES_$_" = internal global ptr getelementptr (i8, ptr @"OBJC_CLASS_$_Base", i32 1), align 8
10 // -- classref for the super message send in anotherClassMethod()
12 // Metaclasses do not use the "stub" mechanism and are referenced statically.
14 // CHECK-LABEL: @"OBJC_CLASSLIST_SUP_REFS_$_" = private global ptr @"OBJC_METACLASS_$_Derived", section "__DATA,__objc_superrefs,regular,no_dead_strip", align 8
16 // -- classref for the super message send in anotherInstanceMethod()
18 // The class is declared with objc_class_stub, so LSB of the class pointer
21 // CHECK-LABEL: @"OBJC_CLASSLIST_SUP_REFS_$_.1" = private global ptr getelementptr (i8, ptr @"OBJC_CLASS_$_Derived", i32 1), section "__DATA,__objc_superrefs,regular,no_dead_strip", align 8
23 // -- category list for class stubs goes in __objc_catlist2.
25 // CHECK-LABEL: @"OBJC_LABEL_STUB_CATEGORY_$" = private global [1 x ptr] [ptr @"_OBJC_$_CATEGORY_Derived_$_MyCategory"], section "__DATA,__objc_catlist2,regular,no_dead_strip", align 8
27 __attribute__((objc_class_stub))
28 __attribute__((objc_subclassing_restricted))
31 - (void) instanceMethod;
34 __attribute__((objc_class_stub))
35 __attribute__((objc_subclassing_restricted))
36 @interface Derived : Base
42 // CHECK-LABEL: define{{.*}} i32 @main()
44 // CHECK-NEXT: [[CLASS:%.*]] = call ptr @objc_loadClassref(ptr @"OBJC_CLASSLIST_REFERENCES_$_")
45 // CHECK-NEXT: [[SELECTOR:%.*]] = load ptr, ptr @OBJC_SELECTOR_REFERENCES_
46 // CHECK-NEXT: call void @objc_msgSend(ptr noundef [[CLASS]], ptr noundef [[SELECTOR]])
47 // CHECK-NEXT: ret i32 0
49 // CHECK-LABEL: declare extern_weak ptr @objc_loadClassref(ptr)
50 // CHECK-SAME: [[ATTRLIST:#.*]]
52 @implementation Derived (MyCategory)
54 + (void) anotherClassMethod {
57 // CHECK-LABEL: define internal void @"\01+[Derived(MyCategory) anotherClassMethod]"(ptr noundef %self, ptr noundef %_cmd) #0 {
59 // CHECK: [[SUPER:%.*]] = alloca %struct._objc_super, align 8
60 // CHECK: [[METACLASS_REF:%.*]] = load ptr, ptr @"OBJC_CLASSLIST_SUP_REFS_$_", align 8
61 // CHECK: [[DEST:%.*]] = getelementptr inbounds nuw %struct._objc_super, ptr [[SUPER]], i32 0, i32 1
62 // CHECK: store ptr [[METACLASS_REF]], ptr [[DEST]], align 8
63 // CHECK: call void @objc_msgSendSuper2(ptr noundef [[SUPER]], ptr noundef {{%.*}})
66 - (void) anotherInstanceMethod {
67 [super instanceMethod];
69 // CHECK-LABEL: define internal void @"\01-[Derived(MyCategory) anotherInstanceMethod]"(ptr noundef %self, ptr noundef %_cmd) #0 {
71 // CHECK: [[SUPER:%.*]] = alloca %struct._objc_super, align 8
72 // CHECK: [[CLASS_REF:%.*]] = call ptr @objc_loadClassref(ptr @"OBJC_CLASSLIST_SUP_REFS_$_.1")
73 // CHECK: [[DEST:%.*]] = getelementptr inbounds nuw %struct._objc_super, ptr [[SUPER]], i32 0, i32 1
74 // CHECK: store ptr [[CLASS_REF]], ptr [[DEST]], align 8
75 // CHECK: call void @objc_msgSendSuper2(ptr noundef [[SUPER]], ptr noundef {{%.*}})
80 // -- calls to objc_loadClassRef() are readnone
81 // CHECK: attributes [[ATTRLIST]] = { nounwind nonlazybind memory(none) }