315 Commits

Author SHA1 Message Date
joaosaffran
5fd3aad54c
[DirectX] Updating Root Signature YAML representation to use Enums instead of uint (#154827)
This PR is updating Root Signature YAML to use enums, this is a required
change to remove the use of to_underlying from DirectXContainer binary
file.

Closes: [#150676](https://github.com/llvm/llvm-project/issues/150676)
2025-09-12 14:31:27 -04:00
joaosaffran
9179d3f19e
[DirectX] Validate if Textures/TypedBuffers are being bound in Root Signatures (#147573)
DXC doesn't allow Textures/TypedBuffers to bind with root signature
descriptors, this implements the same check.

Closes: #126647

---------

Co-authored-by: joaosaffran <joao.saffran@microsoft.com>
Co-authored-by: Joao Saffran <{ID}+{username}@users.noreply.github.com>
Co-authored-by: Joao Saffran <jderezende@microsoft.com>
2025-09-10 19:49:34 -04:00
joaosaffran
9e778f6cd1
[DirectX] Removing dxbc DescriptorRange from mcbxdc (#154629)
MC Descriptor Range Representation currently depend on Object
structures. This PR removes that dependency and in order to facilitate
removing to_underlying usage in follow-up PRs.
2025-09-10 14:49:01 -04:00
Finn Plummer
ad491118df
[HLSL][DirectX] Add support for rootsig as a target environment (#156373)
This pr implements support for a root signature as a target, as specified
[here](https://github.com/llvm/wg-hlsl/blob/main/proposals/0029-root-signature-driver-options.md#target-root-signature-version).

This is implemented in the following steps:
1. Add `rootsignature` as a shader model environment type and define
`rootsig` as a `target_profile`. Only valid as versions 1.0 and 1.1
2. Updates `HLSLFrontendAction` to invoke a special handling of
constructing the `ASTContext` if we are considering an `hlsl` file and
with a `rootsignature` target
3. Defines the special handling to minimally instantiate the `Parser`
and `Sema` to insert the `RootSignatureDecl`
4. Updates `CGHLSLRuntime` to emit the constructed root signature decl
as part of `dx.rootsignatures` with a `null` entry function
5. Updates `DXILRootSignature` to handle emitting a root signature
without an entry function
6. Updates `ToolChains/HLSL` to invoke `only-section=RTS0` to strip any
other generated information

Resolves: https://github.com/llvm/llvm-project/issues/150286.

##### Implementation Considerations
Ideally we could invoke this as part of `clang-dxc` without the need of
a source file. However, the initialization of the `Parser` and `Lexer`
becomes quite complicated to handle this.

Technically, we could avoid generating any of the extra information that
is removed in step 6. However, it seems better to re-use the logic in
`llvm-objcopy` without any need for additional custom logic in
`DXILRootSignature`.
2025-09-09 09:14:58 -06:00
Farzon Lotfi
1dbade85cb
[DirectX] Add emulation for fp16 types of llvm.is.fpclass (#157505)
fixes #157504

This changes adds the emulation we need for IsNaN, IsNormal, & IsFinite
This change only applies these emulations to the llvm.is.fpclass cases
of fp16.

Since there is no DX intrinsics yet for these cases, applying the
emulation to the necessary intrinsics is left for future implementers of
- https://github.com/llvm/llvm-project/issues/99132
- https://github.com/llvm/llvm-project/issues/156069
- https://github.com/llvm/llvm-project/issues/99131
2025-09-08 13:47:50 -04:00
Farzon Lotfi
16661b5d6c
[DirectX] Add isinf f16 emulation for SM6.8 and lower (#156932)
fixes #156068

- We needed to add a new sub arch to the target tripple so we can test
that emulation does not happen when targeting SM6.9
- The HLSL toolchain needed to be updated to handle the conversion of
strings to enums for the new sub arch.
- The emulation is done in DXILIntrinsicExpansion.cpp and needs to be
able to convert both llvm.is.fpclass and lvm.dx.isinf to the proper
emulation
- test updates in TargetParser/TripleTest.cpp, isinf.ll, is_fpclass.ll,
and DXCModeTest.cpp
2025-09-05 14:02:48 -04:00
Helena Kotas
58d2475d8a
[HLSL][NFC] Change line endings to LF (#156930)
Changes line endings in files related to HLSL to LF (`\n`).
2025-09-04 14:19:23 -07:00
Farzon Lotfi
01c0a8409a
[DirectX] Make dx.RawBuffer an op that can't be replaced (#154620)
fixes #152348

SimplifyCFG collapses raw buffer store from a if\else load into a
select.

This change prevents the TargetExtType dx.Rawbuffer from being replace
thus preserving the if\else blocks.

A further change was needed to eliminate the phi node before we process
Intrinsic::dx_resource_getpointer in DXILResourceAccess.cpp
2025-08-29 16:09:03 -04:00
paperchalice
19464d951a
[NFC] #155740 post cleanup (#155966)
Remove all "approx-func-fp-math" in tests.
2025-08-29 12:45:38 +08:00
joaosaffran
36ebd17972
[DirectX] Validate registers are bound to root signature (#146785)
DXC checks if registers are correctly bound to root signature
descriptors. This implements the same check.
closes: #[126645](https://github.com/llvm/llvm-project/issues/126645)

---------

Co-authored-by: joaosaffran <joao.saffran@microsoft.com>
Co-authored-by: Joao Saffran <jderezende@microsoft.com>
2025-08-28 17:10:10 -04:00
Helena Kotas
ddf8cd3c6c
[HLSL][DirectX] Remove uniformity bit from resource initialization intrinsics (#155332)
Removes uniformity bit from resource initialization intrinsics `llvm.{dx|spv}.resource.handlefrombinding` and `llvm.{dx|spv}.resource.handlefromimplicitbinding`. The flag currently always set to `false`. It should be derived from resource analysis and not provided by codegen.

Closes #135452
2025-08-28 09:12:36 -07:00
Finn Plummer
6f0253b435
[DirectX][ObectYAML] Make RootParameterOffset and StaticSamplersOffset behaviour consistent (#155521)
This pr fixes some inconsistencies in behaviour of how we handle
`StaticSamplersOffset` with respect to DXC and `RootParameterOffset`.
Namely:

1. Make codegen of `RTS0` always compute the `StaticSamplersOffset`
regardless if there are any `StaticSampler`s. This is to be consistent
and produce an identical `DXContainer` as DXC.
2. Make the `StaticSamplersOffset` and `RootParametersOffset` optional
parameters in the yaml description. This means it will be used when it
is specified (which was not necassarily the case before).
3. Enforce that the provided `StaticSamplersOffset` and
`RootParametersOffset` in a yaml description match the computed value.

For more context see:
https://github.com/llvm/llvm-project/issues/155299.

Description of existing test updates updates:
- `CodeGen/DirectX/ContainerData`: Updated to codegen computed values
(previously unspecified)
- `llvm-objcopy/DXContainer`: Updated to `yaml2obj` computed values
(previously unspecified)
- `ObjectYAML/DXContainer`: Updated to `yaml2obj` computed values
(previously incorrect)
- `ObjectYAML/DXContainerYAMLTest`: Updated to `yaml2obj` computed
values (previously incorrect)

See newly added tests for testing of optional parameter functionality
and `StaticSamplersOffset` computation.

Resolves: https://github.com/llvm/llvm-project/issues/155299
2025-08-27 11:53:37 -07:00
joaosaffran
c6dfbc5cc7
[DirectX] Refactor RootSignature Backend to remove to_underlying from Root Parameter Header (#154249)
This patch is refactoring Root Parameter Header in DX Container backend
to remove the usage of `to_underlying`. This requires some changes:
first, MC Root Signature should not depend on Object/DXContainer.h;
Second, we need to assume data to be valid in scenarios where it was
originally not expected, this made some tests be removed.
2025-08-25 16:28:07 -04:00
Kaitlin Peng
0bb1af478a
[DirectX] Add GlobalDCE pass after finalize linkage pass in DirectX backend (#151071)
Fixes #139023.

This PR essentially removes unused global variables:
- Restores the `GlobalDCE` Legacy pass and adds it to the DirectX
backend after the finalize linkage pass
- Converts external global variables with no usage to internal linkage
in the finalize linkage pass
  - (so they can be removed by `GlobalDCE`)
- Makes the `dxil-finalize-linkage` pass usable using the new pass
manager flag syntax
- Adds tests to `finalize_linkage.ll` that make sure unused global
variables are removed
- Adds a use for variable `@CBV` in `opaque-value_as_metadata.ll` so it
isn't removed
- Changes the `scalar-data.ll` run command to avoid removing its global
variables

---------

Co-authored-by: Farzon Lotfi <farzonlotfi@microsoft.com>
2025-08-15 10:45:34 -07:00
joaosaffran
d56fa96524
[DirectX] Add Range Overlap validation (#152229)
As part of the Root Signature Spec, we need to validate if Root
Signatures are not defining overlapping ranges.
Closes: https://github.com/llvm/llvm-project/issues/126645

---------

Co-authored-by: joaosaffran <joao.saffran@microsoft.com>
Co-authored-by: Joao Saffran <{ID}+{username}@users.noreply.github.com>
Co-authored-by: Joao Saffran <jderezende@microsoft.com>
2025-08-14 18:40:11 -04:00
Farzon Lotfi
544562ebc2
[DirectX] Remove lifetime intrinsics and run Dead Store Elimination (#152636)
fixes #151764

This fix has two parts first we track all lifetime intrinsics and if
they are users of an alloca of a target extention like dx.RawBuffer then
we eliminate those memory intrinsics when we visit the alloca.

We do step one to allow us to use the Dead Store Elimination Pass. This
removes the alloca and simplifies the use of the target extention back
to using just the global. That keeps things in a form the
DXILBitcodeWriter is expecting.

Obviously to pull this off we needed to bring back the legacy pass
manager plumbing for the DSE pass and hook it up into the DirectX
backend.

The net impact of this change is that DML shader pass rate went from
89.72% (4268 successful compilations) to 90.98% (4328 successful
compilations).
2025-08-12 12:42:08 -04:00
Helena Kotas
5165a6c197
[HLSL] Update DXIL resource metadata code to support resource arrays (#152254)
Closes #145422
2025-08-11 14:55:54 -07:00
Kaitlin Peng
cbc8f650ea
[HLSL][DirectX] Fix dot2add DXIL operation to use float overload (#152781)
Fixes #152585.

The `dot2add` DXILOpFunction should be `dx.op.dot2AddHalf.f32` (i.e. it
has [a single overload that's a
float](https://github.com/microsoft/DirectXShaderCompiler/blob/main/utils/hct/hctdb.py#L3960),
rather than no overloads). It was also being defined for too low of a
DXIL version - [dxc says
SM6.4](https://github.com/microsoft/DirectXShaderCompiler/blob/main/utils/hct/hctdb.py#L740).
2025-08-11 13:03:24 -07:00
Helena Kotas
fb1035cfb4
[DirectX] Fix resource binding analysis incorrectly removing duplicates (#152253)
The resource binding analysis was incorrectly reducing the size of the
`Bindings` vector by one element after sorting and de-duplication. This
led to an inaccurate setting of the `HasOverlappingBinding` flag in the
`DXILResourceBindingInfo` analysis, as the truncated vector no longer
reflected the true binding state.

This update corrects the shrink logic and introduces an `assert` in the
`DXILPostOptimizationValidation` pass. The assertion will trigger if
`HasOverlappingBinding` is set but no corresponding error is detected,
helping catch future inconsistencies.

The bug surfaced when the `srv_metadata.hlsl` and `uav_metadata.hlsl`
tests were updated to include unbounded resource arrays as part of
https://github.com/llvm/llvm-project/issues/145422. These updated test
files are included in this PR, as they would cause the new assertion to
fire if the original issue remained unresolved.

Depends on #152250
2025-08-11 10:53:00 -07:00
Deric C.
e13cb3e299
[DirectX] Update lifetime legalization to account for the removed size argument (#152791)
Fixes #152754 

- Fixes the ArgOperand index in `DXILOpLowering.cpp` used to obtain the
pointer operand of a lifetime intrinsic.
- Updates the tests
`llvm/test/CodeGen/DirectX/legalize-lifetimes-valver-1.5.ll`,
`llvm/test/CodeGen/DirectX/legalize-lifetimes-valver-1.6.ll`,
`llvm/test/CodeGen/DirectX/ShaderFlags/lifetimes-noint64op.ll`, and
`llvm/test/tools/dxil-dis/lifetimes.ll` to use the new size-less
lifetime intrinsic
- Removes lifetime intrinsics from the test
`llvm/test/CodeGen/DirectX/legalize-memset.ll` to be consistent with the
corresponding memcpy test which does not have lifetime intrinsics.
(Removal of lifetime intrinsics from tests like this was suggested here
in the past:
https://github.com/llvm/llvm-project/pull/139173#discussion_r2091778868)
- Rewrites the lifetime legalization functions in the EmbedDXILPass to
re-add the explicit size argument for DXIL
2025-08-08 14:32:27 -07:00
Helena Kotas
f7c6c7ce36
[DirectX] Overlapping binding detection - check register space first (#152250)
The code that checks for overlapping binding did not compare register space when one of the bindings was for an unbounded resource array, leading to false errors. This change fixes it.
2025-08-07 10:48:47 -07:00
Kaitlin Peng
bd741975bc
Scalarize vector mad operations for integer types (#152228)
Fixes #152220.

- Adds `dx_imad` and `dx_umad` to
`isTargetIntrinsicTriviallyScalarizable`
- Adds tests that confirm the intrinsic is now scalarizing
2025-08-07 09:34:42 -07:00
Farzon Lotfi
04672e20d4
[DirectX] ForwardHandle needs to check if globals were stored on allocas (#151751)
fixes #140819

SROA pass is making it so that some globals get loaded into stack
allocations. This means we find an alloca where we use to expect a load
and now need to walk an alloca -> store -> maybe load chain before we
find the global. Doing so fixes All but two instances of #137715 And
fixes every instance of `Load of "8.sroa.0" is not a global resource
handle we are currently seeing in the DML shaders.
2025-08-06 21:14:35 -04:00
joaosaffran
b2e5303292
[DirectX] Error handling improve in root signature metadata Parser (#149232)
This PR addresses
https://github.com/llvm/llvm-project/pull/144465#issuecomment-3063422828.
Using `joinErrors` and `llvm:Error` instead of boolean values.

---------

Co-authored-by: joaosaffran <joao.saffran@microsoft.com>
Co-authored-by: Joao Saffran <{ID}+{username}@users.noreply.github.com>
2025-07-31 22:59:02 -04:00
Helena Kotas
f169af3ba7
[HLSL] Fix detection of overlapping binding with unbounded array (#150547)
Fixes #150534
2025-07-25 09:41:20 -07:00
Deric C.
4ae2678372
[DirectX] Add support for vector type checking in DXIL Shader Flag Analysis (#150532)
Fixes #150482 by replacing all `Instruction.getType()` in
DXILShaderFlags.cpp with `Instruction.getType()->getScalarType()` to
account for vectors types as suggested by @bogner
2025-07-24 17:09:34 -07:00
Deric C.
e178e82c63
[DirectX] Do not flatten GEP chains for unsupported types (#150484)
Fixes #150463 by not processing GEPs for unsupported types such as
structs in the DXILFlattenArrays pass.
2025-07-24 13:36:36 -07:00
Farzon Lotfi
c73c19c60e
[DirectX] Support ConstExpr GEPs (#150082)
- Fixes #150050
- Address the issue of many nested geps
- Check for ConstantExpr GEP if we see it check if it needs a global
replacement with a new type. Create the new constExpr Gep and set the
pointer operand to it. Finally cleanup and remove the old nested geps.
2025-07-23 16:38:14 -04:00
Deric C.
c3c72c1de9
[DirectX] Legalize llvm.lifetime.* intrinsics in EmbedDXILPass (#150100)
Fixes #147395

This PR:
- Excludes lifetime intrinsics from the Int64Ops shader flags analysis
to match DXC behavior and pass DXIL validation.
- Performs legalization of `llvm.lifetime.*` intrinsics in the
EmbedDXILPass just before invoking the DXILBitcodeWriter.
- After invoking the DXILBitcodeWriter, all lifetime intrinsics and
associated bitcasts are removed from the module to keep the Module
Verifier happy. This is fine since lifetime intrinsics are not needed by
any passes after the EmbedDXILPass.
2025-07-22 17:08:05 -07:00
Deric C.
0c14f0e891
[Scalarizer] Use correct key for ExtractValueInst gather (#149855)
Fixes #149345

Effectively no-op pairs of insertelement-extractelement instructions
were being created due to the ExtractValueInst visitor in the Scalarizer
storing its scalarized result into the Scattered map using an incorrect
key (specifically the type used in the key).
This PR fixes this issue.
2025-07-21 17:12:15 -07:00
Deric C.
8f9ed78874
Revert "[DirectX] Legalize lifetime intrinsics for DXIL" (#149883)
Reverts llvm/llvm-project#148003 to fix a DirectX backend build breakage
due to #149310
2025-07-21 12:34:50 -07:00
Deric C.
c4f3bc91c0
Revert "Revert "[DirectX] Lower llvm.lifetime.* intrinsics to stores when DXIL version is lower than 1.6 (#147432)"" (#149882)
Reverts llvm/llvm-project#149874

Reverted the wrong PR by mistake.
2025-07-21 12:29:22 -07:00
Deric C.
509af524e3
Revert "[DirectX] Lower llvm.lifetime.* intrinsics to stores when DXIL version is lower than 1.6 (#147432)" (#149874)
This PR reverts commit d47c126fbf7915c01ea112ae372fe8835df4379f
(corresponding to PR #147432) to fix a build failure caused by #149310
2025-07-21 12:10:36 -07:00
Deric C.
fae8df2b82
[DirectX] Fix GEP flattening with 0-indexed GEPs on global variables (#149211)
Fixes #149179 

The issue is that `Builder.CreateGEP` does not return a GEP Instruction
or GEP ContantExpr when the pointer operand is a global variable and all
indices are constant zeroes.

This PR ensures that a GEP instruction is created if `Builder.CreateGEP`
did not return a GEP.
2025-07-17 14:51:53 -07:00
Deric C.
689e95817e
[DirectX] Add a GEP to scalar load/store on globals and remove incorrect assertion (#149191)
Fixes #149180

This PR removes an assertion that triggered on valid IR. It has been
replaced with an if statement that returns early if the conditions are
not correct.

This PR also adds GEPs to scalar loads and stores from/to global
variables.
2025-07-17 14:46:45 -07:00
Deric C.
a9021e5373
Emit array GEPs in memcpy/memset legalization (#148886)
Fixes #148089
2025-07-15 11:35:20 -07:00
Deric C.
09f7cab9a3
[DirectX] Add a GEP to loads and stores on array allocas (#148059)
Fixes #147114 by inserting a GEP between any direct loads and stores on
an alloca.
2025-07-15 10:40:52 -07:00
Deric C.
27b3b4a665
[DirectX] Move the scalarizer pass to before dxil-flatten-arrays (#146800)
Fixes #145924 and #140416
Depends on #146173 being merged first.

This PR moves the scalarizer pass to immediately before the
dxil-flatten-arrays pass to allow the dxil-flatten-arrays pass to turn
scalar GEPs (including i8 GEPs) into flattened array GEPs where
applicable.

A number of LLVM DirectX CodeGen tests have been edited to remove scalar
GEPs and also correct previously uncaught incorrectly-transformed GEPs.

No more validation errors of the form `Access to out-of-bounds memory is
disallowed` or `TGSM pointers must originate from an unambiguous TGSM
global variable` appear anymore after this PR when compiling DML
shaders.
2025-07-14 18:13:42 -07:00
Deric C.
352215c6eb
[DirectX] Simplify and correct the flattening of GEPs in DXILFlattenArrays (#146173)
In tandem with #146800, this PR fixes #145370

This PR simplifies the logic for collapsing GEP chains and replacing
GEPs to multidimensional arrays with GEPs to flattened arrays. This
implementation avoids unnecessary recursion and more robustly computes
the index to the flattened array by using the GEPOperator's
collectOffset function, which has the side effect of allowing "i8 GEPs"
and other types of GEPs to be handled naturally in the flattening /
collapsing of GEP chains.

Furthermore, a handful of LLVM DirectX CodeGen tests have been edited to
fix incorrect GEP offsets, mismatched types (e.g., loading i32s from a
an array of floats), and typos.
2025-07-14 16:39:01 -07:00
Deric C.
fee27b3337
[DirectX] Legalize lifetime intrinsics for DXIL (#148003)
Fixes #147395

This PR legalizes lifetime intrinsics for DXIL by
- Adding a bitcast for the lifetime intrinsics' pointer operand in
dxil-prepare to ensure it gets cast to an `i8*` when written to DXIL
- Removing the memory attribute from lifetime intrinsics in dxil-prepare
to match DXIL
- Making the DXIL bitcode writer write the base/demangled name of
lifetime intrinsics to the symbol table
- Making lifetime intrinsics an exception to Int64Ops shader flag
analysis (otherwise we get `error: Flags must match usage.` from the
validator)
2025-07-11 12:26:53 -07:00
Finn Plummer
420e2f584d
[DirectX] Add missing verifications during validate of DXILRootSignature (#147111)
This pr resolves some discrepancies in verification during `validate` in
`DXILRootSignature.cpp`.

Note: we don't add a backend test for version 1.0 flag values because it
treats the struct as though there is no flags value. However, this will
be used when we use the verifications in the frontend.

- Updates `verifyDescriptorFlag` to check for valid flags based on
version, as reflected [here](https://github.com/llvm/wg-hlsl/pull/297)
- Add test to demonstrate updated flag verifications
- Adds `verifyNumDescriptors` to the validation of `DescriptorRange`s
- Add a test to demonstrate `numDescriptors` verification
- Updates a number of tests that mistakenly had an invalid
`numDescriptors` specified

Resolves: https://github.com/llvm/llvm-project/issues/147107
2025-07-09 12:02:02 -07:00
Deric C.
d47c126fbf
[DirectX] Lower llvm.lifetime.* intrinsics to stores when DXIL version is lower than 1.6 (#147432)
Fixes #147394

References DXC for the implementation logic:

d751c827ed/lib/HLSL/DxilPreparePasses.cpp (L693-L699)

If DXIL Version < 1.6 then replace lifetime intrinsics with stores

- For validator version >= 1.6, store an undef
- For validator version < 1.6, store zeros

else keep the lifetime intrinsics in the DXIL.

After this PR, the number of DML shaders failing validation due to
#146974 is reduced from 157 to 50.
2025-07-08 14:45:14 -07:00
Sarah Spall
5e87a712f9
[DirectX] Add support for Raw Buffer Loads and Stores for scalars and vectors of doubles and i64s in SM6.2 and earlier (#146627)
For SM6.2 and earlier, Raw buffer Loads and Stores can't handle 64 bit
types. This PR expands Raw Buffer Loads and Stores for 64 bit types
double and int64_t. This Adds to the work done in #139996 and #145047 .
Raw Buffer Loads and Stores allow for 64 bit type vectors of size 3 and
4, and the code is modified to allow for that.
Closes #144747
2025-07-07 16:42:32 -07:00
Kaitlin Peng
dc8e89b2b3
[DirectX] Convert private global variables to internal linkage during Finalize Linkage pass (#146406)
Fixes #140420. The switch.table.* validation errors were caused by DXIL
not supporting private global variables. Converting them to internal
linkage fixes the bug.

May need more discussion on the preserved analyses/a follow-up PR that
fixes what this pass says it preserves.
2025-07-07 10:50:43 -07:00
Deric C.
12409a18f6
[DirectX] Implement memcpy in DXIL CBuffer Access pass (#144436)
Fixes #141840

This PR implements support for the `memcpy` intrinsic in the DXIL
CBuffer Access pass with the following restrictions:

- The CBuffer Access must be the `src` operand of `memcpy` and must be
direct (i.e., not a GEP)
- The type of the CBuffer Access must be of an Array Type

These restrictions greatly simplify the implementation of `memcpy` yet
still covers the known uses in DML shaders.

Furthermore, to prevent errors like #141840 from occurring silently
again, this PR adds error reporting for unsupported users of globals in
the DXIL CBuffer Access pass.
2025-06-30 16:32:43 -07:00
joaosaffran
171aa34e43
[DirectX] Add static sampler support to root signature (#143422)
Implements static samplers parsing from root signature metadata
representation. This is required to support Root Signatures in HLSL.
Closes: #[126641](https://github.com/llvm/llvm-project/issues/126641)

---------

Co-authored-by: joaosaffran <joao.saffran@microsoft.com>
2025-06-27 14:30:48 -07:00
Farzon Lotfi
5dbd8772fe
[DirectX] add support for i64 buffer load/stores (#145047)
fixes #140321

Specifically it fixes ` error: Cannot create BufferLoad operation:
Invalid overload type`
https://hlsl.godbolt.org/z/dTq4q7o58
but no new DML shaders are building. This change now exposes #144747.

The change does two things it adds i64 support for intrinsic expansion
for the `dx_resource_load_typedbuffer`, and
`dx_resource_store_typedbuffer` intrinsics.

It also lets loaded typedbuffers crash more gracefully because of ` auto
*EVI = cast<ExtractValueInst>(U);` is now a `dyn_cast` and
`llvm_unreachable`.
2025-06-27 14:11:56 -04:00
Farzon Lotfi
778b6a21ec
[DirectX] Allow vector Allocas to be transformed into arrays (#145972)
fixes #145782

This change modifies `isArrayOfVectors` into `isVectorOrArrayOfVectors`.
The previous implementation did not support vector to array
transformations. Further it was too simplistic and didn't assume allocas
would create multidimensional arrays.
2025-06-27 13:12:47 -04:00
Farzon Lotfi
38aec4f1f4
[DirectX] Limit GEP transformations to Arrays (#145758)
fixes #145408

Before we see the GEP we already have transformed Allocas that get
passed the `isArrayOfVectors`.
The bug is because we are trying to transform a gep for struct of arrays
when we should only be transforming arrays.

The problem with our `visitGetElementPtrInst` is that it was doing
transformations for all allocas when it should be limiting it to the
alloca of array cases. Technically we would have liked to make sure it
was an array of vectors cases but by the time we see the GEP the type
has been changed by replace all uses. There should not be a problem with
looking at all Arrays since DXILDataScalarization does not change any
indicies.
2025-06-25 17:17:52 -04:00
Finn Plummer
a8ef75e758
[DirectX] Strip dx.rootsignatures metadata during dxil-prepare (#145746)
The `dx.rootsignatures` metadata is not recognized in DXIL, so failure
to remove this will cause validation errors.

This metadata is parsed (within `RootSignatureAnalysisWrapper`) into its
binary format. As such, once it has been used to construct the binary
form, it can be safely discarded without loss of information.

This pr ensures that the dxil prepare pass will depend and preserve on
the root signature analysis so that it runs before the metadata is
removed.

- Update `DXILPrepare.cpp` to preserve and depend on
`RootSignatureAnalysisWrapper`
- Update test to demonstrate order is correct
- Provide test-case to demonstrate the metadata is removed

Resolves https://github.com/llvm/llvm-project/issues/145437.

----------

Co-authored-by: Justin Bogner <mail@justinbogner.com>
2025-06-25 14:06:46 -07:00