1 ; RUN: llc -relocation-model=static -verify-machineinstrs < %s -mcpu=pwr7 | FileCheck %s
2 ; RUN: llc -relocation-model=static -verify-machineinstrs < %s -code-model=small -mcpu=pwr7 | FileCheck %s -check-prefix=SCM
4 target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v128:128:128-n32:64"
5 target triple = "powerpc64-unknown-linux-gnu"
8 define dso_local void @foo() nounwind noinline {
12 define weak void @foo_weak() nounwind {
16 ; Calls to local function does not require the TOC restore 'nop'
17 define dso_local void @test_direct() nounwind readnone {
18 ; CHECK-LABEL: test_direct:
19 tail call void @foo() nounwind
20 ; Because of tail call optimization, it can be 'b' instruction.
21 ; CHECK: [[BR:b[l]?]] foo
26 ; Calls to weak function requires a TOC restore 'nop' with all code models
27 ; because the definition that gets choosen at link time may come from a
28 ; different compilation unit that was compiled with PC Relative and has no TOC.
29 define dso_local void @test_weak() nounwind readnone {
30 tail call void @foo_weak() nounwind
31 ; CHECK-LABEL: test_weak:
35 ; SCM-LABEL: test_weak:
41 ; Indirect calls requires a full stub creation
42 define dso_local void @test_indirect(ptr nocapture %fp) nounwind {
43 ; CHECK-LABEL: test_indirect:
44 tail call void %fp() nounwind
47 ; CHECK: ld [[FP:[0-9]+]], 0(3)
48 ; CHECK-NEXT: mtctr [[FP]]
50 ; CHECK-NEXT: ld 2, 40(1)
54 ; Absolute values must use the regular indirect call sequence
55 ; The main purpose of this test is to ensure that BLA is not
56 ; used on 64-bit SVR4 (as e.g. on Darwin).
57 define dso_local void @test_abs() nounwind {
58 ; CHECK-LABEL: test_abs:
59 tail call void inttoptr (i64 1024 to ptr)() nounwind
60 ; CHECK: ld [[FP:[0-9]+]], 1024(0)
61 ; CHECK: ld 11, 1040(0)
62 ; CHECK-NEXT: mtctr [[FP]]
63 ; CHECK: ld 2, 1032(0)
65 ; CHECK-NEXT: ld 2, 40(1)
69 declare double @sin(double) nounwind
71 ; External functions call should also have a 'nop'
72 define double @test_external(double %x) nounwind {
73 ; CHECK-LABEL: test_external:
74 %call = tail call double @sin(double %x) nounwind
80 ; The 'ld 2, 40(1)' really must always come directly after the bctrl to make
81 ; the unwinding code in libgcc happy.
82 @g = external global ptr
84 define dso_local void @test_indir_toc_reload(i64 %x) {
90 ; CHECK-LABEL: @test_indir_toc_reload
92 ; CHECK-NEXT: ld 2, 40(1)