platform/upstream/llvm.git
18 months ago[clang][dataflow] In optional model, implement `widen` and make `compare` sound.
Yitzhak Mandelbaum [Thu, 15 Dec 2022 15:11:21 +0000 (15:11 +0000)]
[clang][dataflow] In optional model, implement `widen` and make `compare` sound.

This patch includes two related changes:

1. Rewrite `compare` operation to be sound. Current version checks for equality
of `isNonEmptyOptional` on both values, judging the values `Same` when the
results are equal. While that works when both are true, it is problematic when
they are both false, because there are four cases in which that's can occur:
both empty, one empty and one unknown (which is two cases), and both unknown. In
the latter three cases, it is unsound to judge them `Same`. This patch changes
`compare` to explicitly check for case of `both empty` and then judge any other
case `Different`.

2. With the change to `compare`, a number of common cases will no longer
terminate. So, we also implement widening to properly handle those cases and
recover termination.

Drive-by: improve performance of `merge` operation.
Of the new tests, the code before the patch fails
* ReassignValueInLoopToSetUnsafe, and
* ReassignValueInLoopToUnknownUnsafe.

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

18 months agoclang/AMDGPU: Update clang test for llvm change
Matt Arsenault [Thu, 12 Jan 2023 20:22:18 +0000 (15:22 -0500)]
clang/AMDGPU: Update clang test for llvm change

18 months agoPartially reapply "AMDGPU: Invert handling of enqueued block detection"
Matt Arsenault [Sun, 8 Jan 2023 13:15:30 +0000 (08:15 -0500)]
Partially reapply "AMDGPU: Invert handling of enqueued block detection"

This mostly reverts commit 270e96f435596449002fc89962595497481c8770.

Keep the attributor related changes around, but functionally restore
the old behavior as a workaround. Device enqueue goes back to not
working at -O0 with this version.

18 months ago[clang-tidy][NFC] Make CheckFactories::CreateChecks* const
Nathan James [Thu, 12 Jan 2023 19:20:53 +0000 (19:20 +0000)]
[clang-tidy][NFC] Make CheckFactories::CreateChecks* const

There's no reason for these methods to be non-const.

Reviewed By: gribozavr2

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

18 months ago[Attributor] Enable tests and ensure all call sites are updated
Johannes Doerfert [Thu, 12 Jan 2023 19:07:33 +0000 (11:07 -0800)]
[Attributor] Enable tests and ensure all call sites are updated

This reverts commit 9e08b083a09ef4e02fb0a4de2c0d3ddc0eccadde and ensures
signature rewriting also updates dead call sites to avoid the call graph
assertion.

18 months ago[fix] Change formatting to use llvm::formatv Summary:
Alexander Yermolovich [Thu, 12 Jan 2023 19:17:55 +0000 (11:17 -0800)]
[fix] Change formatting to use llvm::formatv Summary:

Missed one formating that was reversed.

Reviewed By: hoy, zhuhan0

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

18 months ago[gn build] Port 944f4b280585
LLVM GN Syncbot [Thu, 12 Jan 2023 19:05:33 +0000 (19:05 +0000)]
[gn build] Port 944f4b280585

18 months ago[clang-format][docs] Add ability to link to specific config options
Emilia Dreamer [Thu, 12 Jan 2023 19:00:10 +0000 (21:00 +0200)]
[clang-format][docs] Add ability to link to specific config options

This allows for the creation of permalinks to specific clang-format
options, for better sharing of a specific option and its options.

(I'm adding the usual clang-format reviewers on this patch because
I don't know any other reviewers that well, perhaps someone with
docs experience should be added instead...)

Note that I wanted to make minimal changes to make this happen and thus
landed on an unideal setup, but to me, it seems like the best out of
worse ones.

I could have made every style option a subheading, which would add
automatically the logic for permalinks and the little paragraph icon for
sharing.

However, this meant that the links themselves would be suboptimal, as
they'd include the whole text of the heading, including the type and
versionbadge, which is needless noise and could change, breaking the
concept of a "permalink". The format of the page could be changed to
put the option names on their own in a heading, and the other info below
it in a paragraph.

As Sphinx seems unwilling to fix https://github.com/sphinx-doc/sphinx/issues/1961,
there isn't a succinct way to change the "id" html field used for
sections

