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

Closing the gaps in Texpr generation #1700

Merged
merged 7 commits into from
Mar 7, 2025
Merged

Conversation

DrMichaelPetter
Copy link
Collaborator

@DrMichaelPetter DrMichaelPetter commented Feb 28, 2025

In this PR, I want to fine-tune the expression conversion that is happening in sharedFunctions.apron.ml to cover more expressions, letting all affeqesque domains benefit from more precise information.

  • correct some exception types to reflect the real reason for aborting conversion
  • added metainformation to exceptions like the actual expression, that aborted conversion
  • add output to collect information on conversion success and failure, to be collected via a bash export lines=$(grep "rel-texpr-cil-conv" /tmp/goblintlog.txt | wc -l) ; cat /tmp/goblintlog.txt | grep "rel-texpr-cil-conv" | sed 's/(/ /g' | awk \{print\ \$5\ \$g\} | sort | uniq -c | sort -k 1,1 -rn | awk {print\ \$1*100/$lines\ \"%\ \"\ \$2}
  • implement revealed gaps in conversion: replace raise exception with returning top in evalInt queries

@DrMichaelPetter DrMichaelPetter added in progress precision relational Relational analyses (Apron, affeq, lin2var) labels Feb 28, 2025
@DrMichaelPetter DrMichaelPetter self-assigned this Feb 28, 2025
@DrMichaelPetter
Copy link
Collaborator Author

First evaluations of expr conversions on the bench/coreutils folder revealed the following conversion success/failure stats:

cp:

76.63% Good
 4.15% Overflow
 3.64% Lval: Mem.Accessor
 3.17% LNot
 3.09% Lval: Mem
 2.55% NonIntConst
 2.01% BinOp_not_supported
 1.75% Ask_yields_bot
 0.91% Lval: Var.Accessor
 0.84% CastE
 0.42% other
 0.35% Cast_not_injective
 0.22% Invalid_argument
 0.20% SizeOfXXX

cksum:

52.23% Success
16.52% Lval: Mem.Accessor
11.31% Lval: Mem
 8.27% Ask_yields_bot
 4.81% LNot
 2.70% Overflow
 1.50% NonIntConst
 1.09% BinOp_not_supported
 0.52% Cast_not_injective
 0.48% other
 0.45% CastE
 0.11% Lval: Var.Accessor

Overall, my worries, that overflow-treatment and non-injective assignments would stop the show seem not to be the major issue in these examples. I am curious how far we can push the success rate. A few first steps:

  • Ask_yields_bot demands thinking about how to handle pointers in evalInt queries, which has been ignored in the conversion so far
  • shifts are not implemented at all right now
  • can we do something about ternary operators?
  • Logical Not might be worthwhile to pursue at least partially e.g. when occuring top-level

More long-term thoughts:

  • The unsupported Lvals like pointer, struct and arrays might need some concept of how to deal with them
  • Mapping Array index arithmetics into the linear expression would maybe yield a few more noteworthy invariants

@DrMichaelPetter
Copy link
Collaborator Author

DrMichaelPetter commented Mar 4, 2025

After replacing the raised exception in the conversion's queryInt with a returned top, we could immediately gain roughly 10 points success percentage for both cases, eg. for cksum:

62.2487% Good
16.8537% Exp_not_supported:LValMem.FieldAccessor
 9.65872% Exp_not_supported:LValMem
 4.76858% Exp_not_supported:LValVar(untracked):
 2.78635% Overflow
 1.15942% Exp_not_supported:UnOpLNot
 0.73399% Bitwisebinop
 0.38803% Exp_not_supported:LValVar.Index
 0.35998% (Cast_not_injectiveunsigned
... <1% other

The other data does not immediately suggest any other changes imho, so I would consider this the only change for now.

@michael-schwarz michael-schwarz requested a review from sim642 March 4, 2025 13:12
@DrMichaelPetter DrMichaelPetter merged commit 66dff5a into master Mar 7, 2025
19 checks passed
@DrMichaelPetter DrMichaelPetter deleted the stats_on_texpr branch March 7, 2025 19:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
precision relational Relational analyses (Apron, affeq, lin2var)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants