[llvm] [WinEH] Emit unreachable on malformed catchpad (PR #222181)
Aaron Danen via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 11 17:55:38 PDT 2026
aadanen wrote:
WinEHPrepare has (at least?) two use cases. opt -passes=win-eh-prepare normalizes the IR, but it doesn't inspect the catchpad arguments as part of that. Then later, codegen calls functions like llvm::calculateWinCXXEHStateNumbers() which derives information from the normalized IR. This second use does inspect the catchpad arguments, and this is when crashes occur.
My idea about only removing catchpads when we would have otherwise crashed has the side effect of the first "normalization" pass not doing anything about malformed catchpads. I think this is undesireable, because the normalized "good" IR should have proper arguments.
If we are going to have the "normalization" pass verify catchpad arguments, then I think the current structure is ideal.
1. while we do "detect malformed catchpads" twice, it happens on two different code paths so it isn't really duplicated
2. I think trying to remove a walk over the function by merging the current "removeMalformedCatchswitch" pass into one of the other ones like "removeImplausibleInstructions" would make the code harder to reason about. Like in the pass manager we have many different passes that each do one thing instead of 1 mega pass.
Let me know what you think!
https://github.com/llvm/llvm-project/pull/222181
More information about the llvm-commits
mailing list