summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/MC/MCCodeView.h30
-rw-r--r--llvm/include/llvm/MC/MCContext.h34
-rw-r--r--llvm/include/llvm/MC/MCStreamer.h5
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp5
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp1
-rw-r--r--llvm/lib/CodeGen/MIRParser/MIParser.cpp1
-rw-r--r--llvm/lib/MC/MCAsmStreamer.cpp15
-rw-r--r--llvm/lib/MC/MCCodeView.cpp9
-rw-r--r--llvm/lib/MC/MCContext.cpp8
-rw-r--r--llvm/lib/MC/MCFragment.cpp1
-rw-r--r--llvm/lib/MC/MCObjectStreamer.cpp1
-rw-r--r--llvm/lib/MC/MCParser/AsmParser.cpp9
-rw-r--r--llvm/lib/MC/MCStreamer.cpp9
-rw-r--r--llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp1
-rw-r--r--llvm/lib/Target/AMDGPU/MCTargetDesc/SIMCCodeEmitter.cpp1
15 files changed, 63 insertions, 67 deletions
diff --git a/llvm/include/llvm/MC/MCCodeView.h b/llvm/include/llvm/MC/MCCodeView.h
index d999ff55599..9f881faa492 100644
--- a/llvm/include/llvm/MC/MCCodeView.h
+++ b/llvm/include/llvm/MC/MCCodeView.h
@@ -25,6 +25,7 @@ namespace llvm {
class MCContext;
class MCObjectStreamer;
class MCStreamer;
+class CodeViewContext;
/// \brief Instances of this class represent the information from a
/// .cv_loc directive.
@@ -36,8 +37,8 @@ class MCCVLoc {
uint16_t PrologueEnd : 1;
uint16_t IsStmt : 1;
-private: // MCContext manages these
- friend class MCContext;
+private: // CodeViewContext manages these
+ friend class CodeViewContext;
MCCVLoc(unsigned functionid, unsigned fileNum, unsigned line, unsigned column,
bool prologueend, bool isstmt)
: FunctionId(functionid), FileNum(fileNum), Line(line), Column(column),
@@ -114,6 +115,27 @@ public:
bool addFile(unsigned FileNumber, StringRef Filename);
ArrayRef<StringRef> getFilenames() { return Filenames; }
+ /// Saves the information from the currently parsed .cv_loc directive
+ /// and sets CVLocSeen. When the next instruction is assembled an entry
+ /// in the line number table with this information and the address of the
+ /// instruction will be created.
+ void setCurrentCVLoc(unsigned FunctionId, unsigned FileNo, unsigned Line,
+ unsigned Column, bool PrologueEnd, bool IsStmt) {
+ CurrentCVLoc.setFunctionId(FunctionId);
+ CurrentCVLoc.setFileNum(FileNo);
+ CurrentCVLoc.setLine(Line);
+ CurrentCVLoc.setColumn(Column);
+ CurrentCVLoc.setPrologueEnd(PrologueEnd);
+ CurrentCVLoc.setIsStmt(IsStmt);
+ CVLocSeen = true;
+ }
+ void clearCVLocSeen() { CVLocSeen = false; }
+
+ bool getCVLocSeen() { return CVLocSeen; }
+ const MCCVLoc &getCurrentCVLoc() { return CurrentCVLoc; }
+
+ bool isValidCVFileNumber(unsigned FileNumber);
+
/// \brief Add a line entry.
void addLineEntry(const MCCVLineEntry &LineEntry) {
size_t Offset = MCCVLines.size();
@@ -180,6 +202,10 @@ public:
void emitFileChecksums(MCObjectStreamer &OS);
private:
+ /// The current CodeView line information from the last .cv_loc directive.
+ MCCVLoc CurrentCVLoc = MCCVLoc(0, 0, 0, 0, false, true);
+ bool CVLocSeen = false;
+
/// Map from string to string table offset.
StringMap<unsigned> StringTable;
diff --git a/llvm/include/llvm/MC/MCContext.h b/llvm/include/llvm/MC/MCContext.h
index fe1377e054e..6f6cd96af56 100644
--- a/llvm/include/llvm/MC/MCContext.h
+++ b/llvm/include/llvm/MC/MCContext.h
@@ -16,7 +16,6 @@
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/Twine.h"
-#include "llvm/MC/MCCodeView.h"
#include "llvm/MC/MCDwarf.h"
#include "llvm/MC/MCSubtargetInfo.h"
#include "llvm/MC/SectionKind.h"
@@ -141,10 +140,6 @@ namespace llvm {
MCDwarfLoc CurrentDwarfLoc;
bool DwarfLocSeen;
- /// The current CodeView line information from the last .cv_loc directive.
- MCCVLoc CurrentCVLoc = MCCVLoc(0, 0, 0, 0, false, true);
- bool CVLocSeen = false;
-
/// Generate dwarf debugging info for assembly source files.
bool GenDwarfForAssembly;
@@ -534,35 +529,6 @@ namespace llvm {
/// @}
-
- /// \name CodeView Management
- /// @{
-
- /// Creates an entry in the cv file table.
- unsigned getCVFile(StringRef FileName, unsigned FileNumber);
-
- /// Saves the information from the currently parsed .cv_loc directive
- /// and sets CVLocSeen. When the next instruction is assembled an entry
- /// in the line number table with this information and the address of the
- /// instruction will be created.
- void setCurrentCVLoc(unsigned FunctionId, unsigned FileNo, unsigned Line,
- unsigned Column, bool PrologueEnd, bool IsStmt) {
- CurrentCVLoc.setFunctionId(FunctionId);
- CurrentCVLoc.setFileNum(FileNo);
- CurrentCVLoc.setLine(Line);
- CurrentCVLoc.setColumn(Column);
- CurrentCVLoc.setPrologueEnd(PrologueEnd);
- CurrentCVLoc.setIsStmt(IsStmt);
- CVLocSeen = true;
- }
- void clearCVLocSeen() { CVLocSeen = false; }
-
- bool getCVLocSeen() { return CVLocSeen; }
- const MCCVLoc &getCurrentCVLoc() { return CurrentCVLoc; }
-
- bool isValidCVFileNumber(unsigned FileNumber);
- /// @}
-
char *getSecureLogFile() { return SecureLogFile; }
raw_fd_ostream *getSecureLog() { return SecureLog.get(); }
bool getSecureLogUsed() { return SecureLogUsed; }
diff --git a/llvm/include/llvm/MC/MCStreamer.h b/llvm/include/llvm/MC/MCStreamer.h
index 8863639b059..e5025400671 100644
--- a/llvm/include/llvm/MC/MCStreamer.h
+++ b/llvm/include/llvm/MC/MCStreamer.h
@@ -709,8 +709,9 @@ public:
StringRef FileName);
/// \brief Associate a filename with a specified logical file number. This
- /// implements the '.cv_file 4 "foo.c"' assembler directive.
- virtual unsigned EmitCVFileDirective(unsigned FileNo, StringRef Filename);
+ /// implements the '.cv_file 4 "foo.c"' assembler directive. Returns true on
+ /// success.
+ virtual bool EmitCVFileDirective(unsigned FileNo, StringRef Filename);
/// \brief This implements the CodeView '.cv_loc' assembler directive.
virtual void EmitCVLocDirective(unsigned FunctionId, unsigned FileNo,
diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
index 52d7b45d37b..9e5b8c59b60 100644
--- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -111,8 +111,9 @@ unsigned CodeViewDebug::maybeRecordFile(const DIFile *F) {
if (Insertion.second) {
// We have to compute the full filepath and emit a .cv_file directive.
StringRef FullPath = getFullFilepath(F);
- NextId = OS.EmitCVFileDirective(NextId, FullPath);
- assert(NextId == FileIdMap.size() && ".cv_file directive failed");
+ bool Success = OS.EmitCVFileDirective(NextId, FullPath);
+ (void)Success;
+ assert(Success && ".cv_file directive failed");
}
return Insertion.first->second;
}
diff --git a/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp b/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
index 16ffe2e15ac..357d67fa2e5 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
@@ -18,6 +18,7 @@
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineModuleInfo.h"
#include "llvm/IR/DebugInfo.h"
+#include "llvm/MC/MCStreamer.h"
#include "llvm/Target/TargetSubtargetInfo.h"
using namespace llvm;
diff --git a/llvm/lib/CodeGen/MIRParser/MIParser.cpp b/llvm/lib/CodeGen/MIRParser/MIParser.cpp
index 858c8ebc8e1..91943ea36ac 100644
--- a/llvm/lib/CodeGen/MIRParser/MIParser.cpp
+++ b/llvm/lib/CodeGen/MIRParser/MIParser.cpp
@@ -14,6 +14,7 @@
#include "MIParser.h"
#include "MILexer.h"
#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringSwitch.h"
#include "llvm/AsmParser/Parser.h"
#include "llvm/AsmParser/SlotMapping.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
diff --git a/llvm/lib/MC/MCAsmStreamer.cpp b/llvm/lib/MC/MCAsmStreamer.cpp
index c471229f39d..07adfc413d9 100644
--- a/llvm/lib/MC/MCAsmStreamer.cpp
+++ b/llvm/lib/MC/MCAsmStreamer.cpp
@@ -14,6 +14,7 @@
#include "llvm/MC/MCAsmBackend.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCCodeEmitter.h"
+#include "llvm/MC/MCCodeView.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCFixupKindInfo.h"
@@ -220,7 +221,7 @@ public:
StringRef FileName) override;
MCSymbol *getDwarfLineTableSymbol(unsigned CUID) override;
- unsigned EmitCVFileDirective(unsigned FileNo, StringRef Filename) override;
+ bool EmitCVFileDirective(unsigned FileNo, StringRef Filename) override;
void EmitCVLocDirective(unsigned FunctionId, unsigned FileNo, unsigned Line,
unsigned Column, bool PrologueEnd, bool IsStmt,
StringRef FileName) override;
@@ -1102,17 +1103,15 @@ MCSymbol *MCAsmStreamer::getDwarfLineTableSymbol(unsigned CUID) {
return MCStreamer::getDwarfLineTableSymbol(0);
}
-unsigned MCAsmStreamer::EmitCVFileDirective(unsigned FileNo,
- StringRef Filename) {
- if (!getContext().getCVFile(Filename, FileNo))
- return 0;
+bool MCAsmStreamer::EmitCVFileDirective(unsigned FileNo, StringRef Filename) {
+ if (!getContext().getCVContext().addFile(FileNo, Filename))
+ return false;
OS << "\t.cv_file\t" << FileNo << ' ';
PrintQuotedString(Filename, OS);
EmitEOL();
-
- return FileNo;
+ return true;
}
void MCAsmStreamer::EmitCVLocDirective(unsigned FunctionId, unsigned FileNo,
@@ -1124,7 +1123,7 @@ void MCAsmStreamer::EmitCVLocDirective(unsigned FunctionId, unsigned FileNo,
if (PrologueEnd)
OS << " prologue_end";
- unsigned OldIsStmt = getContext().getCurrentCVLoc().isStmt();
+ unsigned OldIsStmt = getContext().getCVContext().getCurrentCVLoc().isStmt();
if (IsStmt != OldIsStmt) {
OS << " is_stmt ";
diff --git a/llvm/lib/MC/MCCodeView.cpp b/llvm/lib/MC/MCCodeView.cpp
index 65cff41abeb..b955511a4a7 100644
--- a/llvm/lib/MC/MCCodeView.cpp
+++ b/llvm/lib/MC/MCCodeView.cpp
@@ -442,7 +442,8 @@ void CodeViewContext::encodeDefRange(MCAsmLayout &Layout,
// a line entry made for it is made.
//
void MCCVLineEntry::Make(MCObjectStreamer *MCOS) {
- if (!MCOS->getContext().getCVLocSeen())
+ CodeViewContext &CVC = MCOS->getContext().getCVContext();
+ if (!CVC.getCVLocSeen())
return;
// Create a symbol at in the current section for use in the line entry.
@@ -451,14 +452,14 @@ void MCCVLineEntry::Make(MCObjectStreamer *MCOS) {
MCOS->EmitLabel(LineSym);
// Get the current .loc info saved in the context.
- const MCCVLoc &CVLoc = MCOS->getContext().getCurrentCVLoc();
+ const MCCVLoc &CVLoc = CVC.getCurrentCVLoc();
// Create a (local) line entry with the symbol and the current .loc info.
MCCVLineEntry LineEntry(LineSym, CVLoc);
// clear CVLocSeen saying the current .loc info is now used.
- MCOS->getContext().clearCVLocSeen();
+ CVC.clearCVLocSeen();
// Add the line entry to this section's entries.
- MCOS->getContext().getCVContext().addLineEntry(LineEntry);
+ CVC.addLineEntry(LineEntry);
}
diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp
index 47ed1ca3add..f95087f67b2 100644
--- a/llvm/lib/MC/MCContext.cpp
+++ b/llvm/lib/MC/MCContext.cpp
@@ -494,14 +494,6 @@ CodeViewContext &MCContext::getCVContext() {
return *CVContext.get();
}
-unsigned MCContext::getCVFile(StringRef FileName, unsigned FileNumber) {
- return getCVContext().addFile(FileNumber, FileName) ? FileNumber : 0;
-}
-
-bool MCContext::isValidCVFileNumber(unsigned FileNumber) {
- return getCVContext().isValidFileNumber(FileNumber);
-}
-
//===----------------------------------------------------------------------===//
// Error Reporting
//===----------------------------------------------------------------------===//
diff --git a/llvm/lib/MC/MCFragment.cpp b/llvm/lib/MC/MCFragment.cpp
index 638d9103336..e2c4b22688d 100644
--- a/llvm/lib/MC/MCFragment.cpp
+++ b/llvm/lib/MC/MCFragment.cpp
@@ -10,6 +10,7 @@
#include "llvm/MC/MCFragment.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/Twine.h"
+#include "llvm/MC/MCAssembler.h"
#include "llvm/MC/MCAsmBackend.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCAsmLayout.h"
diff --git a/llvm/lib/MC/MCObjectStreamer.cpp b/llvm/lib/MC/MCObjectStreamer.cpp
index 54fb13f6918..e86a0e1dcf9 100644
--- a/llvm/lib/MC/MCObjectStreamer.cpp
+++ b/llvm/lib/MC/MCObjectStreamer.cpp
@@ -13,6 +13,7 @@
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCAssembler.h"
#include "llvm/MC/MCCodeEmitter.h"
+#include "llvm/MC/MCCodeView.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCDwarf.h"
#include "llvm/MC/MCExpr.h"
diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp
index 83c845274d8..deacfbbb6d5 100644
--- a/llvm/lib/MC/MCParser/AsmParser.cpp
+++ b/llvm/lib/MC/MCParser/AsmParser.cpp
@@ -22,6 +22,7 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/MC/MCAsmInfo.h"
+#include "llvm/MC/MCCodeView.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCDirectives.h"
#include "llvm/MC/MCDwarf.h"
@@ -234,6 +235,8 @@ public:
MCContext &getContext() override { return Ctx; }
MCStreamer &getStreamer() override { return Out; }
+ CodeViewContext &getCVContext() { return Ctx.getCVContext(); }
+
unsigned getAssemblerDialect() override {
if (AssemblerDialect == ~0U)
return MAI.getAssemblerDialect();
@@ -3274,9 +3277,9 @@ bool AsmParser::parseDirectiveCVFile() {
parseEscapedString(Filename) ||
parseToken(AsmToken::EndOfStatement,
"unexpected token in '.cv_file' directive"))
- return true;
+ return true;
- if (getStreamer().EmitCVFileDirective(FileNumber, Filename) == 0)
+ if (!getStreamer().EmitCVFileDirective(FileNumber, Filename))
Error(FileNumberLoc, "file number already allocated");
return false;
@@ -3300,7 +3303,7 @@ bool AsmParser::parseDirectiveCVLoc() {
parseIntToken(FileNumber, "expected integer in '.cv_loc' directive") ||
check(FileNumber < 1, Loc,
"file number less than one in '.cv_loc' directive") ||
- check(!getContext().isValidCVFileNumber(FileNumber), Loc,
+ check(!getCVContext().isValidFileNumber(FileNumber), Loc,
"unassigned file number in '.cv_loc' directive"))
return true;
diff --git a/llvm/lib/MC/MCStreamer.cpp b/llvm/lib/MC/MCStreamer.cpp
index cfe25f9299c..ca244126dcd 100644
--- a/llvm/lib/MC/MCStreamer.cpp
+++ b/llvm/lib/MC/MCStreamer.cpp
@@ -12,6 +12,7 @@
#include "llvm/ADT/Twine.h"
#include "llvm/MC/MCAsmBackend.h"
#include "llvm/MC/MCAsmInfo.h"
+#include "llvm/MC/MCCodeView.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCInst.h"
@@ -215,16 +216,16 @@ void MCStreamer::EnsureValidDwarfFrame() {
report_fatal_error("No open frame");
}
-unsigned MCStreamer::EmitCVFileDirective(unsigned FileNo, StringRef Filename) {
- return getContext().getCVFile(Filename, FileNo);
+bool MCStreamer::EmitCVFileDirective(unsigned FileNo, StringRef Filename) {
+ return getContext().getCVContext().addFile(FileNo, Filename);
}
void MCStreamer::EmitCVLocDirective(unsigned FunctionId, unsigned FileNo,
unsigned Line, unsigned Column,
bool PrologueEnd, bool IsStmt,
StringRef FileName) {
- getContext().setCurrentCVLoc(FunctionId, FileNo, Line, Column, PrologueEnd,
- IsStmt);
+ getContext().getCVContext().setCurrentCVLoc(FunctionId, FileNo, Line, Column,
+ PrologueEnd, IsStmt);
}
void MCStreamer::EmitCVLinetableDirective(unsigned FunctionId,
diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
index b777a3e05be..1384043d30e 100644
--- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
+++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
@@ -11,6 +11,7 @@
#include "AArch64RegisterInfo.h"
#include "MCTargetDesc/AArch64FixupKinds.h"
#include "llvm/ADT/Triple.h"
+#include "llvm/MC/MCAssembler.h"
#include "llvm/MC/MCAsmBackend.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCDirectives.h"
diff --git a/llvm/lib/Target/AMDGPU/MCTargetDesc/SIMCCodeEmitter.cpp b/llvm/lib/Target/AMDGPU/MCTargetDesc/SIMCCodeEmitter.cpp
index 71b585c25ac..ab7c830bd4f 100644
--- a/llvm/lib/Target/AMDGPU/MCTargetDesc/SIMCCodeEmitter.cpp
+++ b/llvm/lib/Target/AMDGPU/MCTargetDesc/SIMCCodeEmitter.cpp
@@ -25,6 +25,7 @@
#include "llvm/MC/MCInstrInfo.h"
#include "llvm/MC/MCRegisterInfo.h"
#include "llvm/MC/MCSubtargetInfo.h"
+#include "llvm/MC/MCSymbol.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
OpenPOWER on IntegriCloud