xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenCXX/windows-itanium-exceptions.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -emit-llvm -triple thumbv7-windows-itanium -fexceptions -fcxx-exceptions %s -o - | FileCheck %s
2*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -emit-llvm -triple i686-windows-itanium -fexceptions -fcxx-exceptions %s -o - | FileCheck %s
3*0a6a1f1dSLionel Sambuc // REQUIRES: asserts
4*0a6a1f1dSLionel Sambuc 
except()5*0a6a1f1dSLionel Sambuc void except() {
6*0a6a1f1dSLionel Sambuc   throw 32;
7*0a6a1f1dSLionel Sambuc }
8*0a6a1f1dSLionel Sambuc 
attempt()9*0a6a1f1dSLionel Sambuc void attempt() {
10*0a6a1f1dSLionel Sambuc   try { except(); } catch (...) { }
11*0a6a1f1dSLionel Sambuc }
12*0a6a1f1dSLionel Sambuc 
13*0a6a1f1dSLionel Sambuc // CHECK: @_ZTIi = external constant i8*
14*0a6a1f1dSLionel Sambuc 
15*0a6a1f1dSLionel Sambuc // CHECK: define {{.*}}void @_Z6exceptv() {{.*}} {
16*0a6a1f1dSLionel Sambuc // CHECK:   %exception = call {{.*}}i8* @__cxa_allocate_exception(i32 4)
17*0a6a1f1dSLionel Sambuc // CHECK:   %0 = bitcast i8* %exception to i32*
18*0a6a1f1dSLionel Sambuc // CHECK:   store i32 32, i32* %0
19*0a6a1f1dSLionel Sambuc // CHECK:   call {{.*}}void @__cxa_throw(i8* %exception, i8* bitcast (i8** @_ZTIi to i8*), i8* null)
20*0a6a1f1dSLionel Sambuc // CHECK:   unreachable
21*0a6a1f1dSLionel Sambuc // CHECK: }
22*0a6a1f1dSLionel Sambuc 
23*0a6a1f1dSLionel Sambuc // CHECK: define {{.*}}void @_Z7attemptv() {{.*}} {
24*0a6a1f1dSLionel Sambuc // CHECK:   %exn.slot = alloca i8*
25*0a6a1f1dSLionel Sambuc // CHECK:   %ehselector.slot = alloca i32
26*0a6a1f1dSLionel Sambuc // CHECK:   invoke {{.*}}void @_Z6exceptv()
27*0a6a1f1dSLionel Sambuc // CHECK:     to label %invoke.cont unwind label %lpad
28*0a6a1f1dSLionel Sambuc // CHECK: invoke.cont:
29*0a6a1f1dSLionel Sambuc // CHECK:    br label %try.cont
30*0a6a1f1dSLionel Sambuc // CHECK: lpad:
31*0a6a1f1dSLionel Sambuc // CHECK:    %0 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
32*0a6a1f1dSLionel Sambuc // CHECK:      catch i8* null
33*0a6a1f1dSLionel Sambuc // CHECK:    %1 = extractvalue { i8*, i32 } %0, 0
34*0a6a1f1dSLionel Sambuc // CHECK:    store i8* %1, i8** %exn.slot
35*0a6a1f1dSLionel Sambuc // CHECK:    %2 = extractvalue { i8*, i32 } %0, 1
36*0a6a1f1dSLionel Sambuc // CHECK:    store i32 %2, i32* %ehselector.slot
37*0a6a1f1dSLionel Sambuc // CHECK:    br label %catch
38*0a6a1f1dSLionel Sambuc // CHECK: catch:
39*0a6a1f1dSLionel Sambuc // CHECK:    %exn = load i8** %exn.slot
40*0a6a1f1dSLionel Sambuc // CHECK:    %3 = call {{.*}}i8* @__cxa_begin_catch(i8* %{{2|exn}})
41*0a6a1f1dSLionel Sambuc // CHECK:    call {{.*}}void @__cxa_end_catch()
42*0a6a1f1dSLionel Sambuc // CHECK:    br label %try.cont
43*0a6a1f1dSLionel Sambuc // CHECK: try.cont:
44*0a6a1f1dSLionel Sambuc // CHECK:    ret void
45*0a6a1f1dSLionel Sambuc // CHECK: }
46*0a6a1f1dSLionel Sambuc 
47*0a6a1f1dSLionel Sambuc 
48