[clang] [llvm] [CMake][PGO] Add option for using an external project to generate profile data (PR #78879)

Petr Hosek via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 23 08:49:40 PST 2024


================
@@ -30,26 +30,28 @@ def findFilesWithExtension(path, extension):
 
 
 def clean(args):
-    if len(args) != 2:
+    if len(args) < 2:
         print(
-            "Usage: %s clean <path> <extension>\n" % __file__
+            "Usage: %s clean <paths> <extension>\n" % __file__
             + "\tRemoves all files with extension from <path>."
         )
         return 1
-    for filename in findFilesWithExtension(args[0], args[1]):
-        os.remove(filename)
+    for path in args[1:-1]:
+        for filename in findFilesWithExtension(path, args[-1]):
+            os.remove(filename)
     return 0
 
 
 def merge(args):
-    if len(args) != 3:
+    if len(args) < 3:
         print(
-            "Usage: %s merge <llvm-profdata> <output> <path>\n" % __file__
+            "Usage: %s merge <llvm-profdata> <output> <paths>\n" % __file__
             + "\tMerges all profraw files from path into output."
         )
         return 1
     cmd = [args[0], "merge", "-o", args[1]]
-    cmd.extend(findFilesWithExtension(args[2], "profraw"))
+    for i in range(2, len(args)):
+        cmd.extend(findFilesWithExtension(args[i], "profraw"))
----------------
petrhosek wrote:

```suggestion
    for path in args[2:]:
        cmd.extend(findFilesWithExtension(path, "profraw"))
```

https://github.com/llvm/llvm-project/pull/78879


More information about the cfe-commits mailing list