-
Notifications
You must be signed in to change notification settings - Fork 12.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MachineOutliner] Add "thunk" outlining for AArch64.
When we're outlining a sequence that ends in a call, we can save up to three instructions in the outlined function by turning the call into a tail-call. I refer to this as thunk outlining because the resulting outlined function looks like a thunk; suggestions welcome for a better name. In addition to making the outlined function shorter, thunk outlining allows outlining calls which would otherwise be illegal to outline: we don't need to save/restore LR, so we don't need to prove anything about the stack access patterns of the callee. To make this work effectively, I also added MachineOutlinerInstrType::LegalTerminator to the generic MachineOutliner code; this allows treating an arbitrary instruction as a terminator in the suffix tree. Differential Revision: https://reviews.llvm.org/D47173 llvm-svn: 333015
- Loading branch information
Eli Friedman
committed
May 22, 2018
1 parent
34c8c0d
commit 042dc9e
Showing
5 changed files
with
144 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py | ||
| ; RUN: llc < %s -enable-machine-outliner -verify-machineinstrs | FileCheck %s | ||
|
|
||
| target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" | ||
| target triple = "aarch64-pc-linux-gnu" | ||
|
|
||
| declare i32 @thunk_called_fn(i32, i32, i32, i32) | ||
|
|
||
| define i32 @a() { | ||
| ; CHECK-LABEL: a: | ||
| ; CHECK: // %bb.0: // %entry | ||
| ; CHECK-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill | ||
| ; CHECK-NEXT: .cfi_def_cfa_offset 16 | ||
| ; CHECK-NEXT: .cfi_offset w30, -16 | ||
| ; CHECK-NEXT: bl OUTLINED_FUNCTION_0 | ||
| ; CHECK-NEXT: add w0, w0, #8 // =8 | ||
| ; CHECK-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload | ||
| ; CHECK-NEXT: ret | ||
| entry: | ||
| %call = tail call i32 @thunk_called_fn(i32 1, i32 2, i32 3, i32 4) | ||
| %cx = add i32 %call, 8 | ||
| ret i32 %cx | ||
| } | ||
|
|
||
| define i32 @b() { | ||
| ; CHECK-LABEL: b: | ||
| ; CHECK: // %bb.0: // %entry | ||
| ; CHECK-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill | ||
| ; CHECK-NEXT: .cfi_def_cfa_offset 16 | ||
| ; CHECK-NEXT: .cfi_offset w30, -16 | ||
| ; CHECK-NEXT: bl OUTLINED_FUNCTION_0 | ||
| ; CHECK-NEXT: add w0, w0, #88 // =88 | ||
| ; CHECK-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload | ||
| ; CHECK-NEXT: ret | ||
| entry: | ||
| %call = tail call i32 @thunk_called_fn(i32 1, i32 2, i32 3, i32 4) | ||
| %cx = add i32 %call, 88 | ||
| ret i32 %cx | ||
| } | ||
|
|
||
| ; CHECK-LABEL: OUTLINED_FUNCTION_0: | ||
| ; CHECK: // %bb.0: | ||
| ; CHECK-NEXT: orr w0, wzr, #0x1 | ||
| ; CHECK-NEXT: orr w1, wzr, #0x2 | ||
| ; CHECK-NEXT: orr w2, wzr, #0x3 | ||
| ; CHECK-NEXT: orr w3, wzr, #0x4 | ||
| ; CHECK-NEXT: b thunk_called_fn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters