1; 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. 11define i32 @back_to_back_calls(i32* %a, i32* %b, i32* %c) #1 { 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) 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* %a, i32* %b, i32* %c) 18 %a1 = tail call coldcc i32* @llvm.experimental.gc.relocate.p0i32(i32 %safepoint_token, i32 9, i32 9) 19 %b1 = tail call coldcc i32* @llvm.experimental.gc.relocate.p0i32(i32 %safepoint_token, i32 9, i32 10) 20 %c1 = tail call coldcc i32* @llvm.experimental.gc.relocate.p0i32(i32 %safepoint_token, i32 9, i32 11) 21; CHECK: callq 22; This is the key check. There should NOT be any memory moves here 23; CHECK-NOT: movq 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* %c1, i32* %b1, i32* %a1) 25 %a2 = tail call coldcc i32* @llvm.experimental.gc.relocate.p0i32(i32 %safepoint_token2, i32 9, i32 11) 26 %b2 = tail call coldcc i32* @llvm.experimental.gc.relocate.p0i32(i32 %safepoint_token2, i32 9, i32 10) 27 %c2 = tail call coldcc i32* @llvm.experimental.gc.relocate.p0i32(i32 %safepoint_token2, i32 9, i32 9) 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. 34define i32 @reserve_first(i32* %a, i32* %b, i32* %c) #1 { 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) 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* %a, i32* %b, i32* %c) 41 %a1 = tail call coldcc i32* @llvm.experimental.gc.relocate.p0i32(i32 %safepoint_token, i32 9, i32 9) 42 %b1 = tail call coldcc i32* @llvm.experimental.gc.relocate.p0i32(i32 %safepoint_token, i32 9, i32 10) 43 %c1 = tail call coldcc i32* @llvm.experimental.gc.relocate.p0i32(i32 %safepoint_token, i32 9, i32 11) 44; CHECK: callq 45; This is the key check. There should NOT be any memory moves here 46; CHECK-NOT: movq 47 %safepoint_token2 = tail call i32 (void ()*, i32, i32, ...)* @llvm.experimental.gc.statepoint.p0f_isVoidf(void ()* undef, i32 0, i32 0, i32 5, i32* %a1, i32 0, i32* %c1, i32 0, i32 0, i32* %c1, i32* %b1, i32* %a1) 48 %a2 = tail call coldcc i32* @llvm.experimental.gc.relocate.p0i32(i32 %safepoint_token2, i32 9, i32 11) 49 %b2 = tail call coldcc i32* @llvm.experimental.gc.relocate.p0i32(i32 %safepoint_token2, i32 9, i32 10) 50 %c2 = tail call coldcc i32* @llvm.experimental.gc.relocate.p0i32(i32 %safepoint_token2, i32 9, i32 9) 51; CHECK: callq 52 ret i32 1 53} 54 55; Function Attrs: nounwind 56declare i32* @llvm.experimental.gc.relocate.p0i32(i32, i32, i32) #3 57 58declare i32 @llvm.experimental.gc.statepoint.p0f_isVoidf(void ()*, i32, i32, ...) 59 60attributes #1 = { uwtable } 61