Skip to content

Commit d7c0bde

Browse files
committed
Remove methods from StaticCodegenMethods that are not called in cg_ssa itself
1 parent 669e2ea commit d7c0bde

File tree

5 files changed

+16
-37
lines changed

5 files changed

+16
-37
lines changed

compiler/rustc_codegen_gcc/src/consts.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -160,19 +160,14 @@ impl<'gcc, 'tcx> StaticCodegenMethods for CodegenCx<'gcc, 'tcx> {
160160
self.add_used_global(global.to_rvalue());
161161
}
162162
}
163+
}
163164

165+
impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
164166
/// Add a global value to a list to be stored in the `llvm.used` variable, an array of i8*.
165-
fn add_used_global(&mut self, _global: RValue<'gcc>) {
167+
pub fn add_used_global(&mut self, _global: RValue<'gcc>) {
166168
// TODO(antoyo)
167169
}
168170

169-
fn add_compiler_used_global(&mut self, global: RValue<'gcc>) {
170-
// NOTE: seems like GCC does not make the distinction between compiler.used and used.
171-
self.add_used_global(global);
172-
}
173-
}
174-
175-
impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
176171
#[cfg_attr(not(feature = "master"), allow(unused_variables))]
177172
pub fn add_used_function(&self, function: Function<'gcc>) {
178173
#[cfg(feature = "master")]

compiler/rustc_codegen_llvm/src/consts.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,17 @@ impl<'ll> CodegenCx<'ll, '_> {
557557
}
558558
}
559559
}
560+
561+
/// Add a global value to a list to be stored in the `llvm.used` variable, an array of ptr.
562+
pub(crate) fn add_used_global(&mut self, global: &'ll Value) {
563+
self.used_statics.push(global);
564+
}
565+
566+
/// Add a global value to a list to be stored in the `llvm.compiler.used` variable,
567+
/// an array of ptr.
568+
pub(crate) fn add_compiler_used_global(&mut self, global: &'ll Value) {
569+
self.compiler_used_statics.push(global);
570+
}
560571
}
561572

562573
impl<'ll> StaticCodegenMethods for CodegenCx<'ll, '_> {
@@ -574,15 +585,4 @@ impl<'ll> StaticCodegenMethods for CodegenCx<'ll, '_> {
574585
fn codegen_static(&mut self, def_id: DefId) {
575586
self.codegen_static_item(def_id)
576587
}
577-
578-
/// Add a global value to a list to be stored in the `llvm.used` variable, an array of ptr.
579-
fn add_used_global(&mut self, global: &'ll Value) {
580-
self.used_statics.push(global);
581-
}
582-
583-
/// Add a global value to a list to be stored in the `llvm.compiler.used` variable,
584-
/// an array of ptr.
585-
fn add_compiler_used_global(&mut self, global: &'ll Value) {
586-
self.compiler_used_statics.push(global);
587-
}
588588
}

compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ use std::sync::Arc;
22

33
use itertools::Itertools;
44
use rustc_abi::Align;
5-
use rustc_codegen_ssa::traits::{
6-
BaseTypeCodegenMethods, ConstCodegenMethods, StaticCodegenMethods,
7-
};
5+
use rustc_codegen_ssa::traits::{BaseTypeCodegenMethods, ConstCodegenMethods};
86
use rustc_data_structures::fx::FxIndexMap;
97
use rustc_index::IndexVec;
108
use rustc_middle::ty::TyCtxt;

compiler/rustc_codegen_llvm/src/coverageinfo/mapgen/covfun.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ use std::ffi::CString;
88
use std::sync::Arc;
99

1010
use rustc_abi::Align;
11-
use rustc_codegen_ssa::traits::{
12-
BaseTypeCodegenMethods as _, ConstCodegenMethods, StaticCodegenMethods,
13-
};
11+
use rustc_codegen_ssa::traits::{BaseTypeCodegenMethods as _, ConstCodegenMethods};
1412
use rustc_middle::mir::coverage::{
1513
BasicCoverageBlock, CovTerm, CoverageIdsInfo, Expression, FunctionCoverageInfo, Mapping,
1614
MappingKind, Op,

compiler/rustc_codegen_ssa/src/traits/statics.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,6 @@ use super::BackendTypes;
66
pub trait StaticCodegenMethods: BackendTypes {
77
fn static_addr_of(&self, cv: Self::Value, align: Align, kind: Option<&str>) -> Self::Value;
88
fn codegen_static(&mut self, def_id: DefId);
9-
10-
/// Mark the given global value as "used", to prevent the compiler and linker from potentially
11-
/// removing a static variable that may otherwise appear unused.
12-
fn add_used_global(&mut self, global: Self::Value);
13-
14-
/// Same as add_used_global(), but only prevent the compiler from potentially removing an
15-
/// otherwise unused symbol. The linker is still permitted to drop it.
16-
///
17-
/// This corresponds to the documented semantics of the `#[used]` attribute, although
18-
/// on some targets (non-ELF), we may use `add_used_global` for `#[used]` statics
19-
/// instead.
20-
fn add_compiler_used_global(&mut self, global: Self::Value);
219
}
2210

2311
pub trait StaticBuilderMethods: BackendTypes {

0 commit comments

Comments
 (0)