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

Open
wants to merge 66 commits into
base: dev
Choose a base branch
from
Open

Add new IcfgBuilder #690

wants to merge 66 commits into from

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?

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.

Heizmann and others added 26 commits November 14, 2024 09:25
Do not copy annotations directly from original statements to edges but only to
auxiliary statements. (Because annotations are copied from all
statements to edges anyway.)
Unify code for prepending statements
Use assumption that mapping returns singleton except for calls.
The setting "Only consider context switches at boundaries of atomic blocks"
(aka the nodatarace-LBE) is only meant to affect concurrent programs. It
performs a kind of large-block encoding (LBE) that is usually not desirable
for sequential programs.
IcfgBuilder is already the default anyway.
…rver

The new IcfgBuilder does not use UnstructureCode anymore. To avoid reimplementation there, this was moved to the new oberserver ReplaceArrayAssignments.
This does not seem as useful as in the RCFGBuilder, as most of such assume true statements where introduced in UnstructureCode, but it does not harm to keep it.
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.

<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-21"/>
<classpathentry exported="true" kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry combineaccessrules="false" kind="src" path="/BoogiePrinter"/>
Copy link
Member

Choose a reason for hiding this comment

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

Why is this access rule necessary? Does a utility need to be accessed internally here?
If so, then the API and implementation of the required software component should be restructured to avoid such hacks and instead access public interfaces cleanly via the MANIFEST.MF.

@@ -0,0 +1,23 @@
Copyright (C) @{daterange} @{author:r}

This file is part of the ULTIMATE RCFGBuilder plug-in.
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't the objective be called ICFGBuilder instead of RCFGBuilder in the whole license template file?

Comment on lines +323 to +326
// mLogger.info(getClass().getSimpleName());
// printHondas(cfg, mLogger::info);
// printCFG(cfg, mLogger::info);
// mLogger.info("######## END "+getClass().getSimpleName());
Copy link
Member

Choose a reason for hiding this comment

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

Remove unused debugging code or implement it correctly when debug mode is enabled.

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