Skip to content

Conversation

Zalathar
Copy link
Contributor


This PR dismantles the somewhat complicated LLVMRustDIBuilderCreateStaticVariable function, and replaces it with equivalent calls to LLVMDIBuilderCreateGlobalVariableExpression and LLVMGlobalSetMetadata.

A key difference is that the new code does not replicate the attempted downcast of InitVal. As far as I can tell, those downcasts were actually dead, because llvm::ConstantInt and llvm::ConstantFP are not subclasses of llvm::GlobalVariable. I tried replacing those code paths with fatal errors, and was unable to induce failure in any of the relevant test suites I ran.

I have also confirmed that if the calls to create_static_variable are commented out, debuginfo tests will fail, demonstrating some amount of relevant test coverage.

The new DIBuilder methods have been added via an extension trait, not as inherent methods, to avoid impeding #142897.

@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 12, 2025
@rustbot
Copy link
Collaborator

rustbot commented Oct 12, 2025

r? @nnethercote

rustbot has assigned @nnethercote.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Note that the code in `LLVMRustDIBuilderCreateStaticVariable` that tried to
downcast `InitVal` appears to have been dead, because `llvm::ConstantInt` and
`llvm::ConstantFP` are not subclasses of `llvm::GlobalVariable`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants