diff options
author | Reid Kleckner <rnk@google.com> | 2016-08-26 17:58:37 +0000 |
---|---|---|
committer | Reid Kleckner <rnk@google.com> | 2016-08-26 17:58:37 +0000 |
commit | a5b1eef846e86010f82cff3d812dfd3fb3b99405 (patch) | |
tree | e4a033d53e4d252e662b9eba6face61cb8b0afcd /llvm/lib | |
parent | 8e8fa788214642200b0524a930122d40285e573f (diff) | |
download | bcm5719-llvm-a5b1eef846e86010f82cff3d812dfd3fb3b99405.tar.gz bcm5719-llvm-a5b1eef846e86010f82cff3d812dfd3fb3b99405.zip |
[MC] Move .cv_loc management logic out of MCContext
MCContext already has many tasks, and separating CodeView out from it is
probably a good idea. The .cv_loc tracking was modelled on the DWARF
tracking which lived directly in MCContext.
Removes the inclusion of MCCodeView.h from MCContext.h, so now there are
only 10 build actions while I hack on CodeView support instead of 265.
llvm-svn: 279847
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp | 5 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp | 1 | ||||
-rw-r--r-- | llvm/lib/CodeGen/MIRParser/MIParser.cpp | 1 | ||||
-rw-r--r-- | llvm/lib/MC/MCAsmStreamer.cpp | 15 | ||||
-rw-r--r-- | llvm/lib/MC/MCCodeView.cpp | 9 | ||||
-rw-r--r-- | llvm/lib/MC/MCContext.cpp | 8 | ||||
-rw-r--r-- | llvm/lib/MC/MCFragment.cpp | 1 | ||||
-rw-r--r-- | llvm/lib/MC/MCObjectStreamer.cpp | 1 | ||||
-rw-r--r-- | llvm/lib/MC/MCParser/AsmParser.cpp | 9 | ||||
-rw-r--r-- | llvm/lib/MC/MCStreamer.cpp | 9 | ||||
-rw-r--r-- | llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp | 1 | ||||
-rw-r--r-- | llvm/lib/Target/AMDGPU/MCTargetDesc/SIMCCodeEmitter.cpp | 1 |
12 files changed, 32 insertions, 29 deletions
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; |