This is an archive of the discontinued LLVM Phabricator instance.

[BuildLibCalls] Add globalmemonly to math libcalls that only modify errno
Needs ReviewPublic

Authored by MugilanGN on Sep 11 2021, 11:43 AM.

Details

Reviewers
jdoerfert
Summary

Certain math libcalls, such as acos and exp, only modify the global variable errno. This automatically adds the globalmemonly attribute to those calls. One use case is in removing unnecessary loads of the call arguments, since the calls will have no side-effects on them.

Diff Detail

Event Timeline

MugilanGN created this revision.Sep 11 2021, 11:43 AM
MugilanGN requested review of this revision.Sep 11 2021, 11:43 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 11 2021, 11:43 AM
nikic added a subscriber: nikic.Sep 11 2021, 12:36 PM

Is it safe to assume that errno is a "global value" in the LLVM sense? For example, here's how the musl implementation looks like: https://github.com/ifduyue/musl/blob/master/src/errno/__errno_location.c I believe C only requires that errno expands to a thread-local modifiable lvalue, but it does not necessarily have to correspond to a global.

Is it safe to assume that errno is a "global value" in the LLVM sense? For example, here's how the musl implementation looks like: https://github.com/ifduyue/musl/blob/master/src/errno/__errno_location.c I believe C only requires that errno expands to a thread-local modifiable lvalue, but it does not necessarily have to correspond to a global.

Can we use a target hook to determine if it is? (errno is not the only use case but a good one).