linkonce_odr.ll 891 B

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