|
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. |
4 | 5 |
|
5 | 6 | ; RUN: opt %s -o %t -module-summary -mtriple x86_64-unknown-linux-musl |
6 | 7 | ; RUN: llvm-lto2 run -o %t2 \ |
7 | 8 | ; RUN: -r %t,foo,plx \ |
8 | 9 | ; 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 |
11 | 13 |
|
12 | | -define i1 @foo(ptr %0, [2 x i32] %1) { |
| 14 | +define i1 @foo(ptr %0, ptr %1, i64 %2) { |
13 | 15 | ; 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 |
17 | 18 | ; CHECK-NEXT: ret i1 %eq |
18 | 19 |
|
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) |
21 | 21 | %eq = icmp eq i32 %cmp, 0 |
22 | 22 | ret i1 %eq |
23 | 23 | } |
24 | 24 |
|
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); |
27 | 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 |
| 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 |
33 | 33 | } |
34 | 34 |
|
0 commit comments