1 ; RUN: opt -winehprepare -S < %s | FileCheck %s 2 3 target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128" 4 target triple = "x86_64-pc-windows-msvc" 5 6 ; Modified based on this code: 7 ; struct HasDtor { 8 ; ~HasDtor(); 9 ; }; 10 ; extern "C" void may_throw(); 11 ; int main() { 12 ; try { 13 ; HasDtor o; 14 ; may_throw(); 15 ; } catch (int) { 16 ; } 17 ; } 18 19 %rtti.TypeDescriptor2 = type { i8**, i8*, [3 x i8] } 20 %eh.CatchHandlerType = type { i32, i8* } 21 %struct.HasDtor = type { i8 } 22 23 $"\01??_R0H@8" = comdat any 24 25 @"\01??_7type_info@@6B@" = external constant i8* 26 @"\01??_R0H@8" = linkonce_odr global %rtti.TypeDescriptor2 { i8** @"\01??_7type_info@@6B@", i8* null, [3 x i8] c".H\00" }, comdat 27 @llvm.eh.handlertype.H.0 = private unnamed_addr constant %eh.CatchHandlerType { i32 0, i8* bitcast (%rtti.TypeDescriptor2* @"\01??_R0H@8" to i8*) }, section "llvm.metadata" 28 29 define i32 @main() { 30 entry: 31 %o = alloca %struct.HasDtor, align 1 32 invoke void @may_throw() 33 to label %invoke.cont2 unwind label %lpad1 34 35 invoke.cont2: ; preds = %invoke.cont 36 call void @"\01??1HasDtor@@QEAA@XZ"(%struct.HasDtor* %o) 37 br label %try.cont 38 39 lpad: ; preds = %entry 40 %0 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) 41 catch %eh.CatchHandlerType* @llvm.eh.handlertype.H.0 42 %1 = extractvalue { i8*, i32 } %0, 0 43 %2 = extractvalue { i8*, i32 } %0, 1 44 br label %catch.dispatch 45 46 lpad1: ; preds = %invoke.cont 47 %3 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) 48 cleanup 49 catch %eh.CatchHandlerType* @llvm.eh.handlertype.H.0 50 %4 = extractvalue { i8*, i32 } %3, 0 51 %5 = extractvalue { i8*, i32 } %3, 1 52 invoke void @"\01??1HasDtor@@QEAA@XZ"(%struct.HasDtor* %o) 53 to label %catch.dispatch unwind label %lpad 54 55 catch.dispatch: ; preds = %lpad1, %lpad 56 %exn.slot.0 = phi i8* [ %4, %lpad1 ], [ %1, %lpad ] 57 %ehselector.slot.0 = phi i32 [ %5, %lpad1 ], [ %2, %lpad ] 58 %6 = call i32 @llvm.eh.typeid.for(i8* bitcast (%eh.CatchHandlerType* @llvm.eh.handlertype.H.0 to i8*)) 59 %matches = icmp eq i32 %ehselector.slot.0, %6 60 br i1 %matches, label %catch, label %eh.resume 61 62 catch: ; preds = %catch.dispatch 63 call void @llvm.eh.begincatch(i8* %exn.slot.0, i8* null) 64 call void @llvm.eh.endcatch() 65 br label %try.cont 66 67 try.cont: ; preds = %catch, %invoke.cont2 68 ret i32 0 69 70 eh.resume: ; preds = %catch.dispatch 71 %lpad.val = insertvalue { i8*, i32 } undef, i8* %exn.slot.0, 0 72 %lpad.val5 = insertvalue { i8*, i32 } %lpad.val, i32 %ehselector.slot.0, 1 73 resume { i8*, i32 } %lpad.val5 74 } 75 76 ; CHECK-LABEL: define i32 @main() 77 ; CHECK: @llvm.eh.actions(i32 0, void (i8*, i8*)* @main.cleanup, i32 1, i8* bitcast (%eh.CatchHandlerType* @llvm.eh.handlertype.H.0 to i8*), i32 -1, i8* (i8*, i8*)* @main.catch) 78 79 ; CHECK-LABEL: define internal void @main.cleanup(i8*, i8*) 80 ; CHECK: call void @"\01??1HasDtor@@QEAA@XZ"(%struct.HasDtor* %{{.*}}) 81 ; CHECK: ret void 82 83 declare void @may_throw() 84 85 declare i32 @__CxxFrameHandler3(...) 86 87 declare void @"\01??1HasDtor@@QEAA@XZ"(%struct.HasDtor*) 88 89 declare i32 @llvm.eh.typeid.for(i8*) 90 declare void @llvm.eh.begincatch(i8* nocapture, i8* nocapture) 91 declare void @llvm.eh.endcatch() 92