Skip to content

librustc_codegen_llvm: Pass bitflags as raw integral types for FFI (#61306) #61867

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/librustc_codegen_llvm/debuginfo/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1039,7 +1039,7 @@ impl<'ll> MemberDescription<'ll> {
None => None,
Some(value) => Some(cx.const_u64(value)),
},
self.flags,
self.flags.bits(),
self.type_metadata)
}
}
Expand Down Expand Up @@ -1837,7 +1837,7 @@ fn prepare_enum_metadata(
UNKNOWN_LINE_NUMBER,
layout.size.bits(),
layout.align.abi.bits() as u32,
DIFlags::FlagZero,
DIFlags::FlagZero.bits(),
None,
0, // RuntimeLang
unique_type_id_str.as_ptr())
Expand Down Expand Up @@ -1896,7 +1896,7 @@ fn prepare_enum_metadata(
size.bits(),
align.abi.bits() as u32,
layout.fields.offset(discr_index).bits(),
DIFlags::FlagArtificial,
DIFlags::FlagArtificial.bits(),
discr_metadata))
}
},
Expand All @@ -1921,7 +1921,7 @@ fn prepare_enum_metadata(
size.bits(),
align.bits() as u32,
layout.fields.offset(discr_index).bits(),
DIFlags::FlagArtificial,
DIFlags::FlagArtificial.bits(),
discr_metadata))
}
},
Expand Down Expand Up @@ -1958,7 +1958,7 @@ fn prepare_enum_metadata(
UNKNOWN_LINE_NUMBER,
layout.size.bits(),
layout.align.abi.bits() as u32,
DIFlags::FlagZero,
DIFlags::FlagZero.bits(),
discriminator_metadata,
empty_array,
variant_part_unique_type_id_str.as_ptr())
Expand All @@ -1976,7 +1976,7 @@ fn prepare_enum_metadata(
UNKNOWN_LINE_NUMBER,
layout.size.bits(),
layout.align.abi.bits() as u32,
DIFlags::FlagZero,
DIFlags::FlagZero.bits(),
None,
type_array,
0,
Expand Down Expand Up @@ -2142,7 +2142,7 @@ fn create_struct_stub(
UNKNOWN_LINE_NUMBER,
struct_size.bits(),
struct_align.bits() as u32,
DIFlags::FlagZero,
DIFlags::FlagZero.bits(),
None,
empty_array,
0,
Expand Down Expand Up @@ -2180,7 +2180,7 @@ fn create_union_stub(
UNKNOWN_LINE_NUMBER,
union_size.bits(),
union_align.bits() as u32,
DIFlags::FlagZero,
DIFlags::FlagZero.bits(),
Some(empty_array),
0, // RuntimeLang
unique_type_id.as_ptr())
Expand Down Expand Up @@ -2283,7 +2283,7 @@ pub fn create_vtable_metadata(cx: &CodegenCx<'ll, 'tcx>, ty: Ty<'tcx>, vtable: &
UNKNOWN_LINE_NUMBER,
Size::ZERO.bits(),
cx.tcx.data_layout.pointer_align.abi.bits() as u32,
DIFlags::FlagArtificial,
DIFlags::FlagArtificial.bits(),
None,
empty_array,
0,
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_codegen_llvm/debuginfo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ impl DebugInfoBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> {
loc.line as c_uint,
type_metadata,
cx.sess().opts.optimize != config::OptLevel::No,
DIFlags::FlagZero,
DIFlags::FlagZero.bits(),
argument_index,
align.bytes() as u32,
)
Expand Down Expand Up @@ -321,8 +321,8 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
loc.line as c_uint,
function_type_metadata,
scope_line as c_uint,
flags,
spflags,
flags.bits(),
spflags.bits(),
llfn,
template_parameters,
None)
Expand Down
24 changes: 11 additions & 13 deletions src/librustc_codegen_llvm/llvm/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use super::debuginfo::{
DIBuilder, DIDescriptor, DIFile, DILexicalBlock, DISubprogram, DIType,
DIBasicType, DIDerivedType, DICompositeType, DIScope, DIVariable,
DIGlobalVariableExpression, DIArray, DISubrange, DITemplateTypeParameter, DIEnumerator,
DINameSpace, DIFlags, DISPFlags, DebugEmissionKind,
DINameSpace, DebugEmissionKind,
};

use libc::{c_uint, c_int, size_t, c_char};
Expand Down Expand Up @@ -564,9 +564,8 @@ pub mod debuginfo {

// These values **must** match with LLVMRustDIFlags!!
bitflags! {
#[repr(C)]
#[derive(Default)]
pub struct DIFlags: ::libc::uint32_t {
pub struct DIFlags: u32 {
const FlagZero = 0;
const FlagPrivate = 1;
const FlagProtected = 2;
Expand All @@ -593,9 +592,8 @@ pub mod debuginfo {

// These values **must** match with LLVMRustDISPFlags!!
bitflags! {
#[repr(C)]
#[derive(Default)]
pub struct DISPFlags: ::libc::uint32_t {
pub struct DISPFlags: u32 {
const SPFlagZero = 0;
const SPFlagVirtual = 1;
const SPFlagPureVirtual = 2;
Expand Down Expand Up @@ -1452,8 +1450,8 @@ extern "C" {
LineNo: c_uint,
Ty: &'a DIType,
ScopeLine: c_uint,
Flags: DIFlags,
SPFlags: DISPFlags,
Flags: u32,
SPFlags: u32,
Fn: &'a Value,
TParam: &'a DIArray,
Decl: Option<&'a DIDescriptor>)
Expand All @@ -1480,7 +1478,7 @@ extern "C" {
LineNumber: c_uint,
SizeInBits: u64,
AlignInBits: u32,
Flags: DIFlags,
Flags: u32,
DerivedFrom: Option<&'a DIType>,
Elements: &'a DIArray,
RunTimeLang: c_uint,
Expand All @@ -1496,7 +1494,7 @@ extern "C" {
SizeInBits: u64,
AlignInBits: u32,
OffsetInBits: u64,
Flags: DIFlags,
Flags: u32,
Ty: &'a DIType)
-> &'a DIDerivedType;

Expand All @@ -1509,7 +1507,7 @@ extern "C" {
AlignInBits: u32,
OffsetInBits: u64,
Discriminant: Option<&'a Value>,
Flags: DIFlags,
Flags: u32,
Ty: &'a DIType)
-> &'a DIType;

Expand Down Expand Up @@ -1546,7 +1544,7 @@ extern "C" {
LineNo: c_uint,
Ty: &'a DIType,
AlwaysPreserve: bool,
Flags: DIFlags,
Flags: u32,
ArgNo: c_uint,
AlignInBits: u32)
-> &'a DIVariable;
Expand Down Expand Up @@ -1601,7 +1599,7 @@ extern "C" {
LineNumber: c_uint,
SizeInBits: u64,
AlignInBits: u32,
Flags: DIFlags,
Flags: u32,
Elements: Option<&'a DIArray>,
RunTimeLang: c_uint,
UniqueId: *const c_char)
Expand All @@ -1614,7 +1612,7 @@ extern "C" {
LineNo: c_uint,
SizeInBits: u64,
AlignInBits: u32,
Flags: DIFlags,
Flags: u32,
Discriminator: Option<&'a DIDerivedType>,
Elements: &'a DIArray,
UniqueId: *const c_char)
Expand Down