platform/upstream/llvm.git
2 years ago[gn build] Don't copy xray includes
Arthur Eubanks [Wed, 25 Aug 2021 22:24:49 +0000 (15:24 -0700)]
[gn build] Don't copy xray includes

The gn build doesn't support xray, so there's no reason to make the xray
headers available. Some CMake checks check if xray includes are
available to determine if xray is usable. Since we don't build the xray
runtime, there are link errors.

Reviewed By: thakis

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

2 years ago[libc++][NFC] Remove unused helper function in the test suite
Louis Dionne [Fri, 27 Aug 2021 15:47:27 +0000 (11:47 -0400)]
[libc++][NFC] Remove unused helper function in the test suite

2 years ago[MCParser][z/OS] Mark test as unsupported for the z/OS Target
Fanbo Meng [Fri, 27 Aug 2021 14:26:51 +0000 (10:26 -0400)]
[MCParser][z/OS] Mark test as unsupported for the z/OS Target

Marking test as unsupported for the same reason as https://reviews.llvm.org/D105204

Reviewed By: abhina.sreeskantharajan

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

2 years ago[IR] Remove getWithOperandReplaced (NFC)
Kazu Hirata [Fri, 27 Aug 2021 15:42:57 +0000 (08:42 -0700)]
[IR] Remove getWithOperandReplaced (NFC)

The function hasn't been used for at least 10 years.

2 years ago[AMDGPU][MC][NFC][DOC] Updated AMD GPU assembler syntax description.
Dmitry Preobrazhensky [Fri, 27 Aug 2021 14:16:22 +0000 (17:16 +0300)]
[AMDGPU][MC][NFC][DOC] Updated AMD GPU assembler syntax description.

Summary of changes:
- Added f16 omod modifier (bug 51386).
- Corrected names of data types (bug 48638).
- Enabled a16 with most GFX10 MIMG opcodes (see https://reviews.llvm.org/D102231).
- Corrected description of integer operands (bug 51130).
- Corrected description of 8-bit DS offsets (bug 51536).
- Improved PERMLANE op_sel description.
- Corrected *SAD* opcode types.

2 years ago[libc++][NFC] Remove extra __ranges/take_view.h entry in CMakeLists.txt
Joe Loser [Fri, 27 Aug 2021 14:08:11 +0000 (10:08 -0400)]
[libc++][NFC] Remove extra __ranges/take_view.h entry in CMakeLists.txt

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

2 years agoRevert "[CMake] Enable LLVM_ENABLE_PER_TARGET_RUNTIME_DIR by default on Linux"
Louis Dionne [Fri, 27 Aug 2021 14:01:29 +0000 (10:01 -0400)]
Revert "[CMake] Enable LLVM_ENABLE_PER_TARGET_RUNTIME_DIR by default on Linux"

This reverts commit abb956370ee71d018e9a88ae196f039f6c4e0dae, which broke
the libc++ CI on Linux.

2 years ago[clang-format] Group options that pack constructor initializers
owenca [Wed, 25 Aug 2021 23:22:02 +0000 (16:22 -0700)]
[clang-format] Group options that pack constructor initializers

Add a new option PackConstructorInitializers and deprecate the
related options ConstructorInitializerAllOnOneLineOrOnePerLine and
AllowAllConstructorInitializersOnNextLine. Below is the mapping:

PackConstructorInitializers  ConstructorInitializer... AllowAll...
        Never                            -                  -
        BinPack                        false                -
        CurrentLine                    true               false
        NextLine                       true               true

The option value Never fixes PR50549 by always placing each
constructor initializer on its own line.

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

2 years agoGlobalISel: Remove check for empty functions as these are invalid IR
Matt Arsenault [Fri, 27 Aug 2021 13:18:26 +0000 (09:18 -0400)]
GlobalISel: Remove check for empty functions as these are invalid IR

2 years ago[lld/COFF] Ignore /LTCG, /LTCG:, /LTCGOUT:, /ILK: flags
Nico Weber [Fri, 27 Aug 2021 02:03:26 +0000 (22:03 -0400)]
[lld/COFF] Ignore /LTCG, /LTCG:, /LTCGOUT:, /ILK: flags

We currently complain "could not open /LTCG: no such file or directory",
which isn't very useful.  We could emit a warning when we see this flag, but
just ignoring it seems fine.

Final missing part of PR38799.

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

2 years ago[lld/COFF] Use P_priv more
Nico Weber [Fri, 27 Aug 2021 02:01:00 +0000 (22:01 -0400)]
[lld/COFF] Use P_priv more

P_priv does the same as the old QF further down. Standardize on P_priv.

No behavior change.

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

2 years ago[analyzer] MallocOverflow should consider comparisons only preceding malloc
Balazs Benics [Fri, 27 Aug 2021 12:41:26 +0000 (14:41 +0200)]
[analyzer] MallocOverflow should consider comparisons only preceding malloc

MallocOverflow works in two phases:

1) Collects suspicious malloc calls, whose argument is a multiplication
2) Filters the aggregated list of suspicious malloc calls by iterating
   over the BasicBlocks of the CFG looking for comparison binary
   operators over the variable constituting in any suspicious malloc.

Consequently, it suppressed true-positive cases when the comparison
check was after the malloc call.
In this patch the checker will consider the relative position of the
relation check to the malloc call.

E.g.:

```lang=C++
void *check_after_malloc(int n, int x) {
  int *p = NULL;
  if (x == 42)
    p = malloc(n * sizeof(int)); // Previously **no** warning, now it
                                 // warns about this.

  // The check is after the allocation!
  if (n > 10) {
    // Do something conditionally.
  }
  return p;
}
```

Reviewed By: martong

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

2 years ago[GlobalOpt] don't hoist constant expressions that can trap
Sanjay Patel [Fri, 27 Aug 2021 12:09:28 +0000 (08:09 -0400)]
[GlobalOpt] don't hoist constant expressions that can trap

