+
Skip to content

Constant condition propagation misses cases where variable cannot be easily replaced #5675

@rhelmot

Description

@rhelmot

Description

cmp rax, 0
jnz elsewhere
loop_header:
cmp rax, 10
jz loop_break
inc rax
jmp loop_header
loop_footer:
...

Here, we would like to identify that rax in the loop and rax before the loop are separate variables. ConditionConstantPropagation is supposed to do this, but it can only replace variable access expressions with constants. Here, the next time the vvar is used after the condition is inside the loop where it changes between iterations.

Proposed solution: create an artificial node between the branch and the constant successor where we assign a new vvar to the constant, and then replace all dominated uses of the condition vvar with the new vvar.

Steps to reproduce the bug

decompile wget lookup_host. r14d is branched on at 418F92 and used at 418FD3.

Environment

don't worry about it <3

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is brokenneeds-triageIssue has yet to be looked at by a maintainer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载