77 lines · plain
1// RUN: %clang_cc1 -emit-llvm -triple i686-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -o - %s -O2 | FileCheck %s2 3@interface MyClass4{5}6- (void)method;7@end8 9@implementation MyClass10 11// CHECK: define internal void @"\01-[MyClass method]"12- (void)method13{14 // CHECK: call i32 @objc_sync_enter15 // CHECK: call void @objc_exception_try_enter16 // CHECK: call i32 @_setjmp17 @synchronized(self) {18 }19}20 21@end22 23// CHECK-LABEL: define{{.*}} void @foo(24void foo(id a) {25 // CHECK: [[A:%.*]] = alloca ptr26 // CHECK: [[SYNC:%.*]] = alloca ptr27 28 // CHECK: store ptr [[AVAL:%.*]], ptr [[A]]29 // CHECK-NEXT: call i32 @objc_sync_enter(ptr [[AVAL]])30 // CHECK-NEXT: store ptr [[AVAL]], ptr [[SYNC]]31 // CHECK-NEXT: call void @objc_exception_try_enter32 // CHECK: call i32 @_setjmp33 @synchronized(a) {34 // This is unreachable, but the optimizers can't know that.35 // CHECK: call void asm sideeffect "", "=*m,=*m,=*m"(ptr nonnull elementtype(ptr) [[A]], ptr nonnull elementtype(ptr) [[SYNC]]36 // CHECK: call i32 @objc_sync_exit37 // CHECK: call ptr @objc_exception_extract38 // CHECK: call void @objc_exception_throw39 // CHECK: unreachable40 41 // CHECK: call void @objc_exception_try_exit42 // CHECK-NEXT: call i32 @objc_sync_exit43 // CHECK: ret void44 return;45 }46 47}48 49// CHECK-LABEL: define{{.*}} i32 @f0(50int f0(id a) {51 // We can optimize the ret to a constant as we can figure out52 // that x isn't stored to within the synchronized block.53 54 // CHECK: [[X:%.*]] = alloca i3255 // CHECK: store i32 1, ptr [[X]]56 int x = 0;57 @synchronized((x++, a)) { 58 }59 60 // CHECK: ret i32 161 return x;62}63 64// CHECK-LABEL: define{{.*}} void @f1(65void f1(id a) {66 // Check that the return doesn't go through the cleanup.67 extern void opaque(void);68 opaque();69 70 // CHECK: call void @opaque()71 // CHECK-NEXT: ret void72 73 @synchronized(({ return; }), a) {74 return;75 }76}77