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() {}
+ /// Process the beginning of a new basic-block-section within a
+ /// function. Always called immediately after beginFunction for the first
+ /// basic-block. When basic-block-sections are enabled, called before the
+ /// first block of each such section.
+ virtual void beginBasicBlockSection(const MachineBasicBlock &MBB) {}
+
+ /// Process the end of a basic-block-section within a function. When
+ /// basic-block-sections are enabled, called after the last block in each such
+ /// section (including the last section in the function). When
+ /// basic-block-sections are disabled, called at the end of a function,
+ /// immediately prior to markFunctionEnd.
+ virtual void endBasicBlockSection(const MachineBasicBlock &MBB) {}
/// Emit target-specific EH funclet machinery.
virtual void beginFunclet(const MachineBasicBlock &MBB,
/// Process end of an instruction.
virtual void endInstruction() = 0;
-
- /// Process beginning of a basic block during basic block sections.
- virtual void beginBasicBlock(const MachineBasicBlock &MBB) {}
-
- /// Process end of a basic block during basic block sections.
- virtual void endBasicBlock(const MachineBasicBlock &MBB) {}
};
} // End of namespace llvm
void beginFunction(const MachineFunction *MF) override;
void endFunction(const MachineFunction *MF) override;
- void beginBasicBlock(const MachineBasicBlock &MBB) override;
- void endBasicBlock(const MachineBasicBlock &MBB) override;
+ void beginBasicBlockSection(const MachineBasicBlock &MBB) override;
+ void endBasicBlockSection(const MachineBasicBlock &MBB) override;
/// Return Label preceding the instruction.
MCSymbol *getLabelBeforeInsn(const MachineInstr *MI);
AIXException::AIXException(AsmPrinter *A) : DwarfCFIExceptionBase(A) {}
-void AIXException::markFunctionEnd() { endFragment(); }
+// This overrides 'DwarfCFIExceptionBase::markFunctionEnd', to avoid the call to
+// tidyLandingPads. This is necessary, because the
+// 'PPCAIXAsmPrinter::emitFunctionBodyEnd' function already checked whether we
+// need ehinfo, and emitted a traceback table with the bits set to indicate that
+// we will be emitting it, if so. Thus, if we remove it now -- so late in the
+// process -- we'll end up having emitted a reference to __ehinfo.N symbol, but
+// not emitting a definition for said symbol.
+void AIXException::markFunctionEnd() {}
void AIXException::emitExceptionInfoTable(const MCSymbol *LSDA,
const MCSymbol *PerSym) {
}
}
+void ARMException::markFunctionEnd() {
+ if (shouldEmitCFI)
+ Asm->OutStreamer->emitCFIEndProc();
+ DwarfCFIExceptionBase::markFunctionEnd();
+}
+
/// endFunction - Gather and emit post-function exception information.
///
void ARMException::endFunction(const MachineFunction *MF) {
HI.TimerGroupDescription, TimePassesIsEnabled);
HI.Handler->beginFunction(MF);
}
+ for (const HandlerInfo &HI : Handlers) {
+ NamedRegionTimer T(HI.TimerName, HI.TimerDescription, HI.TimerGroupName,
+ HI.TimerGroupDescription, TimePassesIsEnabled);
+ HI.Handler->beginBasicBlockSection(MF->front());
+ }
// Emit the prologue data.
if (F.hasPrologueData())
OutStreamer->emitELFSize(CurrentFnBeginLocal, SizeExp);
}
+ // Call endBasicBlockSection on the last block now, if it wasn't already
+ // called.
+ if (!MF->back().isEndSection()) {
+ for (const HandlerInfo &HI : Handlers) {
+ NamedRegionTimer T(HI.TimerName, HI.TimerDescription, HI.TimerGroupName,
+ HI.TimerGroupDescription, TimePassesIsEnabled);
+ HI.Handler->endBasicBlockSection(MF->back());
+ }
+ }
for (const HandlerInfo &HI : Handlers) {
NamedRegionTimer T(HI.TimerName, HI.TimerDescription, HI.TimerGroupName,
HI.TimerGroupDescription, TimePassesIsEnabled);
}
// With BB sections, each basic block must handle CFI information on its own
- // if it begins a section (Entry block is handled separately by
- // AsmPrinterHandler::beginFunction).
+ // if it begins a section (Entry block call is handled separately, next to
+ // beginFunction).
if (MBB.isBeginSection() && !MBB.isEntryBlock())
for (const HandlerInfo &HI : Handlers)
- HI.Handler->beginBasicBlock(MBB);
+ HI.Handler->beginBasicBlockSection(MBB);
}
void AsmPrinter::emitBasicBlockEnd(const MachineBasicBlock &MBB) {
// sections.
if (MBB.isEndSection())
for (const HandlerInfo &HI : Handlers)
- HI.Handler->endBasicBlock(MBB);
+ HI.Handler->endBasicBlockSection(MBB);
}
void AsmPrinter::emitVisibility(MCSymbol *Sym, unsigned Visibility,
InstOrdering.clear();
}
-void DebugHandlerBase::beginBasicBlock(const MachineBasicBlock &MBB) {
- if (!MBB.isBeginSection())
- return;
-
- PrevLabel = MBB.getSymbol();
+void DebugHandlerBase::beginBasicBlockSection(const MachineBasicBlock &MBB) {
+ if (!MBB.isEntryBlock())
+ PrevLabel = MBB.getSymbol();
}
-void DebugHandlerBase::endBasicBlock(const MachineBasicBlock &MBB) {
- if (!MBB.isEndSection())
- return;
-
+void DebugHandlerBase::endBasicBlockSection(const MachineBasicBlock &MBB) {
PrevLabel = nullptr;
}
DwarfCFIExceptionBase::DwarfCFIExceptionBase(AsmPrinter *A) : EHStreamer(A) {}
void DwarfCFIExceptionBase::markFunctionEnd() {
- endFragment();
-
// Map all labels and get rid of any dead landing pads.
if (!Asm->MF->getLandingPads().empty()) {
MachineFunction *NonConstMF = const_cast<MachineFunction*>(Asm->MF);
}
}
-void DwarfCFIExceptionBase::endFragment() {
- if (shouldEmitCFI && !Asm->MF->hasBBSections())
- Asm->OutStreamer->emitCFIEndProc();
-}
-
DwarfCFIException::DwarfCFIException(AsmPrinter *A)
: DwarfCFIExceptionBase(A) {}
}
}
-static MCSymbol *getExceptionSym(AsmPrinter *Asm,
- const MachineBasicBlock *MBB) {
- return Asm->getMBBExceptionSym(*MBB);
-}
-
void DwarfCFIException::beginFunction(const MachineFunction *MF) {
shouldEmitPersonality = shouldEmitLSDA = false;
const Function &F = MF->getFunction();
MAI.usesCFIForEH() && (shouldEmitPersonality || shouldEmitMoves);
else
shouldEmitCFI = Asm->needsCFIForDebug() && shouldEmitMoves;
-
- beginFragment(&*MF->begin(), getExceptionSym);
}
-void DwarfCFIException::beginFragment(const MachineBasicBlock *MBB,
- ExceptionSymbolProvider ESP) {
+void DwarfCFIException::beginBasicBlockSection(const MachineBasicBlock &MBB) {
if (!shouldEmitCFI)
return;
if (!shouldEmitPersonality)
return;
- auto &F = MBB->getParent()->getFunction();
+ auto &F = MBB.getParent()->getFunction();
auto *P = dyn_cast<Function>(F.getPersonalityFn()->stripPointerCasts());
assert(P && "Expected personality function");
// Provide LSDA information.
if (shouldEmitLSDA)
- Asm->OutStreamer->emitCFILsda(ESP(Asm, MBB), TLOF.getLSDAEncoding());
+ Asm->OutStreamer->emitCFILsda(Asm->getMBBExceptionSym(MBB),
+ TLOF.getLSDAEncoding());
+}
+
+void DwarfCFIException::endBasicBlockSection(const MachineBasicBlock &MBB) {
+ if (shouldEmitCFI)
+ Asm->OutStreamer->emitCFIEndProc();
}
/// endFunction - Gather and emit post-function exception information.
emitExceptionTable();
}
-
-void DwarfCFIException::beginBasicBlock(const MachineBasicBlock &MBB) {
- beginFragment(&MBB, getExceptionSym);
-}
-
-void DwarfCFIException::endBasicBlock(const MachineBasicBlock &MBB) {
- if (shouldEmitCFI)
- Asm->OutStreamer->emitCFIEndProc();
-}
bool hasEmittedCFISections = false;
void markFunctionEnd() override;
- void endFragment() override;
};
class LLVM_LIBRARY_VISIBILITY DwarfCFIException : public DwarfCFIExceptionBase {
/// Gather and emit post-function exception information.
void endFunction(const MachineFunction *) override;
- void beginFragment(const MachineBasicBlock *MBB,
- ExceptionSymbolProvider ESP) override;
-
- void beginBasicBlock(const MachineBasicBlock &MBB) override;
- void endBasicBlock(const MachineBasicBlock &MBB) override;
+ void beginBasicBlockSection(const MachineBasicBlock &MBB) override;
+ void endBasicBlockSection(const MachineBasicBlock &MBB) override;
};
class LLVM_LIBRARY_VISIBILITY ARMException : public DwarfCFIExceptionBase {
/// Gather and emit post-function exception information.
void endFunction(const MachineFunction *) override;
+
+ void markFunctionEnd() override;
};
class LLVM_LIBRARY_VISIBILITY AIXException : public DwarfCFIExceptionBase {
void endModule() override {}
void beginFunction(const MachineFunction *MF) override {}
-
void endFunction(const MachineFunction *MF) override;
};
} // End of namespace llvm