blob: df956ea3517888c578d518601218022cdf6b74d0 [file] [edit]
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
; RUN: opt < %s -S -passes='move-auto-init' -verify-memoryssa | FileCheck %s
; The auto-init store is moved to %middle, the nearest dominator of its users
; that is not an EH pad, rather than to the top of the catchpad block: a
; CatchPadInst is itself a MemoryDef, so inserting before it would break
; MemorySSA. See #221568.
declare void @dummy()
declare void @use(i32)
define void @test() personality ptr @dummy {
; CHECK-LABEL: define void @test() personality ptr @dummy {
; CHECK-NEXT: entry:
; CHECK-NEXT: [[P:%.*]] = alloca i32, align 4
; CHECK-NEXT: br label [[MIDDLE:%.*]]
; CHECK: middle:
; CHECK-NEXT: store i32 0, ptr [[P]], align 4, !annotation [[META0:![0-9]+]]
; CHECK-NEXT: invoke void @dummy()
; CHECK-NEXT: to label [[CLEAN:%.*]] unwind label [[CATCHBB:%.*]]
; CHECK: clean:
; CHECK-NEXT: ret void
; CHECK: catchbb:
; CHECK-NEXT: [[CS:%.*]] = catchswitch within none [label [[PAD:%.*]]] unwind to caller
; CHECK: pad:
; CHECK-NEXT: [[C:%.*]] = catchpad within [[CS]] [i32 0]
; CHECK-NEXT: [[V:%.*]] = load i32, ptr [[P]], align 4
; CHECK-NEXT: call void @use(i32 [[V]])
; CHECK-NEXT: ret void
;
entry:
%p = alloca i32, align 4
store i32 0, ptr %p, align 4, !annotation !0
br label %middle
middle:
invoke void @dummy() to label %clean unwind label %catchbb
clean:
ret void
catchbb:
%cs = catchswitch within none [label %pad] unwind to caller
pad:
%c = catchpad within %cs [i32 0]
%v = load i32, ptr %p, align 4
call void @use(i32 %v)
ret void
}
!0 = !{!"auto-init"}
;.
; CHECK: [[META0]] = !{!"auto-init"}
;.