1
1
use std:: ops:: Range ;
2
2
3
- use rustc_abi:: {
4
- Align , AlignFromBytesError , HasDataLayout , Primitive , Scalar , Size , WrappingRange ,
5
- } ;
3
+ use rustc_abi:: { Align , HasDataLayout , Primitive , Scalar , Size , WrappingRange } ;
6
4
use rustc_codegen_ssa:: common;
7
5
use rustc_codegen_ssa:: traits:: * ;
8
6
use rustc_hir:: LangItem ;
@@ -20,9 +18,7 @@ use rustc_middle::{bug, span_bug};
20
18
use tracing:: { debug, instrument, trace} ;
21
19
22
20
use crate :: common:: { AsCCharPtr , CodegenCx } ;
23
- use crate :: errors:: {
24
- InvalidMinimumAlignmentNotPowerOfTwo , InvalidMinimumAlignmentTooLarge , SymbolAlreadyDefined ,
25
- } ;
21
+ use crate :: errors:: SymbolAlreadyDefined ;
26
22
use crate :: llvm:: { self , True } ;
27
23
use crate :: type_:: Type ;
28
24
use crate :: type_of:: LayoutLlvmExt ;
@@ -149,22 +145,10 @@ fn set_global_alignment<'ll>(cx: &CodegenCx<'ll, '_>, gv: &'ll Value, mut align:
149
145
// The target may require greater alignment for globals than the type does.
150
146
// Note: GCC and Clang also allow `__attribute__((aligned))` on variables,
151
147
// which can force it to be smaller. Rust doesn't support this yet.
152
- if let Some ( min) = cx. sess ( ) . target . min_global_align {
153
- match Align :: from_bits ( min) {
154
- Ok ( min) => align = align. max ( min) ,
155
- Err ( err) => match err {
156
- AlignFromBytesError :: NotPowerOfTwo ( align) => {
157
- cx. sess ( ) . dcx ( ) . emit_err ( InvalidMinimumAlignmentNotPowerOfTwo { align } ) ;
158
- }
159
- AlignFromBytesError :: TooLarge ( align) => {
160
- cx. sess ( ) . dcx ( ) . emit_err ( InvalidMinimumAlignmentTooLarge { align } ) ;
161
- }
162
- } ,
163
- }
164
- }
165
- unsafe {
166
- llvm:: LLVMSetAlignment ( gv, align. bytes ( ) as u32 ) ;
148
+ if let Some ( min_global) = cx. sess ( ) . target . min_global_align {
149
+ align = Ord :: max ( align, min_global) ;
167
150
}
151
+ llvm:: set_alignment ( gv, align) ;
168
152
}
169
153
170
154
fn check_and_apply_linkage < ' ll , ' tcx > (
0 commit comments