mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-30 10:45:18 +00:00
rustc_codegen_llvm: move from empty enums to extern types.
This commit is contained in:
parent
077be49bde
commit
af04e9426c
@ -9,7 +9,6 @@
|
||||
// except according to those terms.
|
||||
|
||||
use std::ffi::CString;
|
||||
use std::ptr;
|
||||
|
||||
use attributes;
|
||||
use libc::c_uint;
|
||||
@ -90,7 +89,7 @@ pub(crate) unsafe fn codegen(tcx: TyCtxt, mods: &ModuleLlvm, kind: AllocatorKind
|
||||
callee,
|
||||
args.as_ptr(),
|
||||
args.len() as c_uint,
|
||||
ptr::null_mut(),
|
||||
None,
|
||||
"\0".as_ptr() as *const _);
|
||||
llvm::LLVMSetTailCall(ret, True);
|
||||
if output.is_some() {
|
||||
|
@ -14,7 +14,7 @@ use std::ffi::{CString, CStr};
|
||||
use std::io;
|
||||
use std::mem;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::ptr;
|
||||
use std::ptr::{self, NonNull};
|
||||
use std::str;
|
||||
|
||||
use back::bytecode::RLIB_BYTECODE_EXTENSION;
|
||||
@ -246,7 +246,7 @@ impl<'a> ArchiveBuilder<'a> {
|
||||
let name = CString::new(child_name)?;
|
||||
members.push(llvm::LLVMRustArchiveMemberNew(ptr::null(),
|
||||
name.as_ptr(),
|
||||
child.raw()));
|
||||
NonNull::new(child.raw())));
|
||||
strings.push(name);
|
||||
}
|
||||
}
|
||||
@ -257,7 +257,7 @@ impl<'a> ArchiveBuilder<'a> {
|
||||
let name = CString::new(name_in_archive)?;
|
||||
members.push(llvm::LLVMRustArchiveMemberNew(path.as_ptr(),
|
||||
name.as_ptr(),
|
||||
ptr::null_mut()));
|
||||
None));
|
||||
strings.push(path);
|
||||
strings.push(name);
|
||||
}
|
||||
@ -284,7 +284,7 @@ impl<'a> ArchiveBuilder<'a> {
|
||||
let name = CString::new(child_name)?;
|
||||
let m = llvm::LLVMRustArchiveMemberNew(ptr::null(),
|
||||
name.as_ptr(),
|
||||
child.raw());
|
||||
NonNull::new(child.raw()));
|
||||
members.push(m);
|
||||
strings.push(name);
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ use std::borrow::Cow;
|
||||
use std::ffi::CString;
|
||||
use std::ops::Range;
|
||||
use std::ptr;
|
||||
use std::ptr::NonNull;
|
||||
use syntax_pos::Span;
|
||||
|
||||
// All Builders must have an llfn associated with them
|
||||
@ -211,7 +212,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
.join(", "));
|
||||
|
||||
let args = self.check_call("invoke", llfn, args);
|
||||
let bundle = bundle.as_ref().map(|b| b.raw()).unwrap_or(ptr::null_mut());
|
||||
let bundle = bundle.as_ref().and_then(|b| NonNull::new(b.raw()));
|
||||
|
||||
unsafe {
|
||||
llvm::LLVMRustBuildInvoke(self.llbuilder,
|
||||
@ -909,7 +910,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
.join(", "));
|
||||
|
||||
let args = self.check_call("call", llfn, args);
|
||||
let bundle = bundle.as_ref().map(|b| b.raw()).unwrap_or(ptr::null_mut());
|
||||
let bundle = bundle.as_ref().and_then(|b| NonNull::new(b.raw()));
|
||||
|
||||
unsafe {
|
||||
llvm::LLVMRustBuildCall(self.llbuilder, llfn, args.as_ptr(),
|
||||
@ -1196,7 +1197,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
parent: Option<ValueRef>,
|
||||
args: &[ValueRef]) -> ValueRef {
|
||||
self.count_insn("cleanuppad");
|
||||
let parent = parent.unwrap_or(ptr::null_mut());
|
||||
let parent = parent.and_then(NonNull::new);
|
||||
let name = CString::new("cleanuppad").unwrap();
|
||||
let ret = unsafe {
|
||||
llvm::LLVMRustBuildCleanupPad(self.llbuilder,
|
||||
@ -1212,7 +1213,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
pub fn cleanup_ret(&self, cleanup: ValueRef,
|
||||
unwind: Option<BasicBlockRef>) -> ValueRef {
|
||||
self.count_insn("cleanupret");
|
||||
let unwind = unwind.unwrap_or(ptr::null_mut());
|
||||
let unwind = unwind.and_then(NonNull::new);
|
||||
let ret = unsafe {
|
||||
llvm::LLVMRustBuildCleanupRet(self.llbuilder, cleanup, unwind)
|
||||
};
|
||||
@ -1248,8 +1249,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
unwind: Option<BasicBlockRef>,
|
||||
num_handlers: usize) -> ValueRef {
|
||||
self.count_insn("catchswitch");
|
||||
let parent = parent.unwrap_or(ptr::null_mut());
|
||||
let unwind = unwind.unwrap_or(ptr::null_mut());
|
||||
let parent = parent.and_then(NonNull::new);
|
||||
let unwind = unwind.and_then(NonNull::new);
|
||||
let name = CString::new("catchswitch").unwrap();
|
||||
let ret = unsafe {
|
||||
llvm::LLVMRustBuildCatchSwitch(self.llbuilder, parent, unwind,
|
||||
|
@ -35,7 +35,6 @@ use rustc_target::spec::{HasTargetSpec, Target};
|
||||
|
||||
use std::ffi::{CStr, CString};
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::ptr;
|
||||
use std::iter;
|
||||
use std::str;
|
||||
use std::sync::Arc;
|
||||
@ -280,7 +279,9 @@ impl<'a, 'tcx> CodegenCx<'a, 'tcx> {
|
||||
None
|
||||
};
|
||||
|
||||
let mut cx = CodegenCx {
|
||||
let isize_ty = Type::ix_llcx(llcx, tcx.data_layout.pointer_size.bits());
|
||||
|
||||
CodegenCx {
|
||||
tcx,
|
||||
check_overflow,
|
||||
use_dll_storage_attrs,
|
||||
@ -300,16 +301,14 @@ impl<'a, 'tcx> CodegenCx<'a, 'tcx> {
|
||||
lltypes: RefCell::new(FxHashMap()),
|
||||
scalar_lltypes: RefCell::new(FxHashMap()),
|
||||
pointee_infos: RefCell::new(FxHashMap()),
|
||||
isize_ty: Type::from_ref(ptr::null_mut()),
|
||||
isize_ty,
|
||||
dbg_cx,
|
||||
eh_personality: Cell::new(None),
|
||||
eh_unwind_resume: Cell::new(None),
|
||||
rust_try_fn: Cell::new(None),
|
||||
intrinsics: RefCell::new(FxHashMap()),
|
||||
local_gen_sym_counter: Cell::new(0),
|
||||
};
|
||||
cx.isize_ty = Type::isize(&cx);
|
||||
cx
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,12 +13,12 @@ use super::metadata::file_metadata;
|
||||
use super::utils::{DIB, span_start};
|
||||
|
||||
use llvm;
|
||||
use llvm::debuginfo::DIScope;
|
||||
use llvm::debuginfo::DIScope_opaque;
|
||||
use common::CodegenCx;
|
||||
use rustc::mir::{Mir, SourceScope};
|
||||
use std::ptr::NonNull;
|
||||
|
||||
use libc::c_uint;
|
||||
use std::ptr;
|
||||
|
||||
use syntax_pos::Pos;
|
||||
|
||||
@ -29,7 +29,7 @@ use syntax_pos::BytePos;
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct MirDebugScope {
|
||||
pub scope_metadata: DIScope,
|
||||
pub scope_metadata: Option<NonNull<DIScope_opaque>>,
|
||||
// Start and end offsets of the file to which this DIScope belongs.
|
||||
// These are used to quickly determine whether some span refers to the same file.
|
||||
pub file_start_pos: BytePos,
|
||||
@ -38,7 +38,7 @@ pub struct MirDebugScope {
|
||||
|
||||
impl MirDebugScope {
|
||||
pub fn is_valid(&self) -> bool {
|
||||
!self.scope_metadata.is_null()
|
||||
!self.scope_metadata.is_none()
|
||||
}
|
||||
}
|
||||
|
||||
@ -47,7 +47,7 @@ impl MirDebugScope {
|
||||
pub fn create_mir_scopes(cx: &CodegenCx, mir: &Mir, debug_context: &FunctionDebugContext)
|
||||
-> IndexVec<SourceScope, MirDebugScope> {
|
||||
let null_scope = MirDebugScope {
|
||||
scope_metadata: ptr::null_mut(),
|
||||
scope_metadata: None,
|
||||
file_start_pos: BytePos(0),
|
||||
file_end_pos: BytePos(0)
|
||||
};
|
||||
@ -95,7 +95,7 @@ fn make_mir_scope(cx: &CodegenCx,
|
||||
// The root is the function itself.
|
||||
let loc = span_start(cx, mir.span);
|
||||
scopes[scope] = MirDebugScope {
|
||||
scope_metadata: debug_context.fn_metadata,
|
||||
scope_metadata: NonNull::new(debug_context.fn_metadata),
|
||||
file_start_pos: loc.file.start_pos,
|
||||
file_end_pos: loc.file.end_pos,
|
||||
};
|
||||
@ -109,7 +109,7 @@ fn make_mir_scope(cx: &CodegenCx,
|
||||
// However, we don't skip creating a nested scope if
|
||||
// our parent is the root, because we might want to
|
||||
// put arguments in the root and not have shadowing.
|
||||
if parent_scope.scope_metadata != debug_context.fn_metadata {
|
||||
if parent_scope.scope_metadata.unwrap().as_ptr() != debug_context.fn_metadata {
|
||||
scopes[scope] = parent_scope;
|
||||
return;
|
||||
}
|
||||
@ -121,12 +121,12 @@ fn make_mir_scope(cx: &CodegenCx,
|
||||
debug_context.defining_crate);
|
||||
|
||||
let scope_metadata = unsafe {
|
||||
llvm::LLVMRustDIBuilderCreateLexicalBlock(
|
||||
NonNull::new(llvm::LLVMRustDIBuilderCreateLexicalBlock(
|
||||
DIB(cx),
|
||||
parent_scope.scope_metadata,
|
||||
parent_scope.scope_metadata.unwrap().as_ptr(),
|
||||
file_metadata,
|
||||
loc.line as c_uint,
|
||||
loc.col.to_usize() as c_uint)
|
||||
loc.col.to_usize() as c_uint))
|
||||
};
|
||||
scopes[scope] = MirDebugScope {
|
||||
scope_metadata,
|
||||
|
@ -18,7 +18,6 @@ use declare;
|
||||
use type_::Type;
|
||||
use rustc::session::config::NoDebugInfo;
|
||||
|
||||
use std::ptr;
|
||||
use syntax::attr;
|
||||
|
||||
|
||||
@ -50,7 +49,7 @@ pub fn get_or_insert_gdb_debug_scripts_section_global(cx: &CodegenCx)
|
||||
c_section_var_name.as_ptr() as *const _)
|
||||
};
|
||||
|
||||
if section_var == ptr::null_mut() {
|
||||
if section_var.is_null() {
|
||||
let section_name = b".debug_gdb_scripts\0";
|
||||
let section_contents = b"\x01gdb_load_rust_pretty_printers.py\0";
|
||||
|
||||
|
@ -20,7 +20,7 @@ use super::{CrateDebugContext};
|
||||
use abi;
|
||||
|
||||
use llvm::{self, ValueRef};
|
||||
use llvm::debuginfo::{DIType, DIFile, DIScope, DIDescriptor,
|
||||
use llvm::debuginfo::{DIType, DIFile, DIScope_opaque, DIScope, DIDescriptor,
|
||||
DICompositeType, DILexicalBlock, DIFlags};
|
||||
|
||||
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
||||
@ -41,6 +41,7 @@ use std::ffi::CString;
|
||||
use std::fmt::Write;
|
||||
use std::iter;
|
||||
use std::ptr;
|
||||
use std::ptr::NonNull;
|
||||
use std::path::{Path, PathBuf};
|
||||
use syntax::ast;
|
||||
use syntax::symbol::{Interner, InternedString, Symbol};
|
||||
@ -64,8 +65,7 @@ const DW_ATE_unsigned_char: c_uint = 0x08;
|
||||
pub const UNKNOWN_LINE_NUMBER: c_uint = 0;
|
||||
pub const UNKNOWN_COLUMN_NUMBER: c_uint = 0;
|
||||
|
||||
// ptr::null() doesn't work :(
|
||||
pub const NO_SCOPE_METADATA: DIScope = (0 as DIScope);
|
||||
pub const NO_SCOPE_METADATA: Option<NonNull<DIScope_opaque>> = None;
|
||||
|
||||
#[derive(Copy, Debug, Hash, Eq, PartialEq, Clone)]
|
||||
pub struct UniqueTypeId(ast::Name);
|
||||
@ -289,7 +289,7 @@ fn fixed_vec_metadata<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
|
||||
};
|
||||
|
||||
let subrange = unsafe {
|
||||
llvm::LLVMRustDIBuilderGetOrCreateSubrange(DIB(cx), 0, upper_bound)
|
||||
NonNull::new(llvm::LLVMRustDIBuilderGetOrCreateSubrange(DIB(cx), 0, upper_bound))
|
||||
};
|
||||
|
||||
let subscripts = create_DIArray(DIB(cx), &[subrange]);
|
||||
@ -365,15 +365,17 @@ fn subroutine_type_metadata<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
|
||||
&signature,
|
||||
);
|
||||
|
||||
let signature_metadata: Vec<DIType> = iter::once(
|
||||
let signature_metadata: Vec<_> = iter::once(
|
||||
// return type
|
||||
match signature.output().sty {
|
||||
ty::TyTuple(ref tys) if tys.is_empty() => ptr::null_mut(),
|
||||
_ => type_metadata(cx, signature.output(), span)
|
||||
ty::TyTuple(ref tys) if tys.is_empty() => None,
|
||||
_ => NonNull::new(type_metadata(cx, signature.output(), span))
|
||||
}
|
||||
).chain(
|
||||
// regular arguments
|
||||
signature.inputs().iter().map(|argument_type| type_metadata(cx, argument_type, span))
|
||||
signature.inputs().iter().map(|argument_type| {
|
||||
NonNull::new(type_metadata(cx, argument_type, span))
|
||||
})
|
||||
).collect();
|
||||
|
||||
return_if_metadata_created_in_meantime!(cx, unique_type_id);
|
||||
@ -406,7 +408,7 @@ fn trait_pointer_metadata<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
|
||||
let containing_scope = match trait_type.sty {
|
||||
ty::TyDynamic(ref data, ..) => if let Some(principal) = data.principal() {
|
||||
let def_id = principal.def_id();
|
||||
get_namespace_for_item(cx, def_id)
|
||||
NonNull::new(get_namespace_for_item(cx, def_id))
|
||||
} else {
|
||||
NO_SCOPE_METADATA
|
||||
},
|
||||
@ -985,7 +987,7 @@ fn prepare_struct_metadata<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
|
||||
struct_type,
|
||||
&struct_name,
|
||||
unique_type_id,
|
||||
containing_scope);
|
||||
NonNull::new(containing_scope));
|
||||
|
||||
create_and_register_recursive_type_forward_declaration(
|
||||
cx,
|
||||
@ -1317,7 +1319,7 @@ fn describe_enum_variant<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
|
||||
layout.ty,
|
||||
&variant_name,
|
||||
unique_type_id,
|
||||
containing_scope);
|
||||
NonNull::new(containing_scope));
|
||||
|
||||
// If this is not a univariant enum, there is also the discriminant field.
|
||||
let (discr_offset, discr_arg) = match discriminant_info {
|
||||
@ -1376,17 +1378,17 @@ fn prepare_enum_metadata<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
|
||||
let file_metadata = unknown_file_metadata(cx);
|
||||
|
||||
let def = enum_type.ty_adt_def().unwrap();
|
||||
let enumerators_metadata: Vec<DIDescriptor> = def.discriminants(cx.tcx)
|
||||
let enumerators_metadata: Vec<_> = def.discriminants(cx.tcx)
|
||||
.zip(&def.variants)
|
||||
.map(|(discr, v)| {
|
||||
let token = v.name.as_str();
|
||||
let name = CString::new(token.as_bytes()).unwrap();
|
||||
unsafe {
|
||||
llvm::LLVMRustDIBuilderCreateEnumerator(
|
||||
NonNull::new(llvm::LLVMRustDIBuilderCreateEnumerator(
|
||||
DIB(cx),
|
||||
name.as_ptr(),
|
||||
// FIXME: what if enumeration has i128 discriminant?
|
||||
discr.val as u64)
|
||||
discr.val as u64))
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
@ -1459,7 +1461,7 @@ fn prepare_enum_metadata<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
|
||||
enum_type_size.bits(),
|
||||
enum_type_align.abi_bits() as u32,
|
||||
DIFlags::FlagZero,
|
||||
ptr::null_mut(),
|
||||
None,
|
||||
0, // RuntimeLang
|
||||
unique_type_id_str.as_ptr())
|
||||
};
|
||||
@ -1494,7 +1496,7 @@ fn composite_type_metadata<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
|
||||
composite_type_name: &str,
|
||||
composite_type_unique_id: UniqueTypeId,
|
||||
member_descriptions: &[MemberDescription],
|
||||
containing_scope: DIScope,
|
||||
containing_scope: Option<NonNull<DIScope_opaque>>,
|
||||
|
||||
// Ignore source location information as long as it
|
||||
// can't be reconstructed for non-local crates.
|
||||
@ -1535,13 +1537,13 @@ fn set_members_of_composite_type(cx: &CodegenCx,
|
||||
}
|
||||
}
|
||||
|
||||
let member_metadata: Vec<DIDescriptor> = member_descriptions
|
||||
let member_metadata: Vec<_> = member_descriptions
|
||||
.iter()
|
||||
.map(|member_description| {
|
||||
let member_name = member_description.name.as_bytes();
|
||||
let member_name = CString::new(member_name).unwrap();
|
||||
unsafe {
|
||||
llvm::LLVMRustDIBuilderCreateMemberType(
|
||||
NonNull::new(llvm::LLVMRustDIBuilderCreateMemberType(
|
||||
DIB(cx),
|
||||
composite_type_metadata,
|
||||
member_name.as_ptr(),
|
||||
@ -1551,7 +1553,7 @@ fn set_members_of_composite_type(cx: &CodegenCx,
|
||||
member_description.align.abi_bits() as u32,
|
||||
member_description.offset.bits(),
|
||||
member_description.flags,
|
||||
member_description.type_metadata)
|
||||
member_description.type_metadata))
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
@ -1570,7 +1572,7 @@ fn create_struct_stub<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
|
||||
struct_type: Ty<'tcx>,
|
||||
struct_type_name: &str,
|
||||
unique_type_id: UniqueTypeId,
|
||||
containing_scope: DIScope)
|
||||
containing_scope: Option<NonNull<DIScope_opaque>>)
|
||||
-> DICompositeType {
|
||||
let (struct_size, struct_align) = cx.size_and_align_of(struct_type);
|
||||
|
||||
@ -1593,10 +1595,10 @@ fn create_struct_stub<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
|
||||
struct_size.bits(),
|
||||
struct_align.abi_bits() as u32,
|
||||
DIFlags::FlagZero,
|
||||
ptr::null_mut(),
|
||||
None,
|
||||
empty_array,
|
||||
0,
|
||||
ptr::null_mut(),
|
||||
None,
|
||||
unique_type_id.as_ptr())
|
||||
};
|
||||
|
||||
@ -1630,7 +1632,7 @@ fn create_union_stub<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
|
||||
union_size.bits(),
|
||||
union_align.abi_bits() as u32,
|
||||
DIFlags::FlagZero,
|
||||
empty_array,
|
||||
NonNull::new(empty_array),
|
||||
0, // RuntimeLang
|
||||
unique_type_id.as_ptr())
|
||||
};
|
||||
@ -1684,7 +1686,7 @@ pub fn create_global_var_metadata(cx: &CodegenCx,
|
||||
|
||||
unsafe {
|
||||
llvm::LLVMRustDIBuilderCreateStaticVariable(DIB(cx),
|
||||
var_scope,
|
||||
NonNull::new(var_scope),
|
||||
var_name.as_ptr(),
|
||||
// If null, linkage_name field is omitted,
|
||||
// which is what we want for no_mangle statics
|
||||
@ -1695,7 +1697,7 @@ pub fn create_global_var_metadata(cx: &CodegenCx,
|
||||
type_metadata,
|
||||
is_local_to_unit,
|
||||
global,
|
||||
ptr::null_mut(),
|
||||
None,
|
||||
global_align.abi() as u32,
|
||||
);
|
||||
}
|
||||
@ -1749,10 +1751,10 @@ pub fn create_vtable_metadata<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
|
||||
Size::ZERO.bits(),
|
||||
cx.tcx.data_layout.pointer_align.abi_bits() as u32,
|
||||
DIFlags::FlagArtificial,
|
||||
ptr::null_mut(),
|
||||
None,
|
||||
empty_array,
|
||||
0,
|
||||
type_metadata,
|
||||
NonNull::new(type_metadata),
|
||||
name.as_ptr()
|
||||
);
|
||||
|
||||
@ -1771,7 +1773,7 @@ pub fn create_vtable_metadata<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
|
||||
vtable_type,
|
||||
true,
|
||||
vtable,
|
||||
ptr::null_mut(),
|
||||
None,
|
||||
0);
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ use rustc::util::nodemap::{DefIdMap, FxHashMap, FxHashSet};
|
||||
use libc::c_uint;
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::ffi::CString;
|
||||
use std::ptr;
|
||||
use std::ptr::NonNull;
|
||||
|
||||
use syntax_pos::{self, Span, Pos};
|
||||
use syntax::ast;
|
||||
@ -290,7 +290,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
|
||||
cx.sess().opts.optimize != config::OptLevel::No,
|
||||
llfn,
|
||||
template_parameters,
|
||||
ptr::null_mut())
|
||||
None)
|
||||
};
|
||||
|
||||
// Initialize fn debug context (including scope map and namespace map)
|
||||
@ -312,8 +312,8 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
|
||||
|
||||
// Return type -- llvm::DIBuilder wants this at index 0
|
||||
signature.push(match sig.output().sty {
|
||||
ty::TyTuple(ref tys) if tys.is_empty() => ptr::null_mut(),
|
||||
_ => type_metadata(cx, sig.output(), syntax_pos::DUMMY_SP)
|
||||
ty::TyTuple(ref tys) if tys.is_empty() => None,
|
||||
_ => NonNull::new(type_metadata(cx, sig.output(), syntax_pos::DUMMY_SP))
|
||||
});
|
||||
|
||||
let inputs = if sig.abi == Abi::RustCall {
|
||||
@ -342,19 +342,20 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
|
||||
}
|
||||
_ => t
|
||||
};
|
||||
type_metadata(cx, t, syntax_pos::DUMMY_SP)
|
||||
NonNull::new(type_metadata(cx, t, syntax_pos::DUMMY_SP))
|
||||
}));
|
||||
} else {
|
||||
signature.extend(inputs.iter().map(|t| {
|
||||
type_metadata(cx, t, syntax_pos::DUMMY_SP)
|
||||
NonNull::new(type_metadata(cx, t, syntax_pos::DUMMY_SP))
|
||||
}));
|
||||
}
|
||||
|
||||
if sig.abi == Abi::RustCall && !sig.inputs().is_empty() {
|
||||
if let ty::TyTuple(args) = sig.inputs()[sig.inputs().len() - 1].sty {
|
||||
signature.extend(
|
||||
args.iter().map(|argument_type|
|
||||
type_metadata(cx, argument_type, syntax_pos::DUMMY_SP))
|
||||
args.iter().map(|argument_type| {
|
||||
NonNull::new(type_metadata(cx, argument_type, syntax_pos::DUMMY_SP))
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -398,14 +399,14 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
|
||||
type_metadata(cx, actual_type, syntax_pos::DUMMY_SP);
|
||||
let name = CString::new(name.as_str().as_bytes()).unwrap();
|
||||
Some(unsafe {
|
||||
llvm::LLVMRustDIBuilderCreateTemplateTypeParameter(
|
||||
NonNull::new(llvm::LLVMRustDIBuilderCreateTemplateTypeParameter(
|
||||
DIB(cx),
|
||||
ptr::null_mut(),
|
||||
None,
|
||||
name.as_ptr(),
|
||||
actual_type_metadata,
|
||||
file_metadata,
|
||||
0,
|
||||
0)
|
||||
0))
|
||||
})
|
||||
} else {
|
||||
None
|
||||
|
@ -22,7 +22,7 @@ use rustc::hir::map::DefPathData;
|
||||
use common::CodegenCx;
|
||||
|
||||
use std::ffi::CString;
|
||||
use std::ptr;
|
||||
use std::ptr::NonNull;
|
||||
|
||||
pub fn mangled_name_of_instance<'a, 'tcx>(
|
||||
cx: &CodegenCx<'a, 'tcx>,
|
||||
@ -38,11 +38,11 @@ pub fn item_namespace(cx: &CodegenCx, def_id: DefId) -> DIScope {
|
||||
}
|
||||
|
||||
let def_key = cx.tcx.def_key(def_id);
|
||||
let parent_scope = def_key.parent.map_or(ptr::null_mut(), |parent| {
|
||||
item_namespace(cx, DefId {
|
||||
let parent_scope = def_key.parent.and_then(|parent| {
|
||||
NonNull::new(item_namespace(cx, DefId {
|
||||
krate: def_id.krate,
|
||||
index: parent
|
||||
})
|
||||
}))
|
||||
});
|
||||
|
||||
let namespace_name = match def_key.disambiguated_data.data {
|
||||
|
@ -15,18 +15,18 @@ use super::metadata::UNKNOWN_COLUMN_NUMBER;
|
||||
use super::FunctionDebugContext;
|
||||
|
||||
use llvm;
|
||||
use llvm::debuginfo::DIScope;
|
||||
use llvm::debuginfo::{DIScope_opaque, DIScope};
|
||||
use builder::Builder;
|
||||
|
||||
use libc::c_uint;
|
||||
use std::ptr;
|
||||
use std::ptr::NonNull;
|
||||
use syntax_pos::{Span, Pos};
|
||||
|
||||
/// Sets the current debug location at the beginning of the span.
|
||||
///
|
||||
/// Maps to a call to llvm::LLVMSetCurrentDebugLocation(...).
|
||||
pub fn set_source_location(
|
||||
debug_context: &FunctionDebugContext, bx: &Builder, scope: DIScope, span: Span
|
||||
debug_context: &FunctionDebugContext, bx: &Builder, scope: Option<NonNull<DIScope_opaque>>, span: Span
|
||||
) {
|
||||
let function_debug_context = match *debug_context {
|
||||
FunctionDebugContext::DebugInfoDisabled => return,
|
||||
@ -40,7 +40,7 @@ pub fn set_source_location(
|
||||
let dbg_loc = if function_debug_context.source_locations_enabled.get() {
|
||||
debug!("set_source_location: {}", bx.sess().codemap().span_to_string(span));
|
||||
let loc = span_start(bx.cx, span);
|
||||
InternalDebugLocation::new(scope, loc.line, loc.col.to_usize())
|
||||
InternalDebugLocation::new(scope.unwrap().as_ptr(), loc.line, loc.col.to_usize())
|
||||
} else {
|
||||
UnknownLocation
|
||||
};
|
||||
@ -93,17 +93,17 @@ pub fn set_debug_location(bx: &Builder, debug_location: InternalDebugLocation) {
|
||||
debug!("setting debug location to {} {}", line, col);
|
||||
|
||||
unsafe {
|
||||
llvm::LLVMRustDIBuilderCreateDebugLocation(
|
||||
NonNull::new(llvm::LLVMRustDIBuilderCreateDebugLocation(
|
||||
debug_context(bx.cx).llcontext,
|
||||
line as c_uint,
|
||||
col_used,
|
||||
scope,
|
||||
ptr::null_mut())
|
||||
None))
|
||||
}
|
||||
}
|
||||
UnknownLocation => {
|
||||
debug!("clearing debug location ");
|
||||
ptr::null_mut()
|
||||
None
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -17,9 +17,10 @@ use rustc::hir::def_id::DefId;
|
||||
use rustc::ty::DefIdTree;
|
||||
|
||||
use llvm;
|
||||
use llvm::debuginfo::{DIScope, DIBuilderRef, DIDescriptor, DIArray};
|
||||
use llvm::debuginfo::{DIScope, DIBuilderRef, DIDescriptor_opaque, DIArray};
|
||||
use common::{CodegenCx};
|
||||
|
||||
use std::ptr::NonNull;
|
||||
use syntax_pos::{self, Span};
|
||||
|
||||
pub fn is_node_local_to_unit(cx: &CodegenCx, def_id: DefId) -> bool
|
||||
@ -36,7 +37,7 @@ pub fn is_node_local_to_unit(cx: &CodegenCx, def_id: DefId) -> bool
|
||||
}
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
pub fn create_DIArray(builder: DIBuilderRef, arr: &[DIDescriptor]) -> DIArray {
|
||||
pub fn create_DIArray(builder: DIBuilderRef, arr: &[Option<NonNull<DIDescriptor_opaque>>]) -> DIArray {
|
||||
return unsafe {
|
||||
llvm::LLVMRustDIBuilderGetOrCreateArray(builder, arr.as_ptr(), arr.len() as u32)
|
||||
};
|
||||
|
@ -21,6 +21,7 @@
|
||||
#![feature(box_patterns)]
|
||||
#![feature(box_syntax)]
|
||||
#![feature(custom_attribute)]
|
||||
#![feature(extern_types)]
|
||||
#![feature(fs_read_write)]
|
||||
#![allow(unused_attributes)]
|
||||
#![feature(libc)]
|
||||
|
@ -14,7 +14,6 @@ pub use self::OptimizationDiagnosticKind::*;
|
||||
pub use self::Diagnostic::*;
|
||||
|
||||
use libc::c_uint;
|
||||
use std::ptr;
|
||||
|
||||
use super::{DiagnosticInfoRef, TwineRef, ValueRef};
|
||||
|
||||
@ -56,7 +55,7 @@ impl OptimizationDiagnostic {
|
||||
unsafe fn unpack(kind: OptimizationDiagnosticKind,
|
||||
di: DiagnosticInfoRef)
|
||||
-> OptimizationDiagnostic {
|
||||
let mut function = ptr::null_mut();
|
||||
let mut function = 0 as *mut _;
|
||||
let mut line = 0;
|
||||
let mut column = 0;
|
||||
|
||||
@ -105,8 +104,8 @@ impl InlineAsmDiagnostic {
|
||||
|
||||
let mut opt = InlineAsmDiagnostic {
|
||||
cookie: 0,
|
||||
message: ptr::null_mut(),
|
||||
instruction: ptr::null_mut(),
|
||||
message: 0 as *mut _,
|
||||
instruction: 0 as *mut _,
|
||||
};
|
||||
|
||||
super::LLVMRustUnpackInlineAsmDiagnostic(di,
|
||||
|
@ -15,15 +15,17 @@
|
||||
// https://reviews.llvm.org/D26769
|
||||
|
||||
use super::debuginfo::{
|
||||
DIBuilderRef, DIDescriptor, DIFile, DILexicalBlock, DISubprogram, DIType,
|
||||
DIBasicType, DIDerivedType, DICompositeType, DIScope, DIVariable,
|
||||
DIGlobalVariable, DIArray, DISubrange, DITemplateTypeParameter, DIEnumerator,
|
||||
DIBuilderRef, DIDescriptor_opaque, DIDescriptor, DIFile, DILexicalBlock, DISubprogram, DIType_opaque,
|
||||
DIType, DIBasicType, DIDerivedType, DICompositeType, DIScope_opaque, DIScope, DIVariable,
|
||||
DIGlobalVariable, DIArray_opaque, DIArray, DISubrange, DITemplateTypeParameter, DIEnumerator,
|
||||
DINameSpace, DIFlags,
|
||||
};
|
||||
|
||||
use libc::{c_uint, c_int, size_t, c_char};
|
||||
use libc::{c_longlong, c_ulonglong, c_void};
|
||||
|
||||
use std::ptr::NonNull;
|
||||
|
||||
use super::RustStringRef;
|
||||
|
||||
pub type Opcode = u32;
|
||||
@ -348,10 +350,10 @@ pub enum PassKind {
|
||||
}
|
||||
|
||||
/// LLVMRustThinLTOData
|
||||
pub enum ThinLTOData {}
|
||||
extern { pub type ThinLTOData; }
|
||||
|
||||
/// LLVMRustThinLTOBuffer
|
||||
pub enum ThinLTOBuffer {}
|
||||
extern { pub type ThinLTOBuffer; }
|
||||
|
||||
/// LLVMRustThinLTOModule
|
||||
#[repr(C)]
|
||||
@ -373,83 +375,59 @@ pub enum ThreadLocalMode {
|
||||
}
|
||||
|
||||
// Opaque pointer types
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub enum Module_opaque {}
|
||||
extern { pub type Module_opaque; }
|
||||
pub type ModuleRef = *mut Module_opaque;
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub enum Context_opaque {}
|
||||
extern { pub type Context_opaque; }
|
||||
pub type ContextRef = *mut Context_opaque;
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub enum Type_opaque {}
|
||||
extern { pub type Type_opaque; }
|
||||
pub type TypeRef = *mut Type_opaque;
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub enum Value_opaque {}
|
||||
extern { pub type Value_opaque; }
|
||||
pub type ValueRef = *mut Value_opaque;
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub enum Metadata_opaque {}
|
||||
extern { pub type Metadata_opaque; }
|
||||
pub type MetadataRef = *mut Metadata_opaque;
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub enum BasicBlock_opaque {}
|
||||
extern { pub type BasicBlock_opaque; }
|
||||
pub type BasicBlockRef = *mut BasicBlock_opaque;
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub enum Builder_opaque {}
|
||||
extern { pub type Builder_opaque; }
|
||||
pub type BuilderRef = *mut Builder_opaque;
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub enum ExecutionEngine_opaque {}
|
||||
extern { pub type ExecutionEngine_opaque; }
|
||||
pub type ExecutionEngineRef = *mut ExecutionEngine_opaque;
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub enum MemoryBuffer_opaque {}
|
||||
extern { pub type MemoryBuffer_opaque; }
|
||||
pub type MemoryBufferRef = *mut MemoryBuffer_opaque;
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub enum PassManager_opaque {}
|
||||
extern { pub type PassManager_opaque; }
|
||||
pub type PassManagerRef = *mut PassManager_opaque;
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub enum PassManagerBuilder_opaque {}
|
||||
extern { pub type PassManagerBuilder_opaque; }
|
||||
pub type PassManagerBuilderRef = *mut PassManagerBuilder_opaque;
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub enum Use_opaque {}
|
||||
extern { pub type Use_opaque; }
|
||||
pub type UseRef = *mut Use_opaque;
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub enum TargetData_opaque {}
|
||||
extern { pub type TargetData_opaque; }
|
||||
pub type TargetDataRef = *mut TargetData_opaque;
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub enum ObjectFile_opaque {}
|
||||
extern { pub type ObjectFile_opaque; }
|
||||
pub type ObjectFileRef = *mut ObjectFile_opaque;
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub enum SectionIterator_opaque {}
|
||||
extern { pub type SectionIterator_opaque; }
|
||||
pub type SectionIteratorRef = *mut SectionIterator_opaque;
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub enum Pass_opaque {}
|
||||
extern { pub type Pass_opaque; }
|
||||
pub type PassRef = *mut Pass_opaque;
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub enum TargetMachine_opaque {}
|
||||
extern { pub type TargetMachine_opaque; }
|
||||
pub type TargetMachineRef = *mut TargetMachine_opaque;
|
||||
pub enum Archive_opaque {}
|
||||
extern { pub type Archive_opaque; }
|
||||
pub type ArchiveRef = *mut Archive_opaque;
|
||||
pub enum ArchiveIterator_opaque {}
|
||||
extern { pub type ArchiveIterator_opaque; }
|
||||
pub type ArchiveIteratorRef = *mut ArchiveIterator_opaque;
|
||||
pub enum ArchiveChild_opaque {}
|
||||
extern { pub type ArchiveChild_opaque; }
|
||||
pub type ArchiveChildRef = *mut ArchiveChild_opaque;
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub enum Twine_opaque {}
|
||||
extern { pub type Twine_opaque; }
|
||||
pub type TwineRef = *mut Twine_opaque;
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub enum DiagnosticInfo_opaque {}
|
||||
extern { pub type DiagnosticInfo_opaque; }
|
||||
pub type DiagnosticInfoRef = *mut DiagnosticInfo_opaque;
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub enum DebugLoc_opaque {}
|
||||
extern { pub type DebugLoc_opaque; }
|
||||
pub type DebugLocRef = *mut DebugLoc_opaque;
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub enum SMDiagnostic_opaque {}
|
||||
extern { pub type SMDiagnostic_opaque; }
|
||||
pub type SMDiagnosticRef = *mut SMDiagnostic_opaque;
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub enum RustArchiveMember_opaque {}
|
||||
extern { pub type RustArchiveMember_opaque; }
|
||||
pub type RustArchiveMemberRef = *mut RustArchiveMember_opaque;
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub enum OperandBundleDef_opaque {}
|
||||
extern { pub type OperandBundleDef_opaque; }
|
||||
pub type OperandBundleDefRef = *mut OperandBundleDef_opaque;
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub enum Linker_opaque {}
|
||||
extern { pub type Linker_opaque; }
|
||||
pub type LinkerRef = *mut Linker_opaque;
|
||||
|
||||
pub type DiagnosticHandler = unsafe extern "C" fn(DiagnosticInfoRef, *mut c_void);
|
||||
@ -457,26 +435,29 @@ pub type InlineAsmDiagHandler = unsafe extern "C" fn(SMDiagnosticRef, *const c_v
|
||||
|
||||
|
||||
pub mod debuginfo {
|
||||
use super::MetadataRef;
|
||||
use super::Metadata_opaque;
|
||||
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub enum DIBuilder_opaque {}
|
||||
extern { pub type DIBuilder_opaque; }
|
||||
pub type DIBuilderRef = *mut DIBuilder_opaque;
|
||||
|
||||
pub type DIDescriptor = MetadataRef;
|
||||
pub type DIScope = DIDescriptor;
|
||||
pub type DIDescriptor_opaque = Metadata_opaque;
|
||||
pub type DIDescriptor = *mut DIDescriptor_opaque;
|
||||
pub type DIScope_opaque = DIDescriptor_opaque;
|
||||
pub type DIScope = *mut DIScope_opaque;
|
||||
pub type DILocation = DIDescriptor;
|
||||
pub type DIFile = DIScope;
|
||||
pub type DILexicalBlock = DIScope;
|
||||
pub type DISubprogram = DIScope;
|
||||
pub type DINameSpace = DIScope;
|
||||
pub type DIType = DIDescriptor;
|
||||
pub type DIType_opaque = DIDescriptor_opaque;
|
||||
pub type DIType = *mut DIType_opaque;
|
||||
pub type DIBasicType = DIType;
|
||||
pub type DIDerivedType = DIType;
|
||||
pub type DICompositeType = DIDerivedType;
|
||||
pub type DIVariable = DIDescriptor;
|
||||
pub type DIGlobalVariable = DIDescriptor;
|
||||
pub type DIArray = DIDescriptor;
|
||||
pub type DIArray_opaque = DIDescriptor_opaque;
|
||||
pub type DIArray = *mut DIArray_opaque;
|
||||
pub type DISubrange = DIDescriptor;
|
||||
pub type DIEnumerator = DIDescriptor;
|
||||
pub type DITemplateTypeParameter = DIDescriptor;
|
||||
@ -512,8 +493,9 @@ pub mod debuginfo {
|
||||
}
|
||||
}
|
||||
|
||||
pub enum ModuleBuffer {}
|
||||
extern { pub type ModuleBuffer; }
|
||||
|
||||
#[allow(improper_ctypes)] // TODO remove this (use for NonNull)
|
||||
extern "C" {
|
||||
// Create and destroy contexts.
|
||||
pub fn LLVMRustContextCreate(shouldDiscardNames: bool) -> ContextRef;
|
||||
@ -793,7 +775,7 @@ extern "C" {
|
||||
pub fn LLVMDisposeBuilder(Builder: BuilderRef);
|
||||
|
||||
// Metadata
|
||||
pub fn LLVMSetCurrentDebugLocation(Builder: BuilderRef, L: ValueRef);
|
||||
pub fn LLVMSetCurrentDebugLocation(Builder: BuilderRef, L: Option<NonNull<Value_opaque>>);
|
||||
pub fn LLVMGetCurrentDebugLocation(Builder: BuilderRef) -> ValueRef;
|
||||
pub fn LLVMSetInstDebugLocation(Builder: BuilderRef, Inst: ValueRef);
|
||||
|
||||
@ -819,7 +801,7 @@ extern "C" {
|
||||
NumArgs: c_uint,
|
||||
Then: BasicBlockRef,
|
||||
Catch: BasicBlockRef,
|
||||
Bundle: OperandBundleDefRef,
|
||||
Bundle: Option<NonNull<OperandBundleDef_opaque>>,
|
||||
Name: *const c_char)
|
||||
-> ValueRef;
|
||||
pub fn LLVMBuildLandingPad(B: BuilderRef,
|
||||
@ -832,14 +814,14 @@ extern "C" {
|
||||
pub fn LLVMBuildUnreachable(B: BuilderRef) -> ValueRef;
|
||||
|
||||
pub fn LLVMRustBuildCleanupPad(B: BuilderRef,
|
||||
ParentPad: ValueRef,
|
||||
ParentPad: Option<NonNull<Value_opaque>>,
|
||||
ArgCnt: c_uint,
|
||||
Args: *const ValueRef,
|
||||
Name: *const c_char)
|
||||
-> ValueRef;
|
||||
pub fn LLVMRustBuildCleanupRet(B: BuilderRef,
|
||||
CleanupPad: ValueRef,
|
||||
UnwindBB: BasicBlockRef)
|
||||
UnwindBB: Option<NonNull<BasicBlock_opaque>>)
|
||||
-> ValueRef;
|
||||
pub fn LLVMRustBuildCatchPad(B: BuilderRef,
|
||||
ParentPad: ValueRef,
|
||||
@ -849,8 +831,8 @@ extern "C" {
|
||||
-> ValueRef;
|
||||
pub fn LLVMRustBuildCatchRet(B: BuilderRef, Pad: ValueRef, BB: BasicBlockRef) -> ValueRef;
|
||||
pub fn LLVMRustBuildCatchSwitch(Builder: BuilderRef,
|
||||
ParentPad: ValueRef,
|
||||
BB: BasicBlockRef,
|
||||
ParentPad: Option<NonNull<Value_opaque>>,
|
||||
BB: Option<NonNull<BasicBlock_opaque>>,
|
||||
NumHandlers: c_uint,
|
||||
Name: *const c_char)
|
||||
-> ValueRef;
|
||||
@ -1161,7 +1143,7 @@ extern "C" {
|
||||
Fn: ValueRef,
|
||||
Args: *const ValueRef,
|
||||
NumArgs: c_uint,
|
||||
Bundle: OperandBundleDefRef,
|
||||
Bundle: Option<NonNull<OperandBundleDef_opaque>>,
|
||||
Name: *const c_char)
|
||||
-> ValueRef;
|
||||
pub fn LLVMBuildSelect(B: BuilderRef,
|
||||
@ -1433,7 +1415,7 @@ extern "C" {
|
||||
isOptimized: bool,
|
||||
Fn: ValueRef,
|
||||
TParam: DIArray,
|
||||
Decl: DIDescriptor)
|
||||
Decl: Option<NonNull<DIDescriptor_opaque>>)
|
||||
-> DISubprogram;
|
||||
|
||||
pub fn LLVMRustDIBuilderCreateBasicType(Builder: DIBuilderRef,
|
||||
@ -1451,17 +1433,17 @@ extern "C" {
|
||||
-> DIDerivedType;
|
||||
|
||||
pub fn LLVMRustDIBuilderCreateStructType(Builder: DIBuilderRef,
|
||||
Scope: DIDescriptor,
|
||||
Scope: Option<NonNull<DIDescriptor_opaque>>,
|
||||
Name: *const c_char,
|
||||
File: DIFile,
|
||||
LineNumber: c_uint,
|
||||
SizeInBits: u64,
|
||||
AlignInBits: u32,
|
||||
Flags: DIFlags,
|
||||
DerivedFrom: DIType,
|
||||
DerivedFrom: Option<NonNull<DIType_opaque>>,
|
||||
Elements: DIArray,
|
||||
RunTimeLang: c_uint,
|
||||
VTableHolder: DIType,
|
||||
VTableHolder: Option<NonNull<DIType_opaque>>,
|
||||
UniqueId: *const c_char)
|
||||
-> DICompositeType;
|
||||
|
||||
@ -1490,7 +1472,7 @@ extern "C" {
|
||||
-> DILexicalBlock;
|
||||
|
||||
pub fn LLVMRustDIBuilderCreateStaticVariable(Builder: DIBuilderRef,
|
||||
Context: DIScope,
|
||||
Context: Option<NonNull<DIScope_opaque>>,
|
||||
Name: *const c_char,
|
||||
LinkageName: *const c_char,
|
||||
File: DIFile,
|
||||
@ -1498,7 +1480,7 @@ extern "C" {
|
||||
Ty: DIType,
|
||||
isLocalToUnit: bool,
|
||||
Val: ValueRef,
|
||||
Decl: DIDescriptor,
|
||||
Decl: Option<NonNull<DIDescriptor_opaque>>,
|
||||
AlignInBits: u32)
|
||||
-> DIGlobalVariable;
|
||||
|
||||
@ -1535,7 +1517,7 @@ extern "C" {
|
||||
-> DISubrange;
|
||||
|
||||
pub fn LLVMRustDIBuilderGetOrCreateArray(Builder: DIBuilderRef,
|
||||
Ptr: *const DIDescriptor,
|
||||
Ptr: *const Option<NonNull<DIDescriptor_opaque>>,
|
||||
Count: c_uint)
|
||||
-> DIArray;
|
||||
|
||||
@ -1572,7 +1554,7 @@ extern "C" {
|
||||
SizeInBits: u64,
|
||||
AlignInBits: u32,
|
||||
Flags: DIFlags,
|
||||
Elements: DIArray,
|
||||
Elements: Option<NonNull<DIArray_opaque>>,
|
||||
RunTimeLang: c_uint,
|
||||
UniqueId: *const c_char)
|
||||
-> DIType;
|
||||
@ -1580,7 +1562,7 @@ extern "C" {
|
||||
pub fn LLVMSetUnnamedAddr(GlobalVar: ValueRef, UnnamedAddr: Bool);
|
||||
|
||||
pub fn LLVMRustDIBuilderCreateTemplateTypeParameter(Builder: DIBuilderRef,
|
||||
Scope: DIScope,
|
||||
Scope: Option<NonNull<DIScope_opaque>>,
|
||||
Name: *const c_char,
|
||||
Ty: DIType,
|
||||
File: DIFile,
|
||||
@ -1590,7 +1572,7 @@ extern "C" {
|
||||
|
||||
|
||||
pub fn LLVMRustDIBuilderCreateNameSpace(Builder: DIBuilderRef,
|
||||
Scope: DIScope,
|
||||
Scope: Option<NonNull<DIScope_opaque>>,
|
||||
Name: *const c_char,
|
||||
File: DIFile,
|
||||
LineNo: c_uint)
|
||||
@ -1604,7 +1586,7 @@ extern "C" {
|
||||
Line: c_uint,
|
||||
Column: c_uint,
|
||||
Scope: DIScope,
|
||||
InlinedAt: MetadataRef)
|
||||
InlinedAt: Option<NonNull<Metadata_opaque>>)
|
||||
-> ValueRef;
|
||||
pub fn LLVMRustDIBuilderCreateOpDeref() -> i64;
|
||||
pub fn LLVMRustDIBuilderCreateOpPlusUconst() -> i64;
|
||||
@ -1720,7 +1702,7 @@ extern "C" {
|
||||
-> LLVMRustResult;
|
||||
pub fn LLVMRustArchiveMemberNew(Filename: *const c_char,
|
||||
Name: *const c_char,
|
||||
Child: ArchiveChildRef)
|
||||
Child: Option<NonNull<ArchiveChild_opaque>>)
|
||||
-> RustArchiveMemberRef;
|
||||
pub fn LLVMRustArchiveMemberFree(Member: RustArchiveMemberRef);
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
use common::{C_i32, C_null};
|
||||
use libc::c_uint;
|
||||
use llvm::{self, ValueRef, BasicBlockRef};
|
||||
use llvm::debuginfo::DIScope;
|
||||
use llvm::debuginfo::DIScope_opaque;
|
||||
use rustc::ty::{self, Ty, TypeFoldable, UpvarSubsts};
|
||||
use rustc::ty::layout::{LayoutOf, TyLayout};
|
||||
use rustc::mir::{self, Mir};
|
||||
@ -29,6 +29,7 @@ use syntax_pos::{DUMMY_SP, NO_EXPANSION, BytePos, Span};
|
||||
use syntax::symbol::keywords;
|
||||
|
||||
use std::iter;
|
||||
use std::ptr::NonNull;
|
||||
|
||||
use rustc_data_structures::bitvec::BitVector;
|
||||
use rustc_data_structures::indexed_vec::{IndexVec, Idx};
|
||||
@ -121,7 +122,7 @@ impl<'a, 'tcx> FunctionCx<'a, 'tcx> {
|
||||
debuginfo::set_source_location(&self.debug_context, bx, scope, span);
|
||||
}
|
||||
|
||||
pub fn debug_loc(&mut self, source_info: mir::SourceInfo) -> (DIScope, Span) {
|
||||
pub fn debug_loc(&mut self, source_info: mir::SourceInfo) -> (Option<NonNull<DIScope_opaque>>, Span) {
|
||||
// Bail out if debug info emission is not enabled.
|
||||
match self.debug_context {
|
||||
FunctionDebugContext::DebugInfoDisabled |
|
||||
@ -161,16 +162,16 @@ impl<'a, 'tcx> FunctionCx<'a, 'tcx> {
|
||||
// corresponding to span's containing source scope. If so, we need to create a DIScope
|
||||
// "extension" into that file.
|
||||
fn scope_metadata_for_loc(&self, scope_id: mir::SourceScope, pos: BytePos)
|
||||
-> llvm::debuginfo::DIScope {
|
||||
-> Option<NonNull<DIScope_opaque>> {
|
||||
let scope_metadata = self.scopes[scope_id].scope_metadata;
|
||||
if pos < self.scopes[scope_id].file_start_pos ||
|
||||
pos >= self.scopes[scope_id].file_end_pos {
|
||||
let cm = self.cx.sess().codemap();
|
||||
let defining_crate = self.debug_context.get_ref(DUMMY_SP).defining_crate;
|
||||
debuginfo::extend_scope_to_file(self.cx,
|
||||
scope_metadata,
|
||||
NonNull::new(debuginfo::extend_scope_to_file(self.cx,
|
||||
scope_metadata.unwrap().as_ptr(),
|
||||
&cm.lookup_char_pos(pos).file,
|
||||
defining_crate)
|
||||
defining_crate))
|
||||
} else {
|
||||
scope_metadata
|
||||
}
|
||||
@ -280,7 +281,7 @@ pub fn codegen_mir<'a, 'tcx: 'a>(
|
||||
span: decl.source_info.span,
|
||||
scope: decl.visibility_scope,
|
||||
});
|
||||
declare_local(&bx, &fx.debug_context, name, layout.ty, scope,
|
||||
declare_local(&bx, &fx.debug_context, name, layout.ty, scope.unwrap().as_ptr(),
|
||||
VariableAccess::DirectVariable { alloca: place.llval },
|
||||
VariableKind::LocalVariable, span);
|
||||
}
|
||||
@ -424,8 +425,8 @@ fn arg_local_refs<'a, 'tcx>(bx: &Builder<'a, 'tcx>,
|
||||
|
||||
// Get the argument scope, if it exists and if we need it.
|
||||
let arg_scope = scopes[mir::OUTERMOST_SOURCE_SCOPE];
|
||||
let arg_scope = if arg_scope.is_valid() && bx.sess().opts.debuginfo == FullDebugInfo {
|
||||
Some(arg_scope.scope_metadata)
|
||||
let arg_scope = if bx.sess().opts.debuginfo == FullDebugInfo {
|
||||
arg_scope.scope_metadata
|
||||
} else {
|
||||
None
|
||||
};
|
||||
@ -471,7 +472,7 @@ fn arg_local_refs<'a, 'tcx>(bx: &Builder<'a, 'tcx>,
|
||||
bx,
|
||||
&fx.debug_context,
|
||||
arg_decl.name.unwrap_or(keywords::Invalid.name()),
|
||||
arg_ty, scope,
|
||||
arg_ty, scope.as_ptr(),
|
||||
variable_access,
|
||||
VariableKind::ArgumentVariable(arg_index + 1),
|
||||
DUMMY_SP
|
||||
@ -550,7 +551,7 @@ fn arg_local_refs<'a, 'tcx>(bx: &Builder<'a, 'tcx>,
|
||||
&fx.debug_context,
|
||||
arg_decl.name.unwrap_or(keywords::Invalid.name()),
|
||||
arg.layout.ty,
|
||||
scope,
|
||||
scope.as_ptr(),
|
||||
variable_access,
|
||||
VariableKind::ArgumentVariable(arg_index + 1),
|
||||
DUMMY_SP
|
||||
@ -601,7 +602,7 @@ fn arg_local_refs<'a, 'tcx>(bx: &Builder<'a, 'tcx>,
|
||||
&fx.debug_context,
|
||||
decl.debug_name,
|
||||
ty,
|
||||
scope,
|
||||
scope.as_ptr(),
|
||||
variable_access,
|
||||
VariableKind::LocalVariable,
|
||||
DUMMY_SP
|
||||
|
@ -24,7 +24,6 @@ use value::Value;
|
||||
use type_of::LayoutLlvmExt;
|
||||
|
||||
use std::fmt;
|
||||
use std::ptr;
|
||||
|
||||
use super::{FunctionCx, LocalRef};
|
||||
use super::constant::scalar_to_llvm;
|
||||
@ -160,7 +159,7 @@ impl<'a, 'tcx> OperandRef<'tcx> {
|
||||
let projected_ty = self.layout.ty.builtin_deref(true)
|
||||
.unwrap_or_else(|| bug!("deref of non-pointer {:?}", self)).ty;
|
||||
let (llptr, llextra) = match self.val {
|
||||
OperandValue::Immediate(llptr) => (llptr, ptr::null_mut()),
|
||||
OperandValue::Immediate(llptr) => (llptr, 0 as *mut _),
|
||||
OperandValue::Pair(llptr, llextra) => (llptr, llextra),
|
||||
OperandValue::Ref(..) => bug!("Deref of by-Ref operand {:?}", self)
|
||||
};
|
||||
|
@ -24,8 +24,6 @@ use value::Value;
|
||||
use glue;
|
||||
use mir::constant::const_alloc_to_llvm;
|
||||
|
||||
use std::ptr;
|
||||
|
||||
use super::{FunctionCx, LocalRef};
|
||||
use super::operand::{OperandRef, OperandValue};
|
||||
|
||||
@ -51,7 +49,7 @@ impl<'a, 'tcx> PlaceRef<'tcx> {
|
||||
-> PlaceRef<'tcx> {
|
||||
PlaceRef {
|
||||
llval,
|
||||
llextra: ptr::null_mut(),
|
||||
llextra: 0 as *mut _,
|
||||
layout,
|
||||
align
|
||||
}
|
||||
@ -126,7 +124,7 @@ impl<'a, 'tcx> PlaceRef<'tcx> {
|
||||
};
|
||||
|
||||
let val = if self.layout.is_llvm_immediate() {
|
||||
let mut const_llval = ptr::null_mut();
|
||||
let mut const_llval = 0 as *mut _;
|
||||
unsafe {
|
||||
let global = llvm::LLVMIsAGlobalVariable(self.llval);
|
||||
if !global.is_null() && llvm::LLVMIsGlobalConstant(global) == llvm::True {
|
||||
@ -187,7 +185,7 @@ impl<'a, 'tcx> PlaceRef<'tcx> {
|
||||
llextra: if cx.type_has_metadata(field.ty) {
|
||||
self.llextra
|
||||
} else {
|
||||
ptr::null_mut()
|
||||
0 as *mut _
|
||||
},
|
||||
layout: field,
|
||||
align,
|
||||
@ -390,7 +388,7 @@ impl<'a, 'tcx> PlaceRef<'tcx> {
|
||||
-> PlaceRef<'tcx> {
|
||||
PlaceRef {
|
||||
llval: bx.inbounds_gep(self.llval, &[C_usize(bx.cx, 0), llindex]),
|
||||
llextra: ptr::null_mut(),
|
||||
llextra: 0 as *mut _,
|
||||
layout: self.layout.field(bx.cx, 0),
|
||||
align: self.align
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ use rustc::ty::layout::{self, Align, Size};
|
||||
use std::ffi::CString;
|
||||
use std::fmt;
|
||||
use std::mem;
|
||||
use std::ptr;
|
||||
|
||||
use libc::c_uint;
|
||||
|
||||
@ -103,6 +102,11 @@ impl Type {
|
||||
ty!(llvm::LLVMIntTypeInContext(cx.llcx, num_bits as c_uint))
|
||||
}
|
||||
|
||||
// Creates an integer type with the given number of bits, e.g. i24
|
||||
pub fn ix_llcx(llcx: ContextRef, num_bits: u64) -> Type {
|
||||
ty!(llvm::LLVMIntTypeInContext(llcx, num_bits as c_uint))
|
||||
}
|
||||
|
||||
pub fn f32(cx: &CodegenCx) -> Type {
|
||||
ty!(llvm::LLVMFloatTypeInContext(cx.llcx))
|
||||
}
|
||||
@ -128,12 +132,7 @@ impl Type {
|
||||
}
|
||||
|
||||
pub fn isize(cx: &CodegenCx) -> Type {
|
||||
match &cx.tcx.sess.target.target.target_pointer_width[..] {
|
||||
"16" => Type::i16(cx),
|
||||
"32" => Type::i32(cx),
|
||||
"64" => Type::i64(cx),
|
||||
tws => bug!("Unsupported target word size for int: {}", tws),
|
||||
}
|
||||
cx.isize_ty
|
||||
}
|
||||
|
||||
pub fn c_int(cx: &CodegenCx) -> Type {
|
||||
@ -241,7 +240,7 @@ impl Type {
|
||||
pub fn func_params(&self) -> Vec<Type> {
|
||||
unsafe {
|
||||
let n_args = llvm::LLVMCountParamTypes(self.to_ref()) as usize;
|
||||
let mut args = vec![Type { rf: ptr::null_mut() }; n_args];
|
||||
let mut args = vec![Type { rf: 0 as *mut _ }; n_args];
|
||||
llvm::LLVMGetParamTypes(self.to_ref(),
|
||||
args.as_mut_ptr() as *mut TypeRef);
|
||||
args
|
||||
|
Loading…
Reference in New Issue
Block a user