~pali/+junk/llvm-toolchain-3.7

« back to all changes in this revision

Viewing changes to test/CodeGen/PowerPC/ppc64-calls.ll

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2015-07-15 17:51:08 UTC
  • Revision ID: package-import@ubuntu.com-20150715175108-l8mynwovkx4zx697
Tags: upstream-3.7~+rc2
ImportĀ upstreamĀ versionĀ 3.7~+rc2

Show diffs side-by-side

added added

removed removed

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