Skip to content

Indirect replacement in target crashes Alive #30

@davemenendez

Description

@davemenendez

For example, Alive will crash if I have an instruction %r in the target which depends on %y from the source, but %y depends on a value %x which is replaced in the target.

[Reading from terminal...]
%x = sub %A, 0
%y = add %x, C2
%r = add %y, C3
=>
%x = %A
%r = add %y, C3
----------------------------------------
Optimization: 1
Precondition: true
  %x = sub %A, 0
  %y = add %x, C2
  %r = add %y, C3
=>
  %x = %A
  %r = add %y, C3

Traceback (most recent call last):
  File "./alive.py", line 526, in <module>
    main()
  File "./alive.py", line 517, in main
    check_opt(opt)
  File "./alive.py", line 460, in check_opt
    check_typed_opt(pre, src, ident_src, tgt, ident_tgt, types, users)
  File "./alive.py", line 340, in check_typed_opt
    tgtv = toSMT(tgt, ident_tgt, False)
  File "/Users/dave/Documents/Research/alive/alive/language.py", line 1170, in toSMT
    smt = v.toSMT(defined, poison, state, qvars)
  File "/Users/dave/Documents/Research/alive/alive/language.py", line 357, in toSMT
    v1 = state.eval(self.v1, defined, poison, qvars)
  File "/Users/dave/Documents/Research/alive/alive/language.py", line 151, in eval
    (smt, d, p, q) = self.vars[v.getUniqueName()]
KeyError: '%x'

Either %y needs to be reevaluated in the target, or we should disallow replacing values that are used by non-replaced values.

Alternately, we could disallow replacement for non-roots entirely. In the Alive suite, we only seem to do it for values which also have HasOneUse, so there's on real difference between replacement and just creating a new value. (See also #26.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions