1
Fork 0

[LLVM 4.0] Move debuginfo alignment argument

Alignment was removed from createBasicType and moved to

- createGlobalVariable
- createAutoVariable
- createStaticMemberType (unused in Rust)
- createTempGlobalVariableFwdDecl (unused in Rust)

e69c459a6e
This commit is contained in:
Jake Goulding 2016-11-18 11:11:18 -05:00
parent 0eae43e4d0
commit 5bce12c95f
4 changed files with 44 additions and 12 deletions

View file

@ -1417,7 +1417,8 @@ extern "C" {
Ty: DIType, Ty: DIType,
isLocalToUnit: bool, isLocalToUnit: bool,
Val: ValueRef, Val: ValueRef,
Decl: DIDescriptor) Decl: DIDescriptor,
AlignInBits: u64)
-> DIGlobalVariable; -> DIGlobalVariable;
pub fn LLVMRustDIBuilderCreateVariable(Builder: DIBuilderRef, pub fn LLVMRustDIBuilderCreateVariable(Builder: DIBuilderRef,
@ -1429,7 +1430,8 @@ extern "C" {
Ty: DIType, Ty: DIType,
AlwaysPreserve: bool, AlwaysPreserve: bool,
Flags: DIFlags, Flags: DIFlags,
ArgNo: c_uint) ArgNo: c_uint,
AlignInBits: u64)
-> DIVariable; -> DIVariable;
pub fn LLVMRustDIBuilderCreateArrayType(Builder: DIBuilderRef, pub fn LLVMRustDIBuilderCreateArrayType(Builder: DIBuilderRef,

View file

@ -1763,6 +1763,10 @@ pub fn create_global_var_metadata(cx: &CrateContext,
let var_name = CString::new(var_name).unwrap(); let var_name = CString::new(var_name).unwrap();
let linkage_name = CString::new(linkage_name).unwrap(); let linkage_name = CString::new(linkage_name).unwrap();
let ty = cx.tcx().item_type(node_def_id);
let global_align = type_of::align_of(cx, ty);
unsafe { unsafe {
llvm::LLVMRustDIBuilderCreateStaticVariable(DIB(cx), llvm::LLVMRustDIBuilderCreateStaticVariable(DIB(cx),
var_scope, var_scope,
@ -1773,7 +1777,9 @@ pub fn create_global_var_metadata(cx: &CrateContext,
type_metadata, type_metadata,
is_local_to_unit, is_local_to_unit,
global, global,
ptr::null_mut()); ptr::null_mut(),
global_align as u64,
);
} }
} }

View file

@ -462,6 +462,7 @@ pub fn declare_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
LocalVariable | LocalVariable |
CapturedVariable => (0, DW_TAG_auto_variable) CapturedVariable => (0, DW_TAG_auto_variable)
}; };
let align = ::type_of::align_of(cx, variable_type);
let name = CString::new(variable_name.as_str().as_bytes()).unwrap(); let name = CString::new(variable_name.as_str().as_bytes()).unwrap();
match (variable_access, &[][..]) { match (variable_access, &[][..]) {
@ -478,7 +479,9 @@ pub fn declare_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
type_metadata, type_metadata,
cx.sess().opts.optimize != config::OptLevel::No, cx.sess().opts.optimize != config::OptLevel::No,
DIFlags::FlagZero, DIFlags::FlagZero,
argument_index) argument_index,
align as u64,
)
}; };
source_loc::set_debug_location(cx, None, source_loc::set_debug_location(cx, None,
InternalDebugLocation::new(scope_metadata, loc.line, loc.col.to_usize())); InternalDebugLocation::new(scope_metadata, loc.line, loc.col.to_usize()));

View file

@ -552,8 +552,13 @@ extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateBasicType(
uint64_t AlignInBits, uint64_t AlignInBits,
unsigned Encoding) { unsigned Encoding) {
return wrap(Builder->createBasicType( return wrap(Builder->createBasicType(
Name, SizeInBits, Name,
AlignInBits, Encoding)); SizeInBits,
#if LLVM_VERSION_LE(3, 9)
AlignInBits,
#endif
Encoding
));
} }
extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreatePointerType( extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreatePointerType(
@ -645,8 +650,11 @@ extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateStaticVariable(
LLVMRustMetadataRef Ty, LLVMRustMetadataRef Ty,
bool isLocalToUnit, bool isLocalToUnit,
LLVMValueRef Val, LLVMValueRef Val,
LLVMRustMetadataRef Decl = NULL) { LLVMRustMetadataRef Decl = NULL,
return wrap(Builder->createGlobalVariable(unwrapDI<DIDescriptor>(Context), uint64_t AlignInBits = 0)
{
return wrap(Builder->createGlobalVariable(
unwrapDI<DIDescriptor>(Context),
Name, Name,
LinkageName, LinkageName,
unwrapDI<DIFile>(File), unwrapDI<DIFile>(File),
@ -654,7 +662,11 @@ extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateStaticVariable(
unwrapDI<DIType>(Ty), unwrapDI<DIType>(Ty),
isLocalToUnit, isLocalToUnit,
cast<Constant>(unwrap(Val)), cast<Constant>(unwrap(Val)),
unwrapDIptr<MDNode>(Decl))); unwrapDIptr<MDNode>(Decl)
#if LLVM_VERSION_GE(4, 0)
, AlignInBits
#endif
));
} }
extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateVariable( extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateVariable(
@ -667,14 +679,23 @@ extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateVariable(
LLVMRustMetadataRef Ty, LLVMRustMetadataRef Ty,
bool AlwaysPreserve, bool AlwaysPreserve,
LLVMRustDIFlags Flags, LLVMRustDIFlags Flags,
unsigned ArgNo) { unsigned ArgNo,
uint64_t AlignInBits)
{
#if LLVM_VERSION_GE(3, 8) #if LLVM_VERSION_GE(3, 8)
if (Tag == 0x100) { // DW_TAG_auto_variable if (Tag == 0x100) { // DW_TAG_auto_variable
return wrap(Builder->createAutoVariable( return wrap(Builder->createAutoVariable(
unwrapDI<DIDescriptor>(Scope), Name, unwrapDI<DIDescriptor>(Scope),
Name,
unwrapDI<DIFile>(File), unwrapDI<DIFile>(File),
LineNo, LineNo,
unwrapDI<DIType>(Ty), AlwaysPreserve, from_rust(Flags))); unwrapDI<DIType>(Ty),
AlwaysPreserve,
from_rust(Flags)
#if LLVM_VERSION_GE(4,0)
, AlignInBits
#endif
));
} else { } else {
return wrap(Builder->createParameterVariable( return wrap(Builder->createParameterVariable(
unwrapDI<DIDescriptor>(Scope), Name, ArgNo, unwrapDI<DIDescriptor>(Scope), Name, ArgNo,