diff options
author | Jeremy Morse <jeremy.morse@sony.com> | 2024-01-25 18:16:31 +0000 |
---|---|---|
committer | Jeremy Morse <jeremy.morse@sony.com> | 2024-01-25 18:37:13 +0000 |
commit | a19629dae70c9f7e7936eba7aa1e0a3a99742288 (patch) | |
tree | 9d063e861858d722cd6c4b0ba068f98b0d019922 /llvm/lib/Bitcode/Reader/BitcodeReader.cpp | |
parent | 2550ce4d496e54fe929f2242833b73003f36e387 (diff) | |
download | llvm-a19629dae70c9f7e7936eba7aa1e0a3a99742288.zip llvm-a19629dae70c9f7e7936eba7aa1e0a3a99742288.tar.gz llvm-a19629dae70c9f7e7936eba7aa1e0a3a99742288.tar.bz2 |
Reapply 215b8f1e252, reverted in c3f7fb1421e
Turns out I was using DbgMarker::getDbgValueRange rather than the helper
utility in Instruction::getDbgValueRange, which checks for null-ness.
Original commit message follows.
[DebugInfo][RemoveDIs] Convert debug-info modes when loading bitcode (#78967)
As part of eliminating debug-intrinsics in LLVM, we'll shortly be
pushing the conversion from "old" dbg.value mode to "new" DPValue mode
out from when the pass manager runs, to when modules are loaded. This
patch adds that conversion process and some (temporary) options to
llvm-lto{,2} to help test it.
Specifically: now whenever we load a bitcode module, consider a flag of
whether to "upgrade" it into the new debug-info mode, and if we're
lazily materializing functions then do that lazily too. Doing this
exposes an error in the IRLinker/materializer handling of DPValues,
where we need to transfer the debug-info format flag correctly, and in
ValueMapper we need to remap the Values that DPValues point at.
I've added some test coverage in the modified tests; these will be
exercised by our llvm-new-debug-iterators buildbot.
This upgrading of debug-info won't be happening for the llvm18 release,
instead we'll turn it on after the branch date, thenbe push the boundary
of where "new" debug-info starts and ends down into the existing
debug-info upgrade path over the course of the next release.
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r-- | llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index a027d0c..5b233fb 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -100,6 +100,9 @@ static cl::opt<bool> ExpandConstantExprs( cl::desc( "Expand constant expressions to instructions for testing purposes")); +// Declare external flag for whether we're using the new debug-info format. +extern llvm::cl::opt<bool> UseNewDbgInfoFormat; + namespace { enum { @@ -6629,6 +6632,9 @@ Error BitcodeReader::materialize(GlobalValue *GV) { if (Error Err = materializeMetadata()) return Err; + bool NewDebugInfoRequested = F->IsNewDbgInfoFormat; + F->IsNewDbgInfoFormat = false; + // Move the bit stream to the saved position of the deferred function body. if (Error JumpFailed = Stream.JumpToBit(DFII->second)) return JumpFailed; @@ -6704,6 +6710,14 @@ Error BitcodeReader::materialize(GlobalValue *GV) { // Look for functions that rely on old function attribute behavior. UpgradeFunctionAttributes(*F); + // If we've materialized a function set up in "new" debug-info mode, the + // contents just loaded will still be in dbg.value mode. Switch to the new + // mode now. NB: we can add more complicated logic here in the future to + // correctly identify when we do and don't need to autoupgrade. + if (NewDebugInfoRequested) { + F->convertToNewDbgValues(); + } + // Bring in any functions that this function forward-referenced via // blockaddresses. return materializeForwardReferencedFunctions(); @@ -8027,6 +8041,15 @@ BitcodeModule::getModuleImpl(LLVMContext &Context, bool MaterializeAll, if (Error Err = R->materializeForwardReferencedFunctions()) return std::move(Err); } + + // If we are operating in a "new debug-info" context, upgrade the debug-info + // in the loaded module. This is a transitional approach as we enable "new" + // debug-info in LLVM, which will eventually be pushed down into the + // autoupgrade path once the bitcode-encoding is finalised. Non-materialised + // functions will be upgraded in the materialize method. + if (UseNewDbgInfoFormat && !M->IsNewDbgInfoFormat) + M->convertToNewDbgValues(); + return std::move(M); } |