xref: /llvm-project/llvm/test/Transforms/MergeFunc/debuginfo-iterators.ll (revision d2942a86d7b8fc4cba4f73294efb53a3e47dc751)
1;; Ensure that the MergeFunctions pass creates thunks with the appropriate debug
2;; info format set (which would otherwise assert when inlining those thunks).
3; RUN: opt -S -passes=mergefunc,inline --try-experimental-debuginfo-iterators < %s | FileCheck %s
4
5declare void @f1()
6declare void @f2()
7
8define void @f3() {
9  call void @f1()
10  call void @f2()
11  ret void
12}
13
14;; MergeFunctions will replace f4 with a thunk that calls f3. Inlining will
15;; inline f3 into that thunk, which would assert if the thunk had the incorrect
16;; debug info format.
17define void @f4() {
18  call void @f1()
19  call void @f2()
20  ret void
21}
22
23; CHECK-LABEL: define void @f4() {
24; CHECK-NEXT:    call void @f1()
25; CHECK-NEXT:    call void @f2()
26; CHECK-NEXT:    ret void
27; CHECK-NEXT: }
28
29;; Both of these are interposable, so MergeFunctions will create a common thunk
30;; that both will call. Inlining will inline that thunk back, which would assert
31;; if the thunk had the incorrect debug info format.
32define weak void @f5() {
33  call void @f2()
34  call void @f1()
35  ret void
36}
37
38define weak void @f6() {
39  call void @f2()
40  call void @f1()
41  ret void
42}
43
44; CHECK-LABEL: define weak void @f6() {
45; CHECK-NEXT:    call void @f2()
46; CHECK-NEXT:    call void @f1()
47; CHECK-NEXT:    ret void
48; CHECK-NEXT:  }
49
50; CHECK-LABEL: define weak void @f5() {
51; CHECK-NEXT:    call void @f2()
52; CHECK-NEXT:    call void @f1()
53; CHECK-NEXT:    ret void
54; CHECK-NEXT:  }
55