Skip to content

Add support for unstructured programs#202

Draft
atomb wants to merge 15 commits intomainfrom
add-cfgs
Draft

Add support for unstructured programs#202
atomb wants to merge 15 commits intomainfrom
add-cfgs

Conversation

@atomb
Copy link
Contributor

@atomb atomb commented Nov 13, 2025

This introduces a type for control-flow graphs made up of basic blocks that can include the same sorts of commands that structured statements do. It includes a translation from structured statements to unstructured CFGs.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

This introduces a type for control-flow graphs made up of basic blocks
that can include the same sorts of commands that structured statements
do. It includes a translation from structured statements to unstructured
CFGs.
Copy link
Contributor

@tautschnig tautschnig left a comment

Choose a reason for hiding this comment

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

What will be the semantics of jumping into a block while skipping over a declaration? In C one can do:

goto lab;
int x = 42;
lab: ++x; // x is considered declared, but is uninitialised

I believe programs like the above can now be represented, but we also need to be clear on their semantics.


[l_6:
[init (i : int) := init_i_0]
cgoto #true l_5 l_5,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is a comma being printed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I think that's a mistake. Thanks for catching!

@atomb
Copy link
Contributor Author

atomb commented Feb 16, 2026

What will be the semantics of jumping into a block while skipping over a declaration? In C one can do:

goto lab;
int x = 42;
lab: ++x; // x is considered declared, but is uninitialised

I believe programs like the above can now be represented, but we also need to be clear on their semantics.

You caught one of the key reasons I hadn't moved this from a draft yet! My current plan is to require that declarations be procedure-level when translating to CFG, but I haven't yet decided how best to enforce that. As you've probably noticed, the example you commented on with the errant comma has an init command in a later block.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants