Skip to content

Commit b6d5fa0

Browse files
committed
[llvm-ml] Remove unused DWARF/Mach-O/ARM If-Then functions
1 parent 43c3014 commit b6d5fa0

File tree

1 file changed

+0
-135
lines changed

1 file changed

+0
-135
lines changed

llvm/lib/MC/MCParser/MasmParser.cpp

Lines changed: 0 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,11 @@
2222
#include "llvm/ADT/StringRef.h"
2323
#include "llvm/ADT/StringSwitch.h"
2424
#include "llvm/ADT/Twine.h"
25-
#include "llvm/BinaryFormat/Dwarf.h"
2625
#include "llvm/DebugInfo/CodeView/SymbolRecord.h"
2726
#include "llvm/MC/MCAsmInfo.h"
2827
#include "llvm/MC/MCCodeView.h"
2928
#include "llvm/MC/MCContext.h"
3029
#include "llvm/MC/MCDirectives.h"
31-
#include "llvm/MC/MCDwarf.h"
3230
#include "llvm/MC/MCExpr.h"
3331
#include "llvm/MC/MCInstPrinter.h"
3432
#include "llvm/MC/MCInstrDesc.h"
@@ -619,11 +617,6 @@ class MasmParser : public MCAsmParser {
619617
bool lookUpField(const StructInfo &Structure, StringRef Member,
620618
AsmFieldInfo &Info) const;
621619

622-
/// Should we emit DWARF describing this assembler source? (Returns false if
623-
/// the source has .file directives, which means we don't want to generate
624-
/// info describing the assembler source itself.)
625-
bool enabledGenDwarfForAssembly();
626-
627620
/// Enter the specified file. This returns true on failure.
628621
bool enterIncludeFile(const std::string &Filename);
629622

@@ -657,8 +650,6 @@ class MasmParser : public MCAsmParser {
657650
bool parseParenExpr(const MCExpr *&Res, SMLoc &EndLoc);
658651
bool parseBracketExpr(const MCExpr *&Res, SMLoc &EndLoc);
659652

660-
bool parseRegisterOrRegisterNumber(int64_t &Register, SMLoc DirectiveLoc);
661-
662653
// Generic (target and platform independent) directive parsing.
663654
enum DirectiveKind {
664655
DK_NO_DIRECTIVE, // Placeholder
@@ -1205,29 +1196,6 @@ const AsmToken MasmParser::peekTok(bool ShouldSkipSpace) {
12051196
return Tok;
12061197
}
12071198

1208-
bool MasmParser::enabledGenDwarfForAssembly() {
1209-
// Check whether the user specified -g.
1210-
if (!getContext().getGenDwarfForAssembly())
1211-
return false;
1212-
// If we haven't encountered any .file directives (which would imply that
1213-
// the assembler source was produced with debug info already) then emit one
1214-
// describing the assembler source file itself.
1215-
if (getContext().getGenDwarfFileNumber() == 0) {
1216-
// Use the first #line directive for this, if any. It's preprocessed, so
1217-
// there is no checksum, and of course no source directive.
1218-
if (!FirstCppHashFilename.empty())
1219-
getContext().setMCLineTableRootFile(
1220-
/*CUID=*/0, getContext().getCompilationDir(), FirstCppHashFilename,
1221-
/*Cksum=*/std::nullopt, /*Source=*/std::nullopt);
1222-
const MCDwarfFile &RootFile =
1223-
getContext().getMCDwarfLineTable(/*CUID=*/0).getRootFile();
1224-
getContext().setGenDwarfFileNumber(getStreamer().emitDwarfFileDirective(
1225-
/*CUID=*/0, getContext().getCompilationDir(), RootFile.Name,
1226-
RootFile.Checksum, RootFile.Source));
1227-
}
1228-
return true;
1229-
}
1230-
12311199
bool MasmParser::Run(bool NoInitialTextSection, bool NoFinalize) {
12321200
// Create the initial section, if requested.
12331201
if (!NoInitialTextSection)
@@ -1240,22 +1208,6 @@ bool MasmParser::Run(bool NoInitialTextSection, bool NoFinalize) {
12401208
AsmCond StartingCondState = TheCondState;
12411209
SmallVector<AsmRewrite, 4> AsmStrRewrites;
12421210

1243-
// If we are generating dwarf for assembly source files save the initial text
1244-
// section. (Don't use enabledGenDwarfForAssembly() here, as we aren't
1245-
// emitting any actual debug info yet and haven't had a chance to parse any
1246-
// embedded .file directives.)
1247-
if (getContext().getGenDwarfForAssembly()) {
1248-
MCSection *Sec = getStreamer().getCurrentSectionOnly();
1249-
if (!Sec->getBeginSymbol()) {
1250-
MCSymbol *SectionStartSym = getContext().createTempSymbol();
1251-
getStreamer().emitLabel(SectionStartSym);
1252-
Sec->setBeginSymbol(SectionStartSym);
1253-
}
1254-
bool InsertResult = getContext().addGenDwarfSection(Sec);
1255-
assert(InsertResult && ".text section should not have debug info yet");
1256-
(void)InsertResult;
1257-
}
1258-
12591211
// While we have input, parse each statement.
12601212
while (Lexer.isNot(AsmToken::Eof) ||
12611213
SrcMgr.getParentIncludeLoc(CurBuffer) != SMLoc()) {
@@ -1289,40 +1241,12 @@ bool MasmParser::Run(bool NoInitialTextSection, bool NoFinalize) {
12891241
if (TheCondState.TheCond != StartingCondState.TheCond ||
12901242
TheCondState.Ignore != StartingCondState.Ignore)
12911243
printError(getTok().getLoc(), "unmatched .ifs or .elses");
1292-
// Check to see there are no empty DwarfFile slots.
1293-
const auto &LineTables = getContext().getMCDwarfLineTables();
1294-
if (!LineTables.empty()) {
1295-
unsigned Index = 0;
1296-
for (const auto &File : LineTables.begin()->second.getMCDwarfFiles()) {
1297-
if (File.Name.empty() && Index != 0)
1298-
printError(getTok().getLoc(), "unassigned file number: " +
1299-
Twine(Index) +
1300-
" for .file directives");
1301-
++Index;
1302-
}
1303-
}
13041244

13051245
// Check to see that all assembler local symbols were actually defined.
13061246
// Targets that don't do subsections via symbols may not want this, though,
13071247
// so conservatively exclude them. Only do this if we're finalizing, though,
13081248
// as otherwise we won't necessarily have seen everything yet.
13091249
if (!NoFinalize) {
1310-
if (MAI.hasSubsectionsViaSymbols()) {
1311-
for (const auto &TableEntry : getContext().getSymbols()) {
1312-
MCSymbol *Sym = TableEntry.getValue().Symbol;
1313-
// Variable symbols may not be marked as defined, so check those
1314-
// explicitly. If we know it's a variable, we have a definition for
1315-
// the purposes of this check.
1316-
if (Sym && Sym->isTemporary() && !Sym->isVariable() &&
1317-
!Sym->isDefined())
1318-
// FIXME: We would really like to refer back to where the symbol was
1319-
// first referenced for a source location. We need to add something
1320-
// to track that. Currently, we just point to the end of the file.
1321-
printError(getTok().getLoc(), "assembler local symbol '" +
1322-
Sym->getName() + "' not defined");
1323-
}
1324-
}
1325-
13261250
// Temporary symbols like the ones for directional jumps don't go in the
13271251
// symbol table. They also need to be diagnosed in all (final) cases.
13281252
for (std::tuple<SMLoc, CppHashInfoTy, MCSymbol *> &LocSym : DirLabels) {
@@ -2121,20 +2045,9 @@ bool MasmParser::parseStatement(ParseStatementInfo &Info,
21212045
Lex();
21222046
}
21232047

2124-
getTargetParser().doBeforeLabelEmit(Sym, IDLoc);
2125-
21262048
// Emit the label.
21272049
if (!getTargetParser().isParsingMSInlineAsm())
21282050
Out.emitLabel(Sym, IDLoc);
2129-
2130-
// If we are generating dwarf for assembly source files then gather the
2131-
// info to make a dwarf label entry for this label if needed.
2132-
if (enabledGenDwarfForAssembly())
2133-
MCGenDwarfLabelEntry::Make(Sym, &getStreamer(), getSourceManager(),
2134-
IDLoc);
2135-
2136-
getTargetParser().onLabelParsed(Sym);
2137-
21382051
return false;
21392052
}
21402053

@@ -2157,8 +2070,6 @@ bool MasmParser::parseStatement(ParseStatementInfo &Info,
21572070
// manner, or at least have a default behavior that's shared between
21582071
// all targets and platforms.
21592072

2160-
getTargetParser().flushPendingInstructions(getStreamer());
2161-
21622073
// Special-case handling of structure-end directives at higher priority,
21632074
// since ENDS is overloaded as a segment-end directive.
21642075
if (IDVal.equals_insensitive("ends") && StructInProgress.size() > 1 &&
@@ -2475,37 +2386,6 @@ bool MasmParser::parseStatement(ParseStatementInfo &Info,
24752386
if (hasPendingError() || ParseHadError)
24762387
return true;
24772388

2478-
// If we are generating dwarf for the current section then generate a .loc
2479-
// directive for the instruction.
2480-
if (!ParseHadError && enabledGenDwarfForAssembly() &&
2481-
getContext().getGenDwarfSectionSyms().count(
2482-
getStreamer().getCurrentSectionOnly())) {
2483-
unsigned Line;
2484-
if (ActiveMacros.empty())
2485-
Line = SrcMgr.FindLineNumber(IDLoc, CurBuffer);
2486-
else
2487-
Line = SrcMgr.FindLineNumber(ActiveMacros.front()->InstantiationLoc,
2488-
ActiveMacros.front()->ExitBuffer);
2489-
2490-
// If we previously parsed a cpp hash file line comment then make sure the
2491-
// current Dwarf File is for the CppHashFilename if not then emit the
2492-
// Dwarf File table for it and adjust the line number for the .loc.
2493-
if (!CppHashInfo.Filename.empty()) {
2494-
unsigned FileNumber = getStreamer().emitDwarfFileDirective(
2495-
0, StringRef(), CppHashInfo.Filename);
2496-
getContext().setGenDwarfFileNumber(FileNumber);
2497-
2498-
unsigned CppHashLocLineNo =
2499-
SrcMgr.FindLineNumber(CppHashInfo.Loc, CppHashInfo.Buf);
2500-
Line = CppHashInfo.LineNumber - 1 + (Line - CppHashLocLineNo);
2501-
}
2502-
2503-
getStreamer().emitDwarfLocDirective(
2504-
getContext().getGenDwarfFileNumber(), Line, 0,
2505-
DWARF2_LINE_DEFAULT_IS_STMT ? DWARF2_FLAG_IS_STMT : 0, 0, 0,
2506-
StringRef());
2507-
}
2508-
25092389
// If parsing succeeded, match the instruction.
25102390
if (!ParseHadError) {
25112391
uint64_t ErrorInfo;
@@ -4540,21 +4420,6 @@ bool MasmParser::parseDirectiveEven() {
45404420
return false;
45414421
}
45424422

4543-
/// parse register name or number.
4544-
bool MasmParser::parseRegisterOrRegisterNumber(int64_t &Register,
4545-
SMLoc DirectiveLoc) {
4546-
MCRegister RegNo;
4547-
4548-
if (getLexer().isNot(AsmToken::Integer)) {
4549-
if (getTargetParser().parseRegister(RegNo, DirectiveLoc, DirectiveLoc))
4550-
return true;
4551-
Register = getContext().getRegisterInfo()->getDwarfRegNum(RegNo, true);
4552-
} else
4553-
return parseAbsoluteExpression(Register);
4554-
4555-
return false;
4556-
}
4557-
45584423
/// parseDirectiveMacro
45594424
/// ::= name macro [parameters]
45604425
/// ["LOCAL" identifiers]

0 commit comments

Comments
 (0)