platform/upstream/llvm.git
2 years ago[lldb] Cleanup MacOSX platform headers (NFC)
Jonas Devlieghere [Tue, 15 Mar 2022 04:54:07 +0000 (21:54 -0700)]
[lldb] Cleanup MacOSX platform headers (NFC)

While working on dde487e54782 I noticed that the MacOSX platforms were
in need of some love. This patch cleans up the headers:

 - Move platforms into the lldb_private namespace.
 - Remove lldb_private:: prefixes to improve readability.
 - Fix header includes and use forward declarations (iwyu).
 - Fix formatting

2 years ago[clang] Fix DIFile directory root on Windows
Keith Smiley [Sat, 26 Feb 2022 05:12:56 +0000 (21:12 -0800)]
[clang] Fix DIFile directory root on Windows

On unix systems this logic would not separate the file and directory of
the DIFile unless they shared more components at the start than just the
root path character. The logic to do this was unix specific so it didn't
work on Windows. Now we check if the entire root_path is the same as
what you were going to set as the Dir and use the full filepath in that
case.

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

2 years ago[test] Add lit helper for windows paths
Keith Smiley [Sat, 26 Feb 2022 04:40:21 +0000 (20:40 -0800)]
[test] Add lit helper for windows paths

This adds 2 new lit helpers `%{fs-src-root}` and `%{fs-sep}`, these
allow writing tests that correctly handle slashes on Windows. In the
case of tests like clang/test/CodeGen/debug-prefix-map.c, these are
unable to correctly test behavior on both platforms, unless they fork
and add OS requirements, because the relevant logic hits host specific
codepaths like checking if paths are absolute.

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

2 years ago[WebAssembly] Fix asan issue from https://reviews.llvm.org/D121349
Sam Clegg [Tue, 15 Mar 2022 02:57:12 +0000 (19:57 -0700)]
[WebAssembly] Fix asan issue from https://reviews.llvm.org/D121349

2 years agoAMDGPU: Use removeAllRegUnitsForPhysReg()
Ruiling Song [Tue, 11 Jan 2022 13:18:12 +0000 (21:18 +0800)]
AMDGPU: Use removeAllRegUnitsForPhysReg()

I met the issue here when working on something else.
Actually we have already reserved EXEC, but it looks
like the register coalescer is causing the sub-register
of EXEC appears in LiveIntervals. I have not looked
deeper why register coalscer have such behavior, but
removeAllRegUnitsForPhysReg() is the right way.

Reviewed By: critson, foad, arsenm

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

2 years ago[CMake][Fuchsia] Use correct architecture for iossim
Petr Hosek [Tue, 15 Mar 2022 02:01:26 +0000 (19:01 -0700)]
[CMake][Fuchsia] Use correct architecture for iossim

We should be building iossim for x86_64, not arm64.

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

2 years ago[lld-macho] -flat_namespace for dylibs should make all externs interposable
Jez Ng [Tue, 15 Mar 2022 01:51:15 +0000 (21:51 -0400)]
[lld-macho] -flat_namespace for dylibs should make all externs interposable

All references to interposable symbols can be redirected at runtime to
point to a different symbol definition (with the same name). For
example, if both dylib A and B define symbol _foo, and we load A before
B at runtime, then all references to _foo within dylib B will point to
the definition in dylib A.

ld64 makes all extern symbols interposable when linking with
`-flat_namespace`.

TODO 1: Support `-interposable` and `-interposable_list`, which should
just be a matter of parsing those CLI flags and setting the
`Defined::interposable` bit.

TODO 2: Set Reloc::FinalDefinitionInLinkageUnit correctly with this info
(we are currently not setting it at all, so we're erring on the
conservative side, but we should help the LTO backend generate more
optimal code.)

Reviewed By: modimo, MaskRay

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

2 years ago[lld-macho][nfc] Allow Defined symbols to be placed in binding sections
Jez Ng [Tue, 15 Mar 2022 01:51:11 +0000 (21:51 -0400)]
[lld-macho][nfc] Allow Defined symbols to be placed in binding sections

Previously, we only allowed this for DylibSymbols. However, in order to
properly support `-flat_namespace` as well as `-interposable`, we need
to allow this for Defined symbols too. Therefore we hoist the
`lazyBindOffset` and the `stubsHelperIndex` into the parent Symbol
class.

The actual change to support interposition under `-flat_namespace` is in
{D119294}; the NFC changes here have been split out for easier review.

Perf regression isn't stat sig on my 3.2 GHz 16-Core Intel Xeon W linking
chromium_framework:

             base           diff           difference (95% CI)
  sys_time   1.227 ± 0.021  1.234 ± 0.031  [  -0.3% ..   +1.5%]
  user_time  3.665 ± 0.036  3.674 ± 0.035  [  -0.2% ..   +0.7%]
  wall_time  4.596 ± 0.055  4.609 ± 0.064  [  -0.3% ..   +0.9%]
  samples    34             47

Max RSS regression is barely stat sig:

           base                           diff                           difference (95% CI)
  time     1003664356.324 ± 15404053.912  1010380403.613 ± 10578309.455  [  +0.0% ..   +1.3%]
  samples  37                             31

Reviewed By: modimo

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

2 years ago[clang-format] Don't unwrap lines preceded by line comments
Owen Pan [Mon, 14 Mar 2022 07:09:48 +0000 (00:09 -0700)]
[clang-format] Don't unwrap lines preceded by line comments

Fixes #53495

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

2 years ago[OpenMP][Fix] Fix test failing after patch
Joseph Huber [Tue, 15 Mar 2022 01:51:38 +0000 (21:51 -0400)]
[OpenMP][Fix] Fix test failing after patch

2 years ago[OpenMP][Fix] Add offloading kind to AMDGPU libraries
Joseph Huber [Tue, 15 Mar 2022 01:16:45 +0000 (21:16 -0400)]
[OpenMP][Fix] Add offloading kind to AMDGPU libraries

Summary:
A previous patch added the offloading kind to the triple format we used.
I forgot to update the line where we add the AMDGPU libraries.

2 years ago[gn build] Port 9c542a5a4e1b
LLVM GN Syncbot [Tue, 15 Mar 2022 00:51:57 +0000 (00:51 +0000)]
[gn build] Port 9c542a5a4e1b

2 years agoLower `@llvm.global_dtors` using `__cxa_atexit` on MachO
Julian Lettner [Wed, 9 Mar 2022 20:33:59 +0000 (12:33 -0800)]
Lower `@llvm.global_dtors` using `__cxa_atexit` on MachO

For MachO, lower `@llvm.global_dtors` into `@llvm_global_ctors` with
`__cxa_atexit` calls to avoid emitting the deprecated `__mod_term_func`.

Reuse the existing `WebAssemblyLowerGlobalDtors.cpp` to accomplish this.

Enable fallback to the old behavior via Clang driver flag
(`-fregister-global-dtors-with-atexit`) or llc / code generation flag
(`-lower-global-dtors-via-cxa-atexit`).  This escape hatch will be
removed in the future.

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

2 years ago[CUDA] Add CUDA fatbinary magic
Joseph Huber [Thu, 3 Mar 2022 19:56:13 +0000 (14:56 -0500)]
[CUDA] Add CUDA fatbinary magic

Nvidia uses fatbinaries to bundle all of their device code. This patch
adds the magic number "0x50ed55ba" used in their propeitary format to
the list of magic identifies. This is technically undocumented and could
unlikely be changed by Nvidia in the future.

Reviewed By: tra

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

2 years ago[OpenMP][NFC] Refactor new driver to be more general
Joseph Huber [Thu, 3 Mar 2022 18:07:44 +0000 (13:07 -0500)]
[OpenMP][NFC] Refactor new driver to be more general

This path refactors the new driver to be less dependent on OpenMP. This
is done in preparation for the new driver to be able to handle other
offloading kinds and compile them together.

Reviewed By: jdoerfert

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

2 years ago[Clang] Add offload kind to embedded offload object
Joseph Huber [Mon, 21 Feb 2022 23:55:51 +0000 (18:55 -0500)]
[Clang] Add offload kind to embedded offload object

This patch adds the offload kind to the embedded section name in
preparation for offloading to different kinda like CUDA or HIP.

Depends on D120288

Reviewed By: jdoerfert

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

2 years ago[OpenMP] Implement dense map info for device file
Joseph Huber [Mon, 21 Feb 2022 15:08:06 +0000 (10:08 -0500)]
[OpenMP] Implement dense map info for device file

This patch implements a DenseMap info struct for the device file type.
This is used to help grouping device files that have the same triple and
architecture. Because of this the filename, which will always be unique
for each file, is not used.

Reviewed By: jdoerfert

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

2 years ago[OpenMP] Try to embed offloading objects after codegen
Joseph Huber [Mon, 21 Feb 2022 15:07:37 +0000 (10:07 -0500)]
[OpenMP] Try to embed offloading objects after codegen

Currently we use the `-fembed-offload-object` option to embed a binary
file into the host as a named section. This is currently only used as a
codegen action, meaning we only handle this option correctly when the
input is a bitcode file. This patch adds the same handling to embed an
offloading object after we complete code generation. This allows us to
embed the object correctly if the input file is source or bitcode.

Reviewed By: jdoerfert

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

2 years ago[AMDGPU] gfx940: disable OP_SEL on V_DOT instructions
Stanislav Mekhanoshin [Mon, 14 Mar 2022 19:39:52 +0000 (12:39 -0700)]
[AMDGPU] gfx940: disable OP_SEL on V_DOT instructions

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

2 years agoReland "[lld-macho] Avoid using bump-alloc in TrieBuider""
Vy Nguyen [Mon, 14 Mar 2022 22:41:57 +0000 (18:41 -0400)]
Reland  "[lld-macho] Avoid using bump-alloc in TrieBuider""

This reverts commit ee7a286cd3e4364d2f7d5b6ba4b8a6fc0d524854.

2 years ago[AMDGPU] Add symbolic names for gfx940 HWREGs
Stanislav Mekhanoshin [Thu, 10 Mar 2022 22:59:47 +0000 (14:59 -0800)]
[AMDGPU] Add symbolic names for gfx940 HWREGs

The namespaces of HWREGs is now overlapping with gfx10. Thus the
patch is longer than necessary to just support new names. It also
need to handle proper error messages, i.e. to issue a "specified
hardware register is not supported on this GPU" message.

This may need a major refactoring in the future.

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

2 years ago[DFSan] Remove trampolines to unblock opaque pointers. (Reland with fix)
Andrew Browne [Mon, 14 Mar 2022 20:59:23 +0000 (13:59 -0700)]
[DFSan] Remove trampolines to unblock opaque pointers. (Reland with fix)

https://github.com/llvm/llvm-project/issues/54172

Reviewed By: pcc

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

2 years ago[AMDGPU] Support for gfx940 flat lds opcodes
Stanislav Mekhanoshin [Thu, 10 Mar 2022 22:04:16 +0000 (14:04 -0800)]
[AMDGPU] Support for gfx940 flat lds opcodes

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

2 years ago[AMDGPU] Support gfx940 v_lshl_add_u64 instruction
Stanislav Mekhanoshin [Thu, 10 Mar 2022 19:51:57 +0000 (11:51 -0800)]
[AMDGPU] Support gfx940 v_lshl_add_u64 instruction

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

2 years ago[ARM] __cxa_end_cleanup: avoid clobbering r4
Ryan Prichard [Mon, 14 Mar 2022 22:43:50 +0000 (15:43 -0700)]
[ARM] __cxa_end_cleanup: avoid clobbering r4

The fix for D111703 clobbered r4 both to:
 - Save/restore the original lr.
 - Load the address of _Unwind_Resume for LIBCXXABI_BAREMETAL.

This patch saves and restores lr without clobbering any extra
registers.

For LIBCXXABI_BAREMETAL, it is still necessary to clobber one extra
register to hold the address of _Unwind_Resume, but it seems better to
use ip/r12 (intended for linker veneers/trampolines) than r4 for this
purpose.

The function also clobbers r0 for the _Unwind_Resume function's
parameter, but that is unavoidable.

Reviewed By: danielkiss, logan, MaskRay

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

2 years ago[Clang] noinline stmt attribute - emit warnings rather than errors
Dávid Bolvanský [Mon, 14 Mar 2022 22:39:52 +0000 (23:39 +0100)]
[Clang] noinline stmt attribute - emit warnings rather than errors

Compatible behaviour with always_inline stmt attribute

2 years agoDon't report memory return values on MacOS_arm64 of SysV_arm64 ABI's.
Jim Ingham [Mon, 14 Mar 2022 21:37:38 +0000 (14:37 -0700)]
Don't report memory return values on MacOS_arm64 of SysV_arm64 ABI's.

They don't require that the memory return address be restored prior to
function exit, so there's no guarantee the value is correct.  It's better
to return nothing that something that's not accurate.

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

2 years ago[AMDGPU] flat scratch SVS addressing mode for gfx940
Stanislav Mekhanoshin [Tue, 8 Mar 2022 21:33:48 +0000 (13:33 -0800)]
[AMDGPU] flat scratch SVS addressing mode for gfx940

Both VADDR and SADDR are used in SVS mode.

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

2 years agoRevert "[lld-macho] Avoid using bump-alloc in TrieBuider"
Sterling Augustine [Mon, 14 Mar 2022 22:21:19 +0000 (15:21 -0700)]
Revert "[lld-macho] Avoid using bump-alloc in TrieBuider"

This reverts commit e049a87f04cff8e81b4177097a6b2fdf37c7b148.

That commit breaks the build with errors of the form:

