Skip to content

Commit

Permalink
Rollup merge of rust-lang#39529 - dylanmckay:llvm-4.0-align32, r=alex…
Browse files Browse the repository at this point in the history
…crichton

[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.
  • Loading branch information
frewsxcv committed Feb 8, 2017
2 parents 96bf9ba + c7bea76 commit 7709c4d
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 26 deletions.
20 changes: 10 additions & 10 deletions src/librustc_llvm/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1369,14 +1369,14 @@ extern "C" {
pub fn LLVMRustDIBuilderCreateBasicType(Builder: DIBuilderRef,
Name: *const c_char,
SizeInBits: u64,
AlignInBits: u64,
AlignInBits: u32,
Encoding: c_uint)
-> DIBasicType;

pub fn LLVMRustDIBuilderCreatePointerType(Builder: DIBuilderRef,
PointeeTy: DIType,
SizeInBits: u64,
AlignInBits: u64,
AlignInBits: u32,
Name: *const c_char)
-> DIDerivedType;

Expand All @@ -1386,7 +1386,7 @@ extern "C" {
File: DIFile,
LineNumber: c_uint,
SizeInBits: u64,
AlignInBits: u64,
AlignInBits: u32,
Flags: DIFlags,
DerivedFrom: DIType,
Elements: DIArray,
Expand All @@ -1401,7 +1401,7 @@ extern "C" {
File: DIFile,
LineNo: c_uint,
SizeInBits: u64,
AlignInBits: u64,
AlignInBits: u32,
OffsetInBits: u64,
Flags: DIFlags,
Ty: DIType)
Expand Down Expand Up @@ -1429,7 +1429,7 @@ extern "C" {
isLocalToUnit: bool,
Val: ValueRef,
Decl: DIDescriptor,
AlignInBits: u64)
AlignInBits: u32)
-> DIGlobalVariable;

pub fn LLVMRustDIBuilderCreateVariable(Builder: DIBuilderRef,
Expand All @@ -1442,19 +1442,19 @@ extern "C" {
AlwaysPreserve: bool,
Flags: DIFlags,
ArgNo: c_uint,
AlignInBits: u64)
AlignInBits: u32)
-> DIVariable;

pub fn LLVMRustDIBuilderCreateArrayType(Builder: DIBuilderRef,
Size: u64,
AlignInBits: u64,
AlignInBits: u32,
Ty: DIType,
Subscripts: DIArray)
-> DIType;

pub fn LLVMRustDIBuilderCreateVectorType(Builder: DIBuilderRef,
Size: u64,
AlignInBits: u64,
AlignInBits: u32,
Ty: DIType,
Subscripts: DIArray)
-> DIType;
Expand Down Expand Up @@ -1489,7 +1489,7 @@ extern "C" {
File: DIFile,
LineNumber: c_uint,
SizeInBits: u64,
AlignInBits: u64,
AlignInBits: u32,
Elements: DIArray,
ClassType: DIType)
-> DIType;
Expand All @@ -1500,7 +1500,7 @@ extern "C" {
File: DIFile,
LineNumber: c_uint,
SizeInBits: u64,
AlignInBits: u64,
AlignInBits: u32,
Flags: DIFlags,
Elements: DIArray,
RunTimeLang: c_uint,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_trans/debuginfo/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1783,7 +1783,7 @@ pub fn create_global_var_metadata(cx: &CrateContext,
is_local_to_unit,
global,
ptr::null_mut(),
global_align as u64,
global_align,
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_trans/debuginfo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ pub fn declare_local<'a, 'tcx>(bcx: &Builder<'a, 'tcx>,
cx.sess().opts.optimize != config::OptLevel::No,
DIFlags::FlagZero,
argument_index,
align as u64,
align,
)
};
source_loc::set_debug_location(bcx,
Expand Down
11 changes: 7 additions & 4 deletions src/librustc_trans/debuginfo/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ use type_::Type;
use syntax_pos::{self, Span};
use syntax::ast;

use std::ops;

pub fn is_node_local_to_unit(cx: &CrateContext, node_id: ast::NodeId) -> bool
{
// The is_local_to_unit flag indicates whether a function is local to the
Expand All @@ -49,12 +51,13 @@ pub fn span_start(cx: &CrateContext, span: Span) -> syntax_pos::Loc {
cx.sess().codemap().lookup_char_pos(span.lo)
}

pub fn size_and_align_of(cx: &CrateContext, llvm_type: Type) -> (u64, u64) {
(machine::llsize_of_alloc(cx, llvm_type), machine::llalign_of_min(cx, llvm_type) as u64)
pub fn size_and_align_of(cx: &CrateContext, llvm_type: Type) -> (u64, u32) {
(machine::llsize_of_alloc(cx, llvm_type), machine::llalign_of_min(cx, llvm_type))
}

pub fn bytes_to_bits(bytes: u64) -> u64 {
bytes * 8
pub fn bytes_to_bits<T>(bytes: T) -> T
where T: ops::Mul<Output=T> + From<u8> {
bytes * 8u8.into()
}

#[inline]
Expand Down
20 changes: 10 additions & 10 deletions src/rustllvm/RustWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateFunction(

extern "C" LLVMRustMetadataRef
LLVMRustDIBuilderCreateBasicType(LLVMRustDIBuilderRef Builder, const char *Name,
uint64_t SizeInBits, uint64_t AlignInBits,
uint64_t SizeInBits, uint32_t AlignInBits,
unsigned Encoding) {
return wrap(Builder->createBasicType(Name, SizeInBits,
#if LLVM_VERSION_LE(3, 9)
Expand All @@ -524,15 +524,15 @@ LLVMRustDIBuilderCreateBasicType(LLVMRustDIBuilderRef Builder, const char *Name,

extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreatePointerType(
LLVMRustDIBuilderRef Builder, LLVMRustMetadataRef PointeeTy,
uint64_t SizeInBits, uint64_t AlignInBits, const char *Name) {
uint64_t SizeInBits, uint32_t AlignInBits, const char *Name) {
return wrap(Builder->createPointerType(unwrapDI<DIType>(PointeeTy),
SizeInBits, AlignInBits, Name));
}

extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateStructType(
LLVMRustDIBuilderRef Builder, LLVMRustMetadataRef Scope, const char *Name,
LLVMRustMetadataRef File, unsigned LineNumber, uint64_t SizeInBits,
uint64_t AlignInBits, LLVMRustDIFlags Flags,
uint32_t AlignInBits, LLVMRustDIFlags Flags,
LLVMRustMetadataRef DerivedFrom, LLVMRustMetadataRef Elements,
unsigned RunTimeLang, LLVMRustMetadataRef VTableHolder,
const char *UniqueId) {
Expand All @@ -546,7 +546,7 @@ extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateStructType(
extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateMemberType(
LLVMRustDIBuilderRef Builder, LLVMRustMetadataRef Scope, const char *Name,
LLVMRustMetadataRef File, unsigned LineNo, uint64_t SizeInBits,
uint64_t AlignInBits, uint64_t OffsetInBits, LLVMRustDIFlags Flags,
uint32_t AlignInBits, uint64_t OffsetInBits, LLVMRustDIFlags Flags,
LLVMRustMetadataRef Ty) {
return wrap(Builder->createMemberType(unwrapDI<DIDescriptor>(Scope), Name,
unwrapDI<DIFile>(File), LineNo,
Expand All @@ -573,7 +573,7 @@ extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateStaticVariable(
LLVMRustDIBuilderRef Builder, LLVMRustMetadataRef Context, const char *Name,
const char *LinkageName, LLVMRustMetadataRef File, unsigned LineNo,
LLVMRustMetadataRef Ty, bool IsLocalToUnit, LLVMValueRef V,
LLVMRustMetadataRef Decl = nullptr, uint64_t AlignInBits = 0) {
LLVMRustMetadataRef Decl = nullptr, uint32_t AlignInBits = 0) {
Constant *InitVal = cast<Constant>(unwrap(V));

#if LLVM_VERSION_GE(4, 0)
Expand Down Expand Up @@ -612,7 +612,7 @@ extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateVariable(
LLVMRustDIBuilderRef Builder, unsigned Tag, LLVMRustMetadataRef Scope,
const char *Name, LLVMRustMetadataRef File, unsigned LineNo,
LLVMRustMetadataRef Ty, bool AlwaysPreserve, LLVMRustDIFlags Flags,
unsigned ArgNo, uint64_t AlignInBits) {
unsigned ArgNo, uint32_t AlignInBits) {
#if LLVM_VERSION_GE(3, 8)
if (Tag == 0x100) { // DW_TAG_auto_variable
return wrap(Builder->createAutoVariable(
Expand All @@ -637,7 +637,7 @@ extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateVariable(

extern "C" LLVMRustMetadataRef
LLVMRustDIBuilderCreateArrayType(LLVMRustDIBuilderRef Builder, uint64_t Size,
uint64_t AlignInBits, LLVMRustMetadataRef Ty,
uint32_t AlignInBits, LLVMRustMetadataRef Ty,
LLVMRustMetadataRef Subscripts) {
return wrap(
Builder->createArrayType(Size, AlignInBits, unwrapDI<DIType>(Ty),
Expand All @@ -646,7 +646,7 @@ LLVMRustDIBuilderCreateArrayType(LLVMRustDIBuilderRef Builder, uint64_t Size,

extern "C" LLVMRustMetadataRef
LLVMRustDIBuilderCreateVectorType(LLVMRustDIBuilderRef Builder, uint64_t Size,
uint64_t AlignInBits, LLVMRustMetadataRef Ty,
uint32_t AlignInBits, LLVMRustMetadataRef Ty,
LLVMRustMetadataRef Subscripts) {
return wrap(
Builder->createVectorType(Size, AlignInBits, unwrapDI<DIType>(Ty),
Expand Down Expand Up @@ -687,7 +687,7 @@ LLVMRustDIBuilderCreateEnumerator(LLVMRustDIBuilderRef Builder,
extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateEnumerationType(
LLVMRustDIBuilderRef Builder, LLVMRustMetadataRef Scope, const char *Name,
LLVMRustMetadataRef File, unsigned LineNumber, uint64_t SizeInBits,
uint64_t AlignInBits, LLVMRustMetadataRef Elements,
uint32_t AlignInBits, LLVMRustMetadataRef Elements,
LLVMRustMetadataRef ClassTy) {
return wrap(Builder->createEnumerationType(
unwrapDI<DIDescriptor>(Scope), Name, unwrapDI<DIFile>(File), LineNumber,
Expand All @@ -698,7 +698,7 @@ extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateEnumerationType(
extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateUnionType(
LLVMRustDIBuilderRef Builder, LLVMRustMetadataRef Scope, const char *Name,
LLVMRustMetadataRef File, unsigned LineNumber, uint64_t SizeInBits,
uint64_t AlignInBits, LLVMRustDIFlags Flags, LLVMRustMetadataRef Elements,
uint32_t AlignInBits, LLVMRustDIFlags Flags, LLVMRustMetadataRef Elements,
unsigned RunTimeLang, const char *UniqueId) {
return wrap(Builder->createUnionType(
unwrapDI<DIDescriptor>(Scope), Name, unwrapDI<DIFile>(File), LineNumber,
Expand Down

0 comments on commit 7709c4d

Please sign in to comment.