[llvm] [RemoveDIs] Change remapDbgVariableRecord to remapDbgRecord (PR #91456)
Harald van Dijk via llvm-commits
llvm-commits at lists.llvm.org
Wed May 8 03:36:30 PDT 2024
https://github.com/hvdijk created https://github.com/llvm/llvm-project/pull/91456
We need to remap any DbgRecord, not just DbgVariableRecords.
This is the followup to #91447.
>From 5202ac14cd77d83ff8b3d0b53f01ad9e5057993b Mon Sep 17 00:00:00 2001
From: Harald van Dijk <harald.vandijk at codeplay.com>
Date: Wed, 8 May 2024 11:34:54 +0100
Subject: [PATCH] [RemoveDIs] Change remapDbgVariableRecord to remapDbgRecord
We need to remap any DbgRecord, not just DbgVariableRecords.
---
.../llvm/Transforms/Utils/ValueMapper.h | 34 +++++++++----------
.../Transforms/Scalar/SimpleLoopUnswitch.cpp | 5 ++-
llvm/lib/Transforms/Utils/CloneFunction.cpp | 17 +++++-----
.../Transforms/Utils/LoopRotationUtils.cpp | 10 +++---
.../Transforms/Utils/LoopUnrollRuntime.cpp | 5 ++-
llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 4 +--
llvm/lib/Transforms/Utils/ValueMapper.cpp | 10 +++---
7 files changed, 39 insertions(+), 46 deletions(-)
diff --git a/llvm/include/llvm/Transforms/Utils/ValueMapper.h b/llvm/include/llvm/Transforms/Utils/ValueMapper.h
index 54e3e62dc3af5..743cfeb7ef3f0 100644
--- a/llvm/include/llvm/Transforms/Utils/ValueMapper.h
+++ b/llvm/include/llvm/Transforms/Utils/ValueMapper.h
@@ -180,9 +180,8 @@ class ValueMapper {
Constant *mapConstant(const Constant &C);
void remapInstruction(Instruction &I);
- void remapDbgVariableRecord(Module *M, DbgVariableRecord &V);
- void remapDbgVariableRecordRange(Module *M,
- iterator_range<DbgRecordIterator> Range);
+ void remapDbgRecord(Module *M, DbgRecord &V);
+ void remapDbgRecordRange(Module *M, iterator_range<DbgRecordIterator> Range);
void remapFunction(Function &F);
void remapGlobalObjectMetadata(GlobalObject &GO);
@@ -268,26 +267,25 @@ inline void RemapInstruction(Instruction *I, ValueToValueMapTy &VM,
ValueMapper(VM, Flags, TypeMapper, Materializer).remapInstruction(*I);
}
-/// Remap the Values used in the DbgVariableRecord \a V using the value map \a
+/// Remap the Values used in the DbgRecord \a DR using the value map \a
/// VM.
-inline void RemapDbgVariableRecord(Module *M, DbgVariableRecord *V,
- ValueToValueMapTy &VM,
- RemapFlags Flags = RF_None,
- ValueMapTypeRemapper *TypeMapper = nullptr,
- ValueMaterializer *Materializer = nullptr) {
- ValueMapper(VM, Flags, TypeMapper, Materializer)
- .remapDbgVariableRecord(M, *V);
+inline void RemapDbgRecord(Module *M, DbgRecord *DR, ValueToValueMapTy &VM,
+ RemapFlags Flags = RF_None,
+ ValueMapTypeRemapper *TypeMapper = nullptr,
+ ValueMaterializer *Materializer = nullptr) {
+ ValueMapper(VM, Flags, TypeMapper, Materializer).remapDbgRecord(M, *DR);
}
-/// Remap the Values used in the DbgVariableRecord \a V using the value map \a
+/// Remap the Values used in the DbgRecords \a Range using the value map \a
/// VM.
-inline void
-RemapDbgVariableRecordRange(Module *M, iterator_range<DbgRecordIterator> Range,
- ValueToValueMapTy &VM, RemapFlags Flags = RF_None,
- ValueMapTypeRemapper *TypeMapper = nullptr,
- ValueMaterializer *Materializer = nullptr) {
+inline void RemapDbgRecordRange(Module *M,
+ iterator_range<DbgRecordIterator> Range,
+ ValueToValueMapTy &VM,
+ RemapFlags Flags = RF_None,
+ ValueMapTypeRemapper *TypeMapper = nullptr,
+ ValueMaterializer *Materializer = nullptr) {
ValueMapper(VM, Flags, TypeMapper, Materializer)
- .remapDbgVariableRecordRange(M, Range);
+ .remapDbgRecordRange(M, Range);
}
/// Remap the operands, metadata, arguments, and instructions of a function.
diff --git a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
index d763b1ee0aa1b..002ed381a4fd2 100644
--- a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
+++ b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
@@ -1261,9 +1261,8 @@ static BasicBlock *buildClonedLoopBlocks(
Module *M = ClonedPH->getParent()->getParent();
for (auto *ClonedBB : NewBlocks)
for (Instruction &I : *ClonedBB) {
- RemapDbgVariableRecordRange(M, I.getDbgRecordRange(), VMap,
- RF_NoModuleLevelChanges |
- RF_IgnoreMissingLocals);
+ RemapDbgRecordRange(M, I.getDbgRecordRange(), VMap,
+ RF_NoModuleLevelChanges | RF_IgnoreMissingLocals);
RemapInstruction(&I, VMap,
RF_NoModuleLevelChanges | RF_IgnoreMissingLocals);
if (auto *II = dyn_cast<AssumeInst>(&I))
diff --git a/llvm/lib/Transforms/Utils/CloneFunction.cpp b/llvm/lib/Transforms/Utils/CloneFunction.cpp
index 6a3b3faac77df..981183682b8bf 100644
--- a/llvm/lib/Transforms/Utils/CloneFunction.cpp
+++ b/llvm/lib/Transforms/Utils/CloneFunction.cpp
@@ -278,8 +278,8 @@ void llvm::CloneFunctionInto(Function *NewFunc, const Function *OldFunc,
// attached debug-info records.
for (Instruction &II : *BB) {
RemapInstruction(&II, VMap, RemapFlag, TypeMapper, Materializer);
- RemapDbgVariableRecordRange(II.getModule(), II.getDbgRecordRange(), VMap,
- RemapFlag, TypeMapper, Materializer);
+ RemapDbgRecordRange(II.getModule(), II.getDbgRecordRange(), VMap,
+ RemapFlag, TypeMapper, Materializer);
}
// Only update !llvm.dbg.cu for DifferentModule (not CloneModule). In the
@@ -867,10 +867,10 @@ void llvm::CloneAndPruneIntoFromInst(Function *NewFunc, const Function *OldFunc,
Function::iterator Begin = cast<BasicBlock>(VMap[StartingBB])->getIterator();
for (BasicBlock &BB : make_range(Begin, NewFunc->end())) {
for (Instruction &I : BB) {
- RemapDbgVariableRecordRange(I.getModule(), I.getDbgRecordRange(), VMap,
- ModuleLevelChanges ? RF_None
- : RF_NoModuleLevelChanges,
- TypeMapper, Materializer);
+ RemapDbgRecordRange(I.getModule(), I.getDbgRecordRange(), VMap,
+ ModuleLevelChanges ? RF_None
+ : RF_NoModuleLevelChanges,
+ TypeMapper, Materializer);
}
}
@@ -969,9 +969,8 @@ void llvm::remapInstructionsInBlocks(ArrayRef<BasicBlock *> Blocks,
// Rewrite the code to refer to itself.
for (auto *BB : Blocks) {
for (auto &Inst : *BB) {
- RemapDbgVariableRecordRange(
- Inst.getModule(), Inst.getDbgRecordRange(), VMap,
- RF_NoModuleLevelChanges | RF_IgnoreMissingLocals);
+ RemapDbgRecordRange(Inst.getModule(), Inst.getDbgRecordRange(), VMap,
+ RF_NoModuleLevelChanges | RF_IgnoreMissingLocals);
RemapInstruction(&Inst, VMap,
RF_NoModuleLevelChanges | RF_IgnoreMissingLocals);
}
diff --git a/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp b/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
index 5cd96412a322d..08ba65d9483e0 100644
--- a/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
+++ b/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
@@ -639,9 +639,8 @@ bool LoopRotate::rotateLoop(Loop *L, bool SimplifiedLatch) {
!NextDbgInsts.empty()) {
auto DbgValueRange =
LoopEntryBranch->cloneDebugInfoFrom(Inst, NextDbgInsts.begin());
- RemapDbgVariableRecordRange(M, DbgValueRange, ValueMap,
- RF_NoModuleLevelChanges |
- RF_IgnoreMissingLocals);
+ RemapDbgRecordRange(M, DbgValueRange, ValueMap,
+ RF_NoModuleLevelChanges | RF_IgnoreMissingLocals);
// Erase anything we've seen before.
for (DbgVariableRecord &DVR :
make_early_inc_range(filterDbgVars(DbgValueRange)))
@@ -666,9 +665,8 @@ bool LoopRotate::rotateLoop(Loop *L, bool SimplifiedLatch) {
if (LoopEntryBranch->getParent()->IsNewDbgInfoFormat &&
!NextDbgInsts.empty()) {
auto Range = C->cloneDebugInfoFrom(Inst, NextDbgInsts.begin());
- RemapDbgVariableRecordRange(M, Range, ValueMap,
- RF_NoModuleLevelChanges |
- RF_IgnoreMissingLocals);
+ RemapDbgRecordRange(M, Range, ValueMap,
+ RF_NoModuleLevelChanges | RF_IgnoreMissingLocals);
NextDbgInsts = DbgMarker::getEmptyDbgRecordRange();
// Erase anything we've seen before.
for (DbgVariableRecord &DVR :
diff --git a/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp b/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
index 2d5b5f967ffbc..e1af02829c1da 100644
--- a/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
+++ b/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
@@ -917,9 +917,8 @@ bool llvm::UnrollRuntimeLoopRemainder(
for (Instruction &I : *BB) {
RemapInstruction(&I, VMap,
RF_NoModuleLevelChanges | RF_IgnoreMissingLocals);
- RemapDbgVariableRecordRange(M, I.getDbgRecordRange(), VMap,
- RF_NoModuleLevelChanges |
- RF_IgnoreMissingLocals);
+ RemapDbgRecordRange(M, I.getDbgRecordRange(), VMap,
+ RF_NoModuleLevelChanges | RF_IgnoreMissingLocals);
}
}
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 5a44a11ecfd2c..ac9a429976adf 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -1124,7 +1124,7 @@ static void CloneInstructionsIntoPredecessorBlockAndUpdateSSAUses(
NewBonusInst->insertInto(PredBlock, PTI->getIterator());
auto Range = NewBonusInst->cloneDebugInfoFrom(&BonusInst);
- RemapDbgVariableRecordRange(NewBonusInst->getModule(), Range, VMap,
+ RemapDbgRecordRange(NewBonusInst->getModule(), Range, VMap,
RF_NoModuleLevelChanges |
RF_IgnoreMissingLocals);
@@ -3860,7 +3860,7 @@ static bool performBranchToCommonDestFolding(BranchInst *BI, BranchInst *PBI,
PredBlock->getTerminator()->cloneDebugInfoFrom(BB->getTerminator());
for (DbgVariableRecord &DVR :
filterDbgVars(PredBlock->getTerminator()->getDbgRecordRange())) {
- RemapDbgVariableRecord(M, &DVR, VMap,
+ RemapDbgRecord(M, &DVR, VMap,
RF_NoModuleLevelChanges | RF_IgnoreMissingLocals);
}
}
diff --git a/llvm/lib/Transforms/Utils/ValueMapper.cpp b/llvm/lib/Transforms/Utils/ValueMapper.cpp
index 1c877ee937fbf..1696e9c726735 100644
--- a/llvm/lib/Transforms/Utils/ValueMapper.cpp
+++ b/llvm/lib/Transforms/Utils/ValueMapper.cpp
@@ -1236,14 +1236,14 @@ void ValueMapper::remapInstruction(Instruction &I) {
FlushingMapper(pImpl)->remapInstruction(&I);
}
-void ValueMapper::remapDbgVariableRecord(Module *M, DbgVariableRecord &V) {
- FlushingMapper(pImpl)->remapDbgRecord(V);
+void ValueMapper::remapDbgRecord(Module *M, DbgRecord &DR) {
+ FlushingMapper(pImpl)->remapDbgRecord(DR);
}
-void ValueMapper::remapDbgVariableRecordRange(
+void ValueMapper::remapDbgRecordRange(
Module *M, iterator_range<DbgRecord::self_iterator> Range) {
- for (DbgVariableRecord &DVR : filterDbgVars(Range)) {
- remapDbgVariableRecord(M, DVR);
+ for (DbgRecord &DR : Range) {
+ remapDbgRecord(M, DR);
}
}
More information about the llvm-commits
mailing list