Skip to content

Commit 4237433

Browse files
committed
Add Paul's test case
1 parent 6bc8804 commit 4237433

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
;; This test comes from a real world scenario in LTO, where the
2+
;; definition of bcmp is deleted because it has no uses, but later instcombine
3+
;; re-introduces a call to bcmp() as part of SimplifyLibCalls.
4+
5+
; RUN: opt %s -o %t -module-summary -mtriple x86_64-unknown-linux-musl
6+
; RUN: llvm-lto2 run -o %t2 \
7+
; RUN: -r %t,foo,plx \
8+
; RUN: -r %t,memcmp,x \
9+
; RUN: -r %t,bcmp,pl %t -save-temps
10+
; RUN: llvm-dis %t2.1.2.internalize.bc -o - | FileCheck %s
11+
12+
define i1 @foo(ptr %0, [2 x i32] %1) {
13+
; CHECK-LABEL: define{{.*}}i1 @foo
14+
; CHECK-NEXT: %size = extractvalue [2 x i32] %1, 1
15+
; CHECK-NEXT: %cmp = {{.*}}call i32 @memcmp
16+
; CHECK-NEXT: %eq = icmp eq i32 %cmp, 0
17+
; CHECK-NEXT: ret i1 %eq
18+
19+
%size = extractvalue [2 x i32] %1, 1
20+
%cmp = call i32 @memcmp(ptr %0, ptr null, i32 %size)
21+
%eq = icmp eq i32 %cmp, 0
22+
ret i1 %eq
23+
}
24+
25+
; CHECK: declare i32 @memcmp(ptr, ptr, i32)
26+
declare i32 @memcmp(ptr, ptr, i32)
27+
28+
;; Ensure bcmp is removed from module. Follow up patches can address this.
29+
; CHECK-NOT: declare{{.*}}i32 @bcmp
30+
; CHECK-NOT: define{{.*}}i32 @bcmp
31+
define i32 @bcmp(ptr %0, ptr %1, i32 %2) {
32+
ret i32 0
33+
}
34+

0 commit comments

Comments
 (0)