Skip to content

[llvm] using wrapper llvm::sort(nfc) #151000

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
merged 1 commit into from
Aug 4, 2025

Conversation

Zhenhang1213
Copy link
Contributor

using wrapper llvm::sort(nfc)

@llvmbot
Copy link
Member

llvmbot commented Jul 28, 2025

@llvm/pr-subscribers-llvm-support
@llvm/pr-subscribers-backend-amdgpu
@llvm/pr-subscribers-llvm-transforms
@llvm/pr-subscribers-backend-hexagon

@llvm/pr-subscribers-llvm-ir

Author: Austin (Zhenhang1213)

Changes

using wrapper llvm::sort(nfc)


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

3 Files Affected:

  • (modified) llvm/lib/Bitcode/Writer/BitcodeWriter.cpp (+1-1)
  • (modified) llvm/lib/IR/AsmWriter.cpp (+1-1)
  • (modified) llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp (+1-1)
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
index e7ff772fc815a..3de289c6cfdeb 100644
--- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -609,7 +609,7 @@ class IndexBitcodeWriter : public BitcodeWriterBase {
       std::vector<StringRef> ModulePaths;
       for (auto &[ModPath, _] : Index.modulePaths())
         ModulePaths.push_back(ModPath);
-      llvm::sort(ModulePaths.begin(), ModulePaths.end());
+      llvm::sort(ModulePaths);
       for (auto &ModPath : ModulePaths)
         Callback(*Index.modulePaths().find(ModPath));
     }
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp
index b21f4347f34d3..d1cd0c1c780d4 100644
--- a/llvm/lib/IR/AsmWriter.cpp
+++ b/llvm/lib/IR/AsmWriter.cpp
@@ -1160,7 +1160,7 @@ int SlotTracker::processIndex() {
   std::vector<StringRef> ModulePaths;
   for (auto &[ModPath, _] : TheIndex->modulePaths())
     ModulePaths.push_back(ModPath);
-  llvm::sort(ModulePaths.begin(), ModulePaths.end());
+  llvm::sort(ModulePaths);
   for (auto &ModPath : ModulePaths)
     CreateModulePathSlot(ModPath);
 
diff --git a/llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp b/llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp
index 52fa678a600e9..613048be52a2f 100644
--- a/llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp
@@ -1987,7 +1987,7 @@ SmallVector<uint32_t, 8> HvxSelector::getPerfectCompletions(ShuffleMask SM,
   // times). In such cases it will be impossible to complete this to a
   // perfect shuffle.
   SmallVector<uint32_t, 8> Sorted(Worklist);
-  llvm::sort(Sorted.begin(), Sorted.end());
+  llvm::sort(Sorted);
 
   for (unsigned I = 0, E = Sorted.size(); I != E;) {
     unsigned P = Sorted[I], Count = 1;

@CoTinker
Copy link
Contributor

CoTinker commented Jul 29, 2025

Please change the sort with a comparator, such as:

llvm::sort(V.begin(), V.end(), [](const auto *L, const auto *R) {
return L->getName() < R->getName();
});

And the code below can be replaced with llvm::sort(operands());

llvm::sort(op_begin(), op_end());

Copy link
Contributor

@teresajohnson teresajohnson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@Zhenhang1213
Copy link
Contributor Author

Please change the sort with a comparator, such as:

llvm::sort(V.begin(), V.end(), [](const auto *L, const auto *R) {
return L->getName() < R->getName();
});

And the code below can be replaced with llvm::sort(operands());

llvm::sort(op_begin(), op_end());

OK

@CoTinker
Copy link
Contributor

And

// Sort call info by position of call instructions.
llvm::sort(YMF.CallSitesInfo.begin(), YMF.CallSitesInfo.end(),
[](yaml::CallSiteInfo A, yaml::CallSiteInfo B) {
return std::tie(A.CallLocation.BlockNum, A.CallLocation.Offset) <
std::tie(B.CallLocation.BlockNum, B.CallLocation.Offset);
});

Copy link

github-actions bot commented Jul 31, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

using wrapper llvm::sort(nfc)
Copy link
Contributor

@CoTinker CoTinker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks.

@Zhenhang1213 Zhenhang1213 merged commit c7bacc9 into llvm:main Aug 4, 2025
9 checks passed
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.

5 participants