[cfe-dev] different gcc/clang behavior for Internal visibility

Joerg Sonnenberger via cfe-dev cfe-dev at lists.llvm.org
Wed May 12 19:49:41 PDT 2021


On Tue, May 11, 2021 at 10:36:17AM -0700, Reid Kleckner via cfe-dev wrote:
> IIRC, internal visibility is a guarantee that a function is not escaped and
> called indirectly from another DSO. This allows the compiler to avoid
> setting up a TOC or PIC base register in the prologue for architectures
> that have one. This was notably expensive for x86_32 because of the
> call/pop code sequence required to materialize EIP. There are other RISC-y
> architectures (PPC? 64? not sure) with PIC base registers that could
> benefit from internal visibility support, but I think most of them are
> considered legacy architectures at this point, so it's not top priority.

At least i386 does not point to the GOT directly from the PIC base
register, but uses function specific offsets. I'm not aware of a
compiler that tries to optimize this.

PPC uses the TOC and when using hidden functions, it doesn't do the
fixup, so it helps on that. Things get a bit funny when function
pointers etc can be used.

All that said, the one comment I got for INTERNAL on the ELF list is
essentially "don't use this" as it is poorly defined at best and noone
outside SGI really clearly knows the semantic.

Joerg


More information about the cfe-dev mailing list