diff options
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/AsmPrinterHandler.h | 74 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h | 4 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.h | 87 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.h | 138 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h | 2 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h | 4 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/EHStreamer.h | 2 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/WinCFGuard.h | 2 |
11 files changed, 10 insertions, 309 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 66473466a83..7070451e333 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -12,7 +12,6 @@ //===----------------------------------------------------------------------===// #include "llvm/CodeGen/AsmPrinter.h" -#include "AsmPrinterHandler.h" #include "CodeViewDebug.h" #include "DwarfDebug.h" #include "DwarfException.h" @@ -36,6 +35,7 @@ #include "llvm/BinaryFormat/COFF.h" #include "llvm/BinaryFormat/Dwarf.h" #include "llvm/BinaryFormat/ELF.h" +#include "llvm/CodeGen/AsmPrinterHandler.h" #include "llvm/CodeGen/GCMetadata.h" #include "llvm/CodeGen/GCMetadataPrinter.h" #include "llvm/CodeGen/GCStrategy.h" diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinterHandler.h b/llvm/lib/CodeGen/AsmPrinter/AsmPrinterHandler.h deleted file mode 100644 index f5ac95a20b1..00000000000 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinterHandler.h +++ /dev/null @@ -1,74 +0,0 @@ -//===-- lib/CodeGen/AsmPrinter/AsmPrinterHandler.h -------------*- C++ -*--===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file contains a generic interface for AsmPrinter handlers, -// like debug and EH info emitters. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_LIB_CODEGEN_ASMPRINTER_ASMPRINTERHANDLER_H -#define LLVM_LIB_CODEGEN_ASMPRINTER_ASMPRINTERHANDLER_H - -#include "llvm/Support/DataTypes.h" - -namespace llvm { - -class AsmPrinter; -class MachineBasicBlock; -class MachineFunction; -class MachineInstr; -class MCSymbol; - -typedef MCSymbol *ExceptionSymbolProvider(AsmPrinter *Asm); - -/// Collects and handles AsmPrinter objects required to build debug -/// or EH information. -class AsmPrinterHandler { -public: - virtual ~AsmPrinterHandler(); - - /// For symbols that have a size designated (e.g. common symbols), - /// this tracks that size. - virtual void setSymbolSize(const MCSymbol *Sym, uint64_t Size) = 0; - - /// Emit all sections that should come after the content. - virtual void endModule() = 0; - - /// Gather pre-function debug information. - /// Every beginFunction(MF) call should be followed by an endFunction(MF) - /// call. - virtual void beginFunction(const MachineFunction *MF) = 0; - - // Emit any of function marker (like .cfi_endproc). This is called - // before endFunction and cannot switch sections. - virtual void markFunctionEnd(); - - /// Gather post-function debug information. - /// Please note that some AsmPrinter implementations may not call - /// beginFunction at all. - virtual void endFunction(const MachineFunction *MF) = 0; - - virtual void beginFragment(const MachineBasicBlock *MBB, - ExceptionSymbolProvider ESP) {} - virtual void endFragment() {} - - /// Emit target-specific EH funclet machinery. - virtual void beginFunclet(const MachineBasicBlock &MBB, - MCSymbol *Sym = nullptr) {} - virtual void endFunclet() {} - - /// Process beginning of an instruction. - virtual void beginInstruction(const MachineInstr *MI) = 0; - - /// Process end of an instruction. - virtual void endInstruction() = 0; -}; -} // End of namespace llvm - -#endif diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h index 49fba173b20..fcc7c3290eb 100644 --- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h +++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h @@ -14,14 +14,14 @@ #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_CODEVIEWDEBUG_H #define LLVM_LIB_CODEGEN_ASMPRINTER_CODEVIEWDEBUG_H -#include "DbgEntityHistoryCalculator.h" -#include "DebugHandlerBase.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/MapVector.h" #include "llvm/ADT/SetVector.h" #include "llvm/ADT/SmallVector.h" +#include "llvm/CodeGen/DbgEntityHistoryCalculator.h" +#include "llvm/CodeGen/DebugHandlerBase.h" #include "llvm/DebugInfo/CodeView/CodeView.h" #include "llvm/DebugInfo/CodeView/GlobalTypeTableBuilder.h" #include "llvm/DebugInfo/CodeView/TypeIndex.h" diff --git a/llvm/lib/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.cpp b/llvm/lib/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.cpp index bb2fa7d9c72..09867822c30 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include "DbgEntityHistoryCalculator.h" +#include "llvm/CodeGen/DbgEntityHistoryCalculator.h" #include "llvm/ADT/BitVector.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallVector.h" diff --git a/llvm/lib/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.h b/llvm/lib/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.h deleted file mode 100644 index 660d2ff551b..00000000000 --- a/llvm/lib/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.h +++ /dev/null @@ -1,87 +0,0 @@ -//===- llvm/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.h -----*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DBGVALUEHISTORYCALCULATOR_H -#define LLVM_LIB_CODEGEN_ASMPRINTER_DBGVALUEHISTORYCALCULATOR_H - -#include "llvm/ADT/MapVector.h" -#include "llvm/ADT/SmallVector.h" -#include "llvm/IR/DebugInfoMetadata.h" -#include <utility> - -namespace llvm { - -class DILocalVariable; -class MachineFunction; -class MachineInstr; -class TargetRegisterInfo; - -// For each user variable, keep a list of instruction ranges where this variable -// is accessible. The variables are listed in order of appearance. -class DbgValueHistoryMap { - // Each instruction range starts with a DBG_VALUE instruction, specifying the - // location of a variable, which is assumed to be valid until the end of the - // range. If end is not specified, location is valid until the start - // instruction of the next instruction range, or until the end of the - // function. -public: - using InstrRange = std::pair<const MachineInstr *, const MachineInstr *>; - using InstrRanges = SmallVector<InstrRange, 4>; - using InlinedEntity = std::pair<const DINode *, const DILocation *>; - using InstrRangesMap = MapVector<InlinedEntity, InstrRanges>; - -private: - InstrRangesMap VarInstrRanges; - -public: - void startInstrRange(InlinedEntity Var, const MachineInstr &MI); - void endInstrRange(InlinedEntity Var, const MachineInstr &MI); - - // Returns register currently describing @Var. If @Var is currently - // unaccessible or is not described by a register, returns 0. - unsigned getRegisterForVar(InlinedEntity Var) const; - - bool empty() const { return VarInstrRanges.empty(); } - void clear() { VarInstrRanges.clear(); } - InstrRangesMap::const_iterator begin() const { return VarInstrRanges.begin(); } - InstrRangesMap::const_iterator end() const { return VarInstrRanges.end(); } - -#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) - LLVM_DUMP_METHOD void dump() const; -#endif -}; - -/// For each inlined instance of a source-level label, keep the corresponding -/// DBG_LABEL instruction. The DBG_LABEL instruction could be used to generate -/// a temporary (assembler) label before it. -class DbgLabelInstrMap { -public: - using InlinedEntity = std::pair<const DINode *, const DILocation *>; - using InstrMap = MapVector<InlinedEntity, const MachineInstr *>; - -private: - InstrMap LabelInstr; - -public: - void addInstr(InlinedEntity Label, const MachineInstr &MI); - - bool empty() const { return LabelInstr.empty(); } - void clear() { LabelInstr.clear(); } - InstrMap::const_iterator begin() const { return LabelInstr.begin(); } - InstrMap::const_iterator end() const { return LabelInstr.end(); } -}; - -void calculateDbgEntityHistory(const MachineFunction *MF, - const TargetRegisterInfo *TRI, - DbgValueHistoryMap &DbgValues, - DbgLabelInstrMap &DbgLabels); - -} // end namespace llvm - -#endif // LLVM_LIB_CODEGEN_ASMPRINTER_DBGVALUEHISTORYCALCULATOR_H diff --git a/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp b/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp index a362dd40e3b..551cd36d198 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp @@ -12,7 +12,7 @@ // //===----------------------------------------------------------------------===// -#include "DebugHandlerBase.h" +#include "llvm/CodeGen/DebugHandlerBase.h" #include "llvm/ADT/Optional.h" #include "llvm/ADT/Twine.h" #include "llvm/CodeGen/AsmPrinter.h" diff --git a/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.h b/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.h deleted file mode 100644 index cdf8dc72b07..00000000000 --- a/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.h +++ /dev/null @@ -1,138 +0,0 @@ -//===-- llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.h --------*- C++ -*--===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// Common functionality for different debug information format backends. -// LLVM currently supports DWARF and CodeView. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DEBUGHANDLERBASE_H -#define LLVM_LIB_CODEGEN_ASMPRINTER_DEBUGHANDLERBASE_H - -#include "AsmPrinterHandler.h" -#include "DbgEntityHistoryCalculator.h" -#include "llvm/ADT/Optional.h" -#include "llvm/CodeGen/LexicalScopes.h" -#include "llvm/CodeGen/MachineInstr.h" -#include "llvm/IR/DebugInfoMetadata.h" - -namespace llvm { - -class AsmPrinter; -class MachineInstr; -class MachineModuleInfo; - -/// Represents the location at which a variable is stored. -struct DbgVariableLocation { - /// Base register. - unsigned Register; - - /// Chain of offsetted loads necessary to load the value if it lives in - /// memory. Every load except for the last is pointer-sized. - SmallVector<int64_t, 1> LoadChain; - - /// Present if the location is part of a larger variable. - llvm::Optional<llvm::DIExpression::FragmentInfo> FragmentInfo; - - /// Extract a VariableLocation from a MachineInstr. - /// This will only work if Instruction is a debug value instruction - /// and the associated DIExpression is in one of the supported forms. - /// If these requirements are not met, the returned Optional will not - /// have a value. - static Optional<DbgVariableLocation> - extractFromMachineInstruction(const MachineInstr &Instruction); -}; - -/// Base class for debug information backends. Common functionality related to -/// tracking which variables and scopes are alive at a given PC live here. -class DebugHandlerBase : public AsmPrinterHandler { -protected: - DebugHandlerBase(AsmPrinter *A); - - /// Target of debug info emission. - AsmPrinter *Asm; - - /// Collected machine module information. - MachineModuleInfo *MMI; - - /// Previous instruction's location information. This is used to - /// determine label location to indicate scope boundaries in debug info. - /// We track the previous instruction's source location (if not line 0), - /// whether it was a label, and its parent BB. - DebugLoc PrevInstLoc; - MCSymbol *PrevLabel = nullptr; - const MachineBasicBlock *PrevInstBB = nullptr; - - /// This location indicates end of function prologue and beginning of - /// function body. - DebugLoc PrologEndLoc; - - /// If nonnull, stores the current machine instruction we're processing. - const MachineInstr *CurMI = nullptr; - - LexicalScopes LScopes; - - /// History of DBG_VALUE and clobber instructions for each user - /// variable. Variables are listed in order of appearance. - DbgValueHistoryMap DbgValues; - - /// Mapping of inlined labels and DBG_LABEL machine instruction. - DbgLabelInstrMap DbgLabels; - - /// Maps instruction with label emitted before instruction. - /// FIXME: Make this private from DwarfDebug, we have the necessary accessors - /// for it. - DenseMap<const MachineInstr *, MCSymbol *> LabelsBeforeInsn; - - /// Maps instruction with label emitted after instruction. - DenseMap<const MachineInstr *, MCSymbol *> LabelsAfterInsn; - - /// Indentify instructions that are marking the beginning of or - /// ending of a scope. - void identifyScopeMarkers(); - - /// Ensure that a label will be emitted before MI. - void requestLabelBeforeInsn(const MachineInstr *MI) { - LabelsBeforeInsn.insert(std::make_pair(MI, nullptr)); - } - - /// Ensure that a label will be emitted after MI. - void requestLabelAfterInsn(const MachineInstr *MI) { - LabelsAfterInsn.insert(std::make_pair(MI, nullptr)); - } - - virtual void beginFunctionImpl(const MachineFunction *MF) = 0; - virtual void endFunctionImpl(const MachineFunction *MF) = 0; - virtual void skippedNonDebugFunction() {} - - // AsmPrinterHandler overrides. -public: - void beginInstruction(const MachineInstr *MI) override; - void endInstruction() override; - - void beginFunction(const MachineFunction *MF) override; - void endFunction(const MachineFunction *MF) override; - - /// Return Label preceding the instruction. - MCSymbol *getLabelBeforeInsn(const MachineInstr *MI); - - /// Return Label immediately following the instruction. - MCSymbol *getLabelAfterInsn(const MachineInstr *MI); - - /// Return the function-local offset of an instruction. A label for the - /// instruction \p MI should exist (\ref getLabelAfterInsn). - const MCExpr *getFunctionLocalOffsetAfterInsn(const MachineInstr *MI); - - /// If this type is derived from a base type then return base type size. - static uint64_t getBaseTypeSize(const DITypeRef TyRef); -}; - -} - -#endif diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h index 6e9490702c8..9ec22f68c12 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h @@ -14,7 +14,6 @@ #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFCOMPILEUNIT_H #define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFCOMPILEUNIT_H -#include "DbgEntityHistoryCalculator.h" #include "DwarfDebug.h" #include "DwarfUnit.h" #include "llvm/ADT/ArrayRef.h" @@ -23,6 +22,7 @@ #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" #include "llvm/BinaryFormat/Dwarf.h" +#include "llvm/CodeGen/DbgEntityHistoryCalculator.h" #include "llvm/CodeGen/DIE.h" #include "llvm/CodeGen/LexicalScopes.h" #include "llvm/IR/DebugInfoMetadata.h" diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h index 56aac676ed5..8a31e989b28 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h @@ -15,8 +15,6 @@ #define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFDEBUG_H #include "AddressPool.h" -#include "DbgEntityHistoryCalculator.h" -#include "DebugHandlerBase.h" #include "DebugLocStream.h" #include "DwarfFile.h" #include "llvm/ADT/ArrayRef.h" @@ -31,6 +29,8 @@ #include "llvm/ADT/StringRef.h" #include "llvm/BinaryFormat/Dwarf.h" #include "llvm/CodeGen/AccelTable.h" +#include "llvm/CodeGen/DbgEntityHistoryCalculator.h" +#include "llvm/CodeGen/DebugHandlerBase.h" #include "llvm/CodeGen/MachineInstr.h" #include "llvm/IR/DebugInfoMetadata.h" #include "llvm/IR/DebugLoc.h" diff --git a/llvm/lib/CodeGen/AsmPrinter/EHStreamer.h b/llvm/lib/CodeGen/AsmPrinter/EHStreamer.h index e3a6f8e9d58..ce912d032c6 100644 --- a/llvm/lib/CodeGen/AsmPrinter/EHStreamer.h +++ b/llvm/lib/CodeGen/AsmPrinter/EHStreamer.h @@ -14,8 +14,8 @@ #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_EHSTREAMER_H #define LLVM_LIB_CODEGEN_ASMPRINTER_EHSTREAMER_H -#include "AsmPrinterHandler.h" #include "llvm/ADT/DenseMap.h" +#include "llvm/CodeGen/AsmPrinterHandler.h" #include "llvm/Support/Compiler.h" namespace llvm { diff --git a/llvm/lib/CodeGen/AsmPrinter/WinCFGuard.h b/llvm/lib/CodeGen/AsmPrinter/WinCFGuard.h index 124e8f04bfa..28f119e3596 100644 --- a/llvm/lib/CodeGen/AsmPrinter/WinCFGuard.h +++ b/llvm/lib/CodeGen/AsmPrinter/WinCFGuard.h @@ -14,7 +14,7 @@ #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_WINCFGUARD_H #define LLVM_LIB_CODEGEN_ASMPRINTER_WINCFGUARD_H -#include "AsmPrinterHandler.h" +#include "llvm/CodeGen/AsmPrinterHandler.h" #include "llvm/Support/Compiler.h" namespace llvm { |