Skip to content

Commit 7f78b42

Browse files
committed
Auto merge of rust-lang#38317 - shepmaster:llvm-4.0-debuginfo-alignment, r=eddyb
[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
2 parents 0d1b9f4 + 5bce12c commit 7f78b42

File tree

4 files changed

+44
-12
lines changed

4 files changed

+44
-12
lines changed

src/librustc_llvm/ffi.rs

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

14231424
pub fn LLVMRustDIBuilderCreateVariable(Builder: DIBuilderRef,
@@ -1429,7 +1430,8 @@ extern "C" {
14291430
Ty: DIType,
14301431
AlwaysPreserve: bool,
14311432
Flags: DIFlags,
1432-
ArgNo: c_uint)
1433+
ArgNo: c_uint,
1434+
AlignInBits: u64)
14331435
-> DIVariable;
14341436

14351437
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: 29 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,16 +650,23 @@ 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),
653661
LineNo,
654662
unwrapDI<DIType>(Ty),
655663
isLocalToUnit,
656664
cast<Constant>(unwrap(Val)),
657-
unwrapDIptr<MDNode>(Decl)));
665+
unwrapDIptr<MDNode>(Decl)
666+
#if LLVM_VERSION_GE(4, 0)
667+
, AlignInBits
668+
#endif
669+
));
658670
}
659671

660672
extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateVariable(
@@ -667,14 +679,23 @@ extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateVariable(
667679
LLVMRustMetadataRef Ty,
668680
bool AlwaysPreserve,
669681
LLVMRustDIFlags Flags,
670-
unsigned ArgNo) {
682+
unsigned ArgNo,
683+
uint64_t AlignInBits)
684+
{
671685
#if LLVM_VERSION_GE(3, 8)
672686
if (Tag == 0x100) { // DW_TAG_auto_variable
673687
return wrap(Builder->createAutoVariable(
674-
unwrapDI<DIDescriptor>(Scope), Name,
688+
unwrapDI<DIDescriptor>(Scope),
689+
Name,
675690
unwrapDI<DIFile>(File),
676691
LineNo,
677-
unwrapDI<DIType>(Ty), AlwaysPreserve, from_rust(Flags)));
692+
unwrapDI<DIType>(Ty),
693+
AlwaysPreserve,
694+
from_rust(Flags)
695+
#if LLVM_VERSION_GE(4,0)
696+
, AlignInBits
697+
#endif
698+
));
678699
} else {
679700
return wrap(Builder->createParameterVariable(
680701
unwrapDI<DIDescriptor>(Scope), Name, ArgNo,

0 commit comments

Comments
 (0)