Skip to content
Permalink
Browse files

rustc_plugin: Remove support for plugins adding LLVM passes

  • Loading branch information
petrochenkov committed Nov 30, 2019
1 parent cf1ffb0 commit 279937812aaf018f9d50bd70d84b369d41a13f4f
@@ -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
@@ -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(),
@@ -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.
@@ -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
@@ -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()),
@@ -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)))
}

@@ -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
@@ -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> {
@@ -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());
}
}

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 2799378

Please sign in to comment.
You can’t perform that action at this time.