-
-/// getPersonality - Return the personality function for the current function.
-const Function *MachineModuleInfo::getPersonality() const {
- for (const LandingPadInfo &LPI : LandingPads)
- if (LPI.Personality)
- return LPI.Personality;
- return nullptr;
-}
-
-EHPersonality MachineModuleInfo::getPersonalityType() {
- if (PersonalityTypeCache == EHPersonality::Unknown) {
- if (const Function *F = getPersonality())
- PersonalityTypeCache = classifyEHPersonality(F);
- }
- return PersonalityTypeCache;
-}
-
-/// getPersonalityIndex - Return unique index for current personality
-/// function. NULL/first personality function should always get zero index.
-unsigned MachineModuleInfo::getPersonalityIndex() const {
- const Function* Personality = nullptr;
-
- // Scan landing pads. If there is at least one non-NULL personality - use it.
- for (unsigned i = 0, e = LandingPads.size(); i != e; ++i)
- if (LandingPads[i].Personality) {
- Personality = LandingPads[i].Personality;
- break;
- }
-
- for (unsigned i = 0, e = Personalities.size(); i < e; ++i) {
- if (Personalities[i] == Personality)
- return i;
- }
-
- // This will happen if the current personality function is
- // in the zero index.
- return 0;
-}
-
-const Function *MachineModuleInfo::getWinEHParent(const Function *F) const {
- StringRef WinEHParentName =
- F->getFnAttribute("wineh-parent").getValueAsString();
- if (WinEHParentName.empty() || WinEHParentName == F->getName())
- return F;
- return F->getParent()->getFunction(WinEHParentName);
-}
-
-WinEHFuncInfo &MachineModuleInfo::getWinEHFuncInfo(const Function *F) {
- auto &Ptr = FuncInfoMap[getWinEHParent(F)];
- if (!Ptr)
- Ptr.reset(new WinEHFuncInfo);
- return *Ptr;
-}