Sanjoy Das | c0441c2 | 2016-04-19 05:24:47 +0000 | [diff] [blame] | 1 | ; RUN: llc -filetype=obj -o - -mtriple=x86_64-apple-macosx < %s | llvm-objdump -triple x86_64-apple-macosx -disassemble - | FileCheck %s |
| 2 | ; RUN: llc -mtriple=x86_64-apple-macosx < %s | FileCheck %s --check-prefix=CHECK-ALIGN |
| 3 | |
| 4 | declare void @callee(i64*) |
| 5 | |
| 6 | define void @f0() "patchable-function"="prologue-short-redirect" { |
| 7 | ; CHECK-LABEL: _f0: |
| 8 | ; CHECK-NEXT: 66 90 nop |
| 9 | |
| 10 | ; CHECK-ALIGN: .p2align 4, 0x90 |
| 11 | ; CHECK-ALIGN: _f0: |
| 12 | |
| 13 | ret void |
| 14 | } |
| 15 | |
| 16 | define void @f1() "patchable-function"="prologue-short-redirect" "no-frame-pointer-elim"="true" { |
| 17 | ; CHECK-LABEL: _f1 |
| 18 | ; CHECK-NEXT: ff f5 pushq %rbp |
| 19 | |
| 20 | ; CHECK-ALIGN: .p2align 4, 0x90 |
| 21 | ; CHECK-ALIGN: _f1: |
| 22 | ret void |
| 23 | } |
| 24 | |
| 25 | define void @f2() "patchable-function"="prologue-short-redirect" { |
| 26 | ; CHECK-LABEL: _f2 |
| 27 | ; CHECK-NEXT: 48 81 ec a8 00 00 00 subq $168, %rsp |
| 28 | |
| 29 | ; CHECK-ALIGN: .p2align 4, 0x90 |
| 30 | ; CHECK-ALIGN: _f2: |
| 31 | %ptr = alloca i64, i32 20 |
| 32 | call void @callee(i64* %ptr) |
| 33 | ret void |
| 34 | } |
| 35 | |
| 36 | define void @f3() "patchable-function"="prologue-short-redirect" optsize { |
| 37 | ; CHECK-LABEL: _f3 |
| 38 | ; CHECK-NEXT: 66 90 nop |
| 39 | |
| 40 | ; CHECK-ALIGN: .p2align 4, 0x90 |
| 41 | ; CHECK-ALIGN: _f3: |
| 42 | ret void |
| 43 | } |
Matthias Braun | 512424f | 2016-07-13 16:37:29 +0000 | [diff] [blame] | 44 | |
| 45 | ; This testcase happens to produce a KILL instruction at the beginning of the |
| 46 | ; first basic block. In this case the 2nd instruction should be turned into a |
| 47 | ; patchable one. |
| 48 | ; CHECK-LABEL: f4: |
| 49 | ; CHECK-NEXT: 8b 0c 37 movl (%rdi,%rsi), %ecx |
| 50 | define i32 @f4(i8* %arg1, i64 %arg2, i32 %arg3) "patchable-function"="prologue-short-redirect" { |
| 51 | bb: |
| 52 | %tmp10 = getelementptr i8, i8* %arg1, i64 %arg2 |
| 53 | %tmp11 = bitcast i8* %tmp10 to i32* |
| 54 | %tmp12 = load i32, i32* %tmp11, align 4 |
| 55 | fence acquire |
| 56 | %tmp13 = add i32 %tmp12, %arg3 |
| 57 | %tmp14 = cmpxchg i32* %tmp11, i32 %tmp12, i32 %tmp13 seq_cst monotonic |
| 58 | %tmp15 = extractvalue { i32, i1 } %tmp14, 1 |
| 59 | br i1 %tmp15, label %bb21, label %bb16 |
| 60 | |
| 61 | bb16: |
| 62 | br label %bb21 |
| 63 | |
| 64 | bb21: |
| 65 | %tmp22 = phi i32 [ %tmp12, %bb ], [ %arg3, %bb16 ] |
| 66 | ret i32 %tmp22 |
| 67 | } |