cisco-open / llvm-crash-analyzer

llvm crash analysis
Apache License 2.0
41 stars 17 forks source link

[RegEq] Invalidate sub/super registers as well #16

Closed niktesic closed 2 years ago

niktesic commented 2 years ago

When a register is redefined by an instruction, we should invalidate all equivalences where that register is used:

  1. Uses of that particular register (ex. $eax) as a simple register location
  2. Uses of that register as a base register of dereferenced address (ex. deref->$eax+(-16))
  3. Uses of its sub/super registers as a simple register location (ex. $rax, $ax...)
  4. Uses of its sub/super registers as a base register of dereferenced address (ex. deref->$rax+(-8))

This patch introduces function RegisterEquivalence::invalidateAllRegUses as a wrapper of RegisterEquivalence::invalidateRegEq, to address all of the mentioned equivalence invalidations.

$rax : { deref->$rbp+(-24) $rax }
deref->$rbp+(-24) : { deref->$rbp+(-24) $rax }

Reg Eq Table after: $eax = MOV32ri 111111

$rax : { deref->$rbp+(-24) $rax }
$eax : { $eax }
deref->$rbp+(-24) : { deref->$rbp+(-24) $rax }

In the example above, please notice that after $eax = MOV32ri 111111, redefinition $eax should trigger invalidation of $rax equivalences, which is not done, without this patch.