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

扶醉桌前 提交于 2021-02-07 05:46:19

问题


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.


回答1:


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

'target_clones' has yet to land though.



来源:https://stackoverflow.com/questions/39958935/does-clang-offer-anything-similar-to-gcc-6-xs-function-multi-versioning-target

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!