[all-commits] [llvm/llvm-project] 2293d4: [clang] [Headers] Check __SEH__, when checking if ...

Martin Storsjö via All-commits all-commits at lists.llvm.org
Mon Jun 6 13:28:12 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 2293d46a01752e312a0796d044a25a49b2fd17f5
      https://github.com/llvm/llvm-project/commit/2293d46a01752e312a0796d044a25a49b2fd17f5
  Author: Martin Storsjö <martin at martin.st>
  Date:   2022-06-06 (Mon, 06 Jun 2022)

  Changed paths:
    M clang/lib/Headers/unwind.h

  Log Message:
  -----------
  [clang] [Headers] Check __SEH__, when checking if ARM EHABI is implied

ARM EHABI isn't signalled by any specific compiler builtin define,
but is implied by the lack of defines specifying any other
exception handling mechanism, `__USING_SJLJ_EXCEPTIONS__` or
`__ARM_DWARF_EH__`.

As Windows SEH also can be used for unwinding, check for the
`__SEH__` define too, in the same way.

This is the same change as 4a3722a2c3dff1fe885cc38bf43d3c095c9851e7 /
D126866, applied on the clang headers.

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


  Commit: 03c19f41a26a8007b6c994eea3b3c308562e6d59
      https://github.com/llvm/llvm-project/commit/03c19f41a26a8007b6c994eea3b3c308562e6d59
  Author: Martin Storsjö <martin at martin.st>
  Date:   2022-06-06 (Mon, 06 Jun 2022)

  Changed paths:
    M compiler-rt/lib/builtins/gcc_personality_v0.c

  Log Message:
  -----------
  [builtins] Check __SEH__, when checking if ARM EHABI is implied

ARM EHABI isn't signalled by any specific compiler builtin define,
but is implied by the lack of defines specifying any other
exception handling mechanism, `__USING_SJLJ_EXCEPTIONS__` or
`__ARM_DWARF_EH__`.

As Windows SEH also can be used for unwinding, check for the
`__SEH__` define too, in the same way.

This is the same change as 4a3722a2c3dff1fe885cc38bf43d3c095c9851e7 /
D126866, applied on the compiler-rt builtins gcc_personality_v0
function.

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


  Commit: 7c0e93cb89e6aa74881411213abf83faae7c58ee
      https://github.com/llvm/llvm-project/commit/7c0e93cb89e6aa74881411213abf83faae7c58ee
  Author: Martin Storsjö <martin at martin.st>
  Date:   2022-06-06 (Mon, 06 Jun 2022)

  Changed paths:
    M libunwind/include/__libunwind_config.h
    M libunwind/include/libunwind.h
    M libunwind/src/Unwind-seh.cpp
    M libunwind/src/UnwindCursor.hpp

  Log Message:
  -----------
  [libunwind] Fix SEH unwinding on ARM

Check `__SEH__` when checking if ARM EHABI should be implied,
similarly to 4a3722a2c3dff1fe885cc38bf43d3c095c9851e7 / D126866.

Fix a warning by using the right format specifier (PRIxPTR instead
of PRIx64), and add a double->float cast in a codepath that hasn't
been built so far.

This is enough to make SEH unwinding of itanium ABI exceptions on
ARM mostly work - one specific issue is fixed in a separate follow-up
patch.

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


  Commit: 64778c002a77046e15a7ce7a7206f5c15355fc26
      https://github.com/llvm/llvm-project/commit/64778c002a77046e15a7ce7a7206f5c15355fc26
  Author: Martin Storsjö <martin at martin.st>
  Date:   2022-06-06 (Mon, 06 Jun 2022)

  Changed paths:
    M libunwind/src/UnwindCursor.hpp

  Log Message:
  -----------
  [libunwind] Remove unused ARM SEH placeholder code

There's no such corresponding code for ARM64 (which has been working
in production for years). The SEH version of the Unwind functions
(e.g. `_Unwind_GetLanguageSpecificData`) doesn't use these fields.

The `_Unwind_ForcedUnwind` function would need these bits though,
but that's not used in normal C++ exception unwinding.

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


  Commit: 08d30c602bcf3bc25a02938f2663a1b9e96a7cbe
      https://github.com/llvm/llvm-project/commit/08d30c602bcf3bc25a02938f2663a1b9e96a7cbe
  Author: Martin Storsjö <martin at martin.st>
  Date:   2022-06-06 (Mon, 06 Jun 2022)

  Changed paths:
    M libunwind/src/Unwind-seh.cpp
    M libunwind/src/UnwindCursor.hpp

  Log Message:
  -----------
  [libunwind] Don't store a predecremented PC when using SEH

This fixes unwinding in boundary cases on ARM with SEH.

In the case of ARM/Thumb, disp->ControlPc points at the following
instruction, with the thumb bit set. Thus by decrementing 1,
it still points at the next instruction. To achieve the desired
effect of pointing at the previous instruction, one first has to strip
out the thumb bit, then do the decrement by 1 to reach the previous
instruction.

When libcxxabi looks for call site ranges, it already does
`_Unwind_GetIP(context) - 1` (in `scan_eh_tab` in
libcxxabi/src/cxa_personality.cpp), so we shouldn't do the
corresponding `- 1` multiple times.

In the case of libcxxabi on Thumb, `funcStart` (still in `scan_eh_tab`)
may have the thumb bit set. If the program counter address is
decremented both in libunwind (first removing the thumb bit, then
decremented), and then libcxxabi decrements it further, and compares
with a `funcStart` with the thumb bit set, it could point to one byte
before the start of the call site.

Thus: This modification makes libunwind with SEH work with libcxxabi
on Thumb, in settings where libunwind and libcxxabi worked fine with
Dwarf before.

For existing cases with libunwind with SEH (on x86_64 and aarch64),
this modification doesn't break any of my testcases.

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


  Commit: 98dc3e86fd0f22093f1431457c058c70af1db35d
      https://github.com/llvm/llvm-project/commit/98dc3e86fd0f22093f1431457c058c70af1db35d
  Author: Martin Storsjö <martin at martin.st>
  Date:   2022-06-06 (Mon, 06 Jun 2022)

  Changed paths:
    M llvm/lib/MC/MCObjectFileInfo.cpp
    M llvm/lib/Target/ARM/MCTargetDesc/ARMMCAsmInfo.cpp
    M llvm/test/CodeGen/ARM/Windows/dbzchk.ll
    M llvm/test/CodeGen/ARM/Windows/mingw-refptr.ll
    M llvm/test/CodeGen/ARM/Windows/powi.ll
    M llvm/test/CodeGen/ARM/ehabi.ll

  Log Message:
  -----------
  [ARM] [MinGW] Default to WinEH exception handling instead of Dwarf

Switching this target to WinEH also seems to affect the `-windows-itanium`
target.

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


  Commit: fcb784db496137fa29a11b7e106efe89c7550e11
      https://github.com/llvm/llvm-project/commit/fcb784db496137fa29a11b7e106efe89c7550e11
  Author: Martin Storsjö <martin at martin.st>
  Date:   2022-06-06 (Mon, 06 Jun 2022)

  Changed paths:
    M clang/lib/Driver/ToolChains/MinGW.cpp
    M clang/test/Driver/windows-exceptions.cpp

  Log Message:
  -----------
  [clang] [MinGW] Default to WinEH (SEH) exception handling instead of Dwarf

The relevant runtime libraries have been updated to support this
now.

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


Compare: https://github.com/llvm/llvm-project/compare/4a3722a2c3df...fcb784db4961


More information about the All-commits mailing list