[llvm] 927913f - [RemoveDIs] Fix remapping of DbgLabelRecords. (#91447)

via llvm-commits llvm-commits at lists.llvm.org
Wed May 8 03:33:50 PDT 2024


Author: Harald van Dijk
Date: 2024-05-08T11:33:47+01:00
New Revision: 927913fac74b671b5202eb00a52907d8445c7691

URL: https://github.com/llvm/llvm-project/commit/927913fac74b671b5202eb00a52907d8445c7691
DIFF: https://github.com/llvm/llvm-project/commit/927913fac74b671b5202eb00a52907d8445c7691.diff

LOG: [RemoveDIs] Fix remapping of DbgLabelRecords. (#91447)

We already remapped DILocations for DbgVariableRecords, but
DbgLabelRecords have debug locations too that need to be mapped the same
way.

Added: 
    

Modified: 
    llvm/lib/Transforms/Utils/ValueMapper.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Utils/ValueMapper.cpp b/llvm/lib/Transforms/Utils/ValueMapper.cpp
index 6ebdd85d37b43..1c877ee937fbf 100644
--- a/llvm/lib/Transforms/Utils/ValueMapper.cpp
+++ b/llvm/lib/Transforms/Utils/ValueMapper.cpp
@@ -538,17 +538,20 @@ Value *Mapper::mapValue(const Value *V) {
 }
 
 void Mapper::remapDbgRecord(DbgRecord &DR) {
+  // Remap DILocations.
+  auto *MappedDILoc = mapMetadata(DR.getDebugLoc());
+  DR.setDebugLoc(DebugLoc(cast<DILocation>(MappedDILoc)));
+
   if (DbgLabelRecord *DLR = dyn_cast<DbgLabelRecord>(&DR)) {
+    // Remap labels.
     DLR->setLabel(cast<DILabel>(mapMetadata(DLR->getLabel())));
     return;
   }
 
   DbgVariableRecord &V = cast<DbgVariableRecord>(DR);
-  // Remap variables and DILocations.
+  // Remap variables.
   auto *MappedVar = mapMetadata(V.getVariable());
-  auto *MappedDILoc = mapMetadata(V.getDebugLoc());
   V.setVariable(cast<DILocalVariable>(MappedVar));
-  V.setDebugLoc(DebugLoc(cast<DILocation>(MappedDILoc)));
 
   bool IgnoreMissingLocals = Flags & RF_IgnoreMissingLocals;
 


        


More information about the llvm-commits mailing list