提交 4787b7ca 编写于 作者: D Denis Merigoux 提交者: Eduard-Mihai Burtescu

Removed phantomdata no longer necessary

Because CodegenContext doesn't implement Backend anymore
上级 a1d0d4f9
......@@ -26,7 +26,6 @@
use rustc_codegen_utils::symbol_export;
use time_graph::Timeline;
use {ModuleCodegen, ModuleLlvm, ModuleKind};
use std::marker::PhantomData;
use libc;
......@@ -768,7 +767,6 @@ unsafe fn optimize(&mut self, cgcx: &CodegenContext, timeline: &mut Timeline)
llmod_raw,
llcx,
tm,
phantom: PhantomData
},
name: self.name().to_string(),
kind: ModuleKind::Regular,
......
......@@ -49,7 +49,6 @@
use common;
use jobserver::{Client, Acquired};
use rustc_demangle;
use std::marker::PhantomData;
use std::any::Any;
use std::ffi::{CString, CStr};
......@@ -352,7 +351,7 @@ struct AssemblerCommand {
/// Additional resources used by optimize_and_codegen (not module specific)
#[derive(Clone)]
pub struct CodegenContext<'ll> {
pub struct CodegenContext {
// Resources needed when running LTO
pub time_passes: bool,
pub lto: Lto,
......@@ -393,13 +392,10 @@ pub struct CodegenContext<'ll> {
// measuring is disabled.
time_graph: Option<TimeGraph>,
// The assembler command if no_integrated_as option is enabled, None otherwise
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 ()>
assembler_cmd: Option<Arc<AssemblerCommand>>
}
impl CodegenContext<'ll> {
impl CodegenContext {
pub fn create_diag_handler(&self) -> Handler {
Handler::with_emitter(true, false, Box::new(self.diag_emitter.clone()))
}
......@@ -428,12 +424,12 @@ pub(crate) fn save_temp_bitcode(&self, module: &ModuleCodegen, name: &str) {
}
pub struct DiagnosticHandlers<'a> {
data: *mut (&'a CodegenContext<'a>, &'a Handler),
data: *mut (&'a CodegenContext, &'a Handler),
llcx: &'a llvm::Context,
}
impl<'a> DiagnosticHandlers<'a> {
pub fn new(cgcx: &'a CodegenContext<'a>,
pub fn new(cgcx: &'a CodegenContext,
handler: &'a Handler,
llcx: &'a llvm::Context) -> Self {
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(),
debuginfo: tcx.sess.opts.debuginfo,
assembler_cmd,
phantom: PhantomData
};
// This is the "main loop" of parallel work happening for parallel codegen.
......@@ -2113,7 +2108,7 @@ fn maybe_start_llvm_timer(config: &ModuleConfig,
const LLVM_WORK_PACKAGE_KIND: time_graph::WorkPackageKind =
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();
thread::spawn(move || {
......
......@@ -72,7 +72,6 @@
pub use llvm_util::target_features;
use std::any::Any;
use std::sync::mpsc;
use std::marker::PhantomData;
use rustc_data_structures::sync::Lrc;
use rustc::dep_graph::DepGraph;
......@@ -274,7 +273,7 @@ struct ModuleCodegen {
/// as the crate name and disambiguator.
/// We currently generate these names via CodegenUnit::build_cgu_name().
name: String,
module_llvm: ModuleLlvm<'static>,
module_llvm: ModuleLlvm,
kind: ModuleKind,
}
......@@ -316,17 +315,16 @@ fn into_compiled_module(self,
}
}
struct ModuleLlvm<'ll> {
struct ModuleLlvm {
llcx: &'static mut llvm::Context,
llmod_raw: *const llvm::Module,
tm: &'static mut llvm::TargetMachine,
phantom: PhantomData<&'ll ()>
}
unsafe impl Send for ModuleLlvm<'ll> { }
unsafe impl Sync for ModuleLlvm<'ll> { }
unsafe impl Send for ModuleLlvm { }
unsafe impl Sync for ModuleLlvm { }
impl ModuleLlvm<'ll> {
impl ModuleLlvm {
fn new(sess: &Session, mod_name: &str) -> Self {
unsafe {
let llcx = llvm::LLVMRustContextCreate(sess.fewer_names());
......@@ -336,7 +334,6 @@ fn new(sess: &Session, mod_name: &str) -> Self {
llmod_raw,
llcx,
tm: create_target_machine(sess, false),
phantom: PhantomData
}
}
}
......@@ -348,7 +345,7 @@ fn llmod(&self) -> &llvm::Module {
}
}
impl Drop for ModuleLlvm<'ll> {
impl Drop for ModuleLlvm {
fn drop(&mut self) {
unsafe {
llvm::LLVMContextDispose(&mut *(self.llcx as *mut _));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册