1; Test to ensure that we always select the same copy of a linkonce function 2; when it is encountered with different thresholds. When we encounter the 3; copy in funcimport_resolved1.ll with a higher threshold via the direct call 4; from main(), it will be selected for importing. When we encounter it with a 5; lower threshold by reaching it from the deeper call chain via foo(), it 6; won't be selected for importing. We don't want to select both the copy from 7; funcimport_resolved1.ll and the smaller one from funcimport_resolved2.ll, 8; leaving it up to the backend to figure out which one to actually import. 9; The linkonce_odr may have different instruction counts in practice due to 10; different inlines in the compile step. 11 12; Require asserts so we can use -debug-only 13; REQUIRES: asserts 14 15; REQUIRES: x86-registered-target 16 17; RUN: opt -module-summary %s -o %t.bc 18; RUN: opt -module-summary %p/Inputs/funcimport_resolved1.ll -o %t2.bc 19; RUN: opt -module-summary %p/Inputs/funcimport_resolved2.ll -o %t3.bc 20 21; First verify that all callees are imported with the default instruction limit 22; RUN: llvm-lto2 run %t.bc %t2.bc %t3.bc -o %t4 -r=%t.bc,_main,pl -r=%t.bc,_linkonceodrfunc,l -r=%t.bc,_foo,l -r=%t2.bc,_foo,pl -r=%t2.bc,_linkonceodrfunc,pl -r=%t2.bc,_linkonceodrfunc2,pl -r=%t3.bc,_linkonceodrfunc,l -thinlto-threads=1 -debug-only=function-import 2>&1 | FileCheck %s --check-prefix=INSTLIMDEFAULT 23; INSTLIMDEFAULT: Is importing function {{.*}} foo from {{.*}}funcimport_resolved1.ll 24; INSTLIMDEFAULT: Is importing function {{.*}} linkonceodrfunc from {{.*}}funcimport_resolved1.ll 25; INSTLIMDEFAULT: Is importing function {{.*}} linkonceodrfunc2 from {{.*}}funcimport_resolved1.ll 26; INSTLIMDEFAULT: Is importing function {{.*}} f from {{.*}}funcimport_resolved1.ll 27; INSTLIMDEFAULT-NOT: Is importing function {{.*}} linkonceodrfunc from {{.*}}funcimport_resolved2.ll 28 29; Now run with the lower threshold that will only allow linkonceodrfunc to be 30; imported from funcimport_resolved1.ll when encountered via the direct call 31; from main(). Ensure we don't also select the copy in funcimport_resolved2.ll 32; when it is encountered via the deeper call chain. 33; RUN: llvm-lto2 run %t.bc %t2.bc %t3.bc -o %t4 -r=%t.bc,_main,pl -r=%t.bc,_linkonceodrfunc,l -r=%t.bc,_foo,l -r=%t2.bc,_foo,pl -r=%t2.bc,_linkonceodrfunc,pl -r=%t2.bc,_linkonceodrfunc2,pl -r=%t3.bc,_linkonceodrfunc,l -thinlto-threads=1 -debug-only=function-import -import-instr-limit=8 2>&1 | FileCheck %s --check-prefix=INSTLIM8 34; INSTLIM8: Is importing function {{.*}} foo from {{.*}}funcimport_resolved1.ll 35; INSTLIM8: Is importing function {{.*}} linkonceodrfunc from {{.*}}funcimport_resolved1.ll 36; INSTLIM8: Not importing function {{.*}} linkonceodrfunc2 from {{.*}}funcimport_resolved1.ll 37; INSTLIM8: Is importing function {{.*}} f from {{.*}}funcimport_resolved1.ll 38; INSTLIM8-NOT: Is importing function {{.*}} linkonceodrfunc from {{.*}}funcimport_resolved2.ll 39 40target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 41target triple = "x86_64-apple-macosx10.11.0" 42 43define i32 @main() #0 { 44entry: 45 call void (...) @foo() 46 call void (...) @linkonceodrfunc() 47 ret i32 0 48} 49 50declare void @foo(...) #1 51declare void @linkonceodrfunc(...) #1 52