[PATCH] D143217: [BOLT][NFC] Add make_string_error
Amir Ayupov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 2 14:44:55 PST 2023
Amir created this revision.
Amir added a reviewer: bolt.
Herald added a reviewer: rafauler.
Herald added subscribers: treapster, ayermolo.
Herald added a reviewer: maksfb.
Herald added a project: All.
Amir requested review of this revision.
Herald added subscribers: llvm-commits, yota9.
Herald added a project: LLVM.
Provide a wrapper for `make_error<StringError>(..., inconvertibleErrorCode())`
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D143217
Files:
bolt/include/bolt/Utils/Utils.h
bolt/lib/Profile/YAMLProfileReader.cpp
bolt/lib/Rewrite/MachORewriteInstance.cpp
bolt/lib/Rewrite/RewriteInstance.cpp
bolt/lib/Utils/Utils.cpp
Index: bolt/lib/Utils/Utils.cpp
===================================================================
--- bolt/lib/Utils/Utils.cpp
+++ bolt/lib/Utils/Utils.cpp
@@ -19,6 +19,10 @@
namespace llvm {
namespace bolt {
+Error make_string_error(const Twine &Message) {
+ return make_error<StringError>(Message, inconvertibleErrorCode());
+}
+
void report_error(StringRef Message, std::error_code EC) {
assert(EC);
errs() << "BOLT-ERROR: '" << Message << "': " << EC.message() << ".\n";
Index: bolt/lib/Rewrite/RewriteInstance.cpp
===================================================================
--- bolt/lib/Rewrite/RewriteInstance.cpp
+++ bolt/lib/Rewrite/RewriteInstance.cpp
@@ -375,10 +375,8 @@
if (ProfileReader) {
// Already exists
- return make_error<StringError>(Twine("multiple profiles specified: ") +
- ProfileReader->getFilename() + " and " +
- Filename,
- inconvertibleErrorCode());
+ return make_string_error(Twine("multiple profiles specified: ") +
+ ProfileReader->getFilename() + " and " + Filename);
}
// Spawn a profile reader based on file contents.
@@ -3108,9 +3106,8 @@
JITEvaluatedSymbol(I->getAddress(), JITSymbolFlags());
continue;
}
- OnResolved(make_error<StringError>(
- "Symbol not found required by runtime: " + Symbol,
- inconvertibleErrorCode()));
+ OnResolved(make_string_error("Symbol not found required by runtime: " +
+ Symbol));
return;
}
OnResolved(std::move(AllResults));
Index: bolt/lib/Rewrite/MachORewriteInstance.cpp
===================================================================
--- bolt/lib/Rewrite/MachORewriteInstance.cpp
+++ bolt/lib/Rewrite/MachORewriteInstance.cpp
@@ -118,9 +118,8 @@
if (ProfileReader) {
// Already exists
- return make_error<StringError>(
- Twine("multiple profiles specified: ") + ProfileReader->getFilename() +
- " and " + Filename, inconvertibleErrorCode());
+ return make_string_error(Twine("multiple profiles specified: ") +
+ ProfileReader->getFilename() + " and " + Filename);
}
ProfileReader = std::make_unique<DataReader>(Filename);
Index: bolt/lib/Profile/YAMLProfileReader.cpp
===================================================================
--- bolt/lib/Profile/YAMLProfileReader.cpp
+++ bolt/lib/Profile/YAMLProfileReader.cpp
@@ -255,14 +255,11 @@
// Sanity check.
if (YamlBP.Header.Version != 1)
- return make_error<StringError>(
- Twine("cannot read profile : unsupported version"),
- inconvertibleErrorCode());
+ return make_string_error(Twine("cannot read profile: unsupported version"));
if (YamlBP.Header.EventNames.find(',') != StringRef::npos)
- return make_error<StringError>(
- Twine("multiple events in profile are not supported"),
- inconvertibleErrorCode());
+ return make_string_error(
+ Twine("multiple events in profile are not supported"));
// Match profile to function based on a function name.
buildNameMaps(BC.getBinaryFunctions());
Index: bolt/include/bolt/Utils/Utils.h
===================================================================
--- bolt/include/bolt/Utils/Utils.h
+++ bolt/include/bolt/Utils/Utils.h
@@ -27,6 +27,8 @@
TempList.swap(List);
}
+Error make_string_error(const Twine &Message);
+
void report_error(StringRef Message, std::error_code EC);
void report_error(StringRef Message, Error E);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143217.494436.patch
Type: text/x-patch
Size: 3659 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230202/d4edabfa/attachment.bin>
More information about the llvm-commits
mailing list