Skip to content

Conversation

@philnik777
Copy link
Contributor

@philnik777 philnik777 commented Nov 27, 2025

This removes some dead code and simplifies an expression.

@philnik777 philnik777 changed the title [libc++][NFC] Remove some dead code from string.bench.cpp and simplify a bit of code [libc++][NFC] Simplify string.bench.cpp a bit Nov 28, 2025
@philnik777 philnik777 marked this pull request as ready for review November 28, 2025 10:41
@philnik777 philnik777 requested a review from a team as a code owner November 28, 2025 10:41
@philnik777 philnik777 merged commit 1ab64e4 into llvm:main Nov 28, 2025
80 checks passed
@philnik777 philnik777 deleted the simplify_string_bench branch November 28, 2025 10:41
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Nov 28, 2025
@llvmbot
Copy link
Member

llvmbot commented Nov 28, 2025

@llvm/pr-subscribers-libcxx

Author: Nikolas Klauser (philnik777)

Changes

This removes some dead code and simplifies an expression.


Full diff: https://github.com/llvm/llvm-project/pull/169791.diff

1 Files Affected:

  • (modified) libcxx/test/benchmarks/containers/string.bench.cpp (+1-24)
diff --git a/libcxx/test/benchmarks/containers/string.bench.cpp b/libcxx/test/benchmarks/containers/string.bench.cpp
index 2484ec8fd955f..98216d22d0144 100644
--- a/libcxx/test/benchmarks/containers/string.bench.cpp
+++ b/libcxx/test/benchmarks/containers/string.bench.cpp
@@ -541,10 +541,7 @@ struct StringRead {
 
   static bool skip() {
     // Huge does not give us anything that Large doesn't have. Skip it.
-    if (Length() == ::Length::Huge) {
-      return true;
-    }
-    return false;
+    return Length() == ::Length::Huge;
   }
 
   std::string name() const { return "BM_StringRead" + Temperature::name() + Depth::name() + Length::name(); }
@@ -585,14 +582,6 @@ void sanityCheckGeneratedStrings() {
   }
 }
 
-// Some small codegen thunks to easily see generated code.
-bool StringEqString(const std::string& a, const std::string& b) { return a == b; }
-bool StringEqCStr(const std::string& a, const char* b) { return a == b; }
-bool CStrEqString(const char* a, const std::string& b) { return a == b; }
-bool StringEqCStrLiteralEmpty(const std::string& a) { return a == ""; }
-bool StringEqCStrLiteralSmall(const std::string& a) { return a == SmallStringLiteral; }
-bool StringEqCStrLiteralLarge(const std::string& a) { return a == LargeStringLiteral; }
-
 int main(int argc, char** argv) {
   benchmark::Initialize(&argc, argv);
   if (benchmark::ReportUnrecognizedArguments(argc, argv))
@@ -615,16 +604,4 @@ int main(int argc, char** argv) {
   makeCartesianProductBenchmark<StringRelationalLiteral, AllRelations, AllLengths, AllLengths, AllDiffTypes>();
   makeCartesianProductBenchmark<StringRead, AllTemperatures, AllDepths, AllLengths>();
   benchmark::RunSpecifiedBenchmarks();
-
-  if (argc < 0) {
-    // ODR-use the functions to force them being generated in the binary.
-    auto functions = std::make_tuple(
-        StringEqString,
-        StringEqCStr,
-        CStrEqString,
-        StringEqCStrLiteralEmpty,
-        StringEqCStrLiteralSmall,
-        StringEqCStrLiteralLarge);
-    printf("%p", &functions);
-  }
 }

aahrun pushed a commit to aahrun/llvm-project that referenced this pull request Dec 1, 2025
This removes some dead code and simplifies an expression.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants