Skip to content

Commit cd64d1a

Browse files
committed
Make the test case work
1 parent 4237433 commit cd64d1a

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed
Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +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.
1+
;; This test comes from a real world scenario in LTO, where the definition of
2+
;; bcmp was deleted because it has no uses, but later instcombine re-introduced
3+
;; a call to bcmp() as part of SimplifyLibCalls. Such deletions must not be
4+
;; allowed.
45

56
; RUN: opt %s -o %t -module-summary -mtriple x86_64-unknown-linux-musl
67
; RUN: llvm-lto2 run -o %t2 \
78
; RUN: -r %t,foo,plx \
89
; 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
10+
; RUN: -r %t,bcmp,pl \
11+
; RUN: -r %t,bcmp_impl,x %t -save-temps
12+
; RUN: llvm-dis %t2.1.4.opt.bc -o - | FileCheck %s
1113

12-
define i1 @foo(ptr %0, [2 x i32] %1) {
14+
define i1 @foo(ptr %0, ptr %1, i64 %2) {
1315
; 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
16+
; CHECK-NEXT: %bcmp = {{.*}}call i32 @bcmp
17+
; CHECK-NEXT: %eq = icmp eq i32 %bcmp, 0
1718
; CHECK-NEXT: ret i1 %eq
1819

19-
%size = extractvalue [2 x i32] %1, 1
20-
%cmp = call i32 @memcmp(ptr %0, ptr null, i32 %size)
20+
%cmp = call i32 @memcmp(ptr %0, ptr %1, i64 %2)
2121
%eq = icmp eq i32 %cmp, 0
2222
ret i1 %eq
2323
}
2424

25-
; CHECK: declare i32 @memcmp(ptr, ptr, i32)
26-
declare i32 @memcmp(ptr, ptr, i32)
25+
declare i32 @memcmp(ptr, ptr, i64)
26+
declare i32 @bcmp_impl(ptr, ptr, i64);
2727

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
28+
;; Ensure bcmp is not removed from module.
29+
; CHECK: define{{.*}}i32 @bcmp
30+
define i32 @bcmp(ptr %0, ptr %1, i64 %2) noinline {
31+
%r = call i32 @bcmp_impl(ptr %0, ptr %1, i64 %2)
32+
ret i32 %r
3333
}
3434

0 commit comments

Comments
 (0)