int UnwindHelpFrameIdx;
int UnwindHelpFrameOffset;
- WinEHFuncInfo() : UnwindHelpFrameIdx(INT_MAX), UnwindHelpFrameOffset(-1) {}
+ unsigned NumIPToStateFuncsVisited;
+
+ WinEHFuncInfo()
+ : UnwindHelpFrameIdx(INT_MAX), UnwindHelpFrameOffset(-1),
+ NumIPToStateFuncsVisited(0) {}
};
}
}
}
- if (ParentF != F)
+ // Defer emission until we've visited the parent function and all the catch
+ // handlers.
+ if (ParentF == F || FuncInfo.CatchHandlerMaxState.count(F))
+ ++FuncInfo.NumIPToStateFuncsVisited;
+ if (FuncInfo.NumIPToStateFuncsVisited != FuncInfo.CatchHandlerMaxState.size())
return;
MCSymbol *UnwindMapXData = nullptr;
MBBMap[Invoke->getSuccessor(1)]->setIsLandingPad();
// Calculate EH numbers for WinEH.
- if (fn.getFnAttribute("wineh-parent").getValueAsString() == fn.getName()) {
- WinEHNumbering Num(MMI.getWinEHFuncInfo(&fn));
- Num.calculateStateNumbers(fn);
- // Pop everything on the handler stack.
- Num.processCallSite(None, ImmutableCallSite());
+ if (fn.hasFnAttribute("wineh-parent")) {
+ const Function *WinEHParentFn = MMI.getWinEHParent(&fn);
+ WinEHFuncInfo &FI = MMI.getWinEHFuncInfo(WinEHParentFn);
+ if (FI.LandingPadStateMap.empty()) {
+ WinEHNumbering Num(FI);
+ Num.calculateStateNumbers(*WinEHParentFn);
+ // Pop everything on the handler stack.
+ Num.processCallSite(None, ImmutableCallSite());
+ }
}
}