Skip to content

[llvm] Use llvm::transform (NFC) #137532

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

kazutakahirata
Copy link
Contributor

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Apr 27, 2025

@llvm/pr-subscribers-debuginfo

@llvm/pr-subscribers-llvm-transforms

Author: Kazu Hirata (kazutakahirata)

Changes

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

5 Files Affected:

  • (modified) llvm/include/llvm/TableGen/DirectiveEmitter.h (+1-1)
  • (modified) llvm/lib/DebugInfo/LogicalView/Core/LVSupport.cpp (+2-2)
  • (modified) llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.cpp (+2-2)
  • (modified) llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmTypeCheck.cpp (+2-2)
  • (modified) llvm/lib/Transforms/Scalar/NewGVN.cpp (+3-4)
diff --git a/llvm/include/llvm/TableGen/DirectiveEmitter.h b/llvm/include/llvm/TableGen/DirectiveEmitter.h
index b856bb77f7b74..4b21ad6342b59 100644
--- a/llvm/include/llvm/TableGen/DirectiveEmitter.h
+++ b/llvm/include/llvm/TableGen/DirectiveEmitter.h
@@ -211,7 +211,7 @@ class Clause : public BaseRecord {
     StringRef Name = Def->getValueAsString("name");
     std::string N = Name.str();
     bool Cap = true;
-    std::transform(N.begin(), N.end(), N.begin(), [&Cap](unsigned char C) {
+    llvm::transform(N, N.begin(), [&Cap](unsigned char C) {
       if (Cap == true) {
         C = toUpper(C);
         Cap = false;
diff --git a/llvm/lib/DebugInfo/LogicalView/Core/LVSupport.cpp b/llvm/lib/DebugInfo/LogicalView/Core/LVSupport.cpp
index da6ba8dfd483b..d22b136632148 100644
--- a/llvm/lib/DebugInfo/LogicalView/Core/LVSupport.cpp
+++ b/llvm/lib/DebugInfo/LogicalView/Core/LVSupport.cpp
@@ -30,7 +30,7 @@ LVStringPool &llvm::logicalview::getStringPool() { return StringPool; }
 // - '//' into '/'
 std::string llvm::logicalview::transformPath(StringRef Path) {
   std::string Name(Path);
-  std::transform(Name.begin(), Name.end(), Name.begin(), tolower);
+  llvm::transform(Name, Name.begin(), tolower);
   llvm::replace(Name, '\\', '/');
 
   // Remove all duplicate slashes.
@@ -47,7 +47,7 @@ std::string llvm::logicalview::transformPath(StringRef Path) {
 //   '/', '\', '<', '>', '.', ':', '%', '*', '?', '|', '"', ' '.
 std::string llvm::logicalview::flattenedFilePath(StringRef Path) {
   std::string Name(Path);
-  std::transform(Name.begin(), Name.end(), Name.begin(), tolower);
+  llvm::transform(Name, Name.begin(), tolower);
 
   const char *CharSet = "/\\<>.:%*?|\" ";
   char *Input = Name.data();
diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.cpp
index 875b505549f0a..5552cea78694d 100644
--- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.cpp
+++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.cpp
@@ -1018,7 +1018,7 @@ bool AArch64InstPrinter::printSysAlias(const MCInst *MI,
     return false;
 
   std::string Str = Ins + Name;
-  std::transform(Str.begin(), Str.end(), Str.begin(), ::tolower);
+  llvm::transform(Str, Str.begin(), ::tolower);
 
   O << '\t' << Str;
   if (NeedsReg) {
@@ -1077,7 +1077,7 @@ bool AArch64InstPrinter::printSyspAlias(const MCInst *MI,
     return false;
 
   std::string Str = Ins + Name;
-  std::transform(Str.begin(), Str.end(), Str.begin(), ::tolower);
+  llvm::transform(Str, Str.begin(), ::tolower);
 
   O << '\t' << Str;
   O << ", ";
diff --git a/llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmTypeCheck.cpp b/llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmTypeCheck.cpp
index 68b24dbe9f006..c0729cb4f3e9b 100644
--- a/llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmTypeCheck.cpp
+++ b/llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmTypeCheck.cpp
@@ -126,8 +126,8 @@ SmallVector<WebAssemblyAsmTypeCheck::StackType, 4>
 WebAssemblyAsmTypeCheck::valTypesToStackTypes(
     ArrayRef<wasm::ValType> ValTypes) {
   SmallVector<StackType, 4> Types(ValTypes.size());
-  std::transform(ValTypes.begin(), ValTypes.end(), Types.begin(),
-                 [](wasm::ValType Val) -> StackType { return Val; });
+  llvm::transform(ValTypes, Types.begin(),
+                  [](wasm::ValType Val) -> StackType { return Val; });
   return Types;
 }
 
diff --git a/llvm/lib/Transforms/Scalar/NewGVN.cpp b/llvm/lib/Transforms/Scalar/NewGVN.cpp
index d06796660c444..d5fbbf0c10011 100644
--- a/llvm/lib/Transforms/Scalar/NewGVN.cpp
+++ b/llvm/lib/Transforms/Scalar/NewGVN.cpp
@@ -1074,10 +1074,9 @@ PHIExpression *NewGVN::createPHIExpression(ArrayRef<ValPair> PHIOperands,
     HasBackedge = HasBackedge || isBackedge(BB, PHIBlock);
     return lookupOperandLeader(P.first) != I;
   });
-  std::transform(Filtered.begin(), Filtered.end(), op_inserter(E),
-                 [&](const ValPair &P) -> Value * {
-                   return lookupOperandLeader(P.first);
-                 });
+  llvm::transform(Filtered, op_inserter(E), [&](const ValPair &P) -> Value * {
+    return lookupOperandLeader(P.first);
+  });
   return E;
 }
 

@llvmbot
Copy link
Member

llvmbot commented Apr 27, 2025

@llvm/pr-subscribers-backend-aarch64

Author: Kazu Hirata (kazutakahirata)

Changes

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

5 Files Affected:

  • (modified) llvm/include/llvm/TableGen/DirectiveEmitter.h (+1-1)
  • (modified) llvm/lib/DebugInfo/LogicalView/Core/LVSupport.cpp (+2-2)
  • (modified) llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.cpp (+2-2)
  • (modified) llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmTypeCheck.cpp (+2-2)
  • (modified) llvm/lib/Transforms/Scalar/NewGVN.cpp (+3-4)
diff --git a/llvm/include/llvm/TableGen/DirectiveEmitter.h b/llvm/include/llvm/TableGen/DirectiveEmitter.h
index b856bb77f7b74..4b21ad6342b59 100644
--- a/llvm/include/llvm/TableGen/DirectiveEmitter.h
+++ b/llvm/include/llvm/TableGen/DirectiveEmitter.h
@@ -211,7 +211,7 @@ class Clause : public BaseRecord {
     StringRef Name = Def->getValueAsString("name");
     std::string N = Name.str();
     bool Cap = true;
-    std::transform(N.begin(), N.end(), N.begin(), [&Cap](unsigned char C) {
+    llvm::transform(N, N.begin(), [&Cap](unsigned char C) {
       if (Cap == true) {
         C = toUpper(C);
         Cap = false;
diff --git a/llvm/lib/DebugInfo/LogicalView/Core/LVSupport.cpp b/llvm/lib/DebugInfo/LogicalView/Core/LVSupport.cpp
index da6ba8dfd483b..d22b136632148 100644
--- a/llvm/lib/DebugInfo/LogicalView/Core/LVSupport.cpp
+++ b/llvm/lib/DebugInfo/LogicalView/Core/LVSupport.cpp
@@ -30,7 +30,7 @@ LVStringPool &llvm::logicalview::getStringPool() { return StringPool; }
 // - '//' into '/'
 std::string llvm::logicalview::transformPath(StringRef Path) {
   std::string Name(Path);
-  std::transform(Name.begin(), Name.end(), Name.begin(), tolower);
+  llvm::transform(Name, Name.begin(), tolower);
   llvm::replace(Name, '\\', '/');
 
   // Remove all duplicate slashes.
@@ -47,7 +47,7 @@ std::string llvm::logicalview::transformPath(StringRef Path) {
 //   '/', '\', '<', '>', '.', ':', '%', '*', '?', '|', '"', ' '.
 std::string llvm::logicalview::flattenedFilePath(StringRef Path) {
   std::string Name(Path);
-  std::transform(Name.begin(), Name.end(), Name.begin(), tolower);
+  llvm::transform(Name, Name.begin(), tolower);
 
   const char *CharSet = "/\\<>.:%*?|\" ";
   char *Input = Name.data();
diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.cpp
index 875b505549f0a..5552cea78694d 100644
--- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.cpp
+++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.cpp
@@ -1018,7 +1018,7 @@ bool AArch64InstPrinter::printSysAlias(const MCInst *MI,
     return false;
 
   std::string Str = Ins + Name;
-  std::transform(Str.begin(), Str.end(), Str.begin(), ::tolower);
+  llvm::transform(Str, Str.begin(), ::tolower);
 
   O << '\t' << Str;
   if (NeedsReg) {
@@ -1077,7 +1077,7 @@ bool AArch64InstPrinter::printSyspAlias(const MCInst *MI,
     return false;
 
   std::string Str = Ins + Name;
-  std::transform(Str.begin(), Str.end(), Str.begin(), ::tolower);
+  llvm::transform(Str, Str.begin(), ::tolower);
 
   O << '\t' << Str;
   O << ", ";
diff --git a/llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmTypeCheck.cpp b/llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmTypeCheck.cpp
index 68b24dbe9f006..c0729cb4f3e9b 100644
--- a/llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmTypeCheck.cpp
+++ b/llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmTypeCheck.cpp
@@ -126,8 +126,8 @@ SmallVector<WebAssemblyAsmTypeCheck::StackType, 4>
 WebAssemblyAsmTypeCheck::valTypesToStackTypes(
     ArrayRef<wasm::ValType> ValTypes) {
   SmallVector<StackType, 4> Types(ValTypes.size());
-  std::transform(ValTypes.begin(), ValTypes.end(), Types.begin(),
-                 [](wasm::ValType Val) -> StackType { return Val; });
+  llvm::transform(ValTypes, Types.begin(),
+                  [](wasm::ValType Val) -> StackType { return Val; });
   return Types;
 }
 
diff --git a/llvm/lib/Transforms/Scalar/NewGVN.cpp b/llvm/lib/Transforms/Scalar/NewGVN.cpp
index d06796660c444..d5fbbf0c10011 100644
--- a/llvm/lib/Transforms/Scalar/NewGVN.cpp
+++ b/llvm/lib/Transforms/Scalar/NewGVN.cpp
@@ -1074,10 +1074,9 @@ PHIExpression *NewGVN::createPHIExpression(ArrayRef<ValPair> PHIOperands,
     HasBackedge = HasBackedge || isBackedge(BB, PHIBlock);
     return lookupOperandLeader(P.first) != I;
   });
-  std::transform(Filtered.begin(), Filtered.end(), op_inserter(E),
-                 [&](const ValPair &P) -> Value * {
-                   return lookupOperandLeader(P.first);
-                 });
+  llvm::transform(Filtered, op_inserter(E), [&](const ValPair &P) -> Value * {
+    return lookupOperandLeader(P.first);
+  });
   return E;
 }
 

@kazutakahirata kazutakahirata merged commit 52fcb07 into llvm:main Apr 27, 2025
16 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_001_range_llvm_transform branch April 27, 2025 19:36
jyli0116 pushed a commit to jyli0116/llvm-project that referenced this pull request Apr 28, 2025
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
Ankur-0429 pushed a commit to Ankur-0429/llvm-project that referenced this pull request May 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants