platform/upstream/llvm.git
2 years ago[test] Fix leak in test
Vitaly Buka [Sat, 16 Jul 2022 19:40:41 +0000 (12:40 -0700)]
[test] Fix leak in test

2 years ago[PGO][InstrProf][test] Convert to opaque pointers and fix some stale tests
Fangrui Song [Sat, 16 Jul 2022 18:42:35 +0000 (11:42 -0700)]
[PGO][InstrProf][test] Convert to opaque pointers and fix some stale tests

2 years ago[AMDGPU] Declare TableRef in terms of ArrayRef (NFC)
Kazu Hirata [Sat, 16 Jul 2022 17:56:20 +0000 (10:56 -0700)]
[AMDGPU] Declare TableRef in terms of ArrayRef (NFC)

2 years agoVisual C++ doesn't support C99 compound literal
Igor Zhukov [Sat, 16 Jul 2022 17:47:20 +0000 (19:47 +0200)]
Visual C++ doesn't support C99 compound literal

Fix test libcxx/test/std/containers/sequences/array/array.creation/to_array.pass.cpp

Reviewed By: #libc, Mordante

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

2 years agoTests ignore the return value of sto{meow}, triggering nodiscard warnings in MS STL
Igor Zhukov [Sat, 16 Jul 2022 17:40:53 +0000 (19:40 +0200)]
Tests ignore the return value of sto{meow}, triggering nodiscard warnings in MS STL

Reviewed By: #libc, Mordante

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

2 years agoRevert rG14364200821f7b2d97edf6e78160c514800d3ec6 "[ARM] Regenerate reg_sequence...
Simon Pilgrim [Sat, 16 Jul 2022 16:32:53 +0000 (17:32 +0100)]
Revert rG14364200821f7b2d97edf6e78160c514800d3ec6 "[ARM] Regenerate reg_sequence.ll test checks"

Breaks on some apple machines

2 years ago[SystemZ] Add funnel shift test coverage
Simon Pilgrim [Sat, 16 Jul 2022 16:31:50 +0000 (17:31 +0100)]
[SystemZ] Add funnel shift test coverage

Based off conversations on Issue #56495

2 years ago[LV] Avoid creating new run-time VF expression for each runtime checks.
Florian Hahn [Sat, 16 Jul 2022 16:24:07 +0000 (17:24 +0100)]
[LV] Avoid creating new run-time VF expression for each runtime checks.

At the moment, the cost of runtime checks for scalable vectors is
overestimated due to creating separate vscale * VF expressions for each
check. Instead re-use the first expression.

2 years ago[clang-format][docs] Fix incorrect 'clang-format 7' option markers
Krystian Kuzniarek [Thu, 28 Apr 2022 13:40:09 +0000 (15:40 +0200)]
[clang-format][docs] Fix incorrect 'clang-format 7' option markers

Introduced by 23a5090c6, some style option markers indicated
'clang-format 7', though their respective options were available in
different releases.

2 years ago[ARM] Regenerate reg_sequence.ll test checks
Simon Pilgrim [Sat, 16 Jul 2022 16:10:35 +0000 (17:10 +0100)]
[ARM] Regenerate reg_sequence.ll test checks

2 years ago[DAG] visitINSERT_VECTOR_ELT - refactor BUILD_VECTOR creation from INSERT_VECTOR_ELT...
Simon Pilgrim [Sat, 16 Jul 2022 15:37:31 +0000 (16:37 +0100)]
[DAG] visitINSERT_VECTOR_ELT - refactor BUILD_VECTOR creation from INSERT_VECTOR_ELT chain.

D127595 added the ability to recurse up a (one-use) INSERT_VECTOR_ELT chain to create a BUILD_VECTOR before other combines manage to break the chain, something that is particularly bad in D127115.

The patch generalises this so it doesn't have to build the chain starting from the last element insertion, instead it can now start from any insertion and will recurse up the chain until it finds all elements or finds a UNDEF/BUILD_VECTOR/SCALAR_TO_VECTOR which represents that start of the chain.

Fixes several regressions in D127115

2 years ago[DAG] visitINSERT_VECTOR_ELT - remove duplicate VT.getVectorNumElements() call. NFC.
Simon Pilgrim [Sat, 16 Jul 2022 15:20:49 +0000 (16:20 +0100)]
[DAG] visitINSERT_VECTOR_ELT - remove duplicate VT.getVectorNumElements() call. NFC.

2 years agoDon't sink ptrtoint/inttoptr sequences into non-noop addrspacecasts.
Tim Besard [Sat, 16 Jul 2022 14:34:42 +0000 (10:34 -0400)]
Don't sink ptrtoint/inttoptr sequences into non-noop addrspacecasts.

In https://reviews.llvm.org/D30114, support for mismatching address
spaces was introduced to CodeGenPrepare's optimizeMemoryInst, using
addrspacecast as it was argued that only no-op addrspacecasts would be
considered when constructing the address mode. However, by doing
inttoptr/ptrtoint, it's possible to get CGP to emit an addrspace
that's not actually no-op, introducing a miscompilation:

define void @kernel(i8* %julia_ptr) {
  %intptr = ptrtoint i8* %julia_ptr to i64
  %ptr = inttoptr i64 %intptr to i32 addrspace(3)*

  br label %end
end:

  store atomic i32 1, i32 addrspace(3)* %ptr unordered, align 4
  ret void
}

