[llvm] r234067 - [WinEH] Fill out CatchHigh in the TryBlockMap
David Majnemer
david.majnemer at gmail.com
Fri Apr 3 16:37:34 PDT 2015
Author: majnemer
Date: Fri Apr 3 18:37:34 2015
New Revision: 234067
URL: http://llvm.org/viewvc/llvm-project?rev=234067&view=rev
Log:
[WinEH] Fill out CatchHigh in the TryBlockMap
Now all fields in the WinEH xdata have been filled out.
Modified:
llvm/trunk/include/llvm/CodeGen/WinEHFuncInfo.h
llvm/trunk/lib/CodeGen/AsmPrinter/Win64Exception.cpp
llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
llvm/trunk/test/CodeGen/WinEH/cppeh-prepared-catch.ll
Modified: llvm/trunk/include/llvm/CodeGen/WinEHFuncInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/WinEHFuncInfo.h?rev=234067&r1=234066&r2=234067&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/WinEHFuncInfo.h (original)
+++ llvm/trunk/include/llvm/CodeGen/WinEHFuncInfo.h Fri Apr 3 18:37:34 2015
@@ -128,7 +128,6 @@ struct WinEHHandlerType {
struct WinEHTryBlockMapEntry {
int TryLow;
int TryHigh;
- int CatchHigh;
SmallVector<WinEHHandlerType, 1> HandlerArray;
};
@@ -136,6 +135,7 @@ struct WinEHFuncInfo {
DenseMap<const LandingPadInst *, int> LandingPadStateMap;
DenseMap<const Function *, int> CatchHandlerParentFrameObjIdx;
DenseMap<const Function *, int> CatchHandlerParentFrameObjOffset;
+ DenseMap<const Function *, int> CatchHandlerMaxState;
SmallVector<WinEHUnwindMapEntry, 4> UnwindMap;
SmallVector<WinEHTryBlockMapEntry, 4> TryBlockMap;
SmallVector<std::pair<MCSymbol *, int>, 4> IPToStateList;
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/Win64Exception.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/Win64Exception.cpp?rev=234067&r1=234066&r2=234067&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/Win64Exception.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/Win64Exception.cpp Fri Apr 3 18:37:34 2015
@@ -421,11 +421,16 @@ void Win64Exception::emitCXXFrameHandler
HandlerMaps.push_back(HandlerMapXData);
+ int CatchHigh = -1;
+ for (WinEHHandlerType &HT : TBME.HandlerArray)
+ CatchHigh =
+ std::max(CatchHigh, FuncInfo.CatchHandlerMaxState[HT.Handler]);
+
assert(TBME.TryLow <= TBME.TryHigh);
- assert(TBME.CatchHigh > TBME.TryHigh);
+ assert(CatchHigh > TBME.TryHigh);
OS.EmitIntValue(TBME.TryLow, 4); // TryLow
OS.EmitIntValue(TBME.TryHigh, 4); // TryHigh
- OS.EmitIntValue(TBME.CatchHigh, 4); // CatchHigh
+ OS.EmitIntValue(CatchHigh, 4); // CatchHigh
OS.EmitIntValue(TBME.HandlerArray.size(), 4); // NumCatches
OS.EmitValue(createImageRel32(HandlerMapXData), 4); // HandlerArray
}
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp?rev=234067&r1=234066&r2=234067&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp Fri Apr 3 18:37:34 2015
@@ -300,11 +300,7 @@ void WinEHNumbering::createTryBlockMapEn
WinEHTryBlockMapEntry TBME;
TBME.TryLow = TryLow;
TBME.TryHigh = TryHigh;
- // FIXME: This should be revisited when we want to throw inside a catch
- // handler.
- TBME.CatchHigh = INT_MAX;
assert(TBME.TryLow <= TBME.TryHigh);
- assert(TBME.CatchHigh > TBME.TryHigh);
for (CatchHandler *CH : Handlers) {
WinEHHandlerType HT;
if (CH->getSelector()->isNullValue()) {
@@ -444,6 +440,8 @@ void WinEHNumbering::calculateStateNumbe
ActionList.clear();
FuncInfo.LandingPadStateMap[LPI] = currentEHNumber();
}
+
+ FuncInfo.CatchHandlerMaxState[&F] = NextState - 1;
}
/// clear - Clear out all the function-specific state. This returns this
Modified: llvm/trunk/test/CodeGen/WinEH/cppeh-prepared-catch.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WinEH/cppeh-prepared-catch.ll?rev=234067&r1=234066&r2=234067&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/WinEH/cppeh-prepared-catch.ll (original)
+++ llvm/trunk/test/CodeGen/WinEH/cppeh-prepared-catch.ll Fri Apr 3 18:37:34 2015
@@ -137,12 +137,12 @@ try.cont8:
; CHECK-NEXT:"$tryMap$?f@@YAXXZ":
; CHECK-NEXT: .long 1
; CHECK-NEXT: .long 1
-; CHECK-NEXT: .long 2147483647
+; CHECK-NEXT: .long 2
; CHECK-NEXT: .long 1
; CHECK-NEXT: .long ("$handlerMap$0$?f@@YAXXZ")@IMGREL
; CHECK-NEXT: .long 0
; CHECK-NEXT: .long 2
-; CHECK-NEXT: .long 2147483647
+; CHECK-NEXT: .long 3
; CHECK-NEXT: .long 1
; CHECK-NEXT: .long ("$handlerMap$1$?f@@YAXXZ")@IMGREL
; CHECK-NEXT:"$handlerMap$0$?f@@YAXXZ":
More information about the llvm-commits
mailing list