@@ -30,7 +30,7 @@ use tracing::debug;
30
30
31
31
use self :: metadata:: { UNKNOWN_COLUMN_NUMBER , UNKNOWN_LINE_NUMBER , file_metadata, type_di_node} ;
32
32
use self :: namespace:: mangled_name_of_instance;
33
- use self :: utils:: { DIB , create_DIArray, debug_context , is_node_local_to_unit} ;
33
+ use self :: utils:: { DIB , create_DIArray, is_node_local_to_unit} ;
34
34
use crate :: builder:: Builder ;
35
35
use crate :: common:: { AsCCharPtr , CodegenCx } ;
36
36
use crate :: llvm;
@@ -131,28 +131,20 @@ impl<'ll, 'tcx> CodegenUnitDebugContext<'ll, 'tcx> {
131
131
}
132
132
133
133
/// Creates any deferred debug metadata nodes
134
- pub ( crate ) fn finalize ( cx : & mut CodegenCx < ' _ , ' _ > ) {
135
- if cx. dbg_cx . is_none ( ) {
136
- return ;
137
- }
138
-
139
- debug ! ( "finalize" ) ;
140
-
141
- if gdb:: needs_gdb_debug_scripts_section ( cx) {
142
- // Add a .debug_gdb_scripts section to this compile-unit. This will
143
- // cause GDB to try and load the gdb_load_rust_pretty_printers.py file,
144
- // which activates the Rust pretty printers for binary this section is
145
- // contained in.
146
- let section_var = gdb:: get_or_insert_gdb_debug_scripts_section_global ( cx) ;
134
+ pub ( crate ) fn finalize ( cx : & CodegenCx < ' _ , ' _ > ) {
135
+ if let Some ( dbg_cx) = & cx. dbg_cx {
136
+ debug ! ( "finalize" ) ;
137
+
138
+ if gdb:: needs_gdb_debug_scripts_section ( cx) {
139
+ // Add a .debug_gdb_scripts section to this compile-unit. This will
140
+ // cause GDB to try and load the gdb_load_rust_pretty_printers.py file,
141
+ // which activates the Rust pretty printers for binary this section is
142
+ // contained in.
143
+ gdb:: get_or_insert_gdb_debug_scripts_section_global ( cx) ;
144
+ }
147
145
148
- // Make sure that the linker doesn't optimize the global away. Adding
149
- // it to `llvm.used` has the advantage that it works even in no_std
150
- // binaries, where we don't have a main shim and thus don't emit a
151
- // volatile load to preserve the global.
152
- cx. add_used_global ( section_var) ;
146
+ dbg_cx. finalize ( cx. sess ( ) ) ;
153
147
}
154
-
155
- debug_context ( cx) . finalize ( cx. sess ( ) ) ;
156
148
}
157
149
158
150
impl < ' ll > Builder < ' _ , ' ll , ' _ > {
@@ -622,7 +614,7 @@ impl<'ll, 'tcx> DebugInfoCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> {
622
614
metadata:: extend_scope_to_file ( self , scope_metadata, file)
623
615
}
624
616
625
- fn debuginfo_finalize ( & mut self ) {
617
+ fn debuginfo_finalize ( & self ) {
626
618
finalize ( self )
627
619
}
628
620
0 commit comments