[PATCH] [LV][BUG] Tiny fix for printing debug locations for absolute paths.

Zinovy Nis zinovy.nis at gmail.com
Fri Apr 25 09:05:15 PDT 2014

Hi echristo, nadav,

If a loop was defined in a file referenced by an absolute path (for ex. STL header from the system dir), then DEBUG print would print module dir and then that absolute path, which is wrong. 

  LV: Checking a loop in "Foo" from /home/myhome//usr/lib/gcc/z42_128-greencap-linux/1.2.3/../../../../include/c++/9.8.7/bits/list.tcc:171

The correct behavior is to just print the absolute path and skip module dir.

  LV: Checking a loop in "Foo" from /usr/lib/gcc/z42_128-greencap-linux/1.2.3/../../../../include/c++/9.8.7/bits/list.tcc:171



Index: lib/Transforms/Vectorize/LoopVectorize.cpp
--- lib/Transforms/Vectorize/LoopVectorize.cpp
+++ lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -84,6 +84,7 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/Format.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Target/TargetLibraryInfo.h"
 #include "llvm/Transforms/Scalar.h"
@@ -493,8 +494,12 @@
   const DILocation Loc(N);
   const unsigned LineNo = Loc.getLineNumber();
-  const char *DirName = Loc.getDirectory().data();
   const char *FileName = Loc.getFilename().data();
+  // Absolute path doesn't need DirName.
+  if (sys::path::is_absolute(FileName))
+    return format<const char *, const char *, unsigned>("%s%s:%u", "", FileName,
+                                                        LineNo);
+  const char *DirName = Loc.getDirectory().data();
   return format("%s/%s:%u", DirName, FileName, LineNo);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D3513.8849.patch
Type: text/x-patch
Size: 1045 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140425/d3c1e8e9/attachment.bin>

More information about the llvm-commits mailing list