提交 756f84d7 编写于 作者: E Eduard-Mihai Burtescu

[eddyb] rustc_codegen_llvm: remove unused parametrization of `CodegenCx` and...

[eddyb] rustc_codegen_llvm: remove unused parametrization of `CodegenCx` and `Builder` over `Value`s.
上级 0b569249
...@@ -180,17 +180,17 @@ fn module_codegen<'ll, 'tcx>( ...@@ -180,17 +180,17 @@ fn module_codegen<'ll, 'tcx>(
let mono_items = cx.codegen_unit let mono_items = cx.codegen_unit
.items_in_deterministic_order(cx.tcx); .items_in_deterministic_order(cx.tcx);
for &(mono_item, (linkage, visibility)) in &mono_items { for &(mono_item, (linkage, visibility)) in &mono_items {
mono_item.predefine::<Builder<&Value>>(&cx, linkage, visibility); mono_item.predefine::<Builder>(&cx, linkage, visibility);
} }
// ... and now that we have everything pre-defined, fill out those definitions. // ... and now that we have everything pre-defined, fill out those definitions.
for &(mono_item, _) in &mono_items { for &(mono_item, _) in &mono_items {
mono_item.define::<Builder<&Value>>(&cx); mono_item.define::<Builder>(&cx);
} }
// If this codegen unit contains the main function, also create the // If this codegen unit contains the main function, also create the
// wrapper here // wrapper here
maybe_create_entry_wrapper::<Builder<&Value>>(&cx); maybe_create_entry_wrapper::<Builder>(&cx);
// Run replace-all-uses-with for statics that need it // Run replace-all-uses-with for statics that need it
for &(old_g, new_g) in cx.statics_to_rauw().borrow().iter() { for &(old_g, new_g) in cx.statics_to_rauw().borrow().iter() {
......
...@@ -34,12 +34,12 @@ ...@@ -34,12 +34,12 @@
// All Builders must have an llfn associated with them // All Builders must have an llfn associated with them
#[must_use] #[must_use]
pub struct Builder<'a, 'll: 'a, 'tcx: 'll, V: 'll = &'ll Value> { pub struct Builder<'a, 'll: 'a, 'tcx: 'll> {
pub llbuilder: &'ll mut llvm::Builder<'ll>, pub llbuilder: &'ll mut llvm::Builder<'ll>,
pub cx: &'a CodegenCx<'ll, 'tcx, V>, pub cx: &'a CodegenCx<'ll, 'tcx>,
} }
impl<V> Drop for Builder<'a, 'll, 'tcx, V> { impl Drop for Builder<'a, 'll, 'tcx> {
fn drop(&mut self) { fn drop(&mut self) {
unsafe { unsafe {
llvm::LLVMDisposeBuilder(&mut *(self.llbuilder as *mut _)); llvm::LLVMDisposeBuilder(&mut *(self.llbuilder as *mut _));
......
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
/// There is one `CodegenCx` per compilation unit. Each one has its own LLVM /// There is one `CodegenCx` per compilation unit. Each one has its own LLVM
/// `llvm::Context` so that several compilation units may be optimized in parallel. /// `llvm::Context` so that several compilation units may be optimized in parallel.
/// All other LLVM data structures in the `CodegenCx` are tied to that `llvm::Context`. /// All other LLVM data structures in the `CodegenCx` are tied to that `llvm::Context`.
pub struct CodegenCx<'ll, 'tcx: 'll, V = &'ll Value> { pub struct CodegenCx<'ll, 'tcx: 'll> {
pub tcx: TyCtxt<'ll, 'tcx, 'tcx>, pub tcx: TyCtxt<'ll, 'tcx, 'tcx>,
pub check_overflow: bool, pub check_overflow: bool,
pub use_dll_storage_attrs: bool, pub use_dll_storage_attrs: bool,
...@@ -59,11 +59,11 @@ pub struct CodegenCx<'ll, 'tcx: 'll, V = &'ll Value> { ...@@ -59,11 +59,11 @@ pub struct CodegenCx<'ll, 'tcx: 'll, V = &'ll Value> {
pub codegen_unit: Arc<CodegenUnit<'tcx>>, pub codegen_unit: Arc<CodegenUnit<'tcx>>,
/// Cache instances of monomorphic and polymorphic items /// Cache instances of monomorphic and polymorphic items
pub instances: RefCell<FxHashMap<Instance<'tcx>, V>>, pub instances: RefCell<FxHashMap<Instance<'tcx>, &'ll Value>>,
/// Cache generated vtables /// Cache generated vtables
pub vtables: RefCell<FxHashMap<(Ty<'tcx>, ty::PolyExistentialTraitRef<'tcx>), V>>, pub vtables: RefCell<FxHashMap<(Ty<'tcx>, ty::PolyExistentialTraitRef<'tcx>), &'ll Value>>,
/// Cache of constant strings, /// Cache of constant strings,
pub const_cstr_cache: RefCell<FxHashMap<LocalInternedString, V>>, pub const_cstr_cache: RefCell<FxHashMap<LocalInternedString, &'ll Value>>,
/// Reverse-direction for const ptrs cast from globals. /// Reverse-direction for const ptrs cast from globals.
/// Key is a Value holding a *T, /// Key is a Value holding a *T,
...@@ -73,20 +73,20 @@ pub struct CodegenCx<'ll, 'tcx: 'll, V = &'ll Value> { ...@@ -73,20 +73,20 @@ pub struct CodegenCx<'ll, 'tcx: 'll, V = &'ll Value> {
/// when we ptrcast, and we have to ptrcast during codegen /// when we ptrcast, and we have to ptrcast during codegen
/// of a [T] const because we form a slice, a (*T,usize) pair, not /// of a [T] const because we form a slice, a (*T,usize) pair, not
/// a pointer to an LLVM array type. Similar for trait objects. /// a pointer to an LLVM array type. Similar for trait objects.
pub const_unsized: RefCell<FxHashMap<V, V>>, pub const_unsized: RefCell<FxHashMap<&'ll Value, &'ll Value>>,
/// Cache of emitted const globals (value -> global) /// Cache of emitted const globals (value -> global)
pub const_globals: RefCell<FxHashMap<V, V>>, pub const_globals: RefCell<FxHashMap<&'ll Value, &'ll Value>>,
/// List of globals for static variables which need to be passed to the /// List of globals for static variables which need to be passed to the
/// LLVM function ReplaceAllUsesWith (RAUW) when codegen is complete. /// LLVM function ReplaceAllUsesWith (RAUW) when codegen is complete.
/// (We have to make sure we don't invalidate any Values referring /// (We have to make sure we don't invalidate any Values referring
/// to constants.) /// to constants.)
pub statics_to_rauw: RefCell<Vec<(V, V)>>, pub statics_to_rauw: RefCell<Vec<(&'ll Value, &'ll Value)>>,
/// Statics that will be placed in the llvm.used variable /// Statics that will be placed in the llvm.used variable
/// See http://llvm.org/docs/LangRef.html#the-llvm-used-global-variable for details /// See http://llvm.org/docs/LangRef.html#the-llvm-used-global-variable for details
pub used_statics: RefCell<Vec<V>>, pub used_statics: RefCell<Vec<&'ll Value>>,
pub lltypes: RefCell<FxHashMap<(Ty<'tcx>, Option<VariantIdx>), &'ll Type>>, pub lltypes: RefCell<FxHashMap<(Ty<'tcx>, Option<VariantIdx>), &'ll Type>>,
pub scalar_lltypes: RefCell<FxHashMap<Ty<'tcx>, &'ll Type>>, pub scalar_lltypes: RefCell<FxHashMap<Ty<'tcx>, &'ll Type>>,
...@@ -95,11 +95,11 @@ pub struct CodegenCx<'ll, 'tcx: 'll, V = &'ll Value> { ...@@ -95,11 +95,11 @@ pub struct CodegenCx<'ll, 'tcx: 'll, V = &'ll Value> {
pub dbg_cx: Option<debuginfo::CrateDebugContext<'ll, 'tcx>>, pub dbg_cx: Option<debuginfo::CrateDebugContext<'ll, 'tcx>>,
eh_personality: Cell<Option<V>>, eh_personality: Cell<Option<&'ll Value>>,
eh_unwind_resume: Cell<Option<V>>, eh_unwind_resume: Cell<Option<&'ll Value>>,
pub rust_try_fn: Cell<Option<V>>, pub rust_try_fn: Cell<Option<&'ll Value>>,
intrinsics: RefCell<FxHashMap<&'static str, V>>, intrinsics: RefCell<FxHashMap<&'static str, &'ll Value>>,
/// A counter that is used for generating local symbol names /// A counter that is used for generating local symbol names
local_gen_sym_counter: Cell<usize>, local_gen_sym_counter: Cell<usize>,
......
...@@ -29,12 +29,12 @@ While the LLVM-specific code will be left in `rustc_codegen_llvm`, all the new t ...@@ -29,12 +29,12 @@ While the LLVM-specific code will be left in `rustc_codegen_llvm`, all the new t
The two most important structures for the LLVM codegen are `CodegenCx` and `Builder`. They are parametrized by multiple liftime parameters and the type for `Value`. The two most important structures for the LLVM codegen are `CodegenCx` and `Builder`. They are parametrized by multiple liftime parameters and the type for `Value`.
```rust ```rust
struct CodegenCx<'ll, 'tcx: 'll, V: 'll = &'ll Value> { struct CodegenCx<'ll, 'tcx: 'll> {
/* ... */ /* ... */
} }
struct Builder<'a, 'll: 'a, 'tcx: 'll, V: 'll = &'ll Value> { struct Builder<'a, 'll: 'a, 'tcx: 'll> {
cx: &'a CodegenCx<'ll, 'tcx, V>, cx: &'a CodegenCx<'ll, 'tcx>,
/* ... */ /* ... */
} }
``` ```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册