Issue 134574
Summary [DirectX] Add a pass to forward handle creation intrinsics to the accesses of those handles
Labels backend:DirectX, HLSL
Assignees bogner
Reporter 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:
```llvm
  %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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to