[llvm] 92ec614 - [GlobalISel] Compute debug location when merging stores more accurately

Anton Sidorenko via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 1 04:36:46 PDT 2022


Author: Anton Sidorenko
Date: 2022-11-01T14:32:42+03:00
New Revision: 92ec61498831550b0e1231c2150e686cdf2fc125

URL: https://github.com/llvm/llvm-project/commit/92ec61498831550b0e1231c2150e686cdf2fc125
DIFF: https://github.com/llvm/llvm-project/commit/92ec61498831550b0e1231c2150e686cdf2fc125.diff

LOG: [GlobalISel] Compute debug location when merging stores more accurately

Originaly the loop did almost nothing as the calculated location was
overwritten on the next iteration.

Differential Revision: https://reviews.llvm.org/D136937

Added: 
    

Modified: 
    llvm/lib/CodeGen/GlobalISel/LoadStoreOpt.cpp
    llvm/test/CodeGen/AArch64/GlobalISel/store-merging-debug.mir

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/GlobalISel/LoadStoreOpt.cpp b/llvm/lib/CodeGen/GlobalISel/LoadStoreOpt.cpp
index be1bc865d1e17..f5fa5fe6fe6e2 100644
--- a/llvm/lib/CodeGen/GlobalISel/LoadStoreOpt.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/LoadStoreOpt.cpp
@@ -355,10 +355,10 @@ bool LoadStoreOpt::doSingleStoreMerge(SmallVectorImpl<GStore *> &Stores) {
       LLT::scalar(NumStores * SmallTy.getSizeInBits().getFixedSize());
 
   // For each store, compute pairwise merged debug locs.
-  DebugLoc MergedLoc;
-  for (unsigned AIdx = 0, BIdx = 1; BIdx < NumStores; ++AIdx, ++BIdx)
-    MergedLoc = DILocation::getMergedLocation(Stores[AIdx]->getDebugLoc(),
-                                              Stores[BIdx]->getDebugLoc());
+  DebugLoc MergedLoc = Stores.front()->getDebugLoc();
+  for (auto *Store : drop_begin(Stores))
+    MergedLoc = DILocation::getMergedLocation(MergedLoc, Store->getDebugLoc());
+
   Builder.setInstr(*Stores.back());
   Builder.setDebugLoc(MergedLoc);
 

diff  --git a/llvm/test/CodeGen/AArch64/GlobalISel/store-merging-debug.mir b/llvm/test/CodeGen/AArch64/GlobalISel/store-merging-debug.mir
index f95f41dcba0a8..200281f3e54f5 100644
--- a/llvm/test/CodeGen/AArch64/GlobalISel/store-merging-debug.mir
+++ b/llvm/test/CodeGen/AArch64/GlobalISel/store-merging-debug.mir
@@ -127,7 +127,7 @@ body:             |
     ; CHECK-NEXT: [[PTR_ADD2:%[0-9]+]]:_(p0) = G_PTR_ADD [[COPY]], [[C6]](s64), debug-location !DILocation(line: 14, column: 1, scope: !5)
     ; CHECK-NEXT: DBG_VALUE [[PTR_ADD2]](p0), $noreg, !9, !DIExpression(), debug-location !DILocation(line: 14, column: 1, scope: !5)
     ; CHECK-NEXT: [[C7:%[0-9]+]]:_(s64) = G_CONSTANT i64 3940688328982532
-    ; CHECK-NEXT: G_STORE [[C7]](s64), [[COPY]](p0), debug-location !DILocation(line: 9, column: 4, scope: !5) :: (store (s64), align 2)
+    ; CHECK-NEXT: G_STORE [[C7]](s64), [[COPY]](p0), debug-location !DILocation(line: 9, scope: !5) :: (store (s64), align 2)
     ; CHECK-NEXT: DBG_VALUE 3, $noreg, !9, !DIExpression(), debug-location !DILocation(line: 15, column: 1, scope: !5)
     ; CHECK-NEXT: RET_ReallyLR debug-location !DILocation(line: 16, column: 1, scope: !5)
     %0:_(p0) = COPY $x0, debug-location !11


        


More information about the llvm-commits mailing list