summaryrefslogtreecommitdiff
path: root/test/CodeGen/X86/catchpad-reuse.ll
blob: 4a72b895f304cc2d0300d6cbe2fe6fb2b0711b57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
; RUN: llc < %s | FileCheck %s

; IR generated by the following C++ source with modifications to reuse the 'v'
; alloca between catchpads:
; extern "C" void maythrow();
; int main() {
;   try {
;     try {
;       maythrow();
;     } catch (int v) {
;       maythrow();
;     }
;   } catch (int v) {
;     maythrow();
;   }
;   return 0;
; }

; CHECK: $cppxdata$main:
; CHECK-NEXT: .long   429065506               # MagicNumber
; CHECK-NEXT: .long   4                       # MaxState
; CHECK-NEXT: .long   ($stateUnwindMap$main)@IMGREL # UnwindMap
; CHECK-NEXT: .long   2                       # NumTryBlocks
; CHECK-NEXT: .long   ($tryMap$main)@IMGREL   # TryBlockMap
; CHECK-NEXT: .long   5                       # IPMapEntries
; CHECK-NEXT: .long   ($ip2state$main)@IMGREL # IPToStateXData
; CHECK-NEXT: .long   32                      # UnwindHelp
; CHECK-NEXT: .long   0                       # ESTypeList
; CHECK-NEXT: .long   1                       # EHFlags

; CHECK: $tryMap$main:
; CHECK-NEXT: .long   1                       # TryLow
; CHECK-NEXT: .long   1                       # TryHigh
; CHECK-NEXT: .long   2                       # CatchHigh
; CHECK-NEXT: .long   1                       # NumCatches
; CHECK-NEXT: .long   ($handlerMap$0$main)@IMGREL # HandlerArray
; CHECK-NEXT: .long   0                       # TryLow
; CHECK-NEXT: .long   2                       # TryHigh
; CHECK-NEXT: .long   3                       # CatchHigh
; CHECK-NEXT: .long   1                       # NumCatches
; CHECK-NEXT: .long   ($handlerMap$1$main)@IMGREL # HandlerArray

; CHECK: $handlerMap$0$main:
; CHECK-NEXT: .long   0                       # Adjectives
; CHECK-NEXT: .long   "??_R0H@8"@IMGREL       # Type
; CHECK-NEXT: .long   [[v_offset:[0-9]+]]     # CatchObjOffset
; CHECK-NEXT: .long   "?catch$2@?0?main@4HA"@IMGREL # Handler
; CHECK-NEXT: .long   {{.*}}                  # ParentFrameOffset

; CHECK: $handlerMap$1$main:
; CHECK-NEXT: .long   0                       # Adjectives
; CHECK-NEXT: .long   "??_R0H@8"@IMGREL       # Type
; CHECK-NEXT: .long   [[v_offset]]            # CatchObjOffset
; CHECK-NEXT: .long   "?catch$4@?0?main@4HA"@IMGREL # Handler
; CHECK-NEXT: .long   {{.*}}                      # ParentFrameOffset

; ModuleID = 't.cpp'
source_filename = "t.cpp"
target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-windows-msvc19.0.24210"

%rtti.TypeDescriptor2 = type { i8**, i8*, [3 x i8] }

$"\01??_R0H@8" = comdat any

@"\01??_7type_info@@6B@" = external constant i8*
@"\01??_R0H@8" = linkonce_odr global %rtti.TypeDescriptor2 { i8** @"\01??_7type_info@@6B@", i8* null, [3 x i8] c".H\00" }, comdat

; Function Attrs: norecurse uwtable
define i32 @main() local_unnamed_addr personality i32 (...)* @__CxxFrameHandler3 {
entry:
  %v = alloca i32, align 4
  invoke void @maythrow()
          to label %try.cont6 unwind label %catch.dispatch

catch.dispatch:                                   ; preds = %entry
  %0 = catchswitch within none [label %catch] unwind label %catch.dispatch2

catch:                                            ; preds = %catch.dispatch
  %1 = catchpad within %0 [%rtti.TypeDescriptor2* @"\01??_R0H@8", i32 0, i32* %v]
  invoke void @maythrow() [ "funclet"(token %1) ]
          to label %invoke.cont1 unwind label %catch.dispatch2

catch.dispatch2:                                  ; preds = %catch, %catch.dispatch
  %2 = catchswitch within none [label %catch3] unwind to caller

catch3:                                           ; preds = %catch.dispatch2
  %3 = catchpad within %2 [%rtti.TypeDescriptor2* @"\01??_R0H@8", i32 0, i32* %v]
  call void @maythrow() [ "funclet"(token %3) ]
  catchret from %3 to label %try.cont6

try.cont6:                                        ; preds = %entry, %invoke.cont1, %catch3
  ret i32 0

invoke.cont1:                                     ; preds = %catch
  catchret from %1 to label %try.cont6
}

declare void @maythrow() local_unnamed_addr #1

declare i32 @__CxxFrameHandler3(...)

!llvm.module.flags = !{!0}
!llvm.ident = !{!1}

!0 = !{i32 1, !"PIC Level", i32 2}
!1 = !{!"clang version 4.0.0 "}