These test cases for experimental features are a bit too darwin-specific still. Use...
[oota-llvm.git] / test / CodeGen / X86 / patchpoint.ll
1 ; RUN: llc < %s -mtriple=x86_64-apple-darwin | FileCheck %s
2
3 ; Trivial patchpoint codegen
4 ;
5 ; FIXME: We should verify that the call target is materialize after
6 ; the label immediately before the call.
7 ; <rdar://15187295> [JS] llvm.webkit.patchpoint call target should be
8 ; materialized in nop slide.
9 define i64 @trivial_patchpoint_codegen(i64 %p1, i64 %p2, i64 %p3, i64 %p4) {
10 entry:
11 ; CHECK-LABEL: _trivial_patchpoint_codegen:
12 ; CHECK:      Ltmp
13 ; CHECK:      callq *%rax
14 ; CHECK-NEXT: nop
15 ; CHECK:      movq %rax, %[[REG:r.+]]
16 ; CHECK:      callq *%rax
17 ; CHECK-NEXT: nop
18 ; CHECK:      movq %[[REG]], %rax
19 ; CHECK:      ret
20   %resolveCall2 = inttoptr i64 -559038736 to i8*
21   %result = tail call i64 (i32, i32, i8*, i32, ...)* @llvm.experimental.patchpoint.i64(i32 2, i32 12, i8* %resolveCall2, i32 4, i64 %p1, i64 %p2, i64 %p3, i64 %p4)
22   %resolveCall3 = inttoptr i64 -559038737 to i8*
23   tail call void (i32, i32, i8*, i32, ...)* @llvm.experimental.patchpoint.void(i32 3, i32 12, i8* %resolveCall3, i32 2, i64 %p1, i64 %result)
24   ret i64 %result
25 }
26
27 ; Caller frame metadata with stackmaps. This should not be optimized
28 ; as a leaf function.
29 ;
30 ; CHECK-LABEL: caller_meta_leaf
31 ; CHECK: subq $24, %rsp
32 ; CHECK: Ltmp
33 ; CHECK: addq $24, %rsp
34 ; CHECK: ret
35 define void @caller_meta_leaf() {
36 entry:
37   %metadata = alloca i64, i32 3, align 8
38   store i64 11, i64* %metadata
39   store i64 12, i64* %metadata
40   store i64 13, i64* %metadata
41   call void (i32, i32, ...)* @llvm.experimental.stackmap(i32 4, i32 0, i64* %metadata)
42   ret void
43 }
44
45 ; Test the webkit_jscc calling convention.
46 ; Two arguments will be pushed on the stack.
47 ; Return value in $rax.
48 define void @jscall_patchpoint_codegen(i64 %p1, i64 %p2, i64 %p3, i64 %p4) {
49 entry:
50 ; CHECK-LABEL: jscall_patchpoint_codegen:
51 ; CHECK: Ltmp
52 ; CHECK: movq %r{{.+}}, 8(%rsp)
53 ; CHECK: movq %r{{.+}}, (%rsp)
54 ; CHECK: movq $-559038736, %rax
55 ; CHECK: Ltmp
56 ; CHECK: callq *%rax
57 ; CHECK: movq %rax, 8(%rsp)
58 ; CHECK: callq
59   %resolveCall2 = inttoptr i64 -559038736 to i8*
60   %result = tail call webkit_jscc i64 (i32, i32, i8*, i32, ...)* @llvm.experimental.patchpoint.i64(i32 5, i32 12, i8* %resolveCall2, i32 2, i64 %p1, i64 %p2)
61   %resolveCall3 = inttoptr i64 -559038737 to i8*
62   tail call webkit_jscc void (i32, i32, i8*, i32, ...)* @llvm.experimental.patchpoint.void(i32 6, i32 12, i8* %resolveCall3, i32 2, i64 %p1, i64 %result)
63   ret void
64 }
65
66 declare void @llvm.experimental.stackmap(i32, i32, ...)
67 declare void @llvm.experimental.patchpoint.void(i32, i32, i8*, i32, ...)
68 declare i64 @llvm.experimental.patchpoint.i64(i32, i32, i8*, i32, ...)