Gets compiled to:

define void @kernel(i8* %julia_ptr) {
end:
  %0 = addrspacecast i8* %julia_ptr to i32 addrspace(3)*
  store atomic i32 1, i32 addrspace(3)* %0 unordered, align 4
  ret void
}

In the case of NVPTX, this introduces a cvta.to.shared, whereas
leaving out the %end block and branch doesn't trigger this
optimization. This results in illegal memory accesses as seen in
https://github.com/JuliaGPU/CUDA.jl/issues/558

In this change, I introduced a check before doing the pointer cast
that verifies address spaces are the same. If not, it emits a
ptrtoint/inttoptr combination to get a no-op cast between address
spaces. I decided against disallowing ptrtoint/inttoptr with
non-default AS in matchOperationAddr, because now its still possible
to look through multiple sequences of them that ultimately do not
result in a address space mismatch (i.e. the second lit test).

2 years ago[AArch64] Regenerate arm64-vector-ldst.ll test checks
Simon Pilgrim [Sat, 16 Jul 2022 14:27:41 +0000 (15:27 +0100)]
[AArch64] Regenerate arm64-vector-ldst.ll test checks

2 years ago[AArch64] Regenerate arm64-neon-simd-ldst-one.ll test checks
Simon Pilgrim [Sat, 16 Jul 2022 14:26:51 +0000 (15:26 +0100)]
[AArch64] Regenerate arm64-neon-simd-ldst-one.ll test checks

2 years ago[AArch64] Regenerate arm64-vmax.ll test checks
Simon Pilgrim [Sat, 16 Jul 2022 14:25:43 +0000 (15:25 +0100)]
[AArch64] Regenerate arm64-vmax.ll test checks

2 years ago[AArch64] Regenerate arm64-mul.ll test checks
Simon Pilgrim [Sat, 16 Jul 2022 14:24:53 +0000 (15:24 +0100)]
[AArch64] Regenerate arm64-mul.ll test checks

2 years ago[mlir][NFC] Fully qualify typenames in SymbolInterfaces.td
Markus Böck [Sat, 16 Jul 2022 12:38:53 +0000 (14:38 +0200)]
[mlir][NFC] Fully qualify typenames in SymbolInterfaces.td

2 years ago[VectorCombine] Only consider shuffle uses with the same type.
David Green [Sat, 16 Jul 2022 12:23:39 +0000 (13:23 +0100)]
[VectorCombine] Only consider shuffle uses with the same type.

The backend getShuffleCosts do not currently handle shuffles that change
size very well. Limit the shuffles we collect to the same type to make
sure they do not cause issues as reported in D128732.

2 years agoFix signed/unsigned mismatch
Simon Pilgrim [Sat, 16 Jul 2022 10:48:41 +0000 (11:48 +0100)]
Fix signed/unsigned mismatch

2 years ago[DAG] Canonicalize non-inlane shuffle -> AND if all non-inlane referenced elements...
Simon Pilgrim [Sat, 16 Jul 2022 10:38:19 +0000 (11:38 +0100)]
[DAG] Canonicalize non-inlane shuffle -> AND if all non-inlane referenced elements are known zero

As mentioned on D127115, this patch that attempts to recognise shuffle masks that could be simplified to a AND mask - we already have a similar transform that will fold AND -> 'clear mask' shuffle, but this patch handles cases where the referenced elements are not from the same lane indices but are known to be zero.

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

2 years ago[MC] Avoid UAF in WinCOFFObjectWriter with weak symbols.
Tim Besard [Sat, 16 Jul 2022 07:48:30 +0000 (10:48 +0300)]
[MC] Avoid UAF in WinCOFFObjectWriter with weak symbols.

When using weak symbols, the WinCOFFObjectWriter keeps a list (`WeakDefaults`)
that's used to make names unique. This list should be reset when the object
writer is reset, because otherwise reuse of the object writer can result in
freed symbols being accessed. With some added output, this becomes clear when
using `llc` in `--run-twice` mode:

```
$ ./llc --compile-twice -mtriple=x86_64-pc-win32 trivial.ll -filetype=obj

DefineSymbol::WeakDefaults
 - .weak.foo.default
 - .weak.bar.default

DefineSymbol::WeakDefaults
 - .weak.foo.default
 - áÑJij⌂  p§┼Ø┐☺
 - .debug_macinfo.dw
 - .weak.bar.default
```

This does not seem to leak into the output object file though, so I couldn't
come up with a test. I added one that just does `--run-twice` (and verified
that it does access freed memory), which should result in detecting the
invalid memory accesses when running under ASAN.

Observed in a Julia PR where we started using weak symbols:
https://github.com/JuliaLang/julia/pull/45649

Reviewed By: mstorsjo

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

2 years ago[DAG] combineShiftAnd1ToBitTest - match "and (srl (not X), C)), 1 --> (and X, 1<...
Simon Pilgrim [Sat, 16 Jul 2022 10:00:02 +0000 (11:00 +0100)]
[DAG] combineShiftAnd1ToBitTest - match "and (srl (not X), C)), 1 --> (and X, 1<<C) == 0" patterns

combineShiftAnd1ToBitTest already matches "and (not (srl X, C)), 1 --> (and X, 1<<C) == 0" patterns, but we can end up with situations where the not is before the shift.

