github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {darker}-->
:warning: Python code formatter, darker found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
darker --check --diff -r origin/main...HEAD
llvm/utils/mlgo-utils/IR2Vec/generateTriplets.py
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from darker here.
</summary>
``````````diff
--- generateTriplets.py 2025-10-20 22:59:11.000000 +0000
+++ generateTriplets.py 2025-10-20 23:00:46.075803 +0000
@@ -114,13 +114,11 @@
# For MIR files, process directly without optimization
triplets, file_max_relation = self._run_mir_pipeline(input_file)
if triplets:
all_triplets.update(triplets)
max_relation = max(max_relation, file_max_relation)
- logger.debug(
- f"Generated {len(triplets)} triplets for {input_file}"
- )
+ logger.debug(f"Generated {len(triplets)} triplets for
{input_file}")
else:
# For LLVM IR files, apply multiple optimization levels
opt_levels = self._select_optimization_levels()
for opt_level in opt_levels:
triplets, file_max_relation = self._run_pipeline(input_file,
opt_level)
@@ -168,11 +166,18 @@
def _run_mir_pipeline(self, input_file: Path) -> Tuple[Set[str], int]:
"""Run llvm-ir2vec pipeline for MIR files."""
try:
# Run llvm-ir2vec directly on MIR file
result = subprocess.run(
- [self.ir2vec_binary, "triplets", "--mode=mir",
str(input_file), "-o", "-"],
+ [
+ self.ir2vec_binary,
+ "triplets",
+ "--mode=mir",
+ str(input_file),
+ "-o",
+ "-",
+ ],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
check=False,
)
@@ -202,13 +207,13 @@
def generate_triplets(self, file_list: Path) -> None:
"""Main method to generate triplets from a list of LLVM IR or MIR
files"""
# Store file_list_path for later use in entity generation
self.file_list_path = file_list
-
+
input_files = self._read_file_list(file_list)
-
+
if self.mode == "mir":
logger.info(
f"Processing {len(input_files)} MIR files using
{self.max_workers} workers"
)
else:
@@ -276,20 +281,32 @@
# For MIR mode, we need to provide a sample MIR file to determine
target
# Use the first file from the processed list
input_files = self._read_file_list(self.file_list_path)
if not input_files:
raise ValueError("No input files available for entity
generation")
-
+
subprocess.run(
- [str(self.ir2vec_binary), "entities", "--mode=mir",
- str(input_files[0]), "-o", str(output_file)],
+ [
+ str(self.ir2vec_binary),
+ "entities",
+ "--mode=mir",
+ str(input_files[0]),
+ "-o",
+ str(output_file),
+ ],
check=True,
capture_output=True,
)
else:
subprocess.run(
- [str(self.ir2vec_binary), "entities", "--mode=llvm", "-o",
str(output_file)],
+ [
+ str(self.ir2vec_binary),
+ "entities",
+ "--mode=llvm",
+ "-o",
+ str(output_file),
+ ],
check=True,
capture_output=True,
)
def _generate_relation2id(self, output_file: Path, max_relation: int) ->
None:
``````````
</details>
https://github.com/llvm/llvm-project/pull/164332
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits