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

[mlir] proper "undefined" state in pointer analysis and correct handling of fresh state #1572

Merged
merged 6 commits into from
Jan 18, 2024

Commits on Jan 5, 2024

  1. [mlir] add a proper "undefined" state to pointer analyses

    Historically, `AliasClassSet` has been using empty set as the bottom
    state of the join-semilattice. This made it impossible to differentiate
    between "not yet analyzed" and "known not to alias with anything"
    states. While not necessarily problematic for the naive alias analysis,
    this is crucial for points-to-pointer analysis that was forced to become
    unnecessarily conservative by treating "not yet analyzed" points-to
    state as "points to unknown" (top sate of the join-semilattice). Worse,
    some transfer functions weren't trivially monotonous because of that.
    
    Introduce a new "undefined" set to `AliasClassSet` and lattice. Update
    PointsToLattice to explicitly store the cases when a known alias class
    points to unknown alias class and interpret unknown (not yet listed)
    alias class as pointing to undefined alias class. Make all transfer
    functions monotonous by only processing known points-to entries. Unknown
    points-to classes can be treated by the client as potentially pointing
    to unknown, but so far this wasn't needed as, at the fixpoint state, all
    available classes should have been analyzed. Assertions are put in place
    in activity analysis to catch undefined classes.
    
    Additionally, make it more difficult to move the join-semilattice to a
    previous (<= current) value by exposing mostly the APIs that can only
    advance the lattice. This is not yet complete due to partially incorect
    handling of distinct identifers that get recreated every time in
    transfer functions.
    ftynse committed Jan 5, 2024
    Configuration menu
    Copy the full SHA
    28cb95e View commit details
    Browse the repository at this point in the history
  2. [mlir] correct handling of fresh alias sets

    Previously, dataflow initialization and transfer functions would
    allocate a fresh alias class for allocation-like cases that are known
    not to alias with anything, and do so _on every invocation_. This is
    unsound in the general case as the class may keep changing, which could
    affect convergence to fix point. Instead, add a cache that associates a
    class with a value on the first invocation of the dataflow-related
    functions and use the cached value on each subsequent invocation.
    
    Fix a couple of issues unconvered due to the change:
      - not recreate the common scope that function results may be pointing
        to for each capturable operand;
      - invert the condition of handling nocapture in function results;
      - add a TODO for better handling of alias classes of function results
        in presence of function-level attributes.
    ftynse committed Jan 5, 2024
    Configuration menu
    Copy the full SHA
    84a455f View commit details
    Browse the repository at this point in the history
  3. [mlir] better handling of function result attributes

    Specifically, handle the siutation where some alias classes are
    associateded with pointer operands that cannot be written into. In such
    a case, even if the results of the function may alias the operands, the
    alias classes of the operands are known not to point to anything that
    the function could have written.
    
    Additionally, don't include results marked as `noalias` into the common
    alias class of function results.
    ftynse committed Jan 5, 2024
    Configuration menu
    Copy the full SHA
    0e90f15 View commit details
    Browse the repository at this point in the history

Commits on Jan 16, 2024

  1. Configuration menu
    Copy the full SHA
    5c84760 View commit details
    Browse the repository at this point in the history

Commits on Jan 18, 2024

  1. Configuration menu
    Copy the full SHA
    18cb191 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    7b6aaf3 View commit details
    Browse the repository at this point in the history