platform/upstream/llvm.git
17 months ago[flang] Add Count to simplified intrinsics
Sacha Ballantyne [Fri, 27 Jan 2023 15:31:42 +0000 (15:31 +0000)]
[flang] Add Count to simplified intrinsics

This patch adds a simplfiied version of count for the simplify intrinsics pass, allowing the function to be inlined.

This was done specifically to help improve performance for exchange2, and provides a ~12% performance increase.

Reviewed By: vzakhari, Leporacanthicus

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

17 months ago[gn] merge 650bbc56203c9
Nico Weber [Fri, 27 Jan 2023 16:26:55 +0000 (11:26 -0500)]
[gn] merge 650bbc56203c9

Needed to link e.g. LexTests after ca446037af0.

17 months agoCorrect the link to the latest C DR status page for C11 and C17
Aaron Ballman [Fri, 27 Jan 2023 16:17:42 +0000 (11:17 -0500)]
Correct the link to the latest C DR status page for C11 and C17

We were linking against:
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2148.htm

However, the latest DR page for the 400s is:
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2396.htm

17 months ago[libc][math] Implement asinhf function correctly rounded for all rounding modes.
Tue Ly [Fri, 27 Jan 2023 15:15:46 +0000 (10:15 -0500)]
[libc][math] Implement asinhf function correctly rounded for all rounding modes.

Implement asinhf function correctly rounded for all rounding modes.

Reviewed By: zimmermann6

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

17 months ago[libc++] Disables a test in clang-17.
Mark de Wever [Fri, 27 Jan 2023 16:01:55 +0000 (17:01 +0100)]
[libc++] Disables a test in clang-17.

This test already had issues and bumping main to 17 causes them to fail
again.

17 months ago[SCCP] Add test cases with switch on range containing undef.
Florian Hahn [Fri, 27 Jan 2023 16:02:29 +0000 (16:02 +0000)]
[SCCP] Add test cases with switch on range containing undef.

17 months agoStop diagnosing member and array access in offsetof as an extension
Aaron Ballman [Fri, 27 Jan 2023 16:01:12 +0000 (11:01 -0500)]
Stop diagnosing member and array access in offsetof as an extension