Part of some yak shaving for D127115 to generalise the "xor (X >> ShiftC), XorC --> (not X) >> ShiftC" fold.

2 years ago[mlir][LLVM] Add OpBuilder for opaque pointer GEPs without struct indices
Markus Böck [Sat, 16 Jul 2022 08:55:49 +0000 (10:55 +0200)]
[mlir][LLVM] Add OpBuilder for opaque pointer GEPs without struct indices

An OpBuilder already exists for GEPs that does not have any struct indices for existing typed pointers, but no such builder exists for GEPs utilizing opaque pointers that has an explicit `basePtrType`.

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

2 years ago[LegacyPM] Remove ControlHeightReductionLegacyPass
Fangrui Song [Sat, 16 Jul 2022 08:35:56 +0000 (01:35 -0700)]
[LegacyPM] Remove ControlHeightReductionLegacyPass

This pass tries to reduce the number of conditional branches in the hot path
based on profile. It's mostly a no-op after legacy PGO passes are moved.

2 years ago[LegacyPM] Remove createInstrProfilingLegacyPass
Fangrui Song [Sat, 16 Jul 2022 08:26:40 +0000 (01:26 -0700)]
[LegacyPM] Remove createInstrProfilingLegacyPass

Follow the steps of removing non-core instrumentation passes like PGO.

2 years ago[test] Migrate PGO related -instrprof tests to new PM
Fangrui Song [Sat, 16 Jul 2022 08:21:11 +0000 (01:21 -0700)]
[test] Migrate PGO related -instrprof tests to new PM

2 years ago[test] Migrate FunctionImport/cg_profile.ll to new PM
Fangrui Song [Sat, 16 Jul 2022 08:10:39 +0000 (01:10 -0700)]
[test] Migrate FunctionImport/cg_profile.ll to new PM

2 years ago[test] Migrate legacy InstrProfiling tests to new PM
Fangrui Song [Sat, 16 Jul 2022 08:10:08 +0000 (01:10 -0700)]
[test] Migrate legacy InstrProfiling tests to new PM

2 years ago[flang] Use value_or (NFC)
Kazu Hirata [Sat, 16 Jul 2022 07:51:54 +0000 (00:51 -0700)]
[flang] Use value_or (NFC)

2 years ago[LegacyPM] Remove CGProfileLegacyPass
Fangrui Song [Sat, 16 Jul 2022 07:39:55 +0000 (00:39 -0700)]
[LegacyPM] Remove CGProfileLegacyPass

It's mostly a no-op after I removed legacy PGO passes in D123834.

2 years ago[SDAG] Add test for DAGCombiner multiple result commutative CSE
Itay Bookstein [Fri, 15 Jul 2022 20:30:57 +0000 (23:30 +0300)]
[SDAG] Add test for DAGCombiner multiple result commutative CSE

This commit adds a test for DAGCombiner commutative CSE on
nodes with multiple results (UMUL_LOHI). In this commit it
asserts the lack of CSE, a later commit will demonstrate
the CSE in the changed assertions.

Signed-off-by: Itay Bookstein <ibookstein@gmail.com>
Reviewed By: barannikov88

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

2 years ago[mli][sparse] Remove manual dense dealloc from test case
Matthias Springer [Fri, 15 Jul 2022 06:17:50 +0000 (08:17 +0200)]
[mli][sparse] Remove manual dense dealloc from test case

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

2 years ago[MLIR] Clean up checks for alloc-like ops in analysis
Uday Bondhugula [Sat, 16 Jul 2022 07:21:55 +0000 (12:51 +0530)]
[MLIR] Clean up checks for alloc-like ops in analysis

Clean up checks for alloc-like ops in analysis. Use the analysis
utility to properly check for the desired kind of effects. The previous
locality utility worked for all practical purposes but wasn't sound and
was locally duplicate code. Instead, use mlir::hasSingleEffect.

Reviewed By: rriddle

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

2 years ago[flang] Use *X instead of X.getValue() (NFC)
Kazu Hirata [Sat, 16 Jul 2022 07:24:02 +0000 (00:24 -0700)]
[flang] Use *X instead of X.getValue() (NFC)

Per Flang C++ Style Guide, this patch replaces X.getValue() with *X
where *X is protected by a presence test.

2 years ago[MLIR] NFC. Clean up logic of hasSingleEffect
Uday Bondhugula [Sat, 16 Jul 2022 07:09:24 +0000 (12:39 +0530)]
[MLIR] NFC. Clean up logic of hasSingleEffect

Clean up conditional logic of hasSingleEffect. NFC.

Reviewed By: rriddle

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

2 years agoUse drop_begin (NFC)
Kazu Hirata [Sat, 16 Jul 2022 06:58:11 +0000 (23:58 -0700)]
Use drop_begin (NFC)

2 years ago[flang][OpenMP] Fix warning due to uninitialized pointer dereference during atomic...
Nimish Mishra [Sat, 16 Jul 2022 07:20:19 +0000 (12:50 +0530)]
[flang][OpenMP] Fix warning due to uninitialized pointer dereference during atomic update lowering

Reviewed By: kiranchandramohan, kazu

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

2 years agoExample:
Stella Laurenzo [Sat, 16 Jul 2022 04:03:04 +0000 (21:03 -0700)]
Example:

```
// -----// IR Dump Before LowerLinalgMicrokernels (iree-vmvx-lower-linalg-microkernels) //----- //
```

I've been meaning to suggest this for a long time, and I think the only reason we don't have it is because we didn't used to have the `getArgument()` handy when printing these comments. When debugging or putting a pipeline together based on such dumps, I often find myself grepping for the argument name of the pass (which is often related but not universally).

2 years agoUse drop_begin (NFC)
Kazu Hirata [Sat, 16 Jul 2022 06:24:59 +0000 (23:24 -0700)]
Use drop_begin (NFC)

2 years ago[MLIR][Liveness] Add `currentlyLiveValues`, a way to get a set of values that are...
bzcheeseman [Sun, 10 Jul 2022 15:27:45 +0000 (08:27 -0700)]
[MLIR][Liveness] Add `currentlyLiveValues`, a way to get a set of values that are live as of a given operation.

This change allows the user of LivenessBlockInfo to specify an op within the block and get a set of all values that are live as of that op. Semantically it relies on having a dominance-based region that has ordered operations. For DFG regions, computing liveness statically this way doesn't really make sense, it likely needs to be done at runtime.

Reviewed By: rriddle

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

2 years ago[sanitizer_common] Several Solaris procmaps fixes
Rainer Orth [Sat, 16 Jul 2022 04:59:00 +0000 (06:59 +0200)]
[sanitizer_common] Several Solaris procmaps fixes

Since the introduction of GoogleTest sharding in D122251
<https://reviews.llvm.org/D122251>, some of the Solaris sanitizer tests
have been running extremly long (up to an hour) while they took mere
seconds before.  Initial investigation suggests that massive lock
contention in Solaris procfs is involved here.

However, there's an easy way to somewhat reduce the impact: while the
current `ReadProcMaps` uses `ReadFileToBuffer` to read `/proc/self/xmap`,
that function primarily caters to Linux procfs reporting file sizes of 0
while the size on Solaris is accurate.  This patch makes use of that,
reducing the number of syscalls involved and reducing the runtime of
affected tests by a factor of 4.

Besides, it handles shared mappings and doesn't call `readlink` for unnamed
map entries.

Tested on `sparcv9-sun-solaris2.11` and `amd64-pc-solaris2.11`.

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

2 years ago[lld-macho][nfc] Add more tests + comments around ICF + unwind info interaction
Jez Ng [Sat, 16 Jul 2022 03:38:48 +0000 (23:38 -0400)]
[lld-macho][nfc] Add more tests + comments around ICF + unwind info interaction

While working on {D129830}, I realized that our handling of ICF +
eh_frame combined was untested. Additionally I realized that the comment
explaining why we were safely slicing away the functionAddress reloc
from our compact unwind entries was... insufficient and slightly
misleading. I've tried to clarify it.

Reviewed By: #lld-macho, thevinster

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

2 years agoUse has_value/value instead of hasValue/getValue (NFC)
Kazu Hirata [Sat, 16 Jul 2022 04:48:17 +0000 (21:48 -0700)]
Use has_value/value instead of hasValue/getValue (NFC)

2 years ago[BOLT][TEST] Add icp-inline.s test
Amir Ayupov [Sat, 16 Jul 2022 03:41:03 +0000 (20:41 -0700)]
[BOLT][TEST] Add icp-inline.s test

Add a test for `-icp-inline` knob, which ensures that ICP is only performed for
functions that can be subsequently inlined.

Reviewed By: rafauler

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

2 years agoUse value instead of getValue (NFC)
Kazu Hirata [Sat, 16 Jul 2022 03:03:13 +0000 (20:03 -0700)]
Use value instead of getValue (NFC)

2 years agoUse value_or (NFC)
Kazu Hirata [Sat, 16 Jul 2022 02:46:29 +0000 (19:46 -0700)]
Use value_or (NFC)

2 years ago[LegacyPM] Remove ModuleSanitizerCoverageLegacyPass
Fangrui Song [Sat, 16 Jul 2022 02:01:20 +0000 (19:01 -0700)]
[LegacyPM] Remove ModuleSanitizerCoverageLegacyPass

Follow the steps of various other legacy instrumentation passes removed for
15.0.0.

2 years ago[mlir] remove unnecessary statements in test
Ashay Rane [Sat, 16 Jul 2022 00:53:06 +0000 (17:53 -0700)]
[mlir] remove unnecessary statements in test

A previous commit (f2b94bd) added some unnecessary statements that
dereferenced operations only to get the operations back.  This patch
removes the unnecessary statements.

Reviewed By: rriddle

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

2 years ago[X86][FP16] Enable vector support for FP16 emulation
Phoebe Wang [Sat, 16 Jul 2022 01:00:54 +0000 (09:00 +0800)]
[X86][FP16] Enable vector support for FP16 emulation

This is follow up of D107082, which enable vector support according to psABI.

Reviewed By: skan

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

2 years ago[lit][unit] add a test for sanitizer-only test failures
Yuanfang Chen [Sat, 16 Jul 2022 01:21:35 +0000 (18:21 -0700)]
[lit][unit] add a test for sanitizer-only test failures

Follow-up for 6b02c53936b9e77fee.

2 years ago[mlir][ods] Allow specifying return types of builders
Jeff Niu [Thu, 14 Jul 2022 17:31:38 +0000 (10:31 -0700)]
[mlir][ods] Allow specifying return types of builders

