[all-commits] [llvm/llvm-project] a255c1: [WebAssembly] Avoid crash in LateEHPrepare with em...

Derek Schuff via All-commits all-commits at lists.llvm.org
Mon Jun 1 00:23:57 PDT 2026


  Branch: refs/heads/release/22.x
  Home:   https://github.com/llvm/llvm-project
  Commit: a255c1ed36a1d06f79bd2633ba9f8d900153007c
      https://github.com/llvm/llvm-project/commit/a255c1ed36a1d06f79bd2633ba9f8d900153007c
  Author: Derek Schuff <dschuff at chromium.org>
  Date:   2026-06-01 (Mon, 01 Jun 2026)

  Changed paths:
    M llvm/lib/Target/WebAssembly/WebAssemblyLateEHPrepare.cpp
    M llvm/test/CodeGen/WebAssembly/exception.ll

  Log Message:
  -----------
  [WebAssembly] Avoid crash in LateEHPrepare with empty cleanup pads (#200322)

WebAssemblyLateEHPrepare::addCatchRefsAndThrowRefs was using
Catch->getIterator()->getNextNode() to find the insertion position
after the CATCH (or CATCH_ALL) instruction in an EH pad.
If the CATCH/CATCH_ALL instruction is the last instruction in the basic
block, getNextNode() returns nullptr, which causees a crash when passed
to BuildMI. This patch fixes it by using std::next(Catch->getIterator())
which returns MBB.end() if the catch is the last instruction, and the
overload of BuildMI that takes an iterator correctly handles BB.end().

Fixes #197077

Assisted-By: Gemini
(cherry picked from commit dc40fccbc1f8fcd6d53c970efe199fc02464b986)



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