Skip to content

DynComp: add --dyncomp-unhandled-ops=panic|warn - #85

Open
mernst wants to merge 3 commits into
codespecs:masterfrom
mernst:dyncomp-unhandled-ops
Open

mernst wants to merge 3 commits into
codespecs:masterfrom
mernst:dyncomp-unhandled-ops

Conversation

@mernst

@mernst mernst commented Oct 10, 2026 •

Copy link
Copy Markdown
Member

This pull request adds the option --dyncomp-unhandled-ops=panic|warn. When DynComp reaches the default case for a binary, ternary, or quaternary operation that it does not handle, the default case calls the new function approximate_unhandled_op_DC:

  • panic (the default) prints the operation and stops, as before.
  • warn prints a warning once per operation and approximates the operation.

The approximation guesses each operand's role from its type, as given by typeOfPrimop. It ignores operands that it guesses are rounding modes (a first operand of type I32 when the result or another operand is a floating-point or vector value), shift amounts, or lane indices (a later operand of type I8 when the first operand is not of type I8). The remaining operands are the "data operands". Then:

  • An operation whose result has type I1 and that has 2 data operands is treated as a comparison: the data operands' tags are merged, and the result gets tag 0.
  • Any other operation is treated as an interaction under --dyncomp-interactions=all: the data operands' tags are merged, and the result gets the merged tag. Under --dyncomp-interactions=units and --dyncomp-interactions=comparisons, it is treated as a non-interaction (the result gets tag 0), because it might be, for example, a multiplication.
  • Under --dyncomp-interactions=none, every operation is treated as a non-interaction.

Merging can over-approximate comparability (Daikon then checks more candidate invariants, so it may report extra, irrelevant invariants), and treating an operation as a non-interaction can under-approximate it (Daikon may then miss invariants). The warning says which approximation was used.

The option is listed in --help. codespecs/daikon#894 documents it in the Daikon manual.

This is one of three pull requests split from #83. It is independent of #86. #87 builds on both, also uses approximate_unhandled_op_DC for unary operations, and makes the approximation of a comparison merge with #104's dirty call.

#123 makes every merge of tags go through mkMergeTags_DC or stmtMergeTagsReturn0_DC, but no branch contains both #123 and this pull request, whose approximate_unhandled_op_DC creates the clean calls of MC_(helperc_MERGE_TAGS), MC_(helperc_MERGE_3_TAGS), and MC_(helperc_MERGE_4_TAGS) with mkIRExprCCall. Whichever of this pull request and #123 lands second should route those merges through mkMergeTags_DC.

The new option controls what happens when DynComp reaches the default
case for a binary, ternary, or quaternary VEX operation that it does not
handle.  "panic" (the default) stops, as before.  "warn" prints a
warning once per operation and approximates the operation by merging
its operands' tags.
@coderabbitai

coderabbitai Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Warning

Review limit reached

  • Run on-demand review

This review includes 3 billable files and costs up to $0.75.

Or wait 59 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository: codespecs/fjalar/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 924c2a63-3afb-4008-8a0f-7edd922283a3
📥 Commits

Reviewing files that changed from the base of the PR and between 3a80b42 and 2e68c6f.

📒 Files selected for processing: 3
  • valgrind/fjalar/kvasir/dyncomp_translate.c
  • valgrind/fjalar/kvasir/kvasir_main.c
  • valgrind/fjalar/kvasir/kvasir_main.h

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: codespecs/fjalar/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: f9e797c3-294d-4f89-9298-05aa11b8a63e
📥 Commits

Reviewing files that changed from the base of the PR and between ea8fa94 and 3a80b42.

📒 Files selected for processing (3)
  • valgrind/fjalar/kvasir/dyncomp_translate.c
  • valgrind/fjalar/kvasir/kvasir_main.c
  • valgrind/fjalar/kvasir/kvasir_main.h

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Walkthrough

The change adds the --dyncomp-unhandled-ops option, with panic as the default and warn to enable warnings and type-based approximation. The approximation excludes rounding modes, shift amounts, and lane indices from data tags. It also accounts for dataflow-only and interaction modes. The Qop, Triop, and Binop fallback paths now use this shared approximation.

Priority: ⬇️ Low

Change: Feature

Merge Risk: ⚪ Minimal · up to 3a80b

The new option is opt-in and the default behavior is unchanged. No concrete merge-blocking risk was identified.

### Architecture Summary

Architecture risk: 🟡 Medium · up to 3a80b

The change affects 1 system.

Changed systems: valgrind

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — valgrind (service) was modified; 3 changed files map to changed impact.

Before / after behavior

  • observed — Modified behavior in valgrind/fjalar/kvasir/dyncomp_translate.c: Added isFloatOrVectorType_DC and approximate_unhandled_op_DC. The approximation panics unless unhandled-op warnings are enabled; then it warns once per opcode. It uses typeOfPrimop to exclude a leading I32 rounding mode when the result or another operand is floating-point/vector, and later I8 shift amounts or lane indices when operand 0 is not I8. In dataflow-only mode, or when units or dataflow-comparisons mode suppresses non-comparison interactions, it returns tag 0. Otherwise, an I1 result with exactly two data operands merges their tags and returns 0; other operations return 0 for no data tags, the sole tag for one, or merge up to four tags.
  • observed — Modified behavior in valgrind/fjalar/kvasir/dyncomp_translate.c: The Qop default no longer prints the opcode and panics; it passes the four operands and their tags to the shared approximation, identifying the Qop handler as the warning location.
  • observed — Modified behavior in valgrind/fjalar/kvasir/dyncomp_translate.c: The Triop default now forwards its three operands and tags to the shared approximation instead of printing the opcode and panicking.
  • observed — Modified behavior in valgrind/fjalar/kvasir/dyncomp_translate.c: The Binop default now forwards its two operands and tags to the shared approximation instead of printing the opcode and panicking.

Reliability and maintainability

  • inferred — Risk-relevant change factors for valgrind: blast_radius_3; direct_dependents_3
Pre-merge checks | Passed 2 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 42.86% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

In warn mode, do not merge operands that appear to be rounding modes,
shift amounts, or lane indices; treat boolean-valued ops as comparisons;
and treat other ops as non-interactions in units and comparisons modes.
Also realign and clarify the --help text.
@mernst

mernst commented Oct 11, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@mernst

mernst commented Oct 11, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@mernst

mernst commented Oct 11, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@mernst

mernst commented Oct 11, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@mernst

mernst commented Oct 11, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@mernst

mernst commented Oct 11, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@mernst
mernst requested a review from markro49 October 11, 2026 20:20
mernst added a commit to mernst/fjalar that referenced this pull request Oct 13, 2026
…unary operation

codespecs#85 replaced report_unhandled_op_DC by approximate_unhandled_op_DC, which
handled only binary, ternary, and quaternary operations.  An unhandled
unary operation still returns the tag of its operand.
mernst added a commit to mernst/fjalar that referenced this pull request Oct 17, 2026
…RF PRs codespecs#89-codespecs#95

Both upgrades should wait for them: codespecs#89, codespecs#90, codespecs#91, and codespecs#95 change dwarf.c
(and codespecs#90/codespecs#95 change mc_main.c and mc_include.h), and codespecs#85-codespecs#88 change
dyncomp_translate.c.  codespecs#85's --dyncomp-unhandled-ops=warn and codespecs#87's
explicit unary handling also change how to find unhandled IROps.

@markro49 markro49 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

again no comments on dyncomp_translate.c
the kvasir changes for the option look ok

@markro49 markro49 assigned mernst and unassigned markro49 Oct 17, 2026

This branch has not been deployed

No deployments
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