This was a mistake from e7300e75b51a7e7d4e81975b4be7a6c65f9a8286
(https://reviews.llvm.org/D133574) caused by us accidentally tracking
an older copy of the C DR list for DR496. The text in
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2396.htm#dr_496 makes
it clear that subobjects are allowed, which means member and array
access expressions are allowed.

This backs out the changes from the previous commit that relate to this
diagnostic.

17 months ago[gn] port a3b0dde4edb9 (llvm-cov -> Debuginfod dep)
Nico Weber [Fri, 27 Jan 2023 15:59:54 +0000 (10:59 -0500)]
[gn] port a3b0dde4edb9 (llvm-cov -> Debuginfod dep)

17 months agoRevert "[DAGCombine] fp_to_sint isSaturatingMinMax"
Samuel Parker [Fri, 27 Jan 2023 15:31:54 +0000 (15:31 +0000)]
Revert "[DAGCombine] fp_to_sint isSaturatingMinMax"

This reverts commit 85395af27241ab9c8d5763b8afcaa07f1bab26d5.

This is causing trouble with scalable vectors.

17 months ago[NFC][AArch64] Get extension strings directly from ArchInfo in target parser
Lucas Prates [Wed, 25 Jan 2023 12:15:00 +0000 (12:15 +0000)]
[NFC][AArch64] Get extension strings directly from ArchInfo in target parser

Reviewed By: tmatheson

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

17 months ago[libc][cmake] Fix LIBC_TARGET_OS query from compiler triple for `darwin`.
Tue Ly [Mon, 9 Jan 2023 15:05:41 +0000 (10:05 -0500)]
[libc][cmake] Fix LIBC_TARGET_OS query from compiler triple for `darwin`.

Currently LIBC_TARGET_OS query from compiler triple returns `apple` for
macOS.  This change will fix it back to `darwin` as before.

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

17 months agoWorkflows: Fix version-check.py script for when there is no RC tag yet
Tom Stellard [Fri, 27 Jan 2023 14:57:35 +0000 (06:57 -0800)]
Workflows: Fix version-check.py script for when there is no RC tag yet

Reviewed By: thieta

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

17 months ago[mlir] GreedyPatternRewriteDriver: Move strict mode to GreedyPatternRewriteDriver
Matthias Springer [Fri, 27 Jan 2023 14:44:12 +0000 (15:44 +0100)]
[mlir] GreedyPatternRewriteDriver: Move strict mode to GreedyPatternRewriteDriver

`strictMode` is moved to GreedyRewriteConfig to simplify the API and state of rewriter classes. The region-based GreedyPatternRewriteDriver now also supports strict mode.

MultiOpPatternRewriteDriver becomes simpler: fewer method must be overridden.

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

17 months ago[SCCP] Use range info to prove AddInst has NSW flag.
Florian Hahn [Fri, 27 Jan 2023 14:09:25 +0000 (14:09 +0000)]
[SCCP] Use range info to prove AddInst has NSW flag.

This patch updates SCCP to use the value ranges of AddInst operands to
try to prove the AddInst does not overflow in the signed sense and
adds the NSW flag. The reasoning is done with
makeGuaranteedNoWrapRegion (thanks @nikic for point it out!).

Follow-ups will include extending this to more
OverflowingBinaryOperators.

Depends on D142387.

Reviewed By: nikic

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

17 months ago[mlir] GreedyPatternRewriteDriver: All entry points take a config
Matthias Springer [Fri, 27 Jan 2023 13:14:41 +0000 (14:14 +0100)]
[mlir] GreedyPatternRewriteDriver: All entry points take a config

The multi-op entry point now also takes a GreedyPatternRewriteConfig and respects config.maxNumRewrites. The scope is also a part of the config now.

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

17 months ago[lldb][Target] GetScratchTypeSystems: sort TypeSystems with strict weak ordering
Michael Buch [Fri, 27 Jan 2023 13:03:57 +0000 (13:03 +0000)]
[lldb][Target] GetScratchTypeSystems: sort TypeSystems with strict weak ordering

`std::sort` requires a comparison operator that obides by strict weak
ordering. `operator<=` on pointer does not and leads to undefined
behaviour. Specifically, when we grow the `scratch_type_systems` vector
slightly larger (and thus take `std::sort` down a slightly different
codepath), we segfault. This happened while working on a patch that
would in fact grow this vector. In such a case ASAN reports:

```
$ ./bin/lldb ./lldb-test-build.noindex/lang/cpp/complete-type-check/TestCppIsTypeComplete.test_builtin_types/a.out -o "script -- lldb.target.FindFirstType(\"void\")"
(lldb) script -- lldb.target.FindFirstType("void")
=================================================================
==59975==ERROR: AddressSanitizer: container-overflow on address 0x000108f6b510 at pc 0x000280177b4c bp 0x00016b7d7430 sp 0x00016b7d7428
READ of size 8 at 0x000108f6b510 thread T0
    #0 0x280177b48 in std::__1::shared_ptr<lldb_private::TypeSystem>::shared_ptr[abi:v15006](std::__1::shared_ptr<lldb_private::TypeSystem> const&)+0xb4 (/Users/michaelbuch/Git/lldb-build-main-no-modules/lib/liblldb.17.0.0git.dylib:arm64+0x177b48)
(BuildId: ea963d2c0d47354fb647f5c5f32b76d932000000200000000100000000000d00)
    #1 0x280dcc008 in void std::__1::__introsort<std::__1::_ClassicAlgPolicy, lldb_private::Target::GetScratchTypeSystems(bool)::$_3&, std::__1::shared_ptr<lldb_private::TypeSystem>*>(std::__1::shared_ptr<lldb_private::TypeSystem>*, std::__1::shared_
ptr<lldb_private::TypeSystem>*, lldb_private::Target::GetScratchTypeSystems(bool)::$_3&, std::__1::iterator_traits<std::__1::shared_ptr<lldb_private::TypeSystem>*>::difference_type)+0x1050 (/Users/michaelbuch/Git/lldb-build-main-no-modules/lib/liblld
b.17.0.0git.dylib:arm64+0xdcc008) (BuildId: ea963d2c0d47354fb647f5c5f32b76d932000000200000000100000000000d00)
    #2 0x280d88788 in lldb_private::Target::GetScratchTypeSystems(bool)+0x5a4 (/Users/michaelbuch/Git/lldb-build-main-no-modules/lib/liblldb.17.0.0git.dylib:arm64+0xd88788) (BuildId: ea963d2c0d47354fb647f5c5f32b76d932000000200000000100000000000d00)
    #3 0x28021f0b4 in lldb::SBTarget::FindFirstType(char const*)+0x624 (/Users/michaelbuch/Git/lldb-build-main-no-modules/lib/liblldb.17.0.0git.dylib:arm64+0x21f0b4) (BuildId: ea963d2c0d47354fb647f5c5f32b76d932000000200000000100000000000d00)
    #4 0x2804e9590 in _wrap_SBTarget_FindFirstType(_object*, _object*)+0x26c (/Users/michaelbuch/Git/lldb-build-main-no-modules/lib/liblldb.17.0.0git.dylib:arm64+0x4e9590) (BuildId: ea963d2c0d47354fb647f5c5f32b76d932000000200000000100000000000d00)
    #5 0x1062d3ad4 in cfunction_call+0x5c (/opt/homebrew/Cellar/python@3.11/3.11.1/Frameworks/Python.framework/Versions/3.11/Python:arm64+0xcfad4) (BuildId: c9efc4bbb1943f9a9b7cc4e91fce477732000000200000000100000000000d00)

<--- snipped --->

0x000108f6b510 is located 400 bytes inside of 512-byte region [0x000108f6b380,0x000108f6b580)
allocated by thread T0 here:
    #0 0x105209414 in wrap__Znwm+0x74 (/Applications/Xcode2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/14.0.3/lib/darwin/libclang_rt.asan_osx_dynamic.dylib:arm64e+0x51414) (BuildId: 0a44828ceb64337bbfff60b22cd838f0320000
00200000000100000000000b00)
    #1 0x280dca3b4 in std::__1::__split_buffer<std::__1::shared_ptr<lldb_private::TypeSystem>, std::__1::allocator<std::__1::shared_ptr<lldb_private::TypeSystem>>&>::__split_buffer(unsigned long, unsigned long, std::__1::allocator<std::__1::shared_pt
r<lldb_private::TypeSystem>>&)+0x11c (/Users/michaelbuch/Git/lldb-build-main-no-modules/lib/liblldb.17.0.0git.dylib:arm64+0xdca3b4) (BuildId: ea963d2c0d47354fb647f5c5f32b76d932000000200000000100000000000d00)
    #2 0x280dc978c in void std::__1::vector<std::__1::shared_ptr<lldb_private::TypeSystem>, std::__1::allocator<std::__1::shared_ptr<lldb_private::TypeSystem>>>::__push_back_slow_path<std::__1::shared_ptr<lldb_private::TypeSystem> const&>(std::__1::s
hared_ptr<lldb_private::TypeSystem> const&)+0x13c (/Users/michaelbuch/Git/lldb-build-main-no-modules/lib/liblldb.17.0.0git.dylib:arm64+0xdc978c) (BuildId: ea963d2c0d47354fb647f5c5f32b76d932000000200000000100000000000d00)
    #3 0x280d88dec in std::__1::vector<std::__1::shared_ptr<lldb_private::TypeSystem>, std::__1::allocator<std::__1::shared_ptr<lldb_private::TypeSystem>>>::push_back[abi:v15006](std::__1::shared_ptr<lldb_private::TypeSystem> const&)+0x80 (/Users/mic
haelbuch/Git/lldb-build-main-no-modules/lib/liblldb.17.0.0git.dylib:arm64+0xd88dec) (BuildId: ea963d2c0d47354fb647f5c5f32b76d932000000200000000100000000000d00)
    #4 0x280d8857c in lldb_private::Target::GetScratchTypeSystems(bool)+0x398 (/Users/michaelbuch/Git/lldb-build-main-no-modules/lib/liblldb.17.0.0git.dylib:arm64+0xd8857c) (BuildId: ea963d2c0d47354fb647f5c5f32b76d932000000200000000100000000000d00)
    #5 0x28021f0b4 in lldb::SBTarget::FindFirstType(char const*)+0x624 (/Users/michaelbuch/Git/lldb-build-main-no-modules/lib/liblldb.17.0.0git.dylib:arm64+0x21f0b4) (BuildId: ea963d2c0d47354fb647f5c5f32b76d932000000200000000100000000000d00)
    #6 0x2804e9590 in _wrap_SBTarget_FindFirstType(_object*, _object*)+0x26c (/Users/michaelbuch/Git/lldb-build-main-no-modules/lib/liblldb.17.0.0git.dylib:arm64+0x4e9590) (BuildId: ea963d2c0d47354fb647f5c5f32b76d932000000200000000100000000000d00)
    #7 0x1062d3ad4 in cfunction_call+0x5c (/opt/homebrew/Cellar/python@3.11/3.11.1/Frameworks/Python.framework/Versions/3.11/Python:arm64+0xcfad4) (BuildId: c9efc4bbb1943f9a9b7cc4e91fce477732000000200000000100000000000d00)
    #8 0x10627fff0 in _PyObject_MakeTpCall+0x7c (/opt/homebrew/Cellar/python@3.11/3.11.1/Frameworks/Python.framework/Versions/3.11/Python:arm64+0x7bff0) (BuildId: c9efc4bbb1943f9a9b7cc4e91fce477732000000200000000100000000000d00)
    #9 0x106378a98 in _PyEval_EvalFrameDefault+0xbcf8 (/opt/homebrew/Cellar/python@3.11/3.11.1/Frameworks/Python.framework/Versions/3.11/Python:arm64+0x174a98) (BuildId: c9efc4bbb1943f9a9b7cc4e91fce477732000000200000000100000000000d00)
```

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

17 months ago[NFC][AArch64] Get default features directly from ArchInfo and CpuInfo objects
Lucas Prates [Tue, 24 Jan 2023 17:44:15 +0000 (17:44 +0000)]
[NFC][AArch64] Get default features directly from ArchInfo and CpuInfo objects

This updates the AArch64's Target Parser and its uses to capture
information about default features directly from ArchInfo and CpuInfo
objects, instead of relying on an API function to access them
indirectly.

Reviewed By: tmatheson

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

17 months ago[NFC][AArch64] Use optional returns in target parser instead of 'invalid' objects
Lucas Prates [Mon, 23 Jan 2023 11:12:38 +0000 (11:12 +0000)]
[NFC][AArch64] Use optional returns in target parser instead of 'invalid' objects

This updates the parsing methods in AArch64's Target Parser to make use
of optional returns instead of "invalid" enum values, making the API's
behaviour clearer.

Reviewed By: lenary, tmatheson

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

17 months agoAdd clang_CXXMethod_isExplicit to libclang
Luca Di Sera [Mon, 23 Jan 2023 12:14:17 +0000 (13:14 +0100)]
Add clang_CXXMethod_isExplicit to libclang

The new method is a wrapper of `CXXConstructorDecl::isExplicit` and
`CXXConversionDecl::isExplicit`, allowing the user to recognize whether
the declaration pointed to by a cursor was marked with the explicit
specifier.

An export for the function, together with its documentation, was added
to "clang/include/clang-c/Index.h" with an implementation provided in
"clang/tools/libclang/CIndex.cpp".

The implementation is based on similar `clang_CXXMethod`
implementations, returning a falsy unsigned value when the cursor is not
a declaration, is not a declaration for a constructor or conversion
function or is not a relevant declaration that was marked with the
`explicit` specifier.

The new symbol was added to "clang/tools/libclang/libclang.map" to be
exported, under the LLVM16 tag.

"clang/tools/c-index-test/c-index-test.c" was modified to print a
specific tag, "(explicit)", for cursors that are recognized by
`clang_CXXMethod_isExplicit`.

Two new regression files, "explicit-constructor.cpp" and
"explicit-conversion-function.cpp", were added to "clang/test/Index", to
ensure that the behavior of the new function is correct for constructors
and conversion functions, respectively.

The "get-cursor.cpp", "index-file.cpp" and
"recursive-cxx-member-calls.cpp" regression files in "clang/test/Index"
were updated as they were affected by the new "(explicit)" tag.

A binding for the new function was added to libclang's python's
bindings, in "clang/bindings/python/clang/cindex.py", as the
"is_explicit_method" method under `Cursor`.

An accompanying test was added to
"clang/bindings/python/tests/cindex/test_cursor.py", mimicking the
regression tests for the C side.

The current release note for Clang, "clang/docs/ReleaseNotes.rst" was
modified to report the new addition under the "libclang" section.

Reviewed By: aaron.ballman

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

17 months ago[Docs] Fix a statement wrt instruction alignment of 0
Shivam Gupta [Fri, 27 Jan 2023 11:59:00 +0000 (17:29 +0530)]
[Docs] Fix a statement wrt instruction alignment of 0

This fix https://github.com/llvm/llvm-project/issues/53371
Zero is not a legal alignment.

Reviewed By: nikic

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

17 months ago[flang][hlfir] Handle box and non constant must_free in end_associate.
Jean Perier [Fri, 27 Jan 2023 11:52:01 +0000 (12:52 +0100)]
[flang][hlfir] Handle box and non constant must_free in end_associate.

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

17 months ago[flang][hlfir] Handle scalar to array in hlfir.assign codegen.
Jean Perier [Fri, 27 Jan 2023 11:49:55 +0000 (12:49 +0100)]
[flang][hlfir] Handle scalar to array in hlfir.assign codegen.

The scalar must be placed in memory before creating descriptors and
calling the runtime assignment API.

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

17 months agoRevert "[lldb] Add support for DW_AT_default_value in template params"
David Spickett [Fri, 27 Jan 2023 11:13:31 +0000 (11:13 +0000)]
Revert "[lldb] Add support for DW_AT_default_value in template params"

This reverts commit 1cf52e540242f968e0cf789587bcf76c01332aeb.

Due to test failures on Arm and AArch64 bots:
https://lab.llvm.org/buildbot/#/builders/96/builds/34718

(which were obscured by an earlier build failure)

17 months ago[mlir][transforms] CSE ops with multiple regions
Matthias Springer [Fri, 27 Jan 2023 11:14:10 +0000 (12:14 +0100)]
[mlir][transforms] CSE ops with multiple regions

There were issues with the CSE equivalence analysis that have been fixed with D142558. This makes it possible to CSE ops with multiple regions.

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

17 months ago[PowerPC] ppc64-P9-vabsd.ll - add some basic ISD::ABDS test coverage
Simon Pilgrim [Fri, 27 Jan 2023 11:12:10 +0000 (11:12 +0000)]
[PowerPC] ppc64-P9-vabsd.ll - add some basic ISD::ABDS test coverage

Test coverage to ensure D142313 lowers ISD::ABDU -> VABSD but not ISD::ABDS (although I think v4i32 would be compatible with the XVNEGSP trick)

17 months ago[mlir][transforms] Simplify OperationEquivalence and CSE
Matthias Springer [Fri, 27 Jan 2023 10:49:25 +0000 (11:49 +0100)]
[mlir][transforms] Simplify OperationEquivalence and CSE

Replace `mapOperands` and `mapResults` with two new callbacks. It was not clear what "mapping" meant and why the equivalence relationship was a property of the Operand/OpResult as opposed to just SSA values.

This revision changes the contract of the two callbacks: `checkEquivalent` compares two values for equivalence. `markEquivalent` informs the caller that the analysis determined that two values are equivalent. This simplifies the API because callers do not have to reason about operands/results, but just SSA values.

`OperationEquivalence::isEquivalentTo` can be used directly in CSE and there is no need for a custom op equivalence analysis.

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

17 months ago[mlir] GreedyPatternRewriteDriver: Entry point takes single region
Matthias Springer [Fri, 27 Jan 2023 10:09:13 +0000 (11:09 +0100)]
[mlir] GreedyPatternRewriteDriver: Entry point takes single region

The rewrite driver is typically applied to a single region or all regions of the same op. There is no longer an overload to apply the rewrite driver to a list of regions.

This simplifies the rewrite driver implementation because the scope is now a single region as opposed to a list of regions.

Note: This change is not NFC because `config.maxIterations` and `config.maxNumRewrites` is now counted for each region separately. Furthermore, worklist filtering (`scope`) is now applied to each region separately.

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

17 months ago[memref][Transform][NFC] Improve the doc for masked_vectorize
Quentin Colombet [Thu, 26 Jan 2023 14:36:44 +0000 (15:36 +0100)]
[memref][Transform][NFC] Improve the doc for masked_vectorize

The `transform.structured.masked_vectorize` operator assumes that the
iteration space of the given linalg op is smaller than the given vector
sizes.
Explicitly states this requirement in the description of the operation.

Also fix the related comment and assert message in the vectorization code.
The wording was flipped.

NFC

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

17 months ago[MLIR] Fix tensor shapes in Toy chapter 1
Thomas Preud'homme [Mon, 23 Jan 2023 14:01:08 +0000 (14:01 +0000)]
[MLIR] Fix tensor shapes in Toy chapter 1

In Toy tutorial chapter 1, multiply_transpose() is called with b<2, 3>
and c<3, 2> when both parameters should have the same shape. This commit
fixes this by instead using c and d as parameters and fix a comment typo
where c and d are mentioned to have shape <2, 2> when they actually have
shape <3, 2>.

Reviewed By: mehdi_amini

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

17 months ago[mlir] GreedyPatternRewriteDriver: Make classes single-use
Matthias Springer [Fri, 27 Jan 2023 09:49:16 +0000 (10:49 +0100)]
[mlir] GreedyPatternRewriteDriver: Make classes single-use

Less mutable state, more `const`. This is to address a concern about complexity of state in D140304.

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

17 months ago[mlir][NFC] GreedyPatternRewriteDriver: Remove OpPatternRewriteDriver
Matthias Springer [Fri, 27 Jan 2023 09:41:45 +0000 (10:41 +0100)]
[mlir][NFC] GreedyPatternRewriteDriver: Remove OpPatternRewriteDriver

The `MultiOpPatternRewriteDriver` can be reused. This gives us better debug messages and more code reuse. Debug messages such as `** Replace: (op name)` were previously not printed when using the `applyOpPatternsAndFold(Operation *, ...)` overload.

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

17 months ago[mlir] GreedyPatternRewriteDriver: Enqueue ancestors in MultiOpPatternRewriteDriver
Matthias Springer [Fri, 27 Jan 2023 09:19:50 +0000 (10:19 +0100)]
[mlir] GreedyPatternRewriteDriver: Enqueue ancestors in MultiOpPatternRewriteDriver

The `GreedyPatternRewriteDriver` was extended to enqueue ancestors in D140304. With this change, `MultiOpPatternRewriteDriver` behaves the same way.

Note: `MultiOpPatternRewriteDriver` now also has a scope that limits how far we go when checking ancestors. By default, this is the first common region of all given ops.

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

17 months ago[mlir][Conversion] Rename the MemRefToLLVM pass
Quentin Colombet [Tue, 24 Jan 2023 13:05:47 +0000 (13:05 +0000)]
[mlir][Conversion] Rename the MemRefToLLVM pass

Since the recent MemRef refactoring that centralizes the lowering of
complex MemRef operations outside of the conversion framework, the
MemRefToLLVM pass doesn't directly convert these complex operations.

Instead, to fully convert the whole MemRef dialect space, MemRefToLLVM
needs to run after `expand-strided-metadata`.

Make this more obvious by changing the name of the pass and the option
associated with it from `convert-memref-to-llvm` to
`finalize-memref-to-llvm`.
The word "finalize" conveys that this pass needs to run after something
else and that something else is documented in its tablegen description.

This is a follow-up patch related to the conversation at:
https://discourse.llvm.org/t/psa-you-need-to-run-expand-strided-metadata-before-memref-to-llvm-now/66956/14

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

17 months ago[mlir] fail gracefull in CallOpSignatureConversion
Alex Zinenko [Thu, 26 Jan 2023 14:02:34 +0000 (14:02 +0000)]
[mlir] fail gracefull in CallOpSignatureConversion

Previously, the CallOpSignatureConversion pattern would assert if
function signature change affected the number of results. Fail the
pattern instead and let the caller propagate failure.

Fixes #60186.

Reviewed By: mehdi_amini

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

17 months agoRevert "[JT][CT] Preserve exisiting BPI/BFI during JumpThreading"
Evgeniy Brevnov [Fri, 27 Jan 2023 08:35:32 +0000 (15:35 +0700)]
Revert "[JT][CT] Preserve exisiting BPI/BFI during JumpThreading"

This reverts commit 26e7cb24cb5dfa560683064d37f560558f00aa67.

17 months ago[mlir][linalg] Make Linalg vectorizer lower affine.apply
Andrzej Warzynski [Mon, 23 Jan 2023 19:01:04 +0000 (19:01 +0000)]
[mlir][linalg] Make Linalg vectorizer lower affine.apply

It is possible that the input to the Linalg vectorizer contains
`affine.apply` ops (see the example in [1]). Such operations are not
vectarizable at the moment, but this can be fixed by simply converting
them to arithmetic operations. This is basically what this patch
introduces.

The IR change enabled in this patch could be part of a larger set of
"linalgOp pre-processing" transformations that happens right before
vectorization starts but after we know we can vectorize the op. I am
leaving this as a TODO.

[1] https://github.com/iree-org/iree/issues/10876.

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

17 months ago[clang][Interp][NFC] Print parent class name of methods
Timm Bäder [Thu, 26 Jan 2023 11:47:08 +0000 (12:47 +0100)]
[clang][Interp][NFC] Print parent class name of methods

in Function::dump().

17 months ago[clang][Interp][NFC] Remove an unnecessary isArray() check
Timm Bäder [Tue, 24 Jan 2023 18:58:09 +0000 (19:58 +0100)]
[clang][Interp][NFC] Remove an unnecessary isArray() check

We already do an isPrimitiveArray() check, so no need for the isArray()
check.

17 months ago[JT][CT] Preserve exisiting BPI/BFI during JumpThreading
Evgeniy Brevnov [Fri, 25 Nov 2022 10:29:27 +0000 (17:29 +0700)]
[JT][CT] Preserve exisiting BPI/BFI during JumpThreading

Currently, JT creates and updates local instances of BPI\BFI. As a result global ones have to be invalidated if JT made any changes.
In fact, JT doesn't use any information from BPI/BFI for the sake of the transformation itself. It only creates BPI/BFI to keep them up to date. But since it updates local copies (besides cases when it updates profile metadata) it just waste of time.

Current patch is a rework of D124439. D124439 makes one step and replaces local copies with global ones retrieved through AnalysisPassManager. Here we do one more step and don't create BPI/BFI if the only reason of creation is to keep BPI/BFI up to date. Overall logic is the following. If there is cached BPI/BFI then update it along the transformations. If there is no existing BPI/BFI, then create it only if it is required to update profile metadata.

Please note if BPI/BFI exists on exit from JT (either cached or created) it is always up to date and no reason to invalidate it.

Reviewed By: mkazantsev

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

17 months ago[clang][Interp][NFC] Add GetPtrBasePop opcode
Timm Bäder [Thu, 5 Jan 2023 11:55:29 +0000 (12:55 +0100)]
[clang][Interp][NFC] Add GetPtrBasePop opcode

Change GetPtrBase to *not* pop the base pointer and add a *Pop variant.
This will be used in later patches.

17 months ago[clang][Interp] Implement __builtin_assume
Timm Bäder [Sat, 7 Jan 2023 11:05:05 +0000 (12:05 +0100)]
[clang][Interp] Implement __builtin_assume

Just ignore it.

As part of this, move the Ret and RetVoid implementation to Interp.h, so
they can be shared with InterpBuiltin.cpp.

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

17 months ago[OpenMP] Fix stack overflow for test bug54082.c
Shilei Tian [Fri, 27 Jan 2023 04:45:02 +0000 (23:45 -0500)]
[OpenMP] Fix stack overflow for test bug54082.c

When `N` is 1024, `int result[N][N]` is obviously large stack that Windows cannot support...

Fix #60326.

Reviewed By: jdoerfert

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

17 months ago[lldb][Test][NFC] TestCreateClassTemplateDecl: make variable names more readable
Michael Buch [Fri, 27 Jan 2023 03:25:16 +0000 (03:25 +0000)]
[lldb][Test][NFC] TestCreateClassTemplateDecl: make variable names more readable

Suggested in https://reviews.llvm.org/D140030

17 months ago[lldb][NFC] Build fix: use TemplateParameterInfos public APIs instead of accessing...
Michael Buch [Fri, 27 Jan 2023 03:08:39 +0000 (03:08 +0000)]
[lldb][NFC] Build fix: use TemplateParameterInfos public APIs instead of accessing private members

Fixes build failures caused by a faulty rebase
in `a29e06bbeaad7012ac85b221f1aaba3fe1d5fd35`

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

17 months ago[ReleaseNotes] Add release notes for LLDB/Clang changes to handling of defaulted...
Michael Buch [Thu, 26 Jan 2023 17:52:09 +0000 (17:52 +0000)]
[ReleaseNotes] Add release notes for LLDB/Clang changes to handling of defaulted template arguments

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

17 months ago[lldb] Add support for DW_AT_default_value in template params
Michael Buch [Sun, 15 Jan 2023 03:26:41 +0000 (03:26 +0000)]
[lldb] Add support for DW_AT_default_value in template params

**Summary**

This patch makes LLDB understand the `DW_AT_default_value` on
template argument DIEs. As a result, type summaries will no
longer contain the defaulted template arguments, reducing
noise substantially. E.g.,

Before:
```
(lldb) v nested
(std::vector<std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, std::allocator<std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator <char> > > > > >) nested = size=0 {}
```

After:
```
(lldb) v nested
(std::vector<std::vector<std::basic_string<char> > >) nested = size=0 {}
```

See discussion in https://reviews.llvm.org/D140423

**Testing**

* Adjust API tests
* Added unit-test

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

17 months ago[lldb][TypeSystemClang][NFC] Make TemplateParameterInfos members private
Michael Buch [Sat, 17 Dec 2022 17:32:51 +0000 (17:32 +0000)]
[lldb][TypeSystemClang][NFC] Make TemplateParameterInfos members private

This patch makes the members of `TemplateParameterInfos` only accessible
via public APIs. The motivation for this is that
`TemplateParameterInfos` attempts to maintain two vectors in tandem
(`args` for the template arguments and `names` for the corresponding
name). Working with this structure as it's currently designed makes
it easy to run into out-of-bounds accesses later down the line.

This patch proposes to introduce a new
`TemplateParameterInfos::InsertArg` which is the only way to
set the `TemplateArgument` and name of an entry and since we
require both to be specified we maintain the vectors in sync
out-of-the-box.

To avoid adding non-const getters just for unit-tests a new
`TemplateParameterInfosManipulatorForTests` is introduced
that can be used to control internal state from tests.

17 months ago[clang][DebugInfo] Check TemplateArgument::IsDefaulted
Michael Buch [Sat, 21 Jan 2023 01:49:14 +0000 (01:49 +0000)]
[clang][DebugInfo] Check TemplateArgument::IsDefaulted

Since `ClassTemplateSpecializationDecl`s now set the
`TemplateArgument::IsDefaulted` bit, there's no need
to derive it here.

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

17 months ago[clang][TypePrinter] Test TemplateArgument::IsDefaulted when omitting default arguments
Michael Buch [Sun, 15 Jan 2023 03:37:09 +0000 (03:37 +0000)]
[clang][TypePrinter] Test TemplateArgument::IsDefaulted when omitting default arguments

**Summary**

This patch allows clients who can't properly construct
a `ClassTemplateDecl` to still benefit from the `clang::TypePrinter`s
ability to skip printing defaulted template arguments. The
clients simply have to call `TemplateArgument::setIsDefaulted`
in advance.

See discussion in https://reviews.llvm.org/D140423

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

17 months ago[clang][TemplateBase] Add IsDefaulted bit to TemplateArgument
Michael Buch [Sun, 15 Jan 2023 03:36:50 +0000 (03:36 +0000)]
[clang][TemplateBase] Add IsDefaulted bit to TemplateArgument

**Summary**

This patch adds a `IsDefaulted` field to `clang::TemplateArgument`.

To prevent memory footprint increase we still 1 bit from `ArgKind`.

**Changes**

1. `getIsDefaulted`/`setIsDefaulted` to allow clients to communicate
   an argument's defaulted-ness to the TypePrinter
2. The `TemplateArgument` properties description had to be changed
   to make sure we correctly mark the defaulted-ness of arguments
   that came from a deserialized AST (caught by the HLSL test-suite)
3. The `TemplateArgument` constructors now accept a `IsDefaulted`
   parameter to simplify construction from the tablegen description.
   Though if people don't want to clutter the constructors we can
   instead call `setIsDefaulted` from tablegen
4. When `clang::Sema` checks the template arguments against template
   parameters we now call `setIsDefaulted`. This makes sure that
   whenever a specialization decl gets constructed, the defaulted-ness
   of the associated `TemplateArgument`s has already been deduced.
   This preserves the immutability of `TemplateArgumentList`s

**Background**

In LLDB we construct ASTs from debug-info and hand it to clang
to perform actions such as printing/formatting a typenames.
Some debug formats, specifically DWARF, may only encode information
about class template instantiations, losing the structure of the generic
class definition. However, the `clang::TypePrinter` needs a properly
constructed `ClassTemplateDecl` with generic default argument decls
to be able to deduce whether a `ClassTemplateSpecializationDecl` was
instantiatiated with `TemplateArgument`s that correspond to the
defaults. LLDB does know whether a particular template argument was
defaulted, but can't currently tell clang about it.

This patch allows LLDB to set the defaulted-ness of a `TemplateArgument`
and thus benefit more from `clang::TypePrinter`.

See discussion in https://reviews.llvm.org/D140423

**Testing**

* Added unit-test
* LLDB/clang/llvm test-suite passes

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

17 months ago[clang][TypePrinter] Support expression template arguments when checking defaultedness
Michael Buch [Wed, 25 Jan 2023 17:09:06 +0000 (17:09 +0000)]
[clang][TypePrinter] Support expression template arguments when checking defaultedness

This patch adds support for `TemplateArgument`s of kind
`TemplateArgument::Expression` to `clang::isSubstitutedDefaultArgument`.
We do so by evaluating both the `Pattern` and `Arg` expression to an
`APInt`, if we can, and comparing the results.

This will be useful in an upcoming change where
`clang::isSubstitutedDefaultArgument` gets called from `clang::Sema`
where the `TemplateArgument`s are instantiated as expressions (without
being evaluted to `APInt` beforehand).

**Testing**

- Added unit-tests

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

17 months ago[test] Remove unused `unittest2` import from concurrent_base.py
Jordan Rupprecht [Fri, 27 Jan 2023 02:23:23 +0000 (18:23 -0800)]
[test] Remove unused `unittest2` import from concurrent_base.py

17 months ago[X86][ConstraintFP] Model `MXCSR` for function call
Phoebe Wang [Fri, 27 Jan 2023 01:24:57 +0000 (09:24 +0800)]
[X86][ConstraintFP] Model `MXCSR` for function call

This patch is inspired by D111433. It would affect the performance under
strict FP mode. But it preserves the correct rounding behavior accross
function calls.

Fixes #59305

Reviewed By: sepavloff

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

17 months ago[test] Remove unused `unittest2` import
Jordan Rupprecht [Fri, 27 Jan 2023 02:02:16 +0000 (18:02 -0800)]
[test] Remove unused `unittest2` import

17 months ago[clang-format] Disallow templates to be followed by literal
Emilia Dreamer [Fri, 27 Jan 2023 01:56:11 +0000 (03:56 +0200)]
[clang-format] Disallow templates to be followed by literal

There should not be any cases where the angle brackets of template
parameters are directly followed by a literal. It is more likely that a
comparison is taking place instead.

This patch makes the TokenAnnotator prefer to annotate < and > as
operators when directly followed by a literal. A similar check already
exists for literals directly *before* potential template args.

Fixes https://github.com/llvm/llvm-project/issues/60140

Reviewed By: HazardyKnusperkeks, owenpan, MyDeveloperDay

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

17 months ago[mlir][tensor] Add a tiling interface registration for pack/unpack only.
Hanhan Wang [Wed, 18 Jan 2023 00:44:32 +0000 (16:44 -0800)]
[mlir][tensor] Add a tiling interface registration for pack/unpack only.

Reviewed By: mravishankar

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

17 months ago[NFC] Optimize vector usage in lld
Jez Ng [Fri, 27 Jan 2023 01:28:58 +0000 (20:28 -0500)]
[NFC] Optimize vector usage in lld

By using emplace_back, as well as converting some loops to for-each, we can do more efficient vectorization.

Make copy constructor for TemporaryFile noexcept.

Reviewed By: #lld-macho, int3

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

17 months agotest-release.sh: Use parallel xz for packaging the binaries
Tom Stellard [Thu, 26 Jan 2023 23:18:58 +0000 (15:18 -0800)]
test-release.sh: Use parallel xz for packaging the binaries

Reviewed By: amyk, dim, hans

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

17 months ago[test][lldb-vscode] Fix unclean shutdown in test_terminate_commands
Jordan Rupprecht [Thu, 26 Jan 2023 22:29:48 +0000 (14:29 -0800)]
[test][lldb-vscode] Fix unclean shutdown in test_terminate_commands

This test manually sends `terminateCommands` to shutdown, but then the test attempts another `terminateCommands` request in test tear down, which fails since it's already torn down. This error is ignored in LLDB's old fork of unittest2, but will be reported as a test failure in `unittest` from the Python standard library. Use `disconnectAutomatically` to avoid terminating twice.

17 months ago[bazel] Add missing dependency after 55cf0de35e
Benjamin Kramer [Thu, 26 Jan 2023 22:25:15 +0000 (23:25 +0100)]
[bazel] Add missing dependency after 55cf0de35e

17 months ago[flang] Fixed restrictions checking for OpenACC loop-associated constructs.
Slava Zakharin [Thu, 26 Jan 2023 22:20:47 +0000 (14:20 -0800)]
[flang] Fixed restrictions checking for OpenACC loop-associated constructs.

CheckDoConcurrentClauseRestriction and CheckTileClauseRestriction expect
that the construct has associated DoConstruct, while it is not set
when the do-loop has no loop control. The change is to skip the clauses
checks, when the do-loop does not have the loop control.

An alternative fix would be to associate the DoConstruct even when
the do-loop has no loop control and let Check*ClauseRestriction run their
checks, but I am not sure if associating invalid DoConstruct is a good idea.

This fixes failure in Semantics/OpenACC/acc-canonicalization-validity.f90
reported in D142279.

Reviewed By: clementval

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

17 months ago[flang] Fixed uninitialized std::unique_ptr dereference.
Slava Zakharin [Thu, 26 Jan 2023 22:17:13 +0000 (14:17 -0800)]
[flang] Fixed uninitialized std::unique_ptr dereference.

This fixes unittest failures reported in D142279:
  flang-Unit :: Frontend/./FlangFrontendTests/5/7
  flang-Unit :: Frontend/./FlangFrontendTests/6/7

17 months ago[mlir][Linalg] Adding a greedy packing transform dialect op.
Nicolas Vasilache [Thu, 26 Jan 2023 20:30:54 +0000 (12:30 -0800)]
[mlir][Linalg] Adding a greedy packing transform dialect op.

This PR adds a `pack_greedily` transform operation that infers the packing for gemm
subcomputations embedded within in any LinalgOp and packs accordingly.
A normalization step guarantees that we get the innermost op dimensions in one of `8`
possible `(m, n, k)` orders, specified as a parameter, from which we can emit all
packed forms.

The current implementation takes an arbitrary LinalgOp and tries to pack it along
the specified dimensions with specified sizes and inner dim permutation.

This achieves a new level of normalization and generalization for any `n-D`
LinalgOp that contains a gemm embedded within it:
we will always see a predictable packed form for any of these ops.

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

17 months ago[SYCL] Fix test to conform to SYCL2020
Elizabeth Andrews [Thu, 26 Jan 2023 21:51:56 +0000 (13:51 -0800)]
[SYCL] Fix test to conform to SYCL2020

17 months ago[OpenMP][OMPIRBuilder]Move SIMD alignment calculation to LLVM Frontend
Dominik Adamski [Tue, 17 Jan 2023 09:51:48 +0000 (03:51 -0600)]
[OpenMP][OMPIRBuilder]Move SIMD alignment calculation to LLVM Frontend

Currently default simd alignment is defined by Clang specific TargetInfo class.
This class cannot be reused for LLVM Flang. That's why default simd alignment
calculation has been moved to OMPIRBuilder which is common for Flang and Clang.

Previous attempt: https://reviews.llvm.org/D138496 was wrong because
the default alignment depended on the number of built LLVM targets.

If we wanted to calculate the default alignment for PPC and we hadn't specified
PPC LLVM target to build, then we would get 0 as the alignment because
OMPIRBuilder couldn't create PPCTargetMachine object and it returned 0 as
the default value.

If PPC LLVM target had been built earlier, then OMPIRBuilder could have created
PPCTargetMachine object and it would have returned 128.

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

Reviewed By: jdoerfert

17 months ago[LinkerWrapper] Fix `-Bsymbolic` being sent to the compiler and not the linker
Joseph Huber [Thu, 26 Jan 2023 21:00:24 +0000 (15:00 -0600)]
[LinkerWrapper] Fix `-Bsymbolic` being sent to the compiler and not the linker

Summary:
Clang doesn't warn on `-B` options passed to it. This one is not
forwarded to the linker which results in some tests failing when
offloading to x86_64 with the `bfd` linker.

17 months agoReland: [llvm-cov] Look up object files using debuginfod
Daniel Thornburgh [Mon, 24 Oct 2022 22:35:00 +0000 (15:35 -0700)]
Reland: [llvm-cov] Look up object files using debuginfod

Reviewed By: gulfem

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

17 months ago[RISCV] Add MC support of RISCV Zcb Extension
WuXinlong [Thu, 26 Jan 2023 20:54:00 +0000 (12:54 -0800)]
[RISCV] Add MC support of RISCV Zcb Extension

This patch add the instructions of Zcb extension.

Instructions in zcb extensions shorten part of bit manipulation instructions.

Co-authored-by: Craig Topper <craig.topper@sifive.com>
Reviewed By: craig.topper

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

17 months ago[Support] Remove findFirstSet and findLastSet
Kazu Hirata [Thu, 26 Jan 2023 20:29:48 +0000 (12:29 -0800)]
[Support] Remove findFirstSet and findLastSet

This patch removes findFirstSet and findLastSet as there are no uses
left in LLVM.

I am not aware of any uses of findFirstSet and findLastSet in the
open-source world outside LLVM, so I am skipping the deprecation step.

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

17 months ago[extract_symbols.py] Filter out more symbols for MSVC
Mike Hommey [Thu, 26 Jan 2023 20:28:09 +0000 (21:28 +0100)]
[extract_symbols.py] Filter out more symbols for MSVC

This strips out about 5k symbols.

Fixes https://github.com/llvm/llvm-project/issues/60109

Reviewed By: john.brawn

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

17 months ago[libc++] Add documentation for reproducing CI issues locally
Louis Dionne [Wed, 25 Jan 2023 18:09:39 +0000 (13:09 -0500)]
[libc++] Add documentation for reproducing CI issues locally

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

17 months ago[gn build] Port 36080434a885
LLVM GN Syncbot [Thu, 26 Jan 2023 19:41:53 +0000 (19:41 +0000)]
[gn build] Port 36080434a885

17 months ago[libc++] Move the definition of aligned allocation helpers outside of <new>
Louis Dionne [Fri, 2 Dec 2022 21:45:49 +0000 (13:45 -0800)]
[libc++] Move the definition of aligned allocation helpers outside of <new>

They are not needed in <new> -- in fact they are only needed in .cpp files.
Getting those out of the way makes the headers smaller and also makes it
easier to use the library on platforms where aligned allocation is not
available.

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

17 months ago[CMake] Support undefined LLVM_NATIVE_ARCH in llvm_map_components_to_libnames().
Ivan Kosarev [Thu, 26 Jan 2023 17:44:43 +0000 (17:44 +0000)]
[CMake] Support undefined LLVM_NATIVE_ARCH in llvm_map_components_to_libnames().

https://reviews.llvm.org/D142405 made this function relying on the
LLVM_NATIVE_ARCH be defined, which is not necessarily the case for
third-party projects that include LLVM as their part.

Reviewed By: beanz

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

17 months ago[llvm][docs] Update old metadata syntax in examples
Paul Kirth [Thu, 26 Jan 2023 17:53:19 +0000 (17:53 +0000)]
[llvm][docs] Update old metadata syntax in examples

This patch updates examples in the documentation to match the existing
convention. Calls to intrinsics that have metadata arguments were not
included.

Reviewed By: dexonsmith

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

17 months ago[NVPTX] Do not addrspacecast AS-specific kernel arguments.
Artem Belevich [Wed, 25 Jan 2023 20:12:32 +0000 (12:12 -0800)]
[NVPTX] Do not addrspacecast AS-specific kernel arguments.

Fixes https://github.com/llvm/llvm-project/issues/46954

The assumption that generic pointers passed to a CUDA kernel is CUDA-specific
and should not be applied to non-CUDA compilations.  Addrspacecasts to global AS
and back should never be applied to AS-specific pointers.

In order to make tests actually do the testing for non-CUDA compilation, we need
to get TargetMachine from the TargetPassConfig, instead of passing it explicitly
as a pass constructor argument.

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

17 months ago[OpenMP] Run an extra 'OpenMPOpt' pass in LTO-mode
Joseph Huber [Thu, 26 Jan 2023 17:23:21 +0000 (11:23 -0600)]
[OpenMP] Run an extra 'OpenMPOpt' pass in LTO-mode

The `OpenMPOpt` pass is pivotal to the performance of many OpenMP
offloading programs. When we perform non-LTO builds with OpenMP we used
to link the OpenMP deviceRTL individually for each TU. This lead to us
getting an additional attributor run on the combined runtime and user
code. When we used LTO we lost a run and suffered a large performance
degradation. This patch simply adds in the extra `OpenMPOpt` pass that
we miss into the LTO pipeline. This patch fixes the performance
regression shown in applications that used OpenMP offloading in LTO
mode.

Previously, this wasn't legal to do as we could emit new runtime calls
into the module. That was fixed by D142646.

Depends on D142646

Fixes https://github.com/llvm/llvm-project/issues/60300

Reviewed By: jdoerfert

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

17 months ago[OpenMP] Make OpenMPOpt aware of the OpenMP runtime's status
Joseph Huber [Thu, 26 Jan 2023 17:13:56 +0000 (11:13 -0600)]
[OpenMP] Make OpenMPOpt aware of the OpenMP runtime's status

The `OpenMPOpt` pass contains optimizations that generate new calls into
the OpenMP runtime. This causes problems if we are in a state where the
runtime has already been linked statically. Generating these new calls
will result in them never being resolved. We should indicate if we are
in a "post-link" LTO phase and prevent OpenMPOpt from generating new
runtime calls.

Generally, it's not desireable for passes to maintain state about the
context in which they're called. But this is the only reasonable
solution to static linking when we have a pass that generates new
runtime calls.

Reviewed By: jdoerfert

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

17 months ago__arithmetic_fence enforces ordering on expression evaluation when fast-math
Zahira Ammarguellat [Wed, 25 Jan 2023 22:11:07 +0000 (17:11 -0500)]
__arithmetic_fence enforces ordering on expression evaluation when fast-math
is enabled.
In fast math mode some floating-point optimizations are performed such as
reassociation and distribution.

For example, the compiler may transform (a+b)+c into a+(b+c). Although these
two expressions are equivalent in integer arithmetic, they may not be in
floating-point arithmetic. The builtin tells the compiler that the expression
in parenthesis can’t be re-associated or distributed.
__arithmetic_fence(a+b)+c is not equivalent to a+(b+c).

This patch adds the support of the builtin to SPIR target.

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

17 months ago[NFC][Concepts] Change the Source Range of Concepts ParamMatching
Erich Keane [Thu, 26 Jan 2023 19:11:29 +0000 (11:11 -0800)]
[NFC][Concepts] Change the Source Range of Concepts ParamMatching

As came up in the discussion on
https://reviews.llvm.org/rG12cb1cb3720de8d164196010123ce1a8901d8122

We were asserting because the attempt to print a note found that our
source range for a immediately declared constraint (as a part of
Parameter Mapping Substitution) wasn't in order.

However, it doesn't really make sense to have the location of this be
the whole list of template arguments, as that would result in the range
being:
bool func(std::thing<char*> auto foo) {}
                     ^^^^^^^^^^^^^^^

Even if done correctly.  Instead, this patch makes the range be just
'foo' in this case (or a pointer right after 'auto' if unnamed).

17 months ago[lld] Remove transitional legacy pass manager flags
Arthur Eubanks [Wed, 25 Jan 2023 19:25:35 +0000 (11:25 -0800)]
[lld] Remove transitional legacy pass manager flags

Reviewed By: asbirlea

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

17 months ago[Clang][NFC] Fix out-of-date comments on 'clang-offload-bundler'
Joseph Huber [Thu, 26 Jan 2023 19:02:22 +0000 (13:02 -0600)]
[Clang][NFC] Fix out-of-date comments on 'clang-offload-bundler'

Summary:
These comments are confusing as the `clang-offload-bundler` is no longer
used by these toolchains.

17 months ago[analyzer] Fix crash exposed by D140059
einvbri [Thu, 26 Jan 2023 14:23:22 +0000 (08:23 -0600)]
[analyzer] Fix crash exposed by D140059

Change https://reviews.llvm.org/D140059 exposed the following crash in
Z3Solver, where bit widths were not checked consistently with that
change. This change makes the check consistent, and fixes the crash.

```
clang: <root>/llvm/include/llvm/ADT/APSInt.h:99:
  int64_t llvm::APSInt::getExtValue() const: Assertion
  `isRepresentableByInt64() && "Too many bits for int64_t"' failed.
...
Stack dump:
0. Program arguments: clang -cc1 -internal-isystem <root>/lib/clang/16/include
  -nostdsysteminc -analyze -analyzer-checker=core,unix.Malloc,debug.ExprInspection
  -analyzer-config crosscheck-with-z3=true -verify reproducer.c

 #0 0x00000000045b3476 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
  <root>/llvm/lib/Support/Unix/Signals.inc:567:22
 #1 0x00000000045b3862 PrintStackTraceSignalHandler(void*)
  <root>/llvm/lib/Support/Unix/Signals.inc:641:1
 #2 0x00000000045b14a5 llvm::sys::RunSignalHandlers()
  <root>/llvm/lib/Support/Signals.cpp:104:20
 #3 0x00000000045b2eb4 SignalHandler(int)
  <root>/llvm/lib/Support/Unix/Signals.inc:412:1
 ...
 #9 0x0000000004be2eb3 llvm::APSInt::getExtValue() const
  <root>/llvm/include/llvm/ADT/APSInt.h:99:5
  <root>/llvm/lib/Support/Z3Solver.cpp:740:53
  clang::ASTContext&, clang::ento::SymExpr const*, llvm::APSInt const&, llvm::APSInt const&, bool)
  <root>/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConv.h:552:61
