1 ; RUN: llc -mtriple=arm64-apple-ios -O2 -aarch64-collect-loh -aarch64-collect-loh-bb-only=false < %s -o - | FileCheck %s
2 ; RUN: llc -mtriple=arm64-linux-gnu -O2 -aarch64-collect-loh -aarch64-collect-loh-bb-only=false < %s -o - | FileCheck %s --check-prefix=CHECK-ELF
5 ; CHECK-ELF-NOT: AdrpAdrp
6 ; CHECK-ELF-NOT: AdrpAdd
7 ; CHECK-ELF-NOT: AdrpLdrGot
9 @a = internal unnamed_addr global i32 0, align 4
10 @b = external global i32
12 ; Function Attrs: noinline nounwind ssp
13 define void @foo(i32 %t) {
15 %tmp = load i32* @a, align 4
16 %add = add nsw i32 %tmp, %t
17 store i32 %add, i32* @a, align 4
21 ; Function Attrs: nounwind ssp
22 ; Testcase for <rdar://problem/15438605>, AdrpAdrp reuse is valid only when the first adrp
23 ; dominates the second.
24 ; The first adrp comes from the loading of 'a' and the second the loading of 'b'.
25 ; 'a' is loaded in if.then, 'b' in if.end4, if.then does not dominates if.end4.
28 ; CHECK-NOT: .loh AdrpAdrp
29 define i32 @test(i32 %t) {
31 %cmp = icmp sgt i32 %t, 5
32 br i1 %cmp, label %if.then, label %if.end4
34 if.then: ; preds = %entry
35 %tmp = load i32* @a, align 4
36 %add = add nsw i32 %tmp, %t
37 %cmp1 = icmp sgt i32 %add, 12
38 br i1 %cmp1, label %if.then2, label %if.end4
40 if.then2: ; preds = %if.then
41 tail call void @foo(i32 %add)
42 %tmp1 = load i32* @a, align 4
45 if.end4: ; preds = %if.then2, %if.then, %entry
46 %t.addr.0 = phi i32 [ %tmp1, %if.then2 ], [ %t, %if.then ], [ %t, %entry ]
47 %tmp2 = load i32* @b, align 4
48 %add5 = add nsw i32 %tmp2, %t.addr.0
49 tail call void @foo(i32 %add5)
50 %tmp3 = load i32* @b, align 4
51 %add6 = add nsw i32 %tmp3, %t.addr.0