[llvm] 2503ffb - [WebAssembly] Fix exception handling initialization order in TargetMachine constructor (#177542)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 23 22:26:07 PST 2026
Author: Anutosh Bhat
Date: 2026-01-24T06:26:02Z
New Revision: 2503ffbdf3307d37e20b312ab336bd3dafb37246
URL: https://github.com/llvm/llvm-project/commit/2503ffbdf3307d37e20b312ab336bd3dafb37246
DIFF: https://github.com/llvm/llvm-project/commit/2503ffbdf3307d37e20b312ab336bd3dafb37246.diff
LOG: [WebAssembly] Fix exception handling initialization order in TargetMachine constructor (#177542)
The WebAssemblyTargetMachine constructor had an ordering issue where
initAsmInfo() was called before basicCheckForEHAndSjLj(). This caused
problems in incremental compilation scenarios where:
1. `initAsmInfo()` sets `MCAsmInfo` exception type based on
`Options.ExceptionModel`
2. But `Options.ExceptionModel` might still be None at this point
3. `basicCheckForEHAndSjLj()` runs later and updates
`Options.ExceptionModel`
based on command-line flags like `-wasm-enable-eh`
4. `MCAsmInfo` retains the incorrect exception type (`None` instead of
`Wasm`)
5. This prevents WebAssembly exception handling passes from running
The fix swaps the order so basicCheckForEHAndSjLj() runs first to
establish the correct exception model before initAsmInfo() configures
MCAsmInfo based on that model.
This enables WebAssembly exception handling to work correctly in
clang-repl and other incremental compilation scenarios.
Added:
Modified:
llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
index 402929caa760c..a57ebfad03b1c 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
@@ -212,8 +212,8 @@ WebAssemblyTargetMachine::WebAssemblyTargetMachine(
this->Options.DataSections = true;
this->Options.UniqueSectionNames = true;
- initAsmInfo();
basicCheckForEHAndSjLj(this);
+ initAsmInfo();
// Note that we don't use setRequiresStructuredCFG(true). It disables
// optimizations than we're ok with, and want, such as critical edge
// splitting and tail merging.
More information about the llvm-commits
mailing list