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

rustc_codegen_ssa: only "spill" SSA-like values to the stack for debuginfo. #68961

Merged
merged 2 commits into from
Feb 11, 2020

Conversation

eddyb
Copy link
Member

@eddyb eddyb commented Feb 8, 2020

This is an implementation of the idea described in #68817 (comment).

In short, instead of debuginfo forcing otherwise-SSA-like MIR locals into allocas, and requiring a load for each use (or two, for scalar pairs), the alloca is now only used for attaching debuginfo with llvm.dbg.declare: the OperandRef is stored to the alloca, but never loaded from it.

Outside of debug_introduce_local, nothing cares about the debuginfo-only alloca, and instead works with OperandRef the same as MIR locals without debuginfo before this PR.

This should have some of the benefits of llvm.dbg.value, while working today.

cc @nagisa @nikomatsakis

@rust-highfive
Copy link
Collaborator

r? @matthewjasper

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

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 8, 2020
@eddyb
Copy link
Member Author

eddyb commented Feb 8, 2020

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion

@bors
Copy link
Contributor

bors commented Feb 8, 2020

⌛ Trying commit e34b66075282e9a3d29da0a15b83a1744b93ff3d with merge 9366841f40c1b378839d842909d2708a1e361923...

@bors
Copy link
Contributor

bors commented Feb 8, 2020

☀️ Try build successful - checks-azure
Build commit: 9366841f40c1b378839d842909d2708a1e361923 (9366841f40c1b378839d842909d2708a1e361923)

@Mark-Simulacrum
Copy link
Member

@rust-timer build 9366841f40c1b378839d842909d2708a1e361923

@rust-timer
Copy link
Collaborator

Queued 9366841f40c1b378839d842909d2708a1e361923 with parent 85ffd44, future comparison URL.

bx.set_var_name(spill_slot.llval, &(name + ".dbg.spill"));
}
operand.val.store(bx, spill_slot);
spill_slot
Copy link
Member

Choose a reason for hiding this comment

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

Is this code triggered anywhere? Do we have a test for related behaviours? In particular that the value and name as seen by debugger is right and remains in scope for as long as necessary (i.e. the problem that appears to be preventing our use to llvm-dbg.value)

Might be worth adding a couple now if they don’t yet exist so that we catch issues when we move to llvm.dbg.value.

Copy link
Member Author

Choose a reason for hiding this comment

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

Most of the debuginfo tests fail with llvm.dbg.value, which is how I found all the issues with it.

A common pattern with debuginfo tests is that they breakpoint at the end of a function, so all the variables are as close to the end of their scope as possible, stressing even llvm.dbg.value+inline asm (which only gives you the value if you breakpoint earlier).

@nagisa
Copy link
Member

nagisa commented Feb 8, 2020

overall r=me.

@rust-timer
Copy link
Collaborator

Finished benchmarking try commit 9366841f40c1b378839d842909d2708a1e361923, comparison URL.

@eddyb

This comment has been minimized.

@bors

This comment has been minimized.

@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 Feb 9, 2020
@eddyb

This comment has been minimized.

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Feb 9, 2020
@eddyb
Copy link
Member Author

eddyb commented Feb 9, 2020

@bors r=nagisa

@bors
Copy link
Contributor

bors commented Feb 9, 2020

📌 Commit 1a8f5ef has been approved by nagisa

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 9, 2020
@matthewjasper matthewjasper assigned nagisa and unassigned matthewjasper Feb 9, 2020
@eddyb
Copy link
Member Author

eddyb commented Feb 9, 2020

@bors rollup=never (suggested by @hanna-kruppe in case perf results change, but I also want to run debug-mode lolbench after it's merged)

@Dylan-DPC-zz
Copy link

@bors p=1

@bors
Copy link
Contributor

bors commented Feb 11, 2020

⌛ Testing commit 1a8f5ef with merge b6690a8...

bors added a commit that referenced this pull request Feb 11, 2020
rustc_codegen_ssa: only "spill" SSA-like values to the stack for debuginfo.

This is an implementation of the idea described in #68817 (comment).

In short, instead of debuginfo forcing otherwise-SSA-like MIR locals into `alloca`s, and requiring a `load` for each use (or two, for scalar pairs), the `alloca` is now *only* used for attaching debuginfo with `llvm.dbg.declare`: the `OperandRef` is stored to the `alloca`, but *never loaded* from it.

Outside of `debug_introduce_local`, nothing cares about the debuginfo-only `alloca`, and instead works with `OperandRef` the same as MIR locals without debuginfo before this PR.

This should have some of the benefits of `llvm.dbg.value`, while working today.

cc @nagisa @nikomatsakis
@bors
Copy link
Contributor

bors commented Feb 11, 2020

☀️ Test successful - checks-azure
Approved by: nagisa
Pushing b6690a8 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Feb 11, 2020
@bors bors merged commit 1a8f5ef into rust-lang:master Feb 11, 2020
@eddyb eddyb deleted the dbg-stack-dunk branch February 11, 2020 11:48
@eddyb
Copy link
Member Author

eddyb commented Feb 12, 2020

FWIW, this is the comparison for the actual merged build (dc4242d...b6690a8).

Doesn't really look any different from the PR run, which is nice.
I need to use these to do a debug-mode lolbench run, but it might be tricky.
The goal is to show that runtime performance in debug mode improved (while staying debuggable).

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. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants