Skip to content

Commit a1971ab

Browse files
committed
fix an issue in update_mc_script that the not case is not handle
properly
1 parent 92663de commit a1971ab

File tree

3 files changed

+31
-6
lines changed

3 files changed

+31
-6
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
// RUN: not llvm-mc -triple=amdgcn -show-encoding %s 2>&1 | FileCheck --check-prefixes=CHECK %s
22

33
v_bfrev_b32 v5, v299
4+
5+
v_bfrev_b32 v5, v1

llvm/test/tools/UpdateTestChecks/update_mc_test_checks/Inputs/amdgpu_asm_err.s.expected

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@
33

44
v_bfrev_b32 v5, v299
55
// CHECK: :[[@LINE-1]]:17: error: register index is out of range
6+
7+
v_bfrev_b32 v5, v1
8+
// CHECK: v_bfrev_b32_e32 v5, v1 ; encoding: [0x01,0x71,0x0a,0x7e]

llvm/utils/update_mc_test_checks.py

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,14 @@
1515

1616
mc_LIKE_TOOLS = [
1717
"llvm-mc",
18-
"not llvm-mc",
1918
]
2019
ERROR_RE = re.compile(r":\d+: (warning|error): .*")
2120
ERROR_CHECK_RE = re.compile(r"# COM: .*")
2221
OUTPUT_SKIPPED_RE = re.compile(r"(.text)")
2322
COMMENT = {"asm": "//", "dasm": "#"}
2423

2524

26-
def invoke_tool(exe, cmd_args, testline, verbose=False):
25+
def invoke_tool(exe, prefix_not, cmd_args, testline, verbose=False):
2726
if isinstance(cmd_args, list):
2827
args = [applySubstitutions(a, substitutions) for a in cmd_args]
2928
else:
@@ -32,7 +31,20 @@ def invoke_tool(exe, cmd_args, testline, verbose=False):
3231
cmd = 'echo "' + testline + '" | ' + exe + " " + args
3332
if verbose:
3433
print("Command: ", cmd)
35-
out = subprocess.check_output(cmd, shell=True)
34+
35+
# if not is used in runline, the command might or might not
36+
# return non-zero code on a single line run
37+
try:
38+
out = subprocess.check_output(cmd, shell=True)
39+
except:
40+
if prefix_not:
41+
cmd = 'echo "' + testline + '" | ' + "not " + exe + " " + args
42+
if verbose:
43+
print("Command: ", cmd)
44+
out = subprocess.check_output(cmd, shell=True)
45+
else:
46+
raise Exception("Command '{}' return non-zero value".format(cmd))
47+
3648
# Fix line endings to unix CR style.
3749
return out.decode().replace("\r\n", "\n")
3850

@@ -151,11 +163,16 @@ def main():
151163
assert len(commands) >= 2
152164
mc_cmd = " | ".join(commands[:-1])
153165
filecheck_cmd = commands[-1]
154-
mc_tool = mc_cmd.split(" ")[0]
155166

156167
# special handling for negating exit status
157-
if mc_tool == "not":
158-
mc_tool = mc_tool + " " + mc_cmd.split(" ")[1]
168+
prefix_not = ""
169+
mc_cmd_args = mc_cmd.split(" ")
170+
if mc_cmd_args[0] == "not":
171+
prefix_not = mc_cmd_args[0]
172+
mc_tool = mc_cmd_args[1]
173+
mc_cmd = mc_cmd[len(mc_cmd_args[0]) :].strip()
174+
else:
175+
mc_tool = mc_cmd_args[0]
159176

160177
triple_in_cmd = None
161178
m = common.TRIPLE_ARG_RE.search(mc_cmd)
@@ -188,6 +205,7 @@ def main():
188205
(
189206
check_prefixes,
190207
mc_tool,
208+
prefix_not,
191209
mc_cmd_args,
192210
triple_in_cmd,
193211
march_in_cmd,
@@ -204,6 +222,7 @@ def main():
204222
for (
205223
prefixes,
206224
mc_tool,
225+
prefix_not,
207226
mc_args,
208227
triple_in_cmd,
209228
march_in_cmd,
@@ -222,6 +241,7 @@ def main():
222241
# get output for each testline
223242
out = invoke_tool(
224243
ti.args.llvm_mc_binary or mc_tool,
244+
prefix_not,
225245
mc_args,
226246
line,
227247
verbose=ti.args.verbose,

0 commit comments

Comments
 (0)