Like the comment says, this isn't the most efficient fix in terms of codesize, but it works.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
We already do this for X86, would it be better to make the check in non-target-specific code? (Just asking, not expressing an opinion.)
We came up with a different solution for this called SEH_Epilogue. It basically inserts a nop if the last real instruction was a call. It's slightly complicated because it looks backwards across empty basic blocks and things. You can see it here:
https://github.com/llvm-mirror/llvm/blob/master/lib/Target/X86/X86MCInstLower.cpp#L1800
I'd rather take that approach. I don't like that just going to Windows gets you this extra trapping behavior. That should be something else that the user controls. Otherwise soon they'll start relying on it. =/
The case I'm trying to fix is functions/funclets which don't have an epilogue at all. As far as I can tell, the x86 only emits SEH_Epilogue before an epilogue; I don't see how it's related.
Right, I remember how this works now. Go ahead and do this.
You could imagine adding an instruction after a call that only turns into a real nop if the next instruction is in a different EH region.
Sorry for not commenting earlier on this one, but, should we only do this if actually using SEH exceptions? (Currently I'm using dwarf exceptions for arm64/mingw, but once all this is done and libunwind supports it, I'll probably switch my mingw setups.)