platform/upstream/llvm.git
16 months ago[ModuleUtils] Handle globals_ctors/dtors with non-literal type (PR56809)
Nikita Popov [Tue, 21 Mar 2023 15:16:52 +0000 (16:16 +0100)]
[ModuleUtils] Handle globals_ctors/dtors with non-literal type (PR56809)

If the global already exists, use its existing type, so we don't
try to mix literal and non-literal structs among the elements.

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

16 months agoinline stmt attribute diagnosing in templates
Erich Keane [Fri, 17 Mar 2023 16:54:39 +0000 (09:54 -0700)]
inline stmt attribute diagnosing in templates

D146089's author discovered that our diagnostics for always/no inline
would null-dereference when used in a template. He fixed that by
skipping in the dependent case.

This patch makes sure we diagnose these after a template instantiation.
It also adds infrastructure for other statement attributes to add
checking/transformation.

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

16 months ago[LSR] Use evaluateAtIteration in lsr-term-fold
Philip Reames [Tue, 21 Mar 2023 15:02:32 +0000 (08:02 -0700)]
[LSR] Use evaluateAtIteration in lsr-term-fold

This is a follow up to one of the side discussions on D146429.  There are two semantic changes contained here.

The motivation for the change to the legality condition introduced in D146429 comes from the fact that we only check the post-inc form. As such, as long as the values of the post-inc variable don't self wrap, it's actually okay if we wrap past the starting value of the pre-inc IV.

Second, Nikic noticed during review that the test changes changed behavior for TC=0 (i.e. N=0 in the tests).  On more careful inspection, it became apparent that the previous manual expansion code was incorrect in the case where the primary IV could wrap without poison, and started with the limit value (i.e. i8 post-inc starts at 255 for 0 exit test, implying pre-inc starts with 0).  See @wrap_around test for an example of the (previous) miscompile.

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

16 months ago[LSR] Add a test case for (another) miscompile in lsr-term-fold
Philip Reames [Tue, 21 Mar 2023 14:45:30 +0000 (07:45 -0700)]
[LSR] Add a test case for (another) miscompile in lsr-term-fold

Derived from an observation by @nikic on D146457.

16 months ago[flang] Carry over dynamic type information when creating an unlimited polymorphic...
Valentin Clement [Tue, 21 Mar 2023 15:07:25 +0000 (16:07 +0100)]
[flang] Carry over dynamic type information when creating an unlimited polymorphic temp

The dyanmic type must be carried over in a PolymorphicValue when the address is
loaded from an unlimited polymorphic allocatable.

Reviewed By: PeteSteinfeld

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

16 months ago[mlir] tosa.concat - Add InferTensorType interface
Maya Amrami [Thu, 9 Mar 2023 11:51:27 +0000 (13:51 +0200)]
[mlir] tosa.concat - Add InferTensorType interface

When this interface is used, a call to inferReturnTypeComponents()
is generated on creation and verification of the op.
A few changes were required in inferReturnTypeComponents():
- Emit error when it fails.
  The verifier calls this method now, and it is preferable to
  indicate what caused the failure.
- Fix the inferred return shapes so they have a type too.

Reviewed By: rsuderman

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

16 months ago[mlir] Transform dialect: add named sequences
Alex Zinenko [Mon, 20 Mar 2023 16:18:35 +0000 (16:18 +0000)]
[mlir] Transform dialect: add named sequences

Named sequences introduce an additional abstraction and reuse capability
to the transform dialect. They can be though of as macros parameterized
with handles that can be invoked in places where a transform dialect
operation is expected. Such reuse was previously not possible in the
dialect and required dynamic construction of the transform IR from the
client language. Named sequences are intentionally restricted to
disallow recursion, as it could make the dialect accidentally
Turing-complete, which isn't desired at this point.

Reviewed By: springerm

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

16 months agoNo longer issue pedantic warning about pre-c++2b compat
Aaron Ballman [Tue, 21 Mar 2023 14:49:54 +0000 (10:49 -0400)]
No longer issue pedantic warning about pre-c++2b compat

We were accidentally issuing "overloaded 'operator[]' with more than
one parameter is a C++2b extension" with -pedantic because it was an
ExtWarn diagnostic rather than a Warning. This corrects the diagnostic
category and adds some test coverage.

Fixes #61582

16 months agoFix -fsplit-lto-unit with ifuncs
Daniel Kiss [Tue, 21 Mar 2023 09:46:57 +0000 (10:46 +0100)]
Fix -fsplit-lto-unit with ifuncs

ifuncs can't take part of the whole-program devirtualization so no need them to be copied to the merged module.
The corresponding resolver function also kept out which caused the crash.

Fixes #60962 #57870

Reviewed By: tejohnson

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

16 months ago[LFTR] Assert and simplify under assumption exit counts are integers [nfc]
Philip Reames [Tue, 21 Mar 2023 14:18:27 +0000 (07:18 -0700)]
[LFTR] Assert and simplify under assumption exit counts are integers [nfc]

This invariant was introduced in 8f3d16905d75b07a933d01dc29677fe5867c1b3e.

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

16 months ago[lldb] For native compiles, check signal numbers are correct when adding codes
David Spickett [Fri, 17 Mar 2023 11:04:38 +0000 (11:04 +0000)]
[lldb] For native compiles, check signal numbers are correct when adding codes

Reviewed By: arichardson, emaste

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

16 months agoReland [clang][ASTImport] Add support for import of empty records
Pavel Kosov [Tue, 21 Mar 2023 11:05:19 +0000 (14:05 +0300)]
Reland [clang][ASTImport] Add support for import of empty records

Patch represents the clang part of changes in D143347

Reviewed By: balazske

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

~~

Huawei RRI, OS Lab

