Skip to content

Commit

Permalink
rustc_plugin: Remove support for plugins adding LLVM passes
Browse files Browse the repository at this point in the history
  • Loading branch information
petrochenkov committed Dec 1, 2019
1 parent cf1ffb0 commit 2799378
Show file tree
Hide file tree
Showing 8 changed files with 5 additions and 79 deletions.
2 changes: 0 additions & 2 deletions src/librustc/session/mod.rs
Expand Up @@ -76,7 +76,6 @@ pub struct Session {
/// (sub)diagnostics that have been set once, but should not be set again,
/// in order to avoid redundantly verbose output (Issue #24690, #44953).
pub one_time_diagnostics: Lock<FxHashSet<(DiagnosticMessageId, Option<Span>, String)>>,
pub plugin_llvm_passes: OneThread<RefCell<Vec<String>>>,
pub crate_types: Once<Vec<config::CrateType>>,
/// The `crate_disambiguator` is constructed out of all the `-C metadata`
/// arguments passed to the compiler. Its value together with the crate-name
Expand Down Expand Up @@ -1149,7 +1148,6 @@ fn build_session_(
local_crate_source_file,
working_dir,
one_time_diagnostics: Default::default(),
plugin_llvm_passes: OneThread::new(RefCell::new(Vec::new())),
crate_types: Once::new(),
crate_disambiguator: Once::new(),
features: Once::new(),
Expand Down
14 changes: 0 additions & 14 deletions src/librustc_codegen_llvm/back/write.rs
Expand Up @@ -365,20 +365,6 @@ pub(crate) unsafe fn optimize(cgcx: &CodegenContext<LlvmCodegenBackend>,

add_sanitizer_passes(config, &mut extra_passes);

for pass_name in &cgcx.plugin_passes {
if let Some(pass) = find_pass(pass_name) {
extra_passes.push(pass);
} else {
diag_handler.err(&format!("a plugin asked for LLVM pass \
`{}` but LLVM does not \
recognize it", pass_name));
}

if pass_name == "name-anon-globals" {
have_name_anon_globals_pass = true;
}
}

// Some options cause LLVM bitcode to be emitted, which uses ThinLTOBuffers, so we need
// to make sure we run LLVM's NameAnonGlobals pass when emitting bitcode; otherwise
// we'll get errors in LLVM.
Expand Down
3 changes: 0 additions & 3 deletions src/librustc_codegen_ssa/back/write.rs
Expand Up @@ -231,8 +231,6 @@ pub struct CodegenContext<B: WriteBackendMethods> {
pub total_cgus: usize,
// Handler to use for diagnostics produced during codegen.
pub diag_emitter: SharedEmitter,
// LLVM passes added by plugins.
pub plugin_passes: Vec<String>,
// LLVM optimizations for which we want to print remarks.
pub remark: Passes,
// Worker thread number
Expand Down Expand Up @@ -1028,7 +1026,6 @@ fn start_executing_work<B: ExtraBackendMethods>(
time_passes: sess.time_extended(),
prof: sess.prof.clone(),
exported_symbols,
plugin_passes: sess.plugin_llvm_passes.borrow().clone(),
remark: sess.opts.cg.remark.clone(),
worker: 0,
incr_comp_session_dir: sess.incr_comp_session_dir_opt().map(|r| r.clone()),
Expand Down
15 changes: 5 additions & 10 deletions src/librustc_interface/passes.rs
Expand Up @@ -208,27 +208,22 @@ pub fn register_plugins<'a>(
middle::recursion_limit::update_limits(sess, &krate);
});

let registrars = time(sess, "plugin loading", || {
plugin::load::load_plugins(sess, metadata_loader, &krate)
});

let mut lint_store = rustc_lint::new_lint_store(
sess.opts.debugging_opts.no_interleave_lints,
sess.unstable_options(),
);
register_lints(&sess, &mut lint_store);

(register_lints)(&sess, &mut lint_store);

let mut registry = Registry::new(sess, &mut lint_store, krate.span);

let registrars = time(sess, "plugin loading", || {
plugin::load::load_plugins(sess, metadata_loader, &krate)
});
time(sess, "plugin registration", || {
let mut registry = Registry::new(sess, &mut lint_store, krate.span);
for registrar in registrars {
registrar(&mut registry);
}
});

*sess.plugin_llvm_passes.borrow_mut() = registry.llvm_passes;

Ok((krate, Lrc::new(lint_store)))
}

Expand Down
15 changes: 0 additions & 15 deletions src/librustc_plugin_impl/registry.rs
Expand Up @@ -4,8 +4,6 @@ use rustc::lint::LintStore;
use rustc::session::Session;
use syntax_pos::Span;

use std::borrow::ToOwned;

/// Structure used to register plugins.
///
/// A plugin registrar function takes an `&mut Registry` and should call
Expand All @@ -24,9 +22,6 @@ pub struct Registry<'a> {

#[doc(hidden)]
pub krate_span: Span,

#[doc(hidden)]
pub llvm_passes: Vec<String>,
}

impl<'a> Registry<'a> {
Expand All @@ -36,16 +31,6 @@ impl<'a> Registry<'a> {
sess,
lint_store,
krate_span,
llvm_passes: vec![],
}
}

/// Register an LLVM pass.
///
/// Registration with LLVM itself is handled through static C++ objects with
/// constructors. This method simply adds a name to the list of passes to
/// execute.
pub fn register_llvm_pass(&mut self, name: &str) {
self.llvm_passes.push(name.to_owned());
}
}
19 changes: 0 additions & 19 deletions src/test/ui-fulldeps/auxiliary/llvm-pass-plugin.rs

This file was deleted.

8 changes: 0 additions & 8 deletions src/test/ui-fulldeps/llvm-pass-plugin.rs

This file was deleted.

8 changes: 0 additions & 8 deletions src/test/ui-fulldeps/llvm-pass-plugin.stderr

This file was deleted.

0 comments on commit 2799378

Please sign in to comment.