Bug 93811 - __builtin___clear_cache() is a noop on powerpc (which is incorrect)
Summary: __builtin___clear_cache() is a noop on powerpc (which is incorrect)
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 7.5.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-02-18 17:17 UTC by anton
Modified: 2021-10-30 05:33 UTC (History)
1 user (show)

See Also:
Host: powerpc64-unknown-linux-gnu
Target: powerpc64-unknown-linux-gnu
Build: powerpc64-unknown-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2020-05-01 00:00:00


Attachments
source code for demonstrating the bug (77 bytes, text/plain)
2020-02-18 17:17 UTC, anton
Details
Disassembly output for demonstration file (160 bytes, text/plain)
2020-02-18 17:20 UTC, anton
Details

Note You need to log in before you can comment on or make changes to this bug.
Description anton 2020-02-18 17:17:52 UTC
Created attachment 47869 [details]
source code for demonstrating the bug

A call to __builtin___clear_cache() results in no code being generated.  This can lead to stale I-cache contents on at least the PPC970 and the PPC7447A (I have seen breakage from this bug on these CPUs).  This bug is present in at least gcc-4.3.2, gcc-5.5.0, and gcc-7.5.0.  Given that it has not been fixed for such a long time, it probably is still present in gcc-9 (which I could not test for other reasons).

You can find a working implementation of a similar function at <http://git.savannah.gnu.org/cgit/gforth.git/tree/arch/power/_sync_cache_range.c>
Comment 1 anton 2020-02-18 17:20:12 UTC
Created attachment 47870 [details]
Disassembly output for demonstration file
Comment 2 Andrew Pinski 2020-02-20 03:37:25 UTC
Note ___clear_cache was originally designed for trampolines. PoewrPC64v1 ABI does not use trampolines for nested functions.
Comment 3 Segher Boessenkool 2020-05-01 02:06:31 UTC
Confirmed.  Apparently this builtin isn't used much at all :-/
Comment 4 Andrew Pinski 2021-10-30 05:33:58 UTC
Mono's implementation seems like the best so far:
https://github.com/mono/mono/blob/main/mono/mini/mini-ppc.c#L759-L795