diff options
author | Paul Robinson <paul.robinson@sony.com> | 2018-03-09 00:11:54 +0000 |
---|---|---|
committer | Paul Robinson <paul.robinson@sony.com> | 2018-03-09 00:11:54 +0000 |
commit | b45fd5673421135214c214872728f5d08dc16224 (patch) | |
tree | 7dc07e3f569a172055160a14612bcb0ffe82ad69 /llvm/lib/MC/MCParser/AsmParser.cpp | |
parent | d5453b2c3f72e27f0cefe3003252f49462a419f9 (diff) | |
download | bcm5719-llvm-b45fd5673421135214c214872728f5d08dc16224.tar.gz bcm5719-llvm-b45fd5673421135214c214872728f5d08dc16224.zip |
Revert "[DWARF] Fix mixing assembler -g with DWARF .file directives."
This reverts commit d6d9ac1ab5039ba1fe0f63c36eac2bdd9f0a79c9.
aka r327073
llvm-svn: 327083
Diffstat (limited to 'llvm/lib/MC/MCParser/AsmParser.cpp')
-rw-r--r-- | llvm/lib/MC/MCParser/AsmParser.cpp | 43 |
1 files changed, 14 insertions, 29 deletions
diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp index daf01ead13a..54a76732bbe 100644 --- a/llvm/lib/MC/MCParser/AsmParser.cpp +++ b/llvm/lib/MC/MCParser/AsmParser.cpp @@ -311,11 +311,6 @@ private: } static void DiagHandler(const SMDiagnostic &Diag, void *Context); - /// Should we emit DWARF describing this assembler source? (Returns false if - /// the source has .file directives, which means we don't want to generate - /// info describing the assembler source itself.) - bool enabledGenDwarfForAssembly(); - /// \brief Enter the specified file. This returns true on failure. bool enterIncludeFile(const std::string &Filename); @@ -829,19 +824,6 @@ const AsmToken &AsmParser::Lex() { return *tok; } -bool AsmParser::enabledGenDwarfForAssembly() { - // Check whether the user specified -g. - if (!getContext().getGenDwarfForAssembly()) - return false; - // If we haven't encountered any .file directives (which would imply that - // the assembler source was produced with debug info already) then emit one - // describing the assembler source file itself. - if (getContext().getGenDwarfFileNumber() == 0) - getContext().setGenDwarfFileNumber(getStreamer().EmitDwarfFileDirective( - 0, StringRef(), getContext().getMainFileName())); - return true; -} - bool AsmParser::Run(bool NoInitialTextSection, bool NoFinalize) { // Create the initial section, if requested. if (!NoInitialTextSection) @@ -855,9 +837,7 @@ bool AsmParser::Run(bool NoInitialTextSection, bool NoFinalize) { SmallVector<AsmRewrite, 4> AsmStrRewrites; // If we are generating dwarf for assembly source files save the initial text - // section. (Don't use enabledGenDwarfForAssembly() here, as we aren't - // emitting any actual debug info yet and haven't had a chance to parse any - // embedded .file directives.) + // section and generate a .file directive. if (getContext().getGenDwarfForAssembly()) { MCSection *Sec = getStreamer().getCurrentSectionOnly(); if (!Sec->getBeginSymbol()) { @@ -868,6 +848,8 @@ bool AsmParser::Run(bool NoInitialTextSection, bool NoFinalize) { bool InsertResult = getContext().addGenDwarfSection(Sec); assert(InsertResult && ".text section should not have debug info yet"); (void)InsertResult; + getContext().setGenDwarfFileNumber(getStreamer().EmitDwarfFileDirective( + 0, StringRef(), getContext().getMainFileName())); } // While we have input, parse each statement. @@ -1802,7 +1784,7 @@ bool AsmParser::parseStatement(ParseStatementInfo &Info, // If we are generating dwarf for assembly source files then gather the // info to make a dwarf label entry for this label if needed. - if (enabledGenDwarfForAssembly()) + if (getContext().getGenDwarfForAssembly()) MCGenDwarfLabelEntry::Make(Sym, &getStreamer(), getSourceManager(), IDLoc); @@ -2171,7 +2153,7 @@ bool AsmParser::parseStatement(ParseStatementInfo &Info, // If we are generating dwarf for the current section then generate a .loc // directive for the instruction. - if (!ParseHadError && enabledGenDwarfForAssembly() && + if (!ParseHadError && getContext().getGenDwarfForAssembly() && getContext().getGenDwarfSectionSyms().count( getStreamer().getCurrentSectionOnly())) { unsigned Line; @@ -3354,12 +3336,15 @@ bool AsmParser::parseDirectiveFile(SMLoc DirectiveLoc) { } // If there is -g option as well as debug info from directive file, // we turn off -g option, directly use the existing debug info instead. - getContext().setGenDwarfForAssembly(false); - Expected<unsigned> FileNumOrErr = getStreamer().tryEmitDwarfFileDirective( - FileNumber, Directory, Filename, CKMem, Source); - if (!FileNumOrErr) - return Error(DirectiveLoc, toString(FileNumOrErr.takeError())); - FileNumber = FileNumOrErr.get(); + if (getContext().getGenDwarfForAssembly()) + getContext().setGenDwarfForAssembly(false); + else { + Expected<unsigned> FileNumOrErr = getStreamer().tryEmitDwarfFileDirective( + FileNumber, Directory, Filename, CKMem, Source); + if (!FileNumOrErr) + return Error(DirectiveLoc, toString(FileNumOrErr.takeError())); + FileNumber = FileNumOrErr.get(); + } } return false; |