Commit Graph

422165 Commits

Author SHA1 Message Date
Florian Hahn 6a6cc5542b
[SimpleLoopUnswitch] Enable freezing of conditions by default.
This fixes a series of mis-compiles by SimpleLoopUnswitch.

My measurements showed no performance regression with -O3 on AArch64
in SPEC2006, SPEC2017 and a set of internal benchmarks.

Fixes #50387, #50430

Depends on D124251.

Reviewed By: nikic, aqjune

Differential Revision: https://reviews.llvm.org/D124252
2022-04-25 14:26:41 +01:00
Nikolas Klauser 6b257af822 [libc++] Fix C++03 with the unstable ABI enabled 2022-04-25 15:17:24 +02:00
Jeremy Morse 13815e8cbf Revert "[DebugInfo][InstrRef] Add a size operand to DBG_PHI"
This reverts commit fda4305e53.

Green dragon has spotted a problem -- it's understood, but might be fiddly
to fix, reverting in the meantime.
2022-04-25 14:06:12 +01:00
Nico Weber 36ba89b5b3 Revert "[sanitizer] Use canonical syscalls everywhere"
This reverts commit 34b676eb60.
Speculative, might have caused test problems on Android.
2022-04-25 08:49:16 -04:00
Jeremy Morse fda4305e53 [DebugInfo][InstrRef] Add a size operand to DBG_PHI
DBG_PHI instructions can refer to stack slots, to indicate that multiple
values merge together on control flow joins in that slot. This is fine --
however the slot might be merged at a later date with a slot of a different
size. In doing so, we lose information about the size the eliminated PHI.
Later analysis passes have to guess.

Improve this by attaching an optional "bit size" operand to DBG_PHI, which
only gets added for stack slots, to let us know how large a size the value
on the stack is.

Differential Revision: https://reviews.llvm.org/D124184
2022-04-25 13:41:34 +01:00
Sam McCall 00f0c805ff [Frontend] shrink in-memory PCH buffers to fit
After building a PCH, the vector capacity is on average ~1/3 unused.
If we're going to keep it in memory for a while, reallocate to the right size.
Take care to do this once clang is destroyed so that we can reuse its
memory rather than requesting more.

Differential Revision: https://reviews.llvm.org/D124242
2022-04-25 14:31:14 +02:00
Nikita Popov e8945110d2 [InstCombine] Remove redundant unsigned underflow fold (NFCI)
This is now handled as a combination of two other folds:
(A+B) <= A & (A+B) != 0  -->  (A+B)-1 < A
(A+B)-1 < A  -->  -B < A
2022-04-25 14:22:43 +02:00
Mariusz Sikora d1762fc454 [AMDGPU] Use d16 flag for image.sample instructions
Image.sample instruction can be forced to return half type instead of
float when d16 flag is enabled.

This patch adds new pattern in InstCombine to detect if output of
image.sample is used later only by fptrunc which converts the type
from float to half. If pattern is detected then fptrunc and image.sample
are combined to single image.sample which is returning half type.
Later in Lowering part d16 flag is added to image sample intrinsic.

Differential Revision: https://reviews.llvm.org/D124232
2022-04-25 13:05:52 +01:00
Luo, Yuanke c712bf3ce4 [X86][AMX] Add test case for D124378. 2022-04-25 20:03:27 +08:00
Andrzej Warzynski 97a32d3e43 [flang][driver] Add support for generating executables
This patch adds 2 missing items required for `flang-new` to be able to
generate executables:

1. The Fortran_main runtime library, which implements the main entry
   point into Fortran's `PROGRAM` in Flang,

2. Extra linker flags to include Fortran runtime libraries (e.g.
   Fortran_main).

Fortran_main is the bridge between object files generated by Flang and
the C runtime that takes care of program set-up at system-level. For
every Fortran `PROGRAM`, Flang generates the `_QQmain` function.
Fortran_main implements the C `main` function that simply calls
`_QQmain`.

Additionally, "<driver-path>/../lib" directory is added to the list of
search directories for libraries. This is where the required runtime
libraries are currently located. Note that this the case for the build
directory. We haven't considered installation directories/targets yet.

With this change, you can generate an executable that will print `hello,
world!` as follows:

```bash
$ cat hello.f95
PROGRAM HELLO
  write(*, *) "hello, world!"
END PROGRAM HELLO
$ flang-new -flang-experimental-exec hello.f95
./a.out
hello, world!
```

NOTE 1: Fortran_main has to be a static library at all times. It invokes
`_QQmain`, which is the main entry point generated by Flang for the
given input file (you can check this with `flang-new -S hello.f95 -o - |
grep "Qmain"`). This means that Fortran_main has an unresolved
dependency at build time. The linker will allow this for a static
library. However, if Fortran_main was a shared object, then the linker
will produce an error: `undefined symbol: `_QQmain`.

NOTE 2: When Fortran runtime libraries are generated as shared libraries
(excluding Fortran_main, which is always static), you will need to
tell the dynamic linker (by e.g. tweaking LD_LIBRARY_PATH) where to look
for them when invoking the executables. For example:
```bash
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:<flang-build-dir>/lib/ ./a.out
```

NOTE 3: This feature is considered experimental and currently guarded
with a flag: `-flang-experimental-exec`.

Differential Revision: https://reviews.llvm.org/D122008

[1] https://github.com/flang-compiler/f18-llvm-project

CREDITS: Fortran_main was originally written by Eric Schweitz, Jean
Perier, Peter Klausler and Steve Scalpone in the fir-dev` branch in [1].

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: Peter Klausler <pklausler@nvidia.com>
Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Steve Scalpone <sscalpone@nvidia.com
2022-04-25 12:00:23 +00:00
Florian Hahn 2fee8dd621
[SimpleLoopUnswitch] Run LICM for nested unswitching tests.
When enabling freeze-loop-unswitch-cond the inserted freeze instruction
may block unswitching of parent loops if they get inserted in a block in
the parent loop (as the llvm::Loop-based invariance check only checks
 whether an instruction is in a loop block or not).

In the optimization pipeline, LICM is responsible to hoist out loop
invariant instructions to enable further unswitching. Also run LICM for
nested unswitching tests in preparation for flipping the default of
freeze-loop-unswitch-cond.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D124251
2022-04-25 12:49:08 +01:00
Simon Pilgrim 7ddf39bc1d [X86][AVX] Add shuffle test case for Issue #55066 2022-04-25 12:17:32 +01:00
Nikita Popov ee50925894 [InstCombine] Fold (X != 0) & (Y u>= X)
This adds the De Morgan conjugated fold for the existing
(X == 0) | (Y u< X) fold.

Proof: https://alive2.llvm.org/ce/z/3Me3JQ
2022-04-25 13:16:47 +02:00
Nico Weber 010acc52a8 [lld/mac] Revert libcompiler_rt.dylib version check change
This reverts D117925 since it's no longer needed after D124336.

Differential Revision: https://reviews.llvm.org/D124354
2022-04-25 06:55:49 -04:00
Nikita Popov 2bec8d6d59 [InstCombine] Fold X + Y + C u< X
This is a variation on the X + Y u< X fold with an extra constant.
Proof: https://alive2.llvm.org/ce/z/VNb8pY
2022-04-25 12:53:39 +02:00
Nikita Popov e38b1f7d09 [InstCombine] Add additional tests for X + Y + C u< X (NFC)
We don't actually need the limitation for C == -1, so update test
naming accordingly, and also test a non-uniform vector constant.
2022-04-25 12:50:15 +02:00
Max Kazantsev 606a000d1a [LoopInstSimplify] Ignore users in unreachable blocks. PR55072
Logic in this pass assumes that all users of loop instructions are
either in the same loop or are LCSSA Phis. In fact, there can also
be users in unreachable blocks that currently break assertions.
Such users don't need to go to the next round of simplifications.

Reviewed By: fhahn
Differential Revision: https://reviews.llvm.org/D124368
2022-04-25 17:35:28 +07:00
Florian Hahn b00fd35277
[LangRef] Limit readnone,read/writeonly to memory visible outside the fn
This patch unifies the wording used for readnone, readonly and writeonly
attributes. The definitions now more specifically refer to memory visible
outside the function

