Skip to content

Commit fef8b92

Browse files
authored
Rollup merge of rust-lang#39529 - dylanmckay:llvm-4.0-align32, r=alexcrichton
[LLVM 4.0] Use 32-bits for alignment LLVM 4.0 changes this. This change is fine to make for LLVM 3.9 as we won't have alignments greater than 2^32-1.
2 parents ed172ee + c7bea76 commit fef8b92

File tree

5 files changed

+29
-26
lines changed

5 files changed

+29
-26
lines changed

src/librustc_llvm/ffi.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,14 +1369,14 @@ extern "C" {
13691369
pub fn LLVMRustDIBuilderCreateBasicType(Builder: DIBuilderRef,
13701370
Name: *const c_char,
13711371
SizeInBits: u64,
1372-
AlignInBits: u64,
1372+
AlignInBits: u32,
13731373
Encoding: c_uint)
13741374
-> DIBasicType;
13751375

13761376
pub fn LLVMRustDIBuilderCreatePointerType(Builder: DIBuilderRef,
13771377
PointeeTy: DIType,
13781378
SizeInBits: u64,
1379-
AlignInBits: u64,
1379+
AlignInBits: u32,
13801380
Name: *const c_char)
13811381
-> DIDerivedType;
13821382

@@ -1386,7 +1386,7 @@ extern "C" {
13861386
File: DIFile,
13871387
LineNumber: c_uint,
13881388
SizeInBits: u64,
1389-
AlignInBits: u64,
1389+
AlignInBits: u32,
13901390
Flags: DIFlags,
13911391
DerivedFrom: DIType,
13921392
Elements: DIArray,
@@ -1401,7 +1401,7 @@ extern "C" {
14011401
File: DIFile,
14021402
LineNo: c_uint,
14031403
SizeInBits: u64,
1404-
AlignInBits: u64,
1404+
AlignInBits: u32,
14051405
OffsetInBits: u64,
14061406
Flags: DIFlags,
14071407
Ty: DIType)
@@ -1429,7 +1429,7 @@ extern "C" {
14291429
isLocalToUnit: bool,
14301430
Val: ValueRef,
14311431
Decl: DIDescriptor,
1432-
AlignInBits: u64)
1432+
AlignInBits: u32)
14331433
-> DIGlobalVariable;
14341434

14351435
pub fn LLVMRustDIBuilderCreateVariable(Builder: DIBuilderRef,
@@ -1442,19 +1442,19 @@ extern "C" {
14421442
AlwaysPreserve: bool,
14431443
Flags: DIFlags,
14441444
ArgNo: c_uint,
1445-
AlignInBits: u64)
1445+
AlignInBits: u32)
14461446
-> DIVariable;
14471447

14481448
pub fn LLVMRustDIBuilderCreateArrayType(Builder: DIBuilderRef,
14491449
Size: u64,
1450-
AlignInBits: u64,
1450+
AlignInBits: u32,
14511451
Ty: DIType,
14521452
Subscripts: DIArray)
14531453
-> DIType;
14541454

14551455
pub fn LLVMRustDIBuilderCreateVectorType(Builder: DIBuilderRef,
14561456
Size: u64,
1457-
AlignInBits: u64,
1457+
AlignInBits: u32,
14581458
Ty: DIType,
14591459
Subscripts: DIArray)
14601460
-> DIType;
@@ -1489,7 +1489,7 @@ extern "C" {
14891489
File: DIFile,
14901490
LineNumber: c_uint,
14911491
SizeInBits: u64,
1492-
AlignInBits: u64,
1492+
AlignInBits: u32,
14931493
Elements: DIArray,
14941494
ClassType: DIType)
14951495
-> DIType;
@@ -1500,7 +1500,7 @@ extern "C" {
15001500
File: DIFile,
15011501
LineNumber: c_uint,
15021502
SizeInBits: u64,
1503-
AlignInBits: u64,
1503+
AlignInBits: u32,
15041504
Flags: DIFlags,
15051505
Elements: DIArray,
15061506
RunTimeLang: c_uint,

src/librustc_trans/debuginfo/metadata.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1783,7 +1783,7 @@ pub fn create_global_var_metadata(cx: &CrateContext,
17831783
is_local_to_unit,
17841784
global,
17851785
ptr::null_mut(),
1786-
global_align as u64,
1786+
global_align,
17871787
);
17881788
}
17891789
}

