aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/DirectX
AgeCommit message (Collapse)AuthorFilesLines
4 days[DirectX] Validating Root flags are denying shader stage (#160919)joaosaffran1-12/+60
Root Signature Flags, allow flags to block compilation of certain shader stages. This PR implements a validation and notify the user if they compile a root signature that is denying such shader stage. Closes: https://github.com/llvm/llvm-project/issues/153062 Previously approved: https://github.com/llvm/llvm-project/pull/153287 --------- 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>
5 daysImplements isnan() HLSL intrinsic for DXIL and SPIR-V targets. (#157733)Dan Brown3-0/+7
Addresses #99132.
7 days[DirectX] NonUniformResourceIndex lowering (#159608)Helena Kotas1-10/+58
Introduces `llvm.{dx|svp}.resource.nonuniformindex` intrinsic that will be used when a resource index is not guaranteed to be uniform across threads (HLSL function NonUniformResourceIndex). The DXIL lowering layer looks for this intrinsic call in the resource index calculation, makes sure it is reflected in the NonUniform flag on DXIL create handle ops (`dx.op.createHandle` and `dx.op.createHandleFromBinding`), and then removes it from the module. Closes #155701
2025-09-11[DirectX] Removing dxbc StaticSampler from mcbxdc (#154631)joaosaffran1-1/+1
MC Static Samplers Representation currently depends on Object structures. This PR removes that dependency and in order to facilitate removing to_underlying usage in follow-up PRs.
2025-09-11[llvm] Move data layout string computation to TargetParser (#157612)Reid Kleckner1-5/+2
Clang and other frontends generally need the LLVM data layout string in order to generate LLVM IR modules for LLVM. MLIR clients often need it as well, since MLIR users often lower to LLVM IR. Before this change, the LLVM datalayout string was computed in the LLVM${TGT}CodeGen library in the relevant TargetMachine subclass. However, none of the logic for computing the data layout string requires any details of code generation. Clients who want to avoid duplicating this information were forced to link in LLVMCodeGen and all registered targets, leading to bloated binaries. This happened in PR #145899, which measurably increased binary size for some of our users. By moving this information to the TargetParser library, we can delete the duplicate datalayout strings in Clang, and retain the ability to generate IR for unregistered targets. This is intended to be a very mechanical LLVM-only change, but there is an immediately obvious follow-up to clang, which will be prepared separately. The vast majority of data layouts are computable with two inputs: the triple and the "ABI name". There is only one exception, NVPTX, which has a cl::opt to enable short device pointers. I invented a "shortptr" ABI name to pass this option through the target independent interface. Everything else fits. Mips is a bit awkward because it uses a special MipsABIInfo abstraction, which includes members with codegen-like concepts like ABI physical registers that can't live in TargetParser. I think the string logic of looking for "n32" "n64" etc is reasonable to duplicate. We have plenty of other minor duplication to preserve layering. --------- Co-authored-by: Matt Arsenault <arsenm2@gmail.com> Co-authored-by: Sergei Barannikov <barannikov88@gmail.com>
2025-09-10[DirectX] Validate if Textures/TypedBuffers are being bound in Root ↵joaosaffran1-3/+33
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[DirectX] Removing dxbc DescriptorRange from mcbxdc (#154629)joaosaffran2-23/+6
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-09[HLSL][DirectX] Add support for `rootsig` as a target environment (#156373)Finn Plummer3-22/+40
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-08[DirectX] Add emulation for fp16 types of llvm.is.fpclass (#157505)Farzon Lotfi1-1/+112
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-08CodeGen: Pass SubtargetInfo to TargetGenInstrInfo constructors (#157337)Matt Arsenault4-3/+10
This will make it possible for tablegen to make subtarget dependent decisions without adding new arguments to every target. --------- Co-authored-by: Sergei Barannikov <barannikov88@gmail.com>
2025-09-05[DirectX] Add isinf f16 emulation for SM6.8 and lower (#156932)Farzon Lotfi1-1/+41
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-08-29[DirectX] Make dx.RawBuffer an op that can't be replaced (#154620)Farzon Lotfi1-3/+126
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[DirectX] Removing dxbc RootSignature and RootDescriptor from mcbxdc (#154585)joaosaffran2-4/+4
2025-08-28[DirectX] Validate registers are bound to root signature (#146785)joaosaffran1-11/+36
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[HLSL][DirectX] Remove uniformity bit from resource initialization ↵Helena Kotas2-5/+13
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-26[NFC][DirectX] Fix build failure (#155441)Rahul Joshi1-0/+1
Add `BinaryFormat` to `LINK_COMPONENTS` to fix the following linker error: ``` ld.lld: error: undefined symbol: llvm::dxbc::getRootParameterTypes() >>> referenced by DXILRootSignature.cpp >>> lib/Target/DirectX/CMakeFiles/LLVMDirectXCodeGen.dir/DXILRootSignature.cpp.o:(llvm::dxil::RootSignatureAnalysisPrinter::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&)) ld.lld: error: undefined symbol: llvm::dxbc::getShaderVisibility() >>> referenced by DXILRootSignature.cpp >>> lib/Target/DirectX/CMakeFiles/LLVMDirectXCodeGen.dir/DXILRootSignature.cpp.o:(llvm::dxil::RootSignatureAnalysisPrinter::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&)) >>> referenced by DXILRootSignature.cpp >>> lib/Target/DirectX/CMakeFiles/LLVMDirectXCodeGen.dir/DXILRootSignature.cpp.o:(llvm::dxil::RootSignatureAnalysisPrinter::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&)) ``` Root cause: https://github.com/llvm/llvm-project/pull/154249 changed a header-only dependency to a real dependency without noticing that the dependency was missing in CMakeLists.txt
2025-08-26[NFC][DirectX] Fix variable set but not used warning (#155445)Rahul Joshi1-1/+1
2025-08-26[DirectX] Fix the writing of ConstantExpr GEPs to DXIL bitcode (#154446)Deric C.4-10/+27
Fixes #153304 Changes: - When writing `ConstantExpr` GEPs to DXIL bitcode, the bitcode writer will use the old Constant Code `CST_CODE_CE_GEP_OLD = 12` instead of the newer `CST_CODE_CE_GEP = 32` which is interpreted as an undef in DXIL. Additional context: [CST_CODE_CE_GEP = 12 in DXC](https://github.com/microsoft/DirectXShaderCompiler/blob/0c9e75e7e91bb18fab101abc81d399a0296f499e/include/llvm/Bitcode/LLVMBitCodes.h#L187) while the same constant code is labeled [CST_CODE_CE_GEP_OLD in LLVM](https://github.com/llvm/llvm-project/blob/65de318d186c815f43b892aa20b98c50f22ab6fe/llvm/include/llvm/Bitcode/LLVMBitCodes.h#L411) - Modifies the `PointerTypeAnalysis` to be able to analyze pointer-typed constants that appear in the operands of instructions so that the correct type of the `ConstantExpr` GEP is determined and written into the DXIL bitcode. - Adds a `PointerTypeAnalysis` test and dxil-dis test to ensure that the pointer type of `ConstantExpr` GEPs are resolved and `ConstantExpr` GEPs are written to DXIL bitcode correctly In addition, this PR also adds a missing call to `GV.removeDeadConstantUsers()` in the DXILFinalizeLinkage pass, and removes an unnecessary manual removal of a ConstantExpr in the DXILFlattenArrays pass.
2025-08-25[DirectX] Refactor RootSignature Backend to remove `to_underlying` from Root ↵joaosaffran2-24/+23
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-15[DirectX] Add GlobalDCE pass after finalize linkage pass in DirectX backend ↵Kaitlin Peng4-4/+10
(#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-14[DirectX] Add Range Overlap validation (#152229)joaosaffran4-12/+176
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-12[DirectX] Remove lifetime intrinsics and run Dead Store Elimination (#152636)Farzon Lotfi2-2/+25
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-11[HLSL][DirectX] Fix `dot2add` DXIL operation to use float overload (#152781)Kaitlin Peng1-5/+5
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[DirectX] Fix resource binding analysis incorrectly removing duplicates ↵Helena Kotas1-3/+5
(#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-08[DirectX] Update lifetime legalization to account for the removed size ↵Deric C.2-32/+68
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-07Scalarize vector `mad` operations for integer types (#152228)Kaitlin Peng1-0/+2
Fixes #152220. - Adds `dx_imad` and `dx_umad` to `isTargetIntrinsicTriviallyScalarizable` - Adds tests that confirm the intrinsic is now scalarizing
2025-08-06[DirectX] ForwardHandle needs to check if globals were stored on allocas ↵Farzon Lotfi1-2/+35
(#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-04[llvm] Use llvm::iterator_range::empty (NFC) (#151905)Kazu Hirata1-1/+1
2025-08-02MCAsmBackend::applyFixup: Change `Data` to indicate the relocated locationFangrui Song1-2/+1
`Data` now references the first byte of the fixup offset within the current fragment. MCAssembler::layout asserts that the fixup offset is within either the fixed-size content or the optional variable-size tail, as this is the most the generic code can validate without knowing the target-specific fixup size. Many backends applyFixup assert ``` assert(Offset + Size <= F.getSize() && "Invalid fixup offset!"); ``` This refactoring allows a subsequent change to move the fixed-size content outside of MCSection::ContentStorage, fixing the -fsanitize=pointer-overflow issue of #150846 Pull Request: https://github.com/llvm/llvm-project/pull/151724
2025-07-31[DirectX] Error handling improve in root signature metadata Parser (#149232)joaosaffran1-11/+15
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-24[DirectX] Add support for vector type checking in DXIL Shader Flag Analysis ↵Deric C.1-7/+8
(#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[DirectX] Fix crash in passes when building with ↵Farzon Lotfi2-45/+55
LLVM_ENABLE_EXPENSIVE_CHECKS (#150483) fixes #148681 fixes #148680 For the scalarizer pass we just need to indicate that scalarization took place, I used the logic for knowing when to eraseFromParent to indicate this. For the DXILLegalizePass the new `legalizeScalarLoadStoreOnArrays` did not use `ToRemove` which means our uses of !ToRemove.empty(); was no longer correct. This meant each legalization now needed a means of indicated if a change was maded. For DXILResourceAccess.cpp the `Changed` bool was never set to true. So removed it and replaced it with `!Resources.empty();` since we only call `replaceAccess` if we have items in Resources.
2025-07-24[DirectX] Do not flatten GEP chains for unsupported types (#150484)Deric C.1-2/+7
Fixes #150463 by not processing GEPs for unsupported types such as structs in the DXILFlattenArrays pass.
2025-07-23[DirectX] Moving Root Signature Metadata Parsing in to Shared Root Signature ↵joaosaffran2-474/+8
Metadata lib (#149221) This PR, moves the existing Root Signature Metadata Parsing logic used in `DXILRootSignature` to the common library used by both frontend and backend. Closes: [#145942](https://github.com/llvm/llvm-project/issues/145942) --------- Co-authored-by: joaosaffran <joao.saffran@microsoft.com>
2025-07-23[DirectX] Support ConstExpr GEPs (#150082)Farzon Lotfi1-17/+29
- 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-22[DirectX] Legalize `llvm.lifetime.*` intrinsics in EmbedDXILPass (#150100)Deric C.2-1/+58
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-21Revert "[DirectX] Legalize lifetime intrinsics for DXIL" (#149883)Deric C.3-56/+5
Reverts llvm/llvm-project#148003 to fix a DirectX backend build breakage due to #149310
2025-07-21Revert "Revert "[DirectX] Lower `llvm.lifetime.*` intrinsics to stores when ↵Deric C.1-14/+55
DXIL version is lower than 1.6 (#147432)"" (#149882) Reverts llvm/llvm-project#149874 Reverted the wrong PR by mistake.
2025-07-21Revert "[DirectX] Lower `llvm.lifetime.*` intrinsics to stores when DXIL ↵Deric C.1-55/+14
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-17[DirectX] Fix GEP flattening with 0-indexed GEPs on global variables (#149211)Deric C.1-0/+10
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[DirectX] Add a GEP to scalar load/store on globals and remove incorrect ↵Deric C.1-14/+22
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-15Emit array GEPs in memcpy/memset legalization (#148886)Deric C.1-11/+11
Fixes #148089
2025-07-15[DirectX] Add a GEP to loads and stores on array allocas (#148059)Deric C.1-2/+42
Fixes #147114 by inserting a GEP between any direct loads and stores on an alloca.
2025-07-15[DirectX] Replace `getNextNonDebugInstruction` with `getNextNode` (#148890)Deric C.1-1/+1
Fixes the DirectX backend build failure due to #144383
2025-07-14[DirectX] Move the scalarizer pass to before dxil-flatten-arrays (#146800)Deric C.2-2/+7
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[DirectX] Simplify and correct the flattening of GEPs in DXILFlattenArrays ↵Deric C.1-147/+151
(#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-11[DirectX] Legalize lifetime intrinsics for DXIL (#148003)Deric C.3-5/+56
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-10[DirectX][NFC] Refactor `DXILRootSignature` to follow the same pattern as ↵joaosaffran3-22/+46
other analysis (#146783) When implementing #146785, notice `DXILRootSignature` had some design changes that made it harder to integrate with other analysis. This change refactors `DXILRootSignature` to solve this issue. --------- Co-authored-by: joaosaffran <joao.saffran@microsoft.com>
2025-07-09[DirectX] Add missing verifications during `validate` of `DXILRootSignature` ↵Finn Plummer1-2/+6
(#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-08[DirectX] Lower `llvm.lifetime.*` intrinsics to stores when DXIL version is ↵Deric C.1-14/+55
lower than 1.6 (#147432) Fixes #147394 References DXC for the implementation logic: https://github.com/microsoft/DirectXShaderCompiler/blob/d751c827ed3b61e87fdf57d0f424cb2d7af30cd0/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.