-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Cranelift: add alignment parameter to stack slots. #8635
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6d96151
Cranelift: add alignment parameter to stack slots.
cfallin 7c1c9a2
Apply suggestions from code review
cfallin 438096c
Update filetest.
cfallin 3377cb0
Update alignment to ValRaw vector.
cfallin 6aeb4d5
Fix printer test.
cfallin 1370b71
cargo-fmt from suggestion update.
cfallin 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 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
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,61 @@ | ||
test compile precise-output | ||
target x86_64 | ||
|
||
function %f0(i64 vmctx) -> i64, i64, i64, i64 { | ||
gv0 = vmctx | ||
stack_limit = gv0 | ||
ss0 = explicit_slot 8, align=16 | ||
ss1 = explicit_slot 8, align=16 | ||
ss2 = explicit_slot 4 | ||
ss3 = explicit_slot 4 | ||
|
||
block0(v0: i64): | ||
v1 = stack_addr.i64 ss0 | ||
v2 = stack_addr.i64 ss1 | ||
v3 = stack_addr.i64 ss2 | ||
v4 = stack_addr.i64 ss3 | ||
return v1, v2, v3, v4 | ||
} | ||
|
||
; VCode: | ||
; pushq %rbp | ||
; movq %rsp, %rbp | ||
; movq %rdi, %r10 | ||
; addq %r10, $48, %r10 | ||
; cmpq %rsp, %r10 | ||
; jnbe #trap=stk_ovf | ||
; subq %rsp, $48, %rsp | ||
; block0: | ||
; lea rsp(0 + virtual offset), %rax | ||
; lea rsp(16 + virtual offset), %rdx | ||
; lea rsp(32 + virtual offset), %r8 | ||
; lea rsp(40 + virtual offset), %r9 | ||
; movq %r8, 0(%rsi) | ||
; movq %r9, 8(%rsi) | ||
; addq %rsp, $48, %rsp | ||
; movq %rbp, %rsp | ||
; popq %rbp | ||
; ret | ||
; | ||
; Disassembled: | ||
; block0: ; offset 0x0 | ||
; pushq %rbp | ||
; movq %rsp, %rbp | ||
; movq %rdi, %r10 | ||
; addq $0x30, %r10 | ||
; cmpq %rsp, %r10 | ||
; ja 0x3b | ||
; subq $0x30, %rsp | ||
; block1: ; offset 0x18 | ||
; leaq (%rsp), %rax | ||
; leaq 0x10(%rsp), %rdx | ||
; leaq 0x20(%rsp), %r8 | ||
; leaq 0x28(%rsp), %r9 | ||
; movq %r8, (%rsi) | ||
; movq %r9, 8(%rsi) | ||
; addq $0x30, %rsp | ||
; movq %rbp, %rsp | ||
; popq %rbp | ||
; retq | ||
; ud2 ; trap: stk_ovf | ||
|
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
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.
If the alignment is bigger than the ABI stack alignment it would be necessary to adjust the stack pointer to correctly align it. This is missing here. Rust allows arbitrary power of two alignments for stack variables, even something crazy like a 1GB alignment. More realistically though, cache line alignment is used by crates like rayon for performance reasons. Without correctly aligning, rustc will trigger a debug assertion in some cases like for the aforementioned rayon crate.
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.
Ah, yes, that's a good point -- to summarize: alignment of offset within the stack frame to alignment A does not imply alignment to A overall, because SP itself may be aligned less (e.g. only to A/4).
I don't have time to work further on this at the moment, but I'd be happy to review a PR that addressed this.