Author: Chen Zheng Date: 2021-04-26T01:31:23-04:00 New Revision: 93a3592728ac1b55a7dd2a1d6abeeb8f9a54e2b6
URL: https://github.com/llvm/llvm-project/commit/93a3592728ac1b55a7dd2a1d6abeeb8f9a54e2b6 DIFF: https://github.com/llvm/llvm-project/commit/93a3592728ac1b55a7dd2a1d6abeeb8f9a54e2b6.diff LOG: file name - directory info Added: llvm/test/CodeGen/PowerPC/aix-filename-absolute-path.ll llvm/test/CodeGen/PowerPC/aix-filename-relative-path.ll Modified: llvm/include/llvm/MC/MCAsmInfo.h llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp llvm/lib/MC/MCAsmInfoXCOFF.cpp Removed: ################################################################################ diff --git a/llvm/include/llvm/MC/MCAsmInfo.h b/llvm/include/llvm/MC/MCAsmInfo.h index 250d219d100e4..b674af072ed55 100644 --- a/llvm/include/llvm/MC/MCAsmInfo.h +++ b/llvm/include/llvm/MC/MCAsmInfo.h @@ -341,6 +341,10 @@ class MCAsmInfo { /// argument and how it is interpreted. Defaults to NoAlignment. LCOMM::LCOMMType LCOMMDirectiveAlignmentType = LCOMM::NoAlignment; + /// True if the target only has basename for .file directive. False if the + /// target also needs the directory along with the basename. Default to true. + bool HasBasenameOnlyForFileDirective = true; + // True if the target allows .align directives on functions. This is true for // most targets, so defaults to true. bool HasFunctionAlignment = true; @@ -666,6 +670,9 @@ class MCAsmInfo { return LCOMMDirectiveAlignmentType; } + bool hasBasenameOnlyForFileDirective() const { + return HasBasenameOnlyForFileDirective; + } bool hasFunctionAlignment() const { return HasFunctionAlignment; } bool hasDotTypeDotSizeDirective() const { return HasDotTypeDotSizeDirective; } bool hasSingleParameterDotFile() const { return HasSingleParameterDotFile; } diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index eb7c7e2797d4e..869d83abd47dc 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -297,8 +297,11 @@ 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( - llvm::sys::path::filename(M.getSourceFileName())); + if (MAI->hasBasenameOnlyForFileDirective()) + OutStreamer->emitFileDirective( + llvm::sys::path::filename(M.getSourceFileName())); + else + OutStreamer->emitFileDirective(M.getSourceFileName()); } GCModuleInfo *MI = getAnalysisIfAvailable<GCModuleInfo>(); diff --git a/llvm/lib/MC/MCAsmInfoXCOFF.cpp b/llvm/lib/MC/MCAsmInfoXCOFF.cpp index a23a71b865b43..f90fc5a8f4983 100644 --- a/llvm/lib/MC/MCAsmInfoXCOFF.cpp +++ b/llvm/lib/MC/MCAsmInfoXCOFF.cpp @@ -19,6 +19,7 @@ void MCAsmInfoXCOFF::anchor() {} MCAsmInfoXCOFF::MCAsmInfoXCOFF() { IsLittleEndian = false; HasVisibilityOnlyWithLinkage = true; + HasBasenameOnlyForFileDirective = false; PrivateGlobalPrefix = "L.."; PrivateLabelPrefix = "L.."; SupportsQuotedNames = false; diff --git a/llvm/test/CodeGen/PowerPC/aix-filename-absolute-path.ll b/llvm/test/CodeGen/PowerPC/aix-filename-absolute-path.ll new file mode 100644 index 0000000000000..d5b6886ebcefe --- /dev/null +++ b/llvm/test/CodeGen/PowerPC/aix-filename-absolute-path.ll @@ -0,0 +1,8 @@ +; RUN: llc -verify-machineinstrs -mtriple powerpc-ibm-aix-xcoff < %s \ +; RUN: | FileCheck %s +; RUN: llc -verify-machineinstrs -mtriple powerpc64-ibm-aix-xcoff < %s \ +; RUN: | FileCheck %s + +; CHECK: .file "/absolute/path/to/file" + +source_filename = "/absolute/path/to/file" diff --git a/llvm/test/CodeGen/PowerPC/aix-filename-relative-path.ll b/llvm/test/CodeGen/PowerPC/aix-filename-relative-path.ll new file mode 100644 index 0000000000000..6df85c84d2678 --- /dev/null +++ b/llvm/test/CodeGen/PowerPC/aix-filename-relative-path.ll @@ -0,0 +1,8 @@ +; RUN: llc -verify-machineinstrs -mtriple powerpc-ibm-aix-xcoff < %s \ +; RUN: | FileCheck %s +; RUN: llc -verify-machineinstrs -mtriple powerpc64-ibm-aix-xcoff < %s \ +; RUN: | FileCheck %s + +; CHECK: .file "../relative/path/to/file" + +source_filename = "../relative/path/to/file" _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits