Skip to content

Commit

Permalink
Locked ordering: Allow id find to fail with splitting
Browse files Browse the repository at this point in the history
  • Loading branch information
dop-amin authored and mkannwischer committed Jan 7, 2025
1 parent 745e958 commit a5a9346
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions slothy/core/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2965,7 +2965,24 @@ def find_node_by_source_id(src_id):
force_after = t1.inst.source_line.tags.get("after", [])
if not isinstance(force_after, list):
force_after = [force_after]
t0s = list(map(find_node_by_source_id, force_after))
t0s = []
for fa in force_after:
# In case the split heuristic is used, only instructions in the
# current "window" are considered here. The instruction that is
# being referred to using the id may not be present in this
# snippet of code. Thus, no constraint needs to be added because
# it does not affect this step right now, therefore we continue
# despite the exception.
try:
t0 = find_node_by_source_id(fa)
t0s.append(t0)
except SlothyException as e:
if self.config.split_heuristic:
self.logger.info("%s < %s by source annotation NOT enforced because of split heuristic", t0, t1)
continue
else:
raise e

force_after_last = t1.inst.source_line.tags.get("after_last", False)
if force_after_last is True:
if i == 0:
Expand All @@ -2982,7 +2999,20 @@ def find_node_by_source_id(src_id):
if not isinstance(force_before, list):
force_before = [force_before]
for t1_id in force_before:
t1 = find_node_by_source_id(t1_id)
# In case the split heuristic is used, only instructions in the
# current "window" are considered here. The instruction that is
# being referred to using the id may not be present in this
# snippet of code. Thus, no constraint needs to be added because
# it does not affect this step right now, therefore we continue
# despite the exception.
try:
t1 = find_node_by_source_id(t1_id)
except SlothyException as e:
if self.config.split_heuristic:
self.logger.info("%s < %s by source annotation NOT enforced because of split heuristic", t0, t1)
continue
else:
raise e
self.logger.info("Force %s < %s by source annotation", t0, t1)
self._add_path_constraint(t1, t0,
lambda t0=t0, t1=t1: self._Add(t0.program_start_var < t1.program_start_var))
Expand Down

0 comments on commit a5a9346

Please sign in to comment.