I could have used an add-on (https://github.com/GeeTransit/sphinx-better-subsection),
or made one myself, but I wanted to avoid extra dependencies for no
reason. (plus, I don't know how to make one myself.)

I could have used raw HTML for each heading, but that would immensely
pollute the rst file, which, while it is generated, is currently still
human-readable and it'd be nice for it to stay that way.

Also note that sphinx treats references as case-insensitive, which means
that they will all be lowercased in the resulting HTML. I envisioned
the ability to simply add #OptionName after the URL to get placed right
at the desired config option, which isn't possible without things such
as inline `raw` HTML.

To reconcile that, I added the ¶ paragraph buttons that can be used to
generate the link to the desired section, but since headings are not
actually used, they are faked and literally just a link following each
option, which means they stylistically don't match all other headings.

Also note that this sort-of assumes HTML output. I know Sphinx can
output other formats but I do not know if they are used. A non-html
output could embed unusable ¶ signs everywhere.

I'm okay with this patch being rejected in its current solution, or if
any of the above listed alternatives are better, they could be pursued
instead. In case the downsides of this solution are too much, I will
just create a feature request issue for this and maybe let someone more
experienced with Sphinx handle it, since this is still a feature I would
like to have. (and I do not want to deal with Sphinx at all after
battling with it for a whole day to produce a mediocre result.)

Reviewed By: HazardyKnusperkeks, owenpan, MyDeveloperDay, aaron.ballman

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

18 months ago[DWARFLibrary] Add support to re-construct cu-index
Alexander Yermolovich [Thu, 12 Jan 2023 18:43:08 +0000 (10:43 -0800)]
[DWARFLibrary] Add support to re-construct cu-index

According to DWARF5 specification and gnu specification for DWARF4 the offset
entry in the CU/TU Index is 32 bits. This presents a problem when
.debug_info.dwo in DWP file grows beyond 4GB. The CU Index becomes partially
corrupted.

This diff adds manual parsing of .debug_info.dwo/.debug_abbrev.dwo to
reconstruct CU index in general, and TU index for DWARF5. This is a work around
until DWARF6 spec is finalized.

Next patch will change internal CU/TU struct to 64 bit, and change uses as
necessary. The plan is to land all the patches in one go after all are approved.

This patch originates from the discussion in: https://discourse.llvm.org/t/dwarf-dwp-4gb-limit/63902

Reviewed By: dblaikie

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

18 months ago[LinkerWrapper] Emit assembly files from LTO with `save-temps`
Joseph Huber [Wed, 11 Jan 2023 20:57:39 +0000 (14:57 -0600)]
[LinkerWrapper] Emit assembly files from LTO with `save-temps`

Currently in LTO mode we don't emit any `.s` files for non-NVPTX targets
during LTO. This makes it diffcult to investigate any failures in the
assembly. This patch makes the save-temps mode output an assembly file
and then assembles it separately. I decided to simply invoke `clang` for
this as it would be a lot of effort to invoke the `MCStramer` interface
directly.

Reviewed By: arsenm

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

18 months agoLoopIdiom: avoid patterned memset if constant is not relocatable.
Tim Northover [Wed, 11 Jan 2023 13:52:45 +0000 (13:52 +0000)]
LoopIdiom: avoid patterned memset if constant is not relocatable.

The pattern we're using for the memset_pattern* call gets put into a static
global variable initialized, which means it has to be representable with
relocations on the target. Most `ConstantExpr` instances do not satisfy this
constraint, so avoid all of them for now.

18 months ago[lldb] Fix compile error in Lua typemap
Jonas Devlieghere [Thu, 12 Jan 2023 18:47:14 +0000 (10:47 -0800)]
[lldb] Fix compile error in Lua typemap

Fix error "non-const lvalue reference to type 'lldb::FileSP'  cannot
bind to a value of unrelated type" in Lua typemap.

18 months ago[DirectX backend] add support ConstantBuffer to DXILResource.h
Xiang Li [Thu, 12 Jan 2023 16:56:18 +0000 (11:56 -0500)]
[DirectX backend] add support ConstantBuffer to DXILResource.h

class ConstantBuffer is added to save information for cbuffer.
Also add CBufferDataLayout to calculate the size for cbuffer.

Now always use legacy cbuffer layout.
https://reviews.llvm.org/D134998 will add control to disable legacy cbuffer layout.

Reviewed By: beanz

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

18 months agoclang/OpenCL: Check calling convention in test
Matt Arsenault [Thu, 12 Jan 2023 14:28:51 +0000 (09:28 -0500)]
clang/OpenCL: Check calling convention in test

update_cc_test_checks misses this, so make sure at least one block
enqueue test manually checks the calling convention for the kernel.

18 months ago[libc++] Add missing includes in move_iterator.h
Louis Dionne [Thu, 12 Jan 2023 18:37:49 +0000 (13:37 -0500)]
[libc++] Add missing includes in move_iterator.h

18 months ago[Attributor] Disable breaking tests to unblock bots
Johannes Doerfert [Thu, 12 Jan 2023 18:28:51 +0000 (10:28 -0800)]
[Attributor] Disable breaking tests to unblock bots

The tests will be re-enabled asap as a fix is available.

18 months agoAdd -Wreturn-local-addr, GCC alias for -Wreturn-stack-address
Adrian Dole [Thu, 12 Jan 2023 17:45:03 +0000 (17:45 +0000)]
Add -Wreturn-local-addr, GCC alias for -Wreturn-stack-address

For warning compatibility with GCC.

Reviewed By: cjdb

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

18 months ago[AIX][NFC] Unsupport test when running on AIX
Jake Egan [Thu, 12 Jan 2023 18:18:16 +0000 (13:18 -0500)]
[AIX][NFC] Unsupport test when running on AIX

Previously the test's targets were restricted to avoid the AIX target, but
it should be marked unsupported for system-aix instead because the test
fails to run on AIX as well.

18 months ago[AArch64] Add an error if SVE scalable vector types are used in a context without sve
David Green [Thu, 12 Jan 2023 18:21:28 +0000 (18:21 +0000)]
[AArch64] Add an error if SVE scalable vector types are used in a context without sve

This adds an error message if the isSVESizelessBuiltinType like
__SVFloat32_t / __SVInt64_t / etc, which provide the backing for the
svfloat32_t / svint64_t / etc ACLE types, are used in a function without
SVE. The alternative is a crash in the backend, which is not capable of
handling scalable vector types.

When SVE is available, either through a -march=..+sve option or via a
target(sve) attribute, nothing should change. Without the sve feature,
this patch gives an error for any function arguments, return values and
variable declarations involving the scalable types. Struct/class members
and global variables already give an error. As this can be based on the
current function target attributes, the error sometimes needs to be
handled later than would otherwise if it was just based on the global
target.

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

18 months ago[lldb] Limit `nothreadallow` to Python in SWIG bindings
Jonas Devlieghere [Thu, 12 Jan 2023 18:15:51 +0000 (10:15 -0800)]
[lldb] Limit `nothreadallow` to Python in SWIG bindings

SWIG allows you to partially disable thread support for a given function
in Python with `nothreadallow`. This functionality is limited to Python,
but until SWIG 4.1, it would silently ignore this for other languages,
such as Lua. New versions of SWIG are more strict and therefore we need
to guard this with `SWIGPYTHON`.

For more details on the functionality, I recommend reading the commit
message from 070a1d562b30.

18 months ago[mlir][llvmir] Cleaned up MetadataOp.
Slava Zakharin [Fri, 6 Jan 2023 21:43:22 +0000 (13:43 -0800)]
[mlir][llvmir] Cleaned up MetadataOp.

Added NoTerminator trait, and created a single builder
that adds a block into the region at operation construction.
Added custom assembly parser that automatically adds the body
block, when the region appears to be empty to parseRegion().

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

18 months agoclang: Fix excessively strict test requirements
Matt Arsenault [Thu, 12 Jan 2023 14:09:46 +0000 (09:09 -0500)]
clang: Fix excessively strict test requirements

At most this requires x86 as it's used in the run lines, it
doesn't require a linux host.

18 months ago[clang] Reland parenthesized aggregate init patches
Alan Zhao [Wed, 4 Jan 2023 23:12:00 +0000 (15:12 -0800)]
[clang] Reland parenthesized aggregate init patches

This commit relands the patches for implementing P0960R3 and P1975R0,
which describe initializing aggregates via a parenthesized list.

The relanded commits are:

40c52159d3ee - P0960R3 and P1975R0: Allow initializing aggregates from
  a parenthesized list of values
c77a91bb7ba7 - Remove overly restrictive aggregate paren init logic
32d7aae04fdb - Fix a clang crash on invalid code in C++20 mode

This patch also fixes a crash in the original implementation.
Previously, if the input tried to call an implicitly deleted copy or
move constructor of a union, we would then try to initialize the union
by initializing it's first element with a reference to a union. This
behavior is incorrect (we should fail to initialize) and if the type of
the first element has a constructor with a single template typename
parameter, then Clang will explode. This patch fixes that issue by
checking that constructor overload resolution did not result in a
deleted function before attempting parenthesized aggregate
initialization.

Additionally, this patch also includes D140159, which contains some
minor fixes made in response to code review comments in the original
implementation that were made after that patch was submitted.

Co-authored-by: Sheng <ox59616e@gmail.com>
Fixes #54040, Fixes #59675

Reviewed By: ilya-biryukov

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

18 months agoRevert "[mlir][llvm] Add an explicit void type debug info attribute."
Tobias Gysi [Thu, 12 Jan 2023 17:50:56 +0000 (18:50 +0100)]
Revert "[mlir][llvm] Add an explicit void type debug info attribute."

This commit broke the flang build bots
https://lab.llvm.org/buildbot#builders/175/builds/23560.

This reverts commit a960547ea12128a67c99760f57bf01609a265546.

18 months ago[libc++] Make pmr::monotonic_buffer_resource bump down
Nikolas Klauser [Thu, 12 Jan 2023 17:35:19 +0000 (18:35 +0100)]
[libc++] Make pmr::monotonic_buffer_resource bump down

Bumping down is significantly faster than bumping up. This is ABI breaking, but the ABI of `pmr::monotonic_buffer_resource` was only stabilized in this release cycle, so we can still change it.
For a more detailed explanation why bumping down is better, see https://fitzgeraldnick.com/2019/11/01/always-bump-downwards.html.

Reviewed By: ldionne, #libc

Spies: libcxx-commits

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

18 months ago[libc++] Add [[nodiscard]] extensions in <math.h>
Nikolas Klauser [Sun, 25 Dec 2022 19:13:39 +0000 (20:13 +0100)]
[libc++] Add [[nodiscard]] extensions in <math.h>

There are quite a few functions marked `[[gnu::const]]` inside the compiler. This patch adds `[[nodiscard]]` to libc++-provided overloads of these functions to match the diagnostics produced.

Reviewed By: ldionne, #libc

Spies: libcxx-commits

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

18 months ago[EarlyCSE] Fix crash when optimizing masked loads/stores
Fraser Cormack [Thu, 12 Jan 2023 15:35:24 +0000 (15:35 +0000)]
[EarlyCSE] Fix crash when optimizing masked loads/stores

With opaque pointers, it is possible for EarlyCSE to encounter masked
load/store intrinsics which access the same pointer value but with
different incompatible types. These cannot form valid replacements
(without explicit casting, which we don't yet do even for regular
load/store instructions) so should be prevented.

Reviewed By: nikic

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

18 months ago[libc++][NFC] Rename basic_istream_view::__iterator to __basic_istream_view_iterator
Nikolas Klauser [Wed, 28 Dec 2022 01:44:04 +0000 (02:44 +0100)]
[libc++][NFC] Rename basic_istream_view::__iterator to __basic_istream_view_iterator

This makes it a lot easier to specialize traits types for it, like __segmented_iterator_traits.

Reviewed By: Mordante, #libc

Spies: libcxx-commits

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

18 months ago[libc++][NFC] Qualify declval
Nikolas Klauser [Sun, 31 Jul 2022 19:54:25 +0000 (21:54 +0200)]
[libc++][NFC] Qualify declval

While it's not necessary to qualify calls to `declval` it makes error messages very crypric if the declaration isn't reachable anymore

For example:
```
    /home/nikolask/llvm-projects/libcxx/build/include/c++/v1/__chrono/duration.h:53:66: error: no type named 'type' in 'std::common_type<long, long>'
        typedef chrono::duration<typename common_type<_Rep1, _Rep2>::type,
                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
    /home/nikolask/llvm-projects/libcxx/build/include/c++/v1/__type_traits/common_type.h:107:14: note: in instantiation of template class 'std::common_type<std::chrono::duration<long, std::ratio<3600, 1>>, std::chrono::duration<long, std::ratio<3600, 1>>>' requested here
        : public common_type<_Tp, _Tp> {};
                 ^
    /home/nikolask/llvm-projects/libcxx/build/include/c++/v1/__chrono/duration.h:279:58: note: in instantiation of template class 'std::common_type<std::chrono::duration<long, std::ratio<3600, 1>>>' requested here
        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename common_type<duration>::type operator+() const {return typename common_type<duration>::type(*this);}
                                                             ^
    /home/nikolask/llvm-projects/libcxx/build/include/c++/v1/__chrono/duration.h:308:54: note: in instantiation of template class 'std::chrono::duration<long, std::ratio<3600, 1>>' requested here
    typedef duration<     int, ratio_multiply<ratio<24>, hours::period>>         days;
                                                         ^
    /home/nikolask/llvm-projects/libcxx/build/include/c++/v1/__chrono/duration.h:280:81: error: no type named 'type' in 'std::common_type<std::chrono::duration<long, std::ratio<3600, 1>>>'
        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename common_type<duration>::type operator-() const {return typename common_type<duration>::type(-__rep_);}
                                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
    /home/nikolask/llvm-projects/libcxx/build/include/c++/v1/__chrono/duration.h:308:54: note: in instantiation of template class 'std::chrono::duration<long, std::ratio<3600, 1>>' requested here
    typedef duration<     int, ratio_multiply<ratio<24>, hours::period>>         days;
                                                         ^
    /home/nikolask/llvm-projects/libcxx/build/include/c++/v1/__chrono/duration.h:53:66: error: no type named 'type' in 'std::common_type<int, int>'
        typedef chrono::duration<typename common_type<_Rep1, _Rep2>::type,
                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
    /home/nikolask/llvm-projects/libcxx/build/include/c++/v1/__type_traits/common_type.h:107:14: note: in instantiation of template class 'std::common_type<std::chrono::duration<int, std::ratio<86400, 1>>, std::chrono::duration<int, std::ratio<86400, 1>>>' requested here
        : public common_type<_Tp, _Tp> {};
                 ^
    /home/nikolask/llvm-projects/libcxx/build/include/c++/v1/__chrono/duration.h:279:58: note: in instantiation of template class 'std::common_type<std::chrono::duration<int, std::ratio<86400, 1>>>' requested here
        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename common_type<duration>::type operator+() const {return typename common_type<duration>::type(*this);}
                                                             ^
    /home/nikolask/llvm-projects/libcxx/build/include/c++/v1/__chrono/duration.h:309:55: note: in instantiation of template class 'std::chrono::duration<int, std::ratio<86400, 1>>' requested here
    typedef duration<     int, ratio_multiply<ratio<7>,   days::period>>         weeks;
                                                          ^
    19 similar errors omitted
```
changes with qualification added to:
```
    While building module 'std' imported from /home/nikolask/llvm-projects/libcxx/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp:13:
    In file included from <module-includes>:17:
    In file included from /home/nikolask/llvm-projects/libcxx/build/include/c++/v1/math.h:309:
    In file included from /home/nikolask/llvm-projects/libcxx/build/include/c++/v1/limits:107:
    In file included from /home/nikolask/llvm-projects/libcxx/build/include/c++/v1/type_traits:432:
    In file included from /home/nikolask/llvm-projects/libcxx/build/include/c++/v1/__type_traits/common_reference.h:13:
    /home/nikolask/llvm-projects/libcxx/build/include/c++/v1/__type_traits/common_type.h:28:43: error: declaration of 'declval' must be imported from module 'std.utility.__utility.declval' before it is required
    using __cond_type = decltype(false ? std::declval<_Tp>() : std::declval<_Up>());
                                              ^
    /home/nikolask/llvm-projects/libcxx/build/include/c++/v1/__utility/declval.h:30:34: note: declaration here is not visible
    decltype(std::__declval<_Tp>(0)) declval() _NOEXCEPT;
                                     ^
    /home/nikolask/llvm-projects/libcxx/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp:13:10: fatal error: could not build module 'std'
    #include <functional>
     ~~~~~~~~^
    2 errors generated.
```

Reviewed By: ldionne, Mordante, #libc

Spies: libcxx-commits

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

18 months ago[clangd] Fix tests for CLANGD_TIDY_CHECKS=OFF builds
Kadir Cetinkaya [Thu, 12 Jan 2023 17:25:52 +0000 (18:25 +0100)]
[clangd] Fix tests for CLANGD_TIDY_CHECKS=OFF builds

18 months agoRevert "build: with -DCLANGD_ENABLE_REMOTE=ON, search for grpc++ dependencies too"
Kadir Cetinkaya [Thu, 12 Jan 2023 17:14:05 +0000 (18:14 +0100)]
Revert "build: with -DCLANGD_ENABLE_REMOTE=ON, search for grpc++ dependencies too"

This reverts commit 9f3081dc6fe8447e85741865846840bc491866e5.
Broke clangd buildbots in
https://lab.llvm.org/buildbot/#/builders/131/builds/38935.

18 months ago[flang] Carry the whole polymorphic box in PolymorphicValue
Valentin Clement [Thu, 12 Jan 2023 16:59:18 +0000 (17:59 +0100)]
[flang] Carry the whole polymorphic box in PolymorphicValue

Until now, only the address of the type descriptor was hold in
a PolymorphicValue. In some cases, the element size and the
type code are also needed when creating new polymorphic
descriptors from an element of a polymorphic entity.

This patch updates PolymorphicValue to carry the source
descriptor from which the element is extracted. The source
descriptor is then used when emboxing the element to a new
polymorphic descriptor.

This simplify the code done in D141274 and will be used
when creating polymorphic temporary as well.

Reviewed By: jeanPerier, PeteSteinfeld

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

18 months ago[LinkerWrapper] Fix errors from missing files during a dry run
Joseph Huber [Thu, 12 Jan 2023 16:41:18 +0000 (10:41 -0600)]
[LinkerWrapper] Fix errors from missing files during a dry run

Summary:
We use a dry run for testing. If we do a dry run there is no file to
open and try to embed. Intead of erroring just create an empty one.

18 months ago[mlir][llvm] Add an explicit void type debug info attribute.
Tobias Gysi [Thu, 12 Jan 2023 16:32:22 +0000 (17:32 +0100)]
[mlir][llvm] Add an explicit void type debug info attribute.

Previously, the DISubroutineType attribute used an optional result
parameter and an optional argument types array to model the subroutine
signature. LLVM IR debug metadata, on the other hand, has one types
list whose first entry maps to the result type. That entry may be
null to model a void result type. The type list may also be entirely
empty not specifying any type information. The latter is problematic
since the current DISubroutineType attribute cannot express it.

The revision changes DISubroutineTypeAttr to closely follow the
LLVM metadata design. In particular, it uses a single types parameter
array to model the subroutine signature and introduces an explicit
DIVoidResultTypeAttr to model the null entries.

Reviewed By: Dinistro

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

18 months ago[mlir][spirv] Add support for fptoui conversion in ArithToSPIRV
Steve Suzuki [Thu, 12 Jan 2023 16:35:02 +0000 (16:35 +0000)]
[mlir][spirv] Add support for fptoui conversion in ArithToSPIRV

To enable the conversion of arith.fptoui to SPIRV OpConvertFToU

Reviewed By: kuhar

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

18 months ago[mlir] Broadcast scalars when vectorising tensor.extract
Andrzej Warzynski [Fri, 30 Dec 2022 15:22:22 +0000 (15:22 +0000)]
[mlir] Broadcast scalars when vectorising tensor.extract

When vectorizing tensor.extract embedded within linalg.generic, the
default option is to rewrite it as vector.gather. When doing so, we need
to make sure that the corresponding indices are vectorized accordingly.
However, the Linalg vectorizer will not vectorize constants like in the
following example. This is fixed by simply broadcasting %c0 and %c1.

```
  func.func @example(%arg0: tensor<3x3xf32>, %arg2: tensor<1x1x3xf32>) -> tensor<1x1x3xf32> {
    %c0 = arith.constant 1 : index
    %c1 = arith.constant 2 : index
    %1 = linalg.generic {
      (...)
    } outs(...) {
    ^bb0(...):
      %2 = tensor.extract %arg0[%c0, %c1] : tensor<3x3xf32>
      linalg.yield %2 : f32
    } -> tensor<1x1x3xf32>
    return %1 : tensor<1x1x3xf32>
  }
```

This patch makes sure that in the case above (and other similar cases),
the vectorizer broadcasts %c0 and %c1.

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

18 months ago[NFC][LoopFlatten][LoopInterchange] Do not explicitly forget subloops
Joshua Cao [Thu, 5 Jan 2023 04:42:19 +0000 (20:42 -0800)]
[NFC][LoopFlatten][LoopInterchange] Do not explicitly forget subloops

We don't need to explicitly forget subloops because forgetting parent
loops will automatically forget their subloops

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

18 months ago[Clang] Diagnose undefined behavior in a constant expression while evaluating a compo...
Shafik Yaghmour [Thu, 12 Jan 2023 16:02:00 +0000 (08:02 -0800)]
[Clang] Diagnose undefined behavior in a constant expression while evaluating a compound assignment with remainder as operand

Currently we don't diagnose overflow in a constant expression for the case of
compound assignment with remainder as a operand.

In handleIntIntBinOp the arguments LHS and Result can be the same source but in
the check for remainder in this function we assigned to Result before checking
for overflow. In all the other operations the check is done before Result is
assigned to.

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

18 months ago[include-mapping] Print an error message in case the symbol index points to a non...
Viktoriia Bakalova [Thu, 12 Jan 2023 15:39:38 +0000 (15:39 +0000)]
[include-mapping] Print an error message in case the symbol index points to a non-existent page.

Fix: https://github.com/llvm/llvm-project/issues/59610
Differential Revision: https://reviews.llvm.org/D141611

18 months ago[RISCV] Add zvl65536b to the target feature list
Kito Cheng [Thu, 12 Jan 2023 15:51:23 +0000 (23:51 +0800)]
[RISCV] Add zvl65536b to the target feature list

We have zvl65536b listed in RISCVISAInfo.cpp, but we don't have
corresponding target feature in td file.

Reviewed By: reames

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

18 months ago[LVI][CVP] Make use of condition known at use
Nikita Popov [Wed, 11 Jan 2023 10:58:00 +0000 (11:58 +0100)]
[LVI][CVP] Make use of condition known at use

When an instruction is only used in a select or phi operand, we might
be able to make use of additional information from the select/branch
condition. For example in

  %sub = call i16 @llvm.usub.sat.i16(i16 %x, i16 10)
  %cmp = icmp uge i16 %x, 10
  %sel = select i1 %cmp, i16 %sub, i16 42

the usub.sat is only used in a select where %x uge 10 is known to
hold, so we can fold it based on that knowledge.

This addresses the regression reported at
https://reviews.llvm.org/D140798#4039748, but also provides a
solution to a recurring problem we've had, where we fail to make
use of range information after a branch+phi has been converted
into a select. Our current solution to this is to hope that IPSCCP
can perform the fold before that happens, but handling this in LVI
is a somewhat more general solution.

Currently we only make use of this for the willNotOverflow() fold,
but I plan to adjust other folds to use the new API as well.

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

18 months ago[Mem2Reg] Extract code for converting !nonull to assume (NFC)
Nikita Popov [Thu, 12 Jan 2023 13:50:39 +0000 (14:50 +0100)]
[Mem2Reg] Extract code for converting !nonull to assume (NFC)

18 months ago[mlir][llvm] Handle debug metadata arg lists during LLVM IR import.
Tobias Gysi [Thu, 12 Jan 2023 15:10:58 +0000 (16:10 +0100)]
[mlir][llvm] Handle debug metadata arg lists during LLVM IR import.

Debug intrinsics may get an argument list as first parameter. Argument
lists are metadata nodes that refer to a list of SSA values and
constant that are needed to evaluate the debug expression attached to
the intrinsic.

We do currently not model these debug expressions in MLIR. This
revision thus makes sure debug intrinsics that get an argument list
as a first parameter are dropped. It also adds a test to verify
a warning is emitted.

Reviewed By: Dinistro

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

18 months agoReword diagnostic slightly; NFC
Aaron Ballman [Thu, 12 Jan 2023 15:12:13 +0000 (10:12 -0500)]
Reword diagnostic slightly; NFC

This adds single quotes around a syntax element and it rewords the diag
slightly to talk about Clang 17 instead of LLVM 17.

18 months agoReland "[InstCombine] Fold nested selects"
Roman Lebedev [Thu, 12 Jan 2023 14:55:24 +0000 (17:55 +0300)]
Reland "[InstCombine] Fold nested selects"

The change was reverted because one of the changes were suspected of
causing a miscompile, but said miscompile was (confirmed to be) fixed
before the revert happened, by 07ecdd9b1a8af51f07d5f4dfe46845c801482a39.

https://alive2.llvm.org/ce/z/GjCXkB
https://alive2.llvm.org/ce/z/Guz2tt

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

This reverts commit d73383c145ea83d25063246e0c34f5a41fd35293,
and relands commmit 9ddff66d0c9c3e18d56e6b20aa26a2a8cdfb6d2b.

18 months agoLower math.tan to __nv_tan[f] / __ocml_tan_f{32|64}
Goran Flegar [Wed, 11 Jan 2023 18:39:10 +0000 (19:39 +0100)]
Lower math.tan to __nv_tan[f] / __ocml_tan_f{32|64}

At present math.tan fails to lower for NVVM and ROCDL.

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

18 months ago[X86] vector-mul.ll - remove old FIXME comment
Simon Pilgrim [Thu, 12 Jan 2023 14:18:04 +0000 (14:18 +0000)]
[X86] vector-mul.ll - remove old FIXME comment

Vector AssertZExt support was added by D54725 / 4954c664307d56c5aa7ed400b3bac730bd71ddb9

18 months ago[UpdateTestChecks] Handle nounwind functions for s390x
Nikita Popov [Thu, 12 Jan 2023 14:09:06 +0000 (15:09 +0100)]
[UpdateTestChecks] Handle nounwind functions for s390x

Unlike all the other architectures, s390x requires cfi_startproc
to be present, so update_llc_test_checks did no work with nounwind
functions.

18 months ago[mips][clang] Do not define __GCC_HAVE_SYNC_COMPARE_AND_SWAP macros for MIPS-I
Brad Smith [Thu, 12 Jan 2023 14:02:50 +0000 (09:02 -0500)]
[mips][clang] Do not define __GCC_HAVE_SYNC_COMPARE_AND_SWAP macros for MIPS-I

Do not define __GCC_HAVE_SYNC_COMPARE_AND_SWAP macros for MIPS-I

Reviewed By: MaskRay

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

18 months ago[ARM] Use MCInstrInfo::get in ARMDisassembler instead of reinventing it
Jay Foad [Wed, 11 Jan 2023 16:00:07 +0000 (16:00 +0000)]
[ARM] Use MCInstrInfo::get in ARMDisassembler instead of reinventing it

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

18 months ago[Clang] Clean up some offloading driver tests
Joseph Huber [Thu, 12 Jan 2023 13:29:46 +0000 (07:29 -0600)]
[Clang] Clean up some offloading driver tests

Summary:
These tests used an external `dummy.o` and `dummy.bc` files instead of
just generating them. This should be cleaner and less error prone.

18 months ago[MemorySSA] Don't check def set when cloning memoryaccesses
luxufan [Thu, 12 Jan 2023 13:46:22 +0000 (21:46 +0800)]
[MemorySSA] Don't check def set when cloning memoryaccesses

For internal functions, globals-aa returns different ModRefInfo
results if they are inlined and are no longer called by external
functions. This causes an assertion failure when cloning memoryssa
accesses.

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

Reviewed By: nikic

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

18 months agoRevert "[amdgpu] Change the RA to basic"
Matt Arsenault [Thu, 15 Sep 2022 19:41:57 +0000 (15:41 -0400)]
Revert "[amdgpu] Change the RA to basic"

This reverts commit 28733d86cf7bf3e4e9667654ad6785aa8e21e04f.

This was a workaround for a bug which was fixed in
74ef03d38a59bb4da710a43dac189be3d01d0cd7

18 months ago[InstCombine] Add extra tests for copy from constant with phi (NFC)
Nikita Popov [Thu, 12 Jan 2023 13:24:46 +0000 (14:24 +0100)]
[InstCombine] Add extra tests for copy from constant with phi (NFC)

Additional tests for D136201.

Also fix intrinsic name mangling while here.

18 months ago[mlir][llvm] A DICompositeTypeAttr is also a DIScopeAttr.
Tobias Gysi [Thu, 12 Jan 2023 13:09:47 +0000 (14:09 +0100)]
[mlir][llvm] A DICompositeTypeAttr is also a DIScopeAttr.

A DICompositeTypeAttr is the MLIR counterpart of LLVMIR's
DICompositeType debug metadata node. It can be used to store debug
information associated to a class or struct type definition. Any class
member method then sets its scope to the parent DICompositeType. This
revision adds DICompositeTypeAttr to the list of DIScopeAttrs to
prevent verification failures for legal debug information. Additionally,
it adds a number of test cases.

Reviewed By: Dinistro

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

18 months ago[utils][filecheck-lint] Add filecheck-lint, a linter for FileCheck directives.
Benjamin Chetioui [Thu, 12 Jan 2023 13:19:42 +0000 (13:19 +0000)]
[utils][filecheck-lint] Add filecheck-lint, a linter for FileCheck directives.

FileCheck is a versatile tool for testing compiler output regardless of syntax.
FileCheck achieves this versatility by processing only input lines in which it
detects a valid CHECK directive, and ignoring everything else.

This comes at a price: if a directive is not typed properly, it is not
processed by FileCheck, and the test code it precedes is effectively disabled.
This results in the illusion that the code is tested, while the test may have
actually never run.

This scenario is not hypothetical, see the fixes introduced in, e.g.
https://github.com/tensorflow/tensorflow/commit/48cacf049f3d6ed3f289ccc48ec50491b6d8d9a8,
https://reviews.llvm.org/D139698, https://reviews.llvm.org/D139636,
https://github.com/iree-org/iree/pull/11693.

The findings corrected in the above changes originate in filecheck-lint.
In a given test file, filecheck-lint uses the edit distance between anything
that looks like a FileCheck directive and the set of locally valid directives
to detect likely misspelled directives.

The tool is not yet feature complete---e.g. it does not parse custom comment
prefixes to exclude them from reporting---but it already yields useful results,
as demonstrated above.

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

18 months agoAdd a warning comment that this file is generated
Aaron Ballman [Thu, 12 Jan 2023 13:09:30 +0000 (08:09 -0500)]
Add a warning comment that this file is generated

This file is partially generated by a Python script in the
clang/docs/tools directory, but it's not obvious for people making
drive-by fixes. This comment hopefully helps people avoid making
changes that are later overwritten by the script.

18 months agollvm-link: Do not use .ll extension for tests with no IR
Matt Arsenault [Thu, 12 Jan 2023 13:06:51 +0000 (08:06 -0500)]
llvm-link: Do not use .ll extension for tests with no IR

These don't actually contain IR and don't use the correct IR comment
character. The assembler was not happy when I tried running tools over
every test in the suite.

18 months agollvm-reduce: Simplify attribute reduction implementation
Matt Arsenault [Mon, 2 Jan 2023 18:33:17 +0000 (13:33 -0500)]
llvm-reduce: Simplify attribute reduction implementation

There's no need to construct a map of attributes to modify throughout
the whole function before applying them all at once. The attribute
classes already have the necessary set behavior.

18 months agoFix the Clang sphinx bot again
Aaron Ballman [Thu, 12 Jan 2023 12:59:07 +0000 (07:59 -0500)]
Fix the Clang sphinx bot again

The changes to fix the bot yesterday got reverted in a subsequent
commit, so this adds those changes back again.

Fixes the issue found in:
https://lab.llvm.org/buildbot/#/builders/92/builds/38593

18 months agoRevert "[mlir][linalg] Swap extract_slice(fill(x)) ops"
Alexander Belyaev [Thu, 12 Jan 2023 11:51:23 +0000 (12:51 +0100)]
Revert "[mlir][linalg] Swap extract_slice(fill(x)) ops"

This reverts commit bcfd32adc4b658dc45aa8c338d5dd03837e2a0e4.

There is already a similar pattern in mlir/lib/Dialect/Linalg/Transforms/SwapExtractSliceWithFillPatterns.cpp

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

18 months ago[lldb] Add lldb-server targets to build docs
David Spickett [Tue, 20 Dec 2022 11:31:58 +0000 (11:31 +0000)]
[lldb] Add lldb-server targets to build docs

The current doc has people just do "ninja lldb" which is
not incorrect, it does build lldb. However it does not build lldb-server.
So you can't just "lldb some-binary" and expect it to work.

I've updated the instructions to reflect that most of the time
you'll want both lldb and lldb-server.

Though there is a use case for building just lldb. I'm assuming
Mac OS (where you have debugserver) and if you only wanted to do
remote debug.

Fixes #59575

Reviewed By: JDevlieghere

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

18 months ago[clangd] Tag clang-tidy diagnostics: modernize-*=deprecated, misc-unused-*=unneccesary
Sam McCall [Wed, 11 Jan 2023 20:06:25 +0000 (21:06 +0100)]
[clangd] Tag clang-tidy diagnostics: modernize-*=deprecated, misc-unused-*=unneccesary

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

18 months ago[include-cleaner] Treat a constructor call as a use of the class type.
Haojian Wu [Thu, 12 Jan 2023 11:40:12 +0000 (12:40 +0100)]
[include-cleaner] Treat a constructor call as a use of the class type.

Per the discussion in https://github.com/llvm/llvm-project/issues/59916.

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

18 months ago[lldb] Fix typo in integral format specifier
Michael Buch [Thu, 12 Jan 2023 12:06:03 +0000 (12:06 +0000)]
[lldb] Fix typo in integral format specifier

This regressed with `e262b8f48af9fdca8380f2f079e50291956aad71`.

Two issues here:
1. `:16x` is not a valid format specifier and
   we would crash when we encountered this log
   (which was the case in `TestCPPAccelerator.py`)
2. The third argument was missing curly braces so
   the log message itself was malformed.

18 months ago[clang] Fix unused variable warning in SemaConcept.cpp
Victor Komarov [Thu, 12 Jan 2023 11:55:21 +0000 (12:55 +0100)]
[clang] Fix unused variable warning in SemaConcept.cpp

Issue is described here: https://github.com/llvm/llvm-project/issues/59696

Reviewed By: hokein

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

18 months ago[Mips] Convert some tests to opaque pointers (NFC)
Nikita Popov [Thu, 12 Jan 2023 11:39:54 +0000 (12:39 +0100)]
[Mips] Convert some tests to opaque pointers (NFC)

Dropped bitcasts result in dropped COPYs in MIR.

18 months ago[Mips] Regenerate test checks (NFC)
Nikita Popov [Thu, 12 Jan 2023 11:24:06 +0000 (12:24 +0100)]
[Mips] Regenerate test checks (NFC)

18 months ago[OptTable] Precompute OptTable prefixes union table through tablegen
serge-sans-paille [Fri, 30 Dec 2022 07:32:59 +0000 (08:32 +0100)]
[OptTable] Precompute OptTable prefixes union table through tablegen

This avoid rediscovering this table when reading each options, providing
a sensible 2% speedup when processing and empty file, and a measurable
speedup on typical workloads, see:

This is optional, the legacy, on-the-fly, approach can still be used
through the GenericOptTable class, while the new one is used through
PrecomputedOptTable.

https://llvm-compile-time-tracker.com/compare.php?from=4da6cb3202817ee2897d6b690e4af950459caea4&to=19a492b704e8f5c1dea120b9c0d3859bd78796be&stat=instructions:u

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

18 months ago[OptTable] Make ValuesCode initialisation of Options constexpr
serge-sans-paille [Mon, 26 Dec 2022 07:51:47 +0000 (08:51 +0100)]
[OptTable] Make ValuesCode initialisation of Options constexpr

Current implementation requires a copy of the initialization array to a
vector to be able to modify their Values field.

This is inefficient: it requires a large copy to update a value, while
TableGen has all information to avoid this overwrite.

Modify TableGen to emit the Values code and use it to perform the
initialisation.

The impact on performance is not amazing compared to the actual
compilation, but still noticeable:

https://llvm-compile-time-tracker.com/compare.php?from=d9ab3e82f30d646deff054230b0c742704a1cf26&to=f2b37fb65d5149f70b43d1801beb5239285a2a20&stat=instructions:u

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

18 months ago[Flang] Add/Restore basic debug support (1/n)
Kiran Chandramohan [Thu, 12 Jan 2023 10:34:34 +0000 (10:34 +0000)]
[Flang] Add/Restore basic debug support (1/n)

Recent changes to MLIR meant that Flang does not generate any debug line
table information.

This patch adds a pass that provides some foundation work with which
basic line table debug info can be generated. A walk is performed on
all the `func` ops in the module and they are decorated with a fusedLoc
op that contains the debug metadata for the subroutine along with
location information.

Alternatives include populating this info during lowering or during FIR
to LLVM Dialect conversion.

Note: Patches in future will add
    -> more realistic debug info for types and other fields.
    -> driver flags to control generation of debug.

Fixes #58634.

Reviewed By: awarzynski, vzakhari

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

18 months ago[AMDGPU] Simplify getNumFlatOffsetBits. NFC.
Jay Foad [Thu, 22 Dec 2022 16:50:55 +0000 (16:50 +0000)]
[AMDGPU] Simplify getNumFlatOffsetBits. NFC.

Previously we considered this field to be either N-bit unsigned or
N+1-bit signed, depending on the instruction. I think it's conceptually
simpler to say that the field is always N+1-bit signed, but some
instructions do not allow negative values.

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

18 months ago[llvm/cmake] Replace CMAKE_SOURCE_DIR with PROJECT_SOURCE_DIR
Sebastian Neubauer [Wed, 11 Jan 2023 17:42:00 +0000 (18:42 +0100)]
[llvm/cmake] Replace CMAKE_SOURCE_DIR with PROJECT_SOURCE_DIR

When adding llvm to a build with add_subdirectory, CMAKE_SOURCE_DIR
refers to the source directory of the parent project. We want to use
PROJECT_SOURCE_DIR instead.

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

18 months agoRevert "Don't attempt to create vectors with complex element types."
Johannes Reifferscheid [Thu, 12 Jan 2023 10:34:19 +0000 (11:34 +0100)]
Revert "Don't attempt to create vectors with complex element types."

This reverts commit 91181db6d6fd896f01e1e89786d6d7d3d09a911e.

18 months ago[Attributor] Properly repair broken unittest
Johannes Doerfert [Thu, 12 Jan 2023 10:20:50 +0000 (02:20 -0800)]
[Attributor] Properly repair broken unittest

Reverts 2dc7c7095153822ecd1a8f43aa4c185f9e80cc00 and instead repairs the
unittest properly. The test was broken as that it used references to
dead functions, assumed dead functions could reach code, assumed code
would not be deleted, and did not pre-query all assertion queries.
Arguably, the querry AAs don't make it easy to use them outside the
attributor pipeline, maybe we just should not (or should fix them
pessimistically). For now, the unittest is fixed.

18 months ago[Assignment Tracking][Docs] Remove TODO for replacing undef with poison
OCHyams [Thu, 12 Jan 2023 10:17:53 +0000 (10:17 +0000)]
[Assignment Tracking][Docs] Remove TODO for replacing undef with poison

This has been resolved for assignment tracking by the patch D140906 and others
in the same stack.

18 months ago[Attributor][FIX] Avoid creating accidental poison callees
Johannes Doerfert [Thu, 12 Jan 2023 10:08:07 +0000 (02:08 -0800)]
[Attributor][FIX] Avoid creating accidental poison callees

Back with f3ad8cf00e213 we introduced a bug that caused us to skip
callees when we replace uses. This is not sound since subsequent IR
cleanup will assume replacement has happend. As such we created poison
callees for a long while. The original intend of the check was to
prevent call graph invalidation, however, we now properly check if the
instructions (here the call) are inside the SCC or not.

18 months ago[flang] Restore declared type when deallocating polymorphic entities
Valentin Clement [Thu, 12 Jan 2023 10:12:00 +0000 (11:12 +0100)]
[flang] Restore declared type when deallocating polymorphic entities

As mentioned in section 7.3.2.3 note 7, The dynamic type of an unallocated
allocatable object or a disassociated pointer is the same as its declared type.

This patch adds two function to the runtime:
- `PointerDeallocatePolymorphic`
- `AllocatableDeallocatePolymorphic`

These two functions take a DerivedTypeDesc pointer of the declared type.
The lowering is updated accordingly to call these functions for polymorphic
and unlimited polyrmophic entities. For unlimited polymorphic entities, the
dynamic type is set to nullptr when the entity is on an unallocated or
disassociated state.

Reviewed By: PeteSteinfeld, klausler

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

18 months ago[DebugInfo] Replace UndefValue with PoisonValue in AssignmentTrackingAnalysis
OCHyams [Thu, 12 Jan 2023 09:51:08 +0000 (09:51 +0000)]
[DebugInfo] Replace UndefValue with PoisonValue in AssignmentTrackingAnalysis

This helps towards the effort to remove UndefValue from LLVM.

Related to https://discourse.llvm.org/t/auto-undef-debug-uses-of-a-deleted-value

Reviewed By: scott.linder

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

18 months ago[include-mapping] Fix parsing of html_book_20190607.zip (https://en.cppreference...
Viktoriia Bakalova [Wed, 11 Jan 2023 16:01:33 +0000 (16:01 +0000)]
[include-mapping] Fix parsing of html_book_20190607.zip (https://en.cppreference.com/w/File:html_book_20190607.zip). Skip entries that have been added to the index (C++20 symbols), but the corresponding pages for which have not been created yet.

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

18 months ago[NFC][Assignment Tracking] Add is/setKillAddress
OCHyams [Wed, 11 Jan 2023 16:40:34 +0000 (16:40 +0000)]
[NFC][Assignment Tracking] Add is/setKillAddress

Unlike D140903 this patch folds in treating an empty metadata address component
of a dbg.assign the same as undef because it was already being treated that way
in the AssignmentTrackingAnalysis pass.

Reviewed By: scott.linder

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

18 months ago[analyzer] Don't escape local static memregions on bind
Balazs Benics [Thu, 12 Jan 2023 09:42:57 +0000 (10:42 +0100)]
[analyzer] Don't escape local static memregions on bind

When the engine processes a store to a variable, it will eventually call
`ExprEngine::processPointerEscapedOnBind()`. This function is supposed to
invalidate (put the given locations to an escape list) the locations
which we cannot reason about.

Unfortunately, local static variables are also put into this list.

This patch relaxes the guard condition, so that beyond stack variables,
static local variables are also ignored.

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

18 months ago[clang][Driver][CUDA] Get rid of unused LibPath
Kadir Cetinkaya [Wed, 11 Jan 2023 08:57:37 +0000 (09:57 +0100)]
[clang][Driver][CUDA] Get rid of unused LibPath

LibPath discovered during InstallationDetection wasn't used anywhere.
Moreover it actually resulted in discarding installations that don't have any
`/lib` directory.

This is causing troubles for our pipelines downstream, that want to perform
syntax-only analysis on the sources.

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

18 months ago[ODRHash] Handle `Integral` and `NullPtr` template parameters in `ODRHash`
isuckatcs [Sun, 8 Jan 2023 13:32:06 +0000 (14:32 +0100)]
[ODRHash] Handle `Integral` and `NullPtr` template parameters in `ODRHash`

Before this patch the parameters mentioned in the title weren't
handled by ODRHash, when a hash was generated for a template
specialization. This patch adds these parameters to the hash,
so that different template specializations will get different
hashes in every case.

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

18 months agoMarking TypeSize getFixedSize() and getKnownMinSize() deprecated
Guillaume Chatelet [Wed, 11 Jan 2023 17:02:32 +0000 (17:02 +0000)]
Marking TypeSize getFixedSize() and getKnownMinSize() deprecated

This change is the last of a series to implement the discussion from
https://reviews.llvm.org/D141134 to only keep one version of the functions.

18 months agoAvoid u8"" literals in tests, their type changes in C++20
Jens Massberg [Tue, 10 Jan 2023 16:12:49 +0000 (17:12 +0100)]
Avoid u8"" literals in tests, their type changes in C++20

Just specify the encoded bytes instead.
Additionally delete insertion operator of raw_ostream for char8_t as it
doesn't work as users might expect (Numbers and pointers are added to
the stream instead of UTF-8 characters). Added a comment and instructions
on how to use UTF-8 strings with raw_ostream.

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

18 months ago[Attributor][FIX] Avoid deleting (internal) library functions
Johannes Doerfert [Thu, 12 Jan 2023 09:06:41 +0000 (01:06 -0800)]
[Attributor][FIX] Avoid deleting (internal) library functions

In CGSCC mode we cannot delete internal library functions, esp.
__kmpc_alloc_shared, or we trigger an assertion. While the assertion is
probably too narrow, we avoid deleting those unused functions for now to
unblock the AMDGPU buildbot.

18 months ago[flang][NFC] Remove CallBuilder class
Jean Perier [Thu, 12 Jan 2023 09:14:07 +0000 (10:14 +0100)]
[flang][NFC] Remove CallBuilder class

The methods of CallBuilder do need to belong to a class.
This was made to avoid having to propagate generic lowering context
(converter, symbol mappings, location and StatementContext).

Packaging them together will actually make it harder to share the code
for user and intrinsic elemental lowering (I plan to use C++ CRTP),
and it is also misleading: one could think there is something going
with the class state while lowering the function while there is not
(and there should not be).

Removes the class and turns the methods into static functions.
Add a new CallContext class to solve the argument threading
inconvenience.

This contains no functional changes at all.

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

18 months ago[flang] Lower component-ref to hlfir.designate
Jean Perier [Thu, 12 Jan 2023 09:08:16 +0000 (10:08 +0100)]
[flang] Lower component-ref to hlfir.designate

Implement the visit of component refs in DesignatorBuilder.
The ArrayRef code has to be updated a bit to cope with the
case where the base is an array and the component is also an
array.

Improve the result type of array sections designators (only return
a fir.box if the array section is not contiguous/has dynamic extent).
This required exposing IsContiguous entry point for different
front-end designator nodes (the implementation already existed,
but was internal to check-expression.cpp).

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

18 months ago[IR] Support importing modules with invalid data layouts.
Jannik Silvanus [Wed, 4 Jan 2023 10:52:00 +0000 (11:52 +0100)]
[IR] Support importing modules with invalid data layouts.

Use the existing mechanism to change the data layout using callbacks.

Before this patch, we had a callback type DataLayoutCallbackTy that receives
a single StringRef specifying the target triple, and optionally returns
the data layout string to be used. Module loaders (both IR and BC) then
apply the callback to potentially override the module's data layout,
after first having imported and parsed the data layout from the file.

We can't do the same to fix invalid data layouts, because the import will already
fail, before the callback has a chance to fix it.
Instead, module loaders now tentatively parse the data layout into a string,
wait until the target triple has been parsed, apply the override callback
to the imported string and only then parse the tentative string as a data layout.

Moreover, add the old data layout string S as second argument to the callback,
in addition to the already existing target triple argument.
S is either the default data layout string in case none is specified, or the data
layout string specified in the module, possibly after auto-upgrades (for the BitcodeReader).
This allows callbacks to inspect the old data layout string,
and fix it instead of setting a fixed data layout.

Also allow to pass data layout override callbacks to lazy bitcode module
loader functions.

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

18 months ago[Clang] Emit noundef metadata next to range metadata
Nikita Popov [Wed, 11 Jan 2023 14:19:57 +0000 (15:19 +0100)]
[Clang] Emit noundef metadata next to range metadata

To preserve the previous semantics after D141386, adjust places
that currently emit !range metadata to also emit !noundef metadata.
This retains range violation as immediate undefined behavior,
rather than just poison.

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

18 months ago[LangRef] Make !range, !nonnull and !align return poison instead of IUB
Nikita Popov [Tue, 10 Jan 2023 15:06:30 +0000 (16:06 +0100)]
[LangRef] Make !range, !nonnull and !align return poison instead of IUB

Make violation of !range, !nonnull and !align metadata return poison
instead of causing immediate undefined behavior. This makes the
behavior match that of the nonnull and align parameter and return
value attributes. The previous behavior can be restored by additionally
specifying the !noundef metadata, same as with parameters.

Some benefits of this change are:

 * This is needed to fix https://github.com/llvm/llvm-project/issues/59888.
   Under current semantics, it is illegal to add !range annotations
   based on known bits. Unless we want to drop that optimization
   entirely, we need to change the !range semantics.
 * This allows preserving range/nonnull/align metadata on
   speculated loads. !noundef metadata needs to be dropped, but
   the poison-generating metadata can be retained.

I don't think there are really disadvantages to the change (apart
from the need to review and adjust optimizations for the new
semantics), as the old behavior is still available via !noundef,
so it should be strictly more flexible.

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

18 months agoDon't attempt to create vectors with complex element types.
Johannes Reifferscheid [Thu, 12 Jan 2023 08:54:47 +0000 (09:54 +0100)]
Don't attempt to create vectors with complex element types.

Reviewed By: pifon2a

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

18 months ago[OpenMP] Fix a test that fails when 'libgomp' is the default library
Dmitri Gribenko [Thu, 12 Jan 2023 08:24:55 +0000 (09:24 +0100)]
[OpenMP] Fix a test that fails when 'libgomp' is the default library

We can't do offloading with libgomp, thus the test fails. This change
explicitly chooses an OpenMP runtime library that is capable of
offloading.

This change is similar to
https://github.com/llvm/llvm-project/commit/a5098e5f27badc3ba16533418accd2e17641e4e4.

18 months ago[Attributor] Temporarily disable unit test to unbreak buildbots
Johannes Doerfert [Thu, 12 Jan 2023 08:51:33 +0000 (00:51 -0800)]
[Attributor] Temporarily disable unit test to unbreak buildbots

The root cause seems to have expressed in two separate errors and isn't
caught by any IR tests. Will be investigated.

18 months ago[mlir][Tosa][NFC] Migrate Tosa dialect to the new fold API
Markus Böck [Tue, 10 Jan 2023 19:27:12 +0000 (20:27 +0100)]
[mlir][Tosa][NFC] Migrate Tosa dialect to the new fold API

See https://discourse.llvm.org/t/psa-new-improved-fold-method-signature-has-landed-please-update-your-downstream-projects/67618 for context

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

18 months ago[mlir][Vector][NFC] Migrate Vector dialect to the new fold API
Markus Böck [Tue, 10 Jan 2023 19:18:31 +0000 (20:18 +0100)]
[mlir][Vector][NFC] Migrate Vector dialect to the new fold API

See https://discourse.llvm.org/t/psa-new-improved-fold-method-signature-has-landed-please-update-your-downstream-projects/67618 for context

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

18 months ago[mlir][Shape][NFC] Migrate shape dialect to the new fold API
Markus Böck [Tue, 10 Jan 2023 19:03:08 +0000 (20:03 +0100)]
[mlir][Shape][NFC] Migrate shape dialect to the new fold API

See https://discourse.llvm.org/t/psa-new-improved-fold-method-signature-has-landed-please-update-your-downstream-projects/67618 for context

Changes are mostly mechanical in nature. The code nevertheless became more expressive in a lot of places thanks to the use of the new getters!

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

18 months ago[cmake] Optionally install clang-tblgen to aid cross-compiling
James Le Cuirot [Thu, 12 Jan 2023 08:42:26 +0000 (09:42 +0100)]
[cmake] Optionally install clang-tblgen to aid cross-compiling

clang-tblgen is required to cross-compile clang itself. Unlike before,
most of the infrastructure is in place to do this now, and the only
thing preventing it is LLVM_BUILD_UTILS, which doesn't apply to Clang.

I thought about changing this to ${project}_BUILD_UTILS and adding
a CLANG_BUILD_UTILS option, but there seems little point for just one tool.

Instead, it checks whether clang-tblgen was explicitly requested in
LLVM_DISTRIBUTION_COMPONENTS, which is good enough for Gentoo and
other distributions.

Closes https://github.com/llvm/llvm-project/issues/20282.

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

18 months ago[OpenMP] Replace ExternalizationRAII with virtual uses
Johannes Doerfert [Wed, 11 Jan 2023 09:22:45 +0000 (01:22 -0800)]
[OpenMP] Replace ExternalizationRAII with virtual uses

The externalization was always a stopgap solution. One of the drawbacks
is that it is very conservative no matter if we actually require the
functions at the end of the pass. The new concept is more generic and
properly integrates into the dependence graph. Whenever we might need a
function, it has a "virtual use" that cannot be analyzed. If we do not
because of some AA state, there will be a dependence to ensure state
changes trigger revisits of uses, including a potentially new virtual
use.