[PATCH] D30584: CodeGen: Use the source filename as the argument to .file, rather than the module ID.

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 15 05:04:57 PDT 2017


I think this is fine.

LGTM


Peter Collingbourne via Phabricator via llvm-commits
<llvm-commits at lists.llvm.org> writes:

> pcc created this revision.
>
> Using the module ID here is wrong for a couple of reasons:
>
> 1. The module ID is not persisted, so we can end up with different object file contents given the same input file (for example if the same file is accessed via different paths).
> 2. With ThinLTO the module ID field may contain the path to a bitcode file, which is incorrect, as the .file argument is supposed to contain the path to a source file.
>
>
> https://reviews.llvm.org/D30584
>
> Files:
>   llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
>   llvm/test/CodeGen/X86/file-source-filename.ll
>
>
> Index: llvm/test/CodeGen/X86/file-source-filename.ll
> ===================================================================
> --- /dev/null
> +++ llvm/test/CodeGen/X86/file-source-filename.ll
> @@ -0,0 +1,4 @@
> +; RUN: llc -march=x86-64 < %s | FileCheck %s
> +; CHECK: .file "foobar"
> +
> +source_filename = "foobar"
> Index: llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
> ===================================================================
> --- llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
> +++ llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
> @@ -267,7 +267,7 @@
>    // don't, this at least helps the user find where a global came from.
>    if (MAI->hasSingleParameterDotFile()) {
>      // .file "foo.c"
> -    OutStreamer->EmitFileDirective(M.getModuleIdentifier());
> +    OutStreamer->EmitFileDirective(M.getSourceFileName());
>    }
>  
>    GCModuleInfo *MI = getAnalysisIfAvailable<GCModuleInfo>();
>
>
> Index: llvm/test/CodeGen/X86/file-source-filename.ll
> ===================================================================
> --- /dev/null
> +++ llvm/test/CodeGen/X86/file-source-filename.ll
> @@ -0,0 +1,4 @@
> +; RUN: llc -march=x86-64 < %s | FileCheck %s
> +; CHECK: .file "foobar"
> +
> +source_filename = "foobar"
> Index: llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
> ===================================================================
> --- llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
> +++ llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
> @@ -267,7 +267,7 @@
>    // don't, this at least helps the user find where a global came from.
>    if (MAI->hasSingleParameterDotFile()) {
>      // .file "foo.c"
> -    OutStreamer->EmitFileDirective(M.getModuleIdentifier());
> +    OutStreamer->EmitFileDirective(M.getSourceFileName());
>    }
>  
>    GCModuleInfo *MI = getAnalysisIfAvailable<GCModuleInfo>();
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


More information about the llvm-commits mailing list