[all-commits] [llvm/llvm-project] 10be25: [clang] Fix catching pointers by reference on ming...

Martin Storsjö via All-commits all-commits at lists.llvm.org
Wed Oct 15 23:50:00 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 10be254587da24d56e2c6817b382beaca612b6c3
      https://github.com/llvm/llvm-project/commit/10be254587da24d56e2c6817b382beaca612b6c3
  Author: Martin Storsjö <martin at martin.st>
  Date:   2025-10-16 (Thu, 16 Oct 2025)

  Changed paths:
    M clang/lib/CodeGen/TargetInfo.cpp
    M clang/test/CodeGenCXX/sizeof-unwind-exception.cpp

  Log Message:
  -----------
  [clang] Fix catching pointers by reference on mingw targets (#162546)

For this specific case, when catching a pointer data type, by reference,
Clang generates a special code pattern, which directly accesses the
exception data by skipping past the `_Unwind_Exception` manually (rather
than using the return value of `__cxa_begin_catch`).

On most platforms, `_Unwind_Exception` is 32 bytes, but in some
configurations it's different. (ARM EHABI is one preexisting case.) In
the case of SEH, it's also different - it is 48 bytes in 32 bit mode and
64 bytes in 64 bit mode. (See the SEH ifdef in `_Unwind_Exception` in
`clang/lib/Headers/unwind.h`.)

Handle this case in `TargetCodeGenInfo::getSizeOfUnwindException`,
fixing the code generation for catching pointers by reference.

This fixes https://github.com/mstorsjo/llvm-mingw/issues/522.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list