[WinEH] Pull Adjectives and CatchObj out of the catchpad arg list
[oota-llvm.git] / lib / CodeGen / SelectionDAG / FunctionLoweringInfo.cpp
index fe359777a361de79f28a991570397c58fdb63e63..baf9ee990ea91d46c9041c314d0b761f4f00fa3d 100644 (file)
@@ -294,11 +294,18 @@ void FunctionLoweringInfo::set(const Function &fn, MachineFunction &mf,
     calculateSEHStateNumbers(WinEHParentFn, EHInfo);
 
   // Map all BB references in the WinEH data to MBBs.
-  for (WinEHTryBlockMapEntry &TBME : EHInfo.TryBlockMap)
-    for (WinEHHandlerType &H : TBME.HandlerArray)
-      if (const auto *BB =
-              dyn_cast<BasicBlock>(H.Handler.get<const Value *>()))
+  for (WinEHTryBlockMapEntry &TBME : EHInfo.TryBlockMap) {
+    for (WinEHHandlerType &H : TBME.HandlerArray) {
+      if (H.CatchObjRecoverIdx == -2 && H.CatchObj.Alloca) {
+        assert(StaticAllocaMap.count(H.CatchObj.Alloca));
+        H.CatchObj.FrameIndex = StaticAllocaMap[H.CatchObj.Alloca];
+      } else {
+        H.CatchObj.FrameIndex = INT_MAX;
+      }
+      if (const auto *BB = dyn_cast<BasicBlock>(H.Handler.get<const Value *>()))
         H.Handler = MBBMap[BB];
+    }
+  }
   for (WinEHUnwindMapEntry &UME : EHInfo.UnwindMap)
     if (UME.Cleanup)
       if (const auto *BB = dyn_cast<BasicBlock>(UME.Cleanup.get<const Value *>()))