1 ; RUN: llvm-reduce --abort-on-invalid-reduction --delta-passes=ifuncs --test FileCheck --test-arg --check-prefixes=CHECK-INTERESTINGNESS --test-arg %s --test-arg --input-file %s -o %t.0
2 ; RUN: FileCheck --check-prefixes=CHECK-FINAL-IFUNCS,ALL --input-file=%t.0 %s
4 ; RUN: llvm-reduce --abort-on-invalid-reduction --delta-passes=aliases,ifuncs --test FileCheck --test-arg --check-prefixes=CHECK-INTERESTINGNESS --test-arg %s --test-arg --input-file %s -o %t.1
5 ; RUN: FileCheck --check-prefixes=CHECK-FINAL-BOTH,ALL --input-file=%t.1 %s
7 ; Check interaction of reductions between aliases and ifuncs
10 ; CHECK-INTERESTINGNESS: @ifunc0_kept =
13 ; ALL: [[TABLE:@[0-9]+]] = internal global [2 x ptr] poison
14 ; ALL: @llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 10, ptr [[CONSTRUCTOR:@[0-9]+]], ptr null }]
17 ; CHECK-FINAL-IFUNCS: @resolver_alias = alias ptr (), ptr @resolver
18 ; CHECK-FINAL-IFUNCS: @ifunc_alias = alias ptr (), ptr @resolver_alias
19 ; CHECK-FINAL-IFUNCS: @alias_of_ifunc = alias float (i64), ptr @ifunc_def
21 ; CHECK-FINAL-IFUNCS: @ifunc0_kept = ifunc float (i64), ptr @resolver_alias
22 ; CHECK-FINAL-IFUNCS: @ifunc_def = ifunc float (i64), ptr @resolver
25 ; CHECK-FINAL-BOTH-NOT: _alias
26 ; CHECK-FINAL-BOTH-NOT: @ifunc
27 ; CHECK-FINAL-BOTH: @ifunc0_kept = ifunc float (i64), ptr @resolver
28 ; CHECK-FINAL-BOTH-NOT: _alias
29 ; CHECK-FINAL-BOTH-NOT: @ifunc
30 define ptr @resolver() {
31 ret ptr inttoptr (i64 333 to ptr)
34 @resolver_alias = alias ptr (), ptr @resolver
35 @ifunc_alias = alias ptr (), ptr @resolver_alias
37 @ifunc0_kept = ifunc float (i64), ptr @resolver_alias
38 @ifunc1_removed = ifunc float (i64), ptr @resolver_alias
40 @ifunc_def = ifunc float (i64), ptr @resolver
41 @alias_of_ifunc = alias float (i64), ptr @ifunc_def
43 ; ALL-LABEL: define float @call_ifunc_aliasee(i64 %arg) {
44 ; ALL: %1 = load ptr, ptr [[TABLE]], align 8
45 ; ALL: %call = call float %1(i64 %arg)
46 ; ALL: ret float %call
47 define float @call_ifunc_aliasee(i64 %arg) {
48 %call = call float @ifunc1_removed(i64 %arg)
52 ; ALL-LABEL: @call_alias_of_ifunc(
53 ; CHECK-FINAL-IFUNCS: call float @alias_of_ifunc(
55 ; CHECK-FINAL-BOTH-NEXT: %1 = load ptr, ptr getelementptr inbounds ([2 x ptr], ptr [[TABLE]], i32 0, i32 1), align 8
56 ; CHECK-FINAL-BOTH-NEXT: %call = call float %1(i64 %arg)
57 ; CHECK-FINAL-BOTH-NEXT: ret float %call
58 define float @call_alias_of_ifunc(i64 %arg) {
59 %call = call float @alias_of_ifunc(i64 %arg)
63 ; CHECK-FINAL-BOTH: define internal void [[CONSTRUCTOR]]() {
64 ; CHECK-FINAL-BOTH-NEXT: %1 = call ptr @resolver()
65 ; CHECK-FINAL-BOTH-NEXT: store ptr %1, ptr [[TABLE]], align 8
66 ; CHECK-FINAL-BOTH-NEXT: %2 = call ptr @resolver()
67 ; CHECK-FINAL-BOTH-NEXT: store ptr %2, ptr getelementptr inbounds ([2 x ptr], ptr [[TABLE]], i32 0, i32 1), align 8
68 ; CHECK-FINAL-BOTH-NEXT: ret void