mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-24 07:44:10 +00:00
rustc_plugin: Remove support for plugins adding LLVM passes
This commit is contained in:
parent
cf1ffb0355
commit
279937812a
@ -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());
|
||||
}
|
||||
}
|
||||
|
@ -1,19 +0,0 @@
|
||||
// force-host
|
||||
|
||||
#![feature(plugin_registrar)]
|
||||
#![feature(rustc_private)]
|
||||
|
||||
extern crate rustc;
|
||||
extern crate rustc_driver;
|
||||
|
||||
use rustc_driver::plugin::Registry;
|
||||
|
||||
#[plugin_registrar]
|
||||
pub fn plugin_registrar(reg: &mut Registry) {
|
||||
// This pass is built in to LLVM.
|
||||
//
|
||||
// Normally, we would name a pass that was registered through
|
||||
// C++ static object constructors in the same .so file as the
|
||||
// plugin registrar.
|
||||
reg.register_llvm_pass("gvn");
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
// run-pass
|
||||
// aux-build:llvm-pass-plugin.rs
|
||||
// ignore-stage1
|
||||
|
||||
#![feature(plugin)]
|
||||
#![plugin(llvm_pass_plugin)] //~ WARNING compiler plugins are deprecated
|
||||
|
||||
pub fn main() { }
|
@ -1,8 +0,0 @@
|
||||
warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675
|
||||
--> $DIR/llvm-pass-plugin.rs:6:1
|
||||
|
|
||||
LL | #![plugin(llvm_pass_plugin)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version
|
||||
|
|
||||
= note: `#[warn(deprecated)]` on by default
|
||||
|
Loading…
Reference in New Issue
Block a user