We try to forward a stored-once-constant-value from one global access
to another, but that's not safe if the constant value is an expression
that can trap.

The tests are reduced from the miscompile examples in:
https://llvm.org/PR47578

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

2 years ago[AArch64][SVE] Optimize ptrue predicate pattern with known sve register width.
Jun Ma [Wed, 25 Aug 2021 11:25:38 +0000 (19:25 +0800)]
[AArch64][SVE] Optimize ptrue predicate pattern with known sve register width.

For vectors that are exactly equal to getMaxSVEVectorSizeInBits, just use
AArch64SVEPredPattern::all, which can enable the use of unpredicated ptrue when available.

TestPlan: check-llvm

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

2 years ago[AArch64][SVE] Add API for conversion between SVE predicate pattern and element numbe...
Jun Ma [Wed, 25 Aug 2021 09:25:39 +0000 (17:25 +0800)]
[AArch64][SVE] Add API for conversion between SVE predicate pattern and element number. NFC

This patch solely moves convert operation between SVE predicate pattern
and element number into two small functions. It's pre-commit patch for optimize
pture with known sve register width.

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

2 years ago[AArch64][SVE] Use getPTrue uniformly.NFC.
Jun Ma [Wed, 25 Aug 2021 07:43:18 +0000 (15:43 +0800)]
[AArch64][SVE] Use getPTrue uniformly.NFC.

2 years ago [MCA][NFC] Removed unused method, and fixed a coverity issue.
Andrea Di Biagio [Fri, 27 Aug 2021 11:48:30 +0000 (12:48 +0100)]
 [MCA][NFC] Removed unused method, and fixed a coverity issue.

The coverity issue was reported agaist class MCAOperand
due to the lack of proper initialization for field Index.

No functional change intended.

2 years ago[openmp][amdgpu] Initial gfx10 offloading implementation
Jon Chesterfield [Fri, 27 Aug 2021 11:34:02 +0000 (12:34 +0100)]
[openmp][amdgpu] Initial gfx10 offloading implementation

Lets wavefront size be 32 for amdgpu openmp, as well as 64.

Fixes up as little as possible to pass that through the libraries. This change
is end to end, as opposed to updating clang/devicertl/plugin separately. It can
be broken up for review/commit if preferred. Posting as-is so that others with
a gfx10 can try it out. It works roughly as well as gfx9 for me, but there are
probably bugs remaining as well as the todo: for letting grid values vary more.

Reviewed By: ronlieb

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

2 years ago[X86] Implement llvm.isnan(x86_fp80) as unordered comparison
Serge Pavlov [Fri, 13 Aug 2021 09:52:29 +0000 (16:52 +0700)]
[X86] Implement llvm.isnan(x86_fp80) as unordered comparison

x86_fp80 format allows values that do not fit any of IEEE-754 category.
Previously they were recognized by intrinsic __builtin_isnan as NaNs.
Now this intrinsic is implemented using instruction FXAM, which
distinguish between NaNs and unsupported values. It can make some
programs behave differently.

As a solution, this fix changes lowering of the intrinsic. If floating
point exceptions are ignored, llvm.isnan is lowered into unordered
comparison, as __buildtin_isnan was implemented earlier. In strictfp
functions the intrinsic is lowered using FXAM, which does not raise
exceptions even for signaling NaN, as required by IEEE-754 and C
standards.

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

2 years ago[NFC][X86] Sret return register cleanup
Nathan Sidwell [Thu, 26 Aug 2021 11:05:25 +0000 (04:05 -0700)]
[NFC][X86] Sret return register cleanup

There are no paths into LowerFormalParms that have already specified
the sret register. We always materialize a virtual and then assign it
to the physical reg at the point of the return.

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

2 years ago[DAGCombine] Allow FMA combine with both FMA and FMAD
Carl Ritson [Fri, 27 Aug 2021 10:08:10 +0000 (19:08 +0900)]
[DAGCombine] Allow FMA combine with both FMA and FMAD

Without this change only the preferred fusion opcode is tested
when attempting to combine FMA operations.
If both FMA and FMAD are available then FMA ops formed prior to
legalization will not be merged post legalization as FMAD becomes
the preferred fusion opcode.

Reviewed By: foad

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

2 years ago[M68k] Update pointer data layout
Ricky Taylor [Thu, 26 Aug 2021 21:13:28 +0000 (22:13 +0100)]
[M68k] Update pointer data layout

Fixes PR51626.

The M68k requires that all instruction, word and long word reads are
aligned to word boundaries. From the 68020 onwards, there is a
performance benefit from aligning long words to long word boundaries.

The M68k uses the same data layout for pointers and integers.

In line with this, this commit updates the pointer data layout to
match the layout already set for 32-bit integers: 32:16:32.

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

2 years ago[X86] AMD Zen 3: MULX w/ mem operand has the same throughput as with reg op
Roman Lebedev [Fri, 27 Aug 2021 10:23:27 +0000 (13:23 +0300)]
[X86] AMD Zen 3: MULX w/ mem operand has the same throughput as with reg op

Exegesis is faulty and sometimes when measuring throughput^-1
produces snippets that have loop-carried dependencies,
which must be what caused me to incorrectly measure it originally.

After looking much more carefully, the inverse throughput should match
that of the MULX w/ reg op.

As per llvm-exegesis measurements.

2 years ago[X86] AMD Zen 3: MULX produces low part of the result in 3cy, +1cy for high part
Roman Lebedev [Fri, 27 Aug 2021 10:01:36 +0000 (13:01 +0300)]
[X86] AMD Zen 3: MULX produces low part of the result in 3cy, +1cy for high part

As per llvm-exegesis measurements.

2 years ago[NFC][X86][MCA] AMD Zen 3: improve MULX test coverage
Roman Lebedev [Fri, 27 Aug 2021 09:12:57 +0000 (12:12 +0300)]
[NFC][X86][MCA] AMD Zen 3: improve MULX test coverage

