aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-rc/llvm-rc.cpp
diff options
context:
space:
mode:
authorserge-sans-paille <sguelton@mozilla.com>2022-12-26 09:19:09 +0100
committerserge-sans-paille <sguelton@mozilla.com>2022-12-27 09:55:19 +0100
commitd9ab3e82f30d646deff054230b0c742704a1cf26 (patch)
treebc1265dff45eb195c81b781bd11a1e3edd0e28bb /llvm/tools/llvm-rc/llvm-rc.cpp
parentd065472c9ebca5efea7361c229ead7d5cb6f81b5 (diff)
downloadllvm-d9ab3e82f30d646deff054230b0c742704a1cf26.zip
llvm-d9ab3e82f30d646deff054230b0c742704a1cf26.tar.gz
llvm-d9ab3e82f30d646deff054230b0c742704a1cf26.tar.bz2
[clang] Use a StringRef instead of a raw char pointer to store builtin and call information
This avoids recomputing string length that is already known at compile time. It has a slight impact on preprocessing / compile time, see https://llvm-compile-time-tracker.com/compare.php?from=3f36d2d579d8b0e8824d9dd99bfa79f456858f88&to=e49640c507ddc6615b5e503144301c8e41f8f434&stat=instructions:u This a recommit of e953ae5bbc313fd0cc980ce021d487e5b5199ea4 and the subsequent fixes caa713559bd38f337d7d35de35686775e8fb5175 and 06b90e2e9c991e211fecc97948e533320a825470. The above patchset caused some version of GCC to take eons to compile clang/lib/Basic/Targets/AArch64.cpp, as spotted in aa171833ab0017d9732e82b8682c9848ab25ff9e. The fix is to make BuiltinInfo tables a compilation unit static variable, instead of a private static variable. Differential Revision: https://reviews.llvm.org/D139881
Diffstat (limited to 'llvm/tools/llvm-rc/llvm-rc.cpp')
-rw-r--r--llvm/tools/llvm-rc/llvm-rc.cpp30
1 files changed, 20 insertions, 10 deletions
diff --git a/llvm/tools/llvm-rc/llvm-rc.cpp b/llvm/tools/llvm-rc/llvm-rc.cpp
index 00fb9c1..f7f9ce2 100644
--- a/llvm/tools/llvm-rc/llvm-rc.cpp
+++ b/llvm/tools/llvm-rc/llvm-rc.cpp
@@ -55,7 +55,11 @@ enum ID {
#undef OPTION
};
-#define PREFIX(NAME, VALUE) const char *const NAME[] = VALUE;
+namespace rc_opt {
+#define PREFIX(NAME, VALUE) \
+ static constexpr StringLiteral NAME##_init[] = VALUE; \
+ static constexpr ArrayRef<StringLiteral> NAME(NAME##_init, \
+ std::size(NAME##_init) - 1);
#include "Opts.inc"
#undef PREFIX
@@ -70,10 +74,11 @@ static constexpr opt::OptTable::Info InfoTable[] = {
#include "Opts.inc"
#undef OPTION
};
+} // namespace rc_opt
class RcOptTable : public opt::OptTable {
public:
- RcOptTable() : OptTable(InfoTable, /* IgnoreCase = */ true) {}
+ RcOptTable() : OptTable(rc_opt::InfoTable, /* IgnoreCase = */ true) {}
};
enum Windres_ID {
@@ -85,25 +90,30 @@ enum Windres_ID {
#undef OPTION
};
-#define PREFIX(NAME, VALUE) const char *const WINDRES_##NAME[] = VALUE;
+namespace windres_opt {
+#define PREFIX(NAME, VALUE) \
+ static constexpr StringLiteral NAME##_init[] = VALUE; \
+ static constexpr ArrayRef<StringLiteral> NAME(NAME##_init, \
+ std::size(NAME##_init) - 1);
#include "WindresOpts.inc"
#undef PREFIX
-static constexpr opt::OptTable::Info WindresInfoTable[] = {
+static constexpr opt::OptTable::Info InfoTable[] = {
#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
HELPTEXT, METAVAR, VALUES) \
- { \
- WINDRES_##PREFIX, NAME, HELPTEXT, \
- METAVAR, WINDRES_##ID, opt::Option::KIND##Class, \
- PARAM, FLAGS, WINDRES_##GROUP, \
- WINDRES_##ALIAS, ALIASARGS, VALUES},
+ {PREFIX, NAME, HELPTEXT, \
+ METAVAR, WINDRES_##ID, opt::Option::KIND##Class, \
+ PARAM, FLAGS, WINDRES_##GROUP, \
+ WINDRES_##ALIAS, ALIASARGS, VALUES},
#include "WindresOpts.inc"
#undef OPTION
};
+} // namespace windres_opt
class WindresOptTable : public opt::OptTable {
public:
- WindresOptTable() : OptTable(WindresInfoTable, /* IgnoreCase = */ false) {}
+ WindresOptTable()
+ : OptTable(windres_opt::InfoTable, /* IgnoreCase = */ false) {}
};
static ExitOnError ExitOnErr;