Skip to content

Commit 2799378

Browse files
committed
rustc_plugin: Remove support for plugins adding LLVM passes
1 parent cf1ffb0 commit 2799378

File tree

8 files changed

+5
-79
lines changed

8 files changed

+5
-79
lines changed

src/librustc/session/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ pub struct Session {
7676
/// (sub)diagnostics that have been set once, but should not be set again,
7777
/// in order to avoid redundantly verbose output (Issue #24690, #44953).
7878
pub one_time_diagnostics: Lock<FxHashSet<(DiagnosticMessageId, Option<Span>, String)>>,
79-
pub plugin_llvm_passes: OneThread<RefCell<Vec<String>>>,
8079
pub crate_types: Once<Vec<config::CrateType>>,
8180
/// The `crate_disambiguator` is constructed out of all the `-C metadata`
8281
/// arguments passed to the compiler. Its value together with the crate-name
@@ -1149,7 +1148,6 @@ fn build_session_(
11491148
local_crate_source_file,
11501149
working_dir,
11511150
one_time_diagnostics: Default::default(),
1152-
plugin_llvm_passes: OneThread::new(RefCell::new(Vec::new())),
11531151
crate_types: Once::new(),
11541152
crate_disambiguator: Once::new(),
11551153
features: Once::new(),

src/librustc_codegen_llvm/back/write.rs

-14
Original file line numberDiff line numberDiff line change
@@ -365,20 +365,6 @@ pub(crate) unsafe fn optimize(cgcx: &CodegenContext<LlvmCodegenBackend>,
365365

366366
add_sanitizer_passes(config, &mut extra_passes);
367367

368-
for pass_name in &cgcx.plugin_passes {
369-
if let Some(pass) = find_pass(pass_name) {
370-
extra_passes.push(pass);
371-
} else {
372-
diag_handler.err(&format!("a plugin asked for LLVM pass \
373-
`{}` but LLVM does not \
374-
recognize it", pass_name));
375-
}
376-
377-
if pass_name == "name-anon-globals" {
378-
have_name_anon_globals_pass = true;
379-
}
380-
}
381-
382368
// Some options cause LLVM bitcode to be emitted, which uses ThinLTOBuffers, so we need
383369
// to make sure we run LLVM's NameAnonGlobals pass when emitting bitcode; otherwise
384370
// we'll get errors in LLVM.

src/librustc_codegen_ssa/back/write.rs

-3
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,6 @@ pub struct CodegenContext<B: WriteBackendMethods> {
231231
pub total_cgus: usize,
232232
// Handler to use for diagnostics produced during codegen.
233233
pub diag_emitter: SharedEmitter,
234-
// LLVM passes added by plugins.
235-
pub plugin_passes: Vec<String>,
236234
// LLVM optimizations for which we want to print remarks.
237235
pub remark: Passes,
238236
// Worker thread number
@@ -1028,7 +1026,6 @@ fn start_executing_work<B: ExtraBackendMethods>(
10281026
time_passes: sess.time_extended(),
10291027
prof: sess.prof.clone(),
10301028
exported_symbols,
1031-
plugin_passes: sess.plugin_llvm_passes.borrow().clone(),
10321029
remark: sess.opts.cg.remark.clone(),
10331030
worker: 0,
10341031
incr_comp_session_dir: sess.incr_comp_session_dir_opt().map(|r| r.clone()),

src/librustc_interface/passes.rs

+5-10
Original file line numberDiff line numberDiff line change
@@ -208,27 +208,22 @@ pub fn register_plugins<'a>(
208208
middle::recursion_limit::update_limits(sess, &krate);
209209
});
210210

211-
let registrars = time(sess, "plugin loading", || {
212-
plugin::load::load_plugins(sess, metadata_loader, &krate)
213-
});
214-
215211
let mut lint_store = rustc_lint::new_lint_store(
216212
sess.opts.debugging_opts.no_interleave_lints,
217213
sess.unstable_options(),
218214
);
215+
register_lints(&sess, &mut lint_store);
219216

220-
(register_lints)(&sess, &mut lint_store);
221-
222-
let mut registry = Registry::new(sess, &mut lint_store, krate.span);
223-
217+
let registrars = time(sess, "plugin loading", || {
218+
plugin::load::load_plugins(sess, metadata_loader, &krate)
219+
});
224220
time(sess, "plugin registration", || {
221+
let mut registry = Registry::new(sess, &mut lint_store, krate.span);
225222
for registrar in registrars {
226223
registrar(&mut registry);
227224
}
228225
});
229226

230-
*sess.plugin_llvm_passes.borrow_mut() = registry.llvm_passes;
231-
232227
Ok((krate, Lrc::new(lint_store)))
233228
}
234229

src/librustc_plugin_impl/registry.rs

-15
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ use rustc::lint::LintStore;
44
use rustc::session::Session;
55
use syntax_pos::Span;
66

7-
use std::borrow::ToOwned;
8-
97
/// Structure used to register plugins.
108
///
119
/// A plugin registrar function takes an `&mut Registry` and should call
@@ -24,9 +22,6 @@ pub struct Registry<'a> {
2422

2523
#[doc(hidden)]
2624
pub krate_span: Span,
27-
28-
#[doc(hidden)]
29-
pub llvm_passes: Vec<String>,
3025
}
3126

3227
impl<'a> Registry<'a> {
@@ -36,16 +31,6 @@ impl<'a> Registry<'a> {
3631
sess,
3732
lint_store,
3833
krate_span,
39-
llvm_passes: vec![],
4034
}
4135
}
42-
43-
/// Register an LLVM pass.
44-
///
45-
/// Registration with LLVM itself is handled through static C++ objects with
46-
/// constructors. This method simply adds a name to the list of passes to
47-
/// execute.
48-
pub fn register_llvm_pass(&mut self, name: &str) {
49-
self.llvm_passes.push(name.to_owned());
50-
}
5136
}

src/test/ui-fulldeps/auxiliary/llvm-pass-plugin.rs

-19
This file was deleted.

src/test/ui-fulldeps/llvm-pass-plugin.rs

-8
This file was deleted.

src/test/ui-fulldeps/llvm-pass-plugin.stderr

-8
This file was deleted.

0 commit comments

Comments
 (0)