llvm / llvm/llvm-project

[HLSL][DirectX] Collection of bugs in `dxil-resource-access`

Open
#211,121 0 comments 0 reactions 1 assignee Claimed by @inbelic View on GitHub
backend:DirectX HLSL
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

The following bugs were noted when auditing `dxil-resource-access`.

1. The pass does not account for the case when the resource holds a struct and generates a gep into the struct. https://godbolt.org/z/PqseYcPMe. This should be resolved by extending the `collectUsedHandles` to traverse through a gep.
2. The pass can incorrectly place a load/store within the phi nodes at top of the basic block. https://godbolt.org/z/x5Ec4GWGT. This should be resolved by updating `replaceHandleWithIndices` to adjust the insertion point when the ptr comes from a phi node.
3. The pass will enter an infinite loop when collecting the handles if the phi nodes loop. https://godbolt.org/z/77sr89oMj and https://godbolt.org/z/h4oW7Me5G. This should be resolved by updating `collectUsedHandles`/`getAccessIndices` with a visited set of phi nodes.
4. A phi node of the index should only be created if the indices actually differ. https://godbolt.org/z/x6z64qqvK. This should be resolved by updating `getAccessIndices` to only create a new phi when needed. This causes validation errors when accessing specific resources that require all indices are constant.

_Note_: In the above links, removing the `-mllvm -stop-before=dxil-resource-access` exhibits the behaviour

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.