This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] Do not untag before returning via a `resume` instruction
Changes PlannedPublic

Authored by chill on Oct 4 2019, 8:46 AM.

Details

Summary

Such untag operations are redundant, as the stack unwind runtime has to clear
the deallocated portion of the stack anyway.

Diff Detail

Event Timeline

chill created this revision.Oct 4 2019, 8:46 AM
eugenis added a subscriber: pcc.Oct 4 2019, 2:04 PM

@pcc We actually went back and forth on this with HWASan, and ended up wrapping personality functions with a small tag cleanup routine:
https://github.com/llvm-mirror/llvm/blob/master/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp#L1435

As I understand, this line assumes that "resume" exits clean tags for their frame:
https://github.com/llvm-mirror/compiler-rt/blob/master/lib/hwasan/hwasan_exceptions.cpp#L51

This does not have to be same for MTE, but it has an advantage that frames without tagging do not incur the overhead of untagging when an exception flies by.
On the other hand, exceptions are not expected to be exceptionally fast, and untagging in the unwinder has the advantage of simplicity and smaller code size.
In the end, this is a platform ABI issue and should be documented somewhere - SysV ABI supplement maybe? Or here for Android: https://developer.android.com/ndk/guides/abis.

chill planned changes to this revision.Oct 7 2019, 3:02 AM

Indeed, that patch is a bit premature. I've kicked up a discussion about supplementing the (EH)ABI, and this patch need to wait for the outcome.