1 ; ModuleID = 'exception.cpp' 2 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" 3 target triple = "x86_64-pc-linux-gnu" 4 5 @_ZTIi = external constant i8* 6 7 ; Function Attrs: uwtable 8 define i32 @main(i32 %argc, i8** %argv) #0 { 9 %1 = alloca i32, align 4 ; CHECK: !dbg 10 %2 = alloca i32, align 4 ; CHECK-NEXT: !dbg 11 %3 = alloca i8**, align 8 ; CHECK-NEXT: !dbg 12 %4 = alloca i8* ; CHECK-NEXT: !dbg 13 %5 = alloca i32 ; CHECK-NEXT: !dbg 14 %e = alloca i32, align 4 ; CHECK-NEXT: !dbg 15 %6 = alloca i32 ; CHECK-NEXT: !dbg 16 store i32 0, i32* %1 ; CHECK-NEXT: !dbg 17 store i32 %argc, i32* %2, align 4 ; CHECK-NEXT: !dbg 18 store i8** %argv, i8*** %3, align 8 ; CHECK-NEXT: !dbg 19 %7 = call i8* @__cxa_allocate_exception(i64 4) #2 ; CHECK-NEXT: !dbg 20 %8 = bitcast i8* %7 to i32* ; CHECK-NEXT: !dbg 21 %9 = load i32* %2, align 4 ; CHECK-NEXT: !dbg 22 store i32 %9, i32* %8 ; CHECK-NEXT: !dbg 23 invoke void @__cxa_throw(i8* %7, i8* bitcast (i8** @_ZTIi to i8*), i8* null) #3 24 to label %31 unwind label %10 ; CHECK: !dbg 25 26 ; <label>:10 ; preds = %0 27 %11 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) 28 catch i8* bitcast (i8** @_ZTIi to i8*) ; CHECK: !dbg 29 %12 = extractvalue { i8*, i32 } %11, 0 ; CHECK-NEXT: !dbg 30 store i8* %12, i8** %4 ; CHECK-NEXT: !dbg 31 %13 = extractvalue { i8*, i32 } %11, 1 ; CHECK-NEXT: !dbg 32 store i32 %13, i32* %5 ; CHECK-NEXT: !dbg 33 br label %14 ; CHECK-NEXT: !dbg 34 35 ; <label>:14 ; preds = %10 36 %15 = load i32* %5 ; CHECK: !dbg 37 %16 = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*)) #2 ; CHECK-NEXT: !dbg 38 %17 = icmp eq i32 %15, %16 ; CHECK-NEXT: !dbg 39 br i1 %17, label %18, label %26 ; CHECK-NEXT: !dbg 40 41 ; <label>:18 ; preds = %14 42 %19 = load i8** %4 ; CHECK: !dbg 43 %20 = call i8* @__cxa_begin_catch(i8* %19) #2 ; CHECK-NEXT: !dbg 44 %21 = bitcast i8* %20 to i32* ; CHECK-NEXT: !dbg 45 %22 = load i32* %21, align 4 ; CHECK-NEXT: !dbg 46 store i32 %22, i32* %e, align 4 ; CHECK-NEXT: !dbg 47 %23 = load i32* %e, align 4 ; CHECK-NEXT: !dbg 48 store i32 %23, i32* %1 ; CHECK-NEXT: !dbg 49 store i32 1, i32* %6 ; CHECK-NEXT: !dbg 50 call void @__cxa_end_catch() #2 ; CHECK-NEXT: !dbg 51 br label %24 ; CHECK-NEXT: !dbg 52 53 ; <label>:24 ; preds = %18 54 %25 = load i32* %1 ; CHECK: !dbg 55 ret i32 %25 ; CHECK-NEXT: !dbg 56 57 ; <label>:26 ; preds = %14 58 %27 = load i8** %4 ; CHECK: !dbg 59 %28 = load i32* %5 ; CHECK-NEXT: !dbg 60 %29 = insertvalue { i8*, i32 } undef, i8* %27, 0 ; CHECK-NEXT: !dbg 61 %30 = insertvalue { i8*, i32 } %29, i32 %28, 1 ; CHECK-NEXT: !dbg 62 resume { i8*, i32 } %30 ; CHECK-NEXT: !dbg 63 64 ; <label>:31 ; preds = %0 65 unreachable ; CHECK: !dbg 66 } 67 68 declare i8* @__cxa_allocate_exception(i64) 69 70 declare void @__cxa_throw(i8*, i8*, i8*) 71 72 declare i32 @__gxx_personality_v0(...) 73 74 ; Function Attrs: nounwind readnone 75 declare i32 @llvm.eh.typeid.for(i8*) #1 76 77 declare i8* @__cxa_begin_catch(i8*) 78 79 declare void @__cxa_end_catch() 80 81 attributes #0 = { uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"="true" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" } 82 attributes #1 = { nounwind readnone } 83 attributes #2 = { nounwind } 84 attributes #3 = { noreturn } 85 ; CHECK: = metadata !{i32 16, 86 ; CHECK-NEXT: = metadata !{i32 17, 87 ; CHECK-NEXT: = metadata !{i32 18, 88 ; CHECK-NEXT: = metadata !{i32 19, 89 ; CHECK-NEXT: = metadata !{i32 20, 90 ; CHECK-NEXT: = metadata !{i32 21, 91 ; CHECK-NEXT: = metadata !{i32 22, 92 ; CHECK-NEXT: = metadata !{i32 24, 93 94 ; CHECK-NEXT: = metadata !{i32 28, 95 ; CHECK-NEXT: = metadata !{i32 29, 96 ; CHECK-NEXT: = metadata !{i32 30, 97 ; CHECK-NEXT: = metadata !{i32 31, 98 ; CHECK-NEXT: = metadata !{i32 32, 99 ; CHECK-NEXT: = metadata !{i32 33, 100 101 ; CHECK-NEXT: = metadata !{i32 36, 102 ; CHECK-NEXT: = metadata !{i32 37, 103 ; CHECK-NEXT: = metadata !{i32 38, 104 ; CHECK-NEXT: = metadata !{i32 39, 105 106 ; CHECK-NEXT: = metadata !{i32 42, 107 ; CHECK-NEXT: = metadata !{i32 43, 108 ; CHECK-NEXT: = metadata !{i32 44, 109 ; CHECK-NEXT: = metadata !{i32 45, 110 ; CHECK-NEXT: = metadata !{i32 46, 111 ; CHECK-NEXT: = metadata !{i32 47, 112 ; CHECK-NEXT: = metadata !{i32 48, 113 ; CHECK-NEXT: = metadata !{i32 49, 114 ; CHECK-NEXT: = metadata !{i32 50, 115 ; CHECK-NEXT: = metadata !{i32 51, 116 117 ; CHECK-NEXT: = metadata !{i32 54, 118 ; CHECK-NEXT: = metadata !{i32 55, 119 120 ; CHECK-NEXT: = metadata !{i32 58, 121 ; CHECK-NEXT: = metadata !{i32 59, 122 ; CHECK-NEXT: = metadata !{i32 60, 123 ; CHECK-NEXT: = metadata !{i32 61, 124 ; CHECK-NEXT: = metadata !{i32 62, 125 ; CHECK-NEXT: = metadata !{i32 65, 126 127 ; RUN: opt %s -debug-ir -S | FileCheck %s 128