[clang] [llvm] [ARM] Add support for Windows SEH (PR #184953)

Eli Friedman via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 7 16:02:26 PDT 2026


================
@@ -0,0 +1,57 @@
+; RUN: llc -mtriple thumbv7-windows-msvc -o - %s
+; XFAIL: *
+
+; FIXME: C++ EH is not supported on thumbv7-windows-msvc yet.
+
+; FIXME: Windows SEH for armv7 does not preserve the frame register R11 in
+; handlers. This may affect C++ EH when accessing arguments on the stack in
+; functions with stack realignment.
+
+; C++ source:
+; struct X { int x[100]; };
+; void f(X x, void (*a)(), void (*g)(int*)) {
+;     alignas(64) int aligned;
+;     try {
+;         a();
+;     } catch (...) {
+;         g(&x.x[11]);
+;     }
+; }
+
+%struct.X = type { [100 x i32] }
+
+define void @"?f@@YAXUX@@P6AXXZP6AXPAH at Z@Z"(ptr byval(%struct.X) align 4 %x, ptr %a, ptr %g) personality ptr @__CxxFrameHandler3 {
----------------
efriedma-quic wrote:

We assume a catchpad in an SEH function is an `__except`, which doesn't make a separate function, right.  This should work, though (build with optimizations enabled):

```
struct X { int x[100]; };
void g(int*, int*) noexcept;
void f(X x, void (*a)()) {
    alignas(64) int aligned;
    struct A {
        X &x;
        int &aligned;
        ~A() {g(&x.x[11], &aligned);}
    } obj = {x, aligned};
    a();
}
```

Really, the reason I've been pushing this a bit is that I'm a little concerned that there might be some way to access local variables that doesn't go through llvm.localrecover.  (There's nothing fundamentally stopping it, it's just not easy to trigger with the transforms LLVM currently runs.)

https://github.com/llvm/llvm-project/pull/184953


More information about the cfe-commits mailing list