This is an archive of the discontinued LLVM Phabricator instance.

[safestack] Fast access to the unsafe stack pointer on AArch64/Android (2nd try).
ClosedPublic

Authored by eugenis on Oct 15 2015, 3:21 PM.

Details

Reviewers
rengolin
echristo
Summary

Android libc provides a fixed TLS slot for the unsafe stack pointer,
and this change implements direct access to that slot on AArch64 via
__builtin_thread_pointer() + offset.

This change also moves more code into TargetLowering and its
target-specific subclasses to get rid of target-specific codegen
in SafeStackPass.

This change does not touch the ARM backend because ARM lowers
builting_thread_pointer as aeabi_read_tp, which is not available
on Android.

This is a second attempt which leave the generic, compiler-rt-based implementation in SafeStack.cpp. This way things still work even when there is no TargetMachine.

Diff Detail

Repository
rL LLVM

Event Timeline

eugenis updated this revision to Diff 37527.Oct 15 2015, 3:21 PM
eugenis retitled this revision from to [safestack] Fast access to the unsafe stack pointer on AArch64/Android (2nd try)..
eugenis updated this object.
eugenis added reviewers: echristo, rengolin.
eugenis set the repository for this revision to rL LLVM.
eugenis added a subscriber: llvm-commits.

To clarify, Eric, Renato, this goes against some of your comments in the original review. Namely, the TargetLowering methods are, again, Android-specific because I had to move the generic implementation to SafeStack pass to have it working without TargetMachine. This sounds like the right thing to do, because the compiler-rt based implementation does not require target knowledge to emit the IR, and this allows target-independent testing.

I'd like a confirmation that you are OK with this.

rengolin edited edge metadata.Oct 20 2015, 6:36 AM

Overall, this is less android specific in that only x86_64 and AArch64 knows about it, but the generic target lowering is independent. In that sense, it is better this way than previously.

lib/Transforms/Instrumentation/SafeStack.cpp
513

Moving this around makes it harder to review. Can you move it back where it was?

eugenis updated this revision to Diff 37907.Oct 20 2015, 12:14 PM
eugenis edited edge metadata.
eugenis added inline comments.
lib/Transforms/Instrumentation/SafeStack.cpp
513

Sorry, did not noticed the method was moved. Fixed.

echristo accepted this revision.Oct 23 2015, 6:31 PM
echristo edited edge metadata.

LGTM.

-eric

This revision is now accepted and ready to land.Oct 23 2015, 6:31 PM
eugenis closed this revision.Oct 26 2015, 11:31 AM

Thank you.
r251324