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 9 10; 16-NOT: movl %edi, %edi 11; 16-NOT: xchgw %ax, %ax 12 13declare void @callee(ptr) 14 15define void @f0() "patchable-function"="prologue-short-redirect" { 16; CHECK-LABEL: _f0{{>?}}: 17; CHECK-NEXT: 66 90 nop 18 19; CHECK-ALIGN: .p2align 4, 0x90 20; CHECK-ALIGN: _f0: 21 22; 32: f0: 23; 32CFI-NEXT: .cfi_startproc 24; 32-NEXT: # %bb.0: 25; XCHG-NEXT: xchgw %ax, %ax # encoding: [0x66,0x90] 26; MOV-NEXT: movl %edi, %edi # encoding: [0x8b,0xff] 27; 32-NEXT: retl 28 29; 64: f0: 30; 64-NEXT: # %bb.0: 31; 64-NEXT: xchgw %ax, %ax # encoding: [0x66,0x90] 32; 64-NEXT: retq 33 34 ret void 35} 36 37define void @f1() "patchable-function"="prologue-short-redirect" "frame-pointer"="all" { 38; CHECK-LABEL: _f1 39; CHECK-NEXT: ff f5 pushq %rbp 40 41; CHECK-ALIGN: .p2align 4, 0x90 42; CHECK-ALIGN: _f1: 43 44; 32: f1: 45; 32CFI-NEXT: .cfi_startproc 46; 32-NEXT: # %bb.0: 47; XCHG-NEXT: xchgw %ax, %ax # encoding: [0x66,0x90] 48; MOV-NEXT: movl %edi, %edi # encoding: [0x8b,0xff] 49; 32-NEXT: pushl %ebp 50 51; 64: f1: 52; 64-NEXT: .seh_proc f1 53; 64-NEXT: # %bb.0: 54; 64-NEXT: pushq %rbp 55 56 ret void 57} 58 59define void @f2() "patchable-function"="prologue-short-redirect" { 60; CHECK-LABEL: _f2 61; CHECK-NEXT: 48 81 ec a8 00 00 00 subq $168, %rsp 62 63; CHECK-ALIGN: .p2align 4, 0x90 64; CHECK-ALIGN: _f2: 65 66; 32: f2: 67; 32CFI-NEXT: .cfi_startproc 68; 32-NEXT: # %bb.0: 69; XCHG-NEXT: xchgw %ax, %ax # encoding: [0x66,0x90] 70; MOV-NEXT: movl %edi, %edi # encoding: [0x8b,0xff] 71; 32-NEXT: pushl %ebp 72 73; 64: f2: 74; 64-NEXT: .seh_proc f2 75; 64-NEXT: # %bb.0: 76; 64-NEXT: subq $200, %rsp 77 78 %ptr = alloca i64, i32 20 79 call void @callee(ptr %ptr) 80 ret void 81} 82 83define void @f3() "patchable-function"="prologue-short-redirect" optsize { 84; CHECK-LABEL: _f3 85; CHECK-NEXT: 66 90 nop 86 87; CHECK-ALIGN: .p2align 4, 0x90 88; CHECK-ALIGN: _f3: 89 90; 32: f3: 91; 32CFI-NEXT: .cfi_startproc 92; 32-NEXT: # %bb.0: 93; XCHG-NEXT: xchgw %ax, %ax 94; MOV-NEXT: movl %edi, %edi 95; 32-NEXT: retl 96 97; 64: f3: 98; 64-NEXT: # %bb.0: 99; 64-NEXT: xchgw %ax, %ax 100; 64-NEXT: retq 101 102 ret void 103} 104 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 107; patchable one. 108; CHECK-LABEL: f4{{>?}}: 109; CHECK-NEXT: 8b 0c 37 movl (%rdi,%rsi), %ecx 110; 32: f4: 111; 32CFI-NEXT: .cfi_startproc 112; 32-NEXT: # %bb.0: 113; XCHG-NEXT: xchgw %ax, %ax 114; MOV-NEXT: movl %edi, %edi 115; 32-NEXT: pushl %ebx 116 117; 64: f4: 118; 64-NEXT: # %bb.0: 119; 64-NOT: xchgw %ax, %ax 120 121define i32 @f4(ptr %arg1, i64 %arg2, i32 %arg3) "patchable-function"="prologue-short-redirect" { 122bb: 123 %tmp10 = getelementptr i8, ptr %arg1, i64 %arg2 124 %tmp12 = load i32, ptr %tmp10, align 4 125 fence acquire 126 %tmp13 = add i32 %tmp12, %arg3 127 %tmp14 = cmpxchg ptr %tmp10, i32 %tmp12, i32 %tmp13 seq_cst monotonic 128 %tmp15 = extractvalue { i32, i1 } %tmp14, 1 129 br i1 %tmp15, label %bb21, label %bb16 130 131bb16: 132 br label %bb21 133 134bb21: 135 %tmp22 = phi i32 [ %tmp12, %bb ], [ %arg3, %bb16 ] 136 ret i32 %tmp22 137} 138