• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc < %s -march=ppc64 -mcpu=pwr7 | FileCheck %s
2target 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"
3target triple = "powerpc64-unknown-linux-gnu"
4
5
6define void @foo() nounwind noinline {
7  ret void
8}
9
10define weak void @foo_weak() nounwind {
11  ret void
12}
13
14; Calls to local function does not require the TOC restore 'nop'
15define void @test_direct() nounwind readnone {
16; CHECK-LABEL: test_direct:
17  tail call void @foo() nounwind
18; Because of tail call optimization, it can be 'b' instruction.
19; CHECK: [[BR:b[l]?]] foo
20; CHECK-NOT: nop
21  ret void
22}
23
24; Calls to weak function requires a TOC restore 'nop' because they
25; may be overridden in a different module.
26define void @test_weak() nounwind readnone {
27; CHECK-LABEL: test_weak:
28  tail call void @foo_weak() nounwind
29; CHECK: bl foo
30; CHECK-NEXT: nop
31  ret void
32}
33
34; Indirect calls requires a full stub creation
35define void @test_indirect(void ()* nocapture %fp) nounwind {
36; CHECK-LABEL: test_indirect:
37  tail call void %fp() nounwind
38; CHECK: ld [[FP:[0-9]+]], 0(3)
39; CHECK: ld 11, 16(3)
40; CHECK: ld 2, 8(3)
41; CHECK-NEXT: mtctr [[FP]]
42; CHECK-NEXT: bctrl
43; CHECK-NEXT: ld 2, 40(1)
44  ret void
45}
46
47; Absolute values must use the regular indirect call sequence
48; The main purpose of this test is to ensure that BLA is not
49; used on 64-bit SVR4 (as e.g. on Darwin).
50define void @test_abs() nounwind {
51; CHECK-LABEL: test_abs:
52  tail call void inttoptr (i64 1024 to void ()*)() nounwind
53; CHECK: ld [[FP:[0-9]+]], 1024(0)
54; CHECK: ld 11, 1040(0)
55; CHECK: ld 2, 1032(0)
56; CHECK-NEXT: mtctr [[FP]]
57; CHECK-NEXT: bctrl
58; CHECK-NEXT: ld 2, 40(1)
59  ret void
60}
61
62declare double @sin(double) nounwind
63
64; External functions call should also have a 'nop'
65define double @test_external(double %x) nounwind {
66; CHECK-LABEL: test_external:
67  %call = tail call double @sin(double %x) nounwind
68; CHECK: bl sin
69; CHECK-NEXT: nop
70  ret double %call
71}
72
73; The 'ld 2, 40(1)' really must always come directly after the bctrl to make
74; the unwinding code in libgcc happy.
75@g = external global void ()*
76declare void @h(i64)
77define void @test_indir_toc_reload(i64 %x) {
78  %1 = load void ()*, void ()** @g
79  call void %1()
80  call void @h(i64 %x)
81  ret void
82
83; CHECK-LABEL: @test_indir_toc_reload
84; CHECK: bctrl
85; CHECK-NEXT: ld 2, 40(1)
86; CHECK: blr
87}
88
89