Skip to content

Commit ccc7a07

Browse files
authored
[BOLT] Drop blocks without profile in BAT YAML (#107970)
Align BAT YAML (DataAggregator) to YAMLProfileWriter which drops blocks without profile: https://github.com/llvm/llvm-project/blob/61372fc5db9b14fd612be8a58a76edd7f0ee38aa/bolt/lib/Profile/YAMLProfileWriter.cpp#L162-L176 Test Plan: NFCI
1 parent 86ec59e commit ccc7a07

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

bolt/lib/Profile/DataAggregator.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2427,11 +2427,15 @@ std::error_code DataAggregator::writeBATYAML(BinaryContext &BC,
24272427
}
24282428
}
24292429
}
2430-
// Drop blocks without a hash, won't be useful for stale matching.
2431-
llvm::erase_if(YamlBF.Blocks,
2432-
[](const yaml::bolt::BinaryBasicBlockProfile &YamlBB) {
2433-
return YamlBB.Hash == (yaml::Hex64)0;
2434-
});
2430+
// Skip printing if there's no profile data
2431+
llvm::erase_if(
2432+
YamlBF.Blocks, [](const yaml::bolt::BinaryBasicBlockProfile &YamlBB) {
2433+
auto HasCount = [](const auto &SI) { return SI.Count; };
2434+
bool HasAnyCount = YamlBB.ExecCount ||
2435+
llvm::any_of(YamlBB.Successors, HasCount) ||
2436+
llvm::any_of(YamlBB.CallSites, HasCount);
2437+
return !HasAnyCount;
2438+
});
24352439
BP.Functions.emplace_back(YamlBF);
24362440
}
24372441
}

0 commit comments

Comments
 (0)