summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2015-04-10 04:56:17 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2015-04-10 04:56:17 +0000
commit5c65f58f6487dd5d9dec43d927dd9842e8b72ba2 (patch)
tree9f097c1e08e0f63bdcf5adf26c1d4f952e8d17d2
parentbd38544c0a19aaa1554f9be93e5ff22e2f358cbd (diff)
downloadbcm5719-llvm-5c65f58f6487dd5d9dec43d927dd9842e8b72ba2.tar.gz
bcm5719-llvm-5c65f58f6487dd5d9dec43d927dd9842e8b72ba2.zip
[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. llvm-svn: 234566
-rw-r--r--llvm/include/llvm/CodeGen/WinEHFuncInfo.h6
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/Win64Exception.cpp6
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp14
3 files changed, 19 insertions, 7 deletions
diff --git a/llvm/include/llvm/CodeGen/WinEHFuncInfo.h b/llvm/include/llvm/CodeGen/WinEHFuncInfo.h
index 9b826754015..5fc2b126db8 100644
--- a/llvm/include/llvm/CodeGen/WinEHFuncInfo.h
+++ b/llvm/include/llvm/CodeGen/WinEHFuncInfo.h
@@ -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) {}
};
}
diff --git a/llvm/lib/CodeGen/AsmPrinter/Win64Exception.cpp b/llvm/lib/CodeGen/AsmPrinter/Win64Exception.cpp
index a685d2e23d5..39f7875cb3f 100644
--- a/llvm/lib/CodeGen/AsmPrinter/Win64Exception.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/Win64Exception.cpp
@@ -343,7 +343,11 @@ void Win64Exception::emitCXXFrameHandler3Table(const MachineFunction *MF) {
}
}
- 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;
diff --git a/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp b/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
index 8eac8eb4f1b..65a67265d79 100644
--- a/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
@@ -275,11 +275,15 @@ void FunctionLoweringInfo::set(const Function &fn, MachineFunction &mf,
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());
+ }
}
}
OpenPOWER on IntegriCloud