This is an archive of the discontinued LLVM Phabricator instance.

[compiler-rt] Do not use ldrexd or strexd on v7M
ClosedPublic

Authored by olista01 on Sep 25 2014, 8:48 AM.

Details

Reviewers
rengolin
Summary

The ldrexd and strexd instructions are undefined for the ARMv7M architecture, so we cannot use them to implement the __sync_fetch_and_*_8 builtins. There is no other way to implement these without OS support, so this patch #ifdef's these functions out for M-class architectures.

There are no tests as I cannot find any existing tests for these builtins.

I used the ARM_ARCH_PROFILE predefine because ARM_FEATURE_LDREX is deprecated and not set by clang.

Diff Detail

Event Timeline

olista01 updated this revision to Diff 14074.Sep 25 2014, 8:48 AM
olista01 retitled this revision from to [compiler-rt] Do not use ldrexd or strexd on v7M.
olista01 updated this object.
olista01 edited the test plan for this revision. (Show Details)
olista01 set the repository for this revision to rL LLVM.
olista01 added a subscriber: Unknown Object (MLST).

Hi Oliver,

If these macros are not defined, wouldn't that become a compilation time error on any code that use them?

Unless they're defined by something else (OS-specific headers?), there should be an #error stating the lack of support, or some other way to help the user identify the problem earlier.

cheers,
--renato

The SYNC_OP_8 macro (defined in lib/builtins/arm/sync-ops.h) uses these macros to emit the __sync_fetch_and_*_8 functions, so these #ifdefs have the effect of not building any of these functions. These are builtins which are used by the compiler, so they are not in any header file. This will result in a link error if the user tries to use any 64-bit atomic operations. However, a version of this runtime library designed to be used with an operating system could provide these operations, so I don't think the compiler should error if they are used.

rengolin accepted this revision.Sep 29 2014, 3:12 AM
rengolin added a reviewer: rengolin.

Makes sense, LGTM. Thanks!

--renato

This revision is now accepted and ready to land.Sep 29 2014, 3:12 AM
olista01 closed this revision.Sep 29 2014, 3:33 AM

Thanks, committed as r218601.