RISCVTargetMachine::getSubtargetImpl creates subtargets based on target attributes of IR functions. As result now runtime functions are placed in another subtarget and have another ABI. That causes warning messages like Hard-float 'd' ABI can't be used for a target that doesn't support the D instruction set extension (ignoring target-abi) during linking with lld with -flto
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
How does this affect LTO? LTO for RISC-V is broken for various reasons, but LTO isn't Clang's responsibility beyond passing on driver arguments. Is this not just one of many symptoms of RISC-V not having the right module-level subtarget under LTO, which is a real problem that needs fixing?
The code changes/test changes seem innocuous enough, so from an 'attribute code owner perspective' I think this is alright. I think @rjmccall or @eli.friedman need to take a peak from CodeGen owner's perspective, and it seems useful if the commit message better described (at least in a way that the three of us could understand) the motivation/reasoning here.
How does this affect LTO?
This problem appeared only under lto as far as it's processed as one module.
Is this not just one of many symptoms of RISC-V not having the right module-level subtarget under LTO, which is a real problem that needs fixing?
Not exactly, to build right subtarget we need attributes. As far as mentioned in comments in code the main approach to provide subtarget information is adding information in functions attributes. Why not to provide this information for runtime functions? If we don't have right attributes what shall we use to find out proper target features?
How does this affect LTO?
More detailed answer. We work with bitcode files only when use lto. If we don't use lto clang produces .o file that are already contains target information. We don't work with function attributes to get subtarget without lto.
I've created one more patch connected with lto https://reviews.llvm.org/D142191 and it also uses attributes of functions as the way to get right TargetMachine in linker.