This updates the ADO yaml to select the latest version of the OS. In the
case of MacOS, this will still be 11 for now. For Ubuntu, it will
silence the warnings that we are using a deprecated version and save us
the headache of having to do this again.
The risk is that a new version of either OS will cause the build to
break without our intervention, but the real motivation for explicit
versions was an earlier impulse to support the minimal build system that
is no longer a priority. As for the risk, I feel it is minimal and we
can respond in a timely fashion if it should occur.
There were a few things missing in the initial attempt at this workflow. I left off the file extension for the CMake cache file, and also forgot to initialize the submodules.
Additionally using make is... slow. Using make `-j` causes the VM to run out of memory. To resolve those issues I'm installing ninja and using ninja instead. I'm also setting `LLVM_USE_LINKER=lld` to reduce linker memory usage and `LLVM_PARALLEL_LINK_JOBS=1` to only run one link at a time.
I've also added `--rerun-failed` and `--output-on-failure` to the ctest invocation so that if it fails we get some hopefully helpful output.
Needed for the impending enabling on *nix platforms
* Remove circular dependency from RDAT Dumper
A file included by the source that implemented various ToString
converters of reflection data to strings itself depended on those
declarations, which it only found because of the unique way MSVC
processes templates. By moving the definitions and declarations into
their own header and source files, everyone gets what they need
without ouroborosing.
* Create DirectX-Headers submodule
Creates the DirectX-Headers submodule and adds the needed defines to
allow them to be used. As yet makes no use of these headers
* Improve src dir finding error
The check for the file stream that is meant to represent the filechecked
source file wasn't sufficient to detect a non-existent file. By expanding
the error check, it can produce a helpful message.
Also initialize the failure code so it isn't random
* Enable reflection functionality and testing
This flips the switch, removing or repositioning many ifdefs and
including previously excluded files in the build.
* Actually add the DirectX-Headers submodule
* fix *nix build breaks caused while fixing win breaks :P
* Respond to feedback -- some of it anyway ;)
* simplify cmake file to exclude unneeded src dir
* fix cmake (again)
* Fix GCC template specialization finickiness
What compiler is overly permissive now huh? huh? (or just quick to adopt
new language features?)
* LPCBYTE isn't a thing
Loathe as I am to push one more commit onto this. I don't want to
propagate a misconception. I meant to remove this earlier and caught it
from one final self-review >:(
Use an array of 32-bit integer values instead of 32-bit float values for the `"dx.icb"` immediate constant buffer data.
This prevents the FPU flipping the 22nd bit of integer constants, when their bit pattern represents a float32 signalling NaN on x86 architecture.
Fixes#4786
The new taef lit configuration names don't conform to the normal
conventions which makes it difficult for them to have automatically
generated targets. This updates them to match LLVM & Clang conventions.
* Cleanup windows build to conform to C++ 17
MSVC's C++ language implementation deviates from the standard in a
number of ways, this patch cleans up several issues that become errors
if you build DXC using clang-cl, which has a more strict
interpreteation of C++.
This change should not have any functional impact on the final program.
Specific changes include:
* static_assert(false...) is removed, this is always ill-formed by the
C++ standard.
* Under template instantiations implicit `this` is not always allowed.
* Character array `<` comparision is... probably not what was intended.
* Implicit conversions are stricter than MSVC enforces.
* Template base types need explicit type specialization when referred
to.
* It is illegal to initialize more than one member of a union.
* Scope nested enums cannot be forward declared.
* Header paths should be case-sensitive.
* Exception specifications of specific types are disallowed in C++ 17.
* Clang is stricter about const-correctness, especially as it relates
to constant c strings.
* Update based on review feedback.
* Converted string construction to copy-constructor calls.
* Removed constexpr method bodys to cause linker error.
* Catching other methods I missed.
* I was a bit too over-zealous deleting methods.
* Remove DXC_BUILD_ARCH variable
This commit simplifies the cross-targeting build support to not require
specifying the build architecture explicitly. Instead it is derived from
the build tools used in the generation.
I've tested this change locally for Win32, x64 and arm64.
* Special handling for arm64ec
* Bump required CMake to 3.10
CMake 3.10 is very old, but has a feature this PR uses. Raising the
requirement should have no impact on our users.
* Fix build issues caused by changes in CMake 3.10
I encountered two issues building arm64ec. First CMake and/or link.exe
seem to have a disagreement about flag ordering and how to handle
`/INCREMENTAL`. This change results in disabling kernel-mode debugging
on arm64ec builds, but it means we can build... so that's a win.
The other issue is that libClangSema has some files that have gotten too
big, so we need `/bigobj` for Sema.
This change provides a default value based on the build configuration
which can be used in the absence of a specified HLSL Data Dir when
running the tests. This does not change any existing functionality, but
enables the common configuration of running the tests inside the
configured source directory to omit specifiying a path.
Before this commit, struct field indices were computed from the AST
type. This was correct as SPIR-V types and AST types had the same
structure.
When adding bitfields, we started to squash some fields together, as
long as some rules were respected (bitfield, same type, doesn't span
over multiple type-sized words, etc).
This means indices now diverge between SPIR-V types and AST types.
This requires us to lower the AST type before the lowering pass, when
generating instructions like OpAccessChain.
A cleaner alternative would be to lower all types before instruction
generation, and only operate on SPIR-V type. But cost of making this
refactoring is large, and we don't believe it is worth it since we plan
to upstream to clang (hence rewrite this code).
note: this code prevents AST indices to diverge from SPIR-V indices when
computed. This is just a safeguard until bitfields are in place in case
I made a mistake with the layout rules, allowing us to catch those bugs
faster.
Signed-off-by: Nathan Gauër <brioche@google.com>
* Enable SPIR-V tests to run without arguments
This specifies a default value for the --spirv-test-root flag based on
the source directory at configuration time. This simplifies the command
line for running the tests manually, but does not alter the ability to
override the test directory explicitly.
* Restoring code I should not have deleted
The initializer list goes out of scope after the expression it is used
in, so the ArrayRef points to invalid memory. This change keeps the
initialization list around so that the array ref remains valid through
the test.
* Support VK_EXT_mesh_shader
* Fix errors when compiling with SPV_NV_mesh_shader
* Minor tweak onto amplification shaders
* Fix pre-checkin failure
* Add amplification and mesh tests for EXT_mesh_shader
* Add some comments
* Fix primitive indices
Co-authored-by: Tianyuan <Tianyuan.Wu@amd.com>
* [CMake] Simplify code coverage CMake configuration
This just addes an option processed by the CMake cache file to configure
code coverage for DXC. With this patch you can generate a coverage
report locally if you build with Clang using the following commnads:
cmake -G Ninja -DDXC_COVERAGE=On <other options> -C
<path to dxc>/cmake/caches/PredefinedParams.cmake <path to dxc>
ninja
ctest
ninja generate-coverage-report
* Adding code comment explaining caches
CMake cache scripts aren't super common, but are very useful. Adding a
comment to explain how they work is probably generally valuable.
Fixing some clang warnings about mixing logical and bitwise and
the use of one deprecated CPP type (Removed in cpp17, same change
as seen in #4761).
Some are using those bitwise operation to avoid operator laziness. It
was fixed upstream by an int cast, applying the same fixes.
Signed-off-by: Nathan Gauër <brioche@google.com>
* On Windows, use CreateFileW to delete files in sys::fs::remove.
Merged from
0f9e889881
This will fix fail on llvm unit test ProgramTest::CreateProcessLongPath.
Use MSFileSystemRef::CreateFileW.
This cherry-picks in a bunch of upstream LLVM changes and has a few small modifications for DXC.
* [CMake] Add LLVM_BUILD_INSTRUMENTED option to enable building with
-fprofile-instr-generate
This is the first step in supporting PGO data generation via CMake.
I've marked the option as advanced and experimental until it is fleshed
out further.
llvm-svn: 255298
* Add support for collating profiles for use with code coverage
Differential Revision: http://reviews.llvm.org/D20993
llvm-svn: 272599
Patch by: Vedant Kumar <vsk@apple.com>
* [CMake] Add targets for generating coverage reports
This is a pretty small bit of CMake goop to generate code coverage
reports. I always forget the right script invocation and end up
fumbling around too much.
Wouldn't it be great to have targets that "Just Work"?
Well, I thought so.
At present this only really works correctly for LLVM, but I'll extend
it in subsequent patches to work for subprojects.
Reviewed By: phosek
Differential Revision: https://reviews.llvm.org/D109019
* Update prepare-code-coverage.py from llvm/main
Theres's a swath of changes that went in here. Cherry-picking them all
indivudially is not worth it. Contained commits:
8773822c578a [Zequan Wu] [Utils] Add -compilation-dir flag to
prepare-code-coverage-artifact.py
577d59bc679d [Nico Weber] svn propset svn:executable on
utils/prepare-code-coverage-artifact.py
9a10eac663dd [Chris Bieneman] [Coverage] Apply filtered paths to summary
16776315460e [Vedant Kumar] [utils] coverage: Add help text about the
--restrict flag (NFC)
f4df0edf3ea3 [Vedant Kumar] [utils] Add a '--unified-report' option to
the code coverage prep script
7466987cb7ba [Vedant Kumar] [utils] Use print_function in the code
coverage prep script, NFC.
273b6dc3e2f7 [Vedant Kumar] [utils] Add an '--only-merge' option to the
code coverage prep script
547ebad0b984 [Vedant Kumar] [utils] Teach the code coverage prep script
about --restrict
05ee94f1b573 [Vedant Kumar] [utils] Generate html reports with the code
coverage utility script
d9aed82cf7e2 [Vedant Kumar] Add support for collating profiles for use
with code coverage
* HLSL-specific change to coverage reporting
This works around DXC not having a cmake target to run tests by
exposing a new variable which can configure which target gets run to
produce profiles. A similar change will be useful upstream, so I'll add
a change there too.
* Support taef run in lib.
lit.formats.taef is added to run taef under lit.
New lit target check-clang-hlsl is added to run clang-hlsl-test taef tests.
Add lit-target for dxil conv to set different hlsl data dir.
- Added a comment warning about using MergeGepUse while iterating.
- Changed MergeGepUse to return bool for whether anything actually changed.
- Adding GEP's user to worklist, even when GEP and GEP's source pointer GEP cannot be merged.
This is some preliminary work to bitfield addition into the SPIR-V
backend. This commit should not change the behavior of our backend.
Signed-off-by: Nathan Gauër <brioche@google.com>
Signed-off-by: Nathan Gauër <brioche@google.com>
Things like -DResType=RasterizerOrderedStructuredBuffer<uint> could be workaround with
-DResType="RasterizerOrderedStructuredBuffer<uint>" for lit.
But clang-hlsl-tests will not work.
So put the template inside the test.
* WinAdapter: Remove virtual dtors from IUnknown to fix vtable ABI
The vtable for `IUnknown` and its subclasses contain two deletion
pointers when compiled on non-Windows systems with `IUnknown` from
`WinAdapter.h`:
vtable for 'DxcLibrary' @ 0x7ffff7cbc5f8 (subobject @ 0x5555556bb9e0):
[0]: 0x7ffff6a56d40 <DxcLibrary::QueryInterface(_GUID const&, void**)>
[1]: 0x7ffff6a56d20 <DxcLibrary::AddRef()>
[2]: 0x7ffff6a56d30 <DxcLibrary::Release()>
[3]: 0x7ffff6b36bc0 <IUnknown::~IUnknown()> // Complete object destructor
[4]: 0x7ffff6a57130 <DxcLibrary::~DxcLibrary()> // Deleting destructor
[5]: 0x7ffff6a56d50 <DxcLibrary::SetMalloc(IMalloc*)>
[6]: 0x7ffff6a56d60 <DxcLibrary::CreateBlobFromBlob(IDxcBlob*, unsigned int, unsigned int, IDxcBlob**)>
... More DxcLibrary virtual functions
This shifts the the pointers for functions for all subclasses, and is
[annoying] to deal with in otherwise cross-platform applications using
DirectXShaderCompiler as library. `dxcompiler.dll` compiled on/for
Windows without `WinAdapter.h` does not suffer this problem, and only
has three function pointers for `IUnknown`.
Fortunately, it is easily solved by removing the virtual destructor from
`IUnknown`. LLVM enables `-Wnon-virtual-dtor` that warns against
classes with virtual methods but no virtual destructor, though this
warning is best not enabled akin to Windows builds where `IUnknown` from
`windows.h` (`unknwn.h`) results in the same warning on MSVC ([1]/[2]).
[annoying]: 1e624792fc/src/unknown.rs
[1]: https://github.com/microsoft/DirectXShaderCompiler/issues/3783#issuecomment-844189358
[2]: https://godbolt.org/z/hKPT6ThEf
* WinAdapter: Make `IUnknown` and `IMalloc` pure-virtual classes
`IUnknown` in Windows' `unknwn.h` and `IMalloc` in `ObjIdl.h` are marked
as pure virtual, and are best marked as such in `WinAdapter` for
non-Windows platforms too [1]. Only the shim for `IMalloc` was relying
on the default refcounting implementation, all other subclasses either
contain pure-virtual methods themselves or provide an implementation for
`AddRef`/`Release` as required. Likewise the default implementation for
`IMalloc` was only instantiated once by `CoGetMalloc`, and has been
moved into a local class implementing the `IMalloc` interface instead.
[1]: https://github.com/microsoft/DirectXShaderCompiler/pull/3793#issuecomment-846459741
* WinAdapter: Add three missing virtual functions to `IMalloc` interface
To prevent unexpected vtable breakage, add the missing functions from
the [documentation]. Note that they are listed in the wrong order, the
right order is retrieved from the `ObjIdl.h` header and implementations
for `IMalloc` in DirectXShaderCompiler. All implementations are now
properly using the `override` keyword too, to enforce virtual method
existence in the base class.
[documentation]: https://docs.microsoft.com/en-us/windows/win32/api/objidl/nn-objidl-imalloc
* Make all WinAdapter destructions explicit
This prevents warnings about non-virtual destructor usage that trip up
the Linux build. It represents status quo on Windows.
Co-authored-by: Greg Roth <grroth@microsoft.com>
This change alters how globallycoherent attributes are validated. We
will need similar changes for other HLSL type attributes as well.
Without this change, globallycoherent attributes are only allowed to
apply to declarations of builtin objects during parsing. Additionally
if applied to a non-UAV we catch that late (during code generation) and
report a different error there.
This patch reworks all of that. Instead, during parsing we allow verify
the attribute is applying to a UAV builtin type and issue a diagnostic
if applied to a non-UAV type. We also allow the attribute to be applied
to any dependent type.
If the attribute is applied to a dependent type, we verify that the
dependent type is resolved to a valid UAV type during instantation.
This change also reworks the existing test case for globallycoherent
diagnostics and deletes duplicated tests that were not adding meanigful
value.
Fixes 4583.
This change makes mixing bitfields and HLSL annotations an error. Since
the syntax for HLSL annotations and bitfields are ambiguous, this change
works around some issues with the ambiguity by disallowing mixing the
two on the same declaration.
Fixes#4686