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 test used the ShaderOpArithTable.xml in a weird way that breaks the
way we map to the HLK test. Use of ShaderOpArithTable.xml in this test
was unnecessary, since it wasn't using more than one row with different
parameter sets to define data-driven test cases.
This change simplifies things and gets rid of this dependency. The
impact is that the shaders are now defined in ShaderOpArith.xml in place
of the dummy shaders that used to be there, instead of
ShaderOpArithTable.xml. The shader text and target are used as defined
from ShaderOpArith.xml, instead of overriding those values with ones
from ShaderOpArithTable.xml.
The only changes to the shader content during the move is in whitespace:
indentation changed to be consistent with target file, trailing
whitespace removed.
It is not easy to pass through the quoted /p options thru python. And
these options are mainly for local debug filter, not for taef FileCheck
tests. Just fall back to taef for these options and treat them like taef
helper.
This is help to allow lit FileCheck shell test.
Except for Output Complete, instructions should not accept handle
arguments that are undefs / zeroinitializers, and should emit a
diagnostic when this happens. This PR adds tests to specifically
exercise the cases where a call instruction :
1. receives an undef argument
2. receives a zeroinitializer argument
3. receives a handle argument that is invalid
And combines these cases with all different types of handle arguments
(resource handle, node handle, and node record handle)
This PR intends to at least implement the first work item in
[#5356](https://github.com/microsoft/DirectXShaderCompiler/issues/5356)
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
This is prepare for allow both taef FileCheck and lit shell FileCheck
exist.
For tests under HLSLFileCheck directory, taef FileCheck will run. Else
py llvm-lit.py will run.
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.
A recent change to libc++ added a 'struct __noop' to the 'std'
namespace. When building with clang-cl using libc++ on Windows, this now
introduces an ambiguity between this std::__noop struct, and the MSVC
__noop intrinsic, in translation units where 'using namespace std;' is
used. This commit replaces these with using clauses for the exact
symbols required in the non-test cpp files.
Last set of cherry picks for reverse iteration, this time enabling
utilities that the ReverseIterator test uses in upstream
---------
Co-authored-by: Tim Shen <timshen91@gmail.com>
Co-authored-by: Duncan P. N. Exon Smith <dexonsmith@apple.com>
Co-authored-by: Justin Lebar <jlebar@google.com>
Co-authored-by: Mehdi Amini <mehdi.amini@apple.com>
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>
A previous PR added this spriv option. The default should have been
false, but in the block that checks for spirv options on a non-spirv
build, the default was set to true. This broke testing on non-spirv
builds.
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.
These are to prepare for a 'zip' change that makes writing iterator
tests a lot easier (and is used heavily in ReverseIterator changes still
to come).
---------
Co-authored-by: Tim Shen <timshen91@gmail.com>
Co-authored-by: Duncan P. N. Exon Smith <dexonsmith@apple.com>
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>
I found other users reporting a similar issue:
https://github.com/actions/deploy-pages/issues/188
The root cause seems to be that the deploy-pages action changed to stop
correcting permissions problems in the upload since it was slowing down
deployment. The recommended fix is to set the permissions before
uploading the artifact.
Let's see if this works.
Fixes#5376
Cherry-picks to get some good changes, specifically in STLExtras
---------
Co-authored-by: Pete Cooper <peter_cooper@apple.com>
Co-authored-by: Duncan P. N. Exon Smith <dexonsmith@apple.com>
A recent change from a recent PR includes changes to how the MDVals data
structure inside of EmitDxilFunctionProps gets elements (push_back
instead of index assignment).
However, there was no accompanying test for these changes, because
HLSLFileCheck\hlsl\workgraph\called_function_arg_nodeoutput.hlsl
exercised this code path and failed without the MDVals changes.
This PR adds some extra context to the above test so that the extra
purpose the above test serves isn't lost with time.
The test passes with the MDVals pushback changes, and fails with the
original valIdx index assignments.
This is used set a path that lit will use to write out an xml file
containing the test results.
I had tried to reuse the existing `-dxc-cmake-extra-args` flag to set
the output, but I ran into a lot of problems getting the arg value to
parse correctly since it has embedded `=` signs that cmd treats as a
command line separator the same as a space (we need to pass a value like
`-DLLVM_LIT_ARGS=--xunit-xml-output=log.xml`). No combination of quotes
and backslashes could get the arg value passed through correctly, so I
opted for the direct route taken in this PR.
The macro LLVM_ENABLE_ABI_BREAKING_CHECKS is moved to a new header
abi-breaking.h, from llvm-config.h. Only headers that are using the
macro are including this new header.
LLVM will define a symbol, either EnableABIBreakingChecks or
DisableABIBreakingChecks depending on the configuration setting for
LLVM_ABI_BREAKING_CHECKS.
The abi-breaking.h header will add weak references to these symbols in
every clients that includes this header. This should ensure that a
mismatch triggers a link failure (or a load time failure for DSO).
On MSVC, the pragma "detect_mismatch" is used instead.
Differential Revision: https://reviews.llvm.org/D26876
llvm-svn: 288082
Co-authored-by: Mehdi Amini <mehdi.amini@apple.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
This change introduces three new issue templates for DXC. The three
issue templates are:
* feature_request - Issues filed with this template will get
automatically tagged with the `enhancement` label
* bug_report - Issues filed with this template will get automatically
get tagged with the `bug` label
* bug_report_spirv - Issues filed with this template will get
automatically tagged with the `bug` and `spirv` labels
The bug_report and bug_report_spirv templates are otherwise identical,
but could diverge to better meet the needs of the supporting teams.
Fixes#4975.
Continuing work from
https://github.com/microsoft/DirectXShaderCompiler/pull/5329
Another 2 cherry picks. Bit bigger this time, but no changes required
apart from the free->delete change as before
---------
Co-authored-by: Matthias Braun <matze@braunis.de>
Co-authored-by: Benjamin Kramer <benny.kra@googlemail.com>
There are a number of changes required to get ReverseIterator support
into DXC. Rather than attempting to do it all as one large PR, it makes
more sense to break it up into smaller PRs of 2-3 changes.
These first two are just some small refactoring in the SmallPtrSet
classes and should not change any behavior.
There was one small change in the DXC codebase that was necessary to
bring forward which deviates from the original cherry-pick slightly
(will mark it in a comment).
---------
Co-authored-by: Matthias Braun <matze@braunis.de>
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.