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

Anton Sidorenko via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 28 03:28:49 PDT 2022


asi-sc created this revision.
Herald added subscribers: hiraditya, rovka.
Herald added a project: All.
asi-sc requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136937

Files:
  llvm/lib/CodeGen/GlobalISel/LoadStoreOpt.cpp


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.471476.patch
Type: text/x-patch
Size: 873 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221028/0d26bcdc/attachment.bin>


More information about the llvm-commits mailing list