/usr/local/google/home/saugustine/llvm/llvm-project/lld/MachO/ExportTrie.cpp:148:11: error: definition of implicitly declared destructor
TrieNode::~TrieNode() {

2 years ago[flang] IEEE_ARITHMETIC must imply USE IEEE_EXCEPTIONS
Peter Klausler [Fri, 11 Mar 2022 18:17:04 +0000 (10:17 -0800)]
[flang] IEEE_ARITHMETIC must imply USE IEEE_EXCEPTIONS

The intrinsic module IEEE_ARITHMETIC must incorporate the public
names from the intrisic module IEEE_EXCEPTIONS.  Rename IEEE_EXCEPTIONS
to __Fortran_ieee_exceptions so that it won't clash with the
nonintrinsic namespace, establish a new intrinic IEEE_EXCEPTIONS
module that USEs it, and add a USE to IEEE_ARITHMETIC.

Updated to use STREQUAL rather than ambiguous MATCHES in
the CMakeLists.txt file.

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

2 years ago[AMDGPU] gfx940 memory model
Stanislav Mekhanoshin [Tue, 8 Mar 2022 19:14:33 +0000 (11:14 -0800)]
[AMDGPU] gfx940 memory model

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

2 years ago[IROutliner] Ensure merged PHINodes respect order and incoming blocks, not just incom...
Andrew Litteken [Mon, 14 Mar 2022 04:44:46 +0000 (23:44 -0500)]
[IROutliner] Ensure merged PHINodes respect order and incoming blocks, not just incoming values

When matching PHINodes when margining functions the IROutliner only checks that an incoming value exists in phi node in overall function. It doesn't check the length, the order, or that the incoming block also matches. In the given example, we see that both phi nodes have the same incoming values, but from different blocks.

The fix is to to enforce stricter a match of the incoming value, and the incoming block as well when matching the created phi nodes.

Reviewers: paquette

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

2 years ago[InstCombine] Fold select based logic of fcmps with same operands when FMF is present.
Craig Topper [Mon, 14 Mar 2022 21:30:42 +0000 (14:30 -0700)]
[InstCombine] Fold select based logic of fcmps with same operands when FMF is present.

If we have a logical and/or in select form and the true/false operand
is an fcmp with poison generating FMF, we won't be able to fold it
to an and/or instruction. This prevents us from optimizing the case
where it is a logical operation of two fcmps with identical operands.

This patch adds explicit checks for this case that doesn't rely on
converting to and/or to do the optimization. It reuses the existing
foldLogicOfFCmps, but adds a new flag to disable the other combine
that is inside that function.

FMF flags from the two FCmps are intersected using the logic added in
D121243. The FIXME has been updated to indicate that we can only use
a union for the non-select form.

This allows us to optimize cases like this from compare-fp-3.c in the
gcc torture suite with fast math.

void
test1 (float x, float y)
{
  if ((x==y) && (x!=y))
    link_error0();
}

Reviewed By: spatel

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

2 years ago[IRLinker] make IRLinker::AddLazyFor optional (llvm::unique_function). NFC
Nick Desaulniers [Mon, 14 Mar 2022 21:08:25 +0000 (14:08 -0700)]
[IRLinker] make IRLinker::AddLazyFor optional (llvm::unique_function). NFC

2 of the 3 callsite of IRMover::move() pass empty lambda functions. Just
make this parameter llvm::unique_function.

Came about via discussion in D120781. Probably worth making this change
regardless of the resolution of D120781.

Reviewed By: dexonsmith

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

2 years ago[lld-macho] Avoid using bump-alloc in TrieBuider
Vy Nguyen [Mon, 14 Mar 2022 21:22:24 +0000 (17:22 -0400)]
[lld-macho] Avoid using bump-alloc in TrieBuider

The code can be used in multi-threads and the allocator is not thread safe.

fixes PR/54378

Reviewed By: int3, #lld-macho

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

2 years ago[X86] Fix avx512.mask.vpshld/vpshrd tests to correctly test maskz cases
Simon Pilgrim [Mon, 14 Mar 2022 21:20:16 +0000 (21:20 +0000)]
[X86] Fix avx512.mask.vpshld/vpshrd tests to correctly test maskz cases

2 years ago[AttrDocs] try to fix build
Dávid Bolvanský [Mon, 14 Mar 2022 21:19:40 +0000 (22:19 +0100)]
[AttrDocs] try to fix build

2 years ago[ELF] Move section assignment from initializeSymbols to postParse
Fangrui Song [Mon, 14 Mar 2022 21:13:41 +0000 (14:13 -0700)]
[ELF] Move section assignment from initializeSymbols to postParse

https://discourse.llvm.org/t/parallel-input-file-parsing/60164

initializeSymbols currently sets Defined::section and handles non-prevailing
COMDAT groups. Move the code to the parallel postParse to reduce work from the
single-threading code path and make parallel section initialization infeasible.

Postpone reporting duplicate symbol errors so that the messages have the
section information. (`Defined::section` is assigned in postParse and another
thread may not have the information).

* duplicated-synthetic-sym.s: BinaryFile duplicate definition (very rare) now
  has no section information
* comdat-binding: `%t/w.o %t/g.o` leads to an undesired undefined symbol. This
  is not ideal but we report a diagnostic to inform that this is unsupported.
  (See release note)
* comdat-discarded-lazy.s: %tdef.o is unextracted. The new behavior (discarded
  section error) makes more sense

Depends on D120640

Reviewed By: peter.smith

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

2 years agoNFC: Remove unterminated string from Python pyi file.
Stella Laurenzo [Mon, 14 Mar 2022 21:10:08 +0000 (14:10 -0700)]
NFC: Remove unterminated string from Python pyi file.

2 years ago[AMDGPU] Restrict machine copy propagation from creating unaligned classes
Stanislav Mekhanoshin [Fri, 11 Mar 2022 21:42:11 +0000 (13:42 -0800)]
[AMDGPU] Restrict machine copy propagation from creating unaligned classes

Fixes: SWDEV-326366

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

2 years ago[flang] Lower any intrinsic
Valentin Clement [Mon, 14 Mar 2022 21:06:02 +0000 (22:06 +0100)]
[flang] Lower any intrinsic

This patch lowers the `any` intrinsic function to FIR.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: PeteSteinfeld

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: mleair <leairmark@gmail.com>
2 years ago[GlobalISel] Fix store merging incorrectly merging volatile stores.
Amara Emerson [Mon, 14 Mar 2022 20:47:14 +0000 (13:47 -0700)]
[GlobalISel] Fix store merging incorrectly merging volatile stores.

The existing volatile checks only handle aliasing hazards between stores,
but that isn't enough since by that point volatile stores may have already
been added to the current candidate group.

2 years agoRevert "[DFSan] Remove trampolines to unblock opaque pointers."
Andrew Browne [Mon, 14 Mar 2022 20:47:21 +0000 (13:47 -0700)]
Revert "[DFSan] Remove trampolines to unblock opaque pointers."

This reverts commit 84af90336fed36f7dfdc468ded39236f32bbb82e.

2 years ago[Clang] always_inline statement attribute
Dávid Bolvanský [Mon, 14 Mar 2022 20:44:59 +0000 (21:44 +0100)]
[Clang] always_inline statement  attribute

Motivation:

```
int test(int x, int y) {
    int r = 0;
    [[clang::always_inline]] r += foo(x, y); // force compiler to inline this function here
    return r;
}
```

In 2018, @kuhar proposed "Introduce per-callsite inline intrinsics" in https://reviews.llvm.org/D51200 to solve this motivation case (and many others).

This patch solves this problem with call site attribute. "noinline" statement attribute already landed in D119061. Also, some LLVM Inliner fixes landed so call site attribute is stronger than function attribute.

Reviewed By: aaron.ballman

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

2 years ago[DFSan] Remove trampolines to unblock opaque pointers.
Andrew Browne [Tue, 8 Mar 2022 21:18:29 +0000 (13:18 -0800)]
[DFSan] Remove trampolines to unblock opaque pointers.

https://github.com/llvm/llvm-project/issues/54172

Reviewed By: pcc

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

2 years ago[MTE] Add test that stack tagging does not mess up stack coloring.
Florian Mayer [Fri, 11 Mar 2022 02:15:48 +0000 (18:15 -0800)]
[MTE] Add test that stack tagging does not mess up stack coloring.

Reviewed By: eugenis

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

2 years ago[LLDB] Applying clang-tidy modernize-use-default-member-init over LLDB
Shafik Yaghmour [Mon, 14 Mar 2022 20:32:03 +0000 (13:32 -0700)]
[LLDB] Applying clang-tidy modernize-use-default-member-init over LLDB

Applied modernize-use-default-member-init clang-tidy check over LLDB.
It appears in many files we had already switched to in class member init but
never updated the constructors to reflect that. This check is already present in
the lldb/.clang-tidy config.

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

2 years ago[IROutliner] Separate split PHI nodes from multiple exits by different outlinable...
Andrew Litteken [Mon, 14 Mar 2022 04:45:09 +0000 (23:45 -0500)]
[IROutliner] Separate split PHI nodes from multiple exits by different outlinable regions.

The IR Outliner is supposed to extract the outputs contained in an external phi node and place them into a phi node contained within the outlined function. However, when the output values of two outlined functions with two different output sets are contained within the same phi node, they are counted as the same exit path when first analyzed. In reality, these create two different phi nodes, creating an inconsistency, resulting in a mismatch in the expected number of output paths and a crash.  This fixes that counting when analyzing the outputs by also analyzing the incoming blocks rather than just the incoming values.

Reviewer: paquette

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

2 years agogn build: Add support for building with libcurl.
Peter Collingbourne [Tue, 8 Mar 2022 22:48:16 +0000 (14:48 -0800)]
gn build: Add support for building with libcurl.

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

2 years ago[LV] Check for users of truncated IVs, add more detailed comment.
Florian Hahn [Mon, 14 Mar 2022 19:39:30 +0000 (19:39 +0000)]
[LV] Check for users of truncated IVs, add more detailed comment.

Add missing outside user check for truncated IVs. Also hoist the code in
the helper with additional explanations.

Fixes #54370.

2 years ago[X86] Fix cosmetic issues in instruction mnemonics
Amir Ayupov [Mon, 14 Mar 2022 19:27:21 +0000 (12:27 -0700)]
[X86] Fix cosmetic issues in instruction mnemonics

- Remove spurious } in invlpgb mnemonic
- Add \t between mnemonic and operands for ud1 instructions

Reviewed By: skan, craig.topper

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

2 years ago[lldb] Plumb process host architecture through platform selection
Jonas Devlieghere [Mon, 14 Mar 2022 19:14:16 +0000 (12:14 -0700)]
[lldb] Plumb process host architecture through platform selection

To allow us to select a different platform based on where the process is
running, plumb the process host architecture through platform selection.

This patch is in preparation for D121444 which needs this functionality
to tell apart iOS binaries running on Apple Silicon vs on a remote iOS
device.

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

2 years ago[ELF] Set the priority of STB_GNU_UNIQUE the same as STB_WEAK
Fangrui Song [Mon, 14 Mar 2022 19:00:15 +0000 (12:00 -0700)]
[ELF] Set the priority of STB_GNU_UNIQUE the same as STB_WEAK

In GCC -fgnu-unique output, STB_GNU_UNIQUE symbols are always defined relative
to a section in a COMDAT group. Currently `other` cannot be STB_GNU_UNIQUE for
valid input, so this patch is NFC.

If we switch to the model that ignores COMDAT resolution when performing symbol
resolution (D120626), this will fix bogus `relocation refers to a symbol in a
discarded section` errors when mixing -fno-gnu-unique objects with -fgnu-unique
objects.

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

2 years ago[Support] Add const to `FileError::getFileName`
Ben Barham [Fri, 11 Mar 2022 22:37:06 +0000 (14:37 -0800)]
[Support] Add const to `FileError::getFileName`

`getFileName` returns a `StringRef`, there's no reason it shouldn't be
const.

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

2 years ago[VFS] Rename `RedirectingFileSystem::dump` to `print`
Ben Barham [Fri, 11 Mar 2022 22:31:21 +0000 (14:31 -0800)]
[VFS] Rename `RedirectingFileSystem::dump` to `print`

The rest of LLVM uses `print` for the method taking the `raw_ostream`
and `dump` only for the method with no parameters. Use the same for
`RedirectingFileSystem`.

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

2 years ago[CodeGen] Remove an unused variable introduced in D121128
Kazu Hirata [Mon, 14 Mar 2022 18:36:58 +0000 (11:36 -0700)]
[CodeGen] Remove an unused variable introduced in D121128

2 years ago[Support] Change zlib::compress to return void
Fangrui Song [Mon, 14 Mar 2022 18:38:04 +0000 (11:38 -0700)]
[Support] Change zlib::compress to return void

With a sufficiently large output buffer, the only failure is Z_MEM_ERROR.
Check it and call the noreturn report_bad_alloc_error if applicable.
resize_for_overwrite may call report_bad_alloc_error as well.

Now that there is no other error type, we can replace the return type with void
and simplify call sites.

Reviewed By: ikudrin

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

2 years ago[lldb] Fix the Windows build after D121536
Jonas Devlieghere [Mon, 14 Mar 2022 18:22:12 +0000 (11:22 -0700)]
[lldb] Fix the Windows build after D121536

2 years ago[flang] LBOUND() edge case: empty dimension
Peter Klausler [Wed, 9 Mar 2022 21:43:54 +0000 (13:43 -0800)]
[flang] LBOUND() edge case: empty dimension

LBOUND must return 1 for an empty dimension, no matter what
explicit expression might appear in a declaration or arrive in
a descriptor.

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

2 years agoWrite a pass to annotate constant operands on FIR ops. This works
Eric Schweitz [Wed, 2 Feb 2022 20:46:21 +0000 (12:46 -0800)]
Write a pass to annotate constant operands on FIR ops. This works
around the feature in MLIR's canonicalizer, which considers the semantics
of constants differently based on how they are packaged and not their
values and use.  Add test.

Reviewed By: clementval

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

2 years agoRevert "[flang] IEEE_ARITHMETIC must imply USE IEEE_EXCEPTIONS"
Andrzej Warzynski [Mon, 14 Mar 2022 17:59:55 +0000 (17:59 +0000)]
Revert "[flang] IEEE_ARITHMETIC must imply USE IEEE_EXCEPTIONS"

