Skip to content

Commit d2d2b28

Browse files
committed
Auto merge of #102570 - cjgillot:deagg-debuginfo, r=oli-obk
Perform simple scalar replacement of aggregates (SROA) MIR opt This is a re-open of rust-lang/rust#85796 I copied the debuginfo implementation (first commit) from `@eddyb's` own SROA PR. This pass replaces plain field accesses by simple locals when possible. To be eligible, the replaced locals: - must not be enums or unions; - must not be used whole; - must not have their address taken. The storage and deinit statements are duplicated on each created local. cc `@tmiasko` who reviewed the former version of this PR.
2 parents eb0bc47 + af8682b commit d2d2b28

File tree

1 file changed

+49
-8
lines changed

1 file changed

+49
-8
lines changed

src/debuginfo.rs

+49-8
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,25 @@ use rustc_codegen_ssa::traits::{DebugInfoBuilderMethods, DebugInfoMethods};
44
use rustc_middle::mir;
55
use rustc_middle::ty::{Instance, PolyExistentialTraitRef, Ty};
66
use rustc_span::{SourceFile, Span, Symbol};
7-
use rustc_target::abi::Size;
87
use rustc_target::abi::call::FnAbi;
8+
use rustc_target::abi::Size;
9+
use std::ops::Range;
910

1011
use crate::builder::Builder;
1112
use crate::context::CodegenCx;
1213

1314
impl<'a, 'gcc, 'tcx> DebugInfoBuilderMethods for Builder<'a, 'gcc, 'tcx> {
1415
// FIXME(eddyb) find a common convention for all of the debuginfo-related
1516
// names (choose between `dbg`, `debug`, `debuginfo`, `debug_info` etc.).
16-
fn dbg_var_addr(&mut self, _dbg_var: Self::DIVariable, _scope_metadata: Self::DIScope, _variable_alloca: Self::Value, _direct_offset: Size, _indirect_offsets: &[Size]) {
17+
fn dbg_var_addr(
18+
&mut self,
19+
_dbg_var: Self::DIVariable,
20+
_scope_metadata: Self::DIScope,
21+
_variable_alloca: Self::Value,
22+
_direct_offset: Size,
23+
_indirect_offsets: &[Size],
24+
_fragment: Option<Range<Size>>,
25+
) {
1726
unimplemented!();
1827
}
1928

@@ -31,32 +40,64 @@ impl<'a, 'gcc, 'tcx> DebugInfoBuilderMethods for Builder<'a, 'gcc, 'tcx> {
3140
}
3241

3342
impl<'gcc, 'tcx> DebugInfoMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
34-
fn create_vtable_debuginfo(&self, _ty: Ty<'tcx>, _trait_ref: Option<PolyExistentialTraitRef<'tcx>>, _vtable: Self::Value) {
43+
fn create_vtable_debuginfo(
44+
&self,
45+
_ty: Ty<'tcx>,
46+
_trait_ref: Option<PolyExistentialTraitRef<'tcx>>,
47+
_vtable: Self::Value,
48+
) {
3549
// TODO(antoyo)
3650
}
3751

38-
fn create_function_debug_context(&self, _instance: Instance<'tcx>, _fn_abi: &FnAbi<'tcx, Ty<'tcx>>, _llfn: RValue<'gcc>, _mir: &mir::Body<'tcx>) -> Option<FunctionDebugContext<Self::DIScope, Self::DILocation>> {
52+
fn create_function_debug_context(
53+
&self,
54+
_instance: Instance<'tcx>,
55+
_fn_abi: &FnAbi<'tcx, Ty<'tcx>>,
56+
_llfn: RValue<'gcc>,
57+
_mir: &mir::Body<'tcx>,
58+
) -> Option<FunctionDebugContext<Self::DIScope, Self::DILocation>> {
3959
// TODO(antoyo)
4060
None
4161
}
4262

43-
fn extend_scope_to_file(&self, _scope_metadata: Self::DIScope, _file: &SourceFile) -> Self::DIScope {
63+
fn extend_scope_to_file(
64+
&self,
65+
_scope_metadata: Self::DIScope,
66+
_file: &SourceFile,
67+
) -> Self::DIScope {
4468
unimplemented!();
4569
}
4670

4771
fn debuginfo_finalize(&self) {
4872
// TODO(antoyo)
4973
}
5074

51-
fn create_dbg_var(&self, _variable_name: Symbol, _variable_type: Ty<'tcx>, _scope_metadata: Self::DIScope, _variable_kind: VariableKind, _span: Span) -> Self::DIVariable {
75+
fn create_dbg_var(
76+
&self,
77+
_variable_name: Symbol,
78+
_variable_type: Ty<'tcx>,
79+
_scope_metadata: Self::DIScope,
80+
_variable_kind: VariableKind,
81+
_span: Span,
82+
) -> Self::DIVariable {
5283
unimplemented!();
5384
}
5485

55-
fn dbg_scope_fn(&self, _instance: Instance<'tcx>, _fn_abi: &FnAbi<'tcx, Ty<'tcx>>, _maybe_definition_llfn: Option<RValue<'gcc>>) -> Self::DIScope {
86+
fn dbg_scope_fn(
87+
&self,
88+
_instance: Instance<'tcx>,
89+
_fn_abi: &FnAbi<'tcx, Ty<'tcx>>,
90+
_maybe_definition_llfn: Option<RValue<'gcc>>,
91+
) -> Self::DIScope {
5692
unimplemented!();
5793
}
5894

59-
fn dbg_loc(&self, _scope: Self::DIScope, _inlined_at: Option<Self::DILocation>, _span: Span) -> Self::DILocation {
95+
fn dbg_loc(
96+
&self,
97+
_scope: Self::DIScope,
98+
_inlined_at: Option<Self::DILocation>,
99+
_span: Span,
100+
) -> Self::DILocation {
60101
unimplemented!();
61102
}
62103
}

0 commit comments

Comments
 (0)