Open svenvh opened 4 months ago
Is there a reason why we named the SPIR-V linkage LinkOnceODR and not WeakODR in the first place? May be we will benefit from adding a new linkage (WeakODR)? Adding @bashbaug for comments. Thanks
Thanks for the comments so far. No problem holding off merging this PR; it would be great to hear what @bashbaug or @Fznamznon think.
Thanks for the comments so far. No problem holding off merging this PR; it would be great to hear what @bashbaug or @Fznamznon think.
I don't mind to merge, worst case we will revert it downstream, as it's a consumer part, not generator.
I don't mind to merge, worst case we will revert it downstream
We're not in a rush for this, so we could wait a few more days for folks to step in. I'm quite keen to hear some more thoughts.
The translator currently maps SPIR-V's
LinkOnceODR
to llvm'slinkonce_odr
, but that allows llvm to discard unreferenced globals, causing linking failures when linkinglinkonce_odr
symbols from multiple modules. llvm'sweak_odr
has the same merging semantics as llvm'slinkonce_odr
, except that unreferenced globals may not be discarded.SPIR-V's
LinkOnceODR
is "Same as theExport
linkage type but a function or global variable with this linkage type will be merged with other functions or global variables of the same name when linkage occurs". Unreferenced globals withExport
linkage (that gets mapped tocommon
orexternal
llvm linkage) are not discarded, soweak_odr
seems to be a better fit forLinkOnceODR
.When producing SPIR-V, map both
linkonce_odr
andweak_odr
toLinkOnceODR
for backwards compatibility, and add an llvm function with the previouslinkonce_odr
linkage to the test.