forked from OSchip/llvm-project
[SEH] Fix _except_handler4 table base states
We got them right for the old IR, but not with funclets. Port the old test to the new IR and fix the code. llvm-svn: 249906
This commit is contained in:
parent
f6e237e606
commit
e1c8a7f9c7
|
@ -902,7 +902,10 @@ void WinException::emitExceptHandlerTable(const MachineFunction *MF) {
|
|||
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
|
||||
}
|
||||
|
|
|
@ -15,18 +15,16 @@ define internal i32 @catchall_filt() {
|
|||
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:
|
||||
|
@ -47,28 +45,27 @@ eh.resume:
|
|||
; 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:
|
||||
|
@ -89,6 +86,7 @@ eh.resume:
|
|||
; 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:
|
||||
|
@ -98,7 +96,7 @@ eh.resume:
|
|||
; 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()
|
||||
|
|
Loading…
Reference in New Issue