```

Reviewed By: steakhal

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

17 months ago[InstSimplify] X && !(X || Y) --> false
Sanjay Patel [Thu, 26 Jan 2023 18:03:46 +0000 (13:03 -0500)]
[InstSimplify] X && !(X || Y) --> false

https://alive2.llvm.org/ce/z/7J8Exr

This is a commuted variant that was not included in:
D138853 / f2973327496fc966c4e89597

17 months ago[InstSimplify] add commuted variants of logical and/or pattern; NFC
Sanjay Patel [Thu, 26 Jan 2023 17:30:37 +0000 (12:30 -0500)]
[InstSimplify] add commuted variants of logical and/or pattern; NFC

Existing tests were added with D138853, but that patch failed
to handle all of the commutes. The poison-safety behavior is
symmetric, so I'm not duplicating all of the tests that were
added with that patch.

17 months ago[AMDGPU] Split dot7 feature
Stanislav Mekhanoshin [Wed, 25 Jan 2023 20:07:30 +0000 (12:07 -0800)]
[AMDGPU] Split dot7 feature

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

17 months ago[SystemZ] Add atomicrmw tests for i128 (NFC).
Jonas Paulsson [Thu, 19 Jan 2023 18:46:34 +0000 (12:46 -0600)]
[SystemZ] Add atomicrmw tests for i128 (NFC).

Review: Ulrich Weigand

17 months ago[CMake] Remove libLTO from Fuchsia toolchain
Alex Brachet [Thu, 26 Jan 2023 18:18:21 +0000 (18:18 +0000)]
[CMake] Remove libLTO from Fuchsia toolchain

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

17 months ago[clang-doc] Reduce duplicate code with template
Paul Kirth [Tue, 19 Jul 2022 22:55:41 +0000 (22:55 +0000)]
[clang-doc] Reduce duplicate code with template

Reviewed By: phosek

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

17 months ago[flang] Fix dereference of std::optional with no value
Jay Foad [Thu, 26 Jan 2023 17:27:56 +0000 (17:27 +0000)]
[flang] Fix dereference of std::optional with no value

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

17 months ago[MLIR][NFC] Fix a checked after used case in ReshapeOpsUtils.cpp
Shivam Gupta [Thu, 26 Jan 2023 17:21:44 +0000 (22:51 +0530)]
[MLIR][NFC] Fix a checked after used case in ReshapeOpsUtils.cpp

Found by PVS-Studio - https://pvs-studio.com/en/blog/posts/cpp/1003/, N18.
The value of the 'sourceDim' index is checked after it was used.

Reviewed By: zero9178

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

17 months ago[mlir][vector] Allow transposing multi_reduction when the parallel dim is in the...
Benjamin Kramer [Tue, 24 Jan 2023 17:01:26 +0000 (18:01 +0100)]
[mlir][vector] Allow transposing multi_reduction when the parallel dim is in the middle

The check for the outer lowering wasn't quite right.

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

17 months ago[AArch64][SME2] Add Multi-vector add vector intrinsics
Caroline Concatto [Thu, 26 Jan 2023 16:50:25 +0000 (16:50 +0000)]
[AArch64][SME2] Add Multi-vector add vector intrinsics

Add the following intrinsic:

 ADD vectors

NOTE: These intrinsics are still in development and are subject to future changes.

Reviewed By: david-arm

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

17 months ago[MISched] Dump the execution trace of the schedule.
Francesco Petrogalli [Mon, 23 Jan 2023 16:35:52 +0000 (17:35 +0100)]
[MISched] Dump the execution trace of the schedule.

The traces are printed only for bottom-up and top-down scheduling
because the values of TopReadyCycle and BottomReadyCycle are
inconsistent when obtained via bidirectional scheduling (see
`BIDIRECTIONAL` checks in the test).

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

17 months ago[mlir][Linalg] Put a proper type on transform.structured.match op
Nicolas Vasilache [Thu, 26 Jan 2023 15:58:59 +0000 (07:58 -0800)]
[mlir][Linalg] Put a proper type on transform.structured.match op

This allows much better verification messages in consuming ops that properly declare
`TransformHandleTypeInterface` on their operands.

Downstream tests can be updated with a command resembling:

```
 git grep -l "structured\.match" mlir/test | xargs -i sed -i {} -e  "s/\(structured.match.*\)/\1 : (\!pdl.operation) -> \!pdl.operation/g"
