1 ; RUN: llc < %s -mtriple=x86_64-apple-darwin | FileCheck %s
3 ; Trivial patchpoint codegen
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) {
11 ; CHECK-LABEL: _trivial_patchpoint_codegen:
15 ; CHECK: movq %rax, %[[REG:r.+]]
18 ; CHECK: movq %[[REG]], %rax
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)
27 ; Caller frame metadata with stackmaps. This should not be optimized
30 ; CHECK-LABEL: caller_meta_leaf
31 ; CHECK: subq $24, %rsp
33 ; CHECK: addq $24, %rsp
35 define void @caller_meta_leaf() {
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)
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) {
50 ; CHECK-LABEL: jscall_patchpoint_codegen:
52 ; CHECK: movq %r{{.+}}, 8(%rsp)
53 ; CHECK: movq %r{{.+}}, (%rsp)
54 ; CHECK: movq $-559038736, %rax
57 ; CHECK: movq %rax, 8(%rsp)
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)
66 ; Test patchpoints reusing the same TargetConstant.
67 ; <rdar:15390785> Assertion failed: (CI.getNumArgOperands() >= NumArgs + 4)
68 ; There is no way to verify this, since it depends on memory allocation.
69 ; But I think it's useful to include as a working example.
70 define i64 @testLowerConstant(i64 %arg, i64 %tmp2, i64 %tmp10, i64* %tmp33, i64 %tmp79) {
72 %tmp80 = add i64 %tmp79, -16
73 %tmp81 = inttoptr i64 %tmp80 to i64*
74 %tmp82 = load i64* %tmp81, align 8
75 tail call void (i32, i32, ...)* @llvm.experimental.stackmap(i32 14, i32 5, i64 %arg, i64 %tmp2, i64 %tmp10, i64 %tmp82)
76 tail call void (i32, i32, i8*, i32, ...)* @llvm.experimental.patchpoint.void(i32 15, i32 30, i8* null, i32 3, i64 %arg, i64 %tmp10, i64 %tmp82)
77 %tmp83 = load i64* %tmp33, align 8
78 %tmp84 = add i64 %tmp83, -24
79 %tmp85 = inttoptr i64 %tmp84 to i64*
80 %tmp86 = load i64* %tmp85, align 8
81 tail call void (i32, i32, ...)* @llvm.experimental.stackmap(i32 17, i32 5, i64 %arg, i64 %tmp10, i64 %tmp86)
82 tail call void (i32, i32, i8*, i32, ...)* @llvm.experimental.patchpoint.void(i32 18, i32 30, i8* null, i32 3, i64 %arg, i64 %tmp10, i64 %tmp86)
86 declare void @llvm.experimental.stackmap(i32, i32, ...)
87 declare void @llvm.experimental.patchpoint.void(i32, i32, i8*, i32, ...)
88 declare i64 @llvm.experimental.patchpoint.i64(i32, i32, i8*, i32, ...)