Граф коммитов

4149 Коммитов

Автор SHA1 Сообщение Дата
Chris B 573b652210
Instantiate argument default parameters (#5443)
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
2023-07-24 10:19:07 -05:00
Tex Riddell 566adca5eb
[lit] Merge git usr bin changes to release branch (#5442)
This will avoid test fail when forget to add git usr bin to PATH.
If git usr bin already on PATH, it will just use it.

Port from

0f1f13fcb1
2023-07-21 20:21:33 -07:00
Tex Riddell 29823abbcd
WaveMatrix test data refactor: remove ShaderOpArithTable.xml dependency (#5336)
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.
2023-07-21 19:20:17 -07:00
Xiang Li 051b05cc5c
[lit] fall back to taef for taef only test options (#5404)
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.
2023-07-21 21:48:01 -04:00
Joshua Batista 9468120e6c
[Validation] Prevent instructions that accept handle arguments from accepting malformed handle arguments (#5399)
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)
2023-07-21 18:06:03 -07:00
Steven Perron 15c8723458
Generate counter for arrays of RW, consume, and append structured buffers. (#5415)
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.
2023-07-20 23:48:13 -07:00
Xiang Li fed08e5c0d [lit] allow find git usr bin in path directly. (#5385)
This is for case where git usr bin is not in winreg.
2023-07-20 14:56:04 -04:00
Xiang Li 2f58557f49 [lit] Add git usr bin to path automatically. (#5355)
This will avoid test fail when forget to add git usr bin to PATH.

Port from
0f1f13fcb1
2023-07-20 14:55:53 -04:00
Joshua Batista af0b809140
Error out if two blobs compiled with different compiler versions are linked. (#5361)
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
2023-07-20 11:16:16 -07:00
Xiang Li 1174c88837
[lit] allow hcttest file-check to run on lit. (#5393)
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.
2023-07-20 13:49:07 -04:00
Diego Novillo 7305c8bf42
Update SPIRV-Tools and SPIRV-Headers to current release candidate versions (#5439)
Taken from
http://sheets/1r4wC2cge0Cjru1ShjGqZRmUNEmo_FRZHCX-BdeemXsU#gid=1167313977
2023-07-20 18:24:29 +02:00
Steven Perron 9021cae50b
Expand WaveActiveAllEqual with vector and matrix arguments. (#5428)
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
2023-07-19 12:58:44 -07:00
Adam Yang 325ae8efbf
Fixed a crash when linker erases functions that still have users. (#5437)
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.
2023-07-19 11:48:57 -07:00
Xiang Li cdee4461c9
[Build] cleanup build dependency (#5432)
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.
2023-07-19 01:06:31 -04:00
Antonio Maiorano 5d796bf3f7
Remove 'using namespace std' to fix __noop ambiguity with latest libc++ (#5406)
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.
2023-07-18 11:05:07 -04:00
Jesse Natalie f09905d0ec
Fix include in DxilNodeProps.h (#5433)
Globals.h defines things like `IFC` macros that leak into callers. All
that was really needed here was a definition of `std::string`.
2023-07-18 07:29:29 -07:00
Brian Favela 32379dd559
Add zip range adapter and other utility functions (#5425)
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>
2023-07-17 17:58:45 -04:00
Antonio Maiorano 44f8833938
Add macro to disable usage of allocator overrides (#5296)
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>
2023-07-17 15:27:30 -04:00
Steven Perron 1501181418
Update spirv-headers and spirv-tools (#5419)
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.
2023-07-17 10:28:48 -07:00
Nathan Gauër f4dcc6e296
SPIRV: don't generate invalid debug instructions (#5397)
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>
2023-07-17 12:40:19 +00:00
Tex Riddell 68c7d38d42
Fix test break on non-spirv build (#5422)
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.
2023-07-14 21:56:51 +00:00
Steven Perron 34b47c2c8b
Allow arrays of RW, consume, and append structured buffers. (#5405)
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.
2023-07-13 17:23:36 +00:00
Brian Favela a86e3f3399
More cherry picks for testing changes (iterator related) (#5403)
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>
2023-07-11 12:28:41 -04:00
Kirill Kozlov 38fcd6f741
[SPIRV] Add option to preserve interface variables (#5400)
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
2023-07-11 12:20:58 +02:00
Joshua Batista 6287d513d1
Error on diff blob versions part 1 (#5378)
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.
2023-07-10 11:01:06 -07:00
Steven Perron e931c944ce
Make assert consistent with the code (#5382)
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
2023-07-07 11:50:09 -07:00
Nathan Gauër 6289ba317e
[SPIRV] Emit Offset decoration for PhysicalStorage structs (#5392)
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>
2023-07-07 17:17:51 +00:00
Nathan Gauër dcf754c264
Fix SPIRV struct reconstruction with bitfields (#5390)
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>
2023-07-07 11:57:23 -04:00
Chris B 8711ee6e44
Update build artifact permissions (#5387)
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
2023-07-05 16:05:24 +00:00
Nathan Gauër 2096d1b805
Revert "[SPIR-V] add support for extension KHR_fragment_shading_barycentric (SV_Barycentrics)" (#5384)
Reverts microsoft/DirectXShaderCompiler#4638
This PR causes multiples issues (#5326, #5342, #5270). Reverting, will
need more testing.

Fixed #5270
2023-07-04 09:39:23 -04:00
Brian Favela 4c9b6a5b19
Few more cherry-picks to prep for reverse iterator changes (#5386)
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>
2023-07-03 17:25:57 -04:00
Xiang Li 1775fffc0b
[lit] allow find git usr bin in path directly. (#5385)
This is for case where git usr bin is not in winreg.
2023-07-03 13:31:29 -04:00
Joshua Batista 6b18a6ab84
[NFC] Add more information on testing MDVals insertion in EmitDxilFunctionProps (#5335)
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.
2023-07-01 00:42:29 +00:00
David Peixotto a64a7682cf
Add -lit-xml-output-path option to hctbuild.cmd (#5381)
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.
2023-06-30 19:53:28 +00:00
Brian Favela 5f931c3f14
Add link-time detection of LLVM_ABI_BREAKING_CHECKS mismatch (#5380)
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>
2023-06-30 13:15:17 -04:00
Steven Perron bf2d6c073a
Propagate literal types through loads. (#5339)
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
2023-06-30 11:42:09 +02:00
Steven Perron 8d9daa25d4
Process enums in class (#5330)
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
2023-06-30 10:57:14 +02:00
Xiang Li 29b55d138c
[lit] Add git usr bin to path automatically. (#5355)
This will avoid test fail when forget to add git usr bin to PATH.

Port from
0f1f13fcb1
2023-06-29 17:20:35 -04:00
Chris B d599cd98b0
Introduce issue templates (#4984)
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.
2023-06-29 17:23:54 +00:00
Brian Favela c462faa844
[NFC] More cherry picks in preparation of ReverseIterator changes (#5340)
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>
2023-06-28 21:50:32 +00:00
Xiang Li a35f1fa350
Make HLSLOptions getter methods const (#5333)
Make HLSLOptions getter methods const

Co-authored-by: Tex Riddell <texr@microsoft.com>
2023-06-28 14:44:11 -07:00
Chris B b28885f7d0
[NFC] Fix RUN line in SPIR-V test (#5344)
This was introduced from an out-of-date PR.
2023-06-28 20:11:12 +00:00
Jaebaek Seo 1d2bc2c05f
[spirv] emit valid stride for array of empty struct (#3885)
Fixes #3101
2023-06-28 11:02:53 -04:00
Xiang Li a65635b0ea
[lit] Pass the USERPROFILE variable through on Windows (#5331)
This is to fix the failure when running hcttest inside docker image.

Upstream PR is in

9de63b2e05
2023-06-27 19:20:08 +00:00
Brian Favela 3b4ce9d338
[NFC] Cherry-picking some changes to prepare for ReverseIterator support (#5329)
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>
2023-06-27 13:51:11 -04:00
Adam Yang 8e0e56fe9d
Made linker preserve nops for Od. (#5317)
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.
2023-06-28 01:21:29 +08:00
Steven Perron 8f2881e511
Propagate bitwidth for BitCast in LiteralTypeVisitor (#5324)
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.
2023-06-27 14:37:43 +00:00
Jeff Noyle 7a36b7ece5
PIX: don't report modification from DXRInvocationsLog pass for non-DXR-hit libs (#5323)
PIX may well have libs in a state object that have no DXR hit groups.
2023-06-26 11:04:41 -07:00
Jeff Noyle c9b50a588a
WinPIX: File-check test for new DXR invocations log pass (#5322)
A test for the DXR invocations log pass
2023-06-25 08:49:59 -07:00
Jeff Noyle d278bbe538
WinPIX: Shader debug should use UAV 0 always (#5315)
Recent small regression: the WinPIX shader debug pass should always
write to UAV 0 (that's the only one that's correctly setup by WinPIX).
2023-06-23 13:21:26 -07:00