platform/upstream/llvm.git
3 years ago[clang-cl] Remove the /fallback option
Hans Wennborg [Tue, 2 Feb 2021 13:10:26 +0000 (14:10 +0100)]
[clang-cl] Remove the /fallback option

As discussed in
https://lists.llvm.org/pipermail/cfe-dev/2021-January/067524.html

It doesn't appear to be used, isn't really maintained, and adds some
complexity to the code. Let's remove it.

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

3 years ago[clang][cli] Command line round-trip for HeaderSearch options
Jan Svoboda [Thu, 4 Feb 2021 08:49:59 +0000 (09:49 +0100)]
[clang][cli] Command line round-trip for HeaderSearch options

This patch implements generation of remaining header search arguments.
It's done manually in C++ as opposed to TableGen, because we need the flexibility and don't anticipate reuse.

This patch also tests the generation of header search options via a round-trip. This way, the code gets exercised whenever Clang is built and tested in asserts mode. All `check-clang` tests pass.

Reviewed By: dexonsmith

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

3 years ago[Support] Indent multi-line descr of enum cli options.
Joachim Meyer [Thu, 17 Dec 2020 22:58:13 +0000 (23:58 +0100)]
[Support] Indent multi-line descr of enum cli options.

As noted in https://reviews.llvm.org/D93459, the formatting of
multi-line descriptions of clEnumValN and the likes is unfavorable.
Thus this patch adds support for correctly indenting these.

Reviewed By: serge-sans-paille

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

3 years ago[AMDGPU] Save all lanes for reserved VGPRs
Sebastian Neubauer [Thu, 4 Feb 2021 08:56:36 +0000 (09:56 +0100)]
[AMDGPU] Save all lanes for reserved VGPRs

When SGPRs are spilled to VGPRs, they can overwrite any lane. We need
to preserve the value of inactive lanes in function calls, so we save
the register even if it is marked as caller saved.

Also, teach buildPrologSpill to work when no registers are free like in
CodeGen/AMDGPU/pei-scavenge-vgpr-spill.mir and update the comment on
findScratchNonCalleeSaveRegister as it is not used anymore to realign
the stack pointer since D95865.

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

3 years ago[clangd] Detect rename conflicits within enclosing scope
Kirill Bobyrev [Thu, 4 Feb 2021 08:45:36 +0000 (09:45 +0100)]
[clangd] Detect rename conflicits within enclosing scope

This patch allows detecting conflicts with variables defined in the current
CompoundStmt or If/While/For variable init statements.

Reviewed By: hokein

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

3 years ago[Syntax] Support condition for IfStmt.
Haojian Wu [Mon, 1 Feb 2021 12:45:42 +0000 (13:45 +0100)]
[Syntax] Support condition for IfStmt.

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

3 years ago[mlir][Linalg] Generalize the definition of a Linalg contraction.
Nicolas Vasilache [Thu, 4 Feb 2021 07:42:26 +0000 (07:42 +0000)]
[mlir][Linalg] Generalize the definition of a Linalg contraction.

This revision defines a Linalg contraction in general terms:

  1. Has 2 input and 1 output shapes.
  2. Has at least one reduction dimension.
  3. Has only projected permutation indexing maps.
  4. its body computes `u5(u1(c) + u2(u3(a) * u4(b)))` on some field
    (AddOpType, MulOpType), where u1, u2, u3, u4 and u5 represent scalar unary
    operations that may change the type (e.g. for mixed-precision).

As a consequence, when vectorization of such an op occurs, the only special
behavior is that the (unique) MulOpType is vectorized into a
`vector.contract`. All other ops are handled in a generic fashion.

 In the future, we may wish to allow more input arguments and elementwise and
 constant operations that do not involve the reduction dimension(s).

A test is added to demonstrate the proper vectorization of matmul_i8_i8_i32.

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

3 years agoGive this test a target triple.
Richard Smith [Thu, 4 Feb 2021 07:38:52 +0000 (23:38 -0800)]
Give this test a target triple.

3 years agoFix miscompile when performing template instantiation of non-dependent
Richard Smith [Thu, 4 Feb 2021 07:31:51 +0000 (23:31 -0800)]
Fix miscompile when performing template instantiation of non-dependent
doubly-nested implicit CXXConstructExprs.

Ensure that we transform the parameter initializer using
TransformInitializer rather than TransformExpr so that we properly strip
down and rebuild the initialization, including any necessary
CXXBindTemporaryExprs. Otherwise we can end up forgetting to destroy
temporary objects used to construct a constructor parameter.

3 years ago[mlir][Linalg] NFC - Extract a standalone LinalgInterfaces
Nicolas Vasilache [Wed, 3 Feb 2021 22:19:12 +0000 (22:19 +0000)]
[mlir][Linalg] NFC - Extract a standalone LinalgInterfaces

This separation improves the layering and paves the way for more interfaces coming up in the future.

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

3 years ago[hip][cuda] Enable extended lambda support on Windows.
Michael Liao [Fri, 11 Oct 2019 21:15:26 +0000 (17:15 -0400)]
[hip][cuda] Enable extended lambda support on Windows.

