brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.5 KiB · 3995eec Raw
82 lines · plain
1// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -Wno-objc-root-class -emit-llvm -o - %s | FileCheck %s2 3// -- classref for the message send in main()4//5// The class is declared with objc_class_stub, so LSB of the class pointer6// must be set to 1.7//8// CHECK-LABEL: @"OBJC_CLASSLIST_REFERENCES_$_" = internal global ptr getelementptr (i8, ptr @"OBJC_CLASS_$_Base", i32 1), align 89 10// -- classref for the super message send in anotherClassMethod()11//12// Metaclasses do not use the "stub" mechanism and are referenced statically.13//14// CHECK-LABEL: @"OBJC_CLASSLIST_SUP_REFS_$_" = private global ptr @"OBJC_METACLASS_$_Derived", section "__DATA,__objc_superrefs,regular,no_dead_strip", align 815 16// -- classref for the super message send in anotherInstanceMethod()17//18// The class is declared with objc_class_stub, so LSB of the class pointer19// must be set to 1.20//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 822 23// -- category list for class stubs goes in __objc_catlist2.24//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 826 27__attribute__((objc_class_stub))28__attribute__((objc_subclassing_restricted))29@interface Base30+ (void) classMethod;31- (void) instanceMethod;32@end33 34__attribute__((objc_class_stub))35__attribute__((objc_subclassing_restricted))36@interface Derived : Base37@end38 39int main(void) {40  [Base classMethod];41}42// CHECK-LABEL: define{{.*}} i32 @main()43// CHECK-NEXT: entry: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 048 49// CHECK-LABEL: declare extern_weak ptr @objc_loadClassref(ptr)50// CHECK-SAME: [[ATTRLIST:#.*]]51 52@implementation Derived (MyCategory)53 54+ (void) anotherClassMethod {55  [super classMethod];56}57// CHECK-LABEL: define internal void @"\01+[Derived(MyCategory) anotherClassMethod]"(ptr noundef %self, ptr noundef %_cmd) #0 {58// CHECK-NEXT: entry:59// CHECK:        [[SUPER:%.*]] = alloca %struct._objc_super, align 860// CHECK:        [[METACLASS_REF:%.*]] = load ptr, ptr @"OBJC_CLASSLIST_SUP_REFS_$_", align 861// CHECK:        [[DEST:%.*]] = getelementptr inbounds nuw %struct._objc_super, ptr [[SUPER]], i32 0, i32 162// CHECK:        store ptr [[METACLASS_REF]], ptr [[DEST]], align 863// CHECK:        call void @objc_msgSendSuper2(ptr noundef [[SUPER]], ptr noundef {{%.*}})64// CHECK:        ret void65 66- (void) anotherInstanceMethod {67  [super instanceMethod];68}69// CHECK-LABEL: define internal void @"\01-[Derived(MyCategory) anotherInstanceMethod]"(ptr noundef %self, ptr noundef %_cmd) #0 {70// CHECK-NEXT: entry:71// CHECK:        [[SUPER:%.*]] = alloca %struct._objc_super, align 872// 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 174// CHECK:        store ptr [[CLASS_REF]], ptr [[DEST]], align 875// CHECK:        call void @objc_msgSendSuper2(ptr noundef [[SUPER]], ptr noundef {{%.*}})76// CHECK:        ret void77 78@end79 80// -- calls to objc_loadClassRef() are readnone81// CHECK: attributes [[ATTRLIST]] = { nounwind nonlazybind memory(none) }82