/// \name Exception Handling
/// \{
- /// Vector of all personality functions ever seen. Used to emit common EH
- /// frames.
- std::vector<const Function *> Personalities;
-
/// The current call site index being processed, if any. 0 if none.
unsigned CurCallSite;
/// none.
unsigned getCurrentCallSite() { return CurCallSite; }
- /// Provide the personality function for the exception information.
- void addPersonality(const Function *Personality);
-
- /// Return array of personality functions ever seen.
- const std::vector<const Function *>& getPersonalities() const {
- return Personalities;
- }
/// \}
// MMI owes MCContext. It should never be invalidated.
DwarfCFIException::~DwarfCFIException() = default;
+void DwarfCFIException::addPersonality(const GlobalValue *Personality) {
+ if (!llvm::is_contained(Personalities, Personality))
+ Personalities.push_back(Personality);
+}
+
/// endModule - Emit all exception information that should come after the
/// content.
void DwarfCFIException::endModule() {
if ((PerEncoding & 0x80) != dwarf::DW_EH_PE_indirect)
return;
- // Emit references to all used personality functions
- for (const Function *Personality : MMI->getPersonalities()) {
- if (!Personality)
- continue;
+ // Emit indirect reference table for all used personality functions
+ for (const GlobalValue *Personality : Personalities) {
MCSymbol *Sym = Asm->getSymbol(Personality);
TLOF.emitPersonalityValue(*Asm->OutStreamer, Asm->getDataLayout(), Sym);
}
+ Personalities.clear();
}
void DwarfCFIException::beginFunction(const MachineFunction *MF) {
const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering();
unsigned PerEncoding = TLOF.getPersonalityEncoding();
- const Function *Per = nullptr;
+ const GlobalValue *Per = nullptr;
if (F.hasPersonalityFn())
- Per = dyn_cast<Function>(F.getPersonalityFn()->stripPointerCasts());
+ Per = dyn_cast<GlobalValue>(F.getPersonalityFn()->stripPointerCasts());
// Emit a personality function even when there are no landing pads
forceEmitPersonality =
return;
auto &F = MBB.getParent()->getFunction();
- auto *P = dyn_cast<Function>(F.getPersonalityFn()->stripPointerCasts());
+ auto *P = dyn_cast<GlobalValue>(F.getPersonalityFn()->stripPointerCasts());
assert(P && "Expected personality function");
-
- // If we are forced to emit this personality, make sure to record
- // it because it might not appear in any landingpad
- if (forceEmitPersonality)
- MMI->addPersonality(P);
+ // Record the personality function.
+ addPersonality(P);
const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering();
unsigned PerEncoding = TLOF.getPersonalityEncoding();
const Instruction *FirstI = LandingPad->getBasicBlock()->getFirstNonPHI();
if (const auto *LPI = dyn_cast<LandingPadInst>(FirstI)) {
- if (const auto *PF =
- dyn_cast<Function>(F.getPersonalityFn()->stripPointerCasts()))
- getMMI().addPersonality(PF);
-
// If there's no typeid list specified, then "cleanup" is implicit.
// Otherwise, id 0 is reserved for the cleanup action.
if (LPI->isCleanup() && LPI->getNumClauses() != 0)
}
void MachineModuleInfo::finalize() {
- Personalities.clear();
-
Context.reset();
// We don't clear the ExternalContext.
MachineModuleInfo::~MachineModuleInfo() { finalize(); }
-/// \name Exception Handling
-/// \{
-
-void MachineModuleInfo::addPersonality(const Function *Personality) {
- if (!llvm::is_contained(Personalities, Personality))
- Personalities.push_back(Personality);
-}
-
-/// \}
-
MachineFunction *
MachineModuleInfo::getMachineFunction(const Function &F) const {
auto I = MachineFunctions.find(&F);