platform/upstream/llvm.git
23 months ago[gn build] Port 122efef8ee9b
LLVM GN Syncbot [Mon, 5 Dec 2022 00:11:52 +0000 (00:11 +0000)]
[gn build] Port 122efef8ee9b

23 months ago[DebugInfo] llvm::Optional => std::optional
Fangrui Song [Mon, 5 Dec 2022 00:09:22 +0000 (00:09 +0000)]
[DebugInfo] llvm::Optional => std::optional

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[clang] Use std::nullopt instead of None in comments (NFC)
Kazu Hirata [Sun, 4 Dec 2022 23:57:24 +0000 (15:57 -0800)]
[clang] Use std::nullopt instead of None in comments (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months agoRevert "Reapply "[CodeGen] Add new pass for late cleanup of redundant definitions.""
Jonas Paulsson [Sun, 4 Dec 2022 23:52:00 +0000 (00:52 +0100)]
Revert "Reapply "[CodeGen] Add new pass for late cleanup of redundant definitions.""

This reverts commit 17db0de330f943833296ae72e26fa988bba39cb3.

Some more bots got broken - need to investigate.

23 months ago[flang] Check restrictions on TRANSFER()
Peter Klausler [Thu, 17 Nov 2022 01:10:05 +0000 (17:10 -0800)]
[flang] Check restrictions on TRANSFER()

Enforce detectable compilation-time violations of restrictions on the
arguments to the TRANSFER() intrinsic function (16.9.163) with
error messages, and mark other potential problems with warnings.

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

23 months ago[SanitizerBinaryMetadata] Use weak __start_/__stop_ instead of dummy empty section
Fangrui Song [Sun, 4 Dec 2022 23:06:34 +0000 (15:06 -0800)]
[SanitizerBinaryMetadata] Use weak __start_/__stop_ instead of dummy empty section

D130887 uses a dummy empty section `sanmd_covered` (with the SHF_GNU_RETAIN flag on
ELF) to prevent `undefined symbol: __start_sanmd_covered` if all `sanmd_covered`
are discarded by `ld --gc-sections` (in `-z start-stop-gc` mode).

The dummy `sanmd_covered` does not have the SHF_LINK_ORDER flag, so mixing it
with SHF_LINK_ORDER `sanmd_covered` causes an issue to GNU ld<2.36
(https://sourceware.org/bugzilla/show_bug.cgi?id=26256).

Similar to D98903 for SanitizerCoverage, let's make encapsulation symbols
undefined weak[1]. This additionally avoids size cost due to the dummy section and
symbol.

[1]: https://maskray.me/blog/2021-01-31-metadata-sections-comdat-and-shf-link-order

Reviewed By: melver

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

23 months ago[IR] Use std::nullopt instead of None (NFC)
Kazu Hirata [Sun, 4 Dec 2022 23:05:22 +0000 (15:05 -0800)]
[IR] Use std::nullopt instead of None (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[VPlan] Support sinking VPScalarIVStepsRecipe.
Florian Hahn [Sun, 4 Dec 2022 22:59:16 +0000 (22:59 +0000)]
[VPlan] Support sinking VPScalarIVStepsRecipe.

This patch extends VP-based sinking to also sink VPScalarStepsRecipe.
This takes us a step closer towards retiring the IR based sinking.

The main change is extending VPScalarIVStepsRecipe::execute to support
executing in a replicate-region.

Depends on D133758.

Reviewed By: Ayal

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

23 months ago[Target] llvm::Optional => std::optional
Fangrui Song [Sun, 4 Dec 2022 22:43:14 +0000 (22:43 +0000)]
[Target] llvm::Optional => std::optional

The updated functions are mostly internal with a few exceptions (virtual functions in
TargetInstrInfo.h, TargetRegisterInfo.h).
To minimize changes to LLVMCodeGen, GlobalISel files are skipped.

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[flang] Use std::nullopt instead of None (NFC)
Kazu Hirata [Sun, 4 Dec 2022 22:40:10 +0000 (14:40 -0800)]
[flang] Use std::nullopt instead of None (NFC)

I've verified that every single instance of std::nullopt in this patch
affects generated files and would reduce the number of warnings if
None were deprecated.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[mlir] Use std::nullopt instead of None (NFC)
Kazu Hirata [Sun, 4 Dec 2022 22:40:08 +0000 (14:40 -0800)]
[mlir] Use std::nullopt instead of None (NFC)

I've verified that every single instance of std::nullopt in this patch
affects generated files and would reduce the number of warnings if
None were deprecated.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[flang] Use std::nullopt instead of None (NFC)
Kazu Hirata [Sun, 4 Dec 2022 21:52:47 +0000 (13:52 -0800)]
[flang] Use std::nullopt instead of None (NFC)

I've verified that every change in this patch affects generated files
and would reduce the number of warnings if None were deprecated.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[mlir] Use std::nullopt instead of None (NFC)
Kazu Hirata [Sun, 4 Dec 2022 21:52:45 +0000 (13:52 -0800)]
[mlir] Use std::nullopt instead of None (NFC)

I've verified that every change in this patch affects generated files
and would reduce the number of warnings if None were deprecated.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[clang] Use std::nullopt instead of None (NFC)
Kazu Hirata [Sun, 4 Dec 2022 21:52:44 +0000 (13:52 -0800)]
[clang] Use std::nullopt instead of None (NFC)

I've verified that every change in this patch affects generated files
and would reduce the number of warnings if None were deprecated.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[llvm] Use std::nullopt instead of None (NFC)
Kazu Hirata [Sun, 4 Dec 2022 21:52:42 +0000 (13:52 -0800)]
[llvm] Use std::nullopt instead of None (NFC)

I've verified that every change in this patch affects generated files
and would reduce the number of warnings if None were deprecated.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[MC] llvm::Optional => std::optional
Fangrui Song [Sun, 4 Dec 2022 21:36:08 +0000 (21:36 +0000)]
[MC] llvm::Optional => std::optional

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[flang] Fix pgoOpt
Fangrui Song [Sun, 4 Dec 2022 21:29:00 +0000 (21:29 +0000)]
[flang] Fix pgoOpt

23 months ago[flang] Emit errors and warnings about DIM= arguments to intrinsic functions
Peter Klausler [Wed, 16 Nov 2022 21:48:45 +0000 (13:48 -0800)]
[flang] Emit errors and warnings about DIM= arguments to intrinsic functions

The semantics of many transformational intrinsic functions, especially
reductions like SUM(), are determined by the static presence or absence
of a DIM= argument.  In the case of an actual DIM= argument that is
syntactically present but could be dynamically absent at execution time
(due to being OPTIONAL, POINTER, or ALLOCATABLE), f18 should emit some
kind of diagnostic message.

Other compilers either ignore this possibility or treat it as a hard
error; neither really seems correct, so let's do something more nuanced.

For cases where the dynamic absence of a value for DIM doesn't pose
as much of a risk because it lowering is going to assume that it's
equal to 1 anyway, emit only a portability warning.

For other cases where the generated code or runtime support library
will need the value of DIM= during execution, emit a warning that
the use of an OPTIONAL/POINTER/ALLOCATABLE variable or component
here is dicey and should be reconsidered.

While here, also catch bad constant DIM= values.

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

23 months ago[Passes] llvm::Optional => std::optional
Fangrui Song [Sun, 4 Dec 2022 20:44:52 +0000 (20:44 +0000)]
[Passes] llvm::Optional => std::optional

23 months agoInstructions: convert Optional to std::optional
Krzysztof Parzyszek [Sat, 3 Dec 2022 21:26:59 +0000 (15:26 -0600)]
Instructions: convert Optional to std::optional

23 months ago[clang-format] Link the braces of a block in UnwrappedLineParser
Owen Pan [Sat, 3 Dec 2022 15:16:32 +0000 (07:16 -0800)]
[clang-format] Link the braces of a block in UnwrappedLineParser

This includes TT_MacroBlockBegin and TT_MacroBlockEnd as well.

We can no longer use MatchingParen of FormatToken as an indicator
to mark optional braces. Instead, we directly set Optional of an
l_brace first and reset it later if it turns out that the braces
are not optional.

Also added a test case for deeply nested loops.

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

23 months ago[ELF][test] Clean up aarch64-variant_pcs.s
Fangrui Song [Sun, 4 Dec 2022 19:52:11 +0000 (11:52 -0800)]
[ELF][test] Clean up aarch64-variant_pcs.s

23 months agoUndo a bit of fcf4e360ba6b that confuses MSVC
Benjamin Kramer [Sun, 4 Dec 2022 19:33:25 +0000 (20:33 +0100)]
Undo a bit of fcf4e360ba6b that confuses MSVC

clang\lib\Serialization\GlobalModuleIndex.cpp(818): error C2440: 'initializing': cannot convert from 'const ValueTy' to '_Ty2 &&'
        with
        [
            ValueTy=llvm::SmallVector<unsigned int,2>
        ]
        and
        [
            _Ty2=llvm::SmallVector<unsigned int,2>
        ]

23 months ago[test] Fix CodeGen/M68k/pipeline.ll after D123394 MachineLateInstrsCleanupPass
Fangrui Song [Sun, 4 Dec 2022 19:08:37 +0000 (19:08 +0000)]
[test] Fix CodeGen/M68k/pipeline.ll after D123394 MachineLateInstrsCleanupPass

23 months agoIR: HotnessThreshold llvm::Optional => std::optional
Fangrui Song [Sun, 4 Dec 2022 19:06:47 +0000 (19:06 +0000)]
IR: HotnessThreshold llvm::Optional => std::optional

23 months ago[BOLT] Fix after DebugInfoMetadata change 0ca43d44888885d6caf7636db91fe810e822263c
Fangrui Song [Sun, 4 Dec 2022 18:57:52 +0000 (18:57 +0000)]
[BOLT] Fix after DebugInfoMetadata change 0ca43d44888885d6caf7636db91fe810e822263c

23 months ago[flang] Check constraint C834 on INTENT(OUT) assumed-size dummy arrays
Peter Klausler [Tue, 15 Nov 2022 20:14:51 +0000 (12:14 -0800)]
[flang] Check constraint C834 on INTENT(OUT) assumed-size dummy arrays

An assumed-size dummy array argument with INTENT(OUT) can't have a type
that might require any runtime (re)initialization, since the size of the
array is not known.

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

23 months ago[NFC][SimplifyCFG] Add some tests with PHI's for fold-branch-to-common-dest xform
Roman Lebedev [Sun, 4 Dec 2022 15:51:57 +0000 (18:51 +0300)]
[NFC][SimplifyCFG] Add some tests with PHI's for fold-branch-to-common-dest xform

23 months ago[NFC] Re-autogenerate checklines in a few tests being affected
Roman Lebedev [Sun, 4 Dec 2022 17:50:26 +0000 (20:50 +0300)]
[NFC] Re-autogenerate checklines in a few tests being affected

23 months ago[NFC][SimplifyCFG] `shouldFoldCondBranchesToCommonDestination()`: report the common...
Roman Lebedev [Sun, 4 Dec 2022 16:29:16 +0000 (19:29 +0300)]
[NFC][SimplifyCFG] `shouldFoldCondBranchesToCommonDestination()`: report the common succ

23 months agoDebugInfoMetadata: convert Optional to std::optional
Krzysztof Parzyszek [Sat, 3 Dec 2022 22:01:15 +0000 (16:01 -0600)]
DebugInfoMetadata: convert Optional to std::optional

23 months agoIterate over StringMaps using structured bindings. NFCI.
Benjamin Kramer [Sun, 4 Dec 2022 17:36:41 +0000 (18:36 +0100)]
Iterate over StringMaps using structured bindings. NFCI.

23 months ago[ADT] Enable structured bindings for iterating StringMap
Benjamin Kramer [Sun, 4 Dec 2022 16:30:33 +0000 (17:30 +0100)]
[ADT] Enable structured bindings for iterating StringMap

const references only for now, we can add overloads to have a mutable or
movable `second` if the need arises.

23 months agoCompress a few pairs using PointerIntPairs
Benjamin Kramer [Sun, 4 Dec 2022 15:15:39 +0000 (16:15 +0100)]
Compress a few pairs using PointerIntPairs

Use the uniform structured bindings interface where possible. NFCI.

23 months agoDebugInfo: convert Optional to std::optional
Krzysztof Parzyszek [Sat, 3 Dec 2022 21:55:23 +0000 (15:55 -0600)]
DebugInfo: convert Optional to std::optional

23 months ago[ADT] Allow structured bindings on PointerIntPair
Benjamin Kramer [Sun, 4 Dec 2022 15:10:00 +0000 (16:10 +0100)]
[ADT] Allow structured bindings on PointerIntPair

Apart from simplifying code, this has the advantage of making the
interface between std::pair and PointerIntPair more uniform.

23 months ago[NFC][clang] Strengthen checks in avx512fp16-builtins.c
John McIver [Sun, 4 Dec 2022 14:57:34 +0000 (14:57 +0000)]
[NFC][clang] Strengthen checks in avx512fp16-builtins.c

* Add end-of-line check to load instructions

23 months ago[NFC][clang] Strengthen checks in avx512f-builtins.c
John McIver [Sun, 4 Dec 2022 14:55:03 +0000 (14:55 +0000)]
[NFC][clang] Strengthen checks in avx512f-builtins.c

* Add check to unnamed portion of nontemporal attribute
* Add end-of-line check to load instructions

23 months ago[VPlan] Mark VPScalarIVStepsRecipe as not reading/writing memory.
Florian Hahn [Sun, 4 Dec 2022 12:58:46 +0000 (12:58 +0000)]
[VPlan] Mark VPScalarIVStepsRecipe as not reading/writing memory.

The recipe only computes the inductions steps using its operands. It
does neither read nor write memory.

Split of from D133760.

23 months ago[VPlan] Add sideeffect/memory unit test for VPScalarIVStepsRecipe. (NFC)
Florian Hahn [Sun, 4 Dec 2022 12:50:09 +0000 (12:50 +0000)]
[VPlan] Add sideeffect/memory unit test for VPScalarIVStepsRecipe. (NFC)

23 months ago[OpenMP][libomptarget] Add hasQueue() function in NextGen plugin's AsyncInfoWrapperTy
Kevin Sala [Sun, 4 Dec 2022 00:40:39 +0000 (01:40 +0100)]
[OpenMP][libomptarget] Add hasQueue() function in NextGen plugin's AsyncInfoWrapperTy

This patch prepares the PluginInterface for the new AMDGPU NextGen plugin.

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

23 months ago[LV] Update test to use use variables in CHECK lines.
Florian Hahn [Sun, 4 Dec 2022 11:59:00 +0000 (11:59 +0000)]
[LV] Update test to use use variables in CHECK lines.

This makes the test more robust with respect to value numbering which
will change with future changes.

23 months ago[mlir][affine] Support affine.parallel in the index set analysis
Kai Sasaki [Sun, 4 Dec 2022 11:09:01 +0000 (20:09 +0900)]
[mlir][affine] Support affine.parallel in the index set analysis

Support affine.parallel in the index set analysis. It allows us to do dependence analysis containing affine.parallel in addition to affine.for and affine.if. This change only supports the constant lower/upper bound in affine.parallel. Other complicated affine map bounds will be supported in further commits.

See https://github.com/llvm/llvm-project/issues/57327

Reviewed By: bondhugula

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

23 months agoRevert "[AArch64] Make ArchInfo copyable again"
Tomas Matheson [Sun, 4 Dec 2022 11:00:01 +0000 (11:00 +0000)]
Revert "[AArch64] Make ArchInfo copyable again"

This reverts commit 6272f87ba06132a1b479068759d72178e5fe4472.

23 months ago[DWARFLinker][NFC] Change interface of DWARFLinker to specify accel table kinds expli...
Alexey Lapshin [Sun, 20 Nov 2022 19:03:51 +0000 (20:03 +0100)]
[DWARFLinker][NFC] Change interface of DWARFLinker to specify accel table kinds explicitly.

Currently, DWARFLinker receives kind of accel tables as predefined sets:

```
  Apple,   ///< .apple_names, .apple_namespaces, .apple_types, .apple_objc.
  Dwarf,   ///< DWARF v5 .debug_names.
  Default, ///< Dwarf for DWARF5 or later, Apple otherwise.
  Pub,     ///< .debug_pubnames, .debug_pubtypes
```

This patch removes implicit sets of tables(Default, Dwarf) and allows to ask for several sets:

```
  Apple,     ///< .apple_names, .apple_namespaces, .apple_types, .apple_objc.
  Pub,       ///< .debug_pubnames, .debug_pubtypes
  DebugNames ///< .debug_names.
```

It allows seamlessness adding more accel tables in the future: .gdb_index, .debug_cu_index...
Doing things that way, DWARFLinker will be independent of consumers' requirements.
f.e. dsymutil and llvm-dwarfutil may have different variants for Default set
(so, instead of implementing these differencies inside DWARFLinker it could be
implemented in the corresponding module).

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

23 months ago[Object] llvm::Optional => std::optional
Fangrui Song [Sun, 4 Dec 2022 09:11:11 +0000 (09:11 +0000)]
[Object] llvm::Optional => std::optional

23 months agoCorrect typo introduced in f607884a04b0ca06951227a01d00bc59b948d337
serge-sans-paille [Sat, 3 Dec 2022 21:23:44 +0000 (22:23 +0100)]
Correct typo introduced in f607884a04b0ca06951227a01d00bc59b948d337

Fix #59321

23 months ago[flang/unittests] Use std::nullopt instead of None (NFC)
Kazu Hirata [Sun, 4 Dec 2022 03:08:01 +0000 (19:08 -0800)]
[flang/unittests] Use std::nullopt instead of None (NFC)

This patch mechanically replaces None with std::nullopt where the
compiler would warn if None were deprecated.  The intent is to reduce
the amount of manual work required in migrating from Optional to
std::optional.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[mlir/unittests] Use std::nullopt instead of None (NFC)
Kazu Hirata [Sun, 4 Dec 2022 03:07:59 +0000 (19:07 -0800)]
[mlir/unittests] Use std::nullopt instead of None (NFC)

This patch mechanically replaces None with std::nullopt where the
compiler would warn if None were deprecated.  The intent is to reduce
the amount of manual work required in migrating from Optional to
std::optional.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[polly] Use std::nullopt instead of None (NFC)
Kazu Hirata [Sun, 4 Dec 2022 02:50:29 +0000 (18:50 -0800)]
[polly] Use std::nullopt instead of None (NFC)

This patch mechanically replaces None with std::nullopt where the
compiler would warn if None were deprecated.  The intent is to reduce
the amount of manual work required in migrating from Optional to
std::optional.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[mlir] Use std::nullopt instead of None (NFC)
Kazu Hirata [Sun, 4 Dec 2022 02:50:27 +0000 (18:50 -0800)]
[mlir] Use std::nullopt instead of None (NFC)

This patch mechanically replaces None with std::nullopt where the
compiler would warn if None were deprecated.  The intent is to reduce
the amount of manual work required in migrating from Optional to
std::optional.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[MLIR] Fix typo in `add_mlir_library` docs. NFC.
Joe Loser [Sun, 4 Dec 2022 02:27:37 +0000 (19:27 -0700)]
[MLIR] Fix typo in `add_mlir_library` docs. NFC.

`s/librar/library` in `llvm_add_library`.

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

23 months ago[MLIR] Use `if constexpr` in `StorageUniquer` and `IR/AffineExpr`
Joe Loser [Sun, 4 Dec 2022 01:01:53 +0000 (18:01 -0700)]
[MLIR] Use `if constexpr` in `StorageUniquer` and `IR/AffineExpr`

Querying the type trait is something that can be done at compile time. So,
replace the runtime `if` with `if constexpr`.

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

23 months ago[flang] Warn about local names that are the same as their enclosing program unit
Peter Klausler [Mon, 14 Nov 2022 22:38:03 +0000 (14:38 -0800)]
[flang] Warn about local names that are the same as their enclosing program unit

Modules, submodules, main programs, and BLOCK DATA subprograms have names
that cannot be used within their scope, so we allow those names to be
used for other entities in the scope.  This might not be entirely
conformant with the language standard, so warn about it.

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

23 months ago[flang] More error checking for ASSOCIATED()
Peter Klausler [Mon, 14 Nov 2022 18:29:32 +0000 (10:29 -0800)]
[flang] More error checking for ASSOCIATED()

The TARGET= argument of the ASSOCIATED() intrinsic function must be a valid
pointer assignment statement target.  Ensure that it does not contain a vector
subscript or any coindexing, either of which would imply a data copy into
temporary storage.

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

23 months ago[flang] Emit portability warning for assigned FORMAT use
Peter Klausler [Mon, 14 Nov 2022 17:42:12 +0000 (09:42 -0800)]
[flang] Emit portability warning for assigned FORMAT use

Emit a portability warning about usage of a deprecated feature
when an I/O data transfer statement uses a scalar integer
variable as an assigned format.

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

23 months ago[flang] INTENT(IN) pointer may not be forwarded to INTENT(IN OUT) or (OUT) dummy
Peter Klausler [Mon, 14 Nov 2022 01:08:01 +0000 (17:08 -0800)]
[flang] INTENT(IN) pointer may not be forwarded to INTENT(IN OUT) or (OUT) dummy

19.6.8 forbids using an INTENT(IN) pointer dummy argument in a pointer association
context, and associated such a pointer with a dummy argument of INTENT(IN OUT) or
INTENT(OUT) is a circumstance that needs to be caught as an error.

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

23 months ago[MLIR] Simplify key construction/hashing in StorageUniquer
Joe Loser [Sat, 3 Dec 2022 05:18:24 +0000 (22:18 -0700)]
[MLIR] Simplify key construction/hashing in StorageUniquer

`getKey` and `getHash` use mutually exclusive overloads based on existence of
methods to determine how to compute get the key or hash, respectively.  This is
a bit verbose with `std::enable_if_t`.  Simplify it a bit by using
`if constexpr` directly.  As an added bonus, this is slightly quicker to
compile.

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

23 months ago[flang] Check constraint C1577 for statement functions
Peter Klausler [Thu, 10 Nov 2022 18:24:38 +0000 (10:24 -0800)]
[flang] Check constraint C1577 for statement functions

Check most of the requiremens of constraint C1577 for statement functions.
The restrictions that prevent recursion are hard errors; the others seem
to be benign legacies and are caught as portability warnings.

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

23 months agoRemove a useless temporary of a base class type.
Alexander Kornienko [Sat, 3 Dec 2022 22:58:37 +0000 (23:58 +0100)]
Remove a useless temporary of a base class type.

This was found by clang-tidy bugprone-undelegated-constructor check.
Was there since the very first commit back in 2016.

Reviewed By: clayborg, labath, srhines

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

23 months ago[flang] Don't repeat module procedure interface from ancestor in *.mod file
Peter Klausler [Thu, 1 Dec 2022 19:41:40 +0000 (11:41 -0800)]
[flang] Don't repeat module procedure interface from ancestor in *.mod file

When a submodule defines a module procedure whose interface was declared
in an ancestor (sub)module, don't repeat the definition of that interface
in the submodule's *.mod file output.

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

23 months ago[OpenMP][libomptarget] Simplify resource managers in NextGen plugins
Kevin Sala [Sun, 27 Nov 2022 22:12:41 +0000 (23:12 +0100)]
[OpenMP][libomptarget] Simplify resource managers in NextGen plugins

This patch removes the classes GenericStreamManagerTy and GenericEventManagerTy
from the PluginInterface header.

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

23 months ago[OpenMP][libomptarget] Improve NextGen plugin interface for initialization
Kevin Sala [Wed, 23 Nov 2022 23:24:12 +0000 (00:24 +0100)]
[OpenMP][libomptarget] Improve NextGen plugin interface for initialization

This patch modifies the PluginInterface to define functions for initializing
and deinitializing GenericPluginTy instances instead of using the constructor
and destructor. This way, we can return errors from these functions. Also, it
defines some functions that each plugin should implement for creating
plugin-specific objects.

This patch prepares the PluginInterface for the new AMDGPU NextGen plugin.

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

23 months agoIRBuilder: convert Optional to std::optional
Krzysztof Parzyszek [Sat, 3 Dec 2022 19:11:42 +0000 (13:11 -0600)]
IRBuilder: convert Optional to std::optional

23 months ago[OpenMP][libomptarget] Add minor fixes to NextGen plugins
Kevin Sala [Wed, 23 Nov 2022 22:27:53 +0000 (23:27 +0100)]
[OpenMP][libomptarget] Add minor fixes to NextGen plugins

List of fixes:
  - omptarget_device_environment symbol is not mandatory in device images
  - Do not synchronize in ~AsyncInfoWrapperTy() if the async info's queue is null
  - GenericDeviceResourceRef's create() and destroy() require the device as parameter

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

23 months ago[OpenMP][libomptarget] Allow overriding function that gets ELF symbol info
Kevin Sala [Wed, 23 Nov 2022 21:15:14 +0000 (22:15 +0100)]
[OpenMP][libomptarget] Allow overriding function that gets ELF symbol info

The OpenMP target's NextGen plugins retrieve symbol information in the ELF image
(i.e., address and size) through the ELF section and ELF symbol objects. However,
the images of CUDA programs compute the address differently from the images of
AMDGPU programs:

  - Address for CUDA symbols: image begin + section's offset + symbol's st_value
  - Address for AMDGPU symbols: image + begin + symbol's st_value

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

23 months ago[flang] Take character function length into account when testing compatibility
Peter Klausler [Wed, 9 Nov 2022 22:20:32 +0000 (14:20 -0800)]
[flang] Take character function length into account when testing compatibility

When a character-valued function is passed as an actual argument, and both
the actual function and the dummy argument have explicit result lengths, take them
into account when testing for compatibility.

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

23 months ago[gn build] Port 17db0de330f9
LLVM GN Syncbot [Sat, 3 Dec 2022 20:23:49 +0000 (20:23 +0000)]
[gn build] Port 17db0de330f9

23 months ago[COFF] llvm::Optional => std::optional
Fangrui Song [Sat, 3 Dec 2022 20:23:39 +0000 (20:23 +0000)]
[COFF] llvm::Optional => std::optional

23 months ago[Driver] llvm::Optional => std::optional
Fangrui Song [Sat, 3 Dec 2022 20:17:05 +0000 (20:17 +0000)]
[Driver] llvm::Optional => std::optional

and change a few referenced Basic and llvm/lib/WindowsDriver API

23 months agoReapply "[CodeGen] Add new pass for late cleanup of redundant definitions."
Jonas Paulsson [Thu, 1 Dec 2022 18:33:11 +0000 (19:33 +0100)]
Reapply "[CodeGen] Add new pass for late cleanup of redundant definitions."

Init captures added in processBlock() to avoid capturing structured bindings,
which caused the build problems (with clang).

RISCV has this disabled for now until problems relating to post RA pseudo
expansions are resolved.

23 months ago[flang] Use std::nullopt instead of None (NFC)
Kazu Hirata [Sat, 3 Dec 2022 20:14:21 +0000 (12:14 -0800)]
[flang] Use std::nullopt instead of None (NFC)

This patch mechanically replaces None with std::nullopt where the
compiler would warn if None were deprecated.  The intent is to reduce
the amount of manual work required in migrating from Optional to
std::optional.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[clang/unittests] Use std::nullopt instead of None (NFC)
Kazu Hirata [Sat, 3 Dec 2022 20:14:19 +0000 (12:14 -0800)]
[clang/unittests] Use std::nullopt instead of None (NFC)

This patch mechanically replaces None with std::nullopt where the
compiler would warn if None were deprecated.  The intent is to reduce
the amount of manual work required in migrating from Optional to
std::optional.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months agoFPEnv: convert Optional to std::optional
Krzysztof Parzyszek [Sat, 3 Dec 2022 19:54:35 +0000 (13:54 -0600)]
FPEnv: convert Optional to std::optional

23 months ago[clang-tools-extra] Use std::nullopt instead of None (NFC)
Kazu Hirata [Sat, 3 Dec 2022 19:54:50 +0000 (11:54 -0800)]
[clang-tools-extra] Use std::nullopt instead of None (NFC)

This patch mechanically replaces None with std::nullopt where the
compiler would warn if None were deprecated.  The intent is to reduce
the amount of manual work required in migrating from Optional to
std::optional.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[clang-tidy] Use std::nullopt instead of None (NFC)
Kazu Hirata [Sat, 3 Dec 2022 19:54:48 +0000 (11:54 -0800)]
[clang-tidy] Use std::nullopt instead of None (NFC)

This patch mechanically replaces None with std::nullopt where the
compiler would warn if None were deprecated.  The intent is to reduce
the amount of manual work required in migrating from Optional to
std::optional.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[clang] Use std::nullopt instead of None (NFC)
Kazu Hirata [Sat, 3 Dec 2022 19:54:46 +0000 (11:54 -0800)]
[clang] Use std::nullopt instead of None (NFC)

This patch mechanically replaces None with std::nullopt where the
compiler would warn if None were deprecated.  The intent is to reduce
the amount of manual work required in migrating from Optional to
std::optional.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[Driver] llvm::None => std::nullopt. NFC
Fangrui Song [Sat, 3 Dec 2022 19:43:25 +0000 (19:43 +0000)]
[Driver] llvm::None => std::nullopt. NFC

23 months ago[Basic] Use std::nullopt instead of None (NFC)
Kazu Hirata [Sat, 3 Dec 2022 19:34:27 +0000 (11:34 -0800)]
[Basic] Use std::nullopt instead of None (NFC)

This patch mechanically replaces None with std::nullopt where the
compiler would warn if None were deprecated.  The intent is to reduce
the amount of manual work required in migrating from Optional to
std::optional.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[Analysis] Use std::nullopt instead of None (NFC)
Kazu Hirata [Sat, 3 Dec 2022 19:34:25 +0000 (11:34 -0800)]
[Analysis] Use std::nullopt instead of None (NFC)

This patch mechanically replaces None with std::nullopt where the
compiler would warn if None were deprecated.  The intent is to reduce
the amount of manual work required in migrating from Optional to
std::optional.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[StaticAnalyzer] Use std::nullopt instead of None (NFC)
Kazu Hirata [Sat, 3 Dec 2022 19:34:24 +0000 (11:34 -0800)]
[StaticAnalyzer] Use std::nullopt instead of None (NFC)

This patch mechanically replaces None with std::nullopt where the
compiler would warn if None were deprecated.  The intent is to reduce
the amount of manual work required in migrating from Optional to
std::optional.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[flang] Disable flang/test/Semantics/resolve110.f90 on Windows
Peter Klausler [Sat, 3 Dec 2022 19:21:54 +0000 (11:21 -0800)]
[flang] Disable flang/test/Semantics/resolve110.f90 on Windows

This test crashes Semantics (infinite recursion?) only when built with MSVC;
need to investigate further, disabling test for now.

23 months ago[CodeGen] Use std::nullopt instead of None (NFC)
Kazu Hirata [Sat, 3 Dec 2022 19:13:43 +0000 (11:13 -0800)]
[CodeGen] Use std::nullopt instead of None (NFC)

This patch mechanically replaces None with std::nullopt where the
compiler would warn if None were deprecated.  The intent is to reduce
the amount of manual work required in migrating from Optional to
std::optional.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[AST] Use std::nullopt instead of None (NFC)
Kazu Hirata [Sat, 3 Dec 2022 19:13:41 +0000 (11:13 -0800)]
[AST] Use std::nullopt instead of None (NFC)

This patch mechanically replaces None with std::nullopt where the
compiler would warn if None were deprecated.  The intent is to reduce
the amount of manual work required in migrating from Optional to
std::optional.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[Sema] Use std::nullopt instead of None (NFC)
Kazu Hirata [Sat, 3 Dec 2022 19:13:39 +0000 (11:13 -0800)]
[Sema] Use std::nullopt instead of None (NFC)

This patch mechanically replaces None with std::nullopt where the
compiler would warn if None were deprecated.  The intent is to reduce
the amount of manual work required in migrating from Optional to
std::optional.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

23 months ago[flang] Document and warn about an extension
Peter Klausler [Thu, 1 Dec 2022 18:13:57 +0000 (10:13 -0800)]
[flang] Document and warn about an extension

Standard Fortran allows type-bound procedure bindings to only
be called, and disallows them from being used in other contexts
where a procedure name can be: as the target of a procedure pointer
assignment statement, and as an actual argument that corresponds
to a dummy procedure.  So long as the interfaces match, there's
no good reason for these uses to be errors, and there some obvious
use cases in polymorphic programming.  So emit portability warnings
rather than errors, and document this usage as an extension.

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

23 months ago[lldb] Convert Optional<llvm::Reloc::Model> to std::optional
Fangrui Song [Sat, 3 Dec 2022 18:49:51 +0000 (18:49 +0000)]
[lldb] Convert Optional<llvm::Reloc::Model> to std::optional

23 months agoCodeGen/CommandFlags: Convert Optional to std::optional
Fangrui Song [Sat, 3 Dec 2022 18:38:12 +0000 (18:38 +0000)]
CodeGen/CommandFlags: Convert Optional to std::optional

23 months ago[flang] Enforce accessibility requirement on type-bound generic operators, &c.
Peter Klausler [Thu, 1 Dec 2022 01:40:48 +0000 (17:40 -0800)]
[flang] Enforce accessibility requirement on type-bound generic operators, &c.

Type-bound generics like operator(+) and assignment(=) need to not be
PRIVATE if they are used outside the module in which they are declared.

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

23 months ago[ELF] Add final to some SyntheticSection derived classes
Fangrui Song [Sat, 3 Dec 2022 18:11:34 +0000 (18:11 +0000)]
[ELF] Add final to some SyntheticSection derived classes

23 months agoConvert Optional<CodeModel> to std::optional<CodeModel>
Krzysztof Parzyszek [Sat, 3 Dec 2022 17:06:12 +0000 (11:06 -0600)]
Convert Optional<CodeModel> to std::optional<CodeModel>

23 months ago[ELF] Fix TimeTraceScope for "Finalize .eh_frame"
Fangrui Song [Sat, 3 Dec 2022 18:00:51 +0000 (18:00 +0000)]
[ELF] Fix TimeTraceScope for "Finalize .eh_frame"

23 months ago[flang] Warn on missing colons (C768)
Peter Klausler [Mon, 7 Nov 2022 23:51:03 +0000 (15:51 -0800)]
[flang] Warn on missing colons (C768)

In a derived type definition, a type bound procedure declaration
statement with neither interface nor attributes is required by constraint
C768 to have the optional "::" between the PROCEDURE keyword and the
bindings if any binding has a renaming with "=>".  The colons are
not actually necessary for a correct and unambiguous parse, so
emit a warning when they are missing.

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

23 months ago[AArch64] Enable the select optimize pass for AArch64
David Green [Sat, 3 Dec 2022 16:08:58 +0000 (16:08 +0000)]
[AArch64] Enable the select optimize pass for AArch64

This enabled the select optimize patch for ARM Out of order AArch64
cores. It is trying to solve a problem that is difficult for the
compiler to fix. The criteria for when a csel is better or worse than a
branch depends heavily on whether the branch is well predicted and the
amount of ILP in the loop (as well as other criteria like the core in
question and the relative performance of the branch predictor).  The
pass seems to do a decent job though, with the inner loop heuristics
being well implemented and doing a better job than I had expected in
general, even without PGO information.

I've been doing quite a bit of benchmarking. The headline numbers are
these for SPEC2017 on a Neoverse N1:
  500.perlbench_r   -0.12%
  502.gcc_r         0.02%
  505.mcf_r         6.02%
  520.omnetpp_r     0.32%
  523.xalancbmk_r   0.20%
  525.x264_r        0.02%
  531.deepsjeng_r   0.00%
  541.leela_r       -0.09%
  548.exchange2_r   0.00%
  557.xz_r          -0.20%

Running benchmarks with a combination of the llvm-test-suite plus
several versions of SPEC gave between a 0.2% and 0.4% geomean
improvement depending on the core/run. The instruction count went down
by 0.1% too, which is a good sign, but the results can be a little
noisy.  Some issues from other benchmarks I had ran were improved in
rGca78b5601466f8515f5f958ef8e63d787d9d812e. In summary well predicted
branches will see in improvement, badly predicted branches may get
worse, and on average performance seems to be a little better overall.

This patch enables the pass for AArch64 under -O3 for cores that will
benefit for it. i.e. not in-order cores that do not fit into the "Assume
infinite resources that allow to fully exploit the available
instruction-level parallelism" cost model. It uses a subtarget feature
for specifying when the pass will be enabled, which I have enabled under
cpu=generic as the performance increases for out of order cores seems
larger than any decreases for inorder, which were minor.

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

23 months ago[flang] Respect function vs subroutine distinction in generic matching
Peter Klausler [Sun, 6 Nov 2022 19:37:12 +0000 (11:37 -0800)]
[flang] Respect function vs subroutine distinction in generic matching

When checking the specific procedures of a generic interface for a
match against a given set of actual arguments, be sure to not match
a function against a subroutine call or vice versa.  (We generally
catch and warn about attempts to declare mixed interfaces, but they
are usually conforming and can be inadvertently created when generics
are merged due to USE and host association.)

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

23 months ago[clang][Windows]Ignore Options '/d1'
qfrost [Sat, 3 Dec 2022 14:30:13 +0000 (22:30 +0800)]
[clang][Windows]Ignore Options '/d1'

23 months ago[clang-format] Add .inc extension to git-clang-format
Alexandre Ganea [Sat, 3 Dec 2022 14:24:03 +0000 (09:24 -0500)]
[clang-format] Add .inc extension to git-clang-format

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

23 months agoRevert "[LoongArch] Use tablegen size for getInstSizeInBytes"
Nico Weber [Sat, 3 Dec 2022 13:02:41 +0000 (08:02 -0500)]
Revert "[LoongArch] Use tablegen size for getInstSizeInBytes"

This reverts commit d62480c1995b32eea8b9ed5a92829ee5615c4750.
Added test fails, see https://reviews.llvm.org/D138469#3968539

23 months ago[loongarch] fix syntax error in script
Nico Weber [Sat, 3 Dec 2022 12:49:41 +0000 (07:49 -0500)]
[loongarch] fix syntax error in script

At least on macOS with zsh, the test failed with

    line 1: syntax error near unexpected token `&'

previously.

23 months agoImprove type conversion error propagation/failure during LLVM lowering
Uday Bondhugula [Sat, 3 Dec 2022 10:59:07 +0000 (16:29 +0530)]
Improve type conversion error propagation/failure during LLVM lowering

Improve type conversion error propagation/failure during LLVM lowering.

BEFORE

```
llvm-mlir/mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp:304: SmallVector<mlir::Type, 5> mlir::LLVMTypeConverter::getMemRefDescriptorFields(mlir::MemRefType, bool): Assertion `isStrided(type) && "Non-strided layout maps must have been normalized away"' failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
...
```

AFTER
```
<unknown>:0: error: integer overflow during size computation
<unknown>:0: error: Conversion to strided form failed either due to non-strided layout maps (which should have been normalized away) or other reasons
<unknown>:0: error: failed to legalize operation 'gpu.func' that was explicitly marked illegal
<unknown>:0: note: see current operation:
"gpu.func"() ( {
...
```

Reviewed By: ftynse

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