[PATCH] D122608: Fix behavior of ifuncs with 'used' extern "C" static functions
Erich Keane via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 28 11:52:46 PDT 2022
erichkeane created this revision.
erichkeane added reviewers: tahonermann, aaron.ballman, cor3ntin.
Herald added a project: All.
erichkeane requested review of this revision.
We expect that `extern "C"` static functions to be usable in things like
inline assembly, as well as ifuncs:
See the bug report here: https://github.com/llvm/llvm-project/issues/54549
However, we were diagnosing this as 'not defined', because the
ifunc's attempt to look up its resolver would generate a declared IR
function.
Additionally, as background, the way we allow these static extern "C"
functions to work in inline assembly is by making an alias with the C
mangling in MOST situations to the version we emit with
internal-linkage/mangling.
The problem here was multi-fold: First- We generated the alias after the
ifunc was checked, so the function by that name didn't exist yet.
Second, the ifunc's generation caused a symbol to exist under the name
of the alias already (the declared function above), which suppressed the
alias generation.
This patch fixes all of this by moving the checking of ifuncs/CFE aliases
until AFTER we have generated the extern-C alias. Then, it does a
'fixup' around the GlobalIFunc to make sure we correct the reference.
https://reviews.llvm.org/D122608
Files:
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGenCXX/externc-ifunc-resolver.cpp
clang/test/SemaCXX/externc-ifunc-resolver.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122608.418669.patch
Type: text/x-patch
Size: 4847 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220328/d1684c32/attachment-0001.bin>
More information about the cfe-commits
mailing list