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

[DF] defined analysis producing wrong output. #120

Open
cgyurgyik opened this issue Jan 12, 2021 · 1 comment
Open

[DF] defined analysis producing wrong output. #120

cgyurgyik opened this issue Jan 12, 2021 · 1 comment

Comments

@cgyurgyik
Copy link
Contributor

Example

# bril2json < p.bril | python3 ../../df.py defined

@main(awesome_integer: int) {
.entry:
  print awesome_integer;
}

Actual:

entry:
  in:  ∅ 
  out: ∅

Expected

awesome_integer should be defined in .entry.

entry:
  in:  awesome_integer
  out: awesome_integer

I think the issue here is two-fold.

  1. There's no simple way to pass in arguments to the analyses. Here, we pass in an analysis with a defaulted (empty) data structure. However, for an analysis such as reaching definitions or defined analysis, we want to pass in the function arguments to the first block.

    bril/examples/df.py

    Lines 82 to 92 in dbbd8e8

    def run_df(bril, analysis):
    for func in bril['functions']:
    # Form the CFG.
    blocks = cfg.block_map(form_blocks(func['instrs']))
    cfg.add_terminators(blocks)
    in_, out = df_worklist(blocks, analysis)
    for block in blocks:
    print('{}:'.format(block))
    print(' in: ', fmt(in_[block]))
    print(' out:', fmt(out[block]))

  2. Even if we do pass in the correct function arguments,

    bril/examples/df.py

    Lines 48 to 49 in dbbd8e8

    inval = analysis.merge(out[n] for n in in_edges[node])
    in_[node] = inval

inval = analysis.merge(out[n] for n in in_edges[node]) # in_edges[.entry] == []

So, even though in_[.entry] is initialized correctly, it is over-written afterward.

As usual, let me know if I'm off-target.

@sampsyo
Copy link
Owner

sampsyo commented Jan 12, 2021

Yeah, I wrote the DF analysis examples before function parameters existed. The right thing to do is to still use empty sets as the initial values but essentially hallucinate an entry block that defines the parameters.

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

No branches or pull requests

2 participants