platform/upstream/llvm.git
3 years ago[OpenMP][deviceRTLs] Drop `assert` in common parts of `deviceRTLs`
Shilei Tian [Thu, 4 Feb 2021 17:39:23 +0000 (12:39 -0500)]
[OpenMP][deviceRTLs] Drop `assert` in common parts of `deviceRTLs`

The header `assert.h` needs to be included in order to use `assert` in the code.
When building NVPTX `deviceRTLs` on a CUDA free system, it requires headers from
`gcc-multilib`, which some systems don't have. This patch drops the use of
`assert` in common parts of `deviceRTLs`. In light of
`openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h`, a code block
```
if (!cond)
  __builtin_trap();
```
is being used. The builtin will be translated to `call void @llvm.trap()`, and
the corresponding PTX is `trap;`.

Reviewed By: JonChesterfield

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

3 years agoRemove dead code from Linalg vectorization to fix GCC warning (NFC)
Mehdi Amini [Thu, 4 Feb 2021 17:37:25 +0000 (17:37 +0000)]
Remove dead code from Linalg vectorization to fix GCC warning (NFC)

3 years ago[mlir][ODS] Use StringLiteral instead of StringRef when applicable
Vladislav Vinogradov [Thu, 4 Feb 2021 17:12:15 +0000 (17:12 +0000)]
[mlir][ODS] Use StringLiteral instead of StringRef when applicable

Use `StringLiteral` for function return type if it is known to return
constant string literals only.

This will make it visible to API users, that such values can be safely
stored, since they refers to constant data, which will never be deallocated.

`StringRef` is general is not safe to store for a long term,
since it might refer to temporal data allocated in heap.

Reviewed By: mehdi_amini, bkramer

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

3 years ago[ELF] Make SHF_GNU_RETAIN sections GC roots
Fangrui Song [Thu, 4 Feb 2021 17:23:01 +0000 (09:23 -0800)]
[ELF] Make SHF_GNU_RETAIN sections GC roots

binutils 2.36 introduced the new section flag SHF_GNU_RETAIN (for ELFOSABI_GNU &
ELFOSABI_FREEBSD) to mark a sections as a GC root. Several LLVM side toolchain
folks (including me) were involved in the design process of SHF_GNU_RETAIN and
were happy with this proposal.

