This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] [Windows] Trap after noreturn calls.
ClosedPublic

Authored by efriedma on Nov 5 2018, 5:25 PM.

Details

Summary

Like the comment says, this isn't the most efficient fix in terms of codesize, but it works.

Diff Detail

Repository
rL LLVM

Event Timeline

efriedma created this revision.Nov 5 2018, 5:25 PM

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.)

rnk added a comment.Nov 6 2018, 10:11 AM

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.

rnk added a comment.Nov 6 2018, 3:11 PM

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.

rnk accepted this revision.Nov 6 2018, 3:11 PM
This revision is now accepted and ready to land.Nov 6 2018, 3:11 PM
This revision was automatically updated to reflect the committed changes.

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.)

Changed to check usesWindowsCFI() in r346366.