HomePhabricator

[X86] Fix variadic argument handling for x32

Authored by hvdijk on Dec 14 2020, 3:47 PM.

Description

[X86] Fix variadic argument handling for x32

The X86-64 ABI defines va_list as

typedef struct {
  unsigned int gp_offset;
  unsigned int fp_offset;
  void *overflow_arg_area;
  void *reg_save_area;
} va_list[1];

This means the size, alignment, and reg_save_area offset will depend on
whether we are in LP64 or in ILP32 mode, so this commit adds the checks.
Additionally, the VAARG_64 pseudo-instruction assumed 64-bit pointers, so
this commit adds a VAARG_X32 pseudo-instruction that behaves just like
VAARG_64, except for assuming 32-bit pointers.

Some of these changes were originally done by
Michael Liao <michael.hliao@gmail.com>.

Fixes https://bugs.llvm.org/show_bug.cgi?id=48428.

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D93160

Details

Committed
hvdijkDec 14 2020, 3:47 PM
Reviewer
RKSimon
Differential Revision
D93160: [X86] Fix variadic argument handling for x32
Parents
rGd058b69b1cd3: [lld/mac] implement -compatibility_version, -current_version
Branches
Unknown
Tags
Unknown