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

25 Коммитов

Автор SHA1 Сообщение Дата
Xiang Li 72b353a345
[tools] add -help option for opt. (#7002)
Add -help option to opt in opt.cpp.

The -help option for opt in clean llvm3.7 was disabled with 
[disable
-help](d5bb3089cf (diff-1c7e1b16bc72f52ebd811ef2a24aa91fc4df0f9b47c279b75d0bbb0ae1684d0aR1719))

Fixes #5514
2024-11-16 02:59:29 +00:00
David Neto d324261642
Reassociation: fix counting of constant multiplicative factors (#6830)
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
2024-08-01 11:41:05 -04:00
Zhengxing li b79169bc85
[llc/opt] Add an option to run all passes twice (#6666)
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>
2024-06-24 15:03:08 -07:00
David Neto 393b759c8a
indvars: don't replace a phi when that breaks LCSSA (#6695)
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.
2024-06-17 20:56:16 -04:00
David Neto 206b7c2e53
Remove unstructured loop exits: Don't introduce loops (#6676)
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
2024-06-14 09:43:50 -04:00
Antonio Maiorano 3dc67421ba
Revert "Fix RemoveUnstructuredLoopExits when an exiting edge jumps out multiple levels of loops. (#6668)" (#6685)
This reverts commit 8206fbdc7f.

Reason for revert: since landing this, new asserts/crashes have been
found.
2024-06-11 18:39:57 +00:00
David Neto 8206fbdc7f
Fix RemoveUnstructuredLoopExits when an exiting edge jumps out multiple levels of loops. (#6668)
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.
2024-06-06 10:56:13 -05:00
David Neto 3a78b67849
NFC: Comment, refactor, and test hlsl::RemoveUnstructuredLoopExits (#6655)
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.
2024-05-30 09:43:39 -04:00
Zhengxing li 6f9c107b78
Reassociate: add global reassociation algorithm (#6598)
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.
2024-05-21 11:55:40 -07:00
Chris B 01007bcd7f
Add local lit config to re-enable reassociate tests (#6605)
This change adds a local lit configuration file to re-enable the
reassociate pass tests.
2024-05-10 11:57:10 -05:00
David Peixotto 481090a822
[bug] Fix crash when lowering multi-dimension groupshared variable (#5895)
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.
2023-10-23 11:00:36 -07:00
Chris B ffd4fee5e1
[Instcombine] Disable bswap match for DXIL (#5899)
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
2023-10-20 13:31:00 -05:00
Chris B 9998ec138b
Enable `.ll` test suffix for LLVM tests (#5887)
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.
2023-10-18 11:55:53 -05:00
David Peixotto 7efd6ee468
[bug] Fix crash in dxilgen when buffer subscript gep feeds an lcssa phi (#5570)
[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).
2023-08-25 05:54:10 +00:00
Helena Kotas b503da7084
DXC Tests: Filter out unsupported test, add verbose option and improve output (#5537)
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.
2023-08-18 10:56:52 -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
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
Chris B ce495eb611
Fix last LLVM tests on Windows (#4829)
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
2022-12-02 15:42:58 -06:00
Chris B 36fdecf357
Update Linux build and test workflows to use lit (#4836)
* 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.
2022-12-02 12:55:14 -06:00
Chris B ea3c096960
Disable LLVM LIT suites and tests (#4827)
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.
2022-11-29 12:53:22 -06:00
Chris B 3d17803bad
Enable building LLVM testing tools (#4023)
* 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.
2021-10-21 11:31:31 -05:00
Chris B 0a0ed9f50b
Make it possible to enable building LLVM & Clang unit tests (#4020)
* 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.
2021-10-20 12:32:45 -05:00
Shoeb Patel 9bcb3a5b81 Updated comment to fix typo (#1637) 2018-11-13 11:06:23 -08:00
David Peixotto f805233b49 Revert license text in banner comments to original llvm verbage (#33)
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
2017-01-24 17:54:00 -08:00
Marcelo Lopez Ruiz 6ee4074a4b first commit 2016-12-28 11:52:27 -08:00