In the middle of rewriting expressions like (A*B + A*C + D) to pull
common factor A out, the algorithm finds that there's actually only one
A. This is unexpected, and it fires an assertion.
This can occur when A is a constant, and constant -A also appears in the
terms somewhere else.
There is no harm in this situation, however, because the algorithm then
creates an addition-tree, but with a single element, and that's still
correct.
This bookkeeping issue was fixed later in LLVM, at
95abfa35d6
Unfortunately the associated test doesn't translate cleanly to DXC-era
LLVM. I've added test case reduced from our original case.
Fixed: #6829
This PR pulls the following upstream changes into DXC:
[llc/opt] Add an option to run all passes twice
(04464cf731)
> Lately, I have submitted a number of patches to fix bugs that only
occurred when using the same pass manager to compile
> multiple modules (generally these bugs are failure to reset some
persistent state).
>
> Unfortunately I don't think there is currently a way to test that from
the command line. This adds a very simple flag to both
> llc and opt, under which the tools will simply re-run their respective
> pass pipelines using the same pass manager on (a clone of the same
module). Additionally, we verify that both outputs are
> bitwise the same.
>
> Reviewers: yaron.keren
[opt] Fix sanitizer complaints about r254774
(38707c45be)
> `Out` can be null if no output is requested, so move any access
> to it inside the conditional. Thanks to Justin Bogner for finding
> this.
This is for the test of this change
(ef8761fd3b)
to fix#6659.
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Adam Yang <31109344+adam-yang@users.noreply.github.com>
Induction variable simplification (indvars) tries to rewrite exit
values; these appear as phi nodes in loop exit blocks. If the
replacement for the phi is still in the loop, then that would break the
LCSSA property. Don't do that.
Add a test for this.
Previously, if the latch exit was reachable from a different exit block
for the loop, then the pass would introduce a loop involving that exit
block and the latch exit. This is unwanted and unaccounted for.
- Add a test for shared exits.
- Add a test for non-dedicated latch exit
Before doing any major surgery on an exit from loop L, ensure that if an
exit edge from L goes to block X, then X is in L's parent loop or no
loop at all.
Add test cases:
- a reduced test case where the exiting block does not dominate its own
loop latch.
- a reduced test case where the exiting block is the latch for its own
loop. This reproduces the assert triggered by the original HLSL.
- the original HLSL that triggered this bug fix.
- the intermediate module from the original HLSL, taken just before the
attempt to remove unstructured loop exits.
Add a pass to run hlsl::RemoveUnstructuredLoopExits in isolation
Example: opt -dxil-r-u-l-e a.ll -S
Add some basic tests.
No functional change to the pass itself.
This PR pulls the upstream change, Reassociate: add global reassociation
algorithm
(b8a330c42a),
into DXC with miminal changes.
For the code below:
foo = (a * b) * c
bar = (a * d) * c
As the upstream change states, it can identify the a*c is a common
factor and redundant.
This is part 1 of the fix for #6593.
This commit fixes a crash in the compiler when lowering a groupshared
variable with a multi-dimensional array type. The root cause of the bug
was that we had a nested gep expression that could not be merged into a
single gep because of an intervening addrspacecast.
The `MultiDimArrayToOneDimArray` pass flattens the multi-dimension
global variables to a single dimension. It relies on the `MergeGepUse`
function to flatten any nested geps into a single gep that fully
dereferences a scalar element.
The fix is to modify the `MergeGepUse` function to look through
addrspacecast instructions when trying to merge geps. We can now merge
geps like
gep(addrspacecast(gep(p0, gep_args0)) to p1*, gep_args1)
into
addrspacecast(gep(p0, gep_args0+gep_args1) to p1*)
We also added a call to `removeDeadConstantUsers` before flattening
multi-dimension globals because we can have some dead constants hanging
around after merging geps and these constants should be ignored by the
flattening pass.
DXIL doesn't support the bswap intrinsic, normally a backend would lower
this intrinsic to something else, in this case we don't have a backend
so we just end up generating invalid DXIL.
The solution here is to disable bswap matching when targeting DXIL.
Fixes#5104
This enables `.ll` as a default test suffix in the LLVM tests. To
preserve the low number of unsupported tests, this changes the way we
disable tests from using config.unsupported to setting the suffixes to
empty.
[bug] Fix crash in dxilgen when buffer subscript gep feeds an lcssa phi
This change fixes a crash in the dxilgen pass when lowering buffer
subscripts. These subscripts feed into a gep instruction that needs to
be replaced with the computed index and offset for the dxil buffer load
intrinsics.
When processing all the users of the subscripts the code would crash on
any phi node user. We can handle single-value phis by propagating
through to the users of the phi. The single-value phis can be inserted
by the lcssa pass.
After fixing this initial crash it triggered another error later in the
compiler for a similar issue. The lowered handle used by the buffer load
was also being fed through an lcssa phi by a later run of that pass.
This would trigger a dxil validation error because handles are not
allowed in phis. Since it is a single-value phi we can again propagate
the value to the phi users to avoid this error.
The test case was reduced from a real-world shader and only occurred
when compiling with optimization disabled (Od).
Improve output of DXC test runs:
- Add `-lit-verbose` option to `hctbuild` to setup lit test runs with
verbose output (`hcttest` will list test names as they run)
- Hide tests that are never supported (there was over 10K of unsupported
tests found by LIT discovery)
- Show warnings about non-essential tools only in LIT debug mode
- Skip over file copying and non-LIT part of `hcttest.cmd` if all
requested tests have already been run
- CMD tests have been move under clang's lit tests; keep the `hcttest
cmd` option for running cmd tests separately
Number of unsupported tests was reduced from 10452 to 1 if spir-v is
enabled, 39 if not. The number of tests that run did not change.
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>
This handles a few last Windows fixes for LLVM tests.
* The YAML praser convertes \r to \n, resulting in repeated newlines in
YAML tests on Windows.
* The MS filesystem changes on Windows cause one of the MemoryBuffer
tests to fail. I've disabled that test on Windows.
* Because we convert many crash cases to exceptions on Windows the
GoogleTest DEATH tests fail to die on Windows.
This change addresses the same issue #4794 solves, but restricts the
change to Windows only. I'm only merging this since @python3kgae is out
and I don't really want to wait until he returns.
utils/unittest/googletest/include/gtest/internal/gtest-port.h
* Update Linux build and test workflows to use lit
This change updates the build and test workflows in our azure pipelines
and the GitHub action for code coverage data to use lit instead of ctest
as the test runner. This adds additional test coverage by running some
of the LLVM & Clang tests.
* Fix missing dependency between LLVMAnalysis & DXIL
The default Linux linker fails because LLVMAnalysis depends on LLVMDXIL
and BFD doesn't cycle libraries.
* Updating pipelines to remove mkdir and cd
This just cleans up the pipeline shell commands to avoid unnecissary
mkdir and cd invocations.
Based on feedback from @Keenuts. Thanks!
* Disable LLVM LIT tests that use garbage collection
DXC disabled support for the LLVM garbage collection intrinsics.
Disable LLVM LIT suites and tests
This patch is a little more selective than the clang counterpart. Most
of the LLVM tests are expected to pass in DXC.
In cases where very few tests are failing for obvious reasons I've
disabled individual tests using `REQUIRES` lines. In most places I've
disabled whole suites. Any suite that is expected to pass, I've also
included a comment of the failing test cases so that we can investigate
further.
IR Verifier and Integer tests are disabled only on Windows. These tests
pass on *nix platforms but fail on Windows due to the MS filesystem
modifications causing llvm-as to crash.
* Enable building LLVM testing tools
This gets a bunch of the LLVM testing tools building, which allows us
to run the LIT tests (which have a lot of failures)
* Fixing broken Linux and Windows builds
* Removing a change that snuck in.
* Changes to get LLVM unit tests building
This change gets the LLVM unit tests building again and running through
LIT via the `check-llvm-unit` target.
This change does not have the tests passing! Subsequent changes will
get the unit tests passing. This change also disables some tests where
the LLVM code is no longer used and making those tests work will
require substantial effort.
* Changes to get Clang unit tests building
This change gets the Clang unit tests building again and running
through LIT via the `check-clang-unit` target.
This change does not have the tests passing! Subsequent changes will
get the unit tests passing. This change also disables some tests where
the Clang code is no longer used and making those tests work will
require substantial effort.
* A few extra Windows fixes
This adds some missing APIs to the Windows Filesystem code and adds an
option to hctbuild to enable building the LLVM & Clang unit tests.
* Disable libClangFormat tests
These tests are a bit gnarly to repair... unless we really start using
the format library we probably just want to disable these tests.
Fix#30: Revert license text in banner comments to original llvm verbage
This commit removes the Microsoft-specific copyright in llvm files
and reverts the copyright wording to the original llvm wording.
We used the following method to find the files to change:
1. Find all files in DirectXShaderCompiler that are also in llvm 3.7
2. For those files that have the Microsoft-specific copyright, revert
it to the original llvm copyright as present in llvm 3.7
3. Revert the copyright in a few files that are not in llvm, but are
mostly copies of files in llvm:
lib\Transforms\Scalar\ScalarReplAggregatesHLSL.cpp
lib\Transforms\Scalar\Reg2MemHLSL.cpp
Leave the Microsoft-specific copyright header in files not present
in stock llvm:
include\dxc\*
lib\HLSL\*
lib\DxcSupport\*
tools\clang\test\HLSL\*
tools\clang\test\CodeGenHLSL\*
tools\clang\unittests\HLSL\*
tools\clang\unittests\HLSLHost\*
tools\clang\tools\dxcompiler\*
tools\clang\tools\dxa\*
tools\clang\tools\dxc\*
tools\clang\tools\dxopt\*
tools\clang\tools\dxr\*
tools\clang\tools\dxv\*
tools\clang\tools\dotnetc\*
utils\hct\*
CONTRIBUTING.md
COPYRIGHT
LICENSE-MIT
README.md
cmake\modules\FindD3D12.cmake
cmake\modules\FindDiaSDK.cmake
cmake\modules\FindTAEF.cmake
docs\DXIL.rst
docs\HLSLChanges.rst
docs\_themes\dxc-theme\layout.html
docs\_themes\dxc-theme\theme.conf
docs\_themes\dxc-theme\static\dxc-theme.css
include\llvm\llvm_assert\assert.h
include\llvm\llvm_assert\cassert
include\llvm\Support\MSFileSystem.h
include\llvm\Support\OacrIgnoreCond.h
lib\MSSupport\CMakeLists.txt
lib\MSSupport\MSFileSystemImpl.cpp
lib\Support\assert.cpp
lib\Support\MSFileSystemBasic.cpp
lib\Support\Windows\MSFileSystem.inc.cpp
lib\Transforms\Scalar\Reg2MemHLSL.cpp
lib\Transforms\Scalar\ScalarReplAggregatesHLSL.cpp
tools\clang\docs\UsingDxc.rst
tools\clang\include\clang\AST\HlslTypes.h
tools\clang\include\clang\Basic\BuiltinsDXIL.def
tools\clang\include\clang\Basic\LangOptions.fixed.def
tools\clang\include\clang\Parse\ParseHLSL.h
tools\clang\include\clang\Sema\SemaHLSL.h
tools\clang\lib\AST\ASTContextHLSL.cpp
tools\clang\lib\AST\HlslTypes.cpp
tools\clang\lib\CodeGen\CGHLSLMS.cpp
tools\clang\lib\CodeGen\CGHLSLRuntime.cpp
tools\clang\lib\CodeGen\CGHLSLRuntime.h
tools\clang\lib\Frontend\Rewrite\FrontendActions_rewrite.cpp
tools\clang\lib\Parse\HLSLRootSignature.cpp
tools\clang\lib\Parse\HLSLRootSignature.h
tools\clang\lib\Parse\ParseHLSL.cpp
tools\clang\lib\Sema\gen_intrin_main_tables_15.h
tools\clang\lib\Sema\SemaHLSL.cpp
tools\clang\tools\d3dcomp\CMakeLists.txt
tools\clang\tools\d3dcomp\d3dcomp.cpp
tools\clang\tools\d3dcomp\d3dcomp.def
tools\clang\tools\libclang\dxcisenseimpl.cpp
tools\clang\tools\libclang\dxcisenseimpl.h
tools\clang\tools\libclang\dxcrewriteunused.cpp
tools\clang\tools\libclang\libclang.rc
tools\dxexp\CMakeLists.txt
tools\dxexp\dxexp.cpp
tools\dxexp\LLVMBuild.txt