Skip to content
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

Enable stack probes on aarch64 for LLVM 18 #118491

Merged
merged 2 commits into from
Dec 14, 2023

Conversation

cuviper
Copy link
Member

@cuviper cuviper commented Dec 1, 2023

I tested this on aarch64-unknown-linux-gnu with LLVM main (~18).

cc #77071, to be closed once we upgrade our LLVM submodule.

@rustbot
Copy link
Collaborator

rustbot commented Dec 1, 2023

r? @wesleywiser

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 1, 2023
@rustbot
Copy link
Collaborator

rustbot commented Dec 1, 2023

These commits modify compiler targets.
(See the Target Tier Policy.)

@rcvalle rcvalle added the PG-exploit-mitigations Project group: Exploit mitigations label Dec 1, 2023
Copy link
Member

@wesleywiser wesleywiser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't looked closely at the LLVM changes but is it possible to enable this for aarch64-pc-windows-msvc as well?

@cuviper
Copy link
Member Author

cuviper commented Dec 1, 2023

I was assuming that Windows targets would already (implicitly) be using "__chkstk" calls, like they do on i686 and x86_64, but I haven't confirmed that.

@cuviper
Copy link
Member Author

cuviper commented Dec 1, 2023

Yeah, it looks like Windows has had aarch64 probing for years:

(through the external call mandated by the platform, not inline codegen)

@bjorn3
Copy link
Member

bjorn3 commented Dec 6, 2023

Cg_clif always uses inline stack probes on aarch64. Even on Windows. Is there any documentation about why windows requires external stack probes?

@cuviper
Copy link
Member Author

cuviper commented Dec 6, 2023

I may be overstating it to call __chkstk a mandate. I know that LLVM doesn't make it optional on Windows, with an early branch for that target before it would look at the "probe-stack" attribute at all. But MSVC has the option /Gs to control when checks are emitted, which you could set to an absurdly high number to effectively disable that.

As noted there, part of the effect of that call is for stack growth. As long as that's an indirect effect -- probing the guard page to trigger growth -- then cg_clif's inline probes should be fine for that as well.

@bjorn3
Copy link
Member

bjorn3 commented Dec 6, 2023

As noted there, part of the effect of that call is for stack growth. As long as that's an indirect effect -- probing the guard page to trigger growth -- then cg_clif's inline probes should be fine for that as well.

Yeah, inline stack probing support was added to cranelift for that stack growing on windows. The way you worded it, it seemed like on windows stack probes are required to be outline stack probes.

@bors
Copy link
Contributor

bors commented Dec 7, 2023

☔ The latest upstream changes (presumably #116565) made this pull request unmergeable. Please resolve the merge conflicts.

@cuviper cuviper force-pushed the aarch64-stack-probes branch from fd00a51 to b99b5e5 Compare December 8, 2023 01:17
@@ -18,6 +18,7 @@ pub fn target() -> Target {
options: TargetOptions {
features: "+neon,+fp-armv8,+apple-a7".into(),
max_atomic_width: Some(128),
stack_probes: StackProbeType::Inline,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to gate use of StackProbeType::Inline on LLVM 18 or newer? Is this just ignored for unsupported targets on earlier versions of LLVM?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's ignored -- or rather goes unchecked and unnoticed. The other times we've concerned ourselves about the version is when we know there are bugs in the implementation.

@wesleywiser
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Dec 13, 2023

📌 Commit 233de9d has been approved by wesleywiser

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 13, 2023
@bors
Copy link
Contributor

bors commented Dec 14, 2023

⌛ Testing commit 233de9d with merge e6d1b0e...

@bors
Copy link
Contributor

bors commented Dec 14, 2023

☀️ Test successful - checks-actions
Approved by: wesleywiser
Pushing e6d1b0e to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Dec 14, 2023
@bors bors merged commit e6d1b0e into rust-lang:master Dec 14, 2023
12 checks passed
@rustbot rustbot added this to the 1.76.0 milestone Dec 14, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (e6d1b0e): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
1.6% [1.6%, 1.6%] 1
Regressions ❌
(secondary)
4.4% [4.4%, 4.4%] 1
Improvements ✅
(primary)
-0.8% [-0.8%, -0.8%] 1
Improvements ✅
(secondary)
-3.1% [-4.1%, -2.2%] 2
All ❌✅ (primary) 0.4% [-0.8%, 1.6%] 2

Cycles

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
0.7% [0.7%, 0.7%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.0% [-3.0%, -3.0%] 1
All ❌✅ (primary) 0.7% [0.7%, 0.7%] 1

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 673.133s -> 673.665s (0.08%)
Artifact size: 312.44 MiB -> 312.46 MiB (0.00%)

@cuviper cuviper deleted the aarch64-stack-probes branch December 20, 2023 00:13
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Mar 6, 2024
…, r=workingjubilee

Remove outdated footnote "missing-stack-probe" in platform-support

... after rust-lang#120055 and rust-lang#118491.

cc rust-lang#77071 (comment).
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Mar 7, 2024
Rollup merge of rust-lang#122094 - slanterns:arm-stack-probe-footnote, r=workingjubilee

Remove outdated footnote "missing-stack-probe" in platform-support

... after rust-lang#120055 and rust-lang#118491.

cc rust-lang#77071 (comment).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. PG-exploit-mitigations Project group: Exploit mitigations S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants