| Philip Reames | 1a1bdb2 | 2014-12-02 18:50:36 +0000 | [diff] [blame] | 1 | ; RUN: llc < %s | FileCheck %s |
| 2 | |
| 3 | target datalayout = "e-i64:64-f80:128-n8:16:32:64-S128" |
| 4 | target 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 Ramachandra | bb406c0 | 2015-01-15 18:10:44 +0000 | [diff] [blame] | 11 | define i32 @back_to_back_calls(i32 addrspace(1)* %a, i32 addrspace(1)* %b, i32 addrspace(1)* %c) #1 { |
| Philip Reames | 1a1bdb2 | 2014-12-02 18:50:36 +0000 | [diff] [blame] | 12 | ; 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 Ramachandra | bb406c0 | 2015-01-15 18:10:44 +0000 | [diff] [blame] | 17 | %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 Reames | 1a1bdb2 | 2014-12-02 18:50:36 +0000 | [diff] [blame] | 21 | ; CHECK: callq |
| 22 | ; This is the key check. There should NOT be any memory moves here |
| 23 | ; CHECK-NOT: movq |
| Ramkumar Ramachandra | bb406c0 | 2015-01-15 18:10:44 +0000 | [diff] [blame] | 24 | %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 Reames | 1a1bdb2 | 2014-12-02 18:50:36 +0000 | [diff] [blame] | 28 | ; 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 Ramachandra | bb406c0 | 2015-01-15 18:10:44 +0000 | [diff] [blame] | 34 | define i32 @reserve_first(i32 addrspace(1)* %a, i32 addrspace(1)* %b, i32 addrspace(1)* %c) #1 { |
| Philip Reames | 1a1bdb2 | 2014-12-02 18:50:36 +0000 | [diff] [blame] | 35 | ; 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 Ramachandra | bb406c0 | 2015-01-15 18:10:44 +0000 | [diff] [blame] | 40 | %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 Reames | 1a1bdb2 | 2014-12-02 18:50:36 +0000 | [diff] [blame] | 44 | ; CHECK: callq |
| 45 | ; This is the key check. There should NOT be any memory moves here |
| 46 | ; CHECK-NOT: movq |
| Ramkumar Ramachandra | bb406c0 | 2015-01-15 18:10:44 +0000 | [diff] [blame] | 47 | %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 Reames | 1a1bdb2 | 2014-12-02 18:50:36 +0000 | [diff] [blame] | 51 | ; CHECK: callq |
| 52 | ret i32 1 |
| 53 | } |
| 54 | |
| 55 | ; Function Attrs: nounwind |
| Ramkumar Ramachandra | bb406c0 | 2015-01-15 18:10:44 +0000 | [diff] [blame] | 56 | declare i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(i32, i32, i32) #3 |
| Philip Reames | 1a1bdb2 | 2014-12-02 18:50:36 +0000 | [diff] [blame] | 57 | |
| 58 | declare i32 @llvm.experimental.gc.statepoint.p0f_isVoidf(void ()*, i32, i32, ...) |
| 59 | |
| 60 | attributes #1 = { uwtable } |