@@ -105,13 +105,30 @@ pub(super) fn emit_va_arg(
105105) -> & ' ll Value {
106106 // Determine the va_arg implementation to use. The LLVM va_arg instruction
107107 // is lacking in some instances, so we should only use it as a fallback.
108+ let target = & bx. cx . tcx . sess . target . target ;
108109 let arch = & bx. cx . tcx . sess . target . target . arch ;
109- match ( & * * arch,
110- bx . cx . tcx . sess . target . target . options . is_like_windows ) {
110+ match ( & * * arch, target . options . is_like_windows ) {
111+ // Windows x86
111112 ( "x86" , true ) => {
112113 emit_ptr_va_arg ( bx, addr, target_ty, false ,
113114 Align :: from_bytes ( 4 ) . unwrap ( ) , false )
114115 }
116+ // Generic x86
117+ ( "x86" , _) => {
118+ emit_ptr_va_arg ( bx, addr, target_ty, false ,
119+ Align :: from_bytes ( 4 ) . unwrap ( ) , true )
120+ }
121+ // Windows Aarch64
122+ ( "aarch4" , true ) => {
123+ emit_ptr_va_arg ( bx, addr, target_ty, false ,
124+ Align :: from_bytes ( 8 ) . unwrap ( ) , false )
125+ }
126+ // iOS Aarch64
127+ ( "aarch4" , _) if target. target_os == "ios" => {
128+ emit_ptr_va_arg ( bx, addr, target_ty, false ,
129+ Align :: from_bytes ( 8 ) . unwrap ( ) , true )
130+ }
131+ // Windows x86_64
115132 ( "x86_64" , true ) => {
116133 let target_ty_size = bx. cx . size_of ( target_ty) . bytes ( ) ;
117134 let indirect = if target_ty_size > 8 || !target_ty_size. is_power_of_two ( ) {
@@ -122,15 +139,14 @@ pub(super) fn emit_va_arg(
122139 emit_ptr_va_arg ( bx, addr, target_ty, indirect,
123140 Align :: from_bytes ( 8 ) . unwrap ( ) , false )
124141 }
125- ( "x86" , false ) => {
126- emit_ptr_va_arg ( bx, addr, target_ty, false ,
127- Align :: from_bytes ( 4 ) . unwrap ( ) , true )
128- }
142+ // For all other architecture/OS combinations fall back to using
143+ // the LLVM va_arg instruction.
144+ // https://llvm.org/docs/LangRef.html#va-arg-instruction
129145 _ => {
130- let va_list = if ( bx . tcx ( ) . sess . target . target . arch == "aarch64" ||
131- bx . tcx ( ) . sess . target . target . arch == "x86_64" ||
132- bx . tcx ( ) . sess . target . target . arch == "powerpc" ) &&
133- !bx . tcx ( ) . sess . target . target . options . is_like_windows {
146+ let va_list = if ( target. arch == "aarch64" ||
147+ target. arch == "x86_64" ||
148+ target. arch == "powerpc" ) &&
149+ !target. options . is_like_windows {
134150 bx. load ( addr. immediate ( ) , bx. tcx ( ) . data_layout . pointer_align . abi )
135151 } else {
136152 addr. immediate ( )
0 commit comments