Skip to content

Tensor variable count semantics under k-CFA context sensitivity #371

Closed
ponder-lab/ML
#396

Description

@khatchad

Question

The test(...) helper in TestTensorflow2Model counts tensor variables by iterating over all (CGNode, vn) pairs in the analysis results that match the target function name. Under k-CFA context sensitivity, the same IR variable (same value number in the same method) can appear under multiple calling contexts (e.g., distinct trampolines), inflating the count relative to context-insensitive analysis.

This is a design question, not clearly a bug: tests could reasonably reflect either context-sensitive counts (current behavior) or IR-level source counts (one entry per (CGNode, vn) regardless of context).

Design Question

Should the test helper count:

  1. By (CGNode, vn) — current behavior. Faithfully reflects what the analysis computed. Count changes when context-sensitivity depth changes.
  2. By vn only — deduplicate across contexts. Count reflects IR-level source variables. Stable under context-sensitivity changes.

Option 1 is the current implementation; option 2 is what older tests assumed before higher-k context sensitivity was added.

Impact of the Current Behavior

  • Test expectations become coupled to context-sensitivity implementation details.
  • Changes to calling-context structure (e.g., adding/removing trampolines, changing k in k-CFA) silently shift the expected count.

Possible Resolution

  • Decide on the counting semantics (option 1 or option 2 above) and document it in the test helper's Javadoc.
  • If option 2: deduplicate by vn in the test helper; existing tests that expected the context-insensitive count continue to work.
  • If option 1: accept that test expectations may need updating when context-sensitivity changes; document this as a known maintenance cost.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions