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

Fix sroa replace constant with non constant in entry block #6591

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Commits on Apr 24, 2024

  1. Fix invalid IR from scalarrepl-param-hlsl in ReplaceConstantWithInst

    ReplaceConstantWithInst(C, V) replaces uses of C in the current function with V.
    If such a use C is an instruction I, the it replaces uses of C in I with V.
    However, this function did not make sure to only perform this replacement if V
    dominates I. As a result, it may end up replacing uses of C in instructions
    before the definition of V.
    
    The fix is to lazily compute the dominator tree in ReplaceConstantWithInst so
    that we can guard the replacement with that dominance check.
    amaiorano authored and pow2clk committed Apr 24, 2024
    Configuration menu
    Copy the full SHA
    e7832f4 View commit details
    Browse the repository at this point in the history

Commits on Apr 30, 2024

  1. Place memcpy constant replacements in entry block

    In order to replace memcpy instances, sometimes constants need to be
    replaced with instructions. Rather than place them wherever is
    immediately convenient, placing them in the entry block after the
    allocas ensures they have access to the allocas while making sure they
    dominate any uses, increasing the chances that the associated memcpy can
    be replaced rather than potentially introducing a domination issue that
    would prevent the memcpy replace.
    pow2clk committed Apr 30, 2024
    Configuration menu
    Copy the full SHA
    64bfdc0 View commit details
    Browse the repository at this point in the history
  2. prevent static global init breaking up allocas

    We try to keep the allocas at the top of the entry block. This
    initialization code placed the init instruction just after the alloca it
    was initializing, which left it in the middle of the allocas. This
    disrupted future attempts to find the end of the allocas and potentially
    put instructions referencing allocas before the relevant alloca.
    pow2clk committed Apr 30, 2024
    Configuration menu
    Copy the full SHA
    41663ca View commit details
    Browse the repository at this point in the history