[PATCH] D63887: [PoC][ThinLTO] only emit used or referenced CFI records to index
Bob Haarman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 28 12:56:52 PDT 2019
inglorion updated this revision to Diff 207130.
inglorion added a comment.
Use ModuleToSummariesForIndex to find GUIDs defined or used by the module
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D63887/new/
https://reviews.llvm.org/D63887
Files:
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
===================================================================
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -3825,7 +3825,8 @@
Flags |= 0x10;
Stream.EmitRecord(bitc::FS_FLAGS, ArrayRef<uint64_t>{Flags});
- for (const auto &GVI : valueIds()) {
+ const std::map<GlobalValue::GUID, unsigned> &ValueIds = valueIds();
+ for (const auto &GVI : ValueIds) {
Stream.EmitRecord(bitc::FS_VALUE_GUID,
ArrayRef<uint64_t>{GVI.second, GVI.first});
}
@@ -3904,9 +3905,13 @@
NameVals.clear();
};
+ std::set<GlobalValue::GUID> DefOrUseGUIDs;
forEachSummary([&](GVInfo I, bool IsAliasee) {
GlobalValueSummary *S = I.second;
assert(S);
+ DefOrUseGUIDs.insert(I.first);
+ for (const ValueInfo &VI : S->refs())
+ DefOrUseGUIDs.insert(VI.getGUID());
auto ValueId = getValueId(I.first);
assert(ValueId);
@@ -4047,20 +4052,28 @@
if (!Index.cfiFunctionDefs().empty()) {
for (auto &S : Index.cfiFunctionDefs()) {
- NameVals.push_back(StrtabBuilder.add(S));
- NameVals.push_back(S.size());
+ if (DefOrUseGUIDs.count(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();
}
- Stream.EmitRecord(bitc::FS_CFI_FUNCTION_DEFS, NameVals);
- NameVals.clear();
}
if (!Index.cfiFunctionDecls().empty()) {
for (auto &S : Index.cfiFunctionDecls()) {
- NameVals.push_back(StrtabBuilder.add(S));
- NameVals.push_back(S.size());
+ if (DefOrUseGUIDs.count(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_DECLS, NameVals);
+ NameVals.clear();
}
- Stream.EmitRecord(bitc::FS_CFI_FUNCTION_DECLS, NameVals);
- NameVals.clear();
}
// Walk the GUIDs that were referenced, and write the
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63887.207130.patch
Type: text/x-patch
Size: 2254 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190628/9aaa257a/attachment.bin>
More information about the llvm-commits
mailing list