1
Fork 0

Add discriminators to DILocations when multiple functions are inlined into a single point.

LLVM does not expect to ever see multiple dbg_declares for the same variable at the same
location with different values. proc-macros make it possible for arbitrary code,
including multiple calls that get inlined, to happen at any given location in the source
code. Add discriminators when that happens so these locations are different to LLVM.

This may interfere with the AddDiscriminators pass in LLVM, which is added by the
unstable flag -Zdebug-info-for-profiling.

Fixes #131944
This commit is contained in:
Kyle Huey 2024-11-04 11:38:14 -08:00
parent 80445576d0
commit 1dc106121b
5 changed files with 133 additions and 3 deletions

View file

@ -1305,6 +1305,14 @@ LLVMRustDIBuilderCreateDebugLocation(unsigned Line, unsigned Column,
return wrap(Loc);
}
extern "C" LLVMMetadataRef
LLVMRustDILocationCloneWithBaseDiscriminator(LLVMMetadataRef Location,
unsigned BD) {
DILocation *Loc = unwrapDIPtr<DILocation>(Location);
auto NewLoc = Loc->cloneWithBaseDiscriminator(BD);
return wrap(NewLoc.has_value() ? NewLoc.value() : nullptr);
}
extern "C" uint64_t LLVMRustDIBuilderCreateOpDeref() {
return dwarf::DW_OP_deref;
}