Skip to content
  • Caio Oliveira's avatar
    nir: Skip common instructions when comparing deref paths · 8364ec3f
    Caio Oliveira authored
    
    
    Deref paths may share the same deref instructions in their chains,
    e.g.
    
        ssa_100 = deref_var A
        ssa_101 = deref_struct "array_field" of ssa_100
        ssa_102 = deref_array "[1]" of ssa_101
        ssa_103 = deref_struct "field_a" of ssa_102
        ssa_104 = deref_struct "field_a" of ssa_103
    
    when comparing the two last deref instructions, their paths will share
    a common sequence ssa_100, ssa_101, ssa_102.  This patch skips to next
    iteration if the deref instructions are the same.  Path[0] (the var)
    is still handled specially, so in the case above, only ssa_101 and
    ssa_102 will be skipped.
    
    Reviewed-by: default avatarJason Ekstrand <jason@jlekstrand.net>
    8364ec3f