[llvm] 4d59552 - [NFC][YAML][IR] Output CfiFunction sorted (#130379)

via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 8 12:19:32 PST 2025


Author: Vitaly Buka
Date: 2025-03-08T12:19:28-08:00
New Revision: 4d5955215eb74a3bfa2394333a0a412df7d5a036

URL: https://github.com/llvm/llvm-project/commit/4d5955215eb74a3bfa2394333a0a412df7d5a036
DIFF: https://github.com/llvm/llvm-project/commit/4d5955215eb74a3bfa2394333a0a412df7d5a036.diff

LOG: [NFC][YAML][IR] Output CfiFunction sorted (#130379)

As-is it's NFC, as internally `CfiFunction*` are std::set<>.

We are changing internals of `CfiFunctionDefs` and
`CfiFunctionDecls` so they will be ordered by GUID.

Sorting by name is unnecessary but good for
readability and tests.

Added: 
    

Modified: 
    llvm/include/llvm/IR/ModuleSummaryIndexYAML.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/IR/ModuleSummaryIndexYAML.h b/llvm/include/llvm/IR/ModuleSummaryIndexYAML.h
index 14b8ce5df8536..adcd17783d6c0 100644
--- a/llvm/include/llvm/IR/ModuleSummaryIndexYAML.h
+++ b/llvm/include/llvm/IR/ModuleSummaryIndexYAML.h
@@ -9,8 +9,10 @@
 #ifndef LLVM_IR_MODULESUMMARYINDEXYAML_H
 #define LLVM_IR_MODULESUMMARYINDEXYAML_H
 
+#include "llvm/ADT/StringRef.h"
 #include "llvm/IR/ModuleSummaryIndex.h"
 #include "llvm/Support/YAMLTraits.h"
+#include <algorithm>
 
 namespace llvm {
 namespace yaml {
@@ -345,11 +347,13 @@ template <> struct MappingTraits<ModuleSummaryIndex> {
                    index.WithGlobalValueDeadStripping);
 
     if (io.outputting()) {
-      std::vector<std::string> CfiFunctionDefs(index.CfiFunctionDefs.begin(),
-                                               index.CfiFunctionDefs.end());
+      std::vector<StringRef> CfiFunctionDefs(index.CfiFunctionDefs.begin(),
+                                             index.CfiFunctionDefs.end());
+      std::sort(CfiFunctionDefs.begin(), CfiFunctionDefs.end());
       io.mapOptional("CfiFunctionDefs", CfiFunctionDefs);
-      std::vector<std::string> CfiFunctionDecls(index.CfiFunctionDecls.begin(),
-                                                index.CfiFunctionDecls.end());
+      std::vector<StringRef> CfiFunctionDecls(index.CfiFunctionDecls.begin(),
+                                              index.CfiFunctionDecls.end());
+      std::sort(CfiFunctionDecls.begin(), CfiFunctionDecls.end());
       io.mapOptional("CfiFunctionDecls", CfiFunctionDecls);
     } else {
       std::vector<std::string> CfiFunctionDefs;


        


More information about the llvm-commits mailing list