[llvm] 0715c6c - [NFC][IR] De-duplicate CFI related code (#130450)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 8 18:02:34 PST 2025
Author: Vitaly Buka
Date: 2025-03-08T18:02:30-08:00
New Revision: 0715c6cc6d11814b8a31bc0368ca080b72810177
URL: https://github.com/llvm/llvm-project/commit/0715c6cc6d11814b8a31bc0368ca080b72810177
DIFF: https://github.com/llvm/llvm-project/commit/0715c6cc6d11814b8a31bc0368ca080b72810177.diff
LOG: [NFC][IR] De-duplicate CFI related code (#130450)
Added:
Modified:
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
index bddc2cd2180b1..2f4802ca2d404 100644
--- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -5064,29 +5064,23 @@ void IndexBitcodeWriter::writeCombinedGlobalValueSummary() {
getReferencedTypeIds(FS, ReferencedTypeIds);
}
- for (auto &S : Index.cfiFunctionDefs()) {
- if (DefOrUseGUIDs.contains(
- GlobalValue::getGUID(GlobalValue::dropLLVMManglingEscape(S)))) {
- NameVals.push_back(StrtabBuilder.add(S));
- NameVals.push_back(S.size());
+ auto EmitCfiFunctions = [&](const CfiFunctionIndex &CfiIndex,
+ bitc::GlobalValueSummarySymtabCodes Code) {
+ for (auto &S : CfiIndex) {
+ if (DefOrUseGUIDs.contains(
+ GlobalValue::getGUID(GlobalValue::dropLLVMManglingEscape(S)))) {
+ NameVals.push_back(StrtabBuilder.add(S));
+ NameVals.push_back(S.size());
+ }
}
- }
- if (!NameVals.empty()) {
- Stream.EmitRecord(bitc::FS_CFI_FUNCTION_DEFS, NameVals);
- NameVals.clear();
- }
-
- for (auto &S : Index.cfiFunctionDecls()) {
- if (DefOrUseGUIDs.contains(
- GlobalValue::getGUID(GlobalValue::dropLLVMManglingEscape(S)))) {
- NameVals.push_back(StrtabBuilder.add(S));
- NameVals.push_back(S.size());
+ if (!NameVals.empty()) {
+ Stream.EmitRecord(Code, NameVals);
+ NameVals.clear();
}
- }
- if (!NameVals.empty()) {
- Stream.EmitRecord(bitc::FS_CFI_FUNCTION_DECLS, NameVals);
- NameVals.clear();
- }
+ };
+
+ EmitCfiFunctions(Index.cfiFunctionDefs(), bitc::FS_CFI_FUNCTION_DEFS);
+ EmitCfiFunctions(Index.cfiFunctionDecls(), bitc::FS_CFI_FUNCTION_DECLS);
// Walk the GUIDs that were referenced, and write the
// corresponding type id records.
More information about the llvm-commits
mailing list