Closed
Description
We currently use the C APIs LLVM{Get,Set}ValueName
which return/take a 0-terminated char *
, but those APIs have been deprecated a while ago in favor of LLVM{Get,Set}ValueName2
which return/take pairs of char *
+ length (the C-friendly lowering of llvm::StringRef
) which need not be 0-terminated. We should migrate to those APIs. Besides avoiding silly error cases for names that contain a 0 byte, it would also make conversions from &str
to LLVM name free, and reduce the cost of the opposite direction to an UTF-8 validity check (plus, I suspect many or all code paths that do that could just as well use &[u8]
, and that conversion actually is 100% free).
Activity
eddyb commentedon Sep 6, 2019
Any idea how old the new APIs are? I don't see any reason not to switch other than that.
hanna-kruppe commentedon Sep 6, 2019
They were added in llvm/llvm-project@025c78f which is in the 7.0 release, what's our minimum supported LLVM version these days?
hanna-kruppe commentedon Sep 6, 2019
The current minimum is 6, but considering the constraints raised when it was bumped from 5 to 6 (#56642) it seems to me that bumping to 7 might be OK already. Worth a try IMO.
nikic commentedon Sep 6, 2019
@rkruppe We'll have to wait for #63649 to land first, as emscripten is still on LLVM 6.
hanna-kruppe commentedon Oct 4, 2019
I just realized, if we cared enough we could also provide our own equivalent of these functions in src/rustllvm (and just remove them when we drop LLVM 6 support). The C API was just lagging behind, the C++ APIs have supported it for much longer.
cuviper commentedon Dec 2, 2019
FYI, #66973 bumps to LLVM 7.
Rollup merge of rust-lang#67033 - cuviper:ValueName2, r=rkruppe