The MachineFunctionInfo here is a bit awkward because
WasmEHInfo is in the MachineFunction but handled from
the target code. Either everything should move into WebAssembly
or into the MachineFunction for MIR serialization.
Details
Diff Detail
Event Timeline
It's been a while and I don't remember why I put a pointer to MF as a member in WebAssemblyFunctionInfo, but if things work without it, it should be fine. But I don't understand some comments, about which I asked questions below.
I think the reason I put WasmEHInfo in MachineFunction is, Wasm is not only a target but an exception mode (even though it is only being used by WebAssembly target), and also WinEHInfo, which contains info for WinEH EH mode, is there too.
llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.cpp | ||
---|---|---|
31–35 | What does this mean by "if WasmEHFuncInfo from the block reference"? | |
164 | Why? Which link? |
llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.h | ||
---|---|---|
34 | Back in https://github.com/llvm/llvm-project/commit/cc5a1b3dd9039d50f6b9caa679d60398f0cec65f you changed this from a reference to a pointer. Apparently this is not needed at all and you are removing it. I am happy with it. Looking through the code I get the feeling that this was an artifact from doing similar things as other backends. Some of which have ended up removing MF, while others still have it. |
llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.cpp | ||
---|---|---|
31–35 | Ultimately WasmEHFuncInfo has a bunch of MachineBasicBlock pointers in it. When cloned to a new machine function, those need to be updated to point to the blocks in the new function which isn't handled | |
164 | This is the layering violation where this field is stored in the MachineFunction, but all the handling is done here in target code. Either everything should be done here, or done in the generic MIR handling | |
llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.h | ||
34 | I purged this from all targets last time I posted this patch; this one was added back in at some point since then |
llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.cpp | ||
---|---|---|
31–35 | Apparently I'm not familiar with the cloning functionality you added a while ago. What is that for? Is that creating an in-memory copy of a while function, including BBs and instructions? Then what's src BB and what's dst BB? And how does WinEHFuncInfo handle it currently? | |
164 | As I said, WinEHFuncInfo is also within MachineFunction. Also this WasmEHFuncInfo is not only for MIR handling. It is referenced throughout our compilation passes. |
llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.cpp | ||
---|---|---|
31–35 | It's for llvm-reduce; it's just unhandled now. If you try to reduce a function with EH info it won't faithfully reproduce | |
164 | Right, it's a well spread out layering violation. The handling should be consistently in webassembly only, or consistently in the generic MachineFunction handling |
llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.cpp | ||
---|---|---|
31–35 |
| |
164 | I think the reason both of them are in MachineFunction is, as noted above, they are for exception handling conventions, not for specific targets. (Well, WinEHFuncInfo kind of happens to be only used in x86, and WasmEHFuncInfo only in WebAssembly... but anyway) As we don't have a plan atm to restructure this, how about removing this FIXME, or elaborating more on what the suggestion could be? "This link should be removed" doesn't explain much on why for future readers. |
ff2b60bbcb28701c86b200b0c03439a2e6ef6b44 (except I dropped the MF check from the clone since it didn't actually work)
Back in https://github.com/llvm/llvm-project/commit/cc5a1b3dd9039d50f6b9caa679d60398f0cec65f you changed this from a reference to a pointer. Apparently this is not needed at all and you are removing it. I am happy with it. Looking through the code I get the feeling that this was an artifact from doing similar things as other backends. Some of which have ended up removing MF, while others still have it.