brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · abaeae9 Raw
48 lines · plain
1; RUN: opt -S -passes=mergefunc < %s | FileCheck %s2 3define weak i32 @sum(i32 %x, i32 %y) {4  %sum = add i32 %x, %y5  %sum2 = add i32 %sum, %y6  %sum3 = add i32 %sum2, %y7  ret i32 %sum38}9 10define weak i32 @add(i32 %x, i32 %y) {11  %sum = add i32 %x, %y12  %sum2 = add i32 %sum, %y13  %sum3 = add i32 %sum2, %y14  ret i32 %sum315}16 17; Don't replace a weak function use by another equivalent function. We don't18; know whether the symbol that will ulitmately be linked is equivalent - we19; don't know that the weak definition is the definitive definition or whether it20; will be overriden by a stronger definition).21 22; CHECK-LABEL: define private i32 @023; CHECK: add i3224; CHECK: add i3225; CHECK: add i3226; CHECK: ret27 28; CHECK-LABEL: define i32 @use_weak29; CHECK: call i32 @add30; CHECK: call i32 @sum31; CHECK: ret32 33; CHECK-LABEL: define weak i32 @sum34; CHECK:  tail call i32 @035; CHECK:  ret36 37; CHECK-LABEL: define weak i32 @add38; CHECK:  tail call i32 @039; CHECK:  ret40 41 42define 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, %res246  ret i32 %res347}48