1 ; RUN: llc < %s -verify-machineinstrs | FileCheck %s
2 target datalayout = "e-p:64:64:64-S128-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f16:16:16-f32:32:32-f64:64:64-f128:128:128-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
3 target triple = "x86_64-apple-darwin11.4.0"
7 define i64 @test_trivial() {
8 %A = tail call i64 @testi()
11 ; CHECK: test_trivial:
12 ; CHECK: jmp _testi ## TAILCALL
15 define i64 @test_noop_bitcast() {
16 %A = tail call i64 @testi()
17 %B = bitcast i64 %A to i64
20 ; CHECK: test_noop_bitcast:
21 ; CHECK: jmp _testi ## TAILCALL
24 ; Tail call shouldn't be blocked by no-op inttoptr.
25 define i8* @test_inttoptr() {
26 %A = tail call i64 @testi()
27 %B = inttoptr i64 %A to i8*
31 ; CHECK: test_inttoptr:
32 ; CHECK: jmp _testi ## TAILCALL
35 declare <4 x float> @testv()
37 define <4 x i32> @test_vectorbitcast() {
38 %A = tail call <4 x float> @testv()
39 %B = bitcast <4 x float> %A to <4 x i32>
42 ; CHECK: test_vectorbitcast:
43 ; CHECK: jmp _testv ## TAILCALL
46 declare { i64, i64 } @testp()
48 define {i64, i64} @test_pair_trivial() {
49 %A = tail call { i64, i64} @testp()
52 ; CHECK: test_pair_trivial:
53 ; CHECK: jmp _testp ## TAILCALL
57 define {i64, i64} @test_pair_trivial_extract() {
58 %A = tail call { i64, i64} @testp()
59 %x = extractvalue { i64, i64} %A, 0
60 %y = extractvalue { i64, i64} %A, 1
62 %b = insertvalue {i64, i64} undef, i64 %x, 0
63 %c = insertvalue {i64, i64} %b, i64 %y, 1
68 ; CHECK: test_pair_trivial_extract:
69 ; CHECK: jmp _testp ## TAILCALL
71 define {i8*, i64} @test_pair_conv_extract() {
72 %A = tail call { i64, i64} @testp()
73 %x = extractvalue { i64, i64} %A, 0
74 %y = extractvalue { i64, i64} %A, 1
76 %x1 = inttoptr i64 %x to i8*
78 %b = insertvalue {i8*, i64} undef, i8* %x1, 0
79 %c = insertvalue {i8*, i64} %b, i64 %y, 1
84 ; CHECK: test_pair_conv_extract:
85 ; CHECK: jmp _testp ## TAILCALL
90 define { i64, i64 } @crash(i8* %this) {
91 %c = tail call { i64, i64 } @testp()
92 %mrv7 = insertvalue { i64, i64 } %c, i64 undef, 1
93 ret { i64, i64 } %mrv7
96 ; <rdar://problem/12282281> Fold an indexed load into the tail call instruction.
97 ; Calling a varargs function with 6 arguments requires 7 registers (%al is the
98 ; vector count for varargs functions). This leaves %r11 as the only available
101 ; It is not possible to fold an indexed load into TCRETURNmi64 in that case.
103 ; typedef int (*funcptr)(void*, ...);
104 ; extern const funcptr funcs[];
106 ; return funcs[n](0, 0, 0, 0, 0, 0);
109 ; CHECK: rdar12282281
110 ; CHECK: jmpq *%r11 # TAILCALL
111 @funcs = external constant [0 x i32 (i8*, ...)*]
113 define i32 @rdar12282281(i32 %n) nounwind uwtable ssp {
115 %idxprom = sext i32 %n to i64
116 %arrayidx = getelementptr inbounds [0 x i32 (i8*, ...)*]* @funcs, i64 0, i64 %idxprom
117 %0 = load i32 (i8*, ...)** %arrayidx, align 8
118 %call = tail call i32 (i8*, ...)* %0(i8* null, i32 0, i32 0, i32 0, i32 0, i32 0) nounwind
122 ; Same thing, using a fixed offset. The load should foid.
123 ; CHECK: rdar12282281fixed
124 ; CHECK: jmpq *8(%r11) # TAILCALL
125 define i32 @rdar12282281fixed() nounwind uwtable ssp {
127 %0 = load i32 (i8*, ...)** getelementptr inbounds ([0 x i32 (i8*, ...)*]* @funcs, i64 0, i64 1), align 8
128 %call.i = tail call i32 (i8*, ...)* %0(i8* null, i32 0, i32 0, i32 0, i32 0, i32 0) nounwind