Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does clang offer anything similar to GCC 6.x's function multi-versioning (target_clones)?

I've read this LWN article with great interest. Executive summary: GCC 6.x supports something called function multi-versioning which builds multiple versions of the same function, optimized for different instruction sets. Let's say you have a machine with AVX2 support and one without. It's possible to run the same binary on both, with function foo() existing in two versions, one of which uses AVX2 instructions. The function with the AVX2 instructions are, however, only called if the CPU supports it.

My question is: does clang support something similar? It doesn't seem like the most advanced feature in the world.

like image 691
bolind Avatar asked Oct 10 '16 13:10

bolind


1 Answers

LLVM 7 supports function multiversioning using the 'target' attribute for ELF-based x86/x86_64 targets.

'target_clones' has yet to land though.

like image 177
Hadi Brais Avatar answered Oct 30 '22 20:10

Hadi Brais