-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Introduce debuginfo to statements in MIR #142771
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
Open
dianqk
wants to merge
7
commits into
rust-lang:master
Choose a base branch
from
dianqk:mir-stmt-debuginfo
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
06f5a9d
mir-opt: Eliminate dead ref statements
dianqk 29357bc
codegen: Generate `dbg_value` for the ref statement
dianqk a0b4fe1
simplifycfg: Preserve debuginfos when merging bbs
dianqk ec25192
mir-opt: Eliminate trivial unnecessary storage annotations
dianqk 458ad93
mir-opt: Eliminate dead statements even if they are used by debuginfos
dianqk f8bfc83
fixup! codegen: Generate `dbg_value` for the ref statement
dianqk a4ce010
fixup! codegen: Generate `dbg_value` for the ref statement
dianqk 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -253,6 +253,51 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { | |
spill_slot | ||
} | ||
|
||
pub(crate) fn debug_new_value_to_local( | ||
&self, | ||
bx: &mut Bx, | ||
local: mir::Local, | ||
base: PlaceValue<Bx::Value>, | ||
layout: TyAndLayout<'tcx>, | ||
projection: &[mir::PlaceElem<'tcx>], | ||
) { | ||
let full_debug_info = bx.sess().opts.debuginfo == DebugInfo::Full; | ||
if !full_debug_info { | ||
return; | ||
} | ||
|
||
let vars = match &self.per_local_var_debug_info { | ||
Some(per_local) => &per_local[local], | ||
None => return, | ||
}; | ||
|
||
for var in vars.iter().cloned() { | ||
self.debug_new_value_to_local_as_var(bx, base, layout, projection, var); | ||
} | ||
} | ||
|
||
fn debug_new_value_to_local_as_var( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be inlined? This should allow to compute offsets only once outside the loop. |
||
&self, | ||
bx: &mut Bx, | ||
base: PlaceValue<Bx::Value>, | ||
layout: TyAndLayout<'tcx>, | ||
projection: &[mir::PlaceElem<'tcx>], | ||
var: PerLocalVarDebugInfo<'tcx, Bx::DIVariable>, | ||
) { | ||
let Some(dbg_var) = var.dbg_var else { return }; | ||
let Some(dbg_loc) = self.dbg_loc(var.source_info) else { return }; | ||
let DebugInfoOffset { direct_offset, indirect_offsets, result: _ } = | ||
calculate_debuginfo_offset(bx, projection, layout); | ||
bx.dbg_var_value( | ||
dbg_var, | ||
dbg_loc, | ||
base.llval, | ||
direct_offset, | ||
&indirect_offsets, | ||
var.fragment, | ||
); | ||
} | ||
|
||
/// Apply debuginfo and/or name, after creating the `alloca` for a local, | ||
/// or initializing the local with an operand (whichever applies). | ||
pub(crate) fn debug_introduce_local(&self, bx: &mut Bx, local: mir::Local) { | ||
|
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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.
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.
Would it be possible to move all debuginfo to
DbgValue
?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.
I'm not sure, but it's very complicated. It might be better to let LLVM do it.
LLVM might also preserve the declare: https://rust.godbolt.org/z/GKWYeT7rK, but this seems like it could be dropped.