This patch allows custom attribute and type builders to return
something other than the C++ type of the attribute or type.

This is useful for attributes or types that may perform extra work during
construction (e.g. canonicalization) that could result in a different
kind of attribute or type being returned.

Reviewed By: rriddle, lattner

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

2 years ago[clang-format][NFC] Replace SmallVector parameter with ArrayRef
owenca [Sat, 16 Jul 2022 00:25:58 +0000 (17:25 -0700)]
[clang-format][NFC] Replace SmallVector parameter with ArrayRef

Addresses https://reviews.llvm.org/D129466#3654410.

2 years ago[gn build] Port 4162aefad125
LLVM GN Syncbot [Sat, 16 Jul 2022 00:15:08 +0000 (00:15 +0000)]
[gn build] Port 4162aefad125

2 years agoRevert "Re-apply 5acd47169884, Add a shared-memory based orc::MemoryMapper, with...
Mitch Phillips [Sat, 16 Jul 2022 00:11:55 +0000 (17:11 -0700)]
Revert "Re-apply 5acd47169884, Add a shared-memory based orc::MemoryMapper, with fixes."

This reverts commit 32d8d23cd0b2d4d010eb112dfe5216f11b2681f9.

Reason: Broke the UBSan buildbots. See more details on Phabricator:
https://reviews.llvm.org/D128544

2 years ago[test] Fix old memory leak in a test
Vitaly Buka [Fri, 15 Jul 2022 23:55:13 +0000 (16:55 -0700)]
[test] Fix old memory leak in a test

2 years ago[lit][test] explicitly use utf-8 encoding to write testing json file
Yuanfang Chen [Fri, 15 Jul 2022 23:40:43 +0000 (16:40 -0700)]
[lit][test] explicitly use utf-8 encoding to write testing json file

Related test failure:
https://lab.llvm.org/buildbot/#/builders/178/builds/2527/steps/13/logs/FAIL__lit___googletest-timeout_py

2 years ago[Sanitizer][Darwin][NFC] Small SANITIZER_APPLE cleanup
Julian Lettner [Fri, 15 Jul 2022 23:12:31 +0000 (16:12 -0700)]
[Sanitizer][Darwin][NFC] Small SANITIZER_APPLE cleanup

We introduced `SANITIZER_APPLE` here: https://reviews.llvm.org/D126263

2 years ago[unittests/Tooling/DependencyScannerTest.cpp] Use `using namespace` instead of wrappi...
Argyrios Kyrtzidis [Fri, 15 Jul 2022 23:08:48 +0000 (16:08 -0700)]
[unittests/Tooling/DependencyScannerTest.cpp] Use `using namespace` instead of wrapping the `.cpp` file contents in namespaces, NFC

This makes the file consistent with the coding style of the rest of LLVM.

2 years ago[flang] Add semantics test for EVENT POST statement
Naje George [Mon, 11 Jul 2022 20:17:04 +0000 (13:17 -0700)]
[flang] Add semantics test for EVENT POST statement

Reviewed By: ktras

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

2 years ago[mlir][Linalg] Add a pattern to decompose `linalg.generic` ops.
Mahesh Ravishankar [Wed, 13 Jul 2022 23:22:47 +0000 (23:22 +0000)]
[mlir][Linalg] Add a pattern to decompose `linalg.generic` ops.

This patch adds a pattern to decompose a `linalg.generic` operations
that
- has only parallel iterator types
- has more than 2 statements (including the yield)

into multiple `linalg.generic` operation such that each operation has
a single statement and a yield.
The pattern added here just splits the matching `linalg.generic` into
two `linalg.generic`s, one containing the first statement, and the
other containing the remaining. The same pattern can be applied
repeatedly on the second op to ultimately fully decompose the generic
op.

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

2 years ago[nfc][amdgpu] Remove dead variable and function
Jon Chesterfield [Fri, 15 Jul 2022 22:55:42 +0000 (23:55 +0100)]
[nfc][amdgpu] Remove dead variable and function

2 years ago[lit][unit] make sure to include failed shard in test summary report
Yuanfang Chen [Fri, 15 Jul 2022 22:33:57 +0000 (15:33 -0700)]
[lit][unit] make sure to include failed shard in test summary report

For sanitizer only failures, the tests all pass but still need to
put the shard in failed test summary.

2 years ago[PGO] Report number of counts being dropped when a hash-mismatch happens
Rong Xu [Fri, 15 Jul 2022 21:51:49 +0000 (14:51 -0700)]
[PGO] Report number of counts being dropped when a hash-mismatch happens

This patch reports number of counts being dropped when a hash-mismatch
happens. This information will be helpful to the users -- if the dropped
counts are large, the user should redo the instrumentation build and
recollect the profile.

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

2 years ago[mlir] check whether region and block visitors are interrupted
Ashay Rane [Thu, 14 Jul 2022 01:20:56 +0000 (18:20 -0700)]
[mlir] check whether region and block visitors are interrupted

The visitor functions for `Region` and `Block` types did not always
check the value returned by recursive calls.  This caused the top-level
visitor invocation to return `WalkResult::advance()` even if one or more
recursive invocations returned `WalkResult::interrupt()`.  This patch
fixes the problem by check if any recursive call is interrupted, and if
so, return `WalkResult::interrupt()`.

Reviewed By: dcaballe

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

2 years ago[CUDA] Make the new driver properly ignore non-CUDA inputs
Joseph Huber [Fri, 15 Jul 2022 17:52:27 +0000 (13:52 -0400)]
[CUDA] Make the new driver properly ignore non-CUDA inputs

The new driver generated offloadinga actions for each active toolchain.
However, for CUDA and HIP it is possible for the toolchain to be active
but one of the files is not a valid input. This can occur if the user
compiles both a CUDA and C source file in the same compiler invocation.
This patch adds some simple logic to quit if the input is not valid as
well.

Reviewed By: tra, MaskRay

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

2 years ago[lit] fix a bug in 4cd1c96d375aa
Yuanfang Chen [Fri, 15 Jul 2022 21:35:53 +0000 (14:35 -0700)]
[lit] fix a bug in 4cd1c96d375aa

Only report failure for tests that actually runs.

2 years ago[lsan][Darwin][nfc] Fix thread vector size
Leonard Grey [Fri, 15 Jul 2022 19:36:01 +0000 (15:36 -0400)]
[lsan][Darwin][nfc] Fix thread vector size

The reserve constructor was removed in 44f55509d75d8c67077810bb6d9f3bedaea05831
but this one was missed. As a result, we attempt to iterate through 1024 threads
each time, most of which are 0.

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

2 years ago[bolt] Include <atomic>
Fangrui Song [Fri, 15 Jul 2022 21:27:01 +0000 (14:27 -0700)]
[bolt] Include <atomic>

2 years ago[Libomptarget] Fix warnings on address space attributes
Joseph Huber [Fri, 15 Jul 2022 19:34:50 +0000 (15:34 -0400)]
[Libomptarget] Fix warnings on address space attributes

The device runtime uses the address space attribute to control the
placement of important constants on the GPU. The changes made in D126061
caused these to start emitting errors as they were not applied to the
type. This patch fixes the issues to make the warnings go away.

Reviewed By: ye-luo

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

2 years ago[PGO] Don't cross reference CSFDO profile and non-CSFDO profile
Rong Xu [Fri, 15 Jul 2022 20:57:23 +0000 (13:57 -0700)]
[PGO] Don't cross reference CSFDO profile and non-CSFDO profile

Don't cross reference CSFDO profile and non-CSFDO profile when
checking the function hash. Only return hash_mismatch when
CS bits match, and return unknown_function otherwise.

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

2 years ago[PGO] Improve hash-mismatch warning message
Rong Xu [Fri, 15 Jul 2022 20:44:55 +0000 (13:44 -0700)]
[PGO] Improve hash-mismatch warning message

This patch improves FDO hash-mismatch handling:
(1) filter out warnings to weak functions.
Weak functions definition will be overridden by a strong definition by linker.
The hash mismatch in profile use compilation is expected.
Make the profile hash mismatch warning under the existing option (default true).

(2) add an option to trace the hash of functions with the specific string.
Note that an empty string parameter will trace all functions.

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

2 years ago[mlir][sparse] Introduce new reduce op
Jim Kitchen [Fri, 15 Jul 2022 20:26:41 +0000 (15:26 -0500)]
[mlir][sparse] Introduce new reduce op

A new sparse_tensor operation allows for
custom reduction code to be injected during
linalg.generic lowering for sparse tensors.
An identity value is provided to indicate
the starting value of the reduction. A single
block region is required to contain the
custom reduce computation.

Reviewed by: aartbik

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

2 years ago[LSR] Allow already invariant operand for ICmpZero matching [try 2]
Philip Reames [Fri, 15 Jul 2022 20:23:10 +0000 (13:23 -0700)]
[LSR] Allow already invariant operand for ICmpZero matching [try 2]

Changes since initial commit:

* Wrapping a pointer in an SCEV unknown hides the base, and SCEV is only able to compute a subtraction when the bases are known to be equal. This results in a SCEVCouldNotCompute flowing forward and triggering asserts. Test case added in d767b392.
* isLoopInvariant returns true for instructions outside the loop, but not necessarily *above* the loop. Since this code is allowed to visit uses of an IV outside of a loop, we have to make sure the operands of the compare are both invariant and dominating the header. Test case added in 2aed3cdb.

Original commit message follows...

The ICmpZero matching is checking to see if the expression is loop invariant per SCEV and expandable. This allows expressions inside the loop which can be made loop invariant to be seamlessly expanded, but is overly conservative for expressions which already *are* loop invariant.

As a simple justification for why this is correct, consider a loop invariant urem as RHS vs an alternate function with that same urem wrapped inside a helper call. Why would it be legal to match the later, but not the former?

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

2 years ago[reland][lit][unit] makes sure to print stderr when no test failures are found
Yuanfang Chen [Fri, 15 Jul 2022 20:23:22 +0000 (13:23 -0700)]
[reland][lit][unit] makes sure to print stderr when no test failures are found

In some situations, like running tests with sanitizers, all test
passes but the shard could still fail due to memory issues.

Relands 65769429c0644c81d271e9d971f5b64191503

2 years agoRevert "[lit][unit] makes sure to print stderr when no test failures are found"
Yuanfang Chen [Fri, 15 Jul 2022 20:21:01 +0000 (13:21 -0700)]
Revert "[lit][unit] makes sure to print stderr when no test failures are found"

This reverts commit 65769429c0644c81d271e9d971f5b64191503f6e.

This patch is incomplete.

