microsoft / DirectXShaderCompiler

This repo hosts the source for the DirectX Shader Compiler which is based on LLVM/Clang.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DxilValidation should reject unsupported llvm integer sizes

tex3d opened this issue · comments

Description
Some locations in Clang CodeGen or llvm optimizations will result in odd-sized int value types, such as i25. The DXIL Validator should catch and reject such unsupported sizes when found in the IR, and we should fix the sources of these to prevent them from appearing in the first place.

Steps to Reproduce

uint param;

bool fn()
{
    switch (param)
    {
    case 0:
    case 20:
    case 24:
        return false;
    }
    return true;
}

float4 main() : SV_Target
{
    float4 ret = float4(0, 0, 0, 0);
    if (fn())
    {
        ret = float4(1, 1, 1, 1);
    }
    return ret;
}

Actual Behavior
Results in IR containing i25:

  %6 = trunc i32 %3 to i25
  %7 = lshr i25 15728638, %6
  %8 = and i25 %7, 1
  %9 = icmp ne i25 %8, 0
  %10 = select i1 %9, float 1.000000e+00, float 0.000000e+00

This i25 type should never be produced or accepted by DxilValidation. In this case, an optimization produces the value (which is usually the case).

This bug is about preventing this from passing validation. See #6564 for tracking the optimization producing the value in the first place.

Environment

  • DXC version: latest main, not a regression
  • Host Operating System: any