Skip to content

Commit b431546

Browse files
authored
[BOLT] Check BF state in stale matching (#85339)
Only apply stale matching if the binary function is in CFG state, i.e. has basic blocks. Test Plan: Updated bolt/test/X86/reader-stale-yaml.test
1 parent cd07125 commit b431546

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

bolt/lib/Profile/StaleProfileMatching.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,9 @@ void assignProfile(BinaryFunction &BF,
705705

706706
bool YAMLProfileReader::inferStaleProfile(
707707
BinaryFunction &BF, const yaml::bolt::BinaryFunctionProfile &YamlBF) {
708+
if (!BF.hasCFG())
709+
return false;
710+
708711
LLVM_DEBUG(dbgs() << "BOLT-INFO: applying profile inference for "
709712
<< "\"" << BF.getPrintName() << "\"\n");
710713

bolt/test/X86/reader-stale-yaml.test

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ RUN: --profile-ignore-hash=1 --profile-use-dfs=0 --debug-only=bolt-prof 2>&1 |
1414
RUN: llvm-bolt %t.exe -o %t.null --b %p/Inputs/blarge_profile_stale.yaml \
1515
RUN: --print-cfg --print-only=SolveCubic --infer-stale-profile=1 \
1616
RUN: --profile-ignore-hash=1 --profile-use-dfs=0 --debug-only=bolt-prof 2>&1 | FileCheck %s -check-prefix=CHECK2
17+
# Testing skipped function
18+
RUN: llvm-bolt %t.exe -o %t.null --b %p/Inputs/blarge_profile_stale.yaml \
19+
RUN: --print-cfg --print-only=usqrt --infer-stale-profile=1 --skip-funcs=usqrt \
20+
RUN: --profile-ignore-hash=1 --profile-use-dfs=0
1721

1822
CHECK0: BOLT-INFO: 2 out of 7 functions in the binary (28.6%) have non-empty execution profile
1923
CHECK0: BOLT-WARNING: 2 (100.0% of all profiled) functions have invalid (possibly stale) profile

0 commit comments

Comments
 (0)