2 years ago[lldb] [llgs] Improve stdio forwarding in multiprocess+nonstop
Michał Górny [Thu, 30 Jun 2022 18:24:04 +0000 (20:24 +0200)]
[lldb] [llgs] Improve stdio forwarding in multiprocess+nonstop

Enable stdio forwarding when nonstop mode is enabled, and disable it
once it is disabled.  This makes it possible to cleanly handle stdio
forwarding while running multiple processes in non-stop mode.

Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.llvm.org/D128932

2 years ago[lldb] [test] Skip test_leave_nonstop on Windows
Michał Górny [Fri, 15 Jul 2022 19:47:37 +0000 (21:47 +0200)]
[lldb] [test] Skip test_leave_nonstop on Windows

2 years ago[mlir][Linalg] Extend Generic op dedup canonicalization to drop redundant result...
Mahesh Ravishankar [Fri, 15 Jul 2022 04:29:08 +0000 (04:29 +0000)]
[mlir][Linalg] Extend Generic op dedup canonicalization to drop redundant result values.

2 years ago[mlir][Linalg] NFC: Refactor canonicalization for deduping generic op operands.
Mahesh Ravishankar [Fri, 15 Jul 2022 03:56:48 +0000 (03:56 +0000)]
[mlir][Linalg] NFC: Refactor canonicalization for deduping generic op operands.

This is a NFC change to make it easier to update this canonicalization
for more use cases. The refactoring makes things easier to
understand/adapt.

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

2 years ago[lsan][nfc] Add missing newline to VReport
Leonard Grey [Fri, 15 Jul 2022 19:44:23 +0000 (15:44 -0400)]
[lsan][nfc] Add missing newline to VReport

2 years ago[Flang] Set constructExit for Where and Forall constructs
Jonathon Penix [Fri, 15 Jul 2022 19:32:36 +0000 (12:32 -0700)]
[Flang] Set constructExit for Where and Forall constructs

Evaluations for the Where and Forall constructs previously did
not have their constructExit field fixed up. This could lead to
falling through to subsequent case blocks in select case
statements if either a Where or Forall construct was the final part
of one case block. Setting the constructExit field results in the
proper branching behavior.

Fixes issue: https://github.com/llvm/llvm-project/issues/56500

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

Change-Id: Ia868df12084520a935f087524e118bcdf47f6d7a

2 years ago[lit][unit] makes sure to print stderr when no test failures are found
Yuanfang Chen [Fri, 15 Jul 2022 19:16:18 +0000 (12:16 -0700)]
[lit][unit] makes sure to print stderr when no test failures are found

In some situations, like running tests with sanitizers, all test passes
but the shard could still fail due to memory issues.

2 years ago[lld-macho][nfc] Fix numeric substitutions in icf.s test
Jez Ng [Fri, 15 Jul 2022 19:28:14 +0000 (15:28 -0400)]
[lld-macho][nfc] Fix numeric substitutions in icf.s test

We were re-defining the various numeric variables when we actually
intended to check already-defined variables against the value on the
current CHECK line.

Reviewed By: #lld-macho, thakis

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

2 years ago[test] Reduced test for second distinct issue triggering revert of 9153515
Philip Reames [Fri, 15 Jul 2022 19:08:24 +0000 (12:08 -0700)]
[test] Reduced test for second distinct issue triggering revert of 9153515

2 years ago[mlir][sparse] Add 3-dimensional sparse tensor multiplication integration test
Rajas Vanjape [Fri, 15 Jul 2022 18:09:17 +0000 (11:09 -0700)]
[mlir][sparse] Add 3-dimensional sparse tensor multiplication integration test

This diff adds an integration test which does element wise multiplication for two sparse 3-d tensors of size 3x3x5

Reviewed By: aartbik

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

2 years ago[syntax] Some #includes cleanup, NFC.
Haojian Wu [Fri, 15 Jul 2022 18:49:12 +0000 (20:49 +0200)]
[syntax] Some #includes cleanup, NFC.

2 years ago[llvm-cov] Add error message for missing profdata on report and export subcommands.
Zequan Wu [Thu, 14 Jul 2022 18:29:10 +0000 (11:29 -0700)]
[llvm-cov] Add error message for missing profdata on report and export subcommands.

When profdata is missing on report and export commands, the error message is
indistinguishable from missing instrumented binary file. This adds the error
message for report and export commands.

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

2 years ago[Reassociate] Enable FP reassociation via 'reassoc' and 'nsz'
Warren Ristow [Fri, 15 Jul 2022 18:44:35 +0000 (11:44 -0700)]
[Reassociate] Enable FP reassociation via 'reassoc' and 'nsz'

Compiling with '-ffast-math' tuns on all the FastMathFlags (FMF), as
expected, and that enables FP reassociation. Only the two FMF flags
'reassoc' and 'nsz' are technically required to perform reassociation,
but disabling other unrelated FMF bits is needlessly suppressing the
optimization.

This patch fixes that needless suppression, and makes appropriate
adjustments to test-cases, fixing some outstanding TODOs in the process.

Fixes: #56483

Reviewed By: spatel

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

2 years ago[test] Reduced test which triggered revert of 9153515
Philip Reames [Fri, 15 Jul 2022 18:31:29 +0000 (11:31 -0700)]
[test] Reduced test which triggered revert of 9153515

