Removed phantomdata no longer necessary

Because CodegenContext doesn't implement Backend anymore
This commit is contained in:
Denis Merigoux 2018-09-06 16:04:20 -07:00 committed by Eduard-Mihai Burtescu
parent a1d0d4f943
commit 4787b7cac9
3 changed files with 12 additions and 22 deletions

View file

@ -26,7 +26,6 @@ use rustc_data_structures::fx::FxHashMap;
use rustc_codegen_utils::symbol_export; use rustc_codegen_utils::symbol_export;
use time_graph::Timeline; use time_graph::Timeline;
use {ModuleCodegen, ModuleLlvm, ModuleKind}; use {ModuleCodegen, ModuleLlvm, ModuleKind};
use std::marker::PhantomData;
use libc; use libc;
@ -768,7 +767,6 @@ impl ThinModule {
llmod_raw, llmod_raw,
llcx, llcx,
tm, tm,
phantom: PhantomData
}, },
name: self.name().to_string(), name: self.name().to_string(),
kind: ModuleKind::Regular, kind: ModuleKind::Regular,

View file

@ -49,7 +49,6 @@ use context::{is_pie_binary, get_reloc_model};
use common; use common;
use jobserver::{Client, Acquired}; use jobserver::{Client, Acquired};
use rustc_demangle; use rustc_demangle;
use std::marker::PhantomData;
use std::any::Any; use std::any::Any;
use std::ffi::{CString, CStr}; use std::ffi::{CString, CStr};
@ -352,7 +351,7 @@ struct AssemblerCommand {
/// Additional resources used by optimize_and_codegen (not module specific) /// Additional resources used by optimize_and_codegen (not module specific)
#[derive(Clone)] #[derive(Clone)]
pub struct CodegenContext<'ll> { pub struct CodegenContext {
// Resources needed when running LTO // Resources needed when running LTO
pub time_passes: bool, pub time_passes: bool,
pub lto: Lto, pub lto: Lto,
@ -393,13 +392,10 @@ pub struct CodegenContext<'ll> {
// measuring is disabled. // measuring is disabled.
time_graph: Option<TimeGraph>, time_graph: Option<TimeGraph>,
// The assembler command if no_integrated_as option is enabled, None otherwise // The assembler command if no_integrated_as option is enabled, None otherwise
assembler_cmd: Option<Arc<AssemblerCommand>>, assembler_cmd: Option<Arc<AssemblerCommand>>
// This field is used to give a lifetime parameter to the struct so that it can implement
// the Backend trait.
phantom: PhantomData<&'ll ()>
} }
impl CodegenContext<'ll> { impl CodegenContext {
pub fn create_diag_handler(&self) -> Handler { pub fn create_diag_handler(&self) -> Handler {
Handler::with_emitter(true, false, Box::new(self.diag_emitter.clone())) Handler::with_emitter(true, false, Box::new(self.diag_emitter.clone()))
} }
@ -428,12 +424,12 @@ impl CodegenContext<'ll> {
} }
pub struct DiagnosticHandlers<'a> { pub struct DiagnosticHandlers<'a> {
data: *mut (&'a CodegenContext<'a>, &'a Handler), data: *mut (&'a CodegenContext, &'a Handler),
llcx: &'a llvm::Context, llcx: &'a llvm::Context,
} }
impl<'a> DiagnosticHandlers<'a> { impl<'a> DiagnosticHandlers<'a> {
pub fn new(cgcx: &'a CodegenContext<'a>, pub fn new(cgcx: &'a CodegenContext,
handler: &'a Handler, handler: &'a Handler,
llcx: &'a llvm::Context) -> Self { llcx: &'a llvm::Context) -> Self {
let data = Box::into_raw(Box::new((cgcx, handler))); let data = Box::into_raw(Box::new((cgcx, handler)));
@ -1618,7 +1614,6 @@ fn start_executing_work(tcx: TyCtxt,
target_pointer_width: tcx.sess.target.target.target_pointer_width.clone(), target_pointer_width: tcx.sess.target.target.target_pointer_width.clone(),
debuginfo: tcx.sess.opts.debuginfo, debuginfo: tcx.sess.opts.debuginfo,
assembler_cmd, assembler_cmd,
phantom: PhantomData
}; };
// This is the "main loop" of parallel work happening for parallel codegen. // This is the "main loop" of parallel work happening for parallel codegen.
@ -2113,7 +2108,7 @@ pub const CODEGEN_WORK_PACKAGE_KIND: time_graph::WorkPackageKind =
const LLVM_WORK_PACKAGE_KIND: time_graph::WorkPackageKind = const LLVM_WORK_PACKAGE_KIND: time_graph::WorkPackageKind =
time_graph::WorkPackageKind(&["#7DB67A", "#C6EEC4", "#ACDAAA", "#579354", "#3E6F3C"]); time_graph::WorkPackageKind(&["#7DB67A", "#C6EEC4", "#ACDAAA", "#579354", "#3E6F3C"]);
fn spawn_work(cgcx: CodegenContext<'static>, work: WorkItem) { fn spawn_work(cgcx: CodegenContext, work: WorkItem) {
let depth = time_depth(); let depth = time_depth();
thread::spawn(move || { thread::spawn(move || {

View file

@ -72,7 +72,6 @@ use back::bytecode::RLIB_BYTECODE_EXTENSION;
pub use llvm_util::target_features; pub use llvm_util::target_features;
use std::any::Any; use std::any::Any;
use std::sync::mpsc; use std::sync::mpsc;
use std::marker::PhantomData;
use rustc_data_structures::sync::Lrc; use rustc_data_structures::sync::Lrc;
use rustc::dep_graph::DepGraph; use rustc::dep_graph::DepGraph;
@ -274,7 +273,7 @@ struct ModuleCodegen {
/// as the crate name and disambiguator. /// as the crate name and disambiguator.
/// We currently generate these names via CodegenUnit::build_cgu_name(). /// We currently generate these names via CodegenUnit::build_cgu_name().
name: String, name: String,
module_llvm: ModuleLlvm<'static>, module_llvm: ModuleLlvm,
kind: ModuleKind, kind: ModuleKind,
} }
@ -316,17 +315,16 @@ impl ModuleCodegen {
} }
} }
struct ModuleLlvm<'ll> { struct ModuleLlvm {
llcx: &'static mut llvm::Context, llcx: &'static mut llvm::Context,
llmod_raw: *const llvm::Module, llmod_raw: *const llvm::Module,
tm: &'static mut llvm::TargetMachine, tm: &'static mut llvm::TargetMachine,
phantom: PhantomData<&'ll ()>
} }
unsafe impl Send for ModuleLlvm<'ll> { } unsafe impl Send for ModuleLlvm { }
unsafe impl Sync for ModuleLlvm<'ll> { } unsafe impl Sync for ModuleLlvm { }
impl ModuleLlvm<'ll> { impl ModuleLlvm {
fn new(sess: &Session, mod_name: &str) -> Self { fn new(sess: &Session, mod_name: &str) -> Self {
unsafe { unsafe {
let llcx = llvm::LLVMRustContextCreate(sess.fewer_names()); let llcx = llvm::LLVMRustContextCreate(sess.fewer_names());
@ -336,7 +334,6 @@ impl ModuleLlvm<'ll> {
llmod_raw, llmod_raw,
llcx, llcx,
tm: create_target_machine(sess, false), tm: create_target_machine(sess, false),
phantom: PhantomData
} }
} }
} }
@ -348,7 +345,7 @@ impl ModuleLlvm<'ll> {
} }
} }
impl Drop for ModuleLlvm<'ll> { impl Drop for ModuleLlvm {
fn drop(&mut self) { fn drop(&mut self) {
unsafe { unsafe {
llvm::LLVMContextDispose(&mut *(self.llcx as *mut _)); llvm::LLVMContextDispose(&mut *(self.llcx as *mut _));