Auto merge of #122972 - beetrees:use-align-type, r=fee1-dead

Use the `Align` type when parsing alignment attributes

Use the `Align` type in `rustc_attr::parse_alignment`, removing the need to call `Align::from_bytes(...).unwrap()` later in the compilation process.
This commit is contained in:
bors 2024-04-01 03:16:45 +00:00
commit defef8658e
12 changed files with 74 additions and 26 deletions

View file

@ -16,6 +16,7 @@ use rustc_middle::bug;
use rustc_middle::mir::coverage::CoverageKind;
use rustc_middle::ty::layout::HasTyCtxt;
use rustc_middle::ty::Instance;
use rustc_target::abi::Align;
use std::cell::RefCell;
@ -23,7 +24,7 @@ pub(crate) mod ffi;
pub(crate) mod map_data;
pub mod mapgen;
const VAR_ALIGN_BYTES: usize = 8;
const VAR_ALIGN: Align = Align::EIGHT;
/// A context object for maintaining all state needed by the coverageinfo module.
pub struct CrateCoverageContext<'ll, 'tcx> {
@ -225,7 +226,7 @@ pub(crate) fn save_cov_data_to_mod<'ll, 'tcx>(
llvm::set_global_constant(llglobal, true);
llvm::set_linkage(llglobal, llvm::Linkage::PrivateLinkage);
llvm::set_section(llglobal, &covmap_section_name);
llvm::set_alignment(llglobal, VAR_ALIGN_BYTES);
llvm::set_alignment(llglobal, VAR_ALIGN);
cx.add_used_global(llglobal);
}
@ -255,7 +256,7 @@ pub(crate) fn save_func_record_to_mod<'ll, 'tcx>(
llvm::set_linkage(llglobal, llvm::Linkage::LinkOnceODRLinkage);
llvm::set_visibility(llglobal, llvm::Visibility::Hidden);
llvm::set_section(llglobal, covfun_section_name);
llvm::set_alignment(llglobal, VAR_ALIGN_BYTES);
llvm::set_alignment(llglobal, VAR_ALIGN);
llvm::set_comdat(cx.llmod, llglobal, &func_record_var_name);
cx.add_used_global(llglobal);
}