The motivation for the clarification is D123473.

Reviewed By: nlopes

Differential Revision: https://reviews.llvm.org/D124124
2022-04-25 11:32:50 +01:00
LLVM GN Syncbot ea8cbd5c58 [gn build] Port 042dc3c46d 2022-04-25 10:26:57 +00:00
Markus Böck 12a2716953 [mlir][LLVM] Support opaque pointers in `llvm.mlir.addressof`
The verifier of llvm.mlir.addressof did not properly account for opaque pointers, that is, the pointer type not having an element type equal to the type of the referenced global or function. This patch fixes that by skipping the test for the element type if the pointer is opaque.

Differential Revision: https://reviews.llvm.org/D124333
2022-04-25 12:23:16 +02:00
Hui Xie 042dc3c46d [libc++] add zip_view and views::zip for C++23
- add zip_view and views::zip for C++23
- added unit tests
- implemented section 5.6 (zip) in P2321R2

I used clang-format to format the files but they look nothing like the rest of the code base. Manually indenting each line to match the styles sounds like an impossible task. Is there any clang-format file which can format it reasonable similar to the rest of the code base so that I can manually format the rest lines that look weird?

Reviewed By: ldionne, #libc, philnik, var-const

Spies: Mordante, philnik, libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D122806
2022-04-25 12:22:22 +02:00
Nikita Popov 04f78947e4 [InstCombine] Add tests for X + Y - 1 u< X (NFC) 2022-04-25 12:21:40 +02:00
Max Kazantsev ab17873ee6 [Test] Simplify test for PR55072 2022-04-25 17:20:34 +07:00
Sam McCall 0cd5cd19af [Serialization] write expr dependence bits as a single integer
When exprs are written unabbreviated:
  - these were encoded as 5 x vbr6 = 30 bits
  - now they fit exactly into a one-chunk vbr = 6 bits

clangd --check=clangd/AST.cpp reports ~1% reduction in PCH size
(42826720->42474460)

Differential Revision: https://reviews.llvm.org/D124250
2022-04-25 12:09:40 +02:00
Alex Zinenko 4c807f2f57 [mlir][vector] insert `alloca`s outside of loops
After https://reviews.llvm.org/D119743 added the `AutomaticAllocationScope`
trait to loop-like constructs, the vector transfer full/partial splitting pass
started inserting allocations for temporaries within the closest loop rather
than the closest function (or other allocation scope such as `async.execute`).
While this is correct as long as the lowered code takes care of automatic
deallocation at the end of each iteration of the loop, this interferes with
downstream optimizations that expect `alloca`s to be at the function level.
Step over loops when looking for the closest allocation scope in vector
transfer full/partial splitting pass thus restoring the original behavior.

Reviewed By: hanchung

Differential Revision: https://reviews.llvm.org/D124366
2022-04-25 10:49:09 +02:00
Florian Hahn 0a5db8912c
[MemorySSA] Use -simple-loop-unswitch instead of -loop-unswitch in test. 2022-04-25 09:22:52 +01:00
Martin Storsjö 9a7339c997 [runtimes] [CMake] Rename a cmake variable missed in b3df14b6c9
This was missed as this check only is executed if linking doesn't
work without it.
2022-04-25 11:22:38 +03:00
Max Kazantsev 8ac447adc8 [Test] Add test for PR55072 2022-04-25 15:18:51 +07:00
Florian Hahn cd81ecba2c
[MemorySSA] Generate check lines for test.
This is to ensure we produce the same code when switching to
SimpleLoopUnswitch.
2022-04-25 09:02:42 +01:00
Adrian Kuegel c2a8490193 [mlir][Bazel] Add missing dependencies.
When building with layering_check enabled, there needs to be a
dependency for each header include.
2022-04-25 09:24:07 +02:00
Jean Perier fca52e8218 [flang] fix LBOUND lowering with KIND and no DIM arguments
The lowering code was mistakenly assuming that the second argument
in the signature provided by semantics is the DIM argument. This
caused calls with a KIND argument but no DIM to be lowered as if the
KIND argument was DIM.

