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>
Created attachment 47870 [details] Disassembly output for demonstration file
Note ___clear_cache was originally designed for trampolines. PoewrPC64v1 ABI does not use trampolines for nested functions.
Confirmed. Apparently this builtin isn't used much at all :-/
Mono's implementation seems like the best so far: https://github.com/mono/mono/blob/main/mono/mini/mini-ppc.c#L759-L795