Skip to content

[DirectX] Add a pass to forward handle creation intrinsics to the accesses of those handles #134574

Closed
@bogner

Description

@bogner

Given a resource handle that's generated via a global initializer and later used by various resource specific intrinsics, we end up with code that looks something like so:

  %h = tail call target(...) @llvm.dx.resource.handlefrombinding(...)
  store target(...) %h, ptr @GlobalHandle
  ; ...
  %h1 = load target(...), ptr @GlobalHandle
  call void @llvm.dx.resource.use(target(...) %h1)

Generally this gets cleaned up throughout the optimizer, which recognizes that we're loading from the global we just stored to and forwards the argument from the handle creation intrinsic to the use directly. However, this is optimization dependent and isn't guaranteed. Furthermore, for cases like cbuffers, where we introduce the resource uses late as a translation from accesses to globals (see #124630), we may have this pattern created post optimization so there's no chance to clean it up.

We need a pass that specifically recognizes this type of access to an HLSL resource and forwards the accesses directly in order to do the right thing reliably and independent of optimization level.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Closed

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions