cg_llvm: Use LLVMDIBuilderCreateGlobalVariableExpression
#147608
+150
−93
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
cg_llvm
debuginfo handling to use the LLVM-C API #134001This PR dismantles the somewhat complicated
LLVMRustDIBuilderCreateStaticVariable
function, and replaces it with equivalent calls toLLVMDIBuilderCreateGlobalVariableExpression
andLLVMGlobalSetMetadata
.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, becausellvm::ConstantInt
andllvm::ConstantFP
are not subclasses ofllvm::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.