Fix bug 3140.
authorRafael Espindola <rafael.espindola@gmail.com>
Wed, 3 Dec 2008 11:01:37 +0000 (11:01 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Wed, 3 Dec 2008 11:01:37 +0000 (11:01 +0000)
Print a single parameter .file directive if we have an ELF target.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60480 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Target/TargetAsmInfo.h
lib/CodeGen/AsmPrinter/AsmPrinter.cpp
lib/Target/ARM/ARMTargetAsmInfo.cpp
lib/Target/PowerPC/PPCTargetAsmInfo.cpp
lib/Target/TargetAsmInfo.cpp
lib/Target/X86/X86TargetAsmInfo.cpp

index 44c9e55d3e861bf30b6e811e0705da401ede1941..3c71dc8d1d6a1a85e26aca47fa6bcd43074c74ed 100644 (file)
@@ -390,7 +390,11 @@ namespace llvm {
     /// HasDotTypeDotSizeDirective - True if the target has .type and .size
     /// directives, this is true for most ELF targets.
     bool HasDotTypeDotSizeDirective;      // Defaults to true.
-    
+
+    /// HasSingleParameterDotFile - True if the target has a single parameter
+    /// .file directive, this is true for ELF targets.
+    bool HasSingleParameterDotFile;      // Defaults to true.
+
     /// UsedDirective - This directive, if non-null, is used to declare a global
     /// as being used somehow that the assembler can't see.  This prevents dead
     /// code elimination on some targets.
@@ -765,6 +769,9 @@ namespace llvm {
     bool hasDotTypeDotSizeDirective() const {
       return HasDotTypeDotSizeDirective;
     }
+    bool hasSingleParameterDotFile() const {
+      return HasSingleParameterDotFile;
+    }
     const char *getUsedDirective() const {
       return UsedDirective;
     }
@@ -856,4 +863,3 @@ namespace llvm {
 }
 
 #endif
-
index bfc2e35cf363d3633bdfab9a2cd6de09eb522e7f..b640a589badac6ff06c3aaa84d8692ab410271ce 100644 (file)
@@ -142,6 +142,14 @@ bool AsmPrinter::doInitialization(Module &M) {
   
   GCModuleInfo *MI = getAnalysisToUpdate<GCModuleInfo>();
   assert(MI && "AsmPrinter didn't require GCModuleInfo?");
+
+  if (TAI->hasSingleParameterDotFile()) {
+    /* Very minimal debug info. It is ignored if we emit actual
+       debug info. If we don't, this at helps the user find where
+       a function came from. */
+    O << "\t.file\t\"" << M.getModuleIdentifier() << "\"\n";
+  }
+
   for (GCModuleInfo::iterator I = MI->begin(), E = MI->end(); I != E; ++I)
     if (GCMetadataPrinter *MP = GetOrCreateGCPrinter(*I))
       MP->beginAssembly(O, *this, *TAI);
index aae3712fb130e7ac4f142ca2f8f53c13ff2cd5a7..e0c81d61cbd24ece5e563fa2a9912238b7a85242 100644 (file)
@@ -61,6 +61,7 @@ ARMDarwinTargetAsmInfo::ARMDarwinTargetAsmInfo(const ARMTargetMachine &TM):
   JumpTableDataSection = ".const";
   CStringSection = "\t.cstring";
   HasDotTypeDotSizeDirective = false;
+  HasSingleParameterDotFile = false;
   NeedsIndirectEncoding = true;
   if (TM.getRelocationModel() == Reloc::Static) {
     StaticCtorsSection = ".constructor";
index f8642b2a44ac2e49de4730b43fd9f5bd0842252a..4151064c6a1289634d3f7e2ba4f1235a8c23b3e3 100644 (file)
@@ -37,6 +37,7 @@ PPCDarwinTargetAsmInfo::PPCDarwinTargetAsmInfo(const PPCTargetMachine &TM):
     StaticCtorsSection = ".mod_init_func";
     StaticDtorsSection = ".mod_term_func";
   }
+  HasSingleParameterDotFile = false;
   SwitchToSectionDirective = "\t.section ";
   UsedDirective = "\t.no_dead_strip\t";
   WeakDefDirective = "\t.weak_definition ";
index a124922e6cbdb4931bb7f5689718fbed16589986..d79652ac5666c8473a9a34c4d38de05a8ad1b9f6 100644 (file)
@@ -85,6 +85,7 @@ void TargetAsmInfo::fillDefaultValues() {
   COMMDirective = "\t.comm\t";
   COMMDirectiveTakesAlignment = true;
   HasDotTypeDotSizeDirective = true;
+  HasSingleParameterDotFile = true;
   UsedDirective = 0;
   WeakRefDirective = 0;
   WeakDefDirective = 0;
index abb05260cbac6e0243158ada3d1ba0495b744868..feff9307be9345859cc904fd2d747155e6f6ceea 100644 (file)
@@ -69,6 +69,7 @@ X86DarwinTargetAsmInfo::X86DarwinTargetAsmInfo(const X86TargetMachine &TM):
   // Leopard and above support aligned common symbols.
   COMMDirectiveTakesAlignment = (Subtarget->getDarwinVers() >= 9);
   HasDotTypeDotSizeDirective = false;
+  HasSingleParameterDotFile = false;
   if (TM.getRelocationModel() == Reloc::Static) {
     StaticCtorsSection = ".constructor";
     StaticDtorsSection = ".destructor";
@@ -221,6 +222,7 @@ X86COFFTargetAsmInfo::X86COFFTargetAsmInfo(const X86TargetMachine &TM):
   LCOMMDirective = "\t.lcomm\t";
   COMMDirectiveTakesAlignment = false;
   HasDotTypeDotSizeDirective = false;
+  HasSingleParameterDotFile = false;
   StaticCtorsSection = "\t.section .ctors,\"aw\"";
   StaticDtorsSection = "\t.section .dtors,\"aw\"";
   HiddenDirective = NULL;
@@ -335,6 +337,7 @@ X86WinTargetAsmInfo::X86WinTargetAsmInfo(const X86TargetMachine &TM):
   Data32bitsDirective = "\tdd\t";
   Data64bitsDirective = "\tdq\t";
   HasDotTypeDotSizeDirective = false;
+  HasSingleParameterDotFile = false;
 
   TextSection = getUnnamedSection("_text", SectionFlags::Code);
   DataSection = getUnnamedSection("_data", SectionFlags::Writeable);