[SM6.9][SER] inout dx::HitObject parameter reaches the DXIL intrinsic as undef

未关闭
#9,062 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
55/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
cpp
领域
compilers

调研方向

Start in CGHLSLMS.cpp at the copy-in and copy-back checks around lines 6201 and 6495, then inspect the temporary address replacement and lifetime marker handling around lines 6408 and 6540–6549. Compare how HitObject is classified in both paths and run the proposed hitobject-inout-byval.hlsl case with dxc -T lib_6_9; done means the reading callee observes the value created by MakeMiss and validation passes.

由索引模型根据 Issue 内容生成。

描述

bug needs-triage

Description

Passing a dx::HitObject as an inout parameter loses the caller's value. The callee sees undef and validation fails. in works, and inout also works with -Od or -disable-lifetime-markers. Lifetime markers are on by default from SM 6.6, so this affects normal SM 6.9 compiles.

Steps to Reproduce

RWBuffer<uint> o : register(u0);

void F(inout dx::HitObject h) { o[0] = h.IsMiss(); }

[shader("raygeneration")]
void main() {
  RayDesc r;
  dx::HitObject h = dx::HitObject::MakeMiss(0, 0, r);
  F(h);
}
dxc -T lib_6_9 hitobject_inout.hlsl

Compiles cleanly with any of: -Od, -disable-lifetime-markers, or inout changed to in.

Actual Behavior

error: validation errors
hitobject_inout.hlsl:3:40: error: HitObject is undef.
note: at '%2 = call i1 @dx.op.hitObject_StateScalar.i1(i32 269, %dx.types.HitObject undef)' in block '#0' of function '?main@@YAXXZ'.
Validation failed.

Expected Behavior

h.IsMiss() reads the hit object created by MakeMiss.

Environment

  • DXC 1.9.2609.5 (01b62ad47), also reproduced on 1.9.2602.24
  • Windows 10 Home 64-bit, build 19045

Additional context

The copy-in and copy-back code in CGHLSLMS.cpp disagree on whether HitObject is an object:

  • Copy-in (:6201) checks IsByValueObject, treats HitObject as a value, and emits the copy.
  • Copy-back (:6495) checks only dxilutil::IsHLSLObjectType, treats it as an object, and falls through to tmpArgAddr->replaceAllUsesWith(argLV.getAddress()) at :6540.

The lifetime.start emitted at :6408 is one of the rewritten uses, so it moves onto the caller's alloca after MakeMiss has stored to it. mem2reg treats it as a def and the value becomes undef. The lifetime.end at :6549 is created after the RAUW and stays on the unused temporary.

This looks like a regression from #7767 (8872029ef), which introduced IsByValueObject but didn't update the copy-back check.

Test coverage note: hitobject-byval.hlsl and hitobject-array-byval.hlsl say inout behaves like the other modifiers, but neither tests it. Adding an inout RUN line wouldn't catch this anyway, because none of the callees read their parameter. A test with a reading callee will be attached as hitobject-inout-byval.hlsl; only its inout RUN line fails today.

主要语言
C++
星标
3.7k
派生
926
平均合并
3 天 22 小时
30 天内合并 PR
45

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

microsoft/DirectXShaderCompiler 的其他 Issue

查看 microsoft/DirectXShaderCompiler 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。