diff options
author | Orlando Cazalet-Hyams <orlando.hyams@sony.com> | 2024-03-19 12:12:35 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-19 12:12:35 +0000 |
commit | 4f909da6bc880b816e000159ce2bf69862d0936e (patch) | |
tree | 072da9e5e47ab370b6a5251ee180f52270970a8c /llvm/lib/Bitcode/Reader/BitcodeReader.cpp | |
parent | 4a6bc9fd14bd79f1edf5b651b43bd9bda9b90991 (diff) | |
download | llvm-4f909da6bc880b816e000159ce2bf69862d0936e.zip llvm-4f909da6bc880b816e000159ce2bf69862d0936e.tar.gz llvm-4f909da6bc880b816e000159ce2bf69862d0936e.tar.bz2 |
[RemoveDIs] Add flag to control loading into new debug mode from bitcode (#85649)
--load-bitcode-into-experimental-debuginfo-iterators
false: Convert to the old debug mode after reading.
true: Upgrade to the new debug info format (*).
unset: Same as false (for now).
(*) As of this patch it actually just means "don't convert to either
mode after loading". Auto-upgrading will be implemented in an upcoming
patch.
With this flag we can incrementally add support for RemoveDIs by
overriding the "unset" behaviour in individual tools. The flag can be
removed once all tools support the new debug info mode.
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r-- | llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index d284c98..dd1b3d9 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -100,6 +100,15 @@ static cl::opt<bool> ExpandConstantExprs( cl::desc( "Expand constant expressions to instructions for testing purposes")); +/// Load bitcode directly into RemoveDIs format (use debug records instead +/// of debug intrinsics). UNSET is treated as FALSE, so the default action +/// is to do nothing. Individual tools can override this to incrementally add +/// support for the RemoveDIs format. +cl::opt<cl::boolOrDefault> LoadBitcodeIntoNewDbgInforFormat( + "load-bitcode-into-experimental-debuginfo-iterators", cl::Hidden, + cl::desc("Load bitcode directly into the new debug info format (regardless " + "of input format)")); + namespace { enum { @@ -4276,9 +4285,11 @@ Error BitcodeReader::parseGlobalIndirectSymbolRecord( Error BitcodeReader::parseModule(uint64_t ResumeBit, bool ShouldLazyLoadMetadata, ParserCallbacks Callbacks) { - // Force the debug-info mode into the old format for now. - // FIXME: Remove this once all tools support RemoveDIs. - TheModule->IsNewDbgInfoFormat = false; + // Load directly into RemoveDIs format if LoadBitcodeIntoNewDbgInforFormat + // has been set to true (default action: load into the old debug format). + TheModule->IsNewDbgInfoFormat = + UseNewDbgInfoFormat && + LoadBitcodeIntoNewDbgInforFormat == cl::boolOrDefault::BOU_TRUE; this->ValueTypeCallback = std::move(Callbacks.ValueType); if (ResumeBit) { @@ -6762,9 +6773,9 @@ Error BitcodeReader::materialize(GlobalValue *GV) { if (Error JumpFailed = Stream.JumpToBit(DFII->second)) return JumpFailed; - // Set the debug info mode to "new", forcing a mismatch between + // Set the debug info mode to "new", possibly creating a mismatch between // module and function debug modes. This is okay because we'll convert - // everything back to the old mode after parsing. + // everything back to the old mode after parsing if needed. // FIXME: Remove this once all tools support RemoveDIs. F->IsNewDbgInfoFormat = true; @@ -6774,7 +6785,8 @@ Error BitcodeReader::materialize(GlobalValue *GV) { // Convert new debug info records into intrinsics. // FIXME: Remove this once all tools support RemoveDIs. - F->convertFromNewDbgValues(); + if (!F->getParent()->IsNewDbgInfoFormat) + F->convertFromNewDbgValues(); if (StripDebugInfo) stripDebugInfo(*F); |