llvm/llvm/test/Transforms/NewGVN/2011-09-07-TypeIdFor.ll

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
; RUN: opt < %s -passes=newgvn -S | FileCheck %s
%struct.__fundamental_type_info_pseudo = type { %struct.__type_info_pseudo }
%struct.__type_info_pseudo = type { ptr, ptr }

@_ZTIi = external constant %struct.__fundamental_type_info_pseudo
@_ZTIb = external constant %struct.__fundamental_type_info_pseudo

declare void @_Z4barv()

declare void @_Z7cleanupv()

declare i32 @llvm.eh.typeid.for.p0(ptr) nounwind readonly

declare ptr @__cxa_begin_catch(ptr) nounwind

declare void @__cxa_end_catch()

declare i32 @__gxx_personality_v0(i32, i64, ptr, ptr)

define void @_Z3foov() uwtable personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: define void @_Z3foov(
; CHECK-SAME: ) #[[ATTR2:[0-9]+]] personality ptr @__gxx_personality_v0 {
; CHECK-NEXT:  entry:
; CHECK-NEXT:    invoke void @_Z4barv()
; CHECK-NEXT:            to label [[RETURN:%.*]] unwind label [[LPAD:%.*]]
; CHECK:       lpad:
; CHECK-NEXT:    [[TMP0:%.*]] = landingpad { ptr, i32 }
; CHECK-NEXT:            catch ptr @_ZTIi
; CHECK-NEXT:            catch ptr @_ZTIb
; CHECK-NEXT:            catch ptr @_ZTIi
; CHECK-NEXT:            catch ptr @_ZTIb
; CHECK-NEXT:    [[EXC_PTR2_I:%.*]] = extractvalue { ptr, i32 } [[TMP0]], 0
; CHECK-NEXT:    [[FILTER3_I:%.*]] = extractvalue { ptr, i32 } [[TMP0]], 1
; CHECK-NEXT:    [[TYPEID_I:%.*]] = tail call i32 @llvm.eh.typeid.for.p0(ptr @_ZTIi)
; CHECK-NEXT:    [[TMP1:%.*]] = icmp eq i32 [[FILTER3_I]], [[TYPEID_I]]
; CHECK-NEXT:    br i1 [[TMP1]], label [[PPAD:%.*]], label [[NEXT:%.*]]
; CHECK:       next:
; CHECK-NEXT:    [[TYPEID1_I:%.*]] = tail call i32 @llvm.eh.typeid.for.p0(ptr @_ZTIb)
; CHECK-NEXT:    [[TMP2:%.*]] = icmp eq i32 [[FILTER3_I]], [[TYPEID1_I]]
; CHECK-NEXT:    br i1 [[TMP2]], label [[PPAD2:%.*]], label [[NEXT2:%.*]]
; CHECK:       ppad:
; CHECK-NEXT:    [[TMP3:%.*]] = tail call ptr @__cxa_begin_catch(ptr [[EXC_PTR2_I]]) #[[ATTR1:[0-9]+]]
; CHECK-NEXT:    tail call void @__cxa_end_catch() #[[ATTR1]]
; CHECK-NEXT:    br label [[RETURN]]
; CHECK:       ppad2:
; CHECK-NEXT:    [[D_2073_5_I:%.*]] = tail call ptr @__cxa_begin_catch(ptr [[EXC_PTR2_I]]) #[[ATTR1]]
; CHECK-NEXT:    tail call void @__cxa_end_catch() #[[ATTR1]]
; CHECK-NEXT:    br label [[RETURN]]
; CHECK:       next2:
; CHECK-NEXT:    call void @_Z7cleanupv()
; CHECK-NEXT:    br i1 [[TMP1]], label [[PPAD3:%.*]], label [[NEXT3:%.*]]
; CHECK:       next3:
; CHECK-NEXT:    br i1 [[TMP2]], label [[PPAD4:%.*]], label [[UNWIND:%.*]]
; CHECK:       unwind:
; CHECK-NEXT:    resume { ptr, i32 } [[TMP0]]
; CHECK:       ppad3:
; CHECK-NEXT:    [[TMP4:%.*]] = tail call ptr @__cxa_begin_catch(ptr [[EXC_PTR2_I]]) #[[ATTR1]]
; CHECK-NEXT:    tail call void @__cxa_end_catch() #[[ATTR1]]
; CHECK-NEXT:    br label [[RETURN]]
; CHECK:       ppad4:
; CHECK-NEXT:    [[D_2080_5:%.*]] = tail call ptr @__cxa_begin_catch(ptr [[EXC_PTR2_I]]) #[[ATTR1]]
; CHECK-NEXT:    tail call void @__cxa_end_catch() #[[ATTR1]]
; CHECK-NEXT:    br label [[RETURN]]
; CHECK:       return:
; CHECK-NEXT:    ret void
;
entry:
  invoke void @_Z4barv()
  to label %return unwind label %lpad

lpad:                                             ; preds = %entry
  %0 = landingpad { ptr, i32 }
  catch ptr @_ZTIi
  catch ptr @_ZTIb
  catch ptr @_ZTIi
  catch ptr @_ZTIb
  %exc_ptr2.i = extractvalue { ptr, i32 } %0, 0
  %filter3.i = extractvalue { ptr, i32 } %0, 1
  %typeid.i = tail call i32 @llvm.eh.typeid.for.p0(ptr @_ZTIi)
  %1 = icmp eq i32 %filter3.i, %typeid.i
  br i1 %1, label %ppad, label %next

next:                                             ; preds = %lpad
  %typeid1.i = tail call i32 @llvm.eh.typeid.for.p0(ptr @_ZTIb)
  %2 = icmp eq i32 %filter3.i, %typeid1.i
  br i1 %2, label %ppad2, label %next2

ppad:                                             ; preds = %lpad
  %3 = tail call ptr @__cxa_begin_catch(ptr %exc_ptr2.i) nounwind
  tail call void @__cxa_end_catch() nounwind
  br label %return

ppad2:                                            ; preds = %next
  %D.2073_5.i = tail call ptr @__cxa_begin_catch(ptr %exc_ptr2.i) nounwind
  tail call void @__cxa_end_catch() nounwind
  br label %return

next2:                                            ; preds = %next
  call void @_Z7cleanupv()
  %typeid = tail call i32 @llvm.eh.typeid.for.p0(ptr @_ZTIi)
  %4 = icmp eq i32 %filter3.i, %typeid
  br i1 %4, label %ppad3, label %next3

next3:                                            ; preds = %next2
  %typeid1 = tail call i32 @llvm.eh.typeid.for.p0(ptr @_ZTIb)
  %5 = icmp eq i32 %filter3.i, %typeid1
  br i1 %5, label %ppad4, label %unwind

unwind:                                           ; preds = %next3
  resume { ptr, i32 } %0

ppad3:                                            ; preds = %next2
  %6 = tail call ptr @__cxa_begin_catch(ptr %exc_ptr2.i) nounwind
  tail call void @__cxa_end_catch() nounwind
  br label %return

ppad4:                                            ; preds = %next3
  %D.2080_5 = tail call ptr @__cxa_begin_catch(ptr %exc_ptr2.i) nounwind
  tail call void @__cxa_end_catch() nounwind
  br label %return

return:                                           ; preds = %ppad4, %ppad3, %ppad2, %ppad, %entry
  ret void
}