Differential Revision: https://reviews.llvm.org/D124243
2022-04-25 09:20:51 +02:00
Markus Böck 34312f1f0c [mlir][LLVM] Support opaque pointers in data layout entries
This is likely preferable to having it crash if one were to specify an opaque pointer type, and the actual element type is unused either way.

Differential Revision: https://reviews.llvm.org/D124334
2022-04-25 09:14:33 +02:00
Jun Zhang e33867a434
Fix an issue in comment. NFC
I think the author renamed the function but forgot to update the
comment.
Signed-off-by: Jun Zhang <jun@junz.org>
2022-04-25 12:45:39 +08:00
Shraiysh Vaishay a5c52ff0d4 [OpenMP][IRBuilder] Handle unexcuted EXPECT_FALSE
This patch addresses the comment about unexecuted test in D122371.

Reviewed By: probinson

Differential Revision: https://reviews.llvm.org/D123920
2022-04-25 09:08:29 +05:30
Chenbing Zheng 5805cfb901 [InstCombine] Complete folding of fneg-of-fabs
This patch add a function foldSelectWithFCmpToFabs, and do more combine for
fneg-of-fabs.
With 'nsz':
fold (X <  +/-0.0) ? X : -X or (X <= +/-0.0) ? X : -X to -fabs(x)
fold (X >  +/-0.0) ? X : -X or (X >= +/-0.0) ? X : -X to -fabs(x)

Reviewed By: spatel

Differential Revision: https://reviews.llvm.org/D123830
2022-04-25 09:53:36 +08:00
Brad Smith d13f502389 [libcxx] random_device, use arc4random() on FreeBSD, NetBSD and DragonFlyBSD
Reviewed By: ldionne, emaste, dim

Differential Revision: https://reviews.llvm.org/D122628
2022-04-24 21:45:49 -04:00
sstwcw c261f78d05 [clang-format] Refactor determineStarAmpUsage NFC
There was some duplicate code in determineStarAmpUsage and
determinePlusMinusCaretUsage

Now a `-` or `+` following `;`, `sizeof`, `co_await`, or `delete` is
regarded as a unary operator.

Now a `*` or `&` following `case` is also a unary operator.

Reviewed By: curdeius, MyDeveloperDay, HazardyKnusperkeks

Differential Revision: https://reviews.llvm.org/D121754
2022-04-24 22:30:22 +00:00
Aaron Puchert ac5f7be6a8 Move test/.gitattributes to clang-tools-extra/test
It was probably accidentally added there, see the discussion on change
D97625. It is certainly without effect, to quote gitattributes(5):

    When deciding what attributes are assigned to a path, Git consults
    [...], `.gitattributes` file in the same directory as the path in
    question, and its parent directories up to the toplevel of the work
    tree [...]

Running `git check-attr -a` on the files in question shows that now the
settings are indeed effective whereas before they were not.

Lastly, lit ignores the file like any dotfile, see getTestsInDirectory
of FileBasedTest in llvm/utils/lit/lit/formats/base.py. This can be
verified with `llvm-lit --show-tests clang-tools-extra/test`.
2022-04-24 22:30:25 +02:00
Valentin Clement (バレンタイン クレメン) 6243b90ead
[flang] Do not create arith.extui with same from/to type
In some case the lowering of `ichar` is generating an `arith.extui` operation
with the same from/to type. This operation do not accept from/to types to be
the same. If the from/to types are identical, we do not generate the extra
operation.

Reviewed By: jeanPerier

Differential Revision: https://reviews.llvm.org/D124107
2022-04-24 20:37:48 +02:00
Jonas Toth 3f0f203666 run-clang-tidy: Fix infinite loop on windows
`find_compilation_database` checked only for "/" as exit point, but on Windows, this root is impossible.
Fixes #53642

