platform/upstream/llvm.git
15 months agoRevert "[MemProf] Context disambiguation cloning pass [patch 1a/3]"
Nikita Popov [Wed, 22 Mar 2023 14:43:46 +0000 (15:43 +0100)]
Revert "[MemProf] Context disambiguation cloning pass [patch 1a/3]"

This reverts commit d6ad4f01c3dafcab335bca66dac6e36d9eac8421.

Fails to build on at least gcc 12.2:

/home/npopov/repos/llvm-project/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp:482:1: error: no declaration matches ‘ContextNode<DerivedCCG, FuncTy, CallTy>* CallsiteContextGraph<DerivedCCG, FuncTy, CallTy>::getNodeForInst(const CallInfo&)’
  482 | CallsiteContextGraph<DerivedCCG, FuncTy, CallTy>::getNodeForInst(
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/npopov/repos/llvm-project/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp:393:16: note: candidate is: ‘CallsiteContextGraph<DerivedCCG, FuncTy, CallTy>::ContextNode* CallsiteContextGraph<DerivedCCG, FuncTy, CallTy>::getNodeForInst(const CallInfo&)’
  393 |   ContextNode *getNodeForInst(const CallInfo &C);
      |                ^~~~~~~~~~~~~~
/home/npopov/repos/llvm-project/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp:99:7: note: ‘class CallsiteContextGraph<DerivedCCG, FuncTy, CallTy>’ defined here
   99 | class CallsiteContextGraph {
      |       ^~~~~~~~~~~~~~~~~~~~

15 months ago[MLIR][LLVM] Copy byval attributes during inlining.
Johannes de Fine Licht [Wed, 22 Mar 2023 14:22:11 +0000 (15:22 +0100)]
[MLIR][LLVM] Copy byval attributes during inlining.

Support inlining of function calls with the byval attribute on function
arguments by copying the pointee into a newly alloca'ed pointer at the
callsite before inlining.

The alignment attribute is not yet taken into account.

Reviewed By: ftynse, gysit

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

15 months ago[gn build] Port e4ceb5a7bb9b
LLVM GN Syncbot [Wed, 22 Mar 2023 14:28:29 +0000 (14:28 +0000)]
[gn build] Port e4ceb5a7bb9b

15 months ago[GVN] Fix change reporting when removing assume (PR61574)
Nikita Popov [Wed, 22 Mar 2023 14:22:33 +0000 (15:22 +0100)]
[GVN] Fix change reporting when removing assume (PR61574)

Report a change when removing a true/false assume.

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

15 months ago[X86] Create extra prolog/epilog for stack realignment
Luo, Yuanke [Wed, 22 Mar 2023 12:41:36 +0000 (20:41 +0800)]
[X86] Create extra prolog/epilog for stack realignment

Fix some bugs and reland e4c1dfed38370b4 and 614c63bec6d67c.
1. Run argument stack rebase pass before the reserved physical register
   is finalized.
2. Add LEA pseudo instruction to prevent the instruction being
   eliminated.
3. Don't support X32.

15 months ago[Assignment Tracking] Fix mem2reg misidentifying unlinked stores
OCHyams [Wed, 22 Mar 2023 13:29:46 +0000 (13:29 +0000)]
[Assignment Tracking] Fix mem2reg misidentifying unlinked stores

updateForDeletedStore updates the assignment tracking debug info for a store
that is about to be deleted by mem2reg. For each variable backed by the target
alloca, if a dbg.assign exists it is kept (well - it's downgraded to a
dbg.value). A dbg.value is inserted if there's not a linked dbg.assign for a
variable which is backed by the target alloca. This patch fixes a bug whereby a
store with a linked dbg.assign that describes a fragment different to the one
linked to the alloca was not counted for the variable, leading to both keeping
the dbg.assign (downgrading it) and inserting a new dbg.value.

Reviewed By: StephenTozer

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

15 months ago[NFC] Add DebugVariableAggregate class
OCHyams [Wed, 22 Mar 2023 13:27:35 +0000 (13:27 +0000)]
[NFC] Add DebugVariableAggregate class

A DebugVariableAggregate is a DebugVariable that discards FragmentInfo; it
represents a whole variable instance.

Reviewed By: StephenTozer

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

15 months ago[gn build] Port d6ad4f01c3da
LLVM GN Syncbot [Wed, 22 Mar 2023 14:06:06 +0000 (14:06 +0000)]
[gn build] Port d6ad4f01c3da

15 months ago[MemProf] Context disambiguation cloning pass [patch 1a/3]
Teresa Johnson [Thu, 29 Dec 2022 20:11:38 +0000 (12:11 -0800)]
[MemProf] Context disambiguation cloning pass [patch 1a/3]

Support for building, printing, and displaying CallsiteContextGraph
which represents the MemProf metadata contexts. Uses CRTP to enable
support for both IR (regular LTO) and summary (ThinLTO). This patch
includes the support for building it in regular LTO mode (from
memprof and callsite metadata), and the next patch will add the
handling for building it from ThinLTO summaries.

Also includes support for dumping the graph to text and to dot files.

Follow-on patches will contain the support for cloning on the graph and
in the IR.

The graph represents the call contexts in all memprof metadata on
allocation calls, with nodes for the allocations themselves, as well as
for the calls in each context. The graph is initially built from the
allocation memprof metadata (or summary) MIBs. It is then updated to
match calls with callsite metadata onto the nodes, updating it to
reflect any inlining performed on those calls.

Each MIB (representing an allocation's call context with allocation
behavior) is assigned a unique context id during the graph build. The
edges and nodes in the graph are decorated with the context ids they
carry. This is used to correctly update the graph when cloning is
performed so that we can uniquify the context for a single (possibly
cloned) allocation.

Depends on D140786.

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

15 months ago[Dexter] Add timeout options
Stephen Tozer [Wed, 1 Mar 2023 13:05:11 +0000 (13:05 +0000)]
[Dexter] Add timeout options

Adds a pair of options for Dexter that allow the user to specify a
timeout duration. These options are:

* --timeout-total: Times out if the total run-time of the debugger session
  exceeds <timeout-total> seconds.
* --timeout-breakpoint: Times out if the time without hitting a
  breakpoint exceeds <timeout-breakpoint> seconds.

Reviewed By: Orlando

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

15 months agodocs: add some documentation on Windows SDK search
Saleem Abdulrasool [Wed, 15 Mar 2023 20:06:56 +0000 (13:06 -0700)]
docs: add some documentation on Windows SDK search

Add some documentation on the flags and the process by which clang
identifies the headers and libraries for the Windows environment.  It
should identify the flags and their interactions as well as the order in
which the various sources of information are consulted.

Differential Revision: https://reviews.llvm.org/D146165
Reviewed By: hans, mstorjo

15 months ago[flang] add -flang-experimental-hlfir flag to flang-new
Tom Eccles [Tue, 14 Mar 2023 13:27:30 +0000 (13:27 +0000)]
[flang] add -flang-experimental-hlfir flag to flang-new

This flag instructs flang-new to use the new HLFIR lowering. It is
marked as experimental and not included in --help.

This was added to make it more convenient to test the performance of
code generated by the HLFIR lowering.

Extra diffs are from running clang-format on CLOptions.inc (which was
being forced by CI).

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

15 months ago[SimplifyCFG][LICM] Add metadata speculation tests (NFC)
Nikita Popov [Wed, 22 Mar 2023 13:21:51 +0000 (14:21 +0100)]
[SimplifyCFG][LICM] Add metadata speculation tests (NFC)

15 months ago[ConstraintElim] Add tests with GEP constant expressions.
Florian Hahn [Wed, 22 Mar 2023 13:12:49 +0000 (13:12 +0000)]
[ConstraintElim] Add tests with GEP constant expressions.

15 months ago[libc][Bazel] Bazel fix for 494734b06d62b
Dmitry Chernenkov [Wed, 22 Mar 2023 12:50:22 +0000 (12:50 +0000)]
[libc][Bazel] Bazel fix for 494734b06d62b

15 months ago[mlir][AffineMap] NFC - Refactor getProjectedMap and split into projectDims and proje...
Nicolas Vasilache [Wed, 22 Mar 2023 09:19:20 +0000 (02:19 -0700)]
[mlir][AffineMap] NFC - Refactor getProjectedMap and split into projectDims and projectSymbols

The default behavior of getProjectedMap may be surprising as it implicitly compresses the dims and
the unused symbols.

Make these explicit in the API and refactor to more idiomatic implementations with better reuse.

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

15 months ago[mlir] Add a pattern to fold tensor.cast into scf.forall.
Alexander Belyaev [Wed, 22 Mar 2023 11:50:24 +0000 (12:50 +0100)]
[mlir] Add a pattern to fold tensor.cast into scf.forall.

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

15 months ago[InstCombine] enhance icmp with sub folds
Zhongyunde [Wed, 22 Mar 2023 11:52:41 +0000 (19:52 +0800)]
[InstCombine] enhance icmp with sub folds

The new IR with And removes a use of the input variable, which is better for analysis.
Fix https://github.com/llvm/llvm-project/issues/60818

Reviewed By: nikic, spatel

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

15 months ago[tests] precommit tests for D145846
Zhongyunde [Wed, 22 Mar 2023 11:47:35 +0000 (19:47 +0800)]
[tests] precommit tests for D145846

15 months ago[LV] Set inbounds flag using CreateGEP in vectorizeInterleaveGroup(NFC).
Florian Hahn [Wed, 22 Mar 2023 11:28:49 +0000 (11:28 +0000)]
[LV] Set inbounds flag using CreateGEP in vectorizeInterleaveGroup(NFC).

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

15 months ago[LoopPredication] Add a test demonstrating bug.
Serguei Katkov [Wed, 22 Mar 2023 10:19:48 +0000 (17:19 +0700)]
[LoopPredication] Add a test demonstrating bug.

LoopPredication may introduce undefined behavior.

15 months ago[MLIR][Affine] Fix assumption on int type in memref elt size method
Uday Bondhugula [Wed, 22 Mar 2023 01:46:35 +0000 (07:16 +0530)]
[MLIR][Affine] Fix assumption on int type in memref elt size method

Fix assumption on memref element type being int/float in memref elt size
related method and affine data copy generate.

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

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

15 months ago[GVN] Regenerate test checks (NFC)
Nikita Popov [Wed, 22 Mar 2023 10:40:07 +0000 (11:40 +0100)]
[GVN] Regenerate test checks (NFC)

15 months ago[IR] Rename dropUndefImplying to dropUBImplying (NFC)
Nikita Popov [Wed, 22 Mar 2023 09:48:26 +0000 (10:48 +0100)]
[IR] Rename dropUndefImplying to dropUBImplying (NFC)

Clarify that this is only about immediate undefined behavior,
not about undef or poison.

15 months ago[dataflow] Log flow condition to the correct stream.
Sam McCall [Tue, 21 Mar 2023 14:34:31 +0000 (15:34 +0100)]
[dataflow] Log flow condition to the correct stream.

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

15 months ago[llvm][ARM] Fix bounds check after use in ARMAsmParser
David Spickett [Wed, 22 Mar 2023 09:49:02 +0000 (09:49 +0000)]
[llvm][ARM] Fix bounds check after use in ARMAsmParser

Fixes #61605

15 months ago[lldb] Add test for unavailable registers
David Spickett [Mon, 13 Mar 2023 14:28:39 +0000 (14:28 +0000)]
[lldb] Add test for unavailable registers

Prior to this the only check was that we did not print
this message when reading registers that should exist.

I thought there was an indentation bug here so I wrote a test
for it. There is not, but we could do with the coverage anyway.

Reviewed By: rupprecht

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

15 months ago[mlir][llvm] Add experimental alias scope decl intrinsic.
Tobias Gysi [Wed, 22 Mar 2023 09:20:55 +0000 (10:20 +0100)]
[mlir][llvm] Add experimental alias scope decl intrinsic.

The revision adds the llvm.experimental.noalias.scope.decl intrinsic
to the LLVM dialect and updates the import and export accordingly.

Reviewed By: Dinistro

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

15 months ago[mlir][Transforms][NFC] Improve builder/listener API of OperationFolder
Matthias Springer [Wed, 22 Mar 2023 08:04:01 +0000 (09:04 +0100)]
[mlir][Transforms][NFC] Improve builder/listener API of OperationFolder

The constructor of `OperationFolder` takes a listener. Therefore, the remaining API should not take any builder/rewriters. This could lead to double notifications in case a listener is attached to the builder/rewriter.

As an internal cleanup, `OperationFolder` now has an `IRRewriter` instead of a `RewriterBase::Listener`. In most cases, `OperationFolder` no longer has to notify/deal with listeners. This is done by the rewriter.

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

15 months ago[mlir][Bazel] Add missing dependency.
Adrian Kuegel [Wed, 22 Mar 2023 08:20:35 +0000 (09:20 +0100)]
[mlir][Bazel] Add missing dependency.

15 months ago[GuardWidening] Improve analysis of potential widening into hotter block, try 2
Max Kazantsev [Wed, 22 Mar 2023 07:29:12 +0000 (14:29 +0700)]
[GuardWidening] Improve analysis of potential widening into hotter block, try 2

The initial version was reverted because it looped infinitely if the likely successor
isn't properly dominated by the predecessor. In practice it means that we went up the
CFG through backedge and looped infinitely.

I also added some paranoid assertion checks to make sure that every other invariant
holds. I also found a hypothetical situation when we may go past the dominated block
while following the likely successors (it means that in fact the dominated block is
dynamically not reachable from dominating block) and explicitly prohibited this, though
I don't have a motivating test showing that it's a real problem.

https://reviews.llvm.org/D146276

15 months ago[mlir] Argument and result attribute handling during inlining.
Tobias Gysi [Wed, 22 Mar 2023 07:38:55 +0000 (08:38 +0100)]
[mlir] Argument and result attribute handling during inlining.

The revision adds the handleArgument and handleResult handlers that
allow users of the inlining interface to implement argument and result
conversions that take argument and result attributes into account. The
motivating use cases for this revision are taken from the LLVM dialect
inliner, which has to copy arguments that are marked as byval and that
also has to consider zeroext / signext when converting integers.

All type conversions are currently handled by the
materializeCallConversion hook. It runs before isLegalToInline and
supports only the introduction of a single cast operation since it may
have to rollback. The new handlers run shortly before and after
inlining and cannot fail. As a result, they can introduce more complex
ir such as copying a struct argument. At the moment, the new hooks
cannot be used to perform type conversions since all type conversions
have to be done using the materializeCallConversion. A follow up
revision will either relax this constraint or drop
materializeCallConversion in favor of the new and more flexible
handlers.

The revision also extends the CallableOpInterface to provide access
to the argument and result attributes if available.

Reviewed By: rriddle, Dinistro

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

15 months ago[mlir][IR] Add ReverseDominanceIterator for IR walkers
Matthias Springer [Wed, 22 Mar 2023 07:53:38 +0000 (08:53 +0100)]
[mlir][IR] Add ReverseDominanceIterator for IR walkers

Blocks are enumerated depth-first, but post-order. I.e., a block is enumerated when its successors have been enumerated. This iteration style is suitable when deleting blocks in a regions: in the absence of cycles, uses are deleted before their definitions.

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

15 months ago[analyzer] Fix crashing getSValFromInitListExpr for nested initlists
Balazs Benics [Wed, 22 Mar 2023 07:43:09 +0000 (08:43 +0100)]
[analyzer] Fix crashing getSValFromInitListExpr for nested initlists

In the following example, we will end up hitting the `llvm_unreachable()`:
https://godbolt.org/z/5sccc95Ec
```lang=C++
enum class E {};
const E glob[] = {{}};
void initlistWithinInitlist() {
  clang_analyzer_dump(glob[0]); // crashes at loading from `glob[0]`
}
```

We should just return `std::nullopt` instead for these cases.
It's better than crashing.

Reviewed By: xazax.hun

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

15 months ago[llvm] Use llvm::isNullConstant (NFC)
Kazu Hirata [Wed, 22 Mar 2023 07:31:48 +0000 (00:31 -0700)]
[llvm] Use llvm::isNullConstant (NFC)

15 months ago[Test] Add hanging test for D146276
Max Kazantsev [Wed, 22 Mar 2023 07:25:34 +0000 (14:25 +0700)]
[Test] Add hanging test for D146276

The patch was reverted because of hang, adding the test so that this doesn't
happen again.

15 months ago[X86] Use llvm::isOneConstant (NFC)
Kazu Hirata [Wed, 22 Mar 2023 07:25:13 +0000 (00:25 -0700)]
[X86] Use llvm::isOneConstant (NFC)

15 months ago[flang] Feature list plugin
Ethan Luis McDonough [Thu, 2 Mar 2023 18:29:05 +0000 (12:29 -0600)]
[flang] Feature list plugin

Plugin that counts the number of times each tree node occurs in a given program.  Used for test coverage.

Updated to fix build issues.

Reviewed By: jdoerfert

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

15 months ago[MCContext] Use `const Twine &` in symbol creation methods. NFC
paperchalice [Wed, 22 Mar 2023 06:13:59 +0000 (23:13 -0700)]
[MCContext] Use `const Twine &` in symbol creation methods. NFC

All of these methods will invoke `getOrCreateSymbol(const Twine &Name)`, using `Twine` here makes these methods more flexible.

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

15 months ago[mlir][memref] Use folded composed affine apply ops in FoldMemRefAliasOps
Nicolas Vasilache [Mon, 20 Mar 2023 21:22:00 +0000 (14:22 -0700)]
[mlir][memref] Use folded composed affine apply ops in FoldMemRefAliasOps

Creating maximally folded and composd affine.apply operation during
FoldMemRefAliasOps composes better with other transformations without having
to interleave canonicalization passes.

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

15 months ago[clang][driver] Enable '-flto' on AVR
Ben Shi [Thu, 9 Mar 2023 04:04:54 +0000 (12:04 +0800)]
[clang][driver] Enable '-flto' on AVR

Reviewed By: MaskRay

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

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

15 months ago[Coroutines] Implement fix for cwg2563 issue and enable RVO under certain conditions
Bruno Cardoso Lopes [Thu, 9 Mar 2023 00:00:02 +0000 (16:00 -0800)]
[Coroutines] Implement fix for cwg2563 issue and enable RVO under certain conditions

- The cwg2563 issue is fixed by delaying GRO initialization only when the types
  mismatch between GRO and function return.
- When the types match directly initialize, which indirectly enables RVO to
  kick in, partially restores behavior introduced in
  https://reviews.llvm.org/D117087.
- Add entry to release notes.

Background:
https://github.com/llvm/llvm-project/issues/56532
https://cplusplus.github.io/CWG/issues/2563.html
https://github.com/cplusplus/papers/issues/1414

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

15 months ago[Coroutines] Fix premature conversion of return object
Bruno Cardoso Lopes [Tue, 7 Mar 2023 20:51:34 +0000 (12:51 -0800)]
[Coroutines] Fix premature conversion of return object

Fix https://github.com/llvm/llvm-project/issues/56532

Effectively, this reverts behavior introduced in https://reviews.llvm.org/D117087,
which did two things:

1. Change delayed to early conversion of return object.
2. Introduced RVO possibilities because of early conversion.

This patches fixes (1) and removes (2). I already worked on a follow up for (2)
in a separated patch. I believe it's important to split these two because if the RVO
causes any problems we can explore reverting (2) while maintaining (1).

Notes on some testcase changes:
- `pr59221.cpp` changed to `-O1` so we can check that the front-end honors
  the value checked for. Sounds like `-O3` without RVO is more likely
  to work with LLVM optimizations...
- Comment out delete members `coroutine-no-move-ctor.cpp` since behavior
  now requires copies again.

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

15 months ago[PowerPC][NFC] add const-nonsplat-array-init.ll
Ting Wang [Wed, 22 Mar 2023 04:32:18 +0000 (00:32 -0400)]
[PowerPC][NFC] add const-nonsplat-array-init.ll

When doing store constant vector/scalar, some duplicated values can be reused.
Add test case and will show combiner can improve these.

Reviewed By: shchenz

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

15 months agoupdate dependency for TransformOpsPyTdFiles
yijia1212 [Wed, 22 Mar 2023 04:26:09 +0000 (21:26 -0700)]
update dependency for TransformOpsPyTdFiles

update dependency for TransformOpsPyTdFiles

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

15 months ago[RISCV] Clear mayRaiseFPException for fclass.d instruction.
Craig Topper [Wed, 22 Mar 2023 02:48:20 +0000 (19:48 -0700)]
[RISCV] Clear mayRaiseFPException for fclass.d instruction.

We got it right for fclass.s and fclass.h.

15 months ago[RISCV] Clear mayRaiseFPException for Zfa fmvh.x.d and fmvp.d.x instructions.
Craig Topper [Wed, 22 Mar 2023 02:42:27 +0000 (19:42 -0700)]
[RISCV] Clear mayRaiseFPException for Zfa fmvh.x.d and fmvp.d.x instructions.

16 months ago[RISCV] Move fli selection in RISCVISelDAGToDAG.cpp. NFC
Craig Topper [Wed, 22 Mar 2023 02:15:30 +0000 (19:15 -0700)]
[RISCV] Move fli selection in RISCVISelDAGToDAG.cpp. NFC

We custom isel for ConstantFP that has higher priority than isel
patterns. We were previously detecting valid FP constants for fli
to early exit from the custom code. This detection called
getLoadFPImm. Then we would run the isel patterns which would call
getLoadFPImm a second time.

With a little bit more code we can directly select the fli instruction
in the custom handler and avoid a second call.

Remove the incorrect mayRaiseFPException flag from the FLI instructions.

Reviewed By: joshua-arch1

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

16 months ago[AIX][r] Do not call AddFilePathLibArgs with -r
Michael Francis [Tue, 21 Mar 2023 22:06:47 +0000 (22:06 +0000)]
[AIX][r] Do not call AddFilePathLibArgs with -r

We do not want to add file path lib args when -r is specified.

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

16 months ago[LFTR] Minor style cleanup [nfc]
Philip Reames [Wed, 22 Mar 2023 02:12:35 +0000 (19:12 -0700)]
[LFTR] Minor style cleanup [nfc]

16 months ago[LFTR] Use evaluateAtIteration in genLoopLimit [nfc]
Philip Reames [Wed, 22 Mar 2023 02:08:34 +0000 (19:08 -0700)]
[LFTR] Use evaluateAtIteration in genLoopLimit [nfc]

Note that the comments being removed appear to be very out of sync with the actual code in question.

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

16 months ago[LFTR] Simplify another case under assumption exit counts are integers [nfc]
Philip Reames [Wed, 22 Mar 2023 02:04:14 +0000 (19:04 -0700)]
[LFTR] Simplify another case under assumption exit counts are integers [nfc]

This invariant was introduced in 8f3d16905d75b07a933d01dc29677fe5867c1b3e.

16 months ago[OpenMP] Remove shadow pointer map and introduce consistent locking
Johannes Doerfert [Tue, 21 Mar 2023 20:40:36 +0000 (13:40 -0700)]
[OpenMP] Remove shadow pointer map and introduce consistent locking

The shadow pointer map was problematic as we scanned an entire list if
an entry had shadow pointers. The new scheme stores the shadow pointers
inside the entries. This allows easy access without any search. It also
helps us, but also makes it necessary, to define a consistent locking
scheme. The implicit locking of entries via TargetPointerResultTy makes
this pretty effortless, however one has to:

- Lock HDTTMap before locking an entry.
- Do not lock HDTTMap while holding an entry lock.
- Hold the entry lock to read or modify an entry.

The changes to submitData and retrieveData have been made to ensure 2
when the LIBOMPTARGET_INFO flag is used. Most everything else happens by
itself as TargetPointerResultTy acts as a lock_guard for the entry. It
is a little complicated when we deal with multiple entries, especially
as they can be equal. However, one can still follow the rules with
reasonable effort.

LookupResult are now finally also locking the entry before it is
inspected. This is good even if we haven't run into a problem yet.

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

16 months ago[OpenMP] Remove restriction on the thread count for parallel regions
Johannes Doerfert [Wed, 22 Mar 2023 00:43:26 +0000 (17:43 -0700)]
[OpenMP] Remove restriction on the thread count for parallel regions

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

16 months ago[OpenMP] Avoid zero size copies to the device
Johannes Doerfert [Tue, 21 Mar 2023 22:48:11 +0000 (15:48 -0700)]
[OpenMP] Avoid zero size copies to the device

This unblocks one of the XFAIL tests for AMD, though we need to work
around the missing printf still.

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

16 months ago[libc] Don't install the GPU startup code for now
Joseph Huber [Wed, 22 Mar 2023 02:00:46 +0000 (21:00 -0500)]
[libc] Don't install the GPU startup code for now

Summary:
This startup code is only intended to be used internally, we shouldn't
export it under a conflicting name. In the future we may package this in
an exportable format.

16 months ago[RISCV] Use LBU for extloadi8.
Craig Topper [Wed, 22 Mar 2023 01:52:05 +0000 (18:52 -0700)]
[RISCV] Use LBU for extloadi8.

The Zcb extension has c.lbu, but not c.lb. This patch makes us
prefer LBU over LB if we have a choice which will enable more
compression opportunities.

Reviewed By: asb

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

16 months ago[amdgpu][nfc] clang-format AMDGPULowerModuleLDS for easier merging
Jon Chesterfield [Wed, 22 Mar 2023 01:49:41 +0000 (01:49 +0000)]
[amdgpu][nfc] clang-format AMDGPULowerModuleLDS for easier merging

16 months ago[SCEV] Add coverage for a missing flag inference case
Philip Reames [Wed, 22 Mar 2023 01:34:40 +0000 (18:34 -0700)]
[SCEV] Add coverage for a missing flag inference case

16 months ago[amdgpu][nfc] Extract more functions in LowerModuleLDS, mark more methods static
Jon Chesterfield [Wed, 22 Mar 2023 01:23:19 +0000 (01:23 +0000)]
[amdgpu][nfc] Extract more functions in LowerModuleLDS, mark more methods static

16 months ago[llvm] Use ConstantInt::{isZero,isOne} (NFC)
Kazu Hirata [Wed, 22 Mar 2023 00:40:35 +0000 (17:40 -0700)]
[llvm] Use ConstantInt::{isZero,isOne} (NFC)

16 months ago[mlir][sparse] fix crash when using pure constant index in indexing mapping (fixes...
Peiming Liu [Tue, 21 Mar 2023 20:47:47 +0000 (20:47 +0000)]
[mlir][sparse] fix crash when using pure constant index in indexing mapping (fixes #61530)

To address https://github.com/llvm/llvm-project/issues/61530

Reviewed By: aartbik, wrengr

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

16 months ago[amdgpu][nfc] Comment and extract two functions in LowerModuleLDS
Jon Chesterfield [Tue, 21 Mar 2023 23:15:44 +0000 (23:15 +0000)]
[amdgpu][nfc] Comment and extract two functions in LowerModuleLDS

16 months ago[lldb][CMake] Enforce not linking against plugin libs in core libs
Alex Langford [Tue, 21 Mar 2023 18:20:31 +0000 (11:20 -0700)]
[lldb][CMake] Enforce not linking against plugin libs in core libs

Non-plugin lldb libraries should generally not be linking against lldb
plugin libraries. Enforce this in CMake.

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

16 months ago[mlir][sparse] Adding new `Merger::addLat` overload
wren romano [Tue, 21 Mar 2023 20:13:42 +0000 (13:13 -0700)]
[mlir][sparse] Adding new `Merger::addLat` overload

Reviewed By: aartbik

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

16 months ago[RISCV] Improve validation of opcode for .insn.
Craig Topper [Tue, 21 Mar 2023 23:20:30 +0000 (16:20 -0700)]
[RISCV] Improve validation of opcode for .insn.

The lower 2 bits of the opcode must be 0x3. If the lower 2 bits are
0-2, it's a compressed instruction.

Merge 3 slightly different error messages into 1 to reduce code. The
messages differed slightly depending on whether we parsed a string
or an expression. The message gets a little more generic, but is no
more generic than what binutils prints.

16 months ago[WebAssembly] Fix i64_i64_func_i64_i64_i32 type signature when multivalue feature...
Congcong Cai [Tue, 21 Mar 2023 22:32:01 +0000 (06:32 +0800)]
[WebAssembly] Fix i64_i64_func_i64_i64_i32 type signature when multivalue feature is enabled

Reviewed By: tlively

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

16 months ago[NFC][tsan] Add __tsan_default_{options,suppressions} into interface header
Vitaly Buka [Tue, 21 Mar 2023 22:41:19 +0000 (15:41 -0700)]
[NFC][tsan] Add __tsan_default_{options,suppressions} into interface header

16 months ago[CUDA] Update cached kernel handle when the function instance changes.
Artem Belevich [Mon, 20 Mar 2023 18:18:53 +0000 (11:18 -0700)]
[CUDA] Update cached kernel handle when the function instance changes.

Fixes clang crash caused by a stale function pointer.

The bug has been present for a pretty long time, but we were lucky not to
trigger it until  D140663.

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

16 months agoAdd missing dependency for TransformDialect
Anlun Xu [Tue, 21 Mar 2023 22:23:13 +0000 (15:23 -0700)]
Add missing dependency for TransformDialect

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

16 months ago[lldb] Refactor deduction of the instance variable's name (NFC)
Dave Lee [Fri, 17 Mar 2023 02:19:05 +0000 (19:19 -0700)]
[lldb] Refactor deduction of the instance variable's name (NFC)

Move responsibility of providing the instance variable name (`this`, `self`) from
`TypeSystem` to `Language`.

`Language` the natural place for this, but also has downstream benefits. Some languages
have multiple `TypeSystem` implementations (ex Swift), and by placing this logic in the
`Language`, redundancy is avoided.

This change relies on the tests from D145348 and D146320.

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

16 months ago[RISCV] Remove 'rs1' field from RVInst16 class. NFC
Craig Topper [Tue, 21 Mar 2023 21:58:53 +0000 (14:58 -0700)]
[RISCV] Remove 'rs1' field from RVInst16 class. NFC

16 months agoFix dep error for transform dialect in bazel
yijia1212 [Tue, 21 Mar 2023 21:40:17 +0000 (14:40 -0700)]
Fix dep error for transform dialect in bazel

Fix dep error for transform dialect in bazel

Reviewed By: anlunx

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

16 months ago[mlir][tosa] Add check if the operand of the operations is constant.
TatWai Chong [Tue, 21 Mar 2023 20:50:13 +0000 (20:50 +0000)]
[mlir][tosa] Add check if the operand of the operations is constant.

Some uses of TOSA rely on the constant operands of particular operations,
e.g. paddings and pad_const in pad op. Add a verification pattern in the
validation pass, and this is optionally enabled.

Change-Id: I1628c0840a27ab06ef91150eee56ad4f5ac9543d

Reviewed By: rsuderman

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

16 months ago[mlir][sparse][gpu] end-to-end test for 2:4 sparsity on NVidia GPUs
Aart Bik [Sat, 18 Mar 2023 01:24:01 +0000 (18:24 -0700)]
[mlir][sparse][gpu] end-to-end test for 2:4 sparsity on NVidia GPUs

Example of using 2:4 sparsity on NVidia GPU

Reviewed By: ThomasRaoux

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

16 months ago[memprof] Support symbolization of PIE binaries.
Snehasish Kumar [Sat, 11 Mar 2023 00:16:03 +0000 (00:16 +0000)]
[memprof] Support symbolization of PIE binaries.

Support symolization of PIE binaries in memprof. We assume that the
profiled binary has one executable text segment for simplicity. Update
the memprof-pic test to now expect the same output as the memprof-basic test.

Reviewed By: tejohnson

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

16 months ago[IRSim] Check largest sections first when analyzing similarity
Andrew Litteken [Tue, 21 Mar 2023 01:54:44 +0000 (20:54 -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.

Recommit fixes the IRSimilarity tests.

Recommit of: 805ec19d7d9915989be8a8a626176b5e29e19eee

Recommit fixes llvm-sim tests

Recommit of: 082ec267583100455fee356bb0d4ebd55aba2d46

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

16 months ago[flang] Set proper source location for the main function.
Slava Zakharin [Fri, 17 Mar 2023 23:52:19 +0000 (16:52 -0700)]
[flang] Set proper source location for the main function.

Take the source position for the anonymous program from its scope.
If the first evaluation is a construct or directive, then it has
null source position.

Author: vdonaldson
Differential Revision: https://reviews.llvm.org/D146445

16 months ago[TSAN][Darwin] Forward declare spinlock functions on darwin for TSAN interceptors
Blue Gaston [Tue, 21 Mar 2023 15:48:22 +0000 (08:48 -0700)]
[TSAN][Darwin] Forward declare spinlock functions on darwin for TSAN interceptors

Spinlock symbols are removed from headers in MacOS version 10.12 and greater.
Even though they are deprecated, the symbols remain available on the system.

The TSAN interceptors currently cause a build failure after this version because
of the change in availability of the symbol.

We want to continue intercepting the symbols available on the OS.
So we add forward declarations so that the TSAN interceptors can build.

This is tested with the existing osspinlock_norace test.

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

16 months ago[NFC] Fix incorrect comment for simplifyRightShift
Arthur Eubanks [Tue, 21 Mar 2023 19:05:18 +0000 (12:05 -0700)]
[NFC] Fix incorrect comment for simplifyRightShift

16 months ago[llvm-libtool-darwin] Fix test when libfile.a exists
Shoaib Meenai [Tue, 21 Mar 2023 18:19:34 +0000 (11:19 -0700)]
[llvm-libtool-darwin] Fix test when libfile.a exists

This can be a valid system library, as reported in
https://reviews.llvm.org/D85540#inline-1415298

16 months agoUpdate checks in advance of an update to D68233.
Kevin P. Neal [Tue, 21 Mar 2023 17:54:42 +0000 (13:54 -0400)]
Update checks in advance of an update to D68233.

In the past, the IR Verifier would bail out at the first broken function
it found. This required trickery with sed to put multiple broken functions
in a single test file.

Now, the Verifier allows for multiple broken functions. The sed trickery
is no longer needed. I've eliminated it.

I've also split the test into two since one of them passes verification
and we need to look at the output IR from 'opt'. The other fails and we
need to look at the diagnostics printed by the Verifier.

16 months ago[SelectionDAG][RISCV] Remove code for handling too small shift type from SimplifyDema...
Craig Topper [Tue, 21 Mar 2023 18:07:38 +0000 (11:07 -0700)]
[SelectionDAG][RISCV] Remove code for handling too small shift type from SimplifyDemandedBits.

This code detected that the type returned from getShiftAmountTy was
too small to hold the constant shift amount. But it used the full
type size instead of scalar type size leading it to crash for
scalable vectors.

This code was necessary when getShiftAmountTy would always
return the target preferred shift amount type for scalars even when
the type was an illegal type larger than the target supported. For
vectors, getShiftAmountTy has always returned the vector type.

Fortunately, getShiftAmountTy was fixed a while ago to detect that
the target's preferred size for scalars is not large enough for the
type. So we can delete this code.

Switched to use getShiftAmountConstant to further simplify the code.

Fixs PR61561.

16 months ago[libc++][spaceship] Implement `operator<=>` for `duration`
Hristo Hristov [Sat, 18 Mar 2023 10:54:17 +0000 (12:54 +0200)]
[libc++][spaceship] Implement `operator<=>` for `duration`

Implements parts of [[ https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1614r2.html | P1614R2 ]]
Implemented `operator<=>` for `std::chrono::duration`

Reviewed By: #libc, Mordante

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

16 months ago[lldb][expr] Propagate ClangDynamicCheckerFunctions::Install() errors to caller
Stefan Gränitz [Tue, 21 Mar 2023 18:01:54 +0000 (19:01 +0100)]
[lldb][expr] Propagate ClangDynamicCheckerFunctions::Install() errors to caller

I came accross this, because a lot of regression tests were saying:
```
(lldb) p argc
error: expression failed to parse:
error: couldn't install checkers, unknown error
```

With this change, error messages provide more detail:
```
(lldb) p argc
error: expression failed to parse:
error: couldn't install checkers:
error: Couldn't lookup symbols:
  __objc_load
```

I didn't find a case where `Diagnostics()` is not empty. Also it looks like this isn't covered in any test (yet).

Reviewed By: bulbazord, Michael137

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

16 months ago[AlwaysInliner] Make legacy pass like the new pass
Arthur Eubanks [Mon, 20 Mar 2023 18:18:35 +0000 (11:18 -0700)]
[AlwaysInliner] Make legacy pass like the new pass

The legacy pass is only used in AMDGPU codegen, which doesn't care about running it in call graph order (it actually has to work around that fact).

Make the legacy pass a module pass and share code with the new pass.

This allows us to remove the legacy inliner infrastructure.

Reviewed By: mtrofin

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

16 months ago[lldb][CMake] Enforce not letting lldbUtility link against any other lldb libs
Alex Langford [Mon, 20 Mar 2023 23:41:11 +0000 (16:41 -0700)]
[lldb][CMake] Enforce not letting lldbUtility link against any other lldb libs

lldbUtility is not supposed to depend on anything else in lldb. Let's
enforce that constraint in CMake rather than hoping something doesn't
slip in under the radar.

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

16 months ago[test] Change DAG to NEXT in pipeline tests
Arthur Eubanks [Tue, 21 Mar 2023 17:25:04 +0000 (10:25 -0700)]
[test] Change DAG to NEXT in pipeline tests

These were made consistent in 951a980dc7aa6.

16 months agoRecommit [lldb] Change dwim-print to default to disabled persistent results
Dave Lee [Wed, 8 Mar 2023 21:22:00 +0000 (13:22 -0800)]
Recommit [lldb] Change dwim-print to default to disabled persistent results

Change `dwim-print` to now disable persistent results by default, unless requested by
the user with the `--persistent-result` flag.

Ex:

```
(lldb) dwim-print 1 + 1
(int) 2
(lldb) dwim-print --persistent-result on -- 1 + 1
(int) $0 = 2
```

Users who wish to enable persistent results can make and use an alias that includes
`--persistent-result on`.

Updates: To recommit this, both TestPersistentResult.py and TestPAlias.py needed to be
updated, as well as the changes in D146230.

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

16 months ago[llvm][support] Fix ScopedPrinterTest on AIX
Paul Kirth [Tue, 21 Mar 2023 16:39:33 +0000 (16:39 +0000)]
[llvm][support] Fix ScopedPrinterTest on AIX

The test strings we used for infinity and NAN were not correct on AIX.
This patch creates those dynamically instead of hard-coded.

Reviewed By: abhina.sreeskantharajan

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

16 months ago[DAG] visitABS - use FoldConstantArithmetic to perform constant folding.
Simon Pilgrim [Tue, 21 Mar 2023 17:23:21 +0000 (17:23 +0000)]
[DAG] visitABS - use FoldConstantArithmetic to perform constant folding.

Avoid needing to perform extra isConstantIntBuildVectorOrConstantInt checks

16 months ago[lldb] Test direct ivar access in objc++ (NFC)
Dave Lee [Fri, 17 Mar 2023 02:15:38 +0000 (19:15 -0700)]
[lldb] Test direct ivar access in objc++ (NFC)

Add an Objective-C++ specific test for direct ivar access. This adds to the existing C++ and ObjC tests, and tests against regression for future refactoring.

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

16 months ago[test] Remove redundant check prefix from new-pm-thinlto-prelink-pgo-defaults.ll
Arthur Eubanks [Tue, 21 Mar 2023 17:11:01 +0000 (10:11 -0700)]
[test] Remove redundant check prefix from new-pm-thinlto-prelink-pgo-defaults.ll

16 months ago[ADT] Add `llvm::range_size` function for generic ranges
Jakub Kuderski [Tue, 21 Mar 2023 16:58:17 +0000 (12:58 -0400)]
[ADT] Add `llvm::range_size` function for generic ranges

This function follows `std::ranges::size` from C++20. It is intended
mainly for generic code that does not know the exact range type.
I did not modify the existing `llvm::size` function because it has a strict
guarantee of O(1) running time, and we cannot guarantee that when we delegate
size check to user-defined size functions.

Use `range_size` to optimize size checks in `zip`* and `enumerate`
functions. Before that, we would have to perform linear scans for ranges
without random access iterators.

This is the last change I have planned in the series that overhauls
`zip`* and `enumerate`.

Reviewed By: dblaikie, zero9178

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

16 months agoNo longer issue static lambda pedantic warning for pre-c++2b compat
Aaron Ballman [Tue, 21 Mar 2023 16:48:13 +0000 (12:48 -0400)]
No longer issue static lambda pedantic warning for pre-c++2b compat

We were accidentally issuing "static lambdas are incompatible with C++
standards before C++2b" 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 ago[IndVarSimplify] Remove duplicate call to getSCEV. NFC
Craig Topper [Tue, 21 Mar 2023 16:47:07 +0000 (09:47 -0700)]
[IndVarSimplify] Remove duplicate call to getSCEV. NFC

We already did this same call on the line before.

Reviewed By: nikic

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

16 months ago[libc++] Qualifies size_t.
Mark de Wever [Tue, 14 Mar 2023 20:27:03 +0000 (21:27 +0100)]
[libc++] Qualifies size_t.

This has been done using the following command

  find libcxx/test -type f -exec perl -pi -e 's|^([^/]+?)((?<!::)size_t)|\1std::\2|' \{} \;

And manually removed some false positives in std/depr/depr.c.headers.

The `std` module doesn't export `::size_t`, this is a preparation for that module.

Reviewed By: ldionne, #libc, EricWF, philnik

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

16 months ago[LSR] Don't crash on non-branch terminator in -lsr-term-fold
Philip Reames [Tue, 21 Mar 2023 16:28:27 +0000 (09:28 -0700)]
[LSR] Don't crash on non-branch terminator in -lsr-term-fold

Reported in https://reviews.llvm.org/D146415.  I rewrote the patch and aded the test case.  Per that report, spec2006.483.xalancbmk crashes without this fix.

16 months ago[LSR] Remove a couple stale comments in lsr-term-fold
Philip Reames [Tue, 21 Mar 2023 15:30:38 +0000 (08:30 -0700)]
[LSR] Remove a couple stale comments in lsr-term-fold

16 months ago[test] Split up new-pm-thinlto-defaults.ll into prelink and postlink pipelines
Arthur Eubanks [Tue, 21 Mar 2023 01:01:50 +0000 (18:01 -0700)]
[test] Split up new-pm-thinlto-defaults.ll into prelink and postlink pipelines

They're becoming different enough that it's getting annoying to figure out how allocate check prefixes.

Reviewed By: tejohnson

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