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

Eric Christopher echristo at gmail.com
Fri Apr 25 15:00:57 PDT 2014


For printing it out? Maybe. There's not a lot of times that we print
out the full path.

That said, putting it in sys::path wouldn't be terrible either :)

-eric

On Fri, Apr 25, 2014 at 2:57 PM, Nadav Rotem <nrotem at apple.com> wrote:
> I don’t think that the logic for getting the absolute path is not unique to the vectorizer. Can you place it in sys::path ?
>
> Thanks,
> Nadav
>
>
> On Apr 25, 2014, at 9:05 AM, Zinovy Nis <zinovy.nis at gmail.com> wrote:
>
>> 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
>>
>> http://reviews.llvm.org/D3513
>>
>> Files:
>>  lib/Transforms/Vectorize/LoopVectorize.cpp
>>
>> 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);
>> }
>> #endif
>> <D3513.8849.patch>
>




More information about the llvm-commits mailing list