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 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 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 the small codemodel
27 ; because the definition that gets choosen at link time may come from a
28 ; different section even though we have seen a weak definition in the same
29 ; section at compile time.
30 ; With large and medium codemodels no TOC restore is needed, since we know
31 ; whichever definition is choosen it resides within the same DSO boundaries and
32 ; therefore shares the same TOC.
33 define void @test_weak() nounwind readnone {
34 tail call void @foo_weak() nounwind
35 ; CHECK-LABEL: test_weak:
39 ; SCM-LABEL: test_weak:
45 ; Indirect calls requires a full stub creation
46 define void @test_indirect(void ()* nocapture %fp) nounwind {
47 ; CHECK-LABEL: test_indirect:
48 tail call void %fp() nounwind
49 ; CHECK: ld [[FP:[0-9]+]], 0(3)
52 ; CHECK-NEXT: mtctr [[FP]]
54 ; CHECK-NEXT: ld 2, 40(1)
58 ; Absolute values must use the regular indirect call sequence
59 ; The main purpose of this test is to ensure that BLA is not
60 ; used on 64-bit SVR4 (as e.g. on Darwin).
61 define void @test_abs() nounwind {
62 ; CHECK-LABEL: test_abs:
63 tail call void inttoptr (i64 1024 to void ()*)() nounwind
64 ; CHECK: ld [[FP:[0-9]+]], 1024(0)
65 ; CHECK: ld 11, 1040(0)
66 ; CHECK: ld 2, 1032(0)
67 ; CHECK-NEXT: mtctr [[FP]]
69 ; CHECK-NEXT: ld 2, 40(1)
73 declare double @sin(double) nounwind
75 ; External functions call should also have a 'nop'
76 define double @test_external(double %x) nounwind {
77 ; CHECK-LABEL: test_external:
78 %call = tail call double @sin(double %x) nounwind
84 ; The 'ld 2, 40(1)' really must always come directly after the bctrl to make
85 ; the unwinding code in libgcc happy.
86 @g = external global void ()*
88 define void @test_indir_toc_reload(i64 %x) {
89 %1 = load void ()*, void ()** @g
94 ; CHECK-LABEL: @test_indir_toc_reload
96 ; CHECK-NEXT: ld 2, 40(1)