1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals --include-generated-funcs
2 ; RUN: opt -S -passes=lower-ifunc < %s | FileCheck %s
4 define ptr @resolver() {
5 ret ptr inttoptr (i64 333 to ptr)
8 @resolver_alias = alias ptr (), ptr @resolver
9 @ifunc_alias = alias ptr (), ptr @resolver_alias
11 @ifunc0_kept = ifunc float (i64), ptr @resolver_alias
12 @ifunc1_removed = ifunc float (i64), ptr @resolver_alias
14 @ifunc_def = ifunc float (i64), ptr @resolver
15 @alias_of_ifunc = alias float (i64), ptr @ifunc_def
17 define float @call_ifunc_aliasee(i64 %arg) {
18 %call = call float @ifunc1_removed(i64 %arg)
22 define float @call_alias_of_ifunc(i64 %arg) {
23 %call = call float @alias_of_ifunc(i64 %arg)
27 ; CHECK: @[[GLOB0:[0-9]+]] = internal global [3 x ptr] poison, align 8
28 ; CHECK: @[[LLVM_GLOBAL_CTORS:[a-zA-Z0-9_$"\\.-]+]] = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 10, ptr @[[GLOB1:[0-9]+]], ptr null }]
29 ; CHECK: @[[RESOLVER_ALIAS:[a-zA-Z0-9_$"\\.-]+]] = alias ptr (), ptr @resolver
30 ; CHECK: @[[IFUNC_ALIAS:[a-zA-Z0-9_$"\\.-]+]] = alias ptr (), ptr @resolver_alias
31 ; CHECK: @[[ALIAS_OF_IFUNC:[a-zA-Z0-9_$"\\.-]+]] = alias float (i64), ptr @ifunc_def
32 ; CHECK: @[[IFUNC_DEF:[a-zA-Z0-9_$"\\.-]+]] = ifunc float (i64), ptr @resolver
34 ; CHECK-LABEL: define {{[^@]+}}@resolver(
35 ; CHECK-NEXT: ret ptr inttoptr (i64 333 to ptr)
38 ; CHECK-LABEL: define {{[^@]+}}@call_ifunc_aliasee(
39 ; CHECK-NEXT: [[TMP1:%.*]] = load ptr, ptr getelementptr inbounds ([3 x ptr], ptr @[[GLOB0]], i32 0, i32 1), align 8
40 ; CHECK-NEXT: [[CALL:%.*]] = call float [[TMP1]](i64 [[ARG:%.*]])
41 ; CHECK-NEXT: ret float [[CALL]]
44 ; CHECK-LABEL: define {{[^@]+}}@call_alias_of_ifunc(
45 ; CHECK-NEXT: [[CALL:%.*]] = call float @alias_of_ifunc(i64 [[ARG:%.*]])
46 ; CHECK-NEXT: ret float [[CALL]]
49 ; CHECK-LABEL: define {{[^@]+}}@1(
50 ; CHECK-NEXT: [[TMP1:%.*]] = call ptr @resolver()
51 ; CHECK-NEXT: store ptr [[TMP1]], ptr @[[GLOB0]], align 8
52 ; CHECK-NEXT: [[TMP2:%.*]] = call ptr @resolver()
53 ; CHECK-NEXT: store ptr [[TMP2]], ptr getelementptr inbounds ([3 x ptr], ptr @[[GLOB0]], i32 0, i32 1), align 8
54 ; CHECK-NEXT: [[TMP3:%.*]] = call ptr @resolver()
55 ; CHECK-NEXT: store ptr [[TMP3]], ptr getelementptr inbounds ([3 x ptr], ptr @[[GLOB0]], i32 0, i32 2), align 8
56 ; CHECK-NEXT: ret void