The clang-12 warning is:
error: fallthrough annotation in unreachable code
[-Werror,-Wimplicit-fallthrough]
These LLVM_C_FALLTHROUGH were originally added to silence GCC warnings,
but the GCC PR validation build is has succeeded, so it looks like they
are not needed.
(cherry picked from commit eb4cec4ad1)
CP of main PR (#6053), regression caused by main PR
https://github.com/microsoft/DirectXShaderCompiler/pull/6033
The misplacement of that "return" in DxilDebugInstrumentation.cpp meant
that a thread would continue to the following call to
addStepDebugEntryValue, even if pix_dxil::PixDxilReg::FromInst had
failed (i.e. returned false), which means that RegNum is not valid
(although initialized to 0).
This meant that PIX was instrumenting a bunch of void-return DXIL
instructions that it shouldn't have.
Didn't think to test that it WASN'T instrumenting instructions, but
herein is added a test to do just that.
(cherry picked from commit 71afbcc7cf)
The IsNormal tests required an addition to the testing framework
provided by ShaderOpTest.cpp, known as the MakeShaderReplacementCallback
function. This function takes a shader, compiles it to DXIL,
disassembles it into a string, replaces anything specified in the
function parameters, and reassembles the shader back into a dxil
container. The problem with the initial implementation was that after
disassembling the shader, the signature applied to the shader on the
compile step would be lost.
This PR adds a validation / signing step right after assembling the
shader to ensure the new DXIL container has a signature. This will
prevent problems with calling CreateComputePipelineState due to a
missing signature.
Verified that this fails when disabling experimental mode, and passes
only when dxil.dll is available.
Fixes https://github.com/microsoft/DirectXShaderCompiler/issues/5337
(cherry picked from commit
3974b57d12)
From a customer bug report, the previous code would skip over a
DISubProgram scope if that scope was contained in a DINamespace (as in
the first test case herein, wherein an include file is enclosed in a
namespace). This would result in DXIL being attributed to the includer
file instead of the included file.
(cherry picked from commit 5adc7bcf67)
Add `-opt-disable sink` to HelperLaneTest shader compilation to prevent
sinking of `ddx_fine`/`ddy_fine` intrinsics into flow control.
Separate issue has been filed to track down the root of the problem:
#5744: Intrinsics ddx_fine/ddy_fine should not be allowed to sink into
flow control
Improve output of DXC test runs:
- Add `-lit-verbose` option to `hctbuild` to setup lit test runs with
verbose output (`hcttest` will list test names as they run)
- Hide tests that are never supported (there was over 10K of unsupported
tests found by LIT discovery)
- Show warnings about non-essential tools only in LIT debug mode
- Skip over file copying and non-LIT part of `hcttest.cmd` if all
requested tests have already been run
- CMD tests have been move under clang's lit tests; keep the `hcttest
cmd` option for running cmd tests separately
Number of unsupported tests was reduced from 10452 to 1 if spir-v is
enabled, 39 if not. The number of tests that run did not change.
(cherry picked from commit b503da7084)
Lit TAEF files fixes:
- Use filter parameter when enumerating tests. This enables listing of
just the tests that should run, and it also filtering by architecture.
This is crucial for isolating ARM64 and ARM64EC versions of tests that
are in the same test dll.
- Fix verbose parameter - it was not getting applied
- Enable verbose on all tests - the output is shown only when the test
fails
Related to #5489.
(cherry picked from commit 96e13a0e0a)
The comment from the checkin kinda says it all:
// DINamespace has a getScope member (that hides DIScope's) // that
returns a DIScope directly, but if that namespace
// is at file-level scope, it will return nullptr.
(The upshot of this is that you couldn't step into functions within a
namespace in WinPIX's shader debugger)
(cherry picked from commit c2233c6c0a)
HL Intrinsic functions share declarations with those that match group
and function signature, regardless of the original intrinsic name. This
means that intrinsics with differing attributes can be collapsed into
the same HL functions, leading to incorrect attributes for some HL
intrinsics.
This fixes this issue by adding the attributes to the HL operation
mangling, the same way this issue was fixed for the HLWaveSensitive
attribute before.
Fixes#3505
---------
Co-authored-by: Joshua Batista <jbatista@microsoft.com>
(cherry picked from commit d9c07e90e1)
Co-authored-by: Tex Riddell <texr@microsoft.com>
My recent changes to correct AST inaccuracies around `this` objects
caused crashes in debug info generation for `this`. This resolves the
crashes by making the code behave correctly when `this` is a reference.
This has no change to debug info output. The added test case should
verify the same output we've always had, but is an important addition
since this was not tested in our pre-merge testing.
Fixes#5530
Cherry-pick of dc82ed29c9
…shaders (#5499)
Two main themes:
-Add instrumentation to the DXR hit group and miss shader types -Return
a bit more info to the caller (PIX) via output text
(cherry picked from commit 3693755da6)
This fixes a few cases that were missed when I updated `this` objects to
be references. Specifically we were still generating some implicit
`this` cases as pointers, and we were not always correctly looking
through the reference types.
Fixes#4709
Cherry-pick of 871fba1edc
Add any_sampler builtin parameter type. This will match any sampler type
as the select() built-in added with HLSL 2021 requires.
Adds a new built-in overload that takes the any_sampler type and ensures
that the last two arguments and return type match. Many of the changes
were required because we never had to ensure object parameter types
matched nor transmit that type to the return type before. Most of the
changes to MatchArguments in SemaHLSL are addressing new issues this
revealed. Non-basic types can pass the conversion check if they outright
match.
Adds testing to select() and the ternary operator that it supplements
for these usages
Fixes#4673
(cherry picked from commit a6497c3894)
The `vk::counter_binding` binding attribute is defined to only apply to
scalars because until recently arrays of RWStructuredBuffers and the
like could not be arrays. That has changed, so the attribute can apply
to the arrays of RWStructuredBuffers.
Allow new/delete operators to be called before DllMain and allocator
initialization in DxcInitThreadMalloc().
The operators can be called before DllMain from CRT libraries when
static linking is enabled. If that happens, the new/delete operators
will fallback to the standard allocator and use CoTaskMemAlloc/Free
directly instead of CoGetMalloc, Alloc/Free & Release for better perf.
Enables fixing of
[#5163](https://github.com/microsoft/DirectXShaderCompiler/issues/5163)
and
[#5178](https://github.com/microsoft/DirectXShaderCompiler/issues/5178).
Copy SPIRV tests under legal-examples and modify to work with lit.
This is first PR for moving SPIRV test to lit.
The reason to copy instead of moving the tests is to make sure not lost
coverage before all tests switch to lit. And update all tests in one PR
will be a PR with 1000 files.
This is for support adapter option for exec test when using lit.
no_priority is enabled for clang test too.
CMake behavior will be the same except not support adapter option.
Also hcttest cmd will only run cmd test for lit.
getFinalACSBufferCounter currently returns a CounterIdAliasPair. This is
because all cases in the original design could return the entire
counter variable. When using arrays for RWStructuredBuffers, we will
need to be able to return something the represents a portion of the
array that is needed. The best method of doing that is to write reusable
functions that return a SpirvInstruction whose result is a pointer to
the approparite element of the array.
This is then used to allow copying individual counter variables.
It does not handle copying the entire array of counter variables.
This addresses a latent bug in Clang that was fixed _way_ after DXC was
forked. We encounter it in DXC because of the way that we inject AST
bits through the external sema source, but it likely wasn't exposable
through C++.
This change is mostly a back porting of the following upstream LLVM
commits:
llvm-project/73c6a2448f24
llvm-project/f721e0582b15
llvm-project/c601377b2376
llvm-project/4409a83c2935
The end result of this change is that we still lazily instantiate
default arguments, but we do force them to be instantiated during sema
when they are used.
Fixes#5145
This commit adds code to generate counters for single dimensional arrays
of RW,consume, and append structured buffers.
After this commit, the counter can be used if the global resource is
used directly.
This PR aims to accomplish the final step of the task to prevent blobs
compiled with different compiler versions from being linked together.
The same compiler is used to compile both blobs in the test, but the
compilerversion part in the first blob is forcefully changed to conflict
with the compilerversion part within the second blob.
The test detects the correct error message, which mentions the names of
the two libraries that differ, and what their differing versions are
exactly.
The PR aims to resolve this issue:
https://github.com/microsoft/DirectXShaderCompiler/issues/5310
For vector and matrix inputs to WaveActiveAllEqual, the
OpGroupNonuniformAllEqual instruction must be applied on each element of
the vector or matrix, and then have the results combined into a vector
or matrix of bools. We make that change in this PR.
Fixes#5426
When linking to library with a list of `-exports`, the linker erases
functions that are not exported assuming they are no longer used. This
assumption is not correct when the function is a constructor for a
global variable. This change fixes the crash by first checking whether
the function still has uses before erasing.
This change adds a regression test with a non-trivially removable global
variable constructor that would crash without this change.
Add LLVMHLSL dependency to LLVMIPO and LLVMScalarOpts. Remove
passprinters from LLVMHLSL to avoid cycle.
This is to fix link error found when trying to enable clang_cc1.
Add macro DXC_DISABLE_ALLOCATOR_OVERRIDES which, if defined, will use
the default CRT allocator for new/delete and malloc/realloc/free.
We need this on Chrome for our GN build of DXC, because our component
builds use libc++as a shared library, and we end up with mismatched
new/delete calls between libc++ and these custom overrides.
---------
Co-authored-by: Chris Bieneman <cbieneman@microsoft.com>
Updates the submodules, and disables validation on two tests. The SPIR-V
is invalid, and spir-val just started checking it. Since we have been
generating this code for a while, I do not see the need to modify the
generated code immediatly.
When generating debug instructions for a function, each one is linked to
its scope.
In case of member functions, this scope is the class.
When declaring a class, all its member, including functions must be
declared.
This cycle requires a forward reference, which is allowed by the debug
instruction spec, but not by parents: NonSemantic & SPIR-V specs. This
is a spec issue we have to fix. In the meantime, we decided to emit a
warning, and generate slightly worse debug instructions.
Context: https://github.com/KhronosGroup/SPIRV-Registry/issues/203
---------
Signed-off-by: Nathan Gauër <brioche@google.com>
This is the first commit in a series that will enable array of
RW, consume, and append Structured buffers. This commit removes the
error when one is used on its own.
There will be a failure if a counter variable is needed.
This is the first PR is a series that will slowly enable different
features for arrays of RWStructuredBuffers. To see the general direction
the changes will go see
https://github.com/microsoft/DirectXShaderCompiler/pull/5407.
Add `-fspv-preserve-interface` CLI option to prevent DCE optimization
pass from compiling out interface variables. It happens if these
variables are unused.
The option may be useful when decompiling SPIR-V back to HLSL.
Personally, I need it to convert DX12 shaders to DX11 ones using
SPIRV-Cross as a tool for converting SPIR-V, produced by DXC, to the old
shader model HLSL.
SPIR-V Tools now have a parameter in `RegisterPerformancePasses()` and
`RegisterLegalizationPasses()` for this. This PR creates a new command
line option in DXC and passes it to the `spvtools::Optimizer`.
Closes#4567
This PR is the first of 2 PRs to prevent libraries of different compiler
versions from linking together. This first PR implements adding the
compiler version information into the Dxil Container itself, to allow
for comparison later. It also adds some basic validation to the new part
in the Dxil Container.
There is an assert that checks if a variable will be placed in the
Function or Private storage class in the spir-v. However, the condition
checked in that assert is inconsistent with the part of the code that
determines which storage class a variable belongs to.
The fix is to make the function `isExternalVar` available outside of
SprivEmitter.cpp, and use that in the assert. Now the same check is used
everywhere.
Fixes#5273
When the SPV_EXT_physical_storage_buffer extensions is used, vulkan can
load raw addresses. For structs loaded through this mecanism, the
offsets must be explicit.
This commit fixes decoration emission by attaching the correct layout
when a struct is loaded using this extensions.
(Specifying a layout different than void forces explicit offsets).
Fixes#5327
---------
Signed-off-by: Nathan Gauër <brioche@google.com>
HLSL/SPIR-V structs have some layout differences due to bitfields being
squashed.
The reconstruction logic was using the AST layout, and not the new
SPIR-V layout, meaning we could generate invalid indices during
extraction/construction.
This PR fixes a potential bug with bitfields, while making the code
reusable.
---------
Signed-off-by: Nathan Gauër <brioche@google.com>
We currently do not do anything to determine the correct type for
variables with a literal type. This leads to type mismatches. In this
commit, I propagate the type the result of the load to the variable that
is loaded. This makes sure that the load is correct.
Fixes#5319
The SPIR-V emitter does not process enum that are declared in class.
This leads to errors in some places it will be used. The fix is to
process the enum in the same place that static variables for an enum are
processed. They are essentially treated like a static variable.
Fixes#5325
For `-Od`/`-O0` compilations, the compiler generates nop instructions in
the form of:
```
@dx.nothing.a = internal constant [1 x i32] zeroinitializer
...
%0 = load i32, i32* getelementptr inbounds ([1 x i32], [1 x i32]* @dx.nothing.a, i32 0, i32 0)
```
This instruction is intended to be a complete no-op, and backends that
recognizes this pattern can turn it into proper hardware specific no-op
instructions for debug purposes.
When linking DXIL libraries, the passes that run end up removing these
nops. This change adds a new pass `DxilReinsertNops` to run at the
beginning of linking to read the `LoadInst`s representing nops and turn
them back into calls of `dx.noop`, before turning back into loads again
at the end.
For a BitCast instruction, the bitwidth of the operand must be the same
as the bitwidth of the result type. That requirement is coded into the
LiteralTypeVisitor, so that we do not get validation errors.
Fixes#5319.
* Add cast after RWByteAddressBuffer atomic compare exchange
The type of the RWByteAddressBuffer is always uint in the SPIR-V
representation. This means that the OpAtomicCompareExchange instruction
must have parameters and a result of type uint. If the original code
used an in for the result, then there is a type mismatch when storing
the value. This is fixed by add a cast when appropriate.
Fixes#4741
Vectors of 1 element are handled as scalars in the spir-v backend
because the element count of [vectors in
spir-v](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#OpTypeVector)
must be at least 2.
This case is not handled in getTypeWithCustomBitwidth and is causing an
assert. The fix is to add code to explicitly handle vectors of size one.
Fixes#5130
This PR adds a new PIX pass that instruments DXR 1.0 shaders
(intersection, any/closest hit and miss). The new pass emits each shader
invocation's [ray system
values](https://microsoft.github.io/DirectX-Specs/d3d/Raytracing.html#system-value-intrinsics)
and DispatchRaysIndex into a UAV that can be read back later. This will
enable new DXR debugging features in PIX.