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

No shortcut for narrow and meet in HConsed when int refinement is active #1186

Merged
merged 3 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/common/domains/lattice.ml
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,15 @@ end
module HConsed (Base:S) =
struct
include Printable.HConsed (Base)

(* We do refine int values on narrow and meet {!IntDomain.IntDomTupleImpl}, which can lead to fixpoint issues if we assume x op x = x *)
(* see https://github.com/goblint/analyzer/issues/1005 *)
let int_refine_active = GobConfig.get_string "ana.int.refinement" <> "never"
Copy link
Member

Choose a reason for hiding this comment

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

It should not be too expensive, as a local boolean to cache this information is introduced.

This is immediately evaluated though, not a ResettableLazy/ref. A properly dynamic value already exists as IntDomain.get_refinement, so we should just reuse that.

Copy link
Member Author

Choose a reason for hiding this comment

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

This module is constructed dynamically though, so it is not really a problem here.


let lift_f2 f x y = f (unlift x) (unlift y)
let narrow x y = if x.BatHashcons.tag == y.BatHashcons.tag then x else lift (lift_f2 Base.narrow x y)
let narrow x y = if (not int_refine_active) && x.BatHashcons.tag == y.BatHashcons.tag then x else lift (lift_f2 Base.narrow x y)
let widen x y = if x.BatHashcons.tag == y.BatHashcons.tag then x else lift (lift_f2 Base.widen x y)
let meet x y = if x.BatHashcons.tag == y.BatHashcons.tag then x else lift (lift_f2 Base.meet x y)
let meet x y = if (not int_refine_active) && x.BatHashcons.tag == y.BatHashcons.tag then x else lift (lift_f2 Base.meet x y)
let join x y = if x.BatHashcons.tag == y.BatHashcons.tag then x else lift (lift_f2 Base.join x y)
let leq x y = (x.BatHashcons.tag == y.BatHashcons.tag) || lift_f2 Base.leq x y
let is_top = lift_f Base.is_top
Expand Down
18 changes: 18 additions & 0 deletions tests/regression/38-int-refinements/06-narrow.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// PARAM: --set ana.int.refinement fixpoint --enable ana.int.interval
// FIXPOINT
#include<assert.h>

int g = 0;

void main()
{
int i = 0;
while (1) {
i++;
for (int j=0; j < 10; j++) {
if (i > 100) g = 1;
}
if (i>9) i=0;
}
return;
}
Loading