Skip to content

Migrate to LLVM{Get,Set}ValueName2 #64223

@hanna-kruppe

Description

@hanna-kruppe
Contributor

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

added
C-cleanupCategory: PRs that clean code up or issues documenting cleanup.
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.
on Sep 6, 2019
eddyb

eddyb commented on Sep 6, 2019

@eddyb
Member

Any idea how old the new APIs are? I don't see any reason not to switch other than that.

hanna-kruppe

hanna-kruppe commented on Sep 6, 2019

@hanna-kruppe
ContributorAuthor

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

hanna-kruppe commented on Sep 6, 2019

@hanna-kruppe
ContributorAuthor

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

nikic commented on Sep 6, 2019

@nikic
Contributor

@rkruppe We'll have to wait for #63649 to land first, as emscripten is still on LLVM 6.

added
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
on Sep 10, 2019
hanna-kruppe

hanna-kruppe commented on Oct 4, 2019

@hanna-kruppe
ContributorAuthor

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

cuviper commented on Dec 2, 2019

@cuviper
Member

FYI, #66973 bumps to LLVM 7.

added a commit that references this issue on Dec 6, 2019
0b471bf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-cleanupCategory: PRs that clean code up or issues documenting cleanup.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @cuviper@eddyb@nikic@jonas-schievink@hanna-kruppe

      Issue actions

        Migrate to LLVM{Get,Set}ValueName2 · Issue #64223 · rust-lang/rust