1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 3
2 ; RUN: opt -passes=mergefunc -S %s | FileCheck %s
4 ; This test contains three identical functions, aside from the metadata
5 ; they pass to a function call. This test verifies that the function merger
6 ; pass is able to merge the two functions that are truly identical,
7 ; but the third that passes different metadata is preserved
9 declare { ptr, i1 } @llvm.type.checked.load(ptr, i32, metadata)
11 define i1 @merge_candidate_a(ptr %ptr, i32 %offset) {
12 ; CHECK-LABEL: define i1 @merge_candidate_a(
13 ; CHECK-SAME: ptr [[PTR:%.*]], i32 [[OFFSET:%.*]]) {
14 ; CHECK-NEXT: [[TMP1:%.*]] = call { ptr, i1 } @llvm.type.checked.load(ptr [[PTR]], i32 [[OFFSET]], metadata !"common_metadata")
15 ; CHECK-NEXT: [[TMP2:%.*]] = extractvalue { ptr, i1 } [[TMP1]], 1
16 ; CHECK-NEXT: ret i1 [[TMP2]]
18 %1 = call { ptr, i1 } @llvm.type.checked.load(ptr %ptr, i32 %offset, metadata !"common_metadata")
19 %2 = extractvalue { ptr, i1 } %1, 1
23 define i1 @merge_candidate_c(ptr %ptr, i32 %offset) {
24 ; CHECK-LABEL: define i1 @merge_candidate_c(
25 ; CHECK-SAME: ptr [[PTR:%.*]], i32 [[OFFSET:%.*]]) {
26 ; CHECK-NEXT: [[TMP1:%.*]] = call { ptr, i1 } @llvm.type.checked.load(ptr [[PTR]], i32 [[OFFSET]], metadata !"different_metadata")
27 ; CHECK-NEXT: [[TMP2:%.*]] = extractvalue { ptr, i1 } [[TMP1]], 1
28 ; CHECK-NEXT: ret i1 [[TMP2]]
30 %1 = call { ptr, i1 } @llvm.type.checked.load(ptr %ptr, i32 %offset, metadata !"different_metadata")
31 %2 = extractvalue { ptr, i1 } %1, 1
35 define i1 @merge_candidate_b(ptr %ptr, i32 %offset) {
36 ; CHECK-LABEL: define i1 @merge_candidate_b(
37 ; CHECK-SAME: ptr [[TMP0:%.*]], i32 [[TMP1:%.*]]) {
38 ; CHECK-NEXT: [[TMP3:%.*]] = tail call i1 @merge_candidate_a(ptr [[TMP0]], i32 [[TMP1]])
39 ; CHECK-NEXT: ret i1 [[TMP3]]
41 %1 = call { ptr, i1 } @llvm.type.checked.load(ptr %ptr, i32 %offset, metadata !"common_metadata")
42 %2 = extractvalue { ptr, i1 } %1, 1