1 ; RUN: llc -verify-machineinstrs -mtriple powerpc-ibm-aix-xcoff -mcpu=pwr4 \
2 ; RUN: -mattr=-altivec -simplifycfg-require-and-preserve-domtree=1 < %s | \
3 ; RUN: FileCheck --check-prefixes=ASM,ASM32 %s
5 ; RUN: llc -verify-machineinstrs -mtriple powerpc64-ibm-aix-xcoff -mcpu=pwr4 \
6 ; RUN: -mattr=-altivec -simplifycfg-require-and-preserve-domtree=1 < %s | \
7 ; RUN: FileCheck --check-prefixes=ASM,ASM64 %s
9 @_ZTIi = external constant i8*
11 define void @_Z9throwFuncv() {
13 %exception = call i8* @__cxa_allocate_exception(i32 4) #2
14 %0 = bitcast i8* %exception to i32*
15 store i32 1, i32* %0, align 16
16 call void @__cxa_throw(i8* %exception, i8* bitcast (i8** @_ZTIi to i8*), i8* null) #3
20 ; ASM: ._Z9throwFuncv:
21 ; ASM: bl .__cxa_allocate_exception[PR]
23 ; ASM32: lwz 4, L..C0(2)
24 ; ASM64: ld 4, L..C0(2)
25 ; ASM: bl .__cxa_throw[PR]
28 define i32 @_Z9catchFuncv() personality i8* bitcast (i32 (...)* @__xlcxx_personality_v1 to i8*) {
30 %retval = alloca i32, align 4
31 %exn.slot = alloca i8*, align 4
32 %ehselector.slot = alloca i32, align 4
33 %0 = alloca i32, align 4
34 invoke void @_Z9throwFuncv()
35 to label %invoke.cont unwind label %lpad
37 invoke.cont: ; preds = %entry
40 lpad: ; preds = %entry
41 %1 = landingpad { i8*, i32 }
42 catch i8* bitcast (i8** @_ZTIi to i8*)
43 %2 = extractvalue { i8*, i32 } %1, 0
44 store i8* %2, i8** %exn.slot, align 4
45 %3 = extractvalue { i8*, i32 } %1, 1
46 store i32 %3, i32* %ehselector.slot, align 4
47 br label %catch.dispatch
49 catch.dispatch: ; preds = %lpad
50 %sel = load i32, i32* %ehselector.slot, align 4
51 %4 = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*)) #2
52 %matches = icmp eq i32 %sel, %4
53 br i1 %matches, label %catch, label %eh.resume
55 catch: ; preds = %catch.dispatch
56 %exn = load i8*, i8** %exn.slot, align 4
57 %5 = call i8* @__cxa_begin_catch(i8* %exn) #2
58 %6 = bitcast i8* %5 to i32*
59 %7 = load i32, i32* %6, align 4
60 store i32 %7, i32* %0, align 4
61 store i32 2, i32* %retval, align 4
62 call void @__cxa_end_catch() #2
65 try.cont: ; preds = %invoke.cont
66 store i32 1, i32* %retval, align 4
69 return: ; preds = %try.cont, %catch
70 %8 = load i32, i32* %retval, align 4
73 eh.resume: ; preds = %catch.dispatch
74 %exn1 = load i8*, i8** %exn.slot, align 4
75 %sel2 = load i32, i32* %ehselector.slot, align 4
76 %lpad.val = insertvalue { i8*, i32 } undef, i8* %exn1, 0
77 %lpad.val3 = insertvalue { i8*, i32 } %lpad.val, i32 %sel2, 1
78 resume { i8*, i32 } %lpad.val3
81 ; ASM: ._Z9catchFuncv:
82 ; ASM: L..func_begin0:
83 ; ASM: # %bb.0: # %entry
86 ; ASM: bl ._Z9throwFuncv
89 ; ASM: # %bb.1: # %invoke.cont
91 ; ASM: L..BB1_2: # %return
94 ; ASM: L..BB1_3: # %lpad
96 ; ASM: bl .__cxa_begin_catch[PR]
98 ; ASM: bl .__cxa_end_catch[PR]
102 ; ASM: L.._Z9catchFuncv0:
103 ; ASM: .vbyte 4, 0x00000000 # Traceback table begin
104 ; ASM: .byte 0x00 # Version = 0
105 ; ASM: .byte 0x09 # Language = CPlusPlus
106 ; ASM: .byte 0x20 # -IsGlobaLinkage, -IsOutOfLineEpilogOrPrologue
107 ; ASM: # +HasTraceBackTableOffset, -IsInternalProcedure
108 ; ASM: # -HasControlledStorage, -IsTOCless
109 ; ASM: # -IsFloatingPointPresent
110 ; ASM: # -IsFloatingPointOperationLogOrAbortEnabled
111 ; ASM: .byte 0x41 # -IsInterruptHandler, +IsFunctionNamePresent, -IsAllocaUsed
112 ; ASM: # OnConditionDirective = 0, -IsCRSaved, +IsLRSaved
113 ; ASM: .byte 0x80 # +IsBackChainStored, -IsFixup, NumOfFPRsSaved = 0
114 ; ASM: .byte 0x80 # +HasExtensionTable, -HasVectorInfo, NumOfGPRsSaved = 0
115 ; ASM: .byte 0x00 # NumberOfFixedParms = 0
116 ; ASM: .byte 0x01 # NumberOfFPParms = 0, +HasParmsOnStack
117 ; ASM: .vbyte 4, L.._Z9catchFuncv0-._Z9catchFuncv # Function size
118 ; ASM: .vbyte 2, 0x000d # Function name len = 13
119 ; ASM: .byte "_Z9catchFuncv" # Function Name
120 ; ASM: .byte 0x08 # ExtensionTableFlag = TB_EH_INFO
122 ; ASM32: .vbyte 4, L..C1-TOC[TC0] # EHInfo Table
123 ; ASM64: .vbyte 8, L..C1-TOC[TC0] # EHInfo Table
126 ; ASM: .csect .gcc_except_table[RO],2
128 ; ASM: GCC_except_table1:
129 ; ASM: L..exception0:
130 ; ASM: .byte 255 # @LPStart Encoding = omit
131 ; ASM32: .byte 187 # @TType Encoding = indirect datarel sdata4
132 ; ASM64: .byte 188 # @TType Encoding = indirect datarel sdata8
135 ; ASM: .byte 3 # Call site Encoding = udata4
137 ; ASM: .vbyte 4, L..tmp0-L..func_begin0 # >> Call Site 1 <<
138 ; ASM: .vbyte 4, L..tmp1-L..tmp0 # Call between L..tmp0 and L..tmp1
139 ; ASM: .vbyte 4, L..tmp2-L..func_begin0 # jumps to L..tmp2
140 ; ASM: .byte 1 # On action: 1
141 ; ASM: .vbyte 4, L..tmp1-L..func_begin0 # >> Call Site 2 <<
142 ; ASM: .vbyte 4, L..func_end0-L..tmp1 # Call between L..tmp1 and L..func_end0
143 ; ASM: .vbyte 4, 0 # has no landing pad
144 ; ASM: .byte 0 # On action: cleanup
146 ; ASM: .byte 1 # >> Action Record 1 <<
147 ; ASM: # Catch TypeInfo 1
148 ; ASM: .byte 0 # No further actions
150 ; ASM: # >> Catch TypeInfos <<
151 ; ASM32: .vbyte 4, L..C0-TOC[TC0] # TypeInfo 1
152 ; ASM64: .vbyte 8, L..C0-TOC[TC0] # TypeInfo 1
156 ; ASM: .csect .eh_info_table[RW],2
160 ; ASM32: .vbyte 4, GCC_except_table1
161 ; ASM32: .vbyte 4, __xlcxx_personality_v1[DS]
163 ; ASM64: .vbyte 8, GCC_except_table1
164 ; ASM64: .vbyte 8, __xlcxx_personality_v1[DS]
168 ; ASM: .tc _ZTIi[TC],_ZTIi[UA]
170 ; ASM: .tc __ehinfo.1[TC],__ehinfo.1
172 declare i8* @__cxa_allocate_exception(i32)
173 declare void @__cxa_throw(i8*, i8*, i8*)
174 declare i32 @__xlcxx_personality_v1(...)
175 declare i32 @llvm.eh.typeid.for(i8*)
176 declare i8* @__cxa_begin_catch(i8*)
177 declare void @__cxa_end_catch()