https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94136

            Bug ID: 94136
           Summary: GCC doc for built-in function
                    __builtin___clear_cache() not 100% correct
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: other
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bmeng.cn at gmail dot com
  Target Milestone: ---

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

It says:

"Built-in Function: void __builtin___clear_cache (void *begin, void *end)
This function is used to flush the processor’s instruction cache for the region
of memory between begin inclusive and end exclusive. Some targets require that
the instruction cache be flushed, after modifying memory containing code, in
order to obtain deterministic behavior.

If the target does not require instruction cache flushes,
__builtin___clear_cache has no effect. Otherwise either instructions are
emitted in-line to clear the instruction cache or a call to the __clear_cache
function in libgcc is made."

When I was looking at the RISC-V port, I assumed the GCC RISC-V would replace
the call to __builtin___clear_cache() with __clear_cache() as the document
says, but it does not.

I raised this to RISC-V GCC and had a discussion with Andrew at:
https://github.com/riscv/riscv-gcc/issues/178

As Andrew suggested, the doc should be improved to avoid such confusion.

Reply via email to