[PATCH] D93160: [X86] Fix variadic argument handling for x32

Harald van Dijk via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Dec 12 04:39:19 PST 2020


hvdijk created this revision.
hvdijk added reviewers: craig.topper, RKSimon.
Herald added subscribers: pengfei, hiraditya, arichardson.
hvdijk requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

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 at gmail.com>.

           

As stack offsets were wrong because of this, this adds to
update_llc_test_checks.py the --no_x86_scrub_sp option to preserve stack
offsets in lit tests, and uses it to update x86-64-varargs.ll to test
the changes.

             

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93160

Files:
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Target/X86/X86ISelLowering.h
  llvm/lib/Target/X86/X86InstrCompiler.td
  llvm/lib/Target/X86/X86InstrInfo.td
  llvm/test/CodeGen/X86/x86-64-varargs.ll
  llvm/utils/UpdateTestChecks/asm.py
  llvm/utils/update_llc_test_checks.py

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93160.311379.patch
Type: text/x-patch
Size: 39189 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201212/7b5d50de/attachment.bin>


More information about the llvm-commits mailing list