1 ; RUN: opt -S -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 (float*), bitcast (void (i32*)* @external_external_1 to void (float*)*)
7 ; CHECK: @weak_weak_2 = weak unnamed_addr alias void (float*), bitcast (void (i32*)* @0 to void (float*)*)
8 ; CHECK: @weak_weak_1 = weak unnamed_addr alias void (i32*), void (i32*)* @0
9 ; CHECK: @weak_external_1 = weak unnamed_addr alias void (i32*), bitcast (void (float*)* @weak_external_2 to void (i32*)*)
10 ; CHECK: @external_weak_2 = weak unnamed_addr alias void (float*), bitcast (void (i32*)* @external_weak_1 to void (float*)*)
11 ; CHECK: @weak_internal_1 = weak unnamed_addr alias void (i32*), bitcast (void (float*)* @weak_internal_2 to void (i32*)*)
12 ; CHECK: @internal_weak_2 = weak unnamed_addr alias void (float*), bitcast (void (i32*)* @internal_weak_1 to void (float*)*)
14 ; A strong backing function had to be created for the weak-weak pair
16 ; CHECK: define private void @0(i32* %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(float *%a) unnamed_addr
22 ; CHECK-NOT: define internal void @internal_external_1(i32 *%a) unnamed_addr
23 ; CHECK-NOT: define internal void @internal_external_1(i32 *%a) unnamed_addr
24 ; CHECK-NOT: define internal void @internal_external_2(float *%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(i32 *%a) unnamed_addr {
41 define void @external_external_2(float *%a) unnamed_addr {
46 define void @external_internal_1(i32 *%a) unnamed_addr {
50 define internal void @external_internal_2(float *%a) unnamed_addr {
55 define internal void @internal_external_1(i32 *%a) unnamed_addr {
59 define void @internal_external_2(float *%a) unnamed_addr {
64 define weak void @weak_weak_1(i32 *%a) unnamed_addr {
68 define weak void @weak_weak_2(float *%a) unnamed_addr {
73 define weak void @weak_external_1(i32 *%a) unnamed_addr {
77 define external void @weak_external_2(float *%a) unnamed_addr {
82 define external void @external_weak_1(i32 *%a) unnamed_addr {
86 define weak void @external_weak_2(float *%a) unnamed_addr {
91 define weak void @weak_internal_1(i32 *%a) unnamed_addr {
95 define internal void @weak_internal_2(float *%a) unnamed_addr {
100 define internal void @internal_weak_1(i32 *%a) unnamed_addr {
104 define weak void @internal_weak_2(float *%a) unnamed_addr {
109 define internal void @internal_internal_1(i32 *%a) unnamed_addr {
113 define internal void @internal_internal_2(float *%a) unnamed_addr {