This avoids implicit conversion to StringRef at several points, which in
turns avoid redundant calls to strlen.
It also eventually gives a consistent, humble speedup in compilation
time
Differential D139274
Store OptTable::Info::Name as a StringRef serge-sans-paille on Dec 4 2022, 9:41 AM. Authored by
Details
This avoids implicit conversion to StringRef at several points, which in It also eventually gives a consistent, humble speedup in compilation
Diff Detail
Event TimelineComment Actions Build failure in pre-merge checks: FAILED: lib/Option/CMakeFiles/LLVMOption.dir/OptTable.cpp.o CCACHE_CPP2=yes CCACHE_HASHDIR=yes /usr/bin/ccache /usr/bin/clang++ -DBUILD_EXAMPLES -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/var/lib/buildkite-agent/builds/llvm-project/build/lib/Option -I/var/lib/buildkite-agent/builds/llvm-project/llvm/lib/Option -I/var/lib/buildkite-agent/builds/llvm-project/build/include -I/var/lib/buildkite-agent/builds/llvm-project/llvm/include -gmlt -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG -fno-exceptions -fno-rtti -UNDEBUG -std=c++17 -MD -MT lib/Option/CMakeFiles/LLVMOption.dir/OptTable.cpp.o -MF lib/Option/CMakeFiles/LLVMOption.dir/OptTable.cpp.o.d -o lib/Option/CMakeFiles/LLVMOption.dir/OptTable.cpp.o -c /var/lib/buildkite-agent/builds/llvm-project/llvm/lib/Option/OptTable.cpp /var/lib/buildkite-agent/builds/llvm-project/llvm/lib/Option/OptTable.cpp:70:15: error: no matching function for call to 'StrCmpOptionName' if (int N = StrCmpOptionName(A.Name, B.Name)) ^~~~~~~~~~~~~~~~ /var/lib/buildkite-agent/builds/llvm-project/llvm/lib/Option/OptTable.cpp:60:12: note: candidate function not viable: no known conversion from 'const llvm::StringRef' to 'const char *' for 1st argument static int StrCmpOptionName(const char *A, const char *B) { ^ 1 error generated.
Comment Actions Also simplify StrCmpOptionNameIgnoreCase implementation thanks to the move to StringRef Comment Actions Reverted in de4b6a1bc64db33643f001ad45fae7b92b4a4688 for now. (Note that there was a follow-up fix in e50a60d7349de151bd2b06d85a79201ebc372d8a that I reverted in 13e061e73e1b067589d3bd680fc29297d7e4ec8d. When you reland, you'll likely want to cherry-pick that into your reland.) Comment Actions @serge-sans-paille Your change is causing 24 test failures on the Linux PS4 bot, mostly with an assertion failure it seems. Can you take a look? |
The code in this function (and also StrCmpOptionName) depends on the terminating null byte, while a StringRef is not guaranteed to by directly followed by one. I think these two functions would have to be adjusted to operate on StringRef rather than pointers as well.