This reverts commit b6a7600491d755f6f700fe245b2fc7b928264c58. It caused
the following build failure:
```
ninja: error: dependency cycle: include/flang/__fortran_ieee_exceptions.mod -> include/flang/__fortran_ieee_exceptions.mod
```

See e.g.:
* https://lab.llvm.org/buildbot/#/builders/172/builds/9595

To reproduce:
```
cmake -G Ninja \
  -DLLVM_TARGETS_TO_BUILD=host \
  -DCMAKE_BUILD_TYPE=Release \
  -DLLVM_ENABLE_PROJECTS="clang;flang" \
  ../../llvm
ninja check-flang
```

2 years ago[RISCV] Add MIR tests exposing missed InstAliases
Fraser Cormack [Fri, 27 Nov 2020 14:29:58 +0000 (14:29 +0000)]
[RISCV] Add MIR tests exposing missed InstAliases

The InstAlias framework cannot match registers against zero_reg, which
RVV uses to encode unmasked operations.

Reviewed By: craig.topper

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

2 years ago[libc++][NFC] Remove several redundant #if _LIBCPP_STD_VER > 17 in <span>
Louis Dionne [Mon, 14 Mar 2022 15:36:21 +0000 (11:36 -0400)]
[libc++][NFC] Remove several redundant #if _LIBCPP_STD_VER > 17 in <span>

It turns out that the whole header is only enabled in C++20 and above,
so these checks were redundant (and always true).

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

2 years ago[regalloc] Remove -consider-local-interval-cost
Mircea Trofin [Mon, 7 Mar 2022 16:23:05 +0000 (08:23 -0800)]
[regalloc] Remove -consider-local-interval-cost

Discussed extensively on D98232. The functionality introduced in D35816
never worked correctly. In D98232, it was fixed, but, as it was
introducing a large compile-time regression, and the value of the
original patch was called into doubt, we disabled it by default
everywhere. A year later, it appears that caused no grief, so it seems
safe to remove the disabled code.

This should be accompanied by re-opening bug 26810.

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

2 years ago[flang] IEEE_ARITHMETIC must imply USE IEEE_EXCEPTIONS
Peter Klausler [Fri, 11 Mar 2022 18:17:04 +0000 (10:17 -0800)]
[flang] IEEE_ARITHMETIC must imply USE IEEE_EXCEPTIONS

The intrinsic module IEEE_ARITHMETIC must incorporate the public
names from the intrisic module IEEE_EXCEPTIONS.  Rename IEEE_EXCEPTIONS
to __Fortran_ieee_exceptions so that it won't clash with the
nonintrinsic namespace, establish a new intrinic IEEE_EXCEPTIONS
module that USEs it, and add a USE to IEEE_ARITHMETIC.

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

2 years ago[lldb] Use the debugger's asynchronous output stream for progress events.
Jonas Devlieghere [Mon, 14 Mar 2022 17:22:04 +0000 (10:22 -0700)]
[lldb] Use the debugger's asynchronous output stream for progress events.

Use the debugger's asynchronous output stream for printing progress
events. This allows the active IOHandler to be in charge of printing
them and doing the necessary synchronization.

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

2 years ago[AArch64] Perform last active true vector combine
zhongyunde [Mon, 14 Mar 2022 17:19:39 +0000 (01:19 +0800)]
[AArch64] Perform last active true vector combine

Test bit of lane EC-1 can use P register directly, eg:
Materialize : Idx = (add (mul vscale, NumEls), -1)
               i1 = extract_vector_elt t37, Constant:i64<Idx>
    ... into: "ptrue p, all" + PTEST

Reviewed By: paulwalker-arm

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

2 years ago[clang][dataflow] Add support for nested composite bool expressions
Stanislav Gatev [Fri, 11 Mar 2022 11:52:53 +0000 (11:52 +0000)]
[clang][dataflow] Add support for nested composite bool expressions

This is part of the implementation of the dataflow analysis framework.
See "[RFC] A dataflow analysis framework for Clang AST" on cfe-dev.

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

2 years ago[WebAssembly] Remove unused method from WebAssemblyTargetStreamer. NFC
Sam Clegg [Sun, 13 Mar 2022 05:11:56 +0000 (21:11 -0800)]
[WebAssembly] Remove unused method from WebAssemblyTargetStreamer. NFC

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

2 years ago[WPD] Extend checking mode to support fallback to indirect call
Teresa Johnson [Thu, 10 Mar 2022 22:17:53 +0000 (14:17 -0800)]
[WPD] Extend checking mode to support fallback to indirect call

Extend -wholeprogramdevirt-check to support both the existing
trapping mode on an incorrect devirtualization, as well as a new
mode to fallback to an indirect call on a mismatch. The new mode is

The new mode is useful in cases where we want to enable
devirtualization but cannot fully guarantee whole program visibility
(e.g in the case where LTO has been disabled for a small set of objects
that could potentially override virtual methods without having a symbol
reference to anything in the base class including the vtable).

