Page MenuHomePhabricator

[RFC] [AArch64] Add a target feature flag for restoring X18 after foreign function calls
Needs ReviewPublic

Authored by mstorsjo on May 14 2019, 6:09 AM.



This is a different, more comprehensive solution to the same issue as D61892 (

This is an incomplete PoC patch; in -O0 mode, the function calls are lowered with GlobalISel which doesn't use the modified functions in AArch64ISelLowering.cpp. When GlobalISel lowers a call in IRTranslator::translateCall in lib/CodeGen/GlobalISel/IRTranslator.cpp, it doesn't have target specific knowledge where it could check for this AArch64 specific feature flag.

Currently this is implemented as target feature flag (used via clang as -Xclang -target-feature -Xclang +protect-x18). This is not ideal though, because it's hard to check for this feature flag in e.g. a configure script; on clang versions that don't have the flag, test compiling with this flag does work but emits a warning (which -Werror doesn't make into an error either).

Diff Detail

Event Timeline

mstorsjo created this revision.May 14 2019, 6:09 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 14 2019, 6:09 AM