From cbe96ddc5f952c02abf6109d313f7cf19e4f054e Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Wed, 15 Mar 2017 16:24:52 +0000 Subject: [PATCH] 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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297853 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 2 +- test/CodeGen/X86/file-source-filename.ll | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 test/CodeGen/X86/file-source-filename.ll diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index f02062b7377..fb6fa4df0b7 100644 --- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -267,7 +267,7 @@ bool AsmPrinter::doInitialization(Module &M) { // 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(); diff --git a/test/CodeGen/X86/file-source-filename.ll b/test/CodeGen/X86/file-source-filename.ll new file mode 100644 index 00000000000..146da9e16c9 --- /dev/null +++ b/test/CodeGen/X86/file-source-filename.ll @@ -0,0 +1,4 @@ +; RUN: llc -mtriple=x86_64-linux-gnu < %s | FileCheck %s +; CHECK: .file "foobar" + +source_filename = "foobar" -- 2.50.1