1 ; RUN: llc -verify-machineinstrs -filetype=obj -o - -mtriple=x86_64-apple-macosx < %s | llvm-objdump --triple=x86_64-apple-macosx -d - | FileCheck %s
2 ; RUN: llc -verify-machineinstrs -mtriple=x86_64-apple-macosx < %s | FileCheck %s --check-prefix=CHECK-ALIGN
3 ; RUN: llc -verify-machineinstrs -show-mc-encoding -mtriple=i386 < %s | FileCheck %s --check-prefixes=32,32CFI,XCHG
4 ; RUN: llc -verify-machineinstrs -show-mc-encoding -mtriple=i386-windows-msvc < %s | FileCheck %s --check-prefixes=32,MOV
5 ; RUN: llc -verify-machineinstrs -show-mc-encoding -mtriple=i386-windows-msvc -mcpu=pentium3 < %s | FileCheck %s --check-prefixes=32,MOV
6 ; RUN: llc -verify-machineinstrs -show-mc-encoding -mtriple=i386-windows-msvc -mcpu=pentium4 < %s | FileCheck %s --check-prefixes=32,XCHG
7 ; RUN: llc -verify-machineinstrs -show-mc-encoding -mtriple=x86_64-windows-msvc < %s | FileCheck %s --check-prefix=64
8 ; RUN: llc -verify-machineinstrs -show-mc-encoding -mtriple=i386-unknown-linux-code16 < %s | FileCheck %s --check-prefix=16
10 ; 16-NOT: movl %edi, %edi
11 ; 16-NOT: xchgw %ax, %ax
13 declare void @callee(i64*)
15 define void @f0() "patchable-function"="prologue-short-redirect" {
16 ; CHECK-LABEL: _f0{{>?}}:
17 ; CHECK-NEXT: 66 90 nop
19 ; CHECK-ALIGN: .p2align 4, 0x90
23 ; 32CFI-NEXT: .cfi_startproc
25 ; XCHG-NEXT: xchgw %ax, %ax # encoding: [0x66,0x90]
26 ; MOV-NEXT: movl %edi, %edi # encoding: [0x8b,0xff]
31 ; 64-NEXT: xchgw %ax, %ax # encoding: [0x66,0x90]
37 define void @f1() "patchable-function"="prologue-short-redirect" "frame-pointer"="all" {
39 ; CHECK-NEXT: ff f5 pushq %rbp
41 ; CHECK-ALIGN: .p2align 4, 0x90
45 ; 32CFI-NEXT: .cfi_startproc
47 ; XCHG-NEXT: xchgw %ax, %ax # encoding: [0x66,0x90]
48 ; MOV-NEXT: movl %edi, %edi # encoding: [0x8b,0xff]
52 ; 64-NEXT: .seh_proc f1
59 define void @f2() "patchable-function"="prologue-short-redirect" {
61 ; CHECK-NEXT: 48 81 ec a8 00 00 00 subq $168, %rsp
63 ; CHECK-ALIGN: .p2align 4, 0x90
67 ; 32CFI-NEXT: .cfi_startproc
69 ; XCHG-NEXT: xchgw %ax, %ax # encoding: [0x66,0x90]
70 ; MOV-NEXT: movl %edi, %edi # encoding: [0x8b,0xff]
74 ; 64-NEXT: .seh_proc f2
76 ; 64-NEXT: subq $200, %rsp
78 %ptr = alloca i64, i32 20
79 call void @callee(i64* %ptr)
83 define void @f3() "patchable-function"="prologue-short-redirect" optsize {
85 ; CHECK-NEXT: 66 90 nop
87 ; CHECK-ALIGN: .p2align 4, 0x90
91 ; 32CFI-NEXT: .cfi_startproc
93 ; XCHG-NEXT: xchgw %ax, %ax
94 ; MOV-NEXT: movl %edi, %edi
99 ; 64-NEXT: xchgw %ax, %ax
105 ; This testcase happens to produce a KILL instruction at the beginning of the
106 ; first basic block. In this case the 2nd instruction should be turned into a
108 ; CHECK-LABEL: f4{{>?}}:
109 ; CHECK-NEXT: 8b 0c 37 movl (%rdi,%rsi), %ecx
111 ; 32CFI-NEXT: .cfi_startproc
113 ; XCHG-NEXT: xchgw %ax, %ax
114 ; MOV-NEXT: movl %edi, %edi
115 ; 32-NEXT: pushl %ebx
119 ; 64-NOT: xchgw %ax, %ax
121 define i32 @f4(i8* %arg1, i64 %arg2, i32 %arg3) "patchable-function"="prologue-short-redirect" {
123 %tmp10 = getelementptr i8, i8* %arg1, i64 %arg2
124 %tmp11 = bitcast i8* %tmp10 to i32*
125 %tmp12 = load i32, i32* %tmp11, align 4
127 %tmp13 = add i32 %tmp12, %arg3
128 %tmp14 = cmpxchg i32* %tmp11, i32 %tmp12, i32 %tmp13 seq_cst monotonic
129 %tmp15 = extractvalue { i32, i1 } %tmp14, 1
130 br i1 %tmp15, label %bb21, label %bb16
136 %tmp22 = phi i32 [ %tmp12, %bb ], [ %arg3, %bb16 ]