[llvm] r234566 - [WinEHPrepare] Don't rely on the order of IR
David Majnemer
david.majnemer at gmail.com
Thu Apr 9 21:56:17 PDT 2015
Author: majnemer
Date: Thu Apr 9 23:56:17 2015
New Revision: 234566
URL: http://llvm.org/viewvc/llvm-project?rev=234566&view=rev
Log:
[WinEHPrepare] Don't rely on the order of IR
The IPToState table must be emitted after we have generated labels for
all functions in the table. Don't rely on the order of the list of
globals. Instead, utilize WinEHFuncInfo to tell us how many catch
handlers we expect to outline. Once we know we've visited all the catch
handlers, emit the cppxdata.
Modified:
llvm/trunk/include/llvm/CodeGen/WinEHFuncInfo.h
llvm/trunk/lib/CodeGen/AsmPrinter/Win64Exception.cpp
llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
Modified: llvm/trunk/include/llvm/CodeGen/WinEHFuncInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/WinEHFuncInfo.h?rev=234566&r1=234565&r2=234566&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/WinEHFuncInfo.h (original)
+++ llvm/trunk/include/llvm/CodeGen/WinEHFuncInfo.h Thu Apr 9 23:56:17 2015
@@ -142,7 +142,11 @@ struct WinEHFuncInfo {
int UnwindHelpFrameIdx;
int UnwindHelpFrameOffset;
- WinEHFuncInfo() : UnwindHelpFrameIdx(INT_MAX), UnwindHelpFrameOffset(-1) {}
+ unsigned NumIPToStateFuncsVisited;
+
+ WinEHFuncInfo()
+ : UnwindHelpFrameIdx(INT_MAX), UnwindHelpFrameOffset(-1),
+ NumIPToStateFuncsVisited(0) {}
};
}
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/Win64Exception.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/Win64Exception.cpp?rev=234566&r1=234565&r2=234566&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/Win64Exception.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/Win64Exception.cpp Thu Apr 9 23:56:17 2015
@@ -343,7 +343,11 @@ void Win64Exception::emitCXXFrameHandler
}
}
- 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;
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp?rev=234566&r1=234565&r2=234566&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp Thu Apr 9 23:56:17 2015
@@ -275,11 +275,15 @@ void FunctionLoweringInfo::set(const Fun
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());
+ }
}
}
More information about the llvm-commits
mailing list