Rollup merge of #147608 - Zalathar:debuginfo, r=nnethercote
cg_llvm: Use `LLVMDIBuilderCreateGlobalVariableExpression` - Part of rust-lang/rust#134001 - Follow-up to rust-lang/rust#146763 --- 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 rust-lang/rust#142897.
This commit is contained in:
@@ -22,9 +22,9 @@ use libc::{c_char, c_int, c_uchar, c_uint, c_ulonglong, c_void, size_t};
|
||||
|
||||
use super::RustString;
|
||||
use super::debuginfo::{
|
||||
DIArray, DIBuilder, DIDerivedType, DIDescriptor, DIEnumerator, DIFile, DIFlags,
|
||||
DIGlobalVariableExpression, DILocation, DISPFlags, DIScope, DISubprogram,
|
||||
DITemplateTypeParameter, DIType, DebugEmissionKind, DebugNameTableKind,
|
||||
DIArray, DIBuilder, DIDerivedType, DIDescriptor, DIEnumerator, DIFile, DIFlags, DILocation,
|
||||
DISPFlags, DIScope, DISubprogram, DITemplateTypeParameter, DIType, DebugEmissionKind,
|
||||
DebugNameTableKind,
|
||||
};
|
||||
use crate::llvm::MetadataKindId;
|
||||
use crate::{TryFromU32, llvm};
|
||||
@@ -781,7 +781,6 @@ pub(crate) mod debuginfo {
|
||||
pub(crate) type DIDerivedType = DIType;
|
||||
pub(crate) type DICompositeType = DIDerivedType;
|
||||
pub(crate) type DIVariable = DIDescriptor;
|
||||
pub(crate) type DIGlobalVariableExpression = DIDescriptor;
|
||||
pub(crate) type DIArray = DIDescriptor;
|
||||
pub(crate) type DIEnumerator = DIDescriptor;
|
||||
pub(crate) type DITemplateTypeParameter = DIDescriptor;
|
||||
@@ -1877,6 +1876,22 @@ unsafe extern "C" {
|
||||
Length: size_t,
|
||||
) -> &'ll Metadata;
|
||||
|
||||
pub(crate) fn LLVMDIBuilderCreateGlobalVariableExpression<'ll>(
|
||||
Builder: &DIBuilder<'ll>,
|
||||
Scope: Option<&'ll Metadata>,
|
||||
Name: *const c_uchar, // See "PTR_LEN_STR".
|
||||
NameLen: size_t,
|
||||
Linkage: *const c_uchar, // See "PTR_LEN_STR".
|
||||
LinkLen: size_t,
|
||||
File: &'ll Metadata,
|
||||
LineNo: c_uint,
|
||||
Ty: &'ll Metadata,
|
||||
LocalToUnit: llvm::Bool,
|
||||
Expr: &'ll Metadata,
|
||||
Decl: Option<&'ll Metadata>,
|
||||
AlignInBits: u32,
|
||||
) -> &'ll Metadata;
|
||||
|
||||
pub(crate) fn LLVMDIBuilderInsertDeclareRecordAtEnd<'ll>(
|
||||
Builder: &DIBuilder<'ll>,
|
||||
Storage: &'ll Value,
|
||||
@@ -2213,22 +2228,6 @@ unsafe extern "C" {
|
||||
Ty: &'a DIType,
|
||||
) -> &'a DIType;
|
||||
|
||||
pub(crate) fn LLVMRustDIBuilderCreateStaticVariable<'a>(
|
||||
Builder: &DIBuilder<'a>,
|
||||
Context: Option<&'a DIScope>,
|
||||
Name: *const c_char,
|
||||
NameLen: size_t,
|
||||
LinkageName: *const c_char,
|
||||
LinkageNameLen: size_t,
|
||||
File: &'a DIFile,
|
||||
LineNo: c_uint,
|
||||
Ty: &'a DIType,
|
||||
isLocalToUnit: bool,
|
||||
Val: &'a Value,
|
||||
Decl: Option<&'a DIDescriptor>,
|
||||
AlignInBits: u32,
|
||||
) -> &'a DIGlobalVariableExpression;
|
||||
|
||||
pub(crate) fn LLVMRustDIBuilderCreateEnumerator<'a>(
|
||||
Builder: &DIBuilder<'a>,
|
||||
Name: *const c_char,
|
||||
|
||||
Reference in New Issue
Block a user