Latency for MULX isn't right

2 years ago[docs] Add DIA register instructions to Getting Started with Visual Studio page
Yaron Keren [Fri, 27 Aug 2021 09:14:58 +0000 (12:14 +0300)]
[docs] Add DIA register instructions to Getting Started with Visual Studio page

Since Visual Studio 2017 the DIA libs are not registered by default, see:
https://docs.microsoft.com/en-us/visualstudio/extensibility/breaking-changes-2017?view=vs-2019#change-reduce-registry-impact
LLDB building instruction already specify registering these DLLs, required
both the LLVM PDB tests and LLDB build.

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

2 years ago[analyzer] Catch leaking stack addresses via stack variables
Balazs Benics [Fri, 27 Aug 2021 09:31:16 +0000 (11:31 +0200)]
[analyzer] Catch leaking stack addresses via stack variables

Not only global variables can hold references to dead stack variables.
Consider this example:

  void write_stack_address_to(char **q) {
    char local;
    *q = &local;
  }

  void test_stack() {
    char *p;
    write_stack_address_to(&p);
  }

The address of 'local' is assigned to 'p', which becomes a dangling
pointer after 'write_stack_address_to()' returns.

The StackAddrEscapeChecker was looking for bindings in the store which
referred to variables of the popped stack frame, but it only considered
global variables in this regard. This patch relaxes this, catching
stack variable bindings as well.

---

This patch also works for temporary objects like:

  struct Bar {
    const int &ref;
    explicit Bar(int y) : ref(y) {
      // Okay.
    } // End of the constructor call, `ref` is dangling now. Warning!
  };

  void test() {
    Bar{33}; // Temporary object, so the corresponding memregion is
             // *not* a VarRegion.
  }

---

The return value optimization aka. copy-elision might kick in but that
is modeled by passing an imaginary CXXThisRegion which refers to the
parent stack frame which is supposed to be the 'return slot'.
Objects residing in the 'return slot' outlive the scope of the inner
call, thus we should expect no warning about them - except if we
explicitly disable copy-elision.

Reviewed By: NoQ, martong

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

2 years agopolly: remove the old reference to svn in the doc
Sylvestre Ledru [Fri, 27 Aug 2021 08:46:50 +0000 (10:46 +0200)]
polly: remove the old reference to svn in the doc

2 years ago[clang] Move the soname declaration in a variable at the top of the file
Sylvestre Ledru [Fri, 27 Aug 2021 07:06:52 +0000 (09:06 +0200)]
[clang] Move the soname declaration in a variable at the top of the file

Currently, it is a bit buried in the file even if this is
pretty important for distro.

Reviewed By: MaskRay

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

2 years ago[NFC] [ASTReader] Remove unused variables
Chuanqi Xu [Fri, 27 Aug 2021 06:00:03 +0000 (14:00 +0800)]
[NFC] [ASTReader] Remove unused variables

2 years ago[gn build] Port b749ef9e2241
LLVM GN Syncbot [Fri, 27 Aug 2021 04:42:51 +0000 (04:42 +0000)]
[gn build] Port b749ef9e2241

2 years ago[ORC][ORC-RT] Reapply "Introduce ELF/*nix Platform and runtime..." with fixes.
Lang Hames [Thu, 26 Aug 2021 21:52:40 +0000 (07:52 +1000)]
[ORC][ORC-RT] Reapply "Introduce ELF/*nix Platform and runtime..." with fixes.