Authored By: Febbe
Reviewed By: JonasToth
Differential Revision: https://reviews.llvm.org/D119481
2022-04-24 17:17:02 +02:00
Matt Arsenault 49aeeafda3 llvm-reduce: Don't delete triple/datalayout
Removing these is extremely unhelpful and just adds extra hassle. This
is really finding out whether your test script uses -mtriple or
not. You can't meaningfully delete these fields, and the resulting
module defaults to the host.
2022-04-24 11:01:31 -04:00
Petr Hosek b3df14b6c9 [runtimes] [CMake] Unify variable names
Avoid repeating CMake checks across runtimes by unifying names of
variables used for results to leverage CMake caching.

Differential Revision: https://reviews.llvm.org/D110005
2022-04-24 13:06:36 +03:00
Chenbing Zheng 2fc67af487 [InstCombine] Add test for fold fcmp-of-copysign. nfc
Add more tests with differert predicates.
2022-04-24 17:26:15 +08:00
Vince Bridgers 3566bbe62f [analyzer] Add option for AddrSpace in core.NullDereference check
This change adds an option to detect all null dereferences for
    non-default address spaces, except for address spaces 256, 257 and 258.
    Those address spaces are special since null dereferences are not errors.

    All address spaces can be considered (except for 256, 257, and 258) by
    using -analyzer-config
    core.NullDereference:DetectAllNullDereferences=true. This option is
    false by default, retaining the original behavior.

    A LIT test was enhanced to cover this case, and the rst documentation
    was updated to describe this behavior.

Reviewed By: steakhal

Differential Revision: https://reviews.llvm.org/D122841
2022-04-24 03:51:49 -05:00
wangpc 7a21a0525a [RISCV] Add sched to pseudo function call instructions
To fix llvm-mca's error of 'found an unsupported instruction
in the input assembly sequence.' caused by the lack of
scheduling info.

Pseudo function call instructions will be expanded to `auipc`
and `jalr`, so their scheduling info are the combination of
two.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D123578
2022-04-24 14:58:18 +08:00
Senran Zhang ae76eb32a5 [NFC][Clang][Pragma] Remove unused variables
Reviewed By: beanz

Differential Revision: https://reviews.llvm.org/D124339
2022-04-24 14:50:59 +08:00
Vaivaswatha Nagaraj fc655a0a96 [OCaml][DebugInfo] Add bindings for parameter and auto variable creation
This patch extends https://reviews.llvm.org/D90831 with a few more
functions added to the OCaml debuginfo bindings.

Differential Revision: https://reviews.llvm.org/D123914
2022-04-24 09:37:04 +05:30
Nico Weber 3254f46884 [lld/mac] For catalyst outputs, tolerate implicitly linking against mac-only tbd files
Before this,

  clang empty.cc -target x86_64-apple-ios13.1-macabi \
      -framework CoreServices -fuse-ld=lld

would error out with

    ld64.lld: error: path/to/MacOSX.sdk/System/Library/Frameworks/
         CoreServices.framework/Versions/A/Frameworks/CarbonCore.framework/
         Versions/A/CarbonCore.tbd(
             /System/Library/Frameworks/
             CoreServices.framework/Versions/A/Frameworks/CarbonCore.framework/
             Versions/A/CarbonCore) is incompatible with x86_64 (macCatalyst)

Now it works, like with ld64.

Differential Revision: https://reviews.llvm.org/D124336
2022-04-23 21:43:46 -04:00
Jun Ma c0022b4bb1 [InlineCost] Set LastCallToStaticBonus in ML inlining models.
This patch set LastCallToStaticBonus based on check, it has
no noticeable size reduction on an internal workload and linux kernel
with Os/Oz.

Differential Revision: https://reviews.llvm.org/D124233
2022-04-24 09:34:19 +08:00
Nick Kreeger 4620032ee3 Revert "[mlir][sparse] Expose SpareTensor passes as enums instead of opaque numbers for vectorization and parallelization options."
This reverts commit d59cf901cb.

Build fails on NVIDIA Sparse tests:
https://lab.llvm.org/buildbot/#/builders/61/builds/25447
2022-04-23 20:14:48 -05:00