Skip to content

Commit 2be4b0c

Browse files
committed
Address minor test nits
1 parent 9b5162d commit 2be4b0c

File tree

4 files changed

+68
-12
lines changed

4 files changed

+68
-12
lines changed

cross-project-tests/dtlto/dtlto-translate-options.ll

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
; RUN: opt -thinlto-bc x86_64-pc-windows-msvc.ll -o x86_64-pc-windows-msvc.bc
99

1010

11-
;; Check that any invalid arguments would cause a Clang error. This property is
12-
;; relied on by the actual testcases later in this test.
11+
;; Check that invalid arguments cause a Clang error. This property is relied on
12+
;; by the actual testcases later in this test.
1313
; RUN: not %clang -x ir x86_64-unknown-linux-gnu.ll \
1414
; RUN: -invalid-incorrect-not-an-option 2>&1 | FileCheck %s --check-prefix=SANITY1
1515
; SANITY1: unknown argument: '-invalid-incorrect-not-an-option'
@@ -25,7 +25,7 @@
2525
; DEFINE: @%{triple}.rsp %{extra_flags}
2626

2727

28-
;; Write common arguments to a response files.
28+
;; Write common arguments to response files.
2929

3030
; RUN: echo "x86_64-unknown-linux-gnu.bc -o x86_64-unknown-linux-gnu.o \
3131
; RUN: -dtlto \
@@ -63,7 +63,7 @@
6363
; RUN: %{command}
6464
; REDEFINE: %{distributor} = validate.py
6565
; RUN: not %{command} 2>&1 | FileCheck %s --check-prefix=ON \
66-
; RUN: --implicit-check-not=-no-pgo-warn-mismatch
66+
; RUN: --implicit-check-not=-no-pgo-warn-mismatch
6767
; ON-DAG: "-faddrsig"
6868
; ON-DAG: "-ffunction-sections"
6969
; ON-DAG: "-fdata-sections"
@@ -80,7 +80,7 @@
8080
; OFF-NOT: --implicit-check-not=-no-pgo-warn-mismatch
8181

8282

83-
;; Check optimisation level.
83+
;; Check optimization level.
8484

8585
; RUN: llvm-lto2 run \
8686
; RUN: -thinlto-distributor-arg=%llvm_src_root/utils/dtlto/local.py \
@@ -124,7 +124,6 @@
124124

125125

126126
;--- x86_64-unknown-linux-gnu.ll
127-
128127
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
129128
target triple = "x86_64-unknown-linux-gnu"
130129

@@ -134,7 +133,6 @@ entry:
134133
}
135134

136135
;--- x86_64-pc-windows-msvc.ll
137-
138136
target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
139137
target triple = "x86_64-pc-windows-msvc"
140138

llvm/utils/dtlto/local.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
1+
"""
2+
DTLTO local serial distributor.
3+
4+
This script parses the Distributed ThinLTO (DTLTO) JSON file and serially
5+
executes the specified code generation tool on the local host to perform each
6+
backend compilation job. This simple functional distributor is intended to be
7+
used for integration tests.
8+
9+
Usage:
10+
python dtlto_codegen.py <json_file>
11+
12+
Arguments:
13+
- <json_file> : JSON file describing the DTLTO jobs.
14+
"""
15+
116
import subprocess
217
import sys
318
import json
419
from pathlib import Path
520

621
if __name__ == "__main__":
722
# Load the DTLTO information from the input JSON file.
8-
data = json.loads(Path(sys.argv[-1]).read_bytes())
23+
with Path(sys.argv[-1]).open() as f:
24+
data = json.load(f)
925

1026
# Iterate over the jobs and execute the codegen tool.
1127
for job in data["jobs"]:

llvm/utils/dtlto/mock.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
"""
2+
DTLTO Mock Distributor.
3+
4+
This script acts as a mock distributor for Distributed ThinLTO (DTLTO). It is
5+
used for testing DTLTO when a Clang binary is not be available to invoke to
6+
perform the backend compilation jobs.
7+
8+
Usage:
9+
python mock_distributor.py <input_file1> <input_file2> ... <json_file>
10+
11+
Arguments:
12+
- <input_file1>, <input_file2>, ... : Input files to be copied.
13+
- <json_file> : JSON file describing the DTLTO jobs.
14+
15+
The script performs the following:
16+
1. Reads the JSON file containing job descriptions.
17+
2. For each job copies the corresponding input file to the output location
18+
specified for that job.
19+
3. Validates the JSON format using the `validate` module.
20+
"""
21+
122
import sys
223
import json
324
import shutil
@@ -9,7 +30,8 @@
930
distributor_args = sys.argv[1:-1]
1031

1132
# Load the DTLTO information from the input JSON file.
12-
data = json.loads(Path(json_arg).read_bytes())
33+
with Path(json_arg).open() as f:
34+
data = json.load(f)
1335

1436
# Iterate over the jobs and create the output
1537
# files by copying over the supplied input files.

llvm/utils/dtlto/validate.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
"""
2+
DTLTO JSON Validator.
3+
4+
This script is used for DTLTO testing to check that the distributor has
5+
been invoked correctly.
6+
7+
Usage:
8+
python validate.py <json_file>
9+
10+
Arguments:
11+
- <json_file> : JSON file describing the DTLTO jobs.
12+
13+
The script does the following:
14+
1. Prints the supplied CLI arguments.
15+
2. Loads the JSON file.
16+
3. Validates the structure and required fields.
17+
4. Pretty prints the JSON.
18+
"""
19+
120
import sys
221
import json
322
from pathlib import Path
@@ -64,16 +83,17 @@ def validate_reference(a):
6483

6584

6685
if __name__ == "__main__":
67-
json_arg = sys.argv[-1]
86+
json_arg = Path(sys.argv[-1])
6887
distributor_args = sys.argv[1:-1]
6988

7089
print(f"{distributor_args=}")
7190

7291
# Load the DTLTO information from the input JSON file.
73-
jdoc = json.loads(Path(json_arg).read_bytes())
92+
with json_arg.open() as f:
93+
jdoc = json.load(f)
7494

7595
# Write the input JSON to stdout.
7696
print(json.dumps(jdoc, indent=4))
7797

78-
# Check the format of the JSON
98+
# Check the format of the JSON.
7999
validate(jdoc)

0 commit comments

Comments
 (0)