Eric Christopher | cee313d | 2019-04-17 04:52:47 +0000 | [diff] [blame^] | 1 | ; RUN: opt < %s -S -partial-inliner -skip-partial-inlining-cost-analysis=true | FileCheck %s |
| 2 | |
| 3 | |
| 4 | define i32 @callee_most(i32 %v) unnamed_addr #0 #1 { |
| 5 | entry: |
| 6 | %cmp = icmp sgt i32 %v, 2000 |
| 7 | br i1 %cmp, label %if.then, label %if.end |
| 8 | |
| 9 | if.then: |
| 10 | br label %if.then2 |
| 11 | |
| 12 | if.then2: |
| 13 | %sub = sub i32 %v, 10 |
| 14 | br label %if.end |
| 15 | |
| 16 | if.end: |
| 17 | %v2 = phi i32 [ %v, %entry ], [ %sub, %if.then2 ] |
| 18 | %add = add nsw i32 %v2, 200 |
| 19 | ret i32 %add |
| 20 | } |
| 21 | |
| 22 | define i32 @callee_noinline(i32 %v) optnone noinline { |
| 23 | entry: |
| 24 | %cmp = icmp sgt i32 %v, 2000 |
| 25 | br i1 %cmp, label %if.then, label %if.end |
| 26 | |
| 27 | if.then: |
| 28 | br label %if.then2 |
| 29 | |
| 30 | if.then2: |
| 31 | %sub = sub i32 %v, 10 |
| 32 | br label %if.end |
| 33 | |
| 34 | if.end: |
| 35 | %v2 = phi i32 [ %v, %entry ], [ %sub, %if.then2 ] |
| 36 | %add = add nsw i32 %v2, 200 |
| 37 | ret i32 %add |
| 38 | } |
| 39 | |
| 40 | define i32 @callee_writeonly(i32 %v) writeonly { |
| 41 | entry: |
| 42 | %cmp = icmp sgt i32 %v, 2000 |
| 43 | br i1 %cmp, label %if.then, label %if.end |
| 44 | |
| 45 | if.then: |
| 46 | br label %if.then2 |
| 47 | |
| 48 | if.then2: |
| 49 | %sub = sub i32 %v, 10 |
| 50 | br label %if.end |
| 51 | |
| 52 | if.end: |
| 53 | %v2 = phi i32 [ %v, %entry ], [ %sub, %if.then2 ] |
| 54 | %add = add nsw i32 %v2, 200 |
| 55 | ret i32 %add |
| 56 | } |
| 57 | ; CHECK-LABEL: @caller |
| 58 | ; CHECK: call void @callee_most.2.if.then(i32 %v |
| 59 | ; CHECK: call i32 @callee_noinline(i32 %v) |
| 60 | ; CHECK: call void @callee_writeonly.1.if.then(i32 %v |
| 61 | define i32 @caller(i32 %v) { |
| 62 | entry: |
| 63 | %c1 = call i32 @callee_most(i32 %v) |
| 64 | %c2 = call i32 @callee_noinline(i32 %v) |
| 65 | %c3 = call i32 @callee_writeonly(i32 %v) |
| 66 | ret i32 %c3 |
| 67 | } |
| 68 | |
| 69 | ; CHECK: define internal void @callee_writeonly.1.if.then(i32 %v, i32* %sub.out) { |
| 70 | ; CHECK: define internal void @callee_most.2.if.then(i32 %v, i32* %sub.out) [[FN_ATTRS:#[0-9]+]] |
| 71 | |
| 72 | ; attributes to preserve |
| 73 | attributes #0 = { |
| 74 | inlinehint minsize noduplicate noimplicitfloat norecurse noredzone nounwind |
| 75 | nonlazybind optsize safestack sanitize_address sanitize_hwaddress sanitize_memory |
| 76 | sanitize_thread ssp sspreq sspstrong strictfp uwtable "foo"="bar" |
| 77 | "patchable-function"="prologue-short-redirect" "probe-stack"="_foo_guard" "stack-probe-size"="4096" } |
| 78 | |
| 79 | ; CHECK: attributes [[FN_ATTRS]] = { inlinehint minsize noduplicate noimplicitfloat norecurse noredzone nounwind nonlazybind optsize safestack sanitize_address sanitize_hwaddress sanitize_memory sanitize_thread ssp sspreq sspstrong strictfp uwtable "foo"="bar" "patchable-function"="prologue-short-redirect" "probe-stack"="_foo_guard" "stack-probe-size"="4096" } |
| 80 | |
| 81 | ; attributes to drop |
| 82 | attributes #1 = { |
| 83 | alignstack=16 convergent inaccessiblememonly inaccessiblemem_or_argmemonly naked |
| 84 | noreturn readonly argmemonly returns_twice speculatable "thunk" |
| 85 | } |