16 months ago[mlir] Add missing registrations to runners.
Adrian Kuegel [Tue, 21 Mar 2023 14:15:36 +0000 (15:15 +0100)]
[mlir] Add missing registrations to runners.

16 months ago[mlir][Bazel] Adjust BUILD files to 0e9523efda8a4ad95ecb1d5b5e65e10bcc3711f5
Adrian Kuegel [Tue, 21 Mar 2023 14:00:10 +0000 (15:00 +0100)]
[mlir][Bazel] Adjust BUILD files to 0e9523efda8a4ad95ecb1d5b5e65e10bcc3711f5

16 months ago[PowerPC] Emit warn_deprecated_lax_vec_conv_all warning only for PPC
Maryam Moghadas [Tue, 7 Mar 2023 15:27:02 +0000 (09:27 -0600)]
[PowerPC] Emit warn_deprecated_lax_vec_conv_all warning only for PPC

This patch is to isolate the lax vector conversions warning only for PPC,
the reason is that SystemZ wants different logic in terms of
vector bool compatibility.

Reviewed By: lei

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

16 months ago[mlir] Add alloca address space handling to the data layout subsystem
Jan Sjodin [Mon, 20 Mar 2023 20:54:52 +0000 (16:54 -0400)]
[mlir] Add alloca address space handling to the data layout subsystem

This patch adds alloca address space information to the data layout interface
and implementation in the DLTI dialect. This is needed for targets that use
separate address spaces for local/stack data.

Reviewed By: ftynse, krzysz00

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

16 months ago[X86] Add verify-machineinstrs checks to baseptr tests
Simon Pilgrim [Tue, 21 Mar 2023 13:24:47 +0000 (13:24 +0000)]
[X86] Add verify-machineinstrs checks to baseptr tests

Help catch regressions from D145650 that were only noticed on EXPENSIVE_CHECKS builds

16 months ago[mlir][Transform] NFC - Add more advanced debug spew to help hunt down potential...
Nicolas Vasilache [Tue, 21 Mar 2023 08:33:51 +0000 (01:33 -0700)]
[mlir][Transform] NFC - Add more advanced debug spew to help hunt down potential misuses

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

16 months ago[Sema] Fix crash on __fp16 parameters in template instantiations
Ilya Biryukov [Tue, 21 Mar 2023 13:06:45 +0000 (14:06 +0100)]
[Sema] Fix crash on __fp16 parameters in template instantiations

Fixes #61441.

Currently, Clang stores `nullptr` in the parameter lists inside
`FunctionProtoTypeLoc` if `__fp16` is used without pointer qualifiers.

Any code path that calls `Declarator::setInvalidType()` before
`GetFullTypeForDeclarator` will lead to the same problem downstream.

The relevant code is:
```cpp
if (D.isInvalidType())
  return Context.getTrivialTypeSourceInfo(T);

return GetTypeSourceInfoForDeclarator(state, T, TInfo);
```

`GetTypeSourceInfoForDeclarator` sets the parameter `Decl`, but we can't
call it when `isInvalidType() == true` as this causes other assertion
failures that seem harder to fix.

Reviewed By: kadircet

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

16 months ago[DAG] foldBinOpIntoSelect - use FoldConstantArithmetic instead of getNode() + constan...
Simon Pilgrim [Tue, 21 Mar 2023 12:59:10 +0000 (12:59 +0000)]
[DAG] foldBinOpIntoSelect - use FoldConstantArithmetic instead of getNode() + constant check.

This prevents unused nodes from being created if the constant check fails.

Noticed while triaging D127115 regressions

16 months ago[mlir] Support lowering of dialect attributes attached to top-level modules
Sergio Afonso [Mon, 13 Mar 2023 12:51:18 +0000 (12:51 +0000)]
[mlir] Support lowering of dialect attributes attached to top-level modules

This patch supports the processing of dialect attributes attached to top-level
module-type operations during MLIR-to-LLVMIR lowering.

This approach modifies the `mlir::translateModuleToLLVMIR()` function to call
`ModuleTranslation::convertOperation()` on the top-level operation, after its
body has been lowered. This, in turn, will get the
`LLVMTranslationDialectInterface` object associated to that operation's dialect
before trying to use it for lowering prior to processing dialect attributes
attached to the operation.

Since there are no `LLVMTranslationDialectInterface`s for the builtin and GPU
dialects, which define their own module-type operations, this patch also adds
and registers them. The requirement for always calling
`mlir::registerBuiltinDialectTranslation()` before any translation of MLIR to
LLVM IR where builtin module operations are present is introduced. The purpose
of these new translation interfaces is to succeed when processing module-type
operations, allowing the lowering process to continue and to prevent the
introduction of failures related to not finding such interfaces.

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

16 months ago[gn build] Port da8260a9b111
LLVM GN Syncbot [Tue, 21 Mar 2023 12:38:15 +0000 (12:38 +0000)]
[gn build] Port da8260a9b111

16 months ago[clang][NFC] Fix typo in comment
Ilyas Mustafazade [Tue, 21 Mar 2023 12:29:05 +0000 (13:29 +0100)]
[clang][NFC] Fix typo in comment

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

16 months agoRevert "[X86] Create extra prolog/epilog for stack realignment"
Luo, Yuanke [Tue, 21 Mar 2023 12:14:22 +0000 (20:14 +0800)]
Revert "[X86] Create extra prolog/epilog for stack realignment"

This reverts commit e4c1dfed38370b4933f05c8e24b1d77df56b526c.

16 months ago[MLIR] Fix warnings in AttrTypeSubElements.h
Uday Bondhugula [Tue, 21 Mar 2023 12:18:45 +0000 (17:48 +0530)]
[MLIR] Fix warnings in AttrTypeSubElements.h

Fix warnings in AttrTypeSubElements.h (below) with GCC 9.4.0.

