Skip to content

Add asm goto support#2067

Open
sim642 wants to merge 8 commits into
masterfrom
asm-goto
Open

Add asm goto support#2067
sim642 wants to merge 8 commits into
masterfrom
asm-goto

Conversation

@sim642

@sim642 sim642 commented Jun 26, 2026

Copy link
Copy Markdown
Member

This is an alternative to #1326. It just adds asm goto support, but nothing related to invalidation, etc.

This is cherry-picked from https://github.com/sws-lab/race-harness-goblint/commit/733c9865e1912c7663207291cbf48dc26213a493, which is originally by @jprotopopov-ut.

TODO

Co-authored-by: Jevgenijs Protopopovs <jevgenijs.protopopovs@ut.ee>
@sim642 sim642 added this to the v2.9.0 milestone Jun 26, 2026
@sim642 sim642 self-assigned this Jun 26, 2026
@sim642 sim642 added feature pr-dependency Depends or builds on another PR, which should be merged before labels Jun 26, 2026
@sim642 sim642 marked this pull request as ready for review June 26, 2026 12:38
Copilot AI review requested due to automatic review settings June 26, 2026 12:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@sim642

sim642 commented Jun 26, 2026

Copy link
Copy Markdown
Member Author

Hmm, there's something fishy with the tests: they pass locally but fail in some of the CI. The CFG rendering might be sensitive to sids changing internal Graphviz labels and the renderer sorting them differently or something like that.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.

Comment thread src/util/loopUnrolling.ml
Comment on lines +389 to +401
| Asm a ->
let (changed, gotos') = List.fold_left_map (fun acc target ->
match newtarget !target with
| None -> (acc, target) (* TODO: need to copy target ref as well? *)
| Some nt -> (true, ref nt)
) false a.gotos
in
if changed then (
s.skind <- Asm {a with gotos = gotos'};
DoChildren
)
else
SkipChildren

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wondered about this too and that's why I left the TODO. It wasn't clear to me whether the sharing of refs might be intentional for something because the Goto case doesn't do the copy if it's not necessary. A bunch of this logic deals with physical equality in various ways so it can be quite fragile.

I then tried to just remove the ref wrapper from Goto in CIL itself to see if it's really necessary. There's at least one use case there for it: during Cabs2cil the Gotos initially refer to dummy statements which are filled in at the end of the function once all labels have been seen. Maybe that's the only reason for the ref and the mutability is never used again.

If that's the case, it'd be useful to have private mutability (which sadly doesn't exist): https://discuss.ocaml.org/t/mutable-fields-of-private-records/18213.
Another option might be to build some thin abstraction around the ref which can ensure that it's only assigned once within CIL and cannot be mutated later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature pr-dependency Depends or builds on another PR, which should be merged before

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants