blob: 3ecef3345ffd800d99415e5300cb912bf91030f9 [file] [log] [blame]
Philip Reames1a1bdb22014-12-02 18:50:36 +00001; RUN: llc < %s | FileCheck %s
2
3target datalayout = "e-i64:64-f80:128-n8:16:32:64-S128"
4target triple = "x86_64-pc-linux-gnu"
5
6; This test is checking to make sure that we reuse the same stack slots
7; for GC values spilled over two different call sites. Since the order
8; of GC arguments differ, niave lowering code would insert loads and
9; stores to rearrange items on the stack. We need to make sure (for
10; performance) that this doesn't happen.
Ramkumar Ramachandrabb406c02015-01-15 18:10:44 +000011define i32 @back_to_back_calls(i32 addrspace(1)* %a, i32 addrspace(1)* %b, i32 addrspace(1)* %c) #1 {
Philip Reames1a1bdb22014-12-02 18:50:36 +000012; CHECK-LABEL: back_to_back_calls
13; The exact stores don't matter, but there need to be three stack slots created
14; CHECK: movq %rdx, 16(%rsp)
15; CHECK: movq %rdi, 8(%rsp)
16; CHECK: movq %rsi, (%rsp)
Ramkumar Ramachandrabb406c02015-01-15 18:10:44 +000017 %safepoint_token = tail call i32 (void ()*, i32, i32, ...)* @llvm.experimental.gc.statepoint.p0f_isVoidf(void ()* undef, i32 0, i32 0, i32 5, i32 0, i32 -1, i32 0, i32 0, i32 0, i32 addrspace(1)* %a, i32 addrspace(1)* %b, i32 addrspace(1)* %c)
18 %a1 = tail call coldcc i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(i32 %safepoint_token, i32 9, i32 9)
19 %b1 = tail call coldcc i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(i32 %safepoint_token, i32 9, i32 10)
20 %c1 = tail call coldcc i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(i32 %safepoint_token, i32 9, i32 11)
Philip Reames1a1bdb22014-12-02 18:50:36 +000021; CHECK: callq
22; This is the key check. There should NOT be any memory moves here
23; CHECK-NOT: movq
Ramkumar Ramachandrabb406c02015-01-15 18:10:44 +000024 %safepoint_token2 = tail call i32 (void ()*, i32, i32, ...)* @llvm.experimental.gc.statepoint.p0f_isVoidf(void ()* undef, i32 0, i32 0, i32 5, i32 0, i32 -1, i32 0, i32 0, i32 0, i32 addrspace(1)* %c1, i32 addrspace(1)* %b1, i32 addrspace(1)* %a1)
25 %a2 = tail call coldcc i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(i32 %safepoint_token2, i32 9, i32 11)
26 %b2 = tail call coldcc i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(i32 %safepoint_token2, i32 9, i32 10)
27 %c2 = tail call coldcc i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(i32 %safepoint_token2, i32 9, i32 9)
Philip Reames1a1bdb22014-12-02 18:50:36 +000028; CHECK: callq
29 ret i32 1
30}
31
32; This test simply checks that minor changes in vm state don't prevent slots
33; being reused for gc values.
Ramkumar Ramachandrabb406c02015-01-15 18:10:44 +000034define i32 @reserve_first(i32 addrspace(1)* %a, i32 addrspace(1)* %b, i32 addrspace(1)* %c) #1 {
Philip Reames1a1bdb22014-12-02 18:50:36 +000035; CHECK-LABEL: reserve_first
36; The exact stores don't matter, but there need to be three stack slots created
37; CHECK: movq %rdx, 16(%rsp)
38; CHECK: movq %rdi, 8(%rsp)
39; CHECK: movq %rsi, (%rsp)
Ramkumar Ramachandrabb406c02015-01-15 18:10:44 +000040 %safepoint_token = tail call i32 (void ()*, i32, i32, ...)* @llvm.experimental.gc.statepoint.p0f_isVoidf(void ()* undef, i32 0, i32 0, i32 5, i32 0, i32 -1, i32 0, i32 0, i32 0, i32 addrspace(1)* %a, i32 addrspace(1)* %b, i32 addrspace(1)* %c)
41 %a1 = tail call coldcc i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(i32 %safepoint_token, i32 9, i32 9)
42 %b1 = tail call coldcc i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(i32 %safepoint_token, i32 9, i32 10)
43 %c1 = tail call coldcc i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(i32 %safepoint_token, i32 9, i32 11)
Philip Reames1a1bdb22014-12-02 18:50:36 +000044; CHECK: callq
45; This is the key check. There should NOT be any memory moves here
46; CHECK-NOT: movq
Ramkumar Ramachandrabb406c02015-01-15 18:10:44 +000047 %safepoint_token2 = tail call i32 (void ()*, i32, i32, ...)* @llvm.experimental.gc.statepoint.p0f_isVoidf(void ()* undef, i32 0, i32 0, i32 5, i32 addrspace(1)* %a1, i32 0, i32 addrspace(1)* %c1, i32 0, i32 0, i32 addrspace(1)* %c1, i32 addrspace(1)* %b1, i32 addrspace(1)* %a1)
48 %a2 = tail call coldcc i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(i32 %safepoint_token2, i32 9, i32 11)
49 %b2 = tail call coldcc i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(i32 %safepoint_token2, i32 9, i32 10)
50 %c2 = tail call coldcc i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(i32 %safepoint_token2, i32 9, i32 9)
Philip Reames1a1bdb22014-12-02 18:50:36 +000051; CHECK: callq
52 ret i32 1
53}
54
55; Function Attrs: nounwind
Ramkumar Ramachandrabb406c02015-01-15 18:10:44 +000056declare i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(i32, i32, i32) #3
Philip Reames1a1bdb22014-12-02 18:50:36 +000057
58declare i32 @llvm.experimental.gc.statepoint.p0f_isVoidf(void ()*, i32, i32, ...)
59
60attributes #1 = { uwtable }