llvm-project
6cad48ae - [WebAssembly] Remove WasmEHFuncInfo (NFC) (#194972)

Commit
2 days ago
[WebAssembly] Remove WasmEHFuncInfo (NFC) (#194972) This removes `WasmEHFuncInfo` class. This class was created to maintain the information of, "If an exception is not caught by EHPad A, what is its next unwind destination?". Turns out this information is already in the CFG. After #130374, we use the common `findUnwindDestination`: https://github.com/llvm/llvm-project/blob/113479d119a997e4c4c3eae63e087588c9662121/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp#L2107-L2164 Note that in case of `catchswitch`, we follow its unwind destination chain and add all of them to the invoke BB's successors until it meets a `cleanuppad`, which always catches an exception. And the order of the successor is the order of the unwind destination chain. So an invoke BB's successor list would be like: [normal destination, unwind EHPad 1, unwind EHPad 2, unwind EHPad 3, ...] where EHPad 2 is the next unwind destination if EHPad 1 does not catch an exception and so on. So if we want to know what the current EHPad's next unwind destination is, we can examine the EHPad's predecessor (invoke BB)'s successor list, and find the next successor of EHPad. If there is no further next unwind destination, the list should end with that EHPad. How we do this is in the added lambda functions in CFGStackify, which replaces `WasmEHFuncInfo`'s `hasUnwindDest`/`getUnwindDest`. This depends on the order of successors of a CFG, which someone can argue may be not guaranteed, in case someone messes up the successor order in later passes. But I think in practice this should be fine. Also maintaining `WasmEHFuncInfo` has more risks, because if other passes change EH-related CFGs, they have to make sure `WasmEHFuncInfo` stays synced. I haven't personally found (so far) those passes and haven't had to any adjustments to other passes, but it was always an inherent risk when you maintain a separate data structure. I wasn't able to completely delete `WasmEHFuncInfo.h` because it contains the `Tag` enum. I renamed it to `WasmEHInfo.h`, because we dont' have `WasmEHFuncInfo` class anymore.
Author
Parents
Loading