Currently GNU ld only respects SHF_GNU_RETAIN semantics for ELFOSABI_GNU &
ELFOSABI_FREEBSD object files
(https://sourceware.org/bugzilla/show_bug.cgi?id=27282).  GNU ld sets EI_OSABI
to ELFOSABI_GNU for relocatable output
(https://sourceware.org/bugzilla/show_bug.cgi?id=27091). In practice the single
value EI_OSABI is neither a good indicator for object file compatibility, nor a
useful mechanism marking used ELF extensions.

For input, we respect SHF_GNU_RETAIN semantics even for ELFOSABI_NONE object
files. This is compatible with how LLD and GNU ld handle (mildly useful) STT_GNU_IFUNC
/ (emitted by GCC, considered misfeature by some folks) STB_GNU_UNIQUE input.
(As of LLVM 12.0.0, the integrated assembler does not set ELFOSABI_GNU for
STT_GNU_IFUNC/STB_GNU_UNIQUE).
Arguably STT_GNU_IFUNC/STB_GNU_UNIQUE probably need indicators in object files
but SHF_GNU_RETAIN is more likely accepted by more OSABI platforms.

For output, we take a step further than GNU ld: we don't promote ELFOSABI_NONE
to ELFOSABI_GNU for all output.

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

3 years ago[ELF] Allow R_386_GOTOFF from .debug_info
Fangrui Song [Thu, 4 Feb 2021 17:17:47 +0000 (09:17 -0800)]
[ELF] Allow R_386_GOTOFF from .debug_info

In GCC emitted .debug_info sections, R_386_GOTOFF may be used to
relocate DW_AT_GNU_call_site_value values
(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98946).

R_386_GOTOFF (`S + A - GOT`) is one of the `isStaticLinkTimeConstant` relocation
type which is not PC-relative, so it can be used from non-SHF_ALLOC sections. We
current allow new relocation types as needs come. The diagnostic has caught some
bugs in the past.

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

3 years ago[examples] Fix Target does not support MC emission in ParallelJIT
xgupta [Thu, 4 Feb 2021 17:14:02 +0000 (22:44 +0530)]
[examples] Fix Target does not support MC emission in ParallelJIT

3 years ago[mlir][ODS] Add explicit namespace to `ViewLikeInterface` definition
Vladislav Vinogradov [Thu, 4 Feb 2021 17:11:49 +0000 (17:11 +0000)]
[mlir][ODS] Add explicit namespace to `ViewLikeInterface` definition

To allow it usage for Operation classes defined outside of `mlir` namespace.

Reviewed By: mehdi_amini

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

3 years ago[llvm-objdump] --source: drop the warning when there is no debug info
Fangrui Song [Thu, 4 Feb 2021 17:07:44 +0000 (09:07 -0800)]
[llvm-objdump] --source: drop the warning when there is no debug info

Warnings have been added for three cases (PR41905): (1) missing debug info, (2)
the source file cannot be found, (3) the debug info points at a line beyond the
end of the file.

(1) is probably less useful. This was brought up once on
http://lists.llvm.org/pipermail/llvm-dev/2020-April/141264.html and two
internal users mentioned it to me that it was annoying. (I personally
find the warning confusing, too.)

Users specify --source to get additional information if sources happen to be
available.  If sources are not available, it should be obvious as the output
will have no interleaved source lines. The warning can be especially annoying
when using llvm-objdump -S on a bunch of files.

This patch drops the warning when there is no debug info.
(If LLVMSymbolizer::symbolizeCode returns an `Error`, there will still be
an error. There is currently no test for an `Error` return value.
The only code path is probably a broken symbol table, but we probably already emit a warning
in that case)

`source-interleave-prefix.test` has an inappropriate "malformed" test - the test simply has no
.debug_* because new llc does not produce debug info when the filename is empty (invalid).
I have tried tampering the header of .debug_info/.debug_line but llvm-symbolizer does not warn.
This patch does not intend to add the missing test coverage.

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

3 years ago[mlir][ODS] Small fixes for ODS classes
Vladislav Vinogradov [Thu, 4 Feb 2021 17:05:20 +0000 (17:05 +0000)]
[mlir][ODS] Small fixes for ODS classes

* Introduce separate `RankedTensorOf` class. Use it as base class for `AnyRankedTensor`.
* Add C++ class specification (`::mlir::MemRefType`) to `MemRefRankOf` and `StaticShapeMemRefOf`.

Reviewed By: ftynse

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

3 years ago[AMDGPU][GlobalISel] Fix v2s16 right shifts
Jay Foad [Thu, 4 Feb 2021 16:25:14 +0000 (16:25 +0000)]
[AMDGPU][GlobalISel] Fix v2s16 right shifts

When widening, each half of the v2s16 operands needs to be sign extended
for G_ASHR or zero extended for G_LSHR.

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

3 years ago[AMDGPU][GlobalISel] Use scalar min/max instructions
Jay Foad [Thu, 4 Feb 2021 16:08:39 +0000 (16:08 +0000)]
[AMDGPU][GlobalISel] Use scalar min/max instructions

SALU min/max s32 instructions exist so use them. This means that
regbankselect can handle min/max much like add/sub/mul/shifts.

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

3 years ago[mlir][Linalg] Introduce a ContractionOpInterface
Nicolas Vasilache [Thu, 4 Feb 2021 16:49:09 +0000 (16:49 +0000)]
[mlir][Linalg] Introduce a ContractionOpInterface

This revision takes advantage of recent extensions to vectorization to refactor contraction detection into a bona fide Linalg interface.
The mlit-linalg-ods-gen parser is extended to support adding such interfaces.
The detection that was originally enabling vectorization is refactored to serve as both a test on a generic LinalgOp as well as to verify ops that declare to conform to that interface.

This is plugged through Linalg transforms and strategies but it quickly becomes evident that the complexity and rigidity of the C++ class based templating does not pay for itself.
Therefore, this revision changes the API for vectorization patterns to get rid of templates as much as possible.
Variadic templates are relegated to the internals of LinalgTransformationFilter as much as possible and away from the user-facing APIs.

It is expected other patterns / transformations will follow the same path and drop as much C++ templating as possible from the class definition.

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

3 years ago[lldb] Simplify the logic to detect compiler flag support
Jonas Devlieghere [Thu, 4 Feb 2021 16:40:26 +0000 (08:40 -0800)]
[lldb] Simplify the logic to detect compiler flag support

This patch effectively does the following 3 things:

 - Centralize the logic to figure out if a compiler flag is supported.
 - Stop sanity checking whether the compiler works at all. While useful,
   that's not the decorator's responsibility.
 - Invoke the compiler with xcrun on Darwin so we know where to find the
   sysroot.

On my macOS Big Sur system, the clang invocation couldn't find libSystem
and would fail the sanity check in the decorator. This meant that the
test suite would always try to run the ASan/UBSan/TSan tests, regardless
of whether compiler-rt was built.

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

3 years ago[flang][driver] Fix reading from stdin when using `-test-io`
Andrzej Warzynski [Thu, 4 Feb 2021 16:23:42 +0000 (16:23 +0000)]
[flang][driver] Fix reading from stdin when using `-test-io`

This patch adds logic in the InputOutputTestAction frontend action for
reading input from stdin. Without this patch the following fails:
```
    flang-new -fc1 -test-io -
```

The implementation of `InputOutputTestAction` is cleaned-up and a test
for reading from stdin is added.

Note that there's a difference between `-test-io` and e.g. `-E` in terms
of file I/O. The frontend action for the former handles all file I/O on
it's own. Conversely, the action corresponding to -E relies on the
prescanner API to handle this.

Currently we can't test reading from stdin for `flang-new -`. In this
case `libclangDriver` assumes `-x -c`. This in turn leads to `flang-new
-cc1`, which is not supported.

3 years ago[libc++] Remove the ability to use braced-init for filesystem paths
Louis Dionne [Wed, 3 Feb 2021 21:40:41 +0000 (16:40 -0500)]
[libc++] Remove the ability to use braced-init for filesystem paths

According to my reading of http://eel.is/c++draft/filesystems#fs.class.path,
the Standard doesn't actually mention that this should work. Since other
implementations don't allow it, allowing it in libc++ is just setting a
portability trap.

Supersedes https://reviews.llvm.org/D89865.

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

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[libc++] Make feature-test macros consistent with availability macros
Louis Dionne [Tue, 19 Jan 2021 18:04:01 +0000 (13:04 -0500)]
[libc++] Make feature-test macros consistent with availability macros

Before this patch, feature-test macros didn't take special availability
markup into account, which means that feature-test macros can sometimes
appear to "lie". For example, if you compile in C++20 mode and target
macOS 10.13, the __cpp_lib_filesystem feature-test macro will be provided
even though the <filesystem> declarations are marked as unavailable.
This patch fixes that.

rdar://68142369

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

3 years ago[libc++] Fix libcxx build on 32bit architectures with 64bit time_t defaults e.g....
Louis Dionne [Wed, 3 Feb 2021 22:00:20 +0000 (17:00 -0500)]
[libc++] Fix libcxx build on 32bit architectures with 64bit time_t defaults e.g. riscv32

Patch by Khem Raj.

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

3 years ago[clang][Arm] Fix handling of -Wa,-march=
David Spickett [Mon, 1 Feb 2021 11:29:14 +0000 (11:29 +0000)]
[clang][Arm] Fix handling of -Wa,-march=

This fixes Bugzilla #48894 for Arm, where it
was reported that -Wa,-march was not being handled
by the integrated assembler.

This was previously fixed for -Wa,-mthumb by
parsing the argument in ToolChain::ComputeLLVMTriple
instead of CollectArgsForIntegratedAssembler.
It has to be done in the former because the Triple
is read only by the time we get to the latter.

Previously only mcpu would work via -Wa but only because
"-target-cpu" is it's own option to cc1, which we were
able to modify. Target architecture is part of "-target-triple".

This change applies the same workaround to -march and cleans up
handling of -Wa,-mcpu at the same time. There were some
places where we were not using the last instance of an argument.

The existing -Wa,-mthumb code was doing this correctly,
so I've just added tests to confirm that.

Now the same rules will apply to -Wa,-march/-mcpu as would
if you just passed them to the compiler:
* -Wa/-Xassembler options only apply to assembly files.
* Architecture derived from mcpu beats any march options.
* When there are multiple mcpu or multiple march, the last
  one wins.
* If there is a compiler option and an assembler option of
  the same type, we prefer the one that fits the input type.
* If there is an applicable mcpu option but it is overruled
  by an march, the cpu value is still used for the "-target-cpu"
  cc1 option.

Reviewed By: nickdesaulniers

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

3 years ago[flang][driver] Add support for `-J/-module-dir`
Arnamoy Bhattacharyya [Thu, 4 Feb 2021 16:13:04 +0000 (16:13 +0000)]
[flang][driver] Add support for `-J/-module-dir`

Add support for option -J/-module-dir in the new Flang driver.  This
will allow for including module files in other directories, as the
default search path is currently the working folder. This also provides
an option of storing the output module in the specified folder.

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

3 years ago[Hexagon] Add -mv68 option to driver
Krzysztof Parzyszek [Thu, 4 Feb 2021 16:16:37 +0000 (10:16 -0600)]
[Hexagon] Add -mv68 option to driver

3 years ago[libc++] Adds a make_string test helper function.
Mark de Wever [Wed, 16 Dec 2020 08:43:14 +0000 (09:43 +0100)]
[libc++] Adds a make_string test helper function.

These function makes it easier to write generic unit tests for the
format header. It solves the issue where it's not possible to use
  `templated_prefix"foo"`
where `templated_prefix` resolves to: nothing, `L`, `u8`, `u`,
or `U`. The templated_prefix would be more faster during execution.

Reviewed By: ldionne, #libc, curdeius

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

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

3 years ago[InstCombine] add tests for demanded/known bits of shifted constant; NFC
Sanjay Patel [Wed, 3 Feb 2021 17:07:06 +0000 (12:07 -0500)]
[InstCombine] add tests for demanded/known bits of shifted constant; NFC

These are variations of a missed analysis noted in:
https://llvm.org/PR48984

3 years ago[AVR] Fix up a few accidentally-regressed Generic CodeGen tests recently broken
Dylan McKay [Thu, 4 Feb 2021 15:18:48 +0000 (04:18 +1300)]
[AVR] Fix up a few accidentally-regressed Generic CodeGen tests recently broken

In 85e8e6246e0fcc62ba727e8fb5990f1a632125d0, these tests were modified
to work with AVR, but the regex matchers were finicky and required a
fix forward patch, being this.

3 years ago[libc++] Rename include/support to include/__support
Louis Dionne [Tue, 2 Feb 2021 21:58:38 +0000 (16:58 -0500)]
[libc++] Rename include/support to include/__support

We do ship those headers, so the directory name should not be something
that can potentially conflict with user-defined directories.

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

3 years ago[X86] Use VT::changeVectorElementType helper where possible. NFCI.
Simon Pilgrim [Thu, 4 Feb 2021 14:26:02 +0000 (14:26 +0000)]
[X86] Use VT::changeVectorElementType helper where possible. NFCI.

3 years ago[AVR] Add 'XFAIL' to the remaining failing Generic CodeGen tests for AVR
Dylan McKay [Thu, 4 Feb 2021 13:20:48 +0000 (02:20 +1300)]
[AVR] Add 'XFAIL' to the remaining failing Generic CodeGen tests for AVR

This patch adds 'XFAIL: avr' to 2 Generic CodeGen tests, bringing the
Generic CodeGen tests for AVR to a pass, with only two XFAILures.

After this patch, the Generic CodeGen tests pass on AVR.

3 years ago[AVR] Fix 14 Generic CodeGen tests by making address space explicit or optional
Dylan McKay [Thu, 4 Feb 2021 14:56:20 +0000 (03:56 +1300)]
[AVR] Fix 14 Generic CodeGen tests by making address space explicit or optional

This fixes the vast majority of remaining failing AVR Generic CodeGen
tests.

3 years ago[Dexter] Avoid infinite loop in dbgeng driver
Jeremy Morse [Thu, 4 Feb 2021 14:54:12 +0000 (14:54 +0000)]
[Dexter] Avoid infinite loop in dbgeng driver

This method of the dbgeng debugger driver used to just "pass", as setting
dbgeng free running still leads to numerous errors. This wasn't a problem
in the past because, as it turns out, nothing called the go method.
However, a recent refactor uses it.

Rather than launch dbgeng free running, instead have it single step one
step forwards. This is slow, but it makes progress, where previously we
weren't.

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

3 years ago[flang][driver] Add PrescanAction frontend action (nfc)
Andrzej Warzynski [Thu, 4 Feb 2021 13:06:43 +0000 (13:06 +0000)]
[flang][driver] Add PrescanAction frontend action (nfc)

This new action encapsulates all actions that require the prescanner to
be run before proceeding with other processing. By adding this new
action, we are better equipped to control which actions _do_ run the
prescanner and which _do not_.

The following actions that require the prescanner are refactored to
inherit from `PrescanAction`:
  * `PrintPreprocessedAction`
  * `ParseSyntaxOnlyAction` .

New virtual method is introduced to facilitate all this:
  * `BeginSourceFileAction`
Like in Clang, this method is run inside `BeginSourceFile`. In other
words, it is invoked before `ExecuteAction` for the corresponding
frontend action is run. This method allows us to:
  * carry out any processing that is always required by the action (e.g.
    run the prescanner)
  * fine tune the settings/options on a file-by-file basis (e.g. to
    decide between fixed-form and free-form based on file extension)

This patch implements non-functional-changes.

Reviewed By: FarisRehman

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

3 years agoNFC: Migrate LoopUnrollPass to work on InstructionCost
Sander de Smalen [Thu, 4 Feb 2021 11:32:45 +0000 (11:32 +0000)]
NFC: Migrate LoopUnrollPass to work on InstructionCost

This patch migrates cost values and arithmetic to work on InstructionCost.
When the interfaces to TargetTransformInfo are changed, any InstructionCost
state will propagate naturally.

See this patch for the introduction of the type: https://reviews.llvm.org/D91174
See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2020-November/146408.html

Reviewed By: david-arm, fhahn

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

3 years ago[OpenCL][Docs] Link page explaining tooling for offline compilation.
Anastasia Stulova [Thu, 4 Feb 2021 13:59:13 +0000 (13:59 +0000)]
[OpenCL][Docs] Link page explaining tooling for offline compilation.

Tags: #clang

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

3 years ago[ConstraintElimination] Support conditions from loop preheaders
Florian Hahn [Wed, 3 Feb 2021 12:37:40 +0000 (12:37 +0000)]
[ConstraintElimination] Support conditions from loop preheaders

This patch extends the condition collection logic to allow adding
conditions from pre-headers to loop headers, by allowing cases where the
target block dominates some of its predecessors.

3 years ago[OpenCL] Fix default address space in template argument deduction.
Anastasia Stulova [Thu, 4 Feb 2021 13:46:11 +0000 (13:46 +0000)]
[OpenCL] Fix default address space in template argument deduction.

When deducing a reference type for forwarding references prevent
adding default address space of a template argument if it is given.

This got reported in PR48896 because in OpenCL all parameters are
in private address space and therefore when we initialize a
forwarding reference with a parameter we should just inherit the
address space from it i.e. keep __private instead of __generic.

Tags: #clang

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

3 years ago[mlir] Return scf.parallel ops resulted from tiling.
Alexander Belyaev [Thu, 4 Feb 2021 13:35:09 +0000 (14:35 +0100)]
[mlir] Return scf.parallel ops resulted from tiling.

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

3 years agoAMDGPU: Add support for amdgpu-unsafe-fp-atomics attribute
Konstantin Zhuravlyov [Thu, 4 Feb 2021 13:08:44 +0000 (08:08 -0500)]
AMDGPU: Add support for amdgpu-unsafe-fp-atomics attribute

If amdgpu-unsafe-fp-atomics is specified, allow {flat|global}_atomic_add_f32 even if atomic modes don't match.

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

3 years ago[AVR] Remove an assertion that causes generic CodeGen tests to fail
Dylan McKay [Thu, 4 Feb 2021 13:02:49 +0000 (02:02 +1300)]
[AVR] Remove an assertion that causes generic CodeGen tests to fail

It was discussed a few years ago and agreed that it makes sense to
remove this assertion as other targets do not perform similar register
size checking in inline assembly constraint logic, so the check just
adds a needless barrier on AVR.

This patch removes the assertion and removes 'XFAIL' from two Generic
CodeGen tests for AVR as a result.

3 years ago[clang] Add AddClang.cmake to the list of the CMake modules that are installed
Andrzej Warzynski [Thu, 4 Feb 2021 11:16:08 +0000 (11:16 +0000)]
[clang] Add AddClang.cmake to the list of the CMake modules that are installed

This makes sure that AddClang.cmake is installed alongside other Clang
CMake modules. This mirrors LLVM and MLIR in this respect and is
required when building the new Flang driver out of tree (as it depends
on Clang and includes AddClang.cmake).

Reviewed By: bogner

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

3 years ago[flang][driver] Add forced form flags and -ffixed-line-length
Faris Rehman [Tue, 26 Jan 2021 16:27:30 +0000 (16:27 +0000)]
[flang][driver] Add forced form flags and -ffixed-line-length

Add support for the following layout options:
* -ffree-form
* -ffixed-form
- -ffixed-line-length=n (alias -ffixed-line-length-n)
Additionally remove options `-fno-free-form` and `-fno-fixed-form` as they were initially added to forward to gfortran but gfortran does not support these flags.

This patch adds the flag FlangOnlyOption to the existing options `-ffixed-form`, `-ffree-form` and `-ffree-line-length-` in Options.td. As of commit 6a75496836ea14bcfd2f4b59d35a1cad4ac58cee, these flags are not currently forwarded to gfortran anyway.

The default fixed line length in FrontendOptions is 72, based off the current default in Fortran::parser::Options. The line length cannot be set to a negative integer, or a positive integer less than 7 excluding 0, consistent with the behaviour of gfortran.

This patch does not add `-ffree-line-length-n` as Fortran::parser::Options does not have a variable for free form columns.
Whilst the `fixedFormColumns` variable is used in f18 for `-ffree-line-length-n`, f18 only allows `-ffree-line-length-none`/`-ffree-line-length-0` and not a user-specified value. `fixedFormcolumns` cannot be used in the new driver as it is ignored in the frontend when dealing with free form files.

Summary of changes:
- Remove -fno-fixed-form and -fno-free-form from Options.td
- Make -ffixed-form, -ffree-form and -ffree-line-length-n FlangOnlyOption in Options.td
- Create AddFortranDialectOptions method in Flang.cpp
- Create FortranForm enum in FrontendOptions.h
- Add fortranForm_ and fixedFormColumns_ to Fortran::frontend::FrontendOptions
- Update fixed-form-test.f so that it guarantees that it fails when forced as a free form file to better facilitate testing.

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

3 years ago[X86] Remove stale TODO comment. NFC.
Simon Pilgrim [Thu, 4 Feb 2021 11:16:33 +0000 (11:16 +0000)]
[X86] Remove stale TODO comment. NFC.

We now handle implicit zero-extension shuffle mask cases.

3 years agoRevert "[hip][cuda] Enable extended lambda support on Windows."
Nico Weber [Thu, 4 Feb 2021 12:10:46 +0000 (07:10 -0500)]
Revert "[hip][cuda] Enable extended lambda support on Windows."

This reverts commit a2fdf9d4d734732a6fa9288f1ffdf12bf8618123.
Slightly speculative, seeing several cuda tests fail on this
Windows bot: http://45.33.8.238/win/32620/step_7.txt

3 years ago[gn build] (manually) port 0609f257dc2e2c3
Nico Weber [Thu, 4 Feb 2021 11:52:22 +0000 (06:52 -0500)]
[gn build] (manually) port 0609f257dc2e2c3

3 years ago[ElementCount] NFC: Set 'const' qualifier for getWithIncrement/Decrement.
Sander de Smalen [Thu, 4 Feb 2021 10:51:56 +0000 (10:51 +0000)]
[ElementCount] NFC: Set 'const' qualifier for getWithIncrement/Decrement.

These class methods simply return a new UnivariateLinearPolyBase
(e.g. ElementCount), and do not modify the object in any way or form,
so qualify for being 'const'.

3 years ago[mlir][Linalg] Drop SliceOp
Nicolas Vasilache [Thu, 4 Feb 2021 10:48:26 +0000 (10:48 +0000)]
[mlir][Linalg] Drop SliceOp

This op is subsumed by rank-reducing SubViewOp and has become useless.

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

3 years agoRe-land D94976 after revert in e29552c5aff6
Jeremy Morse [Thu, 4 Feb 2021 11:13:53 +0000 (11:13 +0000)]
Re-land D94976 after revert in e29552c5aff6

This modified patch avoids redirecting the unit in which a subprogram is
created if type units are enabled -- DIEs were getting children allocated
from different units memory pools. Original commit message:

[DWARF] Create subprogram's DIE in DISubprogram's unit

This is a fix for PR48790. Over in D70350, subprogram DIEs were permitted
to be shared between CUs. However, the creation of a subprogram DIE can be
triggered early, from other CUs. The subprogram definition is then created
in one CU, and when the function is actually emitted children are attached
to the subprogram that expect to be in another CU. This breaks internal CU
references in the children.

Fix this by redirecting the creation of subprogram DIEs in
getOrCreateContextDIE to the CU specified by it's DISubprogram definition.
This ensures that the subprogram DIE is always created in the correct CU.

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

3 years ago[ARM] Handle f16 in GeneratePerfectShuffle
David Green [Thu, 4 Feb 2021 11:14:52 +0000 (11:14 +0000)]
[ARM] Handle f16 in GeneratePerfectShuffle

This new f16 shuffle under Neon would hit an assert in
GeneratePerfectShuffle as it would try to treat a f16 vector as an i8.
Add f16 handling, treating them like an i16.

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

3 years ago[mlir] make vector to llvm conversion truly partial
Alex Zinenko [Thu, 4 Feb 2021 10:16:48 +0000 (11:16 +0100)]
[mlir] make vector to llvm conversion truly partial

Historically, the Vector to LLVM dialect conversion subsumed the Standard to
LLVM dialect conversion patterns. This was necessary because the conversion
infrastructure did not have sufficient support for reconciling type
conversions. This support is now available. Only keep the patterns related to
the Vector dialect in the Vector to LLVM conversion and require type casts
operations to be inserted if necessary. These casts will be removed by
following conversions if possible. Update integration tests to also run the
Standard to LLVM conversion.

There is a significant amount of test churn, which is due to (a) unnecessarily
strict tests in VectorToLLVM and (b) many patterns actually targeting Standard
dialect ops instead of LLVM dialect ops leading to tests actually exercising a
Vector->Standard->LLVM conversion. This churn is a good illustration of the
reason to make the conversion partial: now the tests only check the code in the
Vector to LLVM conversion and will not be randomly broken by changes in
Standard to LLVM conversion.

Arguably, it may be possible to extract Vector to Standard patterns into a
separate pass, but given the ongoing splitting of the Standard dialect, such
pass will be short-lived and will require further refactoring.

Depends On D95626

Reviewed By: nicolasvasilache, aartbik

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

3 years ago[lldb] Make TestLocalVariables.py compatible with the new pass manager
Pavel Labath [Thu, 4 Feb 2021 10:23:32 +0000 (11:23 +0100)]
[lldb] Make TestLocalVariables.py compatible with the new pass manager

The new PM is more aggressive at inlining, which breaks assumptions in
the test => slap some __attribute__((noinlines)) to prevent that.

3 years ago[mlir] Apply source materialization in case of transitive conversion
Alex Zinenko [Thu, 28 Jan 2021 16:43:13 +0000 (17:43 +0100)]
[mlir] Apply source materialization in case of transitive conversion

In dialect conversion infrastructure, source materialization applies as part of
the finalization procedure to results of the newly produced operations that
replace previously existing values with values having a different type.
However, such operations may be created to replace operations created in other
patterns. At this point, it is possible that the results of the _original_
operation are still in use and have mismatching types, but the results of the
_intermediate_ operation that performed the type change are not in use leading
to the absence of source materialization. For example,

  %0 = dialect.produce : !dialect.A
  dialect.use %0 : !dialect.A

can be replaced with

  %0 = dialect.other : !dialect.A
  %1 = dialect.produce : !dialect.A  // replaced, scheduled for removal
  dialect.use %1 : !dialect.A

and then with

  %0 = dialect.final : !dialect.B
  %1 = dialect.other : !dialect.A    // replaced, scheduled for removal
  %2 = dialect.produce : !dialect.A  // replaced, scheduled for removal
  dialect.use %2 : !dialect.A

in the same rewriting, but only the %1->%0 replacement is currently considered.

Change the logic in dialect conversion to look up all values that were replaced
by the given value and performing source materialization if any of those values
is still in use with mismatching types. This is performed by computing the
inverse value replacement mapping. This arguably expensive manipulation is
performed only if there were some type-changing replacements. An alternative
could be to consider all replaced operations and not only those that resulted
in type changes, but it would harm pattern-level composability: the pattern
that performed the non-type-changing replacement would have to be made aware of
the type converter in order to call the materialization hook.

Reviewed By: rriddle

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

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