[llvm] [DebugInfo][RemoveDIs] Support cloning and remapping DPValues (PR #72546)

via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 16 10:15:58 PST 2023


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff f4e3fb5972b2c42b5373952fccc8259e98b3423b fc90371e43e58497da4e2b31addb4ceb02be58be -- llvm/include/llvm/Transforms/Utils/ValueMapper.h llvm/lib/IR/BasicBlock.cpp llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp llvm/lib/Transforms/Utils/CloneFunction.cpp llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp llvm/lib/Transforms/Utils/SimplifyCFG.cpp llvm/lib/Transforms/Utils/ValueMapper.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/include/llvm/Transforms/Utils/ValueMapper.h b/llvm/include/llvm/Transforms/Utils/ValueMapper.h
index 82f0f99ee1..43ee875a58 100644
--- a/llvm/include/llvm/Transforms/Utils/ValueMapper.h
+++ b/llvm/include/llvm/Transforms/Utils/ValueMapper.h
@@ -180,7 +180,8 @@ public:
 
   void remapInstruction(Instruction &I);
   void remapDPValue(Module *M, DPValue &V);
-  void remapDPValueRange(Module *M, iterator_range<simple_ilist<DPValue>::iterator> Range);
+  void remapDPValueRange(Module *M,
+                         iterator_range<simple_ilist<DPValue>::iterator> Range);
   void remapFunction(Function &F);
   void remapGlobalObjectMetadata(GlobalObject &GO);
 
@@ -268,15 +269,17 @@ inline void RemapInstruction(Instruction *I, ValueToValueMapTy &VM,
 
 /// Remap the Values used in the DPValue \a V using the value map \a VM.
 inline void RemapDPValue(Module *M, DPValue *V, ValueToValueMapTy &VM,
-                  RemapFlags Flags = RF_None,
-                  ValueMapTypeRemapper *TypeMapper = nullptr,
-                  ValueMaterializer *Materializer = nullptr) {
+                         RemapFlags Flags = RF_None,
+                         ValueMapTypeRemapper *TypeMapper = nullptr,
+                         ValueMaterializer *Materializer = nullptr) {
   ValueMapper(VM, Flags, TypeMapper, Materializer).remapDPValue(M, *V);
 }
 
 /// Remap the Values used in the DPValue \a V using the value map \a VM.
-inline void RemapDPValueRange(Module *M, iterator_range<simple_ilist<DPValue>::iterator> Range, ValueToValueMapTy &VM,
-                  RemapFlags Flags = RF_None,
+inline void
+RemapDPValueRange(Module *M,
+                  iterator_range<simple_ilist<DPValue>::iterator> Range,
+                  ValueToValueMapTy &VM, RemapFlags Flags = RF_None,
                   ValueMapTypeRemapper *TypeMapper = nullptr,
                   ValueMaterializer *Materializer = nullptr) {
   ValueMapper(VM, Flags, TypeMapper, Materializer).remapDPValueRange(M, Range);
diff --git a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
index 72465d0a1d..63f6367f3b 100644
--- a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
+++ b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
@@ -1263,7 +1263,8 @@ static BasicBlock *buildClonedLoopBlocks(
   Module *M = ClonedPH->getParent()->getParent();
   for (auto *ClonedBB : NewBlocks)
     for (Instruction &I : *ClonedBB) {
-      RemapDPValueRange(M, I.getDbgValueRange(), VMap, RF_NoModuleLevelChanges | RF_IgnoreMissingLocals);
+      RemapDPValueRange(M, I.getDbgValueRange(), 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/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index fda5d6a7f9..90f883ec81 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -1129,7 +1129,8 @@ static void CloneInstructionsIntoPredecessorBlockAndUpdateSSAUses(
     NewBonusInst->cloneDebugInfoFrom(&BonusInst);
 
     for (DPValue &DPV : NewBonusInst->getDbgValueRange())
-      RemapDPValue(NewBonusInst->getModule(), &DPV, VMap, RF_NoModuleLevelChanges | RF_IgnoreMissingLocals);
+      RemapDPValue(NewBonusInst->getModule(), &DPV, VMap,
+                   RF_NoModuleLevelChanges | RF_IgnoreMissingLocals);
 
     if (isa<DbgInfoIntrinsic>(BonusInst))
       continue;
@@ -3769,7 +3770,8 @@ static bool performBranchToCommonDestFolding(BranchInst *BI, BranchInst *PBI,
   if (PredBlock->IsNewDbgInfoFormat) {
     PredBlock->getTerminator()->cloneDebugInfoFrom(BB->getTerminator());
     for (DPValue &DPV : PredBlock->getTerminator()->getDbgValueRange()) {
-      RemapDPValue(M, &DPV, VMap, RF_NoModuleLevelChanges | RF_IgnoreMissingLocals);
+      RemapDPValue(M, &DPV, VMap,
+                   RF_NoModuleLevelChanges | RF_IgnoreMissingLocals);
     }
   }
 
diff --git a/llvm/lib/Transforms/Utils/ValueMapper.cpp b/llvm/lib/Transforms/Utils/ValueMapper.cpp
index 70dfffc5d1..4d7498ede5 100644
--- a/llvm/lib/Transforms/Utils/ValueMapper.cpp
+++ b/llvm/lib/Transforms/Utils/ValueMapper.cpp
@@ -546,7 +546,7 @@ void Mapper::remapDPValue(DPValue &V) {
 
   // Find Value operands and remap those.
   SmallVector<Value *, 4> Vals, NewVals;
-  for (Value *Val: V.location_ops())
+  for (Value *Val : V.location_ops())
     Vals.push_back(Val);
   for (Value *Val : Vals)
     NewVals.push_back(mapValue(Val));
@@ -559,7 +559,7 @@ void Mapper::remapDPValue(DPValue &V) {
 
   // Otherwise, do some replacement.
   if (!IgnoreMissingLocals &&
-      llvm::any_of(NewVals, [&](Value *V) { return V == nullptr;})) {
+      llvm::any_of(NewVals, [&](Value *V) { return V == nullptr; })) {
     V.setKillLocation();
   } else {
     for (unsigned int I = 0; I < Vals.size(); ++I)
@@ -1216,7 +1216,8 @@ void ValueMapper::remapDPValue(Module *M, DPValue &V) {
   FlushingMapper(pImpl)->remapDPValue(V);
 }
 
-void ValueMapper::remapDPValueRange(Module *M, iterator_range<DPValue::self_iterator> Range) {
+void ValueMapper::remapDPValueRange(
+    Module *M, iterator_range<DPValue::self_iterator> Range) {
   for (DPValue &DPV : Range) {
     remapDPValue(M, DPV);
   }

``````````

</details>


https://github.com/llvm/llvm-project/pull/72546


More information about the llvm-commits mailing list