Skip to content

Attribute to control frame pointers #872

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

Closed
1 of 3 tasks
tgross35 opened this issue May 7, 2025 · 3 comments
Closed
1 of 3 tasks

Attribute to control frame pointers #872

tgross35 opened this issue May 7, 2025 · 3 comments
Labels
major-change A proposal to make a major change to rustc T-compiler Add this label so rfcbot knows to poll the compiler team

Comments

@tgross35
Copy link

tgross35 commented May 7, 2025

Background

The standard library is distributed with -Cforce-frame-pointers=true, which was added in rust-lang/rust#122646 to aid profiling. This is a net positive but there are some cases where having frame pointers doesn't make as much sense. compiler_builtins has a handful of small functions that can't be inlined because they must be a callable symbol, but are tiny enough that updating the frame pointer contributes to a significant portion of the instruction count.

The most notable example is our current fma implementation with runtime feature detection on x86. This would usually be three instructions, but tracking the frame pointer triples this count (involves two noninlineable symbols).

More background: https://rust-lang.zulipchat.com/#narrow/channel/219381-t-libs/topic/significant.20mul_add.20perf.20regression.20since.20nightly-2025-03-06/with/516632450

Proposal

LLVM's frame-pointer attribute is function-level, so we can add an unstable attribute to match them.

#![feature(frame_pointer_attribute)]

#[frame_pointer(none)]     // "frame-pointer"="none"
#[frame_pointer(reserved)] // "frame-pointer"="reserved"
#[frame_pointer(non_leaf)] // "frame-pointer"="non-leaf"
#[frame_pointer(all)]      // "frame-pointer"="all"

These will override the -Cforce-frame-pointers setting for that crate.

LLVM docs: https://llvm.org/docs/LangRef.html#function-attributes.

Mentors or Reviewers

If you have a reviewer or mentor in mind for this work, mention them
here. You can put your own name here if you are planning to mentor the
work.

Process

The main points of the Major Change Process are as follows:

  • File an issue describing the proposal.
  • A compiler team member or contributor who is knowledgeable in the area can second by writing @rustbot second.
    • Finding a "second" suffices for internal changes. If however, you are proposing a new public-facing feature, such as a -C flag, then full team check-off is required.
    • Compiler team members can initiate a check-off via @rfcbot fcp merge on either the MCP or the PR.
  • Once an MCP is seconded, the Final Comment Period begins. If no objections are raised after 10 days, the MCP is considered approved.

You can read more about Major Change Proposals on forge.

@tgross35 tgross35 added T-compiler Add this label so rfcbot knows to poll the compiler team major-change A proposal to make a major change to rustc labels May 7, 2025
@rustbot
Copy link
Collaborator

rustbot commented May 7, 2025

Important

This issue is not meant to be used for technical discussion. There is a Zulip stream for that.
Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.

Concerns or objections can formally be registered here by adding a comment.

@rfcbot concern reason-for-concern
<description of the concern>

Concerns can be lifted with:

@rfcbot resolve reason-for-concern

See documentation at https://forge.rust-lang.org

cc @rust-lang/compiler

@workingjubilee
Copy link
Member

workingjubilee commented May 7, 2025

I would object: This MCP would introduce a specific hammer in order to tap a specific nail in, but does not evaluate our existing hammers for fitness. Are they too oddly-shaped? So it needs evaluation of alternatives like compiling std with -Zunstable-options -Cforce-frame-pointers=non-leaf to determine whether this is required or beneficial or what.

@tgross35
Copy link
Author

tgross35 commented May 7, 2025

From discussion on Zulip it sounds like there is likely a better path here.

@tgross35 tgross35 closed this as completed May 7, 2025
@apiraino apiraino removed the to-announce Announce this issue on triage meeting label May 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
major-change A proposal to make a major change to rustc T-compiler Add this label so rfcbot knows to poll the compiler team
Projects
None yet
Development

No branches or pull requests

4 participants