1 ; RUN: rm -rf %t && split-file %s %t && cd %t
2 ; RUN: opt -module-summary -o a.bc a.ll
3 ; RUN: opt -module-summary -o b.bc b.ll
4 ; RUN: llvm-lto2 run a.bc b.bc -o t --save-temps \
5 ; RUN: -r a.bc,external.ifunc,pl -r a.bc,use,pl -r a.bc,use2,pl -r a.bc,__cpu_model,lx \
6 ; RUN: -r b.bc,main,plx -r b.bc,use,l -r b.bc,use2,l
7 ; RUN: llvm-dis < t.1.3.import.bc | FileCheck %s --check-prefix=A
8 ; RUN: llvm-dis < t.2.3.import.bc | FileCheck %s --check-prefix=B --implicit-check-not='@internal.resolver'
10 ; A: define internal nonnull ptr @internal.resolver()
11 ; A: define internal i32 @internal.default.1(i32 %n)
13 ;; The ifunc implementations of internal.ifunc are internal in A, so they cannot
14 ;; be referenced by B. Our implementation actually ensures that the ifunc resolver
15 ;; along with its implementations are not imported.
16 ; B: declare i32 @use(i32) local_unnamed_addr
17 ; B: define available_externally i32 @use2(i32 %n) local_unnamed_addr
18 ; B: declare i32 @external.ifunc(i32)
21 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
22 target triple = "x86_64-unknown-linux-gnu"
24 $internal.resolver = comdat any
26 @__cpu_model = external dso_local local_unnamed_addr global { i32, i32, i32, [1 x i32] }
28 @internal.ifunc = internal ifunc i32 (i32), ptr @internal.resolver
29 @external.ifunc = ifunc i32 (i32), ptr @internal.resolver
31 define dso_local i32 @use(i32 %n) local_unnamed_addr {
33 %call = call i32 @internal.ifunc(i32 %n)
37 define dso_local i32 @use2(i32 %n) local_unnamed_addr {
39 %call = call i32 @external.ifunc(i32 %n)
43 define internal nonnull ptr @internal.resolver() comdat {
45 %0 = load i32, ptr getelementptr inbounds ({ i32, i32, i32, [1 x i32] }, ptr @__cpu_model, i64 0, i32 3, i64 0), align 4
47 %.not = icmp eq i32 %1, 0
48 %internal.popcnt.0.internal.default.1 = select i1 %.not, ptr @internal.default.1, ptr @internal.popcnt.0
49 ret ptr %internal.popcnt.0.internal.default.1
52 define internal i32 @internal.popcnt.0(i32 %n) {
54 %0 = call i32 @llvm.ctpop.i32(i32 %n)
58 declare i32 @llvm.ctpop.i32(i32)
60 define internal i32 @internal.default.1(i32 %n) {
62 %0 = call i32 @llvm.ctpop.i32(i32 %n)
67 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
68 target triple = "x86_64-unknown-linux-gnu"
70 define dso_local i32 @main() local_unnamed_addr {
72 %0 = call i32 @use(i32 0)
73 %1 = call i32 @use2(i32 0)
78 declare i32 @use(i32) local_unnamed_addr
79 declare i32 @use2(i32) local_unnamed_addr