Fix bug 3140.

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
This commit is contained in:
Rafael Espindola 2008-12-03 11:01:37 +00:00
parent 269bc0042f
commit 952b839ce9
6 changed files with 22 additions and 2 deletions

View 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

View 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);

View 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";

View 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 ";

View File

@ -85,6 +85,7 @@ void TargetAsmInfo::fillDefaultValues() {
COMMDirective = "\t.comm\t";
COMMDirectiveTakesAlignment = true;
HasDotTypeDotSizeDirective = true;
HasSingleParameterDotFile = true;
UsedDirective = 0;
WeakRefDirective = 0;
WeakDefDirective = 0;

View 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);