rust/compiler/rustc_codegen_llvm/src
Guillaume Gomez 3938f42bb1
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.
2025-10-13 11:25:23 +02:00
..
back Remove inherent methods from llvm::Type 2025-10-04 18:47:18 +10:00
builder Use globals instead of metadata, since metadata isn't emitted in debug builds 2025-10-07 20:13:59 -04:00
coverageinfo use declarative macro for #[derive(TryFromU32)] 2025-10-06 14:54:38 +00:00
debuginfo Use LLVMDIBuilderCreateGlobalVariableExpression 2025-10-12 23:36:26 +11:00
llvm Rollup merge of #147608 - Zalathar:debuginfo, r=nnethercote 2025-10-13 11:25:23 +02:00
abi.rs Consistently import llvm::Type and llvm::Value 2025-10-06 13:09:16 +11:00
allocator.rs Remove inherent methods from several LLVM FFI types 2025-10-04 18:16:13 +10:00
asm.rs Consistently import llvm::Type and llvm::Value 2025-10-06 13:09:16 +11:00
attributes.rs Consistently import llvm::Type and llvm::Value 2025-10-06 13:09:16 +11:00
base.rs Consistently import llvm::Type and llvm::Value 2025-10-06 13:09:16 +11:00
builder.rs remove intrinsic wrapper functions from LLVM bindings 2025-10-09 09:26:44 +02:00
callee.rs Consistently import llvm::Type and llvm::Value 2025-10-06 13:09:16 +11:00
common.rs Consistently import llvm::Type and llvm::Value 2025-10-06 13:09:16 +11:00
consts.rs refactor: Remove LLVMRustInsertPrivateGlobal and define_private_global 2025-10-08 21:59:48 +02:00
context.rs Consistently import llvm::Type and llvm::Value 2025-10-06 13:09:16 +11:00
declare.rs refactor: Remove LLVMRustInsertPrivateGlobal and define_private_global 2025-10-08 21:59:48 +02:00
errors.rs Use the object crate rather than LLVM for extracting bitcode sections 2025-07-25 11:21:28 +00:00
intrinsic.rs Consistently import llvm::Type and llvm::Value 2025-10-06 13:09:16 +11:00
lib.rs Replace LLVMRustContextCreate with normal LLVM-C API calls 2025-10-10 15:45:40 +02:00
llvm_util.rs Add panic=immediate-abort 2025-09-21 13:12:18 -04:00
macros.rs use declarative macro for #[derive(TryFromU32)] 2025-10-06 14:54:38 +00:00
mono_item.rs Replace the llvm::Bool typedef with a proper newtype 2025-08-24 23:09:54 +10:00
type_.rs Consistently import llvm::Type and llvm::Value 2025-10-06 13:09:16 +11:00
type_of.rs Consistently import llvm::Type and llvm::Value 2025-10-06 13:09:16 +11:00
typetree.rs autodiff: typetree recursive depth query from enzyme with fallback 2025-09-19 05:42:27 +00:00
va_arg.rs Consistently import llvm::Type and llvm::Value 2025-10-06 13:09:16 +11:00
value.rs Consistently import llvm::Type and llvm::Value 2025-10-06 13:09:16 +11:00