1 ; RUN: opt -S -mergefunc < %s | FileCheck %s 2 3 ; Replacments should be totally ordered on the function name. 4 ; If we don't do this we can end up with one module defining a thunk for @funA 5 ; and another module defining a thunk for @funB. 6 ; 7 ; The problem with this is that the linker could then choose these two stubs 8 ; each of the two modules and we end up with two stubs calling each other. 9 10 ; CHECK-LABEL: define linkonce_odr i32 @funA 11 ; CHECK-NEXT: add 12 ; CHECK: ret 13 14 ; CHECK-LABEL: define linkonce_odr i32 @funB 15 ; CHECK-NEXT: tail call i32 @funA(i32 %0, i32 %1) 16 ; CHECK-NEXT: ret 17 18 define linkonce_odr i32 @funB(i32 %x, i32 %y) { 19 %sum = add i32 %x, %y 20 %sum2 = add i32 %x, %sum 21 %sum3 = add i32 %x, %sum2 22 ret i32 %sum3 23 } 24 25 define linkonce_odr i32 @funA(i32 %x, i32 %y) { 26 %sum = add i32 %x, %y 27 %sum2 = add i32 %x, %sum 28 %sum3 = add i32 %x, %sum2 29 ret i32 %sum3 30 } 31