```
mlir/lib/IR/ExtensibleDialect.cpp:443:62:   required from here
mlir/include/mlir/IR/AttrTypeSubElements.h:412:37: warning: parameter ‘derived’ set but not used [-Wunused-but-set-parameter]
  412 | void walkImmediateSubElementsImpl(T derived,
      |                                   ~~^~~
```

Reviewed By: mehdi_amini

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

16 months ago[AArch64] Add tests for bitcast to and mask reduction (NFC)
Nikita Popov [Tue, 21 Mar 2023 10:59:56 +0000 (11:59 +0100)]
[AArch64] Add tests for bitcast to and mask reduction (NFC)

This is a copy of the vecreduce_or tests but with comparison
to -1 rather than 0.

16 months agoRevert "[X86] Create extra prolog/epilog for stack realignment [part 2]"
Luo, Yuanke [Tue, 21 Mar 2023 12:12:35 +0000 (20:12 +0800)]
Revert "[X86] Create extra prolog/epilog for stack realignment [part 2]"

This reverts commit 614c63bec6d67cbfdc17b50e443ff769a28c18d0.

16 months ago[lldb] Add compile time checks for signal codes when on the matching platform
David Spickett [Thu, 16 Mar 2023 11:32:35 +0000 (11:32 +0000)]
[lldb] Add compile time checks for signal codes when on the matching platform

This adds a new macro to the UnixSignals subclasses, ADD_SIGCODE.

ADD_SIGCODE(4, ILL_ILLOPC, 1, "illegal opcode");

Adds a sigcode to signal 4. That code is ILL_ILLOPC and we expect
its value to be 1. When compiling on a system that matches the class
e.g. FreeBSD for FreeBSDSignals, the macro will check that that is true.

When you're not on FreeBSD we just use the number 1, and ILL_ILLOPC
won't be defined to anything because we don't include csignal.

Example error:
LinuxSignals.cpp:52:3: error: static_assert failed due to requirement
'ILL_COPROC == 9' "Value mismatch for signal code ILL_COPROC"

Reviewed By: arichardson

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

16 months ago[LV] Set imbounds flag using CreateGEP in VPWidenMemInst (NFC).
Florian Hahn [Tue, 21 Mar 2023 11:43:23 +0000 (11:43 +0000)]
[LV] Set imbounds flag using CreateGEP in VPWidenMemInst (NFC).

This avoids having to cast the result of the builder to
GetElementPtrInst.

16 months ago[mlir] Add a pattern to fold single- and zero-iteration scf.forall ops.
Alexander Belyaev [Tue, 21 Mar 2023 10:56:08 +0000 (11:56 +0100)]
[mlir] Add a pattern to fold single- and zero-iteration scf.forall ops.

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

16 months ago[lldb] Relax expectation on TestMainThreadExit
Pavel Labath [Tue, 21 Mar 2023 10:19:13 +0000 (11:19 +0100)]
[lldb] Relax expectation on TestMainThreadExit

The exit code of the (funky) test inferior depends on the linux kernel
version (changed some time between 5.15 and 6.1).

16 months agoMark widenable condition as noundef
Max Kazantsev [Tue, 21 Mar 2023 10:11:10 +0000 (17:11 +0700)]
Mark widenable condition as noundef

This corresponds to its description in LangRef:
The intrinsic @llvm.experimental.widenable.condition() returns either true or false.

Differential Revision: https://reviews.llvm.org/D146508
Reviewed By: skatkov, nikic

16 months ago[AMDGPU] Make use of GCNSubtarget::hasNSAEncoding. NFC.
Jay Foad [Tue, 21 Mar 2023 09:49:43 +0000 (09:49 +0000)]
[AMDGPU] Make use of GCNSubtarget::hasNSAEncoding. NFC.

16 months ago[BOLT] Reject symbols pointing to section end
Job Noorman [Tue, 21 Mar 2023 09:58:36 +0000 (13:58 +0400)]
[BOLT] Reject symbols pointing to section end

Sometimes, symbols are present that point to the end of a section (i.e.,
one-past the highest valid address). Currently, BOLT either rejects
those symbols when they don't point to another existing section, or errs
when they do and the other section is not executable. I suppose BOLT
would accept the symbol when it points to an executable section.

In any case, these symbols should not be considered while discovering
functions and should not result in an error. This patch implements that.

Note that this patch checks explicitly for symbols whose value equals
the end of their section. It might make more sense to verify that the
symbol's value is within [section start, section end). However, I'm not
sure if this could every happen *and* its value does not equal the end.

Another way to implement this is to verify that the BinarySection we
find at the symbol's address actually corresponds to the symbol's
section. I'm not sure what the best approach is so feedback is welcome.

Reviewed By: yota9, rafauler

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

16 months ago[InstCombine] Fold icmp eq of non-inbounds geps
Nikita Popov [Tue, 21 Mar 2023 09:46:13 +0000 (10:46 +0100)]
[InstCombine] Fold icmp eq of non-inbounds geps

