Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new IcfgBuilder #690

Merged
merged 81 commits into from
Nov 18, 2024
Merged

Add new IcfgBuilder #690

merged 81 commits into from
Nov 18, 2024

Conversation

Heizmann
Copy link
Member

Commits for switching from RCFGBuilder to IcfgBuilder are missing in this branch. But Frank convinced me to already start a pull request.

Copy link
Contributor

@schuessf schuessf left a comment

Choose a reason for hiding this comment

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

Thanks for your work! I did not have a detailed look yet, but here are already some more general comments.

@schuessf schuessf changed the title Wip/nk/icfgbuilder Add new IcfgBuilder Oct 31, 2024
@schuessf
Copy link
Contributor

schuessf commented Nov 4, 2024

I just synced the CfgBuilder classes from RCFGBuilder and the new IcfgBuilder. To inspect the differences, you can take a look a the diff.

firstStatement =
new ReturnStatement(mBoogieDeclarations.getProcImplementation().get(procName).getLocation());
} else {
firstStatement = body.getBlock()[0];
Copy link
Contributor

Choose a reason for hiding this comment

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

In the RCFGBuilder firstStatement is always set to body.getBlock()[0], why is this different here?

Copy link
Contributor

Choose a reason for hiding this comment

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

For the RCFGBuilder body.getBlock() could never be empty, because the BoogiePreprocessor would insert a return statement in that case. With the setting that disables the UnstructureCode class from the BoogiePreprocessor body.getBlock() can now be empty.

Copy link
Contributor

Choose a reason for hiding this comment

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

But does this belong to the CfgBuilder? Wouldn't it be better to move it into its own Preprocessor that always runs independant of UnstructureCode?

Copy link
Contributor

Choose a reason for hiding this comment

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

Or do we even need this statement here? Is it possible to create a location without a statement?

@schuessf
Copy link
Contributor

schuessf commented Nov 6, 2024

I just looked into the open backtranslation issues, the created CFG for loops (especially when translated from C) looks slightly different.
Consider the following C program

while (x > 0) x--

This is roughly translated to the following Boogie program

while (true) {
  label: if (!(x > 0)) {
    break;
  }
  x := x - 1;
}

In the old CFG, we only had only two states and three edges (with SequenceOfStatements):

  • a loop in the initial location with the body and the negated if-condition (x > 0)
  • an edge from the initial location to the exit location with the if-condition (!(x > 0))
  • an edge from the initial location to the exit location with the negated while-condition (false)
    grafik

With the same settings, the new CFG has 5 locations and the following 6 edges:

  • one with the while condition (true)
  • an edge from the initial location to the exit location with the negated while-condition (false)
  • another edge with true after the label
  • an edge with the negated if-condition (x > 0)
  • an edge to the exit location with the if-condition (!(x > 0))
  • an edge with the body back to the initial location
    grafik

This means that in the old CFG we had a stronger block encoding for SequenceOfStatements. With other settings the CFG should be more similar. I am not sure if this behaviour is desired.

@Heizmann
Copy link
Member Author

Heizmann commented Nov 6, 2024

Some info (not enough time to think about your post): The new IcfgBuilder alredy makes sure that labels get their own IcfgLocation.

Copy link
Member

@bahnwaerter bahnwaerter left a comment

Choose a reason for hiding this comment

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

The changes look good so far. The branch has already been correctly adapted to our Java 21 and Eclipse migration and can therefore be merged without any issues.

However, there are still a few small things that need to be improved. For example, in the comments and the license agreement in the headers of ICFG source code files, the word RCFGBuilder should be replaced consistently with ICFGBuilder.

Copy link
Contributor

@maul-esel maul-esel left a comment

Choose a reason for hiding this comment

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

Thanks @NiklasKult, @Heizmann and @schuessf for working on this!

I had a look at the changes and did not find any major issues. Due to the time constraints, I was not able to review in-depth, but since others have done so, and our latest evaluations have shown no major issues (only a slight increase in the number of locations) I have no objection to merging 👍


translateProgramExecution(final IProgramExecution<IIcfgTransition<IcfgLocation>, Term> programExecution) {
if (!(programExecution instanceof IcfgProgramExecution)) {
throw new IllegalArgumentException();
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: add an error message

@@ -89,7 +89,7 @@ public class BoogieIcfgContainer extends ModernAnnotations implements IIcfg<Boog
* Note: This map is only used during construction!
*
*/
final Map<String, BoogieIcfgLocation> mFinalNode;
public final Map<String, BoogieIcfgLocation> mFinalNode;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it necessary to make this public?

Copy link
Contributor

@schuessf schuessf Nov 18, 2024

Choose a reason for hiding this comment

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

I think so, as this is also used by the IcfgBuilder plugin. Of course, it would be more optimal to move it to some library, but we can do this, if we remove RCFGBuilder in the future.

@maul-esel
Copy link
Contributor

I also had a quick look at the RCFGBuilder/ICFGBuilder diff by @schuessf and did not find any issues there either.

@schuessf
Copy link
Contributor

I will try to address these minor issues and merge this later.

@schuessf schuessf merged commit 7a7902f into dev Nov 18, 2024
2 checks passed
@schuessf schuessf deleted the wip/nk/icfgbuilder branch November 18, 2024 21:29
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.

6 participants