for (SEHUnwindMapEntry &UME : FuncInfo.SEHUnwindMap) {
MCSymbol *ExceptOrFinally =
UME.Handler.get<MachineBasicBlock *>()->getSymbol();
- OS.EmitIntValue(UME.ToState, 4); // ToState
+ // -1 is usually the base state for "unwind to caller", but for
+ // _except_handler4 it's -2. Do that replacement here if necessary.
+ int ToState = UME.ToState == -1 ? BaseState : UME.ToState;
+ OS.EmitIntValue(ToState, 4); // ToState
OS.EmitValue(create32bitRef(UME.Filter), 4); // Filter
OS.EmitValue(create32bitRef(ExceptOrFinally), 4); // Except/Finally
}
define void @use_except_handler3() personality i32 (...)* @_except_handler3 {
entry:
invoke void @may_throw_or_crash()
- to label %cont unwind label %catchall
+ to label %cont unwind label %lpad
cont:
ret void
-catchall:
- %0 = landingpad { i8*, i32 }
- catch i8* bitcast (i32 ()* @catchall_filt to i8*)
- %1 = extractvalue { i8*, i32 } %0, 1
- %2 = call i32 @llvm.eh.typeid.for(i8* bitcast (i32 ()* @catchall_filt to i8*)) #4
- %matches = icmp eq i32 %1, %2
- br i1 %matches, label %cont, label %eh.resume
-eh.resume:
- resume { i8*, i32 } %0
+lpad:
+ %p = catchpad [i8* bitcast (i32 ()* @catchall_filt to i8*)]
+ to label %catch unwind label %endpad
+catch:
+ catchret %p to label %cont
+endpad:
+ catchendpad unwind to caller
}
; CHECK-LABEL: _use_except_handler3:
; CHECK: movl -28(%ebp), %[[next:[^ ,]*]]
; CHECK: movl %[[next]], %fs:0
; CHECK: retl
+; CHECK: LBB1_2: # %lpad{{$}}
; CHECK: .section .xdata,"dr"
; CHECK-LABEL: L__ehtable$use_except_handler3:
; CHECK-NEXT: .long -1
; CHECK-NEXT: .long _catchall_filt
-; CHECK-NEXT: .long Ltmp{{[0-9]+}}
+; CHECK-NEXT: .long LBB1_2
define void @use_except_handler4() personality i32 (...)* @_except_handler4 {
entry:
invoke void @may_throw_or_crash()
- to label %cont unwind label %catchall
+ to label %cont unwind label %lpad
cont:
ret void
-catchall:
- %0 = landingpad { i8*, i32 }
- catch i8* bitcast (i32 ()* @catchall_filt to i8*)
- %1 = extractvalue { i8*, i32 } %0, 1
- %2 = call i32 @llvm.eh.typeid.for(i8* bitcast (i32 ()* @catchall_filt to i8*)) #4
- %matches = icmp eq i32 %1, %2
- br i1 %matches, label %cont, label %eh.resume
-eh.resume:
- resume { i8*, i32 } %0
+lpad:
+ %p = catchpad [i8* bitcast (i32 ()* @catchall_filt to i8*)]
+ to label %catch unwind label %endpad
+catch:
+ catchret %p to label %cont
+endpad:
+ catchendpad unwind to caller
}
; CHECK-LABEL: _use_except_handler4:
; CHECK: movl -28(%ebp), %[[next:[^ ,]*]]
; CHECK: movl %[[next]], %fs:0
; CHECK: retl
+; CHECK: LBB2_2: # %lpad{{$}}
; CHECK: .section .xdata,"dr"
; CHECK-LABEL: L__ehtable$use_except_handler4:
; CHECK-NEXT: .long 0
; CHECK-NEXT: .long -2
; CHECK-NEXT: .long _catchall_filt
-; CHECK-NEXT: .long Ltmp{{[0-9]+}}
+; CHECK-NEXT: .long LBB2_2
define void @use_CxxFrameHandler3() personality i32 (...)* @__CxxFrameHandler3 {
invoke void @may_throw_or_crash()