Skip to content

Commit 3b18f93

Browse files
committed
Fix va_list handling for Windows Arm64 ABI
1 parent 144812a commit 3b18f93

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

gcc/config/aarch64/aarch64.cc

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21411,6 +21411,17 @@ aarch64_expand_builtin_va_start (tree valist, rtx nextarg ATTRIBUTE_UNUSED)
2141121411
expand_expr (t, const0_rtx, VOIDmode, EXPAND_NORMAL);
2141221412
}
2141321413

21414+
#ifdef TARGET_AARCH64_MS_ABI
21415+
21416+
static void
21417+
aarch64_ms_abi_expand_builtin_va_start (tree valist, rtx nextarg)
21418+
{
21419+
nextarg = plus_constant (Pmode, nextarg, -4);
21420+
std_expand_builtin_va_start (valist, nextarg);
21421+
}
21422+
21423+
#endif
21424+
2141421425
/* Implement TARGET_GIMPLIFY_VA_ARG_EXPR. */
2141521426

2141621427
static tree
@@ -22562,9 +22573,12 @@ static const char *
2256222573
aarch64_mangle_type (const_tree type)
2256322574
{
2256422575
/* The AArch64 ABI documents say that "__va_list" has to be
22565-
mangled as if it is in the "std" namespace. */
22576+
mangled as if it is in the "std" namespace.
22577+
The Windows Arm64 ABI uses just a pointer to the first variadict argument. */
22578+
#ifndef TARGET_AARCH64_MS_ABI
2256622579
if (lang_hooks.types_compatible_p (CONST_CAST_TREE (type), va_list_type))
2256722580
return "St9__va_list";
22581+
#endif
2256822582

2256922583
/* Half-precision floating point types. */
2257022584
if (SCALAR_FLOAT_TYPE_P (type) && TYPE_PRECISION (type) == 16)
@@ -30790,8 +30804,10 @@ aarch64_run_selftests (void)
3079030804
#undef TARGET_ASM_PRINT_PATCHABLE_FUNCTION_ENTRY
3079130805
#define TARGET_ASM_PRINT_PATCHABLE_FUNCTION_ENTRY aarch64_print_patchable_function_entry
3079230806

30807+
#ifndef TARGET_AARCH64_MS_ABI
3079330808
#undef TARGET_BUILD_BUILTIN_VA_LIST
3079430809
#define TARGET_BUILD_BUILTIN_VA_LIST aarch64_build_builtin_va_list
30810+
#endif
3079530811

3079630812
#undef TARGET_CALLEE_COPIES
3079730813
#define TARGET_CALLEE_COPIES hook_bool_CUMULATIVE_ARGS_arg_info_false
@@ -30862,7 +30878,11 @@ aarch64_run_selftests (void)
3086230878
#define TARGET_EXPAND_BUILTIN aarch64_expand_builtin
3086330879

3086430880
#undef TARGET_EXPAND_BUILTIN_VA_START
30881+
#ifdef TARGET_AARCH64_MS_ABI
30882+
#define TARGET_EXPAND_BUILTIN_VA_START aarch64_ms_abi_expand_builtin_va_start
30883+
#else
3086530884
#define TARGET_EXPAND_BUILTIN_VA_START aarch64_expand_builtin_va_start
30885+
#endif
3086630886

3086730887
#undef TARGET_FOLD_BUILTIN
3086830888
#define TARGET_FOLD_BUILTIN aarch64_fold_builtin
@@ -30902,8 +30922,10 @@ aarch64_run_selftests (void)
3090230922
#undef TARGET_GIMPLE_FOLD_BUILTIN
3090330923
#define TARGET_GIMPLE_FOLD_BUILTIN aarch64_gimple_fold_builtin
3090430924

30925+
#ifndef TARGET_AARCH64_MS_ABI
3090530926
#undef TARGET_GIMPLIFY_VA_ARG_EXPR
3090630927
#define TARGET_GIMPLIFY_VA_ARG_EXPR aarch64_gimplify_va_arg_expr
30928+
#endif
3090730929

3090830930
#undef TARGET_INIT_BUILTINS
3090930931
#define TARGET_INIT_BUILTINS aarch64_init_builtins

0 commit comments

Comments
 (0)