Remove !prof and !callees metadata (which are used by indirect call
promotion) from both the new direct call and the fallback indirect call
(so that we don't perform another round of promotion on the latter).
Also remove it from the direct call in the non-fallback cases, which
was an oversight, although it didn't seem to cause any issues. Add tests
for the metadata removal covering the various cases.

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

2 years ago[flang] Lower format statement
Valentin Clement [Mon, 14 Mar 2022 17:15:16 +0000 (18:15 +0100)]
[flang] Lower format statement

This patch lowers the format statement.

Reviewed By: PeteSteinfeld

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

2 years ago[llvm] Fix warning: missing submodule 'LLVM_Analysis.ScalarFuncs'
Jonas Devlieghere [Mon, 14 Mar 2022 16:47:39 +0000 (09:47 -0700)]
[llvm] Fix warning: missing submodule 'LLVM_Analysis.ScalarFuncs'

2 years ago[lldb] Use the IOHandler's stream instead of the debugger's in PrintAsync
Jonas Devlieghere [Mon, 14 Mar 2022 16:26:39 +0000 (09:26 -0700)]
[lldb] Use the IOHandler's stream instead of the debugger's in PrintAsync

PrintAsync is relying on the IOHandler to print to the output/error
stream. In that context it doesn't make much sense that this is using
the debugger's streams rather than the one from the IOHandler.

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

2 years ago[OpaquePtr][AArch64] Use elementtype on ldxr/stxr
Arthur Eubanks [Thu, 24 Feb 2022 23:51:00 +0000 (15:51 -0800)]
[OpaquePtr][AArch64] Use elementtype on ldxr/stxr

Includes verifier changes checking the elementtype, clang codegen
changes to emit the elementtype, and ISel changes using the elementtype.

Reviewed By: #opaque-pointers, nikic

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

2 years ago[flang] Lower common block
Valentin Clement [Mon, 14 Mar 2022 17:03:50 +0000 (18:03 +0100)]
[flang] Lower common block

This patch lowers common block variable to FIR.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: PeteSteinfeld

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

Co-authored-by: V Donaldson <vdonaldson@nvidia.com>
Co-authored-by: Jean Perier <jperier@nvidia.com>
2 years ago[DFSan] Remove use of setarch in dfsan test.
Andrew Browne [Fri, 11 Mar 2022 02:58:17 +0000 (18:58 -0800)]
[DFSan] Remove use of setarch in dfsan test.

Use of setarch Was added by
https://github.com/llvm/llvm-project/commit/f93c2b64ed381bc4bc52f4b8539026f1597f574d

Running the test now it doesn't seem necessary because:

1) Explicitly only x86_64 is supported for dfsan.

2) https://reviews.llvm.org/D111522 makes it less flakey.

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

2 years ago[IROutliner] Avoid reusing PHINodes that have already been matched when merging outli...
Andrew Litteken [Wed, 9 Mar 2022 18:33:33 +0000 (10:33 -0800)]
[IROutliner] Avoid reusing PHINodes that have already been matched when merging outlined functions' phi node blocks

When there are two external phi nodes for two different outlined regions, when compressing the created phi nodes between the two regions, the matching for the second phi node in the second region matches the first phi node created for the first region rather than the second phi node created for the first region. This adds an extra output path where there should not be one.

The fix is the ignore phi nodes that have already been matched for each region.

Reviewer: paquette

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

2 years ago[gn build] Port 5e65e79bace6
LLVM GN Syncbot [Mon, 14 Mar 2022 16:52:53 +0000 (16:52 +0000)]
[gn build] Port 5e65e79bace6

2 years ago[flang] Lower all intrinsic
Valentin Clement [Mon, 14 Mar 2022 16:40:47 +0000 (17:40 +0100)]
[flang] Lower all intrinsic

Lower the `all` intrinsic procedure.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: PeteSteinfeld

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

Co-authored-by: mleair <leairmark@gmail.com>
Co-authored-by: Jean Perier <jperier@nvidia.com>
2 years agoFix the implicit module build (2/2)
Jonas Devlieghere [Mon, 14 Mar 2022 16:40:24 +0000 (09:40 -0700)]
Fix the implicit module build (2/2)

This fixes the implicit module build after b1b4b6f36695 broke the LLDB
build: https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/42084/

My previous commit didn't have the modulemap change staged.

2 years ago[NewPM] Actually recompute GlobalsAA before module optimization pipeline
Arthur Eubanks [Sat, 5 Mar 2022 23:06:08 +0000 (15:06 -0800)]
[NewPM] Actually recompute GlobalsAA before module optimization pipeline

RequireAnalysis<GlobalsAA> doesn't actually recompute GlobalsAA.
GlobalsAA isn't invalidated (unless specifically invalidated) because
it's self-updating via ValueHandles, but can be imprecise during the
self-updates.

Rather than invalidating GlobalsAA, which would invalidate AAManager and
any analyses that use AAManager, create a new pass that recomputes
GlobalsAA.

Fixes #53131.

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

2 years ago[test] Add phase ordering test
Arthur Eubanks [Sat, 5 Mar 2022 23:20:24 +0000 (15:20 -0800)]
[test] Add phase ordering test

2 years ago[flang] Lower elemental calls
Valentin Clement [Mon, 14 Mar 2022 16:38:47 +0000 (17:38 +0100)]
[flang] Lower elemental calls

This patch adds more lowering of operations sub-expression inside elemental call arguments.
It tests array contexts where an address is needed for each element (for
the argument), but part of the array sub-expression must be lowered by value
(for the operation)

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: PeteSteinfeld

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years ago[ValueTracking] Simplify llvm::isPointerOffset()
Arthur Eubanks [Thu, 24 Feb 2022 23:30:23 +0000 (15:30 -0800)]
[ValueTracking] Simplify llvm::isPointerOffset()

We still need the code after stripAndAccumulateConstantOffsets() since
it doesn't handle GEPs of scalable types and non-constant but identical
indexes.

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

2 years agoFix issing header on z/OS
serge-sans-paille [Mon, 14 Mar 2022 16:28:38 +0000 (17:28 +0100)]
Fix issing header on z/OS

Bug introduced in fbbc41f8dd23

