Skip to content

Commit 5202ac1

Browse files
committed
[RemoveDIs] Change remapDbgVariableRecord to remapDbgRecord
We need to remap any DbgRecord, not just DbgVariableRecords.
1 parent 927913f commit 5202ac1

File tree

7 files changed

+39
-46
lines changed

7 files changed

+39
-46
lines changed

llvm/include/llvm/Transforms/Utils/ValueMapper.h

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,8 @@ class ValueMapper {
180180
Constant *mapConstant(const Constant &C);
181181

182182
void remapInstruction(Instruction &I);
183-
void remapDbgVariableRecord(Module *M, DbgVariableRecord &V);
184-
void remapDbgVariableRecordRange(Module *M,
185-
iterator_range<DbgRecordIterator> Range);
183+
void remapDbgRecord(Module *M, DbgRecord &V);
184+
void remapDbgRecordRange(Module *M, iterator_range<DbgRecordIterator> Range);
186185
void remapFunction(Function &F);
187186
void remapGlobalObjectMetadata(GlobalObject &GO);
188187

@@ -268,26 +267,25 @@ inline void RemapInstruction(Instruction *I, ValueToValueMapTy &VM,
268267
ValueMapper(VM, Flags, TypeMapper, Materializer).remapInstruction(*I);
269268
}
270269

271-
/// Remap the Values used in the DbgVariableRecord \a V using the value map \a
270+
/// Remap the Values used in the DbgRecord \a DR using the value map \a
272271
/// VM.
273-
inline void RemapDbgVariableRecord(Module *M, DbgVariableRecord *V,
274-
ValueToValueMapTy &VM,
275-
RemapFlags Flags = RF_None,
276-
ValueMapTypeRemapper *TypeMapper = nullptr,
277-
ValueMaterializer *Materializer = nullptr) {
278-
ValueMapper(VM, Flags, TypeMapper, Materializer)
279-
.remapDbgVariableRecord(M, *V);
272+
inline void RemapDbgRecord(Module *M, DbgRecord *DR, ValueToValueMapTy &VM,
273+
RemapFlags Flags = RF_None,
274+
ValueMapTypeRemapper *TypeMapper = nullptr,
275+
ValueMaterializer *Materializer = nullptr) {
276+
ValueMapper(VM, Flags, TypeMapper, Materializer).remapDbgRecord(M, *DR);
280277
}
281278

282-
/// Remap the Values used in the DbgVariableRecord \a V using the value map \a
279+
/// Remap the Values used in the DbgRecords \a Range using the value map \a
283280
/// VM.
284-
inline void
285-
RemapDbgVariableRecordRange(Module *M, iterator_range<DbgRecordIterator> Range,
286-
ValueToValueMapTy &VM, RemapFlags Flags = RF_None,
287-
ValueMapTypeRemapper *TypeMapper = nullptr,
288-
ValueMaterializer *Materializer = nullptr) {
281+
inline void RemapDbgRecordRange(Module *M,
282+
iterator_range<DbgRecordIterator> Range,
283+
ValueToValueMapTy &VM,
284+
RemapFlags Flags = RF_None,
285+
ValueMapTypeRemapper *TypeMapper = nullptr,
286+
ValueMaterializer *Materializer = nullptr) {
289287
ValueMapper(VM, Flags, TypeMapper, Materializer)
290-
.remapDbgVariableRecordRange(M, Range);
288+
.remapDbgRecordRange(M, Range);
291289
}
292290

293291
/// Remap the operands, metadata, arguments, and instructions of a function.

llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,9 +1261,8 @@ static BasicBlock *buildClonedLoopBlocks(
12611261
Module *M = ClonedPH->getParent()->getParent();
12621262
for (auto *ClonedBB : NewBlocks)
12631263
for (Instruction &I : *ClonedBB) {
1264-
RemapDbgVariableRecordRange(M, I.getDbgRecordRange(), VMap,
1265-
RF_NoModuleLevelChanges |
1266-
RF_IgnoreMissingLocals);
1264+
RemapDbgRecordRange(M, I.getDbgRecordRange(), VMap,
1265+
RF_NoModuleLevelChanges | RF_IgnoreMissingLocals);
12671266
RemapInstruction(&I, VMap,
12681267
RF_NoModuleLevelChanges | RF_IgnoreMissingLocals);
12691268
if (auto *II = dyn_cast<AssumeInst>(&I))

llvm/lib/Transforms/Utils/CloneFunction.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,8 @@ void llvm::CloneFunctionInto(Function *NewFunc, const Function *OldFunc,
278278
// attached debug-info records.
279279
for (Instruction &II : *BB) {
280280
RemapInstruction(&II, VMap, RemapFlag, TypeMapper, Materializer);
281-
RemapDbgVariableRecordRange(II.getModule(), II.getDbgRecordRange(), VMap,
282-
RemapFlag, TypeMapper, Materializer);
281+
RemapDbgRecordRange(II.getModule(), II.getDbgRecordRange(), VMap,
282+
RemapFlag, TypeMapper, Materializer);
283283
}
284284

285285
// Only update !llvm.dbg.cu for DifferentModule (not CloneModule). In the
@@ -867,10 +867,10 @@ void llvm::CloneAndPruneIntoFromInst(Function *NewFunc, const Function *OldFunc,
867867
Function::iterator Begin = cast<BasicBlock>(VMap[StartingBB])->getIterator();
868868
for (BasicBlock &BB : make_range(Begin, NewFunc->end())) {
869869
for (Instruction &I : BB) {
870-
RemapDbgVariableRecordRange(I.getModule(), I.getDbgRecordRange(), VMap,
871-
ModuleLevelChanges ? RF_None
872-
: RF_NoModuleLevelChanges,
873-
TypeMapper, Materializer);
870+
RemapDbgRecordRange(I.getModule(), I.getDbgRecordRange(), VMap,
871+
ModuleLevelChanges ? RF_None
872+
: RF_NoModuleLevelChanges,
873+
TypeMapper, Materializer);
874874
}
875875
}
876876

@@ -969,9 +969,8 @@ void llvm::remapInstructionsInBlocks(ArrayRef<BasicBlock *> Blocks,
969969
// Rewrite the code to refer to itself.
970970
for (auto *BB : Blocks) {
971971
for (auto &Inst : *BB) {
972-
RemapDbgVariableRecordRange(
973-
Inst.getModule(), Inst.getDbgRecordRange(), VMap,
974-
RF_NoModuleLevelChanges | RF_IgnoreMissingLocals);
972+
RemapDbgRecordRange(Inst.getModule(), Inst.getDbgRecordRange(), VMap,
973+
RF_NoModuleLevelChanges | RF_IgnoreMissingLocals);
975974
RemapInstruction(&Inst, VMap,
976975
RF_NoModuleLevelChanges | RF_IgnoreMissingLocals);
977976
}

llvm/lib/Transforms/Utils/LoopRotationUtils.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -639,9 +639,8 @@ bool LoopRotate::rotateLoop(Loop *L, bool SimplifiedLatch) {
639639
!NextDbgInsts.empty()) {
640640
auto DbgValueRange =
641641
LoopEntryBranch->cloneDebugInfoFrom(Inst, NextDbgInsts.begin());
642-
RemapDbgVariableRecordRange(M, DbgValueRange, ValueMap,
643-
RF_NoModuleLevelChanges |
644-
RF_IgnoreMissingLocals);
642+
RemapDbgRecordRange(M, DbgValueRange, ValueMap,
643+
RF_NoModuleLevelChanges | RF_IgnoreMissingLocals);
645644
// Erase anything we've seen before.
646645
for (DbgVariableRecord &DVR :
647646
make_early_inc_range(filterDbgVars(DbgValueRange)))
@@ -666,9 +665,8 @@ bool LoopRotate::rotateLoop(Loop *L, bool SimplifiedLatch) {
666665
if (LoopEntryBranch->getParent()->IsNewDbgInfoFormat &&
667666
!NextDbgInsts.empty()) {
668667
auto Range = C->cloneDebugInfoFrom(Inst, NextDbgInsts.begin());
669-
RemapDbgVariableRecordRange(M, Range, ValueMap,
670-
RF_NoModuleLevelChanges |
671-
RF_IgnoreMissingLocals);
668+
RemapDbgRecordRange(M, Range, ValueMap,
669+
RF_NoModuleLevelChanges | RF_IgnoreMissingLocals);
672670
NextDbgInsts = DbgMarker::getEmptyDbgRecordRange();
673671
// Erase anything we've seen before.
674672
for (DbgVariableRecord &DVR :

llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -917,9 +917,8 @@ bool llvm::UnrollRuntimeLoopRemainder(
917917
for (Instruction &I : *BB) {
918918
RemapInstruction(&I, VMap,
919919
RF_NoModuleLevelChanges | RF_IgnoreMissingLocals);
920-
RemapDbgVariableRecordRange(M, I.getDbgRecordRange(), VMap,
921-
RF_NoModuleLevelChanges |
922-
RF_IgnoreMissingLocals);
920+
RemapDbgRecordRange(M, I.getDbgRecordRange(), VMap,
921+
RF_NoModuleLevelChanges | RF_IgnoreMissingLocals);
923922
}
924923
}
925924

llvm/lib/Transforms/Utils/SimplifyCFG.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,7 +1124,7 @@ static void CloneInstructionsIntoPredecessorBlockAndUpdateSSAUses(
11241124

11251125
NewBonusInst->insertInto(PredBlock, PTI->getIterator());
11261126
auto Range = NewBonusInst->cloneDebugInfoFrom(&BonusInst);
1127-
RemapDbgVariableRecordRange(NewBonusInst->getModule(), Range, VMap,
1127+
RemapDbgRecordRange(NewBonusInst->getModule(), Range, VMap,
11281128
RF_NoModuleLevelChanges |
11291129
RF_IgnoreMissingLocals);
11301130

@@ -3860,7 +3860,7 @@ static bool performBranchToCommonDestFolding(BranchInst *BI, BranchInst *PBI,
38603860
PredBlock->getTerminator()->cloneDebugInfoFrom(BB->getTerminator());
38613861
for (DbgVariableRecord &DVR :
38623862
filterDbgVars(PredBlock->getTerminator()->getDbgRecordRange())) {
3863-
RemapDbgVariableRecord(M, &DVR, VMap,
3863+
RemapDbgRecord(M, &DVR, VMap,
38643864
RF_NoModuleLevelChanges | RF_IgnoreMissingLocals);
38653865
}
38663866
}

llvm/lib/Transforms/Utils/ValueMapper.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,14 +1236,14 @@ void ValueMapper::remapInstruction(Instruction &I) {
12361236
FlushingMapper(pImpl)->remapInstruction(&I);
12371237
}
12381238

1239-
void ValueMapper::remapDbgVariableRecord(Module *M, DbgVariableRecord &V) {
1240-
FlushingMapper(pImpl)->remapDbgRecord(V);
1239+
void ValueMapper::remapDbgRecord(Module *M, DbgRecord &DR) {
1240+
FlushingMapper(pImpl)->remapDbgRecord(DR);
12411241
}
12421242

1243-
void ValueMapper::remapDbgVariableRecordRange(
1243+
void ValueMapper::remapDbgRecordRange(
12441244
Module *M, iterator_range<DbgRecord::self_iterator> Range) {
1245-
for (DbgVariableRecord &DVR : filterDbgVars(Range)) {
1246-
remapDbgVariableRecord(M, DVR);
1245+
for (DbgRecord &DR : Range) {
1246+
remapDbgRecord(M, DR);
12471247
}
12481248
}
12491249

0 commit comments

Comments
 (0)