compiler/rustc_codegen_llvm/src/intrinsic.rs before after
- @@ compiler/rustc_codegen_llvm/src/intrinsic.rs: use rustc_session::config::CrateType;
- use rustc_span::{Span, Symbol, sym};
- use rustc_symbol_mangling::{mangle_internal_symbol, symbol_name_for_instance_in_crate};
- use rustc_target::callconv::PassMode;
- -use rustc_target::spec::Os;
- +use rustc_target::spec::{Arch, Os};
- use tracing::debug;
-
- use crate::abi::FnAbiLlvmExt;
@@ compiler/rustc_codegen_llvm/src/intrinsic.rs: impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
}
sym::breakpoint => self.call_intrinsic("llvm.debugtrap", &[], &[]),
+ emit_va_arg(self, args[0], result.layout.ty)
+ }
+ Primitive::Int(..) => {
- + // `va_arg` should not be called on an integer type
- + // less than c_int (typically i32, but i16 on e.g. avr).
- + assert!({
- + let int_width = self.cx().size_of(result.layout.ty).bits();
- + let target_c_int_width = self.cx().sess().target.options.c_int_width;
- +
- + int_width >= u64::from(target_c_int_width)
- + });
+ + let int_width = self.cx().size_of(result.layout.ty).bits();
+ + let target_c_int_width = self.cx().sess().target.options.c_int_width;
+ + if int_width < u64::from(target_c_int_width) {
+ + // Smaller integer types are automatically promototed and `va_arg`
+ + // should not be called on them.
+ + bug!(
+ + "va_arg got i{} but needs at least c_int (an i{})",
+ + int_width,
+ + target_c_int_width
+ + );
+ }
+ emit_va_arg(self, args[0], result.layout.ty)
+ }
+ Primitive::Float(Float::F16) => {
+ emit_va_arg(self, args[0], result.layout.ty)
+ } else {
+ bug!("the va_arg intrinsic does not support `f32` on this target")
- }
- }
- - _ => bug!("the va_arg intrinsic does not work with non-scalar types"),
+ + }
+ + }
+ Primitive::Float(Float::F64) => {
+ // 64-bit floats are always OK.
+ emit_va_arg(self, args[0], result.layout.ty)
+ }
+ Primitive::Float(Float::F128) => {
+ bug!("the va_arg intrinsic does not support `f128`")
- + }
+ }
+ - _ => bug!("the va_arg intrinsic does not work with non-scalar types"),
}
}