From 67713e2687d3699a2c44db9f600669f19261e730 Mon Sep 17 00:00:00 2001 From: Philip Reames Date: Mon, 22 Jul 2019 23:08:56 +0000 Subject: [PATCH] [Statepoints] Add a test which shows a miscompile with no-realign-stacks llvm-svn: 366760 --- .../CodeGen/X86/statepoint-no-realign-stack.ll | 55 ++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 llvm/test/CodeGen/X86/statepoint-no-realign-stack.ll diff --git a/llvm/test/CodeGen/X86/statepoint-no-realign-stack.ll b/llvm/test/CodeGen/X86/statepoint-no-realign-stack.ll new file mode 100644 index 0000000..943d877 --- /dev/null +++ b/llvm/test/CodeGen/X86/statepoint-no-realign-stack.ll @@ -0,0 +1,55 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc -verify-machineinstrs -mcpu=skylake < %s | FileCheck %s + +target datalayout = "e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-pc-linux-gnu" + +; Shows a case where we spill a 32 byte value onto a stack which is only +; 16 byte aligned. With stack realignment, we can use an aligned spill slot +; (if we think it's profitable), but without realignment, using a stack +; slot which is 32 byte aligned or a store which expects 32 byte alignment +; is incorrect. + +declare void @foo() +define void @can_realign(<8 x i32>* %p) { +; CHECK-LABEL: can_realign: +; CHECK: # %bb.0: +; CHECK-NEXT: pushq %rbp +; CHECK-NEXT: .cfi_def_cfa_offset 16 +; CHECK-NEXT: .cfi_offset %rbp, -16 +; CHECK-NEXT: movq %rsp, %rbp +; CHECK-NEXT: .cfi_def_cfa_register %rbp +; CHECK-NEXT: andq $-32, %rsp +; CHECK-NEXT: subq $64, %rsp +; CHECK-NEXT: vmovaps (%rdi), %ymm0 +; CHECK-NEXT: vmovaps %ymm0, (%rsp) +; CHECK-NEXT: vzeroupper +; CHECK-NEXT: callq foo +; CHECK-NEXT: .Ltmp0: +; CHECK-NEXT: movq %rbp, %rsp +; CHECK-NEXT: popq %rbp +; CHECK-NEXT: .cfi_def_cfa %rsp, 8 +; CHECK-NEXT: retq + %val = load <8 x i32>, <8 x i32>* %p, align 32 + call void @foo() ["deopt" (<8 x i32> %val)] + ret void +} + +; TODO: currently shows incorrect codegen, FIXME +define void @no_realign(<8 x i32>* %p) "no-realign-stack" { +; CHECK-LABEL: no_realign: +; CHECK: # %bb.0: +; CHECK-NEXT: subq $40, %rsp +; CHECK-NEXT: .cfi_def_cfa_offset 48 +; CHECK-NEXT: vmovaps (%rdi), %ymm0 +; CHECK-NEXT: vmovaps %ymm0, (%rsp) +; CHECK-NEXT: vzeroupper +; CHECK-NEXT: callq foo +; CHECK-NEXT: .Ltmp1: +; CHECK-NEXT: addq $40, %rsp +; CHECK-NEXT: .cfi_def_cfa_offset 8 +; CHECK-NEXT: retq + %val = load <8 x i32>, <8 x i32>* %p, align 32 + call void @foo() ["deopt" (<8 x i32> %val)] + ret void +} -- 2.7.4