2 years ago[lldb] [llgs] Fix disabling non-stop mode
Michał Górny [Thu, 30 Jun 2022 08:47:15 +0000 (10:47 +0200)]
[lldb] [llgs] Fix disabling non-stop mode

Stop all processes and clear notification queues when disabling non-stop
mode.  Ensure that no stop notifications are sent for processes stopped
due to the mode switch.

Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.llvm.org/D128893

2 years ago[lldb] [test] Skip test_stop_reason_while_running on Windows
Michał Górny [Fri, 15 Jul 2022 18:14:26 +0000 (20:14 +0200)]
[lldb] [test] Skip test_stop_reason_while_running on Windows

2 years ago[libc] add rounding modes to printf float conv
Michael Jones [Wed, 13 Jul 2022 18:47:03 +0000 (11:47 -0700)]
[libc] add rounding modes to printf float conv

This adds functionality for rounding towards negative inf, positive inf,
and zero to the float hex conversion (%a).

Reviewed By: lntue

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

2 years ago[AMDGPU] Add remarks to output some resource usage
Vang Thao [Fri, 11 Mar 2022 00:46:50 +0000 (00:46 +0000)]
[AMDGPU] Add remarks to output some resource usage

Add analyis remarks to output kernel name, register usage, occupancy,
scratch usage, spills, and LDS information.

Reviewed By: arsenm

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

2 years ago[mlir][linalg] Fix tensor tiling together with interchange
Lei Zhang [Fri, 15 Jul 2022 17:43:57 +0000 (13:43 -0400)]
[mlir][linalg] Fix tensor tiling together with interchange

In `linalg::tileConsumerAndFuseProducers`, there are two levels of
tiling and fusion; we partition the tile sizes and only use one
half for each of them. The partition is using the first non-parallel
dimension *after* interchange as the boundary. However, concrete
tiling happens *together with* loop interchange, so we still need
to provide the partial tile sizes *before* the interchange.
Otherwise, there will be inconsistency, which is what this patch
is to fix.

Reviewed By: ThomasRaoux

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

2 years agoRevert "[LSR] Allow already invariant operand for ICmpZero matching"
Philip Reames [Fri, 15 Jul 2022 17:47:32 +0000 (10:47 -0700)]
Revert "[LSR] Allow already invariant operand for ICmpZero matching"

This reverts commit 9153515a7bea9fb9dd4c76f70053a170bf825f35.  Builtbot crash was reported in the commit thread, reverting while investigating.

2 years ago[mlir] Enable perfect forwarding in RewritePatternSet::add
Laszlo Kindrat [Fri, 15 Jul 2022 17:43:41 +0000 (19:43 +0200)]
[mlir] Enable perfect forwarding in RewritePatternSet::add

This patch modifies the implementation of `RewritePatternSet::add` to perfectly forward its arguments to pattern constructors. Without this, code like the following compiles but, due to the limited lifetime of the temporary TypeConverter, can produce unexpected behavior:
```
RewritePatternSet patterns(context);
patterns.add<SomeOpConversion, OtherOpConversion>(TypeConverter(), context);

if (failed(applyPartialConversion(getOperation(), target, std::move(patterns))))
  return signalPassFailure();
```

The patch also changes the linalg fusion pattern implementation to correctly fill the test pattern set given the new behavior.

Author: Laszlo Kindrat <laszlokindrat@gmail.com>

Reviewed By: nicolasvasilache

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

2 years ago[sanitizer] Add "mainfile" prefix to sanitizer special case list
Fangrui Song [Fri, 15 Jul 2022 17:39:26 +0000 (10:39 -0700)]
[sanitizer] Add "mainfile" prefix to sanitizer special case list

When an issue exists in the main file (caller) instead of an included file
(callee), using a `src` pattern applying to the included file may be
inappropriate if it's the caller's responsibility. Add `mainfile` prefix to check
the main filename.

For the example below, the issue may reside in a.c (foo should not be called
with a misaligned pointer or foo should switch to an unaligned load), but with
`src` we can only apply to the innocent callee a.h. With this patch we can use
the more appropriate `mainfile:a.c`.
```
//--- a.h
// internal linkage
static inline int load(int *x) { return *x; }

//--- a.c, -fsanitize=alignment
#include "a.h"
int foo(void *x) { return load(x); }
```

See the updated clang/docs/SanitizerSpecialCaseList.rst for a caveat due
to C++ vague linkage functions.

Reviewed By: #sanitizers, kstoimenov, vitalybuka

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

2 years ago[LV] Use umax(VF * UF, MinProfTC) for scalable vectors.
Florian Hahn [Fri, 15 Jul 2022 17:07:39 +0000 (10:07 -0700)]
[LV] Use umax(VF * UF, MinProfTC) for scalable vectors.

For scalable vectors, it is not sufficient to only check
MinProfitableTripCount if it is >= VF.getKnownMinValue() * UF, because
this property may not holder for larger values of vscale. In those
cases, compute umax(VF * UF, MinProfTC) instead.

This should fix
https://lab.llvm.org/buildbot/#/builders/197/builds/2262

2 years ago[Libomptarget][NFC] Fix signed comparison warnings
Joseph Huber [Fri, 15 Jul 2022 17:22:00 +0000 (13:22 -0400)]
[Libomptarget][NFC] Fix signed comparison warnings

Summary:
Non-functional change, just fixing some sign comparison warnings by
making both match.