[PATCH] [LV][REFACTOR] One more tiny fix for printing debug locations in loop vectorizer. Now consistent with the remarks emitter.

Zinovy Nis zinovy.nis at gmail.com
Mon May 19 02:19:32 PDT 2014


Hi echristo, nadav, yaron.keren,

I refactored a bit a code for printing loop locations in the loop vectorizer. Now the location is taken from loop itself, not from it's first instruction.

http://reviews.llvm.org/D3821

Files:
  lib/Transforms/Vectorize/LoopVectorize.cpp

Index: lib/Transforms/Vectorize/LoopVectorize.cpp
===================================================================
--- lib/Transforms/Vectorize/LoopVectorize.cpp
+++ lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -477,18 +477,17 @@
 }
 
 #ifndef NDEBUG
-/// \return string containing a file name and a line # for the given
-/// instruction.
-static std::string getDebugLocString(const Instruction *I) {
+/// \return string containing a file name and a line # for the given loop.
+static std::string getDebugLocString(const Loop *L) {
   std::string Result;
-  if (I) {
+  if (L) {
     raw_string_ostream OS(Result);
-    const DebugLoc &InstrDebugLoc = I->getDebugLoc();
-    if (!InstrDebugLoc.isUnknown())
-      InstrDebugLoc.print(I->getContext(), OS);
+    const DebugLoc LoopDbgLoc = L->getStartLoc();
+    if (!LoopDbgLoc.isUnknown())
+      LoopDbgLoc.print(L->getHeader()->getContext(), OS);
     else
       // Just print the module name.
-      OS << I->getParent()->getParent()->getParent()->getModuleIdentifier();
+      OS << L->getHeader()->getParent()->getParent()->getModuleIdentifier();
     OS.flush();
   }
   return Result;
@@ -1107,8 +1106,7 @@
     assert(L->empty() && "Only process inner loops.");
 
 #ifndef NDEBUG
-    const std::string DebugLocStr =
-        getDebugLocString(L->getHeader()->getFirstNonPHIOrDbgOrLifetime());
+    const std::string DebugLocStr = getDebugLocString(L);
 #endif /* NDEBUG */
 
     DEBUG(dbgs() << "\nLV: Checking a loop in \""
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D3821.9526.patch
Type: text/x-patch
Size: 1491 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140519/7fb9271b/attachment.bin>


More information about the llvm-commits mailing list