Simplify register access to constant value based on VSA

Open
#1,721 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
cpp

Research direction

No file or test is named. Start by tracing where VSA ConstantValue results are consumed during decompilation and where register returns are selected. Done means the redundant register access is simplified when VSA proves the value is constant, with behavior covered by a regression test.

Written by the indexing model from the issue text.

Description

Component: Core Core: HLIL Effort: Medium IL Optimization Impact: Medium

I often see this sort of thing in particular:

if (x == 0)
    return x

which could be (and is, in source):

if (x == 0)
    return 0

It seems this is a common compiler optimization - why load 0 into a register when you've just proven it's already there? Binja's VSA already correctly determines that x is ConstantValue: 0 here.

Dominant language
C++
Stars
1.3k
Forks
298
Avg merge
5d 5h
Merged PRs (30d)
19

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Vector35/binaryninja-api

All issues in Vector35/binaryninja-api

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.