[PATCH] D147308: [BOLT][NFC] Simplify code using std::optional
Yi Kong via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 31 22:48:59 PDT 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd788db3d193e: [BOLT][NFC] Simplify code using std::optional (authored by kongyi).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D147308/new/
https://reviews.llvm.org/D147308
Files:
bolt/tools/merge-fdata/merge-fdata.cpp
Index: bolt/tools/merge-fdata/merge-fdata.cpp
===================================================================
--- bolt/tools/merge-fdata/merge-fdata.cpp
+++ bolt/tools/merge-fdata/merge-fdata.cpp
@@ -257,8 +257,7 @@
void mergeLegacyProfiles(const SmallVectorImpl<std::string> &Filenames) {
errs() << "Using legacy profile format.\n";
- bool BoltedCollection = false;
- bool First = true;
+ std::optional<bool> BoltedCollection;
StringMap<uint64_t> Entries;
for (const std::string &Filename : Filenames) {
if (isYAML(Filename))
@@ -272,17 +271,18 @@
StringRef Buf = MB.get()->getBuffer();
// Check if the string "boltedcollection" is in the first line
if (Buf.startswith("boltedcollection\n")) {
- if (!First && !BoltedCollection)
+ if (!BoltedCollection.value_or(true))
report_error(
Filename,
"cannot mix profile collected in BOLT and non-BOLT deployments");
BoltedCollection = true;
Buf = Buf.drop_front(17);
} else {
- if (BoltedCollection)
+ if (BoltedCollection.value_or(false))
report_error(
Filename,
"cannot mix profile collected in BOLT and non-BOLT deployments");
+ BoltedCollection = false;
}
SmallVector<StringRef> Lines;
@@ -298,7 +298,6 @@
Count += Entries.lookup(Signature);
Entries.insert_or_assign(Signature, Count);
}
- First = false;
}
if (BoltedCollection)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147308.510182.patch
Type: text/x-patch
Size: 1472 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230401/fd212c9f/attachment.bin>
More information about the llvm-commits
mailing list