Home | History | Annotate | Download | only in WinEH
      1 ; RUN: opt -S -winehprepare -sehprepare < %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 @str.__except = internal unnamed_addr constant [9 x i8] c"__except\00", align 1
      7 
      8 ; Function Attrs: uwtable
      9 
     10 declare i32 @puts(i8*)
     11 
     12 define void @may_crash() {
     13 entry:
     14   store volatile i32 42, i32* null, align 4
     15   ret void
     16 }
     17 
     18 declare i32 @__C_specific_handler(...)
     19 
     20 ; Function Attrs: nounwind readnone
     21 declare i8* @llvm.frameaddress(i32)
     22 
     23 ; Function Attrs: uwtable
     24 define void @seh_catch_all() {
     25 entry:
     26   %exn.slot = alloca i8*
     27   %ehselector.slot = alloca i32
     28   invoke void @may_crash()
     29           to label %invoke.cont unwind label %lpad
     30 
     31 invoke.cont:                                      ; preds = %entry
     32   br label %__try.cont
     33 
     34 lpad:                                             ; preds = %entry
     35   %0 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*)
     36           catch i8* null
     37   %1 = extractvalue { i8*, i32 } %0, 0
     38   store i8* %1, i8** %exn.slot
     39   %2 = extractvalue { i8*, i32 } %0, 1
     40   store i32 %2, i32* %ehselector.slot
     41   br label %__except
     42 
     43 __except:                                         ; preds = %lpad
     44   %call = call i32 @puts(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @str.__except, i32 0, i32 0))
     45   br label %__try.cont
     46 
     47 __try.cont:                                       ; preds = %__except, %invoke.cont
     48   ret void
     49 }
     50 
     51 ; CHECK-LABEL: define void @seh_catch_all()
     52 ; CHECK: landingpad
     53 ; CHECK-NEXT: catch i8* null
     54 ; CHECK-NEXT: call i8* (...) @llvm.eh.actions(i32 1, i8* null, i32 -1, i8* blockaddress(@seh_catch_all, %catch.all))
     55 ; CHECK-NEXT: indirectbr
     56 ;
     57 ; CHECK: catch.all:
     58 ; CHECK-NOT: extractvalue
     59 ; CHECK: call i32 @puts
     60