llvm-project/llvm/test/LTO/Resolution/X86/libcall-external.ll
Daniel Thornburgh fecf609998
Reland "[LTO][LLD] Prevent invalid LTO libfunc transforms (#164916)" (#190642)
This reverts commit 1ec7e86b3a779df2a0af3f37e58c8f5b3a398d7f after issue
#190072 was fixed.
2026-04-06 19:20:45 +00:00

26 lines
1000 B
LLVM

;; When a libcall was not brought into the link, it can be used iff it is
;; defined in native code, not bitcode.
; RUN: opt %s -o %t.o -mtriple x86_64-unknown-linux-musl
; RUN: llvm-lto2 run -o %t.bitcode.o \
; RUN: -r %t.o,foo,plx -r %t.o,memcmp,x -save-temps %t.o \
; RUN: --bitcode-libfuncs=bcmp
; RUN: llvm-dis %t.bitcode.o.0.4.opt.bc -o - | FileCheck --check-prefixes=CHECK,BITCODE %s
; RUN: llvm-lto2 run -o %t.native.o \
; RUN: -r %t.o,foo,plx -r %t.o,memcmp,x -save-temps %t.o
; RUN: llvm-dis %t.native.o.0.4.opt.bc -o - | FileCheck --check-prefixes=CHECK,NATIVE %s
define i1 @foo(ptr %0, ptr %1, i64 %2) {
; CHECK-LABEL: define{{.*}}i1 @foo
; BITCODE-NEXT: %cmp = {{.*}}call i32 @memcmp
; BITCODE-NEXT: %eq = icmp eq i32 %cmp, 0
; NATIVE-NEXT: %bcmp = {{.*}}call i32 @bcmp
; NATIVE-NEXT: %eq = icmp eq i32 %bcmp, 0
; CHECK-NEXT: ret i1 %eq
%cmp = call i32 @memcmp(ptr %0, ptr %1, i64 %2)
%eq = icmp eq i32 %cmp, 0
ret i1 %eq
}
declare i32 @memcmp(ptr, ptr, i64)