```

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

17 months ago[unittests] Use GTEST_SKIP() instead of return when appropriate
Paul Robinson [Thu, 26 Jan 2023 15:47:37 +0000 (07:47 -0800)]
[unittests] Use GTEST_SKIP() instead of return when appropriate

Basically NFC: A TEST/TEST_F/etc that bails out early (usually because
setup failed or some other runtime condition wasn't met) generally
should use GTEST_SKIP() to report its status correctly, unless it
takes steps to report another status (e.g., FAIL()).

17 months ago[analyzer] Fix assertion failure in SMT conversion for unary operator on floats
Tomasz Kamiński [Thu, 26 Jan 2023 16:33:48 +0000 (17:33 +0100)]
[analyzer] Fix assertion failure in SMT conversion for unary operator on floats

In the handling of the Symbols from the RangExpr, the code assumed that
the operands of the unary operators need to have integral type.
However, the CSA can create SymExpr with a floating point operand, when
the integer value is cast into it, like `(float)h == (float)l` where
both of `h` and `l` are integers.

This patch handles such situations, by using `fromFloatUnOp()` instead
of `fromUnOp()`, when the operand have a floating point type.

I have investigated all other calls of `fromUnOp()`, and for one in:

 - `getZeroExpr()` is applied only on boolean types, so it correct
 - `fromBinOp()` is not invoked for floating points
 - `fromFloatUnOp()` I am uncertain about this case and I was not able
   to produce a test that would reach this point, as a negation of
   floating points numbers seem to produce `Unknown` symbols.

This issue exists since the introduction of `UnarySymExpr` in D125318
and their handling for Z3 in D125547.

Patch by Tomasz Kamiński.

Reviewed By: mikhail.ramalho

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

17 months agoFix assertion failure "PathDiagnosticSpotPiece's must have a valid location." in...
Arseniy Zaostrovnykh [Thu, 26 Jan 2023 16:19:04 +0000 (17:19 +0100)]
Fix assertion failure "PathDiagnosticSpotPiece's must have a valid location." in ReturnPtrRange checker on builtin functions

Builtin functions (such as `std::move`, `std::forward`, `std::as_const`)
have a body generated during the analysis not related to any source file
so their statements have no valid source locations.
`ReturnPtrRange` checker should not report issues for these builtin
functions because they only forward its parameter and do not create any
new pointers.

Fixes #55347

Patch by Arseniy Zaostrovnykh.

Reviewed By: NoQ

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

17 months ago[clang] Fix sizeof of boolean vector
Mariya Podchishchaeva [Thu, 26 Jan 2023 15:43:27 +0000 (10:43 -0500)]
[clang] Fix sizeof of boolean vector

Ensure it is at least 8 bits.

Fixes #59801

Reviewed By: erichkeane

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

17 months ago[SCCP] Regenerate check lines for test.
Florian Hahn [Thu, 26 Jan 2023 15:28:49 +0000 (15:28 +0000)]
[SCCP] Regenerate check lines for test.

The auto-generated check lines for the test are missing `align`.
Re-generate the check lines to avoid unrelated changes in upcoming
change.