Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[12.0.0]: x64: Remove recursion in to_amode helper #6995

Merged
merged 1 commit into from
Sep 11, 2023

Commits on Sep 11, 2023

  1. x64: Remove recursion in to_amode helper

    This commit removes the recursion present in the x64 backend's
    `to_amode` and `to_amode_add` helpers. The recursion is currently
    unbounded and controlled by user input meaning it's not too hard to
    craft user input which triggers stack overflow in the host. By removing
    recursion there's no need to worry about this since the stack depth will
    never be hit.
    
    The main concern with removing recursion is that code quality may not be
    quite as good any more. The purpose of the recursion here is to "hunt
    for constants" and update the immediate `Offset32`, and now without
    recursion only at most one constant is found and folded instead of an
    arbitrary number of constants as before. This should continue to produce
    the same code as before so long as optimizations are enabled, but
    without optimizations this will produce worse code than before.
    
    Note with a hypothetical mid-end optimization that does this constant
    folding for us the rules here could be further simplified to purely
    consider the shape of the input `Value` to amode computation without
    considering constants at all.
    alexcrichton committed Sep 11, 2023
    Configuration menu
    Copy the full SHA
    55617e3 View commit details
    Browse the repository at this point in the history