aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
diff options
context:
space:
mode:
authorVitaly Buka <vitalybuka@google.com>2025-03-08 18:02:30 -0800
committerGitHub <noreply@github.com>2025-03-08 18:02:30 -0800
commit0715c6cc6d11814b8a31bc0368ca080b72810177 (patch)
tree4a0201c254438bf7b954f779ffcf761841e6901c /llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
parent1649ca5af07a40948ea409ca055330bec1419e72 (diff)
downloadllvm-0715c6cc6d11814b8a31bc0368ca080b72810177.zip
llvm-0715c6cc6d11814b8a31bc0368ca080b72810177.tar.gz
llvm-0715c6cc6d11814b8a31bc0368ca080b72810177.tar.bz2
[NFC][IR] De-duplicate CFI related code (#130450)
Diffstat (limited to 'llvm/lib/Bitcode/Writer/BitcodeWriter.cpp')
-rw-r--r--llvm/lib/Bitcode/Writer/BitcodeWriter.cpp36
1 files changed, 15 insertions, 21 deletions
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
index bddc2cd..2f4802c 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.