[PATCH] D112349: [Verifier] Add verification logic for GlobalIFuncs

Erich Keane via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 4 09:30:03 PDT 2021


erichkeane added a comment.

In D112349#3109211 <https://reviews.llvm.org/D112349#3109211>, @nextsilicon-itay-bookstein wrote:

>> I don't know much about the ELF format... but this works today?  We can define a resolver in a different TU and it WORKS thanks to the linker?  So there is perhaps something?
>
> The ifunc symbol that is emitted in the TU with the undefined resolver loses its connection to the resolver and the calls to the ifunc are instead bound against the resolver itself (which is absolutely not what you want).
>
>   itay> cat specific.c
>   #include <stdio.h>
>   
>   __attribute__((cpu_specific(generic)))
>   void single_version(void){
>     puts("In single_version generic");
>   }
>   
>   void useage() {
>     single_version();
>   }
>   
>   itay> cat dispatch_main.c
>   void useage(void);
>   
>   __attribute__((cpu_dispatch(generic)))
>   void single_version(void);
>   
>   int main()
>   {
>     useage();
>     single_version();
>     return 0;
>   }
>   
>   itay> clang -c dispatch_main.c -o dispatch_main.c.o
>   itay> clang -c specific.c -o specific.c.o
>   itay> clang specific.c.o dispatch_main.c.o -o main
>   itay> ./main
>   In single_version generic
>
> This line should have been printed twice, not once.

I see... thank you for your patience, my knowledge of ELF (or, that is, basically everything after Clang LLVM-IR generation) is pretty slim.

I think what I would need to be able to correctly implement this is some level of 'forward declarable' ifunc.  I have to be able to process declarations as we reach them, so just doing a function declaration then rewriting it wouldn't be allowed.

Is it possible to get some IR-level 'ifunc' declaration implemented?  If so, I think I have a good idea on how to implement that in the CFE.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112349/new/

https://reviews.llvm.org/D112349



More information about the llvm-commits mailing list