aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Bitcode/Reader/MetadataLoader.cpp
diff options
context:
space:
mode:
authorOrlando Cazalet-Hyams <orlando.hyams@sony.com>2024-03-19 13:28:43 +0000
committerGitHub <noreply@github.com>2024-03-19 13:28:43 +0000
commit835c1b56a82542d91c337e24140bd2b08a7bf715 (patch)
tree9aeb9a507aaf79987be72c223c0cc3297f1d6915 /llvm/lib/Bitcode/Reader/MetadataLoader.cpp
parent94c6ce1de92f56879cad1bfa12ba23ef0ecfcd91 (diff)
downloadllvm-835c1b56a82542d91c337e24140bd2b08a7bf715.zip
llvm-835c1b56a82542d91c337e24140bd2b08a7bf715.tar.gz
llvm-835c1b56a82542d91c337e24140bd2b08a7bf715.tar.bz2
[RemoveDIs] Auto-upgrade debug intrinsics to DbgRecords (default false) (#85650)
If --load-bitcode-into-experimental-debuginfo-iterators is true then debug intrinsics are auto-upgraded to DbgRecords (the new debug info format). The upgrade is trivial because the two representations are semantically identical. llvm.dbg.value with 4 operands and llvm.dbg.addr intrinsics are upgraded in the same way as usual, but converted directly into DbgRecords instead of debug intrinsics.
Diffstat (limited to 'llvm/lib/Bitcode/Reader/MetadataLoader.cpp')
-rw-r--r--llvm/lib/Bitcode/Reader/MetadataLoader.cpp26
1 files changed, 17 insertions, 9 deletions
diff --git a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp
index 3807320..fb005ee 100644
--- a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp
+++ b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp
@@ -609,17 +609,25 @@ class MetadataLoader::MetadataLoaderImpl {
if (!NeedDeclareExpressionUpgrade)
return;
+ auto UpdateDeclareIfNeeded = [&](auto *Declare) {
+ auto *DIExpr = Declare->getExpression();
+ if (!DIExpr || !DIExpr->startsWithDeref() ||
+ !isa_and_nonnull<Argument>(Declare->getAddress()))
+ return;
+ SmallVector<uint64_t, 8> Ops;
+ Ops.append(std::next(DIExpr->elements_begin()), DIExpr->elements_end());
+ Declare->setExpression(DIExpression::get(Context, Ops));
+ };
+
for (auto &BB : F)
- for (auto &I : BB)
+ for (auto &I : BB) {
+ for (DPValue &DPV : filterDbgVars(I.getDbgRecordRange())) {
+ if (DPV.isDbgDeclare())
+ UpdateDeclareIfNeeded(&DPV);
+ }
if (auto *DDI = dyn_cast<DbgDeclareInst>(&I))
- if (auto *DIExpr = DDI->getExpression())
- if (DIExpr->startsWithDeref() &&
- isa_and_nonnull<Argument>(DDI->getAddress())) {
- SmallVector<uint64_t, 8> Ops;
- Ops.append(std::next(DIExpr->elements_begin()),
- DIExpr->elements_end());
- DDI->setExpression(DIExpression::get(Context, Ops));
- }
+ UpdateDeclareIfNeeded(DDI);
+ }
}
/// Upgrade the expression from previous versions.