Skip to content

Commit 5b036d9

Browse files
committed
Merging r344100:
------------------------------------------------------------------------ r344100 | emaste | 2018-10-09 17:34:17 -0700 (Tue, 09 Oct 2018) | 16 lines clang: Allow ifunc resolvers to accept arguments When ifunc support was added to Clang (r265917) it did not allow resolvers to take function arguments. This was based on GCC's documentation, which states resolvers return a pointer and take no arguments. However, GCC actually allows resolvers to take arguments, and glibc (on non-x86 platforms) and FreeBSD (on x86 and arm64) pass some CPU identification information as arguments to ifunc resolvers. I believe GCC's documentation is simply incorrect / out-of-date. FreeBSD already removed the prohibition in their in-tree Clang copy. Differential Revision: https://reviews.llvm.org/D52703 ------------------------------------------------------------------------ llvm-svn: 348012
1 parent 4d730d8 commit 5b036d9

File tree

4 files changed

+1
-9
lines changed

4 files changed

+1
-9
lines changed

clang/include/clang/Basic/AttrDocs.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3364,7 +3364,7 @@ def IFuncDocs : Documentation {
33643364
let Content = [{
33653365
``__attribute__((ifunc("resolver")))`` is used to mark that the address of a declaration should be resolved at runtime by calling a resolver function.
33663366

3367-
The symbol name of the resolver function is given in quotes. A function with this name (after mangling) must be defined in the current translation unit; it may be ``static``. The resolver function should take no arguments and return a pointer.
3367+
The symbol name of the resolver function is given in quotes. A function with this name (after mangling) must be defined in the current translation unit; it may be ``static``. The resolver function should return a pointer.
33683368

33693369
The ``ifunc`` attribute may only be used on a function declaration. A function declaration with an ``ifunc`` attribute is considered to be a definition of the declared entity. The entity must not have weak linkage; for example, in C++, it cannot be applied to a declaration if a definition at that location would be considered inline.
33703370

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2857,8 +2857,6 @@ def err_cyclic_alias : Error<
28572857
"%select{alias|ifunc}0 definition is part of a cycle">;
28582858
def err_ifunc_resolver_return : Error<
28592859
"ifunc resolver function must return a pointer">;
2860-
def err_ifunc_resolver_params : Error<
2861-
"ifunc resolver function must have no parameters">;
28622860
def warn_attribute_wrong_decl_type_str : Warning<
28632861
"%0 attribute only applies to %1">, InGroup<IgnoredAttributes>;
28642862
def err_attribute_wrong_decl_type_str : Error<

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,6 @@ void CodeGenModule::checkAliases() {
320320
assert(FTy);
321321
if (!FTy->getReturnType()->isPointerTy())
322322
Diags.Report(Location, diag::err_ifunc_resolver_return);
323-
if (FTy->getNumParams())
324-
Diags.Report(Location, diag::err_ifunc_resolver_params);
325323
}
326324

327325
llvm::Constant *Aliasee = Alias->getIndirectSymbol();

clang/test/Sema/attr-ifunc.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ void f4_ifunc() {}
2727
void f4() __attribute__((ifunc("f4_ifunc")));
2828
//expected-error@-1 {{ifunc resolver function must return a pointer}}
2929

30-
void* f5_ifunc(int i) { return 0; }
31-
void f5() __attribute__((ifunc("f5_ifunc")));
32-
//expected-error@-1 {{ifunc resolver function must have no parameters}}
33-
3430
#else
3531
void f1a() __asm("f1");
3632
void f1a() {}

0 commit comments

Comments
 (0)