LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 48489 - __builtin___clear_cache() has a different prototype than GCC
Summary: __builtin___clear_cache() has a different prototype than GCC
Status: CONFIRMED
Alias: None
Product: clang
Classification: Unclassified
Component: C (show other bugs)
Version: unspecified
Hardware: All All
: P normal
Assignee: Unassigned Clang Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-12-11 12:44 PST by Alejandro Colomar
Modified: 2020-12-18 03:15 PST (History)
7 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alejandro Colomar 2020-12-11 12:44:25 PST
GCC provides:

void __builtin___clear_cache(void *begin, void *end);

See: https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html

Clang provides:

void __builtin___clear_cache(char *begin, char *end);

I think GCC used char *' in the past, and moved to 'void *', but I'm not sure about this.  Please, use the same prototype that GCC uses, for compatibility reasons.

I don't know much about internals of Clang/LLVM, but the only source I could find that defines the types for the prototype is:
https://github.com/llvm/llvm-project/blob/7faf62a80bfc3a9dfe34133681fcc31f8e8d658b/clang/include/clang/Basic/Builtins.def#L583

If you can confirm that, or tell me which other sources need to be modified, I'll be happy to submit a patch.

And a reminder to myself when this bug is closed:  Update cacheflush(2) manual page.

Related linux-man@ thread: https://lore.kernel.org/linux-man/747d56e0-c102-ab40-add4-530a48a43a4d@gmx.de/T/#t
Comment 1 Heinrich Schuchardt 2020-12-13 04:03:58 PST
The change in GCC came with commit 5d8723600bc0e 2019-02-21:
libgcc2.h (__clear_cache): Correct signature

On the GCC mailing list 2019-02-07:
https://gcc.gnu.org/pipermail/gcc-patches/2019-February/516296.html
[PATCH] correct __clear_cache signature
Comment 2 Heinrich Schuchardt 2020-12-13 04:09:20 PST
As void * is more permissive than char * moving to void * will not break any existing code using the built in. So I suggest to follow GCC.