]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: optimize EH phase 2
authorJason Merrill <jason@redhat.com>
Wed, 31 May 2023 19:02:05 +0000 (15:02 -0400)
committerJason Merrill <jason@redhat.com>
Thu, 1 Jun 2023 12:49:20 +0000 (08:49 -0400)
In the ABI's two-phase EH model, first we walk the stack looking for a
handler, then we walk the stack running cleanups until we reach that
handler.  In the cleanup phase, we shouldn't redundantly check the handlers
along the way, e.g. when walking through g():

  void f() { throw 42; }
  void g() { try { f(); } catch (void *) { } }
  int main() { try { g(); } catch (int) { } }

libstdc++-v3/ChangeLog:

* libsupc++/eh_personality.cc (PERSONALITY_FUNCTION): Don't check
handlers in the cleanup phase.

libstdc++-v3/libsupc++/eh_personality.cc

index 12391e563d6186aaa2062f33b61d434962904f88..cc6bc048892a8cdc84b2dc85146788acf98ba58c 100644 (file)
@@ -592,6 +592,10 @@ PERSONALITY_FUNCTION (int version,
              // Zero filter values are cleanups.
              saw_cleanup = true;
            }
+         else if (actions == _UA_CLEANUP_PHASE)
+           // We checked the handlers in the search phase; if one of them
+           // matched, actions would also have _UA_HANDLER_FRAME set.
+           ;
          else if (ar_filter > 0)
            {
              // Positive filter values are handlers.