Skip to content

Commit

Permalink
Update LLVM to rust-llvm-2015-01-30
Browse files Browse the repository at this point in the history
  • Loading branch information
dotdash committed Feb 1, 2015
1 parent 682f867 commit 602e508
Show file tree
Hide file tree
Showing 7 changed files with 268 additions and 203 deletions.
96 changes: 53 additions & 43 deletions src/librustc_llvm/lib.rs
Expand Up @@ -64,8 +64,9 @@ use libc::{c_uint, c_ushort, uint64_t, c_int, size_t, c_char};
use libc::{c_longlong, c_ulonglong, c_void};
use debuginfo::{DIBuilderRef, DIDescriptor,
DIFile, DILexicalBlock, DISubprogram, DIType,
DIBasicType, DIDerivedType, DICompositeType,
DIVariable, DIGlobalVariable, DIArray, DISubrange};
DIBasicType, DIDerivedType, DICompositeType, DIScope,
DIVariable, DIGlobalVariable, DIArray, DISubrange,
DITemplateTypeParameter, DIEnumerator, DINameSpace};

pub mod archive_ro;
pub mod diagnostic;
Expand Down Expand Up @@ -443,6 +444,9 @@ pub type TypeRef = *mut Type_opaque;
pub enum Value_opaque {}
pub type ValueRef = *mut Value_opaque;
#[allow(missing_copy_implementations)]
pub enum Metadata_opaque {}
pub type MetadataRef = *mut Metadata_opaque;
#[allow(missing_copy_implementations)]
pub enum BasicBlock_opaque {}
pub type BasicBlockRef = *mut BasicBlock_opaque;
#[allow(missing_copy_implementations)]
Expand Down Expand Up @@ -502,18 +506,19 @@ pub type InlineAsmDiagHandler = unsafe extern "C" fn(SMDiagnosticRef, *const c_v

pub mod debuginfo {
pub use self::DIDescriptorFlags::*;
use super::{ValueRef};
use super::{MetadataRef};

#[allow(missing_copy_implementations)]
pub enum DIBuilder_opaque {}
pub type DIBuilderRef = *mut DIBuilder_opaque;

pub type DIDescriptor = ValueRef;
pub type DIDescriptor = MetadataRef;
pub type DIScope = DIDescriptor;
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 DIBasicType = DIType;
pub type DIDerivedType = DIType;
Expand All @@ -522,6 +527,8 @@ pub mod debuginfo {
pub type DIGlobalVariable = DIDescriptor;
pub type DIArray = DIDescriptor;
pub type DISubrange = DIDescriptor;
pub type DIEnumerator = DIDescriptor;
pub type DITemplateTypeParameter = DIDescriptor;

#[derive(Copy)]
pub enum DIDescriptorFlags {
Expand Down Expand Up @@ -1779,8 +1786,8 @@ extern {
Flags: c_uint,
isOptimized: bool,
Fn: ValueRef,
TParam: ValueRef,
Decl: ValueRef)
TParam: DIArray,
Decl: DIDescriptor)
-> DISubprogram;

pub fn LLVMDIBuilderCreateBasicType(Builder: DIBuilderRef,
Expand Down Expand Up @@ -1808,7 +1815,7 @@ extern {
DerivedFrom: DIType,
Elements: DIArray,
RunTimeLang: c_uint,
VTableHolder: ValueRef,
VTableHolder: DIType,
UniqueId: *const c_char)
-> DICompositeType;

Expand All @@ -1825,25 +1832,25 @@ extern {
-> DIDerivedType;

pub fn LLVMDIBuilderCreateLexicalBlock(Builder: DIBuilderRef,
Scope: DIDescriptor,
Scope: DIScope,
File: DIFile,
Line: c_uint,
Col: c_uint)
-> DILexicalBlock;

pub fn LLVMDIBuilderCreateStaticVariable(Builder: DIBuilderRef,
Context: DIDescriptor,
Context: DIScope,
Name: *const c_char,
LinkageName: *const c_char,
File: DIFile,
LineNo: c_uint,
Ty: DIType,
isLocalToUnit: bool,
Val: ValueRef,
Decl: ValueRef)
Decl: DIDescriptor)
-> DIGlobalVariable;

pub fn LLVMDIBuilderCreateLocalVariable(Builder: DIBuilderRef,
pub fn LLVMDIBuilderCreateVariable(Builder: DIBuilderRef,
Tag: c_uint,
Scope: DIDescriptor,
Name: *const c_char,
Expand All @@ -1852,6 +1859,8 @@ extern {
Ty: DIType,
AlwaysPreserve: bool,
Flags: c_uint,
AddrOps: *const i64,
AddrOpsCount: c_uint,
ArgNo: c_uint)
-> DIVariable;

Expand Down Expand Up @@ -1882,79 +1891,80 @@ extern {
pub fn LLVMDIBuilderInsertDeclareAtEnd(Builder: DIBuilderRef,
Val: ValueRef,
VarInfo: DIVariable,
AddrOps: *const i64,
AddrOpsCount: c_uint,
InsertAtEnd: BasicBlockRef)
-> ValueRef;

pub fn LLVMDIBuilderInsertDeclareBefore(Builder: DIBuilderRef,
Val: ValueRef,
VarInfo: DIVariable,
AddrOps: *const i64,
AddrOpsCount: c_uint,
InsertBefore: ValueRef)
-> ValueRef;

pub fn LLVMDIBuilderCreateEnumerator(Builder: DIBuilderRef,
Name: *const c_char,
Val: c_ulonglong)
-> ValueRef;
-> DIEnumerator;

pub fn LLVMDIBuilderCreateEnumerationType(Builder: DIBuilderRef,
Scope: ValueRef,
Scope: DIScope,
Name: *const c_char,
File: ValueRef,
File: DIFile,
LineNumber: c_uint,
SizeInBits: c_ulonglong,
AlignInBits: c_ulonglong,
Elements: ValueRef,
ClassType: ValueRef)
-> ValueRef;
Elements: DIArray,
ClassType: DIType)
-> DIType;

pub fn LLVMDIBuilderCreateUnionType(Builder: DIBuilderRef,
Scope: ValueRef,
Scope: DIScope,
Name: *const c_char,
File: ValueRef,
File: DIFile,
LineNumber: c_uint,
SizeInBits: c_ulonglong,
AlignInBits: c_ulonglong,
Flags: c_uint,
Elements: ValueRef,
Elements: DIArray,
RunTimeLang: c_uint,
UniqueId: *const c_char)
-> ValueRef;
-> DIType;

pub fn LLVMSetUnnamedAddr(GlobalVar: ValueRef, UnnamedAddr: Bool);

pub fn LLVMDIBuilderCreateTemplateTypeParameter(Builder: DIBuilderRef,
Scope: ValueRef,
Scope: DIScope,
Name: *const c_char,
Ty: ValueRef,
File: ValueRef,
Ty: DIType,
File: DIFile,
LineNo: c_uint,
ColumnNo: c_uint)
-> ValueRef;

pub fn LLVMDIBuilderCreateOpDeref(IntType: TypeRef) -> ValueRef;
-> DITemplateTypeParameter;

pub fn LLVMDIBuilderCreateOpPlus(IntType: TypeRef) -> ValueRef;
pub fn LLVMDIBuilderCreateOpDeref() -> i64;

pub fn LLVMDIBuilderCreateComplexVariable(Builder: DIBuilderRef,
Tag: c_uint,
Scope: ValueRef,
Name: *const c_char,
File: ValueRef,
LineNo: c_uint,
Ty: ValueRef,
AddrOps: *const ValueRef,
AddrOpsCount: c_uint,
ArgNo: c_uint)
-> ValueRef;
pub fn LLVMDIBuilderCreateOpPlus() -> i64;

pub fn LLVMDIBuilderCreateNameSpace(Builder: DIBuilderRef,
Scope: ValueRef,
Scope: DIScope,
Name: *const c_char,
File: ValueRef,
File: DIFile,
LineNo: c_uint)
-> ValueRef;
-> DINameSpace;

pub fn LLVMDIBuilderCreateDebugLocation(Context: ContextRef,
Line: c_uint,
Column: c_uint,
Scope: DIScope,
InlinedAt: MetadataRef)
-> ValueRef;

pub fn LLVMDICompositeTypeSetTypeArray(CompositeType: ValueRef, TypeArray: ValueRef);
pub fn LLVMDICompositeTypeSetTypeArray(Builder: DIBuilderRef,
CompositeType: DIType,
TypeArray: DIArray);
pub fn LLVMWriteTypeToString(Type: TypeRef, s: RustStringRef);
pub fn LLVMWriteValueToString(value_ref: ValueRef, s: RustStringRef);

Expand Down
4 changes: 0 additions & 4 deletions src/librustc_trans/trans/common.rs
Expand Up @@ -780,10 +780,6 @@ pub fn C_i32(ccx: &CrateContext, i: i32) -> ValueRef {
C_integral(Type::i32(ccx), i as u64, true)
}

pub fn C_i64(ccx: &CrateContext, i: i64) -> ValueRef {
C_integral(Type::i64(ccx), i as u64, true)
}

pub fn C_u64(ccx: &CrateContext, i: u64) -> ValueRef {
C_integral(Type::i64(ccx), i, false)
}
Expand Down
77 changes: 33 additions & 44 deletions src/librustc_trans/trans/debuginfo.rs
Expand Up @@ -197,7 +197,7 @@ use metadata::csearch;
use middle::subst::{self, Substs};
use trans::{self, adt, machine, type_of};
use trans::common::{self, NodeIdAndSpan, CrateContext, FunctionContext, Block,
C_bytes, C_i32, C_i64, NormalizingClosureTyper};
C_bytes, NormalizingClosureTyper};
use trans::_match::{BindingInfo, TrByCopy, TrByMove, TrByRef};
use trans::monomorphize;
use trans::type_::Type;
Expand Down Expand Up @@ -702,7 +702,7 @@ enum VariableAccess<'a> {
DirectVariable { alloca: ValueRef },
// The llptr given is an alloca containing the start of some pointer chain
// leading to the variable's content.
IndirectVariable { alloca: ValueRef, address_operations: &'a [ValueRef] }
IndirectVariable { alloca: ValueRef, address_operations: &'a [i64] }
}

enum VariableKind {
Expand Down Expand Up @@ -928,10 +928,10 @@ pub fn create_captured_var_metadata<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
env_index);

let address_operations = unsafe {
[llvm::LLVMDIBuilderCreateOpDeref(Type::i64(cx).to_ref()),
llvm::LLVMDIBuilderCreateOpPlus(Type::i64(cx).to_ref()),
C_i64(cx, byte_offset_of_var_in_env as i64),
llvm::LLVMDIBuilderCreateOpDeref(Type::i64(cx).to_ref())]
[llvm::LLVMDIBuilderCreateOpDeref(),
llvm::LLVMDIBuilderCreateOpPlus(),
byte_offset_of_var_in_env as i64,
llvm::LLVMDIBuilderCreateOpDeref()]
};

let address_op_count = if captured_by_ref {
Expand Down Expand Up @@ -969,7 +969,7 @@ pub fn create_match_binding_metadata<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,

let scope_metadata = scope_metadata(bcx.fcx, binding.id, binding.span);
let aops = unsafe {
[llvm::LLVMDIBuilderCreateOpDeref(bcx.ccx().int_type().to_ref())]
[llvm::LLVMDIBuilderCreateOpDeref()]
};
// Regardless of the actual type (`T`) we're always passed the stack slot (alloca)
// for the binding. For ByRef bindings that's a `T*` but for ByMove bindings we
Expand Down Expand Up @@ -1699,11 +1699,11 @@ fn declare_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
};

let name = CString::from_slice(name.get().as_bytes());
let (var_alloca, var_metadata) = match variable_access {
DirectVariable { alloca } => (
alloca,
unsafe {
llvm::LLVMDIBuilderCreateLocalVariable(
match (variable_access, [].as_slice()) {
(DirectVariable { alloca }, address_operations) |
(IndirectVariable {alloca, address_operations}, _) => {
let metadata = unsafe {
llvm::LLVMDIBuilderCreateVariable(
DIB(cx),
dwarf_tag,
scope_metadata,
Expand All @@ -1713,38 +1713,25 @@ fn declare_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
type_metadata,
cx.sess().opts.optimize != config::No,
0,
argument_index)
}
),
IndirectVariable { alloca, address_operations } => (
alloca,
unsafe {
llvm::LLVMDIBuilderCreateComplexVariable(
DIB(cx),
dwarf_tag,
scope_metadata,
name.as_ptr(),
file_metadata,
loc.line as c_uint,
type_metadata,
address_operations.as_ptr(),
address_operations.len() as c_uint,
argument_index)
}
)
};

set_debug_location(cx, InternalDebugLocation::new(scope_metadata,
};
set_debug_location(cx, InternalDebugLocation::new(scope_metadata,
loc.line,
loc.col.to_usize()));
unsafe {
let instr = llvm::LLVMDIBuilderInsertDeclareAtEnd(
DIB(cx),
var_alloca,
var_metadata,
bcx.llbb);
unsafe {
let instr = llvm::LLVMDIBuilderInsertDeclareAtEnd(
DIB(cx),
alloca,
metadata,
address_operations.as_ptr(),
address_operations.len() as c_uint,
bcx.llbb);

llvm::LLVMSetInstDebugLocation(trans::build::B(bcx).llbuilder, instr);
llvm::LLVMSetInstDebugLocation(trans::build::B(bcx).llbuilder, instr);
}
}
}

match variable_kind {
Expand Down Expand Up @@ -2716,7 +2703,7 @@ fn set_members_of_composite_type(cx: &CrateContext,

unsafe {
let type_array = create_DIArray(DIB(cx), &member_metadata[]);
llvm::LLVMDICompositeTypeSetTypeArray(composite_type_metadata, type_array);
llvm::LLVMDICompositeTypeSetTypeArray(DIB(cx), composite_type_metadata, type_array);
}
}

Expand Down Expand Up @@ -3150,12 +3137,14 @@ fn set_debug_location(cx: &CrateContext, debug_location: InternalDebugLocation)
// Always set the column to zero like Clang and GCC
let col = UNKNOWN_COLUMN_NUMBER;
debug!("setting debug location to {} {}", line, col);
let elements = [C_i32(cx, line as i32), C_i32(cx, col as i32),
scope, ptr::null_mut()];

unsafe {
metadata_node = llvm::LLVMMDNodeInContext(debug_context(cx).llcontext,
elements.as_ptr(),
elements.len() as c_uint);
metadata_node = llvm::LLVMDIBuilderCreateDebugLocation(
debug_context(cx).llcontext,
line as c_uint,
col as c_uint,
scope,
ptr::null_mut());
}
}
UnknownLocation => {
Expand Down
2 changes: 1 addition & 1 deletion src/llvm
Submodule llvm updated 4187 files

0 comments on commit 602e508

Please sign in to comment.