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

3895 Коммитов

Автор SHA1 Сообщение Дата
Xiang Li f3f9a2dec4
[opt] initialize HLSL passes with SetupRegistryPassForHLSL (#5217)
* [opt] initialize HLSL passes with SetupRegistryPassForHLSL

call hlsl::SetupRegistryPassForHLSL in opt to initialize all HLSL/DXIL passes.
This is for enable lit by default where opt test used to test HLSL/DXIL passes.
2023-05-16 13:35:15 -07:00
Brian Favela a6cf6d7c08
Adding test as a copy into currently supported testsuite (for PR #5209) (#5216)
* Adding test as a copy into currently supported testsuite and comment lit runner regarding copied test

* removing erroneous comment
2023-05-15 21:20:06 +00:00
Chris B 2317959500
Enable generating per-directory lit test targets (#5215)
This enables generation of per-directory test targets in non-IDE
generators, and preserves a limited set of targets for IDE generators.
2023-05-15 15:19:21 -05:00
Tex Riddell ccd97acc02
PSV0: Fix GS multi stream out ViewID dependency serialization (#5204)
GetViewIDOutputMask and GetInputToOutputTable take an output index to support multiple stream outputs in geometry shaders.
Previously, these functions would map the same local pointer to a location for serializing or deserializing the dependency bit vectors.
This causes data to overlap and size to be computed based only on the last used stream.

This change fixes this by using an array of pointers for each of these.
Then, a new test verifies output for two streams, which fails without this fix.
2023-05-15 20:18:38 +00:00
Damyan Pepper 5dbe8490e5
Update inline API reference docs for dxcapi.h (#5160)
Documentation comments are now formatted using Doxygen-style markup. Although there's no automated processes in place to generate documentation from this markup, aligning around this style allows for comments that are more readable than xmldoc when viewed as text.
2023-05-15 11:55:27 -07:00
Brian Favela 8330655de7
[GlobalOpt] Sort members of llvm.used deterministically (#5209)
Patch by Jake VanAdrighem!

Summary:
Fix the way we sort the llvm.used and llvm.compiler.used members.

This bug seems to have been introduced in rL183756 through a set of improper casts to GlobalValue*. In subsequent patches this problem was missed and transformed into a getName call on a ConstantExpr.

Reviewers: silvas

Subscribers: silvas, llvm-commits

Differential Revision: http://reviews.llvm.org/D12851

llvm-svn: 248728

Co-authored-by: Sean Silva <chisophugis@gmail.com>
2023-05-15 11:24:25 -04:00
Jeff Noyle 5400a2f022
PIX: Don't run PIX prep passes during variable evaluation (PIX already did that) (#5208)
These passes have already been run by PIX at this point, and running them twice is both a waste and a source of issues: the annotate-with-virtual-registers pass might thereby change virtual register ordinals, which will cause PIX's view of HLSL variables to degrade as the user steps further into a long function.
2023-05-12 16:41:07 -07:00
Xiang Li fdf9074a4f
[enable-lit] Allow file-check when enable-lit (#5201)
Also run exec test separately.

This is help to keep existing workflow after switch to lit.
2023-05-11 08:30:24 -07:00
Xiang Li bf015d2e1a
Fix loss of buffer type info with libraries and linker (#5197)
* Fix loss of buffer type info with libraries and linker

## Fix loss of buffer type info.

When undef, there was no global symbol, thus type-preserving cast was lost,
and undef type for resource would be dx.types.Handle instead.  This would
particularly impact path through higher lib target then linked to a lower
final shader target.

The fix is to use the HLSL type for undef when the GlobalSymbol is undef.

## Copy resource type annotation in linker.

Linker was dropping the resource type annotation for the target module.
Fixed by copying the type annotation to the target after AddResource.

## Check resource type annotation with libs and linking and various targets

These tests check both module metadata and reflection dump.
While IR may be unnecessary given reflection check, it does reveal some
format inconsistencies that should be addressed.

TODO: investigate https://github.com/microsoft/DirectXShaderCompiler/issues/5202
2023-05-10 21:05:14 +00:00
Steven Perron fae8401702
Set the layout rule in processTemplatedLoadFromBuffer (#5192)
* Set the layout rule in processTemplatedLoadFromBuffer

They layout rules for value coming from processTemplatedLoadFromBuffer
are inconsistent, and this is causing problems. This PR changes the
function to return an instruction whose layout rule is Void.

This should remove the inconsistenty.

Fixes #5123

* Add test

The cg.return.memory-layout.hlsl had to be updated because the Byteaddress load no longer has a different layout rule.

* Remove `-Vd` from test
2023-05-10 10:45:11 -04:00
Xiang Li ba1b4cfbdf
Set AddrSpaceCast as unreachable for DXILCounters (#5185)
Set AddrSpaceCast as unreachable for DXILCounters since it should be gone at this point.
2023-05-09 11:02:18 -07:00
Xiang Li 2dd8344cc3
[NFC] remove useless comment in test. (#5188) 2023-05-08 10:02:22 -07:00
Xiang Li 5cadb2589e
Fix reflection on bitfield. (#5142)
* Fix reflection on bitfield.

This is for case where bitfield member lost when reflection.

Save bitfield information in DxilFieldAnnotation.
Then use the information in CShaderReflectionType::Initialize.

Add field for the integer and put bit fields as members of the integer field.
2023-05-05 17:56:32 -07:00
Jesse Natalie 012d48cdd1
Require break-critical-edges to run before reg2mem_hlsl (#5180)
* Require break-critical-edges to run before reg2mem_hlsl

A DXIL shader containing a loop, where the `phi` node at the
beginning of the loop is re-used outside the loop, does not get
translated correctly by this version of reg2mem. Running critical
edge splitting beforehand resolves the issue.

* Add a test which verifies the fix
2023-04-28 06:37:11 -07:00
Chris B 0eef1830b9
[NFC] Enable -Werror for C sources too (#5021)
This fixes some fallthrough warnings that were appearing in C source
files and enables -Werror for both C and C++ sources.

Additionally, this fixes some GCC warnings and migrates AppVeyor builds
to building with clang-14 to reach agreement between GCC and Clang
about what is valid in C++.
2023-04-25 13:51:21 -05:00
Xiang Li 918673ef5b
[enable-lit] use !TEST_CLANG! to get updated result (#5170)
This is for enable lit by default.
It fix issue when running single test instead of all test under lit.
%TEST_CLANG% will not get update until out of the if.
2023-04-21 15:36:31 -07:00
Xiang Li 14063a661c
[enable lit] Keep same name for ClangHLSLTests when enable lit (#5167)
* [enable lit] Keep same name for ClangHLSLTests when enable lit

This is for enable lit by default.
It will make sure with/without lit enabled, ClangHLSLTests output dll with same name.

Use ClangHLSLTests because LIT needs GoogleTest binaries to be named that way for test discovery.
2023-04-21 15:27:35 -07:00
Xiang Li 947861e2c0
Fix build error for deprecated function in UCRT. (#5162)
* Fix build error for deprecated function in UCRT.

This is for enable-lit by default.
gtest got link error for missing dup/dup2/close/creat.

* Update comment.

* Mark HLSL Change.
2023-04-20 21:33:50 -04:00
Nathan Gauër 9d89d67fd0
ci: add GCP pipeline files to replace AppVeyor (#5152)
Those files are the required to drive the new GCP pipeline aimed to
replace AppVeyor. As-is, those file have no effect on the repo.
What's needed to add the CI is to setup some repository permissions,
and only then CI will be able to run.

This CI will build x86_64 versions of DXC on both Linux and Windows, run
tests, and allow retrieving build artifacts (same as Appveyor).

Signed-off-by: Nathan Gauër <brioche@google.com>
2023-04-20 14:30:52 -07:00
Tex Riddell 5874b72e81
Support dependent template args in HLSL Object templates (#5140)
HLSL objects have a special hook for validating template arguments.
Previously, this didn't handle dependent arguments.
This change skips dependent arguments, which will be checked once they are concrete.
2023-04-18 18:12:14 +00:00
Chris B 39e13951cc
[NFC] Delete duplicated tests (#5155)
These tests are just copies of HLSLFileCheck/shader_targets/library/lib_no_alias.hlsl testing the exact same output, so they provide no unique value.
2023-04-18 10:09:37 -05:00
Chris B 4f5e4d1b74
Setup `install-distribution` target for DXC (#5154)
* [CMake] Update distribution build for DXC

Building off the LLVM 3.9 changes, this gets the `install-distribution`
target working for DXC with preset parameters that configure the
normal distribution. It also enables the DXC distribution to be built
through Visual Studio builds since DXC has a limited number of
components so it doesn't suffer from the IDE issues that upstream
LLVM & Clang do.

The `hctbuild` tooling has been updated to set a default install
prefix relative to the build directory, and allow overriding with a flag.

Cherry-picked commit details below:

From c90e12fe9fd7eb9fd7b342e7ac0cec971dd3e4db Mon Sep 17 00:00:00 2001
From: Chris Bieneman <beanz@apple.com>
Date: Tue, 23 Feb 2016 20:33:53 +0000
Subject: [PATCH] [CMake] Create an install-distribution target driven by LLVM_DISTRIBUTION_COMPONENTS

The idea here is to provide a customizable install target that only depends on building the things you actually want to install. It relies on each component being installed having an auto-generated install-${component}, which in turn depends only on the target being installed.

This is fundamentally a workaround for the fact that CMake generates build files which have their "install" target depend on the "all" target. This results in "ninja install" building a bunch of unneeded things.

llvm-svn: 261681
2023-04-18 10:09:21 -05:00
Chris B d6ea7357b3
[NFC] Update tests that depend on 2018 behavior (#5157)
Under HLSL 2021 short circuiting ternary operators result in _very_
different control flow in these tests, so they aren't really portable.
Changing these tests to being HV 2018 keeps them working with minimal
changes.
2023-04-18 10:04:54 -05:00
Xiang Li 1e390295e1
Allow find te.exe with %TAEF_PATH% directly. (#5150)
* Allow find te.exe with %TAEF_PATH% directly.

This is for pipeline test where te.exe is set with %TAEF_PATH%.

* Use FATAL_ERROR when cannot find taef
2023-04-17 11:51:19 -07:00
Chris B f90af4e15e
Move some of the raytracing diags to Sema (#5131)
This change moves some of the raytracing entry signature diagnostics up
into Sema. This is fallout from some work that I'm doing to cleanup and
reduce complexity in HLSL's CodeGen code, but it is also generally just
a win.

By catching these errors in Sema we stop compilation earlier and don't
need to make our Code Generation code resilient against invalid ASTs or
partial IR generation.
2023-04-14 10:54:10 -05:00
Nathan Gauër cbe8ec28a3
spirv: fix GL semantic in inherited classes (#5144)
When a semantic was in an inherited class, it was missed and caused
issues later down the pipe. This was because we assumed semantic fields
would only be present at the top-level struct, ignoring inheritance.

This commit also changes the parameter type from `DeclaratorDecl` to
`NamedDecl` as it only requires methods up to `NamedDecl`. Loosening
this requirement allowed me to pass a CXXRecordDecl.

Fixes #5138

Signed-off-by: Nathan Gauër <brioche@google.com>
2023-04-13 15:57:19 +02:00
Joshua Batista a526984da9
Fill in MDVals with push_back for maintainability. (#5126)
* use push-back

* use small vector for performance gain
2023-04-05 13:58:35 -07:00
Chris B 39481d9d58
Extend add_lit_testsuites to cover more cases (#4801)
This pulls in a couple upstream commits by myself and @bogner.

commit 3adaa8cf4a6df45430b47a62c649c7cb54bb1626
Author: Justin Bogner <mail@justinbogner.com>
Date:   Wed Jun 8 22:36:37 2016 +0000

    cmake: Simplify add_lit_testsuites

    cmake 3.4 introduced LIST_DIRECTORIES to glob recurse, which can be
    used to simplify this code greatly.

    llvm-svn: 272217

commit 25ef9e34c9de7b1edc327189b78200459337f7e5
Author: Justin Bogner <mail@justinbogner.com>
Date:   Mon Jul 25 18:07:14 2016 +0000

    cmake: When adding lit testsuites, ignore Output directories

    With in-tree builds we can get Output directories scattered among
our
    tests. Recursing into those to find tests doesn't make sense.

    Thanks to nlewycky for noticing this!

    llvm-svn: 276667

commit a44ef999fb5e9243df9c4459df1b17b66aa3fd23
Author: Chris Bieneman <chris.bieneman@me.com>
Date:   Mon Jan 3 11:52:44 2022 -0600

    [NFC][CMake] Add FOLDER to utility targets

    As Visual Studio's CMake support is getting better and better the
line
    between IDE generator and non-IDE generators is blurring. Visual
Studio
    2019 and later have a very useful UI that can handle all of the
various
    targets we create, but if they are unsorted it is wildly unwieldy.

    This change sorts the lit testsuite targets and per-component
install
    targets into folders, which are not generated for IDE generators but
    are generated by default under Visual Studio's CMake + Ninja
    integration.
2023-04-05 09:22:08 -05:00
Sebastian Neubauer d529af3e2b
Replace deprecated std::iterator inheritance (#5111)
std::iterator is deprecated since C++17. E.g. when using the standard
library of gcc 12, deprecation warnings are shown.

There is some background info here:
https://www.fluentcpp.com/2018/05/08/std-iterator-deprecated/
2023-04-03 19:25:04 -05:00
Nathan Gauër d0c4285ddc
spirv: fix crash when no initializer can be made (#5127)
* spirv: fix crash when no initializer can be made

When an initializer can't be implemented, an error should be emitted.
Because we deref a pointer without checking for error, we simply crash,
preventing the diagnostic message to be shown.
(Fixing #5124 crash)

Signed-off-by: Nathan Gauër <brioche@google.com>
2023-04-03 13:53:50 +00:00
Laura Hermanns b248b4c571
[SPIR-V] Fix composites with empty struct fields. (#5017)
- Fix index assertion in getFieldIndexInStruct.
- Don't generate composite for empty structs in struct fields.
2023-04-03 11:48:05 +02:00
Xiang Li 02d4922aa5
[template] Support empty template arg list on TypeAliasTemplateDecl. (#5114)
* [template] Support empty template arg list on TypeAliasTemplateDecl.

This is to help add sperate type for row major and column major matrix.

The issue is only support ClassTemplateSpecializationDecl in getHLSLDefaultSpecialization.
It cause compile error on t22 in following shader.

  template<typename T=float, int i=0>
  struct test {
    T d;
  };

  template<typename T=float>
  using test2 = test<T, 1>;

  test2 t22;

The fix is using Sema::CheckTemplateIdType to generate the default specialization for all TemplateDecl.
2023-03-30 10:43:52 -07:00
Tex Riddell 6cdaa61d8d
Fix ScoreCast for class types, fix more struct assumptions in SemaHLSL (#5110)
SemaHLSL had various locations where getAsStructureType or isStructureType were used, when classes should have been handled in the same way.

This change uses `getAs<RecordType>` instead of `getAsStructureType` and replaces `isStructureType` with `isStructureOrClassType` in locations that should handle structs and classes.

Also, it deletes unused HLSL methods in `clang::Sema` found while adding unit tests.

New tests added and existing tests updated.
- `err_hlsl_typeintemplateargument_requires_struct`: say struct/class rather than just struct
- VerifierTests with Texture2D using a specific class failed because it was `class`, not for the right reasons, other checks happen later which could happen earlier, but not this change's purpose to reimplement new diagnostics
- One test had `CHECK-NOT: and` which unfortunately collided with the branch name (`and` in `handle...`) in the llvm.ident metadata.  Added label to scope the check to the code in the function.
2023-03-23 10:21:26 -07:00
Nathan Gauër b96b69af98
build: add exception header (#5112)
This file uses std::current_exception, so it should
include <exception>
2023-03-23 15:12:54 +00:00
Adam Yang ef53fb0f0f
Fixed a crash due to an incorrect call to dropAllReferences (#5102)
Fixed a crash when there's addrspacecast going into a getelementptr, which goes into a dbg.decare. The HLSL SROA pass was incorrectly calling dropAllReferences on the addrspacecast ConstExpr, which invalidates the getelementptr ConstExpr (sets the operand to nullptr).
2023-03-22 12:43:06 -07:00
Nathan Gauër d04c296ad7
update SPIRV-Tools version to v2023.2.rc1 (#5097)
Rolling SPIRV-Tools to the new version.
2023-03-21 09:19:49 -04:00
Xiang Li 3ef0ccc76d
Move HLSLDefaultRowMajor to LangOptions. (#5098)
This is for use the information in Sema.
2023-03-20 13:30:01 -07:00
Tex Riddell 0837d2ed82
Add script to compile to intermediate IR for easier pass test authoring (#5101)
This script automates some operations to make it easier to write IR tests:
  1. Gets the pass list for an HLSL compilation using -Odump
  2. Compiles HLSL with -fcgl and outputs to intermediate IR
  3. Collects list of passes before the desired pass and adds
     -hlsl-passes-pause to write correct metadata
  4. Invokes dxopt to run passes on -fcgl output and write bitcode result
  5. Disassembles bitcode to .ll file for use as a test
  6. Inserts RUN line with -hlsl-passes-resume and desired pass
2023-03-20 10:37:48 -07:00
Tex Riddell f4ea912411
Add script to compile to intermediate IR for easier pass test authoring (#5101)
This script automates some operations to make it easier to write IR tests:
  1. Gets the pass list for an HLSL compilation using -Odump
  2. Compiles HLSL with -fcgl and outputs to intermediate IR
  3. Collects list of passes before the desired pass and adds
     -hlsl-passes-pause to write correct metadata
  4. Invokes dxopt to run passes on -fcgl output and write bitcode result
  5. Disassembles bitcode to .ll file for use as a test
  6. Inserts RUN line with -hlsl-passes-resume and desired pass
2023-03-20 10:36:49 -07:00
Xiang Li ca6d80f511
Switch HLSL matrix major attribute to TypeAttr (#5087)
This change removes redundant information saved in AST.
Now major information only saved in AttributedType.
2023-03-13 21:40:22 -07:00
Chris B 47958467cb
No special case for unannotated params (#5094)
Initially the change here was forcing unannotated parameters to be
treated as uses (`in` parameters). Instead this changes to not handle
them explicitly.

Most `in` parameter uses should produce `LValueToRValue` casts which
will be identified as uses through other means, but by removing this
special case we can support unannotated AST nodes from generated ASTs
through this analysis based on their type and usage alone.

Fixes #5093
2023-03-10 13:37:59 -06:00
Helena Kotas 667fb773cc
Change SharedLibAffix.h include path to eliminate the need to change build setting (#5085)
The file dxcapi.use.cpp is used in other projects and would require build changes if the #include did not change.
2023-03-08 12:08:51 -08:00
Chris B 30841a0f2c
Don't try to validate invalid decls (#5086)
We should not try to validate template arguments for invalid decls.
Doing so seems to result in infinte recursion that eventually kills the
compiler... so let's not do that.

Fixes #3455
2023-03-08 13:58:32 -06:00
Chris B 53f5a1422e
Only track scalar `out` params (#5078)
The UninitializedValues analysis doesn't correctly handle arrays or pointer objects, so we should not enable out parameter analysis for those types. Additionally, because the HLSL ASTs incorrectly represent structure out parameters as non-reference types, the analysis will generate incorrect diagnostics for uses of structs in call expressions. There isn't really an easy solution for that. This change takes a conservative approach to addressing those issues by disabling the analysis for values that we can't correctly identify.

This change also disables the "suggest initialization" fix-it for out parameters. Default initialization for out parameters doesn't work, and would be confusing.
2023-03-06 19:24:37 -06:00
Chris B 364d5f9da2
Add #pragma region support (#5074)
Add the pragma region handler to the HLSL pragma handlers list.

Fixes #676

Sorry for the slow turn around time.
2023-03-02 14:52:36 -06:00
Chris B 1380cf88ed
Add diagnostics for uninitialized `out` parameters (#5047)
This change adds diagnostic support for uninitialized `out` parameters.
With this change, `out` parameters are treated as uninitiailzed values
until they are initialized and use of the values produdces a diagnostic.

This change is a slightly hacky extension of Clang's uninitiailzed
values analysis which is achieved by adding ParamVarDecls for `out`
parameters to the list of variables to analyize. It also adds dummy
uses of the variables on `return` statements.

It also introduces the maybe_unused attribute, adopting C++ naming and
C++-like behavior.

When applied to an `out` parameter `maybe_unused` results in skipping
uninitialized value analysis on return and function block exits only
if the value is always uninitialized.

If the value is maybe uninitialized or if the value is used explicitly
the warnings are still emitted.
2023-03-01 22:38:06 -06:00
Helena Kotas 22b392ab8f
Remove DXC.Release pipeline (#5073)
It has been replaced by internal build pipeline that also includes dxil.dll.
2023-03-01 17:56:34 -08:00
Chris B 44ba911a05
[NFC] Delete some dead/unreachable code in CGCall (#5069)
This code is all unreachable. Reverting this strips out some cascading
changes adding an unused parameter to a few functions.
2023-02-28 21:10:39 -06:00
Adam Yang 129024cd18
Added -opt-disable sink to disable instruction sinking in instcombine (#5050)
In some cases, sinking instructions can significantly extend register lifetime. Added option -opt-disable sink in the same vein as -opt-disable "gvn" so shader authors can have some degree of control over this behaviour.
2023-02-28 15:22:52 -08:00
Greg Roth 5eb7c77d7c
Move WinAdapter into interface directory (#5066)
Since it is shipped and relied upon, the WinAdapter header belongs in
the release directory. This removes the need to include the Support
directory for building purposes

revises fix to #4918
2023-02-28 10:41:50 -08:00