Skip to content

Commit 93abc57

Browse files
author
dev-aditya-hub
committed
hazards: return regs before continue on incompatible fpr variants
Reorder the compatibility check so we bail out before allocating the producer params. Previously raw/waw/war could allocate params_a and then continue without returning its regs to the pool.
1 parent f0cd163 commit 93abc57

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

  • generators/testgen/src/testgen/coverpoints

generators/testgen/src/testgen/coverpoints/hazards.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -120,24 +120,22 @@ def make_cp_fpr_hazard(instr_name: str, instr_type: str, coverpoint: str, test_d
120120

121121
for haz_type in hazard_types:
122122
for i in range(2):
123+
# Bail out before allocating the producer if the consumer can't form this
124+
# hazard, otherwise params_a's regs would leak from the pool on continue.
125+
if haz_type == "raw" and not consumer_fp_srcs:
126+
continue
127+
if haz_type in ("waw", "war") and not consumer_has_fd:
128+
continue
129+
123130
params_a = generate_random_params(test_data, producer_type)
124131
assert params_a.fs1 is not None and params_a.fs2 is not None and params_a.fd is not None
125132

126133
if haz_type == "raw":
127-
if consumer_fp_srcs:
128-
src_field = consumer_fp_srcs[i % len(consumer_fp_srcs)]
129-
params_b = generate_random_params(test_data, instr_type, **{src_field: params_a.fd})
130-
else:
131-
# Consumer reads no FP source register — skip this iteration's hazard
132-
# rather than emit a no-op test that pretends to cover RAW.
133-
continue
134+
src_field = consumer_fp_srcs[i % len(consumer_fp_srcs)]
135+
params_b = generate_random_params(test_data, instr_type, **{src_field: params_a.fd})
134136
elif haz_type == "waw":
135-
if not consumer_has_fd:
136-
continue
137137
params_b = generate_random_params(test_data, instr_type, fd=params_a.fd)
138138
elif haz_type == "war":
139-
if not consumer_has_fd:
140-
continue
141139
src_of_a = params_a.fs1 if i % 2 == 0 else params_a.fs2
142140
params_b = generate_random_params(test_data, instr_type, fd=src_of_a)
143141
elif haz_type == "nohaz":

0 commit comments

Comments
 (0)