[WinEH] Minor bug fixes.
authorAndrew Kaylor <andrew.kaylor@intel.com>
Wed, 8 Apr 2015 20:57:22 +0000 (20:57 +0000)
committerAndrew Kaylor <andrew.kaylor@intel.com>
Wed, 8 Apr 2015 20:57:22 +0000 (20:57 +0000)
Fixed insert point for allocas created for demoted values.
Clear the nested landing pad list after it has been processed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234433 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/WinEHPrepare.cpp
test/CodeGen/WinEH/cppeh-nonalloca-frame-values.ll

index 1133151ca77265b32a34711323617eaa8f3a89d9..84c10bfceca902d868e00fa0b0f366cb73520a63 100644 (file)
@@ -499,6 +499,7 @@ bool WinEHPrepare::prepareExceptionHandlers(
   // cleans up references to outlined blocks that will be deleted.
   for (auto &LPadPair : NestedLPtoOriginalLP)
     completeNestedLandingPad(&F, LPadPair.first, LPadPair.second, FrameVarInfo);
+  NestedLPtoOriginalLP.clear();
 
   F.addFnAttr("wineh-parent", F.getName());
 
@@ -554,10 +555,10 @@ bool WinEHPrepare::prepareExceptionHandlers(
           ++InsertPt;
           ParentAlloca =
               new AllocaInst(ParentInst->getType(), nullptr,
-                             ParentInst->getName() + ".reg2mem", InsertPt);
+                             ParentInst->getName() + ".reg2mem", AllocaInsertPt);
           new StoreInst(ParentInst, ParentAlloca, InsertPt);
         } else {
-          ParentAlloca = DemoteRegToStack(*ParentInst, true, ParentInst);
+          ParentAlloca = DemoteRegToStack(*ParentInst, true, AllocaInsertPt);
         }
       }
     }
index 2c629d831950472c0c78e5efdcdb58a733c3c8eb..6382a872a6401bf2aab6aa9f8547f3cdc4e42351 100644 (file)
@@ -55,6 +55,8 @@ $"\01??_R0H@8" = comdat any
 ; CHECK: entry:
 ; CHECK:   [[NUMEXCEPTIONS_REGMEM:\%.+]] = alloca i32
 ; CHECK:   [[I_REGMEM:\%.+]] = alloca i32
+; CHECK:   [[A_REGMEM:\%.+]] = alloca i32*
+; CHECK:   [[B_REGMEM:\%.+]] = alloca i32*
 ; CHECK:   [[E_PTR:\%.+]] = alloca i32, align 4
 ; CHECK:   [[EXCEPTIONVAL:\%.+]] = alloca [10 x i32], align 16
 ; CHECK:   [[DATA_PTR:\%.+]] = alloca i64, align 8
@@ -62,11 +64,9 @@ $"\01??_R0H@8" = comdat any
 ; CHECK:   [[TMP:\%.+]] = bitcast [10 x i32]* [[EXCEPTIONVAL]] to i8*
 ; CHECK:   call void @llvm.lifetime.start(i64 40, i8* [[TMP]])
 ; CHECK:   store i64 0, i64* [[DATA_PTR]], align 8
-; CHECK:   [[A_REGMEM:\%.+]] = alloca i32*
 ; CHECK:   [[A_PTR:\%.+]] = bitcast i64* [[DATA_PTR]] to i32*
 ; CHECK:   store i32* [[A_PTR]], i32** [[A_REGMEM]]
 ; CHECK:   [[B_PTR:\%.+]] = getelementptr inbounds %struct.SomeData, %struct.SomeData* [[TMPCAST]], i64 0, i32 1
-; CHECK:   [[B_REGMEM:\%.+]] = alloca i32*
 ; CHECK:   store i32* [[B_PTR]], i32** [[B_REGMEM]]
 ; CHECK:   store i32 0, i32* [[NUMEXCEPTIONS_REGMEM]]
 ; CHECK:   store i32 0, i32* [[I_REGMEM]]