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

Anton Sidorenko via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 31 06:07:24 PDT 2022


asi-sc updated this revision to Diff 471982.
asi-sc added a comment.

Add a test


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D136937/new/

https://reviews.llvm.org/D136937

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


Index: llvm/test/CodeGen/AArch64/GlobalISel/store-merging-debug.mir
===================================================================
--- llvm/test/CodeGen/AArch64/GlobalISel/store-merging-debug.mir
+++ llvm/test/CodeGen/AArch64/GlobalISel/store-merging-debug.mir
@@ -127,7 +127,7 @@
     ; 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
Index: llvm/lib/CodeGen/GlobalISel/LoadStoreOpt.cpp
===================================================================
--- llvm/lib/CodeGen/GlobalISel/LoadStoreOpt.cpp
+++ llvm/lib/CodeGen/GlobalISel/LoadStoreOpt.cpp
@@ -355,10 +355,10 @@
       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);
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136937.471982.patch
Type: text/x-patch
Size: 2030 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221031/7c073e56/attachment.bin>


More information about the llvm-commits mailing list