about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCamille GILLOT <gillot.camille@gmail.com>2021-01-02 14:42:15 +0100
committerCamille GILLOT <gillot.camille@gmail.com>2021-09-07 19:53:04 +0200
commit81a600b6b7db07ebac28c8ddedd357e3c5b9951d (patch)
treedc9bf55bd478ff63cd26ab0464be90579d4e14d0
parentbba4be681d664a50ab307ec732f957c02255e067 (diff)
downloadrust-81a600b6b7db07ebac28c8ddedd357e3c5b9951d.tar.gz
rust-81a600b6b7db07ebac28c8ddedd357e3c5b9951d.zip
Move monomorphize code to its own crate.
-rw-r--r--Cargo.lock17
-rwxr-xr-xcompiler/rustc_codegen_cranelift/scripts/filter_profile.rs4
-rw-r--r--compiler/rustc_interface/Cargo.toml1
-rw-r--r--compiler/rustc_interface/src/passes.rs1
-rw-r--r--compiler/rustc_mir/src/lib.rs4
-rw-r--r--compiler/rustc_monomorphize/Cargo.toml20
-rw-r--r--compiler/rustc_monomorphize/src/collector.rs (renamed from compiler/rustc_mir/src/monomorphize/collector.rs)6
-rw-r--r--compiler/rustc_monomorphize/src/lib.rs (renamed from compiler/rustc_mir/src/monomorphize/mod.rs)28
-rw-r--r--compiler/rustc_monomorphize/src/partitioning/default.rs (renamed from compiler/rustc_mir/src/monomorphize/partitioning/default.rs)6
-rw-r--r--compiler/rustc_monomorphize/src/partitioning/merging.rs (renamed from compiler/rustc_mir/src/monomorphize/partitioning/merging.rs)2
-rw-r--r--compiler/rustc_monomorphize/src/partitioning/mod.rs (renamed from compiler/rustc_mir/src/monomorphize/partitioning/mod.rs)4
-rw-r--r--compiler/rustc_monomorphize/src/polymorphize.rs (renamed from compiler/rustc_mir/src/monomorphize/polymorphize.rs)0
-rw-r--r--compiler/rustc_monomorphize/src/util.rs (renamed from compiler/rustc_mir/src/monomorphize/util.rs)0
13 files changed, 71 insertions, 22 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 3ec143d2492..841fc608476 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -3929,6 +3929,7 @@ dependencies = [
  "rustc_mir",
  "rustc_mir_build",
  "rustc_mir_transform",
+ "rustc_monomorphize",
  "rustc_parse",
  "rustc_passes",
  "rustc_plugin_impl",
@@ -4143,6 +4144,22 @@ dependencies = [
 ]
 
 [[package]]
+name = "rustc_monomorphize"
+version = "0.0.0"
+dependencies = [
+ "rustc_data_structures",
+ "rustc_errors",
+ "rustc_hir",
+ "rustc_index",
+ "rustc_middle",
+ "rustc_session",
+ "rustc_span",
+ "rustc_target",
+ "smallvec",
+ "tracing",
+]
+
+[[package]]
 name = "rustc_parse"
 version = "0.0.0"
 dependencies = [
diff --git a/compiler/rustc_codegen_cranelift/scripts/filter_profile.rs b/compiler/rustc_codegen_cranelift/scripts/filter_profile.rs
index c4801a0a87b..7a51293f5cd 100755
--- a/compiler/rustc_codegen_cranelift/scripts/filter_profile.rs
+++ b/compiler/rustc_codegen_cranelift/scripts/filter_profile.rs
@@ -42,7 +42,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
             continue;
         }
 
-        if stack.contains("rustc_mir::monomorphize::partitioning::collect_and_partition_mono_items")
+        if stack.contains("rustc_monomorphize::partitioning::collect_and_partition_mono_items")
             || stack.contains("rustc_incremental::assert_dep_graph::assert_dep_graph")
             || stack.contains("rustc_symbol_mangling::test::report_symbol_names")
         {
@@ -81,7 +81,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
         }
 
         const COLLECT_AND_PARTITION_MONO_ITEMS: &str =
-            "rustc_mir::monomorphize::partitioning::collect_and_partition_mono_items";
+            "rustc_monomorphize::partitioning::collect_and_partition_mono_items";
         if let Some(index) = stack.find(COLLECT_AND_PARTITION_MONO_ITEMS) {
             stack = &stack[..index + COLLECT_AND_PARTITION_MONO_ITEMS.len()];
         }
diff --git a/compiler/rustc_interface/Cargo.toml b/compiler/rustc_interface/Cargo.toml
index 8b277269258..306728dbeac 100644
--- a/compiler/rustc_interface/Cargo.toml
+++ b/compiler/rustc_interface/Cargo.toml
@@ -35,6 +35,7 @@ rustc_metadata = { path = "../rustc_metadata" }
 rustc_mir = { path = "../rustc_mir" }
 rustc_mir_build = { path = "../rustc_mir_build" }
 rustc_mir_transform = { path = "../rustc_mir_transform" }
+rustc_monomorphize = { path = "../rustc_monomorphize" }
 rustc_passes = { path = "../rustc_passes" }
 rustc_typeck = { path = "../rustc_typeck" }
 rustc_lint = { path = "../rustc_lint" }
diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs
index 7d41db0d4ae..547823a067c 100644
--- a/compiler/rustc_interface/src/passes.rs
+++ b/compiler/rustc_interface/src/passes.rs
@@ -743,6 +743,7 @@ pub static DEFAULT_QUERY_PROVIDERS: SyncLazy<Providers> = SyncLazy::new(|| {
     mir_borrowck::provide(providers);
     mir_build::provide(providers);
     rustc_mir_transform::provide(providers);
+    rustc_monomorphize::provide(providers);
     rustc_privacy::provide(providers);
     typeck::provide(providers);
     ty::provide(providers);
diff --git a/compiler/rustc_mir/src/lib.rs b/compiler/rustc_mir/src/lib.rs
index 4c79c7da15c..fa1f27daa80 100644
--- a/compiler/rustc_mir/src/lib.rs
+++ b/compiler/rustc_mir/src/lib.rs
@@ -4,7 +4,6 @@ Rust MIR: a lowered representation of Rust.
 
 */
 
-#![feature(array_windows)]
 #![feature(assert_matches)]
 #![cfg_attr(bootstrap, feature(bindings_after_at))]
 #![feature(associated_type_defaults)]
@@ -36,7 +35,6 @@ extern crate rustc_middle;
 pub mod const_eval;
 pub mod dataflow;
 pub mod interpret;
-pub mod monomorphize;
 pub mod transform;
 pub mod util;
 
@@ -44,8 +42,6 @@ use rustc_middle::ty::query::Providers;
 
 pub fn provide(providers: &mut Providers) {
     const_eval::provide(providers);
-    monomorphize::partitioning::provide(providers);
-    monomorphize::polymorphize::provide(providers);
     providers.eval_to_const_value_raw = const_eval::eval_to_const_value_raw_provider;
     providers.eval_to_allocation_raw = const_eval::eval_to_allocation_raw_provider;
     providers.const_caller_location = const_eval::const_caller_location;
diff --git a/compiler/rustc_monomorphize/Cargo.toml b/compiler/rustc_monomorphize/Cargo.toml
new file mode 100644
index 00000000000..93a964bf3cc
--- /dev/null
+++ b/compiler/rustc_monomorphize/Cargo.toml
@@ -0,0 +1,20 @@
+[package]
+authors = ["The Rust Project Developers"]
+name = "rustc_monomorphize"
+version = "0.0.0"
+edition = "2018"
+
+[lib]
+doctest = false
+
+[dependencies]
+smallvec = { version = "1.6.1", features = ["union", "may_dangle"] }
+tracing = "0.1"
+rustc_data_structures = { path = "../rustc_data_structures" }
+rustc_errors = { path = "../rustc_errors" }
+rustc_hir = { path = "../rustc_hir" }
+rustc_index = { path = "../rustc_index" }
+rustc_middle = { path = "../rustc_middle" }
+rustc_session = { path = "../rustc_session" }
+rustc_span = { path = "../rustc_span" }
+rustc_target = { path = "../rustc_target" }
diff --git a/compiler/rustc_mir/src/monomorphize/collector.rs b/compiler/rustc_monomorphize/src/collector.rs
index 4cb362238c1..1e39b1bd5e8 100644
--- a/compiler/rustc_mir/src/monomorphize/collector.rs
+++ b/compiler/rustc_monomorphize/src/collector.rs
@@ -178,8 +178,6 @@
 //! this is not implemented however: a mono item will be produced
 //! regardless of whether it is actually needed or not.
 
-use crate::monomorphize;
-
 use rustc_data_structures::fx::{FxHashMap, FxHashSet};
 use rustc_data_structures::sync::{par_iter, MTLock, MTRef, ParallelIterator};
 use rustc_errors::{ErrorReported, FatalError};
@@ -1052,7 +1050,7 @@ fn find_vtable_types_for_unsizing<'tcx>(
             assert_eq!(source_adt_def, target_adt_def);
 
             let CustomCoerceUnsized::Struct(coerce_index) =
-                monomorphize::custom_coerce_unsize_info(tcx, source_ty, target_ty);
+                crate::custom_coerce_unsize_info(tcx, source_ty, target_ty);
 
             let source_fields = &source_adt_def.non_enum_variant().fields;
             let target_fields = &target_adt_def.non_enum_variant().fields;
@@ -1085,7 +1083,7 @@ fn create_fn_mono_item<'tcx>(
     let def_id = instance.def_id();
     if tcx.sess.opts.debugging_opts.profile_closures && def_id.is_local() && tcx.is_closure(def_id)
     {
-        monomorphize::util::dump_closure_profile(tcx, instance);
+        crate::util::dump_closure_profile(tcx, instance);
     }
 
     respan(source, MonoItem::Fn(instance.polymorphize(tcx)))
diff --git a/compiler/rustc_mir/src/monomorphize/mod.rs b/compiler/rustc_monomorphize/src/lib.rs
index 57d2723cf9c..2a40eeac5bd 100644
--- a/compiler/rustc_mir/src/monomorphize/mod.rs
+++ b/compiler/rustc_monomorphize/src/lib.rs
@@ -1,13 +1,24 @@
+#![feature(array_windows)]
+#![feature(bool_to_option)]
+#![feature(crate_visibility_modifier)]
+#![feature(control_flow_enum)]
+#![feature(in_band_lifetimes)]
+
+#[macro_use]
+extern crate tracing;
+#[macro_use]
+extern crate rustc_middle;
+
+use rustc_hir::lang_items::LangItem;
 use rustc_middle::traits;
 use rustc_middle::ty::adjustment::CustomCoerceUnsized;
+use rustc_middle::ty::query::Providers;
 use rustc_middle::ty::{self, Ty, TyCtxt};
 
-use rustc_hir::lang_items::LangItem;
-
-pub mod collector;
-pub mod partitioning;
-pub mod polymorphize;
-pub mod util;
+mod collector;
+mod partitioning;
+mod polymorphize;
+mod util;
 
 fn custom_coerce_unsize_info<'tcx>(
     tcx: TyCtxt<'tcx>,
@@ -31,3 +42,8 @@ fn custom_coerce_unsize_info<'tcx>(
         }
     }
 }
+
+pub fn provide(providers: &mut Providers) {
+    partitioning::provide(providers);
+    polymorphize::provide(providers);
+}
diff --git a/compiler/rustc_mir/src/monomorphize/partitioning/default.rs b/compiler/rustc_monomorphize/src/partitioning/default.rs
index a559a6ce415..429ed53d379 100644
--- a/compiler/rustc_mir/src/monomorphize/partitioning/default.rs
+++ b/compiler/rustc_monomorphize/src/partitioning/default.rs
@@ -13,9 +13,9 @@ use rustc_middle::ty::{self, DefIdTree, InstanceDef, TyCtxt};
 use rustc_span::symbol::Symbol;
 
 use super::PartitioningCx;
-use crate::monomorphize::collector::InliningMap;
-use crate::monomorphize::partitioning::merging;
-use crate::monomorphize::partitioning::{
+use crate::collector::InliningMap;
+use crate::partitioning::merging;
+use crate::partitioning::{
     MonoItemPlacement, Partitioner, PostInliningPartitioning, PreInliningPartitioning,
 };
 
diff --git a/compiler/rustc_mir/src/monomorphize/partitioning/merging.rs b/compiler/rustc_monomorphize/src/partitioning/merging.rs
index cbe36665790..229468b47ff 100644
--- a/compiler/rustc_mir/src/monomorphize/partitioning/merging.rs
+++ b/compiler/rustc_monomorphize/src/partitioning/merging.rs
@@ -6,7 +6,7 @@ use rustc_middle::mir::mono::{CodegenUnit, CodegenUnitNameBuilder};
 use rustc_span::symbol::{Symbol, SymbolStr};
 
 use super::PartitioningCx;
-use crate::monomorphize::partitioning::PreInliningPartitioning;
+use crate::partitioning::PreInliningPartitioning;
 
 pub fn merge_codegen_units<'tcx>(
     cx: &PartitioningCx<'_, 'tcx>,
diff --git a/compiler/rustc_mir/src/monomorphize/partitioning/mod.rs b/compiler/rustc_monomorphize/src/partitioning/mod.rs
index 6ed0ab8be41..7a7a56a034e 100644
--- a/compiler/rustc_mir/src/monomorphize/partitioning/mod.rs
+++ b/compiler/rustc_monomorphize/src/partitioning/mod.rs
@@ -105,8 +105,8 @@ use rustc_middle::ty::query::Providers;
 use rustc_middle::ty::TyCtxt;
 use rustc_span::symbol::Symbol;
 
-use crate::monomorphize::collector::InliningMap;
-use crate::monomorphize::collector::{self, MonoItemCollectionMode};
+use crate::collector::InliningMap;
+use crate::collector::{self, MonoItemCollectionMode};
 
 pub struct PartitioningCx<'a, 'tcx> {
     tcx: TyCtxt<'tcx>,
diff --git a/compiler/rustc_mir/src/monomorphize/polymorphize.rs b/compiler/rustc_monomorphize/src/polymorphize.rs
index 3c55a4b0a8f..3c55a4b0a8f 100644
--- a/compiler/rustc_mir/src/monomorphize/polymorphize.rs
+++ b/compiler/rustc_monomorphize/src/polymorphize.rs
diff --git a/compiler/rustc_mir/src/monomorphize/util.rs b/compiler/rustc_monomorphize/src/util.rs
index 799b4e18c24..799b4e18c24 100644
--- a/compiler/rustc_mir/src/monomorphize/util.rs
+++ b/compiler/rustc_monomorphize/src/util.rs