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

4149 Коммитов

Автор SHA1 Сообщение Дата
Greg Roth 2b7e144030
Indicate extra metadata with unknown nodeio tag (#5711)
When unrecognized metadata is encountered, it needs to be recorded so
that validation will fail. Additionally, this removes the assert that
was there so that the code can be tested. Asserts for code that can be
encountered through potential input isn't ideal anyway.

Adds testing for the same which involves introducing dxv testing into
the llvm test directory requiring enabling .ll tests for that
subdirectory and enabling lit to understand %dxv.

Incidentally fixes some comments in unrelated workgraph tests that had
outdated values for some of the metadata that might lead to confusion

Fixes #5609
2023-09-21 15:08:05 -07:00
Xiang Li 2325bc539c
Add SampleCmpBias and SampleCmpGrad (#5716)
1. Add DXIL opcode for SampleCmpBias and SampleCmpGrad.
Merged from https://github.com/microsoft/DirectXShaderCompiler/pull/5562

2. Add hlsl intrinsic for  SampleCmpBias and SampleCmpGrad.
3. Lower the intrinsic to DXIL.

This is for https://github.com/microsoft/hlsl-specs/issues/30
Fixes #5560

---------

Co-authored-by: Greg Roth <grroth@microsoft.com>
2023-09-20 20:31:55 -04:00
Chris B a1bc696553
[NFC] Merge clang-format into 6.8 staging (#5752)
This merges the clang-formatting change into the 6.8 staging branch and
formats the 6.8 sources appropriately.
2023-09-20 12:47:34 -05:00
Chris Bieneman 2169fc1c27 Merge remote-tracking branch 'origin/main' into cbieneman/clang-format-6.8 2023-09-19 09:37:40 -05:00
Chris Bieneman 325096a001 Merge commit 'd949f78f69c0620fdba7320c2014424f4ecdd14f' into cbieneman/clang-format-6.8 2023-09-19 09:35:16 -05:00
Chris B 37ed613864
[NFC] Clang-format DXC sources (#5602)
This change applies clang-format to all of the sources added in DXC that
were not part of the original LLVM/Clang 3.7 release when DXC forked.
This provides consistent code formatting across the codebase.

Fixes #5591.
2023-09-19 07:49:22 -05:00
Greg Roth eb252f0f33
Merge branch 'main' into 'staging-sm-6.8' (#5741)
Conflicts mostly to do with removing SAL annotations

---------

Signed-off-by: Nathan Gauër <brioche@google.com>
Co-authored-by: Helena Kotas <hekotas@microsoft.com>
Co-authored-by: Xiang Li <python3kgae@outlook.com>
Co-authored-by: Chris B <cbieneman@microsoft.com>
Co-authored-by: Justin Bogner <mail@justinbogner.com>
Co-authored-by: Steven Perron <stevenperron@google.com>
Co-authored-by: Cassandra Beckley <cbeckley@google.com>
Co-authored-by: Natalie Chouinard <1953083+sudonatalie@users.noreply.github.com>
Co-authored-by: Jeff Noyle <jeffno@microsoft.com>
Co-authored-by: Nathan Gauër <brioche@google.com>
Co-authored-by: Tex Riddell <texr@microsoft.com>
Co-authored-by: r-a-sattarov <51679282+r-a-sattarov@users.noreply.github.com>
Co-authored-by: David Peixotto <davpeix@microsoft.com>
Co-authored-by: Joshua Batista <jbatista@microsoft.com>
Co-authored-by: Antonio Maiorano <amaiorano@google.com>
Co-authored-by: Minmin Gong <gongminmin@msn.com>
2023-09-18 22:01:12 -07:00
Chris B d949f78f69
Revert "Add clang-format checker GitHub action." (#5746)
Reverts microsoft/DirectXShaderCompiler#5617
2023-09-18 21:21:30 -05:00
Chris B 2431f3f0a5
[NFC] Integrate clang-format to hctgen (#5732)
This integrates formatting generated sources with clang-format with the
hctgen generation process.

This change makes a few small adjustments to how the build-time header
generation works. This change, disables automated build-time generation
for C++ sources if you don't have clang-format available on your system.

CMake can automatically detect clang-format installed as part of Visual
Studio, or based on your PATH. You can also explicitly set
`CLANG_FORMAT_EXE` when configuring to manually override. **Developers
on macOS** will need to install clang-format manually and place it on
their path to generate DXC's generated sources.

If clang-format cannot be found and `HLSL_COPY_GENERATED_SOURCES` is On
a fatal error will be reported at configuration time.

This change _does not_ make clang-format a requirement to build DXC, but
it does make it a requirement if you are modifying the generated
sources.
2023-09-18 21:10:30 -05:00
Chris B d4b3cb6788
Add clang-format checker GitHub action. (#5617)
This action runs clang-format-diff on the difference between the head
and the merge base to identify introductions of clang-format violtions
in changed code.
2023-09-18 21:09:59 -05:00
Greg Roth 88c5b416c4
Remove unneeded Sema equal param special case (#5734)
This was added to address a special case where OutputComplete was
expecting a templated type, but got the wrong one and gave an unhelpful
"no matching function" error instead of the error more specific to the
requirements of OutputComplete.

Since OutputComplete no longer takes this as a parameter and is instead
a method of the object, the hack is not needed.

Also restores testing for this by `node_emptynodeinput` in
tools/clang/test/HLSL/workgraph/outputcomplete_unsupported_nodeio.hlsl
```hlsl
[Shader("node")]
[NodeLaunch("Coalescing")]
void node_emptynodeinput([MaxRecords(5)] EmptyNodeInput emptyNodeInput)
{
  emptyNodeInput.OutputComplete(); // expected-error {{no member named 'OutputComplete' in 'EmptyNodeInput'}}
}
```


part of #5364
2023-09-18 16:46:08 -07:00
Greg Roth 4d132f95ff
[lit] allow for spaces in taef commands (#5720)
The way taef tests were gathered and executed previously flattened the
list of arguments to a string. This allowed the weird /select: flag to
work correctly, but if any of the arguments had spaces, they were
misinterpretted having lost the implicit quotes around each.

By removing the flattening, putting a space between the flag and the
argument for /select: and removing the explicit quotes around that
argument, the command executes properly whether there are spaces or not

Additionally added a way to detect when these commands failed since they
were silently failing and skipping a large swath of testing when spaces
were present.

Fixes #5719
2023-09-18 19:58:04 +00:00
Helena Kotas 3e9e771e15
WaveMatrix tests cleanup (#5724)
- Rename `Placeholder*` functions
- Rename `expectedMatrices`/`expectedLeftCols`/`expectedRightRows`
variables to `matrices`/`leftCols`/`rightRow` when they are used for
both the initial and the expected values
- Mark test as skipped when it is disabled by external TAEF parameter
- hide debugging-only `PrintMat` function under `#ifndef NDEBUG`

Fixes
[#5371](https://github.com/microsoft/DirectXShaderCompiler/issues/5371)
2023-09-18 10:35:17 -07:00
Tex Riddell 199333bd14
[lit][SPIRV] convert error check shaders to lit FileCheck test (#5702)
warning check shaders are converted too.

Add not 2>&1 for error check shaders.
Only 2>&1 for warning check shaders.
2023-09-18 10:34:46 -07:00
Antonio Maiorano e999412c4a
Fix ASAN container-overflow in FunctionTests (#5731)
Test was writing to a std::vector reserved buffer with a size of 0. Fix
by resizing the buffer.
2023-09-18 10:32:28 -04:00
Antonio Maiorano 906fc46f52
Fix ASAN memory leak in FileChecker (#5718)
AllocVFSIncludeHandler was returning it's IUnknown object by Detach()ing
from a CComPtr, then assiging to CComPtr. This would result in the
object have a ref count of 2, and when the second CComPtr destructed, it
would go down to 1, and leak memory.

The fix is to return the object as a CComPtr; however, with Clang, this
failed to compile because it finds no conversion from a CComPtr of child
class type to a CComPtr of base class type. This compiles fine on MSVC,
so I debugged it, and realized that MSVC compiles this as first a
conversion to T*, then a constructor call. I suspect MSVC is wrong here.
In any case, this change adds a template conversion constructor to
CComPtr, very much like the existing template assignment operator.
2023-09-18 10:32:04 -04:00
Antonio Maiorano 08215dab0b
Fix ASAN stack-use-after-scope in unit test (#5730)
When StackOption is destructed, it reads the its ArgStr member, which in
this test is set to local variable ArgString. Since ArgString was
declared after TestOption, it would be destructed first, and thus result
in a stack-use-after-scope. Fix this by swapping the declaration order.
2023-09-18 10:31:48 -04:00
Antonio Maiorano 29460c54ad
Fix ASAN alloc-dealloc-mismatch (operator new vs free) (#5728)
The MallocAllocator originally used malloc and free, but this was
changed for DXC to use operator new/delete. The test called free() on
the object that is now allocated with new. Fixed the test by passing in
the allocator explicitly, and destroying the object using it.
2023-09-18 10:31:39 -04:00
Antonio Maiorano 0163da3757
Fix memory leak on DxcCreateBlob of empty string (#5725)
In the case of an empty string, DxcCreateBlob does not take ownership of
the input data object, and ends up leaking it.

Example ASAN error:
```
./bin/dxc -E main -T lib_6_3 /home/amaiorano/src/external/DirectXShaderCompiler/tools/clang/test/DXC/show-includes.hlsl

==524344==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 1 byte(s) in 1 object(s) allocated from:
...
```
2023-09-18 10:27:17 -04:00
Antonio Maiorano 7bd186f48c
Fix memory leaks of debug name in a couple of tests (#5727)
A few tests were calling CompileWithDebug, passing in pointer that gets
set to the debug name, but was never freed.
2023-09-18 09:24:38 -04:00
Greg Roth bfa397ac9b
StringSwitch CodeGen/HLops string->enums (#5735)
A number of places had if else chains to convert strings into enum
values. This unapoligetically uses StringSwitch for all of them and
moves one that already did in line with the rest for consistency

In HLOperations, There was a complex cascading swith on characters that
was error prone. Using StringSwitch is easily maintainable and
reasonably performant

This also required submitting only the substring relevant to the
operation group as before it only attended to the first few characters

part of #5364
2023-09-15 14:26:32 -07:00
Joshua Batista e7bbd882e0
Remove node + compute validation exemption in sema (#5726)
#5679 removed some code in the CodeGen pass that allowed node + compute,
and some tests were updated.
In this follow up PR, code is changed in the Sema pass that used to
allow validation exemptions for node + compute. The appropriate tests
were updated. This is an improvement to #5601

Fixes #5601
2023-09-15 12:54:41 -07:00
Xiang Li 549030f977
[lit] set clang_taef_site_config in llvm-lit.py (#5717)
This will make it possible to run taef test from llvm-lit.py directly
 without set clang_taef_site_config and clang_taef_exec_site_config.
2023-09-14 23:43:43 +00:00
Joshua Batista a79a8a0726
Add profile target shader attribute to entry point function declaration (#5627)
This PR will automatically add the target profile shader stage as a
HLSLShader attribute to the function declaration that represents the
entry point. If the entry point doesn't exist (in the case of library
shaders), then this behavior won't happen.
Fixes #5626
2023-09-14 16:33:38 -07:00
Chris B 7cd613bda7
[NFC] Add missing includes in reflection headers (#5715)
`DxilRuntimeReflection.h` uses `size_t`, which is defined by
`<cstddef>`.

`dxcutil.h` uses `hlsl::SerializeDxilFlags` by value whcih is declared
in `DxilContainer.h`.

`D3DReflectionStrings.h` relies on windows tyoes like `LPCSTR`. It also
includes `D3DReflection.h`, which in turn includes `d3d12shader.h` (from
DirectXHeaders), which relies on basically the whole `WinAdapter.h`.

I've included `WInAdapter.h` in both `D3DReflectionStrings.h` and
`D3DReflection.h` to make both headers indipendently resilient.
2023-09-14 20:37:50 +00:00
Chris B 6159d5890c
[NFC] Fix ubsan failure (#5700)
This variable was never initialized so it was always whatever garbage
bits were left there. It should be defaulted to `false`.
2023-09-14 19:33:19 +00:00
Minmin Gong 3fb1a33b33
Use the correct header for stringstream (#5685)
stringstream is defined in sstream, not strstream. Include the correct
one.
2023-09-14 13:57:32 -05:00
Greg Roth c3b8a14cc3
Require validator ver 1.3 for link without version (#5714)
Require a lesser validator version for linking without version for
RunLinkWithTempReg test in order to allow the test to run on older
validators. 1.3 is the lowest version that supports libraries

Another follow up to #5378
2023-09-14 11:03:46 -07:00
Xiang Li 67fde16627
[CLANG_CL] Fix clang-cl warnings (#5660)
Add -Wno-unused-parameter -Wno-unknown-pragams -Wno-switch which are
enabled for clang in linux build.
Fix
-Wimplicit-fallthrough
-Wconstant-logical-operand (Thanks patch from Chris)
 -Wunused-function
-Wunused-variable
-Wtrigraphs
-Wnonportable-include-path

Still more warnings to be fixed.
2023-09-14 13:25:46 -04:00
Antonio Maiorano 108c346549
Fix asan stack use after return (#5628)
Fix asan use-after-return

In cases where arg 0's template id set to one of
INTRIN_TEMPLATE_FROM_TYPE, INTRIN_TEMPLATE_VARARGS,
or INTRIN_TEMPLATE_FROM_FUNCTION), this code would erroneously index
beyond Template's size.

ASAN helped to catch this error, reporting it as a use-after-return.
2023-09-14 10:04:36 -04:00
Antonio Maiorano c8375d5a3d
Fix asan container-overflow (#5619)
When the reference 'e' to stack top is popped, the call to erase(e)
reads from this now invalid reference. ASAN catches this as a container
overflow. We fix this by taking a copy of the stack top instead.

Note that this was similarly fixed in upstream LLVM as well:
9987d98370
2023-09-14 10:04:26 -04:00
Chris B 3266a87f9a
[NFC] Remove SAL annotations from internal APIs (#5639)
We don't keep these annotations up to date or rely on them, so to
simplify our platform layering and ease code formatting this change
removes all the SAL annotations from internal APIs. This change also
replaces most `_Analysis_Assme_(...)` annotations with `assert(...)`.

One `_Analysis_Assume_` in ParseDecl.cpp needed to be updated because it
was incorrect. The code was `_Analysis_Assume_(assert(name.size() >
sizeof("space"));`. When converted to an `assert` it fired in our test
suite because the sizeof a string literal includes the null terminator,
but the size of a StringRef does not.

A few of the `_Analysis_Assume_` annotations were removed because they
didn't make sense (like the ones inside the `DXASSERT` implementation,
and a few others were removed to avoid introducing additional header or
linkage dependencies.

This change does not introduce any functional or behavioral changes.
2023-09-14 08:59:49 -05:00
Joshua Batista 034ed24f5b
[DCE] Move output complete removal code later to DCE (#5620)
Elimination of incorrect output complete calls was located in an awkward
spot. The code has been moved over to DCE.
Fixes #5363
2023-09-13 13:34:30 -07:00
Jeff Noyle d2882d8530
PIX: Use CA2W in original fashion, to avoid build issue on release branch (#5671)
This should fix a build issue in the 2380 release branch.
2023-09-13 09:08:05 -07:00
Xiang Li dc560add27 [lit][SPIRV] convert error check shaders to lit FileCheck test
Add not 2>&1 for error check shader.
And only 2>&1 for warning check shader.
2023-09-12 21:17:14 -04:00
Xiang Li eb69837c65 [lit][SPIRV] move error check shaders to lit folder.
Warning check shaders are moved too.
2023-09-12 21:16:22 -04:00
Tex Riddell f80b8d6ecd
Fix debug info nondeterminism in SROAGlobalsAndAllocas from staticGVs (#5259)
staticGVs is used to track which globals are static and don't need new
debug info added at a certain point. Some global values are erased
during iteration of the work list, including globals that could be in
this set. This could lead to stale pointers in the set, which could
alias new global values from SROA, nondeterministically causing missing
debug info.

This change removes globals from the set (if present) in each path where
they are deleted. It also skips adding globals to the set (and
MergeGepUse) that have no users in the first place, since these will
just be deleted and have to be removed from the set later.

Fixes #5196.

---------

Co-authored-by: Greg Roth <grroth@microsoft.com>
2023-09-12 18:08:44 -07:00
Xiang Li b6bfe337c2
[lit][SPIRV] convert error check test to lit FileCheck test (#5698)
Add not 2>&1 to convert to lit FileCheck test.
Need one more PR to convert all error check tests.
2023-09-12 21:02:55 -04:00
Joshua Batista 6d26052111
[HCT] Add user defined query functionality (#5555)
This PR aims to add some functionality to hctdb_instrhelp.py to
efficiently search and find specific instructions.
For example, in #5451, a parser needed to be written to parse through
gen_intrin_main.txt to search for any set of instructions that:

1. had at least one function attribute that was "readnone"
2. All had the same return type
3. All had the same argument list (types and length)

This search could've been made much easier if hctdb_instrhelp.py had a
method to search through instructions in a database-like manner.
This PR allows the user to define a query function with which to filter
out dxil instructions in hctdb.py. The instructions can be filtered out
based on function attributes, return type, function name, and the
function argument list. It should allow the user to quickly find
instructions that satisfy any arbitrary requirements.

On the command line, the user may run: `python3 hctdb_instrhelp.py
--query-dxil=<filename-no-extension>`
This command will instruct hctdb_instrhelp.py to run a query using the
inst_query_dxil function defined by the filename argument in the command
line. Alternatively, for hl operations, one can instead use the
--query-hlsl argument, and define a function called inst_query_hlsl in
that file instead.
And then the query functionality of the script will be run, which
applies the user-defined query function to all instructions and outputs
the query results.

Fixes #5556
2023-09-12 16:37:43 -07:00
Joshua Batista 816bc8c03f
Disallow multiple shader attributes from existing on a single declaration (#5679)
There was a recent spec change on work-graphs that disallows the
existence of node + compute attributes on shader declarations. Because
of this old behavior, a lot of code worked around the possibility that 2
shader attributes could exist for one declaration. With this old
behavior disallowed, we no longer need to account for this possibility.
The PR now adds a diagnostic preventing multiple attributes from
existing. It will also change all the tests that worked with shaders
with multiple shader attributes, and either remove them, or update them
so that only one attribute is used.
Fixes #5601
2023-09-12 14:00:06 -07:00
Xiang Li da33b6ec94
[lit][SPIRV] convert error message check shaders to lit FileCheck test (#5691)
Add not 2>&1 to check the error message.
This is only first part. Need more PRs to convert all error check
shaders.
2023-09-12 12:34:00 -04:00
David Peixotto 3b408e51b5
Add outputs to the IDxcResult when linking (#5678)
This change modifies the IDxcLinker::Link api to return outputs via the
IDxcResult interface. We now support getting the following outputs from
the
IDxcResult returned from the call to Link

  DXC_OUT_REFLECTION
  DXC_OUT_SHADER_HASH
  DXC_OUT_ERRORS
  DXC_OUT_ROOT_SIGNATURE

Additionally, the DXC_OUT_OBJECT output will now set its name based on
the `/Fo`
command line flag.

This makes the api more consistent with the Compile output and makes it
easier
to access these outputs without having to crack open the dxil container.

Original patch by @tex3d. Tests added by @dmpots.

---------

Co-authored-by: Tex Riddell <texr@microsoft.com>
2023-09-11 20:56:33 -07:00
r-a-sattarov 9cb80b6cc5
Added e2k support (MCST Elbrus 2000) (#5222)
- Add e2k target to config.guess
- Update config-ix.cmake to support e2k

E2K - this is VLIW/EPIC architecture, like Intel Itanium (IA-64)
architecture.

Ref:
1) https://en.wikipedia.org/wiki/Elbrus_2000
2)
https://lists.gnu.org/archive/html/config-patches/2015-03/msg00000.html
2023-09-11 14:09:48 -07:00
Xiang Li 4f0ace9781
[SPIRV] simplify FileTest. (#5673)
Remove unused method for runFileTest and enable validation for all
tests. This will help code review when convert to lit FileCheck test.
2023-09-11 17:47:45 +00:00
Helena Kotas 67fd9dd84e
Update DXC help default language version (#5677)
The current default language version is 2021.
2023-09-11 09:59:26 -07:00
Nathan Gauër 18328d5105
spirv: remove superfluous test lines. (#5676)
Those are not used as we compile in `-fcgl`.
2023-09-08 16:32:23 +00:00
Xiang Li a9d9e65be8
[NFC] Add dxcutil::ComputeSerializeDxilFlags to share code with linker (#5334)
Add dxcutil::ComputeSerializeDxilFlags to share code with linker

Use refactored ComputeSerializeDxilFlags in DxcCompiler::Compile()

---------

Co-authored-by: Tex Riddell <texr@microsoft.com>
2023-09-08 14:44:22 +00:00
Nathan Gauër 3e7c98a91f
spirv: stop emitting ImageMSArray capability (#5663)
ImageMSArray is only required is OpTypeImage arrayed=1, MS=1 and
sampled=2. This is never the case AFAIK for code emitted from HLSL. No
tests or shaders I knew about required it, so should be OK removing it
from DXC.

---------

Signed-off-by: Nathan Gauër <brioche@google.com>
2023-09-08 09:57:20 -04:00
Natalie Chouinard b7a50ba6d7
[spirv] Fix firstbithigh/low signedness (#5665)
The SPIR-V backend was incorrectly choosing to emit either FindSMsb or
FindUMsb based on whether the result type of the call expression was
signed or unsigned. Since the AST result type was always unsigned (and
wrapped in a cast if necessary), this meant FindSMsb was never
generated. FindSMsB should however be generated when the argument type
is signed. This is indicated by the HLSL intrinsic op code (firstbithigh
for signed and ufirstbithigh for unsigned). The SPIR-V generated now
matches the DXIL generated.

This bug was discovered while investigating #4702, so at the same time
some error checking is added to make unimplemented cases explicit.
Because the underlying GLSL.std.450 instructions FindSMsb, FindUMsb and
FindILsB are currently limited to 32-bit width components, we now emit
an error messages when this would otherwise result in invalid SPIR-V.
2023-09-08 09:09:34 -04:00
Steven Perron 087773779c
Handle log10 with float16_t parameter (#5659)
When the spirv backend sees the log10 intrinsic, it will generate a
multiple with a constant. The type of that constant is hard coded to be
a float. However, if the type of the parameter is not a float, there is
a type mismatch on the multiple instruction.

This commit changes that so the type of the contanst matches the scalar
type of the parameter. That is, it will be a type T if the parameter is
type T, a vector of type T, or a matrix of type T.

Fixes #5608
2023-09-07 16:57:53 -04:00