[llvm] r297853 - CodeGen: Use the source filename as the argument to .file, rather than the module ID.

Peter Collingbourne via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 15 09:24:52 PDT 2017


Author: pcc
Date: Wed Mar 15 11:24:52 2017
New Revision: 297853

URL: http://llvm.org/viewvc/llvm-project?rev=297853&view=rev
Log:
CodeGen: Use the source filename as the argument to .file, rather than the module ID.

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.

Differential Revision: https://reviews.llvm.org/D30584

Added:
    llvm/trunk/test/CodeGen/X86/file-source-filename.ll
Modified:
    llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=297853&r1=297852&r2=297853&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Wed Mar 15 11:24:52 2017
@@ -267,7 +267,7 @@ bool AsmPrinter::doInitialization(Module
   // 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>();

Added: llvm/trunk/test/CodeGen/X86/file-source-filename.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/file-source-filename.ll?rev=297853&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/file-source-filename.ll (added)
+++ llvm/trunk/test/CodeGen/X86/file-source-filename.ll Wed Mar 15 11:24:52 2017
@@ -0,0 +1,4 @@
+; RUN: llc -mtriple=x86_64-linux-gnu < %s | FileCheck %s
+; CHECK: .file "foobar"
+
+source_filename = "foobar"




More information about the llvm-commits mailing list