src/librustc_trans/debuginfo/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ pub fn declare_local<'a, 'tcx>(bcx: &Builder<'a, 'tcx>,
464464
cx.sess().opts.optimize != config::OptLevel::No,
465465
DIFlags::FlagZero,
466466
argument_index,
467-
align as u64,
467+
align,
468468
)
469469
};
470470
source_loc::set_debug_location(bcx,

src/librustc_trans/debuginfo/utils.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ use type_::Type;
2424
use syntax_pos::{self, Span};
2525
use syntax::ast;
2626

27+
use std::ops;
28+
2729
pub fn is_node_local_to_unit(cx: &CrateContext, node_id: ast::NodeId) -> bool
2830
{
2931
// The is_local_to_unit flag indicates whether a function is local to the
@@ -49,12 +51,13 @@ pub fn span_start(cx: &CrateContext, span: Span) -> syntax_pos::Loc {
4951
cx.sess().codemap().lookup_char_pos(span.lo)
5052
}
5153

52-
pub fn size_and_align_of(cx: &CrateContext, llvm_type: Type) -> (u64, u64) {
53-
(machine::llsize_of_alloc(cx, llvm_type), machine::llalign_of_min(cx, llvm_type) as u64)
54+
pub fn size_and_align_of(cx: &CrateContext, llvm_type: Type) -> (u64, u32) {
55+
(machine::llsize_of_alloc(cx, llvm_type), machine::llalign_of_min(cx, llvm_type))
5456
}
5557

56-
pub fn bytes_to_bits(bytes: u64) -> u64 {
57-
bytes * 8
58+
pub fn bytes_to_bits<T>(bytes: T) -> T
59+
where T: ops::Mul<Output=T> + From<u8> {
60+
bytes * 8u8.into()
5861
}
5962

6063
#[inline]

src/rustllvm/RustWrapper.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateFunction(
513513

514514
extern "C" LLVMRustMetadataRef
515515
LLVMRustDIBuilderCreateBasicType(LLVMRustDIBuilderRef Builder, const char *Name,
516-
uint64_t SizeInBits, uint64_t AlignInBits,
516+
uint64_t SizeInBits, uint32_t AlignInBits,
517517
unsigned Encoding) {
518518
return wrap(Builder->createBasicType(Name, SizeInBits,
519519
#if LLVM_VERSION_LE(3, 9)
@@ -524,15 +524,15 @@ LLVMRustDIBuilderCreateBasicType(LLVMRustDIBuilderRef Builder, const char *Name,
524524

525525
extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreatePointerType(
526526
LLVMRustDIBuilderRef Builder, LLVMRustMetadataRef PointeeTy,
527-
uint64_t SizeInBits, uint64_t AlignInBits, const char *Name) {
527+
uint64_t SizeInBits, uint32_t AlignInBits, const char *Name) {
528528
return wrap(Builder->createPointerType(unwrapDI<DIType>(PointeeTy),
529529
SizeInBits, AlignInBits, Name));
530530
}
531531

532532
extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateStructType(
533533
LLVMRustDIBuilderRef Builder, LLVMRustMetadataRef Scope, const char *Name,
534534
LLVMRustMetadataRef File, unsigned LineNumber, uint64_t SizeInBits,
535-
uint64_t AlignInBits, LLVMRustDIFlags Flags,
535+
uint32_t AlignInBits, LLVMRustDIFlags Flags,
536536
LLVMRustMetadataRef DerivedFrom, LLVMRustMetadataRef Elements,
537537
unsigned RunTimeLang, LLVMRustMetadataRef VTableHolder,
538538
const char *UniqueId) {
@@ -546,7 +546,7 @@ extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateStructType(
546546
extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateMemberType(
547547
LLVMRustDIBuilderRef Builder, LLVMRustMetadataRef Scope, const char *Name,
548548
LLVMRustMetadataRef File, unsigned LineNo, uint64_t SizeInBits,
549-
uint64_t AlignInBits, uint64_t OffsetInBits, LLVMRustDIFlags Flags,
549+
uint32_t AlignInBits, uint64_t OffsetInBits, LLVMRustDIFlags Flags,
550550
LLVMRustMetadataRef Ty) {
551551
return wrap(Builder->createMemberType(unwrapDI<DIDescriptor>(Scope), Name,
552552
unwrapDI<DIFile>(File), LineNo,
@@ -573,7 +573,7 @@ extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateStaticVariable(
573573
LLVMRustDIBuilderRef Builder, LLVMRustMetadataRef Context, const char *Name,
574574
const char *LinkageName, LLVMRustMetadataRef File, unsigned LineNo,
575575
LLVMRustMetadataRef Ty, bool IsLocalToUnit, LLVMValueRef V,
576-
LLVMRustMetadataRef Decl = nullptr, uint64_t AlignInBits = 0) {
576+
LLVMRustMetadataRef Decl = nullptr, uint32_t AlignInBits = 0) {
577577
Constant *InitVal = cast<Constant>(unwrap(V));
578578

579579
#if LLVM_VERSION_GE(4, 0)
@@ -612,7 +612,7 @@ extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateVariable(
612612
LLVMRustDIBuilderRef Builder, unsigned Tag, LLVMRustMetadataRef Scope,
613613
const char *Name, LLVMRustMetadataRef File, unsigned LineNo,
614614
LLVMRustMetadataRef Ty, bool AlwaysPreserve, LLVMRustDIFlags Flags,
615-
unsigned ArgNo, uint64_t AlignInBits) {
615+
unsigned ArgNo, uint32_t AlignInBits) {
616616
#if LLVM_VERSION_GE(3, 8)
617617
if (Tag == 0x100) { // DW_TAG_auto_variable
618618
return wrap(Builder->createAutoVariable(
@@ -637,7 +637,7 @@ extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateVariable(
637637

638638
extern "C" LLVMRustMetadataRef
639639
LLVMRustDIBuilderCreateArrayType(LLVMRustDIBuilderRef Builder, uint64_t Size,
640-
uint64_t AlignInBits, LLVMRustMetadataRef Ty,
640+
uint32_t AlignInBits, LLVMRustMetadataRef Ty,
641641
LLVMRustMetadataRef Subscripts) {
642642
return wrap(
643643
Builder->createArrayType(Size, AlignInBits, unwrapDI<DIType>(Ty),
@@ -646,7 +646,7 @@ LLVMRustDIBuilderCreateArrayType(LLVMRustDIBuilderRef Builder, uint64_t Size,
646646

647647
extern "C" LLVMRustMetadataRef
648648
LLVMRustDIBuilderCreateVectorType(LLVMRustDIBuilderRef Builder, uint64_t Size,
649-
uint64_t AlignInBits, LLVMRustMetadataRef Ty,
649+
uint32_t AlignInBits, LLVMRustMetadataRef Ty,
650650
LLVMRustMetadataRef Subscripts) {
651651
return wrap(
652652
Builder->createVectorType(Size, AlignInBits, unwrapDI<DIType>(Ty),
@@ -687,7 +687,7 @@ LLVMRustDIBuilderCreateEnumerator(LLVMRustDIBuilderRef Builder,
687687
extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateEnumerationType(
688688
LLVMRustDIBuilderRef Builder, LLVMRustMetadataRef Scope, const char *Name,
689689
LLVMRustMetadataRef File, unsigned LineNumber, uint64_t SizeInBits,
690-
uint64_t AlignInBits, LLVMRustMetadataRef Elements,
690+
uint32_t AlignInBits, LLVMRustMetadataRef Elements,
691691
LLVMRustMetadataRef ClassTy) {
692692
return wrap(Builder->createEnumerationType(
693693
unwrapDI<DIDescriptor>(Scope), Name, unwrapDI<DIFile>(File), LineNumber,
@@ -698,7 +698,7 @@ extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateEnumerationType(
698698
extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateUnionType(
699699
LLVMRustDIBuilderRef Builder, LLVMRustMetadataRef Scope, const char *Name,
700700
LLVMRustMetadataRef File, unsigned LineNumber, uint64_t SizeInBits,
701-
uint64_t AlignInBits, LLVMRustDIFlags Flags, LLVMRustMetadataRef Elements,
701+
uint32_t AlignInBits, LLVMRustDIFlags Flags, LLVMRustMetadataRef Elements,
702702
unsigned RunTimeLang, const char *UniqueId) {
703703
return wrap(Builder->createUnionType(
704704
unwrapDI<DIDescriptor>(Scope), Name, unwrapDI<DIFile>(File), LineNumber,

0 commit comments

Comments
 (0)