This is an archive of the discontinued LLVM Phabricator instance.

Add support for probestack on ARM targets
Needs ReviewPublic

Authored by ryan-summers on Jun 10 2023, 11:32 AM.

Details

Summary

There is a desire to add support for probestack functionality on ARM (32-bit) targets for embedded applications, as the stack probe functionality can be used, along with a memory protection unit, to protect bare-metal applications from stack overflow issues (or to detect these issues so they can be acted upon).

See https://github.com/rust-embedded/wg/issues/460 for more information as to why this is useful

This diff provides the ability to use function annotations for the probestack and probe-stack-size to define the various probestack stubs and page protection size. This patch does not enable any of this functionality in clang, and is only targeting the LLVM library currently (as the final usecase for this patch is intended to be in rustc).

Implementation is largely based off the X86 implementation of stack probes. As such, I have tagged some of the reviewers from the original review (https://reviews.llvm.org/D68720) for this diff.

Diff Detail

Event Timeline

ryan-summers created this revision.Jun 10 2023, 11:32 AM
ryan-summers requested review of this revision.Jun 10 2023, 11:32 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 10 2023, 11:32 AM
ryan-summers added inline comments.Jun 11 2023, 2:36 AM
llvm/lib/Target/ARM/ARMFrameLowering.cpp
591

The no-stack-arg-probe FnAttribute is no longer present for Windows, which isn't desirable as the removal would imply a break in backwards compatibility.

765

It looks like this unintentionally is removing the check for WIndows stack probe requirements. I'll need to reinclude this condition

967

Similar to the above, this changes the conditional for Windows requiring stack probes, which it shouldn't.

2301

Same as earlier - we need to preserve stack probe emission for Windows