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

Eric Christopher echristo at gmail.com
Mon Apr 28 10:41:50 PDT 2014


Zinovy,

I think Nadav is saying that the code to concatenate paths like this
could be factored out somewhere. Probably true, not sure that
sys::path is the best place, and we don't have a lot of namespaces.
Nadav, can you elaborate here a bit more?

-eric

On Sun, Apr 27, 2014 at 4:26 AM, Zinovy Nis <zinovy.nis at gmail.com> wrote:
> Nadav, I did not add any additional logic for sys::path in fact. I just used
> sys::path::is_absolute() method for my lcal purpose:
>
> if (sys::path::is_absolute(FileName))
>
> So I don't see anything to add to sys::path.
>
>
> 2014-04-26 1:57 GMT+04:00 Nadav Rotem <nrotem at apple.com>:
>
>> 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