-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[AArch64] Stop reserved registers from being saved in prolog/epilog #138448
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
96e5548
[AArch64] Stop manually reserved registers from being saved in prolog…
yasuna-oribe 61aca3c
Merge branch 'main' into main
yasuna-oribe 73ceb48
fixup! [AArch64] Stop manually reserved registers from being saved in…
yasuna-oribe f18cae5
Merge branch 'main' into main
yasuna-oribe f0e6095
fixup! [AArch64] Stop manually reserved registers from being saved in…
yasuna-oribe 4ffa297
Merge branch 'main' into main
yasuna-oribe 41a6019
fixup! [AArch64] Stop manually reserved registers from being saved in…
yasuna-oribe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,43 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py | ||
; RUN: llc < %s -mtriple=aarch64-unknown-linux-gnu -reserve-regs-for-regalloc=LR,FP,X28,X27,X26,X25,X24,X23,X22,X21,X20,X19,X18,X17,X16,X15,X14,X13,X12,X11,X10,X9,X8,X7,X6,X5,X4 | FileCheck %s | ||
; RUN: llc < %s -mtriple=aarch64-unknown-linux-gnu -reserve-regs-for-regalloc=X30,X29,X28,X27,X26,X25,X24,X23,X22,X21,X20,X19,X18,X17,X16,X15,X14,X13,X12,X11,X10,X9,X8,X7,X6,X5,X4 | FileCheck %s | ||
|
||
; LR, FP, X30 and X29 should be correctly recognized and not used. | ||
|
||
define void @foo(i64 %v1, i64 %v2, ptr %ptr) { | ||
; CHECK-LABEL: foo: | ||
; CHECK: // %bb.0: | ||
; CHECK-NEXT: sub sp, sp, #16 | ||
; CHECK-NEXT: .cfi_def_cfa_offset 16 | ||
; CHECK-NEXT: add x3, x0, x1 | ||
; CHECK-NEXT: str x3, [sp, #8] // 8-byte Folded Spill | ||
; CHECK-NEXT: str x3, [x2, #8] | ||
; CHECK-NEXT: ldr x3, [x2, #16] | ||
; CHECK-NEXT: add x3, x0, x3 | ||
; CHECK-NEXT: sub x3, x3, x1 | ||
; CHECK-NEXT: str x3, [x2, #16] | ||
; CHECK-NEXT: ldr x3, [sp, #8] // 8-byte Folded Reload | ||
; CHECK-NEXT: str x3, [x2, #24] | ||
; CHECK-NEXT: str x0, [x2, #32] | ||
; CHECK-NEXT: str x1, [x2, #40] | ||
; CHECK-NEXT: add sp, sp, #16 | ||
; CHECK-NEXT: ret | ||
%v3 = add i64 %v1, %v2 | ||
%p1 = getelementptr i64, ptr %ptr, i64 1 | ||
store volatile i64 %v3, ptr %p1, align 8 | ||
|
||
%p2 = getelementptr i64, ptr %ptr, i64 2 | ||
%v4 = load volatile i64, ptr %p2, align 8 | ||
%v5 = add i64 %v1, %v4 | ||
%v6 = sub i64 %v5, %v2 | ||
store volatile i64 %v6, ptr %p2, align 8 | ||
|
||
%p3 = getelementptr i64, ptr %ptr, i64 3 | ||
store volatile i64 %v3, ptr %p3, align 8 | ||
|
||
%p4 = getelementptr i64, ptr %ptr, i64 4 | ||
store volatile i64 %v1, ptr %p4, align 8 | ||
%p5 = getelementptr i64, ptr %ptr, i64 5 | ||
store volatile i64 %v2, ptr %p5, align 8 | ||
ret void | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This recomputes the entire BitVector every time we query for a callee-saved register? That seems expensive.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was fully aware of this when writing the function, but take a look at line 431,
// FIXME: avoid re-calculating this every time.
for getStrictlyReservedRegs, a way more expensive function returning a BitVector of registers, that is also called in the same loop. I've followed the golden rule and followed existing code.The loop in determineCalleeSaves only loops over callee-saved regs (CSRegs) anyway, and if you insist, I can save the BitVector at the top of the function and lookup from it, but it will be inconsistent with the rest of the function that uses isReserved directly (which calls getReservedRegs which in turn calls getStrictlyReservedRegs), breaking the golden rule, or require me to overhaul things out of my scope, and I doubt it will make a difference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess given the actual number of GPRs on AArch64 is a fixed number, it's not a big deal to loop 1000 times.