-
Notifications
You must be signed in to change notification settings - Fork 1.5k
cranelift: Implement TLS on aarch64 Mach-O (Apple Silicon) #5434
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: Implement TLS on aarch64 Mach-O (Apple Silicon) #5434
Conversation
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.
Nicely done! The register handling and regalloc metadata for the new pseudoinstruction is the trickiest part, and that looks basically correct here. There are a few things that could actually be omitted in the call (but no harm when present). A few nits below but otherwise LGTM.
It looks like the cargo-deny
failure is because two versions of object
are present in the deps; could you find where object
0.29 is still in use and resolve that? Then the upgrade to 0.30 is causing the cargo-vet
failure. Our policy is to have a core committer vet upgrades, so I'll take a look at the 0.29 -> 0.30 diff and push a "vetted by" commit to this PR if it looks OK.
Thanks again!
cranelift/codegen/src/binemit/mod.rs
Outdated
@@ -56,6 +56,14 @@ pub enum Reloc { | |||
/// Mach-O x86_64 32 bit signed PC relative offset to a `__thread_vars` entry. | |||
MachOX86_64Tlv, | |||
|
|||
/// Mach-O AAarch64 TLS |
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.
s/AAarch64/Aarch64/ (and in comment below too)
Inst::CallInd { | ||
info: crate::isa::Box::new(CallIndInfo { | ||
rn: rtmp.to_reg(), | ||
uses: smallvec![CallArgPair { |
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.
uses
and defs
and clobbers
can all be empty here, as this emission happens after regalloc runs so we don't need any of this metadata.
I did an audit of |
Not missing anything AFAIK. Someone just has to bite the bullet and review the new deps and delta for upgraded deps if Firefox folks haven't already done so. |
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.
One more nit below; but otherwise LGTM, modulo the cargo-vet TODO. One of us will try to get to this soon...
@@ -124,7 +124,7 @@ fn count_zero_half_words(mut value: u64, num_half_words: u8) -> usize { | |||
fn inst_size_test() { | |||
// This test will help with unintentionally growing the size | |||
// of the Inst enum. | |||
assert_eq!(32, std::mem::size_of::<Inst>()); | |||
assert_eq!(40, std::mem::size_of::<Inst>()); |
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.
We probably don't want to increase the size of Inst
if we can help it at all -- the point of this test is to guard against perf regressions. Can we find a way to remove a field or, failing that, box the contents of the inst? Two options come to mind:
- (Maybe preferred) eliminate
rtmp
, and usex1
explicitly instead. This is part of the clobber-set of the call already, so it should be legal to use it to hold the address of the called function. - (Alternately) create a struct and hold a
Box
in the inst, taking only 8 bytes
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, I wasn't sure that it was okay to use x1
, but your explanation makes sense (and helped clear up my confusion) - thanks!
Just pushed a commit to make that change (and reverted the change to the size test as well)
89279b4
to
013217b
Compare
Since there is no review process for an Rust update, all of EDIT: The reviews were already done in #5550, which will probably land soon. |
@nathanwhit would you be willing to rebase this? I think we should be close to able to merge this with vets that have happened in the meantime... |
013217b
to
1d6a9b0
Compare
Done! |
Ah, the merged cargo-vet review for the object crate is for 0.30.1, not 0.30. If you bump to that version, I believe the cargo-vet check will pass. In addition, I'm sorry that this PR is taking a long time to merge. We're still working out our processes for supply-chain review. We're learning though! |
Now object has been updated in master. I think with an rebase the build should succeed. |
Rebased this locally onto main and all tests pass (except for a filetest needing bless due to #5780). Any updates on this? |
- `Aarch64` instead of `AArch64` in comments - Remove unnecessary guard in tls_value lowering - Remove unnecessary regalloc metadata in emission
- Instead of passing in a temporary register to use when emitting the TLS code, just use `x1`, as it's already in the clobber set. This also keeps the size of `aarch64::inst::Inst` at 32 bytes. - Update filetest accordingly
1d6a9b0
to
e5aa875
Compare
Ah sorry, completely forgot this hadn't been merged. Thanks for the reminder! I've rebased on top of main so it should be good to go now |
Fixes #5433.
This PR implements support for TLS on aarch64 Mach-O (i.e. Apple silicon). This also includes an update to
object
as this PR depends on a fix released inobject 0.30
.For testing, I've added a filetest similar to the existing test for aarch64 ELF. I wasn't sure if I should add an emit test as well, since there doesn't seem to be one for TLS on aarch64 ELF. I've also tested these changes on a local branch of cg_clif, and it passes the TLS tests there.