1# RUN: llc -o - %s -mtriple=x86_64-- -run-pass=branch-folder | FileCheck %s
2# Branch folder should ignore the DBG_VALUE between block bb.2 and bb.3,
3# set these blocks as bb.3, so that bb.6 will succeed to merge between bb.2 and bb.3.
4# if the DBG_VALUE is not ignored, bb.6 will merge between bb.1 and bb.2, the result is
5# different with Codegen without -g.
6#
7# Generated with
8#
9# clang++ -g -w -O1 -S -emit-llvm test.cc
10# llc -stop-before=branch-folder test.ll
11#
12# template <typename, typename = int> class e;
13# class allocator {
14# public:
15#   ~allocator();
16# };
17# template <typename, typename> class e {
18# public:
19#   e(char *, allocator = allocator());
20# };
21# template <typename b, typename c, typename d> bool operator==(e<c, d>, b);
22# class f {
23# public:
24#   f(int *, int *, int *, int, int, int, int);
25#   e<char> g();
26#   void j();
27# };
28# int h, i;
29# class k {
30#   void l();
31#   bool m_fn4();
32#   int m;
33#   int n;
34#   int q;
35#   int fmap;
36# };
37# void k::l() {
38#   e<char> o = "";
39#   for (;;) {
40#     int p = 0;
41#     for (;;) {
42#       if (m_fn4())
43#         break;
44#       f a(&q, &fmap, &m, n, h, i, 0);
45#       if (a.g() == "")
46#         a.j();
47#     }
48#   }
49# }
50
51--- |
52
53  define dso_local void @l() {
54    ret void
55  }
56
57...
58---
59name:            l
60body:             |
61  bb.0:
62    ; CHECK: bb.0:
63    ; CHECK-NEXT: successors: %bb.1({{.*}}), %bb.7
64    successors: %bb.1, %bb.3
65
66  bb.1:
67    $rdi = MOV64rr $rsp
68
69  bb.2:
70    ; CHECK: bb.2:
71    ; CHECK-NEXT: successors: %bb.3
72    successors: %bb.2, %bb.4
73    DBG_VALUE
74    CFI_INSTRUCTION def_cfa_offset 8
75    ; CHECK: bb.3
76    ; CHECK-NEXT: successors: %bb.2({{.*}}), %bb.4
77    TEST8rr killed renamable $al, renamable $al, implicit-def $eflags
78    JCC_1 %bb.2, 5, implicit killed $eflags
79    JMP_1 %bb.4
80
81  bb.3 (landing-pad):
82    ; CHECK: bb.4:
83    ; CHECK-NEXT: successors: %bb.5({{.*}}), %bb.6
84    successors:
85
86  bb.4:
87    successors: %bb.5, %bb.6
88    JCC_1 %bb.6, 4, implicit killed $eflags
89    ; CHECK: JCC_1 %bb.6, 4, implicit $eflags
90    JMP_1 %bb.5
91
92  bb.5:
93    ; CHECK: bb.5:
94    ; CHECK-NEXT: successors: %bb.6
95    $rdi = COPY renamable $r12
96
97  bb.6:
98    ; CHECK: bb.6:
99    ; CHECK-NEXT: successors: %bb.3
100    successors: %bb.2, %bb.4
101    ; CHECK: JMP_1 %bb.3
102
103  ; CHECK: bb.7 (landing-pad):
104    $rdi = COPY renamable $rbx
105    TEST8rr killed renamable $al, renamable $al, implicit-def $eflags
106    JCC_1 %bb.2, 5, implicit killed $eflags
107    JMP_1 %bb.4
108
109...
110