- On Windows, extended lambda has extra issues due to the numbering
  schemes are different between the host compilation (Microsoft C++ ABI)
  and the device compilation (Itanium C++ ABI. Additional device side
  lambda number is required per lambda for the host compilation to
  correctly mangle the device-side lambda name.
- A hybrid numbering context `MSHIPNumberingContext` is introduced to
  number a lambda for both host- and device-compilations.

Reviewed By: rnk

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

3 years ago[CSSPGO][llvm-profgen] Compress recursive cycles in calling context
wlei [Fri, 29 Jan 2021 23:00:08 +0000 (15:00 -0800)]
[CSSPGO][llvm-profgen] Compress recursive cycles in calling context

This change compresses the context string by removing cycles due to recursive function for CS profile generation. Removing recursion cycles is a way to normalize the calling context which will be better for the sample aggregation and also make the context promoting deterministic.
Specifically for implementation, we recognize adjacent repeated frames as cycles and deduplicated them through multiple round of iteration.
For example:
Considering a input context string stack:
[“a”, “a”, “b”, “c”, “a”, “b”, “c”, “b”, “c”, “d”]
For first iteration,, it removed all adjacent repeated frames of size 1:
[“a”, “b”, “c”, “a”, “b”, “c”, “b”, “c”, “d”]
For second iteration, it removed all adjacent repeated frames of size 2:
[“a”, “b”, “c”, “a”, “b”, “c”, “d”]
So in the end, we get compressed output:
[“a”, “b”, “c”, “d”]

Compression will be called in two place: one for sample's context key right after unwinding, one is for the eventual context string id in the ProfileGenerator.
Added a switch `compress-recursion` to control the size of duplicated frames, default -1 means no size limit.
Added unit tests and regression test for this.

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

3 years agoRevert "[CSSPGO][llvm-profgen] Compress recursive cycles in calling context"
wlei [Thu, 4 Feb 2021 05:17:21 +0000 (21:17 -0800)]
Revert "[CSSPGO][llvm-profgen] Compress recursive cycles in calling context"

This reverts commit 0609f257dc2e2c3e4c7cd30fe2ffd520117e706b.

3 years agoRevert "[CSSPGO][llvm-profgen] Aggregate samples on call frame trie to speed up profi...
wlei [Thu, 4 Feb 2021 05:16:49 +0000 (21:16 -0800)]
Revert "[CSSPGO][llvm-profgen] Aggregate samples on call frame trie to speed up profile generation"

This reverts commit 1714ad2336293f351b15dd4b518f9e8618ec38f2.

3 years ago[ASTReader] Always rebuild a cached module that has errors
Ben Barham [Thu, 4 Feb 2021 06:02:29 +0000 (22:02 -0800)]
[ASTReader] Always rebuild a cached module that has errors

A module in the cache with an error should just be a cache miss. If
allowing errors (with -fallow-pcm-with-compiler-errors), a rebuild is
needed so that the appropriate diagnostics are output and in case search
paths have changed. If not allowing errors, the module was built
*allowing* errors and thus should be rebuilt regardless.

Reviewed By: akyrtzi

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

3 years ago[NFC] Fix the noprofile attribute comment
Petr Hosek [Thu, 4 Feb 2021 05:54:09 +0000 (21:54 -0800)]
[NFC] Fix the noprofile attribute comment

3 years ago[lldb] Convert more assertTrue to assertEqual (NFC)
Dave Lee [Tue, 2 Feb 2021 22:46:37 +0000 (14:46 -0800)]
[lldb] Convert more assertTrue to assertEqual (NFC)

Follow up to D95813, this converts multiline assertTrue to assertEqual.

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

3 years ago[NFC][Coroutine] Remove redundant comment
Chuanqi Xu [Thu, 4 Feb 2021 04:51:20 +0000 (12:51 +0800)]
[NFC][Coroutine] Remove redundant comment

The functionallity in the TODO was added before:
https://reviews.llvm.org/rGb3a722e66b75328ab5e2eb5c8572022cb083855b

3 years ago[Transforms/IPO] Use range-based for loops (NFC)
Kazu Hirata [Thu, 4 Feb 2021 04:41:20 +0000 (20:41 -0800)]
[Transforms/IPO] Use range-based for loops (NFC)

3 years ago[TableGen] Use ListSeparator (NFC)
Kazu Hirata [Thu, 4 Feb 2021 04:41:18 +0000 (20:41 -0800)]
[TableGen] Use ListSeparator (NFC)

3 years ago[Support] Drop unnecessary const from return types (NFC)
Kazu Hirata [Thu, 4 Feb 2021 04:41:16 +0000 (20:41 -0800)]
[Support] Drop unnecessary const from return types (NFC)

Identified with const-return-type.

3 years agoFix the guaranteed alignment of memory returned by malloc/new on Darwin
Akira Hatanaka [Tue, 2 Feb 2021 21:17:29 +0000 (13:17 -0800)]
Fix the guaranteed alignment of memory returned by malloc/new on Darwin

The guaranteed alignment is 16 bytes on Darwin.

rdar://73431623

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

3 years ago[test] Pin spir-codegen.ll to legacy PM
Arthur Eubanks [Thu, 4 Feb 2021 03:37:32 +0000 (19:37 -0800)]
[test] Pin spir-codegen.ll to legacy PM

-polly-enable-delicm is not supported under the new PM but is tested here:
  Assertion `!EnableDeLICM && "This option is not implemented"' failed.

3 years ago[CSSPGO][llvm-profgen] Aggregate samples on call frame trie to speed up profile gener...
wlei [Mon, 11 Jan 2021 20:47:22 +0000 (12:47 -0800)]
[CSSPGO][llvm-profgen] Aggregate samples on call frame trie to speed up profile generation

For CS profile generation, the process of call stack unwinding is time-consuming since for each LBR entry we need linear time to generate the context( hash, compression, string concatenation). This change speeds up this by grouping all the call frame within one LBR sample into a trie and aggregating the result(sample counter) on it, deferring the context compression and string generation to the end of unwinding.

Specifically, it uses `StackLeaf` as the top frame on the stack and manipulates(pop or push a trie node) it dynamically during virtual unwinding so that the raw sample can just be recoded on the leaf node, the path(root to leaf) will represent its calling context. In the end, it traverses the trie and generates the context on the fly.

Results:
Our internal branch shows about 5X speed-up on some large workloads in SPEC06 benchmark.

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

3 years ago[CSSPGO][llvm-profgen] Compress recursive cycles in calling context
wlei [Fri, 29 Jan 2021 23:00:08 +0000 (15:00 -0800)]
[CSSPGO][llvm-profgen] Compress recursive cycles in calling context

This change compresses the context string by removing cycles due to recursive function for CS profile generation. Removing recursion cycles is a way to normalize the calling context which will be better for the sample aggregation and also make the context promoting deterministic.
Specifically for implementation, we recognize adjacent repeated frames as cycles and deduplicated them through multiple round of iteration.
For example:
Considering a input context string stack:
[“a”, “a”, “b”, “c”, “a”, “b”, “c”, “b”, “c”, “d”]
For first iteration,, it removed all adjacent repeated frames of size 1:
[“a”, “b”, “c”, “a”, “b”, “c”, “b”, “c”, “d”]
For second iteration, it removed all adjacent repeated frames of size 2:
[“a”, “b”, “c”, “a”, “b”, “c”, “d”]
So in the end, we get compressed output:
[“a”, “b”, “c”, “d”]

Compression will be called in two place: one for sample's context key right after unwinding, one is for the eventual context string id in the ProfileGenerator.
Added a switch `compress-recursion` to control the size of duplicated frames, default -1 means no size limit.
Added unit tests and regression test for this.

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

3 years ago[MLIR] Fix building unittests in in-tree build
Isuru Fernando [Thu, 4 Feb 2021 01:59:08 +0000 (01:59 +0000)]
[MLIR] Fix building unittests in in-tree build

Reviewed By: mehdi_amini

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

3 years agoMake the folder more robust against op fold() methods that generate a type mismatch
Mehdi Amini [Thu, 4 Feb 2021 01:53:59 +0000 (01:53 +0000)]
Make the folder more robust against op fold() methods that generate a type mismatch

We could extend this with an interface to allow dialect to perform a type
conversion, but that would make the folder creating operation which isn't
the case at the moment, and isn't necessarily always desirable.

Reviewed By: rriddle

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

3 years ago[OpenMP][NVPTX] Take functions in `deviceRTLs` as `convergent`
Shilei Tian [Thu, 4 Feb 2021 01:57:59 +0000 (20:57 -0500)]
[OpenMP][NVPTX] Take functions in `deviceRTLs` as `convergent`

OpenMP device compiler (similar to other SPMD compilers) assumes that
functions are convergent by default to avoid invalid transformations, such as
the bug (https://bugs.llvm.org/show_bug.cgi?id=49021).

Reviewed By: jdoerfert

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

3 years ago[OpenMPIRBuilder] Implement collapseLoops.
Michael Kruse [Wed, 3 Feb 2021 19:44:00 +0000 (13:44 -0600)]
[OpenMPIRBuilder] Implement collapseLoops.

The collapseLoops method implements a transformations facilitating the implementation of the collapse-clause. It takes a list of loops from a loop nest and reduces it to a single loop that can be used by other methods that are implemented on just a single loop, such as createStaticWorkshareLoop.

This patch shares some changes with D92974 (such as adding some getters to CanonicalLoopNest), used by both patches.

Reviewed By: jdoerfert

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

3 years ago[lldb] Rollback to using i386 for the watch simulator
Jonas Devlieghere [Thu, 4 Feb 2021 00:28:10 +0000 (16:28 -0800)]
[lldb] Rollback to using i386 for the watch simulator

I switched the watch simulator test from i386 to using x86_64, but
apparently that's not supported on the bots. Rollback to using i386 and
solve the original issue by passing the target, similar to what I did
in TestSimulatorPlatform.py.

3 years ago[CSSPGO][llvm-profgen] Pseudo probe based CS profile generation
wlei [Mon, 11 Jan 2021 17:08:39 +0000 (09:08 -0800)]
[CSSPGO][llvm-profgen] Pseudo probe based CS profile generation

This change implements profile generation infra for pseudo probe in llvm-profgen. During virtual unwinding, the raw profile is extracted into range counter and branch counter and aggregated to sample counter map indexed by the call stack context. This change introduces the last step and produces the eventual profile. Specifically, the body of function sample is recorded by going through each probe among the range and callsite target sample is recorded by extracting the callsite probe from branch's source.

Please refer https://groups.google.com/g/llvm-dev/c/1p1rdYbL93s and https://reviews.llvm.org/D89707 for more context about CSSPGO and llvm-profgen.

**Implementation**

- Extended `PseudoProbeProfileGenerator` for pseudo probe based profile generation.
- `populateBodySamplesWithProbes` reading range counter is responsible for recording function body samples and inferring caller's body samples.
- `populateBoundarySamplesWithProbes` reading branch counter is responsible for recording call site target samples.
- Each sample is recorded with its calling context(named `ContextId`). Remind that the probe based context key doesn't include the leaf frame probe info, so the `ContextId` string is created from two part: one from the probe stack strings' concatenation and other one from the leaf frame probe.
- Added regression test

Test Plan:

ninja & ninja check-llvm

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

3 years ago[AArch64][GlobalISel] Change store value type from p0 -> s64 to import patterns
Jessica Paquette [Tue, 2 Feb 2021 23:23:06 +0000 (15:23 -0800)]
[AArch64][GlobalISel] Change store value type from p0 -> s64 to import patterns

Similar to the G_PTR_ADD + G_LOAD twiddling we do in `preISelLower`.

The imported patterns expect scalars only, so they can't handle things like

```
 G_STORE %ptr1, %ptr2
```

To get around this, use s64 instead.

(This probably makes a good portion of the manual selection code for G_STORE
dead.)

This is a 0.2% geomean code size improvement on CTMark at -Os.

(Best is consumer-typeset @ -0.7%)

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

3 years agoRevert "[InstrProfiling] Use !associated metadata for counters, data and values"
Nico Weber [Thu, 4 Feb 2021 00:14:34 +0000 (19:14 -0500)]
Revert "[InstrProfiling] Use !associated metadata for counters, data and values"

This reverts commit 97ba5cde52664200819446c1a18de28faf2ed1c6.
Still breaks tests: https://reviews.llvm.org/D76802#2540647

3 years ago[AArch64][GlobalISel] Emit G_ASSERT_ZEXT in assignValueToAddress for ZExt params
Jessica Paquette [Fri, 29 Jan 2021 21:19:08 +0000 (13:19 -0800)]
[AArch64][GlobalISel] Emit G_ASSERT_ZEXT in assignValueToAddress for ZExt params

When we have a zeroext parameter coming in on the stack, build

```
%x = G_LOAD ...
%x_assert_zext = G_ASSERT_ZEXT %x, narrow_size
%trunc = G_TRUNC %x_assert_zext
```

Rather than just loading into the truncated type.

This allows us to optimize cases like this: https://godbolt.org/z/vfjhW8

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

3 years ago[libc++] [P0879] constexpr std::sort
Arthur O'Dwyer [Sun, 20 Dec 2020 20:21:42 +0000 (15:21 -0500)]
[libc++] [P0879] constexpr std::sort

This completes libc++'s implementation of
P0879 "Constexpr for swap and swap related functions."
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0879r0.html

For the feature-macro adjustment, see
https://cplusplus.github.io/LWG/issue3256

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

3 years ago[Docs] Add some documentation for constructor homing, a debug info optimization ...
Amy Huang [Tue, 2 Feb 2021 01:33:46 +0000 (17:33 -0800)]
[Docs] Add some documentation for constructor homing, a debug info optimization (-fuse-ctor-homing)

Adding this, since there's currently no documentation about this.

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

3 years ago[clang-tidy] Use new mapping matchers
Stephen Kelly [Sat, 2 Jan 2021 21:18:29 +0000 (21:18 +0000)]
[clang-tidy] Use new mapping matchers

Use mapAnyOf() and matchers based on it.

Use of binaryOperation() means that modernize-loop-convert and
readability-container-size-empty can now be used with rewritten binary
operators.

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

3 years agoPR44325 (and duplicates): don't issue -Wzero-as-null-pointer-constant
Richard Smith [Wed, 3 Feb 2021 22:57:19 +0000 (14:57 -0800)]
PR44325 (and duplicates): don't issue -Wzero-as-null-pointer-constant
when rewriting 'a < b' as '(a <=> b) < 0'.

It's pretty common for comparison category types to use a pointer or
pointer-to-member type as their '0' parameter.

3 years agoRevert "[LTO] Use lto::backend for code generation."
Florian Hahn [Wed, 3 Feb 2021 22:45:45 +0000 (22:45 +0000)]
Revert "[LTO] Use lto::backend for code generation."

This reverts commit 6a59f0560648b43324b5aed51b9ef996404a25e0, because
it is causing failures on green dragon.

3 years agoRevert "[LTO] Add option enable NewPM with LTOCodeGenerator."
Florian Hahn [Wed, 3 Feb 2021 22:45:42 +0000 (22:45 +0000)]
Revert "[LTO] Add option enable NewPM with LTOCodeGenerator."

This reverts commit 7a6a2cc81aaf064e6f5bc9a9a16973f552d2bdc2 because
it is causing failures on green dragon.

3 years agoRevert "[LTOCodeGenerator] Use lto::Config for options (NFC)."
Florian Hahn [Wed, 3 Feb 2021 22:45:31 +0000 (22:45 +0000)]
Revert "[LTOCodeGenerator] Use lto::Config for options (NFC)."

This reverts commit 0d487cf87aa1b609b7db061def3e5ad068576ecf because
it is causing failures on green dragon.

3 years agoTurn on the new pass manager by default
Arthur Eubanks [Mon, 25 Jan 2021 19:00:56 +0000 (11:00 -0800)]
Turn on the new pass manager by default

This turns on the new pass manager by default for the optimization pipeline in
Clang and ThinLTO in various LLD backends. This also makes uses of `opt
-instcombine` use the new pass manager (unless specifically opted out).

This does not affect the backend target-dependent codegen pipeline.

If this causes regressions, you can opt out of the new pass manager
either via the -DENABLE_EXPERIMENTAL_NEW_PASS_MANAGER=OFF CMake flag
while building LLVM, or via various compiler flags, e.g.
-flegacy-pass-manager for Clang or -Wl,--lto-legacy-pass-manager for
ELF LLD. Please file bugs for any regressions.

Major differences:
* The inliner works slightly differently
* -O1 does some amount of inlining
* LCSSA and LoopSimplify are run before all loop passes
* Loop unswitching is implemented slightly differently
* A new SpeculateAroundPHIs pass is added to the pipeline

https://lists.llvm.org/pipermail/llvm-dev/2021-January/148098.html

Reviewed By: asbirlea, ychen, MaskRay, echristo

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

3 years agoPR49020: Diagnose brace elision in designated initializers in C++.
Richard Smith [Wed, 3 Feb 2021 22:33:17 +0000 (14:33 -0800)]
PR49020: Diagnose brace elision in designated initializers in C++.

This is a corner of the differences between C99 designators and C++20
designators that we'd previously overlooked. As with other such cases,
this continues to be permitted as an extension and allowed by default,
behind the -Wc99-designators warning flag, except in cases where it
leads to a conformance difference (such as in overload resolution and in
a SFINAE context).

3 years ago[GlobalISel] Add sext(constant) -> constant artifact combine.
Amara Emerson [Sat, 30 Jan 2021 06:48:13 +0000 (22:48 -0800)]
[GlobalISel] Add sext(constant) -> constant artifact combine.

This is the G_SEXT counterpart to the existing G_ZEXT/G_ANYEXT combines.

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

3 years ago[lldb] Check for both Lua 5.3 and 5.4 error messages in the tests.
Jonas Devlieghere [Wed, 3 Feb 2021 21:45:54 +0000 (13:45 -0800)]
[lldb] Check for both Lua 5.3 and 5.4 error messages in the tests.

3 years ago[lldb] Honor the CPU type & subtype when launching on macOS
Jonas Devlieghere [Wed, 3 Feb 2021 07:25:27 +0000 (23:25 -0800)]
[lldb] Honor the CPU type & subtype when launching on macOS

Honor the CPU type (and subtype) when launching the inferior on macOS.

Part of this functionality was thought to be no longer needed and
removed in 85bd4369610fe60397455c8e0914a09288285e84, however it's still
needed, for example to launch binaries under Rosetta 2 on Apple Silicon.

This patch will use posix_spawnattr_setarchpref_np if available and
fallback to posix_spawnattr_setbinpref_np if not.

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

3 years ago[Coverage] Propogate counter to condition of conditional operator
Zequan Wu [Wed, 3 Feb 2021 04:43:13 +0000 (20:43 -0800)]
[Coverage] Propogate counter to condition of conditional operator

Clang usually propagates counter mapping region for conditions of `if`, `while`,
`for`, etc from parent counter. We should do the same for condition of conditional operator.

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

3 years ago[libc++] Rationalize our treatment of contiguous iterators and __unwrap_iter().
Arthur O'Dwyer [Fri, 15 Jan 2021 17:59:56 +0000 (12:59 -0500)]
[libc++] Rationalize our treatment of contiguous iterators and __unwrap_iter().

- Implement C++20's changes to `reverse_iterator`, so that it won't be
    accidentally counted as a contiguous iterator in C++20 mode.
- Implement C++20's changes to `move_iterator` as well.
- `move_iterator` should not be contiguous. This fixes a bug where
    we optimized `std::copy`-of-move-iterators in an observable way.
    Add a regression test for that bugfix.
- Add libcxx tests for `__is_cpp17_contiguous_iterator` of all relevant
    standard iterator types. Particularly check that vector::iterator
    is still considered contiguous in all C++ modes, even C++03.

After this patch, there continues to be no supported way to write your
own iterator type in C++17-and-earlier such that libc++ will consider it
"contiguous"; however, we now fully support the C++20 approach (in C++20
mode only). If you want user-defined contiguous iterators in C++17-and-earlier,
libc++'s position is "please upgrade to C++20."

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

3 years agoAdd API for adding arguments to blocks
George [Wed, 3 Feb 2021 20:34:29 +0000 (12:34 -0800)]
Add API for adding arguments to blocks

This just exposes a missing API

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

3 years ago[lld-macho] Try to fix Windows build
Jez Ng [Wed, 3 Feb 2021 21:04:36 +0000 (16:04 -0500)]
[lld-macho] Try to fix Windows build

3 years ago[NewPM][HelloWorld] Move HelloWorld to Utils
Arthur Eubanks [Wed, 3 Feb 2021 00:43:32 +0000 (16:43 -0800)]
[NewPM][HelloWorld] Move HelloWorld to Utils

To prevent creating a new component, which creates a new library.

Reviewed By: ychen

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

3 years ago[asan] Fix pthread_create interceptor
Vitaly Buka [Sat, 30 Jan 2021 08:19:48 +0000 (00:19 -0800)]
[asan] Fix pthread_create interceptor

AsanThread::Destroy implementation expected to be called on
child thread.

I missed authors concern regarding this reviewing D95184.

Reviewed By: delcypher

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

3 years agoFix overflowing signed left shift, found by ubsan buildbot.
Richard Smith [Wed, 3 Feb 2021 20:51:11 +0000 (12:51 -0800)]
Fix overflowing signed left shift, found by ubsan buildbot.

3 years ago[mlir] Add gpu async integration test.
Christian Sigg [Wed, 3 Feb 2021 19:10:51 +0000 (20:10 +0100)]
[mlir] Add gpu async integration test.

Reviewed By: herhut

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

3 years ago[Hexagon] Add LLVM instruction definitions for Hexagon V68
Krzysztof Parzyszek [Wed, 3 Feb 2021 16:25:44 +0000 (10:25 -0600)]
[Hexagon] Add LLVM instruction definitions for Hexagon V68

3 years ago[clang-tblgen] AnnotateAttr::printPretty has spurious comma when no variadic argument...
Félix Cloutier [Tue, 2 Feb 2021 22:20:20 +0000 (14:20 -0800)]
[clang-tblgen] AnnotateAttr::printPretty has spurious comma when no variadic argument is specified

rdar://73742471
Differential Revision: https://reviews.llvm.org/D95695

3 years ago[SampleFDO][NFC] Detach SampleProfileLoader from SampleCoverageTracker
Rong Xu [Wed, 3 Feb 2021 19:21:02 +0000 (11:21 -0800)]
[SampleFDO][NFC] Detach SampleProfileLoader from SampleCoverageTracker

This patch detaches SampleProfileLoader from class
SampleCoverageTracker. We plan to move SampleProfileLoader
to a template class. This would remain SampleCoverageTracker
as a class.
Also make callsiteIsHot() as a file static function.

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

3 years ago[NFC][CUDA] Refactor registering device variable
Yaxun (Sam) Liu [Tue, 26 Jan 2021 22:11:01 +0000 (17:11 -0500)]
[NFC][CUDA] Refactor registering device variable

Extract registering device variable to CUDA runtime codegen function since it
will be called in multiple places.

Reviewed by: Artem Belevich

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

3 years agoDelete CUDA context after linking device code.
Christian Sigg [Tue, 2 Feb 2021 09:48:12 +0000 (10:48 +0100)]
Delete CUDA context after linking device code.

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

3 years ago[GlobalISel] Combine narrowScalar of G_ADD and G_SUB. NFC
Justin Bogner [Wed, 3 Feb 2021 01:02:52 +0000 (17:02 -0800)]
[GlobalISel] Combine narrowScalar of G_ADD and G_SUB. NFC

These two cases have identical implementations other than an
unreachable part of `G_ADD` that checks if the scalar we're narrowing
is a vector. Combining them to avoid unnecessary divergence.

3 years agoSet GPU context before {cu,hip}MemHostRegister.
Christian Sigg [Tue, 2 Feb 2021 09:43:32 +0000 (10:43 +0100)]
Set GPU context before {cu,hip}MemHostRegister.

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

3 years agoRegisterCoalescer: Fix not setting undef on coalesced subregister uses
Matt Arsenault [Fri, 11 Dec 2020 16:04:37 +0000 (11:04 -0500)]
RegisterCoalescer: Fix not setting undef on coalesced subregister uses

This was only adding undef to the use if the copy itself had a
subregister index. It did not consider the subrange liveness if the
use had a subreg index to begin with.

3 years ago[flang] Fix calls to LBOUND() intrinsic for arrays with lower bounds not 1
Peter Steinfeld [Tue, 2 Feb 2021 22:15:50 +0000 (14:15 -0800)]
[flang] Fix calls to LBOUND() intrinsic for arrays with lower bounds not 1

Constant folding for calls to LBOUND() was not working when the lower bound of
a constant array was not 1.

I fixed this and re-enabled the test in Evaluate/folding16.f90 that previously
was silently failing.  I slightly changed the test to parenthesize the first
argument to exercise all of the new code.

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

3 years ago[dfsan] Wrap strcat
Jianzhou Zhao [Wed, 3 Feb 2021 05:28:42 +0000 (05:28 +0000)]
[dfsan] Wrap strcat

Reviewed-by: morehouse
Differential Revision: https://reviews.llvm.org/D95923

3 years ago[dfsan] Test IGN and DFL for sigaction
Jianzhou Zhao [Wed, 3 Feb 2021 17:23:32 +0000 (17:23 +0000)]
[dfsan] Test IGN and DFL for sigaction

Reviewed-by: morehouse
Differential Revision: https://reviews.llvm.org/D95957

3 years ago[libc][NFC] Move generic math implementations to the generic directory.
Siva Chandra [Wed, 3 Feb 2021 08:37:16 +0000 (00:37 -0800)]
[libc][NFC] Move generic math implementations to the generic directory.

This expands the pattern suggest in https://reviews.llvm.org/D95850 to all
math functions.

3 years ago[sanitizer_common] Use zx_system_get_page_size() on Fuchsia
Roland McGrath [Wed, 3 Feb 2021 04:59:45 +0000 (20:59 -0800)]
[sanitizer_common] Use zx_system_get_page_size() on Fuchsia

Fuchsia is migrating to a variable page size.

Reviewed By: phosek, charco

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

3 years ago[lld-macho] Rename VERSION CONTROL to VERSION TARGETING in helptext
Jez Ng [Wed, 3 Feb 2021 18:35:56 +0000 (13:35 -0500)]
[lld-macho] Rename VERSION CONTROL to VERSION TARGETING in helptext

Per https://reviews.llvm.org/D94938#inline-896740.

3 years ago[lld-macho] Remove stray ehFrame change
Jez Ng [Wed, 3 Feb 2021 18:33:30 +0000 (13:33 -0500)]
[lld-macho] Remove stray ehFrame change

Per https://reviews.llvm.org/D95121#inline-897943.

3 years ago[lld-macho] Force-loading should share code path with regular archive loads
Jez Ng [Wed, 3 Feb 2021 18:31:42 +0000 (13:31 -0500)]
[lld-macho] Force-loading should share code path with regular archive loads

This extends {D92539} to work even when we are loading archive
members via `-force_load`. I uncovered this issue while trying to
force-load archives containing bitcode -- we were segfaulting.

In addition to fixing the `-force_load` case, this diff also addresses
the behavior of `-ObjC` when LTO bitcode is involved -- we need to
force-load those archive members if they contain ObjC categories.

Reviewed By: #lld-macho, smeenai

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

3 years ago[lld-macho] Associate each Symbol with an InputFile
Jez Ng [Wed, 3 Feb 2021 18:31:40 +0000 (13:31 -0500)]
[lld-macho] Associate each Symbol with an InputFile

This makes our error messages more informative. But the bigger motivation is for
LTO symbol resolution, which will be in an upcoming diff. The changes in this
one are largely mechanical.

Reviewed By: #lld-macho, smeenai

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

3 years agoRegisterCoalescer: Prune undef subranges from copy pairs in loops
Matt Arsenault [Mon, 16 Nov 2020 21:23:26 +0000 (16:23 -0500)]
RegisterCoalescer: Prune undef subranges from copy pairs in loops

If we had a pair of copies inside a loop which introduced new liveness
to a subregister which was undef before the loop, we would have a
dummy phi-only segment remaining across the loop body. Later, this
false segment would confuse RenameIndependentSubregs causing it to
introduce IMPLICIT_DEFs with broken value numbering.

It seems always adding the lanes to ShrinkMask is OK, so any
conditions should be purely a compile time filter.

3 years ago[lldb] Fix debugserver-entitlements.plist path
Jonas Devlieghere [Wed, 3 Feb 2021 18:42:20 +0000 (10:42 -0800)]
[lldb] Fix debugserver-entitlements.plist path

3 years ago[gwp_asan] Use zx_system_get_page_size() on Fuchsia
Roland McGrath [Wed, 3 Feb 2021 18:31:45 +0000 (10:31 -0800)]
[gwp_asan] Use zx_system_get_page_size() on Fuchsia

Fuchsia is migrating to a variable page size.

Reviewed By: hctim

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

3 years ago[scudo/standalone] Use zx_system_get_page_size() on Fuchsia
Roland McGrath [Wed, 3 Feb 2021 04:55:52 +0000 (20:55 -0800)]
[scudo/standalone] Use zx_system_get_page_size() on Fuchsia

Fuchsia is migrating to a variable page size.

Reviewed By: hctim

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

3 years agoRevert "AMDGPU: Don't consider global pressure when bundling soft clauses"
Matt Arsenault [Wed, 3 Feb 2021 18:19:09 +0000 (13:19 -0500)]
Revert "AMDGPU: Don't consider global pressure when bundling soft clauses"

This reverts commit 1e377a273f59375d8e6a424f66f069b3adfa1ca4.

A regression was reported.

3 years ago[AMDGPU] Added -mcpu to couple more tests. NFC.
Stanislav Mekhanoshin [Wed, 3 Feb 2021 18:04:02 +0000 (10:04 -0800)]
[AMDGPU] Added -mcpu to couple more tests. NFC.

3 years ago[DAGCombiner] Remove (sra (shl X, C), C) if X has more than C sign bits.
Craig Topper [Wed, 3 Feb 2021 18:16:08 +0000 (10:16 -0800)]
[DAGCombiner] Remove (sra (shl X, C), C) if X has more than C sign bits.

If sext_inreg is supported, we will turn this into sext_inreg. That
will then remove it if there are enough sign bits. But if sext_inreg
isn't supported, we can still remove the shift pair based on sign
bits.

Split from D95890.

3 years ago[flang] Enable FIR types and Dialect round trip tests
Sourabh Singh Tomar [Wed, 3 Feb 2021 17:28:59 +0000 (22:58 +0530)]
[flang] Enable FIR types and Dialect round trip tests

Reviewed By: schweitz, mehdi_amini

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

3 years ago[OpenMP] Fixed an issue that taskwait doesn't work on detachable task
Shilei Tian [Wed, 3 Feb 2021 18:12:34 +0000 (13:12 -0500)]
[OpenMP] Fixed an issue that taskwait doesn't work on detachable task

D77609 mistakenly changed the bebavior of task waiting on detachable task that a detachable task is not waited, based on https://lists.llvm.org/pipermail/openmp-dev/2021-February/003836.html. This patch fixed it. Thank Raúl for the report.

Reviewed By: jdoerfert

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

3 years agoRevert "[DWARF] Location-less inlined variables should not have DW_TAG_variable"
Jeremy Morse [Wed, 3 Feb 2021 17:54:33 +0000 (17:54 +0000)]
Revert "[DWARF] Location-less inlined variables should not have DW_TAG_variable"

This reverts commit ddc2f1e3fb4f8f9ae7dd130e40b60cfc775eba24.

A build-bot objected:

  http://lab.llvm.org:8011/#builders/105/builds/5486

3 years ago[VPlan] Manage induction value creation using VPValues.
Florian Hahn [Wed, 3 Feb 2021 17:45:03 +0000 (17:45 +0000)]
[VPlan] Manage induction value creation using VPValues.

This patch updates the induction value creation to use VPValues of
recipes to map the created values. This should bring is one step closer
to being able to optimize induction recipes directly in VPlan.

Currently widenIntOrFpInduction also generates vector values for a cast
of the induction, if it exists. Make this explicit by adding the cast
instruction to the values defined by the recipe.

Reviewed By: gilr

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

3 years ago[DWARF] Location-less inlined variables should not have DW_TAG_variable
Jeremy Morse [Wed, 3 Feb 2021 17:27:30 +0000 (17:27 +0000)]
[DWARF] Location-less inlined variables should not have DW_TAG_variable

Discussed in this thread:

  https://lists.llvm.org/pipermail/llvm-dev/2021-January/148139.html

DwarfDebug::collectEntityInfo accidentally distinguishes between variable
locations that never have a location specified, and variable locations that
have an empty location specified. The latter leads to the creation of an
empty variable referring to the abstract origin.

Fix this by seeking a non-empty location before producing a concrete
entity, to guarantee a DW_AT_location will be produced. Other loops in
collectEntityInfo and endFunctionImpl take care of examining the
retainedNodes collection and ensuring optimised-out variables are created.

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

3 years ago[flang][NFCI] Relpace `LoopOp` Op with `DoLoopOp` Op in FIR Dialect
Sourabh Singh Tomar [Wed, 3 Feb 2021 14:30:21 +0000 (20:00 +0530)]
[flang][NFCI] Relpace `LoopOp` Op with `DoLoopOp` Op in FIR Dialect

Part of upstreaming effort,
PR: https://github.com/flang-compiler/f18-llvm-project/pull/296

Reviewed By: schweitz

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

3 years ago[dfsan] Clean TLS after signal callbacks
Jianzhou Zhao [Tue, 2 Feb 2021 22:35:27 +0000 (22:35 +0000)]
[dfsan] Clean TLS after signal callbacks

Similar to https://reviews.llvm.org/D95642, this diff fixes signal.

Reviewed-by: morehouse
Differential Revision: https://reviews.llvm.org/D95896

3 years ago[Hexagon] Add ELF flags for Hexagon V68
Krzysztof Parzyszek [Wed, 3 Feb 2021 16:34:50 +0000 (10:34 -0600)]
[Hexagon] Add ELF flags for Hexagon V68

3 years ago[flang] Add -fsyntax-only to f18; retain -fparse-only synonym
peter klausler [Tue, 2 Feb 2021 18:51:14 +0000 (10:51 -0800)]
[flang] Add -fsyntax-only to f18; retain -fparse-only synonym

Now that semantics is working, the standard -fsyntax-only option of
GNU and Clang should be used as the name of the option that causes
f18 to just run the front-end.  Support both options in f18, silently
accepting the old option as a synonym for the new one (as
preferred by the code owner), and replace all instances of the
old -fparse-only option with -fsyntax-only throughout the source base.

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

3 years ago[FPEnv][X86] Platform builtins edition: clang should get from the AST the metadata...
Kevin P. Neal [Tue, 12 Jan 2021 20:46:59 +0000 (15:46 -0500)]
[FPEnv][X86] Platform builtins edition: clang should get from the AST the metadata for constrained FP builtins

Currently clang is not correctly retrieving from the AST the metadata for
constrained FP builtins. This patch fixes that for the X86 specific builtins.

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

3 years ago[ConstraintElimination] Add some tests with conds in loop header.
Florian Hahn [Wed, 3 Feb 2021 15:00:37 +0000 (15:00 +0000)]
[ConstraintElimination] Add some tests with conds in loop header.

This patch adds a set of tests in which we can add the information from
the pre-header to a loop header, but currently do not do so.

3 years ago[AMDGPU] Fix multiclass template parameter types. NFC.
Jay Foad [Wed, 3 Feb 2021 16:20:12 +0000 (16:20 +0000)]
[AMDGPU] Fix multiclass template parameter types. NFC.

This fixes TableGen parser errors that will be reported when D95874 is
applied.

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

3 years agoRevert "[ConstantFold] Fold more operations to poison"
Juneyoung Lee [Wed, 3 Feb 2021 15:07:04 +0000 (00:07 +0900)]
Revert "[ConstantFold] Fold more operations to poison"

This reverts commit 53040a968dc2ff20931661e55f05da2ef8b964a0 due to its
bad interaction with select i1 -> and/or i1 transformation.

This fixes:
https://bugs.llvm.org/show_bug.cgi?id=49005
https://bugs.llvm.org/show_bug.cgi?id=48435

3 years ago[test] Use host platform specific error message substitution in lit tests - continued
Abhina Sreeskantharajan [Wed, 3 Feb 2021 14:52:43 +0000 (09:52 -0500)]
[test] Use host platform specific error message substitution in lit tests - continued

On z/OS, other error messages are not matched correctly in lit tests.

```
EDC5121I Invalid argument.
EDC5111I Permission denied.
```

This patch adds a lit substitution to fix it.

Reviewed By: jhenderson

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

3 years agoAMDGPU: Move handling of allocation of fixed ABI inputs
Matt Arsenault [Sat, 9 Jan 2021 15:44:29 +0000 (10:44 -0500)]
AMDGPU: Move handling of allocation of fixed ABI inputs

For the fixed ABI, set this in the initial argument constructor,
rather than relying on the allocation logic to set the values. Also
stop passing them for amdgpu_gfx, since the DAG path seems to skip
these. I'm unclear on what amdgpu_gfx's expectations are.  This will
allow moving the special input registers out of the normal argument
range.

3 years ago[LoopVectorize] add test for fake min/max; NFC
Sanjay Patel [Wed, 3 Feb 2021 14:22:51 +0000 (09:22 -0500)]
[LoopVectorize] add test for fake min/max; NFC

This goes with the dyn_cast fix:
0fa61304d247a61

That was made after noticing that the assert was over-reaching here:
bbed5f2f8a ( D95690 )

3 years ago[X86][SSE] Support variable-index float/double vector insertion on SSE41+ targets...
Simon Pilgrim [Wed, 3 Feb 2021 13:26:36 +0000 (13:26 +0000)]
[X86][SSE] Support variable-index float/double vector insertion on SSE41+ targets (PR47924)

Extends D95779 to permit insertion into float/doubles vectors while avoiding a lot of aliased memory traffic.

The scalar value is already on the simd unit, so we only need to transfer and splat the index value, then perform the select.

SSE4 codegen is a little bulky due to the tied register requirements of (non-VEX) BLENDPS/PD but the extra moves are cheap so shouldn't be an actual problem.

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

3 years ago[OpenCL][Docs] Fix command line flag in the example.
Anastasia Stulova [Wed, 3 Feb 2021 14:04:13 +0000 (14:04 +0000)]
[OpenCL][Docs] Fix command line flag in the example.

Fixed incorrect example of clang command line with
the builtin function declarations in OpenCLSupport.

Tags: #clang

3 years ago[Sema] Fix -Warray-bounds false negative when casting an out-of-bounds array item
Ilya Mirsky [Mon, 18 Jan 2021 00:02:44 +0000 (18:02 -0600)]
[Sema] Fix -Warray-bounds false negative when casting an out-of-bounds array item

Patch by Ilya Mirsky!

Fixes: http://llvm.org/PR44343

Reviewed By: rsmith

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

3 years ago[OpenCL] Fix address space in binding of initializer lists to referencs
Anastasia Stulova [Wed, 3 Feb 2021 11:05:00 +0000 (11:05 +0000)]
[OpenCL] Fix address space in binding of initializer lists to referencs

Prevent materializing temporaries in the address space of the references
they are bind to. The temporaries should always be in the same address
space - private for OpenCL.

Tags: #clang

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

3 years agoFix MLIR Async Runtime DLL on Windows
Matthew Parkinson [Wed, 3 Feb 2021 11:28:43 +0000 (11:28 +0000)]
Fix MLIR Async Runtime DLL on Windows

The AsyncRuntime declares prototypes for extern "C" functions inside a
namespace in the header, but not inside that namespace in the
definition. This causes Visual Studio to treat them as different
entities and thus the dllexport is ignored for the definitions.

Using the same namespace fixes this issue.

Secondly, this commit moves the dllexport to be consistent with the
JITs expectation.

This is an update to https://reviews.llvm.org/D95386 that fixes the
compile issues in old versions of Visual studio.

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

3 years ago[clang][AVR][NFC] Fix a typo
Ben Shi [Wed, 3 Feb 2021 12:00:06 +0000 (20:00 +0800)]
[clang][AVR][NFC] Fix a typo

Fix a typo in commit d38973aa4d6a2c8be97b9781ca7325ca3eb0c40d