llvm.org GIT mirror llvm / 0f16f3c
[WinEH] Don't visit the same catchswitch twice We visited the same catchswitch twice because it was both the child of another funclet and the predecessor of a cleanuppad. Instead, change the numbering algorithm to only recurse if the unwind destination of the inner funclet agrees with the unwind destination of the catchswitch. This fixes PR25926. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256317 91177308-0d34-0410-b5e6-96231b3b80d8 David Majnemer 4 years ago
2 changed file(s) with 70 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
164164 continue;
165165
166166 auto &BBColors = BlockColors[&BB];
167 assert(BBColors.size() == 1 &&
168 "multi-color BB not removed by preparation");
167 assert(BBColors.size() == 1 && "multi-color BB not removed by preparation");
169168 BasicBlock *FuncletEntryBB = BBColors.front();
170169
171170 BasicBlock *FuncletUnwindDest;
248247 FuncInfo.FuncletBaseStateMap[CatchPad] = CatchLow;
249248 for (const User *U : CatchPad->users()) {
250249 const auto *UserI = cast(U);
251 if (UserI->isEHPad())
252 calculateCXXStateNumbers(FuncInfo, UserI, CatchLow);
250 if (auto *InnerCatchSwitch = dyn_cast(UserI))
251 if (InnerCatchSwitch->getUnwindDest() == CatchSwitch->getUnwindDest())
252 calculateCXXStateNumbers(FuncInfo, UserI, CatchLow);
253 if (auto *InnerCleanupPad = dyn_cast(UserI))
254 if (getCleanupRetUnwindDest(InnerCleanupPad) ==
255 CatchSwitch->getUnwindDest())
256 calculateCXXStateNumbers(FuncInfo, UserI, CatchLow);
253257 }
254258 }
255259 int CatchHigh = FuncInfo.getLastStateNumber();
346350 // outside the __try.
347351 for (const User *U : CatchPad->users()) {
348352 const auto *UserI = cast(U);
349 if (UserI->isEHPad()) {
350 calculateSEHStateNumbers(FuncInfo, UserI, ParentState);
351 }
353 if (auto *InnerCatchSwitch = dyn_cast(UserI))
354 if (InnerCatchSwitch->getUnwindDest() == CatchSwitch->getUnwindDest())
355 calculateSEHStateNumbers(FuncInfo, UserI, ParentState);
356 if (auto *InnerCleanupPad = dyn_cast(UserI))
357 if (getCleanupRetUnwindDest(InnerCleanupPad) ==
358 CatchSwitch->getUnwindDest())
359 calculateSEHStateNumbers(FuncInfo, UserI, ParentState);
352360 }
353361 } else {
354362 auto *CleanupPad = cast(FirstNonPHI);
7878 ; CHECK-NEXT: ret i32 0
7979 ; CHECK-NOT: __ehhandler$nopads
8080
81 ; CHECK-LABEL: define void @PR25926()
82 define void @PR25926() personality i32 (...)* @__CxxFrameHandler3 {
83 entry:
84 ; CHECK: entry:
85 ; CHECK: store i32 -1
86 ; CHECK: store i32 0
87 ; CHECK: invoke void @_CxxThrowException(
88 invoke void @_CxxThrowException(i8* null, %eh.ThrowInfo* null)
89 to label %unreachable unwind label %catch.dispatch
90
91 catch.dispatch: ; preds = %entry
92 %0 = catchswitch within none [label %catch] unwind to caller
93
94 catch: ; preds = %catch.dispatch
95 %1 = catchpad within %0 [i8* null, i32 64, i8* null]
96 ; CHECK: catch:
97 ; CHECK: store i32 3
98 ; CHECK: invoke void @_CxxThrowException(
99 invoke void @_CxxThrowException(i8* null, %eh.ThrowInfo* null) [ "funclet"(token %1) ]
100 to label %unreachable1 unwind label %catch.dispatch1
101
102 catch.dispatch1: ; preds = %catch
103 %2 = catchswitch within %1 [label %catch2] unwind label %ehcleanup
104
105 catch2: ; preds = %catch.dispatch1
106 %3 = catchpad within %2 [i8* null, i32 64, i8* null]
107 catchret from %3 to label %try.cont
108
109 try.cont: ; preds = %catch2
110 ; CHECK: try.cont:
111 ; CHECK: store i32 1
112 ; CHECK: call void @dtor()
113 call void @dtor() #3 [ "funclet"(token %1) ]
114 catchret from %1 to label %try.cont4
115
116 try.cont4: ; preds = %try.cont
117 ret void
118
119 ehcleanup: ; preds = %catch.dispatch1
120 %4 = cleanuppad within %1 []
121 ; CHECK: ehcleanup:
122 ; CHECK: store i32 -1
123 ; CHECK: call void @dtor()
124 call void @dtor() #3 [ "funclet"(token %4) ]
125 cleanupret from %4 unwind to caller
126
127 unreachable: ; preds = %entry
128 unreachable
129
130 unreachable1: ; preds = %catch
131 unreachable
132 }
133
81134 declare void @g(i32) #0
135
136 declare void @dtor()
82137
83138 declare x86_stdcallcc void @_CxxThrowException(i8*, %eh.ThrowInfo*)
84139