1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-attributes --check-globals
2 ; RUN: opt < %s -passes=debugify,simplifycfg -simplifycfg-require-and-preserve-domtree=1 -sink-common-insts -S | FileCheck %s
3 ; RUN: opt < %s -passes='debugify,simplifycfg<sink-common-insts>' -S | FileCheck %s
5 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
6 target triple = "x86_64-unknown-linux-gnu"
8 ; More interesting test, here we can merge the invokes.
9 define void @t1_mergeable_invoke() personality ptr @__gxx_personality_v0 {
10 ; CHECK-LABEL: @t1_mergeable_invoke(
12 ; CHECK-NEXT: [[C0:%.*]] = call i1 @cond(), !dbg [[DBG12:![0-9]+]]
13 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i1 [[C0]], metadata [[META9:![0-9]+]], metadata !DIExpression()), !dbg [[DBG12]]
14 ; CHECK-NEXT: br i1 [[C0]], label [[IF_THEN1_INVOKE:%.*]], label [[IF_ELSE:%.*]], !dbg [[DBG13:![0-9]+]]
16 ; CHECK-NEXT: [[EH:%.*]] = landingpad { ptr, i32 }
17 ; CHECK-NEXT: cleanup, !dbg [[DBG14:![0-9]+]]
18 ; CHECK-NEXT: call void @destructor(), !dbg [[DBG15:![0-9]+]]
19 ; CHECK-NEXT: resume { ptr, i32 } [[EH]], !dbg [[DBG16:![0-9]+]]
21 ; CHECK-NEXT: [[C1:%.*]] = call i1 @cond(), !dbg [[DBG17:![0-9]+]]
22 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i1 [[C1]], metadata [[META11:![0-9]+]], metadata !DIExpression()), !dbg [[DBG17]]
23 ; CHECK-NEXT: br i1 [[C1]], label [[IF_THEN1_INVOKE]], label [[IF_END:%.*]], !dbg [[DBG18:![0-9]+]]
24 ; CHECK: if.then1.invoke:
25 ; CHECK-NEXT: invoke void @simple_throw()
26 ; CHECK-NEXT: to label [[IF_THEN1_CONT:%.*]] unwind label [[LPAD:%.*]], !dbg [[DBG19:![0-9]+]]
27 ; CHECK: if.then1.cont:
28 ; CHECK-NEXT: unreachable
30 ; CHECK-NEXT: call void @sideeffect(), !dbg [[DBG20:![0-9]+]]
31 ; CHECK-NEXT: ret void, !dbg [[DBG21:![0-9]+]]
35 br i1 %c0, label %if.then0, label %if.else
38 invoke void @simple_throw() to label %invoke.cont0 unwind label %lpad
44 %eh = landingpad { ptr, i32 } cleanup
45 call void @destructor()
46 resume { ptr, i32 } %eh
50 br i1 %c1, label %if.then1, label %if.end
53 invoke void @simple_throw() to label %invoke.cont2 unwind label %lpad
59 call void @sideeffect()
64 declare void @sideeffect()
65 declare void @simple_throw() noreturn
66 declare void @destructor()
68 declare dso_local i32 @__gxx_personality_v0(...)
70 ; CHECK: attributes #[[ATTR0:[0-9]+]] = { noreturn }
71 ; CHECK: attributes #[[ATTR1:[0-9]+]] = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
73 ; CHECK: [[META0:![0-9]+]] = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
74 ; CHECK: [[META1:![0-9]+]] = !DIFile(filename: "<stdin>", directory: "/")
75 ; CHECK: [[META2:![0-9]+]] = !{i32 13}
76 ; CHECK: [[META3:![0-9]+]] = !{i32 2}
77 ; CHECK: [[META4:![0-9]+]] = !{i32 2, !"Debug Info Version", i32 3}
78 ; CHECK: [[META5:![0-9]+]] = distinct !DISubprogram(name: "t1_mergeable_invoke", linkageName: "t1_mergeable_invoke", scope: null, file: !1, line: 1, type: !6, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !8)
79 ; CHECK: [[META6:![0-9]+]] = !DISubroutineType(types: !7)
80 ; CHECK: [[META7:![0-9]+]] = !{}
81 ; CHECK: [[META8:![0-9]+]] = !{!9, !11}
82 ; CHECK: [[META9]] = !DILocalVariable(name: "1", scope: !5, file: !1, line: 1, type: !10)
83 ; CHECK: [[META10:![0-9]+]] = !DIBasicType(name: "ty8", size: 8, encoding: DW_ATE_unsigned)
84 ; CHECK: [[META11]] = !DILocalVariable(name: "2", scope: !5, file: !1, line: 8, type: !10)
85 ; CHECK: [[DBG12]] = !DILocation(line: 1, column: 1, scope: !5)
86 ; CHECK: [[DBG13]] = !DILocation(line: 2, column: 1, scope: !5)
87 ; CHECK: [[DBG14]] = !DILocation(line: 5, column: 1, scope: !5)
88 ; CHECK: [[DBG15]] = !DILocation(line: 6, column: 1, scope: !5)
89 ; CHECK: [[DBG16]] = !DILocation(line: 7, column: 1, scope: !5)
90 ; CHECK: [[DBG17]] = !DILocation(line: 8, column: 1, scope: !5)
91 ; CHECK: [[DBG18]] = !DILocation(line: 9, column: 1, scope: !5)
92 ; CHECK: [[DBG19]] = !DILocation(line: 0, scope: !5)
93 ; CHECK: [[DBG20]] = !DILocation(line: 12, column: 1, scope: !5)
94 ; CHECK: [[DBG21]] = !DILocation(line: 13, column: 1, scope: !5)