Skip to content

Commit 350ff59

Browse files
committed
[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) llvm-mirror/llvm@e69c459
1 parent 557e1b9 commit 350ff59

File tree

4 files changed

+46
-12
lines changed

4 files changed

+46
-12
lines changed

src/librustc_llvm/ffi.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,7 +1418,8 @@ extern "C" {
14181418
Ty: DIType,
14191419
isLocalToUnit: bool,
14201420
Val: ValueRef,
1421-
Decl: DIDescriptor)
1421+
Decl: DIDescriptor,
1422+
AlignInBits: u64)
14221423
-> DIGlobalVariable;
14231424

14241425
pub fn LLVMRustDIBuilderCreateVariable(Builder: DIBuilderRef,
@@ -1430,7 +1431,8 @@ extern "C" {
14301431
Ty: DIType,
14311432
AlwaysPreserve: bool,
14321433
Flags: DIFlags,
1433-
ArgNo: c_uint)
1434+
ArgNo: c_uint,
1435+
AlignInBits: u64)
14341436
-> DIVariable;
14351437

14361438
pub fn LLVMRustDIBuilderCreateArrayType(Builder: DIBuilderRef,

src/librustc_trans/debuginfo/metadata.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1763,6 +1763,10 @@ pub fn create_global_var_metadata(cx: &CrateContext,
17631763

17641764
let var_name = CString::new(var_name).unwrap();
17651765
let linkage_name = CString::new(linkage_name).unwrap();
1766+
1767+
let ty = cx.tcx().item_type(node_def_id);
1768+
let global_align = type_of::align_of(cx, ty);
1769+
17661770
unsafe {
17671771
llvm::LLVMRustDIBuilderCreateStaticVariable(DIB(cx),
17681772
var_scope,
@@ -1773,7 +1777,9 @@ pub fn create_global_var_metadata(cx: &CrateContext,
17731777
type_metadata,
17741778
is_local_to_unit,
17751779
global,
1776-
ptr::null_mut());
1780+
ptr::null_mut(),
1781+
global_align as u64,
1782+
);
17771783
}
17781784
}
17791785

src/librustc_trans/debuginfo/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,7 @@ pub fn declare_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
462462
LocalVariable |
463463
CapturedVariable => (0, DW_TAG_auto_variable)
464464
};
465+
let align = ::type_of::align_of(cx, variable_type);
465466

466467
let name = CString::new(variable_name.as_str().as_bytes()).unwrap();
467468
match (variable_access, &[][..]) {
@@ -478,7 +479,9 @@ pub fn declare_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
478479
type_metadata,
479480
cx.sess().opts.optimize != config::OptLevel::No,
480481
DIFlags::FlagZero,
481-
argument_index)
482+
argument_index,
483+
align as u64,
484+
)
482485
};
483486
source_loc::set_debug_location(cx, None,
484487
InternalDebugLocation::new(scope_metadata, loc.line, loc.col.to_usize()));

src/rustllvm/RustWrapper.cpp

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -552,8 +552,13 @@ extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateBasicType(
552552
uint64_t AlignInBits,
553553
unsigned Encoding) {
554554
return wrap(Builder->createBasicType(
555-
Name, SizeInBits,
556-
AlignInBits, Encoding));
555+
Name,
556+
SizeInBits,
557+
#if LLVM_VERSION_LE(3, 9)
558+
AlignInBits,
559+
#endif
560+
Encoding
561+
));
557562
}
558563

559564
extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreatePointerType(
@@ -645,8 +650,11 @@ extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateStaticVariable(
645650
LLVMRustMetadataRef Ty,
646651
bool isLocalToUnit,
647652
LLVMValueRef Val,
648-
LLVMRustMetadataRef Decl = NULL) {
649-
return wrap(Builder->createGlobalVariable(unwrapDI<DIDescriptor>(Context),
653+
LLVMRustMetadataRef Decl = NULL,
654+
uint64_t AlignInBits = 0)
655+
{
656+
return wrap(Builder->createGlobalVariable(
657+
unwrapDI<DIDescriptor>(Context),
650658
Name,
651659
LinkageName,
652660
unwrapDI<DIFile>(File),
@@ -659,7 +667,12 @@ extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateStaticVariable(
659667
#else
660668
cast<Constant>(unwrap(Val)),
661669
#endif
662-
unwrapDIptr<MDNode>(Decl)));
670+
unwrapDIptr<MDNode>(Decl)
671+
#if LLVM_VERSION_GE(4, 0)
672+
,
673+
AlignInBits
674+
#endif
675+
));
663676
}
664677

665678
extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateVariable(
@@ -672,14 +685,24 @@ extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateVariable(
672685
LLVMRustMetadataRef Ty,
673686
bool AlwaysPreserve,
674687
LLVMRustDIFlags Flags,
675-
unsigned ArgNo) {
688+
unsigned ArgNo,
689+
uint64_t AlignInBits)
690+
{
676691
#if LLVM_VERSION_GE(3, 8)
677692
if (Tag == 0x100) { // DW_TAG_auto_variable
678693
return wrap(Builder->createAutoVariable(
679-
unwrapDI<DIDescriptor>(Scope), Name,
694+
unwrapDI<DIDescriptor>(Scope),
695+
Name,
680696
unwrapDI<DIFile>(File),
681697
LineNo,
682-
unwrapDI<DIType>(Ty), AlwaysPreserve, from_rust(Flags)));
698+
unwrapDI<DIType>(Ty),
699+
AlwaysPreserve,
700+
from_rust(Flags)
701+
#if LLVM_VERSION_GE(4,0)
702+
,
703+
AlignInBits
704+
#endif
705+
));
683706
} else {
684707
return wrap(Builder->createParameterVariable(
685708
unwrapDI<DIDescriptor>(Scope), Name, ArgNo,

0 commit comments

Comments
 (0)