forked from OSchip/llvm-project
Revert "make the AsmPrinterHandler array public"
I messed up one of the tests.
This commit is contained in:
parent
24b5266892
commit
4242df1470
|
@ -139,23 +139,6 @@ public:
|
||||||
using GOTEquivUsePair = std::pair<const GlobalVariable *, unsigned>;
|
using GOTEquivUsePair = std::pair<const GlobalVariable *, unsigned>;
|
||||||
MapVector<const MCSymbol *, GOTEquivUsePair> GlobalGOTEquivs;
|
MapVector<const MCSymbol *, GOTEquivUsePair> GlobalGOTEquivs;
|
||||||
|
|
||||||
/// struct HandlerInfo and Handlers permit users or target extended
|
|
||||||
/// AsmPrinter to add their own handlers.
|
|
||||||
struct HandlerInfo {
|
|
||||||
std::unique_ptr<AsmPrinterHandler> Handler;
|
|
||||||
const char *TimerName;
|
|
||||||
const char *TimerDescription;
|
|
||||||
const char *TimerGroupName;
|
|
||||||
const char *TimerGroupDescription;
|
|
||||||
|
|
||||||
HandlerInfo(std::unique_ptr<AsmPrinterHandler> Handler,
|
|
||||||
const char *TimerName, const char *TimerDescription,
|
|
||||||
const char *TimerGroupName, const char *TimerGroupDescription)
|
|
||||||
: Handler(std::move(Handler)), TimerName(TimerName),
|
|
||||||
TimerDescription(TimerDescription), TimerGroupName(TimerGroupName),
|
|
||||||
TimerGroupDescription(TimerGroupDescription) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MCSymbol *CurrentFnEnd = nullptr;
|
MCSymbol *CurrentFnEnd = nullptr;
|
||||||
|
|
||||||
|
@ -179,10 +162,26 @@ private:
|
||||||
protected:
|
protected:
|
||||||
MCSymbol *CurrentFnBegin = nullptr;
|
MCSymbol *CurrentFnBegin = nullptr;
|
||||||
|
|
||||||
|
/// Protected struct HandlerInfo and Handlers permit target extended
|
||||||
|
/// AsmPrinter adds their own handlers.
|
||||||
|
struct HandlerInfo {
|
||||||
|
std::unique_ptr<AsmPrinterHandler> Handler;
|
||||||
|
const char *TimerName;
|
||||||
|
const char *TimerDescription;
|
||||||
|
const char *TimerGroupName;
|
||||||
|
const char *TimerGroupDescription;
|
||||||
|
|
||||||
|
HandlerInfo(std::unique_ptr<AsmPrinterHandler> Handler,
|
||||||
|
const char *TimerName, const char *TimerDescription,
|
||||||
|
const char *TimerGroupName, const char *TimerGroupDescription)
|
||||||
|
: Handler(std::move(Handler)), TimerName(TimerName),
|
||||||
|
TimerDescription(TimerDescription), TimerGroupName(TimerGroupName),
|
||||||
|
TimerGroupDescription(TimerGroupDescription) {}
|
||||||
|
};
|
||||||
|
|
||||||
/// A vector of all debug/EH info emitters we should use. This vector
|
/// A vector of all debug/EH info emitters we should use. This vector
|
||||||
/// maintains ownership of the emitters.
|
/// maintains ownership of the emitters.
|
||||||
std::vector<HandlerInfo> Handlers;
|
SmallVector<HandlerInfo, 1> Handlers;
|
||||||
size_t NumUserHandlers = 0;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
struct SrcMgrDiagInfo {
|
struct SrcMgrDiagInfo {
|
||||||
|
@ -447,11 +446,6 @@ public:
|
||||||
// Overridable Hooks
|
// Overridable Hooks
|
||||||
//===------------------------------------------------------------------===//
|
//===------------------------------------------------------------------===//
|
||||||
|
|
||||||
void addAsmPrinterHandler(HandlerInfo Handler) {
|
|
||||||
Handlers.insert(Handlers.begin(), std::move(Handler));
|
|
||||||
NumUserHandlers++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Targets can, or in the case of EmitInstruction, must implement these to
|
// Targets can, or in the case of EmitInstruction, must implement these to
|
||||||
// customize output.
|
// customize output.
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,6 @@ class MachineBasicBlock;
|
||||||
class MachineFunction;
|
class MachineFunction;
|
||||||
class MachineInstr;
|
class MachineInstr;
|
||||||
class MCSymbol;
|
class MCSymbol;
|
||||||
class Module;
|
|
||||||
|
|
||||||
typedef MCSymbol *ExceptionSymbolProvider(AsmPrinter *Asm,
|
typedef MCSymbol *ExceptionSymbolProvider(AsmPrinter *Asm,
|
||||||
const MachineBasicBlock *MBB);
|
const MachineBasicBlock *MBB);
|
||||||
|
@ -38,8 +37,6 @@ public:
|
||||||
/// this tracks that size.
|
/// this tracks that size.
|
||||||
virtual void setSymbolSize(const MCSymbol *Sym, uint64_t Size) = 0;
|
virtual void setSymbolSize(const MCSymbol *Sym, uint64_t Size) = 0;
|
||||||
|
|
||||||
virtual void beginModule(Module *M) {}
|
|
||||||
|
|
||||||
/// Emit all sections that should come after the content.
|
/// Emit all sections that should come after the content.
|
||||||
virtual void endModule() = 0;
|
virtual void endModule() = 0;
|
||||||
|
|
||||||
|
@ -78,7 +75,6 @@ public:
|
||||||
/// Process end of a basic block during basic block sections.
|
/// Process end of a basic block during basic block sections.
|
||||||
virtual void endBasicBlock(const MachineBasicBlock &MBB) {}
|
virtual void endBasicBlock(const MachineBasicBlock &MBB) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // End of namespace llvm
|
} // End of namespace llvm
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -115,8 +115,6 @@ private:
|
||||||
|
|
||||||
// AsmPrinterHandler overrides.
|
// AsmPrinterHandler overrides.
|
||||||
public:
|
public:
|
||||||
void beginModule(Module *M) override;
|
|
||||||
|
|
||||||
void beginInstruction(const MachineInstr *MI) override;
|
void beginInstruction(const MachineInstr *MI) override;
|
||||||
void endInstruction() override;
|
void endInstruction() override;
|
||||||
|
|
||||||
|
|
|
@ -188,8 +188,7 @@ AsmPrinter::AsmPrinter(TargetMachine &tm, std::unique_ptr<MCStreamer> Streamer)
|
||||||
}
|
}
|
||||||
|
|
||||||
AsmPrinter::~AsmPrinter() {
|
AsmPrinter::~AsmPrinter() {
|
||||||
assert(!DD && Handlers.size() == NumUserHandlers &&
|
assert(!DD && Handlers.empty() && "Debug/EH info didn't get finalized");
|
||||||
"Debug/EH info didn't get finalized");
|
|
||||||
|
|
||||||
if (GCMetadataPrinters) {
|
if (GCMetadataPrinters) {
|
||||||
gcp_map_type &GCMap = getGCMap(GCMetadataPrinters);
|
gcp_map_type &GCMap = getGCMap(GCMetadataPrinters);
|
||||||
|
@ -253,9 +252,6 @@ bool AsmPrinter::doInitialization(Module &M) {
|
||||||
auto *MMIWP = getAnalysisIfAvailable<MachineModuleInfoWrapperPass>();
|
auto *MMIWP = getAnalysisIfAvailable<MachineModuleInfoWrapperPass>();
|
||||||
MMI = MMIWP ? &MMIWP->getMMI() : nullptr;
|
MMI = MMIWP ? &MMIWP->getMMI() : nullptr;
|
||||||
|
|
||||||
if (!M.debug_compile_units().empty())
|
|
||||||
MMI->setDebugInfoAvailability(true);
|
|
||||||
|
|
||||||
// Initialize TargetLoweringObjectFile.
|
// Initialize TargetLoweringObjectFile.
|
||||||
const_cast<TargetLoweringObjectFile&>(getObjFileLowering())
|
const_cast<TargetLoweringObjectFile&>(getObjFileLowering())
|
||||||
.Initialize(OutContext, TM);
|
.Initialize(OutContext, TM);
|
||||||
|
@ -317,7 +313,8 @@ bool AsmPrinter::doInitialization(Module &M) {
|
||||||
CodeViewLineTablesGroupDescription);
|
CodeViewLineTablesGroupDescription);
|
||||||
}
|
}
|
||||||
if (!EmitCodeView || M.getDwarfVersion()) {
|
if (!EmitCodeView || M.getDwarfVersion()) {
|
||||||
DD = new DwarfDebug(this);
|
DD = new DwarfDebug(this, &M);
|
||||||
|
DD->beginModule();
|
||||||
Handlers.emplace_back(std::unique_ptr<DwarfDebug>(DD), DbgTimerName,
|
Handlers.emplace_back(std::unique_ptr<DwarfDebug>(DD), DbgTimerName,
|
||||||
DbgTimerDescription, DWARFGroupName,
|
DbgTimerDescription, DWARFGroupName,
|
||||||
DWARFGroupDescription);
|
DWARFGroupDescription);
|
||||||
|
@ -382,13 +379,6 @@ bool AsmPrinter::doInitialization(Module &M) {
|
||||||
Handlers.emplace_back(std::make_unique<WinCFGuard>(this), CFGuardName,
|
Handlers.emplace_back(std::make_unique<WinCFGuard>(this), CFGuardName,
|
||||||
CFGuardDescription, DWARFGroupName,
|
CFGuardDescription, DWARFGroupName,
|
||||||
DWARFGroupDescription);
|
DWARFGroupDescription);
|
||||||
|
|
||||||
for (const HandlerInfo &HI : Handlers) {
|
|
||||||
NamedRegionTimer T(HI.TimerName, HI.TimerDescription, HI.TimerGroupName,
|
|
||||||
HI.TimerGroupDescription, TimePassesIsEnabled);
|
|
||||||
HI.Handler->beginModule(&M);
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1120,6 +1110,8 @@ void AsmPrinter::emitFunctionBody() {
|
||||||
// Emit target-specific gunk before the function body.
|
// Emit target-specific gunk before the function body.
|
||||||
emitFunctionBodyStart();
|
emitFunctionBodyStart();
|
||||||
|
|
||||||
|
bool ShouldPrintDebugScopes = MMI->hasDebugInfo();
|
||||||
|
|
||||||
if (isVerbose()) {
|
if (isVerbose()) {
|
||||||
// Get MachineDominatorTree or compute it on the fly if it's unavailable
|
// Get MachineDominatorTree or compute it on the fly if it's unavailable
|
||||||
MDT = getAnalysisIfAvailable<MachineDominatorTree>();
|
MDT = getAnalysisIfAvailable<MachineDominatorTree>();
|
||||||
|
@ -1157,10 +1149,13 @@ void AsmPrinter::emitFunctionBody() {
|
||||||
if (MCSymbol *S = MI.getPreInstrSymbol())
|
if (MCSymbol *S = MI.getPreInstrSymbol())
|
||||||
OutStreamer->emitLabel(S);
|
OutStreamer->emitLabel(S);
|
||||||
|
|
||||||
for (const HandlerInfo &HI : Handlers) {
|
if (ShouldPrintDebugScopes) {
|
||||||
NamedRegionTimer T(HI.TimerName, HI.TimerDescription, HI.TimerGroupName,
|
for (const HandlerInfo &HI : Handlers) {
|
||||||
HI.TimerGroupDescription, TimePassesIsEnabled);
|
NamedRegionTimer T(HI.TimerName, HI.TimerDescription,
|
||||||
HI.Handler->beginInstruction(&MI);
|
HI.TimerGroupName, HI.TimerGroupDescription,
|
||||||
|
TimePassesIsEnabled);
|
||||||
|
HI.Handler->beginInstruction(&MI);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isVerbose())
|
if (isVerbose())
|
||||||
|
@ -1214,10 +1209,13 @@ void AsmPrinter::emitFunctionBody() {
|
||||||
if (MCSymbol *S = MI.getPostInstrSymbol())
|
if (MCSymbol *S = MI.getPostInstrSymbol())
|
||||||
OutStreamer->emitLabel(S);
|
OutStreamer->emitLabel(S);
|
||||||
|
|
||||||
for (const HandlerInfo &HI : Handlers) {
|
if (ShouldPrintDebugScopes) {
|
||||||
NamedRegionTimer T(HI.TimerName, HI.TimerDescription, HI.TimerGroupName,
|
for (const HandlerInfo &HI : Handlers) {
|
||||||
HI.TimerGroupDescription, TimePassesIsEnabled);
|
NamedRegionTimer T(HI.TimerName, HI.TimerDescription,
|
||||||
HI.Handler->endInstruction();
|
HI.TimerGroupName, HI.TimerGroupDescription,
|
||||||
|
TimePassesIsEnabled);
|
||||||
|
HI.Handler->endInstruction();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1639,11 +1637,7 @@ bool AsmPrinter::doFinalization(Module &M) {
|
||||||
HI.TimerGroupDescription, TimePassesIsEnabled);
|
HI.TimerGroupDescription, TimePassesIsEnabled);
|
||||||
HI.Handler->endModule();
|
HI.Handler->endModule();
|
||||||
}
|
}
|
||||||
|
Handlers.clear();
|
||||||
// This deletes all the ephemeral handlers that AsmPrinter added, while
|
|
||||||
// keeping all the user-added handlers alive until the AsmPrinter is
|
|
||||||
// destroyed.
|
|
||||||
Handlers.erase(Handlers.begin() + NumUserHandlers, Handlers.end());
|
|
||||||
DD = nullptr;
|
DD = nullptr;
|
||||||
|
|
||||||
// If the target wants to know about weak references, print them all.
|
// If the target wants to know about weak references, print them all.
|
||||||
|
|
|
@ -141,6 +141,7 @@ CodeViewDebug::CodeViewDebug(AsmPrinter *AP)
|
||||||
if (!MMI->getModule()->getNamedMetadata("llvm.dbg.cu") ||
|
if (!MMI->getModule()->getNamedMetadata("llvm.dbg.cu") ||
|
||||||
!AP->getObjFileLowering().getCOFFDebugSymbolsSection()) {
|
!AP->getObjFileLowering().getCOFFDebugSymbolsSection()) {
|
||||||
Asm = nullptr;
|
Asm = nullptr;
|
||||||
|
MMI->setDebugInfoAvailability(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Tell MMI that we have debug info.
|
// Tell MMI that we have debug info.
|
||||||
|
@ -563,6 +564,8 @@ void CodeViewDebug::endModule() {
|
||||||
if (!Asm || !MMI->hasDebugInfo())
|
if (!Asm || !MMI->hasDebugInfo())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
assert(Asm != nullptr);
|
||||||
|
|
||||||
// The COFF .debug$S section consists of several subsections, each starting
|
// The COFF .debug$S section consists of several subsections, each starting
|
||||||
// with a 4-byte control code (e.g. 0xF1, 0xF2, etc) and then a 4-byte length
|
// with a 4-byte control code (e.g. 0xF1, 0xF2, etc) and then a 4-byte length
|
||||||
// of the payload followed by the payload itself. The subsections are 4-byte
|
// of the payload followed by the payload itself. The subsections are 4-byte
|
||||||
|
|
|
@ -91,11 +91,6 @@ DbgVariableLocation::extractFromMachineInstruction(
|
||||||
|
|
||||||
DebugHandlerBase::DebugHandlerBase(AsmPrinter *A) : Asm(A), MMI(Asm->MMI) {}
|
DebugHandlerBase::DebugHandlerBase(AsmPrinter *A) : Asm(A), MMI(Asm->MMI) {}
|
||||||
|
|
||||||
void DebugHandlerBase::beginModule(Module *M) {
|
|
||||||
if (M->debug_compile_units().empty())
|
|
||||||
Asm = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Each LexicalScope has first instruction and last instruction to mark
|
// Each LexicalScope has first instruction and last instruction to mark
|
||||||
// beginning and end of a scope respectively. Create an inverse map that list
|
// beginning and end of a scope respectively. Create an inverse map that list
|
||||||
// scopes starts (and ends) with an instruction. One instruction may start (or
|
// scopes starts (and ends) with an instruction. One instruction may start (or
|
||||||
|
@ -281,7 +276,7 @@ void DebugHandlerBase::beginFunction(const MachineFunction *MF) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebugHandlerBase::beginInstruction(const MachineInstr *MI) {
|
void DebugHandlerBase::beginInstruction(const MachineInstr *MI) {
|
||||||
if (!Asm || !MMI->hasDebugInfo())
|
if (!MMI->hasDebugInfo())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
assert(CurMI == nullptr);
|
assert(CurMI == nullptr);
|
||||||
|
@ -307,7 +302,7 @@ void DebugHandlerBase::beginInstruction(const MachineInstr *MI) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebugHandlerBase::endInstruction() {
|
void DebugHandlerBase::endInstruction() {
|
||||||
if (!Asm || !MMI->hasDebugInfo())
|
if (!MMI->hasDebugInfo())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
assert(CurMI != nullptr);
|
assert(CurMI != nullptr);
|
||||||
|
@ -339,7 +334,7 @@ void DebugHandlerBase::endInstruction() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebugHandlerBase::endFunction(const MachineFunction *MF) {
|
void DebugHandlerBase::endFunction(const MachineFunction *MF) {
|
||||||
if (Asm && hasDebugInfo(MMI, MF))
|
if (hasDebugInfo(MMI, MF))
|
||||||
endFunctionImpl(MF);
|
endFunctionImpl(MF);
|
||||||
DbgValues.clear();
|
DbgValues.clear();
|
||||||
DbgLabels.clear();
|
DbgLabels.clear();
|
||||||
|
|
|
@ -148,6 +148,10 @@ static cl::opt<LinkageNameOption>
|
||||||
"Abstract subprograms")),
|
"Abstract subprograms")),
|
||||||
cl::init(DefaultLinkageNames));
|
cl::init(DefaultLinkageNames));
|
||||||
|
|
||||||
|
static const char *const DWARFGroupName = "dwarf";
|
||||||
|
static const char *const DWARFGroupDescription = "DWARF Emission";
|
||||||
|
static const char *const DbgTimerName = "writer";
|
||||||
|
static const char *const DbgTimerDescription = "DWARF Debug Writer";
|
||||||
static constexpr unsigned ULEB128PadSize = 4;
|
static constexpr unsigned ULEB128PadSize = 4;
|
||||||
|
|
||||||
void DebugLocDwarfExpression::emitOp(uint8_t Op, const char *Comment) {
|
void DebugLocDwarfExpression::emitOp(uint8_t Op, const char *Comment) {
|
||||||
|
@ -326,7 +330,7 @@ static AccelTableKind computeAccelTableKind(unsigned DwarfVersion,
|
||||||
return AccelTableKind::None;
|
return AccelTableKind::None;
|
||||||
}
|
}
|
||||||
|
|
||||||
DwarfDebug::DwarfDebug(AsmPrinter *A)
|
DwarfDebug::DwarfDebug(AsmPrinter *A, Module *M)
|
||||||
: DebugHandlerBase(A), DebugLocs(A->OutStreamer->isVerboseAsm()),
|
: DebugHandlerBase(A), DebugLocs(A->OutStreamer->isVerboseAsm()),
|
||||||
InfoHolder(A, "info_string", DIEValueAllocator),
|
InfoHolder(A, "info_string", DIEValueAllocator),
|
||||||
SkeletonHolder(A, "skel_string", DIEValueAllocator),
|
SkeletonHolder(A, "skel_string", DIEValueAllocator),
|
||||||
|
@ -1107,17 +1111,21 @@ sortGlobalExprs(SmallVectorImpl<DwarfCompileUnit::GlobalExpr> &GVEs) {
|
||||||
// Emit all Dwarf sections that should come prior to the content. Create
|
// Emit all Dwarf sections that should come prior to the content. Create
|
||||||
// global DIEs and emit initial debug info sections. This is invoked by
|
// global DIEs and emit initial debug info sections. This is invoked by
|
||||||
// the target AsmPrinter.
|
// the target AsmPrinter.
|
||||||
void DwarfDebug::beginModule(Module *M) {
|
void DwarfDebug::beginModule() {
|
||||||
DebugHandlerBase::beginModule(M);
|
NamedRegionTimer T(DbgTimerName, DbgTimerDescription, DWARFGroupName,
|
||||||
|
DWARFGroupDescription, TimePassesIsEnabled);
|
||||||
if (!Asm || !MMI->hasDebugInfo() || DisableDebugInfoPrinting)
|
if (DisableDebugInfoPrinting) {
|
||||||
|
MMI->setDebugInfoAvailability(false);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Module *M = MMI->getModule();
|
||||||
|
|
||||||
unsigned NumDebugCUs = std::distance(M->debug_compile_units_begin(),
|
unsigned NumDebugCUs = std::distance(M->debug_compile_units_begin(),
|
||||||
M->debug_compile_units_end());
|
M->debug_compile_units_end());
|
||||||
assert(NumDebugCUs > 0 && "Asm unexpectedly initialized");
|
// Tell MMI whether we have debug info.
|
||||||
assert(MMI->hasDebugInfo() &&
|
assert(MMI->hasDebugInfo() == (NumDebugCUs > 0) &&
|
||||||
"DebugInfoAvailabilty unexpectedly not initialized");
|
"DebugInfoAvailabilty initialized unexpectedly");
|
||||||
SingleCU = NumDebugCUs == 1;
|
SingleCU = NumDebugCUs == 1;
|
||||||
DenseMap<DIGlobalVariable *, SmallVector<DwarfCompileUnit::GlobalExpr, 1>>
|
DenseMap<DIGlobalVariable *, SmallVector<DwarfCompileUnit::GlobalExpr, 1>>
|
||||||
GVMap;
|
GVMap;
|
||||||
|
@ -1380,7 +1388,7 @@ void DwarfDebug::endModule() {
|
||||||
// If we aren't actually generating debug info (check beginModule -
|
// If we aren't actually generating debug info (check beginModule -
|
||||||
// conditionalized on !DisableDebugInfoPrinting and the presence of the
|
// conditionalized on !DisableDebugInfoPrinting and the presence of the
|
||||||
// llvm.dbg.cu metadata node)
|
// llvm.dbg.cu metadata node)
|
||||||
if (!Asm || !MMI->hasDebugInfo() || DisableDebugInfoPrinting)
|
if (!MMI->hasDebugInfo())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Finalize the debug info for the module.
|
// Finalize the debug info for the module.
|
||||||
|
@ -1891,8 +1899,7 @@ void DwarfDebug::beginInstruction(const MachineInstr *MI) {
|
||||||
}
|
}
|
||||||
|
|
||||||
DebugHandlerBase::beginInstruction(MI);
|
DebugHandlerBase::beginInstruction(MI);
|
||||||
if (!CurMI)
|
assert(CurMI);
|
||||||
return;
|
|
||||||
|
|
||||||
if (NoDebug)
|
if (NoDebug)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -621,13 +621,13 @@ public:
|
||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
// Main entry points.
|
// Main entry points.
|
||||||
//
|
//
|
||||||
DwarfDebug(AsmPrinter *A);
|
DwarfDebug(AsmPrinter *A, Module *M);
|
||||||
|
|
||||||
~DwarfDebug() override;
|
~DwarfDebug() override;
|
||||||
|
|
||||||
/// Emit all Dwarf sections that should come prior to the
|
/// Emit all Dwarf sections that should come prior to the
|
||||||
/// content.
|
/// content.
|
||||||
void beginModule(Module *M) override;
|
void beginModule();
|
||||||
|
|
||||||
/// Emit all Dwarf sections that should come after the content.
|
/// Emit all Dwarf sections that should come after the content.
|
||||||
void endModule() override;
|
void endModule() override;
|
||||||
|
|
|
@ -304,7 +304,7 @@ char MachineModuleInfoWrapperPass::ID = 0;
|
||||||
bool MachineModuleInfoWrapperPass::doInitialization(Module &M) {
|
bool MachineModuleInfoWrapperPass::doInitialization(Module &M) {
|
||||||
MMI.initialize();
|
MMI.initialize();
|
||||||
MMI.TheModule = &M;
|
MMI.TheModule = &M;
|
||||||
MMI.DbgInfoAvailable = false;
|
MMI.DbgInfoAvailable = !M.debug_compile_units().empty();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -319,6 +319,6 @@ MachineModuleInfo MachineModuleAnalysis::run(Module &M,
|
||||||
ModuleAnalysisManager &) {
|
ModuleAnalysisManager &) {
|
||||||
MachineModuleInfo MMI(TM);
|
MachineModuleInfo MMI(TM);
|
||||||
MMI.TheModule = &M;
|
MMI.TheModule = &M;
|
||||||
MMI.DbgInfoAvailable = false;
|
MMI.DbgInfoAvailable = !M.debug_compile_units().empty();
|
||||||
return MMI;
|
return MMI;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1076,9 +1076,6 @@ void BTFDebug::beginInstruction(const MachineInstr *MI) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CurMI) // no debug info
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Skip this instruction if no DebugLoc or the DebugLoc
|
// Skip this instruction if no DebugLoc or the DebugLoc
|
||||||
// is the same as the previous instruction.
|
// is the same as the previous instruction.
|
||||||
const DebugLoc &DL = MI->getDebugLoc();
|
const DebugLoc &DL = MI->getDebugLoc();
|
||||||
|
|
|
@ -8,13 +8,8 @@
|
||||||
|
|
||||||
#include "TestAsmPrinter.h"
|
#include "TestAsmPrinter.h"
|
||||||
#include "llvm/CodeGen/AsmPrinter.h"
|
#include "llvm/CodeGen/AsmPrinter.h"
|
||||||
#include "llvm/CodeGen/MachineModuleInfo.h"
|
|
||||||
#include "llvm/IR/LegacyPassManager.h"
|
|
||||||
#include "llvm/IR/Module.h"
|
|
||||||
#include "llvm/IR/PassManager.h"
|
|
||||||
#include "llvm/MC/MCContext.h"
|
#include "llvm/MC/MCContext.h"
|
||||||
#include "llvm/MC/MCSectionELF.h"
|
#include "llvm/MC/MCSectionELF.h"
|
||||||
#include "llvm/Target/TargetMachine.h"
|
|
||||||
#include "llvm/Testing/Support/Error.h"
|
#include "llvm/Testing/Support/Error.h"
|
||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
@ -372,58 +367,4 @@ TEST_F(AsmPrinterEmitDwarfUnitLengthAsHiLoDiffTest, DWARF64) {
|
||||||
TestPrinter->getAP()->emitDwarfUnitLength(Hi, Lo, "");
|
TestPrinter->getAP()->emitDwarfUnitLength(Hi, Lo, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
class AsmPrinterHandlerTest : public AsmPrinterFixtureBase {
|
|
||||||
class TestHandler : public AsmPrinterHandler {
|
|
||||||
AsmPrinterHandlerTest &Test;
|
|
||||||
|
|
||||||
public:
|
|
||||||
TestHandler(AsmPrinterHandlerTest &Test) : Test(Test) {}
|
|
||||||
virtual ~TestHandler() {}
|
|
||||||
virtual void setSymbolSize(const MCSymbol *Sym, uint64_t Size) override {}
|
|
||||||
virtual void beginModule(Module *M) override { Test.BeginCount++; }
|
|
||||||
virtual void endModule() override { Test.EndCount++; }
|
|
||||||
virtual void beginFunction(const MachineFunction *MF) override {}
|
|
||||||
virtual void endFunction(const MachineFunction *MF) override {}
|
|
||||||
virtual void beginInstruction(const MachineInstr *MI) override {}
|
|
||||||
virtual void endInstruction() override {}
|
|
||||||
};
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool init(const std::string &TripleStr, unsigned DwarfVersion,
|
|
||||||
dwarf::DwarfFormat DwarfFormat) {
|
|
||||||
if (!AsmPrinterFixtureBase::init(TripleStr, DwarfVersion, DwarfFormat))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
auto *AP = TestPrinter->getAP();
|
|
||||||
AP->addAsmPrinterHandler(AsmPrinter::HandlerInfo(
|
|
||||||
std::unique_ptr<AsmPrinterHandler>(new TestHandler(*this)),
|
|
||||||
"TestTimerName", "TestTimerDesc", "TestGroupName", "TestGroupDesc"));
|
|
||||||
LLVMTargetMachine *LLVMTM = static_cast<LLVMTargetMachine *>(&AP->TM);
|
|
||||||
legacy::PassManager PM;
|
|
||||||
PM.add(new MachineModuleInfoWrapperPass(LLVMTM));
|
|
||||||
PM.add(TestPrinter->releaseAP()); // Takes ownership of destroying AP
|
|
||||||
LLVMContext Context;
|
|
||||||
std::unique_ptr<Module> M(new Module("TestModule", Context));
|
|
||||||
M->setDataLayout(LLVMTM->createDataLayout());
|
|
||||||
PM.run(*M);
|
|
||||||
// Now check that we can run it twice.
|
|
||||||
AP->addAsmPrinterHandler(AsmPrinter::HandlerInfo(
|
|
||||||
std::unique_ptr<AsmPrinterHandler>(new TestHandler(*this)),
|
|
||||||
"TestTimerName", "TestTimerDesc", "TestGroupName", "TestGroupDesc"));
|
|
||||||
PM.run(*M);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
int BeginCount = 0;
|
|
||||||
int EndCount = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
TEST_F(AsmPrinterHandlerTest, Basic) {
|
|
||||||
if (!init("x86_64-pc-linux", /*DwarfVersion=*/4, dwarf::DWARF32))
|
|
||||||
return;
|
|
||||||
|
|
||||||
ASSERT_EQ(BeginCount, 3);
|
|
||||||
ASSERT_EQ(EndCount, 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // end namespace
|
} // end namespace
|
||||||
|
|
|
@ -73,7 +73,6 @@ public:
|
||||||
void setDwarfUsesRelocationsAcrossSections(bool Enable);
|
void setDwarfUsesRelocationsAcrossSections(bool Enable);
|
||||||
|
|
||||||
AsmPrinter *getAP() const { return Asm.get(); }
|
AsmPrinter *getAP() const { return Asm.get(); }
|
||||||
AsmPrinter *releaseAP() { return Asm.release(); }
|
|
||||||
MCContext &getCtx() const { return *MC; }
|
MCContext &getCtx() const { return *MC; }
|
||||||
MockMCStreamer &getMS() const { return *MS; }
|
MockMCStreamer &getMS() const { return *MS; }
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue