<div dir="ltr">ThinLTO uses the source filename to compute GUIDs for globals, so this change will increase the likelihood of GUID collisions.<div><br></div><div>My understanding is that there are still known correctness bugs associated with GUID collisions. Maybe Mehdi or Teresa know what the current status is.</div><div><div><div><br></div><div>Peter</div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Aug 9, 2017 at 5:44 PM, Rafael Avila de Espindola <span dir="ltr"><<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I think this is fine as I now see that there are other uses of<br>
source_filename and it is not clear that they all want just the file<br>
name itself.<br>
<br>
Peter, what do you think?<br>
<span class="im HOEnZb"><br>
Cheers,<br>
Rafael<br>
<br>
Taewook Oh via Phabricator via llvm-commits<br>
<<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> writes:<br>
<br>
</span><div class="HOEnZb"><div class="h5">> twoh created this revision.<br>
><br>
> Currently LLVM puts directory along with the filename in .file directive, but this behavior doesn't match gcc. There's a no clear description about which one is right (<a href="https://sourceware.org/binutils/docs/as/File.html#File" rel="noreferrer" target="_blank">https://sourceware.org/<wbr>binutils/docs/as/File.html#<wbr>File</a>), but one document (<a href="https://sourceware.org/gdb/current/onlinedocs/stabs/ELF-Linker-Relocation.html" rel="noreferrer" target="_blank">https://sourceware.org/gdb/<wbr>current/onlinedocs/stabs/ELF-<wbr>Linker-Relocation.html</a>) suggests that STT_FILE symbol in elf file is expected to have basename only, which should have a same sting file .file directive according to (<a href="https://docs.oracle.com/cd/E26502_01/html/E28388/eoiyg.html" rel="noreferrer" target="_blank">https://docs.oracle.com/cd/<wbr>E26502_01/html/E28388/eoiyg.<wbr>html</a>).<br>
><br>
> This also affects badly on the build system that uses hashing, as the directory info could be differnt from developer to developer even when they're working on same file.<br>
><br>
><br>
> <a href="https://reviews.llvm.org/D36018" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D36018</a><br>
><br>
> Files:<br>
>   lib/CodeGen/AsmPrinter/<wbr>AsmPrinter.cpp<br>
>   test/CodeGen/X86/file-<wbr>directive.ll<br>
><br>
><br>
> Index: test/CodeGen/X86/file-<wbr>directive.ll<br>
> ==============================<wbr>==============================<wbr>=======<br>
> --- /dev/null<br>
> +++ test/CodeGen/X86/file-<wbr>directive.ll<br>
> @@ -0,0 +1,14 @@<br>
> +; RUN: llc -mtriple=x86_64-linux-gnu -filetype=asm < %s | FileCheck %s --check-prefix=DIRECTIVE<br>
> +; RUN: llc -mtriple=x86_64-linux-gnu -filetype=obj < %s | llvm-readobj -symbols | FileCheck %s --check-prefix=STT-FILE<br>
> +<br>
> +; DIRECTIVE: .file "foobar"<br>
> +; STT-FILE: Name: foobar<br>
> +; STT-FILE-NEXT: Value: 0x0<br>
> +; STT-FILE-NEXT: Size: 0<br>
> +; STT-FILE-NEXT: Binding: Local<br>
> +; STT-FILE-NEXT: Type: File<br>
> +; STT-FILE-NEXT: Other: 0<br>
> +; STT-FILE-NEXT: Section: Absolute<br>
> +; STT-FILE-NOT: Name:<br>
> +<br>
> +source_filename = "/path/to/foobar"<br>
> Index: lib/CodeGen/AsmPrinter/<wbr>AsmPrinter.cpp<br>
> ==============================<wbr>==============================<wbr>=======<br>
> --- lib/CodeGen/AsmPrinter/<wbr>AsmPrinter.cpp<br>
> +++ lib/CodeGen/AsmPrinter/<wbr>AsmPrinter.cpp<br>
> @@ -87,6 +87,7 @@<br>
>  #include "llvm/Support/ErrorHandling.h"<br>
>  #include "llvm/Support/Format.h"<br>
>  #include "llvm/Support/MathExtras.h"<br>
> +#include "llvm/Support/Path.h"<br>
>  #include "llvm/Support/TargetRegistry.<wbr>h"<br>
>  #include "llvm/Support/Timer.h"<br>
>  #include "llvm/Support/raw_ostream.h"<br>
> @@ -272,7 +273,8 @@<br>
>    // don't, this at least helps the user find where a global came from.<br>
>    if (MAI-><wbr>hasSingleParameterDotFile()) {<br>
>      // .file "foo.c"<br>
> -    OutStreamer-><wbr>EmitFileDirective(M.<wbr>getSourceFileName());<br>
> +    OutStreamer-><wbr>EmitFileDirective(<br>
> +        llvm::sys::path::filename(M.<wbr>getSourceFileName()));<br>
>    }<br>
><br>
>    GCModuleInfo *MI = getAnalysisIfAvailable<<wbr>GCModuleInfo>();<br>
><br>
><br>
> Index: test/CodeGen/X86/file-<wbr>directive.ll<br>
> ==============================<wbr>==============================<wbr>=======<br>
> --- /dev/null<br>
> +++ test/CodeGen/X86/file-<wbr>directive.ll<br>
> @@ -0,0 +1,14 @@<br>
> +; RUN: llc -mtriple=x86_64-linux-gnu -filetype=asm < %s | FileCheck %s --check-prefix=DIRECTIVE<br>
> +; RUN: llc -mtriple=x86_64-linux-gnu -filetype=obj < %s | llvm-readobj -symbols | FileCheck %s --check-prefix=STT-FILE<br>
> +<br>
> +; DIRECTIVE: .file "foobar"<br>
> +; STT-FILE: Name: foobar<br>
> +; STT-FILE-NEXT: Value: 0x0<br>
> +; STT-FILE-NEXT: Size: 0<br>
> +; STT-FILE-NEXT: Binding: Local<br>
> +; STT-FILE-NEXT: Type: File<br>
> +; STT-FILE-NEXT: Other: 0<br>
> +; STT-FILE-NEXT: Section: Absolute<br>
> +; STT-FILE-NOT: Name:<br>
> +<br>
> +source_filename = "/path/to/foobar"<br>
> Index: lib/CodeGen/AsmPrinter/<wbr>AsmPrinter.cpp<br>
> ==============================<wbr>==============================<wbr>=======<br>
> --- lib/CodeGen/AsmPrinter/<wbr>AsmPrinter.cpp<br>
> +++ lib/CodeGen/AsmPrinter/<wbr>AsmPrinter.cpp<br>
> @@ -87,6 +87,7 @@<br>
>  #include "llvm/Support/ErrorHandling.h"<br>
>  #include "llvm/Support/Format.h"<br>
>  #include "llvm/Support/MathExtras.h"<br>
> +#include "llvm/Support/Path.h"<br>
>  #include "llvm/Support/TargetRegistry.<wbr>h"<br>
>  #include "llvm/Support/Timer.h"<br>
>  #include "llvm/Support/raw_ostream.h"<br>
> @@ -272,7 +273,8 @@<br>
>    // don't, this at least helps the user find where a global came from.<br>
>    if (MAI-><wbr>hasSingleParameterDotFile()) {<br>
>      // .file "foo.c"<br>
> -    OutStreamer-><wbr>EmitFileDirective(M.<wbr>getSourceFileName());<br>
> +    OutStreamer-><wbr>EmitFileDirective(<br>
> +        llvm::sys::path::filename(M.<wbr>getSourceFileName()));<br>
>    }<br>
><br>
>    GCModuleInfo *MI = getAnalysisIfAvailable<<wbr>GCModuleInfo>();<br>
</div></div><div class="HOEnZb"><div class="h5">> ______________________________<wbr>_________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-commits</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">-- <div>Peter</div></div></div>
</div>