radeco icon indicating copy to clipboard operation
radeco copied to clipboard

Finish SSAVerifier

Open ZhangZhuoSJTU opened this issue 7 years ago • 12 comments

SSAVerifier / Verified add to ensure IR invariants are maintained and never violated. This will help future developer to make sure their changes on IR is correct and viable.

Some invariants are as follows. (Please remind me if i forget some invariants)

  • [x] All the basic block should have one unconditional outgoing edge or two conditional outgoing edges.
  • [x] For basic blocks, which have two conditional outgoing edges, a selector is necessary.
  • [x] For basic blocks, which only have one unconditional outgoing edge, they could not have any selector.
  • [ ] Unreachable block should be deleted, which means all the basic block should be reached from start_node.
  • [ ] Every operation node should have the same operands as its arity.
  • [ ] Every operation node's operands should correspond width rule.
  • [x] Every operation node, except phi node, should not have back use-def edge or self loop.
  • [x] Every use-def SCC should be reachable
  • [x] There is only one copy for every constant
  • [x] Every constant must be registered into constants HashMap

ZhangZhuoSJTU avatar Sep 07 '17 10:09 ZhangZhuoSJTU

You can gain some inspiration from BIL verifier https://github.com/BinaryAnalysisPlatform/bap-veri

XVilka avatar Sep 12 '17 06:09 XVilka

After #95, the selector test for unconditional branches has been disabled. This needs to be re-enabled and checked when the target of an unconditional is not:

  1. A single target - Analysis of an indirect CF transfer may resolve it to a set of possible targets.
  2. Unresolved - No analysis has been run to determine the possible targets.

sushant94 avatar Sep 22 '17 07:09 sushant94

@ZhangZhuoSJTU any update on this one?

XVilka avatar Oct 02 '17 16:10 XVilka

So, what with this one?

XVilka avatar Jun 12 '18 04:06 XVilka

Let me check the code later today, I am not sure whether these have been finished by other people by chance.

ZhangZhuoSJTU avatar Jun 12 '18 04:06 ZhangZhuoSJTU

@ZhangZhuoSJTU are there any updates on this one?

XVilka avatar Jul 17 '18 02:07 XVilka

@ZhangZhuoSJTU ping? We want to make the first version next month.

XVilka avatar Jul 27 '18 05:07 XVilka

@ZhangZhuoSJTU can you please finish this one? Seems not that much work is left.

XVilka avatar Sep 26 '18 06:09 XVilka

Sorry, I forgot this one. Right now I have a finished SSAVerifier, but it will fail (all the time) because our SSA does have many bugs. If we want to let the test pass, we should close the verifier.

Anyway, I will finish this one this week when I am free. It's quick.

ZhangZhuoSJTU avatar Sep 26 '18 17:09 ZhangZhuoSJTU

This is good that it shows the bugs, it is the purpose after all.

On Thu, Sep 27, 2018, 1:59 AM izhuer [email protected] wrote:

Sorry, I forgot this one. Right now I have a finished SSAVerifier, but it will fail (all the time) because our SSA does have many bugs. If we want to let the test pass, we should close the verifier.

Anyway, I will finish this one this week when I am free. It's quick.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/radareorg/radeco-lib/issues/85#issuecomment-424812078, or mute the thread https://github.com/notifications/unsubscribe-auth/AAMZ_YsP7gd1XbUqNXoo3R8fk-9lrMBkks5ue8BigaJpZM4PPnyY .

XVilka avatar Sep 27 '18 01:09 XVilka

@ZhangZhuoSJTU can you please write what is the state of it? @Mm7 this one is important for making sure we get a valid results.

XVilka avatar Dec 28 '18 05:12 XVilka

@XVilka

I am sorry I might not be able to upload my local SSAVerifier. It seems RadecoIL has changed a lot so that my old code failed. I am so sorry that I do not have enough time to work on this right now.

But I think it might be easy to rewrite the verifier by someone who is familiar with the new IR. It would also be a good chance to get familiar with our IR.

Someone who will work on this can get hints from the original SSAVerifier. If he needs any help, I can answer in this issue.

ZhangZhuoSJTU avatar Dec 28 '18 08:12 ZhangZhuoSJTU