1 ; RUN: opt -S -passes=mergefunc -mergefunc-use-aliases < %s | FileCheck %s
3 ; Aliases should always be created for the weak functions, and
4 ; for external functions if there is no local function
6 ; CHECK: @external_external_2 = unnamed_addr alias void (ptr), ptr @external_external_1
7 ; CHECK: @weak_weak_2 = weak unnamed_addr alias void (ptr), ptr @0
8 ; CHECK: @weak_weak_1 = weak unnamed_addr alias void (ptr), ptr @0
9 ; CHECK: @weak_external_1 = weak unnamed_addr alias void (ptr), ptr @weak_external_2
10 ; CHECK: @external_weak_2 = weak unnamed_addr alias void (ptr), ptr @external_weak_1
11 ; CHECK: @weak_internal_1 = weak unnamed_addr alias void (ptr), ptr @weak_internal_2
12 ; CHECK: @internal_weak_2 = weak unnamed_addr alias void (ptr), ptr @internal_weak_1
14 ; A strong backing function had to be created for the weak-weak pair
16 ; CHECK: define private void @0(ptr %a) unnamed_addr
17 ; CHECK-NEXT: call void @dummy4()
19 ; These internal functions are dropped in favor of the external ones
21 ; CHECK-NOT: define internal void @external_internal_2(ptr %a) unnamed_addr
22 ; CHECK-NOT: define internal void @internal_external_1(ptr %a) unnamed_addr
23 ; CHECK-NOT: define internal void @internal_external_1(ptr %a) unnamed_addr
24 ; CHECK-NOT: define internal void @internal_external_2(ptr %a) unnamed_addr
26 ; Only used to mark which functions should be merged.
27 declare void @dummy1()
28 declare void @dummy2()
29 declare void @dummy3()
30 declare void @dummy4()
31 declare void @dummy5()
32 declare void @dummy6()
33 declare void @dummy7()
34 declare void @dummy8()
35 declare void @dummy9()
37 define void @external_external_1(ptr %a) unnamed_addr {
41 define void @external_external_2(ptr %a) unnamed_addr {
46 define void @external_internal_1(ptr %a) unnamed_addr {
50 define internal void @external_internal_2(ptr %a) unnamed_addr {
55 define internal void @internal_external_1(ptr %a) unnamed_addr {
59 define void @internal_external_2(ptr %a) unnamed_addr {
64 define weak void @weak_weak_1(ptr %a) unnamed_addr {
68 define weak void @weak_weak_2(ptr %a) unnamed_addr {
73 define weak void @weak_external_1(ptr %a) unnamed_addr {
77 define external void @weak_external_2(ptr %a) unnamed_addr {
82 define external void @external_weak_1(ptr %a) unnamed_addr {
86 define weak void @external_weak_2(ptr %a) unnamed_addr {
91 define weak void @weak_internal_1(ptr %a) unnamed_addr {
95 define internal void @weak_internal_2(ptr %a) unnamed_addr {
100 define internal void @internal_weak_1(ptr %a) unnamed_addr {
104 define weak void @internal_weak_2(ptr %a) unnamed_addr {
109 define internal void @internal_internal_1(ptr %a) unnamed_addr {
113 define internal void @internal_internal_2(ptr %a) unnamed_addr {