[all-commits] [llvm/llvm-project] b7e110: [X86] Align stack to 16-bytes on 32-bit with X86_I...

antangelo via All-commits all-commits at lists.llvm.org
Thu Jun 1 02:00:54 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: b7e110fcfe22a1f887507dbaa6fdb001630e223d
      https://github.com/llvm/llvm-project/commit/b7e110fcfe22a1f887507dbaa6fdb001630e223d
  Author: Antonio Abbatangelo <contact at antangelo.com>
  Date:   2023-06-01 (Thu, 01 Jun 2023)

  Changed paths:
    M llvm/lib/Target/X86/X86FrameLowering.cpp
    M llvm/lib/Target/X86/X86RegisterInfo.cpp
    M llvm/lib/Target/X86/X86RegisterInfo.h
    M llvm/test/CodeGen/X86/x86-32-intrcc.ll
    M llvm/test/CodeGen/X86/x86-interrupt_cc.ll

  Log Message:
  -----------
  [X86] Align stack to 16-bytes on 32-bit with X86_INTR call convention

Adds a dynamic stack alignment to functions under the interrupt call
convention on x86-32. This fixes the issue where the stack can be
misaligned on entry, since x86-32 makes no guarantees about the stack
pointer position when the interrupt service routine is called.

The alignment is done by overriding X86RegisterInfo::shouldRealignStack,
and by setting the correct alignment in X86FrameLowering::calculateMaxStackAlign.
This forces the interrupt handler to be dynamically aligned, generating
the appropriate `and` instruction in the prologue and `lea` in the
epilogue. The `no-realign-stack` attribute can be used as an opt-out.

Fixes #26851

Reviewed By: pengfei

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




More information about the All-commits mailing list