2 years ago[lldb] Skip Test11588 on Windows
Stella Stamenova [Mon, 14 Mar 2022 16:26:41 +0000 (09:26 -0700)]
[lldb] Skip Test11588 on Windows

The test was marked as XFAIL on Windows, but recent changes have made it flaky instead

2 years agoFix the implicit module build
Jonas Devlieghere [Mon, 14 Mar 2022 16:22:30 +0000 (09:22 -0700)]
Fix the implicit module build

This fixes the implicit module build after b1b4b6f36695 broke the LLDB
build: https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/42084/

2 years ago[lldb] Move ProgressEventData out of debugger and into its own file (NFC)
Jonas Devlieghere [Mon, 14 Mar 2022 16:01:53 +0000 (09:01 -0700)]
[lldb] Move ProgressEventData out of debugger and into its own file (NFC)

Move ProgressEventData out of debugger and into its own file. This is in
preparation of adding a few new type of event data for diagnostics.

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

2 years ago[TLI] Check that malloc argument has type size_t
Nikita Popov [Mon, 14 Mar 2022 16:14:16 +0000 (17:14 +0100)]
[TLI] Check that malloc argument has type size_t

DSE assumes that this is the case when forming a calloc from a
malloc + memset pair.

For tests, either update the malloc signature or change the
data layout.

2 years ago[mlir][vector] Implement unrolling of ReductionOp
Matthias Springer [Mon, 14 Mar 2022 16:05:32 +0000 (01:05 +0900)]
[mlir][vector] Implement unrolling of ReductionOp

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

2 years ago[WebAssembly] Rename member in WasmYAML.h to avoid compiler warning
Sam Clegg [Mon, 14 Mar 2022 16:07:48 +0000 (09:07 -0700)]
[WebAssembly] Rename member in WasmYAML.h to avoid compiler warning

Followup/fix for https://reviews.llvm.org/D121349.

2 years agoclang-tidy: discover binaries in build dir
Keith Smiley [Sun, 13 Mar 2022 17:02:02 +0000 (10:02 -0700)]
clang-tidy: discover binaries in build dir

This changes the clang-tidy script to discover binaries you've built
locally without having to pass them.

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

2 years ago[WebAssembly] Second phase of implemented extended const proposal
Sam Clegg [Thu, 10 Mar 2022 02:11:44 +0000 (18:11 -0800)]
[WebAssembly] Second phase of implemented extended const proposal

This change continues to lay the ground work for supporting extended
const expressions in the linker.

The included test covers object file reading and writing and the YAML
representation.

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

2 years ago[SLPVectorizer] Handle external load/store pointer uses with opaque pointers
Nikita Popov [Mon, 14 Mar 2022 15:54:07 +0000 (16:54 +0100)]
[SLPVectorizer] Handle external load/store pointer uses with opaque pointers

In this case we may not generate a bitcast, so the new load/store
becomes the external user.

2 years ago[lldb] Require native for command-thread-siginfo.test
Ayush Sahay [Mon, 14 Mar 2022 15:25:13 +0000 (20:55 +0530)]
[lldb] Require native for command-thread-siginfo.test

command-thread-siginfo.test employs a subject with a call to wait, and
thus requires system-linux. However, it's possible to target non-Linux
platforms despite operating on Linux hosts. So, have it require native
too.

Reviewed By: mgorny, labath

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

2 years ago[LV] Remove dead Loop argument from emitMinimumVector... (NFC)
Florian Hahn [Mon, 14 Mar 2022 15:47:40 +0000 (15:47 +0000)]
[LV] Remove dead Loop argument from emitMinimumVector... (NFC)

The argument is not used, remove it.

2 years ago[polly] Introduce -polly-print-* passes to replace -analyze.
Michael Kruse [Mon, 14 Mar 2022 13:39:25 +0000 (08:39 -0500)]
[polly] Introduce -polly-print-* passes to replace -analyze.

The `opt -analyze` option only works with the legacy pass manager and might be removed in the future, as explained in llvm.org/PR53733. This patch introduced -polly-print-* passes that print what the pass would print with the `-analyze` option and replaces all uses of `-analyze` in the regression tests.

There are two exceptions: `CodeGen\single_loop_param_less_equal.ll` and `CodeGen\loop_with_condition_nested.ll` use `-analyze on the `-loops` pass which is not part of Polly.

Reviewed By: aeubanks

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

2 years ago[mlir][vector] Add unrolling pattern for multidim_reduce op
Thomas Raoux [Wed, 9 Mar 2022 00:08:11 +0000 (00:08 +0000)]
[mlir][vector] Add unrolling pattern for multidim_reduce op

Implement the vectorLoopUnroll interface for MultiDimReduceOp and add a
pattern to do the unrolling following the same interface other vector
unroll patterns.

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

2 years ago[Verifier] Verify llvm.access.group metadata
Nikita Popov [Mon, 14 Mar 2022 14:36:32 +0000 (15:36 +0100)]
[Verifier] Verify llvm.access.group metadata

According to LangRef, an access scope must have zero operands and
be distinct. The access group may either be a single access scope
or a list of access scopes.

LoopInfo may assert if this is not the case.

2 years ago[PowerPC] Add missed VSX shuffles instead of Altivec ones
Nemanja Ivanovic [Fri, 11 Mar 2022 17:19:20 +0000 (11:19 -0600)]
[PowerPC] Add missed VSX shuffles instead of Altivec ones

VSX introduced some permute instructions that are direct
replacements for Altivec ones except they can target all
the VSX registers. We have added code generation for most
of these but somehow missed the low/hi word merges (XXMRG[LH]W).
This caused some additional spills on some large
computationally intensive code.

This patch simply adds the missed patterns.