We can fold equality comparisons of non-inbounds geps to offset
comparison (https://alive2.llvm.org/ce/z/x2Zp8b). The inbounds
requirement is only necessary for relational comparisons.

16 months ago[Assignment Tracking] Downgrade dbg.assigns to dbg.values in mem2reg
OCHyams [Tue, 21 Mar 2023 09:14:42 +0000 (09:14 +0000)]
[Assignment Tracking] Downgrade dbg.assigns to dbg.values in mem2reg

For fully promoted variables dbg.assigns and dbg.values convey the same
information and can be used interchangeably. This patch converts dbg.assigns to
dbg.values for variables promoted by mem2reg. This reduces resource usage by
reducing the amount of unnecessary function local metadata. The compile time
tracker reports that CTMark projects build with LTO-O3-g with 0.4% fewer
instructions retired and peak memory usage is reduced by 2.2%.

Reviewed By: jryans

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

16 months ago[lldb] Fix TestStepOverWatchpoint
Pavel Labath [Tue, 21 Mar 2023 09:44:40 +0000 (10:44 +0100)]
[lldb] Fix TestStepOverWatchpoint

16 months ago[InstCombine] Add icmp gep tests without inbounds (NFC)
Nikita Popov [Tue, 21 Mar 2023 09:41:15 +0000 (10:41 +0100)]
[InstCombine] Add icmp gep tests without inbounds (NFC)

16 months ago[InstCombine] Fold icmp eq of non-inbounds gep with base pointer
Nikita Popov [Tue, 21 Mar 2023 09:16:51 +0000 (10:16 +0100)]
[InstCombine] Fold icmp eq of non-inbounds gep with base pointer

For equality comparisons, we don't need the gep to be inbounds:
https://alive2.llvm.org/ce/z/Fe_kn2

16 months ago[mlir][Linalg][Transform] Fix effect on RewriteInDestinationPassingStyleOp that did...
Nicolas Vasilache [Tue, 21 Mar 2023 08:04:04 +0000 (01:04 -0700)]
[mlir][Linalg][Transform] Fix effect on RewriteInDestinationPassingStyleOp that did not consume its operand

16 months ago[Assignment Tracking][NFC] Use BitVectors as masks for SmallVectors
OCHyams [Tue, 21 Mar 2023 08:28:08 +0000 (08:28 +0000)]
[Assignment Tracking][NFC] Use BitVectors as masks for SmallVectors

...rather than using DenseMaps to track per-variable information.

Rather than tracking 3 maps of {VariableID: SomeInfo} per block, use a
BitVector indexed by VariableID to mask 3 vectors of SomeInfo.

BlockInfos now need to be initialised with a call to init which sets the
BitVector width to the number of partially promoted variables in the function
and fills the vectors with Top values.

Prior to this patch, in joinBlockInfo, it was necessary to insert Top values
into the Join result for variables in A XOR B after joining the variables in A
AND B. Now, because the vectors are pre-filled with Top values we need only
join the variables A AND B and set the BitVector of tracked variables to A OR
B.

The patch achieves an average of 0.25% reduction in instructions retired and a
1.1% max-rss for the CTMark suite in LTO-O3-g builds.

Reviewed By: scott.linder

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

16 months ago[NFC] Add iterator traits to BitVector set_bits_iterator
OCHyams [Tue, 21 Mar 2023 08:17:24 +0000 (08:17 +0000)]
[NFC] Add iterator traits to BitVector set_bits_iterator

Reviewed By: scott.linder

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

16 months ago[LLDB] Show sub type of signals when debugging a core file
David Spickett [Tue, 14 Mar 2023 11:52:48 +0000 (11:52 +0000)]
[LLDB] Show sub type of signals when debugging a core file

Previously we only looked at the si_signo field, so you got:
```
(lldb) bt
* thread #1, name = 'a.out.mte', stop reason = signal SIGSEGV
  * frame #0: 0x00000000004007f4
```
This patch adds si_code so we can show:
```
(lldb) bt
* thread #1, name = 'a.out.mte', stop reason = signal SIGSEGV: sync tag check fault
  * frame #0: 0x00000000004007f4
```

The order of errno and code was incorrect in ElfLinuxSigInfo::Parse.
It was the order that a "swapped" siginfo arch would use, which for Linux,
is only MIPS. We removed MIPS Linux support some time ago.

See:
https://github.com/torvalds/linux/blob/fe15c26ee26efa11741a7b632e9f23b01aca4cc6/include/uapi/asm-generic/siginfo.h#L121

A test is added using memory tagging faults. Which were the original
motivation for the changes.

Reviewed By: JDevlieghere

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

16 months ago[InstCombine] Simplify foldOperationIntoSelectOperand() (NFCI)
Nikita Popov [Tue, 21 Mar 2023 08:59:52 +0000 (09:59 +0100)]
[InstCombine] Simplify foldOperationIntoSelectOperand() (NFCI)

Rather than handling all instruction types separately, clone the
original instruction and replace the select operand.

16 months ago[Test] Add test on freezing of widenable condition
Max Kazantsev [Tue, 21 Mar 2023 08:59:00 +0000 (15:59 +0700)]
[Test] Add test on freezing of widenable condition

16 months ago[flang] Handle polymorphic entities with rank > 0 in entry statement
Valentin Clement [Tue, 21 Mar 2023 08:50:31 +0000 (09:50 +0100)]
[flang] Handle polymorphic entities with rank > 0 in entry statement

Correctly create the temporary for argument absent in the entry statement.

Reviewed By: PeteSteinfeld

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

16 months ago[MergeFuncs] Compare load instruction metadata
Ding Xiang Fei [Tue, 21 Mar 2023 08:45:51 +0000 (09:45 +0100)]
[MergeFuncs] Compare load instruction metadata

MergeFuncs currently merges load instructions with differing
semantically-relevant metadata, e.g. a load that has !nonnull
with one that does not.

Update FunctionComparator to make sure that metadata of both
loads is the same. Alternatively, it would be possilbe to ignore
the metadata during comparison, and then drop it during merging.

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

16 months ago[NFC] Change strcpy to std::copy
Ilyas Mustafazade [Tue, 21 Mar 2023 08:43:51 +0000 (09:43 +0100)]
[NFC] Change strcpy to std::copy

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

16 months ago[X86][MemFold] Stop emitting Header for X86 fold tables
Bing1 Yu [Tue, 21 Mar 2023 08:38:05 +0000 (16:38 +0800)]
[X86][MemFold] Stop emitting Header for X86 fold tables

Reviewed By: skan

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

16 months ago[WebAssembly] Add auto-upgrade for renamed intrinsics
Nikita Popov [Mon, 20 Mar 2023 14:48:48 +0000 (15:48 +0100)]
[WebAssembly] Add auto-upgrade for renamed intrinsics

D138249 renamed a number of wasm intrinsics without implementing
auto-upgrade support.

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

16 months ago[Bazel] Fixup for D144351, Add `alwayslink` to `//llvm:tblgen`
NAKAMURA Takumi [Tue, 21 Mar 2023 07:52:14 +0000 (16:52 +0900)]
[Bazel] Fixup for D144351, Add `alwayslink` to `//llvm:tblgen`

16 months ago[InstCombine] Combine binary operator of two phi node
luxufan [Fri, 3 Mar 2023 08:34:17 +0000 (16:34 +0800)]
[InstCombine] Combine binary operator of two phi node

Combine binary operator of two phi node if there is at least one
specific constant value in phi0 and phi1's incoming values for each
same incoming block and this specific constant value can be used
to do optimization for specific binary operator.
For example:
```
%phi0 = phi i32 [0, %bb0], [%i, %bb1]
%phi1 = phi i32 [%j, %bb0], [0, %bb1]
%add = add i32 %phi0, %phi1
==>
%add = phi i32 [%j, %bb0], [%i, %bb1]
```

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

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

16 months agollvm-tblgen: Rewrite emitters to use `TableGen::Emitter`
NAKAMURA Takumi [Sun, 19 Feb 2023 05:30:14 +0000 (14:30 +0900)]
llvm-tblgen: Rewrite emitters to use `TableGen::Emitter`

Each emitter became self-contained since it has the registration of option.

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

16 months agollvm-tblgen: Cleanup for each EmitterClass to be invoked by uniform signature.
NAKAMURA Takumi [Sat, 18 Feb 2023 16:22:38 +0000 (01:22 +0900)]
llvm-tblgen: Cleanup for each EmitterClass to be invoked by uniform signature.

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

16 months agollvm-tblgen: Move decl of `EmitDecoder()`to TableGenBackends.h
NAKAMURA Takumi [Mon, 20 Feb 2023 14:02:00 +0000 (23:02 +0900)]
llvm-tblgen: Move decl of `EmitDecoder()`to TableGenBackends.h

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

16 months agoTableGen: Introduce `llvm::TableGen::Emitter` to register backends
NAKAMURA Takumi [Thu, 16 Feb 2023 23:24:07 +0000 (08:24 +0900)]
TableGen: Introduce `llvm::TableGen::Emitter` to register backends

`Opt(flag, func, desc)` registers an option into `Action`.

`OptClass<EmitterC>` is also available if `EmitterC(RK).run(OS)` is capable.

`Action` is defined as `ManagedStatic<cl::opt>` to guarantee to be created
when each registration of emitter is invoked.

`llvm::TableGenMain(argv0, MainFn)` invokes `Action` instead of `MainFn`

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

16 months agoTableGen: Make 2nd arg `MainFn` of `TableGenMain(argv0, MainFn)` optional.
NAKAMURA Takumi [Tue, 21 Mar 2023 03:58:57 +0000 (12:58 +0900)]
TableGen: Make 2nd arg `MainFn` of `TableGenMain(argv0, MainFn)` optional.

16 months agoReformat
NAKAMURA Takumi [Tue, 21 Mar 2023 04:09:34 +0000 (13:09 +0900)]
Reformat

16 months ago[clangd][NFC] Format & include cleanup for AddUsingTests.cpp
Kadir Cetinkaya [Tue, 21 Mar 2023 06:51:03 +0000 (07:51 +0100)]
[clangd][NFC] Format & include cleanup for AddUsingTests.cpp

16 months ago[InstCombine][NFC] Precommit test case of PR61137
luxufan [Fri, 3 Mar 2023 07:21:28 +0000 (15:21 +0800)]
[InstCombine][NFC] Precommit test case of PR61137

16 months agoRevert "Revert "[clangd] Fix AddUsing in the face of typo-correction""
Kadir Cetinkaya [Mon, 20 Mar 2023 18:06:09 +0000 (19:06 +0100)]
Revert "Revert "[clangd] Fix AddUsing in the face of typo-correction""

This reverts commit fb3f6a95393f33bc8d8550a5ac62c18e488a9b6f.

16 months ago[X86] Create extra prolog/epilog for stack realignment [part 2]
Luo, Yuanke [Tue, 21 Mar 2023 01:06:44 +0000 (09:06 +0800)]
[X86] Create extra prolog/epilog for stack realignment [part 2]

This patch is to support D145650 for elf target as well.

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

16 months ago[Attributor] Add convergent abstract attribute
Ishaan Gandhi [Tue, 21 Mar 2023 05:31:39 +0000 (22:31 -0700)]
[Attributor] Add convergent abstract attribute

This patch adds the AANonConvergent abstract attribute. It removes the
convergent attribute from functions that only call non-convergent
functions.

Reviewed By: jdoerfert

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

16 months ago[RISCV] Simplify RISCVISAInfo::compareExtension. NFCI
Craig Topper [Tue, 21 Mar 2023 04:58:42 +0000 (21:58 -0700)]
[RISCV] Simplify RISCVISAInfo::compareExtension. NFCI

Instead of having a separate single letter and multiletter ranking
use a unified rank that assigns multiletter a larger value than
single letter.

Once we've ranked the extensions, then we compare using these ranks.

Reviewed By: kito-cheng

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

16 months ago[Webassembly][NFC] Fix typo in comment
Congcong Cai [Tue, 21 Mar 2023 05:19:35 +0000 (13:19 +0800)]
[Webassembly][NFC] Fix typo in comment

16 months ago[MLIR][Affine] Fix addInductionVarOrTerminalSymbol
Uday Bondhugula [Tue, 21 Mar 2023 04:52:19 +0000 (10:22 +0530)]
[MLIR][Affine] Fix addInductionVarOrTerminalSymbol

Update affine analysis method `addInductionVarOrTerminalSymbol` for
affine.parallel IV.

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

Reviewed By: dcaballe

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

16 months ago[Webassembly][multivalue] update libcall signature when multivalue feature enabled
Congcong Cai [Tue, 21 Mar 2023 04:04:41 +0000 (12:04 +0800)]
[Webassembly][multivalue] update libcall signature when multivalue feature enabled

fixed: #59095
Update libcall signatures to use multivalue return rather than returning via a pointer
when the multivalue features is enabled in the WebAssembly backend.

Reviewed By: tlively

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

16 months ago[AVR] Fix incorrect expansion of the pseudo 'ELPMBRdZ' instruction
Ben Shi [Sun, 8 Jan 2023 12:35:23 +0000 (20:35 +0800)]
[AVR] Fix incorrect expansion of the pseudo 'ELPMBRdZ' instruction

The 'ELPM' instruction has three forms:

--------------------------
| form        | feature  |
| ----------- | -------- |
| ELPM        | hasELPM  |
| ELPM Rd, Z  | hasELPMX |
| ELPM Rd, Z+ | hasELPMX |
--------------------------

The second form is always used in the expansion of the pseudo
instruction 'ELPMBRdZ'. But for devices without ELPMX but only
with ELPM, only the first form can be emitted.

Reviewed By: jacquesguan

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

16 months ago[llvm-jitlink] Fix typo in description of llvm-jitlink's -alias option.
Lang Hames [Tue, 21 Mar 2023 01:55:00 +0000 (18:55 -0700)]
[llvm-jitlink] Fix typo in description of llvm-jitlink's -alias option.

16 months ago[llvm-readobj] Fix ambiguous call of printNumber in ELFDumper.cpp (NFC)
Jie Fu [Tue, 21 Mar 2023 02:33:48 +0000 (10:33 +0800)]
[llvm-readobj] Fix ambiguous call of printNumber in ELFDumper.cpp (NFC)

/Users/jiefu/llvm-project/llvm/tools/llvm-readobj/ELFDumper.cpp:7175:5: error: call to member function 'printNumber' is ambiguous
  W.printNumber("TotalBuckets", NBucket);
  ~~^~~~~~~~~~~
/Users/jiefu/llvm-project/llvm/include/llvm/Support/ScopedPrinter.h:201:16: note: candidate function
  virtual void printNumber(StringRef Label, uint64_t Value) {
               ^
/Users/jiefu/llvm-project/llvm/include/llvm/Support/ScopedPrinter.h:205:16: note: candidate function
  virtual void printNumber(StringRef Label, uint32_t Value) {
               ^
/Users/jiefu/llvm-project/llvm/include/llvm/Support/ScopedPrinter.h:209:16: note: candidate function
  virtual void printNumber(StringRef Label, uint16_t Value) {
               ^
/Users/jiefu/llvm-project/llvm/include/llvm/Support/ScopedPrinter.h:213:16: note: candidate function
  virtual void printNumber(StringRef Label, uint8_t Value) {
               ^
/Users/jiefu/llvm-project/llvm/include/llvm/Support/ScopedPrinter.h:217:16: note: candidate function
  virtual void printNumber(StringRef Label, int64_t Value) {
               ^
/Users/jiefu/llvm-project/llvm/include/llvm/Support/ScopedPrinter.h:221:16: note: candidate function
  virtual void printNumber(StringRef Label, int32_t Value) {
               ^
/Users/jiefu/llvm-project/llvm/include/llvm/Support/ScopedPrinter.h:225:16: note: candidate function
  virtual void printNumber(StringRef Label, int16_t Value) {
               ^
/Users/jiefu/llvm-project/llvm/include/llvm/Support/ScopedPrinter.h:229:16: note: candidate function
  virtual void printNumber(StringRef Label, int8_t Value) {
               ^
/Users/jiefu/llvm-project/llvm/include/llvm/Support/ScopedPrinter.h:237:16: note: candidate function
  virtual void printNumber(StringRef Label, float Value) {
               ^
/Users/jiefu/llvm-project/llvm/include/llvm/Support/ScopedPrinter.h:241:16: note: candidate function
  virtual void printNumber(StringRef Label, double Value) {
               ^

16 months ago[docs] Update the status for coroutines
Chuanqi Xu [Thu, 16 Mar 2023 03:02:06 +0000 (11:02 +0800)]
[docs] Update the status for coroutines

According to the discussion in
https://discourse.llvm.org/t/rfc-could-we-mark-coroutines-as-unreleased-now/69220

We should mark coroutines as "it’s supported fully everywhere but on
Windows targets".

Reviewed By: aaron.ballman

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

16 months agoFix Windows export list.
Peter Collingbourne [Tue, 21 Mar 2023 02:20:33 +0000 (19:20 -0700)]
Fix Windows export list.

Should fix Windows buildbot:
https://lab.llvm.org/buildbot/#/builders/127/builds/45411

16 months ago[AIX] Consolidate Crt0Basename logic
Michael Francis [Mon, 20 Mar 2023 18:00:32 +0000 (18:00 +0000)]
[AIX] Consolidate Crt0Basename logic

when certain flags are specified, the Crt0 object files are not linked.
However, the logic for determining which files will always run. This
patch moves that logic so that the basename is only determined if it is
needed.

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

16 months ago[Attributor][FIX] Avoid H2S on GPUs if the pointer can be shared
Johannes Doerfert [Tue, 21 Mar 2023 00:13:18 +0000 (17:13 -0700)]
[Attributor][FIX] Avoid H2S on GPUs if the pointer can be shared

If the stack is not accessible by other threads, e.g., on a GPU, we need
to ensure heap-2-stack will not create a stack version of a pointer that
might be passed to another thread. Since passing through memory is by
default transparent, we need to register a callback and inspect stores
we might look through explicitly.

16 months ago[OpenMPOpt][FIX] Avoid removing barriers in callees
Johannes Doerfert [Mon, 20 Mar 2023 23:01:39 +0000 (16:01 -0700)]
[OpenMPOpt][FIX] Avoid removing barriers in callees

We could be smarter about this, e.g., if the callee has a single call
site, but for now we first avoid the miscompile.

16 months ago[OpenMP][FIX] Properly track and lookup Execution Domains
Johannes Doerfert [Tue, 7 Mar 2023 21:26:31 +0000 (13:26 -0800)]
[OpenMP][FIX] Properly track and lookup Execution Domains

This is a two part fix. First, we need two Execution Domains (ED) to
track the values of a function. One for incoming values and one for
outgoing values. This was conflated before. Second, at the function
entry we need to look at the incoming information from call sites not
iterate over non-existing predecessors.

16 months ago[Attributor][FIX] Ensure loop PHI replacements are dynamically unique
Johannes Doerfert [Mon, 20 Mar 2023 18:21:56 +0000 (11:21 -0700)]
[Attributor][FIX] Ensure loop PHI replacements are dynamically unique

Similar to loads, PHIs can be used to introduce non-dynamically unique
values into the simplification "algorithm". We need to check that PHIs
do not carry such a value from one iteration into the next as can cause
downstream reasoning to fail, e.g., downstream could think a comparison
is equal because the simplified values are equal while they are defined
in different loop iterations. Similarly, instructions in cycles are now
conservatively treated as non-dynamically unique. We could do better but
I'll leave that for the future.

The change in AAUnderlyingObjects allows us to ignore dynamically unique
when we simply look for underlying objects. The user of that AA should
be aware that the result might not be a dynamically unique value.

16 months ago[Attributor][NFC] Precommit test exposing a bug
Johannes Doerfert [Mon, 20 Mar 2023 19:42:56 +0000 (12:42 -0700)]
[Attributor][NFC] Precommit test exposing a bug

16 months ago[Attributor][NFC] Reduce output verbosity
Johannes Doerfert [Tue, 7 Mar 2023 21:31:44 +0000 (13:31 -0800)]
[Attributor][NFC] Reduce output verbosity

16 months ago[libc] temporarily disable wctob entrypoint
Michael Jones [Tue, 21 Mar 2023 00:41:07 +0000 (17:41 -0700)]
[libc] temporarily disable wctob entrypoint

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

16 months ago[libc][obvious] fix missing stdio dependency
Michael Jones [Tue, 21 Mar 2023 00:35:14 +0000 (17:35 -0700)]
[libc][obvious] fix missing stdio dependency

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

16 months ago[llvm-readobj] Provide Hash Histogram for all ELFDumper implementations
Paul Kirth [Sat, 18 Mar 2023 03:33:26 +0000 (03:33 +0000)]
[llvm-readobj] Provide Hash Histogram for all ELFDumper implementations

Previously, the GNUELFDumper was the only implementer for Hash Histograms.
This patch moves the implementation for printHashHistogram and
printGnuHashHistogram into the ELFDumper base class, and allows each
derived class to specialize how it outputs that information.

This change also prevents the JSONELFDumper from emitting invalid JSON,
since the shared implementation in LLVMELFDumper no longer emits a
warning message to the output stream.

Reviewed By: jhenderson

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

16 months ago[support] Support printing floats in ScopedPrinter
Paul Kirth [Sat, 18 Mar 2023 02:39:12 +0000 (02:39 +0000)]
[support] Support printing floats in ScopedPrinter

llvm-readobj will need the ability to print floats for use in
HashHistograms. This adds that functionality to the ScopedPrinter and
JSONScopedPrinter.

Reviewed By: jhenderson

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

16 months ago[libc][obvious] remove currently unused types
Michael Jones [Tue, 21 Mar 2023 00:20:01 +0000 (17:20 -0700)]
[libc][obvious] remove currently unused types

Somehow having MBState and StructTmType in the definition for wchar was
causing test failures. This should fix those.

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

16 months ago[gn build] Port e4c1dfed3837
LLVM GN Syncbot [Tue, 21 Mar 2023 00:14:05 +0000 (00:14 +0000)]
[gn build] Port e4c1dfed3837

16 months ago[X86] Create extra prolog/epilog for stack realignment
Luo, Yuanke [Thu, 9 Mar 2023 05:32:31 +0000 (13:32 +0800)]
[X86] Create extra prolog/epilog for stack realignment

The base pointer register is reserved by compiler when there is
dynamic size alloca and stack realign in a function. However the
base pointer register is not defined in X86 ABI, so user can use
this register in inline assembly. The inline assembly would
clobber base pointer register without being awared by user. This
patch is to create extra prolog to save the stack pointer to a
scratch register and use this register to reference argument from
stack. For some calling convention (e.g. regcall), there may be
few scratch register.
Below is the example code for such case.

```
extern int bar(void *p);
long long foo(size_t size, char c, int id) {
  __attribute__((__aligned__(64))) int a;
  char *p = (char *)alloca(size);
  asm volatile ("nop"::"S"(405):);
  asm volatile ("movl %0, %1"::"r"(id), "m"(a):);
  p[2] = 8;
  memset(p, c, size);
  return bar(p);
}
```
And below prolog/epilog will be emit for this case.
```
leal    4(%esp), %ebx
.cfi_def_cfa %ebx, 0
andl    $-128, %esp
pushl   -4(%ebx)
...
leal    4(%ebx), %esp
.cfi_def_cfa %esp, 4
```

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

16 months ago[-Wunsafe-buffer-usage] Add Fixable for dereference of simple ptr arithmetic
ziqingluo-90 [Mon, 20 Mar 2023 23:57:50 +0000 (16:57 -0700)]
[-Wunsafe-buffer-usage] Add Fixable for dereference of simple ptr arithmetic

For each expression `e` of the form `*(DRE + n)` (or `*(n + DRE)`), where
`DRE` has a pointer type and `n` is an integer literal, `e` will be
transformed to `DRE[n]` (or `n[DRE]` respectively), if
- `e` is at the left-hand side of an assignment or is an lvalue being casted to an rvalue; and
- the variable referred by `DRE` is going to be transformed to be of `std::span` type.

Reviewed by: jkorous, NoQ

Differential revision: https://reviews.llvm.org/D142795

16 months ago[gn build] Port ee232506b870
LLVM GN Syncbot [Mon, 20 Mar 2023 23:57:12 +0000 (23:57 +0000)]
[gn build] Port ee232506b870

16 months ago[mlir][sparse] Fixing -Wunused-variable in Sparsification.cpp
wren romano [Mon, 20 Mar 2023 23:41:39 +0000 (16:41 -0700)]
[mlir][sparse] Fixing -Wunused-variable in Sparsification.cpp

Reviewed By: aartbik, Peiming

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

16 months agoFollow on to 2c7abc83f605b2d3b1062f28422eeff81278ecd5.
Jim Ingham [Mon, 20 Mar 2023 23:47:07 +0000 (16:47 -0700)]
Follow on to 2c7abc83f605b2d3b1062f28422eeff81278ecd5.

I didn't refactor the test that's failing on arm64 correctly so it
failed everywhere.

Looks like the step test passes on other aarch64 systems as well as
Darwin.  Turn off the xfail and see how far that gets.

16 months ago[libc][obvious] fix missing type headers
Michael Jones [Mon, 20 Mar 2023 23:41:08 +0000 (16:41 -0700)]
[libc][obvious] fix missing type headers

forgot to add wint_t and wchar_t type headers to the wchar
headergen definition.

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

16 months agoDisable __sancov_lowest_stack on Windows.
Peter Collingbourne [Mon, 20 Mar 2023 23:38:54 +0000 (16:38 -0700)]
Disable __sancov_lowest_stack on Windows.

Should fix Windows buildbot:
https://lab.llvm.org/buildbot/#/builders/127/builds/45401

16 months agoRevert "[IRSim] Check largest sections first when analyzing similarity"
Andrew Litteken [Mon, 20 Mar 2023 23:38:39 +0000 (18:38 -0500)]
Revert "[IRSim] Check largest sections first when analyzing similarity"

This reverts commit 805ec19d7d9915989be8a8a626176b5e29e19eee.

Did not update llvm-sim tests

16 months ago[libc] add basic wide char functions
Michael Jones [Mon, 13 Mar 2023 22:30:36 +0000 (15:30 -0700)]
[libc] add basic wide char functions

This patch adds the wchar header, as well as the functions to convert to
and from wide chars. The header also sets up the definitions for wint
and wchar.

Reviewed By: lntue

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

16 months agoExpose `__tsan_on_thread_idle` as part of tsan shared interface
Dave MacLachlan [Mon, 20 Mar 2023 23:30:18 +0000 (16:30 -0700)]
Expose `__tsan_on_thread_idle` as part of tsan shared interface

`__tsan_on_thread_idle` is part of the tsan interface that was not being
exported in shared libraries. Fixes it so that we can link to dynamic
versions of tsan and still call `__tsan_on_thread_idle`.

Reviewed By: vitalybuka

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

16 months ago[IRSim] Check largest sections first when analyzing similarity
Andrew Litteken [Sun, 2 Oct 2022 17:34:14 +0000 (12:34 -0500)]
[IRSim] Check largest sections first when analyzing similarity

When we check for similarity, right now there is no order to how it is checked, except for via the suffix tree ordering.

We can reduce how much structural analysis we perform by checking the the regions in decreasing size. In doing so, we know that if two large sections match, each of their contained regions also match. This allows us to skip the structural checking for each smaller section. IT does require that we use the large regions as a "bridge" to create the canonical mapping between the two regions.

This reduces compile time significantly for some benchmarks. It will not perform as well for programs with many small items.

Reviewer: paquette
Differential Revision: https://reviews.llvm.org/D139338

16 months agosanitizer_common: Use plain thread_local for __sancov_lowest_stack definition.
Peter Collingbourne [Sat, 18 Mar 2023 03:48:21 +0000 (20:48 -0700)]
sanitizer_common: Use plain thread_local for __sancov_lowest_stack definition.

We can't use initial-exec for the definition of __sancov_lowest_stack
because it gets linked into shared libraries such as the UBSan and
HWASan runtimes on Android. I think we can expect plain thread_local
to work unconditionally in sanitizer_common as several other sanitizers
are already using it, so drop the platform-dependent macro and just use
thread_local in the definition.

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

16 months ago[NFC][tsan] Clang-format includes
Vitaly Buka [Mon, 20 Mar 2023 23:20:03 +0000 (16:20 -0700)]
[NFC][tsan] Clang-format includes

16 months ago[mlir][sparse] Making `TensorExp::Kind` a nested enum-class
wren romano [Mon, 20 Mar 2023 23:11:17 +0000 (16:11 -0700)]
[mlir][sparse] Making `TensorExp::Kind` a nested enum-class

This improves namespacing, and follows the pattern used for "Kind" enums elsewhere in MLIR.

Reviewed By: aartbik

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

16 months agoReapply 8d024a79ea783ed3fbb5691aeaf186ad3f0a4ae9 w/o the extra bits.
Jim Ingham [Mon, 20 Mar 2023 23:11:00 +0000 (16:11 -0700)]
Reapply 8d024a79ea783ed3fbb5691aeaf186ad3f0a4ae9 w/o the extra bits.