target_clones: molehill or everest?

Johan j at j.nl
Tue Jun 7 20:26:03 UTC 2022


On Tuesday, 7 June 2022 at 15:50:56 UTC, kinke wrote:
> On Tuesday, 7 June 2022 at 14:18:11 UTC, Bruce Carneal wrote:
>> Would adding clang's *target_clones* attribute be difficult?
>
> Hmm, it's apparently not supported in LLVM IR directly; the IR 
> changes for clang are substantial: 
> https://cpp.godbolt.org/z/WT56axqj1
>
> So unless the LLVM API provides a helper (mainly generating the 
> resolver with its conditions depending on some 
> `__cpu_indicator_init()` and `__cpu_model`), it's probably 
> difficult indeed.

I've looked at this in the past and indeed this will be a lot of 
work + probably a lot of maintenance work. Unfortunately, the 
LLVM project implementation resides mainly in Clang's code, 
rather than LLVM's. I'd say the first step is within the LLVM 
project to move code to the shared LLVM library, so it's 
available for other frontends (=us).

-Johan



More information about the digitalmars-d-ldc mailing list