1; REQUIRES: asserts 2; RUN: opt -passes=elim-avail-extern -avail-extern-to-local -stats -S 2>&1 < %s | FileCheck %s 3; 4; RUN: echo '[{"Guid":1234, "Counters": [1]}]' | llvm-ctxprof-util fromYAML --input=- --output=%t_profile.ctxprofdata 5; 6; Because we pass a contextual profile with a root defined in this module, we expect the outcome to be the same as-if 7; we passed -avail-extern-to-local, i.e. available_externally don't get elided and instead get converted to local linkage 8; RUN: opt -passes='assign-guid,require<ctx-prof-analysis>,elim-avail-extern' -use-ctx-profile=%t_profile.ctxprofdata -stats -S 2>&1 < %s | FileCheck %s 9 10; If the profile doesn't apply to this module, available_externally won't get converted to internal linkage, and will be 11; removed instead. 12; RUN: echo '[{"Guid":5678, "Counters": [1]}]' | llvm-ctxprof-util fromYAML --input=- --output=%t_profile_bad.ctxprofdata 13; RUN: opt -passes='assign-guid,require<ctx-prof-analysis>,elim-avail-extern' -use-ctx-profile=%t_profile_bad.ctxprofdata -stats -S 2>&1 < %s | FileCheck %s --check-prefix=NOOP 14 15declare void @call_out(ptr %fct) 16 17define available_externally hidden void @f() { 18 ret void 19} 20 21define available_externally hidden void @g() { 22 ret void 23} 24 25define void @hello(ptr %g) !guid !0 { 26 call void @f() 27 %f = load ptr, ptr @f 28 call void @call_out(ptr %f) 29 ret void 30} 31 32!0 = !{i64 1234} 33 34; CHECK: define internal void @f.__uniq.{{[0-9|a-f]*}}() 35; CHECK: declare hidden void @g() 36; CHECK: call void @f.__uniq.{{[0-9|a-f]*}}() 37; CHECK-NEXT: load ptr, ptr @f 38; CHECK-NEXT: call void @call_out(ptr %f) 39; CHECK: Statistics Collected 40; CHECK: 1 elim-avail-extern - Number of functions converted 41; CHECK: 1 elim-avail-extern - Number of functions removed 42 43; NOOP: 2 elim-avail-extern - Number of functions removed