xref: /llvm-project/llvm/test/CodeGen/X86/rtm.ll (revision 2f448bf509432c1a19ec46ab8cbc7353c03c6280)
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc -verify-machineinstrs < %s -mtriple=i686-unknown-unknown -mattr=+rtm | FileCheck %s --check-prefix=X86
3; RUN: llc -verify-machineinstrs < %s -mtriple=x86_64-unknown-unknown -mattr=+rtm | FileCheck %s --check-prefix=X64
4
5declare i32 @llvm.x86.xbegin() nounwind
6declare void @llvm.x86.xend() nounwind
7declare void @llvm.x86.xabort(i8) nounwind
8declare void @f1()
9
10define i32 @test_xbegin() nounwind uwtable {
11; X86-LABEL: test_xbegin:
12; X86:       # %bb.0: # %entry
13; X86-NEXT:    xbegin .LBB0_2
14; X86-NEXT:  # %bb.1: # %entry
15; X86-NEXT:    movl $-1, %eax
16; X86-NEXT:    retl
17; X86-NEXT:  .LBB0_2: # %entry
18; X86-NEXT:    # XABORT DEF
19; X86-NEXT:    retl
20;
21; X64-LABEL: test_xbegin:
22; X64:       # %bb.0: # %entry
23; X64-NEXT:    xbegin .LBB0_2
24; X64-NEXT:  # %bb.1: # %entry
25; X64-NEXT:    movl $-1, %eax
26; X64-NEXT:    retq
27; X64-NEXT:  .LBB0_2: # %entry
28; X64-NEXT:    # XABORT DEF
29; X64-NEXT:    retq
30entry:
31  %0 = tail call i32 @llvm.x86.xbegin() nounwind
32  ret i32 %0
33}
34
35define void @test_xend() nounwind uwtable {
36; X86-LABEL: test_xend:
37; X86:       # %bb.0: # %entry
38; X86-NEXT:    xend
39; X86-NEXT:    retl
40;
41; X64-LABEL: test_xend:
42; X64:       # %bb.0: # %entry
43; X64-NEXT:    xend
44; X64-NEXT:    retq
45entry:
46  tail call void @llvm.x86.xend() nounwind
47  ret void
48}
49
50define void @test_xabort() nounwind uwtable {
51; X86-LABEL: test_xabort:
52; X86:       # %bb.0: # %entry
53; X86-NEXT:    xabort $2
54; X86-NEXT:    retl
55;
56; X64-LABEL: test_xabort:
57; X64:       # %bb.0: # %entry
58; X64-NEXT:    xabort $2
59; X64-NEXT:    retq
60entry:
61  tail call void @llvm.x86.xabort(i8 2)
62  ret void
63}
64
65define void @f2(i32 %x) nounwind uwtable {
66; X86-LABEL: f2:
67; X86:       # %bb.0: # %entry
68; X86-NEXT:    xabort $1
69; X86-NEXT:    calll f1@PLT
70; X86-NEXT:    retl
71;
72; X64-LABEL: f2:
73; X64:       # %bb.0: # %entry
74; X64-NEXT:    pushq %rax
75; X64-NEXT:    .cfi_def_cfa_offset 16
76; X64-NEXT:    movl %edi, {{[0-9]+}}(%rsp)
77; X64-NEXT:    xabort $1
78; X64-NEXT:    callq f1@PLT
79; X64-NEXT:    popq %rax
80; X64-NEXT:    .cfi_def_cfa_offset 8
81; X64-NEXT:    retq
82entry:
83  %x.addr = alloca i32, align 4
84  store i32 %x, ptr %x.addr, align 4
85  call void @llvm.x86.xabort(i8 1)
86  call void @f1()
87  ret void
88}
89
90