22
22
#include " llvm/ADT/StringRef.h"
23
23
#include " llvm/ADT/StringSwitch.h"
24
24
#include " llvm/ADT/Twine.h"
25
- #include " llvm/BinaryFormat/Dwarf.h"
26
25
#include " llvm/DebugInfo/CodeView/SymbolRecord.h"
27
26
#include " llvm/MC/MCAsmInfo.h"
28
27
#include " llvm/MC/MCCodeView.h"
29
28
#include " llvm/MC/MCContext.h"
30
29
#include " llvm/MC/MCDirectives.h"
31
- #include " llvm/MC/MCDwarf.h"
32
30
#include " llvm/MC/MCExpr.h"
33
31
#include " llvm/MC/MCInstPrinter.h"
34
32
#include " llvm/MC/MCInstrDesc.h"
@@ -619,11 +617,6 @@ class MasmParser : public MCAsmParser {
619
617
bool lookUpField (const StructInfo &Structure, StringRef Member,
620
618
AsmFieldInfo &Info) const ;
621
619
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
-
627
620
// / Enter the specified file. This returns true on failure.
628
621
bool enterIncludeFile (const std::string &Filename);
629
622
@@ -657,8 +650,6 @@ class MasmParser : public MCAsmParser {
657
650
bool parseParenExpr (const MCExpr *&Res, SMLoc &EndLoc);
658
651
bool parseBracketExpr (const MCExpr *&Res, SMLoc &EndLoc);
659
652
660
- bool parseRegisterOrRegisterNumber (int64_t &Register, SMLoc DirectiveLoc);
661
-
662
653
// Generic (target and platform independent) directive parsing.
663
654
enum DirectiveKind {
664
655
DK_NO_DIRECTIVE, // Placeholder
@@ -1205,29 +1196,6 @@ const AsmToken MasmParser::peekTok(bool ShouldSkipSpace) {
1205
1196
return Tok;
1206
1197
}
1207
1198
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
-
1231
1199
bool MasmParser::Run (bool NoInitialTextSection, bool NoFinalize) {
1232
1200
// Create the initial section, if requested.
1233
1201
if (!NoInitialTextSection)
@@ -1240,22 +1208,6 @@ bool MasmParser::Run(bool NoInitialTextSection, bool NoFinalize) {
1240
1208
AsmCond StartingCondState = TheCondState;
1241
1209
SmallVector<AsmRewrite, 4 > AsmStrRewrites;
1242
1210
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
-
1259
1211
// While we have input, parse each statement.
1260
1212
while (Lexer.isNot (AsmToken::Eof) ||
1261
1213
SrcMgr.getParentIncludeLoc (CurBuffer) != SMLoc ()) {
@@ -1289,40 +1241,12 @@ bool MasmParser::Run(bool NoInitialTextSection, bool NoFinalize) {
1289
1241
if (TheCondState.TheCond != StartingCondState.TheCond ||
1290
1242
TheCondState.Ignore != StartingCondState.Ignore )
1291
1243
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
- }
1304
1244
1305
1245
// Check to see that all assembler local symbols were actually defined.
1306
1246
// Targets that don't do subsections via symbols may not want this, though,
1307
1247
// so conservatively exclude them. Only do this if we're finalizing, though,
1308
1248
// as otherwise we won't necessarily have seen everything yet.
1309
1249
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
-
1326
1250
// Temporary symbols like the ones for directional jumps don't go in the
1327
1251
// symbol table. They also need to be diagnosed in all (final) cases.
1328
1252
for (std::tuple<SMLoc, CppHashInfoTy, MCSymbol *> &LocSym : DirLabels) {
@@ -2121,20 +2045,9 @@ bool MasmParser::parseStatement(ParseStatementInfo &Info,
2121
2045
Lex ();
2122
2046
}
2123
2047
2124
- getTargetParser ().doBeforeLabelEmit (Sym, IDLoc);
2125
-
2126
2048
// Emit the label.
2127
2049
if (!getTargetParser ().isParsingMSInlineAsm ())
2128
2050
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
-
2138
2051
return false ;
2139
2052
}
2140
2053
@@ -2157,8 +2070,6 @@ bool MasmParser::parseStatement(ParseStatementInfo &Info,
2157
2070
// manner, or at least have a default behavior that's shared between
2158
2071
// all targets and platforms.
2159
2072
2160
- getTargetParser ().flushPendingInstructions (getStreamer ());
2161
-
2162
2073
// Special-case handling of structure-end directives at higher priority,
2163
2074
// since ENDS is overloaded as a segment-end directive.
2164
2075
if (IDVal.equals_insensitive (" ends" ) && StructInProgress.size () > 1 &&
@@ -2475,37 +2386,6 @@ bool MasmParser::parseStatement(ParseStatementInfo &Info,
2475
2386
if (hasPendingError () || ParseHadError)
2476
2387
return true ;
2477
2388
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
-
2509
2389
// If parsing succeeded, match the instruction.
2510
2390
if (!ParseHadError) {
2511
2391
uint64_t ErrorInfo;
@@ -4540,21 +4420,6 @@ bool MasmParser::parseDirectiveEven() {
4540
4420
return false ;
4541
4421
}
4542
4422
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
-
4558
4423
// / parseDirectiveMacro
4559
4424
// / ::= name macro [parameters]
4560
4425
// / ["LOCAL" identifiers]
0 commit comments