1 ; RUN: opt -S -basicaa -objc-arc-aa -gvn < %s | FileCheck %s 2 3 @x = common global i8* null, align 8 4 5 declare i8* @objc_retain(i8*) 6 declare i32 @objc_sync_enter(i8*) 7 declare i32 @objc_sync_exit(i8*) 8 9 ; GVN should be able to eliminate this redundant load, with ARC-specific 10 ; alias analysis. 11 12 ; CHECK: define i8* @test0(i32 %n) 13 ; CHECK-NEXT: entry: 14 ; CHECK-NEXT: %s = load i8*, i8** @x 15 ; CHECK-NOT: load 16 ; CHECK: ret i8* %s 17 ; CHECK-NEXT: } 18 define i8* @test0(i32 %n) nounwind { 19 entry: 20 %s = load i8*, i8** @x 21 %0 = tail call i8* @objc_retain(i8* %s) nounwind 22 %t = load i8*, i8** @x 23 ret i8* %t 24 } 25 26 ; GVN should not be able to eliminate this redundant load, with ARC-specific 27 ; alias analysis. 28 29 ; CHECK-LABEL: define i8* @test1( 30 ; CHECK: load 31 ; CHECK: load 32 ; CHECK: ret i8* %t 33 ; CHECK: } 34 define i8* @test1(i32 %n) nounwind { 35 entry: 36 %s = load i8*, i8** @x 37 %0 = call i32 @objc_sync_enter(i8* %s) 38 %t = load i8*, i8** @x 39 %1 = call i32 @objc_sync_exit(i8* %s) 40 ret i8* %t 41 } 42