This reapplies e256445bfff, which was reverted in 45ac5f54418 due to bot errors
(e.g. https://lab.llvm.org/buildbot/#/builders/112/builds/8599). The issue that
caused the bot failure was fixed in 2e6a4fce356.

2 years ago[ORC][JITLink][ELF] Treat STB_GNU_UNIQUE as Weak in the JIT.
Lang Hames [Thu, 26 Aug 2021 21:47:58 +0000 (07:47 +1000)]
[ORC][JITLink][ELF] Treat STB_GNU_UNIQUE as Weak in the JIT.

This should fix the bot error in
https://lab.llvm.org/buildbot/#/builders/112/builds/8599
which forced reversion of the ELFNixPlatform in 45ac5f54418.

This should allow us to re-enable the ELFNixPlatform in a follow-up patch.

2 years agoAMDGPU: Fix hardcoded registers in test
Matt Arsenault [Sun, 15 Aug 2021 01:16:42 +0000 (21:16 -0400)]
AMDGPU: Fix hardcoded registers in test

2 years agoAMDGPU/GlobalISel: Add baseline test for new ABI attribute hints
Matt Arsenault [Sat, 14 Aug 2021 23:01:27 +0000 (19:01 -0400)]
AMDGPU/GlobalISel: Add baseline test for new ABI attribute hints

2 years agoAMDGPU: Remove implicit argument attributes when introducing new calls
Matt Arsenault [Fri, 13 Aug 2021 17:28:57 +0000 (13:28 -0400)]
AMDGPU: Remove implicit argument attributes when introducing new calls

In a future patch, a new set of amdgpu-no-* attributes will be
introduced to indicate when a function does not need an implicitly
passed input. This pass introduces new instances of these intrinsic
calls, and should remove the attributes if they were present before.

2 years agoAMDGPU: Fix broken test
Matt Arsenault [Fri, 27 Aug 2021 02:04:13 +0000 (22:04 -0400)]
AMDGPU: Fix broken test

2 years ago[PowerPC][ELF] make sure local variable space does not overlap with parameter save...
Chen Zheng [Thu, 1 Jul 2021 09:41:03 +0000 (09:41 +0000)]
[PowerPC][ELF] make sure local variable space does not overlap with parameter save area

Reviewed By: jsji

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

2 years agoAMDGPU: Invert AMDGPUAttributor
Matt Arsenault [Wed, 11 Aug 2021 22:33:40 +0000 (18:33 -0400)]
AMDGPU: Invert AMDGPUAttributor

Switch to using BitIntegerState for each of the inputs, and invert
their meanings.

This now diverges more from the old AMDGPUAnnotateKernelFeatures, but
this isn't used yet anyway.

2 years agoAMDGPU: Fix broken check lines
Matt Arsenault [Sat, 14 Aug 2021 17:24:54 +0000 (13:24 -0400)]
AMDGPU: Fix broken check lines

2 years agoGlobalISel: Add CallBase to CallLoweringInfo
Matt Arsenault [Sat, 14 Aug 2021 19:58:17 +0000 (15:58 -0400)]
GlobalISel: Add CallBase to CallLoweringInfo

The DAG version has this, and is necessary for call lowering to take
advantage of any attributes at the call site.

2 years agoAMDGPU: Restrict attributor transforms
Matt Arsenault [Fri, 13 Aug 2021 18:20:00 +0000 (14:20 -0400)]
AMDGPU: Restrict attributor transforms

We only really want this to add the custom attributes. Theoretically
the regular transforms were already run at this point. Touching
undefined behavior breaks a lot of tests when this is enabled by
default, many of which are expecting to test handling of undef
operations.

2 years ago[libomptarget][NFC] Replaced obsolete name "getOrAllocTgtPtr" with new "getTargetPoin...
George Rokos [Fri, 27 Aug 2021 01:00:05 +0000 (18:00 -0700)]
[libomptarget][NFC] Replaced obsolete name "getOrAllocTgtPtr" with new "getTargetPointer" in debug messages.

2 years agoAMDGPU: Remove hacky attribute deduction from AMDGPUAttributor
Matt Arsenault [Wed, 11 Aug 2021 23:01:30 +0000 (19:01 -0400)]
AMDGPU: Remove hacky attribute deduction from AMDGPUAttributor

amdgpu-calls and amdgpu-stack-objects don't really belong as
attributes, and are currently a hacky way of passing an analysis into
the DAG. These don't really belong in the IR, and don't really fit in
with the other attributes. Remove these to facilitate inverting the
pass.

I don't exactly understand the indirect call test changes. These tests
are using calls which are trivially replacable with a direct call, so
I'm not sure what the point is.

2 years agoAMDGPU: Stop inferring use of llvm.amdgcn.kernarg.segment.ptr
Matt Arsenault [Sat, 14 Aug 2021 00:43:32 +0000 (20:43 -0400)]
AMDGPU: Stop inferring use of llvm.amdgcn.kernarg.segment.ptr

We no longer use this intrinsic outside of the backend and no longer
support using it outside of kernels.

2 years ago[WebAssembly] Fix PHI when relaying longjmps
Heejin Ahn [Thu, 26 Aug 2021 19:25:03 +0000 (12:25 -0700)]
[WebAssembly] Fix PHI when relaying longjmps

When doing Emscritpen EH, if SjLj is also enabled and used and if the
thrown exception has a possiblity being a longjmp instead of an
exception, we shouldn't swallow it; we should rethrow, or relay it. It
was done in D106525 and the code is here:
https://github.com/llvm/llvm-project/blob/8441a8eea8007b9eaaaabf76055949180a702d6d/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp#L858-L898

Here is the pseudocode of that part: (copied from comments)
```
if (%__THREW__.val == 0 || %__THREW__.val == 1)
  goto %tail
else
  goto %longjmp.rethrow

longjmp.rethrow: ;; This is longjmp. Rethrow it
  %__threwValue.val = __threwValue
  emscripten_longjmp(%__THREW__.val, %__threwValue.val);

tail: ;; Nothing happened or an exception is thrown
  ... Continue exception handling ...
```

If the current BB (where the `invoke` is created) has successors that
has the current BB as its PHI incoming node, now that has to change to
`tail` in the pseudocode, because `tail` is the latest BB that is
connected with the next BB, but this was missing.

Reviewed By: tlively

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

2 years agoRemove set-but-unused variable
David Blaikie [Wed, 25 Aug 2021 19:03:53 +0000 (12:03 -0700)]
Remove set-but-unused variable

2 years ago[sanitizer] No THREADLOCAL in qsort and bsearch
Vitaly Buka [Thu, 26 Aug 2021 17:25:09 +0000 (10:25 -0700)]
[sanitizer] No THREADLOCAL in qsort and bsearch

qsort can reuse qsort_r if available.
bsearch always passes key as the first comparator argument, so we
can use it to wrap the original comparator.

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

2 years agoAMDGPU: Remove unnecessary -NEXT checks
Matt Arsenault [Sat, 14 Aug 2021 15:00:47 +0000 (11:00 -0400)]
AMDGPU: Remove unnecessary -NEXT checks

This avoids spuriously breaking the test in a future change

2 years agoAMDGPU: Fix amdgpu_gfx calling convention usage in test
Matt Arsenault [Sat, 14 Aug 2021 15:58:07 +0000 (11:58 -0400)]
AMDGPU: Fix amdgpu_gfx calling convention usage in test

This was calling a regular C function from amdgpu_gfx, which isn't
defined to have all of the necessary implicit arguments.

2 years ago[lld-macho][nfc] Clean up InputSection constructors
Jez Ng [Thu, 8 Jul 2021 16:31:37 +0000 (12:31 -0400)]
[lld-macho][nfc] Clean up InputSection constructors

2 years ago[CUDA] update constraints on NVPTX builtins to include PTX73 and 74.
Artem Belevich [Thu, 26 Aug 2021 23:00:18 +0000 (16:00 -0700)]
[CUDA] update constraints on NVPTX builtins to include PTX73 and 74.

2 years agoAMDGPU: Fix crashing on kernel declarations when lowering LDS
Matt Arsenault [Thu, 26 Aug 2021 21:41:33 +0000 (17:41 -0400)]
AMDGPU: Fix crashing on kernel declarations when lowering LDS

This was trying to insert the used marker into a declaration.

2 years ago[lld-macho] Have -ObjC load archive members before symbol resolution
Jez Ng [Thu, 26 Aug 2021 17:51:38 +0000 (13:51 -0400)]
[lld-macho] Have -ObjC load archive members before symbol resolution

This is what ld64 does. Deviating in behavior here can result
in some subtle duplicate symbol errors, as detailed in the objc.s test.

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

2 years ago[lld-macho] Refactor archive loading
Jez Ng [Thu, 26 Aug 2021 15:49:47 +0000 (11:49 -0400)]
[lld-macho] Refactor archive loading

The previous logic was duplicated between symbol-initiated
archive loads versus flag-initiated loads (i.e. `-force_load` and
`-ObjC`). This resulted in code duplication as well as redundant work --
we would create Archive instances twice whenever we had one of those
flags; once in `getArchiveMembers` and again when we constructed the
ArchiveFile.

This was motivated by an upcoming diff where we load archive members
containing ObjC-related symbols before loading those containing
ObjC-related sections, as well as before performing symbol resolution.
Without this refactor, it would be difficult to do that while avoiding
loading the same archive member twice.

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

2 years ago[lld-macho] Fix unwind info personality size
Jez Ng [Thu, 26 Aug 2021 02:46:48 +0000 (22:46 -0400)]
[lld-macho] Fix unwind info personality size

This was missed by {D107035}. This fix addresses the following warning:

  loop variable 'personality' has type 'const uint32_t &' (aka 'const unsigned int &') but is initialized with type 'const unsigned long long' resulting in a copy [-Wrange-loop-analysis]

In addition to fixing the size, I also removed the const reference,
since there's no performance benefit to avoiding copies of integer-sized
values.

2 years ago[mlir][spirv] Initial support for 64 bit index type and builtins
Butygin [Sat, 14 Aug 2021 08:57:02 +0000 (11:57 +0300)]
[mlir][spirv] Initial support for 64 bit index type and builtins

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

2 years ago[AST] Pick last tentative definition as the acting definition
Benson Chu [Sun, 15 Aug 2021 18:12:21 +0000 (13:12 -0500)]
[AST] Pick last tentative definition as the acting definition

Clang currently picks the second tentative definition when
VarDecl::getActingDefinition is called.

This can lead to attributes being dropped if they are attached to
tentative definitions that appear after the second one. This is
because VarDecl::getActingDefinition loops through VarDecl::redecls
assuming that the last tentative definition is the last element in the
iterator. However, it is the second element that would be the last
tentative definition.

This changeset modifies getActingDefinition to iterate through the
declaration chain in reverse, so that it can immediately return when
it encounters a tentative definition.

Originally the unit test for this changeset did not have a -triple
flag for the clang invocation, leading to this test being broken on
MacOS, since Mach-O does not support the section attribute.

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

2 years ago[clang][NewPM] Mention that legacy PM flags are deprecated
Arthur Eubanks [Thu, 26 Aug 2021 21:32:06 +0000 (14:32 -0700)]
[clang][NewPM] Mention that legacy PM flags are deprecated

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

2 years ago[DebugInfo] convert btf_tag attrs to DI annotations for func parameters
Yonghong Song [Thu, 26 Aug 2021 18:25:04 +0000 (11:25 -0700)]
[DebugInfo] convert btf_tag attrs to DI annotations for func parameters

Generate btf_tag annotations for DILocalVariable. The annotations
are represented as an DINodeArray in DebugInfo.

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

2 years ago[CMake] Change -DENABLE_EXPERIMENTAL_NEW_PASS_MANAGER=off to -DLLVM_ENABLE_NEW_PASS_M...
Fangrui Song [Thu, 26 Aug 2021 21:25:31 +0000 (14:25 -0700)]
[CMake] Change -DENABLE_EXPERIMENTAL_NEW_PASS_MANAGER=off to -DLLVM_ENABLE_NEW_PASS_MANAGER=off

LLVM_ENABLE_NEW_PASS_MANAGER is set to ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER, so
-DLLVM_ENABLE_NEW_PASS_MANAGER=off has no effect.

Change the cache variable to LLVM_ENABLE_NEW_PASS_MANAGER instead.
A user opting out the new PM needs to switch from
-DENABLE_EXPERIMENTAL_NEW_PASS_MANAGER=off to
-DLLVM_ENABLE_NEW_PASS_MANAGER=off.

Also give a warning that -DLLVM_ENABLE_NEW_PASS_MANAGER=off is deprecated.

Reviewed By: aeubanks, phosek

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

2 years ago[DebugInfo] generate btf_tag annotations for func parameters
Yonghong Song [Mon, 19 Jul 2021 16:11:10 +0000 (09:11 -0700)]
[DebugInfo] generate btf_tag annotations for func parameters

Generate btf_tag annotations for function parameters.
A field "annotations" is introduced to DILocalVariable, and
annotations are represented as an DINodeArray, similar to
DIComposite elements. The following example illustrates how
annotations are encoded in IR:
    distinct !DILocalVariable(name: "info",, arg: 1, ..., annotations: !10)
    !10 = !{!11, !12}
    !11 = !{!"btf_tag", !"a"}
    !12 = !{!"btf_tag", !"b"}

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

2 years ago[analyzer] Fix scan-build report deduplication.
Artem Dergachev [Thu, 26 Aug 2021 04:33:38 +0000 (21:33 -0700)]
[analyzer] Fix scan-build report deduplication.

The previous behavior was to deduplicate reports based on md5 of the
html file. This algorithm might have worked originally but right now
HTML reports contain information rich enough to make them virtually
always distinct which breaks deduplication entirely.

The new strategy is to (finally) take advantage of IssueHash - the
stable report identifier provided by clang that is the same if and only if
the reports are duplicates of each other.

Additionally, scan-build no longer performs deduplication on its own.
Instead, the report file name is now based on the issue hash,
and clang instances will silently refuse to produce a new html file
when a duplicate already exists. This eliminates the problem entirely.

The '-analyzer-config stable-report-filename' option is deprecated
because report filenames are no longer unstable. A new option is
introduced, '-analyzer-config verbose-report-filename', to produce
verbose file names that look similar to the old "stable" file names.
The old option acts as an alias to the new option.

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

2 years ago[asan] Implemented flag to emit intrinsics to optimize ASan callbacks.
Kirill Stoimenov [Thu, 19 Aug 2021 17:58:29 +0000 (17:58 +0000)]
[asan] Implemented flag to emit intrinsics to optimize ASan callbacks.

Reviewed By: vitalybuka

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

2 years ago[asan] Fixed a runtime crash.
Kirill Stoimenov [Thu, 26 Aug 2021 00:12:53 +0000 (00:12 +0000)]
[asan] Fixed a runtime crash.

Looks like the NoRegister has some effect on the final code that is generated. My guess is that some optimization kicks in at the end?

When I use -S to dump the assembly I get the correct version with 'shrq    $3, %r8':
        movq    %r9, %r8
        shrq    $3, %r8
        movsbl  2147450880(%r8), %r8d

But, when I disassemble the final binary I get RAX in stead of R8:
        mov    %r9,%r8
        shr    $0x3,%rax
        movsbl 0x7fff8000(%r8),%r8d

Reviewed By: vitalybuka

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

2 years ago[mlir][tosa] Tosa reverse to linalg supporting dynamic shapes
Rob Suderman [Thu, 26 Aug 2021 18:20:58 +0000 (11:20 -0700)]
[mlir][tosa] Tosa reverse to linalg supporting dynamic shapes

Needed to switch to extract to support tosa.reverse using dynamic shapes.

Reviewed By: NatashaKnk

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

2 years ago[SLP]Improve graph reordering.
Alexey Bataev [Tue, 3 Aug 2021 20:20:32 +0000 (13:20 -0700)]
[SLP]Improve graph reordering.

Reworked reordering algorithm. Originally, the compiler just tried to
detect the most common order in the reordarable nodes (loads, stores,
extractelements,extractvalues) and then fully rebuilding the graph in
the best order. This was not effecient, since it required an extra
memory and time for building/rebuilding tree, double the use of the
scheduling budget, which could lead to missing vectorization due to
exausted scheduling resources.

Patch provide 2-way approach for graph reodering problem. At first, all
reordering is done in-place, it doe not required tree
deleting/rebuilding, it just rotates the scalars/orders/reuses masks in
the graph node.

The first step (top-to bottom) rotates the whole graph, similarly to the previous
implementation. Compiler counts the number of the most used orders of
the graph nodes with the same vectorization factor and then rotates the
subgraph with the given vectorization factor to the most used order, if
it is not empty. Then repeats the same procedure for the subgraphs with
the smaller vectorization factor. We can do this because we still need
to reshuffle smaller subgraph when buildiong operands for the graph
nodes with lasrger vectorization factor, we can rotate just subgraph,
not the whole graph.

The second step (bottom-to-top) scans through the leaves and tries to
detect the users of the leaves which can be reordered. If the leaves can
be reorder in the best fashion, they are reordered and their user too.
It allows to remove double shuffles to the same ordering of the operands in
many cases and just reorder the user operations instead. Plus, it moves
the final shuffles closer to the top of the graph and in many cases
allows to remove extra shuffle because the same procedure is repeated
again and we can again merge some reordering masks and reorder user nodes
instead of the operands.

Also, patch improves cost model for gathering of loads, which improves
x264 benchmark in some cases.

Gives about +2% on AVX512 + LTO (more expected for AVX/AVX2) for {625,525}x264,
+3% for 508.namd, improves most of other benchmarks.
The compile and link time are almost the same, though in some cases it
should be better (we're not doing an extra instruction scheduling
anymore) + we may vectorize more code for the large basic blocks again
because of saving scheduling budget.

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

2 years ago[MergeICmps] Add test for call before first load (NFC)
Nikita Popov [Thu, 26 Aug 2021 19:12:11 +0000 (21:12 +0200)]
[MergeICmps] Add test for call before first load (NFC)

If a clobbering call happens before all loads, that shouldn't
block the transform.

2 years ago[test] Update precommit tests for D108734
Arthur Eubanks [Thu, 26 Aug 2021 19:05:56 +0000 (12:05 -0700)]
[test] Update precommit tests for D108734

2 years ago[sanitizer] Add basic qsort test
Vitaly Buka [Thu, 26 Aug 2021 19:02:45 +0000 (12:02 -0700)]
[sanitizer] Add basic qsort test

2 years ago[libomptarget][amdgpu][nfc] Rename variables, delete dead code
Jon Chesterfield [Thu, 26 Aug 2021 17:56:01 +0000 (18:56 +0100)]
[libomptarget][amdgpu][nfc] Rename variables, delete dead code

2 years agoRevert "[MCA][NFC] Remove redundant calls to std::move."
Andrea Di Biagio [Thu, 26 Aug 2021 18:53:17 +0000 (19:53 +0100)]
Revert "[MCA][NFC] Remove redundant calls to std::move."

This reverts commit 9cc0023fb863194be526f0bf19bd21e36236c5f6.
due to buildbot failures.

2 years ago[libc][NFC] Move the mutex implementation into a utility class.
Siva Chandra Reddy [Thu, 26 Aug 2021 05:21:54 +0000 (05:21 +0000)]
[libc][NFC] Move the mutex implementation into a utility class.

This allows others parts of the libc to use the mutex types without
actually pulling in public function implementations.

Along the way, few cleanups have been done, like using a uniform type to
refer the linux futex word.

Reviewed By: michaelrj

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

2 years ago[MCA][NFC] Remove redundant calls to std::move.
Andrea Di Biagio [Thu, 26 Aug 2021 18:43:18 +0000 (19:43 +0100)]
[MCA][NFC] Remove redundant calls to std::move.

This fixes some redundant move in return statement [-Wredundant-move] gcc 9.3.0
warnings.

This also fixes a minor coverity issue reported agaist class MCAOperand about
the lack of proper initialization for field Index.

No functional change intended.

2 years ago[AArch64][GlobalISel] Optimize G_BUILD_VECTOR of undef + 1 elt -> SUBREG_TO_REG
Jessica Paquette [Thu, 26 Aug 2021 18:04:17 +0000 (11:04 -0700)]
[AArch64][GlobalISel] Optimize G_BUILD_VECTOR of undef + 1 elt -> SUBREG_TO_REG

This pattern

```
%elt = ... something ...
%undef = G_IMPLICIT_DEF
%vec = G_BUILD_VECTOR %elt, %undef, %undef, ... %undef
```

Can be selected to a SUBREG_TO_REG, assuming `%elt` and `%vec` have the same
register bank. We don't care about any of the bits in `%vec` aside from those
in `%elt`, which just happens to be the 0th element.

This is preferable to emitting `mov` instructions for every index.

This gives minor code size improvements on the test suite at -Os.

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

2 years ago[docs, AMDGPU] Fix typo in dwarf register number mapping
RamNalamothu [Thu, 26 Aug 2021 18:24:15 +0000 (23:54 +0530)]
[docs, AMDGPU] Fix typo in dwarf register number mapping

Reviewed By: xgupta

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

2 years ago[docs] Update Getting Started with Visual Studio guide
Yaron Keren [Sat, 21 Aug 2021 17:59:45 +0000 (20:59 +0300)]
[docs] Update Getting Started with Visual Studio guide

Update this document for 2021.

Reviewed By: aaron.ballman, kuhnel, amccarth

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

2 years ago[mlir][tosa] Elementwise operation dynamic shape support
Rob Suderman [Thu, 26 Aug 2021 18:06:12 +0000 (11:06 -0700)]
[mlir][tosa] Elementwise operation dynamic shape support

Added dynamic shape support for elementwise operations. This assumes equal
sizes (broadcasting 1-length dynamic is problematic).

Reviewed By: NatashaKnk

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

2 years ago[libc++][NFC] Sort headers alphabetically
Louis Dionne [Thu, 26 Aug 2021 18:18:03 +0000 (14:18 -0400)]
[libc++][NFC] Sort headers alphabetically

2 years ago[LLDB] Add type to the output for FieldDecl when logging in ClangASTSource::layoutRec...
Shafik Yaghmour [Thu, 26 Aug 2021 18:11:00 +0000 (11:11 -0700)]
[LLDB] Add type to the output for FieldDecl when logging in ClangASTSource::layoutRecordType

I was debugging a problem and noticed that it would have been helpful to have
the type of each FieldDecl when looking at the output from
ClangASTSource::layoutRecordType.

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

2 years ago[MCA][RegisterFile] Consistently update the PRF in the presence of multiple writes...
Andrea Di Biagio [Thu, 26 Aug 2021 17:57:59 +0000 (18:57 +0100)]
[MCA][RegisterFile] Consistently update the PRF in the presence of multiple writes to the same register.

My last change to the RegisterFile (PR51495) has introduced a bug in the logic
that allocates physical registers in the PRF.

In some cases, this bug could have triggered a nasty unsigned wrap in the number
of allocated registers, thus resulting in mca being stuck forever in a loop of
PRF availability checks.

2 years ago[gn build] Port ee44dd8062a2
LLVM GN Syncbot [Thu, 26 Aug 2021 18:08:07 +0000 (18:08 +0000)]
[gn build] Port ee44dd8062a2

2 years ago[libc++] Implement the underlying mechanism for range adaptors
Louis Dionne [Wed, 11 Aug 2021 21:36:35 +0000 (17:36 -0400)]
[libc++] Implement the underlying mechanism for range adaptors

This patch implements the underlying mechanism for range adaptors. It
does so based on http://wg21.link/p2387, even though that paper hasn't
been adopted yet. In the future, if p2387 is adopted, it would suffice
to rename `__bind_back` to `std::bind_back` and `__range_adaptor_closure`
to `std::range_adaptor_closure` to implement that paper by the spec.

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

2 years ago[libc] add inttypes header
Michael Jones [Wed, 25 Aug 2021 21:11:31 +0000 (21:11 +0000)]
[libc] add inttypes header

Add inttypes.h to llvm libc. As its first functions strtoimax and
strtoumax are included.

Reviewed By: sivachandra

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

2 years ago[SLP][NFC]Add a test for correct shuffles order after reordering.
Alexey Bataev [Thu, 26 Aug 2021 17:35:31 +0000 (10:35 -0700)]
[SLP][NFC]Add a test for correct shuffles order after reordering.

2 years ago[DebugInfo] convert btf_tag attrs to DI annotations for DIGlobalVariable
Yonghong Song [Thu, 26 Aug 2021 16:44:14 +0000 (09:44 -0700)]
[DebugInfo] convert btf_tag attrs to DI annotations for DIGlobalVariable

Generate btf_tag annotations for DIGlobalVariable. The annotations
are represented as an DINodeArray in DebugInfo.

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

2 years ago[NFC] Removing deprecated intel-features test folder
Walter Erquinigo [Thu, 26 Aug 2021 17:35:29 +0000 (10:35 -0700)]
[NFC] Removing deprecated intel-features test folder

This folder has no valid tests anymore

2 years ago[GlobalOpt] add tests for constant expressions that can trap; NFC
Sanjay Patel [Thu, 26 Aug 2021 16:33:42 +0000 (12:33 -0400)]
[GlobalOpt] add tests for constant expressions that can trap; NFC

https://llvm.org/PR47578

2 years ago[NFC] Remove deprecated Intel PT test
Walter Erquinigo [Thu, 26 Aug 2021 17:34:04 +0000 (10:34 -0700)]
[NFC] Remove deprecated Intel PT test

2 years ago[libomptarget][amdgpu][nfc] Rename source files
Jon Chesterfield [Thu, 26 Aug 2021 16:36:04 +0000 (17:36 +0100)]
[libomptarget][amdgpu][nfc] Rename source files

2 years ago[libc++] Fix incorrect bypassing of <wctype.h>
Louis Dionne [Wed, 25 Aug 2021 16:27:20 +0000 (12:27 -0400)]
[libc++] Fix incorrect bypassing of <wctype.h>

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

2 years ago[NFC][sanitizer] Swap qsort_r and qsort code
Vitaly Buka [Thu, 26 Aug 2021 17:21:20 +0000 (10:21 -0700)]
[NFC][sanitizer] Swap qsort_r and qsort code

To simplify future review.

2 years ago[libc++] XFAIL align.pass.cpp for PowerPC LE
Louis Dionne [Thu, 26 Aug 2021 17:21:29 +0000 (13:21 -0400)]
[libc++] XFAIL align.pass.cpp for PowerPC LE

This patch XFAILs the `align.pass.cpp` for PowerPC (LE).

It appears that this test will fail on Power for the `LLIArr2` and `Padding` structs within the test,
as the `assert` for `alignof(AtomicImpl) >= sizeof(AtomicImpl)` will be false. In this case, these structs
presumably should not be lock-free, so we currently XFAIL this for now.

The failure was discovered after D97913 was committed. It looks like `alignof(AtomicImpl) < sizeof(AtomicImpl)`,
even prior to this commit, but this test began running on Power after D97913, whereas we were
not running `align.pass.cpp` before.

This patch addresses https://bugs.llvm.org/show_bug.cgi?id=51548 by temporarily XFAILing the test
in order to investigate it further.

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

2 years ago[RISCV] Insert a sext_inreg when type legalizing i32 shl by constant on RV64.
Craig Topper [Thu, 26 Aug 2021 16:33:53 +0000 (09:33 -0700)]
[RISCV] Insert a sext_inreg when type legalizing i32 shl by constant on RV64.

Similar to what we do for add/sub/mul.

This can help remove some sext.w. There are some regressions on
some bswap tests, but I have an idea how to fix that for a follow up.

A new PACKW pattern is added to handle the new sext_inreg placement.

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

2 years ago[CMake] Enable LLVM_ENABLE_PER_TARGET_RUNTIME_DIR by default on Linux
Fangrui Song [Thu, 26 Aug 2021 17:13:16 +0000 (10:13 -0700)]
[CMake] Enable LLVM_ENABLE_PER_TARGET_RUNTIME_DIR by default on Linux

This makes the default build closer to a -DLLVM_ENABLE_RUNTIMES=all build.
The layout is arguably superior because different libraries of target triples
are in different directories, similar to GCC/Debian multiarch.

When LLVM_DEFAULT_TARGET_TRIPLE is x86_64-unknown-linux-gnu,
`lib/clang/14.0.0/lib/libclang_rt.asan-x86_64.a`
becomes
`lib/clang/14.0.0/lib/x86_64-unknown-linux-gnu/libclang_rt.asan.a`.

Clang has been detecting both paths since 2018 (D50547).

---

Note: Darwin needs to be disabled. The hierarchy needs to be sorted out.
The current -DLLVM_DEFAULT_TARGET_TRIPLE=off state is like:
```
lib/clang/14.0.0/lib/darwin/libclang_rt.profile_ios.a
lib/clang/14.0.0/lib/darwin/libclang_rt.profile_iossim.a
lib/clang/14.0.0/lib/darwin/libclang_rt.profile_osx.a
```

Windows needs to be disabled: https://reviews.llvm.org/D107799?id=368557#2963311

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

2 years ago[DebugInfo] generate btf_tag annotations for DIGlobalVariable
Yonghong Song [Mon, 19 Jul 2021 16:33:55 +0000 (09:33 -0700)]
[DebugInfo] generate btf_tag annotations for DIGlobalVariable

Generate btf_tag annotations for DIGlobalVariable.
A field "annotations" is introduced to DIGlobalVariable, and
annotations are represented as an DINodeArray, similar to
DIComposite elements. The following example illustrates how
annotations are encoded in IR:
    distinct !DIGlobalVariable(..., annotations: !10)
    !10 = !{!11, !12}
    !11 = !{!"btf_tag", !"a"}
    !12 = !{!"btf_tag", !"b"}

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

2 years ago[DWARFLinker] Prefix debug section names with '.' in the comments. NFC.
RamNalamothu [Thu, 26 Aug 2021 16:54:06 +0000 (22:24 +0530)]
[DWARFLinker] Prefix debug section names with '.' in the comments. NFC.

In DWARFLinker.h, some comments prefix the debug section names
with '.' while others do not.

Reviewed By: dblaikie

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

2 years agoTypo fix; NFC
Aaron Ballman [Thu, 26 Aug 2021 16:53:52 +0000 (12:53 -0400)]
Typo fix; NFC

2 years agoAdding an assertion back.
Aaron Ballman [Thu, 26 Aug 2021 16:39:12 +0000 (12:39 -0400)]
Adding an assertion back.

This assert was removed in 98339f14a0420cdfbe4215d8d1bc0a01165e0495,
but during post-commit review, it was pointed out that the assert was
valid.

2 years ago[CodeExtractor] Making the arguments outlined easier to access from the outside
Andrew Litteken [Thu, 26 Aug 2021 15:24:34 +0000 (08:24 -0700)]
[CodeExtractor] Making the arguments outlined easier to access from the outside

The Code Extractor does not provide an easy mechanism for determining the
inputs and outputs after extraction has occurred, this patch gives the
ability to pass in empty SetVectors to be filled with the inputs and
outputs if they need to be analyzed.

Added Tests:
- InputOutputMonitoring in unittests/Transforms/Utils/CodeExtractorTests.cpp

Reviewers: paquette

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