xref: /llvm-project/llvm/test/CodeGen/X86/pr30290.ll (revision 834cc88c5d08ca55664b7742590463de813d768f)
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc -mcpu=btver2 %s -o - | FileCheck %s
3; Test desc: two functions (foo, bar) with byval arguments, should not have
4; reads/writes from/to byval storage re-ordered.
5; When broken, five "1" constants are written into the byval %struct.face,
6; but the subsequent byval read of that struct (call to bar) gets re-ordered
7; before those writes, illegally.
8source_filename = "test.c"
9target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
10target triple = "x86_64-pc-linux-gnu"
11
12%struct.face = type { [7 x i32] }
13
14; Function Attrs: noinline nounwind uwtable
15declare void @bar(ptr byval(%struct.face) nocapture readonly align 8);
16
17; Function Attrs: noinline nounwind uwtable
18define void @foo(ptr byval(%struct.face) nocapture align 8) local_unnamed_addr {
19; CHECK-LABEL: foo:
20; CHECK:       # %bb.0:
21; CHECK-NEXT:    subq $40, %rsp
22; CHECK-NEXT:    .cfi_def_cfa_offset 48
23; CHECK-NEXT:    vbroadcastss {{.*#+}} xmm0 = [1,1,1,1]
24; CHECK-NEXT:    vmovaps %xmm0, {{[0-9]+}}(%rsp)
25; CHECK-NEXT:    movl $1, {{[0-9]+}}(%rsp)
26; CHECK-NEXT:    vmovups {{[0-9]+}}(%rsp), %xmm0
27; CHECK-NEXT:    vmovups %xmm0, {{[0-9]+}}(%rsp)
28; CHECK-NEXT:    vmovaps {{[0-9]+}}(%rsp), %xmm0
29; CHECK-NEXT:    vmovups %xmm0, (%rsp)
30; CHECK-NEXT:    callq bar@PLT
31; CHECK-NEXT:    addq $40, %rsp
32; CHECK-NEXT:    .cfi_def_cfa_offset 8
33; CHECK-NEXT:    retq
34  store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, ptr %0, align 8
35  %2 = getelementptr inbounds %struct.face, ptr %0, i64 0, i32 0, i64 4
36  store i32 1, ptr %2, align 8
37  call void @bar(ptr byval(%struct.face) nonnull align 8 %0)
38  ret void
39}
40