1 ; RUN: opt -S -mergefunc < %s | FileCheck %s
3 define weak i32 @sum(i32 %x, i32 %y) {
5 %sum2 = add i32 %sum, %y
6 %sum3 = add i32 %sum2, %y
10 define weak i32 @add(i32 %x, i32 %y) {
12 %sum2 = add i32 %sum, %y
13 %sum3 = add i32 %sum2, %y
17 ; Don't replace a weak function use by another equivalent function. We don't
18 ; know whether the symbol that will ulitmately be linked is equivalent - we
19 ; don't know that the weak definition is the definitive definition or whether it
20 ; will be overriden by a stronger definition).
22 ; CHECK-LABEL: define private i32 @0
28 ; CHECK-LABEL: define i32 @use_weak
29 ; CHECK: call i32 @add
30 ; CHECK: call i32 @sum
33 ; CHECK-LABEL: define weak i32 @sum
34 ; CHECK: tail call i32 @0
37 ; CHECK-LABEL: define weak i32 @add
38 ; CHECK: tail call i32 @0
42 define i32 @use_weak(i32 %a, i32 %b) {
43 %res = call i32 @add(i32 %a, i32 %b)
44 %res2 = call i32 @sum(i32 %a, i32 %b)
45 %res3 = add i32 %res, %res2