llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.66k stars 11.85k forks source link

-fsemantic-interposition breaks extern inline #49821

Open nsz-arm opened 3 years ago

nsz-arm commented 3 years ago
Bugzilla Link 50477
Version trunk
OS Linux
CC @MaskRay,@zygoloid

Extended Description

consider

void foo_good(); extern inline void foo() { foo_good(); } void bar() { foo(); }

using: -fsemantic-interposition -fPIC -O2 expected: no reference to foo, only to foo_good. got: interposable call to foo.

with -O0 i expect a local call to foo that is not interposable.

(i don't think iso c requires either way, but gcc implements it the described way on elf platforms and existing software relies on it. at least on linux targets clang should follow.)

nsz-arm commented 3 years ago

i spotted this in glibc code (which also uses -fgnu89-inline)

but glibc is probably not the only affected software: in gcc -fsemantic-interposition is the default.

MaskRay commented 3 years ago

what software relies on the gcc behavior?

software needing -fsemantic-interposition is rare. clang has always been allowing interprocedural optimizations in ELF -fpic mode.