[PATCH] D27996: [XRay][AArch64] An attempt to fix test patching-unpatching.cc by flushing the instruction cache after code modification

Serge Rogatch via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 23 06:22:05 PST 2016


rSerge added a comment.

As discussed[[ https://groups.google.com/forum/#!topic/native-client-reviews/hILW7tRcowk |  here ]] , presence or absence of `__clear_cache` built-in depends on the compiler options. The built-in is common to gcc and clang, just currently in clang it is implemented via a called function in compiler-rt, but (another version of) gcc may inline it as an intrinsic. As discussed here <http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20130513/079815.html> , earlier there was a bug in gcc that gcc was expecting the parameters to be `void*`, in contradiction to the documentation <https://gcc.gnu.org/onlinedocs/gccint/Miscellaneous-routines.html> which says they are `char*`, and clang developers implemented this bug too (so that parameters are `void*`), and I understood that clang developers were then fixing this bug.

However, in compiler-rt, file clear_cache.c the function is still defined as `void __clear_cache(void *start, void *end) { ... }`, and it seems used in file trampoline_setup.c via a forward declaration also as `extern void __clear_cache(void* start, void* end);`.

So it seems that the best I can do to let the code compile with different gcc and clang versions is to forward-declare the function as `extern void __clear_cache(void* start, void* end);` and keep the `reinterpret_cast<char*>` so that the code accepts both the function and the intrinsic (but this may lead to ambiguity for some compiler version and flags).


https://reviews.llvm.org/D27996





More information about the llvm-commits mailing list